diff --git a/applications/osgviewer/osgviewer.cpp b/applications/osgviewer/osgviewer.cpp index 2a768e5db..4e2b92304 100644 --- a/applications/osgviewer/osgviewer.cpp +++ b/applications/osgviewer/osgviewer.cpp @@ -49,16 +49,24 @@ public: switch(viewer->getThreadingModel()) { case(osgViewer::Viewer::SingleThreaded): - viewer->setThreadingModel(osgViewer::Viewer::ThreadPerContext); - osg::notify(osg::NOTICE)<<"Threading model 'ThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::CullDrawThreadPerContext); + osg::notify(osg::NOTICE)<<"Threading model 'CullDrawThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::ThreadPerCamera); - osg::notify(osg::NOTICE)<<"Threading model 'ThreadPerCamera' selected."<setThreadingModel(osgViewer::Viewer::DrawThreadPerContext); + osg::notify(osg::NOTICE)<<"Threading model 'DrawThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext); + osg::notify(osg::NOTICE)<<"Threading model 'CullThreadPerCameraDrawThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::SingleThreaded); - osg::notify(osg::NOTICE)<<"Threading model 'SingleTheaded' selected."<setThreadingModel(viewer->suggestBestThreadingModel()); + osg::notify(osg::NOTICE)<<"Threading model 'AutomaticSelection' selected."<getThreadingModel()) { case(osgViewer::Viewer::SingleThreaded): - viewer->setThreadingModel(osgViewer::Viewer::ThreadPerContext); - osg::notify(osg::NOTICE)<<"Threading model 'ThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::CullDrawThreadPerContext); + osg::notify(osg::NOTICE)<<"Threading model 'CullDrawThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::ThreadPerCamera); - osg::notify(osg::NOTICE)<<"Threading model 'ThreadPerCamera' selected."<setThreadingModel(osgViewer::Viewer::DrawThreadPerContext); + osg::notify(osg::NOTICE)<<"Threading model 'DrawThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext); + osg::notify(osg::NOTICE)<<"Threading model 'CullThreadPerCameraDrawThreadPerContext' selected."<setThreadingModel(osgViewer::Viewer::SingleThreaded); - osg::notify(osg::NOTICE)<<"Threading model 'SingleTheaded' selected."<setThreadingModel(viewer->suggestBestThreadingModel()); + osg::notify(osg::NOTICE)<<"Threading model 'AutomaticSelection' selected."<= static_cast(cameras.size()+contexts.size())) + { + return CullThreadPerCameraDrawThreadPerContext; + } + +#if 1 + return DrawThreadPerContext; +#else + return CullDrawThreadPerContext; +#endif +} + unsigned int Viewer::computeNumberOfThreadsIncludingMainRequired() { unsigned int numThreadsOnBarrier = 1; - switch(_threadingModel) + + ThreadingModel threadingModel = _threadingModel==AutomaticSelection ? suggestBestThreadingModel() : _threadingModel; + + switch(threadingModel) { case(SingleThreaded): numThreadsOnBarrier = 1; break; - case(ThreadPerContext): + case(CullDrawThreadPerContext): { Contexts contexts; getContexts(contexts); numThreadsOnBarrier = contexts.size()+1; break; - } - case(ThreadPerCamera): + } + case(DrawThreadPerContext): + numThreadsOnBarrier = 1; + break; + case(CullThreadPerCameraDrawThreadPerContext): { Cameras cameras; getCameras(cameras); numThreadsOnBarrier = _useMainThreadForRenderingTraversal ? cameras.size() : cameras.size()+1; break; } + default: + osg::notify(osg::NOTICE)<<"Error: Threading model not selected"<resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts()); } - osg::notify(osg::NOTICE)<<"_numThreadsOnBarrier = "<<_numThreadsOnBarrier<