summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorTofu Linden <tofu.linden@lindenlab.com>2010-01-20 13:54:34 -0800
committerTofu Linden <tofu.linden@lindenlab.com>2010-01-20 13:54:34 -0800
commita65188d85f75e848d224bd335a00ed8aa51f945e (patch)
treef43b390cba45d047fc0fa31659f6969f62b925d1 /indra/llcommon
parent1a8008ea150d1eb9a8f4036988ef971fb1901cb3 (diff)
parent5ca943cd0279d35ffdf584fa0de3b795645f276c (diff)
Merge from viewer2. Minor conflict resolved.
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llfasttimer.h97
1 files changed, 66 insertions, 31 deletions
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 5058a2e772..8af79c90fd 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -1,11 +1,11 @@
-/**
+/**
* @file llfasttimer.h
* @brief Declaration of a fast timer.
*
* $LicenseInfo:firstyear=2004&license=viewergpl$
- *
+ *
* Copyright (c) 2004-2009, Linden Research, Inc.
- *
+ *
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
@@ -13,17 +13,17 @@
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
+ *
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
+ *
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
- *
+ *
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
@@ -39,42 +39,77 @@
#define TIME_FAST_TIMERS 0
#if LL_WINDOWS
+#define LL_INLINE __forceinline
+
+//
+// NOTE: put back in when we aren't using platform sdk anymore
+//
// because MS has different signatures for these functions in winnt.h
// need to rename them to avoid conflicts
-#define _interlockedbittestandset _renamed_interlockedbittestandset
-#define _interlockedbittestandreset _renamed_interlockedbittestandreset
-#include <intrin.h>
-#undef _interlockedbittestandset
-#undef _interlockedbittestandreset
+//#define _interlockedbittestandset _renamed_interlockedbittestandset
+//#define _interlockedbittestandreset _renamed_interlockedbittestandreset
+//#include <intrin.h>
+//#undef _interlockedbittestandset
+//#undef _interlockedbittestandreset
+
+//inline U32 get_cpu_clock_count_32()
+//{
+// U64 time_stamp = __rdtsc();
+// return (U32)(time_stamp >> 8);
+//}
+//
+//// return full timer value, *not* shifted by 8 bits
+//inline U64 get_cpu_clock_count_64()
+//{
+// return __rdtsc();
+//}
-#define LL_INLINE __forceinline
// shift off lower 8 bits for lower resolution but longer term timing
// on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing
inline U32 get_cpu_clock_count_32()
{
- U64 time_stamp = __rdtsc();
- return (U32)(time_stamp >> 8);
+ U32 ret_val;
+ __asm
+ {
+ _emit 0x0f
+ _emit 0x31
+ shr eax,8
+ shl edx,24
+ or eax, edx
+ mov dword ptr [ret_val], eax
+ }
+ return ret_val;
}
// return full timer value, *not* shifted by 8 bits
inline U64 get_cpu_clock_count_64()
{
- return __rdtsc();
+ U64 ret_val;
+ __asm
+ {
+ _emit 0x0f
+ _emit 0x31
+ mov eax,eax
+ mov edx,edx
+ mov dword ptr [ret_val+4], edx
+ mov dword ptr [ret_val], eax
+ }
+ return ret_val;
}
#else
#define LL_INLINE
-#endif // LL_WINDOWS
+#endif
#if (LL_LINUX || LL_SOLARIS || LL_DARWIN) && (defined(__i386__) || defined(__amd64__))
inline U32 get_cpu_clock_count_32()
-{
- U64 x;
- __asm__ volatile (".byte 0x0f, 0x31": "=A"(x));
- return (U32)x >> 8;
+{
+ U64 x;
+ __asm__ volatile (".byte 0x0f, 0x31": "=A"(x));
+ return (U32)x >> 8;
}
inline U32 get_cpu_clock_count_64()
-{
+{
U64 x;
__asm__ volatile (".byte 0x0f, 0x31": "=A"(x));
return x >> 8;
@@ -93,7 +128,7 @@ inline U32 get_cpu_clock_count_32()
}
inline U32 get_cpu_clock_count_64()
-{
+{
return get_clock_count();
}
#endif
@@ -123,7 +158,7 @@ public:
};
// stores a "named" timer instance to be reused via multiple LLFastTimer stack instances
- class LL_COMMON_API NamedTimer
+ class LL_COMMON_API NamedTimer
: public LLInstanceTracker<NamedTimer>
{
friend class DeclareTimer;
@@ -158,7 +193,7 @@ public:
FrameState& getFrameState() const;
- private:
+ private:
friend class LLFastTimer;
friend class NamedTimerFactory;
@@ -169,14 +204,14 @@ public:
// recursive call to gather total time from children
static void accumulateTimings();
- // updates cumulative times and hierarchy,
+ // updates cumulative times and hierarchy,
// can be called multiple times in a frame, at any point
static void processTimes();
static void buildHierarchy();
static void resetFrame();
static void reset();
-
+
//
// members
//
@@ -212,7 +247,7 @@ public:
private:
NamedTimer& mTimer;
- FrameState* mFrameState;
+ FrameState* mFrameState;
};
public:
@@ -232,7 +267,7 @@ public:
frame_state->mCalls++;
// keep current parent as long as it is active when we are
frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0);
-
+
LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData;
mLastTimerData = *cur_timer_data;
cur_timer_data->mCurTimer = this;
@@ -270,7 +305,7 @@ public:
U64 timer_end = get_cpu_clock_count_64();
sTimerCycles += timer_end - timer_start;
sTimerCalls++;
-#endif
+#endif
}
public:
@@ -286,13 +321,13 @@ public:
typedef std::vector<FrameState> info_list_t;
static info_list_t& getFrameStateList();
-
+
// call this once a frame to reset timers
static void nextFrame();
// dumps current cumulative frame stats to log
// call nextFrame() to reset timers
- static void dumpCurTimes();
+ static void dumpCurTimes();
// call this to reset timer hierarchy, averages, etc.
static void reset();