From 8bddaeec6647e735415f9bd72a4e1313e11fe720 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 22 Jun 2013 12:00:18 -0700 Subject: fixed scene load monitor resetting to eagerly due to spurious camer amotion pulled swap() out of ui time block cleaned up internal lltrace dependencies, factored out common accumulator definitions --- indra/llcommon/lltraceaccumulators.cpp | 112 +++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 indra/llcommon/lltraceaccumulators.cpp (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp new file mode 100644 index 0000000000..5948696418 --- /dev/null +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -0,0 +1,112 @@ +/** + * @file lltracesampler.cpp + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2012, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltraceaccumulators.h" +#include "lltracethreadrecorder.h" + +namespace LLTrace +{ + + +/////////////////////////////////////////////////////////////////////// +// AccumulatorBufferGroup +/////////////////////////////////////////////////////////////////////// + +AccumulatorBufferGroup::AccumulatorBufferGroup() +{} + +void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) +{ + other.mCounts.reset(&mCounts); + other.mSamples.reset(&mSamples); + other.mEvents.reset(&mEvents); + other.mStackTimers.reset(&mStackTimers); + other.mMemStats.reset(&mMemStats); +} + +void AccumulatorBufferGroup::makePrimary() +{ + mCounts.makePrimary(); + mSamples.makePrimary(); + mEvents.makePrimary(); + mStackTimers.makePrimary(); + mMemStats.makePrimary(); + + ThreadRecorder* thread_recorder = get_thread_recorder().get(); + AccumulatorBuffer& timer_accumulator_buffer = mStackTimers; + // update stacktimer parent pointers + for (S32 i = 0, end_i = mStackTimers.size(); i < end_i; i++) + { + TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(i); + if (tree_node) + { + timer_accumulator_buffer[i].mParent = tree_node->mParent; + } + } +} + +bool AccumulatorBufferGroup::isPrimary() const +{ + return mCounts.isPrimary(); +} + +void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) +{ + mCounts.addSamples(other.mCounts); + mSamples.addSamples(other.mSamples); + mEvents.addSamples(other.mEvents); + mMemStats.addSamples(other.mMemStats); + mStackTimers.addSamples(other.mStackTimers); +} + +void AccumulatorBufferGroup::merge( const AccumulatorBufferGroup& other) +{ + mCounts.addSamples(other.mCounts, false); + mSamples.addSamples(other.mSamples, false); + mEvents.addSamples(other.mEvents, false); + mMemStats.addSamples(other.mMemStats, false); + // for now, hold out timers from merge, need to be displayed per thread + //mStackTimers.addSamples(other.mStackTimers, false); +} + +void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) +{ + mCounts.reset(other ? &other->mCounts : NULL); + mSamples.reset(other ? &other->mSamples : NULL); + mEvents.reset(other ? &other->mEvents : NULL); + mStackTimers.reset(other ? &other->mStackTimers : NULL); + mMemStats.reset(other ? &other->mMemStats : NULL); +} + +void AccumulatorBufferGroup::flush() +{ + LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); + + mSamples.flush(time_stamp); +} + +} -- cgit v1.3 From 808d3eff198d65e5a870abb670786935fc8356bd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 27 Jun 2013 00:07:21 -0700 Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in statistics console fixed some lltrace logic errors more consistent syncing of timestamps of sample values in recording stack selection of primary buffers was completely incorrect assignment of recordings got wrong play state due to implicit operator = defined in base class fixed asset stats only working up to the first send --- indra/llcommon/llfasttimer.h | 7 ---- indra/llcommon/lltraceaccumulators.cpp | 15 +++++++-- indra/llcommon/lltraceaccumulators.h | 37 ++++++++++++++------- indra/llcommon/lltracerecording.cpp | 7 ++-- indra/llcommon/lltracerecording.h | 6 ++++ indra/llcommon/lltracethreadrecorder.cpp | 57 ++++++++++++++++++++------------ indra/llcommon/lltracethreadrecorder.h | 2 +- indra/newview/llappviewer.cpp | 4 ++- indra/newview/llviewerassetstats.cpp | 15 +++++---- 9 files changed, 95 insertions(+), 55 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 642c99ccce..ab8612a8ad 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -38,13 +38,6 @@ class LLMutex; namespace LLTrace { -struct BlockTimerStackRecord -{ - class BlockTimer* mActiveTimer; - class TimeBlock* mTimeBlock; - U64 mChildTime; -}; - class ThreadTimerStack : public BlockTimerStackRecord, public LLThreadLocalSingleton diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 5948696418..950c1d97d1 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -69,6 +69,16 @@ void AccumulatorBufferGroup::makePrimary() } } +//static +void AccumulatorBufferGroup::clearPrimary() +{ + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::clearPrimary(); +} + bool AccumulatorBufferGroup::isPrimary() const { return mCounts.isPrimary(); @@ -102,11 +112,12 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) mMemStats.reset(other ? &other->mMemStats : NULL); } -void AccumulatorBufferGroup::flush() +void AccumulatorBufferGroup::sync() { LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); - mSamples.flush(time_stamp); + mSamples.sync(time_stamp); + mMemStats.sync(time_stamp); } } diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 7994dcc217..825cc9e3a8 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -109,12 +109,12 @@ namespace LLTrace } } - void flush(LLUnitImplicit time_stamp) + void sync(LLUnitImplicit time_stamp) { llassert(mStorageSize >= sNextStorageSlot); for (size_t i = 0; i < sNextStorageSlot; i++) { - mStorage[i].flush(time_stamp); + mStorage[i].sync(time_stamp); } } @@ -128,6 +128,11 @@ namespace LLTrace return LLThreadLocalSingletonPointer::getInstance() == mStorage; } + static void clearPrimary() + { + LLThreadLocalSingletonPointer::setInstance(NULL); + } + LL_FORCE_INLINE static ACCUMULATOR* getPrimaryStorage() { ACCUMULATOR* accumulator = LLThreadLocalSingletonPointer::getInstance(); @@ -302,7 +307,7 @@ namespace LLTrace mLastValue = other ? other->mLastValue : 0; } - void flush(LLUnitImplicit) {} + void sync(LLUnitImplicit) {} F64 getSum() const { return mSum; } F64 getMin() const { return mMin; } @@ -434,7 +439,7 @@ namespace LLTrace mHasValue = other ? other->mHasValue : false; } - void flush(LLUnitImplicit time_stamp) + void sync(LLUnitImplicit time_stamp) { LLUnitImplicit delta_time = time_stamp - mLastSampleTimeStamp; @@ -500,7 +505,7 @@ namespace LLTrace mSum = 0; } - void flush(LLUnitImplicit) {} + void sync(LLUnitImplicit) {} F64 getSum() const { return mSum; } @@ -535,7 +540,7 @@ namespace LLTrace TimeBlockAccumulator(); void addSamples(const self_t& other, bool /*append*/); void reset(const self_t* other); - void flush(LLUnitImplicit) {} + void sync(LLUnitImplicit) {} // // members @@ -566,6 +571,13 @@ namespace LLTrace bool mCollapsed; bool mNeedsSorting; }; + + struct BlockTimerStackRecord + { + class BlockTimer* mActiveTimer; + class TimeBlock* mTimeBlock; + U64 mChildTime; + }; struct MemStatAccumulator { @@ -611,16 +623,16 @@ namespace LLTrace mDeallocatedCount = 0; } - void flush(LLUnitImplicit time_stamp) + void sync(LLUnitImplicit time_stamp) { - mSize.flush(time_stamp); - mChildSize.flush(time_stamp); + mSize.sync(time_stamp); + mChildSize.sync(time_stamp); } SampleAccumulator mSize, - mChildSize; + mChildSize; int mAllocatedCount, - mDeallocatedCount; + mDeallocatedCount; }; struct AccumulatorBufferGroup : public LLRefCount @@ -630,11 +642,12 @@ namespace LLTrace void handOffTo(AccumulatorBufferGroup& other); void makePrimary(); bool isPrimary() const; + static void clearPrimary(); void append(const AccumulatorBufferGroup& other); void merge(const AccumulatorBufferGroup& other); void reset(AccumulatorBufferGroup* other = NULL); - void flush(); + void sync(); AccumulatorBuffer mCounts; AccumulatorBuffer mSamples; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c30f204fa4..0938317eaa 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -59,11 +59,12 @@ Recording& Recording::operator = (const Recording& other) mBuffers = other.mBuffers; - LLStopWatchControlsMixin::setPlayState(other_play_state); - // above call will clear mElapsedSeconds as a side effect, so copy it here mElapsedSeconds = other.mElapsedSeconds; mSamplingTimer = other.mSamplingTimer; + + setPlayState(other_play_state); + return *this; } @@ -82,7 +83,6 @@ void Recording::update() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); AccumulatorBufferGroup* buffers = mBuffers.write(); - buffers->flush(); LLTrace::get_thread_recorder()->bringUpToDate(buffers); mSamplingTimer.reset(); @@ -107,7 +107,6 @@ void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); AccumulatorBufferGroup* buffers = mBuffers.write(); - buffers->flush(); LLTrace::get_thread_recorder()->deactivate(buffers); } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 38eaa47f9f..355dbabb1c 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -81,6 +81,7 @@ class LLStopWatchControlsMixin : public LLStopWatchControlsMixinCommon { public: + typedef LLStopWatchControlsMixin self_t; virtual void splitTo(DERIVED& other) { @@ -98,6 +99,11 @@ public: static_cast(other).handleSplitTo(*static_cast(this)); } private: + self_t& operator = (const self_t& other) + { + // don't do anything, derived class must implement logic + } + // atomically stop this object while starting the other // no data can be missed in between stop and start virtual void handleSplitTo(DERIVED& other) {}; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index c571e013e1..7192564c94 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -87,7 +87,7 @@ ThreadRecorder::~ThreadRecorder() delete[] mTimeBlockTreeNodes; } -TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode(S32 index) +TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode( S32 index ) { if (0 <= index && index < mNumTimeBlockTreeNodes) { @@ -99,10 +99,20 @@ TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode(S32 index) void ThreadRecorder::activate( AccumulatorBufferGroup* recording ) { + active_recording_list_t::reverse_iterator it, end_it; + for (it = mActiveRecordings.rbegin(), end_it = mActiveRecordings.rend(); + it != end_it; + ++it) + { + llassert((*it)->mTargetRecording != recording); + } + ActiveRecording* active_recording = new ActiveRecording(recording); if (!mActiveRecordings.empty()) { - mActiveRecordings.back()->mPartialRecording.handOffTo(active_recording->mPartialRecording); + AccumulatorBufferGroup& prev_active_recording = mActiveRecordings.back()->mPartialRecording; + prev_active_recording.sync(); + prev_active_recording.handOffTo(active_recording->mPartialRecording); } mActiveRecordings.push_back(active_recording); @@ -113,7 +123,7 @@ ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringU { if (mActiveRecordings.empty()) return mActiveRecordings.rend(); - mActiveRecordings.back()->mPartialRecording.flush(); + mActiveRecordings.back()->mPartialRecording.sync(); TimeBlock::updateTimes(); active_recording_list_t::reverse_iterator it, end_it; @@ -156,18 +166,22 @@ void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) active_recording_list_t::reverse_iterator it = bringUpToDate(recording); if (it != mActiveRecordings.rend()) { - // and if we've found the recording we wanted to update - active_recording_list_t::reverse_iterator next_it = it; - ++next_it; - if (next_it != mActiveRecordings.rend()) - { - (*next_it)->mPartialRecording.makePrimary(); - } - active_recording_list_t::iterator recording_to_remove = (++it).base(); + bool was_primary = (*recording_to_remove)->mPartialRecording.isPrimary(); llassert((*recording_to_remove)->mTargetRecording == recording); delete *recording_to_remove; mActiveRecordings.erase(recording_to_remove); + if (was_primary) + { + if (mActiveRecordings.empty()) + { + AccumulatorBufferGroup::clearPrimary(); + } + else + { + mActiveRecordings.back()->mPartialRecording.makePrimary(); + } + } } } @@ -202,7 +216,6 @@ SlaveThreadRecorder::~SlaveThreadRecorder() void SlaveThreadRecorder::pushToMaster() { { LLMutexLock lock(&mSharedRecordingMutex); - mThreadRecordingBuffers.flush(); LLTrace::get_thread_recorder()->bringUpToDate(&mThreadRecordingBuffers); mSharedRecordingBuffers.append(mThreadRecordingBuffers); } @@ -213,23 +226,25 @@ void SlaveThreadRecorder::pushToMaster() /////////////////////////////////////////////////////////////////////// static LLFastTimer::DeclareTimer FTM_PULL_TRACE_DATA_FROM_SLAVES("Pull slave trace data"); + void MasterThreadRecorder::pullFromSlaveThreads() { - LLFastTimer _(FTM_PULL_TRACE_DATA_FROM_SLAVES); + /*LLFastTimer _(FTM_PULL_TRACE_DATA_FROM_SLAVES); if (mActiveRecordings.empty()) return; { LLMutexLock lock(&mSlaveListMutex); - AccumulatorBufferGroup& target_recording_buffers = mActiveRecordings.back()->mPartialRecording; - for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); - it != end_it; - ++it) - { LLMutexLock lock(&(*it)->mSharedRecordingMutex); + AccumulatorBufferGroup& target_recording_buffers = mActiveRecordings.back()->mPartialRecording; + target_recording_buffers.sync(); + for (slave_thread_recorder_list_t::iterator it = mSlaveThreadRecorders.begin(), end_it = mSlaveThreadRecorders.end(); + it != end_it; + ++it) + { LLMutexLock lock(&(*it)->mSharedRecordingMutex); - target_recording_buffers.merge((*it)->mSharedRecordingBuffers); - (*it)->mSharedRecordingBuffers.reset(); - } + target_recording_buffers.merge((*it)->mSharedRecordingBuffers); + (*it)->mSharedRecordingBuffers.reset(); } + }*/ } // called by slave thread diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index 0680c2c590..6b7a8e5865 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -71,6 +71,7 @@ namespace LLTrace class BlockTimer* mRootTimer; TimeBlockTreeNode* mTimeBlockTreeNodes; size_t mNumTimeBlockTreeNodes; + BlockTimerStackRecord mBlockTimerStackRecord; }; class LL_COMMON_API MasterThreadRecorder : public ThreadRecorder @@ -105,7 +106,6 @@ namespace LLTrace private: friend class MasterThreadRecorder; - MasterThreadRecorder* mMaster; LLMutex mSharedRecordingMutex; AccumulatorBufferGroup mSharedRecordingBuffers; MasterThreadRecorder& mMasterRecorder; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 733c9cc9df..7c5cd520da 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1294,6 +1294,8 @@ bool LLAppViewer::mainLoop() { LLFastTimer _(FTM_FRAME); LLTrace::TimeBlock::processTimes(); + llassert((LLTrace::get_frame_recording().getCurRecording().update(), + LLTrace::get_frame_recording().getCurRecording().getSampleCount(LLStatViewer::FPS) <= 1)); LLTrace::get_frame_recording().nextPeriod(); LLTrace::TimeBlock::logStats(); @@ -5617,6 +5619,6 @@ void LLAppViewer::metricsSend(bool enable_reporting) // Reset even if we can't report. Rather than gather up a huge chunk of // data, we'll keep to our sampling interval and retain the data // resolution in time. - gViewerAssetStats->reset(); + gViewerAssetStats->restart(); } diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp index bada565d3d..af82b61dc8 100755 --- a/indra/newview/llviewerassetstats.cpp +++ b/indra/newview/llviewerassetstats.cpp @@ -314,9 +314,9 @@ void LLViewerAssetStats::handleStop() } void LLViewerAssetStats::handleReset() - { +{ reset(); - } +} void LLViewerAssetStats::reset() @@ -328,6 +328,7 @@ void LLViewerAssetStats::reset() if (mRegionHandle) { mCurRecording = &mRegionRecordings[mRegionHandle]; + mCurRecording->setPlayState(getPlayState()); } } @@ -346,7 +347,7 @@ void LLViewerAssetStats::setRegion(region_handle_t region_handle) if (region_handle) { mCurRecording = &mRegionRecordings[region_handle]; - mCurRecording->start(); + mCurRecording->setPlayState(getPlayState()); } mRegionHandle = region_handle; @@ -493,19 +494,19 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output) } LLSD LLViewerAssetStats::asLLSD(bool compact_output) - { +{ LLParamSDParser parser; LLSD sd; AssetStats stats; getStats(stats, compact_output); LLInitParam::predicate_rule_t rule = LLInitParam::default_parse_rules(); if (!compact_output) - { + { rule.allow(LLInitParam::EMPTY); - } + } parser.writeSD(sd, stats, rule); return sd; - } +} // ------------------------------------------------------ // Global free-function definitions (LLViewerAssetStatsFF namespace) -- cgit v1.3 From 8d3daa141e9ea14f533559843d77ab5c0f715421 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 9 Aug 2013 16:14:19 -0700 Subject: SH-4374 FIX Interesting: Statistics Object cache hit rate is always 100% moved object cache sampling code so that it actually gets executed default values for stats are NaN instead of 0 in many cases --- indra/llcommon/llfasttimer.cpp | 4 +- indra/llcommon/lltraceaccumulators.cpp | 146 +++++++++++++++-- indra/llcommon/lltraceaccumulators.h | 291 +++++++++++---------------------- indra/llcommon/lltracerecording.cpp | 42 +++-- indra/llcommon/lltracerecording.h | 2 + indra/llmath/llmath.h | 4 + indra/llui/lllayoutstack.h | 2 +- indra/newview/llviewerobjectlist.cpp | 5 +- indra/newview/llviewerobjectlist.h | 2 - indra/newview/llviewerregion.cpp | 1 + indra/newview/llviewerstats.cpp | 3 + indra/newview/llviewerstats.h | 2 + 12 files changed, 280 insertions(+), 224 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index f4c87ab6f6..3b17b6022c 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -431,11 +431,11 @@ TimeBlockAccumulator::TimeBlockAccumulator() mParent(NULL) {} -void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other, bool append ) +void TimeBlockAccumulator::addSamples( const TimeBlockAccumulator& other, EBufferAppendType append_type ) { // we can't merge two unrelated time block samples, as that will screw with the nested timings // due to the call hierarchy of each thread - llassert(append); + llassert(append_type == SEQUENTIAL); mTotalTimeCounter += other.mTotalTimeCounter - other.mStartTotalTimeCounter; mSelfTimeCounter += other.mSelfTimeCounter; mCalls += other.mCalls; diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 950c1d97d1..a632f5634c 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -86,21 +86,21 @@ bool AccumulatorBufferGroup::isPrimary() const void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) { - mCounts.addSamples(other.mCounts); - mSamples.addSamples(other.mSamples); - mEvents.addSamples(other.mEvents); - mMemStats.addSamples(other.mMemStats); - mStackTimers.addSamples(other.mStackTimers); + mCounts.addSamples(other.mCounts, SEQUENTIAL); + mSamples.addSamples(other.mSamples, SEQUENTIAL); + mEvents.addSamples(other.mEvents, SEQUENTIAL); + mMemStats.addSamples(other.mMemStats, SEQUENTIAL); + mStackTimers.addSamples(other.mStackTimers, SEQUENTIAL); } void AccumulatorBufferGroup::merge( const AccumulatorBufferGroup& other) { - mCounts.addSamples(other.mCounts, false); - mSamples.addSamples(other.mSamples, false); - mEvents.addSamples(other.mEvents, false); - mMemStats.addSamples(other.mMemStats, false); + mCounts.addSamples(other.mCounts, NON_SEQUENTIAL); + mSamples.addSamples(other.mSamples, NON_SEQUENTIAL); + mEvents.addSamples(other.mEvents, NON_SEQUENTIAL); + mMemStats.addSamples(other.mMemStats, NON_SEQUENTIAL); // for now, hold out timers from merge, need to be displayed per thread - //mStackTimers.addSamples(other.mStackTimers, false); + //mStackTimers.addSamples(other.mStackTimers, NON_SEQUENTIAL); } void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) @@ -120,4 +120,130 @@ void AccumulatorBufferGroup::sync() mMemStats.sync(time_stamp); } +void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) +{ + if (!mHasValue) + { + *this = other; + + if (append_type == NON_SEQUENTIAL) + { + // restore own last value state + mLastValue = NaN; + mHasValue = false; + } + } + else if (other.mHasValue) + { + mSum += other.mSum; + + if (other.mMin < mMin) { mMin = other.mMin; } + if (other.mMax > mMax) { mMax = other.mMax; } + + F64 epsilon = 0.0000001; + + if (other.mTotalSamplingTime > epsilon) + { + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = mTotalSamplingTime, + n_2 = other.mTotalSamplingTime; + F64 m_1 = mMean, + m_2 = other.mMean; + F64 v_1 = mSumOfSquares / mTotalSamplingTime, + v_2 = other.mSumOfSquares / other.mTotalSamplingTime; + if (n_1 < epsilon) + { + mSumOfSquares = other.mSumOfSquares; + } + else + { + mSumOfSquares = mTotalSamplingTime + * ((((n_1 - epsilon) * v_1) + + ((n_2 - epsilon) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - epsilon)); + } + + llassert(other.mTotalSamplingTime > 0); + F64 weight = mTotalSamplingTime / (mTotalSamplingTime + other.mTotalSamplingTime); + mNumSamples += other.mNumSamples; + mTotalSamplingTime += other.mTotalSamplingTime; + mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); + } + if (append_type == SEQUENTIAL) + { + mLastValue = other.mLastValue; + mLastSampleTimeStamp = other.mLastSampleTimeStamp; + mHasValue = true; + } + } +} + +void SampleAccumulator::reset( const SampleAccumulator* other ) +{ + mLastValue = other ? other->mLastValue : NaN; + mHasValue = other ? other->mHasValue : false; + mNumSamples = 0; + mSum = 0; + mMin = mLastValue; + mMax = mLastValue; + mMean = mLastValue; + mSumOfSquares = 0; + mLastSampleTimeStamp = LLTimer::getTotalSeconds(); + mTotalSamplingTime = 0; +} + +void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendType append_type ) +{ + if (other.mNumSamples) + { + if (!mNumSamples) + { + *this = other; + } + else + { + mSum += other.mSum; + + // NOTE: both conditions will hold first time through + if (other.mMin < mMin) { mMin = other.mMin; } + if (other.mMax > mMax) { mMax = other.mMax; } + + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = (F64)mNumSamples, + n_2 = (F64)other.mNumSamples; + F64 m_1 = mMean, + m_2 = other.mMean; + F64 v_1 = mSumOfSquares / mNumSamples, + v_2 = other.mSumOfSquares / other.mNumSamples; + mSumOfSquares = (F64)mNumSamples + * ((((n_1 - 1.f) * v_1) + + ((n_2 - 1.f) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - 1.f)); + + F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); + mNumSamples += other.mNumSamples; + mMean = mMean * weight + other.mMean * (1.f - weight); + if (append_type == SEQUENTIAL) mLastValue = other.mLastValue; + } + } +} + +void EventAccumulator::reset( const EventAccumulator* other ) +{ + mNumSamples = 0; + mSum = NaN; + mMin = NaN; + mMax = NaN; + mMean = NaN; + mSumOfSquares = 0; + mLastValue = other ? other->mLastValue : NaN; +} + + } diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 9ea787188c..5871dc4bea 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -38,6 +38,14 @@ namespace LLTrace { + const F64 NaN = std::numeric_limits::quiet_NaN(); + + enum EBufferAppendType + { + SEQUENTIAL, + NON_SEQUENTIAL + }; + template class AccumulatorBuffer : public LLRefCount { @@ -83,12 +91,12 @@ namespace LLTrace return mStorage[index]; } - void addSamples(const AccumulatorBuffer& other, bool append = true) + void addSamples(const AccumulatorBuffer& other, EBufferAppendType append_type) { llassert(mStorageSize >= sNextStorageSlot && other.mStorageSize > sNextStorageSlot); for (size_t i = 0; i < sNextStorageSlot; i++) { - mStorage[i].addSamples(other.mStorage[i], append); + mStorage[i].addSamples(other.mStorage[i], append_type); } } @@ -211,7 +219,6 @@ namespace LLTrace template size_t AccumulatorBuffer::sNextStorageSlot = 0; template AccumulatorBuffer* AccumulatorBuffer::sDefaultBuffer = NULL; - class EventAccumulator { public: @@ -219,98 +226,51 @@ namespace LLTrace typedef F64 mean_t; EventAccumulator() - : mSum(0), - mMin((std::numeric_limits::max)()), - mMax((std::numeric_limits::min)()), - mMean(0), + : mSum(NaN), + mMin(NaN), + mMax(NaN), + mMean(NaN), mSumOfSquares(0), mNumSamples(0), - mLastValue(0) + mLastValue(NaN) {} void record(F64 value) { - mNumSamples++; - mSum += value; - // NOTE: both conditions will hold on first pass through - if (value < mMin) + if (mNumSamples == 0) { + mSum = value; + mMean = value; mMin = value; - } - if (value > mMax) - { mMax = value; } - F64 old_mean = mMean; - mMean += (value - old_mean) / (F64)mNumSamples; - mSumOfSquares += (value - old_mean) * (value - mMean); - mLastValue = value; - } - - void addSamples(const EventAccumulator& other, bool append) - { - if (other.mNumSamples) + else { - mSum += other.mSum; - - // NOTE: both conditions will hold first time through - if (other.mMin < mMin) { mMin = other.mMin; } - if (other.mMax > mMax) { mMax = other.mMax; } - - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - F64 n_1 = (F64)mNumSamples, - n_2 = (F64)other.mNumSamples; - F64 m_1 = mMean, - m_2 = other.mMean; - F64 v_1 = mSumOfSquares / mNumSamples, - v_2 = other.mSumOfSquares / other.mNumSamples; - if (n_1 == 0) - { - mSumOfSquares = other.mSumOfSquares; - } - else if (n_2 == 0) - { - // don't touch variance - // mSumOfSquares = mSumOfSquares; - } - else - { - mSumOfSquares = (F64)mNumSamples - * ((((n_1 - 1.f) * v_1) - + ((n_2 - 1.f) * v_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - 1.f)); - } + mSum += value; + F64 old_mean = mMean; + mMean += (value - old_mean) / (F64)mNumSamples; + mSumOfSquares += (value - old_mean) * (value - mMean); - F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); - mNumSamples += other.mNumSamples; - mMean = mMean * weight + other.mMean * (1.f - weight); - if (append) mLastValue = other.mLastValue; + if (value < mMin) { mMin = value; } + else if (value > mMax) { mMax = value; } } - } - void reset(const EventAccumulator* other) - { - mNumSamples = 0; - mSum = 0; - mMin = std::numeric_limits::max(); - mMax = std::numeric_limits::min(); - mMean = 0; - mSumOfSquares = 0; - mLastValue = other ? other->mLastValue : 0; + mNumSamples++; + mLastValue = value; } + void addSamples(const EventAccumulator& other, EBufferAppendType append_type); + void reset(const EventAccumulator* other); void sync(LLUnitImplicit) {} - F64 getSum() const { return mSum; } - F64 getMin() const { return mMin; } - F64 getMax() const { return mMax; } - F64 getLastValue() const { return mLastValue; } - F64 getMean() const { return mMean; } + F64 getSum() const { return mSum; } + F64 getMin() const { return mMin; } + F64 getMax() const { return mMax; } + F64 getLastValue() const { return mLastValue; } + F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mNumSamples); } - U32 getSampleCount() const { return mNumSamples; } + U32 getSampleCount() const { return mNumSamples; } + bool hasValue() const { return mNumSamples > 0; } private: F64 mSum, @@ -333,143 +293,85 @@ namespace LLTrace SampleAccumulator() : mSum(0), - mMin((std::numeric_limits::max)()), - mMax((std::numeric_limits::min)()), - mMean(0), + mMin(NaN), + mMax(NaN), + mMean(NaN), mSumOfSquares(0), - mLastSampleTimeStamp(LLTimer::getTotalSeconds()), + mLastSampleTimeStamp(0), mTotalSamplingTime(0), mNumSamples(0), - mLastValue(0), + mLastValue(NaN), mHasValue(false) {} void sample(F64 value) { LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); - LLUnitImplicit delta_time = time_stamp - mLastSampleTimeStamp; - mLastSampleTimeStamp = time_stamp; - if (mHasValue) + // store effect of last value + sync(time_stamp); + + if (!mHasValue) { - mTotalSamplingTime += delta_time; - mSum += mLastValue * delta_time; + mHasValue = true; - // NOTE: both conditions will hold first time through + mMin = value; + mMax = value; + mMean = value; + mLastSampleTimeStamp = time_stamp; + } + else + { if (value < mMin) { mMin = value; } - if (value > mMax) { mMax = value; } - - F64 old_mean = mMean; - mMean += (delta_time / mTotalSamplingTime) * (mLastValue - old_mean); - mSumOfSquares += delta_time * (mLastValue - old_mean) * (mLastValue - mMean); + else if (value > mMax) { mMax = value; } } mLastValue = value; mNumSamples++; - mHasValue = true; } - void addSamples(const SampleAccumulator& other, bool append) - { - if (other.mTotalSamplingTime) - { - mSum += other.mSum; - - // NOTE: both conditions will hold first time through - if (other.mMin < mMin) { mMin = other.mMin; } - if (other.mMax > mMax) { mMax = other.mMax; } - - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - F64 n_1 = mTotalSamplingTime, - n_2 = other.mTotalSamplingTime; - F64 m_1 = mMean, - m_2 = other.mMean; - F64 v_1 = mSumOfSquares / mTotalSamplingTime, - v_2 = other.mSumOfSquares / other.mTotalSamplingTime; - if (n_1 == 0) - { - mSumOfSquares = other.mSumOfSquares; - } - else if (n_2 == 0) - { - // variance is unchanged - // mSumOfSquares = mSumOfSquares; - } - else - { - mSumOfSquares = mTotalSamplingTime - * ((((n_1 - 1.f) * v_1) - + ((n_2 - 1.f) * v_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - 1.f)); - } - - llassert(other.mTotalSamplingTime > 0); - F64 weight = mTotalSamplingTime / (mTotalSamplingTime + other.mTotalSamplingTime); - mNumSamples += other.mNumSamples; - mTotalSamplingTime += other.mTotalSamplingTime; - mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); - if (append) - { - mLastValue = other.mLastValue; - mLastSampleTimeStamp = other.mLastSampleTimeStamp; - mHasValue |= other.mHasValue; - } - } - } - - void reset(const SampleAccumulator* other) - { - mNumSamples = 0; - mSum = 0; - mMin = std::numeric_limits::max(); - mMax = std::numeric_limits::min(); - mMean = other ? other->mLastValue : 0; - mSumOfSquares = 0; - mLastSampleTimeStamp = LLTimer::getTotalSeconds(); - mTotalSamplingTime = 0; - mLastValue = other ? other->mLastValue : 0; - mHasValue = other ? other->mHasValue : false; - } + void addSamples(const SampleAccumulator& other, EBufferAppendType append_type); + void reset(const SampleAccumulator* other); void sync(LLUnitImplicit time_stamp) { - LLUnitImplicit delta_time = time_stamp - mLastSampleTimeStamp; - if (mHasValue) { + LLUnitImplicit delta_time = time_stamp - mLastSampleTimeStamp; mSum += mLastValue * delta_time; mTotalSamplingTime += delta_time; + F64 old_mean = mMean; + mMean += (delta_time / mTotalSamplingTime) * (mLastValue - old_mean); + mSumOfSquares += delta_time * (mLastValue - old_mean) * (mLastValue - mMean); } mLastSampleTimeStamp = time_stamp; } - F64 getSum() const { return mSum; } - F64 getMin() const { return mMin; } - F64 getMax() const { return mMax; } - F64 getLastValue() const { return mLastValue; } - F64 getMean() const { return mMean; } + F64 getSum() const { return mSum; } + F64 getMin() const { return mMin; } + F64 getMax() const { return mMax; } + F64 getLastValue() const { return mLastValue; } + F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mTotalSamplingTime); } - U32 getSampleCount() const { return mNumSamples; } - bool hasValue() const { return mHasValue; } + U32 getSampleCount() const { return mNumSamples; } + bool hasValue() const { return mHasValue; } private: - F64 mSum, - mMin, - mMax, - mLastValue; + F64 mSum, + mMin, + mMax, + mLastValue; - bool mHasValue; + bool mHasValue; // distinct from mNumSamples, since we might have inherited an old sample - F64 mMean, - mSumOfSquares; + F64 mMean, + mSumOfSquares; - LLUnitImplicit mLastSampleTimeStamp, - mTotalSamplingTime; + LLUnitImplicit + mLastSampleTimeStamp, + mTotalSamplingTime; - U32 mNumSamples; + U32 mNumSamples; }; class CountAccumulator @@ -489,7 +391,7 @@ namespace LLTrace mSum += value; } - void addSamples(const CountAccumulator& other, bool /*append*/) + void addSamples(const CountAccumulator& other, bool /*follows_in_sequence*/) { mSum += other.mSum; mNumSamples += other.mNumSamples; @@ -534,25 +436,26 @@ namespace LLTrace }; TimeBlockAccumulator(); - void addSamples(const self_t& other, bool /*append*/); + void addSamples(const self_t& other, EBufferAppendType append_type); void reset(const self_t* other); void sync(LLUnitImplicit) {} // // members // - U64 mStartTotalTimeCounter, - mTotalTimeCounter, - mSelfTimeCounter; - U32 mCalls; - class TimeBlock* mParent; // last acknowledged parent of this time block - class TimeBlock* mLastCaller; // used to bootstrap tree construction - U16 mActiveCount; // number of timers with this ID active on stack - bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame + U64 mStartTotalTimeCounter, + mTotalTimeCounter, + mSelfTimeCounter; + U32 mCalls; + class TimeBlock* mParent; // last acknowledged parent of this time block + class TimeBlock* mLastCaller; // used to bootstrap tree construction + U16 mActiveCount; // number of timers with this ID active on stack + bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame }; class TimeBlock; + class TimeBlockTreeNode { public: @@ -603,10 +506,10 @@ namespace LLTrace mDeallocatedCount(0) {} - void addSamples(const MemStatAccumulator& other, bool append) + void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) { - mSize.addSamples(other.mSize, append); - mChildSize.addSamples(other.mChildSize, append); + mSize.addSamples(other.mSize, append_type); + mChildSize.addSamples(other.mChildSize, append_type); mAllocatedCount += other.mAllocatedCount; mDeallocatedCount += other.mDeallocatedCount; } @@ -645,11 +548,11 @@ namespace LLTrace void reset(AccumulatorBufferGroup* other = NULL); void sync(); - AccumulatorBuffer mCounts; - AccumulatorBuffer mSamples; - AccumulatorBuffer mEvents; - AccumulatorBuffer mStackTimers; - AccumulatorBuffer mMemStats; + AccumulatorBuffer mCounts; + AccumulatorBuffer mSamples; + AccumulatorBuffer mEvents; + AccumulatorBuffer mStackTimers; + AccumulatorBuffer mMemStats; }; } diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 9fce6c11cc..a4d58d8ab1 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -287,6 +287,11 @@ U32 Recording::getSampleCount( const TraceType& stat ) return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } +bool Recording::hasValue(const TraceType& stat) +{ + return mBuffers->mEvents[stat.getIndex()].hasValue(); +} + F64 Recording::getMin( const TraceType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMin(); @@ -531,10 +536,12 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, s for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].getDuration() > 0.f) + Recording& recording = mRecordingPeriods[index]; + + if (recording.hasValue(stat)) { - S32 period_sample_count = mRecordingPeriods[index].getSampleCount(stat); - mean += mRecordingPeriods[index].getMean(stat) * period_sample_count; + S32 period_sample_count = recording.getSampleCount(stat); + mean += recording.getMean(stat) * period_sample_count; total_sample_count += period_sample_count; } } @@ -555,7 +562,11 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, si for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) + { + min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + } } return min_val; } @@ -569,7 +580,11 @@ F64 PeriodicRecording::getPeriodMax( const TraceType& stat, si for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) + { + max_val = llmax(max_val, recording.getMax(stat)); + } } return max_val; } @@ -583,9 +598,10 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, s for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].hasValue(stat)) + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) { - min_val = llmin(min_val, mRecordingPeriods[index].getMin(stat)); + min_val = llmin(min_val, recording.getMin(stat)); } } return min_val; @@ -600,9 +616,10 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, si for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].hasValue(stat)) + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) { - max_val = llmax(max_val, mRecordingPeriods[index].getMax(stat)); + max_val = llmax(max_val, recording.getMax(stat)); } } return max_val; @@ -622,10 +639,11 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, for (S32 i = 1; i <= num_periods; i++) { S32 index = (mCurPeriod + total_periods - i) % total_periods; - if (mRecordingPeriods[index].getDuration() > 0.f && mRecordingPeriods[index].hasValue(stat)) + Recording& recording = mRecordingPeriods[index]; + if (recording.hasValue(stat)) { - LLUnit recording_duration = mRecordingPeriods[index].getDuration(); - mean += mRecordingPeriods[index].getMean(stat) * recording_duration.value(); + LLUnit recording_duration = recording.getDuration(); + mean += recording.getMean(stat) * recording_duration.value(); total_duration += recording_duration; } } diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 51b411b7bd..7ee8aba874 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -248,6 +248,8 @@ namespace LLTrace U32 getSampleCount(const TraceType& stat); // EventStatHandle accessors + bool hasValue(const TraceType& stat); + F64 getSum(const TraceType& stat); template typename RelatedTypes::sum_t getSum(const EventStatHandle& stat) diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index eeb5cd3ee6..2f83836501 100755 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -83,6 +83,10 @@ const F32 OO_LN2 = 1.4426950408889634073599246810019f; const F32 F_ALMOST_ZERO = 0.0001f; const F32 F_ALMOST_ONE = 1.0f - F_ALMOST_ZERO; +const F64 NaN = std::numeric_limits::quiet_NaN(); +const F64 INFINITY = std::numeric_limits::infinity(); +const F64 MINUS_INFINITY = std::numeric_limits::infinity() * -1.0; + // BUG: Eliminate in favor of F_APPROXIMATELY_ZERO above? const F32 FP_MAG_THRESHOLD = 0.0000001f; diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 5930741d5c..dbc4999678 100755 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -62,7 +62,7 @@ public: /*virtual*/ void draw(); /*virtual*/ void removeChild(LLView*); /*virtual*/ BOOL postBuild(); - /*virtual*/ bool addChild(LLView* child, S32 tab_groupdatefractuiona = 0); + /*virtual*/ bool addChild(LLView* child, S32 tab_group = 0); /*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index e50e666421..d61b6ba18a 100755 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -94,7 +94,6 @@ extern LLPipeline gPipeline; U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check. std::map LLViewerObjectList::sIPAndPortToIndex; std::map LLViewerObjectList::sIndexAndLocalIDToUUID; -LLTrace::SampleStatHandle > LLViewerObjectList::sCacheHitRate("object_cache_hits"); LLViewerObjectList::LLViewerObjectList() { @@ -308,6 +307,8 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry* LLViewerStatsRecorder& recorder = LLViewerStatsRecorder::instance(); // Cache Hit. + record(LLStatViewer::OBJECT_CACHE_HIT_RATE, LLUnits::Ratio::fromValue(1)); + cached_dpp->reset(); cached_dpp->unpackUUID(fullid, "ID"); cached_dpp->unpackU32(local_id, "LocalID"); @@ -355,7 +356,6 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry* } justCreated = true; mNumNewObjects++; - sample(sCacheHitRate, LLUnits::Ratio::fromValue(1)); } if (objectp->isDead()) @@ -697,7 +697,6 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys, continue; // no data packer, skip this object } - //sample(sCacheHitRate, LLUnits::Ratio::fromValue(0)); } return; diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index 741c7c7db9..2fabd50e97 100755 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -196,8 +196,6 @@ protected: std::vector mOrphanChildren; // UUID's of orphaned objects S32 mNumOrphans; - static LLTrace::SampleStatHandle > sCacheHitRate; - typedef std::vector > vobj_list_t; vobj_list_t mObjects; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index e28ea6f988..34a9767fdf 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1985,6 +1985,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB // Create new entry and add to map result = CACHE_UPDATE_ADDED; entry = new LLVOCacheEntry(local_id, crc, dp); + record(LLStatViewer::OBJECT_CACHE_HIT_RATE, LLUnits::Ratio::fromValue(0)); mImpl->mCacheMap[local_id] = entry; diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 69198ed53d..bb023ce422 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -200,6 +200,9 @@ LLTrace::EventStatHandle > AVATAR_EDIT_TIME("avata FPS_10_TIME("fps10time", "Seconds below 10 FPS"), FPS_8_TIME("fps8time", "Seconds below 8 FPS"), FPS_2_TIME("fps2time", "Seconds below 2 FPS"); + +LLTrace::EventStatHandle > OBJECT_CACHE_HIT_RATE("object_cache_hits"); + } LLViewerStats::LLViewerStats() diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 9fed558e03..b580606326 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -240,6 +240,8 @@ extern LLTrace::EventStatHandle > AVATAR_EDIT_TIME FPS_8_TIME, FPS_2_TIME; +extern LLTrace::EventStatHandle > OBJECT_CACHE_HIT_RATE; + } class LLViewerStats : public LLSingleton -- cgit v1.3 From 612892b45a3413b16e40c49d3bfde77a4ca927fd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 18 Aug 2013 22:30:27 -0700 Subject: SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms continued conversion to units system made units perform type promotion correctly and preserve type in arithmetic e.g. can now do LLVector3 in units added typedefs for remaining common unit types, including implicits --- indra/llcommon/llcriticaldamp.cpp | 2 +- indra/llcommon/llcriticaldamp.h | 4 +- indra/llcommon/lldate.cpp | 2 +- indra/llcommon/lldate.h | 2 +- indra/llcommon/llframetimer.h | 4 +- indra/llcommon/llmemory.cpp | 46 +- indra/llcommon/llmemory.h | 18 +- indra/llcommon/llprocessor.cpp | 2 +- indra/llcommon/llprocessor.h | 2 +- indra/llcommon/llsys.cpp | 18 +- indra/llcommon/llsys.h | 4 +- indra/llcommon/lltimer.cpp | 18 +- indra/llcommon/lltimer.h | 20 +- indra/llcommon/lltraceaccumulators.cpp | 2 +- indra/llcommon/lltraceaccumulators.h | 20 +- indra/llcommon/lltracerecording.h | 4 +- indra/llcommon/llunit.h | 727 +++++++++----- indra/llcommon/tests/llunits_test.cpp | 126 ++- indra/llmessage/llassetstorage.cpp | 8 +- indra/llmessage/llassetstorage.h | 12 +- indra/llmessage/llcircuit.cpp | 32 +- indra/llmessage/llcircuit.h | 4 +- indra/llmessage/llhttpassetstorage.cpp | 4 +- indra/llmessage/llhttpassetstorage.h | 4 +- indra/llmessage/llpacketack.h | 2 +- indra/llmessage/llthrottle.cpp | 8 +- indra/llmessage/message.cpp | 18 +- indra/llmessage/message.h | 2 +- indra/llrender/llgltexture.cpp | 2 +- indra/llrender/llgltexture.h | 2 +- indra/llrender/llimagegl.cpp | 12 +- indra/llrender/llimagegl.h | 6 +- indra/llui/llstatbar.cpp | 10 +- indra/newview/llappviewer.cpp | 20 +- indra/newview/llappviewer.h | 8 +- indra/newview/llconversationlog.cpp | 8 +- indra/newview/llconversationlog.h | 2 +- indra/newview/llfasttimerview.cpp | 8 +- indra/newview/llfeaturemanager.cpp | 2 +- indra/newview/llfloaterabout.cpp | 2 +- indra/newview/llfloaterhardwaresettings.cpp | 4 +- indra/newview/llscenemonitor.cpp | 7 +- indra/newview/llscenemonitor.h | 2 +- indra/newview/llsurfacepatch.cpp | 2 +- indra/newview/lltexturefetch.cpp | 18 +- indra/newview/lltexturefetch.h | 10 +- indra/newview/lltextureinfo.cpp | 8 +- indra/newview/lltextureinfodetails.h | 8 +- indra/newview/lltextureview.cpp | 20 +- indra/newview/llviewerassetstorage.cpp | 6 +- indra/newview/llviewerassetstorage.h | 4 +- indra/newview/llviewercontrol.cpp | 2 +- indra/newview/llviewerdisplay.cpp | 4 +- indra/newview/llviewermessage.cpp | 4 +- indra/newview/llviewerobject.cpp | 24 +- indra/newview/llviewerobject.h | 8 +- indra/newview/llviewerregion.cpp | 6 +- indra/newview/llviewerstats.cpp | 30 +- indra/newview/llviewerstats.h | 4 +- indra/newview/llviewertexture.cpp | 1398 +++++++++++++-------------- indra/newview/llviewertexture.h | 24 +- indra/newview/llviewertexturelist.cpp | 88 +- indra/newview/llviewertexturelist.h | 15 +- indra/newview/llviewerwindow.cpp | 4 +- indra/newview/llvlmanager.cpp | 18 +- indra/newview/llvlmanager.h | 16 +- indra/newview/llvoavatar.cpp | 10 +- indra/newview/llvoavatar.h | 40 +- indra/newview/llvoavatarself.cpp | 8 +- indra/newview/llvoavatarself.h | 2 +- indra/newview/llvopartgroup.cpp | 2 +- indra/newview/llworld.cpp | 6 +- indra/newview/llworld.h | 6 +- indra/newview/pipeline.cpp | 2 +- 74 files changed, 1642 insertions(+), 1365 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/llcriticaldamp.cpp b/indra/llcommon/llcriticaldamp.cpp index 5ffad88973..9f4cb09000 100755 --- a/indra/llcommon/llcriticaldamp.cpp +++ b/indra/llcommon/llcriticaldamp.cpp @@ -81,7 +81,7 @@ void LLSmoothInterpolation::updateInterpolants() //----------------------------------------------------------------------------- // getInterpolant() //----------------------------------------------------------------------------- -F32 LLSmoothInterpolation::getInterpolant(LLUnitImplicit time_constant, bool use_cache) +F32 LLSmoothInterpolation::getInterpolant(F32SecondsImplicit time_constant, bool use_cache) { if (time_constant == 0.f) { diff --git a/indra/llcommon/llcriticaldamp.h b/indra/llcommon/llcriticaldamp.h index 7b2a414459..a02a2a0dcf 100755 --- a/indra/llcommon/llcriticaldamp.h +++ b/indra/llcommon/llcriticaldamp.h @@ -42,10 +42,10 @@ public: static void updateInterpolants(); // ACCESSORS - static F32 getInterpolant(LLUnitImplicit time_constant, bool use_cache = true); + static F32 getInterpolant(F32SecondsImplicit time_constant, bool use_cache = true); template - static T lerp(T a, T b, LLUnitImplicit time_constant, bool use_cache = true) + static T lerp(T a, T b, F32SecondsImplicit time_constant, bool use_cache = true) { F32 interpolant = getInterpolant(time_constant, use_cache); return ((a * (1.f - interpolant)) diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index cb6f239396..4f2e1304b2 100755 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -55,7 +55,7 @@ LLDate::LLDate(const LLDate& date) : mSecondsSinceEpoch(date.mSecondsSinceEpoch) {} -LLDate::LLDate(LLUnitImplicit seconds_since_epoch) : +LLDate::LLDate(F64SecondsImplicit seconds_since_epoch) : mSecondsSinceEpoch(seconds_since_epoch.value()) {} diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 816bc62b14..aecf3b765e 100755 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -59,7 +59,7 @@ public: * * @param seconds_since_epoch The number of seconds since UTC epoch. */ - LLDate(LLUnitImplicit seconds_since_epoch); + LLDate(F64SecondsImplicit seconds_since_epoch); /** * @brief Construct a date from a string representation diff --git a/indra/llcommon/llframetimer.h b/indra/llcommon/llframetimer.h index d64009440c..81bd5da8a3 100755 --- a/indra/llcommon/llframetimer.h +++ b/indra/llcommon/llframetimer.h @@ -43,7 +43,7 @@ public: // Return the number of seconds since the start of this // application instance. - static F64 getElapsedSeconds() + static F64SecondsImplicit getElapsedSeconds() { // Loses msec precision after ~4.5 hours... return sFrameTime; @@ -52,7 +52,7 @@ public: // Return a low precision usec since epoch static U64 getTotalTime() { - return sTotalTime ? LLUnitImplicit(sTotalTime) : totalTime(); + return sTotalTime ? U64MicrosecondsImplicit(sTotalTime) : totalTime(); } // Return a low precision seconds since epoch diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index c59b61471a..d46e205500 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -47,11 +47,11 @@ //static char* LLMemory::reserveMem = 0; -U32Kibibytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); -U32Kibibytes LLMemory::sMaxPhysicalMemInKB(0); -U32Kibibytes LLMemory::sAllocatedMemInKB(0); -U32Kibibytes LLMemory::sAllocatedPageSizeInKB(0); -U32Kibibytes LLMemory::sMaxHeapSizeInKB(U32_MAX); +U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); +U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0); +U32Kilobytes LLMemory::sAllocatedMemInKB(0); +U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0); +U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX); BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE; #if __DEBUG_PRIVATE_MEM__ @@ -94,9 +94,9 @@ void LLMemory::freeReserve() } //static -void LLMemory::initMaxHeapSizeGB(F32 max_heap_size_gb, BOOL prevent_heap_failure) +void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure) { - sMaxHeapSizeInKB = (U32)(max_heap_size_gb * 1024 * 1024) ; + sMaxHeapSizeInKB = max_heap_size; sEnableMemoryFailurePrevention = prevent_heap_failure ; } @@ -113,10 +113,10 @@ void LLMemory::updateMemoryInfo() return ; } - sAllocatedMemInKB = (U32)(counters.WorkingSetSize / 1024) ; - sAllocatedPageSizeInKB = (U32)(counters.PagefileUsage / 1024) ; + sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ; + sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ; - U32Kibibytes avail_phys, avail_virtual; + U32Kilobytes avail_phys, avail_virtual; LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ; sMaxPhysicalMemInKB = llmin(avail_phys + sAllocatedMemInKB, sMaxHeapSizeInKB); @@ -126,7 +126,7 @@ void LLMemory::updateMemoryInfo() } else { - sAvailPhysicalMemInKB = 0 ; + sAvailPhysicalMemInKB = U32Kilobytes(0); } #else //not valid for other systems for now. @@ -187,8 +187,8 @@ void LLMemory::logMemoryInfo(BOOL update) //static bool LLMemory::isMemoryPoolLow() { - static const U32 LOW_MEMEOY_POOL_THRESHOLD_KB = 64 * 1024 ; //64 MB for emergency use - const static U32 MAX_SIZE_CHECKED_MEMORY_BLOCK = 64 * 1024 * 1024 ; //64 MB + static const U32Megabytes LOW_MEMORY_POOL_THRESHOLD(64); + const static U32Megabytes MAX_SIZE_CHECKED_MEMORY_BLOCK(64); static void* last_reserved_address = NULL ; if(!sEnableMemoryFailurePrevention) @@ -196,32 +196,32 @@ bool LLMemory::isMemoryPoolLow() return false ; //no memory failure prevention. } - if(sAvailPhysicalMemInKB < (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2)) //out of physical memory + if(sAvailPhysicalMemInKB < (LOW_MEMORY_POOL_THRESHOLD / 4)) //out of physical memory { return true ; } - if(sAllocatedPageSizeInKB + (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2) > sMaxHeapSizeInKB) //out of virtual address space. + if(sAllocatedPageSizeInKB + (LOW_MEMORY_POOL_THRESHOLD / 4) > sMaxHeapSizeInKB) //out of virtual address space. { return true ; } - bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMEOY_POOL_THRESHOLD_KB || - sAllocatedPageSizeInKB + LOW_MEMEOY_POOL_THRESHOLD_KB > sMaxHeapSizeInKB) ; + bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD || + sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ; //check the virtual address space fragmentation if(!is_low) { if(!last_reserved_address) { - last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ; + last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ; } else { - last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ; + last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ; if(!last_reserved_address) //failed, try once more { - last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK) ; + last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ; } } @@ -232,19 +232,19 @@ bool LLMemory::isMemoryPoolLow() } //static -U32Kibibytes LLMemory::getAvailableMemKB() +U32Kilobytes LLMemory::getAvailableMemKB() { return sAvailPhysicalMemInKB ; } //static -U32Kibibytes LLMemory::getMaxMemKB() +U32Kilobytes LLMemory::getMaxMemKB() { return sMaxPhysicalMemInKB ; } //static -U32Kibibytes LLMemory::getAllocatedMemKB() +U32Kilobytes LLMemory::getAllocatedMemKB() { return sAllocatedMemInKB ; } diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index c45c7ed213..23be1e5b2d 100755 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -166,22 +166,22 @@ public: static U64 getCurrentRSS(); static U32 getWorkingSetSize(); static void* tryToAlloc(void* address, U32 size); - static void initMaxHeapSizeGB(F32 max_heap_size_gb, BOOL prevent_heap_failure); + static void initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure); static void updateMemoryInfo() ; static void logMemoryInfo(BOOL update = FALSE); static bool isMemoryPoolLow(); - static U32Kibibytes getAvailableMemKB() ; - static U32Kibibytes getMaxMemKB() ; - static U32Kibibytes getAllocatedMemKB() ; + static U32Kilobytes getAvailableMemKB() ; + static U32Kilobytes getMaxMemKB() ; + static U32Kilobytes getAllocatedMemKB() ; private: static char* reserveMem; - static U32Kibibytes sAvailPhysicalMemInKB ; - static U32Kibibytes sMaxPhysicalMemInKB ; - static U32Kibibytes sAllocatedMemInKB; - static U32Kibibytes sAllocatedPageSizeInKB ; + static U32Kilobytes sAvailPhysicalMemInKB ; + static U32Kilobytes sMaxPhysicalMemInKB ; + static U32Kilobytes sAllocatedMemInKB; + static U32Kilobytes sAllocatedPageSizeInKB ; - static U32Kibibytes sMaxHeapSizeInKB; + static U32Kilobytes sMaxHeapSizeInKB; static BOOL sEnableMemoryFailurePrevention; }; diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 80b86153e4..69043dc173 100755 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -875,7 +875,7 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL) LLProcessorInfo::~LLProcessorInfo() {} -LLUnitImplicit LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); } +F64MegahertzImplicit LLProcessorInfo::getCPUFrequency() const { return mImpl->getCPUFrequency(); } bool LLProcessorInfo::hasSSE() const { return mImpl->hasSSE(); } bool LLProcessorInfo::hasSSE2() const { return mImpl->hasSSE2(); } bool LLProcessorInfo::hasAltivec() const { return mImpl->hasAltivec(); } diff --git a/indra/llcommon/llprocessor.h b/indra/llcommon/llprocessor.h index 7f220467b0..4956a39700 100755 --- a/indra/llcommon/llprocessor.h +++ b/indra/llcommon/llprocessor.h @@ -37,7 +37,7 @@ public: LLProcessorInfo(); ~LLProcessorInfo(); - LLUnitImplicit getCPUFrequency() const; + F64MegahertzImplicit getCPUFrequency() const; bool hasSSE() const; bool hasSSE2() const; bool hasAltivec() const; diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 8f7e60fb68..1ff45d3d90 100755 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -832,7 +832,7 @@ LLMemoryInfo::LLMemoryInfo() } #if LL_WINDOWS -static U32Kibibytes LLMemoryAdjustKBResult(U32Kibibytes inKB) +static U32Kilobytes LLMemoryAdjustKBResult(U32Kilobytes inKB) { // Moved this here from llfloaterabout.cpp @@ -843,16 +843,16 @@ static U32Kibibytes LLMemoryAdjustKBResult(U32Kibibytes inKB) // returned from the GetMemoryStatusEx function. Here we keep the // original adjustment from llfoaterabout.cpp until this can be // fixed somehow. - inKB += U32Mibibytes(1); + inKB += U32Megabytes(1); return inKB; } #endif -U32Kibibytes LLMemoryInfo::getPhysicalMemoryKB() const +U32Kilobytes LLMemoryInfo::getPhysicalMemoryKB() const { #if LL_WINDOWS - return LLMemoryAdjustKBResult(U32Kibibytes(mStatsMap["Total Physical KB"].asInteger())); + return LLMemoryAdjustKBResult(U32Kilobytes(mStatsMap["Total Physical KB"].asInteger())); #elif LL_DARWIN // This might work on Linux as well. Someone check... @@ -885,8 +885,8 @@ U32Bytes LLMemoryInfo::getPhysicalMemoryClamped() const // Return the total physical memory in bytes, but clamp it // to no more than U32_MAX - U32Bytes phys_kb = getPhysicalMemoryKB(); - if (phys_kb >= 4194304 /* 4GB in KB */) + U32Kilobytes phys_kb = getPhysicalMemoryKB(); + if (phys_kb >= U32Gigabytes(4)) { return U32Bytes(U32_MAX); } @@ -897,15 +897,15 @@ U32Bytes LLMemoryInfo::getPhysicalMemoryClamped() const } //static -void LLMemoryInfo::getAvailableMemoryKB(U32Kibibytes& avail_physical_mem_kb, U32Kibibytes& avail_virtual_mem_kb) +void LLMemoryInfo::getAvailableMemoryKB(U32Kilobytes& avail_physical_mem_kb, U32Kilobytes& avail_virtual_mem_kb) { #if LL_WINDOWS // Sigh, this shouldn't be a static method, then we wouldn't have to // reload this data separately from refresh() LLSD statsMap(loadStatsMap()); - avail_physical_mem_kb = statsMap["Avail Physical KB"].asInteger(); - avail_virtual_mem_kb = statsMap["Avail Virtual KB"].asInteger(); + avail_physical_mem_kb = (U32Kilobytes)statsMap["Avail Physical KB"].asInteger(); + avail_virtual_mem_kb = (U32Kilobytes)statsMap["Avail Virtual KB"].asInteger(); #elif LL_DARWIN // mStatsMap is derived from vm_stat, look for (e.g.) "kb free": diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index ad4f243d05..962367f69f 100755 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -112,7 +112,7 @@ public: LLMemoryInfo(); ///< Default constructor void stream(std::ostream& s) const; ///< output text info to s - U32Kibibytes getPhysicalMemoryKB() const; + U32Kilobytes getPhysicalMemoryKB() const; /*! Memory size in bytes, if total memory is >= 4GB then U32_MAX will ** be returned. @@ -120,7 +120,7 @@ public: U32Bytes getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes //get the available memory infomation in KiloBytes. - static void getAvailableMemoryKB(U32Kibibytes& avail_physical_mem_kb, U32Kibibytes& avail_virtual_mem_kb); + static void getAvailableMemoryKB(U32Kilobytes& avail_physical_mem_kb, U32Kilobytes& avail_virtual_mem_kb); // Retrieve a map of memory statistics. The keys of the map are platform- // dependent. The values are in kilobytes to try to avoid integer overflow. diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 74f3a7f587..da9d2b646c 100755 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -225,7 +225,7 @@ void update_clock_frequencies() // returns a U64 number that represents the number of // microseconds since the unix epoch - Jan 1, 1970 -LLUnitImplicit totalTime() +U64MicrosecondsImplicit totalTime() { U64 current_clock_count = get_clock_count(); if (!gTotalTimeClockCount) @@ -295,14 +295,14 @@ void LLTimer::cleanupClass() } // static -LLUnitImplicit LLTimer::getTotalTime() +U64MicrosecondsImplicit LLTimer::getTotalTime() { // simply call into the implementation function. return totalTime(); } // static -LLUnitImplicit LLTimer::getTotalSeconds() +F64SecondsImplicit LLTimer::getTotalSeconds() { return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; } @@ -351,36 +351,36 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) } -LLUnitImplicit LLTimer::getElapsedTimeF64() const +F64SecondsImplicit LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; } -LLUnitImplicit LLTimer::getElapsedTimeF32() const +F32SecondsImplicit LLTimer::getElapsedTimeF32() const { return (F32)getElapsedTimeF64(); } -LLUnitImplicit LLTimer::getElapsedTimeAndResetF64() +F64SecondsImplicit LLTimer::getElapsedTimeAndResetF64() { return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; } -LLUnitImplicit LLTimer::getElapsedTimeAndResetF32() +F32SecondsImplicit LLTimer::getElapsedTimeAndResetF32() { return (F32)getElapsedTimeAndResetF64(); } /////////////////////////////////////////////////////////////////////////////// -void LLTimer::setTimerExpirySec(LLUnitImplicit expiration) +void LLTimer::setTimerExpirySec(F32SecondsImplicit expiration) { mExpirationTicks = get_clock_count() + (U64)((F32)(expiration * gClockFrequency)); } -LLUnitImplicit LLTimer::getRemainingTimeF32() const +F32SecondsImplicit 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 1f2c56432b..12a453e897 100755 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -67,7 +67,7 @@ public: // Return a high precision number of seconds since the start of // this application instance. - static LLUnitImplicit getElapsedSeconds() + static F64SecondsImplicit getElapsedSeconds() { if (sTimer) { @@ -80,10 +80,10 @@ public: } // Return a high precision usec since epoch - static LLUnitImplicit getTotalTime(); + static U64MicrosecondsImplicit getTotalTime(); // Return a high precision seconds since epoch - static LLUnitImplicit getTotalSeconds(); + static F64SecondsImplicit getTotalSeconds(); // MANIPULATORS @@ -91,19 +91,19 @@ public: void stop() { mStarted = FALSE; } void reset(); // Resets the timer void setLastClockCount(U64 current_count); // Sets the timer so that the next elapsed call will be relative to this time - void setTimerExpirySec(LLUnitImplicit expiration); + void setTimerExpirySec(F32SecondsImplicit expiration); BOOL checkExpirationAndReset(F32 expiration); BOOL hasExpired() const; - LLUnitImplicit getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset - LLUnitImplicit getElapsedTimeAndResetF64(); + F32SecondsImplicit getElapsedTimeAndResetF32(); // Returns elapsed time in seconds with reset + F64SecondsImplicit getElapsedTimeAndResetF64(); - LLUnitImplicit getRemainingTimeF32() const; + F32SecondsImplicit getRemainingTimeF32() const; static BOOL knownBadTimer(); // ACCESSORS - LLUnitImplicit getElapsedTimeF32() const; // Returns elapsed time in seconds - LLUnitImplicit getElapsedTimeF64() const; // Returns elapsed time in seconds + F32SecondsImplicit getElapsedTimeF32() const; // Returns elapsed time in seconds + F64SecondsImplicit getElapsedTimeF64() const; // Returns elapsed time in seconds bool getStarted() const { return mStarted; } @@ -171,6 +171,6 @@ LL_COMMON_API struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_dayli LL_COMMON_API void microsecondsToTimecodeString(U64 current_time, std::string& tcstring); LL_COMMON_API void secondsToTimecodeString(F32 current_time, std::string& tcstring); -LLUnitImplicit LL_COMMON_API totalTime(); // Returns current system time in microseconds +U64MicrosecondsImplicit LL_COMMON_API totalTime(); // Returns current system time in microseconds #endif diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index a632f5634c..1fb68c8158 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -114,7 +114,7 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) void AccumulatorBufferGroup::sync() { - LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); + F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); mSamples.sync(time_stamp); mMemStats.sync(time_stamp); diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 73da6bd2d8..f9d223066d 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -118,7 +118,7 @@ namespace LLTrace } } - void sync(LLUnitImplicit time_stamp) + void sync(F64SecondsImplicit time_stamp) { llassert(mStorageSize >= sNextStorageSlot); for (size_t i = 0; i < sNextStorageSlot; i++) @@ -260,7 +260,7 @@ namespace LLTrace void addSamples(const EventAccumulator& other, EBufferAppendType append_type); void reset(const EventAccumulator* other); - void sync(LLUnitImplicit) {} + void sync(F64SecondsImplicit) {} F64 getSum() const { return mSum; } F64 getMin() const { return mMin; } @@ -305,7 +305,7 @@ namespace LLTrace void sample(F64 value) { - LLUnitImplicit time_stamp = LLTimer::getTotalSeconds(); + F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); // store effect of last value sync(time_stamp); @@ -332,11 +332,11 @@ namespace LLTrace void addSamples(const SampleAccumulator& other, EBufferAppendType append_type); void reset(const SampleAccumulator* other); - void sync(LLUnitImplicit time_stamp) + void sync(F64SecondsImplicit time_stamp) { if (mHasValue) { - LLUnitImplicit delta_time = time_stamp - mLastSampleTimeStamp; + F64SecondsImplicit delta_time = time_stamp - mLastSampleTimeStamp; mSum += mLastValue * delta_time; mTotalSamplingTime += delta_time; F64 old_mean = mMean; @@ -353,7 +353,7 @@ namespace LLTrace F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mTotalSamplingTime); } F64 getSumOfSquares() const { return mSumOfSquares; } - LLUnitImplicit getSamplingTime() { return mTotalSamplingTime; } + F64SecondsImplicit getSamplingTime() { return mTotalSamplingTime; } U32 getSampleCount() const { return mNumSamples; } bool hasValue() const { return mHasValue; } @@ -368,7 +368,7 @@ namespace LLTrace F64 mMean, mSumOfSquares; - LLUnitImplicit + F64SecondsImplicit mLastSampleTimeStamp, mTotalSamplingTime; @@ -403,7 +403,7 @@ namespace LLTrace mSum = 0; } - void sync(LLUnitImplicit) {} + void sync(F64SecondsImplicit) {} F64 getSum() const { return mSum; } @@ -435,7 +435,7 @@ namespace LLTrace TimeBlockAccumulator(); void addSamples(const self_t& other, EBufferAppendType append_type); void reset(const self_t* other); - void sync(LLUnitImplicit) {} + void sync(F64SecondsImplicit) {} // // members @@ -516,7 +516,7 @@ namespace LLTrace mDeallocatedCount = 0; } - void sync(LLUnitImplicit time_stamp) + void sync(F64SecondsImplicit time_stamp) { mSize.sync(time_stamp); mChildSize.sync(time_stamp); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index f5fb2bf561..ea090e6ee1 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -490,7 +490,7 @@ namespace LLTrace for (S32 i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); - if (recording.getDuration() > 0.f) + if (recording.getDuration() > (F32Seconds)0.f) { mean += recording.getSum(stat); } @@ -530,7 +530,7 @@ namespace LLTrace for (S32 i = 1; i <= num_periods; i++) { Recording& recording = getPrevRecording(i); - if (recording.getDuration() > 0.f) + if (recording.getDuration() > (F32Seconds)0.f) { mean += recording.getPerSec(stat); } diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index b62bebc440..c49c882f23 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -31,11 +31,29 @@ #include "llpreprocessor.h" #include "llerror.h" +//lightweight replacement of type traits for simple type equality check +template +struct LLIsSameType +{ + static const bool value = false; +}; + +template +struct LLIsSameType +{ + static const bool value = true; +}; + +template +struct LLPromotedType +{ + typedef decltype(S() + T()) type_t; +}; + template struct LLUnit { typedef LLUnit self_t; - typedef STORAGE_TYPE storage_t; // value initialization @@ -49,18 +67,6 @@ struct LLUnit : mValue(convert(other).mValue) {} - bool operator == (const self_t& other) - { - return mValue = other.mValue; - } - - // value assignment - self_t& operator = (storage_t value) - { - mValue = value; - return *this; - } - // unit assignment template self_t& operator = (LLUnit other) @@ -91,22 +97,12 @@ struct LLUnit *this = LLUnit(value); } - void operator += (storage_t value) - { - mValue += value; - } - template void operator += (LLUnit other) { mValue += convert(other).mValue; } - void operator -= (storage_t value) - { - mValue -= value; - } - template void operator -= (LLUnit other) { @@ -161,7 +157,7 @@ std::istream& operator >>(std::istream& s, LLUnit& unit { STORAGE_TYPE val; s >> val; - unit = val; + unit.value(val); return s; } @@ -181,12 +177,37 @@ struct LLUnitImplicit : public LLUnit : base_t(convert(other)) {} - // unlike LLUnit, LLUnitImplicit is *implicitly* convertable to a POD scalar (F32, S32, etc) + // unlike LLUnit, LLUnitImplicit is *implicitly* convertable to a POD value (F32, S32, etc) // this allows for interoperability with legacy code operator storage_t() const { return base_t::value(); } + + using base_t::operator +=; + void operator += (storage_t value) + { + mValue += value; + } + + template + void operator += (LLUnitImplicit other) + { + mValue += convert(other).value(); + } + + using base_t::operator -=; + void operator -= (storage_t value) + { + mValue -= value; + } + + template + void operator -= (LLUnitImplicit other) + { + mValue -= convert(other).value(); + } + }; template @@ -205,24 +226,12 @@ std::istream& operator >>(std::istream& s, LLUnitImplicit -struct LLIsSameType -{ - static const bool value = false; -}; - -template -struct LLIsSameType -{ - static const bool value = true; -}; - template LL_FORCE_INLINE void ll_convert_units(LLUnit in, LLUnit& out, ...) { LL_STATIC_ASSERT((LLIsSameType::value || !LLIsSameType::value - || !LLIsSameType::value), "invalid conversion"); + || !LLIsSameType::value), "invalid conversion: incompatible units"); if (LLIsSameType::value) { @@ -253,65 +262,63 @@ LL_FORCE_INLINE void ll_convert_units(LLUnit in, LLUnit& out, .. // operator + // template -LLUnit operator + (LLUnit first, LLUnit second) +LLUnit operator + (LLUnit first, LLUnit second) { - LLUnit result(first); + LLUnit result(first); result += second; return result; } -template -LLUnit operator + (LLUnit first, SCALAR_TYPE second) +template +LLUnit operator + (LLUnit first, UNITLESS second) { - LLUnit result(first); - result += second; - return result; + LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "operator + requires compatible unit types"); + return LLUnit(0); } -template -LLUnit operator + (SCALAR_TYPE first, LLUnit second) +template +LLUnit operator + (UNITLESS first, LLUnit second) { - LLUnit result(first); - result += second; - return result; + LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "operator + requires compatible unit types"); + return LLUnit(0); } template -LLUnitImplicit operator + (LLUnitImplicit first, LLUnitImplicit second) +LLUnitImplicit operator + (LLUnitImplicit first, LLUnitImplicit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result += second; return result; } template -LLUnitImplicit operator + (LLUnit first, LLUnitImplicit second) +LLUnitImplicit operator + (LLUnit first, LLUnitImplicit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result += second; return result; } template -LLUnitImplicit operator + (LLUnitImplicit first, LLUnit second) +LLUnitImplicit operator + (LLUnitImplicit first, LLUnit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result += LLUnitImplicit(second); return result; } -template -LLUnitImplicit operator + (LLUnitImplicit first, SCALAR_TYPE second) +template +LLUnitImplicit operator + (LLUnitImplicit first, UNITLESS_TYPE second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result += second; return result; } -template -LLUnitImplicit operator + (SCALAR_TYPE first, LLUnitImplicit second) +template +LLUnitImplicit operator + (UNITLESS_TYPE first, LLUnitImplicit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result += second; return result; } @@ -320,65 +327,63 @@ LLUnitImplicit operator + (SCALAR_TYPE first, LLUnitImp // operator - // template -LLUnit operator - (LLUnit first, LLUnit second) +LLUnit operator - (LLUnit first, LLUnit second) { - LLUnit result(first); + LLUnit result(first); result -= second; return result; } -template -LLUnit operator - (LLUnit first, SCALAR_TYPE second) +template +LLUnit operator - (LLUnit first, UNITLESS second) { - LLUnit result(first); - result -= second; - return result; + LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "operator - requires compatible unit types"); + return LLUnit(0); } -template -LLUnit operator - (SCALAR_TYPE first, LLUnit second) +template +LLUnit operator - (UNITLESS first, LLUnit second) { - LLUnit result(first); - result -= second; - return result; + LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "operator - requires compatible unit types"); + return LLUnit(0); } template -LLUnitImplicit operator - (LLUnitImplicit first, LLUnitImplicit second) +LLUnitImplicit operator - (LLUnitImplicit first, LLUnitImplicit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result -= second; return result; } template -LLUnitImplicit operator - (LLUnit first, LLUnitImplicit second) +LLUnitImplicit operator - (LLUnit first, LLUnitImplicit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result -= second; return result; } template -LLUnitImplicit operator - (LLUnitImplicit first, LLUnit second) +LLUnitImplicit operator - (LLUnitImplicit first, LLUnit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result -= LLUnitImplicit(second); return result; } -template -LLUnitImplicit operator - (LLUnitImplicit first, SCALAR_TYPE second) +template +LLUnitImplicit operator - (LLUnitImplicit first, UNITLESS_TYPE second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result -= second; return result; } -template -LLUnitImplicit operator - (SCALAR_TYPE first, LLUnitImplicit second) +template +LLUnitImplicit operator - (UNITLESS_TYPE first, LLUnitImplicit second) { - LLUnitImplicit result(first); + LLUnitImplicit result(first); result -= second; return result; } @@ -390,119 +395,144 @@ template operator * (LLUnit, LLUnit) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "Multiplication of unit types results in new unit type - not supported."); + LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "multiplication of unit types results in new unit type - not supported."); return LLUnit(); } -template -LLUnit operator * (LLUnit first, SCALAR_TYPE second) +template +LLUnit operator * (LLUnit first, UNITLESS_TYPE second) { - return LLUnit((STORAGE_TYPE)(first.value() * second)); + return LLUnit(first.value() * second); } -template -LLUnit operator * (SCALAR_TYPE first, LLUnit second) +template +LLUnit operator * (UNITLESS_TYPE first, LLUnit second) { - return LLUnit((STORAGE_TYPE)(first * second.value())); + return LLUnit(first * second.value()); } template LLUnitImplicit operator * (LLUnitImplicit, LLUnitImplicit) { // spurious use of dependent type to stop gcc from triggering the static assertion before instantiating the template - LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "Multiplication of unit types results in new unit type - not supported."); + LL_BAD_TEMPLATE_INSTANTIATION(STORAGE_TYPE1, "multiplication of unit types results in new unit type - not supported."); return LLUnitImplicit(); } -template -LLUnitImplicit operator * (LLUnitImplicit first, SCALAR_TYPE second) +template +LLUnitImplicit operator * (LLUnitImplicit first, UNITLESS_TYPE second) { - return LLUnitImplicit(first.value() * second); + return LLUnitImplicit(first.value() * second); } -template -LLUnitImplicit operator * (SCALAR_TYPE first, LLUnitImplicit second) +template +LLUnitImplicit operator * (UNITLESS_TYPE first, LLUnitImplicit second) { - return LLUnitImplicit(first * second.value()); + return LLUnitImplicit(first * second.value()); } // // operator / // -template -SCALAR_TYPE operator / (SCALAR_TYPE first, LLUnit second) -{ - return SCALAR_TYPE(first / second.value()); -} -template -LLUnit operator / (LLUnit first, SCALAR_TYPE second) +template +LLUnit operator / (LLUnit first, UNITLESS_TYPE second) { - return LLUnit((STORAGE_TYPE)(first.value() / second)); + return LLUnit(first.value() / second); } template -STORAGE_TYPE1 operator / (LLUnit first, LLUnit second) +decltype(STORAGE_TYPE1() / STORAGE_TYPE2()) operator / (LLUnit first, LLUnit second) { - return STORAGE_TYPE1(first.value() / first.convert(second)); + return first.value() / first.convert(second).value(); } -template -LLUnitImplicit operator / (LLUnitImplicit first, SCALAR_TYPE second) +template +LLUnitImplicit operator / (LLUnitImplicit first, UNITLESS_TYPE second) { - return LLUnitImplicit((STORAGE_TYPE)(first.value() / second)); + return LLUnitImplicit(first.value() / second); } template -STORAGE_TYPE1 operator / (LLUnitImplicit first, LLUnitImplicit second) +decltype(STORAGE_TYPE1() / STORAGE_TYPE2()) operator / (LLUnitImplicit first, LLUnitImplicit second) { - return STORAGE_TYPE1(first.value() / first.convert(second)); + return (decltype(STORAGE_TYPE1() / STORAGE_TYPE2()))(first.value() / first.convert(second).value()); } template -STORAGE_TYPE1 operator / (LLUnit first, LLUnitImplicit second) +decltype(STORAGE_TYPE1() / STORAGE_TYPE2()) operator / (LLUnit first, LLUnitImplicit second) { - return STORAGE_TYPE1(first.value() / first.convert(second)); + return (decltype(STORAGE_TYPE1() / STORAGE_TYPE2()))(first.value() / first.convert(second).value()); } template -STORAGE_TYPE1 operator / (LLUnitImplicit first, LLUnit second) -{ - return STORAGE_TYPE1(first.value() / first.convert(second)); -} - -#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 (LLUnitImplicit first, LLUnitImplicit second) \ -{ \ - return first.value() op first.convert(second); \ -} \ - \ -template \ - bool operator op (LLUnit first, LLUnit second) \ -{ \ - return first.value() op first.convert(second); \ -} - -COMPARISON_OPERATORS(<) -COMPARISON_OPERATORS(<=) -COMPARISON_OPERATORS(>) -COMPARISON_OPERATORS(>=) -COMPARISON_OPERATORS(==) -COMPARISON_OPERATORS(!=) +decltype(STORAGE_TYPE1() / STORAGE_TYPE2()) operator / (LLUnitImplicit first, LLUnit second) +{ + return (decltype(STORAGE_TYPE1() / STORAGE_TYPE2()))(first.value() / first.convert(second).value()); +} + +// +// comparison operators +// + +#define LL_UNIT_DECLARE_COMPARISON_OPERATOR(op) \ +template \ +bool operator op (LLUnitImplicit first, LLUnitImplicit second) \ +{ \ + return first.value() op first.convert(second).value(); \ +} \ + \ +template \ +bool operator op (LLUnitImplicit first, UNITLESS_TYPE second) \ +{ \ + return first.value() op second; \ +} \ + \ +template \ +bool operator op (UNITLESS_TYPE first, LLUnitImplicit second) \ +{ \ + return first op second.value(); \ +} \ + \ +template \ +bool operator op (LLUnit first, LLUnit second) \ +{ \ + return first.value() op first.convert(second).value(); \ +} \ + \ +template \ +bool operator op (LLUnit first, UNITLESS_TYPE second) \ +{ \ + LL_BAD_TEMPLATE_INSTANTIATION(UNITLESS_TYPE, "operator " #op " requires compatible unit types"); \ + return false; \ +} \ + \ +template \ +bool operator op (UNITLESS_TYPE first, LLUnit second) \ +{ \ + LL_BAD_TEMPLATE_INSTANTIATION(UNITLESS_TYPE, "operator " #op " requires compatible unit types"); \ + return false; \ +} \ + \ +template \ +bool operator op (LLUnit first, LLUnitImplicit second) \ +{ \ + return first.value() op first.convert(second).value(); \ +} \ + \ +template \ +bool operator op (LLUnitImplicit first, LLUnit second) \ +{ \ + return first.value() op first.convert(second).value(); \ +} + +LL_UNIT_DECLARE_COMPARISON_OPERATOR(<); +LL_UNIT_DECLARE_COMPARISON_OPERATOR(<=); +LL_UNIT_DECLARE_COMPARISON_OPERATOR(>); +LL_UNIT_DECLARE_COMPARISON_OPERATOR(>=); +LL_UNIT_DECLARE_COMPARISON_OPERATOR(==); +LL_UNIT_DECLARE_COMPARISON_OPERATOR(!=); template @@ -517,8 +547,6 @@ struct LLGetUnitLabel > static const char* getUnitLabel() { return T::getUnitLabel(); } }; -#define LL_UNIT_PROMOTE_VALUE(output_type, value) ((true ? (output_type)(1) : (value/value)) * value) - template struct LLUnitLinearOps { @@ -534,25 +562,25 @@ struct LLUnitLinearOps template output_t operator * (T other) { - return mInput * other; + return typename LLPromotedType::type_t(mInput) * other; } template output_t operator / (T other) { - return LL_UNIT_PROMOTE_VALUE(OUTPUT_TYPE, mInput) / other; + return typename LLPromotedType::type_t(mInput) / other; } template output_t operator + (T other) { - return mInput + other; + return typename LLPromotedType::type_t(mInput) + other; } template output_t operator - (T other) { - return mInput - other; + return typename LLPromotedType::type_t(mInput) - other; } }; @@ -571,25 +599,25 @@ struct LLUnitInverseLinearOps template output_t operator * (T other) { - return LL_UNIT_PROMOTE_VALUE(OUTPUT_TYPE, mInput) / other; + return typename LLPromotedType::type_t(mInput) / other; } template output_t operator / (T other) { - return mInput * other; + return typename LLPromotedType::type_t(mInput) * other; } template output_t operator + (T other) { - return mInput - other; + return typename LLPromotedType::type_t(mInput) - other; } template output_t operator - (T other) { - return mInput + other; + return typename LLPromotedType::type_t(mInput) + other; } }; @@ -621,13 +649,13 @@ struct unit_name template \ void ll_convert_units(LLUnit in, LLUnit& out) \ { \ - out = LLUnit((S2)(LLUnitLinearOps(in.value()) conversion_operation)); \ + out = LLUnit((S2)(LLUnitLinearOps(in.value()) conversion_operation)); \ } \ \ template \ void ll_convert_units(LLUnit in, LLUnit& out) \ { \ - out = LLUnit((S2)(LLUnitInverseLinearOps(in.value()) conversion_operation)); \ + out = LLUnit((S2)(LLUnitInverseLinearOps(in.value()) conversion_operation)); \ } // @@ -637,120 +665,140 @@ void ll_convert_units(LLUnit in, LLUnit& out) namespace LLUnits { LL_DECLARE_BASE_UNIT(Bytes, "B"); -LL_DECLARE_DERIVED_UNIT(Bytes, * 1000, Kilobytes, "KB"); -LL_DECLARE_DERIVED_UNIT(Kilobytes, * 1000, Megabytes, "MB"); -LL_DECLARE_DERIVED_UNIT(Megabytes, * 1000, Gigabytes, "GB"); -LL_DECLARE_DERIVED_UNIT(Bytes, * 1024, Kibibytes, "KiB"); -LL_DECLARE_DERIVED_UNIT(Kibibytes, * 1024, Mibibytes, "MiB"); -LL_DECLARE_DERIVED_UNIT(Mibibytes, * 1024, Gibibytes, "GiB"); +// technically, these are kibibytes, mibibytes, etc. but we should stick with commonly accepted terminology +LL_DECLARE_DERIVED_UNIT(Bytes, * 1024, Kilobytes, "KB"); +LL_DECLARE_DERIVED_UNIT(Kilobytes, * 1024, Megabytes, "MB"); +LL_DECLARE_DERIVED_UNIT(Megabytes, * 1024, Gigabytes, "GB"); } typedef LLUnit F32Bytes; typedef LLUnit F32Kilobytes; typedef LLUnit F32Megabytes; typedef LLUnit F32Gigabytes; -typedef LLUnit F32Kibibytes; -typedef LLUnit F32Mibibytes; -typedef LLUnit F32Gibibytes; + +typedef LLUnitImplicit F32BytesImplicit; +typedef LLUnitImplicit F32KilobytesImplicit; +typedef LLUnitImplicit F32MegabytesImplicit; +typedef LLUnitImplicit F32GigabytesImplicit; typedef LLUnit F64Bytes; typedef LLUnit F64Kilobytes; typedef LLUnit F64Megabytes; typedef LLUnit F64Gigabytes; -typedef LLUnit F64Kibibytes; -typedef LLUnit F64Mibibytes; -typedef LLUnit F64Gibibytes; + +typedef LLUnitImplicit F64BytesImplicit; +typedef LLUnitImplicit F64KilobytesImplicit; +typedef LLUnitImplicit F64MegabytesImplicit; +typedef LLUnitImplicit F64GigabytesImplicit; typedef LLUnit S32Bytes; typedef LLUnit S32Kilobytes; typedef LLUnit S32Megabytes; typedef LLUnit S32Gigabytes; -typedef LLUnit S32Kibibytes; -typedef LLUnit S32Mibibytes; -typedef LLUnit S32Gibibytes; -typedef LLUnit U32Bytes; -typedef LLUnit U32Kilobytes; -typedef LLUnit U32Megabytes; -typedef LLUnit U32Gigabytes; -typedef LLUnit U32Kibibytes; -typedef LLUnit U32Mibibytes; -typedef LLUnit U32Gibibytes; +typedef LLUnitImplicit S32BytesImplicit; +typedef LLUnitImplicit S32KilobytesImplicit; +typedef LLUnitImplicit S32MegabytesImplicit; +typedef LLUnitImplicit S32GigabytesImplicit; typedef LLUnit S64Bytes; typedef LLUnit S64Kilobytes; typedef LLUnit S64Megabytes; typedef LLUnit S64Gigabytes; -typedef LLUnit S64Kibibytes; -typedef LLUnit S64Mibibytes; -typedef LLUnit S64Gibibytes; + +typedef LLUnitImplicit S64BytesImplicit; +typedef LLUnitImplicit S64KilobytesImplicit; +typedef LLUnitImplicit S64MegabytesImplicit; +typedef LLUnitImplicit S64GigabytesImplicit; + +typedef LLUnit U32Bytes; +typedef LLUnit U32Kilobytes; +typedef LLUnit U32Megabytes; +typedef LLUnit U32Gigabytes; + +typedef LLUnitImplicit U32BytesImplicit; +typedef LLUnitImplicit U32KilobytesImplicit; +typedef LLUnitImplicit U32MegabytesImplicit; +typedef LLUnitImplicit U32GigabytesImplicit; typedef LLUnit U64Bytes; typedef LLUnit U64Kilobytes; typedef LLUnit U64Megabytes; typedef LLUnit U64Gigabytes; -typedef LLUnit U64Kibibytes; -typedef LLUnit U64Mibibytes; -typedef LLUnit U64Gibibytes; + +typedef LLUnitImplicit U64BytesImplicit; +typedef LLUnitImplicit U64KilobytesImplicit; +typedef LLUnitImplicit U64MegabytesImplicit; +typedef LLUnitImplicit U64GigabytesImplicit; namespace LLUnits { +// technically, these are kibibits, mibibits, etc. but we should stick with commonly accepted terminology LL_DECLARE_DERIVED_UNIT(Bytes, / 8, Bits, "b"); -LL_DECLARE_DERIVED_UNIT(Bits, * 1000, Kilobits, "Kb"); -LL_DECLARE_DERIVED_UNIT(Kilobits, * 1000, Megabits, "Mb"); -LL_DECLARE_DERIVED_UNIT(Megabits, * 1000, Gigabits, "Gb"); -LL_DECLARE_DERIVED_UNIT(Bits, * 1024, Kibibits, "Kib"); -LL_DECLARE_DERIVED_UNIT(Kibibits, * 1024, Mibibits, "Mib"); -LL_DECLARE_DERIVED_UNIT(Mibibits, * 1024, Gibibits, "Gib"); +LL_DECLARE_DERIVED_UNIT(Bits, * 1024, Kilobits, "Kb"); +LL_DECLARE_DERIVED_UNIT(Kilobits, * 1024, Megabits, "Mb"); +LL_DECLARE_DERIVED_UNIT(Megabits, * 1024, Gigabits, "Gb"); } typedef LLUnit F32Bits; typedef LLUnit F32Kilobits; typedef LLUnit F32Megabits; typedef LLUnit F32Gigabits; -typedef LLUnit F32Kibibits; -typedef LLUnit F32Mibibits; -typedef LLUnit F32Gibibits; - + +typedef LLUnitImplicit F32BitsImplicit; +typedef LLUnitImplicit F32KilobitsImplicit; +typedef LLUnitImplicit F32MegabitsImplicit; +typedef LLUnitImplicit F32GigabitsImplicit; + typedef LLUnit F64Bits; typedef LLUnit F64Kilobits; typedef LLUnit F64Megabits; typedef LLUnit F64Gigabits; -typedef LLUnit F64Kibibits; -typedef LLUnit F64Mibibits; -typedef LLUnit F64Gibibits; + +typedef LLUnitImplicit F64BitsImplicit; +typedef LLUnitImplicit F64KilobitsImplicit; +typedef LLUnitImplicit F64MegabitsImplicit; +typedef LLUnitImplicit F64GigabitsImplicit; typedef LLUnit S32Bits; typedef LLUnit S32Kilobits; typedef LLUnit S32Megabits; typedef LLUnit S32Gigabits; -typedef LLUnit S32Kibibits; -typedef LLUnit S32Mibibits; -typedef LLUnit S32Gibibits; -typedef LLUnit U32Bits; -typedef LLUnit U32Kilobits; -typedef LLUnit U32Megabits; -typedef LLUnit U32Gigabits; -typedef LLUnit U32Kibibits; -typedef LLUnit U32Mibibits; -typedef LLUnit U32Gibibits; +typedef LLUnitImplicit S32BitsImplicit; +typedef LLUnitImplicit S32KilobitsImplicit; +typedef LLUnitImplicit S32MegabitsImplicit; +typedef LLUnitImplicit S32GigabitsImplicit; typedef LLUnit S64Bits; typedef LLUnit S64Kilobits; typedef LLUnit S64Megabits; typedef LLUnit S64Gigabits; -typedef LLUnit S64Kibibits; -typedef LLUnit S64Mibibits; -typedef LLUnit S64Gibibits; + +typedef LLUnitImplicit S64BitsImplicit; +typedef LLUnitImplicit S64KilobitsImplicit; +typedef LLUnitImplicit S64MegabitsImplicit; +typedef LLUnitImplicit S64GigabitsImplicit; + +typedef LLUnit U32Bits; +typedef LLUnit U32Kilobits; +typedef LLUnit U32Megabits; +typedef LLUnit U32Gigabits; + +typedef LLUnitImplicit U32BitsImplicit; +typedef LLUnitImplicit U32KilobitsImplicit; +typedef LLUnitImplicit U32MegabitsImplicit; +typedef LLUnitImplicit U32GigabitsImplicit; typedef LLUnit U64Bits; typedef LLUnit U64Kilobits; typedef LLUnit U64Megabits; typedef LLUnit U64Gigabits; -typedef LLUnit U64Kibibits; -typedef LLUnit U64Mibibits; -typedef LLUnit U64Gibibits; + +typedef LLUnitImplicit U64BitsImplicit; +typedef LLUnitImplicit U64KilobitsImplicit; +typedef LLUnitImplicit U64MegabitsImplicit; +typedef LLUnitImplicit U64GigabitsImplicit; namespace LLUnits { @@ -771,6 +819,14 @@ typedef LLUnit F32Milliseconds; typedef LLUnit F32Microseconds; typedef LLUnit F32Nanoseconds; +typedef LLUnitImplicit F32SecondsImplicit; +typedef LLUnitImplicit F32MinutesImplicit; +typedef LLUnitImplicit F32HoursImplicit; +typedef LLUnitImplicit F32DaysImplicit; +typedef LLUnitImplicit F32MillisecondsImplicit; +typedef LLUnitImplicit F32MicrosecondsImplicit; +typedef LLUnitImplicit F32NanosecondsImplicit; + typedef LLUnit F64Seconds; typedef LLUnit F64Minutes; typedef LLUnit F64Hours; @@ -779,6 +835,14 @@ typedef LLUnit F64Milliseconds; typedef LLUnit F64Microseconds; typedef LLUnit F64Nanoseconds; +typedef LLUnitImplicit F64SecondsImplicit; +typedef LLUnitImplicit F64MinutesImplicit; +typedef LLUnitImplicit F64HoursImplicit; +typedef LLUnitImplicit F64DaysImplicit; +typedef LLUnitImplicit F64MillisecondsImplicit; +typedef LLUnitImplicit F64MicrosecondsImplicit; +typedef LLUnitImplicit F64NanosecondsImplicit; + typedef LLUnit S32Seconds; typedef LLUnit S32Minutes; typedef LLUnit S32Hours; @@ -787,13 +851,13 @@ typedef LLUnit S32Milliseconds; typedef LLUnit S32Microseconds; typedef LLUnit S32Nanoseconds; -typedef LLUnit U32Seconds; -typedef LLUnit U32Minutes; -typedef LLUnit U32Hours; -typedef LLUnit U32Days; -typedef LLUnit U32Milliseconds; -typedef LLUnit U32Microseconds; -typedef LLUnit U32Nanoseconds; +typedef LLUnitImplicit S32SecondsImplicit; +typedef LLUnitImplicit S32MinutesImplicit; +typedef LLUnitImplicit S32HoursImplicit; +typedef LLUnitImplicit S32DaysImplicit; +typedef LLUnitImplicit S32MillisecondsImplicit; +typedef LLUnitImplicit S32MicrosecondsImplicit; +typedef LLUnitImplicit S32NanosecondsImplicit; typedef LLUnit S64Seconds; typedef LLUnit S64Minutes; @@ -802,7 +866,31 @@ typedef LLUnit S64Days; typedef LLUnit S64Milliseconds; typedef LLUnit S64Microseconds; typedef LLUnit S64Nanoseconds; - + +typedef LLUnitImplicit S64SecondsImplicit; +typedef LLUnitImplicit S64MinutesImplicit; +typedef LLUnitImplicit S64HoursImplicit; +typedef LLUnitImplicit S64DaysImplicit; +typedef LLUnitImplicit S64MillisecondsImplicit; +typedef LLUnitImplicit S64MicrosecondsImplicit; +typedef LLUnitImplicit S64NanosecondsImplicit; + +typedef LLUnit U32Seconds; +typedef LLUnit U32Minutes; +typedef LLUnit U32Hours; +typedef LLUnit U32Days; +typedef LLUnit U32Milliseconds; +typedef LLUnit U32Microseconds; +typedef LLUnit U32Nanoseconds; + +typedef LLUnitImplicit U32SecondsImplicit; +typedef LLUnitImplicit U32MinutesImplicit; +typedef LLUnitImplicit U32HoursImplicit; +typedef LLUnitImplicit U32DaysImplicit; +typedef LLUnitImplicit U32MillisecondsImplicit; +typedef LLUnitImplicit U32MicrosecondsImplicit; +typedef LLUnitImplicit U32NanosecondsImplicit; + typedef LLUnit U64Seconds; typedef LLUnit U64Minutes; typedef LLUnit U64Hours; @@ -811,6 +899,14 @@ typedef LLUnit U64Milliseconds; typedef LLUnit U64Microseconds; typedef LLUnit U64Nanoseconds; +typedef LLUnitImplicit U64SecondsImplicit; +typedef LLUnitImplicit U64MinutesImplicit; +typedef LLUnitImplicit U64HoursImplicit; +typedef LLUnitImplicit U64DaysImplicit; +typedef LLUnitImplicit U64MillisecondsImplicit; +typedef LLUnitImplicit U64MicrosecondsImplicit; +typedef LLUnitImplicit U64NanosecondsImplicit; + namespace LLUnits { LL_DECLARE_BASE_UNIT(Meters, "m"); @@ -824,31 +920,61 @@ typedef LLUnit F32Kilometers; typedef LLUnit F32Centimeters; typedef LLUnit F32Millimeters; +typedef LLUnitImplicit F32MetersImplicit; +typedef LLUnitImplicit F32KilometersImplicit; +typedef LLUnitImplicit F32CentimetersImplicit; +typedef LLUnitImplicit F32MillimetersImplicit; + typedef LLUnit F64Meters; typedef LLUnit F64Kilometers; typedef LLUnit F64Centimeters; typedef LLUnit F64Millimeters; +typedef LLUnitImplicit F64MetersImplicit; +typedef LLUnitImplicit F64KilometersImplicit; +typedef LLUnitImplicit F64CentimetersImplicit; +typedef LLUnitImplicit F64MillimetersImplicit; + typedef LLUnit S32Meters; typedef LLUnit S32Kilometers; typedef LLUnit S32Centimeters; typedef LLUnit S32Millimeters; -typedef LLUnit U32Meters; -typedef LLUnit U32Kilometers; -typedef LLUnit U32Centimeters; -typedef LLUnit U32Millimeters; +typedef LLUnitImplicit S32MetersImplicit; +typedef LLUnitImplicit S32KilometersImplicit; +typedef LLUnitImplicit S32CentimetersImplicit; +typedef LLUnitImplicit S32MillimetersImplicit; typedef LLUnit S64Meters; typedef LLUnit S64Kilometers; typedef LLUnit S64Centimeters; typedef LLUnit S64Millimeters; +typedef LLUnitImplicit S64MetersImplicit; +typedef LLUnitImplicit S64KilometersImplicit; +typedef LLUnitImplicit S64CentimetersImplicit; +typedef LLUnitImplicit S64MillimetersImplicit; + +typedef LLUnit U32Meters; +typedef LLUnit U32Kilometers; +typedef LLUnit U32Centimeters; +typedef LLUnit U32Millimeters; + +typedef LLUnitImplicit U32MetersImplicit; +typedef LLUnitImplicit U32KilometersImplicit; +typedef LLUnitImplicit U32CentimetersImplicit; +typedef LLUnitImplicit U32MillimetersImplicit; + typedef LLUnit U64Meters; typedef LLUnit U64Kilometers; typedef LLUnit U64Centimeters; typedef LLUnit U64Millimeters; +typedef LLUnitImplicit U64MetersImplicit; +typedef LLUnitImplicit U64KilometersImplicit; +typedef LLUnitImplicit U64CentimetersImplicit; +typedef LLUnitImplicit U64MillimetersImplicit; + namespace LLUnits { // rare units @@ -868,4 +994,137 @@ LL_DECLARE_DERIVED_UNIT(Triangles, * 1000, Kilotriangles, "ktris"); } // namespace LLUnits +// rare units +typedef LLUnit F32Hertz; +typedef LLUnit F32Kilohertz; +typedef LLUnit F32Megahertz; +typedef LLUnit F32Gigahertz; +typedef LLUnit F32Radians; +typedef LLUnit F32Degrees; +typedef LLUnit F32Percent; +typedef LLUnit F32Ratio; +typedef LLUnit F32Triangles; +typedef LLUnit F32KiloTriangles; + +typedef LLUnitImplicit F32HertzImplicit; +typedef LLUnitImplicit F32KilohertzImplicit; +typedef LLUnitImplicit F32MegahertzImplicit; +typedef LLUnitImplicit F32GigahertzImplicit; +typedef LLUnitImplicit F32RadiansImplicit; +typedef LLUnitImplicit F32DegreesImplicit; +typedef LLUnitImplicit F32PercentImplicit; +typedef LLUnitImplicit F32RatioImplicit; +typedef LLUnitImplicit F32TrianglesImplicit; +typedef LLUnitImplicit F32KiloTrianglesImplicit; + +typedef LLUnit F64Hertz; +typedef LLUnit F64Kilohertz; +typedef LLUnit F64Megahertz; +typedef LLUnit F64Gigahertz; +typedef LLUnit F64Radians; +typedef LLUnit F64Degrees; +typedef LLUnit F64Percent; +typedef LLUnit F64Ratio; +typedef LLUnit F64Triangles; +typedef LLUnit F64KiloTriangles; + +typedef LLUnitImplicit F64HertzImplicit; +typedef LLUnitImplicit F64KilohertzImplicit; +typedef LLUnitImplicit F64MegahertzImplicit; +typedef LLUnitImplicit F64GigahertzImplicit; +typedef LLUnitImplicit F64RadiansImplicit; +typedef LLUnitImplicit F64DegreesImplicit; +typedef LLUnitImplicit F64PercentImplicit; +typedef LLUnitImplicit F64RatioImplicit; +typedef LLUnitImplicit F64TrianglesImplicit; +typedef LLUnitImplicit F64KiloTrianglesImplicit; + +typedef LLUnit S32Hertz; +typedef LLUnit S32Kilohertz; +typedef LLUnit S32Megahertz; +typedef LLUnit S32Gigahertz; +typedef LLUnit S32Radians; +typedef LLUnit S32Degrees; +typedef LLUnit S32Percent; +typedef LLUnit S32Ratio; +typedef LLUnit S32Triangles; +typedef LLUnit S32KiloTriangles; + +typedef LLUnitImplicit S32HertzImplicit; +typedef LLUnitImplicit S32KilohertzImplicit; +typedef LLUnitImplicit S32MegahertzImplicit; +typedef LLUnitImplicit S32GigahertzImplicit; +typedef LLUnitImplicit S32RadiansImplicit; +typedef LLUnitImplicit S32DegreesImplicit; +typedef LLUnitImplicit S32PercentImplicit; +typedef LLUnitImplicit S32RatioImplicit; +typedef LLUnitImplicit S32TrianglesImplicit; +typedef LLUnitImplicit S32KiloTrianglesImplicit; + +typedef LLUnit S64Hertz; +typedef LLUnit S64Kilohertz; +typedef LLUnit S64Megahertz; +typedef LLUnit S64Gigahertz; +typedef LLUnit S64Radians; +typedef LLUnit S64Degrees; +typedef LLUnit S64Percent; +typedef LLUnit S64Ratio; +typedef LLUnit S64Triangles; +typedef LLUnit S64KiloTriangles; + +typedef LLUnitImplicit S64HertzImplicit; +typedef LLUnitImplicit S64KilohertzImplicit; +typedef LLUnitImplicit S64MegahertzImplicit; +typedef LLUnitImplicit S64GigahertzImplicit; +typedef LLUnitImplicit S64RadiansImplicit; +typedef LLUnitImplicit S64DegreesImplicit; +typedef LLUnitImplicit S64PercentImplicit; +typedef LLUnitImplicit S64RatioImplicit; +typedef LLUnitImplicit S64TrianglesImplicit; +typedef LLUnitImplicit S64KiloTrianglesImplicit; + +typedef LLUnit U32Hertz; +typedef LLUnit U32Kilohertz; +typedef LLUnit U32Megahertz; +typedef LLUnit U32Gigahertz; +typedef LLUnit U32Radians; +typedef LLUnit U32Degrees; +typedef LLUnit U32Percent; +typedef LLUnit U32Ratio; +typedef LLUnit U32Triangles; +typedef LLUnit U32KiloTriangles; + +typedef LLUnitImplicit U32HertzImplicit; +typedef LLUnitImplicit U32KilohertzImplicit; +typedef LLUnitImplicit U32MegahertzImplicit; +typedef LLUnitImplicit U32GigahertzImplicit; +typedef LLUnitImplicit U32RadiansImplicit; +typedef LLUnitImplicit U32DegreesImplicit; +typedef LLUnitImplicit U32PercentImplicit; +typedef LLUnitImplicit U32RatioImplicit; +typedef LLUnitImplicit U32TrianglesImplicit; +typedef LLUnitImplicit U32KiloTrianglesImplicit; + +typedef LLUnit U64Hertz; +typedef LLUnit U64Kilohertz; +typedef LLUnit U64Megahertz; +typedef LLUnit U64Gigahertz; +typedef LLUnit U64Radians; +typedef LLUnit U64Degrees; +typedef LLUnit U64Percent; +typedef LLUnit U64Ratio; +typedef LLUnit U64Triangles; +typedef LLUnit U64KiloTriangles; + +typedef LLUnitImplicit U64HertzImplicit; +typedef LLUnitImplicit U64KilohertzImplicit; +typedef LLUnitImplicit U64MegahertzImplicit; +typedef LLUnitImplicit U64GigahertzImplicit; +typedef LLUnitImplicit U64RadiansImplicit; +typedef LLUnitImplicit U64DegreesImplicit; +typedef LLUnitImplicit U64PercentImplicit; +typedef LLUnitImplicit U64RatioImplicit; +typedef LLUnitImplicit U64TrianglesImplicit; +typedef LLUnitImplicit U64KiloTrianglesImplicit; + #endif // LL_LLUNIT_H diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 8546bcbc54..a8e9be86ca 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -38,6 +38,13 @@ namespace LLUnits LL_DECLARE_DERIVED_UNIT(Latinum, / 16, Solari, "Sol"); } +typedef LLUnit F32Quatloos; +typedef LLUnit S32Quatloos; +typedef LLUnit F32Latinum; +typedef LLUnit S32Latinum; +typedef LLUnit F32Solari; +typedef LLUnit S32Solari; + namespace tut { using namespace LLUnits; @@ -54,28 +61,28 @@ namespace tut void units_object_t::test<1>() { LLUnit float_quatloos; - ensure("default float unit is zero", float_quatloos == 0.f); + ensure("default float unit is zero", float_quatloos == F32Quatloos(0.f)); LLUnit float_initialize_quatloos(1); - ensure("non-zero initialized unit", float_initialize_quatloos == 1.f); + ensure("non-zero initialized unit", float_initialize_quatloos == F32Quatloos(1.f)); LLUnit int_quatloos; - ensure("default int unit is zero", int_quatloos == 0); + ensure("default int unit is zero", int_quatloos == S32Quatloos(0)); - int_quatloos = 42; - ensure("int assignment is preserved", int_quatloos == 42); + int_quatloos = S32Quatloos(42); + ensure("int assignment is preserved", int_quatloos == S32Quatloos(42)); float_quatloos = int_quatloos; - ensure("float assignment from int preserves value", float_quatloos == 42.f); + ensure("float assignment from int preserves value", float_quatloos == F32Quatloos(42.f)); int_quatloos = float_quatloos; - ensure("int assignment from float preserves value", int_quatloos == 42); + ensure("int assignment from float preserves value", int_quatloos == S32Quatloos(42)); - float_quatloos = 42.1f; + float_quatloos = F32Quatloos(42.1f); int_quatloos = float_quatloos; - ensure("int units truncate float units on assignment", int_quatloos == 42); + ensure("int units truncate float units on assignment", int_quatloos == S32Quatloos(42)); LLUnit unsigned_int_quatloos(float_quatloos); - ensure("unsigned int can be initialized from signed int", unsigned_int_quatloos == 42); + ensure("unsigned int can be initialized from signed int", unsigned_int_quatloos == S32Quatloos(42)); } // conversions to/from base unit @@ -84,15 +91,15 @@ namespace tut { LLUnit quatloos(1.f); LLUnit latinum_bars(quatloos); - ensure("conversion between units is automatic via initialization", latinum_bars == 1.f / 4.f); + ensure("conversion between units is automatic via initialization", latinum_bars == F32Latinum(1.f / 4.f)); - latinum_bars = 256; + latinum_bars = S32Latinum(256); quatloos = latinum_bars; - ensure("conversion between units is automatic via assignment, and bidirectional", quatloos == 1024); + ensure("conversion between units is automatic via assignment, and bidirectional", quatloos == S32Quatloos(1024)); LLUnit single_quatloo(1); LLUnit quarter_latinum = single_quatloo; - ensure("division of integer unit preserves fractional values when converted to float unit", quarter_latinum == 0.25f); + ensure("division of integer unit preserves fractional values when converted to float unit", quarter_latinum == F32Latinum(0.25f)); } // conversions across non-base units @@ -101,10 +108,10 @@ namespace tut { LLUnit quatloos(1024); LLUnit solari(quatloos); - ensure("conversions can work between indirectly related units: Quatloos -> Latinum -> Solari", solari == 4096); + ensure("conversions can work between indirectly related units: Quatloos -> Latinum -> Solari", solari == S32Solari(4096)); LLUnit latinum_bars = solari; - ensure("Non base units can be converted between each other", latinum_bars == 256); + ensure("Non base units can be converted between each other", latinum_bars == S32Latinum(256)); } // math operations @@ -114,36 +121,36 @@ namespace tut // exercise math operations LLUnit quatloos(1.f); quatloos *= 4.f; - ensure(quatloos == 4); + ensure(quatloos == S32Quatloos(4)); quatloos = quatloos * 2; - ensure(quatloos == 8); + ensure(quatloos == S32Quatloos(8)); quatloos = 2.f * quatloos; - ensure(quatloos == 16); - - quatloos += 4.f; - ensure(quatloos == 20); - quatloos += 4; - ensure(quatloos == 24); - quatloos = quatloos + 4; - ensure(quatloos == 28); - quatloos = 4 + quatloos; - ensure(quatloos == 32); + ensure(quatloos == S32Quatloos(16)); + + quatloos += F32Quatloos(4.f); + ensure(quatloos == S32Quatloos(20)); + quatloos += S32Quatloos(4); + ensure(quatloos == S32Quatloos(24)); + quatloos = quatloos + S32Quatloos(4); + ensure(quatloos == S32Quatloos(28)); + quatloos = S32Quatloos(4) + quatloos; + ensure(quatloos == S32Quatloos(32)); quatloos += quatloos * 3; - ensure(quatloos == 128); + ensure(quatloos == S32Quatloos(128)); quatloos -= quatloos / 4 * 3; - ensure(quatloos == 32); - quatloos = quatloos - 8; - ensure(quatloos == 24); - quatloos -= 4; - ensure(quatloos == 20); - quatloos -= 4.f; - ensure(quatloos == 16); + ensure(quatloos == S32Quatloos(32)); + quatloos = quatloos - S32Quatloos(8); + ensure(quatloos == S32Quatloos(24)); + quatloos -= S32Quatloos(4); + ensure(quatloos == S32Quatloos(20)); + quatloos -= F32Quatloos(4.f); + ensure(quatloos == S32Quatloos(16)); quatloos /= 2.f; - ensure(quatloos == 8); + ensure(quatloos == S32Quatloos(8)); quatloos = quatloos / 4; - ensure(quatloos == 2); + ensure(quatloos == S32Quatloos(2)); F32 ratio = quatloos / LLUnit(2.f); ensure(ratio == 1); @@ -151,23 +158,54 @@ namespace tut ensure(ratio == 1); quatloos += LLUnit(8.f); - ensure(quatloos == 4); + ensure(quatloos == S32Quatloos(4)); quatloos -= LLUnit(1.f); - ensure(quatloos == 0); + ensure(quatloos == S32Quatloos(0)); } - // implicit units + // comparison operators template<> template<> void units_object_t::test<5>() + { + LLUnit quatloos(1); + ensure("can perform less than comparison against same type", quatloos < S32Quatloos(2)); + ensure("can perform less than comparison against different storage type", quatloos < F32Quatloos(2.f)); + ensure("can perform less than comparison against different units", quatloos < S32Latinum(5)); + ensure("can perform less than comparison against different storage type and units", quatloos < F32Latinum(5.f)); + + ensure("can perform greater than comparison against same type", quatloos > S32Quatloos(0)); + ensure("can perform greater than comparison against different storage type", quatloos > F32Quatloos(0.f)); + ensure("can perform greater than comparison against different units", quatloos > S32Latinum(0)); + ensure("can perform greater than comparison against different storage type and units", quatloos > F32Latinum(0.f)); + + } + + bool accept_explicit_quatloos(S32Quatloos q) + { + return true; + } + + // signature compatibility + template<> template<> + void units_object_t::test<6>() + { + S32Quatloos quatloos(1); + ensure("can pass unit values as argument", accept_explicit_quatloos(S32Quatloos(1))); + ensure("can pass unit values as argument", accept_explicit_quatloos(quatloos)); + } + + // implicit units + template<> template<> + void units_object_t::test<7>() { LLUnit quatloos; - LLUnitImplicit quatloos_implicit = quatloos + 1; + LLUnitImplicit quatloos_implicit = quatloos + S32Quatloos(1); ensure("can initialize implicit unit from explicit", quatloos_implicit == 1); quatloos = quatloos_implicit; - ensure("can assign implicit unit to explicit unit", quatloos == 1); + ensure("can assign implicit unit to explicit unit", quatloos == S32Quatloos(1)); quatloos += quatloos_implicit; - ensure("can perform math operation using mixture of implicit and explicit units", quatloos == 2); + ensure("can perform math operation using mixture of implicit and explicit units", quatloos == S32Quatloos(2)); // math operations on implicits quatloos_implicit = 1; diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 413266a29d..94552750f4 100755 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -1405,7 +1405,7 @@ void LLAssetStorage::storeAssetData( bool is_priority, bool store_local, bool user_waiting, - F64 timeout) + F64Seconds timeout) { LL_WARNS() << "storeAssetData: wrong version called" << LL_ENDL; // LLAssetStorage metric: Virtual base call @@ -1424,7 +1424,7 @@ void LLAssetStorage::storeAssetData( bool store_local, const LLUUID& requesting_agent_id, bool user_waiting, - F64 timeout) + F64Seconds timeout) { LL_WARNS() << "storeAssetData: wrong version called" << LL_ENDL; // LLAssetStorage metric: Virtual base call @@ -1442,7 +1442,7 @@ void LLAssetStorage::storeAssetData( bool temp_file, bool is_priority, bool user_waiting, - F64 timeout) + F64Seconds timeout) { LL_WARNS() << "storeAssetData: wrong version called" << LL_ENDL; // LLAssetStorage metric: Virtual base call @@ -1460,7 +1460,7 @@ void LLAssetStorage::storeAssetData( bool temp_file, bool is_priority, bool user_waiting, - F64 timeout) + F64Seconds timeout) { LL_WARNS() << "storeAssetData: wrong version called" << LL_ENDL; // LLAssetStorage metric: Virtual base call diff --git a/indra/llmessage/llassetstorage.h b/indra/llmessage/llassetstorage.h index 6ed1027cee..1bb4acea9e 100755 --- a/indra/llmessage/llassetstorage.h +++ b/indra/llmessage/llassetstorage.h @@ -49,7 +49,7 @@ class LLSD; // anything that takes longer than this to download will abort. // HTTP Uploads also timeout if they take longer than this. -const F32 LL_ASSET_STORAGE_TIMEOUT = 5 * 60.0f; +const F32Minutes LL_ASSET_STORAGE_TIMEOUT(5); // Specific error codes @@ -103,7 +103,7 @@ public: void setUUID(const LLUUID& id) { mUUID = id; } void setType(LLAssetType::EType type) { mType = type; } - void setTimeout (F64 timeout) { mTimeout = timeout; } + void setTimeout (F64Seconds timeout) { mTimeout = timeout; } protected: LLUUID mUUID; @@ -279,7 +279,7 @@ public: bool is_priority = false, bool store_local = false, bool user_waiting= false, - F64 timeout=LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT); /* * AssetID version @@ -295,7 +295,7 @@ public: bool store_local = false, const LLUUID& requesting_agent_id = LLUUID::null, bool user_waiting= false, - F64 timeout=LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT); virtual void checkForTimeouts(); @@ -403,7 +403,7 @@ public: bool temp_file = false, bool is_priority = false, bool user_waiting = false, - F64 timeout = LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout = LL_ASSET_STORAGE_TIMEOUT); /* * TransactionID version @@ -417,7 +417,7 @@ public: bool temp_file = false, bool is_priority = false, bool user_waiting = false, - F64 timeout = LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout = LL_ASSET_STORAGE_TIMEOUT); static void legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType, void *user_data, S32 status, LLExtStat ext_status); static void legacyStoreDataCallback(const LLUUID &uuid, void *user_data, S32 status, LLExtStat ext_status); diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index 1ace4d9b70..5aaada63b1 100755 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -207,7 +207,7 @@ void LLCircuitData::ackReliablePacket(TPACKETID packet_num) } if (packetp->mCallback) { - if (packetp->mTimeout < 0.f) // negative timeout will always return timeout even for successful ack, for debugging + if (packetp->mTimeout < F32Seconds(0.f)) // negative timeout will always return timeout even for successful ack, for debugging { packetp->mCallback(packetp->mCallbackData,LL_ERR_TCP_TIMEOUT); } @@ -241,7 +241,7 @@ void LLCircuitData::ackReliablePacket(TPACKETID packet_num) } if (packetp->mCallback) { - if (packetp->mTimeout < 0.f) // negative timeout will always return timeout even for successful ack, for debugging + if (packetp->mTimeout < F32Seconds(0.f)) // negative timeout will always return timeout even for successful ack, for debugging { packetp->mCallback(packetp->mCallbackData,LL_ERR_TCP_TIMEOUT); } @@ -540,8 +540,8 @@ void LLCircuitData::checkPeriodTime() mBytesInLastPeriod = mBytesInThisPeriod; mBytesOutLastPeriod = mBytesOutThisPeriod; - mBytesInThisPeriod = 0; - mBytesOutThisPeriod = 0; + mBytesInThisPeriod = S32Bytes(0); + mBytesOutThisPeriod = S32Bytes(0); mLastPeriodLength = period_length; mPeriodTime = mt_sec; @@ -549,14 +549,14 @@ void LLCircuitData::checkPeriodTime() } -void LLCircuitData::addBytesIn(S32 bytes) +void LLCircuitData::addBytesIn(S32Bytes bytes) { mBytesIn += bytes; mBytesInThisPeriod += bytes; } -void LLCircuitData::addBytesOut(S32 bytes) +void LLCircuitData::addBytesOut(S32Bytes bytes) { mBytesOut += bytes; mBytesOutThisPeriod += bytes; @@ -743,7 +743,7 @@ void LLCircuitData::checkPacketInID(TPACKETID id, BOOL receive_resent) } // LL_INFOS() << "adding potential lost: " << index << LL_ENDL; - mPotentialLostPackets[index] = time.value(); + mPotentialLostPackets[index] = time; index++; index = index % LL_MAX_OUT_PACKET_ID; gap_count++; @@ -1152,23 +1152,23 @@ std::ostream& operator<<(std::ostream& s, LLCircuitData& circuit) << endl; s << "Global In/Out " << S32(age) << " sec" - << " KBytes: " << circuit.mBytesIn.valueInUnits() << "/" << circuit.mBytesOut.valueInUnits() + << " KBytes: " << circuit.mBytesIn.valueInUnits() << "/" << circuit.mBytesOut.valueInUnits() << " Kbps: " - << S32(circuit.mBytesIn.valueInUnits() / circuit.mExistenceTimer.getElapsedTimeF32().value()) + << S32(circuit.mBytesIn.valueInUnits() / circuit.mExistenceTimer.getElapsedTimeF32().value()) << "/" - << S32(circuit.mBytesOut.valueInUnits() / circuit.mExistenceTimer.getElapsedTimeF32().value()) + << S32(circuit.mBytesOut.valueInUnits() / circuit.mExistenceTimer.getElapsedTimeF32().value()) << " Packets: " << circuit.mPacketsIn << "/" << circuit.mPacketsOut << endl; s << "Recent In/Out " << circuit.mLastPeriodLength << " KBytes: " - << circuit.mBytesInLastPeriod.valueInUnits() + << circuit.mBytesInLastPeriod.valueInUnits() << "/" - << circuit.mBytesOutLastPeriod.valueInUnits() + << circuit.mBytesOutLastPeriod.valueInUnits() << " Kbps: " - << (S32)(circuit.mBytesInLastPeriod.valueInUnits() / circuit.mLastPeriodLength.value()) + << (S32)(circuit.mBytesInLastPeriod.valueInUnits() / circuit.mLastPeriodLength.value()) << "/" - << (S32)(circuit.mBytesOutLastPeriod.valueInUnits() / circuit.mLastPeriodLength.value()) + << (S32)(circuit.mBytesOutLastPeriod.valueInUnits() / circuit.mLastPeriodLength.value()) << " Peak kbps: " << S32(circuit.mPeakBPSIn / 1024.f) << "/" @@ -1261,7 +1261,7 @@ void LLCircuitData::pingTimerStop(const U8 ping_id) // Nota Bene: no averaging of ping times until we get a feel for how this works F64Seconds time = mt_secs - mPingTime; - if (time == 0.0) + if (time == F32Seconds(0.0)) { // Ack, we got our ping response on the same frame! Sigh, let's get a real time otherwise // all of our ping calculations will be skewed. @@ -1368,7 +1368,7 @@ F32Milliseconds LLCircuitData::getPingInTransitTime() if (mPingsInTransit) { - time_since_ping_was_sent = ((mPingsInTransit*mHeartbeatInterval - 1) + time_since_ping_was_sent = ((mPingsInTransit*mHeartbeatInterval - F32Seconds(1)) + (LLMessageSystem::getMessageTimeSeconds() - mPingTime)); } diff --git a/indra/llmessage/llcircuit.h b/indra/llmessage/llcircuit.h index bc29805859..5b109fc218 100755 --- a/indra/llmessage/llcircuit.h +++ b/indra/llmessage/llcircuit.h @@ -167,8 +167,8 @@ protected: void setPingDelay(U32Milliseconds ping); BOOL checkCircuitTimeout(); // Return FALSE if the circuit is dead and should be cleaned up - void addBytesIn(S32 bytes); - void addBytesOut(S32 bytes); + void addBytesIn(S32Bytes bytes); + void addBytesOut(S32Bytes bytes); U8 nextPingID() { mLastPingID++; return mLastPingID; } diff --git a/indra/llmessage/llhttpassetstorage.cpp b/indra/llmessage/llhttpassetstorage.cpp index d9b537941b..095da6f0f9 100755 --- a/indra/llmessage/llhttpassetstorage.cpp +++ b/indra/llmessage/llhttpassetstorage.cpp @@ -456,7 +456,7 @@ void LLHTTPAssetStorage::storeAssetData( bool store_local, const LLUUID& requesting_agent_id, bool user_waiting, - F64 timeout) + F64Seconds timeout) { if (mVFS->getExists(uuid, type)) // VFS treats nonexistant and zero-length identically { @@ -516,7 +516,7 @@ void LLHTTPAssetStorage::storeAssetData( bool temp_file, bool is_priority, bool user_waiting, - F64 timeout) + F64Seconds timeout) { LL_INFOS() << "LLAssetStorage::storeAssetData (legacy)" << asset_id << ":" << LLAssetType::lookup(asset_type) << LL_ENDL; diff --git a/indra/llmessage/llhttpassetstorage.h b/indra/llmessage/llhttpassetstorage.h index f743ccf0ac..783e95cac6 100755 --- a/indra/llmessage/llhttpassetstorage.h +++ b/indra/llmessage/llhttpassetstorage.h @@ -69,7 +69,7 @@ public: bool store_local = false, const LLUUID& requesting_agent_id = LLUUID::null, bool user_waiting=FALSE, - F64 timeout=LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT); virtual void storeAssetData( const std::string& filename, @@ -80,7 +80,7 @@ public: bool temp_file, bool is_priority, bool user_waiting=FALSE, - F64 timeout=LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT); virtual LLSD getPendingDetails(ERequestType rt, LLAssetType::EType asset_type, diff --git a/indra/llmessage/llpacketack.h b/indra/llmessage/llpacketack.h index 0a5604f74f..f55d5246f6 100755 --- a/indra/llmessage/llpacketack.h +++ b/indra/llmessage/llpacketack.h @@ -54,7 +54,7 @@ public: mHost.invalidate(); mRetries = 0; mPingBasedRetry = TRUE; - mTimeout = 0.f; + mTimeout = F32Seconds(0.f); mCallback = NULL; mCallbackData = NULL; mMessageName = NULL; diff --git a/indra/llmessage/llthrottle.cpp b/indra/llmessage/llthrottle.cpp index 00eaa7e2ec..e484bd258d 100755 --- a/indra/llmessage/llthrottle.cpp +++ b/indra/llmessage/llthrottle.cpp @@ -356,7 +356,7 @@ BOOL LLThrottleGroup::throttleOverflow(S32 throttle_cat, F32 bits) BOOL LLThrottleGroup::dynamicAdjust() { - const F32 DYNAMIC_ADJUST_TIME = 1.0f; // seconds + const F32Seconds DYNAMIC_ADJUST_TIME(1.0f); const F32 CURRENT_PERIOD_WEIGHT = .25f; // how much weight to give to last period while determining BPS utilization const F32 BUSY_PERCENT = 0.75f; // if use more than this fraction of BPS, you are busy const F32 IDLE_PERCENT = 0.70f; // if use less than this fraction, you are "idle" @@ -405,7 +405,7 @@ BOOL LLThrottleGroup::dynamicAdjust() for (i = 0; i < TC_EOF; i++) { // Is this a busy channel? - if (mBitsSentHistory[i] >= BUSY_PERCENT * DYNAMIC_ADJUST_TIME * mCurrentBPS[i]) + if (mBitsSentHistory[i] >= BUSY_PERCENT * DYNAMIC_ADJUST_TIME.value() * mCurrentBPS[i]) { // this channel is busy channels_busy = TRUE; @@ -418,7 +418,7 @@ BOOL LLThrottleGroup::dynamicAdjust() } // Is this an idle channel? - if ((mBitsSentHistory[i] < IDLE_PERCENT * DYNAMIC_ADJUST_TIME * mCurrentBPS[i]) && + if ((mBitsSentHistory[i] < IDLE_PERCENT * DYNAMIC_ADJUST_TIME.value() * mCurrentBPS[i]) && (mBitsAvailable[i] > 0)) { channel_idle[i] = TRUE; @@ -462,7 +462,7 @@ BOOL LLThrottleGroup::dynamicAdjust() // Therefore it's a candidate to give up some bandwidth. // Figure out how much bandwidth it has been using, and how // much is available to steal. - used_bps = mBitsSentHistory[i] / DYNAMIC_ADJUST_TIME; + used_bps = mBitsSentHistory[i] / DYNAMIC_ADJUST_TIME.value(); // CRO make sure to keep a minimum amount of throttle available // CRO NB: channels set to < MINIMUM_BPS will never give up bps, diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 1f4dd11f73..88c73852af 100755 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -80,7 +80,7 @@ // Constants //const char* MESSAGE_LOG_FILENAME = "message.log"; -static const F32 CIRCUIT_DUMP_TIMEOUT = 30.f; +static const F32Seconds CIRCUIT_DUMP_TIMEOUT(30.f); static const S32 TRUST_TIME_WINDOW = 3; // *NOTE: This needs to be moved into a seperate file so that it never gets @@ -259,7 +259,7 @@ LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port, mSendPacketFailureCount = 0; - mCircuitPrintFreq = 60.f; // seconds + mCircuitPrintFreq = F32Seconds(60.f); loadTemplateFile(filename, failure_is_fatal); @@ -312,11 +312,11 @@ LLMessageSystem::LLMessageSystem(const std::string& filename, U32 port, // Constants for dumping output based on message processing time/count mNumMessageCounts = 0; mMaxMessageCounts = 200; // >= 0 means dump warnings - mMaxMessageTime = 1.f; + mMaxMessageTime = F32Seconds(1.f); mTrueReceiveSize = 0; - mReceiveTime = 0.f; + mReceiveTime = F32Seconds(0.f); } @@ -833,7 +833,7 @@ void LLMessageSystem::processAcks() } } - if (mMaxMessageTime >= 0.f) + if (mMaxMessageTime >= F32Seconds(0.f)) { // This is one of the only places where we're required to get REAL message system time. mReceiveTime = getMessageTimeSeconds(TRUE) - mMessageCountTime; @@ -1337,7 +1337,7 @@ S32 LLMessageSystem::sendMessage(const LLHost &host) else { // mCircuitInfo already points to the correct circuit data - cdp->addBytesOut( buffer_length ); + cdp->addBytesOut( (S32Bytes)buffer_length ); } if(mVerboseLog) @@ -1464,7 +1464,7 @@ void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, BOOL r { // update circuit packet ID tracking (missing/out of order packets) cdp->checkPacketInID( mCurrentRecvPacketID, recv_resent ); - cdp->addBytesIn( mTrueReceiveSize ); + cdp->addBytesIn( (S32Bytes)mTrueReceiveSize ); } if(mVerboseLog) @@ -1731,7 +1731,7 @@ LLHost LLMessageSystem::findHost(const U32 circuit_code) void LLMessageSystem::setMaxMessageTime(const F32 seconds) { - mMaxMessageTime = seconds; + mMaxMessageTime = F32Seconds(seconds); } void LLMessageSystem::setMaxMessageCounts(const S32 num) @@ -2752,7 +2752,7 @@ void LLMessageSystem::dumpReceiveCounts() if (mt->mReceiveCount > 0) { LL_INFOS("Messaging") << "Num: " << std::setw(3) << mt->mReceiveCount << " Bytes: " << std::setw(6) << mt->mReceiveBytes - << " Invalid: " << std::setw(3) << mt->mReceiveInvalid << " " << mt->mName << " " << llround(100 * mt->mDecodeTimeThisFrame / mReceiveTime) << "%" << LL_ENDL; + << " Invalid: " << std::setw(3) << mt->mReceiveInvalid << " " << mt->mName << " " << llround(100 * mt->mDecodeTimeThisFrame / mReceiveTime.value()) << "%" << LL_ENDL; } } } diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h index 75eccc7f75..da06b64506 100755 --- a/indra/llmessage/message.h +++ b/indra/llmessage/message.h @@ -267,7 +267,7 @@ public: LLCircuit mCircuitInfo; F64Seconds mCircuitPrintTime; // used to print circuit debug info every couple minutes - F32 mCircuitPrintFreq; // seconds + F32Seconds mCircuitPrintFreq; std::map mIPPortToCircuitCode; std::map mCircuitCodeToIPPort; diff --git a/indra/llrender/llgltexture.cpp b/indra/llrender/llgltexture.cpp index d06ed5e57b..56e263c5f1 100644 --- a/indra/llrender/llgltexture.cpp +++ b/indra/llrender/llgltexture.cpp @@ -294,7 +294,7 @@ LLTexUnit::eTextureAddressMode LLGLTexture::getAddressMode(void) const return mGLTexturep->getAddressMode() ; } -S32 LLGLTexture::getTextureMemory() const +S32Bytes LLGLTexture::getTextureMemory() const { llassert(mGLTexturep.notNull()) ; diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index 6b85f81aee..45592ee077 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -138,7 +138,7 @@ public: S32 getDiscardLevel() const; S8 getComponents() const; BOOL getBoundRecently() const; - S32 getTextureMemory() const ; + S32Bytes getTextureMemory() const ; LLGLenum getPrimaryFormat() const; BOOL getIsAlphaMask() const ; LLTexUnit::eTextureType getTarget(void) const ; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index b63ee7f9f9..5d46fb290c 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -253,7 +253,7 @@ void LLImageGL::updateStats(F32 current_time) } //static -S32 LLImageGL::updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) +S32 LLImageGL::updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) { LLImageGL::sCurBoundTextureMemory += mem ; return LLImageGL::sCurBoundTextureMemory.value(); @@ -398,7 +398,7 @@ void LLImageGL::init(BOOL usemipmaps) // so that it is obvious by visual inspection if we forgot to // init a field. - mTextureMemory = 0; + mTextureMemory = (S32Bytes)0; mLastBindTime = 0.f; mPickMask = NULL; @@ -563,7 +563,7 @@ void LLImageGL::forceUpdateBindStats(void) const mLastBindTime = sLastFrameTime; } -BOOL LLImageGL::updateBindStats(S32 tex_mem) const +BOOL LLImageGL::updateBindStats(S32Bytes tex_mem) const { if (mTexName != 0) { @@ -1460,7 +1460,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ stop_glerror(); } - mTextureMemory = getMipBytes(discard_level); + mTextureMemory = (S32Bytes)getMipBytes(discard_level); sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight() ; @@ -1618,10 +1618,10 @@ void LLImageGL::destroyGLTexture() { if (mTexName != 0) { - if(mTextureMemory) + if(mTextureMemory != S32Bytes(0)) { sGlobalTextureMemory -= mTextureMemory; - mTextureMemory = 0; + mTextureMemory = (S32Bytes)0; } LLImageGL::deleteTextures(mBindTarget, mFormatInternal, mMipLevels, 1, &mTexName); diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 035d42c3ad..5e027851f3 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -63,7 +63,7 @@ public: static S32 dataFormatBytes(S32 dataformat, S32 width, S32 height); static S32 dataFormatComponents(S32 dataformat); - BOOL updateBindStats(S32 tex_mem) const ; + BOOL updateBindStats(S32Bytes tex_mem) const ; F32 getTimePassedSinceLastBound(); void forceUpdateBindStats(void) const; @@ -76,7 +76,7 @@ public: static void dirtyTexOptions(); // Sometimes called externally for textures not using LLImageGL (should go away...) - static S32 updateBoundTexMem(const S32 mem, const S32 ncomponents, S32 category) ; + static S32 updateBoundTexMem(const S32Bytes mem, const S32 ncomponents, S32 category) ; static bool checkSize(S32 width, S32 height); @@ -189,7 +189,7 @@ public: public: // Various GL/Rendering options - S32 mTextureMemory; + S32Bytes mTextureMemory; mutable F32 mLastBindTime; // last time this was bound, by discard level private: diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 4c64cc944e..03a2895289 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -253,7 +253,7 @@ template S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const T& stat, const F32Seconds time_period) { F32Seconds elapsed_time, - time_since_value_changed; + time_since_value_changed; S32 num_rapid_changes = 0; const F32Seconds RAPID_CHANGE_THRESHOLD = F32Seconds(0.3f); @@ -266,7 +266,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const if (last_value != cur_value) { if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; - time_since_value_changed = 0; + time_since_value_changed = (F32Seconds)0; } last_value = cur_value; @@ -280,7 +280,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const F32Seconds time_period) { F32Seconds elapsed_time, - time_since_value_changed; + time_since_value_changed; S32 num_rapid_changes = 0; F64 last_value = periodic_recording.getPrevRecording(1).getSum(stat); @@ -292,7 +292,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const if (last_value != cur_value) { if (time_since_value_changed < RAPID_CHANGE_THRESHOLD) num_rapid_changes++; - time_since_value_changed = 0; + time_since_value_changed = (F32Seconds)0; } last_value = cur_value; @@ -355,7 +355,7 @@ void LLStatBar::draw() mean = frame_recording.getPeriodMean(sample_stat, num_frames); num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); - if (num_rapid_changes / RAPID_CHANGE_WINDOW > MAX_RAPID_CHANGES_PER_SEC) + if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC) { display_value = mean; } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 339a8f1ab0..f506765da3 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -293,12 +293,12 @@ U32 gFrameCount = 0; U32 gForegroundFrameCount = 0; // number of frames that app window was in foreground LLPumpIO* gServicePump = NULL; -LLUnitImplicit gFrameTime = 0; -LLUnitImplicit gFrameTimeSeconds = 0.f; -LLUnitImplicit gFrameIntervalSeconds = 0.f; +U64MicrosecondsImplicit gFrameTime = 0; +F32SecondsImplicit gFrameTimeSeconds = 0.f; +F32SecondsImplicit 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 -LLUnitImplicit gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds +U64MicrosecondsImplicit gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds U32 gFrameStalls = 0; const F64 FRAME_STALL_THRESHOLD = 1.0; @@ -1046,9 +1046,8 @@ bool LLAppViewer::init() // get RAM data from XML std::stringstream minRAMString(LLNotifications::instance().getGlobalString("UnsupportedRAMAmount")); - U64 minRAM = 0; + U64Bytes minRAM; minRAMString >> minRAM; - minRAM = minRAM * 1024 * 1024; if(!LLFeatureManager::getInstance()->isGPUSupported() && LLFeatureManager::getInstance()->getGPUClass() != GPU_CLASS_UNKNOWN) { @@ -1202,7 +1201,7 @@ void LLAppViewer::initMaxHeapSize() //currently SL is built under 32-bit setting, we set its max heap size no more than 1.6 GB. //F32 max_heap_size_gb = llmin(1.6f, (F32)gSavedSettings.getF32("MaxHeapSize")) ; - F32 max_heap_size_gb = gSavedSettings.getF32("MaxHeapSize") ; + F32Gigabytes max_heap_size_gb = (F32Gigabytes)gSavedSettings.getF32("MaxHeapSize") ; BOOL enable_mem_failure_prevention = (BOOL)gSavedSettings.getBOOL("MemoryFailurePreventionEnabled") ; LLMemory::initMaxHeapSizeGB(max_heap_size_gb, enable_mem_failure_prevention) ; @@ -1464,7 +1463,7 @@ bool LLAppViewer::mainLoop() ms_sleep(500); } - const F64 max_idle_time = llmin(.005*10.0*gFrameTimeSeconds, LLUnitImplicit(0.005f)); // 5 ms a second + const F64 max_idle_time = llmin(.005f*10.f*(F32MillisecondsImplicit)gFrameTimeSeconds, F32MillisecondsImplicit(5)); // 5 ms a second idleTimer.reset(); S32 total_work_pending = 0; S32 total_io_pending = 0; @@ -3138,8 +3137,7 @@ bool LLAppViewer::meetsRequirementsForMaximizedStart() { bool maximizedOk = (LLFeatureManager::getInstance()->getGPUClass() >= GPU_CLASS_2); - const U32 one_gigabyte_kb = 1024 * 1024; - maximizedOk &= (gSysMemory.getPhysicalMemoryKB() >= one_gigabyte_kb); + maximizedOk &= (gSysMemory.getPhysicalMemoryKB() >= U32Gigabytes(1)); return maximizedOk; } @@ -3330,7 +3328,7 @@ void LLAppViewer::writeSystemInfo() gDebugInfo["CPUInfo"]["CPUSSE2"] = gSysCPU.hasSSE2(); gDebugInfo["RAMInfo"]["Physical"] = (LLSD::Integer)(gSysMemory.getPhysicalMemoryKB().value()); - gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated.valueInUnits()); + gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated.valueInUnits()); gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple(); // The user is not logged on yet, but record the current grid choice login url diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 10452e64e2..6b16a96c11 100755 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -334,10 +334,10 @@ extern U32 gForegroundFrameCount; extern LLPumpIO* gServicePump; -extern LLUnitImplicit gStartTime; -extern LLUnitImplicit gFrameTime; // The timestamp of the most-recently-processed frame -extern LLUnitImplicit gFrameTimeSeconds; // Loses msec precision after ~4.5 hours... -extern LLUnitImplicit gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds +extern U64MicrosecondsImplicit gStartTime; +extern U64MicrosecondsImplicit gFrameTime; // The timestamp of the most-recently-processed frame +extern F32SecondsImplicit gFrameTimeSeconds; // Loses msec precision after ~4.5 hours... +extern F32SecondsImplicit gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds extern F32 gFPSClamped; // Frames per second, smoothed, weighted toward last frame extern F32 gFrameDTClamped; extern U32 gFrameStalls; diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp index 9311056a27..03b1f14a03 100755 --- a/indra/newview/llconversationlog.cpp +++ b/indra/newview/llconversationlog.cpp @@ -35,7 +35,7 @@ #include #include "boost/lexical_cast.hpp" -const int CONVERSATION_LIFETIME = 30; // lifetime of LLConversation is 30 days by spec +const S32Days CONVERSATION_LIFETIME = (S32Days)30; // lifetime of LLConversation is 30 days by spec struct ConversationParams : public LLInitParam::Block { @@ -100,7 +100,7 @@ LLConversation::~LLConversation() void LLConversation::updateTimestamp() { - mTime = time_corrected(); + mTime = (U64Seconds)time_corrected(); mTimestamp = createTimestamp(mTime); } @@ -130,10 +130,10 @@ const std::string LLConversation::createTimestamp(const U64Seconds& utc_time) return timeStr; } -bool LLConversation::isOlderThan(U32 days) const +bool LLConversation::isOlderThan(U32Days days) const { U64Seconds now(time_corrected()); - LLUnit age = now - mTime; + U32Days age = now - mTime; return age > days; } diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h index fd6ad9ad66..b38d472156 100755 --- a/indra/newview/llconversationlog.h +++ b/indra/newview/llconversationlog.h @@ -61,7 +61,7 @@ public: void setConversationName(std::string conv_name) { mConversationName = conv_name; } void setOfflineMessages(bool new_messages) { mHasOfflineIMs = new_messages; } - bool isOlderThan(U32 days) const; + bool isOlderThan(U32Days days) const; /* * updates last interaction time diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 725a2f2daf..36cbd67333 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -1143,7 +1143,7 @@ void LLFastTimerView::drawLineGraph() } //interpolate towards new maximum - max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); + max_time = (F32Seconds)lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f)); if (llabs((max_time - cur_max).value()) <= 1) { max_time = llmax(F32Microseconds(1.f), F32Microseconds(cur_max)); @@ -1439,7 +1439,7 @@ void LLFastTimerView::drawBars() bar_height -= vpad; updateTotalTime(); - if (mTotalTimeDisplay <= 0.0) return; + if (mTotalTimeDisplay <= (F32Seconds)0.0) return; drawTicks(); const S32 bars_top = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4); @@ -1550,7 +1550,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer if (timer_bar_index == 0) { - timer_bar.mSelfStart = 0.f; + timer_bar.mSelfStart = F32Seconds(0.f); timer_bar.mSelfEnd = bar_time; } @@ -1583,7 +1583,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer } child_timer_bar.mStartFraction = bar_fraction_start; - child_timer_bar.mEndFraction = bar_time > 0 + child_timer_bar.mEndFraction = bar_time > (S32Seconds)0 ? bar_fraction_start + child_timer_bar.mTotalTime / bar_time : 1.f; child_timer_bar.mSelfStart = timer_bar.mChildrenStart diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 01596f0b4b..333e8ee67e 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -867,7 +867,7 @@ void LLFeatureManager::applyBaseMasks() maskFeatures(gpustr); // now mask cpu type ones - if (gSysMemory.getPhysicalMemoryClamped() <= 256*1024*1024) + if (gSysMemory.getPhysicalMemoryClamped() <= U32Megabytes(256)) { maskFeatures("RAM256MB"); } diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp index ad94949863..7f81d40ebb 100755 --- a/indra/newview/llfloaterabout.cpp +++ b/indra/newview/llfloaterabout.cpp @@ -259,7 +259,7 @@ LLSD LLFloaterAbout::getInfo() // CPU info["CPU"] = gSysCPU.getCPUString(); - info["MEMORY_MB"] = LLSD::Integer(gSysMemory.getPhysicalMemoryKB().valueInUnits()); + info["MEMORY_MB"] = LLSD::Integer(gSysMemory.getPhysicalMemoryKB().valueInUnits()); // Moved hack adjustment to Windows memory size into llsys.cpp info["OS_VERSION"] = LLAppViewer::instance()->getOSInfo().getOSString(); info["GRAPHICS_CARD_VENDOR"] = (const char*)(glGetString(GL_VENDOR)); diff --git a/indra/newview/llfloaterhardwaresettings.cpp b/indra/newview/llfloaterhardwaresettings.cpp index adb490d524..9efdf9d10e 100755 --- a/indra/newview/llfloaterhardwaresettings.cpp +++ b/indra/newview/llfloaterhardwaresettings.cpp @@ -89,8 +89,8 @@ void LLFloaterHardwareSettings::refresh() void LLFloaterHardwareSettings::refreshEnabledState() { - S32Mibibytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); - S32Mibibytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(); + S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting(); + S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(); getChild("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value()); getChild("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value()); diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index ecee801e8e..7fafabb493 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -471,7 +471,8 @@ void LLSceneMonitor::fetchQueryResult() LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF); // also throttle timing here, to avoid going below sample time due to phasing with frame capture - static LLCachedControl scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime"); + static LLCachedControl scene_load_sample_time_control(gSavedSettings, "SceneLoadingMonitorSampleTime"); + F32Seconds scene_load_sample_time = (F32Seconds)scene_load_sample_time_control(); if(mDiffState == WAIT_ON_RESULT && !LLAppViewer::instance()->quitRequested()) @@ -491,7 +492,7 @@ void LLSceneMonitor::fetchQueryResult() record(sFramePixelDiff, mDiffResult); static LLCachedControl diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold"); - F32 elapsed_time = mRecordingTimer.getElapsedTimeF32(); + F32Seconds elapsed_time = mRecordingTimer.getElapsedTimeF32(); if (elapsed_time > scene_load_sample_time) { @@ -649,7 +650,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) for (S32 frame = 1; frame <= frame_count; frame++) { - os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).valueInUnits(); + os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).valueInUnits(); } os << '\n'; diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h index f94232e536..c99ec1e824 100644 --- a/indra/newview/llscenemonitor.h +++ b/indra/newview/llscenemonitor.h @@ -62,7 +62,7 @@ public: const LLTrace::ExtendablePeriodicRecording* getRecording() const {return &mSceneLoadRecording;} void dumpToFile(std::string file_name); - bool hasResults() const { return mSceneLoadRecording.getResults().getDuration() != 0;} + bool hasResults() const { return mSceneLoadRecording.getResults().getDuration() != S32Seconds(0);} private: void freezeScene(); diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp index 55afc3e454..2d06b8599c 100755 --- a/indra/newview/llsurfacepatch.cpp +++ b/indra/newview/llsurfacepatch.cpp @@ -43,7 +43,7 @@ #include "noise.h" extern bool gShiftFrame; -extern LLUnitImplicit gFrameTime; +extern U64MicrosecondsImplicit gFrameTime; extern LLPipeline gPipeline; LLSurfacePatch::LLSurfacePatch() diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 07ff1de702..8d63ebdffc 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -946,7 +946,7 @@ LLTextureFetchWorker::~LLTextureFetchWorker() mHttpBufferArray = NULL; } unlockWorkMutex(); // -Mw - mFetcher->removeFromHTTPQueue(mID, 0); + mFetcher->removeFromHTTPQueue(mID, (S32Bytes)0); mFetcher->removeHttpWaiter(mID); mFetcher->updateStateStats(mCacheReadCount, mCacheWriteCount, mResourceWaitCount); } @@ -1483,7 +1483,7 @@ bool LLTextureFetchWorker::doWork(S32 param) mGetReason.clear(); LL_DEBUGS("Texture") << "HTTP GET: " << mID << " Offset: " << mRequestedOffset << " Bytes: " << mRequestedSize - << " Bandwidth(kbps): " << mFetcher->getTextureBandwidth().value() << "/" << mFetcher->mMaxBandwidth + << " Bandwidth(kbps): " << mFetcher->getTextureBandwidth() << "/" << mFetcher->mMaxBandwidth << LL_ENDL; // Will call callbackHttpGet when curl request completes @@ -1931,7 +1931,7 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe partial = (par_status == status); } - S32 data_size = callbackHttpGet(response, partial, success); + S32BytesImplicit data_size = callbackHttpGet(response, partial, success); if (log_texture_traffic && data_size > 0) { @@ -2352,7 +2352,7 @@ void LLTextureFetchWorker::recordTextureDone(bool is_http) is_http, LLImageBase::TYPE_AVATAR_BAKE == mType, LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime); - mMetricsStartTime = 0; + mMetricsStartTime = (U32Seconds)0; } LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, is_http, @@ -2607,11 +2607,11 @@ void LLTextureFetch::addToHTTPQueue(const LLUUID& id) } // -Mfnq // Threads: T* -void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32 received_size) +void LLTextureFetch::removeFromHTTPQueue(const LLUUID& id, S32Bytes received_size) { LLMutexLock lock(&mNetworkQueueMutex); // +Mfnq mHTTPTextureQueue.erase(id); - mHTTPTextureBits += received_size * 8; // Approximate - does not include header bits + mHTTPTextureBits += received_size; // Approximate - does not include header bits } // -Mfnq // NB: If you change deleteRequest() you should probably make @@ -2762,7 +2762,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level, raw = worker->mRawImage; aux = worker->mAuxImage; F32Seconds cache_read_time(worker->mCacheReadTime); - if (cache_read_time != 0.f) + if (cache_read_time != (F32Seconds)0.f) { record(sCacheReadLatency, cache_read_time); } @@ -2888,10 +2888,10 @@ S32 LLTextureFetch::update(F32 max_time_ms) { mNetworkQueueMutex.lock(); // +Mfnq - mMaxBandwidth = band_width; + mMaxBandwidth = band_width(); add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, mHTTPTextureBits); - mHTTPTextureBits = 0; + mHTTPTextureBits = (U32Bits)0; mNetworkQueueMutex.unlock(); // -Mfnq } diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 78b13cdd80..81c505679e 100755 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -107,10 +107,10 @@ public: bool receiveImagePacket(const LLHost& host, const LLUUID& id, U16 packet_num, U16 data_size, U8* data); // Threads: T* (but not safe) - void setTextureBandwidth(F32Kibibits bandwidth) { mTextureBandwidth = bandwidth; } + void setTextureBandwidth(F32 bandwidth) { mTextureBandwidth = bandwidth; } // Threads: T* (but not safe) - F32Kibibits getTextureBandwidth() { return mTextureBandwidth; } + F32 getTextureBandwidth() { return mTextureBandwidth; } // Threads: T* BOOL isFromLocalCache(const LLUUID& id); @@ -234,7 +234,7 @@ protected: // XXX possible delete // Threads: T* - void removeFromHTTPQueue(const LLUUID& id, S32 received_size); + void removeFromHTTPQueue(const LLUUID& id, S32Bytes received_size); // Identical to @deleteRequest but with different arguments // (caller already has the worker pointer). @@ -325,8 +325,8 @@ private: queue_t mHTTPTextureQueue; // Mfnq typedef std::map > cancel_queue_t; cancel_queue_t mCancelQueue; // Mfnq - F32Kibibits mTextureBandwidth; // - F32Kibibits mMaxBandwidth; // Mfnq + F32 mTextureBandwidth; // + F32 mMaxBandwidth; // Mfnq LLTextureInfo mTextureInfo; // XXX possible delete diff --git a/indra/newview/lltextureinfo.cpp b/indra/newview/lltextureinfo.cpp index 6906f82c1c..59d692b287 100755 --- a/indra/newview/lltextureinfo.cpp +++ b/indra/newview/lltextureinfo.cpp @@ -40,7 +40,7 @@ LLTextureInfo::LLTextureInfo() : mLogTextureDownloadsToViewerLog(false), mLogTextureDownloadsToSimulator(false), mTextureDownloadProtocol("NONE"), - mTextureLogThreshold(LLUnits::Kibibytes::fromValue(100)) + mTextureLogThreshold(LLUnits::Kilobytes::fromValue(100)) { mTextures.clear(); mRecording.start(); @@ -95,7 +95,7 @@ void LLTextureInfo::setRequestStartTime(const LLUUID& id, U64 startTime) { addRequest(id); } - mTextures[id]->mStartTime = startTime; + mTextures[id]->mStartTime = (U64Microseconds)startTime; add(sTextureDownloadsStarted, 1); } @@ -105,7 +105,7 @@ void LLTextureInfo::setRequestSize(const LLUUID& id, U32 size) { addRequest(id); } - mTextures[id]->mSize = size; + mTextures[id]->mSize = (U32Bytes)size; } void LLTextureInfo::setRequestOffset(const LLUUID& id, U32 offset) @@ -194,7 +194,7 @@ LLSD LLTextureInfo::getAverages() LLSD averagedTextureData; S32 averageDownloadRate; U32Milliseconds download_time = mRecording.getSum(sTexureDownloadTime); - if(download_time == 0) + if(download_time == (U32Milliseconds)0) { averageDownloadRate = 0; } diff --git a/indra/newview/lltextureinfodetails.h b/indra/newview/lltextureinfodetails.h index 0ad95eb94e..7cba87e5a8 100755 --- a/indra/newview/lltextureinfodetails.h +++ b/indra/newview/lltextureinfodetails.h @@ -40,10 +40,10 @@ struct LLTextureInfoDetails }; U32Microseconds mStartTime, - mCompleteTime; - U32 mOffset; - U32Bytes mSize; - LLRequestType mType; + mCompleteTime; + U32 mOffset; + U32Bytes mSize; + LLRequestType mType; LLTextureInfoDetails(); }; diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index f39d41c2b8..3974668d09 100755 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -350,7 +350,7 @@ void LLTextureBar::draw() // draw the image size at the end { std::string num_str = llformat("%3dx%3d (%2d) %7d", mImagep->getWidth(), mImagep->getHeight(), - mImagep->getDiscardLevel(), mImagep->hasGLTexture() ? mImagep->getTextureMemory() : 0); + mImagep->getDiscardLevel(), mImagep->hasGLTexture() ? mImagep->getTextureMemory().value() : 0); LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, title_x4, getRect().getHeight(), color, LLFontGL::LEFT, LLFontGL::TOP); } @@ -507,13 +507,13 @@ private: void LLGLTexMemBar::draw() { - S32Mibibytes bound_mem = LLViewerTexture::sBoundTextureMemory; - S32Mibibytes max_bound_mem = LLViewerTexture::sMaxBoundTextureMem; - S32Mibibytes total_mem = LLViewerTexture::sTotalTextureMemory; - S32Mibibytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem; + S32Megabytes bound_mem = LLViewerTexture::sBoundTextureMemory; + S32Megabytes max_bound_mem = LLViewerTexture::sMaxBoundTextureMem; + S32Megabytes total_mem = LLViewerTexture::sTotalTextureMemory; + S32Megabytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem; F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; - F32 cache_usage = (F32)F32Mibibytes(LLAppViewer::getTextureCache()->getUsage()).value() ; - F32 cache_max_usage = (F32)F32Mibibytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ; + F32 cache_usage = (F32)F32Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ; + F32 cache_max_usage = (F32)F32Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ; S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); F32Bytes total_texture_downloaded = gTotalTextureData; @@ -586,8 +586,8 @@ void LLGLTexMemBar::draw() left = 550; - F32Kibibits bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth(); - F32Kibibits max_bandwidth(gSavedSettings.getF32("ThrottleBandwidthKBPS")); + F32Kilobits bandwidth(LLAppViewer::getTextureFetch()->getTextureBandwidth()); + F32Kilobits max_bandwidth(gSavedSettings.getF32("ThrottleBandwidthKBPS")); color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; color[VALPHA] = text_color[VALPHA]; text = llformat("BW:%.0f/%.0f",bandwidth.value(), max_bandwidth.value()); @@ -793,7 +793,7 @@ void LLTextureView::draw() if (mPrintList) { - S32 tex_mem = imagep->hasGLTexture() ? imagep->getTextureMemory() : 0 ; + S32 tex_mem = imagep->hasGLTexture() ? imagep->getTextureMemory().value() : 0 ; LL_INFOS() << imagep->getID() << "\t" << tex_mem << "\t" << imagep->getBoostLevel() diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp index df65a637b7..5fb99ce02f 100755 --- a/indra/newview/llviewerassetstorage.cpp +++ b/indra/newview/llviewerassetstorage.cpp @@ -77,7 +77,7 @@ protected: LLViewerAssetStatsFF::record_response(mType, false, false, (LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime)); - mMetricsStartTime = 0; + mMetricsStartTime = (U32Seconds)0; } } @@ -113,7 +113,7 @@ void LLViewerAssetStorage::storeAssetData( bool is_priority, bool store_local, bool user_waiting, - F64 timeout) + F64Seconds timeout) { LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); LL_DEBUGS("AssetStorage") << "LLViewerAssetStorage::storeAssetData (legacy) " << tid << ":" << LLAssetType::lookup(asset_type) @@ -237,7 +237,7 @@ void LLViewerAssetStorage::storeAssetData( bool temp_file, bool is_priority, bool user_waiting, - F64 timeout) + F64Seconds timeout) { if(filename.empty()) { diff --git a/indra/newview/llviewerassetstorage.h b/indra/newview/llviewerassetstorage.h index ca9b9943fa..6baec647e6 100755 --- a/indra/newview/llviewerassetstorage.h +++ b/indra/newview/llviewerassetstorage.h @@ -51,7 +51,7 @@ public: bool is_priority = false, bool store_local = false, bool user_waiting=FALSE, - F64 timeout=LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT); virtual void storeAssetData( const std::string& filename, @@ -62,7 +62,7 @@ public: bool temp_file = false, bool is_priority = false, bool user_waiting=FALSE, - F64 timeout=LL_ASSET_STORAGE_TIMEOUT); + F64Seconds timeout=LL_ASSET_STORAGE_TIMEOUT); protected: using LLAssetStorage::_queueDataRequest; diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index d0491450dc..95419c7cf3 100755 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -287,7 +287,7 @@ static bool handleMaxPartCountChanged(const LLSD& newvalue) static bool handleVideoMemoryChanged(const LLSD& newvalue) { - gTextureList.updateMaxResidentTexMem(S32Mibibytes(newvalue.asInteger())); + gTextureList.updateMaxResidentTexMem(S32Megabytes(newvalue.asInteger())); return true; } diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index cb5078b988..d2a702049a 100755 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -220,8 +220,8 @@ void display_stats() F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency"); if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq) { - gMemoryAllocated = LLMemory::getCurrentRSS(); - U32Mibibytes memory = gMemoryAllocated; + gMemoryAllocated = (U64Bytes)LLMemory::getCurrentRSS(); + U32Megabytes memory = gMemoryAllocated; LL_INFOS() << llformat("MEMORY: %d MB", memory.value()) << LL_ENDL; LLMemory::logMemoryInfo(TRUE) ; gRecentMemoryTime.reset(); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 6c435bf147..cbc895390c 100755 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -401,11 +401,11 @@ void process_layer_data(LLMessageSystem *mesgsys, void **user_data) LLVLData *vl_datap = new LLVLData(regionp, type, datap, size); if (mesgsys->getReceiveCompressedSize()) { - gVLManager.addLayerData(vl_datap, mesgsys->getReceiveCompressedSize()); + gVLManager.addLayerData(vl_datap, (S32Bytes)mesgsys->getReceiveCompressedSize()); } else { - gVLManager.addLayerData(vl_datap, mesgsys->getReceiveSize()); + gVLManager.addLayerData(vl_datap, (S32Bytes)mesgsys->getReceiveSize()); } } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index b054e519e0..8092eda7b2 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2417,14 +2417,14 @@ void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) if (!mStatic && sVelocityInterpolate && !isSelected()) { // calculate dt from last update - F32 dt_raw = (F32)(time - mLastInterpUpdateSecs); + F32 dt_raw = ((F64Seconds)time - mLastInterpUpdateSecs).value(); F32 dt = mTimeDilation * dt_raw; applyAngularVelocity(dt); if (isAttachment()) { - mLastInterpUpdateSecs = time; + mLastInterpUpdateSecs = (F64Seconds)time; return; } else @@ -2438,8 +2438,8 @@ void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) } -// Move an object due to idle-time viewer side updates by iterpolating motion -void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt) +// Move an object due to idle-time viewer side updates by interpolating motion +void LLViewerObject::interpolateLinearMotion(const F64SecondsImplicit& time, const F32SecondsImplicit& dt) { // linear motion // PHYSICS_TIMESTEP is used below to correct for the fact that the velocity in object @@ -2450,8 +2450,8 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt) // to see if object is selected, instead of explicitly // zeroing it out - F64 time_since_last_update = time - mLastMessageUpdateSecs; - if (time_since_last_update <= 0.0 || dt <= 0.f) + F64Seconds time_since_last_update = time - mLastMessageUpdateSecs; + if (time_since_last_update <= (F64Seconds)0.0 || dt <= (F32Seconds)0.f) { return; } @@ -2459,11 +2459,11 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt) LLVector3 accel = getAcceleration(); LLVector3 vel = getVelocity(); - if (sMaxUpdateInterpolationTime <= 0.0) + if (sMaxUpdateInterpolationTime <= (F64Seconds)0.0) { // Old code path ... unbounded, simple interpolation if (!(accel.isExactlyZero() && vel.isExactlyZero())) { - LLVector3 pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt; + LLVector3 pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt.value(); // region local setPositionRegion(pos + getPositionRegion()); @@ -2477,12 +2477,12 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt) { // Object is moving, and hasn't been too long since we got an update from the server // Calculate predicted position and velocity - LLVector3 new_pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt; + LLVector3 new_pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt.value(); LLVector3 new_v = accel * dt; if (time_since_last_update > sPhaseOutUpdateInterpolationTime && - sPhaseOutUpdateInterpolationTime > 0.0) - { // Haven't seen a viewer update in a while, check to see if the ciruit is still active + sPhaseOutUpdateInterpolationTime > (F64Seconds)0.0) + { // Haven't seen a viewer update in a while, check to see if the circuit is still active if (mRegionp) { // The simulator will NOT send updates if the object continues normally on the path // predicted by the velocity and the acceleration (often gravity) sent to the viewer @@ -2498,7 +2498,7 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt) (time_since_last_packet > sPhaseOutUpdateInterpolationTime)) { // Start to reduce motion interpolation since we haven't seen a server update in a while - F64 time_since_last_interpolation = time - mLastInterpUpdateSecs; + F64Seconds time_since_last_interpolation = time - mLastInterpUpdateSecs; F64 phase_out = 1.0; if (time_since_last_update > sMaxUpdateInterpolationTime) { // Past the time limit, so stop the object diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 3943709049..24dff45ae8 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -580,7 +580,7 @@ private: U32 checkMediaURL(const std::string &media_url); // Motion prediction between updates - void interpolateLinearMotion(const F64 & time, const F32 & dt); + void interpolateLinearMotion(const F64SecondsImplicit & time, const F32SecondsImplicit & dt); static void initObjectDataMap(); @@ -707,8 +707,8 @@ protected: child_list_t mChildList; - F64 mLastInterpUpdateSecs; // Last update for purposes of interpolation - F64 mLastMessageUpdateSecs; // Last update from a message from the simulator + F64Seconds mLastInterpUpdateSecs; // Last update for purposes of interpolation + F64Seconds mLastMessageUpdateSecs; // Last update from a message from the simulator TPACKETID mLatestRecvPacketID; // Latest time stamp on message from simulator // extra data sent from the sim...currently only used for tree species info @@ -781,7 +781,7 @@ protected: mutable LLVector3 mPositionAgent; static void setPhaseOutUpdateInterpolationTime(F32 value) { sPhaseOutUpdateInterpolationTime = (F64Seconds) value; } - static void setMaxUpdateInterpolationTime(F32 value) { sMaxUpdateInterpolationTime = (F64) value; } + static void setMaxUpdateInterpolationTime(F32 value) { sMaxUpdateInterpolationTime = (F64Seconds) value; } static void setVelocityInterpolate(BOOL value) { sVelocityInterpolate = value; } static void setPingInterpolate(BOOL value) { sPingInterpolate = value; } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 24c56df8db..61a0ed098a 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -428,14 +428,14 @@ void LLViewerRegion::initStats() { mImpl->mLastNetUpdate.reset(); mPacketsIn = 0; - mBitsIn = 0; - mLastBitsIn = 0; + mBitsIn = (U32Bits)0; + mLastBitsIn = (U32Bits)0; mLastPacketsIn = 0; mPacketsOut = 0; mLastPacketsOut = 0; mPacketsLost = 0; mLastPacketsLost = 0; - mPingDelay = 0; + mPingDelay = (U32Seconds)0; mAlive = false; // can become false if circuit disconnects } diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index bb2c13df33..f300983f19 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -95,7 +95,7 @@ LLTrace::CountStatHandle > LLTrace::EventStatHandle > TRIANGLES_DRAWN_PER_FRAME("trianglesdrawnperframestat"); -LLTrace::CountStatHandle +LLTrace::CountStatHandle ACTIVE_MESSAGE_DATA_RECEIVED("activemessagedatareceived", "Message system data received on all active regions"), LAYERS_NETWORK_DATA_RECEIVED("layersdatareceived", "Network data received for layer data (terrain)"), OBJECT_NETWORK_DATA_RECEIVED("objectdatareceived", "Network data received for objects"), @@ -156,7 +156,7 @@ LLTrace::SampleStatHandle GL_TEX_MEM("gltexmemstat"), GL_BOUND_MEM("glboundmemstat"), RAW_MEM("rawmemstat"), FORMATTED_MEM("formattedmemstat"); -LLTrace::SampleStatHandle DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"), +LLTrace::SampleStatHandle DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"), MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"); @@ -221,7 +221,7 @@ void LLViewerStats::resetStats() void LLViewerStats::updateFrameStats(const F64Seconds time_diff) { - if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0) + if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > F32Percent(5.0)) { add(LLStatViewer::LOSS_5_PERCENT_TIME, time_diff); } @@ -239,20 +239,20 @@ void LLViewerStats::updateFrameStats(const F64Seconds time_diff) add(LLStatViewer::SIM_PHYSICS_20_FPS_TIME, time_diff); } - if (time_diff >= 0.5) + if (time_diff >= (F64Seconds)0.5) { record(LLStatViewer::FPS_2_TIME, time_diff); } - if (time_diff >= 0.125) + if (time_diff >= (F64Seconds)0.125) { record(LLStatViewer::FPS_8_TIME, time_diff); } - if (time_diff >= 0.1) + if (time_diff >= (F64Seconds)0.1) { record(LLStatViewer::FPS_10_TIME, time_diff); } - if (gFrameCount && mLastTimeDiff > 0.0) + if (gFrameCount && mLastTimeDiff > (F64Seconds)0.0) { // new "stutter" meter add(LLStatViewer::FRAMETIME_DOUBLED, time_diff >= 2.0 * mLastTimeDiff ? 1 : 0); @@ -260,7 +260,7 @@ void LLViewerStats::updateFrameStats(const F64Seconds time_diff) // old stats that were never really used sample(LLStatViewer::FRAMETIME_JITTER, F64Milliseconds (mLastTimeDiff - time_diff)); - F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount; + F32Seconds average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount; sample(LLStatViewer::FRAMETIME_SLEW, F64Milliseconds (average_frametime - time_diff)); F32 max_bandwidth = gViewerThrottle.getMaxBandwidth(); @@ -359,7 +359,7 @@ void update_statistics() if (cdp) { sample(LLStatViewer::SIM_PING, F64Milliseconds (cdp->getPingDelay())); - gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay().value())) / ((F32)gSimPingCount + 1); + gAvgSimPing = ((gAvgSimPing * gSimPingCount) + cdp->getPingDelay()) / (gSimPingCount + 1); gSimPingCount++; } else @@ -373,8 +373,8 @@ void update_statistics() } add(LLStatViewer::FPS, 1); - F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits()); - add(LLStatViewer::LAYERS_NETWORK_DATA_RECEIVED, F64Bits(layer_bits)); + F64Bits layer_bits = gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits(); + add(LLStatViewer::LAYERS_NETWORK_DATA_RECEIVED, layer_bits); add(LLStatViewer::OBJECT_NETWORK_DATA_RECEIVED, gObjectData); sample(LLStatViewer::PENDING_VFS_OPERATIONS, LLVFile::getVFSThread()->getPending()); add(LLStatViewer::ASSET_UDP_DATA_RECEIVED, F64Bits(gTransferManager.getTransferBitsIn(LLTCT_ASSET))); @@ -395,7 +395,7 @@ void update_statistics() // Reset all of these values. gVLManager.resetBitCounts(); - gObjectData = 0; + gObjectData = (U32Bytes)0; // gDecodedBits = 0; // Only update texture stats periodically so that they are less noisy @@ -553,9 +553,9 @@ void send_stats() LLSD &download = body["downloads"]; - download["world_kbytes"] = F64Kibibytes(gTotalWorldData).value(); - download["object_kbytes"] = F64Kibibytes(gTotalObjectData).value(); - download["texture_kbytes"] = F64Kibibytes(gTotalTextureData).value(); + download["world_kbytes"] = F64Kilobytes(gTotalWorldData).value(); + download["object_kbytes"] = F64Kilobytes(gTotalObjectData).value(); + download["texture_kbytes"] = F64Kilobytes(gTotalTextureData).value(); download["mesh_kbytes"] = LLMeshRepository::sBytesReceived/1024.0; LLSD &in = body["stats"]["net"]["in"]; diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h index 42c56e8835..0d959ed034 100755 --- a/indra/newview/llviewerstats.h +++ b/indra/newview/llviewerstats.h @@ -142,7 +142,7 @@ extern LLTrace::CountStatHandle<> FPS, extern LLTrace::CountStatHandle > TRIANGLES_DRAWN; -extern LLTrace::CountStatHandle ACTIVE_MESSAGE_DATA_RECEIVED, +extern LLTrace::CountStatHandle ACTIVE_MESSAGE_DATA_RECEIVED, LAYERS_NETWORK_DATA_RECEIVED, OBJECT_NETWORK_DATA_RECEIVED, ASSET_UDP_DATA_RECEIVED, @@ -196,7 +196,7 @@ extern LLTrace::SampleStatHandle GL_TEX_MEM, GL_BOUND_MEM, RAW_MEM, FORMATTED_MEM; -extern LLTrace::SampleStatHandle DELTA_BANDWIDTH, +extern LLTrace::SampleStatHandle DELTA_BANDWIDTH, MAX_BANDWIDTH; extern SimMeasurement SIM_FRAME_TIME, SIM_NET_TIME, diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 4290d338c1..6bda1499d0 100755 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -63,8 +63,8 @@ /////////////////////////////////////////////////////////////////////////////// // extern -const S32Mibibytes gMinVideoRam(32); -const S32Mibibytes gMaxVideoRam(512); +const S32Megabytes gMinVideoRam(32); +const S32Megabytes gMaxVideoRam(512); // statics @@ -76,8 +76,8 @@ LLPointer LLViewerFetchedTexture::sWhiteImagep = NULL; LLPointer LLViewerFetchedTexture::sDefaultImagep = NULL; LLPointer LLViewerFetchedTexture::sSmokeImagep = NULL; LLPointer LLViewerFetchedTexture::sFlatNormalImagep = NULL; -LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap ; -LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL ; +LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap; +LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL; const std::string sTesterName("TextureTester"); S32 LLViewerTexture::sImageCount = 0; @@ -88,19 +88,19 @@ F32 LLViewerTexture::sDesiredDiscardBias = 0.f; F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; S32Bytes LLViewerTexture::sBoundTextureMemory; S32Bytes LLViewerTexture::sTotalTextureMemory; -S32Mibibytes LLViewerTexture::sMaxBoundTextureMem; -S32Mibibytes LLViewerTexture::sMaxTotalTextureMem; +S32Megabytes LLViewerTexture::sMaxBoundTextureMem; +S32Megabytes LLViewerTexture::sMaxTotalTextureMem; S32Bytes LLViewerTexture::sMaxDesiredTextureMem; -S8 LLViewerTexture::sCameraMovingDiscardBias = 0 ; -F32 LLViewerTexture::sCameraMovingBias = 0.0f ; -S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size -const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64 ; -const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez ; -const S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128 ; -S32 LLViewerTexture::sMinLargeImageSize = 65536 ; //256 * 256. -S32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA ; -BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE ; -F32 LLViewerTexture::sCurrentTime = 0.0f ; +S8 LLViewerTexture::sCameraMovingDiscardBias = 0; +F32 LLViewerTexture::sCameraMovingBias = 0.0f; +S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size +const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64; +const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez; +const S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128; +S32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256. +S32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA; +BOOL LLViewerTexture::sFreezeImageScalingDown = FALSE; +F32 LLViewerTexture::sCurrentTime = 0.0f; F32 LLViewerTexture::sTexelPixelRatio = 1.0f; LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF; @@ -142,7 +142,7 @@ void LLLoadedCallbackEntry::removeTexture(LLViewerFetchedTexture* tex) { if(mSourceCallbackList) { - mSourceCallbackList->erase(tex->getID()) ; + mSourceCallbackList->erase(tex->getID()); } } @@ -155,33 +155,33 @@ void LLLoadedCallbackEntry::cleanUpCallbackList(LLLoadedCallbackEntry::source_ca for(LLLoadedCallbackEntry::source_callback_list_t::iterator iter = callback_list->begin(); iter != callback_list->end(); ++iter) { - LLViewerFetchedTexture* tex = gTextureList.findImage(*iter) ; + LLViewerFetchedTexture* tex = gTextureList.findImage(*iter); if(tex) { - tex->deleteCallbackEntry(callback_list) ; + tex->deleteCallbackEntry(callback_list); } } - callback_list->clear() ; + callback_list->clear(); } } LLViewerMediaTexture* LLViewerTextureManager::createMediaTexture(const LLUUID &media_id, BOOL usemipmaps, LLImageGL* gl_image) { - return new LLViewerMediaTexture(media_id, usemipmaps, gl_image) ; + return new LLViewerMediaTexture(media_id, usemipmaps, gl_image); } LLViewerTexture* LLViewerTextureManager::findTexture(const LLUUID& id) { - LLViewerTexture* tex ; + LLViewerTexture* tex; //search fetched texture list - tex = gTextureList.findImage(id) ; + tex = gTextureList.findImage(id); //search media texture list if(!tex) { - tex = LLViewerTextureManager::findMediaTexture(id) ; + tex = LLViewerTextureManager::findMediaTexture(id); } - return tex ; + return tex; } LLViewerFetchedTexture* LLViewerTextureManager::findFetchedTexture(const LLUUID& id) @@ -191,78 +191,78 @@ LLViewerFetchedTexture* LLViewerTextureManager::findFetchedTexture(const LLUUID LLViewerMediaTexture* LLViewerTextureManager::findMediaTexture(const LLUUID &media_id) { - return LLViewerMediaTexture::findMediaTexture(media_id) ; + return LLViewerMediaTexture::findMediaTexture(media_id); } LLViewerMediaTexture* LLViewerTextureManager::getMediaTexture(const LLUUID& id, BOOL usemipmaps, LLImageGL* gl_image) { - LLViewerMediaTexture* tex = LLViewerMediaTexture::findMediaTexture(id) ; + LLViewerMediaTexture* tex = LLViewerMediaTexture::findMediaTexture(id); if(!tex) { - tex = LLViewerTextureManager::createMediaTexture(id, usemipmaps, gl_image) ; + tex = LLViewerTextureManager::createMediaTexture(id, usemipmaps, gl_image); } - tex->initVirtualSize() ; + tex->initVirtualSize(); - return tex ; + return tex; } LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLTexture* tex, BOOL report_error) { if(!tex) { - return NULL ; + return NULL; } - S8 type = tex->getType() ; + S8 type = tex->getType(); if(type == LLViewerTexture::FETCHED_TEXTURE || type == LLViewerTexture::LOD_TEXTURE) { - return static_cast(tex) ; + return static_cast(tex); } if(report_error) { - LL_ERRS() << "not a fetched texture type: " << type << LL_ENDL ; + LL_ERRS() << "not a fetched texture type: " << type << LL_ENDL; } - return NULL ; + return NULL; } LLPointer LLViewerTextureManager::getLocalTexture(BOOL usemipmaps, BOOL generate_gl_tex) { - LLPointer tex = new LLViewerTexture(usemipmaps) ; + LLPointer tex = new LLViewerTexture(usemipmaps); if(generate_gl_tex) { - tex->generateGLTexture() ; - tex->setCategory(LLGLTexture::LOCAL) ; + tex->generateGLTexture(); + tex->setCategory(LLGLTexture::LOCAL); } - return tex ; + return tex; } LLPointer LLViewerTextureManager::getLocalTexture(const LLUUID& id, BOOL usemipmaps, BOOL generate_gl_tex) { - LLPointer tex = new LLViewerTexture(id, usemipmaps) ; + LLPointer tex = new LLViewerTexture(id, usemipmaps); if(generate_gl_tex) { - tex->generateGLTexture() ; - tex->setCategory(LLGLTexture::LOCAL) ; + tex->generateGLTexture(); + tex->setCategory(LLGLTexture::LOCAL); } - return tex ; + return tex; } LLPointer LLViewerTextureManager::getLocalTexture(const LLImageRaw* raw, BOOL usemipmaps) { - LLPointer tex = new LLViewerTexture(raw, usemipmaps) ; - tex->setCategory(LLGLTexture::LOCAL) ; - return tex ; + LLPointer tex = new LLViewerTexture(raw, usemipmaps); + tex->setCategory(LLGLTexture::LOCAL); + return tex; } LLPointer LLViewerTextureManager::getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex) { - LLPointer tex = new LLViewerTexture(width, height, components, usemipmaps) ; + LLPointer tex = new LLViewerTexture(width, height, components, usemipmaps); if(generate_gl_tex) { - tex->generateGLTexture() ; - tex->setCategory(LLGLTexture::LOCAL) ; + tex->generateGLTexture(); + tex->setCategory(LLGLTexture::LOCAL); } - return tex ; + return tex; } LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture( @@ -275,7 +275,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture( LLGLenum primary_format, LLHost request_from_host) { - return gTextureList.getImage(image_id, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, request_from_host) ; + return gTextureList.getImage(image_id, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, request_from_host); } LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromFile( @@ -288,7 +288,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromFile( LLGLenum primary_format, const LLUUID& force_id) { - return gTextureList.getImageFromFile(filename, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id) ; + return gTextureList.getImageFromFile(filename, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id); } //static @@ -302,12 +302,12 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const s const LLUUID& force_id ) { - return gTextureList.getImageFromUrl(url, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id) ; + return gTextureList.getImageFromUrl(url, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id); } LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromHost(const LLUUID& image_id, FTType f_type, LLHost host) { - return gTextureList.getImageFromHost(image_id, f_type, host) ; + return gTextureList.getImageFromHost(image_id, f_type, host); } // Create a bridge to the viewer texture manager. @@ -335,15 +335,15 @@ void LLViewerTextureManager::init() { LLPointer raw = new LLImageRaw(1,1,3); raw->clear(0x77, 0x77, 0x77, 0xFF); - LLViewerTexture::sNullImagep = LLViewerTextureManager::getLocalTexture(raw.get(), TRUE) ; + LLViewerTexture::sNullImagep = LLViewerTextureManager::getLocalTexture(raw.get(), TRUE); } const S32 dim = 128; LLPointer image_raw = new LLImageRaw(dim,dim,3); U8* data = image_raw->getData(); - memset(data, 0, dim * dim * 3) ; - LLViewerTexture::sBlackImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE) ; + memset(data, 0, dim * dim * 3); + LLViewerTexture::sBlackImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE); #if 1 LLPointer imagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT); @@ -372,16 +372,16 @@ void LLViewerTextureManager::init() } imagep->createGLTexture(0, image_raw); //cache the raw image - imagep->setCachedRawImage(0, image_raw) ; + imagep->setCachedRawImage(0, image_raw); image_raw = NULL; #else LLViewerFetchedTexture::sDefaultImagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, TRUE, LLGLTexture::BOOST_UI); #endif LLViewerFetchedTexture::sDefaultImagep->dontDiscard(); - LLViewerFetchedTexture::sDefaultImagep->setCategory(LLGLTexture::OTHER) ; + LLViewerFetchedTexture::sDefaultImagep->setCategory(LLGLTexture::OTHER); LLViewerFetchedTexture::sSmokeImagep = LLViewerTextureManager::getFetchedTexture(IMG_SMOKE, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI); - LLViewerFetchedTexture::sSmokeImagep->setNoDelete() ; + LLViewerFetchedTexture::sSmokeImagep->setNoDelete(); image_raw = new LLImageRaw(32,32,3); data = image_raw->getData(); @@ -398,14 +398,14 @@ void LLViewerTextureManager::init() LLViewerTexture::sCheckerBoardImagep = LLViewerTextureManager::getLocalTexture(image_raw.get(), TRUE); - LLViewerTexture::initClass() ; + LLViewerTexture::initClass(); // Create a texture manager bridge. gTextureManagerBridgep = new LLViewerTextureManagerBridge; if (LLMetricPerformanceTesterBasic::isMetricLogRequested(sTesterName) && !LLMetricPerformanceTesterBasic::getTester(sTesterName)) { - sTesterp = new LLTexturePipelineTester() ; + sTesterp = new LLTexturePipelineTester(); if (!sTesterp->isValid()) { delete sTesterp; @@ -419,7 +419,7 @@ void LLViewerTextureManager::cleanup() stop_glerror(); delete gTextureManagerBridgep; - LLImageGL::sDefaultGLTexture = NULL ; + LLImageGL::sDefaultGLTexture = NULL; LLViewerTexture::sNullImagep = NULL; LLViewerTexture::sBlackImagep = NULL; LLViewerTexture::sCheckerBoardImagep = NULL; @@ -429,7 +429,7 @@ void LLViewerTextureManager::cleanup() LLViewerFetchedTexture::sWhiteImagep = NULL; LLViewerFetchedTexture::sFlatNormalImagep = NULL; - LLViewerMediaTexture::cleanUpClass() ; + LLViewerMediaTexture::cleanUpClass(); } //---------------------------------------------------------------------------------------------- @@ -439,7 +439,7 @@ void LLViewerTextureManager::cleanup() // static void LLViewerTexture::initClass() { - LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture() ; + LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture(); if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled")) { @@ -460,37 +460,37 @@ static LLFastTimer::DeclareTimer FTM_TEXTURE_MEMORY_CHECK("Memory Check"); //static bool LLViewerTexture::isMemoryForTextureLow() { - const F32 WAIT_TIME = 1.0f ; //second - static LLFrameTimer timer ; + const F32 WAIT_TIME = 1.0f; //second + static LLFrameTimer timer; if(timer.getElapsedTimeF32() < WAIT_TIME) //call this once per second. { return false; } - timer.reset() ; + timer.reset(); LLFastTimer t(FTM_TEXTURE_MEMORY_CHECK); - const S32 MIN_FREE_TEXTURE_MEMORY = 5 ; //MB - const S32 MIN_FREE_MAIN_MEMORy = 100 ; //MB + const S32Megabytes MIN_FREE_TEXTURE_MEMORY(5); //MB + const S32Megabytes MIN_FREE_MAIN_MEMORY(100); //MB - bool low_mem = false ; + bool low_mem = false; if (gGLManager.mHasATIMemInfo) { S32 meminfo[4]; glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, meminfo); - if(meminfo[0] / 1024 < MIN_FREE_TEXTURE_MEMORY) + if((S32Megabytes)meminfo[0] < MIN_FREE_TEXTURE_MEMORY) { - low_mem = true ; + low_mem = true; } if(!low_mem) //check main memory, only works for windows. { - LLMemory::updateMemoryInfo() ; - if(LLMemory::getAvailableMemKB() / 1024 < MIN_FREE_MAIN_MEMORy) + LLMemory::updateMemoryInfo(); + if(LLMemory::getAvailableMemKB() < MIN_FREE_TEXTURE_MEMORY) { - low_mem = true ; + low_mem = true; } } } @@ -502,12 +502,12 @@ bool LLViewerTexture::isMemoryForTextureLow() if(free_memory / 1024 < MIN_FREE_TEXTURE_MEMORY) { - low_mem = true ; + low_mem = true; } } #endif - return low_mem ; + return low_mem; } static LLFastTimer::DeclareTimer FTM_TEXTURE_UPDATE_MEDIA("Media"); @@ -516,31 +516,31 @@ static LLFastTimer::DeclareTimer FTM_TEXTURE_UPDATE_TEST("Test"); //static void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity) { - sCurrentTime = gFrameTimeSeconds ; + sCurrentTime = gFrameTimeSeconds; LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { LLFastTimer t(FTM_TEXTURE_UPDATE_TEST); - tester->update() ; + tester->update(); } { LLFastTimer t(FTM_TEXTURE_UPDATE_MEDIA); - LLViewerMediaTexture::updateClass() ; + LLViewerMediaTexture::updateClass(); } sBoundTextureMemory = LLImageGL::sBoundTextureMemory; sTotalTextureMemory = LLImageGL::sGlobalTextureMemory; sMaxBoundTextureMem = gTextureList.getMaxResidentTexMem(); sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem(); - sMaxDesiredTextureMem = sMaxTotalTextureMem ; //in Bytes, by default and when total used texture memory is small. + sMaxDesiredTextureMem = sMaxTotalTextureMem; //in Bytes, by default and when total used texture memory is small. if (sBoundTextureMemory >= sMaxBoundTextureMem || sTotalTextureMemory >= sMaxTotalTextureMem) { //when texture memory overflows, lower down the threshold to release the textures more aggressively. - sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, S32Bytes(gMaxVideoRam)); + sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, F32Bytes(gMaxVideoRam)); // If we are using more texture memory than we should, // scale up the desired discard level @@ -569,13 +569,13 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity } sDesiredDiscardBias = llclamp(sDesiredDiscardBias, desired_discard_bias_min, desired_discard_bias_max); - F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed() ; + F32 camera_moving_speed = LLViewerCamera::getInstance()->getAverageSpeed(); F32 camera_angular_speed = LLViewerCamera::getInstance()->getAverageAngularSpeed(); sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1); sCameraMovingDiscardBias = (S8)(sCameraMovingBias); LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < 0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale) && - (sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale) ; + (sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale); } //end of static functions @@ -631,31 +631,31 @@ void LLViewerTexture::init(bool firstinit) mSelectedTime = 0.f; mMaxVirtualSize = 0.f; mMaxVirtualSizeResetInterval = 1; - mMaxVirtualSizeResetCounter = mMaxVirtualSizeResetInterval ; - mAdditionalDecodePriority = 0.f ; - mParcelMedia = NULL ; + mMaxVirtualSizeResetCounter = mMaxVirtualSizeResetInterval; + mAdditionalDecodePriority = 0.f; + mParcelMedia = NULL; mNumVolumes = 0; - mFaceList[LLRender::DIFFUSE_MAP].clear() ; - mFaceList[LLRender::NORMAL_MAP].clear() ; - mFaceList[LLRender::SPECULAR_MAP].clear() ; + mFaceList[LLRender::DIFFUSE_MAP].clear(); + mFaceList[LLRender::NORMAL_MAP].clear(); + mFaceList[LLRender::SPECULAR_MAP].clear(); mNumFaces[LLRender::DIFFUSE_MAP] = mNumFaces[LLRender::NORMAL_MAP] = - mNumFaces[LLRender::SPECULAR_MAP] = 0 ; + mNumFaces[LLRender::SPECULAR_MAP] = 0; mVolumeList.clear(); } //virtual S8 LLViewerTexture::getType() const { - return LLViewerTexture::LOCAL_TEXTURE ; + return LLViewerTexture::LOCAL_TEXTURE; } void LLViewerTexture::cleanup() { - mFaceList[LLRender::DIFFUSE_MAP].clear() ; - mFaceList[LLRender::NORMAL_MAP].clear() ; - mFaceList[LLRender::SPECULAR_MAP].clear() ; + mFaceList[LLRender::DIFFUSE_MAP].clear(); + mFaceList[LLRender::NORMAL_MAP].clear(); + mFaceList[LLRender::SPECULAR_MAP].clear(); mVolumeList.clear(); } @@ -673,11 +673,11 @@ void LLViewerTexture::setBoostLevel(S32 level) { if(mBoostLevel != level) { - mBoostLevel = level ; + mBoostLevel = level; if(mBoostLevel != LLViewerTexture::BOOST_NONE && mBoostLevel != LLViewerTexture::BOOST_SELECTED) { - setNoDelete() ; + setNoDelete(); } } @@ -732,12 +732,12 @@ bool LLViewerTexture::bindDefaultImage(S32 stage) stop_glerror(); //check if there is cached raw image and switch to it if possible - switchToCachedImage() ; + switchToCachedImage(); LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { - tester->updateGrayTextureBinding() ; + tester->updateGrayTextureBinding(); } return res; } @@ -757,17 +757,17 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co { if(needs_gltexture) { - mNeedsGLTexture = TRUE ; + mNeedsGLTexture = TRUE; } virtual_size *= sTexelPixelRatio; if(!mMaxVirtualSizeResetCounter) { //flag to reset the values because the old values are used. - resetMaxVirtualSizeResetCounter() ; + resetMaxVirtualSizeResetCounter(); mMaxVirtualSize = virtual_size; - mAdditionalDecodePriority = 0.f ; - mNeedsGLTexture = needs_gltexture ; + mAdditionalDecodePriority = 0.f; + mNeedsGLTexture = needs_gltexture; } else if (virtual_size > mMaxVirtualSize) { @@ -777,15 +777,15 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co void LLViewerTexture::resetTextureStats() { - mMaxVirtualSize = 0.0f ; - mAdditionalDecodePriority = 0.f ; - mMaxVirtualSizeResetCounter = 0 ; + mMaxVirtualSize = 0.0f; + mAdditionalDecodePriority = 0.f; + mMaxVirtualSizeResetCounter = 0; } //virtual F32 LLViewerTexture::getMaxVirtualSize() { - return mMaxVirtualSize ; + return mMaxVirtualSize; } //virtual @@ -801,12 +801,12 @@ void LLViewerTexture::addFace(U32 ch, LLFace* facep) if(mNumFaces[ch] >= mFaceList[ch].size()) { - mFaceList[ch].resize(2 * mNumFaces[ch] + 1) ; + mFaceList[ch].resize(2 * mNumFaces[ch] + 1); } - mFaceList[ch][mNumFaces[ch]] = facep ; - facep->setIndexInTex(ch, mNumFaces[ch]) ; - mNumFaces[ch]++ ; - mLastFaceListUpdateTimer.reset() ; + mFaceList[ch][mNumFaces[ch]] = facep; + facep->setIndexInTex(ch, mNumFaces[ch]); + mNumFaces[ch]++; + mLastFaceListUpdateTimer.reset(); } //virtual @@ -816,18 +816,18 @@ void LLViewerTexture::removeFace(U32 ch, LLFace* facep) if(mNumFaces[ch] > 1) { - S32 index = facep->getIndexInTex(ch) ; + S32 index = facep->getIndexInTex(ch); llassert(index < mFaceList[ch].size()); llassert(index < mNumFaces[ch]); - mFaceList[ch][index] = mFaceList[ch][--mNumFaces[ch]] ; - mFaceList[ch][index]->setIndexInTex(ch, index) ; + mFaceList[ch][index] = mFaceList[ch][--mNumFaces[ch]]; + mFaceList[ch][index]->setIndexInTex(ch, index); } else { - mFaceList[ch].clear() ; - mNumFaces[ch] = 0 ; + mFaceList[ch].clear(); + mNumFaces[ch] = 0; } - mLastFaceListUpdateTimer.reset() ; + mLastFaceListUpdateTimer.reset(); } S32 LLViewerTexture::getTotalNumFaces() const @@ -854,12 +854,12 @@ void LLViewerTexture::addVolume(LLVOVolume* volumep) { if( mNumVolumes >= mVolumeList.size()) { - mVolumeList.resize(2 * mNumVolumes + 1) ; + mVolumeList.resize(2 * mNumVolumes + 1); } - mVolumeList[mNumVolumes] = volumep ; - volumep->setIndexInTex(mNumVolumes) ; - mNumVolumes++ ; - mLastVolumeListUpdateTimer.reset() ; + mVolumeList[mNumVolumes] = volumep; + volumep->setIndexInTex(mNumVolumes); + mNumVolumes++; + mLastVolumeListUpdateTimer.reset(); } //virtual @@ -867,64 +867,64 @@ void LLViewerTexture::removeVolume(LLVOVolume* volumep) { if(mNumVolumes > 1) { - S32 index = volumep->getIndexInTex() ; + S32 index = volumep->getIndexInTex(); llassert(index < mVolumeList.size()); llassert(index < mNumVolumes); - mVolumeList[index] = mVolumeList[--mNumVolumes] ; - mVolumeList[index]->setIndexInTex(index) ; + mVolumeList[index] = mVolumeList[--mNumVolumes]; + mVolumeList[index]->setIndexInTex(index); } else { - mVolumeList.clear() ; - mNumVolumes = 0 ; + mVolumeList.clear(); + mNumVolumes = 0; } - mLastVolumeListUpdateTimer.reset() ; + mLastVolumeListUpdateTimer.reset(); } S32 LLViewerTexture::getNumVolumes() const { - return mNumVolumes ; + return mNumVolumes; } void LLViewerTexture::reorganizeFaceList() { static const F32 MAX_WAIT_TIME = 20.f; // seconds - static const U32 MAX_EXTRA_BUFFER_SIZE = 4 ; + static const U32 MAX_EXTRA_BUFFER_SIZE = 4; if(mLastFaceListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME) { - return ; + return; } for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) { if(mNumFaces[i] + MAX_EXTRA_BUFFER_SIZE > mFaceList[i].size()) { - return ; + return; } mFaceList[i].erase(mFaceList[i].begin() + mNumFaces[i], mFaceList[i].end()); } - mLastFaceListUpdateTimer.reset() ; + mLastFaceListUpdateTimer.reset(); } void LLViewerTexture::reorganizeVolumeList() { static const F32 MAX_WAIT_TIME = 20.f; // seconds - static const U32 MAX_EXTRA_BUFFER_SIZE = 4 ; + static const U32 MAX_EXTRA_BUFFER_SIZE = 4; if(mNumVolumes + MAX_EXTRA_BUFFER_SIZE > mVolumeList.size()) { - return ; + return; } if(mLastVolumeListUpdateTimer.getElapsedTimeF32() < MAX_WAIT_TIME) { - return ; + return; } - mLastVolumeListUpdateTimer.reset() ; + mLastVolumeListUpdateTimer.reset(); mVolumeList.erase(mVolumeList.begin() + mNumVolumes, mVolumeList.end()); } @@ -942,7 +942,7 @@ void LLViewerTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) BOOL LLViewerTexture::isLargeImage() { - return (S32)mTexelsPerImage > LLViewerTexture::sMinLargeImageSize ; + return (S32)mTexelsPerImage > LLViewerTexture::sMinLargeImageSize; } //virtual @@ -951,7 +951,7 @@ void LLViewerTexture::updateBindStatsForTester() LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { - tester->updateTextureBindingStats(this) ; + tester->updateTextureBindingStats(this); } } @@ -967,19 +967,19 @@ LLViewerFetchedTexture::LLViewerFetchedTexture(const LLUUID& id, FTType f_type, : LLViewerTexture(id, usemipmaps), mTargetHost(host) { - init(TRUE) ; + init(TRUE); mFTType = f_type; if (mFTType == FTT_HOST_BAKE) { mCanUseHTTP = false; } - generateGLTexture() ; + generateGLTexture(); } LLViewerFetchedTexture::LLViewerFetchedTexture(const LLImageRaw* raw, FTType f_type, BOOL usemipmaps) : LLViewerTexture(raw, usemipmaps) { - init(TRUE) ; + init(TRUE); mFTType = f_type; } @@ -987,9 +987,9 @@ LLViewerFetchedTexture::LLViewerFetchedTexture(const std::string& url, FTType f_ : LLViewerTexture(id, usemipmaps), mUrl(url) { - init(TRUE) ; + init(TRUE); mFTType = f_type; - generateGLTexture() ; + generateGLTexture(); } void LLViewerFetchedTexture::init(bool firstinit) @@ -1000,7 +1000,7 @@ void LLViewerFetchedTexture::init(bool firstinit) mRequestedDiscardLevel = -1; mRequestedDownloadPriority = 0.f; mFullyLoaded = FALSE; - mCanUseHTTP = true ; + mCanUseHTTP = true; mDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; mMinDesiredDiscardLevel = MAX_DISCARD_LEVEL + 1; @@ -1008,7 +1008,7 @@ void LLViewerFetchedTexture::init(bool firstinit) mKnownDrawWidth = 0; mKnownDrawHeight = 0; - mKnownDrawSizeChanged = FALSE ; + mKnownDrawSizeChanged = FALSE; if (firstinit) { @@ -1021,7 +1021,7 @@ void LLViewerFetchedTexture::init(bool firstinit) mIsMissingAsset = FALSE; mLoadedCallbackDesiredDiscardLevel = S8_MAX; - mPauseLoadedCallBacks = FALSE ; + mPauseLoadedCallBacks = FALSE; mNeedsCreateTexture = FALSE; @@ -1036,21 +1036,21 @@ void LLViewerFetchedTexture::init(bool firstinit) mDownloadProgress = 0.f; mFetchDeltaTime = 999999.f; mRequestDeltaTime = 0.f; - mForSculpt = FALSE ; - mIsFetched = FALSE ; + mForSculpt = FALSE; + mIsFetched = FALSE; mInFastCacheList = FALSE; - mCachedRawImage = NULL ; - mCachedRawDiscardLevel = -1 ; - mCachedRawImageReady = FALSE ; - - mSavedRawImage = NULL ; - mForceToSaveRawImage = FALSE ; - mSaveRawImage = FALSE ; - mSavedRawDiscardLevel = -1 ; - mDesiredSavedRawDiscardLevel = -1 ; - mLastReferencedSavedRawImageTime = 0.0f ; - mKeptSavedRawImageTime = 0.f ; + mCachedRawImage = NULL; + mCachedRawDiscardLevel = -1; + mCachedRawImageReady = FALSE; + + mSavedRawImage = NULL; + mForceToSaveRawImage = FALSE; + mSaveRawImage = FALSE; + mSavedRawDiscardLevel = -1; + mDesiredSavedRawDiscardLevel = -1; + mLastReferencedSavedRawImageTime = 0.0f; + mKeptSavedRawImageTime = 0.f; mLastCallBackActiveTime = 0.f; mInDebug = FALSE; @@ -1073,7 +1073,7 @@ LLViewerFetchedTexture::~LLViewerFetchedTexture() //virtual S8 LLViewerFetchedTexture::getType() const { - return LLViewerTexture::FETCHED_TEXTURE ; + return LLViewerTexture::FETCHED_TEXTURE; } FTType LLViewerFetchedTexture::getFTType() const @@ -1090,7 +1090,7 @@ void LLViewerFetchedTexture::cleanup() // We never finished loading the image. Indicate failure. // Note: this allows mLoadedCallbackUserData to be cleaned up. entryp->mCallback( FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData ); - entryp->removeTexture(this) ; + entryp->removeTexture(this); delete entryp; } mLoadedCallbackList.clear(); @@ -1098,10 +1098,10 @@ void LLViewerFetchedTexture::cleanup() // Clean up image data destroyRawImage(); - mCachedRawImage = NULL ; - mCachedRawDiscardLevel = -1 ; - mCachedRawImageReady = FALSE ; - mSavedRawImage = NULL ; + mCachedRawImage = NULL; + mCachedRawDiscardLevel = -1; + mCachedRawImageReady = FALSE; + mSavedRawImage = NULL; mSavedRawDiscardLevel = -1; } @@ -1114,7 +1114,7 @@ void LLViewerFetchedTexture::loadFromFastCache() } mInFastCacheList = FALSE; - mRawImage = LLAppViewer::getTextureCache()->readFromFastCache(getID(), mRawDiscardLevel) ; + mRawImage = LLAppViewer::getTextureCache()->readFromFastCache(getID(), mRawDiscardLevel); if(mRawImage.notNull()) { mFullWidth = mRawImage->getWidth() << mRawDiscardLevel; @@ -1127,56 +1127,56 @@ void LLViewerFetchedTexture::loadFromFastCache() destroyRawImage(); LL_WARNS() << "oversized, setting as missing" << LL_ENDL; setIsMissingAsset(); - mRawDiscardLevel = INVALID_DISCARD_LEVEL ; + mRawDiscardLevel = INVALID_DISCARD_LEVEL; } else { mRequestedDiscardLevel = mDesiredDiscardLevel + 1; mIsRawImageValid = TRUE; - addToCreateTexture() ; + addToCreateTexture(); } } } void LLViewerFetchedTexture::setForSculpt() { - static const S32 MAX_INTERVAL = 8 ; //frames + static const S32 MAX_INTERVAL = 8; //frames - mForSculpt = TRUE ; + mForSculpt = TRUE; if(isForSculptOnly() && hasGLTexture() && !getBoundRecently()) { - destroyGLTexture() ; //sculpt image does not need gl texture. + destroyGLTexture(); //sculpt image does not need gl texture. mTextureState = ACTIVE; } - checkCachedRawSculptImage() ; - setMaxVirtualSizeResetInterval(MAX_INTERVAL) ; + checkCachedRawSculptImage(); + setMaxVirtualSizeResetInterval(MAX_INTERVAL); } BOOL LLViewerFetchedTexture::isForSculptOnly() const { - return mForSculpt && !mNeedsGLTexture ; + return mForSculpt && !mNeedsGLTexture; } BOOL LLViewerFetchedTexture::isDeleted() { - return mTextureState == DELETED ; + return mTextureState == DELETED; } BOOL LLViewerFetchedTexture::isInactive() { - return mTextureState == INACTIVE ; + return mTextureState == INACTIVE; } BOOL LLViewerFetchedTexture::isDeletionCandidate() { - return mTextureState == DELETION_CANDIDATE ; + return mTextureState == DELETION_CANDIDATE; } void LLViewerFetchedTexture::setDeletionCandidate() { if(mGLTexturep.notNull() && mGLTexturep->getTexName() && (mTextureState == INACTIVE)) { - mTextureState = DELETION_CANDIDATE ; + mTextureState = DELETION_CANDIDATE; } } @@ -1185,7 +1185,7 @@ void LLViewerFetchedTexture::setInactive() { if(mTextureState == ACTIVE && mGLTexturep.notNull() && mGLTexturep->getTexName() && !mGLTexturep->getBoundRecently()) { - mTextureState = INACTIVE ; + mTextureState = INACTIVE; } } @@ -1229,57 +1229,57 @@ void LLViewerFetchedTexture::destroyTexture() { //if(LLImageGL::sGlobalTextureMemoryInBytes < sMaxDesiredTextureMemInBytes)//not ready to release unused memory. //{ - // return ; + // return; //} if (mNeedsCreateTexture)//return if in the process of generating a new texture. { - return ; + return; } //LL_DEBUGS("Avatar") << mID << LL_ENDL; - destroyGLTexture() ; - mFullyLoaded = FALSE ; + destroyGLTexture(); + mFullyLoaded = FALSE; } void LLViewerFetchedTexture::addToCreateTexture() { - bool force_update = false ; + bool force_update = false; if (getComponents() != mRawImage->getComponents()) { // We've changed the number of components, so we need to move any // objects using this pool to a different pool. mComponents = mRawImage->getComponents(); - mGLTexturep->setComponents(mComponents) ; - force_update = true ; + mGLTexturep->setComponents(mComponents); + force_update = true; for (U32 j = 0; j < LLRender::NUM_TEXTURE_CHANNELS; ++j) { llassert(mNumFaces[j] <= mFaceList[j].size()); - for(U32 i = 0 ; i < mNumFaces[j]; i++) + for(U32 i = 0; i < mNumFaces[j]; i++) { - mFaceList[j][i]->dirtyTexture() ; + mFaceList[j][i]->dirtyTexture(); } } //discard the cached raw image and the saved raw image - mCachedRawImageReady = FALSE ; - mCachedRawDiscardLevel = -1 ; - mCachedRawImage = NULL ; - mSavedRawDiscardLevel = -1 ; - mSavedRawImage = NULL ; + mCachedRawImageReady = FALSE; + mCachedRawDiscardLevel = -1; + mCachedRawImage = NULL; + mSavedRawDiscardLevel = -1; + mSavedRawImage = NULL; } if(isForSculptOnly()) { //just update some variables, not to create a real GL texture. - createGLTexture(mRawDiscardLevel, mRawImage, 0, FALSE) ; - mNeedsCreateTexture = FALSE ; + createGLTexture(mRawDiscardLevel, mRawImage, 0, FALSE); + mNeedsCreateTexture = FALSE; destroyRawImage(); } else if(!force_update && getDiscardLevel() > -1 && getDiscardLevel() <= mRawDiscardLevel) { - mNeedsCreateTexture = FALSE ; + mNeedsCreateTexture = FALSE; destroyRawImage(); } else @@ -1299,11 +1299,11 @@ void LLViewerFetchedTexture::addToCreateTexture() //scale it down to size >= LLViewerTexture::sMinLargeImageSize if(w * h > LLViewerTexture::sMinLargeImageSize) { - S32 d_level = llmin(mRequestedDiscardLevel, (S32)mDesiredDiscardLevel) - mRawDiscardLevel ; + S32 d_level = llmin(mRequestedDiscardLevel, (S32)mDesiredDiscardLevel) - mRawDiscardLevel; if(d_level > 0) { - S32 i = 0 ; + S32 i = 0; while((d_level > 0) && ((w >> i) * (h >> i) > LLViewerTexture::sMinLargeImageSize)) { i++; @@ -1311,14 +1311,14 @@ void LLViewerFetchedTexture::addToCreateTexture() } if(i > 0) { - mRawDiscardLevel += i ; + mRawDiscardLevel += i; if(mRawDiscardLevel >= getDiscardLevel() && getDiscardLevel() > 0) { - mNeedsCreateTexture = FALSE ; + mNeedsCreateTexture = FALSE; destroyRawImage(); - return ; + return; } - mRawImage->scale(w >> i, h >> i) ; + mRawImage->scale(w >> i, h >> i); } } } @@ -1327,7 +1327,7 @@ void LLViewerFetchedTexture::addToCreateTexture() mNeedsCreateTexture = TRUE; gTextureList.mCreateTextureList.insert(this); } - return ; + return; } // ONLY called from LLViewerTextureList @@ -1405,7 +1405,7 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/) res = mGLTexturep->createGLTexture(mRawDiscardLevel, mRawImage, usename, TRUE, mBoostLevel); - setActive() ; + setActive(); if (!needsToSaveRawImage()) { @@ -1421,11 +1421,11 @@ void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height) { if(mKnownDrawWidth < width || mKnownDrawHeight < height) { - mKnownDrawWidth = llmax(mKnownDrawWidth, width) ; - mKnownDrawHeight = llmax(mKnownDrawHeight, height) ; + mKnownDrawWidth = llmax(mKnownDrawWidth, width); + mKnownDrawHeight = llmax(mKnownDrawHeight, height); - mKnownDrawSizeChanged = TRUE ; - mFullyLoaded = FALSE ; + mKnownDrawSizeChanged = TRUE; + mFullyLoaded = FALSE; } addTextureStats((F32)(mKnownDrawWidth * mKnownDrawHeight)); } @@ -1437,13 +1437,13 @@ void LLViewerFetchedTexture::processTextureStats() { if(mDesiredDiscardLevel > mMinDesiredDiscardLevel)//need to load more { - mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ; - mFullyLoaded = FALSE ; + mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel); + mFullyLoaded = FALSE; } } else { - updateVirtualSize() ; + updateVirtualSize(); static LLCachedControl textures_fullres(gSavedSettings,"TextureLoadFullRes"); @@ -1453,7 +1453,7 @@ void LLViewerFetchedTexture::processTextureStats() } else if(!mFullWidth || !mFullHeight) { - mDesiredDiscardLevel = llmin(getMaxDiscardLevel(), (S32)mLoadedCallbackDesiredDiscardLevel) ; + mDesiredDiscardLevel = llmin(getMaxDiscardLevel(), (S32)mLoadedCallbackDesiredDiscardLevel); } else { @@ -1471,36 +1471,36 @@ void LLViewerFetchedTexture::processTextureStats() else if(mKnownDrawSizeChanged)//known draw size is set { mDesiredDiscardLevel = (S8)llmin(log((F32)mFullWidth / mKnownDrawWidth) / log_2, - log((F32)mFullHeight / mKnownDrawHeight) / log_2) ; - mDesiredDiscardLevel = llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel()) ; - mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel) ; + log((F32)mFullHeight / mKnownDrawHeight) / log_2); + mDesiredDiscardLevel = llclamp(mDesiredDiscardLevel, (S8)0, (S8)getMaxDiscardLevel()); + mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, mMinDesiredDiscardLevel); } - mKnownDrawSizeChanged = FALSE ; + mKnownDrawSizeChanged = FALSE; if(getDiscardLevel() >= 0 && (getDiscardLevel() <= mDesiredDiscardLevel)) { - mFullyLoaded = TRUE ; + mFullyLoaded = TRUE; } } } if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0) //force to refetch the texture. { - mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel) ; + mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel); if(getDiscardLevel() < 0 || getDiscardLevel() > mDesiredDiscardLevel) { - mFullyLoaded = FALSE ; + mFullyLoaded = FALSE; } } } -const F32 MAX_PRIORITY_PIXEL = 999.f ; //pixel area -const F32 PRIORITY_BOOST_LEVEL_FACTOR = 1000.f ; //boost level -const F32 PRIORITY_DELTA_DISCARD_LEVEL_FACTOR = 100000.f ; //delta discard -const S32 MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY = 4 ; -const F32 PRIORITY_ADDITIONAL_FACTOR = 1000000.f ; //additional -const S32 MAX_ADDITIONAL_LEVEL_FOR_PRIORITY = 8 ; -const F32 PRIORITY_BOOST_HIGH_FACTOR = 10000000.f ;//boost high +const F32 MAX_PRIORITY_PIXEL = 999.f; //pixel area +const F32 PRIORITY_BOOST_LEVEL_FACTOR = 1000.f; //boost level +const F32 PRIORITY_DELTA_DISCARD_LEVEL_FACTOR = 100000.f; //delta discard +const S32 MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY = 4; +const F32 PRIORITY_ADDITIONAL_FACTOR = 1000000.f; //additional +const S32 MAX_ADDITIONAL_LEVEL_FOR_PRIORITY = 8; +const F32 PRIORITY_BOOST_HIGH_FACTOR = 10000000.f;//boost high F32 LLViewerFetchedTexture::calcDecodePriority() { #ifndef LL_RELEASE_FOR_DOWNLOAD @@ -1516,7 +1516,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority() } if(mFullyLoaded && !mForceToSaveRawImage)//already loaded for static texture { - return -1.0f ; //alreay fetched + return -1.0f; //alreay fetched } S32 cur_discard = getCurrentDiscardLevelForFetching(); @@ -1531,7 +1531,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority() } else if(mDesiredDiscardLevel >= cur_discard && cur_discard > -1) { - priority = -2.0f ; + priority = -2.0f; } else if(mCachedRawDiscardLevel > -1 && mDesiredDiscardLevel >= mCachedRawDiscardLevel) { @@ -1568,7 +1568,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority() S32 ddiscard = MAX_DISCARD_LEVEL - (S32)desired; ddiscard = llclamp(ddiscard, 0, MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY); priority = (ddiscard + 1) * PRIORITY_DELTA_DISCARD_LEVEL_FACTOR; - setAdditionalDecodePriority(0.1f) ;//boost the textures without any data so far. + setAdditionalDecodePriority(0.1f);//boost the textures without any data so far. } else if ((mMinDiscardLevel > 0) && (cur_discard <= mMinDiscardLevel)) { @@ -1603,13 +1603,13 @@ F32 LLViewerFetchedTexture::calcDecodePriority() // [10,000,000] + [1,000,000-9,000,000] + [100,000-500,000] + [1-20,000] + [0-999] if (priority > 0.0f) { - bool large_enough = mCachedRawImageReady && ((S32)mTexelsPerImage > sMinLargeImageSize) ; + bool large_enough = mCachedRawImageReady && ((S32)mTexelsPerImage > sMinLargeImageSize); if(large_enough) { //Note: //to give small, low-priority textures some chance to be fetched, //cut the priority in half if the texture size is larger than 256 * 256 and has a 64*64 ready. - priority *= 0.5f ; + priority *= 0.5f; } pixel_priority = llclamp(pixel_priority, 0.0f, MAX_PRIORITY_PIXEL); @@ -1628,7 +1628,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority() //Note: //to give small, low-priority textures some chance to be fetched, //if high priority texture has a 64*64 ready, lower its fetching priority. - setAdditionalDecodePriority(0.5f) ; + setAdditionalDecodePriority(0.5f); } else { @@ -1645,7 +1645,7 @@ F32 LLViewerFetchedTexture::calcDecodePriority() //Note: //to give small, low-priority textures some chance to be fetched, //cut the additional priority to a quarter if the texture size is larger than 256 * 256 and has a 64*64 ready. - additional *= 0.25f ; + additional *= 0.25f; } priority += additional; } @@ -1660,9 +1660,9 @@ F32 LLViewerFetchedTexture::maxDecodePriority() PRIORITY_ADDITIONAL_FACTOR * (MAX_ADDITIONAL_LEVEL_FOR_PRIORITY + 1) + //additional (view dependent factors) PRIORITY_DELTA_DISCARD_LEVEL_FACTOR * (MAX_DELTA_DISCARD_LEVEL_FOR_PRIORITY + 1) + //delta discard PRIORITY_BOOST_LEVEL_FACTOR * (BOOST_MAX_LEVEL - 1) + //boost level - MAX_PRIORITY_PIXEL + 1.0f ; //pixel area. + MAX_PRIORITY_PIXEL + 1.0f; //pixel area. - return max_priority ; + return max_priority; } //============================================================================ @@ -1673,7 +1673,7 @@ void LLViewerFetchedTexture::setDecodePriority(F32 priority) if(mDecodePriority < F_ALMOST_ZERO) { - mStopFetchingTimer.reset() ; + mStopFetchingTimer.reset(); } } @@ -1690,16 +1690,16 @@ void LLViewerFetchedTexture::updateVirtualSize() { if(!mMaxVirtualSizeResetCounter) { - addTextureStats(0.f, FALSE) ;//reset + addTextureStats(0.f, FALSE);//reset } for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) { llassert(mNumFaces[ch] <= mFaceList[ch].size()); - for(U32 i = 0 ; i < mNumFaces[ch]; i++) + for(U32 i = 0; i < mNumFaces[ch]; i++) { - LLFace* facep = mFaceList[ch][i] ; + LLFace* facep = mFaceList[ch][i]; if( facep ) { LLDrawable* drawable = facep->getDrawable(); @@ -1712,8 +1712,8 @@ void LLViewerFetchedTexture::updateVirtualSize() { setBoostLevel(LLViewerTexture::BOOST_SELECTED); } - addTextureStats(facep->getVirtualSize()) ; - setAdditionalDecodePriority(facep->getImportanceToCamera()) ; + addTextureStats(facep->getVirtualSize()); + setAdditionalDecodePriority(facep->getImportanceToCamera()); } } } @@ -1732,26 +1732,26 @@ void LLViewerFetchedTexture::updateVirtualSize() { mMaxVirtualSizeResetCounter--; } - reorganizeFaceList() ; + reorganizeFaceList(); reorganizeVolumeList(); } S32 LLViewerFetchedTexture::getCurrentDiscardLevelForFetching() { - S32 current_discard = getDiscardLevel() ; + S32 current_discard = getDiscardLevel(); if(mForceToSaveRawImage) { if(mSavedRawDiscardLevel < 0 || current_discard < 0) { - current_discard = -1 ; + current_discard = -1; } else { - current_discard = llmax(current_discard, mSavedRawDiscardLevel) ; + current_discard = llmax(current_discard, mSavedRawDiscardLevel); } } - return current_discard ; + return current_discard; } bool LLViewerFetchedTexture::setDebugFetching(S32 debug_level) @@ -1782,7 +1782,7 @@ bool LLViewerFetchedTexture::updateFetch() static LLCachedControl sCameraMotionBoost(gSavedSettings,"TextureCameraMotionBoost"); if(textures_decode_disabled) { - return false ; + return false; } mFetchState = 0; @@ -1817,7 +1817,7 @@ bool LLViewerFetchedTexture::updateFetch() return false; } - S32 current_discard = getCurrentDiscardLevelForFetching() ; + S32 current_discard = getCurrentDiscardLevelForFetching(); S32 desired_discard = getDesiredDiscardLevel(); F32 decode_priority = getDecodePriority(); decode_priority = llclamp(decode_priority, 0.0f, maxDecodePriority()); @@ -1835,7 +1835,7 @@ bool LLViewerFetchedTexture::updateFetch() if (finished) { mIsFetching = FALSE; - mLastPacketTimer.reset() ; + mLastPacketTimer.reset(); } else { @@ -1849,8 +1849,8 @@ bool LLViewerFetchedTexture::updateFetch() LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { - mIsFetched = TRUE ; - tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID)) ; + mIsFetched = TRUE; + tester->updateTextureLoadingStats(this, mRawImage, LLAppViewer::getTextureFetch()->isFromLocalCache(mID)); } mRawDiscardLevel = fetch_discard; if ((mRawImage->getDataSize() > 0 && mRawDiscardLevel >= 0) && @@ -1866,17 +1866,17 @@ bool LLViewerFetchedTexture::updateFetch() destroyRawImage(); LL_WARNS() << "oversize, setting as missing" << LL_ENDL; setIsMissingAsset(); - mRawDiscardLevel = INVALID_DISCARD_LEVEL ; - mIsFetching = FALSE ; + mRawDiscardLevel = INVALID_DISCARD_LEVEL; + mIsFetching = FALSE; mLastPacketTimer.reset(); } else { mIsRawImageValid = TRUE; - addToCreateTexture() ; + addToCreateTexture(); } - return TRUE ; + return TRUE; } else { @@ -1924,10 +1924,10 @@ bool LLViewerFetchedTexture::updateFetch() // LL_INFOS() << "Calling updateRequestPriority() with decode_priority = 0.0f" << LL_ENDL; // calcDecodePriority(); // } - static const F32 MAX_HOLD_TIME = 5.0f ; //seconds to wait before canceling fecthing if decode_priority is 0.f. + static const F32 MAX_HOLD_TIME = 5.0f; //seconds to wait before canceling fecthing if decode_priority is 0.f. if(decode_priority > 0.0f || mStopFetchingTimer.getElapsedTimeF32() > MAX_HOLD_TIME) { - mStopFetchingTimer.reset() ; + mStopFetchingTimer.reset(); LLAppViewer::getTextureFetch()->updateRequestPriority(mID, decode_priority); } } @@ -1953,7 +1953,7 @@ bool LLViewerFetchedTexture::updateFetch() else if(mCachedRawImage.notNull() && (current_discard < 0 || current_discard > mCachedRawDiscardLevel)) { make_request = false; - switchToCachedImage() ; //use the cached raw data first + switchToCachedImage(); //use the cached raw data first } //else if (!isJustBound() && mCachedRawImageReady) //{ @@ -1965,7 +1965,7 @@ bool LLViewerFetchedTexture::updateFetch() // Load the texture progressively: we try not to rush to the desired discard too fast. // If the camera is not moving, we do not tweak the discard level notch by notch but go to the desired discard with larger boosted steps // This mitigates the "textures stay blurry" problem when loading while not killing the texture memory while moving around - S32 delta_level = (mBoostLevel > LLGLTexture::BOOST_NONE) ? 2 : 1 ; + S32 delta_level = (mBoostLevel > LLGLTexture::BOOST_NONE) ? 2 : 1; if (current_discard < 0) { desired_discard = llmax(desired_discard, getMaxDiscardLevel() - delta_level); @@ -2051,7 +2051,7 @@ void LLViewerFetchedTexture::clearFetchedResults() { if(mNeedsCreateTexture || mIsFetching) { - return ; + return; } cleanup(); @@ -2068,7 +2068,7 @@ void LLViewerFetchedTexture::forceToDeleteRequest() if (mHasFetcher) { mHasFetcher = FALSE; - mIsFetching = FALSE ; + mIsFetching = FALSE; } resetTextureStats(); @@ -2116,19 +2116,19 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call } else { - mLoadedCallbackDesiredDiscardLevel = llmin(mLoadedCallbackDesiredDiscardLevel, (S8)discard_level) ; + mLoadedCallbackDesiredDiscardLevel = llmin(mLoadedCallbackDesiredDiscardLevel, (S8)discard_level); } if(mPauseLoadedCallBacks) { if(!pause) { - unpauseLoadedCallbacks(src_callback_list) ; + unpauseLoadedCallbacks(src_callback_list); } } else if(pause) { - pauseLoadedCallbacks(src_callback_list) ; + pauseLoadedCallbacks(src_callback_list); } LLLoadedCallbackEntry* entryp = new LLLoadedCallbackEntry(loaded_callback, discard_level, keep_imageraw, userdata, src_callback_list, this, pause); @@ -2137,21 +2137,21 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call mNeedsAux |= needs_aux; if(keep_imageraw) { - mSaveRawImage = TRUE ; + mSaveRawImage = TRUE; } if (mNeedsAux && mAuxRawImage.isNull() && getDiscardLevel() >= 0) { // We need aux data, but we've already loaded the image, and it didn't have any LL_WARNS() << "No aux data available for callback for image:" << getID() << LL_ENDL; } - mLastCallBackActiveTime = sCurrentTime ; + mLastCallBackActiveTime = sCurrentTime; } void LLViewerFetchedTexture::clearCallbackEntryList() { if(mLoadedCallbackList.empty()) { - return ; + return; } for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); @@ -2162,29 +2162,29 @@ void LLViewerFetchedTexture::clearCallbackEntryList() // We never finished loading the image. Indicate failure. // Note: this allows mLoadedCallbackUserData to be cleaned up. entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData); - iter = mLoadedCallbackList.erase(iter) ; + iter = mLoadedCallbackList.erase(iter); delete entryp; } gTextureList.mCallbackList.erase(this); - mLoadedCallbackDesiredDiscardLevel = S8_MAX ; + mLoadedCallbackDesiredDiscardLevel = S8_MAX; if(needsToSaveRawImage()) { - destroySavedRawImage() ; + destroySavedRawImage(); } - return ; + return; } void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::source_callback_list_t* callback_list) { if(mLoadedCallbackList.empty() || !callback_list) { - return ; + return; } - S32 desired_discard = S8_MAX ; - S32 desired_raw_discard = INVALID_DISCARD_LEVEL ; + S32 desired_discard = S8_MAX; + S32 desired_raw_discard = INVALID_DISCARD_LEVEL; for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); iter != mLoadedCallbackList.end(); ) { @@ -2194,17 +2194,17 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so // We never finished loading the image. Indicate failure. // Note: this allows mLoadedCallbackUserData to be cleaned up. entryp->mCallback(FALSE, this, NULL, NULL, 0, TRUE, entryp->mUserData); - iter = mLoadedCallbackList.erase(iter) ; + iter = mLoadedCallbackList.erase(iter); delete entryp; } else { ++iter; - desired_discard = llmin(desired_discard, entryp->mDesiredDiscard) ; + desired_discard = llmin(desired_discard, entryp->mDesiredDiscard); if(entryp->mNeedsImageRaw) { - desired_raw_discard = llmin(desired_raw_discard, entryp->mDesiredDiscard) ; + desired_raw_discard = llmin(desired_raw_discard, entryp->mDesiredDiscard); } } } @@ -2217,18 +2217,18 @@ void LLViewerFetchedTexture::deleteCallbackEntry(const LLLoadedCallbackEntry::so if(needsToSaveRawImage()) { - destroySavedRawImage() ; + destroySavedRawImage(); } } else if(needsToSaveRawImage() && mBoostLevel != LLGLTexture::BOOST_PREVIEW) { if(desired_raw_discard != INVALID_DISCARD_LEVEL) { - mDesiredSavedRawDiscardLevel = desired_raw_discard ; + mDesiredSavedRawDiscardLevel = desired_raw_discard; } else { - destroySavedRawImage() ; + destroySavedRawImage(); } } } @@ -2237,29 +2237,29 @@ void LLViewerFetchedTexture::unpauseLoadedCallbacks(const LLLoadedCallbackEntry: { if(!callback_list) { - mPauseLoadedCallBacks = FALSE ; - return ; + mPauseLoadedCallBacks = FALSE; + return; } - BOOL need_raw = FALSE ; + BOOL need_raw = FALSE; for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); iter != mLoadedCallbackList.end(); ) { LLLoadedCallbackEntry *entryp = *iter++; if(entryp->mSourceCallbackList == callback_list) { - entryp->mPaused = FALSE ; + entryp->mPaused = FALSE; if(entryp->mNeedsImageRaw) { - need_raw = TRUE ; + need_raw = TRUE; } } } - mPauseLoadedCallBacks = FALSE ; - mLastCallBackActiveTime = sCurrentTime ; + mPauseLoadedCallBacks = FALSE; + mLastCallBackActiveTime = sCurrentTime; if(need_raw) { - mSaveRawImage = TRUE ; + mSaveRawImage = TRUE; } } @@ -2267,10 +2267,10 @@ void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::s { if(!callback_list) { - return ; + return; } - bool paused = true ; + bool paused = true; for(callback_list_t::iterator iter = mLoadedCallbackList.begin(); iter != mLoadedCallbackList.end(); ) @@ -2278,25 +2278,25 @@ void LLViewerFetchedTexture::pauseLoadedCallbacks(const LLLoadedCallbackEntry::s LLLoadedCallbackEntry *entryp = *iter++; if(entryp->mSourceCallbackList == callback_list) { - entryp->mPaused = TRUE ; + entryp->mPaused = TRUE; } else if(!entryp->mPaused) { - paused = false ; + paused = false; } } if(paused) { - mPauseLoadedCallBacks = TRUE ;//when set, loaded callback is paused. + mPauseLoadedCallBacks = TRUE;//when set, loaded callback is paused. resetTextureStats(); - mSaveRawImage = FALSE ; + mSaveRawImage = FALSE; } } bool LLViewerFetchedTexture::doLoadedCallbacks() { - static const F32 MAX_INACTIVE_TIME = 900.f ; //seconds + static const F32 MAX_INACTIVE_TIME = 900.f; //seconds if (mNeedsCreateTexture) { @@ -2309,8 +2309,8 @@ bool LLViewerFetchedTexture::doLoadedCallbacks() } if(sCurrentTime - mLastCallBackActiveTime > MAX_INACTIVE_TIME && !mIsFetching) { - clearCallbackEntryList() ; //remove all callbacks. - return false ; + clearCallbackEntryList(); //remove all callbacks. + return false; } bool res = false; @@ -2330,7 +2330,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks() // Remove ourself from the global list of textures with callbacks gTextureList.mCallbackList.erase(this); - return false ; + return false; } S32 gl_discard = getDiscardLevel(); @@ -2451,7 +2451,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks() // to satisfy the interested party, then this is the last time that // we're going to call them. - mLastCallBackActiveTime = sCurrentTime ; + mLastCallBackActiveTime = sCurrentTime; //llassert_always(mRawImage.notNull()); if(mNeedsAux && mAuxRawImage.isNull()) { @@ -2487,7 +2487,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks() LLLoadedCallbackEntry *entryp = *curiter; if (!entryp->mNeedsImageRaw && (entryp->mLastUsedDiscard > gl_discard)) { - mLastCallBackActiveTime = sCurrentTime ; + mLastCallBackActiveTime = sCurrentTime; BOOL final = gl_discard <= entryp->mDesiredDiscard ? TRUE : FALSE; entryp->mLastUsedDiscard = gl_discard; entryp->mCallback(TRUE, this, NULL, NULL, gl_discard, final, entryp->mUserData); @@ -2521,66 +2521,66 @@ void LLViewerFetchedTexture::forceImmediateUpdate() //only immediately update a deleted texture which is now being re-used. if(!isDeleted()) { - return ; + return; } //if already called forceImmediateUpdate() if(mInImageList && mDecodePriority == LLViewerFetchedTexture::maxDecodePriority()) { - return ; + return; } - gTextureList.forceImmediateUpdate(this) ; - return ; + gTextureList.forceImmediateUpdate(this); + return; } LLImageRaw* LLViewerFetchedTexture::reloadRawImage(S8 discard_level) { - llassert_always(mGLTexturep.notNull()) ; + llassert_always(mGLTexturep.notNull()); llassert_always(discard_level >= 0); llassert_always(mComponents > 0); if (mRawImage.notNull()) { //mRawImage is in use by somebody else, do not delete it. - return NULL ; + return NULL; } if(mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= discard_level) { if(mSavedRawDiscardLevel != discard_level) { - mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()) ; - mRawImage->copy(getSavedRawImage()) ; + mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()); + mRawImage->copy(getSavedRawImage()); } else { - mRawImage = getSavedRawImage() ; + mRawImage = getSavedRawImage(); } - mRawDiscardLevel = discard_level ; + mRawDiscardLevel = discard_level; } else { //force to fetch raw image again if cached raw image is not good enough. if(mCachedRawDiscardLevel > discard_level) { - mRawImage = mCachedRawImage ; + mRawImage = mCachedRawImage; mRawDiscardLevel = mCachedRawDiscardLevel; } else //cached raw image is good enough, copy it. { if(mCachedRawDiscardLevel != discard_level) { - mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()) ; - mRawImage->copy(mCachedRawImage) ; + mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()); + mRawImage->copy(mCachedRawImage); } else { - mRawImage = mCachedRawImage ; + mRawImage = mCachedRawImage; } - mRawDiscardLevel = discard_level ; + mRawDiscardLevel = discard_level; } } - mIsRawImageValid = TRUE ; + mIsRawImageValid = TRUE; sRawCount++; return mRawImage; @@ -2588,7 +2588,7 @@ LLImageRaw* LLViewerFetchedTexture::reloadRawImage(S8 discard_level) bool LLViewerFetchedTexture::needsToSaveRawImage() { - return mForceToSaveRawImage || mSaveRawImage ; + return mForceToSaveRawImage || mSaveRawImage; } void LLViewerFetchedTexture::destroyRawImage() @@ -2607,9 +2607,9 @@ void LLViewerFetchedTexture::destroyRawImage() { if(needsToSaveRawImage()) { - saveRawImage() ; + saveRawImage(); } - setCachedRawImage() ; + setCachedRawImage(); } mRawImage = NULL; @@ -2625,19 +2625,19 @@ void LLViewerFetchedTexture::switchToCachedImage() { if(mCachedRawImage.notNull()) { - mRawImage = mCachedRawImage ; + mRawImage = mCachedRawImage; if (getComponents() != mRawImage->getComponents()) { // We've changed the number of components, so we need to move any // objects using this pool to a different pool. mComponents = mRawImage->getComponents(); - mGLTexturep->setComponents(mComponents) ; + mGLTexturep->setComponents(mComponents); gTextureList.dirtyImage(this); } mIsRawImageValid = TRUE; - mRawDiscardLevel = mCachedRawDiscardLevel ; + mRawDiscardLevel = mCachedRawDiscardLevel; gTextureList.mCreateTextureList.insert(this); mNeedsCreateTexture = TRUE; } @@ -2649,9 +2649,9 @@ void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* im { if(imageraw != mRawImage.get()) { - mCachedRawImage = imageraw ; - mCachedRawDiscardLevel = discard_level ; - mCachedRawImageReady = TRUE ; + mCachedRawImage = imageraw; + mCachedRawDiscardLevel = discard_level; + mCachedRawImageReady = TRUE; } } @@ -2659,56 +2659,56 @@ void LLViewerFetchedTexture::setCachedRawImage() { if(mRawImage == mCachedRawImage) { - return ; + return; } if(!mIsRawImageValid) { - return ; + return; } if(mCachedRawImageReady) { - return ; + return; } if(mCachedRawDiscardLevel < 0 || mCachedRawDiscardLevel > mRawDiscardLevel) { - S32 i = 0 ; - S32 w = mRawImage->getWidth() ; - S32 h = mRawImage->getHeight() ; + S32 i = 0; + S32 w = mRawImage->getWidth(); + S32 h = mRawImage->getHeight(); - S32 max_size = MAX_CACHED_RAW_IMAGE_AREA ; + S32 max_size = MAX_CACHED_RAW_IMAGE_AREA; if(LLGLTexture::BOOST_TERRAIN == mBoostLevel) { - max_size = MAX_CACHED_RAW_TERRAIN_IMAGE_AREA ; + max_size = MAX_CACHED_RAW_TERRAIN_IMAGE_AREA; } if(mForSculpt) { - max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA ; - mCachedRawImageReady = !mRawDiscardLevel ; + max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA; + mCachedRawImageReady = !mRawDiscardLevel; } else { - mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)) ; + mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)); } while(((w >> i) * (h >> i)) > max_size) { - ++i ; + ++i; } if(i) { if(!(w >> i) || !(h >> i)) { - --i ; + --i; } - mRawImage->scale(w >> i, h >> i) ; + mRawImage->scale(w >> i, h >> i); } - mCachedRawImage = mRawImage ; - mRawDiscardLevel += i ; - mCachedRawDiscardLevel = mRawDiscardLevel ; + mCachedRawImage = mRawImage; + mRawDiscardLevel += i; + mCachedRawDiscardLevel = mRawDiscardLevel; } } @@ -2718,11 +2718,11 @@ void LLViewerFetchedTexture::checkCachedRawSculptImage() { if(getDiscardLevel() != 0) { - mCachedRawImageReady = FALSE ; + mCachedRawImageReady = FALSE; } else if(isForSculptOnly()) { - resetTextureStats() ; //do not update this image any more. + resetTextureStats(); //do not update this image any more. } } } @@ -2731,45 +2731,45 @@ void LLViewerFetchedTexture::saveRawImage() { if(mRawImage.isNull() || mRawImage == mSavedRawImage || (mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= mRawDiscardLevel)) { - return ; + return; } - mSavedRawDiscardLevel = mRawDiscardLevel ; - mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()) ; + mSavedRawDiscardLevel = mRawDiscardLevel; + mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()); if(mForceToSaveRawImage && mSavedRawDiscardLevel <= mDesiredSavedRawDiscardLevel) { - mForceToSaveRawImage = FALSE ; + mForceToSaveRawImage = FALSE; } - mLastReferencedSavedRawImageTime = sCurrentTime ; + mLastReferencedSavedRawImageTime = sCurrentTime; } void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard, F32 kept_time) { - mKeptSavedRawImageTime = kept_time ; - mLastReferencedSavedRawImageTime = sCurrentTime ; + mKeptSavedRawImageTime = kept_time; + mLastReferencedSavedRawImageTime = sCurrentTime; if(mSavedRawDiscardLevel > -1 && mSavedRawDiscardLevel <= desired_discard) { - return ; //raw imge is ready. + return; //raw imge is ready. } if(!mForceToSaveRawImage || mDesiredSavedRawDiscardLevel < 0 || mDesiredSavedRawDiscardLevel > desired_discard) { - mForceToSaveRawImage = TRUE ; - mDesiredSavedRawDiscardLevel = desired_discard ; + mForceToSaveRawImage = TRUE; + mDesiredSavedRawDiscardLevel = desired_discard; //copy from the cached raw image if exists. if(mCachedRawImage.notNull() && mRawImage.isNull() ) { - mRawImage = mCachedRawImage ; - mRawDiscardLevel = mCachedRawDiscardLevel ; + mRawImage = mCachedRawImage; + mRawDiscardLevel = mCachedRawDiscardLevel; - saveRawImage() ; + saveRawImage(); - mRawImage = NULL ; - mRawDiscardLevel = INVALID_DISCARD_LEVEL ; + mRawImage = NULL; + mRawDiscardLevel = INVALID_DISCARD_LEVEL; } } } @@ -2777,38 +2777,38 @@ void LLViewerFetchedTexture::destroySavedRawImage() { if(mLastReferencedSavedRawImageTime < mKeptSavedRawImageTime) { - return ; //keep the saved raw image. + return; //keep the saved raw image. } - mForceToSaveRawImage = FALSE ; - mSaveRawImage = FALSE ; + mForceToSaveRawImage = FALSE; + mSaveRawImage = FALSE; - clearCallbackEntryList() ; + clearCallbackEntryList(); - mSavedRawImage = NULL ; - mForceToSaveRawImage = FALSE ; - mSaveRawImage = FALSE ; - mSavedRawDiscardLevel = -1 ; - mDesiredSavedRawDiscardLevel = -1 ; - mLastReferencedSavedRawImageTime = 0.0f ; - mKeptSavedRawImageTime = 0.f ; + mSavedRawImage = NULL; + mForceToSaveRawImage = FALSE; + mSaveRawImage = FALSE; + mSavedRawDiscardLevel = -1; + mDesiredSavedRawDiscardLevel = -1; + mLastReferencedSavedRawImageTime = 0.0f; + mKeptSavedRawImageTime = 0.f; } LLImageRaw* LLViewerFetchedTexture::getSavedRawImage() { - mLastReferencedSavedRawImageTime = sCurrentTime ; + mLastReferencedSavedRawImageTime = sCurrentTime; - return mSavedRawImage ; + return mSavedRawImage; } BOOL LLViewerFetchedTexture::hasSavedRawImage() const { - return mSavedRawImage.notNull() ; + return mSavedRawImage.notNull(); } F32 LLViewerFetchedTexture::getElapsedLastReferencedSavedRawImageTime() const { - return sCurrentTime - mLastReferencedSavedRawImageTime ; + return sCurrentTime - mLastReferencedSavedRawImageTime; } //---------------------------------------------------------------------------------------------- @@ -2821,13 +2821,13 @@ F32 LLViewerFetchedTexture::getElapsedLastReferencedSavedRawImageTime() const LLViewerLODTexture::LLViewerLODTexture(const LLUUID& id, FTType f_type, const LLHost& host, BOOL usemipmaps) : LLViewerFetchedTexture(id, f_type, host, usemipmaps) { - init(TRUE) ; + init(TRUE); } LLViewerLODTexture::LLViewerLODTexture(const std::string& url, FTType f_type, const LLUUID& id, BOOL usemipmaps) : LLViewerFetchedTexture(url, f_type, id, usemipmaps) { - init(TRUE) ; + init(TRUE); } void LLViewerLODTexture::init(bool firstinit) @@ -2840,19 +2840,19 @@ void LLViewerLODTexture::init(bool firstinit) //virtual S8 LLViewerLODTexture::getType() const { - return LLViewerTexture::LOD_TEXTURE ; + return LLViewerTexture::LOD_TEXTURE; } BOOL LLViewerLODTexture::isUpdateFrozen() { - return LLViewerTexture::sFreezeImageScalingDown && !getDiscardLevel() ; + return LLViewerTexture::sFreezeImageScalingDown && !getDiscardLevel(); } // This is gauranteed to get called periodically for every texture //virtual void LLViewerLODTexture::processTextureStats() { - updateVirtualSize() ; + updateVirtualSize(); static LLCachedControl textures_fullres(gSavedSettings,"TextureLoadFullRes"); @@ -2874,7 +2874,7 @@ void LLViewerLODTexture::processTextureStats() } else if (!mFullWidth || !mFullHeight) { - mDesiredDiscardLevel = getMaxDiscardLevel() ; + mDesiredDiscardLevel = getMaxDiscardLevel(); } else { @@ -2900,7 +2900,7 @@ void LLViewerLODTexture::processTextureStats() if(isLargeImage() && !isJustBound() && mAdditionalDecodePriority < 0.3f) { //if is a big image and not being used recently, nor close to the view point, do not load hi-res data. - mMaxVirtualSize = llmin(mMaxVirtualSize, (F32)LLViewerTexture::sMinLargeImageSize) ; + mMaxVirtualSize = llmin(mMaxVirtualSize, (F32)LLViewerTexture::sMinLargeImageSize); } if ((mCalculatedDiscardLevel >= 0.f) && @@ -2921,7 +2921,7 @@ void LLViewerLODTexture::processTextureStats() { discard_level += sDesiredDiscardBias; discard_level *= sDesiredDiscardScale; // scale - discard_level += sCameraMovingDiscardBias ; + discard_level += sCameraMovingDiscardBias; } discard_level = floorf(discard_level); @@ -2948,19 +2948,19 @@ void LLViewerLODTexture::processTextureStats() if(desired_discard_bias_max <= sDesiredDiscardBias && !mForceToSaveRawImage) { //needs to release texture memory urgently - scaleDown() ; + scaleDown(); } // Limit the amount of GL memory bound each frame else if ( sBoundTextureMemory > sMaxBoundTextureMem * texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { - scaleDown() ; + scaleDown(); } // Only allow GL to have 2x the video card memory else if ( sTotalTextureMemory > sMaxTotalTextureMem * texmem_middle_bound_scale && (!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel)) { - scaleDown() ; + scaleDown(); } } @@ -2968,13 +2968,13 @@ void LLViewerLODTexture::processTextureStats() if(mForceToSaveRawImage && mDesiredSavedRawDiscardLevel >= 0) { - mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel) ; + mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel); } else if(LLPipeline::sMemAllocationThrottled)//release memory of large textures by decrease their resolutions. { if(scaleDown()) { - mDesiredDiscardLevel = mCachedRawDiscardLevel ; + mDesiredDiscardLevel = mCachedRawDiscardLevel; } } } @@ -2983,17 +2983,17 @@ bool LLViewerLODTexture::scaleDown() { if(hasGLTexture() && mCachedRawDiscardLevel > getDiscardLevel()) { - switchToCachedImage() ; + switchToCachedImage(); LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { - tester->setStablizingTime() ; + tester->setStablizingTime(); } - return true ; + return true; } - return false ; + return false; } //---------------------------------------------------------------------------------------------- //end of LLViewerLODTexture @@ -3005,14 +3005,14 @@ bool LLViewerLODTexture::scaleDown() //static void LLViewerMediaTexture::updateClass() { - static const F32 MAX_INACTIVE_TIME = 30.f ; + static const F32 MAX_INACTIVE_TIME = 30.f; #if 0 //force to play media. - gSavedSettings.setBOOL("AudioStreamingMedia", true) ; + gSavedSettings.setBOOL("AudioStreamingMedia", true); #endif - for(media_map_t::iterator iter = sMediaMap.begin() ; iter != sMediaMap.end(); ) + for(media_map_t::iterator iter = sMediaMap.begin(); iter != sMediaMap.end(); ) { LLViewerMediaTexture* mediap = iter->second; @@ -3023,29 +3023,29 @@ void LLViewerMediaTexture::updateClass() // if(mediap->getLastReferencedTimer()->getElapsedTimeF32() > MAX_INACTIVE_TIME) { - media_map_t::iterator cur = iter++ ; - sMediaMap.erase(cur) ; - continue ; + media_map_t::iterator cur = iter++; + sMediaMap.erase(cur); + continue; } } - ++iter ; + ++iter; } } //static void LLViewerMediaTexture::removeMediaImplFromTexture(const LLUUID& media_id) { - LLViewerMediaTexture* media_tex = findMediaTexture(media_id) ; + LLViewerMediaTexture* media_tex = findMediaTexture(media_id); if(media_tex) { - media_tex->invalidateMediaImpl() ; + media_tex->invalidateMediaImpl(); } } //static void LLViewerMediaTexture::cleanUpClass() { - sMediaMap.clear() ; + sMediaMap.clear(); } //static @@ -3057,9 +3057,9 @@ LLViewerMediaTexture* LLViewerMediaTexture::findMediaTexture(const LLUUID& media return NULL; } - LLViewerMediaTexture* media_tex = iter->second ; - media_tex->setMediaImpl() ; - media_tex->getLastReferencedTimer()->reset() ; + LLViewerMediaTexture* media_tex = iter->second; + media_tex->setMediaImpl(); + media_tex->getLastReferencedTimer()->reset(); return media_tex; } @@ -3071,48 +3071,48 @@ LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LL { sMediaMap.insert(std::make_pair(id, this)); - mGLTexturep = gl_image ; + mGLTexturep = gl_image; if(mGLTexturep.isNull()) { - generateGLTexture() ; + generateGLTexture(); } mGLTexturep->setAllowCompression(false); - mGLTexturep->setNeedsAlphaAndPickMask(FALSE) ; + mGLTexturep->setNeedsAlphaAndPickMask(FALSE); - mIsPlaying = FALSE ; + mIsPlaying = FALSE; - setMediaImpl() ; + setMediaImpl(); - setCategory(LLGLTexture::MEDIA) ; + setCategory(LLGLTexture::MEDIA); - LLViewerTexture* tex = gTextureList.findImage(mID) ; + LLViewerTexture* tex = gTextureList.findImage(mID); if(tex) //this media is a parcel media for tex. { - tex->setParcelMedia(this) ; + tex->setParcelMedia(this); } } //virtual LLViewerMediaTexture::~LLViewerMediaTexture() { - LLViewerTexture* tex = gTextureList.findImage(mID) ; + LLViewerTexture* tex = gTextureList.findImage(mID); if(tex) //this media is a parcel media for tex. { - tex->setParcelMedia(NULL) ; + tex->setParcelMedia(NULL); } } void LLViewerMediaTexture::reinit(BOOL usemipmaps /* = TRUE */) { - llassert(mGLTexturep.notNull()) ; + llassert(mGLTexturep.notNull()); - mUseMipMaps = usemipmaps ; - getLastReferencedTimer()->reset() ; - mGLTexturep->setUseMipMaps(mUseMipMaps) ; - mGLTexturep->setNeedsAlphaAndPickMask(FALSE) ; + mUseMipMaps = usemipmaps; + getLastReferencedTimer()->reset(); + mGLTexturep->setUseMipMaps(mUseMipMaps); + mGLTexturep->setNeedsAlphaAndPickMask(FALSE); } void LLViewerMediaTexture::setUseMipMaps(BOOL mipmap) @@ -3121,26 +3121,26 @@ void LLViewerMediaTexture::setUseMipMaps(BOOL mipmap) if(mGLTexturep.notNull()) { - mGLTexturep->setUseMipMaps(mipmap) ; + mGLTexturep->setUseMipMaps(mipmap); } } //virtual S8 LLViewerMediaTexture::getType() const { - return LLViewerTexture::MEDIA_TEXTURE ; + return LLViewerTexture::MEDIA_TEXTURE; } void LLViewerMediaTexture::invalidateMediaImpl() { - mMediaImplp = NULL ; + mMediaImplp = NULL; } void LLViewerMediaTexture::setMediaImpl() { if(!mMediaImplp) { - mMediaImplp = LLViewerMedia::getMediaImplFromTextureID(mID) ; + mMediaImplp = LLViewerMedia::getMediaImplFromTextureID(mID); } } @@ -3149,71 +3149,71 @@ void LLViewerMediaTexture::setMediaImpl() // because it does not check the face validity after the current frame. BOOL LLViewerMediaTexture::findFaces() { - mMediaFaceList.clear() ; + mMediaFaceList.clear(); - BOOL ret = TRUE ; + BOOL ret = TRUE; - LLViewerTexture* tex = gTextureList.findImage(mID) ; + LLViewerTexture* tex = gTextureList.findImage(mID); if(tex) //this media is a parcel media for tex. { for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) { - const ll_face_list_t* face_list = tex->getFaceList(ch) ; - U32 end = tex->getNumFaces(ch) ; - for(U32 i = 0 ; i < end ; i++) + const ll_face_list_t* face_list = tex->getFaceList(ch); + U32 end = tex->getNumFaces(ch); + for(U32 i = 0; i < end; i++) { - mMediaFaceList.push_back((*face_list)[i]) ; + mMediaFaceList.push_back((*face_list)[i]); } } } if(!mMediaImplp) { - return TRUE ; + return TRUE; } //for media on a face. - const std::list< LLVOVolume* >* obj_list = mMediaImplp->getObjectList() ; - std::list< LLVOVolume* >::const_iterator iter = obj_list->begin() ; + const std::list< LLVOVolume* >* obj_list = mMediaImplp->getObjectList(); + std::list< LLVOVolume* >::const_iterator iter = obj_list->begin(); for(; iter != obj_list->end(); ++iter) { - LLVOVolume* obj = *iter ; + LLVOVolume* obj = *iter; if(obj->mDrawable.isNull()) { - ret = FALSE ; - continue ; + ret = FALSE; + continue; } - S32 face_id = -1 ; - S32 num_faces = obj->mDrawable->getNumFaces() ; + S32 face_id = -1; + S32 num_faces = obj->mDrawable->getNumFaces(); while((face_id = obj->getFaceIndexWithMediaImpl(mMediaImplp, face_id)) > -1 && face_id < num_faces) { - LLFace* facep = obj->mDrawable->getFace(face_id) ; + LLFace* facep = obj->mDrawable->getFace(face_id); if(facep) { - mMediaFaceList.push_back(facep) ; + mMediaFaceList.push_back(facep); } else { - ret = FALSE ; + ret = FALSE; } } } - return ret ; + return ret; } void LLViewerMediaTexture::initVirtualSize() { if(mIsPlaying) { - return ; + return; } - findFaces() ; + findFaces(); for(std::list< LLFace* >::iterator iter = mMediaFaceList.begin(); iter!= mMediaFaceList.end(); ++iter) { - addTextureStats((*iter)->getVirtualSize()) ; + addTextureStats((*iter)->getVirtualSize()); } } @@ -3221,77 +3221,77 @@ void LLViewerMediaTexture::addMediaToFace(LLFace* facep) { if(facep) { - facep->setHasMedia(true) ; + facep->setHasMedia(true); } if(!mIsPlaying) { - return ; //no need to add the face because the media is not in playing. + return; //no need to add the face because the media is not in playing. } - switchTexture(LLRender::DIFFUSE_MAP, facep) ; + switchTexture(LLRender::DIFFUSE_MAP, facep); } void LLViewerMediaTexture::removeMediaFromFace(LLFace* facep) { if(!facep) { - return ; + return; } - facep->setHasMedia(false) ; + facep->setHasMedia(false); if(!mIsPlaying) { - return ; //no need to remove the face because the media is not in playing. + return; //no need to remove the face because the media is not in playing. } - mIsPlaying = FALSE ; //set to remove the media from the face. - switchTexture(LLRender::DIFFUSE_MAP, facep) ; - mIsPlaying = TRUE ; //set the flag back. + mIsPlaying = FALSE; //set to remove the media from the face. + switchTexture(LLRender::DIFFUSE_MAP, facep); + mIsPlaying = TRUE; //set the flag back. if(getTotalNumFaces() < 1) //no face referencing to this media { - stopPlaying() ; + stopPlaying(); } } //virtual void LLViewerMediaTexture::addFace(U32 ch, LLFace* facep) { - LLViewerTexture::addFace(ch, facep) ; + LLViewerTexture::addFace(ch, facep); - const LLTextureEntry* te = facep->getTextureEntry() ; + const LLTextureEntry* te = facep->getTextureEntry(); if(te && te->getID().notNull()) { - LLViewerTexture* tex = gTextureList.findImage(te->getID()) ; + LLViewerTexture* tex = gTextureList.findImage(te->getID()); if(tex) { - mTextureList.push_back(tex) ;//increase the reference number by one for tex to avoid deleting it. - return ; + mTextureList.push_back(tex);//increase the reference number by one for tex to avoid deleting it. + return; } } //check if it is a parcel media if(facep->getTexture() && facep->getTexture() != this && facep->getTexture()->getID() == mID) { - mTextureList.push_back(facep->getTexture()) ; //a parcel media. - return ; + mTextureList.push_back(facep->getTexture()); //a parcel media. + return; } if(te && te->getID().notNull()) //should have a texture { - LL_ERRS() << "The face does not have a valid texture before media texture." << LL_ENDL ; + LL_ERRS() << "The face does not have a valid texture before media texture." << LL_ENDL; } } //virtual void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep) { - LLViewerTexture::removeFace(ch, facep) ; + LLViewerTexture::removeFace(ch, facep); - const LLTextureEntry* te = facep->getTextureEntry() ; + const LLTextureEntry* te = facep->getTextureEntry(); if(te && te->getID().notNull()) { - LLViewerTexture* tex = gTextureList.findImage(te->getID()) ; + LLViewerTexture* tex = gTextureList.findImage(te->getID()); if(tex) { for(std::list< LLPointer >::iterator iter = mTextureList.begin(); @@ -3299,8 +3299,8 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep) { if(*iter == tex) { - mTextureList.erase(iter) ; //decrease the reference number for tex by one. - return ; + mTextureList.erase(iter); //decrease the reference number for tex by one. + return; } } @@ -3314,7 +3314,7 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep) llassert(mNumFaces[ch] <= mFaceList[ch].size()); - for(U32 j = 0 ; j < mNumFaces[ch] ; j++) + for(U32 j = 0; j < mNumFaces[ch]; j++) { te_list.push_back(mFaceList[ch][j]->getTextureEntry());//all textures are in use. } @@ -3322,8 +3322,8 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep) if (te_list.empty()) { - mTextureList.clear() ; - return ; + mTextureList.clear(); + return; } S32 end = te_list.size(); @@ -3333,18 +3333,18 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep) { S32 i = 0; - for(i = 0 ; i < end ; i++) + for(i = 0; i < end; i++) { if(te_list[i] && te_list[i]->getID() == (*iter)->getID())//the texture is in use. { - te_list[i] = NULL ; - break ; + te_list[i] = NULL; + break; } } if(i == end) //no hit for this texture, remove it. { - mTextureList.erase(iter) ; //decrease the reference number for tex by one. - return ; + mTextureList.erase(iter); //decrease the reference number for tex by one. + return; } } } @@ -3356,14 +3356,14 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep) { if((*iter)->getID() == mID) { - mTextureList.erase(iter) ; //decrease the reference number for tex by one. - return ; + mTextureList.erase(iter); //decrease the reference number for tex by one. + return; } } if(te && te->getID().notNull()) //should have a texture { - LL_ERRS() << "mTextureList texture reference number is corrupted." << LL_ENDL ; + LL_ERRS() << "mTextureList texture reference number is corrupted." << LL_ENDL; } } @@ -3372,9 +3372,9 @@ void LLViewerMediaTexture::stopPlaying() // Don't stop the media impl playing here -- this breaks non-inworld media (login screen, search, and media browser). // if(mMediaImplp) // { -// mMediaImplp->stop() ; +// mMediaImplp->stop(); // } - mIsPlaying = FALSE ; + mIsPlaying = FALSE; } void LLViewerMediaTexture::switchTexture(U32 ch, LLFace* facep) @@ -3387,29 +3387,29 @@ void LLViewerMediaTexture::switchTexture(U32 ch, LLFace* facep) { if(mID == facep->getTexture()->getID()) //this is a parcel media { - return ; //let the prim media win. + return; //let the prim media win. } } if(mIsPlaying) //old textures switch to the media texture { - facep->switchTexture(ch, this) ; + facep->switchTexture(ch, this); } else //switch to old textures. { - const LLTextureEntry* te = facep->getTextureEntry() ; + const LLTextureEntry* te = facep->getTextureEntry(); if(te) { - LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL ; + LLViewerTexture* tex = te->getID().notNull() ? gTextureList.findImage(te->getID()) : NULL; if(!tex && te->getID() != mID)//try parcel media. { - tex = gTextureList.findImage(mID) ; + tex = gTextureList.findImage(mID); } if(!tex) { - tex = LLViewerFetchedTexture::sDefaultImagep ; + tex = LLViewerFetchedTexture::sDefaultImagep; } - facep->switchTexture(ch, tex) ; + facep->switchTexture(ch, tex); } } } @@ -3419,36 +3419,36 @@ void LLViewerMediaTexture::setPlaying(BOOL playing) { if(!mMediaImplp) { - return ; + return; } if(!playing && !mIsPlaying) { - return ; //media is already off + return; //media is already off } if(playing == mIsPlaying && !mMediaImplp->isUpdated()) { - return ; //nothing has changed since last time. + return; //nothing has changed since last time. } - mIsPlaying = playing ; + mIsPlaying = playing; if(mIsPlaying) //is about to play this media { if(findFaces()) { //about to update all faces. - mMediaImplp->setUpdated(FALSE) ; + mMediaImplp->setUpdated(FALSE); } if(mMediaFaceList.empty())//no face pointing to this media { - stopPlaying() ; - return ; + stopPlaying(); + return; } for(std::list< LLFace* >::iterator iter = mMediaFaceList.begin(); iter!= mMediaFaceList.end(); ++iter) { - switchTexture(LLRender::DIFFUSE_MAP, *iter) ; + switchTexture(LLRender::DIFFUSE_MAP, *iter); } } else //stop playing this media @@ -3456,12 +3456,12 @@ void LLViewerMediaTexture::setPlaying(BOOL playing) U32 ch = LLRender::DIFFUSE_MAP; llassert(mNumFaces[ch] <= mFaceList[ch].size()); - for(U32 i = mNumFaces[ch] ; i ; i--) + for(U32 i = mNumFaces[ch]; i; i--) { - switchTexture(ch, mFaceList[ch][i - 1]) ; //current face could be removed in this function. + switchTexture(ch, mFaceList[ch][i - 1]); //current face could be removed in this function. } } - return ; + return; } //virtual @@ -3469,13 +3469,13 @@ F32 LLViewerMediaTexture::getMaxVirtualSize() { if(LLFrameTimer::getFrameCount() == mUpdateVirtualSizeTime) { - return mMaxVirtualSize ; + return mMaxVirtualSize; } - mUpdateVirtualSizeTime = LLFrameTimer::getFrameCount() ; + mUpdateVirtualSizeTime = LLFrameTimer::getFrameCount(); if(!mMaxVirtualSizeResetCounter) { - addTextureStats(0.f, FALSE) ;//reset + addTextureStats(0.f, FALSE);//reset } if(mIsPlaying) //media is playing @@ -3483,28 +3483,28 @@ F32 LLViewerMediaTexture::getMaxVirtualSize() for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) { llassert(mNumFaces[ch] <= mFaceList[ch].size()); - for(U32 i = 0 ; i < mNumFaces[ch] ; i++) + for(U32 i = 0; i < mNumFaces[ch]; i++) { - LLFace* facep = mFaceList[ch][i] ; + LLFace* facep = mFaceList[ch][i]; if(facep->getDrawable()->isRecentlyVisible()) { - addTextureStats(facep->getVirtualSize()) ; + addTextureStats(facep->getVirtualSize()); } } } } else //media is not in playing { - findFaces() ; + findFaces(); if(!mMediaFaceList.empty()) { for(std::list< LLFace* >::iterator iter = mMediaFaceList.begin(); iter!= mMediaFaceList.end(); ++iter) { - LLFace* facep = *iter ; + LLFace* facep = *iter; if(facep->getDrawable()->isRecentlyVisible()) { - addTextureStats(facep->getVirtualSize()) ; + addTextureStats(facep->getVirtualSize()); } } } @@ -3514,10 +3514,10 @@ F32 LLViewerMediaTexture::getMaxVirtualSize() { mMaxVirtualSizeResetCounter--; } - reorganizeFaceList() ; + reorganizeFaceList(); reorganizeVolumeList(); - return mMaxVirtualSize ; + return mMaxVirtualSize; } //---------------------------------------------------------------------------------------------- //end of LLViewerMediaTexture @@ -3528,27 +3528,27 @@ F32 LLViewerMediaTexture::getMaxVirtualSize() //---------------------------------------------------------------------------------------------- LLTexturePipelineTester::LLTexturePipelineTester() : LLMetricPerformanceTesterWithSession(sTesterName) { - addMetric("TotalBytesLoaded") ; - addMetric("TotalBytesLoadedFromCache") ; - addMetric("TotalBytesLoadedForLargeImage") ; - addMetric("TotalBytesLoadedForSculpties") ; - addMetric("StartFetchingTime") ; - addMetric("TotalGrayTime") ; - addMetric("TotalStablizingTime") ; - addMetric("StartTimeLoadingSculpties") ; - addMetric("EndTimeLoadingSculpties") ; - - addMetric("Time") ; - addMetric("TotalBytesBound") ; - addMetric("TotalBytesBoundForLargeImage") ; - addMetric("PercentageBytesBound") ; + addMetric("TotalBytesLoaded"); + addMetric("TotalBytesLoadedFromCache"); + addMetric("TotalBytesLoadedForLargeImage"); + addMetric("TotalBytesLoadedForSculpties"); + addMetric("StartFetchingTime"); + addMetric("TotalGrayTime"); + addMetric("TotalStablizingTime"); + addMetric("StartTimeLoadingSculpties"); + addMetric("EndTimeLoadingSculpties"); + + addMetric("Time"); + addMetric("TotalBytesBound"); + addMetric("TotalBytesBoundForLargeImage"); + addMetric("PercentageBytesBound"); - mTotalBytesLoaded = 0 ; - mTotalBytesLoadedFromCache = 0 ; - mTotalBytesLoadedForLargeImage = 0 ; - mTotalBytesLoadedForSculpties = 0 ; + mTotalBytesLoaded = (S32Bytes)0; + mTotalBytesLoadedFromCache = (S32Bytes)0; + mTotalBytesLoadedForLargeImage = (S32Bytes)0; + mTotalBytesLoadedForSculpties = (S32Bytes)0; - reset() ; + reset(); } LLTexturePipelineTester::~LLTexturePipelineTester() @@ -3558,222 +3558,222 @@ LLTexturePipelineTester::~LLTexturePipelineTester() void LLTexturePipelineTester::update() { - mLastTotalBytesUsed = mTotalBytesUsed ; - mLastTotalBytesUsedForLargeImage = mTotalBytesUsedForLargeImage ; - mTotalBytesUsed = 0 ; - mTotalBytesUsedForLargeImage = 0 ; + mLastTotalBytesUsed = mTotalBytesUsed; + mLastTotalBytesUsedForLargeImage = mTotalBytesUsedForLargeImage; + mTotalBytesUsed = (S32Bytes)0; + mTotalBytesUsedForLargeImage = (S32Bytes)0; if(LLAppViewer::getTextureFetch()->getNumRequests() > 0) //fetching list is not empty { if(mPause) { //start a new fetching session - reset() ; - mStartFetchingTime = LLImageGL::sLastFrameTime ; - mPause = FALSE ; + reset(); + mStartFetchingTime = LLImageGL::sLastFrameTime; + mPause = FALSE; } //update total gray time if(mUsingDefaultTexture) { - mUsingDefaultTexture = FALSE ; - mTotalGrayTime = LLImageGL::sLastFrameTime - mStartFetchingTime ; + mUsingDefaultTexture = FALSE; + mTotalGrayTime = LLImageGL::sLastFrameTime - mStartFetchingTime; } //update the stablizing timer. - updateStablizingTime() ; + updateStablizingTime(); - outputTestResults() ; + outputTestResults(); } else if(!mPause) { //stop the current fetching session - mPause = TRUE ; - outputTestResults() ; - reset() ; + mPause = TRUE; + outputTestResults(); + reset(); } } void LLTexturePipelineTester::reset() { - mPause = TRUE ; + mPause = TRUE; - mUsingDefaultTexture = FALSE ; - mStartStablizingTime = 0.0f ; - mEndStablizingTime = 0.0f ; + mUsingDefaultTexture = FALSE; + mStartStablizingTime = 0.0f; + mEndStablizingTime = 0.0f; - mTotalBytesUsed = 0 ; - mTotalBytesUsedForLargeImage = 0 ; - mLastTotalBytesUsed = 0 ; - mLastTotalBytesUsedForLargeImage = 0 ; + mTotalBytesUsed = (S32Bytes)0; + mTotalBytesUsedForLargeImage = (S32Bytes)0; + mLastTotalBytesUsed = (S32Bytes)0; + mLastTotalBytesUsedForLargeImage = (S32Bytes)0; - mStartFetchingTime = 0.0f ; + mStartFetchingTime = 0.0f; - mTotalGrayTime = 0.0f ; - mTotalStablizingTime = 0.0f ; + mTotalGrayTime = 0.0f; + mTotalStablizingTime = 0.0f; - mStartTimeLoadingSculpties = 1.0f ; - mEndTimeLoadingSculpties = 0.0f ; + mStartTimeLoadingSculpties = 1.0f; + mEndTimeLoadingSculpties = 0.0f; } //virtual void LLTexturePipelineTester::outputTestRecord(LLSD *sd) { std::string currentLabel = getCurrentLabelName(); - (*sd)[currentLabel]["TotalBytesLoaded"] = (LLSD::Integer)mTotalBytesLoaded ; - (*sd)[currentLabel]["TotalBytesLoadedFromCache"] = (LLSD::Integer)mTotalBytesLoadedFromCache ; - (*sd)[currentLabel]["TotalBytesLoadedForLargeImage"] = (LLSD::Integer)mTotalBytesLoadedForLargeImage ; - (*sd)[currentLabel]["TotalBytesLoadedForSculpties"] = (LLSD::Integer)mTotalBytesLoadedForSculpties ; + (*sd)[currentLabel]["TotalBytesLoaded"] = (LLSD::Integer)mTotalBytesLoaded.value(); + (*sd)[currentLabel]["TotalBytesLoadedFromCache"] = (LLSD::Integer)mTotalBytesLoadedFromCache.value(); + (*sd)[currentLabel]["TotalBytesLoadedForLargeImage"] = (LLSD::Integer)mTotalBytesLoadedForLargeImage.value(); + (*sd)[currentLabel]["TotalBytesLoadedForSculpties"] = (LLSD::Integer)mTotalBytesLoadedForSculpties.value(); - (*sd)[currentLabel]["StartFetchingTime"] = (LLSD::Real)mStartFetchingTime ; - (*sd)[currentLabel]["TotalGrayTime"] = (LLSD::Real)mTotalGrayTime ; - (*sd)[currentLabel]["TotalStablizingTime"] = (LLSD::Real)mTotalStablizingTime ; + (*sd)[currentLabel]["StartFetchingTime"] = (LLSD::Real)mStartFetchingTime; + (*sd)[currentLabel]["TotalGrayTime"] = (LLSD::Real)mTotalGrayTime; + (*sd)[currentLabel]["TotalStablizingTime"] = (LLSD::Real)mTotalStablizingTime; - (*sd)[currentLabel]["StartTimeLoadingSculpties"] = (LLSD::Real)mStartTimeLoadingSculpties ; - (*sd)[currentLabel]["EndTimeLoadingSculpties"] = (LLSD::Real)mEndTimeLoadingSculpties ; + (*sd)[currentLabel]["StartTimeLoadingSculpties"] = (LLSD::Real)mStartTimeLoadingSculpties; + (*sd)[currentLabel]["EndTimeLoadingSculpties"] = (LLSD::Real)mEndTimeLoadingSculpties; - (*sd)[currentLabel]["Time"] = LLImageGL::sLastFrameTime ; - (*sd)[currentLabel]["TotalBytesBound"] = (LLSD::Integer)mLastTotalBytesUsed ; - (*sd)[currentLabel]["TotalBytesBoundForLargeImage"] = (LLSD::Integer)mLastTotalBytesUsedForLargeImage ; - (*sd)[currentLabel]["PercentageBytesBound"] = (LLSD::Real)(100.f * mLastTotalBytesUsed / mTotalBytesLoaded) ; + (*sd)[currentLabel]["Time"] = LLImageGL::sLastFrameTime; + (*sd)[currentLabel]["TotalBytesBound"] = (LLSD::Integer)mLastTotalBytesUsed.value(); + (*sd)[currentLabel]["TotalBytesBoundForLargeImage"] = (LLSD::Integer)mLastTotalBytesUsedForLargeImage.value(); + (*sd)[currentLabel]["PercentageBytesBound"] = (LLSD::Real)(100.f * mLastTotalBytesUsed / mTotalBytesLoaded); } void LLTexturePipelineTester::updateTextureBindingStats(const LLViewerTexture* imagep) { - U32 mem_size = (U32)imagep->getTextureMemory() ; - mTotalBytesUsed += mem_size ; + U32Bytes mem_size = imagep->getTextureMemory(); + mTotalBytesUsed += mem_size; - if(MIN_LARGE_IMAGE_AREA <= (U32)(mem_size / (U32)imagep->getComponents())) + if(MIN_LARGE_IMAGE_AREA <= (U32)(mem_size.value() / (U32)imagep->getComponents())) { - mTotalBytesUsedForLargeImage += mem_size ; + mTotalBytesUsedForLargeImage += mem_size; } } void LLTexturePipelineTester::updateTextureLoadingStats(const LLViewerFetchedTexture* imagep, const LLImageRaw* raw_imagep, BOOL from_cache) { - U32 data_size = (U32)raw_imagep->getDataSize() ; - mTotalBytesLoaded += data_size ; + U32Bytes data_size = (U32Bytes)raw_imagep->getDataSize(); + mTotalBytesLoaded += data_size; if(from_cache) { - mTotalBytesLoadedFromCache += data_size ; + mTotalBytesLoadedFromCache += data_size; } - if(MIN_LARGE_IMAGE_AREA <= (U32)(data_size / (U32)raw_imagep->getComponents())) + if(MIN_LARGE_IMAGE_AREA <= (U32)(data_size.value() / (U32)raw_imagep->getComponents())) { - mTotalBytesLoadedForLargeImage += data_size ; + mTotalBytesLoadedForLargeImage += data_size; } if(imagep->forSculpt()) { - mTotalBytesLoadedForSculpties += data_size ; + mTotalBytesLoadedForSculpties += data_size; if(mStartTimeLoadingSculpties > mEndTimeLoadingSculpties) { - mStartTimeLoadingSculpties = LLImageGL::sLastFrameTime ; + mStartTimeLoadingSculpties = LLImageGL::sLastFrameTime; } - mEndTimeLoadingSculpties = LLImageGL::sLastFrameTime ; + mEndTimeLoadingSculpties = LLImageGL::sLastFrameTime; } } void LLTexturePipelineTester::updateGrayTextureBinding() { - mUsingDefaultTexture = TRUE ; + mUsingDefaultTexture = TRUE; } void LLTexturePipelineTester::setStablizingTime() { if(mStartStablizingTime <= mStartFetchingTime) { - mStartStablizingTime = LLImageGL::sLastFrameTime ; + mStartStablizingTime = LLImageGL::sLastFrameTime; } - mEndStablizingTime = LLImageGL::sLastFrameTime ; + mEndStablizingTime = LLImageGL::sLastFrameTime; } void LLTexturePipelineTester::updateStablizingTime() { if(mStartStablizingTime > mStartFetchingTime) { - F32 t = mEndStablizingTime - mStartStablizingTime ; + F32 t = mEndStablizingTime - mStartStablizingTime; if(t > F_ALMOST_ZERO && (t - mTotalStablizingTime) < F_ALMOST_ZERO) { //already stablized - mTotalStablizingTime = LLImageGL::sLastFrameTime - mStartStablizingTime ; + mTotalStablizingTime = LLImageGL::sLastFrameTime - mStartStablizingTime; //cancel the timer - mStartStablizingTime = 0.f ; - mEndStablizingTime = 0.f ; + mStartStablizingTime = 0.f; + mEndStablizingTime = 0.f; } else { - mTotalStablizingTime = t ; + mTotalStablizingTime = t; } } - mTotalStablizingTime = 0.f ; + mTotalStablizingTime = 0.f; } //virtual void LLTexturePipelineTester::compareTestSessions(std::ofstream* os) { - LLTexturePipelineTester::LLTextureTestSession* base_sessionp = dynamic_cast(mBaseSessionp) ; - LLTexturePipelineTester::LLTextureTestSession* current_sessionp = dynamic_cast(mCurrentSessionp) ; + LLTexturePipelineTester::LLTextureTestSession* base_sessionp = dynamic_cast(mBaseSessionp); + LLTexturePipelineTester::LLTextureTestSession* current_sessionp = dynamic_cast(mCurrentSessionp); if(!base_sessionp || !current_sessionp) { - LL_ERRS() << "type of test session does not match!" << LL_ENDL ; + LL_ERRS() << "type of test session does not match!" << LL_ENDL; } //compare and output the comparison - *os << llformat("%s\n", getTesterName().c_str()) ; - *os << llformat("AggregateResults\n") ; + *os << llformat("%s\n", getTesterName().c_str()); + *os << llformat("AggregateResults\n"); - compareTestResults(os, "TotalFetchingTime", base_sessionp->mTotalFetchingTime, current_sessionp->mTotalFetchingTime) ; - compareTestResults(os, "TotalGrayTime", base_sessionp->mTotalGrayTime, current_sessionp->mTotalGrayTime) ; + compareTestResults(os, "TotalFetchingTime", base_sessionp->mTotalFetchingTime, current_sessionp->mTotalFetchingTime); + compareTestResults(os, "TotalGrayTime", base_sessionp->mTotalGrayTime, current_sessionp->mTotalGrayTime); compareTestResults(os, "TotalStablizingTime", base_sessionp->mTotalStablizingTime, current_sessionp->mTotalStablizingTime); - compareTestResults(os, "StartTimeLoadingSculpties", base_sessionp->mStartTimeLoadingSculpties, current_sessionp->mStartTimeLoadingSculpties) ; - compareTestResults(os, "TotalTimeLoadingSculpties", base_sessionp->mTotalTimeLoadingSculpties, current_sessionp->mTotalTimeLoadingSculpties) ; + compareTestResults(os, "StartTimeLoadingSculpties", base_sessionp->mStartTimeLoadingSculpties, current_sessionp->mStartTimeLoadingSculpties); + compareTestResults(os, "TotalTimeLoadingSculpties", base_sessionp->mTotalTimeLoadingSculpties, current_sessionp->mTotalTimeLoadingSculpties); - compareTestResults(os, "TotalBytesLoaded", base_sessionp->mTotalBytesLoaded, current_sessionp->mTotalBytesLoaded) ; - compareTestResults(os, "TotalBytesLoadedFromCache", base_sessionp->mTotalBytesLoadedFromCache, current_sessionp->mTotalBytesLoadedFromCache) ; - compareTestResults(os, "TotalBytesLoadedForLargeImage", base_sessionp->mTotalBytesLoadedForLargeImage, current_sessionp->mTotalBytesLoadedForLargeImage) ; - compareTestResults(os, "TotalBytesLoadedForSculpties", base_sessionp->mTotalBytesLoadedForSculpties, current_sessionp->mTotalBytesLoadedForSculpties) ; + compareTestResults(os, "TotalBytesLoaded", base_sessionp->mTotalBytesLoaded, current_sessionp->mTotalBytesLoaded); + compareTestResults(os, "TotalBytesLoadedFromCache", base_sessionp->mTotalBytesLoadedFromCache, current_sessionp->mTotalBytesLoadedFromCache); + compareTestResults(os, "TotalBytesLoadedForLargeImage", base_sessionp->mTotalBytesLoadedForLargeImage, current_sessionp->mTotalBytesLoadedForLargeImage); + compareTestResults(os, "TotalBytesLoadedForSculpties", base_sessionp->mTotalBytesLoadedForSculpties, current_sessionp->mTotalBytesLoadedForSculpties); - *os << llformat("InstantResults\n") ; - S32 size = llmin(base_sessionp->mInstantPerformanceListCounter, current_sessionp->mInstantPerformanceListCounter) ; - for(S32 i = 0 ; i < size ; i++) + *os << llformat("InstantResults\n"); + S32 size = llmin(base_sessionp->mInstantPerformanceListCounter, current_sessionp->mInstantPerformanceListCounter); + for(S32 i = 0; i < size; i++) { - *os << llformat("Time(B-T)-%.4f-%.4f\n", base_sessionp->mInstantPerformanceList[i].mTime, current_sessionp->mInstantPerformanceList[i].mTime) ; + *os << llformat("Time(B-T)-%.4f-%.4f\n", base_sessionp->mInstantPerformanceList[i].mTime, current_sessionp->mInstantPerformanceList[i].mTime); compareTestResults(os, "AverageBytesUsedPerSecond", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond, - current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond) ; + current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond); compareTestResults(os, "AverageBytesUsedForLargeImagePerSecond", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond, - current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond) ; + current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond); compareTestResults(os, "AveragePercentageBytesUsedPerSecond", base_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond, - current_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond) ; + current_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond); } if(size < base_sessionp->mInstantPerformanceListCounter) { - for(S32 i = size ; i < base_sessionp->mInstantPerformanceListCounter ; i++) + for(S32 i = size; i < base_sessionp->mInstantPerformanceListCounter; i++) { - *os << llformat("Time(B-T)-%.4f- \n", base_sessionp->mInstantPerformanceList[i].mTime) ; + *os << llformat("Time(B-T)-%.4f- \n", base_sessionp->mInstantPerformanceList[i].mTime); - *os << llformat(", AverageBytesUsedPerSecond, %d, N/A \n", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond) ; - *os << llformat(", AverageBytesUsedForLargeImagePerSecond, %d, N/A \n", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond) ; - *os << llformat(", AveragePercentageBytesUsedPerSecond, %.4f, N/A \n", base_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond) ; + *os << llformat(", AverageBytesUsedPerSecond, %d, N/A \n", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond); + *os << llformat(", AverageBytesUsedForLargeImagePerSecond, %d, N/A \n", base_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond); + *os << llformat(", AveragePercentageBytesUsedPerSecond, %.4f, N/A \n", base_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond); } } else if(size < current_sessionp->mInstantPerformanceListCounter) { - for(S32 i = size ; i < current_sessionp->mInstantPerformanceListCounter ; i++) + for(S32 i = size; i < current_sessionp->mInstantPerformanceListCounter; i++) { - *os << llformat("Time(B-T)- -%.4f\n", current_sessionp->mInstantPerformanceList[i].mTime) ; + *os << llformat("Time(B-T)- -%.4f\n", current_sessionp->mInstantPerformanceList[i].mTime); - *os << llformat(", AverageBytesUsedPerSecond, N/A, %d\n", current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond) ; - *os << llformat(", AverageBytesUsedForLargeImagePerSecond, N/A, %d\n", current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond) ; - *os << llformat(", AveragePercentageBytesUsedPerSecond, N/A, %.4f\n", current_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond) ; + *os << llformat(", AverageBytesUsedPerSecond, N/A, %d\n", current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedPerSecond); + *os << llformat(", AverageBytesUsedForLargeImagePerSecond, N/A, %d\n", current_sessionp->mInstantPerformanceList[i].mAverageBytesUsedForLargeImagePerSecond); + *os << llformat(", AveragePercentageBytesUsedPerSecond, N/A, %.4f\n", current_sessionp->mInstantPerformanceList[i].mAveragePercentageBytesUsedPerSecond); } } } @@ -3781,144 +3781,144 @@ void LLTexturePipelineTester::compareTestSessions(std::ofstream* os) //virtual LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::loadTestSession(LLSD* log) { - LLTexturePipelineTester::LLTextureTestSession* sessionp = new LLTexturePipelineTester::LLTextureTestSession() ; + LLTexturePipelineTester::LLTextureTestSession* sessionp = new LLTexturePipelineTester::LLTextureTestSession(); if(!sessionp) { - return NULL ; + return NULL; } - F32 total_fetching_time = 0.f ; - F32 total_gray_time = 0.f ; - F32 total_stablizing_time = 0.f ; - F32 total_loading_sculpties_time = 0.f ; - - F32 start_fetching_time = -1.f ; - F32 start_fetching_sculpties_time = 0.f ; - - F32 last_time = 0.0f ; - S32 frame_count = 0 ; - - sessionp->mInstantPerformanceListCounter = 0 ; - sessionp->mInstantPerformanceList.resize(128) ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond = 0 ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond = 0 ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond = 0.f ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = 0.f ; + F32 total_fetching_time = 0.f; + F32 total_gray_time = 0.f; + F32 total_stablizing_time = 0.f; + F32 total_loading_sculpties_time = 0.f; + + F32 start_fetching_time = -1.f; + F32 start_fetching_sculpties_time = 0.f; + + F32 last_time = 0.0f; + S32 frame_count = 0; + + sessionp->mInstantPerformanceListCounter = 0; + sessionp->mInstantPerformanceList.resize(128); + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond = 0; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond = 0; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond = 0.f; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = 0.f; //load a session std::string currentLabel = getCurrentLabelName(); - BOOL in_log = (*log).has(currentLabel) ; + BOOL in_log = (*log).has(currentLabel); while (in_log) { - LLSD::String label = currentLabel ; + LLSD::String label = currentLabel; if(sessionp->mInstantPerformanceListCounter >= (S32)sessionp->mInstantPerformanceList.size()) { - sessionp->mInstantPerformanceList.resize(sessionp->mInstantPerformanceListCounter + 128) ; + sessionp->mInstantPerformanceList.resize(sessionp->mInstantPerformanceListCounter + 128); } //time - F32 start_time = (*log)[label]["StartFetchingTime"].asReal() ; - F32 cur_time = (*log)[label]["Time"].asReal() ; + F32 start_time = (*log)[label]["StartFetchingTime"].asReal(); + F32 cur_time = (*log)[label]["Time"].asReal(); if(start_time - start_fetching_time > F_ALMOST_ZERO) //fetching has paused for a while { - sessionp->mTotalFetchingTime += total_fetching_time ; - sessionp->mTotalGrayTime += total_gray_time ; - sessionp->mTotalStablizingTime += total_stablizing_time ; + sessionp->mTotalFetchingTime += total_fetching_time; + sessionp->mTotalGrayTime += total_gray_time; + sessionp->mTotalStablizingTime += total_stablizing_time; - sessionp->mStartTimeLoadingSculpties = start_fetching_sculpties_time ; - sessionp->mTotalTimeLoadingSculpties += total_loading_sculpties_time ; + sessionp->mStartTimeLoadingSculpties = start_fetching_sculpties_time; + sessionp->mTotalTimeLoadingSculpties += total_loading_sculpties_time; - start_fetching_time = start_time ; - total_fetching_time = 0.0f ; - total_gray_time = 0.f ; - total_stablizing_time = 0.f ; - total_loading_sculpties_time = 0.f ; + start_fetching_time = start_time; + total_fetching_time = 0.0f; + total_gray_time = 0.f; + total_stablizing_time = 0.f; + total_loading_sculpties_time = 0.f; } else { - total_fetching_time = cur_time - start_time ; - total_gray_time = (*log)[label]["TotalGrayTime"].asReal() ; - total_stablizing_time = (*log)[label]["TotalStablizingTime"].asReal() ; + total_fetching_time = cur_time - start_time; + total_gray_time = (*log)[label]["TotalGrayTime"].asReal(); + total_stablizing_time = (*log)[label]["TotalStablizingTime"].asReal(); - total_loading_sculpties_time = (*log)[label]["EndTimeLoadingSculpties"].asReal() - (*log)[label]["StartTimeLoadingSculpties"].asReal() ; + total_loading_sculpties_time = (*log)[label]["EndTimeLoadingSculpties"].asReal() - (*log)[label]["StartTimeLoadingSculpties"].asReal(); if(start_fetching_sculpties_time < 0.f && total_loading_sculpties_time > 0.f) { - start_fetching_sculpties_time = (*log)[label]["StartTimeLoadingSculpties"].asReal() ; + start_fetching_sculpties_time = (*log)[label]["StartTimeLoadingSculpties"].asReal(); } } //total loaded bytes - sessionp->mTotalBytesLoaded = (*log)[label]["TotalBytesLoaded"].asInteger() ; - sessionp->mTotalBytesLoadedFromCache = (*log)[label]["TotalBytesLoadedFromCache"].asInteger() ; - sessionp->mTotalBytesLoadedForLargeImage = (*log)[label]["TotalBytesLoadedForLargeImage"].asInteger() ; - sessionp->mTotalBytesLoadedForSculpties = (*log)[label]["TotalBytesLoadedForSculpties"].asInteger() ; + sessionp->mTotalBytesLoaded = (*log)[label]["TotalBytesLoaded"].asInteger(); + sessionp->mTotalBytesLoadedFromCache = (*log)[label]["TotalBytesLoadedFromCache"].asInteger(); + sessionp->mTotalBytesLoadedForLargeImage = (*log)[label]["TotalBytesLoadedForLargeImage"].asInteger(); + sessionp->mTotalBytesLoadedForSculpties = (*log)[label]["TotalBytesLoadedForSculpties"].asInteger(); //instant metrics sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond += - (*log)[label]["TotalBytesBound"].asInteger() ; + (*log)[label]["TotalBytesBound"].asInteger(); sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond += - (*log)[label]["TotalBytesBoundForLargeImage"].asInteger() ; + (*log)[label]["TotalBytesBoundForLargeImage"].asInteger(); sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond += - (*log)[label]["PercentageBytesBound"].asReal() ; - frame_count++ ; + (*log)[label]["PercentageBytesBound"].asReal(); + frame_count++; if(cur_time - last_time >= 1.0f) { - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond /= frame_count ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond /= frame_count ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond /= frame_count ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = last_time ; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond /= frame_count; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond /= frame_count; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond /= frame_count; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = last_time; - frame_count = 0 ; - last_time = cur_time ; - sessionp->mInstantPerformanceListCounter++ ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond = 0 ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond = 0 ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond = 0.f ; - sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = 0.f ; + frame_count = 0; + last_time = cur_time; + sessionp->mInstantPerformanceListCounter++; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedPerSecond = 0; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond = 0; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond = 0.f; + sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mTime = 0.f; } // Next label - incrementCurrentCount() ; + incrementCurrentCount(); currentLabel = getCurrentLabelName(); - in_log = (*log).has(currentLabel) ; + in_log = (*log).has(currentLabel); } - sessionp->mTotalFetchingTime += total_fetching_time ; - sessionp->mTotalGrayTime += total_gray_time ; - sessionp->mTotalStablizingTime += total_stablizing_time ; + sessionp->mTotalFetchingTime += total_fetching_time; + sessionp->mTotalGrayTime += total_gray_time; + sessionp->mTotalStablizingTime += total_stablizing_time; if(sessionp->mStartTimeLoadingSculpties < 0.f) { - sessionp->mStartTimeLoadingSculpties = start_fetching_sculpties_time ; + sessionp->mStartTimeLoadingSculpties = start_fetching_sculpties_time; } - sessionp->mTotalTimeLoadingSculpties += total_loading_sculpties_time ; + sessionp->mTotalTimeLoadingSculpties += total_loading_sculpties_time; return sessionp; } LLTexturePipelineTester::LLTextureTestSession::LLTextureTestSession() { - reset() ; + reset(); } LLTexturePipelineTester::LLTextureTestSession::~LLTextureTestSession() { } void LLTexturePipelineTester::LLTextureTestSession::reset() { - mTotalFetchingTime = 0.0f ; + mTotalFetchingTime = 0.0f; - mTotalGrayTime = 0.0f ; - mTotalStablizingTime = 0.0f ; + mTotalGrayTime = 0.0f; + mTotalStablizingTime = 0.0f; - mStartTimeLoadingSculpties = 0.0f ; - mTotalTimeLoadingSculpties = 0.0f ; + mStartTimeLoadingSculpties = 0.0f; + mTotalTimeLoadingSculpties = 0.0f; - mTotalBytesLoaded = 0 ; - mTotalBytesLoadedFromCache = 0 ; - mTotalBytesLoadedForLargeImage = 0 ; - mTotalBytesLoadedForSculpties = 0 ; + mTotalBytesLoaded = 0; + mTotalBytesLoadedFromCache = 0; + mTotalBytesLoadedForLargeImage = 0; + mTotalBytesLoadedForSculpties = 0; - mInstantPerformanceListCounter = 0 ; + mInstantPerformanceListCounter = 0; } //---------------------------------------------------------------------------------------------- //end of LLTexturePipelineTester diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 9a00ccd8c6..b12b988513 100755 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -38,8 +38,8 @@ #include #include -extern const S32Mibibytes gMinVideoRam; -extern const S32Mibibytes gMaxVideoRam; +extern const S32Megabytes gMinVideoRam; +extern const S32Megabytes gMaxVideoRam; class LLImageGL ; class LLImageRaw; @@ -207,8 +207,8 @@ public: static F32 sDesiredDiscardScale; static S32Bytes sBoundTextureMemory; static S32Bytes sTotalTextureMemory; - static S32Mibibytes sMaxBoundTextureMem; - static S32Mibibytes sMaxTotalTextureMem; + static S32Megabytes sMaxBoundTextureMem; + static S32Megabytes sMaxTotalTextureMem; static S32Bytes sMaxDesiredTextureMem ; static S8 sCameraMovingDiscardBias; static F32 sCameraMovingBias; @@ -690,18 +690,18 @@ private: private: BOOL mUsingDefaultTexture; //if set, some textures are still gray. - U32 mTotalBytesUsed ; //total bytes of textures bound/used for the current frame. - U32 mTotalBytesUsedForLargeImage ; //total bytes of textures bound/used for the current frame for images larger than 256 * 256. - U32 mLastTotalBytesUsed ; //total bytes of textures bound/used for the previous frame. - U32 mLastTotalBytesUsedForLargeImage ; //total bytes of textures bound/used for the previous frame for images larger than 256 * 256. + U32Bytes mTotalBytesUsed ; //total bytes of textures bound/used for the current frame. + U32Bytes mTotalBytesUsedForLargeImage ; //total bytes of textures bound/used for the current frame for images larger than 256 * 256. + U32Bytes mLastTotalBytesUsed ; //total bytes of textures bound/used for the previous frame. + U32Bytes mLastTotalBytesUsedForLargeImage ; //total bytes of textures bound/used for the previous frame for images larger than 256 * 256. // //data size // - U32 mTotalBytesLoaded ; //total bytes fetched by texture pipeline - U32 mTotalBytesLoadedFromCache ; //total bytes fetched by texture pipeline from local cache - U32 mTotalBytesLoadedForLargeImage ; //total bytes fetched by texture pipeline for images larger than 256 * 256. - U32 mTotalBytesLoadedForSculpties ; //total bytes fetched by texture pipeline for sculpties + U32Bytes mTotalBytesLoaded ; //total bytes fetched by texture pipeline + U32Bytes mTotalBytesLoadedFromCache ; //total bytes fetched by texture pipeline from local cache + U32Bytes mTotalBytesLoadedForLargeImage ; //total bytes fetched by texture pipeline for images larger than 256 * 256. + U32Bytes mTotalBytesLoadedForSculpties ; //total bytes fetched by texture pipeline for sculpties // //time diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index f4dc04bd51..21da915f97 100755 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -85,11 +85,11 @@ void LLViewerTextureList::init() mInitialized = TRUE ; sNumImages = 0; mUpdateStats = TRUE; - mMaxResidentTexMemInMegaBytes = 0; - mMaxTotalTextureMemInMegaBytes = 0 ; + mMaxResidentTexMemInMegaBytes = (U32Bytes)0; + mMaxTotalTextureMemInMegaBytes = (U32Bytes)0; // Update how much texture RAM we're allowed to use. - updateMaxResidentTexMem(S32Mibibytes(0)); // 0 = use current + updateMaxResidentTexMem(S32Megabytes(0)); // 0 = use current doPreloadImages(); } @@ -662,7 +662,7 @@ void LLViewerTextureList::updateImages(F32 max_time) } cleared = FALSE; - LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED)); + LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED).value()); { using namespace LLStatViewer; @@ -1231,23 +1231,23 @@ const S32 MIN_VIDEO_RAM = 32; const S32 MAX_VIDEO_RAM = 512; // 512MB max for performance reasons. // Returns min setting for TextureMemory (in MB) -S32Mibibytes LLViewerTextureList::getMinVideoRamSetting() +S32Megabytes LLViewerTextureList::getMinVideoRamSetting() { - S32Mibibytes system_ram = gSysMemory.getPhysicalMemoryClamped(); + S32Megabytes system_ram = gSysMemory.getPhysicalMemoryClamped(); //min texture mem sets to 64M if total physical mem is more than 1.5GB - return (system_ram > S32Mibibytes(1500)) ? S32Mibibytes(64) : gMinVideoRam ; + return (system_ram > S32Megabytes(1500)) ? S32Megabytes(64) : gMinVideoRam ; } //static // Returns max setting for TextureMemory (in MB) -S32Mibibytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) +S32Megabytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) { - S32Mibibytes max_texmem; + S32Megabytes max_texmem; if (gGLManager.mVRAM != 0) { // Treat any card with < 32 MB (shudder) as having 32 MB // - it's going to be swapping constantly regardless - S32Mibibytes max_vram(gGLManager.mVRAM); + S32Megabytes max_vram(gGLManager.mVRAM); if(gGLManager.mIsATI) { @@ -1264,21 +1264,21 @@ S32Mibibytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) { if (!get_recommended) { - max_texmem = 512; + max_texmem = (S32Megabytes)512; } else if (gSavedSettings.getBOOL("NoHardwareProbe")) //did not do hardware detection at startup { - max_texmem = 512; + max_texmem = (S32Megabytes)512; } else { - max_texmem = 128; + max_texmem = (S32Megabytes)128; } LL_WARNS() << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << LL_ENDL; } - S32Mibibytes system_ram = gSysMemory.getPhysicalMemoryClamped(); // In MB + S32Megabytes system_ram = gSysMemory.getPhysicalMemoryClamped(); // In MB //LL_INFOS() << "*** DETECTED " << system_ram << " MB of system memory." << LL_ENDL; if (get_recommended) max_texmem = llmin(max_texmem, system_ram/2); @@ -1290,25 +1290,25 @@ S32Mibibytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended) return max_texmem; } -const S32Mibibytes VIDEO_CARD_FRAMEBUFFER_MEM(12); -const S32Mibibytes MIN_MEM_FOR_NON_TEXTURE(512); -void LLViewerTextureList::updateMaxResidentTexMem(S32Mibibytes mem) +const S32Megabytes VIDEO_CARD_FRAMEBUFFER_MEM(12); +const S32Megabytes MIN_MEM_FOR_NON_TEXTURE(512); +void LLViewerTextureList::updateMaxResidentTexMem(S32Megabytes mem) { // Initialize the image pipeline VRAM settings - S32Mibibytes cur_mem(gSavedSettings.getS32("TextureMemory")); + S32Megabytes cur_mem(gSavedSettings.getS32("TextureMemory")); F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple"); - S32Mibibytes default_mem(getMaxVideoRamSetting(true)); // recommended default - if (mem == 0) + S32Megabytes default_mem(getMaxVideoRamSetting(true)); // recommended default + if (mem == (S32Bytes)0) { - mem = cur_mem > 0 ? cur_mem : default_mem; + mem = cur_mem > (S32Bytes)0 ? cur_mem : default_mem; } - else if (mem < 0) + else if (mem < (S32Bytes)0) { mem = default_mem; } // limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise - mem = llmin(mem, S32Mibibytes(mem_multiplier * (F32Mibibytes)default_mem)); + mem = llmin(mem, S32Megabytes(mem_multiplier * (F32Megabytes)default_mem)); mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting()); if (mem != cur_mem) @@ -1320,23 +1320,23 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32Mibibytes mem) // TODO: set available resident texture mem based on use by other subsystems // currently max(12MB, VRAM/4) assumed... - S32Mibibytes vb_mem = mem; - S32Mibibytes fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4); + S32Megabytes vb_mem = mem; + S32Megabytes fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4); mMaxResidentTexMemInMegaBytes = (vb_mem - fb_mem) ; //in MB mMaxTotalTextureMemInMegaBytes = mMaxResidentTexMemInMegaBytes * 2; - if (mMaxResidentTexMemInMegaBytes > 640) + if (mMaxResidentTexMemInMegaBytes > (S32Megabytes)640) { mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes / 4); } //system mem - S32Mibibytes system_ram = gSysMemory.getPhysicalMemoryClamped(); + S32Megabytes system_ram = gSysMemory.getPhysicalMemoryClamped(); //minimum memory reserved for non-texture use. //if system_raw >= 1GB, reserve at least 512MB for non-texture use; //otherwise reserve half of the system_ram for non-texture use. - S32Mibibytes min_non_texture_mem = llmin(system_ram / 2, MIN_MEM_FOR_NON_TEXTURE) ; + S32Megabytes min_non_texture_mem = llmin(system_ram / 2, MIN_MEM_FOR_NON_TEXTURE) ; if (mMaxTotalTextureMemInMegaBytes > system_ram - min_non_texture_mem) { @@ -1364,16 +1364,16 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d char ip_string[256]; u32_to_ip_string(msg->getSenderIP(),ip_string); - U32 received_size ; + U32Bytes received_size ; if (msg->getReceiveCompressedSize()) { - received_size = msg->getReceiveCompressedSize() ; + received_size = (U32Bytes)msg->getReceiveCompressedSize() ; } else { - received_size = msg->getReceiveSize() ; + received_size = (U32Bytes)msg->getReceiveSize() ; } - add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, F64Bytes(received_size)); + add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, received_size); add(LLStatViewer::TEXTURE_PACKETS, 1); U8 codec; @@ -1437,14 +1437,14 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d char ip_string[256]; u32_to_ip_string(msg->getSenderIP(),ip_string); - U32 received_size ; + U32Bytes received_size ; if (msg->getReceiveCompressedSize()) { - received_size = msg->getReceiveCompressedSize() ; + received_size = (U32Bytes)msg->getReceiveCompressedSize() ; } else { - received_size = msg->getReceiveSize() ; + received_size = (U32Bytes)msg->getReceiveSize() ; } add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, F64Bytes(received_size)); @@ -1511,24 +1511,6 @@ void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void ** } } -/////////////////////////////////////////////////////////////////////////////// - -//static -const LLUnitImplicit SIXTEEN_MEG(16); -S32Bytes LLViewerTextureList::calcMaxTextureRAM() -{ - // Decide the maximum amount of RAM we should allow the user to allocate to texture cache - LLMemoryInfo memory_info; - LLUnitImplicit available_memory = memory_info.getPhysicalMemoryClamped(); - - // as originally written, this code was a no-op. Not sure of the side effect of making it actually work - /*clamp_rescale(available_memory.value(), - (SIXTEEN_MEG * 16), - (F32Mibibytes)U32_MAX, - (SIXTEEN_MEG * 4), - (F32Mibibytes)(U32_MAX >> 1));*/ - return available_memory; -} /////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index 9817fea811..835d750d94 100755 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -71,7 +71,6 @@ public: static BOOL createUploadFile(const std::string& filename, const std::string& out_filename, const U8 codec); static LLPointer convertToUploadFile(LLPointer raw_image); static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data ); - static S32Bytes calcMaxTextureRAM(); static void receiveImageHeader(LLMessageSystem *msg, void **user_data); static void receiveImagePacket(LLMessageSystem *msg, void **user_data); @@ -101,11 +100,11 @@ public: void setUpdateStats(BOOL b) { mUpdateStats = b; } - S32Mibibytes getMaxResidentTexMem() const { return mMaxResidentTexMemInMegaBytes; } - S32Mibibytes getMaxTotalTextureMem() const { return mMaxTotalTextureMemInMegaBytes;} + S32Megabytes getMaxResidentTexMem() const { return mMaxResidentTexMemInMegaBytes; } + S32Megabytes getMaxTotalTextureMem() const { return mMaxTotalTextureMemInMegaBytes;} S32 getNumImages() { return mImageList.size(); } - void updateMaxResidentTexMem(S32Mibibytes mem); + void updateMaxResidentTexMem(S32Megabytes mem); void doPreloadImages(); void doPrefetchImages(); @@ -113,8 +112,8 @@ public: void clearFetchingRequests(); void setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level); - static S32Mibibytes getMinVideoRamSetting(); - static S32Mibibytes getMaxVideoRamSetting(bool get_recommended = false); + static S32Megabytes getMinVideoRamSetting(); + static S32Megabytes getMaxVideoRamSetting(bool get_recommended = false); private: void updateImagesDecodePriorities(); @@ -200,8 +199,8 @@ private: BOOL mInitialized ; BOOL mUpdateStats; - S32Mibibytes mMaxResidentTexMemInMegaBytes; - S32Mibibytes mMaxTotalTextureMemInMegaBytes; + S32Megabytes mMaxResidentTexMemInMegaBytes; + S32Megabytes mMaxTotalTextureMemInMegaBytes; LLFrameTimer mForceDecodeTimer; private: diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 1e60b59932..5509c6e0e5 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -736,9 +736,9 @@ public: U32 old_y = ypos ; for(S32 i = LLViewerTexture::BOOST_NONE; i < LLViewerTexture::MAX_GL_IMAGE_CATEGORY; i++) { - if(gTotalTextureBytesPerBoostLevel[i] > 0) + if(gTotalTextureBytesPerBoostLevel[i] > (S32Bytes)0) { - addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, F32Mibibytes(gTotalTextureBytesPerBoostLevel[i]).value())); + addText(xpos, ypos, llformat("Boost_Level %d: %.3f MB", i, F32Megabytes(gTotalTextureBytesPerBoostLevel[i]).value())); ypos += y_inc; } } diff --git a/indra/newview/llvlmanager.cpp b/indra/newview/llvlmanager.cpp index 9b55bbf277..895ceed880 100755 --- a/indra/newview/llvlmanager.cpp +++ b/indra/newview/llvlmanager.cpp @@ -52,19 +52,19 @@ LLVLManager::~LLVLManager() mPacketData.clear(); } -void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size) +void LLVLManager::addLayerData(LLVLData *vl_datap, const S32Bytes mesg_size) { if (LAND_LAYER_CODE == vl_datap->mType) { - mLandBits += mesg_size * 8; + mLandBits += mesg_size; } else if (WIND_LAYER_CODE == vl_datap->mType) { - mWindBits += mesg_size * 8; + mWindBits += mesg_size; } else if (CLOUD_LAYER_CODE == vl_datap->mType) { - mCloudBits += mesg_size * 8; + mCloudBits += mesg_size; } else { @@ -112,25 +112,25 @@ void LLVLManager::unpackData(const S32 num_packets) void LLVLManager::resetBitCounts() { - mLandBits = mWindBits = mCloudBits = 0; + mLandBits = mWindBits = mCloudBits = (S32Bits)0; } -S32 LLVLManager::getLandBits() const +U32Bits LLVLManager::getLandBits() const { return mLandBits; } -S32 LLVLManager::getWindBits() const +U32Bits LLVLManager::getWindBits() const { return mWindBits; } -S32 LLVLManager::getCloudBits() const +U32Bits LLVLManager::getCloudBits() const { return mCloudBits; } -S32 LLVLManager::getTotalBytes() const +S32Bytes LLVLManager::getTotalBytes() const { return mLandBits + mWindBits + mCloudBits; } diff --git a/indra/newview/llvlmanager.h b/indra/newview/llvlmanager.h index 0733aebaae..5e7fadc522 100755 --- a/indra/newview/llvlmanager.h +++ b/indra/newview/llvlmanager.h @@ -39,15 +39,15 @@ class LLVLManager public: ~LLVLManager(); - void addLayerData(LLVLData *vl_datap, const S32 mesg_size); + void addLayerData(LLVLData *vl_datap, const S32Bytes mesg_size); void unpackData(const S32 num_packets = 10); - S32 getTotalBytes() const; + S32Bytes getTotalBytes() const; - S32 getLandBits() const; - S32 getWindBits() const; - S32 getCloudBits() const; + U32Bits getLandBits() const; + U32Bits getWindBits() const; + U32Bits getCloudBits() const; void resetBitCounts(); @@ -55,9 +55,9 @@ public: protected: std::vector mPacketData; - U32 mLandBits; - U32 mWindBits; - U32 mCloudBits; + U32Bits mLandBits; + U32Bits mWindBits; + U32Bits mCloudBits; }; class LLVLData diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 5971da95ce..724ba3c85e 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -4175,9 +4175,9 @@ std::string LLVOAvatar::bakedTextureOriginInfo() return result; } -S32 LLVOAvatar::totalTextureMemForUUIDS(std::set& ids) +S32Bytes LLVOAvatar::totalTextureMemForUUIDS(std::set& ids) { - S32 result = 0; + S32Bytes result(0); for (std::set::const_iterator it = ids.begin(); it != ids.end(); ++it) { LLViewerFetchedTexture *imagep = gTextureList.findImage(*it); @@ -4242,12 +4242,12 @@ void LLVOAvatar::collectTextureUUIDs(std::set& ids) void LLVOAvatar::releaseOldTextures() { - S32 current_texture_mem = 0; + S32Bytes current_texture_mem; // Any textures that we used to be using but are no longer using should no longer be flagged as "NO_DELETE" std::set baked_texture_ids; collectBakedTextureUUIDs(baked_texture_ids); - S32 new_baked_mem = totalTextureMemForUUIDS(baked_texture_ids); + S32Bytes new_baked_mem = totalTextureMemForUUIDS(baked_texture_ids); std::set local_texture_ids; collectLocalTextureUUIDs(local_texture_ids); @@ -4256,7 +4256,7 @@ void LLVOAvatar::releaseOldTextures() std::set new_texture_ids; new_texture_ids.insert(baked_texture_ids.begin(),baked_texture_ids.end()); new_texture_ids.insert(local_texture_ids.begin(),local_texture_ids.end()); - S32 new_total_mem = totalTextureMemForUUIDS(new_texture_ids); + S32Bytes new_total_mem = totalTextureMemForUUIDS(new_texture_ids); //S32 old_total_mem = totalTextureMemForUUIDS(mTextureIDs); //LL_DEBUGS("Avatar") << getFullname() << " old_total_mem: " << old_total_mem << " new_total_mem (L/B): " << new_total_mem << " (" << new_local_mem <<", " << new_baked_mem << ")" << LL_ENDL; diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 2c86ed63d1..b600d2a8f1 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -128,29 +128,29 @@ protected: public: /*virtual*/ void updateGL(); /*virtual*/ LLVOAvatar* asAvatar(); - virtual U32 processUpdateMessage(LLMessageSystem *mesgsys, - void **user_data, - U32 block_num, - const EObjectUpdateType update_type, - LLDataPacker *dp); - virtual void idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); + virtual U32 processUpdateMessage(LLMessageSystem *mesgsys, + void **user_data, + U32 block_num, + const EObjectUpdateType update_type, + LLDataPacker *dp); + virtual void idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); /*virtual*/ BOOL updateLOD(); - BOOL updateJointLODs(); - void updateLODRiggedAttachments( void ); + BOOL updateJointLODs(); + void updateLODRiggedAttachments( void ); /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. - S32 totalTextureMemForUUIDS(std::set& ids); - bool allTexturesCompletelyDownloaded(std::set& ids) const; - bool allLocalTexturesCompletelyDownloaded() const; - bool allBakedTexturesCompletelyDownloaded() const; - void bakedTextureOriginCounts(S32 &sb_count, S32 &host_count, - S32 &both_count, S32 &neither_count); - std::string bakedTextureOriginInfo(); - void collectLocalTextureUUIDs(std::set& ids) const; - void collectBakedTextureUUIDs(std::set& ids) const; - void collectTextureUUIDs(std::set& ids); - void releaseOldTextures(); + S32Bytes totalTextureMemForUUIDS(std::set& ids); + bool allTexturesCompletelyDownloaded(std::set& ids) const; + bool allLocalTexturesCompletelyDownloaded() const; + bool allBakedTexturesCompletelyDownloaded() const; + void bakedTextureOriginCounts(S32 &sb_count, S32 &host_count, + S32 &both_count, S32 &neither_count); + std::string bakedTextureOriginInfo(); + void collectLocalTextureUUIDs(std::set& ids) const; + void collectBakedTextureUUIDs(std::set& ids) const; + void collectTextureUUIDs(std::set& ids); + void releaseOldTextures(); /*virtual*/ void updateTextures(); - LLViewerFetchedTexture* getBakedTextureImage(const U8 te, const LLUUID& uuid); + LLViewerFetchedTexture* getBakedTextureImage(const U8 te, const LLUUID& uuid); /*virtual*/ S32 setTETexture(const U8 te, const LLUUID& uuid); // If setting a baked texture, need to request it from a non-local sim. /*virtual*/ void onShift(const LLVector4a& shift_vector); /*virtual*/ U32 getPartitionType() const; diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index db6d2d6fe9..e36bed3e5b 100755 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -142,7 +142,7 @@ struct LocalTextureData //----------------------------------------------------------------------------- // Static Data //----------------------------------------------------------------------------- -S32 LLVOAvatarSelf::sScratchTexBytes = 0; +S32Bytes LLVOAvatarSelf::sScratchTexBytes(0); std::map< LLGLenum, LLGLuint*> LLVOAvatarSelf::sScratchTexNames; @@ -3067,13 +3067,13 @@ void LLVOAvatarSelf::deleteScratchTextures() stop_glerror(); } - if( sScratchTexBytes ) + if( sScratchTexBytes.value() ) { - LL_DEBUGS() << "Clearing Scratch Textures " << (sScratchTexBytes/1024) << "KB" << LL_ENDL; + LL_DEBUGS() << "Clearing Scratch Textures " << (S32Kilobytes)sScratchTexBytes << LL_ENDL; delete_and_clear(sScratchTexNames); LLImageGL::sGlobalTextureMemory -= sScratchTexBytes; - sScratchTexBytes = 0; + sScratchTexBytes = S32Bytes(0); } } diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index be98f8dfa9..9e9e2b61d7 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -276,7 +276,7 @@ public: public: static void deleteScratchTextures(); private: - static S32 sScratchTexBytes; + static S32Bytes sScratchTexBytes; static std::map< LLGLenum, LLGLuint*> sScratchTexNames; /** Textures diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 1f346b2928..e226583097 100755 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -46,7 +46,7 @@ const F32 MAX_PART_LIFETIME = 120.f; -extern LLUnitImplicit gFrameTime; +extern U64MicrosecondsImplicit gFrameTime; LLPointer LLVOPartGroup::sVB = NULL; S32 LLVOPartGroup::sVBSlotFree[]; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 9d727dafbe..2c160754a6 100755 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -727,7 +727,7 @@ void LLWorld::updateNetStats() regionp->updateNetStats(); bits += regionp->mBitsReceived; packets += llfloor( regionp->mPacketsReceived ); - regionp->mBitsReceived = 0.f; + regionp->mBitsReceived = (F32Bits)0.f; regionp->mPacketsReceived = 0.f; } @@ -977,12 +977,12 @@ LLViewerTexture* LLWorld::getDefaultWaterTexture() return mDefaultWaterTexturep; } -void LLWorld::setSpaceTimeUSec(const LLUnitImplicit space_time_usec) +void LLWorld::setSpaceTimeUSec(const U64MicrosecondsImplicit space_time_usec) { mSpaceTimeUSec = space_time_usec; } -LLUnitImplicit LLWorld::getSpaceTimeUSec() const +U64MicrosecondsImplicit LLWorld::getSpaceTimeUSec() const { return mSpaceTimeUSec; } diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h index c74ac3fa6f..287e41d323 100755 --- a/indra/newview/llworld.h +++ b/indra/newview/llworld.h @@ -141,8 +141,8 @@ public: void waterHeightRegionInfo(std::string const& sim_name, F32 water_height); void shiftRegions(const LLVector3& offset); - void setSpaceTimeUSec(const LLUnitImplicit space_time_usec); - LLUnitImplicit getSpaceTimeUSec() const; + void setSpaceTimeUSec(const U64MicrosecondsImplicit space_time_usec); + U64MicrosecondsImplicit getSpaceTimeUSec() const; void getInfo(LLSD& info); U32 getNumOfActiveCachedObjects() const {return mNumOfActiveCachedObjects;} @@ -189,7 +189,7 @@ private: S32 mLastPacketsOut; S32 mLastPacketsLost; U32 mNumOfActiveCachedObjects; - LLUnitImplicit mSpaceTimeUSec; + U64MicrosecondsImplicit mSpaceTimeUSec; BOOL mClassicCloudsEnabled; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6754918149..a64747742f 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3015,7 +3015,7 @@ void LLPipeline::updateGeom(F32 max_dtime) S32 count = 0; - max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnitImplicit(max_dtime)); + max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, F32SecondsImplicit(max_dtime)); LLSpatialGroup* last_group = NULL; LLSpatialBridge* last_bridge = NULL; -- cgit v1.3 From 2c6bc5afa59a88136fd6de4ebf0cb99ea7cdef3f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 14:06:57 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms made getPrimaryAccumulator return a reference since it was an always non-null pointer changed unit conversion to perform lazy division in order to avoid truncation of timer values --- indra/llcommon/llerror.h | 2 + indra/llcommon/llfasttimer.cpp | 28 ++-- indra/llcommon/llfasttimer.h | 20 +-- indra/llcommon/llmemory.cpp | 2 +- indra/llcommon/lltimer.cpp | 92 ++++++----- indra/llcommon/lltimer.h | 4 +- indra/llcommon/lltrace.cpp | 2 +- indra/llcommon/lltrace.h | 100 ++++-------- indra/llcommon/lltraceaccumulators.cpp | 14 +- indra/llcommon/lltraceaccumulators.h | 3 + indra/llcommon/lltracethreadrecorder.cpp | 6 +- indra/llcommon/llunit.h | 180 +++++++++++---------- indra/llcommon/tests/llunits_test.cpp | 23 ++- indra/llui/llstatbar.cpp | 24 +-- indra/llui/llstatbar.h | 2 +- indra/newview/llviewerobject.cpp | 9 +- .../newview/skins/default/xui/en/floater_stats.xml | 88 ++++------ 17 files changed, 296 insertions(+), 303 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index af76a7653a..6eaab450ed 100755 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -346,6 +346,8 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; #define LL_INFOS(...) lllog(LLError::LEVEL_INFO, false, ##__VA_ARGS__) #define LL_WARNS(...) lllog(LLError::LEVEL_WARN, false, ##__VA_ARGS__) #define LL_ERRS(...) lllog(LLError::LEVEL_ERROR, false, ##__VA_ARGS__) +// alternative to llassert_always that prints explanatory message +#define LL_ERRS_IF(exp, ...) if (exp) LL_ERRS(##__VA_ARGS__) << "(" #exp ")" // Only print the log message once (good for warnings or infos that would otherwise // spam the log file over and over, such as tighter loops). diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index d99c4c990e..ae3234a87a 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -189,15 +189,15 @@ void TimeBlock::bootstrapTimerTree() // when this timer was called if (timer.getParent() == &TimeBlock::getRootTimeBlock()) { - TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); - if (accumulator->mLastCaller) + if (accumulator.mLastCaller) { - timer.setParent(accumulator->mLastCaller); - accumulator->mParent = accumulator->mLastCaller; + timer.setParent(accumulator.mLastCaller); + accumulator.mParent = accumulator.mLastCaller; } // no need to push up tree on first use, flag can be set spuriously - accumulator->mMoveUpTree = false; + accumulator.mMoveUpTree = false; } } } @@ -223,17 +223,17 @@ void TimeBlock::incrementalUpdateTimerTree() // skip root timer if (timerp != &TimeBlock::getRootTimeBlock()) { - TimeBlockAccumulator* accumulator = timerp->getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator(); - if (accumulator->mMoveUpTree) + if (accumulator.mMoveUpTree) { // since ancestors have already been visited, re-parenting won't affect tree traversal //step up tree, bringing our descendants with us LL_DEBUGS("FastTimers") << "Moving " << timerp->getName() << " from child of " << timerp->getParent()->getName() << " to child of " << timerp->getParent()->getParent()->getName() << LL_ENDL; timerp->setParent(timerp->getParent()->getParent()); - accumulator->mParent = timerp->getParent(); - accumulator->mMoveUpTree = false; + accumulator.mParent = timerp->getParent(); + accumulator.mMoveUpTree = false; // don't bubble up any ancestors until descendants are done bubbling up // as ancestors may call this timer only on certain paths, so we want to resolve @@ -253,7 +253,7 @@ void TimeBlock::updateTimes() U64 cur_time = getCPUClockCount64(); BlockTimer* cur_timer = stack_record->mActiveTimer; - TimeBlockAccumulator* accumulator = stack_record->mTimeBlock->getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = &stack_record->mTimeBlock->getPrimaryAccumulator(); while(cur_timer && cur_timer->mParentTimerData.mActiveTimer != cur_timer) // root defined by parent pointing to self @@ -269,7 +269,7 @@ void TimeBlock::updateTimes() cur_timer->mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter; stack_record = &cur_timer->mParentTimerData; - accumulator = stack_record->mTimeBlock->getPrimaryAccumulator(); + accumulator = &stack_record->mTimeBlock->getPrimaryAccumulator(); cur_timer = stack_record->mActiveTimer; stack_record->mChildTime += cumulative_time_delta; @@ -299,10 +299,10 @@ void TimeBlock::processTimes() ++it) { TimeBlock& timer = *it; - TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); - accumulator->mLastCaller = NULL; - accumulator->mMoveUpTree = false; + accumulator.mLastCaller = NULL; + accumulator.mMoveUpTree = false; } } diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index ccf71c3f4c..7bad6134c5 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -257,11 +257,11 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) #if FAST_TIMER_ON BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator* accumulator = timer.getPrimaryAccumulator(); - accumulator->mActiveCount++; - mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter; + TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + accumulator.mActiveCount++; + mBlockStartTotalTimeCounter = accumulator.mTotalTimeCounter; // keep current parent as long as it is active when we are - accumulator->mMoveUpTree |= (accumulator->mParent->getPrimaryAccumulator()->mActiveCount == 0); + accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); // store top of stack mParentTimerData = *cur_timer_data; @@ -281,16 +281,16 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator* accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); - accumulator->mCalls++; - accumulator->mTotalTimeCounter += total_time - (accumulator->mTotalTimeCounter - mBlockStartTotalTimeCounter); - accumulator->mSelfTimeCounter += total_time - cur_timer_data->mChildTime; - accumulator->mActiveCount--; + accumulator.mCalls++; + accumulator.mTotalTimeCounter += total_time - (accumulator.mTotalTimeCounter - mBlockStartTotalTimeCounter); + accumulator.mSelfTimeCounter += total_time - cur_timer_data->mChildTime; + accumulator.mActiveCount--; // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - accumulator->mLastCaller = mParentTimerData.mTimeBlock; + accumulator.mLastCaller = mParentTimerData.mTimeBlock; // we are only tracking self time, so subtract our total time delta from parents mParentTimerData.mChildTime += total_time; diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 4b21fa3bda..06334c012a 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -130,7 +130,7 @@ void LLMemory::updateMemoryInfo() } #else //not valid for other systems for now. - sAllocatedMemInKB = (U32)(LLMemory::getCurrentRSS() / 1024) ; + sAllocatedMemInKB = (U32Bytes)LLMemory::getCurrentRSS(); sMaxPhysicalMemInKB = (U32Bytes)U32_MAX ; sAvailPhysicalMemInKB = (U32Bytes)U32_MAX ; #endif diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index da9d2b646c..9baac20be9 100755 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -55,11 +55,6 @@ const F64 USEC_TO_SEC_F64 = 0.000001; S32 gUTCOffset = 0; // viewer's offset from server UTC, in seconds LLTimer* LLTimer::sTimer = NULL; -F64 gClockFrequency = 0.0; -F64 gClockFrequencyInv = 0.0; -F64 gClocksToMicroseconds = 0.0; -U64 gTotalTimeClockCount = 0; -U64 gLastTotalTimeClockCount = 0; // // Forward declarations @@ -213,56 +208,76 @@ U64 get_clock_count() #endif -void update_clock_frequencies() +struct TimerInfo { - gClockFrequency = calc_clock_frequency(50U); - gClockFrequencyInv = 1.0/gClockFrequency; - gClocksToMicroseconds = gClockFrequencyInv * SEC_TO_MICROSEC; -} + TimerInfo() + : mClockFrequency(0.0), + mTotalTimeClockCount(0), + mLastTotalTimeClockCount(0) + {} + + void update() + { + mClockFrequency = calc_clock_frequency(50U); + mClockFrequencyInv = 1.0/mClockFrequency; + mClocksToMicroseconds = mClockFrequencyInv; + } + F64 mClockFrequency; + F64SecondsImplicit mClockFrequencyInv; + F64MicrosecondsImplicit mClocksToMicroseconds; + U64 mTotalTimeClockCount; + U64 mLastTotalTimeClockCount; +}; +TimerInfo& get_timer_info() +{ + static TimerInfo sTimerInfo; + return sTimerInfo; +} /////////////////////////////////////////////////////////////////////////////// // returns a U64 number that represents the number of -// microseconds since the unix epoch - Jan 1, 1970 +// microseconds since the Unix epoch - Jan 1, 1970 U64MicrosecondsImplicit totalTime() { U64 current_clock_count = get_clock_count(); - if (!gTotalTimeClockCount) + if (!get_timer_info().mTotalTimeClockCount || get_timer_info().mClocksToMicroseconds.value() == 0) { - update_clock_frequencies(); - gTotalTimeClockCount = current_clock_count; + get_timer_info().update(); + get_timer_info().mTotalTimeClockCount = current_clock_count; #if LL_WINDOWS - // Synch us up with local time (even though we PROBABLY don't need to, this is how it was implemented) + // Sync us up with local time (even though we PROBABLY don't need to, this is how it was implemented) // Unix platforms use gettimeofday so they are synced, although this probably isn't a good assumption to // make in the future. - gTotalTimeClockCount = (U64)(time(NULL) * gClockFrequency); + get_timer_info().mTotalTimeClockCount = (U64)(time(NULL) * get_timer_info().mClockFrequency); #endif // Update the last clock count - gLastTotalTimeClockCount = current_clock_count; + get_timer_info().mLastTotalTimeClockCount = current_clock_count; } else { - if (current_clock_count >= gLastTotalTimeClockCount) + if (current_clock_count >= get_timer_info().mLastTotalTimeClockCount) { // No wrapping, we're all okay. - gTotalTimeClockCount += current_clock_count - gLastTotalTimeClockCount; + get_timer_info().mTotalTimeClockCount += current_clock_count - get_timer_info().mLastTotalTimeClockCount; } else { // We've wrapped. Compensate correctly - gTotalTimeClockCount += (0xFFFFFFFFFFFFFFFFULL - gLastTotalTimeClockCount) + current_clock_count; + get_timer_info().mTotalTimeClockCount += (0xFFFFFFFFFFFFFFFFULL - get_timer_info().mLastTotalTimeClockCount) + current_clock_count; } // Update the last clock count - gLastTotalTimeClockCount = current_clock_count; + get_timer_info().mLastTotalTimeClockCount = current_clock_count; } // Return the total clock tick count in microseconds. - return U64Microseconds(gTotalTimeClockCount*gClocksToMicroseconds); + U64Microseconds time(get_timer_info().mTotalTimeClockCount*get_timer_info().mClocksToMicroseconds); + return time; } @@ -270,9 +285,9 @@ U64MicrosecondsImplicit totalTime() LLTimer::LLTimer() { - if (!gClockFrequency) + if (!get_timer_info().mClockFrequency) { - update_clock_frequencies(); + get_timer_info().update(); } mStarted = TRUE; @@ -298,13 +313,14 @@ void LLTimer::cleanupClass() U64MicrosecondsImplicit LLTimer::getTotalTime() { // simply call into the implementation function. - return totalTime(); + U64MicrosecondsImplicit total_time = totalTime(); + return total_time; } // static F64SecondsImplicit LLTimer::getTotalSeconds() { - return U64_to_F64(getTotalTime()) * USEC_TO_SEC_F64; + return F64Microseconds(U64_to_F64(getTotalTime())); } void LLTimer::reset() @@ -354,7 +370,7 @@ U64 getElapsedTimeAndUpdate(U64& lastClockCount) F64SecondsImplicit LLTimer::getElapsedTimeF64() const { U64 last = mLastClockCount; - return (F64)getElapsedTimeAndUpdate(last) * gClockFrequencyInv; + return (F64)getElapsedTimeAndUpdate(last) * get_timer_info().mClockFrequencyInv; } F32SecondsImplicit LLTimer::getElapsedTimeF32() const @@ -364,7 +380,7 @@ F32SecondsImplicit LLTimer::getElapsedTimeF32() const F64SecondsImplicit LLTimer::getElapsedTimeAndResetF64() { - return (F64)getElapsedTimeAndUpdate(mLastClockCount) * gClockFrequencyInv; + return (F64)getElapsedTimeAndUpdate(mLastClockCount) * get_timer_info().mClockFrequencyInv; } F32SecondsImplicit LLTimer::getElapsedTimeAndResetF32() @@ -377,7 +393,7 @@ F32SecondsImplicit LLTimer::getElapsedTimeAndResetF32() void LLTimer::setTimerExpirySec(F32SecondsImplicit expiration) { mExpirationTicks = get_clock_count() - + (U64)((F32)(expiration * gClockFrequency)); + + (U64)((F32)(expiration * get_timer_info().mClockFrequency)); } F32SecondsImplicit LLTimer::getRemainingTimeF32() const @@ -387,7 +403,7 @@ F32SecondsImplicit LLTimer::getRemainingTimeF32() const { return 0.0f; } - return F32((mExpirationTicks - cur_ticks) * gClockFrequencyInv); + return F32((mExpirationTicks - cur_ticks) * get_timer_info().mClockFrequencyInv); } @@ -400,7 +416,7 @@ BOOL LLTimer::checkExpirationAndReset(F32 expiration) } mExpirationTicks = cur_ticks - + (U64)((F32)(expiration * gClockFrequency)); + + (U64)((F32)(expiration * get_timer_info().mClockFrequency)); return TRUE; } @@ -499,20 +515,20 @@ BOOL is_daylight_savings() struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time) { - S32 pacific_offset_hours; + S32Hours pacific_offset_hours; if (pacific_daylight_time) { - pacific_offset_hours = 7; + pacific_offset_hours = S32Hours(7); } else { - pacific_offset_hours = 8; + pacific_offset_hours = S32Hours(8); } // We subtract off the PST/PDT offset _before_ getting // "UTC" time, because this will handle wrapping around // for 5 AM UTC -> 10 PM PDT of the previous day. - utc_time -= pacific_offset_hours * MIN_PER_HOUR * SEC_PER_MIN; + utc_time -= S32SecondsImplicit(pacific_offset_hours); // Internal buffer to PST/PDT (see above) struct tm* internal_time = gmtime(&utc_time); @@ -529,7 +545,7 @@ struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time) } -void microsecondsToTimecodeString(U64 current_time, std::string& tcstring) +void microsecondsToTimecodeString(U64MicrosecondsImplicit current_time, std::string& tcstring) { U64 hours; U64 minutes; @@ -551,9 +567,9 @@ void microsecondsToTimecodeString(U64 current_time, std::string& tcstring) } -void secondsToTimecodeString(F32 current_time, std::string& tcstring) +void secondsToTimecodeString(F32SecondsImplicit current_time, std::string& tcstring) { - microsecondsToTimecodeString((U64)((F64)(SEC_TO_MICROSEC*current_time)), tcstring); + microsecondsToTimecodeString(current_time, tcstring); } diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 12a453e897..8b3930e2fa 100755 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -168,8 +168,8 @@ LL_COMMON_API BOOL is_daylight_savings(); // struct tm* internal_time = utc_to_pacific_time(utc_time, gDaylight); LL_COMMON_API struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time); -LL_COMMON_API void microsecondsToTimecodeString(U64 current_time, std::string& tcstring); -LL_COMMON_API void secondsToTimecodeString(F32 current_time, std::string& tcstring); +LL_COMMON_API void microsecondsToTimecodeString(U64MicrosecondsImplicit current_time, std::string& tcstring); +LL_COMMON_API void secondsToTimecodeString(F32SecondsImplicit current_time, std::string& tcstring); U64MicrosecondsImplicit LL_COMMON_API totalTime(); // Returns current system time in microseconds diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 436ad9a0a2..05422f9191 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -76,7 +76,7 @@ void TimeBlockTreeNode::setParent( TimeBlock* parent ) } mParent = parent; - mBlock->getPrimaryAccumulator()->mParent = parent; + mBlock->getPrimaryAccumulator().mParent = parent; parent_tree_node->mChildren.push_back(mBlock); parent_tree_node->mNeedsSorting = true; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 1f86aadaba..bf8e950a8c 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -80,10 +80,10 @@ public: mAccumulatorIndex(AccumulatorBuffer::getDefaultBuffer()->reserveSlot()) {} - LL_FORCE_INLINE ACCUMULATOR* getPrimaryAccumulator() const + LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() const { ACCUMULATOR* accumulator_storage = AccumulatorBuffer::getPrimaryStorage(); - return &accumulator_storage[mAccumulatorIndex]; + return accumulator_storage[mAccumulatorIndex]; } size_t getIndex() const { return mAccumulatorIndex; } @@ -137,7 +137,7 @@ template void record(EventStatHandle& measurement, VALUE_T value) { T converted_value(value); - measurement.getPrimaryAccumulator()->record(storage_value(converted_value)); + measurement.getPrimaryAccumulator().record(storage_value(converted_value)); } template @@ -160,7 +160,7 @@ template void sample(SampleStatHandle& measurement, VALUE_T value) { T converted_value(value); - measurement.getPrimaryAccumulator()->sample(storage_value(converted_value)); + measurement.getPrimaryAccumulator().sample(storage_value(converted_value)); } template @@ -183,7 +183,7 @@ template void add(CountStatHandle& count, VALUE_T value) { T converted_value(value); - count.getPrimaryAccumulator()->add(storage_value(converted_value)); + count.getPrimaryAccumulator().add(storage_value(converted_value)); } template<> @@ -340,49 +340,37 @@ public: void* operator new(size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); - accumulator->mAllocatedCount++; - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); + accumulator.mAllocatedCount++; return ::operator new(size); } void operator delete(void* ptr, size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); - accumulator->mAllocatedCount--; - accumulator->mDeallocatedCount++; - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); + accumulator.mAllocatedCount--; + accumulator.mDeallocatedCount++; ::operator delete(ptr); } void *operator new [](size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); - accumulator->mAllocatedCount++; - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); + accumulator.mAllocatedCount++; return ::operator new[](size); } void operator delete[](void* ptr, size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); - accumulator->mAllocatedCount--; - accumulator->mDeallocatedCount++; - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); + accumulator.mAllocatedCount--; + accumulator.mDeallocatedCount++; ::operator delete[](ptr); } @@ -405,12 +393,9 @@ public: template AMOUNT_T& memClaimAmount(AMOUNT_T& size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); mMemFootprint += (size_t)size; - if (accumulator) - { - accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); - } + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); return size; } @@ -432,11 +417,8 @@ public: template AMOUNT_T& memDisclaimAmount(AMOUNT_T& size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); return size; } @@ -448,24 +430,18 @@ private: { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - size_t footprint = MemFootprint::measure(tracked); - accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)footprint); - tracker.mMemFootprint += footprint; - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + size_t footprint = MemFootprint::measure(tracked); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)footprint : (F64)footprint); + tracker.mMemFootprint += footprint; } static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - size_t footprint = MemFootprint::measure(tracked); - accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)footprint); - tracker.mMemFootprint -= footprint; - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + size_t footprint = MemFootprint::measure(tracked); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)footprint : -(F64)footprint); + tracker.mMemFootprint -= footprint; } }; @@ -474,20 +450,14 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() + (F64)MemFootprint::measure(tracked)); - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() + (F64)MemFootprint::measure(tracked) : (F64)MemFootprint::measure(tracked)); } static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - if (accumulator) - { - accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() - (F64)MemFootprint::measure(tracked)); - } + MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() - (F64)MemFootprint::measure(tracked) : -(F64)MemFootprint::measure(tracked)); } }; }; diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 1fb68c8158..c79c102afd 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -114,10 +114,13 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) void AccumulatorBufferGroup::sync() { - F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); + if (isPrimary()) + { + F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); - mSamples.sync(time_stamp); - mMemStats.sync(time_stamp); + mSamples.sync(time_stamp); + mMemStats.sync(time_stamp); + } } void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) @@ -144,6 +147,7 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen if (other.mTotalSamplingTime > epsilon) { + llassert(mTotalSamplingTime > 0); // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm F64 n_1 = mTotalSamplingTime, @@ -166,17 +170,16 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen / (n_1 + n_2 - epsilon)); } - llassert(other.mTotalSamplingTime > 0); F64 weight = mTotalSamplingTime / (mTotalSamplingTime + other.mTotalSamplingTime); mNumSamples += other.mNumSamples; mTotalSamplingTime += other.mTotalSamplingTime; mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); + llassert(mMean < 0 || mMean >= 0); } if (append_type == SEQUENTIAL) { mLastValue = other.mLastValue; mLastSampleTimeStamp = other.mLastSampleTimeStamp; - mHasValue = true; } } } @@ -190,6 +193,7 @@ void SampleAccumulator::reset( const SampleAccumulator* other ) mMin = mLastValue; mMax = mLastValue; mMean = mLastValue; + LL_ERRS_IF(mHasValue && !(mMean < 0) && !(mMean >= 0)) << "Invalid mean after capturing value" << LL_ENDL; mSumOfSquares = 0; mLastSampleTimeStamp = LLTimer::getTotalSeconds(); mTotalSamplingTime = 0; diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index f9d223066d..d4ff4b8d71 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -1,3 +1,4 @@ + /** * @file lltraceaccumulators.h * @brief Storage for accumulating statistics @@ -317,6 +318,7 @@ namespace LLTrace mMin = value; mMax = value; mMean = value; + llassert(mMean < 0 || mMean >= 0); mLastSampleTimeStamp = time_stamp; } else @@ -341,6 +343,7 @@ namespace LLTrace mTotalSamplingTime += delta_time; F64 old_mean = mMean; mMean += (delta_time / mTotalSamplingTime) * (mLastValue - old_mean); + llassert(mMean < 0 || mMean >= 0); mSumOfSquares += delta_time * (mLastValue - old_mean) * (mLastValue - mMean); } mLastSampleTimeStamp = time_stamp; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 8c32e1568b..28470fb4c4 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -69,13 +69,13 @@ void ThreadRecorder::init() tree_node.mBlock = &time_block; tree_node.mParent = &root_time_block; - it->getPrimaryAccumulator()->mParent = &root_time_block; + it->getPrimaryAccumulator().mParent = &root_time_block; } mRootTimer = new BlockTimer(root_time_block); timer_stack->mActiveTimer = mRootTimer; - TimeBlock::getRootTimeBlock().getPrimaryAccumulator()->mActiveCount = 1; + TimeBlock::getRootTimeBlock().getPrimaryAccumulator().mActiveCount = 1; } @@ -247,8 +247,6 @@ void ThreadRecorder::pushToParent() mThreadRecordingBuffers.reset(); } } - - static LLFastTimer::DeclareTimer FTM_PULL_TRACE_DATA_FROM_CHILDREN("Pull child thread trace data"); diff --git a/indra/llcommon/llunit.h b/indra/llcommon/llunit.h index 8fb53dd94d..f42456fe72 100644 --- a/indra/llcommon/llunit.h +++ b/indra/llcommon/llunit.h @@ -156,7 +156,8 @@ struct LLUnit static self_t convert(LLUnit v) { self_t result; - ll_convert_units(v, result); + STORAGE_TYPE divisor = ll_convert_units(v, result); + result.mValue /= divisor; return result; } @@ -193,7 +194,7 @@ struct LLUnitImplicit : public LLUnit template LLUnitImplicit(LLUnit other) - : base_t(convert(other)) + : base_t(other) {} // unlike LLUnit, LLUnitImplicit is *implicitly* convertable to a POD value (F32, S32, etc) @@ -209,6 +210,8 @@ struct LLUnitImplicit : public LLUnit base_t::mValue += value; } + // this overload exists to explicitly catch use of another implicit unit + // without ambiguity between conversion to storage_t vs conversion to base_t template void operator += (LLUnitImplicit other) { @@ -221,6 +224,8 @@ struct LLUnitImplicit : public LLUnit base_t::mValue -= value; } + // this overload exists to explicitly catch use of another implicit unit + // without ambiguity between conversion to storage_t vs conversion to base_t template void operator -= (LLUnitImplicit other) { @@ -246,35 +251,35 @@ std::istream& operator >>(std::istream& s, LLUnitImplicit -LL_FORCE_INLINE void ll_convert_units(LLUnit in, LLUnit& out, ...) +LL_FORCE_INLINE S2 ll_convert_units(LLUnit in, LLUnit& out, ...) { + S2 divisor(1); + LL_STATIC_ASSERT((LLIsSameType::value - || !LLIsSameType::value - || !LLIsSameType::value), "invalid conversion: incompatible units"); + || !LLIsSameType::value + || !LLIsSameType::value), + "conversion requires compatible units"); - if (LLIsSameType::value) + if (LLIsSameType::value) { - if (LLIsSameType::value) - - { - // T1 and T2 fully reduced and equal...just copy - out = LLUnit((S2)in.value()); - } - else - { - // reduce T2 - LLUnit new_out; - ll_convert_units(in, new_out); - ll_convert_units(new_out, out); - } + // T1 and T2 same type, just assign + out.value((S2)in.value()); } - else + else if (LLIsSameType::value) { // reduce T1 - LLUnit new_in; - ll_convert_units(in, new_in); - ll_convert_units(new_in, out); + LLUnit new_in; + divisor *= (S2)ll_convert_units(in, new_in); + divisor *= (S2)ll_convert_units(new_in, out); } + else + { + // reduce T2 + LLUnit new_out; + divisor *= (S2)ll_convert_units(in, new_out); + divisor *= (S2)ll_convert_units(new_out, out); + } + return divisor; } template @@ -579,77 +584,86 @@ struct LLGetUnitLabel > static const char* getUnitLabel() { return T::getUnitLabel(); } }; -template +template struct LLUnitLinearOps { - typedef LLUnitLinearOps output_t; + typedef LLUnitLinearOps self_t; - LLUnitLinearOps(INPUT_TYPE val) - : mInput (val) + LLUnitLinearOps(T val) + : mValue(val), + mDivisor(1) {} - operator OUTPUT_TYPE() const { return (OUTPUT_TYPE)mInput; } - INPUT_TYPE mInput; + T mValue; + T mDivisor; - template - output_t operator * (T other) + template + self_t operator * (OTHER_T other) { - return typename LLResultTypeMultiply::type_t(mInput) * other; + return mValue * other; } - template - output_t operator / (T other) + template + self_t operator / (OTHER_T other) { - return typename LLResultTypeDivide::type_t(mInput) / other; + mDivisor *= other; + return *this; } - template - output_t operator + (T other) + template + self_t operator + (OTHER_T other) { - return typename LLResultTypeAdd::type_t(mInput) + other; + mValue += other; + return *this; } - template - output_t operator - (T other) + template + self_t operator - (OTHER_T other) { - return typename LLResultTypeSubtract::type_t(mInput) - other; + mValue -= other; + return *this; } }; -template +template struct LLUnitInverseLinearOps { - typedef LLUnitInverseLinearOps output_t; + typedef LLUnitInverseLinearOps self_t; - LLUnitInverseLinearOps(INPUT_TYPE val) - : mInput(val) + LLUnitInverseLinearOps(T val) + : mValue(val), + mDivisor(1) {} - operator OUTPUT_TYPE() const { return (OUTPUT_TYPE)mInput; } - INPUT_TYPE mInput; + T mValue; + T mDivisor; - template - output_t operator * (T other) + template + self_t operator * (OTHER_T other) { - return typename LLResultTypeDivide::type_t(mInput) / other; + mDivisor *= other; + return *this; } - template - output_t operator / (T other) + template + self_t operator / (OTHER_T other) { - return typename LLResultTypeMultiply::type_t(mInput) * other; + mValue *= other; + return *this; } - template - output_t operator + (T other) + template + self_t operator + (OTHER_T other) { - return typename LLResultTypeAdd::type_t(mInput) - other; + mValue -= other; + return *this; } - template - output_t operator - (T other) + template + self_t operator - (OTHER_T other) { - return typename LLResultTypeSubtract::type_t(mInput) + other; + mValue += other; + return *this; } }; @@ -666,28 +680,32 @@ struct base_unit_name } -#define LL_DECLARE_DERIVED_UNIT(base_unit_name, conversion_operation, unit_name, unit_label) \ -struct unit_name \ -{ \ - typedef base_unit_name base_unit_t; \ - static const char* getUnitLabel() { return unit_label; } \ - template \ - static LLUnit fromValue(T value) { return LLUnit(value); } \ - template \ - static LLUnit fromValue(LLUnit value) \ - { return LLUnit(value); } \ -}; \ - \ -template \ -void ll_convert_units(LLUnit in, LLUnit& out) \ -{ \ - out = LLUnit((S2)(LLUnitLinearOps(in.value()) conversion_operation)); \ -} \ - \ -template \ -void ll_convert_units(LLUnit in, LLUnit& out) \ -{ \ - out = LLUnit((S2)(LLUnitInverseLinearOps(in.value()) conversion_operation)); \ +#define LL_DECLARE_DERIVED_UNIT(base_unit_name, conversion_operation, unit_name, unit_label) \ +struct unit_name \ +{ \ + typedef base_unit_name base_unit_t; \ + static const char* getUnitLabel() { return unit_label; } \ + template \ + static LLUnit fromValue(T value) { return LLUnit(value); } \ + template \ + static LLUnit fromValue(LLUnit value) \ + { return LLUnit(value); } \ +}; \ + \ +template \ +S2 ll_convert_units(LLUnit in, LLUnit& out) \ +{ \ + LLUnitLinearOps op = LLUnitLinearOps(in.value()) conversion_operation; \ + out = LLUnit((S2)op.mValue); \ + return op.mDivisor; \ +} \ + \ +template \ +S2 ll_convert_units(LLUnit in, LLUnit& out) \ +{ \ + LLUnitInverseLinearOps op = LLUnitInverseLinearOps(in.value()) conversion_operation; \ + out = LLUnit((S2)op.mValue); \ + return op.mDivisor; \ } #define LL_DECLARE_UNIT_TYPEDEFS(ns, unit_name) \ diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index a8e9be86ca..b8aef9d15e 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -38,12 +38,9 @@ namespace LLUnits LL_DECLARE_DERIVED_UNIT(Latinum, / 16, Solari, "Sol"); } -typedef LLUnit F32Quatloos; -typedef LLUnit S32Quatloos; -typedef LLUnit F32Latinum; -typedef LLUnit S32Latinum; -typedef LLUnit F32Solari; -typedef LLUnit S32Solari; +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Quatloos); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Latinum); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Solari); namespace tut { @@ -83,6 +80,15 @@ namespace tut LLUnit unsigned_int_quatloos(float_quatloos); ensure("unsigned int can be initialized from signed int", unsigned_int_quatloos == S32Quatloos(42)); + + S32Solari int_solari(1); + + float_quatloos = int_solari; + ensure("fractional units are preserved in conversion from integer to float type", float_quatloos == F32Quatloos(0.25f)); + + int_quatloos = S32Quatloos(1); + F32Solari float_solari = int_quatloos; + ensure("can convert with fractional intermediates from integer to float type", float_solari == F32Solari(4.f)); } // conversions to/from base unit @@ -185,6 +191,11 @@ namespace tut return true; } + bool accept_implicit_quatloos(S32Quatloos q) + { + return true; + } + // signature compatibility template<> template<> void units_object_t::test<6>() diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index 03a2895289..8658a2f968 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -386,17 +386,24 @@ void LLStatBar::draw() mCurMaxBar = LLSmoothInterpolation::lerp(mCurMaxBar, mMaxBar, 0.05f); mCurMinBar = LLSmoothInterpolation::lerp(mCurMinBar, mMinBar, 0.05f); + S32 decimal_digits = mDecimalDigits; + if (is_approx_equal((F32)(S32)display_value, display_value)) + { + decimal_digits = 0; + } + // rate limited updates - if (mLastDisplayValueTimer.getElapsedTimeF32() > MEAN_VALUE_UPDATE_TIME) + if (mLastDisplayValueTimer.getElapsedTimeF32() < MEAN_VALUE_UPDATE_TIME) { - mLastDisplayValueTimer.reset(); - drawLabelAndValue(display_value, unit_label, bar_rect); - mLastDisplayValue = display_value; + display_value = mLastDisplayValue; } else { - drawLabelAndValue(mLastDisplayValue, unit_label, bar_rect); + mLastDisplayValueTimer.reset(); } + drawLabelAndValue(display_value, unit_label, bar_rect, mDecimalDigits); + mLastDisplayValue = display_value; + if (mDisplayBar && (mCountFloatp || mEventFloatp || mSampleFloatp)) @@ -568,16 +575,11 @@ LLRect LLStatBar::getRequiredRect() return rect; } -void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect ) +void LLStatBar::drawLabelAndValue( F32 value, std::string &label, LLRect &bar_rect, S32 decimal_digits ) { LLFontGL::getFontMonospace()->renderUTF8(mLabel, 0, 0, getRect().getHeight(), LLColor4(1.f, 1.f, 1.f, 1.f), LLFontGL::LEFT, LLFontGL::TOP); - S32 decimal_digits = mDecimalDigits; - if (is_approx_equal((F32)(S32)value, value)) - { - decimal_digits = 0; - } std::string value_str = !llisnan(value) ? llformat("%10.*f %s", decimal_digits, value, label.c_str()) : "n/a"; diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index bf2bd3e259..f311e4a13c 100755 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -72,7 +72,7 @@ public: /*virtual*/ LLRect getRequiredRect(); // Return the height of this object, given the set options. private: - void drawLabelAndValue( F32 mean, std::string &unit_label, LLRect &bar_rect ); + void drawLabelAndValue( F32 mean, std::string &unit_label, LLRect &bar_rect, S32 decimal_digits ); void drawTicks( F32 min, F32 max, F32 value_scale, LLRect &bar_rect ); F32 mMinBar, diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 8092eda7b2..9235f23a8c 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2439,7 +2439,7 @@ void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) // Move an object due to idle-time viewer side updates by interpolating motion -void LLViewerObject::interpolateLinearMotion(const F64SecondsImplicit& time, const F32SecondsImplicit& dt) +void LLViewerObject::interpolateLinearMotion(const F64SecondsImplicit& time, const F32SecondsImplicit& dt_seconds) { // linear motion // PHYSICS_TIMESTEP is used below to correct for the fact that the velocity in object @@ -2450,8 +2450,9 @@ void LLViewerObject::interpolateLinearMotion(const F64SecondsImplicit& time, con // to see if object is selected, instead of explicitly // zeroing it out + F32 dt = dt_seconds; F64Seconds time_since_last_update = time - mLastMessageUpdateSecs; - if (time_since_last_update <= (F64Seconds)0.0 || dt <= (F32Seconds)0.f) + if (time_since_last_update <= (F64Seconds)0.0 || dt <= 0.f) { return; } @@ -2463,7 +2464,7 @@ void LLViewerObject::interpolateLinearMotion(const F64SecondsImplicit& time, con { // Old code path ... unbounded, simple interpolation if (!(accel.isExactlyZero() && vel.isExactlyZero())) { - LLVector3 pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt.value(); + LLVector3 pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt; // region local setPositionRegion(pos + getPositionRegion()); @@ -2477,7 +2478,7 @@ void LLViewerObject::interpolateLinearMotion(const F64SecondsImplicit& time, con { // Object is moving, and hasn't been too long since we got an update from the server // Calculate predicted position and velocity - LLVector3 new_pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt.value(); + LLVector3 new_pos = (vel + (0.5f * (dt-PHYSICS_TIMESTEP)) * accel) * dt; LLVector3 new_v = accel * dt; if (time_since_last_update > sPhaseOutUpdateInterpolationTime && diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index fc2369276c..02d1bf6a0e 100755 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -42,8 +42,7 @@ show_bar="true"/> + stat="packetslostpercentstat"/> @@ -71,12 +70,10 @@ stat="numobjectsstat"/> + stat="numnewobjectsstat"/> + stat="gltexmemstat"/> + stat="formattedmemstat"/> + stat="rawmemstat"/> + stat="glboundmemstat"/> + stat="simtimedilation"/> + stat="simmainagents"/> + stat="simobjects"/> + stat="simactiveobjects"/> + stat="simactivescripts"/> + stat="simpctscriptsrun"/> + stat="simsimaistepmsec"/> + unit_label="/sec"/> + stat="simframemsec"/> + stat="simnetmsec"/> + stat="simsimphysicsmsec"/> + stat="simsimothermsec"/> + stat="simagentmsec"/> + stat="simimagesmsec"/> + stat="simscriptmsec"/> + stat="simsparemsec"/> + stat="simsimphysicsstepmsec"/> + stat="simsimphysicsshapeupdatemsec"/> + stat="simsimphysicsothermsec"/> + stat="simsleepmsec"/> + stat="simpumpiomsec"/> -- cgit v1.3 From 049317fc6442e8b2c2d93309a9d759aa063d2010 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 21 Aug 2013 23:51:46 -0700 Subject: SH-4433 WIP Interesting: Statistics > Ping Sim is always 0 ms added unit tests for lltrace --- indra/llcommon/CMakeLists.txt | 1 + indra/llcommon/lltraceaccumulators.cpp | 3 +- indra/llcommon/lltraceaccumulators.h | 1 + indra/llcommon/tests/lltrace_test.cpp | 141 +++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 indra/llcommon/tests/lltrace_test.cpp (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 4336550d07..62880b07f6 100755 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -287,6 +287,7 @@ if (LL_TESTS) LL_ADD_INTEGRATION_TEST(llsdserialize "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llsingleton "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llstring "" "${test_libs}") + LL_ADD_INTEGRATION_TEST(lltrace "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lltreeiterators "" "${test_libs}") LL_ADD_INTEGRATION_TEST(lluri "" "${test_libs}") LL_ADD_INTEGRATION_TEST(llunits "" "${test_libs}") diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index c79c102afd..42f075a7cb 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -147,7 +147,6 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen if (other.mTotalSamplingTime > epsilon) { - llassert(mTotalSamplingTime > 0); // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm F64 n_1 = mTotalSamplingTime, @@ -193,7 +192,7 @@ void SampleAccumulator::reset( const SampleAccumulator* other ) mMin = mLastValue; mMax = mLastValue; mMean = mLastValue; - LL_ERRS_IF(mHasValue && !(mMean < 0) && !(mMean >= 0)) << "Invalid mean after capturing value" << LL_ENDL; + llassert(!mHasValue || mMean < 0 || mMean >= 0); mSumOfSquares = 0; mLastSampleTimeStamp = LLTimer::getTotalSeconds(); mTotalSamplingTime = 0; diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index d4ff4b8d71..bf195f72b1 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -342,6 +342,7 @@ namespace LLTrace mSum += mLastValue * delta_time; mTotalSamplingTime += delta_time; F64 old_mean = mMean; + llassert(mMean < 0 || mMean >= 0); mMean += (delta_time / mTotalSamplingTime) * (mLastValue - old_mean); llassert(mMean < 0 || mMean >= 0); mSumOfSquares += delta_time * (mLastValue - old_mean) * (mLastValue - mMean); diff --git a/indra/llcommon/tests/lltrace_test.cpp b/indra/llcommon/tests/lltrace_test.cpp new file mode 100644 index 0000000000..1c2a4528ae --- /dev/null +++ b/indra/llcommon/tests/lltrace_test.cpp @@ -0,0 +1,141 @@ +/** + * @file llsingleton_test.cpp + * @date 2011-08-11 + * @brief Unit test for the LLSingleton class + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "lltrace.h" +#include "lltracethreadrecorder.h" +#include "lltracerecording.h" +#include "../test/lltut.h" + +namespace LLUnits +{ + // using powers of 2 to allow strict floating point equality + LL_DECLARE_BASE_UNIT(Ounces, "oz"); + LL_DECLARE_DERIVED_UNIT(Ounces, * 12, TallCup, ""); + LL_DECLARE_DERIVED_UNIT(Ounces, * 16, GrandeCup, ""); + LL_DECLARE_DERIVED_UNIT(Ounces, * 20, VentiCup, ""); + + LL_DECLARE_BASE_UNIT(Grams, "g"); + LL_DECLARE_DERIVED_UNIT(Grams, / 1000, Milligrams, "mg"); +} + +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Ounces); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, TallCup); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, GrandeCup); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, VentiCup); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Grams); +LL_DECLARE_UNIT_TYPEDEFS(LLUnits, Milligrams); + + +namespace tut +{ + using namespace LLTrace; + struct trace + { + ThreadRecorder mRecorder; + }; + + typedef test_group trace_t; + typedef trace_t::object trace_object_t; + tut::trace_t tut_singleton("LLTrace"); + + static CountStatHandle sCupsOfCoffeeConsumed("coffeeconsumed", "Delicious cup of dark roast."); + static SampleStatHandle sCaffeineLevelStat("caffeinelevel", "Coffee buzz quotient"); + static EventStatHandle sOuncesPerCup("cupsize", "Large, huge, or ginormous"); + + static F32 sCaffeineLevel(0.f); + const F32Milligrams sCaffeinePerOz(18.f); + + void drink_coffee(S32 num_cups, S32Ounces cup_size) + { + add(sCupsOfCoffeeConsumed, num_cups); + for (S32 i = 0; i < num_cups; i++) + { + record(sOuncesPerCup, cup_size); + } + + sCaffeineLevel += F32Ounces(num_cups * cup_size).value() * sCaffeinePerOz.value(); + sample(sCaffeineLevelStat, sCaffeineLevel); + } + + // basic data collection + template<> template<> + void trace_object_t::test<1>() + { + sample(sCaffeineLevelStat, sCaffeineLevel); + + Recording all_day; + Recording at_work; + Recording after_3pm; + + all_day.start(); + { + // warm up with one grande cup + drink_coffee(1, S32TallCup(1)); + + // go to work + at_work.start(); + { + // drink 3 tall cups, 1 after 3 pm + drink_coffee(2, S32GrandeCup(1)); + after_3pm.start(); + drink_coffee(1, S32GrandeCup(1)); + } + at_work.stop(); + drink_coffee(1, S32VentiCup(1)); + } + after_3pm.stop(); + all_day.stop(); + + ensure("count stats are counted when recording is active", + at_work.getSum(sCupsOfCoffeeConsumed) == 3 + && all_day.getSum(sCupsOfCoffeeConsumed) == 5 + && after_3pm.getSum(sCupsOfCoffeeConsumed) == 2); + ensure("measurement sums are counted when recording is active", + at_work.getSum(sOuncesPerCup) == S32Ounces(48) + && all_day.getSum(sOuncesPerCup) == S32Ounces(80) + && after_3pm.getSum(sOuncesPerCup) == S32Ounces(36)); + ensure("measurement min is specific to when recording is active", + at_work.getMin(sOuncesPerCup) == S32GrandeCup(1) + && all_day.getMin(sOuncesPerCup) == S32TallCup(1) + && after_3pm.getMin(sOuncesPerCup) == S32GrandeCup(1)); + ensure("measurement max is specific to when recording is active", + at_work.getMax(sOuncesPerCup) == S32GrandeCup(1) + && all_day.getMax(sOuncesPerCup) == S32VentiCup(1) + && after_3pm.getMax(sOuncesPerCup) == S32VentiCup(1)); + ensure("sample min is specific to when recording is active", + at_work.getMin(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1)).value() + && all_day.getMin(sCaffeineLevelStat) == F32Milligrams(0.f) + && after_3pm.getMin(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(2)).value()); + ensure("sample max is specific to when recording is active", + at_work.getMax(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(3)).value() + && all_day.getMax(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(3) + (S32Ounces)S32VentiCup(1)).value() + && after_3pm.getMax(sCaffeineLevelStat) == sCaffeinePerOz * ((S32Ounces)S32TallCup(1) + (S32Ounces)S32GrandeCup(3) + (S32Ounces)S32VentiCup(1)).value()); + } + +} -- cgit v1.3 From f0a642898dad11f6519bad735857a58e1d83422e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 29 Aug 2013 15:25:48 -0700 Subject: SH-4377 FIX: Interesting: Windows viewer crashes when SceneLoadingMonitorEnabled is enabled --- indra/llcommon/lltraceaccumulators.cpp | 3 +-- indra/llcommon/lltraceaccumulators.h | 5 +---- indra/newview/llscenemonitor.cpp | 1 + 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 42f075a7cb..ae769350b9 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -145,7 +145,7 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen F64 epsilon = 0.0000001; - if (other.mTotalSamplingTime > epsilon) + if (other.mTotalSamplingTime > epsilon && mTotalSamplingTime > epsilon) { // combine variance (and hence standard deviation) of 2 different sized sample groups using // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm @@ -173,7 +173,6 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen mNumSamples += other.mNumSamples; mTotalSamplingTime += other.mTotalSamplingTime; mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); - llassert(mMean < 0 || mMean >= 0); } if (append_type == SEQUENTIAL) { diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index e0f60800e3..02af480b8a 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -318,7 +318,6 @@ namespace LLTrace mMin = value; mMax = value; mMean = value; - llassert(mMean < 0 || mMean >= 0); mLastSampleTimeStamp = time_stamp; } else @@ -336,15 +335,13 @@ namespace LLTrace void sync(F64SecondsImplicit time_stamp) { - if (mHasValue) + if (mHasValue && time_stamp != mLastSampleTimeStamp) { F64SecondsImplicit delta_time = time_stamp - mLastSampleTimeStamp; mSum += mLastValue * delta_time; mTotalSamplingTime += delta_time; F64 old_mean = mMean; - llassert(mMean < 0 || mMean >= 0); mMean += (delta_time / mTotalSamplingTime) * (mLastValue - old_mean); - llassert(mMean < 0 || mMean >= 0); mSumOfSquares += delta_time * (mLastValue - old_mean) * (mLastValue - mMean); } mLastSampleTimeStamp = time_stamp; diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index ecffc67993..666fb1a0e5 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -283,6 +283,7 @@ void LLSceneMonitor::capture() else { mEnabled = enabled; + reset(); freezeScene(); } } -- cgit v1.3 From 3fd68662f267a3fd96d101834b3a9563bde3f61e Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sat, 7 Sep 2013 21:16:39 -0700 Subject: added memory usage and occlusion events to traces renamed "current" to "primary" when referring to accumulators --- indra/llcommon/llfasttimer.cpp | 10 +++---- indra/llcommon/llfasttimer.h | 6 ++--- indra/llcommon/llmemory.cpp | 5 ++++ indra/llcommon/lltrace.cpp | 2 +- indra/llcommon/lltrace.h | 45 +++++++++++++++++++++----------- indra/llcommon/lltraceaccumulators.cpp | 30 ++++++++++----------- indra/llcommon/lltraceaccumulators.h | 16 ++++++------ indra/llcommon/lltracethreadrecorder.cpp | 14 +++++----- indra/newview/llagent.h | 1 + indra/newview/llappviewer.cpp | 4 +-- indra/newview/llremoteparcelrequest.h | 3 ++- indra/newview/llvieweroctree.cpp | 16 ++++++++++++ 12 files changed, 95 insertions(+), 57 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 2235eb1a08..c58fad12e7 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -189,7 +189,7 @@ void TimeBlock::bootstrapTimerTree() // when this timer was called if (timer.getParent() == &TimeBlock::getRootTimeBlock()) { - TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); if (accumulator.mLastCaller) { @@ -223,7 +223,7 @@ void TimeBlock::incrementalUpdateTimerTree() // skip root timer if (timerp != &TimeBlock::getRootTimeBlock()) { - TimeBlockAccumulator& accumulator = timerp->getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timerp->getCurrentAccumulator(); if (accumulator.mMoveUpTree) { @@ -253,7 +253,7 @@ void TimeBlock::updateTimes() U64 cur_time = getCPUClockCount64(); BlockTimer* cur_timer = stack_record->mActiveTimer; - TimeBlockAccumulator* accumulator = &stack_record->mTimeBlock->getPrimaryAccumulator(); + TimeBlockAccumulator* accumulator = &stack_record->mTimeBlock->getCurrentAccumulator(); while(cur_timer && cur_timer->mParentTimerData.mActiveTimer != cur_timer) // root defined by parent pointing to self @@ -269,7 +269,7 @@ void TimeBlock::updateTimes() cur_timer->mBlockStartTotalTimeCounter = accumulator->mTotalTimeCounter; stack_record = &cur_timer->mParentTimerData; - accumulator = &stack_record->mTimeBlock->getPrimaryAccumulator(); + accumulator = &stack_record->mTimeBlock->getCurrentAccumulator(); cur_timer = stack_record->mActiveTimer; stack_record->mChildTime += cumulative_time_delta; @@ -299,7 +299,7 @@ void TimeBlock::processTimes() ++it) { TimeBlock& timer = *it; - TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); accumulator.mLastCaller = NULL; accumulator.mMoveUpTree = false; diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 7bad6134c5..1586ea2d04 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -257,11 +257,11 @@ LL_FORCE_INLINE BlockTimer::BlockTimer(TimeBlock& timer) #if FAST_TIMER_ON BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator& accumulator = timer.getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = timer.getCurrentAccumulator(); accumulator.mActiveCount++; mBlockStartTotalTimeCounter = accumulator.mTotalTimeCounter; // keep current parent as long as it is active when we are - accumulator.mMoveUpTree |= (accumulator.mParent->getPrimaryAccumulator().mActiveCount == 0); + accumulator.mMoveUpTree |= (accumulator.mParent->getCurrentAccumulator().mActiveCount == 0); // store top of stack mParentTimerData = *cur_timer_data; @@ -281,7 +281,7 @@ LL_FORCE_INLINE BlockTimer::~BlockTimer() BlockTimerStackRecord* cur_timer_data = LLThreadLocalSingletonPointer::getInstance(); if (!cur_timer_data) return; - TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getPrimaryAccumulator(); + TimeBlockAccumulator& accumulator = cur_timer_data->mTimeBlock->getCurrentAccumulator(); accumulator.mCalls++; accumulator.mTotalTimeCounter += total_time - (accumulator.mTotalTimeCounter - mBlockStartTotalTimeCounter); diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index cb2f853070..e0b2aa87c2 100755 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -43,12 +43,15 @@ #include "llsys.h" #include "llframetimer.h" +#include "lltrace.h" //---------------------------------------------------------------------------- //static char* LLMemory::reserveMem = 0; U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0); +static LLTrace::SampleStatHandle sAllocatedMem("allocated_mem", "active memory in use by application"); +static LLTrace::SampleStatHandle sVirtualMem("virtual_mem", "virtual memory assigned to application"); U32Kilobytes LLMemory::sAllocatedMemInKB(0); U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0); U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX); @@ -114,7 +117,9 @@ void LLMemory::updateMemoryInfo() } sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ; + sample(sAllocatedMem, sAllocatedMemInKB); sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ; + sample(sVirtualMem, sAllocatedPageSizeInKB); U32Kilobytes avail_phys, avail_virtual; LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 05422f9191..e4a6f4c902 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -76,7 +76,7 @@ void TimeBlockTreeNode::setParent( TimeBlock* parent ) } mParent = parent; - mBlock->getPrimaryAccumulator().mParent = parent; + mBlock->getCurrentAccumulator().mParent = parent; parent_tree_node->mChildren.push_back(mBlock); parent_tree_node->mNeedsSorting = true; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index bf8e950a8c..cda15c0de5 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -80,9 +80,9 @@ public: mAccumulatorIndex(AccumulatorBuffer::getDefaultBuffer()->reserveSlot()) {} - LL_FORCE_INLINE ACCUMULATOR& getPrimaryAccumulator() const + LL_FORCE_INLINE ACCUMULATOR& getCurrentAccumulator() const { - ACCUMULATOR* accumulator_storage = AccumulatorBuffer::getPrimaryStorage(); + ACCUMULATOR* accumulator_storage = AccumulatorBuffer::getCurrentStorage(); return accumulator_storage[mAccumulatorIndex]; } @@ -137,7 +137,7 @@ template void record(EventStatHandle& measurement, VALUE_T value) { T converted_value(value); - measurement.getPrimaryAccumulator().record(storage_value(converted_value)); + measurement.getCurrentAccumulator().record(storage_value(converted_value)); } template @@ -160,7 +160,22 @@ template void sample(SampleStatHandle& measurement, VALUE_T value) { T converted_value(value); - measurement.getPrimaryAccumulator().sample(storage_value(converted_value)); + measurement.getCurrentAccumulator().sample(storage_value(converted_value)); +} + +template +void add(SampleStatHandle& measurement, VALUE_T value) +{ + T converted_value(value); + SampleAccumulator& acc = measurement.getCurrentAccumulator(); + if (acc.hasValue()) + { + acc.sample(acc.getLastValue() + converted_value); + } + else + { + acc.sample(converted_value); + } } template @@ -183,7 +198,7 @@ template void add(CountStatHandle& count, VALUE_T value) { T converted_value(value); - count.getPrimaryAccumulator().add(storage_value(converted_value)); + count.getCurrentAccumulator().add(storage_value(converted_value)); } template<> @@ -340,7 +355,7 @@ public: void* operator new(size_t size) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); accumulator.mAllocatedCount++; @@ -349,7 +364,7 @@ public: void operator delete(void* ptr, size_t size) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); accumulator.mAllocatedCount--; accumulator.mDeallocatedCount++; @@ -358,7 +373,7 @@ public: void *operator new [](size_t size) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); accumulator.mAllocatedCount++; @@ -367,7 +382,7 @@ public: void operator delete[](void* ptr, size_t size) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); accumulator.mAllocatedCount--; accumulator.mDeallocatedCount++; @@ -393,7 +408,7 @@ public: template AMOUNT_T& memClaimAmount(AMOUNT_T& size) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); mMemFootprint += (size_t)size; accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); return size; @@ -417,7 +432,7 @@ public: template AMOUNT_T& memDisclaimAmount(AMOUNT_T& size) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); return size; } @@ -430,7 +445,7 @@ private: { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); size_t footprint = MemFootprint::measure(tracked); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)footprint : (F64)footprint); tracker.mMemFootprint += footprint; @@ -438,7 +453,7 @@ private: static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); size_t footprint = MemFootprint::measure(tracked); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)footprint : -(F64)footprint); tracker.mMemFootprint -= footprint; @@ -450,13 +465,13 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() + (F64)MemFootprint::measure(tracked) : (F64)MemFootprint::measure(tracked)); } static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator& accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator& accumulator = DERIVED::sMemStat.getCurrentAccumulator(); accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() - (F64)MemFootprint::measure(tracked) : -(F64)MemFootprint::measure(tracked)); } }; diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index ae769350b9..b234f43337 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -48,13 +48,13 @@ void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) other.mMemStats.reset(&mMemStats); } -void AccumulatorBufferGroup::makePrimary() +void AccumulatorBufferGroup::makeCurrent() { - mCounts.makePrimary(); - mSamples.makePrimary(); - mEvents.makePrimary(); - mStackTimers.makePrimary(); - mMemStats.makePrimary(); + mCounts.makeCurrent(); + mSamples.makeCurrent(); + mEvents.makeCurrent(); + mStackTimers.makeCurrent(); + mMemStats.makeCurrent(); ThreadRecorder* thread_recorder = get_thread_recorder().get(); AccumulatorBuffer& timer_accumulator_buffer = mStackTimers; @@ -70,18 +70,18 @@ void AccumulatorBufferGroup::makePrimary() } //static -void AccumulatorBufferGroup::clearPrimary() +void AccumulatorBufferGroup::resetCurrent() { - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); - AccumulatorBuffer::clearPrimary(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::resetCurrent(); } -bool AccumulatorBufferGroup::isPrimary() const +bool AccumulatorBufferGroup::isCurrent() const { - return mCounts.isPrimary(); + return mCounts.isCurrent(); } void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) @@ -114,7 +114,7 @@ void AccumulatorBufferGroup::reset(AccumulatorBufferGroup* other) void AccumulatorBufferGroup::sync() { - if (isPrimary()) + if (isCurrent()) { F64SecondsImplicit time_stamp = LLTimer::getTotalSeconds(); diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 02af480b8a..e31058ab4b 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -75,7 +75,7 @@ namespace LLTrace ~AccumulatorBuffer() { - if (isPrimary()) + if (isCurrent()) { LLThreadLocalSingletonPointer::setInstance(NULL); } @@ -128,22 +128,22 @@ namespace LLTrace } } - void makePrimary() + void makeCurrent() { LLThreadLocalSingletonPointer::setInstance(mStorage); } - bool isPrimary() const + bool isCurrent() const { return LLThreadLocalSingletonPointer::getInstance() == mStorage; } - static void clearPrimary() + static void resetCurrent() { LLThreadLocalSingletonPointer::setInstance(NULL); } - LL_FORCE_INLINE static ACCUMULATOR* getPrimaryStorage() + LL_FORCE_INLINE static ACCUMULATOR* getCurrentStorage() { ACCUMULATOR* accumulator = LLThreadLocalSingletonPointer::getInstance(); return accumulator ? accumulator : getDefaultBuffer()->mStorage; @@ -534,9 +534,9 @@ namespace LLTrace AccumulatorBufferGroup(); void handOffTo(AccumulatorBufferGroup& other); - void makePrimary(); - bool isPrimary() const; - static void clearPrimary(); + void makeCurrent(); + bool isCurrent() const; + static void resetCurrent(); void append(const AccumulatorBufferGroup& other); void merge(const AccumulatorBufferGroup& other); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 28470fb4c4..df4af89184 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -69,13 +69,13 @@ void ThreadRecorder::init() tree_node.mBlock = &time_block; tree_node.mParent = &root_time_block; - it->getPrimaryAccumulator().mParent = &root_time_block; + it->getCurrentAccumulator().mParent = &root_time_block; } mRootTimer = new BlockTimer(root_time_block); timer_stack->mActiveTimer = mRootTimer; - TimeBlock::getRootTimeBlock().getPrimaryAccumulator().mActiveCount = 1; + TimeBlock::getRootTimeBlock().getCurrentAccumulator().mActiveCount = 1; } @@ -135,7 +135,7 @@ void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_hand } mActiveRecordings.push_back(active_recording); - mActiveRecordings.back()->mPartialRecording.makePrimary(); + mActiveRecordings.back()->mPartialRecording.makeCurrent(); } ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringUpToDate( AccumulatorBufferGroup* recording ) @@ -186,19 +186,19 @@ void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) if (it != mActiveRecordings.rend()) { active_recording_list_t::iterator recording_to_remove = (++it).base(); - bool was_primary = (*recording_to_remove)->mPartialRecording.isPrimary(); + bool was_current = (*recording_to_remove)->mPartialRecording.isCurrent(); llassert((*recording_to_remove)->mTargetRecording == recording); delete *recording_to_remove; mActiveRecordings.erase(recording_to_remove); - if (was_primary) + if (was_current) { if (mActiveRecordings.empty()) { - AccumulatorBufferGroup::clearPrimary(); + AccumulatorBufferGroup::resetCurrent(); } else { - mActiveRecordings.back()->mPartialRecording.makePrimary(); + mActiveRecordings.back()->mPartialRecording.makeCurrent(); } } } diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 093a65682a..8e9a1dd40a 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -34,6 +34,7 @@ #include "llcoordframe.h" // for mFrameAgent #include "llavatarappearancedefines.h" #include "llpermissionsflags.h" +#include "v3dmath.h" #include #include diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 7f37cee8b8..9cd589c34a 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1224,8 +1224,8 @@ void LLAppViewer::checkMemory() } mMemCheckTimer.reset() ; - //update the availability of memory - LLMemory::updateMemoryInfo() ; + //update the availability of memory + LLMemory::updateMemoryInfo() ; bool is_low = LLMemory::isMemoryPoolLow() ; diff --git a/indra/newview/llremoteparcelrequest.h b/indra/newview/llremoteparcelrequest.h index b87056573b..e4b8791f7c 100755 --- a/indra/newview/llremoteparcelrequest.h +++ b/indra/newview/llremoteparcelrequest.h @@ -30,7 +30,8 @@ #define LL_LLREMOTEPARCELREQUEST_H #include "llhttpclient.h" -#include "llpanel.h" +#include "llhandle.h" +#include "llsingleton.h" class LLMessageSystem; class LLRemoteParcelInfoObserver; diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 481befdb44..b6389fac33 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -39,6 +39,11 @@ U32 LLViewerOctreeEntryData::sCurVisible = 0; BOOL LLViewerOctreeDebug::sInDebug = FALSE; +static LLTrace::CountStatHandle sOcclusionQueries("occlusion_queries", "Number of occlusion queries executed"), + sNumObjectsOccluded("occluded_objects", "Count of objects being occluded by a query"), + sNumObjectsUnoccluded("unoccluded_objects", "Count of objects being unoccluded by a query"); +static LLTrace::SampleStatHandle sOcclusionQueriesInFlight("occlusion_queries_in_flight", "Number of occlusion queries waiting for results"); + //----------------------------------------------------------------------------------- //some global functions definitions //----------------------------------------------------------------------------------- @@ -921,6 +926,10 @@ void LLOcclusionCullingGroup::setOcclusionState(U32 state, S32 mode) } else { + if (state & OCCLUDED) + { + add(sNumObjectsOccluded, 1); + } mOcclusionState[LLViewerCamera::sCurCameraID] |= state; if ((state & DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID]) { @@ -979,6 +988,10 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) } else { + if (state & OCCLUDED) + { + add(sNumObjectsUnoccluded, 1); + } mOcclusionState[LLViewerCamera::sCurCameraID] &= ~state; } } @@ -1082,6 +1095,7 @@ void LLOcclusionCullingGroup::checkOcclusion() #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]); #endif + add(sOcclusionQueriesInFlight, -1); } else if (mOcclusionQuery[LLViewerCamera::sCurCameraID]) { //delete the query to avoid holding onto hundreds of pending queries @@ -1187,6 +1201,8 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg #if LL_TRACK_PENDING_OCCLUSION_QUERIES sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]); #endif + add(sOcclusionQueries, 1); + add(sOcclusionQueriesInFlight, 1); { LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS); -- cgit v1.3 From 72f979135b3497d16c2635babf057900ddbc42fe Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 18 Sep 2013 14:20:30 -0700 Subject: merge --- indra/llcommon/lltrace.h | 81 ++++++++++++++++++++++---------- indra/llcommon/lltraceaccumulators.cpp | 12 ++--- indra/llcommon/lltraceaccumulators.h | 20 +++----- indra/llcommon/lltracerecording.cpp | 20 ++++---- indra/llcommon/lltracerecording.h | 10 ++-- indra/llcommon/lltracethreadrecorder.cpp | 2 +- 6 files changed, 85 insertions(+), 60 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index f7ceaf585d..472f0b0cf0 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -80,8 +80,8 @@ public: LL_FORCE_INLINE ACCUMULATOR& getCurrentAccumulator() const { - ACCUMULATOR* accumulator_storage = AccumulatorBuffer::getCurrentStorage(); - return accumulator_storage[mAccumulatorIndex]; + ACCUMULATOR* accumulator_storage = LLThreadLocalSingletonPointer::getInstance(); + return accumulator_storage ? accumulator_storage[mAccumulatorIndex] : (*AccumulatorBuffer::getDefaultBuffer())[mAccumulatorIndex]; } size_t getIndex() const { return mAccumulatorIndex; } @@ -222,7 +222,7 @@ public: }; template<> -class TraceType +class TraceType : public TraceType { public: @@ -258,12 +258,51 @@ public: return static_cast&>(*(TraceType*)this); } - TraceType& childMem() + TraceType& childMem() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(TraceType*)this); } }; +inline void track_alloc(MemStatHandle& measurement, size_t size) +{ + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); + accumulator.mAllocatedCount++; +} + +inline void track_dealloc(MemStatHandle& measurement, size_t size) +{ + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); + accumulator.mAllocatedCount--; + accumulator.mDeallocatedCount++; +} + +inline void claim_mem(MemStatHandle& measurement, size_t size) +{ + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); +} + +inline void disclaim_mem(MemStatHandle& measurement, size_t size) +{ + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); +} + +inline void claim_shadow_mem(MemStatHandle& measurement, size_t size) +{ + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); +} + +inline void disclaim_shadow_mem(MemStatHandle& measurement, size_t size) +{ + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); +} + // measures effective memory footprint of specified type // specialize to cover different types @@ -369,9 +408,7 @@ public: void* operator new(size_t size) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mAllocatedCount++; + track_alloc(sMemStat, size); if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) { @@ -393,10 +430,7 @@ public: void operator delete(void* ptr, size_t size) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mAllocatedCount--; - accumulator.mDeallocatedCount++; + track_dealloc(sMemStat, size); if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) { @@ -418,9 +452,7 @@ public: void *operator new [](size_t size) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mAllocatedCount++; + track_alloc(sMemStat, size); if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) { @@ -442,7 +474,7 @@ public: void operator delete[](void* ptr, size_t size) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); + MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); accumulator.mAllocatedCount--; accumulator.mDeallocatedCount++; @@ -484,9 +516,8 @@ public: template AMOUNT_T& memClaimAmount(AMOUNT_T& size) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); + MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator(); mMemFootprint += (size_t)size; - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); return size; } @@ -508,7 +539,7 @@ public: template AMOUNT_T& memDisclaimAmount(AMOUNT_T& size) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); + MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); return size; } @@ -521,17 +552,17 @@ private: { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); + MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator(); size_t footprint = MemFootprint::measure(tracked); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)footprint : (F64)footprint); + claim_mem(sMemStat, footprint); tracker.mMemFootprint += footprint; } static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); + MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator(); size_t footprint = MemFootprint::measure(tracked); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)footprint : -(F64)footprint); + disclaim_mem(sMemStat, footprint); tracker.mMemFootprint -= footprint; } }; @@ -541,13 +572,13 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); + MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator(); accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() + (F64)MemFootprint::measure(tracked) : (F64)MemFootprint::measure(tracked)); } static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator& accumulator = sMemStat.getCurrentAccumulator(); + MemStatAccumulator& accumulator = sMemStat.getPrimaryAccumulator(); accumulator.mChildSize.sample(accumulator.mChildSize.hasValue() ? accumulator.mChildSize.getLastValue() - (F64)MemFootprint::measure(tracked) : -(F64)MemFootprint::measure(tracked)); } }; diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index b234f43337..58d0b5b227 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -70,13 +70,13 @@ void AccumulatorBufferGroup::makeCurrent() } //static -void AccumulatorBufferGroup::resetCurrent() +void AccumulatorBufferGroup::clearCurrent() { - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); - AccumulatorBuffer::resetCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); } bool AccumulatorBufferGroup::isCurrent() const diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index e31058ab4b..c5a0693fef 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -138,17 +138,11 @@ namespace LLTrace return LLThreadLocalSingletonPointer::getInstance() == mStorage; } - static void resetCurrent() + static void clearCurrent() { LLThreadLocalSingletonPointer::setInstance(NULL); } - LL_FORCE_INLINE static ACCUMULATOR* getCurrentStorage() - { - ACCUMULATOR* accumulator = LLThreadLocalSingletonPointer::getInstance(); - return accumulator ? accumulator : getDefaultBuffer()->mStorage; - } - // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned size_t reserveSlot() { @@ -491,7 +485,7 @@ namespace LLTrace typedef U32 value_t; }; - struct ChildMemFacet + struct ShadowMemFacet { typedef F64Bytes value_t; }; @@ -504,7 +498,7 @@ namespace LLTrace void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) { mSize.addSamples(other.mSize, append_type); - mChildSize.addSamples(other.mChildSize, append_type); + mShadowSize.addSamples(other.mShadowSize, append_type); mAllocatedCount += other.mAllocatedCount; mDeallocatedCount += other.mDeallocatedCount; } @@ -512,7 +506,7 @@ namespace LLTrace void reset(const MemStatAccumulator* other) { mSize.reset(other ? &other->mSize : NULL); - mChildSize.reset(other ? &other->mChildSize : NULL); + mShadowSize.reset(other ? &other->mShadowSize : NULL); mAllocatedCount = 0; mDeallocatedCount = 0; } @@ -520,11 +514,11 @@ namespace LLTrace void sync(F64SecondsImplicit time_stamp) { mSize.sync(time_stamp); - mChildSize.sync(time_stamp); + mShadowSize.sync(time_stamp); } SampleAccumulator mSize, - mChildSize; + mShadowSize; int mAllocatedCount, mDeallocatedCount; }; @@ -536,7 +530,7 @@ namespace LLTrace void handOffTo(AccumulatorBufferGroup& other); void makeCurrent(); bool isCurrent() const; - static void resetCurrent(); + static void clearCurrent(); void append(const AccumulatorBufferGroup& other); void merge(const AccumulatorBufferGroup& other); diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index bc98eebf31..c278901bc0 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -193,29 +193,29 @@ F64Bytes Recording::getLastValue(const TraceType& stat) return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Bytes Recording::getMin(const TraceType& stat) +F64Bytes Recording::getMin(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMin()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMin()); } -F64Bytes Recording::getMean(const TraceType& stat) +F64Bytes Recording::getMean(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMean()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMean()); } -F64Bytes Recording::getMax(const TraceType& stat) +F64Bytes Recording::getMax(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getMax()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMax()); } -F64Bytes Recording::getStandardDeviation(const TraceType& stat) +F64Bytes Recording::getStandardDeviation(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getStandardDeviation()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getStandardDeviation()); } -F64Bytes Recording::getLastValue(const TraceType& stat) +F64Bytes Recording::getLastValue(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mChildSize.getLastValue()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getLastValue()); } U32 Recording::getSum(const TraceType& stat) diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index ea090e6ee1..9550838798 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -181,11 +181,11 @@ namespace LLTrace F64Bytes getStandardDeviation(const TraceType& stat); F64Bytes getLastValue(const TraceType& stat); - F64Bytes getMin(const TraceType& stat); - F64Bytes getMean(const TraceType& stat); - F64Bytes getMax(const TraceType& stat); - F64Bytes getStandardDeviation(const TraceType& stat); - F64Bytes getLastValue(const TraceType& stat); + F64Bytes getMin(const TraceType& stat); + F64Bytes getMean(const TraceType& stat); + F64Bytes getMax(const TraceType& stat); + F64Bytes getStandardDeviation(const TraceType& stat); + F64Bytes getLastValue(const TraceType& stat); U32 getSum(const TraceType& stat); U32 getSum(const TraceType& stat); diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 8cddc49e71..d3d9eb5ca7 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -194,7 +194,7 @@ void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) { if (mActiveRecordings.empty()) { - AccumulatorBufferGroup::resetCurrent(); + AccumulatorBufferGroup::clearCurrent(); } else { -- cgit v1.3 From af6b6db264aaa02e9e6a01d88233d129cf960fdf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 27 Sep 2013 21:24:27 -0700 Subject: fixed lltrace memory tracking image memory utilization now always non-negative --- indra/llcommon/lltrace.h | 16 ++++++++++------ indra/llcommon/lltraceaccumulators.cpp | 2 +- indra/llcommon/lltraceaccumulators.h | 31 +++++++++++++++++-------------- indra/llcommon/lltracerecording.cpp | 24 ++++++++++++------------ 4 files changed, 40 insertions(+), 33 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 355617a898..5c68bbbc0b 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -283,30 +283,34 @@ public: inline void claim_footprint(MemStatHandle& measurement, S32 size) { + if(size == 0) return; MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mAllocated.add(1); + accumulator.mFootprintAllocations.record(size); } inline void disclaim_footprint(MemStatHandle& measurement, S32 size) { + if(size == 0) return; MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mDeallocated.add(1); + accumulator.mFootprintDeallocations.add(size); } inline void claim_shadow(MemStatHandle& measurement, S32 size) { + if(size == 0) return; MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mShadowAllocated.add(1); + accumulator.mShadowAllocations.record(size); } inline void disclaim_shadow(MemStatHandle& measurement, S32 size) { + if(size == 0) return; MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mShadowDeallocated.add(1); + accumulator.mShadowDeallocations.add(size); } // measures effective memory footprint of specified type @@ -465,13 +469,13 @@ public: void *operator new [](size_t size) { - claim_footprint(sMemStat, size); + claim_footprint(sMemStat, size, true); return ll_aligned_malloc(ALIGNMENT, size); } void operator delete[](void* ptr, size_t size) { - disclaim_footprint(sMemStat, size); + disclaim_footprint(sMemStat, size, true); ll_aligned_free(ALIGNMENT, ptr); } diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 58d0b5b227..a7bd04415e 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -239,7 +239,7 @@ void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendT void EventAccumulator::reset( const EventAccumulator* other ) { mNumSamples = 0; - mSum = NaN; + mSum = 0; mMin = NaN; mMax = NaN; mMean = NaN; diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 2dcfdf48ad..01f4ef506f 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -223,7 +223,7 @@ namespace LLTrace typedef F64 value_t; EventAccumulator() - : mSum(NaN), + : mSum(0), mMin(NaN), mMax(NaN), mMean(NaN), @@ -389,7 +389,7 @@ namespace LLTrace mSum += value; } - void addSamples(const CountAccumulator& other, bool /*follows_in_sequence*/) + void addSamples(const CountAccumulator& other, EBufferAppendType /*type*/) { mSum += other.mSum; mNumSamples += other.mNumSamples; @@ -515,8 +515,11 @@ namespace LLTrace void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) { - mAllocated.addSamples(other.mAllocated, append_type); - mDeallocated.addSamples(other.mDeallocated, append_type); + mFootprintAllocations.addSamples(other.mFootprintAllocations, append_type); + mFootprintDeallocations.addSamples(other.mFootprintDeallocations, append_type); + mShadowAllocations.addSamples(other.mShadowAllocations, append_type); + mShadowDeallocations.addSamples(other.mShadowDeallocations, append_type); + if (append_type == SEQUENTIAL) { mSize.addSamples(other.mSize, SEQUENTIAL); @@ -524,12 +527,12 @@ namespace LLTrace } else { - F64 allocation_delta(other.mAllocated.getSum() - other.mDeallocated.getSum()); + F64 allocation_delta(other.mFootprintAllocations.getSum() - other.mFootprintDeallocations.getSum()); mSize.sample(mSize.hasValue() ? mSize.getLastValue() + allocation_delta : allocation_delta); - F64 shadow_allocation_delta(other.mShadowAllocated.getSum() - other.mShadowDeallocated.getSum()); + F64 shadow_allocation_delta(other.mShadowAllocations.getSum() - other.mShadowDeallocations.getSum()); mShadowSize.sample(mShadowSize.hasValue() ? mShadowSize.getLastValue() + shadow_allocation_delta : shadow_allocation_delta); @@ -540,10 +543,10 @@ namespace LLTrace { mSize.reset(other ? &other->mSize : NULL); mShadowSize.reset(other ? &other->mShadowSize : NULL); - mAllocated.reset(other ? &other->mAllocated : NULL); - mDeallocated.reset(other ? &other->mDeallocated : NULL); - mShadowAllocated.reset(other ? &other->mShadowAllocated : NULL); - mShadowDeallocated.reset(other ? &other->mShadowDeallocated : NULL); + mFootprintAllocations.reset(other ? &other->mFootprintAllocations : NULL); + mFootprintDeallocations.reset(other ? &other->mFootprintDeallocations : NULL); + mShadowAllocations.reset(other ? &other->mShadowAllocations : NULL); + mShadowDeallocations.reset(other ? &other->mShadowDeallocations : NULL); } void sync(F64SecondsImplicit time_stamp) @@ -554,10 +557,10 @@ namespace LLTrace SampleAccumulator mSize, mShadowSize; - CountAccumulator mAllocated, - mDeallocated, - mShadowAllocated, - mShadowDeallocated; + EventAccumulator mFootprintAllocations, + mShadowAllocations; + CountAccumulator mFootprintDeallocations, + mShadowDeallocations; }; struct AccumulatorBufferGroup : public LLRefCount diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ddf62845a0..fb2293844a 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -230,62 +230,62 @@ F64Kilobytes Recording::getLastValue(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mDeallocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mShadowAllocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocated.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSampleCount(); } F64 Recording::getSum( const TraceType& stat ) -- cgit v1.3 From 12f0f8cb72f789e21b01b45063dcc5f1f5292087 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 1 Oct 2013 13:46:43 -0700 Subject: changed over to manual naming of MemTrackable stats changed claimMem and disclaimMem behavior to not pass through argument added more mem tracking stats to floater_stats --- indra/llcommon/lltrace.h | 298 +++++---------------- indra/llcommon/lltraceaccumulators.cpp | 5 + indra/llcommon/lltraceaccumulators.h | 36 +-- indra/llcommon/lltracerecording.cpp | 60 ----- indra/llcommon/lltracerecording.h | 16 -- indra/llcommon/llunittype.h | 1 + indra/llimage/llimage.cpp | 29 +- indra/llimage/llimagej2c.cpp | 1 + indra/llimage/llimagejpeg.cpp | 10 +- indra/llinventory/llinventory.cpp | 23 +- indra/llinventory/llinventory.h | 3 +- indra/llrender/llfontbitmapcache.cpp | 20 +- indra/llrender/llfontbitmapcache.h | 3 +- indra/llrender/llfontfreetype.cpp | 20 +- indra/llrender/llfontfreetype.h | 6 +- indra/llrender/llimagegl.cpp | 18 +- indra/llrender/llimagegl.h | 2 +- indra/llrender/llvertexbuffer.cpp | 7 +- indra/llrender/llvertexbuffer.h | 6 +- indra/llui/llfolderviewitem.cpp | 8 - indra/llui/llfolderviewmodel.h | 9 +- indra/llui/lltextbase.cpp | 16 +- indra/llui/lltextbase.h | 8 +- indra/llui/lluictrl.cpp | 40 ++- indra/llui/llview.cpp | 3 +- indra/llui/llview.h | 2 +- indra/llui/llviewmodel.cpp | 10 +- indra/newview/lldrawable.cpp | 5 +- indra/newview/lldrawable.h | 4 +- indra/newview/llviewerobject.cpp | 3 +- indra/newview/llviewerwindow.cpp | 3 + indra/newview/llvocache.cpp | 10 +- .../newview/skins/default/xui/en/floater_stats.xml | 37 +-- 33 files changed, 290 insertions(+), 432 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index da4bf6e36b..226f64d0c7 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -35,6 +35,8 @@ #include "lltraceaccumulators.h" #include "llthreadlocalstorage.h" #include "lltimer.h" +#include "llpointer.h" +#include "llunits.h" #include @@ -206,39 +208,6 @@ public: {} }; -template<> -class TraceType - : public TraceType -{ -public: - - TraceType(const char* name, const char* description = "") - : TraceType(name, description) - {} -}; - -template<> -class TraceType - : public TraceType -{ -public: - - TraceType(const char* name, const char* description = "") - : TraceType(name, description) - {} -}; - -template<> -class TraceType - : public TraceType -{ -public: - - TraceType(const char* name, const char* description = "") - : TraceType(name, description) - {} -}; - class MemStatHandle : public TraceType { public: @@ -264,109 +233,40 @@ public: { return static_cast&>(*(TraceType*)this); } - - TraceType& shadowAllocations() - { - return static_cast&>(*(TraceType*)this); - } - - TraceType& shadowDeallocations() - { - return static_cast&>(*(TraceType*)this); - } - - TraceType& shadowMem() - { - return static_cast&>(*(TraceType*)this); - } }; -inline void claim_footprint(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mFootprintAllocations.record(size); -} - -inline void disclaim_footprint(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mFootprintDeallocations.add(size); -} - -inline void claim_shadow(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mShadowAllocations.record(size); -} - -inline void disclaim_shadow(MemStatHandle& measurement, S32 size) -{ - if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); - accumulator.mShadowSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mShadowDeallocations.add(size); -} // measures effective memory footprint of specified type // specialize to cover different types - -template +template struct MeasureMem { static size_t measureFootprint(const T& value) { return sizeof(T); } - - static size_t measureFootprint() - { - return sizeof(T); - } - - static size_t measureShadow(const T& value) - { - return 0; - } - - static size_t measureShadow() - { - return 0; - } }; -template -struct MeasureMem +template +struct MeasureMem { static size_t measureFootprint(const T& value) { return sizeof(T) + value.getMemFootprint(); } +}; - static size_t measureFootprint() - { - return sizeof(T); - } - - static size_t measureShadow(const T& value) - { - return value.getMemShadow(); - } - - static size_t measureShadow() +template +struct MeasureMem +{ + static size_t measureFootprint(const T& value) { - return MeasureMem::measureShadow(); + return U32Bytes(value).value(); } }; - -template -struct MeasureMem +template +struct MeasureMem { static size_t measureFootprint(const T* value) { @@ -376,46 +276,68 @@ struct MeasureMem } return MeasureMem::measureFootprint(*value); } +}; - static size_t measureFootprint() +template +struct MeasureMem, IS_MEM_TRACKABLE, IS_BYTES> +{ + static size_t measureFootprint(const LLPointer value) { - return MeasureMem::measureFootprint(); + if (value.isNull()) + { + return 0; + } + return MeasureMem::measureFootprint(*value); } +}; - static size_t measureShadow(const T* value) +template +struct MeasureMem +{ + static size_t measureFootprint(S32 value) { - return MeasureMem::measureShadow(*value); + return value; } +}; - static size_t measureShadow() +template +struct MeasureMem +{ + static size_t measureFootprint(U32 value) { - return MeasureMem::measureShadow(); + return value; } }; -template -struct MeasureMem, IS_MEM_TRACKABLE> +template +struct MeasureMem, IS_MEM_TRACKABLE, IS_BYTES> { static size_t measureFootprint(const std::basic_string& value) { return value.capacity() * sizeof(T); } +}; - static size_t measureFootprint() - { - return sizeof(std::basic_string); - } - static size_t measureShadow(const std::basic_string& value) - { - return 0; - } +template +inline void claim_footprint(MemStatHandle& measurement, const T& value) +{ + S32 size = MeasureMem::measureFootprint(value); + if(size == 0) return; + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); + accumulator.mFootprintAllocations.record(size); +} - static size_t measureShadow() - { - return 0; - } -}; +template +inline void disclaim_footprint(MemStatHandle& measurement, const T& value) +{ + S32 size = MeasureMem::measureFootprint(value); + if(size == 0) return; + MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); + accumulator.mFootprintDeallocations.add(size); +} template class MemTrackable @@ -423,28 +345,20 @@ class MemTrackable public: typedef void mem_trackable_tag_t; - enum EMemType - { - MEM_FOOTPRINT, - MEM_SHADOW - }; - - MemTrackable() - : mMemFootprint(0), - mMemShadow(0) + MemTrackable(const char* name) + : mMemFootprint(0) { static bool name_initialized = false; if (!name_initialized) { name_initialized = true; - sMemStat.setName(typeid(DERIVED).name()); + sMemStat.setName(name); } } virtual ~MemTrackable() { - disclaimMem(mMemFootprint, MEM_FOOTPRINT); - disclaimMem(mMemShadow, MEM_SHADOW); + disclaimMem(mMemFootprint); } static MemStatHandle& getMemStatHandle() @@ -453,7 +367,6 @@ public: } S32 getMemFootprint() const { return mMemFootprint; } - S32 getMemShadow() const { return mMemShadow; } void* operator new(size_t size) { @@ -467,7 +380,7 @@ public: ll_aligned_free(ALIGNMENT, ptr); } - void *operator new [](size_t size) + void* operator new [](size_t size) { claim_footprint(sMemStat, size); return ll_aligned_malloc(ALIGNMENT, size); @@ -481,98 +394,27 @@ public: // claim memory associated with other objects/data as our own, adding to our calculated footprint template - CLAIM_T& claimMem(CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackAlloc(MeasureMem::measureFootprint(value), mem_type); - trackAlloc(MeasureMem::measureShadow(value), MEM_SHADOW); - return value; - } - - template - const CLAIM_T& claimMem(const CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackAlloc(MeasureMem::measureFootprint(value), mem_type); - trackAlloc(MeasureMem::measureShadow(value), MEM_SHADOW); - return value; - } - - size_t& claimMem(size_t& size, EMemType mem_type = MEM_FOOTPRINT) - { - trackAlloc(size, mem_type); - return size; - } - - S32& claimMem(S32& size, EMemType mem_type = MEM_FOOTPRINT) + void claimMem(const CLAIM_T& value) const { - trackAlloc(size, mem_type); - return size; + S32 size = MeasureMem::measureFootprint(value); + claim_footprint(sMemStat, size); + mMemFootprint += size; } // remove memory we had claimed from our calculated footprint template - CLAIM_T& disclaimMem(CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackDealloc(MeasureMem::measureFootprint(value), mem_type); - trackDealloc(MeasureMem::measureShadow(value), MEM_SHADOW); - return value; - } - - template - const CLAIM_T& disclaimMem(const CLAIM_T& value, EMemType mem_type = MEM_FOOTPRINT) - { - trackDealloc(MeasureMem::measureFootprint(value), mem_type); - trackDealloc(MeasureMem::measureShadow(value), MEM_SHADOW); - return value; - } - - size_t& disclaimMem(size_t& size, EMemType mem_type = MEM_FOOTPRINT) + void disclaimMem(const CLAIM_T& value) const { - trackDealloc(size, mem_type); - return size; - } - - S32& disclaimMem(S32& size, EMemType mem_type = MEM_FOOTPRINT) - { - trackDealloc(size, mem_type); - return size; - } - -private: - - void trackAlloc(S32 size, EMemType mem_type) - { - if (mem_type == MEM_FOOTPRINT) - { - claim_footprint(sMemStat, size); - mMemFootprint += size; - } - else - { - claim_shadow(sMemStat, size); - mMemShadow += size; - } - } - - void trackDealloc(S32 size, EMemType mem_type) - { - if (mem_type == MEM_FOOTPRINT) - { - disclaim_footprint(sMemStat, size); - mMemFootprint -= size; - } - else - { - disclaim_shadow(sMemStat, size); - mMemShadow -= size; - } + S32 size = MeasureMem::measureFootprint(value); + disclaim_footprint(sMemStat, size); + mMemFootprint -= size; } private: // use signed values so that we can temporarily go negative // and reconcile in destructor // NB: this assumes that no single class is responsible for > 2GB of allocations - S32 mMemFootprint, - mMemShadow; + mutable S32 mMemFootprint; static MemStatHandle sMemStat; }; diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index a7bd04415e..f5f2e7df1c 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -125,6 +125,11 @@ void AccumulatorBufferGroup::sync() void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) { + if (append_type == NON_SEQUENTIAL) + { + return; + } + if (!mHasValue) { *this = other; diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 5cba3e5360..ecc569f5d6 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -498,32 +498,14 @@ namespace LLTrace typedef F64Bytes value_t; }; - struct ShadowAllocationFacet - { - typedef F64Bytes value_t; - }; - - struct ShadowDeallocationFacet - { - typedef F64Bytes value_t; - }; - - struct ShadowMemFacet - { - typedef F64Bytes value_t; - }; - void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) { mFootprintAllocations.addSamples(other.mFootprintAllocations, append_type); mFootprintDeallocations.addSamples(other.mFootprintDeallocations, append_type); - mShadowAllocations.addSamples(other.mShadowAllocations, append_type); - mShadowDeallocations.addSamples(other.mShadowDeallocations, append_type); if (append_type == SEQUENTIAL) { mSize.addSamples(other.mSize, SEQUENTIAL); - mShadowSize.addSamples(other.mShadowSize, SEQUENTIAL); } else { @@ -531,36 +513,24 @@ namespace LLTrace mSize.sample(mSize.hasValue() ? mSize.getLastValue() + allocation_delta : allocation_delta); - - F64 shadow_allocation_delta(other.mShadowAllocations.getSum() - other.mShadowDeallocations.getSum()); - mShadowSize.sample(mShadowSize.hasValue() - ? mShadowSize.getLastValue() + shadow_allocation_delta - : shadow_allocation_delta); } } void reset(const MemStatAccumulator* other) { mSize.reset(other ? &other->mSize : NULL); - mShadowSize.reset(other ? &other->mShadowSize : NULL); mFootprintAllocations.reset(other ? &other->mFootprintAllocations : NULL); mFootprintDeallocations.reset(other ? &other->mFootprintDeallocations : NULL); - mShadowAllocations.reset(other ? &other->mShadowAllocations : NULL); - mShadowDeallocations.reset(other ? &other->mShadowDeallocations : NULL); } void sync(F64SecondsImplicit time_stamp) { mSize.sync(time_stamp); - mShadowSize.sync(time_stamp); } - SampleAccumulator mSize, - mShadowSize; - EventAccumulator mFootprintAllocations, - mShadowAllocations; - CountAccumulator mFootprintDeallocations, - mShadowDeallocations; + SampleAccumulator mSize; + EventAccumulator mFootprintAllocations; + CountAccumulator mFootprintDeallocations; }; struct AccumulatorBufferGroup : public LLRefCount diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index fb2293844a..ce4a433cca 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -173,11 +173,6 @@ bool Recording::hasValue(const TraceType& stat) return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } -bool Recording::hasValue(const TraceType& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowSize.hasValue(); -} - F64Kilobytes Recording::getMin(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); @@ -203,31 +198,6 @@ F64Kilobytes Recording::getLastValue(const TraceType& stat) return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Kilobytes Recording::getMin(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMin()); -} - -F64Kilobytes Recording::getMean(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMean()); -} - -F64Kilobytes Recording::getMax(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getMax()); -} - -F64Kilobytes Recording::getStandardDeviation(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getStandardDeviation()); -} - -F64Kilobytes Recording::getLastValue(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowSize.getLastValue()); -} - F64Kilobytes Recording::getSum(const TraceType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum()); @@ -258,36 +228,6 @@ S32 Recording::getSampleCount(const TraceTypemMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount(); } -F64Kilobytes Recording::getSum(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum()); -} - -F64Kilobytes Recording::getPerSec(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSum() / mElapsedSeconds.value()); -} - -S32 Recording::getSampleCount(const TraceType& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowAllocations.getSampleCount(); -} - -F64Kilobytes Recording::getSum(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum()); -} - -F64Kilobytes Recording::getPerSec(const TraceType& stat) -{ - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSum() / mElapsedSeconds.value()); -} - -S32 Recording::getSampleCount(const TraceType& stat) -{ - return mBuffers->mMemStats[stat.getIndex()].mShadowDeallocations.getSampleCount(); -} - F64 Recording::getSum( const TraceType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSum(); diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 13dffdc701..085780198d 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -30,7 +30,6 @@ #include "stdtypes.h" #include "llpreprocessor.h" -#include "llpointer.h" #include "lltimer.h" #include "lltraceaccumulators.h" @@ -178,7 +177,6 @@ namespace LLTrace // Memory accessors bool hasValue(const TraceType& stat); - bool hasValue(const TraceType& stat); F64Kilobytes getMin(const TraceType& stat); F64Kilobytes getMean(const TraceType& stat); @@ -186,12 +184,6 @@ namespace LLTrace F64Kilobytes getStandardDeviation(const TraceType& stat); F64Kilobytes getLastValue(const TraceType& stat); - F64Kilobytes getMin(const TraceType& stat); - F64Kilobytes getMean(const TraceType& stat); - F64Kilobytes getMax(const TraceType& stat); - F64Kilobytes getStandardDeviation(const TraceType& stat); - F64Kilobytes getLastValue(const TraceType& stat); - F64Kilobytes getSum(const TraceType& stat); F64Kilobytes getPerSec(const TraceType& stat); S32 getSampleCount(const TraceType& stat); @@ -200,14 +192,6 @@ namespace LLTrace F64Kilobytes getPerSec(const TraceType& stat); S32 getSampleCount(const TraceType& stat); - F64Kilobytes getSum(const TraceType& stat); - F64Kilobytes getPerSec(const TraceType& stat); - S32 getSampleCount(const TraceType& stat); - - F64Kilobytes getSum(const TraceType& stat); - F64Kilobytes getPerSec(const TraceType& stat); - S32 getSampleCount(const TraceType& stat); - // CountStatHandle accessors F64 getSum(const TraceType& stat); template diff --git a/indra/llcommon/llunittype.h b/indra/llcommon/llunittype.h index fb72d6d8a9..0e05ecd683 100644 --- a/indra/llcommon/llunittype.h +++ b/indra/llcommon/llunittype.h @@ -80,6 +80,7 @@ struct LLUnit { typedef LLUnit self_t; typedef STORAGE_TYPE storage_t; + typedef void is_unit_t; // value initialization LL_FORCE_INLINE explicit LLUnit(storage_t value = storage_t()) diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 326f477504..1ca1bf55a6 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -89,15 +89,15 @@ void LLImage::setLastError(const std::string& message) //--------------------------------------------------------------------------- LLImageBase::LLImageBase() - : mData(NULL), - mDataSize(0), - mWidth(0), - mHeight(0), - mComponents(0), - mBadBufferAllocation(false), - mAllowOverSize(false) -{ -} +: LLTrace::MemTrackable("LLImage"), + mData(NULL), + mDataSize(0), + mWidth(0), + mHeight(0), + mComponents(0), + mBadBufferAllocation(false), + mAllowOverSize(false) +{} // virtual LLImageBase::~LLImageBase() @@ -158,7 +158,8 @@ void LLImageBase::sanityCheck() void LLImageBase::deleteData() { FREE_MEM(sPrivatePoolp, mData) ; - disclaimMem(mDataSize) = 0; + disclaimMem(mDataSize); + mDataSize = 0; mData = NULL; } @@ -223,7 +224,9 @@ U8* LLImageBase::reallocateData(S32 size) FREE_MEM(sPrivatePoolp, mData) ; } mData = new_datap; - claimMem(disclaimMem(mDataSize) = size); + disclaimMem(mDataSize); + mDataSize = size; + claimMem(mDataSize); return mData; } @@ -1618,7 +1621,9 @@ void LLImageBase::setDataAndSize(U8 *data, S32 size) { ll_assert_aligned(data, 16); mData = data; - claimMem(disclaimMem(mDataSize) = size); + disclaimMem(mDataSize); + mDataSize = size; + claimMem(mDataSize); } //static diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 8e2bcc3f94..7cd59a2983 100755 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -62,6 +62,7 @@ LLImageJ2C::LLImageJ2C() : LLImageFormatted(IMG_CODEC_J2C), mAreaUsedForDataSizeCalcs(0) { mImpl = fallbackCreateLLImageJ2CImpl(); + claimMem(mImpl); // Clear data size table for( S32 i = 0; i <= MAX_DISCARD_LEVEL; i++) diff --git a/indra/llimage/llimagejpeg.cpp b/indra/llimage/llimagejpeg.cpp index a25794dab4..e419c77ff2 100755 --- a/indra/llimage/llimagejpeg.cpp +++ b/indra/llimage/llimagejpeg.cpp @@ -32,8 +32,7 @@ jmp_buf LLImageJPEG::sSetjmpBuffer ; LLImageJPEG::LLImageJPEG(S32 quality) - : - LLImageFormatted(IMG_CODEC_JPEG), +: LLImageFormatted(IMG_CODEC_JPEG), mOutputBuffer( NULL ), mOutputBufferSize( 0 ), mEncodeQuality( quality ) // on a scale from 1 to 100 @@ -383,7 +382,9 @@ boolean LLImageJPEG::encodeEmptyOutputBuffer( j_compress_ptr cinfo ) cinfo->dest->next_output_byte = self->mOutputBuffer + self->mOutputBufferSize; cinfo->dest->free_in_buffer = self->mOutputBufferSize; + self->disclaimMem(self->mOutputBufferSize); self->mOutputBufferSize = new_buffer_size; + self->claimMem(new_buffer_size); return TRUE; } @@ -489,7 +490,9 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) // Allocate a temporary buffer big enough to hold the entire compressed image (and then some) // (Note: we make it bigger in emptyOutputBuffer() if we need to) delete[] mOutputBuffer; + disclaimMem(mOutputBufferSize); mOutputBufferSize = getWidth() * getHeight() * getComponents() + 1024; + claimMem(mOutputBufferSize); mOutputBuffer = new U8[ mOutputBufferSize ]; const U8* raw_image_data = NULL; @@ -526,6 +529,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) jpeg_destroy_compress(&cinfo); delete[] mOutputBuffer; mOutputBuffer = NULL; + disclaimMem(mOutputBufferSize); mOutputBufferSize = 0; return FALSE; } @@ -628,6 +632,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) // After finish_compress, we can release the temp output buffer. delete[] mOutputBuffer; mOutputBuffer = NULL; + disclaimMem(mOutputBufferSize); mOutputBufferSize = 0; //////////////////////////////////////// @@ -640,6 +645,7 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) jpeg_destroy_compress(&cinfo); delete[] mOutputBuffer; mOutputBuffer = NULL; + disclaimMem(mOutputBufferSize); mOutputBufferSize = 0; return FALSE; } diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp index d2efda8612..61ba0939bf 100755 --- a/indra/llinventory/llinventory.cpp +++ b/indra/llinventory/llinventory.cpp @@ -72,17 +72,20 @@ const LLUUID MAGIC_ID("3c115e51-04f4-523c-9fa6-98aff1034730"); LLInventoryObject::LLInventoryObject(const LLUUID& uuid, const LLUUID& parent_uuid, LLAssetType::EType type, - const std::string& name) : + const std::string& name) +: LLTrace::MemTrackable("LLInventoryObject"), mUUID(uuid), mParentUUID(parent_uuid), mType(type), mName(name), mCreationDate(0) { + claimMem(mName); correctInventoryName(mName); } -LLInventoryObject::LLInventoryObject() : +LLInventoryObject::LLInventoryObject() +: LLTrace::MemTrackable("LLInventoryObject"), mType(LLAssetType::AT_NONE), mCreationDate(0) { @@ -97,7 +100,9 @@ void LLInventoryObject::copyObject(const LLInventoryObject* other) mUUID = other->mUUID; mParentUUID = other->mParentUUID; mType = other->mType; + disclaimMem(mName); mName = other->mName; + claimMem(mName); } const LLUUID& LLInventoryObject::getUUID() const @@ -150,7 +155,9 @@ void LLInventoryObject::rename(const std::string& n) correctInventoryName(new_name); if( !new_name.empty() && new_name != mName ) { + disclaimMem(mName); mName = new_name; + claimMem(mName); } } @@ -326,6 +333,8 @@ LLInventoryItem::LLInventoryItem(const LLUUID& uuid, LLStringUtil::replaceNonstandardASCII(mDescription, ' '); LLStringUtil::replaceChar(mDescription, '|', ' '); + claimMem(mDescription); + mPermissions.initMasks(inv_type); } @@ -357,7 +366,9 @@ void LLInventoryItem::copyItem(const LLInventoryItem* other) copyObject(other); mPermissions = other->mPermissions; mAssetUUID = other->mAssetUUID; + disclaimMem(mDescription); mDescription = other->mDescription; + claimMem(mDescription); mSaleInfo = other->mSaleInfo; mInventoryType = other->mInventoryType; mFlags = other->mFlags; @@ -432,7 +443,9 @@ void LLInventoryItem::setDescription(const std::string& d) LLStringUtil::replaceChar(new_desc, '|', ' '); if( new_desc != mDescription ) { + disclaimMem(mDescription); mDescription = new_desc; + claimMem(mDescription); } } @@ -713,7 +726,9 @@ BOOL LLInventoryItem::importFile(LLFILE* fp) valuestr[0] = '\000'; } + disclaimMem(mDescription); mDescription.assign(valuestr); + claimMem(mDescription); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); /* TODO -- ask Ian about this code const char *donkey = mDescription.c_str(); @@ -919,8 +934,10 @@ BOOL LLInventoryItem::importLegacyStream(std::istream& input_stream) valuestr[0] = '\000'; } + disclaimMem(mDescription); mDescription.assign(valuestr); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); + claimMem(mDescription); /* TODO -- ask Ian about this code const char *donkey = mDescription.c_str(); if (donkey[0] == '|') @@ -1160,8 +1177,10 @@ bool LLInventoryItem::fromLLSD(const LLSD& sd) w = INV_DESC_LABEL; if (sd.has(w)) { + disclaimMem(mDescription); mDescription = sd[w].asString(); LLStringUtil::replaceNonstandardASCII(mDescription, ' '); + claimMem(mDescription); } w = INV_CREATION_DATE_LABEL; if (sd.has(w)) diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index 47b06af5b8..aa0b4cc24c 100755 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -34,6 +34,7 @@ #include "llsaleinfo.h" #include "llsd.h" #include "lluuid.h" +#include "lltrace.h" class LLMessageSystem; @@ -43,7 +44,7 @@ class LLMessageSystem; // Base class for anything in the user's inventory. Handles the common code // between items and categories. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLInventoryObject : public LLRefCount +class LLInventoryObject : public LLRefCount, public LLTrace::MemTrackable { public: typedef std::list > object_list_t; diff --git a/indra/llrender/llfontbitmapcache.cpp b/indra/llrender/llfontbitmapcache.cpp index c985f6b959..f128636ab2 100755 --- a/indra/llrender/llfontbitmapcache.cpp +++ b/indra/llrender/llfontbitmapcache.cpp @@ -29,7 +29,8 @@ #include "llgl.h" #include "llfontbitmapcache.h" -LLFontBitmapCache::LLFontBitmapCache(): +LLFontBitmapCache::LLFontBitmapCache() +: LLTrace::MemTrackable("LLFontBitmapCache"), mNumComponents(0), mBitmapWidth(0), mBitmapHeight(0), @@ -81,6 +82,7 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm { // We're out of space in the current image, or no image // has been allocated yet. Make a new one. + mImageRawVec.push_back(new LLImageRaw); mBitmapNum = mImageRawVec.size()-1; LLImageRaw *image_raw = getImageRaw(mBitmapNum); @@ -122,6 +124,9 @@ BOOL LLFontBitmapCache::nextOpenPos(S32 width, S32 &pos_x, S32 &pos_y, S32& bitm image_gl->createGLTexture(0, image_raw); gGL.getTexUnit(0)->bind(image_gl); image_gl->setFilteringOption(LLTexUnit::TFO_POINT); // was setMipFilterNearest(TRUE, TRUE); + + claimMem(image_raw); + claimMem(image_gl); } else { @@ -151,7 +156,20 @@ void LLFontBitmapCache::destroyGL() void LLFontBitmapCache::reset() { + for (std::vector >::iterator it = mImageRawVec.begin(), end_it = mImageRawVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageRawVec.clear(); + + for (std::vector >::iterator it = mImageGLVec.begin(), end_it = mImageGLVec.end(); + it != end_it; + ++it) + { + disclaimMem(**it); + } mImageGLVec.clear(); mBitmapWidth = 0; diff --git a/indra/llrender/llfontbitmapcache.h b/indra/llrender/llfontbitmapcache.h index c93b0c7320..75df3a94a7 100755 --- a/indra/llrender/llfontbitmapcache.h +++ b/indra/llrender/llfontbitmapcache.h @@ -28,10 +28,11 @@ #define LL_LLFONTBITMAPCACHE_H #include +#include "lltrace.h" // Maintain a collection of bitmaps containing rendered glyphs. // Generalizes the single-bitmap logic from LLFontFreetype and LLFontGL. -class LLFontBitmapCache: public LLRefCount +class LLFontBitmapCache : public LLTrace::MemTrackable { public: LLFontBitmapCache(); diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 4cc5b78b63..bde62f89b3 100755 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -101,7 +101,8 @@ LLFontGlyphInfo::LLFontGlyphInfo(U32 index) } LLFontFreetype::LLFontFreetype() -: mFontBitmapCachep(new LLFontBitmapCache), +: LLTrace::MemTrackable("LLFontFreetype"), + mFontBitmapCachep(new LLFontBitmapCache), mValid(FALSE), mAscender(0.f), mDescender(0.f), @@ -126,7 +127,7 @@ LLFontFreetype::~LLFontFreetype() // Delete glyph info std::for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); - // mFontBitmapCachep will be cleaned up by LLPointer destructor. + delete mFontBitmapCachep; // mFallbackFonts cleaned up by LLPointer destructor } @@ -186,6 +187,8 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v S32 max_char_height = llround(0.5f + (y_max - y_min)); mFontBitmapCachep->init(components, max_char_width, max_char_height); + claimMem(mFontBitmapCachep); + if (!mFTFace->charmap) { @@ -200,6 +203,7 @@ BOOL LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v } mName = filename; + claimMem(mName); mPointSize = point_size; mStyle = LLFontGL::NORMAL; @@ -476,6 +480,7 @@ void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const } else { + claimMem(gi); mCharGlyphInfoMap[wch] = gi; } } @@ -517,8 +522,15 @@ void LLFontFreetype::reset(F32 vert_dpi, F32 horz_dpi) void LLFontFreetype::resetBitmapCache() { - for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer()); + for (char_glyph_info_map_t::iterator it = mCharGlyphInfoMap.begin(), end_it = mCharGlyphInfoMap.end(); + it != end_it; + ++it) + { + disclaimMem(it->second); + delete it->second; + } mCharGlyphInfoMap.clear(); + disclaimMem(mFontBitmapCachep); mFontBitmapCachep->reset(); // Adding default glyph is skipped for fallback fonts here as well as in loadFace(). @@ -540,7 +552,7 @@ const std::string &LLFontFreetype::getName() const return mName; } -const LLPointer LLFontFreetype::getFontBitmapCache() const +const LLFontBitmapCache* LLFontFreetype::getFontBitmapCache() const { return mFontBitmapCachep; } diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index f1b23f22d5..2963fbd43d 100755 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -74,7 +74,7 @@ struct LLFontGlyphInfo extern LLFontManager *gFontManagerp; -class LLFontFreetype : public LLRefCount +class LLFontFreetype : public LLRefCount, public LLTrace::MemTrackable { public: LLFontFreetype(); @@ -134,7 +134,7 @@ public: const std::string& getName() const; - const LLPointer getFontBitmapCache() const; + const LLFontBitmapCache* getFontBitmapCache() const; void setStyle(U8 style); U8 getStyle() const; @@ -167,7 +167,7 @@ private: typedef boost::unordered_map char_glyph_info_map_t; mutable char_glyph_info_map_t mCharGlyphInfoMap; // Information about glyph location in bitmap - mutable LLPointer mFontBitmapCachep; + mutable LLFontBitmapCache* mFontBitmapCachep; mutable S32 mRenderGlyphCount; mutable S32 mAddGlyphCount; diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index d66b6d8432..4330a9891e 100755 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -279,8 +279,10 @@ void LLImageGL::destroyGL(BOOL save_state) if (save_state && glimage->isGLTextureCreated() && glimage->mComponents) { glimage->mSaveData = new LLImageRaw; + glimage->claimMem(glimage->mSaveData); if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it. { + glimage->disclaimMem(glimage->mSaveData); glimage->mSaveData = NULL ; } } @@ -354,7 +356,8 @@ BOOL LLImageGL::create(LLPointer& dest, const LLImageRaw* imageraw, B //---------------------------------------------------------------------------- LLImageGL::LLImageGL(BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -363,7 +366,8 @@ LLImageGL::LLImageGL(BOOL usemipmaps) } LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable("LLImageGL"), + mSaveData(0) { llassert( components <= 4 ); init(usemipmaps); @@ -373,7 +377,8 @@ LLImageGL::LLImageGL(U32 width, U32 height, U8 components, BOOL usemipmaps) } LLImageGL::LLImageGL(const LLImageRaw* imageraw, BOOL usemipmaps) - : mSaveData(0) +: LLTrace::MemTrackable("LLImageGL"), + mSaveData(0) { init(usemipmaps); setSize(0, 0, 0); @@ -387,6 +392,7 @@ LLImageGL::~LLImageGL() { LLImageGL::cleanup(); sImageList.erase(this); + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; sCount--; @@ -500,6 +506,7 @@ void LLImageGL::setSize(S32 width, S32 height, S32 ncomponents, S32 discard_leve } // pickmask validity depends on old image size, delete it + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -1460,7 +1467,9 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ stop_glerror(); } + disclaimMem(mTextureMemory); mTextureMemory = (S32Bytes)getMipBytes(discard_level); + claimMem(mTextureMemory); sGlobalTextureMemory += mTextureMemory; mTexelsInGLTexture = getWidth() * getHeight() ; @@ -1621,6 +1630,7 @@ void LLImageGL::destroyGLTexture() if(mTextureMemory != S32Bytes(0)) { sGlobalTextureMemory -= mTextureMemory; + disclaimMem(mTextureMemory); mTextureMemory = (S32Bytes)0; } @@ -1970,6 +1980,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) return ; } + disclaimMem((mPickMaskWidth * mPickMaskHeight + 7) / 8); delete [] mPickMask; mPickMask = NULL; mPickMaskWidth = mPickMaskHeight = 0; @@ -1987,6 +1998,7 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) U32 size = pick_width * pick_height; size = (size + 7) / 8; // pixelcount-to-bits mPickMask = new U8[size]; + claimMem(size); mPickMaskWidth = pick_width - 1; mPickMaskHeight = pick_height - 1; diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 09ea8a1124..816169a30c 100755 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -42,7 +42,7 @@ class LLTextureAtlas ; #define MEGA_BYTES_TO_BYTES(x) ((x) << 20) //============================================================================ -class LLImageGL : public LLRefCount +class LLImageGL : public LLRefCount, public LLTrace::MemTrackable { friend class LLTexUnit; public: diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index b1a5a194be..38351dd9ae 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -959,7 +959,8 @@ S32 LLVertexBuffer::determineUsage(S32 usage) return ret_usage; } -LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : +LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) +: LLTrace::MemTrackable("LLVertexBuffer"), LLRefCount(), mNumVerts(0), @@ -1096,7 +1097,9 @@ void LLVertexBuffer::waitFence() const void LLVertexBuffer::genBuffer(U32 size) { + disclaimMem(mSize); mSize = vbo_block_size(size); + claimMem(mSize); if (mUsage == GL_STREAM_DRAW_ARB) { @@ -1185,7 +1188,9 @@ void LLVertexBuffer::createGLBuffer(U32 size) static int gl_buffer_idx = 0; mGLBuffer = ++gl_buffer_idx; mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); + disclaimMem(mSize); mSize = size; + disclaimMem(mSize); } } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index 0b4b87f338..92ea3bfc8e 100755 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -34,6 +34,7 @@ #include "v4coloru.h" #include "llstrider.h" #include "llrender.h" +#include "lltrace.h" #include #include #include @@ -98,7 +99,7 @@ public: //============================================================================ // base class class LLPrivateMemoryPool; -class LLVertexBuffer : public LLRefCount +class LLVertexBuffer : public LLRefCount, public LLTrace::MemTrackable { public: class MappedRegion @@ -112,7 +113,8 @@ public: }; LLVertexBuffer(const LLVertexBuffer& rhs) - : mUsage(rhs.mUsage) + : LLTrace::MemTrackable("LLVertexBuffer"), + mUsage(rhs.mUsage) { *this = rhs; } diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 802cb783ed..ac36cd1173 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -1496,16 +1496,12 @@ void LLFolderViewFolder::extractItem( LLFolderViewItem* item ) ft = std::find(mFolders.begin(), mFolders.end(), f); if (ft != mFolders.end()) { - disclaimMem(mFolders); mFolders.erase(ft); - claimMem(mFolders); } } else { - disclaimMem(mItems); mItems.erase(it); - claimMem(mItems); } //item has been removed, need to update filter getViewModelItem()->removeChild(item->getViewModelItem()); @@ -1582,9 +1578,7 @@ void LLFolderViewFolder::addItem(LLFolderViewItem* item) } item->setParentFolder(this); - disclaimMem(mItems); mItems.push_back(item); - claimMem(mItems); item->setRect(LLRect(0, 0, getRect().getWidth(), 0)); item->setVisible(FALSE); @@ -1607,9 +1601,7 @@ void LLFolderViewFolder::addFolder(LLFolderViewFolder* folder) folder->mParentFolder->extractItem(folder); } folder->mParentFolder = this; - disclaimMem(mFolders); mFolders.push_back(folder); - claimMem(mFolders); folder->setOrigin(0, 0); folder->reshape(getRect().getWidth(), 0); folder->setVisible(FALSE); diff --git a/indra/llui/llfolderviewmodel.h b/indra/llui/llfolderviewmodel.h index 3f62d133e4..c665dce509 100755 --- a/indra/llui/llfolderviewmodel.h +++ b/indra/llui/llfolderviewmodel.h @@ -111,6 +111,10 @@ public: class LLFolderViewModelInterface : public LLTrace::MemTrackable { public: + LLFolderViewModelInterface() + : LLTrace::MemTrackable("LLFolderViewModelInterface") + {} + virtual ~LLFolderViewModelInterface() {} virtual void requestSortAll() = 0; @@ -131,7 +135,10 @@ public: class LLFolderViewModelItem : public LLRefCount, public LLTrace::MemTrackable { public: - LLFolderViewModelItem() { } + LLFolderViewModelItem() + : LLTrace::MemTrackable("LLFolderViewModelItem") + {} + virtual ~LLFolderViewModelItem() { } virtual void update() {} //called when drawing diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 5c221edea7..730c3b2ada 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -576,7 +576,7 @@ void LLTextBase::drawText() if ( (mSpellCheckStart != start) || (mSpellCheckEnd != end) ) { const LLWString& wstrText = getWText(); - disclaimMem(mMisspellRanges).clear(); + mMisspellRanges.clear(); segment_set_t::const_iterator seg_it = getSegIterContaining(start); while (mSegments.end() != seg_it) @@ -652,7 +652,6 @@ void LLTextBase::drawText() mSpellCheckStart = start; mSpellCheckEnd = end; - claimMem(mMisspellRanges); } } else @@ -922,11 +921,9 @@ void LLTextBase::createDefaultSegment() if (mSegments.empty()) { LLStyleConstSP sp(new LLStyle(getStyleParams())); - disclaimMem(mSegments); LLTextSegmentPtr default_segment = new LLNormalTextSegment( sp, 0, getLength() + 1, *this); mSegments.insert(default_segment); default_segment->linkToDocument(this); - claimMem(mSegments); } } @@ -937,8 +934,6 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) return; } - disclaimMem(mSegments); - segment_set_t::iterator cur_seg_iter = getSegIterContaining(segment_to_insert->getStart()); S32 reflow_start_index = 0; @@ -1011,7 +1006,6 @@ void LLTextBase::insertSegment(LLTextSegmentPtr segment_to_insert) // layout potentially changed needsReflow(reflow_start_index); - claimMem(mSegments); } BOOL LLTextBase::handleMouseDown(S32 x, S32 y, MASK mask) @@ -1322,10 +1316,8 @@ void LLTextBase::replaceWithSuggestion(U32 index) removeStringNoUndo(it->first, it->second - it->first); // Insert the suggestion in its place - disclaimMem(mSuggestionList); LLWString suggestion = utf8str_to_wstring(mSuggestionList[index]); insertStringNoUndo(it->first, utf8str_to_wstring(mSuggestionList[index])); - claimMem(mSuggestionList); setCursorPos(it->first + (S32)suggestion.length()); @@ -1388,7 +1380,7 @@ bool LLTextBase::isMisspelledWord(U32 pos) const void LLTextBase::onSpellCheckSettingsChange() { // Recheck the spelling on every change - disclaimMem(mMisspellRanges).clear(); + mMisspellRanges.clear(); mSpellCheckStart = mSpellCheckEnd = -1; } @@ -1666,7 +1658,7 @@ LLRect LLTextBase::getTextBoundingRect() void LLTextBase::clearSegments() { - disclaimMem(mSegments).clear(); + mSegments.clear(); createDefaultSegment(); } @@ -3210,9 +3202,7 @@ void LLNormalTextSegment::setToolTip(const std::string& tooltip) LL_WARNS() << "LLTextSegment::setToolTip: cannot replace keyword tooltip." << LL_ENDL; return; } - disclaimMem(mTooltip); mTooltip = tooltip; - claimMem(mTooltip); } bool LLNormalTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index b1558a7abe..87f1a10cc5 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -53,11 +53,13 @@ class LLUrlMatch; /// class LLTextSegment : public LLRefCount, - public LLMouseHandler, - public LLTrace::MemTrackable + public LLMouseHandler { public: - LLTextSegment(S32 start, S32 end) : mStart(start), mEnd(end){}; + LLTextSegment(S32 start, S32 end) + : mStart(start), + mEnd(end) + {} virtual ~LLTextSegment(); virtual bool getDimensions(S32 first_char, S32 num_chars, S32& width, S32& height) const; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 9a81c91e0d..546cd6fc46 100755 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -941,7 +941,9 @@ boost::signals2::connection LLUICtrl::setCommitCallback( boost::function cb ) { - if (!mValidateSignal) mValidateSignal = claimMem(new enable_signal_t()); + if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + claimMem(mValidateSignal); + return mValidateSignal->connect(boost::bind(cb, _2)); } @@ -1004,55 +1006,73 @@ boost::signals2::connection LLUICtrl::setValidateCallback(const EnableCallbackPa boost::signals2::connection LLUICtrl::setCommitCallback( const commit_signal_t::slot_type& cb ) { - if (!mCommitSignal) mCommitSignal = claimMem(new commit_signal_t()); + if (!mCommitSignal) mCommitSignal = new commit_signal_t(); + claimMem(mCommitSignal); + return mCommitSignal->connect(cb); } boost::signals2::connection LLUICtrl::setValidateCallback( const enable_signal_t::slot_type& cb ) { - if (!mValidateSignal) mValidateSignal = claimMem(new enable_signal_t()); + if (!mValidateSignal) mValidateSignal = new enable_signal_t(); + claimMem(mValidateSignal); + return mValidateSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseEnterCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseEnterSignal) mMouseEnterSignal = claimMem(new commit_signal_t()); + if (!mMouseEnterSignal) mMouseEnterSignal = new commit_signal_t(); + claimMem(mMouseEnterSignal); + return mMouseEnterSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseLeaveCallback( const commit_signal_t::slot_type& cb ) { - if (!mMouseLeaveSignal) mMouseLeaveSignal = claimMem(new commit_signal_t()); + if (!mMouseLeaveSignal) mMouseLeaveSignal = new commit_signal_t(); + claimMem(mMouseLeaveSignal); + return mMouseLeaveSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseDownSignal) mMouseDownSignal = claimMem(new mouse_signal_t()); + if (!mMouseDownSignal) mMouseDownSignal = new mouse_signal_t(); + claimMem(mMouseDownSignal); + return mMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mMouseUpSignal) mMouseUpSignal = claimMem(new mouse_signal_t()); + if (!mMouseUpSignal) mMouseUpSignal = new mouse_signal_t(); + claimMem(mMouseUpSignal); + return mMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseDownCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseDownSignal) mRightMouseDownSignal = claimMem(new mouse_signal_t()); + if (!mRightMouseDownSignal) mRightMouseDownSignal = new mouse_signal_t(); + claimMem(mRightMouseDownSignal); + return mRightMouseDownSignal->connect(cb); } boost::signals2::connection LLUICtrl::setRightMouseUpCallback( const mouse_signal_t::slot_type& cb ) { - if (!mRightMouseUpSignal) mRightMouseUpSignal = claimMem(new mouse_signal_t()); + if (!mRightMouseUpSignal) mRightMouseUpSignal = new mouse_signal_t(); + claimMem(mRightMouseUpSignal); + return mRightMouseUpSignal->connect(cb); } boost::signals2::connection LLUICtrl::setDoubleClickCallback( const mouse_signal_t::slot_type& cb ) { - if (!mDoubleClickSignal) mDoubleClickSignal = claimMem(new mouse_signal_t()); + if (!mDoubleClickSignal) mDoubleClickSignal = new mouse_signal_t(); + claimMem(mDoubleClickSignal); + return mDoubleClickSignal->connect(cb); } diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index e81d19ae3a..e3b3444a00 100755 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -131,7 +131,8 @@ LLView::Params::Params() } LLView::LLView(const LLView::Params& p) -: mVisible(p.visible), +: LLTrace::MemTrackable("LLView"), + mVisible(p.visible), mInDraw(false), mName(p.name), mParentView(NULL), diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 3a0dfb5f42..665aad70cf 100755 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -167,7 +167,7 @@ protected: private: // widgets in general are not copyable - LLView(const LLView& other) {}; + LLView(const LLView& other); public: //#if LL_DEBUG static BOOL sIsDrawing; diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index 6459ade027..282addf692 100755 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -37,13 +37,15 @@ /// LLViewModel::LLViewModel() - : mDirty(false) +: LLTrace::MemTrackable("LLViewModel"), + mDirty(false) { } /// Instantiate an LLViewModel with an existing data value LLViewModel::LLViewModel(const LLSD& value) - : mDirty(false) +: LLTrace::MemTrackable("LLViewModel"), + mDirty(false) { setValue(value); } @@ -79,12 +81,14 @@ LLTextViewModel::LLTextViewModel(const LLSD& value) /// Update the stored value void LLTextViewModel::setValue(const LLSD& value) { - LLViewModel::setValue(value); // approximate LLSD storage usage disclaimMem(mDisplay.size()); + LLViewModel::setValue(value); disclaimMem(mDisplay); mDisplay = utf8str_to_wstring(value.asString()); + claimMem(mDisplay); + // approximate LLSD storage usage claimMem(mDisplay.size()); // mDisplay and mValue agree diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 5baebab5a3..2890d3f61c 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -90,8 +90,9 @@ void LLDrawable::incrementVisible() } LLDrawable::LLDrawable(LLViewerObject *vobj, bool new_entry) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLDRAWABLE), - mVObjp(vobj) +: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLDRAWABLE), + LLTrace::MemTrackable("LLDrawable"), + mVObjp(vobj) { init(new_entry); } diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index a0ac417b24..067cee6838 100755 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -64,7 +64,9 @@ class LLDrawable public LLTrace::MemTrackable { public: - LLDrawable(const LLDrawable& rhs) : LLViewerOctreeEntryData(rhs) + LLDrawable(const LLDrawable& rhs) + : LLTrace::MemTrackable("LLDrawable"), + LLViewerOctreeEntryData(rhs) { *this = rhs; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 394b11b759..e65f99c452 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -206,7 +206,8 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco } LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp, BOOL is_global) -: LLPrimitive(), +: LLTrace::MemTrackable("LLViewerObject"), + LLPrimitive(), mChildList(), mID(id), mLocalID(0), diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 34b0f450ab..ecb1fd696a 100755 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -287,6 +287,8 @@ public: // LLDebugText // +static LLTrace::TimeBlock FTM_DISPLAY_DEBUG_TEXT("Display Debug Text"); + class LLDebugText { private: @@ -799,6 +801,7 @@ public: void draw() { + LL_RECORD_BLOCK_TIME(FTM_DISPLAY_DEBUG_TEXT); for (line_list_t::iterator iter = mLineList.begin(); iter != mLineList.end(); ++iter) { diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 7ba0c31ffc..01666778b1 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -56,7 +56,8 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) //--------------------------------------------------------------------------- LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(local_id), mCRC(crc), mUpdateFlags(-1), @@ -74,7 +75,8 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer & } LLVOCacheEntry::LLVOCacheEntry() - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mLocalID(0), mCRC(0), mUpdateFlags(-1), @@ -91,7 +93,8 @@ LLVOCacheEntry::LLVOCacheEntry() } LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file) - : LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), +: LLTrace::MemTrackable("LLVOCacheEntry"), + LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), mBuffer(NULL), mUpdateFlags(-1), mState(INACTIVE), @@ -471,6 +474,7 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child) //LLVOCachePartition //------------------------------------------------------------------- LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) +: LLTrace::MemTrackable("LLVOCachePartition") { mLODPeriod = 16; mRegionp = regionp; diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index f0a464dfc9..d4decf383d 100755 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -111,25 +111,32 @@ + label="UI" + stat="LLView"/> + + + label="Viewer Objects" + stat="LLViewerObject"/> + label="Viewer Object Cache" + stat="LLVOCacheEntry"/> + label="Drawables" + stat="LLDrawable"/> + label="Image Data" + stat="LLImage"/> + + Date: Thu, 3 Oct 2013 14:30:34 -0700 Subject: added initial memory usage tracking for lltrace --- indra/llcommon/lltrace.cpp | 2 + indra/llcommon/lltrace.h | 16 +++--- indra/llcommon/lltraceaccumulators.cpp | 20 ++++++- indra/llcommon/lltraceaccumulators.h | 6 +++ indra/llcommon/lltracerecording.cpp | 19 ++++++- indra/llcommon/lltracerecording.h | 3 +- indra/llcommon/lltracethreadrecorder.cpp | 62 ++++++++++++++-------- indra/llcommon/lltracethreadrecorder.h | 2 +- indra/llrender/llvertexbuffer.cpp | 6 +-- indra/newview/app_settings/settings.xml | 11 ++++ indra/newview/llappviewer.cpp | 22 ++++++-- indra/newview/llviewerobject.cpp | 2 +- .../newview/skins/default/xui/en/floater_stats.xml | 3 ++ 13 files changed, 132 insertions(+), 42 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index e4a6f4c902..73846ba900 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -33,6 +33,8 @@ namespace LLTrace { +MemStatHandle gTraceMemStat("LLTrace"); + TraceBase::TraceBase( const char* name, const char* description ) : mName(name), mDescription(description ? description : "") diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 226f64d0c7..421ec3bda5 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -320,7 +320,7 @@ struct MeasureMem, IS_MEM_TRACKABLE, IS_BYTES> template -inline void claim_footprint(MemStatHandle& measurement, const T& value) +inline void claim_alloc(MemStatHandle& measurement, const T& value) { S32 size = MeasureMem::measureFootprint(value); if(size == 0) return; @@ -330,7 +330,7 @@ inline void claim_footprint(MemStatHandle& measurement, const T& value) } template -inline void disclaim_footprint(MemStatHandle& measurement, const T& value) +inline void disclaim_alloc(MemStatHandle& measurement, const T& value) { S32 size = MeasureMem::measureFootprint(value); if(size == 0) return; @@ -370,25 +370,25 @@ public: void* operator new(size_t size) { - claim_footprint(sMemStat, size); + claim_alloc(sMemStat, size); return ll_aligned_malloc(ALIGNMENT, size); } void operator delete(void* ptr, size_t size) { - disclaim_footprint(sMemStat, size); + disclaim_alloc(sMemStat, size); ll_aligned_free(ALIGNMENT, ptr); } void* operator new [](size_t size) { - claim_footprint(sMemStat, size); + claim_alloc(sMemStat, size); return ll_aligned_malloc(ALIGNMENT, size); } void operator delete[](void* ptr, size_t size) { - disclaim_footprint(sMemStat, size); + disclaim_alloc(sMemStat, size); ll_aligned_free(ALIGNMENT, ptr); } @@ -397,7 +397,7 @@ public: void claimMem(const CLAIM_T& value) const { S32 size = MeasureMem::measureFootprint(value); - claim_footprint(sMemStat, size); + claim_alloc(sMemStat, size); mMemFootprint += size; } @@ -406,7 +406,7 @@ public: void disclaimMem(const CLAIM_T& value) const { S32 size = MeasureMem::measureFootprint(value); - disclaim_footprint(sMemStat, size); + disclaim_alloc(sMemStat, size); mMemFootprint -= size; } diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index f5f2e7df1c..9f270e60b9 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -26,18 +26,36 @@ #include "linden_common.h" #include "lltraceaccumulators.h" +#include "lltrace.h" #include "lltracethreadrecorder.h" namespace LLTrace { +extern MemStatHandle gTraceMemStat; + /////////////////////////////////////////////////////////////////////// // AccumulatorBufferGroup /////////////////////////////////////////////////////////////////////// AccumulatorBufferGroup::AccumulatorBufferGroup() -{} +{ + /*claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); + claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); + claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ +} + +AccumulatorBufferGroup::~AccumulatorBufferGroup() +{ + /*disclaim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + disclaim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); + disclaim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); + disclaim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); + disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ +} void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) { diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index ecc569f5d6..d03c6ce5c0 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -188,6 +188,11 @@ namespace LLTrace return getNumIndices(); } + size_t capacity() const + { + return mStorageSize; + } + static size_t getNumIndices() { return sNextStorageSlot; @@ -536,6 +541,7 @@ namespace LLTrace struct AccumulatorBufferGroup : public LLRefCount { AccumulatorBufferGroup(); + ~AccumulatorBufferGroup(); void handOffTo(AccumulatorBufferGroup& other); void makeCurrent(); diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index ce4a433cca..c33d9aedcc 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -25,15 +25,18 @@ #include "linden_common.h" +#include "lltracerecording.h" + #include "lltrace.h" #include "llfasttimer.h" -#include "lltracerecording.h" #include "lltracethreadrecorder.h" #include "llthread.h" namespace LLTrace { - + +extern MemStatHandle gTraceMemStat; + /////////////////////////////////////////////////////////////////////// // Recording /////////////////////////////////////////////////////////////////////// @@ -42,12 +45,15 @@ Recording::Recording(EPlayState state) : mElapsedSeconds(0), mInHandOff(false) { + claim_alloc(gTraceMemStat, sizeof(*this)); mBuffers = new AccumulatorBufferGroup(); + claim_alloc(gTraceMemStat, mBuffers); setPlayState(state); } Recording::Recording( const Recording& other ) { + claim_alloc(gTraceMemStat, sizeof(*this)); *this = other; } @@ -73,6 +79,9 @@ Recording& Recording::operator = (const Recording& other) Recording::~Recording() { + disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, mBuffers); + if (isStarted() && LLTrace::get_thread_recorder().notNull()) { LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); @@ -330,6 +339,12 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) mRecordingPeriods(num_periods ? num_periods : 1) { setPlayState(state); + claim_alloc(gTraceMemStat, sizeof(*this)); +} + +PeriodicRecording::~PeriodicRecording() +{ + disclaim_alloc(gTraceMemStat, sizeof(*this)); } void PeriodicRecording::nextPeriod() diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 5cf7596966..8bb0b1892f 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -313,7 +313,7 @@ namespace LLTrace class ThreadRecorder* getThreadRecorder(); LLTimer mSamplingTimer; - F64Seconds mElapsedSeconds; + F64Seconds mElapsedSeconds; LLCopyOnWritePointer mBuffers; bool mInHandOff; @@ -324,6 +324,7 @@ namespace LLTrace { public: PeriodicRecording(S32 num_periods, EPlayState state = STOPPED); + ~PeriodicRecording(); void nextPeriod(); S32 getNumRecordedPeriods() { return mNumPeriods; } diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index e131af5f16..bf6189dd25 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -27,9 +27,11 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" +#include "lltrace.h" namespace LLTrace { +extern MemStatHandle gTraceMemStat; static ThreadRecorder* sMasterThreadRecorder = NULL; @@ -55,6 +57,7 @@ void ThreadRecorder::init() timer_stack->mActiveTimer = NULL; mNumTimeBlockTreeNodes = AccumulatorBuffer::getDefaultBuffer()->size(); + mTimeBlockTreeNodes = new TimeBlockTreeNode[mNumTimeBlockTreeNodes]; activate(&mThreadRecordingBuffers); @@ -76,10 +79,14 @@ void ThreadRecorder::init() timer_stack->mActiveTimer = mRootTimer; TimeBlock::getRootTimeBlock().getCurrentAccumulator().mActiveCount = 1; + + claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, sizeof(BlockTimer)); + claim_alloc(gTraceMemStat, sizeof(TimeBlockTreeNode) * mNumTimeBlockTreeNodes); } -ThreadRecorder::ThreadRecorder(ThreadRecorder& master) +ThreadRecorder::ThreadRecorder( ThreadRecorder& master ) : mMasterRecorder(&master) { init(); @@ -91,6 +98,10 @@ ThreadRecorder::~ThreadRecorder() { LLThreadLocalSingletonPointer::setInstance(NULL); + disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, sizeof(BlockTimer)); + disclaim_alloc(gTraceMemStat, sizeof(TimeBlockTreeNode) * mNumTimeBlockTreeNodes); + deactivate(&mThreadRecordingBuffers); delete mRootTimer; @@ -135,9 +146,9 @@ void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_hand mActiveRecordings.back()->mPartialRecording.makeCurrent(); } -ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringUpToDate( AccumulatorBufferGroup* recording ) +ThreadRecorder::active_recording_list_t::iterator ThreadRecorder::bringUpToDate( AccumulatorBufferGroup* recording ) { - if (mActiveRecordings.empty()) return mActiveRecordings.rend(); + if (mActiveRecordings.empty()) return mActiveRecordings.end(); mActiveRecordings.back()->mPartialRecording.sync(); TimeBlock::updateTimes(); @@ -174,15 +185,14 @@ ThreadRecorder::active_recording_list_t::reverse_iterator ThreadRecorder::bringU LL_WARNS() << "Recording not active on this thread" << LL_ENDL; } - return it; + return (++it).base(); } void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) { - active_recording_list_t::reverse_iterator it = bringUpToDate(recording); - if (it != mActiveRecordings.rend()) + active_recording_list_t::iterator recording_to_remove = bringUpToDate(recording); + if (recording_to_remove != mActiveRecordings.end()) { - active_recording_list_t::iterator recording_to_remove = (++it).base(); bool was_current = (*recording_to_remove)->mPartialRecording.isCurrent(); llassert((*recording_to_remove)->mTargetRecording == recording); delete *recording_to_remove; @@ -216,25 +226,33 @@ void ThreadRecorder::ActiveRecording::movePartialToTarget() // called by child thread void ThreadRecorder::addChildRecorder( class ThreadRecorder* child ) -{ LLMutexLock lock(&mChildListMutex); - mChildThreadRecorders.push_back(child); +{ + { LLMutexLock lock(&mChildListMutex); + mChildThreadRecorders.push_back(child); + } } // called by child thread void ThreadRecorder::removeChildRecorder( class ThreadRecorder* child ) -{ LLMutexLock lock(&mChildListMutex); - -for (child_thread_recorder_list_t::iterator it = mChildThreadRecorders.begin(), end_it = mChildThreadRecorders.end(); - it != end_it; - ++it) -{ - if ((*it) == child) - { - mChildThreadRecorders.erase(it); - break; +{ + { LLMutexLock lock(&mChildListMutex); + for (child_thread_recorder_list_t::iterator it = mChildThreadRecorders.begin(), end_it = mChildThreadRecorders.end(); + it != end_it; + ++it) + { + if ((*it) == child) + { + // FIXME: this won't do any good, as the child stores the "pushed" values internally + // and it is in the process of being deleted. + // We need a way to finalize the stats from the outgoing thread, but the storage + // for those stats needs to be outside the child's thread recorder + //(*it)->pushToParent(); + mChildThreadRecorders.erase(it); + break; + } + } } } -} void ThreadRecorder::pushToParent() { @@ -269,7 +287,7 @@ void ThreadRecorder::pullFromChildren() } -void set_master_thread_recorder(ThreadRecorder* recorder) +void set_master_thread_recorder( ThreadRecorder* recorder ) { sMasterThreadRecorder = recorder; } @@ -291,7 +309,7 @@ const LLThreadLocalPointer& get_thread_recorder() return get_thread_recorder_ptr(); } -void set_thread_recorder(ThreadRecorder* recorder) +void set_thread_recorder( ThreadRecorder* recorder ) { get_thread_recorder_ptr() = recorder; } diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index c40228785e..c6afcdac80 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -49,7 +49,7 @@ namespace LLTrace void activate(AccumulatorBufferGroup* recording, bool from_handoff = false); void deactivate(AccumulatorBufferGroup* recording); - active_recording_list_t::reverse_iterator bringUpToDate(AccumulatorBufferGroup* recording); + active_recording_list_t::iterator bringUpToDate(AccumulatorBufferGroup* recording); void addChildRecorder(class ThreadRecorder* child); void removeChildRecorder(class ThreadRecorder* child); diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 0cfc11ef19..968b796d6b 100755 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1190,7 +1190,7 @@ void LLVertexBuffer::createGLBuffer(U32 size) mMappedData = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); disclaimMem(mSize); mSize = size; - disclaimMem(mSize); + claimMem(mSize); } } @@ -2272,10 +2272,10 @@ void LLVertexBuffer::setBuffer(U32 data_mask) if (unsatisfied_mask & (1 << TYPE_INDEX)) { - llinfos << "Missing indices" << llendl; + LL_INFOS() << "Missing indices" << LL_ENDL; } - llerrs << "Shader consumption mismatches data provision." << llendl; + LL_ERRS() << "Shader consumption mismatches data provision." << LL_ENDL; } } } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 051cf6d43e..8642114362 100755 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -2983,6 +2983,17 @@ Value Female Shape & Outfit + DefaultLoginLocation + + Comment + Startup destination default (if not specified on command line) + Persist + 1 + Type + String + Value + + DefaultMaleAvatar Comment diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 1ea428ff03..3099a1b74f 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2653,10 +2653,26 @@ bool LLAppViewer::initConfiguration() // What can happen is that someone can use IE (or potentially // other browsers) and do the rough equivalent of command // injection and steal passwords. Phoenix. SL-55321 - std::string CmdLineLoginLocation(gSavedSettings.getString("CmdLineLoginLocation")); - if(! CmdLineLoginLocation.empty()) + + std::string starting_location; + + std::string cmd_line_login_location(gSavedSettings.getString("CmdLineLoginLocation")); + if(! cmd_line_login_location.empty()) + { + starting_location = cmd_line_login_location; + } + else + { + std::string default_login_location(gSavedSettings.getString("DefaultLoginLocation")); + if (! default_login_location.empty()) + { + starting_location = default_login_location; + } + } + + if (! starting_location.empty()) { - LLSLURL start_slurl(CmdLineLoginLocation); + LLSLURL start_slurl(starting_location); LLStartUp::setStartSLURL(start_slurl); if(start_slurl.getType() == LLSLURL::LOCATION) { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index dd80a4f65d..f2abadce85 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4756,7 +4756,7 @@ bool LLViewerObject::isImageAlphaBlended(const U8 te) const case GL_RGB: break; default: { - llwarns << "Unexpected tex format in LLViewerObject::isImageAlphaBlended...returning no alpha." << llendl; + LL_WARNS() << "Unexpected tex format in LLViewerObject::isImageAlphaBlended...returning no alpha." << LL_ENDL; } break; } diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index d4decf383d..b2399123be 100755 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -110,6 +110,9 @@ + -- cgit v1.3 From 1821fa12838974c4eb7de2b6e9f79bf8a4cf23f1 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 3 Oct 2013 16:57:15 -0700 Subject: fixed memory tracking of lltrace system --- indra/llcommon/lltraceaccumulators.cpp | 17 +++++++++++++---- indra/llcommon/lltracethreadrecorder.cpp | 17 +++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 9f270e60b9..6381281a56 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -41,20 +41,29 @@ extern MemStatHandle gTraceMemStat; AccumulatorBufferGroup::AccumulatorBufferGroup() { - /*claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); +} + +AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup&) +{ + claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); + claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); + claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); } AccumulatorBufferGroup::~AccumulatorBufferGroup() { - /*disclaim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); + disclaim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); disclaim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); disclaim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); disclaim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator));*/ + disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); } void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index bf6189dd25..9dac4f6771 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -80,7 +80,7 @@ void ThreadRecorder::init() TimeBlock::getRootTimeBlock().getCurrentAccumulator().mActiveCount = 1; - claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, this); claim_alloc(gTraceMemStat, sizeof(BlockTimer)); claim_alloc(gTraceMemStat, sizeof(TimeBlockTreeNode) * mNumTimeBlockTreeNodes); } @@ -98,7 +98,7 @@ ThreadRecorder::~ThreadRecorder() { LLThreadLocalSingletonPointer::setInstance(NULL); - disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, this); disclaim_alloc(gTraceMemStat, sizeof(BlockTimer)); disclaim_alloc(gTraceMemStat, sizeof(TimeBlockTreeNode) * mNumTimeBlockTreeNodes); @@ -190,13 +190,13 @@ ThreadRecorder::active_recording_list_t::iterator ThreadRecorder::bringUpToDate( void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) { - active_recording_list_t::iterator recording_to_remove = bringUpToDate(recording); - if (recording_to_remove != mActiveRecordings.end()) + active_recording_list_t::iterator recording_it = bringUpToDate(recording); + if (recording_it != mActiveRecordings.end()) { - bool was_current = (*recording_to_remove)->mPartialRecording.isCurrent(); - llassert((*recording_to_remove)->mTargetRecording == recording); - delete *recording_to_remove; - mActiveRecordings.erase(recording_to_remove); + ActiveRecording* recording_to_remove = *recording_it; + bool was_current = recording_to_remove->mPartialRecording.isCurrent(); + llassert(recording_to_remove->mTargetRecording == recording); + mActiveRecordings.erase(recording_it); if (was_current) { if (mActiveRecordings.empty()) @@ -208,6 +208,7 @@ void ThreadRecorder::deactivate( AccumulatorBufferGroup* recording ) mActiveRecordings.back()->mPartialRecording.makeCurrent(); } } + delete recording_to_remove; } } -- cgit v1.3 From f8a85003ddd4bee1ae00fc329c1c1d66d6100cbd Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 3 Oct 2013 19:04:51 -0700 Subject: more memory optimizations of lltrace --- indra/llcommon/lltrace.h | 4 ++-- indra/llcommon/lltraceaccumulators.cpp | 7 ++++++- indra/llcommon/lltraceaccumulators.h | 38 +++++++++++++++++++--------------- indra/llcommon/lltracerecording.cpp | 22 ++++++++++---------- indra/newview/llfasttimerview.cpp | 2 +- indra/newview/llfasttimerview.h | 12 +++++------ indra/newview/llstartup.cpp | 4 ---- 7 files changed, 47 insertions(+), 42 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 421ec3bda5..3dc2e5248f 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -326,7 +326,7 @@ inline void claim_alloc(MemStatHandle& measurement, const T& value) if(size == 0) return; MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); - accumulator.mFootprintAllocations.record(size); + accumulator.mAllocations.record(size); } template @@ -336,7 +336,7 @@ inline void disclaim_alloc(MemStatHandle& measurement, const T& value) if(size == 0) return; MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); - accumulator.mFootprintDeallocations.add(size); + accumulator.mDeallocations.add(size); } template diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 6381281a56..c25bb704f5 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -48,7 +48,12 @@ AccumulatorBufferGroup::AccumulatorBufferGroup() claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); } -AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup&) +AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& other) +: mCounts(other.mCounts), + mSamples(other.mSamples), + mEvents(other.mEvents), + mStackTimers(other.mStackTimers), + mMemStats(other.mMemStats) { claim_alloc(gTraceMemStat, mCounts.capacity() * sizeof(CountAccumulator)); claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index d03c6ce5c0..27c0910665 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -266,8 +266,8 @@ namespace LLTrace void sync(F64SecondsImplicit) {} F64 getSum() const { return mSum; } - F64 getMin() const { return mMin; } - F64 getMax() const { return mMax; } + F32 getMin() const { return mMin; } + F32 getMax() const { return mMax; } F64 getLastValue() const { return mLastValue; } F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mNumSamples); } @@ -277,13 +277,14 @@ namespace LLTrace private: F64 mSum, - mMin, - mMax, mLastValue; F64 mMean, mSumOfSquares; + F32 mMin, + mMax; + S32 mNumSamples; }; @@ -350,8 +351,8 @@ namespace LLTrace } F64 getSum() const { return mSum; } - F64 getMin() const { return mMin; } - F64 getMax() const { return mMax; } + F32 getMin() const { return mMin; } + F32 getMax() const { return mMax; } F64 getLastValue() const { return mLastValue; } F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mTotalSamplingTime); } @@ -362,12 +363,8 @@ namespace LLTrace private: F64 mSum, - mMin, - mMax, mLastValue; - bool mHasValue; // distinct from mNumSamples, since we might have inherited an old sample - F64 mMean, mSumOfSquares; @@ -375,7 +372,13 @@ namespace LLTrace mLastSampleTimeStamp, mTotalSamplingTime; + F32 mMin, + mMax; + S32 mNumSamples; + // distinct from mNumSamples, since we might have inherited a last value from + // a previous sampling period + bool mHasValue; }; class CountAccumulator @@ -505,8 +508,8 @@ namespace LLTrace void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) { - mFootprintAllocations.addSamples(other.mFootprintAllocations, append_type); - mFootprintDeallocations.addSamples(other.mFootprintDeallocations, append_type); + mAllocations.addSamples(other.mAllocations, append_type); + mDeallocations.addSamples(other.mDeallocations, append_type); if (append_type == SEQUENTIAL) { @@ -514,7 +517,7 @@ namespace LLTrace } else { - F64 allocation_delta(other.mFootprintAllocations.getSum() - other.mFootprintDeallocations.getSum()); + F64 allocation_delta(other.mAllocations.getSum() - other.mDeallocations.getSum()); mSize.sample(mSize.hasValue() ? mSize.getLastValue() + allocation_delta : allocation_delta); @@ -524,8 +527,8 @@ namespace LLTrace void reset(const MemStatAccumulator* other) { mSize.reset(other ? &other->mSize : NULL); - mFootprintAllocations.reset(other ? &other->mFootprintAllocations : NULL); - mFootprintDeallocations.reset(other ? &other->mFootprintDeallocations : NULL); + mAllocations.reset(other ? &other->mAllocations : NULL); + mDeallocations.reset(other ? &other->mDeallocations : NULL); } void sync(F64SecondsImplicit time_stamp) @@ -534,13 +537,14 @@ namespace LLTrace } SampleAccumulator mSize; - EventAccumulator mFootprintAllocations; - CountAccumulator mFootprintDeallocations; + EventAccumulator mAllocations; + CountAccumulator mDeallocations; }; struct AccumulatorBufferGroup : public LLRefCount { AccumulatorBufferGroup(); + AccumulatorBufferGroup(const AccumulatorBufferGroup&); ~AccumulatorBufferGroup(); void handOffTo(AccumulatorBufferGroup& other); diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index c33d9aedcc..06b4351339 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -45,7 +45,7 @@ Recording::Recording(EPlayState state) : mElapsedSeconds(0), mInHandOff(false) { - claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, this); mBuffers = new AccumulatorBufferGroup(); claim_alloc(gTraceMemStat, mBuffers); setPlayState(state); @@ -53,7 +53,7 @@ Recording::Recording(EPlayState state) Recording::Recording( const Recording& other ) { - claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, this); *this = other; } @@ -79,7 +79,7 @@ Recording& Recording::operator = (const Recording& other) Recording::~Recording() { - disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, this); disclaim_alloc(gTraceMemStat, mBuffers); if (isStarted() && LLTrace::get_thread_recorder().notNull()) @@ -209,32 +209,32 @@ F64Kilobytes Recording::getLastValue(const TraceType& stat) F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mFootprintAllocations.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } F64Kilobytes Recording::getSum(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } F64Kilobytes Recording::getPerSec(const TraceType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSum() / mElapsedSeconds.value()); + return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const TraceType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mFootprintDeallocations.getSampleCount(); + return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } F64 Recording::getSum( const TraceType& stat ) @@ -339,12 +339,12 @@ PeriodicRecording::PeriodicRecording( S32 num_periods, EPlayState state) mRecordingPeriods(num_periods ? num_periods : 1) { setPlayState(state); - claim_alloc(gTraceMemStat, sizeof(*this)); + claim_alloc(gTraceMemStat, this); } PeriodicRecording::~PeriodicRecording() { - disclaim_alloc(gTraceMemStat, sizeof(*this)); + disclaim_alloc(gTraceMemStat, this); } void PeriodicRecording::nextPeriod() diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index bbd8f0792a..4809a6b7da 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -62,7 +62,7 @@ static const S32 MAX_VISIBLE_HISTORY = 12; static const S32 LINE_GRAPH_HEIGHT = 240; static const S32 MIN_BAR_HEIGHT = 3; static const S32 RUNNING_AVERAGE_WIDTH = 100; -static const S32 NUM_FRAMES_HISTORY = 256; +static const S32 NUM_FRAMES_HISTORY = 200; std::vector ft_display_idx; // line of table entry for display purposes (for collapse) diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h index 8c8eb99b59..672bb5d7ca 100755 --- a/indra/newview/llfasttimerview.h +++ b/indra/newview/llfasttimerview.h @@ -87,12 +87,12 @@ private: mFirstChild(false), mLastChild(false) {} - F32Seconds mTotalTime, - mSelfTime, - mChildrenStart, - mChildrenEnd, - mSelfStart, - mSelfEnd; + F32Seconds mTotalTime, + mSelfTime, + mChildrenStart, + mChildrenEnd, + mSelfStart, + mSelfEnd; LLTrace::TimeBlock* mTimeBlock; bool mVisible, mFirstChild, diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 39ced906ad..72c76f9424 100755 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2176,10 +2176,6 @@ bool idle_startup() // reset keyboard focus to sane state of pointing at world gFocusMgr.setKeyboardFocus(NULL); -#if 0 // sjb: enable for auto-enabling timer display - gDebugView->mFastTimerView->setVisible(TRUE); -#endif - LLAppViewer::instance()->handleLoginComplete(); LLAgentPicksInfo::getInstance()->requestNumberOfPicks(); -- cgit v1.3 From 17df8988fec3f2ba991ca9e34ff8148253a2fc04 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 7 Oct 2013 13:38:03 -0700 Subject: renamed TraceType to StatType added more MemTrackable types optimized memory usage of LLTrace some more --- indra/llcommon/llfasttimer.cpp | 2 +- indra/llcommon/llfasttimer.h | 10 +- indra/llcommon/lltrace.cpp | 4 +- indra/llcommon/lltrace.h | 127 +++++++++------- indra/llcommon/lltraceaccumulators.cpp | 8 +- indra/llcommon/lltraceaccumulators.h | 18 +-- indra/llcommon/lltracerecording.cpp | 104 ++++++------- indra/llcommon/lltracerecording.h | 166 ++++++++++----------- indra/llrender/lltexture.h | 8 +- indra/llui/llstatbar.cpp | 26 ++-- indra/llui/llstatbar.h | 8 +- indra/llui/llstatgraph.h | 8 +- indra/llui/lltextbase.cpp | 1 - indra/newview/lldrawable.cpp | 4 +- indra/newview/lldrawable.h | 2 +- indra/newview/lldynamictexture.h | 6 +- indra/newview/llface.h | 21 +-- indra/newview/llscenemonitor.cpp | 8 +- indra/newview/llspatialpartition.cpp | 36 ++--- indra/newview/llspatialpartition.h | 26 +--- indra/newview/llvieweroctree.cpp | 120 +++++++-------- indra/newview/llvieweroctree.h | 90 +++++------ indra/newview/llviewerregion.cpp | 10 +- indra/newview/llviewerregion.h | 4 +- indra/newview/llviewerstats.cpp | 14 +- indra/newview/llvoavatar.h | 6 +- indra/newview/llvoavatarself.h | 10 -- indra/newview/llvocache.cpp | 20 +-- indra/newview/llvocache.h | 2 +- .../newview/skins/default/xui/en/floater_stats.xml | 17 ++- 30 files changed, 439 insertions(+), 447 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 32ef01b2b6..c948e0ac85 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -165,7 +165,7 @@ U64 TimeBlock::countsPerSecond() #endif TimeBlock::TimeBlock(const char* name, TimeBlock* parent) -: TraceType(name) +: StatType(name) {} TimeBlockTreeNode& TimeBlock::getTreeNode() const diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 4eb12907dc..1266d87f08 100755 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -86,7 +86,7 @@ LL_FORCE_INLINE class BlockTimer timeThisBlock(class TimeBlock& timer) // stores a "named" timer instance to be reused via multiple BlockTimer stack instances class TimeBlock -: public TraceType, +: public StatType, public LLInstanceTracker { public: @@ -102,14 +102,14 @@ public: child_iter endChildren(); std::vector& getChildren(); - TraceType& callCount() + StatType& callCount() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } - TraceType& selfTime() + StatType& selfTime() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } static TimeBlock& getRootTimeBlock(); diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 73846ba900..1ad31cacfe 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -35,7 +35,7 @@ namespace LLTrace MemStatHandle gTraceMemStat("LLTrace"); -TraceBase::TraceBase( const char* name, const char* description ) +StatBase::StatBase( const char* name, const char* description ) : mName(name), mDescription(description ? description : "") { @@ -47,7 +47,7 @@ TraceBase::TraceBase( const char* name, const char* description ) #endif } -const char* TraceBase::getUnitLabel() const +const char* StatBase::getUnitLabel() const { return ""; } diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 3dc2e5248f..325112b9b1 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -38,8 +38,6 @@ #include "llpointer.h" #include "llunits.h" -#include - namespace LLTrace { class Recording; @@ -53,11 +51,11 @@ STORAGE_TYPE storage_value(LLUnit val) { return val.val template STORAGE_TYPE storage_value(LLUnitImplicit val) { return val.value(); } -class TraceBase +class StatBase { public: - TraceBase(const char* name, const char* description); - virtual ~TraceBase() {}; + StatBase(const char* name, const char* description); + virtual ~StatBase() {}; virtual const char* getUnitLabel() const; const std::string& getName() const { return mName; } @@ -69,14 +67,14 @@ protected: }; template -class TraceType -: public TraceBase, - public LLInstanceTracker, std::string> +class StatType +: public StatBase, + public LLInstanceTracker, std::string> { public: - TraceType(const char* name, const char* description = NULL) - : LLInstanceTracker, std::string>(name), - TraceBase(name, description), + StatType(const char* name, const char* description = NULL) + : LLInstanceTracker, std::string>(name), + StatBase(name, description), mAccumulatorIndex(AccumulatorBuffer::getDefaultBuffer()->reserveSlot()) {} @@ -95,38 +93,38 @@ protected: template<> -class TraceType -: public TraceType +class StatType +: public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; template<> -class TraceType - : public TraceType +class StatType + : public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; template class EventStatHandle -: public TraceType +: public StatType { public: typedef F64 storage_t; - typedef TraceType trace_t; + typedef StatType stat_t; typedef EventStatHandle self_t; EventStatHandle(const char* name, const char* description = NULL) - : trace_t(name, description) + : stat_t(name, description) {} /*virtual*/ const char* getUnitLabel() const { return LLGetUnitLabel::getUnitLabel(); } @@ -142,15 +140,15 @@ void record(EventStatHandle& measurement, VALUE_T value) template class SampleStatHandle -: public TraceType +: public StatType { public: typedef F64 storage_t; - typedef TraceType trace_t; + typedef StatType stat_t; typedef SampleStatHandle self_t; SampleStatHandle(const char* name, const char* description = NULL) - : trace_t(name, description) + : stat_t(name, description) {} /*virtual*/ const char* getUnitLabel() const { return LLGetUnitLabel::getUnitLabel(); } @@ -165,15 +163,15 @@ void sample(SampleStatHandle& measurement, VALUE_T value) template class CountStatHandle -: public TraceType +: public StatType { public: typedef F64 storage_t; - typedef TraceType trace_t; + typedef StatType stat_t; typedef CountStatHandle self_t; CountStatHandle(const char* name, const char* description = NULL) - : trace_t(name, description) + : stat_t(name, description) {} /*virtual*/ const char* getUnitLabel() const { return LLGetUnitLabel::getUnitLabel(); } @@ -187,34 +185,36 @@ void add(CountStatHandle& count, VALUE_T value) } template<> -class TraceType -: public TraceType +class StatType +: public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; template<> -class TraceType -: public TraceType +class StatType +: public StatType { public: - TraceType(const char* name, const char* description = "") - : TraceType(name, description) + StatType(const char* name, const char* description = "") + : StatType(name, description) {} }; -class MemStatHandle : public TraceType +class MemStatHandle : public StatType { public: - typedef TraceType trace_t; + typedef StatType stat_t; MemStatHandle(const char* name) - : trace_t(name) - {} + : stat_t(name) + { + mName = name; + } void setName(const char* name) { @@ -224,14 +224,14 @@ public: /*virtual*/ const char* getUnitLabel() const { return "KB"; } - TraceType& allocations() + StatType& allocations() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } - TraceType& deallocations() + StatType& deallocations() { - return static_cast&>(*(TraceType*)this); + return static_cast&>(*(StatType*)this); } }; @@ -324,7 +324,7 @@ inline void claim_alloc(MemStatHandle& measurement, const T& value) { S32 size = MeasureMem::measureFootprint(value); if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + MemAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() + (F64)size : (F64)size); accumulator.mAllocations.record(size); } @@ -334,18 +334,18 @@ inline void disclaim_alloc(MemStatHandle& measurement, const T& value) { S32 size = MeasureMem::measureFootprint(value); if(size == 0) return; - MemStatAccumulator& accumulator = measurement.getCurrentAccumulator(); + MemAccumulator& accumulator = measurement.getCurrentAccumulator(); accumulator.mSize.sample(accumulator.mSize.hasValue() ? accumulator.mSize.getLastValue() - (F64)size : -(F64)size); accumulator.mDeallocations.add(size); } template -class MemTrackable +class MemTrackableNonVirtual { public: typedef void mem_trackable_tag_t; - MemTrackable(const char* name) + MemTrackableNonVirtual(const char* name) : mMemFootprint(0) { static bool name_initialized = false; @@ -356,7 +356,7 @@ public: } } - virtual ~MemTrackable() + ~MemTrackableNonVirtual() { disclaimMem(mMemFootprint); } @@ -374,12 +374,27 @@ public: return ll_aligned_malloc(ALIGNMENT, size); } + template + static void* aligned_new(size_t size) + { + claim_alloc(sMemStat, size); + return ll_aligned_malloc(CUSTOM_ALIGNMENT, size); + } + void operator delete(void* ptr, size_t size) { disclaim_alloc(sMemStat, size); ll_aligned_free(ALIGNMENT, ptr); } + template + static void aligned_delete(void* ptr, size_t size) + { + disclaim_alloc(sMemStat, size); + ll_aligned_free(CUSTOM_ALIGNMENT, ptr); + } + + void* operator new [](size_t size) { claim_alloc(sMemStat, size); @@ -420,7 +435,19 @@ private: }; template -MemStatHandle MemTrackable::sMemStat(""); +MemStatHandle MemTrackableNonVirtual::sMemStat(typeid(MemTrackableNonVirtual).name()); +template +class MemTrackable : public MemTrackableNonVirtual +{ +public: + MemTrackable(const char* name) + : MemTrackableNonVirtual(name) + {} + + virtual ~MemTrackable() + {} +}; } + #endif // LL_LLTRACE_H diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index c25bb704f5..7d0e63e76a 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -45,7 +45,7 @@ AccumulatorBufferGroup::AccumulatorBufferGroup() claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& other) @@ -59,7 +59,7 @@ AccumulatorBufferGroup::AccumulatorBufferGroup(const AccumulatorBufferGroup& oth claim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); claim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); claim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + claim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } AccumulatorBufferGroup::~AccumulatorBufferGroup() @@ -68,7 +68,7 @@ AccumulatorBufferGroup::~AccumulatorBufferGroup() disclaim_alloc(gTraceMemStat, mSamples.capacity() * sizeof(SampleAccumulator)); disclaim_alloc(gTraceMemStat, mEvents.capacity() * sizeof(EventAccumulator)); disclaim_alloc(gTraceMemStat, mStackTimers.capacity() * sizeof(TimeBlockAccumulator)); - disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemStatAccumulator)); + disclaim_alloc(gTraceMemStat, mMemStats.capacity() * sizeof(MemAccumulator)); } void AccumulatorBufferGroup::handOffTo(AccumulatorBufferGroup& other) @@ -108,7 +108,7 @@ void AccumulatorBufferGroup::clearCurrent() AccumulatorBuffer::clearCurrent(); AccumulatorBuffer::clearCurrent(); AccumulatorBuffer::clearCurrent(); - AccumulatorBuffer::clearCurrent(); + AccumulatorBuffer::clearCurrent(); } bool AccumulatorBufferGroup::isCurrent() const diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 27c0910665..85873d469a 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -52,7 +52,7 @@ namespace LLTrace class AccumulatorBuffer : public LLRefCount { typedef AccumulatorBuffer self_t; - static const S32 ACCUMULATOR_BUFFER_SIZE_INCREMENT = 16; + static const S32 DEFAULT_ACCUMULATOR_BUFFER_SIZE = 32; private: struct StaticAllocationMarker { }; @@ -67,7 +67,7 @@ namespace LLTrace : mStorageSize(0), mStorage(NULL) { - resize(other.mStorageSize); + resize(sNextStorageSlot); for (S32 i = 0; i < sNextStorageSlot; i++) { mStorage[i] = other.mStorage[i]; @@ -152,7 +152,7 @@ namespace LLTrace { // don't perform doubling, as this should only happen during startup // want to keep a tight bounds as we will have a lot of these buffers - resize(mStorageSize + ACCUMULATOR_BUFFER_SIZE_INCREMENT); + resize(mStorageSize + mStorageSize / 2); } llassert(mStorage && next_slot < mStorageSize); return next_slot; @@ -207,7 +207,7 @@ namespace LLTrace // so as not to trigger an access violation sDefaultBuffer = new AccumulatorBuffer(StaticAllocationMarker()); sInitialized = true; - sDefaultBuffer->resize(ACCUMULATOR_BUFFER_SIZE_INCREMENT); + sDefaultBuffer->resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE); } return sDefaultBuffer; } @@ -491,9 +491,9 @@ namespace LLTrace U64 mChildTime; }; - struct MemStatAccumulator + struct MemAccumulator { - typedef MemStatAccumulator self_t; + typedef MemAccumulator self_t; // fake classes that allows us to view different facets of underlying statistic struct AllocationFacet @@ -506,7 +506,7 @@ namespace LLTrace typedef F64Bytes value_t; }; - void addSamples(const MemStatAccumulator& other, EBufferAppendType append_type) + void addSamples(const MemAccumulator& other, EBufferAppendType append_type) { mAllocations.addSamples(other.mAllocations, append_type); mDeallocations.addSamples(other.mDeallocations, append_type); @@ -524,7 +524,7 @@ namespace LLTrace } } - void reset(const MemStatAccumulator* other) + void reset(const MemAccumulator* other) { mSize.reset(other ? &other->mSize : NULL); mAllocations.reset(other ? &other->mAllocations : NULL); @@ -561,7 +561,7 @@ namespace LLTrace AccumulatorBuffer mSamples; AccumulatorBuffer mEvents; AccumulatorBuffer mStackTimers; - AccumulatorBuffer mMemStats; + AccumulatorBuffer mMemStats; }; } diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 06b4351339..87083eee96 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -137,26 +137,26 @@ void Recording::appendRecording( Recording& other ) mElapsedSeconds += other.mElapsedSeconds; } -F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mTotalTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -F64Seconds Recording::getSum(const TraceType& stat) +F64Seconds Recording::getSum(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::TimeBlock::countsPerSecond()); } -S32 Recording::getSum(const TraceType& stat) +S32 Recording::getSum(const StatType& stat) { return mBuffers->mStackTimers[stat.getIndex()].mCalls; } -F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -164,7 +164,7 @@ F64Seconds Recording::getPerSec(const TraceType& stat) / ((F64)LLTrace::TimeBlock::countsPerSecond() * mElapsedSeconds.value())); } -F64Seconds Recording::getPerSec(const TraceType& stat) +F64Seconds Recording::getPerSec(const StatType& stat) { const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; @@ -172,158 +172,158 @@ F64Seconds Recording::getPerSec(const TraceType& stat) +F32 Recording::getPerSec(const StatType& stat) { return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); } -F64Kilobytes Recording::getMin(const TraceType& stat) +F64Kilobytes Recording::getMin(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); } -F64Kilobytes Recording::getMean(const TraceType& stat) +F64Kilobytes Recording::getMean(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); } -F64Kilobytes Recording::getMax(const TraceType& stat) +F64Kilobytes Recording::getMax(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); } -F64Kilobytes Recording::getStandardDeviation(const TraceType& stat) +F64Kilobytes Recording::getStandardDeviation(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); } -F64Kilobytes Recording::getLastValue(const TraceType& stat) +F64Kilobytes Recording::getLastValue(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); } -F64Kilobytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); } -F64Kilobytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); } -S32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); } -F64Kilobytes Recording::getSum(const TraceType& stat) +F64Kilobytes Recording::getSum(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); } -F64Kilobytes Recording::getPerSec(const TraceType& stat) +F64Kilobytes Recording::getPerSec(const StatType& stat) { return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); } -S32 Recording::getSampleCount(const TraceType& stat) +S32 Recording::getSampleCount(const StatType& stat) { return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); } -F64 Recording::getSum( const TraceType& stat ) +F64 Recording::getSum( const StatType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSum(); } -F64 Recording::getSum( const TraceType& stat ) +F64 Recording::getSum( const StatType& stat ) { return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); } -F64 Recording::getPerSec( const TraceType& stat ) +F64 Recording::getPerSec( const StatType& stat ) { F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); return sum / mElapsedSeconds.value(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mCounts[stat.getIndex()].getSampleCount(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mSamples[stat.getIndex()].hasValue(); } -F64 Recording::getMin( const TraceType& stat ) +F64 Recording::getMin( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType& stat ) +F64 Recording::getMax( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType& stat ) +F64 Recording::getMean( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType& stat ) +F64 Recording::getStandardDeviation( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType& stat ) +F64 Recording::getLastValue( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getLastValue(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mSamples[stat.getIndex()].getSampleCount(); } -bool Recording::hasValue(const TraceType& stat) +bool Recording::hasValue(const StatType& stat) { return mBuffers->mEvents[stat.getIndex()].hasValue(); } -F64 Recording::getMin( const TraceType& stat ) +F64 Recording::getMin( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMin(); } -F64 Recording::getMax( const TraceType& stat ) +F64 Recording::getMax( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMax(); } -F64 Recording::getMean( const TraceType& stat ) +F64 Recording::getMean( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getMean(); } -F64 Recording::getStandardDeviation( const TraceType& stat ) +F64 Recording::getStandardDeviation( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); } -F64 Recording::getLastValue( const TraceType& stat ) +F64 Recording::getLastValue( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getLastValue(); } -S32 Recording::getSampleCount( const TraceType& stat ) +S32 Recording::getSampleCount( const StatType& stat ) { return mBuffers->mEvents[stat.getIndex()].getSampleCount(); } @@ -534,7 +534,7 @@ void PeriodicRecording::handleSplitTo(PeriodicRecording& other) getCurRecording().splitTo(other.getCurRecording()); } -F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -556,7 +556,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S3 : NaN; } -F64 PeriodicRecording::getPeriodMax( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMax( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -579,7 +579,7 @@ F64 PeriodicRecording::getPeriodMax( const TraceType& stat, S3 } // calculates means using aggregates per period -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -603,7 +603,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -628,7 +628,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -650,7 +650,7 @@ F64 PeriodicRecording::getPeriodMin( const TraceType& stat, S : NaN; } -F64 PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) +F64 PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -673,7 +673,7 @@ F64 PeriodicRecording::getPeriodMax(const TraceType& stat, S3 } -F64 PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -696,7 +696,7 @@ F64 PeriodicRecording::getPeriodMean( const TraceType& stat, : NaN; } -F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64 PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -722,7 +722,7 @@ F64 PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMin( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -739,10 +739,10 @@ F64Kilobytes PeriodicRecording::getPeriodMin( const TraceType&>(stat), num_periods); + return getPeriodMin(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType& stat, S32 num_periods /*= S32_MAX*/) +F64Kilobytes PeriodicRecording::getPeriodMax(const StatType& stat, S32 num_periods /*= S32_MAX*/) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -759,10 +759,10 @@ F64Kilobytes PeriodicRecording::getPeriodMax(const TraceType F64Kilobytes PeriodicRecording::getPeriodMax(const MemStatHandle& stat, S32 num_periods) { - return getPeriodMax(static_cast&>(stat), num_periods); + return getPeriodMax(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodMean( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -780,10 +780,10 @@ F64Kilobytes PeriodicRecording::getPeriodMean( const TraceType&>(stat), num_periods); + return getPeriodMean(static_cast&>(stat), num_periods); } -F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType& stat, S32 num_periods /*= S32_MAX*/ ) +F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const StatType& stat, S32 num_periods /*= S32_MAX*/ ) { S32 total_periods = mRecordingPeriods.size(); num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -810,7 +810,7 @@ F64Kilobytes PeriodicRecording::getPeriodStandardDeviation( const TraceType&>(stat), num_periods); + return getPeriodStandardDeviation(static_cast&>(stat), num_periods); } /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 8bb0b1892f..810f796666 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -113,7 +113,7 @@ private: namespace LLTrace { template - class TraceType; + class StatType; template class CountStatHandle; @@ -168,135 +168,135 @@ namespace LLTrace void makeUnique() { mBuffers.makeUnique(); } // Timer accessors - F64Seconds getSum(const TraceType& stat); - F64Seconds getSum(const TraceType& stat); - S32 getSum(const TraceType& stat); + F64Seconds getSum(const StatType& stat); + F64Seconds getSum(const StatType& stat); + S32 getSum(const StatType& stat); - F64Seconds getPerSec(const TraceType& stat); - F64Seconds getPerSec(const TraceType& stat); - F32 getPerSec(const TraceType& stat); + F64Seconds getPerSec(const StatType& stat); + F64Seconds getPerSec(const StatType& stat); + F32 getPerSec(const StatType& stat); // Memory accessors - bool hasValue(const TraceType& stat); + bool hasValue(const StatType& stat); - F64Kilobytes getMin(const TraceType& stat); - F64Kilobytes getMean(const TraceType& stat); - F64Kilobytes getMax(const TraceType& stat); - F64Kilobytes getStandardDeviation(const TraceType& stat); - F64Kilobytes getLastValue(const TraceType& stat); + F64Kilobytes getMin(const StatType& stat); + F64Kilobytes getMean(const StatType& stat); + F64Kilobytes getMax(const StatType& stat); + F64Kilobytes getStandardDeviation(const StatType& stat); + F64Kilobytes getLastValue(const StatType& stat); - F64Kilobytes getSum(const TraceType& stat); - F64Kilobytes getPerSec(const TraceType& stat); - S32 getSampleCount(const TraceType& stat); + F64Kilobytes getSum(const StatType& stat); + F64Kilobytes getPerSec(const StatType& stat); + S32 getSampleCount(const StatType& stat); - F64Kilobytes getSum(const TraceType& stat); - F64Kilobytes getPerSec(const TraceType& stat); - S32 getSampleCount(const TraceType& stat); + F64Kilobytes getSum(const StatType& stat); + F64Kilobytes getPerSec(const StatType& stat); + S32 getSampleCount(const StatType& stat); // CountStatHandle accessors - F64 getSum(const TraceType& stat); + F64 getSum(const StatType& stat); template typename RelatedTypes::sum_t getSum(const CountStatHandle& stat) { - return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); + return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); } - F64 getPerSec(const TraceType& stat); + F64 getPerSec(const StatType& stat); template typename RelatedTypes::fractional_t getPerSec(const CountStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getPerSec(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getPerSec(static_cast&> (stat)); } - S32 getSampleCount(const TraceType& stat); + S32 getSampleCount(const StatType& stat); // SampleStatHandle accessors - bool hasValue(const TraceType& stat); + bool hasValue(const StatType& stat); - F64 getMin(const TraceType& stat); + F64 getMin(const StatType& stat); template T getMin(const SampleStatHandle& stat) { - return (T)getMin(static_cast&> (stat)); + return (T)getMin(static_cast&> (stat)); } - F64 getMax(const TraceType& stat); + F64 getMax(const StatType& stat); template T getMax(const SampleStatHandle& stat) { - return (T)getMax(static_cast&> (stat)); + return (T)getMax(static_cast&> (stat)); } - F64 getMean(const TraceType& stat); + F64 getMean(const StatType& stat); template typename RelatedTypes::fractional_t getMean(SampleStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); } - F64 getStandardDeviation(const TraceType& stat); + F64 getStandardDeviation(const StatType& stat); template typename RelatedTypes::fractional_t getStandardDeviation(const SampleStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); } - F64 getLastValue(const TraceType& stat); + F64 getLastValue(const StatType& stat); template T getLastValue(const SampleStatHandle& stat) { - return (T)getLastValue(static_cast&> (stat)); + return (T)getLastValue(static_cast&> (stat)); } - S32 getSampleCount(const TraceType& stat); + S32 getSampleCount(const StatType& stat); // EventStatHandle accessors - bool hasValue(const TraceType& stat); + bool hasValue(const StatType& stat); - F64 getSum(const TraceType& stat); + F64 getSum(const StatType& stat); template typename RelatedTypes::sum_t getSum(const EventStatHandle& stat) { - return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); + return (typename RelatedTypes::sum_t)getSum(static_cast&> (stat)); } - F64 getMin(const TraceType& stat); + F64 getMin(const StatType& stat); template T getMin(const EventStatHandle& stat) { - return (T)getMin(static_cast&> (stat)); + return (T)getMin(static_cast&> (stat)); } - F64 getMax(const TraceType& stat); + F64 getMax(const StatType& stat); template T getMax(const EventStatHandle& stat) { - return (T)getMax(static_cast&> (stat)); + return (T)getMax(static_cast&> (stat)); } - F64 getMean(const TraceType& stat); + F64 getMean(const StatType& stat); template typename RelatedTypes::fractional_t getMean(EventStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getMean(static_cast&> (stat)); } - F64 getStandardDeviation(const TraceType& stat); + F64 getStandardDeviation(const StatType& stat); template typename RelatedTypes::fractional_t getStandardDeviation(const EventStatHandle& stat) { - return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); + return (typename RelatedTypes::fractional_t)getStandardDeviation(static_cast&> (stat)); } - F64 getLastValue(const TraceType& stat); + F64 getLastValue(const StatType& stat); template T getLastValue(const EventStatHandle& stat) { - return (T)getLastValue(static_cast&> (stat)); + return (T)getLastValue(static_cast&> (stat)); } - S32 getSampleCount(const TraceType& stat); + S32 getSampleCount(const StatType& stat); F64Seconds getDuration() const { return mElapsedSeconds; } @@ -342,7 +342,7 @@ namespace LLTrace Recording snapshotCurRecording() const; template - S32 getSampleCount(const TraceType& stat, S32 num_periods = S32_MAX) + S32 getSampleCount(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -362,7 +362,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename T::value_t getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX) + typename T::value_t getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -379,28 +379,28 @@ namespace LLTrace template T getPeriodMin(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMin(static_cast&>(stat), num_periods)); + return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64 getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMin(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMin(static_cast&>(stat), num_periods)); + return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64 getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMin(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMin(static_cast&>(stat), num_periods)); + return T(getPeriodMin(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMin(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMin(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodMin(const MemStatHandle& stat, S32 num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMinPerSec(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMinPerSec(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -417,7 +417,7 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMinPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMinPerSec(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMinPerSec(static_cast&>(stat), num_periods)); } // @@ -426,7 +426,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename T::value_t getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX) + typename T::value_t getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -443,28 +443,28 @@ namespace LLTrace template T getPeriodMax(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMax(static_cast&>(stat), num_periods)); + return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64 getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMax(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMax(static_cast&>(stat), num_periods)); + return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64 getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); template T getPeriodMax(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return T(getPeriodMax(static_cast&>(stat), num_periods)); + return T(getPeriodMax(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMax(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMax(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodMax(const MemStatHandle& stat, S32 num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMaxPerSec(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMaxPerSec(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -481,7 +481,7 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMaxPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMaxPerSec(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMaxPerSec(static_cast&>(stat), num_periods)); } // @@ -490,7 +490,7 @@ namespace LLTrace // catch all for stats that have a defined sum template - typename RelatedTypes::fractional_t getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -513,27 +513,27 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMean(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64 getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodMean(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64 getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodMean(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMean(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodMean(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodMean(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodMean(const MemStatHandle& stat, S32 num_periods = S32_MAX); template - typename RelatedTypes::fractional_t getPeriodMeanPerSec(const TraceType& stat, S32 num_periods = S32_MAX) + typename RelatedTypes::fractional_t getPeriodMeanPerSec(const StatType& stat, S32 num_periods = S32_MAX) { S32 total_periods = mNumPeriods; num_periods = llmin(num_periods, isStarted() ? total_periods - 1 : total_periods); @@ -557,29 +557,29 @@ namespace LLTrace template typename RelatedTypes::fractional_t getPeriodMeanPerSec(const CountStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodMeanPerSec(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodMeanPerSec(static_cast&>(stat), num_periods)); } // // PERIODIC STANDARD DEVIATION // - F64 getPeriodStandardDeviation(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodStandardDeviation(const SampleStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); } - F64 getPeriodStandardDeviation(const TraceType& stat, S32 num_periods = S32_MAX); + F64 getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); template typename RelatedTypes::fractional_t getPeriodStandardDeviation(const EventStatHandle& stat, S32 num_periods = S32_MAX) { - return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); + return typename RelatedTypes::fractional_t(getPeriodStandardDeviation(static_cast&>(stat), num_periods)); } - F64Kilobytes getPeriodStandardDeviation(const TraceType& stat, S32 num_periods = S32_MAX); + F64Kilobytes getPeriodStandardDeviation(const StatType& stat, S32 num_periods = S32_MAX); F64Kilobytes getPeriodStandardDeviation(const MemStatHandle& stat, S32 num_periods = S32_MAX); private: diff --git a/indra/llrender/lltexture.h b/indra/llrender/lltexture.h index ff711b8004..9fca8b8cd3 100755 --- a/indra/llrender/lltexture.h +++ b/indra/llrender/lltexture.h @@ -33,6 +33,8 @@ #define LL_TEXTURE_H #include "llrefcount.h" +#include "lltrace.h" + class LLImageGL ; class LLTexUnit ; class LLFontGL ; @@ -40,7 +42,7 @@ class LLFontGL ; // //this is an abstract class as the parent for the class LLGLTexture // -class LLTexture : public virtual LLRefCount +class LLTexture : public virtual LLRefCount, public LLTrace::MemTrackable { friend class LLTexUnit ; friend class LLFontGL ; @@ -49,7 +51,9 @@ protected: virtual ~LLTexture(); public: - LLTexture(){} + LLTexture() + : LLTrace::MemTrackable("LLTexture") + {} // //interfaces to access LLGLTexture diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index bc8235132e..24256c3193 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -284,7 +284,7 @@ S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const return num_rapid_changes; } -S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::TraceType& stat, const F32Seconds time_period) +S32 calc_num_rapid_changes(LLTrace::PeriodicRecording& periodic_recording, const LLTrace::StatType& stat, const F32Seconds time_period) { F32Seconds elapsed_time, time_since_value_changed; @@ -332,7 +332,7 @@ void LLStatBar::draw() { case STAT_COUNT: { - const LLTrace::TraceType& count_stat = *mStat.countStatp; + const LLTrace::StatType& count_stat = *mStat.countStatp; unit_label = std::string(count_stat.getUnitLabel()) + "/s"; current = last_frame_recording.getPerSec(count_stat); @@ -344,7 +344,7 @@ void LLStatBar::draw() break; case STAT_EVENT: { - const LLTrace::TraceType& event_stat = *mStat.eventStatp; + const LLTrace::StatType& event_stat = *mStat.eventStatp; unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; current = last_frame_recording.getLastValue(event_stat); @@ -356,7 +356,7 @@ void LLStatBar::draw() break; case STAT_SAMPLE: { - const LLTrace::TraceType& sample_stat = *mStat.sampleStatp; + const LLTrace::StatType& sample_stat = *mStat.sampleStatp; unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; current = last_frame_recording.getLastValue(sample_stat); @@ -379,7 +379,7 @@ void LLStatBar::draw() break; case STAT_MEM: { - const LLTrace::TraceType& mem_stat = *mStat.memStatp; + const LLTrace::StatType& mem_stat = *mStat.memStatp; unit_label = mUnitLabel.empty() ? mem_stat.getUnitLabel() : mUnitLabel; current = last_frame_recording.getLastValue(mem_stat).value(); @@ -578,27 +578,27 @@ void LLStatBar::draw() void LLStatBar::setStat(const std::string& stat_name) { using namespace LLTrace; - const TraceType* count_stat; - const TraceType* event_stat; - const TraceType* sample_stat; - const TraceType* mem_stat; + const StatType* count_stat; + const StatType* event_stat; + const StatType* sample_stat; + const StatType* mem_stat; - if ((count_stat = TraceType::getInstance(stat_name))) + if ((count_stat = StatType::getInstance(stat_name))) { mStat.countStatp = count_stat; mStatType = STAT_COUNT; } - else if ((event_stat = TraceType::getInstance(stat_name))) + else if ((event_stat = StatType::getInstance(stat_name))) { mStat.eventStatp = event_stat; mStatType = STAT_EVENT; } - else if ((sample_stat = TraceType::getInstance(stat_name))) + else if ((sample_stat = StatType::getInstance(stat_name))) { mStat.sampleStatp = sample_stat; mStatType = STAT_SAMPLE; } - else if ((mem_stat = TraceType::getInstance(stat_name))) + else if ((mem_stat = StatType::getInstance(stat_name))) { mStat.memStatp = mem_stat; mStatType = STAT_MEM; diff --git a/indra/llui/llstatbar.h b/indra/llui/llstatbar.h index 5e9255b9eb..57e492bc80 100755 --- a/indra/llui/llstatbar.h +++ b/indra/llui/llstatbar.h @@ -105,10 +105,10 @@ private: union { void* valid; - const LLTrace::TraceType* countStatp; - const LLTrace::TraceType* eventStatp; - const LLTrace::TraceType* sampleStatp; - const LLTrace::TraceType* memStatp; + const LLTrace::StatType* countStatp; + const LLTrace::StatType* eventStatp; + const LLTrace::StatType* sampleStatp; + const LLTrace::StatType* memStatp; } mStat; LLUIString mLabel; diff --git a/indra/llui/llstatgraph.h b/indra/llui/llstatgraph.h index 38fe12d18b..f381e92a4d 100755 --- a/indra/llui/llstatgraph.h +++ b/indra/llui/llstatgraph.h @@ -57,9 +57,9 @@ public: struct StatParams : public LLInitParam::ChoiceBlock { - Alternative* > count_stat_float; - Alternative* > event_stat_float; - Alternative* > sample_stat_float; + Alternative* > count_stat_float; + Alternative* > event_stat_float; + Alternative* > sample_stat_float; }; struct Params : public LLInitParam::Block @@ -104,7 +104,7 @@ public: /*virtual*/ void setValue(const LLSD& value); private: - LLTrace::TraceType* mNewStatFloatp; + LLTrace::StatType* mNewStatFloatp; BOOL mPerSec; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 730c3b2ada..00382125a8 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1871,7 +1871,6 @@ LLTextBase::segment_set_t::iterator LLTextBase::getSegIterContaining(S32 index) // when there are no segments, we return the end iterator, which must be checked by caller if (mSegments.size() <= 1) { return mSegments.begin(); } - //FIXME: avoid operator new somehow (without running into refcount problems) index_segment->setStart(index); index_segment->setEnd(index); segment_set_t::iterator it = mSegments.upper_bound(index_segment); diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 4b6c80b51a..5981153bd5 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -1047,7 +1047,7 @@ bool LLDrawable::isVisible() const } { - LLviewerOctreeGroup* group = mEntry->getGroup(); + LLViewerOctreeGroup* group = mEntry->getGroup(); if (group && group->isVisible()) { LLViewerOctreeEntryData::setVisible(); @@ -1073,7 +1073,7 @@ bool LLDrawable::isRecentlyVisible() const return vis ; } -void LLDrawable::setGroup(LLviewerOctreeGroup *groupp) +void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) { LLSpatialGroup* cur_groupp = (LLSpatialGroup*)getGroup(); diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 067cee6838..a3461d4c01 100755 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -176,7 +176,7 @@ public: virtual void cleanupReferences(); - void setGroup(LLviewerOctreeGroup* group); + void setGroup(LLViewerOctreeGroup* group); void setRadius(const F32 radius); F32 getRadius() const { return mRadius; } F32 getVisibilityRadius() const; diff --git a/indra/newview/lldynamictexture.h b/indra/newview/lldynamictexture.h index d287ae6eeb..f3f57c9a6b 100755 --- a/indra/newview/lldynamictexture.h +++ b/indra/newview/lldynamictexture.h @@ -38,12 +38,12 @@ class LLViewerDynamicTexture : public LLViewerTexture public: void* operator new(size_t size) { - return ll_aligned_malloc_16(size); + return LLTrace::MemTrackable::aligned_new<16>(size); } - void operator delete(void* ptr) + void operator delete(void* ptr, size_t size) { - ll_aligned_free_16(ptr); + LLTrace::MemTrackable::aligned_delete<16>(ptr, size); } enum diff --git a/indra/newview/llface.h b/indra/newview/llface.h index 25c87b54f8..40f4968801 100755 --- a/indra/newview/llface.h +++ b/indra/newview/llface.h @@ -53,22 +53,11 @@ class LLDrawInfo; const F32 MIN_ALPHA_SIZE = 1024.f; const F32 MIN_TEX_ANIM_SIZE = 512.f; -class LLFace +class LLFace : public LLTrace::MemTrackableNonVirtual { public: - - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } - - LLFace(const LLFace& rhs) + : LLTrace::MemTrackableNonVirtual("LLFace") { *this = rhs; } @@ -96,7 +85,11 @@ public: static void cacheFaceInVRAM(const LLVolumeFace& vf); public: - LLFace(LLDrawable* drawablep, LLViewerObject* objp) { init(drawablep, objp); } + LLFace(LLDrawable* drawablep, LLViewerObject* objp) + : LLTrace::MemTrackableNonVirtual("LLFace") + { + init(drawablep, objp); + } ~LLFace() { destroy(); } const LLMatrix4& getWorldMatrix() const { return mVObjp->getWorldMatrix(mXform); } diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index c1ebd1f435..db2936b1fd 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -546,7 +546,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) os << '\n'; - typedef TraceType trace_count; + typedef StatType trace_count; for (trace_count::instance_iter it = trace_count::beginInstances(), end_it = trace_count::endInstances(); it != end_it; ++it) @@ -579,7 +579,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - typedef TraceType trace_event; + typedef StatType trace_event; for (trace_event::instance_iter it = trace_event::beginInstances(), end_it = trace_event::endInstances(); it != end_it; @@ -620,7 +620,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - typedef TraceType trace_sample; + typedef StatType trace_sample; for (trace_sample::instance_iter it = trace_sample::beginInstances(), end_it = trace_sample::endInstances(); it != end_it; @@ -661,7 +661,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name) } } - typedef TraceType trace_mem; + typedef StatType trace_mem; for (trace_mem::instance_iter it = trace_mem::beginInstances(), end_it = trace_mem::endInstances(); it != end_it; ++it) diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 0fbe1578cf..045fcccad7 100755 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -483,7 +483,7 @@ void LLSpatialPartition::rebuildMesh(LLSpatialGroup* group) LLSpatialGroup* LLSpatialGroup::getParent() { - return (LLSpatialGroup*)LLviewerOctreeGroup::getParent(); + return (LLSpatialGroup*)LLViewerOctreeGroup::getParent(); } BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree) @@ -831,7 +831,7 @@ void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* entry) { removeObject((LLDrawable*)entry->getDrawable(), TRUE); - LLviewerOctreeGroup::handleRemoval(node, entry); + LLViewerOctreeGroup::handleRemoval(node, entry); } void LLSpatialGroup::handleDestruction(const TreeNode* node) @@ -1065,7 +1065,7 @@ class LLOctreeCull : public LLViewerOctreeCull public: LLOctreeCull(LLCamera* camera) : LLViewerOctreeCull(camera) {} - virtual bool earlyFail(LLviewerOctreeGroup* base_group) + virtual bool earlyFail(LLViewerOctreeGroup* base_group) { LLSpatialGroup* group = (LLSpatialGroup*)base_group; group->checkOcclusion(); @@ -1081,7 +1081,7 @@ public: return false; } - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { S32 res = AABBInFrustumNoFarClipGroupBounds(group); if (res != 0) @@ -1091,7 +1091,7 @@ public: return res; } - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { S32 res = AABBInFrustumNoFarClipObjectBounds(group); if (res != 0) @@ -1101,7 +1101,7 @@ public: return res; } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { LLSpatialGroup* group = (LLSpatialGroup*)base_group; if (group->needsUpdate() || @@ -1119,12 +1119,12 @@ public: LLOctreeCullNoFarClip(LLCamera* camera) : LLOctreeCull(camera) { } - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { return AABBInFrustumNoFarClipGroupBounds(group); } - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { S32 res = AABBInFrustumNoFarClipObjectBounds(group); return res; @@ -1137,12 +1137,12 @@ public: LLOctreeCullShadow(LLCamera* camera) : LLOctreeCull(camera) { } - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { return AABBInFrustumGroupBounds(group); } - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { return AABBInFrustumObjectBounds(group); } @@ -1154,7 +1154,7 @@ public: LLOctreeCullVisExtents(LLCamera* camera, LLVector4a& min, LLVector4a& max) : LLOctreeCullShadow(camera), mMin(min), mMax(max), mEmpty(TRUE) { } - virtual bool earlyFail(LLviewerOctreeGroup* base_group) + virtual bool earlyFail(LLViewerOctreeGroup* base_group) { LLSpatialGroup* group = (LLSpatialGroup*)base_group; @@ -1195,7 +1195,7 @@ public: } } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { LLSpatialGroup* group = (LLSpatialGroup*)base_group; @@ -1231,7 +1231,7 @@ public: LLOctreeCullDetectVisible(LLCamera* camera) : LLOctreeCullShadow(camera), mResult(FALSE) { } - virtual bool earlyFail(LLviewerOctreeGroup* base_group) + virtual bool earlyFail(LLViewerOctreeGroup* base_group) { LLSpatialGroup* group = (LLSpatialGroup*)base_group; @@ -1246,7 +1246,7 @@ public: return false; } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { if (base_group->isVisible()) { @@ -1263,10 +1263,10 @@ public: LLOctreeSelect(LLCamera* camera, std::vector* results) : LLOctreeCull(camera), mResults(results) { } - virtual bool earlyFail(LLviewerOctreeGroup* group) { return false; } - virtual void preprocess(LLviewerOctreeGroup* group) { } + virtual bool earlyFail(LLViewerOctreeGroup* group) { return false; } + virtual void preprocess(LLViewerOctreeGroup* group) { } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { LLSpatialGroup* group = (LLSpatialGroup*)base_group; OctreeNode* branch = group->getOctreeNode(); @@ -3909,7 +3909,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, LLViewerTexture* texture, LLVertexBuffer* buffer, BOOL fullbright, U8 bump, BOOL particle, F32 part_size) -: +: LLTrace::MemTrackableNonVirtual("LLDrawInfo"), mVertexBuffer(buffer), mTexture(texture), mTextureMatrix(NULL), diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 4026175a9a..fef6fdc2c2 100755 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -55,24 +55,14 @@ class LLViewerRegion; void pushVerts(LLFace* face, U32 mask); -class LLDrawInfo : public LLRefCount +class LLDrawInfo : public LLRefCount, public LLTrace::MemTrackableNonVirtual { protected: ~LLDrawInfo(); public: - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } - - LLDrawInfo(const LLDrawInfo& rhs) + : LLTrace::MemTrackableNonVirtual("LLDrawInfo") { *this = rhs; } @@ -209,16 +199,6 @@ public: *this = rhs; } - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } - const LLSpatialGroup& operator=(const LLSpatialGroup& rhs) { LL_ERRS() << "Illegal operation!" << LL_ENDL; @@ -262,7 +242,7 @@ public: typedef enum { - GEOM_DIRTY = LLviewerOctreeGroup::INVALID_STATE, + GEOM_DIRTY = LLViewerOctreeGroup::INVALID_STATE, ALPHA_DIRTY = (GEOM_DIRTY << 1), IN_IMAGE_QUEUE = (ALPHA_DIRTY << 1), IMAGE_DIRTY = (IN_IMAGE_QUEUE << 1), diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index e8eba43242..5bd0a95387 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -231,9 +231,10 @@ S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LL //class LLViewerOctreeEntry definitions //----------------------------------------------------------------------------------- LLViewerOctreeEntry::LLViewerOctreeEntry() - : mGroup(NULL), - mBinRadius(0.f), - mBinIndex(-1) +: LLTrace::MemTrackable("LLViewerOctreeEntry"), + mGroup(NULL), + mBinRadius(0.f), + mBinIndex(-1) { mPositionGroup.clear(); mExtents[0].clear(); @@ -271,7 +272,7 @@ void LLViewerOctreeEntry::removeData(LLViewerOctreeEntryData* data) if(mGroup != NULL && !mData[LLDRAWABLE]) { - LLviewerOctreeGroup* group = mGroup; + LLViewerOctreeGroup* group = mGroup; mGroup = NULL; group->removeFromGroup(data); @@ -285,7 +286,7 @@ void LLViewerOctreeEntry::nullGroup() mGroup = NULL; } -void LLViewerOctreeEntry::setGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeEntry::setGroup(LLViewerOctreeGroup* group) { if(mGroup == group) { @@ -294,7 +295,7 @@ void LLViewerOctreeEntry::setGroup(LLviewerOctreeGroup* group) if(mGroup) { - LLviewerOctreeGroup* group = mGroup; + LLViewerOctreeGroup* group = mGroup; mGroup = NULL; group->removeFromGroup(this); @@ -363,7 +364,7 @@ const LLVector4a* LLViewerOctreeEntryData::getSpatialExtents() const } //virtual -void LLViewerOctreeEntryData::setGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeEntryData::setGroup(LLViewerOctreeGroup* group) { mEntry->setGroup(group); } @@ -375,7 +376,7 @@ void LLViewerOctreeEntryData::shift(const LLVector4a &shift_vector) mEntry->mPositionGroup.add(shift_vector); } -LLviewerOctreeGroup* LLViewerOctreeEntryData::getGroup()const +LLViewerOctreeGroup* LLViewerOctreeEntryData::getGroup()const { return mEntry.notNull() ? mEntry->mGroup : NULL; } @@ -425,15 +426,16 @@ void LLViewerOctreeEntryData::setVisible() const } //----------------------------------------------------------------------------------- -//class LLviewerOctreeGroup definitions +//class LLViewerOctreeGroup definitions //----------------------------------------------------------------------------------- -LLviewerOctreeGroup::~LLviewerOctreeGroup() +LLViewerOctreeGroup::~LLViewerOctreeGroup() { //empty here } -LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : +LLViewerOctreeGroup::LLViewerOctreeGroup(OctreeNode* node) +: LLTrace::MemTrackable("LLViewerOctreeGroup"), mOctreeNode(node), mState(CLEAN) { @@ -448,7 +450,7 @@ LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) : mOctreeNode->addListener(this); } -bool LLviewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) +bool LLViewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) { if(!data->getEntry()) { @@ -457,12 +459,12 @@ bool LLviewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) return std::find(getDataBegin(), getDataEnd(), data->getEntry()) != getDataEnd(); } -bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data) +bool LLViewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data) { return removeFromGroup(data->getEntry()); } -bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) +bool LLViewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) { llassert(entry != NULL); llassert(!entry->getGroup()); @@ -483,7 +485,7 @@ bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry) } //virtual -void LLviewerOctreeGroup::unbound() +void LLViewerOctreeGroup::unbound() { if (isDirty()) { @@ -498,7 +500,7 @@ void LLviewerOctreeGroup::unbound() OctreeNode* parent = (OctreeNode*) mOctreeNode->getParent(); while (parent != NULL) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) parent->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) parent->getListener(0); if (!group || group->isDirty()) { return; @@ -511,7 +513,7 @@ void LLviewerOctreeGroup::unbound() } //virtual -void LLviewerOctreeGroup::rebound() +void LLViewerOctreeGroup::rebound() { if (!isDirty()) { @@ -520,7 +522,7 @@ void LLviewerOctreeGroup::rebound() if (mOctreeNode->getChildCount() == 1 && mOctreeNode->getElementCount() == 0) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); group->rebound(); //copy single child's bounding box @@ -541,7 +543,7 @@ void LLviewerOctreeGroup::rebound() { LLVector4a& newMin = mExtents[0]; LLVector4a& newMax = mExtents[1]; - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0); group->clearState(SKIP_FRUSTUM_CHECK); group->rebound(); //initialize to first child @@ -551,7 +553,7 @@ void LLviewerOctreeGroup::rebound() //first, rebound children for (U32 i = 1; i < mOctreeNode->getChildCount(); i++) { - group = (LLviewerOctreeGroup*) mOctreeNode->getChild(i)->getListener(0); + group = (LLViewerOctreeGroup*) mOctreeNode->getChild(i)->getListener(0); group->clearState(SKIP_FRUSTUM_CHECK); group->rebound(); const LLVector4a& max = group->mExtents[1]; @@ -575,7 +577,7 @@ void LLviewerOctreeGroup::rebound() } //virtual -void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj) +void LLViewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj) { obj->setGroup(this); unbound(); @@ -583,7 +585,7 @@ void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEn } //virtual -void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) +void LLViewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) { unbound(); setState(OBJECT_DIRTY); @@ -592,7 +594,7 @@ void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntr } //virtual -void LLviewerOctreeGroup::handleDestruction(const TreeNode* node) +void LLViewerOctreeGroup::handleDestruction(const TreeNode* node) { for (OctreeNode::element_iter i = mOctreeNode->getDataBegin(); i != mOctreeNode->getDataEnd(); ++i) { @@ -607,7 +609,7 @@ void LLviewerOctreeGroup::handleDestruction(const TreeNode* node) } //virtual -void LLviewerOctreeGroup::handleStateChange(const TreeNode* node) +void LLViewerOctreeGroup::handleStateChange(const TreeNode* node) { //drop bounding box upon state change if (mOctreeNode != node) @@ -618,29 +620,29 @@ void LLviewerOctreeGroup::handleStateChange(const TreeNode* node) } //virtual -void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) +void LLViewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { if (child->getListenerCount() == 0) { - new LLviewerOctreeGroup(child); + new LLViewerOctreeGroup(child); } else { - OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << LL_ENDL; + OCT_ERRS << "LLViewerOctreeGroup redundancy detected." << LL_ENDL; } unbound(); - ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); + ((LLViewerOctreeGroup*)child->getListener(0))->unbound(); } //virtual -void LLviewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) +void LLViewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) { unbound(); } -LLviewerOctreeGroup* LLviewerOctreeGroup::getParent() +LLViewerOctreeGroup* LLViewerOctreeGroup::getParent() { if (isDead()) { @@ -656,14 +658,14 @@ LLviewerOctreeGroup* LLviewerOctreeGroup::getParent() if (parent) { - return (LLviewerOctreeGroup*) parent->getListener(0); + return (LLViewerOctreeGroup*) parent->getListener(0); } return NULL; } //virtual -bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut) +bool LLViewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut) { const OctreeNode* node = mOctreeNode; @@ -721,23 +723,23 @@ bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4 } //virtual -BOOL LLviewerOctreeGroup::isVisible() const +BOOL LLViewerOctreeGroup::isVisible() const { return mVisible[LLViewerCamera::sCurCameraID] >= LLViewerOctreeEntryData::getCurrentFrame() ? TRUE : FALSE; } //virtual -BOOL LLviewerOctreeGroup::isRecentlyVisible() const +BOOL LLViewerOctreeGroup::isRecentlyVisible() const { return FALSE; } -void LLviewerOctreeGroup::setVisible() +void LLViewerOctreeGroup::setVisible() { mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame(); } -void LLviewerOctreeGroup::checkStates() +void LLViewerOctreeGroup::checkStates() { #if LL_OCTREE_PARANOIA_CHECK //LLOctreeStateCheck checker; @@ -837,7 +839,7 @@ public: LLOcclusionCullingGroup::LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part) : - LLviewerOctreeGroup(node), + LLViewerOctreeGroup(node), mSpatialPartition(part) { part->mLODSeed = (part->mLODSeed+1)%part->mLODPeriod; @@ -885,7 +887,7 @@ void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, Octr unbound(); - ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); + ((LLViewerOctreeGroup*)child->getListener(0))->unbound(); } void LLOcclusionCullingGroup::releaseOcclusionQueryObjectNames() @@ -1316,7 +1318,7 @@ BOOL LLViewerOctreePartition::isOcclusionEnabled() //----------------------------------------------------------------------------------- //virtual -bool LLViewerOctreeCull::earlyFail(LLviewerOctreeGroup* group) +bool LLViewerOctreeCull::earlyFail(LLViewerOctreeGroup* group) { return false; } @@ -1324,7 +1326,7 @@ bool LLViewerOctreeCull::earlyFail(LLviewerOctreeGroup* group) //virtual void LLViewerOctreeCull::traverse(const OctreeNode* n) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) n->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) n->getListener(0); if (earlyFail(group)) { @@ -1332,7 +1334,7 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n) } if (mRes == 2 || - (mRes && group->hasState(LLviewerOctreeGroup::SKIP_FRUSTUM_CHECK))) + (mRes && group->hasState(LLViewerOctreeGroup::SKIP_FRUSTUM_CHECK))) { //fully in, just add everything OctreeTraveler::traverse(n); } @@ -1351,17 +1353,17 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n) //------------------------------------------ //agent space group culling -S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); } -S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLViewerOctreeGroup* group) { return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } -S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]); } @@ -1369,17 +1371,17 @@ S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* grou //------------------------------------------ //agent space object set culling -S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); } -S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLViewerOctreeGroup* group) { return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist); } -S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); } @@ -1387,17 +1389,17 @@ S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* gro //------------------------------------------ //local regional space group culling -S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustumNoFarClip(group->mBounds[0], group->mBounds[1]); } -S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustum(group->mBounds[0], group->mBounds[1]); } -S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLViewerOctreeGroup* group, const LLVector3& shift) { return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); } @@ -1405,24 +1407,24 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctr //------------------------------------------ //local regional space object culling -S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustum(group->mObjectBounds[0], group->mObjectBounds[1]); } -S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group) +S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLViewerOctreeGroup* group) { return mCamera->AABBInRegionFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]); } -S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift) +S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOctreeGroup* group, const LLVector3& shift) { return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist); } //------------------------------------------ //virtual -bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group) +bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group) { if (branch->getElementCount() == 0) //no elements { @@ -1441,19 +1443,19 @@ bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOc } //virtual -void LLViewerOctreeCull::preprocess(LLviewerOctreeGroup* group) +void LLViewerOctreeCull::preprocess(LLViewerOctreeGroup* group) { } //virtual -void LLViewerOctreeCull::processGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeCull::processGroup(LLViewerOctreeGroup* group) { } //virtual void LLViewerOctreeCull::visit(const OctreeNode* branch) { - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) branch->getListener(0); preprocess(group); @@ -1475,12 +1477,12 @@ void LLViewerOctreeDebug::visit(const OctreeNode* branch) LL_INFOS() << "Child " << i << " : " << (U32)branch->getChild(i) << LL_ENDL; } #endif - LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0); + LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) branch->getListener(0); processGroup(group); } //virtual -void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group) +void LLViewerOctreeDebug::processGroup(LLViewerOctreeGroup* group) { #if 0 const LLVector4a* vec4 = group->getBounds(); diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h index 174af5e22f..1eaa1b931e 100644 --- a/indra/newview/llvieweroctree.h +++ b/indra/newview/llvieweroctree.h @@ -41,7 +41,7 @@ class LLViewerRegion; class LLViewerOctreeEntryData; -class LLviewerOctreeGroup; +class LLViewerOctreeGroup; class LLViewerOctreeEntry; class LLViewerOctreePartition; @@ -53,7 +53,7 @@ typedef LLOctreeTraveler OctreeTraveler; #if LL_OCTREE_PARANOIA_CHECK #define assert_octree_valid(x) x->validate() -#define assert_states_valid(x) ((LLviewerOctreeGroup*) x->mSpatialPartition->mOctree->getListener(0))->checkStates() +#define assert_states_valid(x) ((LLViewerOctreeGroup*) x->mSpatialPartition->mOctree->getListener(0))->checkStates() #else #define assert_octree_valid(x) #define assert_states_valid(x) @@ -71,7 +71,7 @@ S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVe //defines data needed for octree of an entry //LL_ALIGN_PREFIX(16) -class LLViewerOctreeEntry : public LLRefCount +class LLViewerOctreeEntry : public LLRefCount, public LLTrace::MemTrackable { friend class LLViewerOctreeEntryData; @@ -90,7 +90,7 @@ public: LLViewerOctreeEntry(); void nullGroup(); //called by group handleDestruction() only - void setGroup(LLviewerOctreeGroup* group); + void setGroup(LLViewerOctreeGroup* group); void removeData(LLViewerOctreeEntryData* data); LLViewerOctreeEntryData* getDrawable() const {return mData[LLDRAWABLE];} @@ -100,28 +100,18 @@ public: const LLVector4a* getSpatialExtents() const {return mExtents;} const LLVector4a& getPositionGroup() const {return mPositionGroup;} - LLviewerOctreeGroup* getGroup()const {return mGroup;} + LLViewerOctreeGroup* getGroup()const {return mGroup;} F32 getBinRadius() const {return mBinRadius;} S32 getBinIndex() const {return mBinIndex; } void setBinIndex(S32 index) const {mBinIndex = index; } - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } - private: void addData(LLViewerOctreeEntryData* data); private: LLViewerOctreeEntryData* mData[NUM_DATA_TYPE]; //do not use LLPointer here. - LLviewerOctreeGroup* mGroup; + LLViewerOctreeGroup* mGroup; //aligned members LL_ALIGN_16(LLVector4a mExtents[2]); @@ -153,7 +143,7 @@ public: F32 getBinRadius() const {return mEntry->getBinRadius();} const LLVector4a* getSpatialExtents() const; - LLviewerOctreeGroup* getGroup()const; + LLViewerOctreeGroup* getGroup()const; const LLVector4a& getPositionGroup() const; void setBinRadius(F32 rad) {mEntry->mBinRadius = rad;} @@ -161,7 +151,7 @@ public: void setSpatialExtents(const LLVector4a& min, const LLVector4a& max); void setPositionGroup(const LLVector4a& pos); - virtual void setGroup(LLviewerOctreeGroup* group); + virtual void setGroup(LLViewerOctreeGroup* group); void shift(const LLVector4a &shift_vector); U32 getVisible() const {return mEntry ? mEntry->mVisible : 0;} @@ -185,11 +175,12 @@ protected: //defines an octree group for an octree node, which contains multiple entries. //LL_ALIGN_PREFIX(16) -class LLviewerOctreeGroup : public LLOctreeListener +class LLViewerOctreeGroup +: public LLOctreeListener, public LLTrace::MemTrackable { friend class LLViewerOctreeCull; protected: - virtual ~LLviewerOctreeGroup(); + virtual ~LLViewerOctreeGroup(); public: enum @@ -206,22 +197,13 @@ public: typedef LLOctreeNode::element_iter element_iter; typedef LLOctreeNode::element_list element_list; - LLviewerOctreeGroup(OctreeNode* node); - LLviewerOctreeGroup(const LLviewerOctreeGroup& rhs) + LLViewerOctreeGroup(OctreeNode* node); + LLViewerOctreeGroup(const LLViewerOctreeGroup& rhs) + : LLTrace::MemTrackable("LLViewerOctreeGroup") { *this = rhs; } - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } - bool removeFromGroup(LLViewerOctreeEntryData* data); bool removeFromGroup(LLViewerOctreeEntry* entry); @@ -250,7 +232,7 @@ public: virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child); OctreeNode* getOctreeNode() {return mOctreeNode;} - LLviewerOctreeGroup* getParent(); + LLViewerOctreeGroup* getParent(); const LLVector4a* getBounds() const {return mBounds;} const LLVector4a* getExtents() const {return mExtents;} @@ -285,7 +267,7 @@ public: //octree group which has capability to support occlusion culling //LL_ALIGN_PREFIX(16) -class LLOcclusionCullingGroup : public LLviewerOctreeGroup +class LLOcclusionCullingGroup : public LLViewerOctreeGroup { public: typedef enum @@ -310,7 +292,7 @@ protected: public: LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part); - LLOcclusionCullingGroup(const LLOcclusionCullingGroup& rhs) : LLviewerOctreeGroup(rhs) + LLOcclusionCullingGroup(const LLOcclusionCullingGroup& rhs) : LLViewerOctreeGroup(rhs) { *this = rhs; } @@ -379,35 +361,35 @@ public: LLViewerOctreeCull(LLCamera* camera) : mCamera(camera), mRes(0) { } - virtual bool earlyFail(LLviewerOctreeGroup* group); + virtual bool earlyFail(LLViewerOctreeGroup* group); virtual void traverse(const OctreeNode* n); //agent space group cull - S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group); - S32 AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group); - S32 AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group); + S32 AABBInFrustumNoFarClipGroupBounds(const LLViewerOctreeGroup* group); + S32 AABBSphereIntersectGroupExtents(const LLViewerOctreeGroup* group); + S32 AABBInFrustumGroupBounds(const LLViewerOctreeGroup* group); //agent space object set cull - S32 AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group); - S32 AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group); - S32 AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group); + S32 AABBInFrustumNoFarClipObjectBounds(const LLViewerOctreeGroup* group); + S32 AABBSphereIntersectObjectExtents(const LLViewerOctreeGroup* group); + S32 AABBInFrustumObjectBounds(const LLViewerOctreeGroup* group); //local region space group cull - S32 AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group); - S32 AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group); - S32 AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift); + S32 AABBInRegionFrustumNoFarClipGroupBounds(const LLViewerOctreeGroup* group); + S32 AABBInRegionFrustumGroupBounds(const LLViewerOctreeGroup* group); + S32 AABBRegionSphereIntersectGroupExtents(const LLViewerOctreeGroup* group, const LLVector3& shift); //local region space object set cull - S32 AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group); - S32 AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group); - S32 AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift); + S32 AABBInRegionFrustumNoFarClipObjectBounds(const LLViewerOctreeGroup* group); + S32 AABBInRegionFrustumObjectBounds(const LLViewerOctreeGroup* group); + S32 AABBRegionSphereIntersectObjectExtents(const LLViewerOctreeGroup* group, const LLVector3& shift); - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) = 0; - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) = 0; + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) = 0; + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) = 0; - virtual bool checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group); - virtual void preprocess(LLviewerOctreeGroup* group); - virtual void processGroup(LLviewerOctreeGroup* group); + virtual bool checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group); + virtual void preprocess(LLViewerOctreeGroup* group); + virtual void processGroup(LLViewerOctreeGroup* group); virtual void visit(const OctreeNode* branch); protected: @@ -419,7 +401,7 @@ protected: class LLViewerOctreeDebug : public OctreeTraveler { public: - virtual void processGroup(LLviewerOctreeGroup* group); + virtual void processGroup(LLViewerOctreeGroup* group); virtual void visit(const OctreeNode* branch); public: diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 6e9f649d23..4b4de583d8 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -148,7 +148,7 @@ public: LLVOCacheEntry::vocache_entry_map_t mCacheMap; //all cached entries LLVOCacheEntry::vocache_entry_set_t mActiveSet; //all active entries; LLVOCacheEntry::vocache_entry_set_t mWaitingSet; //entries waiting for LLDrawable to be generated. - std::set< LLPointer > mVisibleGroups; //visible groupa + std::set< LLPointer > mVisibleGroups; //visible groupa LLVOCachePartition* mVOCachePartition; LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //must-be-created visible entries wait for objects creation. LLVOCacheEntry::vocache_entry_priority_list_t mWaitingList; //transient list storing sorted visible entries waiting for object creation. @@ -963,7 +963,7 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d entry->setState(LLVOCacheEntry::INACTIVE); } -bool LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group) +bool LLViewerRegion::addVisibleGroup(LLViewerOctreeGroup* group) { if(mDead || group->isEmpty()) { @@ -1110,17 +1110,17 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time) } //process visible groups - std::set< LLPointer >::iterator group_iter = mImpl->mVisibleGroups.begin(); + std::set< LLPointer >::iterator group_iter = mImpl->mVisibleGroups.begin(); for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter) { - LLPointer group = *group_iter; + LLPointer group = *group_iter; if(group->getNumRefs() < 3 || //group to be deleted !group->getOctreeNode() || group->isEmpty()) //group empty { continue; } - for (LLviewerOctreeGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i) + for (LLViewerOctreeGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i) { if((*i)->hasVOCacheEntry()) { diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 79a992a4c1..4e2252b75b 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -68,7 +68,7 @@ class LLBBox; class LLSpatialGroup; class LLDrawable; class LLViewerRegionImpl; -class LLviewerOctreeGroup; +class LLViewerOctreeGroup; class LLVOCachePartition; class LLViewerRegion: public LLCapabilityProvider // implements this interface @@ -230,7 +230,7 @@ public: F32 getWidth() const { return mWidth; } BOOL idleUpdate(F32 max_update_time); - bool addVisibleGroup(LLviewerOctreeGroup* group); + bool addVisibleGroup(LLViewerOctreeGroup* group); void addVisibleCacheEntry(LLVOCacheEntry* entry); void addActiveCacheEntry(LLVOCacheEntry* entry); void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index f300983f19..c81a9a0ad3 100755 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -343,17 +343,17 @@ void update_statistics() sample(LLStatViewer::DRAW_DISTANCE, (F64)gSavedSettings.getF32("RenderFarClip")); sample(LLStatViewer::CHAT_BUBBLES, gSavedSettings.getBOOL("UseChatBubbles")); - typedef LLInstanceTracker, std::string> trace_type_t; + typedef LLInstanceTracker, std::string> stat_type_t; - F64Seconds idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle")); - F64Seconds network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network")); + F64Seconds idle_secs = last_frame_recording.getSum(*stat_type_t::getInstance("Idle")); + F64Seconds network_secs = last_frame_recording.getSum(*stat_type_t::getInstance("Network")); - record(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Frame"))); + record(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Frame"))); record(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs); record(LLStatViewer::NETWORK_STACKTIME, network_secs); - record(LLStatViewer::IMAGE_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Update Images"))); - record(LLStatViewer::REBUILD_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Sort Draw State"))); - record(LLStatViewer::RENDER_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Render Geometry"))); + record(LLStatViewer::IMAGE_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Update Images"))); + record(LLStatViewer::REBUILD_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Sort Draw State"))); + record(LLStatViewer::RENDER_STACKTIME, last_frame_recording.getSum(*stat_type_t::getInstance("Render Geometry"))); LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost()); if (cdp) diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index b600d2a8f1..6800fe3785 100755 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -97,12 +97,12 @@ public: public: void* operator new(size_t size) { - return ll_aligned_malloc_16(size); + return LLTrace::MemTrackable::aligned_new<16>(size); } - void operator delete(void* ptr) + void operator delete(void* ptr, size_t size) { - ll_aligned_free_16(ptr); + LLTrace::MemTrackable::aligned_delete<16>(ptr, size); } LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index 9e9e2b61d7..c280988fd6 100755 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -50,16 +50,6 @@ class LLVOAvatarSelf : **/ public: - void* operator new(size_t size) - { - return ll_aligned_malloc_16(size); - } - - void operator delete(void* ptr) - { - ll_aligned_free_16(ptr); - } - LLVOAvatarSelf(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); virtual ~LLVOAvatarSelf(); virtual void markDead(); diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index ada412be8c..3f01ffa3cd 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -495,7 +495,7 @@ void LLVOCacheGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c unbound(); - ((LLviewerOctreeGroup*)child->getListener(0))->unbound(); + ((LLViewerOctreeGroup*)child->getListener(0))->unbound(); } LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) @@ -542,7 +542,7 @@ public: mUseObjectCacheOcclusion = use_object_cache_occlusion; } - virtual bool earlyFail(LLviewerOctreeGroup* base_group) + virtual bool earlyFail(LLViewerOctreeGroup* base_group) { if( mUseObjectCacheOcclusion && base_group->getOctreeNode()->getParent()) //never occlusion cull the root node @@ -565,7 +565,7 @@ public: return false; } - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { #if 1 S32 res = AABBInRegionFrustumGroupBounds(group); @@ -579,7 +579,7 @@ public: return res; } - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { #if 1 S32 res = AABBInRegionFrustumObjectBounds(group); @@ -593,7 +593,7 @@ public: return res; } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { if( !mUseObjectCacheOcclusion || !base_group->getOctreeNode()->getParent()) @@ -647,19 +647,19 @@ public: mSphereRadius = back_sphere_radius; } - virtual S32 frustumCheck(const LLviewerOctreeGroup* group) + virtual S32 frustumCheck(const LLViewerOctreeGroup* group) { const LLVector4a* exts = group->getExtents(); return backSphereCheck(exts[0], exts[1]); } - virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) + virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) { const LLVector4a* exts = group->getObjectExtents(); return backSphereCheck(exts[0], exts[1]); } - virtual void processGroup(LLviewerOctreeGroup* base_group) + virtual void processGroup(LLViewerOctreeGroup* base_group) { mRegionp->addVisibleGroup(base_group); return; @@ -721,7 +721,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 0; } - ((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound(); + ((LLViewerOctreeGroup*)mOctree->getListener(0))->rebound(); if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0) { @@ -779,7 +779,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) return 1; } -void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp) +void LLVOCachePartition::addOccluders(LLViewerOctreeGroup* gp) { LLVOCacheGroup* group = (LLVOCacheGroup*)gp; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index b58bb3d499..eef364dd5d 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -180,7 +180,7 @@ public: void addEntry(LLViewerOctreeEntry* entry); void removeEntry(LLViewerOctreeEntry* entry); /*virtual*/ S32 cull(LLCamera &camera, bool do_occlusion); - void addOccluders(LLviewerOctreeGroup* gp); + void addOccluders(LLViewerOctreeGroup* gp); void resetOccluders(); void processOccluders(LLCamera* camera); void removeOccluder(LLVOCacheGroup* group); diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml index b2399123be..6c776907f5 100755 --- a/indra/newview/skins/default/xui/en/floater_stats.xml +++ b/indra/newview/skins/default/xui/en/floater_stats.xml @@ -125,12 +125,27 @@ - + + + + + -- cgit v1.3 From 1dfba44b3dc14564c99333dedb7a380a160aee44 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 21 Oct 2013 14:22:21 -0700 Subject: fixed things so that trace recordings can be read from even while active --- indra/llcommon/lltraceaccumulators.cpp | 102 ++++++----- indra/llcommon/lltraceaccumulators.h | 8 +- indra/llcommon/lltracerecording.cpp | 279 +++++++++++++++++++++++++------ indra/llcommon/lltracerecording.h | 2 +- indra/llcommon/lltracethreadrecorder.cpp | 3 +- indra/llcommon/lltracethreadrecorder.h | 2 +- indra/llcommon/tests/lltrace_test.cpp | 5 +- 7 files changed, 299 insertions(+), 102 deletions(-) (limited to 'indra/llcommon/lltraceaccumulators.cpp') diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 7d0e63e76a..385d31edd7 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -155,6 +155,39 @@ void AccumulatorBufferGroup::sync() } } +F64 SampleAccumulator::mergeSumsOfSquares(const SampleAccumulator& a, const SampleAccumulator& b) +{ + const F64 epsilon = 0.0000001; + + if (a.getSamplingTime() > epsilon && b.getSamplingTime() > epsilon) + { + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = a.getSamplingTime(), + n_2 = b.getSamplingTime(); + F64 m_1 = a.getMean(), + m_2 = b.getMean(); + F64 v_1 = a.getSumOfSquares() / a.getSamplingTime(), + v_2 = b.getSumOfSquares() / b.getSamplingTime(); + if (n_1 < epsilon) + { + return b.getSumOfSquares(); + } + else + { + return a.getSamplingTime() + * ((((n_1 - epsilon) * v_1) + + ((n_2 - epsilon) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - epsilon)); + } + } + + return a.getSumOfSquares(); +} + + void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) { if (append_type == NON_SEQUENTIAL) @@ -180,37 +213,8 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen if (other.mMin < mMin) { mMin = other.mMin; } if (other.mMax > mMax) { mMax = other.mMax; } - F64 epsilon = 0.0000001; + mSumOfSquares = mergeSumsOfSquares(*this, other); - if (other.mTotalSamplingTime > epsilon && mTotalSamplingTime > epsilon) - { - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - F64 n_1 = mTotalSamplingTime, - n_2 = other.mTotalSamplingTime; - F64 m_1 = mMean, - m_2 = other.mMean; - F64 v_1 = mSumOfSquares / mTotalSamplingTime, - v_2 = other.mSumOfSquares / other.mTotalSamplingTime; - if (n_1 < epsilon) - { - mSumOfSquares = other.mSumOfSquares; - } - else - { - mSumOfSquares = mTotalSamplingTime - * ((((n_1 - epsilon) * v_1) - + ((n_2 - epsilon) * v_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - epsilon)); - } - - F64 weight = mTotalSamplingTime / (mTotalSamplingTime + other.mTotalSamplingTime); - mNumSamples += other.mNumSamples; - mTotalSamplingTime += other.mTotalSamplingTime; - mMean = (mMean * weight) + (other.mMean * (1.0 - weight)); - } if (append_type == SEQUENTIAL) { mLastValue = other.mLastValue; @@ -234,6 +238,29 @@ void SampleAccumulator::reset( const SampleAccumulator* other ) mTotalSamplingTime = 0; } +F64 EventAccumulator::mergeSumsOfSquares(const EventAccumulator& a, const EventAccumulator& b) +{ + if (a.mNumSamples && b.mNumSamples) + { + // combine variance (and hence standard deviation) of 2 different sized sample groups using + // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm + F64 n_1 = a.mNumSamples, + n_2 = b.mNumSamples; + F64 m_1 = a.mMean, + m_2 = b.mMean; + F64 v_1 = a.mSumOfSquares / a.mNumSamples, + v_2 = b.mSumOfSquares / b.mNumSamples; + return (F64)a.mNumSamples + * ((((n_1 - 1.f) * v_1) + + ((n_2 - 1.f) * v_2) + + (((n_1 * n_2) / (n_1 + n_2)) + * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) + / (n_1 + n_2 - 1.f)); + } + + return a.mSumOfSquares; +} + void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendType append_type ) { if (other.mNumSamples) @@ -250,20 +277,7 @@ void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendT if (other.mMin < mMin) { mMin = other.mMin; } if (other.mMax > mMax) { mMax = other.mMax; } - // combine variance (and hence standard deviation) of 2 different sized sample groups using - // the following formula: http://www.mrc-bsu.cam.ac.uk/cochrane/handbook/chapter_7/7_7_3_8_combining_groups.htm - F64 n_1 = (F64)mNumSamples, - n_2 = (F64)other.mNumSamples; - F64 m_1 = mMean, - m_2 = other.mMean; - F64 v_1 = mSumOfSquares / mNumSamples, - v_2 = other.mSumOfSquares / other.mNumSamples; - mSumOfSquares = (F64)mNumSamples - * ((((n_1 - 1.f) * v_1) - + ((n_2 - 1.f) * v_2) - + (((n_1 * n_2) / (n_1 + n_2)) - * ((m_1 * m_1) + (m_2 * m_2) - (2.f * m_1 * m_2)))) - / (n_1 + n_2 - 1.f)); + mSumOfSquares = mergeSumsOfSquares(*this, other); F64 weight = (F64)mNumSamples / (F64)(mNumSamples + other.mNumSamples); mNumSamples += other.mNumSamples; diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 2971907849..dfa037d7c0 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -276,6 +276,9 @@ namespace LLTrace S32 getSampleCount() const { return mNumSamples; } bool hasValue() const { return mNumSamples > 0; } + // helper utility to calculate combined sumofsquares total + static F64 mergeSumsOfSquares(const EventAccumulator& a, const EventAccumulator& b); + private: F64 mSum, mLastValue; @@ -359,10 +362,13 @@ namespace LLTrace F64 getMean() const { return mMean; } F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mTotalSamplingTime); } F64 getSumOfSquares() const { return mSumOfSquares; } - F64SecondsImplicit getSamplingTime() { return mTotalSamplingTime; } + F64SecondsImplicit getSamplingTime() const { return mTotalSamplingTime; } S32 getSampleCount() const { return mNumSamples; } bool hasValue() const { return mHasValue; } + // helper utility to calculate combined sumofsquares total + static F64 mergeSumsOfSquares(const SampleAccumulator& a, const SampleAccumulator& b); + private: F64 mSum, mLastValue; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 5ec7ce56b9..0fd0053240 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -32,6 +32,11 @@ #include "lltracethreadrecorder.h" #include "llthread.h" +inline F64 lerp(F64 a, F64 b, F64 u) +{ + return a + ((b - a) * u); +} + namespace LLTrace { @@ -43,7 +48,7 @@ extern MemStatHandle gTraceMemStat; Recording::Recording(EPlayState state) : mElapsedSeconds(0), - mInHandOff(false) + mActiveBuffers(NULL) { claim_alloc(gTraceMemStat, this); mBuffers = new AccumulatorBufferGroup(); @@ -88,13 +93,20 @@ Recording::~Recording() } } +// brings recording to front of recorder stack, with up to date info void Recording::update() { if (isStarted()) { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); - AccumulatorBufferGroup* buffers = mBuffers.write(); - LLTrace::get_thread_recorder()->bringUpToDate(buffers); + + llassert(mActiveBuffers); + if(!mActiveBuffers->isCurrent()) + { + AccumulatorBufferGroup* buffers = mBuffers.write(); + LLTrace::get_thread_recorder()->deactivate(buffers); + mActiveBuffers = LLTrace::get_thread_recorder()->activate(buffers); + } mSamplingTimer.reset(); } @@ -112,20 +124,19 @@ void Recording::handleStart() { mSamplingTimer.reset(); mBuffers.setStayUnique(true); - LLTrace::get_thread_recorder()->activate(mBuffers.write(), mInHandOff); - mInHandOff = false; + mActiveBuffers = LLTrace::get_thread_recorder()->activate(mBuffers.write()); } void Recording::handleStop() { mElapsedSeconds += mSamplingTimer.getElapsedTimeF64(); LLTrace::get_thread_recorder()->deactivate(mBuffers.write()); + mActiveBuffers = NULL; mBuffers.setStayUnique(false); } void Recording::handleSplitTo(Recording& other) { - other.mInHandOff = true; mBuffers.write()->handOffTo(*other.mBuffers.write()); } @@ -139,214 +150,378 @@ void Recording::appendRecording( Recording& other ) bool Recording::hasValue(const StatType& stat) { - return mBuffers->mStackTimers[stat.getIndex()].hasValue(); + update(); + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator && active_accumulator->hasValue()); } F64Seconds Recording::getSum(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mTotalTimeCounter) - / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return F64Seconds((F64)(accumulator.mTotalTimeCounter) + (F64)(active_accumulator ? active_accumulator->mTotalTimeCounter : 0)) + / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond(); } F64Seconds Recording::getSum(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return F64Seconds((F64)(accumulator.mSelfTimeCounter) + (F64)(active_accumulator ? active_accumulator->mSelfTimeCounter : 0) / (F64)LLTrace::BlockTimerStatHandle::countsPerSecond()); } S32 Recording::getSum(const StatType& stat) { - return mBuffers->mStackTimers[stat.getIndex()].mCalls; + update(); + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return accumulator.mCalls + (active_accumulator ? active_accumulator->mCalls : 0); } F64Seconds Recording::getPerSec(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; - return F64Seconds((F64)(accumulator.mTotalTimeCounter) + return F64Seconds((F64)(accumulator.mTotalTimeCounter + (active_accumulator ? active_accumulator->mTotalTimeCounter : 0)) / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F64Seconds Recording::getPerSec(const StatType& stat) { + update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; - return F64Seconds((F64)(accumulator.mSelfTimeCounter) + return F64Seconds((F64)(accumulator.mSelfTimeCounter + (active_accumulator ? active_accumulator->mSelfTimeCounter : 0)) / ((F64)LLTrace::BlockTimerStatHandle::countsPerSecond() * mElapsedSeconds.value())); } F32 Recording::getPerSec(const StatType& stat) { - return (F32)mBuffers->mStackTimers[stat.getIndex()].mCalls / mElapsedSeconds.value(); + update(); + const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; + const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; + return (F32)(accumulator.mCalls + (active_accumulator ? active_accumulator->mCalls : 0)) / mElapsedSeconds.value(); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mSize.hasValue(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mSize.hasValue() || (active_accumulator && active_accumulator->mSize.hasValue() ? active_accumulator->mSize.hasValue() : false); } F64Kilobytes Recording::getMin(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMin()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(llmin(accumulator.mSize.getMin(), (active_accumulator && active_accumulator->mSize.hasValue() ? active_accumulator->mSize.getMin() : F32_MAX))); } F64Kilobytes Recording::getMean(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMean()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + + if (active_accumulator && active_accumulator->mSize.hasValue()) + { + return F64Bytes(lerp(accumulator.mSize.getMean(), active_accumulator->mSize.getMean(), active_accumulator->mSize.getSampleCount() / (accumulator.mSize.getSampleCount() + active_accumulator->mSize.getSampleCount()))); + } + else + { + return F64Bytes(accumulator.mSize.getMean()); + } } F64Kilobytes Recording::getMax(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getMax()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(llmax(accumulator.mSize.getMax(), active_accumulator && active_accumulator->mSize.hasValue() ? active_accumulator->mSize.getMax() : F32_MIN)); } F64Kilobytes Recording::getStandardDeviation(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getStandardDeviation()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + if (active_accumulator && active_accumulator->hasValue()) + { + F64 sum_of_squares = SampleAccumulator::mergeSumsOfSquares(accumulator.mSize, active_accumulator->mSize); + return F64Bytes(sqrtf(sum_of_squares / (accumulator.mSize.getSamplingTime().value() + active_accumulator->mSize.getSamplingTime().value()))); + } + else + { + return F64Bytes(accumulator.mSize.getStandardDeviation()); + } } F64Kilobytes Recording::getLastValue(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mSize.getLastValue()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(active_accumulator ? active_accumulator->mSize.getLastValue() : accumulator.mSize.getLastValue()); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocations.hasValue(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mAllocations.hasValue() || (active_accumulator ? active_accumulator->mAllocations.hasValue() : false); } F64Kilobytes Recording::getSum(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(accumulator.mAllocations.getSum() + (active_accumulator ? active_accumulator->mAllocations.getSum() : 0)); } F64Kilobytes Recording::getPerSec(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mAllocations.getSum() / mElapsedSeconds.value()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes((accumulator.mAllocations.getSum() + (active_accumulator ? active_accumulator->mAllocations.getSum() : 0)) / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mAllocations.getSampleCount(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mAllocations.getSampleCount() + (active_accumulator ? active_accumulator->mAllocations.getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mDeallocations.hasValue(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mDeallocations.hasValue() || (active_accumulator ? active_accumulator->mDeallocations.hasValue() : false); } F64Kilobytes Recording::getSum(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes(accumulator.mDeallocations.getSum() + (active_accumulator ? active_accumulator->mDeallocations.getSum() : 0)); } F64Kilobytes Recording::getPerSec(const StatType& stat) { - return F64Bytes(mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSum() / mElapsedSeconds.value()); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return F64Bytes((accumulator.mDeallocations.getSum() + (active_accumulator ? active_accumulator->mDeallocations.getSum() : 0)) / mElapsedSeconds.value()); } S32 Recording::getSampleCount(const StatType& stat) { - return mBuffers->mMemStats[stat.getIndex()].mDeallocations.getSampleCount(); + update(); + const MemAccumulator& accumulator = mBuffers->mMemStats[stat.getIndex()]; + const MemAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mMemStats[stat.getIndex()] : NULL; + return accumulator.mDeallocations.getSampleCount() + (active_accumulator ? active_accumulator->mDeallocations.getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mCounts[stat.getIndex()].hasValue(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator ? active_accumulator->hasValue() : false); } F64 Recording::getSum(const StatType& stat) { - return mBuffers->mCounts[stat.getIndex()].getSum(); -} - -F64 Recording::getSum( const StatType& stat) -{ - return (F64)mBuffers->mEvents[stat.getIndex()].getSum(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + return accumulator.getSum() + (active_accumulator ? active_accumulator->getSum() : 0); } F64 Recording::getPerSec( const StatType& stat ) { - F64 sum = mBuffers->mCounts[stat.getIndex()].getSum(); - return sum / mElapsedSeconds.value(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + F64 sum = accumulator.getSum() + (active_accumulator ? active_accumulator->getSum() : 0); + return sum / mElapsedSeconds.value(); } S32 Recording::getSampleCount( const StatType& stat ) { - return mBuffers->mCounts[stat.getIndex()].getSampleCount(); + update(); + const CountAccumulator& accumulator = mBuffers->mCounts[stat.getIndex()]; + const CountAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mCounts[stat.getIndex()] : NULL; + return accumulator.getSampleCount() + (active_accumulator ? active_accumulator->getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mSamples[stat.getIndex()].hasValue(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator && active_accumulator->hasValue()); } F64 Recording::getMin( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getMin(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return llmin(accumulator.getMin(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMin() : F32_MAX); } F64 Recording::getMax( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getMax(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return llmax(accumulator.getMax(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMax() : F32_MIN); } F64 Recording::getMean( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getMean(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + if (active_accumulator && active_accumulator->hasValue()) + { + return lerp(accumulator.getMean(), active_accumulator->getMean(), active_accumulator->getSampleCount() / (accumulator.getSampleCount() + active_accumulator->getSampleCount())); + } + else + { + return accumulator.getMean(); + } } F64 Recording::getStandardDeviation( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getStandardDeviation(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + + if (active_accumulator && active_accumulator->hasValue()) + { + F64 sum_of_squares = SampleAccumulator::mergeSumsOfSquares(accumulator, *active_accumulator); + return sqrtf(sum_of_squares / (accumulator.getSamplingTime() + active_accumulator->getSamplingTime())); + } + else + { + return accumulator.getStandardDeviation(); + } } F64 Recording::getLastValue( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getLastValue(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return (active_accumulator && active_accumulator->hasValue() ? active_accumulator->getLastValue() : accumulator.getLastValue()); } S32 Recording::getSampleCount( const StatType& stat ) { - return mBuffers->mSamples[stat.getIndex()].getSampleCount(); + update(); + const SampleAccumulator& accumulator = mBuffers->mSamples[stat.getIndex()]; + const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; + return accumulator.getSampleCount() + (active_accumulator && active_accumulator->hasValue() ? active_accumulator->getSampleCount() : 0); } bool Recording::hasValue(const StatType& stat) { - return mBuffers->mEvents[stat.getIndex()].hasValue(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return accumulator.hasValue() || (active_accumulator && active_accumulator->hasValue()); +} + +F64 Recording::getSum( const StatType& stat) +{ + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return (F64)(accumulator.getSum() + (active_accumulator && active_accumulator->hasValue() ? active_accumulator->getSum() : 0)); } F64 Recording::getMin( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getMin(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return llmin(accumulator.getMin(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMin() : F32_MAX); } F64 Recording::getMax( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getMax(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return llmax(accumulator.getMax(), active_accumulator && active_accumulator->hasValue() ? active_accumulator->getMax() : F32_MIN); } F64 Recording::getMean( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getMean(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + if (active_accumulator && active_accumulator->hasValue()) + { + return lerp(accumulator.getMean(), active_accumulator->getMean(), active_accumulator->getSampleCount() / (accumulator.getSampleCount() + active_accumulator->getSampleCount())); + } + else + { + return accumulator.getMean(); + } } F64 Recording::getStandardDeviation( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getStandardDeviation(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + + if (active_accumulator && active_accumulator->hasValue()) + { + F64 sum_of_squares = EventAccumulator::mergeSumsOfSquares(accumulator, *active_accumulator); + return sqrtf(sum_of_squares / (accumulator.getSampleCount() + active_accumulator->getSampleCount())); + } + else + { + return accumulator.getStandardDeviation(); + } } F64 Recording::getLastValue( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getLastValue(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return active_accumulator ? active_accumulator->getLastValue() : accumulator.getLastValue(); } S32 Recording::getSampleCount( const StatType& stat ) { - return mBuffers->mEvents[stat.getIndex()].getSampleCount(); + update(); + const EventAccumulator& accumulator = mBuffers->mEvents[stat.getIndex()]; + const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; + return accumulator.getSampleCount() + (active_accumulator ? active_accumulator->getSampleCount() : 0); } /////////////////////////////////////////////////////////////////////// diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index b045aafa11..93ac276e33 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -322,7 +322,7 @@ namespace LLTrace LLTimer mSamplingTimer; F64Seconds mElapsedSeconds; LLCopyOnWritePointer mBuffers; - bool mInHandOff; + AccumulatorBufferGroup* mActiveBuffers; }; diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 7b7da5343d..a70e94e4b1 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -131,7 +131,7 @@ TimeBlockTreeNode* ThreadRecorder::getTimeBlockTreeNode( S32 index ) } -void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_handoff ) +AccumulatorBufferGroup* ThreadRecorder::activate( AccumulatorBufferGroup* recording) { ActiveRecording* active_recording = new ActiveRecording(recording); if (!mActiveRecordings.empty()) @@ -144,6 +144,7 @@ void ThreadRecorder::activate( AccumulatorBufferGroup* recording, bool from_hand mActiveRecordings.push_back(active_recording); mActiveRecordings.back()->mPartialRecording.makeCurrent(); + return &active_recording->mPartialRecording; } ThreadRecorder::active_recording_list_t::iterator ThreadRecorder::bringUpToDate( AccumulatorBufferGroup* recording ) diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index c6afcdac80..d30fa15ea7 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -47,7 +47,7 @@ namespace LLTrace ~ThreadRecorder(); - void activate(AccumulatorBufferGroup* recording, bool from_handoff = false); + AccumulatorBufferGroup* activate(AccumulatorBufferGroup* recording); void deactivate(AccumulatorBufferGroup* recording); active_recording_list_t::iterator bringUpToDate(AccumulatorBufferGroup* recording); diff --git a/indra/llcommon/tests/lltrace_test.cpp b/indra/llcommon/tests/lltrace_test.cpp index 8ce509699d..0a9d85ad00 100644 --- a/indra/llcommon/tests/lltrace_test.cpp +++ b/indra/llcommon/tests/lltrace_test.cpp @@ -109,8 +109,9 @@ namespace tut at_work.stop(); drink_coffee(1, S32VentiCup(1)); } - after_3pm.stop(); - all_day.stop(); + // don't need to stop recordings to get accurate values out of them + //after_3pm.stop(); + //all_day.stop(); ensure("count stats are counted when recording is active", at_work.getSum(sCupsOfCoffeeConsumed) == 3 -- cgit v1.3