fix(agc): defer shaders that cannot be prepared at registration to their first use #1836

Merged
EdouardSence merged 1 commit from upstream-pr/1836 into main 2026-10-10 04:41:49 +00:00
EdouardSence commented 2026-10-08 21:08:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-08T21:08:47Z.


What

Since #639, RegisterShader prepares every registered shader up front, and the first one that can't be prepared ends the run. Before that, such a shader only failed when it was dispatched, so titles that never dispatch it, or dispatch it late, kept running.

Several titles now stop at registration on compute shaders that call a user-data function pointer with s_swappc_b64, which is not implemented (#1817): Astro Bot, Ghost of Yōtei, Rise of the Ronin, Epic Mickey: Rebrushed, Stray and GTA V. Silksong and Ratchet & Clank: Rift Apart also register headers without their program address registers.

This change marks those shaders deferred instead of preparing them, and prepares them when they are first used. The deferral is decided before any preparation starts, and only in two cases:

  • The stage's program address registers are missing from the header.
  • The program has an s_swappc_b64 whose target the call analysis can't resolve. ShaderRecompiler::UnresolvableSwappcTarget is the condition that GraphBuilder::Build throws on today. It is shared with the analysis through a new isFetchCall helper, so fetch-shader calls are still accepted.

Every other error, including any GraphBuilder, Structurizer or PrepareShader failure, still throws at registration. There is no retry after an error.

SourceHandleFor and InvocationFor prepare a deferred shader at dispatch, the path unregistered compute shaders already take. So the original error is raised there if the shader is really used.

Tested

Linux (CachyOS, GCC), RX 9070 XT, Mesa 26.2.4 RADV. Head 52b77c20 on main 43972e69.

  • agc_driver_prepared_shaders_deferred registers a compute shader made of s_swappc_b64 s[4:5], s[4:5].
    • Registration succeeds, and logs its s_swappc_b64 at program counter 0x0 calls a computed target.
    • The dispatch fails with not statically resolvable.
    • The test now returns the skip code when no Vulkan device can be opened, like the other device tests.
  • agc_driver (tests/Submit.cpp, testHeaderWithoutProgramAddress, contributed by @lubaxe) registers a type 4 header without SPI_SHADER_PGM_LO/HI. On main it fails with missing static shader ABI register 201.
  • Full ctest: 512/513. The failing test is import_audit, which can't read the commit hash in my worktree and is unrelated.
  • tools/check_conventions.py passes. UnresolvableSwappcTarget is added to shaderCacheReviewedNames: it only decides whether to prepare at registration and doesn't change what a recompile produces.
  • Astro Bot, scripted input, headless:
    • Without this change it stops at its first shader registration on computed/data-dependent s_swappc_b64 call target at program counter 0x00000074.
    • With it, 96 shaders are deferred for an unresolvable s_swappc_b64 and 1 for missing program registers.
    • The run then reaches rectangle ABI refers to a replaced shader header, which #1837 fixes. No frame is presented yet.

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. The investigation, code, tests and this description were written by Claude (Claude Code) on my machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792817597 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-08T21:08:47Z. --- ### What Since #639, `RegisterShader` prepares every registered shader up front, and the first one that can't be prepared ends the run. Before that, such a shader only failed when it was dispatched, so titles that never dispatch it, or dispatch it late, kept running. Several titles now stop at registration on compute shaders that call a user-data function pointer with `s_swappc_b64`, which is not implemented (#1817): Astro Bot, Ghost of Yōtei, Rise of the Ronin, Epic Mickey: Rebrushed, Stray and GTA V. Silksong and Ratchet & Clank: Rift Apart also register headers without their program address registers. This change marks those shaders `deferred` instead of preparing them, and prepares them when they are first used. The deferral is decided before any preparation starts, and only in two cases: - **The stage's program address registers are missing from the header.** - **The program has an `s_swappc_b64` whose target the call analysis can't resolve.** `ShaderRecompiler::UnresolvableSwappcTarget` is the condition that `GraphBuilder::Build` throws on today. It is shared with the analysis through a new `isFetchCall` helper, so fetch-shader calls are still accepted. Every other error, including any `GraphBuilder`, `Structurizer` or `PrepareShader` failure, still throws at registration. There is no retry after an error. `SourceHandleFor` and `InvocationFor` prepare a deferred shader at dispatch, the path unregistered compute shaders already take. So the original error is raised there if the shader is really used. ### Tested Linux (CachyOS, GCC), RX 9070 XT, Mesa 26.2.4 RADV. Head 52b77c20 on `main` 43972e69. - **`agc_driver_prepared_shaders_deferred`** registers a compute shader made of `s_swappc_b64 s[4:5], s[4:5]`. - Registration succeeds, and logs `its s_swappc_b64 at program counter 0x0 calls a computed target`. - The dispatch fails with `not statically resolvable`. - The test now returns the skip code when no Vulkan device can be opened, like the other device tests. - **`agc_driver`** (`tests/Submit.cpp`, `testHeaderWithoutProgramAddress`, contributed by @lubaxe) registers a type 4 header without `SPI_SHADER_PGM_LO/HI`. On `main` it fails with `missing static shader ABI register 201`. - **Full `ctest`:** 512/513. The failing test is `import_audit`, which can't read the commit hash in my worktree and is unrelated. - **`tools/check_conventions.py`** passes. `UnresolvableSwappcTarget` is added to `shaderCacheReviewedNames`: it only decides whether to prepare at registration and doesn't change what a recompile produces. - **Astro Bot**, scripted input, headless: - Without this change it stops at its first shader registration on `computed/data-dependent s_swappc_b64 call target at program counter 0x00000074`. - With it, 96 shaders are deferred for an unresolvable `s_swappc_b64` and 1 for missing program registers. - The run then reaches `rectangle ABI refers to a replaced shader header`, which #1837 fixes. No frame is presented yet. ### 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. The investigation, code, tests and this description were written by Claude (Claude Code) on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fisherjoey commented 2026-10-08 22:32:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T22:32:42Z.


Tested on a third title: Stray (PPSA02100 v1.05, Unreal Engine 4) stops at the same point on main, and this PR gets it past it.

Setup: Linux (Nobara 44, kernel 7.2), RTX 5070 Ti, NVIDIA 595.91.07. Base is main 1be6f9f1 + #861 (Linux needs it to boot titles).

Without this PR, Stray exits about 10 s after launch, before any window, on its first sceAgcCreateShader:

what():  computed/data-dependent s_swappc_b64 call target at program counter 0x00000074 is not statically resolvable

Stack from the core: sceAgcCreateShader -> Driver::RegisterShader -> PrepareRegistered -> GraphBuilder::Build -> analyzeSwappcCalls.

With this PR, registration gets through 111 deferred shaders:

  • 95 are s_swappc_b64 user-data calls, at 27 different program counters (0x3c to 0xfc4).
  • 16 are shader sampler pairs exceed runtime heap capacity (#1789).

The run then stops on a different error that is not related to this PR: AGC driver: unsupported registered shader type, which I'm looking into separately.

One note: the PR no longer merges cleanly onto current main. #1851 added RegisteredFloatMode(snapshot) to the RecompileRequest in PrepareRegistered. I kept your try/catch and added that argument inside it.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6070384820 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6070384820). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-08T22:32:42Z. --- Tested on a third title: Stray (PPSA02100 v1.05, Unreal Engine 4) stops at the same point on `main`, and this PR gets it past it. Setup: Linux (Nobara 44, kernel 7.2), RTX 5070 Ti, NVIDIA 595.91.07. Base is `main` 1be6f9f1 + #861 (Linux needs it to boot titles). Without this PR, Stray exits about 10 s after launch, before any window, on its first `sceAgcCreateShader`: ``` what(): computed/data-dependent s_swappc_b64 call target at program counter 0x00000074 is not statically resolvable ``` Stack from the core: `sceAgcCreateShader` -> `Driver::RegisterShader` -> `PrepareRegistered` -> `GraphBuilder::Build` -> `analyzeSwappcCalls`. With this PR, registration gets through 111 deferred shaders: - 95 are `s_swappc_b64` user-data calls, at 27 different program counters (0x3c to 0xfc4). - 16 are `shader sampler pairs exceed runtime heap capacity` (#1789). The run then stops on a different error that is not related to this PR: `AGC driver: unsupported registered shader type`, which I'm looking into separately. One note: the PR no longer merges cleanly onto current `main`. #1851 added `RegisteredFloatMode(snapshot)` to the `RecompileRequest` in `PrepareRegistered`. I kept your try/catch and added that argument inside it. AI-assisted: yes
Dextroid17 commented 2026-10-08 23:45:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T23:45:15Z.


Title evidence — the deferral is what unblocks a real title.

PPSA26344 (Ghost of Yōtei 01.008): decrypted eboot.bin relinked, staged runtime layout, RTX 3080 Ti on Linux. Stack measured: main + #757 (image/sampler tables at runtime offsets) + this PR.

stack outcome
main exit 134 (SIGABRT) at presentation — GetImageResource dword 0 is not a valid runtime value
main + #757 exit 134 — that wall cleared, dies at computed/data-dependent s_swappc_b64 call target at program counter 0x74 is not statically resolvable
main + #757 + this PR still running

With this PR the run does not terminate: the shaders it cannot prepare are deferred and the title continues.

[Shaders/ShaderRegistry.cpp:332 operator()] Shader 0x55a82bc5f700 could not be prepared at registration
    (computed/data-dependent s_swappc_b64 call target at program counter 0x00000074 is not statically resolvable)
×20 deferrals, then the run continues

Measured ~2 minutes in: the process is alive with 29 threads at ~100% CPU, the GPU is active, the shader disk cache is past 68 writes, and the frame path prints no error (the earlier run's [videoout] presentation failed is gone). I cannot yet say a frame is on screen — this is a Wayland session with no window-listing tooling here — so the claim is "the title keeps running instead of aborting", not "the title renders".

Note #757 is a prerequisite for reaching this point: on main alone the title dies at the earlier image-descriptor wall, so a rebase/test loop needs both.

Merge note: one conflict, Execution/src/Driver/Shaders/ShaderRegistry.cpp — kept this PR's try/defer structure with main's newer RecompileRequest (it gained RegisteredFloatMode(snapshot) since this PR's base). Worth checking that when you rebase.

Raw log kept. Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6071265015 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6071265015). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-08T23:45:15Z. --- Title evidence — the deferral is what unblocks a real title. **PPSA26344 (Ghost of Yōtei 01.008)**: decrypted `eboot.bin` relinked, staged runtime layout, RTX 3080 Ti on Linux. Stack measured: `main` + **#757** (image/sampler tables at runtime offsets) + this PR. | stack | outcome | | --- | --- | | `main` | exit 134 (SIGABRT) at presentation — `GetImageResource dword 0 is not a valid runtime value` | | `main` + #757 | exit 134 — that wall cleared, dies at `computed/data-dependent s_swappc_b64 call target at program counter 0x74 is not statically resolvable` | | `main` + #757 + **this PR** | **still running** | With this PR the run does not terminate: the shaders it cannot prepare are deferred and the title continues. ``` [Shaders/ShaderRegistry.cpp:332 operator()] Shader 0x55a82bc5f700 could not be prepared at registration (computed/data-dependent s_swappc_b64 call target at program counter 0x00000074 is not statically resolvable) ×20 deferrals, then the run continues ``` Measured ~2 minutes in: the process is alive with 29 threads at ~100% CPU, the GPU is active, the shader disk cache is past 68 writes, and the frame path prints no error (the earlier run's `[videoout] presentation failed` is gone). I cannot yet say a frame is on screen — this is a Wayland session with no window-listing tooling here — so the claim is "the title keeps running instead of aborting", not "the title renders". Note #757 is a **prerequisite** for reaching this point: on `main` alone the title dies at the earlier image-descriptor wall, so a rebase/test loop needs both. **Merge note:** one conflict, `Execution/src/Driver/Shaders/ShaderRegistry.cpp` — kept this PR's `try`/`defer` structure with main's newer `RecompileRequest` (it gained `RegisteredFloatMode(snapshot)` since this PR's base). Worth checking that when you rebase. Raw log kept. Written with AI assistance.
lubaxe commented 2026-10-09 03:26:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by lubaxe on 2026-10-09T03:26:17Z.


PPSA12544 (Hollow Knight: Silksong) on Windows (RTX 5090) hits the "program address registers are missing from the header" case of this PR during startup. It registers a type 4 shader whose header has only these registers:

[shader] 0x21906d000 type 4 cx sh 8a=60000002 8b=00030008 ca=03000002

main stops with AGC driver: missing static shader ABI register 201 (0xc9, SPI_SHADER_PGM_HI of the vertex/mesh front). I worked around it locally by returning no prepared entries at registration when programRegister or programRegister + 1 is missing. That is the first case your PR covers. With it, the title reaches gameplay (tut_01).

If it helps, this is the regression I used, for tests/Submit.cpp (agc_driver_tests). It fails on main with exactly that error:

void testHeaderWithoutProgramAddress() {
    alignas(256) static const std::array<std::uint32_t, 64> code{0xbf810000};
    struct Header {
        Shader shader{};
        std::array<ShaderRegister, 3> registers{};
    };
    alignas(8) static Header header{};
    header.shader.file_header = 0x34333231;
    header.shader.version = 0x18;
    header.shader.header_size = sizeof(Header);
    header.shader.shader_size = sizeof(code);
    header.shader.code = code.data();
    header.shader.type = 4;
    header.registers = {{{0x08a, 0x60000002}, {0x08b, 0x00030008}, {0x0ca, 0x03000002}}};
    header.shader.sh_registers = header.registers.data();
    header.shader.num_sh_registers = header.registers.size();
    AgcDriverRegisterShader_nid_postfix(&header.shader);
}

I haven't tested this PR's branch itself yet, since it currently conflicts with main.

(Written with AI assistance: Claude Code.)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073650456 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6073650456). Originally posted by [lubaxe](https://github.com/lubaxe) on 2026-10-09T03:26:17Z. --- PPSA12544 (Hollow Knight: Silksong) on Windows (RTX 5090) hits the "program address registers are missing from the header" case of this PR during startup. It registers a type 4 shader whose header has only these registers: ``` [shader] 0x21906d000 type 4 cx sh 8a=60000002 8b=00030008 ca=03000002 ``` `main` stops with `AGC driver: missing static shader ABI register 201` (0xc9, `SPI_SHADER_PGM_HI` of the vertex/mesh front). I worked around it locally by returning no prepared entries at registration when `programRegister` or `programRegister + 1` is missing. That is the first case your PR covers. With it, the title reaches gameplay (`tut_01`). If it helps, this is the regression I used, for `tests/Submit.cpp` (`agc_driver_tests`). It fails on `main` with exactly that error: ```cpp void testHeaderWithoutProgramAddress() { alignas(256) static const std::array<std::uint32_t, 64> code{0xbf810000}; struct Header { Shader shader{}; std::array<ShaderRegister, 3> registers{}; }; alignas(8) static Header header{}; header.shader.file_header = 0x34333231; header.shader.version = 0x18; header.shader.header_size = sizeof(Header); header.shader.shader_size = sizeof(code); header.shader.code = code.data(); header.shader.type = 4; header.registers = {{{0x08a, 0x60000002}, {0x08b, 0x00030008}, {0x0ca, 0x03000002}}}; header.shader.sh_registers = header.registers.data(); header.shader.num_sh_registers = header.registers.size(); AgcDriverRegisterShader_nid_postfix(&header.shader); } ``` I haven't tested this PR's branch itself yet, since it currently conflicts with `main`. (Written with AI assistance: Claude Code.)
EdouardSence commented 2026-10-09 07:36:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T07:36:58Z.


Rebased onto main a8b032b2 as 177c4b2b. It merges cleanly again. The conflict was the one @fisherjoey and @Dextroid17 described: the try block now builds the RecompileRequest with RegisteredFloatMode(snapshot).

@lubaxe thanks for the Silksong header and the regression test. I added it to tests/Submit.cpp as testHeaderWithoutProgramAddress. On main it fails with AGC driver: missing static shader ABI register 201. On this branch it passes, so it covers the second deferral path (missing program address registers). The first path, an unresolvable s_swappc_b64, is covered by the deferred prepared-shader test.

ctest -j8: 495 of 496 pass. The one failure is import_audit, which can't read the commit hash in my worktree and is unrelated.

As @Dextroid17 says, this PR only moves the failure from registration to first use. Inlining user-data s_swappc_b64 targets is still #1817.

Thanks to all three of you for testing it on Stray, Ghost of Yōtei and Silksong.

AI-assisted: the rebase, the added test and this reply were done by Claude (Claude Code) on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6076592679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6076592679). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-09T07:36:58Z. --- Rebased onto `main` a8b032b2 as 177c4b2b. It merges cleanly again. The conflict was the one @fisherjoey and @Dextroid17 described: the `try` block now builds the `RecompileRequest` with `RegisteredFloatMode(snapshot)`. @lubaxe thanks for the Silksong header and the regression test. I added it to `tests/Submit.cpp` as `testHeaderWithoutProgramAddress`. On `main` it fails with `AGC driver: missing static shader ABI register 201`. On this branch it passes, so it covers the second deferral path (missing program address registers). The first path, an unresolvable `s_swappc_b64`, is covered by the `deferred` prepared-shader test. `ctest -j8`: 495 of 496 pass. The one failure is `import_audit`, which can't read the commit hash in my worktree and is unrelated. As @Dextroid17 says, this PR only moves the failure from registration to first use. Inlining user-data `s_swappc_b64` targets is still #1817. Thanks to all three of you for testing it on Stray, Ghost of Yōtei and Silksong. AI-assisted: the rebase, the added test and this reply were done by Claude (Claude Code) on my machine.
github-actions[bot] commented 2026-10-09 07:38:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T07:38:37Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1902 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L178-180, L219-221
#2261 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L13, L178-180, L219-221
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp L263
#2313 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L178-181, L219-222
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6076614559 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6076614559). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T07:38:37Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1902 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` [L178-180](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L178-L180), [L219-221](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L219-L221) | | | | #2261 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` [L13](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L13), [L178-180](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L178-L180), [L219-221](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L219-L221)<br>`core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp` [L263](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp#L263) | | | | #2313 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` [L178-181](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L178-L181), [L219-222](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L219-L222) | | |
oneandonlydean commented 2026-10-09 09:22:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:37Z.


The try/catch in PrepareRegistered (ShaderRegistry.cpp) turns any preparation error at registration into a second attempt at first use, which is a retry after an error and isn't allowed here; it would also hide real translation bugs until the shader runs. Please decide the deferral before preparing: the missing program-address registers check you already have, plus a user-data s_swappc_b64 found by the analysis, and let every other error throw at registration as before.

The new agc_driver_prepared_shaders_deferred also fails on the Windows runner (vkCreateInstance: Vulkan result -9); it needs to skip without a device like the other AGC device tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078125502 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6078125502). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:37Z. --- The `try`/`catch` in `PrepareRegistered` (`ShaderRegistry.cpp`) turns any preparation error at registration into a second attempt at first use, which is a retry after an error and isn't allowed here; it would also hide real translation bugs until the shader runs. Please decide the deferral before preparing: the missing program-address registers check you already have, plus a user-data `s_swappc_b64` found by the analysis, and let every other error throw at registration as before. The new `agc_driver_prepared_shaders_deferred` also fails on the Windows runner (`vkCreateInstance: Vulkan result -9`); it needs to skip without a device like the other AGC device tests.
oneandonlydean commented 2026-10-09 09:35:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:35:29Z.


@boykopovar this one needs your call, since it touches when shaders compile.

Since #639, several titles stop at registration (testers here name PPSA21567, PPSA26344, PPSA02100 and PPSA12544), and in testing I see the same two stops:

  • compute shaders that call a function pointer passed in user data (s_swappc_b64 s[14:15], mid-program, several times per shader): the target is only known at dispatch, so the shader can't be prepared at registration;
  • GsFront halves with no program address register (missing static shader ABI register 201).

I don't see another way for these to boot than preparing those shaders at first use, the way #639 already does for draw-state-dependent stages; the alternative is translating the data-dependent calls, which isn't written yet. If deferral is acceptable, I'd ask for it to be decided up front (detect the call / missing register before preparing) rather than catching any registration error, as noted above. If you'd rather keep everything at registration, these titles stay stopped until the calls are translated.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078313746 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6078313746). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:35:29Z. --- @boykopovar this one needs your call, since it touches when shaders compile. Since #639, several titles stop at registration (testers here name PPSA21567, PPSA26344, PPSA02100 and PPSA12544), and in testing I see the same two stops: - compute shaders that call a function pointer passed in user data (`s_swappc_b64 s[14:15]`, mid-program, several times per shader): the target is only known at dispatch, so the shader can't be prepared at registration; - GsFront halves with no program address register (`missing static shader ABI register 201`). I don't see another way for these to boot than preparing those shaders at first use, the way #639 already does for draw-state-dependent stages; the alternative is translating the data-dependent calls, which isn't written yet. If deferral is acceptable, I'd ask for it to be decided up front (detect the call / missing register before preparing) rather than catching any registration error, as noted above. If you'd rather keep everything at registration, these titles stay stopped until the calls are translated.
EdouardSence commented 2026-10-09 10:37:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T10:37:54Z.


