Recompiler: relative VGPR addressing lowers to a select chain over the register window; Killzone: Liberation (PPSA11142) freezes compiling a 649k-word mesh shader; fix branch ready #3842

Closed
opened 2026-10-11 17:51:04 +00:00 by Mouad-Scriptz-0 · 0 comments
Mouad-Scriptz-0 commented 2026-10-11 17:51:04 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-11T17:51:04Z.


Follow-up to #3622. With #3539, #3738 and local fixes for its barycentric and provoking-vertex stops, Killzone: Liberation (PPSA11142 01.000.004, Sony's PSP emulator wrapper, Linux) reaches its first PSP frame and then freezes: the frame needs a merged (geometry-path) program of 3176 ISA words that the recompiler turns into 649,515 SPIR-V words with 32,383 OpSelect, and Intel's compiler (Mesa 26.2.3, ANV, Arc Meteor Lake) did not finish it in six minutes and 7 GiB; the thread sits in brw_opt_register_coalesce/brw_live_variables.

Cause. The program addresses its vector registers relatively 104 times (v_movrels_b32 94, v_movreld_b32 10, M0 from scalars such as (s34 << 1) - 2), with bases down to v0 and 154 registers allocated. readRelativeVector/writeRelativeVector (ControlFlowInstructions.cpp) lower each access to a compare-and-select chain over every register from the base to the program's last allocated register, so the IR carried 15,768 SelectU32 and 13,127 IEqual32 before any backend work (APS5_DUMP_IR).

Fix branch ready: Mouad-Scriptz-0:feat/recompiler-vector-window (f8ed012e, one commit on main a11c8f7f). I cannot open it as a PR while #3738 is my one open pull request; anyone eligible is welcome to carry it, keeping the commit as is, or I open it once #3738 is decided. tools/pr_overlap.py --branch reports #3741 touching the same test-registration line in libSceAgcDriver/CMakeLists.txt (one-line merge).

  • The registers from the lowest relative base register up to the program's vector limit live in a function-scope array per invocation, one element per register, through two new IR instructions, LoadVectorWindow and StoreVectorWindow; IrBuilder::GetVectorReg/SetVectorReg route plain accesses to those registers through the same array, so the SSA register model only covers the registers below the window. The window is chosen in Translate from the decoded instructions before the entry prologue writes any register; programs without relative addressing are unchanged.
  • A relative read is one load of UMin(base + offset, size - 1), a relative write one load, the exec-masked select (or the DppUpdateU32 merge when the destination carries a DPP control, as a plain write does) and one store. An index past the window reads 0 and drops its write, as the RDNA ISA describes for out-of-range VGPR indexing; the chain read the base register and dropped the write. Neither is measured on the console (TechnicalDebt entry).
  • The SPIR-V backend declares the array per lane half like scratch_dwords and emits OpAccessChain/OpLoad/OpStore.
  • agc_vector_window (new) recompiles a compute program with v_movrels_b32/v_movreld_b32 and checks for one function-scope array of the window's length, its access chains and no select chain, and that a program without relative addressing keeps no such array. agc_driver_relative_indexing, agc_driver_scalar_relative_indexing and agc_driver_dpp16_operands cover the semantics; the DPP merge was caught by the last one.

Result. The program recompiles to 392,333 words with 4,992 selects (the rest is the driver's bounds and lane guards on its memory accesses, out of scope here). The title plays its logos and reaches its language menu at the PSP 30 fps cap on this iGPU. A new pipeline variant of that program still compiles for about 20 s with APS5_NO_PIPELINE_LTO=1; with the background optimized link on, the link's second compile doubles CPU and memory and the stall runs into minutes, which may be worth a look on its own. Two rendering defects remain on the title and are being looked at separately: 4x4 texel blocks missing from PSP textures read through storage-image views of imported memory (absent with APS5_NO_SAMPLED_FROM_STORAGE=1, so a refresh race rather than tiling), and half-drawn text sprites on the language menu, which is not yet attributed.

Tested on Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, Intel Arc Meteor Lake iGPU, Mesa 26.2.3):

  • agc_vector_window, agc_driver_relative_indexing, agc_driver_scalar_relative_indexing and agc_driver_dpp16_operands pass.
  • ctest -j4 --timeout 180 on a tree carrying this change with #3622, #3534 and the two further local AGC fixes, without the seven agc_driver_* tests that fail the same way on a clean main build on this iGPU: 821 passed, 5 skipped, 1 failed (agc_driver_emulated_color_compare, an ANV sRGB sampling limit that fails identically on clean main).
  • tools/check_conventions.py --base origin/main, tools/check_test_registration.py build and git diff --check pass. Not tested on Windows.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5803607090 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3842). Originally posted by [Mouad-Scriptz-0](https://github.com/Mouad-Scriptz-0) on 2026-10-11T17:51:04Z. --- Follow-up to #3622. With #3539, #3738 and local fixes for its barycentric and provoking-vertex stops, Killzone: Liberation (PPSA11142 01.000.004, Sony's PSP emulator wrapper, Linux) reaches its first PSP frame and then freezes: the frame needs a merged (geometry-path) program of 3176 ISA words that the recompiler turns into 649,515 SPIR-V words with 32,383 `OpSelect`, and Intel's compiler (Mesa 26.2.3, ANV, Arc Meteor Lake) did not finish it in six minutes and 7 GiB; the thread sits in `brw_opt_register_coalesce`/`brw_live_variables`. **Cause.** The program addresses its vector registers relatively 104 times (`v_movrels_b32` 94, `v_movreld_b32` 10, M0 from scalars such as `(s34 << 1) - 2`), with bases down to v0 and 154 registers allocated. `readRelativeVector`/`writeRelativeVector` ([ControlFlowInstructions.cpp](https://github.com/boykopovar/AnyPS5/blob/a11c8f7f70a0ed4e71504a89de69e8cdae687817/core/shader/recompiler/Translation/src/ControlFlowInstructions.cpp#L296)) lower each access to a compare-and-select chain over every register from the base to the program's last allocated register, so the IR carried 15,768 `SelectU32` and 13,127 `IEqual32` before any backend work (`APS5_DUMP_IR`). **Fix branch ready:** [`Mouad-Scriptz-0:feat/recompiler-vector-window`](https://github.com/Mouad-Scriptz-0/AnyPS5/tree/feat/recompiler-vector-window) (`f8ed012e`, one commit on `main` a11c8f7f). I cannot open it as a PR while #3738 is my one open pull request; anyone eligible is welcome to carry it, keeping the commit as is, or I open it once #3738 is decided. `tools/pr_overlap.py --branch` reports #3741 touching the same test-registration line in `libSceAgcDriver/CMakeLists.txt` (one-line merge). - The registers from the lowest relative base register up to the program's vector limit live in a function-scope array per invocation, one element per register, through two new IR instructions, `LoadVectorWindow` and `StoreVectorWindow`; `IrBuilder::GetVectorReg`/`SetVectorReg` route plain accesses to those registers through the same array, so the SSA register model only covers the registers below the window. The window is chosen in `Translate` from the decoded instructions before the entry prologue writes any register; programs without relative addressing are unchanged. - A relative read is one load of `UMin(base + offset, size - 1)`, a relative write one load, the exec-masked select (or the `DppUpdateU32` merge when the destination carries a DPP control, as a plain write does) and one store. An index past the window reads 0 and drops its write, as the RDNA ISA describes for out-of-range VGPR indexing; the chain read the base register and dropped the write. Neither is measured on the console (TechnicalDebt entry). - The SPIR-V backend declares the array per lane half like `scratch_dwords` and emits `OpAccessChain`/`OpLoad`/`OpStore`. - `agc_vector_window` (new) recompiles a compute program with `v_movrels_b32`/`v_movreld_b32` and checks for one function-scope array of the window's length, its access chains and no select chain, and that a program without relative addressing keeps no such array. `agc_driver_relative_indexing`, `agc_driver_scalar_relative_indexing` and `agc_driver_dpp16_operands` cover the semantics; the DPP merge was caught by the last one. **Result.** The program recompiles to 392,333 words with 4,992 selects (the rest is the driver's bounds and lane guards on its memory accesses, out of scope here). The title plays its logos and reaches its language menu at the PSP 30 fps cap on this iGPU. A new pipeline variant of that program still compiles for about 20 s with `APS5_NO_PIPELINE_LTO=1`; with the background optimized link on, the link's second compile doubles CPU and memory and the stall runs into minutes, which may be worth a look on its own. Two rendering defects remain on the title and are being looked at separately: 4x4 texel blocks missing from PSP textures read through storage-image views of imported memory (absent with `APS5_NO_SAMPLED_FROM_STORAGE=1`, so a refresh race rather than tiling), and half-drawn text sprites on the language menu, which is not yet attributed. **Tested** on Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, Intel Arc Meteor Lake iGPU, Mesa 26.2.3): - `agc_vector_window`, `agc_driver_relative_indexing`, `agc_driver_scalar_relative_indexing` and `agc_driver_dpp16_operands` pass. - `ctest -j4 --timeout 180` on a tree carrying this change with #3622, #3534 and the two further local AGC fixes, without the seven `agc_driver_*` tests that fail the same way on a clean `main` build on this iGPU: 821 passed, 5 skipped, 1 failed (`agc_driver_emulated_color_compare`, an ANV sRGB sampling limit that fails identically on clean `main`). - `tools/check_conventions.py --base origin/main`, `tools/check_test_registration.py build` and `git diff --check` pass. Not tested on Windows. AI-assisted: yes (Claude Code).
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#3842
No description provided.