startup: lower constant-lane writelane/readlane spills in translate_m… #2629

Merged
SimSalabimse merged 4 commits from upstream-pr/2637 into main 2026-11-26 02:51:39 +00:00
SimSalabimse commented 2026-11-25 23:58:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-25T23:58:19Z.


Change

Part of #2413 item T7: accept the constant-lane v_writelane_b32 / v_readlane_b32 spill idiom in translate_mesh57, mirroring #2127 / mesh_entry_aot LANE_SPILL_OPS (and the pixel spill helpers in gfx2hlsl).

  • Slot 57 mesh programs may park scalars in fixed lanes of a spill-only VGPR (wave64 lanes 0..63), including an optional saved exec_hi word.
  • Ordinary vector use of the spill VGPR, an unwritten slot, a register-selected lane, and lane 64 stay refused by name.
  • Source-built fixture only; no retail .m57. No R1, no #2603 / #2492 / #2470, no further T6 loop shapes.

Claim: https://github.com/R0Y00/Xbox2Windows/issues/2413#issuecomment-7178160520 (main 66026a39).

AI-assisted.

Verification

Host (Linux pe-env / system Python):

python3 -B tests/startup_mesh57_lane_spill_check.py
python3 -B tests/startup_mesh57_skeleton_check.py
python3 -B tests/startup_gfx2hlsl_sgpr_spill_check.py
python3 -B tests/mesh_lane_spill_check.py
python3 -B tests/docs_links_check.py

All reported ok / PASS on this agent.

Windows verification:

ctest --preset release --no-tests=error -j 1 -V -R '^startup_mesh57_lane_spill'

Expected: host startup_mesh57_lane_spill pass; startup_mesh57_lane_spill_warp pass; startup_mesh57_lane_spill_hardware pass or skip 77 without a mesh-capable GPU. This agent could not run DXC / WARP / hardware draws.

Evidence and follow-up

  • Fixture: hand-assembled words matching tests/startup_mesh57_skeleton.s plus the spill/reload sequence; llvm-mc binary mode is wired in CI.
  • Negative controls: unwritten lane, SGPR-selected lane, lane 64, v_mov into the spill VGPR, missing colour writelane; draw mutant zeroes sp30_3 in HLSL and must change pixels.
  • Bounded lowerers (mesh_entry_aot) are unchanged.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6616281874 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2637). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-25T23:58:19Z. --- ## Change Part of #2413 item **T7**: accept the constant-lane `v_writelane_b32` / `v_readlane_b32` spill idiom in `translate_mesh57`, mirroring #2127 / `mesh_entry_aot` `LANE_SPILL_OPS` (and the pixel spill helpers in `gfx2hlsl`). - Slot 57 mesh programs may park scalars in fixed lanes of a spill-only VGPR (wave64 lanes 0..63), including an optional saved `exec_hi` word. - Ordinary vector use of the spill VGPR, an unwritten slot, a register-selected lane, and lane 64 stay refused by name. - Source-built fixture only; no retail `.m57`. No R1, no #2603 / #2492 / #2470, no further T6 loop shapes. Claim: https://github.com/R0Y00/Xbox2Windows/issues/2413#issuecomment-7178160520 (main `66026a39`). AI-assisted. ## Verification Host (Linux pe-env / system Python): ```bash python3 -B tests/startup_mesh57_lane_spill_check.py python3 -B tests/startup_mesh57_skeleton_check.py python3 -B tests/startup_gfx2hlsl_sgpr_spill_check.py python3 -B tests/mesh_lane_spill_check.py python3 -B tests/docs_links_check.py ``` All reported `ok` / `PASS` on this agent. Windows verification: ```powershell ctest --preset release --no-tests=error -j 1 -V -R '^startup_mesh57_lane_spill' ``` Expected: host `startup_mesh57_lane_spill` pass; `startup_mesh57_lane_spill_warp` pass; `startup_mesh57_lane_spill_hardware` pass or skip **77** without a mesh-capable GPU. This agent could not run DXC / WARP / hardware draws. ## Evidence and follow-up - Fixture: hand-assembled words matching `tests/startup_mesh57_skeleton.s` plus the spill/reload sequence; llvm-mc binary mode is wired in CI. - Negative controls: unwritten lane, SGPR-selected lane, lane 64, `v_mov` into the spill VGPR, missing colour writelane; draw mutant zeroes `sp30_3` in HLSL and must change pixels. - Bounded lowerers (`mesh_entry_aot`) are unchanged. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
