Closed dhardy closed 3 years ago
What it says is that your output color from VS must be interpolated in the same way. I.e. it has to be declared as layout(location = 0) flat out vec4 fragColor
in VS.
cc @jimblandy just in case :)
That solution works. Curious, because I thought I had already tried that only to hit shader compiler error.
Anyway, is this actually an error? On this page I find this quote:
While interpolation qualifiers can be put on any of these variables, the only ones that actually have an effect are those on the fragment shader. The pre-GL 4.3 rules on matching interfaces mean you have to provide them on other stages, but interpolation is controlled entirely by the qualifiers on the fragment shader input variables.
The specification (section 4.5) covers the interpolation modes but doesn't appear clear on where they may (or should) be used. Maybe that's elsewhere; I haven't read the whole thing.
The upstream investigation in https://github.com/gpuweb/gpuweb/issues/802 revealed that D3D requires the interpolation to match between stages. This is more strict than in Vulkan or Metal, and it became the choice for WGSL. Now, accepting SPIR-V in addition to WGSL puts us into a weird position: at the shader module level, we don't know which entry points are used with which. So we can't magically patch the vertex output interpolation...
The only reasonable choice for now that I see is that wgpu-rs expects SPIR-V to be sort of adjusted for WebGPU already. Interpolation is one of the aspects. There are also additional things, like gl_ClipDistance and gl_PointSize being unsupported.
I guess we can just close this then.
I'm updating KAS to v0.8, and get this error:
This appears to be caused by use of
flat
interpolation in my fragment shader:This has nothing to do with
Perspective
projections; interpolating or not interpolating shader inputs is valid either way. Or maybePerspective
refers to something else than the view projection? Anyway, I don't "need"flat
here but also see no reason not to use it (since I don't need interpolation of the colour input), so I think this validation error is simply wrong?