Skip to content

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

Merged
R0Y00 merged 4 commits into
R0Y00:mainfrom
SimSalabimse:cursor/mesh57-t7-lane-spill-17da
Nov 26, 2026
Merged

R0Y00 merged 4 commits into
R0Y00:mainfrom
SimSalabimse:cursor/mesh57-t7-lane-spill-17da

Conversation

@SimSalabimse

@SimSalabimse SimSalabimse commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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).

Claim: #2413 (comment) (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.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head e131743 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.

@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP result for head e131743: 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.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Leyukaka

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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.

@cursor
cursor Bot force-pushed the cursor/mesh57-t7-lane-spill-17da branch 3 times, most recently from 47516ca to e529f97 Compare November 26, 2026 02:09
cursoragent and others added 2 commits November 26, 2026 02:15
…esh57

Accept the R0Y00#2127 constant-lane v_writelane_b32 / v_readlane_b32 idiom on the
slot 57 mesh request path (Part of R0Y00#2413 T7). Spill-only VGPRs become scalar
slots; ordinary vector use, unwritten lanes and non-constant lanes stay refused.
Source-built host checks and WARP/hardware draw fixtures cover the happy path
and a mutant that zeroes the spilled colour word.

AI-assisted.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Refuse raw EXEC writelane sources under the one-lane model, scan
pre-skeleton instructions so exchange VGPRs stay spill-unsafe, park an
ordinary scalar in lane 63, and mutate only the colour spill assignment
so the multi-decl keeps sp30_63 for DXC.

Refs R0Y00#2413

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/mesh57-t7-lane-spill-17da branch from e529f97 to d4ba1d1 Compare November 26, 2026 02:15
cursoragent and others added 2 commits November 26, 2026 02:22
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms).
The negative control still expected only one non-IndexError survivor.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants