14 #ifndef OSGUTIL_INCREMENTALCOMPILEOPERATOR
15 #define OSGUTIL_INCREMENTALCOMPILEOPERATOR
17 #include <osgUtil/GLObjectsVisitor>
18 #include <osg/Geometry>
45 bool empty()
const {
return _textures.empty() && _programs.empty() && _drawables.empty(); }
62 bool isActive()
const {
return !_contexts.empty(); }
116 void assignForceTextureDownloadGeometry();
124 typedef std::vector<osg::GraphicsContext*>
Contexts;
125 void assignContexts(Contexts& contexts);
126 void removeContexts(Contexts& contexts);
148 void compileAllForNextFrame(
unsigned int numFramesToDoCompileAll=1);
166 if (compileAll)
return true;
167 if (maxNumObjectsToCompile==0)
return false;
168 return (allocatedTime - timer.elapsedTime()) >= estimatedTimeForCompile;
182 virtual double estimatedTimeForCompile(
CompileInfo& compileInfo)
const = 0;
184 virtual bool compile(
CompileInfo& compileInfo) = 0;
190 double estimatedTimeForCompile(
CompileInfo& compileInfo)
const;
198 double estimatedTimeForCompile(
CompileInfo& compileInfo)
const;
206 double estimatedTimeForCompile(
CompileInfo& compileInfo)
const;
217 bool empty()
const {
return _compileOps.empty(); }
223 double estimatedTimeForCompile(
CompileInfo& compileInfo)
const;
238 virtual bool compileCompleted(
CompileSet* compileSet) = 0;
247 _subgraphToCompile(subgraphToCompile) {}
250 _attachmentPoint(attachmentPoint),
251 _subgraphToCompile(subgraphToCompile) {}
253 void buildCompileMap(ContextSet& contexts,
StateToCompile& stateToCompile);
258 bool compiled()
const {
return _numberCompileListsToCompile==0; }
266 typedef std::map<osg::GraphicsContext*, CompileList >
CompileMap;
283 void add(
CompileSet* compileSet,
bool callBuildCompileMap=
true);
302 void compileSets(CompileSets& toCompile, CompileInfo& compileInfo);
osg::ref_ptr< osg::PixelBufferObject > _pbo
double getTargetFrameRate() const
unsigned int getCompileAllTillFrameNumber() const
void add(osg::Drawable *drawable)
std::set< osg::GraphicsContext * > ContextSet
OpenThreads::Mutex * getCompiledMutex()
ContextSet & getContextSet()
unsigned int maxNumObjectsToCompile
CompileSets & getToCompile()
This class provides an object-oriented thread mutex interface.
std::set< osg::StateSet * > StateSetSet
double _minimumTimeAvailableForGLCompileAndDeletePerFrame
DrawableSet _drawablesHandled
osg::ref_ptr< CompileCompletedCallback > _compileCompletedCallback
unsigned int _maximumNumOfObjectsToCompilePerFrame
std::set< osg::Program * > ProgramSet
std::list< osg::ref_ptr< CompileOp > > CompileOps
void add(osg::Program *program)
CompileSet(osg::Node *subgraphToCompile)
unsigned int getCurrentFrameNumber() const
void add(osg::Texture *texture)
unsigned int _currentFrameNumber
osg::ref_ptr< osg::Program > _program
osg::observer_ptr< osg::Group > _attachmentPoint
double _conservativeTimeRatio
std::map< osg::GraphicsContext *, CompileList > CompileMap
double getConservativeTimeRatio() const
OpenThreads::Atomic _numberCompileListsToCompile
osg::Geometry * getForceTextureDownloadGeometry()
void setMarkerObject(osg::Object *mo)
std::set< osg::Texture * > TextureSet
bool okToCompile(double estimatedTimeForCompile=0.0) const
This class provides an atomic increment and decrement operation.
osg::ref_ptr< osg::Texture > _texture
IncrementalCompileOperation * incrementalCompileOperation
void setForceTextureDownloadGeometry(osg::Geometry *geom)
const osg::Geometry * getForceTextureDownloadGeometry() const
osg::ref_ptr< osg::Geometry > _forceTextureDownloadGeometry
void setTargetFrameRate(double tfr)
osg::ref_ptr< osg::Drawable > _drawable
double getMinimumTimeAvailableForGLCompileAndDeletePerFrame() const
unsigned int getMaximumNumOfObjectsToCompilePerFrame() const
osg::ref_ptr< osg::Node > _subgraphToCompile
unsigned int _compileAllTillFrameNumber
OpenThreads::Mutex * getToCompiledMutex()
void setCompileAllTillFrameNumber(unsigned int fn)
osg::Object * getMarkerObject()
void setMinimumTimeAvailableForGLCompileAndDeletePerFrame(double ta)
std::vector< osg::GraphicsContext * > Contexts
osg::ref_ptr< osg::Object > _markerObject
void setCurrentFrameNumber(unsigned int fn)
void setFlushTimeRatio(double ratio)
OpenThreads::Mutex _compiledMutex
OpenThreads::Mutex _toCompileMutex
std::list< osg::ref_ptr< CompileSet > > CompileSets
CompileSets & getCompiled()
StateSetSet _statesetsHandled
std::set< osg::Drawable * > DrawableSet
double getFlushTimeRatio() const
void setMaximumNumOfObjectsToCompilePerFrame(unsigned int num)
const osg::Object * getMarkerObject() const
GLObjectsVisitor::Mode _mode
void setConservativeTimeRatio(double ratio)
osg::ref_ptr< osg::Object > _markerObject
const ContextSet & getContextSet() const
CompileSet(osg::Group *attachmentPoint, osg::Node *subgraphToCompile)
Shader generator framework.