Create own instance of osgDB::SharedStateManager so we control when to call prune()

prune() is now called in the background thread, just like the resource cache update.

Seems to improve performance by ~0.3 ms/frame
coverity_scan^2
scrawl 8 years ago
parent 84a92e665c
commit b4a6b6387b

@ -181,6 +181,7 @@ namespace Resource
, mAutoUseNormalMaps(false)
, mAutoUseSpecularMaps(false)
, mInstanceCache(new MultiObjectCache)
, mSharedStateManager(new osgDB::SharedStateManager)
, mImageManager(imageManager)
, mNifFileManager(nifFileManager)
, mMinFilter(osg::Texture::LINEAR_MIPMAP_LINEAR)
@ -392,7 +393,7 @@ namespace Resource
// share state
mSharedStateMutex.lock();
osgDB::Registry::instance()->getOrCreateSharedStateManager()->share(loaded.get());
mSharedStateManager->share(loaded.get());
mSharedStateMutex.unlock();
if (mIncrementalCompileOperation)
@ -549,6 +550,10 @@ namespace Resource
void SceneManager::updateCache(double referenceTime)
{
mSharedStateMutex.lock();
mSharedStateManager->prune();
mSharedStateMutex.unlock();
ResourceManager::updateCache(referenceTime);
mInstanceCache->removeUnreferencedObjectsInCache();

@ -22,6 +22,11 @@ namespace osgUtil
class IncrementalCompileOperation;
}
namespace osgDB
{
class SharedStateManager;
}
namespace Shader
{
class ShaderManager;
@ -147,6 +152,7 @@ namespace Resource
osg::ref_ptr<MultiObjectCache> mInstanceCache;
osg::ref_ptr<osgDB::SharedStateManager> mSharedStateManager;
OpenThreads::Mutex mSharedStateMutex;
Resource::ImageManager* mImageManager;

Loading…
Cancel
Save