fix(shader-recompiler): admit first-lane reads of wave-uniform values in stencil replay #18322
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18322"
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 mrfelek on 2026-11-11T08:15:48Z.
What
On a device without
VK_EXT_shader_stencil_export, stencil reference replay refuses every pixel shader that has aReadFirstLane. This PR admits aReadFirstLanewhose value every lane of the wave holds alike, so which lane it reads makes no difference between replay passes.MaskReplaySafetyintoWaveUniformValues, which the lane-op check and the mask proof now share.ReadConstBufferof aScalarBuffer,LoadAddressU32of aScalarAddress), when their own operands are uniform;FPRecip32/FPRecipIFlag32.ReadLanestays refused. Its shuffle can name an inactive lane.PPSA03671 hits this with
v_readfirstlane_b32in an unsigned divide by a scalar buffer value. That pixel shader then stops at the mask proof, on ans_cbranch_execzbody whose exec-restoring export tail the structurizer duplicated. That is left for a separate change, so this PR doesn't unblock the title alone.Tested
Linux 7.3, RTX 3080 Ti, NVIDIA 615.71.09 (no
VK_EXT_shader_stencil_export).agc_masked_select_testshas four new cases holding seven checks:LaneId, a vector-buffer read andFragCoordare refused;ReadLaneof a uniform value is still refused;ExecZeroskip on a scalar-buffer predicate is proven, and one on a vector-buffer predicate is not.main'sStencilReplay.cpp, and all cases pass with this change.ctest -R 'stencil|masked_select|read_first_lane|pixel_helper_lanes|exec_host_lanes|permlane16' -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, onmainand on this branch:agc_driver_stencil_ref_exportis skipped, since the device lacks the extension.VUID-lines and no missing-layer line in either log.PrepareResourceProgram, the logged PPSA03671 pixel shader's oneReadFirstLaneis uniform, and the shader is now refused only by the mask proof.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T16:31:25Z.
Review: COMMENTED
Reviewed the first-lane stencil replay change — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
115288655cf9d34f0947f709f2bff2e890f76b51, basemain. Read from the pinned diff; no merge preview and no build.Results
Findings
Blocking
None.
Non-blocking
docs/dev/debt/libSceAgcDriver.md:172: the debt entry says "user data, scalar memory reads and arithmetic on them". The walk incore/shader/recompiler/StencilReplay.cppalso accepts descriptor handles,ReadConst, float compares, and the select and compare ops ofIsRuntimeUniformOp. The entry should name that set.core/libs/prx/libSceAgcDriver/tests/MaskedSelect.cpp:963: the description says "five new cases". The diff adds fourrun(registrations holding seven checks, so neither count matches.core/libs/prx/libSceAgcDriver/tests/MaskedSelect.cpp:986:const auto exportUnder =[]drops the space before[]that the other lambdas keep. The line changes only in whitespace.The uniform walk (
WaveUniformValues::Uniform) refuses cycles and deep chains by caching a refusal. That is conservative. I found no path in the code I read that admits a lane-varying value toReadFirstLane.ReadLanestays refused.Not verified
agc_masked_select_tests, and the ctest set. The claims that the two admit cases fail onmainand that 19 of 20 tests pass are the author's and were not run here.MaskedSelect.cppandStencilReplay.cpp, including the mask proof body and the call sites ofuniform, was not read. The full texts infiles/were not read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T02:01:56Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the focused tests and conservative uniformity checks support the stated admission rule.
What I ran
Reviewed head
bf98c25574268e1e3796de1359ca80690c2ed2be. No test or build commands were run;repo_read.pywas used to inspect the prepared diff and targeted source ranges. The author reports running tests on Linux 7.3 with an RTX 3080 Ti and NVIDIA 615.71.09; those runs were not independently verified.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or builds were run. Test execution and the reported GPU behavior were not independently verified. All changed files listed as reviewed in
manifest.jsonwere read:core/libs/prx/libSceAgcDriver/tests/MaskedSelect.cpp,core/shader/recompiler/StencilReplay.cpp, anddocs/dev/debt/libSceAgcDriver.md.files.jsonwas not available through the reader; the manifest lists all three changed files as included, with none excluded.To get this to a good state
Nothing is required.