CostPair GraphicsCostEstimator::estimateDrawCost(const osg::Node* node) const
{
    if (!node) return CostPair(0.0,0.0);
    CollectDrawCosts cdc(this);
    const_cast<osg::Node*>(node)->accept(cdc);
    return cdc._costs;
}
CostPair GraphicsCostEstimator::estimateCompileCost(const osg::Node* node) const
{
    if (!node) return CostPair(0.0,0.0);
    CollectCompileCosts ccc(this);
    const_cast<osg::Node*>(node)->accept(ccc);
    return ccc._costs;
}
Example #3
0
CostPair GeometryCostEstimator::estimateCompileCost(const osg::Geometry* geometry) const
{

    bool usesVBO = geometry->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; i<geometry->getNumTexCoordArrays(); ++i)
        {
            if (geometry->getTexCoordArray(i)) { cost.first += _arrayCompileCost(geometry->getTexCoordArray(i)->getTotalDataSize()); }
        }
        for(unsigned i=0; i<geometry->getNumVertexAttribArrays(); ++i)
        {
            if (geometry->getVertexAttribArray(i)) { cost.first += _arrayCompileCost(geometry->getVertexAttribArray(i)->getTotalDataSize()); }
        }
        for(unsigned i=0; i<geometry->getNumPrimitiveSets(); ++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<<"GeometryCostEstimator::estimateCompileCost(..) size="<<cost.first<<std::endl;

        return cost;
    }
    else
    {
        return CostPair(0.0,0.0);
    }
}
CostPair GeometryCostEstimator::estimateDrawCost(const osg::Geometry* /*geometry*/) const
{
    return CostPair(0.0,0.0);
}
CostPair ProgramCostEstimator::estimateDrawCost(const osg::Program* /*program*/) const
{
    return CostPair(0.0,0.0);
}
CostPair TextureCostEstimator::estimateDrawCost(const osg::Texture* /*texture*/) const
{
    return CostPair(0.0,0.0);
}
Example #7
0
CostPair ProgramCostEstimator::estimateCompileCost(const osg::Program* program) const
{
    return CostPair(0.0,0.0);
}