perf(agc): relocate cached draws across moved user-data V#s and fetch subroutines #13610
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13610"
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 ntamas94 on 2026-10-30T19:32:30Z.
What
#4943 finds a cached draw through a relocation alias when user-data words moved and the data behind them is equal. It only moves user words that the stage's SRT walk used as a base and never as a value (
asBase & ~asValue), and it refuses every other move. Two kinds of user words that move between otherwise equal draws fall outside that rule:descriptorPatches, applied with the forwarded-word patches).s_swappctarget of a GCN vertex program, i.e. its fetch subroutine. The callee is linked into the code, so a moved pointer was refused.UserDataCalleeLengthwords at the address). A copy of the same subroutine at another address relocates; changed code does not.Crysis Remastered (CUSA18659) shows both kinds. It keeps its per-object constant buffers as V#s in VS user SGPRs 4..15 and PS 12..15. Its renderer writes each draw's fetch subroutine and vertex buffer table into a ring, and passes them in VS s[0:1] and s[2:3].
#5609 (open) handles a third case that Crysis shows as well: a buffer whose V# is read from captured memory (here the vertex buffer table behind s[2:3]). Its base moves while the table's other words stay equal. That case is not in this PR; data for it is on #5609. The two do not overlap:
noteBufferBaseWords);#9899 (open) memoizes the cost of linking user-data callees. It does not change the draw-cache key, so it is complementary.
APS5_NO_DRAW_RELOCATION=1turns all draw relocation off, as before.Tested
Windows 11 Pro (10.0.26200), WinLibs GCC 15.2.0, Release with
BUILD_TESTING=ON, NVIDIA GeForce RTX 2080 (driver 617.14), on this branch. After mergingmainde83e8f270(merge9ea244c4c1), the new test and the relocation/reuse tests pass again under the validation layer: 14 of 14, noVUID-error, no missing-layer message. The other runs below were made before that merge, onmain16345cad6a+ this branch's commits; the mergedmaincommits do not touchlibSceAgcDriver/Execution/src/Driver/Drawor its headers.agc_driver_draw_relocate_user_values:agc_driver_draw_cache_relocation*,agc_driver_draw_cache_reuse*,agc_driver_mesh_draw_relocation) on16345cad6a+ this commit: 14 of 14 pass.ctest -j 8onmain4bc9e779aa+ this commit, before rebasing onto16345cad6a(whose 40 commits touchlibSceAgcDriver/Executiononly inVulkanDevice.cpp): 3,141 of 3,144 pass, 13 of them skipped.vulkan_validation_gate_reports,job_reference_errorsandcheck_compile_test_windows_gcc_response_text_mode_is_not_reinterpretedfail in Python tool tests on this machine's Microsoft Store Python (OSErroron its WindowsApps alias path); they testtools/, which this PR does not touch.tools/check_conventions.py --base origin/main --head HEAD: all checks pass.main16345cad6aand on this branch,ctest -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1(agc_driver_draw_cache_relocation*,agc_driver_draw_cache_reuse*,agc_driver_mesh_draw_relocation, and on this branch alsoagc_driver_draw_relocate_user_values):main: 13 of 13 pass;was not found but was requested by env var VK_INSTANCE_LAYERS;VUID-error. The layer was active: both logs carry the same 16Validation Warninglines (Undefined-Value-ShaderOutputNotConsumed).main, so both captures run on the same local branch that reaches it:c06272e103(mainfrom 2026-10-24 plus local GCN fixes);b40b24d172).libSceAgcDriver.prxdiffers between the two runs.APS5_TRACE_SECONDS=310:30,APS5_PROFILE_DRAW=1, same machine.tools/performance_compare.py(the captures are windows, sotrace_digest.pyhas no interval rows to print):Shader.DrawStageSo this change alone does not shorten Crysis's frames measurably: its relocated vertex stages still miss on the vertex buffer V# base inside the table. That table is #5609's case.
The earlier numbers, which included a local stand-in for #5609's case (50.3% hits, 59.8 µs per draw packet against 71.7), came from a different local configuration and are not this PR's gain.
Cache verification on the candidate,
APS5_VERIFY_DRAW_DATA_HITS=1 APS5_VERIFY_DRAW_ENTRIES=1, the same scripted run, 400 s:Checklist
main; no other open PR implements the same functions (searched open and closed boykopovar/AnyPS5 PRs for draw relocation, user data V#, fetch shader relocation, swappc callee, user-data callee, buffer base moved and draw cache key on 2026-10-30; #5609 and #9899 are related, see above)NotImplemented_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-10-30T19:40:59Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The
perf(agc)report omits repository-required matched captures and Vulkan validation evidence, so the performance and GPU results cannot be independently checked.What I ran
Reviewed head
306b439fd684485dbca87c068037a02678c1f5aaagainst PR base16345cad6a692bc37e682150f11c7ab635788941. The stack helper previewed the PR cleanly against then-currentmaincf0e33b6a070c2c69e2956a524da75082cb2cff1. Environment: Linux x86-64, Python 3.11.2, GCC 12.2.0. I did not build or compile.Results
git diff --checktests/execution/*.cppis collected byGLOB CONFIGURE_DEPENDSand passed toadd_test_executable; this is a false positive.Unedited output from local checks
git diff --checkexited 0 and emitted no output. The precheck's unavailable-helper errors were:The test-quality helper's output was:
Findings
Blocking
aps5-summary.jsonllines formainand this change with distinct commit IDs, attached traces, ortools/trace_digest.pyoutput. It also reports tests on the change without the repository-required same focusedctest -Vrun onmainand this head usingVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1, andANYPS5_REQUIRE_VULKAN=1, with logs checked for the requested-layer warning and compared for newVUID-errors. Please add the matched performance captures and the paired AGC validation evidence, or state which prescribed runs remain unavailable so maintainers can assess the gap.Non-blocking
None identified from the source-level review. The test-registration heuristic warning is accounted for by the CMake glob shown in the source.
Sources
Not verified
No local build, CTest, Vulkan validation run, or GPU/game run was performed. Several hosted checks were not complete at the final snapshot; Linux and specialized jobs were skipped.
To get this to a good state
Attach matched
main/change summary lines, traces, and digest output, and provide the paired AGC validation logs on the same machine and GPU. I’ll re-run the same applicable checks against the updated head.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-31T15:08:41Z.
Review: COMMENTED
Linux run of head
9ea244c4c1, including a red for183b781e5f, the fix for oneandonlydean's shared record-count case.Setup: Ubuntu 26.04, GCC 15.2, Release. RTX 3070 with NVIDIA 595.99.02 and lavapipe (Mesa 26.0.3), one at a time via
VK_DRIVER_FILES. The head is merged--no-ffontomain809c7fa2dfwith no conflicts.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,ctest -j1.agc_driver_draw_relocate_user_valuespasses 3/3 on each device with VVL 1.4.341, with noVUID-lines. On the 3070 it also passes with VVL 1.3.275 and with no layer.allbuilds with no new warnings.183b781e5f: this head with only theDrawRelocate.cppline of that commit reverted, and the test kept. It fails 3/3 on each device witha record count that also builds a second descriptor was tagged (mask 80). So the new tagging check catches the case. The test as a whole doesn't build onmain, becausetagUserValueWordsis new.^agc(minus dcc/flip/lds_atomics64): 1133/1133 on the 3070 and on lavapipe.GPUs tested: NVIDIA GeForce RTX 3070, 595.99.02, Ubuntu 26.04; Mesa 26.0.3 lavapipe, Ubuntu 26.04
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.