shader: lower gfx1013 buffer_atomic_add, umax and cmpswap #1677
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1684"
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-24T17:00:57Z.
Refs #1545
Change
Extend the existing raw UAV atomic emitter to gfx1013 DWORD add, unsigned
max and compare-swap. The checked address forms are a fixed shared word
(
off), a dispatch byte offset (offen) and a dispatch index with adeclared stride (
idxen). Returning atomics publish the old DWORD tothe first data VGPR after
vmcnt(0). A later plain DWORD store can recordit in a disjoint field. Compare-swap reads the replacement from VDATA
and compare from VDATA+1. The latter still holds the comparison word
after the wait. AMD RDNA 2 Shader ISA
The pure-Python controls also pin the emitted
InterlockedCompareExchangeargument order, theglcold-value return and the record that stores it, and the non-returning form. Translation controls refuse a lane guard before or after the atomic, 64-bit forms, unmodeled opcodes, an atomic
to an SRV, a return consumed before its wait, overlapping record fields,
an address shift that wraps within a group, and consumption of the first
data VGPR after a non-returning atomic without an explicit rewrite.
Scope requested on #1545
s_waitcnt vmcnt(0), or after only anlgkmcntwait, is refused.Verification
The full draws below ran at
85271d0e. Later commits change only the test file and CMake, not the lowering, the fixture programs or the draw references:They also merge main. At
a823f6d4,compute_store_aot_gfx1013_buffer_atomics_{warp,hardware}passed again on both adapters.The two commits after it,
5daf7adcand43cd101a, only add controls totests/compute_buffer_atomics_check.py. Every other 32-bit MUBUF atomic is refused, and so are the 64-bitadd,umaxandcmpswapforms with defined data. Removing the width check from the gfx1013 gate now fails the no-argument check.Tested
85271d0e85a782066f1ce50ae93cf021f6a11c1con basedf488f52338101bbcf049649bd737bb2d4dcb71b. Windows 10 22H2 build 19045.6456and Windows SDK 10.0.26100.0 DXC, targeting
cs_6_0for the new cases.The branch merges cleanly with #1649 at
faa78cd4. It is merged with main atabb24b67(0c1c7e2d).The shared add reconstructed a valid serialization of the lane operands
from
9e3779b1to9e377bc1. The compare-swap case checked 16 hits and16 misses, both data VGPR records, and all untouched words. The add-as-OR
mutation first differed at word 0 (
9e3779b2expected,9e3779b1read).Writing the addend into the old-value record first differed at word 1
(
9e3779b1expected,00000001read). The debug layer reported zerowarnings and errors in the new Debug runs. The full Debug selection
recorded 85 passes, 6 capability skips and 0 failures. The existing raw
64-bit reduction, exchange and counter cases skipped on both adapters
because they require SM 6.6 and Int64ShaderOps. Release (
/O2) gave the same result: 85 passes,6 capability skips, 0 failures.
After the merge with main, a Debug rerun of
compute_store_aot_(warp|hardware), the newcompute_store_aot_gfx1013_buffer_atomics_{warp,hardware}and the existingmubuf_{reduction,exchange,counter}cases on both adapters had 10 passes and the same 6 capability skips.
The recorded words are LLVM 15's, as in CI. LLVM 15 and 19 leave the unused src2 field of the two
v_mul_lo_u32words in the cmpswap case at 0, where LLVM 23 writes inline 0, so a local LLVM 23 rundiffers in those two bytes only. The Ubuntu job also
checks the container CLI with LLVM 15.
AI-assisted (Codex, driven with Claude Code; Claude Code reviewed the change and ran the Release and post-merge checks).
[PR #1684] shader: lower gfx1013 DWORD buffer atomicsto [PR #1684] shader: lower gfx1013 buffer_atomic_add, umax and cmpswapImported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:08:43Z.
Review: COMMENTED
Review of head
0c1c7e2df57582de7a04a471352dee0113b49721.Linux limits. Linux x86_64,
llvm-mc-19/llvm-objcopy-19(CI pins 15), Python 3.14. No Windows, no DXC, no GPU, so I could NOT run--draw(the ctestcompute_store_aot_gfx1013_buffer_atomics_<adapter>). Old-value return, contended-add serialization and the HLSL semantics were not executed.Scope. The title says DWORD buffer atomics, but the gfx1013 path accepts only
add,umaxandcmpswap(32-bit).sub, smin, umin, smax, and, or, xor, swap, inc, dec, csuband all_x2forms are refused withgfx1013 buffer atomics require 32-bit add, umax or cmpswap. The README row and docs name add, umax and cmpswap, so this is consistent, but the title reads wider.What I ran
python3 -B tests/compute_buffer_atomics_check.py(controls plus lowering of the 5 cases): passes.--binary llvm-mc-19 llvm-objcopy-19 --llvm /usr/lib/llvm-19/lib/libLLVM-19.so:add_offen,umax_idxen,umax_no_glc,shared_addpass.cmpswapfails: the hard-coded words differ in 2 bytes of the filler src2 field of twov_mul_lo_u32-style VOP3 words (...0102expected,...0100from llvm-19). The atomic words themselves (0060c4e0 00040680etc.) match. So this is an assembler-version pin, harmless with the CI's llvm-15, but the check is brittle on other LLVM versions.tools/compute_store_aot.py, each followed by the no-argument check, restored withgit checkout -- .:f"{word}, {operands[1]}"): check STILL PASSED.result = "ignoredAtomic", so the old value is not returned): check STILL PASSED.s_and_saveexec_b32after an atomic): check STILL PASSED.Return record can overlap the fixed atomic address): FAILED, as intended.or) let through the allow list: FAILED, as intended.Findings
glc, and the guard. They are guarded only by--drawon a Windows GPU. The ISA order itself (replacement in VDATA, compare in VDATA+1, HLSL compare first) is what the code does, andllvm-mc-19acceptsbuffer_atomic_cmpswap v[4:5], v0, s[24:27], 0 idxen glc. A text-level assertion on the emittedInterlockedCompareExchangeargument order and onatomicOldwould make the Linux CI step meaningful.glcthe data register is popped fromvector, so a consumer of it is refused (Store data is not a known wordcontrol). That is the safe choice.windows.ymlCHECKS entry with the explicit--binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1, the no-argument step,AGENTS.md) looks consistent with its neighbours; I did not run Actions.Verdict: the accepted shapes assemble to the expected machine words, and the refusals are tight. The ordering and old-value semantics rest on Windows-only draws. Not approving.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T17:30:43Z.
Thanks @tedin7. Both points are addressed in the latest commit:
LLVM pin: the cmpswap fixture recorded LLVM 23's encoding. LLVM 23 writes inline 0 into the unused src2 field of the two
v_mul_lo_u32words, where LLVM 15 and 19 leave it at 0, and that is what failed the gfx1013 CI job. The recorded words are now LLVM 15's, as in CI and in the bytes you saw from LLVM 19.Surviving mutations: the pure-Python controls now pin:
InterlockedCompareExchange(addr, compare, replacement, atomicOld)order, with VDATA+1 as the compare and VDATA as the replacement;glcold value, and that the record storesatomicOld;glcform, which returns nothing;Swapping the cmpswap operands, ignoring
glc, and removing the guard-after refusal now each fail the no-argument check.Title: narrowed to add, umax and cmpswap.
The Windows draws are unchanged from the description: Debug and Release on a GTX 1060 and WARP.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:06:44Z.
Review: COMMENTED
Re-review of head
a34997b982(comment only, not an approval). My earlier review was at0c1c7e2df.Verdict: 0 P1 / 0 P2.
Earlier points
v_mul_lo_u32words now end in...0100; llvm-mc-19--binarypasses all 5 cases (llvm 15 not run).InterlockedCompareExchange(addr, compare, replacement, atomicOld),InterlockedAdd(..., atomicOld)plus the store,ignoredAtomicwithoutatomicOldfor the non-glc case, and two rejections for a lane guard before and after the atomic. I re-ran my earlier cmpswap-order and glc mutations and both now fail. The title now names add, umax and cmpswap.Semantics: the replacement is in VDATA (v4) and the compare in VDATA+1 (v5), HLSL gets the compare first, matching the .s file. With glc the old value goes to the first data VGPR, gated by
vmcnt(0)throughloading[src]. llvm-mc-19 on gfx1013 and gfx1030 gives identical bytes (cmpswap opcode 49, add 50, umax 56).signedis true only for smin/smax, so umax is unsigned.off,idxenandoffengo throughlinear_uav_address. The three opcodes are already in docs/coverage/gfx1013.tsv and rdna2.tsv. No assertion is weakened; the one loosened line only lets gfx1013 follow an atomic with a plain DWORD store, which is the record store.Run
python3 -B tests/compute_buffer_atomics_check.py: controls passed. The same with--binary llvm-mc-19 llvm-objcopy-19 --llvm /usr/lib/llvm-19/lib/libLLVM-19.so: all 5 cases match (machine words, disassembly round trip, container CLI).tests/compute_store_check.py binary ...(no gfx1030 regression), compute_entry_layout_check, run_checks_parallel_check, docs_links_check (17 files, 364 links), bidi_controls_check,git diff --check origin/main...HEAD: pass.git checkout --, green again), caught: cmpswap operands swapped; glc ignored; guard-before refusal removed; return VGPR readable before the wait; offen wrap bound<< 40.Min; per-thread address offset dropped (+ 0u; every atomic fixture uses offset 0, so it is untested even with--draw).Non-blocking
uinttype andInterlockedMaxinlowered["umax_idxen"], andlowered["umax_no_glc"]beyondignoredAtomic);), so signedness and the Max/Min mapping do not rest only on a Windows draw.offset:.FORM_COVERAGE_RECORD, unlikecompute_store_aot_mubuf_reduction_*; the neighbouring gfx1013_image_store test omits it too, so optional.<< 31control.Not run:
--draw(ctestcompute_store_aot_gfx1013_buffer_atomics_*), so the contended-add serialization, the hit/miss readbacks and the 85-pass claim are unconfirmed here.Linux limits: no Windows, WARP or GPU here; LLVM 19 only (CI pins LLVM 15). Anything that needs them was not run.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T18:20:20Z.
Thanks @tedin7. The non-blocking points are in
a823f6d4:uint atomicOld; … InterlockedMax(tid.x * 8u + 0u, 0x80012345u, atomicOld)and the non-glcignoredAtomicform. Treating umax as signed, or mapping it toMin, now fails the no-argument check.offen offset:4atomic must emit(tid.x << 3u) + 4u, with the record moved to offset 0. That's a translation-level pin; the draw fixtures still use offset 0.compute_store_aot_gfx1013_buffer_atomics_*now setsFORM_COVERAGE_RECORD, and the draw writes the accepted mnemonics. Both adapters passed again on the GTX 1060 and WARP with the record written.This commit also merges main at
a4d17cf5, with no conflicts.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T18:24:30Z.
The Windows job failure at
a823f6d4is instartup_launch, which this PR doesn't touch. This PR only changestests/compute_buffer_atomics_check.pyand CMake since the last green run.The failure is a timing edge in the timeout case: the process was killed by the 1 s timeout at the same moment the fast-fail check compared its run time against 1.0 s (
killed after 1 s timeout in 1.00 s…fast-fail: exited with 0xdead0001 in 1.00 s (< 1.0 s)).On the same merged tree,
ctest --preset dev --no-tests=error -R '^startup_launch$'passed 3/3 locally (Windows 10 22H2). Could a maintainer rerun the failed job? I don't have rights to rerun it.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:33:29Z.
Review: COMMENTED
Review of head
c34d584dd163e8751974e82018945c73e2eb98d3. My earlier reviews were on0c1c7e2danda34997b9; since then the PR addeda823f6d4(umax and nonzero-offset pins, form-coverage record) andc34d584d(a comment), plus a main merge.Verdict: no P1 and no P2. The lowering matches the RDNA 2 atomic semantics as I read them, and the new pins hold.
Linux limits. Linux x86_64,
llvm-mc-19andllvm-objcopy-19(CI pins 15), Python 3. No Windows, no DXC, no GPU, and I did not run the pipeline's Windows helper. So I did not run--draw(compute_store_aot_gfx1013_buffer_atomics_<adapter>): the contended-add serialization, the returned old values and the compare-swap hit and miss counts are the author's GTX 1060 and WARP results, not reproduced by me. Those draws ran at85271d0e; the PR text says later commits only changed the test file and CMake, andgit diff 8cef962c HEADagrees for the lowering except one added comment (tools/compute_store_aot.py:1586-1589).Semantics I checked (
tools/compute_store_aot.py)word = f"{operands[1]}, {word}"), the HLSLInterlockedCompareExchangeorder. With glc the first data VGPR is set fromloading[src]and only readable aftervmcnt(0); the compare register keeps its value.ignoredAtomicand pop the first data VGPR, so a later read of it is refused instead of invented.offen/idxengo throughlinear_uav_address(:254-266): the shift is bounded anddims[axis] << shiftcannot pass 2^32, the field must fit the element, and every other group axis must be 1. A sharedoffatomic setsshared_atomic_offset, and a later record must be per-thread and start above it, so a record cannot land on the shared word for any lane.buffer_store_dwordafter the atomic is the only store allowed (buffer_store_dwordx2and the others are still refused).What I ran on this head (worktree at the exact SHA;
git statusclean after every mutation)python3 -B tests/compute_buffer_atomics_check.py: passes.... --binary llvm-mc-19 llvm-objcopy-19 --llvm /usr/lib/llvm-19/lib/libLLVM-19.so: all five cases (add_offen, umax_idxen, umax_no_glc, shared_add, cmpswap) match llvm-mc.python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so(the CI entry for the translator as a whole): exit 0, so the shared lowering still passes its existing cases.git merge-tree --write-tree origin/main HEAD: clean; also clean against #1649.git diff --check origin/main...HEAD,docs_links_check.py(17 files, 366 links),bidi_controls_check.py: clean.tools/compute_store_aot.py, each restored:ignoredAtomic)vmcnt(loading[src]not set)<=to<)subFindings
inc,dec,csubandor(tests/compute_buffer_atomics_check.py:56) but not the other 32-bit forms the gfx1013 gate also refuses (sub,smin,umin,smax,and,xor,swap). Widening the accepted set by one opcode leaves the check green, although no draw covers that opcode. One loop over those names in the existing rejection block would pin it.startup_launchtiming failure unrelated to this PR).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:51:05Z.
Review: COMMENTED
Re-review of head
5daf7adc818198c6f4a3d18395889089cb76fc07. My previous review was atc34d584d. Comment only, not an approval.Verdict: 0 P1 / 0 P2. The one open finding from my last review is closed.
Linux limits. Linux x86_64,
llvm-mc-19andllvm-objcopy-19(CI pins 15), Python 3. No Windows, no DXC, no GPU. I did not run--draw(ctestcompute_store_aot_gfx1013_buffer_atomics_<adapter>), so the contended-add serialization, the returned old values and the compare-swap hit and miss counts remain the author's GTX 1060 and WARP results. Not reproduced by me.Previous finding
substays green": fixed.git diff c34d584d HEADis one commit touching onlytests/compute_buffer_atomics_check.py(+4 / -1). The refusal loop now runs oversorted(set(aot.MUBUF_ATOMIC_METHODS) - {"add", "umax", "cmpswap"}), and an assertion keeps the eleven namessub, smin, umin, smax, and, or, xor, swap, inc, dec, csubinside that list, so the loop cannot silently shrink. Nothing undertools/changed since the head I last reviewed, so the lowering review stands.What I ran at this SHA (worktree at the exact head,
git statusclean after the mutations)python3 -B tests/compute_buffer_atomics_check.py: "controls passed".--binary llvm-mc-19 llvm-objcopy-19 --llvm /usr/lib/llvm-19/lib/libLLVM-19.so: all five cases (add_offen, umax_idxen, umax_no_glc, shared_add, cmpswap) report "machine words match llvm-mc".python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: exit 0. The output ends with the two expectedUnsupported MUBUF cache invalidationrefusal lines.tests/docs_links_check.py(17 files, 366 links),tests/bidi_controls_check.py(1299 files),git diff --check origin/main...HEAD: clean.tools/compute_store_aot.py, each followed by the no-argument check andgit checkout -- .:sub(the previously surviving one)_x2formsumaxmapped toMininMUBUF_ATOMIC_METHODSRemaining notes (non-blocking)
_x2mutation is killed only by a downstream "data is not a known word" assertion. A control that feeds an_x2form and expects the "32-bit" rejection message would pin the wide half of the gate directly. Optional.startup_launchtiming failure the author describes is not touched by this PR; I did not run Actions.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T19:36:39Z.
Thanks @tedin7. Finding 1 is fixed in
5daf7adc. The refusal loop now runs over every op inMUBUF_ATOMIC_METHODSexcept add, umax and cmpswap: sub, smin, umin, smax, and, or, xor, swap, inc, dec and csub. An assertion keeps that list from shrinking. Withsubadded to the gfx1013 gate, the no-argument check now fails. This changes only the test file, so the draws are unaffected.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T22:01:37Z.
Thanks @tedin7. The
_x2note is fixed in43cd101a. It only changestests/compute_buffer_atomics_check.py.add_x2control leftv5undefined. With the width check removed, the data check still refused it ("Atomic reduction data is not a known word"), so the gate itself wasn't pinned.buffer_atomic_add_x2 v[4:5],buffer_atomic_umax_x2 v[4:5]andbuffer_atomic_cmpswap_x2 v[4:7]withv5tov7defined, and each expects the "require 32-bit add, umax or cmpswap" refusal. The old control is replaced; the new one covers the sameadd_x2case.wide orfrom the gfx1013 gate now fails the no-argument check withExpected rejection: require 32-bit add, umax or cmpswap. Restored, it passes again.The lowering and the draws are unchanged.
Status: ready to merge from our side. Every finding from tedin7's four reviews, the P3s included, is addressed in the code or answered here. CI is green at
43cd101a, and the branch merges cleanly with main and with #1649. If you'd like anything else changed or tested, I'll do it.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T22:37:40Z.
Merged main at
889cd3f4in5de96be9to resolve a conflict with main:startup_ngg_slice_check.pyto the Python check lists in.github/workflows/windows.ymlandAGENTS.md, at the spot where this PR addscompute_buffer_atomics_check.py.After the merge, the atomics controls,
run_checks_parallel_check.py,docs_links_check.pyand the newstartup_ngg_slice_check.pypass locally.Status: ready to merge from our side. CI is green at
5de96be9, and every review finding is addressed or answered above.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T00:31:34Z.
Merged main at
05092b6ein26604aa8to resolve a conflict with #1683 (descriptor-format stores):tools/compute_store_aot.py. This PR routes that branch throughlinear_uav_address, while main changed the field size from4 * counttospan.span, so descriptor stores reserve the same bytes as on main.Reruns after the merge:
--binarycheck;compute_store_aot_*draws on the GTX 1060 and WARP. The six_x2atomic draws are capability skips (77) on these adapters, as before.compute_store_aot_descriptor_store_format_*can't run here as registered: this machine'sclanghas no AMDGPU target. I ran its controls and draws with the assembler round trip skipped, and both adapters had 0 mismatches and no debug-layer messages.Status: ready to merge from our side. CI is green at
26604aa8, and every review finding is addressed or answered above.Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T01:51:12Z.
Merged main at
e16fec3cinfa86d4c5. The only conflict was in the Python check lists inAGENTS.mdand.github/workflows/windows.yml. Main addedcompute_alu_bcnt64_check.pywhere this PR addscompute_buffer_atomics_check.py, and both are kept. The translator merged without conflicts. The atomics controls and the LLVM 15--binarycheck pass after the merge.Status: ready to merge from our side. CI is green at
fa86d4c5, the branch merges cleanly with main, and every review finding is addressed or answered above.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:10:38Z.
Review: COMMENTED
Review of head
fa86d4c59eb585d6a14b36a8a7ff9689a24db870(Linux only; no Windows run by me, CI shows Windows build/test and fixture jobs passing on this head).Checked: title is neutral, PR is not a draft, CI jobs "Build and test on Windows", "Assemble and translate gfx1013 fixtures" and "Run platform-independent Python checks on Linux" pass (the O2 and chart jobs were skipped).
Commands executed locally (worktree of the PR head):
python3 -B tests/compute_buffer_atomics_check.py->gfx1013 atomic translation and serialization controls passedpython3 tests/docs_links_check.py-> self-test passed, 18 Markdown files, 399 linkspython3 tests/bidi_controls_check.py-> no bidirectional controls in 1440 filesgit diff --check origin/main...HEAD-> cleantools/compute_store_aot.pyswapped the cmpswap HLSL operand order (compare/replacement). The new check fails. Killed.cpu == "gfx1030" or not line.startswith(...)so gfx1030 no longer refuses a store after an atomic. The new check still passes. Survived (see P2).git checkout -- ..Semantics read against the RDNA 2 MUBUF atomic description: replacement in VDATA, compare in VDATA+1, old value returned in the first VDATA dword with glc, and HLSL
InterlockedCompareExchangetaking compare first. The lowering matches. The gfx1013 refusals (guarded programs,_x2, other ops, mixed idxen+offen, overlap with the fixed shared word) look sound, and the shared-add serialization oracle with a scramble control is a good test.Findings:
tools/compute_store_aot.py(store branch,if atomic_update and (cpu == "gfx1030" or not line.startswith("buffer_store_dword "))): the gfx1030 half of this condition is not guarded by the new suite. A change that lets gfx1030 write a UAV after its atomic passescompute_buffer_atomics_check.py. Please add one negative control for gfx1030 atomic followed bybuffer_store_dword(or point to an existing test that covers it).tools/compute_store_aot.pyatomic branch: for non-glc gfx1013 atomics the data register is silently dropped fromvector. That is documented indocs/experiments.md, and theumax_no_glcfixture exercises it. A one-line control that a later read of that register is refused would pin it down.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:15:52Z.
Review: COMMENTED
Re-review of head
4bf7f7ac66a0a1c0bb7eeb9b4bd16361a8597d19. This head is a merge of upstream main (681d01f5) into the branch. I read the PR's own diff against main (9 files, +399/-22).Verdict: no P1, no P2.
Commands run locally (Linux worktree at this head):
git diff --check origin/main...HEAD: clean.python3 tests/docs_links_check.py: self-test passed, 18 Markdown files, 407 links.python3 tests/bidi_controls_check.py: 1484 files, no bidirectional controls.python3 tests/compute_buffer_atomics_check.py: "gfx1013 atomic translation and serialization controls passed".gh pr checks 1684: Linux Python checks, gfx1013 fixture assembly and Windows build/test all pass. The /O2 job and chart publishing are skipped.Mutations (each reverted with
git checkout -- .):tools/compute_store_aot.py: changed the guardoffset <= shared_atomic_offsettooffset < shared_atomic_offset. The suite fails withExpected rejection: Return record can overlap the fixed atomic address. Killed.{operands[1]}, {word}to{word}, {operands[1]}. The suite fails on the emitted HLSL. Killed.Findings:
Return record can overlap the fixed atomic address) relies on dword alignment, so a store atoffset > shared_atomic_offsetis at least 4 bytes past it. That holds, because the atomic and dword offsets are both multiples of 4. A one-line comment saying so would make it easier to maintain.s_and_saveexec_b32after an atomic is refused. Only 32-bit add, umax and cmpswap are accepted. The cmpswap order matches the ISA (replacement in VDATA, compare in VDATA+1). Without GLC the source register is invalidated rather than given a made-up old value. The per-thread address helperlinear_uav_addressrequires every group axis to be separated.python3 $P win2025. The merge only brought in unrelated upstream changes, and the Windows CI job covering the D3D12 readback check is green on this head.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T05:10:49Z.
Merged current
main(681d01f5) at4bf7f7acto clear the conflict.tools/compute_store_aot.pykeeps bothlinear_uav_address()and main'sdescriptor_load_hlsl(), and the workflow keeps both LLVM 15 entries. Re-run on Windows 10 19045 with the debug layer on (0 D3D12 warnings or errors): the buffer-atomics cases pass on GTX 1060 + WARP. The neighbouringmubuf_reduction_x2cases skip (77, they need SM 6.6 Int64). The descriptor-store cases need the LLVM 15 assembler and pass with it. The descriptor-load hardware case hit the 120 s CTest limit on this GTX 1060 but passes directly in 115 s, and its HLSL is byte-identical to main.compute_store_check.py binary(LLVM 15), docs links, bidi andgit diff --checkalso pass. The texture-case flag bits are unchanged.Status: ready to merge from our side.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:06Z.
@Jess-Doit could you rebase this branch onto current
mainand force-push?GitHub reports head
4bf7f7acas conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(4aaea119):tools/compute_store_aot.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T17:09:19Z.
@tedin7 thanks. Rebased onto current
main(7092683a) as one commit and force-pushed: head is now809b422a.The conflict was in
tools/compute_store_aot.py.mainadded the heap store view branch, and this PR adds the linear address used by the atomics.main.Tests on Windows 10 build 19045,
devpreset, GTX 1060 6GB (driver 32.0.15.6094) and in-box WARP 10.0.19041.compute_store_aot_(gfx1013_buffer_atomics|mubuf_reduction|gfx1013_image_uav_load)_andstartup_compute_buffer_atomics: 11 of 11, including 2 capability skips for the_x2reduction variants.compute_buffer_atomics_check,compute_heap_store_check,compute_heap_view_check,compute_load_format_check,form_coverage_checkandcompute_desc_numeric_check controlspass.A note on scope: #2331 and #2382 lowered buffer atomics in
tools/startup/gfx2hlsl.py, the startup translator. This PR covers the separate offline compute translator,tools/compute_store_aot.py, so the two don't overlap.Ready to merge from our side.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T20:41:16Z.
Rebased onto current
main(5123cc6d) as one commit and force-pushed: head is now3cff259e.The conflict was in
tools/compute_store_aot.py, with #2511's finite-normalfmin/fmaxbuffer atomics, which landed in the same atomic block.m[1]..m[7]. This PR moved that regex to named groups, so its checks now useop,wideandglc.fmin/fmaxdomain check now sits in the non-gfx1013 branch next to thecsubandglcchecks. gfx1013 keeps its own allowlist (32-bitadd,umax,cmpswap), so a float atomic there still gets the gfx1013 refusal. That is what this PR's control expects.buffer_float_update = Falseandshared_atomic_offset = Noneare both kept.Tests, run on Windows 10 19045 with GTX 1060 + WARP:
ctest -R atomic: 21 passed and 1 capability skip (bvh_atomics_warp), 0 failed.compute_buffer_atomics_check.py,startup_compute_buffer_atomics_check.pyandrdna2_tools_check.pypass.Ready to merge from our side.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:36:21Z.
Review: COMMENTED
Review of head
27e8b22a(main merged into the PR) against current main. No blocking issues found.What I checked:
tools/compute_store_aot.py: the gfx1013 raw UAV path now accepts 32-bitbuffer_atomic_add,umaxandcmpswapwithoff,offenandidxenaddressing. 64-bit forms and other opcodes are refused with a clear error. Thecmpswapdata range uses VDATA and VDATA+1.tools/startup/gfx2hlsl.py. This PR works in a different tool (compute_store_aot.py), and #2511's float min/max atomic block is kept intact (the op allowlist still reaches its expected error text).tests/compute_buffer_atomics_check.pypins machine words against the assembler, the emitted HLSL argument order, and the translation refusals. The--drawmode is a real D3D12 readback of the raw UAV, registered ascompute_store_aot_gfx1013_buffer_atomics_<adapter>in CTest. The workflow andAGENTS.mdcheck lists are extended in both places..github/workflows/windows.yml: the only change is one extra Python check entry (LLVM 15 binaries) next to its siblings. The PR's own CI run on this head exercises it.Commands run (Linux, clean worktree at this head). This machine has LLVM 19 only, so I ran the check with
llvm-mc-19/llvm-objcopy-19instead of LLVM 15:python3 -B tests/compute_buffer_atomics_check.py --binary llvm-mc-19 llvm-objcopy-19 --llvm libLLVM.so.1: all cases OKpython3 tests/docs_links_check.py: OKpython3 tests/bidi_controls_check.py: OKgit diff --check origin/main...HEAD: cleanumaxfrom the gfx1013 allowlist: the check fails.cmpswaptoInterlockedExchange: the check fails.Not covered here: the D3D12 draw readback and the LLVM 15 run (Win2025 and CI follow separately).
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T21:18:51Z.
Fixed the failed
Assemble and translate gfx1013 fixturesjob: head is now373f7a7a.Cause: #2511's
mubuf_float_controlsruns abuffer_atomic_fmin/fmaxprogram withcpu="gfx1013"and expectsUnsupported atomic reduction target or binding. On this branch the gfx1013 op allowlist refused it first, with a message that lacked that prefix. That control only runs in the LLVM 15--binarymode, which I couldn't run locally.Fix: the gfx1013 allowlist refusal now starts with
Unsupported atomic reduction target or binding:. That matches the other gfx1013 refusal in this block, and the PR's own control still matchesrequire 32-bit add, umax or cmpswap. Nothing else changed.Checks:
*_controlsfunctions intests/compute_store_check.pypass,mubuf_float_controlsincluded.compute_buffer_atomics_check.pyandstartup_compute_buffer_atomics_check.pypass.Ready for more review.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:37:41Z.
Win2025 WARP receipt for head
27e8b22aafter updating with main.Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
27e8b22a6c5ff46eb80426991d2fc28b2a652512:--preset dev):cmake --build --preset dev -- -j 2):6.20s(configure2.09s)ctest --preset dev -R 'gfx1013_buffer_atomics|compute_store_aot_mubuf_reduction' --parallel 4 --no-tests=error --output-on-failure): 6/6 passed (11.42s:compute_store_aot_mubuf_reduction_x2_hardware4.58s,compute_store_aot_mubuf_reduction_hardware4.75s,compute_store_aot_mubuf_reduction_warp5.27s,compute_store_aot_mubuf_reduction_x2_warp5.83s,compute_store_aot_gfx1013_buffer_atomics_hardware6.27s,compute_store_aot_gfx1013_buffer_atomics_warp6.48s)/O2(--preset release):cmake --build --preset release -- -j 2):25.05s(configure2.58s)ctest --preset release -R 'gfx1013_buffer_atomics|compute_store_aot_mubuf_reduction' --parallel 4 --no-tests=error --output-on-failure): 6/6 passed (10.05s:compute_store_aot_mubuf_reduction_x2_hardware8.07s,compute_store_aot_mubuf_reduction_warp8.07s,compute_store_aot_mubuf_reduction_x2_warp8.12s,compute_store_aot_mubuf_reduction_hardware8.14s,compute_store_aot_gfx1013_buffer_atomics_hardware1.43s,compute_store_aot_gfx1013_buffer_atomics_warp1.42s)tests/compute_buffer_atomics_check.pyok (0.6s),tests/compute_entry_layout_check.pyok (0.2s)sccache: 168/224 hits; wall56.0sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T21:39:41Z.
Post-merge audit of
8f045aee: seven mutations of the DWORD buffer atomics, all caughtReading this as a coverage statement about
main, not a review request.Eleven ops with the scalar-offset, glc/non-glc, alignment, modifier and descriptor dimensions crossed is the right shape
for a table-driven lowering: the table is where a wrong entry hides, so the fixture walks the table.
buffer_atomic_sminlosessigned(Min, True→Min, False)buffer_atomic_substops negating (is_sub True→False)cmpswapwith glc: compare/replace swapped (words[1], words[0]→words[0], words[1])cmpswapwithout glc: same swap inInterlockedCompareStorecmpswapdata VGPR count 2 → 1InterlockedExchangeloses its output operandif self.kind != 'cs': raise)The two
cmpswapswaps matter most: RDNA 2 puts the replacement invdata[0]and the compare invdata[1],while HLSL takes compare first. Getting that backwards compiles and runs, and silently stores the wrong value — the
fixture catches both the glc and the non-glc form, which are different HLSL intrinsics.
The
InterlockedExchangeone is a nice second-order guard: the comment says HLSL's form always requires an outputoperand, so dropping
aois a compile error rather than a logic error — but the fixture still catches it, meaning itcompares the emitted call text rather than only whether translation succeeded.
A correction about my own run, since it changes what the numbers mean
My first pass used
tests/compute_buffer_atomics_check.pyand reported five survivors. That is a different,pre-existing fixture, registered with
--draw <dxc>against the desktop device — it exited 0 on the no-argument runfor its own reasons and never touched the paths I mutated. The file this PR adds is
tests/startup_compute_buffer_atomics_check.py. Re-run against it, all seven are caught as shown above.Two near-identical filenames in one directory is the trap; I should have matched the name from the PR's own file list
rather than from a
Select-Stringforbuffer_atomic. Recording it here because a "survived" list from the wrongfixture reads exactly like a coverage gap.
AI-assisted; pure Python, Windows 11 build 26300, no DXC or GPU for the rows above.