Moved GraphicsCostEstimator ref pointer into osg::State

This commit is contained in:
Robert Osfield 2011-02-03 12:42:23 +00:00
parent 88ce98b47d
commit 6496e35421
4 changed files with 24 additions and 16 deletions

View File

@ -29,6 +29,7 @@
#include <osg/Viewport>
#include <osg/GLBeginEndAdapter>
#include <osg/ArrayDispatchers>
#include <osg/GraphicsCostEstimator>
#include <iosfwd>
#include <vector>
@ -1381,12 +1382,24 @@ class OSG_EXPORT State : public Referenced, public Observer
virtual void objectDeleted(void* object);
/** get the GL adapter object used to map OpenGL 1.0 glBegin/glEnd usage to vertex arrays.*/
/** Get the GL adapter object used to map OpenGL 1.0 glBegin/glEnd usage to vertex arrays.*/
inline GLBeginEndAdapter& getGLBeginEndAdapter() { return _glBeginEndAdapter; }
/** get the helper class for dispatching osg::Arrays as OpenGL attribute data.*/
/** Get the helper class for dispatching osg::Arrays as OpenGL attribute data.*/
inline ArrayDispatchers& getArrayDispatchers() { return _arrayDispatchers; }
/** Set the helper class that provides applications with estimate on how much different graphics operations will cost.*/
inline void setGraphicsCostEstimator(GraphicsCostEstimator* gce) { _graphicsCostEstimator = gce; }
/** Get the helper class that provides applications with estimate on how much different graphics operations will cost.*/
inline GraphicsCostEstimator* getGraphicsCostEstimator() { return _graphicsCostEstimator.get(); }
/** Get the cont helper class that provides applications with estimate on how much different graphics operations will cost.*/
inline const GraphicsCostEstimator* getGraphicsCostEstimator() const { return _graphicsCostEstimator.get(); }
/** Support for synchronizing the system time and the timestamp
* counter available with ARB_timer_query. Note that State
* doesn't update these values itself.
@ -1822,6 +1835,9 @@ class OSG_EXPORT State : public Referenced, public Observer
GLBeginEndAdapter _glBeginEndAdapter;
ArrayDispatchers _arrayDispatchers;
osg::ref_ptr<GraphicsCostEstimator> _graphicsCostEstimator;
Timer_t _startTick;
Timer_t _gpuTick;
GLuint64EXT _gpuTimestamp;

View File

@ -15,7 +15,6 @@
#define OSGUTIL_INCREMENTALCOMPILEOPERATOR
#include <osgUtil/GLObjectsVisitor>
#include <osg/GraphicsCostEstimator>
#include <osg/Geometry>
namespace osgUtil {
@ -120,10 +119,6 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation
osg::Geometry* getForceTextureDownloadGeometry() { return _forceTextureDownloadGeometry.get(); }
const osg::Geometry* getForceTextureDownloadGeometry() const { return _forceTextureDownloadGeometry.get(); }
osg::GraphicsCostEstimator* getGraphicsCostEstimator() { return _graphicsCostEstimator.get(); }
const osg::GraphicsCostEstimator* getGraphicsCostEstimator() const { return _graphicsCostEstimator.get(); }
typedef std::vector<osg::GraphicsContext*> Contexts;
void assignContexts(Contexts& contexts);
void removeContexts(Contexts& contexts);
@ -148,7 +143,6 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation
double availableTime() { return allocatedTime - timer.elapsedTime(); }
IncrementalCompileOperation* incrementalCompileOperation;
osg::GraphicsCostEstimator* graphicsCostEstimator;
unsigned int maxNumObjectsToCompile;
osg::ElapsedTime timer;
double allocatedTime;
@ -280,7 +274,6 @@ class OSGUTIL_EXPORT IncrementalCompileOperation : public osg::GraphicsOperation
double _conservativeTimeRatio;
osg::ref_ptr<osg::Geometry> _forceTextureDownloadGeometry;
osg::ref_ptr<osg::GraphicsCostEstimator> _graphicsCostEstimator;
OpenThreads::Mutex _toCompileMutex;
CompileSets _toCompile;

View File

@ -159,6 +159,8 @@ State::State():
_glBeginEndAdapter.setState(this);
_arrayDispatchers.setState(this);
_graphicsCostEstimator = new GraphicsCostEstimator;
_startTick = 0;
_gpuTick = 0;
_gpuTimestamp = 0;

View File

@ -54,7 +54,7 @@ static osg::ApplicationUsageProxy UCO_e2(osg::ApplicationUsage::ENVIRONMENTAL_VA
StateToCompile::StateToCompile(GLObjectsVisitor::Mode mode):
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_mode(mode),
_assignPBOToImages(true)
_assignPBOToImages(false)
{
}
@ -214,7 +214,7 @@ IncrementalCompileOperation::CompileDrawableOp::CompileDrawableOp(osg::Drawable*
double IncrementalCompileOperation::CompileDrawableOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
{
osg::GraphicsCostEstimator* gce = compileInfo.graphicsCostEstimator;
osg::GraphicsCostEstimator* gce = compileInfo.getState()->getGraphicsCostEstimator();
osg::Geometry* geometry = _drawable->asGeometry();
if (gce && geometry)
{
@ -237,7 +237,7 @@ IncrementalCompileOperation::CompileTextureOp::CompileTextureOp(osg::Texture* te
double IncrementalCompileOperation::CompileTextureOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
{
osg::GraphicsCostEstimator* gce = compileInfo.graphicsCostEstimator;
osg::GraphicsCostEstimator* gce = compileInfo.getState()->getGraphicsCostEstimator();
if (gce) return gce->estimateCompileCost(_texture.get()).first;
else return 0.0;
}
@ -272,7 +272,7 @@ IncrementalCompileOperation::CompileProgramOp::CompileProgramOp(osg::Program* pr
double IncrementalCompileOperation::CompileProgramOp::estimatedTimeForCompile(CompileInfo& compileInfo) const
{
osg::GraphicsCostEstimator* gce = compileInfo.graphicsCostEstimator;
osg::GraphicsCostEstimator* gce = compileInfo.getState()->getGraphicsCostEstimator();
if (gce) return gce->estimateCompileCost(_program.get()).first;
else return 0.0;
}
@ -288,7 +288,6 @@ IncrementalCompileOperation::CompileInfo::CompileInfo(osg::GraphicsContext* cont
{
setState(context->getState());
incrementalCompileOperation = ico;
graphicsCostEstimator = ico->getGraphicsCostEstimator();
}
@ -444,8 +443,6 @@ IncrementalCompileOperation::IncrementalCompileOperation():
_maximumNumOfObjectsToCompilePerFrame = atoi(ptr);
}
_graphicsCostEstimator = new osg::GraphicsCostEstimator;
// assignForceTextureDownloadGeometry();
}