fix(recompiler): accept whole-quad mask halves from separate expansions in stencil replay #9370
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9370"
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-21T19:31:09Z.
What
On devices without
VK_EXT_shader_stencil_export,MaskReplaySafetyaccepts an own-lane mask built fromWqmU64only when both 32-bit halves are extracted from the sameWqmU64value. Onimusha: Way of the Sword (PPSA27836) has a stencil-exporting pixel shader that expands the same mask twice: once for the low word and once for the high word, each with its ownBallot(true)/WqmU64. The two expansions are identical but are separate IR values, so the mask was refused.A quad never straddles bit 32, so the low half of
WQM(m1)depends only onm1's low word, and the high half ofWQM(m2)only onm2's high word. The pair is thereforeWQM(m1.low, m2.high).wqmHalves()now matches that shape (and the same-value shape as before, which is the casem1 == m2):maskStablerequires both source masks to be replay-stable in full, so every value feeding either expansion is still checked and restricted, including the half that is dropped;helpers) is checked on the halves actually used,(m1.low, m2.high).Wave32 behaves as before: only the low half is read.
This is one of several gaps the Onimusha shader hits (it also needs #8145, and further changes after this one), so no title is claimed to be unblocked.
Tested
Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, Release, on main
1896871ba.agc_masked_select, three new cases: a stencil export selected by a whole-quad mask whose low half comes from one expansion of the predicate and whose high half from a second expansion is replay-safe; the same with a helper-dependent mask in only the high half, or only the low half, is refused. On main the first fails (stencil replay admits whole-quad mask halves taken from separate expansions of one mask) and the two refusals pass, as expected.shader_2111c51800, dumped withAPS5_DUMP_SHADERS) checked offline withPrepareResourceProgram+StencilReplaySafeon a local stack of #8145, #9017, #9030 and this change: without this change it stops at an own-lane mask (CompositeExtractU64halves of two differentWqmU64values); with it, every own-lane mask is accepted and it stops at the next gap (the optional body behind block 0'ss_cbranch_execz).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); #9017 and #9030 touch the same file inhelpers()andoptionalBody(), not these branches.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-21T19:52:36Z.
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/libs/prx/libSceAgcDriver/tests/MaskedSelect.cppL1068core/shader/recompiler/StencilReplay.cppL190-201, L288-297core/libs/prx/libSceAgcDriver/tests/MaskedSelect.cppL1068core/shader/recompiler/StencilReplay.cppL190-201, L288-297Some 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-22T07:04:29Z.
Review: CHANGES_REQUESTED
I ran the focused regression on head
c619555ebf58954bfd7d87ea2a680ef7966bf561:cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON. The submodule checkouts used are at the exact gitlink revisions pinned by this head.cmake --build build --target agc_masked_select_tests -j2: passed, including compilation of the changedStencilReplay.cpp.ctest --test-dir build -R '^agc_masked_select$' --output-on-failure: passed 1/1.StencilReplay.cppmade that exact new case fail; restoring the PR source made it pass again.python3 tools/check_conventions.py --base upstream/main --head refs/review/9370andgit diff --check upstream/main...HEAD: passed. Current-main merge-tree is clean.The focused IR test supports the logic change. I could not run the required Vulkan validation comparison here: this container has no GPU device. The PR's same-machine tests on main and the change are useful, but
CONTRIBUTING.mdrequires the focused AGC/shader tests on both withVK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, then a VUID comparison. The PR explicitly says the validation layer was unavailable on its test host. Please rerun that comparison on a machine with the layer and attach the exact logs/results; the local IR test does not replace it.Please also bring the branch up to current
main(it is 514 commits behind) and refresh the overlap report. The currenttools/pr_overlap.py --base mainscan reports shared/conflicting test hunks with #8145 and #9017, and bothMaskedSelect.cppandStencilReplay.cppconflicts with #9266 and #9317. I manually checked the implementation overlap: #9266 pairs structurally equivalent WQM evaluations, while this PR accepts separately expanded halves after validating each source; these are related and touch the same safety gates. #9317 is explicitly stacked on #9017, #9030 and #9266. The scan also cannot compare #6879's sharedMaskedSelect.cpp; its test additions are adjacent to this PR's additions. Please coordinate merge order with those authors, preserve each test, and list any agreed prerequisites underDepends on.Finally, the title-specific report in this PR and its test stack are for Onimusha PPSA27836 (#5769), while the checklist says
Unblocks: noneand the Game bring-up discussion's open-PR table does not list this change. Please reconcile that tracking withCONTRIBUTING.md: if this fixes the recorded shader stop even though another gate remains, name the title/discussion on the checklist and update the bring-up list; otherwise explain why the title-specific evidence does not count as a fix to that stop.Current hosted conventions, eligibility, intake, labels and report checks pass. Product Linux/Windows and other relinker/platform checks are skipped, so they do not provide Vulkan or full-build validation for this change.
Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-22T09:09:36Z.
Closing in favour of #9266. I checked the Onimusha request (
shader_2111c51800, PPSA27836) offline on #9317's branch (which carries #9017, #9030 and #9266) plus #8145: every own-lane mask is accepted there, including the low/high whole-quad halves this PR was written for, so #9266's structural pairing covers this shader and a second rule isn't needed.AI-assisted: yes (Claude Code).
Pull request closed