Addd control for serializing draw dispatch.
This commit is contained in:
@@ -179,6 +179,9 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
|
||||
void setCompileContextsHint(bool useCompileContexts) { _compileContextsHint = useCompileContexts; }
|
||||
bool getCompileContextsHint() const { return _compileContextsHint; }
|
||||
|
||||
void setSerializeDrawDispatch(bool serializeDrawDispatch) { _serializeDrawDispatch = serializeDrawDispatch; }
|
||||
bool getSerializeDrawDispatch() const { return _serializeDrawDispatch; }
|
||||
|
||||
protected:
|
||||
|
||||
@@ -214,6 +217,7 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
unsigned int _numMultiSamples;
|
||||
|
||||
bool _compileContextsHint;
|
||||
bool _serializeDrawDispatch;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -81,9 +81,6 @@ class OSGVIEWER_EXPORT Renderer : public osg::GraphicsOperation, public OpenGLQu
|
||||
|
||||
virtual ~Renderer();
|
||||
|
||||
|
||||
bool _serializeDraw;
|
||||
|
||||
osg::observer_ptr<osg::Camera> _camera;
|
||||
|
||||
bool _done;
|
||||
|
||||
@@ -72,6 +72,7 @@ void DisplaySettings::setDisplaySettings(const DisplaySettings& vs)
|
||||
_numMultiSamples = vs._numMultiSamples;
|
||||
|
||||
_compileContextsHint = vs._compileContextsHint;
|
||||
_serializeDrawDispatch = vs._serializeDrawDispatch;
|
||||
}
|
||||
|
||||
void DisplaySettings::merge(const DisplaySettings& vs)
|
||||
@@ -89,7 +90,7 @@ void DisplaySettings::merge(const DisplaySettings& vs)
|
||||
if (vs._numMultiSamples>_numMultiSamples) _numMultiSamples = vs._numMultiSamples;
|
||||
|
||||
if (vs._compileContextsHint) _compileContextsHint = vs._compileContextsHint;
|
||||
|
||||
if (vs._serializeDrawDispatch) _serializeDrawDispatch = vs._serializeDrawDispatch;
|
||||
}
|
||||
|
||||
void DisplaySettings::setDefaults()
|
||||
@@ -130,6 +131,7 @@ void DisplaySettings::setDefaults()
|
||||
#endif
|
||||
|
||||
_compileContextsHint = false;
|
||||
_serializeDrawDispatch = true;
|
||||
}
|
||||
|
||||
void DisplaySettings::setMaxNumberOfGraphicsContexts(unsigned int num)
|
||||
@@ -165,6 +167,8 @@ static ApplicationUsageProxy DisplaySetting_e10(ApplicationUsage::ENVIRONMENTAL_
|
||||
static ApplicationUsageProxy DisplaySetting_e11(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SPLIT_STEREO_VERTICAL_SEPARATION <float>","number of pixels between viewports");
|
||||
static ApplicationUsageProxy DisplaySetting_e12(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_MAX_NUMBER_OF_GRAPHICS_CONTEXTS <int>","maximum number of graphics contexts to be used with applications.");
|
||||
static ApplicationUsageProxy DisplaySetting_e13(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_COMPIlE_CONTEXTS <mode>","OFF | ON Enable/disable the use a backgrouind compile contexts and threads.");
|
||||
static ApplicationUsageProxy DisplaySetting_e14(ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_SERIALIZE_DRAW_DISPATCH <mode>","OFF | ON Enable/disable the use a muetx to serialize the draw dispatch when there are multiple graphics threads.");
|
||||
|
||||
void DisplaySettings::readEnvironmentalVariables()
|
||||
{
|
||||
const char* ptr = 0;
|
||||
@@ -328,6 +332,21 @@ void DisplaySettings::readEnvironmentalVariables()
|
||||
_compileContextsHint = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_SERIALIZE_DRAW_DISPATCH")) != 0)
|
||||
{
|
||||
if (strcmp(ptr,"OFF")==0)
|
||||
{
|
||||
_serializeDrawDispatch = false;
|
||||
}
|
||||
else
|
||||
if (strcmp(ptr,"ON")==0)
|
||||
{
|
||||
_serializeDrawDispatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
@@ -345,6 +364,7 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--accum-rgba","Request a rgb accumulator buffer visual");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--samples <num>","Request a multisample visual");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--cc","Request use of compile contexts and threads");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--serialize-draw <mode>","OFF | ON - set the serialization of draw dispatch");
|
||||
}
|
||||
|
||||
std::string str;
|
||||
@@ -403,4 +423,10 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
_compileContextsHint = true;
|
||||
}
|
||||
|
||||
while(arguments.read("--serialize-draw",str))
|
||||
{
|
||||
if (str=="ON") _serializeDrawDispatch = true;
|
||||
else if (str=="OFF") _serializeDrawDispatch = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -152,7 +152,6 @@ static OpenThreads::Mutex s_drawSerializerMutex;
|
||||
Renderer::Renderer(osg::Camera* camera):
|
||||
osg::GraphicsOperation("Renderer",true),
|
||||
OpenGLQuerySupport(),
|
||||
_serializeDraw(true),
|
||||
_camera(camera),
|
||||
_done(false),
|
||||
_graphicsThreadDoesCull(true)
|
||||
@@ -305,8 +304,6 @@ void Renderer::draw()
|
||||
|
||||
osgUtil::SceneView* sceneView = _drawQueue.takeFront();
|
||||
|
||||
|
||||
|
||||
DEBUG_MESSAGE<<"draw() got SceneView "<<sceneView<<std::endl;
|
||||
|
||||
osg::GraphicsContext* compileContext = osg::GraphicsContext::getCompileContext(sceneView->getState()->getContextID());
|
||||
@@ -365,8 +362,11 @@ void Renderer::draw()
|
||||
}
|
||||
|
||||
osg::Timer_t beforeDrawTick;
|
||||
|
||||
|
||||
bool serializeDraw = sceneView->getDisplaySettings()->getSerializeDrawDispatch();
|
||||
|
||||
if (_serializeDraw)
|
||||
if (serializeDraw)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_drawSerializerMutex);
|
||||
beforeDrawTick = osg::Timer::instance()->tick();
|
||||
@@ -487,7 +487,9 @@ void Renderer::cull_draw()
|
||||
|
||||
osg::Timer_t beforeDrawTick;
|
||||
|
||||
if (_serializeDraw)
|
||||
bool serializeDraw = sceneView->getDisplaySettings()->getSerializeDrawDispatch();
|
||||
|
||||
if (serializeDraw)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_drawSerializerMutex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user