mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
More Android stub-outs and bug fixes. Fix broken SDL fiber sync.
This commit is contained in:
@@ -87,6 +87,7 @@
|
||||
<ClCompile Include="..\Aerofoil\GpColorCursor_Win32.cpp" />
|
||||
<ClCompile Include="..\Aerofoil\GpFileStream_Win32.cpp" />
|
||||
<ClCompile Include="..\Aerofoil\GpFileSystem_Win32.cpp" />
|
||||
<ClCompile Include="..\Aerofoil\GpLogDriver_Win32.cpp" />
|
||||
<ClCompile Include="..\Aerofoil\GpMutex_Win32.cpp" />
|
||||
<ClCompile Include="..\Aerofoil\GpSystemServices_Win32.cpp" />
|
||||
<ClCompile Include="..\Aerofoil\GpThreadEvent_Win32.cpp" />
|
||||
|
||||
@@ -60,6 +60,9 @@
|
||||
<ClCompile Include="GpAudioDriver_SDL2.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Aerofoil\GpLogDriver_Win32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ShaderCode\Functions.h">
|
||||
|
||||
28
AerofoilSDL/Android.mk
Normal file
28
AerofoilSDL/Android.mk
Normal file
@@ -0,0 +1,28 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := AerofoilSDL
|
||||
|
||||
SDL_PATH := ../SDL2
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/../GpCommon \
|
||||
$(LOCAL_PATH)/../GpShell \
|
||||
$(LOCAL_PATH)/../Common \
|
||||
$(LOCAL_PATH)/../PortabilityLayer \
|
||||
$(LOCAL_PATH)/$(SDL_PATH)/include
|
||||
|
||||
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
|
||||
|
||||
# Add your application source files here...
|
||||
LOCAL_SRC_FILES := \
|
||||
GpAudioDriver_SDL2.cpp \
|
||||
GpDisplayDriver_SDL_GL2.cpp \
|
||||
GpFiber_SDL.cpp \
|
||||
GpFiberStarter_SDL.cpp \
|
||||
ShaderCode/DrawQuadPaletteP.cpp \
|
||||
ShaderCode/DrawQuadV.cpp \
|
||||
ShaderCode/ScaleQuadP.cpp
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
@@ -62,7 +62,7 @@ struct GpAudioChannelBufferChain_SDL2 final
|
||||
bool m_hasTrigger;
|
||||
};
|
||||
|
||||
GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) class GpAudioChannel_SDL2 final : public IGpAudioChannel
|
||||
class GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) GpAudioChannel_SDL2 final : public IGpAudioChannel
|
||||
{
|
||||
public:
|
||||
enum ChannelState
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
ChannelState m_channelState;
|
||||
};
|
||||
|
||||
GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) class GpAudioDriver_SDL2 final : public IGpAudioDriver, public IGpPrefsHandler
|
||||
class GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) GpAudioDriver_SDL2 final : public IGpAudioDriver, public IGpPrefsHandler
|
||||
{
|
||||
public:
|
||||
friend class GpAudioChannel_SDL2;
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#include "GpComPtr.h"
|
||||
#include "GpFiber_SDL.h"
|
||||
#include "GpDisplayDriverProperties.h"
|
||||
#include "GpSystemServices_Win32.h"
|
||||
#include "GpWindows.h" // TODO: Remove
|
||||
//#include "GpSystemServices_Win32.h"
|
||||
//#include "GpWindows.h" // TODO: Remove
|
||||
#include "GpVOSEvent.h"
|
||||
#include "GpRingBuffer.h"
|
||||
#include "HostSystemServices.h"
|
||||
#include "IGpCursor.h"
|
||||
#include "IGpDisplayDriverSurface.h"
|
||||
#include "IGpLogDriver.h"
|
||||
@@ -152,7 +153,6 @@ struct GpGLFunctions
|
||||
|
||||
PFNGLGENBUFFERSPROC GenBuffers;
|
||||
PFNGLBUFFERDATAPROC BufferData;
|
||||
PFNGLMAPBUFFERPROC MapBuffer;
|
||||
PFNGLBINDBUFFERPROC BindBuffer;
|
||||
PFNGLDELETEBUFFERSPROC DeleteBuffers;
|
||||
|
||||
@@ -823,8 +823,6 @@ private:
|
||||
SDL_Cursor *m_arrowCursor;
|
||||
bool m_cursorIsHidden;
|
||||
|
||||
|
||||
UINT m_expectedSyncDelta;
|
||||
bool m_isResettingSwapChain;
|
||||
|
||||
bool m_isFullScreen;
|
||||
@@ -854,7 +852,6 @@ private:
|
||||
|
||||
IGpFiber *m_vosFiber;
|
||||
PortabilityLayer::HostThreadEvent *m_vosEvent;
|
||||
GpWindowsGlobals *m_osGlobals;
|
||||
|
||||
float m_bgColor[4];
|
||||
bool m_bgIsDark;
|
||||
@@ -896,6 +893,9 @@ GpDisplayDriverSurface_GL2::GpDisplayDriverSurface_GL2(GpDisplayDriver_SDL_GL2 *
|
||||
assert(pitch % 4 == 0);
|
||||
paddingPixels = pitch / 4 - width;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
paddingPixels = 0;
|
||||
}
|
||||
|
||||
m_paddedTextureWidth = width + paddingPixels;
|
||||
@@ -1082,7 +1082,6 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
|
||||
, m_lastFullScreenToggleTimeStamp(0)
|
||||
, m_bgIsDark(false)
|
||||
, m_useICCProfile(false)
|
||||
, m_osGlobals(static_cast<GpWindowsGlobals*>(properties.m_osGlobals))
|
||||
, m_properties(properties)
|
||||
, m_syncTimeBase(std::chrono::time_point<std::chrono::high_resolution_clock>::duration::zero())
|
||||
, m_waitCursor(nullptr)
|
||||
@@ -1112,7 +1111,7 @@ static bool LookupOpenGLFunction(T &target, const char *name)
|
||||
void *proc = SDL_GL_GetProcAddress(name);
|
||||
if (proc)
|
||||
{
|
||||
target = static_cast<T>(proc);
|
||||
target = reinterpret_cast<T>(proc);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -1120,7 +1119,7 @@ static bool LookupOpenGLFunction(T &target, const char *name)
|
||||
}
|
||||
|
||||
#define LOOKUP_FUNC(func) do { if (!LookupOpenGLFunction(this->func, "gl" #func)) return false; } while(false)
|
||||
|
||||
|
||||
|
||||
bool GpGLFunctions::LookUpFunctions()
|
||||
{
|
||||
@@ -1139,12 +1138,6 @@ bool GpGLFunctions::LookUpFunctions()
|
||||
LOOKUP_FUNC(CheckFramebufferStatus);
|
||||
LOOKUP_FUNC(DeleteFramebuffers);
|
||||
|
||||
LOOKUP_FUNC(GenBuffers);
|
||||
LOOKUP_FUNC(BufferData);
|
||||
LOOKUP_FUNC(MapBuffer);
|
||||
LOOKUP_FUNC(BindBuffer);
|
||||
LOOKUP_FUNC(DeleteBuffers);
|
||||
|
||||
LOOKUP_FUNC(CreateProgram);
|
||||
LOOKUP_FUNC(DeleteProgram);
|
||||
LOOKUP_FUNC(LinkProgram);
|
||||
@@ -1152,6 +1145,11 @@ bool GpGLFunctions::LookUpFunctions()
|
||||
LOOKUP_FUNC(GetProgramiv);
|
||||
LOOKUP_FUNC(GetProgramInfoLog);
|
||||
|
||||
LOOKUP_FUNC(GenBuffers);
|
||||
LOOKUP_FUNC(BufferData);
|
||||
LOOKUP_FUNC(BindBuffer);
|
||||
LOOKUP_FUNC(DeleteBuffers);
|
||||
|
||||
LOOKUP_FUNC(GetUniformLocation);
|
||||
LOOKUP_FUNC(GetAttribLocation);
|
||||
LOOKUP_FUNC(Uniform4fv);
|
||||
@@ -1671,7 +1669,7 @@ void GpDisplayDriver_SDL_GL2::Run()
|
||||
|
||||
IGpLogDriver *logger = m_properties.m_logger;
|
||||
|
||||
m_vosEvent = GpSystemServices_Win32::GetInstance()->CreateThreadEvent(true, false);
|
||||
m_vosEvent = m_properties.m_systemServices->CreateThreadEvent(true, false);
|
||||
m_vosFiber = new GpFiber_SDL(nullptr, m_vosEvent);
|
||||
|
||||
m_window = SDL_CreateWindow(GP_APPLICATION_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_windowWidthPhysical, m_windowHeightPhysical, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
|
||||
@@ -1685,10 +1683,6 @@ void GpDisplayDriver_SDL_GL2::Run()
|
||||
|
||||
InitResources(m_windowWidthVirtual, m_windowHeightVirtual);
|
||||
|
||||
LARGE_INTEGER lastTimestamp;
|
||||
memset(&lastTimestamp, 0, sizeof(lastTimestamp));
|
||||
|
||||
MSG msg;
|
||||
for (;;)
|
||||
{
|
||||
SDL_Event msg;
|
||||
@@ -2320,13 +2314,13 @@ bool GpDisplayDriver_SDL_GL2::ResizeOpenGLWindow(uint32_t &windowWidth, uint32_t
|
||||
|
||||
if (desiredWidth < 640)
|
||||
desiredWidth = 640;
|
||||
else if (desiredWidth > MAXDWORD)
|
||||
desiredWidth = MAXDWORD;
|
||||
else if (desiredWidth > 32768)
|
||||
desiredWidth = 32768;
|
||||
|
||||
if (desiredHeight < 480)
|
||||
desiredHeight = 480;
|
||||
else if (desiredHeight > MAXDWORD)
|
||||
desiredHeight = MAXDWORD;
|
||||
else if (desiredHeight > 32768)
|
||||
desiredHeight = 32768;
|
||||
|
||||
if (logger)
|
||||
logger->Printf(IGpLogDriver::Category_Information, "ResizeOpenGLWindow: Adjusted dimensions: %i x %i", static_cast<int>(desiredWidth), static_cast<int>(desiredHeight));
|
||||
@@ -2432,8 +2426,8 @@ void GpDisplayDriver_SDL_GL2::ScaleVirtualScreen()
|
||||
{
|
||||
static_cast<float>(static_cast<double>(m_windowWidthVirtual) / static_cast<double>(m_windowWidthPhysical)),
|
||||
static_cast<float>(static_cast<double>(m_windowHeightVirtual) / static_cast<double>(m_windowHeightPhysical)),
|
||||
m_windowWidthVirtual,
|
||||
m_windowHeightVirtual
|
||||
static_cast<float>(m_windowWidthVirtual),
|
||||
static_cast<float>(m_windowHeightVirtual)
|
||||
};
|
||||
|
||||
m_gl.Uniform4fv(m_scaleQuadProgram.m_pixelDXDYDimensionsLocation, 1, reinterpret_cast<const GLfloat*>(dxdy_dimensions));
|
||||
@@ -2526,7 +2520,7 @@ bool GpDisplayDriver_SDL_GL2::ScaleQuadProgram::Link(GpDisplayDriver_SDL_GL2 *dr
|
||||
std::vector<char> errorMsgBuffer;
|
||||
errorMsgBuffer.resize(static_cast<size_t>(logLength) + 1);
|
||||
errorMsgBuffer[logLength] = '\0';
|
||||
|
||||
|
||||
gl->GetProgramInfoLog(m_program->GetID(), static_cast<size_t>(logLength), nullptr, reinterpret_cast<GLchar*>(&errorMsgBuffer[0]));
|
||||
const char *errorMsg = &errorMsgBuffer[0];
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "GpFiberStarter.h"
|
||||
#include "GpFiber_SDL.h"
|
||||
#include "GpSystemServices_Win32.h"
|
||||
|
||||
#include "HostSystemServices.h"
|
||||
#include "HostThreadEvent.h"
|
||||
|
||||
#include "SDL_thread.h"
|
||||
@@ -14,6 +14,7 @@ namespace GpFiberStarter_SDL
|
||||
{
|
||||
GpFiberStarter::ThreadFunc_t m_threadFunc;
|
||||
PortabilityLayer::HostThreadEvent *m_creatingReturnEvent;
|
||||
PortabilityLayer::HostThreadEvent *m_creatingWakeEvent;
|
||||
void *m_context;
|
||||
};
|
||||
|
||||
@@ -23,29 +24,47 @@ namespace GpFiberStarter_SDL
|
||||
|
||||
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
|
||||
PortabilityLayer::HostThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
|
||||
PortabilityLayer::HostThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
|
||||
void *context = tss->m_context;
|
||||
creatingReturnEvent->Signal();
|
||||
|
||||
wakeEvent->Wait();
|
||||
|
||||
threadFunc(context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
IGpFiber *GpFiberStarter::StartFiber(ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
||||
IGpFiber *GpFiberStarter::StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
|
||||
{
|
||||
PortabilityLayer::HostThreadEvent *returnEvent = GpSystemServices_Win32::GetInstance()->CreateThreadEvent(true, false);
|
||||
PortabilityLayer::HostThreadEvent *returnEvent = systemServices->CreateThreadEvent(true, false);
|
||||
if (!returnEvent)
|
||||
return nullptr;
|
||||
|
||||
PortabilityLayer::HostThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false);
|
||||
if (!wakeEvent)
|
||||
{
|
||||
returnEvent->Destroy();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GpFiberStarter_SDL::FiberStartState startState;
|
||||
startState.m_context = context;
|
||||
startState.m_creatingReturnEvent = returnEvent;
|
||||
startState.m_creatingWakeEvent = wakeEvent;
|
||||
startState.m_threadFunc = threadFunc;
|
||||
|
||||
SDL_Thread *thread = SDL_CreateThread(GpFiberStarter_SDL::FiberStartRoutine, "Fiber", &startState);
|
||||
if (!thread)
|
||||
{
|
||||
returnEvent->Destroy();
|
||||
wakeEvent->Destroy();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
returnEvent->Wait();
|
||||
returnEvent->Destroy();
|
||||
|
||||
return new GpFiber_SDL(thread, returnEvent);
|
||||
return new GpFiber_SDL(thread, wakeEvent);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "HostSystemServices.h"
|
||||
#include "HostThreadEvent.h"
|
||||
|
||||
#include "GpSystemServices_Win32.h"
|
||||
|
||||
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent)
|
||||
: m_event(threadEvent)
|
||||
, m_thread(thread)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "Functions.h"
|
||||
#include "DrawQuadPixelConstants.h"
|
||||
|
||||
#define GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL "varying vec4 texCoord;\n"\
|
||||
#define GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL \
|
||||
"\n"\
|
||||
"varying vec4 texCoord;\n"\
|
||||
"uniform sampler2D surfaceTexture;\n"\
|
||||
"uniform sampler2D paletteTexture;\n"\
|
||||
"\n"\
|
||||
@@ -23,6 +25,6 @@
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
const char *g_drawQuadPaletteP_GL2 = GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
|
||||
const char *g_drawQuadPaletteICCP_GL2 = "#define USE_ICC_PROFILE\n" GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
|
||||
const char *g_drawQuadPaletteP_GL2 = GP_GL_SHADER_CODE_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
|
||||
const char *g_drawQuadPaletteICCP_GL2 = "#define USE_ICC_PROFILE\n" GP_GL_SHADER_CODE_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#define GP_GL_SHADER_CODE_PRECISION_PREFIX "precision mediump float;\n"\
|
||||
|
||||
#define GP_GL_SHADER_CODE_FUNCTIONS_H "vec3 pow3(vec3 v, float ex)\n"\
|
||||
"{\n"\
|
||||
" return vec3(pow(v.x, ex), pow(v.y, ex), pow(v.z, ex));\n"\
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
const char *g_scaleQuadP_GL2 = GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_SCALEQUADP_GLSL;
|
||||
const char *g_scaleQuadP_GL2 = GP_GL_SHADER_CODE_PRECISION_PREFIX GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_SCALEQUADP_GLSL;
|
||||
|
||||
extern const char *g_drawQuadRGBP_GL2;
|
||||
extern const char *g_drawQuad15BitP_GL2;
|
||||
|
||||
Reference in New Issue
Block a user