Shaders: lower float wave prefix sums via lane reads #1408

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

@⁠fuzeofficlal on GitHub · 2026-11-24 17:47 UTC · original
fuzeofficlal:fix/shader-float-wave-prefix-sum-1172 → main · +1112 −3 · 4 files · 1 commits · open

Fixes #1172.

Summary

  • Lower Op::AddF wave prefix sums (inclusive and exclusive) via waveActiveBallot + pointer-jumping waveReadLaneAt (Lower::float_prefix_sum) instead of dx.op.wavePrefixOp.f32, keeping Op::AddU on wavePrefixOp.i32.
  • Reproduces and eliminates the AMD Radeon D3D12 driver bug where wavePrefixOp.f32 corrupts lanes whose own input term is NaN, ±inf, or large enough (2^60) to round away earlier terms:
    • For exclusive prefix sums, a lane's own value never enters its accumulator (lowest active lane receives id, remaining active lanes start from their active predecessor).
    • For inclusive prefix sums, each active lane starts from its own value and folds active predecessors in low-to-high lane order without reading inactive host lanes.

Verification

  • Reproduced the pre-fix NaN / +inf corruption on live AMD Radeon(TM) Graphics in both Wave32 and Wave64, then verified wave_prefix_tests (Wave32 plain + narrowed EXEC + divergent s_cbranch_execz, native Wave64 64-lane compute, and 4×4 pixel shader rasterization):
    • dxil.dll validation + container hash check: passed
    • AMD Radeon(TM) Graphics (Wave32, native Wave64, and PS): passed
    • NVIDIA GeForce RTX 5090 (Wave32 and PS): passed
    • Microsoft D3D12 WARP (PS): passed
  • cargo clippy --workspace --all-features and cargo xtask policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-24 17:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408) `fuzeofficlal:fix/shader-float-wave-prefix-sum-1172` → `main` · +1112 −3 · 4 files · 1 commits · open Fixes #1172. ### Summary - Lower `Op::AddF` wave prefix sums (`inclusive` and `exclusive`) via `waveActiveBallot` + pointer-jumping `waveReadLaneAt` (`Lower::float_prefix_sum`) instead of `dx.op.wavePrefixOp.f32`, keeping `Op::AddU` on `wavePrefixOp.i32`. - Reproduces and eliminates the AMD Radeon D3D12 driver bug where `wavePrefixOp.f32` corrupts lanes whose own input term is `NaN`, `±inf`, or large enough (`2^60`) to round away earlier terms: - For exclusive prefix sums, a lane's own value never enters its accumulator (lowest active lane receives `id`, remaining active lanes start from their active predecessor). - For inclusive prefix sums, each active lane starts from its own value and folds active predecessors in low-to-high lane order without reading inactive host lanes. ### Verification - Reproduced the pre-fix `NaN` / `+inf` corruption on live **AMD Radeon(TM) Graphics** in both Wave32 and Wave64, then verified `wave_prefix_tests` (Wave32 plain + narrowed `EXEC` + divergent `s_cbranch_execz`, native Wave64 64-lane compute, and 4×4 pixel shader rasterization): - `dxil.dll` validation + container hash check: passed - **AMD Radeon(TM) Graphics** (Wave32, native Wave64, and PS): passed - **NVIDIA GeForce RTX 5090** (Wave32 and PS): passed - **Microsoft D3D12 WARP** (PS): passed - `cargo clippy --workspace --all-features` and `cargo xtask policy`: passed.
Lower Op::AddF wave prefix sums with ballot/clz/readLaneAt pointer doubling instead of wavePrefixOp.f32 (fixing AMD Radeon corruption on NaN/infinity/large-term lanes), extracted into emit/lower/wave_prefix.rs.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:41 +00:00
Author
Owner

@⁠matheusfermiano-source on GitHub · 2026-11-24 17:52 UTC · original

