From 0bb0bd514b235948c1a21c81ab0e8ab6223b1990 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 8 Nov 2012 23:42:18 -0800 Subject: SH-3499 WIP Ensure asset stats output is correct Finished making LLUnit implicitly convertible to/from scalar integer values cleaned up test code --- indra/llcommon/lldate.cpp | 4 +- indra/llcommon/lldate.h | 4 +- indra/llcommon/lldefs.h | 3 + indra/llcommon/llerrorlegacy.h | 7 + indra/llcommon/lltimer.cpp | 15 +- indra/llcommon/lltimer.h | 16 +- indra/llcommon/lltrace.h | 54 +++-- indra/llcommon/lltracerecording.h | 2 +- indra/llcommon/llunit.h | 404 ++++++++++++++++------------------- indra/llmath/v4color.h | 6 +- indra/llrender/llimagegl.cpp | 6 +- indra/llrender/llimagegl.h | 6 +- indra/newview/llappviewer.cpp | 2 +- indra/newview/llappviewer.h | 2 +- indra/newview/lldrawpoolwater.cpp | 2 +- indra/newview/lltextureview.cpp | 18 +- indra/newview/llviewerassetstats.cpp | 4 +- indra/newview/llviewermessage.cpp | 20 +- indra/newview/llviewerstats.cpp | 6 +- indra/newview/llviewerstats.h | 6 +- indra/newview/llviewertexture.cpp | 18 +- indra/newview/llviewertexture.h | 14 +- indra/newview/llviewerwindow.cpp | 2 +- 23 files changed, 295 insertions(+), 326 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index d8b3dfe6c6..5569b4102d 100644 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -54,8 +54,8 @@ LLDate::LLDate(const LLDate& date) : mSecondsSinceEpoch(date.mSecondsSinceEpoch) {} -LLDate::LLDate(LLUnit::Seconds seconds_since_epoch) : - mSecondsSinceEpoch(seconds_since_epoch) +LLDate::LLDate(LLUnit seconds_since_epoch) : + mSecondsSinceEpoch(seconds_since_epoch.value()) {} LLDate::LLDate(const std::string& iso8601_date) diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 0500b1dcd8..b62a846147 100644 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -57,9 +57,9 @@ public: /** * @brief Construct a date from a seconds since epoch value. * - * @pararm seconds_since_epoch The number of seconds since UTC epoch. + * @param seconds_since_epoch The number of seconds since UTC epoch. */ - LLDate(LLUnit::Seconds seconds_since_epoch); + LLDate(LLUnit seconds_since_epoch); /** * @brief Construct a date from a string representation diff --git a/indra/llcommon/lldefs.h b/indra/llcommon/lldefs.h index 5a4b8325f4..d57b9dccff 100644 --- a/indra/llcommon/lldefs.h +++ b/indra/llcommon/lldefs.h @@ -244,5 +244,8 @@ inline void llswap(LLDATATYPE& lhs, LLDATATYPE& rhs) rhs = tmp; } +#define LL_GLUE_IMPL(x, y) x##y +#define LL_GLUE_TOKENS(x, y) LL_GLUE_IMPL(x, y) + #endif // LL_LLDEFS_H diff --git a/indra/llcommon/llerrorlegacy.h b/indra/llcommon/llerrorlegacy.h index 37cee579cd..58cc2899af 100644 --- a/indra/llcommon/llerrorlegacy.h +++ b/indra/llcommon/llerrorlegacy.h @@ -29,6 +29,7 @@ #define LL_LLERRORLEGACY_H #include "llpreprocessor.h" +#include /* LEGACY -- DO NOT USE THIS STUFF ANYMORE @@ -111,6 +112,12 @@ const int LL_ERR_PRICE_MISMATCH = -23018; #define llverify(func) do {if (func) {}} while(0) #endif +#ifdef LL_WINDOWS +#define llstatic_assert(func, msg) static_assert(func, msg) +#else +#define llstatic_assert(func, msg) BOOST_STATIC_ASSERT(func) +#endif + // handy compile-time assert - enforce those template parameters! #define cassert(expn) typedef char __C_ASSERT__[(expn)?1:-1] /* Flawfinder: ignore */ //XXX: used in two places in llcommon/llskipmap.h diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 05f6b789e4..23cebf4336 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -287,15 +287,14 @@ LLTimer::~LLTimer() } // static -LLUnit::Microseconds LLTimer::getTotalTime() +LLUnit LLTimer::getTotalTime() { - LLUnit::Seconds sec = LLUnit::Milliseconds(2000) + LLUnit::Hours(1.f / 360.f); // simply call into the implementation function. return totalTime(); } // static -LLUnit::Seconds LLTimer::getTotalSeconds() +LLUnit LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -344,23 +343,23 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -LLUnit::Seconds LLTimer::getElapsedTimeF64() const +LLUnit LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -LLUnit::Seconds LLTimer::getElapsedTimeF32() const +LLUnit LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -LLUnit::Seconds LLTimer::getElapsedTimeAndResetF64() +LLUnit LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -LLUnit::Seconds LLTimer::getElapsedTimeAndResetF32() +LLUnit LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } @@ -373,7 +372,7 @@ void LLTimer::setTimerExpirySec(F32 expiration) + (U64)((F32)(expiration * gClockFrequency)); } -LLUnit::Seconds LLTimer::getRemainingTimeF32() const +LLUnit 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 e0a880a346..5cb2b18111 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -67,16 +67,16 @@ public: // Return a high precision number of seconds since the start of // this application instance. - static LLUnit::Seconds getElapsedSeconds() + static LLUnit getElapsedSeconds() { return sTimer->getElapsedTimeF64(); } // Return a high precision usec since epoch - static LLUnit::Microseconds getTotalTime(); + static LLUnit getTotalTime(); // Return a high precision seconds since epoch - static LLUnit::Seconds getTotalSeconds(); + static LLUnit getTotalSeconds(); // MANIPULATORS @@ -87,16 +87,16 @@ public: void setTimerExpirySec(F32 expiration); BOOL checkExpirationAndReset(F32 expiration); BOOL hasExpired() const; - LLUnit::Seconds getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset - LLUnit::Seconds getElapsedTimeAndResetF64(); + LLUnit getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset + LLUnit getElapsedTimeAndResetF64(); - LLUnit::Seconds getRemainingTimeF32() const; + LLUnit getRemainingTimeF32() const; static BOOL knownBadTimer(); // ACCESSORS - LLUnit::Seconds getElapsedTimeF32() const; // Returns elapsed time in seconds - LLUnit::Seconds getElapsedTimeF64() const; // Returns elapsed time in seconds + LLUnit getElapsedTimeF32() const; // Returns elapsed time in seconds + LLUnit getElapsedTimeF64() const; // Returns elapsed time in seconds bool getStarted() const { return mStarted; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index e2530a8a24..d289ea9a88 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -38,37 +38,35 @@ #include -#define LL_TOKEN_PASTE_ACTUAL(x, y) x##y -#define LL_TOKEN_PASTE(x, y) LL_TOKEN_PASTE_ACTUAL(x, y) -#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder LL_TOKEN_PASTE(block_time_recorder, __COUNTER__)(block_timer); +#define LL_RECORD_BLOCK_TIME(block_timer) LLTrace::BlockTimer::Recorder LL_GLUE_TOKENS(block_time_recorder, __COUNTER__)(block_timer); namespace LLTrace { class Recording; - typedef LLUnit::Bytes Bytes; - typedef LLUnit::Kilobytes Kilobytes; - typedef LLUnit::Megabytes Megabytes; - typedef LLUnit::Gigabytes Gigabytes; - typedef LLUnit::Bits Bits; - typedef LLUnit::Kilobits Kilobits; - typedef LLUnit::Megabits Megabits; - typedef LLUnit::Gigabits Gigabits; - - typedef LLUnit::Seconds Seconds; - typedef LLUnit::Milliseconds Milliseconds; - typedef LLUnit::Minutes Minutes; - typedef LLUnit::Hours Hours; - typedef LLUnit::Days Days; - typedef LLUnit::Weeks Weeks; - typedef LLUnit::Milliseconds Milliseconds; - typedef LLUnit::Microseconds Microseconds; - typedef LLUnit::Nanoseconds Nanoseconds; - - typedef LLUnit::Meters Meters; - typedef LLUnit::Kilometers Kilometers; - typedef LLUnit::Centimeters Centimeters; - typedef LLUnit::Millimeters Millimeters; + typedef LLUnit Bytes; + typedef LLUnit Kilobytes; + typedef LLUnit Megabytes; + typedef LLUnit Gigabytes; + typedef LLUnit Bits; + typedef LLUnit Kilobits; + typedef LLUnit Megabits; + typedef LLUnit Gigabits; + + typedef LLUnit Seconds; + typedef LLUnit Milliseconds; + typedef LLUnit Minutes; + typedef LLUnit Hours; + typedef LLUnit Days; + typedef LLUnit Weeks; + typedef LLUnit Milliseconds; + typedef LLUnit Microseconds; + typedef LLUnit Nanoseconds; + + typedef LLUnit Meters; + typedef LLUnit Kilometers; + typedef LLUnit Centimeters; + typedef LLUnit Millimeters; void init(); void cleanup(); @@ -438,7 +436,7 @@ namespace LLTrace void sample(UNIT_T value) { T converted_value; - converted_value.assignFrom(value); + converted_value = value; getPrimaryAccumulator().sample((storage_t)converted_value.value()); } }; @@ -478,7 +476,7 @@ namespace LLTrace void add(UNIT_T value) { T converted_value; - converted_value.assignFrom(value); + converted_value = value; getPrimaryAccumulator().add((storage_t)converted_value.value()); } }; diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index fc96631ce0..ca9950b78d 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -197,7 +197,7 @@ namespace LLTrace U32 getSampleCount(const TraceType >& stat) const; U32 getSampleCount(const TraceType >& stat) const; - LLUnit::Seconds getDuration() const { return mElapsedSeconds; } + LLUnit getDuration() const { return mElapsedSeconds; } private: friend class ThreadRecorder; diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 4519905707..0dcafbe26e 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -30,326 +30,288 @@ #include "stdtypes.h" #include "llpreprocessor.h" -template -struct LLUnitType : public BASE_UNIT +namespace LLUnits { - typedef DERIVED_UNIT unit_t; - - typedef typename STORAGE_TYPE storage_t; - typedef void is_unit_tag_t; - - LLUnitType() - {} - - LLUnitType(storage_t value) - : BASE_UNIT(convertToBase(value)) - {} - - // implicit downcast - operator unit_t& () - { - return static_cast(*this); - } - - operator storage_t () const - { - return value(); - } - - storage_t value() const - { - return convertToDerived(mBaseValue); - } - - template - storage_t as() const - { - return CONVERTED_TYPE(*this).value(); - } - -protected: - static storage_t convertToBase(storage_t derived_value) - { - return (storage_t)((F32)derived_value * unit_t::conversionToBaseFactor()); - } - - static storage_t convertToDerived(storage_t base_value) +template +struct ConversionFactor +{ + static F64 get() { - return (storage_t)((F32)base_value / unit_t::conversionToBaseFactor()); + llstatic_assert(sizeof(DERIVED_UNITS_TAG) == 0, "Cannot convert between types."); } +}; +template +struct ConversionFactor +{ + static F64 get() { return 1.0; } }; +} -template -struct LLUnitType +template +struct LLUnit { - typedef T unit_t; - typedef STORAGE_TYPE storage_t; + typedef LLUnit self_t; + typedef typename STORAGE_TYPE storage_t; typedef void is_unit_tag_t; - LLUnitType() - : mBaseValue() + LLUnit(storage_t value = storage_t()) + : mValue(value) {} - LLUnitType(storage_t value) - : mBaseValue(value) + template + LLUnit(LLUnit other) + : mValue(convert(other)) {} - unit_t& operator=(storage_t value) + LLUnit(self_t& other) + : mValue(other.mValue) + {} + + self_t& operator = (storage_t value) { - setBaseValue(value); + mValue = value; return *this; } - //implicit downcast - operator unit_t& () + template + self_t& operator = (LLUnit other) { - return static_cast(*this); + mValue = convert(other); + return *this; } - operator storage_t () const + operator storage_t() const { return value(); } - storage_t value() const { return mBaseValue; } - - template - storage_t as() const + storage_t value() const { - return CONVERTED_TYPE(*this).value(); + return mValue; } - static storage_t convertToBase(storage_t derived_value) + void operator += (storage_t value) { - return (storage_t)derived_value; + mValue += value; } - static storage_t convertToDerived(storage_t base_value) + template + void operator += (LLUnit other) { - return (storage_t)base_value; + mValue += convert(other); } - void operator += (const unit_t other) + void operator -= (storage_t value) { - mBaseValue += other.mBaseValue; + mValue -= value; } - void operator -= (const unit_t other) + template + void operator -= (LLUnit other) { - mBaseValue -= other.mBaseValue; + mValue -= convert(other); } void operator *= (storage_t multiplicand) { - mBaseValue *= multiplicand; + mValue *= multiplicand; + } + + template + void operator *= (LLUnit multiplicand) + { + llstatic_assert(sizeof(OTHER_UNIT) == false, "Multiplication of unit types not supported."); } void operator /= (storage_t divisor) { - mBaseValue /= divisor; + mValue /= divisor; } -protected: - void setBaseValue(storage_t value) + template + void operator /= (LLUnit divisor) { - mBaseValue = value; + llstatic_assert(sizeof(OTHER_UNIT) == false, "Division of unit types not supported."); } - storage_t mBaseValue; -}; + template + static storage_t convert(LLUnit v) + { + return (storage_t)(v.value() + * LLUnits::ConversionFactor::get() + * LLUnits::ConversionFactor::get()); + } -template -struct LLUnitTypeWrapper -: public LLUnitType -{ - typedef LLUnitType unit_t; - LLUnitTypeWrapper(const unit_t& other) - : unit_t(other) - {} -}; +protected: + storage_t mValue; +}; // // operator + // -template -DERIVED_UNIT operator + (typename LLUnitType::storage_t first, LLUnitType second) +template +LLUnit operator + (LLUnit first, LLUnit second) { - return DERIVED_UNIT(first + LLUnitType(second).value()); + LLUnit result(first); + result += second; + return result; } +template +LLUnit operator + (LLUnit first, SCALAR_TYPE second) +{ + LLUnit result(first); + result += second; + return result; +} -// -// operator - -// -template -DERIVED_UNIT operator - (typename LLUnitType::storage_t first, LLUnitType second) +template +LLUnit operator + (SCALAR_TYPE first, LLUnit second) { - return DERIVED_UNIT(first - LLUnitType(second).value()); + LLUnit result(first); + result += second; + return result; } // -// operator * +// operator - // -template -DERIVED_UNIT operator * (STORAGE_TYPE first, LLUnitType second) +template +LLUnit operator - (LLUnit first, LLUnit second) { - return DERIVED_UNIT(first * second.value()); + LLUnit result(first); + result -= second; + return result; } -template -DERIVED_UNIT operator * (LLUnitType first, STORAGE_TYPE second) + +template +LLUnit operator - (LLUnit first, SCALAR_TYPE second) { - return DERIVED_UNIT(first.value() * second); + LLUnit result(first); + result -= second; + return result; } +template +LLUnit operator - (SCALAR_TYPE first, LLUnit second) +{ + LLUnit result(first); + result -= second; + return result; +} // -// operator / +// operator * // -template -DERIVED_UNIT operator / (STORAGE_TYPE first, LLUnitTypeWrapper second) +template +LLUnit operator * (SCALAR_TYPE first, LLUnit second) { - return DERIVED_UNIT(first / second.value()); + return LLUnit(first * second.value()); } -template -DERIVED_UNIT operator / (LLUnitTypeWrapper first, STORAGE_TYPE second) +template +LLUnit operator * (LLUnit first, SCALAR_TYPE second) { - return DERIVED_UNIT(first.value() / second); + return LLUnit(first.value() * second); } -// -// operator < -// -template - -bool operator < (typename LLUnitType::storage_t first, LLUnitType second) +template +void operator * (LLUnit, LLUnit) { - return first < second.value(); + llstatic_assert(sizeof(STORAGE_TYPE1) == false, "Multiplication of unit types results in new unit type - not supported."); } // -// operator <= +// operator / // -template -bool operator <= (typename LLUnitType::storage_t first, LLUnitType second) +template +SCALAR_TYPE operator / (SCALAR_TYPE first, LLUnit second) { - return first <= second.value(); + return SCALAR_TYPE(first / second.value()); } - -// -// operator > -// -template -bool operator > (typename LLUnitType::storage_t first, LLUnitType second) +template +LLUnit operator / (LLUnit first, SCALAR_TYPE second) { - return first > second.value(); + return LLUnit(first.value() / second); } -// -// operator >= -// -template -bool operator >= (typename LLUnitType::storage_t first, LLUnitType second) +template +void operator / (LLUnit, LLUnit) { - return first >= second.value(); + llstatic_assert(sizeof(STORAGE_TYPE1) == false, "Multiplication of unit types results in new unit type - not supported."); } -// -// operator == -// -template -bool operator == (typename LLUnitType::storage_t first, LLUnitType second) -{ - return first == second.value(); +#define COMPARISON_OPERATORS(op) \ +template \ +bool operator op (SCALAR_TYPE first, LLUnit second) \ +{ \ + return first op second.value(); \ +} \ + \ +template \ +bool operator op (LLUnit first, SCALAR_TYPE second) \ +{ \ + return first.value() op second; \ +} \ + \ +template \ +bool operator op (LLUnit first, LLUnit second) \ +{ \ + return first.value() op first.convert(second); \ } -// -// operator != -// -template -bool operator != (typename LLUnitType::storage_t first, LLUnitType second) +COMPARISON_OPERATORS(<) +COMPARISON_OPERATORS(<=) +COMPARISON_OPERATORS(>) +COMPARISON_OPERATORS(>=) +COMPARISON_OPERATORS(==) +COMPARISON_OPERATORS(!=) + +namespace LLUnits { - return first != second.value(); +#define LL_DECLARE_DERIVED_UNIT(base_unit_name, unit_name, conversion_factor)\ +struct unit_name \ +{ \ + typedef base_unit_name base_unit_t; \ +}; \ +template<> \ +struct ConversionFactor \ +{ \ + static F64 get() { return (conversion_factor); } \ +}; \ + \ +template<> \ +struct ConversionFactor \ +{ \ + static F64 get() { return 1.0 / (conversion_factor); } \ } -#define LL_DECLARE_BASE_UNIT(unit_name) \ - template \ - struct unit_name : public LLUnitType, unit_name > \ - { \ - typedef LLUnitType unit_t; \ - \ - unit_name(storage_t value = 0) \ - : LLUnitType(value) \ - {} \ - \ - template \ - unit_name(LLUnitType, SOURCE_TYPE> source) \ - { \ - assignFrom(source); \ - } \ - \ - template \ - void assignFrom(LLUnitType, SOURCE_TYPE> source) \ - { \ - setBaseValue((storage_t)source.unit_name::unit_t::value()); \ - } \ - \ - }; \ - -#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ - template \ - struct derived_unit : public LLUnitType, derived_unit > \ - { \ - typedef LLUnitType, derived_unit > unit_t; \ - \ - derived_unit(storage_t value = 0) \ - : LLUnitType(value) \ - {} \ - \ - template \ - derived_unit(LLUnitType, SOURCE_TYPE> source) \ - { \ - assignFrom(source); \ - } \ - \ - template \ - void assignFrom(LLUnitType, SOURCE_TYPE> source) \ - { \ - setBaseValue((storage_t)source.base_unit::unit_t::value()); \ - } \ - \ - static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ - \ - }; \ - -namespace LLUnit -{ - LL_DECLARE_BASE_UNIT(Bytes); - LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); - LL_DECLARE_DERIVED_UNIT(Bytes, Megabytes, 1024 * 1024); - LL_DECLARE_DERIVED_UNIT(Bytes, Gigabytes, 1024 * 1024 * 1024); - LL_DECLARE_DERIVED_UNIT(Bytes, Bits, (1.f / 8.f)); - LL_DECLARE_DERIVED_UNIT(Bytes, Kilobits, (1024 / 8)); - LL_DECLARE_DERIVED_UNIT(Bytes, Megabits, (1024 / 8)); - LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); - - LL_DECLARE_BASE_UNIT(Seconds); - LL_DECLARE_DERIVED_UNIT(Seconds, Minutes, 60); - LL_DECLARE_DERIVED_UNIT(Seconds, Hours, 60 * 60); - LL_DECLARE_DERIVED_UNIT(Seconds, Days, 60 * 60 * 24); - LL_DECLARE_DERIVED_UNIT(Seconds, Weeks, 60 * 60 * 24 * 7); - LL_DECLARE_DERIVED_UNIT(Seconds, Milliseconds, (1.f / 1000.f)); - LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.f / (1000000.f))); - LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.f / (1000000000.f))); - - LL_DECLARE_BASE_UNIT(Meters); - LL_DECLARE_DERIVED_UNIT(Meters, Kilometers, 1000); - LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, 1 / 100); - LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, 1 / 1000); +struct Bytes { typedef Bytes base_unit_t; }; +LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); +LL_DECLARE_DERIVED_UNIT(Bytes, Megabytes, 1024 * 1024); +LL_DECLARE_DERIVED_UNIT(Bytes, Gigabytes, 1024 * 1024 * 1024); +LL_DECLARE_DERIVED_UNIT(Bytes, Bits, (1.0 / 8.0)); +LL_DECLARE_DERIVED_UNIT(Bytes, Kilobits, (1024 / 8)); +LL_DECLARE_DERIVED_UNIT(Bytes, Megabits, (1024 / 8)); +LL_DECLARE_DERIVED_UNIT(Bytes, Gigabits, (1024 * 1024 * 1024 / 8)); + +struct Seconds { typedef Seconds base_unit_t; }; +LL_DECLARE_DERIVED_UNIT(Seconds, Minutes, 60); +LL_DECLARE_DERIVED_UNIT(Seconds, Hours, 60 * 60); +LL_DECLARE_DERIVED_UNIT(Seconds, Days, 60 * 60 * 24); +LL_DECLARE_DERIVED_UNIT(Seconds, Weeks, 60 * 60 * 24 * 7); +LL_DECLARE_DERIVED_UNIT(Seconds, Milliseconds, (1.0 / 1000.0)); +LL_DECLARE_DERIVED_UNIT(Seconds, Microseconds, (1.0 / (1000000.0))); +LL_DECLARE_DERIVED_UNIT(Seconds, Nanoseconds, (1.0 / (1000000000.0))); + +struct Meters { typedef Meters base_unit_t; }; +LL_DECLARE_DERIVED_UNIT(Meters, Kilometers, 1000); +LL_DECLARE_DERIVED_UNIT(Meters, Centimeters, (1.0 / 100)); +LL_DECLARE_DERIVED_UNIT(Meters, Millimeters, (1.0 / 1000)); } #endif // LL_LLUNIT_H diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 78223e1e65..0d632f59be 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -49,10 +49,10 @@ 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) - 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) + LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a) explicit LLColor4(const LLSD& sd); + explicit LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1) + explicit LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc)) explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index fc1edbe664..5361d8e7be 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -50,9 +50,9 @@ U32 wpo2(U32 i); U32 LLImageGL::sUniqueCount = 0; U32 LLImageGL::sBindCount = 0; -LLUnit::Bytes LLImageGL::sGlobalTextureMemory = 0; -LLUnit::Bytes LLImageGL::sBoundTextureMemory = 0; -LLUnit::Bytes LLImageGL::sCurBoundTextureMemory = 0; +LLUnit LLImageGL::sGlobalTextureMemory = 0; +LLUnit LLImageGL::sBoundTextureMemory = 0; +LLUnit LLImageGL::sCurBoundTextureMemory = 0; S32 LLImageGL::sCount = 0; LLImageGL::dead_texturelist_t LLImageGL::sDeadTextureList[LLTexUnit::TT_NONE]; U32 LLImageGL::sCurTexName = 1; diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index dfa59f2a34..11555e20c4 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -246,9 +246,9 @@ public: static F32 sLastFrameTime; // Global memory statistics - static LLUnit::Bytes sGlobalTextureMemory; // Tracks main memory texmem - static LLUnit::Bytes sBoundTextureMemory; // Tracks bound texmem for last completed frame - static LLUnit::Bytes sCurBoundTextureMemory; // Tracks bound texmem for current frame + static LLUnit sGlobalTextureMemory; // Tracks main memory texmem + static LLUnit sBoundTextureMemory; // Tracks bound texmem for last completed frame + static LLUnit sCurBoundTextureMemory; // Tracks bound texmem for current frame static U32 sBindCount; // Tracks number of texture binds for current frame static U32 sUniqueCount; // Tracks number of unique texture binds for current frame static BOOL sGlobalUseAnisotropic; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 838a982cb4..ac659c409b 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -277,7 +277,7 @@ LLPumpIO* gServicePump = NULL; U64 gFrameTime = 0; F32 gFrameTimeSeconds = 0.f; -LLUnit::Seconds gFrameIntervalSeconds = 0.f; +LLUnit gFrameIntervalSeconds = 0.f; F32 gFPSClamped = 10.f; // Pretend we start at target rate. F32 gFrameDTClamped = 0.f; // Time between adjacent checks to network for packets U64 gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index d9d888c626..f2bea7cdb2 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -322,7 +322,7 @@ extern LLPumpIO* gServicePump; extern U64 gFrameTime; // The timestamp of the most-recently-processed frame extern F32 gFrameTimeSeconds; // Loses msec precision after ~4.5 hours... -extern LLUnit::Seconds gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds +extern LLUnit gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds extern F32 gFPSClamped; // Frames per second, smoothed, weighted toward last frame extern F32 gFrameDTClamped; extern U64 gStartTime; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 4f6eaa5a5b..61f5ecc46f 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -463,7 +463,7 @@ void LLDrawPoolWater::renderReflection(LLFace* face) gGL.getTexUnit(0)->bind(mHBTex[dr]); - LLOverrideFaceColor override(this, face->getFaceColor().mV); + LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV)); face->renderIndexed(); } diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index d734620f10..288c1233e5 100755 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -503,17 +503,17 @@ private: void LLGLTexMemBar::draw() { - LLUnit::Megabytes bound_mem = LLViewerTexture::sBoundTextureMemory; - LLUnit::Megabytes max_bound_mem = LLViewerTexture::sMaxBoundTextureMem; - LLUnit::Megabytes total_mem = LLViewerTexture::sTotalTextureMemory; - LLUnit::Megabytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem; + LLUnit bound_mem = LLViewerTexture::sBoundTextureMemory; + LLUnit max_bound_mem = LLViewerTexture::sMaxBoundTextureMem; + LLUnit total_mem = LLViewerTexture::sTotalTextureMemory; + LLUnit max_total_mem = LLViewerTexture::sMaxTotalTextureMem; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; F32 cache_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ; F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ; S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); - LLUnit::Megabytes total_texture_downloaded = gTotalTextureData; - LLUnit::Megabytes total_object_downloaded = gTotalObjectData; + LLUnit total_texture_downloaded = gTotalTextureData; + LLUnit total_object_downloaded = gTotalObjectData; U32 total_http_requests = LLAppViewer::getTextureFetch()->getCurlRequest().getTotalIssuedRequests() ; //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; @@ -661,7 +661,7 @@ void LLGLTexSizeBar::draw() if(LLImageGL::sCurTexSizeBar == mIndex) { - F32 text_color[] = {1.f, 1.f, 1.f, 0.75f}; + LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); std::string text; text = llformat("%d", mTopLoaded) ; @@ -673,8 +673,8 @@ void LLGLTexSizeBar::draw() text_color, LLFontGL::LEFT, LLFontGL::TOP); } - F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f}; - F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f}; + LLColor4 loaded_color(1.0f, 0.0f, 0.0f, 0.75f); + LLColor4 bound_color(1.0f, 1.0f, 0.0f, 0.75f); gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ; gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ; } diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index bad2f5b4cd..73a2e24424 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -430,10 +430,10 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output) grid_from_region_handle(it->first, &grid_x, &grid_y); r.grid_x(grid_x); r.grid_y(grid_y); - r.duration(LLUnit::Microseconds(rec.getDuration()).value()); + r.duration(LLUnit(rec.getDuration()).value()); } - stats.duration(mCurRecording ? LLUnit::Microseconds(mCurRecording->getDuration()).value() : 0.0); + stats.duration(mCurRecording ? LLUnit(mCurRecording->getDuration()).value() : 0.0); stats.avatar.setProvided(true); for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat) diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index acbe836c29..197d91593c 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -2587,7 +2587,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) LLSD args; args["SUBJECT"] = subj; args["MESSAGE"] = mes; - LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).time_stamp(timestamp)); + LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).time_stamp(LLDate(timestamp))); } // Also send down the old path for now. @@ -4416,18 +4416,18 @@ void send_agent_update(BOOL force_send, BOOL send_reliable) // *TODO: Remove this dependency, or figure out a better way to handle // this hack. -extern LLUnit::Bits gObjectData; +extern LLUnit gObjectData; void process_object_update(LLMessageSystem *mesgsys, void **user_data) { // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveSize(); + gObjectData += (LLUnit)mesgsys->getReceiveSize(); } // Update the object... @@ -4439,11 +4439,11 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveSize(); + gObjectData += (LLUnit)mesgsys->getReceiveSize(); } // Update the object... @@ -4455,11 +4455,11 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data) // Update the data counters if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveSize(); + gObjectData += (LLUnit)mesgsys->getReceiveSize(); } // Update the object... @@ -4471,11 +4471,11 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_ { if (mesgsys->getReceiveCompressedSize()) { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveCompressedSize(); + gObjectData += (LLUnit)mesgsys->getReceiveCompressedSize(); } else { - gObjectData += (LLUnit::Bytes)mesgsys->getReceiveSize(); + gObjectData += (LLUnit)mesgsys->getReceiveSize(); } gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 317fe5eaf8..36b1179e04 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -288,13 +288,13 @@ F32 gAveLandCompression = 0.f, gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f; -LLUnit::Bytes gTotalWorldData = 0, +LLUnit gTotalWorldData = 0, gTotalObjectData = 0, gTotalTextureData = 0; U32 gSimPingCount = 0; -LLUnit::Bits gObjectData = 0; +LLUnit gObjectData = 0; F32 gAvgSimPing = 0.f; -LLUnit::Bytes gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; +LLUnit gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0}; extern U32 gVisCompared; extern U32 gVisTested; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index eda7b3329d..14ee41dba0 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -319,7 +319,7 @@ void update_statistics(); void send_stats(); extern LLFrameTimer gTextureTimer; -extern LLUnit::Bytes gTotalTextureData; -extern LLUnit::Bytes gTotalObjectData; -extern LLUnit::Bytes gTotalTextureBytesPerBoostLevel[] ; +extern LLUnit gTotalTextureData; +extern LLUnit gTotalObjectData; +extern LLUnit gTotalTextureBytesPerBoostLevel[] ; #endif // LL_LLVIEWERSTATS_H diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index ceb8d3155c..f4e8e3eae1 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -65,8 +65,8 @@ /////////////////////////////////////////////////////////////////////////////// // extern -const LLUnit::Megabytes gMinVideoRam = 32; -const LLUnit::Megabytes gMaxVideoRam = 512; +const LLUnit gMinVideoRam = 32; +const LLUnit gMaxVideoRam = 512; // statics @@ -87,11 +87,11 @@ S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sDesiredDiscardBias = 0.f; F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -LLUnit::Bytes LLViewerTexture::sBoundTextureMemory = 0; -LLUnit::Bytes LLViewerTexture::sTotalTextureMemory = 0; -LLUnit::Megabytes LLViewerTexture::sMaxBoundTextureMem = 0; -LLUnit::Megabytes LLViewerTexture::sMaxTotalTextureMem = 0; -LLUnit::Bytes LLViewerTexture::sMaxDesiredTextureMem = 0 ; +LLUnit LLViewerTexture::sBoundTextureMemory = 0; +LLUnit LLViewerTexture::sTotalTextureMemory = 0; +LLUnit LLViewerTexture::sMaxBoundTextureMem = 0; +LLUnit LLViewerTexture::sMaxTotalTextureMem = 0; +LLUnit LLViewerTexture::sMaxDesiredTextureMem = 0 ; S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ; F32 LLViewerTexture::sCameraMovingBias = 0.0f ; S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size @@ -532,8 +532,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity if (sBoundTextureMemory >= sMaxBoundTextureMem || sTotalTextureMemory >= sMaxTotalTextureMem) { - //when texture memory overflows, lower down the threashold to release the textures more aggressively. - sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit::Bytes(gMaxVideoRam)); + //when texture memory overflows, lower down the threshold to release the textures more aggressively. + sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit(gMaxVideoRam)); // If we are using more texture memory than we should, // scale up the desired discard level diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index aa1e2010b4..e9efb751f8 100755 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -39,8 +39,8 @@ #include #include -extern const LLUnit::Megabytes gMinVideoRam; -extern const LLUnit::Megabytes gMaxVideoRam; +extern const LLUnit gMinVideoRam; +extern const LLUnit gMaxVideoRam; class LLFace; class LLImageGL ; @@ -323,11 +323,11 @@ public: static LLFrameTimer sEvaluationTimer; static F32 sDesiredDiscardBias; static F32 sDesiredDiscardScale; - static LLUnit::Bytes sBoundTextureMemory; - static LLUnit::Bytes sTotalTextureMemory; - static LLUnit::Megabytes sMaxBoundTextureMem; - static LLUnit::Megabytes sMaxTotalTextureMem; - static LLUnit::Bytes sMaxDesiredTextureMem ; + static LLUnit sBoundTextureMemory; + static LLUnit sTotalTextureMemory; + static LLUnit sMaxBoundTextureMem; + static LLUnit sMaxTotalTextureMem; + static LLUnit sMaxDesiredTextureMem ; static S8 sCameraMovingDiscardBias; static F32 sCameraMovingBias; static S32 sMaxSculptRez ; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index b7415669bb..8e72ca1d74 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -733,7 +733,7 @@ public: { if(gTotalTextureBytesPerBoostLevel[i] > 0) { - addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, LLUnit::Megabytes(gTotalTextureBytesPerBoostLevel[i]).value())); + addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, LLUnit(gTotalTextureBytesPerBoostLevel[i]).value())); ypos += y_inc; } } -- cgit v1.2.3