-1

I'm trying tessellation shader on mac but it returns a list of errors:

ERROR: 0:2: Invalid use of layout 'vertices'
ERROR: 0:12: Use of undeclared identifier 'gl_InvocationID'
ERROR: 0:12: Use of undeclared identifier 'gl_InvocationID'
ERROR: 0:13: Use of undeclared identifier 'gl_InvocationID'
ERROR: 0:14: Use of undeclared identifier 'gl_TessLevelInner'
ERROR: 0:15: Use of undeclared identifier 'gl_TessLevelOuter'
ERROR: 0:16: Use of undeclared identifier 'gl_TessLevelOuter'
ERROR: 0:17: Use of undeclared identifier 'gl_TessLevelOuter'

This seems there is something wrong with tessellation controller shader.

#version 410
layout(vertices = 3) out;
in vec3 vPosition[];
out vec3 tcPosition[];
uniform float TessLevelInner;
uniform float TessLevelOuter;

#define ID gl_InvocationID

void main()
{
    tcPosition[ID] = vPosition[ID];
    if (ID == 0) {
        gl_TessLevelInner[0] = TessLevelInner;
        gl_TessLevelOuter[0] = TessLevelOuter;
        gl_TessLevelOuter[1] = TessLevelOuter;
        gl_TessLevelOuter[2] = TessLevelOuter;
    }
}

My opengl projects works fine on my 2010 Windows pc... I'm wondering if this is a macosx issue? The GPU on my mac is Intel Iris. Anyone got a clue for this...

The main.cpp code is shared here

static GLuint LoadProgram( const char* vert, const char* tcs, const char* tes,const char* geom, const char* frag )
{
    GLuint prog = glCreateProgram();
    if( vert ) AttachShader( prog, GL_VERTEX_SHADER, vert );
    if( tcs ) AttachShader( prog, GL_VERTEX_SHADER, tcs );
    if( tes ) AttachShader( prog, GL_VERTEX_SHADER, tes );
    if( geom ) AttachShader( prog, GL_GEOMETRY_SHADER, geom );
    if( frag ) AttachShader( prog, GL_FRAGMENT_SHADER, frag );
    glLinkProgram( prog );
    CheckStatus( prog );
    return prog;
}
t.niese
  • 39,256
  • 9
  • 74
  • 101
Teng Long
  • 435
  • 6
  • 14

1 Answers1

1

In your LoadProgram you call AttachShader with GL_VERTEX_SHADER as type for the both tcs and tes.

But a VertexShader does not have those identifiers the shader compiler complains about.

You have to use the correct shader types (GL_TESS_CONTROL_SHADER and GL_TESS_EVALUATION_SHADER) for your tesselation shaders.

t.niese
  • 39,256
  • 9
  • 74
  • 101