perf(agc): key shader pipeline libraries only by the state their subset reads #23229
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23229"
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 chitters2004 on 2026-11-18T20:36:50Z.
What
Shader pipeline libraries were keyed on more state than they read, so the same shaders were compiled again whenever a draw changed something that only the output or vertex-input part uses.
viewMaskfrom the rendering info. They now passVK_FORMAT_UNDEFINEDdepth and stencil formats and key without them. The fragment library takes a null multisample state unless the pipeline enables sample shading, or a fragment shader readsSampleId,SamplePositionor aSample-decorated input.VK_EXT_extended_dynamic_state2, the depth bias enable is a dynamic state set at bind and leaves the pre-rasterization key. The bias values were already dynamic, and they are zero when bias is off.APS5_WIDE_LIBRARY_KEYS=1restores the old keys andAPS5_NO_DYNAMIC_DEPTH_BIAS_ENABLE=1keeps the enable baked, so both can be compared within one build. The pipeline store key carries the mode, and both switches are in docs/dev/ENVIRONMENT.md.Tested
All runs: RTX 3080, NVIDIA 621.24, Windows 11 (10.0.26320), Ryzen 7 5800X, 3840x2160.
GTA V (PPSA04263 01.011.001), warm boots, main vs this PR (nkp). One CLEAN boot per arm on the same machine, city scene (Franklin's house save), with caches warmed by one untimed boot per build. Only
APS5_TRACE_SECONDS=92:30was set for the window (from the moment the player stands still + 20 s, 30 s long); the other variables in the lines are the harness's (trace paths, pad input, address copy limit). Both arms run with the draw pipeline on (APS5_DRAW_PIPELINE=1,APS5_PIPELINED_DRAWS=32,APS5_PIPELINE_DISPATCH=1), which is how we measure GTA; main ships it off and this PR doesn't touch it. The commits in the lines are lab merges:da3b9f12dd29is main806e2140a9plus #20845 and #14561, which GTA needs to reach gameplay, anda813ef9699a9is that plus exactly this PR's diff (same patch-id). Defender real-time protection was on.No regression: the difference is within this scene's boot-to-boot spread. In an earlier set on the same scene and mode, two CLEAN boots of one main build measured 112.5 and 119.7 ms p50. The change only affects how pipeline libraries are keyed, so a warm steady state is not expected to move; time in
Vulkan.GraphicsPipelineLibraryin the window was 1,109 ms on main and 1,001 ms with this PR, from one boot each.aps5-summary.jsonlwindow lines, main then this PRCold replay of GTA's city frames (rp7).
agc_frame_replayreplays a 3-frame 4K capture of the same city scene with an empty shader cache (ANYPS5_NO_SHADER_CACHE=1,--cold-pipelines,__GL_SHADER_DISK_CACHE=0) and the registration prebuild off (APS5_NO_LIBRARY_PREBUILD=1), so every counted part is one the frames' draws needed and the counts repeat exactly. Order: main, this PR, this PR, main, then this PR withAPS5_WIDE_LIBRARY_KEYS=1. Both builds carry #20845 and #14561, without which this capture replays a wrong picture; every run matches the capture's own frames (pixels_identical1.000).APS5_WIDE_LIBRARY_KEYS=1Compile times are not offered: main's two runs differ by 1.3 s.
Whole GTA boots with a cold cache (three main/PR pairs, dg4 to dg6) varied by about ±30 compiles from boot to boot, more than the effect, so they are not offered as a measurement; neither are the earlier whole-boot switch A/Bs (nk3, nk4).
GPU tests. RTX 3080, NVIDIA 621.24, Windows 11, the AGENTS.md protocol:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, validation layer SDK 1.4.335.0. Every log showsInsert instance layer "VK_LAYER_KHRONOS_validation"and nowas not found but was requested.ctest -R 'library_keys_narrow|color_write_mask_dynamic|agc_driver_graphics$' -V:806e2140a9: 4/4 passed, noVUID-lines;VUID-lines;agc_driver_library_keys_narrowand its_whole_pipelinesand_static_depth_bias_enablevariants;push constant assembly: N x ...lines inagc_driver_graphicsare that test's own diagnostics and appear on main too.Negative controls: one-edit mutants of d9b5bf76a5,
ctest -R library_keys_narrowunder the same protocol.library_keys_narrow_static_depth_bias_enable_whole_pipelinesVUID-vkCmdDraw-None-04877_whole_pipelinespasses in every mutant, as it should, because it runs without libraries.CI on d9b5bf76a5 (our fork): green. Linux lavapipe ran the selected tests 10/10 with the validation layer inserted and no
VUID-lines, and main 6/6. Windows (MinGW, lavapipe) ran 10/10 with noVUID-lines.Checklist
main(806e2140a9; merges cleanly onto today's main); no other open PR implements the same functions. #22058 also adds a field to the pre-rasterization key; the two merge cleanly apart from adjacent new tests intests/Graphics.cppNotImplemented_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-18T21:23:00Z.
Review: COMMENTED
Reviewed — comments
The inspected implementation is consistent with the stated pipeline-key changes, but two changed files were excluded from the review folder and no checks were run in this review.
What I ran
Reviewed head
2857a546d20eaec058a63fa910485f88c83641b3. No commands or tests were run. Read the prepared description, commit list, manifest and diff, plus targeted ranges ofVulkanDevice.cpp,Pipeline.cpp, andGraphics.cppat the pinned head.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
The full changed text for
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppandcore/libs/prx/libSceAgcDriver/tests/Graphics.cppwas excluded because each was too large for the review folder. Targeted ranges of both were read throughrepo_read.py, but their remaining contents were not reviewed. Other changed files whose full text was included inreview/files/were not individually read; the diff was reviewed instead. No tests were run here; test results in the PR description are author-reported.To get this to a good state
Nothing is required. The excluded file contents and checks remain unverified.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T01:55:28Z.
Review: COMMENTED
Reviewed — no blocking findings
The change narrows shader-library keys and adds dynamic depth-bias enable; I found no verified blocking defect in the code read.
What I ran
Reviewed head
9169633a54af9c410de3f01a2add9e4fbe6bca2d. No commands or tests were run; I reviewed the prepared diff and targeted source ranges throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
VulkanDevice.cppandtests/Graphics.cppwas excluded from the review bundle; only targeted ranges ofVulkanDevice.cppand changed hunks oftests/Graphics.cppwere inspected. The changedtests/Recorder.cppwas also excluded and not read. Other included changed files were not individually read. Runtime behavior, test results, CI, performance measurements, and remaining changed-file contents were not independently verified. The prepared manifest lists 18 changed files: 15 included and 3 excluded as too large for the review folder. I read the description, commits, manifest, diff, targeted ranges inPipeline.cpp,PipelineLibrary.cpp,Recorder.cpp,RuntimeSwitches.cpp,Context.hpp, andPipeline.hpp, plus the changed hunks inVulkanDevice.cpp,Graphics.cpp, and the CMake and documentation changes.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T21:12:14Z.
Review: COMMENTED
Reviewed — comments
The change’s library-key and dynamic depth-bias paths look consistent in the inspected code; I did not run the reported checks or read every reviewed file, so a formal approval is not justified.
What I ran
Reviewed head
2393392a4d643fff2d8a4916e1d609eeb82479a3using the prepared diff andrepo_read.py; no tests or build commands were run. The author reports GPU and CI results in the PR description; these were not independently verified.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Not verified
The review folder’s
files.jsonwas not available through the reader. Changed files reported by the folder listing but not read:core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp,core/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hpp,core/libs/prx/libSceAgcDriver/Graphics/include/PipelineLibrary.hpp,core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp,core/libs/prx/libSceAgcDriver/Graphics/include/RuntimeSwitches.hpp,core/libs/prx/libSceAgcDriver/Graphics/src/Resources.cpp,core/libs/prx/libSceAgcDriver/Graphics/src/RuntimeSwitches.cpp,core/libs/prx/libSceAgcDriver/tests/CommandStateLog.hpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp,core/libs/prx/libSceAgcDriver/tests/Recorder.cpp,core/libs/prx/libSceAgcDriver/tests/RuntimeSwitches.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_tests.cmake,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_library_keys_narrow_tests.cmake,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/DepthFastClearHarness.hpp,core/libs/prx/libSceAgcDriver/tests/execution/LibraryKeysNarrow.cpp, anddocs/dev/ENVIRONMENT.md.VulkanDevice.cppwas read only around the feature query and device feature chain;Pipeline.cpponly around key generation, pipeline cache keying, and dynamic state;PipelineLibrary.cpponly around library construction;Recorder.cpponly around depth bias enable tracking. No other behavior or platform results were verified.To get this to a good state
Nothing is required. The test, GPU, and performance observations in the description are optional context and remain author reported.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T21:35:29Z.
Review: COMMENTED
Reviewed — comments
The review is incomplete because three changed files were excluded from the review folder and their added lines were not inspected.
What I ran
741dccedee6c13bf108cfc2ac705aead4c1ab40ausingrepo_read.pyreader tools; no tests were run.description.md,commits.md,manifest.json,README.md, and the available changed-file text listed below. The ruling file was not read, as instructed.Results
Findings
Blocking
None verified in the code inspected.
Non-blocking
None.
Not verified
The added lines in
core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, andcore/libs/prx/libSceAgcDriver/tests/Recorder.cppwere not read; the review reader reported these full texts as excluded from the review folder. No tests were run. The author reports GPU tests and negative controls indescription.md; these were not run by this review.Files read:
core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp,Pipeline.hpp,PipelineLibrary.hpp,Recorder.hpp,RuntimeSwitches.hpp;core/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cpp,PipelineLibrary.cpp,Recorder.cpp,Resources.cpp,RuntimeSwitches.cpp;core/libs/prx/libSceAgcDriver/tests/CommandStateLog.hpp,RuntimeSwitches.cpp,cmake/agc_driver_graphics_tests.cmake,cmake/agc_driver_library_keys_narrow_tests.cmake,cmake/agc_driver_recorder_tests.cmake,execution/DepthFastClearHarness.hpp,execution/LibraryKeysNarrow.cpp; anddocs/dev/ENVIRONMENT.mdwas not read. The first five headers andPipelineLibrary.cpp,RuntimeSwitches.cpp, andLibraryKeysNarrow.cppwere read in full; other included files were inspected only in relevant ranges. Excluded changed files: the three listed above.To get this to a good state
Nothing is required to address a verified defect. The review remains incomplete until the excluded changed lines are inspected; optional feedback: none.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T23:15:06Z.
Review: APPROVED
Reviewed — looks good
The change narrows shader-library keys and adds dynamic depth-bias handling; the inspected code and supplied validation evidence show no verified blocking defect.
What I ran
306e4008b12f646c083f15072eefa7e559baa660usingrepo_read.pyto inspect the prepared diff and targeted source ranges.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Pipeline.cpp,PipelineLibrary.cpp,Recorder.cpp,Resources.cpp,RuntimeSwitches.cpp,VulkanDevice.cpp, and the newLibraryKeysNarrow.cpptest. I also read the changed portions of the prepared tests and documentation.VulkanDevice.cppandtests/Graphics.cppwas excluded by the review folder size limit; I inspected the relevant changed source ranges throughrepo_read.py. The remaining changed files listed inmanifest.jsonwere not read in full.To get this to a good state
Nothing is required.