Browse Source

no pstats for opt4

cxgeorge 25 years ago
parent
commit
744b9ac456

+ 4 - 1
panda/metalibs/panda/Sources.pp

@@ -9,7 +9,7 @@
 #define USE_NET yes
 #define USE_NET yes
 
 
 #define COMPONENT_LIBS \
 #define COMPONENT_LIBS \
-    pvrpn pstatclient grutil chan chancfg \
+    pvrpn grutil chan chancfg $[if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]], pstatclient] \
     char chat collide cull device \
     char chat collide cull device \
     dgraph display gobj graph gsgbase \
     dgraph display gobj graph gsgbase \
     gsgmisc light linmath mathutil net \
     gsgmisc light linmath mathutil net \
@@ -18,6 +18,9 @@
     switchnode text tform tiff lerp loader putil effects \
     switchnode text tform tiff lerp loader putil effects \
     audio gui pandabase 
     audio gui pandabase 
 
 
+
+
+
 #define LOCAL_LIBS downloader event ipc express pandabase
 #define LOCAL_LIBS downloader event ipc express pandabase
 #define OTHER_LIBS dtoolconfig dtool
 #define OTHER_LIBS dtoolconfig dtool
 
 

+ 4 - 0
panda/metalibs/panda/panda.cxx

@@ -9,7 +9,9 @@
 #include <config_display.h>
 #include <config_display.h>
 #include <config_graph.h>
 #include <config_graph.h>
 #include <config_pnmimagetypes.h>
 #include <config_pnmimagetypes.h>
+#ifdef DO_PSTATS
 #include <config_pstats.h>
 #include <config_pstats.h>
+#endif
 #include <config_sgraph.h>
 #include <config_sgraph.h>
 
 
 #ifdef LINK_IN_GL
 #ifdef LINK_IN_GL
@@ -38,7 +40,9 @@ init_libpanda() {
   init_libdisplay();
   init_libdisplay();
   init_libgraph();
   init_libgraph();
   init_libpnmimagetypes();
   init_libpnmimagetypes();
+#ifdef DO_PSTATS
   init_libpstatclient();
   init_libpstatclient();
+#endif
   init_libsgraph();
   init_libsgraph();
 
 
 #ifdef LINK_IN_GL
 #ifdef LINK_IN_GL

+ 1 - 1
panda/src/char/Sources.pp

@@ -10,7 +10,7 @@
   #define TARGET char
   #define TARGET char
   #define LOCAL_LIBS \
   #define LOCAL_LIBS \
     chan graph sgraph linmath putil event sgattrib mathutil gsgbase \
     chan graph sgraph linmath putil event sgattrib mathutil gsgbase \
-    pstatclient
+    $[if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]], pstatclient]  
 
 
   #define SOURCES \
   #define SOURCES \
     character.I character.cxx character.h characterJoint.cxx \
     character.I character.cxx character.h characterJoint.cxx \

+ 17 - 7
panda/src/char/character.cxx

@@ -15,12 +15,15 @@
 #include <datagramIterator.h>
 #include <datagramIterator.h>
 #include <bamReader.h>
 #include <bamReader.h>
 #include <bamWriter.h>
 #include <bamWriter.h>
-#include <pStatTimer.h>
 
 
 TypeHandle Character::_type_handle;
 TypeHandle Character::_type_handle;
+
+#ifdef DO_PSTATS
+#include <pStatTimer.h>
+
 PStatCollector Character::_anim_pcollector =
 PStatCollector Character::_anim_pcollector =
   PStatCollector("Animation", RGBColorf(1,0,1), 30);
   PStatCollector("Animation", RGBColorf(1,0,1), 30);
-
+#endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::Copy Constructor
 //     Function: Character::Copy Constructor
@@ -32,8 +35,10 @@ Character(const Character &copy) :
   PartBundleNode(copy.get_name(), new CharacterJointBundle(copy.get_name())),
   PartBundleNode(copy.get_name(), new CharacterJointBundle(copy.get_name())),
   _cv(DynamicVertices::deep_copy(copy._cv)),
   _cv(DynamicVertices::deep_copy(copy._cv)),
   _computed_vertices(copy._computed_vertices),
   _computed_vertices(copy._computed_vertices),