Tested on Linux under Proton, as a second AMD driver. In short: RADV does not show the #1172 defect, so a run there cannot confirm the fix. It does show the new lowering is exact on an RDNA2 GPU in Wave32, native Wave64 and the pixel-shader case, and on NVIDIA.

Setup

  • Laptop with a Radeon 660M (RDNA2, gfx1035; RADV, Mesa 26.3.1; waves 32..64) and an RTX 3050 Laptop (NVIDIA 620.73.04; waves 32..32). CachyOS, Linux 7.3.5.
  • Proton Experimental (experimental-11.0-20261027b) Wine, with its bundled vkd3d-proton 3.1.0 (cae2e003) and DXVK 3.1.1 DXGI. One GPU at a time (VK_LOADER_DRIVERS_SELECT).
  • Built on Linux with llvm-mingw 20261117 for x86_64-pc-windows-gnullvm, Rust 1.98.1. dxil.dll from DXC 1.9.2609: every module valid.

Results (victory-shader tests, --test-threads=1)

Tree Radeon 660M (RADV) RTX 3050 (NVIDIA, Linux)
#1408 at e7ef4e3, wave_prefix tests 5/5 pass: Wave32 (3 cases each), native Wave64, PS 5/5 pass; Wave64 cases skip (32-lane host)
#1408's tests with lower.rs from main (old wavePrefixOp.f32) 5/5 pass 5/5 pass
main ffe310e + @⁠rouges78's wave_prefix_tests.rs + 2^60 and +infinity in lane 11 sums exact: 10 f32 runs, 4 u32 runs same
the same + @⁠Paull007's patch from #1172 same, plus its lowering test passes same

What this means:

  • On RADV the old wavePrefixOp.f32 is already exact, in Wave32 and in Wave64. So the wrong lanes in #1172 come from AMD's Windows driver (its shader compiler), not from the RDNA2 hardware. A Linux/Proton run of these tests passes with or without the fix; the AMD Windows reproduction in the PR body is the run that shows it.
  • On both drivers here the new lowering gives the same results as the old one, including native Wave64 and the quad case.

A note for anyone running these tests under Proton: DXVK's DXGI has no WARP adapter, so the "D3D12 WARP" rows are the same hardware GPU again (they report its wave range).

Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run above was on this machine.

**@⁠matheusfermiano-source** on GitHub · 2026-11-24 17:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7139825694) Tested on Linux under Proton, as a second AMD driver. In short: RADV does not show the #1172 defect, so a run there cannot confirm the fix. It does show the new lowering is exact on an RDNA2 GPU in Wave32, native Wave64 and the pixel-shader case, and on NVIDIA. **Setup** - Laptop with a Radeon 660M (RDNA2, gfx1035; RADV, Mesa 26.3.1; waves 32..64) and an RTX 3050 Laptop (NVIDIA 620.73.04; waves 32..32). CachyOS, Linux 7.3.5. - Proton Experimental (experimental-11.0-20261027b) Wine, with its bundled vkd3d-proton 3.1.0 (`cae2e003`) and DXVK 3.1.1 DXGI. One GPU at a time (`VK_LOADER_DRIVERS_SELECT`). - Built on Linux with llvm-mingw 20261117 for `x86_64-pc-windows-gnullvm`, Rust 1.98.1. `dxil.dll` from DXC 1.9.2609: every module valid. **Results** (`victory-shader` tests, `--test-threads=1`) | Tree | Radeon 660M (RADV) | RTX 3050 (NVIDIA, Linux) | |---|---|---| | #1408 at `e7ef4e3`, `wave_prefix` tests | 5/5 pass: Wave32 (3 cases each), native Wave64, PS | 5/5 pass; Wave64 cases skip (32-lane host) | | #1408's tests with `lower.rs` from `main` (old `wavePrefixOp.f32`) | 5/5 pass | 5/5 pass | | `main` `ffe310e` + @⁠rouges78's `wave_prefix_tests.rs` + 2^60 and +infinity in lane 11 | sums exact: 10 f32 runs, 4 u32 runs | same | | the same + @⁠Paull007's patch from #1172 | same, plus its lowering test passes | same | What this means: - On RADV the old `wavePrefixOp.f32` is already exact, in Wave32 and in Wave64. So the wrong lanes in #1172 come from AMD's Windows driver (its shader compiler), not from the RDNA2 hardware. A Linux/Proton run of these tests passes with or without the fix; the AMD Windows reproduction in the PR body is the run that shows it. - On both drivers here the new lowering gives the same results as the old one, including native Wave64 and the quad case. A note for anyone running these tests under Proton: DXVK's DXGI has no WARP adapter, so the "D3D12 WARP" rows are the same hardware GPU again (they report its wave range). Synthetic tests only, no game files. AI-assisted (Claude Code, Opus 5.5); every run above was on this machine.
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:59 UTC · original

