Home Game Development c++ – DirectX11 creating enter structure throws error on enter signature not matching shader (instancing)

c++ – DirectX11 creating enter structure throws error on enter signature not matching shader (instancing)

0
c++ – DirectX11 creating enter structure throws error on enter signature not matching shader (instancing)

[ad_1]

The enter structure

D3D11_INPUT_ELEMENT_DESC structure[] = {
            {"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 mannequin;
    matrix modelViewProj;
};
struct VSIn
{
    float3 pos : Position;
    float3 n : Normal;
    row_major float4x4 remodel : Transform;
    float4 colour : Color;
};
struct VSOut
{
    float3 worldPos : Position;
    float3 regular : Normal;
    float4 pos : SV_Position;
    float4 colour : Color;
};
VSOut important(VSIn enter)
{
    VSOut vso;
    vso.worldPos = (float3) mul(float4(enter.pos, 1.0f), enter.remodel);
    vso.regular = mul(enter.n, (float3x3) enter.remodel);
    vso.pos = mul(float4(enter.pos, 1.0f), modelViewProj);
    vso.colour = enter.colour;
    return vso;
}

The error

ID3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Transform'/0, however the declaration would not present an identical title.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Transform'/1, however the declaration would not present an identical title.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Transform'/2, however the declaration would not present an identical title.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Transform'/3, however the declaration would not present an identical title.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Color'/0, however the declaration would not present an identical title.

[Error Code] 0x80070057 (2147942487)
[Error String] E_INVALIDARG
[Description] The parameter is wrong.

The error is thrown on CreateInputLayout earlier than I draw something to display screen. I beforehand had this entire setup working with regular non instanced drawing. I perceive that the error means the enter structure would not match the shader declaration however I am unable to see which half doesn’t match. VSIn incorporates a semantic title for Position, Normal, Transform and Color.

Research:

So for what I’ve tried after studying the above:

  • Use D3D11_APPEND_ALIGNED_ELEMENT as a substitute of manually calculating the offsets
  • Split up the Transform matrix into 4 float4s with numbered semantic names
  • Binding simply the colour and eradicating the remodel from each the enter description and the shader (identical error however solely regarding colour).
  • Ensure the shader that’s loaded is the proper shader
  • Delete the generated .cso file to ensure the shader recompiles
  • Change the semantic names to completely different strings in case of reserved identifiers

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here