Jump to content
  • Advertisement
Sign in to follow this  
Andrea Tucci

DX11 Create Geometry Shader with Stream Output

This topic is 1385 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

Hello everyone,

 

I'm trying to create a geometry shader from the stream out, in order to build a GPU particle system. For the particle system, I have the Frank Luna book as reference, but I'm not using effect files. The relevant code is this:

struct Particle{
		D3DXVECTOR3 speed;
		D3DXVECTOR3 position;
		D3DXVECTOR2 size;
		float	age;
		int	type;
	};
bool result = D3DX11CompileFromFile(gsFilename, NULL, NULL, "main" , "gs_5_0", D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_PACK_MATRIX_ROW_MAJOR, 0, NULL, &geometryShaderBuffer, &errorMessage, NULL);
	/*error checking*/

	//define the system output declaration entry, i.e. what will be written in the SO
	D3D11_SO_DECLARATION_ENTRY pDecl[] = 
	{
		//position, semantic name, semantic index, start component, component count, output slot
		{0,"TEXCOORD", 0, 0, 3, 0 }, // output first 3 components of SPEED
		{0, "POSITION", 0, 0, 3, 0 }, // output first 3 components of "POSITION"
		{0, "TEXCOORD", 1, 0, 2, 0 }, // output first 2 components of SIZE
		{0, "TEXCOORD", 2, 0, 1, 0 }, // output AGE
		{0, "TEXCOORD", 3, 0, 1, 0 }, // output TYPE
				
	};

	UINT strides [] = {sizeof(Particle) };
	device->CreateGeometryShaderWithStreamOutput(geometryShaderBuffer->GetBufferPointer(),geometryShaderBuffer->GetBufferSize(),pDecl,sizeof(pDecl),strides,0,D3D11_SO_NO_RASTERIZED_STREAM,NULL,&geometryShader);

	

The geometry shader is compiling, but the "CreateGeometryShaderWithStreamOutput" call will give me a null geometryShader value. I have been changing the value inside it to make it work, but debugging with RenderDoc showed me that this geometry shader is not binded.

 

vertex shader

struct Particle
{
	float3		speed : TEXCOORD0;
	float3		position : POSITION;
	float2		size : TEXCOORD1;
	float		age : TEXCOORD2;
	int		type : TEXCOORD3;

};


Particle main (Particle vin){
	return vin;
}

geometry shader

#define PT_EMITTER 0
#define PARTICLE 1

cbuffer GameInfo
{
	float3 emitterPosition;
	float gameTime;
	float frameTime;
	float3 padding;
};


struct Particle
{
	float3		speed : TEXCOORD0;
	float3		position : POSITION;
	float2		size : TEXCOORD1;
	float		age : TEXCOORD2;
	int		type : TEXCOORD3;

};



Texture1D randomTexture;
SamplerState linearSampler;


/*UTILITY*/

[maxvertexcount(1)]

void main (point Particle input[1], inout PointStream<Particle> outStream){
	
	//compute stuff
	
}

Any suggestion?

Edited by andrea.tucci

Share this post


Link to post
Share on other sites
Advertisement

Did you create your device with the D3D11_CREATE_DEVICE_DEBUG flag enabled? If you do that, you'll get error messages in the debugger output telling you why API calls failed.

Share this post


Link to post
Share on other sites

 

The geometry shader is compiling, but the "CreateGeometryShaderWithStreamOutput" call will give me a null geometryShader value.

 

This is an indicator that your GS code is valid but the actual GS bytecode created by compilation won't run on your hardware (compilation doesn't do hardware validation, creation does).  I see that you're compiling with "gs_5_0" so the first thing you should check is that your hardware actually supports shader model 5.

Share this post


Link to post
Share on other sites

Thank you for your replies.

 

Did you create your device with the D3D11_CREATE_DEVICE_DEBUG flag enabled? If you do that, you'll get error messages in the debugger output telling you why API calls failed.

 

I create the device without that flag, I'll try to put it in and see if there will be error messages.

 

 

 

The geometry shader is compiling, but the "CreateGeometryShaderWithStreamOutput" call will give me a null geometryShader value.

 

This is an indicator that your GS code is valid but the actual GS bytecode created by compilation won't run on your hardware (compilation doesn't do hardware validation, creation does).  I see that you're compiling with "gs_5_0" so the first thing you should check is that your hardware actually supports shader model 5.

 

 

I'm running the program with a geforce gtx 860m, which fully supports shaders v. 5!

Share this post


Link to post
Share on other sites

Thank you for your replies.

 

Did you create your device with the D3D11_CREATE_DEVICE_DEBUG flag enabled? If you do that, you'll get error messages in the debugger output telling you why API calls failed.

 

I create the device without that flag, I'll try to put it in and see if there will be error messages.

 

 

 

The geometry shader is compiling, but the "CreateGeometryShaderWithStreamOutput" call will give me a null geometryShader value.

 

This is an indicator that your GS code is valid but the actual GS bytecode created by compilation won't run on your hardware (compilation doesn't do hardware validation, creation does).  I see that you're compiling with "gs_5_0" so the first thing you should check is that your hardware actually supports shader model 5.

 

 

I'm running the program with a geforce gtx 860m, which fully supports shaders v. 5!

Which feature level did you create your device with?  Even if your hardware is capable, you can easily request a lower feature level and cap yourself regarding shader level!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!