From e6ca5471a2a816a24888ae1b38332531b22b7254 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 17 Oct 2012 00:06:22 -0700 Subject: SH-3275 Update viewer metrics system to be more flexible put template parameter back in LLUnit units added free function operators for mathematical manipulation of unit values converted texture memory tracking to units --- indra/llcommon/lltrace.h | 36 +++- indra/llcommon/lltracerecording.h | 2 +- indra/llcommon/llunit.h | 376 +++++++++++++++++++++++----------- indra/llrender/llimagegl.cpp | 16 +- indra/llrender/llimagegl.h | 7 +- indra/newview/lltexturefetch.cpp | 2 +- indra/newview/lltextureview.cpp | 20 +- indra/newview/llviewerobject.cpp | 2 +- indra/newview/llviewerstats.cpp | 28 +-- indra/newview/llviewerstats.h | 12 +- indra/newview/llviewertexture.cpp | 43 ++-- indra/newview/llviewertexture.h | 15 +- indra/newview/llviewertexturelist.cpp | 20 +- indra/newview/llviewerwindow.cpp | 2 +- indra/newview/llvoavatarself.cpp | 2 +- indra/newview/llworld.cpp | 6 +- 16 files changed, 379 insertions(+), 210 deletions(-) diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 3e19c83bd7..1c6726605a 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -46,6 +46,30 @@ 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; + void init(); void cleanup(); @@ -353,15 +377,15 @@ namespace LLTrace template class LL_COMMON_API Measurement - : public Measurement + : public Measurement { public: typedef typename T::storage_t storage_t; typedef typename T::base_unit_t base_unit_t; - typedef Measurement base_measurement_t; + typedef Measurement base_measurement_t; Measurement(const char* name, const char* description = NULL) - : Measurement(name) + : Measurement(name, description) {} template @@ -393,15 +417,15 @@ namespace LLTrace template class LL_COMMON_API Count - : public Count + : public Count { public: typedef typename T::storage_t storage_t; typedef typename T::base_unit_t base_unit_t; - typedef Count base_count_t; + typedef Count base_count_t; Count(const char* name, const char* description = NULL) - : Count(name) + : Count(name) {} template diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index bd4b944e5a..5e7b0752c6 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -214,7 +214,7 @@ namespace LLTrace return mRecordingPeriods[(mCurPeriod + mNumPeriods - 1) % mNumPeriods]; } - Recording getCurRecordingPeriod() + Recording& getCurRecordingPeriod() { return mRecordingPeriods[mCurPeriod]; } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index e8f6b2b2ba..d980989c91 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -34,60 +34,43 @@ template(*this); } - value_t value() const + storage_t value() const { return convertToDerived(mBaseValue); } template - value_t value() const + storage_t value() const { return CONVERTED_TYPE(*this).value(); } - static value_t convertToBase(value_t derived_value) - { - return (value_t)((F32)derived_value * unit_t::conversionToBaseFactor()); - } - - static value_t convertToDerived(value_t base_value) - { - return (value_t)((F32)base_value / unit_t::conversionToBaseFactor()); - } - - unit_t operator + (const unit_t other) const - { - return unit_t(mBaseValue + other.mBaseValue); - } - - unit_t operator - (const unit_t other) const - { - return unit_t(mBaseValue - other.mBaseValue); - } - - unit_t operator * (value_t multiplicand) const +protected: + static storage_t convertToBase(storage_t derived_value) { - return unit_t(mBaseValue * multiplicand); + return (storage_t)((F32)derived_value * unit_t::conversionToBaseFactor()); } - unit_t operator / (value_t divisor) const + static storage_t convertToDerived(storage_t base_value) { - return unit_t(mBaseValue / divisor); + return (storage_t)((F32)base_value / unit_t::conversionToBaseFactor()); } }; @@ -96,43 +79,40 @@ template struct LLUnitType { typedef T unit_t; - typedef typename STORAGE_TYPE value_t; + typedef STORAGE_TYPE storage_t; typedef void is_unit_t; + typedef T base_unit_t; LLUnitType() : mBaseValue() {} - explicit LLUnitType(value_t value) + explicit LLUnitType(storage_t value) : mBaseValue(value) {} - unit_t& operator=(value_t value) + unit_t& operator=(storage_t value) { setBaseValue(value); return *this; } + //implicit downcast operator unit_t& () { return static_cast(*this); } - value_t value() const { return mBaseValue; } + storage_t value() const { return mBaseValue; } - static value_t convertToBase(value_t derived_value) + static storage_t convertToBase(storage_t derived_value) { - return (value_t)derived_value; + return (storage_t)derived_value; } - static value_t convertToDerived(value_t base_value) + static storage_t convertToDerived(storage_t base_value) { - return (value_t)base_value; - } - - unit_t operator + (const unit_t other) const - { - return unit_t(mBaseValue + other.mBaseValue); + return (storage_t)base_value; } void operator += (const unit_t other) @@ -140,108 +120,266 @@ struct LLUnitType mBaseValue += other.mBaseValue; } - unit_t operator - (const unit_t other) const - { - return unit_t(mBaseValue - other.mBaseValue); - } - void operator -= (const unit_t other) { mBaseValue -= other.mBaseValue; } - unit_t operator * (value_t multiplicand) const - { - return unit_t(mBaseValue * multiplicand); - } - - void operator *= (value_t multiplicand) + void operator *= (storage_t multiplicand) { mBaseValue *= multiplicand; } - unit_t operator / (value_t divisor) const - { - return unit_t(mBaseValue / divisor); - } - - void operator /= (value_t divisor) + void operator /= (storage_t divisor) { mBaseValue /= divisor; } protected: - void setBaseValue(value_t value) + void setBaseValue(storage_t value) { mBaseValue = value; } - value_t mBaseValue; + storage_t mBaseValue; }; -#define LL_DECLARE_BASE_UNIT(unit_name) \ - struct unit_name : public LLUnitType \ - { \ - typedef unit_name base_unit_t; \ - typedef LLUnitType unit_t; \ - typedef F64 storage_t; \ - \ - unit_name(F64 value) \ - : LLUnitType(value) \ - {} \ - \ - unit_name() \ - {} \ - \ - template \ - unit_name(const LLUnitType& source) \ - { \ - setBaseValue((F64)source.unit_name::unit_t::value()); \ - } \ - \ - using LLUnitType::operator +; \ - using LLUnitType::operator +=; \ - using LLUnitType::operator -; \ - using LLUnitType::operator -=; \ - using LLUnitType::operator *; \ - using LLUnitType::operator *=; \ - using LLUnitType::operator /; \ - using LLUnitType::operator /=; \ +// +// operator + +// +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()); +} + +// +// operator - +// +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()); +} + +// +// operator * +// +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); +} + +// +// operator / +// +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); +} + +// +// operator < +// +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 <= +// +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 > +// +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 >= +// +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 == +// +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 != +// +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(); +} + +#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) \ + { \ + setBaseValue((storage_t)source.unit_name::unit_t::value()); \ + } \ + \ }; -#define LL_DECLARE_DERIVED_UNIT(base_unit, derived_unit, conversion_factor) \ - struct derived_unit : public LLUnitType \ - { \ - typedef base_unit base_unit_t; \ - typedef LLUnitType unit_t; \ - typedef F64 storage_t; \ - \ - derived_unit(value_t value) \ - : LLUnitType(value) \ - {} \ - \ - derived_unit() \ - {} \ - \ - template \ - derived_unit(const LLUnitType& source) \ - { \ - setBaseValue((F64)source.base_unit::unit_t::value()); \ - } \ - \ - static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ - \ - using LLUnitType::operator +; \ - using LLUnitType::operator +=; \ - using LLUnitType::operator -; \ - using LLUnitType::operator -=; \ - using LLUnitType::operator *; \ - using LLUnitType::operator *=; \ - using LLUnitType::operator /; \ - using LLUnitType::operator /=; \ +#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) \ + { \ + setBaseValue((storage_t)source.base_unit::unit_t::value()); \ + } \ + \ + static F32 conversionToBaseFactor() { return (F32)(conversion_factor); } \ + \ }; -namespace LLUnits +namespace LLUnit { LL_DECLARE_BASE_UNIT(Bytes); LL_DECLARE_DERIVED_UNIT(Bytes, Kilobytes, 1024); diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index a4d7872ec2..fc1edbe664 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; -S32 LLImageGL::sGlobalTextureMemoryInBytes = 0; -S32 LLImageGL::sBoundTextureMemoryInBytes = 0; -S32 LLImageGL::sCurBoundTextureMemory = 0; +LLUnit::Bytes LLImageGL::sGlobalTextureMemory = 0; +LLUnit::Bytes LLImageGL::sBoundTextureMemory = 0; +LLUnit::Bytes LLImageGL::sCurBoundTextureMemory = 0; S32 LLImageGL::sCount = 0; LLImageGL::dead_texturelist_t LLImageGL::sDeadTextureList[LLTexUnit::TT_NONE]; U32 LLImageGL::sCurTexName = 1; @@ -243,7 +243,7 @@ void LLImageGL::updateStats(F32 current_time) { LLFastTimer t(FTM_IMAGE_UPDATE_STATS); sLastFrameTime = current_time; - sBoundTextureMemoryInBytes = sCurBoundTextureMemory; + sBoundTextureMemory = sCurBoundTextureMemory; sCurBoundTextureMemory = 0; } @@ -251,7 +251,7 @@ void LLImageGL::updateStats(F32 current_time) S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) { LLImageGL::sCurBoundTextureMemory += mem ; - return LLImageGL::sCurBoundTextureMemory; + return LLImageGL::sCurBoundTextureMemory.value(); } //---------------------------------------------------------------------------- @@ -1395,7 +1395,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ if (old_name != 0) { - sGlobalTextureMemoryInBytes -= mTextureMemory; + sGlobalTextureMemory -= mTextureMemory; LLImageGL::deleteTextures(mBindTarget, mFormatInternal, mMipLevels, 1, &old_name); @@ -1403,7 +1403,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ } mTextureMemory = getMipBytes(discard_level); - sGlobalTextureMemoryInBytes += mTextureMemory; + sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight() ; // mark this as bound at this point, so we don't throw it out immediately @@ -1562,7 +1562,7 @@ void LLImageGL::destroyGLTexture() { if(mTextureMemory) { - sGlobalTextureMemoryInBytes -= mTextureMemory; + sGlobalTextureMemory -= mTextureMemory; mTextureMemory = 0; } diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index cf3c484c79..dfa59f2a34 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -34,6 +34,7 @@ #include "llpointer.h" #include "llrefcount.h" #include "v2math.h" +#include "llunit.h" #include "llrender.h" class LLTextureAtlas ; @@ -245,9 +246,9 @@ public: static F32 sLastFrameTime; // Global memory statistics - static S32 sGlobalTextureMemoryInBytes; // Tracks main memory texmem - static S32 sBoundTextureMemoryInBytes; // Tracks bound texmem for last completed frame - static S32 sCurBoundTextureMemory; // Tracks bound texmem for current frame + 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 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/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index f2caa01644..8ddaac5cc8 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2316,7 +2316,7 @@ S32 LLTextureFetch::update(F32 max_time_ms) if(mCurlGetRequest) { - LLStatViewer::TEXTURE_KBIT.add(mCurlGetRequest->getTotalReceivedBits()); + LLStatViewer::TEXTURE_KBIT.add(mCurlGetRequest->getTotalReceivedBits()); //gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits(); } diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index c60b4155a0..a88233e120 100755 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -503,13 +503,13 @@ private: void LLGLTexMemBar::draw() { - S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes); - S32 max_bound_mem = LLViewerTexture::sMaxBoundTextureMemInMegaBytes; - S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sTotalTextureMemoryInBytes); - S32 max_total_mem = LLViewerTexture::sMaxTotalTextureMemInMegaBytes; + 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; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; - F32 cache_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getUsage()) ; - F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ; + 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); F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024); @@ -526,10 +526,10 @@ void LLGLTexMemBar::draw() text_color, LLFontGL::LEFT, LLFontGL::TOP); text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB", - total_mem, - max_total_mem, - bound_mem, - max_bound_mem, + total_mem.value(), + max_total_mem.value(), + bound_mem.value(), + max_bound_mem.value(), LLRenderTarget::sBytesAllocated/(1024*1024), LLImageRaw::sGlobalRawMemory >> 20, discard_bias, cache_usage, cache_max_usage); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 989a1c4e5a..747dfd3250 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2033,7 +2033,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, // If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) ) { - LLStatViewer::AGENT_POSITION_SNAP.sample(diff.length()); + LLStatViewer::AGENT_POSITION_SNAP.sample(diff.length()); //LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() ); } } diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index f0ad04e0ba..ccc0c9ba59 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -89,7 +89,7 @@ LLTrace::Count<> FPS("fpsstat"), FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"), TEX_BAKES("texbakes"), TEX_REBAKES("texrebakes"); -LLTrace::Count KBIT("kbitstat"), +LLTrace::Count KBIT("kbitstat"), LAYERS_KBIT("layerskbitstat"), OBJECT_KBIT("objectkbitstat"), ASSET_KBIT("assetkbitstat"), @@ -97,7 +97,7 @@ LLTrace::Count KBIT("kbitstat"), ACTUAL_IN_KBIT("actualinkbit"), ACTUAL_OUT_KBIT("actualoutkbit"); -LLTrace::Count AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), +LLTrace::Count AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"), TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"), MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"), FPS_10_TIME("fps10time", "Seconds below 10 FPS"), @@ -146,10 +146,10 @@ LLTrace::Measurement<> NUM_IMAGES("numimagesstat"), WINDOW_WIDTH("windowwidth", "Window width"), WINDOW_HEIGHT("windowheight", "Window height"); -LLTrace::Measurement AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections"); +LLTrace::Measurement AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections"); -LLTrace::Measurement SIM_UNACKED_BYTES("simtotalunackedbytes"), +LLTrace::Measurement SIM_UNACKED_BYTES("simtotalunackedbytes"), SIM_PHYSICS_MEM("physicsmemoryallocated"), GL_TEX_MEM("gltexmemstat"), GL_BOUND_MEM("glboundmemstat"), @@ -159,7 +159,7 @@ LLTrace::Measurement SIM_UNACKED_BYTES("simtotalunackedbytes"), MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"); -SimMeasurement SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS), +SimMeasurement SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS), SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS), SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS), SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS), @@ -174,7 +174,7 @@ SimMeasurement SIM_FRAME_TIME("simframemsec", "", LL_SIM_ SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME), SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME); -LLTrace::Measurement FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), +LLTrace::Measurement FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"), FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"), LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"), REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"), @@ -266,10 +266,10 @@ void LLViewerStats::updateFrameStats(const F64 time_diff) F32 max_bandwidth = gViewerThrottle.getMaxBandwidth(); F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth; - LLStatViewer::DELTA_BANDWIDTH.sample(delta_bandwidth); + LLStatViewer::DELTA_BANDWIDTH.sample(delta_bandwidth); //setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f); - LLStatViewer::MAX_BANDWIDTH.sample(max_bandwidth); + LLStatViewer::MAX_BANDWIDTH.sample(max_bandwidth); //setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f); } @@ -360,27 +360,27 @@ void update_statistics() LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) { - LLStatViewer::SIM_PING.sample(cdp->getPingDelay()); + LLStatViewer::SIM_PING.sample(cdp->getPingDelay()); //stats.mSimPingStat.addValue(cdp->getPingDelay()); gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1); gSimPingCount++; } else { - LLStatViewer::SIM_PING.sample(10000); + LLStatViewer::SIM_PING.sample(10000); //stats.mSimPingStat.addValue(10000); } //stats.mFPSStat.addValue(1); LLStatViewer::FPS.add(1); F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - LLStatViewer::LAYERS_KBIT.add(layer_bits); + LLStatViewer::LAYERS_KBIT.add(layer_bits); //stats.mLayersKBitStat.addValue(layer_bits/1024.f); - LLStatViewer::OBJECT_KBIT.add(gObjectBits); + LLStatViewer::OBJECT_KBIT.add(gObjectBits); //stats.mObjectKBitStat.addValue(gObjectBits/1024.f); //stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending()); LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending()); - LLStatViewer::ASSET_KBIT.add(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); + LLStatViewer::ASSET_KBIT.add(gTransferManager.getTransferBitsIn(LLTCT_ASSET)); //stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f); gTransferManager.resetTransferBitsIn(LLTCT_ASSET); @@ -419,7 +419,7 @@ void update_statistics() static LLFrameTimer texture_stats_timer; if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq) { - gTotalTextureBytes = LLUnits::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); + gTotalTextureBytes = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value(); texture_stats_timer.reset(); } } diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 40109bcea3..b182a40403 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -88,7 +88,7 @@ extern LLTrace::Count<> FPS, TEX_REBAKES; -extern LLTrace::Count KBIT, +extern LLTrace::Count KBIT, LAYERS_KBIT, OBJECT_KBIT, ASSET_KBIT, @@ -96,7 +96,7 @@ extern LLTrace::Count KBIT, ACTUAL_IN_KBIT, ACTUAL_OUT_KBIT; -extern LLTrace::Count AVATAR_EDIT_TIME, +extern LLTrace::Count AVATAR_EDIT_TIME, TOOLBOX_TIME, MOUSELOOK_TIME, FPS_10_TIME, @@ -145,9 +145,9 @@ extern LLTrace::Measurement<> NUM_IMAGES, WINDOW_WIDTH, WINDOW_HEIGHT; -extern LLTrace::Measurement AGENT_POSITION_SNAP; +extern LLTrace::Measurement AGENT_POSITION_SNAP; -extern LLTrace::Measurement SIM_UNACKED_BYTES, +extern LLTrace::Measurement SIM_UNACKED_BYTES, DELTA_BANDWIDTH, MAX_BANDWIDTH, SIM_PHYSICS_MEM, @@ -156,7 +156,7 @@ extern LLTrace::Measurement SIM_UNACKED_BYTES, RAW_MEM, FORMATTED_MEM; -extern SimMeasurement SIM_FRAME_TIME, +extern SimMeasurement SIM_FRAME_TIME, SIM_NET_TIME, SIM_OTHER_TIME, SIM_PHYSICS_TIME, @@ -172,7 +172,7 @@ extern SimMeasurement SIM_FRAME_TIME, SIM_PUMP_IO_TIME; -extern LLTrace::Measurement FRAMETIME_JITTER, +extern LLTrace::Measurement FRAMETIME_JITTER, FRAMETIME_SLEW, LOGIN_SECONDS, REGION_CROSSING_TIME, diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index b0f8f60d1e..f64134b8b7 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -64,6 +64,11 @@ #include "lltexturecache.h" /////////////////////////////////////////////////////////////////////////////// +// extern +const LLUnit::Megabytes gMinVideoRam = 32; +const LLUnit::Megabytes gMaxVideoRam = 512; + + // statics LLPointer LLViewerTexture::sNullImagep = NULL; LLPointer LLViewerTexture::sBlackImagep = NULL; @@ -82,11 +87,11 @@ S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sDesiredDiscardBias = 0.f; F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; -S32 LLViewerTexture::sBoundTextureMemoryInBytes = 0; -S32 LLViewerTexture::sTotalTextureMemoryInBytes = 0; -S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0; -S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0; -S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ; +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 ; S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ; F32 LLViewerTexture::sCameraMovingBias = 0.0f ; S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size @@ -518,17 +523,17 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity LLViewerMediaTexture::updateClass() ; } - sBoundTextureMemoryInBytes = LLImageGL::sBoundTextureMemoryInBytes;//in bytes - sTotalTextureMemoryInBytes = LLImageGL::sGlobalTextureMemoryInBytes;//in bytes - sMaxBoundTextureMemInMegaBytes = gTextureList.getMaxResidentTexMem();//in MB - sMaxTotalTextureMemInMegaBytes = gTextureList.getMaxTotalTextureMem() ;//in MB - sMaxDesiredTextureMemInBytes = MEGA_BYTES_TO_BYTES(sMaxTotalTextureMemInMegaBytes) ; //in Bytes, by default and when total used texture memory is small. + sBoundTextureMemory = LLImageGL::sBoundTextureMemory;//in bytes + sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;//in bytes + sMaxBoundTextureMem = gTextureList.getMaxResidentTexMem();//in MB + sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem() ;//in MB + sMaxDesiredTextureMem = sMaxTotalTextureMem ; //in Bytes, by default and when total used texture memory is small. - if (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) >= sMaxBoundTextureMemInMegaBytes || - BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) >= sMaxTotalTextureMemInMegaBytes) + if (sBoundTextureMemory >= sMaxBoundTextureMem || + sTotalTextureMemory >= sMaxTotalTextureMem) { //when texture memory overflows, lower down the threashold to release the textures more aggressively. - sMaxDesiredTextureMemInBytes = llmin((S32)(sMaxDesiredTextureMemInBytes * 0.75f) , MEGA_BYTES_TO_BYTES(MAX_VIDEO_RAM_IN_MEGA_BYTES)) ;//512 MB + sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, (LLUnit::Bytes)gMaxVideoRam) ;//512 MB // If we are using more texture memory than we should, // scale up the desired discard level @@ -544,8 +549,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity sEvaluationTimer.reset(); } else if (sDesiredDiscardBias > 0.0f && - BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale && - BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale) + sBoundTextureMemory < sMaxBoundTextureMem * texmem_lower_bound_scale && + sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale) { // If we are using less texture memory than we should, // scale down the desired discard level @@ -563,8 +568,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1); sCameraMovingDiscardBias = (S8)(sCameraMovingBias); - LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) && - (BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ; + LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < 0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale) && + (sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale) ; } //end of static functions @@ -3301,13 +3306,13 @@ void LLViewerLODTexture::processTextureStats() scaleDown() ; } // Limit the amount of GL memory bound each frame - else if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale && + else if ( sBoundTextureMemory > sMaxBoundTextureMem * texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { scaleDown() ; } // Only allow GL to have 2x the video card memory - else if ( BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale && + else if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { scaleDown() ; diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 2ea9a07e9a..aa1e2010b4 100755 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -34,12 +34,13 @@ #include "llgltypes.h" #include "llrender.h" #include "llmetricperformancetester.h" +#include "llunit.h" #include #include -#define MIN_VIDEO_RAM_IN_MEGA_BYTES 32 -#define MAX_VIDEO_RAM_IN_MEGA_BYTES 512 // 512MB max for performance reasons. +extern const LLUnit::Megabytes gMinVideoRam; +extern const LLUnit::Megabytes gMaxVideoRam; class LLFace; class LLImageGL ; @@ -322,11 +323,11 @@ public: static LLFrameTimer sEvaluationTimer; static F32 sDesiredDiscardBias; static F32 sDesiredDiscardScale; - static S32 sBoundTextureMemoryInBytes; - static S32 sTotalTextureMemoryInBytes; - static S32 sMaxBoundTextureMemInMegaBytes; - static S32 sMaxTotalTextureMemInMegaBytes; - static S32 sMaxDesiredTextureMemInBytes ; + static LLUnit::Bytes sBoundTextureMemory; + static LLUnit::Bytes sTotalTextureMemory; + static LLUnit::Megabytes sMaxBoundTextureMem; + static LLUnit::Megabytes sMaxTotalTextureMem; + static LLUnit::Bytes sMaxDesiredTextureMem ; static S8 sCameraMovingDiscardBias; static F32 sCameraMovingBias; static S32 sMaxSculptRez ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 56ccf3b1f0..d355432e8a 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -606,8 +606,8 @@ void LLViewerTextureList::updateImages(F32 max_time) if(gTeleportDisplay) { if(!cleared) - { - clearFetchingRequests(); + { + clearFetchingRequests(); gPipeline.clearRebuildGroups(); cleared = TRUE; } @@ -623,10 +623,10 @@ void LLViewerTextureList::updateImages(F32 max_time) using namespace LLStatViewer; NUM_IMAGES.sample(sNumImages); NUM_RAW_IMAGES.sample(LLImageRaw::sRawImageCount); - GL_TEX_MEM.sample(LLImageGL::sGlobalTextureMemoryInBytes); - GL_BOUND_MEM.sample(LLImageGL::sBoundTextureMemoryInBytes); - RAW_MEM.sample(LLImageRaw::sGlobalRawMemory); - FORMATTED_MEM.sample(LLImageFormatted::sGlobalFormattedMemory); + GL_TEX_MEM.sample(LLImageGL::sGlobalTextureMemory); + GL_BOUND_MEM.sample(LLImageGL::sBoundTextureMemory); + RAW_MEM.sample(LLImageRaw::sGlobalRawMemory); + FORMATTED_MEM.sample(LLImageFormatted::sGlobalFormattedMemory); } { @@ -1184,7 +1184,7 @@ S32 LLViewerTextureList::getMinVideoRamSetting() { S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); //min texture mem sets to 64M if total physical mem is more than 1.5GB - return (system_ram > 1500) ? 64 : MIN_VIDEO_RAM_IN_MEGA_BYTES ; + return (system_ram > 1500) ? 64 : gMinVideoRam.value() ; } //static @@ -1234,7 +1234,7 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) else max_texmem = llmin(max_texmem, (S32)(system_ram)); - max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM_IN_MEGA_BYTES); + max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), gMaxVideoRam.value()); return max_texmem; } @@ -1322,7 +1322,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d { received_size = msg->getReceiveSize() ; } - LLStatViewer::TEXTURE_KBIT.add(received_size); + LLStatViewer::TEXTURE_KBIT.add(received_size); LLStatViewer::TEXTURE_PACKETS.add(1); U8 codec; @@ -1396,7 +1396,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d received_size = msg->getReceiveSize() ; } - LLStatViewer::TEXTURE_KBIT.add(received_size); + LLStatViewer::TEXTURE_KBIT.add(received_size); LLStatViewer::TEXTURE_PACKETS.add(1); //llprintline("Start decode, image header..."); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 8161caf5e4..2062f07650 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4740,7 +4740,7 @@ void LLViewerWindow::stopGL(BOOL save_state) gGLManager.mIsDisabled = TRUE; stop_glerror(); - llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemoryInBytes << " bytes" << llendl; + llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemory.value() << " bytes" << llendl; } } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index 3e8b07b6dc..9f0921ff59 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -2790,7 +2790,7 @@ void LLVOAvatarSelf::deleteScratchTextures() sScratchTexNames.deleteAllData(); sScratchTexLastBindTime.deleteAllData(); - LLImageGL::sGlobalTextureMemoryInBytes -= sScratchTexBytes; + LLImageGL::sGlobalTextureMemory -= sScratchTexBytes; sScratchTexBytes = 0; } } diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 604741ff27..dced5a847b 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -703,11 +703,11 @@ void LLWorld::updateNetStats() S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits(); S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits(); - LLStatViewer::ACTUAL_IN_KBIT.add(actual_in_bits); - LLStatViewer::ACTUAL_OUT_KBIT.add(actual_out_bits); + LLStatViewer::ACTUAL_IN_KBIT.add(actual_in_bits); + LLStatViewer::ACTUAL_OUT_KBIT.add(actual_out_bits); //LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f); //LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f); - LLStatViewer::KBIT.add(bits); + LLStatViewer::KBIT.add(bits); //LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f); LLStatViewer::PACKETS_IN.add(packets_in); LLStatViewer::PACKETS_OUT.add(packets_out); -- cgit v1.2.3