Advertisement Jump to content
Sign in to follow this  
NathanRidley

DrawIndexed vs DrawIndexedInstanced

This topic is 1775 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

Just a quick one. It seems to be me that when creating a basic 3D engine, unless you're creating something that you know for a fact ahead of time that is only ever going to exist in one place in your scene (e.g. the ground terrain mesh), then it simplifies things if the default class for rendering meshes always assumes that multiple instances might exist, and therefore caters for that in terms of making an instance buffer available, and the shaders taking instancing information.

 

So I guess what I'm asking is, is it normal to set things up so you're using DrawIndexInstanced for most scene items, and DrawIndexed for the few other remaining things, or is it more normal to simply render each instance individually with DrawIndexed and leave DrawIndexInstanced for things like particles?

Edited by axefrog

Share this post


Link to post
Share on other sites
Advertisement

In my experience, it is easier to implement just one of the above for mesh rendering for example. It is rather small as an optimization to handle single mesh drawing as efficiently as possible versus drawing many meshes optimally, so in my opinion it isn't worth the extra code paths or extra shader code. 

 

I had both code paths originally, but eventually I dropped support for single drawing calls as that functionality exists still with the instanced draw calls.

 

Of course there are cases which are much simpler to handle with single draw calls or cases where instancing is less usefull (such as full screen quads). Also, particles can be drawn with geometry shader so instancing may not be the best approach (geometry shader is used to create the quads on screen from a singular vertex position). 

 

Terrain is another beast then, if you had one unique modelled mesh for a terrain, then instancing may sound unnecessary, but again, if it is a mesh, then your mesh class should have only one code path for drawing 1 or many meshes, so the first answer stands here too. On the other hand, if you are using something like a quadtree terrain LOD, then instancing can be used with drawing different terrain chunks.

 

Cheers!

Edited by kauna

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!