docs(agc): say that a refused device allocation falls back to host memory before throwing #8419

Merged
thuanquang merged 2 commits from upstream-pr/8419 into main 2026-10-24 09:21:54 +00:00
thuanquang commented 2026-10-20 12:29:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T12:29:53Z.


What

The AGC buffer allocations entry in docs/dev/debt/libSceAgcDriver.md ends with "allocation failure still throws when reclaim cannot satisfy the request". BufferPool::AllocateMemory now tries one more step before it throws: after the pool-trim retry and the texture-cache release, VK_ERROR_OUT_OF_DEVICE_MEMORY with a host memory type other than the refused one allocates in that host type and returns it (BufferPool.cpp:86-99 on main), before Check(result, details) at line 119. Only device buffers (Resources.cpp:183) and images (BufferPool.cpp:589, through TakeImageMemory) pass that host type; buffer slab blocks (BufferPool.cpp:268) and host buffers (Resources.cpp:98) do not, so they still throw. The "Host placement after a device-memory refusal" entry, two entries down since #8672 added "Storage-cache pressure and idle device buffers" in between, describes the placement. The clause now reads "allocation failure still throws when reclaim cannot satisfy the request, except for the device buffers and images that the "Host placement after a device-memory refusal" entry places in host memory". @harisibrar1 pointed out in review that the first version read as if every allocation could be placed in host memory.

Tested

Docs only; nothing was built or run. Checked on main by reading core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:56-116 (main 02b5a8e55); the callers named above were read on main 865166414. Rebased onto main 11d6efa06c for the conflict with #8672 (merged) in docs/dev/debt/libSceAgcDriver.md: main's text is kept, and the clause now names the host placement entry instead of "the next entry", which #8672's new entry no longer is; the line numbers above were rechecked on that commit.

  • python tools/check_conventions.py --base origin/main with this title and body passes.
  • Not tested: behaviour on any machine; this changes text only.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4935732218 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8419). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T12:29:53Z. --- ### What The `AGC buffer allocations` entry in `docs/dev/debt/libSceAgcDriver.md` ends with "allocation failure still throws when reclaim cannot satisfy the request". `BufferPool::AllocateMemory` now tries one more step before it throws: after the pool-trim retry and the texture-cache release, `VK_ERROR_OUT_OF_DEVICE_MEMORY` with a host memory type other than the refused one allocates in that host type and returns it (`BufferPool.cpp:86-99` on `main`), before `Check(result, details)` at line 119. Only device buffers (`Resources.cpp:183`) and images (`BufferPool.cpp:589`, through `TakeImageMemory`) pass that host type; buffer slab blocks (`BufferPool.cpp:268`) and host buffers (`Resources.cpp:98`) do not, so they still throw. The "Host placement after a device-memory refusal" entry, two entries down since #8672 added "Storage-cache pressure and idle device buffers" in between, describes the placement. The clause now reads "allocation failure still throws when reclaim cannot satisfy the request, except for the device buffers and images that the "Host placement after a device-memory refusal" entry places in host memory". @harisibrar1 pointed out in review that the first version read as if every allocation could be placed in host memory. ### Tested Docs only; nothing was built or run. Checked on `main` by reading `core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp:56-116` (`main` `02b5a8e55`); the callers named above were read on `main` `865166414`. Rebased onto `main` `11d6efa06c` for the conflict with #8672 (merged) in `docs/dev/debt/libSceAgcDriver.md`: main's text is kept, and the clause now names the host placement entry instead of "the next entry", which #8672's new entry no longer is; the line numbers above were rechecked on that commit. - `python tools/check_conventions.py --base origin/main` with this title and body passes. - Not tested: behaviour on any machine; this changes text only. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
harisibrar1 commented 2026-10-21 06:00:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-21T06:00:13Z.

Review: COMMENTED


