mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
Adding vertex counters to PStats.
This commit is contained in:
parent
feee067952
commit
695f225b10
@ -19,6 +19,11 @@ PStatCollector GraphicsStateGuardian::_total_texusage_pcollector("Texture usage"
|
||||
PStatCollector GraphicsStateGuardian::_active_texusage_pcollector("Texture usage:Active");
|
||||
PStatCollector GraphicsStateGuardian::_total_texmem_pcollector("Texture memory");
|
||||
PStatCollector GraphicsStateGuardian::_used_texmem_pcollector("Texture memory:In use");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_pcollector("Vertices");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_tristrip_pcollector("Vertices:Triangle strips");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_trifan_pcollector("Vertices:Triangle fans");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_tri_pcollector("Vertices:Triangles");
|
||||
PStatCollector GraphicsStateGuardian::_vertices_other_pcollector("Vertices:Other");
|
||||
#endif
|
||||
|
||||
TypeHandle GraphicsStateGuardian::_type_handle;
|
||||
|
@ -175,6 +175,11 @@ protected:
|
||||
static PStatCollector _active_texusage_pcollector;
|
||||
static PStatCollector _total_texmem_pcollector;
|
||||
static PStatCollector _used_texmem_pcollector;
|
||||
static PStatCollector _vertices_pcollector;
|
||||
static PStatCollector _vertices_tristrip_pcollector;
|
||||
static PStatCollector _vertices_trifan_pcollector;
|
||||
static PStatCollector _vertices_tri_pcollector;
|
||||
static PStatCollector _vertices_other_pcollector;
|
||||
|
||||
private:
|
||||
typedef set<TextureContext *> Textures;
|
||||
|
@ -485,6 +485,12 @@ render_frame(const AllAttributesWrapper &initial_state) {
|
||||
NodeAttributes state;
|
||||
state.set_attribute(TextureTransition::get_class_type(), new TextureAttribute);
|
||||
set_state(state, false);
|
||||
|
||||
// Also clear out our vertex counters while we're here.
|
||||
_vertices_tristrip_pcollector.set_level(0);
|
||||
_vertices_trifan_pcollector.set_level(0);
|
||||
_vertices_tri_pcollector.set_level(0);
|
||||
_vertices_other_pcollector.set_level(0);
|
||||
#endif
|
||||
|
||||
if (_clear_buffer_type != 0) {
|
||||
@ -717,6 +723,7 @@ draw_point(const GeomPoint *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_point()" << endl;
|
||||
#endif
|
||||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
call_glPointSize(geom->get_size());
|
||||
|
||||
@ -775,6 +782,7 @@ draw_line(const GeomLine* geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_line()" << endl;
|
||||
#endif
|
||||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
call_glLineWidth(geom->get_width());
|
||||
|
||||
@ -835,6 +843,7 @@ draw_linestrip(const GeomLinestrip* geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_linestrip()" << endl;
|
||||
#endif
|
||||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
call_glLineWidth(geom->get_width());
|
||||
|
||||
@ -945,6 +954,7 @@ draw_sprite(const GeomSprite *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_sprite()" << endl;
|
||||
#endif
|
||||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
Texture *tex = geom->get_texture();
|
||||
nassertv(tex != (Texture *) NULL);
|
||||
@ -1219,6 +1229,7 @@ draw_polygon(const GeomPolygon *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_polygon()" << endl;
|
||||
#endif
|
||||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
const int *plen = geom->get_lengths();
|
||||
@ -1291,6 +1302,7 @@ draw_tri(const GeomTri *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_tri()" << endl;
|
||||
#endif
|
||||
_vertices_tri_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
Geom::VertexIterator vi = geom->make_vertex_iterator();
|
||||
@ -1358,6 +1370,7 @@ draw_quad(const GeomQuad *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_quad()" << endl;
|
||||
#endif
|
||||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
Geom::VertexIterator vi = geom->make_vertex_iterator();
|
||||
@ -1425,6 +1438,7 @@ draw_tristrip(const GeomTristrip *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_tristrip()" << endl;
|
||||
#endif
|
||||
_vertices_tristrip_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
const int *plen = geom->get_lengths();
|
||||
@ -1514,6 +1528,7 @@ draw_trifan(const GeomTrifan *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_trifan()" << endl;
|
||||
#endif
|
||||
_vertices_trifan_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
const int *plen = geom->get_lengths();
|
||||
@ -1604,6 +1619,7 @@ draw_sphere(const GeomSphere *geom) {
|
||||
#ifdef GSG_VERBOSE
|
||||
glgsg_cat.debug() << "draw_sphere()" << endl;
|
||||
#endif
|
||||
_vertices_other_pcollector.add_level(geom->get_num_vertices());
|
||||
|
||||
int nprims = geom->get_num_prims();
|
||||
Geom::VertexIterator vi = geom->make_vertex_iterator();
|
||||
|
@ -306,6 +306,26 @@ get_texcoords(PTA_TexCoordf &texcoords, GeomBindType &bind,
|
||||
tindex = _tindex;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::get_num_vertices
|
||||
// Access: Public
|
||||
// Description: Returns the number of vertices required by all all
|
||||
// the prims in the Geom.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int Geom::
|
||||
get_num_vertices() const {
|
||||
if (!uses_components()) {
|
||||
return get_num_vertices_per_prim() * get_num_prims();
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
for (int i = 0; i < get_num_prims(); i++) {
|
||||
total += _primlengths[i];
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Geom::explode
|
||||
// Access: Public, Virtual
|
||||
|
@ -182,6 +182,8 @@ public:
|
||||
virtual int get_num_more_vertices_than_components() const=0;
|
||||
virtual bool uses_components() const=0;
|
||||
|
||||
int get_num_vertices() const;
|
||||
|
||||
// Returns the length of the indicated primitive. Often this is the
|
||||
// same for all primitives in the Geom. However, geoms which use
|
||||
// the lengths array will redefine this appropriately.
|
||||
|
@ -64,10 +64,15 @@ static TimeCollectorProperties time_properties[] = {
|
||||
};
|
||||
|
||||
static LevelCollectorProperties level_properties[] = {
|
||||
{ "Texture usage", { 1.0, 0.0, 0.0 }, "MB", 8.0 },
|
||||
{ "Texture usage", { 1.0, 0.0, 0.0 }, "MB", 12.0 },
|
||||
{ "Texture usage:Active", { 1.0, 1.0, 0.0 } },
|
||||
{ "Texture memory", { 0.0, 0.0, 1.0 }, "MB", 8.0 },
|
||||
{ "Texture memory", { 0.0, 0.0, 1.0 }, "MB", 12.0 },
|
||||
{ "Texture memory:In use", { 0.0, 1.0, 1.0 } },
|
||||
{ "Vertices", { 0.5, 0.2, 0.0 }, "", 10000.0 },
|
||||
{ "Vertices:Other", { 0.2, 0.2, 0.2 } },
|
||||
{ "Vertices:Triangles", { 0.8, 0.8, 0.8 } },
|
||||
{ "Vertices:Triangle fans", { 0.8, 0.5, 0.2 } },
|
||||
{ "Vertices:Triangle strips", { 0.2, 0.5, 0.8 } },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
@ -66,25 +66,45 @@ mark_dead() {
|
||||
void GtkStatsStripWindow::
|
||||
new_collector() {
|
||||
const PStatClientData *client_data = _monitor->get_client_data();
|
||||
_levels_menu->items().clear();
|
||||
|
||||
// Determine the set of collectors that display level data. We'll
|
||||
// want to put these on the "Levels" pull-down menu.
|
||||
|
||||
set<int> levels;
|
||||
|
||||
int num_collectors = client_data->get_num_collectors();
|
||||
for (int i = 0; i < num_collectors; i++) {
|
||||
if (client_data->has_collector(i) &&
|
||||
client_data->get_collector_has_level(i)) {
|
||||
// We only put top-level entries on the menu. Thus, walk up
|
||||
// from this collector to its top level (the one below Frame).
|
||||
int collector_index = i;
|
||||
const PStatCollectorDef &def =
|
||||
client_data->get_collector_def(i);
|
||||
client_data->get_collector_def(collector_index);
|
||||
int parent_index = def._parent_index;
|
||||
|
||||
// Normally, we only put top-level entries on the menu. The
|
||||
// lower entries can take care of themselves.
|
||||
if (def._parent_index == 0) {
|
||||
_levels_menu->items().push_back
|
||||
(MenuElem(client_data->get_collector_name(i),
|
||||
bind(slot(this, &GtkStatsStripWindow::menu_show_levels), i)));
|
||||
while (parent_index != 0) {
|
||||
collector_index = parent_index;
|
||||
const PStatCollectorDef &def =
|
||||
client_data->get_collector_def(collector_index);
|
||||
parent_index = def._parent_index;
|
||||
}
|
||||
|
||||
levels.insert(collector_index);
|
||||
}
|
||||
}
|
||||
|
||||
// Now put the collectors we found on the menu.
|
||||
_levels_menu->items().clear();
|
||||
set<int>::const_iterator li;
|
||||
for (li = levels.begin(); li != levels.end(); ++li) {
|
||||
int collector_index = (*li);
|
||||
_levels_menu->items().push_back
|
||||
(MenuElem(client_data->get_collector_name(collector_index),
|
||||
bind(slot(this, &GtkStatsStripWindow::menu_show_levels), collector_index)));
|
||||
}
|
||||
|
||||
// Also re-set-up the scale menu, in case the properties have changed.
|
||||
setup_scale_menu();
|
||||
}
|
||||
|
||||
|
@ -180,12 +180,9 @@ public:
|
||||
_client_data(client_data) {
|
||||
}
|
||||
bool operator () (int a, int b) const {
|
||||
// By casting the sort numbers to unsigned ints, we cheat and make
|
||||
// -1 appear to be a very large positive integer, thus placing
|
||||
// collectors with a -1 sort value at the very end.
|
||||
return
|
||||
(unsigned int)_client_data->get_collector_def(a)._sort <
|
||||
(unsigned int)_client_data->get_collector_def(b)._sort;
|
||||
_client_data->get_collector_def(a)._sort >
|
||||
_client_data->get_collector_def(b)._sort;
|
||||
}
|
||||
const PStatClientData *_client_data;
|
||||
};
|
||||
|
@ -258,12 +258,9 @@ public:
|
||||
_client_data(client_data) {
|
||||
}
|
||||
bool operator () (int a, int b) const {
|
||||
// By casting the sort numbers to unsigned ints, we cheat and make
|
||||
// -1 appear to be a very large positive integer, thus placing
|
||||
// collectors with a -1 sort value at the very end.
|
||||
return
|
||||
(unsigned int)_client_data->get_collector_def(a)._sort >
|
||||
(unsigned int)_client_data->get_collector_def(b)._sort;
|
||||
_client_data->get_collector_def(a)._sort >
|
||||
_client_data->get_collector_def(b)._sort;
|
||||
}
|
||||
const PStatClientData *_client_data;
|
||||
};
|
||||
|
@ -432,12 +432,9 @@ public:
|
||||
_client_data(client_data) {
|
||||
}
|
||||
bool operator () (int a, int b) const {
|
||||
// By casting the sort numbers to unsigned ints, we cheat and make
|
||||
// -1 appear to be a very large positive integer, thus placing
|
||||
// collectors with a -1 sort value at the very end.
|
||||
return
|
||||
(unsigned int)_client_data->get_collector_def(a)._sort >
|
||||
(unsigned int)_client_data->get_collector_def(b)._sort;
|
||||
_client_data->get_collector_def(a)._sort >
|
||||
_client_data->get_collector_def(b)._sort;
|
||||
}
|
||||
const PStatClientData *_client_data;
|
||||
};
|
||||
|
@ -39,12 +39,9 @@ public:
|
||||
_client_data(client_data) {
|
||||
}
|
||||
bool operator () (const PStatViewLevel *a, const PStatViewLevel *b) const {
|
||||
// By casting the sort numbers to unsigned ints, we cheat and make
|
||||
// -1 appear to be a very large positive integer, thus placing
|
||||
// collectors with a -1 sort value at the very end.
|
||||
return
|
||||
(unsigned int)_client_data->get_collector_def(a->get_collector())._sort <
|
||||
(unsigned int)_client_data->get_collector_def(b->get_collector())._sort;
|
||||
_client_data->get_collector_def(a->get_collector())._sort >
|
||||
_client_data->get_collector_def(b->get_collector())._sort;
|
||||
}
|
||||
const PStatClientData *_client_data;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user