Graphics Reference
In-Depth Information
Each buffer resource that will be bound for output from the stream output stage must
be created with the D3D11_BIND_STREAM_OUTPUT bind flag, in addition to any other bind
flags that indicate how the buffer will be used for vertex buffer usage. The buffer resource
references that are stored in this stage persist between pipeline executions, meaning that
they must be managed by the developer. This is the same principle that other resource-
binding functionalities use, and the same management techniques can be employed. As we
have seen before, it can be beneficial to either always bind all four buffer entries, with the
unused slots receiving a NULL pointer, or to have the current state of the slots managed by
the application, modifying only the appropriate slots as needed.
The second configuration required for the stream output stage to operate is the speci-
fication of what data will be streamed to which output slot. This information is provided
to the ID3DllDevice: :CreateGeometryShaderWithStreamOutput(...) method in the
form of an array of D3D11_S0_DECLARATION_ENTRY structures. The elements of this struc-
ture are specified in Listing 3.19.
struct D3D11_S0_DECLARATI0N_ENTRY {
UINT Stream;
LPCSTR SemanticName;
UINT Semanticlndex;
BYTE StartComponent;
BYTE ComponentCount;
BYTE OutputSlot;
};
Listing 3.19. The members of the D3D11_S0_DECLARATI0N_ENTRY structure.
In this structure, we can see the information required for each piece of every vertex
output by the geometry shader that will end up in one of the stream output buffers. One of
these structures must be provided for each output attribute that will be streamed out. The
first argument, Stream, identifies which stream output object the data will be coming from
in the geometry shader. The SemanticName attribute provides the semantic that is defined
in the geometry shader for the attribute to be streamed, and the Semanticlndex attribute
provides an index for multiple attributes that share the same semantic name to be uniquely
identified. This is the same type of semantic index that we have seen for vertex buffer ele-
ment declarations.
The StartComponent and ComponentCount arguments determine which portion of a
four-component attribute will be streamed. StartComponent can have a value of {0,1,2,3},
which corresponds to the register components {x,y,z,w} respectively. The ComponentCount
simply indicates how many of these components to stream. For example, if StartComponent
Search WWH ::




Custom Search