Shaders: enforce inactive-lane EXEC rules for DPP16, DPP8 and ds_swizzle_b32 #1582

Manually merged
github merged 1 commit from gh-pr/1582/head into gh-pr/1582/base 2026-11-26 04:37:04 +00:00
Owner

@⁠Capt-Speed on GitHub · 2026-11-24 19:26 UTC · original
Capt-Speed:research/crosslane-inactive-exec-semantics → main · +1106 −15 · 3 files · 1 commits · merged 2026-11-25 21:50 UTC

AI Disclosure: This PR was researched, implemented, and verified with AI coding assistance, using 100% synthetic RDNA2 test shaders and zero game data (cargo xtask policy: 155 files ok).

Summary

Fixes divergent-EXEC inactive-source semantics, out-of-row waveReadLaneAt UB, and pixel-shader quad helper-lane handling across RDNA2 cross-lane lowering (VIC-BT-008 and VIC-BT-018 in #1242):

  • DPP16 (0xFA): Honor fi (already decoded in gfx10::fields), evaluate source-lane EXEC activity via dx.op.waveActiveBallot(guard) before applying write-only row_mask/bank_mask, combine inside & src_active when !fi, and enforce bound_ctrl (1 → substitute 0, 0 → disable destination write preserving old vdst).
  • DPP8 (0xE9) vs DPP8FI (0xEA): Active destination lanes always write; when EXEC[src] == 0, 0xE9 (fi:0) substitutes 0 as src0 (matching AMD RDNA2 ISA & gfx1031 hardware measurements), while 0xEA (fi:1) fetches the inactive lane's src0.
  • ds_swizzle_b32: Return 0 when the selected source lane is inactive under EXEC (covering guarded straight-line EXEC, branched EXEC, and nested branch+guard paths).
  • Safe waveReadLaneAt indexing: Guard reads with select(valid, src, lane) before calling waveReadLaneAt, eliminating 0xFFFF_FFFF out-of-bounds lane reads on row_shr (even when fi == 1) and avoiding DXIL UB on inactive source lanes.
  • Pixel shader quad ops (WQM helper lanes): Lower pixel quad ds_swizzle_b32 and DPP quad_perm via quad_pick (dx.op.quadReadLaneAt) and skip waveActiveBallot when unguarded so DXIL does not zero out WQM helper lanes on triangle edges; when a guard is present, test the quad peer's guard via quad_pick.

Relationship to #1485 and #1416

While this branch was being tested locally, #1485 (VIC-BT-008) and #1416 (VIC-BT-018, compute-only) were opened. This PR unifies both under one shared Lower::src_lane_active() helper and addresses three issues observed in #1485:

  1. DPP8 (0xE9, fi:0) substitutes 0 rather than disabling the destination write on RDNA2 (gfx1031).
  2. waveReadLaneAt must be guarded against out-of-row (0xFFFF_FFFF) / inactive source indices before reading.
  3. Pixel-shader quad DPP must not run waveActiveBallot unconditionally, since DXIL excludes pixel helper lanes from ballot masks.

Verification (NVIDIA GeForce RTX 5090 D, Driver 621.14, Windows 11 26H1, D3D12 Debug Layer enabled)

Added 100% synthetic RDNA2 tests with a CPU reference oracle in crates/victory-shader/src/emit/crosslane_tests.rs:

  • Before fix (23 initial divergent-EXEC Wave32 compute GPU cases): 10 passed, 13 failed, 0 skipped (DPP16 5/14, DPP8 3/4, ds_swizzle_b32 2/5).
  • After fix:
    • crosslane_tests: 5/5 tests passed — 29/29 compute GPU cases passed (18 DPP16, 5 DPP8/DPP8FI, 6 ds_swizzle_b32, covering guarded, branched, nested branch+guard, and bank_mask source-activity independence), plus CPU oracle boundary checks and pixel-shader dxil.dll validation + RTX 5090D/WARP graphics PSO creation.
    • cargo clippy --workspace --all-targets --locked -- -D warnings: pass (0 warnings)
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass (0 warnings)
    • cargo test --workspace --locked: pass (0 failed; victory-shader 125 passed / 1 ignored, victory-gpu 50 passed / 1 ignored, xtask 4 passed including repository_passes_policy)
    • cargo xtask policy: 155 files ok

Limitations / Not Verified on Hardware

  • RTX 5090 D exposes WaveLaneCountMin = WaveLaneCountMax = 32, so the Wave64 upper-dword ballot path ((ballot_lane >> 5) & 1) was checked analytically (masking shift by & 31 to avoid poison) but not executed on a 64-lane GPU.
  • fi:1 across truly divergent DXIL hardware branches remains constrained by DXIL WaveReadLaneAt rules and is tested under straight-line guard narrowing.
  • Pixel shader quad ops were verified through dxil.dll validation and RTX 5090D/WARP PSO creation, not via a rasterized edge-pixel readback draw.

Related to #1242 (VIC-BT-008, VIC-BT-018).

**@⁠Capt-Speed** on GitHub · 2026-11-24 19:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1582) `Capt-Speed:research/crosslane-inactive-exec-semantics` → `main` · +1106 −15 · 3 files · 1 commits · merged 2026-11-25 21:50 UTC > **AI Disclosure:** This PR was researched, implemented, and verified with AI coding assistance, using **100% synthetic RDNA2 test shaders and zero game data** (`cargo xtask policy`: 155 files ok). ### Summary Fixes divergent-`EXEC` inactive-source semantics, out-of-row `waveReadLaneAt` UB, and pixel-shader quad helper-lane handling across RDNA2 cross-lane lowering (**`VIC-BT-008`** and **`VIC-BT-018`** in #1242): - **DPP16 (`0xFA`)**: Honor `fi` (already decoded in `gfx10::fields`), evaluate source-lane `EXEC` activity via `dx.op.waveActiveBallot(guard)` *before* applying write-only `row_mask`/`bank_mask`, combine `inside & src_active` when `!fi`, and enforce `bound_ctrl` (`1` → substitute `0`, `0` → disable destination write preserving old `vdst`). - **DPP8 (`0xE9`) vs DPP8FI (`0xEA`)**: Active destination lanes always write; when `EXEC[src] == 0`, `0xE9` (`fi:0`) substitutes `0` as `src0` (matching AMD RDNA2 ISA & `gfx1031` hardware measurements), while `0xEA` (`fi:1`) fetches the inactive lane's `src0`. - **`ds_swizzle_b32`**: Return `0` when the selected source lane is inactive under `EXEC` (covering guarded straight-line `EXEC`, branched `EXEC`, and nested branch+guard paths). - **Safe `waveReadLaneAt` indexing**: Guard reads with `select(valid, src, lane)` before calling `waveReadLaneAt`, eliminating `0xFFFF_FFFF` out-of-bounds lane reads on `row_shr` (even when `fi == 1`) and avoiding DXIL UB on inactive source lanes. - **Pixel shader quad ops (WQM helper lanes)**: Lower pixel quad `ds_swizzle_b32` and `DPP quad_perm` via `quad_pick` (`dx.op.quadReadLaneAt`) and skip `waveActiveBallot` when unguarded so DXIL does not zero out WQM helper lanes on triangle edges; when a `guard` is present, test the quad peer's guard via `quad_pick`. ### Relationship to #1485 and #1416 While this branch was being tested locally, #1485 (`VIC-BT-008`) and #1416 (`VIC-BT-018`, compute-only) were opened. This PR unifies both under one shared `Lower::src_lane_active()` helper and addresses three issues observed in #1485: 1. `DPP8` (`0xE9`, `fi:0`) substitutes `0` rather than disabling the destination write on RDNA2 (`gfx1031`). 2. `waveReadLaneAt` must be guarded against out-of-row (`0xFFFF_FFFF`) / inactive source indices before reading. 3. Pixel-shader quad DPP must not run `waveActiveBallot` unconditionally, since DXIL excludes pixel helper lanes from ballot masks. ### Verification (NVIDIA GeForce RTX 5090 D, Driver 621.14, Windows 11 26H1, D3D12 Debug Layer enabled) Added 100% synthetic RDNA2 tests with a CPU reference oracle in `crates/victory-shader/src/emit/crosslane_tests.rs`: - **Before fix** (23 initial divergent-`EXEC` Wave32 compute GPU cases): **10 passed, 13 failed, 0 skipped** (DPP16 5/14, DPP8 3/4, `ds_swizzle_b32` 2/5). - **After fix**: - `crosslane_tests`: **5/5 tests passed** — **29/29 compute GPU cases passed** (18 DPP16, 5 DPP8/DPP8FI, 6 `ds_swizzle_b32`, covering guarded, branched, nested branch+guard, and `bank_mask` source-activity independence), plus CPU oracle boundary checks and pixel-shader `dxil.dll` validation + RTX 5090D/WARP graphics PSO creation. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: pass (0 warnings) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: pass (0 warnings) - `cargo test --workspace --locked`: pass (0 failed; `victory-shader` 125 passed / 1 ignored, `victory-gpu` 50 passed / 1 ignored, `xtask` 4 passed including `repository_passes_policy`) - `cargo xtask policy`: `155 files ok` ### Limitations / Not Verified on Hardware - RTX 5090 D exposes `WaveLaneCountMin = WaveLaneCountMax = 32`, so the Wave64 upper-dword ballot path (`(ballot_lane >> 5) & 1`) was checked analytically (masking shift by `& 31` to avoid poison) but not executed on a 64-lane GPU. - `fi:1` across truly divergent DXIL hardware branches remains constrained by DXIL `WaveReadLaneAt` rules and is tested under straight-line `guard` narrowing. - Pixel shader quad ops were verified through `dxil.dll` validation and RTX 5090D/WARP PSO creation, not via a rasterized edge-pixel readback draw. Related to #1242 (`VIC-BT-008`, `VIC-BT-018`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:37:03 +00:00
github manually merged commit 80abf15d67 into gh-pr/1582/base 2026-11-26 04:37:04 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 19:32 UTC · original

