Introduced new osg::discardDeletedOpenGLObjects() methods, and usage of it in
GrpahicsContext::close() to handle cases where deletingOpenGLObjects is no possible, such as when GraphicsWindowEmbedded is used.
This commit is contained in:
parent
f3448d3307
commit
ff565128af
@ -157,6 +157,12 @@ class OSG_EXPORT BufferObject : public Object
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime);
|
static void flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime);
|
||||||
|
|
||||||
|
/** dicard all the cached display list 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 discardDeletedBufferObjects(unsigned int contextID);
|
||||||
|
|
||||||
/** Extensions class which encapsulates the querying of extensions and
|
/** Extensions class which encapsulates the querying of extensions and
|
||||||
* associated function pointers, and provide convenience wrappers to
|
* associated function pointers, and provide convenience wrappers to
|
||||||
* check for the extensions or use the associated functions.*/
|
* check for the extensions or use the associated functions.*/
|
||||||
|
@ -444,6 +444,12 @@ class OSG_EXPORT Drawable : public Object
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushAllDeletedDisplayLists(unsigned int contextID);
|
static void flushAllDeletedDisplayLists(unsigned int contextID);
|
||||||
|
|
||||||
|
/** Flush all the cached display list 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 discardAllDeletedDisplayLists(unsigned int contextID);
|
||||||
|
|
||||||
/** Flush the cached display list which need to be deleted
|
/** Flush the cached display list which need to be deleted
|
||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedDisplayLists(unsigned int contextID,double& availableTime);
|
static void flushDeletedDisplayLists(unsigned int contextID,double& availableTime);
|
||||||
@ -458,6 +464,12 @@ class OSG_EXPORT Drawable : public Object
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedVertexBufferObjects(unsigned int contextID,double currentTime, double& availableTime);
|
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;
|
typedef unsigned int AttributeType;
|
||||||
|
|
||||||
enum AttributeTypes
|
enum AttributeTypes
|
||||||
|
@ -216,6 +216,12 @@ class OSG_EXPORT FragmentProgram : public StateAttribute
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedFragmentProgramObjects(unsigned int contextID,double currentTime, double& availableTime);
|
static void flushDeletedFragmentProgramObjects(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
|
/** discard all the cached fragment programs 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 discardDeletedFragmentProgramObjects(unsigned int contextID);
|
||||||
|
|
||||||
virtual void apply(State& state) const;
|
virtual void apply(State& state) const;
|
||||||
|
|
||||||
virtual void compileGLObjects(State& state) const { apply(state); }
|
virtual void compileGLObjects(State& state) const { apply(state); }
|
||||||
|
@ -171,6 +171,10 @@ namespace osg
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedRenderBuffers(unsigned int contextID,double currentTime, double& availableTime);
|
static void flushDeletedRenderBuffers(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
|
/** discard all the cached RenderBuffers 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 discardDeletedRenderBuffers(unsigned int contextID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~RenderBuffer();
|
virtual ~RenderBuffer();
|
||||||
@ -315,6 +319,10 @@ namespace osg
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedFrameBufferObjects(unsigned int contextID,double currentTime, double& availableTime);
|
static void flushDeletedFrameBufferObjects(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
|
/** discard all the cached FBOs which need to be deleted
|
||||||
|
* in the OpenGL context related to contextID.*/
|
||||||
|
static void discardDeletedFrameBufferObjects(unsigned int contextID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~FrameBufferObject();
|
virtual ~FrameBufferObject();
|
||||||
FrameBufferObject& operator = (const FrameBufferObject&) { return *this; }
|
FrameBufferObject& operator = (const FrameBufferObject&) { return *this; }
|
||||||
|
@ -26,6 +26,12 @@ extern OSG_EXPORT void flushDeletedGLObjects(unsigned int contextID, double curr
|
|||||||
* Note, must be called from a thread which has current the graphics context associated with contextID. */
|
* Note, must be called from a thread which has current the graphics context associated with contextID. */
|
||||||
extern OSG_EXPORT void flushAllDeletedGLObjects(unsigned int contextID);
|
extern OSG_EXPORT void flushAllDeletedGLObjects(unsigned int contextID);
|
||||||
|
|
||||||
|
/** Discard all deleted OpenGL objects.
|
||||||
|
* Note, unlike flushAllDeletedObjectObjects discard does not
|
||||||
|
* do any OpenGL calls so can be called from any thread, but as a consequence it
|
||||||
|
* also doesn't remove the associated OpenGL resource so discard should only be
|
||||||
|
* called when the associated graphics context is being/has been closed. */
|
||||||
|
extern OSG_EXPORT void discardAllDeletedGLObjects(unsigned int contextID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,12 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedGlPrograms(unsigned int contextID,double currentTime, double& availableTime);
|
static void flushDeletedGlPrograms(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
|
/** discard all the cached glPrograms 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 discardDeletedGlPrograms(unsigned int contextID);
|
||||||
|
|
||||||
struct ActiveVarInfo {
|
struct ActiveVarInfo {
|
||||||
ActiveVarInfo() : _location(-1), _type(Uniform::UNDEFINED), _size(-1) {}
|
ActiveVarInfo() : _location(-1), _type(Uniform::UNDEFINED), _size(-1) {}
|
||||||
ActiveVarInfo( GLint loc, GLenum type, GLint size ) : _location(loc), _type(type), _size(size) {}
|
ActiveVarInfo( GLint loc, GLenum type, GLint size ) : _location(loc), _type(type), _size(size) {}
|
||||||
|
@ -114,6 +114,11 @@ class OSG_EXPORT Shader : public osg::Object
|
|||||||
* in the OpenGL context related to contextID.*/
|
* in the OpenGL context related to contextID.*/
|
||||||
static void flushDeletedGlShaders(unsigned int contextID,double currentTime, double& availableTime);
|
static void flushDeletedGlShaders(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
|
/** discard all the cached glShaders 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 discardDeletedGlShaders(unsigned int contextID);
|
||||||
|
|
||||||
static Shader::Type getTypeId( const std::string& tname );
|
static Shader::Type getTypeId( const std::string& tname );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -886,6 +886,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
|||||||
static unsigned int getMinimumNumberOfTextureObjectsToRetainInCache();
|
static unsigned int getMinimumNumberOfTextureObjectsToRetainInCache();
|
||||||
|
|
||||||
static void flushAllDeletedTextureObjects(unsigned int contextID);
|
static void flushAllDeletedTextureObjects(unsigned int contextID);
|
||||||
|
|
||||||
|
static void discardAllDeletedTextureObjects(unsigned int contextID);
|
||||||
|
|
||||||
static void flushDeletedTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
|
static void flushDeletedTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
|
@ -217,6 +217,13 @@ class OSG_EXPORT VertexProgram : public StateAttribute
|
|||||||
*/
|
*/
|
||||||
static void flushDeletedVertexProgramObjects(unsigned int contextID,double currentTime, double& availableTime);
|
static void flushDeletedVertexProgramObjects(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
|
/** discard all the cached vertex programs 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 discardDeletedVertexProgramObjects(unsigned int contextID);
|
||||||
|
|
||||||
virtual void apply(State& state) const;
|
virtual void apply(State& state) const;
|
||||||
|
|
||||||
virtual void compileGLObjects(State& state) const { apply(state); }
|
virtual void compileGLObjects(State& state) const { apply(state); }
|
||||||
|
@ -48,8 +48,6 @@ void BufferObject::deleteBufferObject(unsigned int contextID,GLuint globj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** flush all the cached display list which need to be deleted
|
|
||||||
* in the OpenGL context related to contextID.*/
|
|
||||||
void BufferObject::flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime)
|
void BufferObject::flushDeletedBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime)
|
||||||
{
|
{
|
||||||
// if no time available don't try to flush objects.
|
// if no time available don't try to flush objects.
|
||||||
@ -86,6 +84,13 @@ void BufferObject::flushDeletedBufferObjects(unsigned int contextID,double /*cur
|
|||||||
availableTime -= elapsedTime;
|
availableTime -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferObject::discardDeletedBufferObjects(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedBufferObjectCache);
|
||||||
|
DisplayListMap& dll = s_deletedBufferObjectCache[contextID];
|
||||||
|
dll.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BufferObject::BufferObject():
|
BufferObject::BufferObject():
|
||||||
_target(0),
|
_target(0),
|
||||||
|
@ -116,6 +116,14 @@ void Drawable::flushAllDeletedDisplayLists(unsigned int contextID)
|
|||||||
dll.clear();
|
dll.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Drawable::discardAllDeletedDisplayLists(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedDisplayListCache);
|
||||||
|
|
||||||
|
DisplayListMap& dll = s_deletedDisplayListCache[contextID];
|
||||||
|
dll.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void Drawable::flushDeletedDisplayLists(unsigned int contextID, double& availableTime)
|
void Drawable::flushDeletedDisplayLists(unsigned int contextID, double& availableTime)
|
||||||
{
|
{
|
||||||
// if no time available don't try to flush objects.
|
// if no time available don't try to flush objects.
|
||||||
@ -206,8 +214,6 @@ void Drawable::deleteVertexBufferObject(unsigned int contextID,GLuint globj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** flush all the cached display lists which need to be deleted
|
|
||||||
* in the OpenGL context related to contextID.*/
|
|
||||||
void Drawable::flushDeletedVertexBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime)
|
void Drawable::flushDeletedVertexBufferObjects(unsigned int contextID,double /*currentTime*/, double& availableTime)
|
||||||
{
|
{
|
||||||
// if no time available don't try to flush objects.
|
// if no time available don't try to flush objects.
|
||||||
@ -244,6 +250,13 @@ void Drawable::flushDeletedVertexBufferObjects(unsigned int contextID,double /*c
|
|||||||
availableTime -= elapsedTime;
|
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()
|
Drawable::Drawable()
|
||||||
:Object(true)
|
:Object(true)
|
||||||
|
@ -73,6 +73,13 @@ void FragmentProgram::flushDeletedFragmentProgramObjects(unsigned int contextID,
|
|||||||
availableTime -= elapsedTime;
|
availableTime -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FragmentProgram::discardDeletedFragmentProgramObjects(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedFragmentProgramObjectCache);
|
||||||
|
FragmentProgramObjectList& vpol = s_deletedFragmentProgramObjectCache[contextID];
|
||||||
|
vpol.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FragmentProgram::FragmentProgram()
|
FragmentProgram::FragmentProgram()
|
||||||
{
|
{
|
||||||
|
@ -132,6 +132,13 @@ void RenderBuffer::flushDeletedRenderBuffers(unsigned int contextID,double /*cur
|
|||||||
availableTime -= elapsedTime;
|
availableTime -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderBuffer::discardDeletedRenderBuffers(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedRenderBufferCache);
|
||||||
|
RenderBufferHandleList& pList = s_deletedRenderBufferCache[contextID];
|
||||||
|
pList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RenderBuffer::RenderBuffer()
|
RenderBuffer::RenderBuffer()
|
||||||
: Object(),
|
: Object(),
|
||||||
@ -532,6 +539,14 @@ void FrameBufferObject::flushDeletedFrameBufferObjects(unsigned int contextID,do
|
|||||||
availableTime -= elapsedTime;
|
availableTime -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameBufferObject::discardDeletedFrameBufferObjects(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedFrameBufferObjectCache);
|
||||||
|
FrameBufferObjectHandleList& pList = s_deletedFrameBufferObjectCache[contextID];
|
||||||
|
|
||||||
|
pList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FrameBufferObject::FrameBufferObject()
|
FrameBufferObject::FrameBufferObject()
|
||||||
|
@ -22,31 +22,44 @@
|
|||||||
|
|
||||||
void osg::flushDeletedGLObjects(unsigned int contextID, double currentTime, double& availableTime)
|
void osg::flushDeletedGLObjects(unsigned int contextID, double currentTime, double& availableTime)
|
||||||
{
|
{
|
||||||
osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime);
|
osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime);
|
||||||
osg::RenderBuffer::flushDeletedRenderBuffers(contextID,currentTime,availableTime);
|
|
||||||
osg::Texture::flushDeletedTextureObjects(contextID,currentTime,availableTime);
|
|
||||||
osg::Drawable::flushDeletedDisplayLists(contextID,availableTime);
|
osg::Drawable::flushDeletedDisplayLists(contextID,availableTime);
|
||||||
osg::Drawable::flushDeletedVertexBufferObjects(contextID,currentTime,availableTime);
|
osg::Drawable::flushDeletedVertexBufferObjects(contextID,currentTime,availableTime);
|
||||||
osg::VertexProgram::flushDeletedVertexProgramObjects(contextID,currentTime,availableTime);
|
|
||||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime);
|
osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime);
|
||||||
|
osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime);
|
||||||
osg::Program::flushDeletedGlPrograms(contextID,currentTime,availableTime);
|
osg::Program::flushDeletedGlPrograms(contextID,currentTime,availableTime);
|
||||||
|
osg::RenderBuffer::flushDeletedRenderBuffers(contextID,currentTime,availableTime);
|
||||||
osg::Shader::flushDeletedGlShaders(contextID,currentTime,availableTime);
|
osg::Shader::flushDeletedGlShaders(contextID,currentTime,availableTime);
|
||||||
osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime);
|
osg::Texture::flushDeletedTextureObjects(contextID,currentTime,availableTime);
|
||||||
|
osg::VertexProgram::flushDeletedVertexProgramObjects(contextID,currentTime,availableTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void osg::flushAllDeletedGLObjects(unsigned int contextID)
|
void osg::flushAllDeletedGLObjects(unsigned int contextID)
|
||||||
{
|
{
|
||||||
double currentTime = DBL_MAX;
|
double currentTime = DBL_MAX;
|
||||||
double availableTime = DBL_MAX;
|
double availableTime = DBL_MAX;
|
||||||
osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime);
|
osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime);
|
||||||
osg::RenderBuffer::flushDeletedRenderBuffers(contextID,currentTime,availableTime);
|
|
||||||
osg::Texture::flushAllDeletedTextureObjects(contextID);
|
|
||||||
osg::Drawable::flushAllDeletedDisplayLists(contextID);
|
osg::Drawable::flushAllDeletedDisplayLists(contextID);
|
||||||
osg::Drawable::flushDeletedVertexBufferObjects(contextID,currentTime,availableTime);
|
osg::Drawable::flushDeletedVertexBufferObjects(contextID,currentTime,availableTime);
|
||||||
osg::VertexProgram::flushDeletedVertexProgramObjects(contextID,currentTime,availableTime);
|
|
||||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime);
|
osg::FragmentProgram::flushDeletedFragmentProgramObjects(contextID,currentTime,availableTime);
|
||||||
|
osg::FrameBufferObject::flushDeletedFrameBufferObjects(contextID,currentTime,availableTime);
|
||||||
osg::Program::flushDeletedGlPrograms(contextID,currentTime,availableTime);
|
osg::Program::flushDeletedGlPrograms(contextID,currentTime,availableTime);
|
||||||
|
osg::RenderBuffer::flushDeletedRenderBuffers(contextID,currentTime,availableTime);
|
||||||
osg::Shader::flushDeletedGlShaders(contextID,currentTime,availableTime);
|
osg::Shader::flushDeletedGlShaders(contextID,currentTime,availableTime);
|
||||||
osg::BufferObject::flushDeletedBufferObjects(contextID,currentTime,availableTime);
|
osg::Texture::flushAllDeletedTextureObjects(contextID);
|
||||||
|
osg::VertexProgram::flushDeletedVertexProgramObjects(contextID,currentTime,availableTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
osg::RenderBuffer::discardDeletedRenderBuffers(contextID);
|
||||||
|
osg::Shader::discardDeletedGlShaders(contextID);
|
||||||
|
osg::Texture::discardAllDeletedTextureObjects(contextID);
|
||||||
|
osg::VertexProgram::discardDeletedVertexProgramObjects(contextID);
|
||||||
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <osg/GraphicsContext>
|
#include <osg/GraphicsContext>
|
||||||
#include <osg/Camera>
|
#include <osg/Camera>
|
||||||
#include <osg/View>
|
#include <osg/View>
|
||||||
|
#include <osg/GLObjects>
|
||||||
|
|
||||||
#include <osg/FrameBufferObject>
|
#include <osg/FrameBufferObject>
|
||||||
#include <osg/Program>
|
#include <osg/Program>
|
||||||
@ -464,21 +465,9 @@ void GraphicsContext::close(bool callCloseImplementation)
|
|||||||
|
|
||||||
osg::notify(osg::INFO)<<"Doing Flush"<<std::endl;
|
osg::notify(osg::INFO)<<"Doing Flush"<<std::endl;
|
||||||
|
|
||||||
// flush all the OpenGL object buffer for this context.
|
osg::flushAllDeletedGLObjects(_state->getContextID());
|
||||||
double availableTime = 100.0f;
|
|
||||||
double currentTime = _state->getFrameStamp()?_state->getFrameStamp()->getReferenceTime():0.0;
|
|
||||||
|
|
||||||
osg::FrameBufferObject::flushDeletedFrameBufferObjects(_state->getContextID(),currentTime,availableTime);
|
osg::notify(osg::INFO)<<"Done Flush "<<std::endl;
|
||||||
osg::RenderBuffer::flushDeletedRenderBuffers(_state->getContextID(),currentTime,availableTime);
|
|
||||||
osg::Texture::flushAllDeletedTextureObjects(_state->getContextID());
|
|
||||||
osg::Drawable::flushAllDeletedDisplayLists(_state->getContextID());
|
|
||||||
osg::Drawable::flushDeletedVertexBufferObjects(_state->getContextID(),currentTime,availableTime);
|
|
||||||
osg::VertexProgram::flushDeletedVertexProgramObjects(_state->getContextID(),currentTime,availableTime);
|
|
||||||
osg::FragmentProgram::flushDeletedFragmentProgramObjects(_state->getContextID(),currentTime,availableTime);
|
|
||||||
osg::Program::flushDeletedGlPrograms(_state->getContextID(),currentTime,availableTime);
|
|
||||||
osg::Shader::flushDeletedGlShaders(_state->getContextID(),currentTime,availableTime);
|
|
||||||
|
|
||||||
osg::notify(osg::INFO)<<"Done Flush "<<availableTime<<std::endl;
|
|
||||||
|
|
||||||
_state->reset();
|
_state->reset();
|
||||||
|
|
||||||
@ -486,12 +475,23 @@ void GraphicsContext::close(bool callCloseImplementation)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osg::notify(osg::INFO)<<"makeCurrent did not succedd, could not do flush/deletion of OpenGL objects."<<std::endl;
|
osg::notify(osg::INFO)<<"makeCurrent did not succeed, could not do flush/deletion of OpenGL objects."<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callCloseImplementation) closeImplementation();
|
if (callCloseImplementation) closeImplementation();
|
||||||
|
|
||||||
|
|
||||||
|
// now discard any deleted deleted OpenGL objects that the are still hanging around - such as due to
|
||||||
|
// the the flushDelete*() methods not being invoked, such as when using GraphicContextEmbedded where makeCurrent
|
||||||
|
// does not work.
|
||||||
|
if (_state.valid())
|
||||||
|
{
|
||||||
|
osg::notify(osg::INFO)<<"Doing discard of deleted OpenGL objects."<<std::endl;
|
||||||
|
|
||||||
|
osg::discardAllDeletedGLObjects(_state->getContextID());
|
||||||
|
}
|
||||||
|
|
||||||
if (_state.valid())
|
if (_state.valid())
|
||||||
{
|
{
|
||||||
decrementContextIDUsageCount(_state->getContextID());
|
decrementContextIDUsageCount(_state->getContextID());
|
||||||
|
@ -1977,6 +1977,13 @@ void Program::flushDeletedGlPrograms(unsigned int contextID,double /*currentTime
|
|||||||
availableTime -= elapsedTime;
|
availableTime -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Program::discardDeletedGlPrograms(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedGlProgramCache);
|
||||||
|
GlProgramHandleList& pList = s_deletedGlProgramCache[contextID];
|
||||||
|
pList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// osg::Program
|
// osg::Program
|
||||||
|
@ -83,6 +83,13 @@ void Shader::flushDeletedGlShaders(unsigned int contextID,double /*currentTime*/
|
|||||||
availableTime -= elapsedTime;
|
availableTime -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Shader::discardDeletedGlShaders(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedGlShaderCache);
|
||||||
|
|
||||||
|
GlShaderHandleList& pList = s_deletedGlShaderCache[contextID];
|
||||||
|
pList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// osg::Shader
|
// osg::Shader
|
||||||
|
@ -101,6 +101,8 @@ public:
|
|||||||
|
|
||||||
void flushAllTextureObjects(unsigned int contextID);
|
void flushAllTextureObjects(unsigned int contextID);
|
||||||
|
|
||||||
|
void discardAllTextureObjects(unsigned int contextID);
|
||||||
|
|
||||||
void flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
|
void flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime);
|
||||||
|
|
||||||
void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
|
void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
|
||||||
@ -238,6 +240,14 @@ void TextureObjectManager::flushAllTextureObjects(unsigned int contextID)
|
|||||||
tol.clear();
|
tol.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureObjectManager::discardAllTextureObjects(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||||
|
|
||||||
|
Texture::TextureObjectList& tol = _textureObjectListMap[contextID];
|
||||||
|
tol.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void TextureObjectManager::flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime)
|
void TextureObjectManager::flushTextureObjects(unsigned int contextID,double currentTime, double& availableTime)
|
||||||
{
|
{
|
||||||
// if no time available don't try to flush objects.
|
// if no time available don't try to flush objects.
|
||||||
@ -334,6 +344,11 @@ void Texture::flushAllDeletedTextureObjects(unsigned int contextID)
|
|||||||
if (getTextureObjectManager()) getTextureObjectManager()->flushAllTextureObjects(contextID);
|
if (getTextureObjectManager()) getTextureObjectManager()->flushAllTextureObjects(contextID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::discardAllDeletedTextureObjects(unsigned int contextID)
|
||||||
|
{
|
||||||
|
if (getTextureObjectManager()) getTextureObjectManager()->discardAllTextureObjects(contextID);
|
||||||
|
}
|
||||||
|
|
||||||
void Texture::flushDeletedTextureObjects(unsigned int contextID,double currentTime, double& availbleTime)
|
void Texture::flushDeletedTextureObjects(unsigned int contextID,double currentTime, double& availbleTime)
|
||||||
{
|
{
|
||||||
if (getTextureObjectManager()) getTextureObjectManager()->flushTextureObjects(contextID, currentTime, availbleTime);
|
if (getTextureObjectManager()) getTextureObjectManager()->flushTextureObjects(contextID, currentTime, availbleTime);
|
||||||
|
@ -73,6 +73,13 @@ void VertexProgram::flushDeletedVertexProgramObjects(unsigned int contextID,doub
|
|||||||
availableTime -= elapsedTime;
|
availableTime -= elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VertexProgram::discardDeletedVertexProgramObjects(unsigned int contextID)
|
||||||
|
{
|
||||||
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_mutex_deletedVertexProgramObjectCache);
|
||||||
|
VertexProgramObjectList& vpol = s_deletedVertexProgramObjectCache[contextID];
|
||||||
|
vpol.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VertexProgram::VertexProgram()
|
VertexProgram::VertexProgram()
|
||||||
{
|
{
|
||||||
|
@ -119,6 +119,10 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::BufferObject)
|
|||||||
__void__flushDeletedBufferObjects__unsigned_int__double__double_R1_S,
|
__void__flushDeletedBufferObjects__unsigned_int__double__double_R1_S,
|
||||||
"flush all the cached display list which need to be deleted in the OpenGL context related to contextID. ",
|
"flush all the cached display list which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedBufferObjects, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedBufferObjects__unsigned_int_S,
|
||||||
|
"dicard all the cached display list 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. ");
|
||||||
I_StaticMethod2(osg::BufferObject::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
I_StaticMethod2(osg::BufferObject::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
||||||
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
||||||
"Function to call to get the extension of a specified context. ",
|
"Function to call to get the extension of a specified context. ",
|
||||||
|
@ -408,6 +408,10 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Drawable)
|
|||||||
__void__flushAllDeletedDisplayLists__unsigned_int_S,
|
__void__flushAllDeletedDisplayLists__unsigned_int_S,
|
||||||
"Flush all the cached display list which need to be deleted in the OpenGL context related to contextID. ",
|
"Flush all the cached display list which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardAllDeletedDisplayLists, IN, unsigned int, contextID,
|
||||||
|
__void__discardAllDeletedDisplayLists__unsigned_int_S,
|
||||||
|
"Flush all the cached display list 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. ");
|
||||||
I_StaticMethod2(void, flushDeletedDisplayLists, IN, unsigned int, contextID, IN, double &, availableTime,
|
I_StaticMethod2(void, flushDeletedDisplayLists, IN, unsigned int, contextID, IN, double &, availableTime,
|
||||||
__void__flushDeletedDisplayLists__unsigned_int__double_R1_S,
|
__void__flushDeletedDisplayLists__unsigned_int__double_R1_S,
|
||||||
"Flush the cached display list which need to be deleted in the OpenGL context related to contextID. ",
|
"Flush the cached display list which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
@ -420,6 +424,10 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Drawable)
|
|||||||
__void__flushDeletedVertexBufferObjects__unsigned_int__double__double_R1_S,
|
__void__flushDeletedVertexBufferObjects__unsigned_int__double__double_R1_S,
|
||||||
"Flush all the cached vertex buffer objects which need to be deleted in the OpenGL context related to contextID. ",
|
"Flush all the cached vertex buffer objects which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedVertexBufferObjects, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedVertexBufferObjects__unsigned_int_S,
|
||||||
|
"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. ");
|
||||||
I_StaticMethod2(osg::Drawable::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
I_StaticMethod2(osg::Drawable::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
||||||
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
||||||
"Function to call to get the extension of a specified context. ",
|
"Function to call to get the extension of a specified context. ",
|
||||||
|
@ -173,6 +173,10 @@ BEGIN_OBJECT_REFLECTOR(osg::FragmentProgram)
|
|||||||
__void__flushDeletedFragmentProgramObjects__unsigned_int__double__double_R1_S,
|
__void__flushDeletedFragmentProgramObjects__unsigned_int__double__double_R1_S,
|
||||||
"flush all the cached fragment programs which need to be deleted in the OpenGL context related to contextID. ",
|
"flush all the cached fragment programs which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedFragmentProgramObjects, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedFragmentProgramObjects__unsigned_int_S,
|
||||||
|
"discard all the cached fragment programs 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. ");
|
||||||
I_StaticMethod2(osg::FragmentProgram::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
I_StaticMethod2(osg::FragmentProgram::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
||||||
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
||||||
"Function to call to get the extension of a specified context. ",
|
"Function to call to get the extension of a specified context. ",
|
||||||
|
@ -237,6 +237,10 @@ BEGIN_OBJECT_REFLECTOR(osg::FrameBufferObject)
|
|||||||
__void__flushDeletedFrameBufferObjects__unsigned_int__double__double_R1_S,
|
__void__flushDeletedFrameBufferObjects__unsigned_int__double__double_R1_S,
|
||||||
"flush all the cached FBOs which need to be deleted in the OpenGL context related to contextID. ",
|
"flush all the cached FBOs which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedFrameBufferObjects, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedFrameBufferObjects__unsigned_int_S,
|
||||||
|
"discard all the cached FBOs which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
|
"");
|
||||||
I_ProtectedMethod0(void, dirtyAll,
|
I_ProtectedMethod0(void, dirtyAll,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
Properties::NON_CONST,
|
Properties::NON_CONST,
|
||||||
@ -347,6 +351,10 @@ BEGIN_OBJECT_REFLECTOR(osg::RenderBuffer)
|
|||||||
__void__flushDeletedRenderBuffers__unsigned_int__double__double_R1_S,
|
__void__flushDeletedRenderBuffers__unsigned_int__double__double_R1_S,
|
||||||
"flush all the cached RenderBuffers which need to be deleted in the OpenGL context related to contextID. ",
|
"flush all the cached RenderBuffers which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedRenderBuffers, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedRenderBuffers__unsigned_int_S,
|
||||||
|
"discard all the cached RenderBuffers 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. ");
|
||||||
I_ProtectedMethod0(void, dirtyAll,
|
I_ProtectedMethod0(void, dirtyAll,
|
||||||
Properties::NON_VIRTUAL,
|
Properties::NON_VIRTUAL,
|
||||||
Properties::CONST,
|
Properties::CONST,
|
||||||
|
@ -195,6 +195,10 @@ BEGIN_OBJECT_REFLECTOR(osg::Program)
|
|||||||
__void__flushDeletedGlPrograms__unsigned_int__double__double_R1_S,
|
__void__flushDeletedGlPrograms__unsigned_int__double__double_R1_S,
|
||||||
"flush all the cached glPrograms which need to be deleted in the OpenGL context related to contextID. ",
|
"flush all the cached glPrograms which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedGlPrograms, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedGlPrograms__unsigned_int_S,
|
||||||
|
"discard all the cached glPrograms 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. ");
|
||||||
I_SimpleProperty(const osg::Program::AttribBindingList &, AttribBindingList,
|
I_SimpleProperty(const osg::Program::AttribBindingList &, AttribBindingList,
|
||||||
__C5_AttribBindingList_R1__getAttribBindingList,
|
__C5_AttribBindingList_R1__getAttribBindingList,
|
||||||
0);
|
0);
|
||||||
|
@ -153,6 +153,10 @@ BEGIN_OBJECT_REFLECTOR(osg::Shader)
|
|||||||
__void__flushDeletedGlShaders__unsigned_int__double__double_R1_S,
|
__void__flushDeletedGlShaders__unsigned_int__double__double_R1_S,
|
||||||
"flush all the cached glShaders which need to be deleted in the OpenGL context related to contextID. ",
|
"flush all the cached glShaders which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedGlShaders, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedGlShaders__unsigned_int_S,
|
||||||
|
"discard all the cached glShaders 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. ");
|
||||||
I_StaticMethod1(osg::Shader::Type, getTypeId, IN, const std::string &, tname,
|
I_StaticMethod1(osg::Shader::Type, getTypeId, IN, const std::string &, tname,
|
||||||
__Shader_Type__getTypeId__C5_std_string_R1_S,
|
__Shader_Type__getTypeId__C5_std_string_R1_S,
|
||||||
"",
|
"",
|
||||||
|
@ -475,6 +475,10 @@ BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::Texture)
|
|||||||
__void__flushAllDeletedTextureObjects__unsigned_int_S,
|
__void__flushAllDeletedTextureObjects__unsigned_int_S,
|
||||||
"",
|
"",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardAllDeletedTextureObjects, IN, unsigned int, contextID,
|
||||||
|
__void__discardAllDeletedTextureObjects__unsigned_int_S,
|
||||||
|
"",
|
||||||
|
"");
|
||||||
I_StaticMethod3(void, flushDeletedTextureObjects, IN, unsigned int, contextID, IN, double, currentTime, IN, double &, availableTime,
|
I_StaticMethod3(void, flushDeletedTextureObjects, IN, unsigned int, contextID, IN, double, currentTime, IN, double &, availableTime,
|
||||||
__void__flushDeletedTextureObjects__unsigned_int__double__double_R1_S,
|
__void__flushDeletedTextureObjects__unsigned_int__double__double_R1_S,
|
||||||
"",
|
"",
|
||||||
|
@ -173,6 +173,10 @@ BEGIN_OBJECT_REFLECTOR(osg::VertexProgram)
|
|||||||
__void__flushDeletedVertexProgramObjects__unsigned_int__double__double_R1_S,
|
__void__flushDeletedVertexProgramObjects__unsigned_int__double__double_R1_S,
|
||||||
"Flush all the cached vertex programs which need to be deleted in the OpenGL context related to contextID. ",
|
"Flush all the cached vertex programs which need to be deleted in the OpenGL context related to contextID. ",
|
||||||
"");
|
"");
|
||||||
|
I_StaticMethod1(void, discardDeletedVertexProgramObjects, IN, unsigned int, contextID,
|
||||||
|
__void__discardDeletedVertexProgramObjects__unsigned_int_S,
|
||||||
|
"discard all the cached vertex programs 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. ");
|
||||||
I_StaticMethod2(osg::VertexProgram::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
I_StaticMethod2(osg::VertexProgram::Extensions *, getExtensions, IN, unsigned int, contextID, IN, bool, createIfNotInitalized,
|
||||||
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
__Extensions_P1__getExtensions__unsigned_int__bool_S,
|
||||||
"Function to call to get the extension of a specified context. ",
|
"Function to call to get the extension of a specified context. ",
|
||||||
|
Loading…
Reference in New Issue
Block a user