Skip to content

perf(agc): pool device staging buffers by size class - #1004

Open
Celegans12 wants to merge 1 commit into
boykopovar:mainfrom
Celegans12:perf/agc-staging-pool-reuse
Open

Celegans12 wants to merge 1 commit into
boykopovar:mainfrom
Celegans12:perf/agc-staging-pool-reuse

Conversation

@Celegans12

Copy link
Copy Markdown
Contributor

What

The device-local tier of BufferPool only reused a buffer of the exact same size and usage. Partial storage-image detiles and retiles ask for a new size and the other transfer direction almost every time, so in PPSA26344 the tier sits at its 512 MiB budget and misses and evicts ~77 buffers per frame. The release thread then spends ~38 ms per frame in vkFreeMemory, which on NVIDIA also holds up vkQueueSubmit (mean ~0.7 ms).

  • Device-tier requests of 1 MiB and more round up to an eighth of their octave (at most 12.5% larger); smaller ones keep their power-of-two classes.
  • Device-tier buffers are created with STORAGE | TRANSFER_SRC | TRANSFER_DST added (BufferPool::Usage), so uploads, write-backs and staging shadows share a list; SHADER_DEVICE_ADDRESS and INDIRECT requests keep their own.
  • Take serves a request from the smallest retained buffer of its class up to twice its size; the buffer returns to its own class. Callers bind and copy explicit sizes, as with the small classes.
  • Host tiers, the budget, LRU eviction and reuse only after release are unchanged. APS5_NO_BUFFER_CLASSES=1 still matches exact sizes.
  • feat(agc): host import windows, least-recent eviction under the budget, recoverable GPU out-of-memory #290 adds GPU memory accounting in the same files; the Resources.cpp conflict is textual, so whichever lands second needs a small rebase.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main ab9437e: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 368/368 tests pass (ctest --output-on-failure)
  • Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, VK_DRIVER_FILES): 367/367 pass; agc_driver_flat_store is left out there because it takes several minutes on Windows llvmpipe
  • New agc_buffer_pool (mock device): size classes, shared directions, the 2x fit, reuse only after release, budget. Fails on main.
  • Scratch detile/retile benchmark, RTX 3080 Laptop: frees 68 to 9 per frame, release thread 46 to 4 ms, submit mean 0.48 to 0.17 ms.
  • PPSA26344 v1.008 (with fix(agc): store uncompressed DCC keys at the first write of a fast-cleared image #903): device-tier misses 79 to 40 and release thread 43 to 17 ms per frame, submit mean 0.69 to 0.55 ms; same frames.
  • Not tested: Linux (CI), console behaviour.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

The device-local tier of BufferPool only reused a buffer of the exact
size and usage it was asked for. Partial storage-image detiles and
retiles ask for a new size and the other transfer direction almost
every time, so the tier sat at its budget and missed and evicted
dozens of buffers per frame, and the vkFreeMemory calls on the release
thread held up submits and allocations on the recording threads.

Device-tier requests of 1 MiB and more now round up to an eighth of
their octave, the tier's buffers are created for storage and both
transfer directions, and a request takes the smallest retained buffer
from its own class up to twice its size. Host tiers, the budget and
eviction are unchanged. agc_buffer_pool covers the classes, the fit
and its bound, reuse only after release, the budget and the unchanged
lists.
@github-actions

github-actions Bot commented Oct 7, 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
#290 core/libs/prx/libSceAgcDriver/Graphics/src/Resources.cpp L9-10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant