<p>For a diagram to be comprehensive, it'd have to show way too much detail. It's just a simple tool.</p>
<p><a href="https://www.khronos.org/opengl/wiki/Primitive_Assembly" rel="nofollow noreferrer">Primitive assembly</a> is the process of taking a sequence of vertices for a particular <a href="https://www.khronos.org/opengl/wiki/Primitive" rel="nofollow noreferrer">rendering primitive</a> type, and generating a sequence of base primitives (points, lines, triangles) from them.</p>
<p>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.</p>
<p><em>However</em>, the input to a <a href="https://www.khronos.org/opengl/wiki/Geometry_Shader" rel="nofollow noreferrer">geometry shader</a> invocation is a single base primitive, taken from the sequence of vertices provided up to that point. As such, a form of primitive assembly <em>also</em> must happen before the GS, to convert the vertex sequence into a sequence of base primitives.</p>
<p>This is also one reason why GS's are <em>slow</em>. If there is no GS, then this primitive assembly doesn't happen.</p>
<p>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.</p>

CC BY-SA 4.0
2020-10-26T17:24:34.783Z
Can you tell me where I can take such diagram? I've been going back and forth between Specification (https://www.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.
user8469759
CC BY-SA 4.0
2020-10-26T17:55:12.507Z
@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.
Nicol Bolas
CC BY-SA 4.0
2020-10-26T17:03:23.780Z
2020-10-26T17:03:23.780Z
Nicol Bolas
<p>The question is simple, I have this diagram from the Khronos page:</p>
<p><a href="https://i.sstatic.net/Ru6dz.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Ru6dz.png" alt="enter image description here" /></a></p>
<p>And this diagram from the <a href="https://learnopengl.com/book/book_pdf.pdf" rel="nofollow noreferrer">Learn OpenGL page</a></p>
<p><a href="https://i.sstatic.net/3mDKB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3mDKB.png" alt="enter image description here" /></a></p>
<p>In the first picture the <strong>Primitive assembly</strong> is executed for example <strong>after</strong> the Geometry shader, in the second the execution happens <strong>before</strong>.</p>
<p>For the latter picture I took the relevant bit from the tutorial:</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>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.</p>
<p>When is the Primitive assembly executed then?</p>

CC BY-SA 4.0
2020-10-26T16:30:47.867Z
"*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".
Nicol Bolas
CC BY-SA 4.0
2020-10-26T16:43:28.177Z
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).
user8469759
<opengl>
OpenGL pipeline stages, when is the primitive assembly executed?
user8469759
# OpenGL pipeline stages, when is the primitive assembly executed?

(Asked by: username_0 on 2020-10-26)

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

[![enter image description here](https://i.sstatic.net/Ru6dz.png)](https://i.sstatic.net/Ru6dz.png)

And this diagram from the [Learn OpenGL page](https://learnopengl.com/book/book_pdf.pdf)

[![enter image description here](https://i.sstatic.net/3mDKB.png)](https://i.sstatic.net/3mDKB.png)

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?

**Tags:** opengl

> **Comments:**
> **username_1**: "*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".  
> **username_0**: 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).  

---

## 1 answers

### Answer by username_1 on 2020-10-26. Score: 1

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

[Primitive assembly](https://www.khronos.org/opengl/wiki/Primitive_Assembly) is the process of taking a sequence of vertices for a particular [rendering primitive](https://www.khronos.org/opengl/wiki/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](https://www.khronos.org/opengl/wiki/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.

> **Comments:**
> **username_0**: Can you tell me where I can take such diagram? I've been going back and forth between Specification (https://www.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.  
> **username_1**: @username_0: "*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.  

---

