Jump to content
  • Advertisement
Sign in to follow this  
blueshogun96

OpenGL Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible.

This topic is 1246 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I keep getting this really annoying error, and I can't find out why I'm getting it.

 

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

 

Vertex shader:

cbuffer constant_buffer : register(b0)
{
    matrix world;
    matrix view;
    matrix projection;
    float4 colour;
}

struct vs_out
{
    float4 pos : SV_POSITION;
    float4 colour : COLOR0;
    float2 tex : TEXCOORD0;
};


vs_out vs_main( in float4 in_pos : POSITION, in float4 in_colour : COLOR, in float2 tex : TEXCOORD0 )
{
    vs_out output = (vs_out)0;
    float4 pos = float4( in_pos.xy, 0, 1 );

    output.pos = mul( pos, world );
    output.pos = mul( output.pos, view );
    output.pos = mul( output.pos, projection );
    output.colour = in_colour;

    return output;
}

Pixel shader:

struct vs_out
{
    float4 pos : SV_POSITION;
    float4 colour : COLOR0;
    float2 tex : TEXCOORD0;
};


float4 ps_main( vs_out input ) : SV_Target
{
    return input.colour;    
}

Input layout:

D3D11_INPUT_ELEMENT_DESC layout[] =
{
    { "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 },
    { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};

I've been googing this for hours.  No idea what's going on, or what the hell it's even on about.  All I do know is that porting this poorly written OpenGL game to Direct3D11 for Windows Phone 8 and Windows Metro is a pain.  This sucks.  Any ideas?  Thanks.

 

Shogun

Share this post


Link to post
Share on other sites
Advertisement
Change your vs_out struct (in both shaders) to:
struct vs_out
{
    float4 colour : COLOR0;
    float2 tex : TEXCOORD0;
    float4 pos : SV_POSITION;
};
[edit]
The pixel shader doesn't use pos or tex, so they get optimized out, leaving the pixel shader with an input structure of:
{
  [0]  float4 colour;
};

The vertex shader doesn't use tex, so it gets optimized out, leaving the vertex shader with an output structure of:
{
  [0]  float4 pos;
  [1]  float4 colour;
};


Looking at the array indices on these generated interpolants, vs[0]'s semantic doesn't match ps[0]'s semantic, and vs[1] isn't even used.

With my change, you should end up with:
PS:
{
  [0]  float4 colour;
};

VS:
{
  [0]  float4 colour;
  [1]  float4 pos;
};
Edited by Hodgman

Share this post


Link to post
Share on other sites
@Hodgman: The compiler does not optimize variables out if they're bound to a semantic. Their components just end up unused
// Input signature:
//
// Name                 Index   Mask Register SysValue Format   Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_POSITION              0   xyzw        0      POS  float       
// COLOR                    0   xyzw        1     NONE  float   xyzw
// TEXCOORD                 0   xy          2     NONE  float
For optimization one could strip them though (from the end, if possible of course).

Also, TEXCOORD is output by the VS, because of this:
vs_out output = (vs_out)0;
Recommendation: Don't do that, it hides bugs. Be explicit e.g. with output.Tex = 0. The compiler will warn you about forgotten output.

@shogun: The shaders compile fine as a combined effect (which detects semantic mismatches at compile time). I guess you have the wrong shaders bound at draw call time. Check with the graphics debugger.


Edit: Wait. Windows Metro ? How do you compile them (flags, shader model ?). Downlevel feature levels can translate SV_Position to POSITION. A look at the generated assembly might help. Edited by unbird

Share this post


Link to post
Share on other sites

Okay, switched to .fx files instead.  At least now I'm not getting that annoying error anymore.  Now to find out why nothing draws still...

 

Shogun.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!