0
$\begingroup$

The question is simple, I have this diagram from the Khronos page:

enter image description here

And this diagram from the Learn OpenGL page

enter image description here

In the first picture the Primitive assembly is executed for example after the Geometry shader, in the second the execution happens before.

For the latter picture I took the relevant bit from the tutorial:

The primitive assembly stage takes as input all the vertices (or vertex if GL_POINTS is chosen) from the vertex shader that form a primitive and assembles all the point(s) in the primitive shape given; in this case a triangle. The output of the primitive assembly stage is passed to the geometry shader. The geometry shader takes as input a collection of vertices that form a primitive and has the ability to generate other shapes by emitting new vertices to form new (or other) primitive(s). In this example case, it generates a second triangle out of the given shape.

I'm a bit confused cause I can't figure what that module and the Geometry shader takes as input, I'd be more prone to say the first diagram is correct. But maybe there's an interpretation I'm missing here.

When is the Primitive assembly executed then?

$\endgroup$
2
  • $\begingroup$ "In the first picture the Primitive assembly is executed for example after the Geometry shader" It talks about something they call "shape assembly", not "primitive assembly". $\endgroup$ Oct 26 '20 at 16:30
  • $\begingroup$ Even if it is a "shape assembly" the order is swapped, I don't really understand. Also In the tutorial it seems to me that both "shape assembly" and "primitive assembly" are used as synonyms (see my update). $\endgroup$ Oct 26 '20 at 16:43
1
$\begingroup$

For a diagram to be comprehensive, it'd have to show way too much detail. It's just a simple tool.

Primitive assembly is the process of taking a sequence of vertices for a particular rendering primitive type, and generating a sequence of base primitives (points, lines, triangles) from them.

This process does indeed happen after vertex post-processing, as the input to the rasterizer is a sequence of base primitives. After all, you don't rasterize a triangle strip; you rasterize a triangle.

However, the input to a geometry shader invocation is a single base primitive, taken from the sequence of vertices provided up to that point. As such, a form of primitive assembly also must happen before the GS, to convert the vertex sequence into a sequence of base primitives.

This is also one reason why GS's are slow. If there is no GS, then this primitive assembly doesn't happen.

The output of the geometry shader is a bunch of vertex sequences, which still later undergo primitive assembly based on the output primitive type of the GS. A GS can output triangle strips, so there has to be primitive assembly to turn those strips into individual triangles.

$\endgroup$
2
  • $\begingroup$ Can you tell me where I can take such diagram? I've been going back and forth between Specification (khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf) and the Khronos web page and I can't find a correspondence. I'm starting to assume that tutorial "Learn OpenGL" is good to get some feeling of OpenGL but to be honest the theory explained doesn't satisfy me at all. $\endgroup$ Oct 26 '20 at 17:24
  • $\begingroup$ @user8469759: "I can't find a correspondence" I don't know what you mean by that. The wiki is just a more readable description of the specification. The spec for example says ""If there is an active program for the geometry stage, the executable version of the program’s geometry shader is used to process primitives resulting from the primitive assembly stage.*" That means primitive assembly needs to happen before the GS. $\endgroup$ Oct 26 '20 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.