FEATURE: Interpolation Pacer#1137
Open
JeodC 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.
The current interpolation system takes a requested rate from the port and meets the demand, even if it sacrifices performance. This is more easily noticeable in Lighthouse with maximum draw distance. While some strong single-core processors will have zero problem, others designed for multi-core will run into lower framerate due to the way interpolation works.
Lighthouse has a version of this pull request already, called
AdaptiveFPS. This pull request moves that mechanism to libultraship so it can be shared with other ports. It adds a small, self-containedFast::InterpolationPacerthat decides how many interpolated sub-frames to render between two fixed-rate game ticks, bounded by the measured render budget. It is additive and opt-in: a port adopts it by feedingPlan()in place of its raw accumulator. Ports that don't adopt it are unaffected.Given the user's target FPS, the game's native tick rate, and per-tick measurements of game-logic time and per-sub-frame render cost, it returns how many sub-frames fit the tick's render budget (after reserving logic time), plus the present-pace FPS to feed
Window::SetTargetFps. A heavy scene falls back toward the native rate (keyframe + as many tweens as fit) instead of multiplying render cost across tweens. Game speed stays correct; only smoothness degrades under load.Design Notes
nativeLogicFpsis host-supplied, no baked-in rate. Native tick differs per game (20 Hz OoT/MM, 30 Hz SM64/MK64/BK) and can vary per tick (pause/cutscene).SetSmoothness()optionally exposes the budget safety factor; the default is sensible and most ports won't surface it.<chrono>,<cstdint>,<algorithm>. No new dependencies.