Added DatabasePager::getRequestsInProgress() that return true if there are still tiles to load.

Added DatabasePager::setTargetMaximumNumberOfPageLOD(..) that sets the target number of PagedLOD to try and maintain
This commit is contained in:
Robert Osfield
2008-11-26 11:12:19 +00:00
parent e3d1c4ba04
commit b2762c4788
2 changed files with 52 additions and 9 deletions

View File

@@ -100,6 +100,9 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
void setDone(bool done) { _done = done; }
bool getDone() const { return _done; }
void setActive(bool active) { _active = active; }
bool getActive() const { return _active; }
virtual int cancel();
@@ -110,6 +113,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
virtual ~DatabaseThread();
bool _done;
bool _active;
DatabasePager* _pager;
Mode _mode;
std::string _name;
@@ -202,6 +206,15 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
unsigned int getMaximumNumOfObjectsToCompilePerFrame() const { return _maximumNumOfObjectsToCompilePerFrame; }
/** Set the target maximum number of PagedLOD to maintain in memory.
* Note, if more than the target number are required for rendering of a frame then these active PagedLOD are excempt from being expiried.
* But once the number of active drops back below the target the inactive PagedLOD will be trimmed back to the target number.*/
void setTargetMaximumNumberOfPageLOD(unsigned int target) { _targetMaximumNumberOfPageLOD = target; }
/** Get the target maximum number of PagedLOD to maintain in memory.*/
unsigned int getTargetMaximumNumberOfPageLOD() const { return _targetMaximumNumberOfPageLOD; }
/** Set the amount of time that a subgraph will be kept without being visited in the cull traversal
* before being removed.*/
void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
@@ -311,7 +324,11 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
/** Report how many items are in the _dataToCompileList queue */
unsigned int getDataToCompileListSize() const { return _dataToCompileList->_requestList.size(); }
/** Report how many items are in the _dataToCompileList queue */
unsigned int getDataToMergeListSize() const { return _dataToMergeList->_requestList.size(); }
/** Report whether any requests are in the pager.*/
bool getRequestsInProgress() const;
/** 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; }
@@ -558,7 +575,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl
PagedLODList _activePagedLODList;
PagedLODList _inactivePagedLODList;
unsigned int _maximumNumberOfPageLOD;
unsigned int _targetMaximumNumberOfPageLOD;
double _expiryDelay;
int _expiryFrames;

View File

@@ -339,6 +339,7 @@ void DatabasePager::ReadQueue::takeFirst(osg::ref_ptr<DatabaseRequest>& database
//
DatabasePager::DatabaseThread::DatabaseThread(DatabasePager* pager, Mode mode, const std::string& name):
_done(false),
_active(false),
_pager(pager),
_mode(mode),
_name(name)
@@ -347,6 +348,7 @@ DatabasePager::DatabaseThread::DatabaseThread(DatabasePager* pager, Mode mode, c
DatabasePager::DatabaseThread::DatabaseThread(const DatabaseThread& dt, DatabasePager* pager):
_done(false),
_active(false),
_pager(pager),
_mode(dt._mode),
_name(dt._name)
@@ -442,9 +444,12 @@ void DatabasePager::DatabaseThread::run()
do
{
_active = false;
read_queue->block();
_active = true;
osg::notify(osg::INFO)<<_name<<": _pager->_requestList.size()= "<<read_queue->_requestList.size()<<" to delete = "<<read_queue->_childrenToDeleteList.size()<<std::endl;
@@ -907,11 +912,11 @@ DatabasePager::DatabasePager()
}
_maximumNumberOfPageLOD = 0;
_targetMaximumNumberOfPageLOD = 0;
if( (ptr = getenv("OSG_MAX_PAGEDLOD")) != 0)
{
_maximumNumberOfPageLOD = atoi(ptr);
osg::notify(osg::NOTICE)<<"_maximumNumberOfPageLOD = "<<_maximumNumberOfPageLOD<<std::endl;
_targetMaximumNumberOfPageLOD = atoi(ptr);
osg::notify(osg::NOTICE)<<"_targetMaximumNumberOfPageLOD = "<<_targetMaximumNumberOfPageLOD<<std::endl;
}
@@ -987,7 +992,7 @@ DatabasePager::DatabasePager(const DatabasePager& rhs)
_releaseDelay = rhs._releaseDelay;
_releaseFrames = rhs._releaseFrames;
_maximumNumberOfPageLOD = rhs._maximumNumberOfPageLOD;
_targetMaximumNumberOfPageLOD = rhs._targetMaximumNumberOfPageLOD;
_doPreCompile = rhs._doPreCompile;
_targetFrameRate = rhs._targetFrameRate;
@@ -1193,6 +1198,27 @@ void DatabasePager::resetStats()
_numTilesMerges = 0;
}
bool DatabasePager::getRequestsInProgress() const
{
if (getFileRequestListSize()>0) return true;
if (getDataToCompileListSize()>0)
{
return true;
}
if (getDataToMergeListSize()>0) return true;
for(DatabaseThreadList::const_iterator itr = _databaseThreads.begin();
itr != _databaseThreads.begin();
++itr)
{
if ((*itr)->getActive()) return true;
}
return false;
}
void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* group,
float priority, const osg::FrameStamp* framestamp,
osg::ref_ptr<osg::Referenced>& databaseRequest)
@@ -1233,7 +1259,7 @@ void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* grou
DatabaseRequest* databaseRequest = dynamic_cast<DatabaseRequest*>(databaseRequestRef.get());
if (databaseRequest)
{
osg::notify(osg::INFO)<<"DatabasePager::fileRequest("<<fileName<<") updating alraedy assigned."<<std::endl;
osg::notify(osg::INFO)<<"DatabasePager::fileRequest("<<fileName<<") updating already assigned."<<std::endl;
RequestQueue* requestQueue = databaseRequest->_requestQueue;
if (requestQueue)
@@ -1477,7 +1503,7 @@ public:
void DatabasePager::removeExpiredSubgraphs(const osg::FrameStamp& frameStamp)
{
if (_maximumNumberOfPageLOD>0)
if (_targetMaximumNumberOfPageLOD>0)
{
capped_removeExpiredSubgraphs(frameStamp);
}
@@ -1564,13 +1590,13 @@ void DatabasePager::capped_removeExpiredSubgraphs(const osg::FrameStamp& frameSt
if (s_total_max_stage_a<time_a) s_total_max_stage_a = time_a;
if (numPagedLODs <= _maximumNumberOfPageLOD)
if (numPagedLODs <= _targetMaximumNumberOfPageLOD)
{
// nothing to do
return;
}
int numToPrune = numPagedLODs - _maximumNumberOfPageLOD;
int numToPrune = numPagedLODs - _targetMaximumNumberOfPageLOD;
if (numToPrune > inactivePLOD)
{
numToPrune = inactivePLOD;