Frame pacing and present latency: measure first, then waitable swap chain, tearing and an interval override #728
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork#728
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Revens2 on GitHub · 2026-11-25 05:48 UTC · original
Problem
Two related questions, kept together because they share the same code:
Neither is answered by a measurement in this repository today. The reports here measure world frames of roughly 200 to 800 ms (0.4 to 5 fps; for example #696, #616, #535, #418), where the host's pacing clock is not the limit: the cost is in texture preparation, copy-back and GPU work. So this issue matters for menus, videos and for the day the world runs faster, and its first deliverable is a measurement, not a change.
Related work (checked 2026-11-25; searches: latency, present, vsync, tearing, frame pacing, frame cap, fps limit)
No open or closed issue covers latency or an uncapped frame rate. Overlapping items:
frame::before_present(), so it is a direct neighbour of any change here.fps_limitsetting; that is a cap we add, the opposite of what this issue studies.Current state of the code (
origin/mainat310c6eb)Frame clock (
crates/victory-gpu/src/frame.rs, device methods 0x270 to 0x288):set_interval,lengthin microseconds; 0 means 1/60 s) and aperiod(pipeline depth) which is read and ignored. Our clock ticks once per interval from that moment, and each event kind (origin, vblank, flip) ends once per tick. Event offsets are ignored (schedulereturns success and stores nothing).waitsleeps until the next tick or the time-out. A blocking wait for an event that has already happened (a frame that took longer than a tick) ends at once (theVICTORY_LATE_WAITS=1switch restores sleeping to the next tick).frame.rs). So the title's own cadence isintervalas long as its frames take less than that.Present (
crates/victory-gpu/src/host.rs,Presenter,present):IDXGISwapChain3,DXGI_SWAP_EFFECT_FLIP_DISCARD,BUFFERS = 2,SwapChain flags = 0,Present(0, 0)(sync interval 0, noDXGI_PRESENT_ALLOW_TEARING).DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING, noDXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT, noSetMaximumFrameLatency(the DXGI default applies; the value on this device is not measured).CopyResourceof the title's texture into the back buffer thenPresent. With presents sent ahead (late_free_present) the copy is submitted on its own list and a settle is not waited for.ResizeBuffersis called with flags 0 when the size or format changes; any flag added at creation has to be repeated there.Proposal, in deliverable phases
Presentitself blocked, the time between the title's origin wait ending and the present, and the number of presents with no flip wait since the last one (#457's case). Output goes to the existing frame-rate log line and, when #717 is in, to its panel/overlay.log. Run on the first menu, the opening movie and the world. Deliverable: a table of those figures from one NVIDIA and one AMD run, with no game data.VICTORY_PRESENT=lowlat:DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECTwithSetMaximumFrameLatency(1)and a wait on the handle before the back buffer is acquired, andALLOW_TEARINGwhenCheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING)says yes and the window is borderless/fullscreen, withPresent(0, DXGI_PRESENT_ALLOW_TEARING). Flags repeated inResizeBuffers. KeepBUFFERSat 2 first, try 3 only with a measured reason.VICTORY_FRAME_INTERVAL=<us>replaces the length passed toset_interval. Purpose: find out whether the title's simulation step depends on the interval (it may read the interval as its time step, or measure real time; not verified). A run that shows the game speed changing with the override settles the question and also settles the "unlock" question: if game speed follows the interval, an unlock needs a different mechanism (render faster than simulation), which the host cannot do for a title it does not control.[display] frame_intervalwith a bounded range, and movies/menus excluded or tested separately (the intro movie's cadence is already fragile, #457, #602).Risks
Presentblocks; interplay with presents sent ahead (late_free_present),settle_now, and #457'sbefore_presentis untested.Acceptance criteria (measurable)
VICTORY_PRESENT=lowlat, the number of frames queued in the swap chain (the waitable-object count or the present-to-display statistic) is at most 1 in steady state, and the median present-to-present interval is not worse than main's by more than 1 ms in the menu; no device removal over a 10 minute run.cargo test --workspace --lockedstays green;frame.rs's existing tick test keeps passing.Not verified
Present(0, 0)ever blocks in the world.@Revens2 on GitHub · 2026-11-25 05:48 UTC · original
Sibling issues opened together: #727 (settings/menu), #728 (frame pacing and latency), #729 (Reflex), #730 (upscaling), #731 (frame generation). Overlaps are named in each body; this set should stay split by subject.