Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  
3DModelerMan

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.

If you intended to correct an error in the post then please contact us.

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"
"	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;
	}

Share this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!