diff --git a/include/osg/Texture b/include/osg/Texture index 3c69c0164..82cc19758 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -1189,7 +1189,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute void newFrame(osg::FrameStamp* fs); void resetStats(); void reportStats(std::ostream& out); - void recomputeStats(std::ostream& out); + void recomputeStats(std::ostream& out) const; + bool checkConsistency() const; unsigned int& getFrameNumber() { return _frameNumber; } unsigned int& getNumberFrames() { return _numFrames; } diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index 5b5dd0d42..5e00da7fc 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -1159,7 +1159,7 @@ void GLBufferObjectManager::recomputeStats(std::ostream& out) numActive += os->getNumOfGLBufferObjects(); numOrphans += os->getNumOrphans(); numPendingOrphans += os->getNumPendingOrphans(); - currentSize += os->getProfile()._size * (numObjectsInLists+numOrphans); + currentSize += os->getProfile()._size * (os->computeNumGLBufferObjectsInList()+os->getNumOrphans()); out<<" size="<getProfile()._size <<", os->computeNumGLBufferObjectsInList()"<computeNumGLBufferObjectsInList() <<", os->getNumOfGLBufferObjects()"<getNumOfGLBufferObjects() diff --git a/src/osg/Texture.cpp b/src/osg/Texture.cpp index 46a25ec3e..d705d6a18 100644 --- a/src/osg/Texture.cpp +++ b/src/osg/Texture.cpp @@ -267,6 +267,7 @@ void Texture::TextureObjectSet::deleteAllTextureObjects() // OSG_NOTICE<<"Texture::TextureObjectSet::deleteAllTextureObjects()"<_next; _orphanedTextureObjects.push_back(glto.get()); + remove(glto.get()); + ++numOrphaned; + ref_ptr original_texture = glto->getTexture(); if (original_texture.valid()) { @@ -284,6 +288,9 @@ void Texture::TextureObjectSet::deleteAllTextureObjects() } } + _parent->getNumberOrphanedTextureObjects() += numOrphaned; + _parent->getNumberActiveTextureObjects() -= numOrphaned; + // now do the actual delete. flushAllDeletedTextureObjects(); @@ -378,7 +385,7 @@ void Texture::TextureObjectSet::discardAllDeletedTextureObjects() _numOfTextureObjects -= numDiscarded; // update the TextureObjectManager's running total of current pool size - _parent->setCurrTexturePoolSize( _parent->getCurrTexturePoolSize() - numDiscarded*_profile._size ); + _parent->getCurrTexturePoolSize() -= numDiscarded*_profile._size; // update the number of active and orphaned TextureOjects _parent->getNumberOrphanedTextureObjects() -= numDiscarded; @@ -445,7 +452,7 @@ void Texture::TextureObjectSet::flushDeletedTextureObjects(double currentTime, d // update the number of TO's in this TextureObjectSet _numOfTextureObjects -= numDeleted; - _parent->setCurrTexturePoolSize( _parent->getCurrTexturePoolSize() - numDeleted*_profile._size ); + _parent->getCurrTexturePoolSize() -= numDeleted*_profile._size; // update the number of active and orphaned TextureOjects _parent->getNumberOrphanedTextureObjects() -= numDeleted; @@ -879,16 +886,6 @@ void Texture::TextureObjectManager::flushDeletedTextureObjects(double currentTim { ElapsedTime elapsedTime(&(getDeleteTime())); -#if 0 - static double max_ratio = 0.0f; - double ratio = double(getCurrTexturePoolSize())/double(getMaxTexturePoolSize()); - if (ratio>max_ratio) - { - max_ratio = ratio; - } - // OSG_NOTICE<<"TexturePool Size ratio "< 0.0); ++itr) @@ -938,7 +935,7 @@ void Texture::TextureObjectManager::resetStats() } -void Texture::TextureObjectManager::recomputeStats(std::ostream& out) +void Texture::TextureObjectManager::recomputeStats(std::ostream& out) const { out<<"Texture::TextureObjectManager::recomputeStats()"<second.get(); + const TextureObjectSet* os = itr->second.get(); numObjectsInLists += os->computeNumTextureObjectsInList(); numActive += os->getNumOfTextureObjects(); numOrphans += os->getNumOrphans(); numPendingOrphans += os->getNumPendingOrphans(); - currentSize += os->getProfile()._size * (numObjectsInLists+numOrphans); + currentSize += os->getProfile()._size * (os->computeNumTextureObjectsInList()+os->getNumOrphans()); out<<" size="<getProfile()._size - <<", os->computeNumGLBufferObjectsInList()"<computeNumTextureObjectsInList() - <<", os->getNumOfGLBufferObjects()"<getNumOfTextureObjects() + <<", os->computeNumTextureObjectsInList()"<computeNumTextureObjectsInList() + <<", os->getNumOfTextureObjects()"<getNumOfTextureObjects() <<", os->getNumOrphans()"<getNumOrphans() <<", os->getNumPendingOrphans()"<getNumPendingOrphans() <