Sign in to follow this  
clarkm2

[DX10] Geometry Shader with no Input

Recommended Posts

clarkm2    124
I'm updating my GUI rendering algorithm by using the geometry shader (GS) and no longer supporting vertex coloring. The scale and position for each sprite is defined in the model matrix, so I no longer require a vertex buffer for this simple case. My first attempt was to make an empty vertex shader and set the input PrimitiveType argument to NULL in the GS as so
void VS(){}

[maxvertexcount(8)]	
void GS(NULL, inout TriangleStream<PS_INPUT> outStream ) { ... }

Of course I got a compile error with the "NULL" argument, so I fixed the problem with a dummy structure and passed it into the GS as so
struct GS_INPUT
{
   float3 Rsvd	: POSITION;
};


GS_INPUT VS()
{	
	GS_INPUT results  = (GS_INPUT)0;
	return results;		
}


[maxvertexcount(8)]
void GS(point GS_INPUT Data[1], inout TriangleStream<PS_INPUT> outStream ){ ... }

Now this worked, but I'm wondering if there is another solution. Thanks

Share this post


Link to post
Share on other sites
ET3D    810
Your post suggests that you're rendering one UI element at a time. I'd say that reworking your code to render more than one at once would give you something to do with that vertex buffer and give you better performing code.

Share this post


Link to post
Share on other sites
DieterVW    724
Performance should be much better if you can draw instance the sprites, and possibly transform a single point per sprite in the vertex shader and then use the geometry shader to expand that to a quad sprite just using offsets from the incoming point. This way you are limiting the expensive transform to just once per sprite, plus you are leverage parallelism of the vertex shader and geometry shader by drawing many elements at the same time - there by greatly improving performance. If your sprites are all screen facing, then they won't need a transform, just a 2D point for the top left corner, and then a height and width. In this case the vs can bee a simple pass through using the SV_InstanceID if you need more resources later on in the pipeline.

Also, reducing your maxvertex value to 4 should provide much better performance since the stream out cache is not very big per vertex.

[Edited by - DieterVW on May 1, 2010 11:53:32 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this