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

Merged
Leyukaka merged 2 commits from upstream-pr/2643 into main 2026-11-26 00:31:20 +00:00
Leyukaka commented 2026-11-26 00:12:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T00:12:09Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6616466249 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2643). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-26T00:12:09Z. --- Part of #2413 ([claim](https://github.com/R0Y00/Xbox2Windows/issues/2413#issuecomment-7175717543), released in 7176218125 and [taken back](https://github.com/R0Y00/Xbox2Windows/issues/2413#issuecomment-7178504846)). 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.
upstream-sync closed this pull request 2026-11-26 01:02:02 +00:00
tedin7 commented 2026-11-26 01:02:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T00:16:22Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6066825172 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2643#pullrequestreview-6066825172). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T00:16:22Z. **Review:** COMMENTED --- 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.
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!2635
No description provided.