From daefb3b550e27f291beb78aaea2bc9c9dc77ac78 Mon Sep 17 00:00:00 2001 From: nitsuja Date: Sat, 7 Jan 2012 20:22:48 -0800 Subject: [PATCH] a small thread synchronization speedup for dual core mode. it's most noticeable in games where the CPU is running behind compared to the GPU. --- Source/Core/Common/Src/StdThread.h | 2 +- Source/Core/VideoCommon/Src/Fifo.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Source/Core/Common/Src/StdThread.h b/Source/Core/Common/Src/StdThread.h index 6e9e903561..661d87cfd1 100644 --- a/Source/Core/Common/Src/StdThread.h +++ b/Source/Core/Common/Src/StdThread.h @@ -279,7 +279,7 @@ namespace this_thread inline void yield() { #ifdef _WIN32 - Sleep(0); + SwitchToThread(); #else sleep(0); #endif diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 842ff49e78..7330169ddd 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -171,14 +171,22 @@ void RunGpuLoop() CommandProcessor::isPossibleWaitingSetDrawDone = false; } - fifo.isGpuReadingData = false; - - if (EmuRunningState) - Common::YieldCPU(); + { + if (fifo.isGpuReadingData) + { + fifo.isGpuReadingData = false; + Common::YieldCPU(); + } + else + { + SLEEP(1); + } + } else { // While the emu is paused, we still handle async request such as Savestates then sleep. + fifo.isGpuReadingData = false; while (!EmuRunningState) { g_video_backend->PeekMessages();