feat(shader): share split callee parts across callers that differ outside the callee's registers #28279
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28279"
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-29T17:59:59Z.
Requested by Chef · project thread
What
A split table call builds one program per callee. Until now each callee part replayed the caller's whole main program up to the waterfall loop. So two callers that call the same callee built two different parts, and every part of every caller was recompiled.
A callee part now holds only what the callee needs:
v_readfirstlaneand thev_cmpxthat narrows EXEC rebuilt on a saved copy of the picked VGPR;The entry part saves the pick register (
SavePick) and, when the callee writes the caller's waterfall marker, the marker (SaveMarker). Callee parts restore the pick withLoadPick. A callee that writes the marker gets a repeat part (Repeat): the driver runs it after the callee parts, and lanes whose marker is still set call again in the next round.SplitStateAbigains the two slots and two header words. A shared part without DS instructions ignores the caller's LDS size.The part's code and plan now depend only on the callee and on the caller's registers the callee reads. The recompiler's source cache keys on code and plan (
CacheKey.hpp), so identical parts of different callers compile once.A caller keeps per-callee parts, as before, when sharing does not fit, for example when:
vcc,m0or another special register.A shared part starts from the launch EXEC, so a caller that widens EXEC before its loop (
s_mov exec, -1with partial thread dimensions) would leave lanes unserved.This makes each build analyse every callee against its caller. #28280 caches that analysis.
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_rungains cases that run on the GPU, for wave32 and wave64:The existing thread-dimension and full-EXEC cases pass; the full-EXEC caller keeps per-callee parts.
ScalarCallchecks the shared layout,SavePick, and a callee that uses 49 VGPRs.Offline, on the 27 split callers that Gran Turismo 7 builds up to the Café (PPSA01317, mains and callees dumped from a run),
BuildSplitTableCallProgramswas linked againstmainand against this branch:mainBuild time is the median of 3 runs on a Ryzen 9 5950X, one thread.
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:11:54Z.
Review: COMMENTED
Actionable comments posted: 6
496c5ecc-8a64-4a35-adb8-a4bcfd6d72ccReviewing files that changed from the base of the PR and between
6f6f6c8e6band20b6e0f0b9.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; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T18:18:28Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: fix the repeat marker state so repeat rounds use the saved lane marker value.
What I ran
Reviewed head
20b6e0f0b91a7988c353f45c27d49e2b1dd6a55dusingrepo_read.py-backed file reads. No commands or tests were run.Results
Findings
Blocking
core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp:2880computesmarkerSlotas the lane-state slot containing the saved marker VGPR. Butcore/shader/recompiler/Translation/src/ControlFlowInstructions.cpp:574stores that slot index in the fixedMarkerSlot()(slot 3), and the repeat action atcore/shader/recompiler/Translation/src/ControlFlowInstructions.cpp:578-580loads the index and treats it as the marker value. Consequently, a nonzero marker VGPR slot index makes the repeat check true regardless of the lane’s marker contents; slot index zero makes it false regardless of contents. The repeated-callee path therefore cannot correctly decide whether each lane should call again. Keep the marker slot address separate from a per-lane saved marker value, and haveRepeatload and test that value.Non-blocking
None.
Not verified
No tests were run. The GPU tests, Windows build, and game measurements described in
description.mdare author-reported. The changed files wereShaderRegistry.hpp,Dispatch.cpp,ShaderRegistry.cpp,SplitTableCallRun.cpp,ScalarCall.cpp,GraphBuilder.hpp,GraphBuilder.cpp,SplitStateAbi.hpp, andControlFlowInstructions.cpp; all were listed as included in the manifest and the relevant source ranges were read. No excluded changed files were listed in the manifest.To get this to a good state
Correct the marker state handling, then rerun the repeat-path GPU tests for wave32 and wave64, including CPU and GPU-selected rounds.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:58:54Z.
Review: COMMENTED
Reviewed — comments
The review covers the change at head
658754ed6f08db5cc17877f1b28924d530892e4e; one changed file was unavailable in the review folder, so a formal decision is not justified.What I ran
Read the supplied diff and targeted code at the pinned head. No commands or tests were run.
Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded because it was too large for the review folder. Its changed serialization assertions were visible in the diff, but its full head text was not read. Tests and GPU behavior were not independently verified; the Windows, MinGW, AMD GPU and game results in the description are author-reported.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T11:17:55Z.
Review: COMMENTED
Actionable comments posted: 2
Architecture findings (1)
Advisory architecture findings (1)
5af9c20a-634a-47c4-a972-7d9810412976Reviewing files that changed from the base of the PR and between
20b6e0f0b9and658754ed6f.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; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:46:23Z.
Review: COMMENTED
The repository's request-serializer fixture passed on Linux from main at
b21303b0bdand from this revision. The branch fixture checks that a version-64 split-state record is upgraded with the new header fields and that a current record still round-trips. The split-callee execution path still needs its Vulkan run.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.