perf(agc): eliminate DCC register clear fallback during color metadata pass #5560
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5560"
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 Kikoarl on 2026-10-13T23:55:54Z.
What
In titles issuing color metadata passes for fast-clear elimination (such as Astro Bot, Title ID
PPSA21567), packet0x0 DRAW_INDEX_AUTOinvokesVulkanDevice::ColorMetadataPass->RunColorMetadataPasson targets withDccKeys::ClearRegister.clearToTexelcallsStorageTexture::FillClear, which previously refused with"keys pending"because the DCC keys for the clear register had pending writes recorded in the current batch. This causedRunColorMetadataPassto fall back tostoreClearTexels(context, color, texel), triggeringGuestMemory::Writeacross the 16.7 MB color buffer (1920x1080 RGBA16F). InsideGuestMemory::Write,FlushGpuWritesdetected overlapping in-flight GPU passes on Queue 0x0 and calledSync(), causing synchronous CPU stalls of ~15–22 ms whenever fast-clear elimination occurred.This change adds
allowRegisterCleartoStorageTexture::FillClear, allowingRunColorMetadataPassto asynchronously clear the resident Vulkan image directly on the GPU usingvkCmdClearColorImage. This eliminates the CPU fallback, the 16.7 MB CPU copy, and the synchronous GPU sync stall.Tested
Differential Unit Test:
Added pinned test in
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp(metadataPassTests, registered asagc_metadata_passin CTest):ClearRegisterclears the resident Vulkan image (texels[0] == 0x77retained in host memory, zero CPU write-back, andStorageTexture::FindPending != nullptr) and marks keys uncompressed.mainbefore this PR:FillClearrefused (keys pending), fell back tostoreClearTexels, and overwrote host memory.Empirical Telemetry (Astro Bot -
PPSA21567, Intro 3D Logo / Space Sequence):Measured across alternating runs booted with
-sequence product -mode producton NVIDIA GeForce RTX 5060 Ti (Linux) and verified on RTX 4090 (Linux, @oneandonlydean):DRAW_INDEX_AUTOstore syncs: 821 onmain(2.2 s total stall on RTX 4090; 184 syncs / 3.5 s stall on RTX 5060 Ti) -> 0 with this PR (-100% eliminated).python3 tools/check_conventions.py(0 errors).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 repositoryImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T01:06:10Z.
clearToTexelis shared, so the flag also changesmaterializeRegisterClear(Draw.cpp:144), which the description doesn't cover. Please pass it only fromRunColorMetadataPass, where the keys come fromCurrentDccKeysand its pending fills, or show that the other caller is safe too.The second condition can't be hit:
TextureClearKeysreturnsUncompressedforClearRegister(DccMetadata.cpp:477-482), so the "keys pending" check is the only thing this changes.Please use the current PR template (Based on main, Unblocks, GPUs tested) and replace the table with the summary lines of main and of this PR from the same scene, with the traces.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T03:22:59Z.
Windows test of #5560: Windows 10 (19045), MinGW-w64 GCC 15.2, Release,
ninja -j 4, ctest called directly; the ctest logs contain noSelected GPUline. Tree:maina5f493f90+ merge of PR head942664d2da67b1f9a4bd393d1c9a1146f622d527(local merge19ea7cc46, no conflict). Logs:rtx5560_*_N.log,rtx5560_result.txt.1 ctest targets, 3 runs each, exit code 0 in 3 of 3 runs:
agc_metadata_pass.Test selection: the PR registers the new ctest target
agc_metadata_pass(agc_driver_recorder_tests --metadata-pass-only, with SKIP_RETURN_CODE 77); the three runs reportPassed(notSkipped) and the log printsColor metadata pass tests passed. (An earlier run ofagc_recorder_kept_byteswas the wrong selection and is not part of this result.)Not tested: that the new or changed tests fail without the change (no baseline run), other ctest targets, the AMD GPU unless named above, Linux, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:11:23Z.
Ran this on PPSA21564 against
main(RTX 4090, Linux, 2 alternating warm pairs). The syncs it targets are gone: the 821DRAW_INDEX_AUTOstore syncs onmain(2.2 s, all in the intro) drop to 0, recorded-store waits go from 5.8 s to 0.1 s, and the frame checkpoints matchmain. Frame rate on our sequence barely moves: title and menu within noise, the first level about 4% faster over its first 500 frames and equal after that.Which scene and save give the 34 to 51 fps in the description? The world map isn't in our sequence. The two points from the earlier review still need an answer before this goes in.
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-14T08:37:20Z.
Thanks @oneandonlydean for testing on the RTX 4090 and for the thorough review.
RunColorMetadataPass: UpdatedclearToTexelto acceptbool allowRegisterClear = falseand passedtruestrictly fromRunColorMetadataPass(Draw.cpp:2564).materializeRegisterClearand other callers now retain their default behaviour.keys != DccKeys::ClearRegisterfromTexture.cpp:3563, sinceTextureClearKeysalready returnsDccKeys::UncompressedforClearRegister. The bypass now strictly applies to theRecorder::SnapshotWriteOverlaps("keys pending") check as requested.run_astro_bot.sh, no special save), where the fast-clear fallbacks were heavily concentrated, and measured withAPS5_PROFILE_DRAW=1(which inflated the sync wait onmain). As you observed on the RTX 4090, in general gameplay the gain is ~4%, and the primary benefit is the complete elimination of the 821 synchronousDRAW_INDEX_AUTOstore stalls (dropping recorded-store waits from 5.8 s to 0.1 s and eliminating the 20 ms per-frame CPU hitches).I have updated the PR description using the repository template to reflect this accurate scope.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T09:24:41Z.
Rebased onto main: kept both sides of the agc test list in
libSceAgcDriver/CMakeLists.txt; theagc_tests pass.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T09:31:10Z.
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)core/libs/prx/libSceAgcDriver/CMakeLists.txtL1010core/libs/prx/libSceAgcDriver/tests/Recorder.cppL6599