Card compare: one thread group per 64 KiB piece instead of one thread #518

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

@⁠pug205gti6 on GitHub · 2026-11-25 01:57 UTC · original
pug205gti6:pr/451-card-compare-wide → main · +137 −18 · 2 files · 1 commits · open

The compare's single thread per piece walked 4,096 dependent 16-byte steps, so every pass took the time of a whole piece (0.4-0.77 ms on an RX 9070 whatever its group count) and several hundred passes ran a frame. Now 64 threads hash a piece together, each taking every 64th 16-byte block, and thread 0 folds their hashes in thread order. card_compare_dispatch records a pass as a group per piece, in dispatches of at most 65,535 groups. New WARP test: a change in every part of a piece is flagged, also with a skewed copy and swapped blocks.

**@⁠pug205gti6** on GitHub · 2026-11-25 01:57 UTC · [original](https://github.com/fxceless/victory-fork/pull/518) `pug205gti6:pr/451-card-compare-wide` → `main` · +137 −18 · 2 files · 1 commits · open The compare's single thread per piece walked 4,096 dependent 16-byte steps, so every pass took the time of a whole piece (0.4-0.77 ms on an RX 9070 whatever its group count) and several hundred passes ran a frame. Now 64 threads hash a piece together, each taking every 64th 16-byte block, and thread 0 folds their hashes in thread order. card_compare_dispatch records a pass as a group per piece, in dispatches of at most 65,535 groups. New WARP test: a change in every part of a piece is flagged, also with a skewed copy and swapped blocks.
The compare's single thread per piece walked 4,096 dependent 16-byte
steps, so every pass took the time of a whole piece (0.4-0.77 ms on an
RX 9070 whatever its group count) and several hundred passes ran a
frame. Now 64 threads hash a piece together, each taking every 64th
16-byte block, and thread 0 folds their hashes in thread order.
card_compare_dispatch records a pass as a group per piece, in
dispatches of at most 65,535 groups. New WARP test: a change in every
part of a piece is flagged, also with a skewed copy and swapped blocks.

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

@⁠Headache3318 on GitHub · 2026-11-25 07:51 UTC · original

Independent verification: PR #518 merges cleanly onto main, no conflicts. Build: success. Tests (per-package, target): victory-gpu 118/118 pass, victory-core 11/11 pass, victory 1/1 pass, victory-hle 95/96 pass. Known failure: victory-hle::net::tests::only_loopback_is_reachable fails on Wine (missing WSAConnectByList) — pre-existing on main. PR is clean: builds, no new failures, all GPU tests pass. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.

**@⁠Headache3318** on GitHub · 2026-11-25 07:51 UTC · [original](https://github.com/fxceless/victory-fork/pull/518#issuecomment-7156335580) Independent verification: PR #518 merges cleanly onto main, no conflicts. Build: success. Tests (per-package, target): victory-gpu 118/118 pass, victory-core 11/11 pass, victory 1/1 pass, victory-hle 95/96 pass. Known failure: victory-hle::net::tests::only_loopback_is_reachable fails on Wine (missing WSAConnectByList) — pre-existing on main. PR is clean: builds, no new failures, all GPU tests pass. Machine: Arch Linux, kernel 7.3.5-arch1-1, 3x RTX 4090 driver 620.73.04, Proton, AI-assisted.
Author
Owner

@⁠LeonardoS11 on GitHub · 2026-11-25 08:48 UTC · original

Numbers for this from an RTX 3080 Ti, on current main (9376fd6), in case they help it along.

Windows 11, RTX 3080 Ti 12 GB, 64 GB RAM, diag build with diagnostics; a still scene in the prologue (the room with the window onto the yard, about 4,900 draws a frame), 300 s a run, averages of the last 8 frame-rate lines. All runs with VICTORY_LEVELS_ON_DEMAND=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_KEEP=1 (the last is #780).

ms a frame on the GPU copying back card busy
9376fd6 + #780 276, 251 79, 85 171, 163 63–67 %
+ this PR 251, 226 55, 54 149, 142 53–59 %
+ VICTORY_CARD_FETCH_INFLIGHT=1, without this PR 263 118 54 85 %
+ VICTORY_CARD_FETCH_INFLIGHT=1, with this PR 206 47 63 84 %

So here the 64-thread compare takes 25–30 ms off the wait for the card, and it is what makes the new in-flight fetch pay: without it the fetch moves the time from "copying back" to the card. The picture was the same in all of these (walls, posters, the mesh in the window), no device loss.

The PR does not apply to 9376fd6 as it is (the in-flight fetch touched the same code). I reapplied it there without changing its design — the shader, card_compare_dispatch and the WARP tests are this PR's; the only real change is that the CARD_FETCH tests now call card_compare_dispatch. The rebased commit is 811c5f5 in LeonardoS11/victory-fork (branch port/v4-770, with other things of ours under it); I can put it on a clean branch if you want to take it.

(Runs by me on the hardware above; rebase and this note with Claude Code.)

**@⁠LeonardoS11** on GitHub · 2026-11-25 08:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/518#issuecomment-7157487200) Numbers for this from an RTX 3080 Ti, on current `main` (9376fd6), in case they help it along. Windows 11, RTX 3080 Ti 12 GB, 64 GB RAM, `diag` build with `diagnostics`; a still scene in the prologue (the room with the window onto the yard, about 4,900 draws a frame), 300 s a run, averages of the last 8 frame-rate lines. All runs with `VICTORY_LEVELS_ON_DEMAND=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_INDIRECT_KEEP=1` (the last is #780). | | ms a frame | on the GPU | copying back | card busy | |---|---|---|---|---| | 9376fd6 + #780 | 276, 251 | 79, 85 | 171, 163 | 63–67 % | | + this PR | 251, 226 | 55, 54 | 149, 142 | 53–59 % | | + `VICTORY_CARD_FETCH_INFLIGHT=1`, without this PR | 263 | 118 | 54 | 85 % | | + `VICTORY_CARD_FETCH_INFLIGHT=1`, with this PR | 206 | 47 | 63 | 84 % | So here the 64-thread compare takes 25–30 ms off the wait for the card, and it is what makes the new in-flight fetch pay: without it the fetch moves the time from "copying back" to the card. The picture was the same in all of these (walls, posters, the mesh in the window), no device loss. The PR does not apply to 9376fd6 as it is (the in-flight fetch touched the same code). I reapplied it there without changing its design — the shader, `card_compare_dispatch` and the WARP tests are this PR's; the only real change is that the `CARD_FETCH` tests now call `card_compare_dispatch`. The rebased commit is 811c5f5 in `LeonardoS11/victory-fork` (branch `port/v4-770`, with other things of ours under it); I can put it on a clean branch if you want to take it. (Runs by me on the hardware above; rebase and this note with Claude Code.)
Author
Owner

@⁠Andry018 on GitHub · 2026-11-25 15:14 UTC · original

Measured on an AMD Radeon RX 6600 (8 GB, RDNA2) with a Ryzen 7 9700X and 32 GB RAM, Windows 11, on main at f85101b with the same design as this PR: one group of 64 threads per 64 KiB piece in CARD_COMPARE. My branch is Andry018/victory-fork@perf/parallel-card-compare. It also has a switch, VICTORY_CARD_COMPARE_SERIAL=1, that brings back the one-thread-per-piece compare, so A and B run the same executable and the same warm shader cache.

Default settings, prologue cutscene from the same save. Each run was about 5 to 7 minutes long and showed no device loss.

parallel compare (2 runs) one thread per piece (1 run)
ms/frame, same points of the scene (~7,000 draws/frame) 234-263 300-312
waiting for the GPU per frame 129-152 ms 208-220 ms
copy-back thread waiting for fetches of card copies' pieces (steady window) 129-145 ms 186 ms
fps (steady window) 4.0-4.3 3.1

About 16,800 pieces are compared per frame. With one thread walking each 64 KiB piece, the compare is the longest wait on this card. Splitting the work across a group takes about 70 ms of GPU time off each frame, roughly -20% frame time end to end. This agrees with the 90 -> 32 ms GPU wait reported in #264 on an RX 6800.

Rebasing onto f85101b needs one change: the new test warp_card_fetch_copies_flagged_pieces_to_their_slots dispatches CARD_COMPARE as Dispatch(1, 1, 1), which is the one-thread shape. With a group per piece it has to dispatch one group per piece, or it hashes only piece 0.

Unrelated to the compare and the same in both modes: on this card, faces in the world stay black (as reported on an RX 6800 in #264), and face textures sometimes arrive late, depending on the texture queue.

**@⁠Andry018** on GitHub · 2026-11-25 15:14 UTC · [original](https://github.com/fxceless/victory-fork/pull/518#issuecomment-7166519841) Measured on an AMD Radeon RX 6600 (8 GB, RDNA2) with a Ryzen 7 9700X and 32 GB RAM, Windows 11, on `main` at `f85101b` with the same design as this PR: one group of 64 threads per 64 KiB piece in `CARD_COMPARE`. My branch is [Andry018/victory-fork@perf/parallel-card-compare](https://github.com/Andry018/victory-fork/tree/perf/parallel-card-compare). It also has a switch, `VICTORY_CARD_COMPARE_SERIAL=1`, that brings back the one-thread-per-piece compare, so A and B run the same executable and the same warm shader cache. Default settings, prologue cutscene from the same save. Each run was about 5 to 7 minutes long and showed no device loss. | | parallel compare (2 runs) | one thread per piece (1 run) | |---|---|---| | ms/frame, same points of the scene (~7,000 draws/frame) | 234-263 | 300-312 | | waiting for the GPU per frame | 129-152 ms | 208-220 ms | | copy-back thread waiting for fetches of card copies' pieces (steady window) | 129-145 ms | 186 ms | | fps (steady window) | 4.0-4.3 | 3.1 | About 16,800 pieces are compared per frame. With one thread walking each 64 KiB piece, the compare is the longest wait on this card. Splitting the work across a group takes about 70 ms of GPU time off each frame, roughly -20% frame time end to end. This agrees with the 90 -> 32 ms GPU wait reported in #264 on an RX 6800. Rebasing onto `f85101b` needs one change: the new test `warp_card_fetch_copies_flagged_pieces_to_their_slots` dispatches `CARD_COMPARE` as `Dispatch(1, 1, 1)`, which is the one-thread shape. With a group per piece it has to dispatch one group per piece, or it hashes only piece 0. Unrelated to the compare and the same in both modes: on this card, faces in the world stay black (as reported on an RX 6800 in #264), and face textures sometimes arrive late, depending on the texture queue.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/indirect.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/518/head:github-bot/gh-518'
git switch 'github-bot/gh-518'

Merge

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