compute: image_store / image_load_mip to typed UAVs, and buffer/image atomics #1545
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#1545
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@denn0x on GitHub · 2026-11-24 13:48 UTC · original
Problem
Measured on the 349 gfx1013 compute programs (device slot 67 pipelines) that the executable created in one run past start-up, and on the 627 dispatches of one busy frame after loading. Image stores and atomics have no lowering yet:
image_store(166 sites, withdmask,unorm,d16) into 1D/2D/2D array/3D images.image_load_mip(249 sites).buffer_atomic_add(7 of the busy frame's dispatches),buffer_atomic_cmpswap,image_atomic_umax.Proposal
RWTexture*<float4>(u register); a load from the same descriptor goes through theUAV (typed UAV load). A texture both sampled and stored is refused.
dmaskselects the stored channels, with 0 for the others. d16 data is two halves per VGPR.image_load_mip: the mip is the last address component,Load(int3/int4(..., mip))on an SRV. On a UAV theview's mip slice is used.
RWByteAddressBuffer.Interlocked*(withglcreturning the old value), image atomics toInterlocked*onRWTexture2D<uint>, which needs an R32_UINT view.Alternatives
None noted.
Verification
A source-built gfx1013 fixture (LLVM 15
llvm-mc, as the existingcompute_store_check.pyandpixel_aot_check.pyfixtures) that uses the instructions, translated and dispatched on WARP, with the UAV read back and compared with
expected words. Include a negative control (an operand form or modifier the lowering refuses).
Checklist
AI-assisted (Claude Code).
@Jess-Doit on GitHub · 2026-11-24 14:44 UTC · original
Taking a first slice of this, AI-assisted (Codex, driven with Claude Code), with Windows 10 22H2, a GTX 1060 and WARP.
Slice: gfx1013
image_storeinto a 2D image, lowered toRWTexture2D<float4>(a u register), withdmaskselecting the stored channels. Thenimage_load_mipon an SRV, asLoad(int3(x, y, mip)).Fixture: a source-built gfx1013 program, dispatched on WARP and hardware, with readback compared against independently computed words. A negative control covers a form the lowering refuses (for example d16, or a texture that is both sampled and stored).
Not in this slice: buffer and image atomics, d16, 1D, arrays and 3D. #1587's gfx1030 float image atomics are separate.
@R0Y00 on GitHub · 2026-11-24 14:52 UTC · original
Please go ahead. For the first store, start with full dmask on a typed 2D UAV, unique per-thread destinations, and sentinels outside the written area. Keep sparse masks refused unless the unwritten components and cross-lane behavior are proven. Keep image_load_mip on a separate read-only texture, with different mip contents and a wrong-mip control. These can land independently. Leave same-descriptor reads and writes and atomics outside this slice.
@Jess-Doit on GitHub · 2026-11-24 16:20 UTC · original
Next slice, AI-assisted (Codex, driven with Claude Code), with Windows 10 22H2, a GTX 1060 and WARP. #1611 and #1649 covered the image stores.
Slice: gfx1013
buffer_atomic_add,buffer_atomic_umaxandbuffer_atomic_cmpswapon a raw UAV, lowered toRWByteAddressBuffer.Interlocked*:off). This slice adds per-thread addresses throughoffenandidxen.glc, the old value is returned to the data VGPR and stored to a separate record.Fixture: a source-built gfx1013 program on WARP and hardware.
Negative controls:
_x2, an atomic on a source SRV, and a missingvmcntwait before aglcresult is used;Not in this slice: image atomics, float atomics, 64-bit atomics, and
inc,decandcsubon gfx1013.@R0Y00 on GitHub · 2026-11-24 16:41 UTC · original
This bounded raw-buffer atomics slice can proceed independently of the wider image work. For shared-address add, check the final word and the multiset of old values. For umax and compare-and-swap, use independent cases with deterministic addresses or an order-independent oracle, since their intermediate old values depend on ordering. Keep the guard words and missing-wait refusal.
@Jess-Doit on GitHub · 2026-11-24 22:45 UTC · original
Status of our slices of this issue:
image_store(full dmask) andimage_load_mipon a separate read-only textureimage_store(full dmask)a9fb1792buffer_atomic_add,umaxandcmpswapon a raw UAV5de96be9#1684 follows your conditions above:
umaxandcmpswap: each uses deterministic per-thread addresses.Still open in this issue, with nothing claimed by us:
dmaskandd16stores;image_atomic_umax, which needs anR32_UINTview;_x2) forms, which #1684 refuses on gfx1013.@Jess-Doit on GitHub · 2026-11-24 22:51 UTC · original · edited 2026-11-24 23:07 UTC
Taking the next slice: gfx1013 image atomics. AI-assisted (Claude Code), tested on Windows 10 22H2 with a GTX 1060 and WARP. Now in #2013.
Slice: gfx1013
image_atomic_add,image_atomic_umaxandimage_atomic_cmpswapon a 2DR32_UINTUAV, lowered toInterlockedAdd,InterlockedMaxandInterlockedCompareStoreonRWTexture2D<uint>.glcwould return the old value). The shared lowering refusesglc, so these forms return nothing; the returning forms stay open. As a result, the fixtures check the final words, not a multiset of old values.umaxandcmpswap, plus a contended add with two lanes per texel;Overlap: none of the open PRs touching
tools/compute_store_aot.py(#1683, #1684 and the ALU slices) lowers image atomics. #1684 also touches the gfx1013 rules on different lines; I'll rebase onto whichever lands first.@Jess-Doit on GitHub · 2026-11-24 23:18 UTC · original
Next slice: gfx1013 1D images. AI-assisted (Codex, driven with Claude Code), tested on Windows 10 22H2 with a GTX 1060 and WARP.
Slice:
dmaskimage_store ... dim:SQ_RSRC_IMG_1Dinto anRGBA32_FLOATRWTexture1D<float4>.image_load_mip ... dim:SQ_RSRC_IMG_1Dfrom a separate read-onlyTexture1D<float4>. The mip is the second address word.It follows the rules of #1611 and #1649:
Sparse
dmask,d16,a16, 1D arrays, same-descriptor reads and atomics stay refused.Dependency: this builds on #1649's image-dimension option (
--image-uav-dimension), so it will be stacked on that branch. I'll open it after #1649 merges, or as a stacked PR that names #1649.@Jess-Doit on GitHub · 2026-11-24 23:44 UTC · original
Next slice: gfx1013
d16image stores. AI-assisted (Codex, driven with Claude Code), tested on Windows 10 22H2 with a GTX 1060 and WARP.Slice:
dmaskimage_store ... dmask:0xf dim:SQ_RSRC_IMG_2D d16into a 2DR16G16B16A16_FLOATUAV.v[n]holds x in its low half and y in its high half;v[n+1]holds z and w the same way.f16tof32, and the typed UAV narrows it back. The fixtures use finite binary16 values (normal, subnormal and signed zero) so that round trip is exact; NaN payloads are not claimed.Same rules as #1611: unique per-thread destinations, and sentinels outside the written texels and in the other mips. One control swaps the two halves of a VGPR and must mismatch. Sparse
dmaskstays refused, per your earlier condition, and so dod16loads,a16, other formats, non-2D views and atomics.New branch from main. It touches the same gfx1013 image rules in
tools/compute_store_aot.pyas #1649, #2013 and #2056, so I'll rebase onto whichever lands first.@Jess-Doit on GitHub · 2026-11-25 00:27 UTC · original
Next slice: gfx1013 same-descriptor image loads through the UAV, the "a load from the same descriptor goes through the UAV (typed UAV load)" item of the proposal. AI-assisted (Codex, driven with Claude Code), tested on Windows 10 22H2 with a GTX 1060 and WARP.
Slice: on a 2D
R32G32B32A32_FLOATUAV, a full-dmaskimage_load(mip zero) from the store's own descriptor becomesoutputData[uint2(x, y)], a typed UAV load.Bounds, to keep it within what one lane can prove:
TypedUAVLoadAdditionalFormats).Fixture: each lane reads its texel, changes it and writes it back. Sentinels outside the written texels and in other mips must stay unchanged. One control reads a neighbouring texel and must be refused; another drops the read and must mismatch.
Sparse masks,
d16loads, mips other than zero, arrays and 3D stay refused.New branch from main. It touches the same gfx1013 image rules as #1649, #2056 and #2106, and I'll rebase onto whichever lands first.
@R0Y00 on GitHub · 2026-11-25 00:56 UTC · original
The full-mask 2D D16 store slice is on main via #2106 (
84ce2942). I rebuilt the exact PR head and ran the Release fixture on WARP and RTX 4060 Laptop: 2/2, including the packed-half and untouched-mip controls. The typed-store coverage is for finite half inputs; the separate same-descriptor typed-load work can continue here.@R0Y00 on GitHub · 2026-11-26 06:14 UTC · original
The source-built gfx1030 replay in #2756 is on main (
c458bba9). It adds fixed-address finite-normal buffer compare-swap and the 64-bit compare-swap and min/max forms. WARP and RTX 4060 Laptop both matched the readbacks and detected all four mutations. It uses constant operands and a raw UAV. The independent typed-UAV load and production binding work in this tracker remain open.@Leyukaka on GitHub · 2026-11-28 00:28 UTC · original
Taking the next slice for direct C++ compute (target
main): non-D16image_storewith a prefixdmask(0x1,0x3or0x7) when the bound UAV format has exactly that many channels.Why. In the 882 untranslated requests ranked in #3226, 48 of the 54 programs that stop first at "direct image opcode or descriptor modifiers" do so on a non-D16 prefix-mask
image_store. The shapes aredmask:0x7(2D, 3D and 2D array),0x3and0x1(2D), all withunorm.Plan. This follows your note above: sparse masks stay refused unless the unwritten components and the cross-lane behaviour are proven.
float,float2orfloat3with every component written, as the D16 path already does for masks 1 and 3.R*,RG*andR11G11B10_FLOAT. That way there is no unwritten channel and no read-modify-write, so there is no race between invocations.0x7store keeps a named refusal.0x2,0x9,0xd) stay refused.0x7, and for a non-prefix mask.I do not know yet which formats the title binds to these stores, so the effect on the run is unknown until it is measured at run time.
AI-assisted.