Graphics Reference
In-Depth Information
If the triangle/line strip needs to be restarted to create detached groups of geometry,
the geometry shader can call the RestartStrip() method of the output stream. This will
reset the primitive generation to allow another strip to be started, which is not connected
to the previously streamed geometry. While it is more efficient to produce geometry in a
single strip, if the required output geometry must reside in multiple disconnected sections,
then the strip must be restarted. This process of producing primitives by appending vertices
to the output stream continues until the geometry shader has completed, which marks the
end of this particular invocation of the shader program.
Multiple Stream Objects
One of the new features in Direct3D 11 is the ability of the geometry shader program to use
up to four different stream output objects. When properly configured, these objects can be
used not only to pass pass primitive data to the rasterizer stage, but to send their data to the
stream output stage, where it can be stored in buffer resources. Since the buffer resource is
accessible to the application, 2 0
this means that the stream of pipeline data is directly avail-
able for reading or storing in a file. This is a powerful facility, which can be used for some
interesting data analysis scenarios. To declare multiple streams in the geometry shader
program, you simply include additional stream objects as input parameters to the function.
Listing 3.17 demonstrates this technique. These streams are used in the same way that the
individual output stream is, with the AppendQ and RestartStripQ methods. Each out-
put stream can be written to independently from one another—they don't have to have the
same output frequency.
void MyGS( InVertex verts[2],
inout PointStream<OutVertexl> myStream1,
inout PointStream<0utVertex2> myStream2 )
{
OutVertexl myVert1 = TransformVertexl( verts[0] );
0utVertex2 myVert2 = TransformVertex2( verts[l] );
myStreaml.Append( myVertl );
myStream2.Append( myVert2 );
}
Listing 3.17. A geometry shader that declares more than one output stream, with different vertex structure
types.
Normally, when the geometry shader uses only a single output stream, the results of
that stream are passed on to the rasterizer stage, where they are processed and split into
2 0
Techniques for manipulating resources, including how to read their contents from C/C++, is provided in
Chapter 2: Direct3D 11 Resources.
/
Search WWH ::




Custom Search