ソースを参照

add new pstats collectors

David Rose 22 年 前
コミット
b33978174f

+ 8 - 0
panda/src/display/graphicsEngine.cxx

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

+ 2 - 0
panda/src/display/graphicsEngine.h

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

+ 8 - 0
panda/src/grutil/frameRateMeter.cxx

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

+ 3 - 0
panda/src/grutil/frameRateMeter.h

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

+ 3 - 1
panda/src/pgraph/cullBin.I

@@ -23,7 +23,9 @@
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 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)
 {
 }

+ 5 - 0
panda/src/pgraph/cullBin.cxx

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

+ 7 - 1
panda/src/pgraph/cullBin.h

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

+ 2 - 2
panda/src/pgraph/cullBinBackToFront.I

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

+ 3 - 0
panda/src/pgraph/cullBinBackToFront.cxx

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

+ 1 - 1
panda/src/pgraph/cullBinBackToFront.h

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

+ 2 - 2
panda/src/pgraph/cullBinFixed.I

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

+ 3 - 0
panda/src/pgraph/cullBinFixed.cxx

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

+ 1 - 1
panda/src/pgraph/cullBinFixed.h

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

+ 2 - 2
panda/src/pgraph/cullBinFrontToBack.I

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

+ 3 - 0
panda/src/pgraph/cullBinFrontToBack.cxx

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

+ 1 - 1
panda/src/pgraph/cullBinFrontToBack.h

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

+ 5 - 4
panda/src/pgraph/cullBinManager.cxx

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

+ 2 - 2
panda/src/pgraph/cullBinUnsorted.I

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

+ 2 - 0
panda/src/pgraph/cullBinUnsorted.cxx

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

+ 1 - 1
panda/src/pgraph/cullBinUnsorted.h

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

+ 5 - 1
panda/src/pstatclient/pStatProperties.cxx

@@ -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:Adjust",   { 0.5, 0.0, 0.5 } },
   { 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: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:Show fps",                    { 0.5, 0.8, 1.0 } },
   { 0, NULL }
 };