diff options
| author | degasus <wickmarkus@web.de> | 2016-10-01 13:16:50 +0200 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2016-10-03 10:38:16 +0200 |
| commit | 12f050bb8eccda78aa344a2691198ebae28eb8c2 (patch) | |
| tree | 459190054e71d4ff20ed68f25c62812776541a6f /Source/Core/VideoCommon/Fifo.cpp | |
| parent | d139659ea2a12fddb12b9fd9ead7f16bae24dea0 (diff) | |
Fifo: Fix SyncGPU.
Diffstat (limited to 'Source/Core/VideoCommon/Fifo.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Fifo.cpp | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index b021452594..4ca76cae71 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -371,7 +371,8 @@ void RunGpuLoop() { cyclesExecuted = (int)(cyclesExecuted / param.fSyncGpuOverclock); int old = s_sync_ticks.fetch_sub(cyclesExecuted); - if (old > 0 && old - (int)cyclesExecuted <= 0) + if (old >= param.iSyncGpuMaxDistance && + old - (int)cyclesExecuted < param.iSyncGpuMaxDistance) s_sync_wakeup_event.Set(); } @@ -386,7 +387,7 @@ void RunGpuLoop() if (s_sync_ticks.load() > 0) { int old = s_sync_ticks.exchange(0); - if (old > 0) + if (old >= param.iSyncGpuMaxDistance) s_sync_wakeup_event.Set(); } @@ -554,36 +555,26 @@ static int WaitForGpuThread(int ticks) { const SConfig& param = SConfig::GetInstance(); - // GPU is sleeping, so no need for synchronization - if (s_gpu_mainloop.IsDone() || s_use_deterministic_gpu_thread) - { - if ((s_sync_ticks.load() + ticks) < 0) - { - s_sync_ticks.store(s_sync_ticks.load() + ticks); - return 0 - s_sync_ticks.load(); - } - else - { - s_sync_ticks.store(0); - return -1; - } - } + int old = s_sync_ticks.fetch_add(ticks); + int now = old + ticks; + + // GPU is idle, so stop polling. + if (old >= 0 && s_gpu_mainloop.IsDone()) + return -1; // Wakeup GPU - int old = s_sync_ticks.fetch_add(ticks); - if (old < param.iSyncGpuMinDistance && old + ticks >= param.iSyncGpuMinDistance) + if (old < param.iSyncGpuMinDistance && now >= param.iSyncGpuMinDistance) RunGpu(); + // If the GPU is still sleeping, wait for a longer time + if (now < param.iSyncGpuMinDistance) + return GPU_TIME_SLOT_SIZE + param.iSyncGpuMinDistance - now; + // Wait for GPU - if (s_sync_ticks.load() >= param.iSyncGpuMaxDistance) - { - while (s_sync_ticks.load() > 0) - { - s_sync_wakeup_event.Wait(); - } - } + if (now >= param.iSyncGpuMaxDistance) + s_sync_wakeup_event.Wait(); - return param.iSyncGpuMaxDistance - s_sync_ticks.load(); + return GPU_TIME_SLOT_SIZE; } static void SyncGPUCallback(u64 ticks, s64 cyclesLate) |
