From 9ac09387e33251c3abd9e451182efa6a47f9ad68 Mon Sep 17 00:00:00 2001 From: rogerman Date: Fri, 27 Aug 2021 14:48:22 -0700 Subject: [PATCH] Cocoa Port: Fix a bug where changing the GPU Scaling Factor or GPU Color Depth while the emulator is paused would cause the program to freeze upon restarting the emulation via Run, Frame Advance, or Frame Jump. --- desmume/src/frontend/cocoa/cocoa_GPU.mm | 10 ++++++++++ desmume/src/frontend/cocoa/cocoa_core.mm | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/desmume/src/frontend/cocoa/cocoa_GPU.mm b/desmume/src/frontend/cocoa/cocoa_GPU.mm index 1894e882c..5bb5bf091 100644 --- a/desmume/src/frontend/cocoa/cocoa_GPU.mm +++ b/desmume/src/frontend/cocoa/cocoa_GPU.mm @@ -306,6 +306,11 @@ public: gpuEvent->FramebufferUnlock(); gpuEvent->Render3DUnlock(); + + if (_needRestoreRender3DLock) + { + _needRestoreRender3DLock = NO; + } } - (NSSize) gpuDimensions @@ -374,6 +379,11 @@ public: gpuEvent->FramebufferUnlock(); gpuEvent->Render3DUnlock(); + + if (_needRestoreRender3DLock) + { + _needRestoreRender3DLock = NO; + } } - (NSUInteger) gpuColorFormat diff --git a/desmume/src/frontend/cocoa/cocoa_core.mm b/desmume/src/frontend/cocoa/cocoa_core.mm index 999555080..713d9de43 100644 --- a/desmume/src/frontend/cocoa/cocoa_core.mm +++ b/desmume/src/frontend/cocoa/cocoa_core.mm @@ -685,7 +685,6 @@ volatile bool execute = true; pthread_cond_signal(&threadParam.condThreadExecute); pthread_mutex_unlock(&threadParam.mutexThreadExecute); - [[self cdsGPU] respondToPauseState:(coreState == ExecutionBehavior_Pause)]; [[self cdsController] setHardwareMicPause:(coreState != ExecutionBehavior_Run)]; // This method affects UI updates, but can also be called from a thread that is different from @@ -1178,6 +1177,8 @@ static void* RunCoreThread(void *arg) execControl->ApplySettingsOnExecutionLoopStart(); behavior = execControl->GetExecutionBehaviorApplied(); + [[cdsCore cdsGPU] respondToPauseState:(behavior == ExecutionBehavior_Pause)]; + while (!(behavior != ExecutionBehavior_Pause && execute)) { pthread_cond_wait(¶m->condThreadExecute, ¶m->mutexThreadExecute); @@ -1187,6 +1188,8 @@ static void* RunCoreThread(void *arg) behavior = execControl->GetExecutionBehaviorApplied(); } + [[cdsCore cdsGPU] respondToPauseState:(behavior == ExecutionBehavior_Pause)]; + if ( (lastBehavior == ExecutionBehavior_Run) && (behavior != ExecutionBehavior_Run) ) { lastExecutionWaitBias = executionWaitBias;