fix(agc): reclaim idle buffers on allocation OOM #2828

Closed
Sanjaysrinivas wants to merge 1 commit from upstream-pr/2828 into main
Sanjaysrinivas commented 2026-10-10 16:14:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Sanjaysrinivas on 2026-10-10T16:14:47Z.


What

AGC buffer allocations can report Vulkan out-of-memory while the pool still holds idle buffers or empty slab blocks. Release that idle memory and retry the allocation once, only when actual VkDeviceMemory was freed.

Dedicated host buffers, device buffers and new host slab blocks share this recovery path. Live allocations remain retained. Other Vulkan errors, persistent OOM and failures with no reclaimable memory still throw. Failed allocation output handles are discarded. No new dependencies; the remaining memory limits are recorded in docs/dev/TechnicalDebt.md.

Rebased onto main 1e8fff68c8f6d3b67e38be584e15706a70c9d8bf. Refreshed the upstream implementation and searched existing PRs before publishing: no equivalent idle-buffer allocation recovery was found. Related buffer sizing/accounting work (#2233 and #2283) changes nearby code without implementing this policy. Depends on: none.

Tested

Windows, MinGW GCC 15.2, Release, BUILD_TESTING=ON. Vulkan execution used the RTX 4070 Laptop GPU with Khronos core validation enabled and Vulkan required.

  • The extended pool regression fails with "idle memory did not permit recovery" using main's production allocation files at 1e8fff68c8f6d3b67e38be584e15706a70c9d8bf; it passes after restoring and rebuilding this PR.
  • Coverage includes host/device OOM, dedicated allocations, new and empty slabs, partially live slabs with mapped data preserved, persistent failure, no reclaimable memory, device loss, first-attempt success and invalid failed-allocation handles.
  • Final selected CTest run: 26/29 passed (29.03 seconds). No selected checks skipped; no Vulkan validation errors were reported.
  • The three failures are agc_driver_prepared_shaders, _indirect and _uncached, each reporting "shader failure capture was incomplete". Rebuilt main's production allocation files in the same build/environment: all three fail identically. The recovery regression also fails on that baseline, while test registration passes. Restored this PR's files byte for byte, rebuilt, and repeated the selected checks.
  • Fresh native build, tools/check_conventions.py --base origin/main and git diff --check origin/main...HEAD pass. Linux was not tested locally.

The private game integration, runtime binaries and title assets were not changed by this publication. This generic fix does not establish gameplay, stable FPS or a bound on live images and other retained resources.

Checklist

  • Based on current main; no other open PR implements the same recovery policy
  • One topic per PR; follow-ups go in a new PR
  • No new comments in code
  • Unimplemented paths throw; allocation errors still throw when recovery fails
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4812640844 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2828). Originally posted by [Sanjaysrinivas](https://github.com/Sanjaysrinivas) on 2026-10-10T16:14:47Z. --- ### What AGC buffer allocations can report Vulkan out-of-memory while the pool still holds idle buffers or empty slab blocks. Release that idle memory and retry the allocation once, only when actual `VkDeviceMemory` was freed. Dedicated host buffers, device buffers and new host slab blocks share this recovery path. Live allocations remain retained. Other Vulkan errors, persistent OOM and failures with no reclaimable memory still throw. Failed allocation output handles are discarded. No new dependencies; the remaining memory limits are recorded in `docs/dev/TechnicalDebt.md`. Rebased onto main `1e8fff68c8f6d3b67e38be584e15706a70c9d8bf`. Refreshed the upstream implementation and searched existing PRs before publishing: no equivalent idle-buffer allocation recovery was found. Related buffer sizing/accounting work (#2233 and #2283) changes nearby code without implementing this policy. Depends on: none. ### Tested Windows, MinGW GCC 15.2, Release, `BUILD_TESTING=ON`. Vulkan execution used the RTX 4070 Laptop GPU with Khronos core validation enabled and Vulkan required. - The extended pool regression fails with "idle memory did not permit recovery" using main's production allocation files at `1e8fff68c8f6d3b67e38be584e15706a70c9d8bf`; it passes after restoring and rebuilding this PR. - Coverage includes host/device OOM, dedicated allocations, new and empty slabs, partially live slabs with mapped data preserved, persistent failure, no reclaimable memory, device loss, first-attempt success and invalid failed-allocation handles. - Final selected CTest run: **26/29 passed** (29.03 seconds). No selected checks skipped; no Vulkan validation errors were reported. - The three failures are `agc_driver_prepared_shaders`, `_indirect` and `_uncached`, each reporting "shader failure capture was incomplete". Rebuilt main's production allocation files in the same build/environment: all three fail identically. The recovery regression also fails on that baseline, while test registration passes. Restored this PR's files byte for byte, rebuilt, and repeated the selected checks. - Fresh native build, `tools/check_conventions.py --base origin/main` and `git diff --check origin/main...HEAD` pass. Linux was not tested locally. The private game integration, runtime binaries and title assets were not changed by this publication. This generic fix does not establish gameplay, stable FPS or a bound on live images and other retained resources. ### Checklist - [x] Based on current `main`; no other open PR implements the same recovery policy - [x] One topic per PR; follow-ups go in a new PR - [x] No new comments in code - [x] Unimplemented paths throw; allocation errors still throw when recovery fails - [x] No notes, investigation `.md` files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-10 16:14:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T16:14:57Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6099569675 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2828#issuecomment-6099569675). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T16:14:57Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2828
No description provided.