perf(shader): compile reusable SRT expression plans #1341
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1341"
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 TibixDev on 2026-10-07T23:55:29Z.
What
Compile supported immutable SRT expressions into indexed operations, so each draw evaluates current user data and guest memory without rebuilding an IR walk. Preserve descriptor values, flattened slots, active sources, read order and dependency traces.
Rebased on main
d146ec1b6. Null user-data roots now return zero words and preservenullRootReads, without guest reads or dependency records. Scalar-buffer reads outside the descriptor bounds return zero, matching current main. Successful compiled evaluations clear stale poison output. Plans with guarded slots or memory-derived handles use the generic evaluator, preserving inaccessible-read poison and descriptor-zeroing behavior. Conditional flow, specialization memory, cycles and unsupported operations also use the generic evaluator.APS5_VERIFY_COMPILED_SRT=1compares null-root and poison outputs in addition to values and traces, and forwards accessibility probes with their original callback context.APS5_NO_COMPILED_SRT=1disables compiled evaluation for comparisons.Supersedes the SRT evaluation portion of #1193; its other shader-memory changes remain separate. Depends on: none.
Tested
Fedora 44, GCC 16.2.1, Release:
agc_srt_execution_tests,agc_shader_memory_tests,agc_driver_tests,agc_driver_graphics_testsandagc_driver_pm4_tests.agc_srt_executionpasses normally, with compiled-result verification, and with compiled evaluation disabled. CTest registers it through the existing test loop with a 30-second timeout.PrepareShader, instantiated throughPreparedShaderInvocation, and captured through that invocation. Its direct root read selects a compiled plan; its null-root capture reports one null read and touches no guest memory. The existing guarded translated-shader test requires generic fallback.APS5_VERIFY_COMPILED_SRT=1(RX 6600 RADV for Vulkan tests).git diff --checkpass.Fresh measurements on this base, identical Release binary and flags, warm-up excluded:
Prepared-capture checksums match across all four ABBA runs. Reproduce with
agc_srt_execution_tests --prepared-benchmark, alternatingAPS5_NO_COMPILED_SRT=1and the default;--benchmarkruns the paired evaluator fixtures.These are synthetic evaluator/capture measurements, not title FPS. They replace the stale measurements against #1193 in the previous description. A fresh title-derived capture, title-level performance and Windows runtime validation remain outstanding; guarded nested-read plans receive no compiled-path speedup.
Checklist
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:13:31Z.
Rebased on
bc1fbe81. Kept the upstream buffer-device-address tests alongside compiled SRT coverage.Fedora 44 Release:
agc_srt_execution_tests,agc_shader_memory_tests,agc_driver_tests,agc_driver_graphics_tests,agc_driver_pm4_testsbuild; the targeted tests and contribution checks pass. Windows CI is pending.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:20:22Z.
Review: CHANGES_REQUESTED
Thanks for the work. This conflicts with
mainand the conflict is not only mechanical:core/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cpp:51(main):EvaluateRuntimeSourcesImplnow takesstd::vector<SrtReadPoison>* poisonandstd::uint32_t* nullRootReads(#2989, reads through a null user-data pointer return zero words).SrtExecutionPlan::Evaluateproduces neither, so the compiled path would diverge from the generic one on those cases.ResourceMaterializer.cpp(main) now computesplan.guardedSrtSlotsnext to where this PR setsplan.executionPlan; the compiled plan has to respect guarded slots too, or fall back when any is set.core/libs/prx/libSceAgcDriver/CMakeLists.txt: adjacency withagc_shared_write_testsand the testforeachlist; just a rebase.What would fix it: rebase on current
main, port the plan to the new signature (poison, null-root reads, guarded slots) or makeCompileSrtExecutionPlanreturn null when they apply, extendtests/SrtExecution.cppwith a null-root and a poisoned-read row compared against the generic evaluator, and re-run the paired benchmark on top ofmain(capture now runs against the prepared invocation since #639, so the 18 sources / 72 reads graph may have changed). Also registeragc_srt_execution_testsvia the same loop as the other tests, as it is now, but check it still lands in ctest after the rebase.Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T03:35:43Z.
@adriadam10 Updated to
5380bb932, rebased on maind146ec1b6.PreparedShaderInvocation. Verification compares poison/null-root outputs too. Confirmedagc_srt_executionis registered through the existing CTest loop with a 30-second timeout.Fedora 44 Release: SRT tests pass normally, with verification, and with compiled evaluation disabled. Shader-memory, driver, graphics, PM4, frontend-pair and read-patching checks pass with compiled-result verification; contribution checks pass.
Replaced the stale benchmark in the description with fresh paired synthetic measurements. Prepared-invocation capture (0 descriptor sources / 1 read) measured 0.214–0.220 µs generic versus 0.0949–0.0952 µs compiled across ABBA runs with matching checksums. The 8-source/72-read evaluator fixtures and reproduction commands are also in the description.
Ready for another correctness review. A fresh title-derived capture, title-level performance and Windows runtime validation remain outstanding; these synthetic timings do not establish an FPS improvement.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:46:52Z.
Review: CHANGES_REQUESTED
Thanks for the update. On current
main(8299b2f7e) the PR conflicts incore/libs/prx/libSceAgcDriver/CMakeLists.txt(theforeachtest list and the timeout block; keep both), and after resolving itagc_srt_executionfails:core/libs/prx/libSceAgcDriver/tests/SrtExecution.cpp(prepared()): the target'scapabilitieslacksspv::CapabilityClipDistance, soPrepareShaderfails with "clipping a primitive with an all-zero clip position needs shaderClipDistance on the target device" (the targets inShaderMemory.cppalready declare it). Addspv::CapabilityClipDistanceto the array.Please rebase and rerun
agc_srt_execution,agc_shader_memoryand the driver tests. Nothing else found in the diff.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:05:29Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CMakeLists.txtcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CMakeLists.txtcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T23:44:50Z.
adriadam10's review of 10-13 is still open on this head:
libSceAgcDriver/CMakeLists.txtconflicts with main (keep both theforeachtest list and the timeout block), and after thatagc_srt_executionfails. Could you rebase and look at that failure? #6095 overlaps the compiled evaluation, so please also say which of the two this should build on.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T18:01:40Z.
Closing this as superseded by #6095 (merged 18 Oct, "compile resource plan walks instead of interpreting them").
mainnow compiles the SRT plan walk once (SrtTape) and runs it per capture, which is the same optimisation. A rebase would be a rewrite of SrtDescriptorEvaluation.cpp against that code, and adriadam10's 13 Oct review is still open on this head.Thanks @TibixDev for this. If you measure a case where the compiled plans here beat #6095, please open a new PR against current
mainwith the numbers.Pull request closed