shader-compiler: portable Wave64 ballot, vote & exec lowering for non-64-wide GPUs (#151) #201
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/brcly--TuxBox!201
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-201"
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?
@Vladimir-Human on GitHub · 2026-11-25 21:33 UTC · original
Vladimir-Human:xshader/portable-wave64-ballot→main· +3514 −51 · 18 files · 2 commits · openSummary
AI-assisted implementation towards #151 adding portable Wave64 ballot, vote, and first-lane lowering in
tools/shader-compiler(hlsl::portable_wave64) so console Wave64 compute shaders using subgroup ballots/votes (WaveActiveBallot,WaveActiveAnyTrue,WaveActiveAllTrue,WaveReadLaneFirst, scalar-mask logic/s_mov_b64/s_cmov_b64/s_cselect_b64/s_*_wrexec_b64/s_*_saveexec_b64, 64-bitBallot64propagation intoexec/vcc/scc) run reliably across non-64-wide host GPUs (e.g., Wave32-only GPUs where nativeWaveActiveBallot()only covers 32 lanes), without requiring[WaveSize(64)].Whenever a shader uses constructs that cannot be statically proven safe to rewrite (divergent control flow across votes, multi-wave wave-varying barriers without uniform provenance, non-multiple-of-64 groups, unhandled 32-bit
ExecLo/VccLoors_wqm/SDWA/exec_snapshotsconsumers), the pass cleanly declines lowering and preserves existing behavior.Highlights
uniformity.rs): Tracks group-uniform values (including VOP3v_readfirstlane_b32scalar destinations), hoists provably group-uniform subgroup votes out of convergent regions when needed, and verifies barrier/control-flow convergence across[64*N, 1, 1]and multi-dimensional workgroups (e.g.,[8,8,1],[4,4,4]).masks.rs): Distinguishes 64-bitBallot64lane-mask registers from raw 64-bit masks andOpnd::Null, supports scalar/mask logic promotion (s_and/s_or/s_xor/s_andn2/s_nand/s_nor/s_xnor/s_orn1/s_orn2),s_cmov_b64,s_cselect_b64,s_*_wrexec_b64,s_*_saveexec_b64, and separates-1(all-64-ones) from0xffff_ffffliterals.emit.rs): Emitsgroupshareduint2per-wave ballot scratch (wave_id = gindex >> 6,(lane & 63u)) with EXEC-masked accumulation and barriers strictly isolated to proven convergent sites. Zero changes toruntime/d3d12.git merge-treeagainst bothorigin/mainand PR #185.Verification (
079143b16)python -m unittest discover -s tests -p "test_repository_hygiene.py" -v: 4/4 passed (all new/modified.rsmodules well under limit).cargo test --manifest-path tools/shader-compiler/Cargo.toml: 334 unit + 2 integration passed (0 warnings).cargo test --manifest-path runtime/d3d12/Cargo.toml -- --test-threads=1: 134/134 passed.python build.py lanes+lanes.exe --adapter 10de:2783 --selftest all: 15/15 passed.10de:2783,wave_min=32 wave_max=32, DXCcs_6_0&cs_6_6-WX, D3D12 Debug Layer):139,520/139,520words bit-exact) + independent 64/64 adversarial multi-group ([64,1,1],[128,1,1],[8,8,1],[4,4,4]) & 15/15 convergence repro suite,debug_errors=0 debug_warnings=0.Refs #151.
Co-Authored-By: AI Assistant
- F1: avoid ul clobber by hi(Null) on PostAnyTrue(Null) 64-bit logic votes via dedicated w64_null{idx} register. - F2: extract per-lane bit when writing Ballot64 results into xec/cc via s_mov_b64, s_cmov_b64, s_cselect_b64, or 64-bit logic ops. - F3: support s_*_wrexec_b64 and s_{nor,xnor,orn1}_saveexec_b64 alongside saveexec_b64. - F4: treat Literal(u32::MAX) as zero-extended low-32 mask (not 64-bit -1), promoting to Ballot64 for exact (0xffffffffu, 0u) compares/logic. - F5: promote s_<logic>_b64 combining xec/cc with scalar SGPR pairs or non-mask constants so xec/cc is balloted before bitwise logic. - F6: preserve s_cmov_b64 mask/ballot provenance, mark s_wqm_b64/SDWA _cmp_*/xec_snapshots destinations as unpromotable Mask, and guard is_ballot_word_mov against SDWA/modifiers. - F7: refuse unhandled 32-bit/non-lowered xec/cc reads (s_wqm_b32, s_bcnt1_i32_b32, etc.) instead of falling through to native Wave* intrinsics or 1-bit flags. - F8: decode VOP3 _readfirstlane_b32 scalar dst ( aw[0] & 127, 125 => Null) in both uniformity analysis and emission so multi-wave dependent barriers hoist properly.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.