fix(libSceAgc): link flat pixel inputs as pass-through, as the console does #27327

Merged
aKazm1 merged 1 commit from upstream-pr/27327 into main 2026-11-29 04:44:50 +00:00
aKazm1 commented 2026-11-25 20:55:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by aKazm1 on 2026-11-25T20:55:52Z.


What

sceAgcLinkShaders now maps a flat pixel input as pass-through (SPI_PS_INPUT_CNTL FLAT_SHADE with OFFSET bit 5), with the same mapping as sceAgcCreateInterpolantMapping. Before, it used the _0100 mapping, which leaves bit 5 clear.

That gap is why ps5-opengl titles stop on v_interp_mov p10 of a flat input ... is not measured (#1413). They link their shaders with sceAgcLinkShaders and read flat inputs through v_interp_mov P10, which ACO emits for load_input_vertex. On the console those inputs are pass-through, so P10 holds a vertex's value. Here they arrived as 0x402, the non-pass-through case the recompiler refuses.

Console measurement. A homebrew payload on a retail PS5 (firmware 13.00) called the console's own libSceAgc with a Wave32 NGG vertex shader and a pixel shader whose input semantic I changed:

Pixel input semantic Vertex output slot sceAgcLinkShaders sceAgcCreateInterpolantMapping
smooth (0x00000020) 0 0x000 0x000
flat (0x00400020) 0 0x420 0x420
flat (0x00400020) 2 0x422 0x422
custom (0x01000020) 0 0x420 0x420
flat + custom (0x01400020) 0 0x420 0x420

The same console drew triangles with each value forced into SPI_PS_INPUT_CNTL_0. 0x420 returns the three vertices in P0/P10/P20. 0x400 returns the provoking vertex in P0 and 0 in P10/P20, as on gfx1010 and gfx1036 (#1413). The details are in #1413.

Still open (in the debt entry):

  • Flat 16-bit inputs, and flat inputs without a matching vertex output, were not measured.
  • The console writes the 32 interpolant registers first and VGT_SHADER_STAGES_EN/VGT_GS_OUT_PRIM_TYPE after them. This implementation writes those two first. That only matters to a caller that reads the array by position, so it is not changed here.

Tested

  • Windows 11, Ryzen 9 7900X, RTX 4080 (621.40), WinLibs GCC, Release.
  • guest_shader_link, agc_interpolant_mapping, agc_shader_helpers, agc_create_shader and agc_shader_fusion pass. guest_shader_link now expects 0x425 for a flat input linked to slot 5.
  • check_conventions.py, debt_fold.py --check and pr_overlap.py pass. #23397 changes the argument checks of the same function and merges with this branch without conflicts.
  • PS5SX2 2.50 (PPSA99203, vk-285-321) with a PS2 BIOS from the tester's own console, on main 1afab89d42 with #26653 (which it needs for PCSX2's fastmem fault handler):
    • without this change, it stops as soon as the BIOS starts, with v_interp_mov p10 of a flat input with the first provoking vertex is not measured;
    • with this change, the PS2 system menu draws completely: the orb, "ブラウザ" / "システム設定" and the ○ / △ button labels, at about 45 fps. The two affected inputs were SPI_PS_INPUT_CNTL 0x402, read only through P10;
    • for comparison, returning 0 for those P10 reads (the hardware's answer for a genuinely non-pass-through input) runs, but leaves the text and the orb's lines invisible.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: PPSA99203 #4850
  • GPUs tested: NVIDIA GeForce RTX 4080, driver 621.40, Windows 11 (the PS5SX2 run). The tests above create no Vulkan device, so there is no validation-layer log to compare.
  • AI-assisted: yes

AI-assisted: Yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5499032971 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27327). Originally posted by [aKazm1](https://github.com/aKazm1) on 2026-11-25T20:55:52Z. --- ### What `sceAgcLinkShaders` now maps a flat pixel input as pass-through (`SPI_PS_INPUT_CNTL` `FLAT_SHADE` with `OFFSET` bit 5), with the same mapping as `sceAgcCreateInterpolantMapping`. Before, it used the `_0100` mapping, which leaves bit 5 clear. That gap is why ps5-opengl titles stop on `v_interp_mov p10 of a flat input ... is not measured` (#1413). They link their shaders with `sceAgcLinkShaders` and read flat inputs through `v_interp_mov` P10, which ACO emits for `load_input_vertex`. On the console those inputs are pass-through, so P10 holds a vertex's value. Here they arrived as 0x402, the non-pass-through case the recompiler refuses. **Console measurement.** A homebrew payload on a retail PS5 (firmware 13.00) called the console's own `libSceAgc` with a Wave32 NGG vertex shader and a pixel shader whose input semantic I changed: | Pixel input semantic | Vertex output slot | `sceAgcLinkShaders` | `sceAgcCreateInterpolantMapping` | |---|---|---|---| | smooth (0x00000020) | 0 | 0x000 | 0x000 | | flat (0x00400020) | 0 | **0x420** | 0x420 | | flat (0x00400020) | 2 | **0x422** | 0x422 | | custom (0x01000020) | 0 | 0x420 | 0x420 | | flat + custom (0x01400020) | 0 | 0x420 | 0x420 | The same console drew triangles with each value forced into `SPI_PS_INPUT_CNTL_0`. 0x420 returns the three vertices in P0/P10/P20. 0x400 returns the provoking vertex in P0 and 0 in P10/P20, as on gfx1010 and gfx1036 (#1413). The details are in #1413. **Still open** (in the debt entry): - Flat 16-bit inputs, and flat inputs without a matching vertex output, were not measured. - The console writes the 32 interpolant registers first and `VGT_SHADER_STAGES_EN`/`VGT_GS_OUT_PRIM_TYPE` after them. This implementation writes those two first. That only matters to a caller that reads the array by position, so it is not changed here. ### Tested - Windows 11, Ryzen 9 7900X, RTX 4080 (621.40), WinLibs GCC, Release. - `guest_shader_link`, `agc_interpolant_mapping`, `agc_shader_helpers`, `agc_create_shader` and `agc_shader_fusion` pass. `guest_shader_link` now expects 0x425 for a flat input linked to slot 5. - `check_conventions.py`, `debt_fold.py --check` and `pr_overlap.py` pass. #23397 changes the argument checks of the same function and merges with this branch without conflicts. - PS5SX2 2.50 (PPSA99203, vk-285-321) with a PS2 BIOS from the tester's own console, on `main` 1afab89d42 with #26653 (which it needs for PCSX2's fastmem fault handler): - without this change, it stops as soon as the BIOS starts, with `v_interp_mov p10 of a flat input with the first provoking vertex is not measured`; - with this change, the PS2 system menu draws completely: the orb, "ブラウザ" / "システム設定" and the ○ / △ button labels, at about 45 fps. The two affected inputs were `SPI_PS_INPUT_CNTL` 0x402, read only through P10; - for comparison, returning 0 for those P10 reads (the hardware's answer for a genuinely non-pass-through input) runs, but leaves the text and the orb's lines invisible. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: PPSA99203 #4850 - [x] GPUs tested: NVIDIA GeForce RTX 4080, driver 621.40, Windows 11 (the PS5SX2 run). The tests above create no Vulkan device, so there is no validation-layer log to compare. - [x] AI-assisted: yes AI-assisted: Yes.
MarcZX10 commented 2026-11-25 21:07:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T21:07:52Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the behavior change is covered by a focused regression assertion, and the mapping helper applies flat-default handling to the interpolant mapping.

What I ran

  • Reviewed head ccc235e2baf0696628c5928df251e4cacd2aa54d.
  • No commands or tests were run; inspected the prepared diff and pinned source through repo_read.py.

Results

Check Result Note
Diff and changed files passed Three changed files reviewed
Tests not run Author reports tests; not independently verified
Runtime behavior not run Console and emulator claims not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

The changed files read were core/libs/prx/libSceAgc/Shader/src/LinkShaders.cpp, core/libs/tests/GuestShaderLink.cpp, and docs/dev/debt/changes/fix-agc-link-flat-passthrough.md; all three files listed in the manifest were read. files.json was unavailable. Tests, build results, and the reported console and emulator behavior were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6065001505 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27327#pullrequestreview-6065001505). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T21:07:52Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the behavior change is covered by a focused regression assertion, and the mapping helper applies flat-default handling to the interpolant mapping. ## What I ran - Reviewed head `ccc235e2baf0696628c5928df251e4cacd2aa54d`. - No commands or tests were run; inspected the prepared diff and pinned source through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | Three changed files reviewed | | Tests | not run | Author reports tests; not independently verified | | Runtime behavior | not run | Console and emulator claims not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The changed files read were `core/libs/prx/libSceAgc/Shader/src/LinkShaders.cpp`, `core/libs/tests/GuestShaderLink.cpp`, and `docs/dev/debt/changes/fix-agc-link-flat-passthrough.md`; all three files listed in the manifest were read. `files.json` was unavailable. Tests, build results, and the reported console and emulator behavior were not independently verified. ## To get this to a good state Nothing is required.
Jazeupoi commented 2026-11-26 09:29:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-26T09:29:02Z.

Review: COMMENTED


Tested on a second GPU: an RTX 2060 on Windows. On this machine PS5SX2 used to stop on the P10 message as soon as the BIOS started (my comment in #1413). With this change it gets past it.

Windows 11 (10.0.26300), NVIDIA GeForce RTX 2060 (driver 621.40), WinLibs GCC 15.2, Release, on main 87f0e47be5 with this PR (ccc235e2ba), #26653 (14999dce09, for PCSX2's fastmem faults) and #26600 (a88ecab648, mine, NGG vertex line lists) merged locally. The title was relinked against that build. PS5SX2 ran with its noautoprof flag file, which avoids a SIGPROF stop that is not part of this change.

check result
guest_shader_link, agc_interpolant_mapping, agc_shader_helpers, agc_create_shader, agc_shader_fusion, guest_siginfo_fault 6 of 6 pass
PS5SX2 2.50 (PPSA99203, vk-285-321), "PS2 system menu", with a BIOS from my own console the boot animation plays and it reaches the BIOS's "Select language" screen, with all seven lines and the ✕ Enter prompt drawn. Two runs of 6 minutes each; no v_interp_mov p10 ... is not measured and no other error in the log

Not run on Linux or macOS, and not with the Vulkan validation layer.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6071558195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27327#pullrequestreview-6071558195). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-26T09:29:02Z. **Review:** COMMENTED --- Tested on a second GPU: an RTX 2060 on Windows. On this machine PS5SX2 used to stop on the P10 message as soon as the BIOS started (my comment in #1413). With this change it gets past it. Windows 11 (10.0.26300), NVIDIA GeForce RTX 2060 (driver 621.40), WinLibs GCC 15.2, Release, on `main` `87f0e47be5` with this PR (`ccc235e2ba`), #26653 (`14999dce09`, for PCSX2's fastmem faults) and #26600 (`a88ecab648`, mine, NGG vertex line lists) merged locally. The title was relinked against that build. PS5SX2 ran with its `noautoprof` flag file, which avoids a SIGPROF stop that is not part of this change. | check | result | |---|---| | `guest_shader_link`, `agc_interpolant_mapping`, `agc_shader_helpers`, `agc_create_shader`, `agc_shader_fusion`, `guest_siginfo_fault` | 6 of 6 pass | | PS5SX2 2.50 (PPSA99203, vk-285-321), "PS2 system menu", with a BIOS from my own console | the boot animation plays and it reaches the BIOS's "Select language" screen, with all seven lines and the ✕ Enter prompt drawn. Two runs of 6 minutes each; no `v_interp_mov p10 ... is not measured` and no other error in the log | Not run on Linux or macOS, and not with the Vulkan validation layer. AI-assisted: 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!27327
No description provided.