Compiling geometry shader with D3DCompile

Started by
2 comments, last by 3DModelerMan 10 years ago

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"
"	float g_fParticleRadius = 5.0;\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"
"		float3 position = (g_positions[i]*g_fParticleRadius)+input[0].Pos;\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());
		core::Debug::log(core::ELL_ERROR, "geometry shader", error);

		errorBlob->Release();

		return;
	}
Advertisement

Are you able to compile the shader with FXC offline?

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).

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.

This topic is closed to new replies.

Advertisement