Graphics Reference
In-Depth Information
3.9.1 Stream Output Pipeline Input
The stream output stage can only receive information from the geometry shader stage in
the form of the output streams declared in the geometry shader program. Up to four streams
are available to the geometry shader to pass data to the stream output stage, and each
stream can receive a different vertex structure as its input. This allows multiple variations
of the same geometry to be streamed simultaneously. For example, the positions, normal
vector, tangent and bitangent vectors, or other optional per-vertex data, can be split into
multiple streams and then selectively bound to the input assembler stage later on, providing
a very flexible method of binding only the vertex data that is required for a particular effect.
The restrictions on these vertex structures are that a maximum of 128 scalars is al-
lowed for each structure, and that a geometry shader invocation may not produce more
than 1024 scalars. Thus, if four output streams are used, and each uses a structure of 128
scalar vertices, a total of 512 scalars for all four streams can be written twice. In practice,
this should be a sufficient amount of data to stream, since it is performed for each primitive
that the geometry shader receives.
It is also possible to produce completely disjoint streams of data as well. For instance,
if an algorithm requires that all front faces must be rendered separately from the back faces,
then the front and back faces for a set of geometry can be passed to two different streams.
This provides a simple mechanism for generating these mixed sets of geometry from a
standard geometry format.
3.9.2 Stream Output State Configuration
The stream output stage requires two different types of configurations. The first is that the
application must bind the appropriate number of buffer resources to this stage, through the
ID3DllDeviceContext::SOSetTargets(...) method. This method operates in a simi-
lar way to other resource binding functions, and it allows up to four buffers to be bound
simultaneously from within the same method invocation. Listing 3.18 demonstrates how
this method is used. There is also a corresponding Get method that can be used to retrieve
references to the buffer resources that are currently bound to the stage.
ID3DllBuffer* pBuffers[l] = { pBuffer1 };
UINT aOffsets[1] = { 0 };
pContext->SOSetTargets( 1, pBuffers, offset );
Listing 3.18. Binding buffer resources to the stream output stage.
Search WWH ::




Custom Search