fix(agc): count storage images in the recorder's kept bytes #6030
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6030"
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 tv7 on 2026-10-14T19:39:23Z.
What
On an 8 GB card, Marvel's Wolverine (PPSA03671) runs out of device memory a few minutes after it starts presenting, and aborts in presentation with
vkAllocateMemory storage texture: Vulkan result -2(#5961). The storage-image cache stays at its 2 GiB budget, but the title cycles about 5.4 GiB of storage surfaces through it, so the cache evicts and makes images again many times per batch. Evicted images then stay alive, up to 1,873 images (8.3 GiB) at once in the measurements in #5961, and none of them were held by sampled views.They are held by recorded work, and the recorder does not see their size:
cachedStorageTexturekeeps a new storage image in the open batch withRecorder::Keep(entry.texture), so its size never reacheskeptBytes.So
Recorder::BoundKeptBytes(512 MiB per open batch, twice that in flight) never fires for them, and batches keep gigabytes of images alive until they complete.This change adds each image's size to the open batch's kept bytes with
KeepBytes, which counts each image once per batch:use_count()shows that something besides the eviction still holds it.The existing bound then submits and retires batches before they hold that much. Nothing else changes: the cache budget, eviction order and the keep itself are the same.
Tested
Windows 11, RTX 3070 8 GB (driver 617.14), GCC 15.2.0 UCRT, Release.
agc_driver_storage_cache_budgethas a new check: a dispatch that makes a 1 MiB storage image leaves at least that much in its open batch's kept bytes. On main it fails witha dispatch that made a 1 MiB storage image left 0 bytes in its batch's kept bytes, and with the change it passes.9f03c4fe0, andtools/check_conventions.pypasses.--to-intel, 900 s per run:e34c47921: every run without the change aborted a few minutes in with the error above (plain, or with local logging only), with heap 0 usage up to 13 GiB against a budget of about 7 GiB.9811e9d4bplus this change: ran the full 900 s without aborting. 296 storage-texture allocations still failed with -2 and kept the snapshot path, which is not fatal, and heap 0 usage peaked at 8.7 GiB.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryRelated: #5961 (this addresses the device-memory abort; the eviction churn remains).
🤖 Generated with Claude Code
https://claude.ai/code/session_01TGkh749FbEgqQsma2ix7V6
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T19:40:50Z.
Review: COMMENTED
One behavior concern:
KeepBytesruns when the new image is created, while the storage cache still owns it. If this reaches the kept-byte limit, submitting or retiring the batch cannot free that cached image, so cache churn can add backpressure for memory that is not yet releasable. That was the concern raised on #5998.Could the accounting happen when the cache evicts an image that the recorded batch still holds? The
image.use_count() > 1check in the eviction loop appears to cover the case where no sharedShaderResourcesentry references it. A regression test that records an image, evicts it by exceeding the cache budget, and then checksOpenKeptBytes()would exercise the retained-evicted lifetime directly; the current test checks the image while it is still cached.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T19:43:22Z.
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.cppL932Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-14T19:45:53Z.
Closing as a duplicate of #5998 by @MarcZX100, which was opened first and covers more holders. I'll run Wolverine on #5998 and post the results there. If the extra check in
agc_driver_storage_cache_budgetfrom this branch is useful (a dispatch that makes a storage image must leave its size in the open batch's kept bytes; on main it fails withleft 0 bytes), feel free to take it.Pull request closed