perf(agc): refresh pure data words of a cached draw stage instead of recapturing it #6093
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6093"
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 adriadam10 on 2026-10-14T21:44:02Z.
What
A draw stage whose captured words differ from a cached variant only at pure data positions is now a draw-cache hit: the live words are patched into the cached compiled result instead of capturing and materializing the stage again. This is the dispatch cache's
EqualDatahit (DispatchLookup.cpp) ported to draws.cacheDrawStages): each stage records its pure data positions from its resource capture (DataWordPositionson the flattened SRT binding), minus the words the draw decode reads (decodeReads), so a word that drives the decode, an address or a descriptor is never refreshed.validateVariant): a stage that differs only at those positions returnsEqualData;lookupDrawbuilds the stage's live words and patches them withpatchDataWords, now shared with the dispatch path (moved out ofDispatchLookup.cpp, same behaviour).APS5_NO_DRAW_STAGE_DATA_HITS=1turns it off (also off under stamp validation).APS5_VERIFY_DRAW_DATA_HITS=1(the existing switch of the data-only hits) builds the stage anyway and throws if runs, words, variant, push constants or bindings differ from the patched result.APS5_PROFILE_DRAW=1gets a line[draw-cache] stage data hits (10 s): ...(stages hit, words refreshed, verified, inserts with data positions).Why: on titles whose draw keys repeat but whose constants change every draw, the stage misses on its data and the whole capture runs again. Reports in #1201 (front end ~110 ms/frame vs ~32 ms in
Graphics::Draw), #4943 (Besiege, Diablo II, Minecraft Dungeons II, Hades II) and #494 (Hades II) name this step: refresh the constants in a cached stage instead of comparing them. #494 covers changed user words, #4943 equal contents behind moved pointers, #5609 bound buffer bases; this covers the data words themselves. Pure data words only: V# bases are not refreshed here.Template resources: with movable buffers (the default) a template hit already refreshes data-role bindings through
MovedReadOnlyBuffers, which compares their words with the (patched) descriptor, so a refreshed constant reaches the GPU without a new template.Tested
Linux, AMD Radeon 660M (RADV, Mesa 26.2.4).
StageDataHitsRefreshTheirWordsinagc_driver_draw_cache_reuse(and its_off/_verifyruns): a pixel shader reads a constant through its user words; three draws at 0.25 insert once and hit once (colour 64), then the constant becomes 1.0 and one draw is a hit with 1 stage data hit / 1 word refreshed, no insert, colour 255. WithAPS5_NO_DRAW_STAGE_DATA_HITS=1it misses on the fragment stage and still draws 255; with verify the hit is checked once. The colour check needed a triangle that covers pixels andGuestMemory::FlushGpuWritesbefore reading the target, so the case has its own vertex shader.EqualData(counters); not copying the live words (verify throwsdiffers ... in its words).ctest -R '^agc'before and after rebasing on main: everything passes exceptagc_driver_tessellation(fails on main too) andagc_driver_preparation_scope_settleunder-j4(passes 15/15 alone; also red in an unrelated train run 38623010537).APS5_PROFILE_DRAW=1, the newstage data hitsline) and oneAPS5_VERIFY_DRAW_DATA_HITS=1run with no throw on Astro's Playroom / Besiege / Diablo II would be welcome.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-14T21:49:46Z.
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/tests/execution/DrawCacheReuse.cppL127, L151core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppL76