• Advertisement
Sign in to follow this  

Dynamic vertex buffers

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

Sorry if this is a dumb question but I was reading last night that a dynamic vertex buffer is one who's contents can be discarded when you lock it and is thus faster to lock. This looks like what I need since I am regenerating all the vertex information each frame (for 2D sprite quads). Is this what you get when you specify the WRITE_ONLY flag to CreateVertexBuffer or is it more complicated? Ta.

Share this post


Link to post
Share on other sites
Advertisement
For a dynamic vertex buffer you have to use D3DUSAGE_DYNAMIC. But for optimal performance you should add D3DUSAGE_WRITEONLY too.

Share this post


Link to post
Share on other sites
Dynamic vertex buffers are the only buffers that support the D3DLOCK_DISCARD flag. This flag tells the driver to throw away all the contents of the old buffer, and give you a new one. As such, it's relatively quick compared to some of the other lock types.

Specifying WRITE_ONLY tells the driver you'll only be writing to the buffer, and never reading from it.

[EDIT] bleh, 7 minutes... you even managed to say thanks before I even posted :(.

Share this post


Link to post
Share on other sites
Well, thanks anyway [smile].

So to clarify, I just pass D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY to CreateVertexBuffer8, then I have an optimal buffer for regenerating all the vertex information each frame?

(PS: Using 8 because I am Borland-Boy and I can't get proper library conversions for 9 by the way.)

Share this post


Link to post
Share on other sites
Additional a dynamic vertex buffer needs to create in the default pool.

Share this post


Link to post
Share on other sites
Quote:
Original post by EasilyConfused
Well, thanks anyway [smile].

So to clarify, I just pass D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY to CreateVertexBuffer8, then I have an optimal buffer for regenerating all the vertex information each frame?

You also need the D3DLOCK_DISCARD when locking.

Quote:
(PS: Using 8 because I am Borland-Boy and I can't get proper library conversions for 9 by the way.)

Why oh why? :)

Share this post


Link to post
Share on other sites
Quote:
Original post by ET3D
You also need the D3DLOCK_DISCARD when locking.

Quote:
(PS: Using 8 because I am Borland-Boy and I can't get proper library conversions for 9 by the way.)

Why oh why? :)


D3DLOCK_DISCARD - gotcha, cheers.

And in answer to your other very valid question, I only have 98SE at home and unfortunatley Microsoft have altered all their free compilers so they need 2000 or later to install.

Please believe me - I would like nothing more than to be using Visual C++. I've got a 500mhz P3 so probably would run 2000 or XP okayish but I only have a 5 gig hard drive at the moment.

I promise to buy a new hard drive soon and upgrade my OS so you all stop laughing at me but bl**dy fridge freezer broke down last night and just had to fork out £200 for a new one so not this month.

Wandering off topic a bit. [smile]

Share this post


Link to post
Share on other sites
Quote:
Original post by Demirug
Additional a dynamic vertex buffer needs to create in the default pool.


Is that with D3DPOOL_MANAGED?

Share this post


Link to post
Share on other sites
Quote:
Original post by EasilyConfused
Quote:
Original post by Demirug
Additional a dynamic vertex buffer needs to create in the default pool.


Is that with D3DPOOL_MANAGED?
the default pool is D3DPOOL_DEFAULT [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Right, so D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY and D3DPOOL_DEFAULT to CreateVertexBuffer, then D3DLOCK_DISCARD to Lock.

I'm hoping to use an index buffer as well. Does this have to be created like above as well to be compatible? I'm planning to fill the index buffer once at the start of the program rather than regenerate it each frame.

Share this post


Link to post
Share on other sites
You can mix a dynamic vertex buffer with a static index buffer. Thus, create the index buffer in DEFAULT pool with no particular usage. Lock it once and put the data in, unlock, and be happy.

Share this post


Link to post
Share on other sites
Quote:
Original post by hplus0603
You can mix a dynamic vertex buffer with a static index buffer. Thus, create the index buffer in DEFAULT pool with no particular usage. Lock it once and put the data in, unlock, and be happy.

Managed pool would be better. Always preferable unless you're forced to use the default pool.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement