From a13b821f95ce234c47b80c1c616891a3a6438711 Mon Sep 17 00:00:00 2001 From: netborg <137700136+netborg-afps@users.noreply.github.com> Date: Sun, 23 Feb 2025 09:54:07 +0100 Subject: [PATCH] [dxvk] Allow for fps limit < 50 fps in low-latency mode --- dxvk.conf | 4 ++-- src/dxvk/framepacer/dxvk_framepacer_mode_low_latency.h | 3 ++- src/dxvk/framepacer/dxvk_framepacer_mode_min_latency.h | 3 ++- src/util/util_fps_limiter.cpp | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index 0b8deba8c..d8ae19950 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -39,7 +39,7 @@ # # Supported values: "max-frame-latency", "low-latency", "min-latency" -# dxvk.framePacing = "" +# dxvk.framePace = "" # Allows fine-tuning the low-latency frame pacing mode. @@ -149,7 +149,7 @@ # The implementation will either use VK_NV_low_latency2 if supported # by the driver, or a custom algorithm. # - False: Disable Reflex support as well as built-in latency reduction. -# This build defaults to False to enable dxvk.framePacing. You need to +# This build defaults to False to enable dxvk.framePace. You need to # enable Reflex manually (Auto) until we support switching back and # forth between Reflex and the low-latency frame pacing - for example # via the ingame options - and more critically we want to enable diff --git a/src/dxvk/framepacer/dxvk_framepacer_mode_low_latency.h b/src/dxvk/framepacer/dxvk_framepacer_mode_low_latency.h index ec1d4f542..28f5f170b 100644 --- a/src/dxvk/framepacer/dxvk_framepacer_mode_low_latency.h +++ b/src/dxvk/framepacer/dxvk_framepacer_mode_low_latency.h @@ -164,7 +164,8 @@ namespace dxvk { int32_t frametime = std::chrono::duration_cast( t - m_lastStart ).count(); int32_t frametimeDiff = std::max( 0, m_fpsLimitFrametime.load() - frametime ); delay = std::max( delay, frametimeDiff ); - delay = std::max( 0, std::min( delay, 20000 ) ); + int32_t maxDelay = std::max( m_fpsLimitFrametime.load(), 20000 ); + delay = std::max( 0, std::min( delay, maxDelay ) ); Sleep::TimePoint nextStart = t + microseconds(delay); Sleep::sleepUntil( t, nextStart ); diff --git a/src/dxvk/framepacer/dxvk_framepacer_mode_min_latency.h b/src/dxvk/framepacer/dxvk_framepacer_mode_min_latency.h index 763a5368c..03e94d0de 100644 --- a/src/dxvk/framepacer/dxvk_framepacer_mode_min_latency.h +++ b/src/dxvk/framepacer/dxvk_framepacer_mode_min_latency.h @@ -28,7 +28,8 @@ namespace dxvk { now - m_lastStart ).count(); int32_t frametimeDiff = std::max( 0, m_fpsLimitFrametime.load() - frametime ); int32_t delay = std::max( 0, frametimeDiff ); - delay = std::min( delay, 20000 ); + int32_t maxDelay = std::max( m_fpsLimitFrametime.load(), 20000 ); + delay = std::min( delay, maxDelay ); Sleep::TimePoint nextStart = now + std::chrono::microseconds(delay); Sleep::sleepUntil( now, nextStart ); diff --git a/src/util/util_fps_limiter.cpp b/src/util/util_fps_limiter.cpp index 95fb79e7e..f8866ff16 100644 --- a/src/util/util_fps_limiter.cpp +++ b/src/util/util_fps_limiter.cpp @@ -57,6 +57,8 @@ namespace dxvk { return; } + m_isActive.store(false); + std::unique_lock lock(m_mutex); auto interval = m_targetInterval; auto latency = m_maxLatency; @@ -79,7 +81,6 @@ namespace dxvk { // that can be written by setTargetFrameRate lock.unlock(); - m_isActive.store(false); if (t1 < m_nextFrame) { m_isActive.store(true); Sleep::sleepUntil(t1, m_nextFrame);