A Geometry Shader (GS
) is a Shader program written in GLSL that governs the processing of Primitives.
Geometry shaders reside between the Vertex Shaders (or the optional Tessellation stage) and the fixed-function Vertex Post-Processing stage.
A geometry shader is optional and does not have to be used.
Geometry shader invocations take a single Primitive as input and may output zero or more primitives.
There are implementation-defined limits on how many primitives can be generated from a single GS invocation.
GS’s are written to accept a specific input primitive type and to output a specific primitive type.
While the GS can be used to amplify geometry, thus implementing a crude form of tessellation, this is generally not a good use of a GS. The main reasons to use a GS are:
- Layered rendering: taking one primitive and rendering it to multiple images without having to change bound rendertargets and so forth.
- Transform Feedback: This is often employed for doing computational tasks on the GPU (obviously pre-Compute Shader).