Added a mutex to protect the removal and addition of Uniform and Program to StateSet to avoid parents being invalidated when multi-threading.
This commit is contained in:
@@ -187,6 +187,7 @@ protected:
|
||||
osg::ref_ptr<osg::Texture2D> _fallbackShadowMapTexture;
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::Uniform> > Uniforms;
|
||||
mutable OpenThreads::Mutex _accessUnfiromsAndProgramMutex;
|
||||
Uniforms _uniforms;
|
||||
osg::ref_ptr<osg::Program> _program;
|
||||
};
|
||||
|
||||
@@ -1161,6 +1161,8 @@ void ViewDependentShadowMap::createShaders()
|
||||
|
||||
unsigned int _baseTextureUnit = 0;
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_accessUnfiromsAndProgramMutex);
|
||||
|
||||
_shadowCastingStateSet = new osg::StateSet;
|
||||
|
||||
ShadowSettings* settings = getShadowedScene()->getShadowSettings();
|
||||
@@ -2342,6 +2344,8 @@ osg::StateSet* ViewDependentShadowMap::selectStateSetForRenderingShadow(ViewDepe
|
||||
|
||||
osg::ref_ptr<osg::StateSet> stateset = vdd.getStateSet();
|
||||
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_accessUnfiromsAndProgramMutex);
|
||||
|
||||
vdd.getStateSet()->clear();
|
||||
|
||||
vdd.getStateSet()->setTextureAttributeAndModes(0, _fallbackBaseTexture.get(), osg::StateAttribute::ON);
|
||||
|
||||
Reference in New Issue
Block a user