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:
@@ -541,6 +541,11 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
}
|
||||
}
|
||||
|
||||
/** Set the process affinity hint for any Camera Threads that are/will be assigned to this Camera.*/
|
||||
void setProcessorAffinity(const OpenThreads::Affinity& affinity);
|
||||
OpenThreads::Affinity& getProcessorAffinity() { return _affinity; }
|
||||
const OpenThreads::Affinity& getProcessorAffinity() const { return _affinity; }
|
||||
|
||||
/** Create a operation thread for this camera.*/
|
||||
void createCameraThread();
|
||||
|
||||
@@ -707,6 +712,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
|
||||
|
||||
unsigned int _attachmentMapModifiedCount;
|
||||
|
||||
OpenThreads::Affinity _affinity;
|
||||
ref_ptr<OperationThread> _cameraThread;
|
||||
|
||||
ref_ptr<GraphicsContext> _graphicsContext;
|
||||
|
||||
@@ -145,6 +145,9 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
bool overrideRedirect;
|
||||
|
||||
DisplaySettings::SwapMethod swapMethod;
|
||||
|
||||
// hint of what affinity to use for any thrads associated with the graphics context created using these Traits
|
||||
OpenThreads::Affinity affinity;
|
||||
};
|
||||
|
||||
/** Simple resolution structure used by WindowingSystemInterface to get and set screen resolution.
|
||||
|
||||
@@ -126,9 +126,9 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
|
||||
};
|
||||
|
||||
virtual void setProcessorAffinty(const OpenThreads::Affinity& affinity);
|
||||
OpenThreads::Affinity& getProcessorAffinty() { return _affinity; }
|
||||
const OpenThreads::Affinity& getProcessorAffinty() const { return _affinity; }
|
||||
virtual void setProcessorAffinity(const OpenThreads::Affinity& affinity);
|
||||
OpenThreads::Affinity& getProcessorAffinity() { return _affinity; }
|
||||
const OpenThreads::Affinity& getProcessorAffinity() const { return _affinity; }
|
||||
|
||||
void setUpThreads(unsigned int totalNumThreads=2, unsigned int numHttpThreads=1);
|
||||
|
||||
|
||||
@@ -59,6 +59,15 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
|
||||
/** set up windows and associated threads.*/
|
||||
virtual void realize() = 0;
|
||||
|
||||
|
||||
/** analyse the viewer configuration and select an appropriate Affinity for main thread, and any graphics, camera threads and database pagers that are required.*/
|
||||
virtual void configureAffinity();
|
||||
|
||||
/** Set the processor affinity of main thread.*/
|
||||
virtual void setProcessorAffinty(const OpenThreads::Affinity& affinity) { _affinity = affinity; }
|
||||
OpenThreads::Affinity& getProcessorAffinty() { return _affinity; }
|
||||
const OpenThreads::Affinity& getProcessorAffinty() const { return _affinity; }
|
||||
|
||||
enum ThreadingModel
|
||||
{
|
||||
SingleThreaded,
|
||||
@@ -283,7 +292,7 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
|
||||
virtual void getUsage(osg::ApplicationUsage& usage) const = 0;
|
||||
|
||||
bool getRequestRedraw() const { return _requestRedraw; }
|
||||
|
||||
|
||||
bool getRequestContinousUpdate() const { return _requestContinousUpdate; }
|
||||
|
||||
protected:
|
||||
@@ -318,6 +327,7 @@ protected:
|
||||
bool _quitEventSetsDone;
|
||||
bool _releaseContextAtEndOfFrameHint;
|
||||
|
||||
OpenThreads::Affinity _affinity;
|
||||
ThreadingModel _threadingModel;
|
||||
bool _threadsRunning;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user