   [DirectX10] How fast are geometry shaders?
  I would like to add post processing to my engine, and in my first try I created a vertexbuffer, which holds my quad. Then I transformed them in the vertex shader (via some scale variables) to the size I needed the image. But now, I've seen that nvidia does all this in the geometry shader! And I think this technique is a lot cleaner because you can put everything into your shader. But whats about the speed? Well, I need only 4 vertices but maybe are geometry shaders damn slow? I really don't know this. I never used them before...   
  For only 4 vertices per batch you can safely ignore the performance characteristics of the geometry shader - just use it. As you already guessed it: it's not invoked often enough to make any difference.   ;  Then it's ok. :) Thank you!   ;  I am intested in screen quad using geometry shader. What's the nvidia sample name?Thank you!   ;  The technique of drawing a fullscreen quad using a geometry shader is really simple: Define and bind a dummy vertex shader that doesn't need to have any input parameters; from it, return a dummy structure that has a field with the position semantic. You don't have to assign meaningful values to the returned structure.Define and bind a geometry shader that simply outputs two triangles (note that one larger triangle can also be used) that cover the render target ([-1,-1] to [1,1]). Also output texture coordinates for the pixel shader.Define and bind a pixel shader that processes the pixels of the quad. This is exactly the same as in legacy implementations where geometry shader is not used.Unbind your stream sources. You don't need vertex sources, since the geometry shader generates all the data. Effectively, the combination of this step and the parameterless vertex shader disables the input assembler (although the driver may not need to take any special steps for this).Draw one point using DrawPrimitive.If you need to make point sprites instead of full-screen quads, just load the point data via the vertex shader and then expand each of the incoming vertices to two triangles in the geometry shader.I have noticed that PIX will crash with an access violation if you debug a draw call in which 0 stream sources have been set. It probably incorrectly assumes that at least one stream source is necessary for drawing stuff, whereas in reality it is not.[Edited by - Nik02 on May 11, 2010 5:46:07 AM];  Directx10 doesnt have a DrawPrimitive call, thats Directx9.Do you mean ID3D10Device::Draw(1,0) ?SDK Entry : Using the Input-Assembler Stage without Buffers (Direct3D 10)   ;Quote: I am intested in screen quad using geometry shader. What's the nvidia sample name?Thank you!It is in the nVidia SDK 10. (http://developer.nvidia.com/object/sdk_home.html)See the Volumetric Light example. I found out, that it is a very nice and clean way to draw a quad! The C++ code for drawing the quad is just about 10 lines long! :)   ;  For full screen geometry you really don't need a quad, you can do it with an over sized triangle that covers the screen.  Texture coordinates are easy since the SV_Position value in the pixel shader holds the screen space xy pixel coordinate.  Anyway, this reduces the number of primitives drawn and reduces the number of vertices emitted from the geometry shader.   ;Quote:Original post by maya18222Directx10 doesnt have a DrawPrimitive call, thats Directx9.Do you mean ID3D10Device::Draw(1,0) ?SDK Entry : Using the Input-Assembler Stage without Buffers (Direct3D 10)Yeah, I meant Draw - I've been maintaining some D3D9 code lately and DrawPrimitive was just hot on my cache :)For full screen use a single triangle with root dimensions of 4*4 (as opposed to a 2*2 quad) is indeed optimal, but for a more generic quad filling (as in point sprites and other arbitrary rectangles), two triangles is more convenient and likely gives better performance as you don't have to mess with viewport clipping.   