mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-14 15:51:29 +02:00
Merge pull request #13485 from jordan-woyak/timer-dualcore-fix
CoreTiming: Fix Precision Frame Timing in Dual Core mode on Windows.
This commit is contained in:
commit
2d1671a863
@ -373,22 +373,28 @@ TimePoint CoreTimingManager::GetTargetHostTime(s64 target_cycle)
|
||||
|
||||
void CoreTimingManager::SleepUntil(TimePoint time_point)
|
||||
{
|
||||
const TimePoint time = Clock::now();
|
||||
|
||||
if (time >= time_point)
|
||||
return;
|
||||
|
||||
if (m_use_precision_timer)
|
||||
m_precision_timer.SleepUntil(time_point);
|
||||
else
|
||||
std::this_thread::sleep_until(time_point);
|
||||
const bool use_precision_timer = m_use_precision_timer.load(std::memory_order_relaxed);
|
||||
|
||||
if (Core::IsCPUThread())
|
||||
{
|
||||
const TimePoint time = Clock::now();
|
||||
|
||||
if (use_precision_timer)
|
||||
m_precision_cpu_timer.SleepUntil(time_point);
|
||||
else
|
||||
std::this_thread::sleep_until(time_point);
|
||||
|
||||
// Count amount of time sleeping for analytics
|
||||
const TimePoint time_after_sleep = Clock::now();
|
||||
g_perf_metrics.CountThrottleSleep(time_after_sleep - time);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (use_precision_timer)
|
||||
m_precision_gpu_timer.SleepUntil(time_point);
|
||||
else
|
||||
std::this_thread::sleep_until(time_point);
|
||||
}
|
||||
}
|
||||
|
||||
void CoreTimingManager::Throttle(const s64 target_cycle)
|
||||
|
@ -159,7 +159,7 @@ public:
|
||||
// Throttle the CPU to the specified target cycle.
|
||||
void Throttle(const s64 target_cycle);
|
||||
|
||||
// May be used from any thread.
|
||||
// May be used from CPU or GPU thread.
|
||||
void SleepUntil(TimePoint time_point);
|
||||
|
||||
// Used by VideoInterface
|
||||
@ -216,8 +216,9 @@ private:
|
||||
int DowncountToCycles(int downcount) const;
|
||||
int CyclesToDowncount(int cycles) const;
|
||||
|
||||
bool m_use_precision_timer = false;
|
||||
Common::PrecisionTimer m_precision_timer;
|
||||
std::atomic_bool m_use_precision_timer = false;
|
||||
Common::PrecisionTimer m_precision_cpu_timer;
|
||||
Common::PrecisionTimer m_precision_gpu_timer;
|
||||
};
|
||||
|
||||
} // namespace CoreTiming
|
||||
|
Loading…
x
Reference in New Issue
Block a user