Cocoa Port:

- Fix occasional crash that can occur when switching 3D rendering engines. (Regression from r5288.)
This commit is contained in:
rogerman 2016-03-06 01:52:28 +00:00
parent 4c9a50ae91
commit 7b84225fa4
6 changed files with 23 additions and 8 deletions

View File

@ -6100,7 +6100,11 @@ void GPUSubsystem::SetCustomFramebufferSize(size_t w, size_t h, u16 *clientNativ
this->_engineMain->SetCustomFramebufferSize(w, h); this->_engineMain->SetCustomFramebufferSize(w, h);
this->_engineSub->SetCustomFramebufferSize(w, h); this->_engineSub->SetCustomFramebufferSize(w, h);
BaseRenderer->SetFramebufferSize(w, h); // Since BaseRenderer is persistent, we need to update this manually. BaseRenderer->SetFramebufferSize(w, h); // Since BaseRenderer is persistent, we need to update this manually.
CurrentRenderer->SetFramebufferSize(w, h);
if (CurrentRenderer != BaseRenderer)
{
CurrentRenderer->SetFramebufferSize(w, h);
}
if (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main]) if (this->_displayInfo.didPerformCustomRender[NDSDisplayID_Main])
{ {

View File

@ -786,8 +786,9 @@ static void OpenGLRendererDestroy()
if (CurrentRenderer != BaseRenderer) if (CurrentRenderer != BaseRenderer)
{ {
delete (OpenGLRenderer *)CurrentRenderer; OpenGLRenderer *oldRenderer = (OpenGLRenderer *)CurrentRenderer;
CurrentRenderer = BaseRenderer; CurrentRenderer = BaseRenderer;
delete oldRenderer;
} }
ENDGL(); ENDGL();

View File

@ -49,6 +49,7 @@ private:
pthread_mutex_t *_mutexOutputList; pthread_mutex_t *_mutexOutputList;
NSMutableArray *_cdsOutputList; NSMutableArray *_cdsOutputList;
bool _isRender3DLockHeld; bool _isRender3DLockHeld;
bool _isIn3DRender;
public: public:
GPUEventHandlerOSX(); GPUEventHandlerOSX();
@ -723,6 +724,7 @@ public:
GPUEventHandlerOSX::GPUEventHandlerOSX() GPUEventHandlerOSX::GPUEventHandlerOSX()
{ {
_isRender3DLockHeld = false; _isRender3DLockHeld = false;
_isIn3DRender = false;
_mutexOutputList = NULL; _mutexOutputList = NULL;
pthread_rwlock_init(&_rwlockFrame, NULL); pthread_rwlock_init(&_rwlockFrame, NULL);
pthread_mutex_init(&_mutex3DRender, NULL); pthread_mutex_init(&_mutex3DRender, NULL);
@ -778,12 +780,17 @@ void GPUEventHandlerOSX::DidFrameEnd(bool isFrameSkipped)
void GPUEventHandlerOSX::DidRender3DBegin() void GPUEventHandlerOSX::DidRender3DBegin()
{ {
this->_isIn3DRender = true;
this->Render3DLock(); this->Render3DLock();
} }
void GPUEventHandlerOSX::DidRender3DEnd() void GPUEventHandlerOSX::DidRender3DEnd()
{ {
this->Render3DUnlock(); if (this->_isIn3DRender)
{
this->Render3DUnlock();
this->_isIn3DRender = false;
}
} }
void GPUEventHandlerOSX::FramebufferLockWrite() void GPUEventHandlerOSX::FramebufferLockWrite()
@ -811,8 +818,8 @@ void GPUEventHandlerOSX::Render3DUnlock()
{ {
if (this->_isRender3DLockHeld) if (this->_isRender3DLockHeld)
{ {
pthread_mutex_unlock(&this->_mutex3DRender);
this->_isRender3DLockHeld = false; this->_isRender3DLockHeld = false;
pthread_mutex_unlock(&this->_mutex3DRender);
} }
} }

View File

@ -2314,6 +2314,7 @@ void gfx3d_VBlankEndSignal(bool skipFrame)
if (!CommonSettings.showGpu.main) if (!CommonSettings.showGpu.main)
{ {
memset(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), 0, GPU->GetCustomFramebufferWidth() * GPU->GetCustomFramebufferHeight() * sizeof(FragmentColor)); memset(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), 0, GPU->GetCustomFramebufferWidth() * GPU->GetCustomFramebufferHeight() * sizeof(FragmentColor));
memset(GPU->GetEngineMain()->Get3DFramebufferRGBA5551(), 0, GPU->GetCustomFramebufferWidth() * GPU->GetCustomFramebufferHeight() * sizeof(u16));
return; return;
} }

View File

@ -1146,13 +1146,14 @@ static void SoftRasterizerRendererDestroy()
if (CurrentRenderer != BaseRenderer) if (CurrentRenderer != BaseRenderer)
{ {
#if defined(ENABLE_SSSE3) #if defined(ENABLE_SSSE3)
delete (SoftRasterizerRenderer_SSSE3 *)CurrentRenderer; SoftRasterizerRenderer_SSSE3 *oldRenderer = (SoftRasterizerRenderer_SSSE3 *)CurrentRenderer;
#elif defined(ENABLE_SSE2) #elif defined(ENABLE_SSE2)
delete (SoftRasterizerRenderer_SSE2 *)CurrentRenderer; SoftRasterizerRenderer_SSE2 *oldRenderer = (SoftRasterizerRenderer_SSE2 *)CurrentRenderer;
#else #else
delete (SoftRasterizerRenderer *)CurrentRenderer; SoftRasterizerRenderer *oldRenderer = (SoftRasterizerRenderer *)CurrentRenderer;
#endif #endif
CurrentRenderer = BaseRenderer; CurrentRenderer = BaseRenderer;
delete oldRenderer;
} }
} }

View File

@ -119,8 +119,9 @@ void Render3DBaseDestroy()
{ {
if (CurrentRenderer != BaseRenderer) if (CurrentRenderer != BaseRenderer)
{ {
delete CurrentRenderer; Render3D *oldRenderer = CurrentRenderer;
CurrentRenderer = BaseRenderer; CurrentRenderer = BaseRenderer;
delete oldRenderer;
} }
} }