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 Position,TexCoords,Normal.
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 not.
Thanks
Vertex Buffers, Interleaved or separate?
Started by Vereor, Dec 16 2011 07:05 AM
vertex shadows pipeline performance opengl
5 replies to this topic
#1
Posted 16 December 2011 - 07:05 AM
#2
Posted 16 December 2011 - 09:22 AM
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.
Personally I've always kept them separate, and I don't think that causes a major performance hit.
http://iki.fi/sol - my schtuphh
#3
Posted 16 December 2011 - 12:42 PM
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.
http://www.nutty.ca - Being a nut has its advantages.
#4
Posted 16 December 2011 - 10:36 PM
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 such.
reedbeta.com - developer blog, OpenGL demos, and other projects
#5
Posted 22 December 2011 - 07:07 AM
Thanks guys,
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 necessary.
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 necessary.
#6
Posted 01 January 2012 - 08:49 PM
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.
Cheers, Jarkko
Cheers, Jarkko
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











