gpu: coalesce card-memory piece hashing across 64 threads per piece #997

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

@⁠UnkwnDev on GitHub · 2026-11-25 15:29 UTC · original
UnkwnDev:arc-card-compare-coalesced → main · +260 −34 · 2 files · 1 commits · open

Summary

  • Rewrote CARD_COMPARE in crates/victory-gpu/src/host.rs to dispatch one [numthreads(64, 1, 1)] threadgroup per 64 KiB piece (looping by 65,535 when pieces > 65535), replacing the 4,096-step serial loop per thread with 64 coalesced 16-byte loads striding 1,024 bytes (for (uint at = lo + t * 16u; at < hi; at += 1024u)).
  • Kept the exact root signature and 6-constant Span cbuffer (first, skew, size, pieces, out_at, compare), gave each lane a distinct seed, and reduced groupshared uint4 lane_h[64] via explicit GroupMemoryBarrierWithGroupSync() stages (64 -> 32 -> 16 -> 1) plus a loop-end barrier before the next iteration overwrites lane_h, avoiding any wave-size assumptions across Wave16/Wave32/Wave64/WARP.
  • Updated both CARD_COMPARE dispatch sites in crates/victory-gpu/src/host.rs and the doc comments on CARD_COMPARE and rehash_runs() to use pieces.min(65535).
  • Updated existing warp_card_* tests in crates/victory-gpu/src/indirect.rs for 1-group-per-piece dispatch and added warp_card_compare_coalesced_lanes_and_skew covering non-aligned skew, non-zero first/out_at, single-byte mutations across all 64 lanes, simultaneous identical MSB flips in paired lanes, compare = 0/1/2, and D3D12 debug-layer validation on both WARP and the hardware GPU.

Benchmark (Intel Arc A770, probe_7_coalesced_card_compare)

  • Baseline (1 thread per 64 KiB piece): 706-982 us per pass
  • Coalesced (64 threads per 64 KiB piece): 38.4 us for 1-64 pieces (18x+ faster), 220.9 us for 1024 pieces (4.4x faster)

Verification

  • $env:VICTORY_D3D12_DEBUG='1'; cargo test -p victory-gpu --features diagnostics --lib warp_card -- --test-threads=1: 3 passed, 0 failed (including zero D3D12 debug-layer warnings or errors on CARD_COMPARE).
  • cargo test -p victory-gpu --lib -- --test-threads=1: 170 passed, 5 ignored, 1 pre-existing unrelated failure (indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields).
  • cargo test -p xtask --locked: 4 passed, 0 failed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and --all-features: 0 warnings in touched files (host.rs and new code in indirect.rs); pre-existing upstream warnings remain in resource.rs:2553, draw.rs:2406, shadow.rs:2675, and indirect.rs:2356 (Rig::depth_written).
  • (Get-Item crates/victory-gpu/src/host.rs).Length: 399,234 bytes (< 524,288 bytes).

AI assistance: implemented and verified with Gemini 4 Hydrogen / Claude.

