From ed17c181dd37f56b808838748d289ee7bb5567ec Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 7 Nov 2012 15:32:12 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct further fixes to implicit conversion of unit types --- indra/llcommon/lldate.cpp | 11 +-- indra/llcommon/lldate.h | 3 +- indra/llcommon/lltimer.cpp | 15 ++-- indra/llcommon/lltimer.h | 21 +++--- indra/llcommon/lltracerecording.cpp | 19 +++++ indra/llcommon/lltracerecording.h | 18 +---- indra/llcommon/llunit.h | 141 +++++++++--------------------------- indra/llmath/v4color.h | 6 +- indra/llui/llnotifications.cpp | 2 +- indra/newview/llviewertexture.cpp | 4 +- 10 files changed, 86 insertions(+), 154 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index 030ef6a3c7..d8b3dfe6c6 100644 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -48,18 +48,15 @@ static const F64 LL_APR_USEC_PER_SEC = 1000000.0; LLDate::LLDate() : mSecondsSinceEpoch(DATE_EPOCH) -{ -} +{} LLDate::LLDate(const LLDate& date) : mSecondsSinceEpoch(date.mSecondsSinceEpoch) -{ -} +{} -LLDate::LLDate(F64 seconds_since_epoch) : +LLDate::LLDate(LLUnit::Seconds seconds_since_epoch) : mSecondsSinceEpoch(seconds_since_epoch) -{ -} +{} LLDate::LLDate(const std::string& iso8601_date) { diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 7ff8b550ad..0500b1dcd8 100644 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -33,6 +33,7 @@ #include #include "stdtypes.h" +#include "llunit.h" /** * @class LLDate @@ -58,7 +59,7 @@ public: * * @pararm seconds_since_epoch The number of seconds since UTC epoch. */ - LLDate(F64 seconds_since_epoch); + LLDate(LLUnit::Seconds seconds_since_epoch); /** * @brief Construct a date from a string representation diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 9ebc6de7f4..05f6b789e4 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -287,14 +287,15 @@ LLTimer::~LLTimer() } // static -U64 LLTimer::getTotalTime() +LLUnit::Microseconds LLTimer::getTotalTime() { + LLUnit::Seconds sec = LLUnit::Milliseconds(2000) + LLUnit::Hours(1.f / 360.f); // simply call into the implementation function. return totalTime(); } // static -F64 LLTimer::getTotalSeconds() +LLUnit::Seconds LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -343,23 +344,23 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -F64 LLTimer::getElapsedTimeF64() const +LLUnit::Seconds LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeF32() const +LLUnit::Seconds LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -F64 LLTimer::getElapsedTimeAndResetF64() +LLUnit::Seconds LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -F32 LLTimer::getElapsedTimeAndResetF32() +LLUnit::Seconds LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } @@ -372,7 +373,7 @@ void LLTimer::setTimerExpirySec(F32 expiration) + (U64)((F32)(expiration * gClockFrequency)); } -F32 LLTimer::getRemainingTimeF32() const +LLUnit::Seconds LLTimer::getRemainingTimeF32() const { U64 cur_ticks = get_clock_count(); if (cur_ticks > mExpirationTicks) diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 513de0605d..e0a880a346 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -37,6 +37,7 @@ #include #include // units conversions +#include "llunit.h" #ifndef USEC_PER_SEC const U32 USEC_PER_SEC = 1000000; #endif @@ -55,7 +56,7 @@ public: protected: U64 mLastClockCount; U64 mExpirationTicks; - BOOL mStarted; + bool mStarted; public: LLTimer(); @@ -66,16 +67,16 @@ public: // Return a high precision number of seconds since the start of // this application instance. - static F64 getElapsedSeconds() + static LLUnit::Seconds getElapsedSeconds() { return sTimer->getElapsedTimeF64(); } // Return a high precision usec since epoch - static U64 getTotalTime(); + static LLUnit::Microseconds getTotalTime(); // Return a high precision seconds since epoch - static F64 getTotalSeconds(); + static LLUnit::Seconds getTotalSeconds(); // MANIPULATORS @@ -86,18 +87,18 @@ public: void setTimerExpirySec(F32 expiration); BOOL checkExpirationAndReset(F32 expiration); BOOL hasExpired() const; - F32 getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset - F64 getElapsedTimeAndResetF64(); + LLUnit::Seconds getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset + LLUnit::Seconds getElapsedTimeAndResetF64(); - F32 getRemainingTimeF32() const; + LLUnit::Seconds getRemainingTimeF32() const; static BOOL knownBadTimer(); // ACCESSORS - F32 getElapsedTimeF32() const; // Returns elapsed time in seconds - F64 getElapsedTimeF64() const; // Returns elapsed time in seconds + LLUnit::Seconds getElapsedTimeF32() const; // Returns elapsed time in seconds + LLUnit::Seconds getElapsedTimeF64() const; // Returns elapsed time in seconds - BOOL getStarted() const { return mStarted; } + bool getStarted() const { return mStarted; } static U64 getCurrentClockCount(); // Returns the raw clockticks diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 435c49106f..4252ed57dc 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -46,6 +46,25 @@ Recording::Recording() mStackTimers(new AccumulatorBuffer()) {} +Recording::Recording( const Recording& other ) +{ + llassert(other.mCountsFloat.get() != NULL); + mSamplingTimer = other.mSamplingTimer; + mElapsedSeconds = other.mElapsedSeconds; + mCountsFloat = other.mCountsFloat; + mMeasurementsFloat = other.mMeasurementsFloat; + mCounts = other.mCounts; + mMeasurements = other.mMeasurements; + mStackTimers = other.mStackTimers; + + LLStopWatchControlsMixin::initTo(other.getPlayState()); + if (other.isStarted()) + { + handleStart(); + } +} + + Recording::~Recording() {} diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 31901b599c..fc96631ce0 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -106,23 +106,7 @@ namespace LLTrace public: Recording(); - Recording(const Recording& other) - { - mSamplingTimer = other.mSamplingTimer; - mElapsedSeconds = other.mElapsedSeconds; - mCountsFloat = other.mCountsFloat; - mMeasurementsFloat = other.mMeasurementsFloat; - mCounts = other.mCounts; - mMeasurements = other.mMeasurements; - mStackTimers = other.mStackTimers; - - LLStopWatchControlsMixin::initTo(other.getPlayState()); - if (other.isStarted()) - { - handleStart(); - } - - } + Recording(const Recording& other); ~Recording(); void makePrimary(); diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 98e4de32fa..4519905707 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -51,6 +51,11 @@ struct LLUnitType : public BASE_UNIT return static_cast(*this); } + operator storage_t () const + { + return value(); + } + storage_t value() const { return convertToDerived(mBaseValue); @@ -102,6 +107,11 @@ struct LLUnitType return static_cast(*this); } + operator storage_t () const + { + return value(); + } + storage_t value() const { return mBaseValue; } template @@ -110,7 +120,6 @@ struct LLUnitType return CONVERTED_TYPE(*this).value(); } - static storage_t convertToBase(storage_t derived_value) { return (storage_t)derived_value; @@ -150,99 +159,77 @@ protected: storage_t mBaseValue; }; -// -// operator + -// template -DERIVED_UNIT operator + (typename LLUnitType::storage_t first, LLUnitType second) +struct LLUnitTypeWrapper +: public LLUnitType { - return DERIVED_UNIT(first + second.value()); -} + typedef LLUnitType unit_t; + LLUnitTypeWrapper(const unit_t& other) + : unit_t(other) + {} +}; -template -DERIVED_UNIT operator + (LLUnitType first, typename LLUnitType::storage_t second) -{ - return DERIVED_UNIT(first.value() + second); -} -template -DERIVED_UNIT operator + (LLUnitType first, LLUnitType second) +// +// operator + +// +template +DERIVED_UNIT operator + (typename LLUnitType::storage_t first, LLUnitType second) { - return DERIVED_UNIT(first.value() + second.value()); + return DERIVED_UNIT(first + LLUnitType(second).value()); } + // // operator - // -template +template DERIVED_UNIT operator - (typename LLUnitType::storage_t first, LLUnitType second) { - return DERIVED_UNIT(first - second.value()); -} - -template -DERIVED_UNIT operator - (LLUnitType first, typename LLUnitType::storage_t second) -{ - return DERIVED_UNIT(first.value() - second); -} - -template -DERIVED_UNIT operator - (LLUnitType first, LLUnitType second) -{ - return DERIVED_UNIT(first.value() - second.value()); + return DERIVED_UNIT(first - LLUnitType(second).value()); } // // operator * // template -DERIVED_UNIT operator * (typename LLUnitType::storage_t first, LLUnitType second) +DERIVED_UNIT operator * (STORAGE_TYPE first, LLUnitType second) { return DERIVED_UNIT(first * second.value()); } template -DERIVED_UNIT operator * (LLUnitType first, typename LLUnitType::storage_t second) +DERIVED_UNIT operator * (LLUnitType first, STORAGE_TYPE second) { return DERIVED_UNIT(first.value() * second); } + // // operator / // template -DERIVED_UNIT operator / (typename LLUnitType::storage_t first, LLUnitType second) +DERIVED_UNIT operator / (STORAGE_TYPE first, LLUnitTypeWrapper second) { - return DERIVED_UNIT(first * second.value()); + return DERIVED_UNIT(first / second.value()); } template -DERIVED_UNIT operator / (LLUnitType first, typename LLUnitType::storage_t second) +DERIVED_UNIT operator / (LLUnitTypeWrapper first, STORAGE_TYPE second) { - return DERIVED_UNIT(first.value() * second); + return DERIVED_UNIT(first.value() / second); } // // operator < // -template +template + bool operator < (typename LLUnitType::storage_t first, LLUnitType second) { return first < second.value(); } -template -bool operator < (LLUnitType first, typename LLUnitType::storage_t second) -{ - return first.value() < second; -} - -template -bool operator < (LLUnitType first, LLUnitType second) -{ - return first.value() < second.value(); -} - // // operator <= // @@ -252,17 +239,6 @@ bool operator <= (typename LLUnitType::st return first <= second.value(); } -template -bool operator <= (LLUnitType first, typename LLUnitType::storage_t second) -{ - return first.value() <= second; -} - -template -bool operator <= (LLUnitType first, LLUnitType second) -{ - return first.value() <= second.value(); -} // // operator > @@ -273,17 +249,6 @@ bool operator > (typename LLUnitType::sto return first > second.value(); } -template -bool operator > (LLUnitType first, typename LLUnitType::storage_t second) -{ - return first.value() > second; -} - -template -bool operator > (LLUnitType first, LLUnitType second) -{ - return first.value() > second.value(); -} // // operator >= // @@ -293,18 +258,6 @@ bool operator >= (typename LLUnitType::st return first >= second.value(); } -template -bool operator >= (LLUnitType first, typename LLUnitType::storage_t second) -{ - return first.value() >= second; -} - -template -bool operator >= (LLUnitType first, LLUnitType second) -{ - return first.value() >= second.value(); -} - // // operator == // @@ -314,18 +267,6 @@ bool operator == (typename LLUnitType::st return first == second.value(); } -template -bool operator == (LLUnitType first, typename LLUnitType::storage_t second) -{ - return first.value() == second; -} - -template -bool operator == (LLUnitType first, LLUnitType second) -{ - return first.value() == second.value(); -} - // // operator != // @@ -335,18 +276,6 @@ bool operator != (typename LLUnitType::st return first != second.value(); } -template -bool operator != (LLUnitType first, typename LLUnitType::storage_t second) -{ - return first.value() != second; -} - -template -bool operator != (LLUnitType first, LLUnitType second) -{ - return first.value() != second.value(); -} - #define LL_DECLARE_BASE_UNIT(unit_name) \ template \ struct unit_name : public LLUnitType, unit_name > \ diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index b047f86e6e..78223e1e65 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -49,9 +49,9 @@ class LLColor4 LLColor4(); // Initializes LLColor4 to (0, 0, 0, 1) LLColor4(F32 r, F32 g, F32 b); // Initializes LLColor4 to (r, g, b, 1) LLColor4(F32 r, F32 g, F32 b, F32 a); // Initializes LLColor4 to (r. g, b, a) - LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc)) - LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) - LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) + explicit LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc)) + explicit LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) + explicit LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) explicit LLColor4(const LLSD& sd); explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index 629eef2c3b..118c74b9b2 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -464,7 +464,7 @@ LLNotification::LLNotification(const LLNotification::Params& p) : mTimestamp(p.time_stamp), mSubstitutions(p.substitutions), mPayload(p.payload), - mExpiresAt(0), + mExpiresAt(0.0), mTemporaryResponder(false), mRespondedTo(false), mPriority(p.priority), diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index f64134b8b7..ceb8d3155c 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -533,7 +533,7 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity sTotalTextureMemory >= sMaxTotalTextureMem) { //when texture memory overflows, lower down the threashold to release the textures more aggressively. - sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, (LLUnit::Bytes)gMaxVideoRam) ;//512 MB + sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit::Bytes(gMaxVideoRam)); // If we are using more texture memory than we should, // scale up the desired discard level @@ -3312,7 +3312,7 @@ void LLViewerLODTexture::processTextureStats() scaleDown() ; } // Only allow GL to have 2x the video card memory - else if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale && + else if ( sTotalTextureMemory > sMaxTotalTextureMem * texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { scaleDown() ; -- cgit v1.2.3