Added support for --affinity command line option for switch on procesor affinity where supported,
This commit is contained in:
@@ -148,8 +148,15 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
/** Set the options to set up SceneView with, see osgUtil::SceneView::Options for available options.*/
|
||||
void setRealizeSceneViewOptions(unsigned int options) { _realizeSceneViewOptions = options; }
|
||||
|
||||
/** Get the options to set up SceneView with.*/
|
||||
unsigned int getRealizeSceneViewOptions() { return _realizeSceneViewOptions; }
|
||||
|
||||
/** Set whether processor affinity should be enable where supported by hardware.*/
|
||||
void setEnableProcessorAffinityHint(bool enableProccessAffinityHint) { _enableProccessAffinityHint = enableProccessAffinityHint; }
|
||||
|
||||
/** Get whether processor affinity should be enable where supported by hardware.*/
|
||||
bool getEnableProcessorAffinityHint() const { return _enableProccessAffinityHint; }
|
||||
|
||||
|
||||
/** RealizeCallback class one should override to provide an the implemention of realize callbacks.
|
||||
* Note, this callback overrides the normal call to OsgSceneHandler::init() so it become the your
|
||||
@@ -233,10 +240,12 @@ class OSGPRODUCER_EXPORT OsgCameraGroup : public Producer::CameraGroup
|
||||
|
||||
osg::CullSettings _cullSettings;
|
||||
|
||||
unsigned int _frameNumber;
|
||||
osg::Timer _timer;
|
||||
osg::Timer_t _start_tick;
|
||||
unsigned int _frameNumber;
|
||||
osg::Timer _timer;
|
||||
osg::Timer_t _start_tick;
|
||||
osg::ref_ptr<osg::FrameStamp> _frameStamp;
|
||||
|
||||
bool _enableProccessAffinityHint;
|
||||
|
||||
void _init();
|
||||
};
|
||||
|
||||
@@ -46,24 +46,13 @@ class RenderSurfaceRealizeCallback : public Producer::RenderSurface::Callback
|
||||
{
|
||||
public:
|
||||
|
||||
RenderSurfaceRealizeCallback(OsgCameraGroup* cameraGroup,OsgSceneHandler* sceneHandler):
|
||||
RenderSurfaceRealizeCallback(OsgCameraGroup* cameraGroup,OsgSceneHandler* sceneHandler, bool enableProccessAffinityHint):
|
||||
_cameraGroup(cameraGroup),
|
||||
_sceneHandler(sceneHandler),
|
||||
_numberOfProcessors(1),
|
||||
_sceneHandlerNumber(0),
|
||||
_enableProccessAffinityHint(false)
|
||||
_enableProccessAffinityHint(enableProccessAffinityHint)
|
||||
{
|
||||
const char* str = getenv("OSG_PROCESSOR_AFFINTIY");
|
||||
if (str && (strcmp(str,"ON")==0 || strcmp(str,"On")==0 || strcmp(str,"on")==0))
|
||||
{
|
||||
_enableProccessAffinityHint = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_enableProccessAffinityHint = false;
|
||||
}
|
||||
|
||||
|
||||
#if defined (__linux__)
|
||||
/* Determine the actual number of processors */
|
||||
_numberOfProcessors = sysconf(_SC_NPROCESSORS_CONF);
|
||||
@@ -185,6 +174,13 @@ OsgCameraGroup::OsgCameraGroup(osg::ArgumentParser& arguments):
|
||||
_init();
|
||||
_applicationUsage = arguments.getApplicationUsage();
|
||||
|
||||
// report the usage options.
|
||||
if (arguments.getApplicationUsage())
|
||||
{
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--affinity","Enable processor affinity where supported.");
|
||||
}
|
||||
|
||||
|
||||
for( unsigned int i = 0; i < _cfg->getNumberOfCameras(); i++ )
|
||||
{
|
||||
Producer::Camera *cam = _cfg->getCamera(i);
|
||||
@@ -194,6 +190,13 @@ OsgCameraGroup::OsgCameraGroup(osg::ArgumentParser& arguments):
|
||||
rs->setWindowName(arguments.getApplicationName());
|
||||
}
|
||||
}
|
||||
|
||||
while (arguments.read("--affinity"))
|
||||
{
|
||||
_enableProccessAffinityHint = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -348,6 +351,14 @@ void OsgCameraGroup::_init()
|
||||
if (!_frameStamp) _frameStamp = new osg::FrameStamp;
|
||||
|
||||
_applicationUsage = osg::ApplicationUsage::instance();
|
||||
|
||||
_enableProccessAffinityHint = false;
|
||||
|
||||
str = getenv("OSG_PROCESSOR_AFFINTIY");
|
||||
if (str && (strcmp(str,"ON")==0 || strcmp(str,"On")==0 || strcmp(str,"on")==0))
|
||||
{
|
||||
_enableProccessAffinityHint = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -589,7 +600,7 @@ bool OsgCameraGroup::realize()
|
||||
if (stage) stage->setClearMask(clear_mask);
|
||||
|
||||
// set the realize callback.
|
||||
rs->setRealizeCallback( new RenderSurfaceRealizeCallback(this, sh));
|
||||
rs->setRealizeCallback( new RenderSurfaceRealizeCallback(this, sh, _enableProccessAffinityHint));
|
||||
|
||||
// set up the visual chooser.
|
||||
if (_ds.valid())
|
||||
|
||||
@@ -79,6 +79,8 @@ BEGIN_VALUE_REFLECTOR(osgProducer::OsgCameraGroup)
|
||||
I_MethodWithDefaults2(void, setFusionDistance, IN, osgUtil::SceneView::FusionDistanceMode, mode, , IN, float, value, 1.0f);
|
||||
I_Method1(void, setRealizeSceneViewOptions, IN, unsigned int, options);
|
||||
I_Method0(unsigned int, getRealizeSceneViewOptions);
|
||||
I_Method1(void, setEnableProcessorAffinityHint, IN, bool, enableProccessAffinityHint);
|
||||
I_Method0(bool, getEnableProcessorAffinityHint);
|
||||
I_Method1(void, setRealizeCallback, IN, osgProducer::OsgCameraGroup::RealizeCallback *, cb);
|
||||
I_Method0(osgProducer::OsgCameraGroup::RealizeCallback *, getRealizeCallback);
|
||||
I_Method0(const osgProducer::OsgCameraGroup::RealizeCallback *, getRealizeCallback);
|
||||
@@ -94,6 +96,7 @@ BEGIN_VALUE_REFLECTOR(osgProducer::OsgCameraGroup)
|
||||
I_Property(const osg::Vec4 &, ClearColor);
|
||||
I_Property(const osg::CullSettings &, CullSettings);
|
||||
I_Property(osg::DisplaySettings *, DisplaySettings);
|
||||
I_Property(bool, EnableProcessorAffinityHint);
|
||||
I_Property(osg::FrameStamp *, FrameStamp);
|
||||
I_Property(osg::StateSet *, GlobalStateSet);
|
||||
I_Property(osgProducer::OsgCameraGroup::GraphicsContextList &, GraphicsContextList);
|
||||
|
||||
Reference in New Issue
Block a user