Moved osg::Statistics to osgUtil::Statistics and merged addition to it
fro Pavel Moloshtan.
This commit is contained in:
@@ -785,10 +785,6 @@ SOURCE=..\..\Include\Osg\StateSet
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osg\Statistics
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Include\Osg\Stencil
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -277,6 +277,10 @@ SOURCE=..\..\include\osgUtil\SmoothingVisitor
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgUtil\Statistics
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\osgUtil\Tesselator
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -20,13 +20,10 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// forward declare Statistics to remove link dependancy.
|
||||
namespace osg { class Statistics; }
|
||||
|
||||
namespace osgUtil {
|
||||
|
||||
class RenderStage;
|
||||
|
||||
class Statistics;
|
||||
/**
|
||||
* RenderBin base class.
|
||||
*/
|
||||
@@ -110,9 +107,9 @@ class OSGUTIL_EXPORT RenderBin : public osg::Object
|
||||
|
||||
|
||||
/** extract stats for current draw list. */
|
||||
bool getStats(osg::Statistics* primStats);
|
||||
void getPrims(osg::Statistics* primStats);
|
||||
bool getPrims(osg::Statistics* primStats, int nbin);
|
||||
bool getStats(Statistics* primStats);
|
||||
void getPrims(Statistics* primStats);
|
||||
bool getPrims(Statistics* primStats, int nbin);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@@ -126,7 +126,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
void addToDependencyList(RenderStage* rs);
|
||||
|
||||
/** extract stats for current draw list. */
|
||||
bool getStats(osg::Statistics* primStats);
|
||||
bool getStats(Statistics* primStats);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace osg {
|
||||
namespace osgUtil {
|
||||
|
||||
/**
|
||||
* Statistics base class. Used to extract primitive information from
|
||||
@@ -34,11 +34,13 @@ namespace osg {
|
||||
* each trifan or tristrip = (length-2) triangles and so on.
|
||||
*/
|
||||
|
||||
class Statistics : public osg::Drawable::PrimitiveFunctor{
|
||||
class Statistics : public osg::Drawable::PrimitiveFunctor
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::pair<unsigned int,unsigned int> PrimitivePair;
|
||||
typedef std::map<GLenum,PrimitivePair> PrimtiveValueMap;
|
||||
typedef std::map<GLenum, unsigned int> PrimtiveCountMap;
|
||||
|
||||
|
||||
Statistics()
|
||||
@@ -71,17 +73,61 @@ class Statistics : public osg::Drawable::PrimitiveFunctor{
|
||||
|
||||
void setType(statsType t) {stattype=t;}
|
||||
|
||||
virtual void setVertexArray(unsigned int count,const Vec3*) { _vertexCount += count; }
|
||||
virtual void setVertexArray(unsigned int count,const osg::Vec3*) { _vertexCount += count; }
|
||||
|
||||
virtual void drawArrays(GLenum mode,GLint,GLsizei count) { PrimitivePair& prim = _primitiveCount[mode]; ++prim.first; prim.second+=count; }
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte*) { PrimitivePair& prim = _primitiveCount[mode]; ++prim.first; prim.second+=count; }
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLushort*) { PrimitivePair& prim = _primitiveCount[mode]; ++prim.first; prim.second+=count; }
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLuint*) { PrimitivePair& prim = _primitiveCount[mode]; ++prim.first; prim.second+=count; }
|
||||
virtual void drawArrays(GLenum mode,GLint,GLsizei count)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLubyte*)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLushort*)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
virtual void drawElements(GLenum mode,GLsizei count,const GLuint*)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
prim.second+=count;
|
||||
_primitives_count[mode] += _calculate_primitives_number_by_mode(mode, count);
|
||||
}
|
||||
|
||||
virtual void begin(GLenum mode) { _currentPrimtiveFunctorMode=mode; PrimitivePair& prim = _primitiveCount[mode]; ++prim.first; }
|
||||
virtual void vertex(const Vec3&) { PrimitivePair& prim = _primitiveCount[_currentPrimtiveFunctorMode]; ++prim.second; }
|
||||
virtual void vertex(float,float,float) { PrimitivePair& prim = _primitiveCount[_currentPrimtiveFunctorMode]; ++prim.second; }
|
||||
virtual void end() {}
|
||||
virtual void begin(GLenum mode)
|
||||
{
|
||||
_currentPrimtiveFunctorMode=mode;
|
||||
PrimitivePair& prim = _primitiveCount[mode];
|
||||
++prim.first;
|
||||
_number_of_vertexes = 0;
|
||||
}
|
||||
virtual void vertex(const osg::Vec3&)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[_currentPrimtiveFunctorMode];
|
||||
++prim.second;
|
||||
_number_of_vertexes++;
|
||||
}
|
||||
virtual void vertex(float,float,float)
|
||||
{
|
||||
PrimitivePair& prim = _primitiveCount[_currentPrimtiveFunctorMode];
|
||||
++prim.second;
|
||||
_number_of_vertexes++;
|
||||
}
|
||||
virtual void end()
|
||||
{
|
||||
_primitives_count[_currentPrimtiveFunctorMode] +=
|
||||
_calculate_primitives_number_by_mode(_currentPrimtiveFunctorMode, _number_of_vertexes);
|
||||
}
|
||||
|
||||
void addDrawable() { numDrawables++;}
|
||||
void addMatrix() { nummat++;}
|
||||
@@ -95,6 +141,9 @@ class Statistics : public osg::Drawable::PrimitiveFunctor{
|
||||
|
||||
public:
|
||||
|
||||
PrimtiveCountMap::iterator GetPrimitivesBegin() { return _primitives_count.begin(); }
|
||||
PrimtiveCountMap::iterator GetPrimitivesEnd() { return _primitives_count.end(); }
|
||||
|
||||
int numDrawables, nummat, nbins;
|
||||
int nlights;
|
||||
int depth; // depth into bins - eg 1.1,1.2,1.3 etc
|
||||
@@ -105,10 +154,34 @@ class Statistics : public osg::Drawable::PrimitiveFunctor{
|
||||
unsigned int _vertexCount;
|
||||
PrimtiveValueMap _primitiveCount;
|
||||
GLenum _currentPrimtiveFunctorMode;
|
||||
|
||||
|
||||
private:
|
||||
PrimtiveCountMap _primitives_count;
|
||||
|
||||
unsigned int _total_primitives_count;
|
||||
unsigned int _number_of_vertexes;
|
||||
|
||||
unsigned int _calculate_primitives_number_by_mode(GLenum, GLsizei);
|
||||
};
|
||||
|
||||
inline unsigned int Statistics::_calculate_primitives_number_by_mode(GLenum mode, GLsizei count)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case GL_POINTS:
|
||||
case GL_LINE_LOOP:
|
||||
case GL_POLYGON: return count;
|
||||
case GL_LINES: return count / 2;
|
||||
case GL_LINE_STRIP: return count - 1;
|
||||
case GL_TRIANGLES: return count / 3;
|
||||
case GL_TRIANGLE_STRIP:
|
||||
case GL_TRIANGLE_FAN: return count - 2;
|
||||
case GL_QUADS: return count / 4;
|
||||
case GL_QUAD_STRIP: return count - 3;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,8 +12,8 @@
|
||||
*/
|
||||
#include <osgUtil/RenderBin>
|
||||
#include <osgUtil/RenderStage>
|
||||
#include <osgUtil/Statistics>
|
||||
|
||||
#include <osg/Statistics>
|
||||
#include <osg/ImpostorSprite>
|
||||
#include <osg/Notify>
|
||||
|
||||
@@ -334,7 +334,7 @@ void RenderBin::drawImplementation(osg::State& state,RenderLeaf*& previous)
|
||||
}
|
||||
|
||||
// stats
|
||||
bool RenderBin::getStats(osg::Statistics* primStats)
|
||||
bool RenderBin::getStats(Statistics* primStats)
|
||||
{ // different by return type - collects the stats in this renderrBin
|
||||
bool somestats=false;
|
||||
|
||||
@@ -382,7 +382,7 @@ bool RenderBin::getStats(osg::Statistics* primStats)
|
||||
return somestats;
|
||||
}
|
||||
|
||||
void RenderBin::getPrims(osg::Statistics* primStats)
|
||||
void RenderBin::getPrims(Statistics* primStats)
|
||||
{
|
||||
static int ndepth;
|
||||
ndepth++;
|
||||
@@ -398,7 +398,7 @@ void RenderBin::getPrims(osg::Statistics* primStats)
|
||||
|
||||
}
|
||||
|
||||
bool RenderBin::getPrims(osg::Statistics* primStats, int nbin)
|
||||
bool RenderBin::getPrims(Statistics* primStats, int nbin)
|
||||
{ // collect stats for array of bins, maximum nbin
|
||||
// (which will be modified on next call if array of primStats is too small);
|
||||
// return 1 for OK;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Statistics>
|
||||
#include <osgUtil/Statistics>
|
||||
|
||||
#include <osgUtil/RenderStage>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user