add new pstats collectors

This commit is contained in:
David Rose 2004-01-14 21:19:10 +00:00
parent 41201ed885
commit b33978174f
21 changed files with 69 additions and 19 deletions

View File

@ -41,6 +41,8 @@
#ifndef CPPPARSER #ifndef CPPPARSER
PStatCollector GraphicsEngine::_cull_pcollector("Cull"); PStatCollector GraphicsEngine::_cull_pcollector("Cull");
PStatCollector GraphicsEngine::_draw_pcollector("Draw"); PStatCollector GraphicsEngine::_draw_pcollector("Draw");
PStatCollector GraphicsEngine::_sync_pcollector("Draw:Sync");
PStatCollector GraphicsEngine::_flip_pcollector("Draw:Flip");
PStatCollector GraphicsEngine::_transform_states_pcollector("TransformStates"); PStatCollector GraphicsEngine::_transform_states_pcollector("TransformStates");
PStatCollector GraphicsEngine::_transform_states_unused_pcollector("TransformStates:Unused"); PStatCollector GraphicsEngine::_transform_states_unused_pcollector("TransformStates:Unused");
PStatCollector GraphicsEngine::_render_states_pcollector("RenderStates"); PStatCollector GraphicsEngine::_render_states_pcollector("RenderStates");
@ -627,6 +629,9 @@ flip_windows(const GraphicsEngine::Windows &wlist) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void GraphicsEngine:: void GraphicsEngine::
do_sync_frame() { do_sync_frame() {
// Statistics
PStatTimer timer(_sync_pcollector);
nassertv(_flip_state == FS_draw); nassertv(_flip_state == FS_draw);
// Wait for all the threads to finish their current frame. Grabbing // Wait for all the threads to finish their current frame. Grabbing
@ -649,6 +654,9 @@ do_sync_frame() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void GraphicsEngine:: void GraphicsEngine::
do_flip_frame() { do_flip_frame() {
// Statistics
PStatTimer timer(_flip_pcollector);
nassertv(_flip_state == FS_draw || _flip_state == FS_sync); nassertv(_flip_state == FS_draw || _flip_state == FS_sync);
// First, wait for all the threads to finish their current frame, if // First, wait for all the threads to finish their current frame, if

View File

@ -182,6 +182,8 @@ private:
static PStatCollector _cull_pcollector; static PStatCollector _cull_pcollector;
static PStatCollector _draw_pcollector; static PStatCollector _draw_pcollector;
static PStatCollector _sync_pcollector;
static PStatCollector _flip_pcollector;
static PStatCollector _transform_states_pcollector; static PStatCollector _transform_states_pcollector;
static PStatCollector _transform_states_unused_pcollector; static PStatCollector _transform_states_unused_pcollector;
static PStatCollector _render_states_pcollector; static PStatCollector _render_states_pcollector;

View File

@ -25,6 +25,11 @@
#include "config_grutil.h" #include "config_grutil.h"
#include "depthTestAttrib.h" #include "depthTestAttrib.h"
#include "depthWriteAttrib.h" #include "depthWriteAttrib.h"
#include "pStatTimer.h"
#ifndef CPPPARSER
PStatCollector FrameRateMeter::_show_fps_pcollector("Cull:Show fps");
#endif // CPPPARSER
TypeHandle FrameRateMeter::_type_handle; TypeHandle FrameRateMeter::_type_handle;
@ -143,6 +148,9 @@ clear_layer() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool FrameRateMeter:: bool FrameRateMeter::
cull_callback(CullTraverser *trav, CullTraverserData &data) { cull_callback(CullTraverser *trav, CullTraverserData &data) {
// Statistics
PStatTimer timer(_show_fps_pcollector);
// Check to see if it's time to update. // Check to see if it's time to update.
double now = _clock_object->get_frame_time(); double now = _clock_object->get_frame_time();
double elapsed = now - _last_update; double elapsed = now - _last_update;

View File

@ -25,6 +25,7 @@
#include "graphicsWindow.h" #include "graphicsWindow.h"
#include "graphicsLayer.h" #include "graphicsLayer.h"
#include "pointerTo.h" #include "pointerTo.h"
#include "pStatCollector.h"
class GraphicsChannel; class GraphicsChannel;
class ClockObject; class ClockObject;
@ -76,6 +77,8 @@ private:
string _text_pattern; string _text_pattern;
ClockObject *_clock_object; ClockObject *_clock_object;
static PStatCollector _show_fps_pcollector;
public: public:
static TypeHandle get_class_type() { static TypeHandle get_class_type() {
return _type_handle; return _type_handle;

View File

@ -23,7 +23,9 @@
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CullBin:: INLINE CullBin::
CullBin(GraphicsStateGuardianBase *gsg) : CullBin(const string &name, GraphicsStateGuardianBase *gsg) :
_cull_this_pcollector(_cull_bin_pcollector, name),
_draw_this_pcollector(_draw_bin_pcollector, name),
_gsg(gsg) _gsg(gsg)
{ {
} }

View File

@ -19,6 +19,11 @@
#include "cullBin.h" #include "cullBin.h"
#ifndef CPPPARSER
PStatCollector CullBin::_cull_bin_pcollector("Cull:Bins");
PStatCollector CullBin::_draw_bin_pcollector("Draw:Bins");
#endif
TypeHandle CullBin::_type_handle; TypeHandle CullBin::_type_handle;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -22,6 +22,7 @@
#include "pandabase.h" #include "pandabase.h"
#include "typedReferenceCount.h" #include "typedReferenceCount.h"
#include "pStatCollector.h"
#include "pointerTo.h" #include "pointerTo.h"
class CullableObject; class CullableObject;
@ -40,7 +41,7 @@ class GraphicsStateGuardianBase;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA CullBin : public TypedReferenceCount { class EXPCL_PANDA CullBin : public TypedReferenceCount {
public: public:
INLINE CullBin(GraphicsStateGuardianBase *gsg); INLINE CullBin(const string &name, GraphicsStateGuardianBase *gsg);
virtual ~CullBin(); virtual ~CullBin();
virtual PT(CullBin) make_next() const; virtual PT(CullBin) make_next() const;
@ -53,6 +54,11 @@ public:
protected: protected:
GraphicsStateGuardianBase *_gsg; GraphicsStateGuardianBase *_gsg;
static PStatCollector _cull_bin_pcollector;
static PStatCollector _draw_bin_pcollector;
PStatCollector _cull_this_pcollector;
PStatCollector _draw_this_pcollector;
public: public:
static TypeHandle get_class_type() { static TypeHandle get_class_type() {
return _type_handle; return _type_handle;

View File

@ -47,7 +47,7 @@ operator < (const ObjectData &other) const {
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CullBinBackToFront:: INLINE CullBinBackToFront::
CullBinBackToFront(GraphicsStateGuardianBase *gsg) : CullBinBackToFront(const string &name, GraphicsStateGuardianBase *gsg) :
CullBin(gsg) CullBin(name, gsg)
{ {
} }

View File

@ -21,6 +21,7 @@
#include "geometricBoundingVolume.h" #include "geometricBoundingVolume.h"
#include "cullableObject.h" #include "cullableObject.h"
#include "cullHandler.h" #include "cullHandler.h"
#include "pStatTimer.h"
#include <algorithm> #include <algorithm>
@ -77,6 +78,7 @@ add_object(CullableObject *object) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CullBinBackToFront:: void CullBinBackToFront::
finish_cull() { finish_cull() {
PStatTimer timer(_cull_this_pcollector);
sort(_objects.begin(), _objects.end()); sort(_objects.begin(), _objects.end());
} }
@ -88,6 +90,7 @@ finish_cull() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CullBinBackToFront:: void CullBinBackToFront::
draw() { draw() {
PStatTimer timer(_draw_this_pcollector);
Objects::const_iterator oi; Objects::const_iterator oi;
for (oi = _objects.begin(); oi != _objects.end(); ++oi) { for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
CullableObject *object = (*oi)._object; CullableObject *object = (*oi)._object;

View File

@ -37,7 +37,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA CullBinBackToFront : public CullBin { class EXPCL_PANDA CullBinBackToFront : public CullBin {
public: public:
INLINE CullBinBackToFront(GraphicsStateGuardianBase *gsg); INLINE CullBinBackToFront(const string &name, GraphicsStateGuardianBase *gsg);
virtual ~CullBinBackToFront(); virtual ~CullBinBackToFront();
virtual void add_object(CullableObject *object); virtual void add_object(CullableObject *object);

View File

@ -47,7 +47,7 @@ operator < (const ObjectData &other) const {
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CullBinFixed:: INLINE CullBinFixed::
CullBinFixed(GraphicsStateGuardianBase *gsg) : CullBinFixed(const string &name, GraphicsStateGuardianBase *gsg) :
CullBin(gsg) CullBin(name, gsg)
{ {
} }

View File

@ -21,6 +21,7 @@
#include "geometricBoundingVolume.h" #include "geometricBoundingVolume.h"
#include "cullableObject.h" #include "cullableObject.h"
#include "cullHandler.h" #include "cullHandler.h"
#include "pStatTimer.h"
#include <algorithm> #include <algorithm>
@ -64,6 +65,7 @@ add_object(CullableObject *object) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CullBinFixed:: void CullBinFixed::
finish_cull() { finish_cull() {
PStatTimer timer(_cull_this_pcollector);
stable_sort(_objects.begin(), _objects.end()); stable_sort(_objects.begin(), _objects.end());
} }
@ -75,6 +77,7 @@ finish_cull() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CullBinFixed:: void CullBinFixed::
draw() { draw() {
PStatTimer timer(_draw_this_pcollector);
Objects::const_iterator oi; Objects::const_iterator oi;
for (oi = _objects.begin(); oi != _objects.end(); ++oi) { for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
CullableObject *object = (*oi)._object; CullableObject *object = (*oi)._object;

View File

@ -40,7 +40,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA CullBinFixed : public CullBin { class EXPCL_PANDA CullBinFixed : public CullBin {
public: public:
INLINE CullBinFixed(GraphicsStateGuardianBase *gsg); INLINE CullBinFixed(const string &name, GraphicsStateGuardianBase *gsg);
virtual ~CullBinFixed(); virtual ~CullBinFixed();
virtual void add_object(CullableObject *object); virtual void add_object(CullableObject *object);

View File

@ -47,7 +47,7 @@ operator < (const ObjectData &other) const {
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CullBinFrontToBack:: INLINE CullBinFrontToBack::
CullBinFrontToBack(GraphicsStateGuardianBase *gsg) : CullBinFrontToBack(const string &name, GraphicsStateGuardianBase *gsg) :
CullBin(gsg) CullBin(name, gsg)
{ {
} }

View File

@ -21,6 +21,7 @@
#include "geometricBoundingVolume.h" #include "geometricBoundingVolume.h"
#include "cullableObject.h" #include "cullableObject.h"
#include "cullHandler.h" #include "cullHandler.h"
#include "pStatTimer.h"
#include <algorithm> #include <algorithm>
@ -77,6 +78,7 @@ add_object(CullableObject *object) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CullBinFrontToBack:: void CullBinFrontToBack::
finish_cull() { finish_cull() {
PStatTimer timer(_cull_this_pcollector);
sort(_objects.begin(), _objects.end()); sort(_objects.begin(), _objects.end());
} }
@ -88,6 +90,7 @@ finish_cull() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CullBinFrontToBack:: void CullBinFrontToBack::
draw() { draw() {
PStatTimer timer(_draw_this_pcollector);
Objects::const_iterator oi; Objects::const_iterator oi;
for (oi = _objects.begin(); oi != _objects.end(); ++oi) { for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
CullableObject *object = (*oi)._object; CullableObject *object = (*oi)._object;

View File

@ -38,7 +38,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA CullBinFrontToBack : public CullBin { class EXPCL_PANDA CullBinFrontToBack : public CullBin {
public: public:
INLINE CullBinFrontToBack(GraphicsStateGuardianBase *gsg); INLINE CullBinFrontToBack(const string &name, GraphicsStateGuardianBase *gsg);
virtual ~CullBinFrontToBack(); virtual ~CullBinFrontToBack();
virtual void add_object(CullableObject *object); virtual void add_object(CullableObject *object);

View File

@ -200,19 +200,20 @@ PT(CullBin) CullBinManager::
make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg) { make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg) {
nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), NULL); nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), NULL);
nassertr(_bin_definitions[bin_index]._in_use, NULL); nassertr(_bin_definitions[bin_index]._in_use, NULL);
string name = get_bin_name(bin_index);
switch (_bin_definitions[bin_index]._type) { switch (_bin_definitions[bin_index]._type) {
case BT_back_to_front: case BT_back_to_front:
return new CullBinBackToFront(gsg); return new CullBinBackToFront(name, gsg);
case BT_front_to_back: case BT_front_to_back:
return new CullBinFrontToBack(gsg); return new CullBinFrontToBack(name, gsg);
case BT_fixed: case BT_fixed:
return new CullBinFixed(gsg); return new CullBinFixed(name, gsg);
default: default:
return new CullBinUnsorted(gsg); return new CullBinUnsorted(name, gsg);
} }
} }

View File

@ -23,7 +23,7 @@
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE CullBinUnsorted:: INLINE CullBinUnsorted::
CullBinUnsorted(GraphicsStateGuardianBase *gsg) : CullBinUnsorted(const string &name, GraphicsStateGuardianBase *gsg) :
CullBin(gsg) CullBin(name, gsg)
{ {
} }

View File

@ -19,6 +19,7 @@
#include "cullBinUnsorted.h" #include "cullBinUnsorted.h"
#include "cullHandler.h" #include "cullHandler.h"
#include "graphicsStateGuardianBase.h" #include "graphicsStateGuardianBase.h"
#include "pStatTimer.h"
TypeHandle CullBinUnsorted::_type_handle; TypeHandle CullBinUnsorted::_type_handle;
@ -56,6 +57,7 @@ add_object(CullableObject *object) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CullBinUnsorted:: void CullBinUnsorted::
draw() { draw() {
PStatTimer timer(_draw_this_pcollector);
Objects::iterator oi; Objects::iterator oi;
for (oi = _objects.begin(); oi != _objects.end(); ++oi) { for (oi = _objects.begin(); oi != _objects.end(); ++oi) {
CullableObject *object = (*oi); CullableObject *object = (*oi);

View File

@ -33,7 +33,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA CullBinUnsorted : public CullBin { class EXPCL_PANDA CullBinUnsorted : public CullBin {
public: public:
INLINE CullBinUnsorted(GraphicsStateGuardianBase *gsg); INLINE CullBinUnsorted(const string &name, GraphicsStateGuardianBase *gsg);
~CullBinUnsorted(); ~CullBinUnsorted();
virtual void add_object(CullableObject *object); virtual void add_object(CullableObject *object);

View File

@ -119,9 +119,13 @@ static TimeCollectorProperties time_properties[] = {
{ 0, "App:Show code:Nametags:3d:Contents", { 0.0, 0.5, 0.0 } }, { 0, "App:Show code:Nametags:3d:Contents", { 0.0, 0.5, 0.0 } },
{ 0, "App:Show code:Nametags:3d:Adjust", { 0.5, 0.0, 0.5 } }, { 0, "App:Show code:Nametags:3d:Adjust", { 0.5, 0.0, 0.5 } },
{ 1, "Cull", { 0.0, 1.0, 0.0 }, 1.0 / 30.0 }, { 1, "Cull", { 0.0, 1.0, 0.0 }, 1.0 / 30.0 },
{ 1, "Cull:Show fps", { 0.5, 0.8, 1.0 } },
{ 1, "Cull:Bins", { 0.3, 0.6, 0.3 } },
{ 1, "Draw", { 1.0, 0.0, 0.0 }, 1.0 / 30.0 }, { 1, "Draw", { 1.0, 0.0, 0.0 }, 1.0 / 30.0 },
{ 1, "Draw:Sync", { 0.5, 0.7, 0.7 } },
{ 1, "Draw:Flip", { 1.0, 0.6, 0.3 } },
{ 1, "Draw:Bins", { 0.3, 0.6, 0.3 } },
{ 0, "Draw:Primitive", { 0.0, 0.0, 0.5 } }, { 0, "Draw:Primitive", { 0.0, 0.0, 0.5 } },
{ 0, "Draw:Show fps", { 0.5, 0.8, 1.0 } },
{ 0, NULL } { 0, NULL }
}; };