Card steps: read fills through placed copies, gather reads, bound the pool #105
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!105
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-105"
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?
@SousaTrashBin on GitHub · 2026-11-26 03:32 UTC · original
SousaTrashBin:rdna4/card-steps-forwarding→main· +733 −45 · 2 files · 1 commits · openCard steps: fills read through copies at their place, reads gathered, a bounded pool
Three changes to
host/card_steps.rs(VICTORY_CARD_STEPS=2with 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
planrefuse the whole submission (BEHIND_PLACED), and the submitting thread stood 14–17 ms a frame until the flights had landed.forwardnow 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, asVICTORY_PLACED_ORDER=1does.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, soplannow refuses these itself:Placed::waitsisYes, or a step on the card writes the source ahead of it): the CPU would copy stale bytes into upload memory (PLACED_ON_CPU);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
CopyBufferRegioneach. 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
planandforward: 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.VICTORY_RELAY=2 VICTORY_CARD_STEPS=2).cargo test -p victory-gpu --lib: everything passes excepttimeline::report::tests::real_waits_are_recorded_with_who_ended_them, which fails the same way onmain.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
@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.
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.Merge
Merge the changes and update on Forgejo.