Jump to content
  • Advertisement
Sign in to follow this  
Tarandus

Performance of Instancing static meshes and Concatenation of Vertex Buffers

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

UPDATE: Woops, I missed ID3D11DeviceContext::DrawIndexed which happens to be a better solution than Method 1 so I kind of found my answer. I can use this to render all the different static models as part of the same vertex buffer. It is also best to ignore any precomputation of world positions at this stage as this is premature optimisation (and also has a significant memory overhead). My new question was then: When should you concatenate vertex buffers and use DrawIndexed as opposed to calling Draw from seperate vertex buffers? I more or less found what I was looking for with the link below as it shows an example of why you need to call DrawIndexed: 

http://gamedev.stackexchange.com/questions/58817/direct3d-reducing-drawindexed-cpu-usage 

 

I hope this helps anyone else with a similar question :)

______________________________________________________________________________________________________________________________________

 

This post is regarding rendering static meshes, i.e. Meshes which have a fixed position in the world and therefore a constant world matrix, and the pros and cons in performance for drawing many of them at one time. I am currently planning an implementation of this for real time rendering in DirectX 11.

 

Method 1. Given that static meshes do not move, their vertex positions in the world space only ever have to be computed once and so can be precomputed on the CPU. This would produce a set of individual vertex buffers for each time a given mesh needs to be rendered in a given world location. The benefit of this is that for n objects, we carry out n less matrix multiplications per frame. Furthermore, we can concatenate the vertex buffers for all n meshes into a single vertex buffer and pass them in a single draw call because they are independent of a World matrix and they all share the same View matrix and Projection matrix.

 

Would this mean that they would all have to share the same texture? I suppose I can use a Texture Array and store the Texture Index in each vertex? I am of course making the assumption that all meshes use the same format of Vertices. In the case that I am rendering a set of static meshes which don't share the same model, I can't instance them because the model vertices are different. The only solution in this case, that I can think of, is to draw them all separately to give greater flexibility or use the method I stated above where I concatenate the vertex buffers.

 

Method 2. I have many static meshes that share the same vertex data and do not move. I can make them all share the same vertex buffer and render them each using instancing but this means I cannot precompute their position and must pass in an individual world matrix for each instance of the mesh. Therefore we are doing n more matrix multiplications per frame than Method 1.

 

I know instancing is the very obvious solution if we had the same situation with meshes which have a non-constant world matrix but I was wondering if Method 1 or some variation of Method 1 might be better in this situation?

 

I guess my overall aim is to find out the general best practices when it comes to ordering the drawing the scene in terms of static data and dynamic data. And whether the benefits of this outweigh the benefits of any other methods that I am not aware of.

Edited by Tarandus

Share this post


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