diff --git a/include/osgUtil/IncrementalCompileOperation b/include/osgUtil/IncrementalCompileOperation index f7a486c92..83283553d 100644 --- a/include/osgUtil/IncrementalCompileOperation +++ b/include/osgUtil/IncrementalCompileOperation @@ -15,7 +15,7 @@ #define OSGUTIL_INCREMENTALCOMPILEOPERATOR #include -#include +#include namespace osgUtil { @@ -49,74 +49,6 @@ class OSGUTIL_EXPORT StateToCompile : public osg::NodeVisitor virtual void apply(osg::Texture& texture); }; -class OSGUTIL_EXPORT CompileStats : public osg::Referenced -{ - public: - - CompileStats(); - - void add(const std::string& name,double size, double time); - - double estimateTime(const std::string& name, double size) const; - double estimateTime2(const std::string& name, double size) const; - double estimateTime3(const std::string& name, double size) const; - double estimateTime4(const std::string& name, double size) const; - double averageTime(const std::string& name) const; - - void print(std::ostream& out) const; - - protected: - - struct OSGUTIL_EXPORT Values - { - Values(): - totalSize(0.0), totalTime(0.0), totalNum(0.0), - minSize(0.0), minTime(0.0), - a(0.0), b(0.0), - m(0.0), n(0.0), o(0.0), p(0.0) {} - - void add(double size, double time); - - double estimateTime(double size) const - { - return a + b * size; - } - - double estimateTime2(double size) const - { - return (totalTime/totalSize) * size; - } - - double estimateTime3(double size) const - { - if (size StatsMap; - StatsMap _statsMap; -}; - class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation { public: @@ -186,8 +118,8 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation osg::Geometry* getForceTextureDownloadGeometry() { return _forceTextureDownloadGeometry.get(); } const osg::Geometry* getForceTextureDownloadGeometry() const { return _forceTextureDownloadGeometry.get(); } - CompileStats* getCompileStats() { return _compileStats.get(); } - const CompileStats* getCompileStats() const { return _compileStats.get(); } + GraphicsCostEstimator* getGraphicsCostEstimator() { return _graphicsCostEstimator.get(); } + const GraphicsCostEstimator* getGraphicsCostEstimator() const { return _graphicsCostEstimator.get(); } typedef std::vector Contexts; @@ -338,22 +270,22 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation virtual ~IncrementalCompileOperation(); - double _targetFrameRate; - double _minimumTimeAvailableForGLCompileAndDeletePerFrame; - unsigned int _maximumNumOfObjectsToCompilePerFrame; - double _flushTimeRatio; - double _conservativeTimeRatio; + double _targetFrameRate; + double _minimumTimeAvailableForGLCompileAndDeletePerFrame; + unsigned int _maximumNumOfObjectsToCompilePerFrame; + double _flushTimeRatio; + double _conservativeTimeRatio; - osg::ref_ptr _forceTextureDownloadGeometry; - osg::ref_ptr _compileStats; + osg::ref_ptr _forceTextureDownloadGeometry; + osg::ref_ptr _graphicsCostEstimator; - OpenThreads::Mutex _toCompileMutex; - CompileSets _toCompile; + OpenThreads::Mutex _toCompileMutex; + CompileSets _toCompile; - OpenThreads::Mutex _compiledMutex; - CompileSets _compiled; + OpenThreads::Mutex _compiledMutex; + CompileSets _compiled; - ContextSet _contexts; + ContextSet _contexts; }; diff --git a/src/osgUtil/IncrementalCompileOperation.cpp b/src/osgUtil/IncrementalCompileOperation.cpp index 7d2751036..74ffa62d5 100644 --- a/src/osgUtil/IncrementalCompileOperation.cpp +++ b/src/osgUtil/IncrementalCompileOperation.cpp @@ -163,97 +163,6 @@ void StateToCompile::apply(osg::Texture& texture) _textures.insert(&texture); } -///////////////////////////////////////////////////////////////// -// -// CompileStats -// -CompileStats::CompileStats() -{ -} - -void CompileStats::add(const std::string& name,double size, double time) -{ - Values& values = _statsMap[name]; - values.add(size,time); -} - -double CompileStats::estimateTime(const std::string& name, double size) const -{ - StatsMap::const_iterator itr = _statsMap.find(name); - return (itr!=_statsMap.end()) ? itr->second.estimateTime(size) : 0.0; -} - -double CompileStats::estimateTime2(const std::string& name, double size) const -{ - StatsMap::const_iterator itr = _statsMap.find(name); - return (itr!=_statsMap.end()) ? itr->second.estimateTime2(size) : 0.0; -} - -double CompileStats::estimateTime3(const std::string& name, double size) const -{ - StatsMap::const_iterator itr = _statsMap.find(name); - return (itr!=_statsMap.end()) ? itr->second.estimateTime3(size) : 0.0; -} - -double CompileStats::estimateTime4(const std::string& name, double size) const -{ - StatsMap::const_iterator itr = _statsMap.find(name); - return (itr!=_statsMap.end()) ? itr->second.estimateTime4(size) : 0.0; -} - -double CompileStats::averageTime(const std::string& name) const -{ - StatsMap::const_iterator itr = _statsMap.find(name); - return (itr!=_statsMap.end()) ? itr->second.averageTime() : 0.0; -} - -void CompileStats::print(std::ostream& out) const -{ - for(StatsMap::const_iterator itr = _statsMap.begin(); - itr != _statsMap.end(); - ++itr) - { - const Values& values = itr->second; - out<first<<" : averageTime "<