Added ability to toggle on/off the pre compile of OpenGL objects in the
DatabasePager via the setDoPreCompile(bool) method or via the env var OSG_DO_PRE_COMPILE=ON or OFF.
This commit is contained in:
parent
ac5ffa2bec
commit
44b8b0177c
@ -157,6 +157,16 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
* note, should be only be called from the update thread. */
|
||||
virtual void registerPagedLODs(osg::Node* subgraph);
|
||||
|
||||
/** Set whether the database pager should pre compile OpenGL objects before allowing
|
||||
* them to be merged into the scene graph.
|
||||
* Pre compilation helps reduce the chances of frame drops, but also slows the
|
||||
* speed at which tiles are merged as they have to be compiled first.*/
|
||||
void setDoPreCompile(bool flag) { _doPreCompile = flag; }
|
||||
|
||||
/** Get whether the database pager should pre compile OpenGL objects before allowing
|
||||
* them to be merged into the scene graph.*/
|
||||
bool getDoPreCompile() const { return _doPreCompile; }
|
||||
|
||||
|
||||
/** Set the target frame rate that the DatabasePager should assume.
|
||||
* Typically one would set this to the value refresh rate of your display system i.e. 60Hz.
|
||||
@ -367,6 +377,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
|
||||
ActiveGraphicsContexts _activeGraphicsContexts;
|
||||
|
||||
bool _doPreCompile;
|
||||
double _targetFrameRate;
|
||||
double _minimumTimeAvailableForGLCompileAndDeletePerFrame;
|
||||
unsigned int _maximumNumOfObjectsToCompilePerFrame;
|
||||
|
@ -20,8 +20,9 @@
|
||||
using namespace osgDB;
|
||||
using namespace OpenThreads;
|
||||
|
||||
static osg::ApplicationUsageProxy DatabasePager_e0(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MINIMUM_COMPILE_TIME_PER_FRAME <float>","minimum compile time alloted to compiling GL objects per frame in database pager.");
|
||||
static osg::ApplicationUsageProxy DatabasePager_e1(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAXIMUM_OBJECTS_TO_COMPILE_PER_FRAME <int>","maximum number of GL objects to compile per frame in 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_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.");
|
||||
|
||||
DatabasePager::DatabasePager()
|
||||
{
|
||||
@ -56,11 +57,17 @@ DatabasePager::DatabasePager()
|
||||
|
||||
_expiryDelay = 10;
|
||||
|
||||
const char* ptr=0;
|
||||
_doPreCompile = true;
|
||||
if( (ptr = getenv("OSG_DO_PRE_COMPILE")) != 0)
|
||||
{
|
||||
_doPreCompile = strcmp(ptr,"yes")==0 || strcmp(ptr,"YES")==0 ||
|
||||
strcmp(ptr,"ON")==0 || strcmp(ptr,"ON")==0;
|
||||
}
|
||||
|
||||
_targetFrameRate = 100.0;
|
||||
_minimumTimeAvailableForGLCompileAndDeletePerFrame = 0.001; // 1ms.
|
||||
_maximumNumOfObjectsToCompilePerFrame = 8;
|
||||
|
||||
const char* ptr=0;
|
||||
if( (ptr = getenv("OSG_MINIMUM_COMPILE_TIME_PER_FRAME")) != 0)
|
||||
{
|
||||
_minimumTimeAvailableForGLCompileAndDeletePerFrame = atof(ptr);
|
||||
@ -462,7 +469,7 @@ void DatabasePager::run()
|
||||
|
||||
bool loadedObjectsNeedToBeCompiled = false;
|
||||
|
||||
if (databaseRequest->_loadedModel.valid() && !_activeGraphicsContexts.empty())
|
||||
if (_doPreCompile && databaseRequest->_loadedModel.valid() && !_activeGraphicsContexts.empty())
|
||||
{
|
||||
// force a compute of the loaded model's bounding volume, so that when the subgraph
|
||||
// merged with the main scene graph and large computeBound() isn't incurred.
|
||||
|
Loading…
Reference in New Issue
Block a user