Two more titles hit both deferral paths, on Linux with an RX 9070 XT, on main 43972e69.

Rise of the Ronin (PPSA04540):

  • Without this PR, it stops about 9 s in on its first registration: computed/data-dependent s_swappc_b64 call target at program counter 0x00000074 is not statically resolvable.
  • With it, 96 shaders are deferred, at program counters from 0x74 to 0x76c.
  • With #2105 and #1893 as well, it gets past shader loading (about 2,400 prepared shaders) and stops on an unrelated audio error at about 4 min 40 s. None of the deferred shaders was used before that.

Ratchet & Clank: Rift Apart (PPSA01474):

  • 16 shaders are deferred because their program address registers are missing from the header, the same case as Silksong.
  • The title then reaches an unrelated crash in its own code at about 19 s.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079217259 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6079217259). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-09T10:37:54Z. --- Two more titles hit both deferral paths, on Linux with an RX 9070 XT, on `main` 43972e69. **Rise of the Ronin (PPSA04540):** - Without this PR, it stops about 9 s in on its first registration: `computed/data-dependent s_swappc_b64 call target at program counter 0x00000074 is not statically resolvable`. - With it, 96 shaders are deferred, at program counters from 0x74 to 0x76c. - With #2105 and #1893 as well, it gets past shader loading (about 2,400 prepared shaders) and stops on an unrelated audio error at about 4 min 40 s. None of the deferred shaders was used before that. **Ratchet & Clank: Rift Apart (PPSA01474):** - 16 shaders are deferred because their program address registers are missing from the header, the same case as Silksong. - The title then reaches an unrelated crash in its own code at about 19 s. *Tested and written by Claude (AI assistant) on a contributor's machine.*
