Repository navigation
startup: lower constant-lane SGPR spills on wave64 lanes and in vertex stages in gfx2hlsl (Part of #1723) - #2712
Conversation
Symptom: the constant-lane spill idiom v_writelane_b32 vN, sM, k /
v_readlane_b32 sD, vN, k was refused for k >= 32 ("lane 40 outside 0..31")
and in every vertex stage ("lowered in pixel stages only"), although a wave64
program spills into lanes 0..63 and a vertex stage uses the same idiom.
Root cause: the slot model (one scalar per (VGPR, lane)) was limited to
wave32 lanes and pixel stages. Neither limit is needed by the model: the two
instructions touch only lane k and ignore EXEC in every stage.
Change: lanes 0..63 and vertex stages are accepted. The translator does not
know the wave size and a wave32 program takes the lane select modulo 32, so a
spill VGPR whose lanes include k and k + 32 (one slot in wave32, two in
wave64) is refused by name. Lane 64+, compute stages, register lanes,
branches (open R0Y00#2524 territory) stay refused.
Test: tests/startup_gfx2hlsl_spill_wave64_check.py (controls fail before:
lanes 32..63 and the vertex stage refused). The existing sgpr_spill controls
now expect lane 64 and the k/k+32 pair refused and the vertex stage accepted.
Win2025 WARP dev and release, DXC and FXC: the pixel draw matches the slot
reference on 256/256 pixels, the vertex draw exports the reference param0,
and all five wrong-lane/ignored-overwrite mutations fail.
(cherry picked from commit c7fe3e44b10ffb4ebdf40caab7d8306926b3a881)
…only, slot 57 mesh is always wave64
|
Independent Stage-2 review of head bcb42f9: PASS.
Marked Ready. @MasterDomino AI-assisted; commands listed were executed locally. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Checked the automated review comment from 03:35Z on head Commands run: AI-assisted; commands listed were executed locally. |
R0Y00
left a comment
There was a problem hiding this comment.
Reviewed the constant-lane spill proof and ran the host spill, branch, wave64 and mesh57 controls with main 651577a combined. The synthetic pixel, vertex and mesh draw checks passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, both on Windows 11 build 26200. The lane and overwrite mutants were caught. An unknown-size VS/PS still refuses lane pairs that could alias, and slot 57 retains its two distinct wave64 lanes.
Part of #1723
What this unblocks: constant-lane SGPR spills (
v_writelane_b32 vN, sM, k/v_readlane_b32 sD, vN, k) in wave64 programs (lanes 32..63) and in vertex stages now translate instead of being refused ("lane 40 outside 0..31", "lowered in pixel stages only").Extends #2637, #2524 and #2127: they cover pixel lanes 0..31 (with branches) and the slot 57 mesh stage; the lane range and the vertex stage were still refused.
What changed
The slot model (one scalar per (VGPR, lane)) only needs the two instructions to touch lane k and to ignore EXEC, which holds in every stage. So:
SPILL_LANES = 64) and the vertex stage joins pixel and mesh (SPILL_STAGES);v_readlane/v_writelane). So k and k+32 name one slot in wave32 and two in wave64: a spill VGPR whose lanes include such a pair stays refused by name (require_spill_lanes_apart, new in this PR; it applies to pixel and vertex stages only, because slot 57 mesh is always wave64 and keeps lanes k and k+32 as two slots).What stays refused
Lane 64 and up, register-chosen lanes, compute stages, a VGPR with any non-spill use, and any branches outside the pixel proof of #2524 (vertex stages with branches stay refused).
Tests
New
tests/startup_gfx2hlsl_spill_wave64_check.py(registered inCMakeLists.txt, noted indocs/experiments.md): wave64 pixel slots, the vertex stage, two VGPRs holding lanes 8 and 40, the k/k+32 pair refusal, and adrawmode with a CPU reference and wrong-lane / ignored-overwrite mutations.startup_gfx2hlsl_sgpr_spill_check.pynow expects lane 64 and the k/k+32 pair refused and the vertex stage accepted. Onorigin/mainthe new check fails (wave64 pixel slots translate,vertex stage slots translate,lanes 8 and 40 of two different VGPRs are accepted); with the change it passes.Verification
python3 -B tests/startup_gfx2hlsl_spill_wave64_check.py: PASS (fails onorigin/main);... binary llvm-mc-19: PASSpython3 -Bofstartup_gfx2hlsl_sgpr_spill_check.py,startup_gfx2hlsl_spill_branches_check.py,startup_mesh57_lane_spill_check.pyand the otherstartup_mesh57_*_check.py: PASStests/startup_gfx2hlsl_*_check.pyrun with no arguments on this branch and onorigin/main: same result per script (export_null_drawandmul24_align_drawneed a compiler and renderer and exit 1 on both); the only new script isspill_wave64_check.startup_mesh57_lane_spill_check.pynow keeps lanes 3 and 35 of one VGPR translating, and fails without the fix). Win2025 (Windows Server 2025) on the fixed head bcb42f9: dev 28/28 and release 28/28 passed (startup_gfx2hlsl_spill_wave64_controls/_warp/_hardware, startup_mesh57_lane_spill (controls), _warp, hardware, startup_gfx2hlsl_sgpr_spill*; one mesh57 hardware test skipped by design).Copy-paste (build and run the spill tests):
AI-assisted; commands listed were executed locally.