Moved GraphicsCostEstimator from osgUtil into core OSG library
This commit is contained in:
parent
bcda8e4671
commit
88ce98b47d
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
#include <osgUtil/GraphicsCostEstimator>
|
#include <osg/GraphicsCostEstimator>
|
||||||
|
|
||||||
class CalibrateCostEsimator : public osg::GraphicsOperation
|
class CalibrateCostEsimator : public osg::GraphicsOperation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CalibrateCostEsimator(osgUtil::GraphicsCostEstimator* gce):
|
CalibrateCostEsimator(osg::GraphicsCostEstimator* gce):
|
||||||
osg::GraphicsOperation("CalbirateCostEstimator",false),
|
osg::GraphicsOperation("CalbirateCostEstimator",false),
|
||||||
_gce(gce) {}
|
_gce(gce) {}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public:
|
|||||||
_gce->calibrate(renderInfo);
|
_gce->calibrate(renderInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osgUtil::GraphicsCostEstimator> _gce;
|
osg::ref_ptr<osg::GraphicsCostEstimator> _gce;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,14 +54,14 @@ int main(int argc, char** argv)
|
|||||||
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(arguments);
|
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles(arguments);
|
||||||
if (!node) return 0;
|
if (!node) return 0;
|
||||||
|
|
||||||
osg::ref_ptr<osgUtil::GraphicsCostEstimator> gce = new osgUtil::GraphicsCostEstimator;
|
osg::ref_ptr<osg::GraphicsCostEstimator> gce = new osg::GraphicsCostEstimator;
|
||||||
|
|
||||||
viewer.setSceneData(node.get());
|
viewer.setSceneData(node.get());
|
||||||
|
|
||||||
viewer.realize();
|
viewer.realize();
|
||||||
|
|
||||||
osgUtil::CostPair compileCost = gce->estimateCompileCost(node.get());
|
osg::CostPair compileCost = gce->estimateCompileCost(node.get());
|
||||||
osgUtil::CostPair drawCost = gce->estimateDrawCost(node.get());
|
osg::CostPair drawCost = gce->estimateDrawCost(node.get());
|
||||||
|
|
||||||
OSG_NOTICE<<"estimateCompileCost("<<node->getName()<<"), CPU="<<compileCost.first<<" GPU="<<compileCost.second<<std::endl;
|
OSG_NOTICE<<"estimateCompileCost("<<node->getName()<<"), CPU="<<compileCost.first<<" GPU="<<compileCost.second<<std::endl;
|
||||||
OSG_NOTICE<<"estimateDrawCost("<<node->getName()<<"), CPU="<<drawCost.first<<" GPU="<<drawCost.second<<std::endl;
|
OSG_NOTICE<<"estimateDrawCost("<<node->getName()<<"), CPU="<<drawCost.first<<" GPU="<<drawCost.second<<std::endl;
|
||||||
|
@ -11,18 +11,22 @@
|
|||||||
* OpenSceneGraph Public License for more details.
|
* OpenSceneGraph Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OSGUTIL_GRAPHICSCOSTESTIMATOR
|
#ifndef OSG_GRAPHICSCOSTESTIMATOR
|
||||||
#define OSGUTIL_GRAPHICSCOSTESTIMATOR
|
#define OSG_GRAPHICSCOSTESTIMATOR
|
||||||
|
|
||||||
#include <osgUtil/Export>
|
#include <osg/Referenced>
|
||||||
|
#include <osg/ref_ptr>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <osg/Geometry>
|
namespace osg
|
||||||
#include <osg/Texture>
|
|
||||||
#include <osg/Program>
|
|
||||||
|
|
||||||
namespace osgUtil
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Geometry;
|
||||||
|
class Texture;
|
||||||
|
class Program;
|
||||||
|
class Node;
|
||||||
|
class RenderInfo;
|
||||||
|
|
||||||
struct ClampedLinearCostFunction1D
|
struct ClampedLinearCostFunction1D
|
||||||
{
|
{
|
||||||
ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0):
|
ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0):
|
||||||
@ -50,7 +54,7 @@ struct ClampedLinearCostFunction1D
|
|||||||
typedef std::pair<double, double> CostPair;
|
typedef std::pair<double, double> CostPair;
|
||||||
|
|
||||||
|
|
||||||
class OSGUTIL_EXPORT GeometryCostEstimator : public osg::Referenced
|
class OSG_EXPORT GeometryCostEstimator : public osg::Referenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GeometryCostEstimator();
|
GeometryCostEstimator();
|
||||||
@ -70,7 +74,7 @@ protected:
|
|||||||
double _displayListCompileFactor;
|
double _displayListCompileFactor;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OSGUTIL_EXPORT TextureCostEstimator : public osg::Referenced
|
class OSG_EXPORT TextureCostEstimator : public osg::Referenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextureCostEstimator();
|
TextureCostEstimator();
|
||||||
@ -85,7 +89,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class OSGUTIL_EXPORT ProgramCostEstimator : public osg::Referenced
|
class OSG_EXPORT ProgramCostEstimator : public osg::Referenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProgramCostEstimator();
|
ProgramCostEstimator();
|
||||||
@ -100,7 +104,7 @@ protected:
|
|||||||
ClampedLinearCostFunction1D _drawCost;
|
ClampedLinearCostFunction1D _drawCost;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OSGUTIL_EXPORT GraphicsCostEstimator : public osg::Referenced
|
class OSG_EXPORT GraphicsCostEstimator : public osg::Referenced
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GraphicsCostEstimator();
|
GraphicsCostEstimator();
|
@ -15,7 +15,8 @@
|
|||||||
#define OSGUTIL_INCREMENTALCOMPILEOPERATOR
|
#define OSGUTIL_INCREMENTALCOMPILEOPERATOR
|
||||||
|
|
||||||
#include <osgUtil/GLObjectsVisitor>
|
#include <osgUtil/GLObjectsVisitor>
|
||||||
#include <osgUtil/GraphicsCostEstimator>
|
#include <osg/GraphicsCostEstimator>
|
||||||
|
#include <osg/Geometry>
|
||||||
|
|
||||||
namespace osgUtil {
|
namespace osgUtil {
|
||||||
|
|
||||||
@ -119,8 +120,8 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation
|
|||||||
osg::Geometry* getForceTextureDownloadGeometry() { return _forceTextureDownloadGeometry.get(); }
|
osg::Geometry* getForceTextureDownloadGeometry() { return _forceTextureDownloadGeometry.get(); }
|
||||||
const osg::Geometry* getForceTextureDownloadGeometry() const { return _forceTextureDownloadGeometry.get(); }
|
const osg::Geometry* getForceTextureDownloadGeometry() const { return _forceTextureDownloadGeometry.get(); }
|
||||||
|
|
||||||
GraphicsCostEstimator* getGraphicsCostEstimator() { return _graphicsCostEstimator.get(); }
|
osg::GraphicsCostEstimator* getGraphicsCostEstimator() { return _graphicsCostEstimator.get(); }
|
||||||
const GraphicsCostEstimator* getGraphicsCostEstimator() const { return _graphicsCostEstimator.get(); }
|
const osg::GraphicsCostEstimator* getGraphicsCostEstimator() const { return _graphicsCostEstimator.get(); }
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<osg::GraphicsContext*> Contexts;
|
typedef std::vector<osg::GraphicsContext*> Contexts;
|
||||||
@ -147,6 +148,7 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation
|
|||||||
double availableTime() { return allocatedTime - timer.elapsedTime(); }
|
double availableTime() { return allocatedTime - timer.elapsedTime(); }
|
||||||
|
|
||||||
IncrementalCompileOperation* incrementalCompileOperation;
|
IncrementalCompileOperation* incrementalCompileOperation;
|
||||||
|
osg::GraphicsCostEstimator* graphicsCostEstimator;
|
||||||
unsigned int maxNumObjectsToCompile;
|
unsigned int maxNumObjectsToCompile;
|
||||||
osg::ElapsedTime timer;
|
osg::ElapsedTime timer;
|
||||||
double allocatedTime;
|
double allocatedTime;
|
||||||
@ -278,7 +280,7 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation
|
|||||||
double _conservativeTimeRatio;
|
double _conservativeTimeRatio;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> _forceTextureDownloadGeometry;
|
osg::ref_ptr<osg::Geometry> _forceTextureDownloadGeometry;
|
||||||
osg::ref_ptr<GraphicsCostEstimator> _graphicsCostEstimator;
|
osg::ref_ptr<osg::GraphicsCostEstimator> _graphicsCostEstimator;
|
||||||
|
|
||||||
OpenThreads::Mutex _toCompileMutex;
|
OpenThreads::Mutex _toCompileMutex;
|
||||||
CompileSets _toCompile;
|
CompileSets _toCompile;
|
||||||
|
@ -79,6 +79,7 @@ SET(LIB_PUBLIC_HEADERS
|
|||||||
${HEADER_PATH}/GLBeginEndAdapter
|
${HEADER_PATH}/GLBeginEndAdapter
|
||||||
${HEADER_PATH}/GLObjects
|
${HEADER_PATH}/GLObjects
|
||||||
${HEADER_PATH}/GLU
|
${HEADER_PATH}/GLU
|
||||||
|
${HEADER_PATH}/GraphicsCostEstimator
|
||||||
${HEADER_PATH}/GraphicsContext
|
${HEADER_PATH}/GraphicsContext
|
||||||
${HEADER_PATH}/GraphicsThread
|
${HEADER_PATH}/GraphicsThread
|
||||||
${HEADER_PATH}/Group
|
${HEADER_PATH}/Group
|
||||||
@ -251,6 +252,7 @@ ADD_LIBRARY(${LIB_NAME}
|
|||||||
GLObjects.cpp
|
GLObjects.cpp
|
||||||
GLStaticLibrary.h
|
GLStaticLibrary.h
|
||||||
GLStaticLibrary.cpp
|
GLStaticLibrary.cpp
|
||||||
|
GraphicsCostEstimator.cpp
|
||||||
GraphicsContext.cpp
|
GraphicsContext.cpp
|
||||||
GraphicsThread.cpp
|
GraphicsThread.cpp
|
||||||
Group.cpp
|
Group.cpp
|
||||||
|
@ -11,10 +11,15 @@
|
|||||||
* OpenSceneGraph Public License for more details.
|
* OpenSceneGraph Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <osgUtil/GraphicsCostEstimator>
|
#include <osg/GraphicsCostEstimator>
|
||||||
|
|
||||||
|
#include <osg/RenderInfo>
|
||||||
|
#include <osg/Geometry>
|
||||||
|
#include <osg/Texture>
|
||||||
|
#include <osg/Program>
|
||||||
#include <osg/Geode>
|
#include <osg/Geode>
|
||||||
|
|
||||||
namespace osgUtil
|
namespace osg
|
||||||
{
|
{
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
@ -18,7 +18,6 @@ SET(LIB_PUBLIC_HEADERS
|
|||||||
${HEADER_PATH}/EdgeCollector
|
${HEADER_PATH}/EdgeCollector
|
||||||
${HEADER_PATH}/Export
|
${HEADER_PATH}/Export
|
||||||
${HEADER_PATH}/GLObjectsVisitor
|
${HEADER_PATH}/GLObjectsVisitor
|
||||||
${HEADER_PATH}/GraphicsCostEstimator
|
|
||||||
${HEADER_PATH}/HalfWayMapGenerator
|
${HEADER_PATH}/HalfWayMapGenerator
|
||||||
${HEADER_PATH}/HighlightMapGenerator
|
${HEADER_PATH}/HighlightMapGenerator
|
||||||
${HEADER_PATH}/IntersectionVisitor
|
${HEADER_PATH}/IntersectionVisitor
|
||||||
@ -63,7 +62,6 @@ ADD_LIBRARY(${LIB_NAME}
|
|||||||
DrawElementTypeSimplifier.cpp
|
DrawElementTypeSimplifier.cpp
|
||||||
EdgeCollector.cpp
|
EdgeCollector.cpp
|
||||||
GLObjectsVisitor.cpp
|
GLObjectsVisitor.cpp
|
||||||
GraphicsCostEstimator.cpp
|
|
||||||
HalfWayMapGenerator.cpp
|
HalfWayMapGenerator.cpp
|
||||||
HighlightMapGenerator.cpp
|
HighlightMapGenerator.cpp
|
||||||
IntersectionVisitor.cpp
|
IntersectionVisitor.cpp
|
||||||
|
@ -214,7 +214,7 @@ IncrementalCompileOperation::CompileDrawableOp::CompileDrawableOp(osg::Drawable*
|
|||||||
|
|
||||||
double IncrementalCompileOperation::CompileDrawableOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
|
double IncrementalCompileOperation::CompileDrawableOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
|
||||||
{
|
{
|
||||||
GraphicsCostEstimator* gce = compileInfo.incrementalCompileOperation->getGraphicsCostEstimator();
|
osg::GraphicsCostEstimator* gce = compileInfo.graphicsCostEstimator;
|
||||||
osg::Geometry* geometry = _drawable->asGeometry();
|
osg::Geometry* geometry = _drawable->asGeometry();
|
||||||
if (gce && geometry)
|
if (gce && geometry)
|
||||||
{
|
{
|
||||||
@ -237,7 +237,7 @@ IncrementalCompileOperation::CompileTextureOp::CompileTextureOp(osg::Texture* te
|
|||||||
|
|
||||||
double IncrementalCompileOperation::CompileTextureOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
|
double IncrementalCompileOperation::CompileTextureOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
|
||||||
{
|
{
|
||||||
GraphicsCostEstimator* gce = compileInfo.incrementalCompileOperation->getGraphicsCostEstimator();
|
osg::GraphicsCostEstimator* gce = compileInfo.graphicsCostEstimator;
|
||||||
if (gce) return gce->estimateCompileCost(_texture.get()).first;
|
if (gce) return gce->estimateCompileCost(_texture.get()).first;
|
||||||
else return 0.0;
|
else return 0.0;
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ IncrementalCompileOperation::CompileProgramOp::CompileProgramOp(osg::Program* pr
|
|||||||
|
|
||||||
double IncrementalCompileOperation::CompileProgramOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
|
double IncrementalCompileOperation::CompileProgramOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
|
||||||
{
|
{
|
||||||
GraphicsCostEstimator* gce = compileInfo.incrementalCompileOperation->getGraphicsCostEstimator();
|
osg::GraphicsCostEstimator* gce = compileInfo.graphicsCostEstimator;
|
||||||
if (gce) return gce->estimateCompileCost(_program.get()).first;
|
if (gce) return gce->estimateCompileCost(_program.get()).first;
|
||||||
else return 0.0;
|
else return 0.0;
|
||||||
}
|
}
|
||||||
@ -288,6 +288,7 @@ IncrementalCompileOperation::CompileInfo::CompileInfo(osg::GraphicsContext* cont
|
|||||||
{
|
{
|
||||||
setState(context->getState());
|
setState(context->getState());
|
||||||
incrementalCompileOperation = ico;
|
incrementalCompileOperation = ico;
|
||||||
|
graphicsCostEstimator = ico->getGraphicsCostEstimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,7 +444,7 @@ IncrementalCompileOperation::IncrementalCompileOperation():
|
|||||||
_maximumNumOfObjectsToCompilePerFrame = atoi(ptr);
|
_maximumNumOfObjectsToCompilePerFrame = atoi(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
_graphicsCostEstimator = new GraphicsCostEstimator;
|
_graphicsCostEstimator = new osg::GraphicsCostEstimator;
|
||||||
|
|
||||||
// assignForceTextureDownloadGeometry();
|
// assignForceTextureDownloadGeometry();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user