Verified commit ab416b2 on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, gfx1200, SM 6.6) + WARP:

  • cargo test -p victory-shader --lib: 125 passed, 0 failed, 1 ignored
    • [SUMMARY] DPP8/DPP8FI: 5 passed, 0 failed, 0 skipped
    • [SUMMARY] ds_swizzle_b32: 6 passed, 0 failed, 0 skipped
    • [SUMMARY] DPP16: 18 passed, 0 failed, 0 skipped

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 19:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1582#issuecomment-7142235685) Verified commit `ab416b2` on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, `gfx1200`, SM 6.6)** + **WARP**: - `cargo test -p victory-shader --lib`: **125 passed, 0 failed, 1 ignored** - `[SUMMARY] DPP8/DPP8FI: 5 passed, 0 failed, 0 skipped` - `[SUMMARY] ds_swizzle_b32: 6 passed, 0 failed, 0 skipped` - `[SUMMARY] DPP16: 18 passed, 0 failed, 0 skipped` *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:31 UTC · original · edited 2026-11-25 02:27 UTC

Automated triage for the maintainers.

Recommended for a maintainer's look. In crates/victory-shader/src/emit/lower.rs, Lower::dpp now honours fi and treats a source lane that is out of EXEC like an out-of-row one (zero with bound_ctrl, otherwise no write; DPP8 with fi:0 reads zero), and ds_swizzle_b32 returns zero from an inactive source, both through a new src_lane_active helper built on waveActiveBallot. The waveReadLaneAt index is also redirected to the lane itself when the source is invalid, so no read targets an inactive or out-of-range lane. This matches the RDNA2 ISA's description of DPP FI/BOUND_CTRL. I checked that pixel shaders only reach this path for quad ops (cross_lane refuses the rest), so the quad_pick of the guard there is correct, and that unguarded pixel quad ops skip the ballot so helper lanes are not dropped. Overlap: #1416 (compute ds_swizzle_b32 only, open, needs rebase) does a subset of this; #1485 is closed. The Wave64 upper-dword ballot path is not run on hardware, as the description says. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1582#issuecomment-7149643431) · edited 2026-11-25 02:27 UTC <!-- victory-triage v1 head=80abf15d67b0ba4064994882b18c9be88e8f7797 verdict=merge-candidate at=2026-11-25T02:20:29Z --> Automated triage for the maintainers. Recommended for a maintainer's look. In `crates/victory-shader/src/emit/lower.rs`, `Lower::dpp` now honours `fi` and treats a source lane that is out of EXEC like an out-of-row one (zero with `bound_ctrl`, otherwise no write; DPP8 with `fi:0` reads zero), and `ds_swizzle_b32` returns zero from an inactive source, both through a new `src_lane_active` helper built on `waveActiveBallot`. The `waveReadLaneAt` index is also redirected to the lane itself when the source is invalid, so no read targets an inactive or out-of-range lane. This matches the RDNA2 ISA's description of DPP `FI`/`BOUND_CTRL`. I checked that pixel shaders only reach this path for quad ops (`cross_lane` refuses the rest), so the `quad_pick` of the guard there is correct, and that unguarded pixel quad ops skip the ballot so helper lanes are not dropped. Overlap: #1416 (compute `ds_swizzle_b32` only, open, needs rebase) does a subset of this; #1485 is closed. The Wave64 upper-dword ballot path is not run on hardware, as the description says. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Capt-Speed on GitHub · 2026-11-25 01:58 UTC · original

