Send-and-hash list in three steps (copies, one state change, hash passes): 29 -> 6 ms of card time a frame #1227

Open
github-bot wants to merge 2 commits from github-bot/gh-1227 into main AGit
Owner

@⁠KyleS98 on GitHub · 2026-11-26 00:53 UTC · original
KyleS98:perf/sync-list-batched → main · +163 −34 · 1 files · 2 commits · open

What

Before each submission, one list of the layer's brings the copies in the card's memory up to date ("send-and-hash"). It went copy by copy. For each title buffer's copy it recorded:

  1. its CopyBufferRegions (the changed ranges, from PC memory),
  2. a state change (copy destination → shader resource),
  3. its hash passes (compute).

So the card went from copying to compute and back once per copy. That's about 300 times a frame once every title buffer's copy is in the card's memory (VICTORY_CARD_BUFFERS_MIN_KB=64), which is where the README notes the send-and-hash lists rising from 11.6 to 23.0 ms.

This PR records the same work in three steps over all the copies: every changed range copied up, then every state change in one ResourceBarrier call, then every hash pass, with the hash pipeline bound once.

It's safe to reorder. Each hash pass reads only its own copy's buffer, and a list's copies and hash passes for different copies touch different buffers, so no hash pass reads anything a later copy of the list writes.

VICTORY_CARD_SYNC_BATCH=0 gives the old order.

Measured

RTX 3090 Ti, warm cache, prologue cell. Each row is the same binary with the switch off and on, using the README's run-253 switch set plus VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=1280.

tree send-and-hash lists (card time / frame) frame
Series S profile: 9c184b3 + #798 + #1081 + #1171 + this 29.4 → 5.6 ms 85–86 → 72–73 ms (11.7 → 13.8 fps)
Series X profile: 006c353 + this PR only 31.7–32.0 → 8.4–8.9 ms 111 → 102–104 ms

On the Series X row the two runs were not at the same draw count (4,950 against 3,830–3,990 draws), so take the frame times there as indicative only. The send-and-hash times are the direct comparison.

In the Series S row the card went from 19 to 30 ms idle a frame and the submitting thread never waited for it, so on this machine the thread that prepares submissions is now the only limit.

Picture: the cell is the same in both orders, compared from grabs.

One thing found on the way (not caused by this PR)

In the Series S runs, the print on the back of the prologue's shirt disappears whenever the submitting thread never settles the flights within a frame:

  • It was missing in all four runs with VICTORY_LATE_WAIT_LISTS=1024, with either order of this PR.
  • It was missing in all three runs with VICTORY_CARD_HASH_LEN=1.
  • It was present in the runs with neither, including this PR's default.

So something reads what a flight wrote without the layer knowing, and the settle at 256 lists in the air has been hiding it. I haven't found the read yet.

AI-assisted (Claude Code, Claude Fable 5.2); runs and grabs on my machine; no game data.