**@⁠UnkwnDev** on GitHub · 2026-11-25 15:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/997) `UnkwnDev:arc-card-compare-coalesced` → `main` · +260 −34 · 2 files · 1 commits · open ## Summary - Rewrote `CARD_COMPARE` in `crates/victory-gpu/src/host.rs` to dispatch one `[numthreads(64, 1, 1)]` threadgroup per 64 KiB piece (looping by 65,535 when `pieces > 65535`), replacing the 4,096-step serial loop per thread with 64 coalesced 16-byte loads striding 1,024 bytes (`for (uint at = lo + t * 16u; at < hi; at += 1024u)`). - Kept the exact root signature and 6-constant `Span` cbuffer (`first, skew, size, pieces, out_at, compare`), gave each lane a distinct seed, and reduced `groupshared uint4 lane_h[64]` via explicit `GroupMemoryBarrierWithGroupSync()` stages (64 -> 32 -> 16 -> 1) plus a loop-end barrier before the next iteration overwrites `lane_h`, avoiding any wave-size assumptions across Wave16/Wave32/Wave64/WARP. - Updated both `CARD_COMPARE` dispatch sites in `crates/victory-gpu/src/host.rs` and the doc comments on `CARD_COMPARE` and `rehash_runs()` to use `pieces.min(65535)`. - Updated existing `warp_card_*` tests in `crates/victory-gpu/src/indirect.rs` for 1-group-per-piece dispatch and added `warp_card_compare_coalesced_lanes_and_skew` covering non-aligned `skew`, non-zero `first`/`out_at`, single-byte mutations across all 64 lanes, simultaneous identical MSB flips in paired lanes, `compare = 0/1/2`, and D3D12 debug-layer validation on both WARP and the hardware GPU. ## Benchmark (Intel Arc A770, `probe_7_coalesced_card_compare`) - Baseline (1 thread per 64 KiB piece): 706-982 us per pass - Coalesced (64 threads per 64 KiB piece): 38.4 us for 1-64 pieces (18x+ faster), 220.9 us for 1024 pieces (4.4x faster) ## Verification - `$env:VICTORY_D3D12_DEBUG='1'; cargo test -p victory-gpu --features diagnostics --lib warp_card -- --test-threads=1`: 3 passed, 0 failed (including zero D3D12 debug-layer warnings or errors on `CARD_COMPARE`). - `cargo test -p victory-gpu --lib -- --test-threads=1`: 170 passed, 5 ignored, 1 pre-existing unrelated failure (`indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields`). - `cargo test -p xtask --locked`: 4 passed, 0 failed. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and `--all-features`: 0 warnings in touched files (`host.rs` and new code in `indirect.rs`); pre-existing upstream warnings remain in `resource.rs:2553`, `draw.rs:2406`, `shadow.rs:2675`, and `indirect.rs:2356` (`Rig::depth_written`). - `(Get-Item crates/victory-gpu/src/host.rs).Length`: 399,234 bytes (< 524,288 bytes). AI assistance: implemented and verified with Gemini 4 Hydrogen / Claude.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:28 +00:00
Author
Owner

@⁠UwUCammie on GitHub · 2026-11-25 16:59 UTC · original

Tested on RX 7900 XT (CachyOS Linux, Wine 11.22 + vkd3d-proton + RADV). Merged cleanly and ran through multiple 480–540 s gameplay passes (up to frame 4600) with our card compare lists down to ~1.4–1.5 ms/frame on the GPU clock and zero device removals or debug issues.

**@⁠UwUCammie** on GitHub · 2026-11-25 16:59 UTC · [original](https://github.com/fxceless/victory-fork/pull/997#issuecomment-7168838366) Tested on RX 7900 XT (CachyOS Linux, Wine 11.22 + vkd3d-proton + RADV). Merged cleanly and ran through multiple 480–540 s gameplay passes (up to frame 4600) with our card compare lists down to ~1.4–1.5 ms/frame on the GPU clock and zero device removals or debug issues.
Author
Owner

@⁠UnkwnDev on GitHub · 2026-11-25 17:17 UTC · original

@⁠UwUCammie Thanks for verifying on RX 7900 XT (RADV / vkd3d-proton / Linux) across multiple 540 s runs. Glad to see the coalesced submit approach keeps GPU time at ~1.4 ms/frame with clean stability.

**@⁠UnkwnDev** on GitHub · 2026-11-25 17:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/997#issuecomment-7169280749) @⁠UwUCammie Thanks for verifying on RX 7900 XT (RADV / vkd3d-proton / Linux) across multiple 540 s runs. Glad to see the coalesced submit approach keeps GPU time at ~1.4 ms/frame with clean stability.
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/997/head:github-bot/gh-997'
git switch 'github-bot/gh-997'

Merge

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