[osg-submissions] Reuse of context IDs and cleanup of OpenGL resources.

Robert Osfield robert.osfield at gmail.com
Tue Apr 15 03:25:31 PDT 2008


Hi Mark,

The SVN version of OSG has extra support for deleting and discarding GL
object ID's.  I believe this will probably address the problems you've seen.

Could you move to OSG-2.3.7 or OSG-SVN to see if the problem is addressed.

Robert.

On Mon, Apr 14, 2008 at 9:55 PM, Mark Sciabica <msciabica at itracs.com> wrote:

>  These changes are a fix for the bug reported here:
>
>
> http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2008-January/006048.html
>
>
>
> Briefly, the bug is that objects that allocate OpenGL resources (e.g.
> textures or display lists) for a given contextID believe those objects are
> still valid even after the contextID becomes invalid and then reused by
> another context.
>
>
>
> A source file is attached that reproduces the bug for display lists,
> textures, and fonts. Other resource types have not been tested, although
> code has been added to clean up all types that currently clean up their
> deleted items caches in the GraphicsContext::close function.
>
>
>
> The modifications were made against the 2.2.0 branch.
>
>
>
> Summary of changes.
>
>
>
> 1. ContextData now has a list of objects using OpenGL resources for its
> contextID.
>
>
>
> 2. Objects using OpenGL resources now add themselves to the above list
> when they allocate such a resource, and remove themselves when they
> deallocate it.
>
>
>
> 3. GraphicsContext::close deallocates the registered resources if no other
> contexts are using its contextID. Calling releaseGLObjects on the camera now
> seems redundant so was removed. (Exception: if the _state member of the
> GraphicsContext is NULL (which it is when close() is called more than
> once(and it is)) then the camera will have its GLObjects released in ALL
> contexts. This seems incorrect as it needlessly releases objects in
> unrelated contexts.)
>
>
>
> 4. ContextData was made an Observer of the objects in its list to avoid
> dereferencing invalid pointers if those objects are destroyed without
> deallocating their resources.
>
>
>
> 5. Static functions that allocate resources and manage a cache of deleted
> objects were made nonstatic so they could register the object with the
> context at the time the resource was allocated. They assume the object
> they're called against is the object owning the resource. These functions
> have also been made protected to help enforce this.
>
>
>
>
>
> Regards,
>
>
>
> Mark
>
> _______________________________________________
> osg-submissions mailing list
> osg-submissions at lists.openscenegraph.org
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-submissions-openscenegraph.org/attachments/20080415/ff552b2c/attachment.htm 


More information about the osg-submissions mailing list