Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Uniform Buffer Objects performance issues

  1. #11
    Intern Newbie
    Join Date
    Jul 2009
    I've just checked it. Unfortunately performance stays exactly the same.

  2. #12
    Junior Member Newbie
    Join Date
    Jan 2011
    I've experienced the same - Though not with UBOs by normal VBOs. I had to stop using buffer mapping for that reason and only rely on subbufferdata.
    What I think is happening is that the Nvidia drivers are trying to be clever (I'm guessing you're using Nvidia like me). It's my experience that Nvidia doesn't care about the buffer usage and changes type as they see fit.

    My advice would be to steer clear of mapping GL buffers and handle it yourself.

  3. #13
    Junior Member Newbie
    Join Date
    Feb 2002
    Bratislava, Slovakia
    Buffers are not designed to be updated per draw call but per frame... In your case the texture buffer will be more suitable because you won't be limited by the 64K size and the 256byte alignment.

    // update matrices in TBO / UBO
    glBindBuffer(GL_TEXTURE_BUFFER, tbo);
    float4x4 *mats = (float4x4*)glMapBufferRange(GL_TEXTURE_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
    float4x4 *e = mats + num_instances;
    while(mats != e) {
    *mats++ = compute instance matrix;

    // render meshes
    glBindTexture(GL_TEXTURE_BUFFER, tb); // bind texture buffer created by glTexBuffer
    glUniform1i(your_shader_sampler_uni, 0); // set texture channel for shader sampler

    for(...) {
    glUniform1i(your_mesh_id_uni, id); // or use glVertexAttribI1i(15, id)

    // in shader
    mat4 tm = mat4(
    your_mesh_id * 4),
    texelFetch(tb, your_mesh_id * 4 + 1),
    texelFetch(tb, your_mesh_id * 4 + 2),
    texelFetch(tb, your_mesh_id * 4 + 3));

    You can find more about buffers in free chapter from OpenGL Insights

Posting Permissions

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