play.ps1: VICTORY_SUBMIT_FRAMES=2, the title records the next frame while ours sends this one #379

Open
github-bot wants to merge 1 commit from github-bot/gh-379 into main AGit
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 21:05 UTC · original
Jesper-Andersson:play-submit-frames-2 → main · +2 −0 · 1 files · 1 commits · open

Refs #370.

With VICTORY_THIN=1 (a play.ps1 default), submissions go through our own submit thread (queue/behind.rs). A present returns only once at most VICTORY_SUBMIT_FRAMES presents are left in that line, and the default is 1 (frames_most, behind.rs:722). So the title cannot record frame N+1 while frame N's lists are still being translated and sent: the title, our submit thread and the card take turns.

On an RTX 2070 SUPER, letting the line hold two frames removes the title's wait at presents altogether, and the card goes from 79 % to 92 % busy.

Change

  • scripts/play.ps1: VICTORY_SUBMIT_FRAMES = '2', next to VICTORY_THIN. Like THIN, it is not set with -Safe. -More @{VICTORY_SUBMIT_FRAMES='1'} gives the old behaviour.
  • The code default stays 1, and nothing else changes.
  • Why this is safe is in behind.rs's module doc. The line already keeps everything the title may touch between its call and our send: upload memory, descriptors and constants stay the card's until a fence behind the lists is reached, and no fence is set before the lists have run. Two frames in the line only make that window longer. VICTORY_SUBMIT_DEPTH (64 submissions) still bounds it.

Where it does nothing

  • Without VICTORY_THIN / VICTORY_ASYNC_SUBMIT there is no line, and the switch is not read.
  • Where the title never waits at presents (the card already sets the frame), it changes nothing.

Measured

RTX 2070 SUPER 8 GB (driver 621.14), Ryzen 7 5800X, 32 GB, Windows 11.

  • Build: diag. Main 2de9980 plus open PRs (local branch), including the own-bytes pool from #221.
  • Settings: scripts\play.ps1 defaults, plus Series S, DLSS (VICTORY_UPSCALE=dlss), VICTORY_CARD_BUFFERS_MIN_KB=64 and VICTORY_CARD_BUFFERS_MB=1024.
  • The same build, save and route, one run after the other, about 4 minutes of play each. Medians over the gameplay intervals (frame lines under 25 fps): 33 for before, 37 for after.
per frame before (SUBMIT_FRAMES=1) after (=2)
median frame 179 ms 164 ms
p90 frame 260 ms 210 ms
title's threads waiting at presents (queue::behind line) 8.4 ms 0.0 ms
card busy (the card's clock line) 79 % 92 %
  • No visible change to the picture.
  • No extra input lag I could feel at these frame rates: one more frame queued is noticeable in principle.
  • It does not shorten what the card itself takes. With the card at 92 % that is what sets the frame now.

Checks

  • cargo xtask policy: 265 files ok
  • In game: the two runs above. Picture and controls checked by eye.
  • No Rust code changed, so no new tests.

Not checked

  • AMD cards, Series X, Linux/Proton.
  • Memory: two frames in the line keep a frame's upload memory and lists alive a little longer. Card memory in use stayed within the budget here (8 GB card). A run on a card near its budget would be worth it.
  • The release build.
  • #370 (the frame on this PC is a chain of waits) and #367 (the same PC's runs B-F).
  • No open PR touches VICTORY_SUBMIT_FRAMES. #176 changes play.ps1's -Safe settings only, so it does not overlap.

This change was made with AI assistance (Claude Code).

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 21:05 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/379) `Jesper-Andersson:play-submit-frames-2` → `main` · +2 −0 · 1 files · 1 commits · open Refs #370. With `VICTORY_THIN=1` (a `play.ps1` default), submissions go through our own submit thread (`queue/behind.rs`). A present returns only once at most `VICTORY_SUBMIT_FRAMES` presents are left in that line, and the default is 1 (`frames_most`, `behind.rs:722`). So the title cannot record frame N+1 while frame N's lists are still being translated and sent: the title, our submit thread and the card take turns. On an RTX 2070 SUPER, letting the line hold two frames removes the title's wait at presents altogether, and the card goes from 79 % to 92 % busy. ## Change - `scripts/play.ps1`: `VICTORY_SUBMIT_FRAMES = '2'`, next to `VICTORY_THIN`. Like THIN, it is not set with `-Safe`. `-More @{VICTORY_SUBMIT_FRAMES='1'}` gives the old behaviour. - The code default stays 1, and nothing else changes. - Why this is safe is in `behind.rs`'s module doc. The line already keeps everything the title may touch between its call and our send: upload memory, descriptors and constants stay the card's until a fence behind the lists is reached, and no fence is set before the lists have run. Two frames in the line only make that window longer. `VICTORY_SUBMIT_DEPTH` (64 submissions) still bounds it. ## Where it does nothing - Without `VICTORY_THIN` / `VICTORY_ASYNC_SUBMIT` there is no line, and the switch is not read. - Where the title never waits at presents (the card already sets the frame), it changes nothing. ## Measured RTX 2070 SUPER 8 GB (driver 621.14), Ryzen 7 5800X, 32 GB, Windows 11. - Build: diag. Main `2de9980` plus open PRs (local branch), including the own-bytes pool from #221. - Settings: `scripts\play.ps1` defaults, plus Series S, DLSS (`VICTORY_UPSCALE=dlss`), `VICTORY_CARD_BUFFERS_MIN_KB=64` and `VICTORY_CARD_BUFFERS_MB=1024`. - The same build, save and route, one run after the other, about 4 minutes of play each. Medians over the gameplay intervals (frame lines under 25 fps): 33 for before, 37 for after. | per frame | before (`SUBMIT_FRAMES=1`) | after (`=2`) | |---|---|---| | median frame | 179 ms | **164 ms** | | p90 frame | 260 ms | **210 ms** | | title's threads waiting at presents (`queue::behind` line) | 8.4 ms | 0.0 ms | | card busy (`the card's clock` line) | 79 % | 92 % | - No visible change to the picture. - No extra input lag I could feel at these frame rates: one more frame queued is noticeable in principle. - It does not shorten what the card itself takes. With the card at 92 % that is what sets the frame now. ## Checks - `cargo xtask policy`: 265 files ok - In game: the two runs above. Picture and controls checked by eye. - No Rust code changed, so no new tests. ## Not checked - AMD cards, Series X, Linux/Proton. - Memory: two frames in the line keep a frame's upload memory and lists alive a little longer. Card memory in use stayed within the budget here (8 GB card). A run on a card near its budget would be worth it. - The release build. ## Related - #370 (the frame on this PC is a chain of waits) and #367 (the same PC's runs B-F). - No open PR touches `VICTORY_SUBMIT_FRAMES`. #176 changes `play.ps1`'s `-Safe` settings only, so it does not overlap. This change was made with AI assistance (Claude Code).
RTX 2070 SUPER 8 GB, Series S: 179 -> 164 ms median, p90 260 -> 210;
the title's threads no longer wait at presents, the card 79 -> 92 % busy.
Not with -Safe; -More @{VICTORY_SUBMIT_FRAMES='1'} for the old way.

This change was made with AI assistance (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:13:28 +00:00
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 22:02 UTC · original

A second measurement, on a different build, adds a caveat. I'm marking this as a draft until it is understood.

Run I is the local test branch at b9b32e4 (the ordinary build here; the runs above were on a branch of it), with VICTORY_SUBMIT_FRAMES=2. It is compared with run H, the same build without the switch, on the same PC, route and settings (Series S, DLSS Quality):

per frame, gameplay medians H (=1) I (=2)
frame, median 156 ms 142 ms
frame, p90 238 ms 260 ms
title's threads waiting at presents 17.6 ms 0.0 ms
card busy 98 % 97 %
  • The median gain holds, about 9 % as in the first pair, but the p90 got worse here.
  • More visible: in run I the user saw a bit more graphical artifacting than in H. In the first pair (179 → 164 ms) nothing was seen.
  • The log shows nothing new: the same kinds of warnings (118 against 129), and no errors.
  • One explanation (not checked): with two frames in the line, the title writes memory for the next frame while lists of the frame before have not run yet, and something those lists read is not kept as behind.rs's module doc says. Upload memory, descriptors and constants are covered there. Memory the title writes by the CPU and the card reads in place (renderer port 1's regions, PORT_ALL) may not be.

To try next: =2 with port 1 off, and a capture of a frame with the artifacts. Until then, VICTORY_SUBMIT_FRAMES=2 is a frame-time gain with a possible correctness cost. It should not be a default yet.

AI use: log reading and write-up with AI assistance (Claude Code). The runs are my own.

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 22:02 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/379#issuecomment-7204295437) A second measurement, on a different build, adds a caveat. I'm marking this as a draft until it is understood. Run I is the local `test` branch at `b9b32e4` (the ordinary build here; the runs above were on a branch of it), with `VICTORY_SUBMIT_FRAMES=2`. It is compared with run H, the same build without the switch, on the same PC, route and settings (Series S, DLSS Quality): | per frame, gameplay medians | H (`=1`) | I (`=2`) | |---|---|---| | frame, median | 156 ms | 142 ms | | frame, p90 | 238 ms | **260 ms** | | title's threads waiting at presents | 17.6 ms | 0.0 ms | | card busy | 98 % | 97 % | - The median gain holds, about 9 % as in the first pair, but the p90 got worse here. - More visible: in run I the user saw **a bit more graphical artifacting** than in H. In the first pair (179 → 164 ms) nothing was seen. - The log shows nothing new: the same kinds of warnings (118 against 129), and no errors. - **One explanation (not checked):** with two frames in the line, the title writes memory for the next frame while lists of the frame before have not run yet, and something those lists read is not kept as `behind.rs`'s module doc says. Upload memory, descriptors and constants are covered there. Memory the title writes by the CPU and the card reads in place (renderer port 1's regions, `PORT_ALL`) may not be. To try next: `=2` with port 1 off, and a capture of a frame with the artifacts. Until then, `VICTORY_SUBMIT_FRAMES=2` is a frame-time gain with a possible correctness cost. It should not be a default yet. AI use: log reading and write-up with AI assistance (Claude Code). The runs are my own.
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 23:10 UTC · original

The next measurement from my last comment: =2 with renderer port 1 off. The artifacting from run I did not show, and frames were faster.

Run J is the same test build as H and I (b9b32e4), on the same PC, route and settings (Series S, DLSS Quality). It has VICTORY_SUBMIT_FRAMES=2 and VICTORY_PORT_ALL=0, so port 1 is off; play.ps1 sets VICTORY_PORT_ALL=1 by default.

J2 repeats J with the same settings.

per frame, gameplay medians H (=1, port 1 on) I (=2, port 1 on) J (=2, port 1 off) J2 (repeat of J)
frame, median 156 ms 142 ms 117 ms 109 ms
frame, p90 238 ms 260 ms 249 ms 156 ms
card busy 98 % 97 % 74 % 90 %
waiting for flights 21.2 ms 6.9 ms 6.2 ms
relay waiting for the card with nothing to do 119.7 ms 63.1 ms 64.7 ms
  • No artifacting in J or J2. I saw the artifacts in run I but not in J or J2. The frames saved during gameplay (VICTORY_CAPTURE) look clean too. That points at port 1 together with two frames in flight, not at =2 alone.
  • Port 1 off is also faster on this PC (RTX 2070 SUPER 8 GB, Ryzen 7 5800X): 142 → 117 and 109 ms against I.
    • This goes the other way from #380's RX 9070 XT numbers, where port 1 was a gain, so I'd read it as hardware-dependent.
    • In #365 I saw port 1's heap placement cost time on this card too.
  • The repeat holds it. J2 (28 gameplay intervals, against 29 in I) has a median of 109 ms and a p90 of 156 ms. J's p90 of 249 ms was the new-memory waits in a shorter run (their longest single wait was 1.1 s in J, 0.7 s in J2).
  • Some materials come in late and stay dark for a while before they load. The ground, which looks like one big material, takes the longest. As far as I remember run I had that too, so it isn't from port 1 being off.

