refactor(agc): split Graphics::Draw into a prepare and a record step #8992
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8992"
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 SP4C3B4R-8 on 2026-10-21T08:52:46Z.
What
Step 1 of the draw-side series asked for in #7895 (@oneandonlydean, issuecomment of 10-19): split
Graphics::Drawinto a prepare step and a record step, with no behaviour change. It is the draw counterpart of #8278.prepareDrawprepareDrawInputs), the color target bindings (resident lookup or per-draw target),resolveDrawResourcesand the cache insert, the indirect records' path, the recorded/lean decision, the pipeline and the framebufferrecordPreparedDrawrecordDrawand the draw recipe) or the synchronous path (batch, barriers, render pass, submit, write-back), then the reportThe hand-off is a
PreparedDrawthat holds what used to beDraw's locals, in the same declaration order, so they are destroyed in the same order.TargetBindingmoves fromDraw's body to the anonymous namespace becausePreparedDrawholds the bindings.Drawnow builds aPreparedDrawand calls both steps. Both steps keep their code where it was in the file: the diff adds the struct, the two function heads and the alias lines at the cut. Nothing is reordered or moved across the GPU mutex.DrawWithRecipeis unchanged.The next steps from #7895 build on this cut: moving parts of the prepare step off the committer, then a check at record time that catches writes landing between prepare and record (CPU writes and queued GPU items) and falls back to preparing again. Each will come behind a switch that is off by default, with before/after timings from the same scene and a test that writes in that window.
Tested
Windows 11, RTX 5070 Ti (NVIDIA 617.42), Ryzen 7 7800X3D, MinGW GCC 15.2, Release.
Based on
maind6eafa54d(rebased 10-22: the only conflict was the sample-order and depth-location locals thatmainadded at the end of the prepare step; they move intoPreparedDrawlike the others). The tests below were rerun after the rebase.agc_driver_graphics_tests: passes.agc_driver_*draw*,*stencil*,*indirect*,*multisample*,*msaa*,*target*,*pass*): 99 of 99 pass, including the newagc_driver_polygon_mode_drawandagc_driver_msaa_layout(agc_driver_stencil_ref_exportskips, as onmain).mainf894ba69d10.18 fps, this branch 10.37 fps, which is run-to-run noise. Behaviour is unchanged, so there is no switch.python tools/check_conventions.py --base origin/main: all checks passed.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 clairtonmichel on 2026-10-21T08:57:18Z.
Tested on AMD Ryzen 7 9800X3D and AMD Radeon RX 7900 XTX (RADV NAVI31, Fedora Linux, Mesa 26.2.5):
Graphics::Drawinto preparation and recording stages introduces zero regressions on host. (The 3 failing tests are the known RADV/Mesa edge cases:guest_memory_lifetime,image_array_window_past_layer_limit, andtessellation).Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T09:36:01Z.
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/Draw.cppL2150-2152core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2151-2152core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2176-2177core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2200-2228core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2151-2152core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2151-2152core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2176-2177Some 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/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppImported from boykopovar/AnyPS5. Originally posted by teepean on 2026-10-21T13:39:47Z.
@SP4C3B4R-8 #8992 on Stray (PPSA02100), as promised in #7895. Short version: identical output and the same timings within noise.
Setup
mainb5d763770aagainstmainb5d763770a+ this PR (head 5f3466bd70, merged without conflicts).engine.ini, scripted input. OnlyAPS5_TRACE_SECONDS=185:20set, one run at a time, 8 rounds with the order alternating; the numbers are fromtools/trace_digest.py.Tests
The 51 draw-related tests (
agc_driver_*draw*,*stencil*,*indirect*,*multisample*,*msaa*,*target*,*pass*, andagc_driver_graphics_tests) withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1:agc_driver_draw_pipeline_tracein both variants with ctest's environment.agc_driver_stencil_ref_exportskips: the driver here has noVK_EXT_shader_stencil_export.Timing (ms; runs in the slow state below are left out)
mainmain173.4, 181.5, 181.4, 166.3, 191.5, 176.5; this PR 153.0, 178.3, 199.3, 185.8, 171.6.mainbefore, queue 0's worker bounds this scene, and the committer is busy about 29 % of the frame in every kept run of both builds.main, 3 of this PR) spent the whole window in a state where a frame takes about 1 s. In it, queue 0's worker is 95 % busy and the committer 80-85 %, both about 15 times their usual time per frame. Plainmainfalls into it too (I also saw it onmain7e95bde794and5f7e30233e), so it isn't this PR. I'll look into it separately.Frames
Frame dumps (
APS5_DUMP_FRAMES=40, every 104 presents), two runs of each build, compared over frames 26-37:main's second run against both runs of this PR: frames 26-32 mean 0.0-1.1, at most 0.04 % of pixels off by more than 64.main's first run differs from all three other runs in frames 28-31, by about 20 % of pixels. The other three runs agree there.So the comparison shows no difference between the builds beyond what two runs of one build show. Traces and digests are available on request.
AI-assisted: yes (text with Claude Code; the numbers are from my machine).
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-22T08:10:51Z.
@teepean @clairtonmichel thanks for the runs: identical frames and timings within noise on Stray, and no regressions on RADV, which is the bar @oneandonlydean set for this step.
Rebased on
maind6eafa54d(it was conflicting). The only conflict was the sample-order and depth-location locals thatmainadded at the end of the prepare step; they now live inPreparedDrawlike the other locals, and the record step reads them from there. The draw tests were rerun on the rebase: 99 of 99 pass, including the newagc_driver_polygon_mode_drawandagc_driver_msaa_layout. The description is updated.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T08:30:11Z.
@SP4C3B4R-8, thanks for the rebase and the runs. I read it against the step-1 bar and it's a pure move: each local becomes a
PreparedDrawmember in its old declaration order (so destruction order is unchanged), the early exits return false where they returned before, and the rebased locals (reordered,reorderPass,depthLocations) moved correctly.One small ask before merge, about profiling only:
DrawTimernow starts whenPreparedDrawis built at the top ofDraw, beforerecorder->BoundKeptBytes(), which can submit or finish batches and so wait on the GPU. WithAPS5_PROFILE_DRAWset, the first phase (PhaseSetup) and the[draws]totals now include that wait. Without the variable nothing changes, so the frame-time runs can't show it. Could you start the timer at its old point again, for exampletimer = DrawTimer(profile);whereDrawTimer timer(profile);used to be? The later steps of the outline will be measured with that profile, so it should matchmainhere.After that push, I'll run full CI on the new head and merge once it's green.
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-22T09:18:40Z.
@oneandonlydean done in
930b9640d:prepareDrawrestarts the timer withtimer = DrawTimer(profile);right whereDrawTimer timer(profile);was onmain, afterBoundKeptBytes()and theGraphics.Drawtiming. SoPhaseSetupand the[draws]totals no longer include that wait. The draw tests pass again on the new head (100 of 100 with the graphics tests), and conventions pass.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T09:47:43Z.
@SP4C3B4R-8, merged, thanks. Full CI on
930b964was green on Linux and Windows, and the timer fix keeps the draw profile output the same as onmain, so the later steps of the #7895 outline can be measured against it. Thanks also to @teepean and @clairtonmichel for the runs.