Thread: [PyOpenGL-Users] glDeleteBuffers() and arrays.vbo
Brought to you by:
mcfletch
From: Dan H. <Dan...@no...> - 2009-07-24 23:59:36
|
Hi all, I may have found a bug in PyOpenGL's arrays.vbo module, but it could be a problem with my code or system. When a vertex or other buffer is automatically deleted by PyOpenGL's deleter, here's the error that I get: Exception OpenGL.error.NullFunctionError: NullFunctionError('Attempt to call an undefined function glDeleteBuffers, check for bool(glDeleteBuffers) before calling',) in <function doBufferDeletion at 0x0A8892B0> ignored To me, that sounds like my OpenGL implementation (from Nvidia) doesn't implement glDeleteBuffers() for whatever reason. The deleter code in vbo.py appears to check for this, but it checks for an AttributeError rather than an OpenGL.error.NullFunctionError, or better yet, doing a protective bool(glDeleteBuffers) before actually calling glDeleteBuffers(). By the way, is it problematic that when doing a manual VBO.delete(), the automatic deleter is still invoked? Shouldn't VBO.delete() pop the deleter so glDeleteBuffers() isn't called twice for a particular VBO? Or is that not a problem? Dan |
From: Mike C. F. <mcf...@vr...> - 2009-07-25 04:41:06
|
Dan Helfman wrote: > Hi all, > > I may have found a bug in PyOpenGL's arrays.vbo module, but it could be > a problem with my code or system. When a vertex or other buffer is > automatically deleted by PyOpenGL's deleter, here's the error that I get: > > Exception OpenGL.error.NullFunctionError: NullFunctionError('Attempt to > call an undefined function glDeleteBuffers, check for > bool(glDeleteBuffers) before calling',) in <function doBufferDeletion at > 0x0A8892B0> ignored > This sounds like the VBO is getting deleted after module cleanup? You should always have a glDeleteBuffers implementation if you have a glGenBuffers implementation. Basically this code is getting called after the system has done so much cleanup that the functions aren't available any more (at least, that's my interpretation). > To me, that sounds like my OpenGL implementation (from Nvidia) doesn't > implement glDeleteBuffers() for whatever reason. The deleter code in > vbo.py appears to check for this, but it checks for an AttributeError > rather than an OpenGL.error.NullFunctionError, or better yet, doing a > protective bool(glDeleteBuffers) before actually calling glDeleteBuffers(). > That's now fixed in bzr head, will show up in the 3.0.1a2 release. i.e. we catch the NullFunctionError, so you shouldn't see the ignored error messages any more. > By the way, is it problematic that when doing a manual VBO.delete(), the > automatic deleter is still invoked? Shouldn't VBO.delete() pop the > deleter so glDeleteBuffers() isn't called twice for a particular VBO? Or > is that not a problem? > The auto-deleter uses the same list (self.buffers of the vbo), so the delete method's pop() from that list meant there was nothing left in the auto-deleter. It shouldn't be possible for the deleter to get called before the delete method, but just in case I've altered it to also use pop() to retrieve values (rather than simple iteration). Calling glDeleteBuffers() twice for the same buffer would be a problem if, for instance, another vbo had already been allocated that ID. That said, you *shouldn't* ever need to explicitly call delete on the VBO instance unless for some reason you want to "reuse" the VBO object but not the GL-side buffer (I can't think of a real use-case for that). Thanks for the bug report, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Dan H. <Dan...@no...> - 2009-07-27 16:31:18
|
Mike C. Fletcher wrote: > Dan Helfman wrote: >> Exception OpenGL.error.NullFunctionError: NullFunctionError('Attempt to >> call an undefined function glDeleteBuffers, check for >> bool(glDeleteBuffers) before calling',) in <function doBufferDeletion at >> 0x0A8892B0> ignored >> > This sounds like the VBO is getting deleted after module cleanup? You > should always have a glDeleteBuffers implementation if you have a > glGenBuffers implementation. Basically this code is getting called > after the system has done so much cleanup that the functions aren't > available any more (at least, that's my interpretation). This is happening when a VBO instance is finalized after its containing object goes away. And as far as I can tell, the deleter is only being called once for each VBO. So I'm not sure what else could be doing the cleanup unless it's in the underlying C code. I put some prints in the explicit VBO.delete() call, so I've confirmed that that's not getting called. I should mention that this is all with the 3.0.0 release. > That's now fixed in bzr head, will show up in the 3.0.1a2 release. i.e. > we catch the NullFunctionError, so you shouldn't see the ignored error > messages any more. Great, thanks! > That said, you *shouldn't* ever need to explicitly call delete on the > VBO instance unless for some reason you want to "reuse" the VBO object > but not the GL-side buffer (I can't think of a real use-case for that). Gotcha. Dan |
From: Dan H. <Dan...@no...> - 2009-07-27 17:40:50
|
Dan Helfman wrote: > Mike C. Fletcher wrote: >> Dan Helfman wrote: >>> Exception OpenGL.error.NullFunctionError: NullFunctionError('Attempt to >>> call an undefined function glDeleteBuffers, check for >>> bool(glDeleteBuffers) before calling',) in <function doBufferDeletion at >>> 0x0A8892B0> ignored >>> >> This sounds like the VBO is getting deleted after module cleanup? You >> should always have a glDeleteBuffers implementation if you have a >> glGenBuffers implementation. Basically this code is getting called >> after the system has done so much cleanup that the functions aren't >> available any more (at least, that's my interpretation). > > This is happening when a VBO instance is finalized after its containing > object goes away. And as far as I can tell, the deleter is only being > called once for each VBO. So I'm not sure what else could be doing the > cleanup unless it's in the underlying C code. I put some prints in the > explicit VBO.delete() call, so I've confirmed that that's not getting > called. > > I should mention that this is all with the 3.0.0 release. Follow-up: Upon further investigation, turns out that this is a threading issue. GL and the VBOs were initialized in one thread, and then VBO finalization was getting triggered from a different thread. As soon as I changed it so that the VBO deleter only got triggered from the correct thread, the NullFunctionErrors went away. Dan |