PDA

View Full Version : optimal VBO arrangement.



mictian
07-09-2005, 02:04 PM
I have objects with atm potentially 3 characteristics per vertex (position, normal, texcoord).

Is it best to create 3 separate vertex buffers (one for each property), or to create one big VBO with all of these things in and just tell opengl to offsets to where each part begins?

I am looking to get the best cache usage mainly, so I am wondering which would provide the best locality of reference.

Dark Photon
07-09-2005, 07:56 PM
mictian:
I have objects with atm potentially 3 characteristics per vertex (position, normal, texcoord). ... Is it best to create 3 separate vertex buffers (one for each property), or to create one big VBO...?Are all three always enabled, or do you occasionally enable just one or two? Are these static (GPU-side VBOs) or are you frequently updating them across the AGP bus, and if so are you updating all of them or just one or two?

As you may have already considered, there are a number of permutations. The convention wisdom says interleaved is generally better than separate. In my experience with static (GPU-side) vertex arrays, I find that if you're always using all of the arrays, it's slightly better to interleave them all into one VBO (only slightly), but if you might occasionally disable a few or need to selectively update one or two occasionally, it may be better to just leave them separate.

Intuitively this makes sense as in the static-data all-enabled-all-the-time case the graphics card cache prefetch is more likely to guess right with the single VBO case as you have greater locality of reference.

However, you can envision cases where interleaved probably wouldn't be good (say you were doing a depth-only pass with only the position array [12 bytes] but you fed it a 128 byte-per-vertex interleaved vertex data VBO and only enabled the positions attribute. The memory cache prefetch could potentially read lots of data you won't actually be using.