Repository navigation
rdna2spirv: guard all image_atomic_* by active lane and add swap/inc/dec - #3559
SweatierKey wants to merge 1 commit into
Conversation
|
Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE; integer atomics): |
|
Automated test:
Same machine and setup as my earlier manual reports. AI-assisted (Claude Code). |
whattheflop
left a comment
There was a problem hiding this comment.
AI-assisted CPU review at 8ca3b786 vs f847748c, complementing the native instruction results above. With initialized synthetic images, 328/328 modules passed Vulkan 1.2 and 1.3 SPIR-V validation. 1,000 CPU executions of the emitted SPIR-V matched the expected texel and VGPR results across 2D/3D, glc, a16, mixed/empty EXEC and CAS retries. Inactive lanes made zero storage-image descriptor-array accesses or atomic memory operations in these head cases.
- Integration with #3187: Git reports one shared translator conflict. In scratch I kept this PR's guarded branch and used #3187's
dynamic_storage_accessfor the image-array access. All 328 modules repeated the CPU/validator results. Both CLI assembler backends reported the required storage feature in 6/6 new swap/inc/dec cases after integration, versus 0/6 on this head. The standalone module validator passed either way, so it does not establish that the Vulkan consumer enables the required dynamic-storage feature. Preserve both changes when the branches are reconciled. - Regression:
find_guarded_texel_blockaccepts the true target of any structured selection, and the CAS tests look for the load/exchange anywhere in the module. An initialized mixed-EXEC test that checks the returned register, image texel and zero inactive-lane memory effects would pin the behavior. Checking only the final texel cannot catch a neutral read-modify-write. - Please record the swap/inc/dec and EXEC rules in the translator contract in
docs/design.md, with the scope of the hardware evidence above.
No GPU dispatches or game data in this review.
|
Independent check on NVIDIA at Environment: Windows 11 Pro 26200, Python 3.15.2, NVIDIA GeForce RTX 3080 (Ampere, 32-wide subgroup), driver 616.92 (Vulkan 1.4.351),
The gfx1036 measurements in the description and the AMD run above cover the hardware question; this adds the 32-wide NVIDIA path plus the whole translator suite, which the targeted runs do not reach. |
8ca3b78 to
9f48a2f
Compare
|
Rebased onto
|
|
Apple M2 / MoltenVK GPU-suite no-regression check of head
AI-assisted. |
Summary
Guard all 2D and 3D storage-image atomics (
image_atomic_*) insideif (active)intools/rdna2spirv.py(matchingimage_atomic_cmpswap,buffer_atomic,global_atomic, andlds_op) and addimage_atomic_swap,image_atomic_inc, andimage_atomic_dec.Claim: #3381 (comment)
Bug & Motivation
Previously in
Gen.image_misc:image_atomic_cmpswapwrappedOpImageTexelPointerandOpAtomicCompareExchangeinside an active-lane conditional branch.add,sub,umin,umax,smin,smax,and,or,xor) executedOpAccessChain,OpImageTexelPointer, andOpAtomic*unconditionally in inactive lanes with a neutral operand (0or0xFFFFFFFF), performing spurious read-modify-writes on image memory and dereferencing potentially uninitialized descriptors/coordinates in inactive lanes.image_atomic_swap(which has no neutral element) andimage_atomic_inc/image_atomic_decwereUnsupported.if op == "image_store":block.Fix
%simages) and 3D (%simages3d) image atomics inGen.image_miscunder oneif (active)branch that enclosesOpAccessChain,OpImageTexelPointer,OpAtomic*, and the optionalglcwriteback, and remove the deadimage_storeblock.vdatawidth (1 VGPR for 32-bit atomics, 2 VGPRs forimage_atomic_cmpswap) so unsupported 64-bit forms fail loudly instead of silently dropping the high dword.image_atomic_swap(OpAtomicExchange) andimage_atomic_inc/image_atomic_dec(reusingGen.atomic_inc_dec_cason%_ptr_Image_uint) for both 2D and 3D images, with/withoutglcanda16.Verification (CPU +
spirv-val, no game data)tests/semantic/test_image_atomics_guard.py(3/3 OK, all 13 ops × 2D/3D ×glc/a16+ bad-width rejections, every module validated withspirv-as+spirv-val --target-env vulkan1.3, checking thatOpAccessChainandOpImageTexelPointersit inside anOpSelectionMerge-guarded block).tests/semantic/test_fspx_rules.py(9/9 OK)tests/test_text_write_line_endings.py(2/2 OK)