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: About tessellation shaders

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    5

    About tessellation shaders

    Hi everybody,

    I'm trying to use tessellation shaders and i'm wondering if we can only use them with GL_PATCHES.

    I have a simple code using vertex and fragment shaders with GL_TRIANGLE and I wanted to add tessellation shader but it's not woking when I call
    glDrawArrays ( GL_TRIANGLES, offset, numTris );

    Thanks

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,161
    Of course, that's the point. Tessellation can work only on GL_PATCHES.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    5
    Thank you so much,
    So if I use a geometry shader beginning like this:

    layout(triangles) in;
    layout(triangle_strip, max_vertices = 3) out;

    After fragment shader I have only one choice to draw the final result: glDrawElements or glDrawArray with GL_PATCHES? A glDrawArrays with a GL_TRIANGLES doesn't work event if last shader works on triangle?

    Thanks

    ps: I'm a beginner in shaders

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    After fragment shader I have only one choice to draw the final result: glDrawElements or glDrawArray with GL_PATCHES? A glDrawArrays with a GL_TRIANGLES doesn't work event if last shader works on triangle?
    Slow down. The primitive type on the application level has to match the shaders that are active in the current program or pipeline. If tessellation is active, you have to use GL_PATCHES with any draw command, otherwise you don't:

    Quote Originally Posted by Le Spec
    An INVALID_OPERATION error is generated by any command that transfers vertices to the GL if tessellation is active and the primitive mode is not PATCHES. Patch primitives are not supported by pipeline stages below the tessellation evaluation shader.
    Furthermore the spec states

    Quote Originally Posted by Le Spec
    If a tessellation evaluation shader is active, the tessellation primitive generator subdivides a triangle or quad primitive into a collection of points, lines, or triangles according to the tessellation levels of the patch and the set of layout declarations specified in the tessellation evaluation shader text.
    So, what you get after tessellation is a set of points, lines or triangles. The geometry shader input layout has to match the tess eval shader outputs. For points it's simple: you only get points out of a tess eval shader if you specify point_mode layout and the geometry shader input type should be points. If the input to you tess eval shader is isolines it should be clear as well: The geometry shader input would be lines. For tess eval inputs triangles and quads the input would be triangles.

    The geometry shader can then do whatever it wants just as if there wasn't any tessellation going on and the fragment shader will also do whatever it wants as if you just rendered single points, triangles or lines. Output variables can be passed through the tessellation stages as with any other pipeline stage, the only thing to remember is that control shaders usually take arrays of input and write arrays of outputs and the evaluation stage always processes exactly one vertex that has been generated by the primitive generator.

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2012
    Posts
    5
    "An INVALID_OPERATION error is generated" that is actually what I have with my draw call with GL_TRIANGLES while I use tess shaders.
    Thank you, it's more clear.

Posting Permissions

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