From 1226c3dbd9c8ddc03558308225fd92c899ac5c1f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 9 Aug 2013 00:45:27 -0700 Subject: [PATCH] Try to prevent a deadlock if CPU doesn't NEXTFRAME. --- Core/System.cpp | 1 + GPU/GPUCommon.cpp | 11 +++++++++++ GPU/GPUCommon.h | 1 + GPU/GPUInterface.h | 2 ++ 4 files changed, 15 insertions(+) diff --git a/Core/System.cpp b/Core/System.cpp index 99332ca22f..b4186d799a 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -210,6 +210,7 @@ void CPU_RunLoop() { switch (cpuThreadState) { case CPU_THREAD_EXECUTE: mipsr4k.RunLoopUntil(cpuThreadUntil); + gpu->FinishEventLoop(); CPU_NextState(CPU_THREAD_EXECUTE, CPU_THREAD_RUNNING); break; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 4ae9730209..66c60fbf86 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -577,6 +577,11 @@ void GPUCommon::RunEventsUntil(u64 globalticks) { ReapplyGfxStateInternal(); break; + case GPU_EVENT_FINISH_EVENT_LOOP: + // Stop waiting. + globalticks = 0; + break; + default: ProcessEvent(ev); } @@ -595,6 +600,12 @@ void GPUCommon::RunEventsUntil(u64 globalticks) { } while (CoreTiming::GetTicks() < globalticks); } +void GPUCommon::FinishEventLoop() { + if (g_Config.bSeparateCPUThread) { + ScheduleEvent(GPU_EVENT_FINISH_EVENT_LOOP); + } +} + void GPUCommon::SyncThread() { if (!g_Config.bSeparateCPUThread) { return; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index b4cbc4ea22..0e9d902534 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -11,6 +11,7 @@ public: virtual ~GPUCommon() {} virtual void RunEventsUntil(u64 globalticks); + virtual void FinishEventLoop(); virtual void InterruptStart(int listid); virtual void InterruptEnd(int listid); diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 5c19d4f0e3..7e6ded02e8 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -149,6 +149,7 @@ enum GPUEventType { GPU_EVENT_REAPPLY_GFX_STATE, GPU_EVENT_INVALIDATE_CACHE, GPU_EVENT_FLUSH, + GPU_EVENT_FINISH_EVENT_LOOP, }; struct GPUEvent { @@ -175,6 +176,7 @@ public: virtual void InitClear() = 0; virtual void RunEventsUntil(u64 globalticks) = 0; + virtual void FinishEventLoop() = 0; // Draw queue management virtual DisplayList* getList(int listid) = 0;