Sign in to follow this  
Vertex333

Vertex shader or geometry shader. (performance considerations)

Recommended Posts

What would be the better way to create triangles [u]entirely[/u] on the gpu. Using an empty vertexbuffer and create a vertex for every entry with vertex shader. Or adding some triangles to each vertex in the geometry shader. Let's assume that the information for the geometry shader is as less as possible. Index buffering shouldn't be considered. Two situations (both trianglestrip) are interesting: Either a simple object like a rectangle (so, from 2 points create 2 triangles), or a more complex, triangle fan with may points and the one middlepoint that is reused. What would be better/faster? Another question: Is the geometry shader slower than the vertex shader? Thx, Vertex

Share this post


Link to post
Share on other sites
The performance side is a difficult quantity to guage as it changes with each vendor and each generation of hardware. Even with the unified hardware models the general consensus and advice in early generation hardware (e.g. GeForce 8x00's) was to avoid heavy GS work as it really wasn't very fast.

As with all D3D related performance enquiries the only real answer comes from testing equivalent/alternative solutions. You can't determine it purely from the design document.

Conceptually you need to consider your algorithm and its match for the two shader units. The vertex shader is designed for transforming a single vertex and to do it very quickly, whereas the geometry shader is intended to be informational at the topological level - thinking of the GS as a tesselation unit is not a good idea regardless of its limited abilities in this space.

You need to be very careful when it comes to distorting the intention of your progam to suit the implementation details. It's much like trying to use a screwdriver to put nails in the wall - sure, you can do it but for that particular problem you're better off using a hammer instead [smile]

Also, its quite clear from your description that the source data format needs to change accordingly. The 1-in-1-out VS design places a higher load on memory bandwidth and storage requirements versus the 0..1-to-many of the GS. What impact does this have? Are you bandwidth or storage limited? Is raw performance more important than these? etc..etc..


hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
The performance side is a difficult quantity to guage as it changes with each vendor and each generation of hardware. Even with the unified hardware models the general consensus and advice in early generation hardware (e.g. GeForce 8x00's) was to avoid heavy GS work as it really wasn't very fast.

As with all D3D related performance enquiries the only real answer comes from testing equivalent/alternative solutions. You can't determine it purely from the design document.

Conceptually you need to consider your algorithm and its match for the two shader units. The vertex shader is designed for transforming a single vertex and to do it very quickly, whereas the geometry shader is intended to be informational at the topological level - thinking of the GS as a tesselation unit is not a good idea regardless of its limited abilities in this space.

You need to be very careful when it comes to distorting the intention of your progam to suit the implementation details. It's much like trying to use a screwdriver to put nails in the wall - sure, you can do it but for that particular problem you're better off using a hammer instead [smile]

Also, its quite clear from your description that the source data format needs to change accordingly. The 1-in-1-out VS design places a higher load on memory bandwidth and storage requirements versus the 0..1-to-many of the GS. What impact does this have? Are you bandwidth or storage limited? Is raw performance more important than these? etc..etc..


hth
Jack
Thx!
I thought of something like use the VS if possible ;) or the other way around if you do not create more than two triangles or so... but... I know that I would have to test it anyway.

I am trying to offload vertex data generation to the gpu (it's a very simple vertex data generation). I try to avoid large resource updates/bandwidth. So, storage wouldn't be a problem, but I don't know what to store.

mhm... complex stuff :(

edit: I actually found out that I wouldn't need to create a vertex buffer anyway (working with vertex ID), so vertex buffer would be the better solution anyway, or not?)

Thx,
Vertex

[Edited by - Vertex333 on October 22, 2008 7:42:17 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