shader: lower v_mad_u32_u24 row-pitch compute stores #748
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/754"
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-23T00:53:58Z.
compute_store_aotrejected any address that folds a row pitch withv_mad_u32_u24.docs/experiments.mdnamed this as a remaining limit after the 2D/3D group work in #701 (closed; referenced for context).Change
v_mad_u32_u24 vD, <pitch>, vRow, vColByteswith the literal pitch in either multiplicand, as the address of anoffen-only raw UAV store.vRowis a dispatch index andvColBytesis av_lshlrev_b32byte offset of a different axis.(tid.y & 0xffffffu) * 72u + (tid.x << 3u) + offset.rows * pitch <= 2^32).The existing single-layout, overlap and every-axis-covered checks apply unchanged.
idxenthe descriptor stride is unused, so--stridedoes not change the output. This letsshader_profile_audit, which always offers a stride for multi-thread groups, reach the form.docs/experiments.mdand the README capability row.Where the form comes from
LLVM 15.0.7 emits this instruction, with the pitch in src0, when the row index is masked to 24 bits. It drops the explicit mask because the instruction applies it. I compiled an amdhsa kernel with
llvm.amdgcn.raw.buffer.store.i32(amdgpu_cswithworkgroup.idcrashes LLVM 15 in SI Fix SGPR copies):clang -target amdgcn-amd-amdhsa -mcpu=gfx1013 -nogpulib -O2 -Sgives:That compiled kernel still stops here, at
v_lshl_or_b32(LLVM usesorbecause it knows the local ID is below the group size). The fixture is therefore hand-assembled withv_lshl_add_u32dispatch indexes and the same mad operand order. Without the mask, LLVM usesv_mul_lo_u32plusv_lshl_add_u32. Both remaining forms are now named as rejected in the docs and left for separate changes.Verification
Commit
532c951, rebased on37ed46d(after #738, the #752 test fix and #750). Windows 11 build 10.0.26300.9974, debug layer unavailable on both backends.compute_store_aot_warpgroups=1x1x1and2x3x1, 320 words, 0 mismatchescompute_store_aot_hardwarecompute_to_pixel_*,compute_mesh_texture_*GPU negative controls for the new kernel, each required to fail: a flipped guard word, the 1×1×1 count against the 2×3×1 reference, recompiled HLSL with swapped axes, with half the group X size, and with a 64-byte pitch.
CPU controls (
compute_store_check.pyruns them in every mode). They pin the exact output and check that the pitch is accepted in either multiplicand, as a decimal inline constant, with or without a stride, and at exactlyrows * pitch == 2^32. They reject:0x400004× 1024 rows), or read from a register;clamp, an element overflowing its column,idxenwith a pitch offset, or the pitch offset stored as data;Stores use different address layouts.Baseline:
mainrejects the fixture withUnsupported compute instruction: v_mad_u32_u24 v6, 0x48, v4, v5.binarymode passed for all 12 cases with LLVM 15.0.7 (LLVM-C.dll,llvm-objcopy). The local Windows LLVM has nollvm-mc, so a local shim mapped its flags toclang -cc1as. The Ubuntu job withllvm-mc-15is the authoritative run. The 22 pure-Python checks fromAGENTS.mdpass.Limits
v_lshl_or_b32comes first in compiled code, this change alone may not move the census.This work is AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by FZNull on 2026-11-23T01:53:09Z.
Verified on
532c9512004bf366aee3685fdbf56ccaea263fbe(rebased onto main37ed46d) on an NVIDIA GeForce RTX 4060 (driver 32.0.16.2124, Windows 11 build 26300) and on WARP (Microsoft Basic Render Driver, driver 10.0.26100.10068). The D3D12 debug layer is unavailable on this host.37ed46d: clean fast-forward, no conflicts.ctest --test-dir out/build/wt-pr754 --no-tests=error -R '^compute_store_aot_' -V: 2/2 passed in 38.9 s.compute_store_aot_hardware: passed in 32.13 s. Every kernel compares its full 320-word buffer withmismatches=0, including the new row-pitch kernel at the 1x1x1 and 2x3x1 dispatches (72-byte pitch, storinguint2(tid.x, tid.y)); the power-of-two pitch mutation (72 -> 64) is detected.compute_store_aot_warp: passed in 6.62 s with the same 320-word comparisons andmismatches=0, including the 2x3x1 row-pitch dispatch.s_lshl_b32+v_add_lshl_u32) is part ofgrid_controlsand passes; it lowers to the same HLSL as thev_lshlrev_b32form.ctest -R '^pixel_aot_' -V: 30/30 passed in 357.7 s, no 60 s cap hit; hardware and WARP draws reportmax_absolute_error=0.python -B tests/form_coverage_check.py: passed.After the run
mainmoved tof714d2f;git merge-treereports this head still merges without conflicts there, though the suite was not re-run on that tip.AI-assisted.