GPU: the passes over copies in the card's memory hash with a group per piece #253

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

@⁠TG0000 on GitHub · 2026-11-24 23:01 UTC · original
TG0000:gpu/card-hash-wide → main · +150 −11 · 3 files · 1 commits · open

With copies kept in the card's memory (VICTORY_CARD_BUFFERS_*), the passes that hash their 64 KiB pieces used one shader thread per piece, with a pass per range sent up and copies and passes in turn. They now use one 64-thread group per piece, and the copies come first, behind one barrier. VICTORY_CARD_HASH_WIDE=0 keeps the old passes.

Measured on an RX 6800 (Ryzen 5900X, Windows 11), in the world, on 7b0f736 plus our measuring tools and PastiiJay's AMD wave fixes; the same change is rebased here on a253706 and has not been run in a game on that head:

before after
GPU wait per frame, one launch, arms alternating ABBA, 5 differences 89.7 ms 32.2 ms (-57 ± 29)
frame time in the same launch -45 ± 80 ms: not shown, the frame is CPU-bound there
hash before the lists / compare after them, timestamps in the lists, one launch each 74 / 55 ms 8.7 / 9.8 ms
compared pieces that were fetched back 2.3 % 2.4 %

Tests on this head (3b0521a, one thread, RX 6800 and WARP): victory-gpu 169 passed, 1 failed; victory-shader 215 passed. The failure is warp_budget_saturates_without_wraparound_and_preserves_draw_fields, which also failed 2 of 6 times on unchanged f85101b here (#847 and #849 are about it). Clippy with -D warnings for the Windows target (both feature sets), with #841's patch on top: one error, shadow.rs (is_multiple_of), the same on unchanged a253706.

With main's copy queue (VICTORY_QUEUE2) the copies-first order keeps the landing buffer's offsets: copies are recorded in the same order as they were sent up.

Not measured: NVIDIA, Intel, other AMD cards, and pictures frame by frame (the photos show the same kind of scenes). A report of the GPU ms per frame with VICTORY_CARD_HASH_WIDE=0 and without it, on any card, would help.

AI-assisted.

🤖 Generated with Claude Code

**@⁠TG0000** on GitHub · 2026-11-24 23:01 UTC · [original](https://github.com/fxceless/victory-fork/pull/253) `TG0000:gpu/card-hash-wide` → `main` · +150 −11 · 3 files · 1 commits · open With copies kept in the card's memory (`VICTORY_CARD_BUFFERS_*`), the passes that hash their 64 KiB pieces used one shader thread per piece, with a pass per range sent up and copies and passes in turn. They now use one 64-thread group per piece, and the copies come first, behind one barrier. `VICTORY_CARD_HASH_WIDE=0` keeps the old passes. Measured on an RX 6800 (Ryzen 5900X, Windows 11), in the world, on 7b0f736 plus our measuring tools and PastiiJay's AMD wave fixes; the same change is rebased here on a253706 and has not been run in a game on that head: | | before | after | |---|---|---| | GPU wait per frame, one launch, arms alternating ABBA, 5 differences | 89.7 ms | 32.2 ms (-57 ± 29) | | frame time in the same launch | | -45 ± 80 ms: not shown, the frame is CPU-bound there | | hash before the lists / compare after them, timestamps in the lists, one launch each | 74 / 55 ms | 8.7 / 9.8 ms | | compared pieces that were fetched back | 2.3 % | 2.4 % | Tests on this head (3b0521a, one thread, RX 6800 and WARP): victory-gpu 169 passed, 1 failed; victory-shader 215 passed. The failure is `warp_budget_saturates_without_wraparound_and_preserves_draw_fields`, which also failed 2 of 6 times on unchanged f85101b here (#847 and #849 are about it). Clippy with `-D warnings` for the Windows target (both feature sets), with #841's patch on top: one error, `shadow.rs` (`is_multiple_of`), the same on unchanged a253706. With main's copy queue (`VICTORY_QUEUE2`) the copies-first order keeps the landing buffer's offsets: copies are recorded in the same order as they were sent up. Not measured: NVIDIA, Intel, other AMD cards, and pictures frame by frame (the photos show the same kind of scenes). A report of the GPU ms per frame with `VICTORY_CARD_HASH_WIDE=0` and without it, on any card, would help. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Each 64 KiB piece was hashed by one thread, 4,096 loads in a row, and a pass
before the lists was recorded per range sent up, copies and passes in turn.
Timestamps in the lists on an RX 6800 gave these passes 129 of 197 ms of the
card's busy time in a frame (3.5 GB hashed). VICTORY_CARD_HASH_WIDE=0 keeps
the old passes.

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

@⁠ericomeehan on GitHub · 2026-11-24 23:37 UTC · original

A heads-up on overlap, in case it saves a rebase later: #265 (VICTORY_LEAN_WINDOWS) rewrites the same copy loop in card_before (host.rs). It adds an upload-ring path for lean windows that can close, run and wait on the list partway through the loop when the ring fills, then reset it and carry on. This PR reorders that loop into "all copies, then one barrier, then all hash passes" behind hash_wide(). The two don't merge textually. And once both are in, a mid-loop flush would split "all copies" into several submissions, so the single barrier and the passes after it would need to come after the last flush, or be repeated per part. Whichever of the two lands second will need to fit around the other, so it may be worth comparing notes with CoDrift.

Written with an AI assistant (Claude).

**@⁠ericomeehan** on GitHub · 2026-11-24 23:37 UTC · [original](https://github.com/fxceless/victory-fork/pull/253#issuecomment-7147612481) A heads-up on overlap, in case it saves a rebase later: #265 (`VICTORY_LEAN_WINDOWS`) rewrites the same copy loop in `card_before` (`host.rs`). It adds an upload-ring path for lean windows that can close, run and wait on the list partway through the loop when the ring fills, then reset it and carry on. This PR reorders that loop into "all copies, then one barrier, then all hash passes" behind `hash_wide()`. The two don't merge textually. And once both are in, a mid-loop flush would split "all copies" into several submissions, so the single barrier and the passes after it would need to come after the last flush, or be repeated per part. Whichever of the two lands second will need to fit around the other, so it may be worth comparing notes with CoDrift. Written with an AI assistant (Claude).
Author
Owner

@⁠ryotdev on GitHub · 2026-11-25 00:43 UTC · original

Tested on a desktop RTX 5070, driver 610.88, Windows. I applied the GPU changes from 3c9b4ce to a local #63 build and ran the same executable (SHA-256 prefix 9d1f15b53bb7) with VICTORY_CARD_HASH_WIDE=0, then =1. Each run started from the same save and pipeline-cache seed with relay off. I measured the first 90 seconds after the scene reached 3,500 draws/frame.

Application-reported window Serial Wide
Median frame time, full 90 s 393.2 ms 347.4 ms
Median frame time, final 30 s 216.8 ms (4.61 FPS) 206.9 ms (4.83 FPS)
90th percentile frame time, final 30 s 242.3 ms 260.8 ms
Median GPU queue wait, final 30 s 97.7 ms 87.1 ms

The final windows had 4,959 vs 4,970 median draws/frame and about 16,800 pieces compared per frame in both arms. That gives a 4.8% gain in settled FPS for this pair. The higher p90 is worth keeping in view. Both runs completed. The wide screenshot had a darker character silhouette and brighter background, but the captures were 3.6 seconds apart at different draw counts, so visual parity is still open.

Both comparison shaders passed the D3D12 WARP tests with #71’s paired-sign edit and a skewed boundary/partial tail. The old #71 build missed the paired edit on the same machine. AI-assisted testing.

**@⁠ryotdev** on GitHub · 2026-11-25 00:43 UTC · [original](https://github.com/fxceless/victory-fork/pull/253#issuecomment-7148801886) Tested on a desktop RTX 5070, driver 610.88, Windows. I applied the GPU changes from `3c9b4ce` to a local #63 build and ran the same executable (SHA-256 prefix `9d1f15b53bb7`) with `VICTORY_CARD_HASH_WIDE=0`, then `=1`. Each run started from the same save and pipeline-cache seed with relay off. I measured the first 90 seconds after the scene reached 3,500 draws/frame. | Application-reported window | Serial | Wide | |---|---:|---:| | Median frame time, full 90 s | 393.2 ms | 347.4 ms | | Median frame time, final 30 s | 216.8 ms (4.61 FPS) | 206.9 ms (4.83 FPS) | | 90th percentile frame time, final 30 s | 242.3 ms | 260.8 ms | | Median GPU queue wait, final 30 s | 97.7 ms | 87.1 ms | The final windows had 4,959 vs 4,970 median draws/frame and about 16,800 pieces compared per frame in both arms. That gives a 4.8% gain in settled FPS for this pair. The higher p90 is worth keeping in view. Both runs completed. The wide screenshot had a darker character silhouette and brighter background, but the captures were 3.6 seconds apart at different draw counts, so visual parity is still open. Both comparison shaders passed the D3D12 WARP tests with #71’s paired-sign edit and a skewed boundary/partial tail. The old #71 build missed the paired edit on the same machine. AI-assisted testing.
Author
Owner

@⁠tightfall on GitHub · 2026-11-25 01:10 UTC · original

A data point from an RX 9070 (RDNA 4, Windows 11, Adrenalin 26.11.2), in case it helps this one along.

I hit the same cost independently and made the compare pass part of this change (one 64-lane group per 64 KiB piece, lanes interleaved over 16-byte blocks) in #451, before I saw this PR. This PR covers more (the hash passes too, copies ahead of one barrier), so I'm closing mine in favour of it.

What I measured with the compare-only version, so it is a lower bound for this PR:

  • Radeon GPU Profiler capture in the world (dispatch mode): the old CARD_COMPARE was the most expensive pipeline in the capture, 0.4-0.64 ms per pass regardless of size (4096 serial steps in one thread), about 600 passes a frame. The card was idle about 66% of the time, so the frame is CPU-bound around it.
  • In-game, same scene, one launch each, diag build with VICTORY_INPLACE=2: median 3.0-3.1 fps -> 3.8 fps (about 330 -> 266 ms a frame). Tree: myokex/victory-amd 8e6d29e (2119b0e + 6 commits) plus the compare change, with VICTORY_TEXTURE_SWEEP=0.

I haven't run this PR itself in the game on this card yet; I'll add the numbers here when I have them (with VICTORY_CARD_HASH_WIDE=0 and without, as you asked).

AI-assisted (Claude Code).

**@⁠tightfall** on GitHub · 2026-11-25 01:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/253#issuecomment-7149282178) A data point from an RX 9070 (RDNA 4, Windows 11, Adrenalin 26.11.2), in case it helps this one along. I hit the same cost independently and made the compare pass part of this change (one 64-lane group per 64 KiB piece, lanes interleaved over 16-byte blocks) in #451, before I saw this PR. This PR covers more (the hash passes too, copies ahead of one barrier), so I'm closing mine in favour of it. What I measured with the compare-only version, so it is a lower bound for this PR: - Radeon GPU Profiler capture in the world (dispatch mode): the old `CARD_COMPARE` was the most expensive pipeline in the capture, 0.4-0.64 ms per pass regardless of size (4096 serial steps in one thread), about 600 passes a frame. The card was idle about 66% of the time, so the frame is CPU-bound around it. - In-game, same scene, one launch each, diag build with `VICTORY_INPLACE=2`: median 3.0-3.1 fps -> **3.8 fps** (about 330 -> 266 ms a frame). Tree: myokex/victory-amd 8e6d29e (2119b0e + 6 commits) plus the compare change, with `VICTORY_TEXTURE_SWEEP=0`. I haven't run this PR itself in the game on this card yet; I'll add the numbers here when I have them (with `VICTORY_CARD_HASH_WIDE=0` and without, as you asked). AI-assisted (Claude Code).
Author
Owner

@⁠alpz1000 on GitHub · 2026-11-25 22:15 UTC · original · edited 2026-11-25 22:30 UTC

I tested the standalone CARD_COMPARE_WIDE shader from 3b0521a on an RTX 3060 12 GB (driver 610.88, Windows 11). The baseline is the one-thread-per-piece shader from 9c184b3. Both used the same generated bytes in D3D12 DEFAULT-heap buffers.

Input Main shader PR shader
288 bytes in one piece 2.05 µs 1.47 µs
One full 64 KiB piece 194.37 µs 5.18 µs
Four full pieces 237.38 µs 5.18 µs
64 full pieces 717.95 µs 13.82 µs
512 full pieces 858.43 µs 97.41 µs

Numbers are medians of nine measured batches per shader, with 16 mode-0 hash dispatches per batch, a UAV barrier between dispatches, and D3D12 queue timestamps. This measures the shader and the dispatch barrier in isolation.

I also ran 3b0521a applied to a local integration of 9c184b3, with the Series S profile and a 64 KiB card-buffer threshold. After shader compilation settled, 398 frames at a stationary checkpoint averaged 4.88 FPS, with a 234 ms p90. The median timing windows showed 3.6 ms in send-and-hash lists and 1.4 ms in compare lists per frame. CPU-side submission preparation was 167 ms per frame. An earlier local build recorded 13.8 ms and 6.1 ms respectively for those GPU lists at the same checkpoint, with a different base and card-buffer threshold. The isolated shader benchmark above is the controlled comparison.

AI-assisted with OpenAI Codex.

**@⁠alpz1000** on GitHub · 2026-11-25 22:15 UTC · [original](https://github.com/fxceless/victory-fork/pull/253#issuecomment-7176133941) · edited 2026-11-25 22:30 UTC I tested the standalone `CARD_COMPARE_WIDE` shader from `3b0521a` on an RTX 3060 12 GB (driver 610.88, Windows 11). The baseline is the one-thread-per-piece shader from `9c184b3`. Both used the same generated bytes in D3D12 DEFAULT-heap buffers. | Input | Main shader | PR shader | | --- | ---: | ---: | | 288 bytes in one piece | 2.05 µs | 1.47 µs | | One full 64 KiB piece | 194.37 µs | 5.18 µs | | Four full pieces | 237.38 µs | 5.18 µs | | 64 full pieces | 717.95 µs | 13.82 µs | | 512 full pieces | 858.43 µs | 97.41 µs | Numbers are medians of nine measured batches per shader, with 16 mode-0 hash dispatches per batch, a UAV barrier between dispatches, and D3D12 queue timestamps. This measures the shader and the dispatch barrier in isolation. I also ran `3b0521a` applied to a local integration of `9c184b3`, with the Series S profile and a 64 KiB card-buffer threshold. After shader compilation settled, 398 frames at a stationary checkpoint averaged 4.88 FPS, with a 234 ms p90. The median timing windows showed 3.6 ms in send-and-hash lists and 1.4 ms in compare lists per frame. CPU-side submission preparation was 167 ms per frame. An earlier local build recorded 13.8 ms and 6.1 ms respectively for those GPU lists at the same checkpoint, with a different base and card-buffer threshold. The isolated shader benchmark above is the controlled comparison. AI-assisted with OpenAI Codex.
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/253/head:github-bot/gh-253'
git switch 'github-bot/gh-253'

Merge

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