Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

Possible to leave some vertices in vertexbuffer, while adding and removing others?

This topic is 4846 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, with a vertex buffer, I was wondering if it was possible to say write 30 vertices into the vb, then without having to re-add those 30 vertices, to add/remove 100 or so vertices constantly? thanks

Share this post


Link to post
Share on other sites
Advertisement
In addition, if you know you will never be modifying those 30 vertices while you tweak the rest, limit your range of locked vertices to only those you modify. This can be done by setting the offset and size parameters of the IDirect3DVertexBuffer9::Lock method.

Share this post


Link to post
Share on other sites
Quote:
Original post by Coder
As long as the vertex buffer isn't a dynamic buffer that you lock with DISCARD, it's possible.


My vertexbuffer is dynamic, but if i remove the discard flag, would that be ok then?

Quote:
Original post by skittleo
by setting the offset and size parameters of the IDirect3DVertexBuffer9::Lock method.


so for the offset I should say 'sizeof(Vertex)*30', and for the size parameter, should I just set it to the size of the 'new vertices' that are being added? eg 100 new vertices, so sizeof(Vertex)*100?

Thanks alot

Share this post


Link to post
Share on other sites
Quote:
Original post by johnnyBravo
My vertexbuffer is dynamic, but if i remove the discard flag, would that be ok then?


Yep. Even if you limit the data you modify with offset and size, Direct3D will still hand you a fresh set of memory to fill.

Quote:
Original post by johnnyBravo
so for the offset I should say 'sizeof(Vertex)*30', and for the size parameter, should I just set it to the size of the 'new vertices' that are being added? eg 100 new vertices, so sizeof(Vertex)*100?


You got it.

Share this post


Link to post
Share on other sites
Quote:
Original post by skittleo
Quote:
Original post by johnnyBravo
My vertexbuffer is dynamic, but if i remove the discard flag, would that be ok then?


Yep. Even if you limit the data you modify with offset and size, Direct3D will still hand you a fresh set of memory to fill.

If you don't lock with the DISCARD flag, you won't be handed a fresh set of memory to fill (i.e. you won't get vertex buffer renaming). You'll have to wait for the card to finish any operations it's doing on the buffer before you can write.

Share this post


Link to post
Share on other sites
Quote:
Original post by Coder
If you don't lock with the DISCARD flag, you won't be handed a fresh set of memory to fill (i.e. you won't get vertex buffer renaming). You'll have to wait for the card to finish any operations it's doing on the buffer before you can write.


So should I use the D3DLOCK_NOOVERWRITE flag instead>

As in the sdk docs it says that it will return the driver immediately and continue rendering, does this mean it will allow me access to the vb straight away, but it will also continue to render what it was doing before i interrupted it?

Quote:

D3DLOCK_NOOVERWRITE
The application promises not to overwrite any data in the vertex and index buffers. Specifying this flag allows the driver to return immediately and continue rendering, using this buffer. If this flag is not used, the driver must finish rendering before returning from locking.


thanks.

Share this post


Link to post
Share on other sites
I have found that either the runtime and/or drivers expect NO_OVERWRITE to imply that you are APPENDING to the buffer.

That is certainly the normal usage case, so this may just have been bugs assuming this, but I ran into problems when I used no_overwrite to mean ( I don't have any writes pending to this area I'm going to write to, but it's not necessarily appending ).

So, I would recommend keeping your static vertices in another buffer, refilling the whole vb every time with discard, or keep appending new stuff to the end, and skip the unused old dynamic stuff until you run out of space, then lock with discard.

Share this post


Link to post
Share on other sites
Quote:
Original post by Coder
Quote:
Original post by skittleo
Quote:
Original post by johnnyBravo
My vertexbuffer is dynamic, but if i remove the discard flag, would that be ok then?


Yep. Even if you limit the data you modify with offset and size, Direct3D will still hand you a fresh set of memory to fill.

If you don't lock with the DISCARD flag, you won't be handed a fresh set of memory to fill (i.e. you won't get vertex buffer renaming). You'll have to wait for the card to finish any operations it's doing on the buffer before you can write.


I was under the assumption that we were still talking about the discard flag.

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!