From b976aa9ac7173d2aea6b06bbf81719d96117ffe7 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 13 Jun 2001 15:57:19 +0000 Subject: [PATCH] add proper tracking of display-list vertices to pstats --- panda/src/glgsg/glGeomNodeContext.I | 3 +++ panda/src/glgsg/glGeomNodeContext.h | 6 +++++ panda/src/glgsg/glGraphicsStateGuardian.cxx | 30 +++++++++++++++++++++ panda/src/glgsg/glGraphicsStateGuardian.h | 2 ++ panda/src/pstatclient/pStatClient.cxx | 3 ++- panda/src/pstatclient/pStatProperties.cxx | 1 + 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/panda/src/glgsg/glGeomNodeContext.I b/panda/src/glgsg/glGeomNodeContext.I index 1390a99cac..16bc362d76 100644 --- a/panda/src/glgsg/glGeomNodeContext.I +++ b/panda/src/glgsg/glGeomNodeContext.I @@ -27,4 +27,7 @@ GLGeomNodeContext(GeomNode *node) : GeomNodeContext(node) { _index = 0; +#ifdef DO_PSTATS + _num_verts = 0; +#endif } diff --git a/panda/src/glgsg/glGeomNodeContext.h b/panda/src/glgsg/glGeomNodeContext.h index fcbf2a6e38..ae07948817 100644 --- a/panda/src/glgsg/glGeomNodeContext.h +++ b/panda/src/glgsg/glGeomNodeContext.h @@ -50,6 +50,12 @@ public: typedef pvector Geoms; Geoms _dynamic_geoms; +#ifdef DO_PSTATS + // The number of vertices represented by the display list. This is + // strictly for the benefit of PStats reporting. + int _num_verts; +#endif + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/glgsg/glGraphicsStateGuardian.cxx b/panda/src/glgsg/glGraphicsStateGuardian.cxx index ca54f1033d..67155957fa 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.cxx +++ b/panda/src/glgsg/glGraphicsStateGuardian.cxx @@ -106,6 +106,10 @@ TypeHandle GLGraphicsStateGuardian::_type_handle; +#ifndef CPPPARSER +PStatCollector GLGraphicsStateGuardian::_vertices_display_list_pcollector("Vertices:Display lists"); +#endif + static void issue_vertex_gl(const Geom *geom, Geom::VertexIterator &viterator) { const Vertexf &vertex = geom->get_next_vertex(viterator); @@ -492,6 +496,7 @@ render_frame(const AllAttributesWrapper &initial_state) { // For Pstats to track our current texture memory usage, we have to // reset the set of current textures each frame. init_frame_pstats(); + _vertices_display_list_pcollector.clear_level(); // But since we don't get sent a new issue_texture() unless our // texture state has changed, we have to be sure to clear the @@ -1815,6 +1820,17 @@ prepare_geom_node(GeomNode *node) { _normals_enabled = true; _texturing_enabled = true; +#ifdef DO_PSTATS + // Count up the number of vertices we're about to render, by + // checking the PStats vertex counters now, and at the end. This is + // kind of hacky, but this is debug code. + float num_verts_before = + _vertices_tristrip_pcollector.get_level() + + _vertices_trifan_pcollector.get_level() + + _vertices_tri_pcollector.get_level() + + _vertices_other_pcollector.get_level(); +#endif + // Now define the display list. glNewList(ggnc->_index, GL_COMPILE); for (i = 0; i < num_geoms; i++) { @@ -1831,6 +1847,16 @@ prepare_geom_node(GeomNode *node) { } glEndList(); +#ifdef DO_PSTATS + float num_verts_after = + _vertices_tristrip_pcollector.get_level() + + _vertices_trifan_pcollector.get_level() + + _vertices_tri_pcollector.get_level() + + _vertices_other_pcollector.get_level(); + float num_verts = num_verts_after - num_verts_before; + ggnc->_num_verts = (int)(num_verts + 0.5); +#endif + _normals_enabled = old_normals_enabled; _texturing_enabled = old_texturing_enabled; @@ -1866,6 +1892,10 @@ draw_geom_node(GeomNode *node, GeomNodeContext *gnc) { GLGeomNodeContext *ggnc = DCAST(GLGeomNodeContext, gnc); glCallList(ggnc->_index); +#ifdef DO_PSTATS + _vertices_display_list_pcollector.add_level(ggnc->_num_verts); +#endif + // Also draw all the dynamic Geoms. int num_geoms = ggnc->_dynamic_geoms.size(); for (int i = 0; i < num_geoms; i++) { diff --git a/panda/src/glgsg/glGraphicsStateGuardian.h b/panda/src/glgsg/glGraphicsStateGuardian.h index e39e23f0f2..86f281b8cd 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.h +++ b/panda/src/glgsg/glGraphicsStateGuardian.h @@ -368,6 +368,8 @@ public: virtual TypeHandle get_type(void) const; virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + static PStatCollector _vertices_display_list_pcollector; + private: static TypeHandle _type_handle; }; diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index ccd8a1ef27..1c18d2cc5f 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -635,7 +635,8 @@ add_level(int collector_index, int thread_index, float increment) { //////////////////////////////////////////////////////////////////// float PStatClient:: get_level(int collector_index, int thread_index) const { - return _collectors[collector_index]._per_thread[thread_index]._level; + return _collectors[collector_index]._per_thread[thread_index]._level / + _collectors[collector_index]._def->_factor; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 49779f8e13..b812410751 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -146,6 +146,7 @@ static LevelCollectorProperties level_properties[] = { { 1, "Vertices:Triangles", { 0.8, 0.8, 0.8 } }, { 1, "Vertices:Triangle fans", { 0.8, 0.5, 0.2 } }, { 1, "Vertices:Triangle strips", { 0.2, 0.5, 0.8 } }, + { 1, "Vertices:Display lists", { 0.8, 0.5, 1.0 } }, { 1, "Nodes", { 0.4, 0.2, 0.8 }, "", 500.0 }, { 1, "Nodes:GeomNodes", { 0.8, 0.2, 0.0 } }, { 1, "State changes", { 1.0, 0.5, 0.2 }, "", 500.0 },