Card steps: read fills through placed copies, gather reads, bound the pool #105

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

@⁠SousaTrashBin on GitHub · 2026-11-26 03:32 UTC · original
SousaTrashBin:rdna4/card-steps-forwarding → main · +733 −45 · 2 files · 1 commits · open

Card steps: fills read through copies at their place, reads gathered, a bounded pool

Three changes to host/card_steps.rs (VICTORY_CARD_STEPS=2 with the relay's second stage), measured on an RX 9070 XT.

1. Fills behind a copy at its place read the copy's source (VICTORY_PLACED_FORWARD, on by default)

Some 26 copies a frame write into the title's constant ring at their place in a list, out of what shaders wrote. A constant-buffer fill behind one of them that read what it had put made plan refuse the whole submission (BEHIND_PLACED), and the submitting thread stood 14–17 ms a frame until the flights had landed.

forward now gives such a fill (one that reads only bytes the copy put, through chains of such copies) the copy's source at the same offset. That is the value the CPU read after the old wait: there the copy is done in title memory at submission, in step order. A fill ahead of the copy is left alone, so the draw ahead of it still sees the old bytes. With the switch on, the steps ahead of a placed copy are planned in order, as VICTORY_PLACED_ORDER=1 does.

Measured: the refused submissions went from 0.9 a frame to 0, and the 14–17 ms waits for "a fill of upload memory" are gone.

2. Two holes where the card-steps path could let the CPU read stale bytes

The card-steps path skips late_blocked, so plan now refuses these itself:

  • a copy at its place whose source is taken on the CPU (Placed::waits is Yes, or a step on the card writes the source ahead of it): the CPU would copy stale bytes into upload memory (PLACED_ON_CPU);
  • a step left on the CPU that reads the destination of a copy at its place that title memory does not take at submission (not free, or its source is written on the card) (PLACED_STALE).

Neither showed up in the traces I have, so they should not add waits.

3. Reads gathered by one dispatch (VICTORY_CARD_GATHER, on by default)

A level's reads out of one buffer (8 or more, word-aligned) are copied into the buffer between by one compute dispatch, a group per read, instead of a CopyBufferRegion each. Measured: about 2,100 copy commands a frame became 66, plus about 18 dispatches. The frame-rate line now counts copy commands, gathered reads and dispatches.

4. The pool of lists of ours is bounded and sized

Each pooled list held a 4 MiB buffer, and as many were kept as were ever in the air. Buffers are now sized to the submission (a power of two from 128 KiB; a submission reads about 110 KB on average), a pooled one is taken only if it holds what is needed, and at most 32 are kept (the smallest goes first). Measured: 5.2 MB of these buffers alive.

Tests

  • plan and forward: the regression case from the trace (the draw ahead of the copy reads the old bytes, the one behind reads the new ones), edge cases (writes between copy and fill, partial overlap, chains, a copy onto itself, steps that run), and a randomized check over 20,000 step orders that every fill, copy and read sees what it would one step after the other.
  • On the card: the gather (40 reads gathered, a few copied, a second level gathering what the first wrote) and the bounded pool. These and the existing card-steps tests pass under the D3D12 debug layer, and so does the ignored end-to-end relay test (VICTORY_RELAY=2 VICTORY_CARD_STEPS=2).
  • cargo test -p victory-gpu --lib: everything passes except timeline::report::tests::real_waits_are_recorded_with_who_ended_them, which fails the same way on main.

Effect

The CPU waits went away, but frame time hardly moved (about 15 fps): the card was 96–97% busy, so the frame is bound by GPU work, not by these waits.

🤖 Generated with Claude Code

**@⁠SousaTrashBin** on GitHub · 2026-11-26 03:32 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/105) `SousaTrashBin:rdna4/card-steps-forwarding` → `main` · +733 −45 · 2 files · 1 commits · open ## Card steps: fills read through copies at their place, reads gathered, a bounded pool Three changes to `host/card_steps.rs` (`VICTORY_CARD_STEPS=2` with the relay's second stage), measured on an RX 9070 XT. ### 1. Fills behind a copy at its place read the copy's source (`VICTORY_PLACED_FORWARD`, on by default) Some 26 copies a frame write into the title's constant ring at their place in a list, out of what shaders wrote. A constant-buffer fill behind one of them that read what it had put made `plan` refuse the whole submission (`BEHIND_PLACED`), and the submitting thread stood 14–17 ms a frame until the flights had landed. `forward` now gives such a fill (one that reads only bytes the copy put, through chains of such copies) the copy's source at the same offset. That is the value the CPU read after the old wait: there the copy is done in title memory at submission, in step order. A fill ahead of the copy is left alone, so the draw ahead of it still sees the old bytes. With the switch on, the steps ahead of a placed copy are planned in order, as `VICTORY_PLACED_ORDER=1` does. Measured: the refused submissions went from 0.9 a frame to 0, and the 14–17 ms waits for "a fill of upload memory" are gone. ### 2. Two holes where the card-steps path could let the CPU read stale bytes The card-steps path skips `late_blocked`, so `plan` now refuses these itself: - a copy at its place whose source is taken on the CPU (`Placed::waits` is `Yes`, or a step on the card writes the source ahead of it): the CPU would copy stale bytes into upload memory (`PLACED_ON_CPU`); - a step left on the CPU that reads the destination of a copy at its place that title memory does not take at submission (not `free`, or its source is written on the card) (`PLACED_STALE`). Neither showed up in the traces I have, so they should not add waits. ### 3. Reads gathered by one dispatch (`VICTORY_CARD_GATHER`, on by default) A level's reads out of one buffer (8 or more, word-aligned) are copied into the buffer between by one compute dispatch, a group per read, instead of a `CopyBufferRegion` each. Measured: about 2,100 copy commands a frame became 66, plus about 18 dispatches. The frame-rate line now counts copy commands, gathered reads and dispatches. ### 4. The pool of lists of ours is bounded and sized Each pooled list held a 4 MiB buffer, and as many were kept as were ever in the air. Buffers are now sized to the submission (a power of two from 128 KiB; a submission reads about 110 KB on average), a pooled one is taken only if it holds what is needed, and at most 32 are kept (the smallest goes first). Measured: 5.2 MB of these buffers alive. ### Tests - `plan` and `forward`: the regression case from the trace (the draw ahead of the copy reads the old bytes, the one behind reads the new ones), edge cases (writes between copy and fill, partial overlap, chains, a copy onto itself, steps that run), and a randomized check over 20,000 step orders that every fill, copy and read sees what it would one step after the other. - On the card: the gather (40 reads gathered, a few copied, a second level gathering what the first wrote) and the bounded pool. These and the existing card-steps tests pass under the D3D12 debug layer, and so does the ignored end-to-end relay test (`VICTORY_RELAY=2 VICTORY_CARD_STEPS=2`). - `cargo test -p victory-gpu --lib`: everything passes except `timeline::report::tests::real_waits_are_recorded_with_who_ended_them`, which fails the same way on `main`. ### Effect The CPU waits went away, but frame time hardly moved (about 15 fps): the card was 96–97% busy, so the frame is bound by GPU work, not by these waits. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A fill behind a copy at its place in a list that reads only bytes the copy put
now reads the copy's source in front of the lists (VICTORY_PLACED_FORWARD), the
value the CPU read after the old wait; the submission is no longer refused.
plan also refuses two cases where the CPU could read stale bytes: a placed copy
whose source the CPU takes while flights or card steps write it, and CPU steps
behind a placed copy that title memory does not take at submission.

A level's reads out of one buffer are gathered by one dispatch instead of a copy
each (VICTORY_CARD_GATHER). The buffers between are sized to the submission and
at most 32 lists are pooled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:24:41 +00:00
Author
Owner

@⁠avatarmanz on GitHub · 2026-11-26 07:35 UTC · original

Left open: VICTORY_PLACED_FORWARD and VICTORY_CARD_GATHER are on by default and change the card-step plan on AMD; needs an in-game check on the 7900 XTX first.

**@⁠avatarmanz** on GitHub · 2026-11-26 07:35 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/105#issuecomment-7185626320) Left open: VICTORY_PLACED_FORWARD and VICTORY_CARD_GATHER are on by default and change the card-step plan on AMD; needs an in-game check on the 7900 XTX first.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host/card_steps.rs
  • crates/victory-gpu/src/host/place.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/105/head:github-bot/gh-105'
git switch 'github-bot/gh-105'

Merge

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