Dummy Verticies

Started by
11 comments, last by Jason Z 12 years, 5 months ago
I have an interesting situation where my vertex shader can create or read all of the information it needs from buffers already on the GPU (Using the SV_VertexID as an index) and therefore I don't need to pass any actual vertex information into the shader.

Am I right in assuming that its not possible to trigger the Vertex Shader to execute X number of times with only the SV_VertexID as an input? And therefore I'll have to waste some bandwidth\space by passing in dummy data.

Thanks
Ben
Advertisement

I have an interesting situation where my vertex shader can create or read all of the information it needs from buffers already on the GPU (Using the SV_VertexID as an index) and therefore I don't need to pass any actual vertex information into the shader.

Am I right in assuming that its not possible to trigger the Vertex Shader to execute X number of times with only the SV_VertexID as an input? And therefore I'll have to waste some bandwidth\space by passing in dummy data.

Thanks
Ben


I'm not sure, whether you can render without feeding any geometry into the input assembler. I didn't tried that so far. (I always used dummy vertices.)
If you have many vertices to render you could probably gain some performance if you're rendering a single vertex and use instancing to duplicate it. Then, you could just use the SV_InstanceID to read from your buffers. (However, you'll need a geometry shader to get access to the aforementioned system value semantic.)

Greetings
It is possible. You may call Draw / DrawIndexed without vertex buffer attached and use VertexId to create meaningful output.

I, for example, use that method to generate terrain grids on vertex shader and read the height with vertex texture fetch. No need to pass geometry at all in vertex buffer. However, I didn't test if it is actually any slower to have a vertex buffer with the same data.

However, some docs say that there may be overhead if using too much VertexID / integer calculations.

Cheers!
You could look into shader techniques and passes, that might be helpful, since you control which shaders to use and are able to do multiple passes. I haven't really tried to work with multiple passes, but i did look into it a while ago and it seems to be a little more difficult than one would think. Just thought i'd through the idea out there though
Am I right in assuming that its not possible to trigger the Vertex Shader to execute X number of times with only the SV_VertexID as an input? And therefore I'll have to waste some bandwidth\space by passing in dummy data.
Nope, it is indeed possible to write a vertex shader that reads from zero streams and only relies on SV_VertexID. I've not used it myself, but apparently this technique is used by NVidia's FXAA shader.
Thanks all, and especially thanks for the link to the article.

I'm pleasantly surprised this is possible!

Thanks
Ben
Yes, it's perfectly possible. I'm currently rendering quads by passing null as the vertex buffer and just using index buffers.
I am also using it to render particles from an Append/Consume buffer setup. If you would like to take a look at the code, you can see it in the Particle Storm demo here.
Thanks Jason

Is that one of the samples from your book?
I'm currently on around page 225 (The Pixel Shader section) and loving it (Its the best DX book I've ever read and I've got a lot)..

Ok, so here's what I'm doing... I have a displacement map from which I will create my terrain. Obviously the displacement map is used to define the height of each vertex, and the X and Z positions can easily be calculated in the shader and therefore do not need to be passed in via a Vertex Buffer. However, I can see 2 ways of doing this:
1. Create the positions in the Vertex Shader (The Vertex Shader input would just be SV_VertexID's)
2. Create the verticies in the Geometry shader (Will I need to feed in a single vertex in order to trigger the Geometry shader?)

So the main question is, which is faster? My feeling would be that the Vertex Shader is probably faster, but I'm not sure.

Thanks
Ben
Don't use a geometry shader unless you have to, you'll just waste performance for nothing.

This topic is closed to new replies.

Advertisement