Repository navigation
Conversation
…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.
|
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.
|
|
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.
AI-assisted |
|
Thanks, the equivalence argument and the on/off cases are convincing. One robustness point in
Could the plan return what the record needs: the surface (or the mirror plus its |
|
Intel and AMD Windows data: Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
The test files don't build on 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 AI-assisted: yes (Claude Code) |
|
Rebase handoff — rebased onto current Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, To pick it up: Head is |
# Conflicts: # core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
|
This pull request is labeled |
|
@AlxcBTW This PR now conflicts with main in |
|
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
@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. |
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::Storageno longer fills the mirror,StoreBackclears 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::recordDispatchnow recordsvkCmdClearColorImageon 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::dispatchmatched the kernel (MatchStorageImageClear) over a registered depth surface and installed theDepthPlaneClearscope on the recording thread, and the dispatch is direct (no indirect arguments);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 checksStoreOverwritealready made, now one functionOverwriteOfthat both use; the only new condition is that the mirror's width and height equal the plane's, whichStorageViewMatcheshas already ensured when the mirror is made);ClearColorForTexelgives 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, andMarkGpuWritesmarks the mirror as written.Storagestill leaves out the copy-in andStoreBackstill replaces the copy-out by a clear of the depth image (both #7178, unchanged), and a pending fill of #7131 is applied inStoragebefore 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=1records the dispatch again (like the otherAPS5_NO_*switches: set at all means off). The entry "Reused depth storage" indocs/dev/debt/libSceAgcDriver.mdsays so, anddocs/dev/ENVIRONMENT.mdhas a row forAPS5_NO_DEPTH_CLEAR_DISPATCH_SKIP.Why the result is the same bytes:
cto 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 constantstore(c), and a clear of the whole image to the value that stores the same bits writes the same bytes.ClearColorForTexelfor 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.0is 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.MarkGpuWritesruns 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, inStoreBack.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
main(bad0949, base 0c6a5bd) and the ENVIRONMENT.md row, at d4d6c10 (the PR head fa32376 plus the CI scaffolding commit; run 39677504672, ctest regexagc_): 876 of 876 passed with 60 of them skipped for lack of a device capability, among themagc_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.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 behindAPS5_LAB_CLEAR_KERNEL), the sharedOverwriteOfcheck 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=1on all rows, arm a without the change, arm b with it, trace digest figures: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.
python3 tools/check_conventions.py --base origin/mainpasses. Based on 0c6a5bd (merged into the branch).tools/pr_overlap.pylists fix(agc): execute the DB's out-of-place depth expand #6146 (the "Reused depth storage" line of the debt document) and fix(agc): split oversized dispatches with shader offsets #7390 (the lines ofrecordDispatcharound the dispatch); neither implements the same function.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)