perf(agc): take a 2D storage image's results for a one-slice array on the device #2479
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2479"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-09T22:47:53Z.
What
A 2D surface and a one-slice 2D array over the same memory get separate storage images, because the storage key holds the dimension. While one of them holds pending results, a refresh of the other has to bring those results over.
pendingAliasalready does that on the device (borrowUnits) for a pending image of another format with the same element size. It required the same dimension, though, so for this pair the refresh wrote the pending image back and uploaded it again.Sonic Origins Plus (PPSA05324) uses both views of the same surfaces in its opening animation, about 50 times a frame. Each switch paid a full write-back and a re-upload, and that held the animation at about 3 fps on my machine.
pendingAliasnow counts a 2D surface and a one-slice 2D array as the same dimension. Nothing else in the shape test changes (size, array range, mips, tiling, element size, image layers and depth, tracked units). The conditions for the device copy don't change either: uncompressed keys, a host import, and the surface's write stamps.A follow-up could give both views one image (one storage key for a 2D surface and its one-slice array), which would also remove the device copies. That is a larger change to the storage cache, so it isn't in this PR.
Tested
Ubuntu 26.04, GCC 15.2, Release build, AMD Radeon R9 380 (RADV, Mesa 26.0.8), and lavapipe (LLVM 21.1.8).
New test,
agc_driver_storage_one_slice_alias. It stores through the 2D view and loads through the array view, twice.the array image's refresh wrote the 2D image's results back instead of taking them on the device.Sonic Origins Plus, opening animation, 960x540 (
--res_x=960 --res_y=540,APS5_PROFILE_GPU=1). I used the testing branch from #2021, built with and without this change. Per 10 s of the animation:storage-writebackstorage-uploadThe animation now runs at about 10 fps. Its frames look the same in both runs: the same scenes, with the same colors and layers. Frames were dumped every 15 presents, so frames in the "before" sheet are about 5 s apart and frames in the "after" sheet about 1.5 s apart.
Frame dumps
Before (boot, notice, title emblem and the start of the animation):

After (notice, title emblem and the animation further on):

tools/check_conventions.py --base origin/mainandgit diff --checkpass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T23:05:36Z.
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.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:16:51Z.
Rebased onto current main and added one commit:
StorageOneSliceAlias.cpp:84:GuestAllocations::Mutation().Addtakes a fifthgpuargument on main now, so the test no longer compiled; passingtrue, likeFlatAperturesandHostImportAtMap.Checked: scoped build and ctest for libSceAgcDriver green (355/355); on lavapipe the new test passes with the change and fails without it (
the array image's refresh wrote the 2D image's results back...); on RADV only the texels and the flush are checked, as the test notes. The Sonic Origins Plus numbers are the author's, not reproduced here. Merging once CI is green.