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

Merged
mumba17 merged 1 commit from upstream-pr/3946 into main 2026-12-03 16:26:47 +00:00
mumba17 commented 2026-12-03 16:15:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-03T16:15:00Z.


Part of #3703 (row R1, v_readfirstlane_b32; claim: https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7384414865).

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 #3922: the 99 still stop there with #3922 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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5630338152 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3946). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-03T16:15:00Z. --- Part of #3703 (row R1, `v_readfirstlane_b32`; claim: https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7384414865). ## 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 #3922: the 99 still stop there with #3922 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)
R0Y00 commented 2026-12-03 16:22:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T16:22:07Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6173822680 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3946#pullrequestreview-6173822680). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T16:22:07Z. **Review:** APPROVED --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3946
No description provided.