summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichard <none@none>2009-12-21 17:32:21 -0800
committerrichard <none@none>2009-12-21 17:32:21 -0800
commit2c42062c107c1299e6cf5ea2a689cfb2a2e575e5 (patch)
tree83bfe39c6c05a83d4aa3c9f0dbd2944ebff77630
parent470dba630b2a161e786d5fec9488a25fdbd43f13 (diff)
parent093795c10c9a15f293416467bf686f87f0fdbc8b (diff)
merge
-rw-r--r--indra/llcommon/llfasttimer.h27
-rw-r--r--indra/llui/llui.cpp16
-rw-r--r--indra/newview/llfasttimerview.cpp16
-rw-r--r--indra/newview/llfasttimerview.h1
4 files changed, 46 insertions, 14 deletions
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 45b84ea3ea..f5c90291b8 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -36,6 +36,7 @@
#include "llinstancetracker.h"
#define FAST_TIMER_ON 1
+#define TIME_FAST_TIMERS 0
#if LL_WINDOWS
@@ -56,7 +57,7 @@ inline U32 get_cpu_clock_count_32()
return ret_val;
}
-// return full timer value, still shifted by 8 bits
+// return full timer value, *not* shifted by 8 bits
inline U64 get_cpu_clock_count_64()
{
U64 ret_val;
@@ -69,7 +70,7 @@ inline U64 get_cpu_clock_count_64()
mov dword ptr [ret_val+4], edx
mov dword ptr [ret_val], eax
}
- return ret_val >> 8;
+ return ret_val;
}
#endif // LL_WINDOWS
@@ -242,6 +243,9 @@ public:
LLFastTimer(NamedTimer::FrameState& timer)
: mFrameState(&timer)
{
+#if TIME_FAST_TIMERS
+ U64 timer_start = get_cpu_clock_count_64();
+#endif
#if FAST_TIMER_ON
NamedTimer::FrameState* frame_state = &timer;
U32 cur_time = get_cpu_clock_count_32();
@@ -256,10 +260,17 @@ public:
mLastTimer = sCurTimer;
sCurTimer = this;
#endif
+#if TIME_FAST_TIMERS
+ U64 timer_end = get_cpu_clock_count_64();
+ sTimerCycles += timer_end - timer_start;
+#endif
}
~LLFastTimer()
{
+#if TIME_FAST_TIMERS
+ U64 timer_start = get_cpu_clock_count_64();
+#endif
#if FAST_TIMER_ON
NamedTimer::FrameState* frame_state = mFrameState;
U32 cur_time = get_cpu_clock_count_32();
@@ -276,6 +287,11 @@ public:
U32 total_time = cur_time - mStartTotalTime;
last_timer->mStartSelfTime += total_time;
#endif
+#if TIME_FAST_TIMERS
+ U64 timer_end = get_cpu_clock_count_64();
+ sTimerCycles += timer_end - timer_start;
+ sTimerCalls++;
+#endif
}
@@ -297,11 +313,12 @@ public:
static const NamedTimer* getTimerByName(const std::string& name);
public:
- static bool sPauseHistory;
- static bool sResetHistory;
+ static bool sPauseHistory;
+ static bool sResetHistory;
+ static U64 sTimerCycles;
+ static U32 sTimerCalls;
private:
- typedef std::vector<LLFastTimer*> timer_stack_t;
static LLFastTimer* sCurTimer;
static S32 sCurFrameIndex;
static S32 sLastFrameIndex;
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 728ed4e7aa..d0ed3b6fca 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -2047,12 +2047,16 @@ namespace LLInitParam
void TypedParam<LLRect>::setBlockFromValue()
{
- left = mData.mValue.mLeft;
- right = mData.mValue.mRight;
- bottom = mData.mValue.mBottom;
- top = mData.mValue.mTop;
- width.setProvided(false);
- height.setProvided(false);
+ // because of the ambiguity in specifying a rect by position and/or dimensions
+ // we clear the "provided" flag so that values from xui/etc have priority
+ // over those calculated from the rect object
+
+ left.set(mData.mValue.mLeft, false);
+ right.set(mData.mValue.mRight, false);
+ bottom.set(mData.mValue.mBottom, false);
+ top.set(mData.mValue.mTop, false);
+ width.set(mData.mValue.getWidth(), false);
+ height.set(mData.mValue.getHeight(), false);
}
TypedParam<LLCoordGL>::TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 0b27001f10..effa57b1ef 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -98,6 +98,7 @@ LLFastTimerView::LLFastTimerView(const LLRect& rect)
mHoverBarIndex = -1;
FTV_NUM_TIMERS = LLFastTimer::NamedTimer::instanceCount();
mPrintStats = -1;
+ mAverageCyclesPerTimer = 0;
}
@@ -306,8 +307,9 @@ void LLFastTimerView::draw()
S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f);
S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f);
- // HACK: casting away const. Should use setRect or some helper function instead.
- const_cast<LLRect&>(getRect()).setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
+ LLRect new_rect;
+ new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
+ setRect(new_rect);
S32 left, top, right, bottom;
S32 x, y, barw, barh, dx, dy;
@@ -321,6 +323,10 @@ void LLFastTimerView::draw()
S32 xleft = margin;
S32 ytop = margin;
+ mAverageCyclesPerTimer = llround(lerp((F32)mAverageCyclesPerTimer, (F32)(LLFastTimer::sTimerCycles / (U64)LLFastTimer::sTimerCalls), 0.1f));
+ LLFastTimer::sTimerCycles = 0;
+ LLFastTimer::sTimerCalls = 0;
+
// Draw some help
{
@@ -328,6 +334,10 @@ void LLFastTimerView::draw()
y = height - ytop;
texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
+#if TIME_FAST_TIMERS
+ tdesc = llformat("Cycles per timer call: %d", mAverageCyclesPerTimer);
+ LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+#else
char modedesc[][32] = {
"2 x Average ",
"Max ",
@@ -342,7 +352,6 @@ void LLFastTimerView::draw()
tdesc = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]);
LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-
textw = LLFontGL::getFontMonospace()->getWidth(tdesc);
x = xleft, y -= (texth + 2);
@@ -352,6 +361,7 @@ void LLFastTimerView::draw()
LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"),
0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+#endif
y -= (texth + 2);
}
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 2bb023ab14..f5c8f23818 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -91,6 +91,7 @@ private:
S32 mHoverBarIndex;
LLFrameTimer mHighlightTimer;
S32 mPrintStats;
+ S32 mAverageCyclesPerTimer;
};
#endif