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 DatabasePager * | clone () const |
Create a shallow copy on the DatabasePager. | |
virtual void | requestNodeFile (const std::string &fileName, osg::Group *group, float priority, const osg::FrameStamp *framestamp) |
Add a request to load a node file to end the the database request list. | |
virtual void | requestNodeFile (const std::string &fileName, osg::Group *group, float priority, const osg::FrameStamp *framestamp, ReaderWriter::Options *loadOptions) |
virtual void | run () |
Run does the database paging. | |
virtual int | cancel () |
Cancel the database pager thread. | |
virtual void | clear () |
Clear all internally cached structures. | |
void | setDatabasePagerThreadPause (bool pause) |
Set whether the database pager thread should be paused or not. | |
bool | getDatabasePagerThreadPause () const |
Get whether the database pager thread should is paused or not. | |
void | setAcceptNewDatabaseRequests (bool acceptNewRequests) |
Set whether new database request calls are accepted or ignored. | |
bool | getAcceptNewDatabaseRequests () const |
Get whether new database request calls are accepted or ignored. | |
int | getNumFramesActive () const |
Get the number of frames that are currently active. | |
virtual void | signalBeginFrame (const osg::FrameStamp *framestamp) |
Signal the database thread that the update, cull and draw has begun for a new frame. | |
virtual void | signalEndFrame () |
Signal the database thread that the update, cull and draw dispatch has completed. | |
virtual void | registerPagedLODs (osg::Node *subgraph) |
Find all PagedLOD nodes in a subgraph and register them with the DatabasePager so it can keep track of expired nodes. | |
void | setDoPreCompile (bool flag) |
Set whether the database pager should pre compile OpenGL objects before allowing them to be merged into the scene graph. | |
bool | getDoPreCompile () const |
Get whether the database pager should pre compile OpenGL objects before allowing them to be merged into the scene graph. | |
void | setTargetFrameRate (double tfr) |
Set the target frame rate that the DatabasePager should assume. | |
double | getTargetFrameRate () const |
Get the target frame rate that the DatabasePager should assume. | |
void | setMinimumTimeAvailableForGLCompileAndDeletePerFrame (double ta) |
Set the minimum amount of time (in seconds) that should be made available for compiling and delete OpenGL objects per frame. | |
double | getMinimumTimeAvailableForGLCompileAndDeletePerFrame () const |
Get the minimum amount of time that should be made available for compiling and delete OpenGL objects per frame. | |
void | setMaximumNumOfObjectsToCompilePerFrame (unsigned int num) |
Set the maximum number of OpenGL objects that the page should attempt to compile per frame. | |
unsigned int | getMaximumNumOfObjectsToCompilePerFrame () const |
Get the maximum number of OpenGL objects that the page should attempt to compile per frame. | |
void | setExpiryDelay (double expiryDelay) |
Set the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed. | |
double | getExpiryDelay () const |
Get the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed. | |
void | setDeleteRemovedSubgraphsInDatabaseThread (bool flag) |
Set whether the removed subgraphs should be deleted in the database thread or not. | |
bool | getDeleteRemovedSubgraphsInDatabaseThread () const |
Get whether the removed subgraphs should be deleted in the database thread or not. | |
void | setDrawablePolicy (DrawablePolicy policy) |
Set how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings. | |
DrawablePolicy | getDrawablePolicy () const |
Get how loaded drawables should be handled w.r.t their display list/vertex buffer object/vertex array settings. | |
void | setUnrefImageDataAfterApplyPolicy (bool changeAutoUnRef, bool valueAutoUnRef) |
Set whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value. | |
void | getUnrefImageDataAfterApplyPolicy (bool &changeAutoUnRef, bool &valueAutoUnRef) const |
Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value. | |
void | setMaxAnisotropyPolicy (bool changeAnisotropy, float valueAnisotropy) |
Set whether newly loaded textures should have their MaxAnisotopy set to a specified value. | |
void | getMaxAnisotropyPolicy (bool &changeAnisotropy, float &valueAnisotropy) const |
Set whether newly loaded textures should have their MaxAnisotopy set to a specified value. | |
bool | requiresUpdateSceneGraph () const |
Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(double). | |
virtual void | updateSceneGraph (double currentFrameTime) |
Merge the changes to the scene graph by calling calling removeExpiredSubgraphs then addLoadedDataToSceneGraph. | |
void | setCompileGLObjectsForContextID (unsigned int contextID, bool on) |
Turn the compilation of rendering objects for specfied graphics context on (true) or off(false). | |
bool | getCompileGLObjectsForContextID (unsigned int contextID) |
Get whether the compilation of rendering objects for specfied graphics context on (true) or off(false). | |
bool | requiresExternalCompileGLObjects (unsigned int contextID) const |
Rerturn true if an external draw thread should call compileGLObjects(. | |
bool | requiresCompileGLObjects () const |
Return true if there are pending compile operations that are required. | |
virtual void | compileGLObjects (osg::State &state, double &availableTime) |
Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph. | |
virtual void | compileAllGLObjects (osg::State &state) |
Compile the rendering objects (display lists,texture objects, VBO's) on loaded subgraph. | |
unsigned int | getFileRequestListSize () const |
Report how many items are in the _fileRequestList queue. | |
unsigned int | getDataToCompileListSize () const |
Report how many items are in the _dataToCompileList queue. | |
double | getMinimumTimeToMergeTile () 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 | getMaximumTimeToMergeTile () const |
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 | getAverageTimeToMergeTiles () const |
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. | |
void | resetStats () |
Reset the Stats variables. | |
Static Public Member Functions | |
static osg::ref_ptr < DatabasePager > & | prototype () |
get the prototype singleton used by DatabasePager::create(). | |
static DatabasePager * | create () |
create a DatabasePager by cloning DatabasePager::prototype(). | |
Protected Types | |
typedef std::vector < osg::ref_ptr < DatabaseRequest > > | DatabaseRequestList |
typedef std::vector < osg::ref_ptr < osg::Object > > | ObjectList |
Protected Member Functions | |
virtual | ~DatabasePager () |
void | updateDatabasePagerThreadBlock () |
virtual void | removeExpiredSubgraphs (double currentFrameTime) |
Iterate through the active PagedLOD nodes children removing children which havn't been visited since specified expiryTime. | |
void | addLoadedDataToSceneGraph (double currentFrameTime) |
Add the loaded data to the scene graph. | |
Protected Attributes | |
OpenThreads::Mutex | _run_mutex |
bool | _startThreadCalled |
osg::ref_ptr < osg::RefBlock > | _databasePagerThreadBlock |
bool | _done |
bool | _acceptNewRequests |
bool | _databasePagerThreadPaused |
int | _numFramesActive |
OpenThreads::Mutex | _numFramesActiveMutex |
int | _frameNumber |
DatabaseRequestList | _fileRequestList |
OpenThreads::Mutex | _fileRequestListMutex |
DatabaseRequestList | _dataToCompileList |
OpenThreads::Mutex | _dataToCompileListMutex |
DrawablePolicy | _drawablePolicy |
bool | _changeAutoUnRef |
bool | _valueAutoUnRef |
bool | _changeAnisotropy |
float | _valueAnisotropy |
bool | _deleteRemovedSubgraphsInDatabaseThread |
ObjectList | _childrenToDeleteList |
OpenThreads::Mutex | _childrenToDeleteListMutex |
DatabaseRequestList | _dataToMergeList |
OpenThreads::Mutex | _dataToMergeListMutex |
PagedLODList | _activePagedLODList |
PagedLODList | _inactivePagedLODList |
double | _expiryDelay |
ActiveGraphicsContexts | _activeGraphicsContexts |
bool | _doPreCompile |
double | _targetFrameRate |
double | _minimumTimeAvailableForGLCompileAndDeletePerFrame |
unsigned int | _maximumNumOfObjectsToCompilePerFrame |
double | _minimumTimeToMergeTile |
double | _maximumTimeToMergeTile |
double | _totalTimeToMergeTiles |
unsigned int | _numTilesMerges |
Friends | |
struct | DatabaseRequest |
class | FindCompileableGLObjectsVisitor |
class | FindPagedLODsVisitor |
struct | SortFileRequestFunctor |
Classes | |
struct | CompileOperation |
struct | DatabaseRequest |
typedef OpenThreads::Thread::ThreadPriority osgDB::DatabasePager::ThreadPriority |
typedef std::list< osg::ref_ptr<osg::PagedLOD> > osgDB::DatabasePager::PagedLODList |
typedef std::set< osg::ref_ptr<osg::StateSet> > osgDB::DatabasePager::StateSetList |
typedef std::vector< osg::ref_ptr<osg::Drawable> > osgDB::DatabasePager::DrawableList |
typedef std::pair<StateSetList,DrawableList> osgDB::DatabasePager::DataToCompile |
typedef std::map< unsigned int, DataToCompile > osgDB::DatabasePager::DataToCompileMap |
typedef std::set<unsigned int> osgDB::DatabasePager::ActiveGraphicsContexts |
typedef std::vector< osg::observer_ptr<osg::GraphicsContext> > osgDB::DatabasePager::CompileGraphicsContexts |
typedef std::vector< osg::ref_ptr<DatabaseRequest> > osgDB::DatabasePager::DatabaseRequestList [protected] |
typedef std::vector< osg::ref_ptr<osg::Object> > osgDB::DatabasePager::ObjectList [protected] |
osgDB::DatabasePager::DatabasePager | ( | ) |
osgDB::DatabasePager::DatabasePager | ( | const DatabasePager & | rhs | ) |
virtual osgDB::DatabasePager::~DatabasePager | ( | ) | [protected, virtual] |
virtual DatabasePager* osgDB::DatabasePager::clone | ( | ) | const [inline, virtual] |
Create a shallow copy on the DatabasePager.
static osg::ref_ptr<DatabasePager>& osgDB::DatabasePager::prototype | ( | ) | [static] |
get the prototype singleton used by DatabasePager::create().
static DatabasePager* osgDB::DatabasePager::create | ( | ) | [static] |
create a DatabasePager by cloning DatabasePager::prototype().
virtual void osgDB::DatabasePager::requestNodeFile | ( | const std::string & | fileName, | |
osg::Group * | group, | |||
float | priority, | |||
const osg::FrameStamp * | framestamp | |||
) | [virtual] |
Add a request to load a node file to end the the database request list.
Implements osg::NodeVisitor::DatabaseRequestHandler.
virtual void osgDB::DatabasePager::requestNodeFile | ( | const std::string & | fileName, | |
osg::Group * | group, | |||
float | priority, | |||
const osg::FrameStamp * | framestamp, | |||
ReaderWriter::Options * | loadOptions | |||
) | [virtual] |
virtual void osgDB::DatabasePager::run | ( | ) | [virtual] |
Run does the database paging.
virtual int osgDB::DatabasePager::cancel | ( | ) | [virtual] |
Cancel the database pager thread.
virtual void osgDB::DatabasePager::clear | ( | ) | [virtual] |
Clear all internally cached structures.
void osgDB::DatabasePager::setDatabasePagerThreadPause | ( | bool | pause | ) |
Set whether the database pager thread should be paused or not.
bool osgDB::DatabasePager::getDatabasePagerThreadPause | ( | ) | const [inline] |
Get whether the database pager thread should is paused or not.
void osgDB::DatabasePager::setAcceptNewDatabaseRequests | ( | bool | acceptNewRequests | ) | [inline] |
Set whether new database request calls are accepted or ignored.
bool osgDB::DatabasePager::getAcceptNewDatabaseRequests | ( | ) | const [inline] |
Get whether new database request calls are accepted or ignored.
int osgDB::DatabasePager::getNumFramesActive | ( | ) | const [inline] |
Get the number of frames that are currently active.
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::registerPagedLODs | ( | osg::Node * | subgraph | ) | [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.
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.
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.
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).
double osgDB::DatabasePager::getTargetFrameRate | ( | ) | const [inline] |
Get the target frame rate that the DatabasePager should assume.
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.
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.
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.
unsigned int osgDB::DatabasePager::getMaximumNumOfObjectsToCompilePerFrame | ( | ) | const [inline] |
Get the maximum number of OpenGL objects that the page should attempt to compile per frame.
void osgDB::DatabasePager::setExpiryDelay | ( | double | expiryDelay | ) | [inline] |
Set the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed.
double osgDB::DatabasePager::getExpiryDelay | ( | ) | const [inline] |
Get the amount of time that a subgraph will be kept without being visited in the cull traversal before being removed.
void osgDB::DatabasePager::setDeleteRemovedSubgraphsInDatabaseThread | ( | bool | flag | ) | [inline] |
Set whether the removed subgraphs should be deleted in the database thread or not.
bool osgDB::DatabasePager::getDeleteRemovedSubgraphsInDatabaseThread | ( | ) | const [inline] |
Get whether the removed subgraphs should be deleted in the database thread or not.
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.
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.
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::getUnrefImageDataAfterApplyPolicy | ( | bool & | changeAutoUnRef, | |
bool & | valueAutoUnRef | |||
) | const [inline] |
Get whether newly loaded textures should have their UnrefImageDataAfterApply set to a specified value.
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::getMaxAnisotropyPolicy | ( | bool & | changeAnisotropy, | |
float & | valueAnisotropy | |||
) | const [inline] |
Set whether newly loaded textures should have their MaxAnisotopy set to a specified value.
bool osgDB::DatabasePager::requiresUpdateSceneGraph | ( | ) | const |
Return true if there are pending updates to the scene graph that require a call to updateSceneGraph(double).
virtual void osgDB::DatabasePager::updateSceneGraph | ( | double | currentFrameTime | ) | [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.
void osgDB::DatabasePager::setCompileGLObjectsForContextID | ( | unsigned int | contextID, | |
bool | on | |||
) |
Turn the compilation of rendering objects for specfied graphics context on (true) or off(false).
bool osgDB::DatabasePager::getCompileGLObjectsForContextID | ( | unsigned int | contextID | ) |
Get whether the compilation of rendering objects for specfied graphics context on (true) or off(false).
bool osgDB::DatabasePager::requiresExternalCompileGLObjects | ( | unsigned int | contextID | ) | const |
Rerturn true if an external draw thread should call compileGLObjects(.
.) or not.
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() .
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.
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.
unsigned int osgDB::DatabasePager::getFileRequestListSize | ( | ) | const [inline] |
Report how many items are in the _fileRequestList queue.
unsigned int osgDB::DatabasePager::getDataToCompileListSize | ( | ) | const [inline] |
Report how many items are in the _dataToCompileList queue.
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.
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::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.
void osgDB::DatabasePager::resetStats | ( | ) |
Reset the Stats variables.
void osgDB::DatabasePager::updateDatabasePagerThreadBlock | ( | ) | [inline, protected] |
virtual void osgDB::DatabasePager::removeExpiredSubgraphs | ( | double | currentFrameTime | ) | [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.
void osgDB::DatabasePager::addLoadedDataToSceneGraph | ( | double | currentFrameTime | ) | [protected] |
Add the loaded data to the scene graph.
friend struct DatabaseRequest [friend] |
friend class FindCompileableGLObjectsVisitor [friend] |
friend class FindPagedLODsVisitor [friend] |
friend struct SortFileRequestFunctor [friend] |
OpenThreads::Mutex osgDB::DatabasePager::_run_mutex [protected] |
bool osgDB::DatabasePager::_startThreadCalled [protected] |
bool osgDB::DatabasePager::_done [protected] |
bool osgDB::DatabasePager::_acceptNewRequests [protected] |
bool osgDB::DatabasePager::_databasePagerThreadPaused [protected] |
int osgDB::DatabasePager::_numFramesActive [protected] |
OpenThreads::Mutex osgDB::DatabasePager::_numFramesActiveMutex [mutable, protected] |
int osgDB::DatabasePager::_frameNumber [protected] |
OpenThreads::Mutex osgDB::DatabasePager::_fileRequestListMutex [mutable, protected] |
OpenThreads::Mutex osgDB::DatabasePager::_dataToCompileListMutex [mutable, protected] |
DrawablePolicy osgDB::DatabasePager::_drawablePolicy [protected] |
bool osgDB::DatabasePager::_changeAutoUnRef [protected] |
bool osgDB::DatabasePager::_valueAutoUnRef [protected] |
bool osgDB::DatabasePager::_changeAnisotropy [protected] |
float osgDB::DatabasePager::_valueAnisotropy [protected] |
bool osgDB::DatabasePager::_deleteRemovedSubgraphsInDatabaseThread [protected] |
OpenThreads::Mutex osgDB::DatabasePager::_childrenToDeleteListMutex [mutable, protected] |
OpenThreads::Mutex osgDB::DatabasePager::_dataToMergeListMutex [mutable, protected] |
double osgDB::DatabasePager::_expiryDelay [protected] |
bool osgDB::DatabasePager::_doPreCompile [protected] |
double osgDB::DatabasePager::_targetFrameRate [protected] |
double osgDB::DatabasePager::_minimumTimeAvailableForGLCompileAndDeletePerFrame [protected] |
unsigned int osgDB::DatabasePager::_maximumNumOfObjectsToCompilePerFrame [protected] |
double osgDB::DatabasePager::_minimumTimeToMergeTile [protected] |
double osgDB::DatabasePager::_maximumTimeToMergeTile [protected] |
double osgDB::DatabasePager::_totalTimeToMergeTiles [protected] |
unsigned int osgDB::DatabasePager::_numTilesMerges [protected] |