perf(agc): take the HTILE words pending fills leave instead of reading them #6505
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6505"
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 keravyn-ops on 2026-10-15T17:56:47Z.
What
A depth target's bind (
storeBackClearedHtile) reads the target's HTILE words to find a fast clear, then stores them back expanded. When a recorded fill over the HTILE is still pending, that read makes the flush hook submit the open batch and wait for the GPU while theaps5-trace-0c4816f6119e-896.json.gz
aps5-trace-3dc3324c60ed-17292.json.gz
GPU mutex is held. A title that clears its depth targets with buffer fill kernels (the fill HLE) pays this wait at every clear. In #6045 that was 1271 syncs per 10 s at about 4.3 ms each, 5.5 s per 10 s with the lock held.
The change follows the DCC key path (
KeysAfterPendingWrites/StoreUncompressedOnGpu):VulkanDevice::FillBuffernotes a uniform fill with its 32-bit word (Recorder::NotePendingWordFill).PendingWritesOverreports the word next to the byte value, and the byte value the DCC key paths read is unchanged.storeBackClearedHtile: when a write is pending over the HTILE, it works out the landed word from the notes. That needs every pending write over the range to be a noted fill, and the bytes outside them to hold the same word. When the landed word is a clear, the expanded words are recorded as a GPU fill behind the pending fills, instead of being read and stored on the CPU. Any other pending write keeps the read, as before.APS5_NO_PENDING_HTILE_FILLS=1always reads, as before.DepthFastClearSubmitgets a case for this. A fill is recorded over a bound target's HTILE, then the target is drawn. The case checks that the depth is cleared, that the bind did not wait for the GPU (Recorder::ThreadHookWaits), that the HTILE holds the expanded words afterwards, and that a second draw keeps its depth.Tested
Windows 11 Home 10.0.26100, AMD Radeon 780M (Ryzen Z1 Extreme), AMD driver 25.10.20.01, WinLibs GCC 15.2.0 r7, Release. The change was measured on
main0c4816f611(commit 3dc3324c60ed). It has since been rebased onto03c4cb5e7without conflicts, and both depth fast clear tests below pass 3 of 3 there.agc_driver_depth_fast_clear_submit_tests: passes 3 of 3. The new case fails withAPS5_NO_PENDING_HTILE_FILLS=1(the old path) at "the bind of the depth target waited for the GPU to run the fill recorded over its HTILE".agc_driver_depth_fast_clear_testspasses 3 of 3, andagc_driver_dcc_keys_first_write_testspasses.agc_driver_recorder_testscases pass:--pending-key-stores-only,--shadowed-key-stores-only,--pending-write-snapshot-only,--space-pending-writes-onlyand--storage-cpu-snapshot-only. The full run stops at "(9) a scan under a pending write was kept", onmainas well as with this change.main, which stays below 60 either way). Ten runs had no crash and no error in the log: the trace run below on exactly this commit, and nine runs of this change together with an unrelated local patch (APS5_STORE_QUIET_AT_FLIP, see #726). The inventory opens and closes back to the world, and the frames dumped at the bench look the same as onmain.Summary lines from the same machine and scene,
mainfirst and this PR second (APS5_THREAD_PRIORITY=highon both):In this capture the presented rate sits at about 60 fps, with most of the frame time in
Vulkan.Acquire.acquire_fence_wait. A run started while the display was at 144 Hz, where the title can take its 119.88 Hz output mode, reaches 69-73 fps in the same scene. WithAPS5_PROFILE_DRAW=1, the[hooksync]line is gone and the untagged[lock]line reportslocked GPU waits 0 / 0 ms. Onmainthat line read 2161 / 5424 ms per 10 s.Traces:
aps5-trace-0c4816f6119e-896.json.gzandaps5-trace-3dc3324c60ed-17292.json.gz(attached).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-15T18:27:11Z.
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/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppdocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppdocs/dev/ENVIRONMENT.mddocs/dev/ENVIRONMENT.mdcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppdocs/dev/ENVIRONMENT.mdImported from boykopovar/AnyPS5. Originally posted by SoRadGaming on 2026-10-16T02:28:46Z.
Windows / AMD results for this head (
d6b25f2d6): on ASTRO BOT it recovers what #5627 cost.Host: Windows 11 Pro 26200, Ryzen 7 5800X3D, Radeon RX 9070 XT (AMD proprietary driver 32.0.23033.1002), 32 GB, WinLibs GCC 15.2.0 r7, Release.
What the regression looked like. ASTRO BOT (PPSA21564 01.007.000),
-lvl hub_crashsite, onmain5d9dcc42d(with #6188, #6266, #6273 and #6292 on top). The hub dropped from about 6.6 to 5.4 FPS after the overnight merges.APS5_SAMPLE_WORKERon queue worker 0, over 80 s in the hub, attributes 16 % of the worker's samples to one path:The recorder syncs grew from 6.5 % to 26 % of the worker.
As a diagnostic I made
storeBackClearedHtilereturn without reading when a write is pending over the HTILE. That gave 6.91 / 6.93 FPS, and hub frame dumps matched the unchanged build. It is not a fix: it would miss a clear made by a pending kernel.This PR. Same tree with this PR merged (clean), one relinked executable, toggling only
APS5_NO_PENDING_HTILE_FILLS. No input, warm shader cache (1,904 hits, 0 misses),APS5_NO_SNAPSHOT_CHECK=1 APS5_RESOURCE_CACHE_ENTRIES=4096, pipelined draws on (main's default). FPS is the window's present counter over 120 s, after a 120 s settle once the level has started. Runs alternate.APS5_NO_PENDING_HTILE_FILLS=1(reads, asmain)So this title's pending writes over its depth targets' HTILE are noted fills, and the bind no longer waits for the GPU.
Frames. GPU frame dumps (
APS5_DUMP_FRAMES, every 100th present) through the hub with this PR show the same frames as the build without it: Astro idling by the pool, with depth, shadows and occlusion intact.No stops or errors in the runs above.
AI-assisted (Claude Code); the builds and runs are on my machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T04:17:28Z.
Data point from Planet of Lana (PPSA19450) on Windows with NVIDIA. With this PR, the first meadow checkpoint goes from 7.06 to 8.89 fps. Before #5627, the same spot ran 12.7.
Host: Windows 11 Home 10.0.26300, AMD Ryzen 9 5900HS, GeForce RTX 3070 Laptop GPU (NVIDIA 617.42), 15.4 GB RAM, WinLibs GCC 15.2.0 r7, Release.
Trees:
main93e54cedd3with #5907, #6146, #6366, #6451, #6470 and #6682 merged.mainplus fixes that have all merged since.Scene: a save in the first meadow, loaded through PLAY / Slot 1 / Resume, then standing with no input.
APS5_THREAD_PRIORITY=high. The fps is the median from 3 to 8 minutes after the load, unprofiled, on a warm shader cache.mainplus fixes, before #5627Runs with
APS5_PROFILE_DRAW=1at the same spot, medians per 10 s over windows 40–70 (the run with this PR was its build's first boot):[draws]prepare[hooksync]pending-write syncs[fill]uniform buffer fills, stored on the GPU[guestmem]readAt the checkpoint, the frame matches the base's: no stale depth and no missing clears.
The reads that remain look like the bind-time store-back reading the whole HTILE after a fill's batch has been reaped. On Windows, this title's 640 KiB HTILE import is under the 1 MiB settle floor (
settleFloorBytes), so it stays out of the write watch.GuestMemory::CollectWritesthen returns 0 over it, and the store-back's "unchanged since the last read" check can't hold.Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T08:13:34Z.
Added a depth and stencil case to
RecordedFillClearsWithoutWait(7918fd477): aD32_SFLOAT_S8_UINTtarget, a recorded SMem 0 fill (0xf0) over its HTILE, bound without a GPU wait, stored back as expanded (0xfffff3ff), and the stencil checked cleared to 0.agc_driver_depth_fast_clear_submitpasses on the Radeon 780M (AMD driver 25.10.20.01, Windows 11 26100), compute fill branch included.APS5_NO_PENDING_HTILE_FILLS=1at "the bind of the depth target waited for the GPU to run the fill recorded over its HTILE".check_conventions.pypasses.Note for reviewers: #6764 implements the same idea (taking the fast clear from the pending HTILE fill instead of reading it).
Imported from boykopovar/AnyPS5. Originally posted by moong15 on 2026-10-17T13:51:01Z.
Tested this on Windows (RX 9070 XT, AMD 26.8.1) with Stellar Blade, merged on top of current main together with other draw-pipeline work. The game binds a 2564x1444 depth target every frame, so before this PR every bind read back its 288 KiB of HTILE on the CPU and waited for the GPU to do it. Measured with
APS5_PROFILE_DRAW=1. Numbers are per 10 s, scenes are lined up by load start, and "before" is the same tree without this PR:DRAW_INDEX_OFFSET_2, menuThat's about 18% more frames in the menu and about 15% more in gameplay, and the game felt clearly smoother while playing. One ~8 minute run, no pipeline failures, and nothing looked wrong on screen. The PR's depth fast clear test passes on the merged tree and fails with
APS5_NO_PENDING_HTILE_FILLS=1, as expected.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-17T14:51:27Z.
Tested on GTA V (PPSA04264) in the open world (Los Santos, a story save resumed), Windows 11, RTX 4090 (driver 616.92), i9-13900K. Both HTILE PRs were measured on the same base, one run each, in the same session:
main47a266cf9+ #6488 + #6848, which GTA needs to render.APS5_PROFILE_DRAW=1, last 12 windows of 10 s (two minutes in the world, warm shader cache).[hooksync]pending-write syncs / 10 sd9621eddb)A committer profile of the base (sampling the
DrawPipelinethread) putsDepthSurfaceView→storeBackClearedHtile→GuestMemory::Read→FlushForAccess→Recorder::Syncat about 5 % of the committer's samples, so GTA hits the case both PRs handle. In this scene #6505 removes about 75 % of the hook wait time and #6764 about 40 %. FPS and the committer cost per draw stay within run-to-run noise: the committer is ~84 % busy with other per-draw work. Neither run crashed. I checked the rendering on the #6764 run's screenshots (correct); the #6505 run's were overwritten before I looked.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by mrfelek on 2026-10-18T10:32:37Z.
Data point from Linux / NVIDIA: on Diablo II: Resurrected (PPSA03912), this PR removes every HTILE wait, giving 47 → 60 presents per 10 s (+28%).
Host: Ubuntu 26.10 (kernel 7.3), Ryzen 9 5950X, RTX 3080 Ti (NVIDIA 615.71.09 open), GCC 15.3.0, Release.
Trees:
main1b0c7cfa0, and the same base with this PR's head 7918fd477 merged (clean merge). I also ran #6764 on the same base before it was closed, and it gave the same result (60 presents, 0 HTILE waits).Scene: in game with a saved character loaded, no input.
APS5_PROFILE_DRAW=1, measured over 120 s starting 60 s after the character loads.main[hooksync]HTILE syncs (DRAW_INDEX_2, 714K range) / 10 sDepthSurfaceView. About 230 binds per 10 s took the HTILE read under a pending fill, at about 20 ms each (max 60 ms). The other ~110k binds per 10 s took the cached path at almost no cost.DRAW_INDEX_INDIRECT indirect-args. The bytes are unchanged after every one of those waits (unchanged 60, in flight unsignaled). It is about one per frame, and it is why the gain is smaller than the 4.5 s removed. I'll follow it up separately.AI-assisted; the runs are from my machine(s).
Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-18T20:10:32Z.
Linux / AMD data point on a Unity title: Subnautica (PPSA02453). CachyOS kernel 7.2.2, Ryzen 9 5950X, RX 6650 XT / RADV Mesa 26.2.4, Release, no env switches. Same spot in both runs: the burning lifepod right after the intro, standing still,
APS5_PROFILE_DRAW=1.Before this PR, gdb samples of the committer thread (
DrawPipeline::run) sat in a GPU wait about 70% of the time, every time on this path:commitDraw → VulkanDevice::Draw → Graphics::Draw → DepthSurfaceView → GuestMemory::Read → Recorder::SyncThrough → Recorder::Sync → Recorder::finish → drmSyncobjWaitmain61d3d3080+ #4449About 2x at this spot (~18k draws per frame). Both PRs merged cleanly onto
main61d3d3080. The image is unchanged (fire, lifepod interior, ocean), no crash, clean exit. #4449 was in both builds; without it this title also loses time on failed host imports.AI-assisted (Claude Code).