Repository navigation
perf(agc): refresh pure data words of a cached draw stage instead of recapturing it - #6093
Merged
Merged
Conversation
…recapturing it A draw stage whose captured words differ from a cached variant only at pure data positions (read by the shader as data, never as an address, descriptor or decode input) is now a hit: the live words are patched into the cached compiled result, as the dispatch cache's EqualData hits do. The positions are recorded at insert from the stage's resource capture, minus the words the draw decode reads. Patched draws take no draw recipe. APS5_NO_DRAW_STAGE_DATA_HITS=1 turns it off; APS5_VERIFY_DRAW_DATA_HITS=1 builds the stage anyway and throws on any difference. The draw-cache profile line counts stage data hits and refreshed words. Co-Authored-By: Claude <noreply@anthropic.com>
11 tasks done
|
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.
|
11 tasks done
11 tasks done
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)