Skip to content

perf(agc): clear the mirror of a depth plane instead of dispatching the UAV clear over it - #7449

Closed
AlxcBTW wants to merge 3 commits into
boykopovar:mainfrom
AlxcBTW:pr/clear-kernel
Closed

AlxcBTW wants to merge 3 commits into
boykopovar:mainfrom
AlxcBTW:pr/clear-kernel

Conversation

@AlxcBTW

@AlxcBTW AlxcBTW commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

#7178 left out the two whole-plane copies around the 15-word 8x8x1 image clear kernel when it clears a depth plane, but the dispatch itself was still recorded: a compute pass that stores one colour dword to every texel of the plane's colour mirror (DepthSurface::Storage no longer fills the mirror, StoreBack clears the depth image instead). At the title that is 64 MiB of stores per clear (a 16384x2048 plane at 16 bits), and up to 128 MiB on the larger planes in gameplay, that nobody reads.

VulkanDevice::recordDispatch now records vkCmdClearColorImage on the mirror in place of the dispatch when that dispatch is one of the clears #7178 takes, that is, when all of this holds:

  • Driver::dispatch matched the kernel (MatchStorageImageClear) over a registered depth surface and installed the DepthPlaneClear scope on the recording thread, and the dispatch is direct (no indirect arguments);
  • the dispatch writes the depth plane's mirror (DepthSurface::SkipsClearDispatch), the clear covers the whole plane, the mirror has the view's address, format, tile mode, dimension and the plane's extent, and the colour dword is still the one that was matched (the checks StoreOverwrite already made, now one function OverwriteOf that both use; the only new condition is that the mirror's width and height equal the plane's, which StorageViewMatches has already ensured when the mirror is made);
  • ClearColorForTexel gives an exact clear value for the colour in the mirror's format.

