shader: lower gfx1013 float image stores and mip loads #1604
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1611"
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 Jess-Doit on 2026-11-24T15:02:04Z.
Refs #1545
Change
Require DMASK
0xffor the gfx1013 2D RGBA32 FLOATimage_storeatu0.Four consecutive VGPRs supply R, G, B and A. A sparse store is refused
before emission.
image_load_mipstill accepts sparse masks on a separatefloat4 SRV at
t0and uses the last address VGPR inLoad(int3(x, y, mip)).The source-built shader loads red and blue from mip 1 into v14 and v15.
It stores those two words and distinct constants from v16 and v17 into 16
unique destination texels. The CPU reference checks all 1,344 DWORDs, including
1,280 sentinels in the surrounding texels and untouched mips. The source and
destination textures are separate. The caller supplies distinct destinations
per invocation. Translation controls reject a sparse store, D16, non-2D forms,
image atomics, overlapping or swapped descriptors, and missing waits.
The sparse-store control was accepted and zero-filled by
3ca76c4fand isrefused by the revised lowerer.
Verification
Tested
aa87ce9a451f98cb602752709ed811b7035a60b3on parent3ca76c4f735dc175fcaa3203a4916f4b7ad3239f.Windows 10 22H2 build 19045.6456, Windows SDK 10.0.26100.0 DXC targeting
cs_6_0.Both controls first differed at mip 0, word 0. The swapped sparse load read
3f100004and forced mip zero read3f000000, each against3f100000.The D3D12 debug layer was enabled and reported zero warnings and errors in
the new dispatches. Debug passed 25 tests, covering all 24 compute image tests
and the docs link check. Release passed both new adapter tests. Both runs had
zero failures and zero skips.
An independent rerun of
aa87ce9ain Debug on the same host passed 24/24:ctest --preset dev --no-tests=error -R '^compute_store_aot_.*(image|texture|mimg)'.#1608 has merged. The merge with
mainkeeps bothlower()keywords (image_srv_descriptorandrsrc2).After that merge, Debug passed 28/28 on the same host: all compute image, texture and MIMG tests,
compute_store_aot_{warp,hardware}andcompute_entry_layout_{warp,hardware}.Local LLVM 23.1.6 reproduced the recorded bytes and disassembled them back to
the fixture instructions. The Ubuntu job runs the LLVM 15 word, disassembly
and container CLI checks:
AI-assisted (Codex).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T15:12:44Z.
Review: CHANGES_REQUESTED
This version emits a full float4 store and zero-fills channels omitted by a sparse DMASK. That changes destination components without evidence that the source operation does so. Please start with a full store mask and a sparse-store refusal, as agreed in #1545. Sparse SRV loads can remain if the selected source components and explicit mip are verified separately. Keep the wrong-mip control and verify surrounding destinations and untouched mips.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:46:48Z.
Review: COMMENTED
Technical review (Linux only; no Windows, WARP or GPU run). The draw test
compute_store_aot_gfx1013_image_store_{warp,hardware}and its 1,344-word readback comparison are therefore not reproduced here.Checked out the PR head (
aa87ce9a, which restricts stores to DMASK 0xf) in a clean tree.What I ran:
tests/compute_mimg_float_store_check.py(translation controls): passes.--binary llvm-mc-19 llvm-objcopy-19 --llvm <libLLVM 19>: the recorded gfx1013 machine words matchllvm-mc, the LLVM 19 disassembly translates to the same HLSL as the hand-written program, and the container CLI output equals the library output. (The workflow pins LLVM 15; this is an additional LLVM 19 check, not a replacement.)docs_links_check,bidi_controls_checkandgit diff --check: clean. The new README anchor resolves.rgba32_float_imagethe UAV isRWTexture2D<float4>, the SRV isTexture2D<float4>, the store isasfloat(uint4(...))of the four data VGPRs and the load isasuint(imageData.Load(int3(x,y,mip))), so values pass through as raw words; a store using the SRV descriptor or a load using the UAV descriptor fails the("image"|"image_srv", index)descriptor check. The1,344 = 3 mipsand1,280 sentinelarithmetic in the docs matches the fixture (16 texels x 4 words rewritten).image_load_mip(DMASK 0x5) remains and is checked through channel order (R,B into consecutive VGPRs) and the forced-mip-zero control.Local mutation check on
tools/compute_store_aot.py, againstcontrols()(each reverted afterwards; tree clean):uint4, store emitted withoutasfloat: caught.(m["kind"], mip) not in (("store", False), ("load", True))removed: not caught. Without it, a plainimage_load(no_mip) is accepted on gfx1013 (animage_store_mipis still refused by a later check). No Linux control uses a plainimage_loadorimage_store_mipon this path; the control list usesimage_sample_l, which is refused earlier for a different reason. Suggestion: addimage_loadandimage_store_mipvariants to the refusal list.a16/packedguards removed: not caught, but both are also refused later with a different message, so there is no behaviour hole; only the message would change.cpu ==condition dropped), "SRV requires a typed FLOAT UAV" check removed, SRV overlap test made one-sided, SRV alignment test removed: not caught. I probed the unmutated code with SRV offsets 0x30, 0x34, 0x41 and 0x62, a UINT format andcpu="gfx1030": all are refused today, so these are behaviours worth pinning, not bugs. The suite only tries 0x40 and 0x50 (overlaps above).Not covered by the fixture (all inputs are normal binary32 values, no sign-flipped sentinel is NaN): NaN payloads, denormals and negative zero through the typed load and store. The code is a pure word pass-through, but D3D does not promise bit-exact NaN handling for float typed UAV stores on every adapter, so it is worth either adding one such texel to the fixture or stating the limit in the docs.
No defects found in the lowering itself.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T15:29:59Z.
Updated in
aa87ce9a:image_storenow requires DMASK0xf. A sparse store mask is refused, and the zero-fill path is removed.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T15:51:36Z.
Thanks @tedin7. These are in the latest commit:
image_loadand animage_store_mipare now refusal controls. Removing the(kind, mip)guard fails the controls.0x30,0x34,0x40,0x41,0x50and0x62must be refused: misaligned, or overlapping either half of the UAV descriptor.cpu="gfx1030"must be refused, and so must a separate SRV with a raw output, which pins the "requires a gfx1013 RGBA32 FLOAT image UAV" check.docs/experiments.md. Every fixture word is a normal binary32 value, and D3D12 doesn't promise bit-exact float typed UAV stores for those values.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:13:56Z.
Review: APPROVED
Full-mask float stores and separate read-only mip loads satisfy the requested scope. After reconciling the CLI with #1608, the binding/refusal controls and both hardware/WARP pairs passed in Windows Release with zero skips. The parallel Linux binary command is retained.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T16:13:35Z.
Resolved the CLI conflict with #1608 in
ec7bfff0by retaining both keyword arguments. The full-mask image-store and mip read-only binding controls passed, as did all four RTX and WARP image tests in Release and the entry-layout translation controls.