fix(recompiler): let optional-body merges reach vetted ballots and wave branches in stencil replay #9394
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9394"
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 TheSovietWaffle on 2026-10-21T20:23:08Z.
What
On devices without
VK_EXT_shader_stencil_export,MaskReplaySafety::optionalBodyrefuses an EXEC- or VCC-skipped body when a merge phi isquadObserved: when the merged value reaches a sampler or LOD query, a ballot, a whole-quad mask, a lane-crossing read, shared memory, or any branch condition. The derivative case is the reason for the check (an inactive helper lane's coordinates must not change for a kept lane's implicit LOD; the existingoptionalPixelBodyrefusals cover it).Two of those users are already checked by the mask analysis itself, and
helperObservedalready treats them that way:MaskReplaySafetyhas restricted: its masks were proven stable (maskStable), its whole-quad expansions have their helper provenance checked (helpers), and every user of a restricted value must itself be restricted, an own-lane mask, or a reference;control().quadObservednow skips restricted users and EXEC/VCC branch conditions, likehelperObserved. It still refuses derivatives, unrestricted ballots and whole-quad masks, lane-crossing reads, shared memory, and scalar branches.Onimusha: Way of the Sword (PPSA27836) needs this: the "lane is done" flag merged after an
s_cbranch_execzbody in its stencil-exporting pixel shader feeds the nexts_cbranch_execzand the ballot that builds the export mask.Tested
Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, Release, on main
0c6a5bd59.agc_masked_select, two new cases on the existing single-blockoptionalPixelBody: a merged value read only through an own-lane ballot export guard is replay-safe; the same value widened to its whole quad and used to select the stencil is still refused. On main the first fails (an optional wave body may merge a value that a vetted own-lane ballot guard reads); the second and the existing derivative refusals (... cannot change helper coordinates for later implicit samples,... for LOD queries) pass on both.shader_2111c51800, dumped withAPS5_DUMP_SHADERS) checked offline withPrepareResourceProgram+StencilReplaySafeon a local stack of #8145, #9017, #9030, #9370 and #9393 (theinactiveEqualsrule): with both, blocks 0 to 3 are accepted and it stops at block 8 (an early exit inside a skipped body), so no title is claimed.ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1, on main and on this change:agc_masked_select,agc_driver_sample_mask_depth_stencil,agc_driver_stencil_known_replace,agc_driver_stencil_null_feedback,agc_driver_stencil_ref_export,agc_driver_stencil_ref_export_unused,agc_driver_stencil_replayandagc_driver_stencil_replay_no_gplpass on both GPUs below, exceptagc_driver_stencil_ref_exportskipped on the RTX 3080 (noVK_EXT_shader_stencil_export). Results are identical on main and on this change.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationhas nothing to load; neither log contains aVUID-line), a title.tools/check_conventions.py --base origin/mainandgit diff --checkpass.tools/pr_overlap.pywas not run (noghon this host); #9030 editsoptionalBody, notquadObserved.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)1002:164e), 32.0.21045.5002, Windows 10 22H2🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T20:39:21Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/shader/recompiler/StencilReplay.cppL452-453core/shader/recompiler/StencilReplay.cppL450, L452Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/tests/MaskedSelect.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T05:48:36Z.
Review: CHANGES_REQUESTED
The focused red/green cases and the reported Windows NVIDIA/AMD runs are useful, and I did not find a concrete defect in the revised
quadObservedchecks on this head. I cannot approve it yet because several repository requirements remain unresolved:0c6a5bd593, while currentmainis4a17c71757. Please rebase and refresh the conventions and overlap checks against currentmain.VK_LAYER_KHRONOS_validationwas unavailable, so there is no validation-layer VUID comparison. Please rerun the required paired main/change tests withANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1, and the Khronos layer enabled, and report the GPU/driver and VUID differences. The existing focused test results are valuable, but do not cover that required check.quadObservedcontrol/ballot logic, and #7410, which modifies the same cross-lane refusal condition. Agree on ordering/composition with those authors and updateDepends onaccordingly; the current checklist says none. Refresh the manual test-file comparison with #6879 after rebasing, since both touchMaskedSelect.cpparound the same test area.The repository's hosted eligibility, conventions, intake, labels, and report checks pass. Product build jobs were skipped by CI. I did not run a local shader/GPU test in this environment. Please post the refreshed test report even if the validation layer remains unavailable, and state that limitation clearly.
Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-22T09:11:26Z.
Closing: #9317 implements the
quadObservedrelaxation with the exemption tied to each branch's own proof, which is stricter than this PR's blanket EXEC/VCC exemption. Details and the one extra case Onimusha needs are on #9317.AI-assisted: yes (Claude Code).
Pull request closed