osgDB::DatabasePager Class Reference

Inheritance diagram for osgDB::DatabasePager:
osg::NodeVisitor::DatabaseRequestHandler osg::Referenced

List of all members.

Classes

struct  CompileOperation
struct  DatabaseRequest
class  DatabaseThread
struct  ReadQueue
struct  RequestQueue

Public Types

enum  DrawablePolicy { DO_NOT_MODIFY_DRAWABLE_SETTINGS, USE_DISPLAY_LISTS, USE_VERTEX_BUFFER_OBJECTS, USE_VERTEX_ARRAYS }
typedef
OpenThreads::Thread::ThreadPriority 
ThreadPriority
typedef std::list
< osg::ref_ptr< osg::PagedLOD > > 
PagedLODList
typedef std::set< osg::ref_ptr
< osg::StateSet > > 
StateSetList
typedef std::vector
< osg::ref_ptr< osg::Drawable > > 
DrawableList
typedef std::pair
< StateSetList, DrawableList
DataToCompile
typedef std::map< unsigned int,
DataToCompile
DataToCompileMap
typedef std::set< unsigned int > ActiveGraphicsContexts
typedef std::vector
< osg::observer_ptr
< osg::GraphicsContext > > 
CompileGraphicsContexts

Public Member Functions

 DatabasePager ()
 DatabasePager (const DatabasePager &rhs)
virtual DatabasePagerclone () const
virtual void requestNodeFile (const std::string &fileName, osg::Group *group, float priority, const osg::FrameStamp *framestamp, osg::ref_ptr< osg::Referenced > &databaseRequest)
virtual void requestNodeFile (const std::string &fileName, osg::Group *group, float priority, const osg::FrameStamp *framestamp, osg::ref_ptr< osg::Referenced > &databaseRequest, ReaderWriter::Options *loadOptions)
int setSchedulePriority (OpenThreads::Thread::ThreadPriority priority)
virtual int cancel ()
virtual bool isRunning () const
virtual void clear ()
void setUpThreads (unsigned int totalNumThreads=2, unsigned int numHttpThreads=1)
unsigned int addDatabaseThread (DatabaseThread::Mode mode, const std::string &name)
DatabaseThreadgetDatabaseThread (unsigned int i)
const DatabaseThreadgetDatabaseThread (unsigned int i) const
unsigned int getNumDatabaseThreads () const
void setDatabasePagerThreadPause (bool pause)
bool getDatabasePagerThreadPause () const
void setAcceptNewDatabaseRequests (bool acceptNewRequests)
bool getAcceptNewDatabaseRequests () const
int getNumFramesActive () const
virtual void signalBeginFrame (const osg::FrameStamp *framestamp)
virtual void signalEndFrame ()
virtual void registerPagedLODs (osg::Node *subgraph, int frameNumber=0)
void setDoPreCompile (bool flag)
bool getDoPreCompile () const
void setTargetFrameRate (double tfr)
double getTargetFrameRate () const
void setMinimumTimeAvailableForGLCompileAndDeletePerFrame (double ta)
double getMinimumTimeAvailableForGLCompileAndDeletePerFrame () const
void setMaximumNumOfObjectsToCompilePerFrame (unsigned int num)
unsigned int getMaximumNumOfObjectsToCompilePerFrame () const
void setTargetMaximumNumberOfPageLOD (unsigned int target)
unsigned int getTargetMaximumNumberOfPageLOD () const
void setExpiryDelay (double expiryDelay)
double getExpiryDelay () const
void setExpiryFrames (int expiryFrames)
int getExpiryFrames () const
void setReleaseDelay (double releaseDelay)
double getReleaseDelay () const
void setReleaseFrames (int releaseFrames)
int getReleaseFrames () const
void setDeleteRemovedSubgraphsInDatabaseThread (bool flag)
bool getDeleteRemovedSubgraphsInDatabaseThread () const
void setDrawablePolicy (DrawablePolicy policy)
DrawablePolicy getDrawablePolicy () const
void setUnrefImageDataAfterApplyPolicy (bool changeAutoUnRef, bool valueAutoUnRef)
void getUnrefImageDataAfterApplyPolicy (bool &changeAutoUnRef, bool &valueAutoUnRef) const
void setMaxAnisotropyPolicy (bool changeAnisotropy, float valueAnisotropy)
void getMaxAnisotropyPolicy (bool &changeAnisotropy, float &valueAnisotropy) const
bool requiresUpdateSceneGraph () const
virtual void updateSceneGraph (const osg::FrameStamp &frameStamp)
void setCompileGLObjectsForContextID (unsigned int contextID, bool on)
bool getCompileGLObjectsForContextID (unsigned int contextID)
bool requiresExternalCompileGLObjects (unsigned int contextID) const
bool requiresCompileGLObjects () const
virtual void compileGLObjects (osg::State &state, double &availableTime)
virtual void compileAllGLObjects (osg::State &state)
unsigned int getFileRequestListSize () const
unsigned int getDataToCompileListSize () const
unsigned int getDataToMergeListSize () const
bool getRequestsInProgress () const
double getMinimumTimeToMergeTile () const
double getMaximumTimeToMergeTile () const
double getAverageTimeToMergeTiles () const
void resetStats ()

