fix opt4 do-pstats handling

This commit is contained in:
cxgeorge 2002-02-06 21:46:18 +00:00
parent 11816b3438
commit 02bffb403b
5 changed files with 57 additions and 21 deletions

View File

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

View File

@ -50,11 +50,9 @@ 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
DO_PSTATS_STUFF(int _num_verts;)
public:
static TypeHandle get_class_type() {

View File

@ -66,11 +66,14 @@
#include "pointShapeTransition.h"
#include "polygonOffsetTransition.h"
#include "clockObject.h"
#include "pStatTimer.h"
#include "string_utils.h"
#include "dcast.h"
#include "pvector.h"
#ifdef DO_PSTATS
#include "pStatTimer.h"
#endif
#include <algorithm>
#if 0
@ -83,7 +86,7 @@
TypeHandle GLGraphicsStateGuardian::_type_handle;
#ifndef CPPPARSER
#if !defined(CPPPARSER) && defined(DO_PSTATS)
PStatCollector GLGraphicsStateGuardian::_vertices_display_list_pcollector("Vertices:Display lists");
#endif
@ -343,7 +346,7 @@ reset() {
////////////////////////////////////////////////////////////////////
void GLGraphicsStateGuardian::
clear(const RenderBuffer &buffer) {
PStatTimer timer(_win->_clear_pcollector);
DO_PSTATS_STUFF(PStatTimer timer(_win->_clear_pcollector);)
// activate();
nassertv(buffer._gsg == this);
@ -720,8 +723,10 @@ draw_point(GeomPoint *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_point()" << endl;
#endif
#ifdef DO_PSTATS
PStatTimer timer(_draw_primitive_pcollector);
_vertices_other_pcollector.add_level(geom->get_num_vertices());
#endif
call_glPointSize(geom->get_size());
issue_scene_graph_color();
@ -781,8 +786,10 @@ draw_line(GeomLine *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_line()" << endl;
#endif
#ifdef DO_PSTATS
PStatTimer timer(_draw_primitive_pcollector);
_vertices_other_pcollector.add_level(geom->get_num_vertices());
#endif
call_glLineWidth(geom->get_width());
issue_scene_graph_color();
@ -844,11 +851,13 @@ draw_linestrip(GeomLinestrip *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_linestrip()" << endl;
#endif
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_other_pcollector.add_level(geom->get_num_vertices());
#endif
call_glLineWidth(geom->get_width());
issue_scene_graph_color();
@ -914,7 +923,7 @@ draw_linestrip(GeomLinestrip *geom, GeomContext *) {
glEnd();
}
report_errors();
_draw_primitive_pcollector.stop();
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
}
////////////////////////////////////////////////////////////////////
@ -968,10 +977,12 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
return;
}
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_other_pcollector.add_level(geom->get_num_vertices());
#endif
Geom::VertexIterator vi = geom->make_vertex_iterator();
Geom::ColorIterator ci = geom->make_color_iterator();
@ -1200,7 +1211,7 @@ draw_sprite(GeomSprite *geom, GeomContext *) {
glEnable(GL_DITHER);
report_errors();
_draw_primitive_pcollector.stop();
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
}
@ -1216,10 +1227,13 @@ draw_polygon(GeomPolygon *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_polygon()" << endl;
#endif
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_other_pcollector.add_level(geom->get_num_vertices());
#endif
issue_scene_graph_color();
@ -1280,7 +1294,7 @@ draw_polygon(GeomPolygon *geom, GeomContext *) {
glEnd();
}
report_errors();
_draw_primitive_pcollector.stop();
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
}
////////////////////////////////////////////////////////////////////
@ -1295,10 +1309,13 @@ draw_tri(GeomTri *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_tri()" << endl;
#endif
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_tri_pcollector.add_level(geom->get_num_vertices());
#endif
issue_scene_graph_color();
@ -1354,7 +1371,9 @@ draw_tri(GeomTri *geom, GeomContext *) {
glEnd();
report_errors();
#ifdef DO_PSTATS
_draw_primitive_pcollector.stop();
#endif
}
////////////////////////////////////////////////////////////////////
@ -1369,10 +1388,13 @@ draw_quad(GeomQuad *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_quad()" << endl;
#endif
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_other_pcollector.add_level(geom->get_num_vertices());
#endif
issue_scene_graph_color();
@ -1428,7 +1450,7 @@ draw_quad(GeomQuad *geom, GeomContext *) {
glEnd();
report_errors();
_draw_primitive_pcollector.stop();
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
}
////////////////////////////////////////////////////////////////////
@ -1443,10 +1465,13 @@ draw_tristrip(GeomTristrip *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_tristrip()" << endl;
#endif
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_tristrip_pcollector.add_level(geom->get_num_vertices());
#endif
issue_scene_graph_color();
@ -1524,7 +1549,7 @@ draw_tristrip(GeomTristrip *geom, GeomContext *) {
glEnd();
}
report_errors();
_draw_primitive_pcollector.stop();
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
}
////////////////////////////////////////////////////////////////////
@ -1539,10 +1564,13 @@ draw_trifan(GeomTrifan *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_trifan()" << endl;
#endif
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_trifan_pcollector.add_level(geom->get_num_vertices());
#endif
issue_scene_graph_color();
@ -1620,7 +1648,7 @@ draw_trifan(GeomTrifan *geom, GeomContext *) {
glEnd();
}
report_errors();
_draw_primitive_pcollector.stop();
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
}
@ -1636,10 +1664,13 @@ draw_sphere(GeomSphere *geom, GeomContext *) {
#ifdef GSG_VERBOSE
glgsg_cat.debug() << "draw_sphere()" << endl;
#endif
#ifdef DO_PSTATS
// PStatTimer timer(_draw_primitive_pcollector);
// Using PStatTimer may cause a compiler crash.
_draw_primitive_pcollector.start();
_vertices_other_pcollector.add_level(geom->get_num_vertices());
#endif
issue_scene_graph_color();
@ -1707,7 +1738,7 @@ draw_sphere(GeomSphere *geom, GeomContext *) {
gluDeleteQuadric(sph);
report_errors();
_draw_primitive_pcollector.stop();
DO_PSTATS_STUFF(_draw_primitive_pcollector.stop());
}
////////////////////////////////////////////////////////////////////

View File

@ -379,6 +379,12 @@ private:
static TypeHandle _type_handle;
};
#ifdef DO_PSTATS
#define DO_PSTATS_STUFF(XX) XX;
#else
#define DO_PSTATS_STUFF(XX)
#endif
#include "glGraphicsStateGuardian.I"
#endif

View File

@ -25,7 +25,6 @@
#include <errno.h>
#include <time.h>
#include <mmsystem.h>
#include <pStatTimer.h>
#include <ddraw.h>
#include <tchar.h>
#include <map>
@ -34,6 +33,10 @@
#include <string.h>
#include "Win32Defs.h"
#ifdef DO_PSTATS
#include <pStatTimer.h>
#endif
#define WGL_WGLEXT_PROTOTYPES
#include "wglext.h"
@ -981,7 +984,7 @@ void wglGraphicsWindow::setup_colormap(void) {
////////////////////////////////////////////////////////////////////
void wglGraphicsWindow::end_frame(void) {
if (gl_show_fps_meter) {
PStatTimer timer(_show_fps_pcollector);
DO_PSTATS_STUFF(PStatTimer timer(_show_fps_pcollector);)
DWORD now = timeGetTime(); // this is win32 fn
float time_delta = (now - _start_time) * 0.001f;
@ -1043,7 +1046,7 @@ void wglGraphicsWindow::end_frame(void) {
}
{
PStatTimer timer(_swap_pcollector);
DO_PSTATS_STUFF(PStatTimer timer(_swap_pcollector);)
if(_is_synced)
glFinish();
else SwapBuffers(_hdc);
@ -1347,7 +1350,7 @@ void wglGraphicsWindow::make_current(void) {
return; // we're only allow unmake_current() to set this to NULL
}
PStatTimer timer(_make_current_pcollector);
DO_PSTATS_STUFF(PStatTimer timer(_make_current_pcollector);)
HGLRC current_context = wglGetCurrentContext();
HDC current_dc = wglGetCurrentDC();