Sign in to follow this  
TheAsterite

How to handle vertex/index buffers?

Recommended Posts

How should vertex/index buffers be created? Is it done per mesh, or grouped together? I was reading the msdn d3d optimization page, and it said to minimize buffer switching, so how are these buffers handled normally?

Share this post


Link to post
Share on other sites
Simple apps can take it easy and have a buffer change every time it's needed.
Everything more involved requires to put several meshes in the same buffer. Ideally you would have a single static buffer and a pool of dynamic buffers. In the end everyone optimizes the management as much as he/she needs.
I suggest to consider those as [i]guidelines [/i]rather than [i]must do[/i].

EDIT - to answer your question: I currently try to "merge" meshes coming "in the same request list", most of the time, this is a level load. All other meshes will be stored independently. The performance benefit of more extensive pooling was not worth the effort for me, your mileage might vary; expect other people to have different experiences about that.

Share this post


Link to post
Share on other sites
I think there is no "normal way" to handle them. When using rigid/static objects i try to minimize the amount of buffers. If the objects are subject to lots of changes, such as heavy deformation or often changing attributes splitting up the buffers can help to organize your stuff. I sometimes even split up topology data and other attributes in different buffers, for instance if i have a rigid object with (often) changing material properties.

Another point if find worth mentioning is, that IMO putting objects into different buffers can make debugging easier.

Share this post


Link to post
Share on other sites
[quote name='Krohm' timestamp='1318575287' post='4872427']
Simple apps can take it easy and have a buffer change every time it's needed.
Everything more involved requires to put several meshes in the same buffer. Ideally you would have a single static buffer and a pool of dynamic buffers. In the end everyone optimizes the management as much as he/she needs.
I suggest to consider those as [i]guidelines [/i]rather than [i]must do[/i].

EDIT - to answer your question: I currently try to "merge" meshes coming "in the same request list", most of the time, this is a level load. All other meshes will be stored independently. The performance benefit of more extensive pooling was not worth the effort for me, your mileage might vary; expect other people to have different experiences about that.
[/quote]

Ok, if I make a buffer with a lot of static objects, will they have to be rendered with the same material?

Share this post


Link to post
Share on other sites
Switching vertex buffers does not have the large cost that it used to. In general I'd say it's more important to reduce your draw calls (which [i]can[/i] be done by merging meshes into a single vertex buffer, or through other means), as well as reducing setting constants/constant buffer contents.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this