summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Fifo.cpp
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2016-10-08 01:26:34 +0200
committerGitHub <noreply@github.com>2016-10-08 01:26:34 +0200
commit4ba1100f3191c80e58f89c78d1e8965e126da8f3 (patch)
tree7fef0456182db607cde895d26d76a14514cb4c73 /Source/Core/VideoCommon/Fifo.cpp
parenta172bd7d8cac3c417e33ba8fafb89963fc8b5bbd (diff)
parent12f050bb8eccda78aa344a2691198ebae28eb8c2 (diff)
Merge pull request #4269 from degasus/singlecore
Fifo: Fix SyncGPU on dual core mode.
Diffstat (limited to 'Source/Core/VideoCommon/Fifo.cpp')
-rw-r--r--Source/Core/VideoCommon/Fifo.cpp43
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)