startup: accept the slot 57 count exchange entered under a v_cmpx-narrowed EXEC (Part of #2413) #2643

Manually merged
github merged 2 commits from gh-pr/2643/head into gh-pr/2643/base 2026-11-27 01:10:36 +00:00
Owner

@⁠Leyukaka on GitHub · 2026-11-26 00:12 UTC · original
Leyukaka:mesh57-exec-entry-v2 → main · +142 −13 · 3 files · 2 commits · merged 2026-11-26 00:31 UTC

Part of #2413 (claim, released in 7176218125 and taken back).

Slot 57 programs end the region before the count exchange with:

s_mov_b64 exec, -1
v_cmpx_gt_u32_e32 / v_cmpx_lt_u32_e32 of two operands
s_cbranch_execz COUNT          ; to the count exchange's first s_barrier
... a block on the remaining lanes ...

mesh_skeleton refused this as a branch enters or crosses a group-memory exchange. This accepts exactly that shape:

  • The branch is s_cbranch_execz, forward, in the region between the exchanges, and its target is the count exchange's first instruction. No other branch may land inside the skipped block.
  • The compare is v_cmpx_gt_u32_e32 or v_cmpx_lt_u32_e32, right after s_mov_b64 exec, -1 (only s_nop/s_waitcnt between). Its operands are SGPRs or VGPRs defined for every lane (constants are also taken by the code, but no test covers them). Unlike #2601, no thread index is needed: the block leaves nothing live that a dropped lane could see, so any per-lane EXEC works.
  • The skipped block holds lane-only instructions, and scalar ALU whose results are dead at the exchange. No SGPR it writes is read from the count exchange to the end of the program, and SCC is rewritten by the exchange's s_cmp_eq_i32 before any read. s_barrier only may-writes SCC, so it does not end that scan. Scalar loads and stores stay refused.
  • Both count-exchange arms replace EXEC before lane-dependent work, and the HLSL group barrier runs for every thread. So a lane the compare drops changes nothing: the guest skips the block per wave, the model per lane, and the only live results of the block are lane-predicated VGPR writes.
  • Other s_cbranch_execz blocks keep the existing lane-only rule. An entry or otherwise undefined VGPR operand, s_cbranch_execnz, a missing EXEC reset, an EXEC write or v_cmpx inside the block, and a target past or over the exchange all stay refused.

The second commit (after the first review) drops the thread-index requirement for the compare: any operands defined for every lane are taken, for the reason above.

Tests (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main 8ecaa8e plus these two commits:

  • python -B tests/startup_mesh57_skeleton_check.py: ok.
    • New accepted cases: a gt and an lt compare against the thread index, an lt compare of two defined VGPRs, a defined VGPR other than the thread index (s13 > v7), and the entry over dead scalar ALU.
    • New refusal controls: an undefined (entry) VGPR operand, a branch into the skipped count-entry block, no EXEC reset, s_cbranch_execnz, an EXEC write or v_cmpx in the block, a branch that bypasses the EXEC reset (lands on the compare), a target past or over the exchange, a scalar result read after the exchange, a vcc_lo scalar destination, a scalar load in the block, and dead scalar ALU in an execz block other than the count entry.
  • ... draw <dxc> offscreen_check warp and hardware: ok. The accepted entry cases are drawn against the CPU model (red 255 for the lanes the compare keeps), on WARP (Microsoft Basic Render Driver) and an NVIDIA GeForce RTX 5080.
  • Also ok: startup_mesh57_loop_refusal_check, startup_translator_check, startup_gfx2hlsl_refusals_check, docs_links_check.

Mutation checks, run by hand. The skeleton check fails on each:

  • the defined-operand requirement dropped;
  • the EXEC reset requirement dropped;
  • s_cbranch_execnz accepted;
  • the block check dropped;
  • branches into the block allowed;
  • the dead-result scan dropped;
  • the dead-scalar rule applied to every execz block.

Measured on a local capture at main 8ecaa8e (counts and instruction shape only, inputs private), over all 497 slot 57 requests in that cache: 426 stopped at the entry. With this change all 426 get past it and stop at an earlier s_cbranch_execz block whose scalar results, including scalar loads, are read after its join (the case #2601 started on). No slot 57 request translates fully yet.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-26 00:12 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2643) `Leyukaka:mesh57-exec-entry-v2` → `main` · +142 −13 · 3 files · 2 commits · merged 2026-11-26 00:31 UTC Part of #2413 ([claim](https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/2413), released in 7176218125 and [taken back](https://git.gtahub.st/github/R0Y00--Xbox2Windows/issues/2413)). Slot 57 programs end the region before the count exchange with: ``` s_mov_b64 exec, -1 v_cmpx_gt_u32_e32 / v_cmpx_lt_u32_e32 of two operands s_cbranch_execz COUNT ; to the count exchange's first s_barrier ... a block on the remaining lanes ... ``` `mesh_skeleton` refused this as `a branch enters or crosses a group-memory exchange`. This accepts exactly that shape: - The branch is `s_cbranch_execz`, forward, in the region between the exchanges, and its target is the count exchange's first instruction. No other branch may land inside the skipped block. - The compare is `v_cmpx_gt_u32_e32` or `v_cmpx_lt_u32_e32`, right after `s_mov_b64 exec, -1` (only `s_nop`/`s_waitcnt` between). Its operands are SGPRs or VGPRs defined for every lane (constants are also taken by the code, but no test covers them). Unlike #2601, no thread index is needed: the block leaves nothing live that a dropped lane could see, so any per-lane EXEC works. - The skipped block holds lane-only instructions, and scalar ALU whose results are dead at the exchange. No SGPR it writes is read from the count exchange to the end of the program, and SCC is rewritten by the exchange's `s_cmp_eq_i32` before any read. `s_barrier` only may-writes SCC, so it does not end that scan. Scalar loads and stores stay refused. - Both count-exchange arms replace EXEC before lane-dependent work, and the HLSL group barrier runs for every thread. So a lane the compare drops changes nothing: the guest skips the block per wave, the model per lane, and the only live results of the block are lane-predicated VGPR writes. - Other `s_cbranch_execz` blocks keep the existing lane-only rule. An entry or otherwise undefined VGPR operand, `s_cbranch_execnz`, a missing EXEC reset, an EXEC write or `v_cmpx` inside the block, and a target past or over the exchange all stay refused. The second commit (after the first review) drops the thread-index requirement for the compare: any operands defined for every lane are taken, for the reason above. **Tests** (Windows 11, Python 3.14, DXC from the Windows SDK 10.0.26100), on main `8ecaa8e` plus these two commits: - `python -B tests/startup_mesh57_skeleton_check.py`: ok. - New accepted cases: a `gt` and an `lt` compare against the thread index, an `lt` compare of two defined VGPRs, a defined VGPR other than the thread index (`s13 > v7`), and the entry over dead scalar ALU. - New refusal controls: an undefined (entry) VGPR operand, a branch into the skipped count-entry block, no EXEC reset, `s_cbranch_execnz`, an EXEC write or `v_cmpx` in the block, a branch that bypasses the EXEC reset (lands on the compare), a target past or over the exchange, a scalar result read after the exchange, a `vcc_lo` scalar destination, a scalar load in the block, and dead scalar ALU in an `execz` block other than the count entry. - `... draw <dxc> offscreen_check warp` and `hardware`: ok. The accepted entry cases are drawn against the CPU model (red 255 for the lanes the compare keeps), on WARP (Microsoft Basic Render Driver) and an NVIDIA GeForce RTX 5080. - Also ok: `startup_mesh57_loop_refusal_check`, `startup_translator_check`, `startup_gfx2hlsl_refusals_check`, `docs_links_check`. **Mutation checks**, run by hand. The skeleton check fails on each: - the defined-operand requirement dropped; - the EXEC reset requirement dropped; - `s_cbranch_execnz` accepted; - the block check dropped; - branches into the block allowed; - the dead-result scan dropped; - the dead-scalar rule applied to every `execz` block. **Measured on a local capture** at main `8ecaa8e` (counts and instruction shape only, inputs private), over all 497 slot 57 requests in that cache: 426 stopped at the entry. With this change all 426 get past it and stop at an earlier `s_cbranch_execz` block whose scalar results, including scalar loads, are read after its join (the case #2601 started on). No slot 57 request translates fully yet. AI-assisted.
The region before the count exchange may end with s_mov_b64 exec, -1, a
v_cmpx_gt_u32_e32 or v_cmpx_lt_u32_e32 of an SGPR against the proven
thread index, and an s_cbranch_execz to the exchange's first s_barrier.
The skipped block may hold lane-only instructions and scalar ALU whose
results are dead at the exchange: no SGPR it writes is read from the
exchange on, and SCC is rewritten by the exchange's s_cmp_eq_i32 before
any read. Both count-exchange arms replace EXEC before lane-dependent
work, and the HLSL barrier runs for every thread. Branches into the
skipped block, other compare sources, scalar loads and other execz
blocks stay refused.

AI-assisted.
The entry before the count exchange no longer requires the compare to use
the thread index. The skipped block only leaves lane-predicated VGPR
writes and scalar results that are dead at the exchange, and both exchange
arms replace EXEC, so any per-lane EXEC from v_cmpx_gt_u32_e32 or
v_cmpx_lt_u32_e32 gives the same visible result for a per-lane skip as for
a per-wave skip. Each VGPR operand must be defined for every lane (not an
entry value or left stale by an exchange); SGPRs and constants are taken.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:10:34 +00:00
github manually merged commit e07db98f3d into gh-pr/2643/base 2026-11-27 01:10:36 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 00:16 UTC · original · reviewed

Review of head b73a0982 (code + fixture tests only, no game run).

What I checked:

  • mesh_skeleton change in tools/startup/gfx2hlsl.py: the new exception is narrow (forward s_cbranch_execz into the count exchange's first instruction, s_mov_b64 exec, -1 then v_cmpx_{gt,lt}_u32_e32 s, v<thread>). Anything else keeps the old refusal.
  • Skipped block: lane-only VALU/buffer loads, or scalar ALU whose SGPR results are not read from the count exchange to the end, with an SCC rewrite check that treats s_barrier as may-write only. This reads correctly. Scalar loads/stores and branches into the skipped block are refused.
  • Extra range count_at + 1 and the index == count_at switch look consistent with the old None slot.
  • Fixture tests in tests/startup_mesh57_skeleton_check.py cover the accepted shape plus refusals (VCC write, scalar load, v_cmpx inside the block).

Commands run:

  • python3 tests/startup_mesh57_skeleton_check.py -> ok
  • python3 tests/docs_links_check.py -> ok
  • python3 tests/bidi_controls_check.py -> ok
  • git diff --check origin/main...HEAD -> clean
  • Mutation: allowing ge in the compare regex and dropping the skipped-block scalar check -> the refusal tests fail as expected (3 FAIL), so the tests guard the new rules.

Limits:

  • This is a startup-path lowering for #2413. Only fixture results are reported here. Whether it moves the real program past this point needs a run on the game, which I cannot do. That check and the merge stay with MasterDomino or @⁠R0Y00.
  • This slice has no D3D12 WARP readback test (it is a skeleton/refusal check). The emitted HLSL for the accepted shape is only covered by the fixture, not a GPU-vs-CPU comparison. Worth confirming on the Windows side before merge.
  • No Win2025 run from me (review-only scope).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 00:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2643#pullrequestreview-6066825172) · **reviewed** Review of head b73a0982 (code + fixture tests only, no game run). What I checked: - `mesh_skeleton` change in `tools/startup/gfx2hlsl.py`: the new exception is narrow (forward `s_cbranch_execz` into the count exchange's first instruction, `s_mov_b64 exec, -1` then `v_cmpx_{gt,lt}_u32_e32 s, v<thread>`). Anything else keeps the old refusal. - Skipped block: lane-only VALU/buffer loads, or scalar ALU whose SGPR results are not read from the count exchange to the end, with an SCC rewrite check that treats `s_barrier` as may-write only. This reads correctly. Scalar loads/stores and branches into the skipped block are refused. - Extra range `count_at + 1` and the `index == count_at` switch look consistent with the old `None` slot. - Fixture tests in `tests/startup_mesh57_skeleton_check.py` cover the accepted shape plus refusals (VCC write, scalar load, v_cmpx inside the block). Commands run: - `python3 tests/startup_mesh57_skeleton_check.py` -> ok - `python3 tests/docs_links_check.py` -> ok - `python3 tests/bidi_controls_check.py` -> ok - `git diff --check origin/main...HEAD` -> clean - Mutation: allowing `ge` in the compare regex and dropping the skipped-block scalar check -> the refusal tests fail as expected (3 FAIL), so the tests guard the new rules. Limits: - This is a startup-path lowering for #2413. Only fixture results are reported here. Whether it moves the real program past this point needs a run on the game, which I cannot do. That check and the merge stay with MasterDomino or @⁠R0Y00. - This slice has no D3D12 WARP readback test (it is a skeleton/refusal check). The emitted HLSL for the accepted shape is only covered by the fixture, not a GPU-vs-CPU comparison. Worth confirming on the Windows side before merge. - No Win2025 run from me (review-only scope). AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.