shader: lower three-axis compute stores with a folded plane offset #718
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/724"
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 Not-Saii on 2026-11-22T23:10:41Z.
Change
Completes the remaining 4×4×4 case of #701. After #708, store layouts encoded at most two address axes. This adds a third indexed layout to
tools/compute_store_aot.py:v_lshl_add_u32 vD, v(row dispatch index), shift, v(column byte offset)produces a plane byte offset. The column operand must be av_lshlrev_b32byte offset, and row and column must be different axes.buffer_store_* v[i:i+1] ... idxen offenwith a dispatch index on a third axis and that plane offset emitstid.I * stride + (tid.R << row_shift) + (tid.C << shift) + offset.offset + 4·count ≤ 1 << shift), one group's columns fit one row (dims[C] << shift ≤ 1 << row_shift), and one group's rows fit the stride (dims[R] << row_shift ≤ stride). All three axes count toward the existing "every invocation of the group is separated" check.The existing layouts,
--group-regbehavior andshader_profile_audit.pycandidates are unchanged. The audit already passes group Z as group X + 2 when Z > 1.Fixes #701
Verification
Base
121fdc3, commitb0fa545. Windows 11 build 26300.9974, MSVC 19.44.35230, Windows SDK 10.0.26100 (DXC from the SDK), Python 3.14.8, LLVM 15.0.7 (LLVM-C.dll). Debug layer unavailable.compute_store_aot_hardwaregroups=1x2x2:compared_words=320 mismatches=0compute_store_aot_warp17/17 passed, no skips.
All 22 pure-Python checks listed in
AGENTS.mdpass on Windows, includingdocs_links_check.py.Not run locally:
tests/compute_store_check.py binary. The LLVM 15 Windows installer does not shipllvm-mc, so the Ubuntu CI job (LLVM 15) assembles the new fixture and checks disassembly against the CPU lowering. As a partial local check, a hand-encoded VOP3v_lshl_add_u32 v7, v4, 4, v5disassembled with LLVM 15LLVM-C.dllprints exactly that line, which matches the new pattern. I did not run thereleasepreset.Evidence and follow-up
New fixture
CUBEintests/compute_store_check.pyis original synthetic gfx1013 assembly written for this test (MIT). Group 4×4×4, dispatch Z throughidxen,(tid.y << 4) + (tid.x << 2)throughoffen, stride 132, one word per invocation storing dispatch Z. Dispatches 1×1×1 and 1×2×2 are compared over all 320 words against an independent per-invocation model. The 132-byte stride covers both groups' rows in Y and leaves one guard word per plane.Failure cases that must and do fail:
v2undefined) and wrong sizes on each axis;idxen, from a misaligned register pair, or stored as data.Assumptions: the group-Z SGPR binding remains a caller assumption, as for X and Y. Like the existing two-axis layout, the bounds are per group: the caller's stride and dispatch must keep every plane in range. This is fixture evidence only. Any change to the archive CS counts needs a maintainer rescan.
docs/experiments.md"Two- and three-dimensional thread groups" now describes the third store form, the 4×4×4 fixture row and the new controls.Checklist
This change is AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by rwZephyr on 2026-11-22T23:21:15Z.
Independent Windows 10 validation of the remaining 4×4×4 case from #701 on
b0fa5451923b96f9d36ee4e178a48fd7ef0bb262. Windows 10 22H2 build19045.6466, MSVC19.44.35230, Windows SDK10.0.26100.0, DXC1.8.2502.11, Debug with/MTd. D3D12 debug layer unavailable on both backends.10de:2414), driver621.24(32.0.16.2124via DXGI). Passed.1414:008c), driver10.0.19041.5794. Passed.I also ran
draw_grid(..., "cube")directly after compiling the fixture with-T cs_6_0 -E main. Both adapters matched all 320 reference words for each dispatch (1×1×1and1×2×2). The five negative controls returned exit 1 with the same word mismatch counts on both adapters.The base translator at
121fdc3rejected the sameCUBEprogram atv_lshl_add_u32 v7, v4, 4, v5before dispatch.AI-assisted. All reported runs were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-22T23:25:00Z.
Thanks for picking this up. We had a local branch on the same 4×4×4 case; since you claimed it first, we won't open a duplicate. Two things from it that may help.
Independent run with the debug layer. Head
b0fa545, Windows 11 build 26200.9974, D3D12 debug layer enabled, NVIDIA GeForce RTX 3070 (driver 621.01) and WARP:compute_store_aot_hardwareandcompute_store_aot_warpeach report 17 full readbacks withcompared_words=320 mismatches=0anddebug_errors=0 debug_warnings=0, including the 4×4×4 cube atgroups=1x1x1andgroups=1x2x2. The only debug warnings in the run are the two existingD3D12 1328ones incompute_to_pixel_*.What LLVM 15 emits for this address. We compiled the same layout (row = dispatch Z through
vindex, offset =(dispatch Y << 4) + (dispatch X << 2), storing dispatch Z) with the Ubuntullvm-15package (15.0.7):Run log: https://github.com/roansystemlabs/Xbox2Windows/actions/runs/45081718225 (
b_kernel.llis anamdgpu_kernel;h_cs_args.llis anamdgpu_csentry taking the IDs as arguments and gives the same five address instructions). LLVM folds the X term ass_lshl_b32of the group ID followed byv_add_lshl_u32with the local ID, notv_lshl_add_u32+v_lshlrev_b32. The plane step itself (v_lshl_add_u32 v1, v1, 4, v3) matches your pattern, but its column operand comes fromv_add_lshl_u32. With this sequence (descriptor load as in the other fixtures,--group-reg 2 --group-reg-y 3 --group-reg-z 4 --stride 136),lower()atb0fa545raisesUnsupported compute instruction: s_lshl_b32 s0, s2, 2. This isn't a defect in your fixture, but compiler-generated 4×4×4 stores of this shape would still stop there. Our branch already accepts these three instructions with source-built fixtures and full readbacks on WARP and RTX 3070, so we'll offer that as a small follow-up on top of #724 once it lands.AI-assisted: yes.
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-23T00:48:34Z.
Follow-up as mentioned above: #750 (accepts the LLVM 15 group-base form,
s_lshl_b32+v_add_lshl_u32, with a fixture taken from the actualllc-15output).