Fifo: only sleep once within every ms of emulated time

This commit is contained in:
degasus 2015-03-13 23:36:31 +01:00
parent b020ae1c5d
commit d2c62b1744
4 changed files with 15 additions and 3 deletions

View File

@ -199,6 +199,9 @@ static void PatchEngineCallback(u64 userdata, int cyclesLate)
static void ThrottleCallback(u64 last_time, int cyclesLate)
{
// Allow the GPU thread to sleep. Setting this flag here limits the wakeups to 1 kHz.
CommandProcessor::s_gpuMaySleep.Set();
u32 time = Common::Timer::GetTimeMs();
int diff = (u32)last_time - time;

View File

@ -45,6 +45,8 @@ volatile bool interruptWaiting= false;
volatile bool interruptTokenWaiting = false;
volatile bool interruptFinishWaiting = false;
Common::Flag s_gpuMaySleep;
volatile u32 VITicks = CommandProcessor::m_cpClockOrigin;
static bool IsOnThread()

View File

@ -5,6 +5,7 @@
#pragma once
#include "Common/CommonTypes.h"
#include "Common/Flag.h"
#include "VideoCommon/VideoBackendBase.h"
class PointerWrap;
@ -21,6 +22,7 @@ extern volatile bool interruptSet;
extern volatile bool interruptWaiting;
extern volatile bool interruptTokenWaiting;
extern volatile bool interruptFinishWaiting;
extern Common::Flag s_gpuMaySleep;
// internal hardware addresses
enum

View File

@ -369,9 +369,13 @@ void RunGpuLoop()
{
if (s_gpu_is_running.IsSet())
{
// reset the atomic flag. But as the CPU thread might have pushed some new data, we have to rerun the GPU loop
s_gpu_is_pending.Set();
s_gpu_is_running.Clear();
if (CommandProcessor::s_gpuMaySleep.IsSet())
{
// Reset the atomic flag. But as the CPU thread might have pushed some new data, we have to rerun the GPU loop
s_gpu_is_pending.Set();
s_gpu_is_running.Clear();
CommandProcessor::s_gpuMaySleep.Clear();
}
}
else
{
@ -403,6 +407,7 @@ void FlushGpu()
while (s_gpu_is_running.IsSet() || s_gpu_is_pending.IsSet())
{
CommandProcessor::s_gpuMaySleep.Set();
s_gpu_done_event.Wait();
}
}