shader: lower lane-mask phis, post-loop ballots, and wave32 movk masks #541
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!541
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-537"
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?
@Sheffy007 on GitHub · 2026-11-28 01:32 UTC · original
Sheffy007:feat/lane-mask-phi-data→main· +1431 −34 · 5 files · 1 commits · openCloses #528
Refs #4, #258, #525
Problem
"a lane mask holding lanes elsewhere read as data: a program input"(93 shaders in the 28 November corpus, 32 in#521):Lower::mask_numbersearched onlyp.blocks[b].instsfor masks outsidest.active, so any lane-maskPhinode outside auniform_joinfailed with.ok_or(INPUT).false-resolved mask accumulators inst.active: whenLanes::joinresolved a loop-header mask phi toBool::FALSE(which holds only in lanes still looping, not in lanes that exited on earlier iterations), downstreams_oraccumulators (s_next = s_phi | vcc) enteredst.activeand were balloted inside the divergent loop instead of atOEND(refusing split wave64 withDIVERGENT_EXCHANGEor dropping earlier iterations' bits)."written by a scalar instruction of the other width"(5 shaders in#521): wave32s_movk_i32/s_cmovk_i32masks tracked inLanes::sopmissed the_b32suffix strip inLower::mask_number.Changes
crates/victory-shader/src/structure.rs(Lanes::exec_copies_at_joins):s_mov, three-XOR swaps, constant-lane VGPR spills) on bothEXECand candidate SGPR pairs and solves coinductively across joins so loop-headerEXECshadows restored vias_mov exec, sor nested loops enterst.active.1-bits from back-edgeBool::FALSE-resolved loop joins out ofst.active.crates/victory-shader/src/emit/lower.rs:unchanged_mask_pair: evaluates phi webs whose live edges copy a single strictly-dominating mask pair directly to that pair's dwords (including inside divergent loops).phi_mask_number&post_loop_inst_ballot: ballots wave-converged mask phis and post-loop inactive-preserving loop masks (s_or/s_xor/s_andn2with active-subset masks, including multi-exit linear chains) viawide_ballotat the wave-converged join, refusing joins where skipped arms or back-edges alter inactive lanes' bits as"a lane mask holding lanes elsewhere read as data: a divergent join".loop_local_mask_phi(fill_phis): lowers single-preheader, single-latch loop mask accumulators whose scalar values never escape the natural loop (except pureEXECrestores).s_movk_i32/s_cmovk_i32: lowers inmask_number(restrictingMaskData::Hostto0and-1).docs/native-host.md: documents the new shapes and refusal boundary.Verification
cargo xtask policycargo clippy -p victory-shader --all-targets --locked -- -D warningscargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warningscargo clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-gnullvm -- -D warningscargo test -p victory-shader(mask_tests::lane_mask_phis_and_post_loop_ballots_lower_and_reject_unsound_divergent_joins)cargo test -p victory-gpu lane_mask_phis_post_loop_ballots_and_wave32_movk_masks_run_on_the_gpu(128-thread split-wave64 fast path + wave32flag=0,1)git merge-tree --write-treeclean against all open shader PRs (#433,#464,#512,#516,#523)cc @Olima34
@Olima34 on GitHub · 2026-11-28 03:52 UTC · original · requested changes
Thanks @Sheffy007. This goes after one of the biggest refusal families we see, and the coinductive solve for loop-header EXEC shadows reads right to us. We swept
a43bea1aover our boot corpora by output fingerprint (victory-shader'ssweepexample,-j 4, 120 s per shader), against main ata6a58361. There's been no translator change on main since. One thing needs fixing before it can merge.Translation now times out on 28 compute shaders that main refuses quickly. In both corpora the tool stops them at its 120 s limit (
timeout: no result after 120 s):On main the A six were refused as "a lane-mask join of an untracked mask: a value the translation could not make" (3) or "…: data, at a join of several edges" (3). The 22 on B are all refused on main. Hashes: compute_064fdbe47a08a167, compute_09d594eb56c883c0, compute_11de67113e9eaaa0, compute_699291be9cef22ca, compute_786d6c676336f9ac, compute_e17e4da18a87461b (in both), plus compute_0fce298841f3b454, compute_14f5f388b65f9c2e, compute_15e5a72f41e40d8d, compute_17a4df8a5021087d, compute_1a9863eef9ac19fb, compute_1cdd0fa84d75a465, compute_2085b1b9df027b27, compute_216c04a7da821cca, compute_2588e499202c1588, compute_32fc68148d1bfb7f, compute_75ebd268f5a453d1, compute_870e3d265b593b4b, compute_9155c0be0cbc67fd, compute_9b9cfe1d5814f0fb, compute_c3a6e19d9b92885f, compute_cf6f7b3ef1905eff.
In a game run, a shader that takes minutes to translate holds a pipeline-compile thread. It also holds up the frame that needs it, so the title's 30 s watchdog would fire before it gets refused. We haven't profiled which part loops. The new fixed points (the
candsretain loop and theexited_falsepropagation inexec_copies_at_joins) and the phi-web walks inunchanged_mask_pair/phi_mask_numberlook like the places to bound. A step limit that refuses ("… too many steps") would be fine; so would a cache, if the walks repeat work. A test that one of these shapes finishes quickly would pin it.Also worth confirming when you update: the 13 + 6 changed outputs are all compute. We read them as programs that go through the new phi or post-loop ballot path instead of the old lowering; if that's right, a line in the PR saying so is enough. The 159 that now say "a divergent join" instead of "a program input" match your description.
The world corpus (21,600 shaders) sweep is still running; we'll add its numbers here when it finishes. CI is green on this head. No game run on our side.
@alexballvideos-netizen on GitHub · 2026-11-28 04:56 UTC · original
Swept #541 (head
a43bea1a, merged onto main61f55a49) over a 21,579-shader world corpus (Series X, 1.0.2.1) withexamples/sweep -j 4(120 s per-shader limit), on an M3 Max.Compile-time regression: 33 compute shaders hit the 120 s limit. All 33 are refused on main within 2.4–4.6 s, 28 of them for "a lane-mask join of an untracked mask: data, at a join of several edges", 3 for "… a value the translation could not make" and 2 for "… a program input".
I reran 4 of them with a 15-minute limit. They don't hang: they finish, but take 40–50× as long, and end in the same refusal at the same address as on main:
compute_064fdbe47a08a167compute_09d594eb56c883c0compute_0fce298841f3b454compute_11de67113e9eaaa0(4 at a time; peak memory 525 MB.) These are large programs, with the refusal 80–130 KB into the code, so my guess is that the new fixed-point solve over joins in
Lanes::exec_copies_at_joinsgrows much faster than linearly with block count on them. In game, that would stall pipeline creation for minutes for nothing, since they're refused anyway. Maybe an iteration cap, or bailing out early once a join is already untranslatable, would fix it?All 33: compute_064fdbe47a08a167 compute_09d594eb56c883c0 compute_0fce298841f3b454 compute_11de67113e9eaaa0 compute_14f5f388b65f9c2e compute_15e5a72f41e40d8d compute_17a4df8a5021087d compute_1cdd0fa84d75a465 compute_2085b1b9df027b27 compute_216c04a7da821cca compute_32fc68148d1bfb7f compute_4a21d2a690e7db0a compute_56844698dd8fe19d compute_60997e6e9889a7d2 compute_699291be9cef22ca compute_75ebd268f5a453d1 compute_786d6c676336f9ac compute_870e3d265b593b4b compute_9155c0be0cbc67fd compute_9b9cfe1d5814f0fb compute_9dfa5e1db805f2fb compute_a562d1df29fe914e compute_ad5eae8c99a89f95 compute_c1966eda2faae302 compute_c3a6e19d9b92885f compute_cf6f7b3ef1905eff compute_d7360989b053cee0 compute_df8cffc3cf672be5 compute_e17e4da18a87461b compute_f016b01dc08e831c compute_f9a80955fd1cb648 compute_fb8d942443fe0592 compute_fd4b08d1534e1ec0
I can rerun any of them or time a fix.
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.