Shaders: half-local cross-lane operations run for wave64 on 32-lane hosts (FIND-7) #3115

Open
github-bot wants to merge 4 commits from github-bot/gh-3115 into main AGit
Owner

@⁠Creaa on GitHub · 2026-11-26 08:38 UTC · original
Creaa:shaders/wave64-half-local-cross-lane → main · +378 −21 · 15 files · 4 commits · open

Stacked on #2176; only the top commit (6f8cb55) belongs here. Claimed as FIND-7 in #1633.

On a host of 32-lane waves, #2176 refuses every cross-lane operation that is not quad-local as "a cross-half operation on a 32-lane host". DPP rows (16 lanes), DPP8 (8 lanes), ds_swizzle_b32 in its group-of-32 mode and ds_bpermute_b32 (each 32-lane half on its own, RDNA2 ISA 10.4.4, as the code's own comment says) only read lanes of their own half, which one host wave holds whole. They now run.

What is in it

  • crates/victory-shader/src/emit/lower.rs: cross_lane gets cross_lanes_within(quad, lanes), the size of the group an operation reads in; refused only when the host wave is smaller than that group. Swizzle and bpermute pass 32, DPP8 8, DPP rows 16 when the row write mask has the same bits for both halves (0xF, 0x5, 0xA, 0x0), else the wave: the mask numbers the wave's four rows, and a 32-lane host wave sees only rows 0 and 1 of its half. v_readlane/v_writelane/v_mbcnt and other cross-lane paths are unchanged.
  • crates/victory-shader/src/emit/crosslane_tests.rs: half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host runs a wave64 program of 64 threads, translated for a 32-lane host, on a hardware device and checks all 64 lanes against RDNA2 for row_ror:4, row_mirror, row_share:3, DPP8, ds_swizzle_b32 SWAP(16) and ds_bpermute_b32. The wave32 builder and dispatch were split into shader_of and dispatch_lanes::<N> for it; the existing wave32 tests use them unchanged.
  • crates/victory-shader/src/emit/mod.rs: wave64_dpp_row_is_refused_on_wave32_host_only_with_a_mask_naming_one_half: row masks 0xF and 0x5 emit, 0x1 is still refused as cross-half.

