Frame pacing: VICTORY_FRAME_PACE=auto|<ms> evens out long/short frame pairs, with the wait at our present to the host (VICTORY_PACE_AT_PRESENT=1); the frame meter's report off the presenting thread #3851
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3851"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by duckey-dev on 2026-11-30T09:19:15Z.
The problem
On an RX 7900 XTX at native 1440p (ray tracing off), a walk in the open world keeps about 28 frames a second, but the frames do not come evenly. They come in long/short pairs, 56 ms and then 15 ms. The median difference between two neighbouring frames is 21 ms, and 20 % of frames are over 50 ms. The average is close to 30, but what you see is closer to 18 fps with an extra frame squeezed in.
How it happens: a heavier frame lets the card fall behind. The limit on host lists in flight (
VICTORY_LATE_WAIT_LISTS) then stops the submitting thread, so that present is late. Meanwhile the card drains. The next frame is already made, so it goes out at once.The frame clock in
frame.rsdoes not prevent this at these rates. Its ticks are absolute (start plus whole intervals of the title's 33.3 ms). A wait whose tick has already passed ends at once. Once frames take longer than the interval, the title is always behind the clock, every wait ends at once, and nothing is paced.A second, smaller cause of uneven frames: once a second the frame meter builds its report (frame-time lines, budget, the 5-second counters) on the thread that presents. A timeline capture showed that block holding the submitting thread for 33 ms.
What it changes
1. Frame pacing (
crates/victory-gpu/src/pacer.rs, new; hooks inqueue.rsandhost.rs). Off unlessVICTORY_FRAME_PACEis set.world_since()is set and frames have 500 draws or more (8 frames in a row under that turn pacing off). Menus, movies and loading screens are not paced.VICTORY_FRAME_PACE=<ms>: a fixed target, 1 to 1000 ms.VICTORY_FRAME_PACE=auto: the first target comes from the intervals between our presents to the host, less the wait the pacer itself added. It is a high quantile of neighbour means, so a 60/18 alternation reads as 39 ms, plus 5 %. From then on the share of late presents steers it, looking at the last 32 presents once every 16: three or more late raise the target 3 %, none late lowers it 1 %, and after four looks in a row with none late it comes down 3 % a look. The target stays between 8 and 60 ms.queue.rs), before the present goes to the line or the host;VICTORY_PACE_AT_PRESENT=1, the title's present only notes its turn and goes on. The thread that presents to the host waits just before the swap chain'sPresent(host.rs). The frame's copy has already been sent, so the card keeps working, and the next frame's lists are submitted during the wait. This is the measured setup. With the wait on the title's thread, a capture showed that thread asleep about 27 ms a frame while the next frame's lists sat unsubmitted, and the card idle 15 to 20 ms every other frame.VICTORY_PACE_SLACK=<share>(0 to 2, default 0.2, only withVICTORY_PACE_AT_PRESENT=1): how far past its turn a present may be, as a share of the target, beforeautocounts it as late. Frames a few ms past their turn do not show. Counting them as late keptauto4 to 8 ms above what the walk sustains.Present, so they are paced before their markers. The generated frames in between are spaced by the frame-generation runtime, not by this.2. The frame meter's report off the presenting thread (
host.rs,VICTORY_METER_OFF_THREAD, on unless0). The presenting thread takes only the meter's own figures: intervals, the present budget's window, frame and draw counts, and the 5-second counts. It hands them to avictory-meterthread, which reads the other modules' counters and writes the lines. The window caption is still set from the presenting thread, as before.0keeps the report on the presenting thread, as before. The lines and their contents are unchanged. Counters read off the thread may count a moment longer into one report and the same amount shorter into the next.VICTORY_FRAME_PACEauto, or a target in msVICTORY_PACE_AT_PRESENT1: wait at our present to the host, not on the title's threadVICTORY_PACE_SLACKautocounts itVICTORY_METER_OFF_THREAD0: report on the presenting thread, as beforePacing is off by default. Turning it on lowers the average frame rate, for even frames (see below).
How it was tested
auto+VICTORY_PACE_AT_PRESENT=1autogives up 1 to 2 fps against it. Its target sometimes wanders up for a stretch, for example after a burst of streaming, and that is where its frames over 50 ms come from.cargo testpassed for the crates it touches: no failure that main does not have on this machine (13 pacer tests pass). Both of CI's clippy runs add no warning over main.Not tested
VICTORY_REFLEX, #3072, or the Reflex that frame generation turns on). With both on, two things would pace.Checked for overlap
I searched the open pull requests for the same issue and for the files this touches.
#2201 (stacked on #1988): "Present queue: VICTORY_PACE shows every frame for the same number of refreshes". This is the closest one. It paces on #1988's present thread in whole display refreshes (vblank waits through the output), with
autochoosing the count by the share of late frames. That steering idea is the same as ours. Assessment: for a fixed-refresh display without VRR, theirs is better: a frame held for exactly n refreshes is what a V-synced display can show evenly, and ours does not align to refreshes. Ours is better where theirs does not reach: it needs #1988's present queue (a second queue and a stand-in copy, motivated by an NVIDIA driver behaviour), it is left out with frame generation, and its steps are whole refreshes (at 60 Hz, 33.3 or 50 ms; ours sustains 34.5 ms here). Ours works on the default present path, at any target, with or without VRR. They can live together, but not both on at once. If both land, ours should step aside whenVICTORY_PACEis set. The names also share a prefix (VICTORY_PACEagainstVICTORY_PACE_AT_PRESENT/VICTORY_PACE_SLACK), and one side could rename.#1988: the swap chain on a queue of its own (
VICTORY_PRESENT_QUEUE=1). It replaces thePresentcall that ourbefore_host_presenthook sits before with a handover to its own thread. With both, our wait would happen on the submitting thread before the handover. That still paces, but it would belong on its present thread. The text conflict is next to our hook.#2346: the present on a thread of its own (
VICTORY_PRESENT_THREAD). It rewrites the same lines as our twohost.rshooks. The text conflicts are small. In meaning it is the same question as #1988: with it, the pacer's wait should move into its present job.#2077: the frame clock keeps the title's 30 for videos and menus (
VICTORY_FRAME_INTERVAL_DRAWS). It changes when the title's frames begin (frame.rs). Ours changes when finished frames are let go, and does not touchframe.rs. Complementary; both use the same 500-draw line for "in the world".#3072: NVIDIA Reflex low latency without frame generation (
VICTORY_REFLEX). Reflex's sleep paces the title's frames, on NVIDIA only. It adds markers next to ourqueue.rshook (a small text conflict). Turning both on would mean two pacers.#1938, #2371: pacing inside frame-generation runtimes. No code overlap.
#1357 (with #1360, #1363): the base-frame pace guard for frame generation (
streamline/pace.rs). Despite the name, it decides whether frame generation runs, not when frames go. No overlap.#2783: takes the 5-second
VirtualQuerywalk off in release builds. Related to the meter change only in symptom: that walk already runs on a thread of its own, and this PR moves the rest of the report.Many open PRs add lines to the meter's report body (for example #3074, #3650, #3703, #3617). They merge as text, since the body stays where it is. But a line added there that reads a
Meterfield throughself.has to take its figure intoMeterReportinstead. None of the open ones checked does this.🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by lewisenator on 2026-12-01T00:52:29Z.
Tested under Proton on NVIDIA: the same long/short pairs are here, and this removes them.
Setup: Linux (CachyOS, kernel 7.3.6), GE-Proton11-15, RTX 3080 Ti 12 GB (driver 620.73.04), Ryzen 7 5800X, Series X profile, DLSS Quality at 2560x1440, no frame generation,
VICTORY_VRAM_BUDGET_MB=8000. Build: main ate1251c31plus this PR (and the one-line-HV 2018of #3417, which Proton needs). Scene: the prison cell after the prologue, 115 s of scripted pad movement (the same tape every run), frame times from the diagnostics build's frame log. Runs interleaved, minutes apart.VICTORY_FRAME_PACE=auto,VICTORY_PACE_AT_PRESENT=1Off, a typical stretch reads 74, 52, 53, 75, 19, 96, 26, 85, 19, 103 ms; with it, 59, 60, 59, 60, 59, 60. The pacer's own line agrees: target 54-59 ms, 75-89 presents held in 5 s, at most 44 ms.
So on this machine it evens the frames out completely for about 1.9 fps (10 %).
Two things from here that bear on the cause described above:
VICTORY_LATE_WAIT_LISTS=512and1024(on main at41adb551): the stops for lists in the air went to zero, the frame rate did not move. I did not look at the pairs in those runs.VICTORY_SUBMIT_FRAMES=0made the pairs sharper (36 % of frames under 30 ms), andVICTORY_FRAME_INTERVAL_US=58000left them as they were; in a timeline the title's own Present calls already alternate (53/80, 54/89 ms).Not tested: with frame generation; a fixed target in ms;
cargo test.Merge note: on today's main (
7d93ee07) this conflicts with #2910 in one place inhost.rs(each adds a report line,crate::cardmem::line()andcrate::pacer::line()); keeping both lines resolves it. With that, this PR's commits on7d93ee07together with #2910 and a dozen other open PRs build and ran twice here with the same result (16.5 and 16.0 fps over the window, no pairs, mean step 6.4 and 6.9 ms).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by duckey-dev on 2026-12-01T15:38:54Z.
@lewisenator Thank you, this is the measurement the PR lacked: another vendor, another OS, alternating runs. Your note that the title's own Present calls already alternate fits something we measured since. The title's present job waits on a two-slot ring until the previous frame's sync value is reached, so it keeps one frame outstanding, and when our pipeline needs more than one interval the waits fall into long and short pairs. The pacer evens out what that gate produces; it doesn't remove the gate. I'll resolve the conflict with #2910 by keeping both report lines when I rebase.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:48:12Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed