bufferdrawdirect3dvertexslot

If several different Vertex Buffers are bound to different input slots of the D3D11 pipeline, which one is used by the Draw() call?


Two somewhat related questions, really.

FIRST: If I have different - and differently sized - Vertex Buffers A and B bound to the pipeline input slots 0 and 1, then which one of them will be used in the

ImmediateContext->Draw(VertexCount, StartVertexLocation)

function call?

SECOND: If no buffer is bound to slot 0, while the Vertex Buffer B is still bound to slot 1, then should the Draw(...) call use B ?

In my very possibly erroneous understanding, the Draw(N, ...) call should draw N vertices from each of the bound buffers, however many...


Solution

  • Multistream rendering does not allow you to have different vertex counts in each VB. If you are using Index Buffers, the same index is used for all bound vertex buffers.

    Essentially the multistream rendering is just a way to pick up different parts of a single vertex from multiple buffers at rendering time, not another indexing method. All the logic for which slot to pull from is controlled by the Input Layout's D3D11_INPUT_ELEMENT_DESC.InputSlot. For example, you can have position in slot 0, texture coordinates in slot 1, normals in slot 2, or some other combination.

    You may find this DirectX Tool Kit tutorial helpful