fix(recompiler): accept optional-body merges implied by the skip predicate in stencil replay #9393
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9393"
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:22:14Z.
What
On devices without
VK_EXT_shader_stencil_export,MaskReplaySafety::optionalBodyaccepts an EXEC- or VCC-skipped body when every merge phi's value from the body equals the skipped value on lanes that are inactive in the body (inactiveEquals). Lanes are inactive in the body exactly where the skip predicatePis false.A body value that implies
Pis false on every inactive lane. When the phi's skipped value isPitself, that is also false there, so the two are equal on inactive lanes.inactiveEqualsnow accepts a Bool body valuevwhen the skipped value is the predicate andGuardImplies(v, P)holds. The case that needs it is a lane's own bit ofBallot(P)(optionally intersected with a whole-quad active mask) merged withP: Onimusha: Way of the Sword (PPSA27836) has this as the "lane is done" flag of its stencil-exporting pixel shader, merged after ans_cbranch_execzbody.The existing rules (same value, select on the predicate, region phis) are unchanged.
This branch is rebased onto
main570089a80, which now carries #9317 (merged asdef1f5dd9); the diff is this PR's own commit (one line ininactiveEqualsand two test cases).Tested
Rebased 2026-10-26: on this head
bf0589e28(main570089a80), withANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1on the RTX 3080,agc_masked_select,agc_driver_sample_mask_depth_stencil,agc_driver_stencil_known_replace,agc_driver_stencil_null_feedback,agc_driver_stencil_ref_export_unused,agc_driver_stencil_replayandagc_driver_stencil_replay_no_gplpass andagc_driver_stencil_ref_exportskips (noVK_EXT_shader_stencil_export);tools/check_conventions.py --base origin/mainpasses. The results below were taken on the earlier #9317 base.Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7, Release, on #9317's head
92ebac241.agc_masked_select, two new cases on a single-block EXEC-skipped body: merging a lane's own bit ofBallot(P)from the body withPfrom the skip is replay-safe; merging!P(true on inactive lanes) is refused. With #9317'sStencilReplay.cppthe first fails (an optional wave body may merge a lane's own bit of the predicate's ballot with the skipped predicate) and the second passes; with this change both pass.The Onimusha request (
shader_2111c51800, dumped withAPS5_DUMP_SHADERS) checked offline withPrepareResourceProgram+StencilReplaySafeon #9317 + #8145: without this rule block 0's merge phi of the "done" flag refuses ininactiveEquals; with it, that phi is accepted. The request still needs the ballot exemption I asked about on #9317 and a change for an early exit inside the optional body before it passes (details on #9317), so no title is claimed.With
ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1, on #9317 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 #9317 and on this change.Not run: the Khronos validation layer (not installed on this host, so
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationhas nothing to load; neither log contains aVUID-line), a title.tools/check_conventions.py --base origin/mainpasses with no errors (its one warning,debt-lengthondocs/dev/debt/libSceAgcDriver.md, is in #9317's entry, which this PR does not touch) andgit diff --checkpasses.tools/pr_overlap.pywas not run (noghon this host).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 xXPBSXx on 2026-10-21T23:59:40Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
mainis clean. I built onlyagc_masked_select_tests;ctest -N -R agc_masked_selectlists exactly one test.PR head tested:
61d4817df599177df2a618c20d4a951fa86677da.Results (3 runs each):
agc_masked_selectpasses 3/3.core/shader/recompiler/StencilReplay.cppwith the version from the PR's merge base (0c6a5bd593), then rebuilt. The test fails 3/3 (ctest reports Failed). I restored the PR's files afterwards.GPU: the run output has no
Selected GPUline; no GPU claim is made.Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T06:07:55Z.
Review: DISMISSED
The new
inactiveEqualscase is narrowly guarded byIrType::Bool, predicate identity, andGuardImplies, and the positive/negative regression cases are useful. I builtagc_masked_select_testson this head and ranagc_masked_selectthree times; all three passed. As a local paired check, I applied only the new test hunk to currentmain: the suite failed on the expected “own bit of the predicate's ballot” case.tools/check_conventions.py --base upstream/mainandgit diff --checkalso pass.I cannot approve yet because the change still needs the repository-required follow-up:
mainis5a79f26450; this head is 442 commits behind. Please rebase and refresh the conventions and overlap checks.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_LAYER_KHRONOS_validationhas no VUID comparison. Please rerun the focused main/change tests with the layer and report GPU/driver details and VUID differences. The local unit test above is host-only; I could not run GPU tests here.inactiveEqualsoverlap with open #9317. Please coordinate with that author and agree order/composition, then setDepends onaccurately. The overlap tool could not compare #6879’sMaskedSelect.cpp; I manually confirmed it also adds tests in this file, so please refresh that test-area comparison after rebase.quadObservedand explicitly relies on the separate #9394 change. Please keep the title result scoped to the combined changes and coordinate the dependency/order with #9394 so the checklist and unblocks claim reflect what is actually required.Hosted eligibility, conventions, intake, labels, and report checks pass; product build jobs were skipped. The local focused test and author/independent Windows reports are positive evidence, but the Vulkan validation-layer requirement and current-main/overlap updates remain outstanding.