Fixed the GLBufferObjectSet::deleteAllGLBufferObjets() and TextureObjectSet::deletaAllTextureObjects() methods
and improved the checkConsistency() usage so it's now possible to switch if off completed from being compiled in.
This commit is contained in:
@@ -27,7 +27,11 @@
|
||||
#include <OpenThreads/ScopedLock>
|
||||
#include <OpenThreads/Mutex>
|
||||
|
||||
// #define CHECK_CONSISTENCY
|
||||
#if 0
|
||||
#define CHECK_CONSISTENCY checkConsistency();
|
||||
#else
|
||||
#define CHECK_CONSISTENCY
|
||||
#endif
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -424,10 +428,7 @@ GLBufferObjectSet::~GLBufferObjectSet()
|
||||
|
||||
bool GLBufferObjectSet::checkConsistency() const
|
||||
{
|
||||
#ifndef CHECK_CONSISTENCY
|
||||
return true;
|
||||
#else
|
||||
// OSG_NOTICE<<"GLBufferObjectSet::checkConsistency()"<<std::endl;
|
||||
OSG_NOTICE<<"GLBufferObjectSet::checkConsistency()"<<std::endl;
|
||||
// check consistency of linked list.
|
||||
unsigned int numInList = 0;
|
||||
GLBufferObject* to = _head;
|
||||
@@ -467,7 +468,6 @@ bool GLBufferObjectSet::checkConsistency() const
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLBufferObjectSet::handlePendingOrphandedGLBufferObjects()
|
||||
@@ -487,14 +487,6 @@ void GLBufferObjectSet::handlePendingOrphandedGLBufferObjects()
|
||||
_orphanedGLBufferObjects.push_back(to);
|
||||
|
||||
remove(to);
|
||||
|
||||
#if 0
|
||||
OSG_NOTICE<<" HPOTO after _head = "<<_head<<std::endl;
|
||||
OSG_NOTICE<<" HPOTO after _tail = "<<_tail<<std::endl;
|
||||
OSG_NOTICE<<" HPOTO after to->_previous = "<<to->_previous<<std::endl;
|
||||
OSG_NOTICE<<" HPOTO after to->_next = "<<to->_next<<std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -504,13 +496,25 @@ void GLBufferObjectSet::handlePendingOrphandedGLBufferObjects()
|
||||
|
||||
_pendingOrphanedGLBufferObjects.clear();
|
||||
|
||||
checkConsistency();
|
||||
CHECK_CONSISTENCY
|
||||
}
|
||||
|
||||
void GLBufferObjectSet::deleteAllGLBufferObjects()
|
||||
{
|
||||
// OSG_NOTICE<<"GLBufferObjectSet::deleteAllGLBufferObjects()"<<std::endl;
|
||||
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
if (!_pendingOrphanedGLBufferObjects.empty())
|
||||
{
|
||||
// OSG_NOTICE<<"GLBufferObjectSet::flushDeletedGLBufferObjects(..) handling orphans"<<std::endl;
|
||||
handlePendingOrphandedGLBufferObjects();
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_CONSISTENCY
|
||||
|
||||
unsigned int numOrphaned = 0;
|
||||
GLBufferObject* to = _head;
|
||||
while(to!=0)
|
||||
{
|
||||
@@ -519,8 +523,11 @@ void GLBufferObjectSet::deleteAllGLBufferObjects()
|
||||
to = to->_next;
|
||||
|
||||
_orphanedGLBufferObjects.push_back(glbo.get());
|
||||
|
||||
remove(glbo.get());
|
||||
|
||||
++numOrphaned;
|
||||
|
||||
ref_ptr<BufferObject> original_BufferObject = glbo->getBufferObject();
|
||||
if (original_BufferObject.valid())
|
||||
{
|
||||
@@ -529,8 +536,8 @@ void GLBufferObjectSet::deleteAllGLBufferObjects()
|
||||
}
|
||||
}
|
||||
|
||||
_head = 0;
|
||||
_tail = 0;
|
||||
_parent->getNumberOrphanedGLBufferObjects() += numOrphaned;
|
||||
_parent->getNumberActiveGLBufferObjects() -= numOrphaned;
|
||||
|
||||
// do the actual delete.
|
||||
flushAllDeletedGLBufferObjects();
|
||||
@@ -865,7 +872,7 @@ void GLBufferObjectSet::moveToBack(GLBufferObject* to)
|
||||
OSG_NOTICE<<" m2B after to->_previous = "<<to->_previous<<std::endl;
|
||||
OSG_NOTICE<<" m2B after to->_next = "<<to->_next<<std::endl;
|
||||
#endif
|
||||
checkConsistency();
|
||||
CHECK_CONSISTENCY
|
||||
}
|
||||
|
||||
void GLBufferObjectSet::addToBack(GLBufferObject* to)
|
||||
@@ -898,7 +905,7 @@ void GLBufferObjectSet::addToBack(GLBufferObject* to)
|
||||
OSG_NOTICE<<" a2B after to->_previous = "<<to->_previous<<std::endl;
|
||||
OSG_NOTICE<<" a2B after to->_next = "<<to->_next<<std::endl;
|
||||
#endif
|
||||
checkConsistency();
|
||||
CHECK_CONSISTENCY
|
||||
}
|
||||
|
||||
void GLBufferObjectSet::orphan(GLBufferObject* to)
|
||||
|
||||
@@ -47,8 +47,11 @@
|
||||
#define GL_STORAGE_SHARED_APPLE 0x85BF
|
||||
#endif
|
||||
|
||||
// #define DO_TIMING
|
||||
// #define CHECK_CONSISTENCY
|
||||
#if 0
|
||||
#define CHECK_CONSISTENCY checkConsistency();
|
||||
#else
|
||||
#define CHECK_CONSISTENCY
|
||||
#endif
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -178,10 +181,7 @@ Texture::TextureObjectSet::~TextureObjectSet()
|
||||
|
||||
bool Texture::TextureObjectSet::checkConsistency() const
|
||||
{
|
||||
#ifndef CHECK_CONSISTENCY
|
||||
return true;
|
||||
#else
|
||||
// OSG_NOTICE<<"TextureObjectSet::checkConsistency()"<<std::endl;
|
||||
OSG_NOTICE<<"TextureObjectSet::checkConsistency()"<<std::endl;
|
||||
// check consistency of linked list.
|
||||
unsigned int numInList = 0;
|
||||
Texture::TextureObject* to = _head;
|
||||
@@ -220,8 +220,9 @@ bool Texture::TextureObjectSet::checkConsistency() const
|
||||
return false;
|
||||
}
|
||||
|
||||
_parent->checkConsistency();
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::TextureObjectSet::handlePendingOrphandedTextureObjects()
|
||||
@@ -241,14 +242,6 @@ void Texture::TextureObjectSet::handlePendingOrphandedTextureObjects()
|
||||
_orphanedTextureObjects.push_back(to);
|
||||
|
||||
remove(to);
|
||||
|
||||
#if 0
|
||||
OSG_NOTICE<<" HPOTO after _head = "<<_head<<std::endl;
|
||||
OSG_NOTICE<<" HPOTO after _tail = "<<_tail<<std::endl;
|
||||
OSG_NOTICE<<" HPOTO after to->_previous = "<<to->_previous<<std::endl;
|
||||
OSG_NOTICE<<" HPOTO after to->_next = "<<to->_next<<std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -258,7 +251,7 @@ void Texture::TextureObjectSet::handlePendingOrphandedTextureObjects()
|
||||
|
||||
_pendingOrphanedTextureObjects.clear();
|
||||
|
||||
checkConsistency();
|
||||
CHECK_CONSISTENCY
|
||||
}
|
||||
|
||||
|
||||
@@ -266,6 +259,17 @@ void Texture::TextureObjectSet::deleteAllTextureObjects()
|
||||
{
|
||||
// OSG_NOTICE<<"Texture::TextureObjectSet::deleteAllTextureObjects()"<<std::endl;
|
||||
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
if (!_pendingOrphanedTextureObjects.empty())
|
||||
{
|
||||
// OSG_NOTICE<<"Texture::TextureObjectSet::flushDeletedTextureObjects(..) handling orphans"<<std::endl;
|
||||
handlePendingOrphandedTextureObjects();
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_CONSISTENCY
|
||||
|
||||
// detect all the active texture objects from their Textures
|
||||
unsigned int numOrphaned = 0;
|
||||
TextureObject* to = _head;
|
||||
@@ -636,7 +640,7 @@ void Texture::TextureObjectSet::moveToBack(Texture::TextureObject* to)
|
||||
OSG_NOTICE<<" m2B after to->_previous = "<<to->_previous<<std::endl;
|
||||
OSG_NOTICE<<" m2B after to->_next = "<<to->_next<<std::endl;
|
||||
#endif
|
||||
checkConsistency();
|
||||
CHECK_CONSISTENCY
|
||||
}
|
||||
|
||||
void Texture::TextureObjectSet::addToBack(Texture::TextureObject* to)
|
||||
@@ -669,7 +673,7 @@ void Texture::TextureObjectSet::addToBack(Texture::TextureObject* to)
|
||||
OSG_NOTICE<<" a2B after to->_previous = "<<to->_previous<<std::endl;
|
||||
OSG_NOTICE<<" a2B after to->_next = "<<to->_next<<std::endl;
|
||||
#endif
|
||||
checkConsistency();
|
||||
CHECK_CONSISTENCY
|
||||
}
|
||||
|
||||
void Texture::TextureObjectSet::orphan(Texture::TextureObject* to)
|
||||
|
||||
Reference in New Issue
Block a user