GPUDevice: Use present instead of current time for skip logic

Fixes erratic frame times when fast forwarding and below the
screen refresh rate.
This commit is contained in:
Stenzek committed 2026-01-18 13:29:00 +10:00
1 parent a7d29da8ef
commit abed81d53e
3 files changed
+9 -7

No files matched your search

+4 -3
View File
@@ -1188,9 +1188,10 @@ void GPUPresenter::CalculateDrawRect(const GSVector2i& window_size, bool apply_a
bool GPUPresenter::PresentFrame(GPUPresenter* presenter, GPUBackend* backend, bool allow_skip_present, u64 present_time)
{
const bool skip_present = (!g_gpu_device->HasMainSwapChain() ||
(allow_skip_present && g_gpu_device->GetMainSwapChain()->ShouldSkipPresentingFrame() &&
presenter && presenter->m_skipped_present_count < MAX_SKIPPED_PRESENT_COUNT));
const bool skip_present =
(!g_gpu_device->HasMainSwapChain() ||
(allow_skip_present && g_gpu_device->GetMainSwapChain()->ShouldSkipPresentingFrame(present_time) && presenter &&
presenter->m_skipped_present_count < MAX_SKIPPED_PRESENT_COUNT));
if (!skip_present)
{
+4 -3
View File
@@ -286,7 +286,7 @@ bool GPUSwapChain::IsExclusiveFullscreen() const
return false;
}
bool GPUSwapChain::ShouldSkipPresentingFrame()
bool GPUSwapChain::ShouldSkipPresentingFrame(u64 present_time)
{
// Only needed with FIFO. But since we're so fast, we allow it always.
if (!m_allow_present_throttle)
@@ -295,8 +295,9 @@ bool GPUSwapChain::ShouldSkipPresentingFrame()
const float throttle_rate = (m_window_info.surface_refresh_rate > 0.0f) ? m_window_info.surface_refresh_rate : 60.0f;
const float throttle_period = 1.0f / throttle_rate;
const u64 now = Timer::GetCurrentValue();
const double diff = Timer::ConvertValueToSeconds(now - m_last_frame_displayed_time);
const u64 wanted_time = (present_time == 0) ? Timer::GetCurrentValue() : present_time;
const double diff = Timer::ConvertValueToSeconds(wanted_time - m_last_frame_displayed_time);
m_last_frame_displayed_time = present_time;
if (diff < throttle_period)
return true;
+1 -1
View File
@@ -487,7 +487,7 @@ public:
/// Returns true if exclusive fullscreen is currently active on this swap chain.
virtual bool IsExclusiveFullscreen() const;
bool ShouldSkipPresentingFrame();
bool ShouldSkipPresentingFrame(u64 present_time);
void UpdateLastFramePresentedTime(u64 presented_time = 0);
void ThrottlePresentation();