fix(shader): prove masked lanes unread for every select in one backward pass #4331

Merged
oneandonlydean merged 1 commit from upstream-pr/4331 into main 2026-10-12 14:07:17 +00:00
oneandonlydean commented 2026-10-12 06:43:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T06:43:18Z.


What

Refs #3504. That regression came in with #3279, which I carried, so this is the fix for it. I do not have Stray's requests: @ThatsLeo, could you time 0x200f780000 and 0x200f7a0000 on this branch, and check that 0x2013010000 and the rest of your 43 still compile?

MaskedSelectEliminator walked forward from every select to see whether the lanes its mask excludes are read. Since fda4aa90 (bisected by @ThatsLeo) the walks pass explicit-LOD gathers, size queries and guarded image writes, so most of them cover the rest of the program. The cost is selects times program size.

The pass now computes the answer for all selects at once. For every value it keeps the set of masks under which the value is unread, built from its uses backwards:

  • a use guarded by a condition (a select's active operand, the other side of a LogicalAnd, an access with a trailing exec) contributes the masks that condition implies;
  • a lane-local use, a phi or an explicit-LOD sample adds the set of its own result;
  • any other use contributes nothing.

A select is dropped when its mask is in its own set. Values and conditions that depend on themselves through loop phis are solved per strongly connected component, starting from "every mask". Selects are settled users first, so a dropped select is already gone when the values it read are settled, as in the walk's reverse sweep.

The rules are the walk's: the same guarded uses, lane-local list, phi and loop conditions, ballot and mask-word forms, whole quad masks (#3391), and the selected execs, rebuilt mask words and guarded first-lane reads of #3739. A first-lane read passes the masks its read mask implies when its own result is unread outside that read mask; that is solved once per read, in the same way, with #3739's same-block rule for a loop-local read mask. Three things are gone: the step limit per walk, the 64-level depth of the implication check and the nesting depth of first-lane proofs. A select that the walk kept only because it ran into one of them is now dropped, which includes a first-lane read whose result only reaches itself around a loop. One case is refused instead of counted: a first-lane proof that needs a read mask of a kind (loop-local or not, whole-quad or not) that is already being solved. It is not a budget: no select is kept for lack of time.

Measured on a synthetic pixel shader of the reported shape (each unit compares, selects, gathers with LOD zero and writes a register under the exec; one image write at the end), Release, same machine:

Instructions main 7a84b222 This branch
4,007 0.05 s, 2.6 M values visited 0.001 s
32,007 4.0 s, 168 M 0.010 s
128,007 173.8 s, 2,688 M visited, 384 M implications 0.16 s

The visit and implication counts on main come from counters added locally. Both trees drop the same 16,000 selects in the last row.

Relation to #3550 and #4031: #3550 keeps the walk and stops proving when a per-shader budget is spent, so the selects it keeps depend on the multiple (1,602 of 9,232 dropped at 32x on 0x200f780000, and 0x2013010000 refused below 128x, per @ThatsLeo's tables in #3504). With this change there is no budget to pick, and #3550 should not be needed for #3504; if it goes in anyway it conflicts with this one. #4031 is independent: it is still needed for selects that no proof can drop (Palworld's 0x1b40e5c000, Minecraft Dungeons II), but not to make a budget safe.

Cost: the sets are explicit, so memory grows with values times the masks their guards imply. A chain of 8,000 nested kills takes 0.09 s and about 150 MB here (3.4 s on main).

Tested

Linux (CachyOS, GCC 16.2.1, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON), RTX 4090 (NVIDIA 610.57.04). The commit was rebased over #3739 and carries its three rules, so everything in the first list was run again.

On main 8c4a295f plus this commit:

  • ctest -R "agc|shader": 442 of 442 pass. agc_masked_select passes with every case from #3279, #3391 and #3739 unchanged. Three cases are new: an exec narrowed by 300 kills still drops the select, 300 kills rooted at a wider exec keep it, and a program of 4,000 units costs at most 9 times the steps of one of 500 units (it is 8 times). With MaskedSelectEliminator.cpp from main, the 300-kill case keeps the select (depth limit) and the step case fails; that file takes 4.4 s for the test on main against 0.03 s here.
  • tools/check_conventions.py --base origin/main passes.

On main 436e310d with and without this commit (nothing under core/shader changed between 436e310d and 8c4a295f):

  • 143 dumped recompile requests from two other titles replayed with agc_shader_replay --spv: every module is byte-identical to main (30,722,012 words), in 277 s against 282 s. These are the ones of my 163 that compile on this main; 7 more stop at the clip check of 9db923e9 on both trees. At least one of the 143 has first-lane reads.
  • 300,000 random programs (diamonds, nested loops, exec and mask-word phis, ballots, whole quad masks, selected execs, rebuilt mask words, first-lane reads, both wave sizes, guarded and unguarded accesses, samples and gathers) compared with main's walk with its limits lifted and a first-lane read that only reaches itself around a loop taken as unread: the programs after the pass are identical in all of them. 10 deliberate errors in the three rules from #3739 (the wrong arm of a selected exec, mask words matched on the low word only, a first-lane result taken as always unread, and so on) are each caught by the same comparison within 40,000 programs. The harness is not part of the commit.
  • A 2D title we test with, one scripted run on main and two with this commit (menu, new game, two rooms; 220 s): all 7 visual checkpoints pass on all three, 36.5, 33.8 and 39.1 fps in the menu, 37.7, 29.2 and 40.6 in gameplay (frames dumped on the CPU; other work was running on the machine during the slow one), no error line, no skipped draw, no Xid. Each run started with an empty shader cache and compiled 107 modules (3,251,533 words): the same 107 keys, every module byte-identical.

Before the rebase, with the commit as it was without #3739's rules:

  • Full ctest on main d0ca839c with and without it (configured as CI does): 921 pass and 4 skip (video_out_flip_*) of 925 on both, no failure.
  • A 3D title we test with, on the local tree it boots on (main a11c8f7f with #3391, #425, #454, #290, #2490, #2491 and five local changes), with and without it, scripted to the title, the menu and the first level: 28.4 and 28.2 fps at the title, 27.8 and 26.3 in the menu, 26.5 and 25.4 in the level with a warm cache, the same frames by eye, the same checkpoint scores, no error line, no Xid. With an empty shader cache both compile 1,925 modules (280,313,141 words) with the same keys; 1,607 are byte-identical and the other 318 differ only in one 64-bit constant that holds a host address and differs the same way between two runs of one tree. The title scene starts 50 to 57 s after launch with it and 54 to 87 s without (two cold runs each, other work on the machine in three of them), 43 to 45 s on both with a warm cache; the first level loads in 26 to 30 s on both. No start-up difference shows on this title beyond the spread between runs.

Not tested: Stray itself and its requests (see above), Windows, AMD and Intel; the full ctest and the 3D title on the rebased commit.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4825862723 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4331). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T06:43:18Z. --- ### What Refs #3504. That regression came in with #3279, which I carried, so this is the fix for it. I do not have Stray's requests: @ThatsLeo, could you time `0x200f780000` and `0x200f7a0000` on this branch, and check that `0x2013010000` and the rest of your 43 still compile? `MaskedSelectEliminator` walked forward from every select to see whether the lanes its mask excludes are read. Since `fda4aa90` (bisected by @ThatsLeo) the walks pass explicit-LOD gathers, size queries and guarded image writes, so most of them cover the rest of the program. The cost is selects times program size. The pass now computes the answer for all selects at once. For every value it keeps the set of masks under which the value is unread, built from its uses backwards: - a use guarded by a condition (a select's active operand, the other side of a `LogicalAnd`, an access with a trailing exec) contributes the masks that condition implies; - a lane-local use, a phi or an explicit-LOD sample adds the set of its own result; - any other use contributes nothing. A select is dropped when its mask is in its own set. Values and conditions that depend on themselves through loop phis are solved per strongly connected component, starting from "every mask". Selects are settled users first, so a dropped select is already gone when the values it read are settled, as in the walk's reverse sweep. The rules are the walk's: the same guarded uses, lane-local list, phi and loop conditions, ballot and mask-word forms, whole quad masks (#3391), and the selected execs, rebuilt mask words and guarded first-lane reads of #3739. A first-lane read passes the masks its read mask implies when its own result is unread outside that read mask; that is solved once per read, in the same way, with #3739's same-block rule for a loop-local read mask. Three things are gone: the step limit per walk, the 64-level depth of the implication check and the nesting depth of first-lane proofs. A select that the walk kept only because it ran into one of them is now dropped, which includes a first-lane read whose result only reaches itself around a loop. One case is refused instead of counted: a first-lane proof that needs a read mask of a kind (loop-local or not, whole-quad or not) that is already being solved. It is not a budget: no select is kept for lack of time. Measured on a synthetic pixel shader of the reported shape (each unit compares, selects, gathers with LOD zero and writes a register under the exec; one image write at the end), Release, same machine: | Instructions | `main` 7a84b222 | This branch | |---|---|---| | 4,007 | 0.05 s, 2.6 M values visited | 0.001 s | | 32,007 | 4.0 s, 168 M | 0.010 s | | 128,007 | 173.8 s, 2,688 M visited, 384 M implications | 0.16 s | The visit and implication counts on `main` come from counters added locally. Both trees drop the same 16,000 selects in the last row. Relation to #3550 and #4031: #3550 keeps the walk and stops proving when a per-shader budget is spent, so the selects it keeps depend on the multiple (1,602 of 9,232 dropped at 32x on `0x200f780000`, and `0x2013010000` refused below 128x, per @ThatsLeo's tables in #3504). With this change there is no budget to pick, and #3550 should not be needed for #3504; if it goes in anyway it conflicts with this one. #4031 is independent: it is still needed for selects that no proof can drop (Palworld's `0x1b40e5c000`, Minecraft Dungeons II), but not to make a budget safe. Cost: the sets are explicit, so memory grows with values times the masks their guards imply. A chain of 8,000 nested kills takes 0.09 s and about 150 MB here (3.4 s on `main`). ### Tested Linux (CachyOS, GCC 16.2.1, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`), RTX 4090 (NVIDIA 610.57.04). The commit was rebased over #3739 and carries its three rules, so everything in the first list was run again. On `main` 8c4a295f plus this commit: - `ctest -R "agc|shader"`: 442 of 442 pass. `agc_masked_select` passes with every case from #3279, #3391 and #3739 unchanged. Three cases are new: an exec narrowed by 300 kills still drops the select, 300 kills rooted at a wider exec keep it, and a program of 4,000 units costs at most 9 times the steps of one of 500 units (it is 8 times). With `MaskedSelectEliminator.cpp` from `main`, the 300-kill case keeps the select (depth limit) and the step case fails; that file takes 4.4 s for the test on `main` against 0.03 s here. - `tools/check_conventions.py --base origin/main` passes. On `main` 436e310d with and without this commit (nothing under `core/shader` changed between 436e310d and 8c4a295f): - 143 dumped recompile requests from two other titles replayed with `agc_shader_replay --spv`: every module is byte-identical to `main` (30,722,012 words), in 277 s against 282 s. These are the ones of my 163 that compile on this `main`; 7 more stop at the clip check of 9db923e9 on both trees. At least one of the 143 has first-lane reads. - 300,000 random programs (diamonds, nested loops, exec and mask-word phis, ballots, whole quad masks, selected execs, rebuilt mask words, first-lane reads, both wave sizes, guarded and unguarded accesses, samples and gathers) compared with `main`'s walk with its limits lifted and a first-lane read that only reaches itself around a loop taken as unread: the programs after the pass are identical in all of them. 10 deliberate errors in the three rules from #3739 (the wrong arm of a selected exec, mask words matched on the low word only, a first-lane result taken as always unread, and so on) are each caught by the same comparison within 40,000 programs. The harness is not part of the commit. - A 2D title we test with, one scripted run on `main` and two with this commit (menu, new game, two rooms; 220 s): all 7 visual checkpoints pass on all three, 36.5, 33.8 and 39.1 fps in the menu, 37.7, 29.2 and 40.6 in gameplay (frames dumped on the CPU; other work was running on the machine during the slow one), no error line, no skipped draw, no Xid. Each run started with an empty shader cache and compiled 107 modules (3,251,533 words): the same 107 keys, every module byte-identical. Before the rebase, with the commit as it was without #3739's rules: - Full `ctest` on `main` d0ca839c with and without it (configured as CI does): 921 pass and 4 skip (`video_out_flip_*`) of 925 on both, no failure. - A 3D title we test with, on the local tree it boots on (`main` a11c8f7f with #3391, #425, #454, #290, #2490, #2491 and five local changes), with and without it, scripted to the title, the menu and the first level: 28.4 and 28.2 fps at the title, 27.8 and 26.3 in the menu, 26.5 and 25.4 in the level with a warm cache, the same frames by eye, the same checkpoint scores, no error line, no Xid. With an empty shader cache both compile 1,925 modules (280,313,141 words) with the same keys; 1,607 are byte-identical and the other 318 differ only in one 64-bit constant that holds a host address and differs the same way between two runs of one tree. The title scene starts 50 to 57 s after launch with it and 54 to 87 s without (two cold runs each, other work on the machine in three of them), 43 to 45 s on both with a warm cache; the first level loads in 26 to 30 s on both. No start-up difference shows on this title beyond the spread between runs. Not tested: Stray itself and its requests (see above), Windows, AMD and Intel; the full `ctest` and the 3D title on the rebased commit. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: none - [x] AI-assisted: yes (Claude Code)
ThatsLeo commented 2026-10-12 08:11:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-12T08:11:15Z.


@oneandonlydean measured on this PR's head dbad071a against main 436e310d, with offline replays of Stray's (PPSA02101 v01.002) requests on an Intel Core Ultra (Meteor Lake), Release:

Shader main This PR
0x200f780000 205 s 0.9 s (110 MB peak)
0x200f7a0000 458 s 1.7 s (173 MB peak)
0x2013010000 0.8 s, compiles 0.2 s, compiles

The two main timings ran side by side, so they are a little higher than my earlier single runs (141 s and 385 s on 8ec0e131).

  • All 43 requests compile, and every module passes spirv-val --target-env vulkan1.3. On main the 41 that finish in reasonable time also compile; the two slow ones finish too, just after the times above. The 41 together take 2 s on this PR and 3 s on main.
  • 0x2013010000 compiles without #4031. Unlike #3550 at a low multiple, nothing it needs removed is left behind.
  • Full suite on Intel Arc (Mesa 26.2.3 ANV) and lavapipe, 915 tests each. The only failure is agc_driver_prepared_shaders_registered_workgroup_sync (expected preparation failure), which fails the same way on main.

I haven't run the title with it yet. That needs a rebuilt set, and I'll add it here if it shows anything.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120327097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4331#issuecomment-6120327097). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-12T08:11:15Z. --- @oneandonlydean measured on this PR's head `dbad071a` against `main` `436e310d`, with offline replays of Stray's (PPSA02101 v01.002) requests on an Intel Core Ultra (Meteor Lake), Release: | Shader | `main` | This PR | |---|---|---| | `0x200f780000` | 205 s | 0.9 s (110 MB peak) | | `0x200f7a0000` | 458 s | 1.7 s (173 MB peak) | | `0x2013010000` | 0.8 s, compiles | 0.2 s, compiles | The two `main` timings ran side by side, so they are a little higher than my earlier single runs (141 s and 385 s on `8ec0e131`). - All 43 requests compile, and every module passes `spirv-val --target-env vulkan1.3`. On `main` the 41 that finish in reasonable time also compile; the two slow ones finish too, just after the times above. The 41 together take 2 s on this PR and 3 s on `main`. - `0x2013010000` compiles without #4031. Unlike #3550 at a low multiple, nothing it needs removed is left behind. - Full suite on Intel Arc (Mesa 26.2.3 ANV) and lavapipe, 915 tests each. The only failure is `agc_driver_prepared_shaders_registered_workgroup_sync` (`expected preparation failure`), which fails the same way on `main`. I haven't run the title with it yet. That needs a rebuilt set, and I'll add it here if it shows anything. AI-assisted: yes.
oneandonlydean commented 2026-10-12 09:04:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T09:04:59Z.


@ThatsLeo thanks, that is the number this needed. The branch is rebased onto main after #3739 (d37463e7), and it was not a mechanical rebase: #3739's three rules (selected exec, rebuilt mask words, guarded first-lane reads) are now part of the backward pass. Could you rerun the 43 requests on that head, 0x2013010000 and 0x2012f90000 in particular?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6121122576 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4331#issuecomment-6121122576). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T09:04:59Z. --- @ThatsLeo thanks, that is the number this needed. The branch is rebased onto `main` after #3739 (d37463e7), and it was not a mechanical rebase: #3739's three rules (selected exec, rebuilt mask words, guarded first-lane reads) are now part of the backward pass. Could you rerun the 43 requests on that head, `0x2013010000` and `0x2012f90000` in particular?
ThatsLeo commented 2026-10-12 09:35:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-12T09:35:08Z.


@oneandonlydean on the rebased head d37463e7, the same offline replays of Stray's (PPSA02101 v01.002) requests on Intel Core Ultra (Meteor Lake), Release:

  • All 43 requests compile, and every module passes spirv-val --target-env vulkan1.3.
  • 0x200f780000 takes 0.9 s and 0x200f7a0000 1.8 s, as before the rebase.
  • 0x2013010000: recompiled: 231752 SPIR-V words, in 0.2 s.

0x2012f90000: I can't give you that one. The request I saved was truncated, and replay rejects it with RequestSerializer: truncated data. The shader is only prepared after the brightness calibration screen. Getting there on today's main takes #425, the stencil storage commit and #1077, and #1077 no longer merges (13 files conflict). With #425 and the stencil commit on top of this PR, Stray stops earlier, with color views of several array slices are unsupported. Its shape is the one in my comment on #2548: a SelectU32 on the lane's s_wqm bit. #4033 folds that bit, and #4033 is now on main.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6121601924 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4331#issuecomment-6121601924). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-12T09:35:08Z. --- @oneandonlydean on the rebased head `d37463e7`, the same offline replays of Stray's (PPSA02101 v01.002) requests on Intel Core Ultra (Meteor Lake), Release: - All 43 requests compile, and every module passes `spirv-val --target-env vulkan1.3`. - `0x200f780000` takes 0.9 s and `0x200f7a0000` 1.8 s, as before the rebase. - `0x2013010000`: `recompiled: 231752 SPIR-V words`, in 0.2 s. `0x2012f90000`: I can't give you that one. The request I saved was truncated, and replay rejects it with `RequestSerializer: truncated data`. The shader is only prepared after the brightness calibration screen. Getting there on today's `main` takes #425, the stencil storage commit and #1077, and #1077 no longer merges (13 files conflict). With #425 and the stencil commit on top of this PR, Stray stops earlier, with `color views of several array slices are unsupported`. Its shape is the one in my comment on #2548: a `SelectU32` on the lane's `s_wqm` bit. #4033 folds that bit, and #4033 is now on `main`. AI-assisted: yes.
AlxcBTW commented 2026-10-12 09:59:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-12T09:59:46Z.


Independent soundness check of this branch with the masked-select fuzzer (agc_masked_select_fuzz): random wave programs with exec saved, narrowed, killed, revived and restored around diamonds and loops, run on a small lane interpreter before and after the pass. A select may only go if every observable effect stays the same (stores and loads under their exec, readfirstlane/readlane/ballot, branch decisions, plain uses). The fuzzer is not part of this PR. It is our local fuzzer commit (9c49eaf5c, a test-only file), which we also run against main as a long-running job.

Setup: this PR's head dbad071ac and its base 7a84b2226, each with the fuzzer commit and a local timing harness on top, Release, GCC 15.2 on Windows, CPU only. Current main conflicts with this PR in MaskedSelectEliminator.cpp (#3739), so the comparison is against the PR's own base.

Soundness, seeds 10,000,000 to 10,499,999, both wave sizes, 1,000,000 programs per tree:

programs changed by the pass selects removed skipped mismatches
this PR 1,000,000 784,881 2,108,049 0 0
base 1,000,000 784,881 2,108,109 0 0

No mismatch and no exception. The same fuzzer has run more than 19 M programs on main without a mismatch.

Same programs through both passes (240,000 programs, seeds 10,000,000 to 10,119,999): the IR after the pass is identical in all of them, and the instruction count is identical (26,390,091 on both sides). The removed counts differ in 1,325 programs (770 higher on this branch, 555 lower), with identical IR in every one of those, so that is only a difference in how the stat is counted.

Timing, CPU time on the same machine:

  • Fuzz programs (about 100 instructions each): the pass takes about 3.5 times as long on this branch (about 13.7 s here against 3.9 s on the base, per 180,000 programs). That is a few tens of microseconds more per program.
  • Synthetic pixel shader of the #3504 shape: 4,000 ops 3.1 s on the base, 0.16 s here, identical IR; 32,000 ops 25.1 s on the base, 1.2 s here.
  • At 32,000 ops the IR differs: 17,214 selects removed here against 14,276 on the base. That matches the description (selects the old walk kept only because of its step and depth limits).

Not covered: the fuzz programs are too small to reach the old step and depth limits, so the extra selects dropped beyond them are not checked by this fuzzer. Your comparison against the walk with its limits lifted is the check for those.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6121973568 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4331#issuecomment-6121973568). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-12T09:59:46Z. --- Independent soundness check of this branch with the masked-select fuzzer (`agc_masked_select_fuzz`): random wave programs with exec saved, narrowed, killed, revived and restored around diamonds and loops, run on a small lane interpreter before and after the pass. A select may only go if every observable effect stays the same (stores and loads under their exec, readfirstlane/readlane/ballot, branch decisions, plain uses). The fuzzer is not part of this PR. It is our local fuzzer commit (`9c49eaf5c`, a test-only file), which we also run against `main` as a long-running job. Setup: this PR's head `dbad071ac` and its base `7a84b2226`, each with the fuzzer commit and a local timing harness on top, Release, GCC 15.2 on Windows, CPU only. Current `main` conflicts with this PR in `MaskedSelectEliminator.cpp` (#3739), so the comparison is against the PR's own base. Soundness, seeds 10,000,000 to 10,499,999, both wave sizes, 1,000,000 programs per tree: | | programs | changed by the pass | selects removed | skipped | mismatches | |---|---|---|---|---|---| | this PR | 1,000,000 | 784,881 | 2,108,049 | 0 | 0 | | base | 1,000,000 | 784,881 | 2,108,109 | 0 | 0 | No mismatch and no exception. The same fuzzer has run more than 19 M programs on `main` without a mismatch. Same programs through both passes (240,000 programs, seeds 10,000,000 to 10,119,999): the IR after the pass is identical in all of them, and the instruction count is identical (26,390,091 on both sides). The removed counts differ in 1,325 programs (770 higher on this branch, 555 lower), with identical IR in every one of those, so that is only a difference in how the stat is counted. Timing, CPU time on the same machine: - Fuzz programs (about 100 instructions each): the pass takes about 3.5 times as long on this branch (about 13.7 s here against 3.9 s on the base, per 180,000 programs). That is a few tens of microseconds more per program. - Synthetic pixel shader of the #3504 shape: 4,000 ops 3.1 s on the base, 0.16 s here, identical IR; 32,000 ops 25.1 s on the base, 1.2 s here. - At 32,000 ops the IR differs: 17,214 selects removed here against 14,276 on the base. That matches the description (selects the old walk kept only because of its step and depth limits). Not covered: the fuzz programs are too small to reach the old step and depth limits, so the extra selects dropped beyond them are not checked by this fuzzer. Your comparison against the walk with its limits lifted is the check for those. AI-assisted: yes (Claude Code)
fma-rc commented 2026-10-12 13:00:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-12T13:00:23Z.


I replayed 148 requests from two more titles with and without this PR. The tool's output is identical, including every SPIR-V word count, and the replay is a little faster with it.

Linux, GCC 16.2.1 Release, agc_shader_replay with ANYPS5_NO_SHADER_CACHE=1. "Without" is main 0ef9dc928, "with" is d37463e76 merged onto main 33ae282e4; between those two commits only the replay tool's --prepare option changed in the shader and driver code. Times are the median of three runs over the whole set.

Title requests recompiled without with
Kena (PPSA01746) 17 16 0.26 s 0.24 s
LEGO Horizon Adventures (PPSA14632) 131 131 3.37 s 3.13 s

Kena's one failure is the same on both: packed pixel ancillary input has an unsupported live use (used by SelectU32 1065353216 ?).

The 13 tests matching masked_select|shader_recompiler|agc_shader pass on an RTX 5080, a Radeon 610M (RADV) and lavapipe.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6124772864 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4331#issuecomment-6124772864). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-12T13:00:23Z. --- I replayed 148 requests from two more titles with and without this PR. The tool's output is identical, including every SPIR-V word count, and the replay is a little faster with it. Linux, GCC 16.2.1 Release, `agc_shader_replay` with `ANYPS5_NO_SHADER_CACHE=1`. "Without" is `main` 0ef9dc928, "with" is d37463e76 merged onto `main` 33ae282e4; between those two commits only the replay tool's `--prepare` option changed in the shader and driver code. Times are the median of three runs over the whole set. | Title | requests | recompiled | without | with | |---|---|---|---|---| | Kena (PPSA01746) | 17 | 16 | 0.26 s | 0.24 s | | LEGO Horizon Adventures (PPSA14632) | 131 | 131 | 3.37 s | 3.13 s | Kena's one failure is the same on both: `packed pixel ancillary input has an unsupported live use (used by SelectU32 1065353216 ?)`. The 13 tests matching `masked_select|shader_recompiler|agc_shader` pass on an RTX 5080, a Radeon 610M (RADV) and lavapipe.
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!4331
No description provided.