Shaders: enforce inactive-lane EXEC rules for DPP16, DPP8 and ds_swizzle_b32 (port of Marvisak#1582) #845

Merged
Capt-Speed merged 1 commit from upstream-pr/845 into main 2026-11-29 00:24:47 +00:00
Capt-Speed commented 2026-11-28 07:39:08 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Capt-Speed on 2026-11-28T07:39:08Z.


Port of Marvisak/VIctory#1582 to VIctory-NVIDIA (main @ 63b902f), preserving VIctory-NVIDIA's pixel quad_read fast path and extending coverage to Wave64 halves, native Wave64, pixel edge rendering, and two additional cross-lane edge cases found during multi-GPU testing.

Changes

  • Inactive-lane EXEC enforcement (crates/victory-shader/src/emit/lower.rs):
    • Track source-lane activity in src_lane_active (guard + waveActiveBallot via lane_bit_of for wave/mesh paths; quad_read of guard for convergent pixel quads) across DPP16, DPP8/DPP8FI, and ds_swizzle_b32.
    • Clamp invalid/out-of-row source lanes to lane (select(valid, src, lane)) before issuing waveReadLaneAt, avoiding undefined out-of-range or inactive-lane reads while still applying bound_ctrl (0 vs write-disable) and fi (fetch_inactive).
    • Handle host wave lane indexing for Wave32, native Wave64 (high/low ballot dwords), Wave64 halves, and 1D mesh quads.
  • Refuse pixel quad reads inside per-lane divergent control flow (cross_lane):
    • Return Err("a pixel quad read inside divergent control flow") when self.s.pixel && quad && !all_lane_blocks(self.x.st), matching permlane's existing refusal pattern rather than silently reading stale neighbour values on hardware (observed failing 52/96 lit pixels on AMD Radeon Graphics before this check).
    • Uniform/scalar branches keep all_lane_blocks == true, and convergent WQM / straight-line guard pixel quad ops remain on quad_read.
  • Fix Wave64 halves destination row_mask (dpp):
    • Compute DPP16 destination row indices from self.console_lane() instead of host lane, so console lanes 32..63 map to rows 2..3 (row_mask = 0x4 / 0x8) instead of aliasing rows 0..1. On non-halves/exchange shaders, console_lane() returns lane_index() directly.
  • End-to-end hardware, WARP, and DXIL tests (crates/victory-shader/src/emit/crosslane_tests.rs):
    • Exact RDNA2 (GFX10.3) CPU reference oracle + crosslane_tests covering Wave32 (29 cases), Wave64 halves (7 cases including row_mask=0x4/0x8), pixel quad edge drawing (RTX + WARP), and divergent pixel quad refusal.

Verification

Environment: Windows 11, NVIDIA GeForce RTX 5090 D (driver 621.14, SM 6.8, Wave 32..32), Microsoft WARP, and Windows SDK dxil.dll 1.8.2502.11.

Check Baseline (63b902f) This PR (16d9c75)
Wave32 DPP16 (18 cases) 6/18 18/18
Wave32 DPP8 / DPP8FI (5 cases) 3/5 5/5
Wave32 ds_swizzle_b32 (6 cases) 2/6 6/6
Wave32 total (0 skipped, RTX 5090 D) 11/29 29/29
Wave64 halves (EXEC_LO=0x55555555, EXEC_HI=0x77777777, RTX 5090 D) 1/5 (232/320 lanes) 7/7 (448/448 lanes, incl. row_mask=0x4/0x8)
Pixel quad edge draw (96 lit texels, 8 edge pixels with uncovered horizontal helpers) 52/96 wrong on guarded ds_swizzle_b32 (RTX & WARP) 0/96 wrong on RTX & WARP; WQM quad_read (+1/-1) intact
Divergent pixel quad refusal (DPP16 0xB1 & ds_swizzle_b32 0x80B1) Silent misrender (52/96 wrong on AMD) Cleanly refused (ShaderError::Unsupported)
wave64_tests 13/13 13/13
xtask repository_passes_policy --locked 1/1 1/1
cargo clippy -p victory-shader --lib --tests --locked (default & --all-features) — 0 warnings in touched/added files

(Pre-refusal multi-GPU cross-checks on AMD Radeon(TM) Graphics native Wave64 also moved the 5 Wave64 cases from 1/5 / 232/320 lanes to 5/5 / 320/320 lanes, and RTX mesh quad draws moved from 4/8 to 8/8 matching quads.)

Notes & Known Boundaries

  • Shader cache fingerprint: Editing crates/victory-shader/src/ updates the VICTORY_TRANSLATOR BLAKE3 key (victory-gpu/build.rs), so first launch with this change will re-translate cached shaders on demand under the new key (existing cache files remain intact).
  • fi:1 inside true hardware branches: Same limitation as upstream Marvisak#1582 — fi:1 (DPP16 fi:1 / DPP8FI) fetches inactive lanes under straight-line guard narrowing, whereas inside a true DXIL hardware branch (br i1) lanes that skipped the branch arm do not execute waveReadLaneAt and return undefined values per DXIL rules.
  • Verification scope: All results above come from synthetic RDNA2 ISA tests with D3D12 hardware/WARP readbacks and DXIL validation; this PR does not make title rendering or frame-time claims.
  • Cargo.lock and workspace manifests are unchanged; no external crates added.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5537974888 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/845). Originally posted by [Capt-Speed](https://github.com/Capt-Speed) on 2026-11-28T07:39:08Z. --- Port of [`Marvisak/VIctory#1582`](https://github.com/Marvisak/VIctory/pull/1582) to `VIctory-NVIDIA` (`main` @ `63b902f`), preserving `VIctory-NVIDIA`'s pixel `quad_read` fast path and extending coverage to Wave64 `halves`, native Wave64, pixel edge rendering, and two additional cross-lane edge cases found during multi-GPU testing. ### Changes - **Inactive-lane `EXEC` enforcement (`crates/victory-shader/src/emit/lower.rs`)**: - Track source-lane activity in `src_lane_active` (`guard` + `waveActiveBallot` via `lane_bit_of` for wave/mesh paths; `quad_read` of `guard` for convergent pixel quads) across `DPP16`, `DPP8`/`DPP8FI`, and `ds_swizzle_b32`. - Clamp invalid/out-of-row source lanes to `lane` (`select(valid, src, lane)`) **before** issuing `waveReadLaneAt`, avoiding undefined out-of-range or inactive-lane reads while still applying `bound_ctrl` (`0` vs write-disable) and `fi` (`fetch_inactive`). - Handle host wave lane indexing for Wave32, native Wave64 (high/low ballot dwords), Wave64 `halves`, and 1D mesh quads. - **Refuse pixel quad reads inside per-lane divergent control flow (`cross_lane`)**: - Return `Err("a pixel quad read inside divergent control flow")` when `self.s.pixel && quad && !all_lane_blocks(self.x.st)`, matching `permlane`'s existing refusal pattern rather than silently reading stale neighbour values on hardware (observed failing 52/96 lit pixels on AMD Radeon Graphics before this check). - Uniform/scalar branches keep `all_lane_blocks == true`, and convergent WQM / straight-line `guard` pixel quad ops remain on `quad_read`. - **Fix Wave64 `halves` destination `row_mask` (`dpp`)**: - Compute `DPP16` destination row indices from `self.console_lane()` instead of host `lane`, so console lanes `32..63` map to rows `2..3` (`row_mask = 0x4 / 0x8`) instead of aliasing rows `0..1`. On non-`halves`/`exchange` shaders, `console_lane()` returns `lane_index()` directly. - **End-to-end hardware, WARP, and DXIL tests (`crates/victory-shader/src/emit/crosslane_tests.rs`)**: - Exact RDNA2 (GFX10.3) CPU reference oracle + `crosslane_tests` covering Wave32 (29 cases), Wave64 `halves` (7 cases including `row_mask=0x4/0x8`), pixel quad edge drawing (RTX + WARP), and divergent pixel quad refusal. ### Verification Environment: Windows 11, NVIDIA GeForce RTX 5090 D (driver 621.14, SM 6.8, Wave 32..32), Microsoft WARP, and Windows SDK `dxil.dll` 1.8.2502.11. | Check | Baseline (`63b902f`) | This PR (`16d9c75`) | |---|---:|---:| | Wave32 `DPP16` (18 cases) | 6/18 | **18/18** | | Wave32 `DPP8` / `DPP8FI` (5 cases) | 3/5 | **5/5** | | Wave32 `ds_swizzle_b32` (6 cases) | 2/6 | **6/6** | | **Wave32 total (0 skipped, RTX 5090 D)** | **11/29** | **29/29** | | Wave64 `halves` (`EXEC_LO=0x55555555`, `EXEC_HI=0x77777777`, RTX 5090 D) | 1/5 (232/320 lanes) | **7/7 (448/448 lanes, incl. `row_mask=0x4/0x8`)** | | Pixel quad edge draw (96 lit texels, 8 edge pixels with uncovered horizontal helpers) | 52/96 wrong on guarded `ds_swizzle_b32` (RTX & WARP) | **0/96 wrong** on RTX & WARP; WQM `quad_read` (`+1`/`-1`) intact | | Divergent pixel quad refusal (`DPP16 0xB1` & `ds_swizzle_b32 0x80B1`) | Silent misrender (52/96 wrong on AMD) | **Cleanly refused** (`ShaderError::Unsupported`) | | `wave64_tests` | 13/13 | **13/13** | | `xtask repository_passes_policy --locked` | 1/1 | **1/1** | | `cargo clippy -p victory-shader --lib --tests --locked` (default & `--all-features`) | — | **0 warnings** in touched/added files | *(Pre-refusal multi-GPU cross-checks on AMD Radeon(TM) Graphics native Wave64 also moved the 5 Wave64 cases from `1/5` / `232/320` lanes to `5/5` / `320/320` lanes, and RTX mesh quad draws moved from `4/8` to `8/8` matching quads.)* ### Notes & Known Boundaries - **Shader cache fingerprint**: Editing `crates/victory-shader/src/` updates the `VICTORY_TRANSLATOR` BLAKE3 key (`victory-gpu/build.rs`), so first launch with this change will re-translate cached shaders on demand under the new key (existing cache files remain intact). - **`fi:1` inside true hardware branches**: Same limitation as upstream `Marvisak#1582` — `fi:1` (`DPP16 fi:1` / `DPP8FI`) fetches inactive lanes under straight-line `guard` narrowing, whereas inside a true DXIL hardware branch (`br i1`) lanes that skipped the branch arm do not execute `waveReadLaneAt` and return undefined values per DXIL rules. - **Verification scope**: All results above come from synthetic RDNA2 ISA tests with D3D12 hardware/WARP readbacks and DXIL validation; this PR does not make title rendering or frame-time claims. - `Cargo.lock` and workspace manifests are unchanged; no external crates added.
Dukestar69 commented 2026-11-28 07:44:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T07:44:44Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (295 files ok).
  • Tests (RTX 5090):
    • cargo test -p victory-shader --lib emit::crosslane_tests:: passed (8 passed; 0 failed, verifying DPP16/DPP8/DPP8FI/ds_swizzle_b32 inactive-lane EXEC rules, Wave64 halves, and pixel-quad edge/guarded swizzle behavior on GPU).
    • cargo test -p victory-shader --lib emit::lower::tests:: passed (15 passed; 0 failed; 1 ignored).
    • cargo test -p victory-shader --lib emit::tests:: passed (22 passed; 0 failed; 1 ignored).
  • Lint: cargo clippy -p victory-shader --lib -- -D warnings passed with 0 warnings.

Thorough RDNA2 cross-lane inactive-source EXEC semantics with strong GPU execution coverage. LGTM.

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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6096606777 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/845#pullrequestreview-6096606777). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T07:44:44Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`295 files ok`). - **Tests (RTX 5090)**: - `cargo test -p victory-shader --lib emit::crosslane_tests::` passed (`8 passed; 0 failed`, verifying DPP16/DPP8/DPP8FI/ds_swizzle_b32 inactive-lane EXEC rules, Wave64 halves, and pixel-quad edge/guarded swizzle behavior on GPU). - `cargo test -p victory-shader --lib emit::lower::tests::` passed (`15 passed; 0 failed; 1 ignored`). - `cargo test -p victory-shader --lib emit::tests::` passed (`22 passed; 0 failed; 1 ignored`). - **Lint**: `cargo clippy -p victory-shader --lib -- -D warnings` passed with 0 warnings. Thorough RDNA2 cross-lane inactive-source EXEC semantics with strong GPU execution coverage. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Aniseto commented 2026-11-28 07:50:19 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Aniseto on 2026-11-28T07:50:19Z.


Ran the cross-lane inactive-lane tests at 16d9c75 on an NVIDIA Blackwell desktop part:

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, DXC 1.9.2609.5 (shared env), debug build.

cargo test -p victory-shader --lib emit::crosslane_tests -- --test-threads=1
8 passed; 0 failed; 0 ignored; 0 measured; 298 filtered out      (exit 0)

All eight emit::crosslane_tests pass on a real 32-lane adapter, including the dpp16, dpp8/dpp8fi and ds_swizzle_b32 inactive-source cases. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti. Native wave64 and pixel-quad refusal paths were not exercised by this filter.

Not tested: native wave64 hosts, the pixel quad reads in divergent control flow, a paired smoke run, the full workspace suite, AMD and Intel GPUs, Wine, release profile, game data.

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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7236193714 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/845#issuecomment-7236193714). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-28T07:50:19Z. --- Ran the cross-lane inactive-lane tests at `16d9c75` on an NVIDIA Blackwell desktop part: 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, DXC 1.9.2609.5 (shared env), debug build. ``` cargo test -p victory-shader --lib emit::crosslane_tests -- --test-threads=1 8 passed; 0 failed; 0 ignored; 0 measured; 298 filtered out (exit 0) ``` All eight `emit::crosslane_tests` pass on a real 32-lane adapter, including the `dpp16`, `dpp8`/`dpp8fi` and `ds_swizzle_b32` inactive-source cases. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti. Native wave64 and pixel-quad refusal paths were not exercised by this filter. Not tested: native wave64 hosts, the pixel quad reads in divergent control flow, a paired smoke run, the full workspace suite, AMD and Intel GPUs, Wine, release profile, game data. 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.
upipibi commented 2026-11-28 21:14:31 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by upipibi on 2026-11-28T21:14:31Z.


Tested on Ampere: RTX 3070 (10de:2484), driver 616.56, native Windows 11 Pro 10.0.26100, rustc 1.98.1. Debug test profile. The system WARP is the one that ships with Windows.

  • Head 16d9c75c8, merged onto main 923e38cc8 (--no-ff, clean, no conflicts). The PR's base is 63b902f, 264 commits behind main. The merge changes the same three files by the same amounts as the PR: crosslane_tests.rs +1543, lower.rs +126/-23, mod.rs +2. The head was still 16d9c75c8 when I finished.

Ampere shows the bug on main, and the PR fixes it. On main's lower.rs the 3070 fails the same Wave32 cases as the 5090 D in the description: DPP16 6/18, DPP8/DPP8FI 3/5, ds_swizzle_b32 2/6, 11/29 in all. With the PR, the 3070 passes 29/29, and the wave64 halves cases pass 7/7 (448/448 lanes).

The tests

cargo test -p victory-shader --lib --locked -- --nocapture --test-threads=1 emit::crosslane_tests
VICTORY_WARP=1 cargo test ...   # same command
  • Default, 3 runs: 8 passed, 0 failed, 0 ignored each (6.4 to 6.9 s).
  • VICTORY_WARP=1, 3 runs: 8 passed, 0 failed, 0 ignored each (0.25 s). Four of these eight passes check nothing. See below.

What each of the 8 tests does:

test device
cpu_reference_oracle_boundary_checks none, CPU reference only
divergent_pixel_quad_reads_are_reported_as_unsupported none, lowering only
pixel_quad_swizzle_and_dpp_validate_and_create_pipeline creates a graphics pipeline, hardware then warp; no draw
dpp16_inactive_source_and_bound_ctrl_match_rdna2_on_gpu 32-lane hardware dispatch only
dpp8_and_dpp8fi_inactive_source_match_rdna2_on_gpu 32-lane hardware dispatch only
ds_swizzle_b32_inactive_source_returns_zero_on_gpu 32-lane hardware dispatch only
wave64_halves_dpp_and_swizzle_match_rdna2_on_gpu 32-lane hardware dispatch only
pixel_quad_edge_dpp_and_guarded_swizzle_match_on_gpu draws on hardware, then on warp

The four compute tests call wave32_hardware_info. It returns None for an adapter with the software flag, or one without a 32-lane wave size, and then the test prints hardware device does not support 32-lane waves; skipped and passes. With VICTORY_WARP=1, Host::new(false) opens WARP, so all 29 Wave32 cases and the wave64 test skip:

[SUMMARY] DPP16: 0 passed, 0 failed, 18 skipped
[SUMMARY] DPP8/DPP8FI: 0 passed, 0 failed, 5 skipped
[SUMMARY] ds_swizzle_b32: 0 passed, 0 failed, 6 skipped
hardware device does not support 32-lane waves; wave64 halves skipped

The same thing happens on any runner without a 32-lane card. So only the pixel edge test gives WARP data.

Adapters seen

For one run of each setting, I added a temporary eprintln!. It resolves device.GetAdapterLuid() through EnumAdapterByLuid and prints GetDesc1 and WaveLaneCountMin/Max at every device the tests open. I removed it afterwards.

run label adapter vendor:device flags wave lanes
default compute (26 dispatches) and hardware NVIDIA GeForce RTX 3070 10de:2484 0x0 32-32
default warp Microsoft Basic Render Driver 1414:008c 0x2 (software) 4-4
VICTORY_WARP=1 all, hardware included Microsoft Basic Render Driver 1414:008c 0x2 (software) 4-4

The wave64 test prints its own adapter line: NVIDIA GeForce RTX 3070 | SM=0x68 | Wave=32-32 | RT=D3D12_RAYTRACING_TIER(12) | Mesh=D3D12_MESH_SHADER_TIER(10). In the VICTORY_WARP=1 runs, the pixel edge test's on hardware line is WARP too.

With the PR, every run gave [PASS] for each of the 18 + 5 + 6 Wave32 cases and the 7 wave64 cases (64/64 lanes) on the 3070. The pixel edge test printed 96 lit texels on hardware and on WARP.

Negative control: main's lower.rs, PR's tests

git checkout 923e38cc8 -- crates/victory-shader/src/emit/lower.rs. git diff --stat 923e38cc8 -- crates/: crosslane_tests.rs and mod.rs only (the tests, plus my temporary prints). It builds, with the same single warning as main.

  • Default, 3 runs: 2 passed, 6 failed, 0 ignored each.
  • VICTORY_WARP=1, 3 runs: 6 passed, 2 failed, 0 ignored each. Four of the six passes are the skips described above.

All six runs gave the same values.

test 3070 (default) WARP (VICTORY_WARP=1)
cpu_reference_oracle_boundary_checks pass (no device) pass (no device)
pixel_quad_swizzle_and_dpp_validate_and_create_pipeline pass (pipelines only; passes on main) pass
dpp16_... fail, 6/18 cases pass skipped, passes
dpp8_and_dpp8fi_... fail, 3/5 skipped, passes
ds_swizzle_b32_... fail, 2/6 skipped, passes
wave64_halves_... fail, 1/7 skipped, passes
pixel_quad_edge_... fail, 52/96 texels fail, 52/96 texels
divergent_pixel_quad_reads_are_reported_as_unsupported fail (no device) fail (no device)

The failing Wave32 cases on the 3070, as the test prints them (first wrong lane):

case lanes wrong first lane: got / want
dpp16 row_shr:1 bc:1 fi:0 (guarded, 0x55555555) 14/32 2: 0x10010004 / 0x00010002
dpp16 row_shr:1 bc:0 fi:0 (guarded, 0x55555555) 14/32 2: 0x10010004 / 0xdead0002
dpp16 row_shr:1 bc:0 fi:0 (branched, 0x55555555) 14/32 2: 0x00010002 / 0xdead0002
dpp16 quad_perm:[1,0,3,2] bc:0 fi:0 (guarded, 0x77777777) 8/32 2: 0x10000004 / 0xdead0002
dpp16 row_shl:1 rm:0x1 bm:0x5 bc:1 fi:0 (guarded, 0x77777777) 2/32 2: 0x10010006 / 0x00010002
dpp16 row_ror:1 bc:0 fi:0 (guarded, 0x55555555) 16/32 0: 0x10000010 / 0xdead0000
dpp16 row_share:3 bc:1 fi:0 (guarded, 0x77777777) 24/32 0: 0x10000004 / 0x00000000
dpp16 row_xmask:1 bc:0 fi:0 (branched, 0x55555555) 16/32 0: 0x00000000 / 0xdead0000
dpp16 row_mirror bc:1 fi:0 (guarded, 0x55555555) 16/32 0: 0x10000010 / 0x00000000
dpp16 row_half_mirror bc:0 fi:0 (guarded, 0x55555555) 16/32 0: 0x10000008 / 0xdead0000
dpp16 row_shr:1 bc:0 fi:0 (nested branch+guard, 0x07070707) 2/32 8: 0x00010008 / 0xdead0008
dpp16 row_shl:1 bc:1 fi:0 (nested branch+guard, 0x07070707) 4/32 2: 0x10010006 / 0x00010002
dpp8 (0xE9, fi:0) mov (guarded, 0x77777777) 8/32 2: 0x10000004 / 0x00000000
dpp8 (0xE9, fi:0) add (nested branch+guard, 0x07070707) 4/32 2: 0x10010006 / 0x00010002
ds_swizzle_b32 bitmode SWAP(1) (guarded, 0x55555555) 16/32 0: 0x10000002 / 0x00000000
ds_swizzle_b32 bitmode SWAP(1) (guarded, 0x77777777) 8/32 2: 0x10000004 / 0x00000000
ds_swizzle_b32 quad_perm [3,2,1,0] (guarded, 0x77777777) 8/32 0: 0x10000004 / 0x00000000
ds_swizzle_b32 bitmode SWAP(1) (nested branch+guard, 0x07070707) 4/32 2: 0x10000004 / 0x00000000

The six DPP16 cases that pass on main are the three fi:1 cases, the two branched cases with bc:1, and the full-EXEC bank_mask case. DPP8 and ds_swizzle also pass their fi:1 and branched cases. The fi:0 cases on main read the inactive source lane's value. RDNA2 gives 0 (bound_ctrl:1 / ds_swizzle) or keeps the old vdst (0xdead...., bound_ctrl:0) instead.

wave64_halves_... stops at its first wrong lane (crosslane_tests.rs:1320): wave64 halves dpp16 row_shr:1 bc:0 fi:0: lane 2 got 0x10010004 want 0xdead0002. I replaced the assert with a count and ran it once more on main's code, then put it back. The 3070 then gave 1/7 cases and 336/448 lanes right:

case lanes wrong (half 0 + half 1) first lane: got / want
dpp16 row_shr:1 bc:0 fi:0 20/64 (14 + 6) 2: 0x10010004 / 0xdead0002
dpp16 row_shr:1 bc:1 fi:0 20/64 (14 + 6) 2: 0x10010004 / 0x00010002
dpp16 row_shr:1 row_mask:0x4 bc:1 fi:0 12/64 (0 + 12) 32: 0xdead0020 / 0x00010020
dpp16 row_shr:1 row_mask:0x8 bc:1 fi:0 12/64 (0 + 12) 48: 0xdead0030 / 0x00010030
dpp8 (0xE9, fi:0) mov 24/64 (16 + 8) 0: 0x10000002 / 0x00000000
dpp8fi (0xEA, fi:1) mov pass
ds_swizzle_b32 SWAP(1) 24/64 (16 + 8) 0: 0x10000002 / 0x00000000

The two row_mask cases are wrong only in the upper half, which keeps the old vdst in rows 2 and 3. That is the row-aliasing the PR fixes with console_lane(). The description's main baseline is "1/5 (232/320 lanes)" on a 5090 D. It used a different set of cases, so I can't compare the numbers directly.

pixel_quad_edge_... panics at crosslane_tests.rs:1547 with hardware: texel (0, 0) guarded quad swizzle got 1.5, want 0. In a default run that leg is the 3070, and the WARP leg never runs. With a count in place of the assert, one more run on main's code gave the same result on both adapters: 96 lit, 0 wrong unguarded dx, 52 wrong guarded. All 52 are even-x texels (want 0). They returned 1.5 (15), 3.5 (13), 5.5 (10), 7.5 (7), 9.5 (5) and 11.5 (2). That matches the description's "52/96 wrong" on RTX and WARP.

divergent_pixel_quad_reads_are_reported_as_unsupported never opens a device. It panics at crosslane_tests.rs:1442 with expected Unsupported at offset 56, got Ok(HostShader { stage: Ps, ..., because main lowers the divergent quad read without an error. Its result says nothing about the card.

cargo test -p victory-shader --lib --locked (default, once each)

  • PR merged onto 923e38cc8: 356 passed, 0 failed, 8 ignored (268 s).
  • Plain main 923e38cc8: 348 passed, 0 failed, 8 ignored (292 s).
  • The eight extra passes are the new tests. There were no failures.

The PR adds no compiler warnings. The one warning in both builds, unused colour, is main's (lower.rs:13896 on main, :13999 on the merge).

CI

gh pr checks 845: no checks reported on the branch. I did not run clippy.

Overlap

  • No pr-overlap bot comment on the PR. A search of open PRs for DPP, swizzle, inactive lane, cross-lane, quad_read, EXEC and 1582 finds no other PR for this.
  • #348 (paired Wave64 form, VICTORY_WAVE_PAIRS=1) makes the same row_mask row-index change, but only when self.twin.is_some():
    let row_lane = if self.twin.is_some() { self.console_lane() } else { lane };
    #845 uses self.console_lane() unconditionally. git merge-tree of the two heads has exactly one conflict, this line in lower.rs. It is a mechanical conflict. I did not check whether #845's form covers #348's paired form; that is a hypothesis.
  • #1504 (Wave64 programs on 32-lane cards) adds DPP8/row_mirror tests and talks about DPP within 32 lanes. git merge-tree with #845 is clean.
  • Upstream Marvisak/VIctory#1582 is merged (2026-11-25).

Not tested

  • Native wave64 hosts (this card has 32-lane waves only), mesh-shader quads, and AMD or Intel cards.
  • The Wave32 and wave64 compute cases on WARP. The tests skip them there.
  • fi:1 inside a real DXIL branch (the known limit in the description).
  • A real title shader that uses these instructions, and the game.
  • VICTORY_SHADER_OPT, clippy, the release build, and the rest of the workspace.
  • Merging alongside #348.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7245874555 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/845#issuecomment-7245874555). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T21:14:31Z. --- Tested on Ampere: RTX 3070 (`10de:2484`), driver 616.56, native Windows 11 Pro 10.0.26100, rustc 1.98.1. Debug test profile. The system WARP is the one that ships with Windows. - Head `16d9c75c8`, merged onto main `923e38cc8` (`--no-ff`, clean, no conflicts). The PR's base is `63b902f`, 264 commits behind main. The merge changes the same three files by the same amounts as the PR: `crosslane_tests.rs` +1543, `lower.rs` +126/-23, `mod.rs` +2. The head was still `16d9c75c8` when I finished. **Ampere shows the bug on main, and the PR fixes it.** On main's `lower.rs` the 3070 fails the same Wave32 cases as the 5090 D in the description: DPP16 6/18, DPP8/DPP8FI 3/5, `ds_swizzle_b32` 2/6, 11/29 in all. With the PR, the 3070 passes 29/29, and the wave64 `halves` cases pass 7/7 (448/448 lanes). **The tests** ``` cargo test -p victory-shader --lib --locked -- --nocapture --test-threads=1 emit::crosslane_tests VICTORY_WARP=1 cargo test ... # same command ``` - Default, 3 runs: 8 passed, 0 failed, 0 ignored each (6.4 to 6.9 s). - `VICTORY_WARP=1`, 3 runs: 8 passed, 0 failed, 0 ignored each (0.25 s). **Four of these eight passes check nothing.** See below. What each of the 8 tests does: | test | device | |---|---| | `cpu_reference_oracle_boundary_checks` | none, CPU reference only | | `divergent_pixel_quad_reads_are_reported_as_unsupported` | none, lowering only | | `pixel_quad_swizzle_and_dpp_validate_and_create_pipeline` | creates a graphics pipeline, `hardware` then `warp`; no draw | | `dpp16_inactive_source_and_bound_ctrl_match_rdna2_on_gpu` | 32-lane hardware dispatch only | | `dpp8_and_dpp8fi_inactive_source_match_rdna2_on_gpu` | 32-lane hardware dispatch only | | `ds_swizzle_b32_inactive_source_returns_zero_on_gpu` | 32-lane hardware dispatch only | | `wave64_halves_dpp_and_swizzle_match_rdna2_on_gpu` | 32-lane hardware dispatch only | | `pixel_quad_edge_dpp_and_guarded_swizzle_match_on_gpu` | draws on `hardware`, then on `warp` | The four compute tests call `wave32_hardware_info`. It returns `None` for an adapter with the software flag, or one without a 32-lane wave size, and then the test prints `hardware device does not support 32-lane waves; skipped` and **passes**. With `VICTORY_WARP=1`, `Host::new(false)` opens WARP, so all 29 Wave32 cases and the wave64 test skip: ``` [SUMMARY] DPP16: 0 passed, 0 failed, 18 skipped [SUMMARY] DPP8/DPP8FI: 0 passed, 0 failed, 5 skipped [SUMMARY] ds_swizzle_b32: 0 passed, 0 failed, 6 skipped hardware device does not support 32-lane waves; wave64 halves skipped ``` The same thing happens on any runner without a 32-lane card. So only the pixel edge test gives WARP data. **Adapters seen** For one run of each setting, I added a temporary `eprintln!`. It resolves `device.GetAdapterLuid()` through `EnumAdapterByLuid` and prints `GetDesc1` and `WaveLaneCountMin/Max` at every device the tests open. I removed it afterwards. | run | label | adapter | vendor:device | flags | wave lanes | |---|---|---|---|---|---| | default | compute (26 dispatches) and `hardware` | NVIDIA GeForce RTX 3070 | `10de:2484` | `0x0` | 32-32 | | default | `warp` | Microsoft Basic Render Driver | `1414:008c` | `0x2` (software) | 4-4 | | `VICTORY_WARP=1` | all, `hardware` included | Microsoft Basic Render Driver | `1414:008c` | `0x2` (software) | 4-4 | The wave64 test prints its own adapter line: `NVIDIA GeForce RTX 3070 | SM=0x68 | Wave=32-32 | RT=D3D12_RAYTRACING_TIER(12) | Mesh=D3D12_MESH_SHADER_TIER(10)`. In the `VICTORY_WARP=1` runs, the pixel edge test's `on hardware` line is WARP too. With the PR, every run gave `[PASS]` for each of the 18 + 5 + 6 Wave32 cases and the 7 wave64 cases (`64/64 lanes`) on the 3070. The pixel edge test printed `96 lit texels` on hardware and on WARP. **Negative control: main's `lower.rs`, PR's tests** `git checkout 923e38cc8 -- crates/victory-shader/src/emit/lower.rs`. `git diff --stat 923e38cc8 -- crates/`: `crosslane_tests.rs` and `mod.rs` only (the tests, plus my temporary prints). It builds, with the same single warning as main. - Default, 3 runs: **2 passed, 6 failed, 0 ignored each.** - `VICTORY_WARP=1`, 3 runs: **6 passed, 2 failed, 0 ignored each.** Four of the six passes are the skips described above. All six runs gave the same values. | test | 3070 (default) | WARP (`VICTORY_WARP=1`) | |---|---|---| | `cpu_reference_oracle_boundary_checks` | pass (no device) | pass (no device) | | `pixel_quad_swizzle_and_dpp_validate_and_create_pipeline` | pass (pipelines only; passes on main) | pass | | `dpp16_...` | **fail, 6/18 cases pass** | skipped, passes | | `dpp8_and_dpp8fi_...` | **fail, 3/5** | skipped, passes | | `ds_swizzle_b32_...` | **fail, 2/6** | skipped, passes | | `wave64_halves_...` | **fail, 1/7** | skipped, passes | | `pixel_quad_edge_...` | **fail, 52/96 texels** | **fail, 52/96 texels** | | `divergent_pixel_quad_reads_are_reported_as_unsupported` | fail (no device) | fail (no device) | The failing Wave32 cases on the 3070, as the test prints them (first wrong lane): | case | lanes wrong | first lane: got / want | |---|---|---| | dpp16 row_shr:1 bc:1 fi:0 (guarded, 0x55555555) | 14/32 | 2: `0x10010004` / `0x00010002` | | dpp16 row_shr:1 bc:0 fi:0 (guarded, 0x55555555) | 14/32 | 2: `0x10010004` / `0xdead0002` | | dpp16 row_shr:1 bc:0 fi:0 (branched, 0x55555555) | 14/32 | 2: `0x00010002` / `0xdead0002` | | dpp16 quad_perm:[1,0,3,2] bc:0 fi:0 (guarded, 0x77777777) | 8/32 | 2: `0x10000004` / `0xdead0002` | | dpp16 row_shl:1 rm:0x1 bm:0x5 bc:1 fi:0 (guarded, 0x77777777) | 2/32 | 2: `0x10010006` / `0x00010002` | | dpp16 row_ror:1 bc:0 fi:0 (guarded, 0x55555555) | 16/32 | 0: `0x10000010` / `0xdead0000` | | dpp16 row_share:3 bc:1 fi:0 (guarded, 0x77777777) | 24/32 | 0: `0x10000004` / `0x00000000` | | dpp16 row_xmask:1 bc:0 fi:0 (branched, 0x55555555) | 16/32 | 0: `0x00000000` / `0xdead0000` | | dpp16 row_mirror bc:1 fi:0 (guarded, 0x55555555) | 16/32 | 0: `0x10000010` / `0x00000000` | | dpp16 row_half_mirror bc:0 fi:0 (guarded, 0x55555555) | 16/32 | 0: `0x10000008` / `0xdead0000` | | dpp16 row_shr:1 bc:0 fi:0 (nested branch+guard, 0x07070707) | 2/32 | 8: `0x00010008` / `0xdead0008` | | dpp16 row_shl:1 bc:1 fi:0 (nested branch+guard, 0x07070707) | 4/32 | 2: `0x10010006` / `0x00010002` | | dpp8 (0xE9, fi:0) mov (guarded, 0x77777777) | 8/32 | 2: `0x10000004` / `0x00000000` | | dpp8 (0xE9, fi:0) add (nested branch+guard, 0x07070707) | 4/32 | 2: `0x10010006` / `0x00010002` | | ds_swizzle_b32 bitmode SWAP(1) (guarded, 0x55555555) | 16/32 | 0: `0x10000002` / `0x00000000` | | ds_swizzle_b32 bitmode SWAP(1) (guarded, 0x77777777) | 8/32 | 2: `0x10000004` / `0x00000000` | | ds_swizzle_b32 quad_perm [3,2,1,0] (guarded, 0x77777777) | 8/32 | 0: `0x10000004` / `0x00000000` | | ds_swizzle_b32 bitmode SWAP(1) (nested branch+guard, 0x07070707) | 4/32 | 2: `0x10000004` / `0x00000000` | The six DPP16 cases that pass on main are the three `fi:1` cases, the two `branched` cases with `bc:1`, and the full-EXEC `bank_mask` case. DPP8 and `ds_swizzle` also pass their `fi:1` and `branched` cases. The `fi:0` cases on main read the inactive source lane's value. RDNA2 gives `0` (`bound_ctrl:1` / `ds_swizzle`) or keeps the old `vdst` (`0xdead....`, `bound_ctrl:0`) instead. `wave64_halves_...` stops at its first wrong lane (`crosslane_tests.rs:1320`): `wave64 halves dpp16 row_shr:1 bc:0 fi:0: lane 2 got 0x10010004 want 0xdead0002`. I replaced the assert with a count and ran it once more on main's code, then put it back. The 3070 then gave 1/7 cases and 336/448 lanes right: | case | lanes wrong (half 0 + half 1) | first lane: got / want | |---|---|---| | dpp16 row_shr:1 bc:0 fi:0 | 20/64 (14 + 6) | 2: `0x10010004` / `0xdead0002` | | dpp16 row_shr:1 bc:1 fi:0 | 20/64 (14 + 6) | 2: `0x10010004` / `0x00010002` | | dpp16 row_shr:1 row_mask:0x4 bc:1 fi:0 | 12/64 (0 + 12) | 32: `0xdead0020` / `0x00010020` | | dpp16 row_shr:1 row_mask:0x8 bc:1 fi:0 | 12/64 (0 + 12) | 48: `0xdead0030` / `0x00010030` | | dpp8 (0xE9, fi:0) mov | 24/64 (16 + 8) | 0: `0x10000002` / `0x00000000` | | dpp8fi (0xEA, fi:1) mov | pass | | | ds_swizzle_b32 SWAP(1) | 24/64 (16 + 8) | 0: `0x10000002` / `0x00000000` | The two `row_mask` cases are wrong only in the upper half, which keeps the old `vdst` in rows 2 and 3. That is the row-aliasing the PR fixes with `console_lane()`. The description's main baseline is "1/5 (232/320 lanes)" on a 5090 D. It used a different set of cases, so I can't compare the numbers directly. `pixel_quad_edge_...` panics at `crosslane_tests.rs:1547` with `hardware: texel (0, 0) guarded quad swizzle got 1.5, want 0`. In a default run that leg is the 3070, and the WARP leg never runs. With a count in place of the assert, one more run on main's code gave the same result on both adapters: 96 lit, 0 wrong unguarded `dx`, **52 wrong guarded**. All 52 are even-x texels (want `0`). They returned 1.5 (15), 3.5 (13), 5.5 (10), 7.5 (7), 9.5 (5) and 11.5 (2). That matches the description's "52/96 wrong" on RTX and WARP. `divergent_pixel_quad_reads_are_reported_as_unsupported` never opens a device. It panics at `crosslane_tests.rs:1442` with `expected Unsupported at offset 56, got Ok(HostShader { stage: Ps, ...`, because main lowers the divergent quad read without an error. Its result says nothing about the card. **`cargo test -p victory-shader --lib --locked`** (default, once each) - PR merged onto `923e38cc8`: 356 passed, 0 failed, 8 ignored (268 s). - Plain main `923e38cc8`: 348 passed, 0 failed, 8 ignored (292 s). - The eight extra passes are the new tests. There were no failures. The PR adds no compiler warnings. The one warning in both builds, unused `colour`, is main's (`lower.rs:13896` on main, `:13999` on the merge). **CI** `gh pr checks 845`: no checks reported on the branch. I did not run clippy. **Overlap** - No pr-overlap bot comment on the PR. A search of open PRs for DPP, swizzle, inactive lane, cross-lane, quad_read, EXEC and 1582 finds no other PR for this. - #348 (paired Wave64 form, `VICTORY_WAVE_PAIRS=1`) makes the same `row_mask` row-index change, but only when `self.twin.is_some()`: `let row_lane = if self.twin.is_some() { self.console_lane() } else { lane };` #845 uses `self.console_lane()` unconditionally. `git merge-tree` of the two heads has exactly one conflict, this line in `lower.rs`. It is a mechanical conflict. I did not check whether #845's form covers #348's paired form; that is a hypothesis. - #1504 (Wave64 programs on 32-lane cards) adds DPP8/`row_mirror` tests and talks about DPP within 32 lanes. `git merge-tree` with #845 is clean. - Upstream Marvisak/VIctory#1582 is merged (2026-11-25). **Not tested** - Native wave64 hosts (this card has 32-lane waves only), mesh-shader quads, and AMD or Intel cards. - The Wave32 and wave64 compute cases on WARP. The tests skip them there. - `fi:1` inside a real DXIL branch (the known limit in the description). - A real title shader that uses these instructions, and the game. - `VICTORY_SHADER_OPT`, clippy, the release build, and the rest of the workspace. - Merging alongside #348. AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
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
trustno1-coder/VIctory-NVIDIA!845
No description provided.