fix(recompiler): split descriptor webs whose Phis sit in different blocks #2653

Merged
oneandonlydean merged 1 commit from upstream-pr/2653 into main 2026-10-10 20:26:32 +00:00
oneandonlydean commented 2026-10-10 10:08:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T10:08:02Z.


What

#1274 splits an image read whose T#/S# reaches it through a web of SRT Phis, but its walk requires every Phi of the descriptor tuple to sit in one block. When a sample chooses its T# in one if/else and its S# in a later one, the Phis sit in two blocks. The walk gives up and the plan throws:

GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate))

Astro Bot (PPSA21564) stops with this line after its first frames.

  • The walk now splits at the Phis of the latest block in program order.
  • Phis of earlier blocks pass through each edge unchanged until the walk reaches their block.
  • Every Phi of the tuple is used at the read, so their blocks lie on one dominator chain. The latest block is dominated by the others, so their values are available on each of its edges.
  • The existing state and arm limits still apply.

Tested

Linux (CachyOS, GCC, RTX 4090), Release:

  • Full ctest passes, except agc_driver_dcc_keys_first_write, which fails on main too.
  • tools/check_conventions.py passes.
  • New case in agc_shader_memory, verifyDescriptorPhis: a T# chosen by one if/else and an S# chosen by a second one plan two images and two samplers and recompile. On main it throws the line above.
  • Astro Bot on an earlier main with #1274 and this change: a pixel shader with eleven such samples stopped with the line above. With this change, the level loads.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4810415676 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2653). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T10:08:02Z. --- ### What #1274 splits an image read whose T#/S# reaches it through a web of SRT Phis, but its walk requires every Phi of the descriptor tuple to sit in one block. When a sample chooses its T# in one if/else and its S# in a later one, the Phis sit in two blocks. The walk gives up and the plan throws: ``` GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate)) ``` Astro Bot (PPSA21564) stops with this line after its first frames. - The walk now splits at the Phis of the latest block in program order. - Phis of earlier blocks pass through each edge unchanged until the walk reaches their block. - Every Phi of the tuple is used at the read, so their blocks lie on one dominator chain. The latest block is dominated by the others, so their values are available on each of its edges. - The existing state and arm limits still apply. ### Tested Linux (CachyOS, GCC, RTX 4090), Release: - Full `ctest` passes, except `agc_driver_dcc_keys_first_write`, which fails on `main` too. - `tools/check_conventions.py` passes. - New case in `agc_shader_memory`, `verifyDescriptorPhis`: a T# chosen by one if/else and an S# chosen by a second one plan two images and two samplers and recompile. On `main` it throws the line above. - Astro Bot on an earlier `main` with #1274 and this change: a pixel shader with eleven such samples stopped with the line above. With this change, the level loads. ### 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
Mouhand-Kaddo commented 2026-10-10 10:16:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-10T10:16:30Z.


Additional platform validation on standalone PR head 58d1f5ab18cffe68f9215a1dd891eab21e3caf76:

Windows: passed — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja.

Release / BUILD_TESTING=ON: built the selected test targets; 1 CTest cases, 0 failures, 0 CTest skips.

Tests: agc_shader_memory.

Reproduce after building the test targets: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_shader_memory$".

Vulkan: native AMD RX 6900 XT, driver 32.0.21045.5002.

This shader-memory case validates compiler planning and recompilation, not execution of a GPU workload or a retail title

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096478796 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2653#issuecomment-6096478796). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-10T10:16:30Z. --- <!-- anyps5-platform-validation:58d1f5ab18cffe68f9215a1dd891eab21e3caf76 --> Additional platform validation on standalone PR head `58d1f5ab18cffe68f9215a1dd891eab21e3caf76`: **Windows: passed** — Windows 11, supported WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja. Release / `BUILD_TESTING=ON`: built the selected test targets; 1 CTest cases, 0 failures, 0 CTest skips. Tests: `agc_shader_memory`. Reproduce after building the test targets: `ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^agc_shader_memory$"`. Vulkan: native AMD RX 6900 XT, driver 32.0.21045.5002. This shader-memory case validates compiler planning and recompilation, not execution of a GPU workload or a retail title
EdouardSence commented 2026-10-10 11:53:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-10T11:53:36Z.


Tested on Linux with Astro Bot (PPSA21567).

Setup: CachyOS (kernel 7.2.9), RX 9070 XT (RADV), Release, headless gamescope with scripted input. This PR (58d1f5ab1) cherry-picked onto main b5f5362d3, nothing else.

Without this PR: the title stops about 100 s in on

ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate))

With this PR: that stop is gone. The next stop, about 80 s in, is unrelated to this change:

compute shader 0x50059eb00: image descriptor is incompatible with the static runtime image interface

