I'm trying to introduce a Geometry Shader into my pipeline, but it does not seem to be recognized and the Vertex Shader tries to go directly into the Pixel Shader. I get this error message:
D3D11 ERROR: ID3D11DeviceContext::Draw: Vertex Shader - Pixel 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]
Here is the data input and out for all the shaders
struct vs_input_t
{
float3 localPosition : POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD;
};
struct v2g_t
{
float4 position : POSITIONT;
float4 worldPosition : POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD;
};
struct g2p_t
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv : TEXCOORD;
};
Here is the shader code:
[maxvertexcount(4)]
void GeometryMain(line v2g_t geoInput[2], inout TriangleStream<g2p_t> triangleStream)
{
float3 up = float3(0.0f, 0.0f, 1.0f);
float3 towardsCam = EyePosition - geoInput[0].worldPosition;
towardsCam.z = 0.0f;
towardsCam = normalize(towardsCam);
float3 right = cross(up, towardsCam);
float4 vertexes[4];
vertexes[0] = float4(geoInput[0].worldPosition);
vertexes[1] = float4(geoInput[1].worldPosition);
vertexes[2] = float4(geoInput[0].worldPosition + float4(right, 1.0f));
vertexes[3] = float4(geoInput[1].worldPosition + float4(right, 1.0f));
g2p_t output;
[unroll]
for (int i = 0; i < 4; i++)
{
output.color = geoInput[0].color;
output.position = mul(ViewMatrix, vertexes[i]);
output.position = mul(ProjectionMatrix, output.position);
output.uv = geoInput[0].uv;
triangleStream.Append(output);
}
}
float4 PixelMain(g2p_t input) : SV_Target0
{
float4 resultingColor = diffuseTexture.Sample(diffuseSampler, input.uv) * input.color * ModelColor;
if (resultingColor.w == 0)
discard;
return resultingColor;
}
v2g_t VertexMain(vs_input_t input)
{
v2g_t v2g;
float4 position = float4(input.localPosition, 1);
float4 modelTransform = mul(ModelMatrix, position);
v2g.worldPosition = modelTransform;
float4 modelToViewPos = mul(ViewMatrix, modelTransform);
v2g.position = mul(ProjectionMatrix, modelToViewPos);
v2g.color = input.color;
v2g.uv = input.uv;
return v2g;
}
I'm failing to see any mismatch between the data structures
As @mateeeeeee mentioned, and in case anyone else runs into something similar. I forgot to call ID3D11DeviceContext::GSSetShader