Jump to content
  • Advertisement
Sign in to follow this  
ahmedsalah

dynamic size for vertex buffer

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

Hi there, Is there a way to make the size of the vertex buffer dynamic(i don't want to have to predefine it's size but to add vertices whenever i want) like in a dynamic list. Thanx

Share this post


Link to post
Share on other sites
Advertisement
No, you must set it's size, but you don't have to use all of it at once.

I used to create large objects in their own buffers, but for smallers objects, I'd create a larger VB and append multiple smaller meshes onto those buffers automatically as they were loaded.

Then I saw the D3D10 spec, which implied the best performance would come from static buffers which can only be set during initialization at create time. You can't append to a buffer like that. A few other considerations finally made up my mind... Each mesh has it's own VB, just for simplicity, and customizability. I'm not sure what performance tradeoff their is between multiple VBs vs. type of D3D10 buffer, but I'm sure the performance effects are pretty minor. The simplicity gained, made it worthwhile to switch methods for me.

I'm not actually using D3D10 yet, just 9, and looking forward to help plan my architecture to avoid too many rewrites later.

Share this post


Link to post
Share on other sites
Yeah it is usually better, in my mind, to use 2-4 MB shared vertex, and index, buffers. But mind you, that is when I am using OpenGL. I don't know about D3D9/10 but I imagine it would be the same.

Share this post


Link to post
Share on other sites
That's a good idea a vertex buffer for each mesh but in my application there is a great number of meshes and each of them is just a few vertices (mostly primitives).
Do you think the performance effects will still be minor?

Share this post


Link to post
Share on other sites
IIRC switching vertex buffers isn't cheap. If i were you i would collate geometry of the same format into large buffers, you can keep the indices the same and specify an offset when using DPIP().

Share this post


Link to post
Share on other sites
Is there a good article on vertex buffer management, in general? It's a problem every comes across as soon as they drop the immediate-mode abstraction.

A random quote:


Quote:
Is it better to use one vertex buffer, or many?
Forum FAQ - GameDev.Net Discussion Forums
In general, you should minimize the number of vertex buffers you use. The cost of switching vertex buffers is fairly high. While it's not as bad as it used to be in DirectX 7, it should still be avoided if possible. Try to group everything static using the same FVF into a single vertex buffer if you can fit it. That is, put everything of your terrain into a single buffer, all models into another, particles into a third, etc. You are not limited to having a single "object" per vertex buffer.

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!