Added --db-affinit cpuNum option to osgterrain example to illustrate how to set the thead affinity of the DatabasePager threads.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14516 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -244,6 +244,9 @@ int main(int argc, char** argv)
|
||||
osgDB::Registry::instance()->setReadFileCallback(new CleanTechniqueReadFileCallback());
|
||||
}
|
||||
|
||||
bool setDatabaseThreadAffinity = false;
|
||||
unsigned int cpuNum = 0;
|
||||
while(arguments.read("--db-affinity", cpuNum)) { setDatabaseThreadAffinity = true; }
|
||||
|
||||
// load the nodes from the commandline arguments.
|
||||
osg::ref_ptr<osg::Node> rootnode = osgDB::readNodeFiles(arguments);
|
||||
@@ -294,6 +297,16 @@ int main(int argc, char** argv)
|
||||
// add a viewport to the viewer and attach the scene graph.
|
||||
viewer.setSceneData( rootnode.get() );
|
||||
|
||||
// if required set the DatabaseThread affinity, note must call after viewer.setSceneData() so that the osgViewer::Scene object is constructed with it's DatabasePager.
|
||||
if (setDatabaseThreadAffinity)
|
||||
{
|
||||
for (unsigned int i=0; i<viewer.getDatabasePager()->getNumDatabaseThreads(); ++i)
|
||||
{
|
||||
osgDB::DatabasePager::DatabaseThread* thread = viewer.getDatabasePager()->getDatabaseThread(i);
|
||||
thread->setProcessorAffinity(cpuNum);
|
||||
OSG_NOTICE<<"Settings affinity of DatabaseThread="<<thread<<" isRunning()="<<thread->isRunning()<<" cpuNum="<<cpuNum<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// run the viewers main loop
|
||||
return viewer.run();
|
||||
|
||||
Reference in New Issue
Block a user