tedin7 commented 2026-11-26 01:01:59 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head e1317434 against current main (0 behind). Comment only.

Result: no blocking findings.

  • Change is confined to the slot 57 mesh path: constant-lane v_writelane_b32 / v_readlane_b32, wave64 lanes 0..63, exec_lo/exec_hi saved words. The pixel path keeps lanes 0..31. Ordinary vector use, unwritten slot, register lane and lane 64 stay refused by name.
  • No other open or merged PR covers this slice (searched mesh57 / lane spill / writelane).
  • The new test has a real WARP draw (startup_mesh57_lane_spill_warp, and _hardware) next to the host check, registered in CMake, windows.yml and AGENTS.md.
  • This is a source-built fixture only. It makes no claim about game startup, so none is verified here.

Commands run (Linux, clean worktree on the PR head):

  • python3 -B tests/startup_mesh57_lane_spill_check.py, startup_mesh57_skeleton_check.py, startup_mesh57_loop_refusal_check.py: ok
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: ok
  • Mutation: mesh lane limit 64 -> 32: new test fails (2 cases). Mutation: exec_hi lowers to 1 instead of 0: new test fails. Both reverted.

Windows WARP dev + release will be run and posted next.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6066710769 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2637#pullrequestreview-6066710769). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T00:01:37Z. **Review:** COMMENTED --- Review of head e1317434 against current main (0 behind). Comment only. Result: no blocking findings. - Change is confined to the slot 57 mesh path: constant-lane `v_writelane_b32` / `v_readlane_b32`, wave64 lanes 0..63, `exec_lo`/`exec_hi` saved words. The pixel path keeps lanes 0..31. Ordinary vector use, unwritten slot, register lane and lane 64 stay refused by name. - No other open or merged PR covers this slice (searched mesh57 / lane spill / writelane). - The new test has a real WARP draw (`startup_mesh57_lane_spill_warp`, and `_hardware`) next to the host check, registered in CMake, windows.yml and AGENTS.md. - This is a source-built fixture only. It makes no claim about game startup, so none is verified here. Commands run (Linux, clean worktree on the PR head): - `python3 -B tests/startup_mesh57_lane_spill_check.py`, `startup_mesh57_skeleton_check.py`, `startup_mesh57_loop_refusal_check.py`: ok - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: ok - Mutation: mesh lane limit 64 -> 32: new test fails (2 cases). Mutation: `exec_hi` lowers to 1 instead of 0: new test fails. Both reverted. Windows WARP dev + release will be run and posted next. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-26 01:01:59 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


There is a production correctness problem in addition to the mutant DXC failure already reported. The fixture’s spill follows s_mov_b64 exec, -1 (last word before the spill befe04c1). On wave64, the v_writelane_b32 ... exec_hi, 63 therefore stores 0xffffffff. This candidate emits sp30_63 = 0u. The existing draw never uses the reload in s41. Changing the fixture’s final v_mov_b32 v7, s40 to v_mov_b32 v7, s41 still translates and routes the wrong value to the export. Please keep the ordinary scalar lane 0–63 slice and refuse raw EXEC operands, or prove both EXEC words for each accepted spill and test a consumed reload across the two halves. Please also fix the existing colour mutant so its shader compiles and fails by pixel comparison.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6066794531 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2637#pullrequestreview-6066794531). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T00:12:06Z. **Review:** CHANGES_REQUESTED --- There is a production correctness problem in addition to the mutant DXC failure already reported. The fixture’s spill follows `s_mov_b64 exec, -1` (last word before the spill `befe04c1`). On wave64, the `v_writelane_b32 ... exec_hi, 63` therefore stores `0xffffffff`. This candidate emits `sp30_63 = 0u`. The existing draw never uses the reload in `s41`. Changing the fixture’s final `v_mov_b32 v7, s40` to `v_mov_b32 v7, s41` still translates and routes the wrong value to the export. Please keep the ordinary scalar lane 0–63 slice and refuse raw EXEC operands, or prove both EXEC words for each accepted spill and test a consumed reload across the two halves. Please also fix the existing colour mutant so its shader compiles and fails by pixel comparison.
tedin7 commented 2026-11-26 01:02:09 +00:00 (Migrated from github.com)

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


Win2025 WARP result for head e1317434: FAIL, caused by the new test itself (not by the translator).

Commands (Win2025, default slot pool, dev + release attempted):

  • x2w_pipe.py win2025 2637 --wait 7200 --keep-release (auto plan): no new test was in the plan, so I reran with
  • x2w_pipe.py win2025 2637 --wait 7200 --keep-release --regex '^startup_mesh57|^mesh_lane_spill'

Result: startup_mesh57_lane_spill and mesh_lane_spill_cpu pass. startup_mesh57_lane_spill_warp and startup_mesh57_lane_spill_hardware fail (the hardware one fails the same way on WARP, so this is not a GPU problem). Release did not run because dev failed.

First error (dxc, in the mutant step at tests/startup_mesh57_lane_spill_check.py:165-169):
zero-spill.hlsl: error: use of undeclared identifier 'sp30_63' (also s41 = sp30_63;).

The real draw itself is not the failing step; the failure is the negative-control compile. The mutation re.sub(r'sp30_3 = [^;]+;', 'sp30_3 = 0u;', source, count=1) yields HLSL that no longer declares sp30_63, so dxc refuses it and check=True raises. Suggested fix: make the mutation target exactly the colour spill write (anchor on the sp30_3 assignment with \b, keep every declaration), and compile the mutant with an explicit expectation, then re-run on Win2025.

Linux host checks of this test pass, which is why only the WARP phase shows it.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7178412745 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2637#issuecomment-7178412745). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T00:07:03Z. --- Win2025 WARP result for head e1317434: FAIL, caused by the new test itself (not by the translator). Commands (Win2025, default slot pool, dev + release attempted): - `x2w_pipe.py win2025 2637 --wait 7200 --keep-release` (auto plan): no new test was in the plan, so I reran with - `x2w_pipe.py win2025 2637 --wait 7200 --keep-release --regex '^startup_mesh57|^mesh_lane_spill'` Result: `startup_mesh57_lane_spill` and `mesh_lane_spill_cpu` pass. `startup_mesh57_lane_spill_warp` and `startup_mesh57_lane_spill_hardware` fail (the hardware one fails the same way on WARP, so this is not a GPU problem). Release did not run because dev failed. First error (dxc, in the mutant step at `tests/startup_mesh57_lane_spill_check.py:165-169`): `zero-spill.hlsl: error: use of undeclared identifier 'sp30_63'` (also `s41 = sp30_63;`). The real draw itself is not the failing step; the failure is the negative-control compile. The mutation `re.sub(r'sp30_3 = [^;]+;', 'sp30_3 = 0u;', source, count=1)` yields HLSL that no longer declares `sp30_63`, so dxc refuses it and `check=True` raises. Suggested fix: make the mutation target exactly the colour spill write (anchor on the `sp30_3` assignment with `\b`, keep every declaration), and compile the mutant with an explicit expectation, then re-run on Win2025. Linux host checks of this test pass, which is why only the WARP phase shows it. AI-assisted; commands listed were executed locally.
Leyukaka commented 2026-11-26 02:05:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-26T01:08:57Z.


Review of head e1317434, by reading the diff (not run). Sequences are insertions into tests/startup_mesh57_skeleton.s.

1. An exec_lo spill made under the lane-0 mask reloads per thread. Inserted between ds_read_b32 v5, v6 offset:8 and the following s_mov_b64 exec, -1, the walk is at mask == 'lane0', and op_x2w_mesh_lane0 emits exec = (tid & 63u) == 0u ? 1u : 0u;. So

v_writelane_b32 v30, exec_lo, 63
v_readlane_b32 s40, v30, 63

emits sp30_63 = exec, which is 1 only on thread 0 of each wave, while the guest writes exec_lo (1) into lane 63 whatever EXEC is and reloads 1 for the whole wave. The slot is also marked uniform=True. Main refuses this as lane spills are not covered.

2. A spill of a register the group-index exchange uses survives the exchange. require_spill_only scans self.ins after the exchange has been rewritten, where its v_mov_b32 v6, 0 and ds_write_b32 v6, ... are already x2w_mesh_lane0 / s_nop, so v6 looks spill-only. And if lane_spill: reads_v, writes_v = set(), set() (:1667-1668) skips the stale check that the exchange sets up. With

s_mov_b32 s40, 7
v_writelane_b32 v6, s40, 0       ; before the first s_mov_b64 exec, 1
... group-index exchange ...
v_readlane_b32 s41, v6, 0

the guest's exchange writes v6 = 0 in lane 0, so the reload is 0, while the translation keeps ('const', 7).

