fix(shader): rebuild descriptor dwords deeper than the phi search bound #21745
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21745"
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 edubox on 2026-11-16T18:14:56Z.
What
ResourceTrackerrebuilds a descriptor dword from user data, the SRT and uniform operations when a descriptor web splits the read per edge or per arm. That rebuild shared the 8-level bound of the phi search that looks for the Phis among the descriptor's dwords. A dword assembled by an inlined helper is longer than that search: The Last of Us Part I's S# dword 1 is av_readfirstlaneof a clamp over an SRT dword whose chain is nine operations deep, so the edge substitution returned null,SplitDescriptorEdgesgave up, and the web folded that path onto the first descriptor. A lane that selects the folded arm records anInvalidDescriptorBDA fault and the dword's value is lost.The rebuild budget is now its own constant of 16 operations; the phi, lane and offset searches keep 8.
ShaderDiskCache::FormatVersionstays at main's 99: the disk cache is also keyed on the compiler source version, so a module this change plans differently already misses the old entries and the serialized layout does not change.Evidence:
agc_shader_replay --prepareon the requests captured from PPSA07642 withAPS5_DUMP_SHADERS=1. Ten pixel shaders stopped atGetSamplerResource dword 1 is not a valid runtime valuewithdescriptor web: a per-lane descriptor selection mixes dwords selected differently. Four of them now emit 33570 and 36739 SPIR-V words and also pass--materialize; the other six need a Phi in a second block too (two nested Phis in two blocks, whichSplitDescriptorEdgesrefuses and whichad72175a677left alone on purpose), so they still stop.Tested
verifyDescriptorWebDeepDwordChaininagc_shader_memory_tests: a T# dword built under a branch as an SRT load plus fours_add_u32(a ten-operation chain) must be rebuilt, not folded. It fails onmainwith the folding message and passes with the change.agc_shader_memory_tests(every internal case) withANYPS5_NO_SHADER_CACHE=1: passes onmainand with the change.agc_shader_descriptor_phis,agc_driver_descriptor_web_faultsandagc_driver_buffer_descriptor_runtimewithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer: 3/3 pass on both; each log showsInsert instance layer "VK_LAYER_KHRONOS_validation"twice, noVUID-and nowas not found but was requested by env var.check_conventionsanddebt_fold --checkclean.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
Bug Fixes
Compatibility
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T00:35:55Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed code and supporting evidence are consistent with the stated fixes.
What I ran
a3c49e52e40686d0a3a94e393d76ddd3c0c62966usingrepo_read.pyand the prepared review artifacts.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from full-text review because it exceeded the review folder limit; its added test hunks were inspected in the prepared diff. All other changed files listed in the manifest were read at the relevant changed lines.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T17:08:18Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected changes appear consistent with the stated fixes, but I did not run the reported checks, so a formal approval is not justified.
What I ran
Inspected prepared diff and repository files at head
0345a4409acb2b92ff97485ecbf7da343272b68busingrepo_read.pytools. No test or build command was run.Results
Negative control
Not run; no test command could be run in this review session.
Findings
Blocking
None.
Non-blocking
None.
Sources
Reviewed the prepared diff and targeted code at the pinned head, including
ResourceTracker.cpp, SRT evaluator and tape changes, and the added regression cases.Not verified
No tests, builds, or runtime behavior were verified. The PR description's test results, GPU observations, and offline shader replay are author reported. The full text of
ShaderMemory.cppwas excluded from the review folder because it was too large; I read the added test and nearby helper ranges through the reader. Other changed files were read at their changed sections or in full where short.To get this to a good state
Nothing is required. Optional: run the checks described in the PR on this head and share their results.
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-23T10:41:43Z.
Review: APPROVED
Windows check of head
0345a4409awith GCC 16 on an NVIDIA and an AMD GPU, merged ontomainf5b7e1d1ac(clean merge). The Windows runs so far are NVIDIA only, and the one with the validation layer is of the #21763 stack, not this head.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, 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 #25010, which touches other files apart fromShaderMemory.cpp.agc_shader_memory,agc_shader_memory_coherent_atomic_loads,agc_shader_descriptor_phis,agc_driver_descriptor_web_faultsandagc_driver_buffer_descriptor_runtime: 5 of 5 onmain, and with this PR in 3 of 3 runs, on both GPUs. NoVUID-lines.descriptorDwordDepthback to 8,agc_shader_memoryfails withdescriptor web deep dword chain: a uniform dword chain longer than the phi search bound was folded into a faulting arm instead of rebuilt.ConvertS32F32case always refusing,agc_shader_memoryfails withSRT float-to-signed conversion: descriptor expression could not be evaluated. So both commits are guarded.Correction (edited): I first wrote here that the
FormatVersionbump is lost and that amaincache would be reused. That was wrong.ShaderDiskCachealso rejects a file whoseSourceVersiondiffers, andShaderCacheVersion.cmakehashes every recompiler source, so this PR'sResourceTracker.cppchange invalidates the cache on its own.mainis already at 96 (#21973), so the bump here is a no-op, but harmless. #25010 takes 97.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T22:23:34Z.
Review: COMMENTED
Actionable comments posted: 3
be1d8c0a-31f0-414a-88c9-84038ac8d3fcReviewing files that changed from the base of the PR and between
00b15fcbb0andbadbe8c7fd.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/include/Optimization/SrtWalker/SrtTape.hppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtInstructionPredicates.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cppcore/shader/recompiler/ShaderDiskCache.hppdocs/dev/debt/changes/fix-shader-descriptor-dword-depth.mddocs/dev/debt/changes/fix-shader-srt-convert-s32-f32.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T22:42:59Z.
Review: COMMENTED
Reviewed — comments
The review covers head
badbe8c7fdcf9d58e130f32307f4381fbab511bb; I found no verified blocking defect, but the large changed test file and programmatic checks were not reviewed or run.What I ran
No programmatic checks were run. I read the prepared description, commits, manifest, and diff, plus targeted evaluator, tape, and resource tracker context through
repo_read.py.Results
Findings
Blocking
None verified.
Non-blocking
description.mdsays the shader cache format changes from 89 to 90, while the diff changesFormatVersionfrom 97 to 98 (core/shader/recompiler/ShaderDiskCache.hpp:313). Please correct the description so it matches this commit.Sources
Not verified
I did not read
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppbecause its full text was excluded from the review folder, and I did not independently run the reported tests or validate other environments or console behavior. The included changed files were listed in the manifest; the excluded file wascore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp.To get this to a good state
Nothing is required. Optional: update the cache format version in the PR description to 97 → 98.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T00:05:13Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
1fcf8100b8acbc730f9d393127b393015d9df402against the prepared diff. No merged preview was run. I used the pinnedrepo_read.pyreader for source searches and targeted ranges; no tests or builds were run.Inspected all nine changed files listed as reviewed. For the oversized
ShaderMemory.cpp, I read the changed test regions, helper, and test registration.files.jsonlists no excluded files.Results
Negative control
Not run; no tests were executed or source changed during review.
Findings
Blocking
None.
Non-blocking
Sources
Not verified
Tests reported in the PR description were not run during this review. Native RDNA2/PS5 execution and title behavior remain unverified, as noted in the change documentation.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T00:07:51Z.
Review: COMMENTED
Actionable comments
7acffc3b-cb86-4960-a8dc-23e57fb6f7bcReviewing files that changed from the base of the PR and between
badbe8c7fdand1fcf8100b8.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/include/Optimization/SrtWalker/SrtTape.hppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cppcore/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cppcore/shader/recompiler/ShaderDiskCache.hppIncluded 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 ligmaSec on 2026-12-03T22:18:05Z.
Review: COMMENTED
The trial merge onto
a1b75b0947and a trial composition with #21763 were both clean. This change uses a separate 16-node budget for descriptor-dword rematerialization while keeping the existing phi search limit. Preserve a fixture that fails at the old dword limit when these two patches land together. The paired evaluator and tape coverage forConvertS32F32should also survive the shared code changes. Paired shader-memory validation is pending.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.