perf(recompiler): index memory users once per indirect image planning pass #2813
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2813"
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 SleglJan on 2026-10-10T16:00:22Z.
What
MemoryIndexBelongsToinResourceTracker.cppwalked every instruction of the program on each call and askedBufferAccessOf,AddressOpcodeInfoOfandImageOpcodeInfoOfabout each one.TryMakeTableImagecalls it for each of a table handle's eight descriptor dwords and once more for a material key.PlanIndirectImagescallsTryMakeTableImagefor every image instruction whose handle is not planned yet, so each such instruction could cost up to nine walks of the whole program. This runs once per shader per process, also when the shader disk cache hits.PlanIndirectImagesnow indexes the instructions that access memory by their memory index once, before it plans. While the pass runs,MemoryIndexBelongsTolooks the index up instead of walking the program; the predicate is the same.Issue: #2774. Overlap: #757 and #758 restructure this pass (
PlanTableColumns) and conflict with this commit in one hunk (#757) and two (#758). #1184 and #2653 also changeResourceTracker.cpp, in other functions, and merge with this commit without conflict in that file.Tested
BUILD_TESTING=ONandANYPS5_ENABLE_SPIRV_TOOLS=ON, this branch onmain57f96fd2: of 701 tests, 696 pass, fourvideo_out_flip_*tests (lifetime, reopen, controls, overlay) skip (no Vulkan in SDL's offscreen video driver), andagc_driver_dcc_keys_first_writefails, which is #2767 (NVIDIA, Linux).agc_shader_bindless,agc_shader_memoryandagc_driver_bindless_imagescover the table-planning path.tools/check_conventions.py --base upstream/mainandgit diff --checkpass.maina29ef592with the stack listed in #2523 that gets 007 to its first flip, withResourceTracker.cppas onmain; that file is the same ata29ef592and57f96fd2.AccessesMemory(the same condition), the lookup usesstd::ranges::all_of, and a redundantclear()was dropped.CompiledShaderInfo::shaderHash, which holds the shader's code address; 8 pairs are fully identical. As a control, two cold runs of one build with #1184's tracker hunk (below) differ from each other only in address fields too.agc_shader_replay, 2 runs each on an idle machine, takes 18.3 to 19.9 s without this commit and 2.2 to 2.3 s with it, ending in the same offline error).ResourceTracker.cpp, which carries part of #1184, the same change (the same earlier revision) gives a warm median of 24.6 → 16.2 s over 4 + 4 runs. With a two-line logging probe, both builds started 2,514 background preparations, of which 2,478 succeeded.Checklist
main; no other open PR implements the same changeNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01Fnrk5Dazjb2tLooVSpdRQq
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-10T16:11:56Z.
Independent platform validation on real hardware (Linux x86-64)
Built and tested standalone PR head
7eba9f5bon Linux x86-64:BUILD_TESTING=ON.main57f96fd2.Verification Results:
agc_shader_bindless— Passed (0.02s)agc_shader_memory— Passed (0.06s)agc_driver_bindless_images— Passed (0.03s)Solid
O(N)index optimization inResourceTracker.cppthat maintains exact behavioral parity across table image planning passes.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T17:25:09Z.
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/shader/recompiler/Optimization/src/ResourceTracker.cppL1286core/shader/recompiler/Optimization/src/ResourceTracker.cppL276-277, L1286Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:45:23Z.
Checked the equivalence of the indexed lookup with the previous walk (same predicate, index only live during
PlanIndirectImages, which adds/removes/changes no instruction), built on top of current main and ranagc_shader_bindless,agc_shader_memoryandagc_driver_bindless_images: all pass. Merging.