perf(agc): upload a storage image spanning two host imports on the GPU #3949

Closed
CnRJay wants to merge 1 commit from upstream-pr/3949 into main
CnRJay commented 2026-10-11 19:40:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-11T19:40:35Z.


What

A storage image upload with no DCC keys goes through the host import of its memory when one import covers the whole surface. A surface that straddles two registered allocations has no single import (HostImportFor fails), so StorageTexture::upload fell back to the CPU path: GuestMemory::ReadCommitted of the whole surface (which first waits for the GPU writers of that memory), a staging copy, and a waited batch.

PPSA28416 (STAR WARS: Galactic Racer, UE5) has 3840x2160 surfaces (formats 36 and 56) that cross from a 2 MiB allocation into the 848 MiB heap right after it. At the main menu that is ~54 uploads and ~1.5 s per 10 s on the CPU path.

When every part of the surface is served by an existing import, each import's piece is now copied into one device buffer and detiled from there, recorded in the open batch like the single-import path: shadows published, stores flushed, the pending read noted, the image kept until the batch completes. When any piece has no import, the CPU path runs as before. APS5_NO_GATHERED_UPLOAD=1 turns the new path off.

Tested

Windows 11, WinLibs GCC 15.2.0, Release, RTX 4080.

  • The 78 add_test_executable targets of libSceAgcDriver that build on Windows: all pass.
  • PPSA28416 (on the testing branch): main menu 5.3 -> 5.6-5.7 fps, no crash in 420 s. A 400 s run under VK_LAYER_KHRONOS_validation (~3000 uploads through the new path) reports no errors from it.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4821796076 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3949). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-11T19:40:35Z. --- ### What A storage image upload with no DCC keys goes through the host import of its memory when one import covers the whole surface. A surface that straddles two registered allocations has no single import (`HostImportFor` fails), so `StorageTexture::upload` fell back to the CPU path: `GuestMemory::ReadCommitted` of the whole surface (which first waits for the GPU writers of that memory), a staging copy, and a waited batch. PPSA28416 (STAR WARS: Galactic Racer, UE5) has 3840x2160 surfaces (formats 36 and 56) that cross from a 2 MiB allocation into the 848 MiB heap right after it. At the main menu that is ~54 uploads and ~1.5 s per 10 s on the CPU path. When every part of the surface is served by an existing import, each import's piece is now copied into one device buffer and detiled from there, recorded in the open batch like the single-import path: shadows published, stores flushed, the pending read noted, the image kept until the batch completes. When any piece has no import, the CPU path runs as before. `APS5_NO_GATHERED_UPLOAD=1` turns the new path off. ### Tested Windows 11, WinLibs GCC 15.2.0, Release, RTX 4080. - The 78 `add_test_executable` targets of `libSceAgcDriver` that build on Windows: all pass. - PPSA28416 (on the testing branch): main menu 5.3 -> 5.6-5.7 fps, no crash in 420 s. A 400 s run under `VK_LAYER_KHRONOS_validation` (~3000 uploads through the new path) reports no errors from it. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
oneandonlydean commented 2026-10-11 23:19:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:19:31Z.


Could you add a test for the gathered path: a storage surface that crosses two registered allocations, uploaded with host imports on, its texels compared, and a check that the upload did not go through the CPU path? No test in the tree reaches the new branch of StorageTexture::upload.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115028996 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3949#issuecomment-6115028996). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:19:31Z. --- Could you add a test for the gathered path: a storage surface that crosses two registered allocations, uploaded with host imports on, its texels compared, and a check that the upload did not go through the CPU path? No test in the tree reaches the new branch of `StorageTexture::upload`.
CnRJay commented 2026-10-12 13:20:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-12T13:20:08Z.


Yea I'll do that

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6125111185 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3949#issuecomment-6125111185). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-12T13:20:08Z. --- Yea I'll do that

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