mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-28 09:59:32 -06: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:
@ -373,22 +373,28 @@ TimePoint CoreTimingManager::GetTargetHostTime(s64 target_cycle)
|
|||||||
|
|
||||||
void CoreTimingManager::SleepUntil(TimePoint time_point)
|
void CoreTimingManager::SleepUntil(TimePoint time_point)
|
||||||
{
|
{
|
||||||
const TimePoint time = Clock::now();
|
const bool use_precision_timer = m_use_precision_timer.load(std::memory_order_relaxed);
|
||||||
|
|
||||||
if (time >= time_point)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_use_precision_timer)
|
|
||||||
m_precision_timer.SleepUntil(time_point);
|
|
||||||
else
|
|
||||||
std::this_thread::sleep_until(time_point);
|
|
||||||
|
|
||||||
if (Core::IsCPUThread())
|
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
|
// Count amount of time sleeping for analytics
|
||||||
const TimePoint time_after_sleep = Clock::now();
|
const TimePoint time_after_sleep = Clock::now();
|
||||||
g_perf_metrics.CountThrottleSleep(time_after_sleep - time);
|
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)
|
void CoreTimingManager::Throttle(const s64 target_cycle)
|
||||||
|
@ -159,7 +159,7 @@ public:
|
|||||||
// Throttle the CPU to the specified target cycle.
|
// Throttle the CPU to the specified target cycle.
|
||||||
void Throttle(const s64 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);
|
void SleepUntil(TimePoint time_point);
|
||||||
|
|
||||||
// Used by VideoInterface
|
// Used by VideoInterface
|
||||||
@ -216,8 +216,9 @@ private:
|
|||||||
int DowncountToCycles(int downcount) const;
|
int DowncountToCycles(int downcount) const;
|
||||||
int CyclesToDowncount(int cycles) const;
|
int CyclesToDowncount(int cycles) const;
|
||||||
|
|
||||||
bool m_use_precision_timer = false;
|
std::atomic_bool m_use_precision_timer = false;
|
||||||
Common::PrecisionTimer m_precision_timer;
|
Common::PrecisionTimer m_precision_cpu_timer;
|
||||||
|
Common::PrecisionTimer m_precision_gpu_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CoreTiming
|
} // namespace CoreTiming
|
||||||
|
Reference in New Issue
Block a user