Shaders: retry barrier-free all-lane forms on native wave64 hosts #558
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/fxceless--victory-fork!558
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-558"
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?
@tulerws on GitHub · 2026-11-25 02:14 UTC · original
tulerws:fix/wave64-needs-every-lane→main· +212 −11 · 3 files · 1 commits · openProblem
On native wave64 hosts (
HOST_MAX_WAVE != 32, e.g. AMD RDNA 3/4), compute shaders that hit aneeds_every_lanerefusal (a wave sum of 16-bit floats where not every lane runsinLower::half_sum, ora lane mask holding lanes elsewhere read as datainLower::mask_dword) fail immediately:Lower::half_sumonly recordedneed(self.cur_ir)whenhalves == true(two-wave32 emulation), skipping native wave64.Lower::mask_dwordonly consideredwhole/need(...)whenself.exchange.is_some(), even though a native wave64 compute shader withthreads % 64 == 0already has all 64 lanes present in everyall_lane_blocksblock.emit::emit()gated its early-out/skip/widen retry path onlower::host_max_wave() == 32, even thoughwiden()already allows native wave64 (!(native.wave64 && lower::host_max_wave() == 32)) and none of these forms adds group barriers on native wave64.As a result,
b22a16a178976e1btranslated cleanly on wave32 hosts (without early-outs) while failing on native wave64 hosts, and926c46bab3b86bd6failed on both.Fix
crates/victory-shader/src/emit/lower.rs:need(self.cur_ir)inhalf_sumon native wave64 as well as wave32 halves.mask_dword, treatall_lane_blocksas whole-wave when lowering native wave64 compute shaders whose thread-group size is a multiple of 64, and recordneed(made)when a mask holding lanes outsideEXECsits in a per-lane region.crates/victory-shader/src/emit/mod.rs:emit_programfails on a native wave64 compute shader withlower::needs_every_lane(what), retrywithout_early_outs,without_skips(false),without_skips(true)(respectingVICTORY_WAVE_DEEP_SKIPS), andwiden()(respectingVICTORY_WAVE_WIDE, no group barriers added).crates/victory-shader/src/emit/wave64_tests.rs:TEST_HOST_WAVE = Some(64)):native_wave64_half_sum_inside_early_out_translates_and_runs_exactnative_wave64_mask_outside_exec_inside_branch_translates_and_runs_exactVerification
cargo test -p victory-shaderon AMD Radeon RX 9070 (RDNA 4): 216 passed, 0 failed (both new tests validated withdxil.dlland executed on hardware GPU).cargo clippy -p victory-shader --all-targets -- -D warnings: pass (0 warnings).cargo xtask policy: pass (169 files ok).VICTORY_HOST_MAX_WAVE=64):a wave sum of 16-bit floats where not every lane runs: 2 → 0 (b22a16a178976e1bvalidates withdxil.dlland creates D3D12 pipeline).a lane mask holding lanes elsewhere read as data: 2 → 0 (926c46bab3b86bd6widens 14 branches with 0 barriers, validates withdxil.dll, and creates D3D12 pipeline).Overlap note
half_sumprograms on native wave64 viahalf_sum_present(without widening early-outs). Themask_dwordwhole-wave fix (926c46bab3b86bd6) and the general native-wave64needs_every_laneretry path inemit/mod.rsare not covered by #203 or other open PRs. Happy to rebase/drop thehalf_sumone-liner if #203 merges first.AI-assisted (Antigravity); verified locally on AMD Radeon RX 9070. Hashes, counts, and clean-room tests only; no game data.
@avt0m4t48 on GitHub · 2026-11-25 02:21 UTC · original
I ran an independent synthetic translation check at base
c96b4f2b8365bf43d54ab074940923ef8267f4c6and head973101f230a1ec7ad416270c859f296529ffaed7, with the host wave size forced to 64.dx.op.barriercalls in the selected modules' DXIL census. The half sum succeeded after removing the early-out, and both popcounts required one widened branch.VICTORY_WAVE_WIDE=0, both popcounts returned to the original refusal and the guarded half-sum output stayed byte-identical. Both revisions kept the 96-thread partial-wave refusals. The unguarded native-wave64 sum and the guarded wave32-host control produced byte-identical DXIL across revisions. The wave32-host control emitted three barriers.cargo check --target x86_64-pc-windows-msvc -p victory-shader --testsfrom Linux. The independent probe checked translation and emitted instructions. GPU readback and DXIL validator execution remain unverified in this run.For reproduction, use the synthetic compute setup in
wave64_tests.rs::native_ofand forceTEST_HOST_WAVEto 64. In the guarded half-sum fixture, replace the six words that construct the lane's term with7e0e02ff 00003e00(a constant f16 1.5). In the mask fixture change the skip tobf840005(s_cbranch_scc0), keeping the body and EXEC restore. Use 64 and 128 threads for the mask, and 96 threads for each partial-wave control. SetVICTORY_SHADER_CENSUS=1and inspect thebarriercount fromcensus::takefor the selected DXIL.@HAL9000RELOADED on GitHub · 2026-11-25 08:08 UTC · original
A run on a native wave64 card, to go with the synthetic check above (which forced the host wave size to 64).
Setup: Radeon RX 7900 XTX (RDNA3, waves of 32 to 64 lanes), Adrenalin 32.0.32015.7029, i7-13700KF, Windows 10 Pro 22H2 (19045), Rust 1.98.1. Windows 10's in-box D3D12 stops at SM 6.5, so the tree also carries the D3D12 Agility SDK 1.620 (the same approach as #69). The DXIL validator comes from SDK 10.0.26100 (
VICTORY_DXIL). WARP stays below SM 6.6 on this machine, so the GPU cases ran on the card only. No game data used.Base:
mainc96b4f2plus the Agility patch and the stack-headroom test fix from Marvisak/VIctory#742. The PR head973101fwas merged on top of it. "Base + tests" means the base with only this PR'swave64_tests.rs.native_wave64_half_sum_inside_early_out_translates_and_runs_exactUnsupported { offset: 132, what: "a wave sum of 16-bit floats where not every lane runs" }native_wave64_mask_outside_exec_inside_branch_translates_and_runs_exactUnsupported { offset: 36, what: "a lane mask holding lanes elsewhere read as data" }The whole workspace with this PR: 507 passed, 0 failed. The base gives 505 passed.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.