Merge pull request #11367 from Sam-Belliveau/lagbegone

VideoCommon: VI Skip
This commit is contained in:
Pierre Bourdon
2023-01-19 01:20:01 +01:00
committed by GitHub
15 changed files with 53 additions and 3 deletions

View File

@ -24,6 +24,7 @@
#include "VideoCommon/Fifo.h"
#include "VideoCommon/PerformanceMetrics.h"
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
namespace CoreTiming
{
@ -359,7 +360,7 @@ void CoreTimingManager::Throttle(const s64 target_cycle)
// A maximum fallback is used to prevent the system from sleeping for
// too long or going full speed in an attempt to catch up to timings.
const DT max_fallback =
std::chrono::duration_cast<DT>(DT_ms(Config::Get(Config::MAIN_TIMING_VARIANCE)));
std::chrono::duration_cast<DT>(DT_ms(Config::Get(Config::MAIN_MAX_FALLBACK)));
const TimePoint time = Clock::now();
const TimePoint min_deadline = time - max_fallback;
@ -376,6 +377,13 @@ void CoreTimingManager::Throttle(const s64 target_cycle)
m_throttle_deadline = min_deadline;
}
// Skip the VI interrupt if the CPU is lagging by a certain amount.
// It doesn't matter what amount of lag we skip VI at, as long as it's constant.
const DT max_variance =
std::chrono::duration_cast<DT>(DT_ms(Config::Get(Config::MAIN_TIMING_VARIANCE)));
const TimePoint vi_deadline = time - max_variance;
m_throttle_disable_vi_int = 0.0 < speed && m_throttle_deadline < vi_deadline;
// Only sleep if we are behind the deadline
if (time < m_throttle_deadline)
{
@ -399,6 +407,11 @@ TimePoint CoreTimingManager::GetCPUTimePoint(s64 cyclesLate) const
m_throttle_clock_per_sec));
}
bool CoreTimingManager::GetVISkip() const
{
return m_throttle_disable_vi_int && g_ActiveConfig.bVISkip && !Core::WantsDeterminism();
}
void CoreTimingManager::LogPendingEvents() const
{
auto clone = m_event_queue;