3

I have apparent mismatches between each of them, but I can't see why or how they do not match. I've been looking at it so long I can't see anything now, so perhaps a few more sets of eyes....

Here are the members of the vertex struct:
    XMFLOAT4   _vertexPosition;
    XMFLOAT4   _vertexColor;

Here is the input layout description:

static const D3D11_INPUT_ELEMENT_DESC vertexLayout[] =
{
    { "SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    { "COLOR",       0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};

Here is the vertex shader input:

struct VertexShaderInput
{
    float4 Position             : SV_POSITION0;
    float4 Color                : COLOR0;
};

and finally, the pixel shader input:

struct PixelShaderInput
{
    float4 Color                : COLOR0;
};

And the ultimate error, currently between the two stages only, is:

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]
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'COLOR' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]

To me the vertexLayout definition seems to match the vertex shader input, but the runtime sure doesn't! Can anyone spot what I've botched? Any tips would be appreciated! Thanks!

Dave
  • 1,521
  • 17
  • 31

1 Answers1

3

The Vertex Shader needs to output a SV_POSITION since that's used by the rasterizer to determine where the pixel shader should run. It's legal to have Pixel Shader input not have a SV_POSITION but in that case you can't use the same PixelShaderInput struct as both the VS output and the PS input.

Also by convention, you don't use the semantic index with position, so change SV_POSITION0 to SV_POSITION in your HLSL shader--a vertex can't be in two places at once.

Per-vertex color vertex shader input is typically COLOR while COLOR0/COLOR1 is used in vertex shader output/pixel shader input for diffuse vs. specular colors.

struct VertexShaderInput
{
    float4 Position             : SV_POSITION;
    float4 Color                : COLOR;
};
Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • Thanks. Resolved the incompatibility between the vertex and pixel shaders, but the input stage still complains. The last remaining error is: The input stage requires Semantic/Index (SV_POSITION,0) as input, but it is not provided by the output stage. – Dave Jul 06 '15 at 18:43
  • I've opened a second question for a similar issue that I'm also stumped on: http://stackoverflow.com/questions/31256255/mismatch-between-input-assembler-and-vertex-shader-but-it-looks-right – Dave Jul 06 '15 at 21:50