add proper tracking of display-list vertices to pstats

This commit is contained in:
David Rose 2001-06-13 15:57:19 +00:00
parent 06a8f3e620
commit b976aa9ac7
6 changed files with 44 additions and 1 deletions

View File

@ -27,4 +27,7 @@ GLGeomNodeContext(GeomNode *node) :
GeomNodeContext(node)
{
_index = 0;
#ifdef DO_PSTATS
_num_verts = 0;
#endif
}

View File

@ -50,6 +50,12 @@ public:
typedef pvector<PT(dDrawable) > 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;

View File

@ -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++) {

View File

@ -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;
};

View File

@ -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;
}
////////////////////////////////////////////////////////////////////

View File

@ -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 },