diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 139fc5d686..5118288f33 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -47,8 +47,8 @@ PStatCollector GraphicsStateGuardian::_total_texusage_pcollector("Texture usage" PStatCollector GraphicsStateGuardian::_active_texusage_pcollector("Texture usage:Active"); PStatCollector GraphicsStateGuardian::_total_geom_pcollector("Prepared Geoms"); PStatCollector GraphicsStateGuardian::_active_geom_pcollector("Prepared Geoms:Active"); -PStatCollector GraphicsStateGuardian::_total_buffers_pcollector("Vertex Buffers"); -PStatCollector GraphicsStateGuardian::_active_buffers_pcollector("Vertex Buffers:Active"); +PStatCollector GraphicsStateGuardian::_total_buffers_pcollector("Vertex buffers"); +PStatCollector GraphicsStateGuardian::_active_buffers_pcollector("Vertex buffers:Active"); PStatCollector GraphicsStateGuardian::_total_geom_node_pcollector("Prepared GeomNodes"); PStatCollector GraphicsStateGuardian::_active_geom_node_pcollector("Prepared GeomNodes:Active"); PStatCollector GraphicsStateGuardian::_total_texmem_pcollector("Texture memory"); @@ -1443,6 +1443,7 @@ init_frame_pstats() { if (PStatClient::is_connected()) { _current_textures.clear(); _current_geoms.clear(); + _current_datas.clear(); _active_texusage_pcollector.clear_level(); _active_geom_pcollector.clear_level(); _active_geom_node_pcollector.clear_level(); @@ -1506,11 +1507,13 @@ add_to_geom_record(GeomContext *gc) { //////////////////////////////////////////////////////////////////// void GraphicsStateGuardian:: add_to_data_record(DataContext *dc) { - if (PStatClient::is_connected()) { - if (dc != (DataContext *)NULL && _current_datas.insert(dc).second) { - int delta = dc->get_data()->get_num_bytes() - dc->get_num_bytes(); - _total_buffers_pcollector.add_level(delta); - _active_buffers_pcollector.add_level(dc->get_data()->get_num_bytes()); + if (dc != (DataContext *)NULL) { + int delta = dc->get_data()->get_num_bytes() - dc->get_num_bytes(); + _total_buffers_pcollector.add_level(delta); + if (PStatClient::is_connected()) { + if (_current_datas.insert(dc).second) { + _active_buffers_pcollector.add_level(dc->get_data()->get_num_bytes()); + } } } } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 3ba84388a6..55801194b8 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -2357,12 +2357,14 @@ prepare_data(qpGeomVertexArrayData *data) { CLP(DataContext) *gdc = new CLP(DataContext)(data); _glGenBuffers(1, &gdc->_index); - add_to_data_record(gdc); + /* _glBindBuffer(GL_ARRAY_BUFFER, gdc->_index); _glBufferData(GL_ARRAY_BUFFER, gdc->get_data()->get_num_bytes(), gdc->get_data()->get_data(), get_usage(gdc->get_data()->get_usage_hint())); + add_to_data_record(gdc); gdc->mark_loaded(); + */ report_my_gl_errors(); return gdc; @@ -2383,9 +2385,9 @@ apply_data(DataContext *dc) { CLP(DataContext) *gdc = DCAST(CLP(DataContext), dc); - add_to_data_record(gdc); _glBindBuffer(GL_ARRAY_BUFFER, gdc->_index); + add_to_data_record(gdc); if (gdc->was_modified()) { if (GLCAT.is_debug()) { GLCAT.debug() diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 3a7f9fa720..689da0e6f2 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -24,7 +24,7 @@ #include "mutexHolder.h" PStatCollector PreparedGraphicsObjects::_total_texusage_pcollector("Texture usage"); -PStatCollector PreparedGraphicsObjects::_total_buffers_pcollector("Vertex Buffers"); +PStatCollector PreparedGraphicsObjects::_total_buffers_pcollector("Vertex buffers"); //////////////////////////////////////////////////////////////////// // Function: PreparedGraphicsObjects::Constructor @@ -512,7 +512,10 @@ prepare_data_now(qpGeomVertexArrayData *data, GraphicsStateGuardianBase *gsg) { bool prepared = _prepared_datas.insert(dc).second; nassertr(prepared, dc); - _total_buffers_pcollector.add_level(dc->get_num_bytes()); + // The size has already been counted by + // GraphicsStateGuardian::add_to_data_record(); we don't need to + // count it again here. + //_total_buffers_pcollector.add_level(dc->get_num_bytes()); } return dc; diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index f1f1d859a5..50062a71a7 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -551,10 +551,8 @@ stop(int collector_index, int thread_index, float as_of) { //////////////////////////////////////////////////////////////////// void PStatClient:: clear_level(int collector_index, int thread_index) { - if (_collectors[collector_index].is_active()) { - _collectors[collector_index]._per_thread[thread_index]._has_level = false; - _collectors[collector_index]._per_thread[thread_index]._level = 0.0; - } + _collectors[collector_index]._per_thread[thread_index]._has_level = false; + _collectors[collector_index]._per_thread[thread_index]._level = 0.0; } //////////////////////////////////////////////////////////////////// @@ -568,11 +566,13 @@ clear_level(int collector_index, int thread_index) { //////////////////////////////////////////////////////////////////// void PStatClient:: set_level(int collector_index, int thread_index, float level) { - if (client_is_connected() && _collectors[collector_index].is_active()) { - level *= get_collector_def(collector_index)->_factor; - _collectors[collector_index]._per_thread[thread_index]._has_level = true; - _collectors[collector_index]._per_thread[thread_index]._level = level; - } + // We don't want to condition this on whether the client is already + // connected or the collector is already active, since we might + // connect the client later, and we will want to have an accurate + // value at that time. + level *= get_collector_def(collector_index)->_factor; + _collectors[collector_index]._per_thread[thread_index]._has_level = true; + _collectors[collector_index]._per_thread[thread_index]._level = level; } //////////////////////////////////////////////////////////////////// @@ -588,11 +588,9 @@ set_level(int collector_index, int thread_index, float level) { //////////////////////////////////////////////////////////////////// void PStatClient:: add_level(int collector_index, int thread_index, float increment) { - if (client_is_connected() && _collectors[collector_index].is_active()) { - increment *= get_collector_def(collector_index)->_factor; - _collectors[collector_index]._per_thread[thread_index]._has_level = true; - _collectors[collector_index]._per_thread[thread_index]._level += increment; - } + increment *= get_collector_def(collector_index)->_factor; + _collectors[collector_index]._per_thread[thread_index]._has_level = true; + _collectors[collector_index]._per_thread[thread_index]._level += increment; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 9279b7d180..71df9ef7e8 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -153,6 +153,8 @@ static LevelCollectorProperties level_properties[] = { { 1, "Prepared Geoms:Active", { 0.5, 1.0, 0.8 } }, { 1, "Prepared GeomNodes", { 1.0, 0.0, 0.5 }, "", 500 }, { 1, "Prepared GeomNodes:Active", { 0.5, 1.0, 0.8 } }, + { 1, "Vertex buffers:Active", { 1.0, 0.0, 0.5 } }, + { 1, "Vertex buffers", { 0.0, 0.0, 1.0 }, "MB", 12, 1048576 }, { 1, "Vertices", { 0.5, 0.2, 0.0 }, "K", 10, 1000 }, { 1, "Vertices:Other", { 0.2, 0.2, 0.2 } }, { 1, "Vertices:Triangles", { 0.8, 0.8, 0.8 } },