Unify FPS and V-Sync controls and behavior between renderer (#5132)

* FPS and refresh rate logic changes

Changes FPS behavior on all renderer (despite the actual set FPS):
- Clamp FPS to refresh rate when V-Sync on (or can't be disabled)
- Stick to refresh rate when "MatchRefreshRate" is toggled on

* Max 360 FPS for slider on all renderers

* "Match Refresh Rate" unification

Checkbox for all renderer. Was a button for DirectX.

* Fix wrong CVAR for Match Refresh Rate

* More descriptive V-Sync tooltip

* Fix wrong CVar for DISABLE_FOR_DEBUG_MODE_OFF
This commit is contained in:
Spodi 2025-03-18 09:24:50 +01:00 committed by GitHub
parent 63ae14cc30
commit 546b915106
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 34 deletions

View file

@ -499,15 +499,12 @@ bool OTRGlobals::HasOriginal() {
}
uint32_t OTRGlobals::GetInterpolationFPS() {
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
return CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20);
}
if (CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0)) {
return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
} else if (CVarGetInteger(CVAR_VSYNC_ENABLED, 1) || !Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) {
return std::min<uint32_t>(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), CVarGetInteger(CVAR_SETTING("InterpolationFPS"), 20));
}
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();

View file

@ -125,7 +125,7 @@ void SohMenu::InitElement() {
},
"Not Available on DirectX" } },
{ DISABLE_FOR_MATCH_REFRESH_RATE_ON,
{ [](disabledInfo& info) -> bool { return CVarGetInteger(CVAR_SETTING("gMatchRefreshRate"), 0); },
{ [](disabledInfo& info) -> bool { return CVarGetInteger(CVAR_SETTING("MatchRefreshRate"), 0); },
"Match Refresh Rate is Enabled" } },
{ DISABLE_FOR_ADVANCED_RESOLUTION_ON,
{ [](disabledInfo& info) -> bool { return CVarGetInteger(CVAR_PREFIX_ADVANCED_RESOLUTION ".Enabled", 0); },
@ -140,7 +140,7 @@ void SohMenu::InitElement() {
{ DISABLE_FOR_NULL_PLAY_STATE,
{ [](disabledInfo& info) -> bool { return gPlayState == NULL; }, "Save Not Loaded" } },
{ DISABLE_FOR_DEBUG_MODE_OFF,
{ [](disabledInfo& info) -> bool { return !CVarGetInteger("gDeveloperTools.DebugEnabled", 0); },
{ [](disabledInfo& info) -> bool { return !CVarGetInteger(CVAR_DEVELOPER_TOOLS("DebugEnabled"), 0); },
"Debug Mode is Disabled" } },
{ DISABLE_FOR_FRAME_ADVANCE_OFF,
{ [](disabledInfo& info) -> bool { return !(gPlayState != nullptr && gPlayState->frameAdvCtx.enabled); },

View file

@ -201,18 +201,10 @@ void SohMenu::AddMenuSettings() {
AddWidget(path, "Audio API (Needs reload)", WIDGET_AUDIO_BACKEND);
// Graphics Settings
static int32_t maxFps;
const char* tooltip = "";
if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) {
maxFps = 360;
tooltip = "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is "
"purely visual and does not impact game logic, execution of glitches etc.\n\nA higher target "
"FPS than your monitor's refresh rate will waste resources, and might give a worse result.";
} else {
maxFps = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
tooltip = "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is "
"purely visual and does not impact game logic, execution of glitches etc.";
}
static int32_t maxFps = 360;
const char* tooltip = "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is "
"purely visual and does not impact game logic, execution of glitches etc.\n\nA higher target "
"FPS than your monitor's refresh rate will waste resources, and might give a worse result.";
path.sidebarName = "Graphics";
AddSidebarEntry("Settings", "Graphics", 3);
AddWidget(path, "Toggle Fullscreen", WIDGET_CVAR_CHECKBOX)
@ -276,25 +268,14 @@ void SohMenu::AddMenuSettings() {
info.activeDisables.push_back(DISABLE_FOR_MATCH_REFRESH_RATE_ON);
})
.Options(IntSliderOptions().Tooltip(tooltip).Min(20).Max(maxFps).DefaultValue(20).Format(fpsFormat));
AddWidget(path, "Match Refresh Rate", WIDGET_BUTTON)
.Callback([](WidgetInfo& info) {
int hz = Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate();
if (hz >= 20 && hz <= 360) {
CVarSetInteger(CVAR_SETTING("InterpolationFPS"), hz);
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}
})
.PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NOT_DIRECTX).active; })
.Options(ButtonOptions().Tooltip("Matches interpolation value to the current game's window refresh rate."));
AddWidget(path, "Match Refresh Rate", WIDGET_CVAR_CHECKBOX)
.CVar("gMatchRefreshRate")
.PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_DIRECTX).active; })
.Options(CheckboxOptions().Tooltip("Matches interpolation value to the current game's window refresh rate."));
.CVar(CVAR_SETTING("MatchRefreshRate"))
.Options(CheckboxOptions().Tooltip("Matches interpolation value to the refresh rate of your display."));
AddWidget(path, "Renderer API (Needs reload)", WIDGET_VIDEO_BACKEND);
AddWidget(path, "Enable Vsync", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_VSYNC_ENABLED)
.PreFunc([](WidgetInfo& info) { info.isHidden = mSohMenu->disabledMap.at(DISABLE_FOR_NO_VSYNC).active; })
.Options(CheckboxOptions().Tooltip("Enables Vsync."));
.Options(CheckboxOptions().Tooltip("Removes tearing, but clamps your max FPS to your displays refresh rate."));
AddWidget(path, "Windowed Fullscreen", WIDGET_CVAR_CHECKBOX)
.CVar(CVAR_SDL_WINDOWED_FULLSCREEN)
.PreFunc([](WidgetInfo& info) {