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

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/1408 into main
fuzeofficlal commented 2026-11-24 17:47:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T17:47:51Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5477394584 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T17:47:51Z. --- 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.
DenRakEiw commented 2026-11-24 17:57:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T17:57:05Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6044595750 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#pullrequestreview-6044595750). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T17:57:05Z. **Review:** APPROVED --- 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).
matheusfermiano-source commented 2026-11-24 18:06:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by matheusfermiano-source on 2026-11-24T17:52:20Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7139825694 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7139825694). Originally posted by [matheusfermiano-source](https://github.com/matheusfermiano-source) on 2026-11-24T17:52:20Z. --- 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.
geiyiliyabumo commented 2026-11-24 18:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T17:59:38Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140001298 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7140001298). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T17:59:38Z. --- 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.*
catminou4 commented 2026-11-24 19:24:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:24:57Z.

Review: APPROVED


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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045875171 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#pullrequestreview-6045875171). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T19:24:57Z. **Review:** APPROVED --- 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).
sinan-cmyk commented 2026-11-24 21:03:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:44:05Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143985192 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7143985192). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T20:44:05Z. --- ### 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).
Calvix2k commented 2026-11-24 21:28:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T21:23:58Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144877833 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7144877833). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T21:23:58Z. --- 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.
Marvisak commented 2026-11-25 04:06:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:26:50Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151922253 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7151922253). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:26:50Z. --- <!-- 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)_
fuzeofficlal commented 2026-11-25 05:06:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:37:53Z.


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!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153020659 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7153020659). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:37:53Z. --- 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!
nathanbzrr commented 2026-11-25 07:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by nathanbzrr on 2026-11-25T06:38:45Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7155008722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7155008722). Originally posted by [nathanbzrr](https://github.com/nathanbzrr) on 2026-11-25T06:38:45Z. --- 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.*
fuzeofficlal commented 2026-11-26 03:05:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:52:24Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181193635 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7181193635). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T02:52:24Z. --- 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`.
JAEdotUK commented 2026-11-26 14:01:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by JAEdotUK on 2026-11-26T13:10:06Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7192967073 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7192967073). Originally posted by [JAEdotUK](https://github.com/JAEdotUK) on 2026-11-26T13:10:06Z. --- 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.
andrewpozdnakov7-jpg commented 2026-11-26 14:01:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T13:16:30Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193113420 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7193113420). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T13:16:30Z. --- 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.
andrewpozdnakov7-jpg commented 2026-11-26 14:01:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T13:23:10Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193277257 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7193277257). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T13:23:10Z. --- 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.
ColorMeBoom commented 2026-11-26 19:12:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-26T19:12:13Z.


RDNA1 hardware verification — RX 5700 XT (Navi 10), driver 32.0.21045.29003, Windows 11 26200. Synthetic tests only, no game data.

  • Head 3a4ee54: wave_prefix_tests 5/5 pass on the RX 5700 XT (Wave32, native Wave64, PS 4×4); WARP passes PS and skips Wave32/64 (wave range 4..=4).
  • Control: lower.rs from main 63bcca4, PR tests kept: 4 of 5 fail on the RX 5700 XT. Wave32 exclusive [nan_lanes_9_20] lane 9 = NaN (want −3.75); Wave32 inclusive [pos_inf_lane_11] lane 11 = NaN (want +inf); Wave64 exclusive same as Wave32; PS exclusive [nan_lane_0] lane 0 = NaN (want 0). The u32 test passes.

#1172 reproduces on RDNA1 on main, and this PR fixes it there.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7201307612 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1408#issuecomment-7201307612). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-26T19:12:13Z. --- **RDNA1 hardware verification** — RX 5700 XT (Navi 10), driver 32.0.21045.29003, Windows 11 26200. Synthetic tests only, no game data. - Head `3a4ee54`: `wave_prefix_tests` 5/5 pass on the RX 5700 XT (Wave32, native Wave64, PS 4×4); WARP passes PS and skips Wave32/64 (wave range 4..=4). - Control: `lower.rs` from main `63bcca4`, PR tests kept: 4 of 5 fail on the RX 5700 XT. Wave32 exclusive `[nan_lanes_9_20]` lane 9 = NaN (want −3.75); Wave32 inclusive `[pos_inf_lane_11]` lane 11 = NaN (want +inf); Wave64 exclusive same as Wave32; PS exclusive `[nan_lane_0]` lane 0 = NaN (want 0). The u32 test passes. #1172 reproduces on RDNA1 on main, and this PR fixes it there. AI use: Claude Code (Claude Opus 5.5).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1408:upstream-pr/1408'
git switch 'upstream-pr/1408'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1408'
git switch 'upstream-pr/1408'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1408'
git switch 'upstream-pr/1408'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1408'
git switch 'main'
git merge --squash 'upstream-pr/1408'
git switch 'main'
git merge --ff-only 'upstream-pr/1408'
git switch 'main'
git merge 'upstream-pr/1408'
git push origin 'main'
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!1407
No description provided.