The input layout
D3D11_INPUT_ELEMENT_DESC layout[] = {
{"Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"Normal", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"Transform", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1},
{"Transform", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1},
{"Transform", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1},
{"Transform", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1},
{"Color", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 64, D3D11_INPUT_PER_INSTANCE_DATA, 1},
};
The vertex shader
cbuffer CBuf
{
matrix model;
matrix modelViewProj;
};
struct VSIn
{
float3 pos : Position;
float3 n : Normal;
row_major float4x4 transform : Transform;
float4 color : Color;
};
struct VSOut
{
float3 worldPos : Position;
float3 normal : Normal;
float4 pos : SV_Position;
float4 color : Color;
};
VSOut main(VSIn input)
{
VSOut vso;
vso.worldPos = (float3) mul(float4(input.pos, 1.0f), input.transform);
vso.normal = mul(input.n, (float3x3) input.transform);
vso.pos = mul(float4(input.pos, 1.0f), modelViewProj);
vso.color = input.color;
return vso;
}
The error
ID3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'Transform'/0, but the declaration doesn't provide a matching name.
D3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'Transform'/1, but the declaration doesn't provide a matching name.
D3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'Transform'/2, but the declaration doesn't provide a matching name.
D3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'Transform'/3, but the declaration doesn't provide a matching name.
D3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'Color'/0, but the declaration doesn't provide a matching name.
[Error Code] 0x80070057 (2147942487)
[Error String] E_INVALIDARG
[Description] The parameter is incorrect.
The error is thrown on CreateInputLayout before I draw anything to screen. I previously had this whole setup working with normal non instanced drawing. I understand that the error means the input layout doesn't match the shader declaration but I can't see which part does not match. VSIn contains a semantic name for Position, Normal, Transform and Color.
Research:
- Other Questions
- Examples
So for what I have tried after reading the above:
- Use D3D11_APPEND_ALIGNED_ELEMENT instead of manually calculating the offsets
- Split up the Transform matrix into four float4s with numbered semantic names
- Binding just the color and removing the transform from both the input description and the shader (same error but only concerning color).
- Ensure the shader that is loaded is the correct shader
- Delete the generated .cso file to make sure the shader recompiles
- Change the semantic names to different strings in case of reserved identifiers