diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index 51f08e19e9..159c2f2063 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/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) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 4951022af7..bc98317a01 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/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: diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index e3e7df66c8..0138eb5cf0 100644 --- a/panda/src/display/graphicsEngine.h +++ b/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; diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 797dba0fcd..322d77d1cd 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/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(); + 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(); + // 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 (_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(); diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index b0f9a323dc..42702d1ed3 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/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; diff --git a/panda/src/pgraph/cullTraverser.I b/panda/src/pgraph/cullTraverser.I index 7b243bc7c7..8af8c11c9e 100644 --- a/panda/src/pgraph/cullTraverser.I +++ b/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(); } diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index 1183707240..aa1ea8eaa2 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/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"); diff --git a/panda/src/pgraph/cullTraverser.h b/panda/src/pgraph/cullTraverser.h index a243a165cc..77856351b8 100644 --- a/panda/src/pgraph/cullTraverser.h +++ b/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; diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index 8229f434dc..8c410814ed 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/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; diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 7f4aa84d40..30110fec69 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/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 },