DirectX11 - CreateInputLayout() Vertex shader linkage problem

I keep getting the same error every time, I really have tried everything to fix the problem but it's still not working. Basically I'd like to draw a simple cube.

The error(s):

D3D11 ERROR: ID3D11DeviceContext::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (TEXCOORD,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]
D3D11 ERROR: ID3D11DeviceContext::Draw: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (SV_Position,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND]


The vertex shader, pos.hlsl:

float4 main(float3 pos : POSITION) : SV_POSITION
{
float4 finalPos = { pos.x, pos.y, pos.z, 1.0f };

return finalPos;
}


The vertex layout:

const D3D11_INPUT_ELEMENT_DESC d[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};

struct Vertex
{
XMFLOAT3 poz;
};


The actual code:

Vertex vertex_list[] =
{
{ XMFLOAT3{-1.0f, -1.0f, -1.0f} },
{ XMFLOAT3{-1.0f, +1.0f, -1.0f} },
{ XMFLOAT3{+1.0f, +1.0f, -1.0f} },
{ XMFLOAT3{+1.0f, -1.0f, -1.0f} },
{ XMFLOAT3{-1.0f, -1.0f, +1.0f} },
{ XMFLOAT3{-1.0f, +1.0f, +1.0f} },
{ XMFLOAT3{+1.0f, +1.0f, +1.0f} },
{ XMFLOAT3{+1.0f, -1.0f, +1.0f} }
};

/* First, setup the vertex buffer */
D3D11_BUFFER_DESC o;
o.ByteWidth = sizeof(Vertex) * ARRAYSIZE(vertex_list);
o.Usage = D3D11_USAGE_IMMUTABLE;
o.BindFlags = D3D11_BIND_VERTEX_BUFFER;
o.CPUAccessFlags = 0;
o.MiscFlags = NULL;
o.StructureByteStride = 0;

D3D11_SUBRESOURCE_DATA d;
d.pSysMem = vertex_list;

if FAILED(pRenderer->GetDevice()->CreateBuffer(
&o,
&d,
&m_pBuffer
))
return R_BUFFER_ERROR;

/* Now, setup the vertex layout */

if FAILED(m_pD3DDevice->CreateInputLayout(
d,
ARRAYSIZE(d),
m_bytes,
size,
&m_pInputLayout
))
return R_SETUP_VERTEX_LAYOUT;

m_pD3DKontekst->IASetInputLayout(m_pInputLayout);


Then I'm using m_pD3DContext->Draw() to draw the scene. Nothing shows up, just the usual gray background color using ClearRenderTargetView()

Thanks a lot for any help.

• "I really have tried everything to fix the problem" if that were true, there would be no point in asking us for answers here. You've already investigated every possibility and none of them worked, ergo the problem is simply unsolvable. ;) I'd be willing to bet though that this isn't the case, and there is a solution out there. A more constructive way to approach this would be to tell us what specifically you tried. That lets us eliminate dead ends while also helping us spot possibilities you might have overlooked. – DMGregory Dec 29 '18 at 18:53
• Well, what I tried first was to specify an COLOR and TEXCOORD input and output semantic in the vertex shader (because it seems that D3D wants it). Obviously I changed the Vertex struct too in my code. The errors are a bit different though: link – cattapaw Dec 29 '18 at 22:12
• Of course I'm calling VSSetShader() and PSSetShader() just before Draw() in my rendering function, that's where the error happens. First of all the VS .cso byte code is stored in a char pointer, called "bytes". Then it is passed to CreateVertexShader() and to CreateInputLayout(). Secondly, I free(bytes), then reuse that pointer for CreatePixelShader(). Then free() it again. I debugged the program and it creates both vertex and pixel shaders well, without any errors. The following code helps to illustrate that: link – cattapaw Dec 29 '18 at 22:36

These errors are telling you that you have the wrong vertex shader set when you issue your draw calls.

If we look at the errors and break them down, it can assist in finding the cause.

First of all, the errors all start with this:

Input Assembler - Vertex Shader linkage error

This tells us that the problem is with passing data from the Input Assembler (IA) stage to the Vertex Shader (VS) stage, which is confirmed by the next part:

Signatures between stages are incompatible.

The error then goes on to tell us what data formats the input stage expects (lower-case 'i' here; in this case the input stage is the Vertex Shader, because it's the one which the data is going to). Based on the content of the errors we can reconstruct this signature. So, the errors in full are:

The input stage requires Semantic/Index (COLOR,0) as input...
The input stage requires Semantic/Index (TEXCOORD,0) as input...
The input stage requires Semantic/Index (SV_Position,0) as input...

Meaning that somewhere in your code, you have a vertex shader that looks something like this:

struct VS_INPUT
{
float4 Position : SV_Position;
float2 Texcoord : TEXCOORD;
float4 Color : COLOR;
};

VS_OUTPUT MyVertexShader (VS_INPUT vs_in)
{
...


And that's the shader that's active when you issue your draw calls.

In order to track this down, you can begin as follows:

• Check your IASetInputLayout call and make sure that it has the input layout you intend when issuing your draw calls.
• Check your VSSetShader call and make sure that it has the vertex shader you intend when issuing your draw calls.
• Make sure that the contents of your "pos.cso" file are what you think they are (and likewise for any other .cso files you use).
• Make sure that your shaders and input layouts are all compiled/created successfully.

If this is modified tutorial code then it's possible that any of the above may be at fault.

• Thanks for the answer! I completely forgot to call VSSetShader(). That call removed the last error (SV_Position), but there are still two of them. This is weird because there's absolutely no "COLOR" or "TEXCOORD" in any of my source files. – cattapaw Dec 26 '18 at 15:01
• Maybe there's an error in my drawing function: pastebin.pl/view/480f6905 – cattapaw Dec 26 '18 at 15:10
• @cattapaw - It's difficult to say - you appear to have a lot of things wrapped in your own custom classes and you're not providing the source for those, so there could be bugs in them that we're not aware of. – Maximus Minimus Dec 27 '18 at 10:04
• @Maximus_Minimus - If you could take a look at my code it would be great, I have uploaded an archive with all the rendering code: link Actually I have been following Frank Luna's D3D11 book while writing my game, but he's using .fx files, which I find to be really outdated and unprofessional. So I'm trying to find a way to load shader code from compiled files properly. – cattapaw Dec 27 '18 at 12:43
• @cattapaw - just to advise that "Questions about debugging a problem must provide a minimal, complete, verifiable example of the issue so that readers can diagnose it without needing to guess, read all of your code, or engage in extensive back-and-forth dialog" is a close reason on this site; I'd suggest that you try to break down your code as simply as possible here, or even get it working with those .fx files first before you try to do it your preferred way. – Maximus Minimus Dec 28 '18 at 12:56

After struggling I found an answer: I was calling IASetInputLayout() only once (when initializing D3D11), and actually I needed to call it every frame. That's why I was seeing a colored cube for a fraction of a second just before all these errors came up.