Graphics Reference
In-Depth Information
Figure 3.37. The difference between processing vertex-level data in the vertex shader and the geometry shader.
specify. This includes the control patch primitive types, in addition to the standard point,
line, and triangle types, including their various forms with adjacency.
The other possible pipeline configuration is when the tessellation stages are active. In
this case, the input vertices are received from the domain shader and the primitive topology
is determined by the configuration of the tessellator stage. Since the tessellator stage can
only produce lines or triangles, these are the only available primitive types that the geom-
etry shader can receive when tessellation is active. This is why primitives with adjacency
are not supported when the tessellation stages are active.
Regardless of the pipeline configuration, the geometry is received as a list of vertices
representing the primitives present at this point in the pipeline. This has some performance
implications, since any of the rendering modes that reduce the amount of vertex process-
ing will not produce the same savings in the geometry shader. For example, if a triangle
strip with four vertices is processed in the vertex shader, four invocations of the vertex
shader will process the complete set of geometry. However, if each vertex is processed in
the geometry shader instead, all three vertices will be submitted to each geometry shader
invocation—which is the number of primitives being processed. In this case, there would
be two geometry shader invocations, and each would receive the three vertices of the tri-
angle being processed. Therefore, processing the vertices in the vertex shader requires only
four sets of calculations, while the same operations performed in the geometry shader will
require six. This difference is shown in Figure 3.37.
We can also see from Listing 3.16 how a stream output object is declared for a ge-
ometry shader. This object is actually the mechanism that the geometry shader uses to pass
its output out of the stage, as opposed to the function returning its output values directly.
Even so, the stream is passed as an input argument and hence will be discussed in this
input discussion. The syntax for declaring a stream output object begins with the inout
keyword, which specifies that the object is both an input and an output. This is followed
by one of three possible stream types. The stream output object can be used to output
a point list, a line strip, or a triangle strip; each of these is represented by the available
Search WWH ::




Custom Search