SH-3499 WIP Ensure asset stats output is correct

further fixes to implicit conversion of unit types
meow-7.2.2
Richard Linden 2012-11-07 15:32:12 -08:00
parent 9d70448a12
commit ed17c181dd
10 changed files with 86 additions and 154 deletions

View File

@ -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<F64> seconds_since_epoch) :
mSecondsSinceEpoch(seconds_since_epoch)
{
}
{}
LLDate::LLDate(const std::string& iso8601_date)
{

View File

@ -33,6 +33,7 @@
#include <string>
#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<F64> seconds_since_epoch);
/**
* @brief Construct a date from a string representation

View File

@ -287,14 +287,15 @@ LLTimer::~LLTimer()
}
// static
U64 LLTimer::getTotalTime()
LLUnit::Microseconds<U64> LLTimer::getTotalTime()
{
LLUnit::Seconds<F64> sec = LLUnit::Milliseconds<U32>(2000) + LLUnit::Hours<F32>(1.f / 360.f);
// simply call into the implementation function.
return totalTime();
}
// static
F64 LLTimer::getTotalSeconds()
LLUnit::Seconds<F64> 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<F64> LLTimer::getElapsedTimeF64() const
{
U64 last = mLastClockCount;
return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv;
}
F32 LLTimer::getElapsedTimeF32() const
LLUnit::Seconds<F32> LLTimer::getElapsedTimeF32() const
{
return (F32)getElapsedTimeF64();
}
F64 LLTimer::getElapsedTimeAndResetF64()
LLUnit::Seconds<F64> LLTimer::getElapsedTimeAndResetF64()
{
return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv;
}
F32 LLTimer::getElapsedTimeAndResetF32()
LLUnit::Seconds<F32> LLTimer::getElapsedTimeAndResetF32()
{
return (F32)getElapsedTimeAndResetF64();
}
@ -372,7 +373,7 @@ void LLTimer::setTimerExpirySec(F32 expiration)
+ (U64)((F32)(expiration * gClockFrequency));
}
F32 LLTimer::getRemainingTimeF32() const
LLUnit::Seconds<F32> LLTimer::getRemainingTimeF32() const
{
U64 cur_ticks = get_clock_count();
if (cur_ticks > mExpirationTicks)

View File

@ -37,6 +37,7 @@
#include <string>
#include <list>
// 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<F64> getElapsedSeconds()
{
return sTimer->getElapsedTimeF64();
}
// Return a high precision usec since epoch
static U64 getTotalTime();
static LLUnit::Microseconds<U64> getTotalTime();
// Return a high precision seconds since epoch
static F64 getTotalSeconds();
static LLUnit::Seconds<F64> 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<F32> getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset
LLUnit::Seconds<F64> getElapsedTimeAndResetF64();
F32 getRemainingTimeF32() const;
LLUnit::Seconds<F32> getRemainingTimeF32() const;
static BOOL knownBadTimer();
// ACCESSORS
F32 getElapsedTimeF32() const; // Returns elapsed time in seconds
F64 getElapsedTimeF64() const; // Returns elapsed time in seconds
LLUnit::Seconds<F32> getElapsedTimeF32() const; // Returns elapsed time in seconds
LLUnit::Seconds<F64> getElapsedTimeF64() const; // Returns elapsed time in seconds
BOOL getStarted() const { return mStarted; }
bool getStarted() const { return mStarted; }
static U64 getCurrentClockCount(); // Returns the raw clockticks

View File

@ -46,6 +46,25 @@ Recording::Recording()
mStackTimers(new AccumulatorBuffer<TimerAccumulator>())
{}
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()
{}

View File

@ -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();

View File

@ -51,6 +51,11 @@ struct LLUnitType : public BASE_UNIT
return static_cast<unit_t&>(*this);
}
operator storage_t () const
{
return value();
}
storage_t value() const
{
return convertToDerived(mBaseValue);
@ -102,6 +107,11 @@ struct LLUnitType<STORAGE_TYPE, T, T>
return static_cast<unit_t&>(*this);
}
operator storage_t () const
{
return value();
}
storage_t value() const { return mBaseValue; }
template<typename CONVERTED_TYPE>
@ -110,7 +120,6 @@ struct LLUnitType<STORAGE_TYPE, T, T>
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;
};
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
struct LLUnitTypeWrapper
: public LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>
{
typedef LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> unit_t;
LLUnitTypeWrapper(const unit_t& other)
: unit_t(other)
{}
};
//
// operator +
//
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second)
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2>
DERIVED_UNIT operator + (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE2, BASE_UNIT2, DERIVED_UNIT2> second)
{
return DERIVED_UNIT(first + second.value());
return DERIVED_UNIT(first + LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value());
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return DERIVED_UNIT(first.value() + second);
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
DERIVED_UNIT operator + (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return DERIVED_UNIT(first.value() + second.value());
}
//
// operator -
//
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2>
DERIVED_UNIT operator - (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second)
{
return DERIVED_UNIT(first - second.value());
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return DERIVED_UNIT(first.value() - second);
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
DERIVED_UNIT operator - (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return DERIVED_UNIT(first.value() - second.value());
return DERIVED_UNIT(first - LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>(second).value());
}
//
// operator *
//
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
DERIVED_UNIT operator * (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second)
DERIVED_UNIT operator * (STORAGE_TYPE first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second)
{
return DERIVED_UNIT(first * second.value());
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
DERIVED_UNIT operator * (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second)
{
return DERIVED_UNIT(first.value() * second);
}
//
// operator /
//
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
DERIVED_UNIT operator / (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second)
DERIVED_UNIT operator / (STORAGE_TYPE first, LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second)
{
return DERIVED_UNIT(first * second.value());
return DERIVED_UNIT(first / second.value());
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
DERIVED_UNIT operator / (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
DERIVED_UNIT operator / (LLUnitTypeWrapper<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, STORAGE_TYPE second)
{
return DERIVED_UNIT(first.value() * second);
return DERIVED_UNIT(first.value() / second);
}
//
// operator <
//
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename STORAGE_TYPE2, typename BASE_UNIT2, typename DERIVED_UNIT2>
bool operator < (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t first, LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> second)
{
return first < second.value();
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return first.value() < second;
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
bool operator < (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return first.value() < second.value();
}
//
// operator <=
//
@ -252,17 +239,6 @@ bool operator <= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st
return first <= second.value();
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return first.value() <= second;
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
bool operator <= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return first.value() <= second.value();
}
//
// operator >
@ -273,17 +249,6 @@ bool operator > (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::sto
return first > second.value();
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return first.value() > second;
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
bool operator > (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return first.value() > second.value();
}
//
// operator >=
//
@ -293,18 +258,6 @@ bool operator >= (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st
return first >= second.value();
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return first.value() >= second;
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
bool operator >= (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return first.value() >= second.value();
}
//
// operator ==
//
@ -314,18 +267,6 @@ bool operator == (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st
return first == second.value();
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return first.value() == second;
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
bool operator == (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return first.value() == second.value();
}
//
// operator !=
//
@ -335,18 +276,6 @@ bool operator != (typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::st
return first != second.value();
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT>
bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, typename LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT>::storage_t second)
{
return first.value() != second;
}
template<typename STORAGE_TYPE, typename BASE_UNIT, typename DERIVED_UNIT, typename OTHER_DERIVED_UNIT>
bool operator != (LLUnitType<STORAGE_TYPE, BASE_UNIT, DERIVED_UNIT> first, LLUnitType<STORAGE_TYPE, BASE_UNIT, OTHER_DERIVED_UNIT> second)
{
return first.value() != second.value();
}
#define LL_DECLARE_BASE_UNIT(unit_name) \
template<typename STORAGE> \
struct unit_name : public LLUnitType<STORAGE, unit_name<STORAGE>, unit_name<STORAGE> > \

View File

@ -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

View File

@ -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),

View File

@ -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<S32>)gMaxVideoRam) ;//512 MB
sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit::Bytes<S32>(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() ;