Browse Source

*** empty log message ***

David Rose 24 years ago
parent
commit
a731f403e3

+ 10 - 4
dtool/Config.pp

@@ -279,6 +279,12 @@
 #endif
 #defer HAVE_NET $[HAVE_NSPR]
 
+// Do you want to build the PStats interface, for graphical run-time
+// performance statistics?  This requires NET to be available.  By
+// default, we don't build PStats when OPTIMIZE = 4, although this is
+// possible.
+#defer DO_PSTATS $[and $[HAVE_NET],$[< $[OPTIMIZE], 4]]
+
 // Do you want to build the audio interface?  What additional
 // libraries are required?
 #define AUDIO_IPATH /mspsdk/Include
@@ -405,10 +411,10 @@
 // options to interrogate, guaranteeing that the correct interfaces
 // are generated.  Do not include -D here; that will be supplied
 // automatically.
-#defer CDEFINES_OPT1 _DEBUG DO_PSTATS
-#defer CDEFINES_OPT2 _DEBUG DO_PSTATS
-#defer CDEFINES_OPT3 DO_PSTATS
-#defer CDEFINES_OPT4 NDEBUG $[if $[ne $[DO_PSTATS],],DO_PSTATS]
+#defer CDEFINES_OPT1 _DEBUG
+#defer CDEFINES_OPT2 _DEBUG
+#defer CDEFINES_OPT3
+#defer CDEFINES_OPT4 NDEBUG
 
 // What additional flags should be passed for each value of OPTIMIZE
 // (above)?  We separate out the compiler-optimization flags, above,

+ 3 - 0
dtool/LocalSetup.pp

@@ -85,6 +85,9 @@ $[cdefine HAVE_IPC]
 /* Define if we want to compile the net code.  */
 $[cdefine HAVE_NET]
 
+/* Define if we want to use PStats.  */
+$[cdefine DO_PSTATS]
+
 /* Define if we want to compile the audio code.  */
 $[cdefine HAVE_AUDIO]
 

+ 2 - 0
dtool/Package.pp

@@ -151,6 +151,8 @@
 #set NET_LIBS $[NET_LIBS]
 #set HAVE_NET $[HAVE_NET]
 
+#set DO_PSTATS $[DO_PSTATS]
+
 #set AUDIO_IPATH $[AUDIO_IPATH]
 #set AUDIO_LPATH $[AUDIO_LPATH]
 #set AUDIO_LIBS $[AUDIO_LIBS]

+ 0 - 5
dtool/pptempl/Global.gmsvc.pp

@@ -78,11 +78,6 @@
 
 #define WARNING_LEVEL_FLAG /W3
 
-#if $[or $[ne $[DO_PSTATS],],$[<= $[OPTIMIZE],3]]
-// this should probably only be defined for panda-specific dirs
-#define EXTRA_CDEFS $[EXTRA_CDEFS] DO_PSTATS
-#endif
-
 #if $[TEST_INLINING]
 // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
 #define WARNING_LEVEL_FLAG /W4

+ 0 - 5
dtool/pptempl/Global.msvc.pp

@@ -80,11 +80,6 @@
 
 #define WARNING_LEVEL_FLAG /W3
 
-#if $[or $[ne $[DO_PSTATS],],$[<= $[OPTIMIZE],3]]
-// this should probably only be defined for panda-specific dirs
-#define EXTRA_CDEFS $[EXTRA_CDEFS] DO_PSTATS
-#endif
-
 #if $[TEST_INLINING]
 // /W4 will make MSVC spit out if it inlined a fn or not, but also cause a lot of other spam warnings
 #define WARNING_LEVEL_FLAG /W4

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

@@ -9,7 +9,7 @@
 #define USE_NET yes
 
 #define COMPONENT_LIBS \
-    pvrpn grutil chan chancfg $[if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]], pstatclient] \
+    pvrpn grutil chan chancfg pstatclient \
     char chat collide cull device \
     dgraph display gobj graph gsgbase \
     gsgmisc light linmath mathutil net \

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

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

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

@@ -15,15 +15,12 @@
 #include <datagramIterator.h>
 #include <bamReader.h>
 #include <bamWriter.h>
+#include <pStatTimer.h>
 
 TypeHandle Character::_type_handle;
 
-#ifdef DO_PSTATS
-#include <pStatTimer.h>
-
 PStatCollector Character::_anim_pcollector =
   PStatCollector("Animation", RGBColorf(1,0,1), 30);
-#endif
 
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::Copy Constructor
@@ -35,10 +32,8 @@ Character(const Character &copy) :
   PartBundleNode(copy.get_name(), new CharacterJointBundle(copy.get_name())),
   _cv(DynamicVertices::deep_copy(copy._cv)),
   _computed_vertices(copy._computed_vertices),
