From f1e169e060bcb6cd87751f4cd39a765a3aaca4b4 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Fri, 18 Apr 2025 10:11:16 +1000 Subject: [PATCH] fix: correct implementation of present interval 0 for unlocked FPS Fixes issues in commit bbd32531697fbfb8ed5b6859d3951bf8380e5999 that could cause crashes and deadlocks. The feature now works as intended, allowing games using present interval 0 to run with truly unlocked FPS. This ensures proper functionality of dynamic framerate mods like UltraCam by MaxLastBreath (https://www.nxoptimizer.com/) without stability problems. Signed-off-by: Zephyron --- .../service/nvnflinger/hardware_composer.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/core/hle/service/nvnflinger/hardware_composer.cpp b/src/core/hle/service/nvnflinger/hardware_composer.cpp index 9ed4291b5..c88b1feef 100644 --- a/src/core/hle/service/nvnflinger/hardware_composer.cpp +++ b/src/core/hle/service/nvnflinger/hardware_composer.cpp @@ -19,31 +19,24 @@ namespace { s32 NormalizeSwapInterval(f32* out_speed_scale, s32 swap_interval) { if (swap_interval <= 0) { - // If swap_interval is 0 and setting enabled, respect it as unlocked FPS - if (swap_interval == 0 && Settings::values.respect_present_interval_zero.GetValue()) { - if (out_speed_scale) { - *out_speed_scale = 1.0f; - } - return 0; - } - // As an extension, treat nonpositive swap interval as speed multiplier. if (out_speed_scale) { *out_speed_scale = 2.f * static_cast(1 - swap_interval); } - - swap_interval = 1; + // Only normalize swap_interval to 1 if we're not respecting present interval 0 + if (swap_interval == 0 && Settings::values.respect_present_interval_zero.GetValue()) { + // Keep swap_interval as 0 to allow for unlocked FPS + } else { + swap_interval = 1; + } } - if (swap_interval >= 5) { // As an extension, treat high swap interval as precise speed control. if (out_speed_scale) { *out_speed_scale = static_cast(swap_interval) / 100.f; } - swap_interval = 1; } - return swap_interval; }