Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 11

Thread: Better have one big buffer or several smaller ones?

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Sep 2013
    Posts
    81

    Better have one big buffer or several smaller ones?

    Hi.
    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.

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    Quote Originally Posted by Cornix View Post
    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.
    It is very unlikely. To have better performance you have to find and remove bottleneck.
    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.

    Quote Originally Posted by Cornix View Post
    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.
    That's the third aspect, the complexity of manipulation with such huge buffer.

    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.

  3. #3
    Intern Contributor
    Join Date
    Sep 2013
    Posts
    81
    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?

  4. #4
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    It sounds quite reasonable. Do you have any performance issue, or just want to make things proper at the start?

  5. #5
    Intern Contributor
    Join Date
    Sep 2013
    Posts
    81
    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.

  6. #6
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,188
    A related thread going on right now in the Beginner's Forum:

    * Efficiency of VAO with VBO for every Model

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •