# Compiling geometry shader with D3DCompile

This topic is 2027 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm trying to compile this geometry shader with D3DCompile.

const std::string shaderSource =
"cbuffer ParticleSystemBuffer : register(b0)\n"
"{\n"
"	float4x4 ;\n"
"	Light lights[8];\n"
"}\n\n"

"struct VS_OUTPUT\n"
"{\n"
"	float4 Pos : SV_POSITION;\n"
"	float2 Tex : TEXCOORD;\n"
"};\n\n"

"struct GS_OUTPUT\n"
"{\n"
"	float4 Pos : SV_POSITION;\n"
"	float2 Tex : TEXCOORD;\n"
"};\n\n"

"cbuffer cbImmutable\n"
"{\n"
"	float3 g_positions[4] =\n"
"	{\n"
"		float3( -1, 1, 0 ),\n"
"		float3( 1, 1, 0 ),\n"
"		float3( -1, -1, 0 ),\n"
"		float3( 1, -1, 0 ),\n"
"	};\n"
"	float2 g_texcoords[4] =\n"
"	{\n"
"		float2(0,1),\n"
"		float2(1,1),\n"
"		float2(0,0),\n"
"		float2(1,0),\n"
"	};\n"
"};\n\n"

"[maxvertexcount(4)]\n"
"void GS_main(point VS_OUTPUT input[1], inout TriangleStream<GS_OUTPUT> SpriteStream)\n"
"{\n"
"	GS_OUTPUT output;\n"

"	for(int i=0; i<4; i++)\n"
"	{\n"
"		output.Tex = g_texcoords[i];\n"

"		SpriteStream.Append(output);\n"
"	}\n"

"	SpriteStream.RestartStrip();\n"
"}\n";


The problem is that I keep getting the X3501 error: Error: [geometry shader]error X3501: 'GS_main': entrypoint not found

I've used similar code to compile my vertex and pixel shaders before and it works great for them. Is there something I'm missing that should be added for geometry shaders?

ID3DBlob* GSblob;
ID3DBlob* errorBlob;

HRESULT hr = D3DCompile(&shaderSrc[0], shaderSrc.length(), m_path.toString().c_str(), NULL, NULL, "GS_main", "gs_5_0", D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_SKIP_OPTIMIZATION | D3DCOMPILE_DEBUG, NULL, &GSblob, &errorBlob);
if ( FAILED(hr) )
{
std::string error = std::string((char*)errorBlob->GetBufferPointer());

errorBlob->Release();

return;
}


##### Share on other sites

Are you able to compile the shader with FXC offline?

##### Share on other sites

That isn't the exact code that is giving the error, is it? There is an unnamed variable at line 3 (float4x4 ;), the definition for Light is missing and the Pos member of output isn't set in the shader.

Apart from those 3 errors it compiles fine for me (with the exact same D3DCompile parameters).

##### Share on other sites

You were right. It was those errors. Sorry for the dumb question, I guess I worked too late and got too tired to catch the error.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11