shader: lower constant-lane SGPR spills in gfx2hlsl pixel stages (Part of #2125) #2163
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2171"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:39:49Z.
Part of #2125
What this unblocks: pixel programs that park SGPRs in VGPR lanes (
v_writelane_b32 vN, sM, k...v_readlane_b32 sD, vN, k, constant k) now translate (item E).What changed
tools/startup/gfx2hlsl.py: one scalar slot per (VGPR, lane). Both instructions ignore EXEC and touch only lane k, so with a constant k and a VGPR no other instruction names, no cross-lane read needs modelling. A constant value reloads as a constant.tests/startup_gfx2hlsl_sgpr_spill_check.py: Python controls,binaryassembler check, and a 16 x 16 D3D12 draw compared with an integer reference; four wrong lowerings must read a different image.startup_gfx2hlsl_sgpr_spill_{controls,warp,hardware}, CI list, AGENTS.md, docs/experiments.md.Semantics: AMD RDNA 2 ISA reference (VOP3 lane operations); LLVM 15 AMDGPU.
Verification:
python3 -I -B tests/startup_gfx2hlsl_sgpr_spill_check.py-> PASS;... binary llvm-mc-> PASS (LLVM 19 locally)2a111e5e:ctest --preset devandctest --preset releasewith-R 'startup_gfx2hlsl_sgpr_spill_|startup_gfx2hlsl_dpp_quad_swap_|startup_gfx2hlsl_swap' --parallel 3 --no-tests=error-> 7/7 passed on each, zero skipsNote: #2032 also adds an
op_v_readlane_b32(uniform-source form); whichever lands second needs a small merge.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:59:46Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
2a111e5e6d518302dc6ace1ed55b2b4beee8dfb8:cmake --build --preset dev --target offscreen_check -- -j 4ctest --preset dev -R '^startup_gfx2hlsl_sgpr_spill_(controls|warp)$' --parallel 3 --no-tests=error --output-on-failure-> 2/2 passed (DXC and FXC ps_5_1 draws, 256 pixels each, all four wrong-lowering controls fail as required)tests/startup_gfx2hlsl_sgpr_spill_check.py-> okThe first Win2025 run (
31df9f30) caught one control that did not bite: a constant slot folds into the export, so the lane mutation had no effect. Fixed in2a111e5eby mutating the folded word.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:17:10Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
2a111e5e6dℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:32:07Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:12:08Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
2a111e5ℹ️ About Codex in GitHub
Your 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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T03:17:11Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1788When an SGPR comes directly from
s_buffer_load_dword*with an immediate offset, the existing load handler tags it as('fixed_buffer_word',). This whitelist rejects that ordinary numeric value as a lane mask or descriptor, even thoughS()anduniform_source()already support it. Consequently, a load/spill/reload sequence satisfying the straight-line pixel-stage restrictions still fails translation. I reproduced this with assembled gfx1013 code; replacing the immediate zero offset with an SGPR containing zero, or insertings_or_b32 s0, s0, 0after the load, makes it translate. Includefixed_buffer_wordamong the numeric spill-source tags and add a memory-loaded spill control.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:32:07Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1788Fixed in
59f23fb5:fixed_buffer_wordis now accepted as a numeric spill source inop_v_writelane_b32, andstartup_gfx2hlsl_sgpr_spill_check.pyhas a control for a buffer word loaded at an immediate offset (fails before, passes after).Verification:
python3 -B tests/startup_gfx2hlsl_sgpr_spill_check.pyPASS (control FAILs with the old whitelist);docs_links_check,startup_gfx2hlsl_refusals_check,startup_gfx2hlsl_handler_arity_check,startup_gfx2hlsl_smem_offset_check,startup_gfx2hlsl_scalar_m0_check,mesh_lane_spill_check,startup_gfx2hlsl_readfirstlane_uniform_checkall PASS.startup_gfx2hlsl_sgpr_spill_(controls|warp)2/2 passed each.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T05:43:14Z.
Ran head
59f23fb5on three adapters. All pass. Windows 11 build 26100, debug layer unavailable, DXC and FXC from SDK 10.0.26100.0.startup_gfx2hlsl_sgpr_spill_controlsstartup_gfx2hlsl_sgpr_spill_warpstartup_gfx2hlsl_sgpr_spill_hardware(XBOX2WINDOWS_ADAPTER=Quadro)startup_gfx2hlsl_sgpr_spill_hardware(XBOX2WINDOWS_ADAPTER=Intel)On each adapter all 33 checks printed ok, including
hardware dxc: all 256 pixels equal the slot referenceand the same line for fxc. The hardware draws do not print the adapter line; I selected the adapter withXBOX2WINDOWS_ADAPTER, the same way the other draws report it.AI-assisted.