Removed redundental vertex buffer object flush methods
This commit is contained in:
parent
c33695d2e5
commit
6d3a90219c
@ -454,22 +454,6 @@ class OSG_EXPORT Drawable : public Object
|
||||
* in the OpenGL context related to contextID.*/
|
||||
static void flushDeletedDisplayLists(unsigned int contextID,double& availableTime);
|
||||
|
||||
/** Use deleteVertexBufferObject instead of glDeleteBuffers to allow
|
||||
* OpenGL buffer objects to be cached until they can be deleted
|
||||
* by the OpenGL context in which they were created, specified
|
||||
* by contextID.*/
|
||||
static void deleteVertexBufferObject(unsigned int contextID,GLuint globj);
|
||||
|
||||
/** Flush all the cached vertex buffer objects which need to be deleted
|
||||
* in the OpenGL context related to contextID.*/
|
||||
static void flushDeletedVertexBufferObjects(unsigned int contextID,double currentTime, double& availableTime);
|
||||
|
||||
/** Flush all the cached vertex buffer objects which need to be deleted
|
||||
* in the OpenGL context related to contextID.
|
||||
* Note, unlike flush no OpenGL calls are made, instead the handles are all removed.
|
||||
* this call is useful for when an OpenGL context has been destroyed. */
|
||||
static void discardDeletedVertexBufferObjects(unsigned int contextID);
|
||||
|
||||
typedef unsigned int AttributeType;
|
||||
|
||||
enum AttributeTypes
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
using namespace osg;
|
||||
|
||||
// static cache of deleted display lists which can only
|
||||
// static cache of deleted buffer object lists which can only
|
||||
// by completely deleted once the appropriate OpenGL context
|
||||
// is set. Used osg::BufferObject::deleteDisplayList(..) and flushDeletedBufferObjects(..) below.
|
||||
typedef std::multimap<unsigned int,GLuint> DisplayListMap;
|
||||
|
@ -194,70 +194,11 @@ void Drawable::flushDeletedDisplayLists(unsigned int contextID, double& availabl
|
||||
}
|
||||
elapsedTime = timer.delta_s(start_tick,timer.tick());
|
||||
|
||||
// if (noDeleted) notify(NOTICE)<<"Number display lists deleted = "<<noDeleted<<" elapsed time"<<elapsedTime<<std::endl;
|
||||
if (noDeleted!=0) notify(INFO)<<"Number display lists deleted = "<<noDeleted<<" elapsed time"<<elapsedTime<<std::endl;
|
||||
|
||||
availableTime -= elapsedTime;
|
||||
}
|
||||
|
||||
|
||||
static OpenThreads::Mutex s_mutex_deletedVertexBufferObjectCache;
|
||||
static DeletedDisplayListCache s_deletedVertexBufferObjectCache;
|
||||
|
||||
void Drawable::deleteVertexBufferObject(unsigned int contextID,GLuint globj)
|
||||
{
|
||||
if (globj!=0)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexBufferObjectCache);
|
||||
|
||||
// insert the globj into the cache for the appropriate context.
|
||||
s_deletedVertexBufferObjectCache[contextID].insert(DisplayListMap::value_type(0,globj));
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::flushDeletedVertexBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime)
|
||||
{
|
||||
// if no time available don't try to flush objects.
|
||||
if (availableTime<=0.0) return;
|
||||
|
||||
const osg::Timer& timer = *osg::Timer::instance();
|
||||
osg::Timer_t start_tick = timer.tick();
|
||||
double elapsedTime = 0.0;
|
||||
|
||||
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexBufferObjectCache);
|
||||
|
||||
const Extensions* extensions = getExtensions(contextID,true);
|
||||
|
||||
unsigned int noDeleted = 0;
|
||||
|
||||
DisplayListMap& dll = s_deletedVertexBufferObjectCache[contextID];
|
||||
|
||||
DisplayListMap::iterator ditr=dll.begin();
|
||||
for(;
|
||||
ditr!=dll.end() && elapsedTime<availableTime;
|
||||
++ditr)
|
||||
{
|
||||
extensions->glDeleteBuffers(1,&(ditr->second));
|
||||
elapsedTime = timer.delta_s(start_tick,timer.tick());
|
||||
++noDeleted;
|
||||
}
|
||||
if (ditr!=dll.begin()) dll.erase(dll.begin(),ditr);
|
||||
|
||||
if (noDeleted!=0) notify(osg::INFO)<<"Number VBOs deleted = "<<noDeleted<<std::endl;
|
||||
}
|
||||
|
||||
availableTime -= elapsedTime;
|
||||
}
|
||||
|
||||
void Drawable::discardDeletedVertexBufferObjects(unsigned int contextID)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexBufferObjectCache);
|
||||
DisplayListMap& dll = s_deletedVertexBufferObjectCache[contextID];
|
||||
dll.clear();
|
||||
}
|
||||
|
||||
|
||||
Drawable::Drawable()
|
||||
:Object(true)
|
||||
{
|
||||
|
@ -25,7 +25,6 @@ void osg::flushDeletedGLObjects(unsigned int contextID, double currentTime, doub
|
||||
{
|
||||
osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime);
|
||||
osg::Drawable::flushDeletedDisplayLists(contextID,availableTime);
|
||||
osg::Drawable::flushDeletedVertexBufferObjects(contextID,currentTime,availableTime);
|
||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime);
|
||||
osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime);
|
||||
osg::Program::flushDeletedGlPrograms(contextID,currentTime,availableTime);
|
||||
@ -42,7 +41,6 @@ void osg::flushAllDeletedGLObjects(unsigned int contextID)
|
||||
double availableTime = DBL_MAX;
|
||||
osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime);
|
||||
osg::Drawable::flushAllDeletedDisplayLists(contextID);
|
||||
osg::Drawable::flushDeletedVertexBufferObjects(contextID,currentTime,availableTime);
|
||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime);
|
||||
osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime);
|
||||
osg::Program::flushDeletedGlPrograms(contextID,currentTime,availableTime);
|
||||
@ -57,7 +55,6 @@ void osg::discardAllDeletedGLObjects(unsigned int contextID)
|
||||
{
|
||||
osg::BufferObject::discardDeletedBufferObjects(contextID);
|
||||
osg::Drawable::discardAllDeletedDisplayLists(contextID);
|
||||
osg::Drawable::discardDeletedVertexBufferObjects(contextID);
|
||||
osg::FragmentProgram::discardDeletedFragmentProgramObjects(contextID);
|
||||
osg::FrameBufferObject::discardDeletedFrameBufferObjects(contextID);
|
||||
osg::Program::discardDeletedGlPrograms(contextID);
|
||||
|
Loading…
Reference in New Issue
Block a user