Added experimental timing and PBO usage into ICO+GCE classes

This commit is contained in:
Robert Osfield
2011-02-01 12:18:22 +00:00
parent cb26484ac7
commit 99fc347212
3 changed files with 49 additions and 7 deletions

View File

@@ -36,8 +36,9 @@ class OSGUTIL_EXPORT StateToCompile : public osg::NodeVisitor
GLObjectsVisitor::Mode _mode;
DrawableSet _drawables;
TextureSet _textures;
ProgramSet _programs;
TextureSet _textures;
ProgramSet _programs;
bool _assignPBOToImages;
bool empty() const { return _textures.empty() && _programs.empty() && _drawables.empty(); }

View File

@@ -46,7 +46,6 @@ void GeometryCostEstimator::calibrate(osg::RenderInfo& renderInfo)
CostPair GeometryCostEstimator::estimateCompileCost(const osg::Geometry* geometry) const
{
OSG_INFO<<"GeometryCostEstimator::estimateCompileCost(..)"<<std::endl;
bool usesVBO = geometry->getUseVertexBufferObjects() && geometry->areFastPathsUsed();
bool usesDL = !usesVBO && geometry->getUseDisplayList() && geometry->getSupportsDisplayList();
@@ -79,7 +78,7 @@ CostPair GeometryCostEstimator::estimateCompileCost(const osg::Geometry* geometr
cost.first = _displayListCompileConstant + _displayListCompileFactor * cost.first ;
}
OSG_INFO<<" cost.first="<<cost.first<<std::endl;
OSG_NOTICE<<"GeometryCostEstimator::estimateCompileCost(..) size="<<cost.first<<std::endl;
return cost;
}

View File

@@ -53,7 +53,8 @@ static osg::ApplicationUsageProxy UCO_e2(osg::ApplicationUsage::ENVIRONMENTAL_VA
//
StateToCompile::StateToCompile(GLObjectsVisitor::Mode mode):
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_mode(mode)
_mode(mode),
_assignPBOToImages(true)
{
}
@@ -160,6 +161,45 @@ void StateToCompile::apply(osg::StateSet& stateset)
void StateToCompile::apply(osg::Texture& texture)
{
if (_assignPBOToImages)
{
unsigned int numRequringPBO = 0;
osg::ref_ptr<osg::PixelBufferObject> pbo = 0;
for(unsigned int i=0; i<texture.getNumImages(); ++i)
{
osg::Image* image = texture.getImage(i);
if (image)
{
if (image->getPixelBufferObject())
{
pbo = image->getPixelBufferObject();
}
else
{
++numRequringPBO;
}
}
}
if (numRequringPBO>0)
{
// assign pbo
if (!pbo) pbo = new osg::PixelBufferObject;
for(unsigned int i=0; i<texture.getNumImages(); ++i)
{
osg::Image* image = texture.getImage(i);
if (image)
{
if (!image->getPixelBufferObject())
{
//OSG_NOTICE<<"Assigning PBO"<<std::endl;
image->setPixelBufferObject(pbo.get());
}
}
}
}
}
_textures.insert(&texture);
}
@@ -282,7 +322,7 @@ double IncrementalCompileOperation::CompileList::estimatedTimeForCompile(Compile
bool IncrementalCompileOperation::CompileList::compile(CompileInfo& compileInfo)
{
//#define USE_TIME_ESTIMATES
#define USE_TIME_ESTIMATES
for(CompileOps::iterator itr = _compileOps.begin();
itr != _compileOps.end() && compileInfo.availableTime()>0.0 && compileInfo.maxNumObjectsToCompile>0;
@@ -307,7 +347,9 @@ bool IncrementalCompileOperation::CompileList::compile(CompileInfo& compileInfo)
#ifdef USE_TIME_ESTIMATES
double actualCompileCost = timer.elapsedTime();
OSG_NOTICE<<"IncrementalCompileOperation::CompileList::compile() estimatedTimForCompile= "<<estimatedCompileCost<<", actual="<<actualCompileCost<<", ratio="<<(estimatedCompileCost/actualCompileCost)<<std::endl;
OSG_NOTICE<<"IncrementalCompileOperation::CompileList::compile() estimatedTimForCompile= "<<estimatedCompileCost<<", actual="<<actualCompileCost;
if (estimatedCompileCost>0.0) OSG_NOTICE<<", ratio="<<(actualCompileCost/estimatedCompileCost);
OSG_NOTICE<<std::endl;
#endif
}
return empty();