Rebased onto current \main\ (\940d32f) at commit \80abf15:

  • Resolved the \lower.rs\ conflict cleanly by keeping \main's \helpers_read(quad)\ helper and reusing \lane_bit_of.
  • Updated \crosslane_tests.rs\ for the new \lower::Parts\ / \HostShader\ fields and guarded \wave32_hardware_info\ against software adapters so hardware-only Wave32 tests skip cleanly even when \VICTORY_WARP=1\ on Windows 26H1 (where WARP reports Wave 4–128).
  • Re-verified locally on RTX 5090 D: both \clippy\ jobs (default & --all-features) pass with 0 warnings, \cargo xtask policy\ passes (\183 files ok), \VICTORY_WARP=1\ passes (5/5), and hardware \crosslane_tests\ passes (29/29 GPU cases + pixel PSO).
**@⁠Capt-Speed** on GitHub · 2026-11-25 01:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1582#issuecomment-7150167982) Rebased onto current \main\ (\940d32f\) at commit \80abf15\: - Resolved the \lower.rs\ conflict cleanly by keeping \main\'s \helpers_read(quad)\ helper and reusing \lane_bit_of\. - Updated \crosslane_tests.rs\ for the new \lower::Parts\ / \HostShader\ fields and guarded \wave32_hardware_info\ against software adapters so hardware-only Wave32 tests skip cleanly even when \VICTORY_WARP=1\ on Windows 26H1 (where WARP reports Wave 4–128). - Re-verified locally on RTX 5090 D: both \clippy\ jobs (default & \--all-features\) pass with 0 warnings, \cargo xtask policy\ passes (\183 files ok\), \VICTORY_WARP=1\ passes (5/5), and hardware \crosslane_tests\ passes (29/29 GPU cases + pixel PSO).
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:23 UTC · original

Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 80abf15. cargo test --workspace --locked --no-fail-fast -> 701 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1582#issuecomment-7158272893) **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `80abf15`. `cargo test --workspace --locked --no-fail-fast` -> 701 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
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!1582
No description provided.