Sign in to follow this  
Danmarell

vertex buffer management

Recommended Posts

Danmarell    122
I'm still pretty new to understanding this so any help would be much appreciated. Am i right in assuming that it is more efficient to store static models( world maps,environments,objects in scene) in static vertex buffers on the vid card, and moving ones(ones which are being transformed) in dynamic ones in main memory? Is it then the case that one main static vertex buffer on the vid card, is used to pile all vertex info from other vertex buffers into, so that it can be culled, and ready for drawprimitive()? Is this an efficient way, piling on all previously transformed vertices like layers?

Share this post


Link to post
Share on other sites
Jason Z    6436
A vertex buffer is used to hold whatever vertex data you are sending to the video card. If you create a vertex buffer and the data it holds never changes (like in the case of a static landscape or a static building) then it is a static vertex buffer.

If, on the other hand, the data changes every frame (like for deformable terrain or a building that can be partially blown up) then since the vertex buffer is reloaded with changing data it is a dynamic vertex buffer.

The only real difference is that the static buffer will most likely reside in video memory, which is much faster to get to the video card. Dynamic buffers are generally in system memory which has to get sent to the video card through AGP, which is slower. The moral is, if you don't have to modify the data, then it is generally faster.

The method that you mention I have not heard of before. Instead of copying one buffer into another one, you would just send the first buffer to the video card. Hope this helps.

Jason Z

Share this post


Link to post
Share on other sites
Supernat02    604
Dynamic (as in specifying D3DUSAGE_DYNAMIC when you create the vertex buffer) vertex data is usually stored in AGP memory. Specify D3DUSAGE_DYNAMIC if you will be updating your vertex buffer a lot. The driver of the video card will determine the best place for the buffer, allowing the most efficient access.

What you may be thinking of is a common practice of saving two copies of the buffer, one in system memory, one as a vertex buffer. This is done to prevent reading from the vertex buffer, because reading is tremendously slower than writing. You can use the system memory, update it, calculate collision, physics, etc. Then you just update the vertex buffer by copying the system memory to the vertex buffer each frame.

Good luck,
Chris

Share this post


Link to post
Share on other sites
I was just reading this page, and it says that dynamic buffers will only be put in AGP memory if D3DUSAGE_WRITEONLY is NOT specified. If it is specified, then it goes into video memory.

Its generally not a good idea to read from vertex buffers.

Share this post


Link to post
Share on other sites
Fidelio66    164
Older cards (before GeForce) like the TNT/TNT2 didn't have hardware T&L. This means that vertex buffers get transformed by the CPU, and DirectX sends transformed (screen-space) triangles to the card to be textured and drawn. Obviously then vertex buffers should not be on the card or else they'd be read from video memory to the CPU every frame. If you want to support older cards you must check the caps for hardware t&l and vary your settings accordingly. This can be quite complicated.

You can experiment with writeonly, dynamic, D3DPOOL_DEFAULT etc, but I find performance decent and management much more easy if I specify D3DPOOL_MANAGED for everything. Then DX will handle the best location and reloading after a reset for you.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
I only thought that youd copy them all to one because if the back buffer of the screen is being sent all these vertices from lots of different buffers, then how would they be sent in 'depth' order? I thought that all depth sorting could be done in a static one which could then be sent straight for rendering. Or is depth sorting done further down the pipeline?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this