perf(agc): draw stages use their shared compiled result instead of a copy #5687
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5687"
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 Raghav314 on 2026-10-14T06:43:00Z.
What
materializeDrawStagereturned a copy of the compiled result it had just materialized (RecompileResult result = *stageCapture.compiled), so every stage of every draw that is not a draw-cache hit copied a wholeRecompileResult(its bindings, push constants and vertex attributes) intoDriver::draw'sresults, and freed it again at the end of the draw. The shared result stays alive instageCapturesfor the whole draw anyway.materializeDrawStagereturns the shared result, andDriver::drawkeeps it incompiledStages; the stages point at it.results, as before.resultskeeps its reserve ofprograms.size() + 2, which still covers the most it holds (two rect-list stages and a copy of each program).The shared draw-stage result was in an earlier version of #1202 and left out in its rebase because
mainrewrites stage results; this keeps the copies for the one path that rewrites them.PPSA36082
Standing in the hub, the queue worker is 99% busy, and a profile of it showed about 3.4% of its time copying and freeing these results (inside
malloc/free). Two hub runs in one sitting, one after the other (traces attached):mainf74ec639c:f74ec639c(built from the working tree before the commit, hencedirty):The stage path this changes takes less of the frame:
Shader.DrawStage9.13 to 8.57 ms per frame andDriver.Draw.shader_compile_and_link11.19 to 10.61 ms. The frame time p50 went from 28.3 to 27.6 ms, but an earliermainrun on the same machine gave 500 presents and p50 29.677, so whole-frame numbers vary by about as much as this difference. The picture in the hub is unchanged.aps5-trace-f74ec639c457-742938.json.gz - This PR
aps5-trace-f74ec639c457-743649.json.gz - Main
Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090, NVIDIA 615.78.08.
agc_driver_indirect_patched_stage: a non-indexedDRAW_INDIRECTwhose base vertex location is the vertex stage's user data word 0 takes the CPU path (the stage does not fold that word). The vertex stage writes that word as its depth. A record with 0 over a register value of 2.0 must draw the same pixels as a direct draw with 0, and a record with 2.0 over a register value of 0 must draw nothing (clipped). It passes onmainand with this change. It fails when the copy before the rewrite is skipped on a miss (segmentation fault) and when the patched stage is not materialized again (the draw keeps the register's depth).build.ymlrun locally on this branch (rebased onmaind8888df9b): configure with SPIRV tools on, test registration check, build, libs, ctest 1115/1115,check_skips.pyclean (7 expected skips).APS5_HOST_IMPORT_MIB=6784 APS5_TRACE_SECONDS=120:15, hub standing still, shader cache warmed for each build.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 github-actions[bot] on 2026-10-14T07:07:34Z.
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/Execution/include/Driver/Driver.hppL129core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cppL217, L348core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppL13Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-14T08:29:56Z.
Runs for this PR at head
73a808e9a. Windows 11, MinGW-w64 GCC 15.2.0 Release, two GPUs in one machine: Intel UHD Graphics 770 (driver 32.0.101.6129, picked withANYPS5_GPU=Intel) and RTX 4090 (NVIDIA 616.92).agc_driver_indirect_patched_stage) pass on both GPUs.ctest -R "agc_driver|agc_masked|agc_shader" -j4: no failures on either GPU. Intel: 399 tests, 28 skipped. NVIDIA: 399 tests, 1 skipped (agc_driver_stencil_ref_export). The skips are the same as onmainwith each GPU. On the UHD 770 they are features it doesn't support: f64, 64-bit and float atomics, mesh shaders, fp16 interpolation and dot, shader clock.No difference between the two GPUs.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T10:42:58Z.
Checked the diff (shared result lifetime via
compiledStages/stageCaptures, the indirect CPU path now always copies the stages it rewrites,resultsreserve still covers the maximum), built and ran the libSceAgcDriver tests (agc_driver_indirect_patched_stagepasses;agc_driver_tessellationcrashes inside local RADV and does so identically with the PR's source changes reverted) and merge-tree against #5431 (clean). Windows runs from @tibzejoker on Intel and NVIDIA are green. Merging once the full Build is green.