-  _parts(copy._parts),
-  _char_pcollector(copy._char_pcollector)
+  _parts(copy._parts)
+#ifdef DO_PSTATS
+  , _char_pcollector(copy._char_pcollector)
+#endif
 {
 {
   // Now make a copy of the joint/slider hierarchy.  We could just use
   // Now make a copy of the joint/slider hierarchy.  We could just use
   // the PartBundleNode's copy constructor, but if we do it ourselves
   // the PartBundleNode's copy constructor, but if we do it ourselves
@@ -49,9 +54,10 @@ Character(const Character &copy) :
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 Character::
 Character::
 Character(const string &name) :
 Character(const string &name) :
-  PartBundleNode(name, new CharacterJointBundle(name)),
-  _char_pcollector(_anim_pcollector,
-		   name.empty() ? string("Unnamed Character") : name)
+  PartBundleNode(name, new CharacterJointBundle(name))
+#ifdef DO_PSTATS
+  , _char_pcollector(_anim_pcollector, name.empty() ? string("Unnamed Character") : name)
+#endif
 {
 {
 }
 }
 
 
@@ -121,8 +127,10 @@ app_traverse() {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void Character::
 void Character::
 update() {
 update() {
+#ifdef DO_PSTATS
   // Statistics
   // Statistics
   PStatTimer timer(_char_pcollector);
   PStatTimer timer(_char_pcollector);
+#endif
 
 
   // First, update all the joints and sliders.
   // First, update all the joints and sliders.
   get_bundle()->update();
   get_bundle()->update();
@@ -421,11 +429,13 @@ fillin(DatagramIterator& scan, BamReader* manager)
     _parts.push_back((PartGroup *)NULL);
     _parts.push_back((PartGroup *)NULL);
   }
   }
 
 
+#ifdef DO_PSTATS
   // Reinitialize our collector with our name, now that we know it.
   // Reinitialize our collector with our name, now that we know it.
   if (has_name()) {
   if (has_name()) {
     _char_pcollector =
     _char_pcollector =
       PStatCollector(_anim_pcollector, get_name());
       PStatCollector(_anim_pcollector, get_name());
   }
   }
+#endif
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 9 - 4
panda/src/char/character.h

@@ -13,10 +13,13 @@
 #include <partBundleNode.h>
 #include <partBundleNode.h>
 #include <namedNode.h>
 #include <namedNode.h>
 #include <vector_PartGroupStar.h>
 #include <vector_PartGroupStar.h>
-#include <pStatCollector.h>
 #include <pointerTo.h>
 #include <pointerTo.h>
 #include <geom.h>
 #include <geom.h>
 
 
+#ifdef DO_PSTATS
+#include <pStatCollector.h>
+#endif
+
 class CharacterJointBundle;
 class CharacterJointBundle;
 class ComputedVertices;
 class ComputedVertices;
 
 
@@ -79,9 +82,11 @@ private:
   typedef vector_PartGroupStar Parts;
   typedef vector_PartGroupStar Parts;
   Parts _parts;
   Parts _parts;
 
 
-  // Statistics
-  PStatCollector _char_pcollector;
-  static PStatCollector _anim_pcollector;
+  #ifdef DO_PSTATS
+	// Statistics
+        PStatCollector _char_pcollector;
+	static PStatCollector _anim_pcollector;
+  #endif
 
 
 public:
 public:
   static void register_with_read_factory(void);
   static void register_with_read_factory(void);

+ 1 - 1
panda/src/collide/Sources.pp

@@ -9,7 +9,7 @@
 #begin lib_target
 #begin lib_target
   #define TARGET collide
   #define TARGET collide
   #define LOCAL_LIBS \
   #define LOCAL_LIBS \
-    sgmanip light tform sgraphutil gobj graph putil
+    sgmanip light tform sgraphutil gobj graph putil $[if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]], pstatclient] 
 
 
   #define SOURCES \
   #define SOURCES \
     collisionEntry.I collisionEntry.cxx collisionEntry.h \
     collisionEntry.I collisionEntry.cxx collisionEntry.h \

+ 5 - 1
panda/src/collide/collisionTraverser.cxx

@@ -13,14 +13,16 @@
 #include <wrt.h>
 #include <wrt.h>
 #include <get_rel_pos.h>
 #include <get_rel_pos.h>
 #include <transformTransition.h>
 #include <transformTransition.h>
-#include <pStatTimer.h>
 #include <geomNode.h>
 #include <geomNode.h>
 #include <geom.h>
 #include <geom.h>
 #include <nodePath.h>
 #include <nodePath.h>
 
 
+#ifdef DO_PSTATS
+#include <pStatTimer.h>
 
 
 PStatCollector CollisionTraverser::_collisions_pcollector =
 PStatCollector CollisionTraverser::_collisions_pcollector =
   PStatCollector("Collisions", RGBColorf(1,0.5,0), 40);
   PStatCollector("Collisions", RGBColorf(1,0.5,0), 40);
+#endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CollisionTraverser::Constructor
 //     Function: CollisionTraverser::Constructor
@@ -230,7 +232,9 @@ void CollisionTraverser::
 traverse(const NodePath &root) {
 traverse(const NodePath &root) {
   nassertv(root.get_graph_type() == _graph_type);
   nassertv(root.get_graph_type() == _graph_type);
 
 
+#ifdef DO_PSTATS
   PStatTimer timer(_collisions_pcollector);
   PStatTimer timer(_collisions_pcollector);
+#endif
 
 
   CollisionLevelState level_state(root);
   CollisionLevelState level_state(root);
   prepare_colliders(level_state);
   prepare_colliders(level_state);

+ 8 - 3
panda/src/collide/collisionTraverser.h

@@ -16,9 +16,12 @@
 #include <nullAttributeWrapper.h>
 #include <nullAttributeWrapper.h>
 #include <pointerTo.h>
 #include <pointerTo.h>
 #include <renderRelation.h>
 #include <renderRelation.h>
-#include <pStatCollector.h>
 #include <pointerTo.h>
 #include <pointerTo.h>
 
 
+#ifdef DO_PSTATS
+#include <pStatCollector.h>
+#endif
+
 #include <set>
 #include <set>
 
 
 class CollisionNode;
 class CollisionNode;
@@ -89,8 +92,10 @@ private:
   typedef map<PT(CollisionHandler), int> Handlers;
   typedef map<PT(CollisionHandler), int> Handlers;
   Handlers _handlers;
   Handlers _handlers;
 
 
-  // Statistics
-  static PStatCollector _collisions_pcollector;
+  #ifdef DO_PSTATS
+    // Statistics
+     static PStatCollector _collisions_pcollector;
+  #endif
 };
 };
 
 
 INLINE ostream &operator << (ostream &out, const CollisionTraverser &trav) {
 INLINE ostream &operator << (ostream &out, const CollisionTraverser &trav) {

+ 1 - 1
panda/src/cull/Sources.pp

@@ -10,7 +10,7 @@
   #define TARGET cull
   #define TARGET cull
   #define LOCAL_LIBS \
   #define LOCAL_LIBS \
     gobj sgraphutil graph putil sgraph mathutil sgattrib display \
     gobj sgraphutil graph putil sgraph mathutil sgattrib display \
-    pstatclient
+    $[if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]], pstatclient]     
 
 
   #define SOURCES \
   #define SOURCES \
     config_cull.cxx config_cull.h cullState.I cullState.cxx cullState.h \
     config_cull.cxx config_cull.h cullState.I cullState.cxx cullState.h \

+ 6 - 3
panda/src/cull/cullTraverser.cxx

@@ -22,17 +22,18 @@
 #include <indent.h>
 #include <indent.h>
 #include <config_sgraphutil.h>  // for implicit_app_traversal
 #include <config_sgraphutil.h>  // for implicit_app_traversal
 #include <config_sgattrib.h>    // for support_decals
 #include <config_sgattrib.h>    // for support_decals
-#include <pStatTimer.h>
 #include <string_utils.h>
 #include <string_utils.h>
 
 
 TypeHandle CullTraverser::_type_handle;
 TypeHandle CullTraverser::_type_handle;
 
 
+#ifdef DO_PSTATS
+#include <pStatTimer.h>
+
 PStatCollector CullTraverser::_cull_pcollector =
 PStatCollector CullTraverser::_cull_pcollector =
   PStatCollector("Cull", RGBColorf(0,1,0), 10);
   PStatCollector("Cull", RGBColorf(0,1,0), 10);
 PStatCollector CullTraverser::_draw_pcollector =
 PStatCollector CullTraverser::_draw_pcollector =
   PStatCollector("Draw", RGBColorf(1,0,0), 20);
   PStatCollector("Draw", RGBColorf(1,0,0), 20);
-
-
+#endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CullTraverser::Constructor
 //     Function: CullTraverser::Constructor
@@ -172,8 +173,10 @@ void CullTraverser::
 traverse(Node *root, 
 traverse(Node *root, 
 	 const AllAttributesWrapper &initial_state,
 	 const AllAttributesWrapper &initial_state,
 	 const AllTransitionsWrapper &net_trans) {
 	 const AllTransitionsWrapper &net_trans) {
+#ifdef DO_PSTATS
   // Statistics
   // Statistics
   PStatTimer timer(_cull_pcollector);
   PStatTimer timer(_cull_pcollector);
+#endif
 
 
   if (cull_cat.is_debug()) {
   if (cull_cat.is_debug()) {
     cull_cat.debug()
     cull_cat.debug()

+ 9 - 4
panda/src/cull/cullTraverser.h

@@ -16,7 +16,10 @@
 #include <traverserVisitor.h>
 #include <traverserVisitor.h>
 #include <nullTransitionWrapper.h>
 #include <nullTransitionWrapper.h>
 #include <nullAttributeWrapper.h>
 #include <nullAttributeWrapper.h>
+
+#ifdef DO_PSTATS
 #include <pStatCollector.h>
 #include <pStatCollector.h>
+#endif
 
 
 #include <list>
 #include <list>
 #include <set>
 #include <set>
@@ -119,10 +122,12 @@ private:
   UpdateSeq _now;
   UpdateSeq _now;
 
 
 public:
 public:
-  // Statistics
-  static PStatCollector _cull_pcollector;
-  static PStatCollector _draw_pcollector;
-
+  #ifdef DO_PSTATS
+	  // Statistics
+	  static PStatCollector _cull_pcollector;
+	  static PStatCollector _draw_pcollector;
+  #endif
+  
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {
     return _type_handle;
     return _type_handle;

+ 5 - 0
panda/src/cull/geomBinBackToFront.cxx

@@ -11,7 +11,10 @@
 #include <transformTransition.h>
 #include <transformTransition.h>
 #include <transformAttribute.h>
 #include <transformAttribute.h>
 #include <geometricBoundingVolume.h>
 #include <geometricBoundingVolume.h>
+
+#ifdef DO_PSTATS
 #include <pStatTimer.h>
 #include <pStatTimer.h>
+#endif
 
 
 TypeHandle GeomBinBackToFront::_type_handle;
 TypeHandle GeomBinBackToFront::_type_handle;
 
 
@@ -135,7 +138,9 @@ record_current_state(GraphicsStateGuardian *gsg, CullState *cs, int,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GeomBinBackToFront::
 void GeomBinBackToFront::
 draw(CullTraverser *trav) {
 draw(CullTraverser *trav) {
+#ifdef DO_PSTATS
   PStatTimer timer(CullTraverser::_draw_pcollector);
   PStatTimer timer(CullTraverser::_draw_pcollector);
+#endif
   if (cull_cat.is_spam()) {
   if (cull_cat.is_spam()) {
     cull_cat.spam() 
     cull_cat.spam() 
       << "GeomBinBackToFront drawing " << _node_entries.size() << " entries.\n";
       << "GeomBinBackToFront drawing " << _node_entries.size() << " entries.\n";

+ 5 - 0
panda/src/cull/geomBinFixed.cxx

@@ -12,7 +12,10 @@
 #include <transformAttribute.h>
 #include <transformAttribute.h>
 #include <geometricBoundingVolume.h>
 #include <geometricBoundingVolume.h>
 #include <directRenderTraverser.h>
 #include <directRenderTraverser.h>
+
+#ifdef DO_PSTATS
 #include <pStatTimer.h>
 #include <pStatTimer.h>
+#endif
 
 
 TypeHandle GeomBinFixed::_type_handle;
 TypeHandle GeomBinFixed::_type_handle;
 
 
@@ -64,7 +67,9 @@ record_current_state(GraphicsStateGuardian *, CullState *cs,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GeomBinFixed::
 void GeomBinFixed::
 draw(CullTraverser *trav) {
 draw(CullTraverser *trav) {
+#ifdef DO_PSTATS
   PStatTimer timer(CullTraverser::_draw_pcollector);
   PStatTimer timer(CullTraverser::_draw_pcollector);
+#endif
   NodeEntries::iterator nei;
   NodeEntries::iterator nei;
   for (nei = _node_entries.begin(); nei != _node_entries.end(); ++nei) {
   for (nei = _node_entries.begin(); nei != _node_entries.end(); ++nei) {
     (*nei).draw(trav);
     (*nei).draw(trav);

+ 5 - 0
panda/src/cull/geomBinUnsorted.cxx

@@ -9,7 +9,10 @@
 #include <indent.h>
 #include <indent.h>
 #include <nodeAttributes.h>
 #include <nodeAttributes.h>
 #include <graphicsStateGuardian.h>
 #include <graphicsStateGuardian.h>
+
+#ifdef DO_PSTATS
 #include <pStatTimer.h>
 #include <pStatTimer.h>
+#endif
 
 
 TypeHandle GeomBinUnsorted::_type_handle;
 TypeHandle GeomBinUnsorted::_type_handle;
 
 
@@ -66,7 +69,9 @@ record_current_state(GraphicsStateGuardian *, CullState *cs, int,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void GeomBinUnsorted::
 void GeomBinUnsorted::
 draw(CullTraverser *trav) {
 draw(CullTraverser *trav) {
+#ifdef DO_PSTATS
   PStatTimer timer(CullTraverser::_draw_pcollector);
   PStatTimer timer(CullTraverser::_draw_pcollector);
+#endif
   GraphicsStateGuardian *gsg = trav->get_gsg();
   GraphicsStateGuardian *gsg = trav->get_gsg();
 
 
   if (cull_cat.is_spam()) {
   if (cull_cat.is_spam()) {

+ 2 - 1
panda/src/display/Sources.pp

@@ -9,7 +9,8 @@
 #begin lib_target
 #begin lib_target
   #define TARGET display
   #define TARGET display
   #define LOCAL_LIBS \
   #define LOCAL_LIBS \
-    putil gsgbase gobj linmath graph mathutil sgraph pstatclient
+    putil gsgbase gobj linmath graph mathutil sgraph \
+    $[if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]], pstatclient]  
 
 
   #define SOURCES \
   #define SOURCES \
     config_display.cxx config_display.h displayRegion.I \
     config_display.cxx config_display.h displayRegion.I \

+ 2 - 1
panda/src/display/graphicsWindow.cxx

@@ -24,6 +24,7 @@ TypeHandle GraphicsWindow::WindowPipe::_type_handle;
 
 
 GraphicsWindow::WindowFactory *GraphicsWindow::_factory = NULL;
 GraphicsWindow::WindowFactory *GraphicsWindow::_factory = NULL;
 
 
+#ifdef DO_PSTATS
 PStatCollector GraphicsWindow::_app_pcollector =
 PStatCollector GraphicsWindow::_app_pcollector =
   PStatCollector("App", RGBColorf(0,1,1));
   PStatCollector("App", RGBColorf(0,1,1));
 PStatCollector GraphicsWindow::_show_code_pcollector =
 PStatCollector GraphicsWindow::_show_code_pcollector =
@@ -32,7 +33,7 @@ PStatCollector GraphicsWindow::_swap_pcollector =
   PStatCollector("Draw:Swap Buffers", RGBColorf(0.5,1,0.8));
   PStatCollector("Draw:Swap Buffers", RGBColorf(0.5,1,0.8));
 PStatCollector GraphicsWindow::_make_current_pcollector =
 PStatCollector GraphicsWindow::_make_current_pcollector =
   PStatCollector("Draw:Make Current", RGBColorf(1,0.6,0.3));
   PStatCollector("Draw:Make Current", RGBColorf(1,0.6,0.3));
-
+#endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: GraphicsWindow::Properties::Constructor
 //     Function: GraphicsWindow::Properties::Constructor

+ 10 - 5
panda/src/display/graphicsWindow.h

@@ -24,7 +24,10 @@
 #include <buttonEvent.h>
 #include <buttonEvent.h>
 #include <iterator_types.h>
 #include <iterator_types.h>
 #include <factory.h>
 #include <factory.h>
+
+#ifdef DO_PSTATS
 #include <pStatCollector.h>
 #include <pStatCollector.h>
+#endif
 
 
 #include <string>
 #include <string>
 #include <vector>
 #include <vector>
@@ -155,11 +158,13 @@ public:
   virtual void begin_frame();
   virtual void begin_frame();
   virtual void end_frame();
   virtual void end_frame();
 
 
-  // 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;
+  #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
  
  
 protected:
 protected:
   void make_gsg();
   void make_gsg();

+ 12 - 6
panda/src/dxgsg/dxGraphicsStateGuardian.cxx

@@ -3,10 +3,10 @@
 // 
 // 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 
 
+#include <pandabase.h>
 #include "dxSavedFrameBuffer.h"
 #include "dxSavedFrameBuffer.h"
 #include "config_dxgsg.h"
 #include "config_dxgsg.h"
 #include "dxGraphicsStateGuardian.h"
 #include "dxGraphicsStateGuardian.h"
-#include <pStatTimer.h>
 #include <directRenderTraverser.h>
 #include <directRenderTraverser.h>
 #include <cullTraverser.h>
 #include <cullTraverser.h>
 #include <displayRegion.h>
 #include <displayRegion.h>
@@ -66,7 +66,9 @@
 #include <stencilTransition.h>
 #include <stencilTransition.h>
 #include <throw_event.h>
 #include <throw_event.h>
 
 
-#include <pandabase.h>
+#ifdef DO_PSTATS
+#include <pStatTimer.h>
+#endif
 
 
 #define DISABLE_POLYGON_OFFSET_DECALING
 #define DISABLE_POLYGON_OFFSET_DECALING
 // currently doesnt work well enough in toontown models for us to use
 // currently doesnt work well enough in toontown models for us to use
@@ -1200,7 +1202,7 @@ draw_point(const GeomPoint *geom) {
 			// Geom nodes store floats for colors, drawprim requires ARGB dwords
 			// Geom nodes store floats for colors, drawprim requires ARGB dwords
 			// BUGBUG: eventually this hack every-frame all-colors conversion needs 
 			// BUGBUG: eventually this hack every-frame all-colors conversion needs 
 			// to be done only once as part of a vertex buffer
 			// to be done only once as part of a vertex buffer
-
+			
 			if(_color_transform_enabled || _alpha_transform_enabled) {
 			if(_color_transform_enabled || _alpha_transform_enabled) {
 				for (int i=0;i<nPrims;i++) {
 				for (int i=0;i<nPrims;i++) {
 					D3DCOLOR RGBA_color;
 					D3DCOLOR RGBA_color;
@@ -2005,14 +2007,15 @@ draw_tri(const GeomTri *geom) {
 
 
 		D3DSHADEMODE NeededShadeMode = D3DSHADE_FLAT;
 		D3DSHADEMODE NeededShadeMode = D3DSHADE_FLAT;
 
 
-		DWORD dwVertsPerPrim=geom->get_num_vertices_per_prim();
-
+		const DWORD dwVertsPerPrim=3;
+	
 		if ((NormalBinding != G_OFF) && wants_normals()) {
 		if ((NormalBinding != G_OFF) && wants_normals()) {
 
 
 			dps_data.normal.lpvData = (VOID*)norms;
 			dps_data.normal.lpvData = (VOID*)norms;
 			dps_data.normal.dwStride = sizeof(D3DVECTOR);
 			dps_data.normal.dwStride = sizeof(D3DVECTOR);
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
+			nassertv(geom->get_num_vertices_per_prim()==3);
 			nassertv( nPrims*dwVertsPerPrim*sizeof(D3DVECTOR) <= D3DMAXNUMVERTICES*sizeof(WORD)); 
 			nassertv( nPrims*dwVertsPerPrim*sizeof(D3DVECTOR) <= D3DMAXNUMVERTICES*sizeof(WORD)); 
 			if (NormalBinding==G_PER_VERTEX)
 			if (NormalBinding==G_PER_VERTEX)
 				nassertv(norms.size()>=nPrims*dwVertsPerPrim);
 				nassertv(norms.size()>=nPrims*dwVertsPerPrim);
@@ -2437,7 +2440,7 @@ draw_multitri(const Geom *geom, D3DPRIMITIVETYPE trilisttype) {
 			cTotalVerts+= pLengthArr[i];
 			cTotalVerts+= pLengthArr[i];
 		}
 		}
 
 
-		DWORD cNumMoreVertsthanTris=geom->get_num_more_vertices_than_components();
+		const DWORD cNumMoreVertsthanTris=2;
 
 
 		if((NormalBinding != G_OFF) && wants_normals()) {
 		if((NormalBinding != G_OFF) && wants_normals()) {
 
 
@@ -2445,6 +2448,7 @@ draw_multitri(const Geom *geom, D3DPRIMITIVETYPE trilisttype) {
 			dps_data.normal.dwStride = sizeof(D3DVECTOR);
 			dps_data.normal.dwStride = sizeof(D3DVECTOR);
 
 
 #ifdef _DEBUG
 #ifdef _DEBUG
+			nassertv(geom->get_num_more_vertices_than_components()==2);
 			nassertv(NormalBinding!=G_PER_COMPONENT); // makes no sense, unimplementable for strips since normals always shared across tris
 			nassertv(NormalBinding!=G_PER_COMPONENT); // makes no sense, unimplementable for strips since normals always shared across tris
 			nassertv( cTotalVerts*sizeof(D3DVECTOR) <= D3DMAXNUMVERTICES*sizeof(WORD)); 
 			nassertv( cTotalVerts*sizeof(D3DVECTOR) <= D3DMAXNUMVERTICES*sizeof(WORD)); 
 			if(NormalBinding==G_PER_VERTEX)
 			if(NormalBinding==G_PER_VERTEX)
@@ -5387,7 +5391,9 @@ HRESULT DXGraphicsStateGuardian::RestoreAllVideoSurfaces(void) {
 //       Description:   Repaint primary buffer from back buffer  (windowed mode only)
 //       Description:   Repaint primary buffer from back buffer  (windowed mode only)
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void DXGraphicsStateGuardian::show_frame(void) {
 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
 	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)
 	if(_pri==NULL)
 		return;
 		return;

+ 7 - 3
panda/src/framework/framework.cxx

@@ -410,7 +410,7 @@ void event_esc(CPT_Event) {
   rib_pipe = NULL;
   rib_pipe = NULL;
   rib_win = NULL;
   rib_win = NULL;
 
 
-#ifdef HAVE_NET
+#if defined(HAVE_NET) && defined(DO_PSTATS)
   if (PStatClient::get_global_pstats()->is_connected()) {
   if (PStatClient::get_global_pstats()->is_connected()) {
     framework_cat.info() << "Disconnecting from stats host" << endl;
     framework_cat.info() << "Disconnecting from stats host" << endl;
     PStatClient::get_global_pstats()->disconnect();
     PStatClient::get_global_pstats()->disconnect();
@@ -438,7 +438,9 @@ void event_f(CPT_Event) {
 }
 }
 
 
 void event_S(CPT_Event) {
 void event_S(CPT_Event) {
-#ifdef HAVE_NET
+#ifndef DO_PSTATS
+  framework_cat.error() << "demo not compiled with PStats support." << endl;
+#elif defined(HAVE_NET)
   framework_cat.info() << "Connecting to stats host" << endl;
   framework_cat.info() << "Connecting to stats host" << endl;
   PStatClient::get_global_pstats()->connect();
   PStatClient::get_global_pstats()->connect();
 #else
 #else
@@ -447,7 +449,9 @@ void event_S(CPT_Event) {
 }
 }
 
 
 void event_A(CPT_Event) {
 void event_A(CPT_Event) {
-#ifdef HAVE_NET
+#ifndef DO_PSTATS
+  framework_cat.error() << "demo not compiled with PStats support." << endl;
+#elif defined(HAVE_NET)
   if (PStatClient::get_global_pstats()->is_connected()) {
   if (PStatClient::get_global_pstats()->is_connected()) {
     framework_cat.info() << "Disconnecting from stats host" << endl;
     framework_cat.info() << "Disconnecting from stats host" << endl;
     PStatClient::get_global_pstats()->disconnect();
     PStatClient::get_global_pstats()->disconnect();

+ 9 - 1
panda/src/pstatclient/Sources.pp

@@ -2,10 +2,12 @@
                    dtoolutil:c dtoolbase:c dtool:m
                    dtoolutil:c dtoolbase:c dtool:m
 
 
 #begin lib_target
 #begin lib_target
-  #define TARGET pstatclient
   #define LOCAL_LIBS \
   #define LOCAL_LIBS \
     net linmath putil express
     net linmath putil express
 
 
+#if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]]
+  #define TARGET pstatclient
+
   #define SOURCES \
   #define SOURCES \
     config_pstats.cxx config_pstats.h pStatClient.I pStatClient.cxx \
     config_pstats.cxx config_pstats.h pStatClient.I pStatClient.cxx \
     pStatClient.h pStatClientControlMessage.cxx \
     pStatClient.h pStatClientControlMessage.cxx \
@@ -22,6 +24,12 @@
     pStatTimer.I pStatTimer.h
     pStatTimer.I pStatTimer.h
 
 
   #define IGATESCAN all
   #define IGATESCAN all
+#else
+  #define TARGET
+  #define SOURCES
+  #define INSTALL_HEADERS  
+  #define IGATESCAN
+#endif  
 
 
 #end lib_target
 #end lib_target
 
 

+ 6 - 1
panda/src/sgraphutil/directRenderTraverser.cxx

@@ -23,12 +23,15 @@
 #include <nodeTransitionWrapper.h>
 #include <nodeTransitionWrapper.h>
 #include <decalTransition.h>
 #include <decalTransition.h>
 #include <decalAttribute.h>
 #include <decalAttribute.h>
-#include <pStatTimer.h>
 #include <config_sgattrib.h>   // for support_decals
 #include <config_sgattrib.h>   // for support_decals
 
 
 TypeHandle DirectRenderTraverser::_type_handle;
 TypeHandle DirectRenderTraverser::_type_handle;
+
+#ifdef DO_PSTATS
+#include <pStatTimer.h>
 PStatCollector DirectRenderTraverser::_draw_pcollector =
 PStatCollector DirectRenderTraverser::_draw_pcollector =
   PStatCollector("Draw", RGBColorf(1,0,0), 20);
   PStatCollector("Draw", RGBColorf(1,0,0), 20);
+#endif
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: DirectRenderTraverser::Constructor
 //     Function: DirectRenderTraverser::Constructor
@@ -63,8 +66,10 @@ void DirectRenderTraverser::
 traverse(Node *root, 
 traverse(Node *root, 
 	 const AllAttributesWrapper &initial_state,
 	 const AllAttributesWrapper &initial_state,
 	 const AllTransitionsWrapper &net_trans) {
 	 const AllTransitionsWrapper &net_trans) {
+#ifdef DO_PSTATS
   // Statistics
   // Statistics
   PStatTimer timer(_draw_pcollector);
   PStatTimer timer(_draw_pcollector);
+#endif
 
 
   AllAttributesWrapper render_state;
   AllAttributesWrapper render_state;
   render_state.apply_from(initial_state, net_trans);
   render_state.apply_from(initial_state, net_trans);

+ 8 - 4
panda/src/sgraphutil/directRenderTraverser.h

@@ -17,9 +17,12 @@
 #include <allAttributesWrapper.h>
 #include <allAttributesWrapper.h>
 #include <geometricBoundingVolume.h>
 #include <geometricBoundingVolume.h>
 #include <lmatrix.h>
 #include <lmatrix.h>
-#include <pStatCollector.h>
 #include <pointerTo.h>
 #include <pointerTo.h>
 
 
+#ifdef DO_PSTATS
+#include <pStatCollector.h>
+#endif
+
 class Node;
 class Node;
 class GraphicsStateGuardian;
 class GraphicsStateGuardian;
 class GeometricBoundingVolume;
 class GeometricBoundingVolume;
@@ -60,9 +63,10 @@ public:
 		    const DirectRenderLevelState &level_state);
 		    const DirectRenderLevelState &level_state);
 
 
 private:
 private:
-  // Statistics
-  static PStatCollector _draw_pcollector;
-  
+  #ifdef DO_PSTATS
+    // Statistics
+    static PStatCollector _draw_pcollector;
+  #endif
 
 
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {

+ 1 - 1
panda/src/testbed/Sources.pp

@@ -4,7 +4,7 @@
     framework putil collide loader sgmanip chan text chancfg cull \
     framework putil collide loader sgmanip chan text chancfg cull \
     pnmimage pnmimagetypes event effects shader graph gobj display \
     pnmimage pnmimagetypes event effects shader graph gobj display \
     mathutil sgattrib putil express light dgraph device tform sgraph \
     mathutil sgattrib putil express light dgraph device tform sgraph \
-    linmath pstatclient sgraphutil panda
+    linmath sgraphutil panda $[if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]], pstatclient]  
 
 
 #if $[LINK_ALL_STATIC]
 #if $[LINK_ALL_STATIC]
   // If we're statically linking, we need to explicitly link with
   // If we're statically linking, we need to explicitly link with

+ 13 - 4
panda/src/wgldisplay/wglGraphicsWindow.cxx

@@ -3,18 +3,20 @@
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 // Includes
 // Includes
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
+
 #include "wglGraphicsWindow.h"
 #include "wglGraphicsWindow.h"
 #include "wglGraphicsPipe.h"
 #include "wglGraphicsPipe.h"
 #include "config_wgldisplay.h"
 #include "config_wgldisplay.h"
-
 #include <keyboardButton.h>
 #include <keyboardButton.h>
 #include <mouseButton.h>
 #include <mouseButton.h>
 #include <glGraphicsStateGuardian.h>
 #include <glGraphicsStateGuardian.h>
-#include <pStatTimer.h>
-
 #include <errno.h>
 #include <errno.h>
 #include <time.h>
 #include <time.h>
 
 
+#ifdef DO_PSTATS
+#include <pStatTimer.h>
+#endif
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 // Static variables
 // Static variables
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -846,7 +848,9 @@ void wglGraphicsWindow::setup_colormap(void) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void wglGraphicsWindow::end_frame(void) {
 void wglGraphicsWindow::end_frame(void) {
   {
   {
+#ifdef DO_PSTATS
     PStatTimer timer(_swap_pcollector);
     PStatTimer timer(_swap_pcollector);
+#endif
     SwapBuffers(_hdc);
     SwapBuffers(_hdc);
   }
   }
   GraphicsWindow::end_frame();
   GraphicsWindow::end_frame();
@@ -994,8 +998,10 @@ supports_update() const {
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void wglGraphicsWindow::update(void) {
 void wglGraphicsWindow::update(void) {
+#ifdef DO_PSTATS
   _show_code_pcollector.stop();
   _show_code_pcollector.stop();
   PStatClient::main_tick();
   PStatClient::main_tick();
+#endif
 
 
   if (_change_mask)
   if (_change_mask)
     handle_changes();
     handle_changes();
@@ -1008,8 +1014,9 @@ void wglGraphicsWindow::update(void) {
     idle_wait();
     idle_wait();
   else
   else
     process_events();
     process_events();
-
+#ifdef DO_PSTATS
   _show_code_pcollector.start();
   _show_code_pcollector.start();
+#endif
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -1045,7 +1052,9 @@ void wglGraphicsWindow::enable_mouse_passive_motion(bool val) {
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void wglGraphicsWindow::make_current(void) {
 void wglGraphicsWindow::make_current(void) {
+#ifdef DO_PSTATS
   PStatTimer timer(_make_current_pcollector);
   PStatTimer timer(_make_current_pcollector);
+#endif
   HGLRC current_context = wglGetCurrentContext();
   HGLRC current_context = wglGetCurrentContext();
   HDC current_dc = wglGetCurrentDC();
   HDC current_dc = wglGetCurrentDC();
   if (current_context != _context || current_dc != _hdc)
   if (current_context != _context || current_dc != _hdc)