Ratchet & Clank: Rift Apart (PPSA01474): the compute shader whose s_swappc_b64 calls a computed target becomes a 2.5M-word SPIR-V module that RADV cannot compile (nir_opt_copy_prop_vars grows past 16 GB; Mesa 25.2.8 and 26.2.6) #13538
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-30T17:48:22Z.
On AMD (RADV) Ratchet & Clank is OOM-killed about 4 minutes in, every time. It is not a leak in AnyPS5: the pipeline for one generated compute shader never finishes compiling, and Mesa's
nir_opt_copy_prop_varspass allocates about 330 MB/s until the process is killed. The module is 2,516,220 SPIR-V words and makes 7,279 helper calls, which Mesa inlines. Compiled on its own, outside the title, it reaches 16 GB in 44–47 s on both Mesa 25.2.8 and 26.2.6. The same build plays past this point on an RTX 4090 (NVIDIA proprietary driver). Related: #3274 (thes_swappc_b64through a per-lane function table in Ratchet, most likely this shader), #12089 (Mafia, an 873k-word compute pipeline that takes 37 s on AMD).What happens
The frame counter stops at about frame 600 and the process's anonymous memory grows about 330 MB/s from then on (guest direct memory stays flat at about 9.8 GB) until the cgroup limit kills it: 244–252 s at a 52 GB limit, 187 s at 36 GB.
dmesgshows only the cgroup OOM kill: no ring timeout, no GPU reset. The shader is the compute program whoses_swappc_b64calls a computed target (its address changes from run to run;0x116bb5a200in this run, withAPS5_PROFILE_DRAW=1):No
created a pipelineline follows. The registration line (with program counter0x1ac4) appears in all 9 runs that reached the memory growth (7 OOM-killed, 2 stopped under gdb). It does not appear in the 3 runs that survived (APS5_NO_HOST_IMPORT=1, orAPS5_HOST_IMPORT_MIB=2048): in those, stores fail withdeferred write-back failed: BDA access failed … read-only in the BDA tableand the title never reaches that dispatch, so they say nothing about the shader.Title, test or build step
Ratchet & Clank: Rift Apart (PPSA01474) 01.005.003, cold shader cache.
AnyPS5 commit
mainbb04a4f1eawith #9749, #10906 and #10000 merged (needed to get this far), plus local, environment-gated audio and dispatch-skip changes that are not pushed. The emitter files involved (SpirvRuntimeBuffer.cpp,SpirvBdaRead.cpp,SpirvBdaFault.cpp) andResourceTracker.cpp'sTakeGpuDescriptorare unchanged by those PRs and on currentmain(223b19ba0a). I have not rerun the title on currentmain.System
Ubuntu 24.04.5, kernel 7.0.0-38, AMD Radeon Pro V620 (NAVI21, RDNA2, passed through to a VM), AMD EPYC 7452 (24 vCPUs). RADV from Ubuntu's Mesa 25.2.8, and Mesa 26.2.6 built from the release tarball (RADV only, no LLVM).
What was checked
Where the time goes. gdb on the running title with Ubuntu's debug symbols (debuginfod), and again on the standalone compile with Mesa 26.2.6, shows the same pass, already in the first
nir_opt_copy_prop_varscall ofradv_shader_spirv_to_nir:The module. Caught with
MESA_SPIRV_DUMP_PATHas memory started to grow: GLCompute, 2,516,220 words.mainalone has 45,152 blocks (16k selection merges, 340 loops, 18k phis) and makes 7,279 calls into 25 helpers:record_bda_faultread_bda_span_stopload_formatted_gpu_buffer_x1…x4get_bda_pointerMesa inlines every SPIR-V function before this pass (the
FunctionControlDontInlineMaskthatformattedGpuCallsets does not survive into NIR), so RADV works on roughly 190k blocks. The formatted loads come fromformattedDispatch→formattedGpuCall: the V# is chosen at run time (TakeGpuDescriptorsetsgpuDescriptor) and its format word is not an immediate, so every load goes through the fullformatSwitch. The other module captured in the same run (70 KB) compiles in 0.1–0.2 s.Standalone repro, with the dumped module in a small
vkCreateComputePipelinesharness (reflected layout,MESA_SHADER_CACHE_DISABLE=true, 16 GB cgroup limit):In the title on Mesa 26.2.6 (same build, cold cache, 52 GB limit): the same course. The program counter
0x1ac4shader is prepared at use, the frame counter stops at 600 about 106 s in, anonymous memory grows about 295 MB/s, and the cgroup kills the process at 249 s (25.2.8: 244–252 s).Settings that do not move it (one per run, 52 GB limit):
APS5_NO_PIPELINE_LTO=1(OOM 252 s),APS5_NO_GPL=1(252 s),APS5_TEXTURE_CACHE_MIB=2048(251 s), a warm shader cache (222 s).APS5_NO_TEXTURE_CACHE=1only delays it (542 s, reaching the same point later).What I don't know
I don't know whether this is mainly a Mesa problem (the pass scaling badly with nesting depth and inlined call count) or one AnyPS5 should avoid by emitting less for this shader; with 26.2.6 behaving the same, a Mesa fix would not help current distributions anyway. Shrinking the module seems the practical side: fewer
formatSwitchcopies per dispatch (for example one call site per distinct V#, or a format resolved once per descriptor), or fewer inlined fault sites, as discussed in #2972. Factoring into moreDontInlinefunctions, as suggested in #12089, would not help on RADV, because Mesa inlines them. I have not tried any of these.The SPIR-V module and the dumped request are game-derived, so I can't attach them; I can run any build or diagnostic patch against them on this machine and report numbers.
Tested and written by Claude (AI assistant) on a contributor's machine.