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 <zephyron@citron-emu.org>
This commit is contained in:
parent
ea8bb22148
commit
c8ee0041f2
@ -21,31 +21,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<f32>(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<f32>(swap_interval) / 100.f;
|
||||
}
|
||||
|
||||
swap_interval = 1;
|
||||
}
|
||||
|
||||
return swap_interval;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user