From 9df072ce05c757226a1b8a558432d38c87b3b8a7 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 26 Jan 2011 12:51:46 +0000 Subject: [PATCH] Moved GraphicsCostEstimator into osgUtil. --- examples/osggraphicscost/osggraphicscost.cpp | 436 +------------------ include/osgUtil/GraphicsCostEstimator | 139 ++++++ src/osgUtil/CMakeLists.txt | 2 + src/osgUtil/GraphicsCostEstimator.cpp | 330 ++++++++++++++ 4 files changed, 472 insertions(+), 435 deletions(-) create mode 100644 include/osgUtil/GraphicsCostEstimator create mode 100644 src/osgUtil/GraphicsCostEstimator.cpp diff --git a/examples/osggraphicscost/osggraphicscost.cpp b/examples/osggraphicscost/osggraphicscost.cpp index 8ef8763a2..0e778783d 100644 --- a/examples/osggraphicscost/osggraphicscost.cpp +++ b/examples/osggraphicscost/osggraphicscost.cpp @@ -21,442 +21,8 @@ #include #include -#include -#include - - -#include -#include -#include - -namespace osgUtil -{ - -struct ClampedLinearCostFunction1D -{ - ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0): - _cost0(cost0), - _dcost_di(dcost_di), - _min_input(min_input) {} - - void set(double cost0, double dcost_di, unsigned int min_input) - { - _cost0 = cost0; - _dcost_di = dcost_di; - _min_input = min_input; - } - - double operator() (unsigned int input) const - { - OSG_NOTICE<<"ClampedLinearCostFunction1D::operator("< CostPair; - - -class GeometryCostEstimator : public osg::Referenced -{ -public: - GeometryCostEstimator(); - void setDefaults(); - void calibrate(osg::RenderInfo& renderInfo); - CostPair estimateCompileCost(const osg::Geometry* geometry) const; - CostPair estimateDrawCost(const osg::Geometry* geometry) const; - -protected: - ClampedLinearCostFunction1D _arrayCompileCost; - ClampedLinearCostFunction1D _primtiveSetCompileCost; - - ClampedLinearCostFunction1D _arrayDrawCost; - ClampedLinearCostFunction1D _primtiveSetDrawCost; - - double _displayListCompileConstant; - double _displayListCompileFactor; -}; - -class TextureCostEstimator : public osg::Referenced -{ -public: - TextureCostEstimator(); - void setDefaults(); - void calibrate(osg::RenderInfo& renderInfo); - CostPair estimateCompileCost(const osg::Texture* texture) const; - CostPair estimateDrawCost(const osg::Texture* texture) const; - -protected: - ClampedLinearCostFunction1D _compileCost; - ClampedLinearCostFunction1D _drawCost; -}; - - -class ProgramCostEstimator : public osg::Referenced -{ -public: - ProgramCostEstimator(); - void setDefaults(); - void calibrate(osg::RenderInfo& renderInfo); - CostPair estimateCompileCost(const osg::Program* program) const; - CostPair estimateDrawCost(const osg::Program* program) const; - -protected: - ClampedLinearCostFunction1D _shaderCompileCost; - ClampedLinearCostFunction1D _linkCost; - ClampedLinearCostFunction1D _drawCost; -}; - -class GraphicsCostEstimator : public osg::Referenced -{ -public: - GraphicsCostEstimator(); - - /** set defaults for computing the costs.*/ - void setDefaults(); - - /** calibrate the costs of various compile and draw operations */ - void calibrate(osg::RenderInfo& renderInfo); - - CostPair estimateCompileCost(const osg::Geometry* geometry) const { return _geometryEstimator->estimateCompileCost(geometry); } - CostPair estimateDrawCost(const osg::Geometry* geometry) const { return _geometryEstimator->estimateDrawCost(geometry); } - - CostPair estimateCompileCost(const osg::Texture* texture) const { return _textureEstimator->estimateDrawCost(texture); } - CostPair estimateDrawCost(const osg::Texture* texture) const { return _textureEstimator->estimateDrawCost(texture); } - - CostPair estimateCompileCost(const osg::Program* program) const { return _programEstimator->estimateCompileCost(program); } - CostPair estimateDrawCost(const osg::Program* program) const { return _programEstimator->estimateDrawCost(program); } - - CostPair estimateCompileCost(const osg::Node* node) const; - CostPair estimateDrawCost(const osg::Node* node) const; - -protected: - - virtual ~GraphicsCostEstimator(); - - osg::ref_ptr _geometryEstimator; - osg::ref_ptr _textureEstimator; - osg::ref_ptr _programEstimator; - -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// -// GeometryCostEstimator -// -GeometryCostEstimator::GeometryCostEstimator() -{ - setDefaults(); -} - -void GeometryCostEstimator::setDefaults() -{ - double transfer_bandwidth = 10000000000.0; // 1GB/sec - double gpu_bandwidth = 50000000000.0; // 50 GB/second - double min_time = 0.00001; // 10 nano seconds. - _arrayCompileCost.set(min_time, 1.0/transfer_bandwidth, 256); // min time 1/10th of millisecond, min size 256 - _primtiveSetCompileCost.set(min_time, 1.0/transfer_bandwidth, 256); // min time 1/10th of millisecond, min size 256 - _arrayDrawCost.set(min_time, 1.0/gpu_bandwidth, 256); // min time 1/10th of millisecond, min size 256; - _primtiveSetDrawCost.set(min_time, 1.0/gpu_bandwidth, 256); // min time 1/10th of millisecond, min size 256; - - _displayListCompileConstant = 0.0; - _displayListCompileFactor = 10.0; -} - -void GeometryCostEstimator::calibrate(osg::RenderInfo& renderInfo) -{ -} - -CostPair GeometryCostEstimator::estimateCompileCost(const osg::Geometry* geometry) const -{ - OSG_NOTICE<<"GeometryCostEstimator::estimateCompileCost(..)"<getUseVertexBufferObjects() && geometry->areFastPathsUsed(); - bool usesDL = !usesVBO && geometry->getUseDisplayList() && geometry->getSupportsDisplayList(); - - if (usesVBO || usesDL) - { - CostPair cost; - if (geometry->getVertexArray()) { cost.first += _arrayCompileCost(geometry->getVertexArray()->getTotalDataSize()); } - if (geometry->getNormalArray()) { cost.first += _arrayCompileCost(geometry->getNormalArray()->getTotalDataSize()); } - if (geometry->getColorArray()) { cost.first += _arrayCompileCost(geometry->getColorArray()->getTotalDataSize()); } - if (geometry->getSecondaryColorArray()) { cost.first += _arrayCompileCost(geometry->getSecondaryColorArray()->getTotalDataSize()); } - if (geometry->getFogCoordArray()) { cost.first += _arrayCompileCost(geometry->getFogCoordArray()->getTotalDataSize()); } - for(unsigned i=0; igetNumTexCoordArrays(); ++i) - { - if (geometry->getTexCoordArray(i)) { cost.first += _arrayCompileCost(geometry->getTexCoordArray(i)->getTotalDataSize()); } - } - for(unsigned i=0; igetNumVertexAttribArrays(); ++i) - { - if (geometry->getVertexAttribArray(i)) { cost.first += _arrayCompileCost(geometry->getVertexAttribArray(i)->getTotalDataSize()); } - } - for(unsigned i=0; igetNumPrimitiveSets(); ++i) - { - const osg::PrimitiveSet* primSet = geometry->getPrimitiveSet(i); - const osg::DrawElements* drawElements = primSet ? primSet->getDrawElements() : 0; - if (drawElements) { cost.first += _primtiveSetCompileCost(drawElements->getTotalDataSize()); } - } - - - - if (usesDL) - { - cost.first = _displayListCompileConstant + _displayListCompileFactor * cost.first ; - } - - OSG_NOTICE<<" cost.first="<setDefaults(); - _textureEstimator->setDefaults(); - _programEstimator->setDefaults(); -} - - -void GraphicsCostEstimator::calibrate(osg::RenderInfo& renderInfo) -{ - OSG_NOTICE<<"GraphicsCostEstimator::calibrate(..)"<getStateSet()); - osg::Geometry* geometry = geode.getDrawable(i)->asGeometry(); - if (geometry) apply(geometry); - } - } - - void apply(osg::StateSet* stateset) - { - if (!stateset) return; - if (_statesets.count(stateset)) return; - _statesets.insert(stateset); - - const osg::Program* program = dynamic_cast(stateset->getAttribute(osg::StateAttribute::PROGRAM)); - if (program) - { - CostPair cost = _gce->estimateCompileCost(program); - _costs.first += cost.first; - _costs.second += cost.second; - } - - for(unsigned int i=0; igetNumTextureAttributeLists(); ++i) - { - const osg::Texture* texture = dynamic_cast(stateset->getTextureAttribute(i, osg::StateAttribute::TEXTURE)); - CostPair cost = _gce->estimateCompileCost(texture); - _costs.first += cost.first; - _costs.second += cost.second; - } - } - - void apply(osg::Geometry* geometry) - { - if (!geometry) return; - if (_geometries.count(geometry)) return; - _geometries.insert(geometry); - - CostPair cost = _gce->estimateCompileCost(geometry); - - OSG_NOTICE<<"apply(Geometry), cost.first="< StateSets; - typedef std::set Textures; - typedef std::set Geometries; - - const GraphicsCostEstimator* _gce; - StateSets _statesets; - Textures _textures; - Geometries _geometries; - CostPair _costs; -}; - - -class CollectDrawCosts : public osg::NodeVisitor -{ -public: - CollectDrawCosts(const GraphicsCostEstimator* gce): - osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN), - _gce(gce), - _costs(0.0,0.0) - {} - - virtual void apply(osg::Node& node) - { - apply(node.getStateSet()); - traverse(node); - } - - virtual void apply(osg::Geode& geode) - { - apply(geode.getStateSet()); - for(unsigned int i=0; igetStateSet()); - osg::Geometry* geometry = geode.getDrawable(i)->asGeometry(); - if (geometry) apply(geometry); - } - } - - void apply(osg::StateSet* stateset) - { - if (!stateset) return; - - const osg::Program* program = dynamic_cast(stateset->getAttribute(osg::StateAttribute::PROGRAM)); - if (program) - { - CostPair cost = _gce->estimateDrawCost(program); - _costs.first += cost.first; - _costs.second += cost.second; - } - - for(unsigned int i=0; igetNumTextureAttributeLists(); ++i) - { - const osg::Texture* texture = dynamic_cast(stateset->getTextureAttribute(i, osg::StateAttribute::TEXTURE)); - CostPair cost = _gce->estimateDrawCost(texture); - _costs.first += cost.first; - _costs.second += cost.second; - } - } - - void apply(osg::Geometry* geometry) - { - if (!geometry) return; - - CostPair cost = _gce->estimateDrawCost(geometry); - _costs.first += cost.first; - _costs.second += cost.second; - } - - const GraphicsCostEstimator* _gce; - CostPair _costs; -}; - -CostPair GraphicsCostEstimator::estimateCompileCost(const osg::Node* node) const -{ - if (!node) return CostPair(0.0,0.0); - CollectCompileCosts ccc(this); - const_cast(node)->accept(ccc); - return ccc._costs; -} - -CostPair GraphicsCostEstimator::estimateDrawCost(const osg::Node* node) const -{ - if (!node) return CostPair(0.0,0.0); - CollectDrawCosts cdc(this); - const_cast(node)->accept(cdc); - return cdc._costs; -} - -} +#include class CalibrateCostEsimator : public osg::GraphicsOperation { diff --git a/include/osgUtil/GraphicsCostEstimator b/include/osgUtil/GraphicsCostEstimator new file mode 100644 index 000000000..edd1d6ad3 --- /dev/null +++ b/include/osgUtil/GraphicsCostEstimator @@ -0,0 +1,139 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSGUTIL_GRAPHICSCOSTESTIMATOR +#define OSGUTIL_GRAPHICSCOSTESTIMATOR + +#include + +#include +#include +#include + +namespace osgUtil +{ + +struct ClampedLinearCostFunction1D +{ + ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0): + _cost0(cost0), + _dcost_di(dcost_di), + _min_input(min_input) {} + + void set(double cost0, double dcost_di, unsigned int min_input) + { + _cost0 = cost0; + _dcost_di = dcost_di; + _min_input = min_input; + } + + double operator() (unsigned int input) const + { + OSG_NOTICE<<"ClampedLinearCostFunction1D::operator("< CostPair; + + +class OSGUTIL_EXPORT GeometryCostEstimator : public osg::Referenced +{ +public: + GeometryCostEstimator(); + void setDefaults(); + void calibrate(osg::RenderInfo& renderInfo); + CostPair estimateCompileCost(const osg::Geometry* geometry) const; + CostPair estimateDrawCost(const osg::Geometry* geometry) const; + +protected: + ClampedLinearCostFunction1D _arrayCompileCost; + ClampedLinearCostFunction1D _primtiveSetCompileCost; + + ClampedLinearCostFunction1D _arrayDrawCost; + ClampedLinearCostFunction1D _primtiveSetDrawCost; + + double _displayListCompileConstant; + double _displayListCompileFactor; +}; + +class OSGUTIL_EXPORT TextureCostEstimator : public osg::Referenced +{ +public: + TextureCostEstimator(); + void setDefaults(); + void calibrate(osg::RenderInfo& renderInfo); + CostPair estimateCompileCost(const osg::Texture* texture) const; + CostPair estimateDrawCost(const osg::Texture* texture) const; + +protected: + ClampedLinearCostFunction1D _compileCost; + ClampedLinearCostFunction1D _drawCost; +}; + + +class OSGUTIL_EXPORT ProgramCostEstimator : public osg::Referenced +{ +public: + ProgramCostEstimator(); + void setDefaults(); + void calibrate(osg::RenderInfo& renderInfo); + CostPair estimateCompileCost(const osg::Program* program) const; + CostPair estimateDrawCost(const osg::Program* program) const; + +protected: + ClampedLinearCostFunction1D _shaderCompileCost; + ClampedLinearCostFunction1D _linkCost; + ClampedLinearCostFunction1D _drawCost; +}; + +class OSGUTIL_EXPORT GraphicsCostEstimator : public osg::Referenced +{ +public: + GraphicsCostEstimator(); + + /** set defaults for computing the costs.*/ + void setDefaults(); + + /** calibrate the costs of various compile and draw operations */ + void calibrate(osg::RenderInfo& renderInfo); + + CostPair estimateCompileCost(const osg::Geometry* geometry) const { return _geometryEstimator->estimateCompileCost(geometry); } + CostPair estimateDrawCost(const osg::Geometry* geometry) const { return _geometryEstimator->estimateDrawCost(geometry); } + + CostPair estimateCompileCost(const osg::Texture* texture) const { return _textureEstimator->estimateDrawCost(texture); } + CostPair estimateDrawCost(const osg::Texture* texture) const { return _textureEstimator->estimateDrawCost(texture); } + + CostPair estimateCompileCost(const osg::Program* program) const { return _programEstimator->estimateCompileCost(program); } + CostPair estimateDrawCost(const osg::Program* program) const { return _programEstimator->estimateDrawCost(program); } + + CostPair estimateCompileCost(const osg::Node* node) const; + CostPair estimateDrawCost(const osg::Node* node) const; + +protected: + + virtual ~GraphicsCostEstimator(); + + osg::ref_ptr _geometryEstimator; + osg::ref_ptr _textureEstimator; + osg::ref_ptr _programEstimator; + +}; + +} + +#endif \ No newline at end of file diff --git a/src/osgUtil/CMakeLists.txt b/src/osgUtil/CMakeLists.txt index bb07e35ce..39f370490 100644 --- a/src/osgUtil/CMakeLists.txt +++ b/src/osgUtil/CMakeLists.txt @@ -18,6 +18,7 @@ SET(LIB_PUBLIC_HEADERS ${HEADER_PATH}/EdgeCollector ${HEADER_PATH}/Export ${HEADER_PATH}/GLObjectsVisitor + ${HEADER_PATH}/GraphicsCostEstimator ${HEADER_PATH}/HalfWayMapGenerator ${HEADER_PATH}/HighlightMapGenerator ${HEADER_PATH}/IntersectionVisitor @@ -62,6 +63,7 @@ ADD_LIBRARY(${LIB_NAME} DrawElementTypeSimplifier.cpp EdgeCollector.cpp GLObjectsVisitor.cpp + GraphicsCostEstimator.cpp HalfWayMapGenerator.cpp HighlightMapGenerator.cpp IntersectionVisitor.cpp diff --git a/src/osgUtil/GraphicsCostEstimator.cpp b/src/osgUtil/GraphicsCostEstimator.cpp new file mode 100644 index 000000000..235a6ad87 --- /dev/null +++ b/src/osgUtil/GraphicsCostEstimator.cpp @@ -0,0 +1,330 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include +#include + +namespace osgUtil +{ + +///////////////////////////////////////////////////////////////////////////////////////////// +// +// GeometryCostEstimator +// +GeometryCostEstimator::GeometryCostEstimator() +{ + setDefaults(); +} + +void GeometryCostEstimator::setDefaults() +{ + double transfer_bandwidth = 10000000000.0; // 1GB/sec + double gpu_bandwidth = 50000000000.0; // 50 GB/second + double min_time = 0.00001; // 10 nano seconds. + _arrayCompileCost.set(min_time, 1.0/transfer_bandwidth, 256); // min time 1/10th of millisecond, min size 256 + _primtiveSetCompileCost.set(min_time, 1.0/transfer_bandwidth, 256); // min time 1/10th of millisecond, min size 256 + _arrayDrawCost.set(min_time, 1.0/gpu_bandwidth, 256); // min time 1/10th of millisecond, min size 256; + _primtiveSetDrawCost.set(min_time, 1.0/gpu_bandwidth, 256); // min time 1/10th of millisecond, min size 256; + + _displayListCompileConstant = 0.0; + _displayListCompileFactor = 10.0; +} + +void GeometryCostEstimator::calibrate(osg::RenderInfo& renderInfo) +{ +} + +CostPair GeometryCostEstimator::estimateCompileCost(const osg::Geometry* geometry) const +{ + OSG_NOTICE<<"GeometryCostEstimator::estimateCompileCost(..)"<getUseVertexBufferObjects() && geometry->areFastPathsUsed(); + bool usesDL = !usesVBO && geometry->getUseDisplayList() && geometry->getSupportsDisplayList(); + + if (usesVBO || usesDL) + { + CostPair cost; + if (geometry->getVertexArray()) { cost.first += _arrayCompileCost(geometry->getVertexArray()->getTotalDataSize()); } + if (geometry->getNormalArray()) { cost.first += _arrayCompileCost(geometry->getNormalArray()->getTotalDataSize()); } + if (geometry->getColorArray()) { cost.first += _arrayCompileCost(geometry->getColorArray()->getTotalDataSize()); } + if (geometry->getSecondaryColorArray()) { cost.first += _arrayCompileCost(geometry->getSecondaryColorArray()->getTotalDataSize()); } + if (geometry->getFogCoordArray()) { cost.first += _arrayCompileCost(geometry->getFogCoordArray()->getTotalDataSize()); } + for(unsigned i=0; igetNumTexCoordArrays(); ++i) + { + if (geometry->getTexCoordArray(i)) { cost.first += _arrayCompileCost(geometry->getTexCoordArray(i)->getTotalDataSize()); } + } + for(unsigned i=0; igetNumVertexAttribArrays(); ++i) + { + if (geometry->getVertexAttribArray(i)) { cost.first += _arrayCompileCost(geometry->getVertexAttribArray(i)->getTotalDataSize()); } + } + for(unsigned i=0; igetNumPrimitiveSets(); ++i) + { + const osg::PrimitiveSet* primSet = geometry->getPrimitiveSet(i); + const osg::DrawElements* drawElements = primSet ? primSet->getDrawElements() : 0; + if (drawElements) { cost.first += _primtiveSetCompileCost(drawElements->getTotalDataSize()); } + } + + if (usesDL) + { + cost.first = _displayListCompileConstant + _displayListCompileFactor * cost.first ; + } + + OSG_NOTICE<<" cost.first="<setDefaults(); + _textureEstimator->setDefaults(); + _programEstimator->setDefaults(); +} + + +void GraphicsCostEstimator::calibrate(osg::RenderInfo& renderInfo) +{ + OSG_NOTICE<<"GraphicsCostEstimator::calibrate(..)"<getStateSet()); + osg::Geometry* geometry = geode.getDrawable(i)->asGeometry(); + if (geometry) apply(geometry); + } + } + + void apply(osg::StateSet* stateset) + { + if (!stateset) return; + if (_statesets.count(stateset)) return; + _statesets.insert(stateset); + + const osg::Program* program = dynamic_cast(stateset->getAttribute(osg::StateAttribute::PROGRAM)); + if (program) + { + CostPair cost = _gce->estimateCompileCost(program); + _costs.first += cost.first; + _costs.second += cost.second; + } + + for(unsigned int i=0; igetNumTextureAttributeLists(); ++i) + { + const osg::Texture* texture = dynamic_cast(stateset->getTextureAttribute(i, osg::StateAttribute::TEXTURE)); + CostPair cost = _gce->estimateCompileCost(texture); + _costs.first += cost.first; + _costs.second += cost.second; + } + } + + void apply(osg::Geometry* geometry) + { + if (!geometry) return; + if (_geometries.count(geometry)) return; + _geometries.insert(geometry); + + CostPair cost = _gce->estimateCompileCost(geometry); + + OSG_NOTICE<<"apply(Geometry), cost.first="< StateSets; + typedef std::set Textures; + typedef std::set Geometries; + + const GraphicsCostEstimator* _gce; + StateSets _statesets; + Textures _textures; + Geometries _geometries; + CostPair _costs; +}; + + +class CollectDrawCosts : public osg::NodeVisitor +{ +public: + CollectDrawCosts(const GraphicsCostEstimator* gce): + osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN), + _gce(gce), + _costs(0.0,0.0) + {} + + virtual void apply(osg::Node& node) + { + apply(node.getStateSet()); + traverse(node); + } + + virtual void apply(osg::Geode& geode) + { + apply(geode.getStateSet()); + for(unsigned int i=0; igetStateSet()); + osg::Geometry* geometry = geode.getDrawable(i)->asGeometry(); + if (geometry) apply(geometry); + } + } + + void apply(osg::StateSet* stateset) + { + if (!stateset) return; + + const osg::Program* program = dynamic_cast(stateset->getAttribute(osg::StateAttribute::PROGRAM)); + if (program) + { + CostPair cost = _gce->estimateDrawCost(program); + _costs.first += cost.first; + _costs.second += cost.second; + } + + for(unsigned int i=0; igetNumTextureAttributeLists(); ++i) + { + const osg::Texture* texture = dynamic_cast(stateset->getTextureAttribute(i, osg::StateAttribute::TEXTURE)); + CostPair cost = _gce->estimateDrawCost(texture); + _costs.first += cost.first; + _costs.second += cost.second; + } + } + + void apply(osg::Geometry* geometry) + { + if (!geometry) return; + + CostPair cost = _gce->estimateDrawCost(geometry); + _costs.first += cost.first; + _costs.second += cost.second; + } + + const GraphicsCostEstimator* _gce; + CostPair _costs; +}; + +CostPair GraphicsCostEstimator::estimateCompileCost(const osg::Node* node) const +{ + if (!node) return CostPair(0.0,0.0); + CollectCompileCosts ccc(this); + const_cast(node)->accept(ccc); + return ccc._costs; +} + +CostPair GraphicsCostEstimator::estimateDrawCost(const osg::Node* node) const +{ + if (!node) return CostPair(0.0,0.0); + CollectDrawCosts cdc(this); + const_cast(node)->accept(cdc); + return cdc._costs; +} + +}