Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: VBO memory usage

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2006
    Posts
    3

    VBO memory usage

    I am using VBOs and it seems that OpenGL uses a lot more memory in creating these objects than expected. i assume this is because copies of the vertex data, etc. are maintained behind the scenes by OpenGL. Is there a way to tell OpenGL that it should not under any circumstance maintain anything in main memory? I am currently just setting the GL_STATIC_DRAW_ARB state for static meshes.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    164

    Re: VBO memory usage

    If you mean for the object that is held in the VBO to be static, you can remove the data you allocated after uploading to the VBO.

    Take a look at the examples at the end of this and you will get it:
    http://oss.sgi.com/projects/ogl-samp...fer_object.txt

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2006
    Posts
    3

    Re: VBO memory usage

    It doesn't look like something I could use, it is not an option to mix the creation of the VBOs with the rendering loop. I would like to create the objects somewhere else and just tell OpenGL to keep it on the graphics card at all time and not create system copies

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    164

    Re: VBO memory usage

    Create the VBOs before you render, in something like an init()-function. When you've created the VBOs you will call them by indices, very much like you would with a display list aswell.

    Some more links:
    http://www.idevgames.com/forum/showthread.php?t=10835
    http://www.gamedev.net/community/for...opic_id=336689

  5. #5
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: VBO memory usage

    I believe this is not what bowman had in mind.
    OpenGL support in Windows drivers MUST keep everything passed to GPU in system memory - this is actually Windows fault.
    In DirectX there is an error that tells an application that resource it refers to no longer exists on GPU (it was removed by system). In OpenGL there is no such error message, because it should not be our problem that system removed something from GPU.
    For this reason OpenGL drivers keep everything backed-up in system memory and upload resources again if they're lost.
    Windows could actually tell the driver that some resource needs to be removed from GPU. This way driver could download this resource from GPU and create it's duplicate in system memory. Unfortunately Windows removes resources on it's own and the driver can only get that information after resource is allready gone.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    164

    Re: VBO memory usage

    What I was referring to was the fact that once you have passed the data to your buffer it will be kept there (I don't know exactly where this buffer is physically but I assume it is in some fast memory on the motherboard).

    After reading bowman's post again I am a bit confused. How is it possible to measure how much memory OpenGL uses to create these objects? I have never heard of such a query, but that obviously doesn't mean that it doesn't exist. It may of course be done by checking system memory and figuring out exactly what was allocated where and then assuming that OpenGL accounts for the rest.

    I see know that I wasn't really answering bowman's question at all... sorry about that!

  7. #7
    Junior Member Regular Contributor songho's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    242

    Re: VBO memory usage

    thinks,
    VBO comes with glGetBufferParameterivARB() to measure the size of VBO.

    Code :
    int bufferSize;
    glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &bufferSize);
    Did you mean the above function or something else?

  8. #8
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,256

    Re: VBO memory usage

    You can see how much RAM your system is using by looking at task manager, which is said not to be reliable but I think it is an indicator.

    k_szczech is right, the driver needs to put asside everthing in RAM or hard drive.

    "Is there a way to tell OpenGL that it should not under any circumstance maintain anything in main memory?"

    No
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  9. #9
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: VBO memory usage

    By the way - does Linux habve this drawback? I'm planning to port my framework to Linux soon, s I'm going to find out anyway, but I'm curious.

  10. #10
    Junior Member Newbie
    Join Date
    Dec 2006
    Posts
    3

    Re: VBO memory usage

    I have used task manager as an indicator of how much memory is used. An example is a vertexbuffer, which i calculated would need about 17k for vertices. In the task manager I could see that about 84k actually was used, which seems like a lot more than needed. It seems that DirectX is more flexible, allowing the developer to specify more precisely how memory should be used (whether it should be system, AGP, etc.) and that OpenGL maintains a lot of things behind the scenes, which is out of the developers hands

Posting Permissions

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