perf(shader): decode compact resource plans directly and drop IR storage #28403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28403"
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 muhmuhkuh on 2026-11-30T13:12:00Z.
What
Avoid retaining duplicate
IrValueArenaandIrBlockgraph storage alongsideCompactResourcePlanonce a resource plan is compacted, and decode dense disk-cache resource plans directly intoCompactResourcePlanwithout allocatingIrValue/IrBlockobjects:IrResourcePlan::DropIrStorage()and drop IR storage after compaction whenAPS5_VERIFY_SRT_COMPACTis not enabled (preserving full IR-vs-compact verification whenAPS5_VERIFY_SRT_COMPACT=1is set).SrtEvaluator,SrtInstructionPredicates,SrtTapeCompiler,SrtDescriptorEvaluation,SrtWalker::EvaluateUniformValues, andShaderDiskCache::encodePlanto operate directly onCompactResourcePlan/CompactNodewhen IR storage has been dropped.ShaderDiskCache::decodePlandirectly intoCompactResourcePlanwhile keeping the serialized disk-cache format bit-identical and backward-compatible.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppandcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp.Tested
Windows 11 (10.0.26200):
ctest -R "^(agc_shader_memory$|agc_shader_disk_cache|agc_shader_bindless$|agc_shader_table_resolution_growth$|agc_shader_empty_table_resolution$|agc_shader_shared_table_resolution$|agc_shader_table_snapshot_reuse$)"):11/11passed.ctest -R "^(agc_driver_image_table|agc_driver_image_table_reuse)$" -V) on bothorigin/main(2af8e79edfe1) and this PR (fc671fc84e3d) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, andVK_LOADER_DEBUG=layer:2/2passed on both, confirmingVkLayer_khronos_validationloaded (layerload=2),0not-found warnings, and0VUID-validation errors.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T13:15:57Z.
Review: COMMENTED
Reviewed — comments
Changes are required before merge: fix the compact evaluator’s unchecked dense-cache indexing before this path can be considered safe.
What I ran
Reviewed head
fc671fc84e3dc4943a9bb2d00e9f05b0972e2f79using the prepared review bundle andrepo_read.pytargeted reads. No tests were run; the Windows and Vulkan test results in the PR description are author-reported.Results
Findings
Blocking
core/shader/recompiler/Optimization/src/SrtEvaluator.cpp:100:DenseValuesis sized toplan.compact.values.size()for compact plans, but this access usesinst.Id()directly. Compact plan IDs are vector positions, so a malformed or inconsistent decoded plan with an ID larger than the vector size can access out of bounds before the evaluator falls back to its identity-keyed cache. The decoder validates record IDs in the direct compact path but does not validaterecord.id == indexfor fallback IR decoding, whiledenseValueIdscan still be true. Validate compact IDs and make the dense lookup conditional oninst.Id() < _dense.Size(); otherwise use the fallback cache.Non-blocking
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the review folder because it is too large; only the changed descriptor-Phi region was read through the reader.To get this to a good state
Validate compact IDs before using them as dense-cache indices, with a safe fallback for out-of-range IDs; then rerun the relevant shader memory and disk-cache tests on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T13:25:34Z.
Review: COMMENTED
Actionable comments posted: 3
Architecture findings (1)
Advisory architecture findings (1)
410d57af-1c72-4606-b68b-58560c66a5b3Reviewing files that changed from the base of the PR and between
2af8e79edfandfc671fc84e.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/include/Optimization/SrtWalker.hppcore/shader/recompiler/Optimization/include/Optimization/SrtWalker/SrtEvaluator.hppcore/shader/recompiler/Optimization/include/Optimization/SrtWalker/SrtInstructionPredicates.hppcore/shader/recompiler/Optimization/include/Optimization/SrtWalker/SrtTape.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtWalker.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.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-30T14:51:53Z.
Review: COMMENTED
Reviewed — comments
Changes are required before merge: the changed
ShaderMemory.cppfile was not available to read, so the review is incomplete and does not justify approval.What I ran
Reviewed head
8f7f694d4d88f5a2d264da837b1964844972cc25usingrepo_read.py. No tests or build checks were run; the Windows results in the PR description are author-reported.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded as too large for the review folder and was not read through the reader. The remaining changed files were read in the relevant sections; the description, commits, manifest, and complete diff were read. No test or build results were independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T14:56:55Z.
Review: COMMENTED
Actionable comments posted: 1
94de8826-c11a-422e-ab88-393e11c2614fReviewing files that changed from the base of the PR and between
fc671fc84eand8f7f694d4d.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.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-30T17:59:34Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed code has no verified blocking defect; I did not independently run the reported tests or measure the performance change.
What I ran
Reviewed head
5df5f93b28690e43874e11ebc1ada56747b63461using the prepared diff and files, plus targeted reads throughrepo_read.py. No tests or builds were run.Results
Negative control
Not run; no tests were run during this review.
Findings
Blocking
None.
Non-blocking
No matched before-and-after performance captures or summary were supplied, so the claimed memory and decode improvements are not quantified in this review.
Sources
Not verified
The author-reported test runs were not reproduced. Full text for
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded because it exceeded the review-folder size limit; its changed hunks were read throughrepo_read.py. No changed files were excluded by the manifest rules.To get this to a good state
Nothing is required. Optional: provide matched before-and-after memory captures and a summary to quantify the performance change.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T03:22:22Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
3c97d6fba59ad4fe8fdc28e56520bb0ce39bc430. I ran no checks. The Windows test and Vulkan results below are author-reported.Results
Negative control
Not run.
Findings
Blocking
None.
Non-blocking
Sources
Not verified
No checks were run independently. The 15 changed files' added lines were reviewed;
ShaderMemory.cppwas too large for the review bundle, so I reviewed its changed hunks viarepo_read.py. The reported Windows and Vulkan results, hardware behavior, and performance claims were not independently confirmed.To get this to a good state
Nothing is required. Optional: provide matched baseline and change captures with summary records, traces, and digest output to support the performance claims.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:03:07Z.
Review: COMMENTED
The compact and expanded plan encoders now share the serialized tail. The round-trip fixtures derive their input bytes using the encoder in the same build, so a change to both the writer and reader can still pass. Could one compatibility fixture read an unchanged resource-plan file produced by the parent revision and compare its materialized outputs? A parent-built fixture with a phi, guarded SRT read and uniform-fill expressions would directly check the existing-cache claim.
Source review at
3c97d6fba5. The head trial-merges ontod2e04ef9b3. Paired Vulkan and disk-cache checks are queued.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T12:01:05Z.
Review: APPROVED
Reviewed — looks good
I reviewed the changed hunks at
cb0edbdf31daf4a68b1f7aaa5646e067ba3a897aand found no verified defect.What I ran
Reviewed the prepared diff and changed-line context at the pinned head. No tests or builds were run; the reported Windows results are author-supplied.
Results
Negative control
Not run; no tests were run.
Findings
Blocking
None.
Non-blocking
None.
Sources
Behavior reviewed in ShaderDiskCache.cpp, SrtEvaluator.cpp, and ResourceMaterializer.cpp.
Not verified
ShaderMemory.cppwas excluded from the review folder because of its size; its changed hunks were reviewed from the diff. The author-reported CPU and Vulkan results were not rerun.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T15:50:17Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at
f5042bdb8da447d03dcfea894c252b0934b97c95have no verified blocking defects; the compact paths retain guarded fallbacks for plans they cannot represent.What I ran
Reviewed the prepared diff and targeted source ranges using
repo_read.pyat the exact head above. No tests or builds were run; the Windows and Vulkan results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Behavior claims were checked against the pinned resource-plan decoder, compact plan construction and IR-storage release, and compact and IR evaluator adapters.
Not verified
Tests, builds, and console or hardware behavior were not independently verified. Reviewed changed hunks in all 15 files listed under
reviewedinfiles.json;ShaderMemory.cppwas read through targeted ranges because its full text was excluded from the review folder for size. No files were excluded by thefiles.jsonrules.To get this to a good state
Nothing is required.
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.