Browse Source

pstats: Some collector reorganisation:

- "App:Show code:General" is gone, it was causing too much trouble
- Replace odd "Client::GuiObjects" with "Nodes:GUI"
- Regroup "Dirty PipelineCyclers" underneath "PipelineCyclers"
rdb 3 years ago
parent
commit
d7bbcfb0b7

+ 0 - 6
direct/src/gui/DirectGuiBase.py

@@ -100,8 +100,6 @@ from direct.showbase import DirectObject
 from direct.task import Task
 from direct.task.TaskManagerGlobal import taskMgr
 
-guiObjectCollector = PStatCollector("Client::GuiObjects")
-
 _track_gui_items = ConfigVariableBool('track-gui-items', False)
 
 
@@ -732,8 +730,6 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
         self.guiId = self.guiItem.getId()
 
         if ShowBaseGlobal.__dev__:
-            guiObjectCollector.addLevel(1)
-            guiObjectCollector.flushLevel()
             # track gui items by guiId for tracking down leaks
             if _track_gui_items:
                 if not hasattr(ShowBase, 'guiItems'):
@@ -1033,8 +1029,6 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
     def destroy(self):
         if hasattr(self, "frameStyle"):
             if ShowBaseGlobal.__dev__:
-                guiObjectCollector.subLevel(1)
-                guiObjectCollector.flushLevel()
                 if hasattr(ShowBase, 'guiItems'):
                     ShowBase.guiItems.pop(self.guiId, None)
 

+ 19 - 13
panda/src/display/graphicsEngine.cxx

@@ -69,7 +69,7 @@ PT(GraphicsEngine) GraphicsEngine::_global_ptr;
 
 PStatCollector GraphicsEngine::_wait_pcollector("Wait:Thread sync");
 PStatCollector GraphicsEngine::_cycle_pcollector("App:Cycle");
-PStatCollector GraphicsEngine::_app_pcollector("App:Show code:General");
+//PStatCollector GraphicsEngine::_app_pcollector("App:Show code:General");
 PStatCollector GraphicsEngine::_render_frame_pcollector("App:render_frame");
 PStatCollector GraphicsEngine::_do_frame_pcollector("*:do_frame");
 PStatCollector GraphicsEngine::_yield_pcollector("App:Yield");
