fix(agc): release sampled views after storage eviction #5997
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5997"
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 Ondra97 on 2026-10-14T18:44:21Z.
What
Storage-only cache churn can retain full Vulkan images after storage-cache eviction: cached sampled views still own the evicted image until a later sampled lookup or
TextureCacheUsage()drains the uncached-image queue. The existing lifetime test called that diagnostic before checking expiration, masking the retention.Drain the existing sampled-view cleanup after storage eviction and resource-cache removal, outside the storage mutex. Descriptor resources transferred to the recorder and callers holding a view keep their ownership. The eviction vector also keeps images alive until sampled-cache cleanup has unlocked.
This addresses one concrete ownership problem relevant to the memory pressure reported in Wolverine PPSA03671 #5961, whose bring-up is #5516. It does not establish that the title's entire out-of-memory failure is fixed: its working-set size and other in-flight owners are separate factors.
Tested
I tested on Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs), Release/Ninja, bundled dependencies,
BUILD_TESTING=ON, with Vulkan required.ed835aa76: moving the existing expiry check beforeTextureCacheUsage()fails on the actual GPU withthe sampled texture cache kept the view of an evicted storage image(2.12 s).0x5a5a5a5apixel after eviction; objects expire after the scoped recorder completes.587b63d2a: full default Windows build passed. All 12 targeted Vulkan tests passed (12.40 s): sampled and storage budgets, memory accounting, resource-cache admission/oversized admission/clear, image-table/cache/bounds/reuse, one-slice aliasing and write-back overhang. No GPU tests were skipped; the slowest took 2.73 s.APS5_NO_TEXTURE_HASH=1(2/2, 2.37 s).git diff --checkpassed. I checked the full inventory of 457 open PRs, compared the patches of all 37 that share these files, and ran the repository's overlap checker on this commit. No other open PR implements this cleanup.I have not replayed Wolverine or tested an 8 GB GPU, Linux or AMD/Intel drivers. No cache budget or shader instruction semantics are changed.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in technical debt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-14T19:45:10Z.
Could a maintainer review the lock ordering and resource lifetime changes, particularly preservation of images still referenced by recorded GPU work?
My local Windows build and all 12 targeted Vulkan tests passed, but I have not tested Wolverine. Its latest measurements in #5961 point to other owners as the main source of retained images, so the impact of this cleanup on that title remains unverified.
Could you also trigger the full CI build? A Wolverine test on an 8 GB GPU would help establish its practical impact.
AI-assisted: yes — Codex
Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-14T20:39:19Z.
@Ondra97 I read the change with your two questions in mind, on head
fd9525a2e.Lock ordering: I don't see a problem. The new drain takes
Textures().mutexonly after the storage cache's mutex is released, so the two are never nested on this path. The sampled lookup (cachedTexture) reaches the storage cache throughsampledStorageSourcebefore it takes the sampled mutex. The other places that take the sampled mutex do so briefly (findSampledEntry,TextureCacheUsage,ClearCachedTextures) and don't call into the storage cache while holding it.CachedTableTexturesholds the sampled mutex and then asks the storage cache. That order is sampled before storage, and the new code never holds storage while taking sampled, so it can't invert.Ownership of recorded work:
RemoveImagehands the removedShaderResourcesto the recorder before the drain runs. The drain only erases sampled-cache entries, so a descriptor resource or a view that recorded work or a caller holds keeps its own reference. Theevictedvector also keeps each image alive until the drain has looked it up, whichdropUncachedViewsrelies on to lock theweak_ptr.Wolverine: I ran #5998 alone and #5998 with this PR, 900 s each (numbers in #5998). There's no regression, and no measurable difference in this title: the most evicted-but-alive images at one report were 664 vs 652, and the peak live allocations were 13.9 vs 14.2 GiB. That matches the earlier count in #5961, where almost no survivor was held by a sampled view. So the fix looks correct to me, but Wolverine doesn't show a gain from it.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-14T20:45:58Z.
@tv7 Thanks for reviewing the lock ordering and recorded-resource lifetime, and for both 900-second comparisons. I’ll keep #5997 scoped to the independently reproduced sampled-view retention issue; your results show no measurable Wolverine benefit or regression. Full CI for #5997 is still outstanding.
AI-assisted: yes — Codex
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:13:00Z.
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/tests/execution/SampledCacheBudget.cppL238Some 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/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppImported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-15T17:57:22Z.
Tested on Linux x86-64 (Release build, lavapipe / llvmpipe LLVM 20.1.2), with
fd9525a2emerged into main8cd937e29:SampledCacheBudget.cpppass.Graphics/src/ShaderResources.cpp:agc_driver_sampled_cache_budgetfails withAGC graphics: the sampled texture cache kept the view of an evicted storage image.agc_driver_resource_cache_storage_admissionfails withAGC graphics: the rejected descriptor sets retained an evicted storage image.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T16:33:16Z.
Review: COMMENTED
Reviewed #5997 at
fd9525a2eand compared it with #5998. I do not see a lock-order cycle or a resource-lifetime regression in the cleanup path:cachedStorageTexturereleases the storage-cache mutex before removing shared resources and taking the sampled-texture mutex.cachedTextureobtains its storage source before taking the sampled-texture mutex, andTextureCacheUsagereleases that mutex before reading storage-cache accounting.evictedvector keeps each image alive whileRemoveImageanddropUncachedViewsrun. Resources returned byRemoveImageare retained by the active recorder before the sampled-cache views are erased; descriptor resources and caller-held views therefore keep their images alive for recorded work.The current checks show conventions, eligibility and report passing; platform build jobs are skipped by the current path-filtered workflow. I have not run a full build or a title test, so this is a source review rather than a full-CI result. I see no blocker in the reviewed cleanup change.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:29:59Z.
Checked the diff, the lock order (the new drain takes the sampled mutex after the storage mutex is released, never nested), and ran the area's tests on Linux (RADV):
agc_driver_sampled_cache_budgetandagc_driver_resource_cache_storage_admissionpass with the change and fail withShaderResources.cppreverted, matching @coltken95's lavapipe run. The only failure in the scope,agc_driver_tessellation, segfaults inside the RADV pipeline-library link and is unrelated to this change. Merging once the full Build is green.