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: Confusion about maximum output from Geometry Shaders

  1. #1
    Newbie Newbie
    Join Date
    Mar 2015
    Posts
    2

    Confusion about maximum output from Geometry Shaders

    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:

    Code :
    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:

    Code :
    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?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,574
    Quote Originally Posted by theV0ID View Post
    I have queried the following values for the constants mentioned above:
    Code :
    GL_MAX_GEOMETRY_OUTPUT_VERTICES = 36320
    GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS = 36321
    Those are the just values of the enumerants. You have to use e.g.
    Code :
    GLint max_vertices, max_components;
    glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &max_vertices);
    glGetIntegerv(GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, &max_components);
    to obtain the actual limits.
    Last edited by GClements; 03-21-2015 at 03:41 PM.

  3. #3
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,939
    I have queried the following values for the constants mentioned above:
    No, you have instead made a common mistake. You're looking at the value of the enumeration. What you want is to query the value for that enumeration from the OpenGL implementation. See, it's an implementation-defined limitation; each graphics card can define a different number. OpenGL implementations have to support at least a certain number, but different cards could have higher limts.

    You need to use glGetInteger for that.

    Though it's highly unlikely implementations will let you shove 300+ vertices as output from a GS. What exactly are you trying to accomplish that you need to send that many vertices from a single GS invocation?

  4. #4
    Newbie Newbie
    Join Date
    Mar 2015
    Posts
    2
    Thanks! I need to duplicate a triangle a few hundred times. Previously I was rendering the triangle from CPU with a rendering call each time, but that was getting slow, so I though using a geometry shader might help. I think the solution to go here with is to still make a few rendering calls, s.t. each rendering call still duplicates the triangle like 128/3 times or so?

  5. #5
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,939
    Or you could use instancing.

    A good rule of thumb with GS's is this: if performance is a problem, GS's almost never help.

Posting Permissions

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