Independent verification of \e7ef4e3\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200, native wave32 + wave64) / Rust 1.98.1 MSVC:

  • Merge check vs \main\ (\ fe310e): clean
  • \cargo test -p victory-shader --lib wave_prefix_tests\ (real RX 9060 XT GPU execution): 5 passed, 0 failed
  • \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 155 files ok

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7140001298) Independent verification of \e7ef4e3\ on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200\, native wave32 + wave64) / Rust 1.98.1 MSVC**: - Merge check vs \main\ (\ fe310e\): clean - \cargo test -p victory-shader --lib wave_prefix_tests\ (real RX 9060 XT GPU execution): **5 passed, 0 failed** - \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and \--all-features\): clean - \cargo xtask policy\: 155 files ok *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 20:44 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head a69e324 onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 125, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 20:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7143985192) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head a69e324 onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 125, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 21:23 UTC · original

Hardware run on head 69e324, Radeon RX 7800 XT (RDNA3, driver 32.0.32029.2010), Windows 10 x64, Agility SDK 1.616 locally for SM 6.6:

  • wave_prefix_sum_f32_exclusive_wave32, ..._inclusive_wave32 and ..._wave64 — passed on the hardware backend.
  • wave_prefix_sum_f32_pixel_quad_all_backends — hardware part passed (ok: AMD Radeon RX 7800 XT [PS 4x4 target, wave=32..=64]), then the test failed at line 987 with xpected D3D12 WARP to execute the PS quad test.

WARP here tops out at SM 6.2 even with the Agility runtime, so the WARP half is skipped; the pixel test still requires it, which turns an unavailable backend into a failure. The compute tests already skip gracefully after 69e324; the PS-quad one could do the same (require at least one backend, or only WARP when it is present), otherwise Windows 10 hosts always report this test red although the AMD path is correct.

Happy to re-run after the change.

**@⁠Calvix2k** on GitHub · 2026-11-24 21:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7144877833) Hardware run on head 69e324, Radeon RX 7800 XT (RDNA3, driver 32.0.32029.2010), Windows 10 x64, Agility SDK 1.616 locally for SM 6.6: - wave_prefix_sum_f32_exclusive_wave32, ..._inclusive_wave32 and ..._wave64 — **passed** on the hardware backend. - wave_prefix_sum_f32_pixel_quad_all_backends — hardware part passed (ok: AMD Radeon RX 7800 XT [PS 4x4 target, wave=32..=64]), then the test failed at line 987 with xpected D3D12 WARP to execute the PS quad test. WARP here tops out at SM 6.2 even with the Agility runtime, so the WARP half is skipped; the pixel test still requires it, which turns an unavailable backend into a failure. The compute tests already skip gracefully after 69e324; the PS-quad one could do the same (require at least one backend, or only WARP when it is present), otherwise Windows 10 hosts always report this test red although the AMD path is correct. Happy to re-run after the change.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:26 UTC · original · edited 2026-11-26 03:24 UTC

Automated triage for the maintainers.