Tested

  • RTX 4070 12 GB (driver 617.14, 32-lane waves), i7-13700F, 32 GB RAM, Windows 11 build 26300, Rust 1.98.1 (pinned); on #2176's head fb99078.
  • The two new tests: pass; with lower.rs reverted both fail with "a cross-half operation on a 32-lane host". The existing cross-lane GPU tests (DPP16 18, DPP8 5, swizzle 6 cases) pass.
  • cargo test -q --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index: 302 passed, 3 failed, 3 ignored; #2176 alone: 300 passed, the same 3 failed (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware, the hardware failures of #1744). The skipped test kills the process on this card on #2176's base (#2571, fixed on main by #2596/#2587).
  • cargo test --workspace --locked --no-fail-fast: the other crates 565 passed, 2 failed (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views: the capped-heap failures #2461 fixes), 7 ignored.
  • cargo clippy --workspace --all-targets --locked -- -D warnings and with --all-features: clean. cargo xtask policy: 190 files ok.
  • Offline victory translate --list of the title's shader pack with host_wave32 on (a one-line local change to the translate command to pass it, not in this PR): "a cross-half operation on a 32-lane host" 69 -> 51 programs; compute emitted 2291 -> 2309. The 18: the 2D and array mip-chain programs of levels 2-3 (16), a cascade-shadow min/max and a trail-map mip program.
  • A 12-minute run of the title (diag build, the opening cutscene into its first 3D shots) on this card with #2176 + #2461 + #2464 and the three programs of #1968 skipped (VICTORY_SKIP_PIPELINES), with and without this commit: programs refused as cross-half while playing 28 -> 23, no new refusals, no errors and no device removal in either run; frame rate the same (median about 1.3-1.4 fps there).

Not tested

  • AMD and Intel cards (their hosts take wave64, so the path is not used there), WARP's 32-lane mode.
  • The 51 programs still refused cross the halves for real (v_readlane of another half and the like); not changed here.

AI use

  • Claude Code (Claude Opus 5.5) found the cases, wrote the change and the tests, ran the measurements and drafted this description; I checked it.

🤖 Generated with Claude Code

**@⁠Creaa** on GitHub · 2026-11-26 08:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3115) `Creaa:shaders/wave64-half-local-cross-lane` → `main` · +378 −21 · 15 files · 4 commits · open Stacked on #2176; only the top commit (`6f8cb55`) belongs here. Claimed as FIND-7 in #1633. On a host of 32-lane waves, #2176 refuses every cross-lane operation that is not quad-local as "a cross-half operation on a 32-lane host". DPP rows (16 lanes), DPP8 (8 lanes), `ds_swizzle_b32` in its group-of-32 mode and `ds_bpermute_b32` (each 32-lane half on its own, RDNA2 ISA 10.4.4, as the code's own comment says) only read lanes of their own half, which one host wave holds whole. They now run. **What is in it** - `crates/victory-shader/src/emit/lower.rs`: `cross_lane` gets `cross_lanes_within(quad, lanes)`, the size of the group an operation reads in; refused only when the host wave is smaller than that group. Swizzle and bpermute pass 32, DPP8 8, DPP rows 16 when the row write mask has the same bits for both halves (0xF, 0x5, 0xA, 0x0), else the wave: the mask numbers the wave's four rows, and a 32-lane host wave sees only rows 0 and 1 of its half. `v_readlane`/`v_writelane`/`v_mbcnt` and other cross-lane paths are unchanged. - `crates/victory-shader/src/emit/crosslane_tests.rs`: `half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host` runs a wave64 program of 64 threads, translated for a 32-lane host, on a hardware device and checks all 64 lanes against RDNA2 for `row_ror:4`, `row_mirror`, `row_share:3`, DPP8, `ds_swizzle_b32` SWAP(16) and `ds_bpermute_b32`. The wave32 builder and dispatch were split into `shader_of` and `dispatch_lanes::<N>` for it; the existing wave32 tests use them unchanged. - `crates/victory-shader/src/emit/mod.rs`: `wave64_dpp_row_is_refused_on_wave32_host_only_with_a_mask_naming_one_half`: row masks 0xF and 0x5 emit, 0x1 is still refused as cross-half. **Tested** - RTX 4070 12 GB (driver 617.14, 32-lane waves), i7-13700F, 32 GB RAM, Windows 11 build 26300, Rust 1.98.1 (pinned); on #2176's head `fb99078`. - The two new tests: pass; with `lower.rs` reverted both fail with "a cross-half operation on a 32-lane host". The existing cross-lane GPU tests (DPP16 18, DPP8 5, swizzle 6 cases) pass. - `cargo test -q --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index`: 302 passed, 3 failed, 3 ignored; #2176 alone: 300 passed, the same 3 failed (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware`, the hardware failures of #1744). The skipped test kills the process on this card on #2176's base (#2571, fixed on `main` by #2596/#2587). - `cargo test --workspace --locked --no-fail-fast`: the other crates 565 passed, 2 failed (`dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views`: the capped-heap failures #2461 fixes), 7 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings` and with `--all-features`: clean. `cargo xtask policy`: 190 files ok. - Offline `victory translate --list` of the title's shader pack with `host_wave32` on (a one-line local change to the translate command to pass it, not in this PR): "a cross-half operation on a 32-lane host" 69 -> 51 programs; compute emitted 2291 -> 2309. The 18: the 2D and array mip-chain programs of levels 2-3 (16), a cascade-shadow min/max and a trail-map mip program. - A 12-minute run of the title (diag build, the opening cutscene into its first 3D shots) on this card with #2176 + #2461 + #2464 and the three programs of #1968 skipped (`VICTORY_SKIP_PIPELINES`), with and without this commit: programs refused as cross-half while playing 28 -> 23, no new refusals, no errors and no device removal in either run; frame rate the same (median about 1.3-1.4 fps there). **Not tested** - AMD and Intel cards (their hosts take wave64, so the path is not used there), WARP's 32-lane mode. - The 51 programs still refused cross the halves for real (`v_readlane` of another half and the like); not changed here. **AI use** - Claude Code (Claude Opus 5.5) found the cases, wrote the change and the tests, ran the measurements and drafted this description; I checked it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On a host of 32-lane waves (#2176) every cross-lane operation that is not
quad-local was refused as "a cross-half operation", but DPP rows (16 lanes),
DPP8 (8 lanes), ds_swizzle_b32 in its group-of-32 mode and ds_bpermute_b32
(each 32-lane half on its own, RDNA2 ISA 10.4.4) only read lanes of their
own half, which one host wave holds whole (FIND-7 in #1633).

cross_lane now takes how far an operation reaches. A DPP row write mask
numbers the wave's four rows, so a row operation stays in its half only
when the mask has the same bits for both halves (0xF, 0x5, 0xA, 0x0).

Offline `translate --list` of the title's shader pack as a 32-lane host:
"a cross-half operation on a 32-lane host" 69 -> 51 programs; compute
programs emitted 2291 -> 2309 (the 2D and array mip-chain programs of
levels 2-3, a cascade-shadow min/max and a trail-map mip program).

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

@⁠fuzeofficlal on GitHub · 2026-11-26 08:51 UTC · original · requested changes

Verified on a 32-lane NVIDIA GPU (RTX 5090, Windows 11):

  • emit::crosslane_tests::half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host: all 6 cases (dpp16 row_ror:4, row_mirror, row_share:3, dpp8, ds_swizzle_b32 bitmode SWAP(16), ds_bpermute_b32) passed on hardware.
  • Full emit::crosslane_tests:: (6/6), the three wave32-host refusal tests, and victory-gpu shader_cache:: (4/4) all passed; cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings (default and --all-features) and cargo xtask policy are clean.

One correctness edge case in crates/victory-shader/src/emit/lower.rs:

Asymmetric row_mask on a DPP quad_perm (ctrl: 0..=0xFF) bypasses the cross-half refusal

In dpp():

let quad = matches!(dpp, Dpp::Row { ctrl: 0..=0xFF, .. });
let reach = match dpp {
    Dpp::Lanes { .. } => 8,
    Dpp::Row { row_mask, .. } if row_mask & 3 == row_mask >> 2 => 16,
    Dpp::Row { .. } => self.wave(),
};
...
self.cross_lanes_within(quad, reach)?;

And in cross_lanes_within():

if !quad && self.host_wave() < lanes.min(self.wave()) {
    return Err("a cross-half operation on a 32-lane host");
}

When a wave64 compute shader uses a DPP quad permutation (ctrl: 0..=0xFF) with an asymmetric row_mask (e.g., row_mask = 0x1 or 0x4), reach is 64, but quad is true, so !quad && skips the cross-half check. On a 32-lane host, lane_index() (waveGetLaneIndex) is 0..31 in both halves, so ri = (lane >> 4) & 3 evaluates to {0, 1} in both halves — silently writing to row 2 (lanes 32-47) under row_mask = 0x1, or disabling writes for all 64 lanes under row_mask = 0x4.

Checking all cross_lanes_within call sites, every truly quad-local op already passes lanes <= 32 (ds_swizzle_b32 passes 32, symmetric Dpp::Row passes 16), so dropping !quad && from the condition (if self.host_wave() < lanes.min(self.wave())) fixes this cleanly without affecting valid quad operations. Adding a quad_perm + row_mask = 0x1 case to wave64_dpp_row_is_refused_on_wave32_host_only_with_a_mask_naming_one_half would lock it down.

(Optional non-blocking note: all 6 hardware cases in half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host run with all 64 lanes active and fi = true. Code inspection confirms src_lane_active / ds_bpermute_b32 work with waveGetLaneIndex() (0..31) + waveActiveBallot lo, and adding one divergent-EXEC / fi = false case would cover that path on 32-lane hardware too.)

**@⁠fuzeofficlal** on GitHub · 2026-11-26 08:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/3115#pullrequestreview-6070997712) · **requested changes** Verified on a 32-lane NVIDIA GPU (RTX 5090, Windows 11): - `emit::crosslane_tests::half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host`: all 6 cases (`dpp16 row_ror:4`, `row_mirror`, `row_share:3`, `dpp8`, `ds_swizzle_b32 bitmode SWAP(16)`, `ds_bpermute_b32`) passed on hardware. - Full `emit::crosslane_tests::` (6/6), the three wave32-host refusal tests, and `victory-gpu` `shader_cache::` (4/4) all passed; `cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings` (default and `--all-features`) and `cargo xtask policy` are clean. One correctness edge case in `crates/victory-shader/src/emit/lower.rs`: ### Asymmetric `row_mask` on a DPP `quad_perm` (`ctrl: 0..=0xFF`) bypasses the cross-half refusal In `dpp()`: ```rust let quad = matches!(dpp, Dpp::Row { ctrl: 0..=0xFF, .. }); let reach = match dpp { Dpp::Lanes { .. } => 8, Dpp::Row { row_mask, .. } if row_mask & 3 == row_mask >> 2 => 16, Dpp::Row { .. } => self.wave(), }; ... self.cross_lanes_within(quad, reach)?; ``` And in `cross_lanes_within()`: ```rust if !quad && self.host_wave() < lanes.min(self.wave()) { return Err("a cross-half operation on a 32-lane host"); } ``` When a wave64 compute shader uses a DPP quad permutation (`ctrl: 0..=0xFF`) with an asymmetric `row_mask` (e.g., `row_mask = 0x1` or `0x4`), `reach` is `64`, **but `quad` is `true`, so `!quad &&` skips the cross-half check**. On a 32-lane host, `lane_index()` (`waveGetLaneIndex`) is `0..31` in both halves, so `ri = (lane >> 4) & 3` evaluates to `{0, 1}` in both halves — silently writing to row 2 (lanes 32-47) under `row_mask = 0x1`, or disabling writes for all 64 lanes under `row_mask = 0x4`. Checking all `cross_lanes_within` call sites, every truly quad-local op already passes `lanes <= 32` (`ds_swizzle_b32` passes `32`, symmetric `Dpp::Row` passes `16`), so dropping `!quad &&` from the condition (`if self.host_wave() < lanes.min(self.wave())`) fixes this cleanly without affecting valid quad operations. Adding a `quad_perm` + `row_mask = 0x1` case to `wave64_dpp_row_is_refused_on_wave32_host_only_with_a_mask_naming_one_half` would lock it down. *(Optional non-blocking note: all 6 hardware cases in `half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host` run with all 64 lanes active and `fi = true`. Code inspection confirms `src_lane_active` / `ds_bpermute_b32` work with `waveGetLaneIndex()` (`0..31`) + `waveActiveBallot` `lo`, and adding one divergent-`EXEC` / `fi = false` case would cover that path on 32-lane hardware too.)*
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 08:51 UTC · original · approved these changes

Verified on RTX 5090 (native wave32 host) & WARP against origin/main (63bcca4):

  • cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1: 6/6 passed on RTX 5090 and WARP (including half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host).
  • cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1: 4/4 passed.
  • cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Great NVIDIA/wave32 win: cleanly enables half-local cross-lane wave64 operations on 32-lane hosts and keys the shader cache accordingly.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 08:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/3115#pullrequestreview-6070998074) · **approved these changes** Verified on RTX 5090 (native wave32 host) & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1`: 6/6 passed on RTX 5090 and WARP (including `half_local_cross_lane_ops_of_wave64_match_rdna2_on_a_wave32_host`). - `cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1`: 4/4 passed. - `cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Great NVIDIA/wave32 win: cleanly enables half-local cross-lane wave64 operations on 32-lane hosts and keys the shader cache accordingly. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Aniseto on GitHub · 2026-11-26 08:58 UTC · original

Ran the half-local cross-lane tests at 6f8cb55:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by rust-toolchain.toml), MSVC 14.44.35207, debug build. No dxil.dll on this host, so the test reports validation as skipped; the GPU comparisons still ran.

