shader: accept an inverted VCC as a mesh lane mask before SAVEEXEC (Part of #3703) #3708

Manually merged
github merged 2 commits from github-bot/gh-3706 into main 2026-12-01 08:47:19 +00:00 AGit
Owner

@⁠mumba17 on GitHub · 2026-12-01 06:55 UTC · original
mumba17:shader/mesh-not-vcc-region → main · +55 −2 · 2 files · 2 commits · merged 2026-12-01 08:45 UTC

Part of #3705 (item 5). Refs #3643, #2413.

Problem

Slot 86 mesh programs open an "if not VCC" region like this:

v_cmp_*            vcc, ...
s_xor_b64          s[20:21], vcc, -1
s_and_saveexec_b64 sD, s[20:21]
s_cbranch_execz    ...

The mesh frontend's mask-complement path (s_not_b64 / s_xor_b64 sD, sS, -1) only took an even SGPR pair as the source. With VCC as the source these programs stopped at unsupported mesh instruction or EXEC state: s_xor_b64. @⁠lukaslw-lab found this as the next refusal of the 6 idxen offen requests, once #3704, #3706 and #3707 are applied.

Change

src/gfx1013_direct_mesh.inl: the complement path now also accepts VCC (106) as the source. The lane bit comes from graphics_lane_mask, which already returns this lane's VCC bit. The wave words come from the VCC word slots, the same ones the SAVEEXEC narrowing reads. Inactive lanes come out set, as they do on the GPU, and the AND with EXEC in the following SAVEEXEC drops them. Everything else is unchanged: the result is an ordinary lane-mask pair, so the existing in-skip and top-level SAVEEXEC paths take it as their mask. vcc_hi, and any second operand other than -1, still refuse.

Tests

tests/native_direct_mesh_check.py:

  • Positives.
    • saveexec-not-vcc (if/else inside a lane skip): the branch takes xor(vcc bit, 1), the then arm gives 2, the else arm 3.
    • saveexec-paired-not-vcc: paired-EXECZ form.
    • saveexec-if-not-vcc: the if-only form. Untaken lanes keep the old v1.
  • Refusals. saveexec-not-vcc-hi (s_xor_b64 s[24:25], vcc_hi, -1) and saveexec-xor-vcc-one (vcc ^ 1). Both still stop at unsupported mesh instruction or EXEC state: s_xor_b64.
  • Mutation. With the source change reverted, native_direct_mesh fails at saveexec-not-vcc with that same refusal.
  • Regression. ctest -R "native_|mesh|gfx1013" -E "hardware|_warp": 605/605 pass.

Environment: Windows 11 build 26300, RTX 3090, MSVC 14.44, DXC from SDK 10.0.26100, main 1c634037.

Not measured: how far the 6 title requests get past this point. I couldn't do a native Mesh86 capture run on this host today. @⁠lukaslw-lab, could you rerun your reach probe with this on top of #3704/#3704/#3705? I'll post the counts here if I get a run first.

AI-assisted.

🤖 Generated with Claude Code

**@⁠mumba17** on GitHub · 2026-12-01 06:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3706) `mumba17:shader/mesh-not-vcc-region` → `main` · +55 −2 · 2 files · 2 commits · merged 2026-12-01 08:45 UTC Part of #3705 (item 5). Refs #3643, #2413. ## Problem Slot 86 mesh programs open an "if not VCC" region like this: ``` v_cmp_* vcc, ... s_xor_b64 s[20:21], vcc, -1 s_and_saveexec_b64 sD, s[20:21] s_cbranch_execz ... ``` The mesh frontend's mask-complement path (`s_not_b64` / `s_xor_b64 sD, sS, -1`) only took an even SGPR pair as the source. With VCC as the source these programs stopped at `unsupported mesh instruction or EXEC state: s_xor_b64`. @⁠lukaslw-lab found this as the next refusal of the 6 `idxen offen` requests, once #3704, #3706 and #3707 are applied. ## Change `src/gfx1013_direct_mesh.inl`: the complement path now also accepts VCC (106) as the source. The lane bit comes from `graphics_lane_mask`, which already returns this lane's VCC bit. The wave words come from the VCC word slots, the same ones the SAVEEXEC narrowing reads. Inactive lanes come out set, as they do on the GPU, and the AND with EXEC in the following SAVEEXEC drops them. Everything else is unchanged: the result is an ordinary lane-mask pair, so the existing in-skip and top-level SAVEEXEC paths take it as their mask. `vcc_hi`, and any second operand other than -1, still refuse. ## Tests `tests/native_direct_mesh_check.py`: - **Positives.** - `saveexec-not-vcc` (if/else inside a lane skip): the branch takes `xor(vcc bit, 1)`, the then arm gives 2, the else arm 3. - `saveexec-paired-not-vcc`: paired-EXECZ form. - `saveexec-if-not-vcc`: the if-only form. Untaken lanes keep the old v1. - **Refusals.** `saveexec-not-vcc-hi` (`s_xor_b64 s[24:25], vcc_hi, -1`) and `saveexec-xor-vcc-one` (`vcc ^ 1`). Both still stop at `unsupported mesh instruction or EXEC state: s_xor_b64`. - **Mutation.** With the source change reverted, `native_direct_mesh` fails at `saveexec-not-vcc` with that same refusal. - **Regression.** `ctest -R "native_|mesh|gfx1013" -E "hardware|_warp"`: 605/605 pass. Environment: Windows 11 build 26300, RTX 3090, MSVC 14.44, DXC from SDK 10.0.26100, `main` `1c634037`. **Not measured:** how far the 6 title requests get past this point. I couldn't do a native Mesh86 capture run on this host today. @⁠lukaslw-lab, could you rerun your reach probe with this on top of #3704/#3704/#3705? I'll post the counts here if I get a run first. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The compiler opens an "if not VCC" region as s_xor_b64 sD, vcc, -1 followed
by s_and_saveexec_b64 and s_cbranch_execz. The mesh mask-complement path
only took an even SGPR pair, so these programs stopped at
"unsupported mesh instruction or EXEC state: s_xor_b64". VCC now feeds the
same path: its lane bit is inverted and its wave words come from the VCC
word slots. vcc_hi and any other xor operand still refuse.

