feat(shader): read table-call callee addresses at run time for boot-stable linking #24906
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24906"
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 tablefrogpillow on 2026-11-21T10:16:34Z.
What
Boot-stable table-call linking, so the driver shader cache can hit across boots.
Authored by @Dark3581 (two commits, root-cause analysis in #24525); I rebased onto current
main, reconciled the serializer, and verified it on AMD hardware.Today
LinkCallsbakes the absolute callee address into the linked code as thes_cmp_lg_u32literal (GraphBuilder.cpp). The callee shaders move between boots, so the linked code, the SPIR-V and the pipeline differ every boot and the driver cache can never hit; large Unreal compute modules (1.2–2.6 M words) then rebuild cold on every launch.This change:
LinkCallswrites a0placeholder for each callee-address literal and records its provenance inGuestContext::linkedTableLiterals(table-entry offset + descriptor source: user-data descriptor, user-data/constant pointer, nested descriptor).CompareInstructions.cpp), and callees are ordered by table entry rather than by address.The linked module, SPIR-V and pipeline are then identical across boots, so the cross-process driver cache hits (measured elsewhere: 105 s cold → 217 ms warm once the module is identical).
Scope / honesty: this is the determinism half only. It is necessary but not sufficient to close #24525: even with a boot-stable module, the first encounter still compiles the 1.2–2.6 M-word module cold (105–1632 s), past Unreal's 120 s render-thread watchdog. Keeping the title under the watchdog on a cold cache (startup journal-replay warm path) is a separate follow-up. Not yet verified in game.
Serializer version: adds format version 64, written only when
linkedTableLiteralsis non-empty. This overlaps with #15343, which also uses version 64 — whichever lands second should take version 65. Flagged so they do not collide.Tested
Linux, AMD Vega 56 (RADV VEGA10, GCN5), Mesa 26.2.6. 12 related tests pass; the compute table-call GPU tests ran with
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, the loader confirmed inserting the validation layer, and none logged aVUID-error:request_serializer,scalar_call(determinism:LinkCallsof two different callee-address sets produces byte-identical code,tableLiteralsandfallbacks)agc_driver_compute_table_calls,agc_driver_compute_nested_table_call,agc_driver_compute_fs_table_calls(GPU, 0 validation errors)agc_shader_replay_requests,agc_driver_split_table_call_run,agc_split_table_call,agc_split_table_call_full,agc_split_table_call_none,agc_driver_scalar_swappc,agc_driver_scalar_swappc_fetchNot verified in game (see scope note). The two-boot module hash on a real RADV module is covered at unit level by
scalar_call; an end-to-end in-game two-boot hash still wants the title.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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T10:34:00Z.
Review: COMMENTED
Reviewed — no blocking findings
The review is incomplete, so a formal approval is not justified; no blocking defect was verified in the portions read.
What I ran
c4249c5d25b006dcdbd15070cbe4dd69b827c1aeand read relevant source ranges throughrepo_read.py.Results
Findings
Blocking
None verified in the portions read.
Non-blocking
Not verified
core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp,core/shader/recompiler/ControlFlow/include/ControlFlow/GraphBuilder.hpp,core/shader/recompiler/Translation/src/CompareInstructions.cpp,core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp,core/shader/recompiler/Recompiler.cpp, andcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp.manifest.jsonwere not read:core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp,core/libs/tests/ScalarCall.cpp,core/shader/recompiler/CacheKey.hpp,core/shader/recompiler/ControlFlow/include/ControlFlow/RequestSerializer.hpp,core/shader/recompiler/Recompiler.hpp,core/shader/recompiler/Translation/include/Translation/InstructionTranslator.hpp,core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp,core/shader/recompiler/Translation/src/InstructionTranslator.cpp, andcore/shader/recompiler/tests/RequestSerializerTests.cpp.To get this to a good state
Nothing is required. Optional: finish reviewing the unread changed files and confirm serializer version coordination with #15343 before merge.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T11:36:38Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the source reviewed; the excluded test file and unrun checks leave the review incomplete, so this is a comment rather than an approval.
What I ran
82160181325fee239c61472330c0e1dd2d39d640usingrepo_read.py.Results
ShaderMemory.cppwas excluded from the review bundleFindings
Blocking
None identified in the code read.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded because it was too large for the review folder; its changed line was not read.ShaderRegistry.hpp,ShaderRegistry.cpp,ScalarCall.cpp,CacheKey.hpp,GraphBuilder.hpp,RequestSerializer.hpp,GraphBuilder.cpp,RequestSerializer.cpp,Recompiler.cpp,Recompiler.hpp,InstructionTranslator.hpp,TranslationContext.hpp,CompareInstructions.cpp,InstructionTranslator.cpp, andRequestSerializerTests.cpp. Also read the review description, commits, manifest, diff, and README.ShaderMemory.cppwas the only changed file excluded by the bundle.To get this to a good state
Nothing is required. Optional follow-up: independently run the stated checks and inspect the excluded
ShaderMemory.cppchange before making a formal approval decision.Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-22T12:58:50Z.
Review: APPROVED
Windows check of head
8216018132with GCC 16 on an NVIDIA and an AMD GPU, merged ontomaine493612311(clean merge).Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release full build, run from PowerShell; GPU tests withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. GPUs, each picked withANYPS5_GPU: NVIDIA GeForce RTX 5070 Ti (621.01) and the Ryzen 7 7700X's integrated AMD Radeon (1002:164e, Adrenalin 26.10.2). This was built together with #19100, which touches other files.request_serializerandscalar_call: 2 of 2 onmainand with this PR, in 3 of 3 runs.agc_shader_memoryandagc_shader_memory_coherent_atomic_loads, whose fixture this PR bumps (agc_driver_compute_table_calls,_nested_table_call,_fs_table_calls,agc_driver_split_table_call_run,agc_split_table_call,_full,_none,agc_driver_scalar_swappc,_fetch,agc_shader_replay_requests): every one passes on both GPUs, onmainand with this PR, in 3 of 3 runs. NoVUID-lines.LinkCallsbaking the callee address again (const bool fromTable = false;),scalar_callfails, so its two-boot determinism check does catch an address-dependent link.I read the
ShaderMemory.cppchange the earlier review couldn't open: it's the one-line move of the unsupported-version example past 64 (8216018132).The version-64 overlap with #23818 that Haembina raised still stands. Both are open, and each merges cleanly on its own, so whichever lands second needs 65.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-23T14:30:24Z.
Review: APPROVED
Reviewed exact head
82160181325fee239c61472330c0e1dd2d39d640and all 16 changed-file patches.The linked-table path now records the table entry provenance beside zero placeholders instead of baking absolute callee addresses into the linked code. Translation replaces only those annotated SOPC literal operands with runtime reads from the original descriptor/pointer/table entry; legacy/non-table callees keep their address literals. The provenance is owned, serialized, restored, and included in the recompile cache key, while split-table parts clear it. The scalar-call regression verifies that moving callees between boots leaves linked code and provenance identical, and a red control that bakes addresses again breaks that determinism check.
The exact head has terminal green hosted checks and independent Windows/Linux GPU coverage on NVIDIA and AMD with no validation errors. Superseabas also exercised the current head with a red
fromTable=falsecontrol and approved it.One integration constraint is intentionally still conditional: #23818 is also open and independently uses request format 64. Whichever PR lands second must rebase and assign its new layout version 65 (with fixtures updated); neither branch should pre-emptively bump while both are open.
No blocking finding on this exact head.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-25T12:35:34Z.
Review: COMMENTED
The hold reproduces on Windows on both vendors. My approval of
8216018132on 11-22 predates these tests, so it doesn't cover currentmain.Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release full build, run from PowerShell withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. GPUs: NVIDIA GeForce RTX 5070 Ti (621.01) and the Ryzen 7 7700X's integrated AMD Radeon (1002:164e, Adrenalin 26.10.2).mainc3aae2e8fb, and this head merged onto it (clean merge, built together with #24781 and #21948, which touch other files).agc_driver_split_table_call_driver,_cpu_roundsand_gpu_rounds, each run alone 3 times: 3 of 3 onmain, and 0 of 3 with this PR, on both GPUs.request_serializer,scalar_call, the table-call and split-table-call tests,agc_shader_memory*) passes: 11 of 14 with this PR in 2 of 2 runs, only those three failing.The assertion: the "host imports at shutdown" line is only the end-of-run statistics. The failure before it is
and
_gpu_roundsthen misses itsa batch of N rounds ran ...line.Where the tests come from:
efe46a01dfadded them, merged with #25848 (GPU-selected split table call rounds) on 11-24. So they're new onmainsince this PR's last runs, not something this PR changed.A guess, not traced: the invocation is missing exactly the callee's part of the result. This PR links a table callee through a run-time literal (
tableLiterals, filled per request inShaderRegistry.cpp). A continued split part run through the driver's rounds may not get those literals, so itss_cmpagainst the callee address never matches.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-30T10:28:19Z.
Review: CHANGES_REQUESTED
Request changes on head
82160181325fee239c61472330c0e1dd2d39d640.Current main already serializes
splitStateat version 64. This branch also assigns version 64 tolinkedTableLiteralsand does not carry main'ssplitStatefield/encoding, so it conflicts inRequestSerializer.hppandRequestSerializer.cppand cannot be merged without losing serialization compatibility.For the agreed dependency order
#24906->#23818, please rebase onto current main, preservesplitStateat version 64, and movelinkedTableLiteralsto version 65. Then #23818 must be rebased on top and moveverticesPerPrimitiveto version 66. Update the compatibility fixtures and run the serializer round-trip/backward-compatibility tests on the stacked result before requesting re-review.Pull request closed