perf(shader): cache the split callee analysis across rebuilds of a call table #28280
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28280"
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 Remi-Bon on 2026-11-29T18:00:02Z.
Requested by Chef · project thread
What
Depends on #28279, which shares split callee parts between callers; this PR holds only the last commit.
With shared callee parts,
BuildSplitTableCallProgramsanalyses every callee against its caller (sharedSplitCallee) and computes the callee's scalar liveness. A call table grows while a title runs, and each growth rebuilds the caller's split programs, so the same analysis runs again for every callee it already had.Two caches, each bounded to 16,384 entries and cleared when full:
sharedSplitCallee, keyed by the caller's code hash and size, the callee's target, code hash and size, the split's loop, call and exit program counters, and the call's program counter, target and link registers. These are the only inputs it reads;The hash is the FNV-1a over the words that
ShaderRegistryalready uses for its split keys.Tested
Windows 11, MinGW Release build, AMD Radeon RX 9070.
ctest -R "split|table_call|scalar_call|request_serializer|linked_call|swappc|user_data_call|control_flow|graph" -V: 102/102 passed, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer. The loader log shows the validation layer inserted and contains noVUID-.agc_driver_split_table_call_runbuilds the same caller with several callee sets, so it runs the cache hits and checks their results on the GPU.Offline, on the 27 split callers that Gran Turismo 7 builds up to the Café (PPSA01317, mains and callees dumped from a run), with
BuildSplitTableCallProgramslinked against each build. Ryzen 9 5950X, one thread:mainThe built programs are the same with and without the caches: 13,689 callee parts, 507 distinct, 16,835,688 words.
In game, Gran Turismo 7 (PPSA01317), cold shader cache, to the Café.
mainalone stops before the menu ("layered rendering with a depth target is unsupported"), so the measurement base wasmain+ #24083 (layered depth targets) + #16935 (unnormalized samples on multi-level views). These two open PRs are measurement conditions, not dependencies of this PR. Two runs each of the base, the base + #28279, and the base + #28279 + #28280: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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T18:10:40Z.
Review: COMMENTED
Actionable comments posted: 3
6db6d0e8-3684-4363-a2e2-421ba687d167Reviewing files that changed from the base of the PR and between
6f6f6c8e6band06df51cc07.core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/tests/execution/SplitTableCallRun.cppcore/libs/tests/ScalarCall.cppcore/shader/recompiler/ControlFlow/include/ControlFlow/GraphBuilder.hppcore/shader/recompiler/ControlFlow/src/GraphBuilder.cppcore/shader/recompiler/SplitStateAbi.hppcore/shader/recompiler/Translation/src/ControlFlowInstructions.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T18:17:03Z.
Review: COMMENTED
Reviewed — no blocking findings
The change at head
06df51cc07a9a794d4e26f20be775e6dc665146cadds cached split-callee analysis and repeat-part handling; the inspected code showed no verified blocking defect, but the review is incomplete.What I ran
No commands or tests were run. I read the prepared description, commit list, manifest, diff, and
GraphBuilder.cpplines 2730–2880 through the pinned reader.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
I did not read every changed file or inspect all changed hunks. The manifest lists nine changed files, all marked included; I read only
GraphBuilder.cppwithin the repository. I did not verify cache correctness across hash collisions, repeat-part dispatch behavior, or the report's build, test, and performance claims. The excluded-file list was not available through the provided reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T11:01:49Z.
Review: COMMENTED
Reviewed — comments
The review covered the change at
478bfae598f134db9446b77b6cc19a5d18a7c000; the split-call logic and serialization compatibility changes were inspected, but no checks were run, so a formal approval is not justified.What I ran
No commands or tests were run. I read the prepared description, commits, manifest, diff, and targeted repository source through the pinned reader.
Results
ShaderMemory.cppwas read only around its changed linesNegative control
Not run; this review session did not run tests.
Findings
Blocking
None verified in the inspected code.
Non-blocking
None.
Sources
Reviewed the prepared diff and pinned-head code for split-call dispatch, split-state ABI and translation, graph building, shader registry, request serialization, and changed tests. The changed lines in
ShaderMemory.cppupdate serialization-version expectations; the surrounding test code was also inspected.Not verified
No build, test suite, GPU execution, or performance measurement was run. The full
ShaderMemory.cppfile was not read. The author-reported test and performance results were not independently confirmed.To get this to a good state
Nothing is required. Optional: run the reported test suite and verify GPU behavior on the stated hardware before treating this review as complete.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T11:15:44Z.
Review: COMMENTED
Architecture findings (2)
Advisory architecture findings (2)
5f81f49a-d219-48f8-bf2c-e6d49e0786e0Reviewing files that changed from the base of the PR and between
06df51cc07and478bfae598.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/SplitTableCallRun.cppcore/shader/recompiler/ControlFlow/include/ControlFlow/GraphBuilder.hppcore/shader/recompiler/ControlFlow/src/GraphBuilder.cppcore/shader/recompiler/ControlFlow/src/RequestSerializer.cppcore/shader/recompiler/tests/RequestSerializerTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:42:33Z.
Review: COMMENTED
The current head includes
split.waveSizein both cache keys, which covers the wave-dependent liveness and kill rules I checked. The existing growth test exercises repeated analysis at one wave size. Could it also build the same caller and callee bytes for wave32 and wave64 in one process, using a fixture whose scalar liveness differs? Checking both orders would directly exercise the equality boundary added by the final commit.The performance measurements shown use an offline benchmark and a title baseline with prerequisite PRs. Please include the same-scene
tools/trace_digest.pysummaries for the performance comparison and identify the measured heads alongside them.Source review at
478bfae598. Paired Vulkan execution is pending.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.