fix(agc): release texture cache entries before a budget-full allocation goes to host memory #13064
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13064"
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 milescoviello on 2026-10-30T00:06:19Z.
What
Context::DeviceMemoryTypepicks the memory type for textures, storage textures, device buffers, resident heap mirror slabs and the presentation scaler's images. WhenVK_EXT_memory_budgetreports the device-local heap without room for the allocation, it places the allocation in a host memory type up front. A driver refusal (VK_ERROR_OUT_OF_DEVICE_MEMORY) gets a recovery first: the buffer pool trims, the texture caches release what they can, and the allocation is retried. The budget path skipped that recovery, so a full heap sent every new storage texture to host memory while the sampled texture cache still held reclaimable entries.Ghost of Tsushima (PPSA02225) on a 12 GB RTX 4070 Ti hits this in its opening. The device-local heap sits at its budget (10,511 of 10,511 MiB), and
[gpu] storage texture: device-local heap 0 uses ... of its ... MiB budget, ... placed in host memoryclimbs to 512 allocations and 7,098 MiB, with notexture caches releasedline in the whole run. On Linux NVIDIA that host memory is pinned and outside the title's cgroup, so the run ran the host out of memory 423 s in.How
When the budget has no room and a host type is allowed,
DeviceMemoryTypecalls the context'scacheReclaim(ReleaseTextureCaches, as an image allocation) for the allocation's size plus what the heap is already over its budget:[gpu] ... placed in host memoryline.Without
cacheReclaim(DeviceMemoryFallback's mock contexts, and any context that doesn't set it) nothing changes.docs/user/USAGE.mddescribes the step next to the refusal recovery.Tested
Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09). Tests ran at
c7d9fc8fa5, this change onmaindc38224141. The head here,e2c1c305ff, is the same commit rebased ontomain438cebf361; the PR files didn't change.At this head
e2c1c305ff:main438cebf361vse2c1c305ff: 8 of 8 pass on each side, with noVUID-messages and no missing-layer message. The sampled-cache fixture created 4 Vulkan devices on each side.main1a217758a5is clean.At
c7d9fc8fa5:agc_device_memory_fallback, with a mockcacheReclaimthat records what it was asked for and can lower the reported usage:maindc38224141(73e3f30de7) failsagc_device_memory_fallback:caches release the whole allocation: chose memory type 0, expected 1, and the caches weren't asked.^agc_device_memory_fallback$|^agc_buffer_pool|^agc_driver_sampled_cache|^agc_sampled_cache(9 tests) pass 3 of 3.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_buffer_pool|^agc_driver_sampled_cache|^agc_sampled_cache' -V),maindc38224141vsc7d9fc8fa5:VUID-messages on either side, and no missing-layer message.Ghost of Tsushima (PPSA02225 02.024.000), 30-minute runs on my GoT test stack. These are supplementary: they aren't a matched pair, and run 48 also has GPU-heap and other local fixes.
texture caches releasedlinesThe driver still refused device-local allocations in run 48, and the refusal path placed 20,770 MiB in host memory over the run (cumulative; those allocations are released and made again).
Windows 11 VM (GeForce GT 1030, WinLibs GCC 15.2, Release): the same 9 tests pass 3 of 3 at
c7d9fc8fa5and onmaindc38224141.#12786 (mine, open) changes the refusal-path recovery to keep the current present's storage images when the allocation can go to host memory. This path calls the recovery the way
main's refusal path does today. With #12786, this call should keep those images too; whichever lands second can add that.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 MarcZX10 on 2026-10-30T00:12:28Z.
Review: COMMENTED
Re-checked — new head, GPU validation pending
The current head is source-reviewable and merges cleanly, but the available GPU tests were run on an earlier commit and the author says an exact-head rerun is pending.
What I ran
Reviewed exact head
e2c1c305ff5b03074a56ee7def28a639af862a82against currentmain39fc186c978aa6332538fb1101d1722124979ab5; the merge preview was clean atb1b8d5409e947d7079514b84dc25c39b4b5682e2. Environment: Debian Linux x86-64, Python 3.11.2; no compiler or build was run.Results
DeviceMemoryTypecall sites and the cache reclaim callback's lock/reentrancy guards.The PR description reports the focused fallback, buffer-pool, and cache tests plus validation-layer runs on
c7d9fc8fa5, with a rerun on this rebased head still queued. I could not independently confirm that earlier commit's test source against the current head.Not verified
I did not build or run the GPU tests or a game locally. Exact-head Linux/GPU test results, Windows validation, and physical-console behavior are not yet available to me. The reported Ghost of Tsushima comparison is explicitly not a matched pair and includes other fixes, so I treated it as supplementary rather than causal proof.
To get this to a good state
Please add the queued focused-test results for this exact head. I will re-check the same source and integration points when the results or head change.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T01:48:08Z.
Review: APPROVED
Reviewed — looks good
The exact-head source review and the author-reported Linux GPU results support this change; no blocking issue remains.
What I ran
Reviewed head
e2c1c305ff5b03074a56ee7def28a639af862a82against PR base39fc186c978aa6332538fb1101d1722124979ab5; no local build or test was run. The hosted Windows workflow passed its job, but its product build and test-selection/test-run steps were skipped.Results
Not verified
I did not independently run the GPU tests, build the project, or test console behavior. The focused GPU and validation results above are author-reported.