[osg-users] Questions about shared compile contexts and thread safety

Robert Osfield robert.osfield at gmail.com
Sun Nov 8 07:17:17 PST 2015


Hi Kouichi,

In general I would discourage use of compile contexts except for very
narrow usage models.  The main issue comes down to shadred contexts having
the potential for conflicts when reading/writing to shared GL objects.  The
OSG doesn't have mutexes built into access of GL objects so can only do
shared context/compile context if no GL objects will be accessed by the two
contexts concurrently.  Adding such mutexes would add a huge burden on all
OSG applications.

Robert.

On 7 November 2015 at 23:29, Kouichi Yoshizawa <
kouichi.yoshizawa23 at gmail.com> wrote:

> Hello,
>
> I would like to learn the status of shared compile context threads in
> OpenSceneGraph, as I would like to make use of them for performance
> reasons.  My platform is Linux with Nvidia Quadro GPUs that should have
> good support for shared contexts for GPU transfers.
>
> In 2010 Robert Osfield seems to suggest that shared compile contexts are
> indeed supported by OSG, although GPU hardware/driver support might be
> lacking:
>
>
> > I implemented them [ie shared compile contexts] under Linux with NVidia
> drivers and they worked as expected, but with other drivers and other OS's
> reports back from the community haven't been so positive, so it looks like
> it's a feature that driver developers don't put much effort in to make sure
> it's solid.
>
>
> However, in 2014 he seems to be discouraging their use, maybe due to
> thread safety issues in OSG, or am I reading this wrong?
>
>
> > The OSG's is written to handling multi-theading of shared contexts as
> > handling this special case would require us to add lots of mutex locks
> > to all OpenGL code that is setting or using OpenGL objects.
> >
> > It's better to avoid shared contexts.
> >
>
>
> Inspecting the source code, of particular concern to me is the
> creation/deletion of GL objects.  It appears that the GL object orphan list
> is accessed without mutual exclusion, from the flush functions as well as
> the orphan reuse functions during object creation.  Therefore these two
> operations must then never be performed in different threads, but if they
> are only called from the same thread (the compile context thread in my
> case) is thread safety then guaranteed?  I would be very grateful for
> clarifications regarding this.
>
> Thank you!
>
> Cheers,
> Kouichi[/quote]
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=65576#65576
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151108/fb1a992a/attachment-0003.htm>


More information about the osg-users mailing list