perf(agc): relocate dispatch-cache entries whose user-data pointers or buffer descriptors moved #24661
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24661"
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 bagodees on 2026-11-20T22:34:41Z.
What
A dispatch whose key is not in the dispatch cache now copies the entry of a recent dispatch of the same program when only its user-data pointers, or the buffer descriptors behind them or in user data, moved. Before, every such dispatch took the uncached path. With
APS5_PIPELINE_DISPATCH=1that path also drains the draw committer.Titles that keep their per-frame constants in a ring buffer move these pointers every frame. In PPSA01494 the SRT pointer in
user[12]advances 0x20000 per frame, and the constant buffer descriptors inside it move with it. So nearly every dispatch missed: about 23,000 inserts and 2,400 hits per 10 s.DispatchRelocate.cpp): an inserted dispatch records its user data as a donor, up to 8 per program. On a miss, at most two donors whose differing user words are relocatable pointers (asBaseand notasValue), or the base of a buffer descriptor in user data that aGuestBuffersbinding holds, are tried.VulkanDevice.cpp): a dispatch recipe is now also built when the template served moved read-only buffers, markedmovesBuffers. Such a recipe hit runsMovedDispatchBuffersand binds them throughPrepareDrawBindings, as the template path does, and rebuilds when they cannot move. A relocated copy of a recipe carries the patched push words.ShaderResources::MovedRunAccesses): a dispatch recorded with moved in-place bindings reports their new ranges to the overlap runs. The template's old range is left out when no unmoved binding reads it. Before, a moved dispatch reported the ranges the template was built at.APS5_NO_DISPATCH_RELOCATIONandAPS5_NO_MOVED_RECIPESare runtime switches, soAPS5_ABcan toggle both within one run. WithAPS5_PROFILE_DRAWa[dispatch-relocate]line counts each outcome per 10 s.agc_driver_dispatch_relocationdispatches one program through a table that moves with the same contents, then with its input buffer moved, then with the buffer resized. It checks the results and that the first two were served by relocated entries and the third was not.image_table_vouched_lookupsturns relocation off for its scenario: it tests the capture path's column reuse for an SRT moved with the same contents, which relocation now serves as a hit.Overlap:
tools/pr_overlap.py --branchfound no conflicting lines and no shared exports; it could not compare 108 open PRs that conflict withmainthemselves. Of those, none relocates dispatch-cache entries. #21780 adds the template's data buffer insideShaderResources::RunAccesses, next to therecordDispatchline where this PR addsMovedRunAccesses; the two are independent.Tested
Windows 11 (10.0.26300), Intel Core i9-12900K, NVIDIA GeForce RTX 4080 (NVIDIA 621.01), WinLibs GCC 15.2, Release, on
maine481b13555.mainand on this branch, same machine and GPU, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer(Vulkan SDK layer 1.4.363). Command:ctest --test-dir build -R "^agc_driver_.*(dispatch|relocation|recipe|overlap)|^agc_driver_graphics$|^agc_relocation_runs$" -V.main: 41/41 passed.agc_driver_dispatch_relocation).Insert instance layer "VK_LAYER_KHRONOS_validation"(68 and 70 times), neither haswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-error.ctest -R "^agc_driver"(1462 tests) on this branch: all pass except five that fail the same way onmainon this machine:agc_driver_image_plane_address_on_line,agc_driver_image_sample_lod_clamp,agc_driver_image_sample_lod_clamp_shader_lane,agc_driver_stencil_plane_memoryandagc_driver_msaa_dcc_unwatch.agc_driver_store_over_untrackedpasses and fails intermittently on both (2 of 4 runs failed onmain).APS5_WORKER_AFFINITY=1 APS5_PIPELINE_DISPATCH=1:APS5_AB=20:APS5_NO_DISPATCH_RELOCATION+APS5_NO_MOVED_RECIPES(start 60 s, settle 5 s): frame time 85.6 ms with both on against 87.4 ms with both off, the mean of 8 phases each; on was faster in 7 of 8 pairs.mainand this branch, mean p50 over 60-180 s:main96.4 and 96.9 ms, this branch 95.4 and 94.3 ms. GPU busy per present was the same, about 61 ms.tools/trace_digest.pyof the secondmainand branch runs, intervals 7-18 (60-181 s):main(e481b13555):This branch:
Not tested: Linux, macOS, AMD and Intel GPUs, other titles.
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 MarcZX10 on 2026-11-20T23:08:54Z.
Review: COMMENTED
Reviewed — comments
The review is incomplete because not all changed files were read and no checks were run; no concrete blocking defect was verified.
What I ran
7544a2b95195542bb25db796f10af4afffa006ecusing the review reader.Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Not verified
The full text of all changed files was not read. In particular, the changed
VulkanDevice.cppandShaderResources.cppwere inspected only around relevant hunks, and the remaining changed files were not all inspected. No build, tests, negative control, other operating systems, hardware, or console behavior was verified. The author-reported test and performance results in the description were not independently run.To get this to a good state
Nothing is required. Optional: complete review of the remaining changed-file content and run the focused checks on this head before making a formal approval decision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T07:00:53Z.
Review: COMMENTED
Reviewed — comments
Changes are not ready for a formal decision because the review bundle omitted full text for two changed files, leaving recipe buffer movement and moved-range overlap behavior unverified.
What I ran
Reviewed head
6a4e13379d525727fb3351d08833d4dacdf6cea9from the prepared diff and targeted source context. I did not run commands or tests. The author reports Windows 11, GCC 15.2, Vulkan focused tests (42/42 passed), broader driver tests with five known baseline failures, and PPSA01494 measurements; these were not run by me.Files read:
review/description.md,review/commits.md,review/manifest.json,review/diff.patch,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchInsert.cpp, andcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchRelocate.cpp.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
Full text was excluded for
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp. Their diff hunks were reviewed, but their surrounding implementations and callers were not. Other included changed files were listed in the manifest but not all were read in full. No tests were run.To get this to a good state
Nothing is required. Optional: complete review of the excluded files and run the reported focused checks on this head.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:04:07Z.
Review: COMMENTED
Please reject a relocation when two user-data descriptors with the same donor value move to different destinations. In
relocateDispatchEntry,userDescriptorsdeduplicates byheld.from, so it keeps the first destination and accepts the second descriptor as a fit.ReplaceDescriptorthen sends every matching guest-buffer binding to the first destination. A shader that originally reads two slots backed by the same buffer can therefore keep reading one buffer after the caller rebinds the slots to two different buffers. The old low-word check cannot catch this once the first replacement has removed that value from the compiled bindings. The captured-table comparison already rejects a conflicting destination for the same source. The direct user-data path needs the equivalent check, including slots whose descriptor stays at its original address.Source inspection at
6a4e13379d. This head also conflicts with the main revision I checked.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.