No valid DomainShader-GeometryShader combination could be found

Started by
2 comments, last by unbird 10 years, 11 months ago
FXC is giving me this error when I try to compile my shader. I couldn't find anything on the internet related to this error. I have a tessellation shader that I want to add clipping to. MSDN says that SV_CLIPDISTANCE is writable from both the vertex shader and the geometry shader, so I tried to output from the vertex shader first and got this error:
Error 46	invalid hs_5_0 control point input semantic 'SV_CLIPDISTANCE0'
So I figured maybe you can't do it from there when using a hull shader. I added a geometry shader to the effect and now the error I get is this:
Error 46	No valid DomainShader-GeometryShader combination could be found in Technique Tessellation, Pass P0.
I'm guessing this might have something to do with the configuration of inputs/outputs being wrong, since I can't really find any tutorial on geometry shaders, let alone using one with tessellation. This is my shader:
#include <Shared.fx>

float3 Padding;
int TessellationFactor;
float TessellationNoise = 0.5f;

Texture2DArray DisplacementMap;
SamplerState displacementSampler
{
	Filter = Anisotropic;
	AddressU = Wrap;
	AddressV = Wrap;
	MaxAnisotropy = 16;
};

struct VertexInputType
{
	float3 Position	: POSITION0;
	float3 Normal		: NORMAL0;
	float3 TexCoord	: TEXCOORD0;
	float Shadow		: COLOR0;
	float Index		: INDEX;
	uint Damage		: DAMAGE;
};
struct HullInputType
{
	float4 Position : POSITION;
	float3 TexCoord : TEXCOORD0;
	float3 Normal   : NORMAL;
	float Shadow	 : COLOR0;
	float Selected	 : INDEX;
	uint Damage	 : DAMAGE;
};
struct ConstantOutputType
{
	float edges[3] : SV_TessFactor;
	float inside   : SV_InsideTessFactor;
};
struct HullOutputType
{
	float3 Position : POSITION;
	float3 TexCoord : TEXCOORD0;
	float3 Normal   : NORMAL;
	float Shadow	 : COLOR0;
	float Selected	 : INDEX;
	uint Damage	 : DAMAGE;
};

struct GSInput
{
	float4 Position          : SV_POSITION;
	float3 Normal            : NORMAL;
	float3 TexCoord	     : TEXCOORD0;
	float3x3 TangentToWorld	: TEXCOORD1;
	float Shadow	          : COLOR0;
	float Clip			: CLIPDISTANCE;
	float Selected	          : INDEX;
	uint Damage			: DAMAGE;
};

struct PixelInputType
{
	float4 Position          : SV_POSITION;
	float3 Normal            : NORMAL;
	float3 TexCoord	     : TEXCOORD0;
	float3x3 TangentToWorld	: TEXCOORD1;
	float Shadow	          : COLOR0;
	float Clip			: SV_CLIPDISTANCE0;
	float Selected	          : INDEX;
	uint Damage			: DAMAGE;
};
 
HullInputType VS(VertexInputType input)
{
	HullInputType output;
	output.Position = float4(input.Position, 1);
	output.TexCoord = input.TexCoord;
	output.Normal = input.Normal;
	output.Shadow = input.Shadow;
	output.Selected = input.Index;
	output.Damage = input.Damage;

	return output;
}

ConstantOutputType TessPatchConstantFunction(InputPatch<HullInputType, 3> inputPatch, uint patchId : SV_PrimitiveID)
{    
	ConstantOutputType output;
 
	// Edge factor
	output.edges[0] = TessellationFactor;
	output.edges[1] = TessellationFactor;
	output.edges[2] = TessellationFactor;
 
	// Center factor
	output.inside = TessellationFactor;
 
	return output;
}

//--------------------------------------------------------------------------------------
// Hull Shader
//--------------------------------------------------------------------------------------
[domain("tri")]
[partitioning("integer")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(3)]
[patchconstantfunc("TessPatchConstantFunction")]
HullOutputType HS(InputPatch<HullInputType, 3> patch, uint pointId : SV_OutputControlPointID, uint patchId : SV_PrimitiveID)
{
	HullOutputType output;
	output.Position = patch[pointId].Position;
	output.TexCoord = patch[pointId].TexCoord;
	output.Normal = patch[pointId].Normal;
	output.Shadow = patch[pointId].Shadow;
	output.Selected = patch[pointId].Selected;
	output.Damage = patch[pointId].Damage;
	return output;
}

//--------------------------------------------------------------------------------------
// Domain Shader
//--------------------------------------------------------------------------------------
[domain("tri")]
PixelInputType DS(ConstantOutputType input, float3 uvwCoord : SV_DomainLocation, const OutputPatch<HullOutputType, 3> patch)
{
	GSInput output;

	...

	return output;
}

//--------------------------------------------------------------------------------------
// Geometry Shader
//--------------------------------------------------------------------------------------
[maxvertexcount(3)]
void GS( triangle GSInput input[3], inout TriangleStream<PixelInputType> triStream )
{
    PixelInputType output;

    for( uint i=0; i < 3; i += 1 )
    {
        output.Position = input.Position;
        output.Normal = input.Normal;
        output.TexCoord = input.TexCoord;
	   output.TangentToWorld = input.TangentToWorld;
	   output.Shadow = input.Shadow;
	   output.Selected = input.Selected;
	   output.Damage = input.Damage;
	   output.Clip = input.Clip;
		
        triStream.Append( output );
    }
	
    triStream.RestartStrip();
}

PixelShaderOutput PS(PixelInputType input)
{
	PixelShaderOutput output; 

	...

	return output;
}

technique11 Tessellation
{
	pass P0
	{
		SetGeometryShader(CompileShader(gs_5_0, GS() ));
		SetHullShader( CompileShader( hs_5_0, HS() ) );
		SetDomainShader( CompileShader( ds_5_0, DS() ) );
		SetVertexShader( CompileShader( vs_5_0, VS() ) );
		SetPixelShader( CompileShader( ps_5_0, PS() ) );
	}
}
Advertisement
The signatures simply don't match. I'm a bit surprised the compiler doesn't complain earlier about your domain shader. It should look something like this (note: different function return type):

GSInput DS(ConstantOutputType input, float3 uvwCoord : SV_DomainLocation, const OutputPatch<HullOutputType, 3> patch)
{
   GSInput output;
   ...
   return output;
}
As for SV_ClipDistance: I wonder if the docs are a bit misleading here. Similar to SV_Position I expect it to be only sensible as an input for the rasterizer, so it can only be used as output in the last stage before the pixel shader. I wonder if you really can't write it directly from the DS - without a GS that is ... wait ... tried it, yeah you can.
Yep that was it. Can't believe I missed that. Strange the compiler didn't say anything either. And you're also right that I don't even need the geometry shader, despite what the MSDN says... thanks for the help.

That semantics documentation is confusing. It mixes D3D9, D3D10 and D3D11 stuff. "Writeable from vertex and geometry shader" is probably a leftover from D3D10 which doesn't have tesselation. Another example is that one isn't force to use D3D9 semantics anymore, one can use any name which doesn't collide with the system value semantics. E.g. you could name your tangent frame TANGENT instead of TEXCOORD1.

This topic is closed to new replies.

Advertisement