fix(recompiler): exempt proven control conditions and own-bit ballots in stencil replay #9317

Merged
akkadbakkad89 merged 3 commits from upstream-pr/9317 into main 2026-10-26 13:27:38 +00:00
akkadbakkad89 commented 2026-10-21 18:16:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-21T18:16:17Z.


What

MaskReplaySafety walks downstream uses of mask-derived values and rejects any consumer that can observe the whole quad. On the stencil-replay shaders of Assassin's Creed Shadows (PPSA20397, #8514) and Onimusha (#7006) that accounting rejects three lane-local patterns:

  • Condition uses of branches control() already proves replay-safe. A value merged by a region phi and reused as the predicate of a nested execz guard was refused even though that very branch passed its own control validation.
  • Every Ballot, regardless of how its bits are read — including the compiler's own-lane funnel (CompositeExtractU32x4 per word -> optional lane-local &mask -> SelectU32(lane<32, low, high) -> ShiftRight(., lane&31) -> &1), which reads only the lane's own bit and never crosses lane boundaries.
  • Explicit-LOD samples. ImageSampleExplicitLod and raw sample/gather ops whose memory flags carry an explicit LOD do not compute implicit quad derivatives, so per-lane arguments stay lane-local — the same distinction MaskedSelectEliminator's isExplicitLodSample already makes.

The check now:

  • Runs conditional branches through a memoized controlProven() (with a visiting set, so nested execz cascades recurse safely) and exempts a condition use in quadObserved only when the consuming branch is proven — an unproven branch still rejects.
  • Exempts a Ballot only when every use completes the verified own-bit funnel above (correct half extraction, correct select arm, lane&31 shift, &1 isolate); the isolated per-lane bools continue through the normal traversal. Any other use rejects.
  • Treats explicit-LOD sampler consumers as lane-local in both quadObserved and helperObserved; implicit sampler consumers still reject.
  • Makes optionalBody()'s region set local to each invocation — nested control proofs previously unioned inner and outer regions into one set.

This is gap 2 of the three MaskReplaySafety gaps described on #7006 (the pre-pass that runs control() validation before counting condition uses and own-lane ballots as quad observations), and it clears the last verifier gate documented for PPSA20397 on #8514 (phi -> LogicalNot -> nested ExecZero, with the same merged value feeding an own-bit ballot chain).

Verified on shader 0x407325e400 captured from PPSA20397: with #9017 + #9030 + #9266 applied, StencilReplaySafe refused the mask replay at these gates; with this change agc_shader_replay --prepare on the same request emits 96,161 SPIR-V words. It then stops in SrtWalker::EvaluateRuntimeSources on an unresolved descriptor source — a runtime-capture limitation of the offline replay, not the verifier.

Tested

