fix(shader): link a table call whose V# is a slice of an s_load_dwordx8 or s_load_dwordx16 #8070

Merged
thuanquang merged 2 commits from upstream-pr/8070 into main 2026-10-23 16:40:11 +00:00
thuanquang commented 2026-10-19 19:35:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T19:35:46Z.


What

Little Nightmares Enhanced Edition (PPSA10737) stops, after #7413 and a fix for #7395's GetImageResource case, in compute shader 0x200c340000 (@klosixgaming-arch on #7413):

computed/data-dependent s_swappc_b64 call target at program counter 0x000008b4 is not statically resolvable

Four of that shader's six table calls take their V# from s[88:91] and s[92:95], which one s_load_dwordx8 s[88:95], s[0:1], 0x10 loads. FindTableCalls only accepts a descriptor written by an s_load_dwordx4, so it skips them.

It now also accepts a V# that is a 4-dword-aligned slice of an s_load_dwordx8 or s_load_dwordx16: the descriptor registers must start a multiple of 4 dwords into the load's destination and lie inside it. The V# is read at the load's offset plus 16 bytes per slice before it. An s_load_dwordx4 is the one-slice case, so it behaves as before. The debt entry for table callees says so.

This links the calls at 0x0460, 0x08b4 and 0x0c7c, as @klosixgaming-arch found locally. The fourth call (0x0d2c) then stops with the table callees of the call at program counter 0x00000d2c lands out of the 16-bit branch range, because LinkCalls appends each call's chain and callee copies in call order. That is a separate change; @klosixgaming-arch proposed s_branch relay hops for it on #7413.

Tested

Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, rebased onto main 1edbe4b5e, which has #7413. Rebased again onto main 4ec064d29b on 2026-10-22 (head 73c9c2a762; the only conflict was the debt entry's neighbouring line): scalar_call and agc_driver_compute_table_calls pass 3 of 3 on it. The runs below use VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan-ValidationLayers vulkan-sdk-1.4.363.0, built locally), ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V, with the implicit overlay layers on this PC switched off (VK_LOADER_LAYERS_DISABLE=~implicit~). No log reports the layer as not found, and a run with VK_LOADER_DEBUG=layer shows the loader inserting it as an instance and a device layer.

  • scalar_call: FindTableCalls on the table caller with its s_load_dwordx4 swapped for an s_load_dwordx8 or s_load_dwordx16 into s[24:…]:
    • slices 0 and 1 of the x8, and slices 2 and 3 of the x16, link with descriptor offsets 0x270, 0x280, 0x290 and 0x2a0;
    • a buffer load through registers past the x8, and one through a misaligned register range, link nothing.
  • agc_driver_compute_table_calls: a caller whose V# is the second half of an s_load_dwordx8 at offset 0x10. The first half is a zero V#, so reading the wrong slice would fail. The first record's callee runs with SCC 0 and the second record's with SCC 1, in wave32 and wave64.
  • With this change, scalar_call, agc_driver_compute_table_calls, agc_driver_compute_fs_table_calls and agc_driver_compute_user_data_calls pass 3 of 3. Eight other tests of s_swappc_b64 calls and control flow also pass 3 of 3: scalar_swappc, agc_driver_scalar_swappc, agc_driver_scalar_swappc_fetch, agc_driver_scalar_static_call, agc_driver_compute_user_data_calls_registered, agc_shader_control_flow, agc_shader_control_flow_iteration_selection_off and agc_shader_control_flow_forced_fallback.
  • With GraphBuilder.cpp from main, scalar_call fails (scalar call regression) and agc_driver_compute_table_calls fails with the first record's callee through the second half of an s_load_dwordx8 (wave64): lane 0 is 3405691582, expected 16. The other two pass.
  • main 1edbe4b5e with its own versions of the tests: all four pass.
  • scalar_call also checks three V#s that an s_load_dwordx8 writes only in part, or not on a 4-dword boundary from its first register; none links: the load into s[26:33] with the V# at s[28:31], the same load with the V# at s[24:27], and a load into s[22:29] with the V# at s[28:31]. With the (descriptor - loaded) % 4u clause deleted, the first links at descriptor offset 0x278 and scalar_call fails (scalar call regression).
  • Deleting descriptor < loaded, the dataDwordCount bound, or both changes nothing: scalar_call passes, and a temporary sweep of s_load_dwordx4/x8/x16 destinations from s0 to vcc_hi against V# bases from s0 to s104 (17172 programs) accepts the same 148 calls. The writer search only returns a load that writes part of the V#, so a V# that starts before the load or runs past its end is never 4-dword aligned to it, and the alignment clause rejects it first. The two bounds stay as the statement that the slice lies inside the load.
  • No log has a VUID- error: not the runs with this change, the run with GraphBuilder.cpp from main, or the run on main.
  • @wachi35676 ran the earlier head b521b3eb5 (the same fix commit, before the test commit with the three slice-guard ScalarCall cases was added), merged into main 9127ea36d, on an NVIDIA RTX 5070 Ti (driver 617.42) and an AMD Radeon iGPU (RDNA2, 1002:13c0, AMD proprietary driver 2026.04.17), Windows 11 Home 26300, ANYPS5_REQUIRE_VULKAN=1: scalar_call, agc_driver_compute_table_calls, agc_driver_compute_fs_table_calls and control_flow_graph pass on both. With GraphBuilder.cpp back to main, scalar_call fails, and agc_driver_compute_table_calls fails on both with the message above. On WSL Ubuntu 24.04 with llvmpipe (Mesa 25.2.8), with this and six other PRs merged, 61 of the 62 related tests pass, these four included; the other fails on a WSL write-watch limit.
  • python tools/check_conventions.py --base origin/main with this title and body reports no errors and one warning: the table callees debt entry is over 1000 characters (2981 here, 2908 on main).
  • python tools/pr_overlap.py --branch fix/table-call-wide-descriptor (on 4ec064d29b, 2026-10-22): #8658 (macOS host support) adds Apple-only lines right after the calls.push_back this PR changes, and #9068 rewrites the same Table callees debt entry; neither does what this PR does, and whichever merges second needs a rebase. Among the open PRs it could not compare (they conflict with main), #6977 also changes GraphBuilder.cpp outside FindTableCalls, and #6044 moves ScalarCall.cpp to core/libs/tests/graphics/.
  • Not run: the full suite on this head.
  • Not tested: PPSA10737 itself (its next stop is the branch range above).

