OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GraphicsCostEstimator.h
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 
21 namespace osg
22 {
23 
24 class Geometry;
25 class Texture;
26 class Program;
27 class Node;
28 class 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 
54 typedef std::pair<double, double> CostPair;
55 
56 
58 {
59 public:
61  void setDefaults();
62  void calibrate(osg::RenderInfo& renderInfo);
63  CostPair estimateCompileCost(const osg::Geometry* geometry) const;
64  CostPair estimateDrawCost(const osg::Geometry* geometry) const;
65 
66 protected:
69 
72 
75 };
76 
78 {
79 public:
81  void setDefaults();
82  void calibrate(osg::RenderInfo& renderInfo);
83  CostPair estimateCompileCost(const osg::Texture* texture) const;
84  CostPair estimateDrawCost(const osg::Texture* texture) const;
85 
86 protected:
89 };
90 
91 
93 {
94 public:
96  void setDefaults();
97  void calibrate(osg::RenderInfo& renderInfo);
98  CostPair estimateCompileCost(const osg::Program* program) const;
99  CostPair estimateDrawCost(const osg::Program* program) const;
100 
101 protected:
105 };
106 
108 {
109 public:
111 
113  void setDefaults();
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 
127  CostPair estimateCompileCost(const osg::Node* node) const;
128  CostPair estimateDrawCost(const osg::Node* node) const;
129 
130 protected:
131 
132  virtual ~GraphicsCostEstimator();
133 
137 
138 };
139 
140 }
141 
142 #endif
#define OSG_EXPORT
Definition: Export.h:43
ClampedLinearCostFunction1D _arrayDrawCost
osg::ref_ptr< ProgramCostEstimator > _programEstimator
ClampedLinearCostFunction1D _arrayCompileCost
ClampedLinearCostFunction1D _drawCost
ClampedLinearCostFunction1D _shaderCompileCost
ClampedLinearCostFunction1D _drawCost
osg::ref_ptr< TextureCostEstimator > _textureEstimator
osg::ref_ptr< GeometryCostEstimator > _geometryEstimator
CostPair estimateCompileCost(const osg::Texture *texture) const
void set(double cost0, double dcost_di, unsigned int min_input)
ClampedLinearCostFunction1D(double cost0=0.0, double dcost_di=0.0, unsigned int min_input=0)
CostPair estimateDrawCost(const osg::Texture *texture) const
CostPair estimateCompileCost(const osg::Program *program) const
CostPair estimateDrawCost(const osg::Program *program) const
ClampedLinearCostFunction1D _linkCost
double operator()(unsigned int input) const
CostPair estimateDrawCost(const osg::Geometry *geometry) const
ClampedLinearCostFunction1D _primtiveSetCompileCost
std::pair< double, double > CostPair
Definition: Node.h:71
Definition: AlphaFunc.h:19
CostPair estimateCompileCost(const osg::Geometry *geometry) const
ClampedLinearCostFunction1D _compileCost
ClampedLinearCostFunction1D _primtiveSetDrawCost