feat(agc): store to images selected through image tables #6402
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6402"
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 Pipodi on 2026-10-15T14:05:16Z.
What
An
IMAGE_STOREwhose T# comes from a runtime-indexed image table used to mark the whole table as an unsupported operation. The dispatch's deferred write-back then failed. This follows #757/#758's table model:AssignTablesnow accepts written, non-atomic table images and gives them storage modes. Atomic, packed, BY2/BY4 and dynamic-mip table stores still fault, as before.STORAGE_IMAGEtable binding (260). The sampled image table moves to 261 and keeps the variable descriptor count. The runtime ABI goes to v14, so existing shader caches are invalidated.RunStoreTestsis now a positive test: a lane stores to the key-1 image, while a null-key store and an EXEC-cleared store write nothing.verifyImageTableRegistrationexpects the bound written elements, a store-only table binds no sampled elements, andimage_store_mip,image_store_pckandimage_atomic_addthrough a table still poison the table with an unsupported operation and bind no storage elements.Native pipeline replay with storage tables, reuse of table layouts across size classes (which also lets storage-table sets back into chain pools), and rejecting the second writer of a depth plane are follow-ups. @Celegans12 will add them on top (#675).
Technical debt
New entry "Image storage tables" in
docs/dev/debt/libSceAgcDriver.md:0x80001e5f00binds the stencil plane0x505f350000as R8_UINT and R8_UNORM);maxPerStageDescriptorStorageImages), and the sampled capacity isn't reduced by it;PresyncSurfaceswalks only the sampled table;Tested
Windows 11, NVIDIA GeForce RTX 4090, driver 617.42.
b7e21ca03(rebased ontomain6e7ba928a), fullBUILD_TESTING=ONbuild: 1364/1366 pass.agc_driver_pixel_lds(vkWaitForFences timeout in the wave64 unbounded case) also fails alone on plainmain6e7ba928a;select_testsfailed in the parallel run and passes alone.d92a8dad3+ #5815 #6060 #6168 #5781 #6227 + local patches; the runs differ only in this PR. Program0x80001e5f00ends with threeIMAGE_STOREs through runtime-indexed tables (pc 0x783c/0x785c/0x7868).image table: shader 0x80001e5f00 stage 4 pc 0x783c ... unsupported operation0x80001e5f00compiles (1,457,658 words, 63 s) and dispatches; workers keep running until ~1240 s0x80001e5f00v2 dispatched with 150-169 storage images bound (resources 108-343 ms); loading continues to the first in-game scene (~25-30 min)The game runs predate the review changes, which affect descriptor pool sizing, minLod rejection and depth-surface retirement for table storage elements.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T14:23:26Z.
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.cppL4236-4253core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL4228-4232, L4236core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppL371Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/RuntimeAbi.hppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/BindingAllocator.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/RuntimeAbi.hppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvDescriptors.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/libSceAgcDriver.mdcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-15T14:45:44Z.
Heads-up on an interaction with #6243 (selecting the record of a T# whose offset the CPU evaluates), which is still open. The two merge without conflicts, but on a merge of both,
agc_shader_bindlessfails: #6243'sselected record direct operationscase expects animage_storethrough a T# keyed per lane to stay an unsupported table operation, and this PR makes that store supported.With that one expectation changed to
TableOperation::Supportedforimage_store(atomics, PCK and BY2/BY4 keyed per lane still fault, as both PRs expect), the merge passesagc_shader_bindless,agc_driver_image_tableand the other shader-memory tests 5 runs in a row on GitHub's Linux and Windows runners.ctest -R '^agc'on the merge fails nothing thatmaindoesn't. A store whose record the CPU evaluates stays a direct binding under #6243; this PR's storage table takes the stores keyed per lane.Whichever of the two merges second needs that one-line test change. If this one lands first, I'll make it on #6243.
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-15T14:58:18Z.
@Pipodi I went through this against our local store work, and the model fits #757/#758 nicely. Keeping one element domain with the storage element in 260 and the sampled one in 261, faulting only on use for poisoned or rejected elements, and never reusing tables with written entries are all what I'd have done. A few things I think need fixing before it goes in, plus some I'd be fine leaving to a follow-up.
The two I'd treat as blocking:
StorageTableCapacitydescriptors (up to 4096), but the pool sizes atShaderResources.cpp:1802still only countplannedStorageImages. The split path (:1741) and draw snapshots count the table, and this one doesn't. NVIDIA doesn't enforce per-type pool counts, so our runs won't show it, but a driver that does will fail the allocation. Once the count is right, a 4096-entry set no longer fits a 1024-image chain pool either, so every build would get its own pool. That's why ours sized 260 from the element count in size classes.Smaller ones:
:4072), so a T# whose minLod clamps above the addressed level gets written anyway. A per-elementrejectTableElementwould match the direct path.cachedStorageTexture(..., guestBytes)(sowrittenis false andRetireDepthSurfacesnever runs) but pushed withstorageWritten = true(:4289vs:4297). The direct path keeps the two in step. Either pass true, or reject elements over a depth surface explicitly.Happy to send the depth-plane part and our two extras (pipeline replay with storage tables, and 260 sized in classes of the element count so 233-element sets stay in chain pools) on top once this settles. I'll run it on Yōtei as part of our next game build.
Details and notes
TableCurrentand can't be reused, which matters with Yōtei's 33k-entry sampled tables. A profile split of your 108-343 ms resource time (lookups vs write-back) would show whether it bites. Per-element written bits from the GPU would be the exact fix later.PresyncSurfaces(:4441-4449) walksImageTableonly and applies the sampled rule to every element, so a store-only table isn't considered.StorageTableCapacityis a heuristic (maxPerStageDescriptorStorageImages / 4, max 4096), andImageTableCapacitydoesn't subtract it, soValidateDescriptorLayoutcould throw on devices with tight limits.:4281-4283). That's fine for 0x80001e5f00 (about 233 elements), but mixed tables with many sampled elements first would hit it.Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-15T15:39:49Z.
@Celegans12 thanks for the careful pass. Pushed 085fa565b on top of a rebase onto current
main:StorageTableCapacityno longer fits a 1024-image chain pool, so those sets get a dedicated pool for now. I noted that in the debt entry. Your size classes of the element count are the real fix, and I'd be glad to take them as your follow-up together with the native replay.verifyImageTableRegistrationagain checks thatimage_store_mip(dynamic mip),image_store_pckandimage_atomic_addthrough a table stayTableOperation::Unsupported, poison the table withUnsupportedOperationso it faults on use, and bind no storage elements. I didn't add BY2/BY4: I don't have a hand-encoded instruction for them that I trust, so if your branch has one, I'm happy to add it.rejectTableElement, the same rule the direct path enforces withRequire.written = true, soRetireDepthSurfacesruns as it does on the direct path.The limits in your details block are in the same debt entry now too, along with the ones I should have listed in the first place: the storage capacity heuristic and that
ImageTableCapacitydoesn't subtract it, the absolute-index rejection,PresyncSurfaceswalking only the sampled table, the dedicated pools, and the untested cases (mixed tables, read+write of one T#, non-uniform storage indexing, non-2D modes). I'd keep the code changes for those out of this PR unless you think one of them blocks.Tested on 9161151ef (rebased onto
main92e50418f): Windows 11, MinGW-w64 GCC 15.2.0, RTX 4090. FullBUILD_TESTING=ONbuild, thenctest: 1294/1294 pass.One thing the new check caught:
image_store_mipthrough a table is still planned asSupportedwithImageMipMode::DynamicStorage, and onlyApplyStaticInterfacerefuses it. So the test accepts either the plan'sUnsupportedor a dynamic mip, and then requires the poisoned map and no storage elements in the compiled result.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T19:30:17Z.
Tested on Linux with lavapipe, the CI device: llvmpipe (Mesa 26.2.4, LLVM 23.1.1), CachyOS, GCC 16.2.1, CMake 4.4.3, default build type, full build with
BUILD_TESTING=ON. Each run used a clean environment (env -iwithHOME,PATH,VK_ICD_FILENAMESandGALLIUM_OVERRIDE_CPU_CAPS=avx).This PR (
9161151efmerged intomain44df21632, no conflicts):agc_driver_image_tableandagc_shader_bindless: pass, 3 runs out of 3.ImageTable.cppusesDescriptorRole::ImageStorageTable, which this PR adds, so the test does not build againstmain's sources.Merged together with #6416 (on
main44df21632, no conflicts): full ctest: 2 of 1269 fail, 57 skipped (the same skips asmain). The two failures are not from either PR:agc_driver_mesh_index_cachesegfaults onmaintoo (and 5 runs out of 5 on the merge).agc_frame_dump_io(from #5800) also fails on plainmain, in 13 of 200 runs on an idle machine:closed pipe pixel write was accepted. Reading the test, its 128×128×4 = 65,536 pixel bytes are exactly Linux's default pipe buffer, so if the reader drains the 54-byte header before the pixel write starts, the empty pipe takes the whole write and it succeeds before the reader closes. Not measured beyond that.Apart from those, the failed and skipped lists match
main's full run.Not tested: NVIDIA, AMD, Intel, PPSA26344.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-16T21:12:19Z.
Data from 007 First Light (PPSA11386 v01.018.000), a title that stores to images selected through image tables in compute.
Setup: Linux 7.2.10, RTX 3080 10 GB, NVIDIA 615.78.08, GCC 16.2.1, Release, bubblewrap sandbox. Stack:
main4186f06a9plus open PRs (#5987, #6553, #6465, #6868 and the image-table PRs #6440 and #6567 among them), unpublished local fixes the title needs, local logging and scripted input, and the title's two feedback-wait limits widened in its executable as described in #6172 (local only). This head's three commits (9161151ef) cherry-picked cleanly onto it. Compared with a run of the same stack without this PR, same save and switches (APS5_HOST_IMPORT_MIB=12288,APS5_RESOURCE_CACHE_ENTRIES=64,APS5_NO_DRAW_SRT_ENTRIES=1, a guest fault dump).Without this PR, the title's compute dispatches fail their deferred write-back at five program sites with
deferred write-back failed: image table: … unsupported operation. The failed fault check also skips that dispatch's CPU write-back of copied buffer results; buffers the GPU writes in place are not affected. That path is the same onmainand this PR doesn't change it. Counts per site, in the same order in every cell; this stack prints the line once per failure:rejected by the driver: the image storage table exceeds its capacity of 4096 images.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-16T21:23:50Z.
Thanks, that's the first run on a title that stores through image tables: four of the five sites going from hundreds of failures to zero is what this PR is for.
You're right about the fifth site's message. It comes from one check in
ShaderResources.cppthat covers two different failures:min(image table capacity, 4096, maxPerStageDescriptorStorageImages / 4), so 4096 on your 3080. The index is the element's position in the whole set: every table element before it in the same set counts, sampled ones included. So a small storage table can still land past 4096 if a large sampled table comes first in the set.The two need different fixes. Case 2 means giving storage tables their own index space; case 1 is a recompiler bug. 0229b5f98 (pushed here) gives each case its own message:
set N has no image storage table, but the shader stores to its table element Ithe stored table element I of set N is past the image storage table's capacity of C imagesIt changes only those messages and corrects the debt entry, which said the index counts within the table rather than the set. It cherry-picks on its own, so a run with it would show which case your eleven failures are.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T06:31:38Z.
Reviewed at 0229b5f98. Looks good. Two small things for your next rebase:
RuntimeAbiv13 (f7b2ebd8b), so the 12 -> 13 bump here merges silently and the binding move (storage table 260, sampled table 261) would ship under the same v13. Could you bump it to v14 when you rebase?agc_shader_bindlessexpectation to Supported.Full CI is running on this head. It'll also go through our game gates before merge.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-17T07:02:11Z.
@oneandonlydean thanks. Rebased onto
main6e7ba928aand bumped the runtime ABI to v14 in the commit that moves the bindings, so no commit ships the 260/261 layout under v13. The description says v14 now.On #6243: agreed. EagleBearerYS offered to make the change on #6243 if this one lands first. If #6243 lands first, I'll flip the
image_storeexpectation inagc_shader_bindlesstoSupportedhere.Tested on
b7e21ca03: fullBUILD_TESTING=ONbuild, thenctest: 1364/1366.agc_driver_pixel_ldsalso fails on plainmain6e7ba928aon this machine (a fence timeout in the wave64 unbounded case).select_testsfailed only in the parallel run and passes alone.AI-assisted: yes (Claude Code)