Titles, from testers:

  • @JJenkx, Severed Steel (PPSA05106 01.000.000; Linux 7.2.9, RX 6650 XT, RADV Mesa 26.2.4). main 38d3c0858a + #8847 stops 24 s in on compute shader 0x2007910000: computed/data-dependent s_swappc_b64 call target at program counter 0x74 is not statically resolvable. With only libSceAgcDriver.prx from that main with this PR merged, there is no recompiler stop, and with APS5_PLAYGO_UNLISTED_CHUNKS=installed it reaches the campaign New Game menu. JJenkx did not check that this shader is the s_load_dwordx8 slice case.
  • @frankea, Ghostrunner (PPSA03685 01.000.005; Windows 11, RTX 4090, 616.92). Compute shader 0x200c520000 makes a table call at 0x89c through a V# from the first four dwords of an s_load_dwordx8 s[88:95], s[0:1]. With #9068 alone it stops there; with this PR on top, the shader links. The title's next stops are outside this PR: the structurizer's time on the 4,750-block graph, which is longer than Unreal's 120 s watchdog, and then #7459.
  • @zaidhawk, Persona 3 Reload (PPSA10872; Windows 11, RTX 5090, 617.42). Entering the Iwatodai Station strip mall, compute shader 0x2014960000 makes a table call at 0x854 through the V# s[88:91] from an s_load_dwordx8 s[88:95] at 0x46c. On main b27924d85 + #7048 + #9068 it stops there (computed/data-dependent s_swappc_b64 call target at program counter 0x00000854 is not statically resolvable); with this PR's head 73c9c2a76 applied, the call links. The next stop is a table callee longer than ReadUserDataCallee's 64 KiB limit (on #9068).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA10737 #6275 (the 0x08b4 stop on compute shader 0x200c340000; the title then stops on the 16-bit branch range at 0x0d2c, a separate change); PPSA05106 #9594 (the start-up stop at 0x74, @JJenkx); PPSA03685 #7320 together with #9068 (the call at 0x89c, @frankea); PPSA10872 #9692 together with #7048 and #9068 (the call at 0x854, @zaidhawk)
  • GPUs tested: AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, Windows 11 26200; by @wachi35676: NVIDIA RTX 5070 Ti, driver 617.42, and AMD Radeon iGPU (RDNA2, 1002:13c0), AMD proprietary driver 2026.04.17, Windows 11 Home 26300; llvmpipe (Mesa 25.2.8), WSL Ubuntu 24.04; title runs by @JJenkx: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4, Linux 7.2.9; by @frankea: NVIDIA RTX 4090, driver 616.92, Windows 11; by @zaidhawk: NVIDIA RTX 5090, driver 617.42, Windows 11
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4926340820 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8070). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-19T19:35:46Z. --- ### What Little Nightmares Enhanced Edition (PPSA10737) stops, after #7413 and a fix for #7395's `GetImageResource` case, in compute shader 0x200c340000 (@klosixgaming-arch on #7413): ``` computed/data-dependent s_swappc_b64 call target at program counter 0x000008b4 is not statically resolvable ``` Four of that shader's six table calls take their V# from `s[88:91]` and `s[92:95]`, which one `s_load_dwordx8 s[88:95], s[0:1], 0x10` loads. `FindTableCalls` only accepts a descriptor written by an `s_load_dwordx4`, so it skips them. It now also accepts a V# that is a 4-dword-aligned slice of an `s_load_dwordx8` or `s_load_dwordx16`: the descriptor registers must start a multiple of 4 dwords into the load's destination and lie inside it. The V# is read at the load's offset plus 16 bytes per slice before it. An `s_load_dwordx4` is the one-slice case, so it behaves as before. The debt entry for table callees says so. This links the calls at 0x0460, 0x08b4 and 0x0c7c, as @klosixgaming-arch found locally. The fourth call (0x0d2c) then stops with `the table callees of the call at program counter 0x00000d2c lands out of the 16-bit branch range`, because `LinkCalls` appends each call's chain and callee copies in call order. That is a separate change; @klosixgaming-arch proposed `s_branch` relay hops for it on #7413. ### Tested Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, rebased onto `main` `1edbe4b5e`, which has #7413. Rebased again onto `main` `4ec064d29b` on 2026-10-22 (head `73c9c2a762`; the only conflict was the debt entry's neighbouring line): `scalar_call` and `agc_driver_compute_table_calls` pass 3 of 3 on it. The runs below use `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan-ValidationLayers `vulkan-sdk-1.4.363.0`, built locally), `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V`, with the implicit overlay layers on this PC switched off (`VK_LOADER_LAYERS_DISABLE=~implicit~`). No log reports the layer as not found, and a run with `VK_LOADER_DEBUG=layer` shows the loader inserting it as an instance and a device layer. - `scalar_call`: `FindTableCalls` on the table caller with its `s_load_dwordx4` swapped for an `s_load_dwordx8` or `s_load_dwordx16` into `s[24:…]`: - slices 0 and 1 of the x8, and slices 2 and 3 of the x16, link with descriptor offsets 0x270, 0x280, 0x290 and 0x2a0; - a buffer load through registers past the x8, and one through a misaligned register range, link nothing. - `agc_driver_compute_table_calls`: a caller whose V# is the second half of an `s_load_dwordx8` at offset 0x10. The first half is a zero V#, so reading the wrong slice would fail. The first record's callee runs with SCC 0 and the second record's with SCC 1, in wave32 and wave64. - With this change, `scalar_call`, `agc_driver_compute_table_calls`, `agc_driver_compute_fs_table_calls` and `agc_driver_compute_user_data_calls` pass 3 of 3. Eight other tests of `s_swappc_b64` calls and control flow also pass 3 of 3: `scalar_swappc`, `agc_driver_scalar_swappc`, `agc_driver_scalar_swappc_fetch`, `agc_driver_scalar_static_call`, `agc_driver_compute_user_data_calls_registered`, `agc_shader_control_flow`, `agc_shader_control_flow_iteration_selection_off` and `agc_shader_control_flow_forced_fallback`. - With `GraphBuilder.cpp` from `main`, `scalar_call` fails (`scalar call regression`) and `agc_driver_compute_table_calls` fails with `the first record's callee through the second half of an s_load_dwordx8 (wave64): lane 0 is 3405691582, expected 16`. The other two pass. - `main` `1edbe4b5e` with its own versions of the tests: all four pass. - `scalar_call` also checks three V#s that an `s_load_dwordx8` writes only in part, or not on a 4-dword boundary from its first register; none links: the load into `s[26:33]` with the V# at `s[28:31]`, the same load with the V# at `s[24:27]`, and a load into `s[22:29]` with the V# at `s[28:31]`. With the `(descriptor - loaded) % 4u` clause deleted, the first links at descriptor offset 0x278 and `scalar_call` fails (`scalar call regression`). - Deleting `descriptor < loaded`, the `dataDwordCount` bound, or both changes nothing: `scalar_call` passes, and a temporary sweep of `s_load_dwordx4`/`x8`/`x16` destinations from `s0` to `vcc_hi` against V# bases from `s0` to `s104` (17172 programs) accepts the same 148 calls. The writer search only returns a load that writes part of the V#, so a V# that starts before the load or runs past its end is never 4-dword aligned to it, and the alignment clause rejects it first. The two bounds stay as the statement that the slice lies inside the load. - No log has a `VUID-` error: not the runs with this change, the run with `GraphBuilder.cpp` from `main`, or the run on `main`. - @wachi35676 ran the earlier head `b521b3eb5` (the same fix commit, before the test commit with the three slice-guard `ScalarCall` cases was added), merged into `main` `9127ea36d`, on an NVIDIA RTX 5070 Ti (driver 617.42) and an AMD Radeon iGPU (RDNA2, `1002:13c0`, AMD proprietary driver 2026.04.17), Windows 11 Home 26300, `ANYPS5_REQUIRE_VULKAN=1`: `scalar_call`, `agc_driver_compute_table_calls`, `agc_driver_compute_fs_table_calls` and `control_flow_graph` pass on both. With `GraphBuilder.cpp` back to `main`, `scalar_call` fails, and `agc_driver_compute_table_calls` fails on both with the message above. On WSL Ubuntu 24.04 with llvmpipe (Mesa 25.2.8), with this and six other PRs merged, 61 of the 62 related tests pass, these four included; the other fails on a WSL write-watch limit. - `python tools/check_conventions.py --base origin/main` with this title and body reports no errors and one warning: the table callees debt entry is over 1000 characters (2981 here, 2908 on `main`). - `python tools/pr_overlap.py --branch fix/table-call-wide-descriptor` (on `4ec064d29b`, 2026-10-22): #8658 (macOS host support) adds Apple-only lines right after the `calls.push_back` this PR changes, and #9068 rewrites the same Table callees debt entry; neither does what this PR does, and whichever merges second needs a rebase. Among the open PRs it could not compare (they conflict with `main`), #6977 also changes `GraphBuilder.cpp` outside `FindTableCalls`, and #6044 moves `ScalarCall.cpp` to `core/libs/tests/graphics/`. - Not run: the full suite on this head. - Not tested: PPSA10737 itself (its next stop is the branch range above). **Titles, from testers:** - @JJenkx, [Severed Steel](https://github.com/boykopovar/AnyPS5/pull/8070#issuecomment-6332254753) (PPSA05106 01.000.000; Linux 7.2.9, RX 6650 XT, RADV Mesa 26.2.4). `main` `38d3c0858a` + #8847 stops 24 s in on compute shader 0x2007910000: `computed/data-dependent s_swappc_b64 call target at program counter 0x74 is not statically resolvable`. With only `libSceAgcDriver.prx` from that `main` with this PR merged, there is no recompiler stop, and with `APS5_PLAYGO_UNLISTED_CHUNKS=installed` it reaches the campaign New Game menu. JJenkx did not check that this shader is the `s_load_dwordx8` slice case. - @frankea, [Ghostrunner](https://github.com/boykopovar/AnyPS5/pull/8070#issuecomment-6330349226) (PPSA03685 01.000.005; Windows 11, RTX 4090, 616.92). Compute shader 0x200c520000 makes a table call at 0x89c through a V# from the first four dwords of an `s_load_dwordx8 s[88:95], s[0:1]`. With #9068 alone it stops there; with this PR on top, the shader links. The title's next stops are outside this PR: the structurizer's time on the 4,750-block graph, which is longer than Unreal's 120 s watchdog, and then #7459. - @zaidhawk, [Persona 3 Reload](https://github.com/boykopovar/AnyPS5/pull/8070#issuecomment-6349682960) (PPSA10872; Windows 11, RTX 5090, 617.42). Entering the Iwatodai Station strip mall, compute shader 0x2014960000 makes a table call at `0x854` through the V# `s[88:91]` from an `s_load_dwordx8 s[88:95]` at `0x46c`. On `main` `b27924d85` + #7048 + #9068 it stops there (`computed/data-dependent s_swappc_b64 call target at program counter 0x00000854 is not statically resolvable`); with this PR's head `73c9c2a76` applied, the call links. The next stop is a table callee longer than `ReadUserDataCallee`'s 64 KiB limit (on #9068). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA10737 #6275 (the `0x08b4` stop on compute shader `0x200c340000`; the title then stops on the 16-bit branch range at `0x0d2c`, a separate change); PPSA05106 #9594 (the start-up stop at `0x74`, @JJenkx); PPSA03685 #7320 together with #9068 (the call at `0x89c`, @frankea); PPSA10872 #9692 together with #7048 and #9068 (the call at `0x854`, @zaidhawk) - [x] GPUs tested: AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, Windows 11 26200; by @wachi35676: NVIDIA RTX 5070 Ti, driver 617.42, and AMD Radeon iGPU (RDNA2, `1002:13c0`), AMD proprietary driver 2026.04.17, Windows 11 Home 26300; llvmpipe (Mesa 25.2.8), WSL Ubuntu 24.04; title runs by @JJenkx: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4, Linux 7.2.9; by @frankea: NVIDIA RTX 4090, driver 616.92, Windows 11; by @zaidhawk: NVIDIA RTX 5090, driver 617.42, Windows 11 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wachi35676 commented 2026-10-19 23:13:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T23:13:02Z.


