Graphics Reference
In-Depth Information
configuration. The members of D3D11_INPUT_ELEMENT_DESC are shown in Listing 3.4. We
will examine what each of these structure members represents, and how they define the
needed information for the input assembler to do its job.
Struct D3D11_INPUT_ELEMENT_DESC {
LPCSTR SemanticName;
UINT Semanticlndex;
DXGI_FORMAT Format;
UINT InputSlot;
UINT AlignedByteOffset;
D3D11_INPUT_CLASSIFICATI0N InputSlotClass;
UINT
InstanceDataStepRate;
}
Listing 3.4. The D3D11_INPUT_ELEMENT_DESC structure members.
Per-vertex elements. The first parameter, SemanticName, identifies the textual name of a
vertex attribute, which must match the corresponding name provided in the vertex shader
program. Each input to a vertex shader must have a semantic defined in its HLSL source
code. That semantic name is used to match the vertex shader input to the vertex data pro-
vided by the input assembler. The Semanticlndex is an integer number which allows a
SemanticName to be used more than once. For example, if more than one set of texture
coordinates is used within a single vertex layout, each set of coordinates could use the same
SemanticName, but would use increasing Semanticlndex values to differentiate between
them.
The next structure member is the Format of the component. This specifies what data
type, and how many elements are contained in the attribute. The available formats range
from 1 to 4 elements, with both floating point and integer types available. The next param-
eter is the InputSlot, which indicates which of the 16 vertex buffer slots this component's
data should be read from. The AlignedByteOffset indicates the offset to the first element
in a vertex buffer for the items described by this D3D11_INPUT_ELEMENT_DESC. This tells
the input assembler where in a vertex buffer to begin reading input data from.
Per-instance elements. The final two structure members declare vertex functionality
regarding instancing. The instancing draw methods essentially use a single draw call to
submit a model to the pipeline. This model is then "instanced" multiple times, but with
a subset of the vertex data specified at a per-instance level, instead of a per-vertex level.
This is frequently used when many copies of the same object must be rendered at different
places throughout a scene. The vertex format will include a transformation matrix in its
definition, which is only incremented to the next value for each instance of the model. Then
the transformation matrices for all of the instances of the model are provided in a vertex
Search WWH ::




Custom Search