fix(agc-driver): size the host import budget from the device's host heap #5482

Closed
ee6aba54 wants to merge 1 commit from upstream-pr/5482 into main
ee6aba54 commented 2026-10-13 20:58:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-13T20:58:08Z.


What

Host imports stop at a fixed budget of 6 GiB (APS5_HOST_IMPORT_MIB). A title whose address-based shaders cover more registered memory fills it within seconds; every later import is refused, its range is copied on each use and stays read-only in the BDA table, so a compute shader's stores into it are dropped and a later shader of the same pass that waits for them never finishes. On NVIDIA that ends in a context switch timeout (Xid 109) after minutes.

The default budget is now half of the largest host (non device-local) memory heap, at least 6 GiB and at most 24 GiB, read from the device's memory properties. APS5_HOST_IMPORT_MIB still overrides it.

Tested

  • Ubuntu 24.04, Linux 7.0, GCC 13.3, Release, based on 0aa4cb1c2. agc_driver_graphics gains hostImportBudgetTests: no host heap or a small one keeps the 6 GiB floor, a 32 GiB heap gives 16 GiB, a 64 GiB heap is capped at 24 GiB, a device-local heap does not count.
  • PPSA15304 (engine: Unreal Engine 5) on a 59 GiB host (budget 22 GiB): before the change the budget was full after 30 s and three runs hung after 4 to 5 minutes, each preceded by deferred write-back failed: ... BDA access failed ... read-only in the BDA table reports and ending in Xid 109; with it, eight runs of 10 to 15 minutes reached the main menu and the first cutscene without a hang.
  • Windows not built or tested.

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: PPSA15304 (GPU hang after minutes)
  • GPUs tested: NVIDIA GeForce RTX 5080, driver 595.99.02, Ubuntu 24.04
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4849390284 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5482). Originally posted by [ee6aba54](https://github.com/ee6aba54) on 2026-10-13T20:58:08Z. --- ### What Host imports stop at a fixed budget of 6 GiB (`APS5_HOST_IMPORT_MIB`). A title whose address-based shaders cover more registered memory fills it within seconds; every later import is refused, its range is copied on each use and stays read-only in the BDA table, so a compute shader's stores into it are dropped and a later shader of the same pass that waits for them never finishes. On NVIDIA that ends in a context switch timeout (Xid 109) after minutes. The default budget is now half of the largest host (non device-local) memory heap, at least 6 GiB and at most 24 GiB, read from the device's memory properties. `APS5_HOST_IMPORT_MIB` still overrides it. ### Tested - Ubuntu 24.04, Linux 7.0, GCC 13.3, Release, based on `0aa4cb1c2`. `agc_driver_graphics` gains `hostImportBudgetTests`: no host heap or a small one keeps the 6 GiB floor, a 32 GiB heap gives 16 GiB, a 64 GiB heap is capped at 24 GiB, a device-local heap does not count. - PPSA15304 (engine: Unreal Engine 5) on a 59 GiB host (budget 22 GiB): before the change the budget was full after 30 s and three runs hung after 4 to 5 minutes, each preceded by `deferred write-back failed: ... BDA access failed ... read-only in the BDA table` reports and ending in Xid 109; with it, eight runs of 10 to 15 minutes reached the main menu and the first cutscene without a hang. - Windows not built or tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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] Unblocks: PPSA15304 (GPU hang after minutes) - [x] GPUs tested: NVIDIA GeForce RTX 5080, driver 595.99.02, Ubuntu 24.04 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
oneandonlydean commented 2026-10-14 05:10:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:10:29Z.


#290 changed this on main: the budget is now the larger of 6 GiB and half the physical memory (capped by the largest host heap less 2 GiB), and an import past it can evict the least recently used ones instead of being refused. Does PPSA15304 still hang on current main? If it does, please rebase onto it and add the [gpu] host import budget line from that run; if not, this can be closed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161388831 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5482#issuecomment-6161388831). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:10:29Z. --- #290 changed this on main: the budget is now the larger of 6 GiB and half the physical memory (capped by the largest host heap less 2 GiB), and an import past it can evict the least recently used ones instead of being refused. Does PPSA15304 still hang on current main? If it does, please rebase onto it and add the `[gpu] host import budget` line from that run; if not, this can be closed.
ee6aba54 commented 2026-10-14 11:07:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-14T11:07:04Z.


Tested on current main (c654b199b, with #5483 cherry-picked so the storage cache does not run the device out of memory first): PPSA15304 through NEW GAME, the intro cutscenes and the parachute jump, 25 minutes, RTX 5080, driver 595.99.02, Ubuntu 24.04, with a cold shader cache for this source version (1039 programs compiled during the run). No hang, no Xid, no [gpu] host import budget line at all, so #290's eviction never had to refuse an import where the old budget did. The hang this PR was written against came from refused imports, which main no longer does.

Closing; thanks for the pointer.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6166944956 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5482#issuecomment-6166944956). Originally posted by [ee6aba54](https://github.com/ee6aba54) on 2026-10-14T11:07:04Z. --- Tested on current `main` (`c654b199b`, with #5483 cherry-picked so the storage cache does not run the device out of memory first): PPSA15304 through NEW GAME, the intro cutscenes and the parachute jump, 25 minutes, RTX 5080, driver 595.99.02, Ubuntu 24.04, with a cold shader cache for this source version (1039 programs compiled during the run). No hang, no Xid, no `[gpu] host import budget` line at all, so #290's eviction never had to refuse an import where the old budget did. The hang this PR was written against came from refused imports, which `main` no longer does. Closing; thanks for the pointer. AI-assisted: yes

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!5482
No description provided.