diff options
| author | degasus <wickmarkus@web.de> | 2016-01-19 00:08:18 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2016-01-24 11:06:01 +0100 |
| commit | cf4478dc925b4c20a341bb29ea78a4be4054bcb1 (patch) | |
| tree | 3df00f71b52bc2aa0e8a4692ab7b1c9335340d78 /Source/Core/VideoCommon/Fifo.cpp | |
| parent | aa39b0dab1bf435df690a5a8d41338824dacba53 (diff) | |
Fifo: Fix SyncGPU.
CBoot::BootUp() did call CoreTiming::Advance which itself blocks on the GPU,
but the GPU thread wasn't started already. This commit moves the SyncGPU
initialization into the Fifo.cpp file and call it after BootUp().
Diffstat (limited to 'Source/Core/VideoCommon/Fifo.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Fifo.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index acc43b8855..0ca6096de8 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -15,6 +15,7 @@ #include "Common/MsgHandler.h" #include "Core/ConfigManager.h" +#include "Core/CoreTiming.h" #include "Core/NetPlayProto.h" #include "Core/HW/Memmap.h" @@ -45,6 +46,9 @@ static u8* s_fifo_aux_read_ptr; bool g_use_deterministic_gpu_thread; +static u64 s_last_sync_gpu_tick; +static int s_et_syncGPU; + // STATE_TO_SAVE static u8* s_video_buffer; static u8* s_video_buffer_read_ptr; @@ -79,6 +83,7 @@ void DoState(PointerWrap &p) s_video_buffer_seen_ptr = s_video_buffer_pp_read_ptr = s_video_buffer_read_ptr; } p.Do(g_bSkipCurrentFrame); + p.Do(s_last_sync_gpu_tick); } void PauseAndLock(bool doLock, bool unpauseOnUnlock) @@ -492,16 +497,10 @@ void UpdateWantDeterminism(bool want) } } -int Update(int ticks) +static int Update(int ticks) { const SConfig& param = SConfig::GetInstance(); - if (ticks == 0) - { - FlushGpu(); - return param.iSyncGpuMaxDistance; - } - // GPU is sleeping, so no need for synchronization if (s_gpu_mainloop.IsDone() || g_use_deterministic_gpu_thread) { @@ -529,4 +528,24 @@ int Update(int ticks) return param.iSyncGpuMaxDistance - s_sync_ticks.load(); } +static void SyncGPUCallback(u64 userdata, int cyclesLate) +{ + u64 now = CoreTiming::GetTicks(); + int next = Fifo::Update((int)(now - s_last_sync_gpu_tick)); + s_last_sync_gpu_tick = now; + + if (next > 0) + CoreTiming::ScheduleEvent(next, s_et_syncGPU); +} + +void Prepare() +{ + if (SConfig::GetInstance().bCPUThread && SConfig::GetInstance().bSyncGPU) + { + s_et_syncGPU = CoreTiming::RegisterEvent("SyncGPUCallback", SyncGPUCallback); + CoreTiming::ScheduleEvent(0, s_et_syncGPU); + s_last_sync_gpu_tick = CoreTiming::GetTicks(); + } +} + } |
