Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

Dynamic VertexBuffer use question

This topic is 4795 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 on MSDN that using a dynamic vertex buffer is the fastest if you have to manipulate it during game time. When you lock it you use D3DLOCK_DISCARD to gain even more performance. Now my use is each frame the buffer is going to filled with the triangles the quad tree doesn't cull, then rendered. Obviously sometimes it will contain more triangles or less triangles than usual. Are there any perforamnce issue's by rendering only a part of a vertex buffer? Also, my max vertex buffer size is 65535 for me. That means I have to create a method of generating multiple buffers when necessary right? Does that max size mean max elements in the buffer array? Or max size in total for each element and its members?

Share this post


Link to post
Share on other sites
Advertisement
It's the maximum number of vertices, not the maximum data size. The reason is the 16 bit vs. 32 bit index support.

You shouldn't need to fill more the 65536 vertices in your dynamic buffer. Typically you'll get a couple thousand, then draw, discard, and collect more vertices to draw while the first batch is being drawn, etc. Trying to fill a large buffer may let the GPU catch up and sit idle instead of rendering.

There should be no hit for drawing a partial buffer. Typically you'll make the buffer large enough to handle a few draw batches, it's more efficient to NOOVERWRITE than to DISCARD. If you typically have, say 2000 vertices to draw at once, you'd make, say, an 8000 vertex buffer. You'd DISCARD, fill 2000, NOOVERWRITE, append 2000 more, NOOVERWRITE, append 2000 more, NOOVERWRITE, another 2000, DISCARD, your next 2000. The exception to this is if you're rendering only a few items per frame, as you should discard after a present (according to the docs, though I've noticed no ill effects doing NOOVERWRITE).

Now, your numbers aren't going to work out as nicely as 2000 vertex blocks in an 8000 vertex buffer. Just keep appending with NOOVERWRITE while you can. Once you reach a block that's too large to append in the remaining space, you discard and begin at offset 0 again.

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.

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!