Verdict: merge candidate (unchanged). Thanks for the rebase. At 3a4ee54 (on 63bcca43), Lower::float_prefix_sum has moved to crates/victory-shader/src/emit/lower/wave_prefix.rs. It is the same ballot plus readLane pointer chain I reviewed before. wave_prefix_tests.rs now uses Host::from_device(device), which matches emit/host.rs on main. emit/lower.rs stays under the 512 KiB MAX_FILE_SIZE in xtask/src/policy.rs. Integer prefix sums still go through wavePrefixOp.i32.

One small nit: wave_prefix.rs has a stray blank line before the closing } of the impl. rustfmt would remove it.

CI: passing (check). Merges cleanly.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7151922253) · edited 2026-11-26 03:24 UTC <!-- victory-triage v1 head=3a4ee54c8f3c6d120b80b8641535365a68f4caeb verdict=merge-candidate at=2026-11-26T03:24:35Z --> Automated triage for the maintainers. **Verdict: merge candidate** (unchanged). Thanks for the rebase. At `3a4ee54` (on `63bcca43`), `Lower::float_prefix_sum` has moved to `crates/victory-shader/src/emit/lower/wave_prefix.rs`. It is the same ballot plus `readLane` pointer chain I reviewed before. `wave_prefix_tests.rs` now uses `Host::from_device(device)`, which matches `emit/host.rs` on `main`. `emit/lower.rs` stays under the 512 KiB `MAX_FILE_SIZE` in `xtask/src/policy.rs`. Integer prefix sums still go through `wavePrefixOp.i32`. One small nit: `wave_prefix.rs` has a stray blank line before the closing `}` of the `impl`. `rustfmt` would remove it. CI: passing (`check`). Merges cleanly. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:37 UTC · original

Rebased onto 940d32f (8254052a) and updated wave_prefix_sum_f32_pixel_quad_all_backends to skip WARP when no SM 6.6 WARP adapter is available (requiring ran > 0 instead of assert!(warp_ran)), matching the compute tests so Windows 10 hosts with SM 6.6 hardware pass cleanly. Thanks @⁠Calvix2k for the Windows 10 run!

**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7153020659) Rebased onto `940d32f` (`8254052a`) and updated `wave_prefix_sum_f32_pixel_quad_all_backends` to skip WARP when no SM 6.6 WARP adapter is available (requiring `ran > 0` instead of `assert!(warp_ran)`), matching the compute tests so Windows 10 hosts with SM 6.6 hardware pass cleanly. Thanks @⁠Calvix2k for the Windows 10 run!
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 06:38 UTC · original

Retested the rebased head 8254052a (on main 940d32f) on AMD Radeon RX 7600 (RDNA3) + Windows 11 D3D12 SM 6.6 WARP:

Environment

  • Windows 11 10.0.26340 x64, rustc 1.98.1 (x86_64-pc-windows-msvc)
  • GPU: AMD Radeon RX 7600 (driver 32.0.32029.2010, wave=32..=64) + D3D12 WARP (wave=4..=4)
  • DXIL validator: Windows SDK dxil.dll 1.8.2502.11
  • Scope: synthetic shader/GPU tests only (no game files / title not run)

Results on 8254052a

  • cargo test -p victory-shader --locked wave_prefix_tests -- --nocapture: 5 passed, 0 failed
    • ok: AMD Radeon RX 7600 [Wave32, inclusive=false, wave=32..=64]
    • ok: AMD Radeon RX 7600 [Wave32, inclusive=true, wave=32..=64]
    • ok: AMD Radeon RX 7600 [Wave64, inclusive=false, wave=32..=64]
    • ok: AMD Radeon RX 7600 [Wave64, inclusive=true, wave=32..=64]
    • ok: AMD Radeon RX 7600 [PS 4x4 target, wave=32..=64]
    • ok: D3D12 WARP [PS 4x4 target, wave=4..=4] (compute Wave32/64 skipped on WARP wave range 4..=4)
  • cargo test -p victory-shader --locked: 252 passed, 0 failed, 3 ignored
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings: 0 warnings
  • cargo xtask policy: asset policy: 183 files ok

AI-assisted review/testing; all builds and GPU runs executed locally on my own machine. No game files used.

**@⁠nathanbzrr** on GitHub · 2026-11-25 06:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7155008722) Retested the rebased head `8254052a` (on `main` `940d32f`) on **AMD Radeon RX 7600 (RDNA3)** + **Windows 11 D3D12 SM 6.6 WARP**: **Environment** - Windows 11 `10.0.26340` x64, `rustc 1.98.1` (`x86_64-pc-windows-msvc`) - GPU: **AMD Radeon RX 7600** (driver `32.0.32029.2010`, `wave=32..=64`) + **D3D12 WARP** (`wave=4..=4`) - DXIL validator: Windows SDK `dxil.dll 1.8.2502.11` - Scope: synthetic shader/GPU tests only (no game files / title not run) **Results on `8254052a`** - `cargo test -p victory-shader --locked wave_prefix_tests -- --nocapture`: **5 passed, 0 failed** - `ok: AMD Radeon RX 7600 [Wave32, inclusive=false, wave=32..=64]` - `ok: AMD Radeon RX 7600 [Wave32, inclusive=true, wave=32..=64]` - `ok: AMD Radeon RX 7600 [Wave64, inclusive=false, wave=32..=64]` - `ok: AMD Radeon RX 7600 [Wave64, inclusive=true, wave=32..=64]` - `ok: AMD Radeon RX 7600 [PS 4x4 target, wave=32..=64]` - `ok: D3D12 WARP [PS 4x4 target, wave=4..=4]` (compute Wave32/64 skipped on WARP `wave range 4..=4`) - `cargo test -p victory-shader --locked`: **252 passed, 0 failed, 3 ignored** - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: **0 warnings** - `cargo xtask policy`: `asset policy: 183 files ok` *AI-assisted review/testing; all builds and GPU runs executed locally on my own machine. No game files used.*
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 02:52 UTC · original

Rebased onto main (63bcca43) in 3a4ee54c, updated Host::from_device(device) in wave_prefix_tests.rs (fixing silent test-compilation breakage on current main), and moved float_prefix_sum into crates/victory-shader/src/emit/lower/wave_prefix.rs so emit/lower.rs stays well under the 512 KiB policy limit (~520.7 KiB). Verified wave_prefix_tests + emit::lower::tests (38/38), clippy --all-targets, and xtask policy.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 02:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7181193635) Rebased onto `main` (`63bcca43`) in `3a4ee54c`, updated `Host::from_device(device)` in `wave_prefix_tests.rs` (fixing silent test-compilation breakage on current `main`), and moved `float_prefix_sum` into `crates/victory-shader/src/emit/lower/wave_prefix.rs` so `emit/lower.rs` stays well under the 512 KiB policy limit (`~520.7 KiB`). Verified `wave_prefix_tests` + `emit::lower::tests` (`38/38`), `clippy --all-targets`, and `xtask policy`.
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 17:57 UTC · original · approved these changes

