fix(agc): read zero for pixel inputs of parameters the vertex stage does not export #3523

Merged
XairRrR merged 2 commits from upstream-pr/3523 into main 2026-10-11 21:36:21 +00:00
XairRrR commented 2026-10-11 12:18:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-11T12:18:20Z.


What

Fixes #2975. Same approach as #3336 by @Tamalero, which the intake pause closed. This version also covers FP16 inputs (see below).

A pixel input whose SPI_PS_INPUT_CNTL offset names a parameter that the previous stage does not export failed interface validation, so the draw threw:

graphics interfaces disagree at location 1 (stage 0 output missing, stage 1 input vertex:f32x4; previous outputs: 0:vertex:f32x4; parameter exports: 0; fragment parameters: 0<-0 1<-1 2<-2 3<-3 4<-4 5<-5 6<-6)

No export writes that parameter slot for the draw. radeonsi programs a pixel input without a matching vertex output as OFFSET 0x20 with DEFAULT_VAL 0, so it reads (0, 0, 0, 0) (SI_PS_INPUT_CNTL_UNUSED in src/gallium/drivers/radeonsi/si_shader.h, applied in si_shader.c). Rect-list draws here already pass zero for such inputs.

Changes:

  • Graphics::DefaultUnexportedInputs makes each input whose parameter the previous stage's program does not export read zero: OFFSET bit 5 set, DEFAULT_VAL and FLAT_SHADE cleared.
  • An FP16 input also reads zero in its high half: USE_DEFAULT_ATTR1 set and DEFAULT_VAL_ATTR1 cleared. The recompiler reads the high half's default from those fields (InputHalfIsDefault), so without this the input would still need an interface slot.
  • Inputs that already read a default are unchanged.
  • The execution draw path applies it to the pixel stage, using the parameter exports of the closest preceding stage.

Test in tests/Graphics.cpp (UnexportedPixelInputTests):

  • exported inputs are unchanged, and unexported ones read zero, including flat ones and ones with a non-zero DEFAULT_VAL;
  • FP16 inputs read zero in both halves;
  • inputs that already read a default are unchanged;
  • settings past the input count are left alone.

Uncharted: Legacy of Thieves Collection (PPSA05684) issues such draws: a pixel shader reads seven parameters after a vertex shader that exports one. With this change, these draws no longer throw.

Tested

  • Arch Linux (kernel 7.2.6), GCC 16.2.1, NVIDIA RTX 4070 Ti SUPER (driver 615.71.09), Release with BUILD_TESTING=ON.
  • Branch built alone on main a11c8f7f. Full ctest: 831/832. The one failure, agc_driver_emulated_color_compare, fails the same way on plain main. Conventions check passed.
  • Title: Uncharted: Legacy of Thieves Collection (PPSA05684), on its own bring-up branch.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818990158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3523). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-11T12:18:20Z. --- ### What Fixes #2975. Same approach as #3336 by @Tamalero, which the intake pause closed. This version also covers FP16 inputs (see below). A pixel input whose `SPI_PS_INPUT_CNTL` offset names a parameter that the previous stage does not export failed interface validation, so the draw threw: ``` graphics interfaces disagree at location 1 (stage 0 output missing, stage 1 input vertex:f32x4; previous outputs: 0:vertex:f32x4; parameter exports: 0; fragment parameters: 0<-0 1<-1 2<-2 3<-3 4<-4 5<-5 6<-6) ``` No export writes that parameter slot for the draw. radeonsi programs a pixel input without a matching vertex output as `OFFSET` 0x20 with `DEFAULT_VAL` 0, so it reads (0, 0, 0, 0) (`SI_PS_INPUT_CNTL_UNUSED` in `src/gallium/drivers/radeonsi/si_shader.h`, applied in `si_shader.c`). Rect-list draws here already pass zero for such inputs. Changes: - `Graphics::DefaultUnexportedInputs` makes each input whose parameter the previous stage's program does not export read zero: `OFFSET` bit 5 set, `DEFAULT_VAL` and `FLAT_SHADE` cleared. - An FP16 input also reads zero in its high half: `USE_DEFAULT_ATTR1` set and `DEFAULT_VAL_ATTR1` cleared. The recompiler reads the high half's default from those fields (`InputHalfIsDefault`), so without this the input would still need an interface slot. - Inputs that already read a default are unchanged. - The execution draw path applies it to the pixel stage, using the parameter exports of the closest preceding stage. Test in `tests/Graphics.cpp` (`UnexportedPixelInputTests`): - exported inputs are unchanged, and unexported ones read zero, including flat ones and ones with a non-zero `DEFAULT_VAL`; - FP16 inputs read zero in both halves; - inputs that already read a default are unchanged; - settings past the input count are left alone. Uncharted: Legacy of Thieves Collection (PPSA05684) issues such draws: a pixel shader reads seven parameters after a vertex shader that exports one. With this change, these draws no longer throw. ### Tested - Arch Linux (kernel 7.2.6), GCC 16.2.1, NVIDIA RTX 4070 Ti SUPER (driver 615.71.09), Release with `BUILD_TESTING=ON`. - Branch built alone on main a11c8f7f. Full ctest: 831/832. The one failure, `agc_driver_emulated_color_compare`, fails the same way on plain main. Conventions check passed. - Title: Uncharted: Legacy of Thieves Collection (PPSA05684), on its own bring-up branch. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
adriadam10 commented 2026-10-11 21:29:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:29:35Z.


Checked the diff against #2975 and radeonsi's SI_PS_INPUT_CNTL_UNUSED (OFFSET bit 5, DEFAULT_VAL 0); agc_driver_graphics passes, the new test does not build without the change, and the scoped libSceAgcDriver ctest is green (390/390).

Added by us: a TechnicalDebt line under "Functional" recording that the zero default follows radeonsi and is not measured on console hardware.

Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113982182 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3523#issuecomment-6113982182). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:29:35Z. --- Checked the diff against #2975 and radeonsi's `SI_PS_INPUT_CNTL_UNUSED` (OFFSET bit 5, `DEFAULT_VAL` 0); `agc_driver_graphics` passes, the new test does not build without the change, and the scoped libSceAgcDriver ctest is green (390/390). Added by us: a TechnicalDebt line under "Functional" recording that the zero default follows radeonsi and is not measured on console hardware. Merging once CI is green.
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!3523
No description provided.