diff --git a/dtool/Config.pp b/dtool/Config.pp index f9a129765b..15d06177de 100644 --- a/dtool/Config.pp +++ b/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, diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index de8274de46..e45584c63e 100644 --- a/dtool/LocalSetup.pp +++ b/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] diff --git a/dtool/Package.pp b/dtool/Package.pp index f3a6ca1b90..9e1afe412f 100644 --- a/dtool/Package.pp +++ b/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] diff --git a/dtool/pptempl/Global.gmsvc.pp b/dtool/pptempl/Global.gmsvc.pp index 02a0155dcf..384c19bfaa 100644 --- a/dtool/pptempl/Global.gmsvc.pp +++ b/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 diff --git a/dtool/pptempl/Global.msvc.pp b/dtool/pptempl/Global.msvc.pp index 0fefd5d63a..9f0dfbe33c 100644 --- a/dtool/pptempl/Global.msvc.pp +++ b/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 diff --git a/panda/metalibs/panda/Sources.pp b/panda/metalibs/panda/Sources.pp index 68b15d8613..988aac6371 100644 --- a/panda/metalibs/panda/Sources.pp +++ b/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 \ diff --git a/panda/src/char/Sources.pp b/panda/src/char/Sources.pp index b57a91b06b..e954a44c94 100644 --- a/panda/src/char/Sources.pp +++ b/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 \ diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index 6b72e46f78..21ce5b604d 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -15,15 +15,12 @@ #include #include #include +#include TypeHandle Character::_type_handle; -#ifdef DO_PSTATS -#include - PStatCollector Character::_anim_pcollector = PStatCollector("Animation", RGBColorf(1,0,1), 30); -#endif //////////////////////////////////////////////////////////////////// // Function: Character::Copy Constructor @@ -35,10 +32,8 @@ Character(const Character ©) : 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 ©) : //////////////////////////////////////////////////////////////////// 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(); diff --git a/panda/src/collide/Sources.pp b/panda/src/collide/Sources.pp index d37023671c..5a0ddd57dc 100644 --- a/panda/src/collide/Sources.pp +++ b/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 \ diff --git a/panda/src/cull/Sources.pp b/panda/src/cull/Sources.pp index deee2357a2..1d07bcb1bb 100644 --- a/panda/src/cull/Sources.pp +++ b/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 \ diff --git a/panda/src/display/Sources.pp b/panda/src/display/Sources.pp index 13d643fc35..0140b9a797 100644 --- a/panda/src/display/Sources.pp +++ b/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 \ diff --git a/panda/src/pstatclient/Sources.pp b/panda/src/pstatclient/Sources.pp index 875a55f0e0..a8494f3121 100644 --- a/panda/src/pstatclient/Sources.pp +++ b/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 diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index dfad84e5cd..df2c5273eb 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/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 diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 1498b1be3b..6e5667419b 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -14,7 +14,7 @@ #include #include -#ifdef HAVE_NET +#ifdef DO_PSTATS #include #include #include @@ -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 diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index f644de3da8..66a54a9fed 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/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 ©) { //////////////////////////////////////////////////////////////////// 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 diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index 2b5c809a94..99e65322c2 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/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" diff --git a/panda/src/pstatclient/pStatThread.I b/panda/src/pstatclient/pStatThread.I index f0660dc038..45c72ed472 100644 --- a/panda/src/pstatclient/pStatThread.I +++ b/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 ©) { //////////////////////////////////////////////////////////////////// INLINE void PStatThread:: new_frame() { -#ifdef HAVE_NET +#ifdef DO_PSTATS _client->new_frame(_index); #endif } diff --git a/panda/src/pstatclient/pStatTimer.I b/panda/src/pstatclient/pStatTimer.I index 169ec1f649..42d561ceff 100644 --- a/panda/src/pstatclient/pStatTimer.I +++ b/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 diff --git a/panda/src/pstatclient/pStatTimer.h b/panda/src/pstatclient/pStatTimer.h index a52cda140a..113749f832 100644 --- a/panda/src/pstatclient/pStatTimer.h +++ b/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" diff --git a/panda/src/testbed/Sources.pp b/panda/src/testbed/Sources.pp index b3c23f2216..42cc569039 100644 --- a/panda/src/testbed/Sources.pp +++ b/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 diff --git a/pandatool/src/gtk-stats/Sources.pp b/pandatool/src/gtk-stats/Sources.pp index 77d0ac144c..d36970a555 100644 --- a/pandatool/src/gtk-stats/Sources.pp +++ b/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 diff --git a/pandatool/src/pstatserver/Sources.pp b/pandatool/src/pstatserver/Sources.pp index 9b666f7e60..8e4a720585 100644 --- a/pandatool/src/pstatserver/Sources.pp +++ b/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 diff --git a/pandatool/src/text-stats/Sources.pp b/pandatool/src/text-stats/Sources.pp index 072881e942..9c81b37c14 100644 --- a/pandatool/src/text-stats/Sources.pp +++ b/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