Glsl compiler bug on interpolateAtSample?

I can’t run any of the samples using

in vert
{
    vec2 Texcoord;
    //sample vec2 Texcoord;
} Vert;

layout(location = FRAG_COLOR, index = 0) out vec4 Color;

void main()
{
    Color = texture(Diffuse, interpolateAtSample(Vert.Texcoord, gl_SampleID));
    //Color = texture(Diffuse, Vert.Texcoord);
}

I get:

Shader status invalid: 0(21) : error C5229: Argument 1 for interpolateAtSample must have no component selection

Code is here

Asking on the irc opengl, a guy suggested me to use the commented out lines instead, and that works. He also said it is probabily a glsl compiler bug… what do you think?

Same for

interpolateAtOffset

From your precision definitions I assume that you are running an OpenGL ES application. The interpolation functionality is introduced with the GL_OES_shader_multisample_interpolation extension which specifies:

“For all of the interpolation functions, must be an input
variable or an element of an input variable declared as an array.
Component selection operators (e.g., “.xy”) may not be used when
specifying .”

So this is not a GLSL compiler bug. The workaround you took with the interpolation qualifier sample does not give you the same functionality, but might in your case give you the same result. The interpolation functions allow you to interpolate to a different position as the interpolation of the shader input did. So this allows you to mix centroid- and sample-based interpolation of the same input variable. If you only ever need one interpolation at a time in your shader, you’re fine.

Keep in mind that both the sample qualifier and the use of gl_SampleID enforce per-sample shading, so you lose all beneficial optimizations of multisampling.

Hi,

I am not. Plain OpenGL 4.5, but anyway GL_ARB_gpu_shader5 is available

Built-in interpolation functions are available to compute an interpolated
    value of a fragment shader input variable at a shader-specified (x,y)
    location.  A separate (x,y) location may be used for each invocation of
    the built-in function, and those locations may differ from the default
    (x,y) location used to produce the default value of the input.

      float interpolateAtCentroid(float interpolant);
      vec2 interpolateAtCentroid(vec2 interpolant);
      vec3 interpolateAtCentroid(vec3 interpolant);
      vec4 interpolateAtCentroid(vec4 interpolant);

      float interpolateAtSample(float interpolant, int sample);
      vec2 interpolateAtSample(vec2 interpolant, int sample);
      vec3 interpolateAtSample(vec3 interpolant, int sample);
      vec4 interpolateAtSample(vec4 interpolant, int sample);

      float interpolateAtOffset(float interpolant, vec2 offset);
      vec2 interpolateAtOffset(vec2 interpolant, vec2 offset);
      vec3 interpolateAtOffset(vec3 interpolant, vec2 offset);
      vec4 interpolateAtOffset(vec4 interpolant, vec2 offset);

And as you continue reading, 4 paragraphs below:

“For all of the interpolation functions, must be an input
variable or an element of an input variable declared as an array.
Component selection operators (e.g., “.xy”) may not be used when
specifying .”

You are right, I missed that… sorry

Anyway could you help me to get that? Because I am really struggling…

So in my vertex shader I declare a corresponding vertex attribute input and then I pass it along to the fragment shader (though a block), where I’d like to interpolate it at one specific sample. It makes totally sense for me.

Now in this case my interpolant texCoord is an input variable. When it talks about “Component selection operators (e.g., “.xy”) may not be used” I interpret that like I can’t use any component operator at all, such as texCoord.x, which is what I am doing, I am passing the whole vec2 texCoord to interpolateAtSample

I understand what you are asking, but I can’t really help to clear the confusion. As far as I understand the specification, excluding any component selection for the parameter of the interpolation functions is valid behavior. Even in the case of components from a struct, which individually could have components as well. I don’t know why this is done, as different interpolation qualifiers are allowed for different struct components. I have no insights in how interpolants are handled internally, but I would assume that this being specified the way it is allows the implementation of the interpolation to work more efficiently, even if this makes it less convenient for the GLSL programmer. Maybe you should ask yourself why you use structs here in the first place, when using separate in-/outputs would give you more functionality.

It’s a bug