Skip to content

fix(agc): bound the upload buffers that recorder batches keep alive - #1113

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Celegans12:fix/agc-batch-kept-bytes
Oct 8, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Celegans12:fix/agc-batch-kept-bytes

Conversation

@Celegans12

Copy link
Copy Markdown
Contributor

What

A recorded texture upload keeps its staging, tiled and linear buffers until its batch completes, and nothing limited how much a batch keeps.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main e2b527b: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 386/386 tests pass (ctest --output-on-failure)
  • Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, VK_DRIVER_FILES): 385/385 pass; agc_driver_flat_store is left out there because it takes several minutes on Windows llvmpipe
  • New agc_recorder_kept_bytes (mock device): a batch is submitted at the budget, not below; six budget batches leave two in flight and the four oldest released under the GPU mutex, and six synced one by one in one hold leave at most two alive. Does not compile on main.
  • PPSA26344 v1.008: in a 2,700 s run with this change no allocation fails, although the image-table DRAW_INDIRECT records 585k texture uploads; device buffers peak at 2.7 GiB. A 1,500 s run without it failed at the first such burst (~700 s, 6.6 GiB of device buffers live).
  • 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

@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
#1180 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp L89-96
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L315-317, L1492
#1199 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp L285-286

A sampled texture upload keeps its staging, tiled and linear buffers
until the batch that recorded it completes. A draw whose image table
uploads thousands of textures records them all into one open batch,
so in PPSA26344 6.6 GiB of device buffers were live when the next
texture allocation failed with VK_ERROR_OUT_OF_DEVICE_MEMORY.

Recorder::Keep now takes the bytes an object holds, and the sampled
upload and the storage upload and write-back scratch paths pass theirs.
Before each sampled or storage texture lookup, BoundKeptBytes submits
the open batch once it keeps 512 MiB. While the batches in flight and
those a sync or reap of this hold already finished keep more than twice
that, it destroys the finished ones' objects, then waits for the oldest
in flight and releases its objects at once instead of at the unlock.
agc_recorder_kept_bytes checks these bounds on a mock device.
@Celegans12
Celegans12 force-pushed the fix/agc-batch-kept-bytes branch from 4d0a2f0 to 9af8e9e Compare October 7, 2026 20:42
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on current main: build + full ctest (424/424, agc_recorder_kept_bytes included); the new test doesn't compile without the change; every path that takes a batch out of inFlight goes through finish, so the byte count stays consistent. CI is green on the current head. Merging.

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.

2 participants