perf(agc): mirror a sparse descriptor heap instead of copying it per dispatch #3167
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3167"
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 CnRJay on 2026-10-10T23:55:23Z.
What
PPSA28416 (STAR WARS: Galactic Racer, UE5) binds a 4 GiB GPU heap of which 528 MiB is committed. With the cut from #2992 the heap is copied only up to its last backed byte, but it is still copied for every dispatch that binds it: 528 MiB at ~90 ms each, over thousands of dispatches during boot, which is the 0.1 FPS the title showed.
A sparse descriptor heap region is now bound to a persistent heap mirror of the registered range that backs it, instead of being copied:
servesViewchecks the view start against the extent of any mirror, so a view past the mirror falls back to the copy.This branch carries the commit of #2992 (rebased, as that PR conflicts with
main); drop it when #2992 merges.Tested
Windows 11, WinLibs GCC 15.2.0, Release, RTX 4080.
agc_driver_graphics(sparseHeapMirrorTestsinBdaResources.cpp): a committed range smaller than the heap descriptor bound over it is mirrored, not copied (sparseBinds+1), the view is cut at the mirror, a GPU store is written back. Without the change it fails witha heap bound whole over a smaller registered range was copied.main).[resources] guest upload ... copieddrops from 4095 MiB (528 MiB really read) to 0.0 MiB per dispatch. Device time per dispatch during boot: 10.7 ms before (9500 dispatches, 101.8 s), 2.6 ms after (3600 dispatches, 9.5 s). The title then stops on garbage indirect dispatch arguments, which is a separate problem.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)Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-11T00:04:39Z.
Review: COMMENTED
These two are one line of work on one title, and the second is only safe because of the first — so they want to land in order: #2992 cuts what a copied sparse region costs to its last backed byte, and #3167 removes the per-dispatch copy of a bound heap altogether.
The measurement chain is complete, which is unusual. PPSA28416 binds a 4 GiB GPU heap with 528 MiB committed; before the cut, every dispatch that bound it allocated the whole 4 GiB and failed with
vkAllocateMemory … -2; after it, the copy was still 528 MiB per dispatch at ~90 ms, thousands of times during boot, which is the 0.1 FPS the title showed. Stating the intermediate step as well as the final one is what makes the second change's value checkable rather than asserted.The mirror design is the right answer where a copy is not. Binding a sparse descriptor heap to a persistent mirror of the registered range that actually backs it — looked up for the part that is needed rather than the whole reservation, no part of which any registered range covers — removes the copy instead of shortening it, and committing pages on demand keeps the mirror proportional to what is really used. Refreshing a fully-committed plain mirror from the write watch, the way an address-based build does, is what keeps it honest, and
servesViewbounding a view start against each mirror's extent is the check that would otherwise be missing.One thing worth naming in the descriptions: #2992 is currently conflicting, and this change's cut depends on it. So the sequence is a rebase of the first and then this one — and with
GuestBufferMemory.hpptouched by both, that order is not optional.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:57:29Z.
Windows run, since the PR has no Intel or Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto
maind31b57a4in one build with #3217, #3202, #3167, #3137, #2863, #2849 and #2847, on an RTX 5060 Laptop and the Arrow Lake iGPU (ANYPS5_GPU=Intel).agc_driver_bda_deviceandagc_driver_bda_span_reads(BdaResources.cpp) pass on both GPUs.Full
ctestof that build on both GPUs has no failure that isn't also on plainmainhere (guest_filesystemneeds the symlink privilege, #3169; the Intel ones are listed on #2114 and #3207).AI-assisted (Claude Code); I ran this on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-11T07:34:18Z.
Additional platform validation of standalone PR head
2a430701e4a29733769ecf922f1604ee34a6f178(2026-10-11):Linux: passed — Arch Linux in WSL2 (kernel 6.6.87.2), GCC 16.2.1 20260810; CMake 4.3.1 / Ninja; Release,
BUILD_TESTING=ON.1 checks, 0 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.
Checks:
agc_driver_graphics.Command after building:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_graphics$".This scope checks CPU-side behavior; no GPU execution result is claimed.
Internal limitation: heap-mirror subcases returned early because the guest arena was not write-watched in WSL. Zero CTest skips does not include that early return.
No title/gameplay validation. These results cover the standalone head, not a merge with current main.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:02:42Z.
Rebased onto current
main, dropping the first commit (the original #2992 commit): #2992 landed in a different form, so that commit conflicted and is no longer needed. The two commits of this PR are untouched.Checked on the rebased tree: scoped build + ctest of libSceAgcDriver and neighbours;
agc_driver_graphics,agc_driver_bda_deviceandagc_driver_bda_span_readspass.sparseHeapMirrorTestsis_WIN32-only like the existing heap mirror tests, so it doesn't run on Linux; Windows runs by @Silverash-i8 (RTX 5060 + Arrow Lake iGPU) and the author's own cover it. Merging once CI is green.