fix(shader): replicate a lane-invariant descriptor dword into both web arms #21763
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/21763"
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:59:42Z.
What
A descriptor web splits a read whose descriptor dwords are chosen per lane into one arm per choice.
LaneSelectorgave up as soon as one dword of the tuple was not the same per-lane selection and not an immediate —a per-lane descriptor selection mixes dwords selected differently— even when that dword cannot vary per lane at all: an SRT read, a user-data register or uniform arithmetic over them.Such a dword is now recognised with the same predicate the runtime validator already uses for a descriptor dword (
SrtWalker::ValidateRuntimeValue) and replicated into both arms, so a sampler or texture whose index and some of whose fields are per-lane gets split instead of refused.Evidence: The Last of Us Part I (PPSA07642) registers pixel shaders
0x12b6a8fd00and0x12b6a9e900, whose S# mixes av_readfirstlaneof a per-lane select with three SRT dwords. Both prepare withagc_shader_replay --prepare(15521 SPIR-V words) where they stop atGetSamplerResource dword 1 is not a valid runtime value; four more of that title's ten such shaders already prepare with the dependencies above.Tested
agc_shader_memory_tests(every internal case) andagc_shader_srt_read_patchingwithANYPS5_NO_SHADER_CACHE=1: pass.agc_shader_descriptor_phis,agc_shader_srt_read_patching,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: 4/4 pass, fourInsert instance layer "VK_LAYER_KHRONOS_validation"lines, noVUID-.check_conventionsclean;pr_overlap --names LaneSelectorshows no other branch declaring it.agc_shader_memory(core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp):verifyDescriptorWebLaneInvariantDwordbuilds a descriptor web with a hand-written mixed tuple (one per-lane selection and SRT dwords) and asserts it splits with the SRT dwords replicated into both arms;verifyDescriptorWebLaneVariantRefusalkeeps a per-lane dword that is not the selection and asserts the split is still refused.agc_shader_memorypasses withANYPS5_NO_SHADER_CACHE=1, and the first case fails before this change ("a per-lane descriptor selection mixes dwords selected differently").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-17T03:17:54Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
353af1c2170a7d665123213bbf4d8e0de03c6034, basemain.repo_read.py, pinned to the head):Results
Findings
Blocking
None verified.
Non-blocking
core/shader/recompiler/Optimization/src/ResourceTracker.cpp:1670now rebuilds descriptor dwords up to 16 operations deep, but the strict-mode give-up on line 1672 still callsRebuildBlocker(value, phiSearchDepth).RebuildBlockerthen reports "a chain deeper than 8 operations" (line 1604). For a 12-operation chain whose non-uniform operation sits at depth 10, the message reports the 8-operation limit instead of the real cause. This only affects the strict diagnostic, not the folding result.verifySrtFloatToSignedConversion(core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:1497) andverifyDescriptorWebDeepDwordChain(core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:3023). The body should name all three commits and the new tests, and say which of them ran on this head.core/shader/recompiler/Optimization/src/ResourceTracker.cpp:1768adds theLaneInvariantDwordcase toLaneSelector. The description already says so.Sources
github.com/boykopovar/AnyPS5@353af1c217/core/shader/recompiler/Optimization/src/ResourceTracker.cpp (L1670-L1672)github.com/boykopovar/AnyPS5@353af1c217/core/shader/recompiler/Optimization/src/ResourceTracker.cpp (L1603-L1605)github.com/boykopovar/AnyPS5@353af1c217/core/shader/recompiler/Optimization/src/ResourceTracker.cpp (L1741-L1768)OpConvertFToS:github.com/boykopovar/AnyPS5@353af1c217/core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp (L1204-L1207)github.com/boykopovar/AnyPS5@353af1c217/core/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cpp (L677-L684)Not verified
constexpr SrtWalker walker;(ResourceTracker.cpp:1745) and the new test code were not compiled.SrtWalkerhas no data members in the header I read, so the constexpr declaration should be valid, but that is not confirmed by a build.usesFaultBuffer == falsefor the deep chain, are unconfirmed.main.SrtTape.cppandSrtEvaluator.cppagree, but I readSrtTape.cppandSrtInstructionPredicates.cpponly in the diff.reviewedlist.To get this to a good state
Nothing is required.
The optional points are the non-blocking findings above.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T11:03:20Z.
Review: COMMENTED
Reviewed — no blocking findings
No blocking defect was verified in the code inspected; the review is incomplete because not every changed line was read and no checks were run.
What I ran
Reviewed head
6f269ed545237e88d9df332a8299b6b92c8d5464throughrepo_read.py. No tests or other checks were run.Results
Findings
Blocking
None verified in the inspected code.
Non-blocking
None.
Not verified
The new lines in
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwere only partly read; the file was excluded from the prepared review folder because of its size. Not every changed line in the other files was read. No tests, prechecks, GPU execution, console behavior, or title behavior were verified. Inspected changed files:core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp(targeted range);core/shader/recompiler/Optimization/include/Optimization/SrtWalker/SrtTape.hpp;core/shader/recompiler/Optimization/src/ResourceTracker.cpp;core/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cpp;core/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cpp;core/shader/recompiler/ShaderDiskCache.hpp. Not read:core/shader/recompiler/Optimization/src/SrtWalker/SrtInstructionPredicates.cppand both added debt documentation files.To get this to a good state
Nothing is required. Optional: run the reported tests and read the remaining changed lines before treating this as a complete review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T17:07:14Z.
Review: COMMENTED
Reviewed — comments
The change extends descriptor web splitting and runtime SRT evaluation; I found one test gap that should be addressed before relying on the new behavior.
What I ran
Reviewed head
7ca6f54ec969789c5ab35816bb40d4f3193970ea. I read the prepared description, commits, manifest, diff, and all changed source files available in the review folder; I also read the full changed test file throughrepo_read.py. No build or tests were run during this review. The test results in the description are author-reported.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp:184adds a regression case for the lane-invariant descriptor dword, but the test verifies only that shader recompilation succeeds. It does not verify the produced descriptor arms or selected values. Add an assertion that would fail if the invariant dword were omitted or changed in either arm, so the test guards the behavior this change introduces.Not verified
files.jsonwas not present in the prepared review folder; the folder listing confirmed the changed-file inventory and the test source was read from the pinned head.To get this to a good state
Nothing is required. Optional: strengthen the lane-invariant descriptor regression test to check the resulting descriptor arms and values.
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-22T18:39:17Z.
Review: APPROVED
Windows check of head
7ca6f54ec9(with #21745 and #21240 under it) with GCC 16 on an NVIDIA and an AMD GPU, merged ontomain11f95ea8f6(clean merge). The Windows runs so far were NVIDIA only.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 #17956, which touches other files.agc_shader_memoryandagc_shader_memory_coherent_atomic_loads, run with the native-depth set below: pass on both GPUs, onmainand with this PR, in 3 of 3 runs, with noVUID-lines.LaneInvariantDword(*value) ||in the web-arm replication,agc_shader_memoryfails withGetImageResource dword 0 is not a valid runtime value; chain: ReadFirstLane(SelectU32(…, ReadConst(GetSrtResource, …), ReadConst(GetSrtResource, …)), …); descriptor web: a per-la….On MarcZX10's non-blocking point that
verifyDescriptorWebLaneInvariantDwordonly checks that the recompile succeeds: the red check shows that undoing the fix makes the recompile fail on that case. So it does guard the regression this PR fixes. Checking the arms' values, as suggested, would also guard against a fold that picks the wrong dword.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T22:23:39Z.
Review: COMMENTED
Actionable comments posted: 6
c981afc4-df72-4d18-b715-05e49ec19dcaReviewing files that changed from the base of the PR and between
00b15fcbb0andefc21d368f.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; 5 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T22:42:07Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at head
efc21d368f9288beecc56a42b62095d5a57eaeb3has no verified blocking defects; the evaluator, tape, and descriptor-web changes are consistent with the stated behavior, and the author reports focused tests passing.What I ran
No commands or tests were run. I inspected the prepared diff and the changed code at the pinned head.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests were not run independently. Physical console execution and title behavior are not verified. Read all changed lines in
ShaderMemory.cppvia the pinned reader because the file was excluded from the review folder; read all other changed files through the prepared files. No changed files were excluded from review.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T08:59:06Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the optional points below are for awareness.
What I ran
Reviewed head
4bb0c533db32663e64082cd2329c3727dd32d482using the prepared review bundle andrepo_read.py. No tests were run in this review; test results in the PR description are author-reported.Results
Findings
Blocking
None.
Non-blocking
ResourceTracker.cpp:2131usesValidateRuntimeValueto classify an entire U32 expression as lane-invariant. The validator implementation was not inspected, so the boundary of that predicate was not independently confirmed here.Not verified
The full text of
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded because it was too large for the review bundle. Its diff hunks were inspected, but surrounding test context and test registration were not verified. The included changed files inspected werecore/shader/recompiler/Optimization/include/Optimization/SrtWalker/SrtTape.hpp,core/shader/recompiler/Optimization/src/ResourceTracker.cpp,core/shader/recompiler/Optimization/src/SrtWalker/SrtEvaluator.cpp,core/shader/recompiler/Optimization/src/SrtWalker/SrtInstructionPredicates.cpp,core/shader/recompiler/Optimization/src/SrtWalker/SrtTape.cpp,core/shader/recompiler/ShaderDiskCache.hpp, and both changed debt notes. Console behavior and the reported test runs were not independently verified.To get this to a good state
Nothing is required. Optional: confirm the runtime validator's lane-invariance boundary and run the reported test set on this head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T00:02:41Z.
Review: APPROVED
Reviewed — looks good
The changed descriptor handling and SRT conversion logic are supported by the inspected code and tests, with no verified blocking defects.
What I ran
Reviewed head
9adafafcadd7cdb6ec45b90186fc66001917074busingrepo_read.pyfor changed code and targeted source context. No build or tests were run. No merged preview was checked.Results
Negative control
The new lane-variant refusal test was inspected but not run.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The full 14,538-line
ShaderMemory.cppfile and unrelated portions of other changed files were not read end-to-end. Tests and title behavior were not independently run; test results in the PR description are author-reported.To get this to a good state
Nothing required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T00:08:31Z.
Review: COMMENTED
Actionable comments
94c39dad-fa9f-494b-a8a0-5e4f601d9688Reviewing files that changed from the base of the PR and between
4bb0c533dband9adafafcad.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/SrtTape.cppcore/shader/recompiler/ShaderDiskCache.hppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:13:57Z.
Review: COMMENTED
The trial merge onto
a1b75b0947was clean. I checked that the descriptor-web change uses a lane-invariance proof before replicating a dword and that both the immediate evaluator and runtime tape handleConvertS32F32bounds before converting. The targeted shader-memory tests include safe narrowing and rejected exceptional inputs. Please retain both implementations and those controls if the descriptor-web and conversion changes land in separate commits. 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.