forked from mirror/openmw-tes3mp
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
This commit is contained in:
parent
84a92e665c
commit
b4a6b6387b
2 changed files with 12 additions and 1 deletions
|
@ -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…
Reference in a new issue