'flat' interpolation qualifier needed on vertex output?

I have a vertex/fragment shader pair that passes a color to the fragment shader with the 'flat' qualifier. On iOS (9.2.1, iPad Mini 2) it's generating a "mismatch between vertex and fragment function" error when I attempt to create a pipeline. According to the Metal Shading Language docs though:


"Sampling and interpolation qualifiers are used with inputs to fragment functions declared with the

stage_in
qualifier."


Which suggests you should *not* put any type of interpolation qualifier on vertex shader output. If I do add the 'flat' in the vertex shader then everything seems to work fine. On OSX there is no error in either case. Is this a bug in the compiler, or are the docs wrong?

Can you share the signatures of your vertex and fragment functions, as well as the definitions of the relevant structs? Usually, the output structure of the vertex function is the same type as the

stage_in
-qualified input of the fragment function (which is interpolated by the rasterizer), so attributing the color parameter with
[[flat]]
in that structure definition should work.

The vertex shader output struct looks like this:


struct xlatMtlShaderOutput {
    float4 gl_Position [[position]];
    half4 out_color0;
    half4 out_color1;
    float4 out_texcoord0;
};


The fragment shader input looks like:


struct xlatMtlShaderInput {
     half4 out_color0 [[flat]];
     half4 out_color1 [[flat]];
};


As you ca see these were converted from glsl with glsl_optmizer. I had to modify the glsl_optimizer source to add the interpolation qualifiers in the first place, and I explicitly restricted it to only the fragment shader. I thought I did this because I was seeing compile errors when the qualifiers were present in vertex shaders but I can't really be sure now, maybe I had just read that sentence in the Metal docs that I quoted above.


But you're saying it should be fine to include the qualifier on both the input and output?


Thanks,

Evan

Looks like this is still a problem with Spirv-Cross not placing interpolation modifiers onto vertex shader outputs. Can we get any clarification from Apple, since the docs are super confusing on these. It states that only the "fragment input" needs these modifiers, but the vertex output is also mostly the fragment input. I assume the vs output and ps input both need the same modifier, or the render pipeline fails to link.

https://github.com/KhronosGroup/SPIRV-Cross/issues/1542
'flat' interpolation qualifier needed on vertex output?
 
 
Q