Advertisement

the Directx11 probelm about Vertex Shader Geometry Shader linkage error

Started by October 17, 2019 02:33 PM
8 comments, last by vinterberg 5 years ago

hi,i have a error when i run my code .

and here is my error

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Geometry Shader linkage error: Signatures between stages are incompatible. Semantic 'POSITION' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]
 
and i think that maybe i write wrong in hlsl;
but i cant find where was wrong  .?
 

and this my code

---VS-----

#include"Base.hlsli"

VertexPosSize VS(VertexPosSize Vin)
{
    return Vin;
}

---GS--

#include"Base.hlsli"

static const float2 g_Tex[4] = {{0.0f,0.0f}, {0.0f,1.0f}, {1.0f,0.0f}, {1.0f,1.0f}};

[maxvertexcount(4)]
void GS
(   
    point VertexPosSize Point[1],
    uint primID : SV_PrimitiveID,
    inout TriangleStream<BillboardVertex> output
)
{
    float3 u = float3(0.0f, 1.0f, 0.0f);
    float3 w = g_EyePosW - Point[0].Pos; 
    w.y = 0.0f;
    float3 v = cross(u,w);

    float4 V[4];
    float3 center = Point[0].Pos;
    float halfWidth = Point[0].Size.x * 0.5f;
    float halfHeight = Point[0].Size.y * 0.5f;

    V[0] = float4(center + halfWidth * v + halfHeight * u, 1.0f);
    V[1] = float4(center + halfWidth * v - halfHeight * u, 1.0f);
    V[2] = float4(center - halfWidth * v + halfHeight * u, 1.0f);
    V[3] = float4(center - halfWidth * v - halfHeight * u, 1.0f);
    
    BillboardVertex vertex;
    matrix g = g_View * g_Proj;
    for (int i = 0; i < 4; ++i)
    {  
        vertex.PosW = V.xyz;
        vertex.PosH = mul(float4(vertex.PosW,1.0f), g);
        vertex.PrimID = primID;
        vertex.Tex = g_Tex;
        vertex.NormalW = w;
        output.Append(vertex);

    }
}
------ Base-- the struct that i defined

struct VertexPosSize
{
    float3 Pos : POSITION;
    float2 Size : SIZE;
};
struct BillboardVertex
{
    float4 PosH    :  SV_POSITION;
    float3 PosW    :  POSITION; 
    float3 NormalW :  NORMAL;
    float2 Tex     :  TEXCOORD; 
    uint   PrimID  :  SV_PrimitiveID;
   
};

-------

This is not a Writing question. Moving to a more appropriate forum. 

-- Tom Sloper -- sloperama.com

Advertisement

That error means that your output struct from vertex shader is not the same as the input for geometry shader. But the code you posted looks fine to me as they are both using a shared struct. Have you not forgotten to recompile a shader?

3 minutes ago, turanszkij said:

That error means that your output struct from vertex shader is not the same as the input for geometry shader. But the code you posted looks fine to me as they are both using a shared struct. Have you not forgotten to recompile a shader?

?Thank you for your answer, but I have compiled it. But I now doubt if it is a problem with my structure packaging.

I was thinking it could be a left over shader from an older compilation that uses a different structure. An other thing might be that you are not binding the correct vertex shader and geometry shader pair. Maybe the vertex shader is left over from a different render pass... It would help to capture the frame with Nsight or RenderDoc and look at shader disassembly for the erroring batch and see if the active shaders are the ones you are expecting or not.

1 hour ago, ALFREDO_ said:

vertex.Tex = g_Tex;

That should probably be g_Tex [ i ] ...Not related to issue though, but hey.. :)

Rename SV_Position in your VertexPosSize struct to something else (maybe call PosH/W POSITIONH/W) - you should only output SV_Position from your geometry shader, not the vertex shader!

Here's an example:


struct VS_OUTPUT
{
	float3 Position : POSITION;
	float Height : HEIGHT;
};

struct GS_INPUT
{
	float3 Position : POSITION;
	float Height : HEIGHT;
};

struct GS_OUTPUT
{
	float4 Position : SV_POSITION;
	float2 UV : TEXCOORD0;
	uint TextureIndex : TEXINDEX;

};

 

.:vinterberg:.

Advertisement
7 minutes ago, vinterberg said:
12 minutes ago, vinterberg said:

That should probably be g_Tex [ i ] ...Not related to issue though, but hey.. :)

Rename SV_Position in your VertexPosSize struct to something else (maybe call PosH/W POSITIONH/W) - you should only output SV_Position from your geometry shader, not the vertex shader!

Here's an example:




struct VS_OUTPUT
{
	float3 Position : POSITION;
	float Height : HEIGHT;
};

struct GS_INPUT
{
	float3 Position : POSITION;
	float Height : HEIGHT;
};

struct GS_OUTPUT
{
	float4 Position : SV_POSITION;
	float2 UV : TEXCOORD0;
	uint TextureIndex : TEXINDEX;

};

Thank you for your answer, but my vertex shader does not return SV_position. ?It just returned the POSITION.

this is my VertexPosSize which i defined

struct VertexPosSize
{
    float3 Pos : POSITION;
    float2 Size : SIZE;
};

 

and i return it 

#include"Base.hlsli"

VertexPosSize VS(VertexPosSize Vin)
{
    return Vin;
}

 

 

 

I found the error. I didn't clear the binding of the gs shader.

Oh I misread the structs - my bad :D

.:vinterberg:.

This topic is closed to new replies.

Advertisement