diff --git a/include/osg/BufferObject b/include/osg/BufferObject index 3ac8b1de8..9d8e480ec 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -528,6 +528,14 @@ class OSG_EXPORT BufferObject : public Object BufferObjectProfile& getProfile() { return _profile; } const BufferObjectProfile& getProfile() const { return _profile; } + + /** Set whether the BufferObject should use a GLBufferObject just for copying the BufferData and release it immmediately so that it may be reused.*/ + void setCopyDataAndReleaseGLBufferObject(bool copyAndRelease) { _copyDataAndReleaseGLBufferObject = copyAndRelease; } + + /** Get whether the BufferObject should use a GLBufferObject just for copying the BufferData and release it immmediately.*/ + bool getCopyDataAndReleaseGLBufferObject() const { return _copyDataAndReleaseGLBufferObject; } + + void dirty(); /** Resize any per context GLObject buffers to specified size. */ @@ -572,6 +580,8 @@ class OSG_EXPORT BufferObject : public Object BufferObjectProfile _profile; + bool _copyDataAndReleaseGLBufferObject; + BufferDataList _bufferDataList; mutable GLBufferObjects _glBufferObjects; diff --git a/include/osgUtil/IncrementalCompileOperation b/include/osgUtil/IncrementalCompileOperation index 87fd0912c..efeeec892 100644 --- a/include/osgUtil/IncrementalCompileOperation +++ b/include/osgUtil/IncrementalCompileOperation @@ -39,6 +39,7 @@ class OSGUTIL_EXPORT StateToCompile : public osg::NodeVisitor TextureSet _textures; ProgramSet _programs; bool _assignPBOToImages; + osg::ref_ptr _pbo; bool empty() const { return _textures.empty() && _programs.empty() && _drawables.empty(); } @@ -48,6 +49,7 @@ class OSGUTIL_EXPORT StateToCompile : public osg::NodeVisitor virtual void apply(osg::Drawable& drawable); virtual void apply(osg::StateSet& stateset); virtual void apply(osg::Texture& texture); + }; class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation diff --git a/src/osg/BufferObject.cpp b/src/osg/BufferObject.cpp index d93419942..4c5d3feb4 100644 --- a/src/osg/BufferObject.cpp +++ b/src/osg/BufferObject.cpp @@ -741,7 +741,7 @@ GLBufferObject* GLBufferObjectSet::takeFromOrphans(BufferObject* bufferObject) // place at back of active list addToBack(glbo.get()); - OSG_INFO<<"Reusing orphaned GLBufferObject, _numOfGLBufferObjects="<<_numOfGLBufferObjects<releaseGLObjects(&state); + } } #ifdef DO_TIMING diff --git a/src/osgUtil/IncrementalCompileOperation.cpp b/src/osgUtil/IncrementalCompileOperation.cpp index 9b1b5e87b..0a863fbb5 100644 --- a/src/osgUtil/IncrementalCompileOperation.cpp +++ b/src/osgUtil/IncrementalCompileOperation.cpp @@ -23,8 +23,9 @@ #include #include -#include #include +#include +#include namespace osgUtil { @@ -46,6 +47,7 @@ namespace osgUtil static osg::ApplicationUsageProxy ICO_e1(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MINIMUM_COMPILE_TIME_PER_FRAME ","minimum compile time alloted to compiling OpenGL objects per frame in database pager."); static osg::ApplicationUsageProxy UCO_e2(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAXIMUM_OBJECTS_TO_COMPILE_PER_FRAME ","maximum number of OpenGL objects to compile per frame in database pager."); +static osg::ApplicationUsageProxy UCO_e3(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_FORCE_TEXTURE_DOWNLOAD ","should the texture compiles be forced to download using a dummy Geometry."); ///////////////////////////////////////////////////////////////// // @@ -183,7 +185,11 @@ void StateToCompile::apply(osg::Texture& texture) if (numRequringPBO>0) { // assign pbo - if (!pbo) pbo = new osg::PixelBufferObject; + if (!pbo) + { + if (!_pbo) _pbo = new osg::PixelBufferObject; + pbo = _pbo; + } for(unsigned int i=0; igetPixelBufferObject()) { //OSG_NOTICE<<"Assigning PBO"<setCopyDataAndReleaseGLBufferObject(true); + pbo->setUsage(GL_DYNAMIC_DRAW_ARB); image->setPixelBufferObject(pbo.get()); } } @@ -443,7 +451,20 @@ IncrementalCompileOperation::IncrementalCompileOperation(): _maximumNumOfObjectsToCompilePerFrame = atoi(ptr); } - // assignForceTextureDownloadGeometry(); + bool useForceTextureDownload = false; + if( (ptr = getenv("OSG_FORCE_TEXTURE_DOWNLOAD")) != 0) + { + useForceTextureDownload = strcmp(ptr,"yes")==0 || strcmp(ptr,"YES")==0 || + strcmp(ptr,"on")==0 || strcmp(ptr,"ON")==0; + + OSG_NOTICE<<"OSG_FORCE_TEXTURE_DOWNLOAD set to "<