From 9888a50cbdf9f4538652ab616580f1e3dd3beb64 Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Fri, 8 Dec 2023 14:02:41 +0900 Subject: [PATCH] steamcompmgr: Fix calculated refresh cycle for present timing The "target FPS" feature divides vblank to achieve a target refresh rate. Previously, the target frame time was divided by the divisor again, making it way too small and nonsensical. Correctly calculate this by multiplying instead of dividing. Since the real refresh rate may be odd, apply the multiplier after dividing to avoid rounding error. --- src/steamcompmgr.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index b02fa331c..2042b9125 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -7916,11 +7916,10 @@ steamcompmgr_main(int argc, char **argv) int nRealRefresh = g_nNestedRefresh ? g_nNestedRefresh : g_nOutputRefresh; int nTargetFPS = g_nSteamCompMgrTargetFPS ? g_nSteamCompMgrTargetFPS : nRealRefresh; nTargetFPS = std::min( nTargetFPS, nRealRefresh ); - int nMultiplier = nRealRefresh / nTargetFPS; + int nVblankDivisor = nRealRefresh / nTargetFPS; - int nAppRefresh = nRealRefresh * nMultiplier; g_SteamCompMgrAppRefreshCycle = 1'000'000'000ul / nRealRefresh; - g_SteamCompMgrLimitedAppRefreshCycle = 1'000'000'000ul / nAppRefresh; + g_SteamCompMgrLimitedAppRefreshCycle = 1'000'000'000ul / nRealRefresh * nVblankDivisor; } // Handle presentation-time stuff