fix(agc): free released lavapipe descriptor sets #6614
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6614"
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 MarcZX10 on 2026-10-15T23:02:37Z.
What
Fixes #6608. On Mesa LLVMpipe, free each descriptor set when
DescriptorCache::Freereleases it. Chain pools retain their existing reset-on-empty behavior, while other Vulkan drivers keep the current reset-only path. This addresses the measured growth in #6608 for sets that reachFree; sets held in the draw-setRecyclelists are unchanged.Tested
Linux (Debian 12), GCC 12.2, Release. The
agc_driver_graphics_teststarget built.agc_descriptor_cachepassed (1/1), covering the default reset-only path and the LLVMpipe free/reset/reuse path.This container lacks the CPU features AnyPS5 requires, and GCC 12 also rejects a pre-existing dependent-template expression in
SrtDescriptorEvaluation.cpp. For the local run only, I temporarily bypassed the host CPU gate and added the requiredtemplatedisambiguators to that unrelated file. Both edits were restored and are absent from this PR. No Vulkan GPU runtime test was run here; the regression uses the Vulkan mock. The issue report includes a separate measured lavapipe title run with the equivalent pool/free behavior.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T23:07:49Z.
@EagleBearerYS @SleglJan A merge-tree check against the current heads reports content conflicts in
Graphics/src/ShaderResources.cppbetween this PR and both #6454 and #6567. This PR changes the LLVMpipeFreerelease path; #6567 changes recycled-set allocation, and #6454 changes the image-table path. Can we agree on a merge order or a combined resolution? I will update the dependency note once the intended order is clear.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T23:30:10Z.
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/include/ShaderResources.hppL100-101core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL3386core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppL100-101core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppL1127-1132Some 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/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Context.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppImported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-15T23:34:04Z.
@MarcZX100 Here is what
git merge-tree --write-treegives at the current heads: #66140627bc6bdonmain5d9dcc42d, #6567 544e7afb3 onfa9365ca7, and #6454fae2221c4.ShaderResources.hpp/.cppanddescriptorCacheTestsintests/Graphics.cpp, in different hunks:vkFreeDescriptorSetsmember and its initializer in theDescriptorCacheconstructor, the pool flag inAllocateand the free inFree;Allocate, the lookup inAllocateRewrittenand the key inRecycle.recycleddoes not reachFree. A set past the recycle limit goes toFree; with #6567 that limit is per layout and table size. There #6614 frees it on LLVMpipe when it comes from a shared pool.DescriptorCacheconstructor. #6614 adds an initializer there; #6454 adds aKeptSets()helper above it and gives the constructor a body. Keeping both resolves it.Freemerges cleanly: #6454's dedicated-pool path returns before #6614's call. Either order works.ShaderResources.hpp: theSetAllocationmembers and therecycled/keptlines. The other isShaderResources.cpp: the dedicated-pool return inAllocate. Taken together, the two PR descriptions give the resolution:std::optionalvariableCount;Allocate;recycledby layout andvariableCount.value_or(0).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T23:47:15Z.
Thanks for checking the current merge trees and spelling out the resolutions. That confirms there is no semantic dependency for #6614: it composes directly with #6567, and the #6454 constructor conflict is resolved by keeping both the
KeptSets()helper/body and #6614’s initializer. TheFreepaths also compose as described. I’ll keep the “Depends on: none” note and recheck the combined tree if one of these PRs lands or its head changes. The #6567 + #6454 combined resolution is useful too; I haven’t verified that combination with a build, so I’m treating it as a suggested textual resolution pending integration.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-15T23:53:56Z.
Thanks for checking. Between this PR and #6454 the conflict is one line,
DescriptorCache's constructor: #6454 adds aKeptSets()helper above it and akept.reserve(KeptSets() + 1u)body. Keeping #6454's side and adding this PR'sfreeDescriptorSets(...)initializer to its list resolves it; nothing else conflicts. The two don't change the same sets: this PR'svkFreeDescriptorSetscall is on the chain-pool path ofFree, and #6454's kept sets live in dedicated pools, whichFreehandles before that path. So either order works, and whichever merges second takes that resolution. #6454's description also has the resolution for #6567 against #6454.I ran the combination on GitHub's runners, #6454's head
fae2221c47merged with this PR's0627bc6bdeand resolved as above:agc_descriptor_cacheand #6454's tests pass 3 of 3 on Linux (run).One thing from the Windows side:
agc_descriptor_cacheexits with 0xc0000135 (a DLL not found) on the Windows runner, on this PR alone too (run).agc_descriptor_pool_reset_failure, which runs the same executable, passes. The new test isn't in theif(WIN32)set_tests_properties(... ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:...")list next to its registration, which the otheragc_driver_graphics_teststests are in, so adding it there should fix it. Both runs are also marked failed forguest_kqueueon Windows, and the combined one forprecise_waiton Linux; neither PR touches those.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T00:04:26Z.
Fixed in commit
680095be7:agc_descriptor_cachenow receives the same WindowsPATHprepend as the neighboring graphics tests.python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --checkpass locally. The current workflow run skips platform build/test jobs, so the Windows runtime behavior remains unverified here. Thanks for tracing the missing DLL path.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T00:35:44Z.
Confirmed on GitHub's Windows runner: with
680095be7a,agc_descriptor_cachepasses 3 of 3 (it exited 0xc0000135 before), and on Linux too (run). The run is marked failed only forguest_kqueueon Windows, which this PR doesn't touch.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T01:26:21Z.
Review: COMMENTED
Ran this on a real lavapipe device, the only driver the change applies to (the PR body notes no Vulkan runtime test was run).
Machine: i7-8700, Ubuntu 26.04 (kernel 7.0.0-38), GCC 15.2, Release,
BUILD_TESTING=ON. lavapipe = llvmpipe (LLVM 21.1.8), Mesa 26.0.3, selected withVK_DRIVER_FILES=.../lvp_icd.json ANYPS5_GPU=llvmpipe. Also NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329. Head0627bc6bdmerged intomain5d9dcc42d. The current head680095be7only adds the test to theif(WIN32)PATH list in CMake, so it does not change these Linux runs.agc_descriptor_cache: 3/3 pass. The new test does not build againstmain(it uses the newContextfield), so no test-only red run.ctest -R "^agc" -j1(flip, display andlds_atomics64excluded): 553 pass, 40 skip, 1 fail. On unchangedmainthe same run gives 552 / 40 / 1: same skips, and the one failure isagc_driver_store_over_untrackedin both (#6347). So the free path runs through the whole agc suite on lavapipe with no new failure.^agc|shader|recompiler: same result asmainplus the new test (onlystore_over_untrackedfails,stencil_ref_exportskips).I did not measure memory growth on a title, so this does not confirm the #6608 numbers, only that the per-set free does not break anything on lavapipe.
GPUs tested: lavapipe (Mesa 26.0.3, LLVM 21.1.8), NVIDIA GeForce RTX 3070 (595.99.02), Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T02:15:16Z.
Measured this on a title, which the review above left open: Ghost of Yōtei (PPSA26344) on lavapipe, the scene and probe from #6608.
Tree: main
5d9dcc42dplus the same local changes as in #6608 (the probe and the changes that let the title reach gameplay). The two runs differ only by0627bc6bdand680095be7, re-applied on top. Their only conflicts were with my local switch from #6608, which I removed, so the free path in this run is the PR's own code.-O2build, Mesa 26.2.4 (llvmpipe, LLVM 23.1.1), one 900 s run per tree with the shader cache deleted,systemd-run --scope -p MemoryMax=22G -p MemorySwapMax=8G.cgroup
memory.currentat the first probe at or after each presented frame, with the sets still allocated in Vulkan below:At the last probe (t=897 s):
* highest 10 s sample of
memory.current, not the cgroup'smemory.peak.Freedoes not clearexhaustedafter a single free, so the chain could in principle grow; over 257 frames it did not.VkDeviceMemorylive at the last probe: 8,052 MiB on main and 8,083 MiB with the PR (peak 8,115 MiB in both), so the difference is not in device memory.This matches the numbers with my local switch in #6608 (flat 11.7 GiB, +0.4 sets per frame) and gives the same result on current
main. I measured lavapipe only.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:34:47Z.
Thanks for the lavapipe and Ghost of Yōtei report. I’ve noted the title run as cumulative evidence from a build containing #5998, #5997, #6492 and #6465, rather than attributing the full result to this PR alone.