perf(agc): build the compute pipelines of queue 0's dispatches ahead #27872
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27872"
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 DerKarussellbremser on 2026-11-27T17:09:10Z.
What
On the compute queues the worker resolves the dispatches of a submission ahead (
Driver::resolveGroupAhead) and hands the pipeline of each new one to the prebuild pool (SubmitComputePrebuild), and a dispatch that reaches its packet while its pipeline is still building waits on that build. Queue 0 took no part in this:resolveGroupAheadreturned for it, and with pipelined dispatches it was not called at all. A queue 0 submission with hundreds of new compute programs therefore built its pipelines one at a time on the worker.Horizon Zero Dawn Remastered (PPSA13428, 01.008.001) does that when its opening sequence starts: single queue 0 submissions hold several hundred
DISPATCH_DIRECTpackets, each preceded by aSET_SH_REG_INDIRECTand aSET_SH_REG, and several hundred compute pipelines are new.Queue 0 now walks its dispatches ahead as well, for their pipelines only:
VulkanDevice::ComputePipelineCounts). A scene that builds nothing is walked once.ReadRawShader, whose bounded cache compares the code bytes), so another program written to a walked address is resolved again, and a resolve that failed before anything was prepared is tried again by the next walk (review). Every other dispatch only advances the shader registers. Resolving submits the pipeline of a new program to the prebuild pool; the resolved result is dropped.submission.registerLists).ReadRawShaderfinds queued work over a program's code, as the dispatch does at its packet.APS5_SKIP_REFUSED_DISPATCHESthat marked its shader and skipped the real dispatches too.APS5_NO_GRAPHICS_QUEUE_PIPELINE_PREBUILDturns it off. It does not run withAPS5_ASYNC_DRAW_COMPILEorAPS5_PROBE_DISPATCH.APS5_GROUP_CAPTURE_ALL_QUEUESwithout pipelined dispatches keeps the adopting walk on queue 0 as before.This depends on #27812. Without it a program is specialized once per base alignment of its buffers, the capture the walk takes ahead often has another alignment than the one at the packet, and the walk builds pipelines that are never bound: with the first revision of this PR alone, a warm start of the title dropped from 26 fps to between 0 and 7 fps. The numbers below are with #27812 applied on both sides.
#5925 proposes a lookahead for draws and dispatches on a pool of its own; it is based on
mainof 14 October. This PR is the dispatch half only, on the prebuild pool and the wait-at-use thatmainhas; it adds no pool and touches no draw path.Tested
Windows 11 Home 10.0.26200, i7-10750H (6 cores), 16 GB, NVIDIA GeForce RTX 2060 6 GB, driver 610.91, WinLibs GCC 15.2.0 r7 UCRT, Release. The tests ran on this branch at
b48a5dc355, onmain76d0a4a7dc. Against the revision reviewed before (d7a60caecc) the rebase changes one place: the walk readssubmission.registerListsthrough theRegisterListsclass of #18914. One test commit follows it. The title runs used the same change onmaina4ebd9084cwith #27812 merged locally.agc_driver_graphics_queue_pipeline_prebuild: after a warm-up dispatch, one queue 0 submission holds a dispatch of a known program, aWAIT_REG_MEMon a CPU label the test keeps closed, and a dispatch of a new program. The test requires that the new program's pipeline exists, built ahead, while the worker still waits and the second dispatch has not run; then opens the label and checks both results, that exactly one pipeline was created and that nothing was adopted._offruns the same binary with the switch set and requires that no pipeline is built before the label opens._rendering_waitand_eop_flip(fixtures by JJenkx) check that the walk does not cross those boundaries.DispatchAhead.cppandPacketExecution.cppas onmain, the first test fails withqueue 0 did not build the pipeline of the dispatch behind a wait while the worker waited.agc_driver_graphics_queue_pipeline_prebuild_refused(APS5_SKIP_REFUSED_DISPATCHES=1): the dispatch behind the closed wait has an unsupported type in its output descriptor when the walk reaches it; the test writes the descriptor once the worker waits, opens the wait and requires the dispatch's result.a dispatch whose descriptor was not written when queue 0 walked ahead was refused at its packet: it stored 0 and 0.unknown RDNA instruction familybefore thetry), so the test uses the descriptor.agc_driver_graphics_queue_pipeline_prebuild_register_list(review): as the first test, but the new program's address comes from aSET_SH_REG_INDIRECTlist.submission.registerLists(its condition set tofalse):queue 0 did not build the pipeline of the dispatch behind a wait while the worker waited: 0 pipelines created. The first test passes in that build.agc_driver_graphics_queue_pipeline_prebuild_reused_address(review,e7083a01af): after the first walk the test writes another program to the walked address, creates a pipeline on a compute queue so that a walk starts, and requires the new program's pipeline to be built ahead while the worker waits._offrequires none with the switch set.a90c4c2d60(the test on the walk with its list of walked addresses):queue 0 did not build ahead the pipeline of another program at an address it had walked before: 0 pipelines created.e7083a01af, validation layer loaded: 28 of 28 of the prebuild, gated capture, pipelined dispatch, refused dispatch, overlap and indirect tests, noVUID-line. The title runs below were not repeated.ctest -R "agc_driver_(graphics_queue_pipeline_prebuild|dispatch_ahead|gated_dispatch|pipelined_dispatch|pipelined_predicat|async_draw_compile|indirect|write_data_written_ahead|compute_pipeline_outside|graphics)": 46 of 46 tests pass (19 test programs) atd7a60caecc. With|agc_linked_code_dependenciesadded to the pattern, the Khronos validation layer loaded,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1: 91 of 91 pass atb48a5dc355(20 test programs) and 83 of 83 onmain76d0a4a7dc, the difference being the eight new tests; noVUID-line on either. The first two "red" results above are from the earlier revisions and were not repeated after the rebase. I did not build the rest of the execution tests.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchate904fbb318(not repeated for the test commit after it): one confirmed overlap besides this PR itself, #18956 (GL2 write-back of RELEASE_MEM), which adds a condition to the same twobreaklines of the walk and the preview; both sides stay when they are merged. It could not compare the pull requests that conflict withmain(among them #5925, #22434, #22647 and #24661, which also changeDispatchAhead.cpp).APS5_PREBUILD_THREADS=4:The first
offrun stalled for 57 s building 45 pipelines on the worker that no earlier run had needed; I do not know why that run needed them (the title's remaining variants are not deterministic from run to run) and I do not count it for or against the walk. Between the other three the walk costs nothing I can measure. The first revision of this PR, measured the same way with #27812, spent 111 s and 43 s of its two runs in the walk and ran at 4.0 and 20.7 fps (200 to 320 s) against 26.1 and 25.1 with the walk off.Neither run reaches the main menu in 900 s; both are still building pipelines when they end. The pipeline count is not a measure of progress by itself (the first revision built pipelines that were never bound, see above); with #27812 the next warm start on the
oncache ran through the same 320 s without a stall.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
https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T17:14:36Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the code review found no verified blocking defects.
What I ran
Reviewed head
f80b20c72af6a76bb7a006fb9c584cb80975f4b1against the prepared diff. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build or tests were run. The author’s reported test results and performance measurements were not independently verified. The review folder’s
files.jsonwas not available through the supplied reader, so I could not confirm any files excluded by review rules. No repository files were excluded from reading among the five files listed inmanifest.json:DispatchAhead.cpp,PacketExecution.cpp,agc_driver_graphics_queue_pipeline_prebuild_tests.cmake,GraphicsQueuePipelinePrebuild.cpp, andENVIRONMENT.md.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-27T17:14:47Z.
Review: COMMENTED
Two queue-0 boundaries look worth checking at
f80b20c72af6.resolveGroupAhead, but its execution branch only callsWait(). The earlier dispatch has already clearedgateOpened(), so a later dispatch in the same submission cannot start another prebuild stretch until an ordinary memory wait reopens the gate.PrebuiltUntilonly limits calls that reach the scanner. Rendering wait and dispatch gateFlipPacketHeader. Submit preparation also records EOP releases carrying a flip insubmission.flips, and opcode0x49follows the label path in this scan. If all flips are meant to bound lookahead, the recorded flip offsets cover both forms. Scan boundary · EOP flip registrationThis is source inspection. The added memory-wait fixture covers a different boundary.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T17:29:13Z.
Review: COMMENTED
a81370df-e582-497d-af8f-4c57d7a66c38Reviewing files that changed from the base of the PR and between
f80b20c72aand2a58fa42fe.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T17:40:44Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review is complete and the inspected evidence supports merging.
What I ran
Reviewed head
2a58fa42fedc3d491fa17726d83e05f06aa48731. No commands or tests were run; I inspected the prepared diff and source throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the build, tests, convention checks, or performance measurements; their results in the PR description are author-reported. I read
DispatchAhead.cpp,PacketExecution.cpp,agc_driver_graphics_queue_pipeline_prebuild_tests.cmake,GraphicsQueuePipelinePrebuild.cpp, andENVIRONMENT.md. No changed files were excluded; the prepared diff omits files excluded by its stated preparation rules, and I did not inspect the excluded-file list.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T18:37:59Z.
Review: COMMENTED
23756d77-a1f6-40b7-a085-d575ae8f301bReviewing files that changed from the base of the PR and between
a5c1babcd0and4d5ab2ec12.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T18:38:50Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected code demonstrates a blocking defect; the author’s targeted tests and performance runs are reported but were not run in this review.
What I ran
Reviewed head
4d5ab2ec12f8fe8c200cb5c8aac5e8bfe1147a43against basemain. No tests or builds were run. I read the complete contents of all five changed files and inspected relevant dispatch, submission, and prebuild-pool callers throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the reported 88 AGC driver tests, convention check, build, or Horizon Zero Dawn Remastered measurements. The description says the remaining execution tests, Linux and macOS, AMD and Intel GPUs, and other titles were not covered. No files were excluded from the changed-file review; all files listed as reviewed in the manifest were read.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T20:02:02Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at head
ce69217c2d8a1e211c5bbcb05c952bc07c6e1143has no verified blocking defects; review was static and no checks were run.What I ran
Read the prepared description, commits, manifest and diff, plus all five changed files at the pinned head. No commands or tests were run.
Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Review evidence:
DispatchAhead.cpp,PacketExecution.cpp, the new graphics queue pipeline prebuild test and its CMake registration, andENVIRONMENT.md, all at the reviewed head.Not verified
Build and test results were not independently verified. Platform and GPU behavior outside the author's reported Windows/NVIDIA run was not verified. No files were excluded from the review; all five files listed as reviewed in the manifest were read.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T20:04:33Z.
Review: COMMENTED
Actionable comments posted: 1
6e9600af-6fb4-44db-8f3a-866468298c7fReviewing files that changed from the base of the PR and between
4d5ab2ec12andce69217c2d.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_queue_pipeline_prebuild_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/GraphicsQueuePipelinePrebuild.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T09:40:50Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed changes add queue 0 compute pipeline prebuilding; I found no verified blocking defect, but could not run checks in this review session.
What I ran
Reviewed head
d7a60caecc11dd4a23b481c517bd3e7d690af171and its prepared diff and source context. No commands or tests were run here; the test and performance results in the PR description are author-reported.Results
Findings
Blocking
None verified.
Non-blocking
None.
Sources
The dispatch walk and boundary handling are in DispatchAhead.cpp at the reviewed head and PacketExecution.cpp at the reviewed head.
Not verified
I did not run the build, tests, conventions check, overlap check, or title measurements. The description reports 46 passing tests and successful conventions checks; those results were not reproduced here. No files were excluded from review: all seven changed files listed in the manifest were read.
To get this to a good state
Nothing is required. Optional: independently rerun the reported checks on this head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T18:46:58Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this review; the optional coverage point below would improve confidence in the new register-list path.
What I ran
Reviewed head
e904fbb31814b67de54bb30d426978542f4bee25using the prepared diff and full changed-file texts. No tests or builds were run. The pinnedrepo_read.pycould not read source context because it tried to write its log in the read-only run folder.Results
Negative control
Not run; no tests were run.
Findings
Blocking
None.
Non-blocking
SET_SH_REG_INDIRECTusingsubmission.registerLists. The new prebuild walk handles this path, but the added fixtures exercise direct register writes. (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp:398)Sources
Not verified
The unchanged repository context could not be read with
repo_read.py. No tests, builds, CI results, or hardware behavior were independently verified. All files listed as reviewed were read;files.jsonlists no exclusions.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T20:09:48Z.
Review: APPROVED
Reviewed — looks good
The change at
b48a5dc3550a9a4445269e2ce451c62c462e3229adds queue 0 compute pipeline prebuilding; the changed code and tests support the stated behavior, with no verified blocking defects.What I ran
Reviewed the prepared diff and targeted source at the exact head above using
repo_read.py. No build or tests were run.Results
Negative control
Not run by the reviewer. The description reports a failing base test and earlier failures without fixes; these were not repeated at this head.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Builds, test execution, hardware behavior, and the author-reported performance results were not independently verified. All seven files listed under
reviewedinfiles.jsonwere inspected;files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T15:37:05Z.
Review: APPROVED
Reviewed — looks good
The queue 0 prebuild walk preserves packet-time dispatch execution, and I found no defect in the changed paths.
What I ran
Reviewed head
a90c4c2d6075033de55b0e116fe339b9c07bd8deagainst basemain; no merged-preview check. I reviewed the prepared diff and read relevant ranges from all seven changed-file snapshots, usingrepo_read.pyfor pinned source context. No build or runtime tests were run.Results
Negative control
Not run by me. The PR description reports red results on the base for the original prebuild behavior and for the refused-dispatch case.
Findings
Blocking
None.
Non-blocking
None.
Sources
The queue 0 walk and its stop conditions are in DispatchAhead.cpp. Dispatches still execute at their packets, and prebuild work is submitted through the existing pipeline path in Dispatch.cpp. The worker opens the walk after queue boundaries and invokes it at queue 0 dispatches in PacketExecution.cpp. The new test fixtures cover waits, flips, register lists, and refused dispatches in GraphicsQueuePipelinePrebuild.cpp.
Not verified
No build, runtime tests, performance measurements, or hardware behavior were independently verified. Reviewed files:
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_queue_pipeline_prebuild_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/GraphicsQueuePipelinePrebuild.cpp, anddocs/dev/ENVIRONMENT.md. No files were excluded. Unchanged portions outside the relevant code paths were not read.To get this to a good state
No follow-up required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:28:43Z.
Review: COMMENTED
WalkedRawProgramskeeps one entry per guest address for the worker's lifetime. The entry is installed before the speculative resolve, and it remains even if that resolve fails or the title reuses the address for another shader. Future submissions then skip prebuilding that address indefinitely, and the set has no size bound. Can the skip decision be scoped to a walk, or keyed to a bounded cache with a program generation? The real dispatch still resolves at its packet, so this affects the prebuild behavior.On Linux/lavapipe, the compute pipeline GPU-mutex and scalar-buffer tests passed on
mainand ona90c4c2d60. All eight graphics queue prebuild cases also passed on the change. Each log shows the Khronos validation layer inserted, with no missing-layer warnings orVUID-messages. The address lifetime issue above comes from source inspection.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T23:45:06Z.
Review: COMMENTED
Reviewed — no blocking findings
The queue 0 prebuild walk and its tests are present at head
e7083a01af2ae53bcb5773f217d67999aa2abb89; I found no verified blocking defect, but the performance results are not independently verifiable from the supplied material.What I ran
Reviewed the prepared description, commit list, diff, manifest, and all seven changed files at the exact head above. No tests or builds were run.
Results
Negative control
Not run independently. The author reports failures on the base and with the register-list branch disabled; those results were not reproduced in this review.
Findings
Blocking
None.
Non-blocking
Sources
Not verified
No tests, builds, or performance runs were performed locally. Linux and macOS, AMD and Intel GPUs, other titles, and the reported title runs were not independently verified. All seven changed files listed in
files.jsonwere read; no files were excluded.To get this to a good state
Nothing is required. For stronger performance evidence, include the raw paired-run captures, traces, and digest output.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.