1

The OpenGL-Wiki states on the output limitations of geometry shaders:

The first limit, defined by GL_MAX_GEOMETRY_OUTPUT_VERTICES​, is the maximum number that can be provided to the max_vertices​ output layout qualifier.

[...]

The other limit, defined by GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS​ is [...] the total number of output values (a component, in GLSL terms, is a component of a vector. So a float​ is one component; a vec3​ is 3 components).

That's what the declarative part of my geometry shader looks like:

layout( triangles ) in;
layout( triangle_strip, max_vertices = 300 ) out;
out vec4 var1;

My vertex format only consists of 4 floats for position. So I believe to have the 4 components from the varying var1 plus the 4 components from the position, i.e. 8 in total.

I have queried the following values for the constants mentioned above:

GL_MAX_GEOMETRY_OUTPUT_VERTICES = 36320
GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = 36321

With max_vertices set to 300, a total of 8*300 = 2400 components would be written. It is needless to say that this value is far below 36321 as well as the 300 of max_vertices is far below 36320. So everything should be okay, right?

However, when I build the shader, the linking fails:

error C6033: Hardware limitation reached, can only emit 128 vertices of this size

Can somebody explain to me what is going on and why this doesn't work as I expected?

Community
  • 1
  • 1
theV0ID
  • 4,172
  • 9
  • 35
  • 56

1 Answers1

3

I made a really dumb mistake. For the record, if somebody else is having the same issue: Querying the values for GL_MAX_GEOMETRY_OUTPUT_VERTICES and GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS must be done through glGetInteger and not by just evaluating those macros.

theV0ID
  • 4,172
  • 9
  • 35
  • 56
  • That's a common mistake I guess, but it makes sense as none of the predefined constants can contain information which is specific to the executing hardware. – Gigo Mar 21 '15 at 17:50
  • Languages like C++ have actual `enum` types to eliminate this problem. But C is pretty lackadaisical, **0x8DE0** (`GL_MAX_GEOMETRY_OUTPUT_VERTICES`) is just an integer as far as its concerned. For future reference, if you see numbers hovering around **36xxx** for some constants, particularly if they are sequential, that's a good sign that you're using the enum value instead of querying the implementation limit ;) Most implementation limits having to do with vectors are powers-of-two, so right off the bat **36320** should look suspicious. – Andon M. Coleman Mar 21 '15 at 18:12
  • @Gigo: I wasn't aware that the macros expand to constants, they could as well expand to functions that do the query. This is what I thought. – theV0ID Mar 21 '15 at 21:31