perf(agc): reuse TargetMemo across 3D volume slices and reject overlapping pending targets #27249
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27249"
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 birdmarty on 2026-11-25T15:43:41Z.
What
When a title renders layered draws into a 3D volume color target (
arrayLastSlice == 0andvolume || depth > 1), consecutive draws stepCB_COLOR_VIEWthrough slice ranges (for example, UE4's48x48x48Translucent Lighting Volume renders 6 draws per light withlayers = 8anddepthSlice = 0, 8, 16, 24, 32, 40).prepareColors()resolves all of those draws throughSurfaceForTarget(color)to the same resident 3DStorageTexture, refreshing the whole volume and differing only inStorageTexture::AttachmentView(format, mip, depthSlice, layers, arraySlice)(an O(1) cached view lookup).repeatColors()previously comparedmemo.descriptors != state.colorsusingColorTarget::operator==, which includesdepthSliceandlayers. Every slice step therefore missedTargetMemoondescriptorand ran a full resident-target refresh and page walk over the volume surface.Verification with
APS5_VERIFY_TARGET_MEMO=1also surfaced a pre-existing admission gap inrememberTargets():StorageTexture::Refresh()can complete while another overlapping image stays pending (via alias borrowing, clear hand-over, or GPU-ordered refresh skip) without bumpingPendingSerial().StorageTexture::takeRefreshProof()already checksotherPendingOverlaps()before taking a proof, whereasrememberTargets()did not.otherPendingOverlaps()also now checkspendingUnitInside(...)for pending textures so non-overlapping units of a larger pending surface do not spuriously reject memoization.Changes
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp,Graphics/src/Texture.cpp: exposeStorageTexture::OtherPendingOverlaps()and checkpendingUnitInside(...)for pending textures inotherPendingOverlaps().core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp:rememberTargets(): require!binding.resident->OtherPendingOverlaps()before admitting color targets intoTargetMemo.sameColorTargetSurface()andrepeatColors(): allow non-proxied 3D volume targets (arrayLastSlice == 0 && (volume || depth > 1)) whose descriptors differ only indepthSliceandlayersto hitTargetMemo, resolving the slice's view viabinding.resident->AttachmentView(...)when the descriptor is not an exact match.core/libs/prx/libSceAgcDriver/tests/TargetStateMemo.cpp: addvolumeSlicesReuseMemocovering 3D volume slice stepping (depthSlice 0 -> 1).Tested
Windows 11 Pro (build 26300), i9-9900K, MinGW-w64 GCC 15.3.0, Release build, AMD Radeon RX 6800 (
vendor=0x1002,device=0x73bf), AMD proprietary driver26.10.1(Windows driver32.0.21045.16010, Vulkan1.4.315).Unit tests on
0773e801d3(baseorigin/mainc032ba7c52) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK1.4.363.0),VK_LOADER_DEBUG=layer:ctest -R "^agc_driver_target_memo": 12 / 12 passed,Insert instance layer "VK_LAYER_KHRONOS_validation"confirmed 12 times, 0VUID-errors.origin/main'sDraw.cpp:agc_driver_target_memo_draw_pipelinefails on the newvolumeSlicesReuseMemocase.tools/check_conventions.py --base origin/main: passed.tools/debt_fold.py --check: passed.tools/pr_overlap.py --branch perf/agc-target-memo-3d-volume-slices: 0 mergeable open PR overlaps (exit 2 only for unmergeable PRs touchingDraw.cpp/Texture.cpp).Lies of P (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza) on61250ca018withAPS5_DRAW_PIPELINE=1 APS5_NO_DRAW_STAGING=1 APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1:APS5_VERIFY_TARGET_MEMO=1 APS5_PROFILE_TARGET_MEMO=1):lookup 26,687,hit 828(3.1%),descriptor 14,644per 10 s.lookup 26,587,hit 15,423(58.0%, 18.6× more hits),descriptor 21–28(-99.8%), 200,000+ consecutive verified cross-checks, 0 mismatches, clean exit 0.main(61250ca018):8.80 FPS,p50 112.2 ms,p90 122.8 ms,gpu 74.28 ms/f,Graphics.Draw 75.78 ms/f.8.83 FPS,p50 113.0 ms,p90 121.2 ms,gpu 72.48 ms/f(-1.80 ms/f),Graphics.Draw 73.07 ms/f(-2.71 ms/f).Performance captures (
APS5_TRACE_SECONDS=120:30, clean warm shader cache, no extraAPS5_TRACE_*orAPS5_PROFILE_*switches)Same machine, title (
PPSA10621,v01.012.000,3200x1800, Krat Central Station Plaza), and flags (APS5_DRAW_PIPELINE=1 APS5_NO_DRAW_STAGING=1 APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1 APS5_FAST_F32=1):main,c032ba7c52):9.00 FPS,p50 110.5 ms,p90 117.7 ms,max 151.1 ms,gpu 70.31 ms/f,Graphics.Draw 72.33 ms/f(aps5-trace-c032ba7c5273-23148.json.gz).0773e801d3):9.10 FPS(+0.10),p50 109.6 ms(-0.9 ms),p90 115.0 ms(-2.7 ms),max 139.2 ms,gpu 67.22 ms/f(-3.08 ms/f),Graphics.Draw 70.57 ms/f(-1.76 ms/f) (aps5-trace-0773e801d37e-4284.json.gz).Baseline
aps5-summary.jsonl(c032ba7c52):Candidate
aps5-summary.jsonl(0773e801d3):Series context & interleaved ablation
This PR is part of a general AGC/libc performance series measured on Lies of P (
PPSA10621,v01.012.000,3200x1800, UE4) covering #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, and #27273 (tested together with #20130, #18757, #26778, #27117, and now-merged #26581 and #26681). Combined on base61250ca018(plus remaining unsplit stack changes), steady-state performance rose from7.25 FPS(p50 135.6 ms,gpu 92.7 ms/f, default settings) to12.15 FPSaverage (12.00/12.30 FPS, peak12.33 FPS,p50 81.5 ms,gpu 57.12 ms/f,+67.6%to+70.1%).Because five of the smaller PRs (#27253, #27254, #27270, #27271, and #27273) looked like they slightly lost average FPS (
-0.03to-0.31 FPS) in single isolated runs onc032ba7c52, we ran an interleaved 4-run ablation (A1 -> B1 -> A2 -> B2,APS5_TRACE_SECONDS=120:30, identical warm shader cache and flags) on the full stack to test whether removing those 5 PRs helped or hurt:61250ca018(WITH all 11 PRs): #27249, #27250, #27251, #27252, #27253, #27254, #27268, #27269, #27270, #27271, #27273 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes (per-64 KiB proof/pending tracking and ShapeRecipe).61250ca018MINUS the 5 PRs (#27253, #27254, #27270, #27271, #27273): keeps #27249, #27250, #27251, #27252, #27268, #27269 + #20130, #18757, #26778, #27117, #26581, #26681 + remaining unsplit stack changes.DrawWithRecipe(ms/f)DrawFinish(ms/f)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)61250ca018, WITH all 11 PRs incl. #27253, #27254, #27270, #27271, #27273)61250ca018, MINUS #27253, #27254, #27270, #27271, #27273)+0.39 FPS(+3.3%)-2.1 ms-4.6 ms-10.5 ms-3.21 ms/f-1.02 ms/f-0.88 ms/fRemoving those 5 PRs hurt every run (
A1 > B1andA2 > B2across all metrics), showing that their single-run isolated dips onc032ba7c52were within±0.25 FPSscene variance while larger bottlenecks (#27268, #27249, #27252, #20130, #18757) still dominated. Individual PR captures above remain isolated againstc032ba7c52.Not tested: Linux, NVIDIA/Intel GPUs, 2D array slice memoization (intentionally unchanged because
CachedStorageLayersrefreshes per layer range).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-25T16:33:27Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at head
0773e801d37e1b74cc2bf8d67a6e64a3c8b48e7chas no verified blocking defects; the changed implementation and added volume-slice test support the stated memoization behavior.What I ran
No build or tests were run. I inspected the prepared diff and read the changed code and relevant target-view/equality code through
repo_read.pyat the pinned head.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Texture.cppis listed as excluded from the prepared review folder, but I read the touched implementation and related refresh-proof logic from the pinned head throughrepo_read.py.files.jsonwas not available through the review reader, so exclusions beyond the manifest and review folder listing are not verified. I did not run build/tests or independently verify the author-reported hardware measurements, CI results, or behavior on other GPUs and operating systems.Files read:
Texture.hpp,Draw.cpp,TargetStateMemo.cpp,State.hpp, and the touched portions ofTexture.cpp; prepared documents read:description.md,commits.md,manifest.json,diff.patch, andREADME.md. Excluded changed-file text:Texture.cppfrom the prepared folder; its relevant implementation was read at head.To get this to a good state
Nothing is required.