vertex shader useless when using geometry shader?

Started by
5 comments, last by Jason Z 8 years, 1 month ago

if I have a technique that uses the geometry shader, is there any reason to use the vertex shader to do something( except for passing input assembler data to the geometry shader )?

Is it faster to do the heavy part of an algorithm in the vertex shader and use the geometry shader only to generate the extra mesh?

Advertisement
It depends, but in general I would say the more computation you can offload to the vertex shader the better. For example, if you're just transforming vertices, depending on your primitive topology, the geometry shader may end up doing more operations. But as always in optimisation, benchmarking is key...

Consider that the GPU can usually cache the output of the vertex shader, but not the geometry shader. This is because very little can be assumed about GS output in advance.

Niko Suni

Exactly, there's a position/parameter cache, however its "key" is the vertex index. If you use index-buffers, the same vertex won't be shaded twice, if shaded recently, and you save a bit.

If you don't use indices, then, I think, it doesn't matter where you put your computation - VS or GS.

If you don't use indices, then, I think, it doesn't matter where you put your computation - VS or GS.

Depends on the primitive type. Non-indexed triangle strips still have vertex re-use smile.png

It all depends on how your geometry shader is setup. As mentioned before, there can be no assumptions made as to the output of the geometry shader, but a vertex shader will alway output a single vertex ( varying outputs are implied ). Doing less work is always a plus, so if there is computation that can be offloaded to the vertex shader ( in the event that the geometry shader is moderately complex ), then why not do it. Also, since you cannot bypass the vertex shader, might as well just have it do some useful work if that possible.

Why not run an experiment and see which one is faster? I am sure there are situations where each option will be faster, and lots of situations where it is a wash. If you try it out in your own engine both ways, then you can get a feel for how much of a difference it really makes, and learn more about how to profile how effective your changes are.

Then you can tell people what you found, and back it up with hard numbers :)

This topic is closed to new replies.

Advertisement