Windows 11, WinLibs GCC 15.2, Debug, on main 6b6c7016 with #9017, #9030 and #9266 cherry-picked under this commit.

  • agc_masked_select, five new cases: an optional-body merge may guard another optional wave body; an optional-body merge cannot guard a body with side effects; an optional-body merge cannot feed a ballot escaping the lane's own bit; an optional-body merge may feed an own-lane ballot read; an active mask may flag a sample with an explicit LOD. Reverting the source change makes the three positive cases fail while the negative ones still pass; all pre-existing cases pass unchanged.
  • agc_shader_replay --prepare on the captured 0x407325e400 request (ANYPS5_NO_SHADER_CACHE=1): passes StencilReplaySafe and prepares 96,161 SPIR-V words.
  • python3 tools/check_conventions.py --base origin/main: pass (1 pre-existing debt-length warning from #9017's entry).
  • python3 tools/pr_overlap.py --branch fix/stencil-replay-quad-observations: no same-scope overlap (#7410 touches the opcode list only, different topic).
  • Not run: GPU test matrix (host-only verifier change; no SPIR-V output changes for already-accepted shaders), the title itself.

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: #9017, #9030, #9266 — stacked; the last commit is this PR's change, earlier commits are those PRs applied for context
  • Fixes: none
  • Unblocks: PPSA20397 (#8514) — the last documented stencil-replay verifier gate; a separate SRT runtime-source failure remains at capture time
  • GPUs tested: n/a — verifier-only change validated through the host test suite and the offline shader replay tool (prepared: 96161 SPIR-V words); Windows 11
  • AI-assisted: yes

Generated with Devin

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4956272718 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-21T18:16:17Z. --- ### What `MaskReplaySafety` walks downstream uses of mask-derived values and rejects any consumer that can observe the whole quad. On the stencil-replay shaders of Assassin's Creed Shadows (PPSA20397, #8514) and Onimusha (#7006) that accounting rejects three lane-local patterns: - **Condition uses of branches `control()` already proves replay-safe.** A value merged by a region phi and reused as the predicate of a nested `execz` guard was refused even though that very branch passed its own control validation. - **Every `Ballot`, regardless of how its bits are read** — including the compiler's own-lane funnel (`CompositeExtractU32x4` per word -> optional lane-local `&mask` -> `SelectU32(lane<32, low, high)` -> `ShiftRight(., lane&31)` -> `&1`), which reads only the lane's own bit and never crosses lane boundaries. - **Explicit-LOD samples.** `ImageSampleExplicitLod` and raw sample/gather ops whose memory flags carry an explicit LOD do not compute implicit quad derivatives, so per-lane arguments stay lane-local — the same distinction `MaskedSelectEliminator`'s `isExplicitLodSample` already makes. The check now: - Runs conditional branches through a memoized `controlProven()` (with a visiting set, so nested `execz` cascades recurse safely) and exempts a condition use in `quadObserved` only when the consuming branch is proven — an unproven branch still rejects. - Exempts a `Ballot` only when *every* use completes the verified own-bit funnel above (correct half extraction, correct select arm, `lane&31` shift, `&1` isolate); the isolated per-lane bools continue through the normal traversal. Any other use rejects. - Treats explicit-LOD sampler consumers as lane-local in both `quadObserved` and `helperObserved`; implicit sampler consumers still reject. - Makes `optionalBody()`'s region set local to each invocation — nested control proofs previously unioned inner and outer regions into one set. This is gap 2 of the three `MaskReplaySafety` gaps described on #7006 (the pre-pass that runs `control()` validation before counting condition uses and own-lane ballots as quad observations), and it clears the last verifier gate documented for PPSA20397 on #8514 (phi -> `LogicalNot` -> nested `ExecZero`, with the same merged value feeding an own-bit ballot chain). Verified on shader `0x407325e400` captured from PPSA20397: with #9017 + #9030 + #9266 applied, `StencilReplaySafe` refused the mask replay at these gates; with this change `agc_shader_replay --prepare` on the same request emits 96,161 SPIR-V words. It then stops in `SrtWalker::EvaluateRuntimeSources` on an unresolved descriptor source — a runtime-capture limitation of the offline replay, not the verifier. ### Tested Windows 11, WinLibs GCC 15.2, Debug, on main `6b6c7016` with #9017, #9030 and #9266 cherry-picked under this commit. - `agc_masked_select`, five new cases: an optional-body merge may guard another optional wave body; an optional-body merge cannot guard a body with side effects; an optional-body merge cannot feed a ballot escaping the lane's own bit; an optional-body merge may feed an own-lane ballot read; an active mask may flag a sample with an explicit LOD. Reverting the source change makes the three positive cases fail while the negative ones still pass; all pre-existing cases pass unchanged. - `agc_shader_replay --prepare` on the captured `0x407325e400` request (`ANYPS5_NO_SHADER_CACHE=1`): passes `StencilReplaySafe` and prepares 96,161 SPIR-V words. - `python3 tools/check_conventions.py --base origin/main`: pass (1 pre-existing debt-length warning from #9017's entry). - `python3 tools/pr_overlap.py --branch fix/stencil-replay-quad-observations`: no same-scope overlap (#7410 touches the opcode list only, different topic). - Not run: GPU test matrix (host-only verifier change; no SPIR-V output changes for already-accepted shaders), the title itself. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #9017, #9030, #9266 — stacked; the last commit is this PR's change, earlier commits are those PRs applied for context - [x] Fixes: none - [x] Unblocks: PPSA20397 (#8514) — the last documented stencil-replay verifier gate; a separate SRT runtime-source failure remains at capture time - [x] GPUs tested: n/a — verifier-only change validated through the host test suite and the offline shader replay tool (`prepared: 96161 SPIR-V words`); Windows 11 - [x] AI-assisted: yes Generated with [Devin](https://devin.ai)
xXPBSXx commented 2026-10-21 20:41:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T20:41:22Z.


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: 5e91c441c4d86581d7d7e5bae820ba36d54591b5.

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 (6b6c701636), 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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6326086304 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6326086304). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T20:41:22Z. --- 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:** `5e91c441c4d86581d7d7e5bae820ba36d54591b5`. **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 (`6b6c701636`), 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).
oneandonlydean commented 2026-10-22 05:36:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T05:36:06Z.


@akkadbakkad89 thanks for #9317. On our own logged request (PPSA28183, the program that reached 0x407a788000 in our runs), main + #9017 + #9030 + #9266 + #9317 now replays end to end: prepared: 96941 SPIR-V words, and spirv-val passes. Without #9317 it still stops at quadObserved. The exemptions read right to me: each one is either lane-local or tied to the branch's own control() proof. CI is green apart from one known flaky test, which is rerunning. Next we'll run the title on that stack.

One thing for when you rebase: on top of #9030's current head (9229bcec52), #9317 conflicts in StencilReplay.cpp. #9030 makes region a member, and #9317 uses a local set. In our local merge, keeping the member broke the result, because optionalBody -> quadObserved -> control -> optionalBody re-enters, and the inner proof overwrote the outer proof's region. Keeping #9317's per-call local fixed it. Could you rebase #9317 onto #9030 with the local kept?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333589267 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6333589267). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-22T05:36:06Z. --- @akkadbakkad89 thanks for #9317. On our own logged request (PPSA28183, the program that reached `0x407a788000` in our runs), main + #9017 + #9030 + #9266 + #9317 now replays end to end: `prepared: 96941 SPIR-V words`, and spirv-val passes. Without #9317 it still stops at `quadObserved`. The exemptions read right to me: each one is either lane-local or tied to the branch's own `control()` proof. CI is green apart from one known flaky test, which is rerunning. Next we'll run the title on that stack. One thing for when you rebase: on top of #9030's current head (9229bcec52), #9317 conflicts in `StencilReplay.cpp`. #9030 makes `region` a member, and #9317 uses a local set. In our local merge, keeping the member broke the result, because `optionalBody -> quadObserved -> control -> optionalBody` re-enters, and the inner proof overwrote the outer proof's region. Keeping #9317's per-call local fixed it. Could you rebase #9317 onto #9030 with the local kept?
akkadbakkad89 commented 2026-10-22 06:42:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-22T06:42:27Z.


@oneandonlydean great data — second title clearing the verifier end to end, and spirv-val on top, is exactly what the stack needed.

On the conflict: this PR's head 5e91c441 already resolves it the way you landed on — it sits on #9030's head 9229bcec52 and turns region back into a per-call local inside optionalBody (the member is removed entirely, and inactiveEquals takes the local by const-ref so nested control() proofs can't bleed regions). So the resolution is "take this PR's version"; no rebase needed unless #9030 moves. The re-entrancy you hit — optionalBody → quadObserved → control → optionalBody — is precisely what forced the local on our side too: with the member, the inner walk's insert mutates the outer region and the outer predecessor check then rejects blocks it just added itself.

Thanks for running the title as well — that's the piece neither of us could validate (we only have the offline request for PPSA20397, which passes --prepare but stops later in SrtWalker::EvaluateRuntimeSources, a descriptor-materialization limitation of the harness, not the verifier).

AI-assisted: yes (Devin).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6334531273 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6334531273). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-22T06:42:27Z. --- @oneandonlydean great data — second title clearing the verifier end to end, and spirv-val on top, is exactly what the stack needed. On the conflict: this PR's head `5e91c441` already resolves it the way you landed on — it sits on #9030's head `9229bcec52` and turns `region` back into a per-call local inside `optionalBody` (the member is removed entirely, and `inactiveEquals` takes the local by const-ref so nested `control()` proofs can't bleed regions). So the resolution is "take this PR's version"; no rebase needed unless #9030 moves. The re-entrancy you hit — `optionalBody → quadObserved → control → optionalBody` — is precisely what forced the local on our side too: with the member, the inner walk's `insert` mutates the outer region and the outer predecessor check then rejects blocks it just added itself. Thanks for running the title as well — that's the piece neither of us could validate (we only have the offline request for PPSA20397, which passes `--prepare` but stops later in `SrtWalker::EvaluateRuntimeSources`, a descriptor-materialization limitation of the harness, not the verifier). AI-assisted: yes (Devin).
oneandonlydean commented 2026-10-22 07:17:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T07:17:02Z.


@akkadbakkad89 thanks, that matches what we found. One detail on the base: GitHub's compare shows 5e91c441c4 isn't on top of #9030's current head. 9229bcec52 ("accept optional wave bodies of several blocks in stencil replay", which touches StencilReplay.cpp and MaskedSelect.cpp) is not in this branch's history; it's 1 commit behind it, and the same holds for #9266's head 9b578d5dc7. So #9030 seems to have been amended after you based #9317 on it, and that's where our textual conflict came from. A rebase onto 9229bcec52, with the per-call local kept as you describe, would let the stack merge in order. Our title run on the locally resolved stack is queued for later today.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335075330 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6335075330). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-22T07:17:02Z. --- @akkadbakkad89 thanks, that matches what we found. One detail on the base: GitHub's compare shows `5e91c441c4` isn't on top of #9030's current head. `9229bcec52` ("accept optional wave bodies of several blocks in stencil replay", which touches `StencilReplay.cpp` and `MaskedSelect.cpp`) is not in this branch's history; it's 1 commit behind it, and the same holds for #9266's head `9b578d5dc7`. So #9030 seems to have been amended after you based #9317 on it, and that's where our textual conflict came from. A rebase onto `9229bcec52`, with the per-call local kept as you describe, would let the stack merge in order. Our title run on the locally resolved stack is queued for later today.
akkadbakkad89 commented 2026-10-22 07:26:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-22T07:26:31Z.


@oneandonlydean rebased — head is now 92ebac24, a clean four-commit chain on main d6eafa54 carrying each PR's current head diff in order (#9017 027033f1 → #9030 9229bcec → #9266 9b578d5d → this change), so the stack merges in order. Each commit's diff is identical to its published head (verified file-for-file; #9017's debt entry lands at a different position because the file moved upstream, same added text).

region stays a per-call local — optionalBody's member is removed and inactiveEquals takes the local by const-ref, exactly the resolution your merge needed.

Re-verified on the new head: agc_masked_select passes, and agc_shader_replay --prepare on the PPSA20397 request still reaches prepared: 96161 SPIR-V words.

AI-assisted: yes (Devin).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335229528 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6335229528). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-22T07:26:31Z. --- @oneandonlydean rebased — head is now `92ebac24`, a clean four-commit chain on `main` `d6eafa54` carrying each PR's current head diff in order (#9017 `027033f1` → #9030 `9229bcec` → #9266 `9b578d5d` → this change), so the stack merges in order. Each commit's diff is identical to its published head (verified file-for-file; #9017's debt entry lands at a different position because the file moved upstream, same added text). `region` stays a per-call local — `optionalBody`'s member is removed and `inactiveEquals` takes the local by const-ref, exactly the resolution your merge needed. Re-verified on the new head: `agc_masked_select` passes, and `agc_shader_replay --prepare` on the PPSA20397 request still reaches `prepared: 96161 SPIR-V words`. AI-assisted: yes (Devin).
oneandonlydean commented 2026-10-22 08:00:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T08:00:52Z.


Thanks for the rebase. I checked 92ebac2 against the three PRs it carries: each carried commit matches the published diff of #9017, #9030 and #9266, and your own commit is unchanged from the version I reviewed. Full CI on this head is green on Linux and Windows (agc_masked_select passes on both).

One thing for the merge order. Because the carried commits are re-created copies, git doesn't treat them as the same commits as the originals. Merging the originals first and then this PR conflicts (MaskedSelect.cpp, StencilReplay.cpp). I see two ways to land it, and both give the same final tree:

  1. In order: merge #9017, then #9030. Then #9266 rebases onto main, and this PR rebases down to its own commit only. That means two more rebases and CI runs.
  2. This PR alone: merge #9317 as it is (it merges cleanly now), and #9017, #9030 and #9266 are closed as superseded.

@TheSovietWaffle (#9017, #9030) and @akkadbakkad89 (#9266, #9317): which do you prefer? Option 2 is quicker, but it's your call, since it closes your PRs. The carried commits keep their original authors either way.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335814359 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6335814359). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-22T08:00:52Z. --- Thanks for the rebase. I checked 92ebac2 against the three PRs it carries: each carried commit matches the published diff of #9017, #9030 and #9266, and your own commit is unchanged from the version I reviewed. Full CI on this head is green on Linux and Windows (agc_masked_select passes on both). One thing for the merge order. Because the carried commits are re-created copies, git doesn't treat them as the same commits as the originals. Merging the originals first and then this PR conflicts (MaskedSelect.cpp, StencilReplay.cpp). I see two ways to land it, and both give the same final tree: 1. In order: merge #9017, then #9030. Then #9266 rebases onto main, and this PR rebases down to its own commit only. That means two more rebases and CI runs. 2. This PR alone: merge #9317 as it is (it merges cleanly now), and #9017, #9030 and #9266 are closed as superseded. @TheSovietWaffle (#9017, #9030) and @akkadbakkad89 (#9266, #9317): which do you prefer? Option 2 is quicker, but it's your call, since it closes your PRs. The carried commits keep their original authors either way.
akkadbakkad89 commented 2026-10-22 08:10:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-22T08:10:57Z.


@oneandonlydean @TheSovietWaffle — option 2 gets my vote for #9266 + #9317.

The final tree is identical either way, this repo merges with merge commits so each carried commit keeps its author in history, and what lands is byte-for-byte the stack that already replayed both titles end to end. It also saves two more rebase+CI cycles and removes the intermediate states where the verifier still rejects real shaders.

Two things worth being explicit about:

  • It's all-or-nothing: this branch literally contains the other commits, so there is no "merge #9317, keep #9017 open" middle path. If #9017 or #9030 still needs review changes, option 1 is the only way to take them.
  • The choice that binds it is yours, @TheSovietWaffle — option 2 closes your two PRs as superseded even though your commits land unchanged, so if you'd rather see them merge individually that outweighs the speed argument on our side.

From us: fine to close #9266 as superseded whenever the stack goes in.

AI-assisted: yes (Devin).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335996341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6335996341). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-22T08:10:57Z. --- @oneandonlydean @TheSovietWaffle — option 2 gets my vote for #9266 + #9317. The final tree is identical either way, this repo merges with merge commits so each carried commit keeps its author in history, and what lands is byte-for-byte the stack that already replayed both titles end to end. It also saves two more rebase+CI cycles and removes the intermediate states where the verifier still rejects real shaders. Two things worth being explicit about: - It's all-or-nothing: this branch literally contains the other commits, so there is no "merge #9317, keep #9017 open" middle path. If #9017 or #9030 still needs review changes, option 1 is the only way to take them. - The choice that binds it is yours, @TheSovietWaffle — option 2 closes your two PRs as superseded even though your commits land unchanged, so if you'd rather see them merge individually that outweighs the speed argument on our side. From us: fine to close #9266 as superseded whenever the stack goes in. AI-assisted: yes (Devin).
TheSovietWaffle commented 2026-10-22 09:10:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-22T09:10:49Z.


@akkadbakkad89 data point for PPSA27836 (Onimusha: Way of the Sword) on this branch (92ebac241) + #8145, checked offline with PrepareResourceProgram + StencilReplaySafe on the logged request shader_2111c51800:

  • Masks: all own-lane masks pass (#9266 covers this shader's split whole-quad halves).
  • It then refuses at block 0's optional body: the merge phi of the shader's "lane is done" flag is quadObserved, through a Ballot that is not only read as an own bit. It is Ballot(ownLane(liveWords) && !killed), and its two words also feed an any-active early-exit gate ((lo | hi) != 0) and the merge phis of the export mask after the kill. So the own-bit funnel doesn't apply.

That ballot's argument is false on every helper lane regardless of the merged value: liveWords is Ballot(!helper) & WQM(active), so onHelper(argument) == 0. Would you accept exempting a ballot in quadObserved when it is restricted (its masks already pass maskStable/helpers) and onHelper proves its argument false on helper lanes? Then helper lanes can't contribute to any of its words, whatever the phi holds there. Locally that is one line before your funnel check:

if (opcode == IrOpcode::Ballot && restricted.contains(use.user) && use.user->ArgumentCount() == 1u && onHelper(use.user->Argument(0), 0u) == std::optional<std::uint32_t>{0u}) continue;

With that, #9393's inactiveEquals rule, and one more change for an early exit inside the optional body (a discard's "no live lanes left" return; I'll open it on top of this stack), the request passes StencilReplaySafe. Without #9393's rule it still refuses (the merged flag is an own bit of Ballot(P) merged with P).

Since #9317 already covers what #9394 does in a stricter way, I'll close #9394 and rebase #9393 onto this PR (Depends on: #9317).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337095573 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6337095573). Originally posted by [TheSovietWaffle](https://github.com/TheSovietWaffle) on 2026-10-22T09:10:49Z. --- @akkadbakkad89 data point for PPSA27836 (Onimusha: Way of the Sword) on this branch (`92ebac241`) + #8145, checked offline with `PrepareResourceProgram` + `StencilReplaySafe` on the logged request `shader_2111c51800`: - Masks: all own-lane masks pass (#9266 covers this shader's split whole-quad halves). - It then refuses at block 0's optional body: the merge phi of the shader's "lane is done" flag is `quadObserved`, through a `Ballot` that is not only read as an own bit. It is `Ballot(ownLane(liveWords) && !killed)`, and its two words also feed an any-active early-exit gate (`(lo | hi) != 0`) and the merge phis of the export mask after the kill. So the own-bit funnel doesn't apply. That ballot's argument is false on every helper lane regardless of the merged value: `liveWords` is `Ballot(!helper) & WQM(active)`, so `onHelper(argument) == 0`. Would you accept exempting a ballot in `quadObserved` when it is restricted (its masks already pass `maskStable`/`helpers`) and `onHelper` proves its argument false on helper lanes? Then helper lanes can't contribute to any of its words, whatever the phi holds there. Locally that is one line before your funnel check: ```cpp if (opcode == IrOpcode::Ballot && restricted.contains(use.user) && use.user->ArgumentCount() == 1u && onHelper(use.user->Argument(0), 0u) == std::optional<std::uint32_t>{0u}) continue; ``` With that, #9393's `inactiveEquals` rule, and one more change for an early exit inside the optional body (a discard's "no live lanes left" return; I'll open it on top of this stack), the request passes `StencilReplaySafe`. Without #9393's rule it still refuses (the merged flag is an own bit of `Ballot(P)` merged with `P`). Since #9317 already covers what #9394 does in a stricter way, I'll close #9394 and rebase #9393 onto this PR (`Depends on: #9317`). AI-assisted: yes (Claude Code).
akkadbakkad89 commented 2026-10-22 09:17:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-22T09:17:41Z.


@TheSovietWaffle yes — accept, and the rule is the clean dual of the funnel: we bound consumption (only the own bit is ever read), this bounds contribution (the argument is provably false on helpers, so helper lanes contribute 0 to every word whatever the merged phi holds there). With onHelper(arg) == 0 the ballot's words are a pure function of real-lane arguments, so their consumers — early-exit gates, export phis — can't observe anything about the helper instance. The guards are also right: restricted.contains scopes it to ballots already proven inside a stable mask chain, and the onHelper answer here resolves through own()/RealOnly rather than the phi itself, which is exactly the independence the exemption needs. Skipping the walk through the ballot is safe for the same reason — nothing downstream of those words carries helper information.

On placement: head 92ebac24 is the verified merge candidate while the option-2 vote is open (oneandonlydean checked it byte-for-byte against the carried heads), so we'd rather not move it — the line lands cleanly as your own commit in your stack (#9393 or a small PR, Depends on: #9317), which also keeps the authorship and the onHelper-duality review with you. If you'd rather consolidate the quadObserved exemptions in #9317, say so and we'll take it in with you as author — either way the code lands.

Also good news on the stack shape: #9393 rebasing onto this PR and #9394 closing as covered fits — the merged-flag case you describe (own bit of Ballot(P) merged with P) is exactly the stricter inactiveEquals direction.

AI-assisted: yes (Devin).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6337233552 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9317#issuecomment-6337233552). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-22T09:17:41Z. --- @TheSovietWaffle yes — accept, and the rule is the clean dual of the funnel: we bound *consumption* (only the own bit is ever read), this bounds *contribution* (the argument is provably false on helpers, so helper lanes contribute 0 to every word whatever the merged phi holds there). With `onHelper(arg) == 0` the ballot's words are a pure function of real-lane arguments, so their consumers — early-exit gates, export phis — can't observe anything about the helper instance. The guards are also right: `restricted.contains` scopes it to ballots already proven inside a stable mask chain, and the `onHelper` answer here resolves through `own()`/`RealOnly` rather than the phi itself, which is exactly the independence the exemption needs. Skipping the walk through the ballot is safe for the same reason — nothing downstream of those words carries helper information. On placement: head `92ebac24` is the verified merge candidate while the option-2 vote is open (oneandonlydean checked it byte-for-byte against the carried heads), so we'd rather not move it — the line lands cleanly as your own commit in your stack (#9393 or a small PR, `Depends on: #9317`), which also keeps the authorship and the onHelper-duality review with you. If you'd rather consolidate the quadObserved exemptions in #9317, say so and we'll take it in with you as author — either way the code lands. Also good news on the stack shape: #9393 rebasing onto this PR and #9394 closing as covered fits — the merged-flag case you describe (own bit of `Ballot(P)` merged with `P`) is exactly the stricter `inactiveEquals` direction. AI-assisted: yes (Devin).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9317
No description provided.