perf(agc): replace the plane copies around a depth plane's UAV clear by a depth clear #7178
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7178"
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 AlxcBTW on 2026-10-17T15:07:19Z.
What
A title that clears a shadow atlas with a compute kernel (one colour stored to every texel of a storage image over the depth plane) paid for two whole-plane copies per clear:
DepthSurface::Storagecopies the depth image through a staging buffer into the colour mirror before the dispatch, andDepthSurface::StoreBackcopies the mirror back after it. The kernel reads nothing from the image, so both copies move bytes nobody reads (64 MiB each way for a 16384x2048 D16 atlas).Driver::dispatchnow matches the 15-word 8x8x1 image clear kernel (Graphics::MatchStorageImageClear: the kernel words, 12 user registers so that s12-s14 are the group ids, 8x8x1 threads, three group ids and two thread-id components enabled, one layer of groups; direct dispatches without a partial last group only) whose T# lies on a registered depth surface. It reads the colour under the GPU mutex, where the kernel reads it (the dword at offset 0 of the V# inuser[8..11]), with the packet's labels recorded. The clear is taken when:threads >= extent, texel width equals the plane's 16 or 32 bits);Then
Storageleaves out the copy-in, the dispatch still runs and writes the mirror (so the mirror and its write-back to guest memory are what they were), andStoreBackreplaces the copy-out byvkCmdClearDepthStencilImageof the depth aspect to that value. The colour is read again at that point; if it changed, the copy-out runs. Everything else (other kernels, indirect or partial dispatches, other values and formats, stencil planes, layered views) keeps both copies.There is no switch: the path is always on. The entry "Reused depth storage" in
docs/dev/debt/libSceAgcDriver.mdsays which dispatches are served this way.Why the result is the same bytes:
cto every texel of the mirror that its threads cover; the whole-plane coverage condition makes that every texel of the plane (the T# extent equals the plane extent byStorageViewMatches, one layer, level 0). So the mirror is the constantstore(c)and the copy-out writesstore(c)converted to the depth format. A clear of the depth image to the valuedwithconvert(d) == store(c)writes the same bytes.-0.0stores 0), a uint view of 0xffff and 0 gives 0xffff/65535 = 1.0 and 0.0, and a 32-bit float or integer view is a bit copy of a normal float in (0, 1] or 0 (no denormals, no NaN, nothing the clear's [0, 1] clamp would change).Storageand the dispatch. Any later use of the plane through a storage binding copies the depth image in again (copyPlaneinStorage), so a mirror that was not refreshed is never observed. The mirror keeps the marks that make it write back to guest memory, so guest memory sees the same bytes.ApplyFastClearstill runs inStorage; the stencil plane takescopyPlane), views of more than one layer, partial coverage, other values.Limits: a dispatch that is queued on the draw pipeline (
pipelinedinDriver::dispatch) keeps its copies; the clear covers the dispatches that record on the packet worker. Equivalence to console behaviour is not measured on console hardware.Tested
c05b2567bplus the CI scaffolding commit (run 39041229717, theagc_*set of the lab test filter): 531 of 531 passed, among themagc_driver_depth_clear_hle(2.0 s). Not run on Windows.agc_driver_depth_clear_hle(tests/execution/DepthClearHle.cpp): the matcher alone (every word of the kernel changed, 11 and 13 user registers, other group sizes, missing group ids or thread-id components, two layers of groups, zero groups, partial thread counts); a sequence of clears on the test's own device with the clear taken and with both copies (a 64x32 D32F plane cleared to 1.0, 0.25, 0.5, half of it to 0.75, 2.0 and 0.125; depth tests of the harness' triangle read the plane back; the guest memory after the flush and the depth image, read back texel by texel through its mirror, must hold 0.125 in both modes); the counters of the clear (4 taken, 2 x 8 KiB left out per clear, declines by value and coverage); an integer 32-bit view; a 16-bit plane (an R16 unorm view cleared to 1.0 and 0.0, every texel of the depth image 0xffff and 0, 0.5 declined; a uint view cleared to 0xffff and 0, 0x4000 declined); a depth and stencil surface whose stencil values survive; a PM4 submit through the driver (matching, scope and colour read).APS5_TEXTURE_CACHE_MIB=3072on both arms,APS5_NO_PAD_INPUT=1, trace window 100 s to 160 s of a 200 s row, four alternated rows per arm.mainbc3c0fc13against the change e2559177f (the same code asc05b2567bbefore the rebase; the rebase changed one call inDepthSurface.cppto upstream's newerRequireStorablesignature, and I have not measured the rebased head).tools/trace_digest.pysummary lines:All eight rows are listed. Two rows are outliers that come from memory pressure, not from the arm: main round 2 (4.00 FPS) and change round 3 (3.41 FPS); this machine has 31 GiB, and daytime rows vary with free memory independent of the arm. Mean FPS over all four rows: 6.77 on
main, 7.07 with the change (+4.5 %). Without the two outlier rows (three each): 7.69 onmain, 8.29 with the change (+7.8 %). Mean GPU busy per present: 80.4 ms against 75.9 ms over all rows, 79.6 ms against 74.6 ms without the outliers (-5.0 ms). In the clean rows the change is ahead on frame p50 (118.4 to 119.5 ms against 121.9 to 139.0 ms) and on GPU busy per present (74.2 to 74.8 ms against 79.5 to 79.8 ms); three rows per arm are too few to give an interval. The GPU busy of the two outlier rows (82.8 and 80.0 ms) is raised as well, so the pressure shows in that column too, and round 3 of the pair (80.0 ms against 79.5 ms) does not favour the change.mainagainst exactly this branch.python3 tools/check_conventions.py --base origin/mainpasses. Based on82f0c9aec. Traces are on the lab machine and I can attach them on request.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 github-actions[bot] on 2026-10-17T15:30:29Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-17T16:01:28Z.
First real-GPU datapoint (prior coverage was lavapipe CI only): head
c05b2567b, Windows 11, MinGW (WinLibs GCC 15.2.0), Release, serial fresh processes.agc_driver_depth_clear_hle,agc_driver_depth_fast_clear,agc_driver_depth_fast_clear_submit— 3/3 pass.ANYPS5_GPU=UHD, igvk64): same three, 3/3 pass.The plane-copy-free UAV clear path holds on a hardware depth/stencil implementation; no perf numbers (no trace comparison run).
Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-17T16:38:07Z.
AMD data point, adding to the lavapipe and NVIDIA runs: head
c05b2567bas-is, Release, Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, AMD Radeon RDNA 2 iGPU (1002:164e, driver 32.0.21045.5002) chosen withANYPS5_GPU.agc_driver_depth_clear_hlepasses 5 of 5 (not skipped).Not checked: other tests, titles, timings.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T21:41:04Z.
This now conflicts with main after today's merges. Could you rebase onto current main? We'll re-run full CI on the new head.