Jump to content
  • Advertisement
Sign in to follow this  
BenS1

Dummy Verticies

This topic is 2609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks all, and especially thanks for the link to the article.

I'm pleasantly surprised this is possible!

Thanks
Ben

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Don't use a geometry shader unless you have to, you'll just waste performance for nothing.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!