Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Dwiel

Size of my Vertex Buffer

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

I have read from multipule rescources that say it is a good idea to have somewhere between 500 and 20,000 verticies in each vertex buffer. And so I decied to fill one VB every frame for my environent. (buildings, etc - should deffinately be within the 500-20,000 range) Now I know that it is unthinkable to create new Vertex Buffers every frame, which makes sense, but how should I determine the size of the vertex buffer before I know how many Verticies it will need to put in it? The only thing I thought of was to make sure that most of the time, all of my verts will fit in this one VB. This means the VB will often times be larger than I need it to be. Now I''m concerned about sending a VB that''s half empty. It seems VERY un-efficient to me to send 100s of vertices that are 0s and will not be drawn. Will they be sent and proccessed eating precious CPU an GPU time? I guess, one way to consisely(sp?) put my question is: If I only plan on drawing 1000s verts, but have them in a 20000 vert vB, will it be much slower than if they were in a Buffer than was exactly 1000s verts long? I''m trying to decied how to implement the basics of an rts i''m working on. Thanx for the help!!! tazzel3d ~ dwiel

Share this post


Link to post
Share on other sites
Advertisement
Hey again, Tazzel.

I don''t think it will be slower, so long as you are locking only the portion of the VB that you need, and using the appropriate parameters to DrawIndexedPrimitive() and SetIndices().

If you''re using a dynamic VB, having a VB that''s larger than it needs to be is a good thing when it comes to speed, because it means that you can use the D3DLOCK_NOOVERWRITE lock flag to your advantage.

If you are going to be locking/repopulating your VB often, it''s best to lock only the portion of the VB that you will use (using the NOOVERWRITE flag). Each successive Lock() call in this fashion will place its vertices after those of the previous frame (instead of flushing the entire buffer, which is expensive).

Lock with successive NOOVERWRITE calls until you have no more available space in your VB. At this point, you lock using the D3DLOCK_DISCARD flag to flush the contents of the VB and start over again.

A great resource for how to do this is on the NVidia developer''s website: developer.nvidia.com. Search for everything they have on dynamic vertex buffers. They have whitepapers as well as sample source code to help you.

--Neil.

----------------------
Check out my game demo and resume at
www.fivestory.com/projects/game.

Share this post


Link to post
Share on other sites
Hey, HoozitWhatzit, Thanx again!

What you are saying definately akes sence, I''m just now starting to understand some of the more complex issues behind vertex buffers and stuff... which is really interesting, fun, and a sometimes a bit confusing. Thanx for all of the help.

BTW, I just starte looking at the developer section of the nvidia website and found some really good articles there like you said!

Thanx again

Tazzel3d ~ Dwiel

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!