NVIDIA and AMD iGPU runs, plus Linux, of b521b3eb5.

#7413 has since merged, and this head merges onto current main without conflicts. On top of the merged #7413, what is left is the 6-line FindTableCalls change and its tests, so "Depends on" can be cleared.

Windows 11 Home 26300, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, main 9127ea36d with this head merged. GPUs: RTX 5070 Ti (NVIDIA 617.42) and the AMD Radeon iGPU (RDNA2, 1002:13c0, AMD proprietary driver 2026.04.17, ANYPS5_GPU=AMD). Run with ANYPS5_REQUIRE_VULKAN=1.

  • scalar_call, agc_driver_compute_table_calls, agc_driver_compute_fs_table_calls and control_flow_graph pass on both GPUs.
  • Negative control: with GraphBuilder.cpp back to main, scalar_call fails. agc_driver_compute_table_calls fails on both GPUs with the first record's callee through the second half of an s_load_dwordx8 (wave64): lane 0 is 3405691582, expected 16.
  • I decoded the scalar_call words by hand:
    • 0xf40c0606 is s_load_dwordx8 s[24:31], s[12:13], and 0xf4100606 is s_load_dwordx16 s[24:39].
    • The buffer loads use bases s[24:27], s[28:31], s[32:35] and s[36:39], which are slices 0-3 at +0x00, +0x10, +0x20 and +0x30.
    • The rejected cases are s[32:35] against the x8 (past its end) and s[26:29] (not 4-aligned).
    • This matches the new bounds check: descriptor - loaded is a multiple of 4, and + 4 <= dataDwordCount.
  • Linux: WSL Ubuntu 24.04, GCC 13.3, llvmpipe (Mesa 25.2.8). The base is main 9127ea36d with #8078, #8046, #8069, #8070, #7668, #8015 and #8026 merged together. 61 of the 62 related tests pass, including these four. The other, agc_driver_depth_compare_copy, fails with the guest block is not write-watched after WSL reports asynchronous userfaultfd write protection failed, which is a limit of the environment.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6279409677 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8070#issuecomment-6279409677). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T23:13:02Z. --- NVIDIA and AMD iGPU runs, plus Linux, of `b521b3eb5`. #7413 has since merged, and this head merges onto current `main` without conflicts. On top of the merged #7413, what is left is the 6-line `FindTableCalls` change and its tests, so "Depends on" can be cleared. Windows 11 Home 26300, WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, `main` `9127ea36d` with this head merged. GPUs: RTX 5070 Ti (NVIDIA 617.42) and the AMD Radeon iGPU (RDNA2, `1002:13c0`, AMD proprietary driver 2026.04.17, `ANYPS5_GPU=AMD`). Run with `ANYPS5_REQUIRE_VULKAN=1`. - `scalar_call`, `agc_driver_compute_table_calls`, `agc_driver_compute_fs_table_calls` and `control_flow_graph` pass on both GPUs. - Negative control: with `GraphBuilder.cpp` back to `main`, `scalar_call` fails. `agc_driver_compute_table_calls` fails on both GPUs with `the first record's callee through the second half of an s_load_dwordx8 (wave64): lane 0 is 3405691582, expected 16`. - I decoded the `scalar_call` words by hand: - `0xf40c0606` is `s_load_dwordx8 s[24:31], s[12:13]`, and `0xf4100606` is `s_load_dwordx16 s[24:39]`. - The buffer loads use bases `s[24:27]`, `s[28:31]`, `s[32:35]` and `s[36:39]`, which are slices 0-3 at +0x00, +0x10, +0x20 and +0x30. - The rejected cases are `s[32:35]` against the x8 (past its end) and `s[26:29]` (not 4-aligned). - This matches the new bounds check: `descriptor - loaded` is a multiple of 4, and `+ 4 <= dataDwordCount`. - Linux: WSL Ubuntu 24.04, GCC 13.3, llvmpipe (Mesa 25.2.8). The base is `main` `9127ea36d` with #8078, #8046, #8069, #8070, #7668, #8015 and #8026 merged together. 61 of the 62 related tests pass, including these four. The other, `agc_driver_depth_compare_copy`, fails with `the guest block is not write-watched` after WSL reports `asynchronous userfaultfd write protection failed`, which is a limit of the environment. AI-assisted: yes (Claude Code); results above were run on this machine.
