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 3 of 3

Thread: Deleting VBO and VAO soon after drawing

  1. #1
    Newbie Newbie
    Join Date
    May 2014
    Posts
    2

    Deleting VBO and VAO soon after drawing

    In my render loop, I'm creating a VBO and VAO for some object I'll be drawing. In one particular instance the object will only be temporary (it's the same code for whether it's temporary or not), so drawn after creating those two objects and then deleted soon after (all within the same render loop). I'm wondering what the behaviour is for this kind circumstance? I would've thought the referenced made by the draw call would've kept the objects alive, regardless of if I deleted them myself. But my application doesn't seem to render it correctly when it does this (the object doesn't get drawn at all).

    e.g. On the one particular case my render loop looks like this:
    enter render loop
    do some drawing
    {//draw this particular object
    create vbo with data for that object
    create vao for state that is used to setup when drawing that object
    draw object
    }
    delete object (vao and vbo)
    do some drawing
    exit render loop

    Typically it normally keeps those objects alive for awhile (many render loops), and so this problem isn't apparent.

    So is it correct behaviour for OpenGL not to keep those objects alive? And so I have to change it so the object won't be deleted till the next frame, or flushing the commands, etc.

    Update: Actually I just tried flushing it (tried finishing too), and still same problem. Only works if I postpone the deletion till the next render loop.

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,290
    It's not correct behaviour, so I think it's a driver bug . If you're using a GeForce, try disabling "multithreaded optimisations" from the nvidia control panel.

    When deleting a buffer, it will get unbound only from the currently-bound VAO. I suggest you try first deleting the VAO, then VBO; but this is just a hack.
    When deleting a buffer or anything, the GL spec dictates that for external purposes, the object names get instantly deleted, but internally, the data backing them should remain alive until the GPU finishes using it.

  3. #3
    Newbie Newbie
    Join Date
    May 2014
    Posts
    2
    Yeh I thought so (about how deletions are handled). Also deleting the VAO first then the VBO worked, thanks. I guess I'll just have to file a bug report and wait for a proper fix.

Posting Permissions

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