Cleaned up the thread priority management in DatabasePager and added

support for paging stats.
This commit is contained in:
Robert Osfield
2007-08-24 13:33:35 +00:00
parent cc6ac2704e
commit 54202aae0d
4 changed files with 229 additions and 120 deletions

View File

@@ -87,31 +87,6 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
/** Get whether new database request calls are accepted or ignored.*/
bool getAcceptNewDatabaseRequests() const { return _acceptNewRequests; }
/** Set the use of the frame block which, if enabled, blocks the DatabasePager
* from executing which the current frame is being drawn.
* When a single processor machine is being used it can be useful to block on
* frame to help prevent the database paging thread from slowing the cull and draw
* traversals which in turn can cause frame drops.*/
void setUseFrameBlock(bool useFrameBlock) { _useFrameBlock = useFrameBlock; }
/** Get the whether UseFrameBlock is on or off.*/
bool getUseFrameBlock() const { return _useFrameBlock; }
osg::RefBlock* getFrameBlock() { return _frameBlock.get(); }
/** Set the priority of the database pager thread during the frame (i.e. while cull and draw are running.)*/
void setThreadPriorityDuringFrame(ThreadPriority duringFrame) { _threadPriorityDuringFrame = duringFrame; }
/** Get the priority of the database pager thread during the frame*/
ThreadPriority getThreadPriorityDuringFrame() const { return _threadPriorityDuringFrame; }
/** Set the priority of the database pager thread when the frame is not being exectuted (i.e. before or after cull and draw have run.)*/
void setThreadPriorityOutwithFrame(ThreadPriority outwithFrame) { _threadPriorityOutwithFrame = outwithFrame; }
/** Get the priority of the database pager thread when the frame is not being exectuted.*/
ThreadPriority getThreadPriorityOutwithFrame() const { return _threadPriorityOutwithFrame; }
/** Get the number of frames that are currently active.*/
int getNumFramesActive() const { return _numFramesActive; }
@@ -259,6 +234,20 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
/** Report how many items are in the _dataToCompileList queue */
unsigned int getDataToCompileListSize() const { return _dataToCompileList.size(); }
/** Get the minimum time between the first request for a tile to be loaded and the time of its merge into the main scene graph.*/
double getMinimumTimeToMergeTile() const { return _minimumTimeToMergeTile; }
/** Get the maximum time between the first request for a tile to be loaded and the time of its merge into the main scene graph.*/
double getMaximumTimeToMergeTile() const { return _maximumTimeToMergeTile; }
/** Get the average time between the first request for a tile to be loaded and the time of its merge into the main scene graph.*/
double getAverageTimeToMergeTiles() const { return _totalTimeToMergeTiles/static_cast<double>(_numTilesMerges); }
/** Reset the Stats variables.*/
void resetStats();
typedef std::list< osg::ref_ptr<osg::PagedLOD> > PagedLODList;
@@ -322,13 +311,6 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
(!_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
* children which havn't been visited since specified expiryTime.
@@ -343,15 +325,10 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
bool _acceptNewRequests;
bool _databasePagerThreadPaused;
bool _useFrameBlock;
int _numFramesActive;
mutable OpenThreads::Mutex _numFramesActiveMutex;
osg::ref_ptr<osg::RefBlock> _frameBlock;
int _frameNumber;
ThreadPriority _threadPriorityDuringFrame;
ThreadPriority _threadPriorityOutwithFrame;
DatabaseRequestList _fileRequestList;
mutable OpenThreads::Mutex _fileRequestListMutex;
@@ -386,6 +363,12 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
double _minimumTimeAvailableForGLCompileAndDeletePerFrame;
unsigned int _maximumNumOfObjectsToCompilePerFrame;
double _minimumTimeToMergeTile;
double _maximumTimeToMergeTile;
double _totalTimeToMergeTiles;
unsigned int _numTilesMerges;
struct CompileOperation : public osg::GraphicsOperation
{
CompileOperation(DatabasePager* databasePager);