shader: use a uniform mesh mask proof inside a narrowed lane skip (Part of #3703) #3948

Manually merged
github merged 1 commit from github-bot/gh-3946 into gh-pr/3946/base 2026-12-03 16:45:00 +00:00 AGit
Owner

@⁠mumba17 on GitHub · 2026-12-03 16:15 UTC · original
mumba17:shader/mesh-readfirstlane-r1 → main · +21 −1 · 2 files · 1 commits · merged 2026-12-03 16:26 UTC

Part of #3705 (row R1, v_readfirstlane_b32; claim: #3705).

Problem

mask_uniform records that a lane mask has the same bit on every lane of a lane set: an EXEC-or-zero mask (s_cselect_b64 sN, exec, 0), a compare of uniform values, and their complements and ORs. v_cndmask_b32 on such a mask with uniform sources is then uniform on the active lanes, and a following v_readfirstlane_b32 reads it without a broadcast. The cndmask accepted the proof only when the current lane set was exactly the mask's (first==lane_active). When the select runs inside a per-lane CMPX skip nested under the mask's lanes, the proof was dropped. The read then needed the groupshared broadcast, which a per-lane skip cannot use, and was refused with unsupported mesh instruction or EXEC state: v_readfirstlane_b32.

Change

Use covered_by(lane_active, mask_uniform.at(bit).first), the check the SAVEEXEC, CMPX-parent and VCC-branch proofs on the same map already use. Every lane in a set narrowed from the mask's lanes has the mask's bit, so the select still picks one uniform source. Nothing else changes; a select on a per-lane mask is still refused inside the skip.

Tests (native_direct_mesh)

  • uniform-exec-mask-in-lane-skip: s_cselect_b64 s[30:31], exec, 0 under full EXEC, then a per-lane v_cmpx skip with s_cbranch_execz, and inside it v_cndmask_b32 v6, 0, 1, s[30:31] and v_readfirstlane_b32 s18, v6. It translates with no meshReadFirstLane slot and no barrier, and the read lowers to a select on the scalar condition.
  • varying-exec-mask-in-lane-skip: the same with the mask from a per-lane v_cmp_eq_u32 s[30:31], 0, v0. Still refused.
  • Mutation check: with the source change reverted, uniform-exec-mask-in-lane-skip fails with the v_readfirstlane_b32 refusal.

Census

Our native Mesh86 capture (RTX 3090, 600 s): 6,685 distinct .m86 programs, each run once through compile_dxil … gfx1013-container-ms-texture-heap.

  • main c6a0b036: 2,163 translate; 160 stop at v_readfirstlane_b32.
  • With this change: 2,163 translate, 0 lost. 99 of the 160 move on, all to v_cmpx_lt_u32 (that form is not the wide SAVEEXEC one in #3924: the 99 still stop there with #3924 stacked). No other program's first refusal changes.
  • The 61 left read, inside a per-lane skip, a value the frontend does not prove uniform (58: conversions, shifts, copies and selects on other masks), or stop in a loop body (3). Most need a broadcast that works inside a skip, a separate design this PR does not take.

Counts only; request bytes stay local.

Checks

Windows 11 build 26300, MSVC (VS Build Tools 14.44), SDK/DXC 10.0.26100. ctest --preset pr on this commit (rebased on main ac81f34e): 349/351 pass, native_direct_mesh included. The two local failures, native_compute_implicit_lod_controls and native_wave_virtual_derivative_controls, are the local SDK validator 1.7 vs DXIL 1.8 and fail on main too. The census was measured on c6a0b036 and not rerun after the rebase.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠mumba17** on GitHub · 2026-12-03 16:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3946) `mumba17:shader/mesh-readfirstlane-r1` → `main` · +21 −1 · 2 files · 1 commits · merged 2026-12-03 16:26 UTC Part of #3705 (row R1, `v_readfirstlane_b32`; claim: https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/3705). ## Problem `mask_uniform` records that a lane mask has the same bit on every lane of a lane set: an EXEC-or-zero mask (`s_cselect_b64 sN, exec, 0`), a compare of uniform values, and their complements and ORs. `v_cndmask_b32` on such a mask with uniform sources is then uniform on the active lanes, and a following `v_readfirstlane_b32` reads it without a broadcast. The cndmask accepted the proof only when the current lane set was *exactly* the mask's (`first==lane_active`). When the select runs inside a per-lane CMPX skip nested under the mask's lanes, the proof was dropped. The read then needed the groupshared broadcast, which a per-lane skip cannot use, and was refused with `unsupported mesh instruction or EXEC state: v_readfirstlane_b32`. ## Change Use `covered_by(lane_active, mask_uniform.at(bit).first)`, the check the SAVEEXEC, CMPX-parent and VCC-branch proofs on the same map already use. Every lane in a set narrowed from the mask's lanes has the mask's bit, so the select still picks one uniform source. Nothing else changes; a select on a per-lane mask is still refused inside the skip. ## Tests (`native_direct_mesh`) - `uniform-exec-mask-in-lane-skip`: `s_cselect_b64 s[30:31], exec, 0` under full EXEC, then a per-lane `v_cmpx` skip with `s_cbranch_execz`, and inside it `v_cndmask_b32 v6, 0, 1, s[30:31]` and `v_readfirstlane_b32 s18, v6`. It translates with no `meshReadFirstLane` slot and no barrier, and the read lowers to a select on the scalar condition. - `varying-exec-mask-in-lane-skip`: the same with the mask from a per-lane `v_cmp_eq_u32 s[30:31], 0, v0`. Still refused. - Mutation check: with the source change reverted, `uniform-exec-mask-in-lane-skip` fails with the `v_readfirstlane_b32` refusal. ## Census Our native Mesh86 capture (RTX 3090, 600 s): 6,685 distinct `.m86` programs, each run once through `compile_dxil … gfx1013-container-ms-texture-heap`. - `main` `c6a0b036`: 2,163 translate; 160 stop at `v_readfirstlane_b32`. - With this change: 2,163 translate, 0 lost. 99 of the 160 move on, all to `v_cmpx_lt_u32` (that form is not the wide SAVEEXEC one in #3924: the 99 still stop there with #3924 stacked). No other program's first refusal changes. - The 61 left read, inside a per-lane skip, a value the frontend does not prove uniform (58: conversions, shifts, copies and selects on other masks), or stop in a loop body (3). Most need a broadcast that works inside a skip, a separate design this PR does not take. Counts only; request bytes stay local. ## Checks Windows 11 build 26300, MSVC (VS Build Tools 14.44), SDK/DXC 10.0.26100. `ctest --preset pr` on this commit (rebased on `main` `ac81f34e`): 349/351 pass, `native_direct_mesh` included. The two local failures, `native_compute_implicit_lod_controls` and `native_wave_virtual_derivative_controls`, are the local SDK validator 1.7 vs DXIL 1.8 and fail on `main` too. The census was measured on `c6a0b036` and not rerun after the rebase. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
An EXEC-or-zero mask (s_cselect_b64 sN, exec, 0) or a compare of
uniform values gives every lane of its lane set the same bit. A
v_cndmask_b32 on that mask picked uniform sources only when the current
lane set was exactly the mask's, so the same select inside a nested
per-lane CMPX skip lost the proof and a following v_readfirstlane_b32
was refused. Use covered_by, as the SAVEEXEC and VCC-branch proofs do:
the proof holds on any lane set narrowed from the mask's lanes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 16:25:44 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 16:22 UTC · original · approved these changes

Reviewed ab63fb4f. The mask proof is inherited only along the existing lane-mask ancestry check and both selected values still require uniform proofs. A varying mask still refuses the in-skip readfirstlane. Independently rebuilt compile_dxil in MSVC Debug and ran ctest --test-dir out/build/review --no-tests=error -R '^native_direct_mesh$' --output-on-failure (1/1, no skips). Reverting the ancestry check to exact mask equality made uniform-exec-mask-in-lane-skip fail at +0x44 with the prior v_readfirstlane_b32 refusal. This is source-built compile and emitted-DXIL evidence.

**@⁠R0Y00** on GitHub · 2026-12-03 16:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3946#pullrequestreview-6173822680) · **approved these changes** Reviewed ab63fb4f. The mask proof is inherited only along the existing lane-mask ancestry check and both selected values still require uniform proofs. A varying mask still refuses the in-skip readfirstlane. Independently rebuilt compile_dxil in MSVC Debug and ran ctest --test-dir out/build/review --no-tests=error -R '^native_direct_mesh$' --output-on-failure (1/1, no skips). Reverting the ancestry check to exact mask equality made uniform-exec-mask-in-lane-skip fail at +0x44 with the prior v_readfirstlane_b32 refusal. This is source-built compile and emitted-DXIL evidence.
github-bot changed target branch from main to gh-pr/3946/base 2026-12-03 16:44:46 +00:00
github manually merged commit ab63fb4ffe into gh-pr/3946/base 2026-12-03 16:45:00 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.