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

Closed
opened 2026-10-10 19:09:18 +00:00 by tv7 · 2 comments
tv7 commented 2026-10-10 19:09:18 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-10T19:09:18Z.


What

A pixel shader that reads a parameter the vertex shader never exports is handled differently by the two graphics paths:

  • rect-list draws take it: BuildRectListShaders marks it missing and the generated stages pass zero ("as it would from an unwritten parameter cache entry", RectListShaders.cpp).
  • ordinary vertex -> pixel draws fail in ValidateShaders, which requires every fragment input location to be a previous-stage output.

So the same pixel shader works in a rect-list draw and stops presentation in a triangle draw.

Where it shows up

Marvel's Wolverine (PPSA03671), Windows 11, RTX 3070, GCC 15.2.0 UCRT Release, main 1476f769 + #1940 + #757 + #2838 + #2917 + #2922 (+ 2 local placeholders for unnamed imports). First presentation:

[videoout] presentation failed: AGC graphics: graphics interfaces disagree at location 0 (stage 0 output missing, stage 1 input vertex:f32x4; previous outputs:; parameter exports:; fragment parameters: 0<-0)

Local logging of every draw whose pixel shader reads a parameter the vertex result does not list in parameterExports:

unexported param 0: vs 0x11d00c3300 fs 0x11d015f100 rectList 1 programs 2   <- works (zero-filled)
unexported param 0: vs 0x11d00bd000 fs 0x11d015f100 rectList 0 programs 2   <- the failing draw

Both vertex shaders export only position. Pixel shader 0x11d015f100 reads parameter 0 (SPI_PS_INPUT_CNTL_0 offset 0, not a default value) in its registered variants and in the variant #2917 prepares at use, so this is not caused by #2917.

Test

With a local change that skips the check for missing fragment inputs on the non-rect path (no zero-fill; NVIDIA accepts the pipeline), Wolverine passes this draw and goes on until it runs out of video memory (vkAllocateMemory storage texture: Vulkan result -2, a separate issue). So this is the only interface mismatch on its path so far.

Possible fix

Treat a non-exported parameter on the ordinary path the way the rect-list path already does (reads zero). I have not written this: the vertex and pixel results are compiled separately, so it needs a decision on where the link-time zero source belongs (a vertex variant that writes zero for the missing locations, or a pixel variant that reads a constant). BuildBarycentricGeometryShader currently refuses the same case ("not exported by the vertex shader"), so it would need the same rule.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5794401341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2975). Originally posted by [tv7](https://github.com/tv7) on 2026-10-10T19:09:18Z. --- ### What A pixel shader that reads a parameter the vertex shader never exports is handled differently by the two graphics paths: - **rect-list draws** take it: `BuildRectListShaders` marks it `missing` and the generated stages pass zero ("as it would from an unwritten parameter cache entry", `RectListShaders.cpp`). - **ordinary vertex -> pixel draws** fail in `ValidateShaders`, which requires every fragment input location to be a previous-stage output. So the same pixel shader works in a rect-list draw and stops presentation in a triangle draw. ### Where it shows up Marvel's Wolverine (PPSA03671), Windows 11, RTX 3070, GCC 15.2.0 UCRT Release, main 1476f769 + #1940 + #757 + #2838 + #2917 + #2922 (+ 2 local placeholders for unnamed imports). First presentation: ``` [videoout] presentation failed: AGC graphics: graphics interfaces disagree at location 0 (stage 0 output missing, stage 1 input vertex:f32x4; previous outputs:; parameter exports:; fragment parameters: 0<-0) ``` Local logging of every draw whose pixel shader reads a parameter the vertex result does not list in `parameterExports`: ``` unexported param 0: vs 0x11d00c3300 fs 0x11d015f100 rectList 1 programs 2 <- works (zero-filled) unexported param 0: vs 0x11d00bd000 fs 0x11d015f100 rectList 0 programs 2 <- the failing draw ``` Both vertex shaders export only position. Pixel shader 0x11d015f100 reads parameter 0 (`SPI_PS_INPUT_CNTL_0` offset 0, not a default value) in its registered variants and in the variant #2917 prepares at use, so this is not caused by #2917. ### Test With a local change that skips the check for missing fragment inputs on the non-rect path (no zero-fill; NVIDIA accepts the pipeline), Wolverine passes this draw and goes on until it runs out of video memory (`vkAllocateMemory storage texture: Vulkan result -2`, a separate issue). So this is the only interface mismatch on its path so far. ### Possible fix Treat a non-exported parameter on the ordinary path the way the rect-list path already does (reads zero). I have not written this: the vertex and pixel results are compiled separately, so it needs a decision on where the link-time zero source belongs (a vertex variant that writes zero for the missing locations, or a pixel variant that reads a constant). `BuildBarycentricGeometryShader` currently refuses the same case ("not exported by the vertex shader"), so it would need the same rule.
Silverash-i8 commented 2026-10-10 22:00:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-10T22:00:48Z.


One thing that might make the pixel-side option smaller than it looks: the recompiler already handles the hardware's default-value inputs. ShaderPixelInputInfo::InputIsDefault treats an SPI_PS_INPUT_CNTL entry with (value & 0x420) == 0x20 (OFFSET bit 5 set, not passthrough) as "read DEFAULT_VAL", with InputDefaultBits giving (0,0,0,0) for DEFAULT_VAL 0. SpirvModuleEmitter.cpp then returns those default bits as a constant for a read of that input, ShaderInfoCollector leaves it out of the interpolation slots, and PixelInputLocation refuses to turn it into a fragment parameter.

So a pixel variant whose missing parameter has its setting rewritten to 0x20 reads zero, like the rect-list path, without any new SPIR-V and without the vertex module changing. The cost is the one you point out: the setting would depend on the paired vertex result's parameterExports, so that pixel variant can't be prepared at registration on its own. It would have to be prepared at use (the path #2917 adds), keyed by the rewritten settings.

The vertex-side option (patching the vertex module to write zero to the missing locations) keeps the pixel variants as they are, but needs a SPIR-V rewrite at link time and a different pre-rasterization library key per missing set. As far as I can see there's no SPIR-V patching in the driver today; ShaderValidation.cpp only inspects modules.

I haven't written either, since it's a design call for the maintainers. Just flagging that the default-value machinery is already there if the pixel side is preferred.

AI-assisted (Claude Code); read from main dc105f8a, nothing run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102632435 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2975#issuecomment-6102632435). Originally posted by [Silverash-i8](https://github.com/Silverash-i8) on 2026-10-10T22:00:48Z. --- One thing that might make the pixel-side option smaller than it looks: the recompiler already handles the hardware's default-value inputs. `ShaderPixelInputInfo::InputIsDefault` treats an `SPI_PS_INPUT_CNTL` entry with `(value & 0x420) == 0x20` (OFFSET bit 5 set, not passthrough) as "read DEFAULT_VAL", with `InputDefaultBits` giving (0,0,0,0) for DEFAULT_VAL 0. `SpirvModuleEmitter.cpp` then returns those default bits as a constant for a read of that input, `ShaderInfoCollector` leaves it out of the interpolation slots, and `PixelInputLocation` refuses to turn it into a fragment parameter. So a pixel variant whose missing parameter has its setting rewritten to `0x20` reads zero, like the rect-list path, without any new SPIR-V and without the vertex module changing. The cost is the one you point out: the setting would depend on the paired vertex result's `parameterExports`, so that pixel variant can't be prepared at registration on its own. It would have to be prepared at use (the path #2917 adds), keyed by the rewritten settings. The vertex-side option (patching the vertex module to write zero to the missing locations) keeps the pixel variants as they are, but needs a SPIR-V rewrite at link time and a different pre-rasterization library key per missing set. As far as I can see there's no SPIR-V patching in the driver today; `ShaderValidation.cpp` only inspects modules. I haven't written either, since it's a design call for the maintainers. Just flagging that the default-value machinery is already there if the pixel side is preferred. AI-assisted (Claude Code); read from `main` `dc105f8a`, nothing run.
Tamalero commented 2026-10-11 08:08:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-11T08:08:48Z.


A fix following @Silverash-i8's suggestion is in #3336 (closed by the intake bot, so it can be reopened or carried). For a plain vertex to pixel draw, every SPI_PS_INPUT_CNTL entry whose slot the compiled vertex shader does not export becomes a default-value input (OFFSET bit 5, DEFAULT_VAL 0), so the pixel shader reads (0, 0, 0, 0) as rect-list draws already do. It has a unit test. Marvel's Guardians of the Galaxy (PPSA01748) hits this same stop and gets past it with the change; I haven't tested Wolverine.

Tested and written by Claude (AI assistant) on a contributor's machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106984645 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2975#issuecomment-6106984645). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-11T08:08:48Z. --- A fix following @Silverash-i8's suggestion is in #3336 (closed by the intake bot, so it can be reopened or carried). For a plain vertex to pixel draw, every `SPI_PS_INPUT_CNTL` entry whose slot the compiled vertex shader does not export becomes a default-value input (`OFFSET` bit 5, `DEFAULT_VAL` 0), so the pixel shader reads (0, 0, 0, 0) as rect-list draws already do. It has a unit test. Marvel's Guardians of the Galaxy (PPSA01748) hits this same stop and gets past it with the change; I haven't tested Wolverine. *Tested and written by Claude (AI assistant) on a contributor's machine.*
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#2975
No description provided.