From abed81d53e5e014cd461bb80a8dd5dd0b666c227 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 18 Jan 2026 13:28:32 +1000 Subject: [PATCH] GPUDevice: Use present instead of current time for skip logic Fixes erratic frame times when fast forwarding and below the screen refresh rate. --- src/core/gpu_presenter.cpp | 7 ++++--- src/util/gpu_device.cpp | 7 ++++--- src/util/gpu_device.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/gpu_presenter.cpp b/src/core/gpu_presenter.cpp index 6329ff6e5..def8c5c28 100644 --- a/src/core/gpu_presenter.cpp +++ b/src/core/gpu_presenter.cpp @@ -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) { diff --git a/src/util/gpu_device.cpp b/src/util/gpu_device.cpp index 165a9c7f1..33341013a 100644 --- a/src/util/gpu_device.cpp +++ b/src/util/gpu_device.cpp @@ -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; diff --git a/src/util/gpu_device.h b/src/util/gpu_device.h index f0ea465b1..d9eec48a2 100644 --- a/src/util/gpu_device.h +++ b/src/util/gpu_device.h @@ -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();