Added methods for checking sizes of various buffer object/texture object pool sizes.
This commit is contained in:
@@ -187,10 +187,10 @@ public:
|
||||
|
||||
void report(std::ostream& out)
|
||||
{
|
||||
OSG_NOTICE<<"Nodes "<<_nodes.size()<<std::endl;
|
||||
OSG_NOTICE<<"Geometries "<<_geometryMap.size()<<std::endl;
|
||||
OSG_NOTICE<<"Arrays "<<_arrayMap.size()<<std::endl;
|
||||
OSG_NOTICE<<"PrimitiveSets "<<_primitiveSetMap.size()<<std::endl;
|
||||
out<<"Nodes "<<_nodes.size()<<std::endl;
|
||||
out<<"Geometries "<<_geometryMap.size()<<std::endl;
|
||||
out<<"Arrays "<<_arrayMap.size()<<std::endl;
|
||||
out<<"PrimitiveSets "<<_primitiveSetMap.size()<<std::endl;
|
||||
}
|
||||
|
||||
void reallocate()
|
||||
@@ -551,8 +551,8 @@ public:
|
||||
{
|
||||
if (ea.getKey()=='r')
|
||||
{
|
||||
osg::Texture::getTextureObjectManager(0)->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;
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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()"<<std::endl;
|
||||
OSG_NOTICE<<" total _numOfGLBufferObjects="<<_numActiveGLBufferObjects<<", _numOrphanedGLBufferObjects="<<_numOrphanedGLBufferObjects<<" _currGLBufferObjectPoolSize="<<_currGLBufferObjectPoolSize<<std::endl;
|
||||
OSG_NOTICE<<" total _numGenerated="<<_numGenerated<<", _generateTime="<<_generateTime<<", averagePerFrame="<<_generateTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
OSG_NOTICE<<" total _numDeleted="<<_numDeleted<<", _deleteTime="<<_deleteTime<<", averagePerFrame="<<_deleteTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
OSG_NOTICE<<" total _numApplied="<<_numApplied<<", _applyTime="<<_applyTime<<", averagePerFrame="<<_applyTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
out<<"GLBufferObjectMananger::reportStats()"<<std::endl;
|
||||
out<<" total _numOfGLBufferObjects="<<_numActiveGLBufferObjects<<", _numOrphanedGLBufferObjects="<<_numOrphanedGLBufferObjects<<" _currGLBufferObjectPoolSize="<<_currGLBufferObjectPoolSize<<std::endl;
|
||||
out<<" total _numGenerated="<<_numGenerated<<", _generateTime="<<_generateTime<<", averagePerFrame="<<_generateTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
out<<" total _numDeleted="<<_numDeleted<<", _deleteTime="<<_deleteTime<<", averagePerFrame="<<_deleteTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
out<<" total _numApplied="<<_numApplied<<", _applyTime="<<_applyTime<<", averagePerFrame="<<_applyTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
|
||||
recomputeStats(out);
|
||||
|
||||
}
|
||||
|
||||
void GLBufferObjectManager::resetStats()
|
||||
@@ -1108,6 +1122,33 @@ void GLBufferObjectManager::resetStats()
|
||||
_applyTime = 0;
|
||||
}
|
||||
|
||||
void GLBufferObjectManager::recomputeStats(std::ostream& out)
|
||||
{
|
||||
out<<"GLBufferObjectMananger::recomputeStats()"<<std::endl;
|
||||
unsigned int numObjectsInLists = 0;
|
||||
unsigned int numActive = 0;
|
||||
unsigned int numOrphans = 0;
|
||||
unsigned int numPendingOrphans = 0;
|
||||
unsigned int currentSize = 0;
|
||||
for(GLBufferObjectSetMap::iterator itr = _glBufferObjectSetMap.begin();
|
||||
itr != _glBufferObjectSetMap.end();
|
||||
++itr)
|
||||
{
|
||||
GLBufferObjectSet* os = itr->second.get();
|
||||
numObjectsInLists += os->computeNumGLBufferObjectsInList();
|
||||
numActive += os->getNumOfGLBufferObjects();
|
||||
numOrphans += os->getNumOrphans();
|
||||
numPendingOrphans += os->getNumPendingOrphans();
|
||||
currentSize += os->getProfile()._size * (numObjectsInLists+numOrphans);
|
||||
out<<" size="<<os->getProfile()._size
|
||||
<<", os->computeNumGLBufferObjectsInList()"<<os->computeNumGLBufferObjectsInList()
|
||||
<<", os->getNumOfGLBufferObjects()"<<os->getNumOfGLBufferObjects()
|
||||
<<", os->getNumOrphans()"<<os->getNumOrphans()
|
||||
<<", os->getNumPendingOrphans()"<<os->getNumPendingOrphans()
|
||||
<<std::endl;
|
||||
}
|
||||
out<<" numObjectsInLists="<<numObjectsInLists<<", numActive="<<numActive<<", numOrphans="<<numOrphans<<" currentSize="<<currentSize<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<GLBufferObjectManager>& GLBufferObjectManager::getGLBufferObjectManager(unsigned int contextID)
|
||||
|
||||
@@ -732,6 +732,18 @@ void Texture::TextureObjectSet::moveToSet(TextureObject* to, TextureObjectSet* s
|
||||
set->addToBack(to);
|
||||
}
|
||||
|
||||
unsigned int Texture::TextureObjectSet::computeNumTextureObjectsInList() const
|
||||
{
|
||||
unsigned int num=0;
|
||||
TextureObject* obj = _head;
|
||||
while(obj!=NULL)
|
||||
{
|
||||
++num;
|
||||
obj = obj->_next;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
Texture::TextureObjectManager::TextureObjectManager(unsigned int contextID):
|
||||
_contextID(contextID),
|
||||
@@ -901,14 +913,16 @@ void Texture::TextureObjectManager::newFrame(osg::FrameStamp* fs)
|
||||
++_numFrames;
|
||||
}
|
||||
|
||||
void Texture::TextureObjectManager::reportStats()
|
||||
void Texture::TextureObjectManager::reportStats(std::ostream& out)
|
||||
{
|
||||
double numFrames(_numFrames==0 ? 1.0 : _numFrames);
|
||||
OSG_NOTICE<<"TextureObjectMananger::reportStats()"<<std::endl;
|
||||
OSG_NOTICE<<" total _numOfTextureObjects="<<_numActiveTextureObjects<<", _numOrphanedTextureObjects="<<_numOrphanedTextureObjects<<" _currTexturePoolSize="<<_currTexturePoolSize<<std::endl;
|
||||
OSG_NOTICE<<" total _numGenerated="<<_numGenerated<<", _generateTime="<<_generateTime<<", averagePerFrame="<<_generateTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
OSG_NOTICE<<" total _numDeleted="<<_numDeleted<<", _deleteTime="<<_deleteTime<<", averagePerFrame="<<_deleteTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
OSG_NOTICE<<" total _numApplied="<<_numApplied<<", _applyTime="<<_applyTime<<", averagePerFrame="<<_applyTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
out<<"TextureObjectMananger::reportStats()"<<std::endl;
|
||||
out<<" total _numOfTextureObjects="<<_numActiveTextureObjects<<", _numOrphanedTextureObjects="<<_numOrphanedTextureObjects<<" _currTexturePoolSize="<<_currTexturePoolSize<<std::endl;
|
||||
out<<" total _numGenerated="<<_numGenerated<<", _generateTime="<<_generateTime<<", averagePerFrame="<<_generateTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
out<<" total _numDeleted="<<_numDeleted<<", _deleteTime="<<_deleteTime<<", averagePerFrame="<<_deleteTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
out<<" total _numApplied="<<_numApplied<<", _applyTime="<<_applyTime<<", averagePerFrame="<<_applyTime/numFrames*1000.0<<"ms"<<std::endl;
|
||||
|
||||
recomputeStats(out);
|
||||
}
|
||||
|
||||
void Texture::TextureObjectManager::resetStats()
|
||||
@@ -925,6 +939,34 @@ void Texture::TextureObjectManager::resetStats()
|
||||
}
|
||||
|
||||
|
||||
void Texture::TextureObjectManager::recomputeStats(std::ostream& out)
|
||||
{
|
||||
out<<"Texture::TextureObjectManager::recomputeStats()"<<std::endl;
|
||||
unsigned int numObjectsInLists = 0;
|
||||
unsigned int numActive = 0;
|
||||
unsigned int numOrphans = 0;
|
||||
unsigned int numPendingOrphans = 0;
|
||||
unsigned int currentSize = 0;
|
||||
for(TextureSetMap::iterator itr = _textureSetMap.begin();
|
||||
itr != _textureSetMap.end();
|
||||
++itr)
|
||||
{
|
||||
TextureObjectSet* os = itr->second.get();
|
||||
numObjectsInLists += os->computeNumTextureObjectsInList();
|
||||
numActive += os->getNumOfTextureObjects();
|
||||
numOrphans += os->getNumOrphans();
|
||||
numPendingOrphans += os->getNumPendingOrphans();
|
||||
currentSize += os->getProfile()._size * (numObjectsInLists+numOrphans);
|
||||
out<<" size="<<os->getProfile()._size
|
||||
<<", os->computeNumGLBufferObjectsInList()"<<os->computeNumTextureObjectsInList()
|
||||
<<", os->getNumOfGLBufferObjects()"<<os->getNumOfTextureObjects()
|
||||
<<", os->getNumOrphans()"<<os->getNumOrphans()
|
||||
<<", os->getNumPendingOrphans()"<<os->getNumPendingOrphans()
|
||||
<<std::endl;
|
||||
}
|
||||
out<<" numObjectsInLists="<<numObjectsInLists<<", numActive="<<numActive<<", numOrphans="<<numOrphans<<" currentSize="<<currentSize<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
osg::ref_ptr<Texture::TextureObjectManager>& Texture::getTextureObjectManager(unsigned int contextID)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user