feat(shader): support 32-bit image atomics through keyed image tables #8792
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8792"
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 SuarezPM on 2026-10-21T00:42:59Z.
What
32-bit image atomics through keyed image tables no longer fault. A T# keyed at runtime feeding
image_atomic_*32now lowers toOpAtomic*on the table'sAtomicViewinstead ofunsupported operation, so compute using bindless UAVs stops dying on the first atomic dispatch. Follows up the stores support from #6402, which left atomics faulting ("Atomic, packed, BY2/BY4 and dynamic-mip table stores still fault").ResourceTracker::AssignTableskeepstableOperationsupported for 32-bit atomics; 64-bit atomics, packed and BY formats still markUnsupported.DescriptorBindingBuilder,ShaderResources), and the table write path bindsAtomicViewexactly like the direct path.docs/dev/debt/shader.mdrewrites the image-table entry: 32-bit atomics supported (Devicescope, relaxed,AcquireRelease/UniformMemorybarrier as the direct path); faulting remainder isimage_store_mip/image_store_pck, PCK2/PCK4, MIMG BY2/BY4 and 64-bit atomics.Tested
Host: Linux x86-64 (CachyOS), Ryzen 5 3600, RTX 2060 SUPER (NVIDIA 615.78.08). No validation layer installed on this host, so no VUIDs could be produced here; full builds run on merge.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T00:50:12Z.
Review: CHANGES_REQUESTED
I found a remaining
StorageViewin the recorded image-table descriptor update path. InShaderResources::buildComplete(), thebinding.flags != 0branch around line 2349 constructsVkDescriptorImageInfowithstorageTextures[index]->StorageView(...)unconditionally. The compact-binding path below it (around line 2394) now selectsAtomicViewwhenstorageAtomic[index]is set, but table descriptors use the recorded branch. Since this PR marks table elements atomic inresolveImageTables(), the table can still be written with the non-atomic view and the new execution tests may fail or trigger Vulkan validation there. Please make the recorded table write use the samestorageAtomic64/storageAtomicview selection as the compact path, then run the image-table tests with validation when available. Hosted GPU/build jobs are skipped on the current PR head, so they do not verify this branch.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T01:05:10Z.
Review: APPROVED
Correction to my earlier review: I misread the recorded table descriptor branch. It already selects AtomicView for atomic entries (and Atomic64View for 64-bit entries in the compact branch); the table image-info construction shown here is correct. I withdraw my request for changes. The PR checks currently pass for eligibility, conventions, intake, labels, and report; build/runtime jobs are skipped, so I have not independently verified the GPU execution claim.
Imported from boykopovar/AnyPS5. Originally posted by SuarezPM on 2026-10-21T02:38:35Z.
Thanks for the careful review and the correction, MarcZX10 — glad the recorded table branch reads correctly on re-read. GPU execution evidence is in the PR body (RTX 2060 SUPER runs); happy to add any extra run you want. Leaving it in the maintainers' queue.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T03:53:27Z.
Windows data point for
a55b76e09merged ontomaina683688fe(clean,git merge-treerc 0): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release.ctest -N -R '^agc_shader_memory$'lists exactly that one test;ctest --no-tests=error -R '^agc_shader_memory$'was run three times per tree.ShaderResources.cpp,ResourceMaterializer.hpp/.cpp,DescriptorBindingBuilder.cpp,ResourceTracker.cpp) restored tomain(the new test cases kept): fails 3 of 3 (ordinary test failure, not a crash).Not tested: the new
execution/ImageTable.cppcases (a GPU test, not run), other platforms, a title run.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T06:33:50Z.
An AMD proprietary-driver run: RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2.0, Release,
ANYPS5_REQUIRE_VULKAN=1.main338f22e49with only this PR'sImageTable.cppandShaderMemory.cpp:agc_driver_image_tablefails withimage table registration: a table T# feeding image_atomic_add was not a supported table operation, andagc_shader_memoryfails too.agc_driver_image_atomicsandagc_driver_image_atomics_floatpass.main338f22e49merged with this heada55b76e09(clean merge): all four pass 3 of 3.ctest -Von the same four:maina07e985c8anda07e985c8+ this head both pass 4 of 4. There are 0VUID-lines on either side, and the layer was inserted in each GPU test process.On the float-record case: integer
image_atomic_addon a 32_FLOAT texel adds the raw bits on RDNA 2, as the test expects. I measured this earlier on the same card through the HIP oracle for #7939: the stored value matched the raw-integer model on all 121 rows, in wave32 and wave64.Imported from boykopovar/AnyPS5. Originally posted by SuarezPM on 2026-10-21T21:23:21Z.
Thanks xXPBSXx and thuanquang — the reverted-to-main control failing 3/3 and the AMD + validation 0-VUID runs are exactly the evidence this PR needed, including the float-record confirmation against your HIP oracle rows. Much appreciated.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T03:14:21Z.
@SuarezPM thanks for the update. The full CI run on a55b76e092 (merged into current main) fails three tests on Linux, and the cause is in this PR:
SPIR-V validation before optimization failed: OpPhi's result type <id> '1[%1]' does not match incoming value ..., e.g.%246 = OpPhi %uint %263 %254 %272 %267 %273 %248.Why it shows up only there: only the Linux CI lane configures with
-DANYPS5_ENABLE_SPIRV_TOOLS=ON(build.yml:511). The option defaults to OFF, so Windows CI and a default local build skip validation, and GPU drivers accept the module. That is why the execution runs on real hardware passed.Cause: before this PR, 32-bit image atomics never reached the keyed-table path, so the table merge in
SpirvImageEmitter.cppcould assume a 4 x u32 result. With atomics now in the table path, the result is a scalar%uint, but the poisoned-element branch still feeds the merge Phi a vector zero:The sampler-guard Phi at :1988 has the same constant.
ZeroResult(ctx, inst)in the same file already returns the right zero for U32, U64 and U32x4, so using it at both places should fix it. To reproduce locally, configure with-DANYPS5_ENABLE_SPIRV_TOOLS=ONand runagc_shader_bindless.Imported from boykopovar/AnyPS5. Originally posted by SuarezPM on 2026-10-22T10:38:38Z.
Fixed as suggested: both merge sites now use
ZeroResult(ctx, inst)(commit on top of current main, rebased cleanly). Reproduced your lane locally withANYPS5_ENABLE_SPIRV_TOOLS=ON:agc_shader_bindless,agc_shader_memoryandagc_driver_image_tableall pass, plus the Turing execution runs. The missing submodule for the new main (3rdparty/vgmstream) was the only rebase friction; no code conflicts.