Skip to content

Commit

Permalink
Clamp FPS to refresh rate when V-Sync on
Browse files Browse the repository at this point in the history
  • Loading branch information
Spodi committed Feb 21, 2025
1 parent 33cda37 commit 08e91eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 5 additions & 3 deletions soh/soh/OTRGlobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20));
else if (CVarGetInteger(CVAR_VSYNC_ENABLED, 1)) {
return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20));
}
return CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20);
}

extern "C" void OTRMessage_Init();
Expand Down
8 changes: 1 addition & 7 deletions soh/soh/SohGui/SohMenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 08e91eb

Please sign in to comment.