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

Open
pug205gti6 wants to merge 1 commit from upstream-pr/518 into main
pug205gti6 commented 2026-11-25 01:57:48 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pug205gti6 on 2026-11-25T01:57:48Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595377291 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/518). Originally posted by [pug205gti6](https://github.com/pug205gti6) on 2026-11-25T01:57:48Z. --- 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.
Headache3318 commented 2026-11-25 08:09:04 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Headache3318 on 2026-11-25T07:51:46Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156335580 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/518#issuecomment-7156335580). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T07:51:46Z. --- 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.
LeonardoS11 commented 2026-11-25 09:08:50 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by LeonardoS11 on 2026-11-25T08:48:05Z.


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.)

<!-- greyfinch-sync:fxceless/victory-fork:comment:7157487200 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/518#issuecomment-7157487200). Originally posted by [LeonardoS11](https://github.com/LeonardoS11) on 2026-11-25T08:48:05Z. --- 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.)
Andry018 commented 2026-11-25 16:12:50 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Andry018 on 2026-11-25T15:14:16Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7166519841 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/518#issuecomment-7166519841). Originally posted by [Andry018](https://github.com/Andry018) on 2026-11-25T15:14:16Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/518:upstream-pr/518'
git switch 'upstream-pr/518'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/518'
git switch 'upstream-pr/518'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/518'
git switch 'upstream-pr/518'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/518'
git switch 'main'
git merge --squash 'upstream-pr/518'
git switch 'main'
git merge --ff-only 'upstream-pr/518'
git switch 'main'
git merge 'upstream-pr/518'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!518
No description provided.