Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


DrawIndexed vs DrawIndexedInstanced


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 axefrog   Members   -  Reputation: 898

Like
0Likes
Like

Posted 08 March 2014 - 02:31 AM

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, 08 March 2014 - 02:32 AM.

I'm blogging about my journey to learn 3D graphics and game programming: http://nathanridley.com
I'm also building my own code-first game engine using C#: https://github.com/axefrog/Grasshopper. It's open sourced under a BSD 3-clause license and includes lots of samples that demonstrate how to use the engine.

Sponsor:

#2 kauna   Crossbones+   -  Reputation: 2894

Like
2Likes
Like

Posted 08 March 2014 - 08:48 AM

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, 08 March 2014 - 11:35 AM.


#3 axefrog   Members   -  Reputation: 898

Like
0Likes
Like

Posted 08 March 2014 - 10:17 AM

Thanks kauna, that was very helpful!


I'm blogging about my journey to learn 3D graphics and game programming: http://nathanridley.com
I'm also building my own code-first game engine using C#: https://github.com/axefrog/Grasshopper. It's open sourced under a BSD 3-clause license and includes lots of samples that demonstrate how to use the engine.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS