AGC: a storage image the CPU polls is never stored back, so a title that waits for it deadlocks (Ratchet & Clank: Rift Apart, frame 456) #3272

Closed
opened 2026-10-11 04:49:07 +00:00 by Tamalero · 2 comments
Tamalero commented 2026-10-11 04:49:07 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-11T04:49:07Z.


Ratchet & Clank: Rift Apart freezes on a black screen around frame 455 on every run, right after the intro logos. GPU usage is 0%. AnyPS5's queue threads are all idle, and the game's own watchdog prints ProcessReprojection timed out after 100ms on RenderFrameIndex 456.

The cause is that a compute shader writes its result into a linear storage image, and the game's main thread then polls that memory with plain CPU reads until the last float stops being -1.0. AnyPS5 keeps storage-image results on the GPU until guest memory is read through the driver. The game reads it directly, and the flip-time store is opt-in (APS5_STORE_AT_FLIP), so the result never reaches guest memory. The main thread waits forever, and the rest of the frame waits on the main thread.

APS5_EAGER_WRITEBACK=1 changes the outcome: the game takes a path it never took before (a new compute shader appears) and then stops earlier, on an unrelated shader-recompiler gap. So I could not confirm frame 456 passes with it. The mechanism below is from a core dump and the code.

A possible direction: store pending storage results that overlap a range when a label or end-of-pipe write that follows them completes. That is the point where the console guarantees the GPU's earlier writes are visible to the CPU. Or read-protect pages with pending results, the way the write watch does for stores. I have not implemented either.

Details and logs

Title: Ratchet & Clank: Rift Apart (PPSA01474, content 01.005.003)
Where it stops: ~2.5 min in, frame 455/456, 3 of 3 runs (441 once with APS5_TRACE_GPU, which slows it).
AnyPS5 f1ae427b (upstream main 961b25fe still has the same flush logic). CachyOS (Linux 7.2), RTX 4090, driver 615.78, i9-14900K, relinked with --to-intel.
Local patches needed to get this far (not pushed): guest thread stacks in the guest arena (ChakraCore OOM), sceKernelMunmap returning 0 for unmapped ranges, PR #3158 plus fixed 8 MiB host-import windows, APS5_AMM_BASE_HINT for #3146, and a size cap on per-draw input snapshots (one draw input here is 3 GB).

What the core shows

  • All three Driver::run queue threads are in condition_variable::wait with nothing pending. There are no WAIT_REG_MEM … timed out or dropped-label lines.
  • The game's main thread spins at game+0xde1890: it calls its watchdog (label ProcessReprojection) until float[r15 + r12*4 - 4] != -1.0f.
  • At the freeze r15 = 0x114d640000, r12 = 0x14400. The awaited float at 0x114d690ffc is 0xbf800000, and the floats before it are 0.
  • The log shows the image: StorageTexture address=0x114d640000 384x216 mips=1 … tile=0 format=22 vk=100, i.e. linear R32F, and 384×216 = 0x14400 floats.
  • A hardware write breakpoint on the game's per-frame state flag (perf record -e mem:<addr>/4:w) shows the cycle 1→3→4→5→1 once per frame. At the freeze the worker sets 1 and the main thread never releases it.

Code path (main 961b25fe)

  • GuestMemory.hpp: "The graphics layer keeps the results of storage images on the GPU until guest memory is read; it registers a hook that stores every pending result overlapping a range, which every read and store through this interface calls first."
  • FlushGpuWrites callers are all driver-side reads (copies, display buffers, shader fetches, buffer views). Nothing covers a guest CPU load.
  • VulkanDevice.cpp:2219: FlushAllPending("flip") only runs with APS5_STORE_AT_FLIP=1. Even with it, this title polls before the flip, so it would still wait.

Local experiment

With APS5_EAGER_WRITEBACK=1 the run is faster overall, but at frame 437 it aborts in a compute shader the earlier runs never dispatched:

compute shader 0x116bb5d700: ShaderRecompiler::Recompile: computed/data-dependent s_swappc_b64 call target at program counter 0x00001ac4 is not statically resolvable

That is a separate gap (same class as #2062 / #1817).

What I don't know: which label the console uses to order this result before the CPU read. I did not trace the dispatch's own release packet.
Related: #3146, #3158.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5798070167 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3272). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-11T04:49:07Z. --- Ratchet & Clank: Rift Apart freezes on a black screen around frame 455 on every run, right after the intro logos. GPU usage is 0%. AnyPS5's queue threads are all idle, and the game's own watchdog prints `ProcessReprojection timed out after 100ms on RenderFrameIndex 456`. The cause is that a compute shader writes its result into a linear storage image, and the game's main thread then polls that memory with plain CPU reads until the last float stops being `-1.0`. AnyPS5 keeps storage-image results on the GPU until guest memory is read *through the driver*. The game reads it directly, and the flip-time store is opt-in (`APS5_STORE_AT_FLIP`), so the result never reaches guest memory. The main thread waits forever, and the rest of the frame waits on the main thread. `APS5_EAGER_WRITEBACK=1` changes the outcome: the game takes a path it never took before (a new compute shader appears) and then stops earlier, on an unrelated shader-recompiler gap. So I could not confirm frame 456 passes with it. The mechanism below is from a core dump and the code. A possible direction: store pending storage results that overlap a range when a label or end-of-pipe write that follows them completes. That is the point where the console guarantees the GPU's earlier writes are visible to the CPU. Or read-protect pages with pending results, the way the write watch does for stores. I have not implemented either. <details><summary>Details and logs</summary> **Title:** Ratchet & Clank: Rift Apart (PPSA01474, content 01.005.003) **Where it stops:** ~2.5 min in, frame 455/456, 3 of 3 runs (441 once with `APS5_TRACE_GPU`, which slows it). AnyPS5 `f1ae427b` (upstream `main` `961b25fe` still has the same flush logic). CachyOS (Linux 7.2), RTX 4090, driver 615.78, i9-14900K, relinked with `--to-intel`. Local patches needed to get this far (not pushed): guest thread stacks in the guest arena (ChakraCore OOM), `sceKernelMunmap` returning 0 for unmapped ranges, PR #3158 plus fixed 8 MiB host-import windows, `APS5_AMM_BASE_HINT` for #3146, and a size cap on per-draw input snapshots (one draw input here is 3 GB). ### What the core shows - All three `Driver::run` queue threads are in `condition_variable::wait` with nothing pending. There are no `WAIT_REG_MEM … timed out` or dropped-label lines. - The game's main thread spins at `game+0xde1890`: it calls its watchdog (label `ProcessReprojection`) until `float[r15 + r12*4 - 4] != -1.0f`. - At the freeze `r15 = 0x114d640000`, `r12 = 0x14400`. The awaited float at `0x114d690ffc` is `0xbf800000`, and the floats before it are 0. - The log shows the image: `StorageTexture address=0x114d640000 384x216 mips=1 … tile=0 format=22 vk=100`, i.e. linear R32F, and 384×216 = 0x14400 floats. - A hardware write breakpoint on the game's per-frame state flag (`perf record -e mem:<addr>/4:w`) shows the cycle 1→3→4→5→1 once per frame. At the freeze the worker sets 1 and the main thread never releases it. ### Code path (main `961b25fe`) - `GuestMemory.hpp`: "The graphics layer keeps the results of storage images on the GPU until guest memory is read; it registers a hook that stores every pending result overlapping a range, which every read and store through this interface calls first." - `FlushGpuWrites` callers are all driver-side reads (copies, display buffers, shader fetches, buffer views). Nothing covers a guest CPU load. - `VulkanDevice.cpp:2219`: `FlushAllPending("flip")` only runs with `APS5_STORE_AT_FLIP=1`. Even with it, this title polls before the flip, so it would still wait. ### Local experiment With `APS5_EAGER_WRITEBACK=1` the run is faster overall, but at frame 437 it aborts in a compute shader the earlier runs never dispatched: ``` compute shader 0x116bb5d700: ShaderRecompiler::Recompile: computed/data-dependent s_swappc_b64 call target at program counter 0x00001ac4 is not statically resolvable ``` That is a separate gap (same class as #2062 / #1817). What I don't know: which label the console uses to order this result before the CPU read. I did not trace the dispatch's own release packet. Related: #3146, #3158. </details> *Tested and written by Claude (AI assistant) on a contributor's machine.*
Tamalero commented 2026-10-11 08:07:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-11T08:07:11Z.


A fix with a test is in #3334 (closed by the intake bot, so it can be reopened or carried). When a queue worker runs out of work, it stores the pending storage-image results and submits the stores. With it, Ratchet gets past this wait without APS5_EAGER_WRITEBACK in 3 of 3 runs and stops later at #3274. The intro logos also run faster than with eager write-back.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106972242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3272#issuecomment-6106972242). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-11T08:07:11Z. --- A fix with a test is in #3334 (closed by the intake bot, so it can be reopened or carried). When a queue worker runs out of work, it stores the pending storage-image results and submits the stores. With it, Ratchet gets past this wait without `APS5_EAGER_WRITEBACK` in 3 of 3 runs and stops later at #3274. The intro logos also run faster than with eager write-back. *Tested and written by Claude (AI assistant) on a contributor's machine.*
MarcZX10 commented 2026-10-11 16:40:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T16:40:21Z.


I opened Marc PR #3777 with an independently authored queue-idle write-back path and a focused execution regression. The test builds and passes locally on Linux (GCC 12.2, Release); the PR body records the title run report from the earlier issue work separately, since I did not run the game.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111265745 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3272#issuecomment-6111265745). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T16:40:21Z. --- I opened Marc PR #3777 with an independently authored queue-idle write-back path and a focused execution regression. The test builds and passes locally on Linux (GCC 12.2, Release); the PR body records the title run report from the earlier issue work separately, since I did not run the game.
Sign in to join this conversation.
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#3272
No description provided.