OpenSceneGraph  3.0.1
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
osgUtil::IncrementalCompileOperation Class Reference
Inheritance diagram for osgUtil::IncrementalCompileOperation:
Inheritance graph
[legend]

List of all members.

Classes

struct  CompileCompletedCallback
struct  CompileDrawableOp
struct  CompileInfo
class  CompileList
struct  CompileOp
struct  CompileProgramOp
class  CompileSet
struct  CompileTextureOp

Public Types

typedef std::vector
< osg::GraphicsContext * > 
Contexts
typedef std::set
< osg::GraphicsContext * > 
ContextSet
typedef std::list
< osg::ref_ptr< CompileSet > > 
CompileSets

Public Member Functions

 IncrementalCompileOperation ()
bool isActive () const
 Return true if the IncrementCompileOperation is active.
bool requiresCompile (StateToCompile &stateToCompile)
void setTargetFrameRate (double tfr)
 Set the target frame rate that the IncrementalCompileOperation should assume.
double getTargetFrameRate () const
 Get the target frame rate that the IncrementalCompileOperation 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 setFlushTimeRatio (double ratio)
 FlushTimeRatio governs how much of the spare time in each frame is used for flushing deleted OpenGL objects.
double getFlushTimeRatio () const
void setConservativeTimeRatio (double ratio)
 ConservativeTimeRatio governs how much of the measured spare time in each frame is used for flushing deleted and compile new OpenGL objects.
double getConservativeTimeRatio () const
void assignForceTextureDownloadGeometry ()
 Assign a geometry and associated StateSet than is applied after each texture compile to atttempt to force the OpenGL drive to download the texture object to OpenGL graphics card.
void setForceTextureDownloadGeometry (osg::Geometry *geom)
 Set the osg::Geometry to apply after each texture compile to atttempt to force the OpenGL drive to download the texture object to OpenGL graphics card.
osg::GeometrygetForceTextureDownloadGeometry ()
const osg::GeometrygetForceTextureDownloadGeometry () const
void assignContexts (Contexts &contexts)
void removeContexts (Contexts &contexts)
void addGraphicsContext (osg::GraphicsContext *gc)
void removeGraphicsContext (osg::GraphicsContext *gc)
ContextSetgetContextSet ()
const ContextSetgetContextSet () const
void mergeCompiledSubgraphs (const osg::FrameStamp *frameStamp)
 Merge subgraphs that have been compiled.
void setCurrentFrameNumber (unsigned int fn)
 Set the current frame number that the IncrementalCompileOperation should use as a reference value for calculations based on current frame number.
unsigned int getCurrentFrameNumber () const
void compileAllForNextFrame (unsigned int numFramesToDoCompileAll=1)
 tell the IncrementalCompileOperation to compile all pending objects during next draw traversal, for specified number of frames.
void setCompileAllTillFrameNumber (unsigned int fn)
 tell the IncrementalCompileOperation to compile all pending objects during next draw traversal, till specified frame number.
unsigned int getCompileAllTillFrameNumber () const
virtual void operator() (osg::GraphicsContext *context)
void add (osg::Node *subgraphToCompile)
 Add a subgraph to be compiled.
void add (osg::Group *attachmentPoint, osg::Node *subgraphToCompile)
 Add a subgraph to be compiled and add automatically to attachPoint on call to mergeCompiledSubgraphs.
void add (CompileSet *compileSet, bool callBuildCompileMap=true)
 Add a CompileSet to be compiled.
void remove (CompileSet *compileSet)
 Remove CompileSet from list.
OpenThreads::Mutex * getToCompiledMutex ()
CompileSetsgetToCompile ()
OpenThreads::Mutex * getCompiledMutex ()
CompileSetsgetCompiled ()

Protected Member Functions

virtual ~IncrementalCompileOperation ()
void compileSets (CompileSets &toCompile, CompileInfo compileInfo)

Protected Attributes

double _targetFrameRate
double _minimumTimeAvailableForGLCompileAndDeletePerFrame
unsigned int _maximumNumOfObjectsToCompilePerFrame
double _flushTimeRatio
double _conservativeTimeRatio
unsigned int _currentFrameNumber
unsigned int _compileAllTillFrameNumber
osg::ref_ptr< osg::Geometry_forceTextureDownloadGeometry
OpenThreads::Mutex _toCompileMutex
CompileSets _toCompile
OpenThreads::Mutex _compiledMutex
CompileSets _compiled
ContextSet _contexts

Member Typedef Documentation


Constructor & Destructor Documentation


Member Function Documentation

Add a subgraph to be compiled.

void osgUtil::IncrementalCompileOperation::add ( osg::Group attachmentPoint,
osg::Node subgraphToCompile 
)

Add a subgraph to be compiled and add automatically to attachPoint on call to mergeCompiledSubgraphs.

void osgUtil::IncrementalCompileOperation::add ( CompileSet compileSet,
bool  callBuildCompileMap = true 
)

Add a CompileSet to be compiled.

Assign a geometry and associated StateSet than is applied after each texture compile to atttempt to force the OpenGL drive to download the texture object to OpenGL graphics card.

void osgUtil::IncrementalCompileOperation::compileAllForNextFrame ( unsigned int  numFramesToDoCompileAll = 1)

tell the IncrementalCompileOperation to compile all pending objects during next draw traversal, for specified number of frames.

void osgUtil::IncrementalCompileOperation::compileSets ( CompileSets toCompile,
CompileInfo  compileInfo 
) [protected]

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

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.

Get the target frame rate that the IncrementalCompileOperation should assume.

Return true if the IncrementCompileOperation is active.

Merge subgraphs that have been compiled.

virtual void osgUtil::IncrementalCompileOperation::operator() ( osg::GraphicsContext context) [virtual]

Remove CompileSet from list.

tell the IncrementalCompileOperation to compile all pending objects during next draw traversal, till specified frame number.

ConservativeTimeRatio governs how much of the measured spare time in each frame is used for flushing deleted and compile new OpenGL objects.

Default value is 0.5, valid range is 0.1 to 1.0. A ratio near 1.0 will lead to paged databases being compiled and merged quicker but increase the chances of frame drop. A ratio near 0.1 will lead to paged databases being compiled and merged closer but reduse the chances of frame drop.

Set the current frame number that the IncrementalCompileOperation should use as a reference value for calculations based on current frame number.

Note, this value is set by the mergeCompiledSubgraphs(..) method so one won't normally need to call set the CurrentFrameNumber manually.

FlushTimeRatio governs how much of the spare time in each frame is used for flushing deleted OpenGL objects.

Default value is 0.5, valid range is 0.1 to 0.9.

Set the osg::Geometry to apply after each texture compile to atttempt to force the OpenGL drive to download the texture object to OpenGL graphics card.

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.

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.

Set the target frame rate that the IncrementalCompileOperation 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 IncrementalCompileOperation, but are should be used as a guide for how long to set aside per frame for compiling and deleting OpenGL objects. The longer amount of time to set aside the 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).


Member Data Documentation


The documentation for this class was generated from the following file:

osg logo
Generated at Tue Feb 28 2012 17:50:46 for the OpenSceneGraph by doxygen 1.7.6.1.