perf(agc): learn draw relocation shapes from data donors #26778
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26778"
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 akkadbakkad89 on 2026-11-24T21:14:57Z.
What
When a draw's pointers move between captures, its stored stage variants are reusable only if the draw-cache relocation machinery can patch the moved words. Two pieces of that machinery were missing:
learnPendingRelocationlearned moved shapes only from the keyed entry's own decode results. When that entry lacks decode (data-only hits dominate in some titles), it now learns from the data-donor entry held inDrawRelocationPending.donor.relocatedContentKeyaddedhigh << 32twice and every relocated read landed near twice the pointer's 4 GiB region — unreachable. The offset is now based on(word.high << 32) + AlignedWord(userData[index]), so a read through a moved callee pointer resolves at its delta in the new copy.Stages whose decode records reads (vertex fetch,
resourcesNum > 0) remain non-relocatable; extending relocation to them is split into a follow-up PR per the maintainer's request in #26595.Tested
Windows 11, NVIDIA RTX 3070 (driver 617.42).
ctest -R 'agc_driver_draw_relocate_user_values|agc_driver_draw_cache_relocation'withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LAYER_PATH=D:\VulkanSDK\Bin(layer 1.4.363.0 ≥ VK_HEADER_VERSION 335;Insert instance layer "VK_LAYER_KHRONOS_validation"present in each log, nowas not found but was requested, noVUID-lines): the change passes 8/8 andmain(61cce6e8) passes 8/8 on the same subset.New test
HighCalleeWordsLearnDeltaOffsetsinDrawRelocateUserValues.cpp: a callee pointer and a captured run are placed in the guest arena above 4 GiB, the draw entry is fed to the reallearnPendingRelocationthrough both the keyed path and the data-donor path, and the learned shape must record the run's offset as its delta (0x80), not the absolute address;relocatedContentKeythen keys the donor, a moved copy with identical contents, and a moved copy with changed contents correctly. With the base regression reintroduced the test fails at the delta assertion ("a run through a pointer above 4 GiB learned an absolute offset instead of its delta"); with the fix it passes.MovedDataHitsTheCacheandMovedForwardedWordReachesStageDataHitcontinue to cover the same-data reuse and pointee-changed re-read cases through real draws.In-world (PPSA03530 GTA-VC, PPSA03524 GTA-SA, measured on the instrumented equivalent of these two fixes): every admitted donor relocates — 0 refusals across ~1.1k donors vs ~50% refused under the stock admission. GTA-SA fps A/B in the same scene: 40–54 vs 37–49 presents/10 s — no measurable regression; the ~4–5 fps ceiling there is guest-memory collect, not relocation.
PPSA21564-class workload (Lucky's Tale, reported by JJenkx on the same two fixes): failed relocated reads 101k→0, trial idle-skip 94%→12%, relocation hit rate 2%→56–59%, stage compiles ~300k→~155k per 10 s, +4% presents, ~6 ms better p99, no FATAL. Astro Bot (PPSA21564) itself has not been run on this head — flagged for verification in #26595.
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-25T01:33:14Z.
Review: DISMISSED
Reviewed — changes requested
Changes are required before merge: fix the decode-read attribution so each read uses the actual user-data pointer word.
What I ran
Reviewed head
79699ccee24f453ad7d0e4d9e80f9c88ec7ff34cusingrepo_read.py. No tests were run by me; the test and workload results in the PR description are author-reported.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderInputState.cpp:354: the attribute-table read is tagged withattribWord, the 32-bit contents loaded from the table, instead of the user-data word indexattribWordis meant to identify. The table address is formed fromuserData[attribWord]anduserData[attribWord + 1]at lines 283–284, so this attribution can be an arbitrary value outside the 0–63 user-word domain.DrawCapture.cpp:368–374then rejects the stage as non-relocatable when that value is out of range, or treats an unrelated word as the pointer when it happens to be in range. Pass the pointer-word index (the localattribWordidentifier is shadowed by the later contents variable) torecord; apply the same correction to the buffer-table read atShaderInputState.cpp:364, which already usesbufferWord.Non-blocking
None.
Not verified
To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T06:53:40Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes implement the stated donor-learning and high-address offset fixes; the reported test and runtime results were not independently run here.
What I ran
Inspected head
21db7bb556b22aed99781c2f04c813f78f6535adusingrepo_read.pyto read the prepared review bundle and changed files. No test commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Reviewed the prepared diff and head-pinned repository files:
DrawCache.hpp,Draw.cpp,DrawRelocate.cpp,DrawRelocateUserValues.cpp, andagc-draw-relocation-decode-reads.md.Not verified
The Windows/Vulkan test results, in-world captures, performance claims, and behavior on Astro Bot were not independently verified. No files were excluded by the manifest; all five changed files listed there were read.
To get this to a good state
Nothing is required.
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.