Then the pre-dispatch barrier is recorded (never merged away) with the transfer stage as its destination, the clear is recorded in place of vkCmdDispatch, and the trailing barrier also covers transfer writes. Everything else around it is as before: the descriptor set and pipeline are bound, the GPU timing and the notes of written images are made, and MarkGpuWrites marks the mirror as written. Storage still leaves out the copy-in and StoreBack still replaces the copy-out by a clear of the depth image (both #7178, unchanged), and a pending fill of #7131 is applied in Storage before any of it (ApplyFastClear), so nothing about fills changes. A dispatch that does not qualify is recorded as before.

The path is on by default. APS5_NO_DEPTH_CLEAR_DISPATCH_SKIP=1 records the dispatch again (like the other APS5_NO_* switches: set at all means off). The entry "Reused depth storage" in docs/dev/debt/libSceAgcDriver.md says so, and docs/dev/ENVIRONMENT.md has a row for APS5_NO_DEPTH_CLEAR_DISPATCH_SKIP.

Why the result is the same bytes:

  1. The kernel reads nothing from the image and stores one dword c to every texel its threads cover. perf(agc): replace the plane copies around a depth plane's UAV clear by a depth clear #7178's matcher fixed the kernel's words, the group sizes and the registers, and the whole-plane condition makes that every texel of the mirror (the T# extent is the plane's extent). So after the dispatch the mirror is the constant store(c), and a clear of the whole image to the value that stores the same bits writes the same bytes.
  2. The colour goes through ClearColorForTexel for the mirror's format, which refuses NaN and denormals. The values the depth HLE takes are 0 or 1 through a 16-bit unorm view, 0 or 0xffff through a 16-bit uint view, and 0 or a normal float in (0, 1] through a 32-bit float or integer view; for these a device clear and the image store of the kernel give identical bytes (unorm 1.0 and 0.0 are 0xffff and 0 for any rounding, integer and float 32-bit values are bit copies). -0.0 is read as raw 0 by perf(agc): replace the plane copies around a depth plane's UAV clear by a depth clear #7178 and clears to 0.
  3. The mirror keeps the marks that make it write back to guest memory (MarkGpuWrites runs as before), so guest memory gets the same bytes. The depth image is cleared exactly as perf(agc): replace the plane copies around a depth plane's UAV clear by a depth clear #7178 does, in StoreBack.
  4. The colour is read when the dispatch is matched, again when the dispatch is replaced, and again when the copy-out is replaced (perf(agc): replace the plane copies around a depth plane's UAV clear by a depth clear #7178). A value that changed before the dispatch is replaced keeps the dispatch; one that changed after keeps the copy-out, as in perf(agc): replace the plane copies around a depth plane's UAV clear by a depth clear #7178.
  5. Not taken, so unchanged: indirect dispatches, partial coverage, other values and formats, stencil planes, layered views, dispatches that queue on the draw pipeline (the limit perf(agc): replace the plane copies around a depth plane's UAV clear by a depth clear #7178 states).

Limits: equivalence to console behaviour is not measured on console hardware. The lab verify mode that compared both paths on a device is not in this PR; the argument above and the test below are.

Tested

  • Linux (Ubuntu 24.04, Mesa lavapipe), fork CI after the merge of main (bad0949, base 0c6a5bd) and the ENVIRONMENT.md row, at d4d6c10 (the PR head fa32376 plus the CI scaffolding commit; run 39677504672, ctest regex agc_): 876 of 876 passed with 60 of them skipped for lack of a device capability, among them agc_driver_depth_clear_hle (passed, 2.26 s, not skipped). Not run on Windows.
  • agc_driver_depth_clear_hle (tests/execution/DepthClearHle.cpp) has four new cases, each run with the switch on and off on the same sequence of clears and the same expectations: a 64x32 D32F plane (producer 0.5; clears to 1.0 and 0.25 full, 0.75 on the left half, 2.0 and 0.125 full) and a 64x32 D16 plane (an R16 unorm view cleared to 1.0, 0.0 and 0.5). After the clears the depth tests of the harness' triangle must pass as the value says, the guest memory after the flush (the mirror's write-back) and the depth image (read back texel by texel through the mirror) must hold the cleared value in every texel, and the counters must say which dispatches were left out: 3 of 5 for the 32-bit plane (not the half plane, not 2.0) and 2 of 3 for the 16-bit plane (not 0.5), with the mirror clears adding up to 3 x 8 KiB and 2 x 4 KiB, and 0 with the switch off. The 16-bit case skips itself, as the existing 16-bit case does, on a device without the format. The case with the switch off is the comparison with the dispatch path: both modes must end with the same bytes.
  • Windows 11, NVIDIA, Minecraft Dungeons II (PPSA16064). Measured on the lab version 924e247 of this change (fork branch lab/clear-kernel, on an older base than this PR: the lab stack best10, a run of lab changes of which this is the only difference between the arms), not on this PR's head; the PR head differs from it by the switch (the lab version was behind APS5_LAB_CLEAR_KERNEL), the shared OverwriteOf check with the width and height compare, the colour re-read when the dispatch is replaced, and the lab verify mode that is not in the PR. Job 99, APS5_PROFILE_GPU=1 on all rows, arm a without the change, arm b with it, trace digest figures:
row scene arm FPS frame p50 ms frame p99 ms GPU busy per present ms
ck-t-a-1 title a 9.35 106.5 120.9 77.4
ck-t-a-2 title a 9.28 107.2 122.1 77.5
ck-t-b-1 title b 9.95 99.6 122.3 72.3
ck-t-b-2 title b 9.92 100.3 115.0 72.2
ck-g-a-1 gameplay a 4.70 213.1 277.7 88.7
ck-g-a-2 gameplay a 8.60 119.6 266.2 65.2
ck-g-a-3 gameplay a 6.40 170.6 387.8 66.6
ck-g-b-1 gameplay b 5.90 178.8 434.9 70.4
ck-g-b-2 gameplay b 7.35 144.0 294.3 54.9
ck-g-b-3 gameplay b 4.85 207.1 283.9 64.2
ck-g-verify gameplay verify 4.70 214.4 391.0 69.6

At the title the mean FPS is 9.31 without and 9.93 with the change (+0.62, +6.7 %) and the mean GPU busy per present 77.5 ms against 72.2 ms (-5.3 ms); both rows of each arm agree, which makes the title figure the one I claim. The gameplay rows are memory-noisy (this machine has 31 GiB and the spread inside arm a alone is 4.7 to 8.6 FPS): mean FPS 6.57 without and 6.03 with, mean GPU busy 73.5 ms against 63.2 ms; I claim nothing for gameplay from them. Counters at the end of the b rows (cumulative per process): the clear was taken for 1546 of 1546 and 1534 of 1534 clear dispatches over a depth plane at the title and for 1685 of 1685, 2250 of 2250 and 1580 of 1580 in gameplay, with no decline for coverage, view or format. The verify row (gameplay, kernel recorded, then a copy of its result cleared and compared with it on a sample) compared 201 of 1493 clears texel by texel (every texel of each plane, 16,777,216 to 67,108,864 per plane), with 0 differing clears and 0 differing texels; there is no verify row for the title. Pictures were not compared. Traces are on the lab machine and I can attach them on request.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none (PPSA16064 speed; no Game bring-up discussion yet)
  • GPUs tested: Mesa 25.2.8 lavapipe, Ubuntu 24.04 (all GPU tests); NVIDIA GeForce RTX 5070 Laptop GPU, driver 617.42, Windows 11 26200 (game rows only, GPU tests not run there)
  • AI-assisted: yes

…he UAV clear over it

The 15-word 8x8x1 image clear whose clear the depth HLE takes (#7178) still
recorded its dispatch, which stores one colour dword to every texel of a
mirror that the replaced copy-in and the replaced copy-out no longer read.
Recording vkCmdClearColorImage on the mirror with the same value leaves the
mirror and its write-back marks as the kernel would have, and the dispatch is
not recorded. APS5_NO_DEPTH_CLEAR_DISPATCH_SKIP=1 records it again.
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 1896 docs/dev/ENVIRONMENT.md
PR 4040 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/debt/libSceAgcDriver.md
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 4847 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6186 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/debt/libSceAgcDriver.md
PR 6743 docs/dev/debt/libSceAgcDriver.md
PR 6804 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6924 docs/dev/ENVIRONMENT.md
PR 7002 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7085 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7275 docs/dev/ENVIRONMENT.md
PR 7464 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 7643 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 7668 docs/dev/debt/libSceAgcDriver.md
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9289 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9335 docs/dev/debt/libSceAgcDriver.md
PR 9345 docs/dev/ENVIRONMENT.md
PR 9356 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9712 docs/dev/ENVIRONMENT.md
PR 9748 docs/dev/debt/libSceAgcDriver.md
PR 9852 docs/dev/ENVIRONMENT.md
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9915 docs/dev/debt/libSceAgcDriver.md
PR 9950 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10351 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10359 docs/dev/debt/libSceAgcDriver.md
PR 10442 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 10443 docs/dev/ENVIRONMENT.md
PR 10469 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10492 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10652 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10656 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 10743 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/debt/libSceAgcDriver.md
PR 10867 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10894 docs/dev/ENVIRONMENT.md
PR 11435 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 11436 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 11483 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 11587 docs/dev/debt/libSceAgcDriver.md
PR 11825 docs/dev/debt/libSceAgcDriver.md
PR 12324 docs/dev/ENVIRONMENT.md
PR 12544 docs/dev/ENVIRONMENT.md
PR 12568 docs/dev/debt/libSceAgcDriver.md
PR 12746 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
PR 12792 docs/dev/debt/libSceAgcDriver.md
PR 12828 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12840 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 12849 docs/dev/ENVIRONMENT.md
PR 12855 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 12863 docs/dev/ENVIRONMENT.md
PR 12904 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13147 docs/dev/debt/libSceAgcDriver.md
PR 13148 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13251 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 13263 docs/dev/ENVIRONMENT.md
PR 13599 docs/dev/debt/libSceAgcDriver.md
PR 13796 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 13809 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 13963 docs/dev/debt/libSceAgcDriver.md
PR 14217 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 14218 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 14260 docs/dev/ENVIRONMENT.md
PR 14262 docs/dev/ENVIRONMENT.md
PR 14871 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 14944 docs/dev/debt/libSceAgcDriver.md
PR 14964 docs/dev/debt/libSceAgcDriver.md
PR 15058 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 15136 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/debt/libSceAgcDriver.md
PR 15343 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 15456 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15529 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15548 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 15570 docs/dev/ENVIRONMENT.md
PR 15572 docs/dev/ENVIRONMENT.md
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15845 docs/dev/debt/libSceAgcDriver.md
PR 15941 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 16217 docs/dev/ENVIRONMENT.md
PR 16260 docs/dev/debt/libSceAgcDriver.md
PR 16354 docs/dev/ENVIRONMENT.md
PR 16368 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 16371 docs/dev/ENVIRONMENT.md
PR 16372 docs/dev/ENVIRONMENT.md
PR 16427 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 16483 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 16571 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 16753 docs/dev/ENVIRONMENT.md
PR 16793 docs/dev/ENVIRONMENT.md
PR 16796 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 16831 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 16880 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 16935 docs/dev/debt/libSceAgcDriver.md
PR 16953 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 17022 docs/dev/debt/libSceAgcDriver.md
PR 17056 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 17255 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 17259 docs/dev/ENVIRONMENT.md
PR 17261 docs/dev/ENVIRONMENT.md
PR 17338 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 17347 docs/dev/ENVIRONMENT.md
PR 17555 docs/dev/ENVIRONMENT.md
PR 17556 docs/dev/ENVIRONMENT.md
PR 17557 docs/dev/ENVIRONMENT.md
PR 17558 docs/dev/ENVIRONMENT.md
PR 17611 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 17706 docs/dev/ENVIRONMENT.md
PR 17719 docs/dev/ENVIRONMENT.md
PR 17729 docs/dev/ENVIRONMENT.md
PR 17749 docs/dev/ENVIRONMENT.md
PR 17796 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 17899 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 17915 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 17943 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 17956 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 18029 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 18082 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 18091 docs/dev/debt/libSceAgcDriver.md
PR 18139 docs/dev/debt/libSceAgcDriver.md
PR 18173 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 18177 docs/dev/debt/libSceAgcDriver.md
PR 18185 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 18226 docs/dev/ENVIRONMENT.md
PR 18243 docs/dev/ENVIRONMENT.md
PR 18293 docs/dev/ENVIRONMENT.md
PR 18369 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
PR 18390 docs/dev/debt/libSceAgcDriver.md
PR 18693 docs/dev/ENVIRONMENT.md
PR 18783 docs/dev/ENVIRONMENT.md
PR 18829 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 18956 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 19054 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 19119 docs/dev/ENVIRONMENT.md
PR 19130 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
PR 19131 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 19428 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 19445 docs/dev/ENVIRONMENT.md
PR 19462 docs/dev/debt/libSceAgcDriver.md
PR 19553 docs/dev/ENVIRONMENT.md
PR 19557 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
PR 19610 docs/dev/debt/libSceAgcDriver.md
PR 19686 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 19697 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 19707 docs/dev/ENVIRONMENT.md
PR 19722 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 19821 docs/dev/debt/libSceAgcDriver.md
PR 19852 docs/dev/debt/libSceAgcDriver.md
PR 19904 docs/dev/debt/libSceAgcDriver.md
PR 19967 docs/dev/ENVIRONMENT.md
PR 19999 docs/dev/debt/libSceAgcDriver.md
PR 20001 docs/dev/debt/libSceAgcDriver.md
PR 20010 docs/dev/debt/libSceAgcDriver.md
PR 20030 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
PR 20063 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 20066 docs/dev/ENVIRONMENT.md
PR 20072 docs/dev/debt/libSceAgcDriver.md
PR 20084 docs/dev/debt/libSceAgcDriver.md
PR 20085 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20111 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20153 docs/dev/debt/libSceAgcDriver.md
PR 20156 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/debt/libSceAgcDriver.md
PR 20162 docs/dev/debt/libSceAgcDriver.md
PR 20172 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 20185 docs/dev/debt/libSceAgcDriver.md
PR 20186 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 20187 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 20248 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 20315 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/ENVIRONMENT.md
PR 20344 docs/dev/ENVIRONMENT.md
PR 20518 docs/dev/ENVIRONMENT.md
PR 20519 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 20548 docs/dev/debt/libSceAgcDriver.md
PR 20728 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21087 docs/dev/ENVIRONMENT.md
PR 21211 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 21225 docs/dev/ENVIRONMENT.md
PR 21238 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 21303 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 21460 docs/dev/ENVIRONMENT.md
PR 21499 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21528 docs/dev/debt/libSceAgcDriver.md
PR 21536 docs/dev/ENVIRONMENT.md
PR 21649 docs/dev/ENVIRONMENT.md
docs/dev/debt/libSceAgcDriver.md
PR 21669 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 21683 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21699 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
docs/dev/ENVIRONMENT.md
PR 21700 docs/dev/debt/libSceAgcDriver.md
PR 21708 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 21719 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 21746 docs/dev/ENVIRONMENT.md
PR 21773 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21775 docs/dev/ENVIRONMENT.md
PR 21780 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21948 core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 21960 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 21963 docs/dev/ENVIRONMENT.md
PR 21972 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 22001 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22018 core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hpp
PR 22025 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 22028 docs/dev/debt/libSceAgcDriver.md
PR 22029 docs/dev/debt/libSceAgcDriver.md
PR 22052 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 22062 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
docs/dev/debt/libSceAgcDriver.md
PR 22064 docs/dev/ENVIRONMENT.md
PR 22071 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 22072 docs/dev/ENVIRONMENT.md
PR 22075 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
docs/dev/ENVIRONMENT.md
PR 22079 docs/dev/ENVIRONMENT.md
PR 22140 docs/dev/debt/libSceAgcDriver.md
PR 22156 docs/dev/debt/libSceAgcDriver.md
PR 22174 docs/dev/ENVIRONMENT.md

@LeandroLP23

Copy link
Copy Markdown
Contributor

AMD on Windows: the tests this PR names pass on an RDNA 3.5 GPU.

Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release. main 6efb7261b with this PR (17efa3696) merged, together with #7296, #7446, #7377, #7445, #6708, #6748, #6785, #6706, #6613, #7391, #7489, #7484, #7514. They were built once, so the result is for the combination; each merge was clean.

  • agc_driver_depth_clear_hle: pass, 3 runs of 3.
  • Every agc_* test on the combined build: 713 of 716 pass. The 3 that fail, agc_driver_host_import_lifetime, agc_driver_quad_pixel_mask and agc_driver_layered_volume_vertex_no_gpl, fail the same way on unchanged main here, so none comes from these PRs.

AI-assisted

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks, the equivalence argument and the on/off cases are convincing. One robustness point in recordDispatch:

PlanDepthClearDispatchSkip and RecordDepthClearDispatchSkip each take surfacesMutex() and evaluate SkipsClearDispatch separately, and the leading barrier (with the transfer stage as its destination) is recorded between them. If the second evaluation disagrees with the first, RecordDepthClearDispatchSkip throws "the mirror of a depth clear dispatch belongs to no depth surface any more". That can happen if the colour dword in guest memory changes in between, or another thread retires the surface or replaces its mirror. That makes a guest-visible race an abort, and the PR text and the debt line say "a changed value keeps the dispatch", which isn't what happens after the plan.

Could the plan return what the record needs: the surface (or the mirror plus its VkClearColorValue) decided under one lock, so the record doesn't re-decide? Holding the lock across both, or having the record fall back to the dispatch, would also work, but the fallback would need the compute-stage barrier. Then the only re-read of the colour is the one before the plan, and the debt line can say so.

@savvaniss

Copy link
Copy Markdown
Contributor

Intel and AMD Windows data: agc_driver_depth_clear_hle passes with this PR on an Intel UHD 770 and an AMD RX 9070 XT.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head 17efa3696 merged into main 07377573f.

Tests, ×3 UHD 770 RX 9070 XT
This head: agc_driver_depth_clear_hle pass pass

The test files don't build on main without the rest of the PR, so there is no before-run.

This is a correctness check only; I measured no speed.

I also ran full CTest with this PR and the 13 other open AGC and shader PRs I tested in the same batch merged together (#7668, #7659, #7504, #7432, #7426, #7413, #7480, #7465, #7466, #7464, #7489, #7673, #7560). Neither GPU showed a failure beyond main's own: the five image-table tests (#6647) and agc_driver_sample_multisample_target (#6957) on the UHD 770, and agc_driver_layered_volume_vertex_no_gpl (#4768) on the RX 9070 XT.

AI-assisted: yes (Claude Code)

@blawesom

Copy link
Copy Markdown
Contributor

Rebase handoff — rebased onto current main (authorship unchanged). One conflict in VulkanDevice.cpp: your mirror-clear skip kept before main's newer indirect-buffer dispatch form. One ENVIRONMENT.md row added for APS5_NO_DEPTH_CLEAR_DISPATCH_SKIP.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; the depth tests pass (25/25); conventions pass; full suite green apart from the four known main regressions (#5444 Mesa, #7584 BDA, #7766, #7784), none from this PR.

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/7449
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 9e09b06cb.

@github-actions github-actions Bot removed the unblocks title Names a title ID on the Unblocks line label Oct 20, 2026
# Conflicts:
#	core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
@github-actions

Copy link
Copy Markdown

This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@AlxcBTW This PR now conflicts with main in core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp, docs/dev/debt/libSceAgcDriver.md. Main’s dispatch marker recording overlaps this PR’s depth-mirror clear shortcut. Could you reconcile when the dispatch may be skipped while retaining the current recording and depth-storage behavior?

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Your fork is archived, so we carried this as #14344 with your commits and credit, and we'll close this one once that merges. Thank you!

@CnRJay CnRJay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three gaps in the evidence, all of them things the AGC rules ask for.

1. The speed numbers are not from this change. The Minecraft Dungeons II rows are measured on lab/clear-kernel 924e247, on an older base, behind APS5_LAB_CLEAR_KERNEL, and the PR text itself lists what differs from the PR head (the OverwriteOf width/height compare, the colour re-read at dispatch replacement, the verify mode). All rows also run with APS5_PROFILE_GPU=1. The only figure claimed is the title row (+6.7 % FPS, -5.3 ms GPU busy) from two runs per arm; the gameplay rows go the other way (6.57 to 6.03 FPS) and are set aside as noise. Please give tools/trace_digest.py summaries of main and of this PR head from the same machine and scene, without the profile switch.

2. No validation-layer run on a real GPU. RecordMirrorClear adds vkCmdClearColorImage on the mirror in VK_IMAGE_LAYOUT_GENERAL, with new TRANSFER stage masks in the pre and post barriers in recordDispatch. Nothing in the diff touches the mirror's usage flags, so is VK_IMAGE_USAGE_TRANSFER_DST_BIT already set on every storage mirror that SkipsClearDispatch can accept? The 876 lavapipe tests ran without VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, and the NVIDIA runs are game rows only ("GPU tests not run there"). Please run the focused agc_driver_depth_clear_hle tests on main and on this head with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation on one GPU, and show no new VUID- lines.

3. Per-dispatch lock. DepthClearDispatchSkipActive() checks the thread-local scope first, so ordinary dispatches stay cheap, but a matching clear takes surfacesMutex() and scans every surface twice (PlanDepthClearDispatchSkip, then RecordDepthClearDispatchSkip), with SkipsClearDispatch recomputing OverwriteOf and ClearColorForTexel in both. Resolving the surface once in the plan step and handing it to the record step would avoid the second scan.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change based on the code and test evidence reviewed; the author’s reported CI run passed, but I did not run checks locally.

What I ran

Reviewed head fa32376e3a6562ea19b32fd5f9d4b6bf43ad5f1f. Read the prepared description, commits, manifest and diff, plus targeted source and test ranges through repo_read.py. No commands or tests were run.

Results

Check Result Note
Targeted source review passed Dispatch replacement and depth mirror clear path inspected
Automated checks not run CI results are author reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

The changed files listed in manifest.json were all included in the review bundle; I read the relevant changed functions and test sections, not every line of every changed file. The reported lavapipe CI, Windows behavior, console equivalence, and performance results were not independently verified. Excluded files: none reported in the review bundle.

To get this to a good state

Nothing is required.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@AlxcBTW I am closing this one together with #14344, the carry of this branch with your commits. Measured there, clearing the depth plane's mirror instead of dispatching the UAV clear did not move the frame rate beyond run-to-run noise in the three titles we could measure in-game, so there is no gain to merge it for. If you find a scene where it helps, a new pull request with those numbers is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs needs rebase Conflicts with main, rebase needed perf numbers missing perf pull request without a before and after summary line perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants