Jump to content
  • Advertisement


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


Partitioning Vertex Buffers

This topic is 5322 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 want cre create a vertex buffer that can be easily partitioned and have a representitive class to represent the patitioned space. When it is first partitioned out, there is no problem (simply keep track of the upper bound of used areas). The problem is that i want partitioned areas to be able to "release" what they used for future use and the more it is released and created the more fragmented it becomes. Is there a simple way to keep fragmentation to a minimum?

Share this post

Link to post
Share on other sites
Fragmentation shouldn''t be an issue if you follow the advice nVidia gives for vertex buffers.

In dynamic buffers you just append to the end, until you''re about to overflow. You then discard and begin at the start of the buffer again.

In static buffers, you''re only supposed to Lock once, ever. I used to interpret this as a warning about Locking each frame being bad. Now, however, DX emits warnings about Locking a buffer a second time (again saying it may affect performance). According to a paper I saw, it claimed that some drivers may actually convert your VB to dynamic if you lock a second time. Now, that last part was a shock, and something everyone probably wants to avoid.

So, in essence, static buffers have the following suggested usage: Accumulate data, Create, Lock, Copy, UnLock... On modify, Destroy buffer, accumulate data, Create, Lock, Copy, UnLock... ie: Never a second lock on the buffer.

Now you need your code to be able to find all the source data to copy into new buffers when a new buffer is needed. You want to batch these copies as much as you can to reduce the number of times you do a destroy/create cycle. And finally, you need to be able to modify your structure that says which VB and offset to use for your objects.

Using this pattern can''t fragment, and is apparently the "official" usage pattern. Sure, it''s more of a pain, and will require reorganizing some code, but what''s the point of code that''s incorrect? It''ll just cause you trouble down the line, and more code will rely on the bad code causing the change required later to be massive.

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!