Skip to content

Commit

Permalink
Updated for Pepper 38
Browse files Browse the repository at this point in the history
- fixed for Pepper 38
- ozCore
  * SpinLock uses "pause" instruction on x86
- ports
  * updated and fixed for Pepper 38
  • Loading branch information
ducakar committed Dec 7, 2014
1 parent c895b66 commit 8d80ce6
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 41 deletions.
106 changes: 100 additions & 6 deletions etc/patches/openal-soft-1.16.0.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -Naur openal-soft-1.16.0.orig/Alc/ALc.c openal-soft-1.16.0/Alc/ALc.c
--- openal-soft-1.16.0.orig/Alc/ALc.c 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/Alc/ALc.c 2014-09-02 14:25:39.573760861 +0200
+++ openal-soft-1.16.0/Alc/ALc.c 2014-12-07 04:16:28.814302855 +0100
@@ -23,7 +23,7 @@
#include <math.h>
#include <stdlib.h>
Expand All @@ -20,9 +20,30 @@ diff -Naur openal-soft-1.16.0.orig/Alc/ALc.c openal-soft-1.16.0/Alc/ALc.c

{ "null", ALCnullBackendFactory_getFactory, NULL, NULL, NULL, EmptyFuncs },
#ifdef HAVE_WAVE
diff -Naur openal-soft-1.16.0.orig/Alc/ALu.c openal-soft-1.16.0/Alc/ALu.c
--- openal-soft-1.16.0.orig/Alc/ALu.c 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/Alc/ALu.c 2014-12-07 16:23:03.787207305 +0100
@@ -216,7 +216,7 @@
};

