Present queue: VICTORY_PACE shows every frame for the same number of refreshes (on top of #1988) #2201

Open
github-bot wants to merge 7 commits from github-bot/gh-2201 into main AGit
Owner

@⁠Anorak-314 on GitHub · 2026-11-29 10:27 UTC · original
Anorak-314:present-pace → main · +644 −7 · 1 files · 3 commits · open

Stacked on #1988. This branch is #1988's branch (updated to main at 829188e9) plus two commits, and only those two are new: 9057375f (a trace of the presents) and 30018655 (the pace). It needs the present queue, because the pace is kept by the thread that presents.

What it changes

What was wrong. With the swap chain on a queue of its own (#1988), a frame is presented when the card has drawn it, and frames come out of the card at uneven times: on an RTX 5090 at a 3840x2160 scene, every 28 ms at the median, 24 ms at the fifth percentile and 35 ms at the ninety-fifth. A display without variable refresh shows each frame for as many refreshes as that happens to take (at 240 Hz, five to nine of them), which reads as judder although the average is higher than before. I noted that in #1988 after it was opened; this is the answer to it.

The change (crates/victory-gpu/src/host.rs, module present_aside; nothing changes without the variables):

  • VICTORY_PACE=<n>: every frame of the scene is shown for n refreshes of the display. The thread that presents waits for the card to have drawn the frame, then presents it right after the refresh n after the one of the present before, with a present that cannot tear. A frame that is late is presented at once and the count goes on from it. The thread that submits waits for the present before, as it does without a pace, so the title is held to that rate. Frames of fewer than 200 draws (menus, loading screens) are not paced.
  • VICTORY_PACE=auto: the count is chosen while running. It starts at the count nearest 30 frames a second and looks every 192 frames: more than a quarter of them late, one refresh more (the stutters at a change of scene are fewer than that); now and then it tries one refresh fewer, keeps it if no more than a sixth of the frames are late, and otherwise goes back and waits twice as long before the next try.
  • VICTORY_PRESENT_TRACE=<file>: one line a present (frame, handed over, the wait for the present before, the copy begun, Present called and returned, the swap chain's present and refresh counts), in microseconds. The frame-times line counts the submitting thread's hand-over, which with the present queue is not when the frame is presented; the numbers below are from this trace.

How it differs from the frame clock (VICTORY_FRAME_INTERVAL_US, #269, #2077): that sets when the title's frames begin; this sets when finished frames are shown, counted in refreshes of the display, and it finds the count the frames keep up with.

What it costs. The average. A pace is the next whole number of refreshes the frames keep up with, so the frame rate goes down to it (here from about 32 to 29 a second). It does not remove the long frames at a change of scene either; those are presented late and the count goes on.

How it was tested

  • GPU and profile: RTX 5090 (32 GB, driver 621.24), Ryzen 9 9950X3D, 64 GB, Windows 11 (26300), 3840x2160 at 240 Hz, no variable refresh in use. Series X profile, 3840x2160 scene with DLSS at the DLAA scale, frame generation off, ray tracing off. Release builds, the opening cutscenes, 200 s a run, the last 100 s counted, VICTORY_PRESENT_QUEUE=1 in every run.
  • This branch at 829188e9, two runs each:
frames a second Present returned every (median; 5th to 95th percentile) frames on the screen for exactly the pace's refreshes
Before (no pace) 31.6 / 32.4 30.6 ms; 28.4 to 37.5 / 29.9 ms; 26.1 to 36.3 none: frames stay for 4 to 7 refreshes, no count above 34 %
After (VICTORY_PACE=auto) 28.7 / 29.2 33.3 ms; 33.1 to 43.2 / 33.3 ms; 32.7 to 37.6 76 % / 72 % for 8 refreshes (9 refreshes: 11 % / 14 %)
  • Why not more of them exact here: on this base the submitting thread works 28.9 ms a frame without a pace (the card 70 % busy), so a frame has little room before the 33.3 ms of 8 refreshes, and one frame in four misses its refresh by one. auto kept 8 in both runs; it went to 9 only for the changes of scene at the start.
  • The same module on my fork (a base of two days ago, where the submitting thread works 24 ms a frame and the card is the limit), 100 s each:
    • auto: 30.0 frames a second, 99 % of the frames on the screen for exactly 8 refreshes, Present returned every 33.3 ms (33.1 to 33.5, the longest 34.6), against 34.8 frames a second unpaced with frames 23.6 to 34.7 ms apart;
    • a fixed pace of 8 refreshes: 29.6 frames a second, 94 % exact (33.1 to 33.7 ms);
    • a fixed pace of 7: 32.5 frames a second and only 69 % exact, because the card does not quite keep up with 29.2 ms a frame; this is why auto exists;
    • DLSS Quality with auto: it settles on 7 refreshes, 33.4 frames a second, 85 % exact, against 38.0 frames a second unpaced with frames 23.5 to 31.8 ms apart. A fixed pace of 6 (40 a second) does not hold there.
  • For shader changes, the wave sizes tested: no shader change.
  • cargo test passed for the crates it touches: all but two tests that fail now and then on main as well. cargo test --release -p victory-gpu, three full runs here: 913, 913 and 914 of 915 passed. The failures are host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end and ...::places_written_after_sending_are_learned (counts read back from the card). On main at 829188e9 alone the first of them failed in one of two full runs, and each passes 3 of 3 times when run by itself on this branch. cargo clippy -p victory-gpu reports nothing in the module.

Not tested: displays at 60, 120 or 144 Hz (auto takes its start from the refresh it measures), variable refresh, HDR output, frame generation (the present queue is left out there, and the pace with it), and moving the window to another display while running (the display is asked once for each swap chain).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related:
    • #1988: the base of this, see the top.
    • #269, #1657, #2077: the title's frame clock (when its frames begin). Independent of this, see above.
    • #1357: frame generation's guard on the pace of base frames. Not touched: no pace is kept where frame generation takes the swap chain.
    • #1128: the report of present outcomes. This adds a trace beside it and changes none of its counts.

🤖 Generated with Claude Code

**@⁠Anorak-314** on GitHub · 2026-11-29 10:27 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2201) `Anorak-314:present-pace` → `main` · +644 −7 · 1 files · 3 commits · open Stacked on #1988. This branch is #1988's branch (updated to main at 829188e9) plus two commits, and only those two are new: 9057375f (a trace of the presents) and 30018655 (the pace). It needs the present queue, because the pace is kept by the thread that presents. ## What it changes **What was wrong.** With the swap chain on a queue of its own (#1988), a frame is presented when the card has drawn it, and frames come out of the card at uneven times: on an RTX 5090 at a 3840x2160 scene, every 28 ms at the median, 24 ms at the fifth percentile and 35 ms at the ninety-fifth. A display without variable refresh shows each frame for as many refreshes as that happens to take (at 240 Hz, five to nine of them), which reads as judder although the average is higher than before. I noted that in #1988 after it was opened; this is the answer to it. **The change** (`crates/victory-gpu/src/host.rs`, module `present_aside`; nothing changes without the variables): - `VICTORY_PACE=<n>`: every frame of the scene is shown for `n` refreshes of the display. The thread that presents waits for the card to have drawn the frame, then presents it right after the refresh `n` after the one of the present before, with a present that cannot tear. A frame that is late is presented at once and the count goes on from it. The thread that submits waits for the present before, as it does without a pace, so the title is held to that rate. Frames of fewer than 200 draws (menus, loading screens) are not paced. - `VICTORY_PACE=auto`: the count is chosen while running. It starts at the count nearest 30 frames a second and looks every 192 frames: more than a quarter of them late, one refresh more (the stutters at a change of scene are fewer than that); now and then it tries one refresh fewer, keeps it if no more than a sixth of the frames are late, and otherwise goes back and waits twice as long before the next try. - `VICTORY_PRESENT_TRACE=<file>`: one line a present (frame, handed over, the wait for the present before, the copy begun, `Present` called and returned, the swap chain's present and refresh counts), in microseconds. The frame-times line counts the submitting thread's hand-over, which with the present queue is not when the frame is presented; the numbers below are from this trace. How it differs from the frame clock (`VICTORY_FRAME_INTERVAL_US`, #269, #2077): that sets when the title's frames begin; this sets when finished frames are shown, counted in refreshes of the display, and it finds the count the frames keep up with. **What it costs.** The average. A pace is the next whole number of refreshes the frames keep up with, so the frame rate goes down to it (here from about 32 to 29 a second). It does not remove the long frames at a change of scene either; those are presented late and the count goes on. ## How it was tested - GPU and profile: RTX 5090 (32 GB, driver 621.24), Ryzen 9 9950X3D, 64 GB, Windows 11 (26300), 3840x2160 at 240 Hz, no variable refresh in use. Series X profile, 3840x2160 scene with DLSS at the DLAA scale, frame generation off, ray tracing off. Release builds, the opening cutscenes, 200 s a run, the last 100 s counted, `VICTORY_PRESENT_QUEUE=1` in every run. - This branch at 829188e9, two runs each: | | frames a second | `Present` returned every (median; 5th to 95th percentile) | frames on the screen for exactly the pace's refreshes | |---|---|---|---| | Before (no pace) | 31.6 / 32.4 | 30.6 ms; 28.4 to 37.5 / 29.9 ms; 26.1 to 36.3 | none: frames stay for 4 to 7 refreshes, no count above 34 % | | After (`VICTORY_PACE=auto`) | 28.7 / 29.2 | 33.3 ms; 33.1 to 43.2 / 33.3 ms; 32.7 to 37.6 | 76 % / 72 % for 8 refreshes (9 refreshes: 11 % / 14 %) | - Why not more of them exact here: on this base the submitting thread works 28.9 ms a frame without a pace (the card 70 % busy), so a frame has little room before the 33.3 ms of 8 refreshes, and one frame in four misses its refresh by one. `auto` kept 8 in both runs; it went to 9 only for the changes of scene at the start. - The same module on my fork (a base of two days ago, where the submitting thread works 24 ms a frame and the card is the limit), 100 s each: - `auto`: 30.0 frames a second, 99 % of the frames on the screen for exactly 8 refreshes, `Present` returned every 33.3 ms (33.1 to 33.5, the longest 34.6), against 34.8 frames a second unpaced with frames 23.6 to 34.7 ms apart; - a fixed pace of 8 refreshes: 29.6 frames a second, 94 % exact (33.1 to 33.7 ms); - a fixed pace of 7: 32.5 frames a second and only 69 % exact, because the card does not quite keep up with 29.2 ms a frame; this is why `auto` exists; - DLSS Quality with `auto`: it settles on 7 refreshes, 33.4 frames a second, 85 % exact, against 38.0 frames a second unpaced with frames 23.5 to 31.8 ms apart. A fixed pace of 6 (40 a second) does not hold there. - For shader changes, the wave sizes tested: no shader change. - `cargo test` passed for the crates it touches: all but two tests that fail now and then on main as well. `cargo test --release -p victory-gpu`, three full runs here: 913, 913 and 914 of 915 passed. The failures are `host::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end` and `...::places_written_after_sending_are_learned` (counts read back from the card). On main at 829188e9 alone the first of them failed in one of two full runs, and each passes 3 of 3 times when run by itself on this branch. `cargo clippy -p victory-gpu` reports nothing in the module. Not tested: displays at 60, 120 or 144 Hz (`auto` takes its start from the refresh it measures), variable refresh, HDR output, frame generation (the present queue is left out there, and the pace with it), and moving the window to another display while running (the display is asked once for each swap chain). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: - #1988: the base of this, see the top. - #269, #1657, #2077: the title's frame clock (when its frames begin). Independent of this, see above. - #1357: frame generation's guard on the pace of base frames. Not touched: no pace is kept where frame generation takes the swap chain. - #1128: the report of present outcomes. This adds a trace beside it and changes none of its counts. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The NVIDIA driver lets Present return when the card has run the frame: it
sleeps in the call (an RTX 5090, driver 621.24: 7 ms a frame at 3840x2160 with
DLAA, 1.5 ms with DLSS Quality), and the thread that prepares the submissions
stood still for as long, the card with nothing to run while the next frame's
first submission was prepared. Maximum pre-rendered frames in the driver's
profile (0, 1, 3), three buffers, presents that may not tear and a window that
covers the screen change nothing; the call alone on another thread does not
either (VICTORY_PRESENT_ASIDE=1: the driver keeps its lock while it sleeps).

With VICTORY_PRESENT_QUEUE=1 the swap chain is made on a queue of its own. The
frame is drawn into one of two stand-in textures on the main queue; a thread
has the swap chain's queue wait for it on the card, copies it to the back
buffer and presents. Off unless asked for; not with frame generation, which
takes the swap chain itself.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Four conflicts in host.rs, both sides kept: the module beside main's eight
swap-chain buffers, the wait for the present handed over before main's
composer made aside, the hand-over before main's retry of a refused present,
and FidelityFX's swap chain with main's device argument.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The frame-times line counts the submitting thread's hand-over, not the
present: with the swap chain on its own queue the two differ (hand-over
p95 40.7 ms, Present returned p95 34.8 ms at a median of 28 ms, RTX 5090,
3840x2160, 240 Hz). One line a present: frame, handed over, the wait for
the present before, the copy begun, Present called and returned, and the
swap chain's present and refresh counts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
VICTORY_PACE=<n> or auto, on the thread that presents: the thread waits for
the card to have drawn the frame, then presents it right after the refresh n
after the one of the present before, with no tearing. Frames of menus and
loading screens are not paced. auto starts at the count nearest 30 frames a
second, goes one refresh up when more than a quarter of the frames are late,
and now and then tries one fewer.

RTX 5090, 3840x2160 with DLAA, 240 Hz, 100 s of the opening, two runs each
on this base: unpaced, 31.6 / 32.4 frames a second, Present returned every
30.6 / 29.9 ms at the median (28.4 to 37.5 / 26.1 to 36.3 from the fifth to
the ninety-fifth percentile), frames on the screen for 4 to 7 refreshes;
with auto, 28.7 / 29.2 frames a second, every 33.3 ms (33.1 to 43.2 / 32.7
to 37.6), 76 / 72 % of the frames on the screen for exactly 8 refreshes.
On a base where the frames have more room before the pace (my fork: the
submitting thread 24 ms a frame against 29 here), 99 % exact, 33.1 to
33.5 ms.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 10:28:21 +00:00
With FSR 3 or DLSS frame generation the swap chain is not made on a queue
of its own, and VICTORY_PRESENT_QUEUE=1 then took the path of
VICTORY_PRESENT_ASIDE=1 (the call alone on the thread), which is no gain
and made a frame some 10 ms longer with FSR 3 on an RTX 3060 (measured in
the pull request's thread). Now the presents are called as without the
switch, and a line in the log says so.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2201/head:github-bot/gh-2201'
git switch 'github-bot/gh-2201'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2201'
git switch 'github-bot/gh-2201'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2201'
git switch 'github-bot/gh-2201'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2201'
git switch 'main'
git merge --squash 'github-bot/gh-2201'
git switch 'main'
git merge --ff-only 'github-bot/gh-2201'
git switch 'main'
git merge 'github-bot/gh-2201'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!2201
No description provided.