perf(agc): hold a staged region's changed-copy snapshot only while a batch uses it #18388
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18388"
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 simnJS on 2026-11-11T13:15:53Z.
What
Every staged region of a cached build keeps two device-local buffers: its shadow, and the snapshot the changed-byte copy-back compares the shader's stores against. The snapshot is only read between the copy-in and the copy-back of one use, and no descriptor names it. It stayed with the build anyway, so half of the device memory held by staging grew with the build cache. That growth is what #18356 bounds.
The region now keeps a weak reference once its copy-back is recorded:
Nothing changes in what is copied or stored.
This composes with #18356 (a local merge is clean): under its bound, the snapshots no longer count against the limit while idle, so about twice as many regions can stay staged.
Tested
main(a57e435a53) and on this branch, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:ctest -R '^agc_driver_(recorded_draw_staging|overlap_staged_copies|partially_resident_snapshot|prepared_publication|resident_heap_mirror|recorder)|^agc_(buffer_pool|adaptive_staging)' -V.agc_driver_recorded_draw_stagingskipped on both (lavapipe does not keep host imports write-watched).was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-VkDeviceCreateInfo-pNext-pNext, 18 times each. No newVUID-.agc_driver_overlap_staged_copiesnow checks that each of its three rounds over the same builds takes its snapshots again and that none outlives its batch. With the release removed, it fails with1024 bytes of changed-copy snapshots are still held after the queue went idle.[buffers] stagingline underAPS5_PROFILE_DRAWbetweenmainand this branch in a long session, e.g. the #18020 scene.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T14:25:08Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Head
a0d1e9fc50b57fe8cd780664fed9bc1e19e4b24c, basemain. I read the description, the commits, the manifest and the diff of the four changed files, then the changed code at head through the reader:No build and no test run in this pass.
Results
Keepcalls hold it until its batch completesFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/tests/execution/OverlapStagedCopies.cpp:229:changedCopyBacksis set from round 1 alone, and the snapshot check for rounds 2 and 3 runs only when round 1 took a snapshot. If round 1 takes none, the snapshot check and the byte check both pass without testing anything, so a regression that stops snapshots from being taken would not show. Suggest checkingsnapshots != 0for round 1 directly and dropping the flag.Not verified
Bufferdestructor returning the snapshot to the buffer pool's device tier: I read only the constructor path (core/libs/prx/libSceAgcDriver/Graphics/src/Resources.cpp, lines 58 to 80).AgcDriver::Graphics::) was not checked against the header's enclosing namespace.GuestBufferMemory.hpp(diff hunks only),OverlapStagedCopies.cpp(changed hunks only),docs/dev/debt/libSceAgcDriver.md(diff hunk at lines 374 to 378 only, 451 lines in all), andGuestBufferMemory.cpp(too large for the review folder; read only at the ranges above and at the changed lines in the diff).To get this to a good state
Nothing is required.