Skip to content

Commit

Permalink
steamcompmgr: Fix calculated refresh cycle for present timing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ishitatsuyuki authored and misyltoad committed Dec 18, 2023
1 parent 243582c commit 9888a50
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( 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
Expand Down

0 comments on commit 9888a50

Please sign in to comment.