A likely cause in the code (not confirmed yet):

  • Shader writes into memory port 1 keeps in place are declared nowhere (Shadow::gpu_writes, the early return for place). So nothing waits on them.
  • card_steps refuses memory in place, so fills and copies that read it are done on the CPU when the submission is prepared. In H and I that's about 600-740 fills a frame.
  • A fill that reads bytes a flight still on the card writes in place, or that a list ahead in the same submission writes, gets the bytes from before that write.
  • With =2 our thread runs further ahead of the card, so more of these reads come too early. That would fit "some artifacting at =1, more at =2, none with port 1 off".
  • I have a diagnostics counter for these reads and will run it with port 1 on at =1 and =2.

For now: VICTORY_SUBMIT_FRAMES=2 looks safe and faster on this PC with port 1 off. With port 1 on it is not. I'd keep this PR as a draft. If the counter confirms it, the fix belongs in port 1 and not here: let card_steps take memory in place, so those fills run on the card in queue order. That would also bring back the roughly 12,000 fills a frame that moved to the CPU in #365.

AI use: log reading and write-up with AI assistance (Claude Code). The runs are my own.

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 23:10 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/379#issuecomment-7205321056) The next measurement from my last comment: `=2` with renderer port 1 off. The artifacting from run I did not show, and frames were faster. Run J is the same `test` build as H and I (`b9b32e4`), on the same PC, route and settings (Series S, DLSS Quality). It has `VICTORY_SUBMIT_FRAMES=2` and `VICTORY_PORT_ALL=0`, so port 1 is off; `play.ps1` sets `VICTORY_PORT_ALL=1` by default. J2 repeats J with the same settings. | per frame, gameplay medians | H (`=1`, port 1 on) | I (`=2`, port 1 on) | J (`=2`, port 1 off) | J2 (repeat of J) | |---|---|---|---|---| | frame, median | 156 ms | 142 ms | **117 ms** | **109 ms** | | frame, p90 | 238 ms | 260 ms | 249 ms | 156 ms | | card busy | 98 % | 97 % | 74 % | 90 % | | waiting for flights | | 21.2 ms | 6.9 ms | 6.2 ms | | relay waiting for the card with nothing to do | | 119.7 ms | 63.1 ms | 64.7 ms | - **No artifacting in J or J2.** I saw the artifacts in run I but not in J or J2. The frames saved during gameplay (`VICTORY_CAPTURE`) look clean too. That points at port 1 together with two frames in flight, not at `=2` alone. - **Port 1 off is also faster on this PC** (RTX 2070 SUPER 8 GB, Ryzen 7 5800X): 142 → 117 and 109 ms against I. - This goes the other way from #380's RX 9070 XT numbers, where port 1 was a gain, so I'd read it as hardware-dependent. - In #365 I saw port 1's heap placement cost time on this card too. - **The repeat holds it.** J2 (28 gameplay intervals, against 29 in I) has a median of 109 ms and a p90 of 156 ms. J's p90 of 249 ms was the new-memory waits in a shorter run (their longest single wait was 1.1 s in J, 0.7 s in J2). - **Some materials come in late** and stay dark for a while before they load. The ground, which looks like one big material, takes the longest. As far as I remember run I had that too, so it isn't from port 1 being off. **A likely cause in the code (not confirmed yet):** - Shader writes into memory port 1 keeps in place are declared nowhere (`Shadow::gpu_writes`, the early return for `place`). So nothing waits on them. - `card_steps` refuses memory in place, so fills and copies that read it are done on the CPU when the submission is prepared. In H and I that's about 600-740 fills a frame. - A fill that reads bytes a flight still on the card writes in place, or that a list ahead in the same submission writes, gets the bytes from before that write. - With `=2` our thread runs further ahead of the card, so more of these reads come too early. That would fit "some artifacting at `=1`, more at `=2`, none with port 1 off". - I have a diagnostics counter for these reads and will run it with port 1 on at `=1` and `=2`. For now: `VICTORY_SUBMIT_FRAMES=2` looks safe and faster on this PC with port 1 off. With port 1 on it is not. I'd keep this PR as a draft. If the counter confirms it, the fix belongs in port 1 and not here: let `card_steps` take memory in place, so those fills run on the card in queue order. That would also bring back the roughly 12,000 fills a frame that moved to the CPU in #365. AI use: log reading and write-up with AI assistance (Claude Code). The runs are my own.
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 23:20 UTC · original