Static Public Member Functions

static osg::ref_ptr
< DatabasePager > & 
prototype ()
static DatabasePagercreate ()

Protected Types

typedef std::vector
< osg::ref_ptr< DatabaseThread > > 
DatabaseThreadList
typedef std::vector
< osg::ref_ptr< osg::Object > > 
ObjectList

Protected Member Functions

virtual ~DatabasePager ()
bool isCompiled (osg::Texture *texture) const
bool isCompiled (osg::StateSet *stateSet)
bool isCompiled (const osg::Drawable *drawable) const
virtual void removeExpiredSubgraphs (const osg::FrameStamp &frameStamp)
virtual void expiry_removeExpiredSubgraphs (const osg::FrameStamp &frameStamp)
virtual void capped_removeExpiredSubgraphs (const osg::FrameStamp &frameStamp)
void addLoadedDataToSceneGraph (const osg::FrameStamp &frameStamp)

Static Protected Member Functions

static bool isCompiled (const osg::Texture *texture, unsigned int contextID)
static bool isCompiled (const osg::StateSet *stateSet, unsigned int contextID)
static bool isCompiled (const osg::Drawable *drawable, unsigned int contextID)

Protected Attributes

OpenThreads::Mutex _run_mutex
bool _startThreadCalled
bool _done
bool _acceptNewRequests
bool _databasePagerThreadPaused
DatabaseThreadList _databaseThreads
int _numFramesActive
OpenThreads::Mutex _numFramesActiveMutex
int _frameNumber
osg::ref_ptr< ReadQueue_fileRequestQueue
osg::ref_ptr< ReadQueue_httpRequestQueue
osg::ref_ptr< RequestQueue_dataToCompileList
DrawablePolicy _drawablePolicy
bool _changeAutoUnRef
bool _valueAutoUnRef
bool _changeAnisotropy
float _valueAnisotropy
bool _deleteRemovedSubgraphsInDatabaseThread
osg::ref_ptr< RequestQueue_dataToMergeList
PagedLODList _activePagedLODList
PagedLODList _inactivePagedLODList
unsigned int _targetMaximumNumberOfPageLOD
double _expiryDelay
int _expiryFrames
double _releaseDelay
int _releaseFrames
ActiveGraphicsContexts _activeGraphicsContexts
bool _doPreCompile
double _targetFrameRate
double _minimumTimeAvailableForGLCompileAndDeletePerFrame
unsigned int _maximumNumOfObjectsToCompilePerFrame
double _minimumTimeToMergeTile
double _maximumTimeToMergeTile
double _totalTimeToMergeTiles
unsigned int _numTilesMerges

Friends

class DatabaseThread
struct DatabaseRequest
class FindCompileableGLObjectsVisitor
class FindPagedLODsVisitor
struct SortFileRequestFunctor

Detailed Description

Database paging class which manages the loading of files in a background thread, and synchronizing of loaded models with the main scene graph.


Member Typedef Documentation

typedef std::set<unsigned int> osgDB::DatabasePager::ActiveGraphicsContexts
typedef std::map< unsigned int, DataToCompile > osgDB::DatabasePager::DataToCompileMap
typedef std::vector< osg::ref_ptr<osg::Object> > osgDB::DatabasePager::ObjectList [protected]

Member Enumeration Documentation

Enumerator:
DO_NOT_MODIFY_DRAWABLE_SETTINGS 
USE_DISPLAY_LISTS 
USE_VERTEX_BUFFER_OBJECTS 
USE_VERTEX_ARRAYS 

Constructor & Destructor Documentation

