OpenSceneGraph 3.6.5
GraphicsCostEstimator
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_GRAPHICSCOSTESTIMATOR
15#define OSG_GRAPHICSCOSTESTIMATOR
16
17#include <osg/Referenced>
18#include <osg/ref_ptr>
19#include <utility>
20
21namespace osg
22{
23
24class Geometry;
25class Texture;
26class Program;
27class Node;
28class RenderInfo;
29
31{
32 ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0):
33 _cost0(cost0),
34 _dcost_di(dcost_di),
35 _min_input(min_input) {}
36
37 void set(double cost0, double dcost_di, unsigned int min_input)
38 {
39 _cost0 = cost0;
40 _dcost_di = dcost_di;
41 _min_input = min_input;
42 }
43
44 double operator() (unsigned int input) const
45 {
46 return _cost0 + _dcost_di * double(input<=_min_input ? 0u : input-_min_input);
47 }
48 double _cost0;
49 double _dcost_di;
50 unsigned int _min_input;
51};
52
54typedef std::pair<double, double> CostPair;
55
56
76
90
91
106
108{
109public:
111
114
116 void calibrate(osg::RenderInfo& renderInfo);
117
118 CostPair estimateCompileCost(const osg::Geometry* geometry) const { return _geometryEstimator->estimateCompileCost(geometry); }
119 CostPair estimateDrawCost(const osg::Geometry* geometry) const { return _geometryEstimator->estimateDrawCost(geometry); }
120
121 CostPair estimateCompileCost(const osg::Texture* texture) const { return _textureEstimator->estimateCompileCost(texture); }
122 CostPair estimateDrawCost(const osg::Texture* texture) const { return _textureEstimator->estimateDrawCost(texture); }
123
124 CostPair estimateCompileCost(const osg::Program* program) const { return _programEstimator->estimateCompileCost(program); }
125 CostPair estimateDrawCost(const osg::Program* program) const { return _programEstimator->estimateDrawCost(program); }
126
129
130protected:
131
133
137
138};
139
140}
141
142#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
std::pair< double, double > CostPair
Pair of double representing CPU and GPU times in seconds as first and second elements in std::pair.
Definition GraphicsCostEstimator:54
Definition Geometry:31
Definition GraphicsCostEstimator:31
void set(double cost0, double dcost_di, unsigned int min_input)
Definition GraphicsCostEstimator:37
double operator()(unsigned int input) const
Definition GraphicsCostEstimator:44
double _cost0
Definition GraphicsCostEstimator:48
unsigned int _min_input
Definition GraphicsCostEstimator:50
double _dcost_di
Definition GraphicsCostEstimator:49
ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0)
Definition GraphicsCostEstimator:32
double _displayListCompileConstant
Definition GraphicsCostEstimator:73
CostPair estimateCompileCost(const osg::Geometry *geometry) const
ClampedLinearCostFunction1D _primtiveSetCompileCost
Definition GraphicsCostEstimator:68
double _displayListCompileFactor
Definition GraphicsCostEstimator:74
CostPair estimateDrawCost(const osg::Geometry *geometry) const
void calibrate(osg::RenderInfo &renderInfo)
ClampedLinearCostFunction1D _arrayDrawCost
Definition GraphicsCostEstimator:70
ClampedLinearCostFunction1D _primtiveSetDrawCost
Definition GraphicsCostEstimator:71
ClampedLinearCostFunction1D _arrayCompileCost
Definition GraphicsCostEstimator:67
CostPair estimateDrawCost(const osg::Texture *texture) const
CostPair estimateCompileCost(const osg::Texture *texture) const
ClampedLinearCostFunction1D _compileCost
Definition GraphicsCostEstimator:87
void calibrate(osg::RenderInfo &renderInfo)
ClampedLinearCostFunction1D _drawCost
Definition GraphicsCostEstimator:88
ClampedLinearCostFunction1D _shaderCompileCost
Definition GraphicsCostEstimator:102
ClampedLinearCostFunction1D _drawCost
Definition GraphicsCostEstimator:104
ClampedLinearCostFunction1D _linkCost
Definition GraphicsCostEstimator:103
void calibrate(osg::RenderInfo &renderInfo)
CostPair estimateDrawCost(const osg::Program *program) const
CostPair estimateCompileCost(const osg::Program *program) const
CostPair estimateDrawCost(const osg::Node *node) const
CostPair estimateDrawCost(const osg::Texture *texture) const
Definition GraphicsCostEstimator:122
CostPair estimateDrawCost(const osg::Program *program) const
Definition GraphicsCostEstimator:125
osg::ref_ptr< GeometryCostEstimator > _geometryEstimator
Definition GraphicsCostEstimator:134
CostPair estimateCompileCost(const osg::Geometry *geometry) const
Definition GraphicsCostEstimator:118
CostPair estimateCompileCost(const osg::Program *program) const
Definition GraphicsCostEstimator:124
void calibrate(osg::RenderInfo &renderInfo)
calibrate the costs of various compile and draw operations
osg::ref_ptr< TextureCostEstimator > _textureEstimator
Definition GraphicsCostEstimator:135
osg::ref_ptr< ProgramCostEstimator > _programEstimator
Definition GraphicsCostEstimator:136
CostPair estimateDrawCost(const osg::Geometry *geometry) const
Definition GraphicsCostEstimator:119
CostPair estimateCompileCost(const osg::Texture *texture) const
Definition GraphicsCostEstimator:121
void setDefaults()
set defaults for computing the costs.
CostPair estimateCompileCost(const osg::Node *node) const
Base class for all internal nodes in the scene graph.
Definition Node:72
osg::Program is an application-level abstraction of an OpenGL glProgram.
Definition Program:52
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Definition RenderInfo:28
Texture pure virtual base class that encapsulates OpenGL texture functionality common to the various ...
Definition Texture:422
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.