shader: two lane-mask joins in loops (the 'program input' refusal, and an execz skip's edge): 28 compute shaders translate #304
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T10:30:46Z.
Refs #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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T10:43:50Z.
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:54:07Z.
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.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T12:38:39Z.
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.