From 28bda618b8469cf00cfcb1d0a4629a5cdffbd06a Mon Sep 17 00:00:00 2001 From: Spodi Date: Fri, 28 Mar 2025 23:33:09 +0100 Subject: Unify FPS and V-Sync controls and behavior (#181) - DirectX's "Match Refresh Rate" is now a checkbox like in OpenGL and Metal. - Clamp max FPS to refresh rate when V-Sync is enabled or can't be disabled, regardless of the FPS sliders setting, to avoid slowdown in Metal / OpenGL and dropping frames in DirectX as much as possible. -FPS slider allows up to 360 FPS in every renderer. - More descriptive V-Sync tooltip Also fixes GetInterpolationFPS() not being used to calculate desired FPS. Co-authored-by: Lywx --- src/port/Engine.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/port/Engine.cpp') diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index eeac4b33..f85e2729 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -480,7 +480,7 @@ void GameEngine::ProcessGfxCommands(Gfx* commands) { wnd->SetRendererUCode(UcodeHandlers::ucode_f3dex); std::vector> mtx_replacements; - int target_fps = CVarGetInteger("gInterpolationFPS", 60); + int target_fps = GameEngine::Instance->GetInterpolationFPS(); static int last_fps; static int last_update_rate; static int time; @@ -526,16 +526,16 @@ void GameEngine::ProcessGfxCommands(Gfx* commands) { } uint32_t GameEngine::GetInterpolationFPS() { - if (Ship::Context::GetInstance()->GetWindow()->GetWindowBackend() == Ship::WindowBackend::FAST3D_DXGI_DX11) { - return CVarGetInteger("gInterpolationFPS", 60); - } - if (CVarGetInteger("gMatchRefreshRate", 0)) { return Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + + } else if (CVarGetInteger("gVsyncEnabled", 1) || + !Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { + return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), + CVarGetInteger("gInterpolationFPS", 60)); } - return std::min(Ship::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(), - CVarGetInteger("gInterpolationFPS", 60)); + return CVarGetInteger("gInterpolationFPS", 60); } uint32_t GameEngine::GetInterpolationFrameCount() -- cgit v1.2.3