Repository navigation
shader: lower gfx1013 image_atomic_add, umax and cmpswap - #2013
Conversation
The gfx1013 profile refused every image atomic. It now accepts add, umax and cmpswap on a 2D R32_UINT UAV at mip 0 and lowers them with the existing gfx1030 image atomic lowering, which emits identical HLSL for both targets. Every other image atomic is refused by name on gfx1013, as are signed and float formats; glc and the other flags stay refused. tests/compute_image_atomics_gfx1013_check.py reuses the gfx1030 cases with the gfx1013 profile: controls pin identical HLSL and the gfx1013 refusals; --binary assembles the programs for gfx1013 with LLVM 15, pins the atomic MIMG dwords and checks they equal the gfx1030 bytes; --draw compares every texel of a three-mip texture on WARP and hardware with one mutant per case that must mismatch. The gfx1030 control that expected gfx1013 to refuse the binding now states the new rule. Refs R0Y00#1545 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ran it, broke it five ways: four caught, one survivor proven equivalent by the function's own domain guardRead on the merge base — your branch is 49 commits behind, so out/pe-env/Scripts/python.exe -B tests/compute_image_atomics_gfx1013_check.py # exit 0Note for anyone else running this:
The survivor is equivalent, not a gapLine 300 refuses any other CPU before this code runs: if cpu not in ("gfx1013", "gfx1030"):
raise ...so inside this function What the gating actually says, and the one thing I would addThree conditions decide whether gfx1013 may use the shared atomic lowering: UAV output, The omission I would fix: nothing states why those three ops and not, say, A cheap version: assert in the check that the tuple is exactly Coverage gap I did not close
Notes
|
Conflicts with R0Y00#2013 (gfx1013 image atomics): tools/compute_store_aot.py keeps this branch's view-dimension checks and UAV type together with main's gfx1013 image atomic flag and descriptor helper; the docs, README, CMake and workflow lists keep both entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @ChazY11. On your two points:
Agreed on the |
Refs #1545
Change
The gfx1013 compute profile refused every image atomic ("Invalid image UAV binding"). It now accepts
image_atomic_add,image_atomic_umaxandimage_atomic_cmpswapon a 2DR32_UINTUAV at mip 0, and lowers them with the gfx1030 image atomic lowering that is already on main. The emitted HLSL is byte-identical for the two targets:InterlockedAdd,InterlockedMaxandInterlockedCompareStoreonRWTexture2D<uint>.Still refused on gfx1013:
sub,and,or,xor,umin,swap,inc,dec), with "gfx1013 image atomics require add, umax or cmpswap";R32_SINTandR32_FLOATformats and a nonzero UAV mip, with "Invalid image UAV binding";glcand the other flags the gfx1030 lowering refuses, so none of these atomics returns a value;The gfx1030 control that expected gfx1013 to refuse every image atomic binding now states the rule above for each gfx1030 case, and checks that the accepted ones lower identically.
Tests
tests/compute_image_atomics_gfx1013_check.pyreuses the gfx1030 cases (mimg_atomic_cases) and references (mimg_atomic_reference) with the gfx1013 profile:umaxandcmpswap; pins for the operation, operand order and unsigned type; and every refusal above.--binary(LLVM 15): assembles the four programs for gfx1013, pins the two MIMG dwords of each atomic (opcode 17, 23 or 16, dmask, unorm, 2D), and checks that the bytes equal the gfx1030 bytes. With--llvmit also checks the disassembly round trip and the container CLI output. CI runs it in the gfx1013 fixtures job.--draw(WARP and hardware):umaxand acmpswapon unique texels.InterlockedMinin place ofumax, andcmpswapwith the compare and replacement reversed.FORM_COVERAGE_RECORD.Verification
Tested
3ff6e9d4from main1ebfe511on Windows 10 22H2 build 19045.6456, MSVC 19.44.35230, DXC from Vulkan SDK 1.4.363.0, with the D3D12 debug layer on (zero warnings and errors).devreleaseThe selection is the new test on both adapters, the gfx1013 image-store tests and the five gfx1030 image atomic suites on both adapters. In Release it adds
docs_links. Adapters: NVIDIA GeForce GTX 1060 6GB (hardware) and WARP. All 16 mutant draws, 4 cases × 2 group counts × 2 adapters, mismatched at the predicted word; for example, add with one group gavemismatches=8on the GTX 1060.Also run locally:
compute_image_atomics_gfx1013_check.pywith no arguments, and with--binaryusing LLVM 15.0.7llvm-mc;compile-mimg-atomic-*modes ofcompute_store_check.py;docs_links_check.py,bidi_controls_check.py,run_checks_parallel_check.py,form_coverage_check.pyandgit diff --check.The
--llvmdisassembly step needs libLLVM, which this machine does not have; CI's LLVM 15 job runs it.Limits
glc) are not covered on either target.umin,swapand the others are lowered for gfx1030 but stay refused on gfx1013 until a gfx1013 draw covers them.tools/compute_store_aot.py, for buffer atomics. The two touch different lines; I'll rebase onto whichever lands first.AI-assisted (Claude Code).