Better have one big buffer or several smaller ones?
I am currently trying to find the right way to use OpenGL. Right now I am using several VBO's, each with about 1 - 3mb of data.
But somebody recently told me that was a bad idea and I should try to use only 1 VBO in the entire application. This way the performance would be much better.
However, using only 1 VBO would make for a huge overhead in my application because then I would have to sort the contents by texture and shader to minimize the number of times I had to change either of those.
Would that be worth it? All this overhead on the application, would that pay of in terms of performance? Is switching a VBO such a costly method?
Thanks in advance.
It is very unlikely. To have better performance you have to find and remove bottleneck.
Originally Posted by Cornix
If binding several VBOs is a bottleneck (in which I really doubt), then yes, you'll experience some performance boost.
Another important aspect is data localization and alignment in that buffer. If locality is poor, execution time will be longer because of cache misses. Alignment is aways at least 32 bit. That's why we don't have 3 byte internal texture representation.
That's the third aspect, the complexity of manipulation with such huge buffer.
Originally Posted by Cornix
The fourth aspect is memory management. If OpenGL for some reason cannot store huge buffer in the GPU memory, it won't be rendered (NV) or the performance will be very poor (AMD). Memory eviction count could also be higher with huge buffers.
I'm amazed how some basic concepts are misinterpreted. Yes, generally it is better to have less VBOs for plenty of reasons. But generalization that application should have just one huge VBO for everything is silly.
My current approach is to have one VBO per texture per shader. However, I dont have many different shaders and I dont have many different textures either. I guess I will have no more then 15 VBO's in total at any point in time. This makes it incredibly easy for me to fill these VBO's because I dont have to worry about sorting the data (there is no translucency and all meshes are of the same size).
In my render method I just go from texture to texture, from shader to shader and render one vbo for each of these. So for each VBO only a single draw call.
Would you say that is a good approach or should I try to do something different?
It sounds quite reasonable. Do you have any performance issue, or just want to make things proper at the start?
I am not far enough into developement process to run into any performance issues. I just want to make sure I do it right before I start. It would be a pain to learn later that I have to redo everything. Besides, I want to make it right. I want to learn something here, not just finish some useless project.
A related thread going on right now in the Beginner's Forum:
* Efficiency of VAO with VBO for every Model