diff --git a/examples/osganalysis/osganalysis.cpp b/examples/osganalysis/osganalysis.cpp index aee0cec53..440e433db 100644 --- a/examples/osganalysis/osganalysis.cpp +++ b/examples/osganalysis/osganalysis.cpp @@ -187,10 +187,10 @@ public: void report(std::ostream& out) { - OSG_NOTICE<<"Nodes "<<_nodes.size()<reportStats(); - osg::GLBufferObjectManager::getGLBufferObjectManager(0)->reportStats(); + osg::Texture::getTextureObjectManager(0)->reportStats(osg::notify(osg::NOTICE)); + osg::GLBufferObjectManager::getGLBufferObjectManager(0)->reportStats(osg::notify(osg::NOTICE)); } } return false; diff --git a/include/osg/BufferObject b/include/osg/BufferObject index 9b9205cb8..b5eeb373a 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -365,6 +365,8 @@ class OSG_EXPORT GLBufferObjectSet : public Referenced public: GLBufferObjectSet(GLBufferObjectManager* parent, const BufferObjectProfile& profile); + const BufferObjectProfile& getProfile() const { return _profile; } + void handlePendingOrphandedGLBufferObjects(); void deleteAllGLBufferObjects(); @@ -390,6 +392,11 @@ class OSG_EXPORT GLBufferObjectSet : public Referenced GLBufferObjectManager* getParent() { return _parent; } + unsigned int computeNumGLBufferObjectsInList() const; + unsigned int getNumOfGLBufferObjects() const { return _numOfGLBufferObjects; } + unsigned int getNumOrphans() const { return _orphanedGLBufferObjects.size(); } + unsigned int getNumPendingOrphans() const { return _pendingOrphanedGLBufferObjects.size(); } + protected: @@ -449,7 +456,8 @@ class OSG_EXPORT GLBufferObjectManager : public osg::Referenced void newFrame(osg::FrameStamp* fs); void resetStats(); - void reportStats(); + void reportStats(std::ostream& out); + void recomputeStats(std::ostream& out); unsigned int& getFrameNumber() { return _frameNumber; } unsigned int& getNumberFrames() { return _numFrames; } diff --git a/include/osg/Texture b/include/osg/Texture index e6dc95f14..a98196455 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -1095,6 +1095,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute public: TextureObjectSet(TextureObjectManager* parent, const TextureProfile& profile); + const TextureProfile& getProfile() const { return _profile; } + void handlePendingOrphandedTextureObjects(); void deleteAllTextureObjects(); @@ -1119,6 +1121,11 @@ class OSG_EXPORT Texture : public osg::StateAttribute TextureObjectManager* getParent() { return _parent; } + unsigned int computeNumTextureObjectsInList() const; + unsigned int getNumOfTextureObjects() const { return _numOfTextureObjects; } + unsigned int getNumOrphans() const { return _orphanedTextureObjects.size(); } + unsigned int getNumPendingOrphans() const { return _pendingOrphanedTextureObjects.size(); } + protected: virtual ~TextureObjectSet(); @@ -1185,7 +1192,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute void newFrame(osg::FrameStamp* fs); void resetStats(); - void reportStats(); + void reportStats(std::ostream& out); + void recomputeStats(std::ostream& out); unsigned int& getFrameNumber() { return _frameNumber; } unsigned int& getNumberFrames() { return _numFrames; } diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index f67e1d84a..264146e87 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -937,6 +937,17 @@ void GLBufferObjectSet::moveToSet(GLBufferObject* to, GLBufferObjectSet* set) set->addToBack(to); } +unsigned int GLBufferObjectSet::computeNumGLBufferObjectsInList() const +{ + unsigned int num=0; + GLBufferObject* obj = _head; + while(obj!=NULL) + { + ++num; + obj = obj->_next; + } + return num; +} GLBufferObjectManager::GLBufferObjectManager(unsigned int contextID): @@ -1085,14 +1096,17 @@ void GLBufferObjectManager::newFrame(osg::FrameStamp* fs) ++_numFrames; } -void GLBufferObjectManager::reportStats() +void GLBufferObjectManager::reportStats(std::ostream& out) { double numFrames(_numFrames==0 ? 1.0 : _numFrames); - OSG_NOTICE<<"GLBufferObjectMananger::reportStats()"<second.get(); + numObjectsInLists += os->computeNumGLBufferObjectsInList(); + numActive += os->getNumOfGLBufferObjects(); + numOrphans += os->getNumOrphans(); + numPendingOrphans += os->getNumPendingOrphans(); + currentSize += os->getProfile()._size * (numObjectsInLists+numOrphans); + out<<" size="<getProfile()._size + <<", os->computeNumGLBufferObjectsInList()"<computeNumGLBufferObjectsInList() + <<", os->getNumOfGLBufferObjects()"<getNumOfGLBufferObjects() + <<", os->getNumOrphans()"<getNumOrphans() + <<", os->getNumPendingOrphans()"<getNumPendingOrphans() + <second.get(); + numObjectsInLists += os->computeNumTextureObjectsInList(); + numActive += os->getNumOfTextureObjects(); + numOrphans += os->getNumOrphans(); + numPendingOrphans += os->getNumPendingOrphans(); + currentSize += os->getProfile()._size * (numObjectsInLists+numOrphans); + out<<" size="<getProfile()._size + <<", os->computeNumGLBufferObjectsInList()"<computeNumTextureObjectsInList() + <<", os->getNumOfGLBufferObjects()"<getNumOfTextureObjects() + <<", os->getNumOrphans()"<getNumOrphans() + <<", os->getNumPendingOrphans()"<getNumPendingOrphans() + <