Added a mutex and _numFramesActive count to track multiview usages of
the DatabasePager.
This commit is contained in:
@@ -138,6 +138,9 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
ThreadPriority getThreadPriorityOutwithFrame() const { return _threadPriorityOutwithFrame; }
|
||||
|
||||
|
||||
/** Get the number of frames that are currently active.*/
|
||||
int getNumFramesActive() const { return _numFramesActive; }
|
||||
|
||||
/** Signal the database thread that the update, cull and draw has begun for a new frame.
|
||||
* Note, this is called by the application so that the database pager can go to sleep while the CPU is busy on the main rendering threads. */
|
||||
void signalBeginFrame(const osg::FrameStamp* framestamp);
|
||||
@@ -261,6 +264,13 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
_databasePagerThreadBlock->set(
|
||||
(!_fileRequestList.empty() || !_childrenToDeleteList.empty()) && !_databasePagerThreadPaused);
|
||||
}
|
||||
|
||||
inline void updateFrameBlock(int delta)
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_numFramesActiveMutex);
|
||||
_numFramesActive += delta;
|
||||
_frameBlock->set(_numFramesActive==0);
|
||||
}
|
||||
|
||||
|
||||
/** Iterate through the active PagedLOD nodes children removing
|
||||
@@ -277,6 +287,8 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
|
||||
bool _databasePagerThreadPaused;
|
||||
|
||||
bool _useFrameBlock;
|
||||
int _numFramesActive;
|
||||
mutable OpenThreads::Mutex _numFramesActiveMutex;
|
||||
osg::ref_ptr<Block> _frameBlock;
|
||||
int _frameNumber;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ DatabasePager::DatabasePager()
|
||||
_databasePagerThreadPaused = false;
|
||||
|
||||
_useFrameBlock = false;
|
||||
_numFramesActive = 0;
|
||||
_frameNumber = 0;
|
||||
_frameBlock = new Block;
|
||||
_databasePagerThreadBlock = new Block;
|
||||
@@ -236,20 +237,18 @@ void DatabasePager::signalBeginFrame(const osg::FrameStamp* framestamp)
|
||||
|
||||
} //else osg::notify(osg::INFO) << "signalBeginFrame >>>>>>>>>>>>>>>>"<<std::endl;
|
||||
|
||||
updateFrameBlock(1);
|
||||
|
||||
_frameBlock->reset();
|
||||
|
||||
if (_threadPriorityDuringFrame!=getSchedulePriority())
|
||||
if (_numFramesActive>0 && _threadPriorityDuringFrame!=getSchedulePriority())
|
||||
setSchedulePriority(_threadPriorityDuringFrame);
|
||||
|
||||
}
|
||||
|
||||
void DatabasePager::signalEndFrame()
|
||||
{
|
||||
//osg::notify(osg::INFO) << "signalEndFrame <<<<<<<<<<<<<<<<<<<< "<<std::endl;
|
||||
_frameBlock->release();
|
||||
updateFrameBlock(-1);
|
||||
|
||||
if (_threadPriorityOutwithFrame!=getSchedulePriority())
|
||||
if (_numFramesActive<=0 && _threadPriorityOutwithFrame!=getSchedulePriority())
|
||||
setSchedulePriority(_threadPriorityOutwithFrame);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user