@@ -86,7 +86,7 @@ PStatCollector GraphicsEngine::_transform_states_unused_pcollector("TransformSta
 PStatCollector GraphicsEngine::_render_states_pcollector("RenderStates");
 PStatCollector GraphicsEngine::_render_states_unused_pcollector("RenderStates:Unused");
 PStatCollector GraphicsEngine::_cyclers_pcollector("PipelineCyclers");
-PStatCollector GraphicsEngine::_dirty_cyclers_pcollector("Dirty PipelineCyclers");
+PStatCollector GraphicsEngine::_dirty_cyclers_pcollector("PipelineCyclers:Dirty");
 PStatCollector GraphicsEngine::_delete_pcollector("App:Delete");
 
 
@@ -182,9 +182,9 @@ GraphicsEngine(Pipeline *pipeline) :
 GraphicsEngine::
 ~GraphicsEngine() {
 #ifdef DO_PSTATS
-  if (_app_pcollector.is_started()) {
-    _app_pcollector.stop();
-  }
+  //if (_app_pcollector.is_started()) {
+  //  _app_pcollector.stop();
+  //}
 #endif
 
   remove_all_windows();
@@ -714,9 +714,9 @@ render_frame() {
   // to be App.
 #ifdef DO_PSTATS
   _render_frame_pcollector.start();
-  if (_app_pcollector.is_started()) {
-    _app_pcollector.stop();
-  }
+  //if (_app_pcollector.is_started()) {
+  //  _app_pcollector.stop();
+  //}
 #endif
 
   // Make sure our buffers and windows are fully realized before we render a
@@ -799,7 +799,10 @@ render_frame() {
 
     // Now it's time to do any drawing from the main frame--after all of the
     // App code has executed, but before we begin the next frame.
-    _app.do_frame(this, current_thread);
+    {
+      PStatTimer timer(_do_frame_pcollector, current_thread);
+      _app.do_frame(this, current_thread);
+    }
 
     // Grab each thread's mutex again after all windows have flipped, and wait
     // for the thread to finish.
@@ -854,6 +857,7 @@ render_frame() {
     // Reset our pcollectors that track data across the frame.
     CullTraverser::_nodes_pcollector.clear_level();
     CullTraverser::_geom_nodes_pcollector.clear_level();
+    CullTraverser::_pgui_nodes_pcollector.clear_level();
     CullTraverser::_geoms_pcollector.clear_level();
     GeomCacheManager::_geom_cache_active_pcollector.clear_level();
     GeomCacheManager::_geom_cache_record_pcollector.clear_level();
@@ -954,7 +958,7 @@ render_frame() {
 
   // Anything that happens outside of GraphicsEngine::render_frame() is deemed
   // to be App.
-  _app_pcollector.start();
+  //_app_pcollector.start();
   _render_frame_pcollector.stop();
 }
 
@@ -2573,7 +2577,6 @@ resort_windows() {
  */
 void GraphicsEngine::WindowRenderer::
 do_frame(GraphicsEngine *engine, Thread *current_thread) {
-  PStatTimer timer(engine->_do_frame_pcollector, current_thread);
   LightReMutexHolder holder(_wl_lock);
 
   engine->cull_to_bins(_cull, current_thread);
@@ -2745,8 +2748,11 @@ thread_main() {
       break;
 
     case TS_do_frame:
-      do_pending(_engine, current_thread);
-      do_frame(_engine, current_thread);
+      {
+        PStatTimer timer(_engine->_do_frame_pcollector, current_thread);
+        do_pending(_engine, current_thread);
+        do_frame(_engine, current_thread);
+      }
       break;
 
     case TS_do_flip:

+ 1 - 1
panda/src/display/graphicsEngine.h

@@ -358,7 +358,7 @@ private:
 
   static PStatCollector _wait_pcollector;
   static PStatCollector _cycle_pcollector;
-  static PStatCollector _app_pcollector;
+  //static PStatCollector _app_pcollector;
   static PStatCollector _render_frame_pcollector;
   static PStatCollector _do_frame_pcollector;
   static PStatCollector _yield_pcollector;

+ 20 - 17
panda/src/display/graphicsStateGuardian.cxx

@@ -63,9 +63,9 @@
 
 using std::string;
 
-PStatCollector GraphicsStateGuardian::_vertex_buffer_switch_pcollector("Buffer switch:Vertex");
-PStatCollector GraphicsStateGuardian::_index_buffer_switch_pcollector("Buffer switch:Index");
-PStatCollector GraphicsStateGuardian::_shader_buffer_switch_pcollector("Buffer switch:Shader");
+//PStatCollector GraphicsStateGuardian::_vertex_buffer_switch_pcollector("Buffer switch:Vertex");
+//PStatCollector GraphicsStateGuardian::_index_buffer_switch_pcollector("Buffer switch:Index");
+//PStatCollector GraphicsStateGuardian::_shader_buffer_switch_pcollector("Buffer switch:Shader");
 PStatCollector GraphicsStateGuardian::_load_vertex_buffer_pcollector("Draw:Transfer data:Vertex buffer");
 PStatCollector GraphicsStateGuardian::_load_index_buffer_pcollector("Draw:Transfer data:Index buffer");
 PStatCollector GraphicsStateGuardian::_load_shader_buffer_pcollector("Draw:Transfer data:Shader buffer");
@@ -2376,18 +2376,20 @@ begin_frame(Thread *current_thread) {
   int frame = ClockObject::get_global_clock()->get_frame_count();
   if (_last_query_frame < frame) {
     _last_query_frame = frame;
-    _timer_queries_pcollector.clear_level();
-
-    // Now is a good time to flush previous frame's queries.  We may not
-    // actually have all of the previous frame's results in yet, but that's
-    // okay; the GPU data is allowed to lag a few frames behind.
-    flush_timer_queries();
-
-    if (_timer_queries_active) {
-      // Issue a stop and start event for collector 0, marking the beginning
-      // of the new frame.
-      issue_timer_query(0x8000);
-      issue_timer_query(0x0000);
+    if (pstats_gpu_timing && _supports_timer_query) {
+      _timer_queries_pcollector.clear_level();
+
+      // Now is a good time to flush previous frame's queries.  We may not
+      // actually have all of the previous frame's results in yet, but that's
+      // okay; the GPU data is allowed to lag a few frames behind.
+      flush_timer_queries();
+
+      if (_timer_queries_active) {
+        // Issue a stop and start event for collector 0, marking the beginning
+        // of the new frame.
+        issue_timer_query(0x8000);
+        issue_timer_query(0x0000);
+      }
     }
   }
 #endif
@@ -3223,8 +3225,9 @@ void GraphicsStateGuardian::
 init_frame_pstats() {
   if (PStatClient::is_connected()) {
     _data_transferred_pcollector.clear_level();
-    _vertex_buffer_switch_pcollector.clear_level();
-    _index_buffer_switch_pcollector.clear_level();
+    //_vertex_buffer_switch_pcollector.clear_level();
+    //_index_buffer_switch_pcollector.clear_level();
+    //_shader_buffer_switch_pcollector.clear_level();
 
     _primitive_batches_pcollector.clear_level();
     _primitive_batches_tristrip_pcollector.clear_level();

+ 3 - 3
panda/src/display/graphicsStateGuardian.h

@@ -664,9 +664,9 @@ protected:
 
 public:
   // Statistics
-  static PStatCollector _vertex_buffer_switch_pcollector;
-  static PStatCollector _index_buffer_switch_pcollector;
-  static PStatCollector _shader_buffer_switch_pcollector;
+  //static PStatCollector _vertex_buffer_switch_pcollector;
+  //static PStatCollector _index_buffer_switch_pcollector;
+  //static PStatCollector _shader_buffer_switch_pcollector;
   static PStatCollector _load_vertex_buffer_pcollector;
   static PStatCollector _load_index_buffer_pcollector;
   static PStatCollector _load_shader_buffer_pcollector;

+ 1 - 0
panda/src/pgraph/cullTraverser.I

@@ -198,6 +198,7 @@ INLINE void CullTraverser::
 flush_level() {
   _nodes_pcollector.flush_level();
   _geom_nodes_pcollector.flush_level();
+  _pgui_nodes_pcollector.flush_level();
   _geoms_pcollector.flush_level();
   _geoms_occluded_pcollector.flush_level();
 }

+ 1 - 0
panda/src/pgraph/cullTraverser.cxx

@@ -38,6 +38,7 @@
 
 PStatCollector CullTraverser::_nodes_pcollector("Nodes");
 PStatCollector CullTraverser::_geom_nodes_pcollector("Nodes:GeomNodes");
+PStatCollector CullTraverser::_pgui_nodes_pcollector("Nodes:GUI");
 PStatCollector CullTraverser::_geoms_pcollector("Geoms");
 PStatCollector CullTraverser::_geoms_occluded_pcollector("Geoms:Occluded");
 

+ 1 - 0
panda/src/pgraph/cullTraverser.h

@@ -108,6 +108,7 @@ public:
   // Statistics
   static PStatCollector _nodes_pcollector;
   static PStatCollector _geom_nodes_pcollector;
+  static PStatCollector _pgui_nodes_pcollector;
   static PStatCollector _geoms_pcollector;
   static PStatCollector _geoms_occluded_pcollector;
 

+ 2 - 0
panda/src/pgui/pgItem.cxx

@@ -195,6 +195,8 @@ draw_mask_changed() {
  */
 bool PGItem::
 cull_callback(CullTraverser *trav, CullTraverserData &data) {
+  CullTraverser::_pgui_nodes_pcollector.add_level(1);
+
   // We try not to hold the lock for longer than necessary.
   PT(PandaNode) state_def_root;
   bool has_frame;

+ 2 - 2
panda/src/pstatclient/pStatProperties.cxx

@@ -109,7 +109,7 @@ static TimeCollectorProperties time_properties[] = {
   { 1, "App:Collisions:Reset",             { 0.0, 0.0, 0.5 } },
   { 0, "App:Data graph",                   { 0.5, 0.8, 0.4 } },
   { 1, "App:Show code",                    { 0.8, 0.2, 1.0 } },
-  { 0, "App:Show code:General",            { 0.4, 0.3, 0.9 } },
+  //{ 0, "App:Show code:General",            { 0.4, 0.3, 0.9 } },
   { 0, "App:Show code:Nametags",           { 0.8, 0.8, 1.0 } },
   { 0, "App:Show code:Nametags:2d",        { 0.0, 0.0, 0.5 } },
   { 0, "App:Show code:Nametags:2d:Contents", { 0.0, 0.5, 0.0 } },
@@ -217,7 +217,7 @@ static LevelCollectorProperties level_properties[] = {
   { 1, "RenderStates:Cached",              { 1.0, 0.0, 0.2 } },
   { 1, "RenderStates:Unused",              { 0.2, 0.2, 0.2 } },
   { 1, "PipelineCyclers",                  { 0.5, 0.5, 1.0 },  "", 50000 },
-  { 1, "Dirty PipelineCyclers",            { 0.2, 0.2, 0.2 },  "", 5000 },
+  { 1, "PipelineCyclers:Dirty",            { 0.2, 0.2, 0.2 },  "", 5000 },
   { 1, "Collision Volumes",                { 1.0, 0.8, 0.5 },  "", 500 },
   { 1, "Collision Tests",                  { 0.5, 0.8, 1.0 },  "", 100 },
   { 1, "Command latency",                  { 0.8, 0.2, 0.0 },  "ms", 10, 1.0 / 1000.0 },