Shaders: allow half-local DPP in divergent Wave64 Emulate (FIND-7) #3198

Closed
makmatvey wants to merge 20 commits from upstream-pr/3200 into main
makmatvey commented 2026-11-26 12:23:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by makmatvey on 2026-11-26T12:23:03Z.


Stacked on #189; only the top commit belongs here. Related but separate from #3115 (that PR is the #2176 wave64-on-32-lane cross-half refusal).

What's wrong

Under Wave64Mode::Emulate (#189), DPP source picks go through exchange_64, which refuses with "a cross-lane wave operation in divergent control flow" / "a cross-lane read in divergent control flow" whenever EXEC is narrowed. DPP row/quad/DPP8 never leave a 32-lane half (#1317 H-6.3 / FIND-7), so they need no LDS barrier and should stay legal in divergent control flow. Only v_permlanex16, 64-wide v_readlane, and 64-bit ballots really cross the halves.

What the change does

  • crates/victory-shader/src/emit/lower.rs: in Emulate (non-mesh-quad) DPP, use host lane indices and WaveReadLaneAt instead of exchange_64.
  • crates/victory-shader/src/emit/lower/wave64.rs: src_lane_active(..., half_local) uses the host waveActiveBallot for half-local DPP FI=0, skipping the 64-lane ballot/barrier path.
  • ds_swizzle / permute paths that still need console-lane exchange keep half_local: false.

Tests

  • New divergent_dpp_row_emits_under_wave64_emulate: divergent row_shr:1 emits under Emulate; a same-shape divergent 64-bit ballot still refuses.
  • cargo check -p victory-shader --locked and cargo clippy -p victory-shader --locked -- -D warnings clean on Linux.
  • cargo test -p victory-shader --lib does not compile on Linux on #189's base (validator is cfg(windows)); Windows CI is the gate.
  • cargo xtask policy: 193 files ok.

Asset policy

No game data used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5509947593 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3200). Originally posted by [makmatvey](https://github.com/makmatvey) on 2026-11-26T12:23:03Z. --- Stacked on #189; only the top commit belongs here. Related but separate from #3115 (that PR is the #2176 wave64-on-32-lane `cross-half` refusal). **What's wrong** Under `Wave64Mode::Emulate` (#189), DPP source picks go through `exchange_64`, which refuses with "a cross-lane wave operation in divergent control flow" / "a cross-lane read in divergent control flow" whenever EXEC is narrowed. DPP row/quad/DPP8 never leave a 32-lane half (#1317 H-6.3 / FIND-7), so they need no LDS barrier and should stay legal in divergent control flow. Only `v_permlanex16`, 64-wide `v_readlane`, and 64-bit ballots really cross the halves. **What the change does** - `crates/victory-shader/src/emit/lower.rs`: in Emulate (non-mesh-quad) DPP, use host lane indices and `WaveReadLaneAt` instead of `exchange_64`. - `crates/victory-shader/src/emit/lower/wave64.rs`: `src_lane_active(..., half_local)` uses the host `waveActiveBallot` for half-local DPP FI=0, skipping the 64-lane ballot/barrier path. - `ds_swizzle` / permute paths that still need console-lane exchange keep `half_local: false`. **Tests** - New `divergent_dpp_row_emits_under_wave64_emulate`: divergent `row_shr:1` emits under Emulate; a same-shape divergent 64-bit ballot still refuses. - `cargo check -p victory-shader --locked` and `cargo clippy -p victory-shader --locked -- -D warnings` clean on Linux. - `cargo test -p victory-shader --lib` does not compile on Linux on #189's base (`validator` is `cfg(windows)`); Windows CI is the gate. - `cargo xtask policy`: 193 files ok. **Asset policy** No game data used.
Dukestar69 commented 2026-11-26 12:28:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T12:28:28Z.

Review: COMMENTED


Tested on Windows 11 (RTX 5090 + WARP) against origin/main (63bcca4):

  • cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings: clean.
  • cargo xtask policy: 193 files ok.
  • cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1: 5/5 passed on RTX 5090 and WARP.
  • cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1: 5/5 passed.
  • cargo test -p victory-shader --lib emit::wave64_tests:: -- --test-threads=1: 34/35 passed, 1 failed:
    • emit::wave64_tests::gpu::gpu_128_threads_ds_swizzle_and_dpp_row_mask passed on RTX 5090 (wave=(true, 32..=32), [Emulate, Wave32]), but failed on WARP (wave=(true, 4..=4), [Emulate]):
      assertion `left == right` failed: ds_swizzle_dpp_rowmask (Emulate, WARP) output mismatch
        left[16..20]:  [65554, 65555, 65552, 65553, ...]
        right[16..20]: [1048594, 2162707, 2293776, 2424849, ...]
      
    • Looks like Emulate mode assumes host wave width >= 32 (or >= 16) for half-local DPP row operations, which breaks on inbox WARP (wave=(true, 4..=4)).

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6074125013 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3200#pullrequestreview-6074125013). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T12:28:28Z. **Review:** COMMENTED --- Tested on Windows 11 (RTX 5090 + WARP) against `origin/main` (`63bcca4`): - `cargo clippy -p victory-shader -p victory-gpu -p victory --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 193 files ok. - `cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1`: 5/5 passed on RTX 5090 and WARP. - `cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1`: 5/5 passed. - `cargo test -p victory-shader --lib emit::wave64_tests:: -- --test-threads=1`: **34/35 passed, 1 failed**: - `emit::wave64_tests::gpu::gpu_128_threads_ds_swizzle_and_dpp_row_mask` **passed on RTX 5090** (`wave=(true, 32..=32)`, `[Emulate, Wave32]`), but **failed on WARP** (`wave=(true, 4..=4)`, `[Emulate]`): ``` assertion `left == right` failed: ds_swizzle_dpp_rowmask (Emulate, WARP) output mismatch left[16..20]: [65554, 65555, 65552, 65553, ...] right[16..20]: [1048594, 2162707, 2293776, 2424849, ...] ``` - Looks like `Emulate` mode assumes host wave width >= 32 (or >= 16) for half-local DPP row operations, which breaks on inbox WARP (`wave=(true, 4..=4)`). Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Jackster commented 2026-11-26 23:10:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T23:10:53Z.


Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX — one test fails here, and it is the test that fails in CI:

thread 'emit::wave64_tests::gpu::gpu_128_threads_ds_swizzle_and_dpp_row_mask' panicked at wave64_tests.rs:1239:
assertion `left == right` failed: ds_swizzle_dpp_rowmask (Emulate, WARP) output mismatch
test result: FAILED. 40 passed; 1 failed
  • That is the same test and the same line as the failing check job on this PR (run 45819143235, job 139906541570), so it reproduces rather than being a CI flake.
  • The failing label is (Emulate, WARP) — the emulated path on the software adapter; the other combinations in the same run pass.
  • Unpatched 63bcca4: the wave64 filter matches only 5 tests, all passing, so the failing case is added by this PR.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.

The rest of the wave64 suite (40 tests) passes on this machine. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205322907 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3200#issuecomment-7205322907). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T23:10:53Z. --- Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX — **one test fails here, and it is the test that fails in CI**: ``` thread 'emit::wave64_tests::gpu::gpu_128_threads_ds_swizzle_and_dpp_row_mask' panicked at wave64_tests.rs:1239: assertion `left == right` failed: ds_swizzle_dpp_rowmask (Emulate, WARP) output mismatch test result: FAILED. 40 passed; 1 failed ``` - That is the same test and the same line as the failing `check` job on this PR (run 45819143235, job 139906541570), so it reproduces rather than being a CI flake. - The failing label is `(Emulate, WARP)` — the emulated path on the software adapter; the other combinations in the same run pass. - Unpatched `63bcca4`: the `wave64` filter matches only 5 tests, all passing, so the failing case is added by this PR. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. The rest of the wave64 suite (40 tests) passes on this machine. Synthetic only. AI-assisted.

Pull request closed

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
Marvisak/VIctory!3198
No description provided.