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?