diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index fb1c15dbe5..eb7b537a61 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -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) { diff --git a/Source/Core/Core/CoreTiming.h b/Source/Core/Core/CoreTiming.h index 5918e0f353..1a860c5fa5 100644 --- a/Source/Core/Core/CoreTiming.h +++ b/Source/Core/Core/CoreTiming.h @@ -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;