perf(agc): skip the binds a continued draw repeats #6077
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6077"
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 meh7an on 2026-10-14T21:25:41Z.
What
A draw that continues the open render pass (
Pipeline::Continue) binds its pipeline again, and sets the viewport, the scissor, the pipeline library's dynamic state, the depth bias and the depth bounds again. Consecutive draws of a pass usually repeat all of them.The recorder now keeps what the open pass has bound (
PassBinding). A continued draw issues only the binds and sets whose values changed.Pipeline::Beginresets the record. So does a draw that binds other pipelines inside the pass: one that splits faces or the second channel, and a stencil replay draw (recordStencilReplaybinds its replay pipelines).On the S2 page of Sonic Origins Plus's main menu, the queue worker's samples per frame (APS5 sampler, 15 s) fell as follows:
Pipeline::setLibraryState0.88 to 0.09, andGraphics::Draw30.5 to 27.5.Tested
Windows 11 (10.0.26300), WinLibs GCC 15.2.0 (UCRT), Release, NVIDIA GeForce RTX 2080 Ti, driver 617.14.
9e9d86f81. #5875 now schedules a pipeline's optimized build at the top ofPipeline::Continue, and the repeat checks compare against the handle in use, the optimized one once it is ready. On that main, with this change, the full ctest suite passes 1336 of 1339, includingagc_driver_graphics,agc_driver_draw_cache_reuse(and_off),agc_driver_depth_bias_per_face,agc_driver_stencil_replay(and_no_gpl),agc_resident_present,agc_draw_snapshot_capandagc_draw_inputs_in_place.agc_driver_stencil_ref_exportis skipped on this GPU.agc_driver_gpu_indirect_arguments_misaligned_writer_aheadis not run: main itself does not compile it with MinGW.select_testsfails in its setup on Windows without the symlink privilege (WinError 1314fromsymlink_to), as on main.agc_driver_multisample_fill_host_onlyfailed once: main's own race, #6512, which #6522 fixes. With #6522's line added it failed 0 of 200 runs (8 at a time).APS5_TRACE_SECONDS=200:5on the same machine in one session, caches warm. Traces attached.The FPS shown in the title went from 5.00 to 5.30 (median of six readings).
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)Traces and summary lines (baseline 83b4df5e9c4b, this change 61ac8fdf6bd7):
binds-traces.zip
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-14T22:02:19Z.
Measured on this branch (a0ea880fe, 4 commits behind main), default CMake build (CMAKE_BUILD_TYPE empty, so unoptimized), lavapipe (llvmpipe), CachyOS Linux 7.2.9, built without errors: these 7 targets pass, one run each:
agc_driver_graphics_tests,agc_driver_draw_cache_reuse_tests,agc_driver_depth_bias_per_face_tests,agc_driver_stencil_replay_tests,agc_driver_stencil_ref_export_tests,agc_driver_prepared_graphics_tests,agc_driver_prepared_unregistered_graphics_tests.I read the diff. The pass-bound record is reset in
Begin, and after a draw that binds other pipelines (face split, second channel, stencil replay), and the library state is always re-set whenstencilReplayReferenceis present.Limits: no new test checks that a repeated bind is skipped or that a changed value is re-issued, so these passes show no regression in the existing tests but not that the skip logic is right. I did not mutation-check it, did not measure the performance claim (the PR's numbers are from an RTX 2080 Ti on Windows), and did not repeat the runs.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:14:16Z.
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/Graphics/src/Pipeline.cppL7Some 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/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T23:29:29Z.
The rebased head still has no test for what this changes. I'd like one that continues a draw with the same pipeline, viewport, scissor and depth/stencil state and checks the binds are skipped, then changes one field at a time and checks each change is reissued. #5609 changes the same five files (it conflicts with this in
Pipeline.hpp,Pipeline.cpp,Recorder.hppandDraw.cpp), so please agree with its author which one goes first and declare it with Depends on.Imported from boykopovar/AnyPS5. Originally posted by meh7an on 2026-10-16T23:42:14Z.
Thanks for the reviews. I'm closing this one, since #5609 (@TheAggie) was opened before it and already skips the same binds in
18acdbf4a("skip unchanged dynamic state between draws of an open pass"). I missed it because its title is about buffer base relocation.Both PRs keep the pass's last-bound state per command buffer and reset it when a pass begins and after the back-face and second-channel draws. Both skip the pipeline bind, viewport, scissor and library state that a continued draw repeats.
The one difference is that this PR also skips
vkCmdSetDepthBiasandvkCmdSetDepthBoundson pipelines without libraries, where #5609 filters only with libraries. If that is wanted, I can open it as a small follow-up on top of #5609 once it lands, with the skip-and-reissue test asked for here.Pull request closed