Hi Karl,

Lots has been written on this topic over the years on osg-users so
please search the archives.  The short story is that the OSG is design
to do single threaded (or at least synchronous) updating of the scene
graph, and multi-threaded cull and draw.

Providing support for async update significantly complicates the scene
graph design and implementation, extensibility and the usage of the
scene graph.  Critically is also harms performance as the
multi-buffering, data syncronization and locking of the scene graph
that would be required has a performance penalty.

The best way to tackle this type of work is locally buffer data that
you need to update and then sync this on each new frame during the
update phase.  The osgterrain example has an example of preparing data
in background thread and then assigning this to the scene graph during
update.  The DatabasePager is also an example of this in action.

Robert.

On Fri, Jul 17, 2009 at 10:14 AM, Karl Wurzel<[email protected]> wrote:
> Hi,
>
> Is it possible in OSG to make changes to the scene graph from a thread other 
> than the rendering thread? What kind of thread-safety does OSG provide on its 
> own and which OSG functions that run in the rendering thread will have to be 
> protected with additional mutexes?
>
> I already tried protecting both the rendering code and code changing the 
> scene graph with a common mutex. However, this approach seems to have 
> problems. The rendering thread seems to be holding the mutex almost 100% of 
> the time, particularly while it is waiting for V-sync. This seems to be 
> happening somewhere in renderingTraversals. Is it possible to split 
> renderingTraversals up into separate calls without making changes to or 
> subclassing the OSG viewer classes?
>
> In general, would you recommend such an approach at all, or is it a bad idea 
> to change the scene graph outside the rendering thread? In my application, 
> this approach would be a convenient solution for changing the scene graph in 
> response to external events other than user input. These events are usually 
> handled in separate threads, and if scene graph updates were limited to the 
> rendering thread, this would require communication between threads which is 
> both complicated and expensive.
>
> Thank you!
>
> Cheers,
> sqrtK
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=15064#15064
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to