Dextroid17 commented 2026-10-09 11:18:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T11:18:30Z.


Three titles' worth of evidence now, and both deferral paths hit in the wild rather than in a fixture — that is what this needed, and the program-counter ranges for Rise of the Ronin are the part that makes it checkable.

One limitation on my side, so you know what I can and cannot add: I can only run the GPU tests on lavapipe here, because the NVIDIA driver path does not work on Linux yet. So I cannot give you a second AMD data point. What I can do is run the agc suite on lavapipe at your head — the CI device is where a green run counts — and report it here if that would be useful.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6079815125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6079815125). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-09T11:18:30Z. --- Three titles' worth of evidence now, and both deferral paths hit in the wild rather than in a fixture — that is what this needed, and the program-counter ranges for Rise of the Ronin are the part that makes it checkable. One limitation on my side, so you know what I can and cannot add: I can only run the GPU tests on lavapipe here, because the NVIDIA driver path does not work on Linux yet. So I cannot give you a second AMD data point. What I can do is run the agc suite on lavapipe at your head — the CI device is where a green run counts — and report it here if that would be useful. Written with AI assistance.
EdouardSence commented 2026-10-09 12:26:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T12:26:54Z.


@oneandonlydean thanks. Both points are addressed in 52b77c20.

  • No catch-all any more. PrepareRegistered decides the deferral before preparing anything, in two cases only:

    • the program address registers are missing;
    • ShaderRecompiler::UnresolvableSwappcTarget finds an s_swappc_b64 whose target the call analysis can't resolve. That is the same condition analyzeSwappcCalls throws on, and the two share the fetch-call check through a new isFetchCall helper.

    Every other error, including GraphBuilder, Structurizer and PrepareShader failures, throws at registration as before.

  • The --deferred test now returns VulkanTestSkipped when OpenVulkanTestDevice() fails. Its CMake entry already sets SKIP_RETURN_CODE 77.