Tested head e7ef4e3 (fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • cargo test -p victory-shader wave_prefix_tests: 5 passed, 0 failed (wave_prefix_sum_u32_reads_back, wave_prefix_sum_f32_pixel_quad_all_backends, wave_prefix_sum_f32_exclusive_wave32, wave_prefix_sum_f32_inclusive_wave32, wave_prefix_sum_f32_wave64)
  • cargo test -p victory-shader valu_tests: 13 passed, 0 failed
  • cargo clippy -p victory-shader --all-targets: 0 warnings
  • cargo xtask policy: ok (156 files ok)

Solid float wave prefix sum lowering via lane reads, verified end-to-end on Blackwell hardware and WARP. Approving.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 17:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#pullrequestreview-6044595750) · **approved these changes** Tested head `e7ef4e3` (fast-forward on `main` `ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP**: - `cargo test -p victory-shader wave_prefix_tests`: **5 passed, 0 failed** (`wave_prefix_sum_u32_reads_back`, `wave_prefix_sum_f32_pixel_quad_all_backends`, `wave_prefix_sum_f32_exclusive_wave32`, `wave_prefix_sum_f32_inclusive_wave32`, `wave_prefix_sum_f32_wave64`) - `cargo test -p victory-shader valu_tests`: **13 passed, 0 failed** - `cargo clippy -p victory-shader --all-targets`: **0 warnings** - `cargo xtask policy`: ok (`156 files ok`) Solid float wave prefix sum lowering via lane reads, verified end-to-end on Blackwell hardware and WARP. Approving. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 19:24 UTC · original · approved these changes

Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96. GPU/valu execution tests are Windows-gated and were not run here.

Float wave prefix sums lower through lane reads: ballot the active lanes, find the previous set lane with unaryBits leading-zero counts per ballot word (wave32/64/128 all handled), then Hillis-Steele read_lane rounds. The 988-line wave_prefix_tests.rs pins f32 results against a CPU reference model across wave32/wave64, inclusive/exclusive, pixel quad and every backend — exactly the right harness for a float scan (addition is not associative, so the reference semantics matter). Windows-gated, not run here; macOS 96 green.

One thing to confirm on hardware: the CPU model's summation order vs. the shuffle tree's — the tests should catch any mismatch, but please make sure CI actually runs them (WARP + hardware).

**@⁠catminou4** on GitHub · 2026-11-24 19:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#pullrequestreview-6045875171) · **approved these changes** Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), `cargo test -p victory-shader --locked` → 96. GPU/valu execution tests are Windows-gated and were not run here. Float wave prefix sums lower through lane reads: ballot the active lanes, find the previous set lane with `unaryBits` leading-zero counts per ballot word (wave32/64/128 all handled), then Hillis-Steele `read_lane` rounds. The 988-line `wave_prefix_tests.rs` pins f32 results against a CPU reference model across wave32/wave64, inclusive/exclusive, pixel quad and every backend — exactly the right harness for a float scan (addition is not associative, so the reference semantics matter). Windows-gated, not run here; macOS 96 green. One thing to confirm on hardware: the CPU model's summation order vs. the shuffle tree's — the tests should catch any mismatch, but please make sure CI actually runs them (WARP + hardware).
Author
Owner

@⁠JAEdotUK on GitHub · 2026-11-26 13:10 UTC · original

Hardware test report: head 3a4ee54 (RDNA4)

Environment: AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029, Windows 11 (10.0.26200.9974), rustc 1.98.1. WARP not forced; the test output names the adapter ("AMD Radeon RX 9070 XT", wave=32..=64).

With the PR: cargo test -p victory-shader --lib --locked wave_prefix -- --nocapture -> 5 passed, 0 failed. Wave32 inclusive and exclusive, native Wave64 inclusive and exclusive, and the pixel-shader 4x4 case all ran on the RX 9070 XT and matched. The compute cases were skipped on WARP (wave range 4..=4), as the tests intend; the pixel-shader case also ran on WARP and passed.

Control: with lower.rs taken from the PR's parent commit (rebased onto main 63bcca4) and the PR's tests kept, 4 failed and 1 passed (the u32 test). Each failing test stops at its first wrong lane:

  • wave_prefix_sum_f32_exclusive_wave32 [nan_lanes_9_20], lane 9: got NaN (0x7fc00000), want -3.75 (0xc0700000)
  • wave_prefix_sum_f32_wave64 (exclusive) [nan_lanes_9_20], lane 9: same values
  • wave_prefix_sum_f32_inclusive_wave32 [pos_inf_lane_11], lane 11: got NaN (0xffc00000), want +inf (0x7f800000)
  • wave_prefix_sum_f32_pixel_quad_all_backends (PS exclusive, count=16, rank=0) [nan_lane_0], lane 0: got NaN (0x7fc00000), want 0

Not run: Clippy, xtask policy, any game files. Synthetic tests only.

AI use: this report was prepared with Claude (Claude Sonnet 5.5); the test run was done by me on my own machine.

**@⁠JAEdotUK** on GitHub · 2026-11-26 13:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7192967073) Hardware test report: head 3a4ee54 (RDNA4) Environment: AMD Radeon RX 9070 XT (RDNA4), driver 32.0.32015.7029, Windows 11 (10.0.26200.9974), rustc 1.98.1. WARP not forced; the test output names the adapter ("AMD Radeon RX 9070 XT", wave=32..=64). With the PR: cargo test -p victory-shader --lib --locked wave_prefix -- --nocapture -> 5 passed, 0 failed. Wave32 inclusive and exclusive, native Wave64 inclusive and exclusive, and the pixel-shader 4x4 case all ran on the RX 9070 XT and matched. The compute cases were skipped on WARP (wave range 4..=4), as the tests intend; the pixel-shader case also ran on WARP and passed. Control: with lower.rs taken from the PR's parent commit (rebased onto main 63bcca4) and the PR's tests kept, 4 failed and 1 passed (the u32 test). Each failing test stops at its first wrong lane: - wave_prefix_sum_f32_exclusive_wave32 [nan_lanes_9_20], lane 9: got NaN (0x7fc00000), want -3.75 (0xc0700000) - wave_prefix_sum_f32_wave64 (exclusive) [nan_lanes_9_20], lane 9: same values - wave_prefix_sum_f32_inclusive_wave32 [pos_inf_lane_11], lane 11: got NaN (0xffc00000), want +inf (0x7f800000) - wave_prefix_sum_f32_pixel_quad_all_backends (PS exclusive, count=16, rank=0) [nan_lane_0], lane 0: got NaN (0x7fc00000), want 0 Not run: Clippy, xtask policy, any game files. Synthetic tests only. AI use: this report was prepared with Claude (Claude Sonnet 5.5); the test run was done by me on my own machine.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:16 UTC · original

