Recompiler: since #2083, the f32 NaN select adds a SelectU32 reader of the packed pixel ancillary word, and 2 of 4 Stray S5a shaders fail again #2881

Closed
opened 2026-10-10 17:25:14 +00:00 by fisherjoey · 4 comments
fisherjoey commented 2026-10-10 17:25:14 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-10T17:25:14Z.


#2083 (merged 2026-10-09) picks f32 arithmetic NaN results on the bits with a select. In two of Stray's S5a pixel shaders, that select reads the packed pixel ancillary word. The ancillary lowering only accepts readers that extract a modelled field, so these two shaders fail again with packed pixel ancillary input has an unsupported live use (used by SelectU32 ? ?). #1904 made all four compile before #2083 landed.

Results

Offline replay: the real ShaderRecompiler::Recompile on the requests Stray (PPSA02100) logged for these shaders, CPU only.

Tree 0x200e360000 0x200e3b0000 0x200e3c0000 0x200e8b0000 Total
main 78aedb40 (has #1904 and #2083) FAIL OK FAIL OK 2 of 4
main bc40a6b5 + #1904 6b41cf4d FAIL OK FAIL OK 2 of 4
same with #2083 reverted (git revert -m1 a8b032b2) OK OK OK OK 4 of 4

Both failures read shader info collection failed: packed pixel ancillary input has an unsupported live use (used by SelectU32 ? ?).

To find the cause I bisected main's first-parent history with the #1179 + #1904 code applied at each step. f1451396 gives 4 of 4, and the next merge, a8b032b2 (#2083), gives 2 of 4. Reverting #2083 on current main conflicts with later changes in FloatInstructions.cpp and TranslationContext.hpp, which is why the revert row uses bc40a6b5.

  • #1903: my retest there has the same numbers on bc40a6b5.
  • #2548 is a different shape (the word read whole after its VGPR is reused). The 28 Stray shaders failing with (used by SelectU32) in #2749 may be this issue rather than #2548. I haven't checked them one by one.

Possible fixes

Either the ancillary lowering accepts this select, or #2083 leaves the select out when the operand is the ancillary input. I don't have a branch for this yet. I can write one for whichever side you prefer.

Setup

Linux, Release build with ANYPS5_ENABLE_SPIRV_TOOLS=ON, fresh shader disk cache for each replay. The requests are serialization version 13 and current main reads them directly. The other two S5a shaders (0x200e4d0000, 0x200e680000) can't be replayed offline because the SRT walk needs guest memory, so they aren't counted.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5793597946 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2881). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-10T17:25:14Z. --- #2083 (merged 2026-10-09) picks f32 arithmetic NaN results on the bits with a select. In two of Stray's S5a pixel shaders, that select reads the packed pixel ancillary word. The ancillary lowering only accepts readers that extract a modelled field, so these two shaders fail again with `packed pixel ancillary input has an unsupported live use (used by SelectU32 ? ?)`. #1904 made all four compile before #2083 landed. ## Results Offline replay: the real `ShaderRecompiler::Recompile` on the requests Stray (PPSA02100) logged for these shaders, CPU only. | Tree | 0x200e360000 | 0x200e3b0000 | 0x200e3c0000 | 0x200e8b0000 | Total | |---|---|---|---|---|---| | `main` 78aedb40 (has #1904 and #2083) | FAIL | OK | FAIL | OK | 2 of 4 | | `main` bc40a6b5 + #1904 6b41cf4d | FAIL | OK | FAIL | OK | 2 of 4 | | same with #2083 reverted (`git revert -m1 a8b032b2`) | OK | OK | OK | OK | 4 of 4 | Both failures read `shader info collection failed: packed pixel ancillary input has an unsupported live use (used by SelectU32 ? ?)`. To find the cause I bisected `main`'s first-parent history with the #1179 + #1904 code applied at each step. f1451396 gives 4 of 4, and the next merge, a8b032b2 (#2083), gives 2 of 4. Reverting #2083 on current `main` conflicts with later changes in `FloatInstructions.cpp` and `TranslationContext.hpp`, which is why the revert row uses bc40a6b5. ## Related - #1903: my retest there has the same numbers on bc40a6b5. - #2548 is a different shape (the word read whole after its VGPR is reused). The 28 Stray shaders failing with `(used by SelectU32)` in #2749 may be this issue rather than #2548. I haven't checked them one by one. ## Possible fixes Either the ancillary lowering accepts this select, or #2083 leaves the select out when the operand is the ancillary input. I don't have a branch for this yet. I can write one for whichever side you prefer. ## Setup Linux, Release build with `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, fresh shader disk cache for each replay. The requests are serialization version 13 and current `main` reads them directly. The other two S5a shaders (0x200e4d0000, 0x200e680000) can't be replayed offline because the SRT walk needs guest memory, so they aren't counted. AI-assisted: yes
LeandroSSB commented 2026-10-11 01:14:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroSSB on 2026-10-11T01:14:26Z.


The "#2083 leaves the select out" option is implemented on my fork: LeandroSSB/AnyPS5:fix/ancillary-nan-select (one commit, 0467f908, on main f1ae427b; the 11 commits since don't touch the recompiler's translation sources, only TechnicalDebt.md moved).

nanResultF32 returns the result unchanged — no selects emitted, pre-#2083 behavior exactly for that instruction — when any f32 source traces to the pixel input's ancillary VGPR. Walking to GetBuiltin(PackedAncillary) is impossible at translate time (SsaBuilder links the seed only after translation), so the walk chases the loader chain (BitCastF32U32/BitCastU32F32, abs/neg BitwiseAnd32/BitwiseXor32, the denormal-flush SelectU32, the fma zero-factor SelectF32, DppMoveU32) down to GetVectorRegister and compares the register index against psInputVgpr[Ancillary] — the same mapping the seed site uses. Because a translate-time read cannot know whether the seed or a later write dominates, adds on a reused ancillary VGPR also skip; that is what the real S5a shaders need (their adds read the reused register) and it only ever restores pre-#2083 semantics; it is recorded in TechnicalDebt, together with the unverified NaN-patterned-bit case (bits 6, 7, 12-15, 29-31 have no gfx1013 source per the table in #2548).

Tested on Linux (GCC, full build, lavapipe, CI flags): the new agc_driver_pixel_ancillary_nan (pixel stage with the ancillary input; v_mov reuse + v_add_f32 on the reused VGPR; Recompile must succeed in both float modes and the draw must show plain add semantics) passes including its Vulkan draw; agc_driver_f32_arithmetic_nan (#2083's own test) passes unchanged; pixel_ancillary and its refusal contract are untouched and pass; full ctest shows exactly the three failures this environment also has on main (import_audit, agc_driver_flat_apertures, agc_driver_image_packed16_load) — no new failures.

Honest limitation: a single-add synthetic program also compiles with the select present (MaskedSelectEliminator removes the masked copy in the simple shape), so the new test locks in the post-fix behavior but cannot by itself prove the skip fires. The decisive check is your offline replay: could you run 0x200e360000 and 0x200e3c0000 on this branch? If either shader contains an fma or a sub on the reused VGPR, those paths would be exercised too (the test only covers the add path). If the replay shows 4/4, this closes the regression; if not, the ancillary-lowering option is the remaining side.

Not opened as a PR because of the intake pause; a maintainer is welcome to carry the commit.

AI-assisted (Claude Code); I reviewed the change and ran everything above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104096088 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2881#issuecomment-6104096088). Originally posted by [LeandroSSB](https://github.com/LeandroSSB) on 2026-10-11T01:14:26Z. --- The "#2083 leaves the select out" option is implemented on my fork: [`LeandroSSB/AnyPS5:fix/ancillary-nan-select`](https://github.com/LeandroSSB/AnyPS5/tree/fix/ancillary-nan-select) (one commit, `0467f908`, on `main` `f1ae427b`; the 11 commits since don't touch the recompiler's translation sources, only TechnicalDebt.md moved). `nanResultF32` returns the result unchanged — no selects emitted, pre-#2083 behavior exactly for that instruction — when any f32 source traces to the pixel input's ancillary VGPR. Walking to `GetBuiltin(PackedAncillary)` is impossible at translate time (`SsaBuilder` links the seed only after translation), so the walk chases the loader chain (`BitCastF32U32`/`BitCastU32F32`, abs/neg `BitwiseAnd32`/`BitwiseXor32`, the denormal-flush `SelectU32`, the fma zero-factor `SelectF32`, `DppMoveU32`) down to `GetVectorRegister` and compares the register index against `psInputVgpr[Ancillary]` — the same mapping the seed site uses. Because a translate-time read cannot know whether the seed or a later write dominates, adds on a *reused* ancillary VGPR also skip; that is what the real S5a shaders need (their adds read the reused register) and it only ever restores pre-#2083 semantics; it is recorded in TechnicalDebt, together with the unverified NaN-patterned-bit case (bits 6, 7, 12-15, 29-31 have no gfx1013 source per the table in #2548). **Tested** on Linux (GCC, full build, lavapipe, CI flags): the new `agc_driver_pixel_ancillary_nan` (pixel stage with the ancillary input; `v_mov` reuse + `v_add_f32` on the reused VGPR; Recompile must succeed in both float modes and the draw must show plain add semantics) passes including its Vulkan draw; `agc_driver_f32_arithmetic_nan` (#2083's own test) passes unchanged; `pixel_ancillary` and its refusal contract are untouched and pass; full `ctest` shows exactly the three failures this environment also has on `main` (`import_audit`, `agc_driver_flat_apertures`, `agc_driver_image_packed16_load`) — no new failures. **Honest limitation:** a single-add synthetic program also compiles *with* the select present (`MaskedSelectEliminator` removes the masked copy in the simple shape), so the new test locks in the post-fix behavior but cannot by itself prove the skip fires. The decisive check is your offline replay: could you run `0x200e360000` and `0x200e3c0000` on this branch? If either shader contains an fma or a sub on the reused VGPR, those paths would be exercised too (the test only covers the add path). If the replay shows 4/4, this closes the regression; if not, the ancillary-lowering option is the remaining side. Not opened as a PR because of the intake pause; a maintainer is welcome to carry the commit. AI-assisted (Claude Code); I reviewed the change and ran everything above on my machine.
ThatsLeo commented 2026-10-11 12:01:15 +00:00 (Migrated from github.com)
Author
Contributor

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


On main 8ec0e131 this is gone for Stray: all 41 of its shaders that failed here compile, including the 10 that a helper-lane rule on the ancillary lowering could not take. Offline replay of the requests Stray (PPSA02101 v01.002) dumped on f1ae427b, where 31 of the 41 failed with packed pixel ancillary input has an unsupported live use (used by SelectU32 ? ?).

#3279's masked-lane proofs remove the select that keeps the word on lanes the initial EXEC leaves out, so the ancillary lowering no longer sees it. 0467f908 was not needed for any of them; with it on f1ae427b, all 31 still failed.

Two of the shaders (0x200f780000, 0x200f7a0000) now take 150 and 400 s to prepare: #3504.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108800961 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2881#issuecomment-6108800961). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-11T12:01:15Z. --- On `main` `8ec0e131` this is gone for Stray: all 41 of its shaders that failed here compile, including the 10 that a helper-lane rule on the ancillary lowering could not take. Offline replay of the requests Stray (PPSA02101 v01.002) dumped on `f1ae427b`, where 31 of the 41 failed with `packed pixel ancillary input has an unsupported live use (used by SelectU32 ? ?)`. #3279's masked-lane proofs remove the select that keeps the word on lanes the initial EXEC leaves out, so the ancillary lowering no longer sees it. `0467f908` was not needed for any of them; with it on `f1ae427b`, all 31 still failed. Two of the shaders (`0x200f780000`, `0x200f7a0000`) now take 150 and 400 s to prepare: #3504. AI-assisted: yes.
fisherjoey commented 2026-10-11 12:41:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-11T12:41:29Z.


@ThatsLeo thanks for the replay. That matches what the issue described: the select #2083 adds is one the masked-lane proofs in #3279 now remove, so the ancillary lowering on main no longer sees it. Closing as fixed by #3279. The slow preparation of the two shaders you found is tracked in #3504.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109128168 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2881#issuecomment-6109128168). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-11T12:41:29Z. --- @ThatsLeo thanks for the replay. That matches what the issue described: the select #2083 adds is one the masked-lane proofs in #3279 now remove, so the ancillary lowering on `main` no longer sees it. Closing as fixed by #3279. The slow preparation of the two shaders you found is tracked in #3504. AI-assisted: yes
LeandroSSB commented 2026-10-11 13:20:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroSSB on 2026-10-11T13:20:07Z.


With #3279 resolving this on main (ThatsLeo's replay: all 41 Stray shaders compile), my branch above is superseded — no carry needed. The TechnicalDebt note about unverified NaN-patterned ancillary bits (bits 6, 7, 12-15, 29-31 without a gfx1013 source, per the table in #2548) still applies to whatever path reads those bits and may be worth keeping in mind for #2548.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109453908 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2881#issuecomment-6109453908). Originally posted by [LeandroSSB](https://github.com/LeandroSSB) on 2026-10-11T13:20:07Z. --- With #3279 resolving this on `main` (ThatsLeo's replay: all 41 Stray shaders compile), my branch above is superseded — no carry needed. The TechnicalDebt note about unverified NaN-patterned ancillary bits (bits 6, 7, 12-15, 29-31 without a gfx1013 source, per the table in #2548) still applies to whatever path reads those bits and may be worth keeping in mind for #2548.
Sign in to join this conversation.
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#2881
No description provided.