From e95c1d55e862047888eba9dc38b9c79656360f33 Mon Sep 17 00:00:00 2001 From: Sam Belliveau Date: Fri, 13 Jan 2023 11:59:32 -0500 Subject: [PATCH] Limit Sleep Calls to 8192hz at most --- Source/Core/Core/CoreTiming.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/CoreTiming.cpp b/Source/Core/Core/CoreTiming.cpp index 54a23f629c..fb1c15dbe5 100644 --- a/Source/Core/Core/CoreTiming.cpp +++ b/Source/Core/Core/CoreTiming.cpp @@ -335,13 +335,18 @@ void CoreTimingManager::Advance() void CoreTimingManager::Throttle(const s64 target_cycle) { - const double speed = - Core::GetIsThrottlerTempDisabled() ? 0.0 : Config::Get(Config::MAIN_EMULATION_SPEED); - // Based on number of cycles and emulation speed, increase the target deadline 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)) + return; + m_throttle_last_cycle = target_cycle; + const double speed = + Core::GetIsThrottlerTempDisabled() ? 0.0 : Config::Get(Config::MAIN_EMULATION_SPEED); + if (0.0 < speed) m_throttle_deadline += std::chrono::duration_cast
(DT_s(cycles) / (speed * m_throttle_clock_per_sec));