The compute tests do run on app-local D3D12 WARP 1.0.22 (wave range 4–128). I ran the exact same wave_prefix_tests.rs and module declaration on current upstream 63bcca4, then on the exact head 3a4ee54, with Agility 1.620.2, SDK DXIL validator 1.9.2609.5 and VICTORY_WARP=1. Both loaded app-local DLLs were verified.

Case Upstream + test fixture Exact PR head First mismatch in exact_quarters
Wave32 exclusive Pass Fail lane 4, -4.5 vs -1.5
Wave32 inclusive Pass Fail lane 4, -18 vs 2
Wave64 Pass Fail exclusive lane 4, -4.5 vs -1.5
Float pixel quad Pass Pass
Wave32 integer Pass Pass

The first float failure occurs in the plain input case, before the tests reach the narrowed-EXEC cases. These inputs are exact quarters, so addition grouping does not account for the difference. The lane-4 boundary is consistent with the dynamic lane-read issue seen on this WARP build in #2949. That is a hypothesis for this PR until tested in isolation. This software result sits alongside the RX 9070 XT result above, where the PR passed and the stock lowering failed.

To reproduce, place the WARP 1.0.22 x64 d3d10warp.dll beside the test executable, use SM 6.6-capable Agility, set VICTORY_WARP=1, and run emit::wave_prefix_tests --nocapture --test-threads=1.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 13:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7193113420) The compute tests do run on app-local **D3D12 WARP 1.0.22** (wave range 4–128). I ran the exact same `wave_prefix_tests.rs` and module declaration on current upstream `63bcca4`, then on the exact head `3a4ee54`, with Agility 1.620.2, SDK DXIL validator 1.9.2609.5 and `VICTORY_WARP=1`. Both loaded app-local DLLs were verified. | Case | Upstream + test fixture | Exact PR head | First mismatch in `exact_quarters` | | --- | --- | --- | --- | | Wave32 exclusive | Pass | Fail | lane 4, `-4.5` vs `-1.5` | | Wave32 inclusive | Pass | Fail | lane 4, `-18` vs `2` | | Wave64 | Pass | Fail | exclusive lane 4, `-4.5` vs `-1.5` | | Float pixel quad | Pass | Pass | | | Wave32 integer | Pass | Pass | | The first float failure occurs in the plain input case, before the tests reach the narrowed-EXEC cases. These inputs are exact quarters, so addition grouping does not account for the difference. The lane-4 boundary is consistent with the dynamic lane-read issue seen on this WARP build in #2949. That is a hypothesis for this PR until tested in isolation. This software result sits alongside the RX 9070 XT result above, where the PR passed and the stock lowering failed. To reproduce, place the [WARP 1.0.22](https://www.nuget.org/packages/Microsoft.Direct3D.WARP/1.0.22) x64 `d3d10warp.dll` beside the test executable, use SM 6.6-capable Agility, set `VICTORY_WARP=1`, and run `emit::wave_prefix_tests --nocapture --test-threads=1`. AI-assisted with Codex.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:23 UTC · original

