1
votes

I'm adding a geometry shader (a very simple one) to my DirectX 11 program. I've already got vertex and pixel shader written, and they work just as expected - no errors, no warnings. The shaders are simple, too. The vertex shader is:

cbuffer PerApplication : register(b0)
{
    matrix projectionMatrix;
}

cbuffer PerFrame : register(b1)
{
    matrix viewMatrix;
}

cbuffer PerObject : register(b2)
{
    matrix worldMatrix;
}

struct VertexShaderInput
{
    float4 position : POSITION;
    float4 color: COLOR;
};

struct VertexShaderOutput
{
    float4 color : COLOR;
    float4 position : SV_POSITION;
};

//entry point
VertexShaderOutput SimpleVertexShader(VertexShaderInput IN)
{
    VertexShaderOutput OUT;
 
    matrix mvp = mul(projectionMatrix, mul(viewMatrix, worldMatrix));
    OUT.color = IN.color;
    OUT.position = mul(mvp, IN.position);
 
    return OUT;
}

The pixel shader is:

struct PixelShaderInput
{
    float4 color : COLOR;
};
 
float4 SimplePixelShader(PixelShaderInput IN) : SV_TARGET
{
    return IN.color;
}

Well, as I've said, that's working pretty well. Then I'm adding a geometry shader, which doesn't actually do anything, it just takes a triangle and returns the same triangle. The geometry shader is:

struct VertexInput
{
    float4 color : COLOR;
    float4 position : POSITIONT;
};

struct VertexOutput
{
    float4 color : COLOR;
    float4 position : SV_Position;
};

[maxvertexcount(3)]
void SimpleGeometryShader(triangle VertexInput input[3], inout TriangleStream<VertexOutput> stream)
{    
    VertexOutput v1 = { input[0].color, input[0].position };
    stream.Append(v1); 
    VertexOutput v2 = { input[1].color, input[1].position };
    stream.Append(v2); 
    VertexOutput v3 = { input[2].color, input[2].position };
    stream.Append(v3);

    stream.RestartStrip();
}

Doing this also requires to change the vertex shader, which now returns

struct VertexShaderOutput
{
    float4 color : COLOR;
    float4 position : POSITIONT; //I'm not returning SV_Position in vertex shader anymore.
};

And the program itself works, and it works as expected, I see what I expect to see. But there are now two D3D11 errors:

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

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

Both are pretty strange. The vertex shader clearly returns a POSITIONT, and COLOR and POSITIONT are in the same order. What's my mistake?

1

1 Answers

0
votes

The reason of the problem was that beside of rendering the scene using the shaders that I provided I was also drawing text using some library. Obviously, there were some vertex and pixel shaders involved in it with their own input and output signatures. Setting geometry shader to null solved my problem.