Limit Throttling to 1200hz

This commit is contained in:
Sam Belliveau 2023-01-13 18:17:24 -05:00
parent e95c1d55e8
commit e849172dc9
2 changed files with 8 additions and 3 deletions

View File

@ -339,7 +339,7 @@ void CoreTimingManager::Throttle(const s64 target_cycle)
const s64 cycles = target_cycle - m_throttle_last_cycle;
// Prevent any throttling code if the amount of time passed is < ~0.122ms
if (cycles < (m_throttle_clock_per_sec >> 13))
if (cycles < m_throttle_min_clock_per_sleep)
return;
m_throttle_last_cycle = target_cycle;
@ -403,6 +403,7 @@ void CoreTimingManager::LogPendingEvents() const
void CoreTimingManager::AdjustEventQueueTimes(u32 new_ppc_clock, u32 old_ppc_clock)
{
m_throttle_clock_per_sec = new_ppc_clock;
m_throttle_min_clock_per_sleep = new_ppc_clock / 1200;
for (Event& ev : m_event_queue)
{

View File

@ -140,6 +140,11 @@ public:
// Directly accessed by the JIT.
Globals& GetGlobals() { return m_globals; }
// Throttle the CPU to the specified target cycle.
// Never used outside of CoreTiming, however it remains public
// in order to allow custom throttling implementations to be tested.
void Throttle(const s64 target_cycle);
TimePoint GetCPUTimePoint(s64 cyclesLate) const; // Used by Dolphin Analytics
private:
@ -178,8 +183,7 @@ private:
s64 m_throttle_last_cycle = 0;
TimePoint m_throttle_deadline = Clock::now();
s64 m_throttle_clock_per_sec;
void Throttle(const s64 target_cycle);
s64 m_throttle_min_clock_per_sleep;
int DowncountToCycles(int downcount) const;
int CyclesToDowncount(int cycles) const;