Introduced OpenThreads::Affinity support into osg::Camera, osg::GraphicsContext::Traitse, osgDB::DatabasePager and osgViewer::ViewerBase/Viewer/CompositeViewer.

Added ViewerBase::configureAffinity() to help with the setting of the affinity of camera, graphics context and pager threads
This commit is contained in:
Robert Osfield
2016-09-28 18:44:58 +01:00
parent 77c5e96ccb
commit ee97db3488
10 changed files with 161 additions and 91 deletions

View File

@@ -171,12 +171,12 @@ Viewer::Viewer(osg::ArgumentParser& arguments)
if (ss3d)
{
setThreadingModel(SingleThreaded);
//setThreadingModel(SingleThreaded);
setUpViewFor3DSphericalDisplay(radius, collar, screenNum, intensityMap.get());
}
else
{
setThreadingModel(SingleThreaded);
//setThreadingModel(SingleThreaded);
setUpViewForPanoramicSphericalDisplay(radius, collar, screenNum, intensityMap.get());
}
}
@@ -604,9 +604,6 @@ void Viewer::realize()
if (osg::DisplaySettings::instance()->getCompileContextsHint())
{
int numProcessors = osg::maximum(1, OpenThreads::GetNumberOfProcessors());
int processNum = 0;
for(unsigned int i=0; i<= osg::GraphicsContext::getMaxContextID(); ++i)
{
osg::GraphicsContext* gc = osg::GraphicsContext::getOrCreateCompileContext(i);
@@ -614,10 +611,7 @@ void Viewer::realize()
if (gc)
{
gc->createGraphicsThread();
gc->getGraphicsThread()->setProcessorAffinity(processNum % numProcessors);
gc->getGraphicsThread()->startThread();
++processNum;
}
}
}