Sign in to follow this  
Ratslayer

Input Assembler - Vertex Shader linkage error

Recommended Posts

Ratslayer    110
Hello. I've compiled the Solid Wireframe shader provided by NVidia. I've added a little modification for it to be able to draw lines instead of triangles. It compiled fine and it works, although it gives me the following errors at every rendering call: D3D10: ERROR: ID3D10Device::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The reason is that Semantic 'POSITION' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ EXECUTION ERROR #345: DEVICE_SHADER_LINKAGE_REGISTERMASK ] D3D10: ERROR: ID3D10Device::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The reason is that Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX ] I've tried to find something about it online, but somehow the resources are pretty scarce and I can't find any official documentation on this type of errors. Here's the code I think that is relevant to the problem:
HRESULT CD3DDeviceHolder::InitInputLayout()
{
	HRESULT hr = S_OK;

	nLayoutElements = 3;

	pstrLayout = new D3D10_INPUT_ELEMENT_DESC[nLayoutElements];

	D3D10_INPUT_ELEMENT_DESC layout[] =
	{
		{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
		{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, sizeof(D3DXVECTOR3), D3D10_INPUT_PER_VERTEX_DATA, 0 },
		{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 2*sizeof(D3DXVECTOR3), D3D10_INPUT_PER_VERTEX_DATA, 0 },
	};
	for (unsigned int i = 0; i < nLayoutElements; i++)
		pstrLayout[i] = layout[i];

	return S_OK;
}

//--------------------------------------------------------------------------------------
// Shader Description
//--------------------------------------------------------------------------------------
struct VS_INPUT
{
    float3 Pos  : POSITION;
    float3 Nor  : NORMAL;
    float3 Tex  : TEXCOORD0;
};

struct GS_INPUT
{
    float4 Pos  : POSITION;
    float4 PosV : TEXCOORD0;
};

struct PS_INPUT
{
    float4 Pos : SV_POSITION;
    float4 Col : TEXCOORD0;
};

struct PS_INPUT_WIRE
{
    float4 Pos : SV_POSITION;
    float4 Col : TEXCOORD0;
    noperspective float3 Heights : TEXCOORD1;
};

//--------------------------------------------------------------------------------------
// Utils Funtions
//--------------------------------------------------------------------------------------

// Compute the final color of a face depending on its facing of the light
float4 shadeFace(in float4 verA, in float4 verB, in float4 verC)
{
    // Compute the triangle face normal in view frame
    float3 normal = faceNormal(verA, verB, verC);
    
    // Then the color of the face.
    float shade = 0.5*abs( dot( normal, LightVector) );
    
    return float4(FillColor.xyz*shade, 1);
}

//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
GS_INPUT VS( VS_INPUT input )
{
    GS_INPUT output;
    //output.Pos = modelToProj( float4(input.Pos, 1));
    //output.PosV = modelToView( float4(input.Pos, 1));
    output.Pos = mul(float4(input.Pos, 1), WorldViewProjection);
    output.PosV = mul(float4(input.Pos, 1), WorldView);
    return output;
}

//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------

[maxvertexcount(3)] 
void GS( triangle GS_INPUT input[3],
         inout TriangleStream<PS_INPUT> outStream )
{
    PS_INPUT output;

    // Shade and colour face.
    output.Col = shadeFace(input[0].PosV, input[1].PosV, input[2].PosV);

    output.Pos = input[0].Pos;
    outStream.Append( output );

    output.Pos = input[1].Pos;
    outStream.Append( output );

    output.Pos = input[2].Pos;
    outStream.Append( output );

    outStream.RestartStrip();
}
[maxvertexcount(2)]
void GSLine(line GS_INPUT input[2], inout LineStream<PS_INPUT> outStream)
{
      PS_INPUT output;

      // Shade and colour face.
      output.Col = float4(0.0f,0.0f,0.0f,0.0f);
  
      output.Pos = input[0].Pos;
      outStream.Append( output );
  
      output.Pos = input[1].Pos;
      outStream.Append( output );

      outStream.RestartStrip();
}
[maxvertexcount(3)]
void GSSolidWire( triangle GS_INPUT input[3],
                         inout TriangleStream<PS_INPUT_WIRE> outStream )
{
    PS_INPUT_WIRE output;

    // Shade and colour face.
    output.Col = shadeFace(input[0].PosV, input[1].PosV, input[2].PosV);

    // Emit the 3 vertices
    // The Height attribute is based on the constant
    output.Pos = input[0].Pos;
    output.Heights = float3( 1, 0, 0 );
    outStream.Append( output );

    output.Pos = input[1].Pos;
    output.Heights = float3( 0, 1, 0 );
    outStream.Append( output );

    output.Pos = input[2].Pos;
    output.Heights = float3( 0, 0, 1 );
	outStream.Append( output );

    outStream.RestartStrip();
}

//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------

float4 PSColor( PS_INPUT input) : SV_Target
{
    return input.Col;
}
//--------------------------------------------------------------------------------------

technique10 DephAndSolid
{
    pass
    {
        SetDepthStencilState( DSSDepthWriteLess, 0 );
        SetRasterizerState( RSFill );
        SetBlendState( BSBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( CompileShader( gs_4_0, GS() ) );
        SetPixelShader( CompileShader( ps_4_0, PSColor() ) );
    }
}
technique10 LineDephAndSolid
{
	pass
	{
		SetDepthStencilState( DSSDepthWriteLess, 0 );
        SetRasterizerState( RSFill );
        SetBlendState( BSBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
        SetVertexShader( CompileShader( vs_4_0, VS() ) );
        SetGeometryShader( CompileShader( gs_4_0, GSLine() ) );
        SetPixelShader( CompileShader( ps_4_0, PSColor() ) );
	}
}

I have no idea what the first error is about, but the second one apparently happends when you mismatch the order of the input variables, which I don't think I did. Anybody got any ideas?

Share this post


Link to post
Share on other sites
MENTAL    383
Anything to do with defining VS_INPUT with float3 instead of float4? (not I don't know DX, just looks like a logical error).

edit: actually looking at it, it seems you convert them to float4 in the VS. musawirali, his VS is in the listing.

Share this post


Link to post
Share on other sites
Ratslayer    110
Not sure if I converted everything properly.
I am using D3D10_PRIMITIVE_TOPOLOGY_LINELIST when drawing the lines and everything renders properly, it's just that it's flickering and slower than should be (possibly because Vusual Studio has to process errors, although 2errors/frame doesn't seem that much to me). Also, what I did was simply replace the triangle GS with my GSLine, I'm not sure if there is anything else to change at vertex/pixel shaders. And yes, I think I'm using the correct pass calling , because everything is rendered. Comparatively, the old technique is DephAndSolid and the new one is LineDephAndSolid.
This is the way I use the techniques:

void AnDebugDraw::Render(CCamera* pcamera, D3DXVECTOR4 vviewport)
{
InitializeEffect(pcamera, vviewport);
const NxDebugRenderable *dbgdata=gScene->getDebugRenderable();
if(dbgdata)DrawLines(pcamera, vviewport, dbgdata);
}
void AnDebugDraw::DrawLines(CCamera* pcamera, D3DXVECTOR4 vviewport, const NxDebugRenderable *dbgdata)
{
GenerateLines(dbgdata);
Draw(pcamera, vviewport, dbgdata->getNbLines()*2, "LineDephAndSolid");
}
void AnDebugDraw::Draw(CCamera* pcamera, D3DXVECTOR4 vviewport, unsigned int buffsize, const char* technique_name)
{
D3D10_TECHNIQUE_DESC techDesc;
pEffect->pTechnique->GetDesc(&techDesc);
for(UINT p = 0; p < techDesc.Passes; ++p)
{
pEffect->pTechnique->GetPassByName(technique_name)->Apply(0);
pDH->pD3D10Device->DrawIndexed(buffsize, 0, 0);
}
pDH->pSwapChain->Present(0,0);
}





Also, if it helps, the DephAndSolid technique works fine, which might be an indicator that something's wrong with my LineDephAndSolid technique. Note, as well, that for DephAndSolid I used meshes while for LineDephSolid I'm using vertex Dynamic Vertex/Index Buffers, which I update with the debug information I've been fed by NxDebugRenderable that I store in Staging V/IBs. I hope this is useful information.

[Edited by - Ratslayer on February 11, 2010 5:40:04 PM]

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this