**@⁠KyleS98** on GitHub · 2026-11-26 00:53 UTC · [original](https://github.com/fxceless/victory-fork/pull/1227) `KyleS98:perf/sync-list-batched` → `main` · +163 −34 · 1 files · 2 commits · open ## What Before each submission, one list of the layer's brings the copies in the card's memory up to date ("send-and-hash"). It went **copy by copy**. For each title buffer's copy it recorded: 1. its `CopyBufferRegion`s (the changed ranges, from PC memory), 2. a state change (copy destination → shader resource), 3. its hash passes (compute). So the card went from copying to compute and back once per copy. That's about 300 times a frame once every title buffer's copy is in the card's memory (`VICTORY_CARD_BUFFERS_MIN_KB=64`), which is where the README notes the send-and-hash lists rising from 11.6 to 23.0 ms. This PR records the same work in **three steps over all the copies**: every changed range copied up, then every state change in one `ResourceBarrier` call, then every hash pass, with the hash pipeline bound once. It's safe to reorder. Each hash pass reads only its own copy's buffer, and a list's copies and hash passes for different copies touch different buffers, so no hash pass reads anything a later copy of the list writes. `VICTORY_CARD_SYNC_BATCH=0` gives the old order. ## Measured RTX 3090 Ti, warm cache, prologue cell. Each row is the same binary with the switch off and on, using the README's run-253 switch set plus `VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=1280`. | tree | send-and-hash lists (card time / frame) | frame | |---|---|---| | Series S profile: `9c184b3` + #798 + #1081 + #1171 + this | 29.4 → **5.6 ms** | 85–86 → **72–73 ms** (11.7 → 13.8 fps) | | Series X profile: `006c353` + this PR only | 31.7–32.0 → **8.4–8.9 ms** | 111 → 102–104 ms | On the Series X row the two runs were not at the same draw count (4,950 against 3,830–3,990 draws), so take the frame times there as indicative only. The send-and-hash times are the direct comparison. In the Series S row the card went from 19 to 30 ms idle a frame and the submitting thread never waited for it, so on this machine the thread that prepares submissions is now the only limit. Picture: the cell is the same in both orders, compared from grabs. ## One thing found on the way (not caused by this PR) In the Series S runs, the print on the back of the prologue's shirt disappears whenever the submitting thread never settles the flights within a frame: - It was missing in all four runs with `VICTORY_LATE_WAIT_LISTS=1024`, with either order of this PR. - It was missing in all three runs with `VICTORY_CARD_HASH_LEN=1`. - It was present in the runs with neither, including this PR's default. So something reads what a flight wrote without the layer knowing, and the settle at 256 lists in the air has been hiding it. I haven't found the read yet. AI-assisted (Claude Code, Claude Fable 5.2); runs and grabs on my machine; no game data.
Copy by copy, each with its copies, its state change and its hash passes,
the card went from copying to compute and back for every copy of the list:
about 300 times a frame with every title buffer's copy in the card's
memory (VICTORY_CARD_BUFFERS_MIN_KB=64). Nothing a hash pass reads is
written by a later copy of the list (each copy's ranges and pieces are its
own buffer's), so the copies can all go first, the state changes in one
call, and the hash passes one after the other with one binding of the
pipeline.

Prologue cell, RTX 3090 Ti, Series S profile, the same build both ways:
the send-and-hash lists 29.4 -> 5.6 ms of card time a frame, the frame
85-86 -> 72-73 ms (11.7 -> 13.8 fps).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:59:55 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-26 01:09 UTC · original

Batching helped on an RX 7900 XT under Wine 11.22 / RADV 26.3.1 with VICTORY_CARD_BUFFERS_MIN_KB=64. The same first-room session gave 335 accepted presents in 77.46 s with batching off (4.33 FPS) and 423 in 78.77 s with it on (5.37 FPS). All four adjacent pairs favored batching, by 0.99–1.10 FPS. The counter recorded 190,194 buffers in multi-buffer batches. Both private visual checks showed the room.

A separate two-buffer test on this card verified the copied dwords and the piece hashes in 0.10 s off and 0.08 s on. GPU fixture · Build and gameplay measurements

**@⁠UwUCammie** on GitHub · 2026-11-26 01:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/1227#issuecomment-7179489984) Batching helped on an RX 7900 XT under Wine 11.22 / RADV 26.3.1 with `VICTORY_CARD_BUFFERS_MIN_KB=64`. The same first-room session gave 335 accepted presents in 77.46 s with batching off (4.33 FPS) and 423 in 78.77 s with it on (5.37 FPS). All four adjacent pairs favored batching, by 0.99–1.10 FPS. The counter recorded 190,194 buffers in multi-buffer batches. Both private visual checks showed the room. A separate two-buffer test on this card verified the copied dwords and the piece hashes in 0.10 s off and 0.08 s on. [GPU fixture](https://github.com/KyleS98/victory-fork/pull/4) · [Build and gameplay measurements](https://github.com/UwUCammie/victory-amd/blob/c126408/benchmarks/README.md#card-upload-batching)
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 01:27 UTC · original

@⁠UwUCammie thank you, both for the RX 7900 XT pairs (4.33 → 5.37 fps, all four pairs the same way) and for the fixture. I've merged your test into this branch (1bb0e35). On the RTX 3090 Ti here two_dirty_card_buffers_reach_readback_in_the_same_submission passes with VICTORY_CARD_SYNC_BATCH=0 and with =1 (with VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=1280), so both orders put the same dwords and piece hashes on the card on NVIDIA as well as on RADV.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 01:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/1227#issuecomment-7179798966) @⁠UwUCammie thank you, both for the RX 7900 XT pairs (4.33 → 5.37 fps, all four pairs the same way) and for the fixture. I've merged your test into this branch (`1bb0e35`). On the RTX 3090 Ti here `two_dirty_card_buffers_reach_readback_in_the_same_submission` passes with `VICTORY_CARD_SYNC_BATCH=0` and with `=1` (with `VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=1280`), so both orders put the same dwords and piece hashes on the card on NVIDIA as well as on RADV. AI-assisted (Claude Code, Claude Fable 5.2).
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 06:42 UTC · original

For anyone following: this is in main as 6aed078, carried by hand, off by default there (VICTORY_CARD_SYNC_BATCH=1|alt), with @⁠UwUCammie's test alongside. The maintainer's note says no run of theirs has carried it yet, so reports with =alt on other cards are the useful thing now. Numbers so far: 29.4 -> 5.6 ms of card time in the send-and-hash lists on an RTX 3090 Ti (Series S, prologue cell), and about +1 fps in four paired runs on an RX 7900 XT.

This PR is superseded by that commit and can be closed.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 06:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/1227#issuecomment-7184700632) For anyone following: this is in `main` as `6aed078`, carried by hand, off by default there (`VICTORY_CARD_SYNC_BATCH=1|alt`), with @⁠UwUCammie's test alongside. The maintainer's note says no run of theirs has carried it yet, so reports with `=alt` on other cards are the useful thing now. Numbers so far: 29.4 -> 5.6 ms of card time in the send-and-hash lists on an RTX 3090 Ti (Series S, prologue cell), and about +1 fps in four paired runs on an RX 7900 XT. This PR is superseded by that commit and can be closed. AI-assisted (Claude Code, Claude Fable 5.2).
Author
Owner

@⁠slauko on GitHub · 2026-11-26 08:21 UTC · original

Took it under Wine (RTX 3080 Ti, vkd3d-proton ec20719, uiliannn's line, VICTORY_CARD_SYNC_BATCH=1, the cell at about 5,000 draws a frame, 190 to 200 MB of changed bytes a frame):

  • the frame stays where it was without the switch: 275 to 289 ms, of which preparing: copies is 66 to 76 ms for those 190 MB — the copies are a memcpy into staging on this stack, so the recording side the batching saves is not what they cost here;
  • it did not regress anything either: no device removal, no Xid, the picture the same.

So the 29 → 6 ms is real where it was measured, but a run whose copies are memcpy-bound does not see it. Worth knowing before anyone reads the switch as a frame-time win on Wine; the win there would have to come from the copy itself (a mapped upload heap would be the obvious one, and VICTORY_WINDOW_UPLOAD stays unsupported under this stack: GPU upload heaps ... supported=false).

**@⁠slauko** on GitHub · 2026-11-26 08:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/1227#issuecomment-7186505866) Took it under Wine (RTX 3080 Ti, vkd3d-proton `ec20719`, uiliannn's line, `VICTORY_CARD_SYNC_BATCH=1`, the cell at about 5,000 draws a frame, 190 to 200 MB of changed bytes a frame): - the frame stays where it was without the switch: 275 to 289 ms, of which `preparing: copies` is 66 to 76 ms for those 190 MB — the copies are a memcpy into staging on this stack, so the recording side the batching saves is not what they cost here; - it did not regress anything either: no device removal, no `Xid`, the picture the same. So the 29 → 6 ms is real where it was measured, but a run whose copies are memcpy-bound does not see it. Worth knowing before anyone reads the switch as a frame-time win on Wine; the win there would have to come from the copy itself (a mapped upload heap would be the obvious one, and `VICTORY_WINDOW_UPLOAD` stays unsupported under this stack: `GPU upload heaps ... supported=false`).
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/1227/head:github-bot/gh-1227'
git switch 'github-bot/gh-1227'

Merge

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