shader: carry exact mesh lanes through nested CMPX skips to an EXEC restore (Part of #3703) #3760

Merged
mumba17 merged 2 commits from upstream-pr/3760 into main 2026-12-02 20:49:12 +00:00
mumba17 commented 2026-12-01 16:54:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T16:54:11Z.


Stacked on #3710. The branch contains #3710's commit until it merges; the change here is the last commit (e55a511f).

Part of #3703. This is the wall right after #3729: graphics register undefined on an incoming path.

What goes wrong

Skinned mesh programs nest a chain of per-lane CMPX skips inside the vertex skip. Each one opens straight after a CMPX that narrows the skip around it, and all of them exit to one s_mov_b64 exec, s[N:N+1] that restores the vertex mask. The vertex skip then goes on and reads the accumulated registers.

A per-lane skip merges every register per lane when it closes, so after the chain closes each thread below V holds an exact value. #3710 carried that fact up one level only, and only when the parent closed at the same instruction. Here the chain is deeper and closes at a restore while the vertex skip continues. The restore then treated every register written since the mask was saved as stale, cleared it, and the next read refused.

Change

  • close_skip passes the carried lane set through any number of skips that close at one pc (a skip exact for its guard makes its narrowed_from parent exact too).
  • An EXEC restore at that pc keeps the register file when the restored mask is the carried guard of the enclosing skip (same lane and wave guard).
  • The carried set is tied to the pc that set it, so it never describes a later instruction.

These still break the chain and refuse as before:

  • a write between the innermost CMPX and its EXECZ;
  • a narrowing that is not a CMPX (v_cmp then s_and_b64 exec).

Tests

Source-built in tests/native_direct_mesh_check.py:

  • nested-skip-chain-restore-1 and -3: one and three nested skips exit to a restore of the saved vertex mask, then v10 is read and written again under that mask before the export.
  • nested-skip-chain-end: two nested skips that close where the vertex skip closes.
  • nested-skip-chain-write-before-execz and nested-skip-chain-and-exec: the two controls above, still undefined on an incoming path: 266.

I removed each half of the fix in turn: dropping the multi-level carry fails -3, and ignoring the carried set at the restore fails -1.

Validation (Windows 11, MSVC, Windows SDK 10.0.26100)

  • ctest --test-dir out/build/dev -R "native_direct_mesh|mesh": 210/210 pass (the two mesh_two_exits hardware tests skip as usual).
  • Census, same capture and method as on #3703, on main e1161e43 + #3708 + #3709 + #3710 + #3729 + this: 749 of 1,569 distinct Mesh86 programs translate, up from 512. 237 gained, none lost. Counts only; request bytes stay local.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5590351696 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T16:54:11Z. --- **Stacked on #3710.** The branch contains #3710's commit until it merges; the change here is the last commit (`e55a511f`). Part of #3703. This is the wall right after #3729: `graphics register undefined on an incoming path`. ## What goes wrong Skinned mesh programs nest a chain of per-lane CMPX skips inside the vertex skip. Each one opens straight after a CMPX that narrows the skip around it, and all of them exit to one `s_mov_b64 exec, s[N:N+1]` that restores the vertex mask. The vertex skip then goes on and reads the accumulated registers. A per-lane skip merges every register per lane when it closes, so after the chain closes each thread below V holds an exact value. #3710 carried that fact up one level only, and only when the parent closed at the same instruction. Here the chain is deeper and closes at a restore while the vertex skip continues. The restore then treated every register written since the mask was saved as stale, cleared it, and the next read refused. ## Change - `close_skip` passes the carried lane set through any number of skips that close at one pc (a skip exact for its guard makes its `narrowed_from` parent exact too). - An EXEC restore at that pc keeps the register file when the restored mask is the carried guard of the enclosing skip (same lane and wave guard). - The carried set is tied to the pc that set it, so it never describes a later instruction. These still break the chain and refuse as before: - a write between the innermost CMPX and its EXECZ; - a narrowing that is not a CMPX (`v_cmp` then `s_and_b64 exec`). ## Tests Source-built in `tests/native_direct_mesh_check.py`: - `nested-skip-chain-restore-1` and `-3`: one and three nested skips exit to a restore of the saved vertex mask, then `v10` is read and written again under that mask before the export. - `nested-skip-chain-end`: two nested skips that close where the vertex skip closes. - `nested-skip-chain-write-before-execz` and `nested-skip-chain-and-exec`: the two controls above, still `undefined on an incoming path: 266`. I removed each half of the fix in turn: dropping the multi-level carry fails `-3`, and ignoring the carried set at the restore fails `-1`. ## Validation (Windows 11, MSVC, Windows SDK 10.0.26100) - `ctest --test-dir out/build/dev -R "native_direct_mesh|mesh"`: 210/210 pass (the two `mesh_two_exits` hardware tests skip as usual). - Census, same capture and method as on #3703, on `main` `e1161e43` + #3708 + #3709 + #3710 + #3729 + this: **749 of 1,569** distinct Mesh86 programs translate, up from 512. 237 gained, none lost. Counts only; request bytes stay local. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0Y00 commented 2026-12-01 17:08:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T17:08:40Z.


CI on the current head is green. This branch still carries #3710, whose current head GitHub reports as non-mergeable. Please refresh the stack against current main or confirm that #3760 supersedes #3710 and should be landed as one combined change.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7318825124 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#issuecomment-7318825124). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-01T17:08:40Z. --- CI on the current head is green. This branch still carries #3710, whose current head GitHub reports as non-mergeable. Please refresh the stack against current main or confirm that #3760 supersedes #3710 and should be landed as one combined change.
mumba17 commented 2026-12-01 17:22:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T17:22:31Z.


Thanks @R0Y00. I refreshed the stack against current main (158ef794). Both rebased without conflicts:

  • #3710 is now a7d98042.
  • #3760 is now a7d98042 + c4ee8a14.

ctest -R "native_direct_mesh|mesh" passes 210/210 on the top of the stack, and native_direct_mesh passes on #3710 alone.

#3760 does not replace #3710. It extends it: #3710 carries the lane set from one nested skip to its parent, and #3760 carries it through any depth and into an EXEC restore. Either order works:

  • land #3710, and #3760 then shows only its own commit;
  • or land #3760 as the combined change and close #3710.

Tell me which you prefer and I'll tidy up the other.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7319197661 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#issuecomment-7319197661). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T17:22:31Z. --- Thanks @R0Y00. I refreshed the stack against current `main` (`158ef794`). Both rebased without conflicts: - #3710 is now `a7d98042`. - #3760 is now `a7d98042` + `c4ee8a14`. `ctest -R "native_direct_mesh|mesh"` passes 210/210 on the top of the stack, and `native_direct_mesh` passes on #3710 alone. #3760 does not replace #3710. It extends it: #3710 carries the lane set from one nested skip to its parent, and #3760 carries it through any depth and into an EXEC restore. Either order works: - land #3710, and #3760 then shows only its own commit; - or land #3760 as the combined change and close #3710. Tell me which you prefer and I'll tidy up the other. AI-assisted.
lukaslw-lab commented 2026-12-01 18:56:47 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed c4ee8a14 (own commit on top of #3710's a7d98042) by reading the diff; not built or run.

Verdict: approve. The carry now passes through skips that are exact for their guard by either route: the guard is still current, or a deeper skip carried it. At the restore it is used only when the restored mask is exactly the carried guard of the open skip, both lane and wave guard. No MUST.

  • Checked, no finding:
    • Why the kept register file is exact. Each skip in the chain opened right after the CMPX that narrowed its parent, and branches per thread. Its close merges every VGPR per lane, and per-lane closes clear changed SGPRs. So at the restore, each thread of the carried guard holds its own exact value. Nothing ran under a narrowed mask outside a skip.
    • A chain that breaks. An inner skip that closes before its parent's end sets carried_at to that earlier pc. lane_active then stays narrowed at the parent's close, so guard_lanes is false and the parent passes nothing on. The restore then falls back to the existing clearing.
    • carried_at == pc. Together with closed_nested_skip, this keeps the carry to the restore instruction at the closing pc (gfx1013_direct_mesh.inl:1984).
    • Fixture encodings. 0x061414f2 is v_add_f32 v10, 1.0, v10. 0xbea6047e/0xbefe0426 save and restore s[38:39]. The exit offsets land on the restore, and the vertex skip is still open there.
  • NIT text.count('fadd') >= depth + 1 counts adds anywhere in the output. Acceptance already shows that v10 survived the restore. Following the last fadd to the export would also show that the per-lane merge feeds it.

Tests: -1 and -3 reach the restore path with one and three levels, and chain-end reaches the multi-level carry into #3710's retain. The two controls keep the write-before-EXECZ and non-CMPX narrowing refused. native_direct_mesh is in the pr preset filter, and CI ran it green at this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6137932113 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#pullrequestreview-6137932113). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T18:56:47Z. **Review:** APPROVED --- Reviewed `c4ee8a14` (own commit on top of #3710's `a7d98042`) by reading the diff; not built or run. **Verdict: approve.** The carry now passes through skips that are exact for their guard by either route: the guard is still current, or a deeper skip carried it. At the restore it is used only when the restored mask is exactly the carried guard of the open skip, both lane and wave guard. No MUST. - Checked, no finding: - **Why the kept register file is exact.** Each skip in the chain opened right after the CMPX that narrowed its parent, and branches per thread. Its close merges every VGPR per lane, and per-lane closes clear changed SGPRs. So at the restore, each thread of the carried guard holds its own exact value. Nothing ran under a narrowed mask outside a skip. - **A chain that breaks.** An inner skip that closes before its parent's end sets `carried_at` to that earlier `pc`. `lane_active` then stays narrowed at the parent's close, so `guard_lanes` is false and the parent passes nothing on. The restore then falls back to the existing clearing. - **`carried_at == pc`.** Together with `closed_nested_skip`, this keeps the carry to the restore instruction at the closing `pc` (`gfx1013_direct_mesh.inl:1984`). - **Fixture encodings.** `0x061414f2` is `v_add_f32 v10, 1.0, v10`. `0xbea6047e`/`0xbefe0426` save and restore `s[38:39]`. The exit offsets land on the restore, and the vertex skip is still open there. - **NIT** `text.count('fadd') >= depth + 1` counts adds anywhere in the output. Acceptance already shows that `v10` survived the restore. Following the last `fadd` to the export would also show that the per-lane merge feeds it. Tests: `-1` and `-3` reach the restore path with one and three levels, and `chain-end` reaches the multi-level carry into #3710's `retain`. The two controls keep the write-before-EXECZ and non-CMPX narrowing refused. `native_direct_mesh` is in the `pr` preset filter, and CI ran it green at this head.
Leyukaka commented 2026-12-02 07:13:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T07:13:34Z.


Friendly note: this is approved, but it conflicts with main again since #3797 and #3770 merged today; one more rebase should be all it needs.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7337925747 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#issuecomment-7337925747). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-02T07:13:34Z. --- Friendly note: this is approved, but it conflicts with `main` again since #3797 and #3770 merged today; one more rebase should be all it needs.
mumba17 commented 2026-12-02 07:26:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-02T07:26:53Z.


Thanks @Leyukaka. I rebased the stack on current main (f365f125):

  • #3710 is now 756647ae.
  • #3760 is now 756647ae + cf68344a.

#3760 had one conflict, where main's narrowed-restore branch (from #3765) and #3760's carried-lane check meet. Both are kept: the narrowed restore runs first, and otherwise the restore is skipped only when the lanes were carried.

On top of the stack, ctest -R "native_direct_mesh|mesh" passes 228/230, with the two mesh_two_exits tests skipped as usual. Two startup_indirect_mesh_*_hardware tests failed under -j 8 from GPU contention and pass when run serially. native_direct_mesh also passes on #3710 alone.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7338194176 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#issuecomment-7338194176). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-02T07:26:53Z. --- Thanks @Leyukaka. I rebased the stack on current `main` (`f365f125`): - #3710 is now `756647ae`. - #3760 is now `756647ae` + `cf68344a`. #3760 had one conflict, where `main`'s narrowed-restore branch (from #3765) and #3760's carried-lane check meet. Both are kept: the narrowed restore runs first, and otherwise the restore is skipped only when the lanes were carried. On top of the stack, `ctest -R "native_direct_mesh|mesh"` passes 228/230, with the two `mesh_two_exits` tests skipped as usual. Two `startup_indirect_mesh_*_hardware` tests failed under `-j 8` from GPU contention and pass when run serially. `native_direct_mesh` also passes on #3710 alone. AI-assisted.
lukaslw-lab commented 2026-12-02 07:42:12 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed cf68344a by reading the diff; not built or run.

Verdict: approve. The conflict with #3765's narrowed restore is resolved fail-closed. No MUST.

  • The only change compared with c4ee8a14 is the restore in lower_mesh (gfx1013_direct_mesh.inl:2315). narrowed_restore now runs first, and the carried-lane skip only guards the else if (:2327).
  • When both hold (one CMPX narrowed the guard inside the skip, and the nested skips closed here with the carried guard), the narrowed path keeps only registers unchanged since the narrowing or merged against it, and clears the rest. That can drop registers the carried path would keep, so the worst case is an extra refusal, never a wrong value. The refusal guard above it is unchanged.
  • The test additions are the same as at c4ee8a14.

Tests: native_direct_mesh (in the pr filter) is green on this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6146557497 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#pullrequestreview-6146557497). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T07:42:12Z. **Review:** APPROVED --- Reviewed `cf68344a` by reading the diff; not built or run. **Verdict: approve.** The conflict with #3765's narrowed restore is resolved fail-closed. No MUST. - The only change compared with `c4ee8a14` is the restore in `lower_mesh` (`gfx1013_direct_mesh.inl:2315`). `narrowed_restore` now runs first, and the carried-lane skip only guards the `else if` (`:2327`). - When both hold (one CMPX narrowed the guard inside the skip, and the nested skips closed here with the carried guard), the narrowed path keeps only registers unchanged since the narrowing or merged against it, and clears the rest. That can drop registers the carried path would keep, so the worst case is an extra refusal, never a wrong value. The refusal guard above it is unchanged. - The test additions are the same as at `c4ee8a14`. Tests: `native_direct_mesh` (in the `pr` filter) is green on this head.
mumba17 commented 2026-12-02 07:43:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-02T07:43:17Z.


Census on the rebased stack (same capture and method as on #3703), so the merge can be prioritised:

  • main f365f125: 532 of 1,569 translate. The largest wall is graphics register undefined on an incoming path, at 547 programs.
  • main + #3710 + #3760: 993 of 1,569. 461 gained, none lost. No program stops at graphics register undefined on an incoming path any more.

Counts only; request bytes stay local. Not run in the game.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7338527732 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#issuecomment-7338527732). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-02T07:43:17Z. --- Census on the rebased stack (same capture and method as on #3703), so the merge can be prioritised: - `main` `f365f125`: 532 of 1,569 translate. The largest wall is `graphics register undefined on an incoming path`, at 547 programs. - `main` + #3710 + #3760: **993 of 1,569**. 461 gained, none lost. No program stops at `graphics register undefined on an incoming path` any more. Counts only; request bytes stay local. Not run in the game. AI-assisted.
lukaslw-lab commented 2026-12-02 09:35:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T09:35:51Z.

Review: APPROVED


Reviewed b15feae0 by git range-diff against cf68344a; not built or run.

Verdict: approve. This is a rebase onto 45c809ab. The commit is identical to the one I approved, and its base #3710 only gained #3806's rename in context. No MUST.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6148173109 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#pullrequestreview-6148173109). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T09:35:51Z. **Review:** APPROVED --- Reviewed `b15feae0` by `git range-diff` against `cf68344a`; not built or run. **Verdict: approve.** This is a rebase onto `45c809ab`. The commit is identical to the one I approved, and its base #3710 only gained #3806's rename in context. No MUST.
R0Y00 commented 2026-12-02 20:48:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T20:48:21Z.

Review: APPROVED


Reviewed 42ce2c27 independently and reran the same MSVC Debug native_direct_mesh fixture against the trial merge into 81f677d4 after #3710 and #3790 landed. Both runs passed. The remaining diff carries the lane proof only across closes at the same PC, and the restore still requires the matching saved lane and wave guards. The one-level and three-level cases, the missing adjacency and non-CMPX refusals all passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158735534 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3760#pullrequestreview-6158735534). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T20:48:21Z. **Review:** APPROVED --- Reviewed `42ce2c27` independently and reran the same MSVC Debug `native_direct_mesh` fixture against the trial merge into `81f677d4` after #3710 and #3790 landed. Both runs passed. The remaining diff carries the lane proof only across closes at the same PC, and the restore still requires the matching saved lane and wave guards. The one-level and three-level cases, the missing adjacency and non-CMPX refusals all passed.
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!3760
No description provided.