Rebased onto main 43972e69. Full ctest passes except the unrelated import_audit. On Astro Bot the run defers 96 shaders through the swappc check and 1 for missing registers, then reaches the stop #1837 fixes. The description is updated.

AI-assisted: the change and this reply were written by Claude (Claude Code) on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080860251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6080860251). Originally posted by [EdouardSence](https://github.com/EdouardSence) on 2026-10-09T12:26:54Z. --- @oneandonlydean thanks. Both points are addressed in 52b77c20. - **No catch-all any more.** `PrepareRegistered` decides the deferral before preparing anything, in two cases only: - the program address registers are missing; - `ShaderRecompiler::UnresolvableSwappcTarget` finds an `s_swappc_b64` whose target the call analysis can't resolve. That is the same condition `analyzeSwappcCalls` throws on, and the two share the fetch-call check through a new `isFetchCall` helper. Every other error, including `GraphBuilder`, `Structurizer` and `PrepareShader` failures, throws at registration as before. - **The `--deferred` test** now returns `VulkanTestSkipped` when `OpenVulkanTestDevice()` fails. Its CMake entry already sets `SKIP_RETURN_CODE 77`. Rebased onto `main` 43972e69. Full `ctest` passes except the unrelated `import_audit`. On Astro Bot the run defers 96 shaders through the swappc check and 1 for missing registers, then reaches the stop #1837 fixes. The description is updated. AI-assisted: the change and this reply were written by Claude (Claude Code) on my machine.
hugodearaujo commented 2026-10-09 12:36:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-09T12:36:37Z.


Also unblocks Hollow Knight: Silksong (PPSA12544) on Linux. On current main (d70b89989) it stops while registering shaders:

terminate called after throwing an instance of 'std::runtime_error'
  what():  AGC driver: missing static shader ABI register 201

With this branch merged onto the same main, that shader is deferred instead:

[Shaders/ShaderRegistry.cpp:332 operator()] Shader 0x7f47e98ed000 could not be prepared at registration (its program address is not in the shader registers); preparing it when it is used

and the title gets past that point. It now loads its Unity modules and stops later at sceKernelRaiseException not implemented, which is the Linux signal delivery in #1431, not this change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081019994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6081019994). Originally posted by [hugodearaujo](https://github.com/hugodearaujo) on 2026-10-09T12:36:37Z. --- Also unblocks Hollow Knight: Silksong (PPSA12544) on Linux. On current `main` (`d70b89989`) it stops while registering shaders: ``` terminate called after throwing an instance of 'std::runtime_error' what(): AGC driver: missing static shader ABI register 201 ``` With this branch merged onto the same `main`, that shader is deferred instead: ``` [Shaders/ShaderRegistry.cpp:332 operator()] Shader 0x7f47e98ed000 could not be prepared at registration (its program address is not in the shader registers); preparing it when it is used ``` and the title gets past that point. It now loads its Unity modules and stops later at `sceKernelRaiseException not implemented`, which is the Linux signal delivery in #1431, not this change.
orbz22 commented 2026-10-09 12:44:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T12:44:43Z.


Astro's Playroom (PPSA01325) stops here too, on Windows with NVIDIA.

  • On main 943bd526 (with an unrelated DMA_DATA change on top), it stops at registration, before the first frame: AGC driver: missing static shader ABI register 201.
  • With this PR, tested at 177c4b2b (before the last push), on main 745b775e:
    • 18 shaders log could not be prepared at registration (its program address is not in the shader registers); preparing it when it is used (0x500001700, 0x50000d900, 0x500019b00, ...);
    • the run gets past that point.
  • The next stop is #1837's rectangle ABI refers to a replaced shader header.

Setup: Windows 11, RTX 3060 Laptop (NVIDIA 616.92), WinLibs GCC 15.2.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081144961 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6081144961). Originally posted by [orbz22](https://github.com/orbz22) on 2026-10-09T12:44:43Z. --- Astro's Playroom (PPSA01325) stops here too, on Windows with NVIDIA. - On `main` 943bd526 (with an unrelated DMA_DATA change on top), it stops at registration, before the first frame: `AGC driver: missing static shader ABI register 201`. - With this PR, tested at 177c4b2b (before the last push), on `main` 745b775e: - 18 shaders log `could not be prepared at registration (its program address is not in the shader registers); preparing it when it is used` (0x500001700, 0x50000d900, 0x500019b00, ...); - the run gets past that point. - The next stop is #1837's `rectangle ABI refers to a replaced shader header`. Setup: Windows 11, RTX 3060 Laptop (NVIDIA 616.92), WinLibs GCC 15.2. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dextroid17 commented 2026-10-09 13:25:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T13:25:41Z.


This builds on the deferral path introduced here, so it is stacked on this PR (declared as a dependency in #2257).

Context: a decode failure was still fatal because the decode sat outside the try this PR adds. #2257 moves it in, but only for the failure class that is a capability gap (a known family, an opcode we do not implement), so the contract that corrupt code fails loudly is untouched — PreparedShaders.cpp:239 still passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081815125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1836#issuecomment-6081815125). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-09T13:25:41Z. --- This builds on the deferral path introduced here, so it is stacked on this PR (declared as a dependency in #2257). Context: a decode failure was still fatal because the decode sat outside the `try` this PR adds. #2257 moves it in, but only for the failure class that is a capability gap (a known family, an opcode we do not implement), so the contract that corrupt code fails loudly is untouched — `PreparedShaders.cpp:239` still passes.
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!1836
No description provided.