From 2f918d62d73b3a39477760d8b3c86099c2c609e4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 7 Jan 2004 12:37:44 +0000 Subject: [PATCH] Added DatabasePager::setUseFrameBlock(bool) method --- include/osgDB/DatabasePager | 11 +++++++++++ src/osgDB/DatabasePager.cpp | 36 ++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index 0a6f63351..ec5819832 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -84,6 +84,16 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl /** run does the database paging.*/ virtual void run(); + /** 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; } + /** 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. */ @@ -196,6 +206,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl virtual ~DatabasePager(); + bool _useFrameBlock; osg::ref_ptr _frameBlock; int _frameNumber; diff --git a/src/osgDB/DatabasePager.cpp b/src/osgDB/DatabasePager.cpp index cb38a5fcc..b68053ffd 100644 --- a/src/osgDB/DatabasePager.cpp +++ b/src/osgDB/DatabasePager.cpp @@ -19,6 +19,7 @@ DatabasePager::DatabasePager() { //osg::notify(osg::INFO)<<"Constructing DatabasePager()"<setExpiryDelay(10.0f); + bool firstTime = true; + do { - //std::cout<<"In run loop"<tick(); _fileRequestListEmptyBlock->block(); - //osg::Timer_t t2 = osg::Timer::instance()->tick(); - _frameBlock->block(); - //osg::Timer_t t3 = osg::Timer::instance()->tick(); - - //std::cout<<"Time in _fileRequestListEmptyBlock block()"<delta_m(t1,t2)<delta_m(t2,t3)<block(); + } + // // delete any children if required. // @@ -316,7 +314,7 @@ void DatabasePager::run() osg::notify(osg::INFO)<<"In DatabasePager thread readNodeFile("<_fileName<<")"<tick(); databaseRequest->_loadedModel = osgDB::readNodeFile(databaseRequest->_fileName); - osg::notify(osg::INFO)<<" node read"<delta_m(before,osg::Timer::instance()->tick())<delta_m(before,osg::Timer::instance()->tick())<<" ms"<reset(); _fileRequestListMutex.unlock(); + } else { @@ -389,13 +387,19 @@ void DatabasePager::run() if (_fileRequestList.empty()) _fileRequestListEmptyBlock->reset(); _fileRequestListMutex.unlock(); + } } // go to sleep till our the next time our thread gets scheduled. - //YieldCurrentThread(); - //std::cout<<"At end of loop"<