perf(agc): keep a staged element in place when its frames are faster #13373
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13373"
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 mrfelek on 2026-10-30T13:37:21Z.
What
Follow-up to #7618. Staging a swept write-only element costs a copy-in and a copy-back per use. In Diablo II: Resurrected (PPSA03912) that saves GPU time in town, but in the main menu the 202 MiB element it stages is faster in place (73 vs 91 ms of GPU time per frame), so #7618 cost the menu about a fifth of its frames.
This decides per element by measurement instead of by size:
Recorder::NoteFrameGpuBusy); the first probe turns them on, so no profiling switch is needed.StagingDecisionsCurrent).APS5_NO_ADAPTIVE_STAGING=1stages every eligible element, as before. Each decision prints one[staging] adaptive:line.The policy is in
AdaptiveStaging.hppand takes frame counts and time from its caller.agc_adaptive_stagingcovers keeping the faster mode either way, frame noise, the back-off cap, a scene change and the share threshold; each check fails with the matching part of the policy broken.Tested
Diablo II: Resurrected (PPSA03912 01.039.000), Linux 7.3, Ryzen 9 5950X, RTX 3080 Ti (NVIDIA 615.71.09), 3840x2160. A =
mainda026c7065, B = this head9fe0de059d. One warm-up run per arm, then A B A B per scene. No otherAPS5_TRACE_*/APS5_PROFILE_*switch;APS5_TRACE_EVENTS=2097152so queue worker 0's buffer does not fill. The log is redirected because the run script waits for the save to open.mainAPS5_TRACE_SECONDS=250:10: presentsAPS5_TRACE_SECONDS=490:15: presentsGPU 90.2 ms/frame staged, 71.5 in place -> in place). Entering town the frame GPU time jumps (72.9 -> 129.4 ms, probing again) and it goes back to staged (83.6 staged, 117.1 in place -> staged). No decision falls inside a town window.mainbuilds crashed the same way at D2R boot.main20d3cd84bcgave the same result: menu 101 / 101 against 123 / 123, town level.Traces: Am1 · Bm1 · Am2 · Bm2 · At1 · Bt1 · At2 · Bt2.
trace_digest.pyoutput is in the first comment.Summary lines (aps5-summary.jsonl)
Tests:
ctest -R 'agc|shader'at this head: 1150 of 1150 pass.agc_adaptive_staging, written-buffer, BDA-staging, read/written staging, storage flush ordering, staged clear, partially resident snapshot, recorder and pool tests), withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V:mainda026c706512 of 12, this head 13 of 13 (with the new test). No missing-layer line and noVUID-message on either side.Help wanted on other titles. This changes only titles that stage a large element, and so far it is measured on one title. If you have one of these, a
mainvs PR run of the same scene would show whether it picks the faster mode there too. The[staging] adaptive:lines from a run also help.I'm setting up GTA V (PPSA04263) here as well.
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)AI-assisted. Tested by me on my own machine.