shader: lower gfx1030 finite-normal image atomics #1580
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1587"
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 stan495 on 2026-11-24T14:37:05Z.
Summary
Refs #1565
Lower
image_atomic_fcmpswap,image_atomic_fminandimage_atomic_fmaxfor a scalar gfx1030 2DR32_FLOATimage at mip 0 withglcclear. The caller opts into the finite-normal binary32 domain and binds a desktopR32_UINTUAV carrying the original bits. Compare-swap uses bit equality. Min and max use ordered integer keys and a typed compare-exchange loop. The profile excludes zero, subnormals, infinities and NaNs.Verification
Tested clean head
a5633ab6117a97392ba1ea52bd8bfc2cbae2a6b2on parentbe484d0f12aa6e7d6e755cbded6068dd7172a1f4.CTest reported 10 passes, 0 failures and 0 skips. Both float records contain all three forms. The translated shaders matched the CPU reference over all 336 words per case in one- and two-group dispatches. Swapping compare-swap operands changed mip 0, word 32 from
ff7fffffto00800000on both adapters. The ordering and CAS retry mutations also differed first at that word.Windows 11 build
26300.9974, Intel Arc B390 driver32.0.101.8509, Microsoft WARP10.0.26100.9818. The debug layer was unavailable.The LLVM 15 container check passed assembly, disassembly and synthetic-container CLI regressions.
git diff --check origin/main...HEADandgit merge-tree --write-tree origin/main HEADpassed against6aa50eca1d074ededaafc00325c293eda7890f25. A separate simulation applied #1568 and #1576 first and also merged cleanly.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:50:40Z.
Review: COMMENTED
Reviewed commit
a5633ab6117a97392ba1ea52bd8bfc2cbae2a6b2(shader: lower gfx1030 finite-normal image atomics). No defects found.Technical review
tools/compute_store_aot.py):R32_FLOATis gated toimage_uav_mip is not Noneandimage_float_domain == "finite-normal", andIMAGE_FLOAT_ATOMIC_OPS(fcmpswap,fmin,fmax) are isolated from integerimage_atomic_*ops viaimage_float != (op in IMAGE_FLOAT_ATOMIC_OPS).image_atomic_fcmpswap: mapsVDATA(replacement) andVDATA+1(compare) withdmask:0x3toInterlockedCompareStore(dest, compare, value), which matches RDNA2 operand order and is exact on finite-normal binary32 where numeric and bit equality agree.image_atomic_fmin/image_atomic_fmax: maps the sign-dependent keyvalue ^ ((value & 0x80000000u) ? 0xffffffffu : 0x80000000u)so finite-normal binary32 values order asuint, and usesobserved = 0u(outside the finite-normal domain) to seed theInterlockedCompareExchangeretry loop without a typed UAV load.tests/compute_store_check.py): Coversfcmpswap,fmin,fmax, and contendedfmin/fmax, negative controls (missing domain,R32_UINTmismatch, mip != 0, forbidden flags, wrongdmask/register range, missing descriptor), and HLSL mutation checks.Verification
python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so— passed.python3 tests/docs_links_check.py— passed (16 Markdown files, 347 links).python3 tests/bidi_controls_check.py— passed (1255 files).--preset dev,offscreen_check): 49/49 passed (69.60s), includingcompute_store_aot_mimg_atomic_float_warp(4.53s)./O2(--preset release,offscreen_check): 49/49 passed (70.44s), includingcompute_store_aot_mimg_atomic_float_warp(4.83s).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-24T16:56:49Z.
Independent GPU validation
Measured
7ff2fbc1— the review'sa5633ab6plus a merge of upstream main — merged onto main (my merge1e0d9074, tree283d5798, working tree clean). Nothing below is a code change.Environment
10.0.26100.0user-mode)AMD Radeon RX 9070 XT vendor=1002 device=7550, driver32.0.32029.2010(RDNA 4,gfx1201)Microsoft Basic Render Driver vendor=1414 device=008c, driver10.0.26100.9818dev(Debug),debug_layer=unavailableCommands
Observed
The float entries, three runs each: 6 passed, 0 failed, 0 skipped.
Each backend runs the five cases —
fcmpswap,fmin,fmaxand the two contended forms — at one and two groups, ten dispatches. Thegroups=1dispatches report:and the
groups=2dispatches are identical apart from that field. No dispatch reports a mismatch.The first-difference lines your Intel run reports reproduce here, word for word and at the same word:
So the three mutations are still caught on this adapter, not only on the one you used.
Regression
The five-group selection you ran: 10 passed, 0 failed, 0 skipped.
Limits
0x887a002d, SDK component missing), so the run says nothing about D3D12 API validation — only that the readbacks match.gfx1201(RDNA 4). This covers the translated HLSL executing here, notgfx1030hardware.AI-assisted; runs executed locally on the adapter above.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:35:03Z.
Review: COMMENTED
Audit at
head_sha:7ff2fbc178b15030f1af6607b644d83315a6021d(previously reviewed ata5633ab6).Verdict: 0 P1, 0 P2.
Scope
CMakeLists.txt(one newadd_test, test only),README.md(one table row),docs/experiments.md,tests/compute_store_check.py,tools/compute_store_aot.py. Nosrc/, nogfx2hlsl, no.github/.maininto the branch. Against the previous head the only change in the PR's own patch is thersrc2=Noneparameter in thelower()signature, whichmainadded in the meantime; the new parameterimage_float_domainsits next to it.git merge-treeagainstmain(68969ed8): no conflicts.RDNA 2 semantics
image_atomic_fcmpswap: data VGPR holds the new value, the next one the compare value,dmask:0x3. The lowering isInterlockedCompareStore(dest, compare, value), which storesvaluewhen memory equalscompare. For finite normal binary32, numeric equality and bit equality are the same, so the integer compare is exact. Zero and NaN are outside the declared domain, and the domain is a required, explicit argument (image_float_domain="finite-normal").image_atomic_fmin/fmax: keyw ^ (sign ? 0xffffffff : 0x80000000)orders finite normal binary32 as unsigned integers,fminkeeps the value whenvalueKey < oldKey,fmaxwhen>, through anInterlockedCompareExchangeretry loop. The seedobserved = 0is not a finite normal, so the first exchange cannot change a texel in the declared domain and only fetches the old word.R32_FLOATrequires a UAV withimage_float_domainand nothing else may pass it; the float opcodes require anR32_FLOATimage, and the integer opcodes (add,swap,cmpswap, ...) are refused on one (image_float != (op in IMAGE_FLOAT_ATOMIC_OPS)), so an integer add cannot silently be applied to float words.0x00800000,0x7f7fffff,0xff7fffff,+/-1.0and neighbours, plus 120,000 random finite normals): the result equals binary32 min/max in every case.llvm-mc-19 -mcpu=gfx1030assemblesimage_atomic_fcmpswap v[14:15], v[8:9], s[24:31] dmask:0x3 dim:SQ_RSRC_IMG_2D unorm,image_atomic_fminandimage_atomic_fmax(f0 74 ...,f0 78 ...,f0 7c ...). Ongfx1013the same lines are refused by the assembler, matching the PR's gfx1030-only scope.Verified
Limits: Linux x86-64 only. No Windows/D3D12/DXC:
compute_store_aot_mimg_atomic_float_*(draw, wrong-reference and mutated-HLSL checks) were not run for this head.PYTHONPATH=tests:tools python3 -B -c "import compute_store_check as c; c.controls(); c.mimg_atomic_float_controls()"-> OK.python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so-> exit 0 (194 s).python3 -B tests/docs_links_check.py-> 16 files, 350 links OK.git diff --check HEAD^ HEADclean.fcmpswapno longer treated as a compare-swap: Linux controls fail (Unverified image atomic data range or mask).Expected rejection: Unsupported image atomic target or binding).fmincomparison direction flipped.0xffffffff->0x7fffffff.oldKeycomputed with^ 0x80000000uonly.mimg_float_mutationand the reference words), which I could not run; I detected mutations 3 and 4 with my own text-and-emulation harness above. This is how the neighbouring integer min/max forms are guarded as well.git checkout -- .;git status --shortclean.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:49:11Z.
Review: COMMENTED
Independent verification at
head_sha:7ff2fbc178b15030f1af6607b644d83315a6021d.Verdict: 0 P1, 0 P2.
Scope & Semantics
CMakeLists.txt(test-onlyadd_test),README.md,docs/experiments.md,tests/compute_store_check.py,tools/compute_store_aot.py. Clean-room verified; nosrc/,gfx2hlsl, or.github/changes.image_atomic_fcmpswap,image_atomic_fmin,image_atomic_fmaxongfx10302DR32_FLOATat mip 0 withimage_float_domain="finite-normal"):fcmpswapmaps RDNAVDATA(replacement) /VDATA+1(compare) to HLSLInterlockedCompareStore(dest, compare, replacement), valid because numeric equality equals bit equality on finite-normal binary32.fmin/fmaxuse the order-preserving unsigned key transformx ^ ((x & 0x80000000u) ? 0xffffffffu : 0x80000000u)inside anInterlockedCompareExchangeretry loop seeded with0u(outside finite-normal domain, fetching the old word without a typed UAV load).R32_FLOAT, missing--image-float-domain finite-normal, and non-zero mip.Commands Executed
git diff --check origin/main...HEAD— PASSpython3 tests/docs_links_check.py— PASS (16 Markdown files, 350 links)python3 tests/bidi_controls_check.py— PASS (1277 files)python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/x86_64-linux-gnu/libLLVM-19.so— PASScmake --build --preset dev+ctest --preset dev(57/57 passed, includingcompute_store_aot_mimg_atomic_float_warp) — PASScmake --build --preset release(/O2) +ctest --preset release(57/57 passed, includingcompute_store_aot_mimg_atomic_float_warp) — PASStools/compute_store_aot.py(reverted viagit checkout -- .):image_float != (op in IMAGE_FLOAT_ATOMIC_OPS)gating -> caught bymimg_atomic_float_controls()(AssertionError: Expected rejection: Unsupported image atomic target or binding).fmin/fmaxcomparison predicate (<<->>) -> caught bymimg_float_mutationcheck (expected valueKey < oldKey in lowered HLSL).AI-assisted; commands listed were executed locally.