How is gl_TessCoord computed?

If my tessellation mode is triangles, does the output patch size (sent from the control shader) need to be a multiple of three?

If my tessellation mode is quads, does the output patch size need to be a square number?

I can’t find constraints like this in the spec. Without these constraints, it’s not clear how gl_TessCoord is computed. The spec says it’s a “relative position”, but this implies a topology.

Yes, the GL specification is confusing here.

It says:
“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 …”

which is confusing, because which triangle or quad primitive is it talking about? What if the input patch only has two vertices, or has five, or 32 vertices?

The answer is “it’s an abstract primitive” and has nothing to do with your patch topology.

The D3D11 overview is much better worded:
“The tessellator tiles a canonical domain in a normalized (zero-to-one) coordinate system. For example, a quad domain is tessellated to a unit square.”

This implies that the progression of TessCoord within a patch is implementation-dependent, but that we can expect a roughly uniform sampling of domain space.

It seems natural that TessCoord would follow a “raster scan” progression of the rectangular domain, but apparently we shouldn’t assume so.

Ordering aside, I wonder what a uniform sampling of a rectangular domain looks like when the number of samples is a crazy number like 3 or 7.


The “looks like” part is well defined by the specification; you can easily write a short app to visualize all possible TESS_GEN_SPACING modes at all levels (down to whatever fractional precision you want.)

The “progression” part is undefined. The tessellator can generate the new primitives in any order it wants.

When I said “looks like”, I was referring to TessCoord values, not the topology of the resultant triangles. The spec does not give any rules governing TessCoord, other than defining the interval of legal values.

With quads tessellation, it seems reasonable to assume that TessCoord results from a linear interpolation of 4 “corners” of the patch. But, which verts are corners if the patch size is a non-square number?