osgDB::DatabasePager::DatabasePager (  ) 
osgDB::DatabasePager::DatabasePager ( const DatabasePager rhs  ) 
virtual osgDB::DatabasePager::~DatabasePager (  )  [protected, virtual]

Member Function Documentation

unsigned int osgDB::DatabasePager::addDatabaseThread ( DatabaseThread::Mode  mode,
const std::string &  name 
)
void osgDB::DatabasePager::addLoadedDataToSceneGraph ( const osg::FrameStamp frameStamp  )  [protected]

Add the loaded data to the scene graph.

virtual int osgDB::DatabasePager::cancel (  )  [virtual]

Cancel the database pager thread(s).

virtual void osgDB::DatabasePager::capped_removeExpiredSubgraphs ( const osg::FrameStamp frameStamp  )  [protected, virtual]

New capped based removeExpiredSubgraphs.

virtual void osgDB::DatabasePager::clear (  )  [virtual]

Clear all internally cached structures.

virtual DatabasePager* osgDB::DatabasePager::clone (  )  const [inline, virtual]

Create a shallow copy on the DatabasePager.

virtual void osgDB::DatabasePager::compileAllGLObjects ( osg::State state  )  [virtual]

Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph. note, should only be called from the draw thread. Note, must only be called from a valid graphics context.

virtual void osgDB::DatabasePager::compileGLObjects ( osg::State state,
double &  availableTime 
) [virtual]

Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph. note, should only be called from the draw thread. Note, must only be called from a valid graphics context.

static DatabasePager* osgDB::DatabasePager::create (  )  [static]
virtual void osgDB::DatabasePager::expiry_removeExpiredSubgraphs ( const osg::FrameStamp frameStamp  )  [protected, virtual]

Old expiry delay based removeExpiredSubgraphs.

bool osgDB::DatabasePager::getAcceptNewDatabaseRequests (  )  const [inline]

Get whether new database request calls are accepted or ignored.

double osgDB::DatabasePager::getAverageTimeToMergeTiles (  )  const [inline]

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.

bool osgDB::DatabasePager::getCompileGLObjectsForContextID ( unsigned int  contextID  ) 

Get whether the compilation of rendering objects for specified graphics context on (true) or off(false).

bool osgDB::DatabasePager::getDatabasePagerThreadPause (  )  const [inline]

Get whether the database pager thread should is paused or not.

const DatabaseThread* osgDB::DatabasePager::getDatabaseThread ( unsigned int  i  )  const [inline]
DatabaseThread* osgDB::DatabasePager::getDatabaseThread ( unsigned int  i  )  [inline]
unsigned int osgDB::DatabasePager::getDataToCompileListSize (  )  const [inline]

Report how many items are in the _dataToCompileList queue

unsigned int osgDB::DatabasePager::getDataToMergeListSize (  )  const [inline]

Report how many items are in the _dataToCompileList queue

bool osgDB::DatabasePager::getDeleteRemovedSubgraphsInDatabaseThread (  )  const [inline]

Get whether the removed subgraphs should be deleted in the database thread or not.

bool osgDB::DatabasePager::getDoPreCompile (  )  const [inline]

Get whether the database pager should pre compile OpenGL objects before allowing them to be merged into the scene graph.

DrawablePolicy osgDB::DatabasePager::getDrawablePolicy (  )  const [inline]

Get how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.

double osgDB::DatabasePager::getExpiryDelay (  )  const [inline]

Deprecated.

int osgDB::DatabasePager::getExpiryFrames (  )  const [inline]

Deprecated.

unsigned int osgDB::DatabasePager::getFileRequestListSize (  )  const [inline]

Report how many items are in the _fileRequestList queue

void osgDB::DatabasePager::getMaxAnisotropyPolicy ( bool &  changeAnisotropy,
float &  valueAnisotropy 
) const [inline]

Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.

unsigned int osgDB::DatabasePager::getMaximumNumOfObjectsToCompilePerFrame (  )  const [inline]

Get the maximum number of OpenGL objects that the page should attempt to compile per frame.

double osgDB::DatabasePager::getMaximumTimeToMergeTile (  )  const [inline]

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 osgDB::DatabasePager::getMinimumTimeAvailableForGLCompileAndDeletePerFrame (  )  const [inline]

Get the minimum amount of time that should be made available for compiling and delete OpenGL objects per frame. For usage see notes in setTargetFrameRate.

double osgDB::DatabasePager::getMinimumTimeToMergeTile (  )  const [inline]

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.

unsigned int osgDB::DatabasePager::getNumDatabaseThreads (  )  const [inline]
int osgDB::DatabasePager::getNumFramesActive (  )  const [inline]

Get the number of frames that are currently active.

double osgDB::DatabasePager::getReleaseDelay (  )  const [inline]

Deprecated.

int osgDB::DatabasePager::getReleaseFrames (  )  const [inline]

Deprecated.

bool osgDB::DatabasePager::getRequestsInProgress (  )  const

Report whether any requests are in the pager.

double osgDB::DatabasePager::getTargetFrameRate (  )  const [inline]

Get the target frame rate that the DatabasePager should assume.

unsigned int osgDB::DatabasePager::getTargetMaximumNumberOfPageLOD (  )  const [inline]

Get the target maximum number of PagedLOD to maintain in memory.

void osgDB::DatabasePager::getUnrefImageDataAfterApplyPolicy ( bool &  changeAutoUnRef,
bool &  valueAutoUnRef 
) const [inline]

Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.

bool osgDB::DatabasePager::isCompiled ( const osg::Drawable drawable  )  const [inline, protected]
static bool osgDB::DatabasePager::isCompiled ( const osg::Drawable drawable,
unsigned int  contextID 
) [inline, static, protected]
bool osgDB::DatabasePager::isCompiled ( osg::StateSet stateSet  )  [inline, protected]
static bool osgDB::DatabasePager::isCompiled ( const osg::StateSet stateSet,
unsigned int  contextID 
) [inline, static, protected]
bool osgDB::DatabasePager::isCompiled ( osg::Texture texture  )  const [inline, protected]
static bool osgDB::DatabasePager::isCompiled ( const osg::Texture texture,
unsigned int  contextID 
) [inline, static, protected]
virtual bool osgDB::DatabasePager::isRunning (  )  const [virtual]
static osg::ref_ptr<DatabasePager>& osgDB::DatabasePager::prototype (  )  [static]

get the prototype singleton used by DatabasePager::create().

virtual void osgDB::DatabasePager::registerPagedLODs ( osg::Node subgraph,
int  frameNumber = 0 
) [virtual]

Find all PagedLOD nodes in a subgraph and register them with the DatabasePager so it can keep track of expired nodes. note, should be only be called from the update thread.

virtual void osgDB::DatabasePager::removeExpiredSubgraphs ( const osg::FrameStamp frameStamp  )  [protected, virtual]

Iterate through the active PagedLOD nodes children removing children which havn't been visited since specified expiryTime. note, should be only be called from the update thread.

virtual void osgDB::DatabasePager::requestNodeFile ( const std::string &  fileName,
osg::Group group,
float  priority,
const osg::FrameStamp framestamp,
osg::ref_ptr< osg::Referenced > &  databaseRequest,
ReaderWriter::Options loadOptions 
) [virtual]
virtual void osgDB::DatabasePager::requestNodeFile ( const std::string &  fileName,
osg::Group group,
float  priority,
const osg::FrameStamp framestamp,
osg::ref_ptr< osg::Referenced > &  databaseRequest 
) [virtual]

Add a request to load a node file to end the the database request list.

Implements osg::NodeVisitor::DatabaseRequestHandler.

bool osgDB::DatabasePager::requiresCompileGLObjects (  )  const

Return true if there are pending compile operations that are required. If requiresCompileGLObjects() return true the application should call compileGLObjects() .

bool osgDB::DatabasePager::requiresExternalCompileGLObjects ( unsigned int  contextID  )  const

Return true if an external draw thread should call compileGLObjects(..) or not.

bool osgDB::DatabasePager::requiresUpdateSceneGraph (  )  const

Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(double).

void osgDB::DatabasePager::resetStats (  ) 

Reset the Stats variables.

void osgDB::DatabasePager::setAcceptNewDatabaseRequests ( bool  acceptNewRequests  )  [inline]

Set whether new database request calls are accepted or ignored.

void osgDB::DatabasePager::setCompileGLObjectsForContextID ( unsigned int  contextID,
bool  on 
)

Turn the compilation of rendering objects for specified graphics context on (true) or off(false).

void osgDB::DatabasePager::setDatabasePagerThreadPause ( bool  pause  ) 

Set whether the database pager thread should be paused or not.

void osgDB::DatabasePager::setDeleteRemovedSubgraphsInDatabaseThread ( bool  flag  )  [inline]

Set whether the removed subgraphs should be deleted in the database thread or not.

