Input layouts
Now we have shaders and the different buffers that we need to render. There's just one more crucial component before we can draw anything. We give our vertices to the API, and in the shader we request input data based on semantics, but how does the API know which parts of each vertex to match to each semantic?
This is done through an input layout, which is just a description of the layout of your vertex element, along with annotations to indicate which part matches which semantic. Just like most items in Direct3D11, you need to fill out a description structure before you can create the input layout with the device. A typical layout may look like the following code snippet:
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, };
Each of the D3D11_INPUT_ELEMENT_DESC
structures consists...