From 08e91eb4cacf1eeb838ea09fbce98bde1d4e8b4c Mon Sep 17 00:00:00 2001 From: Spodi Date: Wed, 12 Feb 2025 00:28:15 +0100 Subject: [PATCH] Clamp FPS to refresh rate when V-Sync on --- soh/soh/OTRGlobals.cpp | 8 +++++--- soh/soh/SohGui/SohMenuBar.cpp | 8 +------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 74a51e4a79f..14f4ea3de97 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -493,11 +493,13 @@ bool OTRGlobals::HasOriginal() { } uint32_t OTRGlobals::GetInterpolationFPS() { - if (CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0) || Ship::Context::GetInstance()->GetConsoleVariables()->GetInteger(CVAR_VSYNC_ENABLED, 1)) { + if (CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0)) { return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); } - - return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20)); + else if (CVarGetInteger(CVAR_VSYNC_ENABLED, 1)) { + return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20)); + } + return CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20); } extern "C" void OTRMessage_Init(); diff --git a/soh/soh/SohGui/SohMenuBar.cpp b/soh/soh/SohGui/SohMenuBar.cpp index 4e40c48fa42..dbbd3eab213 100644 --- a/soh/soh/SohGui/SohMenuBar.cpp +++ b/soh/soh/SohGui/SohMenuBar.cpp @@ -374,13 +374,7 @@ void DrawSettingsMenu() { UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); { // FPS Slider const int minFps = 20; - static int maxFps; - // if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { - maxFps = 360; - /* } - else { - maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); - } */ + static int maxFps = 360; int currentFps = fmax(fmin(OTRGlobals::Instance->GetInterpolationFPS(), maxFps), minFps); #ifdef __WIIU__ UIWidgets::Spacer(0);