ALCdevice *Device = ALContext->Device;
- const ALsource *ALSource = src->Source;
+ ALsource *ALSource = src->Source;
ALfloat SourceVolume,ListenerGain,MinVolume,MaxVolume;
ALbufferlistitem *BufferListItem;
enum FmtChannels Channels;
@@ -566,7 +566,7 @@
ALvoid CalcSourceParams(ALactivesource *src, const ALCcontext *ALContext)
{
ALCdevice *Device = ALContext->Device;
- const ALsource *ALSource = src->Source;
+ ALsource *ALSource = src->Source;
ALfloat Velocity[3],Direction[3],Position[3],SourceToListener[3];
ALfloat InnerAngle,OuterAngle,Angle,Distance,ClampedDist;
ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff;
diff -Naur openal-soft-1.16.0.orig/Alc/backends/ppapi.c openal-soft-1.16.0/Alc/backends/ppapi.c
--- openal-soft-1.16.0.orig/Alc/backends/ppapi.c 1970-01-01 01:00:00.000000000 +0100
+++ openal-soft-1.16.0/Alc/backends/ppapi.c 2014-09-02 14:25:39.573760861 +0200
+++ openal-soft-1.16.0/Alc/backends/ppapi.c 2014-12-07 04:16:28.814302855 +0100
@@ -0,0 +1,320 @@
+/**
+ * OpenAL cross platform audio library
Expand Down Expand Up @@ -346,7 +367,7 @@ diff -Naur openal-soft-1.16.0.orig/Alc/backends/ppapi.c openal-soft-1.16.0/Alc/b
+}
diff -Naur openal-soft-1.16.0.orig/Alc/backends/wave.c openal-soft-1.16.0/Alc/backends/wave.c
--- openal-soft-1.16.0.orig/Alc/backends/wave.c 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/Alc/backends/wave.c 2014-09-02 14:25:39.573760861 +0200
+++ openal-soft-1.16.0/Alc/backends/wave.c 2014-12-07 04:16:28.814302855 +0100
@@ -22,7 +22,7 @@

#include <stdlib.h>
Expand All @@ -358,7 +379,7 @@ diff -Naur openal-soft-1.16.0.orig/Alc/backends/wave.c openal-soft-1.16.0/Alc/ba
#include <windows.h>
diff -Naur openal-soft-1.16.0.orig/CMakeLists.txt openal-soft-1.16.0/CMakeLists.txt
--- openal-soft-1.16.0.orig/CMakeLists.txt 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/CMakeLists.txt 2014-09-02 14:25:39.573760861 +0200
+++ openal-soft-1.16.0/CMakeLists.txt 2014-12-07 04:16:28.814302855 +0100
@@ -613,6 +613,7 @@
SET(HAVE_PULSEAUDIO 0)
SET(HAVE_COREAUDIO 0)
Expand Down Expand Up @@ -399,9 +420,19 @@ diff -Naur openal-soft-1.16.0.orig/CMakeLists.txt openal-soft-1.16.0/CMakeLists.
SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_BUILD_LIBRARY AL_ALEXT_PROTOTYPES)
IF(WIN32 AND ALSOFT_NO_UID_DEFS)
SET_PROPERTY(TARGET ${LIBNAME} APPEND PROPERTY COMPILE_DEFINITIONS AL_NO_UID_DEFS)
diff -Naur openal-soft-1.16.0.orig/common/atomic.c openal-soft-1.16.0/common/atomic.c
--- openal-soft-1.16.0.orig/common/atomic.c 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/common/atomic.c 2014-12-07 16:17:28.244652049 +0100
@@ -9,5 +9,5 @@
extern inline uint IncrementRef(RefCount *ptr);
extern inline uint DecrementRef(RefCount *ptr);

-extern inline int ExchangeInt(volatile int *ptr, int newval);
+extern inline int ExchangeInt(_Atomic int *ptr, int newval);
extern inline void *ExchangePtr(XchgPtr *ptr, void *newval);
diff -Naur openal-soft-1.16.0.orig/config.h.in openal-soft-1.16.0/config.h.in
--- openal-soft-1.16.0.orig/config.h.in 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/config.h.in 2014-09-02 14:25:39.573760861 +0200
+++ openal-soft-1.16.0/config.h.in 2014-12-07 04:16:28.814302855 +0100
@@ -70,6 +70,9 @@
/* Define if we have the OpenSL backend */
#cmakedefine HAVE_OPENSL
Expand All @@ -412,9 +443,72 @@ diff -Naur openal-soft-1.16.0.orig/config.h.in openal-soft-1.16.0/config.h.in
/* Define if we have the Wave Writer backend */
#cmakedefine HAVE_WAVE

diff -Naur openal-soft-1.16.0.orig/include/atomic.h openal-soft-1.16.0/include/atomic.h
--- openal-soft-1.16.0.orig/include/atomic.h 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/include/atomic.h 2014-12-07 16:27:28.013326214 +0100
@@ -8,14 +8,14 @@
extern "C" {
#endif

-typedef void *volatile XchgPtr;
+typedef void *_Atomic XchgPtr;

/* Atomics using C11 */
#ifdef HAVE_C11_ATOMIC

#include <stdatomic.h>

-inline int ExchangeInt(volatile int *ptr, int newval)
+inline int ExchangeInt(_Atomic int *ptr, int newval)
{ return atomic_exchange(ptr, newval); }
inline void *ExchangePtr(XchgPtr *ptr, void *newval)
{ return atomic_exchange(ptr, newval); }
diff -Naur openal-soft-1.16.0.orig/OpenAL32/alSource.c openal-soft-1.16.0/OpenAL32/alSource.c
--- openal-soft-1.16.0.orig/OpenAL32/alSource.c 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/OpenAL32/alSource.c 2014-12-07 16:24:42.703662445 +0100
@@ -53,9 +53,9 @@
extern inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id);

static ALvoid InitSourceParams(ALsource *Source);
-static ALint64 GetSourceOffset(const ALsource *Source);
-static ALdouble GetSourceSecOffset(const ALsource *Source);
-static ALvoid GetSourceOffsets(const ALsource *Source, ALenum name, ALdouble *offsets, ALdouble updateLen);
+static ALint64 GetSourceOffset(ALsource *Source);
+static ALdouble GetSourceSecOffset(ALsource *Source);
+static ALvoid GetSourceOffsets(ALsource *Source, ALenum name, ALdouble *offsets, ALdouble updateLen);
static ALint GetSampleOffset(ALsource *Source);

typedef enum SrcFloatProp {
@@ -2574,7 +2574,7 @@
* samples. The offset is relative to the start of the queue (not the start of
* the current buffer).
*/
-static ALint64 GetSourceOffset(const ALsource *Source)
+static ALint64 GetSourceOffset(ALsource *Source)
{
const ALbufferlistitem *BufferList;
const ALbufferlistitem *Current;
@@ -2604,7 +2604,7 @@
* Gets the current read offset for the given Source, in seconds. The offset is
* relative to the start of the queue (not the start of the current buffer).
*/
-static ALdouble GetSourceSecOffset(const ALsource *Source)
+static ALdouble GetSourceSecOffset(ALsource *Source)
{
const ALbufferlistitem *BufferList;
const ALbufferlistitem *Current;
@@ -2647,7 +2647,7 @@
* appropriate format (Bytes, Samples or Seconds). The offsets are relative to
* the start of the queue (not the start of the current buffer).
*/
-static ALvoid GetSourceOffsets(const ALsource *Source, ALenum name, ALdouble *offset, ALdouble updateLen)
+static ALvoid GetSourceOffsets(ALsource *Source, ALenum name, ALdouble *offset, ALdouble updateLen)
{
const ALbufferlistitem *BufferList;
const ALbufferlistitem *Current;
diff -Naur openal-soft-1.16.0.orig/OpenAL32/Include/alMain.h openal-soft-1.16.0/OpenAL32/Include/alMain.h
--- openal-soft-1.16.0.orig/OpenAL32/Include/alMain.h 2014-08-15 09:06:59.000000000 +0200
+++ openal-soft-1.16.0/OpenAL32/Include/alMain.h 2014-09-02 14:25:39.577094197 +0200
+++ openal-soft-1.16.0/OpenAL32/Include/alMain.h 2014-12-07 04:16:28.817636196 +0100
@@ -271,7 +271,7 @@
#define U64(x) ((ALuint64)(x##ui64))
#elif SIZEOF_LONG == 8
Expand Down
8 changes: 4 additions & 4 deletions ports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ function fetch()
download 'http://zlib.net/zlib-1.2.8.tar.xz'

# libpng
download 'http://downloads.sourceforge.net/sourceforge/libpng/libpng-1.6.13.tar.xz'
download 'http://downloads.sourceforge.net/sourceforge/libpng/libpng-1.6.15.tar.xz'

# libogg
download 'http://downloads.xiph.org/releases/ogg/libogg-1.3.1.tar.xz'
download 'http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz'

# libvorbis
download 'http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.xz'
Expand Down Expand Up @@ -345,7 +345,7 @@ function build_zlib()

function build_libpng()
{
prepare libpng-1.6.13 libpng-1.6.13.tar.xz || return
prepare libpng-1.6.15 libpng-1.6.15.tar.xz || return
applyPatches libpng-1.6.6.patch

cmakeBuild -D PNG_SHARED=0 \
Expand All @@ -357,7 +357,7 @@ function build_libpng()

function build_libogg()
{
prepare libogg-1.3.1 libogg-1.3.1.tar.xz || return
prepare libogg-1.3.2 libogg-1.3.2.tar.xz || return
applyPatches libogg-1.3.1.patch

autotoolsBuild
Expand Down
11 changes: 5 additions & 6 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ int Client::init(int argc, char** argv)
screenWidth = screenWidth == 0 ? Window::desktopWidth() : screenWidth;
screenHeight = screenHeight == 0 ? Window::desktopHeight() : screenHeight;

bool fullscreen = config.include("window.fullscreen", true).get(false);
bool fullscreen = config.include("window.fullscreen", true).get(false);

Window::create("OpenZone " OZ_VERSION,
fullscreen ? screenWidth : windowWidth,
Expand All @@ -476,14 +476,13 @@ int Client::init(int argc, char** argv)
for (const String& pkg : packages) {
Pepper::post("data:" + pkg);

File pkgFile = dataDir + "/" + pkg;
String pkgPath = String::str("%s/%s", dataDir.cstr(), pkg.cstr());

if (File::mount("%" + pkgFile.path(), nullptr)) {
Log::println("%s", pkgFile.path().cstr());
if (File::mount("%" + pkgPath, nullptr)) {
Log::println("%s", pkgPath.cstr());
}
else {
OZ_ERROR("Failed to mount '%s' on / in PhysicsFS: %s",
pkgFile.path().cstr(), PHYSFS_getLastError());
OZ_ERROR("Failed to mount '%s' on / in PhysicsFS: %s", pkgPath.cstr(), PHYSFS_getLastError());
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/client/Render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@ void Render::init()
}
}

#ifdef __native_client__
shader.hasVTF = false;
#endif
#ifdef OZ_GL_ES
shader.hasFBO = true;
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/matrix/Object.hh
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ public:
* FIELDS
*/

Object* prev[1]; // the previous object in cell.objects and list
Object* next[1]; // the next object in cell->objects
Object* prev[1]; // the previous object in cell.objects chains
Object* next[1]; // the next object in cell.objects chains

Cell* cell; // parent cell, nullptr if not positioned in the world
int index; // index in orbis.objects
Expand Down
6 changes: 3 additions & 3 deletions src/ozCore/File.cc
Original file line number Diff line number Diff line change
Expand Up @@ -888,9 +888,9 @@ List<File> File::ls() const
else {
#if defined(__native_client__)

typedef std::vector<pp::DirectoryEntry> EntryList;
typedef pp::CompletionCallbackWithOutput<EntryList> CallbackWithOutput;
typedef CallbackWithOutput::BaseType::OutputStorageType EntryListStorage;
typedef std::vector<pp::DirectoryEntry> EntryList;
typedef pp::CompletionCallbackWithOutput<EntryList> CallbackWithOutput;
typedef CallbackWithOutput::OutputStorageType EntryListStorage;

pp::FileRef file(ppFileSystem, filePath);
EntryListStorage entryStorage;
Expand Down
6 changes: 4 additions & 2 deletions src/ozCore/SpinLock.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SpinLock
{
private:

volatile bool flag = false; ///< True iff locked.
bool flag = false; ///< True iff locked.

public:

Expand All @@ -68,7 +68,9 @@ public:
void lock()
{
while (__atomic_test_and_set(&flag, __ATOMIC_ACQUIRE)) {
while (flag);
#if defined(__i386__) || defined(__x86_64__)
__asm__ __volatile__("pause");
#endif
}
}

Expand Down
23 changes: 9 additions & 14 deletions src/ozEngine/GL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,32 +226,27 @@ int GL::textureDataFromFile(const File& file, int bias)
is.seek(4 + 124);

GLenum format;
GLint internalFormat;

if (pixelFlags & DDPF_FOURCC) {
if (String::beginsWith(formatFourCC, "DXT1")) {
format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
blockSize = 8;
format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
blockSize = 8;
}
else if (String::beginsWith(formatFourCC, "DXT3")) {
format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
blockSize = 16;
format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
blockSize = 16;
}
else if (String::beginsWith(formatFourCC, "DXT5")) {
format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
blockSize = 16;
format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
blockSize = 16;
}
else {
return 0;
}
}
else if (pixelFlags & DDPF_RGB) {
format = pixelFlags & DDPF_ALPHAPIXELS ? GL_RGBA : GL_RGB;
internalFormat = pixelFlags & DDPF_ALPHAPIXELS ? GL_RGBA : GL_RGB;
blockSize = 1;
format = pixelFlags & DDPF_ALPHAPIXELS ? GL_RGBA : GL_RGB;
blockSize = 1;
}
else {
return 0;
Expand Down Expand Up @@ -312,7 +307,7 @@ int GL::textureDataFromFile(const File& file, int bias)
}
}

glTexImage2D(target, j - bias, internalFormat, mipmapWidth, mipmapHeight, 0, format,
glTexImage2D(target, j - bias, GLint(format), mipmapWidth, mipmapHeight, 0, format,
GL_UNSIGNED_BYTE, &data[0]);
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/ozEngine/Window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct ScreenshotInfo

#ifdef __native_client__
static Semaphore flushSemaphore;
static pp::Graphics3D* context;
static pp::Graphics3D* context = nullptr;
#else
static SDL_Window* descriptor;
static SDL_GLContext context;
Expand Down Expand Up @@ -298,9 +298,15 @@ bool Window::create(const char* title, int width, int height, bool fullscreen_)

if (context->is_null()) {
Log::printEnd("Failed to create OpenGL context");

delete context;
context = nullptr;
}
else if (!Pepper::instance()->BindGraphics(*context)) {
Log::printEnd("Failed to bind Graphics3D");

delete context;
context = nullptr;
}
else {
glSetCurrentContextPPAPI(context->pp_resource());
Expand All @@ -310,12 +316,11 @@ bool Window::create(const char* title, int width, int height, bool fullscreen_)
glFlush();

context->SwapBuffers(pp::CompletionCallback(flushCompleteCallback, nullptr));
Log::printEnd("OK");
}
};
flushSemaphore.wait();

Log::printEnd("OK");

#else

// Don't mess with screensaver. In X11 it only makes effect for windowed mode, in fullscreen
Expand Down Expand Up @@ -388,7 +393,7 @@ void Window::destroy()
{
#if defined(__native_client__)

if (!context->is_null()) {
if (context != nullptr) {
MainCall() << []
{
glSetCurrentContextPPAPI(0);
Expand Down

0 comments on commit 8d80ce6

Please sign in to comment.