fix(agc-driver): size the storage image cache from the device's reported memory budget #5483
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5483"
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 ee6aba54 on 2026-10-13T20:58:11Z.
What
The storage image cache keeps a quarter of the largest device-local heap (4 GiB on a 16 GiB card) regardless of how much of that heap the driver reports as usable through
VK_EXT_memory_budget. With a desktop and other processes the reported budget on a 16 GiB card is about 10 GiB; the cache stayed full at 4 GiB next to the 2 GiB staging pool and the title's own allocations, and after minutes of a cutscene a 20 MiB device buffer allocation failed withVK_ERROR_OUT_OF_DEVICE_MEMORY, which ends presentation.The storage image cache budget is now the smaller of that quarter of the heap and a quarter of the reported budget, at least 512 MiB, read once per second like the sampled texture budget. A card whose budget is below 8 GiB therefore gets a cache below the 2 GiB that
mainkeeps (6 GiB of budget: 1.5 GiB).APS5_TEXTURE_CACHE_MIBstill overrides it, and the budget report line names the storage budget in use.Tested
0aa4cb1c2.agc_driver_graphicsgainsstorageTextureBudgetTests: without the extension or with a zero budget a quarter of the heap, a 10 GiB budget gives 2560 MiB, a 6 GiB budget gives 1536 MiB, a 1 GiB budget keeps the 512 MiB floor, a budget above the heap size stays at a quarter of the heap, no device-local heap keeps 2 GiB.mainended after 4 to 6 minutes withvkAllocateMemory device buffer: allocation=20971520 ... Vulkan result -2at a heap usage of about 8.2 GiB (4074 MiB of it cached storage images); with the change a 15 minute run through the menu into the cutscene stayed below 6.6 GiB and completed, the storage cache holding 2.5 GiB. Evictions that had to store pending results (cache evictionon the[storage]write-back line): 1 in the 2.5 minutes amainrun lasted, 45 to 49 per 15 minute run with the change (0.4 to 0.8 GB), next to 6 GB ofstorage refreshwrite-backs in the same runs.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 CnRJay on 2026-10-14T01:02:41Z.
Review: COMMENTED
Using
VK_EXT_memory_budgethere is the right signal. The heap size says nothing about what the process can actually use next to the desktop and other applications.Two things to consider:
main. Only cards with a budget above 8 GiB see a lower cap. The OOM described here (cache + 2 GiB staging pool + title allocations > budget) is more likely on 6–8 GiB cards than on the RTX 5080 where it was seen. Scaling the floor down with the budget, or dropping it when the budget is small, would cover them too.heapBudgetand take their own share, with no view of what the others hold. Together they can still exceed the budget. Not necessarily for this PR, but a shared accounting point (one budget reader that each cache asks for its share, reporting total use in the[gpu]budget line) would keep #4472 and this from fighting, so whichever lands second should probably be built on the other.One run-time cost to watch: a lower cap means more evictions. Evicting a storage image with pending results forces its write-back, a GPU→CPU round trip. In the PPSA15304 cutscene run, the count of evictions that had to write back (if the
[gpu]storage cache line reports it), before and after, would show whether the lower cap costs frame time.Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-14T10:10:53Z.
Thanks, both points taken.
64ffeb8c9lowers it to 512 MiB, so the cap applies on small cards too: a 6 GiB budget now gives 1.5 GiB instead of the 2 GiBmainkeeps, a 1 GiB budget 512 MiB. The test and the description are updated.heapBudgetwithout seeing each other. I would make that a follow-up that lands on whichever of #4472 and this one merges first: one budget reader that hands out the shares and prints the total on the[gpu]budget line. The staging pool is the next consumer I have locally (an eighth of the reported budget instead of an eighth of the heap) and would go into that follow-up.cache evictionon the[storage]line) were 1 in the 2.5 minutes amainrun lasted before the OOM, and 45 to 49 per 15 minute run with the change (0.4 to 0.8 GB), next to about 6 GB ofstorage refreshwrite-backs in the same runs, so the lower cap is not what costs frame time there. Added to the description.AI-assisted: yes