perf(agc): reuse read-only guest buffer uploads #18037
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18037"
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 edubox on 2026-11-10T07:03:52Z.
What
Cache the Vulkan buffer a build copies a read-only guest range into and reuse it across builds while the write watch reports no store over the range.
GuestBufferMemory::copyRegioncopied every descriptor-bound guest range into a freshVkBufferon each build, even when the range is read-only and unchanged. Planet Zoo's sparse heaps alone re-uploaded about 25 MiB per build, thousands of times per second, and the copies were the largest CPU cost in the resource build (Upload.CopyRegionabout 75 ms of a 196 ms frame).The cache keys the buffer by address, size,
VkBufferUsageFlagsand the sparse backing pieces, and stores theCollectWritesgeneration taken before the copy. A later build reuses it whileUnchangedSinceholds; a build the plan marks written, or a range whose backing pieces changed, never takes the cache and drops the entry, so every sharer of a cached buffer is a reader and concurrent GPU use is safe.APS5_UPLOAD_CACHE_MIBsets the budget (default 512 MiB,0disables).Tested
agc_driver_guest_memory_lifetime,agc_driver_host_import_at_map,agc_driver_host_import_proofs,agc_driver_host_import_teardown,agc_driver_recorded_draw_stagingandagc_driver_linear_target_dispatch_access: passed.tools/check_conventions.py --base origin/main: passed.presents, exited clean, with no missing functions and 0 failed shaders (1817 compiled). Cache on vs off on the same build and length: 1173 vs 1037 presents (17.6 vs 15.8 average FPS). The scene advances differently between runs, so this is not a formal A/B on the same save.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