1
\$\begingroup\$

I've stared at this for at least half an hour now and I cannot figure out what directx is complaining about. I know this error normally means you put float3 instead of a float4 or something like that, but I've checked over and over and as far as I can tell, everything matches.

This is the full error message:

D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: 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 ]

This is the vertex shader's input signature as seen in PIX:

// Input signature:
//
// Name                 Index   Mask Register SysValue Format   Used
// -------------------- ----- ------ -------- -------- ------ ------
// POSITION                 0   xyz         0     NONE  float   xyz 
// NORMAL                   0   xyz         1     NONE  float       
// COLOR                    0   xyzw        2     NONE  float      

The HLSL structure looks like this:

struct VertexShaderInput
{
    float3 Position : POSITION0;
    float3 Normal : NORMAL0;
    float4 Color: COLOR0;
};

The input layout, from PIX, is:

enter image description here

The C# structure holding the data looks like this:

[StructLayout(LayoutKind.Sequential)]
public struct PositionColored
{
    public static int SizeInBytes = Marshal.SizeOf(typeof(PositionColored));

    public static InputElement[] InputElements = new[]
    {
        new InputElement("POSITION", 0, Format.R32G32B32_Float, 0),
        new InputElement("NORMAL", 0, Format.R32G32B32_Float, 0),
        new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 0)
    };

    Vector3 position;
    Vector3 normal;
    Vector4 color;

    #region Properties
    ...
    #endregion

    public PositionColored(Vector3 position, Vector3 normal, Vector4 color)
    {
        this.position = position;
        this.normal = normal;
        this.color = color;
    }
    public override string ToString()
    {
        StringBuilder sb = new StringBuilder(base.ToString());
        sb.Append(" Position=");
        sb.Append(position);
        sb.Append(" Color=");
        sb.Append(Color);
        return sb.ToString();
    }
}

SizeInBytes comes out to 40, which is correct (4*3 + 4*3 + 4*4 = 40). Can anyone find where the mistake is?

\$\endgroup\$
2
  • \$\begingroup\$ I suspect that since your input elements don't specify the exact offset of the values in the structure, it's assuming they're all aligned and is trying to read from 0, 16, and 32-byte offsets. So it would be trying to read 16 bytes of color from offset 32, which would read past the end of the 40-byte vertex, so instead it gives you an error. \$\endgroup\$ Sep 2 '12 at 6:12
  • \$\begingroup\$ I've always used Append_Aligned_Element without any problems before. And explicitly setting the offsets to 0, 12, and 24 didn't help. \$\endgroup\$
    – Telanor
    Sep 2 '12 at 10:10
1
\$\begingroup\$

Turns out that removing the normal and color (I wasnt using them anyway) from the VertexShaderInput struct makes the warning go away. I suspect this is just covering up some other problem but unless someone has any other ideas, I'll go with this for now.

\$\endgroup\$
1
  • \$\begingroup\$ is obviously very late, and I don't know if it helps/matters are this point, but I had a similar issue with my code. My problem was that I was setting a vertex shader, then drawing a set of geometries, ONE of which had the incompatible layout which was causing the error. \$\endgroup\$
    – A.R.
    Dec 22 '19 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.