perf(agc): skip the depth plane copy when no slice changed #2491
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2491"
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 oneandonlydean on 2026-10-09T23:10:19Z.
What
Follow-up to #425. Stacked on #2490 (keep unchanged guest layers of a depth plane copy), which this builds on; the first commit here is #2490's.
DepthPlaneCopykeeps the image and serial of every slice it copied. A use copies only the slices whose surface or serial changed, plus the guest layers that changed (as before), and records nothing at all when none did.GENERALto transfer and back instead of fromUNDEFINED).#425 is merged, so this head is rebased onto
main1c5e6287, on top of #2490's new headaf716047. Both commits applied without conflicts and the change is the same.DepthSurfaceView(draws) andApplyFastClearonmain, HTILE and memory value fills included (they set the pending clear), so the serial covers every writer.written = ++depthWrites;after itscopyPlane(plane, stencil, false)); whichever lands second needs that one line.It cannot merge before #2490.
Why
Every sampled use of a depth array, cube or
R16_UINTview copied every slice a depth surface holds into the staging buffer and the whole staging buffer into the copy image, behind threeALL_COMMANDSbarriers, although nothing had written the slices since the previous use. A title that renders its shadow cascades once per frame and samples them a few hundred times spent most of its GPU frame in these copies.Tested
Linux (CachyOS, GCC 16.2.1, Release with CI's configure flags and
ANYPS5_ENABLE_SPIRV_TOOLS=ON, full build andlibs), RTX 4090, NVIDIA 610.57.04.ctest -R "agc|shader"(--parallel 4,ANYPS5_REQUIRE_VULKAN=1): 462/462 on this head (e691d032), 462/462 on #2490af716047, 461/461 onmain1c5e6287.tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.The seven
agc_driver_depth*tests underVK_LAYER_KHRONOS_validation: pass, no validation message.agc_driver_depth_plane_guest_layerscounts the recorded slice copies (vkCmdCopyImageToBuffer) and copy fills (vkCmdCopyBufferToImage):sampling the depth planes with nothing written since recorded 1 depth surface copies and 1 plane copy fills, expected 0 and 0;It passes with the change (5 of 5 runs).
A 2D title we test with, on this head: 220 s through the menu into the second room, picture checks pass, no error line. It does not sample depth planes this way, so this is a regression check only.
A 3D title we test with stops on
mainbefore its title scene without #4500, so it was measured onmain1c5e6287+ #4500, with #2490 and this together: frames per second in the title scene and in the menu after it.main1c5e6287+ #4500Without the two changes the title scene runs at 0.6 to 0.9 fps from its first frame on (74 frames in 90 s); with them the run goes on into the first level. One run each; caches warm for the second row. In the second row #4500's store-back also bumps the write serial (the line named under What).
Not measured on this base: the level numbers of the earlier base (0.174 fps without, 2.275 fps with, on
main99c1c263+ #425's earlier head + #454). Not tested on Windows or on AMD.Checklist
main(1c5e6287, the merge of #425); no other open PR changesDepthPlaneCopy(#1368 samples depth arrays with its own storage, separately)NotImplemented_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 NahuelGenchi on 2026-10-10T02:55:06Z.
Tested on a second title and vendor: Sonic Origins Plus (PPSA05324), Linux, Radeon R9 380 2 GB (RADV, Mesa 26.0.8), 960x540 render size. Its main menu draws a 4-slice 1024x1024 D32 shadow cascade array once per frame and samples it in 43 draws.
Main menu, 10 s windows with
APS5_PROFILE_GPU=1. Both builds are the same tree (#425 at62b1e552, #454, and the fixes the title needs to reach the menu), without and with this PR's head 8085ddae:Refresh.agc_driver_depth_plane_guest_layerspasses on this card.One note for the rebase: with #454 in the same tree,
DepthSurfaceViewconflicts. I kept #454's shape, bumpedwrittenwhere it finds the bound surface, and setdrawnDepth = boundbefore the return.Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:04:53Z.
Additional platform validation on standalone PR head
8085ddae5d8326194483da312e50ed9a3d96c702:Windows: passed — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja.
Release /
BUILD_TESTING=ON: built the selected test targets; 2 CTest cases, 0 failures, 0 CTest skips.Tests:
agc_driver_graphics,agc_driver_depth_plane_guest_layers.Reproduce after building the test targets:
ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_driver_(depth_plane_guest_layers|graphics)$".Vulkan: native AMD RX 6900 XT, driver 32.0.21045.5002.
Integration limitation: a local merge against main
948a526c2has source conflicts; these results validate the standalone PR head, not a resolved merge.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T01:17:13Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libSceAgcDriver.mdL29-30core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL209-210, L227-234, L277-287Imported from boykopovar/AnyPS5. Originally posted by GustavoGamarra95 on 2026-10-13T01:22:58Z.
@oneandonlydean #4873 overlaps this PR in
DepthSurface.cpp(the bot flagged it). It is a follow-up to #425 for padded linear slices: Beast of Reincarnation (PPSA29343) samples a 32x32 D16 surface as a six-face cube, andDescribeSurfacegives 16384-byte slices while the copy expects 2048, so the title stops withdepth plane copy geometry does not match its layers.This PR keeps the same tight-slice assumption in
record():region()usessliceBytes() * layeras the staging offset, while the detiler writes atgeometry.LinearLayerOffset(layer). Whichever lands second can resolve it like this:Refresh: acceptgeometry.sliceLinearBytes >= sliceBytes()and grow the staging buffer tosliceLinearBytes * layerswhen needed;region():bufferOffset = geometry.LinearLayerOffset(layer) + mip.linearOffsetandbufferRowLength = mip.pitchBytes / elementBytes.Growing the staging buffer does not affect this PR's partial copy: every copied layer rewrites its part of the staging buffer before the image copy, and unchanged layers are kept in the image, not in the staging buffer. Happy to rebase #4873 onto this one if it lands first, or the other way around.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T01:31:09Z.
This one goes in first, after #2490. Please rebase #4873 on top once it is merged, with the
Refreshandregion()changes you describe, so the partial copy uses the padded slice offsets as well.Imported from boykopovar/AnyPS5. Originally posted by GustavoGamarra95 on 2026-10-13T01:36:58Z.
Sounds good. I'll wait for #2490 and #2491 to land, then rebase #4873 onto the updated main and adapt
Refreshandregion()to preserve the padded linear slice offsets with partial copies. Thanks for coordinating the merge order.Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-13T02:20:00Z.
Windows RTX 5070 Ti cross-test completed for the #2490/#2491 port, now
codex/first-light-depth-plane-copy-cross-testat 2086c53287fce217be13ffaba1e7e190515e5878, base 861fe25b9 (experimental 007 integration).Native guest-layer/copy-count, depth compare-copy, fast-clear, fast-clear-submit, storage-reuse, last-writer and full mocked graphics: 7/7 passed initially (7.50 s). I also imported Michon's sampled-value fixture
dc0c2cf8cpreserving authorship. It exposed a pre-existing integration omission: the extracted planesAccepted helper lost upstream's depth-bits alternative. Both this port and production baseline 861fe25b9 failed the D16 depth-bits array refusal identically. Restoring the same upstream gate made all eight checks pass (8.05 s).Then I removed only #2491's production change, keeping #2490, the restored format gate and both fixtures: copy-count fails with 1 depth surface copy + 1 plane fill where 0 + 0 are expected; sampled-value control passes. Restored and rebuilt: 8/8 passed (7.98 s), without skips (ANYPS5_REQUIRE_VULKAN=1). Final fixture-only comment cleanup follows this integration's conventions; rebuilt sampled-value test passes again. Scoped conventions/diff checks pass.
The integration also has storage-to-depth write-back, so Transfer(..., false, ...) bumps the new write serial as required; retired-surface/address filters and TakeWrites are preserved. No game performance claim yet. The new game comparison stages only patched graphics, with libc/kernel unchanged, normal asynchronous draws, the same warm cache/profile/cache and memory limits as 861fe25b9. Graphics SHA256 FCB1B8FBE97FD95D817653C882B307D2296D81EEA04C913F3474C056016DF166.
AI-assisted (Codex). No title code, captures or assets uploaded.