void osgDB::DatabasePager::setDoPreCompile ( bool  flag  )  [inline]

Set whether the database pager should pre compile OpenGL objects before allowing them to be merged into the scene graph. Pre compilation helps reduce the chances of frame drops, but also slows the speed at which tiles are merged as they have to be compiled first.

void osgDB::DatabasePager::setDrawablePolicy ( DrawablePolicy  policy  )  [inline]

Set how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings.

void osgDB::DatabasePager::setExpiryDelay ( double  expiryDelay  )  [inline]

Deprecated.

void osgDB::DatabasePager::setExpiryFrames ( int  expiryFrames  )  [inline]

Deprecated.

void osgDB::DatabasePager::setMaxAnisotropyPolicy ( bool  changeAnisotropy,
float  valueAnisotropy 
) [inline]

Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.

void osgDB::DatabasePager::setMaximumNumOfObjectsToCompilePerFrame ( unsigned int  num  )  [inline]

Set the maximum number of OpenGL objects that the page should attempt to compile per frame. Note, Lower values reduces chances of a frame drop but lower the rate that database will be paged in at. Default value is 8.

void osgDB::DatabasePager::setMinimumTimeAvailableForGLCompileAndDeletePerFrame ( double  ta  )  [inline]

Set the minimum amount of time (in seconds) that should be made available for compiling and delete OpenGL objects per frame. Default value is 0.001 (1 millisecond). For usage see notes in setTargetFrameRate.

void osgDB::DatabasePager::setReleaseDelay ( double  releaseDelay  ) 

Deprecated.

void osgDB::DatabasePager::setReleaseFrames ( int  releaseFrames  )  [inline]

Deprecated.

int osgDB::DatabasePager::setSchedulePriority ( OpenThreads::Thread::ThreadPriority  priority  ) 

Set the priority of the database pager thread(s).

void osgDB::DatabasePager::setTargetFrameRate ( double  tfr  )  [inline]

Set the target frame rate that the DatabasePager should assume. Typically one would set this to the value refresh rate of your display system i.e. 60Hz. Default value is 100. Usage notes. The TargetFrameRate and the MinimumTimeAvailableForGLCompileAndDeletePerFrame parameters are not directly used by DatabasePager, but are should be used as a guide for how long to set aside per frame for compiling and deleting OpenGL objects - ie. the value to use when calling DatabasePager::compileGLObjectgs(state,availableTime,). The longer amount of time to set aside cthe faster databases will be paged in but with increased chance of frame drops, the lower the amount of time the set aside the slower databases will paged it but with better chance of avoid any frame drops. The default values are chosen to achieve the later when running on a modern mid to high end PC. The way to compute the amount of available time use a scheme such as : availableTime = maximum(1.0/targetFrameRate - timeTakenDuringUpdateCullAndDraw, minimumTimeAvailableForGLCompileAndDeletePerFrame).

void osgDB::DatabasePager::setTargetMaximumNumberOfPageLOD ( unsigned int  target  )  [inline]

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 osgDB::DatabasePager::setUnrefImageDataAfterApplyPolicy ( bool  changeAutoUnRef,
bool  valueAutoUnRef 
) [inline]

Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.

void osgDB::DatabasePager::setUpThreads ( unsigned int  totalNumThreads = 2,
unsigned int  numHttpThreads = 1 
)
virtual void osgDB::DatabasePager::signalBeginFrame ( const osg::FrameStamp framestamp  )  [virtual]

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.

virtual void osgDB::DatabasePager::signalEndFrame (  )  [virtual]

Signal the database thread that the update, cull and draw dispatch has completed. Note, this is called by the application so that the database pager can go to wake back up now the main rendering threads are iddle waiting for the next frame.

virtual void osgDB::DatabasePager::updateSceneGraph ( const osg::FrameStamp frameStamp  )  [inline, virtual]

Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSceneGraph. Note, must only be called from single thread update phase.


Friends And Related Function Documentation

friend struct DatabaseRequest [friend]
friend class DatabaseThread [friend]
friend class FindCompileableGLObjectsVisitor [friend]
friend class FindPagedLODsVisitor [friend]
friend struct SortFileRequestFunctor [friend]

Member Data Documentation

bool osgDB::DatabasePager::_done [protected]
unsigned int osgDB::DatabasePager::_numTilesMerges [protected]

The documentation for this class was generated from the following file:
Generated on Sat Jun 5 21:48:09 2010 for openscenegraph by  doxygen 1.6.3