If you have multiple Vertex Buffers bound to multiple slots when you call Draw*, then they are used in parallel based on the current Input Layout.
If you are using DrawIndexed*, then the one bound Index Buffer is used to generate an index used for all Vertex Buffers bound with D3D11_INPUT_PER_VERTEX_DATA. I.e., they are treated like parallel arrays:
// This is psuedo-code!
Vertex0 vb0[nVerts];
Vertex1 vb1[nVerts];
Vertex2 vb2[nVerts];
uint32_t ib[nTris * 3];
Bind vb0 to slot 0, vb1 to slot 1, vb2 to slot 2 of Vertex Buffers
Bind ib to Index Buffer
// For DirectX 12, the input layout is part of the Pipeline State Object (PSO)
Bind an input layout that uses vertex data from from 3 slots
DrawIndexed
foreach j in 0 to (IndexCount-1);
index = ib[StartIndexLocation + j] + BaseVertexLocation
assemble vertex from vb0[index], vb1[index], vb2[index]
draw when you have enough vertices for the primitive
One of the challenges of using DirectX documentation is that typically each version starts from the assumption that you already know the previous version. Multi-stream rendering was introduced way back in DirectX 9, so that's the last time it was conceptually explained: Programming One or More Streams (Direct3D 9)
In DirectX 11, there are four Draw* methods:
void Draw(
UINT VertexCount,
UINT StartVertexLocation);
void DrawInstanced(
UINT VertexCountPerInstance,
UINT InstanceCount,
UINT StartVertexLocation,
UINT StartInstanceLocation);
// Uses an Index Buffer
void DrawIndexed(
UINT IndexCount,
UINT StartIndexLocation,
INT BaseVertexLocation);
void DrawIndexedInstanced(
UINT IndexCountPerInstance,
UINT InstanceCount,
UINT StartIndexLocation,
INT BaseVertexLocation,
UINT StartInstanceLocation);
DirectX 12 supports all the same functions, but does it all in two methods. If InstanceCount is 1, then it's not instanced:
void DrawInstanced(
UINT VertexCountPerInstance,
UINT InstanceCount,
UINT StartVertexLocation,
UINT StartInstanceLocation
);
// Uses an Index Buffer
void DrawIndexedInstanced(
UINT IndexCountPerInstance,
UINT InstanceCount,
UINT StartIndexLocation,
INT BaseVertexLocation,
UINT StartInstanceLocation
);
For information on using instancing, see the C++ sample SimpleInstancing: DX11 / DX12.