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

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

Loading…
Cancel
Save