diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index a58b091b9..3b5561536 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -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; diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index c041353b1..56df33816 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -339,6 +339,7 @@ void DatabasePager::ReadQueue::takeFirst(osg::ref_ptr& 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()= "<_requestList.size()<<" to delete = "<_childrenToDeleteList.size()<_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 inactivePLOD) { numToPrune = inactivePLOD;