Both look closed by the remedy in the existing review (refuse raw EXEC operands; the exec_lo half has the same defect as the exec_hi one: under full EXEC it reloads 1 where the guest has 0xffffffff) plus one more refusal: a spill to a VGPR the exchanges use (v5 and the exchange temporaries), or the spill-only scan run over the instructions before the exchanges are replaced.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7179481600 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2637#issuecomment-7179481600). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-26T01:08:57Z. --- Review of head `e1317434`, by reading the diff (not run). Sequences are insertions into `tests/startup_mesh57_skeleton.s`. **1. An `exec_lo` spill made under the lane-0 mask reloads per thread.** Inserted between `ds_read_b32 v5, v6 offset:8` and the following `s_mov_b64 exec, -1`, the walk is at `mask == 'lane0'`, and `op_x2w_mesh_lane0` emits `exec = (tid & 63u) == 0u ? 1u : 0u;`. So ``` v_writelane_b32 v30, exec_lo, 63 v_readlane_b32 s40, v30, 63 ``` emits `sp30_63 = exec`, which is 1 only on thread 0 of each wave, while the guest writes `exec_lo` (1) into lane 63 whatever EXEC is and reloads 1 for the whole wave. The slot is also marked `uniform=True`. Main refuses this as `lane spills are not covered`. **2. A spill of a register the group-index exchange uses survives the exchange.** `require_spill_only` scans `self.ins` after the exchange has been rewritten, where its `v_mov_b32 v6, 0` and `ds_write_b32 v6, ...` are already `x2w_mesh_lane0` / `s_nop`, so `v6` looks spill-only. And `if lane_spill: reads_v, writes_v = set(), set()` (`:1667-1668`) skips the stale check that the exchange sets up. With ``` s_mov_b32 s40, 7 v_writelane_b32 v6, s40, 0 ; before the first s_mov_b64 exec, 1 ... group-index exchange ... v_readlane_b32 s41, v6, 0 ``` the guest's exchange writes `v6 = 0` in lane 0, so the reload is 0, while the translation keeps `('const', 7)`. Both look closed by the remedy in the existing review (refuse raw EXEC operands; the `exec_lo` half has the same defect as the `exec_hi` one: under full EXEC it reloads 1 where the guest has 0xffffffff) plus one more refusal: a spill to a VGPR the exchanges use (`v5` and the exchange temporaries), or the spill-only scan run over the instructions before the exchanges are replaced. AI-assisted.
SimSalabimse commented 2026-11-26 02:05:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T01:18:31Z.


Pushed 054efda6 for the WARP mutant and review findings on e1317434:

  • Mutant now rewrites only a standalone sp30_3 = …; line so the multi-decl keeps sp30_63 for DXC (tedin7).
  • Raw exec_lo / exec_hi writelane sources are refused under the one-lane model (R0Y00 / Leyukaka); fixture parks an ordinary scalar in lane 63 instead.
  • Spill-only scan uses the pre-skeleton instruction list so exchange VGPRs stay unsafe; host control covers spill into v5.

Host checks listed in the updated body all pass here. Windows WARP/hardware re-run still needed on this head.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7179643125 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2637#issuecomment-7179643125). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T01:18:31Z. --- Pushed `054efda6` for the WARP mutant and review findings on `e1317434`: - Mutant now rewrites only a standalone `sp30_3 = …;` line so the multi-decl keeps `sp30_63` for DXC (tedin7). - Raw `exec_lo` / `exec_hi` writelane sources are refused under the one-lane model (R0Y00 / Leyukaka); fixture parks an ordinary scalar in lane 63 instead. - Spill-only scan uses the pre-skeleton instruction list so exchange VGPRs stay unsafe; host control covers spill into `v5`. Host checks listed in the updated body all pass here. Windows WARP/hardware re-run still needed on this head. AI-assisted.
upstream-sync closed this pull request 2026-11-26 03:03:01 +00:00
R0Y00 commented 2026-11-26 03:03:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T02:48:39Z.

Review: APPROVED


Re-reviewed this head after integrating the constant-trip loop and keeping the existing pixel branch and join proof. The mesh path refuses raw EXEC and reuse of exchange VGPRs. WARP and RTX 4060 Laptop both passed the spill and loop draws, and the zeroed-spill shader compiled and produced 259 mismatched pixels on both. The pixel spill and branch controls also passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067888679 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2637#pullrequestreview-6067888679). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T02:48:39Z. **Review:** APPROVED --- Re-reviewed this head after integrating the constant-trip loop and keeping the existing pixel branch and join proof. The mesh path refuses raw EXEC and reuse of exchange VGPRs. WARP and RTX 4060 Laptop both passed the spill and loop draws, and the zeroed-spill shader compiled and produced 259 mismatched pixels on both. The pixel spill and branch controls also 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!2629
No description provided.