Monday, August 29, 2022
HomeGame Developmentc++ - DirectX11 creating enter structure throws error on enter signature not...

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


The enter structure

D3D11_INPUT_ELEMENT_DESC structure[] = {
            {"Place", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
            {"Regular", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
            {"Remodel", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1},
            {"Remodel", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1},
            {"Remodel", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1},
            {"Remodel", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1},
            {"Colour", 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 : Place;
    float3 n : Regular;
    row_major float4x4 rework : Remodel;
    float4 colour : Colour;
};
struct VSOut
{
    float3 worldPos : Place;
    float3 regular : Regular;
    float4 pos : SV_Position;
    float4 colour : Colour;
};
VSOut principal(VSIn enter)
{
    VSOut vso;
    vso.worldPos = (float3) mul(float4(enter.pos, 1.0f), enter.rework);
    vso.regular = mul(enter.n, (float3x3) enter.rework);
    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: 'Remodel'/0, however the declaration would not present an identical identify.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Remodel'/1, however the declaration would not present an identical identify.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Remodel'/2, however the declaration would not present an identical identify.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Remodel'/3, however the declaration would not present an identical identify.
D3D11Device::CreateInputLayout: The offered enter signature expects to learn a component with SemanticName/Index: 'Colour'/0, however the declaration would not present an identical identify.

[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. I beforehand had this complete setup working with regular non instanced drawing. I perceive that the error means the enter structure would not match the shader declaration however I can not see which half doesn’t match. VSIn incorporates a semantic identify for Place, Regular, Remodel and Colour.

Analysis:

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

  • Use D3D11_APPEND_ALIGNED_ELEMENT as an alternative of manually calculating the offsets
  • Cut up up the Remodel matrix into 4 float4s with numbered semantic names
  • Binding simply the colour and eradicating the rework from each the enter description and the shader (similar error however solely regarding colour).
  • Make sure the shader that’s loaded is the proper shader
  • Delete the generated .cso file to verify the shader recompiles
  • Change the semantic names to totally different strings in case of reserved identifiers
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments