Skip to content

fix(agc): free released lavapipe descriptor sets - #6614

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
MarcZX10:codex/lvp-descriptor-recycling-6608
Oct 17, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
MarcZX10:codex/lvp-descriptor-recycling-6608

Conversation

@MarcZX10

@MarcZX10 MarcZX10 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes #6608. On Mesa LLVMpipe, free each descriptor set when DescriptorCache::Free releases 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 reach Free; sets held in the draw-set Recycle lists are unchanged.

Tested

Linux (Debian 12), GCC 12.2, Release. The agc_driver_graphics_tests target built. agc_descriptor_cache passed (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 required template disambiguators 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

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new pull request
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in technical debt
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behavior, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: none locally; allocator regression uses a Vulkan mock
  • AI-assisted: yes (Codex)

@MarcZX10

Copy link
Copy Markdown
Contributor Author

@EagleBearerYS @SleglJan A merge-tree check against the current heads reports content conflicts in Graphics/src/ShaderResources.cpp between this PR and both #6454 and #6567. This PR changes the LLVMpipe Free release 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.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6292 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp L100-101
PR 6454 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp L3386
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp L100-101
PR 6788 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp L1127-1132

Some 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.

Pull request Shared files not compared
PR 1341 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4072 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 4339 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 4650 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4891 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5426 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5441 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5500 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5958 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6130 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6146 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6176 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6177 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6194 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6222 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6234 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6259 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6297 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6320 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6373 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6414 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6492 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6535 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6553 core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 6563 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6601 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6636 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6647 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6718 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6783 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6887 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6959 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6965 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
PR 6973 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6987 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6989 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6995 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7002 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7154 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 7201 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7258 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp

@SleglJan

Copy link
Copy Markdown
Contributor

@MarcZX100 Here is what git merge-tree --write-tree gives at the current heads: #6614 0627bc6 on main 5d9dcc4, #6567 544e7af on fa9365c, and #6454 fae2221.

AI-assisted: yes (Claude Code)

@MarcZX10

Copy link
Copy Markdown
Contributor Author

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. The Free paths 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.

@EagleBearerYS

Copy link
Copy Markdown
Contributor

Thanks for checking. Between this PR and #6454 the conflict is one line, DescriptorCache's constructor: #6454 adds a KeptSets() helper above it and a kept.reserve(KeptSets() + 1u) body. Keeping #6454's side and adding this PR's freeDescriptorSets(...) initializer to its list resolves it; nothing else conflicts. The two don't change the same sets: this PR's vkFreeDescriptorSets call is on the chain-pool path of Free, and #6454's kept sets live in dedicated pools, which Free handles 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 fae2221 merged with this PR's 0627bc6 and resolved as above: agc_descriptor_cache and #6454's tests pass 3 of 3 on Linux (run).

One thing from the Windows side: agc_descriptor_cache exits 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 the if(WIN32) set_tests_properties(... ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:...") list next to its registration, which the other agc_driver_graphics_tests tests are in, so adding it there should fix it. Both runs are also marked failed for guest_kqueue on Windows, and the combined one for precise_wait on Linux; neither PR touches those.

@MarcZX10

MarcZX10 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed in commit 680095b: agc_descriptor_cache now receives the same Windows PATH prepend as the neighboring graphics tests. python3 tools/check_conventions.py --base upstream/main --head HEAD and git diff --check pass 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.

@EagleBearerYS

Copy link
Copy Markdown
Contributor

Confirmed on GitHub's Windows runner: with 680095b, agc_descriptor_cache passes 3 of 3 (it exited 0xc0000135 before), and on Linux too (run). The run is marked failed only for guest_kqueue on Windows, which this PR doesn't touch.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with VK_DRIVER_FILES=.../lvp_icd.json ANYPS5_GPU=llvmpipe. Also NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329. Head 0627bc6bd merged into main 5d9dcc42d. The current head 680095be7 only adds the test to the if(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 against main (it uses the new Context field), so no test-only red run.
  • lavapipe, ctest -R "^agc" -j1 (flip, display and lds_atomics64 excluded): 553 pass, 40 skip, 1 fail. On unchanged main the same run gives 552 / 40 / 1: same skips, and the one failure is agc_driver_store_over_untracked in both (#6347). So the free path runs through the whole agc suite on lavapipe with no new failure.
  • RTX 3070 (reset-only path unchanged), ^agc|shader|recompiler: same result as main plus the new test (only store_over_untracked fails, stencil_ref_export skips).

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.

@Dextroid17

Copy link
Copy Markdown
Contributor

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 5d9dcc42d plus the same local changes as in #6608 (the probe and the changes that let the title reach gameplay). The two runs differ only by 0627bc6 and 680095b, 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. -O2 build, 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.current at the first probe at or after each presented frame, with the sets still allocated in Vulkan below:

 frame              1        25       50       75       100      125      150      200
 main 5d9dcc42d     10.8 GiB 12.6 GiB 13.4 GiB 14.2 GiB 15.0 GiB 15.8 GiB 16.1 GiB 17.4 GiB
   sets allocated   277      1,118    1,820    2,460    3,290    3,989    4,684    6,272
 with this PR       11.4 GiB 11.9 GiB 11.9 GiB 11.9 GiB 11.9 GiB 11.9 GiB 11.9 GiB 11.8 GiB
   sets allocated   245      292      268      272      272      270      351      268

At the last probe (t=897 s):

                 frames  sets allocated  sets per frame  peak memory.current*  peak swap lavapipe "allocation fd"
 main 5d9dcc42d  246     7,438           +29.2           18,074 MiB           1,099 MiB 12,812 MiB
 with this PR    257     270             +0.1            12,172 MiB           0         4,461 MiB

* highest 10 s sample of memory.current, not the cgroup's memory.peak.

  • Live descriptor pools at the end: 43 on main, 41 with the PR. Free does not clear exhausted after a single free, so the chain could in principle grow; over 257 frames it did not.
  • VkDeviceMemory live 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.
  • No terminations, validation errors or device loss in either log. Both runs ended at the 900 s timeout.
  • One run per tree, so I make no load-time or frame-rate claim.

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.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added the fix error Closes an issue (Fixes #N) label Oct 17, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 17, 2026
@oneandonlydean
oneandonlydean merged commit e391cf7 into boykopovar:main Oct 17, 2026
8 checks passed
adriadam10 pushed a commit that referenced this pull request Oct 19, 2026
Main's #6402 stores to image tables: a table with a written entry takes
the fresh path, as it does on main, and so does one without a sampled
table binding, whose entries the fresh path rejects. The shared place
step uses the binding as a pointer. Main's #6614 frees descriptor sets
from shared pools one by one, while this branch keeps only dedicated
pools, so both stay. #7101's bulk key read counts its unmapped-page
skips as unmapped, and its key words sit next to this branch's write
stamp and compared runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build fix error Closes an issue (Fixes #N)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AGC: on lavapipe, released descriptor sets stay allocated in chain pools that still hold a live set (about 30 per frame in Ghost of Yōtei PPSA26344)

6 participants