feat(agc): opt-in bindless image heap for sampled image tables, with its review fixes #28652
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28652"
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 17bryen on 2026-12-02T13:30:58Z.
What
The opt-in bindless image heap of #20519 (
APS5_BINDLESS_IMAGES=1, off by default), brought up to currentmain, plus a fix for each defect found in it so far.#20519 has conflicted with
mainsince 2026-11-29, and #28470 and #28487 are built on it. Most of the defects below turned up in my review of #20519 and while testing those two PRs; the list grew too long to keep passing along in comments. The heap's 22 commits are unchanged and keep their authors and co-author lines (@slopezjur's port of theyotei/bestheap by @Celegans12, with the key table of @fable-void and @EagleBearerYS, @hritikutekar's work, and @Scramblrrrr's test commit). #20519's description is the reference for what the heap is and how it is laid out. This PR closes if #20519 is updated to cover the same ground.Merge order: #20519 agreed with @EagleBearerYS to land after #9457, #9633, #9749, #9790 and #9969, which change the same files; the conflicts resolve by keeping both sides. Those five are now carried by @mrfelek's #28483 (#9457), #16472 (#9633, #9749) and #16812 (#9790, #9969). I am keeping the order the original authors agreed and marking it against the PRs that carry it now. This PR does not use their code. Whichever side lands second also renumbers the shader disk cache format.
On top of those commits: two merges of
main(the second atfc294cbbb53) and 31 commits of mine.Defects where the heap did something
main's per-draw path does not:mainrefuses it since #27295. This was the one failing test on #28470 and #28487 (agc_driver_image_table_bindless).mainfaults on it.mainrecords under EXEC.Defects in the heap's own bookkeeping:
DeviceImageKeys::Retainthrew on a probe cluster that wraps the table end.[bindless]frame line was printed under the GPU mutex.APS5_BINDLESS_STATStwo different ways; an unused include.Device limits:
maxUpdateAfterBindDescriptorsInAllPoolsis smaller could not start with the heap on. The arrays now shrink to fit.Tests and build:
Claims I checked and found not to be defects: a probe reused across a store (the per-draw path is a draw-time snapshot and sees no in-shader store either);
NonUniformdropped in single-subgroup compute (one image instruction reads one T# for the whole wave); the timeline-semaphore fixture; a shadowed test member.Known gaps, in the debt fragment
docs/dev/debt/changes/perf-agc-bindless-heap-gaps.md:APS5_BINDLESS_LAZY=1, per-use entries a lazy table reads are refreshed only at present.Also known, outside that fragment:
main's per-draw path (in #20519's fragmentperf-agc-bindless-heap.md). #28090 and #28321 would make the per-draw path accept it; neither has merged, so the heap side is a follow-up.What stays on the per-draw path with the heap on is #20519's list (storage image tables, nested tables, packed and BY table loads, fetch shaders and mesh pipelines) plus one case
15ef82568fdadds: an image from a table that is sampled with an S# from a nested sampler table.Tested
Windows 11, WinLibs GCC 15.2.0 (MinGW-w64), Release (
-O3 -DNDEBUG -g), Ninja, NVIDIA GeForce RTX 5090 (driver 617.14) and AMD Radeon integrated graphics of a Ryzen 9 9950X3D (driver 26.11.2), validation layer 1.4.363.1.Head
a3a4c7a6274andmainfc294cbbb53, built on the same machine (the AMD row of this PR ran at3ab766e3afa, which differs only by a debt-fragment commit and the test-definition commit), withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ctest --test-dir <build> -R '^(agc_driver_(texture_service|bindless|image_table|storage_flush_ordering|heap_device_replacement|nested_sampler_table)|agc_device_image_keys)' -j1 -V --timeout 300:VUID-mainfc294cbbb53, RTX 5090mainfc294cbbb53, AMD integratedAPS5_BINDLESS_IMAGES=1set for every test, RTX 5090APS5_BINDLESS_LAZY=1also set for every test, RTX 5090was not found but was requested by env var VK_INSTANCE_LAYERS.maindoes not have them. From #20519 (11):agc_device_image_keys,agc_driver_bindless_flag_off,_flag_on,agc_driver_bindless_table,agc_driver_bindless_images_heap,agc_driver_image_table_bindless,agc_driver_image_table_runtime_address,agc_driver_texture_service,_driver,_flag_off,_flag_on. Added here (9):agc_driver_texture_service_interface_ids,_resident_rewrite,_replace_failure,_unmapped_table,_per_use_gain,_one_dimensional_array,agc_driver_heap_device_replacement,agc_driver_heap_device_replacement_heap,agc_driver_nested_sampler_table_bindless.agc_driver_image_table,_array_views,_cache_bounds,_reuse,_variantsand the ten_reuse_*modes) unsetAPS5_BINDLESS_IMAGES, asagc_driver_bindless_imagesand the flag-off tests already did, and the heap tests that compare the first sample with the per-draw result (agc_driver_image_table_bindless,agc_driver_bindless_images_heap) unsetAPS5_BINDLESS_LAZY, under which the first sample reads null by design. Before those pins the checks failed 14 and 17 tests, all on those assertions.agc_driver_image_table_bindless(the one failure at #20519's head merged withmain);agc_driver_texture_service_interface_ids;_resident_rewrite; failed replacement:_replace_failure; table unmapped at priming:_unmapped_table;Retain:agc_device_image_keys;_per_use_gain; 1D arrays:_one_dimensional_array;agc_driver_heap_device_replacement_heap;agc_driver_image_table_bindless(each run without its own fix);agc_driver_bindless_table(device lost without it);agc_driver_bindless_table("the heap pool reserves 5306896 descriptors on a device whose update-after-bind pools hold 1048576").agc_driver_nested_sampler_table_bindlessfailed with invalid SPIR-V before the fix was written, log not kept) and the per-stage limits (the capacity test uses the new reservation API, so it cannot build without the fix; the old sizing's arithmetic is in the commit message).python tools/check_conventions.pypasses.tools/pr_overlap.py --branchfails closed and lists 206 open PRs; I compared each against the functions my commits change. The one overlap isDeviceImageKeys::Retain(Graphics/src/DeviceImageKeys.cpp): #7642, #10193, #13928 and #13929 carry the same file as #20519, without the wrapped-cluster fix (#20519 replaces #10193, #13928 and #13929 by agreement in #675). #22424 is a copy of #20519's series plus one commit that touches none of these functions. The rest share files only, in different functions or in shared declarations.^(agc_|shader_)sweep, Linux, Intel GPUs, and any title. My PPSA38500 boots with the heap were on earlier heads with #28487 on top, not on this head.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T13:33:51Z.
Review: COMMENTED
Reviewed — no blocking findings
The sampled implementation sections showed no verified blocking defect, but the full change was not reviewed and no formal decision is justified.
What I ran
Reviewed head
a3a4c7a6274f8e198b1a50dafafa7445731e1d4d. Read the review description, commit list, manifest, and files list; usedrepo_read.pyto inspect selected ranges ofDeviceImageKeys.cpp,DescriptorHeap.cpp,BindlessTable.cpp, andTextureService.cpp. No build or tests were run.Results
Findings
Blocking
None verified in the sampled code.
Non-blocking
The review is incomplete; the remaining changes need inspection before a formal approval decision.
Sources
No behavior claims beyond the inspected code are made.
Not verified
The remaining 75 of 79 changed files were not reviewed. The four inspected implementation files were read only in selected ranges.
files.jsonlists no files excluded by rule; 15 changed files lack full text in the review folder and must be read throughrepo_read.py. No tests, build, platform behavior, or console behavior were verified.To get this to a good state
Nothing is required from the author. A complete review is needed before approval can be justified.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T13:46:19Z.
Review: COMMENTED
Actionable comments
core/libs/prx/libSceAgcDriver/Graphics/src/BindlessTable.cpp, lines38· 🎯 Functional Correctness · ⚡ Quick winAPS5_BINDLESS_RING_RECORDS=64kpasses validation and allocates a 64-record ring.std::strtoullreads the numeric prefix, but this call discards the end pointer. Check that the conversion consumed the entire value before applying the range and power-of-two checks.core/libs/prx/libSceAgcDriver/tests/BindlessTable.cpp, lines489· 🎯 Functional Correctness · ⚡ Quick wingpuTests()then fails at the late allocation before it can check publication ordering. It also needs another slot while the retired slot is still pending. Pass the peak slot requirement to the fixture, including slot zero and the two extra slots. If the device cannot meet it, report that the workload does not fit before allocating descriptors.core/libs/prx/libSceAgcDriver/tests/DeviceImageKeys.cpp, lines161· 🩺 Stability & Availability · ⚡ Quick winExpect()continues. The next assertion readsdecoded.misses[1]out of bounds. Add a short-circuit size check before accessing the record, as in the distinct-record assertion below. The test can then report the decoder regression without crashing.core/libs/prx/libSceAgcDriver/Graphics/src/DescriptorHeap.cpp, lines39· 🩺 Stability & Availability · ⚡ Quick winDeviceCapacitiescaps the sampled and storage counts at theirAbislot counts (lines 40 and 42). It caps the sampler count only by the descriptor limits andmaxSamplerAllocationCount(line 39). A driver that reports large sampler limits can therefore produce more thanAbi::SlotMask + 1(2^20) samplers.Unfitaccepts any count above 1, so the flag is not rejected. The constructor then fails its packed-slot check at line 62. Bring-up builds theBindlessTablewithout checking this bound, so the device creation path fails. It does not fall back to the per-draw path as theUnfitfailure does.Suggested fix
core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp, lines3166· 🎯 Functional Correctness · ⚡ Quick winEmitBindlessAccessrecordsInvalidDescriptorwhenexecis true, even though the lookup returnsBindlessNull. The per-draw path gates sampler faults on a live image. Keep image and sampler invalidity separate, and gate the sampler fault on the image being live. Continue to report the same sampler fault when the image is live.core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp, lines3777–3778· 🎯 Functional Correctness · 🏗️ Heavy liftquadDivergentImplicitLod, a pixel-stageImageSampleRaworImageQueryLodcan take the bindless quad path while valid lanes in the same quad select different resident descriptors.BindlessQuadUniformonly checks the bindless and pixel-stage conditions and quad-group support.BindlessQuadSelectorkeeps each valid lane&`#39`;s own selector, so only invalid lanes are replaced by a neighbour. The implicit derivatives and LOD for those lanes are then undefined under the Vulkan texture rules.quadDivergentImplicitLod. Otherwise, the sampling of divergent valid lanes must use a defined behavior. The required behavior is not established by the inspected source, so this comment does not prescribe a specific code change.core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp, lines3159· 🎯 Functional Correctness · ⚡ Quick winreadPointerreturns zero words.probe.imagethen holds the same zero-derived address in every failed lane.probe.uniformcan therefore be true even when the recording reads recover different pointers. AtSpirvImageEmitter.cpp:3159, only the elected lane records its miss. Another lane with a different descriptor key can miss and remain unrecorded, so its texture can stay unresolved while the same read failure persists.core/libs/prx/libSceAgcDriver/Graphics/src/TextureService.cpp, lines135· 🎯 Functional Correctness · ⚡ Quick winAPS5_BINDLESS_COMMIT_CHUNK=4294967296passes the lower-bound check and becomes zero when cast touint32_t. The worker then selects the prepared table on every pass without consuming any keys. A draw can still finish priming synchronously, but background priming makes no progress. Reject values aboveUINT32_MAXbefore casting. Preserve positive in-range values and the default of 256. (raw.githubusercontent.com)core/libs/prx/libSceAgcDriver/tests/TextureService.cpp, lines709· 🩺 Stability & Availability · ⚡ Quick winWaitPrimedcall can wait 60 seconds before reporting the failure. The registered test allows 120 seconds, so CTest does not enforce the repository&`#39`;s shorter limit. Give each primer check a deadline that leaves time for fixture setup and cleanup. Split or shrink the aggregate test if needed. (raw.githubusercontent.com)core/libs/prx/libSceAgcDriver/tests/cmake/agc_split_table_call_tests.cmake, lines13· 🎯 Functional Correctness · ⚡ Quick winAPS5_BINDLESS_LAZY=1, this registration preserves it. Lazy mode skips priming and returns null descriptors for unresolved keys. However,RunSplitchecks the first direct execution againstExpectedHeap, which includes nonzero texture values. This causes a false test failure. (raw.githubusercontent.com)APS5_BINDLESS_LAZY=unset:toENVIRONMENT_MODIFICATION, as the heap materialization test does. Preserve the WindowsPATHmodification.core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, lines838· 🎯 Functional Correctness · ⚡ Quick winBDA access failedpasses this assertion.Faulted()checks only forimage table:. For example, the wrapped-key test at Line 1144 makes no other assertion on that dispatch. Require the absence of both fault markers in this branch. Keep the separateunmappedbranch for cases that require a BDA fault.core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, lines2217· 🎯 Functional Correctness · ⚡ Quick win!tabled.bindlessHeapandtabled.sampledTableBinding, including when the device has the heap enabled. Also give the two image records distinct texel marks so the fixture detects selection of the wrong record.core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, lines971· 🎯 Functional Correctness · ⚡ Quick winAPS5_BINDLESS_IMAGES=1, these assertions are skipped even for the direct T#/table S# arm. That arm still uses a sampler-table snapshot, as the point-copy check forTableSamplerCodeat Line 1271 expects. If its snapshot omits the inactive sampler, the active texels can still match and the regression passes unnoticed. Gate snapshot-only checks on the compiled outcome&`#39`;sbindlessHeapflag, not the process setting.docs/dev/ENVIRONMENT.md, lines159· 🎯 Functional Correctness · ⚡ Quick winAPS5_BINDLESS_RING_RECORDSholds, the extra misses are dropped and not recorded. Those keys are absent at the present that ends the frame. Their draws in the next frame miss again, so they read null for at least one more frame. The one-frame wording holds only when the miss ring has room. Qualify the claim in this row.docs/dev/debt/changes/perf-agc-bindless-heap.md:5, qualify the sentence "APS5_BINDLESS_LAZY=1reads null until the frame after a first miss" in the same way.Suggested fix
core/libs/prx/libSceAgcDriver/Graphics/src/BindlessTable.cpp, lines250–252· 🚀 Performance & Scalability · ⚡ Quick winTakeMisses()owns the pending vector after the exchange. End the lock scope there.DistinctDeviceImageMisses()can then process the detached records without blockingdrain()orPublish()on the ring mutex. This preserves the first record per key and leaves newly drained records for the next call.core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, lines3238· 📐 Maintainability & Code Quality · ⚡ Quick wincore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp, lines6852–6854· 🗄️ Data Integrity & Integration · ⚡ Quick winHeapDescriptorSet, butcapture.setscontains only set 0.ReplayComputePipeline()rebuilds its layout only fromcapture.sets. The capture therefore cannot reconstruct the pipeline layout used by the captured shader.be75c346-2f2a-425c-8d2b-4754287312bbReviewing files that changed from the base of the PR and between
fc294cbbb5anda3a4c7a627.core/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Presentation.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/BdaResources.hppcore/libs/prx/libSceAgcDriver/Graphics/include/BindlessResolvers.hppcore/libs/prx/libSceAgcDriver/Graphics/include/BindlessTable.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/DescriptorHeap.hppcore/libs/prx/libSceAgcDriver/Graphics/include/DeviceImageKeys.hppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestTextureResource.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Shaders.hppcore/libs/prx/libSceAgcDriver/Graphics/include/TextureService.hppcore/libs/prx/libSceAgcDriver/Graphics/src/BdaResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/BindlessResolvers.cppcore/libs/prx/libSceAgcDriver/Graphics/src/BindlessTable.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DescriptorHeap.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DeviceImageKeys.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestTextureResource.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/PipelineJournal.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderAddressResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cppcore/libs/prx/libSceAgcDriver/Graphics/src/TextureService.cppcore/libs/prx/libSceAgcDriver/tests/BdaContracts.cppcore/libs/prx/libSceAgcDriver/tests/BindlessTable.cppcore/libs/prx/libSceAgcDriver/tests/DeviceImageKeys.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/TextureService.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_device_image_keys_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_bindless_images_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_bindless_table_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_heap_device_replacement_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_pipeline_journal_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_texture_service_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_split_table_call_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/BindlessImages.cppcore/libs/prx/libSceAgcDriver/tests/execution/HeapDeviceReplacement.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/libs/prx/libSceAgcDriver/tests/execution/PipelineJournal.cppcore/libs/prx/libSceAgcDriver/tests/execution/SplitTableCallRun.cppcore/libs/prx/libSceAgcDriver/tests/shaders/BindlessLookup.compcore/shader/recompiler/BdaAbi.hppcore/shader/recompiler/BindlessImageAbi.hppcore/shader/recompiler/CMakeLists.txtcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/DeviceImageTableAbi.hppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ProgramMetadata.hppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceTracker.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvImageEmitter.hppcore/shader/recompiler/SpirvBackend/src/SpirvEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvDescriptors.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cppcore/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cppdocs/dev/ENVIRONMENT.mddocs/dev/debt/changes/perf-agc-bindless-heap-gaps.mddocs/dev/debt/changes/perf-agc-bindless-heap.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Pull request closed