Interpolation qualifiers in interface blocks

Hello,

I’m playing with geometry shaders, so I have to use interface blocks for vertex attributes. I haven’t find much documentation about this (perhaps I missed the line in the specs) so I’m a bit lost here.

supposing this interface block in the vertex shader:

out VertexData
{ 
    vec2 TextCoordInterp;
    vec3 NormalInterp;
}  vertexOut;

and its corresponding in the geometry shader:

 in VertexData
{ 
    vec2 TextCoordInterp;
    vec3 NormalInterp;
} vertexIn[];

All my tries of specifying the interpolation qualifier ends with a compiler error (I’m on NVidia)

Placing the “smooth” keyword before interface blocks’ members (for instance smooth vec2 TextCoordInterp;) ends with the next error: error C7561: OpenGL requires ‘in/out’ with ‘?’

I know that smooth is the default qualifier for interpolation, but I would like to know how to correctly specify it.

Thanks.

Edit: Forget this. I was missing the point that interpolation now must be defined between GS and FS
Edit 2: Anyway, I can set the interpolation qualifier between GS and FS if I don’t use an interface block, but how would do I specify it if want use interface blocks?
I’m having the same compiler error.

First, you can specify interpolation qualifiers on variables between any of the shader stages, not just the one directly feeding the fragment shader. It’s just that they don’t have an effect on anything unless it’s the one feeding the fragment shader.

Second, any such declarations must match between any stages you set them on. Even if they don’t have an effect, per the above.

Third, interpolation qualifiers go onto the variables inside an interface block.

Fourth, if NVIDIA’s compiler complains about putting a qualifier inside an interface block, then it’s broken and should be repaired.

Ok, found the problem.
Although the specification says that:

in Material {
smooth in vec4 Color1; // legal, input inside in block
smooth vec4 Color2; // legal, 'in' inherited from 'in Material'
vec2 TexCoord; // legal, TexCoord is an input
uniform float Atten; // illegal, mismatched storage qualifier
};

If I try this:

out VertexData
{ 
    smooth vec2 TextCoordInterp;
    smooth vec3 NormalInterp;
}vertexOut;

I have compilation errors

I have to add an extra out qualifier in order to make this work as expected:

out VertexData
{ 
    smooth out vec2 TextCoordInterp;
    smooth out vec3 NormalInterp;
}vertexOut;

Ok, found the problem.

No you didn’t. The code you posted that “works” is not required! Your compiler has a bug in it.

Do you think that the specification is lying to you?

I’ve found the problem as far I understood the specification, but of course I could be wrong.

Now, I’m using these interface block in the 3 stages


// interface block in the vertex shader
out VertexData
{ 
    smooth out vec2 TextCoordInterp;
    smooth out vec3 NormalInterp;
}vertexOut;

// Interface bocks in the GS
in VertexData
{ 
    smooth in vec2 TextCoordInterp;
    smooth in vec3 NormalInterp;
}vertexIn[];

out Interpolators
{
    smooth out vec2 TextCoordInterp;
    smooth out vec3 NormalInterp;
}interpData;

// Interface block in the FS
in Interpolators
{
    smooth in vec2 TextCoordInterp;
    smooth in vec3 NormalInterp;
}interpData;

That works as I expected, please correct me if I did this wrong (I know this solution differs from my first post)

But, if I remove the in/out qualifiers from the interface block’s members in the next way, the compiler complains, and according with the specs, they are valid (from the spec sample: (smooth vec4 Color2; // legal, ‘in’ inherited from ‘in Material’).


// interface block in the vertex shader
out VertexData
{ 
    smooth vec2 TextCoordInterp;
    smooth vec3 NormalInterp;
}vertexOut;

// Interface bocks in the GS
in VertexData
{ 
    smooth vec2 TextCoordInterp;
    smooth vec3 NormalInterp;
}vertexIn[];

out Interpolators
{
    smooth vec2 TextCoordInterp;
    smooth vec3 NormalInterp;
}interpData;

// Interface block in the FS
in Interpolators
{
    smooth vec2 TextCoordInterp;
    smooth vec3 NormalInterp;
}interpData;

Can we safely conclude a bug in NV’s driver then?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.