A correction to my last comment: the cause I called likely there is ruled out.

I added a diagnostics counter (local branch, not pushed). Each list notes the title memory in place that its shaders may write. Flights keep those ranges until the card passes their fence value. Before a submission's CPU fills and copies run, it counts the ones that read those bytes while a flight that writes them is unfinished, or that read bytes a list ahead in the same submission writes.

Two runs on the same build, port 1 on (VICTORY_PORT_ALL=1, with xmem's half off as on test), Series S, DLSS Quality:

L1 (=1) L2 (=2)
frame median / p90 146 / 262 ms 192 / 340 ms
CPU steps touching memory in place, per frame about 320-350 about the same
flights writing in place, unfinished at each submission about 7 about 5-6
CPU reads of bytes those flights (or lists ahead) write 0 0
artifacting seen a little as in run I

All shader writes into title memory go through Shadow::gpu_writes, so the counter sees all of them:

  • UAVs in tables (draw.rs, binding a UAV);
  • root UAVs (root_uav, the rest of the buffer unless VICTORY_ROOT_UAV_MB is set);
  • memory.rs.

So our CPU steps don't read port 1's memory too early, and that isn't what goes wrong.

What's left (not checked yet): the title's own CPU writes.

  • Without port 1, every submission works from host copies refreshed when it is prepared, so a later write by the title can't reach a frame that's already sent.
  • With port 1, the card reads the title's memory as it is when the lists run.
  • With =2, a present returns while two frames are queued, so the title starts on the next frame earlier. If it reuses memory (a ring of constants, for example) based on frames presented rather than on fences, it overwrites bytes the card hasn't read yet.

That fits a little artifacting at =1, more at =2, and none with port 1 off. Checking it means watching the title's writes to port 1's regions while flights that read them are in the air. That's the next diagnostic.

On this PC =2 is only a gain with port 1 off. The local play.ps1 now pairs VICTORY_SUBMIT_FRAMES=2 with VICTORY_PORT_ALL=0. This PR stays a draft until the port 1 side is understood.

AI use: diagnostics, log reading and write-up with AI assistance (Claude Code). The runs are my own.

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 23:20 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/379#issuecomment-7205456361) A correction to my last comment: the cause I called likely there is ruled out. I added a diagnostics counter (local branch, not pushed). Each list notes the title memory in place that its shaders may write. Flights keep those ranges until the card passes their fence value. Before a submission's CPU fills and copies run, it counts the ones that read those bytes while a flight that writes them is unfinished, or that read bytes a list ahead in the same submission writes. Two runs on the same build, port 1 on (`VICTORY_PORT_ALL=1`, with xmem's half off as on `test`), Series S, DLSS Quality: | | L1 (`=1`) | L2 (`=2`) | |---|---|---| | frame median / p90 | 146 / 262 ms | 192 / 340 ms | | CPU steps touching memory in place, per frame | about 320-350 | about the same | | flights writing in place, unfinished at each submission | about 7 | about 5-6 | | CPU reads of bytes those flights (or lists ahead) write | **0** | **0** | | artifacting seen | a little | as in run I | All shader writes into title memory go through `Shadow::gpu_writes`, so the counter sees all of them: - UAVs in tables (`draw.rs`, binding a UAV); - root UAVs (`root_uav`, the rest of the buffer unless `VICTORY_ROOT_UAV_MB` is set); - `memory.rs`. So our CPU steps don't read port 1's memory too early, and that isn't what goes wrong. **What's left (not checked yet): the title's own CPU writes.** - Without port 1, every submission works from host copies refreshed when it is prepared, so a later write by the title can't reach a frame that's already sent. - With port 1, the card reads the title's memory as it is when the lists run. - With `=2`, a present returns while two frames are queued, so the title starts on the next frame earlier. If it reuses memory (a ring of constants, for example) based on frames presented rather than on fences, it overwrites bytes the card hasn't read yet. That fits a little artifacting at `=1`, more at `=2`, and none with port 1 off. Checking it means watching the title's writes to port 1's regions while flights that read them are in the air. That's the next diagnostic. On this PC `=2` is only a gain with port 1 off. The local `play.ps1` now pairs `VICTORY_SUBMIT_FRAMES=2` with `VICTORY_PORT_ALL=0`. This PR stays a draft until the port 1 side is understood. AI use: diagnostics, log reading and write-up with AI assistance (Claude Code). The runs are my own.
Author
Owner

@⁠YeokiNoewChi on GitHub · 2026-11-26 23:53 UTC · original

A data point from a different machine: RTX 3070 Ti 8 GB, Ryzen 5 5600X, Windows 11, Series S with DLSS, VICTORY_THIN=1. This was not on your main. It was a cool_fox-based tree with renderer ports 1, 2, 6 and 7. I A/B'd VICTORY_SUBMIT_FRAMES 1 against 2 within one run at the boat save, in 10 s phases, with 29 adjacent pairs.

  • Median frame: +0.3 ms with 2; it was faster in only 8 of the 29 pairs.
  • p90: -1.7 ms with 2.
  • The title's wait at presents (queue::behind line) went from 1-5 ms to 0.0 ms, as in your run.

So here it removes the wait but the frame stays where it was. Our submitting thread works 37-44 ms of a ~56 ms frame, so that thread sets the frame, not the line. I'd expect the gain you measured where the submitting thread has slack and the title is what waits.

**@⁠YeokiNoewChi** on GitHub · 2026-11-26 23:53 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/379#issuecomment-7205958577) A data point from a different machine: RTX 3070 Ti 8 GB, Ryzen 5 5600X, Windows 11, Series S with DLSS, `VICTORY_THIN=1`. This was not on your main. It was a cool_fox-based tree with renderer ports 1, 2, 6 and 7. I A/B'd `VICTORY_SUBMIT_FRAMES` 1 against 2 within one run at the boat save, in 10 s phases, with 29 adjacent pairs. - Median frame: +0.3 ms with 2; it was faster in only 8 of the 29 pairs. - p90: -1.7 ms with 2. - The title's wait at presents (`queue::behind` line) went from 1-5 ms to 0.0 ms, as in your run. So here it removes the wait but the frame stays where it was. Our submitting thread works 37-44 ms of a ~56 ms frame, so that thread sets the frame, not the line. I'd expect the gain you measured where the submitting thread has slack and the title is what waits.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-379'
git switch 'github-bot/gh-379'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-379'
git switch 'github-bot/gh-379'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-379'
git switch 'main'
git merge --squash 'github-bot/gh-379'
git switch 'main'
git merge --ff-only 'github-bot/gh-379'
git switch 'main'
git merge 'github-bot/gh-379'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.