feat(shader): link callees of calls whose target is loaded from a table #4706

Merged
TripyFox merged 2 commits from upstream-pr/4706 into main 2026-10-14 19:15:26 +00:00
TripyFox commented 2026-10-12 19:28:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TripyFox on 2026-10-12T19:28:15Z.


What

Fixes #3274: a compute shader's s_swappc_b64 whose target pair is loaded from a table (s_buffer_load_dwordx4 of a buffer whose descriptor comes from user data, indexed by a shifted offset) failed at compile time with "computed/data-dependent s_swappc_b64 call target ... is not statically resolvable".

  • Table callees (FindTableCalls, LinkCalls, driver ReadTableCallees): at dispatch the driver reads the descriptor and the buffer, collects the distinct non-zero targets at the loaded offset plus multiples of the offset's stride, reads each callee the same way user-data callees are read, and links one copy per call after the caller. The call becomes a branch to a compare chain (s_cmp_lg_u32 with a literal + s_cbranch_scc1 per dword) that s_call_b64s the matching copy. There is one chain per value of SCC at the call, and the chain restores SCC before the callee runs, so the callee sees the caller's SCC. Table contents stay out of the shader and pipeline keys; only the linked code (the target set) is keyed, as with user-data callees.
  • Unlinked calls: when a table call's target matches no linked copy, the call's fallback records an UnlinkedCall fault (target and PC) through the existing fault buffer and stops the invocation, or continues after the call when faults don't stop invocations. The driver reports it like a BDA fault. The linker lists these fallbacks in the request (GuestContext::linkedCallFallbacks, request format 25). Any other s_swappc_b64 whose target is not resolved is still refused at compile time, as on main.
  • Link-register model: outside the call regions, the link pair may now be used freely wherever no return address can reach it. A dataflow over the decoded instructions tracks each dword from the calls that write it until an instruction is known to overwrite it. Before, any non-overwrite use anywhere threw. The R&C caller reuses s14/s15 as scratch all over the program. VALU mask writes count as one SGPR unless the request is wave64. SOPC compares may read the pair anywhere.
  • Callers that read their PC: these can now have callees linked. Their PC-relative reads go to the captured guest code, which linking doesn't change. A caller with an in-code jump table still throws, because the CFG reads that table from the recompiled words.
  • SRT planning (second commit): PlanBuilder::Collect walked the IR recursively and kept visited values in a vector. A linked program with 30 callees (about 29k words) overflowed the stack. The walk now uses an explicit stack and hashed sets, and records reads in the same order.

Sources: AMD RDNA 2 ISA reference guide. The compare chain uses s_cmp_lg_u32/s_cmp_eq_u32 (§12.4, opcodes 6 and 7, encoding §13.1), s_cbranch_scc1/s_branch (§4.2, §12.5) and s_call_b64 (§12.2), and it keeps SCC as §3.8 describes it. The SGPR-mask width used by the link-pair dataflow comes from three places: §2.1 ("The upper half of EXEC and VCC are ignored for wave32 waves"), §3.9 (in wave32 only the low 32 bits of VCC are used) and §6.2.3 (a VALU mask in SGPRs takes two consecutive SGPRs in wave64). From these, a wave32 VALU mask write is counted as one SGPR. That is an inference from the guide, not a measurement. When the wave size is unknown, the dataflow assumes the narrower overwrite and the wider read. The s_buffer_load range is taken as the descriptor's whole size (stride × num_records, or num_records bytes). That size covers both possible range interpretations. Which one the PS5 uses was not measured, and this is recorded in TechnicalDebt. None of the new behaviour was measured on hardware. s_call_b64 itself was already measured on gfx1036, as TechnicalDebt records.

Data from R&C (PPSA01474): one table with 348,156 16-byte records {target, arg} and 30 distinct leaf callees, 85–834 instructions each (about 92 KB in total). Each callee returns through s_setpc_b64 on the link pair and makes no further calls.

