perf(agc): build a pipelined draw's resource-cache key before it reaches the committer #10678
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10678"
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 WallisSkill on 2026-10-24T17:04:29Z.
What
The draw finisher now builds the resource-cache key of a pipelined draw it finishes (
DrawResourceKey, the same inputsplanDrawuses) before it queues the commit, andDriver::commitDrawpasses it down throughVulkanDevice::DrawandGraphics::Draw.planDrawuses the key when it was made for the committing device (the key's first words hold the device handle) and builds its own otherwise, as before. The committer runs every draw under the GPU mutex and is the stage the draws wait for in this scene, while the finisher has time to spare. A draw that queue worker 0 finishes itself (no finisher hand-off) leaves the key to the committer as before, so the change never adds work to the worker (head 7b0b45a52, after the Planet of Lana measurement in the review).APS5_NO_EARLY_DRAW_KEYkeeps the key on the committer.APS5_VERIFY_EARLY_DRAW_KEYrebuilds it on the committer and requires both keys to be equal; a first-room run and the AGC suite below ran with it and found no difference.Tested
Windows 11 Pro 10.0.26200, AMD Ryzen 7 9800X3D, NVIDIA GeForce RTX 5070 (driver 616.92), MinGW Release build.
Update,
maincccdaa273(headf32df519a): re-measured with the same setup, three interleaved rounds, the arms differing only inlibSceAgcDriver.prx: frame p50 52.7 / 53.0 / 52.3 ms onmainand 52.8 / 52.3 / 53.3 ms with this change, so the frame-time gain below does not reproduce on currentmain. The committer still spends about 4.5 ms less per frame inGraphics.Draw(43.4-44.0 against 38.8-39.4 ms) and the finisher about 2 ms more, but queue worker 0 is now the limit (96 % busy in every capture of both arms). The 38 AGC tests pass on this head in plain and pipelined mode withAPS5_VERIFY_EARLY_DRAW_KEY=1(76 of 76), and the validation comparison againstcccdaa273is unchanged (VUID-VkDeviceCreateInfo-pNext-pNextonly, 138 on each side, identical per test). The measurements below are from the earlier bases.Performance: Graveyard Keeper 2 (PPSA35943), the first dungeon room after New game, 1920x1080 window, captured with
APS5_TRACE_SECONDS=120:10andAPS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=256 APS5_PIPELINE_DISPATCH=1 APS5_MIMALLOC=1, no otherAPS5_TRACE_*orAPS5_PROFILE_*switch and no log redirection. Base ismain3fcb5e4d7; the change was built at 0039a4195, which differs from this branch's head only in the commit message. Each build ran the scene once to warm the caches, then the captures below ran back to back on the same machine; the input came fromAPS5_PAD_INPUT_FILE(the libScePad command file), so the window was not focused. The trace buffer dropped events at its default size in every capture (dropped: yes); the frame times come from the presents.Summary lines (main, then this change):
Traces and the other summary lines: https://github.com/WallisSkill/AnyPS5/releases/tag/gk2-perf-traces-2026-10-24 (files
gk2-base-*andgk2-pr4-*).Second measurement, at head 7b0b45a52 (
maincf528e78cas base), same scene and machine, with two launch configurations.ppis the configuration above (APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=256 APS5_PIPELINE_DISPATCH=1 APS5_MIMALLOC=1, the finisher on);npdrops the three draw pipeline switches, so queue worker 0 finishes every draw and is the limit (98 % busy in everynpcapture).oldis the previous head 4d4b48da5, which built the key on whichever thread finished the draw. One warm-up run, then two rounds of np main, np old, np fixed, pp main, pp fixed, interleaved; onlylibSceAgcDriver.prxdiffers between them.mainmainSummary lines of the pp pair:
With the finisher the change still takes about 5 % off the frame. Without it this head matches
main, as intended. In this title the previous head was faster there too (the committer is close to the limit as well), but in the Planet of Lana scene from the review it cost about 1 ms per frame on the worker, so the key now stays off the worker everywhere. Traces and summary lines: filesgk2-ek-*in the release.Tests: 38 AGC driver tests (draw pipeline, finisher, label order, vertex fetch, vertex table read order, draw cache, depth and DCC cases) in plain and
APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1modes withANYPS5_NO_SHADER_CACHE=1: 76 of 76 pass, run withAPS5_VERIFY_EARLY_DRAW_KEY=1, at 4d4b48da5 and again at 7b0b45a52. The branch is rebased ontomaincf528e78c.mainnow passes aDrawTraceContextthroughDriver::commitDraw,VulkanDevice::DrawandGraphics::Draw(andPreparedDraw::trace); the key goes after it in each of those signatures, the pipelined commit captures bothtraceandwritableProgramsfrommainand addscontentKey, andVulkanDevice::Drawkeepsmain'straceDrawsswitch.DrawResourceContentKeystill builds the key from the sameDrawResourceKeyinputs asresolveDrawResources(indexBytesisindexCount * indexSizein both), whichAPS5_VERIFY_EARLY_DRAW_KEY=1checks on every draw of the suite. The captures above are from the first head 0039a4195.Validation: the same 38 AGC driver tests ran on
maincf528e78cand on this head (rebased onto it) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1andVK_LOADER_DEBUG=layer. The layer is theVkLayer_khronos_validation.dllthat Steam ships inbin/cef/cef.win64, registered throughVK_ADD_LAYER_PATHwith its own manifest; every test that creates a device logsInserted device layer "VK_LAYER_KHRONOS_validation"(31 of 38; the other 7 make no Vulkan device), and no log containswas not found but was requested by env var VK_INSTANCE_LAYERS. All 38 pass on both. The only validation message on either side isVUID-VkDeviceCreateInfo-pNext-pNext, 132 times onmainand 132 times on this head, the same count in each test (this layer build predates some device-creation structures the driver chains); no VUID is new. The comparison was repeated at 7b0b45a52 with the same result.Digests of a paired capture (the release holds every trace and summary line):
trace_digest.py of ek-pp-main2-1
seconds 120:10 from present 2582: 167 presents, frame p50 59.4 / p90 63.9 / p99 69.2 / max 70.4 ms, GPU busy 8.2 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.92, Windows 10.0.26200, 1920x1080, commit
cf528e78c6, dropped: yesSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Graphics.Draw 31.7, Driver.Packet 26.8, Graphics.Draw.draw_and_resource_release 25.4, Driver.Packet.draw 12.1, Driver.Packet.dispatch 11.8, Driver.Dispatch 11.8, Driver.Draw 11.6, batch 8.2, Driver.DrawFinish 6.5, Recorder.Sync 6.2
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py of ek-pp-fixed-1
seconds 120:10 from present 2644: 178 presents, frame p50 55.9 / p90 60.0 / p99 65.8 / max 69.9 ms, GPU busy 8.1 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.92, Windows 10.0.26200, 1920x1080, commit 7b0b45a52101, dropped: yes
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Graphics.Draw 26.6, Graphics.Draw.draw_and_resource_release 22.2, Driver.Packet 21.0, Driver.Packet.draw 11.5, Driver.Draw 11.1, Driver.DrawFinish 8.4, batch 8.1, Driver.Packet.dispatch 7.1, Driver.Dispatch 7.1, Recorder.Sync 6.2
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py of base-1
seconds 120:10 from present 2344: 148 presents, frame p50 67.3 / p90 72.2 / p99 77.4 / max 78.1 ms, GPU busy 8.9 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.92, Windows 10.0.26200, 1920x1080, commit
3fcb5e4d76, dropped: yesSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Graphics.Draw 39.5, Graphics.Draw.draw_and_resource_release 31.0, Driver.Packet 27.3, Driver.Packet.draw 14.8, Driver.Draw 14.4, Driver.DrawFinish 10.8, Driver.Packet.dispatch 10.1, Driver.Dispatch 10.0, batch 8.9, Driver.DrawFinish.shader_compile_and_link 7.7
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest.py of pr4-1
seconds 120:10 from present 2459: 159 presents, frame p50 62.7 / p90 67.2 / p99 73.6 / max 82.0 ms, GPU busy 9.0 ms per present
NVIDIA GeForce RTX 5070, NVIDIA 616.92, Windows 10.0.26200, 1920x1080, commit 0039a41950a1, dropped: yes
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Graphics.Draw 32.4, Graphics.Draw.draw_and_resource_release 26.5, Driver.Packet 21.7, Driver.DrawFinish 14.3, Driver.Packet.draw 13.1, Driver.Draw 12.7, batch 9.0, Recorder.Sync 7.4, Driver.DrawFinish.shader_compile_and_link 7.3, Driver.Draw.prepare 6.7
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T17:09:15Z.
Review: CHANGES_REQUESTED
The early-key path appears to preserve the existing fallback when the device marker does not match, and the verification mode compares the precomputed key with the committer-side calculation. I cannot approve this AGC change yet because the repository's AGC validation rule requires the same focused tests on
mainand this head withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_LAYER_KHRONOS_validation, then a comparison confirming no new VUIDs. The PR reports the validation layer is unavailable and gives branch test counts only. Please attach both runs from a layer-equipped machine/GPU (including confirmation the layer was actually loaded), or explain what supported validation route can satisfy the rule.The contribution guide also requires
tools/trace_digest.pyoutput for performance claims. The release has the traces and per-capture JSON summary assets; please include the digest output for the paired captures (or the prescribed report output). I downloaded thebase-1andpr4-1trace assets and confirmed the digester reads them; it reports 147 and 158 frames, respectively, but no summary line was found when run against the release asset layout.This head currently conflicts with
maininDraw.cpp(GitHub also reportsDIRTY) and conflicts with open #10677 in that same file; the two PRs currently sayDepends on: none. Please rebase/resolve themainconflict and coordinate landing order with #10677's author, then record the dependency on the checklist. The overlap is substantive: currentmaincaptureswritableProgramsinfinishDraw, while this branch retainsprograms; integrating both needs an explicit resolution that preserves the current-main behavior and the early-key change.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T19:32:32Z.
Review: APPROVED
Reviewed exact head
f0d6652d3b0f82d2effe59697c0b8be4fc0362b0. The early key is built from the same draw inputs and carries the originating device handle; the commit path falls back to recomputing it if the active device differs, and the verification mode compares it against the committer-side key. The author reports 76/76 focused AGC tests passing with key verification enabled, plus the same 38 tests onmainand this head with Vulkan validation confirmed loaded and no new VUIDs. The paired performance report now includestrace_digest.pysummaries and trace assets. Current hosted conventions, labels, eligibility and report checks pass; product CI jobs are skipped by policy.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T08:07:20Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
b831fd9b5b65d28a6629c9d87a63427e3d3671be. I read the prepared diff, manifest, description, commits, and the changed code at the pinned head. No build, tests, or performance captures were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppwas excluded from the prepared files because it was too large; its changed lines were read through the repository reader. The other six changed files listed in the manifest were read. No independent run verified the reported test suite, validation-layer comparison, or performance measurements; the description says its newest measurement no longer reproduces a frame-time gain on currentmain.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T18:19:29Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the updated measurements report no reproducible frame time gain on current main, while showing reduced committer time.
What I ran
Reviewed head
75f7c6c84e79580e6562fab4d25a0eb8cce57339. No build or tests were run. Read the prepared description, commits, manifest, diff, and all included changed files; read the excludedVulkanDevice.cpponly around its changed lines throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build, tests, and runtime measurements were not run in this review. The description reports test and validation results, including current-main measurements, but those results were not independently confirmed. Files read:
Driver.hpp,VulkanDevice.hpp,Draw.cpp(Execution),VulkanDevice.cppchanged region,Draw.hpp,Draw.cpp(Graphics), andENVIRONMENT.md.files.jsonwas unavailable; the manifest and file listing show all seven changed files, withVulkanDevice.cppexcluded from the prepared full-text bundle but read at its changed region. No other repository files were inspected.To get this to a good state
Nothing is required.