shader: lower a mesh CMPX region inside a SAVEEXEC then arm (Part of #3703) #3782
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3782"
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 R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T21:05:59Z.
Part of #3703. Covers 158 of the 215 programs the wall
mesh SAVEEXEC then arm depends on EXECstops in my census on the current stack.Shape
Inside a SAVEEXEC then arm, the compiler often narrows EXEC once more with a CMPX:
Each lane runs the work, then the region only if the compare holds. That is the if-only region
s_and_saveexec_b64 sX, cmpwould open, except that a CMPX leaves SCC alone. The then-arm scan refused the EXEC copy.Chain form (second commit): in an if-only SAVEEXEC arm the EXECZ may instead skip to the arm's end, leaving the copy unrestored. The rest of the arm is then the region, and the SAVEEXEC restore ends both. Regions chain the same way.
Change (
gfx1013_direct_mesh.inl)match_cmpx_childrecognizes the shape inside a then arm. The work between the copy and the CMPX must leave EXEC, the copied register and control flow alone. The EXECZ must land ons_mov_b64 exec, sXwith the same register, inside the arm.contains_child, so its lane masks are exact, as for a nesteds_and_saveexec_b64.comparison(), so every 32-bit VOPC compare is supported. The region's lane mask is the arm's lane mask AND the compare. It joins and restores through the existing nested SAVEEXEC path. SCC is clobbered after the join, as it is for a nested SAVEEXEC.Tests (
tests/native_direct_mesh_check.py)saveexec-cmpx-regionand-prefixcheck the whole chain:icmp ugt i32 3;then arm depends on EXEC): another restore register, no EXECZ, a prefix that writes the copy, a prefix branch, a VOPC without EXEC, and an EXECZ past the restore.v_cmpx_gt_u16is refused as unsupported.saveexec-cmpx-chainchecks the branch on the compare, the region's select and join, and that the join leaves the arm.-twicechecks a second copy andv_cmpx_ne_u32inside the region, with both joins in order at the arm's end.-elsekeeps the chain refused under an arm with an else arm.Validation (Windows 11, MSVC, Windows SDK 10.0.26100)
ctest --test-dir out/build/dev -R "native_direct_mesh|mesh": 210/210 (the twomesh_two_exitshardware tests skip as usual).main+ #3708 + #3709 + #3710 + #3729 + #3760 + #3765 + #3770 + this: 975 of 1,569 translate, up from 845. 130 gained, none lost. Of the 215:unproven mesh mask operand(a mask built withs_cselect_b64 sN, exec, 0);v_min_f32;v_cvt_f16_f32;mesh scalar branch crosses a nested SAVEEXEC region;s_and_b64 vcc, exec, sN+s_cbranch_vccnzuniform branches, not in scope here.AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T21:34:12Z.
Pushed
d1c76a61: the chain form. In an if-only SAVEEXEC arm the EXECZ after the CMPX may skip to the arm's end, so the rest of the arm is the region and the SAVEEXEC restore ends both.It is accepted only without an else arm, since the inverse would otherwise read the narrowed EXEC. The description has the tests and mutations.
Census on the stack: 975 of 1,569 (was 924 at
7e997a37), none lost. Only the 57s_cbranch_vccnzuniform branches still stop at this wall.ctest -R "native_direct_mesh|mesh": 210/210.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T02:29:06Z.
Review: APPROVED
Reviewed
d1c76a61by reading the diff; not built or run.Verdict: approve. The region reuses the nested SAVEEXEC diamond: the copy is lowered by the existing
s_mov_b64 sX, execpath, the CMPX checks that the copy is still the arm's EXEC (saved_exec.at(start), same lane), and the branch and lane mask (arm AND compare) match the nesteds_and_saveexec_b64case. No MUST.then_writesloop and the SCC entry inscalar_clobbers(gfx1013_direct_mesh.inl:1816,:1818) are what keep this correct. Dropping either one passes every new case, because the regions write onlyv1. Two refusals would pin them:s_mov_b32 s30, 1in the region, then a read ofs30after the restore;s_cmpin the region, thens_cselect_b32after the restore.!shape.else_begin), so the inverse never reads the narrowed EXEC. The second visit of the join address is backed by theoutlives its enclosing armrefusal.writes_savedand in the region at the arm close. A nested SAVEEXEC in the prefix fails the match and stays atdepends on EXEC.then_writes, so after the outer join a chain copy that was never restored reads as unbound, not as a stale lane mask.Tests: the 14 new
native_direct_meshcases check the IR order. The branch takes the compare, the region's select usesarm AND compare, and both joins come in order for the region and the chain forms. The refusals cover each match condition. These are IR checks only; no draw runs a region. CI rannative_direct_meshin theprpreset at this head, green.