Graphics Reference
In-Depth Information
as primitives as they are passed to the next stage in the pipeline. Depending on the type
of stream object declared for receiving this output, the streamed vertices will be used to
construct different primitives. In addition, up to four output streams can be declared to use
in conjunction with the stream output stage, making it quite simple to produce geometry
intended for rasterizing as well as geometry to save into a buffer resource. This streaming
model is the heart of the operation of the geometry shader, and we will see throughout this
section how it can be used in various situations.
3.8.1 Geometry Shader Pipeline Input
The geometry shader stage operates on complete primitives composed of an array of ver-
tices. Depending on which type of primitive is being passed, the array will vary in size,
from a single vertex all the way up to six vertices for a triangle with adjacency information.
The input to the geometry shader program declares the type of primitive that it will receive
in the input attribute definition. A sample geometry shader function signature is shown in
Listing 3.16.
[instance(4)]
[maxvertexcount(3)]
void GSScene( triangleadj GSSceneln input[6],
inout TriangleStream<PSSceneIn> OutputStream )
{
PSSceneln output = (PSSceneIn)0;
for ( uint i = 0; i < 6; i += 2 )
{
output.Pos = input[i].Pos;
output.Norm = input[i].Norm;
output.Tex = input[i].Tex;
OutputStream.Append( output );
}
OutputStream.RestartStrip();
}
Listing 3.16. A sample geometry shader program, demonstrating how to declare an input stream attribute.
In this listing, the input attribute represents a triangle with adjacency, which produces
four triangles out of six vertices. The order of the vertices within this input array depends on
which type of primitive is being passed to the function. The various primitive types, their
vertex counts, and the order that their vertices are provided in, are listed in Table 3.1. In
addition, each of these primitive types is shown in Figure 3.36 for easy reference.
Search WWH ::




Custom Search