-  _parts(copy._parts)
-#ifdef DO_PSTATS
-  , _char_pcollector(copy._char_pcollector)
-#endif
+  _parts(copy._parts),
+  _char_pcollector(copy._char_pcollector)
 {
   // Now make a copy of the joint/slider hierarchy.  We could just use
   // the PartBundleNode's copy constructor, but if we do it ourselves
@@ -54,10 +49,8 @@ Character(const Character &copy) :
 ////////////////////////////////////////////////////////////////////
 Character::
 Character(const string &name) :
-  PartBundleNode(name, new CharacterJointBundle(name))
-#ifdef DO_PSTATS
-  , _char_pcollector(_anim_pcollector, name.empty() ? string("Unnamed Character") : name)
-#endif
+  PartBundleNode(name, new CharacterJointBundle(name)),
+  _char_pcollector(_anim_pcollector, name)
 {
 }
 
@@ -110,9 +103,11 @@ app_traverse() {
   double now = ClockObject::get_global_clock()->get_frame_time();
   get_bundle()->advance_time(now);
 
+#ifndef NDEBUG
   if (char_cat.is_debug()) {
     char_cat.debug() << "Animating " << *this << " at time " << now << "\n";
   }
+#endif
 
   update();
 }
@@ -127,10 +122,8 @@ app_traverse() {
 ////////////////////////////////////////////////////////////////////
 void Character::
 update() {
-#ifdef DO_PSTATS
   // Statistics
   PStatTimer timer(_char_pcollector);
-#endif
 
   // First, update all the joints and sliders.
   get_bundle()->update();

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

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

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

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

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

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

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

@@ -5,16 +5,19 @@
   #define LOCAL_LIBS \
     net linmath putil express
 
-#if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]]
   #define TARGET pstatclient
 
   #define SOURCES \
     config_pstats.cxx config_pstats.h pStatClient.I pStatClient.cxx \
     pStatClient.h pStatClientControlMessage.cxx \
-    pStatClientControlMessage.h pStatCollectorDef.cxx \
+    pStatClientControlMessage.h \
+    pStatCollector.I pStatCollector.h \
+    pStatCollectorDef.cxx \
     pStatCollectorDef.h pStatFrameData.I pStatFrameData.cxx \
     pStatFrameData.h pStatServerControlMessage.cxx \
-    pStatServerControlMessage.h
+    pStatServerControlMessage.h \
+    pStatThread.I pStatThread.h \
+    pStatTimer.I pStatTimer.h
 
   #define INSTALL_HEADERS \
     config_pstats.h pStatClient.I pStatClient.h \
@@ -24,12 +27,6 @@
     pStatTimer.I pStatTimer.h
 
   #define IGATESCAN all
-#else
-  #define TARGET
-  #define SOURCES
-  #define INSTALL_HEADERS  
-  #define IGATESCAN
-#endif  
 
 #end lib_target
 

+ 9 - 7
panda/src/pstatclient/pStatClient.cxx

@@ -5,11 +5,9 @@
 
 #include "pStatClient.h"
 
-#ifdef HAVE_NET 
-// This file only defines anything interesting if we have a network
-// interface, in which case the PStatClient actually does something.
-// If we don't have a network interface, there's nothing to define
-// here.
+#ifdef DO_PSTATS 
+// This file only defines anything interesting if DO_PSTATS is
+// defined.
 
 #include "pStatClientControlMessage.h"
 #include "pStatServerControlMessage.h"
@@ -205,7 +203,11 @@ get_main_thread() const {
 //               called by a PStatCollector constructor.
 ////////////////////////////////////////////////////////////////////
 PStatCollector PStatClient::
-make_collector(int parent_index, const string &fullname) {
+make_collector(int parent_index, string fullname) {
+  if (fullname.empty()) {
+    fullname = "Unnamed";
+  }
+
   // Skip any colons at the beginning of the name.
   size_t start = 0;
   while (start < fullname.size() && fullname[start] == ':') {
@@ -761,4 +763,4 @@ connection_reset(const PT(Connection) &connection) {
   }
 }
 
-#endif // HAVE_NET
+#endif // DO_PSTATS

+ 8 - 8
panda/src/pstatclient/pStatClient.h

@@ -14,7 +14,7 @@
 #include <vector_int.h>
 #include <luse.h>
 
-#ifdef HAVE_NET
+#ifdef DO_PSTATS
 #include <connectionManager.h>
 #include <queuedConnectionReader.h>
 #include <connectionWriter.h>
@@ -31,11 +31,11 @@ class PStatThread;
 // Description : Manages the communications to report statistics via a
 //               network connection to a remote PStatServer.
 //
-//               If HAVE_NET is not defined, we don't have a network
-//               interface, and therefore this class can't do very
-//               much.  It's therefore defined as a stub class.
+//               If DO_PSTATS is not defined, we don't want to use
+//               stats at all.  This class is therefore defined as a
+//               stub class.
 ////////////////////////////////////////////////////////////////////
-#ifdef HAVE_NET
+#ifdef DO_PSTATS
 class EXPCL_PANDA PStatClient : public ConnectionManager {
 public:
   PStatClient();
@@ -69,7 +69,7 @@ PUBLISHED:
   bool is_connected() const;
 
 private:
-  PStatCollector make_collector(int parent_index, const string &fullname);
+  PStatCollector make_collector(int parent_index, string fullname);
   PStatCollector make_collector(int parent_index, const string &fullname,
 				const RGBColorf &suggested_color, int sort);
   PStatThread make_thread(const string &name);
@@ -143,7 +143,7 @@ private:
 
 #include "pStatClient.I"
 
-#else  // HAVE_NET
+#else  // DO_PSTATS
 
 class EXPCL_PANDA PStatClient {
 public:
@@ -153,7 +153,7 @@ public:
   static void main_tick() { }
 };
 
-#endif  // HAVE_NET
+#endif  // DO_PSTATS
 
 #endif
 

+ 4 - 22
panda/src/pstatclient/pStatCollector.I

@@ -4,6 +4,8 @@
 ////////////////////////////////////////////////////////////////////
 
 
+#ifndef DO_PSTATS
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatCollector::Default Constructor
 //       Access: Private
@@ -52,16 +54,11 @@ PStatCollector(PStatClient *client, int index) :
 INLINE PStatCollector::
 PStatCollector(const string &name, const RGBColorf &suggested_color,
 	       int sort, PStatClient *client) {
-#ifdef HAVE_NET
   if (client == (PStatClient *)NULL) {
     client = PStatClient::get_global_pstats();
   }
   PStatCollector collector(client->make_collector(0, name, suggested_color, sort));
   (*this) = collector;
-#else
-  _client = (PStatClient *)NULL;
-  _index = 0;
-#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -90,15 +87,10 @@ PStatCollector(const string &name, const RGBColorf &suggested_color,
 INLINE PStatCollector::
 PStatCollector(const PStatCollector &parent, const string &name, 
 	       const RGBColorf &suggested_color, int sort) {
-#ifdef HAVE_NET
   nassertv(parent._client != (PStatClient *)NULL);
   PStatCollector collector(parent._client->make_collector
 			   (parent._index, name, suggested_color, sort));
   (*this) = collector;
-#else
-  _client = (PStatClient *)NULL;
-  _index = 0;
-#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -132,9 +124,7 @@ operator = (const PStatCollector &copy) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PStatCollector::
 start() {
-#ifdef HAVE_NET
   _client->start(_index, 0, _client->_clock.get_real_time());
-#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -144,9 +134,7 @@ start() {
 ////////////////////////////////////////////////////////////////////
 INLINE void PStatCollector::
 start(const PStatThread &thread) {
-#ifdef HAVE_NET
   _client->start(_index, thread._index, _client->_clock.get_real_time());
-#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -160,9 +148,7 @@ start(const PStatThread &thread) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PStatCollector::
 start(const PStatThread &thread, double as_of) {
-#ifdef HAVE_NET
   _client->start(_index, thread._index, as_of);
-#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -173,9 +159,7 @@ start(const PStatThread &thread, double as_of) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PStatCollector::
 stop() {
-#ifdef HAVE_NET
   _client->stop(_index, 0, _client->_clock.get_real_time());
-#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -185,9 +169,7 @@ stop() {
 ////////////////////////////////////////////////////////////////////
 INLINE void PStatCollector::
 stop(const PStatThread &thread) {
-#ifdef HAVE_NET
   _client->stop(_index, thread._index, _client->_clock.get_real_time());
-#endif
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -201,7 +183,7 @@ stop(const PStatThread &thread) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PStatCollector::
 stop(const PStatThread &thread, double as_of) {
-#ifdef HAVE_NET
   _client->stop(_index, thread._index, as_of);
-#endif
 }
+
+#endif  // DO_PSTATS

+ 23 - 0
panda/src/pstatclient/pStatCollector.h

@@ -20,6 +20,8 @@
 //               timed with calls to start() and stop().
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA PStatCollector {
+#ifdef DO_PSTATS
+
 private:
   INLINE PStatCollector();
   INLINE PStatCollector(PStatClient *client, int index);
@@ -50,6 +52,27 @@ private:
   int _index;
 
 friend class PStatClient;
+
+#else  // DO_PSTATS
+
+  INLINE PStatCollector(const string &, 
+			const RGBColorf & = RGBColorf::zero(),
+			int = -1,
+			PStatClient * = NULL) { }
+  INLINE PStatCollector(const PStatCollector &,
+			const string &,
+			const RGBColorf & = RGBColorf::zero(),
+			int = -1) { }
+
+  INLINE void start() { }
+  INLINE void start(const PStatThread &) { }
+  INLINE void start(const PStatThread &, double) { }
+
+  INLINE void stop() { }
+  INLINE void stop(const PStatThread &) { }
+  INLINE void stop(const PStatThread &, double) { }
+
+#endif  // DO_PSTATS
 };
 
 #include "pStatCollector.I"

+ 2 - 2
panda/src/pstatclient/pStatThread.I

@@ -40,7 +40,7 @@ PStatThread(PStatClient *client, int index) :
 ////////////////////////////////////////////////////////////////////
 INLINE PStatThread::
 PStatThread(const string &name, PStatClient *client) {
-#ifdef HAVE_NET
+#ifdef DO_PSTATS
   if (client == (PStatClient *)NULL) {
     client = PStatClient::get_global_pstats();
   }
@@ -85,7 +85,7 @@ operator = (const PStatThread &copy) {
 ////////////////////////////////////////////////////////////////////
 INLINE void PStatThread::
 new_frame() {
-#ifdef HAVE_NET
+#ifdef DO_PSTATS
   _client->new_frame(_index);
 #endif
 }

+ 3 - 0
panda/src/pstatclient/pStatTimer.I

@@ -4,6 +4,8 @@
 ////////////////////////////////////////////////////////////////////
 
 
+#ifndef DO_PSTATS
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PStatTimer::Constructor
 //       Access: Public
@@ -26,3 +28,4 @@ INLINE PStatTimer::
   _collector.stop();
 }
 
+#endif

+ 8 - 0
panda/src/pstatclient/pStatTimer.h

@@ -22,11 +22,19 @@
 ////////////////////////////////////////////////////////////////////
 class EXPCL_PANDA PStatTimer {
 public:
+#ifdef DO_PSTATS
   INLINE PStatTimer(PStatCollector &collector);
   INLINE ~PStatTimer();
 
 private:
   PStatCollector &_collector;
+
+#else // DO_PSTATS
+
+  INLINE PStatTimer(PStatCollector &) { }
+  INLINE ~PStatTimer() { }
+
+#endif  // DO_PSTATS
 };
 
 #include "pStatTimer.I"

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

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

+ 0 - 8
pandatool/src/gtk-stats/Sources.pp

@@ -4,8 +4,6 @@
 #define USE_NET yes
 
 #begin bin_target
-
-#if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]]
   #define TARGET gtk-stats
   #define LOCAL_LIBS \
     gtkbase progbase pstatserver
@@ -24,12 +22,6 @@
     gtkStatsServer.h gtkStatsStripChart.I gtkStatsStripChart.cxx \
     gtkStatsStripChart.h gtkStatsStripWindow.cxx gtkStatsStripWindow.h \
     gtkStatsWindow.cxx gtkStatsWindow.h
-#else
-  #define TARGET
-  #define SOURCES
-  #define INSTALL_HEADERS  
-#endif  	
-	
 
 #end bin_target
 

+ 0 - 8
pandatool/src/pstatserver/Sources.pp

@@ -2,9 +2,6 @@
 #define USE_NET yes
 
 #begin ss_lib_target
-
-#if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]]
-
   #define TARGET pstatserver
   #define LOCAL_LIBS pandatoolbase
   #define OTHER_LIBS \
@@ -28,11 +25,6 @@
     pStatReader.h pStatServer.h pStatStripChart.I pStatStripChart.h \
     pStatThreadData.I pStatThreadData.h pStatView.I pStatView.h \
     pStatViewLevel.I pStatViewLevel.h
-#else
-  #define TARGET
-  #define SOURCES
-  #define INSTALL_HEADERS  
-#endif  	
 
 #end ss_lib_target
 

+ 0 - 12
pandatool/src/text-stats/Sources.pp

@@ -2,10 +2,6 @@
 #define USE_NET yes
 
 #begin bin_target
-
-
-#if $[or $[<= $[OPTIMIZE],3], $[ne $[DO_PSTATS],]]
-	
   #define TARGET text-stats
   #define LOCAL_LIBS \
     progbase pstatserver
@@ -19,14 +15,6 @@
     textMonitor.cxx textMonitor.h textStats.cxx textStats.h
 
   #define INSTALL_HEADERS 
-  
-#else
-  #define TARGET
-  #define SOURCES
-  #define INSTALL_HEADERS  
-#endif  	  
-
-
 
 #end bin_target