mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Fifo: More comments for SyncGPU functions.
This commit is contained in:
@ -71,7 +71,7 @@ static Common::Event g_compressAndDumpStateSyncEvent;
|
|||||||
static std::thread g_save_thread;
|
static std::thread g_save_thread;
|
||||||
|
|
||||||
// Don't forget to increase this after doing changes on the savestate system
|
// Don't forget to increase this after doing changes on the savestate system
|
||||||
static const u32 STATE_VERSION = 50; // Last changed in PR 3457
|
static const u32 STATE_VERSION = 51; // Last changed in PR 3530
|
||||||
|
|
||||||
// Maps savestate versions to Dolphin versions.
|
// Maps savestate versions to Dolphin versions.
|
||||||
// Versions after 42 don't need to be added to this list,
|
// Versions after 42 don't need to be added to this list,
|
||||||
|
@ -47,7 +47,7 @@ static u8* s_fifo_aux_read_ptr;
|
|||||||
bool g_use_deterministic_gpu_thread;
|
bool g_use_deterministic_gpu_thread;
|
||||||
|
|
||||||
static u64 s_last_sync_gpu_tick;
|
static u64 s_last_sync_gpu_tick;
|
||||||
static int s_et_syncGPU;
|
static int s_event_sync_gpu;
|
||||||
|
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
static u8* s_video_buffer;
|
static u8* s_video_buffer;
|
||||||
@ -497,6 +497,11 @@ void UpdateWantDeterminism(bool want)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function checks the emulated CPU - GPU distance and may wake up the GPU,
|
||||||
|
* or block the CPU if required. It should be called by the CPU thread regulary.
|
||||||
|
* @ticks The gone emulated CPU time.
|
||||||
|
* @return A good time to call Update() next.
|
||||||
|
*/
|
||||||
static int Update(int ticks)
|
static int Update(int ticks)
|
||||||
{
|
{
|
||||||
const SConfig& param = SConfig::GetInstance();
|
const SConfig& param = SConfig::GetInstance();
|
||||||
@ -513,10 +518,12 @@ static int Update(int ticks)
|
|||||||
return param.iSyncGpuMaxDistance;
|
return param.iSyncGpuMaxDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wakeup GPU
|
||||||
int old = s_sync_ticks.fetch_add(ticks);
|
int old = s_sync_ticks.fetch_add(ticks);
|
||||||
if (old < param.iSyncGpuMinDistance && old + ticks >= param.iSyncGpuMinDistance)
|
if (old < param.iSyncGpuMinDistance && old + ticks >= param.iSyncGpuMinDistance)
|
||||||
RunGpu();
|
RunGpu();
|
||||||
|
|
||||||
|
// Wait for GPU
|
||||||
if (s_sync_ticks.load() >= param.iSyncGpuMaxDistance)
|
if (s_sync_ticks.load() >= param.iSyncGpuMaxDistance)
|
||||||
{
|
{
|
||||||
while (s_sync_ticks.load() > 0)
|
while (s_sync_ticks.load() > 0)
|
||||||
@ -535,15 +542,16 @@ static void SyncGPUCallback(u64 userdata, int cyclesLate)
|
|||||||
s_last_sync_gpu_tick = now;
|
s_last_sync_gpu_tick = now;
|
||||||
|
|
||||||
if (next > 0)
|
if (next > 0)
|
||||||
CoreTiming::ScheduleEvent(next, s_et_syncGPU);
|
CoreTiming::ScheduleEvent(next, s_event_sync_gpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize GPU - CPU thread syncing, this gives us a deterministic way to start the GPU thread.
|
||||||
void Prepare()
|
void Prepare()
|
||||||
{
|
{
|
||||||
if (SConfig::GetInstance().bCPUThread && SConfig::GetInstance().bSyncGPU)
|
if (SConfig::GetInstance().bCPUThread && SConfig::GetInstance().bSyncGPU)
|
||||||
{
|
{
|
||||||
s_et_syncGPU = CoreTiming::RegisterEvent("SyncGPUCallback", SyncGPUCallback);
|
s_event_sync_gpu = CoreTiming::RegisterEvent("SyncGPUCallback", SyncGPUCallback);
|
||||||
CoreTiming::ScheduleEvent(0, s_et_syncGPU);
|
CoreTiming::ScheduleEvent(0, s_event_sync_gpu);
|
||||||
s_last_sync_gpu_tick = CoreTiming::GetTicks();
|
s_last_sync_gpu_tick = CoreTiming::GetTicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user