Add configurable FPS cap to CPU Sleep frame rate control, and fix the broken deadline math in LimitFrameRate - #8632
Open
romanstingler wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a user-facing FPS Cap option under Settings → Graphics that lets players pick a target frame rate (
30 / 60 / 75 / 120 / 144 / 165 / 240 / 360) when Frame Rate Control is set to Limit FPS.While implementing, I noticed the existing
LimitFrameRate()math was wrong, even with the option enabled, the cap oscillated between the target and the native framerate instead of holding steady. This PR rewrites the deadline logic with a simple, correct steady-interval scheduler.What's new (feature)
GraphicsOptions::fpsCapoption (default:60), with allowed values30, 60, 75, 120, 144, 165, 240, 360.CantChangeInGame(matches the neighbouring Frame Rate Control row).What's fixed
LimitFrameRate()previously:Two bugs:
v = tc % frameDelay, i.e. the time already elapsed in the current frame interval, instead of the time remaining until the next interval boundary. The scheduler ended up roughly doubling the intended wait.frameDeadlinewas recomputed each frame astc + v + frameDelay, causing a per-iteration drift ofvmicroseconds. Net effect: the cap never settled and oscillated between fast and slow framerates, with reported FPS well above the target.Replaced with a steady-interval scheduler that advances
frameDeadlinebyframeDelayper frame and waitsframeDeadline - tcLimitations / known gotchas
The FPS Cap only takes effect when Frame Rate Control is set to Limit FPS (CPU Sleep). With Vertical Sync on, the limiter returns early and the new option is a no-op, the cap is gated by design.