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

Merged
mumba17 merged 2 commits from upstream-pr/3706 into main 2026-12-01 08:45:11 +00:00
mumba17 commented 2026-12-01 06:55:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T06:55:52Z.


Part of #3703 (item 5). Refs #3641, #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 #3702, #3704 and #3705 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 #3702/#3704/#3705? I'll post the counts here if I get a run first.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5580699691 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3706). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T06:55:52Z. --- Part of #3703 (item 5). Refs #3641, #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 #3702, #3704 and #3705 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 #3702/#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)
lukaslw-lab commented 2026-12-01 07:02:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T07:02:45Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6126544038 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3706#pullrequestreview-6126544038). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T07:02:45Z. **Review:** APPROVED --- 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 commented 2026-12-01 07:05:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T07:05:47Z.


Reach on the 24 slot 86 requests, offline (compile_dxil … gfx1013-container-ms-texture-heap), main 1c634037 + #3702 + #3704 + #3705 + 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 #3703 as item 6.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7303639934 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3706#issuecomment-7303639934). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T07:05:47Z. --- Reach on the 24 slot 86 requests, offline (`compile_dxil … gfx1013-container-ms-texture-heap`), `main` `1c634037` + #3702 + #3704 + #3705 + 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 #3703 as item 6.
mumba17 commented 2026-12-01 08:32:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T08:32:10Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7305447295 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3706#issuecomment-7305447295). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T08:32:10Z. --- 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.
R0Y00 commented 2026-12-01 08:43:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T08:43:39Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6127743076 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3706#pullrequestreview-6127743076). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-01T08:43:39Z. **Review:** APPROVED --- 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.
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!3706
No description provided.