From ffa7123bb5187e1da491a8f475d696053d9c9ee4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 28 Jun 2013 20:45:20 -0700 Subject: SH-4299 FIX Interesting: High fps shown temporarily off scale in statistics console added ability to force uniqueness of LLCopyOnWritePointer converted more variables to units added convenience function for unit constants --- indra/llcommon/llfasttimer.cpp | 4 +- indra/llcommon/llpointer.h | 18 +++++++-- indra/llcommon/lltracerecording.cpp | 5 ++- indra/llcommon/lltracethreadrecorder.cpp | 8 ---- indra/llcommon/llunit.h | 68 +++++++++++++++++++------------- 5 files changed, 61 insertions(+), 42 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 60c451b137..23e27622bf 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -386,7 +386,7 @@ void TimeBlock::dumpCurTimes() U32 num_calls = last_frame_recording.getSum(timerp->callCount()); // Don't bother with really brief times, keep output concise - if (total_time < LLUnit(0.1)) continue; + if (total_time < LLUnits::Milliseconds::fromValue(0.1f)) continue; std::ostringstream out_str; TimeBlock* parent_timerp = timerp; @@ -397,7 +397,7 @@ void TimeBlock::dumpCurTimes() } out_str << timerp->getName() << " " - << std::setprecision(3) << total_time.getAs() << " ms, " + << std::setprecision(3) << total_time.valueAs() << " ms, " << num_calls << " calls"; llinfos << out_str.str() << llendl; diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 6a0a8fcb0d..c827996db1 100755 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -173,15 +173,23 @@ public: typedef LLPointer pointer_t; LLCopyOnWritePointer() + : mStayUnique(false) {} LLCopyOnWritePointer(Type* ptr) - : LLPointer(ptr) + : LLPointer(ptr), + mStayUnique(false) {} LLCopyOnWritePointer(LLPointer& ptr) - : LLPointer(ptr) - {} + : LLPointer(ptr), + mStayUnique(false) + { + if (ptr.mForceUnique) + { + makeUnique(); + } + } Type* write() { @@ -199,6 +207,10 @@ public: const Type* operator->() const { return pointer_t::mPointer; } const Type& operator*() const { return *pointer_t::mPointer; } + + void setStayUnique(bool stay) { makeUnique(); mStayUnique = stay; } +private: + bool mStayUnique; }; #endif diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 0938317eaa..f1388e7935 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -100,14 +100,15 @@ void Recording::handleReset() void Recording::handleStart() { mSamplingTimer.reset(); + mBuffers.setStayUnique(true); LLTrace::get_thread_recorder()->activate(mBuffers.write()); } void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - AccumulatorBufferGroup* buffers = mBuffers.write(); - LLTrace::get_thread_recorder()->deactivate(buffers); + LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); + mBuffers.setStayUnique(false); } void Recording::handleSplitTo(Recording& other) diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 7192564c94..d0f0328d1c 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -99,14 +99,6 @@ TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode( S32 index ) void ThreadRecorder::activate( AccumulatorBufferGroup* recording ) { - active_recording_list_t::reverse_iterator it, end_it; - for (it = mActiveRecordings.rbegin(), end_it = mActiveRecordings.rend(); - it != end_it; - ++it) - { - llassert((*it)->mTargetRecording != recording); - } - ActiveRecording* active_recording = new ActiveRecording(recording); if (!mActiveRecordings.empty()) { diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 2402cdbb95..c9bbed5574 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -75,17 +75,11 @@ struct LLUnit } template - STORAGE_TYPE getAs() + STORAGE_TYPE valueAs() { return LLUnit(*this).value(); } - template - STORAGE_TYPE setAs(STORAGE_TYPE val) - { - *this = LLUnit(val); - } - void operator += (storage_t value) { mValue += value; @@ -181,6 +175,7 @@ LL_FORCE_INLINE void ll_convert_units(LLUnit in, LLUnit& out, .. if (boost::is_same::value) { if (boost::is_same::value) + { // T1 and T2 fully reduced and equal...just copy out = (S2)in.value(); @@ -493,26 +488,45 @@ struct LLUnitInverseLinearOps } }; -#define LL_DECLARE_BASE_UNIT(base_unit_name, unit_label) \ -struct base_unit_name { typedef base_unit_name base_unit_t; static const char* getUnitLabel() { return unit_label; }} - -#define LL_DECLARE_DERIVED_UNIT(unit_name, unit_label, base_unit_name, conversion_operation) \ -struct unit_name \ -{ \ - typedef base_unit_name base_unit_t; \ - static const char* getUnitLabel() { return unit_label; } \ -}; \ - \ -template \ -void ll_convert_units(LLUnit in, LLUnit& out) \ -{ \ - out = (S2)(LLUnitLinearOps(in.value()) conversion_operation).mValue; \ -} \ - \ -template \ -void ll_convert_units(LLUnit in, LLUnit& out) \ -{ \ - out = (S2)(LLUnitInverseLinearOps(in.value()) conversion_operation).mValue; \ +#define LL_DECLARE_BASE_UNIT(base_unit_name, unit_label) \ +struct base_unit_name \ +{ \ + typedef base_unit_name base_unit_t; \ + static const char* getUnitLabel() { return unit_label; } \ + template \ + static LLUnit fromValue(T value) { return LLUnit(value); } \ + template \ + static LLUnit fromValue(LLUnit value) \ + { return LLUnit(value); } \ +}; \ +template std::ostream& operator<<(std::ostream& s, const LLUnit& val) \ +{ s << val.value() << base_unit_name::getUnitLabel; return s; } + + +#define LL_DECLARE_DERIVED_UNIT(unit_name, unit_label, base_unit_name, conversion_operation) \ +struct unit_name \ +{ \ + typedef base_unit_name base_unit_t; \ + static const char* getUnitLabel() { return unit_label; } \ + template \ + static LLUnit fromValue(T value) { return LLUnit(value); } \ + template \ + static LLUnit fromValue(LLUnit value) \ + { return LLUnit(value); } \ +}; \ +template std::ostream& operator<<(std::ostream& s, const LLUnit& val) \ +{ s << val.value() << unit_name::getUnitLabel; return s; } \ + \ +template \ +void ll_convert_units(LLUnit in, LLUnit& out) \ +{ \ + out = (S2)(LLUnitLinearOps(in.value()) conversion_operation).mValue; \ +} \ + \ +template \ +void ll_convert_units(LLUnit in, LLUnit& out) \ +{ \ + out = (S2)(LLUnitInverseLinearOps(in.value()) conversion_operation).mValue; \ } // -- cgit v1.3