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

Of course, that’s the point. Tessellation can work only on GL_PATCHES.

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

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:

Furthermore the spec states

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.

“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.