perf(agc): keep recently sampled depth plane copies up to twice the budget #11307
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11307"
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 dantdmdarealguy on 2026-10-26T02:28:06Z.
What
Astro Bot's intro cutscene runs at about 1.6 FPS on current
mainon Windows with an RTX 5080 (~12 FPS before #7705), and below 1 FPS from the galaxy map on in #11461.Cause: #7705 bounds the sampled depth-plane copies at
APS5_DEPTH_PLANE_COPY_MIB(256 MiB). When the budget is full it evicts the least recently used copy, even one sampled earlier in the same frame. When one frame samples more than the budget, each use evicts a copy the next use needs. Every copy is then made and refilled again on every use.What Astro Bot samples in its intro, alternately (counted with local logging in
evictPlaneCopies, onmainwith #10837):On
mainthat is 37 044 evictions in a 470 s run.The change: a copy sampled in the current or the previous present (
Recorder::Presents(), the frame clock the texture cache uses) is not evicted while all copies together hold at most twice the budget. Past twice the budget, the least recently used copies leave whenever they were sampled; the copy being sampled always stays. Down to the budget, older copies still leave first by least recent use, as before. The copies therefore never hold more than twice the budget (512 MiB by default), or the one copy being sampled if it is larger.APS5_DEPTH_PLANE_COPY_MIB's description says so.Review points from the first version:
agc_driver_depth_plane_guest_layersfailed: two copies sampled before any present could never be evicted. The cap restores an upper bound.mainwithAPS5_DEPTH_PLANE_COPY_MIB=1024(plain least-recently-used, nothing exempt) rises the same way, at the same frame rate: the fast runs reach and load the later scenes, whichmainat 1-2 FPS does not. Table under Tested.Overlap: #10894 adds a case to
DepthPlaneSampling.cpp. This PR replaces its own first version and does not depend on another PR.Tested
Head
36277c4b44is 7830658b18 rebased onto currentmain(3 newer commits, none in the touched files).Traces (all
dropped: no): A main, A change, B change, C first version, C change, D main, D changeWindows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release. Head 7830658b18 on
mainabed035468. The title measurements below were taken with the same change onmaine2d457be34(4f3f10b79e).mainthen moved 155 commits, none of which touchDepthSurface.cpp,DepthSurface.hppor the two test files.agc_driver_depth_plane_sampling_evicting(APS5_DEPTH_PLANE_COPY_MIB=1),FrameCopiesCase, three 3-slice 128x256 D32 copies of 768 KiB each (image and staging):main(itsDepthSurface.cppwith this test):1 depth plane copies were kept after two copies over the 1 MiB budget were sampled in one present, expected both.the depth plane copies sampled in one present hold 2359296 bytes in 3 copies, more than twice the 1 MiB budget.agc_driver_depth_plane_guest_layers: its pooled-memory rounds sample two 1 MiB copies alternately under a 1 MiB budget. Two such copies sampled in one present may now be kept together, so each round now advances two presents first. It still checks that every round evicts, refills once, and takes the evicted copy's memory back from the pool. The first version failed it (round 0, 2 copies); with this change it passes.agc_driver_depth_plane_samplingpasses too.Focused depth tests with the validation layer:
agc_driver_depth_plane_*,depth_compare_copy,depth_copy_draw,depth_surface_from_storage,depth_storage_reuse*,image_plane_address_on_cube,depth_bits_guest_memory; 14 tests.ctest -VandVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1, onmainand on the change.VK_ADD_LAYER_PATH, andVK_LOADER_DEBUG=layershowsInsert instance layer "VK_LAYER_KHRONOS_validation"in every test process (15 lines in each log).was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-linesmaine2d457be34e2d457be34(4f3f10b79e)mainabed035468On
e2d457be34,agc_driver_depth_plane_partial_store("repeated lookups of the first layer of an unchanged array proved no refresh") fails the same way with and without the change. Onabed035468it passes with and without the change.Other checks: full build and
--target libspass, with no warnings in the touched files.patched_librariespasses.tools/check_conventions.pyandtools/check_test_registration.pypass.ASTRO BOT (PPSA21564) 01.007.000: relinked with
--windows --registry --to-intel, 3840x2160, warm caches, the same executable and the same scripted pad input. Onlylibs/was swapped. Runs alternated in one session.Intro cutscene,
APS5_TRACE_SECONDS=200:30(the windows start 39-49 s into the intro in every run),APS5_TRACE_EVENTS=4194304, no dropped events:e2d457be34e2d457be34Run B main was lost to the device loss on
DISPATCH_INDIRECTcompute 0x50057bd00 (arguments 0x5074063c0) during the logo phase. The same loss hit one run of this change in the logo phase, before the intro samples any plane copy. It is #6284's pattern and occurs onmaintoo.Summary lines (A main, then A change; traces linked below):
VRAM over a 470 s run (
nvidia-smi --query-gpu=memory.used -l 5, GiB, whole device, 3.2-3.3 GiB before launch; the same pad script from launch through the intro into the first level; the three plane-copy columns come from local logging, not in this PR):mainmain,APS5_DEPTH_PLANE_COPY_MIB=1024mainmain, 1024 MiB budgetThe plane copies stay at 336 MiB in every run. The fast runs, including
mainwith the larger budget and no present rule, rise together because they reach the later scenes in the same time.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)main, ~11 FPS with this change)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T04:38:31Z.
Review: CHANGES_REQUESTED
The two pasted summary lines provide a same-machine/same-scene perf comparison, but the PR body says the full traces are “available on request”; no trace attachments or
tools/trace_digest.pyoutput are present in the PR description/comments. CONTRIBUTING requires both captured traces to be attached and the digest output for a speed claim, in addition to the summary lines. Please attach the main and change traces and include the digest output before this is ready to approve. The regression test and validation-layer comparison are described in detail; hosted policy checks pass, while product/relinker jobs were skipped by path policy. I have not independently rerun the Windows title capture.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T06:20:35Z.
Review: CHANGES_REQUESTED
The trace-evidence gap is now resolved. I downloaded both GTA V trace attachments from the latest comment and independently ran
tools/trace_digest.py --top 8with their posted summary lines; the outputs reproduce the reported summary values and the traces reportdropped: no. Together with the earlier Astro Bot pair, the PR now includes same-machine before/after captures, summary lines, trace links and digests for two titles. One validation blocker remains:check_main_sync.py --base upstream/main --head refs/review/pr11307reports 1 ahead and 108 behind current main14c99b52ace303eef1667764670d1d1540140b3d(clean merge preview). The posted captures are based on older main commits (64a318c6bc/33ae5a3146). Please refresh to current main, rerun the focused depth-plane tests there, and provide a current-main/change capture pair for the performance claim; then I can re-review that exact head.