mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-10 19:13:49 +00:00
Fifo: only sleep once within every ms of emulated time
This commit is contained in:
parent
b020ae1c5d
commit
d2c62b1744
@ -199,6 +199,9 @@ static void PatchEngineCallback(u64 userdata, int cyclesLate)
|
|||||||
|
|
||||||
static void ThrottleCallback(u64 last_time, 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();
|
u32 time = Common::Timer::GetTimeMs();
|
||||||
|
|
||||||
int diff = (u32)last_time - time;
|
int diff = (u32)last_time - time;
|
||||||
|
@ -45,6 +45,8 @@ volatile bool interruptWaiting= false;
|
|||||||
volatile bool interruptTokenWaiting = false;
|
volatile bool interruptTokenWaiting = false;
|
||||||
volatile bool interruptFinishWaiting = false;
|
volatile bool interruptFinishWaiting = false;
|
||||||
|
|
||||||
|
Common::Flag s_gpuMaySleep;
|
||||||
|
|
||||||
volatile u32 VITicks = CommandProcessor::m_cpClockOrigin;
|
volatile u32 VITicks = CommandProcessor::m_cpClockOrigin;
|
||||||
|
|
||||||
static bool IsOnThread()
|
static bool IsOnThread()
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/Flag.h"
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
|
||||||
class PointerWrap;
|
class PointerWrap;
|
||||||
@ -21,6 +22,7 @@ extern volatile bool interruptSet;
|
|||||||
extern volatile bool interruptWaiting;
|
extern volatile bool interruptWaiting;
|
||||||
extern volatile bool interruptTokenWaiting;
|
extern volatile bool interruptTokenWaiting;
|
||||||
extern volatile bool interruptFinishWaiting;
|
extern volatile bool interruptFinishWaiting;
|
||||||
|
extern Common::Flag s_gpuMaySleep;
|
||||||
|
|
||||||
// internal hardware addresses
|
// internal hardware addresses
|
||||||
enum
|
enum
|
||||||
|
@ -369,9 +369,13 @@ void RunGpuLoop()
|
|||||||
{
|
{
|
||||||
if (s_gpu_is_running.IsSet())
|
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
|
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_pending.Set();
|
||||||
s_gpu_is_running.Clear();
|
s_gpu_is_running.Clear();
|
||||||
|
CommandProcessor::s_gpuMaySleep.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -403,6 +407,7 @@ void FlushGpu()
|
|||||||
|
|
||||||
while (s_gpu_is_running.IsSet() || s_gpu_is_pending.IsSet())
|
while (s_gpu_is_running.IsSet() || s_gpu_is_pending.IsSet())
|
||||||
{
|
{
|
||||||
|
CommandProcessor::s_gpuMaySleep.Set();
|
||||||
s_gpu_done_event.Wait();
|
s_gpu_done_event.Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user