From 9978516bf7eb393facacc0838c5149f8c9b21c80 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 25 Oct 2010 13:42:01 +0000 Subject: [PATCH] Added number of primitive sets to on screen stats --- examples/osganalysis/osganalysis.cpp | 4 ++-- include/osgUtil/Statistics | 4 ++++ src/osgUtil/IncrementalCompileOperation.cpp | 9 +++++++-- src/osgViewer/Renderer.cpp | 10 ++++++++++ src/osgViewer/StatsHandler.cpp | 6 ++++-- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/examples/osganalysis/osganalysis.cpp b/examples/osganalysis/osganalysis.cpp index a2f279c0a..a41c65c5f 100644 --- a/examples/osganalysis/osganalysis.cpp +++ b/examples/osganalysis/osganalysis.cpp @@ -110,8 +110,8 @@ public: OSG_NOTICE<<"Running simplifier with simplification ratio="<accept(simplifier); } diff --git a/include/osgUtil/Statistics b/include/osgUtil/Statistics index 6ab80fbfb..302ab351c 100644 --- a/include/osgUtil/Statistics +++ b/include/osgUtil/Statistics @@ -121,6 +121,10 @@ class OSGUTIL_EXPORT Statistics : public osg::PrimitiveFunctor PrimitiveCountMap& getPrimitiveCountMap() { return _primitives_count; } const PrimitiveCountMap& getPrimitiveCountMap() const { return _primitives_count; } + PrimitiveValueMap& getPrimitiveValueMap() { return _primitiveCount; } + const PrimitiveValueMap& getPrimitiveValueMap() const { return _primitiveCount; } + + /// deprecated PrimitiveCountMap::iterator GetPrimitivesBegin() { return _primitives_count.begin(); } /// deprecated diff --git a/src/osgUtil/IncrementalCompileOperation.cpp b/src/osgUtil/IncrementalCompileOperation.cpp index d70f991f2..6338f4ca0 100644 --- a/src/osgUtil/IncrementalCompileOperation.cpp +++ b/src/osgUtil/IncrementalCompileOperation.cpp @@ -212,6 +212,8 @@ void CompileOperator::runTimingTests(osg::RenderInfo& renderInfo) OSG_NOTICE<<"runTimingTests()"<get(); unsigned int size = drawable->getGLObjectSizeHint(); const std::string& nameOfDrawableType = drawable->getUseVertexBufferObjects() ? vboDrawablesName : dlDawablesName; + +#if 0 double estimatedTime = _compileStats->estimateTime(nameOfDrawableType, double(size)); double estimatedTime2 = _compileStats->estimateTime2(nameOfDrawableType, double(size)); double estimatedTime3 = _compileStats->estimateTime3(nameOfDrawableType, double(size)); double estimatedTime4 = _compileStats->estimateTime4(nameOfDrawableType, double(size)); - +#endif drawable->compileGLObjects(renderInfo); osg::Timer_t currTick = osg::Timer::instance()->tick(); double timeForCompile = osg::Timer::instance()->delta_s(previousTick, currTick); previousTick = currTick; +#if 0 OSG_NOTICE<<"Drawable size = "<(sceneStats.nimpostor)); stats->setAttribute(frameNumber, "Number of ordered leaves", static_cast(sceneStats.numOrderedLeaves)); + unsigned int totalNumPrimitiveSets = 0; + const osgUtil::Statistics::PrimitiveValueMap& pvm = sceneStats.getPrimitiveValueMap(); + for(osgUtil::Statistics::PrimitiveValueMap::const_iterator pvm_itr = pvm.begin(); + pvm_itr != pvm.end(); + ++pvm_itr) + { + totalNumPrimitiveSets += pvm_itr->second.first; + } + stats->setAttribute(frameNumber, "Visible number of PrimitiveSets", static_cast(totalNumPrimitiveSets)); + osgUtil::Statistics::PrimitiveCountMap& pcm = sceneStats.getPrimitiveCountMap(); stats->setAttribute(frameNumber, "Visible number of GL_POINTS", static_cast(pcm[GL_POINTS])); stats->setAttribute(frameNumber, "Visible number of GL_LINES", static_cast(pcm[GL_LINES])); diff --git a/src/osgViewer/StatsHandler.cpp b/src/osgViewer/StatsHandler.cpp index 267a737fb..cc0010792 100644 --- a/src/osgViewer/StatsHandler.cpp +++ b/src/osgViewer/StatsHandler.cpp @@ -419,6 +419,7 @@ struct CameraSceneStatsTextDrawCallback : public virtual osg::Drawable::DrawCall STATS_ATTRIBUTE("Visible number of fast drawables") STATS_ATTRIBUTE("Visible vertex count") + STATS_ATTRIBUTE("Visible number of PrimitiveSets") STATS_ATTRIBUTE("Visible number of GL_POINTS") STATS_ATTRIBUTE("Visible number of GL_LINES") STATS_ATTRIBUTE("Visible number of GL_LINE_STRIP") @@ -1410,7 +1411,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) group->addChild(geode); geode->addDrawable(createBackgroundRectangle(pos + osg::Vec3(-backgroundMargin, characterSize + backgroundMargin, 0), 10 * characterSize + 2 * backgroundMargin, - 21 * characterSize + 2 * backgroundMargin, + 22 * characterSize + 2 * backgroundMargin, backgroundColor)); // Camera scene & primitive stats static text @@ -1436,6 +1437,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) viewStr << "Sorted Drawables" << std::endl; viewStr << "Fast Drawables" << std::endl; viewStr << "Vertices" << std::endl; + viewStr << "PrimitiveSets" << std::endl; viewStr << "Points" << std::endl; viewStr << "Lines" << std::endl; viewStr << "Line strips" << std::endl; @@ -1458,7 +1460,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer) { geode->addDrawable(createBackgroundRectangle(pos + osg::Vec3(-backgroundMargin, characterSize + backgroundMargin, 0), 5 * characterSize + 2 * backgroundMargin, - 21 * characterSize + 2 * backgroundMargin, + 22 * characterSize + 2 * backgroundMargin, backgroundColor)); // Camera scene stats