Pixel shader reading a parameter the vertex shader never exports: rect-list draws zero-fill it, ordinary draws fail validation #2975
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
BuildRectListShadersmarks itmissingand the generated stages pass zero ("as it would from an unwritten parameter cache entry",RectListShaders.cpp).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:Local logging of every draw whose pixel shader reads a parameter the vertex result does not list in
parameterExports:Both vertex shaders export only position. Pixel shader 0x11d015f100 reads parameter 0 (
SPI_PS_INPUT_CNTL_0offset 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).
BuildBarycentricGeometryShadercurrently refuses the same case ("not exported by the vertex shader"), so it would need the same rule.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::InputIsDefaulttreats anSPI_PS_INPUT_CNTLentry with(value & 0x420) == 0x20(OFFSET bit 5 set, not passthrough) as "read DEFAULT_VAL", withInputDefaultBitsgiving (0,0,0,0) for DEFAULT_VAL 0.SpirvModuleEmitter.cppthen returns those default bits as a constant for a read of that input,ShaderInfoCollectorleaves it out of the interpolation slots, andPixelInputLocationrefuses to turn it into a fragment parameter.So a pixel variant whose missing parameter has its setting rewritten to
0x20reads 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'sparameterExports, 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.cpponly 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
maindc105f8a, nothing run.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_CNTLentry whose slot the compiled vertex shader does not export becomes a default-value input (OFFSETbit 5,DEFAULT_VAL0), 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.