fix(recompiler): read lane spills back through relative-addressing window registers #6277

Merged
hypermoist merged 1 commit from upstream-pr/6277 into main 2026-10-18 21:14:36 +00:00
hypermoist commented 2026-10-15 08:54:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-15T08:54:34Z.


What

A program with any v_movrels/v_movreld keeps its relative-addressing window in array storage (#3856), so a v_writelane spill into a window register reaches its v_readlane as ReadLane(LoadVectorWindow k), and ReadLaneEliminator stopped there. A descriptor spilled that way stays a run-time value, and resource analysis rejects it. In PPSA08427 (Killing Floor 3) that skips about 750 draws per 10 s with GetSamplerResource dword 0 is not a valid runtime value, and large UE5 compute programs fail with GetImageResource dword 0 is not a valid runtime value.

  • What lane L of window slot k holds at a load is a forward dataflow over the blocks, computed once per (slot, lane) and memoized. A block's exit holds the lane of its last store to k, or what entered it. A block's entry holds the value every predecessor agrees on, with an unvisited predecessor (a loop's back edge on the first pass) agreeing with any value. The entry block starts unknown.
  • A store's lane is read through its WriteLane chain down to a window load, whose lane is the flow's value at that load, so the chain continues across window registers.
  • A store with a computed index makes the lane unknown, except for slots that are only ever lane-written and lane-read: the guest compiler keeps spill registers out of the indexed array, so such a store cannot name them.
  • The lane is unknown, and the v_readlane stays as before, when predecessors disagree, a store's lane is not a lane write, or the flow does not settle within a bound.

Tested

CachyOS Linux (kernel 7.2.9), NVIDIA GeForce RTX 3060, driver 615.78.08, GCC 16.2.1, Release, on main 721db55dc.

  • New execution test agc_driver_window_lane_spill: an output V# spilled with v_writelane into a window register (the window starts below it) and read back with v_readlane before a buffer store; then the same with a second v_movreld with a computed index between the spill and its read-back. On main it fails: lane 0 stored 3735928559 through the V# read back from a window register.
  • Pass: agc_driver_window_lane_spill, agc_vector_window, agc_driver_vector_window_direct_access, agc_driver_relative_indexing, agc_driver_scalar_relative_indexing, agc_driver_write_lane, agc_shader_memory.
  • PPSA08427: carried on the bring-up branch since 2026-10-12; the skipped draws and failing compute programs above are gone and the hub renders.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3060, driver 615.78.08, CachyOS Linux (kernel 7.2.9)
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Uzy15wqYTt6iWyxYXEzUWo

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4870715124 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277). Originally posted by [hypermoist](https://github.com/hypermoist) on 2026-10-15T08:54:34Z. --- ### What A program with any `v_movrels`/`v_movreld` keeps its relative-addressing window in array storage (#3856), so a `v_writelane` spill into a window register reaches its `v_readlane` as `ReadLane(LoadVectorWindow k)`, and `ReadLaneEliminator` stopped there. A descriptor spilled that way stays a run-time value, and resource analysis rejects it. In PPSA08427 (Killing Floor 3) that skips about 750 draws per 10 s with `GetSamplerResource dword 0 is not a valid runtime value`, and large UE5 compute programs fail with `GetImageResource dword 0 is not a valid runtime value`. - What lane L of window slot k holds at a load is a forward dataflow over the blocks, computed once per (slot, lane) and memoized. A block's exit holds the lane of its last store to k, or what entered it. A block's entry holds the value every predecessor agrees on, with an unvisited predecessor (a loop's back edge on the first pass) agreeing with any value. The entry block starts unknown. - A store's lane is read through its `WriteLane` chain down to a window load, whose lane is the flow's value at that load, so the chain continues across window registers. - A store with a computed index makes the lane unknown, except for slots that are only ever lane-written and lane-read: the guest compiler keeps spill registers out of the indexed array, so such a store cannot name them. - The lane is unknown, and the `v_readlane` stays as before, when predecessors disagree, a store's lane is not a lane write, or the flow does not settle within a bound. ### Tested CachyOS Linux (kernel 7.2.9), NVIDIA GeForce RTX 3060, driver 615.78.08, GCC 16.2.1, Release, on `main` 721db55dc. - New execution test `agc_driver_window_lane_spill`: an output V# spilled with `v_writelane` into a window register (the window starts below it) and read back with `v_readlane` before a buffer store; then the same with a second `v_movreld` with a computed index between the spill and its read-back. On `main` it fails: `lane 0 stored 3735928559 through the V# read back from a window register`. - Pass: `agc_driver_window_lane_spill`, `agc_vector_window`, `agc_driver_vector_window_direct_access`, `agc_driver_relative_indexing`, `agc_driver_scalar_relative_indexing`, `agc_driver_write_lane`, `agc_shader_memory`. - PPSA08427: carried on the bring-up branch since 2026-10-12; the skipped draws and failing compute programs above are gone and the hub renders. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3060, driver 615.78.08, CachyOS Linux (kernel 7.2.9) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Uzy15wqYTt6iWyxYXEzUWo
fma-rc commented 2026-10-15 12:44:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T12:44:35Z.


Death Stranding 2 (PPSA02015) stops on this. On a local stack (current main plus what it needs to get that far, including PR 5426, PR 5855 and PR 6297), compute shader 0x8280575600 throws at about 150 s:

GetImageResource dword 0 is not a valid runtime value; chain: LoadAddressU32@pc=0x000010dc(GetAddressResource(ReadLane(LoadVectorWindow(Immediate), ...

With this PR cherry-picked on top, the shader compiles and the title runs on to 184 s, where it stops on a storage image access to a multisampled color target that is unrelated to this change.

agc_driver_read_lane and agc_driver_window_lane_spill pass here on an RTX 5080 and on a Radeon 610M (RADV), with the PR merged onto current main; lavapipe skips both.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6192362816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277#issuecomment-6192362816). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-15T12:44:35Z. --- Death Stranding 2 (PPSA02015) stops on this. On a local stack (current main plus what it needs to get that far, including PR 5426, PR 5855 and PR 6297), compute shader 0x8280575600 throws at about 150 s: `GetImageResource dword 0 is not a valid runtime value; chain: LoadAddressU32@pc=0x000010dc(GetAddressResource(ReadLane(LoadVectorWindow(Immediate), ...` With this PR cherry-picked on top, the shader compiles and the title runs on to 184 s, where it stops on a storage image access to a multisampled color target that is unrelated to this change. `agc_driver_read_lane` and `agc_driver_window_lane_spill` pass here on an RTX 5080 and on a Radeon 610M (RADV), with the PR merged onto current main; lavapipe skips both.
fdfawef324 commented 2026-10-15 13:06:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-15T13:06:46Z.


Resident Evil 4 (PPSA07411) stops on this pattern too, in a mesh program, but this PR does not get it past. Windows Server 2025, RTX 3060, driver 591.86, MinGW GCC 15.2, Release.

On a private build of main 8cd937e29 + #6126 + #5884 (the stops before this one), the title ends on its resource loader thread, in sceAgcCreatePrimState -> Driver::ResolveGraphicsStagesAbi -> PrepareGraphicsStages:

terminate called after throwing an instance of 'std::runtime_error'
  what():  shader 0xffde46b100 stage 7 (shader_ffde46b100.req): ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), Phi(ReadConst(GetSrtResource, Immediate), ReadLane(LoadVectorWindow(Immediate), Immediate)))

I cherry-picked fe6d2d2e9 onto that build and replayed the saved request with agc_shader_replay --prepare: it fails with the same message. With the rejected slots kept as candidates in collectLaneSpillSlots (a local experiment), it prepares (1,558,931 SPIR-V words).

The reason is the rule that a spill slot is only ever lane-written and lane-read. The window starts at v5, and the spill register is v16, slot 11. In the first part of the program, before any relative access, v16 is an ordinary register: vector ALU instructions write it and read it. Later the program reuses it for SGPR spills. Current LLVM allocates the spill VGPRs like other registers, so one register can be ordinary in one part of a program and hold spill lanes in another. Slot 11 therefore has ordinary stores and loads, collectLaneSpillSlots rejects it, and the computed-index stores between the spill and the read make the lane unknown. The index can't be bounded statically either: it is computed from per-lane data, and the window runs past v16, so M0 = 11 is not excluded.

What we ran for this title instead (not opened as a PR, since this one implements the same function): a constant-slot LoadVectorWindow walks the control flow back to the constant-slot stores that reach it, and computed-index stores on the way are taken not to reach the slot. It is the same assumption as yours (the compiler does not index into a register while a spill lives in it), applied while the spilled lane is live instead of per slot. With it the program prepares, and the title goes on past this stop: with the later fixes it reached the brightness calibration screen (1,485 s run) and the play-data consent screen (2,096 s run), with no driver failure.

Suggestions:

  • Keep a known lane across computed-index stores. In laneFlow a lane only becomes known through v_writelane, so a known lane is a live spill at that point. That is when the assumption applies, and the program-wide rejected rule would no longer be needed. This PR would then cover PPSA07411 too.

  • Record the assumption in technical debt (docs/dev/debt/shader.md, next to "Relative vector addressing"). Here is the entry I used, if it helps:

    v_readlane_b32 of a relatively written window register: in a program with indexed writes (v_movreld_b32, v_movrelsd_b32, v_movrelsd_2_b32, v_swaprel_b32), a scalar spilled with v_writelane_b32 into a window register and restored with v_readlane_b32 reaches the read through StoreVectorWindow/LoadVectorWindow of a constant slot. The read becomes the spilled scalar when every constant-slot store that reaches it sets that lane with v_writelane_b32. Relative stores on the way are taken not to reach the slot: a relative write into a register that holds a live spill would destroy it, so the compiler keeps spill registers out of its relatively indexed arrays. A program that sets a lane of an array register with v_writelane_b32, writes the array relatively and reads that lane back with v_readlane_b32 would read the v_writelane_b32 value instead of the relative write.

  • If you'd rather not rely on the assumption at all: the computed-index stores that the flow skips could record a fault in the fault buffer (as UnlinkedCall does) when their index is the slot and the invocation is the spilled lane. The host then throws instead of the shader reading a stale value. I can send that as a follow-up once this lands.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6192785859 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277#issuecomment-6192785859). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-15T13:06:46Z. --- Resident Evil 4 (PPSA07411) stops on this pattern too, in a mesh program, but this PR does not get it past. Windows Server 2025, RTX 3060, driver 591.86, MinGW GCC 15.2, Release. On a private build of `main` 8cd937e29 + #6126 + #5884 (the stops before this one), the title ends on its resource loader thread, in `sceAgcCreatePrimState` -> `Driver::ResolveGraphicsStagesAbi` -> `PrepareGraphicsStages`: ``` terminate called after throwing an instance of 'std::runtime_error' what(): shader 0xffde46b100 stage 7 (shader_ffde46b100.req): ShaderRecompiler::Recompile: GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConst(GetSrtResource, Immediate), Phi(ReadConst(GetSrtResource, Immediate), ReadLane(LoadVectorWindow(Immediate), Immediate))) ``` I cherry-picked fe6d2d2e9 onto that build and replayed the saved request with `agc_shader_replay --prepare`: it fails with the same message. With the `rejected` slots kept as candidates in `collectLaneSpillSlots` (a local experiment), it prepares (1,558,931 SPIR-V words). The reason is the rule that a spill slot is only ever lane-written and lane-read. The window starts at `v5`, and the spill register is `v16`, slot 11. In the first part of the program, before any relative access, `v16` is an ordinary register: vector ALU instructions write it and read it. Later the program reuses it for SGPR spills. Current LLVM allocates the spill VGPRs like other registers, so one register can be ordinary in one part of a program and hold spill lanes in another. Slot 11 therefore has ordinary stores and loads, `collectLaneSpillSlots` rejects it, and the computed-index stores between the spill and the read make the lane unknown. The index can't be bounded statically either: it is computed from per-lane data, and the window runs past `v16`, so M0 = 11 is not excluded. What we ran for this title instead (not opened as a PR, since this one implements the same function): a constant-slot `LoadVectorWindow` walks the control flow back to the constant-slot stores that reach it, and computed-index stores on the way are taken not to reach the slot. It is the same assumption as yours (the compiler does not index into a register while a spill lives in it), applied while the spilled lane is live instead of per slot. With it the program prepares, and the title goes on past this stop: with the later fixes it reached the brightness calibration screen (1,485 s run) and the play-data consent screen (2,096 s run), with no driver failure. Suggestions: - Keep a known lane across computed-index stores. In `laneFlow` a lane only becomes known through `v_writelane`, so a known lane is a live spill at that point. That is when the assumption applies, and the program-wide `rejected` rule would no longer be needed. This PR would then cover PPSA07411 too. - Record the assumption in technical debt (`docs/dev/debt/shader.md`, next to "Relative vector addressing"). Here is the entry I used, if it helps: > [`v_readlane_b32` of a relatively written window register](../../../core/shader/recompiler/Optimization/src/ReadLaneEliminator.cpp): in a program with indexed writes (`v_movreld_b32`, `v_movrelsd_b32`, `v_movrelsd_2_b32`, `v_swaprel_b32`), a scalar spilled with `v_writelane_b32` into a window register and restored with `v_readlane_b32` reaches the read through `StoreVectorWindow`/`LoadVectorWindow` of a constant slot. The read becomes the spilled scalar when every constant-slot store that reaches it sets that lane with `v_writelane_b32`. Relative stores on the way are taken not to reach the slot: a relative write into a register that holds a live spill would destroy it, so the compiler keeps spill registers out of its relatively indexed arrays. A program that sets a lane of an array register with `v_writelane_b32`, writes the array relatively and reads that lane back with `v_readlane_b32` would read the `v_writelane_b32` value instead of the relative write. - If you'd rather not rely on the assumption at all: the computed-index stores that the flow skips could record a fault in the fault buffer (as `UnlinkedCall` does) when their index is the slot and the invocation is the spilled lane. The host then throws instead of the shader reading a stale value. I can send that as a follow-up once this lands. AI-assisted: yes (Claude Code)
jotitadev commented 2026-10-15 16:30:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T16:30:13Z.

Review: COMMENTED


Tested on Apple as another vendor; the new regression reproduces and the fix clears it.

The window-lane spill path runs on Apple silicon (subgroup size 32, so agc_driver_window_lane_spill is not skipped).

  • With the fix: agc_driver_window_lane_spill passes.
  • Test only, on the base without the ReadLaneEliminator change: it fails with
    AGC graphics: window lane spill: lane 0 stored 3735928559 through the V# read back from a window register,
    so the test does guard the regression here.
  • Full ^agc suite: 13 failures, same set as the base (all pre-existing on MoltenVK: denormals/rounding, dpp16, pixel interlock, relative ancillary, etc.). No new failures from this PR.

Method: macos-port @ b7eb6b6b + ImportWatched + PR diff, not main. Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta, driver SDK MoltenVK 1.4.2.
GPUs tested: Apple M2 Max (MoltenVK 1.4.2).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5536520469 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277#pullrequestreview-5536520469). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T16:30:13Z. **Review:** COMMENTED --- Tested on Apple as another vendor; the new regression reproduces and the fix clears it. The window-lane spill path runs on Apple silicon (subgroup size 32, so `agc_driver_window_lane_spill` is not skipped). - With the fix: `agc_driver_window_lane_spill` passes. - Test only, on the base without the `ReadLaneEliminator` change: it fails with `AGC graphics: window lane spill: lane 0 stored 3735928559 through the V# read back from a window register`, so the test does guard the regression here. - Full `^agc` suite: 13 failures, same set as the base (all pre-existing on MoltenVK: denormals/rounding, dpp16, pixel interlock, relative ancillary, etc.). No new failures from this PR. Method: macos-port @ b7eb6b6b + ImportWatched + PR diff, not main. Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta, driver SDK MoltenVK 1.4.2. GPUs tested: Apple M2 Max (MoltenVK 1.4.2). Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
THEMANnt commented 2026-10-16 12:12:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-16T12:12:34Z.


@hypermoist I tested head fe6d2d2e9 cherry-picked onto main d92a8dad3 with LEGO Horizon Adventures (PPSA14632, 01.004.000). The six focused tests (shader memory, vector window, relative indexing, scalar relative indexing, window lane spill, write lane) pass, but all four captured LEGO compute requests still fail with:

GetSamplerResource dword 0 is not a valid runtime value;
chain: ReadLane(LoadVectorWindow(Immediate), Immediate)

This appears to match the reused-register limitation described above: the first sampler reads resolve, but later reads do not. Keeping every constant slot as a spill candidate makes all four compile in a diagnostic experiment; I reverted that experiment and have not claimed gameplay success.

I also made a small synthetic counterexample for the computed-store assumption. It keeps the output buffer descriptor intact, spills 0x1234 into lane 0 of v3, then executes v_movreld_b32 v2, v0 before reading v3 lane 0:

  • M0 = 0: writes v2; expected output 0x1234, and passes.
  • M0 = 1: writes v3; expected output 0, but this PR outputs 4660 (0x1234).

The same two cases pass when rebuilding the test/driver with only ReadLaneEliminator.cpp restored to its main implementation. This is a host GPU execution comparison, not a console hardware-oracle result.

The patch below applies to this PR's WindowLaneSpill.cpp. Build agc_driver_window_lane_spill_tests and run it with --indexed-alias-only to isolate the counterexample. No game code or shader captures are included.

Synthetic regression test patch
diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp
index f597fc79e..3aa2a7f66 100644
--- a/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp
@@ -29,16 +29,23 @@ alignas(256) constexpr std::array<std::uint32_t, 27> IndexedStoreCode{
     0xd7600009, 0x00010303, 0xd760000a, 0x00010503, 0xd760000b, 0x00010703, 0xe0702000, 0x80020001, 0xbf810000,
 };
 
+alignas(256) constexpr std::array<std::uint32_t, 12> AliasingStoreCode{
+    0x7e020300, 0xbefc030c, 0x7e048500, 0xd7610003, 0x0001000d, 0x7e048500,
+    0xd7600008, 0x00010103, 0x7e040208, 0xe0702000, 0x80010201, 0xbf810000,
+};
+
 std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t count) {
     const auto address = reinterpret_cast<std::uintptr_t>(data);
     return {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu) | (4u << 16u), count, 0x11016facu};
 }
 
-void Run(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code) {
+void Run(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code, std::uint32_t relativeIndex = 0) {
     Output.fill(0xdeadbeefu);
     std::vector<std::uint32_t> userData(16, 0u);
     const auto output = BufferDescriptor(Output.data(), static_cast<std::uint32_t>(Output.size()));
     std::copy(output.begin(), output.end(), userData.begin() + 4);
+    userData[12] = relativeIndex;
+    userData[13] = 0x1234u;
     const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}};
     const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0, {false, false, false}, false, 1};
     ShaderRecompiler::RecompileRequest request{
@@ -61,7 +68,7 @@ void Check(const std::string& name) {
 
 }
 
-int main() {
+int main(int argc, char** argv) {
     try {
         const auto device = OpenVulkanTestDevice();
         if (!device) return VulkanTestSkipped;
@@ -69,10 +76,20 @@ int main() {
             std::printf("skipped, subgroup size %u cannot hold a wave32\n", device->Target().subgroupSize);
             return VulkanTestSkipped;
         }
-        Run(*device, Code);
-        Check("window lane spill");
-        Run(*device, IndexedStoreCode);
-        Check("window lane spill past an indexed store");
+        if (argc != 2 || std::string(argv[1]) != "--indexed-alias-only") {
+            Run(*device, Code);
+            Check("window lane spill");
+            Run(*device, IndexedStoreCode);
+            Check("window lane spill past an indexed store");
+        }
+        for (const auto index : {0u, 1u}) {
+            Run(*device, AliasingStoreCode, index);
+            const auto expected = index == 0u ? 0x1234u : 0u;
+            for (const auto actual : Output) {
+                Require(actual == expected, "indexed spill overwrite: index " + std::to_string(index) +
+                    " returned " + std::to_string(actual) + ", expected " + std::to_string(expected));
+            }
+        }
         std::puts("window lane spill tests passed");
         return 0;
     } catch (const std::exception& error) {

Tested on Windows 11, NVIDIA RTX 5070 Ti (driver 32.0.16.1692), MinGW GCC 15.2, Release. AI-assisted: yes (Codex). I am investigating guarded spill tracking locally; the proposed fault-buffer check above looks relevant for avoiding silently stale values.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6215244790 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277#issuecomment-6215244790). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-16T12:12:34Z. --- @hypermoist I tested head `fe6d2d2e9` cherry-picked onto main `d92a8dad3` with LEGO Horizon Adventures (PPSA14632, 01.004.000). The six focused tests (shader memory, vector window, relative indexing, scalar relative indexing, window lane spill, write lane) pass, but all four captured LEGO compute requests still fail with: ```text GetSamplerResource dword 0 is not a valid runtime value; chain: ReadLane(LoadVectorWindow(Immediate), Immediate) ``` This appears to match the reused-register limitation described above: the first sampler reads resolve, but later reads do not. Keeping every constant slot as a spill candidate makes all four compile in a diagnostic experiment; I reverted that experiment and have not claimed gameplay success. I also made a small synthetic counterexample for the computed-store assumption. It keeps the output buffer descriptor intact, spills `0x1234` into lane 0 of v3, then executes `v_movreld_b32 v2, v0` before reading v3 lane 0: - M0 = 0: writes v2; expected output `0x1234`, and passes. - M0 = 1: writes v3; expected output `0`, but this PR outputs `4660` (`0x1234`). The same two cases pass when rebuilding the test/driver with only ReadLaneEliminator.cpp restored to its main implementation. This is a host GPU execution comparison, not a console hardware-oracle result. The patch below applies to this PR's WindowLaneSpill.cpp. Build `agc_driver_window_lane_spill_tests` and run it with `--indexed-alias-only` to isolate the counterexample. No game code or shader captures are included. <details> <summary>Synthetic regression test patch</summary> ```diff diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp index f597fc79e..3aa2a7f66 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/WindowLaneSpill.cpp @@ -29,16 +29,23 @@ alignas(256) constexpr std::array<std::uint32_t, 27> IndexedStoreCode{ 0xd7600009, 0x00010303, 0xd760000a, 0x00010503, 0xd760000b, 0x00010703, 0xe0702000, 0x80020001, 0xbf810000, }; +alignas(256) constexpr std::array<std::uint32_t, 12> AliasingStoreCode{ + 0x7e020300, 0xbefc030c, 0x7e048500, 0xd7610003, 0x0001000d, 0x7e048500, + 0xd7600008, 0x00010103, 0x7e040208, 0xe0702000, 0x80010201, 0xbf810000, +}; + std::array<std::uint32_t, 4> BufferDescriptor(const void* data, std::uint32_t count) { const auto address = reinterpret_cast<std::uintptr_t>(data); return {static_cast<std::uint32_t>(address), static_cast<std::uint32_t>((address >> 32u) & 0xffffu) | (4u << 16u), count, 0x11016facu}; } -void Run(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code) { +void Run(AgcDriver::VulkanDevice& device, std::span<const std::uint32_t> code, std::uint32_t relativeIndex = 0) { Output.fill(0xdeadbeefu); std::vector<std::uint32_t> userData(16, 0u); const auto output = BufferDescriptor(Output.data(), static_cast<std::uint32_t>(Output.size())); std::copy(output.begin(), output.end(), userData.begin() + 4); + userData[12] = relativeIndex; + userData[13] = 0x1234u; const std::array<ShaderRecompiler::MemoryRegion, 1> memory{{{reinterpret_cast<std::uintptr_t>(code.data()), std::as_bytes(code)}}}; const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0, {false, false, false}, false, 1}; ShaderRecompiler::RecompileRequest request{ @@ -61,7 +68,7 @@ void Check(const std::string& name) { } -int main() { +int main(int argc, char** argv) { try { const auto device = OpenVulkanTestDevice(); if (!device) return VulkanTestSkipped; @@ -69,10 +76,20 @@ int main() { std::printf("skipped, subgroup size %u cannot hold a wave32\n", device->Target().subgroupSize); return VulkanTestSkipped; } - Run(*device, Code); - Check("window lane spill"); - Run(*device, IndexedStoreCode); - Check("window lane spill past an indexed store"); + if (argc != 2 || std::string(argv[1]) != "--indexed-alias-only") { + Run(*device, Code); + Check("window lane spill"); + Run(*device, IndexedStoreCode); + Check("window lane spill past an indexed store"); + } + for (const auto index : {0u, 1u}) { + Run(*device, AliasingStoreCode, index); + const auto expected = index == 0u ? 0x1234u : 0u; + for (const auto actual : Output) { + Require(actual == expected, "indexed spill overwrite: index " + std::to_string(index) + + " returned " + std::to_string(actual) + ", expected " + std::to_string(expected)); + } + } std::puts("window lane spill tests passed"); return 0; } catch (const std::exception& error) { ``` </details> Tested on Windows 11, NVIDIA RTX 5070 Ti (driver 32.0.16.1692), MinGW GCC 15.2, Release. AI-assisted: yes (Codex). I am investigating guarded spill tracking locally; the proposed fault-buffer check above looks relevant for avoiding silently stale values.
ps54all commented 2026-10-17 21:58:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-17T21:58:12Z.


Tested on God of War Ragnarök (PPSA08330, 06.006.000), Windows 11, RTX 3080 10 GB (NVIDIA 610.74), WinLibs GCC 15.2. Base: our test branch (main 82f0c9aec + #6946 + #6958 + #7238 + #7223 + a few open picks).

  • Without: 12 shaders refused after registration, non-fatal: GetSamplerResource dword 0 is not a valid runtime value; chain: ReadLane(LoadVectorWindow(Immediate)....
  • With (#6417 was added in the same build): 0 of those lines in two runs (480 s cold cache, 600 s warm).
  • The window still stays black at ~0.1 FPS. The first presented frame came earlier (~300 s cold, ~100 s warm; the run without this PR presented none in 420 s), but this build also changed #6417 and the shader cache state, so I can't put that on this PR alone.
  • Doesn't touch Ratchet & Clank's GetSamplerResource stop, which is a different chain (LoadAddressU32(GetAddressResource(Phi(Phi(ReadConstBuffer…, #6191).

LLM assistance used (Claude); runs on our machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6241849254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277#issuecomment-6241849254). Originally posted by [ps54all](https://github.com/ps54all) on 2026-10-17T21:58:12Z. --- Tested on God of War Ragnarök (PPSA08330, 06.006.000), Windows 11, RTX 3080 10 GB (NVIDIA 610.74), WinLibs GCC 15.2. Base: our test branch (main `82f0c9aec` + #6946 + #6958 + #7238 + #7223 + a few open picks). - **Without:** 12 shaders refused after registration, non-fatal: `GetSamplerResource dword 0 is not a valid runtime value; chain: ReadLane(LoadVectorWindow(Immediate)...`. - **With** (#6417 was added in the same build): 0 of those lines in two runs (480 s cold cache, 600 s warm). - The window still stays black at ~0.1 FPS. The first presented frame came earlier (~300 s cold, ~100 s warm; the run without this PR presented none in 420 s), but this build also changed #6417 and the shader cache state, so I can't put that on this PR alone. - Doesn't touch Ratchet & Clank's `GetSamplerResource` stop, which is a different chain (`LoadAddressU32(GetAddressResource(Phi(Phi(ReadConstBuffer…`, #6191). LLM assistance used (Claude); runs on our machine.
thuanquang commented 2026-10-20 18:47:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-20T18:47:58Z.


@fdfawef324 your first suggestion here didn't make it into this PR before it merged: keep a known lane across computed-index window stores, since in laneFlow a known lane is a live spill. main still stops on that pattern, in RE4's mesh program and in @THEMANnt's four LEGO Horizon Adventures requests (#6952).

Are you planning to open it yourself? If you'd rather not, I'd like to open it in a few hours with you as co-author: your laneFlow change and debt entry, plus a GPU case in agc_driver_window_lane_spill that fails on main (a window slot written as an ordinary register before the spill). THEMANnt, the same goes for your prototype if it differs. I'll hold off on opening until you've had a chance to answer.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6298565552 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277#issuecomment-6298565552). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-20T18:47:58Z. --- @fdfawef324 your first suggestion here didn't make it into this PR before it merged: keep a known lane across computed-index window stores, since in `laneFlow` a known lane is a live spill. `main` still stops on that pattern, in RE4's mesh program and in @THEMANnt's four LEGO Horizon Adventures requests (#6952). Are you planning to open it yourself? If you'd rather not, I'd like to open it in a few hours with you as co-author: your `laneFlow` change and debt entry, plus a GPU case in `agc_driver_window_lane_spill` that fails on `main` (a window slot written as an ordinary register before the spill). THEMANnt, the same goes for your prototype if it differs. I'll hold off on opening until you've had a chance to answer.
thuanquang commented 2026-10-21 04:16:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T04:16:28Z.


@fdfawef324 I've opened it as #8881, with you as co-author: your laneFlow suggestion and debt text, plus agc_vector_window and agc_driver_window_lane_spill cases that fail on main with LEGO Horizon Adventures' message. If you'd rather carry it yourself, or your RE4 variant differs in a way that matters, say so and I'll close mine. @THEMANnt, a run of the LEGO requests with it would be very welcome.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6307904039 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6277#issuecomment-6307904039). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-21T04:16:28Z. --- @fdfawef324 I've opened it as #8881, with you as co-author: your `laneFlow` suggestion and debt text, plus `agc_vector_window` and `agc_driver_window_lane_spill` cases that fail on `main` with LEGO Horizon Adventures' message. If you'd rather carry it yourself, or your RE4 variant differs in a way that matters, say so and I'll close mine. @THEMANnt, a run of the LEGO requests with it would be very welcome.
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!6277
No description provided.