(a 2D-array comparison sample with emulated compare bound to a plain 2D T#; details in a separate issue). Adding #425 does not change either result here.

Tested and written by Claude (AI assistant) on a contributor's machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097215513 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2653#issuecomment-6097215513). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-10T11:53:36Z. --- Tested on Linux with Astro Bot (PPSA21567). **Setup:** CachyOS (kernel 7.2.9), RX 9070 XT (RADV), Release, headless gamescope with scripted input. This PR (`58d1f5ab1`) cherry-picked onto main `b5f5362d3`, nothing else. **Without this PR:** the title stops about 100 s in on ``` ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate)) ``` **With this PR:** that stop is gone. The next stop, about 80 s in, is unrelated to this change: ``` compute shader 0x50059eb00: image descriptor is incompatible with the static runtime image interface ``` (a 2D-array comparison sample with emulated compare bound to a plain 2D T#; details in a separate issue). Adding #425 does not change either result here. *Tested and written by Claude (AI assistant) on a contributor's machine.*
klosixgaming-arch commented 2026-10-10 14:49:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-10T14:49:55Z.


Independent validation on real hardware

Built and ran the PR head 58d1f5ab on my own box:

  • Windows 11 Pro (26200), WinLibs MinGW-w64 GCC 15.2.0 (r7), Release, BUILD_TESTING=ON.
  • GPU: NVIDIA GeForce RTX 5090.

Result: agc_shader_memory — PASSES (exit 0) ("Shader memory capture, strict validation and deterministic replay passed"), including the new verifyDescriptorPhis case where a T# is chosen in one block and an S# in another (plans 2 images + 2 samplers and recompiles).

Rigor check (is the test real?): I changed the web walk to require every tuple Phi to sit in a single block (i.e. reverted the "split at the latest block" behavior), rebuilt, and the test failed — GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate)) (exit 1), which is exactly the error line in your PR description. Restoring the change → PASS. So the new verifyDescriptorPhis case genuinely exercises the multi-block split rather than passing unconditionally.

Honest limits: I verified the recompiler planning/compilation path on one GPU (the 5090). I did not run Astro Bot (no game/ROM here) or the full ctest suite (you note agc_driver_dcc_keys_first_write fails on main too), and I did not test Linux.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098733704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2653#issuecomment-6098733704). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-10T14:49:55Z. --- **Independent validation on real hardware** Built and ran the PR head `58d1f5ab` on my own box: - **Windows 11 Pro (26200)**, WinLibs MinGW-w64 **GCC 15.2.0 (r7)**, `Release`, `BUILD_TESTING=ON`. - GPU: **NVIDIA GeForce RTX 5090**. **Result:** `agc_shader_memory` — **PASSES (exit 0)** ("Shader memory capture, strict validation and deterministic replay passed"), including the new `verifyDescriptorPhis` case where a T# is chosen in one block and an S# in another (plans 2 images + 2 samplers and recompiles). **Rigor check (is the test real?):** I changed the web walk to require every tuple Phi to sit in a single block (i.e. reverted the "split at the latest block" behavior), rebuilt, and the test **failed** — `GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate))` (exit 1), which is exactly the error line in your PR description. Restoring the change → PASS. So the new `verifyDescriptorPhis` case genuinely exercises the multi-block split rather than passing unconditionally. **Honest limits:** I verified the recompiler planning/compilation path on one GPU (the 5090). I did **not** run Astro Bot (no game/ROM here) or the full `ctest` suite (you note `agc_driver_dcc_keys_first_write` fails on `main` too), and I did not test Linux. Written with AI assistance.
fma-rc commented 2026-10-10 18:57:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T18:57:10Z.


Tested with Astro Bot PPSA21564 v01.007.000 on NVIDIA: the stop this PR targets is reproducible here on main and gone with the PR.

Setup: Arch Linux 7.2.9, GCC 16.2.1, Release, RTX 5080 (NVIDIA 615.78.08), 31 GB RAM. main 57f96fd2 against the same commit with this PR's head 58d1f5ab merged, nothing else. Relinker output unchanged between the two; only the libraries were rebuilt. APS5_HOST_IMPORT_MIB=12288 in all four runs, because with the default budget this title does not get far enough here to compile the shader.

Build Run Result Log lines Last level messages
main 1 stops on the error below 4278 LevelDocument Loaded: ui_pause_next
main 2 stops on the error below 4240 LevelDocument Loaded: ui_pause_next
main + this PR 1 no error 8579 StartLevel ps_logo, GAME: Level has started: ps_logo, LevelDocument Loaded: title_controller_ship
main + this PR 2 no error 8582 same three
terminate called after throwing an instance of 'std::runtime_error'
  what():  ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate))

Not established: what comes after title_controller_ship. Both runs with the PR were ended by my own memory guard, not by the title: the process was at about 25.5 GB resident and the machine had under 4 GiB available. So I cannot say whether there is a later stop on this GPU, and I did not look at the picture.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6101048136 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2653#issuecomment-6101048136). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-10T18:57:10Z. --- Tested with Astro Bot PPSA21564 v01.007.000 on NVIDIA: the stop this PR targets is reproducible here on `main` and gone with the PR. **Setup:** Arch Linux 7.2.9, GCC 16.2.1, Release, RTX 5080 (NVIDIA 615.78.08), 31 GB RAM. `main` 57f96fd2 against the same commit with this PR's head 58d1f5ab merged, nothing else. Relinker output unchanged between the two; only the libraries were rebuilt. `APS5_HOST_IMPORT_MIB=12288` in all four runs, because with the default budget this title does not get far enough here to compile the shader. | Build | Run | Result | Log lines | Last level messages | |---|---|---|---|---| | `main` | 1 | stops on the error below | 4278 | `LevelDocument Loaded: ui_pause_next` | | `main` | 2 | stops on the error below | 4240 | `LevelDocument Loaded: ui_pause_next` | | `main` + this PR | 1 | no error | 8579 | `StartLevel ps_logo`, `GAME: Level has started: ps_logo`, `LevelDocument Loaded: title_controller_ship` | | `main` + this PR | 2 | no error | 8582 | same three | ``` terminate called after throwing an instance of 'std::runtime_error' what(): ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate)) ``` **Not established:** what comes after `title_controller_ship`. Both runs with the PR were ended by my own memory guard, not by the title: the process was at about 25.5 GB resident and the machine had under 4 GiB available. So I cannot say whether there is a later stop on this GPU, and I did not look at the picture.
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!2653
No description provided.