From c7a50a0fa7c1c071c2ea1d5f28a67ae39b169b14 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 11 May 2001 02:49:22 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/showbase/ShowBase.py | 2 +- direct/src/showbase/showBase.cxx | 9 -- direct/src/task/Task.py | 2 +- panda/src/char/character.cxx | 5 +- panda/src/collide/collisionTraverser.cxx | 9 +- panda/src/dgraph/Sources.pp | 2 +- panda/src/dgraph/dataGraphTraversal.cxx | 12 +- panda/src/display/graphicsWindow.cxx | 16 ++- panda/src/display/graphicsWindow.h | 17 ++- panda/src/dxgsg/dxGraphicsStateGuardian.cxx | 7 +- panda/src/glgsg/glGraphicsStateGuardian.cxx | 18 +-- panda/src/glxdisplay/glxGraphicsWindow.cxx | 1 + panda/src/wgldisplay/wglGraphicsWindow.cxx | 132 +++++++++----------- 13 files changed, 107 insertions(+), 125 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 040f5eb91a..7c680944c1 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -302,7 +302,7 @@ class ShowBase: # traverse the data graph. This reads all the control # inputs (from the mouse and keyboard, for instance) and also # directly acts upon them (for instance, to move the avatar). - directTraverseDataGraph(self.dataRoot.node()) + traverseDataGraph(self.dataRoot.node()) return Task.cont diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index 5f98404708..80c27eaaf6 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -204,15 +204,6 @@ add_render_layer(GraphicsWindow *win, Node *render_top, Camera *camera) { } -// This function is just a simple wrapper around traverse_data_graph() -// in Panda. It's just here for the very short term, until everyone -// can build a fresh Panda with traverse_data_graph() properly -// exposed. -void -direct_traverse_data_graph(Node *node) { - traverse_data_graph(node); -} - void toggle_wireframe(NodeAttributes &initial_state) { static bool wireframe_mode = false; diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index adfa9f5fe3..d2d1f2d8cd 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -154,7 +154,7 @@ def make_loop(taskList): return cont else: task = self.taskList[self.index] - # If this is a new task, set it's start time and frame + # If this is a new task, set its start time and frame if (self.index > self.prevIndex): task.setStartTimeFrame(self.time, self.frame) self.prevIndex = self.index diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index dca2e2b4cd..389fe6713c 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -19,8 +19,9 @@ TypeHandle Character::_type_handle; -PStatCollector Character::_anim_pcollector = - PStatCollector("Animation", RGBColorf(1,0,1), 30); +#ifndef CPPPARSER +PStatCollector Character::_anim_pcollector("App:Animation", RGBColorf(1,0,1), 30); +#endif //////////////////////////////////////////////////////////////////// // Function: Character::Copy Constructor diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index fb2bd7060a..c1ac6d9906 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -16,12 +16,10 @@ #include #include #include - -#ifdef DO_PSTATS #include -PStatCollector CollisionTraverser::_collisions_pcollector = - PStatCollector("Collisions", RGBColorf(1,0.5,0), 40); +#ifndef CPPPARSER +PStatCollector CollisionTraverser::_collisions_pcollector("App:Collisions", RGBColorf(1,0.5,0), 40); #endif //////////////////////////////////////////////////////////////////// @@ -231,10 +229,7 @@ traverse(Node *root) { void CollisionTraverser:: traverse(const NodePath &root) { nassertv(root.get_graph_type() == _graph_type); - -#ifdef DO_PSTATS PStatTimer timer(_collisions_pcollector); -#endif CollisionLevelState level_state(root); prepare_colliders(level_state); diff --git a/panda/src/dgraph/Sources.pp b/panda/src/dgraph/Sources.pp index 0e04bf1186..8f96161ac2 100644 --- a/panda/src/dgraph/Sources.pp +++ b/panda/src/dgraph/Sources.pp @@ -4,7 +4,7 @@ #begin lib_target #define TARGET dgraph #define LOCAL_LIBS \ - sgraph graph putil sgattrib mathutil + pstatclient sgraph graph putil sgattrib mathutil #define SOURCES \ buttonEventDataAttribute.I buttonEventDataAttribute.cxx \ diff --git a/panda/src/dgraph/dataGraphTraversal.cxx b/panda/src/dgraph/dataGraphTraversal.cxx index 849529a4f6..0a86d2d76f 100644 --- a/panda/src/dgraph/dataGraphTraversal.cxx +++ b/panda/src/dgraph/dataGraphTraversal.cxx @@ -5,7 +5,12 @@ #include "dataGraphTraversal.h" #include "dataGraphTraverser.h" +#include +#include +#ifndef CPPPARSER +PStatCollector _dgraph_pcollector("App:Data Graph", RGBColorf(0.5,0.8,0.4), 30); +#endif //////////////////////////////////////////////////////////////////// // Function: traverse_data_graph @@ -15,6 +20,9 @@ // downwards. //////////////////////////////////////////////////////////////////// void traverse_data_graph(Node *root) { - DataGraphTraverser dgt; - dgt.traverse(root); + PStatTimer timer(_dgraph_pcollector); + { + DataGraphTraverser dgt; + dgt.traverse(root); + } } diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index ba7c8a7018..5c8ccde4fa 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -24,15 +24,13 @@ TypeHandle GraphicsWindow::WindowPipe::_type_handle; GraphicsWindow::WindowFactory *GraphicsWindow::_factory = NULL; -#ifdef DO_PSTATS -PStatCollector GraphicsWindow::_app_pcollector = - PStatCollector("App", RGBColorf(0,1,1)); -PStatCollector GraphicsWindow::_show_code_pcollector = - PStatCollector("App:Show Code", RGBColorf(0.8,0.2,1)); -PStatCollector GraphicsWindow::_swap_pcollector = - PStatCollector("Draw:Swap Buffers", RGBColorf(0.5,1,0.8)); -PStatCollector GraphicsWindow::_make_current_pcollector = - PStatCollector("Draw:Make Current", RGBColorf(1,0.6,0.3)); +#ifndef CPPPARSER +PStatCollector GraphicsWindow::_app_pcollector("App", RGBColorf(0,1,1)); +PStatCollector GraphicsWindow::_show_code_pcollector("App:Show Code", RGBColorf(0.8,0.2,1)); +PStatCollector GraphicsWindow::_swap_pcollector("Draw:Swap Buffers", RGBColorf(0.5,1,0.8)); +PStatCollector GraphicsWindow::_clear_pcollector("Draw:Clear", RGBColorf(0.5,0.7,0.7)); +PStatCollector GraphicsWindow::_show_fps_pcollector("Draw:Show fps", RGBColorf(0.5,0.8,1)); +PStatCollector GraphicsWindow::_make_current_pcollector("Draw:Make Current", RGBColorf(1,0.6,0.3)); #endif //////////////////////////////////////////////////////////////////// diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index 59891d0ad5..216a6c26af 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -24,10 +24,7 @@ #include #include #include - -#ifdef DO_PSTATS #include -#endif #include #include @@ -158,13 +155,13 @@ public: virtual void begin_frame(); virtual void end_frame(); - #ifdef DO_PSTATS - // Statistics - static PStatCollector _app_pcollector; - static PStatCollector _show_code_pcollector; - static PStatCollector _swap_pcollector; // dxgsg needs access so this is public - static PStatCollector _make_current_pcollector; - #endif + // Statistics + static PStatCollector _app_pcollector; + static PStatCollector _show_code_pcollector; + static PStatCollector _swap_pcollector; // dxgsg needs access so this is public + static PStatCollector _clear_pcollector; + static PStatCollector _show_fps_pcollector; + static PStatCollector _make_current_pcollector; protected: void make_gsg(); diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index b496eb6784..54a5d5a27d 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -66,10 +66,7 @@ #include #include #include - -#ifdef DO_PSTATS #include -#endif #define DISABLE_POLYGON_OFFSET_DECALING // currently doesnt work well enough in toontown models for us to use @@ -483,6 +480,7 @@ init_dx( LPDIRECTDRAW7 context, //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian:: clear(const RenderBuffer &buffer) { + // PStatTimer timer(_win->_clear_pcollector); activate(); @@ -726,6 +724,7 @@ render_frame(const AllAttributesWrapper &initial_state) { } if(dx_show_fps_meter) { + PStatTimer timer(_win->_show_fps_pcollector); DWORD now = timeGetTime(); // this is win32 fn @@ -5485,9 +5484,7 @@ HRESULT DXGraphicsStateGuardian::RestoreAllVideoSurfaces(void) { // Description: Repaint primary buffer from back buffer (windowed mode only) //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian::show_frame(void) { -#ifdef DO_PSTATS PStatTimer timer(_win->_swap_pcollector); // this times just the flip, so it must go here in dxgsg, instead of wdxdisplay, which would time the whole frame -#endif if(_pri==NULL) return; diff --git a/panda/src/glgsg/glGraphicsStateGuardian.cxx b/panda/src/glgsg/glGraphicsStateGuardian.cxx index 4b0b5c1df6..15a90d098b 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.cxx +++ b/panda/src/glgsg/glGraphicsStateGuardian.cxx @@ -75,6 +75,7 @@ #include #include #include +#include #include @@ -343,6 +344,7 @@ reset() { //////////////////////////////////////////////////////////////////// void GLGraphicsStateGuardian:: clear(const RenderBuffer &buffer) { + // PStatTimer timer(_win->_clear_pcollector); activate(); nassertv(buffer._gsg == this); @@ -352,11 +354,11 @@ clear(const RenderBuffer &buffer) { if (buffer_type & RenderBuffer::T_color) { call_glClearColor(_color_clear_value[0], - _color_clear_value[1], - _color_clear_value[2], - _color_clear_value[3]); + _color_clear_value[1], + _color_clear_value[2], + _color_clear_value[3]); state.set_attribute(ColorMaskTransition::get_class_type(), - new ColorMaskAttribute); + new ColorMaskAttribute); mask |= GL_COLOR_BUFFER_BIT; set_draw_buffer(buffer); @@ -370,7 +372,7 @@ clear(const RenderBuffer &buffer) { // writing to the depth buffer. if (!_depth_mask) { state.set_attribute(DepthWriteTransition::get_class_type(), - new DepthWriteAttribute); + new DepthWriteAttribute); } } @@ -381,9 +383,9 @@ clear(const RenderBuffer &buffer) { if (buffer_type & RenderBuffer::T_accum) { call_glClearAccum(_accum_clear_value[0], - _accum_clear_value[1], - _accum_clear_value[2], - _accum_clear_value[3]); + _accum_clear_value[1], + _accum_clear_value[2], + _accum_clear_value[3]); mask |= GL_ACCUM_BUFFER_BIT; } diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index d3b4fb7596..c8dc119a98 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -616,6 +616,7 @@ void glxGraphicsWindow::setup_properties(void) void glxGraphicsWindow::end_frame( void ) { if (gl_show_fps_meter) { + PStatTimer timer(_show_fps_pcollector); ClockObject* co = ClockObject::get_global_clock(); double now = co->get_real_time(); double time_delta = now - _start_time; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index f601cf0382..3752157247 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -13,10 +13,7 @@ #include #include #include - -#ifdef DO_PSTATS #include -#endif //////////////////////////////////////////////////////////////////// // Static variables @@ -868,69 +865,69 @@ void wglGraphicsWindow::setup_colormap(void) { // Description: Swaps the front and back buffers. //////////////////////////////////////////////////////////////////// void wglGraphicsWindow::end_frame(void) { - - if(gl_show_fps_meter) { - DWORD now = timeGetTime(); // this is win32 fn - - float time_delta = (now - _start_time) * 0.001f; - - if(time_delta > gl_fps_meter_update_interval) { - // didnt use global clock object, it wasnt working properly when I tried, - // its probably slower due to cache faults, and I can easily track all the - // info I need in dxgsg - DWORD num_frames = _cur_frame_count - _start_frame_count; - - _current_fps = num_frames / time_delta; - _start_time = now; - _start_frame_count = _cur_frame_count; - } - - char fps_msg[15]; - sprintf(fps_msg, "%.02f fps", _current_fps); - - // Note: we cant use simple GDI TextOut calls to draw FPS meter chars (like DX fps meter) - // because WGL doesnt support GDI in double-buffered mode. Instead we have to - // use glBitMap display lists created by wglUseFontBitmaps - - glColor3f(0.0,1.0,1.0); - - GLboolean tex_was_on = glIsEnabled(GL_TEXTURE_2D); - - if(tex_was_on) - glDisable(GL_TEXTURE_2D); - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadMatrixf(LMatrix4f::ident_mat().get_data()); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadMatrixf(LMatrix4f::ident_mat().get_data()); - - glOrtho(_props._xorg,_props._xorg+_props._xsize, - _props._yorg,_props._yorg+_props._ysize,-1.0,1.0); - - glRasterPos2f(_props._xsize-70,_props._ysize-20); // these seem to be good for default font - - // set up for a string-drawing display list call - glListBase(FONT_BITMAP_OGLDISPLAYLISTNUM); - - // draw a string using font display lists. chars index their corresponding displist name - glCallLists(strlen(fps_msg), GL_UNSIGNED_BYTE, fps_msg); - - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - if(tex_was_on) - glEnable(GL_TEXTURE_2D); - - _cur_frame_count++; // only used by fps meter right now - } - + if (gl_show_fps_meter) { + PStatTimer timer(_show_fps_pcollector); + DWORD now = timeGetTime(); // this is win32 fn + + float time_delta = (now - _start_time) * 0.001f; + + if(time_delta > gl_fps_meter_update_interval) { + // didnt use global clock object, it wasnt working properly when + // I tried, its probably slower due to cache faults, and I can + // easily track all the info I need in dxgsg + DWORD num_frames = _cur_frame_count - _start_frame_count; + + _current_fps = num_frames / time_delta; + _start_time = now; + _start_frame_count = _cur_frame_count; + } + + char fps_msg[15]; + sprintf(fps_msg, "%.02f fps", _current_fps); + + // Note: we cant use simple GDI TextOut calls to draw FPS meter + // chars (like DX fps meter) because WGL doesnt support GDI in + // double-buffered mode. Instead we have to use glBitMap display + // lists created by wglUseFontBitmaps + + glColor3f(0.0,1.0,1.0); + + GLboolean tex_was_on = glIsEnabled(GL_TEXTURE_2D); + + if(tex_was_on) + glDisable(GL_TEXTURE_2D); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadMatrixf(LMatrix4f::ident_mat().get_data()); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadMatrixf(LMatrix4f::ident_mat().get_data()); + + glOrtho(_props._xorg,_props._xorg+_props._xsize, + _props._yorg,_props._yorg+_props._ysize,-1.0,1.0); + + glRasterPos2f(_props._xsize-70,_props._ysize-20); // these seem to be good for default font + + // set up for a string-drawing display list call + glListBase(FONT_BITMAP_OGLDISPLAYLISTNUM); + + // draw a string using font display lists. chars index their + // corresponding displist name + glCallLists(strlen(fps_msg), GL_UNSIGNED_BYTE, fps_msg); + + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + if(tex_was_on) + glEnable(GL_TEXTURE_2D); + + _cur_frame_count++; // only used by fps meter right now + } + { -#ifdef DO_PSTATS PStatTimer timer(_swap_pcollector); -#endif SwapBuffers(_hdc); } GraphicsWindow::end_frame(); @@ -1079,10 +1076,8 @@ supports_update() const { // Description: //////////////////////////////////////////////////////////////////// void wglGraphicsWindow::update(void) { -#ifdef DO_PSTATS _show_code_pcollector.stop(); PStatClient::main_tick(); -#endif if (_change_mask) handle_changes(); @@ -1095,9 +1090,7 @@ void wglGraphicsWindow::update(void) { idle_wait(); else process_events(); -#ifdef DO_PSTATS _show_code_pcollector.start(); -#endif } //////////////////////////////////////////////////////////////////// @@ -1133,9 +1126,8 @@ void wglGraphicsWindow::enable_mouse_passive_motion(bool val) { // Description: //////////////////////////////////////////////////////////////////// void wglGraphicsWindow::make_current(void) { -#ifdef DO_PSTATS PStatTimer timer(_make_current_pcollector); -#endif + HGLRC current_context = wglGetCurrentContext(); HDC current_dc = wglGetCurrentDC(); if (current_context != _context || current_dc != _hdc)