Shaders: lower float wave prefix sums via lane reads #1408
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1408
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1408"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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 · openFixes #1172.
Summary
Op::AddFwave prefix sums (inclusiveandexclusive) viawaveActiveBallot+ pointer-jumpingwaveReadLaneAt(Lower::float_prefix_sum) instead ofdx.op.wavePrefixOp.f32, keepingOp::AddUonwavePrefixOp.i32.wavePrefixOp.f32corrupts lanes whose own input term isNaN,±inf, or large enough (2^60) to round away earlier terms:id, remaining active lanes start from their active predecessor).Verification
NaN/+infcorruption on live AMD Radeon(TM) Graphics in both Wave32 and Wave64, then verifiedwave_prefix_tests(Wave32 plain + narrowedEXEC+ divergents_cbranch_execz, native Wave64 64-lane compute, and 4×4 pixel shader rasterization):dxil.dllvalidation + container hash check: passedcargo clippy --workspace --all-featuresandcargo xtask policy: passed.@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
cae2e003) and DXVK 3.1.1 DXGI. One GPU at a time (VK_LOADER_DRIVERS_SELECT).x86_64-pc-windows-gnullvm, Rust 1.98.1.dxil.dllfrom DXC 1.9.2609: every module valid.Results (
victory-shadertests,--test-threads=1)e7ef4e3,wave_prefixtestslower.rsfrommain(oldwavePrefixOp.f32)mainffe310e+ @rouges78'swave_prefix_tests.rs+ 2^60 and +infinity in lane 11What this means:
wavePrefixOp.f32is 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.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 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:
AI-assisted; synthetic tests only, no game files.
@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
mainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 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 --libpassed 125, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@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:
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 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(on63bcca43),Lower::float_prefix_sumhas moved tocrates/victory-shader/src/emit/lower/wave_prefix.rs. It is the same ballot plusreadLanepointer chain I reviewed before.wave_prefix_tests.rsnow usesHost::from_device(device), which matchesemit/host.rsonmain.emit/lower.rsstays under the 512 KiBMAX_FILE_SIZEinxtask/src/policy.rs. Integer prefix sums still go throughwavePrefixOp.i32.One small nit:
wave_prefix.rshas a stray blank line before the closing}of theimpl.rustfmtwould remove it.CI: passing (
check). Merges cleanly.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 04:37 UTC · original
Rebased onto
940d32f(8254052a) and updatedwave_prefix_sum_f32_pixel_quad_all_backendsto skip WARP when no SM 6.6 WARP adapter is available (requiringran > 0instead ofassert!(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 on GitHub · 2026-11-25 06:38 UTC · original
Retested the rebased head
8254052a(onmain940d32f) on AMD Radeon RX 7600 (RDNA3) + Windows 11 D3D12 SM 6.6 WARP:Environment
10.0.26340x64,rustc 1.98.1(x86_64-pc-windows-msvc)32.0.32029.2010,wave=32..=64) + D3D12 WARP (wave=4..=4)dxil.dll 1.8.2502.11Results on
8254052acargo test -p victory-shader --locked wave_prefix_tests -- --nocapture: 5 passed, 0 failedok: 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 WARPwave range 4..=4)cargo test -p victory-shader --locked: 252 passed, 0 failed, 3 ignoredcargo clippy -p victory-shader --all-targets --locked -- -D warnings: 0 warningscargo xtask policy:asset policy: 183 files okAI-assisted review/testing; all builds and GPU runs executed locally on my own machine. No game files used.
@fuzeofficlal on GitHub · 2026-11-26 02:52 UTC · original
Rebased onto
main(63bcca43) in3a4ee54c, updatedHost::from_device(device)inwave_prefix_tests.rs(fixing silent test-compilation breakage on currentmain), and movedfloat_prefix_sumintocrates/victory-shader/src/emit/lower/wave_prefix.rssoemit/lower.rsstays well under the 512 KiB policy limit (~520.7 KiB). Verifiedwave_prefix_tests+emit::lower::tests(38/38),clippy --all-targets, andxtask policy.@DenRakEiw on GitHub · 2026-11-24 17:57 UTC · original · approved these changes
Tested head
e7ef4e3(fast-forward onmainffe310e) 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 failedcargo clippy -p victory-shader --all-targets: 0 warningscargo 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).
@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
unaryBitsleading-zero counts per ballot word (wave32/64/128 all handled), then Hillis-Steeleread_lanerounds. The 988-linewave_prefix_tests.rspins 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).
@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: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 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.rsand module declaration on current upstream63bcca4, then on the exact head3a4ee54, with Agility 1.620.2, SDK DXIL validator 1.9.2609.5 andVICTORY_WARP=1. Both loaded app-local DLLs were verified.exact_quarters-4.5vs-1.5-18vs2-4.5vs-1.5The 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.dllbeside the test executable, use SM 6.6-capable Agility, setVICTORY_WARP=1, and runemit::wave_prefix_tests --nocapture --test-threads=1.AI-assisted with Codex.
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:23 UTC · original
I tested two follow-ups on the same WARP 1.0.22 setup.
masked_two60case still failed. For example, exclusive lane 9 read-2.25instead of-0.25in both widths.wavePrefixOp.f32for 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
ed634dfis on a branch combining this PR's3a4ee54and #2997'sa4484f5. 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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.