Tested

  • Windows 11, MinGW GCC 15.2, RTX 5090: full ctest on main 23e93c054 + this PR, 1146/1146 passed. New and updated cases are in ScalarCall.cpp (matcher, linker layout, CFG of the linked program, translation, unlinked fallbacks, wave32/64 mask writes, link-pair dataflow, jump-table refusal, s_call range), ShaderMemory.cpp (request format 25 and the new field's round trip), and the new execution test ComputeTableCalls.cpp (agc_driver_compute_table_calls). That test runs a linked two-record table on Vulkan in wave64 and wave32, with SCC 0 and 1 reaching the callee, and checks that a record past the table reports the UnlinkedCall fault.
  • tools/check_conventions.py --base origin/main: passed.
  • Ratchet & Clank: Rift Apart (PPSA01474):
    • In game: it no longer aborts with the #3274 error. The same deferred-lighting shader now stops one step later, at src_private_base (#3803, which needs hardware values; not part of this PR).
    • Offline: with agc_shader_replay on the captured request, plus a local aperture stub that is not in this PR, the call is found and all 30 callees link (29,266 words). The linked CFG is accepted. Planning then fails in a callee that loads an image descriptor through the per-record pointer, which is a data-dependent descriptor (#757 territory). Front-end and planning took about 28 s on this program, so compile cost is a concern for very large linked sets.
  • Astro Bot (PPSA21567): it aborts about 1 minute in with storage image access to depth/stencil surface ... is not implemented. Plain main (d592d54e1) without this PR does the same, so it is not caused by this change.

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
  • Unblocks: PPSA01474 (fixes the #3274 stop; the title then stops at #3803)
  • AI-assisted: yes (written with Claude; I reviewed and tested it)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4834062184 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706). Originally posted by [TripyFox](https://github.com/TripyFox) on 2026-10-12T19:28:15Z. --- ### What Fixes #3274: a compute shader's `s_swappc_b64` whose target pair is loaded from a table (`s_buffer_load_dwordx4` of a buffer whose descriptor comes from user data, indexed by a shifted offset) failed at compile time with "computed/data-dependent s_swappc_b64 call target ... is not statically resolvable". - **Table callees** (`FindTableCalls`, `LinkCalls`, driver `ReadTableCallees`): at dispatch the driver reads the descriptor and the buffer, collects the distinct non-zero targets at the loaded offset plus multiples of the offset's stride, reads each callee the same way user-data callees are read, and links one copy per call after the caller. The call becomes a branch to a compare chain (`s_cmp_lg_u32` with a literal + `s_cbranch_scc1` per dword) that `s_call_b64`s the matching copy. There is one chain per value of SCC at the call, and the chain restores SCC before the callee runs, so the callee sees the caller's SCC. Table contents stay out of the shader and pipeline keys; only the linked code (the target set) is keyed, as with user-data callees. - **Unlinked calls**: when a table call's target matches no linked copy, the call's fallback records an `UnlinkedCall` fault (target and PC) through the existing fault buffer and stops the invocation, or continues after the call when faults don't stop invocations. The driver reports it like a BDA fault. The linker lists these fallbacks in the request (`GuestContext::linkedCallFallbacks`, request format 25). Any other `s_swappc_b64` whose target is not resolved is still refused at compile time, as on main. - **Link-register model**: outside the call regions, the link pair may now be used freely wherever no return address can reach it. A dataflow over the decoded instructions tracks each dword from the calls that write it until an instruction is known to overwrite it. Before, any non-overwrite use anywhere threw. The R&C caller reuses s14/s15 as scratch all over the program. VALU mask writes count as one SGPR unless the request is wave64. SOPC compares may read the pair anywhere. - **Callers that read their PC**: these can now have callees linked. Their PC-relative reads go to the captured guest code, which linking doesn't change. A caller with an in-code jump table still throws, because the CFG reads that table from the recompiled words. - **SRT planning** (second commit): `PlanBuilder::Collect` walked the IR recursively and kept visited values in a vector. A linked program with 30 callees (about 29k words) overflowed the stack. The walk now uses an explicit stack and hashed sets, and records reads in the same order. Sources: [AMD RDNA 2 ISA reference guide](https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf). The compare chain uses `s_cmp_lg_u32`/`s_cmp_eq_u32` (§12.4, opcodes 6 and 7, encoding §13.1), `s_cbranch_scc1`/`s_branch` (§4.2, §12.5) and `s_call_b64` (§12.2), and it keeps SCC as §3.8 describes it. The SGPR-mask width used by the link-pair dataflow comes from three places: §2.1 ("The upper half of EXEC and VCC are ignored for wave32 waves"), §3.9 (in wave32 only the low 32 bits of VCC are used) and §6.2.3 (a VALU mask in SGPRs takes two consecutive SGPRs in wave64). From these, a wave32 VALU mask write is counted as one SGPR. That is an inference from the guide, not a measurement. When the wave size is unknown, the dataflow assumes the narrower overwrite and the wider read. The `s_buffer_load` range is taken as the descriptor's whole size (stride × num_records, or num_records bytes). That size covers both possible range interpretations. Which one the PS5 uses was not measured, and this is recorded in TechnicalDebt. None of the new behaviour was measured on hardware. `s_call_b64` itself was already measured on gfx1036, as TechnicalDebt records. Data from R&C (PPSA01474): one table with 348,156 16-byte records `{target, arg}` and 30 distinct leaf callees, 85–834 instructions each (about 92 KB in total). Each callee returns through `s_setpc_b64` on the link pair and makes no further calls. ### Tested - Windows 11, MinGW GCC 15.2, RTX 5090: full `ctest` on `main` 23e93c054 + this PR, 1146/1146 passed. New and updated cases are in `ScalarCall.cpp` (matcher, linker layout, CFG of the linked program, translation, unlinked fallbacks, wave32/64 mask writes, link-pair dataflow, jump-table refusal, s_call range), `ShaderMemory.cpp` (request format 25 and the new field's round trip), and the new execution test `ComputeTableCalls.cpp` (`agc_driver_compute_table_calls`). That test runs a linked two-record table on Vulkan in wave64 and wave32, with SCC 0 and 1 reaching the callee, and checks that a record past the table reports the `UnlinkedCall` fault. - `tools/check_conventions.py --base origin/main`: passed. - Ratchet & Clank: Rift Apart (PPSA01474): - **In game:** it no longer aborts with the #3274 error. The same deferred-lighting shader now stops one step later, at `src_private_base` (#3803, which needs hardware values; not part of this PR). - **Offline:** with `agc_shader_replay` on the captured request, plus a local aperture stub that is not in this PR, the call is found and all 30 callees link (29,266 words). The linked CFG is accepted. Planning then fails in a callee that loads an image descriptor through the per-record pointer, which is a data-dependent descriptor (#757 territory). Front-end and planning took about 28 s on this program, so compile cost is a concern for very large linked sets. - Astro Bot (PPSA21567): it aborts about 1 minute in with `storage image access to depth/stencil surface ... is not implemented`. Plain `main` (d592d54e1) without this PR does the same, so it is not caused by this change. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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: PPSA01474 (fixes the #3274 stop; the title then stops at #3803) - [x] AI-assisted: yes (written with Claude; I reviewed and tested it) 🤖 Generated with Claude Code
kr4y4 commented 2026-10-12 22:20:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-12T22:20:39Z.


A second-vendor run, to go with the RTX 5090 one.

Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 7c7b22dfe merged into main 584cc4c57.

  • scalar_call, scalar_swappc, agc_driver_scalar_swappc and agc_driver_prepared_shaders pass on both GPUs with --repeat until-fail:3.
  • Full suite (ctest --timeout 120 --parallel 4): 1018 of 1018 on both GPUs. That includes the user-data callee tests from #3294, agc_driver_compute_user_data_calls and its --registered mode.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6133683442 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6133683442). Originally posted by [kr4y4](https://github.com/kr4y4) on 2026-10-12T22:20:39Z. --- A second-vendor run, to go with the RTX 5090 one. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 7c7b22dfe merged into `main` 584cc4c57. - `scalar_call`, `scalar_swappc`, `agc_driver_scalar_swappc` and `agc_driver_prepared_shaders` pass on both GPUs with `--repeat until-fail:3`. - Full suite (`ctest --timeout 120 --parallel 4`): 1018 of 1018 on both GPUs. That includes the user-data callee tests from #3294, `agc_driver_compute_user_data_calls` and its `--registered` mode. Written with AI assistance.
Tamalero commented 2026-10-13 00:13:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-13T00:13:13Z.


In-game confirmation on Linux: with this PR, Ratchet & Clank: Rift Apart (PPSA01474) no longer aborts with the #3274 error. It plays the PS logo, the raytraced logo and the Insomniac logo, then compiles about 240 new shaders. It stops about 6 minutes in at the table shape you predicted from the offline replay.

  • No #3274 abort. No UnlinkedCall fault was reported. The linked programs are big: about 4.5 MB each in the disk cache, with about 230 MB written per 10 s while they compile behind a black screen after the Insomniac logo.
  • No aperture refusal. I had a local stub answering operands 235–238 with values measured on gfx1030 (see #3803), so this doesn't show whether that shader would otherwise stop at src_private_base on this stack.
  • The stop is in compute shader 0x116bb65f00, stage 0: GetImageResource dword 0 is not a valid runtime value. The T# is loaded through a pointer that is read from a buffer at a waterfall index (ReadFirstLane inside a loop):
    LoadAddressU32@pc=0x6340(GetAddressResource(ReadConstBuffer@pc=0x1aa8(GetBufferResource(V# from the SRT),
      ShiftLeftLogical32(ReadFirstLane(SelectU32(LogicalAnd(INotEqual32(BitwiseAnd32, Immediate), INotEqual32(Immediate, Phi)), IAdd32(Phi(Phi, SelectU32), ...
    
    That matches the per-record pointer you describe. Marvel's Guardians of the Galaxy (PPSA01748) has the same shape in two shaders (pcs 0x4378 and 0x4380), so both titles now wait on it.
Details

Setup: CachyOS (Linux 7.2), RTX 4090 (NVIDIA 615.78), GCC 16, Release. The title is relinked with --to-intel from the same tree.

Stack: main 90c683946, plus this PR at 7c7b22dfe, plus #757 (tv7's rebase/757, 8945fe208), plus #758 (cad61e9a7). Local changes on top:

  • Guest thread stacks are placed inside the application area (#3283). Without that, ChakraCore throws Js::OutOfMemoryException during the raytraced logo on Linux.
  • The CB metadata pass and BLEND_BYPASS fixes.
  • The aperture stub mentioned above.

Merge notes against 90c683946:

  • BdaAbi::FaultReason: #757 adds ImageTable and this PR adds UnlinkedCall at the same position. I kept both; each is referenced only by name.
  • PlanBuilder::Collect: main already has an iterative walk, so I kept main's version over this PR's second commit.

Tests on the combined stack, all passing:

  • scalar_call, scalar_swappc
  • agc_driver_scalar_swappc and _fetch
  • agc_driver_compute_user_data_calls and _registered
  • agc_driver_prepared_shaders and its deferred, deferred_undecodable, registered_workgroup(_sync), indirect, uncached, debug and debug_failure variants
  • the image-table, bindless, runtime-image, shader-memory and disk-cache tests

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135097394 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6135097394). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-13T00:13:13Z. --- In-game confirmation on Linux: with this PR, Ratchet & Clank: Rift Apart (PPSA01474) no longer aborts with the #3274 error. It plays the PS logo, the raytraced logo and the Insomniac logo, then compiles about 240 new shaders. It stops about 6 minutes in at the table shape you predicted from the offline replay. - **No #3274 abort.** No `UnlinkedCall` fault was reported. The linked programs are big: about 4.5 MB each in the disk cache, with about 230 MB written per 10 s while they compile behind a black screen after the Insomniac logo. - **No aperture refusal.** I had a local stub answering operands 235–238 with values measured on gfx1030 (see #3803), so this doesn't show whether that shader would otherwise stop at `src_private_base` on this stack. - **The stop** is in compute shader `0x116bb65f00`, stage 0: `GetImageResource dword 0 is not a valid runtime value`. The T# is loaded through a pointer that is read from a buffer at a waterfall index (`ReadFirstLane` inside a loop): ``` LoadAddressU32@pc=0x6340(GetAddressResource(ReadConstBuffer@pc=0x1aa8(GetBufferResource(V# from the SRT), ShiftLeftLogical32(ReadFirstLane(SelectU32(LogicalAnd(INotEqual32(BitwiseAnd32, Immediate), INotEqual32(Immediate, Phi)), IAdd32(Phi(Phi, SelectU32), ... ``` That matches the per-record pointer you describe. Marvel's Guardians of the Galaxy (PPSA01748) has the same shape in two shaders (pcs `0x4378` and `0x4380`), so both titles now wait on it. <details><summary>Details</summary> **Setup:** CachyOS (Linux 7.2), RTX 4090 (NVIDIA 615.78), GCC 16, Release. The title is relinked with `--to-intel` from the same tree. **Stack:** main `90c683946`, plus this PR at `7c7b22dfe`, plus #757 (tv7's `rebase/757`, `8945fe208`), plus #758 (`cad61e9a7`). Local changes on top: - Guest thread stacks are placed inside the application area (#3283). Without that, ChakraCore throws `Js::OutOfMemoryException` during the raytraced logo on Linux. - The CB metadata pass and `BLEND_BYPASS` fixes. - The aperture stub mentioned above. **Merge notes against `90c683946`:** - `BdaAbi::FaultReason`: #757 adds `ImageTable` and this PR adds `UnlinkedCall` at the same position. I kept both; each is referenced only by name. - `PlanBuilder::Collect`: main already has an iterative walk, so I kept main's version over this PR's second commit. **Tests on the combined stack, all passing:** - `scalar_call`, `scalar_swappc` - `agc_driver_scalar_swappc` and `_fetch` - `agc_driver_compute_user_data_calls` and `_registered` - `agc_driver_prepared_shaders` and its `deferred`, `deferred_undecodable`, `registered_workgroup(_sync)`, `indirect`, `uncached`, `debug` and `debug_failure` variants - the image-table, bindless, runtime-image, shader-memory and disk-cache tests </details> *Tested and written by Claude (AI assistant) on a contributor's machine.*
TripyFox commented 2026-10-13 06:00:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TripyFox on 2026-10-13T06:00:04Z.


Thanks for the second-vendor run. Good to see the user-data callee tests from #3294 pass alongside it, on Intel as well as NVIDIA.


Generated by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139312254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6139312254). Originally posted by [TripyFox](https://github.com/TripyFox) on 2026-10-13T06:00:04Z. --- Thanks for the second-vendor run. Good to see the user-data callee tests from #3294 pass alongside it, on Intel as well as NVIDIA. --- _Generated by [Claude Code](https://claude.ai/code)_
TripyFox commented 2026-10-13 06:00:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TripyFox on 2026-10-13T06:00:05Z.


Thanks for the in-game run. That confirms the call linking end to end, and that the next wall is the per-record T# (0x6340 loads the image descriptor through the {target, arg} record's pointer). That needs data-dependent descriptor support (#757 territory), so I'm leaving it out of this PR. Good to know Guardians of the Galaxy has the same shape.

Two notes on the merge:

  • FaultReason: agreed, keep both. The value only has to match between the shader and the driver in one build, so whichever of #757 and this PR lands second takes the next value. The BDA ABI version doesn't change.
  • PlanBuilder::Collect: on current main (88107b7de) it is still recursive, and it keeps visited values in a std::vector with a linear search. The iterative walk you kept is probably from #757/#758 in your stack. On plain main, the second commit is what stops the 30-callee R&C program from overflowing the stack (it did in agc_shader_replay here). If #757 lands first with its own iterative walk, I'll drop this commit.

On size: about 4.5 MB per linked program matches the ~29k-word programs here. Sharing one copy of a callee across call sites, and keeping copies out of programs that don't reach them, would be follow-ups.

I've rebased onto current main (88107b7de) to clear the conflict, and retested: the full ctest passes 1037/1037.


Generated by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139312550 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6139312550). Originally posted by [TripyFox](https://github.com/TripyFox) on 2026-10-13T06:00:05Z. --- Thanks for the in-game run. That confirms the call linking end to end, and that the next wall is the per-record T# (`0x6340` loads the image descriptor through the `{target, arg}` record's pointer). That needs data-dependent descriptor support (#757 territory), so I'm leaving it out of this PR. Good to know Guardians of the Galaxy has the same shape. Two notes on the merge: - `FaultReason`: agreed, keep both. The value only has to match between the shader and the driver in one build, so whichever of #757 and this PR lands second takes the next value. The BDA ABI version doesn't change. - `PlanBuilder::Collect`: on current `main` (`88107b7de`) it is still recursive, and it keeps visited values in a `std::vector` with a linear search. The iterative walk you kept is probably from #757/#758 in your stack. On plain `main`, the second commit is what stops the 30-callee R&C program from overflowing the stack (it did in `agc_shader_replay` here). If #757 lands first with its own iterative walk, I'll drop this commit. On size: about 4.5 MB per linked program matches the ~29k-word programs here. Sharing one copy of a callee across call sites, and keeping copies out of programs that don't reach them, would be follow-ups. I've rebased onto current `main` (`88107b7de`) to clear the conflict, and retested: the full `ctest` passes 1037/1037. --- _Generated by [Claude Code](https://claude.ai/code)_
adriadam10 commented 2026-10-13 15:32:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:32:21Z.

Review: DISMISSED


Checked on Linux (RADV, gfx1035): build, ctest of the touched directories and the PR's tests pass. I measured the wave-size assumptions on the hardware oracle (gfx1035): in wave32, v_cmp_*_e64 sN, v_add_co_u32 ..., sN and vcc_lo writes leave sN+1/vcc_hi untouched and v_cndmask_b32_e64 reads only the low SGPR; in wave64 both are written and read. 0xbf068080 sets SCC to 1 and 0xbf078080 to 0. So the link-pair dataflow and the SCC restore match the hardware. Still needed:

  • Unlinked calls are wider than this PR's case (GraphBuilder.cpp:1506, ControlFlowInstructions.cpp:286). Every s_swappc_b64 whose target isn't resolved now compiles, not only a table call whose target misses the linked set. On the usual dispatch path the fault is only logged, and the dispatch carries on. agc_driver_prepared_shaders_deferred prints [gpu] deferred write-back failed: shader stage 4 called address 0x0 ... which no linked callee of that call matches and passes, where main refused the shader. That turns a refusal into a run with the callee's effects missing. Please keep the refusal for calls that match neither the user-data shape nor the table shape. The fault is reasonable for a table call whose snapshot has gone stale, so keep it for that case.
  • No execution test of a linked table call. ScalarCall.cpp pins the linked words and the CFG, but nothing runs a table call on Vulkan. Please add one alongside tests/execution/ComputeUserDataCalls.cpp. It should cover:
    • a two-record table whose callees write different values, with the index from user data choosing each one;
    • the call made once with SCC 0 and once with SCC 1, with the callee writing s_cselect of it, to pin "the callee sees the caller's SCC";
    • a dispatch whose loaded target is not in the linked set, checked on a path that reports the fault.
  • PreparedShaders.cpp:608: DeferredRegistration now passes whether or not the fault is recorded. Please assert that the UnlinkedCall fault is reported, or move this case to the test above.
  • Minor: the Unlinked calls line is the last one in docs/dev/debt/shader.md (line 116), and #4048 and #4926 already conflict with this PR there. Placing it earlier in the section avoids the next adjacency conflict.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5506066728 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#pullrequestreview-5506066728). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:32:21Z. **Review:** DISMISSED --- Checked on Linux (RADV, gfx1035): build, ctest of the touched directories and the PR's tests pass. I measured the wave-size assumptions on the hardware oracle (gfx1035): in wave32, `v_cmp_*_e64 sN`, `v_add_co_u32 ..., sN` and `vcc_lo` writes leave `sN+1`/`vcc_hi` untouched and `v_cndmask_b32_e64` reads only the low SGPR; in wave64 both are written and read. `0xbf068080` sets SCC to 1 and `0xbf078080` to 0. So the link-pair dataflow and the SCC restore match the hardware. Still needed: - **Unlinked calls are wider than this PR's case** (`GraphBuilder.cpp:1506`, `ControlFlowInstructions.cpp:286`). Every `s_swappc_b64` whose target isn't resolved now compiles, not only a table call whose target misses the linked set. On the usual dispatch path the fault is only logged, and the dispatch carries on. `agc_driver_prepared_shaders_deferred` prints `[gpu] deferred write-back failed: shader stage 4 called address 0x0 ... which no linked callee of that call matches` and passes, where `main` refused the shader. That turns a refusal into a run with the callee's effects missing. Please keep the refusal for calls that match neither the user-data shape nor the table shape. The fault is reasonable for a table call whose snapshot has gone stale, so keep it for that case. - **No execution test of a linked table call.** `ScalarCall.cpp` pins the linked words and the CFG, but nothing runs a table call on Vulkan. Please add one alongside `tests/execution/ComputeUserDataCalls.cpp`. It should cover: - a two-record table whose callees write different values, with the index from user data choosing each one; - the call made once with SCC 0 and once with SCC 1, with the callee writing `s_cselect` of it, to pin "the callee sees the caller's SCC"; - a dispatch whose loaded target is not in the linked set, checked on a path that reports the fault. - **`PreparedShaders.cpp:608`**: `DeferredRegistration` now passes whether or not the fault is recorded. Please assert that the `UnlinkedCall` fault is reported, or move this case to the test above. - Minor: the `Unlinked calls` line is the last one in `docs/dev/debt/shader.md` (line 116), and #4048 and #4926 already conflict with this PR there. Placing it earlier in the section avoids the next adjacency conflict.
TripyFox commented 2026-10-13 16:52:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TripyFox on 2026-10-13T16:52:02Z.


Thanks for measuring the wave-size and SCC assumptions on gfx1035.

Pushed a third commit for the review:

  • Refusal kept. The linker now returns the program counters of the fallback s_swappc_b64 it emits. The driver passes them in the request (GuestContext::linkedCallFallbacks); the field is serialized in request format 24 and is part of the recompile cache key. GraphBuilder faults only at those calls. Every other unresolved s_swappc_b64 throws at compile time again, with main's messages, so ScalarSwappc.cpp and PreparedShaders.cpp are back to main's expectations.
  • Execution test. tests/execution/ComputeTableCalls.cpp (agc_driver_compute_table_calls) runs a linked two-record table on Vulkan in wave64 and wave32:
    • the index from user data picks the record;
    • the caller sets SCC from user data, and each callee returns s_cselect of it, so all four record/SCC pairs check that the callee sees the caller's SCC;
    • a record past the table loads target 0, and the test checks that the UnlinkedCall fault is reported (called address 0x0 ... which no linked callee of that call matches) and that no lane stores.
  • Debt line. Unlinked calls now opens the Functional section of docs/dev/debt/shader.md, away from the lines #4048 and #4926 touch, and it says that only the table fallback faults.

Full ctest passes 1087/1087 locally (the agc_shader_memory request-format check now expects version 24 and round-trips the new field), and the conventions check passes.


Generated by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150658034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6150658034). Originally posted by [TripyFox](https://github.com/TripyFox) on 2026-10-13T16:52:02Z. --- Thanks for measuring the wave-size and SCC assumptions on gfx1035. Pushed a third commit for the review: - **Refusal kept.** The linker now returns the program counters of the fallback `s_swappc_b64` it emits. The driver passes them in the request (`GuestContext::linkedCallFallbacks`); the field is serialized in request format 24 and is part of the recompile cache key. `GraphBuilder` faults only at those calls. Every other unresolved `s_swappc_b64` throws at compile time again, with main's messages, so `ScalarSwappc.cpp` and `PreparedShaders.cpp` are back to main's expectations. - **Execution test.** `tests/execution/ComputeTableCalls.cpp` (`agc_driver_compute_table_calls`) runs a linked two-record table on Vulkan in wave64 and wave32: - the index from user data picks the record; - the caller sets SCC from user data, and each callee returns `s_cselect` of it, so all four record/SCC pairs check that the callee sees the caller's SCC; - a record past the table loads target 0, and the test checks that the `UnlinkedCall` fault is reported (`called address 0x0 ... which no linked callee of that call matches`) and that no lane stores. - **Debt line.** `Unlinked calls` now opens the Functional section of `docs/dev/debt/shader.md`, away from the lines #4048 and #4926 touch, and it says that only the table fallback faults. Full `ctest` passes 1087/1087 locally (the `agc_shader_memory` request-format check now expects version 24 and round-trips the new field), and the conventions check passes. --- _Generated by [Claude Code](https://claude.ai/code)_
tv7 commented 2026-10-13 17:54:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-13T17:54:57Z.


@TripyFox a table-loaded call target this head does not link yet, in case it fits the design. Silent Hill: Townfall (PPSA33286, Unreal Engine), compute shader 0x16402d6e00 (wave64; 0x1640286900 and 0x16402b0500 have the same code). Windows 11, RTX 3070, main 8cf6a0bc3 + #5176 (needed to get past the dispatch first) + this head. The title still stops with computed/data-dependent s_swappc_b64 call target at program counter 0x00000134 is not statically resolvable.

The difference from #3274 is where the descriptor comes from: a constant address, not user data.

0x0f8  s_mov_b32  vcc_lo, 0xe0040000
0x100  s_mov_b32  vcc_hi, 0x0000000f
0x108  s_load_dwordx4        s[4:7], vcc, 0x0           ; descriptor at 0xF_E0040000
0x114  s_buffer_load_dwordx2 s[14:15], s[4:7], 0x20     ; target
0x120  s_cmp_eq_u32 0, s14
0x124  s_cbranch_scc1  -> 0x138                         ; no call when the target is 0
0x128  s_buffer_load_dwordx2 s[16:17], s[4:7], 0x28     ; argument pair
0x134  s_swappc_b64 s[14:15], s[14:15]

The offsets are immediates, so there is one target per dispatch, and the shader skips the call when it reads 0. I have not checked what the console maps at 0xF_E0040000 or what AnyPS5 maps there.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6151785582 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6151785582). Originally posted by [tv7](https://github.com/tv7) on 2026-10-13T17:54:57Z. --- @TripyFox a table-loaded call target this head does not link yet, in case it fits the design. Silent Hill: Townfall (PPSA33286, Unreal Engine), compute shader `0x16402d6e00` (wave64; `0x1640286900` and `0x16402b0500` have the same code). Windows 11, RTX 3070, main `8cf6a0bc3` + #5176 (needed to get past the dispatch first) + this head. The title still stops with `computed/data-dependent s_swappc_b64 call target at program counter 0x00000134 is not statically resolvable`. The difference from #3274 is where the descriptor comes from: a constant address, not user data. ``` 0x0f8 s_mov_b32 vcc_lo, 0xe0040000 0x100 s_mov_b32 vcc_hi, 0x0000000f 0x108 s_load_dwordx4 s[4:7], vcc, 0x0 ; descriptor at 0xF_E0040000 0x114 s_buffer_load_dwordx2 s[14:15], s[4:7], 0x20 ; target 0x120 s_cmp_eq_u32 0, s14 0x124 s_cbranch_scc1 -> 0x138 ; no call when the target is 0 0x128 s_buffer_load_dwordx2 s[16:17], s[4:7], 0x28 ; argument pair 0x134 s_swappc_b64 s[14:15], s[14:15] ``` The offsets are immediates, so there is one target per dispatch, and the shader skips the call when it reads 0. I have not checked what the console maps at `0xF_E0040000` or what AnyPS5 maps there. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Tamalero commented 2026-10-13 18:18:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-13T18:18:22Z.


A run on discrete RDNA2 under RADV with the third commit, to go with the gfx1035 measurements in the review and the NVIDIA and Intel runs.

Setup: Linux (Ubuntu 24.04), GCC 13, Release, AMD Radeon PRO V620 (Navi 21, gfx1030), RADV from Mesa 25.2.8, VK_ICD_FILENAMES limited to RADV. The head 677e8e7f0 merged into main 18c438b10 with no conflicts.

  • Full ctest: 1072 of 1072 pass. 12 are skipped, as on plain main on this card: the headless video-out tests, agc_driver_ngg_vertex_wave_reduction (RADV reports a subgroup size of 64) and agc_driver_oversized_dispatch.
  • The tests this PR touches pass with --repeat until-fail:3, 17 of 17 with ANYPS5_REQUIRE_VULKAN=1: agc_driver_compute_table_calls, agc_driver_scalar_swappc[_fetch], scalar_swappc, scalar_call, agc_driver_compute_user_data_calls[_registered], the agc_driver_prepared_shaders* family and agc_shader_memory.
  • agc_driver_compute_table_calls runs both widths natively here. The device's default subgroup is 64, and wave32 programs get 32 (Wave32 programs run on subgroups of 32). The record past the table reports the expected fault once per width (called address 0x0 at program counter 0xdc, which no linked callee of that call matches), and the test passes.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152204537 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6152204537). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-13T18:18:22Z. --- A run on discrete RDNA2 under RADV with the third commit, to go with the gfx1035 measurements in the review and the NVIDIA and Intel runs. Setup: Linux (Ubuntu 24.04), GCC 13, Release, AMD Radeon PRO V620 (Navi 21, gfx1030), RADV from Mesa 25.2.8, `VK_ICD_FILENAMES` limited to RADV. The head `677e8e7f0` merged into `main` `18c438b10` with no conflicts. - **Full `ctest`: 1072 of 1072 pass.** 12 are skipped, as on plain `main` on this card: the headless video-out tests, `agc_driver_ngg_vertex_wave_reduction` (RADV reports a subgroup size of 64) and `agc_driver_oversized_dispatch`. - **The tests this PR touches pass with `--repeat until-fail:3`**, 17 of 17 with `ANYPS5_REQUIRE_VULKAN=1`: `agc_driver_compute_table_calls`, `agc_driver_scalar_swappc[_fetch]`, `scalar_swappc`, `scalar_call`, `agc_driver_compute_user_data_calls[_registered]`, the `agc_driver_prepared_shaders*` family and `agc_shader_memory`. - **`agc_driver_compute_table_calls` runs both widths natively here.** The device's default subgroup is 64, and wave32 programs get 32 (`Wave32 programs run on subgroups of 32`). The record past the table reports the expected fault once per width (`called address 0x0 at program counter 0xdc, which no linked callee of that call matches`), and the test passes. *Tested and written by Claude (AI assistant) on a contributor's machine.*
oneandonlydean commented 2026-10-14 05:10:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:10:33Z.


Please rebase: core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp conflicts with main in the trailer after version >= 21u (main now requires the float16 byte from version 22). Main is still on request format 23, so 24 for linkedCallFallbacks stays free. The Silent Hill: Townfall shape (descriptor at a constant address) is a separate follow-up, not for this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161389538 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6161389538). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:10:33Z. --- Please rebase: `core/shader/recompiler/ControlFlow/src/RequestSerializer.cpp` conflicts with main in the trailer after `version >= 21u` (main now requires the float16 byte from version 22). Main is still on request format 23, so 24 for `linkedCallFallbacks` stays free. The Silent Hill: Townfall shape (descriptor at a constant address) is a separate follow-up, not for this PR.
TripyFox commented 2026-10-14 10:34:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TripyFox on 2026-10-14T10:34:50Z.


Rebased onto main (23e93c054). Main took request format 24 in #4201 in the meantime, so linkedCallFallbacks is now format 25; the float16 byte check and the trailing-data check from main are kept. Full ctest 1146/1146 on Windows/MinGW, conventions check passes. Agreed on Silent Hill: Townfall, that will be a separate follow-up.


Generated by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6166392739 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6166392739). Originally posted by [TripyFox](https://github.com/TripyFox) on 2026-10-14T10:34:50Z. --- Rebased onto main (23e93c054). Main took request format 24 in #4201 in the meantime, so `linkedCallFallbacks` is now format 25; the float16 byte check and the trailing-data check from main are kept. Full `ctest` 1146/1146 on Windows/MinGW, conventions check passes. Agreed on Silent Hill: Townfall, that will be a separate follow-up. --- _Generated by [Claude Code](https://claude.ai/code)_
oneandonlydean commented 2026-10-14 12:14:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T12:14:23Z.


Rebased on main: linked call fallbacks moved to request format 26 (25 is now dithered coverage), and the vertex user-data tail link fills linked.code. Full ctest passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6168086541 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6168086541). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T12:14:23Z. --- Rebased on main: linked call fallbacks moved to request format 26 (25 is now dithered coverage), and the vertex user-data tail link fills `linked.code`. Full `ctest` passes.
oneandonlydean commented 2026-10-14 17:50:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T17:50:57Z.


Rebased onto main again: UnlinkedCall now comes after ImageTable, and the SRT walk commit was dropped since main already has the same fix. Full ctest passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174722978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6174722978). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T17:50:57Z. --- Rebased onto main again: `UnlinkedCall` now comes after `ImageTable`, and the SRT walk commit was dropped since main already has the same fix. Full `ctest` passes.
github-actions[bot] commented 2026-10-14 17:52:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T17:52:25Z.


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
#5176 docs/dev/debt/shader.md L126-127
#5200 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L2905, L3017, L3133-3135
core/shader/recompiler/tests/RequestSerializerTests.cpp L205-207, L242-244, L265-266, L387-389, L401, L403
#5304 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp L35
#5314 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L2905, L3017, L3135
core/shader/recompiler/tests/RequestSerializerTests.cpp L205-207, L242-244, L265-266, L387-388, L401, L403
#5884 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L2905, L3017
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6174750220 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6174750220). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T17:52:25Z. --- <!-- 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 | |---|---|---|---| | #5176 | `docs/dev/debt/shader.md` [L126-127](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/docs/dev/debt/shader.md#L126-L127) | | | | #5200 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` [L2905](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L2905), [L3017](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L3017), [L3133-3135](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L3133-L3135)<br>`core/shader/recompiler/tests/RequestSerializerTests.cpp` [L205-207](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L205-L207), [L242-244](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L242-L244), [L265-266](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L265-L266), [L387-389](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L387-L389), [L401](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L401), [L403](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L403) | | | | #5304 | `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp` [L35](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp#L35) | | | | #5314 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` [L2905](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L2905), [L3017](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L3017), [L3135](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L3135)<br>`core/shader/recompiler/tests/RequestSerializerTests.cpp` [L205-207](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L205-L207), [L242-244](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L242-L244), [L265-266](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L265-L266), [L387-388](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L387-L388), [L401](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L401), [L403](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/shader/recompiler/tests/RequestSerializerTests.cpp#L403) | | | | #5884 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` [L2905](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L2905), [L3017](https://github.com/boykopovar/AnyPS5/blob/a050f856f14e7b55c5de8a819aefe1ea894a3b72/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L3017) | | |
fma-rc commented 2026-10-14 18:31:29 +00:00 (Migrated from github.com)

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


1348 Ex Voto (PPSA24249) is a second title with the Silent Hill: Townfall shape. On main 32e810db4 with this PR at 3c1f43948 plus #5176, the call and ordered-append tests pass (18 of 18) and the title stops at 119 s with a warm shader cache:

compute shader 0x1680648b00 ... computed/data-dependent s_swappc_b64 call target at program counter 0x00000130 is not statically resolvable

From the dumped request: the shader loads its descriptor with s_load_dwordx4 from the constant address 0xF_E0040000 (vcc set to 0xe0040000 / 0xf), reads the target with s_buffer_load_dwordx2 at offset 0x20, skips the call when that is null, and otherwise calls it with s_swappc_b64. Nothing in AnyPS5 maps that address, so the descriptor is in the title's own memory and could be read when the dispatch is recorded.

Is anyone taking the follow-up? If not, I'd like to write it on top of this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175482064 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6175482064). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-14T18:31:29Z. --- 1348 Ex Voto (PPSA24249) is a second title with the Silent Hill: Townfall shape. On `main` 32e810db4 with this PR at 3c1f43948 plus #5176, the call and ordered-append tests pass (18 of 18) and the title stops at 119 s with a warm shader cache: `compute shader 0x1680648b00 ... computed/data-dependent s_swappc_b64 call target at program counter 0x00000130 is not statically resolvable` From the dumped request: the shader loads its descriptor with `s_load_dwordx4` from the constant address 0xF_E0040000 (vcc set to 0xe0040000 / 0xf), reads the target with `s_buffer_load_dwordx2` at offset 0x20, skips the call when that is null, and otherwise calls it with `s_swappc_b64`. Nothing in AnyPS5 maps that address, so the descriptor is in the title's own memory and could be read when the dispatch is recorded. Is anyone taking the follow-up? If not, I'd like to write it on top of this PR.
tv7 commented 2026-10-14 18:34:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-14T18:34:45Z.


@fma-rc that would be great, please go ahead. Silent Hill: Townfall has the same shape at 0x134, and I can test your head on it. One thing to know first: the descriptor isn't in the title's memory. I looked at this for Silent Hill, and 0xF_E0040000 belongs to Sony's libSceAgc, so reading it at record time on main reads nothing the title wrote.

What the shipped libSceAgc does (from the backport copy that ships with some dumps; I only read it, nothing copied):

  • At init it takes the reserved direct-memory block (other PS5 projects pin it at 0xF_E0000000, 2 MiB), places its "FS table" at base + 0x40000, zeroes the first 0x60 bytes (six 16-byte V# slots), and aborts with [Agc] FS Table offset has shifted. This is not survivable. if the table is not at exactly 0xF_E0040000.
  • Four exports access it: -pjHhph0ZUc writes V# slot i (0..5), OXDc0KCnUhs reads it, 86rJnbZUpr4 writes a qword at 0xF_E0040010 + 8·i, and NbiQSQ-UL+M reads one. Silent Hill does not import any of them.
  • During init the library loads a handful of its own built-in GPU routines and writes {routine address, 0} pairs into a 128-byte buffer. It then sets slot 0 to a V# over that buffer (stride 16, 8 records). So the qword at +0x20 that the title loads is one of Sony's routines, not null. The one Silent Hill reaches is 0xd8 bytes long. It starts with s_getreg_b32 of HW_ID2 and reads trap temporaries (ttmp7), which AnyPS5's decoder rejects today (unsupported scalar source operand code 115).

So on hardware the call does happen. In Silent Hill the shader reads nothing back from it: after the call it builds M0 from its own registers and never reads s[16:17]. That fits an ordering step before ds_ordered_count, which #5176's debt entry already lists as not modeled.

What I measured on Silent Hill with a local stub that skips the call (details in #5176): with #5176 as it is, the title hangs within minutes. With the counter addressed by offset0 (the review's suggestion), it runs the full 900 s. So skipping this call did not cause the hang; #5176's M0 handling did.

A direction that would match this: AnyPS5 commits the table at 0xF_E0040000 itself at init, with slot 0 pointing to a buffer whose routine entries are an AnyPS5-written routine that only returns (s_setpc_b64 s[14:15]). Your follow-up then links that target like any other table callee. It would be worth adding a debt entry saying the routine's ordering work is not modeled, and possibly the four exports. Your call on the design, of course.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175543472 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6175543472). Originally posted by [tv7](https://github.com/tv7) on 2026-10-14T18:34:45Z. --- @fma-rc that would be great, please go ahead. Silent Hill: Townfall has the same shape at 0x134, and I can test your head on it. One thing to know first: the descriptor isn't in the title's memory. I looked at this for Silent Hill, and 0xF_E0040000 belongs to Sony's `libSceAgc`, so reading it at record time on `main` reads nothing the title wrote. What the shipped `libSceAgc` does (from the backport copy that ships with some dumps; I only read it, nothing copied): - At init it takes the reserved direct-memory block (other PS5 projects pin it at 0xF_E0000000, 2 MiB), places its "FS table" at base + 0x40000, zeroes the first 0x60 bytes (six 16-byte V# slots), and aborts with `[Agc] FS Table offset has shifted. This is not survivable.` if the table is not at exactly 0xF_E0040000. - Four exports access it: `-pjHhph0ZUc` writes V# slot `i` (0..5), `OXDc0KCnUhs` reads it, `86rJnbZUpr4` writes a qword at 0xF_E0040010 + 8·i, and `NbiQSQ-UL+M` reads one. Silent Hill does not import any of them. - During init the library loads a handful of its own built-in GPU routines and writes `{routine address, 0}` pairs into a 128-byte buffer. It then sets slot 0 to a V# over that buffer (stride 16, 8 records). So the qword at +0x20 that the title loads is one of Sony's routines, not null. The one Silent Hill reaches is 0xd8 bytes long. It starts with `s_getreg_b32` of HW_ID2 and reads trap temporaries (`ttmp7`), which AnyPS5's decoder rejects today (`unsupported scalar source operand code 115`). So on hardware the call does happen. In Silent Hill the shader reads nothing back from it: after the call it builds M0 from its own registers and never reads `s[16:17]`. That fits an ordering step before `ds_ordered_count`, which #5176's debt entry already lists as not modeled. What I measured on Silent Hill with a local stub that skips the call (details in #5176): with #5176 as it is, the title hangs within minutes. With the counter addressed by `offset0` (the review's suggestion), it runs the full 900 s. So skipping this call did not cause the hang; #5176's M0 handling did. A direction that would match this: AnyPS5 commits the table at 0xF_E0040000 itself at init, with slot 0 pointing to a buffer whose routine entries are an AnyPS5-written routine that only returns (`s_setpc_b64 s[14:15]`). Your follow-up then links that target like any other table callee. It would be worth adding a debt entry saying the routine's ordering work is not modeled, and possibly the four exports. Your call on the design, of course. AI-assisted: yes
fma-rc commented 2026-10-14 20:30:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-14T20:30:02Z.


@tv7 thanks, that saved me a lot. I checked it against the PS5 12.00 libSceAgc and libSceAgcDriver modules and it matches: the driver allocates 2 MiB of direct memory and maps it at 0xF_E0000000 at init, libSceAgc takes its part through Um_jkyDy9rI and places the table at 0xF_E0040000 (aborting otherwise), zeroes the six 16-byte slots, and sets slot 0 to a V# with stride 16 over eight {routine, 0} records, the third of which is what the title calls. The slot accessors return 0x8a6c000b for a slot of 6 or more and 0x8a6c002f when the table is elsewhere.

AnyPS5 maps nothing there yet, so the follow-up will map that block, fill the table at init with routines that only return, and link that callee on top of this PR. It is up as #6160 (branch fma-rc:feat/agc-fs-table-calls). On main 2559e9623 Ex Voto stops at 57 s on this call; with it, no stop in 300 s cold or warm. @tv7 Silent Hill: Townfall on that head would be the second title, if you still have time.

Edit: an earlier version of this comment said the block was not at 0xF_E0000000; the driver module shows it is.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6177781523 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4706#issuecomment-6177781523). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-14T20:30:02Z. --- @tv7 thanks, that saved me a lot. I checked it against the PS5 12.00 `libSceAgc` and `libSceAgcDriver` modules and it matches: the driver allocates 2 MiB of direct memory and maps it at 0xF_E0000000 at init, `libSceAgc` takes its part through `Um_jkyDy9rI` and places the table at 0xF_E0040000 (aborting otherwise), zeroes the six 16-byte slots, and sets slot 0 to a V# with stride 16 over eight `{routine, 0}` records, the third of which is what the title calls. The slot accessors return `0x8a6c000b` for a slot of 6 or more and `0x8a6c002f` when the table is elsewhere. AnyPS5 maps nothing there yet, so the follow-up will map that block, fill the table at init with routines that only return, and link that callee on top of this PR. It is up as #6160 (branch `fma-rc:feat/agc-fs-table-calls`). On `main` 2559e9623 Ex Voto stops at 57 s on this call; with it, no stop in 300 s cold or warm. @tv7 Silent Hill: Townfall on that head would be the second title, if you still have time. Edit: an earlier version of this comment said the block was not at 0xF_E0000000; the driver module shows it is.
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!4706
No description provided.