Checked against main:

  • BufferPool.cpp:86: the host fallback runs only for VK_ERROR_OUT_OF_DEVICE_MEMORY when a hostType was passed; host OOM and TOO_MANY_OBJECTS still go to Check(result, details) as before.
  • A hostType is passed only for device buffers (Resources.cpp:183) and images (BufferPool.cpp:171, via RefusedDeviceMemoryFallback). Buffer slab blocks (BufferPool.cpp:266) and host buffers (Resources.cpp:98) call AllocateMemory without one, so "throws when neither reclaim nor host placement helps" reads as if every allocation in this entry could be placed in host memory.
  • The next entry, "Host placement after a device-memory refusal", already gives the scope and limits. Suggest pointing to it with the scope, e.g. "...allocation failure throws after the reclaim retry, except that a device-local refusal of a device buffer or image is placed in host memory (next entry)", or dropping the change as redundant.
  • tools/check_conventions.py --base main --head pr-8419 passes.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5595539659 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8419#pullrequestreview-5595539659). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-21T06:00:13Z. **Review:** COMMENTED --- Checked against main: - `BufferPool.cpp:86`: the host fallback runs only for `VK_ERROR_OUT_OF_DEVICE_MEMORY` when a `hostType` was passed; host OOM and `TOO_MANY_OBJECTS` still go to `Check(result, details)` as before. - A `hostType` is passed only for device buffers (`Resources.cpp:183`) and images (`BufferPool.cpp:171`, via `RefusedDeviceMemoryFallback`). Buffer slab blocks (`BufferPool.cpp:266`) and host buffers (`Resources.cpp:98`) call `AllocateMemory` without one, so "throws when neither reclaim nor host placement helps" reads as if every allocation in this entry could be placed in host memory. - The next entry, "Host placement after a device-memory refusal", already gives the scope and limits. Suggest pointing to it with the scope, e.g. "...allocation failure throws after the reclaim retry, except that a device-local refusal of a device buffer or image is placed in host memory (next entry)", or dropping the change as redundant. - `tools/check_conventions.py --base main --head pr-8419` passes. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
thuanquang commented 2026-10-21 11:50:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T11:50:01Z.


@harisibrar1 thanks, agreed. I pushed 0423fcd14: the clause now keeps the old "still throws when reclaim cannot satisfy the request" and adds "except for the device buffers and images that the next entry places in host memory", so slab blocks and host buffers read as throwing, as they do (BufferPool.cpp:266, Resources.cpp:98).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6315187110 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8419#issuecomment-6315187110). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T11:50:01Z. --- @harisibrar1 thanks, agreed. I pushed `0423fcd14`: the clause now keeps the old "still throws when reclaim cannot satisfy the request" and adds "except for the device buffers and images that the next entry places in host memory", so slab blocks and host buffers read as throwing, as they do (`BufferPool.cpp:266`, `Resources.cpp:98`).
harisibrar1 commented 2026-10-21 13:41:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-21T13:41:45Z.

Review: APPROVED


Rechecked 0423fcd14 against main:

  • "still throws when reclaim cannot satisfy the request, except for the device buffers and images that the next entry places in host memory" matches the code: only device buffers (Resources.cpp:183) and images (BufferPool.cpp:171) pass a host type to AllocateMemory, while slab blocks (BufferPool.cpp:266) and host buffers (Resources.cpp:98) still throw after the reclaim retry.
  • tools/check_conventions.py --base main passes on this head.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5600662880 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8419#pullrequestreview-5600662880). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-21T13:41:45Z. **Review:** APPROVED --- Rechecked 0423fcd14 against main: - "still throws when reclaim cannot satisfy the request, except for the device buffers and images that the next entry places in host memory" matches the code: only device buffers (`Resources.cpp:183`) and images (`BufferPool.cpp:171`) pass a host type to `AllocateMemory`, while slab blocks (`BufferPool.cpp:266`) and host buffers (`Resources.cpp:98`) still throw after the reclaim retry. - `tools/check_conventions.py --base main` passes on this head. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
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!8419
No description provided.