I tested two follow-ups on the same WARP 1.0.22 setup.

  • Using #2997's four-lane-group reads inside the prefix scan made the plain Wave32 and Wave64 cases pass, along with Wave32 narrowed EXEC without a branch. The branched masked_two60 case still failed. For example, exclusive lane 9 read -2.25 instead of -0.25 in both widths.
  • Keeping the stock wavePrefixOp.f32 for compute on the software adapter made all five tests pass, including the branched cases. The hardware path still selects your prefix scan. The pixel-quad test still uses that path and passed on WARP. I also reran both permutation tests and all 33 lowerer tests. Strict shader Clippy and policy passed.

Patch ed634df is on a branch combining this PR's 3a4ee54 and #2997's a4484f5. It uses #2997's software-adapter selection and separate cache variant. The test fixture chooses lowering per adapter, so it will exercise the hardware scan and software prefix in the same suite when both are available. This follow-up was tested on WARP. The RX 9070 XT results above are for your original hardware path.

If you take the patch, please retain its Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into a different commit.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 13:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7193277257) I tested two follow-ups on the same WARP 1.0.22 setup. - Using #2997's four-lane-group reads inside the prefix scan made the plain Wave32 and Wave64 cases pass, along with Wave32 narrowed EXEC without a branch. The branched `masked_two60` case still failed. For example, exclusive lane 9 read `-2.25` instead of `-0.25` in both widths. - Keeping the stock `wavePrefixOp.f32` for **compute on the software adapter** made all five tests pass, including the branched cases. The hardware path still selects your prefix scan. The pixel-quad test still uses that path and passed on WARP. I also reran both permutation tests and all 33 lowerer tests. Strict shader Clippy and policy passed. [Patch `ed634df`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/ed634df866f4bb469d9520f8a56d3e9d5dcb684e) is on a branch combining this PR's `3a4ee54` and #2997's `a4484f5`. It uses #2997's software-adapter selection and separate cache variant. The test fixture chooses lowering per adapter, so it will exercise the hardware scan and software prefix in the same suite when both are available. This follow-up was tested on WARP. The RX 9070 XT results above are for your original hardware path. If you take the patch, please retain its Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into a different commit. AI-assisted with Codex.
This pull request can be merged automatically.
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/1408/head:github-bot/gh-1408'
git switch 'github-bot/gh-1408'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1408'
git switch 'github-bot/gh-1408'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1408'
git switch 'github-bot/gh-1408'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1408'
git switch 'main'
git merge --squash 'github-bot/gh-1408'
git switch 'main'
git merge --ff-only 'github-bot/gh-1408'
git switch 'main'
git merge 'github-bot/gh-1408'
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!1408
No description provided.