[osg-users] Uniform set and callback

Robert Osfield robert.osfield at gmail.com
Tue Apr 12 01:59:57 PDT 2016


Hi Dario,

On 12 April 2016 at 09:58, Dario Minieri <paradox at cheapnet.it> wrote:

> Simple question: set a uniform value via set() method is thread-safe or we
> have to set the value via Uniform callback? Apparently, set() works fine,
> but thread interactions are devious :D
>

osg::Uniform::set() is not thread safe.  However, whether this is a problem
for your usage model is not something I can say without more knowledge of
your usage model.

Updating via an update callback doesn't add thread safety by itself.  If
you are using DrawThreadPerContext or
CullThreadPerCameraDrawThreadPerContext then the draw thread is allowed to
run at the same time as the update, event and cull traversals of the next
frame.  If you update the state or geometry in this case you need to to set
the StateSet/Geometry DataVariance to DYNAMIC to prevent the draw thread
from reading and the same time as it's being written.  This does however
reduce the amount of the time the the draw thread can run in parallel with
the update, event and cull traversals, in particular if the dynamic objects
are in an opaque bin.

Robert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160412/a5ff9df6/attachment-0002.htm>


More information about the osg-users mailing list