Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Interpolation qualifiers in interface blocks

  1. #1
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    273

    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:
    Code :
    out VertexData
    { 
        vec2 TextCoordInterp;
        vec3 NormalInterp;
    }  vertexOut;

    and its corresponding in the geometry shader:
    Code :
     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.
    Last edited by Ffelagund; 08-26-2013 at 05:29 AM.
    "!I don't know... fly casual"

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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.

  3. #3
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    273
    Ok, found the problem.
    Although the specification says that:
    Code :
    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:
    Code :
    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:
    Code :
    out VertexData
    { 
        smooth out vec2 TextCoordInterp;
        smooth out vec3 NormalInterp;
    }vertexOut;
    "!I don't know... fly casual"

  4. #4
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    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?

  5. #5
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    273
    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
    Code :
    // 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').

    Code :
    // 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?
    Last edited by Ffelagund; 08-26-2013 at 06:15 AM.
    "!I don't know... fly casual"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •