Each geometry shader invocation has access to all vertices in the primitive
(and their associated data), which are presented to the shader as an array
of inputs. The input primitive type expected by the geometry shader is
specified with an OpExecutionMode
instruction in the geometry shader,
and must be compatible with the primitive topology used by primitive
assembly (if tessellation is not in use) or must match the type of
primitive generated by the tessellation primitive generator (if tessellation
is in use). Compatibility is defined below, with each input primitive type.
The input primitive types accepted by a geometry shader are:
OpExecutionMode
instruction specifying the InputPoints
input mode. Such a shader is
valid only when the pipeline primitive topology is
VK_PRIMITIVE_TOPOLOGY_POINT_LIST
(if tessellation is not in use) or if
tessellation is in use and the tessellation evaluation shader uses
PointMode
. There is only a single input vertex available for each
geometry shader invocation. However, inputs to the geometry shader are still
presented as an array, but this array has a length of one.
OpExecutionMode
instruction with the InputLines
mode. Such a
shader is valid only for the VK_PRIMITIVE_TOPOLOGY_LINE_LIST
, and
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
primitive topologies (if tessellation
is not in use) or if tessellation is in use and the tessellation mode is
Isolines
. There are two input vertices available for each geometry
shader invocation. The first vertex refers to the vertex at the beginning of
the line segment and the second vertex refers to the vertex at the end of
the line segment.
Geometry shaders that operate on line segments with adjacent vertices are
generated by including an OpExecutionMode
instruction with the
InputLinesAdjacency
mode. Such a shader is valid only for the
VK_PRIMITIVE_TOPOLOGY_LINES_WITH_ADJACENCY
and
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY
primitive topologies
and must not be used when tessellation is in use.
In this mode, there are four vertices available for each geometry shader invocation. The second vertex refers to attributes of the vertex at the beginning of the line segment and the third vertex refers to the vertex at the end of the line segment. The first and fourth vertices refer to the vertices adjacent to the beginning and end of the line segment, respectively.
Geometry shaders that operate on triangles are created by including an
OpExecutionMode
instruction with the Triangles
mode. Such a
shader is valid when the pipeline topology is
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
,
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
, or
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN
(if tessellation is not in use) or
when tessellation is in use and the tessellation mode is Triangles
or
Quads
.
In this mode, there are three vertices available for each geometry shader invocation. The first, second, and third vertices refer to attributes of the first, second, and third vertex of the triangle, respectively.
Geometry shaders that operate on triangles with adjacent vertices are
created by including an OpExecutionMode
instruction with the
InputTrianglesAdjacency
mode. Such a shader is valid when the pipeline
topology is VK_PRIMITIVE_TOPOLOGY_TRIANGLES_WITH_ADJACENCY
or
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY
, and must not be
used when tessellation is in use.
In this mode, there are six vertices available for each geometry shader invocation. The first, third and fifth vertices refer to attributes of the first, second and third vertex of the triangle, respectively. The second, fourth and sixth vertices refer to attributes of the vertices adjacent to the edges from the first to the second vertex, from the second to the third vertex, and from the third to the first vertex, respectively.