Part of #3703 (item 5).

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

@⁠lukaslw-lab on GitHub · 2026-12-01 07:02 UTC · original · approved these changes

Reviewed 05301cf4 by reading the diff; not built or run.

Verdict: approve. The VCC source reuses the paths that already treat VCC as a mask, and anything outside the full complement still refuses. No MUST.

  • SHOULD No assertion observes the second change, the wave-word lookup at gfx1013_direct_mesh.inl:1438. If it still read 106+j, the words would be empty. The SAVEEXEC at :1609 would then narrow exec_value to empty and SCC would stay unset, without a refusal. The new cases check the lane-bit branch, which comes from graphics_lane_mask (gfx1013_direct_compute.inl:3628, read(106)). A case that reads the result's SCC (s_cbranch_scc0 right after the s_xor_b64), or asserts the xor ..., -1 of the VCC words in the IR, would cover it.
  • Checked, no finding:
    • The source condition admits only VCC (106) next to the even pairs. vcc_hi (107) is odd and still refuses, as saveexec-not-vcc-hi shows.
    • The lane bit is xor(read(106), 1), so inactive lanes come out set and the SAVEEXEC AND with the old EXEC drops them (:1617).
    • The words come from the same vcc_words slots that the SAVEEXEC (:1609) and the VCC branch (:1167) read.
    • The test words decode as intended: 0x8998c16a is s_xor_b64 s[24:25], vcc, -1, 0x8998c16b reads vcc_hi, 0x8998816a XORs with 1.

Tests:

  • saveexec-not-vcc and saveexec-paired-not-vcc prove the inverted compare selects the arms, in the in-skip and paired forms.
  • saveexec-if-not-vcc proves the if-only form keeps v1 for untaken lanes.
  • The two refusals pin the operand checks.

CI runs native_direct_mesh in the pr preset; it was still pending at this head.

I'll post the reach on the 6 requests separately, as asked.

**@⁠lukaslw-lab** on GitHub · 2026-12-01 07:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3706#pullrequestreview-6126544038) · **approved these changes** Reviewed `05301cf4` by reading the diff; not built or run. **Verdict: approve.** The VCC source reuses the paths that already treat VCC as a mask, and anything outside the full complement still refuses. No MUST. - **SHOULD** No assertion observes the second change, the wave-word lookup at `gfx1013_direct_mesh.inl:1438`. If it still read `106+j`, the words would be empty. The SAVEEXEC at `:1609` would then narrow `exec_value` to empty and SCC would stay unset, without a refusal. The new cases check the lane-bit branch, which comes from `graphics_lane_mask` (`gfx1013_direct_compute.inl:3628`, `read(106)`). A case that reads the result's SCC (`s_cbranch_scc0` right after the `s_xor_b64`), or asserts the `xor ..., -1` of the VCC words in the IR, would cover it. - Checked, no finding: - The source condition admits only VCC (106) next to the even pairs. `vcc_hi` (107) is odd and still refuses, as `saveexec-not-vcc-hi` shows. - The lane bit is `xor(read(106), 1)`, so inactive lanes come out set and the SAVEEXEC AND with the old EXEC drops them (`:1617`). - The words come from the same `vcc_words` slots that the SAVEEXEC (`:1609`) and the VCC branch (`:1167`) read. - The test words decode as intended: `0x8998c16a` is `s_xor_b64 s[24:25], vcc, -1`, `0x8998c16b` reads `vcc_hi`, `0x8998816a` XORs with 1. Tests: - `saveexec-not-vcc` and `saveexec-paired-not-vcc` prove the inverted compare selects the arms, in the in-skip and paired forms. - `saveexec-if-not-vcc` proves the if-only form keeps v1 for untaken lanes. - The two refusals pin the operand checks. CI runs `native_direct_mesh` in the `pr` preset; it was still pending at this head. I'll post the reach on the 6 requests separately, as asked.
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-01 07:05 UTC · original