thuanquang commented 2026-10-20 05:37:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T05:37:25Z.


Thanks @wachi35676 for the NVIDIA, AMD iGPU and Linux runs and the hand decode. #7413 has merged, so I'll rebase this onto main, clear Depends on, and add your runs to the description.

@klosixgaming-arch, on #7413 you suggested s_branch relay hops for the stop that comes after this one on shader 0x200c340000:

the table callees of the call at program counter 0x00000d2c lands out of the 16-bit branch range

Are you opening that change? If you aren't, I'll pick it up after this PR. I'm asking first so we don't both write it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6284217312 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8070#issuecomment-6284217312). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T05:37:25Z. --- Thanks @wachi35676 for the NVIDIA, AMD iGPU and Linux runs and the hand decode. #7413 has merged, so I'll rebase this onto `main`, clear `Depends on`, and add your runs to the description. @klosixgaming-arch, on #7413 you suggested `s_branch` relay hops for the stop that comes after this one on shader `0x200c340000`: ``` the table callees of the call at program counter 0x00000d2c lands out of the 16-bit branch range ``` Are you opening that change? If you aren't, I'll pick it up after this PR. I'm asking first so we don't both write it.
frankea commented 2026-10-22 01:20:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-22T01:20:11Z.


Ghostrunner data with this PR and #9068 together (data only).

Setup: Ghostrunner (PPSA03685 01.000.005, Unreal Engine 4) on an RTX 4090 (NVIDIA 616.92) and a Ryzen 7 5800X, Windows 11, WinLibs GCC 15.2, Release, APS5_PLAYGO_UNLISTED_CHUNKS=absent, no input: the title plays its intro cinematic by itself. Its compute shader 0x200c520000 has table calls at 0x434, 0x89c and 0xc84. The one at 0x89c takes its V# from the first four dwords of an s_load_dwordx8 s[88:95], s[0:1], the shape this PR adds.

Linking: with #9068 alone, the shader links its calls at 0x434 and 0xc84 and stops at the third: computed/data-dependent s_swappc_b64 call target at program counter 0x0000089c is not statically resolvable. With this PR on top nothing refuses. The shader links into a 104,136-dword program (6 linked-call fallbacks) and is prepared at its first dispatch.

What follows: that preparation takes minutes, and it runs on the thread that processes queue 0. The cinematic plays at about 60 FPS. When it ends, about two minutes in, the screen goes black and presentation stops. Two to six minutes later Unreal aborts with GameThread timed out waiting for RenderThread after 120.00 secs. The driver logs no error and the device isn't lost. In the fatal handler's thread dump, Unreal's RenderThread and RHIThread are waiting, and the driver's queue worker 0x0 is still running:

InvocationFor -> PrepareShaderWithDiagnostics -> PrepareShader -> getSource -> ResourceProgram
  -> PrepareResourceProgram -> ShaderPreparationContext::AcquireFrontend
  -> Structurizer::Structurize -> structurizeAttempts -> structurize -> splitSharedMergeBlocks

A local trace that names each shader prepared at use shows 0x200c520000 starting its preparation and never finishing. The six other shaders prepared at use in that run took 13 to 25 ms each.

Offline: I replayed the request the driver dumped for that preparation with agc_shader_replay --prepare. It is single-threaded, and another emulator run was using the machine at the same time. It takes 207 s, and 212 s with the trace below:

  • The graph has 4,750 blocks and 49 natural loops. The first structurize attempt succeeds, but its splitSharedMergeBlocks makes about 1,300 splits (budget 19,008) in 200 s. After each split, rebuildPredecessors, recomputeAnalyses and verifyReducibility run over the whole graph, which grows from 4,752 to 10,170 blocks. One split costs about 55 ms at the start and about 240 ms at the end.
  • Resource analysis then refuses: GetImageResource dword 0 is not a valid runtime value. The chain starts LoadAddressU32@pc=0x00051884(GetAddressResource(Phi(Phi(Phi(Phi(ReadConstBuffer@pc=0x000015ac(GetBufferResource(... and has Ballot masks further in. That is the descriptor-Phi case of #7459, like the GT7 World Map shaders in #6191.
  • APS5_FORCE_STRUCTURIZER_FALLBACK=1 is no way around it: the flag structurizer overflows the replay's 2 MiB stack in the recursive tarjanVisit after 4 s.

So with both PRs, the title's next two stops are both outside them: the structurizer's time on this 4,750-block graph, which is longer than Unreal's 120 s watchdog, and then #7459.

Runs: five runs past the cinematic all end the same way.

  • Three ran on my integration branch, which is main f894ba69d plus #9020, #9335, #7243, #7256, #7550 and #7978 and some switched-off diagnostics, with #9068 and this PR added. One of them used APS5_SYNC_DISPATCH=1.
  • Two ran on main d34da5d69 (this PR's base) with only #9068 (e5a02bd48) and this PR (73c9c2a76) merged. One of them had the trace.
  • One run on the integration branch with #9068 but without this PR stopped at 0x89c, as above.

@thuanquang, on the relay change you asked @klosixgaming-arch about above: #9068 has it since e5a02bd48. Before the first of an earlier call's callee copies, and after each one, LinkCalls leaves a pair of s_branch relays for every later call. One relay points toward that call's chain and the other back to the instruction after the call, so each hop spans at most one copy. As far as I can tell from your description, that is the case behind the lands out of the 16-bit branch range throw at 0x0d2c. I don't have PPSA10737, so it's untested there.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330349226 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8070#issuecomment-6330349226). Originally posted by [frankea](https://github.com/frankea) on 2026-10-22T01:20:11Z. --- Ghostrunner data with this PR and #9068 together (data only). **Setup:** Ghostrunner (PPSA03685 01.000.005, Unreal Engine 4) on an RTX 4090 (NVIDIA 616.92) and a Ryzen 7 5800X, Windows 11, WinLibs GCC 15.2, Release, `APS5_PLAYGO_UNLISTED_CHUNKS=absent`, no input: the title plays its intro cinematic by itself. Its compute shader 0x200c520000 has table calls at 0x434, 0x89c and 0xc84. The one at 0x89c takes its V# from the first four dwords of an `s_load_dwordx8 s[88:95], s[0:1]`, the shape this PR adds. **Linking:** with #9068 alone, the shader links its calls at 0x434 and 0xc84 and stops at the third: `computed/data-dependent s_swappc_b64 call target at program counter 0x0000089c is not statically resolvable`. With this PR on top nothing refuses. The shader links into a 104,136-dword program (6 linked-call fallbacks) and is prepared at its first dispatch. **What follows:** that preparation takes minutes, and it runs on the thread that processes queue 0. The cinematic plays at about 60 FPS. When it ends, about two minutes in, the screen goes black and presentation stops. Two to six minutes later Unreal aborts with `GameThread timed out waiting for RenderThread after 120.00 secs`. The driver logs no error and the device isn't lost. In the fatal handler's thread dump, Unreal's RenderThread and RHIThread are waiting, and the driver's `queue worker 0x0` is still running: ``` InvocationFor -> PrepareShaderWithDiagnostics -> PrepareShader -> getSource -> ResourceProgram -> PrepareResourceProgram -> ShaderPreparationContext::AcquireFrontend -> Structurizer::Structurize -> structurizeAttempts -> structurize -> splitSharedMergeBlocks ``` A local trace that names each shader prepared at use shows 0x200c520000 starting its preparation and never finishing. The six other shaders prepared at use in that run took 13 to 25 ms each. **Offline:** I replayed the request the driver dumped for that preparation with `agc_shader_replay --prepare`. It is single-threaded, and another emulator run was using the machine at the same time. It takes 207 s, and 212 s with the trace below: - The graph has 4,750 blocks and 49 natural loops. The first structurize attempt succeeds, but its `splitSharedMergeBlocks` makes about 1,300 splits (budget 19,008) in 200 s. After each split, `rebuildPredecessors`, `recomputeAnalyses` and `verifyReducibility` run over the whole graph, which grows from 4,752 to 10,170 blocks. One split costs about 55 ms at the start and about 240 ms at the end. - Resource analysis then refuses: `GetImageResource dword 0 is not a valid runtime value`. The chain starts `LoadAddressU32@pc=0x00051884(GetAddressResource(Phi(Phi(Phi(Phi(ReadConstBuffer@pc=0x000015ac(GetBufferResource(...` and has `Ballot` masks further in. That is the descriptor-Phi case of #7459, like the GT7 World Map shaders in #6191. - `APS5_FORCE_STRUCTURIZER_FALLBACK=1` is no way around it: the flag structurizer overflows the replay's 2 MiB stack in the recursive `tarjanVisit` after 4 s. So with both PRs, the title's next two stops are both outside them: the structurizer's time on this 4,750-block graph, which is longer than Unreal's 120 s watchdog, and then #7459. **Runs:** five runs past the cinematic all end the same way. - Three ran on my integration branch, which is `main` f894ba69d plus #9020, #9335, #7243, #7256, #7550 and #7978 and some switched-off diagnostics, with #9068 and this PR added. One of them used `APS5_SYNC_DISPATCH=1`. - Two ran on `main` d34da5d69 (this PR's base) with only #9068 (e5a02bd48) and this PR (73c9c2a76) merged. One of them had the trace. - One run on the integration branch with #9068 but without this PR stopped at 0x89c, as above. @thuanquang, on the relay change you asked @klosixgaming-arch about above: #9068 has it since e5a02bd48. Before the first of an earlier call's callee copies, and after each one, `LinkCalls` leaves a pair of `s_branch` relays for every later call. One relay points toward that call's chain and the other back to the instruction after the call, so each hop spans at most one copy. As far as I can tell from your description, that is the case behind the `lands out of the 16-bit branch range` throw at 0x0d2c. I don't have PPSA10737, so it's untested there. AI-assisted: yes (Claude Code)
JJenkx commented 2026-10-22 03:52:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T03:52:28Z.


A second Unreal Engine title this fixes: Severed Steel (PPSA05106) 01.000.000. Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release.

Setup

  • Base: my Release build of main 38d3c0858a + #8847 (an unrelated AGC change).
  • Candidate: the same libraries with only libSceAgcDriver.prx replaced by a build of 38d3c0858a with this PR merged (sha256 prefix 27a7a5b7c187c0a2). Every other library is byte-identical, and the title is relinked against each set.
  • Same input schedule in both runs.

Result

  • Base: stops 24 s in, before any frame:
compute shader 0x2007910000: shader 0x2007910000 stage 0: ShaderRecompiler::Recompile: computed/data-dependent s_swappc_b64 call target at program counter 0x74 is not statically resolvable
  • This PR: no recompiler stop. The run continues to 82 s, where this dump's missing PlayGo files stop it (scePlayGo: sce_sys/playgo-chunk.dat and sce_sys/playgo-scenario.json are missing). That's a property of the dump, not of this PR.

With APS5_PLAYGO_UNLISTED_CHUNKS=installed on the same candidate, it gets past start-up to the campaign "New Game" menu (difficulty, arm cannon, mutators, play) and stays there. That run then stops at 156 s inside the title: Unreal's own PS5 Out of Memory: AvailablePhysical: 0, UsedPhysical: 14180876288, then LowLevelFatalError ... Ran out of memory allocating 2293760 bytes. It also runs at about 2.8 FPS, with this machine's -1000072003 host-import budget collapse (24 failures; #8091). I don't see a link between either of those and this PR, but I haven't looked into the out-of-memory stop.

I haven't checked that the shader is the s_load_dwordx8-slice case your description covers. The evidence is the before/after stop only.

AI-assisted testing and report: yes, Claude Code.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332254753 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8070#issuecomment-6332254753). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-22T03:52:28Z. --- A second Unreal Engine title this fixes: **Severed Steel (PPSA05106) 01.000.000**. Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release. **Setup** - Base: my Release build of `main` `38d3c0858a` + #8847 (an unrelated AGC change). - Candidate: the same libraries with only `libSceAgcDriver.prx` replaced by a build of `38d3c0858a` with this PR merged (sha256 prefix `27a7a5b7c187c0a2`). Every other library is byte-identical, and the title is relinked against each set. - Same input schedule in both runs. **Result** - Base: stops 24 s in, before any frame: ``` compute shader 0x2007910000: shader 0x2007910000 stage 0: ShaderRecompiler::Recompile: computed/data-dependent s_swappc_b64 call target at program counter 0x74 is not statically resolvable ``` - This PR: no recompiler stop. The run continues to 82 s, where this dump's missing PlayGo files stop it (`scePlayGo: sce_sys/playgo-chunk.dat and sce_sys/playgo-scenario.json are missing`). That's a property of the dump, not of this PR. With `APS5_PLAYGO_UNLISTED_CHUNKS=installed` on the same candidate, it gets past start-up to the campaign "New Game" menu (difficulty, arm cannon, mutators, play) and stays there. That run then stops at 156 s inside the title: Unreal's own `PS5 Out of Memory: AvailablePhysical: 0, UsedPhysical: 14180876288`, then `LowLevelFatalError ... Ran out of memory allocating 2293760 bytes`. It also runs at about 2.8 FPS, with this machine's `-1000072003` host-import budget collapse (24 failures; #8091). I don't see a link between either of those and this PR, but I haven't looked into the out-of-memory stop. I haven't checked that the shader is the `s_load_dwordx8`-slice case your description covers. The evidence is the before/after stop only. AI-assisted testing and report: yes, Claude Code.
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!8070
No description provided.