Buffers store data that are used by shaders.
Create Buffer - ID3D11Device::CreateBuffer
A buffer is created by filling in a D3D_BUFFER_DESC and a D3D11_SUBRESOURCE_DATA structure and then calling ID3D11Device::CreateBuffer. The first buffer describe the settings for the buffer to create and the other one specifies the data to put in the buffer.
Identify how the buffer will be bound to the pipeline. The flags can be combined with a logical OR but using a single flag only when possible is best for performence.
Flags that set if and how the buffer can be accessed by the CPU. Can be combined with a logical OR. No flags set enables the best performance use of the resource.
Describe the frequency of how the buffer is expected to be read and written to.
Create vertex input layout - ID3D11Device::CreateInputLayout
To provide the GPU with vertex data one give it a vertex buffer. The vertex input layout tell the GPU what vertex attribute is where in the buffer so the GPU can extract them and give them to the shaders. To make a input layout fill in a array of D3D11_INPUT_ELEMENT_DESC and then call ID3D11Device::CreateInputLayout.
SemanticName: The name of this attribute in the shader.
SemanticIndex: Makes it possible to use the same name with different indices. Ex TexCoord0 and TexCoord1.
InputSlot: It is possible to read from more then one vertex buffer. Each vertex buffer is assigned to a slot (0-n) and this select what slot to read the attribute from.
AlignedByteOffset: How many bytes from the start of the vertex data this attribute starts. Use D3D12_APPEND_ALIGNED_ELEMENT to calculate this automatically from the previous element.
Select the input layout to use - ID3D11DeviceContext:IASetInputLayout
Use ID3D11DeviceContext:IASetInputLayout to select the input layout to use to pull data from the bound vertex buffers.
Using the Buffer
To set one or more vertex buffers to use call ID3D11DeviceContext:IASetVertexBuffers. To select the index buffer call ID3D11DeviceContext:IASetIndexBuffer.