2

I have this question now since a long time, I can't get a simple multisample example running..

This is the original code, this is the vs and this the fs, that I report here for convenience:

layout(location = POSITION) in vec2 Position;
layout(location = TEXCOORD) in vec2 Texcoord;

out vert
{
    vec2 Texcoord;
} Vert;

void main()
{   
    Vert.Texcoord = Texcoord;
    gl_Position = MVP * vec4(Position, 0.0, 1.0);
}

in vert
{
    vec2 Texcoord;
} Vert;

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

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

When I run it, I get the following error:

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

What? I understand the specs says:

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);

The function interpolateAtCentroid() will return the value of the input
varying <interpolant> sampled at a location inside the both the pixel and
the primitive being processed.  The value obtained would be the same value
assigned to the input variable if declared with the "centroid" qualifier.

The function interpolateAtSample() will return the value of the input
varying <interpolant> at the location of the sample numbered <sample>.  If
multisample buffers are not available, the input varying will be evaluated
at the center of the pixel.  If the sample number given by <sample> does
not exist, the position used to interpolate the input varying is
undefined.

The function interpolateAtOffset() will return the value of the input
varying <interpolant> sampled at an offset from the center of the pixel
specified by <offset>.  The two floating-point components of <offset>
give the offset in pixels in the x and y directions, respectively.  
An offset of (0,0) identifies the center of the pixel.  The range and
granularity of offsets supported by this function is
implementation-dependent.  

For all of the interpolation functions, <interpolant> 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 <interpolant>.  If <interpolant> is declared with a "flat" or
"centroid" qualifier, the qualifier will have no effect on the
interpolated value.  If <interpolant> is declared with the "noperspective"
qualifier, the interpolated value will be computed without perspective
correction.

But I still don't get why. The interpolant has no component selection and it is an input variable coming from a bound vertex attribute in the vs. Or does it interpret the .Texcoord of Vert.Texcoord has component selection operator?

I get also the same error in another sample, however, on interpolateAtOffset.

What is wrong? I mean, I want to interpolate the gl_SampleID at the given offset, I don't know how else shall that function be used..

elect
  • 6,765
  • 10
  • 53
  • 119
  • This looks like a compiler bug. The specification clearly says, "Component selection operators (e.g., .xy) may be used when specifying interpolant." Odds are good that the compiler is getting confused, since you're accessing a member of an interface block. – Nicol Bolas Feb 29 '16 at 14:51
  • I was suggested the same on the opengl irc channel, but I didn't have much lucky on the [nvidia forum](https://devtalk.nvidia.com/default/topic/914874/opengl/glsl-compiler-bug-on-interpolateatsample-/?offset=6#4813072) – elect Feb 29 '16 at 14:58

0 Answers0