Skip to content

fix(recompiler): accept optional-body merges implied by the skip predicate in stencil replay - #9393

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
TheSovietWaffle:fix/recompiler-stencil-replay-implied-merge
Oct 26, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
TheSovietWaffle:fix/recompiler-stencil-replay-implied-merge

Conversation

@TheSovietWaffle

@TheSovietWaffle TheSovietWaffle commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

On devices without VK_EXT_shader_stencil_export, MaskReplaySafety::optionalBody accepts 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 predicate P is false.

A body value that implies P is false on every inactive lane. When the phi's skipped value is P itself, that is also false there, so the two are equal on inactive lanes. inactiveEquals now accepts a Bool body value v when the skipped value is the predicate and GuardImplies(v, P) holds. The case that needs it is a lane's own bit of Ballot(P) (optionally intersected with a whole-quad active mask) merged with P: Onimusha: Way of the Sword (PPSA27836) has this as the "lane is done" flag of its stencil-exporting pixel shader, merged after an s_cbranch_execz body.

The existing rules (same value, select on the predicate, region phis) are unchanged.

This branch is rebased onto main 570089a80, which now carries #9317 (merged as def1f5dd9); the diff is this PR's own commit (one line in inactiveEquals and two test cases).

Tested

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none (PPSA27836 Onimusha: Way of the Sword (PPSA27836) #5769 needs this plus the ballot exemption asked about on fix(recompiler): exempt proven control conditions and own-bit ballots in stencil replay #9317 and an early-exit change for optional bodies)
  • GPUs tested: NVIDIA RTX 3080, 617.42, Windows 10 22H2; AMD Radeon RDNA 2 iGPU (1002:164e), 32.0.21045.5002, Windows 10 22H2
  • AI-assisted: yes

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Some 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.

Pull request Shared files not compared
PR 6959 core/libs/prx/libSceAgcDriver/tests/MaskedSelect.cpp
core/shader/recompiler/StencilReplay.cpp
PR 7410 core/shader/recompiler/StencilReplay.cpp

@xXPBSXx

xXPBSXx commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

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 main is clean. I built only agc_masked_select_tests; ctest -N -R agc_masked_select lists exactly one test.

PR head tested: 61d4817df599177df2a618c20d4a951fa86677da.

Results (3 runs each):

  • PR head: agc_masked_select passes 3/3.
  • Baseline: I kept the PR's test and replaced only core/shader/recompiler/StencilReplay.cpp with 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 GPU line; 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).

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 22, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new inactiveEquals case is narrowly guarded by IrType::Bool, predicate identity, and GuardImplies, and the positive/negative regression cases are useful. I built agc_masked_select_tests on this head and ran agc_masked_select three times; all three passed. As a local paired check, I applied only the new test hunk to current main: the suite failed on the expected “own bit of the predicate's ballot” case. tools/check_conventions.py --base upstream/main and git diff --check also pass.

I cannot approve yet because the change still needs the repository-required follow-up:

  • Current main is 5a79f26450; this head is 442 commits behind. Please rebase and refresh the conventions and overlap checks.
  • This is a shader-recompiler change. The PR report says the Khronos validation layer was unavailable, so the required paired GPU run with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_LAYER_KHRONOS_validation has 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.
  • The refreshed overlap scan finds direct inactiveEquals overlap with open #9317. Please coordinate with that author and agree order/composition, then set Depends on accurately. The overlap tool could not compare #6879’s MaskedSelect.cpp; I manually confirmed it also adds tests in this file, so please refresh that test-area comparison after rebase.
  • The Tested section says the Onimusha shader still stops at quadObserved and 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.

@TheSovietWaffle

Copy link
Copy Markdown
Contributor Author

Paired run with the Khronos validation layer (@MarcZX10's request), 2026-10-23.

Layer: VK_LAYER_KHRONOS_validation from KhronosGroup/Vulkan-ValidationLayers' Windows nightly build of 2026-10-22 (manifest api_version 1.4.365), loaded with VK_ADD_LAYER_PATH; VK_LOADER_DEBUG=layer shows the loader inserting it in every test process, and neither log has was not found but was requested by env var VK_INSTANCE_LAYERS.

ctest -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, on #9317 92ebac241 and on this PR's head 5844ac98e, Windows 10 22H2, on NVIDIA RTX 3080 (617.42) and AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002):

  • 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_replay and agc_driver_stencil_replay_no_gpl pass on both GPUs, on both trees; agc_driver_stencil_ref_export passes on the Radeon and skips on the RTX 3080 (no VK_EXT_shader_stencil_export).
  • No VUID- line in any of the four logs, so the change adds no validation errors.

AI-assisted: yes (Claude Code).

…icate in stencil replay

An EXEC- or VCC-skipped optional body is accepted when every merge phi's
value from the body equals the skipped value on lanes inactive in the
body. A body value that implies the skip predicate is false on every
inactive lane, so it equals the skipped value when that value is the
predicate itself. inactiveEquals now accepts that case, which covers a
lane's own bit of a ballot of the predicate merged with the predicate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TheSovietWaffle
TheSovietWaffle force-pushed the fix/recompiler-stencil-replay-implied-merge branch from 5844ac9 to bf0589e Compare October 26, 2026 16:34
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 26, 2026
@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 26, 2026 17:02

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit f95acfc into boykopovar:main Oct 26, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the inactiveEquals change: a Bool body value that implies the skip predicate is false on every lane inactive in the body, and so is the predicate it is merged with, so the two agree there. The guard (Bool, predicate identity, GuardImplies) is narrow. The own-bit-of-Ballot(P) case fails without the change and the !P case is refused. The validation-layer run reports no VUIDs; #9317 is on main and the rebase is clean; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants