shader: two lane-mask joins in loops (the 'program input' refusal, and an execz skip's edge): 28 compute shaders translate #304
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!304
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-304"
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?
@Olima34 on GitHub · 2026-11-27 10:30 UTC · original
Olima34:fix/loop-exec-copy→main· +183 −6 · 5 files · 2 commits · merged 2026-11-27 12:38 UTCRefs #4, #258.
The misleading refusal. "a lane mask holding lanes elsewhere read as data: a program input" is not about a program input. In every case we have, it is a structurized loop's "lanes still looping" register:
s_andn2_b64 s, s, execat the head (its SCC asks whether any lane loops on);s_andn2_wrexec_b64 s, sat the back edge, which writes the same result to both the register and EXEC.Where the structuriser couldn't prove that every lane arriving at the head has its bit set, the head's SCC needed that join as a number. The join has no defining instruction, so
mask_numberread it as an input and refused. An outer loop whose lanes break out is what makes the arrivals unprovable.Fix. On every edge, that join takes EXEC's own incoming value: either a copy, or the same
_wrexecresult. It is therefore EXEC at the head.Lanes::exec_copies_at_joinsgives it EXEC's mask there and counts it as active, so a ballot at the head gives it. A join counts only if every edge's argument is provably EXEC's own incoming value on that edge (the same SSA value read by ans_mov, or written by the_wrexec).Test.
mask_tests::a_loop_register_that_is_exec_on_every_edge_is_exec_at_the_headuses a hand-assembled synthetic program of two nested loops of that shape, and fails without the fix. One loop, or no break, was already resolved.Where it shows. Lighting compute
9e5a12054881a74dis the only writer of a 1280x720 R11G11B10 target that the host never writes in the world ("draws 0 clears 0"), so the target keeps title memory, including Inf/NaN patterns (#258). With this fix that program passes this refusal and stops at its next one: a loop's break accumulator read back through copies ("a lane-mask join of an untracked mask: data whose high dword is not known"). We're on that next.Sweep, and a request. We dumped 4,129 refused containers at boot. All 15 "program input" refusals among them are such joins, and only the compute one changes outcome. Accepted shaders weren't in that corpus, so we can't check that their outputs stay unchanged. @Sandile-0511, could you run your fingerprint sweep on this branch?
Checks: victory-shader 331 and victory-gpu 316 tests pass. Windows clippy is clean with
-D warnings,cargo xtask policypasses, and there's a doc line indocs/native-host.md.shader: a loop register that is EXEC on every edge is EXEC at the head (the 'program input' lane-mask refusal)to shader: two lane-mask joins in loops (the 'program input' refusal, and an execz skip's edge): 28 compute shaders translateAfter a loop that an EXEC skip can jump over, an SGPR holds the loop's mask on one edge and leftover data on the skip's (in the title's programs, descriptor dwords whose high one has no value), and is read only ANDed with EXEC. On the skip's edge that EXEC is the one the skip found empty (s_cbranch_execz, which lockstep rewrites as s_cmp_eq_u64 exec, 0 and s_cbranch_scc1), so the AND keeps no lane whatever the SGPR holds there. Two gaps made it a refusal ("a lane-mask join of an untracked mask: data whose high dword is not known"): - unneeded_edges asked the lane algebra whether the edge's lanes meet EXEC, which it could not prove in these loops; the execz edge itself now says EXEC is empty there. - A join lockstep takes as a number asked for the edge's dwords before checking whether the edge was needed at all. Both are exact: an AND, NAND or ORN2 with an empty EXEC does not depend on its other operand, and an unneeded edge takes any value. Measured offline on the 4,129 refused containers of a boot run (Series S): with this and the previous commit, 28 compute programs translate, among them 9e5a12054881a74d, the only writer of a 1280x720 R11G11B10 target the world's lighting reads (#258), and 2fcb1ef0e54c7df4, another HDR writer; 2 more stop at a later refusal; nothing else changes. Metal made the compute pipelines of 21 of the 28 (not run); the host refused the other 7 as "needs view addresses or write marks". Test: gfx_refusal_tests::a_join_read_only_with_exec_needs_nothing_from_ an_exec_skip (hand-assembled, translated in lockstep): refused before.@Olima34 on GitHub · 2026-11-27 10:43 UTC · original
Second commit (
78cd3fed): the next refusal of9e5a12054881a74d, at 0x76c, "a lane-mask join of an untracked mask: data whose high dword is not known".What the refusal was. It looked like the loop's break accumulator, but it is a join where one edge is an
execzskip over the outer loop. On that edge the register still holds data, descriptor dwords with an unknown high half. Its only read iss_and_b64 s40, s50, exec, and on that edge EXEC is empty: it is exactly what theexecztested. So the edge's value is never needed. Two gaps let it through:unneeded_edgesdidn't see that a takenexeczedge (lowered ass_cmp_eq_u64 exec, 0/s_cbranch_scc1) brings an empty EXEC to a join read only together with EXEC.Both are now handled exactly: such an edge needs nothing, and an unneeded edge accepts any value, as a number too.
Test.
gfx_refusal_tests::a_join_read_only_with_exec_needs_nothing_from_an_exec_skip, a synthetic program, fails without the change. Av_readlanein the skipped arm forces lockstep, so the join is uniform and the skip is thes_cmp_eq_u64 exec, 0form.Sweep over the 4,129 refused containers dumped at boot, with both commits: 28 compute shaders now translate, 2 move on to a later refusal, and nothing else changes, pixel shaders included. The 28 include:
9e5a12054881a74d, the R11G11B10 writer;2fcb1ef0e54c7df4, which writes a 1280x720 fmt 26 HDR target;113a4779d954d6d2,a81f1b5bb0d7ba01anddd1d8e07445421e6, candidate writers of the cullers' 640x360 inputs.Metal, pipeline creation only (no dispatch): 21 of the 28 compute pipelines are created with no error, including all five above. The other 7 are refused by the host with "needs view addresses or write marks" (an existing host refusal, not a Metal error):
00bc6a9b,fcd8ef10,c3873dc0,a2d0209f,550d92da,48828947and0c748826.Checks: victory-shader 332 and victory-gpu 316 tests pass. Windows clippy is clean with
-D warnings,cargo xtask policypasses, anddocs/native-host.mdis updated. As with the first commit, the shaders that translate today weren't in our corpus, so a fingerprint sweep on a full corpus would still be welcome. We haven't measured it in game yet: our runs are paused.@LakshanSivakumar on GitHub · 2026-11-27 11:54 UTC · original
Thank you for the careful write-up and the numbers.
I ran every shader by output on
78cd3fed(33,625 containers, against mainc1b95875):So your 28 are confirmed and nothing is lost. But 50 compute shaders that already translate now give different output, and 8 of them are in my list of shaders the game binds in the world. I expect that is the reordered match arm (an unneeded edge now gives
falsewhere it gave the number). Please check a few of the 50 and say why the new output means the same.Before I merge I also need tests for what must stay refused: a join where one edge is not EXEC, an
execzskip whose taken edge is the non-empty one, and thes_cmp_eq_u32form in a wave64 program (that compares only the low half of EXEC; can it happen there?). A test that runs a loop on the GPU and checks the lanes' values would be better than "it translates".I have not run this in the game.
github-bot referenced this pull request2026-11-27 12:50:19 +00:00
@LakshanSivakumar on GitHub · 2026-11-27 12:38 UTC · original
Merged, with one commit of mine on top.
I checked the 50 shaders whose output changed: with the old order of the match arms all 50 are byte-identical to main, so the reordered arm is the only cause, and on an edge in
unneeded_edgesold and new give the same result (I traced four through the converter's output). All 28 gains are kept,ca62cc7380fe92dfamong them.The
s_cmp_eq_u32form was a real hole in wave64 programs (it compares only the low half of EXEC, and a test showed it was accepted). No shader in my dump hits it; the_u32compare now counts only in wave32 programs. I also added Metal value tests for both rules (lane values checked) and tests for what must stay refused: anexecnzbranch into the join, the wave64_u32form, and a loop register that is not EXEC on one edge.One gap is left and is not new: the skip rule looks at the low half of EXEC only, so a write to
exec_hialone between the skip and the AND would escape it. Not run in the game yet. Thank you @Olima34.