cargo test --locked -p victory-shader --lib half_local_cross_lane_ops_of_wave64 -- --test-threads=1 --nocapture
1 passed; 0 failed; 0 ignored; 308 filtered out      (exit 0)

The GPU test reports [PASS] for all six forms: DPP16 row_ror:4, row_mirror, row_share:3, DPP8, ds_swizzle_b32 SWAP(16) and ds_bpermute_b32 within the half, with all 64 logical lanes matching RDNA2. The negative test wave64_dpp_row_is_refused_on_wave32_host_only_with_a_mask_naming_one_half also passes (1/1).

What this adds: the author measured on an RTX 4070 12 GB (Ada). This is a Blackwell wave32 part, exercising exactly the host configuration the PR targets, and the thread has no report from another machine.

Not tested: the full victory-shader suite, DXIL validation (no dxil.dll), a title run, AMD and Intel GPUs, WARP, release profile.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-26 08:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/3115#issuecomment-7187260991) Ran the half-local cross-lane tests at `6f8cb55`: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, Rust 1.98.1 (pinned by `rust-toolchain.toml`), MSVC 14.44.35207, debug build. No `dxil.dll` on this host, so the test reports validation as skipped; the GPU comparisons still ran. ``` cargo test --locked -p victory-shader --lib half_local_cross_lane_ops_of_wave64 -- --test-threads=1 --nocapture 1 passed; 0 failed; 0 ignored; 308 filtered out (exit 0) ``` The GPU test reports `[PASS]` for all six forms: DPP16 `row_ror:4`, `row_mirror`, `row_share:3`, DPP8, `ds_swizzle_b32` SWAP(16) and `ds_bpermute_b32` within the half, with all 64 logical lanes matching RDNA2. The negative test `wave64_dpp_row_is_refused_on_wave32_host_only_with_a_mask_naming_one_half` also passes (1/1). What this adds: the author measured on an RTX 4070 12 GB (Ada). This is a Blackwell wave32 part, exercising exactly the host configuration the PR targets, and the thread has no report from another machine. Not tested: the full `victory-shader` suite, DXIL validation (no `dxil.dll`), a title run, AMD and Intel GPUs, WARP, release profile. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3115/head:github-bot/gh-3115'
git switch 'github-bot/gh-3115'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3115'
git switch 'github-bot/gh-3115'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3115'
git switch 'github-bot/gh-3115'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3115'
git switch 'main'
git merge --squash 'github-bot/gh-3115'
git switch 'main'
git merge --ff-only 'github-bot/gh-3115'
git switch 'main'
git merge 'github-bot/gh-3115'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3115
No description provided.