Advertisement Jump to content
Sign in to follow this  

DX10 DrawInstanced and DrawAuto compatibility?

This topic is 2587 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 a GPU based particle system that works thusly:
1. create buffer of points. These represent the center of particles, pass them through the vertex shader (which does almost nothing) and into the geometry shader.
2. Geometry shader takes these points and updates their lifetime, potentially killing them, emitting new particles, or a few other various effects. These are sent to the geometry shader stream output
3. Shader stream output is sent back through another pass with DrawAuto(). The next pass calculates position in the vertex shader, expands each point into a quad and then billboards towards camera, then goes to pixel shader where a few other effects can be applied (like soft particles, gradient fade, alpha fade, etc. there are some cool effects that I can do).

Now, I have many "instances" of various particle emitters, the most obvious of which is the plasma bullets that my spaceships shoot. Since each bullet only differs by its transform and velocity vector, I would like to be able to instance these things, thus only running through the shaders in steps 1 and 2 above one time, and then sending it through step 3 once per instance. Only thing is, DrawAuto() doesn't let me specify a number of instances, and so I have no idea how to bind a buffer that contains transforms or whatever else to that stream. Is this something that is even possible? Will DrawAuto instance things for me if I define the vertex format to be instanced and bind another buffer of instancing data prior to calling DrawAuto? Is this even a good idea? Also, I am aware that this will mean that the particle effect will look identical for each instance, but since these are bullets it means that there's a crap-ton of them and I really don't care if they all look identical since no one will ever notice and complain "wow, what a great game but the particle effects for each bullet that the plasma cannon fires all look to be of the same instance and it really looks crappy because every bullet that flies quickly and I can barely even see that damn thing looks identical and it was distracting so this game sucks" (or at least I hope not and if they do then I am a honey badger).

Anyone ever done this before? I'm pondering just writing a bunch of code and trying it, but I have better things to do if it is impossible so I'm hoping someone can just tell me either yes this will work (in which case I can figure it out) or no it's impossible, in which case I won't waste any time with it.

One last note: my code for this looks very similar to a crazy hybrid of the Microsoft DX10 particle sample code and the particle code in Frank Luna's DX10 book. Thanks

Share this post

Link to post
Share on other sites
I don't think DrawAuto supports any kind of instancing. You could instance by using the GS to output multiple quads per input particle, but too much amplification in the GS can lead to poor GPU performance. If you were using compute shaders + append buffers you'd have more options, but unfortunately that's only going to be available on DX11 GPU's.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!