feat(recompiler): implement 64-bit image atomics #896
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/896"
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 boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-06T14:02:37Z.
What
Implement 64-bit integer image atomics.
image_atomic_*with a two-dword data mask (0x3, or0xffor cmpswap) is the 64-bit form of an integer image atomic, and the decoder rejected it withinvalid MIMG data mask.PPSA14632 (LEGO Horizon Adventures, Unreal Engine) updates a 32_32 surface with six 64-bit
image_atomic_umaxin a compute shader during its first frames, and stops there onmain.dataBits = 64.ImageAtomic*64opcodes take and returnU64, read from and written to register pairs as the 64-bit buffer atomics are.atomic64and gets its own descriptor binding range (five bindings after the 32-bit atomic ones), declared as anR64uiimage of 64-bit integers. The descriptor must be 32_32 UINT, SINT or FLOAT. The flag reaches the driver asDescriptorBinding::imageAtomic64and is stored in the shader disk cache.OpImageTexelPointerto a 64-bit texel and the 64-bit atomic opcodes, withInt64,Int64Atomics,Int64ImageEXTandSPV_EXT_shader_image_int64. When the target does not listInt64ImageEXT, recompiling throws64-bit image atomics need VK_EXT_shader_image_atomic_int64.VulkanDeviceenablesshaderImageInt64Atomicswhen the device offers it and advertisesInt64ImageEXT.StorageTexture::Atomic64Viewbinds anR64_UINTview of the surface; storage images are already created withMUTABLE_FORMATandEXTENDED_USAGE, andR64_UINTis in the 64-bit compatibility class ofR32G32_*.Not covered, and listed in TechnicalDebt: 64-bit
image_atomic_inc/decand the float atomics still throw, as does any other access in the same shader to an image it updates with 64-bit atomics.Tested
shaderImageInt64Atomics = true).agc_driver_image_atomics64: each of the 11 operations on 32_32 UINT, SINT and FLOAT surfaces, checking the returned and stored values for every thread against edge cases across the dword boundary (carry, borrow, sign bit, high word deciding min/max). Turning 64-bit umax into umin in the emitter makes it fail. Full ctest: 360/360.OpAtomicUMax %ulongon anR64uiimage,spirv-valaccepts it, and the title runs on to an unrelatedsceAgcCbBranch: null or misaligned address 0x0.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-06T14:25:43Z.
A note on overlaps with open pull requests, for whichever lands second:
decodeImageDescriptorintorejectImage(PoisonReason::InvalidFormat, ...). This PR adds the 64-bit counterpart right before it ("64-bit atomic image descriptor uses an unsupported format"), which should then go throughrejectImagethe same way. #757 also pushesimageAtomic(false)for table images;ShaderResourceshere bounds-checksimageAtomic64, so a table image without an entry is treated as not 64-bit.DescriptorBindingas well, sostatic_assert(sizeof(DescriptorBinding) == ...)inShaderDiskCache.cppneeds the combined size after both land (this PR adds onestd::vector<bool>, 40 bytes).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T08:25:34Z.
Measured all 11 operations (cmpswap with equal and different comparator) on 32_32 UINT/SINT/FLOAT surfaces on RDNA2 hardware (gfx1035) with carry/sign edge rows plus random rows: returned and stored values match this PR's model bit for bit (5760 cells, 0 mismatches). The test passes on RADV and on CI's lavapipe, and fails without the change. Rebased on main (only conflict: the
DescriptorBindingsize assert, now 448, and the newimageUnnormalized/imageSamplerslines next toimageAtomic64); full ctest green after the rebase. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T08:38:39Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL1071Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-07T08:38:48Z.
A second commit makes draws work too. In PPSA14632, a pixel shader with a 64-bit image atomic was rejected by graphics shader validation (
SPIR-V requires unsupported device capability 5016); compute dispatches are not validated this way. The device now recordsimageInt64Atomics, andValidateShadersacceptsInt64Atomics,Int64ImageEXTandSPV_EXT_shader_image_int64when it is set. A test inagc_driver_graphicscovers both capabilities.ctest: 387 of 387 pass.#1074 does the same for 64-bit buffer atomics (
bufferInt64Atomics) and touches the sameValidateShaderssignature; whichever lands second needs a small rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T08:54:06Z.
Re-checked the second commit: graphics validation now accepts
Int64Atomics,Int64ImageEXTandSPV_EXT_shader_image_int64only when the device enabledshaderImageInt64Atomics, and the newagc_driver_graphicscase fails if that acceptance is removed. Full ctest green (387/387) merged onto main. #1074 changes the sameValidateShaderssignature, so whichever lands second needs a small rebase. Merging once CI is green.