Reach on the 24 slot 86 requests, offline (compile_dxil … gfx1013-container-ms-texture-heap), main 1c634037 + #3704 + #3706 + #3707 + this PR:

Requests Refusal
6 past the "if not VCC" open; now graphics register undefined on an incoming path: 274 / 276 / 278 (v18 / v20 / v22) at the first load in the new arm (buffer_load_dword v23, v18, … idxen). That VGPR is written under the earlier EXEC region that the s_mov_b64 exec, s[20:21] just before closes.
18 unchanged: the scalar loop (item 1, in progress on our side)

So item 5 does what it says for all 6. Their next wall looks like VGPR liveness across that EXEC restore, not the SAVEEXEC shape itself; I'll add it to #3705 as item 6.

**@⁠lukaslw-lab** on GitHub · 2026-12-01 07:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3706#issuecomment-7303639934) Reach on the 24 slot 86 requests, offline (`compile_dxil … gfx1013-container-ms-texture-heap`), `main` `1c634037` + #3704 + #3706 + #3707 + this PR: | Requests | Refusal | |---:|---| | 6 | past the "if not VCC" open; now `graphics register undefined on an incoming path: 274 / 276 / 278` (v18 / v20 / v22) at the first load in the new arm (`buffer_load_dword v23, v18, … idxen`). That VGPR is written under the earlier EXEC region that the `s_mov_b64 exec, s[20:21]` just before closes. | | 18 | unchanged: the scalar loop (item 1, in progress on our side) | So item 5 does what it says for all 6. Their next wall looks like VGPR liveness across that EXEC restore, not the SAVEEXEC shape itself; I'll add it to #3705 as item 6.
Review follow-up on #3706. not-vcc-scc reads SCC with s_cselect_b32 right
after s_xor_b64 sD, vcc, -1 on a wave-uniform compare, so the wave-word
lookup is observed: with the lookup reverted to 106+j, SCC is undefined and
the case fails. not-vcc-scc-per-lane keeps the per-lane compare refusing,
since VCC has no known wave words there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠mumba17 on GitHub · 2026-12-01 08:32 UTC · original

Thanks @⁠lukaslw-lab. SHOULD addressed in 0d5a8cb2. Your SHOULD found a real limit. VCC only gets wave words from a wave-uniform compare (gfx1013_direct_mesh.inl VOPC path). After a per-lane compare like 0 > v0, the complement's SCC stays unknown, so it refuses rather than doing anything wrong. The new cases pin both:

  • not-vcc-scc: s_movk_i32 s20, v_cmp_gt_u32_e64 vcc, s20, 0, s_xor_b64 s[24:25], vcc, -1, s_cselect_b32 s21, 1, 0, and s21 reaches the exported X. It asserts both xor …, -1 words, their or, and the SCC icmp ne.
  • not-vcc-scc-per-lane: the same with v_cmp_gt_u32 vcc, 0, v0. It still refuses with undefined on an incoming path: 128 at the s_cselect.
  • Mutation. I applied your mutation (lookup from 106+j). native_direct_mesh then fails at not-vcc-scc with +0x24: graphics register undefined on an incoming path: 128.

AI-assisted.

**@⁠mumba17** on GitHub · 2026-12-01 08:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3706#issuecomment-7305447295) Thanks @⁠lukaslw-lab. SHOULD addressed in `0d5a8cb2`. Your SHOULD found a real limit. VCC only gets wave words from a wave-uniform compare (`gfx1013_direct_mesh.inl` VOPC path). After a per-lane compare like `0 > v0`, the complement's SCC stays unknown, so it refuses rather than doing anything wrong. The new cases pin both: - **`not-vcc-scc`**: `s_movk_i32 s20`, `v_cmp_gt_u32_e64 vcc, s20, 0`, `s_xor_b64 s[24:25], vcc, -1`, `s_cselect_b32 s21, 1, 0`, and `s21` reaches the exported X. It asserts both `xor …, -1` words, their `or`, and the SCC `icmp ne`. - **`not-vcc-scc-per-lane`**: the same with `v_cmp_gt_u32 vcc, 0, v0`. It still refuses with `undefined on an incoming path: 128` at the `s_cselect`. - **Mutation.** I applied your mutation (lookup from `106+j`). `native_direct_mesh` then fails at `not-vcc-scc` with `+0x24: graphics register undefined on an incoming path: 128`. AI-assisted.
github manually merged commit bfe089f599 into main 2026-12-01 08:47:19 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-01 08:43 UTC · original · approved these changes

Reviewed inverted VCC tracking and the current SCC fixture. The integrated native_direct_mesh checks passed. The captured six-request reach check remains a separate runtime follow-up.

**@⁠R0Y00** on GitHub · 2026-12-01 08:43 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3706#pullrequestreview-6127743076) · **approved these changes** Reviewed inverted VCC tracking and the current SCC fixture. The integrated native_direct_mesh checks passed. The captured six-request reach check remains a separate runtime follow-up.
This discussion has been locked. Commenting is limited to contributors.
No description provided.