perf(agc): run the draw finisher by default #15456
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15456"
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 Nesyth on 2026-11-03T11:49:35Z.
What
On
main, queue 0's worker and the draw committer bound draw-heavy scenes (#7895). The draw finisher from #6946 moves the second half of each pipelined draw off the worker: stage materialization, the draw cache insert and the hand-off to the committer. It also lets the committer keep resource proofs for the collect epoch. It has been opt-in behindAPS5_DRAW_PIPELINEsince 17 October. With #15455, a draw finished there recaptures changed memory and skips refused draws as the worker does. This PR turns the finisher on by default, andAPS5_NO_DRAW_PIPELINEturns it off again. On today'smain, in PPSA04264's city, it raises the frame rate by 19.6% (frame p50 78.9 to 66.9 ms, Tested below). #20041 turns the epoch proofs on without the finisher; it touches the same switch reads, and whichever lands second adapts.APS5_PROFILE_DRAW=1) still finish every draw on the worker, as before; the debt entry says so.AgcDriverShutdown. A finisher job runs with the pipelined flag of the draw it finishes, so its captures see queued pipeline writes such as a queuedDUMP_CONST_RAM(agc_driver_queued_constant_ram_dump)._draw_pipelinevariants (depth 32, pipelined dispatches) and gains_no_draw_pipelinevariants for the worker path. The finisher-only metadata pass test registers no_no_draw_pipelinevariant (PIPELINE_ONLY).APS5_DRAW_PIPELINE=1, which this PR retires. The conflicts are textual; whichever lands second drops the variable.Tested
Windows 11 Pro 26300, Radeon RX 7900 XTX (AMD Software 26.10.1), Ryzen 7 7800X3D, Release, MinGW-w64 GCC 15.2. This head is the branch with
main2e48261498merged (169617ba07).PPSA04264 (v01.011.001), Performance graphics mode, a story save in the city (about 3,000 draws and 95 compute dispatches per frame), the player standing still.
mainand this PR were captured one after the other in the same session (mainat 02:23, this PR at 02:41), warm caches, the log not redirected, both withAPS5_PIPELINED_DRAWS=32APS5_PIPELINE_DISPATCH=1andAPS5_TRACE_SECONDS=240:60. The finisher switch is read once at start, so the arms are separate boots, not an in-run A/B.main2e48261498169617ba07)+19.6% FPS over the run, +19.1% presents in the window, the same GPU time per present.
On this machine
main2e48261498shows the picture upside down (#20835); both arms carry it.Traces, both captured on the same machine in one session: main 2e48261498, this PR. The summary lines and
tools/trace_digest.pyoutput are below; both traces are complete.main'sUploadCacheReadOnlyFlush.cppdoes not compile with MinGW (setenv); neither is touched by this PR.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: 74 on this PR (the same tests plus the_no_draw_pipelinevariants and the shutdown and queued-dump tests) and 49 onmain. The layer was loaded, noVUID-on either arm.tools/check_conventions.pypasses.main,APS5_VERIFY_DRAW_PIPELINE=1in the same title checked 16,975 reused epoch proofs against the full check at 9b8f0d7e32: 0 failed.trace_digest: main
2e48261498seconds 240:60 from present 4723: 753 presents, frame p50 78.9 / p90 83.8 / p99 90.3 / max 102.2 ms, GPU busy 24.3 ms per present
AMD Radeon RX 7900 XTX, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
2e48261498, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 39.5, Graphics.Draw 34.9, Graphics.Draw.draw_and_resource_release 28.9, Driver.Packet.draw 27.0, Driver.Draw 26.5, batch 24.3, Driver.Packet.dispatch 8.8, Driver.Dispatch 8.7, Driver.Draw.shader_compile_and_link 7.2, VideoOut.Flip 6.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest: this PR
169617ba07seconds 240:60 from present 5151: 897 presents, frame p50 66.9 / p90 70.5 / p99 81.2 / max 90.0 ms, GPU busy 24.3 ms per present
AMD Radeon RX 7900 XTX, AMD proprietary driver 26.10.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
169617ba07, dropped: noSlowest frames (largest slices inside each, inclusive)
Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Graphics.Draw 25.5, Driver.Packet 24.8, batch 24.3, Graphics.Draw.draw_and_resource_release 21.9, Driver.Packet.draw 13.5, Driver.Draw 13.3, Driver.DrawFinish 11.3, Driver.Draw.prepare 9.1, Driver.Packet.dispatch 8.1, Driver.Dispatch 8.1
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)Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T20:23:23Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Merged onto current
main, the PR makesagc_driver_queued_constant_ram_dumpfail on every run: a draw reads a stale constant-RAM table.mainhas the same failure underAPS5_DRAW_PIPELINE=1, so the finisher already had this bug, and this PR makes it the default path.What I ran
Head
9b8f0d7e3298f4ec475a759f3e9e30b7d13bea47,main086c0686c8adff3ee648fdbe34e0b0b647e1d511, merged tree1399eec3d931d7d63ecd70c6838ecaae6f2bef43, on Debian 13 (VM, Xeon Gold 6136), GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19).Results
maingit diff --checkcheck_conventions.pylibsagc_driver_queued_constant_ram_dump. The 7 known failures also fail onmain.queued_constant_ram_dump, merged tree, default environmentqueued_constant_ram_dump, merged tree,APS5_NO_DRAW_PIPELINE=1queued_constant_ram_dump,main's production files, default /APS5_DRAW_PIPELINE=1check_skips.pyagc_driver_pipelined_metadata_pass_no_draw_pipelineskipped unexpectedly (see non-blocking)agc_driver_image_gather_volume(VUID-VkSamplerCreateInfo-addressMode*).maindid not run that test, so there is no comparison for it (see Not verified).queued_constant_ram_dumpfailed.pipelined_metadata_pass_no_draw_pipelineskipped (on purpose).linear_target_direct_write_completionskipped on this device.agc_driver_queued_constant_ram_dump on the merged tree
Negative control
I restored
Driver.hpp,Execution/src/Driver/Draw/Draw.cpp,ShaderMemory.cppandGraphics/src/Draw.cppfrommainand rebuilt the affected test executables:Default environment: the tests whose expectations now depend on the finisher being on by default fail as intended:
agc_driver_draw_data_hit_user_wordsagc_driver_draw_data_hit_user_words_draw_pipelineagc_driver_draw_unsupported_buffer_typeagc_driver_draw_unsupported_buffer_type_draw_pipelineagc_driver_pipelined_metadata_passagc_driver_pipelined_metadata_pass_draw_pipelineAPS5_DRAW_PIPELINE=1(finisher on, without the recapture and refused-draw fix): these fail, which shows the fix from commit6e2c50b26eis needed and covered:agc_driver_draw_recapture_on_changeagc_driver_draw_recapture_on_change_no_draw_pipelineagc_driver_draw_unsupported_buffer_type_skip_refusedagc_driver_draw_unsupported_buffer_type_skip_refused_no_draw_pipelineagc_driver_queued_constant_ram_dumpalso fails in this run.I then restored the merged files and rebuilt;
git status --porcelainis empty.Findings
Blocking
DUMP_CONST_RAM.agc_driver_queued_constant_ram_dump(QueuedConstantRamDump.cpp#L243) fails on every run once the finisher is on. Draw 1 writes 64 instead of 255, meaning it read the descriptor table from before the first dump.APS5_NO_DRAW_PIPELINE=1, and onmainit fails only underAPS5_DRAW_PIPELINE=1. The bug is in the finisher, and flipping the default at Graphics/src/Draw.cpp#L3989 makes it the default behaviour.mainafter the baselines used in the description and in the NVIDIA run (1e65852). That likely explains why neither caught it. The claim "the^agc_suite has the same two failures asmain" does not hold on currentmain.agc_driver_queued_constant_ram_dumpto the finisher and_no_draw_pipelinevariants so the fix stays covered.Non-blocking
agc_add_draw_pipeline_testnow always registers<name>_no_draw_pipeline(CMakeLists.txt#L645-L646).PipelinedMetadataPass.cpp:122returnsVulkanTestSkippedunder that switch, soagc_driver_pipelined_metadata_pass_no_draw_pipelinealways skips, andtools/check_skips.pycounts it as an unexpected skip. Suggested fix: give the helper an option to leave out the_no_draw_pipelinevariant, or register the metadata pass test without it.draw_recapture_on_change,image_table_cache_bounds,lazy_resolved_abiandlinear_target_direct_write_completion. In each log the test prints its final "passed" line before the crash, which points at process teardown with the finisher thread alive. On lavapipe here the first three pass andlinear_target_direct_write_completionskips, so I can neither confirm nor refute these. They should be explained or fixed before the finisher becomes the default, because NVIDIA users would hit them.finishDraw→restartFinishedDraw→finishDraw(Draw.cpp#L1266-L1271). It is bounded:capturedMemoryChangedreturns false while aRecaptureScopeis active. No issue there.Not verified
agc_driver_image_gather_volumeVUIDs:maindid not run this test in the validation baseline, so I could not tell whether its newVUID-VkSamplerCreateInfo-addressMode*lines are new. The PR does not touch sampler creation, so they are probably not caused by it, but I did not check.To get this to a good state
main.DUMP_CONST_RAMso thatagc_driver_queued_constant_ram_dumppasses with the finisher on, and register finisher and_no_draw_pipelinevariants for it._no_draw_pipelinevariant that can only skip.^agc_suite and the validation comparison against the rebasedmain, and update the description.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T22:04:50Z.
Review: APPROVED
Re-checked — approved
All previous findings are resolved. The new commits make a finisher job run with the pipelined flag of the draw it finishes, join the draw finisher thread at shutdown, and let
agc_add_draw_pipeline_testleave out the variant that can only skip. The focused tests pass, and each fix is covered by a test that fails without it.What changed since my last review
main086c0686c8. Commit4e4b0f11b4is the same change as6e2c50b26e(range-diff=).060cddc3f7: a restarted finished draw starts again from its resolved draw parameters (tail.resolvedParameters). It re-snapshots unregistered program code that changed after capture.DrawRecaptureOnChange.cppgains cases for changed raw code and for folding the vertex offset once.b8f163c606:DrawFinisher::Stop()drains the finisher and joins its thread, andDriver::stop()now calls it (Lifecycle.cpp#L192). Once stopped, a draw handed to the finisher runs on the caller. New test:agc_driver_shutdown_threads_draw_finisher.77cd20649c: the finisher job setsDrawPipeline::Active() = job.pipelined(Draw.cpp#L750).agc_driver_queued_constant_ram_dumpgains_draw_pipelineand_no_draw_pipelinevariants.6330546a47: the helper takesPIPELINE_ONLY, and the metadata pass test uses it. The finisher assertion inDrawRecaptureOnChange.cppis limited toDepth() != 0.mainbase, 3971-test suite, 91/116 validation runs).What I ran
Head
6330546a47e6c4afda70b640f338678e6c9601a5,main04a9eb4fa2877eb6e40bf2c83adf972e40d89b24, merged tree729f064641b491c2bd1d42a1f25bb8f9b698fa91. Machine: Debian 13 (VM, Xeon Gold 6136), GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19).maingit diff --checkcheck_conventions.pylibs(script)main.check_skips.py(script)_no_draw_pipelinevariant is gone.linear_target_direct_write_completionskips on this device (as before).agc_driver_image_gather_volume, which themainbaseline did not run (same as last time)Negative control
In the merged tree I removed only the two new production lines and rebuilt both test executables:
DrawPipeline::Active() = job.pipelined;inDraw.cppDrawFinisher::Get().Stop();inLifecycle.cppThree tests then failed:
agc_driver_queued_constant_ram_dumpagc_driver_queued_constant_ram_dump_draw_pipelineagc_driver_shutdown_threads_draw_finisheragc_driver_queued_constant_ram_dump_no_draw_pipelinestill passed, as expected. I then restored both files from the merged tree and rebuilt. All 4 tests pass, andgit status --porcelainis empty.Failure without the pipelined-flag fix
I did not repeat the negative control for
060cddc3f7(restart from resolved parameters and changed raw code). Its newDrawRecaptureOnChange.cppcases pass on all three variants.Previous findings
DUMP_CONST_RAMwas not seen by draws on the finisher.agc_driver_queued_constant_ram_dumpand both its variants pass 3 of 3 runs. Without theActive()line, the default and_draw_pipelinevariants fail with the same message as before._no_draw_pipelinevariant that can only skip. The metadata pass test is registered withPIPELINE_ONLY, andcheck_skips.pyreports no unexpected skip.Stop()now joins it inDriver::stop()afterDrain().agc_driver_shutdown_threads_draw_finisherchecks that the finisher's thread-local state is released, and it fails without the join. I have no NVIDIA hardware. The author reports that the four crashing tests are fixed, and a new NVIDIA CI run should confirm it.finishDraw→restartFinishedDraw. It was not a defect.restartFinishedDrawnow also refreshes changed raw program code, and the retry stays bounded through the sameRecaptureScopeguard.New findings
Blocking
None.
Non-blocking
None. A note on the closing path: when the finisher is closing,
DrawFinisher::Enqueueruns the job on the caller (DrawPipeline.cpp#L187). The finisher job then sets the caller's thread-localDrawPipeline::Active()and does not restore it. This only happens afterDriver::stop()has joined the queue workers, so I found no reachable case where it matters.Not verified
agc_driver_image_gather_volume: themainbaseline did not run this test, so itsVUID-VkSamplerCreateInfo-addressMode*lines could not be compared. The PR does not touch sampler creation.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T21:17:22Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the code inspected; the remaining unreviewed test registrations prevent a formal approval.
What I ran
Read the prepared diff and changed source at head
f5e417b998c4221bdd64a4bb84a23d5b0e413409usingrepo_read.pyreader tools. No build or tests were run.Results
Findings
Blocking
None found in the inspected code.
Non-blocking
agc_add_draw_pipeline_testretiresAPS5_DRAW_PIPELINEfor the main pipeline and no-pipeline tests but leaves it in the plan verification environment. Since the finisher is now enabled by default, this is redundant and leaves the retired switch in test setup. Seecore/libs/prx/libSceAgcDriver/CMakeLists.txt:778.Not verified
The manifest lists 22 changed files and says all are included, but only these files were read:
core/libs/prx/libSceAgcDriver/CMakeLists.txt,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Lifecycle.cpp,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp, and the preparedreview/description.md,review/commits.md,review/manifest.json, andreview/diff.patch. Other changed files were not read, including the remaining test changes and documentation. Build and test results reported in the PR description were not independently verified.To get this to a good state
Nothing is required. Consider removing the obsolete switch from the plan verification test environment; this is optional feedback.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:40:41Z.
Review: COMMENTED
Reviewed — comments
The core switch and finisher shutdown paths were inspected at head
abf9bd9fafa01b36789bc1588a445ca20ceaaa0f; the review bundle contains 23 changed files, and the suite and build results are author-reported rather than independently run.What I ran
No commands were run. I used
repo_read.pyto inspect the prepared description, manifest, diff, and selected repository ranges at the pinned head.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
DrawFinisher::Stopsetsclosingpermanently, whileEnqueueruns jobs inline after closing. That is consistent with shutdown, but theStop-from-finisher-thread branch detaches the thread and leavesrunningtrue; shutdown currently callsStopfrom the driver thread, so the new test does not exercise this branch. Consider documenting or testing the intended invariant if this method can be called from the finisher thread. (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawPipeline.cpp:278)Not verified
Build, tests, convention checks, physical-console behavior, performance traces, and files excluded from the prepared bundle were not independently verified. The change’s 23 files are all marked included in
manifest.json; their full text was not read in every case. The diff and selected source ranges were inspected. The description’s test, build, convention, and performance results are author-reported.To get this to a good state
Nothing is required. The finisher-thread detach branch is an optional point for follow-up.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:50:00Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected code blocks merging; the author-reported checks support the change, but the full changed-line review could not be completed.
What I ran
Reviewed head
28f06938c2df6625aaa4fd257b588aa863fdaf81. Inspecteddescription.md,commits.md,manifest.json,diff.patch, and targeted source ranges viarepo_read.py. No build or tests were run here; the description reports focused tests, builds, and convention checks on a merged preview.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
The review folder's README says each added line must be read. I could not complete that:
review/files/listed no files, and only targeted ranges of repository source were available. Therefore the remaining changed lines, including documentation and test-registration edits, were not verified. The author reports 74 focused tests passed, builds for every target, andtools/check_conventions.pypassed on the merged preview; these were not run by me. No negative control was run.To get this to a good state
Nothing is required. Optional: make the changed-file contents available so the remaining added lines can be reviewed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T15:06:28Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected finisher and shutdown paths show no verified blocking defect; the review is incomplete because I did not read every changed file or run checks.
What I ran
Reviewed head
b44e9825e14f60b8c6811479795a19c7226a964fusing the prepared diff andrepo_read.pyreader. No commands or checks were run.Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
None.
Not verified
I read the description, commits, manifest, and full diff. At the pinned head, I read
DrawPipeline.cpp,Lifecycle.cpp,Draw.cpp, andDrawPipeline.hppat the relevant ranges, plus changed documentation excerpts. I did not read the head contents of every changed file; the manifest lists all 31 files as included, and no exclusions were listed. Build, test, and console behavior were not verified.To get this to a good state
Nothing is required. Optional: read the remaining changed files and run the focused draw, pipeline, and finisher tests before relying on this review as a complete approval.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:41:08Z.
Review: COMMENTED
The trial merge onto
c1601e56d5conflicts in the build and usage docs. Because this inverts the default, keep execution comparisons with no flag and withAPS5_NO_DRAW_PIPELINEexplicitly set, including shutdown, refused draws, and capture recapture. Existing tests that force the finisher on cannot exercise the changed default. The paired performance report and validation should use the final merged configuration.AI-assisted: yes.
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.