fix(shader): plan image tables through invariant descriptor phis #6417

Merged
UnhealthyKraken merged 1 commit from upstream-pr/6417 into main 2026-10-19 00:40:41 +00:00
UnhealthyKraken commented 2026-10-15 14:33:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-15T14:33:18Z.


What

Resolve invariant Phi words before matching an image or sampler descriptor to a runtime table column. The existing invariant proof already follows cyclic Phi webs and requires equivalent reads and operands; the table planner previously inspected the Phi directly and rejected it. Varying or unresolved Phis still take the existing rejection/splitting paths.

Adds synthetic CPU and GPU regressions with a loop that merges equivalent descriptor reads. A differing-offset CPU case must be refused or split, and the GPU case compares sampled pixels with a loop that retains the original descriptor.

Tested

Windows 11 build 26200, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 5090, driver 617.42.

  • CPU regression: agc_shader_bindless fails without this change with GetImageResource dword 0 is not a valid runtime value, and passes with it.
  • GPU regression: agc_driver_image_table fails without this change on the same invariant descriptor chain. With it, all sampled output words match the control shader, with no table faults and unchanged distinct image count.
  • The captured pixel shader 0x11d1418800 from Marvel's Wolverine (PPSA03671, content 01.001.005, bring-up #5516) reproduces the rejection on main and recompiles with this change.
  • Eleven selected tests pass: shader memory, bindless tables, image-table GPU execution, graphics validation, write tracking, both import-watch cases, untracked forget, host-import retirement, unit shadows, and layered-volume submission.
  • Tests ran on main f633042dfd with local #6150, #6187 and #6308 for the Windows runtime. This branch contains only the descriptor fix and its tests, based on main 940eba9a26. The captured shader replay uses the shader recompiler directly.
  • Full title compatibility remains under investigation. Linux and other GPU vendors are untested; no performance claim.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none confirmed; PPSA03671 #5516 bring-up remains in progress
  • GPUs tested: NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 11 build 26200
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4874951713 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6417). Originally posted by [UnhealthyKraken](https://github.com/UnhealthyKraken) on 2026-10-15T14:33:18Z. --- ### What Resolve invariant Phi words before matching an image or sampler descriptor to a runtime table column. The existing invariant proof already follows cyclic Phi webs and requires equivalent reads and operands; the table planner previously inspected the Phi directly and rejected it. Varying or unresolved Phis still take the existing rejection/splitting paths. Adds synthetic CPU and GPU regressions with a loop that merges equivalent descriptor reads. A differing-offset CPU case must be refused or split, and the GPU case compares sampled pixels with a loop that retains the original descriptor. ### Tested Windows 11 build 26200, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 5090, driver 617.42. - CPU regression: `agc_shader_bindless` fails without this change with `GetImageResource dword 0 is not a valid runtime value`, and passes with it. - GPU regression: `agc_driver_image_table` fails without this change on the same invariant descriptor chain. With it, all sampled output words match the control shader, with no table faults and unchanged distinct image count. - The captured pixel shader `0x11d1418800` from Marvel's Wolverine (PPSA03671, content 01.001.005, bring-up #5516) reproduces the rejection on main and recompiles with this change. - Eleven selected tests pass: shader memory, bindless tables, image-table GPU execution, graphics validation, write tracking, both import-watch cases, untracked forget, host-import retirement, unit shadows, and layered-volume submission. - Tests ran on `main` f633042dfdf0 with local #6150, #6187 and #6308 for the Windows runtime. This branch contains only the descriptor fix and its tests, based on main 940eba9a26ec. The captured shader replay uses the shader recompiler directly. - Full title compatibility remains under investigation. Linux and other GPU vendors are untested; no performance claim. ### 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 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: none - [x] Unblocks: none confirmed; PPSA03671 #5516 bring-up remains in progress - [x] GPUs tested: NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 11 build 26200 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 14:39:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T14:39:58Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1341 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5500 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6177 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6280 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 6454 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6481 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 6612 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6645 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6683 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6941 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6947 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7002 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 7085 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 7223 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 7388 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6194741886 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6417#issuecomment-6194741886). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T14:39:58Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1341](https://www.github.com/boykopovar/AnyPS5/pull/1341) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 6454](https://www.github.com/boykopovar/AnyPS5/pull/6454) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp` | | [PR 6488](https://www.github.com/boykopovar/AnyPS5/pull/6488) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 6612](https://www.github.com/boykopovar/AnyPS5/pull/6612) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6645](https://www.github.com/boykopovar/AnyPS5/pull/6645) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6683](https://www.github.com/boykopovar/AnyPS5/pull/6683) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6941](https://www.github.com/boykopovar/AnyPS5/pull/6941) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 7002](https://www.github.com/boykopovar/AnyPS5/pull/7002) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 7085](https://www.github.com/boykopovar/AnyPS5/pull/7085) | `core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 7223](https://www.github.com/boykopovar/AnyPS5/pull/7223) | `core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 7388](https://www.github.com/boykopovar/AnyPS5/pull/7388) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceTracker.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/Optimization/src/ResourceTracker.cpp` |
Tamalero commented 2026-10-17 06:54:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-17T06:54:00Z.


Title check, since two titles in #6191 stop on the same GetImageResource dword 0 is not a valid runtime value message: this PR doesn't change either stop, and I saw no regression.

Title Tree Without this PR With this PR
Ratchet & Clank: Rift Apart (PPSA01474), chain through a Phi at pc=0x6b6c/0x6b80 main f26eb67c8 + #6814 stops on the chain (1 run) same stop, sibling shader (1 run)
Guardians of the Galaxy (PPSA01748), key at pc=0x4380 main 5d9dcc42d + #6232 + #6606 stops on the key (2 runs) same stop (3 runs)

Both look like shapes this PR isn't meant to cover (two independently selected keys in Ratchet; no Phi in the Guardians key), so this is just a no-regression data point. Linux, RTX 4090, GCC 16.2.1.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6230907355 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6417#issuecomment-6230907355). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-17T06:54:00Z. --- Title check, since two titles in #6191 stop on the same `GetImageResource dword 0 is not a valid runtime value` message: this PR doesn't change either stop, and I saw no regression. | Title | Tree | Without this PR | With this PR | |---|---|---|---| | Ratchet & Clank: Rift Apart (PPSA01474), chain through a `Phi` at `pc=0x6b6c`/`0x6b80` | `main` `f26eb67c8` + #6814 | stops on the chain (1 run) | same stop, sibling shader (1 run) | | Guardians of the Galaxy (PPSA01748), key at `pc=0x4380` | `main` `5d9dcc42d` + #6232 + #6606 | stops on the key (2 runs) | same stop (3 runs) | Both look like shapes this PR isn't meant to cover (two independently selected keys in Ratchet; no `Phi` in the Guardians key), so this is just a no-regression data point. Linux, RTX 4090, GCC 16.2.1. *Tested and written by Claude (AI assistant) on a contributor's machine.*
UnhealthyKraken commented 2026-10-22 14:28:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T14:28:26Z.


Recorded these as contributor-reported no-regression data points. The two independently selected keys and the key without a Phi remain outside this invariant-descriptor-Phi change and belong with the remaining cases in #6191. I have not rerun either title or treated this report as broader shader coverage.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343235588 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6417#issuecomment-6343235588). Originally posted by [UnhealthyKraken](https://github.com/UnhealthyKraken) on 2026-10-22T14:28:26Z. --- Recorded these as contributor-reported no-regression data points. The two independently selected keys and the key without a Phi remain outside this invariant-descriptor-Phi change and belong with the remaining cases in #6191. I have not rerun either title or treated this report as broader shader coverage.
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!6417
No description provided.