Added support for enabling the assignment of PixelBufferObjects to loaded Images to aid the download of images to the GPU.

Feature can be enabled/disabled (default) by setting the env :

   OSG_ASSIGN_PBO_TO_IMAGES  to ON or OFF
This commit is contained in:
Robert Osfield
2011-02-04 12:43:00 +00:00
parent d218a8c9a7
commit e0924886bd
2 changed files with 30 additions and 9 deletions

View File

@@ -216,6 +216,13 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
DrawablePolicy getDrawablePolicy() const { return _drawablePolicy; } DrawablePolicy getDrawablePolicy() const { return _drawablePolicy; }
/** Set whether newly loaded textures should have a PixelBufferObject assigned to them to aid download to the GPU.*/
void setApplyPBOToImages(bool assignPBOToImages) { _assignPBOToImages = assignPBOToImages; }
/** Get whether newly loaded textures should have a PixelBufferObject assigned to them..*/
bool getApplyPBOToImages() const { return _assignPBOToImages; }
/** Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/ /** Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
void setUnrefImageDataAfterApplyPolicy(bool changeAutoUnRef, bool valueAutoUnRef) { _changeAutoUnRef = changeAutoUnRef; _valueAutoUnRef = valueAutoUnRef; } void setUnrefImageDataAfterApplyPolicy(bool changeAutoUnRef, bool valueAutoUnRef) { _changeAutoUnRef = changeAutoUnRef; _valueAutoUnRef = valueAutoUnRef; }
@@ -439,6 +446,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
DrawablePolicy _drawablePolicy; DrawablePolicy _drawablePolicy;
bool _assignPBOToImages;
bool _changeAutoUnRef; bool _changeAutoUnRef;
bool _valueAutoUnRef; bool _valueAutoUnRef;
bool _changeAnisotropy; bool _changeAnisotropy;

View File

@@ -47,6 +47,7 @@ static osg::ApplicationUsageProxy DatabasePager_e0(osg::ApplicationUsage::ENVIRO
static osg::ApplicationUsageProxy DatabasePager_e3(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_DRAWABLE <mode>","Set the drawable policy for setting of loaded drawable to specified type. mode can be one of DoNotModify, DisplayList, VBO or VertexArrays>."); static osg::ApplicationUsageProxy DatabasePager_e3(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_DRAWABLE <mode>","Set the drawable policy for setting of loaded drawable to specified type. mode can be one of DoNotModify, DisplayList, VBO or VertexArrays>.");
static osg::ApplicationUsageProxy DatabasePager_e4(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_PRIORITY <mode>", "Set the thread priority to DEFAULT, MIN, LOW, NOMINAL, HIGH or MAX."); static osg::ApplicationUsageProxy DatabasePager_e4(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_PRIORITY <mode>", "Set the thread priority to DEFAULT, MIN, LOW, NOMINAL, HIGH or MAX.");
static osg::ApplicationUsageProxy DatabasePager_e11(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_PAGEDLOD <num>","Set the target maximum number of PagedLOD to maintain."); static osg::ApplicationUsageProxy DatabasePager_e11(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_PAGEDLOD <num>","Set the target maximum number of PagedLOD to maintain.");
static osg::ApplicationUsageProxy DatabasePager_e12(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_ASSIGN_PBO_TO_IMAGES <ON/OFF>","Set whether PixelBufferObjects should be assigned to Images to aid download to the GPU.");
// Convert function objects that take pointer args into functions that a // Convert function objects that take pointer args into functions that a
// reference to an osg::ref_ptr. This is quite useful for doing STL // reference to an osg::ref_ptr. This is quite useful for doing STL
@@ -297,6 +298,8 @@ public:
_changeAutoUnRef(false), _valueAutoUnRef(false), _changeAutoUnRef(false), _valueAutoUnRef(false),
_changeAnisotropy(false), _valueAnisotropy(1.0) _changeAnisotropy(false), _valueAnisotropy(1.0)
{ {
_assignPBOToImages = _pager->_assignPBOToImages;
_changeAutoUnRef = _pager->_changeAutoUnRef; _changeAutoUnRef = _pager->_changeAutoUnRef;
_valueAutoUnRef = _pager->_valueAutoUnRef; _valueAutoUnRef = _pager->_valueAutoUnRef;
_changeAnisotropy = _pager->_changeAnisotropy; _changeAnisotropy = _pager->_changeAnisotropy;
@@ -988,35 +991,43 @@ DatabasePager::DatabasePager()
} }
} }
_assignPBOToImages = false;
if( (str = getenv("OSG_ASSIGN_PBO_TO_IMAGES")) != 0)
{
_assignPBOToImages = strcmp(str,"yes")==0 || strcmp(str,"YES")==0 ||
strcmp(str,"on")==0 || strcmp(str,"ON")==0;
OSG_NOTICE<<"OSG_ASSIGN_PBO_TO_IMAGES set to "<<_assignPBOToImages<<std::endl;
}
_changeAutoUnRef = true; _changeAutoUnRef = true;
_valueAutoUnRef = false; _valueAutoUnRef = false;
_changeAnisotropy = false; _changeAnisotropy = false;
_valueAnisotropy = 1.0f; _valueAnisotropy = 1.0f;
const char* ptr=0;
_deleteRemovedSubgraphsInDatabaseThread = true; _deleteRemovedSubgraphsInDatabaseThread = true;
if( (ptr = getenv("OSG_DELETE_IN_DATABASE_THREAD")) != 0) if( (str = getenv("OSG_DELETE_IN_DATABASE_THREAD")) != 0)
{ {
_deleteRemovedSubgraphsInDatabaseThread = strcmp(ptr,"yes")==0 || strcmp(ptr,"YES")==0 || _deleteRemovedSubgraphsInDatabaseThread = strcmp(str,"yes")==0 || strcmp(str,"YES")==0 ||
strcmp(ptr,"on")==0 || strcmp(ptr,"ON")==0; strcmp(str,"on")==0 || strcmp(str,"ON")==0;
} }
_targetMaximumNumberOfPageLOD = 300; _targetMaximumNumberOfPageLOD = 300;
if( (ptr = getenv("OSG_MAX_PAGEDLOD")) != 0) if( (str = getenv("OSG_MAX_PAGEDLOD")) != 0)
{ {
_targetMaximumNumberOfPageLOD = atoi(ptr); _targetMaximumNumberOfPageLOD = atoi(str);
OSG_NOTICE<<"_targetMaximumNumberOfPageLOD = "<<_targetMaximumNumberOfPageLOD<<std::endl; OSG_NOTICE<<"_targetMaximumNumberOfPageLOD = "<<_targetMaximumNumberOfPageLOD<<std::endl;
} }
_doPreCompile = true; _doPreCompile = true;
if( (ptr = getenv("OSG_DO_PRE_COMPILE")) != 0) if( (str = getenv("OSG_DO_PRE_COMPILE")) != 0)
{ {
_doPreCompile = strcmp(ptr,"yes")==0 || strcmp(ptr,"YES")==0 || _doPreCompile = strcmp(str,"yes")==0 || strcmp(str,"YES")==0 ||
strcmp(ptr,"on")==0 || strcmp(ptr,"ON")==0; strcmp(str,"on")==0 || strcmp(str,"ON")==0;
} }
// initialize the stats variables // initialize the stats variables
@@ -1079,6 +1090,8 @@ DatabasePager::DatabasePager(const DatabasePager& rhs)
_drawablePolicy = rhs._drawablePolicy; _drawablePolicy = rhs._drawablePolicy;
_assignPBOToImages = rhs._assignPBOToImages;
_changeAutoUnRef = rhs._changeAutoUnRef; _changeAutoUnRef = rhs._changeAutoUnRef;
_valueAutoUnRef = rhs._valueAutoUnRef; _valueAutoUnRef = rhs._valueAutoUnRef;
_changeAnisotropy = rhs._changeAnisotropy; _changeAnisotropy = rhs._changeAnisotropy;