In my current OpenGL-based game I’m using the approach of having
different vertex formats for different purposes, e.g, my TerrainVertex
has Position,Position2,Normal,Data1,Data2 , my ModelVertex has
However, more and more I see examples of people using independent
buffers of data for the different attributes, eg, one buffer for
Position, one buffer for TexCoord.
My question; is the reason why people choose multiple independent
buffers a performance one, or an ease-of-use one?
I know that using only the Position buffer for geometry to be rendered
from a lights perspective (for shadow mapping, no texcoords needed etc)
can save on the amount of data that the GPU has to work with for that
specific operation, but is there a performance hit for binding 5
independent buffers per object to be drawn?
I currently have up to around 600 VBO’s being drawn at one time (large
scale chunk-based terrain) and I’m facing the task of rendering all that
geometry again in order to generate a shadow map which will bring my
frame rate below acceptable levels, so I’m trying to decide if splitting
my VBO’s into one buffer per attribute will be better in the long run or
Please log in or register to post a reply.
Traditionally people recommend using interleaved arrays. I know of one
architecture where that would be the worst possible choice though, so if
you care, you’ll just have to benchmark and see what works.
Personally I’ve always kept them separate, and I don’t think that causes
a major performance hit.
I personally separate my buffers as well, especially when I deal with
dynamic VBOs. I do this mainly because I like the flexibility of this
organizational structure, although I do work with interleaved arrays on
the Windows Phone platform. Theoretically, there’s a slight performance
gain with interleaved arrays because you call fewer functions per frame,
but it’s negligible at best. Since VBOs reside in graphics memory
regardless of how you organize them, you shouldn’t suffer any penalty
for stuff you don’t use. What matters is your shader code. If your
shader only operates on positional data and simple fragment colouring,
then you’re not wasting GPU cycles elsewhere.
TheNut, there can be a nontrivial cost involved in just fetching the
vertex data from memory to the shader, even if the shader doesn’t use
all of it. That’s why people sometimes split streams into e.g.
attributes used by the shadow shader and those only used by the main
shader (the main shader reads both streams). Since shadow-map rendering
is typically vertex-bound, you actually can save time by slimming down
the streams. I’d also guess that on the flip side, having too many
streams can negatively impact GPU memory read performance due to losing
some cache locality. But this will be very hardware-dependent; YMMV, and
I’ve managed to get multiple buffers up and working perfectly fine, with
the added benefit of being able to use position data only when
It’s not generally a good idea to have separate buffers because the
vertex data is fetched in cache lines. Having the data split into
multiple buffers essentially multiplies the amount of data GPU has to
fetch for processings a vertex.