Skip to content

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

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
XairRrR:fix/agc-default-unexported-pixel-inputs
Oct 11, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
XairRrR:fix/agc-default-unexported-pixel-inputs

Conversation

@XairRrR

@XairRrR XairRrR commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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 a11c8f7. 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

@github-actions github-actions Bot added the agc libSceAgc* label Oct 11, 2026
…oes not export

A pixel input whose SPI_PS_INPUT_CNTL offset names a parameter the
previous stage does not export failed validation ("graphics interfaces
disagree"), so the draw threw. 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 that it reads (0, 0, 0, 0)
(SI_PS_INPUT_CNTL_UNUSED in si_shader.h, applied in si_shader.c), and
rect-list draws already pass zero for such inputs.

Before the pixel stage of a draw is prepared, inputs that read a
parameter the previous stage's program does not export now read zero:
OFFSET bit 5 is set, DEFAULT_VAL and FLAT_SHADE are cleared, and an FP16
input also reads zero in its high half (USE_DEFAULT_ATTR1 set,
DEFAULT_VAL_ATTR1 cleared). Inputs that already read a default value
are unchanged.

Fixes boykopovar#2975.
@XairRrR
XairRrR force-pushed the fix/agc-default-unexported-pixel-inputs branch from 7820f73 to 2f140cb Compare October 11, 2026 14:16
@adriadam10

Copy link
Copy Markdown
Collaborator

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pixel shader reading a parameter the vertex shader never exports: rect-list draws zero-fill it, ordinary draws fail validation

2 participants