AGC: the resource cache's 1,024-entry bound pins storage images past their budget until device memory runs out #3256
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 SleglJan on 2026-10-11T03:38:49Z.
What
ResourceCache::Insert(core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, around line 2486 onmain961b25fe) bounds the cache by entry count only: 1,024 entries by default,APS5_RESOURCE_CACHE_ENTRIES. Its comment says the entries "pin their textures and storage images past the texture caches' budgets". The storage-image cache evicts at its own budget (2,560 MiB on a 10 GB card). An image it evicts stays alive, though, while a resource-cache entry references it. When that entry is looked up again, its check fails because the image was evicted, and the entry is replaced. But entries whose key never comes back, for example a draw at an old extent, keep their images until the 1,024-entry bound pushes them out. No budget counts those pinned bytes. They only shrink the sampled-texture budget (which subtracts the heap's other use) down to its 2,048 MiB floor.When a title keeps producing new storage images, the pinned set grows until
vkAllocateMemoryfails. Two examples of new images are different extents from dynamic resolution, and surfaces at new addresses. The failed allocation throws: inTexture.cpp(theCheckaftervkAllocateMemory) for a storage texture, and inResources.cppfor a render target. The title stops. Nothing frees cached resources and retries first.Seen with
007 First Light (PPSA11386) on Linux:
APS5_PROFILE_DRAW=1, warm shader and pipeline caches.main, which stops at #2523 row 4/5. On that stack theResourceCache::Insertbound and its comment are the same as onmain.vkAllocateMemory storage texture: Vulkan result -2(VK_ERROR_OUT_OF_DEVICE_MEMORY) after about 110 s, with 1,112 storage textures createdAPS5_NO_DRAW_RESOURCE_CACHE=1vkAllocateMemory render target: Vulkan result -2after about 89 sAPS5_RESOURCE_CACHE_ENTRIES=64[gpu]budget lines show device-local use rising: 2,919, 4,518, 5,999 and then 6,901 MiB, against aVK_EXT_memory_budgetof about 8,178 MiB. The storage-image cache reaches its 2,560 MiB cap in the last two of those lines.SurfaceKeyincludes the extent, so each step is a new image.Details are in #2523.
Possible directions
VK_ERROR_OUT_OF_DEVICE_MEMORYfor a texture or render target, release the resource cache and the evicted images, then retry once.A test could follow
tests/execution/StorageCacheBudget.cpp, with a dispatch that does get a resource-cache entry, which that test's dispatch doesn't, and a smallAPS5_TEXTURE_CACHE_MIB. It would check that a storage image evicted from the cache is actually destroyed, through aweak_ptr, sinceStorageTexture::FindLiveignores images that are no longer cached.Related:
vkAllocateMemory storage texture: Vulkan result -2in Wolverine, mentioned there as a separate problem and not filed.AI-assisted: yes (Claude Code)