Skip to content

feat(agc): place device buffers in host memory when device memory runs out - #5513

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
codingreapermaps:feat/agc-device-buffers-host-memory
Oct 14, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
codingreapermaps:feat/agc-device-buffers-host-memory

Conversation

@codingreapermaps

Copy link
Copy Markdown
Contributor

What

#4108 places sampled textures and storage images in host memory when the device-local heap's VK_EXT_memory_budget budget cannot hold them, and leaves device buffers to BufferPool::AllocateMemory's trim on failure. On a 2 GB GPU that trim is not enough: PPSA12361 (Transport Fever 2: Console Edition) allocates 176 MiB device buffers once a map loads, the pool recovers one of them by releasing 270 MiB and then fails with

AGC graphics: vkAllocateMemory device buffer: allocation=184549376 memoryType=1 reclaimed=0 initialResult=-2 attempts=1: Vulkan result -2
  • DeviceBuffer now picks its memory type with Context::DeviceMemoryType, as textures and storage images do: the device-local type while the allocation fits in the reported budget, otherwise a type on a heap that is not device-local. Without VK_EXT_memory_budget, or with no budget reported, nothing changes. Placements are logged by the existing [gpu] device buffer: ... placed in host memory line.
  • A buffer placed in host memory is destroyed on release instead of entering the pool's device tier, so a later request is not served host memory as device memory once the budget has room again.
  • The type is chosen before the allocation, as fix(agc): select coherent buffer heaps using available budget #4446 does for coherent buffers after review, not retried after a failure. The pool's out-of-memory trim is unchanged.

Once usage is over the budget every new device buffer goes to host memory and is not pooled, so allocations are made and freed more often there. #4472, which stops the pool keeping device buffers over the budget, addresses the related retention side.

Tested

Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce MX450 2 GB (driver 581.83).

  • agc_buffer_pool_tests: new HostPlacement reports 1600 of a 1620 MiB budget used and requests a 176 MiB device buffer; it is allocated from the host memory type and freed on release, not kept. With usage at 200 MiB the same request is device-local, is kept, and serves the next request. Without the change both host checks fail. All buffer pool tests pass.
  • agc_device_memory_fallback_tests and agc_driver_graphics_tests pass.
  • PPSA12361: with the other local changes the title still needs, the map now loads and runs on the MX450 without the failure above; the log shows the 176 MiB device buffers placed in host memory once usage passes the 1620 MiB budget.
  • Built and tested on main at 8d98e8851.

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 under Silent stubs in their library's technical debt file
  • 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
  • Unblocks: PPSA12361 on GPUs with 2 GB (no Game bring-up discussion yet)
  • GPUs tested: NVIDIA GeForce MX450 2 GB, driver 581.83, Windows 11
  • AI-assisted: yes

…s out

Device buffers now choose their memory type as sampled textures and
storage images do since boykopovar#4108: when the allocation does not fit in the
budget VK_EXT_memory_budget reports for the device-local heap, it goes
to a memory type on another heap. A buffer placed so is destroyed on
release instead of entering the device tier of the pool, so later
requests do not reuse host memory as device memory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 13, 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
#4472 core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp L149, L510

@github-actions github-actions Bot added the agc libSceAgc* label Oct 13, 2026
@adriadam10 adriadam10 self-assigned this Oct 14, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked: agc_buffer_pool passes on the PR merged onto main and fails with the Resources.cpp/Resources.hpp change reverted, so HostPlacement covers the change (host type over budget, not pooled on release, device-local within budget and reused). Host-placed buffers bypass Put as described; merging once the full build is green.

@adriadam10
adriadam10 merged commit fce397b into boykopovar:main Oct 14, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants