[DX11] Does order matter in D3D11_INPUT_ELEMENT_DESC?

Started by
3 comments, last by AlexandreMutel 12 years, 5 months ago
Do the order of the elements in the D3D11_INPUT_ELEMENT_DESC array matter?

In other words, are these two functionally identical?

D3D11_INPUT_ELEMENT_DESC VtxLayoutA[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};


D3D11_INPUT_ELEMENT_DESC VtxLayoutB[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};
Advertisement
It should be identical. Are you experiencing a different behavior when binding the vertex buffer?
Thanks for the quick reply. No, not experiencing any problem. The DX docs don't make it clear and I just wanted to get some clarity.
If you want to use D3D11_APPEND_ALIGNED_ELEMENT for the AlignedByteOffset then it will need to be in order I believe.

If you want to use D3D11_APPEND_ALIGNED_ELEMENT for the AlignedByteOffset then it will need to be in order I believe.

Note that in the previous case:
- On slot 0, POSITION offset(0) and TEXCOORD offset(16)
- On slot 1, NORMAL offset(0)

so D3D11_APPEND_ALIGNED_ELEMENT would also work as input elements are on different slot. Basically, as long as you keep order within a slot, that's fine, but you can make interleaved declaration of input elements on different slots.

This topic is closed to new replies.

Advertisement