Added DatabasePager::s/getDrawablePolicy() to allow the way that the display list/VBO settings
are applied to loaded databases.
This commit is contained in:
parent
85b3c4b179
commit
f77b38ae9c
@ -166,24 +166,38 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
|||||||
* before being removed.*/
|
* before being removed.*/
|
||||||
double getExpiryDelay() const { return _expiryDelay; }
|
double getExpiryDelay() const { return _expiryDelay; }
|
||||||
|
|
||||||
/** set whether the removed subgraphs should be deleted in the database thread or not.*/
|
/** Set whether the removed subgraphs should be deleted in the database thread or not.*/
|
||||||
void setDeleteRemovedSubgraphsInDatabaseThread(bool flag) { _deleteRemovedSubgraphsInDatabaseThread = flag; }
|
void setDeleteRemovedSubgraphsInDatabaseThread(bool flag) { _deleteRemovedSubgraphsInDatabaseThread = flag; }
|
||||||
|
|
||||||
/** get whether the removed subgraphs should be deleted in the database thread or not.*/
|
/** Get whether the removed subgraphs should be deleted in the database thread or not.*/
|
||||||
bool getDeleteRemovedSubgraphsInDatabaseThread() const { return _deleteRemovedSubgraphsInDatabaseThread; }
|
bool getDeleteRemovedSubgraphsInDatabaseThread() const { return _deleteRemovedSubgraphsInDatabaseThread; }
|
||||||
|
|
||||||
|
enum DrawablePolicy
|
||||||
|
{
|
||||||
|
DO_NOT_MODIFY_DRAWABLE_SETTINGS,
|
||||||
|
USE_DISPLAY_LISTS,
|
||||||
|
USE_VERTEX_BUFFER_OBJECTS,
|
||||||
|
USE_VERTEX_ARRAYS
|
||||||
|
};
|
||||||
|
|
||||||
/** set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
|
/** Set how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.*/
|
||||||
|
void setDrawablePolicy(DrawablePolicy policy) { _drawablePolicy = policy; }
|
||||||
|
|
||||||
|
/** Get how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.*/
|
||||||
|
DrawablePolicy getDrawablePolicy() const { return _drawablePolicy; }
|
||||||
|
|
||||||
|
|
||||||
|
/** 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; }
|
||||||
|
|
||||||
/** get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
|
/** Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.*/
|
||||||
void getUnrefImageDataAfterApplyPolicy(bool& changeAutoUnRef, bool& valueAutoUnRef) const { changeAutoUnRef = _changeAutoUnRef; valueAutoUnRef = _valueAutoUnRef; }
|
void getUnrefImageDataAfterApplyPolicy(bool& changeAutoUnRef, bool& valueAutoUnRef) const { changeAutoUnRef = _changeAutoUnRef; valueAutoUnRef = _valueAutoUnRef; }
|
||||||
|
|
||||||
|
|
||||||
/** set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
|
/** Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
|
||||||
void setMaxAnisotropyPolicy(bool changeAnisotropy, float valueAnisotropy) { _changeAnisotropy = changeAnisotropy; _valueAnisotropy = valueAnisotropy; }
|
void setMaxAnisotropyPolicy(bool changeAnisotropy, float valueAnisotropy) { _changeAnisotropy = changeAnisotropy; _valueAnisotropy = valueAnisotropy; }
|
||||||
|
|
||||||
/** set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
|
/** Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.*/
|
||||||
void getMaxAnisotropyPolicy(bool& changeAnisotropy, float& valueAnisotropy) const { changeAnisotropy = _changeAnisotropy; valueAnisotropy = _valueAnisotropy; }
|
void getMaxAnisotropyPolicy(bool& changeAnisotropy, float& valueAnisotropy) const { changeAnisotropy = _changeAnisotropy; valueAnisotropy = _valueAnisotropy; }
|
||||||
|
|
||||||
|
|
||||||
@ -310,6 +324,8 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
|||||||
DatabaseRequestList _dataToCompileList;
|
DatabaseRequestList _dataToCompileList;
|
||||||
mutable OpenThreads::Mutex _dataToCompileListMutex;
|
mutable OpenThreads::Mutex _dataToCompileListMutex;
|
||||||
|
|
||||||
|
DrawablePolicy _drawablePolicy;
|
||||||
|
|
||||||
bool _changeAutoUnRef;
|
bool _changeAutoUnRef;
|
||||||
bool _valueAutoUnRef;
|
bool _valueAutoUnRef;
|
||||||
bool _changeAnisotropy;
|
bool _changeAnisotropy;
|
||||||
|
@ -23,7 +23,7 @@ using namespace OpenThreads;
|
|||||||
static osg::ApplicationUsageProxy DatabasePager_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DO_PRE_COMPILE <ON/OFF>","Switch on or off the pre compile of OpenGL object database pager.");
|
static osg::ApplicationUsageProxy DatabasePager_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DO_PRE_COMPILE <ON/OFF>","Switch on or off the pre compile of OpenGL object database pager.");
|
||||||
static osg::ApplicationUsageProxy DatabasePager_e1(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MINIMUM_COMPILE_TIME_PER_FRAME <float>","minimum compile time alloted to compiling OpenGL objects per frame in database pager.");
|
static osg::ApplicationUsageProxy DatabasePager_e1(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MINIMUM_COMPILE_TIME_PER_FRAME <float>","minimum compile time alloted to compiling OpenGL objects per frame in database pager.");
|
||||||
static osg::ApplicationUsageProxy DatabasePager_e2(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAXIMUM_OBJECTS_TO_COMPILE_PER_FRAME <int>","maximum number of OpenGL objects to compile per frame in database pager.");
|
static osg::ApplicationUsageProxy DatabasePager_e2(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAXIMUM_OBJECTS_TO_COMPILE_PER_FRAME <int>","maximum number of OpenGL objects to compile per frame in database pager.");
|
||||||
|
static osg::ApplicationUsageProxy DatabasePager_e3(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_DATABASE_PAGER_DRAWABLE <DoNotModify/DisplayList/VBO/VertexArrays>","Set the drawable policy for setting of loaded drawable to specified type.");
|
||||||
DatabasePager::DatabasePager()
|
DatabasePager::DatabasePager()
|
||||||
{
|
{
|
||||||
//osg::notify(osg::INFO)<<"Constructing DatabasePager()"<<std::endl;
|
//osg::notify(osg::INFO)<<"Constructing DatabasePager()"<<std::endl;
|
||||||
@ -43,6 +43,36 @@ DatabasePager::DatabasePager()
|
|||||||
_threadPriorityDuringFrame = THREAD_PRIORITY_MIN;
|
_threadPriorityDuringFrame = THREAD_PRIORITY_MIN;
|
||||||
_threadPriorityOutwithFrame = THREAD_PRIORITY_MIN;
|
_threadPriorityOutwithFrame = THREAD_PRIORITY_MIN;
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
// OSX really doesn't like compiling display lists, and performs poorly when they are used,
|
||||||
|
// so apply this hack to make up for its short comings.
|
||||||
|
_drawablePolicy = USE_VERTEX_ARRAYS;
|
||||||
|
#else
|
||||||
|
_drawablePolicy = DO_NOT_MODIFY_DRAWABLE_SETTINGS;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char* str = getenv("OSG_DATABASE_PAGER_GEOMETRY");
|
||||||
|
if (!str) str = getenv("OSG_DATABASE_PAGER_DRAWABLE");
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
if (strcmp(str,"DoNotModify")==0)
|
||||||
|
{
|
||||||
|
_drawablePolicy = DO_NOT_MODIFY_DRAWABLE_SETTINGS;
|
||||||
|
}
|
||||||
|
else if (strcmp(str,"DisplayList")==0 || strcmp(str,"DL")==0)
|
||||||
|
{
|
||||||
|
_drawablePolicy = USE_DISPLAY_LISTS;
|
||||||
|
}
|
||||||
|
else if (strcmp(str,"VBO")==0)
|
||||||
|
{
|
||||||
|
_drawablePolicy = USE_VERTEX_BUFFER_OBJECTS;
|
||||||
|
}
|
||||||
|
else if (strcmp(str,"VertexArrays")==0 || strcmp(str,"VA")==0 )
|
||||||
|
{
|
||||||
|
_drawablePolicy = USE_VERTEX_ARRAYS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_changeAutoUnRef = true;
|
_changeAutoUnRef = true;
|
||||||
_valueAutoUnRef = true;
|
_valueAutoUnRef = true;
|
||||||
_changeAnisotropy = false;
|
_changeAnisotropy = false;
|
||||||
@ -288,38 +318,14 @@ class DatabasePager::FindCompileableGLObjectsVisitor : public osg::NodeVisitor
|
|||||||
public:
|
public:
|
||||||
FindCompileableGLObjectsVisitor(DatabasePager::DataToCompile& dataToCompile,
|
FindCompileableGLObjectsVisitor(DatabasePager::DataToCompile& dataToCompile,
|
||||||
bool changeAutoUnRef, bool valueAutoUnRef,
|
bool changeAutoUnRef, bool valueAutoUnRef,
|
||||||
bool changeAnisotropy, float valueAnisotropy):
|
bool changeAnisotropy, float valueAnisotropy,
|
||||||
|
DatabasePager::DrawablePolicy drawablePolicy):
|
||||||
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
|
||||||
_dataToCompile(dataToCompile),
|
_dataToCompile(dataToCompile),
|
||||||
_changeAutoUnRef(changeAutoUnRef), _valueAutoUnRef(valueAutoUnRef),
|
_changeAutoUnRef(changeAutoUnRef), _valueAutoUnRef(valueAutoUnRef),
|
||||||
_changeAnisotropy(changeAnisotropy), _valueAnisotropy(valueAnisotropy),
|
_changeAnisotropy(changeAnisotropy), _valueAnisotropy(valueAnisotropy),
|
||||||
_useDisplayLists(true),
|
_drawablePolicy(drawablePolicy)
|
||||||
_useVertexBufferObjects(false)
|
|
||||||
{
|
{
|
||||||
#if __APPLE__
|
|
||||||
_useDisplayLists = false;
|
|
||||||
_useVertexBufferObjects = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char* str = getenv("OSG_DATABASE_PAGER_GEOMETRY");
|
|
||||||
if (str)
|
|
||||||
{
|
|
||||||
if (strcmp(str,"DisplayList")==0 || strcmp(str,"DL")==0)
|
|
||||||
{
|
|
||||||
_useDisplayLists = true;
|
|
||||||
_useVertexBufferObjects = false;
|
|
||||||
}
|
|
||||||
else if (strcmp(str,"VBO")==0)
|
|
||||||
{
|
|
||||||
_useDisplayLists = true;
|
|
||||||
_useVertexBufferObjects = true;
|
|
||||||
}
|
|
||||||
else if (strcmp(str,"VertexArrays")==0 || strcmp(str,"VA")==0 )
|
|
||||||
{
|
|
||||||
_useDisplayLists = false;
|
|
||||||
_useVertexBufferObjects = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void apply(osg::Node& node)
|
virtual void apply(osg::Node& node)
|
||||||
@ -371,12 +377,31 @@ public:
|
|||||||
{
|
{
|
||||||
apply(drawable->getStateSet());
|
apply(drawable->getStateSet());
|
||||||
|
|
||||||
drawable->setUseDisplayList(_useDisplayLists);
|
switch(_drawablePolicy)
|
||||||
drawable->setUseVertexBufferObjects(_useVertexBufferObjects);
|
{
|
||||||
|
case DatabasePager::DO_NOT_MODIFY_DRAWABLE_SETTINGS:
|
||||||
|
// do nothing, leave settings as they came in from loaded database.
|
||||||
|
// osg::notify(osg::NOTICE)<<"DO_NOT_MODIFY_DRAWABLE_SETTINGS"<<std::endl;
|
||||||
|
break;
|
||||||
|
case DatabasePager::USE_DISPLAY_LISTS:
|
||||||
|
drawable->setUseDisplayList(true);
|
||||||
|
drawable->setUseVertexBufferObjects(false);
|
||||||
|
break;
|
||||||
|
case DatabasePager::USE_VERTEX_BUFFER_OBJECTS:
|
||||||
|
drawable->setUseDisplayList(true);
|
||||||
|
drawable->setUseVertexBufferObjects(true);
|
||||||
|
// osg::notify(osg::NOTICE)<<"USE_VERTEX_BUFFER_OBJECTS"<<std::endl;
|
||||||
|
break;
|
||||||
|
case DatabasePager::USE_VERTEX_ARRAYS:
|
||||||
|
drawable->setUseDisplayList(false);
|
||||||
|
drawable->setUseVertexBufferObjects(false);
|
||||||
|
// osg::notify(osg::NOTICE)<<"USE_VERTEX_ARRAYS"<<std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (drawable->getUseDisplayList() || drawable->getUseVertexBufferObjects())
|
if (drawable->getUseDisplayList() || drawable->getUseVertexBufferObjects())
|
||||||
{
|
{
|
||||||
//osg::notify(osg::INFO)<<"Found compilable drawable"<<std::endl;
|
// osg::notify(osg::NOTICE)<<" Found compilable drawable"<<std::endl;
|
||||||
_dataToCompile.second.push_back(drawable);
|
_dataToCompile.second.push_back(drawable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -386,8 +411,7 @@ public:
|
|||||||
bool _valueAutoUnRef;
|
bool _valueAutoUnRef;
|
||||||
bool _changeAnisotropy;
|
bool _changeAnisotropy;
|
||||||
float _valueAnisotropy;
|
float _valueAnisotropy;
|
||||||
bool _useDisplayLists;
|
DatabasePager::DrawablePolicy _drawablePolicy;
|
||||||
bool _useVertexBufferObjects;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -512,7 +536,8 @@ void DatabasePager::run()
|
|||||||
// find all the compileable rendering objects
|
// find all the compileable rendering objects
|
||||||
FindCompileableGLObjectsVisitor frov(dtc,
|
FindCompileableGLObjectsVisitor frov(dtc,
|
||||||
_changeAutoUnRef, _valueAutoUnRef,
|
_changeAutoUnRef, _valueAutoUnRef,
|
||||||
_changeAnisotropy, _valueAnisotropy);
|
_changeAnisotropy, _valueAnisotropy,
|
||||||
|
_drawablePolicy);
|
||||||
|
|
||||||
databaseRequest->_loadedModel->accept(frov);
|
databaseRequest->_loadedModel->accept(frov);
|
||||||
|
|
||||||
|
@ -39,6 +39,13 @@ TYPE_NAME_ALIAS(std::map< unsigned int COMMA osgDB::DatabasePager::DataToCompil
|
|||||||
|
|
||||||
TYPE_NAME_ALIAS(std::set< unsigned int >, osgDB::DatabasePager::ActiveGraphicsContexts);
|
TYPE_NAME_ALIAS(std::set< unsigned int >, osgDB::DatabasePager::ActiveGraphicsContexts);
|
||||||
|
|
||||||
|
BEGIN_ENUM_REFLECTOR(osgDB::DatabasePager::DrawablePolicy)
|
||||||
|
I_EnumLabel(osgDB::DatabasePager::DO_NOT_MODIFY_DRAWABLE_SETTINGS);
|
||||||
|
I_EnumLabel(osgDB::DatabasePager::USE_DISPLAY_LISTS);
|
||||||
|
I_EnumLabel(osgDB::DatabasePager::USE_VERTEX_BUFFER_OBJECTS);
|
||||||
|
I_EnumLabel(osgDB::DatabasePager::USE_VERTEX_ARRAYS);
|
||||||
|
END_REFLECTOR
|
||||||
|
|
||||||
BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager)
|
BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager)
|
||||||
I_BaseType(osg::NodeVisitor::DatabaseRequestHandler);
|
I_BaseType(osg::NodeVisitor::DatabaseRequestHandler);
|
||||||
I_Constructor0();
|
I_Constructor0();
|
||||||
@ -73,6 +80,8 @@ BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager)
|
|||||||
I_Method0(double, getExpiryDelay);
|
I_Method0(double, getExpiryDelay);
|
||||||
I_Method1(void, setDeleteRemovedSubgraphsInDatabaseThread, IN, bool, flag);
|
I_Method1(void, setDeleteRemovedSubgraphsInDatabaseThread, IN, bool, flag);
|
||||||
I_Method0(bool, getDeleteRemovedSubgraphsInDatabaseThread);
|
I_Method0(bool, getDeleteRemovedSubgraphsInDatabaseThread);
|
||||||
|
I_Method1(void, setDrawablePolicy, IN, osgDB::DatabasePager::DrawablePolicy, policy);
|
||||||
|
I_Method0(osgDB::DatabasePager::DrawablePolicy, getDrawablePolicy);
|
||||||
I_Method2(void, setUnrefImageDataAfterApplyPolicy, IN, bool, changeAutoUnRef, IN, bool, valueAutoUnRef);
|
I_Method2(void, setUnrefImageDataAfterApplyPolicy, IN, bool, changeAutoUnRef, IN, bool, valueAutoUnRef);
|
||||||
I_Method2(void, getUnrefImageDataAfterApplyPolicy, IN, bool &, changeAutoUnRef, IN, bool &, valueAutoUnRef);
|
I_Method2(void, getUnrefImageDataAfterApplyPolicy, IN, bool &, changeAutoUnRef, IN, bool &, valueAutoUnRef);
|
||||||
I_Method2(void, setMaxAnisotropyPolicy, IN, bool, changeAnisotropy, IN, float, valueAnisotropy);
|
I_Method2(void, setMaxAnisotropyPolicy, IN, bool, changeAnisotropy, IN, float, valueAnisotropy);
|
||||||
@ -88,6 +97,7 @@ BEGIN_OBJECT_REFLECTOR(osgDB::DatabasePager)
|
|||||||
I_Property(bool, DatabasePagerThreadPause);
|
I_Property(bool, DatabasePagerThreadPause);
|
||||||
I_Property(bool, DeleteRemovedSubgraphsInDatabaseThread);
|
I_Property(bool, DeleteRemovedSubgraphsInDatabaseThread);
|
||||||
I_Property(bool, DoPreCompile);
|
I_Property(bool, DoPreCompile);
|
||||||
|
I_Property(osgDB::DatabasePager::DrawablePolicy, DrawablePolicy);
|
||||||
I_Property(double, ExpiryDelay);
|
I_Property(double, ExpiryDelay);
|
||||||
I_ReadOnlyProperty(osg::Block *, FrameBlock);
|
I_ReadOnlyProperty(osg::Block *, FrameBlock);
|
||||||
I_Property(unsigned int, MaximumNumOfObjectsToCompilePerFrame);
|
I_Property(unsigned int, MaximumNumOfObjectsToCompilePerFrame);
|
||||||
|
Loading…
Reference in New Issue
Block a user