From b3e9c46c94dad0c81a5adcb9152521b5368c66a7 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 29 Aug 2012 22:50:56 -0700
Subject: SH-3275 WIP Run viewer metrics for object update messages further
 cleanup of LLStat removed llfloaterlagmeter

---
 indra/newview/CMakeLists.txt                       |   2 -
 indra/newview/llfloaterlagmeter.cpp                | 375 ---------------------
 indra/newview/llfloaterlagmeter.h                  |  80 -----
 indra/newview/llstatusbar.cpp                      |   1 -
 indra/newview/llviewerassetstats.cpp               |   4 +-
 indra/newview/llviewerfloaterreg.cpp               |   2 -
 indra/newview/llviewerstats.cpp                    | 150 ++++-----
 indra/newview/llviewerstats.h                      |  50 ++-
 indra/newview/llviewertexturelist.cpp              |  12 +-
 indra/newview/llvoavatarself.cpp                   |   4 +-
 indra/newview/llworld.cpp                          |   2 +-
 .../skins/default/xui/da/floater_lagmeter.xml      | 151 ---------
 .../skins/default/xui/de/floater_lagmeter.xml      | 151 ---------
 .../skins/default/xui/en/floater_lagmeter.xml      | 336 ------------------
 .../skins/default/xui/es/floater_lagmeter.xml      | 154 ---------
 .../skins/default/xui/fr/floater_lagmeter.xml      | 151 ---------
 .../skins/default/xui/it/floater_lagmeter.xml      | 154 ---------
 .../skins/default/xui/ja/floater_lagmeter.xml      | 151 ---------
 .../skins/default/xui/pl/floater_lagmeter.xml      | 151 ---------
 .../skins/default/xui/pt/floater_lagmeter.xml      | 154 ---------
 .../skins/default/xui/ru/floater_lagmeter.xml      | 151 ---------
 .../skins/default/xui/tr/floater_lagmeter.xml      | 151 ---------
 .../skins/default/xui/zh/floater_lagmeter.xml      | 151 ---------
 23 files changed, 102 insertions(+), 2586 deletions(-)
 delete mode 100644 indra/newview/llfloaterlagmeter.cpp
 delete mode 100644 indra/newview/llfloaterlagmeter.h
 delete mode 100644 indra/newview/skins/default/xui/da/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/de/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/en/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/es/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/fr/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/it/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/ja/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/pl/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/pt/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/ru/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/tr/floater_lagmeter.xml
 delete mode 100644 indra/newview/skins/default/xui/zh/floater_lagmeter.xml

(limited to 'indra/newview')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 4c0657b61d..b3aa6949b3 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -209,7 +209,6 @@ set(viewer_SOURCE_FILES
     llfloaterinspect.cpp
     llfloaterinventory.cpp
     llfloaterjoystick.cpp
-    llfloaterlagmeter.cpp
     llfloaterland.cpp
     llfloaterlandholdings.cpp
     llfloatermap.cpp
@@ -784,7 +783,6 @@ set(viewer_HEADER_FILES
     llfloaterinspect.h
     llfloaterinventory.h
     llfloaterjoystick.h
-    llfloaterlagmeter.h
     llfloaterland.h
     llfloaterlandholdings.h
     llfloatermap.h
diff --git a/indra/newview/llfloaterlagmeter.cpp b/indra/newview/llfloaterlagmeter.cpp
deleted file mode 100644
index 68b1770bb2..0000000000
--- a/indra/newview/llfloaterlagmeter.cpp
+++ /dev/null
@@ -1,375 +0,0 @@
-/** 
- * @file llfloaterlagmeter.cpp
- * @brief The "Lag-o-Meter" floater used to tell users what is causing lag.
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, 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 "llviewerprecompiledheaders.h"
-
-#include "llfloaterlagmeter.h"
-
-#include "lluictrlfactory.h"
-#include "llviewerstats.h"
-#include "llviewertexture.h"
-#include "llviewercontrol.h"
-#include "llappviewer.h"
-
-#include "lltexturefetch.h"
-
-#include "llbutton.h"
-#include "llfocusmgr.h"
-#include "lltextbox.h"
-
-const std::string LAG_CRITICAL_IMAGE_NAME = "lag_status_critical.tga";
-const std::string LAG_WARNING_IMAGE_NAME  = "lag_status_warning.tga";
-const std::string LAG_GOOD_IMAGE_NAME     = "lag_status_good.tga";
-
-LLFloaterLagMeter::LLFloaterLagMeter(const LLSD& key)
-	:	LLFloater(key)
-{
-	mCommitCallbackRegistrar.add("LagMeter.ClickShrink",  boost::bind(&LLFloaterLagMeter::onClickShrink, this));	
-}
-
-BOOL LLFloaterLagMeter::postBuild()
-{
-	// Don't let this window take keyboard focus -- it's confusing to
-	// lose arrow-key driving when testing lag.
-	setIsChrome(TRUE);
-	
-	// were we shrunk last time?
-	if (isShrunk())
-	{
-		onClickShrink();
-	}
-	
-	mClientButton = getChild<LLButton>("client_lagmeter");
-	mClientText = getChild<LLTextBox>("client_text");
-	mClientCause = getChild<LLTextBox>("client_lag_cause");
-
-	mNetworkButton = getChild<LLButton>("network_lagmeter");
-	mNetworkText = getChild<LLTextBox>("network_text");
-	mNetworkCause = getChild<LLTextBox>("network_lag_cause");
-
-	mServerButton = getChild<LLButton>("server_lagmeter");
-	mServerText = getChild<LLTextBox>("server_text");
-	mServerCause = getChild<LLTextBox>("server_lag_cause");
-
-	std::string config_string = getString("client_frame_rate_critical_fps", mStringArgs);
-	mClientFrameTimeCritical = 1.0f / (float)atof( config_string.c_str() );
-	config_string = getString("client_frame_rate_warning_fps", mStringArgs);
-	mClientFrameTimeWarning = 1.0f / (float)atof( config_string.c_str() );
-
-	config_string = getString("network_packet_loss_critical_pct", mStringArgs);
-	mNetworkPacketLossCritical = (float)atof( config_string.c_str() );
-	config_string = getString("network_packet_loss_warning_pct", mStringArgs);
-	mNetworkPacketLossWarning = (float)atof( config_string.c_str() );
-
-	config_string = getString("network_ping_critical_ms", mStringArgs);
-	mNetworkPingCritical = (float)atof( config_string.c_str() );
-	config_string = getString("network_ping_warning_ms", mStringArgs);
-	mNetworkPingWarning = (float)atof( config_string.c_str() );
-	config_string = getString("server_frame_rate_critical_fps", mStringArgs);
-
-	mServerFrameTimeCritical = 1000.0f / (float)atof( config_string.c_str() );
-	config_string = getString("server_frame_rate_warning_fps", mStringArgs);
-	mServerFrameTimeWarning = 1000.0f / (float)atof( config_string.c_str() );
-	config_string = getString("server_single_process_max_time_ms", mStringArgs);
-	mServerSingleProcessMaxTime = (float)atof( config_string.c_str() );
-
-//	mShrunk = false;
-	config_string = getString("max_width_px", mStringArgs);
-	mMaxWidth = atoi( config_string.c_str() );
-	config_string = getString("min_width_px", mStringArgs);
-	mMinWidth = atoi( config_string.c_str() );
-
-	mStringArgs["[CLIENT_FRAME_RATE_CRITICAL]"] = getString("client_frame_rate_critical_fps");
-	mStringArgs["[CLIENT_FRAME_RATE_WARNING]"] = getString("client_frame_rate_warning_fps");
-
-	mStringArgs["[NETWORK_PACKET_LOSS_CRITICAL]"] = getString("network_packet_loss_critical_pct");
-	mStringArgs["[NETWORK_PACKET_LOSS_WARNING]"] = getString("network_packet_loss_warning_pct");
-
-	mStringArgs["[NETWORK_PING_CRITICAL]"] = getString("network_ping_critical_ms");
-	mStringArgs["[NETWORK_PING_WARNING]"] = getString("network_ping_warning_ms");
-
-	mStringArgs["[SERVER_FRAME_RATE_CRITICAL]"] = getString("server_frame_rate_critical_fps");
-	mStringArgs["[SERVER_FRAME_RATE_WARNING]"] = getString("server_frame_rate_warning_fps");
-
-//	childSetAction("minimize", onClickShrink, this);
-	updateControls(isShrunk()); // if expanded append colon to the labels (EXT-4079)
-
-	return TRUE;
-}
-LLFloaterLagMeter::~LLFloaterLagMeter()
-{
-	// save shrunk status for next time
-//	gSavedSettings.setBOOL("LagMeterShrunk", mShrunk);
-	// expand so we save the large window rectangle
-	if (isShrunk())
-	{
-		onClickShrink();
-	}
-}
-
-void LLFloaterLagMeter::draw()
-{
-	determineClient();
-	determineNetwork();
-	determineServer();
-
-	LLFloater::draw();
-}
-
-void LLFloaterLagMeter::determineClient()
-{
-	F32 client_frame_time = LLViewerStats::getInstance()->mFPSStat.getMeanDuration();
-	bool find_cause = false;
-
-	if (!gFocusMgr.getAppHasFocus())
-	{
-		mClientButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME));
-		mClientText->setText( getString("client_frame_time_window_bg_msg", mStringArgs) );
-		mClientCause->setText( LLStringUtil::null );
-	}
-	else if(client_frame_time >= mClientFrameTimeCritical)
-	{
-		mClientButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME));
-		mClientText->setText( getString("client_frame_time_critical_msg", mStringArgs) );
-		find_cause = true;
-	}
-	else if(client_frame_time >= mClientFrameTimeWarning)
-	{
-		mClientButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME));
-		mClientText->setText( getString("client_frame_time_warning_msg", mStringArgs) );
-		find_cause = true;
-	}
-	else
-	{
-		mClientButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME));
-		mClientText->setText( getString("client_frame_time_normal_msg", mStringArgs) );
-		mClientCause->setText( LLStringUtil::null );
-	}	
-
-	if(find_cause)
-	{
-		if(gSavedSettings.getF32("RenderFarClip") > 128)
-		{
-			mClientCause->setText( getString("client_draw_distance_cause_msg", mStringArgs) );
-		}
-		else if(LLAppViewer::instance()->getTextureFetch()->getNumRequests() > 2)
-		{
-			mClientCause->setText( getString("client_texture_loading_cause_msg", mStringArgs) );
-		}
-		else if((BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes)) > LLViewerTexture::sMaxBoundTextureMemInMegaBytes)
-		{
-			mClientCause->setText( getString("client_texture_memory_cause_msg", mStringArgs) );
-		}
-		else 
-		{
-			mClientCause->setText( getString("client_complex_objects_cause_msg", mStringArgs) );
-		}
-	}
-}
-
-void LLFloaterLagMeter::determineNetwork()
-{
-	F32 packet_loss = LLViewerStats::getInstance()->mPacketsLostPercentStat.getMean();
-	F32 ping_time = LLViewerStats::getInstance()->mSimPingStat.getMean();
-	bool find_cause_loss = false;
-	bool find_cause_ping = false;
-
-	// *FIXME: We can't blame a large ping time on anything in
-	// particular if the frame rate is low, because a low frame
-	// rate is a sure recipe for bad ping times right now until
-	// the network handlers are de-synched from the rendering.
-	F32 client_frame_time_ms = 1000.0f * LLViewerStats::getInstance()->mFPSStat.getMeanDuration();
-	
-	if(packet_loss >= mNetworkPacketLossCritical)
-	{
-		mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME));
-		mNetworkText->setText( getString("network_packet_loss_critical_msg", mStringArgs) );
-		find_cause_loss = true;
-	}
-	else if(ping_time >= mNetworkPingCritical)
-	{
-		mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME));
-		if (client_frame_time_ms < mNetworkPingCritical)
-		{
-			mNetworkText->setText( getString("network_ping_critical_msg", mStringArgs) );
-			find_cause_ping = true;
-		}
-	}
-	else if(packet_loss >= mNetworkPacketLossWarning)
-	{
-		mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME));
-		mNetworkText->setText( getString("network_packet_loss_warning_msg", mStringArgs) );
-		find_cause_loss = true;
-	}
-	else if(ping_time >= mNetworkPingWarning)
-	{
-		mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME));
-		if (client_frame_time_ms < mNetworkPingWarning)
-		{
-			mNetworkText->setText( getString("network_ping_warning_msg", mStringArgs) );
-			find_cause_ping = true;
-		}
-	}
-	else
-	{
-		mNetworkButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME));
-		mNetworkText->setText( getString("network_performance_normal_msg", mStringArgs) );
-	}
-
-	if(find_cause_loss)
- 	{
-		mNetworkCause->setText( getString("network_packet_loss_cause_msg", mStringArgs) );
- 	}
-	else if(find_cause_ping)
-	{
-		mNetworkCause->setText( getString("network_ping_cause_msg", mStringArgs) );
-	}
-	else
-	{
-		mNetworkCause->setText( LLStringUtil::null );
-	}
-}
-
-void LLFloaterLagMeter::determineServer()
-{
-	F32 sim_frame_time = LLViewerStats::getInstance()->mSimFrameMsec.getCurrent();
-	bool find_cause = false;
-
-	if(sim_frame_time >= mServerFrameTimeCritical)
-	{
-		mServerButton->setImageUnselected(LLUI::getUIImage(LAG_CRITICAL_IMAGE_NAME));
-		mServerText->setText( getString("server_frame_time_critical_msg", mStringArgs) );
-		find_cause = true;
-	}
-	else if(sim_frame_time >= mServerFrameTimeWarning)
-	{
-		mServerButton->setImageUnselected(LLUI::getUIImage(LAG_WARNING_IMAGE_NAME));
-		mServerText->setText( getString("server_frame_time_warning_msg", mStringArgs) );
-		find_cause = true;
-	}
-	else
-	{
-		mServerButton->setImageUnselected(LLUI::getUIImage(LAG_GOOD_IMAGE_NAME));
-		mServerText->setText( getString("server_frame_time_normal_msg", mStringArgs) );
-		mServerCause->setText( LLStringUtil::null );
-	}	
-
-	if(find_cause)
-	{
-		if(LLViewerStats::getInstance()->mSimSimPhysicsMsec.getCurrent() > mServerSingleProcessMaxTime)
-		{
-			mServerCause->setText( getString("server_physics_cause_msg", mStringArgs) );
-		}
-		else if(LLViewerStats::getInstance()->mSimScriptMsec.getCurrent() > mServerSingleProcessMaxTime)
-		{
-			mServerCause->setText( getString("server_scripts_cause_msg", mStringArgs) );
-		}
-		else if(LLViewerStats::getInstance()->mSimNetMsec.getCurrent() > mServerSingleProcessMaxTime)
-		{
-			mServerCause->setText( getString("server_net_cause_msg", mStringArgs) );
-		}
-		else if(LLViewerStats::getInstance()->mSimAgentMsec.getCurrent() > mServerSingleProcessMaxTime)
-		{
-			mServerCause->setText( getString("server_agent_cause_msg", mStringArgs) );
-		}
-		else if(LLViewerStats::getInstance()->mSimImagesMsec.getCurrent() > mServerSingleProcessMaxTime)
-		{
-			mServerCause->setText( getString("server_images_cause_msg", mStringArgs) );
-		}
-		else
-		{
-			mServerCause->setText( getString("server_generic_cause_msg", mStringArgs) );
-		}
-	}
-}
-
-void LLFloaterLagMeter::updateControls(bool shrink)
-{
-//	LLFloaterLagMeter * self = (LLFloaterLagMeter*)data;
-
-	LLButton * button = getChild<LLButton>("minimize");
-	S32 delta_width = mMaxWidth -mMinWidth;
-	LLRect r = getRect();
-
-	if(!shrink)
-	{
-		setTitle(getString("max_title_msg", mStringArgs) );
-		// make left edge appear to expand
-		r.translate(-delta_width, 0);
-		setRect(r);
-		reshape(mMaxWidth, getRect().getHeight());
-		
-		getChild<LLUICtrl>("client")->setValue(getString("client_text_msg", mStringArgs) + ":");
-		getChild<LLUICtrl>("network")->setValue(getString("network_text_msg",mStringArgs) + ":");
-		getChild<LLUICtrl>("server")->setValue(getString("server_text_msg", mStringArgs) + ":");
-
-		// usually "<<"
-		button->setLabel( getString("smaller_label", mStringArgs) );
-	}
-	else
-	{
-		setTitle( getString("min_title_msg", mStringArgs) );
-		// make left edge appear to collapse
-		r.translate(delta_width, 0);
-		setRect(r);
-		reshape(mMinWidth, getRect().getHeight());
-		
-		getChild<LLUICtrl>("client")->setValue(getString("client_text_msg", mStringArgs) );
-		getChild<LLUICtrl>("network")->setValue(getString("network_text_msg",mStringArgs) );
-		getChild<LLUICtrl>("server")->setValue(getString("server_text_msg", mStringArgs) );
-
-		// usually ">>"
-		button->setLabel( getString("bigger_label", mStringArgs) );
-	}
-	// Don't put keyboard focus on the button
-	button->setFocus(FALSE);
-
-//	self->mClientText->setVisible(self->mShrunk);
-//	self->mClientCause->setVisible(self->mShrunk);
-//	self->getChildView("client_help")->setVisible( self->mShrunk);
-
-//	self->mNetworkText->setVisible(self->mShrunk);
-//	self->mNetworkCause->setVisible(self->mShrunk);
-//	self->getChildView("network_help")->setVisible( self->mShrunk);
-
-//	self->mServerText->setVisible(self->mShrunk);
-//	self->mServerCause->setVisible(self->mShrunk);
-//	self->getChildView("server_help")->setVisible( self->mShrunk);
-
-//	self->mShrunk = !self->mShrunk;
-}
-
-BOOL LLFloaterLagMeter::isShrunk()
-{
-	return gSavedSettings.getBOOL("LagMeterShrunk");
-}
-
-void LLFloaterLagMeter::onClickShrink()  // toggle "LagMeterShrunk"
-{
-	bool shrunk = isShrunk();
-	updateControls(!shrunk);
-	gSavedSettings.setBOOL("LagMeterShrunk", !shrunk);
-}
diff --git a/indra/newview/llfloaterlagmeter.h b/indra/newview/llfloaterlagmeter.h
deleted file mode 100644
index eef6955601..0000000000
--- a/indra/newview/llfloaterlagmeter.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/** 
- * @file llfloaterlagmeter.h
- * @brief The "Lag-o-Meter" floater used to tell users what is causing lag.
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, 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$
- */
-
-#ifndef LLFLOATERLAGMETER_H
-#define LLFLOATERLAGMETER_H
-
-#include "llfloater.h"
-
-class LLTextBox;
-
-class LLFloaterLagMeter : public LLFloater
-{
-	friend class LLFloaterReg;
-	
-public:
-	/*virtual*/ void draw();
-	/*virtual*/ BOOL postBuild();	
-private:
-	
-	LLFloaterLagMeter(const LLSD& key);
-	/*virtual*/ ~LLFloaterLagMeter();
-	void determineClient();
-	void determineNetwork();
-	void determineServer();
-	void updateControls(bool shrink);
-	BOOL isShrunk();
-
-	void onClickShrink();
-
-	bool mShrunk;
-	S32 mMaxWidth, mMinWidth;
-
-	F32 mClientFrameTimeCritical;
-	F32 mClientFrameTimeWarning;
-	LLButton * mClientButton;
-	LLTextBox * mClientText;
-	LLTextBox * mClientCause;
-
-	F32 mNetworkPacketLossCritical;
-	F32 mNetworkPacketLossWarning;
-	F32 mNetworkPingCritical;
-	F32 mNetworkPingWarning;
-	LLButton * mNetworkButton;
-	LLTextBox * mNetworkText;
-	LLTextBox * mNetworkCause;
-
-	F32 mServerFrameTimeCritical;
-	F32 mServerFrameTimeWarning;
-	F32 mServerSingleProcessMaxTime;
-	LLButton * mServerButton;
-	LLTextBox * mServerText;
-	LLTextBox * mServerCause;
-
-	LLStringUtil::format_map_t mStringArgs;
-};
-
-#endif
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 89240c982f..fc6e9fd514 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -37,7 +37,6 @@
 #include "llviewercontrol.h"
 #include "llfloaterbuycurrency.h"
 #include "llbuycurrencyhtml.h"
-#include "llfloaterlagmeter.h"
 #include "llpanelnearbymedia.h"
 #include "llpanelvolumepulldown.h"
 #include "llfloaterregioninfo.h"
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 4c59fd0371..e556743cbf 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -369,8 +369,8 @@ LLViewerAssetStats::asLLSD(bool compact_output)
 		std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat);
 		avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat];
 	}
-	avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].getData();
-	avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].getData();
+	avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD();
+	avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD();
 	ret[avatar_tag] = avatar_info;
 	
 	return ret;
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 1f7cf0cdd4..69586e3634 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -73,7 +73,6 @@
 #include "llfloaterinspect.h"
 #include "llfloaterinventory.h"
 #include "llfloaterjoystick.h"
-#include "llfloaterlagmeter.h"
 #include "llfloaterland.h"
 #include "llfloaterlandholdings.h"
 #include "llfloatermap.h"
@@ -227,7 +226,6 @@ void LLViewerFloaterReg::registerFloaters()
 	LLNotificationsUI::registerFloater();
 	LLFloaterDisplayNameUtil::registerFloater();
 	
-	LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>);
 	LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>);
 	
 	LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>);
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 1d6d5b7e72..58a7b3a463 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -66,137 +66,134 @@ class StatAttributes
 {
 public:
 	StatAttributes(const char* name,
-				   const BOOL enabled,
-				   const BOOL is_timer)
+				   const BOOL enabled)
 		: mName(name),
-		  mEnabled(enabled),
-		  mIsTimer(is_timer)
+		  mEnabled(enabled)
 	{
 	}
 	
 	std::string mName;
 	BOOL mEnabled;
-	BOOL mIsTimer;
 };
 
 const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] =
 {
 	// ST_VERSION
-	StatAttributes("Version", TRUE, FALSE),
+	StatAttributes("Version", TRUE),
 	// ST_AVATAR_EDIT_SECONDS
-	StatAttributes("Seconds in Edit Appearence", FALSE, TRUE),
+	StatAttributes("Seconds in Edit Appearence", FALSE),
 	// ST_TOOLBOX_SECONDS
-	StatAttributes("Seconds using Toolbox", FALSE, TRUE),
+	StatAttributes("Seconds using Toolbox", FALSE),
 	// ST_CHAT_COUNT
-	StatAttributes("Chat messages sent", FALSE, FALSE),
+	StatAttributes("Chat messages sent", FALSE),
 	// ST_IM_COUNT
-	StatAttributes("IMs sent", FALSE, FALSE),
+	StatAttributes("IMs sent", FALSE),
 	// ST_FULLSCREEN_BOOL
-	StatAttributes("Fullscreen mode", FALSE, FALSE),
+	StatAttributes("Fullscreen mode", FALSE),
 	// ST_RELEASE_COUNT
-	StatAttributes("Object release count", FALSE, FALSE),
+	StatAttributes("Object release count", FALSE),
 	// ST_CREATE_COUNT
-	StatAttributes("Object create count", FALSE, FALSE),
+	StatAttributes("Object create count", FALSE),
 	// ST_REZ_COUNT
-	StatAttributes("Object rez count", FALSE, FALSE),
+	StatAttributes("Object rez count", FALSE),
 	// ST_FPS_10_SECONDS
-	StatAttributes("Seconds below 10 FPS", FALSE, TRUE),
+	StatAttributes("Seconds below 10 FPS", FALSE),
 	// ST_FPS_2_SECONDS
-	StatAttributes("Seconds below 2 FPS", FALSE, TRUE),
+	StatAttributes("Seconds below 2 FPS", FALSE),
 	// ST_MOUSELOOK_SECONDS
-	StatAttributes("Seconds in Mouselook", FALSE, TRUE),
+	StatAttributes("Seconds in Mouselook", FALSE),
 	// ST_FLY_COUNT
-	StatAttributes("Fly count", FALSE, FALSE),
+	StatAttributes("Fly count", FALSE),
 	// ST_TELEPORT_COUNT
-	StatAttributes("Teleport count", FALSE, FALSE),
+	StatAttributes("Teleport count", FALSE),
 	// ST_OBJECT_DELETE_COUNT
-	StatAttributes("Objects deleted", FALSE, FALSE),
+	StatAttributes("Objects deleted", FALSE),
 	// ST_SNAPSHOT_COUNT
-	StatAttributes("Snapshots taken", FALSE, FALSE),
+	StatAttributes("Snapshots taken", FALSE),
 	// ST_UPLOAD_SOUND_COUNT
-	StatAttributes("Sounds uploaded", FALSE, FALSE),
+	StatAttributes("Sounds uploaded", FALSE),
 	// ST_UPLOAD_TEXTURE_COUNT
-	StatAttributes("Textures uploaded", FALSE, FALSE),
+	StatAttributes("Textures uploaded", FALSE),
 	// ST_EDIT_TEXTURE_COUNT
-	StatAttributes("Changes to textures on objects", FALSE, FALSE),
+	StatAttributes("Changes to textures on objects", FALSE),
 	// ST_KILLED_COUNT
-	StatAttributes("Number of times killed", FALSE, FALSE),
+	StatAttributes("Number of times killed", FALSE),
 	// ST_FRAMETIME_JITTER
-	StatAttributes("Average delta between sucessive frame times", FALSE, FALSE),
+	StatAttributes("Average delta between successive frame times", FALSE),
 	// ST_FRAMETIME_SLEW
-	StatAttributes("Average delta between frame time and mean", FALSE, FALSE),
+	StatAttributes("Average delta between frame time and mean", FALSE),
 	// ST_INVENTORY_TOO_LONG
-	StatAttributes("Inventory took too long to load", FALSE, FALSE),
+	StatAttributes("Inventory took too long to load", FALSE),
 	// ST_WEARABLES_TOO_LONG
-	StatAttributes("Wearables took too long to load", FALSE, FALSE),
+	StatAttributes("Wearables took too long to load", FALSE),
 	// ST_LOGIN_SECONDS
-	StatAttributes("Time between LoginRequest and LoginReply", FALSE, FALSE),
+	StatAttributes("Time between LoginRequest and LoginReply", FALSE),
 	// ST_LOGIN_TIMEOUT_COUNT
-	StatAttributes("Number of login attempts that timed out", FALSE, FALSE),
+	StatAttributes("Number of login attempts that timed out", FALSE),
 	// ST_HAS_BAD_TIMER
-	StatAttributes("Known bad timer if != 0.0", FALSE, FALSE),
+	StatAttributes("Known bad timer if != 0.0", FALSE),
 	// ST_DOWNLOAD_FAILED
-	StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE, FALSE),
+	StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE),
 	// ST_LSL_SAVE_COUNT
-	StatAttributes("Number of times user has saved a script", FALSE, FALSE),
+	StatAttributes("Number of times user has saved a script", FALSE),
 	// ST_UPLOAD_ANIM_COUNT
-	StatAttributes("Animations uploaded", FALSE, FALSE),
+	StatAttributes("Animations uploaded", FALSE),
 	// ST_FPS_8_SECONDS
-	StatAttributes("Seconds below 8 FPS", FALSE, TRUE),
+	StatAttributes("Seconds below 8 FPS", FALSE),
 	// ST_SIM_FPS_20_SECONDS
-	StatAttributes("Seconds with sim FPS below 20", FALSE, TRUE),
+	StatAttributes("Seconds with sim FPS below 20", FALSE),
 	// ST_PHYS_FPS_20_SECONDS
-	StatAttributes("Seconds with physics FPS below 20", FALSE, TRUE),
+	StatAttributes("Seconds with physics FPS below 20", FALSE),
 	// ST_LOSS_05_SECONDS
-	StatAttributes("Seconds with packet loss > 5%", FALSE, TRUE),
+	StatAttributes("Seconds with packet loss > 5%", FALSE),
 	// ST_FPS_DROP_50_RATIO
-	StatAttributes("Ratio of frames 2x longer than previous", FALSE, FALSE),
+	StatAttributes("Ratio of frames 2x longer than previous", FALSE),
 	// ST_ENABLE_VBO
-	StatAttributes("Vertex Buffers Enabled", TRUE, FALSE),
+	StatAttributes("Vertex Buffers Enabled", TRUE),
 	// ST_DELTA_BANDWIDTH
-	StatAttributes("Increase/Decrease in bandwidth based on packet loss", FALSE, FALSE),
+	StatAttributes("Increase/Decrease in bandwidth based on packet loss", FALSE),
 	// ST_MAX_BANDWIDTH
-	StatAttributes("Max bandwidth setting", FALSE, FALSE),
+	StatAttributes("Max bandwidth setting", FALSE),
 	// ST_LIGHTING_DETAIL
-	StatAttributes("Lighting Detail", FALSE, FALSE),
+	StatAttributes("Lighting Detail", FALSE),
 	// ST_VISIBLE_AVATARS
-	StatAttributes("Visible Avatars", FALSE, FALSE),
+	StatAttributes("Visible Avatars", FALSE),
 	// ST_SHADER_OJECTS
-	StatAttributes("Object Shaders", FALSE, FALSE),
+	StatAttributes("Object Shaders", FALSE),
 	// ST_SHADER_ENVIRONMENT
-	StatAttributes("Environment Shaders", FALSE, FALSE),
+	StatAttributes("Environment Shaders", FALSE),
 	// ST_VISIBLE_DRAW_DIST
-	StatAttributes("Draw Distance", FALSE, FALSE),
+	StatAttributes("Draw Distance", FALSE),
 	// ST_VISIBLE_CHAT_BUBBLES
-	StatAttributes("Chat Bubbles Enabled", FALSE, FALSE),
+	StatAttributes("Chat Bubbles Enabled", FALSE),
 	// ST_SHADER_AVATAR
-	StatAttributes("Avatar Shaders", FALSE, FALSE),
+	StatAttributes("Avatar Shaders", FALSE),
 	// ST_FRAME_SECS
-	StatAttributes("FRAME_SECS", FALSE, FALSE),
+	StatAttributes("FRAME_SECS", FALSE),
 	// ST_UPDATE_SECS
-	StatAttributes("UPDATE_SECS", FALSE, FALSE),
+	StatAttributes("UPDATE_SECS", FALSE),
 	// ST_NETWORK_SECS
-	StatAttributes("NETWORK_SECS", FALSE, FALSE),
+	StatAttributes("NETWORK_SECS", FALSE),
 	// ST_IMAGE_SECS
-	StatAttributes("IMAGE_SECS", FALSE, FALSE),
+	StatAttributes("IMAGE_SECS", FALSE),
 	// ST_REBUILD_SECS
-	StatAttributes("REBUILD_SECS", FALSE, FALSE),
+	StatAttributes("REBUILD_SECS", FALSE),
 	// ST_RENDER_SECS
-	StatAttributes("RENDER_SECS", FALSE, FALSE),
+	StatAttributes("RENDER_SECS", FALSE),
 	// ST_CROSSING_AVG
-	StatAttributes("CROSSING_AVG", FALSE, FALSE),
+	StatAttributes("CROSSING_AVG", FALSE),
 	// ST_CROSSING_MAX
-	StatAttributes("CROSSING_MAX", FALSE, FALSE),
+	StatAttributes("CROSSING_MAX", FALSE),
 	// ST_LIBXUL_WIDGET_USED
-	StatAttributes("LibXUL Widget used", FALSE, FALSE), // Unused
+	StatAttributes("LibXUL Widget used", FALSE), // Unused
 	// ST_WINDOW_WIDTH
-	StatAttributes("Window width", FALSE, FALSE),
+	StatAttributes("Window width", FALSE),
 	// ST_WINDOW_HEIGHT
-	StatAttributes("Window height", FALSE, FALSE),
+	StatAttributes("Window height", FALSE),
 	// ST_TEX_BAKES
-	StatAttributes("Texture Bakes", FALSE, FALSE),
+	StatAttributes("Texture Bakes", FALSE),
 	// ST_TEX_REBAKES
-	StatAttributes("Texture Rebakes", FALSE, FALSE)
+	StatAttributes("Texture Rebakes", FALSE)
 
 };
 
@@ -207,16 +204,11 @@ LLViewerStats::LLViewerStats() :
 	mAssetKBitStat("assetkbitstat"),
 	mTextureKBitStat("texturekbitstat"),
 	mVFSPendingOperations("vfspendingoperations"),
-	mObjectsDrawnStat("objectsdrawnstat"),
-	mObjectsCulledStat("objectsculledstat"),
-	mObjectsTestedStat("objectstestedstat"),
-	mObjectsComparedStat("objectscomparedstat"),
-	mObjectsOccludedStat("objectsoccludedstat"),
 	mFPSStat("fpsstat"),
 	mPacketsInStat("packetsinstat"),
 	mPacketsLostStat("packetsloststat"),
 	mPacketsOutStat("packetsoutstat"),
-	mPacketsLostPercentStat("packetslostpercentstat", 64),
+	mPacketsLostPercentStat("packetslostpercentstat"),
 	mTexturePacketsStat("texturepacketsstat"),
 	mActualInKBitStat("actualinkbitstat"),
 	mActualOutKBitStat("actualoutkbitstat"),
@@ -258,12 +250,12 @@ LLViewerStats::LLViewerStats() :
 	mPhysicsLODTasks("physicslodtasks"),
 	mPhysicsMemoryAllocated("physicsmemoryallocated"),
 	mSimPingStat("simpingstat"),
-	mNumImagesStat("numimagesstat", 32, TRUE),
-	mNumRawImagesStat("numrawimagesstat", 32, TRUE),
-	mGLTexMemStat("gltexmemstat", 32, TRUE),
-	mGLBoundMemStat("glboundmemstat", 32, TRUE),
-	mRawMemStat("rawmemstat", 32, TRUE),
-	mFormattedMemStat("formattedmemstat", 32, TRUE),
+	mNumImagesStat("numimagesstat", TRUE),
+	mNumRawImagesStat("numrawimagesstat", TRUE),
+	mGLTexMemStat("gltexmemstat", TRUE),
+	mGLBoundMemStat("glboundmemstat", TRUE),
+	mRawMemStat("rawmemstat", TRUE),
+	mFormattedMemStat("formattedmemstat", TRUE),
 	mNumObjectsStat("numobjectsstat"),
 	mNumActiveObjectsStat("numactiveobjectsstat"),
 	mNumNewObjectsStat("numnewobjectsstat"),
@@ -284,10 +276,6 @@ LLViewerStats::LLViewerStats() :
 	mAgentPositionSnaps.reset();
 }
 
-LLViewerStats::~LLViewerStats()
-{
-}
-
 void LLViewerStats::resetStats()
 {
 	LLViewerStats& stats = LLViewerStats::instance();
@@ -398,7 +386,7 @@ void LLViewerStats::addToMessage(LLSD &body) const
 		}
 	}
 	
-	body["AgentPositionSnaps"] = mAgentPositionSnaps.getData();
+	body["AgentPositionSnaps"] = mAgentPositionSnaps.asLLSD();
 	llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() 
 			<< "; Count = " << mAgentPositionSnaps.getCount() << llendl;
 }
@@ -783,7 +771,7 @@ void LLViewerStats::PhaseMap::clearPhases()
 	mPhaseMap.clear();
 }
 
-LLSD LLViewerStats::PhaseMap::dumpPhases()
+LLSD LLViewerStats::PhaseMap::asLLSD()
 {
 	LLSD result;
 	for (phase_map_t::iterator iter = mPhaseMap.begin(); iter != mPhaseMap.end(); ++iter)
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index e02a4ccdc7..0d8f2a45c0 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -39,11 +39,6 @@ public:
 			mAssetKBitStat,
 			mTextureKBitStat,
 			mVFSPendingOperations,
-			mObjectsDrawnStat,
-			mObjectsCulledStat,
-			mObjectsTestedStat,
-			mObjectsComparedStat,
-			mObjectsOccludedStat,
 			mFPSStat,
 			mPacketsInStat,
 			mPacketsLostStat,
@@ -55,60 +50,60 @@ public:
 			mTrianglesDrawnStat;
 
 	// Simulator stats
-	LLStat	mSimTimeDilation,
+	LLStat	mSimTimeDilation;
 
-			mSimFPS,
+	LLStat	mSimFPS,
 			mSimPhysicsFPS,
 			mSimAgentUPS,
-			mSimScriptEPS,
+			mSimScriptEPS;
 
-			mSimFrameMsec,
+	LLStat	mSimFrameMsec,
 			mSimNetMsec,
 			mSimSimOtherMsec,
-			mSimSimPhysicsMsec,
+			mSimSimPhysicsMsec;
 
-			mSimSimPhysicsStepMsec,
+	LLStat	mSimSimPhysicsStepMsec,
 			mSimSimPhysicsShapeUpdateMsec,
 			mSimSimPhysicsOtherMsec,
 			mSimSimAIStepMsec,
 			mSimSimSkippedSilhouetteSteps,
-			mSimSimPctSteppedCharacters,
+			mSimSimPctSteppedCharacters;
 
-			mSimAgentMsec,
+	LLStat	mSimAgentMsec,
 			mSimImagesMsec,
 			mSimScriptMsec,
 			mSimSpareMsec,
 			mSimSleepMsec,
-			mSimPumpIOMsec,
+			mSimPumpIOMsec;
 
-			mSimMainAgents,
+	LLStat	mSimMainAgents,
 			mSimChildAgents,
 			mSimObjects,
 			mSimActiveObjects,
 			mSimActiveScripts,
-			mSimPctScriptsRun,
+			mSimPctScriptsRun;
 
-			mSimInPPS,
+	LLStat	mSimInPPS,
 			mSimOutPPS,
 			mSimPendingDownloads,
 			mSimPendingUploads,
 			mSimPendingLocalUploads,
-			mSimTotalUnackedBytes,
+			mSimTotalUnackedBytes;
 
-			mPhysicsPinnedTasks,
+	LLStat	mPhysicsPinnedTasks,
 			mPhysicsLODTasks,
-			mPhysicsMemoryAllocated,
+			mPhysicsMemoryAllocated;
 
-			mSimPingStat,
+	LLStat	mSimPingStat;
 
-			mNumImagesStat,
+	LLStat	mNumImagesStat,
 			mNumRawImagesStat,
 			mGLTexMemStat,
 			mGLBoundMemStat,
 			mRawMemStat,
-			mFormattedMemStat,
+			mFormattedMemStat;
 
-			mNumObjectsStat,
+	LLStat	mNumObjectsStat,
 			mNumActiveObjectsStat,
 			mNumNewObjectsStat,
 			mNumSizeCulledStat,
@@ -182,7 +177,6 @@ public:
 	};
 
 	LLViewerStats();
-	~LLViewerStats();
 
 	// all return latest value of given stat
 	F64 getStat(EStatType type) const;
@@ -203,7 +197,7 @@ public:
 		U32 mCountOfNextUpdatesToIgnore;
 
 		inline StatsAccumulator()
-		{
+		{	
 			reset();
 		}
 
@@ -263,7 +257,7 @@ public:
 			mCountOfNextUpdatesToIgnore = 0;
 		}
 		
-		inline LLSD getData() const
+		inline LLSD asLLSD() const
 		{
 			LLSD data;
 			data["mean"] = getMean();
@@ -293,7 +287,7 @@ public:
 		void			stopPhase(const std::string& phase_name);
 		void			stopAllPhases();
 		void			clearPhases();
-		LLSD			dumpPhases();
+		LLSD			asLLSD();
 		static StatsAccumulator& getPhaseStats(const std::string& phase_name);
 		static void recordPhaseStat(const std::string& phase_name, F32 value);
 	};
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 80cca9963e..c0b196918d 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -67,12 +67,12 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
 U32 LLViewerTextureList::sTextureBits = 0;
 U32 LLViewerTextureList::sTexturePackets = 0;
 S32 LLViewerTextureList::sNumImages = 0;
-LLStat LLViewerTextureList::sNumImagesStat("Num Images", 32, TRUE);
-LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", 32, TRUE);
-LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", 32, TRUE);
-LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", 32, TRUE);
-LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", 32, TRUE);
-LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", 32, TRUE);
+LLStat LLViewerTextureList::sNumImagesStat("Num Images", TRUE);
+LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", TRUE);
+LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", TRUE);
+LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", TRUE);
+LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", TRUE);
+LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", TRUE);
 
 LLViewerTextureList gTextureList;
 static LLFastTimer::DeclareTimer FTM_PROCESS_IMAGES("Process Images");
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 6ef9bdd238..93573ed52e 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2140,8 +2140,8 @@ LLSD LLVOAvatarSelf::metricsData()
 	result["timers"]["ruth"] = mRuthTimer.getElapsedTimeF32();
 	result["timers"]["invisible"] = mInvisibleTimer.getElapsedTimeF32();
 	result["timers"]["fully_loaded"] = mFullyLoadedTimer.getElapsedTimeF32();
-	result["phases"] = getPhases().dumpPhases();
-	result["startup"] = LLStartUp::getPhases().dumpPhases();
+	result["phases"] = getPhases().asLLSD();
+	result["startup"] = LLStartUp::getPhases().asLLSD();
 	
 	return result;
 }
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 09d17b3701..43152c9025 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1157,7 +1157,7 @@ void send_agent_resume()
 	}
 
 	// Reset the FPS counter to avoid an invalid fps
-	LLViewerStats::getInstance()->mFPSStat.start();
+	LLViewerStats::getInstance()->mFPSStat.reset();
 
 	LLAppViewer::instance()->resumeMainloopTimeout();
 }
diff --git a/indra/newview/skins/default/xui/da/floater_lagmeter.xml b/indra/newview/skins/default/xui/da/floater_lagmeter.xml
deleted file mode 100644
index 149d174c34..0000000000
--- a/indra/newview/skins/default/xui/da/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="LAG METER">
-	<floater.string name="max_title_msg">
-		Lag måler
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Lag
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Klient
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normal, vindue i baggrund
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Klients billeder/sek under [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Klients billeder/sek mellem [CLIENT_FRAME_RATE_CRITICAL] og [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Mulig årsag: &apos;Vis afstand&apos; sat for højt i grafik indstillinger
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Mulig årsag: Billeder hentes
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Mulig årsag: For mange billeder i hukommelse
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Mulig årsag: For mange komplekse objekter i scenariet
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Netværk
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		Forbindelsen mister over [NETWORK_PACKET_LOSS_CRITICAL]% pakker
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		Forbindelsen mister [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% pakker
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Forbindelsens ping tider er over [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Forbindelsens ping tider er [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Muligvis dårlig forbindelse eller &apos;båndbredde&apos; sat for højt i netværksopsætning.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Muligvis dårlig forbindelse eller fil delings program.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Server
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Simulator framerate er under [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Simulator framerate er mellem [SERVER_FRAME_RATE_CRITICAL] og [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Mulig årsag: For mange fysiske objekter
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Mulig årsag: For mange objekter med script
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Mulig årsag: For meget netværks trafik
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Mulig årsag: For mange avatarer i bevægelse i regionen
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Mulig årsag: For mange billed udregninger
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Mulig årsag: Simulator belastning for stor
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button label="" label_selected="" name="client_lagmeter" tool_tip="Status for klient lag"/>
-	<text name="client">
-		Klient
-	</text>
-	<text name="client_text">
-		Normal
-	</text>
-	<button label="" label_selected="" name="network_lagmeter" tool_tip="Network lag status"/>
-	<text name="network">
-		Netværk
-	</text>
-	<text name="network_text">
-		Normal
-	</text>
-	<button label="" label_selected="" name="server_lagmeter" tool_tip="Status for server lag"/>
-	<text name="server">
-		Server
-	</text>
-	<text name="server_text">
-		Normal
-	</text>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Ændre størrelse"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/de/floater_lagmeter.xml b/indra/newview/skins/default/xui/de/floater_lagmeter.xml
deleted file mode 100644
index 45ff37c147..0000000000
--- a/indra/newview/skins/default/xui/de/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="LAG METER">
-	<floater.string name="max_title_msg">
-		Lag-Anzeige
-	</floater.string>
-	<floater.string name="max_width_px">
-		350
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Lag
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Client
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normal, Fenster im Hintergrund
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Client-Frame-Rate unter [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Client-Frame-Rate zwischen [CLIENT_FRAME_RATE_CRITICAL] und [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Mögliche Ursache: Sichtweite zu groß
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Mögliche Ursache: Bilder werden geladen
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Mögliche Ursache: Zu viele Bilder im Speicher
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Mögliche Ursache: Zu viele komplexe Objekte in der Szene
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Netzwerk
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		Paketverlust der Verbindung übersteigt [NETWORK_PACKET_LOSS_CRITICAL]%
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		Paketverlust der Verbindung liegt bei [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]%
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Ping-Zeit der Verbindung übersteigt [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Ping-Zeit der Verbindung liegt bei [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Möglicherweise schlechte Verbindung oder zu hoher Wert für „Bandbreite“.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Möglicherweise schlechte Verbindung oder File-Sharing-Anwendung.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Server
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Simulator-Frame-Rate liegt unter [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Simulator-Frame-Rate liegt zwischen [SERVER_FRAME_RATE_CRITICAL] und [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Mögliche Ursache: Zu viele physische Objekte
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Mögliche Ursache: Zu viele geskriptete Objekte
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Mögliche Ursache: Zu viel Netzwerktraffic
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Mögliche Ursache: Zu viele Personen in Bewegung in der Region
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Mögliche Ursache: Zu viele Bildberechnungen
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Mögliche Ursache: Zu hohe Simulator-Last
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button name="client_lagmeter" tool_tip="Client-Lag-Status"/>
-	<text name="client">
-		Client
-	</text>
-	<text name="client_text">
-		Normal
-	</text>
-	<button name="network_lagmeter" tool_tip="Netzwerk-Lag-Status"/>
-	<text name="network">
-		Netzwerk
-	</text>
-	<text name="network_text">
-		Normal
-	</text>
-	<button name="server_lagmeter" tool_tip="Server-Lag-Status"/>
-	<text name="server">
-		Server
-	</text>
-	<text name="server_text">
-		Normal
-	</text>
-	<button label="&gt;&gt; " name="minimize" tool_tip="Fenstergröße ändern"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/en/floater_lagmeter.xml b/indra/newview/skins/default/xui/en/floater_lagmeter.xml
deleted file mode 100644
index b24c745bdd..0000000000
--- a/indra/newview/skins/default/xui/en/floater_lagmeter.xml
+++ /dev/null
@@ -1,336 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<floater
- legacy_header_height="18"
- height="170"
- layout="topleft"
- name="floater_lagmeter"
- help_topic="floater_lagmeter"
- save_rect="true"
- title="LAG METER"
- width="350">
-    <floater.string
-     name="max_title_msg">
-        Lag Meter
-    </floater.string>
-    <floater.string
-     name="max_width_px">
-        360
-    </floater.string>
-    <floater.string
-     name="min_title_msg">
-        Lag
-    </floater.string>
-    <floater.string
-     name="min_width_px">
-        90
-    </floater.string>
-    <floater.string
-     name="client_text_msg">
-        Client
-    </floater.string>
-    <floater.string
-     name="client_frame_rate_critical_fps">
-        10
-    </floater.string>
-    <floater.string
-     name="client_frame_rate_warning_fps">
-        15
-    </floater.string>
-    <floater.string
-     name="client_frame_time_window_bg_msg">
-        Normal, window in background
-    </floater.string>
-    <floater.string
-     name="client_frame_time_critical_msg">
-        Client frame rate below [CLIENT_FRAME_RATE_CRITICAL]
-    </floater.string>
-    <floater.string
-     name="client_frame_time_warning_msg">
-        Client frame rate between [CLIENT_FRAME_RATE_CRITICAL] and [CLIENT_FRAME_RATE_WARNING]
-    </floater.string>
-    <floater.string
-     name="client_frame_time_normal_msg">
-        Normal
-    </floater.string>
-    <floater.string
-     name="client_draw_distance_cause_msg">
-        Possible cause: Draw distance set too high
-    </floater.string>
-    <floater.string
-     name="client_texture_loading_cause_msg">
-        Possible cause: Images loading
-    </floater.string>
-    <floater.string
-     name="client_texture_memory_cause_msg">
-        Possible cause: Too many images in memory
-    </floater.string>
-    <floater.string
-     name="client_complex_objects_cause_msg">
-        Possible cause: Too many complex objects in scene
-    </floater.string>
-    <floater.string
-     name="network_text_msg">
-        Network
-    </floater.string>
-    <floater.string
-     name="network_packet_loss_critical_pct">
-        10
-    </floater.string>
-    <floater.string
-     name="network_packet_loss_warning_pct">
-        5
-    </floater.string>
-    <floater.string
-     name="network_packet_loss_critical_msg">
-        Connection is dropping over [NETWORK_PACKET_LOSS_CRITICAL]% of packets
-    </floater.string>
-    <floater.string
-     name="network_packet_loss_warning_msg">
-        Connection is dropping [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% of packets
-    </floater.string>
-    <floater.string
-     name="network_performance_normal_msg">
-        Normal
-    </floater.string>
-    <floater.string
-     name="network_ping_critical_ms">
-        600
-    </floater.string>
-    <floater.string
-     name="network_ping_warning_ms">
-        300
-    </floater.string>
-    <floater.string
-     name="network_ping_critical_msg">
-        Connection ping time is over [NETWORK_PING_CRITICAL] ms
-    </floater.string>
-    <floater.string
-     name="network_ping_warning_msg">
-        Connection ping time is [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-    </floater.string>
-    <floater.string
-     name="network_packet_loss_cause_msg">
-        Possible bad connection or &apos;Bandwidth&apos; pref too high.
-    </floater.string>
-    <floater.string
-     name="network_ping_cause_msg">
-        Possible bad connection or file-sharing app.
-    </floater.string>
-    <floater.string
-     name="server_text_msg">
-        Server
-    </floater.string>
-    <floater.string
-     name="server_frame_rate_critical_fps">
-        20
-    </floater.string>
-    <floater.string
-     name="server_frame_rate_warning_fps">
-        30
-    </floater.string>
-    <floater.string
-     name="server_single_process_max_time_ms">
-        20
-    </floater.string>
-    <floater.string
-     name="server_frame_time_critical_msg">
-        Simulator framerate below [SERVER_FRAME_RATE_CRITICAL]
-    </floater.string>
-    <floater.string
-     name="server_frame_time_warning_msg">
-        Simulator framerate between [SERVER_FRAME_RATE_CRITICAL] and [SERVER_FRAME_RATE_WARNING]
-    </floater.string>
-    <floater.string
-     name="server_frame_time_normal_msg">
-        Normal
-    </floater.string>
-    <floater.string
-     name="server_physics_cause_msg">
-        Possible Cause: Too many physical objects
-    </floater.string>
-    <floater.string
-     name="server_scripts_cause_msg">
-        Possible Cause: Too many scripted objects
-    </floater.string>
-    <floater.string
-     name="server_net_cause_msg">
-        Possible Cause: Too much network traffic
-    </floater.string>
-    <floater.string
-     name="server_agent_cause_msg">
-        Possible Cause: Too many moving people in region
-    </floater.string>
-    <floater.string
-     name="server_images_cause_msg">
-        Possible Cause: Too many image calculations
-    </floater.string>
-    <floater.string
-     name="server_generic_cause_msg">
-        Possible Cause: Simulator load too heavy
-    </floater.string>
-    <floater.string
-     name="smaller_label">
-        &gt;&gt;
-    </floater.string>
-    <floater.string
-     name="bigger_label">
-        &lt;&lt;
-    </floater.string>
-    <button
-     follows="top|left"
-     height="16"
-     image_selected="lag_status_good.tga"
-     image_unselected="lag_status_good.tga"
-     layout="topleft"
-     left="8"
-     name="client_lagmeter"
-     tab_stop="false"
-     tool_tip="Client lag status"
-     top="24"
-     width="16" />
-    <text
-     type="string"
-     length="1"
-     follows="left|top"
-     font="SansSerif"
-     height="16"
-     layout="topleft"
-     left_pad="3"
-     name="client"
-     top_delta="0"
-     width="128">
-        Client
-    </text>
-    <text
-     invisiblity_control="LagMeterShrunk"
-     type="string"
-     length="1"
-     bottom="40"
-     follows="left|top"
-     font="SansSerif"
-     height="16"
-     layout="topleft"
-     left="110"
-     name="client_text"
-     right="-10">
-        Normal
-    </text>
-    <text
-     invisiblity_control="LagMeterShrunk"
-     bottom="56"
-     follows="left|top"
-     height="16"
-     layout="topleft"
-     left="40"
-     name="client_lag_cause"
-     right="-32" />
-    <button
-     follows="top|left"
-     height="16"
-     image_selected="lag_status_good.tga"
-     image_unselected="lag_status_good.tga"
-     layout="topleft"
-     left="8"
-     name="network_lagmeter"
-     tab_stop="false"
-     tool_tip="Network lag status"
-     top="64"
-     width="16" />
-    <text
-     type="string"
-     length="1"
-     follows="left|top"
-     font="SansSerif"
-     height="16"
-     layout="topleft"
-     left_pad="3"
-     name="network"
-     top_delta="0"
-     width="128">
-        Network
-    </text>
-    <text
-     invisiblity_control="LagMeterShrunk"
-     type="string"
-     length="1"
-     bottom="80"
-     follows="left|top"
-     font="SansSerif"
-     height="16"
-     layout="topleft"
-     left="110"
-     name="network_text"
-     right="-10">
-        Normal
-    </text>
-    <text
-     invisiblity_control="LagMeterShrunk"
-     bottom="96"
-     follows="left|top"
-     height="16"
-     layout="topleft"
-     left="40"
-     name="network_lag_cause"
-     right="-32" />
-    <button
-     follows="top|left"
-     height="16"
-     image_selected="lag_status_good.tga"
-     image_unselected="lag_status_good.tga"
-     layout="topleft"
-     left="8"
-     name="server_lagmeter"
-     tab_stop="false"
-     tool_tip="Server lag status"
-     top="104"
-     width="16" />
-    <text
-     type="string"
-     length="1"
-     follows="left|top"
-     font="SansSerif"
-     height="16"
-     layout="topleft"
-     left_pad="3"
-     name="server"
-     top_delta="0"
-     width="60">
-        Server
-    </text>
-    <text
-     invisiblity_control="LagMeterShrunk"
-     type="string"
-     length="1"
-     bottom="120"
-     follows="left|top"
-     font="SansSerif"
-     height="16"
-     layout="topleft"
-     left="110"
-     name="server_text"
-     right="-10">
-        Normal
-    </text>
-    <text
-     invisiblity_control="LagMeterShrunk"
-     bottom="136"
-     follows="left|top"
-     height="16"
-     layout="topleft"
-     left="40"
-     name="server_lag_cause"
-     right="-32" />
-    <button
-     follows="left|top"
-     height="20"
-     label="&gt;&gt;"
-     layout="topleft"
-     left="10"
-     name="minimize"
-	 tool_tip="Toggle floater size"
-     top_delta="24"
-     width="40">
-        <button.commit_callback
-         function="LagMeter.ClickShrink" />
-    </button>
-</floater>
diff --git a/indra/newview/skins/default/xui/es/floater_lagmeter.xml b/indra/newview/skins/default/xui/es/floater_lagmeter.xml
deleted file mode 100644
index 227689a194..0000000000
--- a/indra/newview/skins/default/xui/es/floater_lagmeter.xml
+++ /dev/null
@@ -1,154 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="MEDIDOR DEL LAG">
-	<floater.string name="max_title_msg">
-		Medidor del lag
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Lag
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Cliente
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normal, ventana en segundo plano
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Frames del cliente valorados por debajo de [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Frames del cliente valorados entre [CLIENT_FRAME_RATE_CRITICAL] y [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Posible causa: distancia de dibujo fijada muy alta
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Posible causa: imágenes cargándose
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Posible causa: demasiadas imágenes en la memoria
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Posible causa: demasiados objetos complejos en la escena
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Red
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		La conexión deja caer más del [NETWORK_PACKET_LOSS_CRITICAL]% de los paquetes
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		La conexión deja caer [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% de los paquetes
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		El tiempo de conexión -ping- supera los [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		El tiempo de conexión -ping- es de [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Quizá una mala conexión o un ancho de banda fijado demasiado alto.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Quizá una mala conexión o una aplicación de archivos compartidos.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Servidor
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Frecuencia (framerate) por debajo de [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Frecuencia (framerate) entre [SERVER_FRAME_RATE_CRITICAL] y [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Posible causa: demasiados objetos físicos
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Posible causa: demasiados objetos con script
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Posible causa: demasiado tráfico en la red
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Posible causa: demasiada gente moviéndose en la región
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Posible causa: demasiados cálculos de imáganes
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Posible causa: carga del simulador muy pesada
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button label="" label_selected="" name="client_lagmeter" tool_tip="Estado del lag del cliente"/>
-	<text name="client">
-		Cliente
-	</text>
-	<text font="SansSerifSmall" name="client_text">
-		Normal
-	</text>
-	<text left="30" name="client_lag_cause" right="-10"/>
-	<button label="" label_selected="" name="network_lagmeter" tool_tip="Estado del lag de la red"/>
-	<text name="network">
-		Red
-	</text>
-	<text font="SansSerifSmall" name="network_text">
-		Normal
-	</text>
-	<text left="30" name="network_lag_cause" right="-10"/>
-	<button label="" label_selected="" name="server_lagmeter" tool_tip="Estado del lag del servidor"/>
-	<text name="server">
-		Servidor
-	</text>
-	<text font="SansSerifSmall" name="server_text">
-		Normal
-	</text>
-	<text left="30" name="server_lag_cause" right="-32"/>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Cambia el tamaño de la ventana"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/fr/floater_lagmeter.xml b/indra/newview/skins/default/xui/fr/floater_lagmeter.xml
deleted file mode 100644
index 39a861d8bd..0000000000
--- a/indra/newview/skins/default/xui/fr/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="MESURE DU LAG">
-	<floater.string name="max_title_msg">
-		Mesure du lag
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Lag
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Client
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normal, fenêtre en arrière-plan
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Taux de défilement [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Taux de défilement entre [CLIENT_FRAME_RATE_CRITICAL] et [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Cause possible : limite d&apos;affichage trop élevée
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Cause possible : images en cours de chargement
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Cause possible : trop d&apos;images en mémoire
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Cause possible : trop d&apos;objets complexes
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Réseau
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		La connexion perd plus de [NETWORK_PACKET_LOSS_CRITICAL] % de paquets
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		La connexion perd entre [NETWORK_PACKET_LOSS_WARNING] % et [NETWORK_PACKET_LOSS_CRITICAL] % de paquets
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Connexion ping > [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Connexion ping entre [NETWORK_PING_WARNING] et [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Mauvaise connexion possible ou réglage de la bande passante trop élevé.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Mauvaise connexion possible ou app. de partage des fichiers
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Serveur
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Défilement du simulateur &lt; [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Défilement simulateur entre [SERVER_FRAME_RATE_CRITICAL] et [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Cause possible : trop d&apos;objets physiques
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Cause possible : trop d&apos;objets scriptés
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Cause possible : trop de trafic réseau
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Cause possible : trop de personnes en mouvement
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Cause possible : trop de calculs d&apos;images
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Cause possible : charge simulateur trop lourde
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button name="client_lagmeter" tool_tip="Statut du lag client"/>
-	<text name="client">
-		Client
-	</text>
-	<text name="client_text">
-		Normal
-	</text>
-	<button name="network_lagmeter" tool_tip="Statut du lag réseau"/>
-	<text name="network">
-		Réseau
-	</text>
-	<text name="network_text">
-		Normal
-	</text>
-	<button name="server_lagmeter" tool_tip="Statut du lag serveur"/>
-	<text name="server">
-		Serveur
-	</text>
-	<text name="server_text">
-		Normal
-	</text>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Activer/désactiver la taille du floater"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/it/floater_lagmeter.xml b/indra/newview/skins/default/xui/it/floater_lagmeter.xml
deleted file mode 100644
index f7b2b1ab4a..0000000000
--- a/indra/newview/skins/default/xui/it/floater_lagmeter.xml
+++ /dev/null
@@ -1,154 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="MISURATORE LAG">
-	<floater.string name="max_title_msg">
-		Misuratore del lag
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Lag
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Programma in locale
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normale, finestra sullo sfondo
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Velocità dei frame al di sotto di [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Velocità dei frame tra [CLIENT_FRAME_RATE_CRITICAL] e [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Normale
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Possibile causa: Campo visivo impostato troppo alto
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Possibile causa: Caricamento immagini
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Possibile causa: Troppe immagini in memoria
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Possibile causa: Troppi oggetti complessi intorno
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Network
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		La connessione sta calando al di sotto del [NETWORK_PACKET_LOSS_CRITICAL]% di pacchetti
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		La connessione sta calando tra il [NETWORK_PACKET_LOSS_WARNING]% e il [NETWORK_PACKET_LOSS_CRITICAL]% di pacchetti
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Normale
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Il tempo di ping della connessione è al di sopra di [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Il tempo di ping della connessione è tra [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Possibile cattiva connessione o la larghezza di banda impostata nelle preferenze troppo alta.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Possibile cattiva connessione o l&apos;apertura di un programma di scambio files.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Server
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Velocità dei frame al di sotto di [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Velocità dei frame tra [SERVER_FRAME_RATE_CRITICAL] e [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Normale
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Possibile causa: troppi oggetti fisici
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Possibile causa: troppi oggetti scriptati
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Possibile causa: eccessivo traffico sulla rete
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Possibile causa: troppi residenti in movimento nella regione
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Possibile causa: troppe elaborazioni di immagini
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Possibile causa: carico eccessivo del simulatore
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button label="" label_selected="" name="client_lagmeter" tool_tip="Stato del lag del programma in locale"/>
-	<text name="client">
-		Client
-	</text>
-	<text font="SansSerifSmall" left="145" name="client_text">
-		Normale
-	</text>
-	<text left="30" name="client_lag_cause" right="-10"/>
-	<button label="" label_selected="" name="network_lagmeter" tool_tip="Stato del lag del network"/>
-	<text name="network">
-		Rete
-	</text>
-	<text font="SansSerifSmall" name="network_text">
-		Normale
-	</text>
-	<text left="30" name="network_lag_cause" right="-10"/>
-	<button label="" label_selected="" name="server_lagmeter" tool_tip="Stato del lag del server"/>
-	<text name="server">
-		Server
-	</text>
-	<text font="SansSerifSmall" name="server_text">
-		Normale
-	</text>
-	<text left="30" name="server_lag_cause" right="-32"/>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Cambia dimensioni floater"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/ja/floater_lagmeter.xml b/indra/newview/skins/default/xui/ja/floater_lagmeter.xml
deleted file mode 100644
index e3546cd837..0000000000
--- a/indra/newview/skins/default/xui/ja/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="ラグメーター">
-	<floater.string name="max_title_msg">
-		ラグ メーター
-	</floater.string>
-	<floater.string name="max_width_px">
-		350
-	</floater.string>
-	<floater.string name="min_title_msg">
-		ラグ
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		クライアント
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		ノーマル、ウィンドウは背景に
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		クライアント フレームレート < [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		クライアント フレームレート: [CLIENT_FRAME_RATE_CRITICAL] ~ [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		ノーマル
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		考えられる原因: 描画距離の設定が大きすぎる
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		考えられる原因: 画像のロード中
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		考えられる原因: メモリ内の画像数が多すぎる
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		考えられる原因: 画面に含まれる複雑なオブジェクトが多すぎる
-	</floater.string>
-	<floater.string name="network_text_msg">
-		ネットワーク
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		接続でドロップされるパケットの割合: > [NETWORK_PACKET_LOSS_CRITICAL]
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		接続でドロップされるパケットの割合:[NETWORK_PACKET_LOSS_WARNING] ~ [NETWORK_PACKET_LOSS_CRITICAL]
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		ノーマル
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		接続の ping 時間: > [NETWORK_PING_CRITICAL] ミリ秒
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		接続の ping 時間: [NETWORK_PING_WARNING] ~ [NETWORK_PING_CRITICAL] ミリ秒
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		接続不良になっているか、帯域幅設定が高すぎます。
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		接続不良になっているか、ファイル共有アプリケーションに問題があります。
-	</floater.string>
-	<floater.string name="server_text_msg">
-		サーバー
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		シミュレーターのフレームレート: < [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		シミュレーターのフレームレート: [SERVER_FRAME_RATE_CRITICAL] ~ [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		ノーマル
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		考えられる原因: 物理的オブジェクトが多すぎる
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		考えられる原因: スクリプトを含むオブジェクトが多すぎる
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		考えられる原因: ネットワーク トラフィック過大
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		考えられる原因: 地域内にて動いているアバターが多すぎる
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		考えられる原因: 画像計算が多すぎる
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		考えられる原因: シミュレーターの過負荷
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button name="client_lagmeter" tool_tip="クライアント ラグ ステータス"/>
-	<text name="client">
-		クライアント
-	</text>
-	<text name="client_text">
-		ノーマル
-	</text>
-	<button name="network_lagmeter" tool_tip="ネットワーク ラグ ステータス"/>
-	<text name="network">
-		ネットワーク
-	</text>
-	<text name="network_text">
-		ノーマル
-	</text>
-	<button name="server_lagmeter" tool_tip="サーバー ラグ ステータス"/>
-	<text name="server">
-		サーバー
-	</text>
-	<text name="server_text">
-		ノーマル
-	</text>
-	<button label="&gt;&gt; " name="minimize" tool_tip="フローターのサイズをトグル"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/pl/floater_lagmeter.xml b/indra/newview/skins/default/xui/pl/floater_lagmeter.xml
deleted file mode 100644
index 8038550bcb..0000000000
--- a/indra/newview/skins/default/xui/pl/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="POMIAR LAGÓW">
-	<floater.string name="max_title_msg">
-		Pomiar lagów
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Lag
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Klient
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		W normie, okno w tle
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Ilość klatek na sekundę klienta poniżej [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Ilość klatek na sekundę pomiędzy [CLIENT_FRAME_RATE_CRITICAL] i [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		W normie
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Przyczyna: dystans rysowania jest za wysoki
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Przyczyna: ładowanie obrazu
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Przyczyna: za dużo obrazów w pamięci
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Przyczyna: za dużo złożonych obiektów
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Sieć
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		Utrata pakietów przekracza [NETWORK_PACKET_LOSS_CRITICAL]%
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		Utrata pakietów przekracza [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]%
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		W normie
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Fatalny ping - [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Wolny ping - [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Złe połączenie lub przepustowość.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Złe połączenie lub aplikacja współdzieląca pliki.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Serwer
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Ilość klatek na sekundę poniżej [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Ilość klatek na sekundę pomiędzy [SERVER_FRAME_RATE_CRITICAL] i [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		W normie
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Przyczyna: za dużo obiektów fizycznych
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Przyczyna: za dużo obieków skryptowanych
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Przyczyna: za duży ruch w sieci
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Przyczyna: za dużo poruszających się awatarów w regionie
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Przyczyna: za dużo kalkulacji obrazu
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Przyczyna: symulator ładuje się zbyt powoli
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button label="" label_selected="" name="client_lagmeter" tool_tip="Status lagów klienta"/>
-	<text name="client">
-		Klient
-	</text>
-	<text name="client_text">
-		W normie
-	</text>
-	<button label="" label_selected="" name="network_lagmeter" tool_tip="Network lag status"/>
-	<text name="network">
-		Sieć
-	</text>
-	<text name="network_text">
-		W normie
-	</text>
-	<button label="" label_selected="" name="server_lagmeter" tool_tip="Server lag status"/>
-	<text name="server">
-		Serwer
-	</text>
-	<text name="server_text">
-		W normie
-	</text>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Złącz rozmiar pliku xml"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/pt/floater_lagmeter.xml b/indra/newview/skins/default/xui/pt/floater_lagmeter.xml
deleted file mode 100644
index 9932318293..0000000000
--- a/indra/newview/skins/default/xui/pt/floater_lagmeter.xml
+++ /dev/null
@@ -1,154 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="LAG - Índice">
-	<floater.string name="max_title_msg">
-		Medidor de Atraso
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Atraso
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Cliente
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normal, janela por baixo
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Taxa de quadros do Cliente abaixo de [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Taxa de quadros do Cliente entre [CLIENT_FRAME_RATE_CRITICAL] e [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Causa possível: Distância de desenho ajustada muito alta
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Causa possível: Carregamento de Imagens
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Causa possível: Muitas imagens na memória
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Causa possível: Muitos objetos complexos na cena
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Rede
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		Conexão está caindo para cerca de [NETWORK_PACKET_LOSS_CRITICAL]% de pacotes
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		Conexão está caindo [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% de pacotes
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Tempo de conexão de ping é cerca de  [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Tempo de conexão de ping é [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Possível conexão ruim ou &apos;Largura de Banda&apos; escolhida muito alta.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Possível conexão ruim ou aplicativos compartilhando arquivos.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Servidor
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Taxa de quadros abaixo de [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Taxa de quadros entre [SERVER_FRAME_RATE_CRITICAL] e [SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Causa possível: Muitos objetos físicos
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Causa possível: Muitos objetos com scripts
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Causa possível: Muito tráfego na rede
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Causa possível: Muitas pessoas se movendo na região
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Causa possível: Muitos cálculos de imagem
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Causa possível: Carga no simulador muito pesada
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button label="" label_selected="" name="client_lagmeter" tool_tip="Status de atraso no Cliente"/>
-	<text name="client">
-		Cliente
-	</text>
-	<text font="SansSerifSmall" name="client_text">
-		Normal
-	</text>
-	<text left="30" name="client_lag_cause" right="-10"/>
-	<button label="" label_selected="" name="network_lagmeter" tool_tip="Status de atraso na rede"/>
-	<text name="network">
-		Rede
-	</text>
-	<text font="SansSerifSmall" name="network_text">
-		Normal
-	</text>
-	<text left="30" name="network_lag_cause" right="-10"/>
-	<button label="" label_selected="" name="server_lagmeter" tool_tip="Status de atraso no servidor"/>
-	<text name="server">
-		Servidor
-	</text>
-	<text font="SansSerifSmall" name="server_text">
-		Normal
-	</text>
-	<text left="30" name="server_lag_cause" right="-32"/>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Alternar o tamanho da janela"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/ru/floater_lagmeter.xml b/indra/newview/skins/default/xui/ru/floater_lagmeter.xml
deleted file mode 100644
index c420006a03..0000000000
--- a/indra/newview/skins/default/xui/ru/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="УРОВЕНЬ ЛАГОВ">
-	<floater.string name="max_title_msg">
-		Уровень лагов
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Лаг
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		Клиент
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Нормально, окно в фоне
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Частота кадров клиента ниже [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Частота кадров клиента от [CLIENT_FRAME_RATE_CRITICAL] до [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Нормально
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Возможная причина: дальность отрисовки слишком велика
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Возможная причина: загрузка изображений
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Возможная причина: слишком много изображений в памяти
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Возможная причина: слишком много сложных объектов в сцене
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Сеть
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		Сеть теряет более [NETWORK_PACKET_LOSS_CRITICAL]% пакетов
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		Сеть теряет [NETWORK_PACKET_LOSS_WARNING]–[NETWORK_PACKET_LOSS_CRITICAL]% пакетов
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Нормально
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Пинг соединения более [NETWORK_PING_CRITICAL] мс
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Пинг соединения [NETWORK_PING_WARNING]–[NETWORK_PING_CRITICAL] мс
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Возможно, плохое соединение, или параметр «Ширина канала» слишком велик.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Возможно, плохое соединение или есть работающие файлообменные программы.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Сервер
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Частота кадров сервера ниже [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Частота кадров сервера [SERVER_FRAME_RATE_CRITICAL]–[SERVER_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Нормально
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Возможная причина: слишком много физических объектов
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Возможная причина: слишком много скриптовых объектов
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Возможная причина: слишком большой сетевой трафик
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Возможная причина: слишком много людей в регионе
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Возможная причина: слишком много изображений
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Возможная причина: сервер сильно загружен
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button name="client_lagmeter" tool_tip="Уровень лагов клиента"/>
-	<text name="client">
-		Клиент
-	</text>
-	<text name="client_text">
-		Нормально
-	</text>
-	<button name="network_lagmeter" tool_tip="Уровень лагов сети"/>
-	<text name="network">
-		Сеть
-	</text>
-	<text name="network_text">
-		Нормально
-	</text>
-	<button name="server_lagmeter" tool_tip="Уровень лагов сервера"/>
-	<text name="server">
-		Сервер
-	</text>
-	<text name="server_text">
-		Нормально
-	</text>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Переключение размера"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/tr/floater_lagmeter.xml b/indra/newview/skins/default/xui/tr/floater_lagmeter.xml
deleted file mode 100644
index 736c50be90..0000000000
--- a/indra/newview/skins/default/xui/tr/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="GECİKME ÖLÇER">
-	<floater.string name="max_title_msg">
-		Gecikme Ölçer
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Gecikme
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		İstemci
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normal, pencere alt zeminde
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		İstemci kare hızı [CLIENT_FRAME_RATE_CRITICAL] altında
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		İstemci kare hızı [CLIENT_FRAME_RATE_CRITICAL] ile [CLIENT_FRAME_RATE_WARNING] arasınad
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Muhtemel neden: Çizme mesafesi çok yüksek
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Muhtemel neden: Görüntüler yükleniyor
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Muhtemel neden: Bellekte çok fazla görüntü
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Muhtemel neden: Sahnede çok fazla karmaşık nesne
-	</floater.string>
-	<floater.string name="network_text_msg">
-		Ağ
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		Bağlantı paketlerin % [NETWORK_PACKET_LOSS_CRITICAL]&apos;sinden fazlasını bırakıyor
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		Bağlantı paketlerin % [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]&apos;sini bırakıyor
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Bağlantı ping süresi [NETWORK_PING_CRITICAL] ms.den fazla
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Bağlantı ping süresi [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Muhtemel yetersiz bağlantı veya &apos;Bant Genişliği&apos; tercihi çok yüksek.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Muhtemel yetersiz bağlantı veya dosya paylaşım uygulaması.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		Sunucu
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		Simülatör kare hızı [SERVER_FRAME_RATE_CRITICAL] altında
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		Simülatör kare hızı [SERVER_FRAME_RATE_CRITICAL] ve [SERVER_FRAME_RATE_WARNING] arasında
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		Normal
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		Muhtemel Neden: Çok fazla fiziki nesne
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		Muhtemel Neden: Çok fazla komut dosyalı nesne
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		Muhtemel Neden: Çok fazla ağ trafiği
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		Muhtemel Neden: Bölgede hareket eden çok fazla insan var
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		Muhtemel Neden: Çok fazla görüntü hesabı
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		Muhtemel Neden: Simülatör yükü çok ağır
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button name="client_lagmeter" tool_tip="İstemci gecikme durumu"/>
-	<text name="client">
-		İstemci
-	</text>
-	<text name="client_text">
-		Normal
-	</text>
-	<button name="network_lagmeter" tool_tip="Ağ gecikme durumu"/>
-	<text name="network">
-		Ağ
-	</text>
-	<text name="network_text">
-		Normal
-	</text>
-	<button name="server_lagmeter" tool_tip="Sunucu gecikme durumu"/>
-	<text name="server">
-		Sunucu
-	</text>
-	<text name="server_text">
-		Normal
-	</text>
-	<button label="&gt;&gt;" name="minimize" tool_tip="Gezdirici büyüklüğünü değiştir"/>
-</floater>
diff --git a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml b/indra/newview/skins/default/xui/zh/floater_lagmeter.xml
deleted file mode 100644
index 6e58e7332f..0000000000
--- a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="LAG 測量器">
-	<floater.string name="max_title_msg">
-		Lag 測量器
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		Lag
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		客戶端
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		Normal, window in background
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		Client frame rate below [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		Client frame rate between [CLIENT_FRAME_RATE_CRITICAL] and [CLIENT_FRAME_RATE_WARNING]
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		正常
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		Possible cause: Draw distance set too high
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		Possible cause: Images loading
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		Possible cause: Too many images in memory
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		Possible cause: Too many complex objects in scene
-	</floater.string>
-	<floater.string name="network_text_msg">
-		網路
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		Connection is dropping over [NETWORK_PACKET_LOSS_CRITICAL]% of packets
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		Connection is dropping [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% of packets
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		正常
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		Connection ping time is over [NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		Connection ping time is [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] ms
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		Possible bad connection or &apos;Bandwidth&apos; pref too high.
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		Possible bad connection or file-sharing app.
-	</floater.string>
-	<floater.string name="server_text_msg">
-		伺服器
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		模擬器 framerate 低於 [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		模擬器 framerate 介於 [SERVER_FRAME_RATE_CRITICAL] 與 [SERVER_FRAME_RATE_WARNING] 之間
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		正常
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		可能原因:太多物理物件
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		可能原因:太多腳本物件
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		可能原因:太多網路流量
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		可能原因:地區有太多移動的人
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		可能原因:太多圖像計算
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		可能原因:模擬器負載過重
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button name="client_lagmeter" tool_tip="客戶端 lag 狀態"/>
-	<text name="client">
-		客戶端
-	</text>
-	<text name="client_text">
-		正常
-	</text>
-	<button name="network_lagmeter" tool_tip="網路 lag 狀態"/>
-	<text name="network">
-		網路
-	</text>
-	<text name="network_text">
-		正常
-	</text>
-	<button name="server_lagmeter" tool_tip="伺服器 lag 狀態"/>
-	<text name="server">
-		伺服器
-	</text>
-	<text name="server_text">
-		正常
-	</text>
-	<button label="&gt;&gt;" name="minimize" tool_tip="切換浮動視窗尺寸"/>
-</floater>
-- 
cgit v1.2.3


From 3254f9fb5f44426494208927c464d2f1447f812a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 6 Sep 2012 11:52:11 -0700
Subject: removed unused file

---
 .../skins/default/xui/zh/floater_lagmeter.xml      | 151 ---------------------
 1 file changed, 151 deletions(-)
 delete mode 100644 indra/newview/skins/default/xui/zh/floater_lagmeter.xml

(limited to 'indra/newview')

diff --git a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml b/indra/newview/skins/default/xui/zh/floater_lagmeter.xml
deleted file mode 100644
index e9a082288a..0000000000
--- a/indra/newview/skins/default/xui/zh/floater_lagmeter.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<floater name="floater_lagmeter" title="LAG 測量器">
-	<floater.string name="max_title_msg">
-		Lag 測量器
-	</floater.string>
-	<floater.string name="max_width_px">
-		360
-	</floater.string>
-	<floater.string name="min_title_msg">
-		延遲
-	</floater.string>
-	<floater.string name="min_width_px">
-		90
-	</floater.string>
-	<floater.string name="client_text_msg">
-		客戶端
-	</floater.string>
-	<floater.string name="client_frame_rate_critical_fps">
-		10
-	</floater.string>
-	<floater.string name="client_frame_rate_warning_fps">
-		15
-	</floater.string>
-	<floater.string name="client_frame_time_window_bg_msg">
-		正常,視窗位於背景
-	</floater.string>
-	<floater.string name="client_frame_time_critical_msg">
-		客戶端幀率低於 [CLIENT_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="client_frame_time_warning_msg">
-		客戶端幀率介於 [CLIENT_FRAME_RATE_CRITICAL] 和 [CLIENT_FRAME_RATE_WARNING] 之間
-	</floater.string>
-	<floater.string name="client_frame_time_normal_msg">
-		正常
-	</floater.string>
-	<floater.string name="client_draw_distance_cause_msg">
-		可能原因:可視距離設得太遠
-	</floater.string>
-	<floater.string name="client_texture_loading_cause_msg">
-		可能原因:正在載入圖像
-	</floater.string>
-	<floater.string name="client_texture_memory_cause_msg">
-		可能原因:記憶體裡圖像太多
-	</floater.string>
-	<floater.string name="client_complex_objects_cause_msg">
-		可能原因:場景內複雜物件太多
-	</floater.string>
-	<floater.string name="network_text_msg">
-		網路
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_pct">
-		10
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_pct">
-		5
-	</floater.string>
-	<floater.string name="network_packet_loss_critical_msg">
-		這次連通丟失了至少 [NETWORK_PACKET_LOSS_CRITICAL]% 的封包
-	</floater.string>
-	<floater.string name="network_packet_loss_warning_msg">
-		這次連通丟失了 [NETWORK_PACKET_LOSS_WARNING]%-[NETWORK_PACKET_LOSS_CRITICAL]% 的封包
-	</floater.string>
-	<floater.string name="network_performance_normal_msg">
-		正常
-	</floater.string>
-	<floater.string name="network_ping_critical_ms">
-		600
-	</floater.string>
-	<floater.string name="network_ping_warning_ms">
-		300
-	</floater.string>
-	<floater.string name="network_ping_critical_msg">
-		探測連通回應時間超過 [NETWORK_PING_CRITICAL] 毫秒
-	</floater.string>
-	<floater.string name="network_ping_warning_msg">
-		探測連通回應時間為 [NETWORK_PING_WARNING]-[NETWORK_PING_CRITICAL] 毫秒
-	</floater.string>
-	<floater.string name="network_packet_loss_cause_msg">
-		可能連通不良,或所設的偏好連通頻寬過高。
-	</floater.string>
-	<floater.string name="network_ping_cause_msg">
-		可能連通不良,或使用檔案分享應用程式。
-	</floater.string>
-	<floater.string name="server_text_msg">
-		伺服器
-	</floater.string>
-	<floater.string name="server_frame_rate_critical_fps">
-		20
-	</floater.string>
-	<floater.string name="server_frame_rate_warning_fps">
-		30
-	</floater.string>
-	<floater.string name="server_single_process_max_time_ms">
-		20
-	</floater.string>
-	<floater.string name="server_frame_time_critical_msg">
-		模擬器 framerate 低於 [SERVER_FRAME_RATE_CRITICAL]
-	</floater.string>
-	<floater.string name="server_frame_time_warning_msg">
-		模擬器 framerate 介於 [SERVER_FRAME_RATE_CRITICAL] 與 [SERVER_FRAME_RATE_WARNING] 之間
-	</floater.string>
-	<floater.string name="server_frame_time_normal_msg">
-		正常
-	</floater.string>
-	<floater.string name="server_physics_cause_msg">
-		可能原因:太多物理物件
-	</floater.string>
-	<floater.string name="server_scripts_cause_msg">
-		可能原因:太多腳本物件
-	</floater.string>
-	<floater.string name="server_net_cause_msg">
-		可能原因:太多網路流量
-	</floater.string>
-	<floater.string name="server_agent_cause_msg">
-		可能原因:地區有太多移動的人
-	</floater.string>
-	<floater.string name="server_images_cause_msg">
-		可能原因:太多圖像計算
-	</floater.string>
-	<floater.string name="server_generic_cause_msg">
-		可能原因:模擬器負載過重
-	</floater.string>
-	<floater.string name="smaller_label">
-		&gt;&gt;
-	</floater.string>
-	<floater.string name="bigger_label">
-		&lt;&lt;
-	</floater.string>
-	<button name="client_lagmeter" tool_tip="客戶端 lag 狀態"/>
-	<text name="client">
-		客戶端
-	</text>
-	<text name="client_text">
-		正常
-	</text>
-	<button name="network_lagmeter" tool_tip="網路 lag 狀態"/>
-	<text name="network">
-		網路
-	</text>
-	<text name="network_text">
-		正常
-	</text>
-	<button name="server_lagmeter" tool_tip="伺服器 lag 狀態"/>
-	<text name="server">
-		伺服器
-	</text>
-	<text name="server_text">
-		正常
-	</text>
-	<button label="&gt;&gt;" name="minimize" tool_tip="切換浮動視窗尺寸"/>
-</floater>
-- 
cgit v1.2.3


From 456a9a44d8bb039c21a9c125686778972077121d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 6 Sep 2012 14:11:42 -0700
Subject: fixed build

---
 indra/newview/lltexturefetch.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 216a022774..e7538d685d 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -3427,18 +3427,20 @@ void LLTextureFetchDebugger::tryToStopDebug()
 	}
 
 	if(update(0.005f))
-		{
-	//unlock the fetcher
-	mFetcher->lockFetcher(false);
+	{
+		//unlock the fetcher
+		mFetcher->lockFetcher(false);
 		mFetcher->resetLoadSource();
-	mFreezeHistory = FALSE;
+		mFreezeHistory = FALSE;
 		mStopDebug = FALSE;
 
 		if(mClearHistory)
 		{
 			mFetchingHistory.clear();
 			init();	
-	mTotalFetchingTime = gTextureTimer.getElapsedTimeF32(); //reset
+			mTotalFetchingTime = gTextureTimer.getElapsedTimeF32(); //reset
+		}
+	}
 }
 
 //called in the main thread and when the fetching queue is empty
-- 
cgit v1.2.3


From 0027ee8a7ddc47da656fb542ea4a97c00ca2683b Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 6 Sep 2012 14:38:23 -0700
Subject: another build fix

---
 indra/newview/llvoavatarself.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index ed84e8103d..fd892db3d3 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2138,7 +2138,7 @@ LLSD LLVOAvatarSelf::metricsData()
 	result["timers"]["ruth"] = mRuthTimer.getElapsedTimeF32();
 	result["timers"]["invisible"] = mInvisibleTimer.getElapsedTimeF32();
 	result["timers"]["fully_loaded"] = mFullyLoadedTimer.getElapsedTimeF32();
-	result["startup"] = LLStartUp::getPhases().dumpPhases();
+	result["startup"] = LLStartUp::getPhases().asLLSD();
 	
 	return result;
 }
-- 
cgit v1.2.3


From 07c4be092b276f0d7c14ba12872efb31c1f16764 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 26 Sep 2012 19:12:40 -0700
Subject: SH-3275 WIP Run viewer metrics for object update messages slave
 threads now pushing data to master thread

---
 indra/newview/llappviewer.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c3ac615169..fcbef491fe 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1222,6 +1222,7 @@ bool LLAppViewer::mainLoop()
 	{
 		LLFastTimer _(FTM_FRAME);
 		LLFastTimer::nextFrame(); 
+		LLTrace::getMasterThreadTrace().pullFromSlaveThreads();
 
 		//clear call stack records
 		llclearcallstacks;
-- 
cgit v1.2.3


From 38354e19063478c8cda0408547ad05023b457041 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 28 Sep 2012 10:45:14 -0700
Subject: SH-3275 WIP Run viewer metrics for object update messages created
 separate constructor for static allocation of sampler buffer fixed
 start/stop/resume semantics of samplers and added sampler time interval
 tracking

---
 indra/newview/llappviewer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index fcbef491fe..0bb87dfa6c 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -60,7 +60,7 @@
 #include "llcurl.h"
 #include "llcalc.h"
 #include "lltexturestats.h"
-#include "lltexturestats.h"
+#include "lltrace.h"
 #include "llviewerwindow.h"
 #include "llviewerdisplay.h"
 #include "llviewermedia.h"
-- 
cgit v1.2.3


From b1baf982b1bd41a150233d0a28d3601226924c65 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sun, 30 Sep 2012 10:41:29 -0700
Subject: SH-3275 WIP Run viewer metrics for object update messages factored
 out lltrace::sampler into separate file added rudimentary lltrace support to
 llstatgraph made llstatgraph use param blocks more effectively moves initial
 set of stats over to lltrace removed windows.h #defines for min and max

---
 indra/newview/llstatusbar.cpp         | 33 ++++++++++++++++--------------
 indra/newview/llviewerstats.cpp       | 38 +++++++++++++++++++++--------------
 indra/newview/llviewerstats.h         | 20 ++++++++++++------
 indra/newview/llviewertexturelist.cpp |  4 +++-
 indra/newview/llworld.cpp             |  3 ++-
 5 files changed, 60 insertions(+), 38 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 4892de9da0..9f499ef4ef 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -198,10 +198,10 @@ BOOL LLStatusBar::postBuild()
 	sgp.rect(r);
 	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	sgp.mouse_opaque(false);
+	sgp.stat.f32_stat(&STAT_KBIT);
+	sgp.units("Kbps");
+	sgp.precision(0);
 	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
-	mSGBandwidth->setStat(&LLViewerStats::getInstance()->mKBitStat);
-	mSGBandwidth->setUnits("Kbps");
-	mSGBandwidth->setPrecision(0);
 	addChild(mSGBandwidth);
 	x -= SIM_STAT_WIDTH + 2;
 
@@ -212,17 +212,20 @@ BOOL LLStatusBar::postBuild()
 	pgp.rect(r);
 	pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	pgp.mouse_opaque(false);
+	pgp.stat.legacy_stat(&LLViewerStats::getInstance()->mPacketsLostPercentStat);
+	pgp.units("%");
+	pgp.min(0.f);
+	pgp.max(5.f);
+	pgp.precision(1);
+	pgp.per_sec(false);
+	LLStatGraph::Thresholds thresholds;
+	thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green))
+						.add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow))
+						.add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red));
+
+	pgp.thresholds(thresholds);
 
 	mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
-	mSGPacketLoss->setStat(&LLViewerStats::getInstance()->mPacketsLostPercentStat);
-	mSGPacketLoss->setUnits("%");
-	mSGPacketLoss->setMin(0.f);
-	mSGPacketLoss->setMax(5.f);
-	mSGPacketLoss->setThreshold(0, 0.5f);
-	mSGPacketLoss->setThreshold(1, 1.f);
-	mSGPacketLoss->setThreshold(2, 3.f);
-	mSGPacketLoss->setPrecision(1);
-	mSGPacketLoss->mPerSec = FALSE;
 	addChild(mSGPacketLoss);
 
 	mPanelVolumePulldown = new LLPanelVolumePulldown();
@@ -252,9 +255,9 @@ void LLStatusBar::refresh()
 		F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
 		mSGBandwidth->setMin(0.f);
 		mSGBandwidth->setMax(bwtotal*1.25f);
-		mSGBandwidth->setThreshold(0, bwtotal*0.75f);
-		mSGBandwidth->setThreshold(1, bwtotal);
-		mSGBandwidth->setThreshold(2, bwtotal);
+		//mSGBandwidth->setThreshold(0, bwtotal*0.75f);
+		//mSGBandwidth->setThreshold(1, bwtotal);
+		//mSGBandwidth->setThreshold(2, bwtotal);
 	}
 	
 	// update clock every 10 seconds
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index da87cc2673..b1aeaef91d 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -62,6 +62,13 @@
 #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived
 
 
+LLTrace::Stat<F32>	STAT_KBIT("kbitstat"),
+					STAT_LAYERS_KBIT("layerskbitstat"),
+					STAT_OBJECT_KBIT("objectkbitstat"),
+					STAT_ASSET_KBIT("assetkbitstat"),
+					STAT_TEXTURE_KBIT("texturekbitstat");
+
+
 class StatAttributes
 {
 public:
@@ -198,11 +205,6 @@ const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] =
 };
 
 LLViewerStats::LLViewerStats() :
-	mKBitStat("kbitstat"),
-	mLayersKBitStat("layerskbitstat"),
-	mObjectKBitStat("objectkbitstat"),
-	mAssetKBitStat("assetkbitstat"),
-	mTextureKBitStat("texturekbitstat"),
 	mVFSPendingOperations("vfspendingoperations"),
 	mFPSStat("fpsstat"),
 	mPacketsInStat("packetsinstat"),
@@ -261,7 +263,8 @@ LLViewerStats::LLViewerStats() :
 	mNumNewObjectsStat("numnewobjectsstat"),
 	mNumSizeCulledStat("numsizeculledstat"),
 	mNumVisCulledStat("numvisculledstat"),
-	mLastTimeDiff(0.0)
+	mLastTimeDiff(0.0),
+	mSampler(LLThread::getTraceData()->createSampler())
 {
 	for (S32 i = 0; i < ST_COUNT; i++)
 	{
@@ -274,17 +277,18 @@ LLViewerStats::LLViewerStats() :
 	}	
 	
 	mAgentPositionSnaps.reset();
+	mSampler->start();
+}
+
+LLViewerStats::~LLViewerStats()
+{
+	delete mSampler;
 }
 
 void LLViewerStats::resetStats()
 {
 	LLViewerStats& stats = LLViewerStats::instance();
-	stats.mKBitStat.reset();
-	stats.mLayersKBitStat.reset();
-	stats.mObjectKBitStat.reset();
-	stats.mTextureKBitStat.reset();
 	stats.mVFSPendingOperations.reset();
-	stats.mAssetKBitStat.reset();
 	stats.mPacketsInStat.reset();
 	stats.mPacketsLostStat.reset();
 	stats.mPacketsOutStat.reset();
@@ -463,10 +467,13 @@ void update_statistics()
 
 	stats.mFPSStat.addValue(1);
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	stats.mLayersKBitStat.addValue(layer_bits/1024.f);
-	stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
+	STAT_LAYERS_KBIT.sample(layer_bits/1024.f);
+	//stats.mLayersKBitStat.addValue(layer_bits/1024.f);
+	STAT_OBJECT_KBIT.sample(gObjectBits/1024.f);
+	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
 	stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
-	stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
+	STAT_ASSET_KBIT.sample(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
+	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
 	if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
@@ -503,7 +510,8 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f);
+			STAT_TEXTURE_KBIT.sample(LLViewerTextureList::sTextureBits/1024.f);
+			//stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f);
 			stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets);
 			gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8;
 			LLViewerTextureList::sTextureBits = 0;
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 0d8f2a45c0..ca70660ce9 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -29,16 +29,18 @@
 
 #include "llstat.h"
 #include "lltextureinfo.h"
+#include "lltracesampler.h"
+
+extern LLTrace::Stat<F32>	STAT_KBIT,
+							STAT_LAYERS_KBIT,
+							STAT_OBJECT_KBIT,
+							STAT_ASSET_KBIT,
+							STAT_TEXTURE_KBIT;
 
 class LLViewerStats : public LLSingleton<LLViewerStats>
 {
 public:
-	LLStat	mKBitStat,
-			mLayersKBitStat,
-			mObjectKBitStat,
-			mAssetKBitStat,
-			mTextureKBitStat,
-			mVFSPendingOperations,
+	LLStat	mVFSPendingOperations,
 			mFPSStat,
 			mPacketsInStat,
 			mPacketsLostStat,
@@ -110,7 +112,9 @@ public:
 			mNumVisCulledStat;
 
 	void resetStats();
+
 public:
+
 	// If you change this, please also add a corresponding text label in llviewerstats.cpp
 	enum EStatType
 	{
@@ -177,6 +181,7 @@ public:
 	};
 
 	LLViewerStats();
+	~LLViewerStats();
 
 	// all return latest value of given stat
 	F64 getStat(EStatType type) const;
@@ -292,8 +297,11 @@ public:
 		static void recordPhaseStat(const std::string& phase_name, F32 value);
 	};
 
+	LLTrace::Sampler* getSampler() { return mSampler; }
+
 private:
 	F64	mStats[ST_COUNT];
+	LLTrace::Sampler*	mSampler;
 
 	F64 mLastTimeDiff;  // used for time stat updates
 };
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 17d8e5e4fa..034f8edf24 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -622,7 +622,9 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 	cleared = FALSE;
 
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(LLViewerStats::getInstance()->mTextureKBitStat.getMeanPerSec());
+	LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler();
+
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(sampler->getMean(STAT_TEXTURE_KBIT) / sampler->getSampleTime());
 
 	LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
 	LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 43152c9025..97079e0588 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -704,7 +704,8 @@ void LLWorld::updateNetStats()
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 	LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
 	LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
-	LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
+	STAT_KBIT.sample(bits/1024.f);
+	//LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
 	LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in);
 	LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out);
 	LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets);
-- 
cgit v1.2.3


From 14b1b0b2bb6bac5bc688cc4d14c33f1b680dd3b4 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 1 Oct 2012 19:39:04 -0700
Subject: SH-3275 WIP Run viewer metrics for object update messages cleaned up
 API samplers are now value types with copy-on-write buffers under the hood
 removed coupling with LLThread

---
 indra/newview/llstatusbar.cpp         |  2 +-
 indra/newview/llviewerstats.cpp       | 13 ++++++-------
 indra/newview/llviewerstats.h         |  2 +-
 indra/newview/llviewertexturelist.cpp |  2 +-
 indra/newview/llworld.cpp             |  2 +-
 5 files changed, 10 insertions(+), 11 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 9f499ef4ef..ab97d6465a 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild()
 	sgp.rect(r);
 	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	sgp.mouse_opaque(false);
-	sgp.stat.f32_stat(&STAT_KBIT);
+	sgp.stat.rate_stat(&STAT_KBIT);
 	sgp.units("Kbps");
 	sgp.precision(0);
 	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index b1aeaef91d..e2b09a1902 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -62,7 +62,7 @@
 #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived
 
 
-LLTrace::Stat<F32>	STAT_KBIT("kbitstat"),
+LLTrace::Rate<F32>	STAT_KBIT("kbitstat"),
 					STAT_LAYERS_KBIT("layerskbitstat"),
 					STAT_OBJECT_KBIT("objectkbitstat"),
 					STAT_ASSET_KBIT("assetkbitstat"),
@@ -263,8 +263,7 @@ LLViewerStats::LLViewerStats() :
 	mNumNewObjectsStat("numnewobjectsstat"),
 	mNumSizeCulledStat("numsizeculledstat"),
 	mNumVisCulledStat("numvisculledstat"),
-	mLastTimeDiff(0.0),
-	mSampler(LLThread::getTraceData()->createSampler())
+	mLastTimeDiff(0.0)
 {
 	for (S32 i = 0; i < ST_COUNT; i++)
 	{
@@ -467,12 +466,12 @@ void update_statistics()
 
 	stats.mFPSStat.addValue(1);
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	STAT_LAYERS_KBIT.sample(layer_bits/1024.f);
+	STAT_LAYERS_KBIT.add(layer_bits/1024.f);
 	//stats.mLayersKBitStat.addValue(layer_bits/1024.f);
-	STAT_OBJECT_KBIT.sample(gObjectBits/1024.f);
+	STAT_OBJECT_KBIT.add(gObjectBits/1024.f);
 	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
 	stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
-	STAT_ASSET_KBIT.sample(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
+	STAT_ASSET_KBIT.add(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
@@ -510,7 +509,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			STAT_TEXTURE_KBIT.sample(LLViewerTextureList::sTextureBits/1024.f);
+			STAT_TEXTURE_KBIT.add(LLViewerTextureList::sTextureBits/1024.f);
 			//stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f);
 			stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets);
 			gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8;
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index ca70660ce9..9e809dd08c 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -31,7 +31,7 @@
 #include "lltextureinfo.h"
 #include "lltracesampler.h"
 
-extern LLTrace::Stat<F32>	STAT_KBIT,
+extern LLTrace::Rate<F32>	STAT_KBIT,
 							STAT_LAYERS_KBIT,
 							STAT_OBJECT_KBIT,
 							STAT_ASSET_KBIT,
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 034f8edf24..21a83b1676 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -622,7 +622,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 	cleared = FALSE;
 
-	LLTrace::Sampler* sampler = LLThread::getTraceData()->getPrimarySampler();
+	LLTrace::Sampler* sampler = LLTrace::getThreadTrace()->getPrimarySampler();
 
 	LLAppViewer::getTextureFetch()->setTextureBandwidth(sampler->getMean(STAT_TEXTURE_KBIT) / sampler->getSampleTime());
 
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 97079e0588..1e8665e229 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -704,7 +704,7 @@ void LLWorld::updateNetStats()
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 	LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
 	LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
-	STAT_KBIT.sample(bits/1024.f);
+	STAT_KBIT.add(bits/1024.f);
 	//LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
 	LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in);
 	LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out);
-- 
cgit v1.2.3


From dbe9742703cf14db85ec3d16c540efc68dce95a6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 2 Oct 2012 15:37:16 -0700
Subject: SH-3404  create sampler class renamed LLTrace::ThreadTrace to
 LLTrace::ThreadRecorder renamed LLTrace::Sampler to LLTrace::Recording

---
 indra/newview/llappviewer.cpp         | 2 +-
 indra/newview/llviewerstats.cpp       | 3 +--
 indra/newview/llviewerstats.h         | 7 ++++---
 indra/newview/llviewertexturelist.cpp | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0bb87dfa6c..22f3cce9e8 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1222,7 +1222,7 @@ bool LLAppViewer::mainLoop()
 	{
 		LLFastTimer _(FTM_FRAME);
 		LLFastTimer::nextFrame(); 
-		LLTrace::getMasterThreadTrace().pullFromSlaveThreads();
+		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
 
 		//clear call stack records
 		llclearcallstacks;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index e2b09a1902..a6e9643edd 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -276,12 +276,11 @@ LLViewerStats::LLViewerStats() :
 	}	
 	
 	mAgentPositionSnaps.reset();
-	mSampler->start();
+	mRecording.start();
 }
 
 LLViewerStats::~LLViewerStats()
 {
-	delete mSampler;
 }
 
 void LLViewerStats::resetStats()
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 9e809dd08c..ca5f6c6821 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -29,7 +29,8 @@
 
 #include "llstat.h"
 #include "lltextureinfo.h"
-#include "lltracesampler.h"
+#include "lltracerecording.h"
+#include "lltrace.h"
 
 extern LLTrace::Rate<F32>	STAT_KBIT,
 							STAT_LAYERS_KBIT,
@@ -297,11 +298,11 @@ public:
 		static void recordPhaseStat(const std::string& phase_name, F32 value);
 	};
 
-	LLTrace::Sampler* getSampler() { return mSampler; }
+	LLTrace::Recording& getRecording() { return mRecording; }
 
 private:
 	F64	mStats[ST_COUNT];
-	LLTrace::Sampler*	mSampler;
+	LLTrace::Recording	mRecording;
 
 	F64 mLastTimeDiff;  // used for time stat updates
 };
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 21a83b1676..4e62cbd714 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -622,9 +622,9 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 	cleared = FALSE;
 
-	LLTrace::Sampler* sampler = LLTrace::getThreadTrace()->getPrimarySampler();
+	LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording();
 
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(sampler->getMean(STAT_TEXTURE_KBIT) / sampler->getSampleTime());
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(STAT_TEXTURE_KBIT));
 
 	LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
 	LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
-- 
cgit v1.2.3


From 8f5e83789254d19a1a31737b0d7515cd7e967b26 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 3 Oct 2012 19:32:59 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system SH-3403 FIX
 implement unit conversion LLUnit implements unit tracking and conversion
 added support for LLUnit to LLTrace duplicated most llstats into LLTrace
 equivalents

---
 indra/newview/llstatusbar.cpp         |   2 +-
 indra/newview/llviewerstats.cpp       | 131 ++++++++++++++++++++++++++++++----
 indra/newview/llviewerstats.h         | 120 +++++++++++++++++++++++++++++--
 indra/newview/llviewertexturelist.cpp |   2 +-
 indra/newview/llworld.cpp             |   3 +-
 5 files changed, 238 insertions(+), 20 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index ab97d6465a..6f2a0de894 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild()
 	sgp.rect(r);
 	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	sgp.mouse_opaque(false);
-	sgp.stat.rate_stat(&STAT_KBIT);
+	sgp.stat.rate_stat(&LLStatViewer::KBIT);
 	sgp.units("Kbps");
 	sgp.precision(0);
 	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index a6e9643edd..954fa24eaa 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -61,21 +61,128 @@
 #include "llviewernetwork.h"
 #include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived
 
+namespace LLStatViewer
+{
 
-LLTrace::Rate<F32>	STAT_KBIT("kbitstat"),
-					STAT_LAYERS_KBIT("layerskbitstat"),
-					STAT_OBJECT_KBIT("objectkbitstat"),
-					STAT_ASSET_KBIT("assetkbitstat"),
-					STAT_TEXTURE_KBIT("texturekbitstat");
-
+LLTrace::Rate<F32>					FPS("fpsstat"),
+									PACKETS_IN("packetsinstat"),
+									PACKETS_LOST("packetsloststat"),
+									PACKETS_OUT("packetsoutstat"),
+									TEXTURE_PACKETS("texturepacketsstat"),
+									TRIANGLES_DRAWN("trianglesdrawnstat"),
+									CHAT_COUNT("chatcount"),
+									IM_COUNT("imcount"),
+									OBJECT_CREATE("objectcreate"),
+									OBJECT_REZ("objectrez"),
+									LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay"),
+									LOGIN_TIMEOUTS("logintimeouts"),
+									FAILED_DOWNLOADS("faileddownloads"),
+									LSL_SAVES("lslsaves"),
+									ANIMATION_UPLOADS("animationuploads"),
+									FLY("fly"),
+									TELEPORT("teleport"),
+									DELETE_OBJECT("deleteobject"),
+									SNAPSHOT("snapshot"),
+									UPLOAD_SOUND("uploadsound"),
+									UPLOAD_TEXTURE("uploadtexture"),
+									EDIT_TEXTURE("edittexture"),
+									KILLED("killed"),
+									FRAMETIME_DOUBLED("frametimedoubled"),
+									TEX_BAKES("texbakes"),
+									TEX_REBAKES("texrebakes");
+LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT("kbitstat"),
+									LAYERS_KBIT("layerskbitstat"),
+									OBJECT_KBIT("objectkbitstat"),
+									ASSET_KBIT("assetkbitstat"),
+									TEXTURE_KBIT("texturekbitstat"),
+									ACTUAL_IN_KBIT("actualinkbit"),
+									ACTUAL_OUT_KBIT("actualoutkbit");
+
+LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittimr"),
+									 TOOLBOX_TIME("toolboxtime"),
+									 MOUSELOOK_TIME("mouselooktime"),
+									 FPS_10_TIME("fps10time"),
+									 FPS_8_TIME("fps8time"),
+									 FPS_2_TIME("fps2time"),
+									 SIM_20_FPS_TIME("sim20fpstime"),
+									 SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime"),
+									 LOSS_5_PERCENT_TIME("loss5percenttime");
+
+LLTrace::Measurement<F32>			SIM_TIME_DILATION("simtimedilation"),
+									SIM_FPS("simfps"),
+									SIM_PHYSICS_FPS("simphysicsfps"),
+									SIM_AGENT_UPS("simagentups"),
+									SIM_SCRIPT_EPS("simscripteps"),
+									SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"),
+									SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"),
+									SIM_MAIN_AGENTS("simmainagents"),
+									SIM_CHILD_AGENTS("simchildagents"),
+									SIM_OBJECTS("simobjects"),
+									SIM_ACTIVE_OBJECTS("simactiveobjects"),
+									SIM_ACTIVE_SCRIPTS("simactivescripts"),
+									SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"),
+									SIM_IN_PACKETS_PER_SEC("siminpps"),
+									SIM_OUT_PACKETS_PER_SEC("simoutpps"),
+									SIM_PENDING_DOWNLOADS("simpendingdownloads"),
+									SIM_PENDING_UPLOADS("simpendinguploads"),
+									SIM_PENING_LOCAL_UPLOADS("simpendinglocaluploads"),
+									SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"),
+									SIM_PHYSICS_LOD_TASKS("physicslodtasks"),
+									NUM_IMAGES("numimagesstat"),
+									NUM_RAW_IMAGES("numrawimagesstat"),
+									NUM_OBJECTS("numobjectsstat"),
+									NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
+									NUM_NEW_OBJECTS("numnewobjectsstat"),
+									NUM_SIZE_CULLED("numsizeculledstat"),
+									NUM_VIS_CULLED("numvisculledstat"),
+									ENABLE_VBO("enablevbo"),
+									DELTA_BANDWIDTH("deltabandwidth"),
+									MAX_BANDWIDTH("maxbandwidth"),
+									LIGHTING_DETAIL("lightingdetail"),
+									VISIBLE_AVATARS("visibleavatars"),
+									SHADER_OBJECTS("shaderobjects"),
+									DRAW_DISTANCE("drawdistance"),
+									CHAT_BUBBLES("chatbubbles"),
+									WINDOW_WIDTH("windowwidth"),
+									WINDOW_HEIGHT("windowheight");
+
+LLTrace::Measurement<LLUnits::Bytes<F32> >	SIM_UNACKED_BYTES("simtotalunackedbytes"),
+											SIM_PHYSICS_MEM("physicsmemoryallocated"),
+											GL_TEX_MEM("gltexmemstat"),
+											GL_BOUND_MEM("glboundmemstat"),
+											RAW_MEM("rawmemstat"),
+											FORMATTED_MEM("formattedmemstat");
+
+
+LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME("simsimphysicsmsec"),
+											SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"),
+											SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"),
+											SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"),
+											SIM_AI_TIME("simsimaistepmsec"),
+											SIM_AGENTS_TIME("simagentmsec"),
+											SIM_IMAGES_TIME("simimagesmsec"),
+											SIM_SCRIPTS_TIME("simscriptmsec"),
+											SIM_SPARE_TIME("simsparemsec"),
+											SIM_SLEEP_TIME("simsleepmsec"),
+											SIM_PUMP_IO_TIME("simpumpiomsec"),
+											SIM_PING("simpingstat"),
+											LOGIN_SECONDS("loginseconds"),
+											REGION_CROSSING_TIME("regioncrossingtime"),
+											FRAME_STACKTIME("framestacktime"),
+											UPDATE_STACKTIME("updatestacktime"),
+											NETWORK_STACKTIME("networkstacktime"),
+											IMAGE_STACKTIME("imagestacktime"),
+											REBUILD_STACKTIME("rebuildstacktime"),
+											RENDER_STACKTIME("renderstacktime");
+}
 
 class StatAttributes
 {
 public:
 	StatAttributes(const char* name,
 				   const BOOL enabled)
-		: mName(name),
-		  mEnabled(enabled)
+	:	mName(name),
+		mEnabled(enabled)
 	{
 	}
 	
@@ -465,12 +572,12 @@ void update_statistics()
 
 	stats.mFPSStat.addValue(1);
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	STAT_LAYERS_KBIT.add(layer_bits/1024.f);
+	LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits<F32> >(layer_bits);
 	//stats.mLayersKBitStat.addValue(layer_bits/1024.f);
-	STAT_OBJECT_KBIT.add(gObjectBits/1024.f);
+	LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits<F32> >(gObjectBits);
 	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
 	stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
-	STAT_ASSET_KBIT.add(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
+	LLStatViewer::ASSET_KBIT.add<LLUnits::Bits<F32> >(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
 	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
@@ -508,7 +615,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			STAT_TEXTURE_KBIT.add(LLViewerTextureList::sTextureBits/1024.f);
+			LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(LLViewerTextureList::sTextureBits);
 			//stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f);
 			stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets);
 			gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8;
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index ca5f6c6821..af2e915994 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -32,11 +32,121 @@
 #include "lltracerecording.h"
 #include "lltrace.h"
 
-extern LLTrace::Rate<F32>	STAT_KBIT,
-							STAT_LAYERS_KBIT,
-							STAT_OBJECT_KBIT,
-							STAT_ASSET_KBIT,
-							STAT_TEXTURE_KBIT;
+namespace LLStatViewer
+{
+extern LLTrace::Rate<F32>					FPS,
+											PACKETS_IN,
+											PACKETS_LOST,
+											PACKETS_OUT,
+											TEXTURE_PACKETS,
+											TRIANGLES_DRAWN,
+											CHAT_COUNT,
+											IM_COUNT,
+											OBJECT_CREATE,
+											OBJECT_REZ,
+											LOADING_WEARABLES_LONG_DELAY,
+											LOGIN_TIMEOUTS,
+											FAILED_DOWNLOADS,
+											LSL_SAVES,
+											ANIMATION_UPLOADS,
+											FLY,
+											TELEPORT,
+											DELETE_OBJECT,
+											SNAPSHOT,
+											UPLOAD_SOUND,
+											UPLOAD_TEXTURE,
+											EDIT_TEXTURE,
+											KILLED,
+											FRAMETIME_DOUBLED,
+											TEX_BAKES,
+											TEX_REBAKES;
+
+
+extern LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT,
+											LAYERS_KBIT,
+											OBJECT_KBIT,
+											ASSET_KBIT,
+											TEXTURE_KBIT,
+											ACTUAL_IN_KBIT,
+											ACTUAL_OUT_KBIT;
+
+extern LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME,
+											 TOOLBOX_TIME,
+											 MOUSELOOK_TIME,
+											 FPS_10_TIME,
+											 FPS_8_TIME,
+											 FPS_2_TIME,
+											 SIM_20_FPS_TIME,
+											 SIM_PHYSICS_20_FPS_TIME,
+											 LOSS_5_PERCENT_TIME;
+
+extern LLTrace::Measurement<F32>			SIM_TIME_DILATION,
+											SIM_FPS,
+											SIM_PHYSICS_FPS,
+											SIM_AGENT_UPS,
+											SIM_SCRIPT_EPS,
+											SIM_SKIPPED_SILHOUETTE,
+											SIM_SKIPPED_CHARACTERS_PERCENTAGE,
+											SIM_MAIN_AGENTS,
+											SIM_CHILD_AGENTS,
+											SIM_OBJECTS,
+											SIM_ACTIVE_OBJECTS,
+											SIM_ACTIVE_SCRIPTS,
+											SIM_PERCENTAGE_SCRIPTS_RUN,
+											SIM_IN_PACKETS_PER_SEC,
+											SIM_OUT_PACKETS_PER_SEC,
+											SIM_PENDING_DOWNLOADS,
+											SIM_PENDING_UPLOADS,
+											SIM_PENING_LOCAL_UPLOADS,
+											SIM_PHYSICS_PINNED_TASKS,
+											SIM_PHYSICS_LOD_TASKS,
+											NUM_IMAGES,
+											NUM_RAW_IMAGES,
+											NUM_OBJECTS,
+											NUM_ACTIVE_OBJECTS,
+											NUM_NEW_OBJECTS,
+											NUM_SIZE_CULLED,
+											NUM_VIS_CULLED,
+											ENABLE_VBO,
+											DELTA_BANDWIDTH,
+											MAX_BANDWIDTH,
+											LIGHTING_DETAIL,
+											VISIBLE_AVATARS,
+											SHADER_OBJECTS,
+											DRAW_DISTANCE,
+											CHAT_BUBBLES,
+											WINDOW_WIDTH,
+											WINDOW_HEIGHT;
+
+extern LLTrace::Measurement<LLUnits::Bytes<F32> >	SIM_UNACKED_BYTES,
+													SIM_PHYSICS_MEM,
+													GL_TEX_MEM,
+													GL_BOUND_MEM,
+													RAW_MEM,
+													FORMATTED_MEM;
+
+
+extern LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME,
+													SIM_PHYSICS_STEP_TIME,
+													SIM_PHYSICS_SHAPE_UPDATE_TIME,
+													SIM_PHYSICS_OTHER_TIME,
+													SIM_AI_TIME,
+													SIM_AGENTS_TIME,
+													SIM_IMAGES_TIME,
+													SIM_SCRIPTS_TIME,
+													SIM_SPARE_TIME,
+													SIM_SLEEP_TIME,
+													SIM_PUMP_IO_TIME,
+													SIM_PING,
+													LOGIN_SECONDS,
+													REGION_CROSSING_TIME,
+													FRAME_STACKTIME,
+													UPDATE_STACKTIME,
+													NETWORK_STACKTIME,
+													IMAGE_STACKTIME,
+													REBUILD_STACKTIME,
+													RENDER_STACKTIME;
+}
 
 class LLViewerStats : public LLSingleton<LLViewerStats>
 {
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 4e62cbd714..de3dd3c1c6 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -624,7 +624,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 
 	LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording();
 
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(STAT_TEXTURE_KBIT));
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT));
 
 	LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
 	LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 1e8665e229..bf2a58f107 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -702,9 +702,10 @@ void LLWorld::updateNetStats()
 
 	S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
+
 	LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
 	LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
-	STAT_KBIT.add(bits/1024.f);
+	LLStatViewer::KBIT.add<LLUnits::Bits<F32> >(bits);
 	//LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
 	LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in);
 	LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out);
-- 
cgit v1.2.3


From 74ac0182ec8f7a0f6d0ea89f5814f0998ab90b62 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 10 Oct 2012 19:25:56 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system fixed units
 conversion so that trace getters return convertable units removed circular
 dependencies from lltrace* converted more stats to lltrace

---
 indra/newview/lltexturefetch.cpp      |   3 +-
 indra/newview/llviewermessage.cpp     |  13 +-
 indra/newview/llviewerstats.cpp       | 349 +++++++++++-----------------------
 indra/newview/llviewerstats.h         |   9 +-
 indra/newview/llviewertexturelist.cpp |  14 +-
 indra/newview/llviewertexturelist.h   |   3 -
 indra/newview/llviewerwindow.cpp      |   7 +-
 indra/newview/llworld.cpp             |  36 ++--
 indra/newview/pipeline.cpp            |   5 +-
 9 files changed, 164 insertions(+), 275 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index e7538d685d..2ce5f95b54 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2316,7 +2316,8 @@ S32 LLTextureFetch::update(F32 max_time_ms)
 
 	if(mCurlGetRequest)
 	{
-		gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits();
+		LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(mCurlGetRequest->getTotalReceivedBits());
+		//gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits();
 	}
 
 	if(mFetchDebugger)
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 85ea543838..79ed093382 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4756,18 +4756,23 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data)
 		switch (stat_id)
 		{
 		case LL_SIM_STAT_TIME_DILATION:
-			LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value);
+			LLStatViewer::SIM_TIME_DILATION.sample(stat_value);
+			//LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value);
 			break;
 		case LL_SIM_STAT_FPS:
-			LLViewerStats::getInstance()->mSimFPS.addValue(stat_value);
+			LLStatViewer::SIM_FPS.sample(stat_value);
+			//LLViewerStats::getInstance()->mSimFPS.addValue(stat_value);
 			break;
 		case LL_SIM_STAT_PHYSFPS:
-			LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value);
+			LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value);
+			//LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value);
 			break;
 		case LL_SIM_STAT_AGENTUPS:
-			LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
+			LLStatViewer::SIM_AGENT_UPS.sample(stat_value);
+			//LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
 			break;
 		case LL_SIM_STAT_FRAMEMS:
+			//LLStatViewer::SIM_.sample(stat_value);
 			LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value);
 			break;
 		case LL_SIM_STAT_NETMS:
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 954fa24eaa..2737d24674 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -64,32 +64,32 @@
 namespace LLStatViewer
 {
 
-LLTrace::Rate<F32>					FPS("fpsstat"),
-									PACKETS_IN("packetsinstat"),
-									PACKETS_LOST("packetsloststat"),
-									PACKETS_OUT("packetsoutstat"),
-									TEXTURE_PACKETS("texturepacketsstat"),
-									TRIANGLES_DRAWN("trianglesdrawnstat"),
-									CHAT_COUNT("chatcount"),
-									IM_COUNT("imcount"),
-									OBJECT_CREATE("objectcreate"),
-									OBJECT_REZ("objectrez"),
-									LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay"),
-									LOGIN_TIMEOUTS("logintimeouts"),
-									FAILED_DOWNLOADS("faileddownloads"),
-									LSL_SAVES("lslsaves"),
-									ANIMATION_UPLOADS("animationuploads"),
-									FLY("fly"),
-									TELEPORT("teleport"),
-									DELETE_OBJECT("deleteobject"),
-									SNAPSHOT("snapshot"),
-									UPLOAD_SOUND("uploadsound"),
-									UPLOAD_TEXTURE("uploadtexture"),
-									EDIT_TEXTURE("edittexture"),
-									KILLED("killed"),
-									FRAMETIME_DOUBLED("frametimedoubled"),
-									TEX_BAKES("texbakes"),
-									TEX_REBAKES("texrebakes");
+LLTrace::Rate<F32>	FPS("fpsstat"),
+					PACKETS_IN("packetsinstat"),
+					PACKETS_LOST("packetsloststat"),
+					PACKETS_OUT("packetsoutstat"),
+					TEXTURE_PACKETS("texturepacketsstat"),
+					TRIANGLES_DRAWN("trianglesdrawnstat"),
+					CHAT_COUNT("chatcount", "Chat messages sent"),
+					IM_COUNT("imcount", "IMs sent"),
+					OBJECT_CREATE("objectcreate"),
+					OBJECT_REZ("objectrez", "Object rez count"),
+					LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load"),
+					LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"),
+					FAILED_DOWNLOADS("faileddownloads", "Number of times LLAssetStorage::getAssetData() has failed"),
+					LSL_SAVES("lslsaves", "Number of times user has saved a script"),
+					ANIMATION_UPLOADS("animationuploads", "Animations uploaded"),
+					FLY("fly", "Fly count"),
+					TELEPORT("teleport", "Teleport count"),
+					DELETE_OBJECT("deleteobject", "Objects deleted"),
+					SNAPSHOT("snapshot", "Snapshots taken"),
+					UPLOAD_SOUND("uploadsound", "Sounds uploaded"),
+					UPLOAD_TEXTURE("uploadtexture", "Textures uploaded"),
+					EDIT_TEXTURE("edittexture", "Changes to textures on objects"),
+					KILLED("killed", "Number of times killed"),
+					FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"),
+					TEX_BAKES("texbakes"),
+					TEX_REBAKES("texrebakes");
 LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT("kbitstat"),
 									LAYERS_KBIT("layerskbitstat"),
 									OBJECT_KBIT("objectkbitstat"),
@@ -98,53 +98,54 @@ LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT("kbitstat"),
 									ACTUAL_IN_KBIT("actualinkbit"),
 									ACTUAL_OUT_KBIT("actualoutkbit");
 
-LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittimr"),
-									 TOOLBOX_TIME("toolboxtime"),
-									 MOUSELOOK_TIME("mouselooktime"),
-									 FPS_10_TIME("fps10time"),
-									 FPS_8_TIME("fps8time"),
-									 FPS_2_TIME("fps2time"),
-									 SIM_20_FPS_TIME("sim20fpstime"),
-									 SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime"),
-									 LOSS_5_PERCENT_TIME("loss5percenttime");
-
-LLTrace::Measurement<F32>			SIM_TIME_DILATION("simtimedilation"),
-									SIM_FPS("simfps"),
-									SIM_PHYSICS_FPS("simphysicsfps"),
-									SIM_AGENT_UPS("simagentups"),
-									SIM_SCRIPT_EPS("simscripteps"),
-									SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"),
-									SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"),
-									SIM_MAIN_AGENTS("simmainagents"),
-									SIM_CHILD_AGENTS("simchildagents"),
-									SIM_OBJECTS("simobjects"),
-									SIM_ACTIVE_OBJECTS("simactiveobjects"),
-									SIM_ACTIVE_SCRIPTS("simactivescripts"),
-									SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"),
-									SIM_IN_PACKETS_PER_SEC("siminpps"),
-									SIM_OUT_PACKETS_PER_SEC("simoutpps"),
-									SIM_PENDING_DOWNLOADS("simpendingdownloads"),
-									SIM_PENDING_UPLOADS("simpendinguploads"),
-									SIM_PENING_LOCAL_UPLOADS("simpendinglocaluploads"),
-									SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"),
-									SIM_PHYSICS_LOD_TASKS("physicslodtasks"),
-									NUM_IMAGES("numimagesstat"),
-									NUM_RAW_IMAGES("numrawimagesstat"),
-									NUM_OBJECTS("numobjectsstat"),
-									NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
-									NUM_NEW_OBJECTS("numnewobjectsstat"),
-									NUM_SIZE_CULLED("numsizeculledstat"),
-									NUM_VIS_CULLED("numvisculledstat"),
-									ENABLE_VBO("enablevbo"),
-									DELTA_BANDWIDTH("deltabandwidth"),
-									MAX_BANDWIDTH("maxbandwidth"),
-									LIGHTING_DETAIL("lightingdetail"),
-									VISIBLE_AVATARS("visibleavatars"),
-									SHADER_OBJECTS("shaderobjects"),
-									DRAW_DISTANCE("drawdistance"),
-									CHAT_BUBBLES("chatbubbles"),
-									WINDOW_WIDTH("windowwidth"),
-									WINDOW_HEIGHT("windowheight");
+LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
+									 TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
+									 MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
+									 FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
+									 FPS_8_TIME("fps8time", "Seconds below 8 FPS"),
+									 FPS_2_TIME("fps2time", "Seconds below 2 FPS"),
+									 SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
+									 SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
+									 LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
+
+LLTrace::Measurement<F32>	SIM_TIME_DILATION("simtimedilation"),
+							SIM_FPS("simfps"),
+							SIM_PHYSICS_FPS("simphysicsfps"),
+							SIM_AGENT_UPS("simagentups"),
+							SIM_SCRIPT_EPS("simscripteps"),
+							SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"),
+							SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"),
+							SIM_MAIN_AGENTS("simmainagents"),
+							SIM_CHILD_AGENTS("simchildagents"),
+							SIM_OBJECTS("simobjects"),
+							SIM_ACTIVE_OBJECTS("simactiveobjects"),
+							SIM_ACTIVE_SCRIPTS("simactivescripts"),
+							SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"),
+							SIM_IN_PACKETS_PER_SEC("siminpps"),
+							SIM_OUT_PACKETS_PER_SEC("simoutpps"),
+							SIM_PENDING_DOWNLOADS("simpendingdownloads"),
+							SIM_PENDING_UPLOADS("simpendinguploads"),
+							SIM_PENDING_LOCAL_UPLOADS("simpendinglocaluploads"),
+							SIM_PENDING_VFS_OPERATIONS("vfspendingoperations"), 
+							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"),
+							SIM_PHYSICS_LOD_TASKS("physicslodtasks"),
+							NUM_IMAGES("numimagesstat"),
+							NUM_RAW_IMAGES("numrawimagesstat"),
+							NUM_OBJECTS("numobjectsstat"),
+							NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
+							NUM_NEW_OBJECTS("numnewobjectsstat"),
+							NUM_SIZE_CULLED("numsizeculledstat"),
+							NUM_VIS_CULLED("numvisculledstat"),
+							ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
+							DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
+							MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"),
+							LIGHTING_DETAIL("lightingdetail", "Lighting Detail"),
+							VISIBLE_AVATARS("visibleavatars", "Visible Avatars"),
+							SHADER_OBJECTS("shaderobjects", "Object Shaders"),
+							DRAW_DISTANCE("drawdistance", "Draw Distance"),
+							CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"),
+							WINDOW_WIDTH("windowwidth", "Window width"),
+							WINDOW_HEIGHT("windowheight", "Window height");
 
 LLTrace::Measurement<LLUnits::Bytes<F32> >	SIM_UNACKED_BYTES("simtotalunackedbytes"),
 											SIM_PHYSICS_MEM("physicsmemoryallocated"),
@@ -166,14 +167,16 @@ LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME("simsimphysicsmsec
 											SIM_SLEEP_TIME("simsleepmsec"),
 											SIM_PUMP_IO_TIME("simpumpiomsec"),
 											SIM_PING("simpingstat"),
-											LOGIN_SECONDS("loginseconds"),
-											REGION_CROSSING_TIME("regioncrossingtime"),
-											FRAME_STACKTIME("framestacktime"),
-											UPDATE_STACKTIME("updatestacktime"),
-											NETWORK_STACKTIME("networkstacktime"),
-											IMAGE_STACKTIME("imagestacktime"),
-											REBUILD_STACKTIME("rebuildstacktime"),
-											RENDER_STACKTIME("renderstacktime");
+											FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+											FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
+											LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
+											REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
+											FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
+											UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
+											NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
+											IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
+											REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
+											RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
 }
 
 class StatAttributes
@@ -190,139 +193,18 @@ public:
 	BOOL mEnabled;
 };
 
-const StatAttributes STAT_INFO[LLViewerStats::ST_COUNT] =
-{
-	// ST_VERSION
-	StatAttributes("Version", TRUE),
-	// ST_AVATAR_EDIT_SECONDS
-	StatAttributes("Seconds in Edit Appearence", FALSE),
-	// ST_TOOLBOX_SECONDS
-	StatAttributes("Seconds using Toolbox", FALSE),
-	// ST_CHAT_COUNT
-	StatAttributes("Chat messages sent", FALSE),
-	// ST_IM_COUNT
-	StatAttributes("IMs sent", FALSE),
-	// ST_FULLSCREEN_BOOL
-	StatAttributes("Fullscreen mode", FALSE),
-	// ST_RELEASE_COUNT
-	StatAttributes("Object release count", FALSE),
-	// ST_CREATE_COUNT
-	StatAttributes("Object create count", FALSE),
-	// ST_REZ_COUNT
-	StatAttributes("Object rez count", FALSE),
-	// ST_FPS_10_SECONDS
-	StatAttributes("Seconds below 10 FPS", FALSE),
-	// ST_FPS_2_SECONDS
-	StatAttributes("Seconds below 2 FPS", FALSE),
-	// ST_MOUSELOOK_SECONDS
-	StatAttributes("Seconds in Mouselook", FALSE),
-	// ST_FLY_COUNT
-	StatAttributes("Fly count", FALSE),
-	// ST_TELEPORT_COUNT
-	StatAttributes("Teleport count", FALSE),
-	// ST_OBJECT_DELETE_COUNT
-	StatAttributes("Objects deleted", FALSE),
-	// ST_SNAPSHOT_COUNT
-	StatAttributes("Snapshots taken", FALSE),
-	// ST_UPLOAD_SOUND_COUNT
-	StatAttributes("Sounds uploaded", FALSE),
-	// ST_UPLOAD_TEXTURE_COUNT
-	StatAttributes("Textures uploaded", FALSE),
-	// ST_EDIT_TEXTURE_COUNT
-	StatAttributes("Changes to textures on objects", FALSE),
-	// ST_KILLED_COUNT
-	StatAttributes("Number of times killed", FALSE),
-	// ST_FRAMETIME_JITTER
-	StatAttributes("Average delta between successive frame times", FALSE),
-	// ST_FRAMETIME_SLEW
-	StatAttributes("Average delta between frame time and mean", FALSE),
-	// ST_INVENTORY_TOO_LONG
-	StatAttributes("Inventory took too long to load", FALSE),
-	// ST_WEARABLES_TOO_LONG
-	StatAttributes("Wearables took too long to load", FALSE),
-	// ST_LOGIN_SECONDS
-	StatAttributes("Time between LoginRequest and LoginReply", FALSE),
-	// ST_LOGIN_TIMEOUT_COUNT
-	StatAttributes("Number of login attempts that timed out", FALSE),
-	// ST_HAS_BAD_TIMER
-	StatAttributes("Known bad timer if != 0.0", FALSE),
-	// ST_DOWNLOAD_FAILED
-	StatAttributes("Number of times LLAssetStorage::getAssetData() has failed", FALSE),
-	// ST_LSL_SAVE_COUNT
-	StatAttributes("Number of times user has saved a script", FALSE),
-	// ST_UPLOAD_ANIM_COUNT
-	StatAttributes("Animations uploaded", FALSE),
-	// ST_FPS_8_SECONDS
-	StatAttributes("Seconds below 8 FPS", FALSE),
-	// ST_SIM_FPS_20_SECONDS
-	StatAttributes("Seconds with sim FPS below 20", FALSE),
-	// ST_PHYS_FPS_20_SECONDS
-	StatAttributes("Seconds with physics FPS below 20", FALSE),
-	// ST_LOSS_05_SECONDS
-	StatAttributes("Seconds with packet loss > 5%", FALSE),
-	// ST_FPS_DROP_50_RATIO
-	StatAttributes("Ratio of frames 2x longer than previous", FALSE),
-	// ST_ENABLE_VBO
-	StatAttributes("Vertex Buffers Enabled", TRUE),
-	// ST_DELTA_BANDWIDTH
-	StatAttributes("Increase/Decrease in bandwidth based on packet loss", FALSE),
-	// ST_MAX_BANDWIDTH
-	StatAttributes("Max bandwidth setting", FALSE),
-	// ST_LIGHTING_DETAIL
-	StatAttributes("Lighting Detail", FALSE),
-	// ST_VISIBLE_AVATARS
-	StatAttributes("Visible Avatars", FALSE),
-	// ST_SHADER_OJECTS
-	StatAttributes("Object Shaders", FALSE),
-	// ST_SHADER_ENVIRONMENT
-	StatAttributes("Environment Shaders", FALSE),
-	// ST_VISIBLE_DRAW_DIST
-	StatAttributes("Draw Distance", FALSE),
-	// ST_VISIBLE_CHAT_BUBBLES
-	StatAttributes("Chat Bubbles Enabled", FALSE),
-	// ST_SHADER_AVATAR
-	StatAttributes("Avatar Shaders", FALSE),
-	// ST_FRAME_SECS
-	StatAttributes("FRAME_SECS", FALSE),
-	// ST_UPDATE_SECS
-	StatAttributes("UPDATE_SECS", FALSE),
-	// ST_NETWORK_SECS
-	StatAttributes("NETWORK_SECS", FALSE),
-	// ST_IMAGE_SECS
-	StatAttributes("IMAGE_SECS", FALSE),
-	// ST_REBUILD_SECS
-	StatAttributes("REBUILD_SECS", FALSE),
-	// ST_RENDER_SECS
-	StatAttributes("RENDER_SECS", FALSE),
-	// ST_CROSSING_AVG
-	StatAttributes("CROSSING_AVG", FALSE),
-	// ST_CROSSING_MAX
-	StatAttributes("CROSSING_MAX", FALSE),
-	// ST_LIBXUL_WIDGET_USED
-	StatAttributes("LibXUL Widget used", FALSE), // Unused
-	// ST_WINDOW_WIDTH
-	StatAttributes("Window width", FALSE),
-	// ST_WINDOW_HEIGHT
-	StatAttributes("Window height", FALSE),
-	// ST_TEX_BAKES
-	StatAttributes("Texture Bakes", FALSE),
-	// ST_TEX_REBAKES
-	StatAttributes("Texture Rebakes", FALSE)
-
-};
-
 LLViewerStats::LLViewerStats() :
-	mVFSPendingOperations("vfspendingoperations"),
-	mFPSStat("fpsstat"),
-	mPacketsInStat("packetsinstat"),
-	mPacketsLostStat("packetsloststat"),
-	mPacketsOutStat("packetsoutstat"),
-	mPacketsLostPercentStat("packetslostpercentstat"),
-	mTexturePacketsStat("texturepacketsstat"),
-	mActualInKBitStat("actualinkbitstat"),
-	mActualOutKBitStat("actualoutkbitstat"),
-	mTrianglesDrawnStat("trianglesdrawnstat"),
-	mSimTimeDilation("simtimedilation"),
+	//mVFSPendingOperations("vfspendingoperations"),
+	//mFPSStat("fpsstat"),
+	//mPacketsInStat("packetsinstat"),
+	//mPacketsLostStat("packetsloststat"),
+	//mPacketsOutStat("packetsoutstat"),
+	//mPacketsLostPercentStat("packetslostpercentstat"),
+	//mTexturePacketsStat("texturepacketsstat"),
+	//mActualInKBitStat("actualinkbitstat"),
+	//mActualOutKBitStat("actualoutkbitstat"),
+	//mTrianglesDrawnStat("trianglesdrawnstat"),
+	//mSimTimeDilation("simtimedilation"),
 	mSimFPS("simfps"),
 	mSimPhysicsFPS("simphysicsfps"),
 	mSimAgentUPS("simagentups"),
@@ -393,13 +275,14 @@ LLViewerStats::~LLViewerStats()
 void LLViewerStats::resetStats()
 {
 	LLViewerStats& stats = LLViewerStats::instance();
-	stats.mVFSPendingOperations.reset();
-	stats.mPacketsInStat.reset();
-	stats.mPacketsLostStat.reset();
-	stats.mPacketsOutStat.reset();
-	stats.mFPSStat.reset();
-	stats.mTexturePacketsStat.reset();
-	stats.mAgentPositionSnaps.reset();
+	stats.mRecording.reset();
+	//stats.mVFSPendingOperations.reset();
+	//stats.mPacketsInStat.reset();
+	//stats.mPacketsLostStat.reset();
+	//stats.mPacketsOutStat.reset();
+	//stats.mFPSStat.reset();
+	//stats.mTexturePacketsStat.reset();
+	//stats.mAgentPositionSnaps.reset();
 }
 
 
@@ -484,16 +367,9 @@ void LLViewerStats::addToMessage(LLSD &body) const
 {
 	LLSD &misc = body["misc"];
 	
-	for (S32 i = 0; i < ST_COUNT; i++)
-	{
-		if (STAT_INFO[i].mEnabled)
-		{
-			// TODO: send timer value so dataserver can normalize
-			misc[STAT_INFO[i].mName] = mStats[i];
-			llinfos << "STAT: " << STAT_INFO[i].mName << ": " << mStats[i]
-					<< llendl;
-		}
-	}
+	misc["Version"] = TRUE;
+	//TODO RN: get last value, not mean
+	misc["Vertex Buffers Enabled"] = mRecording.getMean(LLStatViewer::ENABLE_VBO);
 	
 	body["AgentPositionSnaps"] = mAgentPositionSnaps.asLLSD();
 	llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() 
@@ -570,13 +446,15 @@ void update_statistics()
 		stats.mSimPingStat.addValue(10000);
 	}
 
-	stats.mFPSStat.addValue(1);
+	//stats.mFPSStat.addValue(1);
+	LLStatViewer::FPS.add(1);
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
 	LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits<F32> >(layer_bits);
 	//stats.mLayersKBitStat.addValue(layer_bits/1024.f);
 	LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits<F32> >(gObjectBits);
 	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
-	stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
+	//stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
+	LLStatViewer::SIM_PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending());
 	LLStatViewer::ASSET_KBIT.add<LLUnits::Bits<F32> >(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
 	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
@@ -615,12 +493,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(LLViewerTextureList::sTextureBits);
-			//stats.mTextureKBitStat.addValue(LLViewerTextureList::sTextureBits/1024.f);
-			stats.mTexturePacketsStat.addValue(LLViewerTextureList::sTexturePackets);
-			gTotalTextureBytes += LLViewerTextureList::sTextureBits / 8;
-			LLViewerTextureList::sTextureBits = 0;
-			LLViewerTextureList::sTexturePackets = 0;
+			gTotalTextureBytes = LLUnits::Bytes<F32>(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).get();//LLViewerTextureList::sTextureBits / 8;
 			texture_stats_timer.reset();
 		}
 	}
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index af2e915994..a14518f536 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -1,5 +1,5 @@
 /** 
- * @file llviewerstats.h
+ * @file llviewerim_peningtats.h
  * @brief LLViewerStats class header file
  *
  * $LicenseInfo:firstyear=2002&license=viewerlgpl$
@@ -97,7 +97,8 @@ extern LLTrace::Measurement<F32>			SIM_TIME_DILATION,
 											SIM_OUT_PACKETS_PER_SEC,
 											SIM_PENDING_DOWNLOADS,
 											SIM_PENDING_UPLOADS,
-											SIM_PENING_LOCAL_UPLOADS,
+											SIM_PENDING_LOCAL_UPLOADS,
+											SIM_PENDING_VFS_OPERATIONS,
 											SIM_PHYSICS_PINNED_TASKS,
 											SIM_PHYSICS_LOD_TASKS,
 											NUM_IMAGES,
@@ -138,6 +139,8 @@ extern LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME,
 													SIM_SLEEP_TIME,
 													SIM_PUMP_IO_TIME,
 													SIM_PING,
+													FRAMETIME_JITTER,
+													FRAMETIME_SLEW,
 													LOGIN_SECONDS,
 													REGION_CROSSING_TIME,
 													FRAME_STACKTIME,
@@ -409,10 +412,12 @@ public:
 	};
 
 	LLTrace::Recording& getRecording() { return mRecording; }
+	LLTrace::Recording& getFrameRecording() { return mFrameRecording; }
 
 private:
 	F64	mStats[ST_COUNT];
 	LLTrace::Recording	mRecording;
+	LLTrace::Recording	mFrameRecording;
 
 	F64 mLastTimeDiff;  // used for time stat updates
 };
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index de3dd3c1c6..b22c0c797e 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -58,14 +58,13 @@
 #include "pipeline.h"
 #include "llappviewer.h"
 #include "llxuiparser.h"
+#include "lltracethreadrecorder.h"
 #include "llviewerdisplay.h"
 
 ////////////////////////////////////////////////////////////////////////////
 
 void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
 
-U32 LLViewerTextureList::sTextureBits = 0;
-U32 LLViewerTextureList::sTexturePackets = 0;
 S32 LLViewerTextureList::sNumImages = 0;
 LLStat LLViewerTextureList::sNumImagesStat("Num Images", TRUE);
 LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", TRUE);
@@ -624,7 +623,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 
 	LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording();
 
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT));
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT).get());
 
 	LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
 	LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
@@ -1326,8 +1325,8 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	gTextureList.sTextureBits += received_size * 8;
-	gTextureList.sTexturePackets++;
+	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size);
+	LLStatViewer::TEXTURE_PACKETS.add(1);
 	
 	U8 codec;
 	U16 packets;
@@ -1399,8 +1398,9 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	gTextureList.sTextureBits += received_size * 8;
-	gTextureList.sTexturePackets++;
+
+	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size);
+	LLStatViewer::TEXTURE_PACKETS.add(1);
 	
 	//llprintline("Start decode, image header...");
 	msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, id);
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 3dda973d3f..ab6f009e28 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -201,9 +201,6 @@ private:
 	LLFrameTimer mForceDecodeTimer;
 	
 public:
-	static U32 sTextureBits;
-	static U32 sTexturePackets;
-
 	static LLStat sNumImagesStat;
 	static LLStat sNumRawImagesStat;
 	static LLStat sGLTexMemStat;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 8b50e56fb3..4ad7c49d4b 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1402,10 +1402,11 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window,  S32 x,  S32 y, S32 width,  S
 		FillRect(hdc, &wnd_rect, CreateSolidBrush(RGB(255, 255, 255)));
 
 		std::string temp_str;
+		LLTrace::Recording& recording = LLViewerStats::instance().getRecording();
 		temp_str = llformat( "FPS %3.1f Phy FPS %2.1f Time Dil %1.3f",		/* Flawfinder: ignore */
-				LLViewerStats::getInstance()->mFPSStat.getMeanPerSec(),
-				LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0),
-				LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0));
+				recording.getPerSec(LLStatViewer::FPS), //mFPSStat.getMeanPerSec(),
+				recording.getMean(LLStatViewer::SIM_PHYSICS_FPS), //LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0),
+				recording.getMean(LLStatViewer::SIM_TIME_DILATION)); //LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0));
 		S32 len = temp_str.length();
 		TextOutA(hdc, 0, 0, temp_str.c_str(), len); 
 
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index bf2a58f107..056132c165 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -703,21 +703,26 @@ void LLWorld::updateNetStats()
 	S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 
-	LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
-	LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
+	LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits<F32> >(actual_in_bits);
+	LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits<F32> >(actual_out_bits);
+	//LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
+	//LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
 	LLStatViewer::KBIT.add<LLUnits::Bits<F32> >(bits);
 	//LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
-	LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in);
-	LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out);
-	LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets);
-	if (packets_in)
-	{
-		LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in));
-	}
-	else
-	{
-		LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f);
-	}
+	LLStatViewer::PACKETS_IN.add(packets_in);
+	LLStatViewer::PACKETS_OUT.add(packets_out);
+	LLStatViewer::PACKETS_LOST.add(packets_lost);
+	//LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in);
+	//LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out);
+	//LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets);
+	//if (packets_in)
+	//{
+	//	LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in));
+	//}
+	//else
+	//{
+	//	LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f);
+	//}
 
 	mLastPacketsIn = gMessageSystem->mPacketsIn;
 	mLastPacketsOut = gMessageSystem->mPacketsOut;
@@ -1129,6 +1134,7 @@ void send_agent_pause()
 	}
 
 	gObjectList.mWasPaused = TRUE;
+	LLViewerStats::instance().getRecording().stop();
 }
 
 
@@ -1158,8 +1164,8 @@ void send_agent_resume()
 		gMessageSystem->sendReliable(regionp->getHost());
 	}
 
-	// Reset the FPS counter to avoid an invalid fps
-	LLViewerStats::getInstance()->mFPSStat.reset();
+	// Resume data collection to ignore invalid rates
+	LLViewerStats::instance().getRecording().resume();//getInstance()->mFPSStat.reset();
 
 	LLAppViewer::instance()->resumeMainloopTimeout();
 }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 86791a37fb..4582de805f 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -488,7 +488,7 @@ void LLPipeline::init()
 	getPool(LLDrawPool::POOL_BUMP);
 	getPool(LLDrawPool::POOL_GLOW);
 
-	LLViewerStats::getInstance()->mTrianglesDrawnStat.reset();
+	//LLViewerStats::getInstance()->mTrianglesDrawnStat.reset();
 	resetFrameStats();
 
 	for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
@@ -1768,7 +1768,8 @@ void LLPipeline::resetFrameStats()
 {
 	assertInitialized();
 
-	LLViewerStats::getInstance()->mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f);
+	LLStatViewer::TRIANGLES_DRAWN.add(mTrianglesDrawn);
+	//LLViewerStats::getInstance()->mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f);
 
 	if (mBatchCount > 0)
 	{
-- 
cgit v1.2.3


From 0f58ca02cdec62711eadb82ba28fcff08faef2ee Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 12 Oct 2012 00:20:19 -0700
Subject: SH-3275 WIP Update viewer metrics system to be more flexible cleaned
 up accumulator merging logic introduced frame recording to LLTrace directly
 instead of going through LLViewerStats moved consumer code over to frame
 recording instead of whatever the current active recording was

---
 indra/newview/llviewerstats.cpp       | 2 ++
 indra/newview/llviewerstats.h         | 8 +++-----
 indra/newview/llviewertexturelist.cpp | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 11d9f5e1ec..bed2dffb14 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -497,6 +497,8 @@ void update_statistics()
 			texture_stats_timer.reset();
 		}
 	}
+
+	LLTrace::get_frame_recording().nextPeriod();
 }
 
 class ViewerStatsResponder : public LLHTTPClient::Responder
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index a14518f536..a164a28a59 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -412,14 +412,12 @@ public:
 	};
 
 	LLTrace::Recording& getRecording() { return mRecording; }
-	LLTrace::Recording& getFrameRecording() { return mFrameRecording; }
 
 private:
-	F64	mStats[ST_COUNT];
-	LLTrace::Recording	mRecording;
-	LLTrace::Recording	mFrameRecording;
+	F64								mStats[ST_COUNT];
+	LLTrace::Recording				mRecording;
 
-	F64 mLastTimeDiff;  // used for time stat updates
+	F64								mLastTimeDiff;  // used for time stat updates
 };
 
 static const F32 SEND_STATS_PERIOD = 300.0f;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 81c45cfb84..af28ea36eb 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -58,7 +58,7 @@
 #include "pipeline.h"
 #include "llappviewer.h"
 #include "llxuiparser.h"
-#include "lltracethreadrecorder.h"
+#include "lltracerecording.h"
 #include "llviewerdisplay.h"
 
 ////////////////////////////////////////////////////////////////////////////
@@ -621,9 +621,9 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 	cleared = FALSE;
 
-	LLTrace::Recording* recording = LLTrace::get_thread_recorder()->getPrimaryRecording();
+	LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording();
 
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording->getPerSec(LLStatViewer::TEXTURE_KBIT).value());
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording.getPerSec(LLStatViewer::TEXTURE_KBIT).value());
 
 	LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
 	LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
-- 
cgit v1.2.3


From 041dfccd1ea5b59c1b3c4e37e9a5495cad342c8f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 12 Oct 2012 20:17:52 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system default to
 double precision now fixed unit conversion logic for LLUnit renamed
 LLTrace::Rate to LLTrace::Count and got rid of the old count as it was
 confusing some const correctness changes

---
 indra/newview/lltexturefetch.cpp      |  2 +-
 indra/newview/llviewermessage.cpp     |  1 -
 indra/newview/llviewerstats.cpp       | 98 ++++++++++++++++++-----------------
 indra/newview/llviewerstats.h         | 86 +++++++++++++++---------------
 indra/newview/llviewertexturelist.cpp |  4 +-
 indra/newview/llworld.cpp             |  6 +--
 6 files changed, 100 insertions(+), 97 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 2ce5f95b54..f2caa01644 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2316,7 +2316,7 @@ S32 LLTextureFetch::update(F32 max_time_ms)
 
 	if(mCurlGetRequest)
 	{
-		LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits<F32> >(mCurlGetRequest->getTotalReceivedBits());
+		LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits>(mCurlGetRequest->getTotalReceivedBits());
 		//gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits();
 	}
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 79ed093382..ec7d91ec4f 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4772,7 +4772,6 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data)
 			//LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
 			break;
 		case LL_SIM_STAT_FRAMEMS:
-			//LLStatViewer::SIM_.sample(stat_value);
 			LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value);
 			break;
 		case LL_SIM_STAT_NETMS:
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index bed2dffb14..a3d04d655a 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -64,7 +64,7 @@
 namespace LLStatViewer
 {
 
-LLTrace::Rate<F32>	FPS("fpsstat"),
+LLTrace::Count<>	FPS("fpsstat"),
 					PACKETS_IN("packetsinstat"),
 					PACKETS_LOST("packetsloststat"),
 					PACKETS_OUT("packetsoutstat"),
@@ -90,7 +90,7 @@ LLTrace::Rate<F32>	FPS("fpsstat"),
 					FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"),
 					TEX_BAKES("texbakes"),
 					TEX_REBAKES("texrebakes");
-LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT("kbitstat"),
+LLTrace::Count<LLUnits::Kilobits>	KBIT("kbitstat"),
 									LAYERS_KBIT("layerskbitstat"),
 									OBJECT_KBIT("objectkbitstat"),
 									ASSET_KBIT("assetkbitstat"),
@@ -98,17 +98,17 @@ LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT("kbitstat"),
 									ACTUAL_IN_KBIT("actualinkbit"),
 									ACTUAL_OUT_KBIT("actualoutkbit");
 
-LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
-									 TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
-									 MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
-									 FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
-									 FPS_8_TIME("fps8time", "Seconds below 8 FPS"),
-									 FPS_2_TIME("fps2time", "Seconds below 2 FPS"),
-									 SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
-									 SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
-									 LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
-
-LLTrace::Measurement<F32>	SIM_TIME_DILATION("simtimedilation"),
+LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
+								TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
+								MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
+								FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
+								FPS_8_TIME("fps8time", "Seconds below 8 FPS"),
+								FPS_2_TIME("fps2time", "Seconds below 2 FPS"),
+								SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
+								SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
+								LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
+
+LLTrace::Measurement<>		SIM_TIME_DILATION("simtimedilation"),
 							SIM_FPS("simfps"),
 							SIM_PHYSICS_FPS("simphysicsfps"),
 							SIM_AGENT_UPS("simagentups"),
@@ -147,36 +147,36 @@ LLTrace::Measurement<F32>	SIM_TIME_DILATION("simtimedilation"),
 							WINDOW_WIDTH("windowwidth", "Window width"),
 							WINDOW_HEIGHT("windowheight", "Window height");
 
-LLTrace::Measurement<LLUnits::Bytes<F32> >	SIM_UNACKED_BYTES("simtotalunackedbytes"),
-											SIM_PHYSICS_MEM("physicsmemoryallocated"),
-											GL_TEX_MEM("gltexmemstat"),
-											GL_BOUND_MEM("glboundmemstat"),
-											RAW_MEM("rawmemstat"),
-											FORMATTED_MEM("formattedmemstat");
-
-
-LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME("simsimphysicsmsec"),
-											SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"),
-											SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"),
-											SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"),
-											SIM_AI_TIME("simsimaistepmsec"),
-											SIM_AGENTS_TIME("simagentmsec"),
-											SIM_IMAGES_TIME("simimagesmsec"),
-											SIM_SCRIPTS_TIME("simscriptmsec"),
-											SIM_SPARE_TIME("simsparemsec"),
-											SIM_SLEEP_TIME("simsleepmsec"),
-											SIM_PUMP_IO_TIME("simpumpiomsec"),
-											SIM_PING("simpingstat"),
-											FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
-											FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
-											LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
-											REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
-											FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
-											UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
-											NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
-											IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
-											REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
-											RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
+LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes"),
+										SIM_PHYSICS_MEM("physicsmemoryallocated"),
+										GL_TEX_MEM("gltexmemstat"),
+										GL_BOUND_MEM("glboundmemstat"),
+										RAW_MEM("rawmemstat"),
+										FORMATTED_MEM("formattedmemstat");
+
+
+LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME("simsimphysicsmsec"),
+										SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"),
+										SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"),
+										SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"),
+										SIM_AI_TIME("simsimaistepmsec"),
+										SIM_AGENTS_TIME("simagentmsec"),
+										SIM_IMAGES_TIME("simimagesmsec"),
+										SIM_SCRIPTS_TIME("simscriptmsec"),
+										SIM_SPARE_TIME("simsparemsec"),
+										SIM_SLEEP_TIME("simsleepmsec"),
+										SIM_PUMP_IO_TIME("simpumpiomsec"),
+										SIM_PING("simpingstat"),
+										FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+										FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
+										LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
+										REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
+										FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
+										UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
+										NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
+										IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
+										REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
+										RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
 }
 
 class StatAttributes
@@ -266,6 +266,7 @@ LLViewerStats::LLViewerStats() :
 	
 	mAgentPositionSnaps.reset();
 	mRecording.start();
+	LLTrace::get_frame_recording().start();
 }
 
 LLViewerStats::~LLViewerStats()
@@ -437,25 +438,28 @@ void update_statistics()
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
+		LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(cdp->getPingDelay());
 		stats.mSimPingStat.addValue(cdp->getPingDelay());
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
+		LLUnits::Seconds i(10000);
+		LLStatViewer::SIM_PING.sample(i);//<LLUnits::Seconds<U32> >(10000);
 		stats.mSimPingStat.addValue(10000);
 	}
 
 	//stats.mFPSStat.addValue(1);
 	LLStatViewer::FPS.add(1);
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits<F32> >(layer_bits);
+	LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits>(layer_bits);
 	//stats.mLayersKBitStat.addValue(layer_bits/1024.f);
-	LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits<F32> >(gObjectBits);
+	LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits>(gObjectBits);
 	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
 	//stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
 	LLStatViewer::SIM_PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending());
-	LLStatViewer::ASSET_KBIT.add<LLUnits::Bits<F32> >(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
+	LLStatViewer::ASSET_KBIT.add<LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
 	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
@@ -493,7 +497,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			gTotalTextureBytes = LLUnits::Bytes<F32>(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value();
+			gTotalTextureBytes = LLUnits::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value();
 			texture_stats_timer.reset();
 		}
 	}
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index a164a28a59..5412294cf2 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -34,7 +34,7 @@
 
 namespace LLStatViewer
 {
-extern LLTrace::Rate<F32>					FPS,
+extern LLTrace::Count<>						FPS,
 											PACKETS_IN,
 											PACKETS_LOST,
 											PACKETS_OUT,
@@ -62,7 +62,7 @@ extern LLTrace::Rate<F32>					FPS,
 											TEX_REBAKES;
 
 
-extern LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT,
+extern LLTrace::Count<LLUnits::Kilobits>	KBIT,
 											LAYERS_KBIT,
 											OBJECT_KBIT,
 											ASSET_KBIT,
@@ -70,17 +70,17 @@ extern LLTrace::Rate<LLUnits::Bytes<F32> >	KBIT,
 											ACTUAL_IN_KBIT,
 											ACTUAL_OUT_KBIT;
 
-extern LLTrace::Rate<LLUnits::Seconds<F32> > AVATAR_EDIT_TIME,
-											 TOOLBOX_TIME,
-											 MOUSELOOK_TIME,
-											 FPS_10_TIME,
-											 FPS_8_TIME,
-											 FPS_2_TIME,
-											 SIM_20_FPS_TIME,
-											 SIM_PHYSICS_20_FPS_TIME,
-											 LOSS_5_PERCENT_TIME;
-
-extern LLTrace::Measurement<F32>			SIM_TIME_DILATION,
+extern LLTrace::Count<LLUnits::Seconds>		AVATAR_EDIT_TIME,
+											TOOLBOX_TIME,
+											MOUSELOOK_TIME,
+											FPS_10_TIME,
+											FPS_8_TIME,
+											FPS_2_TIME,
+											SIM_20_FPS_TIME,
+											SIM_PHYSICS_20_FPS_TIME,
+											LOSS_5_PERCENT_TIME;
+
+extern LLTrace::Measurement<>				SIM_TIME_DILATION,
 											SIM_FPS,
 											SIM_PHYSICS_FPS,
 											SIM_AGENT_UPS,
@@ -119,36 +119,36 @@ extern LLTrace::Measurement<F32>			SIM_TIME_DILATION,
 											WINDOW_WIDTH,
 											WINDOW_HEIGHT;
 
-extern LLTrace::Measurement<LLUnits::Bytes<F32> >	SIM_UNACKED_BYTES,
-													SIM_PHYSICS_MEM,
-													GL_TEX_MEM,
-													GL_BOUND_MEM,
-													RAW_MEM,
-													FORMATTED_MEM;
-
-
-extern LLTrace::Measurement<LLUnits::Seconds<F32> > SIM_PHYSICS_TIME,
-													SIM_PHYSICS_STEP_TIME,
-													SIM_PHYSICS_SHAPE_UPDATE_TIME,
-													SIM_PHYSICS_OTHER_TIME,
-													SIM_AI_TIME,
-													SIM_AGENTS_TIME,
-													SIM_IMAGES_TIME,
-													SIM_SCRIPTS_TIME,
-													SIM_SPARE_TIME,
-													SIM_SLEEP_TIME,
-													SIM_PUMP_IO_TIME,
-													SIM_PING,
-													FRAMETIME_JITTER,
-													FRAMETIME_SLEW,
-													LOGIN_SECONDS,
-													REGION_CROSSING_TIME,
-													FRAME_STACKTIME,
-													UPDATE_STACKTIME,
-													NETWORK_STACKTIME,
-													IMAGE_STACKTIME,
-													REBUILD_STACKTIME,
-													RENDER_STACKTIME;
+extern LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES,
+											SIM_PHYSICS_MEM,
+											GL_TEX_MEM,
+											GL_BOUND_MEM,
+											RAW_MEM,
+											FORMATTED_MEM;
+
+
+extern LLTrace::Measurement<LLUnits::Seconds>	SIM_PHYSICS_TIME,
+												SIM_PHYSICS_STEP_TIME,
+												SIM_PHYSICS_SHAPE_UPDATE_TIME,
+												SIM_PHYSICS_OTHER_TIME,
+												SIM_AI_TIME,
+												SIM_AGENTS_TIME,
+												SIM_IMAGES_TIME,
+												SIM_SCRIPTS_TIME,
+												SIM_SPARE_TIME,
+												SIM_SLEEP_TIME,
+												SIM_PUMP_IO_TIME,
+												SIM_PING,
+												FRAMETIME_JITTER,
+												FRAMETIME_SLEW,
+												LOGIN_SECONDS,
+												REGION_CROSSING_TIME,
+												FRAME_STACKTIME,
+												UPDATE_STACKTIME,
+												NETWORK_STACKTIME,
+												IMAGE_STACKTIME,
+												REBUILD_STACKTIME,
+												RENDER_STACKTIME;
 }
 
 class LLViewerStats : public LLSingleton<LLViewerStats>
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index af28ea36eb..ccfedd8881 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -1325,7 +1325,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size);
+	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size);
 	LLStatViewer::TEXTURE_PACKETS.add(1);
 	
 	U8 codec;
@@ -1399,7 +1399,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 		received_size = msg->getReceiveSize() ;		
 	}
 
-	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes<F32> >(received_size);
+	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size);
 	LLStatViewer::TEXTURE_PACKETS.add(1);
 	
 	//llprintline("Start decode, image header...");
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 056132c165..9e495c46b1 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -703,11 +703,11 @@ void LLWorld::updateNetStats()
 	S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 
-	LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits<F32> >(actual_in_bits);
-	LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits<F32> >(actual_out_bits);
+	LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits>(actual_in_bits);
+	LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits>(actual_out_bits);
 	//LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
 	//LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
-	LLStatViewer::KBIT.add<LLUnits::Bits<F32> >(bits);
+	LLStatViewer::KBIT.add<LLUnits::Bits>(bits);
 	//LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
 	LLStatViewer::PACKETS_IN.add(packets_in);
 	LLStatViewer::PACKETS_OUT.add(packets_out);
-- 
cgit v1.2.3


From 8d2f7a526545a10cd3669bf837a0b6f02cf5fe71 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 15 Oct 2012 19:43:35 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system converted all
 remaining LLViewerStats to lltrace

---
 indra/newview/llagent.cpp             |   8 +-
 indra/newview/llappviewer.cpp         |   3 +-
 indra/newview/llchatbar.cpp           |  18 --
 indra/newview/llcompilequeue.cpp      |   2 +-
 indra/newview/llfloaterabout.cpp      |   3 +-
 indra/newview/llfloaterregioninfo.cpp |   2 +-
 indra/newview/llfloatersnapshot.cpp   |   3 +-
 indra/newview/llgesturemgr.cpp        |   2 +-
 indra/newview/lllandmarklist.cpp      |   2 +-
 indra/newview/llnearbychatbar.cpp     |   3 +-
 indra/newview/llpanelface.cpp         |   3 +-
 indra/newview/llpreviewgesture.cpp    |   2 +-
 indra/newview/llpreviewnotecard.cpp   |   2 +-
 indra/newview/llpreviewscript.cpp     |  11 +-
 indra/newview/llselectmgr.cpp         |   7 +-
 indra/newview/llstartup.cpp           |   3 +-
 indra/newview/llstatusbar.cpp         |   4 +-
 indra/newview/lltexlayer.cpp          |   3 +-
 indra/newview/lltooldraganddrop.cpp   |   9 +-
 indra/newview/lltoolplacer.cpp        |   3 +-
 indra/newview/llviewermenu.cpp        |  66 -------
 indra/newview/llviewermenufile.cpp    |  24 ++-
 indra/newview/llviewermessage.cpp     | 264 ++++++++++++++------------
 indra/newview/llviewerobject.cpp      |   3 +-
 indra/newview/llviewerobjectlist.cpp  |  12 +-
 indra/newview/llviewerstats.cpp       | 344 +++++++++++++---------------------
 indra/newview/llviewerstats.h         | 221 ++++++----------------
 indra/newview/llviewertexturelist.cpp |  21 +--
 indra/newview/llviewertexturelist.h   |  10 +-
 indra/newview/llviewerthrottle.cpp    |   5 +-
 indra/newview/llviewerwindow.cpp      |   6 +-
 indra/newview/llvoavatarself.cpp      |  21 ++-
 indra/newview/llwearablelist.cpp      |   2 +-
 indra/newview/llworld.cpp             |   8 +-
 34 files changed, 438 insertions(+), 662 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 447836910d..a41efbe0b2 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -753,7 +753,8 @@ void LLAgent::setFlying(BOOL fly)
 		}
 		if( !was_flying )
 		{
-			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT);
+			LLStatViewer::FLY.add(1);
+			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT);
 		}
 		setControlFlags(AGENT_CONTROL_FLY);
 	}
@@ -3809,7 +3810,8 @@ bool LLAgent::teleportCore(bool is_local)
 	gAgentCamera.resetView(FALSE);
 
 	// local logic
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT);
+	LLStatViewer::TELEPORT.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT);
 	if (is_local)
 	{
 		gAgent.setTeleportState( LLAgent::TELEPORT_LOCAL );
@@ -4120,7 +4122,7 @@ void LLAgent::setTeleportState(ETeleportState state)
 
 		case TELEPORT_ARRIVING:
 		// First two position updates after a teleport tend to be weird
-		LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2;
+		//LLViewerStats::getInstance()->mAgentPositionSnaps.mCountOfNextUpdatesToIgnore = 2;
 
 		// Let the interested parties know we've teleported.
 		LLViewerParcelMgr::getInstance()->onTeleportFinished(false, getPositionGlobal());
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index a43776912c..6e0b298b2a 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4810,7 +4810,8 @@ void LLAppViewer::idleNetwork()
 			gPrintMessagesThisFrame = FALSE;
 		}
 	}
-	LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects);
+	LLStatViewer::NUM_NEW_OBJECTS.sample(gObjectList.mNumNewObjects);
+	//LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects);
 
 	// Retransmit unacknowledged packets.
 	gXferManager->retransmitUnackedPackets();
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index d6095cce07..f6bad18070 100644
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -618,24 +618,6 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL
 
 	send_chat_from_viewer(utf8_out_text, type, channel);
 }
-/*
-void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel)
-{
-	LLMessageSystem* msg = gMessageSystem;
-	msg->newMessageFast(_PREHASH_ChatFromViewer);
-	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->nextBlockFast(_PREHASH_ChatData);
-	msg->addStringFast(_PREHASH_Message, utf8_out_text);
-	msg->addU8Fast(_PREHASH_Type, type);
-	msg->addS32("Channel", channel);
-
-	gAgent.sendReliableMessage();
-
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
-}
-*/
 
 void LLChatBar::onCommitGesture(LLUICtrl* ctrl)
 {
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 4f5f9e22b6..6739910c38 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -436,7 +436,7 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 	}
 	else
 	{
-		LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
 		{
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 83fb887d81..58701ca3c9 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -296,7 +296,8 @@ LLSD LLFloaterAbout::getInfo()
 
 	if (gPacketsIn > 0)
 	{
-		info["PACKETS_LOST"] = LLViewerStats::getInstance()->mPacketsLostStat.getCurrent();
+		LLTrace::Recording cur_frame = LLTrace::get_frame_recording().snapshotCurRecordingPeriod();
+		info["PACKETS_LOST"] = cur_frame.getSum(LLStatViewer::PACKETS_LOST);
 		info["PACKETS_IN"] = F32(gPacketsIn);
 		info["PACKETS_PCT"] = 100.f*info["PACKETS_LOST"].asReal() / info["PACKETS_IN"].asReal();
 	}
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index fe29bb38c7..8234841966 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -2491,7 +2491,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 		}
 		else
 		{
-			LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index d8d62e5bbb..4a58e0186c 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -992,7 +992,8 @@ void LLSnapshotLivePreview::saveTexture()
 		llwarns << "Error encoding snapshot" << llendl;
 	}
 
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT );
+	LLStatViewer::SNAPSHOT.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT );
 	
 	mDataSize = 0;
 }
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 66ca76bfb0..63ef8c3d21 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -1137,7 +1137,7 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs,
 	}
 	else
 	{
-		LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 			LL_ERR_FILE_EMPTY == status)
diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp
index dd402de394..1666425cbe 100644
--- a/indra/newview/lllandmarklist.cpp
+++ b/indra/newview/lllandmarklist.cpp
@@ -141,7 +141,7 @@ void LLLandmarkList::processGetAssetReply(
 	}
 	else
 	{
-		LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 		// SJB: No use case for a notification here. Use lldebugs instead
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
 		{
diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index c00dc4bc89..0aced5c575 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -638,7 +638,8 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32
 
 	gAgent.sendReliableMessage();
 
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
+	LLStatViewer::CHAT_COUNT.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
 }
 
 class LLChatCommandHandler : public LLCommandHandler
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 202be9671b..52ed24f06d 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -1049,7 +1049,8 @@ BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item)
 
 void LLPanelFace::onCommitTexture( const LLSD& data )
 {
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
+	LLStatViewer::EDIT_TEXTURE.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 	sendTexture();
 }
 
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index f47928b131..4082d272f2 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -883,7 +883,7 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs,
 		}
 		else
 		{
-			LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index 3a9360fd23..b93b97f1e0 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -339,7 +339,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 		}
 		else
 		{
-			LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 88727bf59b..059d5d4061 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -942,7 +942,8 @@ void LLScriptEdCore::onBtnInsertFunction(LLUICtrl *ui, void* userdata)
 
 void LLScriptEdCore::doSave( BOOL close_after_save )
 {
-	LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
+	LLStatViewer::LSL_SAVES.add(1);
+	//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
 
 	if( mSaveCallback )
 	{
@@ -1146,8 +1147,8 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data )
 
 void LLScriptEdCore::onBtnSaveToFile( void* userdata )
 {
-
-	LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
+	LLStatViewer::LSL_SAVES.add(1);
+	//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
 
 	LLScriptEdCore* self = (LLScriptEdCore*) userdata;
 
@@ -1670,7 +1671,7 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset
 		}
 		else
 		{
-			LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
@@ -1902,7 +1903,7 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
 		}
 		else
 		{
-			LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index c3c37141ed..fd03d7c0be 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1550,7 +1550,8 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item)
 				}
 
 				// apply texture for the selected faces
-				LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
+				LLStatViewer::EDIT_TEXTURE.add(1);
+				//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 				object->setTEImage(te, image);
 				dialog_refresh_all();
 
@@ -3424,9 +3425,7 @@ bool LLSelectMgr::confirmDelete(const LLSD& notification, const LLSD& response,
 			gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
 
 			// Keep track of how many objects have been deleted.
-			F64 obj_delete_count = LLViewerStats::getInstance()->getStat(LLViewerStats::ST_OBJECT_DELETE_COUNT);
-			obj_delete_count += LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount();
-			LLViewerStats::getInstance()->setStat(LLViewerStats::ST_OBJECT_DELETE_COUNT, obj_delete_count );
+			LLStatViewer::DELETE_OBJECT.add(LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount());
 		}
 		break;
 	case 1:
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 1e7c325d30..cb3c90ea2a 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2071,7 +2071,8 @@ bool idle_startup()
 		if (wearables_time > MAX_WEARABLES_TIME)
 		{
 			LLNotificationsUtil::add("ClothingLoading");
-			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG);
+			LLStatViewer::LOADING_WEARABLES_LONG_DELAY.add(1);
+			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG);
 			LLStartUp::setStartupState( STATE_CLEANUP );
 			return TRUE;
 		}
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 6f2a0de894..5720395d05 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild()
 	sgp.rect(r);
 	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	sgp.mouse_opaque(false);
-	sgp.stat.rate_stat(&LLStatViewer::KBIT);
+	sgp.stat.count_stat(&LLStatViewer::KBIT);
 	sgp.units("Kbps");
 	sgp.precision(0);
 	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
@@ -212,7 +212,7 @@ BOOL LLStatusBar::postBuild()
 	pgp.rect(r);
 	pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	pgp.mouse_opaque(false);
-	pgp.stat.legacy_stat(&LLViewerStats::getInstance()->mPacketsLostPercentStat);
+	pgp.stat.measurement_stat(&LLStatViewer::PACKETS_LOST_PERCENT);
 	pgp.units("%");
 	pgp.min(0.f);
 	pgp.max(5.f);
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index 467115c928..e354a5c59d 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -460,7 +460,8 @@ BOOL LLTexLayerSetBuffer::requestUpdateImmediate()
 void LLTexLayerSetBuffer::doUpload()
 {
 	llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl;
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES);
+	LLStatViewer::TEX_BAKES.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES);
 
 	// Don't need caches since we're baked now.  (note: we won't *really* be baked 
 	// until this image is sent to the server and the Avatar Appearance message is received.)
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index c69999981c..791da59a1a 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1062,7 +1062,8 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
 		return;
 	}
 	LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
+	LLStatViewer::EDIT_TEXTURE.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 	S32 num_faces = hit_obj->getNumTEs();
 	for( S32 face = 0; face < num_faces; face++ )
 	{
@@ -1130,7 +1131,8 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
 	}
 	// update viewer side image in anticipation of update from simulator
 	LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
+	LLStatViewer::EDIT_TEXTURE.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 	hit_obj->setTEImage(hit_face, image);
 	dialog_refresh_all();
 
@@ -1354,7 +1356,8 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
 
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_REZ_COUNT);
+	LLStatViewer::OBJECT_REZ.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_REZ_COUNT);
 }
 
 void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj,
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index 93ba3b2558..cf5a6e3762 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -433,7 +433,8 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
 
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CREATE_COUNT);
+	LLStatViewer::OBJECT_CREATE.add(1);
+	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CREATE_COUNT);
 
 	return TRUE;
 }
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 4ec498dc33..219e01fe81 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -3973,72 +3973,6 @@ void handle_duplicate_in_place(void*)
 	LLSelectMgr::getInstance()->selectDuplicate(offset, TRUE);
 }
 
-/* dead code 30-apr-2008
-void handle_deed_object_to_group(void*)
-{
-	LLUUID group_id;
-	
-	LLSelectMgr::getInstance()->selectGetGroup(group_id);
-	LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
-	LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
-}
-
-BOOL enable_deed_object_to_group(void*)
-{
-	if(LLSelectMgr::getInstance()->getSelection()->isEmpty()) return FALSE;
-	LLPermissions perm;
-	LLUUID group_id;
-
-	if (LLSelectMgr::getInstance()->selectGetGroup(group_id) &&
-		gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) &&
-		LLSelectMgr::getInstance()->selectGetPermissions(perm) &&
-		perm.deedToGroup(gAgent.getID(), group_id))
-	{
-		return TRUE;
-	}
-	return FALSE;
-}
-
-*/
-
-
-/*
- * No longer able to support viewer side manipulations in this way
- *
-void god_force_inv_owner_permissive(LLViewerObject* object,
-									LLInventoryObject::object_list_t* inventory,
-									S32 serial_num,
-									void*)
-{
-	typedef std::vector<LLPointer<LLViewerInventoryItem> > item_array_t;
-	item_array_t items;
-
-	LLInventoryObject::object_list_t::const_iterator inv_it = inventory->begin();
-	LLInventoryObject::object_list_t::const_iterator inv_end = inventory->end();
-	for ( ; inv_it != inv_end; ++inv_it)
-	{
-		if(((*inv_it)->getType() != LLAssetType::AT_CATEGORY))
-		{
-			LLInventoryObject* obj = *inv_it;
-			LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem((LLViewerInventoryItem*)obj);
-			LLPermissions perm(new_item->getPermissions());
-			perm.setMaskBase(PERM_ALL);
-			perm.setMaskOwner(PERM_ALL);
-			new_item->setPermissions(perm);
-			items.push_back(new_item);
-		}
-	}
-	item_array_t::iterator end = items.end();
-	item_array_t::iterator it;
-	for(it = items.begin(); it != end; ++it)
-	{
-		// since we have the inventory item in the callback, it should not
-		// invalidate iteration through the selection manager.
-		object->updateInventory((*it), TASK_INVENTORY_ITEM_KEY, false);
-	}
-}
-*/
-
 void handle_object_owner_permissive(void*)
 {
 	// only send this if they're a god.
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index be78603e2d..7ce8cdcfd8 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -1096,17 +1096,20 @@ void upload_new_resource(
 	
 	if( LLAssetType::AT_SOUND == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT );
+		LLStatViewer::UPLOAD_SOUND.add(1);
+		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT );
 	}
 	else
 	if( LLAssetType::AT_TEXTURE == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
+		LLStatViewer::UPLOAD_TEXTURE.add(1);
+		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
 	}
 	else
 	if( LLAssetType::AT_ANIMATION == asset_type)
 	{
-		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT );
+		LLStatViewer::ANIMATION_UPLOADS.add(1);
+		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT );
 	}
 
 	if(LLInventoryType::IT_NONE == inv_type)
@@ -1231,18 +1234,21 @@ void increase_new_upload_stats(LLAssetType::EType asset_type)
 {
 	if ( LLAssetType::AT_SOUND == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(
-			LLViewerStats::ST_UPLOAD_SOUND_COUNT );
+		LLStatViewer::UPLOAD_SOUND.add(1);
+		//LLViewerStats::getInstance()->incStat(
+		//	LLViewerStats::ST_UPLOAD_SOUND_COUNT );
 	}
 	else if ( LLAssetType::AT_TEXTURE == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(
-			LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
+		LLStatViewer::UPLOAD_TEXTURE.add(1);
+		//LLViewerStats::getInstance()->incStat(
+		//	LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
 	}
 	else if ( LLAssetType::AT_ANIMATION == asset_type )
 	{
-		LLViewerStats::getInstance()->incStat(
-			LLViewerStats::ST_UPLOAD_ANIM_COUNT );
+		LLStatViewer::ANIMATION_UPLOADS.add(1);
+		//LLViewerStats::getInstance()->incStat(
+		//	LLViewerStats::ST_UPLOAD_ANIM_COUNT );
 	}
 }
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index ec7d91ec4f..b3e1c9bdbe 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4753,125 +4753,150 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data)
 		F32 stat_value;
 		msg->getU32("Stat", "StatID", stat_id, i);
 		msg->getF32("Stat", "StatValue", stat_value, i);
-		switch (stat_id)
+		LLStatViewer::SimMeasurementSampler* measurementp = LLStatViewer::SimMeasurementSampler::getInstance((ESimStatID)stat_id);
+		
+		if (measurementp )
 		{
-		case LL_SIM_STAT_TIME_DILATION:
-			LLStatViewer::SIM_TIME_DILATION.sample(stat_value);
-			//LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_FPS:
-			LLStatViewer::SIM_FPS.sample(stat_value);
-			//LLViewerStats::getInstance()->mSimFPS.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_PHYSFPS:
-			LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value);
-			//LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_AGENTUPS:
-			LLStatViewer::SIM_AGENT_UPS.sample(stat_value);
-			//LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_FRAMEMS:
-			LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_NETMS:
-			LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMOTHERMS:
-			LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMPHYSICSMS:
-			LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_AGENTMS:
-			LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_IMAGESMS:
-			LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SCRIPTMS:
-			LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_NUMTASKS:
-			LLViewerStats::getInstance()->mSimObjects.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_NUMTASKSACTIVE:
-			LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_NUMAGENTMAIN:
-			LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_NUMAGENTCHILD:
-			LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_NUMSCRIPTSACTIVE:
-			LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SCRIPT_EPS:
-			LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_INPPS:
-			LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_OUTPPS:
-			LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_PENDING_DOWNLOADS:
-			LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_PENDING_UPLOADS:
-			LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_PENDING_LOCAL_UPLOADS:
-			LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_TOTAL_UNACKED_BYTES:
-			LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f);
-			break;
-		case LL_SIM_STAT_PHYSICS_PINNED_TASKS:
-			LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_PHYSICS_LOD_TASKS:
-			LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMPHYSICSSTEPMS:
-			LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMPHYSICSSHAPEMS:
-			LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMPHYSICSOTHERMS:
-			LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMPHYSICSMEMORY:
-			LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMSPARETIME:
-			LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMSLEEPTIME:
-			LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_IOPUMPTIME:
-			LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_PCTSCRIPTSRUN:
-			LLViewerStats::getInstance()->mSimPctScriptsRun.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SIMAISTEPTIMEMS:
-			LLViewerStats::getInstance()->mSimSimAIStepMsec.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_SKIPPEDAISILSTEPS_PS:
-			LLViewerStats::getInstance()->mSimSimSkippedSilhouetteSteps.addValue(stat_value);
-			break;
-		case LL_SIM_STAT_PCTSTEPPEDCHARACTERS:
-			LLViewerStats::getInstance()->mSimSimPctSteppedCharacters.addValue(stat_value);
-			break;
-		default:
-			// Used to be a commented out warning.
- 			LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL;
-		  break;
+			measurementp->sample(stat_value);
 		}
+		else
+		{
+			llwarns << "Unknown sim stat identifier: " << stat_id << llendl;
+		}
+		//switch (stat_id)
+		//{
+		//case LL_SIM_STAT_TIME_DILATION:
+		//	LLStatViewer::SIM_TIME_DILATION.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_FPS:
+		//	LLStatViewer::SIM_FPS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimFPS.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_PHYSFPS:
+		//	LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_AGENTUPS:
+		//	LLStatViewer::SIM_AGENT_UPS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_FRAMEMS:
+		//	LLStatViewer::SIM_FRAME_TIME.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_NETMS:
+		//	LLStatViewer::SIM_NET_TIME.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMOTHERMS:
+		//	LLStatViewer::SIM_PHYSICS_OTHER_TIME.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMPHYSICSMS:
+		//	LLStatViewer::SIM_PHYSICS_TIME.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_AGENTMS:
+		//	LLStatViewer::SIM_AGENTS_TIME.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_IMAGESMS:
+		//	LLStatViewer::SIM_IMAGES_TIME.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SCRIPTMS:
+		//	LLStatViewer::SIM_SCRIPTS_TIME.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_NUMTASKS:
+		//	LLStatViewer::SIM_OBJECTS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimObjects.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_NUMTASKSACTIVE:
+		//	LLStatViewer::SIM_ACTIVE_OBJECTS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_NUMAGENTMAIN:
+		//	LLStatViewer::SIM_MAIN_AGENTS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_NUMAGENTCHILD:
+		//	LLStatViewer::SIM_CHILD_AGENTS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_NUMSCRIPTSACTIVE:
+		//	LLStatViewer::SIM_ACTIVE_SCRIPTS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SCRIPT_EPS:
+		//	LLStatViewer::SIM_SCRIPT_EPS.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_INPPS:
+		//	LLStatViewer::SIM_IN_PACKETS_PER_SEC.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_OUTPPS:
+		//	LLStatViewer::SIM_OUT_PACKETS_PER_SEC.sample(stat_value);
+		//	//LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_PENDING_DOWNLOADS:
+		//	LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_PENDING_UPLOADS:
+		//	LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_PENDING_LOCAL_UPLOADS:
+		//	LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_TOTAL_UNACKED_BYTES:
+		//	LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f);
+		//	break;
+		//case LL_SIM_STAT_PHYSICS_PINNED_TASKS:
+		//	LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_PHYSICS_LOD_TASKS:
+		//	LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMPHYSICSSTEPMS:
+		//	LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMPHYSICSSHAPEMS:
+		//	LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMPHYSICSOTHERMS:
+		//	LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMPHYSICSMEMORY:
+		//	LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMSPARETIME:
+		//	LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMSLEEPTIME:
+		//	LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_IOPUMPTIME:
+		//	LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_PCTSCRIPTSRUN:
+		//	LLViewerStats::getInstance()->mSimPctScriptsRun.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SIMAISTEPTIMEMS:
+		//	LLViewerStats::getInstance()->mSimSimAIStepMsec.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_SKIPPEDAISILSTEPS_PS:
+		//	LLViewerStats::getInstance()->mSimSimSkippedSilhouetteSteps.addValue(stat_value);
+		//	break;
+		//case LL_SIM_STAT_PCTSTEPPEDCHARACTERS:
+		//	LLViewerStats::getInstance()->mSimSimPctSteppedCharacters.addValue(stat_value);
+		//	break;
+		//default:
+		//	// Used to be a commented out warning.
+ 	//		LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL;
+		//  break;
+		//}
 	}
 
 	/*
@@ -5942,7 +5967,8 @@ void process_alert_core(const std::string& message, BOOL modal)
 	// HACK -- handle callbacks for specific alerts. It also is localized in notifications.xml
 	if ( message == "You died and have been teleported to your home location")
 	{
-		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT);
+		LLStatViewer::KILLED.add(1);
+		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT);
 	}
 	else if( message == "Home position set." )
 	{
@@ -7369,7 +7395,7 @@ void onCovenantLoadComplete(LLVFS *vfs,
 	}
 	else
 	{
-		LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 		
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 		    LL_ERR_FILE_EMPTY == status)
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index aba1d131e1..989a1c4e5a 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2033,7 +2033,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		// If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps
 		if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
 		{
-			LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() );
+			LLStatViewer::AGENT_POSITION_SNAP.sample<LLUnits::Meters>(diff.length());
+			//LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() );
 		}
 	}
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 88bb087742..2f171f89d7 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1029,10 +1029,14 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	}
 	*/
 
-	LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size());
-	LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(idle_count);
-	LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled);
-	LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled);
+	LLStatViewer::NUM_OBJECTS.sample(mObjects.size());
+	LLStatViewer::NUM_ACTIVE_OBJECTS.sample(idle_count);
+	LLStatViewer::NUM_SIZE_CULLED.sample(mNumSizeCulled);
+	LLStatViewer::NUM_VIS_CULLED.sample(mNumVisCulled);
+	//LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size());
+	//LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(idle_count);
+	//LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled);
+	//LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled);
 }
 
 void LLViewerObjectList::fetchObjectCosts()
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index a3d04d655a..f0ad04e0ba 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -76,7 +76,6 @@ LLTrace::Count<>	FPS("fpsstat"),
 					OBJECT_REZ("objectrez", "Object rez count"),
 					LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load"),
 					LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"),
-					FAILED_DOWNLOADS("faileddownloads", "Number of times LLAssetStorage::getAssetData() has failed"),
 					LSL_SAVES("lslsaves", "Number of times user has saved a script"),
 					ANIMATION_UPLOADS("animationuploads", "Animations uploaded"),
 					FLY("fly", "Fly count"),
@@ -108,28 +107,28 @@ LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in
 								SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
 								LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
 
-LLTrace::Measurement<>		SIM_TIME_DILATION("simtimedilation"),
-							SIM_FPS("simfps"),
-							SIM_PHYSICS_FPS("simphysicsfps"),
-							SIM_AGENT_UPS("simagentups"),
-							SIM_SCRIPT_EPS("simscripteps"),
-							SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps"),
-							SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters"),
-							SIM_MAIN_AGENTS("simmainagents"),
-							SIM_CHILD_AGENTS("simchildagents"),
-							SIM_OBJECTS("simobjects"),
-							SIM_ACTIVE_OBJECTS("simactiveobjects"),
-							SIM_ACTIVE_SCRIPTS("simactivescripts"),
-							SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun"),
-							SIM_IN_PACKETS_PER_SEC("siminpps"),
-							SIM_OUT_PACKETS_PER_SEC("simoutpps"),
-							SIM_PENDING_DOWNLOADS("simpendingdownloads"),
-							SIM_PENDING_UPLOADS("simpendinguploads"),
-							SIM_PENDING_LOCAL_UPLOADS("simpendinglocaluploads"),
-							SIM_PENDING_VFS_OPERATIONS("vfspendingoperations"), 
-							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks"),
-							SIM_PHYSICS_LOD_TASKS("physicslodtasks"),
-							NUM_IMAGES("numimagesstat"),
+SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DILATION),
+							SIM_FPS("simfps", "", LL_SIM_STAT_FPS),
+							SIM_PHYSICS_FPS("simphysicsfps", "", LL_SIM_STAT_PHYSFPS),
+							SIM_AGENT_UPS("simagentups", "", LL_SIM_STAT_AGENTUPS),
+							SIM_SCRIPT_EPS("simscripteps", "", LL_SIM_STAT_SCRIPT_EPS),
+							SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps", "", LL_SIM_STAT_SKIPPEDAISILSTEPS_PS),
+							SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters", "", LL_SIM_STAT_PCTSTEPPEDCHARACTERS),
+							SIM_MAIN_AGENTS("simmainagents", "", LL_SIM_STAT_NUMAGENTMAIN),
+							SIM_CHILD_AGENTS("simchildagents", "", LL_SIM_STAT_NUMAGENTCHILD),
+							SIM_OBJECTS("simobjects", "", LL_SIM_STAT_NUMTASKS),
+							SIM_ACTIVE_OBJECTS("simactiveobjects", "", LL_SIM_STAT_NUMTASKSACTIVE),
+							SIM_ACTIVE_SCRIPTS("simactivescripts", "", LL_SIM_STAT_NUMSCRIPTSACTIVE),
+							SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun", "", LL_SIM_STAT_PCTSCRIPTSRUN),
+							SIM_IN_PACKETS_PER_SEC("siminpps", "", LL_SIM_STAT_INPPS),
+							SIM_OUT_PACKETS_PER_SEC("simoutpps", "", LL_SIM_STAT_OUTPPS),
+							SIM_PENDING_DOWNLOADS("simpendingdownloads", "", LL_SIM_STAT_PENDING_DOWNLOADS),
+							SIM_PENDING_UPLOADS("simpendinguploads", "", LL_SIM_STAT_PENDING_UPLOADS),
+							SIM_PENDING_LOCAL_UPLOADS("simpendinglocaluploads", "", LL_SIM_STAT_PENDING_LOCAL_UPLOADS),
+							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS),
+							SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS);
+
+LLTrace::Measurement<>		NUM_IMAGES("numimagesstat"),
 							NUM_RAW_IMAGES("numrawimagesstat"),
 							NUM_OBJECTS("numobjectsstat"),
 							NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
@@ -137,134 +136,61 @@ LLTrace::Measurement<>		SIM_TIME_DILATION("simtimedilation"),
 							NUM_SIZE_CULLED("numsizeculledstat"),
 							NUM_VIS_CULLED("numvisculledstat"),
 							ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
-							DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
-							MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting"),
 							LIGHTING_DETAIL("lightingdetail", "Lighting Detail"),
 							VISIBLE_AVATARS("visibleavatars", "Visible Avatars"),
 							SHADER_OBJECTS("shaderobjects", "Object Shaders"),
 							DRAW_DISTANCE("drawdistance", "Draw Distance"),
 							CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"),
+							PENDING_VFS_OPERATIONS("vfspendingoperations"), 
+							PACKETS_LOST_PERCENT("packetslostpercentstat"),
 							WINDOW_WIDTH("windowwidth", "Window width"),
 							WINDOW_HEIGHT("windowheight", "Window height");
 
+LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
+
+
 LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes"),
 										SIM_PHYSICS_MEM("physicsmemoryallocated"),
 										GL_TEX_MEM("gltexmemstat"),
 										GL_BOUND_MEM("glboundmemstat"),
 										RAW_MEM("rawmemstat"),
-										FORMATTED_MEM("formattedmemstat");
-
-
-LLTrace::Measurement<LLUnits::Seconds> SIM_PHYSICS_TIME("simsimphysicsmsec"),
-										SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec"),
-										SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec"),
-										SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec"),
-										SIM_AI_TIME("simsimaistepmsec"),
-										SIM_AGENTS_TIME("simagentmsec"),
-										SIM_IMAGES_TIME("simimagesmsec"),
-										SIM_SCRIPTS_TIME("simscriptmsec"),
-										SIM_SPARE_TIME("simsparemsec"),
-										SIM_SLEEP_TIME("simsleepmsec"),
-										SIM_PUMP_IO_TIME("simpumpiomsec"),
-										SIM_PING("simpingstat"),
-										FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
-										FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
-										LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
-										REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
-										FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
-										UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
-										NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
-										IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
-										REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
-										RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
-}
+										FORMATTED_MEM("formattedmemstat"),
+										DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
+										MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
+
+
+SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
+										SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS),
+										SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS),
+										SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS),
+										SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec", "", LL_SIM_STAT_SIMPHYSICSSTEPMS),
+										SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec", "", LL_SIM_STAT_SIMPHYSICSSHAPEMS),
+										SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec", "", LL_SIM_STAT_SIMPHYSICSOTHERMS),
+										SIM_AI_TIME("simsimaistepmsec", "", LL_SIM_STAT_SIMAISTEPTIMEMS),
+										SIM_AGENTS_TIME("simagentmsec", "", LL_SIM_STAT_AGENTMS),
+										SIM_IMAGES_TIME("simimagesmsec", "", LL_SIM_STAT_IMAGESMS),
+										SIM_SCRIPTS_TIME("simscriptmsec", "", LL_SIM_STAT_SCRIPTMS),
+										SIM_SPARE_TIME("simsparemsec", "", LL_SIM_STAT_SIMSPARETIME),
+										SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
+										SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
+
+LLTrace::Measurement<LLUnits::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+											FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
+											LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
+											REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
+											FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
+											UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
+											NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
+											IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
+											REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
+											RENDER_STACKTIME("renderstacktime", "RENDER_SECS"),
+											SIM_PING("simpingstat");
 
-class StatAttributes
-{
-public:
-	StatAttributes(const char* name,
-				   const BOOL enabled)
-	:	mName(name),
-		mEnabled(enabled)
-	{
-	}
-	
-	std::string mName;
-	BOOL mEnabled;
-};
+}
 
-LLViewerStats::LLViewerStats() :
-	//mVFSPendingOperations("vfspendingoperations"),
-	//mFPSStat("fpsstat"),
-	//mPacketsInStat("packetsinstat"),
-	//mPacketsLostStat("packetsloststat"),
-	//mPacketsOutStat("packetsoutstat"),
-	//mPacketsLostPercentStat("packetslostpercentstat"),
-	//mTexturePacketsStat("texturepacketsstat"),
-	//mActualInKBitStat("actualinkbitstat"),
-	//mActualOutKBitStat("actualoutkbitstat"),
-	//mTrianglesDrawnStat("trianglesdrawnstat"),
-	//mSimTimeDilation("simtimedilation"),
-	mSimFPS("simfps"),
-	mSimPhysicsFPS("simphysicsfps"),
-	mSimAgentUPS("simagentups"),
-	mSimScriptEPS("simscripteps"),
-	mSimFrameMsec("simframemsec"),
-	mSimNetMsec("simnetmsec"),
-	mSimSimOtherMsec("simsimothermsec"),
-	mSimSimPhysicsMsec("simsimphysicsmsec"),
-	mSimSimPhysicsStepMsec("simsimphysicsstepmsec"),
-	mSimSimPhysicsShapeUpdateMsec("simsimphysicsshapeupdatemsec"),
-	mSimSimPhysicsOtherMsec("simsimphysicsothermsec"),
-	mSimSimAIStepMsec("simsimaistepmsec"),
-	mSimSimSkippedSilhouetteSteps("simsimskippedsilhouettesteps"),
-	mSimSimPctSteppedCharacters("simsimpctsteppedcharacters"),
-	mSimAgentMsec("simagentmsec"),
-	mSimImagesMsec("simimagesmsec"),
-	mSimScriptMsec("simscriptmsec"),
-	mSimSpareMsec("simsparemsec"),
-	mSimSleepMsec("simsleepmsec"),
-	mSimPumpIOMsec("simpumpiomsec"),
-	mSimMainAgents("simmainagents"),
-	mSimChildAgents("simchildagents"),
-	mSimObjects("simobjects"),
-	mSimActiveObjects("simactiveobjects"),
-	mSimActiveScripts("simactivescripts"),
-	mSimPctScriptsRun("simpctscriptsrun"),
-	mSimInPPS("siminpps"),
-	mSimOutPPS("simoutpps"),
-	mSimPendingDownloads("simpendingdownloads"),
-	mSimPendingUploads("simpendinguploads"),
-	mSimPendingLocalUploads("simpendinglocaluploads"),
-	mSimTotalUnackedBytes("simtotalunackedbytes"),
-	mPhysicsPinnedTasks("physicspinnedtasks"),
-	mPhysicsLODTasks("physicslodtasks"),
-	mPhysicsMemoryAllocated("physicsmemoryallocated"),
-	mSimPingStat("simpingstat"),
-	mNumImagesStat("numimagesstat", TRUE),
-	mNumRawImagesStat("numrawimagesstat", TRUE),
-	mGLTexMemStat("gltexmemstat", TRUE),
-	mGLBoundMemStat("glboundmemstat", TRUE),
-	mRawMemStat("rawmemstat", TRUE),
-	mFormattedMemStat("formattedmemstat", TRUE),
-	mNumObjectsStat("numobjectsstat"),
-	mNumActiveObjectsStat("numactiveobjectsstat"),
-	mNumNewObjectsStat("numnewobjectsstat"),
-	mNumSizeCulledStat("numsizeculledstat"),
-	mNumVisCulledStat("numvisculledstat"),
-	mLastTimeDiff(0.0)
+LLViewerStats::LLViewerStats() 
+:	mLastTimeDiff(0.0)
 {
-	for (S32 i = 0; i < ST_COUNT; i++)
-	{
-		mStats[i] = 0.0;
-	}
-	
-	if (LLTimer::knownBadTimer())
-	{
-		mStats[ST_HAS_BAD_TIMER] = 1.0;
-	}	
-	
-	mAgentPositionSnaps.reset();
 	mRecording.start();
 	LLTrace::get_frame_recording().start();
 }
@@ -275,93 +201,80 @@ LLViewerStats::~LLViewerStats()
 
 void LLViewerStats::resetStats()
 {
-	LLViewerStats& stats = LLViewerStats::instance();
-	stats.mRecording.reset();
-	//stats.mVFSPendingOperations.reset();
-	//stats.mPacketsInStat.reset();
-	//stats.mPacketsLostStat.reset();
-	//stats.mPacketsOutStat.reset();
-	//stats.mFPSStat.reset();
-	//stats.mTexturePacketsStat.reset();
-	//stats.mAgentPositionSnaps.reset();
-}
-
-
-F64 LLViewerStats::getStat(EStatType type) const
-{
-	return mStats[type];
-}
-
-F64 LLViewerStats::setStat(EStatType type, F64 value)
-{
-	mStats[type] = value;
-	return mStats[type];
-}
-
-F64 LLViewerStats::incStat(EStatType type, F64 value)
-{
-	mStats[type] += value;
-	return mStats[type];
+	LLViewerStats::instance().mRecording.reset();
 }
 
 void LLViewerStats::updateFrameStats(const F64 time_diff)
 {
-	if (mPacketsLostPercentStat.getCurrent() > 5.0)
+	if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0)
 	{
-		incStat(ST_LOSS_05_SECONDS, time_diff);
+		LLStatViewer::LOSS_5_PERCENT_TIME.add(time_diff);
+		//incStat(ST_LOSS_05_SECONDS, time_diff);
 	}
 	
-	if (mSimFPS.getCurrent() < 20.f && mSimFPS.getCurrent() > 0.f)
+	F32 sim_fps = getRecording().getLastValue(LLStatViewer::SIM_FPS);
+	if (0.f < sim_fps && sim_fps < 20.f)
 	{
-		incStat(ST_SIM_FPS_20_SECONDS, time_diff);
+		LLStatViewer::SIM_20_FPS_TIME.add(time_diff);
+		//incStat(ST_SIM_FPS_20_SECONDS, time_diff);
 	}
 	
-	if (mSimPhysicsFPS.getCurrent() < 20.f && mSimPhysicsFPS.getCurrent() > 0.f)
+	F32 sim_physics_fps = getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS);
+
+	if (0.f < sim_physics_fps && sim_physics_fps < 20.f)
 	{
-		incStat(ST_PHYS_FPS_20_SECONDS, time_diff);
+		LLStatViewer::SIM_PHYSICS_20_FPS_TIME.add(time_diff);
+		//incStat(ST_PHYS_FPS_20_SECONDS, time_diff);
 	}
 		
 	if (time_diff >= 0.5)
 	{
-		incStat(ST_FPS_2_SECONDS, time_diff);
+		LLStatViewer::FPS_2_TIME.add(time_diff);
+		//incStat(ST_FPS_2_SECONDS, time_diff);
 	}
 	if (time_diff >= 0.125)
 	{
-		incStat(ST_FPS_8_SECONDS, time_diff);
+		LLStatViewer::FPS_8_TIME.add(time_diff);
+		//incStat(ST_FPS_8_SECONDS, time_diff);
 	}
 	if (time_diff >= 0.1)
 	{
-		incStat(ST_FPS_10_SECONDS, time_diff);
+		LLStatViewer::FPS_10_TIME.add(time_diff);
+		//incStat(ST_FPS_10_SECONDS, time_diff);
 	}
 
 	if (gFrameCount && mLastTimeDiff > 0.0)
 	{
 		// new "stutter" meter
-		setStat(ST_FPS_DROP_50_RATIO,
-				(getStat(ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + 
-				 (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount);
+		LLStatViewer::FRAMETIME_DOUBLED.add(time_diff >= 2.0 * mLastTimeDiff ? 1 : 0);
+		//setStat(ST_FPS_DROP_50_RATIO,
+		//		(getStat(ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + 
+		//		 (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount);
 			
 
 		// old stats that were never really used
-		setStat(ST_FRAMETIME_JITTER,
-				(getStat(ST_FRAMETIME_JITTER) * (gFrameCount - 1) + 
-				 fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount);
+		LLStatViewer::FRAMETIME_JITTER.sample(mLastTimeDiff - time_diff);
+		//setStat(ST_FRAMETIME_JITTER,
+		//		(getStat(ST_FRAMETIME_JITTER) * (gFrameCount - 1) + 
+		//		 fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount);
 			
 		F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
-		setStat(ST_FRAMETIME_SLEW,
-				(getStat(ST_FRAMETIME_SLEW) * (gFrameCount - 1) + 
-				 fabs(average_frametime - time_diff) / average_frametime) / gFrameCount);
+		LLStatViewer::FRAMETIME_SLEW.sample(average_frametime - time_diff);
+		//setStat(ST_FRAMETIME_SLEW,
+		//		(getStat(ST_FRAMETIME_SLEW) * (gFrameCount - 1) + 
+		//		 fabs(average_frametime - time_diff) / average_frametime) / gFrameCount);
 
 		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
 		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
-		setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);
+		LLStatViewer::DELTA_BANDWIDTH.sample<LLUnits::Bits>(delta_bandwidth);
+		//setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);
 
-		setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
+		LLStatViewer::MAX_BANDWIDTH.sample<LLUnits::Bits>(max_bandwidth);
+		//setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
 		
 	}
 	
 	mLastTimeDiff = time_diff;
-
 }
 
 void LLViewerStats::addToMessage(LLSD &body) const
@@ -370,11 +283,11 @@ void LLViewerStats::addToMessage(LLSD &body) const
 	
 	misc["Version"] = TRUE;
 	//TODO RN: get last value, not mean
-	misc["Vertex Buffers Enabled"] = mRecording.getMean(LLStatViewer::ENABLE_VBO);
+	misc["Vertex Buffers Enabled"] = getRecording().getMean(LLStatViewer::ENABLE_VBO);
 	
-	body["AgentPositionSnaps"] = mAgentPositionSnaps.asLLSD();
-	llinfos << "STAT: AgentPositionSnaps: Mean = " << mAgentPositionSnaps.getMean() << "; StdDev = " << mAgentPositionSnaps.getStdDev() 
-			<< "; Count = " << mAgentPositionSnaps.getCount() << llendl;
+	body["AgentPositionSnaps"] = getRecording().getSum(LLStatViewer::AGENT_POSITION_SNAP).value(); //mAgentPositionSnaps.asLLSD();
+	llinfos << "STAT: AgentPositionSnaps: Mean = " << getRecording().getMean(LLStatViewer::AGENT_POSITION_SNAP).value() << "; StdDev = " << getRecording().getStandardDeviation(LLStatViewer::AGENT_POSITION_SNAP).value() 
+			<< "; Count = " << getRecording().getSampleCount(LLStatViewer::AGENT_POSITION_SNAP) << llendl;
 }
 
 // *NOTE:Mani The following methods used to exist in viewer.cpp
@@ -386,8 +299,6 @@ F32		gAveLandCompression = 0.f, gAveWaterCompression = 0.f;
 F32		gBestLandCompression = 1.f, gBestWaterCompression = 1.f;
 F32		gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f;
 
-
-
 U32		gTotalWorldBytes = 0, gTotalObjectBytes = 0, gTotalTextureBytes = 0, gSimPingCount = 0;
 U32		gObjectBits = 0;
 F32		gAvgSimPing = 0.f;
@@ -403,51 +314,61 @@ void update_statistics()
 	gTotalWorldBytes += gVLManager.getTotalBytes();
 	gTotalObjectBytes += gObjectBits / 8;
 
-	LLViewerStats& stats = LLViewerStats::instance();
-
 	// make sure we have a valid time delta for this frame
 	if (gFrameIntervalSeconds > 0.f)
 	{
 		if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
 		{
-			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds);
+			LLStatViewer::MOUSELOOK_TIME.add(gFrameIntervalSeconds);
+			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds);
 		}
 		else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
 		{
-			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds);
+			LLStatViewer::AVATAR_EDIT_TIME.add(gFrameIntervalSeconds);
+			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds);
 		}
 		else if (LLFloaterReg::instanceVisible("build"))
 		{
-			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds);
+			LLStatViewer::TOOLBOX_TIME.add(gFrameIntervalSeconds);
+			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds);
 		}
 	}
-	stats.setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
-	stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
-	stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip"));
-	stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
-
-	stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame"));
+	LLStatViewer::ENABLE_VBO.sample((F64)gSavedSettings.getBOOL("RenderVBOEnable"));
+	//stats.setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
+	LLStatViewer::LIGHTING_DETAIL.sample((F64)gPipeline.getLightingDetail());
+	//stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
+	LLStatViewer::DRAW_DISTANCE.sample((F64)gSavedSettings.getF32("RenderFarClip"));
+	//stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip"));
+	LLStatViewer::CHAT_BUBBLES.sample((F64)gSavedSettings.getBOOL("UseChatBubbles"));
+	//stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
+
+	LLStatViewer::FRAME_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Frame"));
+	//stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame"));
 	F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle");
 	F64 network_secs = gDebugView->mFastTimerView->getTime("Network");
-	stats.setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs);
-	stats.setStat(LLViewerStats::ST_NETWORK_SECS, network_secs);
-	stats.setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images"));
-	stats.setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State"));
-	stats.setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry"));
+	LLStatViewer::UPDATE_STACKTIME.sample(idle_secs - network_secs);
+	//stats.setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs);
+	LLStatViewer::NETWORK_STACKTIME.sample(network_secs);
+	//stats.setStat(LLViewerStats::ST_NETWORK_SECS, network_secs);
+	LLStatViewer::IMAGE_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Update Images"));
+	//stats.setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images"));
+	LLStatViewer::REBUILD_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Sort Draw State"));
+	//stats.setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State"));
+	LLStatViewer::RENDER_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Geometry"));
+	//stats.setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry"));
 		
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
 		LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(cdp->getPingDelay());
-		stats.mSimPingStat.addValue(cdp->getPingDelay());
+		//stats.mSimPingStat.addValue(cdp->getPingDelay());
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
-		LLUnits::Seconds i(10000);
-		LLStatViewer::SIM_PING.sample(i);//<LLUnits::Seconds<U32> >(10000);
-		stats.mSimPingStat.addValue(10000);
+		LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(10000);
+		//stats.mSimPingStat.addValue(10000);
 	}
 
 	//stats.mFPSStat.addValue(1);
@@ -458,7 +379,7 @@ void update_statistics()
 	LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits>(gObjectBits);
 	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
 	//stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
-	LLStatViewer::SIM_PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending());
+	LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending());
 	LLStatViewer::ASSET_KBIT.add<LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
 	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
@@ -481,7 +402,8 @@ void update_statistics()
 			visible_avatar_frames = 1.f;
 			avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames;
 		}
-		stats.setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars);
+		LLStatViewer::VISIBLE_AVATARS.sample((F64)avg_visible_avatars);
+		//stats.setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars);
 	}
 	LLWorld::getInstance()->updateNetStats();
 	LLWorld::getInstance()->requestCacheMisses();
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 5412294cf2..40109bcea3 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -28,12 +28,39 @@
 #define LL_LLVIEWERSTATS_H
 
 #include "llstat.h"
+#include "llstatenums.h"
 #include "lltextureinfo.h"
 #include "lltracerecording.h"
 #include "lltrace.h"
 
 namespace LLStatViewer
 {
+
+struct SimMeasurementSampler : public LLInstanceTracker<SimMeasurementSampler, ESimStatID>
+{
+	SimMeasurementSampler(ESimStatID id)
+	:	LLInstanceTracker(id)
+	{}
+	virtual ~SimMeasurementSampler() {}
+	virtual void sample(F64 value) = 0;
+};
+
+template<typename T = F64>
+struct SimMeasurement : public LLTrace::Measurement<T>, public SimMeasurementSampler
+{
+	SimMeasurement(const char* name, const char* description, ESimStatID stat_id)
+	:	LLTrace::Measurement<T>(name, description),
+		SimMeasurementSampler(stat_id)	
+	{}
+
+	using SimMeasurementSampler::getInstance;
+
+	/*virtual*/ void sample(F64 value)
+	{
+		LLTrace::Measurement<T>::sample(value);
+	}
+};
+
 extern LLTrace::Count<>						FPS,
 											PACKETS_IN,
 											PACKETS_LOST,
@@ -46,7 +73,6 @@ extern LLTrace::Count<>						FPS,
 											OBJECT_REZ,
 											LOADING_WEARABLES_LONG_DELAY,
 											LOGIN_TIMEOUTS,
-											FAILED_DOWNLOADS,
 											LSL_SAVES,
 											ANIMATION_UPLOADS,
 											FLY,
@@ -80,7 +106,7 @@ extern LLTrace::Count<LLUnits::Seconds>		AVATAR_EDIT_TIME,
 											SIM_PHYSICS_20_FPS_TIME,
 											LOSS_5_PERCENT_TIME;
 
-extern LLTrace::Measurement<>				SIM_TIME_DILATION,
+extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_FPS,
 											SIM_PHYSICS_FPS,
 											SIM_AGENT_UPS,
@@ -98,10 +124,10 @@ extern LLTrace::Measurement<>				SIM_TIME_DILATION,
 											SIM_PENDING_DOWNLOADS,
 											SIM_PENDING_UPLOADS,
 											SIM_PENDING_LOCAL_UPLOADS,
-											SIM_PENDING_VFS_OPERATIONS,
 											SIM_PHYSICS_PINNED_TASKS,
-											SIM_PHYSICS_LOD_TASKS,
-											NUM_IMAGES,
+											SIM_PHYSICS_LOD_TASKS;
+
+extern LLTrace::Measurement<>				NUM_IMAGES,
 											NUM_RAW_IMAGES,
 											NUM_OBJECTS,
 											NUM_ACTIVE_OBJECTS,
@@ -109,25 +135,31 @@ extern LLTrace::Measurement<>				SIM_TIME_DILATION,
 											NUM_SIZE_CULLED,
 											NUM_VIS_CULLED,
 											ENABLE_VBO,
-											DELTA_BANDWIDTH,
-											MAX_BANDWIDTH,
 											LIGHTING_DETAIL,
 											VISIBLE_AVATARS,
 											SHADER_OBJECTS,
 											DRAW_DISTANCE,
 											CHAT_BUBBLES,
+											PENDING_VFS_OPERATIONS,
+											PACKETS_LOST_PERCENT,
 											WINDOW_WIDTH,
 											WINDOW_HEIGHT;
 
+extern LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP;
+
 extern LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES,
+											DELTA_BANDWIDTH,
+											MAX_BANDWIDTH,
 											SIM_PHYSICS_MEM,
 											GL_TEX_MEM,
 											GL_BOUND_MEM,
 											RAW_MEM,
 											FORMATTED_MEM;
 
-
-extern LLTrace::Measurement<LLUnits::Seconds>	SIM_PHYSICS_TIME,
+extern SimMeasurement<LLUnits::Milliseconds>	SIM_FRAME_TIME,
+												SIM_NET_TIME,
+												SIM_OTHER_TIME,
+												SIM_PHYSICS_TIME,
 												SIM_PHYSICS_STEP_TIME,
 												SIM_PHYSICS_SHAPE_UPDATE_TIME,
 												SIM_PHYSICS_OTHER_TIME,
@@ -137,171 +169,32 @@ extern LLTrace::Measurement<LLUnits::Seconds>	SIM_PHYSICS_TIME,
 												SIM_SCRIPTS_TIME,
 												SIM_SPARE_TIME,
 												SIM_SLEEP_TIME,
-												SIM_PUMP_IO_TIME,
-												SIM_PING,
-												FRAMETIME_JITTER,
-												FRAMETIME_SLEW,
-												LOGIN_SECONDS,
-												REGION_CROSSING_TIME,
-												FRAME_STACKTIME,
-												UPDATE_STACKTIME,
-												NETWORK_STACKTIME,
-												IMAGE_STACKTIME,
-												REBUILD_STACKTIME,
-												RENDER_STACKTIME;
+												SIM_PUMP_IO_TIME;
+
+
+extern LLTrace::Measurement<LLUnits::Milliseconds>	FRAMETIME_JITTER,
+													FRAMETIME_SLEW,
+													LOGIN_SECONDS,
+													REGION_CROSSING_TIME,
+													FRAME_STACKTIME,
+													UPDATE_STACKTIME,
+													NETWORK_STACKTIME,
+													IMAGE_STACKTIME,
+													REBUILD_STACKTIME,
+													RENDER_STACKTIME,
+													SIM_PING;
 }
 
 class LLViewerStats : public LLSingleton<LLViewerStats>
 {
 public:
-	LLStat	mVFSPendingOperations,
-			mFPSStat,
-			mPacketsInStat,
-			mPacketsLostStat,
-			mPacketsOutStat,
-			mPacketsLostPercentStat,
-			mTexturePacketsStat,
-			mActualInKBitStat,	// From the packet ring (when faking a bad connection)
-			mActualOutKBitStat,	// From the packet ring (when faking a bad connection)
-			mTrianglesDrawnStat;
-
-	// Simulator stats
-	LLStat	mSimTimeDilation;
-
-	LLStat	mSimFPS,
-			mSimPhysicsFPS,
-			mSimAgentUPS,
-			mSimScriptEPS;
-
-	LLStat	mSimFrameMsec,
-			mSimNetMsec,
-			mSimSimOtherMsec,
-			mSimSimPhysicsMsec;
-
-	LLStat	mSimSimPhysicsStepMsec,
-			mSimSimPhysicsShapeUpdateMsec,
-			mSimSimPhysicsOtherMsec,
-			mSimSimAIStepMsec,
-			mSimSimSkippedSilhouetteSteps,
-			mSimSimPctSteppedCharacters;
-
-	LLStat	mSimAgentMsec,
-			mSimImagesMsec,
-			mSimScriptMsec,
-			mSimSpareMsec,
-			mSimSleepMsec,
-			mSimPumpIOMsec;
-
-	LLStat	mSimMainAgents,
-			mSimChildAgents,
-			mSimObjects,
-			mSimActiveObjects,
-			mSimActiveScripts,
-			mSimPctScriptsRun;
-
-	LLStat	mSimInPPS,
-			mSimOutPPS,
-			mSimPendingDownloads,
-			mSimPendingUploads,
-			mSimPendingLocalUploads,
-			mSimTotalUnackedBytes;
-
-	LLStat	mPhysicsPinnedTasks,
-			mPhysicsLODTasks,
-			mPhysicsMemoryAllocated;
-
-	LLStat	mSimPingStat;
-
-	LLStat	mNumImagesStat,
-			mNumRawImagesStat,
-			mGLTexMemStat,
-			mGLBoundMemStat,
-			mRawMemStat,
-			mFormattedMemStat;
-
-	LLStat	mNumObjectsStat,
-			mNumActiveObjectsStat,
-			mNumNewObjectsStat,
-			mNumSizeCulledStat,
-			mNumVisCulledStat;
-
 	void resetStats();
 
 public:
 
-	// If you change this, please also add a corresponding text label in llviewerstats.cpp
-	enum EStatType
-	{
-		ST_VERSION = 0,
-		ST_AVATAR_EDIT_SECONDS = 1,
-		ST_TOOLBOX_SECONDS = 2,
-		ST_CHAT_COUNT = 3,
-		ST_IM_COUNT = 4,
-		ST_FULLSCREEN_BOOL = 5,
-		ST_RELEASE_COUNT= 6,
-		ST_CREATE_COUNT = 7,
-		ST_REZ_COUNT = 8,
-		ST_FPS_10_SECONDS = 9,
-		ST_FPS_2_SECONDS = 10,
-		ST_MOUSELOOK_SECONDS = 11,
-		ST_FLY_COUNT = 12,
-		ST_TELEPORT_COUNT = 13,
-		ST_OBJECT_DELETE_COUNT = 14,
-		ST_SNAPSHOT_COUNT = 15,
-		ST_UPLOAD_SOUND_COUNT = 16,
-		ST_UPLOAD_TEXTURE_COUNT = 17,
-		ST_EDIT_TEXTURE_COUNT = 18,
-		ST_KILLED_COUNT = 19,
-		ST_FRAMETIME_JITTER = 20,
-		ST_FRAMETIME_SLEW = 21,
-		ST_INVENTORY_TOO_LONG = 22,
-		ST_WEARABLES_TOO_LONG = 23,
-		ST_LOGIN_SECONDS = 24,
-		ST_LOGIN_TIMEOUT_COUNT = 25,
-		ST_HAS_BAD_TIMER = 26,
-		ST_DOWNLOAD_FAILED = 27,
-		ST_LSL_SAVE_COUNT = 28,
-		ST_UPLOAD_ANIM_COUNT = 29,
-		ST_FPS_8_SECONDS = 30,
-		ST_SIM_FPS_20_SECONDS = 31,
-		ST_PHYS_FPS_20_SECONDS = 32,
-		ST_LOSS_05_SECONDS = 33,
-		ST_FPS_DROP_50_RATIO = 34,
-		ST_ENABLE_VBO = 35,
-		ST_DELTA_BANDWIDTH = 36,
-		ST_MAX_BANDWIDTH = 37,
-		ST_LIGHTING_DETAIL = 38,
-		ST_VISIBLE_AVATARS = 39,
-		ST_SHADER_OBJECTS = 40,
-		ST_SHADER_ENVIRONMENT = 41,
-		ST_DRAW_DIST = 42,
-		ST_CHAT_BUBBLES = 43,
-		ST_SHADER_AVATAR = 44,
-		ST_FRAME_SECS = 45,
-		ST_UPDATE_SECS = 46,
-		ST_NETWORK_SECS = 47,
-		ST_IMAGE_SECS = 48,
-		ST_REBUILD_SECS = 49,
-		ST_RENDER_SECS = 50,
-		ST_CROSSING_AVG = 51,
-		ST_CROSSING_MAX = 52,
-		ST_LIBXUL_WIDGET_USED = 53, // Unused
-		ST_WINDOW_WIDTH = 54,
-		ST_WINDOW_HEIGHT = 55,
-		ST_TEX_BAKES = 56,
-		ST_TEX_REBAKES = 57,
-		
-		ST_COUNT = 58
-	};
-
 	LLViewerStats();
 	~LLViewerStats();
 
-	// all return latest value of given stat
-	F64 getStat(EStatType type) const;
-	F64 setStat(EStatType type, F64 value);		// set the stat to value
-	F64 incStat(EStatType type, F64 value = 1.f);	// add value to the stat
-
 	void updateFrameStats(const F64 time_diff);
 	
 	void addToMessage(LLSD &body) const;
@@ -388,8 +281,6 @@ public:
 		}
 	};
 
-	StatsAccumulator mAgentPositionSnaps;
-
 	// Phase tracking (originally put in for avatar rezzing), tracking
 	// progress of active/completed phases for activities like outfit changing.
 	typedef std::map<std::string,LLFrameTimer>	phase_map_t;
@@ -412,9 +303,9 @@ public:
 	};
 
 	LLTrace::Recording& getRecording() { return mRecording; }
+	const LLTrace::Recording& getRecording() const { return mRecording; }
 
 private:
-	F64								mStats[ST_COUNT];
 	LLTrace::Recording				mRecording;
 
 	F64								mLastTimeDiff;  // used for time stat updates
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index ccfedd8881..56ccf3b1f0 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -66,12 +66,6 @@
 void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
 
 S32 LLViewerTextureList::sNumImages = 0;
-LLStat LLViewerTextureList::sNumImagesStat("Num Images", TRUE);
-LLStat LLViewerTextureList::sNumRawImagesStat("Num Raw Images", TRUE);
-LLStat LLViewerTextureList::sGLTexMemStat("GL Texture Mem", TRUE);
-LLStat LLViewerTextureList::sGLBoundMemStat("GL Bound Mem", TRUE);
-LLStat LLViewerTextureList::sRawMemStat("Raw Image Mem", TRUE);
-LLStat LLViewerTextureList::sFormattedMemStat("Formatted Image Mem", TRUE);
 
 LLViewerTextureList gTextureList;
 static LLFastTimer::DeclareTimer FTM_PROCESS_IMAGES("Process Images");
@@ -625,12 +619,15 @@ void LLViewerTextureList::updateImages(F32 max_time)
 
 	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording.getPerSec(LLStatViewer::TEXTURE_KBIT).value());
 
-	LLViewerStats::getInstance()->mNumImagesStat.addValue(sNumImages);
-	LLViewerStats::getInstance()->mNumRawImagesStat.addValue(LLImageRaw::sRawImageCount);
-	LLViewerStats::getInstance()->mGLTexMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sGlobalTextureMemoryInBytes));
-	LLViewerStats::getInstance()->mGLBoundMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageGL::sBoundTextureMemoryInBytes));
-	LLViewerStats::getInstance()->mRawMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageRaw::sGlobalRawMemory));
-	LLViewerStats::getInstance()->mFormattedMemStat.addValue((F32)BYTES_TO_MEGA_BYTES(LLImageFormatted::sGlobalFormattedMemory));
+	{
+		using namespace LLStatViewer;
+		NUM_IMAGES.sample(sNumImages);
+		NUM_RAW_IMAGES.sample(LLImageRaw::sRawImageCount);
+		GL_TEX_MEM.sample<LLUnits::Bytes>(LLImageGL::sGlobalTextureMemoryInBytes);
+		GL_BOUND_MEM.sample<LLUnits::Bytes>(LLImageGL::sBoundTextureMemoryInBytes);
+		RAW_MEM.sample<LLUnits::Bytes>(LLImageRaw::sGlobalRawMemory);
+		FORMATTED_MEM.sample<LLUnits::Bytes>(LLImageFormatted::sGlobalFormattedMemory);
+	}
 
 	{
 		//loading from fast cache 
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index ab6f009e28..a00f48b5a2 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -1,5 +1,5 @@
 /** 
- * @file llviewertexturelist.h
+ * @file llviewertexturelinumimagest.h
  * @brief Object for managing the list of images within a region
  *
  * $LicenseInfo:firstyear=2000&license=viewerlgpl$
@@ -200,14 +200,6 @@ private:
 	S32 mMaxTotalTextureMemInMegaBytes;
 	LLFrameTimer mForceDecodeTimer;
 	
-public:
-	static LLStat sNumImagesStat;
-	static LLStat sNumRawImagesStat;
-	static LLStat sGLTexMemStat;
-	static LLStat sGLBoundMemStat;
-	static LLStat sRawMemStat;
-	static LLStat sFormattedMemStat;
-
 private:
 	static S32 sNumImages;
 	static void (*sUUIDCallback)(void**, const LLUUID &);
diff --git a/indra/newview/llviewerthrottle.cpp b/indra/newview/llviewerthrottle.cpp
index 5147272122..34f2c8f6e6 100644
--- a/indra/newview/llviewerthrottle.cpp
+++ b/indra/newview/llviewerthrottle.cpp
@@ -304,7 +304,8 @@ void LLViewerThrottle::updateDynamicThrottle()
 	}
 	mUpdateTimer.reset();
 
-	if (LLViewerStats::getInstance()->mPacketsLostPercentStat.getMean() > TIGHTEN_THROTTLE_THRESHOLD)
+	F32 mean_packets_lost = LLViewerStats::instance().getRecording().getMean(LLStatViewer::PACKETS_LOST_PERCENT);
+	if (mean_packets_lost > TIGHTEN_THROTTLE_THRESHOLD)
 	{
 		if (mThrottleFrac <= MIN_FRACTIONAL || mCurrentBandwidth / 1024.0f <= MIN_BANDWIDTH)
 		{
@@ -317,7 +318,7 @@ void LLViewerThrottle::updateDynamicThrottle()
 		mCurrent.sendToSim();
 		llinfos << "Tightening network throttle to " << mCurrentBandwidth << llendl;
 	}
-	else if (LLViewerStats::getInstance()->mPacketsLostPercentStat.getMean() <= EASE_THROTTLE_THRESHOLD)
+	else if (mean_packets_lost <= EASE_THROTTLE_THRESHOLD)
 	{
 		if (mThrottleFrac >= MAX_FRACTIONAL || mCurrentBandwidth / 1024.0f >= MAX_BANDWIDTH)
 		{
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 4ad7c49d4b..8161caf5e4 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2184,8 +2184,10 @@ void LLViewerWindow::reshape(S32 width, S32 height)
 			}
 		}
 
-		LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width);
-		LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height);
+		LLStatViewer::WINDOW_WIDTH.sample((F64)width);
+		//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width);
+		LLStatViewer::WINDOW_HEIGHT.sample((F64)height);
+		//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height);
 
 		LLLayoutStack::updateClass();
 	}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index fd892db3d3..3e8b07b6dc 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -911,13 +911,14 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 		{
 			++mRegionCrossingCount;
 			F64 delta = (F64)mRegionCrossingTimer.getElapsedTimeF32();
-			F64 avg = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_AVG);
-			F64 delta_avg = (delta + avg*(mRegionCrossingCount-1)) / mRegionCrossingCount;
-			LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_AVG, delta_avg);
-			
-			F64 max = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_MAX);
-			max = llmax(delta, max);
-			LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max);
+			//F64 avg = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_AVG);
+			//F64 delta_avg = (delta + avg*(mRegionCrossingCount-1)) / mRegionCrossingCount;
+			LLStatViewer::REGION_CROSSING_TIME.sample(delta);
+			//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_AVG, delta_avg);
+			//
+			//F64 max = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_MAX);
+			//max = llmax(delta, max);
+			//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max);
 
 			// Diagnostics
 			llinfos << "Region crossing took " << (F32)(delta * 1000.0) << " ms " << llendl;
@@ -2587,7 +2588,8 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
 					llinfos << "TAT: rebake - matched entry " << (S32)index << llendl;
 					gAgentAvatarp->invalidateComposite(layer_set, TRUE);
 					found = TRUE;
-					LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES);
+					LLStatViewer::TEX_REBAKES.add(1);
+					//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES);
 				}
 			}
 		}
@@ -2632,7 +2634,8 @@ void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug)
 			}
 
 			invalidateComposite(layer_set, TRUE);
-			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES);
+			LLStatViewer::TEX_REBAKES.add(1);
+			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES);
 		}
 		else
 		{
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp
index 6f6411ce3c..20033d6fe4 100644
--- a/indra/newview/llwearablelist.cpp
+++ b/indra/newview/llwearablelist.cpp
@@ -136,7 +136,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
 		{
 			LLFile::remove(std::string(filename));
 		}
-		LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
+		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 		LL_WARNS("Wearable") << "Wearable download failed: " << LLAssetStorage::getErrorString( status ) << " " << uuid << LL_ENDL;
 		switch( status )
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 9e495c46b1..604741ff27 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -712,13 +712,15 @@ void LLWorld::updateNetStats()
 	LLStatViewer::PACKETS_IN.add(packets_in);
 	LLStatViewer::PACKETS_OUT.add(packets_out);
 	LLStatViewer::PACKETS_LOST.add(packets_lost);
+	LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));
 	//LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in);
 	//LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out);
 	//LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets);
-	//if (packets_in)
-	//{
+	if (packets_in)
+	{
+		LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));
 	//	LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in));
-	//}
+	}
 	//else
 	//{
 	//	LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f);
-- 
cgit v1.2.3


From c0ba626c8009b22310b3923e8170e5db2a021253 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 15 Oct 2012 21:34:29 -0600
Subject: For SH-3333: Design and implement a new object cache system on viewer
 side

---
 indra/newview/CMakeLists.txt            |   2 +
 indra/newview/app_settings/settings.xml |  11 +
 indra/newview/llappviewer.cpp           |   2 +-
 indra/newview/lldrawable.cpp            | 349 +++++++-------
 indra/newview/lldrawable.h              |  62 +--
 indra/newview/llspatialpartition.cpp    | 787 +++++++++++---------------------
 indra/newview/llspatialpartition.h      | 128 +++---
 indra/newview/lltextureview.cpp         |   9 +-
 indra/newview/llviewermessage.cpp       |  25 +-
 indra/newview/llviewerobject.cpp        | 105 +++--
 indra/newview/llviewerobjectlist.cpp    | 145 +++++-
 indra/newview/llviewerobjectlist.h      |   6 +-
 indra/newview/llvieweroctree.cpp        | 704 ++++++++++++++++++++++++++++
 indra/newview/llvieweroctree.h          | 274 +++++++++++
 indra/newview/llviewerpartsim.cpp       |   4 +-
 indra/newview/llviewerregion.cpp        | 478 +++++++++++++++++--
 indra/newview/llviewerregion.h          |  38 +-
 indra/newview/llviewerstatsrecorder.cpp |   2 +-
 indra/newview/llvoavatarself.cpp        |   6 +-
 indra/newview/llvocache.cpp             |  78 +++-
 indra/newview/llvocache.h               |  36 +-
 indra/newview/llvograss.cpp             |  14 +-
 indra/newview/llvopartgroup.cpp         |  20 +-
 indra/newview/llvosurfacepatch.cpp      |   4 +-
 indra/newview/llvotree.cpp              |   4 +-
 indra/newview/llvovolume.cpp            |  44 +-
 indra/newview/llvowater.cpp             |   6 +-
 indra/newview/llworld.cpp               |  20 +-
 indra/newview/llworld.h                 |   3 +-
 indra/newview/pipeline.cpp              |  50 +-
 30 files changed, 2429 insertions(+), 987 deletions(-)
 create mode 100644 indra/newview/llvieweroctree.cpp
 create mode 100644 indra/newview/llvieweroctree.h

(limited to 'indra/newview')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 04ea646100..c81ade6937 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -583,6 +583,7 @@ set(viewer_SOURCE_FILES
     llviewernetwork.cpp
     llviewerobject.cpp
     llviewerobjectlist.cpp
+	llvieweroctree.cpp
     llviewerparcelmedia.cpp
     llviewerparcelmediaautoplay.cpp
     llviewerparcelmgr.cpp
@@ -1148,6 +1149,7 @@ set(viewer_HEADER_FILES
     llviewernetwork.h
     llviewerobject.h
     llviewerobjectlist.h
+	llvieweroctree.h
     llviewerparcelmedia.h
     llviewerparcelmediaautoplay.h
     llviewerparcelmgr.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 7497a273ea..13c95c2381 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6400,6 +6400,17 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
+    <key>ObjectCacheViewCullingEnabled</key>
+    <map>
+      <key>Comment</key>
+      <string>Enable the object cache view culling. Needs to restart viewer.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>1</integer>
+    </map>
     <key>OpenDebugStatAdvanced</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index a43776912c..bffa1708ec 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -3685,7 +3685,7 @@ U32 LLAppViewer::getObjectCacheVersion()
 {
 	// Viewer object cache version, change if object update
 	// format changes. JC
-	const U32 INDRA_OBJECT_CACHE_VERSION = 14;
+	const U32 INDRA_OBJECT_CACHE_VERSION = 15;
 
 	return INDRA_OBJECT_CACHE_VERSION;
 }
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 46ec1abec1..e29551e83c 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -49,6 +49,7 @@
 #include "llspatialpartition.h"
 #include "llviewerobjectlist.h"
 #include "llviewerwindow.h"
+#include "llvocache.h"
 
 const F32 MIN_INTERPOLATE_DISTANCE_SQUARED = 0.001f * 0.001f;
 const F32 MAX_INTERPOLATE_DISTANCE_SQUARED = 10.f * 10.f;
@@ -75,7 +76,6 @@ extern bool gShiftFrame;
 //
 
 // static
-U32 LLDrawable::sCurVisible = 0;
 U32 LLDrawable::sNumZombieDrawables = 0;
 F32 LLDrawable::sCurPixelAngle = 0;
 LLDynamicArrayPtr<LLPointer<LLDrawable> > LLDrawable::sDeadList;
@@ -85,33 +85,59 @@ LLDynamicArrayPtr<LLPointer<LLDrawable> > LLDrawable::sDeadList;
 // static
 void LLDrawable::incrementVisible() 
 {
-	sCurVisible++;
+	LLViewerOctreeEntryData::incrementVisible();
 	sCurPixelAngle = (F32) gViewerWindow->getWindowHeightRaw()/LLViewerCamera::getInstance()->getView();
 }
 
-void LLDrawable::init()
+LLDrawable::LLDrawable(LLViewerObject *vobj, bool new_entry)
+	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLDRAWABLE),
+	  mVObjp(vobj)
+{
+	init(new_entry); 
+}
+
+void LLDrawable::init(bool new_entry)
 {
 	// mXform
 	mParent = NULL;
 	mRenderType = 0;
 	mCurrentScale = LLVector3(1,1,1);
-	mDistanceWRTCamera = 0.0f;
-	mPositionGroup.clear();
-	mExtents[0].clear();
-	mExtents[1].clear();
-
+	mDistanceWRTCamera = 0.0f;	
 	mState     = 0;
-	mVObjp   = NULL;
-	// mFaces
-	mSpatialGroupp = NULL;
-	mVisible = sCurVisible - 2;//invisible for the current frame and the last frame.
-	mRadius = 0.f;
 	
-	mGeneration = -1;
-	mBinRadius = 1.f;
-	mBinIndex = -1;
-
+	// mFaces	
+	mRadius = 0.f;	
+	mGeneration = -1;	
 	mSpatialBridge = NULL;
+
+	LLViewerOctreeEntry* entry = NULL;
+	LLVOCacheEntry* vo_entry = NULL;
+	if(!new_entry && mVObjp && getRegion() != NULL)
+	{
+		vo_entry = getRegion()->getCacheEntryForOctree(mVObjp->getLocalID());
+		if(vo_entry)
+		{
+			entry = vo_entry->getEntry();			
+		}
+	}
+	setOctreeEntry(entry);
+	if(vo_entry)
+	{
+		if(!entry)
+		{
+			vo_entry->setOctreeEntry(mEntry);
+		}
+		else if(vo_entry->getNumOfChildren() > 0)
+		{
+			getRegion()->addVisibleCacheEntry(vo_entry); //to load all children.
+		}
+
+		getRegion()->addActiveCacheEntry(vo_entry);		
+	}
+
+	llassert(!vo_entry || vo_entry->getEntry() == mEntry);
+
+	initVisible(sCurVisible - 2);//invisible for the current frame and the last frame.
 }
 
 // static
@@ -155,6 +181,7 @@ void LLDrawable::markDead()
 		llwarns << "Warning!  Marking dead multiple times!" << llendl;
 		return;
 	}
+	setState(DEAD);
 
 	if (mSpatialBridge)
 	{
@@ -164,8 +191,7 @@ void LLDrawable::markDead()
 
 	sNumZombieDrawables++;
 
-	// We're dead.  Free up all of our references to other objects
-	setState(DEAD);
+	// We're dead.  Free up all of our references to other objects	
 	cleanupReferences();
 //	sDeadList.put(this);
 }
@@ -219,6 +245,8 @@ void LLDrawable::cleanupReferences()
 	
 	gPipeline.unlinkDrawable(this);
 	
+	removeFromOctree();
+
 	{
 		LLFastTimer t(FTM_DEREF_DRAWABLE);
 		// Cleanup references to other objects
@@ -227,6 +255,21 @@ void LLDrawable::cleanupReferences()
 	}
 }
 
+void LLDrawable::removeFromOctree()
+{
+	if(!mEntry)
+	{
+		return;
+	}
+
+	mEntry->removeData(this);
+	if(mEntry->hasVOCacheEntry())
+	{
+		getRegion()->removeActiveCacheEntry((LLVOCacheEntry*)mEntry->getVOCacheEntry(), this);
+	}
+	mEntry = NULL;
+}
+
 void LLDrawable::cleanupDeadDrawables()
 {
 	/*
@@ -715,7 +758,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 		LLVOVolume* volume = getVOVolume();
 		if (volume)
 		{
-			if (getSpatialGroup())
+			if (getGroup())
 			{
 				pos.set(getPositionGroup().getF32ptr());
 			}
@@ -833,9 +876,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 			}
 		}
 		
-		mExtents[0].add(shift_vector);
-		mExtents[1].add(shift_vector);
-		mPositionGroup.add(shift_vector);
+		shift(shift_vector);
 	}
 	else if (mSpatialBridge)
 	{
@@ -843,9 +884,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 	}
 	else if (isAvatar())
 	{
-		mExtents[0].add(shift_vector);
-		mExtents[1].add(shift_vector);
-		mPositionGroup.add(shift_vector);
+		shift(shift_vector);
 	}
 	
 	mVObjp->onShift(shift_vector);
@@ -857,40 +896,24 @@ const LLVector3& LLDrawable::getBounds(LLVector3& min, LLVector3& max) const
 	return mXform.getPositionW();
 }
 
-const LLVector4a* LLDrawable::getSpatialExtents() const
-{
-	return mExtents;
-}
-
-void LLDrawable::setSpatialExtents(const LLVector3& min, const LLVector3& max)
-{ 
-	mExtents[0].load3(min.mV); 
-	mExtents[1].load3(max.mV);
-}
-
-void LLDrawable::setSpatialExtents(const LLVector4a& min, const LLVector4a& max)
-{ 
-	mExtents[0] = min; 
-	mExtents[1] = max;
-}
-
-void LLDrawable::setPositionGroup(const LLVector4a& pos)
-{
-	mPositionGroup = pos;
-}
-
 void LLDrawable::updateSpatialExtents()
 {
 	if (mVObjp)
 	{
-		mVObjp->updateSpatialExtents(mExtents[0], mExtents[1]);
+		const LLVector4a* exts = getSpatialExtents();
+		LLVector4a extents[2];
+		extents[0] = exts[0];
+		extents[1] = exts[1];
+
+		mVObjp->updateSpatialExtents(extents[0], extents[1]);
+		setSpatialExtents(extents[0], extents[1]);
 	}
 	
 	updateBinRadius();
 	
 	if (mSpatialBridge.notNull())
 	{
-		mPositionGroup.splat(0.f);
+		getGroupPosition().splat(0.f);
 	}
 }
 
@@ -899,11 +922,11 @@ void LLDrawable::updateBinRadius()
 {
 	if (mVObjp.notNull())
 	{
-		mBinRadius = llmin(mVObjp->getBinRadius(), 256.f);
+		setBinRadius(llmin(mVObjp->getBinRadius(), 256.f));
 	}
 	else
 	{
-		mBinRadius = llmin(getRadius()*4.f, 256.f);
+		setBinRadius(llmin(getRadius()*4.f, 256.f));
 	}
 }
 
@@ -937,20 +960,48 @@ void LLDrawable::updateUVMinMax()
 {
 }
 
-LLSpatialGroup* LLDrawable::getSpatialGroup() const
-{ 
-	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
-	return mSpatialGroupp; 
+//virtual
+bool LLDrawable::isVisible() const
+{
+	if (LLViewerOctreeEntryData::isVisible())
+	{
+		return true;
+	}
+	
+	{
+		LLviewerOctreeGroup* group = mEntry->getGroup();
+		if (group && group->isVisible())
+		{
+			LLViewerOctreeEntryData::setVisible();
+			return true;
+		}
+	}
+
+	return false;
 }
 
-void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
+//virtual
+bool LLDrawable::isRecentlyVisible() const
 {
-/*if (mSpatialGroupp && (groupp != mSpatialGroupp))
+	//currently visible or visible in the previous frame.
+	bool vis = LLViewerOctreeEntryData::isRecentlyVisible();
+
+	if(!vis)
 	{
-		mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY);
-	}*/
+		LLviewerOctreeGroup* group = getGroup();
+		if (group && group->isRecentlyVisible())
+		{
+			LLViewerOctreeEntryData::setVisible();
+			vis = TRUE ;
+		}
+	}
+
+	return vis ;
+}
 
-	if (mSpatialGroupp != groupp && getVOVolume())
+void LLDrawable::setGroup(LLviewerOctreeGroup *groupp)
+{
+	if (getGroup() != groupp && getVOVolume())
 	{ //NULL out vertex buffer references for volumes on spatial group change to maintain
 		//requirement that every face vertex buffer is either NULL or points to a vertex buffer
 		//contained by its drawable's spatial group
@@ -964,9 +1015,7 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
 		}
 	}
 
-	mSpatialGroupp = groupp;
-
-	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
+	LLViewerOctreeEntryData::setGroup(groupp);
 }
 
 LLSpatialPartition* LLDrawable::getSpatialPartition()
@@ -985,11 +1034,11 @@ LLSpatialPartition* LLDrawable::getSpatialPartition()
 		{
 			if (mVObjp->isHUDAttachment())
 			{
-				setSpatialBridge(new LLHUDBridge(this));
+				setSpatialBridge(new LLHUDBridge(this, getRegion()));
 			}
 			else
 			{
-				setSpatialBridge(new LLVolumeBridge(this));
+				setSpatialBridge(new LLVolumeBridge(this, getRegion()));
 			}
 		}
 		return mSpatialBridge->asPartition();
@@ -1008,89 +1057,26 @@ LLSpatialPartition* LLDrawable::getSpatialPartition()
 	return retval;
 }
 
-const S32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one.
-//static 
-S32 LLDrawable::getMinVisFrameRange()
+//virtual
+S32 LLDrawable::getMinVisFrameRange() const
 {
-	return MIN_VIS_FRAME_RANGE ;
-}
-
-BOOL LLDrawable::isRecentlyVisible() const
-{
-	//currently visible or visible in the previous frame.
-	BOOL vis = isVisible() || (sCurVisible - mVisible < MIN_VIS_FRAME_RANGE)  ;
-
-	if(!vis)
-	{
-		LLSpatialGroup* group = getSpatialGroup();
-		if (group && group->isRecentlyVisible())
-		{
-			mVisible = sCurVisible;
-			vis = TRUE ;
-		}
-	}
-
-	return vis ;
-}
-
-BOOL LLDrawable::isVisible() const
-{
-	if (mVisible == sCurVisible)
-	{
-		return TRUE;
-	}
-	
-#if 0
-	//disabling this code fixes DEV-20105.  Leaving in place in case some other bug pops up as a a result.
-	//should be safe to just always ask the spatial group for visibility.
-	if (isActive())
-	{
-		if (isRoot())
-		{
-			LLSpatialGroup* group = mSpatialBridge.notNull() ? mSpatialBridge->getSpatialGroup() :
-									getSpatialGroup();
-			if (group && group->isVisible())
-			{
-				mVisible = sCurVisible;
-				return TRUE;
-			}
-		}
-		else
-		{
-			if (getParent()->isVisible())
-			{
-				mVisible = sCurVisible;
-				return TRUE;
-			}
-		}
-	}
-	else
-#endif
-	{
-		LLSpatialGroup* group = getSpatialGroup();
-		if (group && group->isVisible())
-		{
-			mVisible = sCurVisible;
-			return TRUE;
-		}
-	}
+	const S32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one.
 
-	return FALSE;
+	return MIN_VIS_FRAME_RANGE ;
 }
 
 //=======================================
 // Spatial Partition Bridging Drawable
 //=======================================
 
-LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask)
-: LLSpatialPartition(data_mask, render_by_group, GL_STREAM_DRAW_ARB)
+LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask, LLViewerRegion* regionp) : 
+	LLDrawable(root->getVObj(), true),
+	LLSpatialPartition(data_mask, render_by_group, GL_STREAM_DRAW_ARB, regionp)
 {
 	mBridge = this;
 	mDrawable = root;
 	root->setSpatialBridge(this);
 	
-	mBinIndex = -1;
-
 	mRenderType = mDrawable->mRenderType;
 	mDrawableType = mDrawable->mRenderType;
 	
@@ -1111,10 +1097,13 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat
 
 LLSpatialBridge::~LLSpatialBridge()
 {	
-	LLSpatialGroup* group = getSpatialGroup();
-	if (group)
+	if(mEntry)
 	{
-		group->mSpatialPartition->remove(this, group);
+		LLSpatialGroup* group = getSpatialGroup();
+		if (group)
+		{
+			group->mSpatialPartition->remove(this, group);
+		}
 	}
 
 	//delete octree here so listeners will still be able to access bridge specific state
@@ -1136,8 +1125,9 @@ void LLSpatialBridge::updateSpatialExtents()
 		root->rebound();
 	}
 	
+	const LLVector4a* root_bounds = root->getBounds();
 	LLVector4a offset;
-	LLVector4a size = root->mBounds[1];
+	LLVector4a size = root_bounds[1];
 		
 	//VECTORIZE THIS
 	LLMatrix4a mat;
@@ -1149,7 +1139,7 @@ void LLSpatialBridge::updateSpatialExtents()
 	LLVector4a center;
 	mat.affineTransform(t, center);
 	
-	mat.rotate(root->mBounds[0], offset);
+	mat.rotate(root_bounds[0], offset);
 	center.add(offset);
 	
 	LLVector4a v[4];
@@ -1171,12 +1161,9 @@ void LLSpatialBridge::updateSpatialExtents()
 	scale.mul(size);
 	mat.rotate(scale, v[3]);
 
-	
-	LLVector4a& newMin = mExtents[0];
-	LLVector4a& newMax = mExtents[1];
-	
-	newMin = newMax = center;
-	
+	LLVector4a newMin;
+	LLVector4a newMax;	
+	newMin = newMax = center;	
 	for (U32 i = 0; i < 4; i++)
 	{
 		LLVector4a delta;
@@ -1189,19 +1176,21 @@ void LLSpatialBridge::updateSpatialExtents()
 		newMin.setMin(newMin, min);
 		newMax.setMax(newMax, max);
 	}
-	
+	setSpatialExtents(newMin, newMax);
+
 	LLVector4a diagonal;
 	diagonal.setSub(newMax, newMin);
 	mRadius = diagonal.getLength3().getF32() * 0.5f;
 	
-	mPositionGroup.setAdd(newMin,newMax);
-	mPositionGroup.mul(0.5f);
+	LLVector4a& pos = getGroupPosition();
+	pos.setAdd(newMin,newMax);
+	pos.mul(0.5f);
 	updateBinRadius();
 }
 
 void LLSpatialBridge::updateBinRadius()
 {
-	mBinRadius = llmin( mOctree->getSize()[0]*0.5f, 256.f);
+	setBinRadius(llmin( mOctree->getSize()[0]*0.5f, 256.f));
 }
 
 LLCamera LLSpatialBridge::transformCamera(LLCamera& camera)
@@ -1236,7 +1225,7 @@ LLCamera LLSpatialBridge::transformCamera(LLCamera& camera)
 
 void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results, BOOL for_select)
 {
-	mVisible = sCurVisible;
+	LLViewerOctreeEntryData::setVisible();
 	
 #if 0 && !LL_RELEASE_FOR_DOWNLOAD
 	//crazy paranoid rules checking
@@ -1271,21 +1260,21 @@ void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results,
 #endif
 }
 
-class LLOctreeMarkNotCulled: public LLOctreeTraveler<LLDrawable>
+class LLOctreeMarkNotCulled: public OctreeTraveler
 {
 public:
 	LLCamera* mCamera;
 	
 	LLOctreeMarkNotCulled(LLCamera* camera_in) : mCamera(camera_in) { }
 	
-	virtual void traverse(const LLOctreeNode<LLDrawable>* node)
+	virtual void traverse(const OctreeNode* node)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 		group->setVisible();
-		LLOctreeTraveler<LLDrawable>::traverse(node);
+		OctreeTraveler::traverse(node);
 	}
 	
-	void visit(const LLOctreeNode<LLDrawable>* branch)
+	void visit(const OctreeNode* branch)
 	{
 		gPipeline.markNotCulled((LLSpatialGroup*) branch->getListener(0), *mCamera);
 	}
@@ -1329,7 +1318,7 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 			}
 
 			if (!group ||
-				LLDrawable::getCurrentFrame() - av->mVisible > 1 ||
+				LLDrawable::getCurrentFrame() - av->getVisible() > 1 ||
 				impostor ||
 				!loaded)
 			{
@@ -1343,16 +1332,17 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>*
 	group->rebound();
 	
 	LLVector4a center;
-	center.setAdd(mExtents[0], mExtents[1]);
+	const LLVector4a* exts = getSpatialExtents();
+	center.setAdd(exts[0], exts[1]);
 	center.mul(0.5f);
 	LLVector4a size;
-	size.setSub(mExtents[1], mExtents[0]);
+	size.setSub(exts[1], exts[0]);
 	size.mul(0.5f);
 
 	if ((LLPipeline::sShadowRender && camera_in.AABBInFrustum(center, size)) ||
 		LLPipeline::sImpostorRender ||
 		(camera_in.AABBInFrustumNoFarClip(center, size) && 
-		AABBSphereIntersect(mExtents[0], mExtents[1], camera_in.getOrigin(), camera_in.mFrustumCornerDist)))
+		AABBSphereIntersect(exts[0], exts[1], camera_in.getOrigin(), camera_in.mFrustumCornerDist)))
 	{
 		if (!LLPipeline::sImpostorRender &&
 			!LLPipeline::sShadowRender && 
@@ -1467,22 +1457,28 @@ BOOL LLSpatialBridge::updateMove()
 
 void LLSpatialBridge::shiftPos(const LLVector4a& vec)
 {
-	mExtents[0].add(vec);
-	mExtents[1].add(vec);
-	mPositionGroup.add(vec);
+	LLDrawable::shift(vec);
 }
 
 void LLSpatialBridge::cleanupReferences()
 {	
+	LLPointer<LLVOCacheEntry> dummy_entry;
+	if (mDrawable && mDrawable->isDead() && mDrawable->getEntry()->hasVOCacheEntry())
+	{
+		//create a dummy entry to insert the entire LLSpatialBridge to the vo_cache partition so it can be reloaded.
+
+		dummy_entry = new LLVOCacheEntry();
+		dummy_entry->setOctreeEntry(mEntry);
+		dummy_entry->addChild((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry());
+		llassert(!mDrawable->getParent());
+		
+		mDrawable->mParent = this;
+	}
+
 	LLDrawable::cleanupReferences();
 	if (mDrawable)
 	{
-		LLSpatialGroup* group = mDrawable->getSpatialGroup();
-		if (group)
-		{
-			group->mOctreeNode->remove(mDrawable);
-			mDrawable->setSpatialGroup(NULL);
-		}
+		mDrawable->setGroup(NULL);
 		
 		if (mDrawable->getVObj())
 		{
@@ -1494,12 +1490,7 @@ void LLSpatialBridge::cleanupReferences()
 				LLDrawable* drawable = child->mDrawable;					
 				if (drawable)
 				{
-					LLSpatialGroup* group = drawable->getSpatialGroup();
-					if (group)
-					{
-						group->mOctreeNode->remove(drawable);
-						drawable->setSpatialGroup(NULL);
-					}
+					drawable->setGroup(NULL);				
 				}
 			}
 		}
@@ -1571,8 +1562,8 @@ void LLDrawable::updateFaceSize(S32 idx)
 	}
 }
 
-LLBridgePartition::LLBridgePartition()
-: LLSpatialPartition(0, FALSE, 0) 
+LLBridgePartition::LLBridgePartition(LLViewerRegion* regionp)
+: LLSpatialPartition(0, FALSE, 0, regionp) 
 { 
 	mDrawableType = LLPipeline::RENDER_TYPE_AVATAR; 
 	mPartitionType = LLViewerRegion::PARTITION_BRIDGE;
@@ -1580,8 +1571,8 @@ LLBridgePartition::LLBridgePartition()
 	mSlopRatio = 0.25f;
 }
 
-LLHUDBridge::LLHUDBridge(LLDrawable* drawablep)
-: LLVolumeBridge(drawablep)
+LLHUDBridge::LLHUDBridge(LLDrawable* drawablep, LLViewerRegion* regionp)
+: LLVolumeBridge(drawablep, regionp)
 {
 	mDrawableType = LLPipeline::RENDER_TYPE_HUD;
 	mPartitionType = LLViewerRegion::PARTITION_HUD;
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 4608d16fec..8e193a02bd 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -42,6 +42,7 @@
 #include "llviewerobject.h"
 #include "llrect.h"
 #include "llappviewer.h" // for gFrameTimeSeconds
+#include "llvieweroctree.h"
 
 class LLCamera;
 class LLDrawPool;
@@ -59,10 +60,10 @@ const U32 SILHOUETTE_HIGHLIGHT = 0;
 
 // All data for new renderer goes into this class.
 LL_ALIGN_PREFIX(16)
-class LLDrawable : public LLRefCount
+class LLDrawable : public LLViewerOctreeEntryData
 {
 public:
-	LLDrawable(const LLDrawable& rhs)
+	LLDrawable(const LLDrawable& rhs) : LLViewerOctreeEntryData(rhs)
 	{
 		*this = rhs;
 	}
@@ -85,19 +86,17 @@ public:
 		ll_aligned_free_16(ptr);
 	}
 
-	LLDrawable()				{ init(); }
+	LLDrawable(LLViewerObject *vobj, bool new_entry = false);
 	
 	void markDead();			// Mark this drawable as dead
 	BOOL isDead() const			{ return isState(DEAD); }
 	BOOL isNew() const			{ return !isState(BUILT); }
 
 	BOOL isLight() const;
-
-	BOOL isVisible() const;	
-	BOOL isRecentlyVisible() const;	
+	
 	virtual void setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* results = NULL, BOOL for_select = FALSE);
 
-
+	LLSpatialGroup* getSpatialGroup()const          {return (LLSpatialGroup*)getGroup();}
 	LLViewerRegion* getRegion()               const { return mVObjp->getRegion(); }
 	const LLTextureEntry* getTextureEntry(U8 which) const { return mVObjp->getTE(which); }
 	LLPointer<LLViewerObject>& getVObj()							  { return mVObjp; }
@@ -110,17 +109,13 @@ public:
 	const LLVector3&	  getPosition() const			{ return mXform.getPosition(); }
 	const LLVector3&      getWorldPosition() const		{ return mXform.getPositionW(); }
 	const LLVector3		  getPositionAgent() const;
-	const LLVector4a&	  getPositionGroup() const		{ return mPositionGroup; }
 	const LLVector3&	  getScale() const				{ return mCurrentScale; }
 	void				  setScale(const LLVector3& scale) { mCurrentScale = scale; }
 	const LLQuaternion&   getWorldRotation() const		{ return mXform.getWorldRotation(); }
 	const LLQuaternion&   getRotation() const			{ return mXform.getRotation(); }
 	F32			          getIntensity() const			{ return llmin(mXform.getScale().mV[0], 4.f); }
 	S32					  getLOD() const				{ return mVObjp ? mVObjp->getLOD() : 1; }
-	F32					  getBinRadius() const			{ return mBinRadius; }
-	S32					  getBinIndex() const			{ return mBinIndex; }
-	void				  setBinIndex(S32 index) const	{ mBinIndex = index; }
-
+	
 	void  getMinMax(LLVector3& min,LLVector3& max) const { mXform.getMinMax(min,max); }
 	LLXformMatrix*		getXform() { return &mXform; }
 
@@ -150,7 +145,7 @@ public:
 	void                setNumFacesFast(const S32 numFaces, LLFacePool *poolp, LLViewerTexture *texturep);
 	void				mergeFaces(LLDrawable* src);
 
-	void init();
+	void init(bool new_entry);
 	void destroy();
 
 	void update();
@@ -181,8 +176,12 @@ public:
 	BOOL getLit() const							{ return isState(UNLIT) ? FALSE : TRUE; }
 	void setLit(BOOL lit)						{ lit ? clearState(UNLIT) : setState(UNLIT); }
 
+	bool isVisible() const;
+	bool isRecentlyVisible() const;
+
 	virtual void cleanupReferences();
 
+	void setGroup(LLviewerOctreeGroup* group);
 	void setRadius(const F32 radius);
 	F32 getRadius() const						{ return mRadius; }
 	F32 getVisibilityRadius() const;
@@ -192,11 +191,6 @@ public:
 	const LLVector3& getBounds(LLVector3& min, LLVector3& max) const;
 	virtual void updateSpatialExtents();
 	virtual void updateBinRadius();
-	const LLVector4a* getSpatialExtents() const;
-	void setSpatialExtents(const LLVector3& min, const LLVector3& max);
-	void setSpatialExtents(const LLVector4a& min, const LLVector4a& max);
-
-	void setPositionGroup(const LLVector4a& pos);
 	
 	void setRenderType(S32 type) 				{ mRenderType = type; }
 	BOOL isRenderType(S32 type) 				{ return mRenderType == type; }
@@ -205,10 +199,14 @@ public:
 	// Debugging methods
 	S32 findReferences(LLDrawable *drawablep); // Not const because of @#$! iterators...
 
-	void setSpatialGroup(LLSpatialGroup *groupp);
-	LLSpatialGroup *getSpatialGroup() const;
 	LLSpatialPartition* getSpatialPartition();
 	
+	virtual S32 getMinVisFrameRange()const;
+	void removeFromOctree();
+
+	void setSpatialBridge(LLSpatialBridge* bridge) { mSpatialBridge = (LLDrawable*) bridge; }
+	LLSpatialBridge* getSpatialBridge() { return (LLSpatialBridge*) (LLDrawable*) mSpatialBridge; }
+
 	// Statics
 	static void incrementVisible();
 	static void cleanupDeadDrawables();
@@ -292,10 +290,6 @@ public:
 		ANIMATED_CHILD  = 0x20000000,
 		ACTIVE_CHILD	= 0x40000000,
 	} EDrawableFlags;
-
-private: //aligned members
-	LL_ALIGN_16(LLVector4a		mExtents[2]);
-	LL_ALIGN_16(LLVector4a		mPositionGroup);
 	
 public:
 	LLXformMatrix       mXform;
@@ -303,35 +297,23 @@ public:
 	// vis data
 	LLPointer<LLDrawable> mParent;
 
-	F32				mDistanceWRTCamera;
-
-	static S32 getCurrentFrame() { return sCurVisible; }
-	static S32 getMinVisFrameRange();
-
-	void setSpatialBridge(LLSpatialBridge* bridge) { mSpatialBridge = (LLDrawable*) bridge; }
-	LLSpatialBridge* getSpatialBridge() { return (LLSpatialBridge*) (LLDrawable*) mSpatialBridge; }
+	F32				mDistanceWRTCamera;	
 	
 	static F32 sCurPixelAngle; //current pixels per radian
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
 	
-	U32				mState;
+	U32             mState;
 	S32				mRenderType;
 	LLPointer<LLViewerObject> mVObjp;
 	face_list_t     mFaces;
-	LLSpatialGroup* mSpatialGroupp;
 	LLPointer<LLDrawable> mSpatialBridge;
-	
-	mutable U32		mVisible;
+		
 	F32				mRadius;
-	F32				mBinRadius;
-	mutable S32		mBinIndex;
 	S32				mGeneration;
 	
-	LLVector3		mCurrentScale;
-	
-	static U32 sCurVisible; // Counter for what value of mVisible means currently visible
+	LLVector3		mCurrentScale;	
 
 	static U32 sNumZombieDrawables;
 	static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 5083478392..debb790c58 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -138,94 +138,6 @@ void sg_assert(BOOL expr)
 #endif
 }
 
-S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad)
-{
-	return AABBSphereIntersectR2(min, max, origin, rad*rad);
-}
-
-S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &r)
-{
-	F32 d = 0.f;
-	F32 t;
-	
-	if ((min-origin).magVecSquared() < r &&
-		(max-origin).magVecSquared() < r)
-	{
-		return 2;
-	}
-
-	for (U32 i = 0; i < 3; i++)
-	{
-		if (origin.mV[i] < min.mV[i])
-		{
-			t = min.mV[i] - origin.mV[i];
-			d += t*t;
-		}
-		else if (origin.mV[i] > max.mV[i])
-		{
-			t = origin.mV[i] - max.mV[i];
-			d += t*t;
-		}
-
-		if (d > r)
-		{
-			return 0;
-		}
-	}
-
-	return 1;
-}
-
-
-S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad)
-{
-	return AABBSphereIntersectR2(min, max, origin, rad*rad);
-}
-
-S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &r)
-{
-	F32 d = 0.f;
-	F32 t;
-	
-	LLVector4a origina;
-	origina.load3(origin.mV);
-
-	LLVector4a v;
-	v.setSub(min, origina);
-	
-	if (v.dot3(v) < r)
-	{
-		v.setSub(max, origina);
-		if (v.dot3(v) < r)
-		{
-			return 2;
-		}
-	}
-
-
-	for (U32 i = 0; i < 3; i++)
-	{
-		if (origin.mV[i] < min[i])
-		{
-			t = min[i] - origin.mV[i];
-			d += t*t;
-		}
-		else if (origin.mV[i] > max[i])
-		{
-			t = origin.mV[i] - max[i];
-			d += t*t;
-		}
-
-		if (d > r)
-		{
-			return 0;
-		}
-	}
-
-	return 1;
-}
-
-
 typedef enum
 {
 	b000 = 0x00,
@@ -352,13 +264,17 @@ LLSpatialGroup::~LLSpatialGroup()
 	{
 		llerrs << "Illegal deletion of LLSpatialGroup!" << llendl;
 	}*/
+	if(isVisible())
+	{
+		mSpatialPartition->mRegionp->clearVisibleGroup(this);
+	}
 
 	if (gDebugGL)
 	{
 		gPipeline.checkReferences(this);
 	}
 
-	if (isState(DEAD))
+	if (hasState(DEAD))
 	{
 		sZombieGroups--;
 	}
@@ -514,7 +430,8 @@ BOOL LLSpatialGroup::isHUDGroup()
 
 BOOL LLSpatialGroup::isRecentlyVisible() const
 {
-	return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < LLDrawable::getMinVisFrameRange() ;
+	const S32 MIN_VIS_FRAME_RANGE = 2;
+	return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < MIN_VIS_FRAME_RANGE ;
 }
 
 BOOL LLSpatialGroup::isVisible() const
@@ -619,7 +536,7 @@ BOOL LLSpatialGroup::updateInGroup(LLDrawable *drawablep, BOOL immediate)
 	OctreeNode* parent = mOctreeNode->getOctParent();
 	
 	if (mOctreeNode->isInside(drawablep->getPositionGroup()) && 
-		(mOctreeNode->contains(drawablep) ||
+		(mOctreeNode->contains(drawablep->getEntry()) ||
 		 (drawablep->getBinRadius() > mOctreeNode->getSize()[0] &&
 				parent && parent->getElementCount() >= gOctreeMaxCapacity)))
 	{
@@ -633,15 +550,14 @@ BOOL LLSpatialGroup::updateInGroup(LLDrawable *drawablep, BOOL immediate)
 }
 
 
-BOOL LLSpatialGroup::addObject(LLDrawable *drawablep, BOOL add_all, BOOL from_octree)
+BOOL LLSpatialGroup::addObject(LLDrawable *drawablep)
 {
-	if (!from_octree)
+	if(!drawablep)
 	{
-		mOctreeNode->insert(drawablep);
+		return FALSE;
 	}
-	else
 	{
-		drawablep->setSpatialGroup(this);
+		drawablep->setGroup(this);
 		setState(OBJECT_DIRTY | GEOM_DIRTY);
 		setOcclusionState(LLSpatialGroup::DISCARD_QUERY, LLSpatialGroup::STATE_MODE_ALL_CAMERAS);
 		gPipeline.markRebuild(this, TRUE);
@@ -664,7 +580,7 @@ void LLSpatialGroup::rebuildGeom()
 	{
 		mSpatialPartition->rebuildGeom(this);
 
-		if (isState(LLSpatialGroup::MESH_DIRTY))
+		if (hasState(LLSpatialGroup::MESH_DIRTY))
 		{
 			gPipeline.markMeshDirty(this);
 		}
@@ -686,7 +602,7 @@ static LLFastTimer::DeclareTimer FTM_GET_GEOMETRY("Get Geometry");
 
 void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group)
 {
-	if (group->isDead() || !group->isState(LLSpatialGroup::GEOM_DIRTY))
+	if (group->isDead() || !group->hasState(LLSpatialGroup::GEOM_DIRTY))
 	{
 		return;
 	}
@@ -751,103 +667,6 @@ void LLSpatialPartition::rebuildMesh(LLSpatialGroup* group)
 
 }
 
-BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut)
-{	
-	const OctreeNode* node = mOctreeNode;
-
-	if (node->isEmpty())
-	{	//don't do anything if there are no objects
-		if (empty && mOctreeNode->getParent())
-		{	//only root is allowed to be empty
-			OCT_ERRS << "Empty leaf found in octree." << llendl;
-		}
-		return FALSE;
-	}
-
-	LLVector4a& newMin = mObjectExtents[0];
-	LLVector4a& newMax = mObjectExtents[1];
-	
-	if (isState(OBJECT_DIRTY))
-	{ //calculate new bounding box
-		clearState(OBJECT_DIRTY);
-
-		//initialize bounding box to first element
-		OctreeNode::const_element_iter i = node->getDataBegin();
-		LLDrawable* drawablep = *i;
-		const LLVector4a* minMax = drawablep->getSpatialExtents();
-
-		newMin = minMax[0];
-		newMax = minMax[1];
-
-		for (++i; i != node->getDataEnd(); ++i)
-		{
-			drawablep = *i;
-			minMax = drawablep->getSpatialExtents();
-			
-			update_min_max(newMin, newMax, minMax[0]);
-			update_min_max(newMin, newMax, minMax[1]);
-
-			//bin up the object
-			/*for (U32 i = 0; i < 3; i++)
-			{
-				if (minMax[0].mV[i] < newMin.mV[i])
-				{
-					newMin.mV[i] = minMax[0].mV[i];
-				}
-				if (minMax[1].mV[i] > newMax.mV[i])
-				{
-					newMax.mV[i] = minMax[1].mV[i];
-				}
-			}*/
-		}
-		
-		mObjectBounds[0].setAdd(newMin, newMax);
-		mObjectBounds[0].mul(0.5f);
-		mObjectBounds[1].setSub(newMax, newMin);
-		mObjectBounds[1].mul(0.5f);
-	}
-	
-	if (empty)
-	{
-		minOut = newMin;
-		maxOut = newMax;
-	}
-	else
-	{
-		minOut.setMin(minOut, newMin);
-		maxOut.setMax(maxOut, newMax);
-	}
-		
-	return TRUE;
-}
-
-void LLSpatialGroup::unbound()
-{
-	if (isState(DIRTY))
-	{
-		return;
-	}
-
-	setState(DIRTY);
-	
-	//all the parent nodes need to rebound this child
-	if (mOctreeNode)
-	{
-		OctreeNode* parent = (OctreeNode*) mOctreeNode->getParent();
-		while (parent != NULL)
-		{
-			LLSpatialGroup* group = (LLSpatialGroup*) parent->getListener(0);
-			if (group->isState(DIRTY))
-			{
-				return;
-			}
-			
-			group->setState(DIRTY);
-			parent = (OctreeNode*) parent->getParent();
-		}
-	}
-}
-
 LLSpatialGroup* LLSpatialGroup::getParent()
 {
 	if (isDead())
@@ -871,17 +690,19 @@ LLSpatialGroup* LLSpatialGroup::getParent()
 
 BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree)
 {
+	if(!drawablep)
+	{
+		return FALSE;
+	}
+
 	unbound();
 	if (mOctreeNode && !from_octree)
 	{
-		if (!mOctreeNode->remove(drawablep))
-		{
-			OCT_ERRS << "Could not remove drawable from spatial group" << llendl;
-		}
+		drawablep->setGroup(NULL);
 	}
 	else
 	{
-		drawablep->setSpatialGroup(NULL);
+		drawablep->setGroup(NULL);
 		setState(GEOM_DIRTY);
 		gPipeline.markRebuild(this, TRUE);
 
@@ -928,12 +749,12 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
 	}
 }
 
-class LLSpatialSetState : public LLSpatialGroup::OctreeTraveler
+class LLSpatialSetState : public OctreeTraveler
 {
 public:
 	U32 mState;
 	LLSpatialSetState(U32 state) : mState(state) { }
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->setState(mState); }	
+	virtual void visit(const OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->setState(mState); }	
 };
 
 class LLSpatialSetStateDiff : public LLSpatialSetState
@@ -941,24 +762,17 @@ class LLSpatialSetStateDiff : public LLSpatialSetState
 public:
 	LLSpatialSetStateDiff(U32 state) : LLSpatialSetState(state) { }
 
-	virtual void traverse(const LLSpatialGroup::OctreeNode* n)
+	virtual void traverse(const OctreeNode* n)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
 		
-		if (!group->isState(mState))
+		if (!group->hasState(mState))
 		{
-			LLSpatialGroup::OctreeTraveler::traverse(n);
+			OctreeTraveler::traverse(n);
 		}
 	}
 };
 
-void LLSpatialGroup::setState(U32 state) 
-{ 
-	mState |= state; 
-	
-	llassert(state <= LLSpatialGroup::STATE_MASK);
-}	
-
 void LLSpatialGroup::setState(U32 state, S32 mode) 
 {
 	llassert(state <= LLSpatialGroup::STATE_MASK);
@@ -982,12 +796,12 @@ void LLSpatialGroup::setState(U32 state, S32 mode)
 	}
 }
 
-class LLSpatialClearState : public LLSpatialGroup::OctreeTraveler
+class LLSpatialClearState : public OctreeTraveler
 {
 public:
 	U32 mState;
 	LLSpatialClearState(U32 state) : mState(state) { }
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->clearState(mState); }
+	virtual void visit(const OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->clearState(mState); }
 };
 
 class LLSpatialClearStateDiff : public LLSpatialClearState
@@ -995,24 +809,17 @@ class LLSpatialClearStateDiff : public LLSpatialClearState
 public:
 	LLSpatialClearStateDiff(U32 state) : LLSpatialClearState(state) { }
 
-	virtual void traverse(const LLSpatialGroup::OctreeNode* n)
+	virtual void traverse(const OctreeNode* n)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
 		
-		if (group->isState(mState))
+		if (group->hasState(mState))
 		{
-			LLSpatialGroup::OctreeTraveler::traverse(n);
+			OctreeTraveler::traverse(n);
 		}
 	}
 };
 
-void LLSpatialGroup::clearState(U32 state)
-{
-	llassert(state <= LLSpatialGroup::STATE_MASK);
-
-	mState &= ~state; 
-}
-
 void LLSpatialGroup::clearState(U32 state, S32 mode)
 {
 	llassert(state <= LLSpatialGroup::STATE_MASK);
@@ -1036,22 +843,15 @@ void LLSpatialGroup::clearState(U32 state, S32 mode)
 	}
 }
 
-BOOL LLSpatialGroup::isState(U32 state) const
-{ 
-	llassert(state <= LLSpatialGroup::STATE_MASK);
-
-	return mState & state ? TRUE : FALSE; 
-}
-
 //=====================================
 //		Occlusion State Set/Clear
 //=====================================
-class LLSpatialSetOcclusionState : public LLSpatialGroup::OctreeTraveler
+class LLSpatialSetOcclusionState : public OctreeTraveler
 {
 public:
 	U32 mState;
 	LLSpatialSetOcclusionState(U32 state) : mState(state) { }
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->setOcclusionState(mState); }	
+	virtual void visit(const OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->setOcclusionState(mState); }	
 };
 
 class LLSpatialSetOcclusionStateDiff : public LLSpatialSetOcclusionState
@@ -1059,13 +859,13 @@ class LLSpatialSetOcclusionStateDiff : public LLSpatialSetOcclusionState
 public:
 	LLSpatialSetOcclusionStateDiff(U32 state) : LLSpatialSetOcclusionState(state) { }
 
-	virtual void traverse(const LLSpatialGroup::OctreeNode* n)
+	virtual void traverse(const OctreeNode* n)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
 		
 		if (!group->isOcclusionState(mState))
 		{
-			LLSpatialGroup::OctreeTraveler::traverse(n);
+			OctreeTraveler::traverse(n);
 		}
 	}
 };
@@ -1110,13 +910,13 @@ void LLSpatialGroup::setOcclusionState(U32 state, S32 mode)
 	}
 }
 
-class LLSpatialClearOcclusionState : public LLSpatialGroup::OctreeTraveler
+class LLSpatialClearOcclusionState : public OctreeTraveler
 {
 public:
 	U32 mState;
 	
 	LLSpatialClearOcclusionState(U32 state) : mState(state) { }
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->clearOcclusionState(mState); }
+	virtual void visit(const OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->clearOcclusionState(mState); }
 };
 
 class LLSpatialClearOcclusionStateDiff : public LLSpatialClearOcclusionState
@@ -1124,13 +924,13 @@ class LLSpatialClearOcclusionStateDiff : public LLSpatialClearOcclusionState
 public:
 	LLSpatialClearOcclusionStateDiff(U32 state) : LLSpatialClearOcclusionState(state) { }
 
-	virtual void traverse(const LLSpatialGroup::OctreeNode* n)
+	virtual void traverse(const OctreeNode* n)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
 		
 		if (group->isOcclusionState(mState))
 		{
-			LLSpatialGroup::OctreeTraveler::traverse(n);
+			OctreeTraveler::traverse(n);
 		}
 	}
 };
@@ -1166,13 +966,11 @@ void LLSpatialGroup::clearOcclusionState(U32 state, S32 mode)
 //		Octree Listener Implementation
 //======================================
 
-LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
+LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLviewerOctreeGroup(node),
 	mObjectBoxSize(1.f),
-	mState(0),
 	mGeometryBytes(0),
 	mSurfaceArea(0.f),
 	mBuilt(0.f),
-	mOctreeNode(node),
 	mSpatialPartition(part),
 	mVertexBuffer(NULL), 
 	mBufferUsage(part->mBufferUsage),
@@ -1191,17 +989,11 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
 
 	mViewAngle.splat(0.f);
 	mLastUpdateViewAngle.splat(-1.f);
-	mExtents[0] = mExtents[1] = mObjectBounds[0] = mObjectBounds[0] = mObjectBounds[1] = 
-		mObjectExtents[0] = mObjectExtents[1] = mViewAngle;
-
+	
 	sg_assert(mOctreeNode->getListenerCount() == 0);
-	mOctreeNode->addListener(this);
 	setState(SG_INITIAL_STATE_MASK);
 	gPipeline.markRebuild(this, TRUE);
 
-	mBounds[0] = node->getCenter();
-	mBounds[1] = node->getSize();
-
 	part->mLODSeed = (part->mLODSeed+1)%part->mLODPeriod;
 	mLODHash = part->mLODSeed;
 
@@ -1235,7 +1027,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 	}
 
 #if !LL_RELEASE_FOR_DOWNLOAD
-	if (isState(LLSpatialGroup::OBJECT_DIRTY))
+	if (hasState(LLSpatialGroup::OBJECT_DIRTY))
 	{
 		llerrs << "Spatial group dirty on distance update." << llendl;
 	}
@@ -1266,7 +1058,7 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera)
 		dist = eye.getLength3().getF32();
 		eye.normalize3fast();
 
-		if (!group->isState(LLSpatialGroup::ALPHA_DIRTY))
+		if (!group->hasState(LLSpatialGroup::ALPHA_DIRTY))
 		{
 			if (!group->mSpatialPartition->isBridge())
 			{
@@ -1343,7 +1135,7 @@ BOOL LLSpatialGroup::needsUpdate()
 
 BOOL LLSpatialGroup::changeLOD()
 {
-	if (isState(ALPHA_DIRTY | OBJECT_DIRTY))
+	if (hasState(ALPHA_DIRTY | OBJECT_DIRTY))
 	{ ///a rebuild is going to happen, update distance and LoD
 		return TRUE;
 	}
@@ -1371,29 +1163,51 @@ BOOL LLSpatialGroup::changeLOD()
 	return FALSE;
 }
 
-void LLSpatialGroup::handleInsertion(const TreeNode* node, LLDrawable* drawablep)
+void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* entry)
 {
-	addObject(drawablep, FALSE, TRUE);
+	if(mSpatialPartition->isVOCachePartition())
+	{
+		LLviewerOctreeGroup::handleInsertion(node, entry);
+		return;
+	}
+		
+	addObject((LLDrawable*)entry->getDrawable());
 	unbound();
 	setState(OBJECT_DIRTY);
 }
 
-void LLSpatialGroup::handleRemoval(const TreeNode* node, LLDrawable* drawable)
+void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* entry)
 {
-	removeObject(drawable, TRUE);
-	setState(OBJECT_DIRTY);
+	if(!mSpatialPartition->isVOCachePartition())
+	{
+		removeObject((LLDrawable*)entry->getDrawable(), TRUE);
+	}
+	LLviewerOctreeGroup::handleRemoval(node, entry);
 }
 
 void LLSpatialGroup::handleDestruction(const TreeNode* node)
 {
 	setState(DEAD);
-	
+
+	if(mSpatialPartition->isVOCachePartition())
+	{
+		LLviewerOctreeGroup::handleDestruction(node);
+		return;
+	}
+
 	for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
 	{
-		LLDrawable* drawable = *i;
-		if (drawable->getSpatialGroup() == this)
+		LLViewerOctreeEntry* entry = *i;
+		if (entry->getGroup() == this)
 		{
-			drawable->setSpatialGroup(NULL);
+			if(entry->hasDrawable())
+			{
+				((LLDrawable*)entry->getDrawable())->setGroup(NULL);
+			}
+			else
+			{
+				llerrs << "No Drawable found in the entry." << llendl;
+			}
 		}
 	}
 	
@@ -1415,16 +1229,6 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
 	mOctreeNode = NULL;
 }
 
-void LLSpatialGroup::handleStateChange(const TreeNode* node)
-{
-	//drop bounding box upon state change
-	if (mOctreeNode != node)
-	{
-		mOctreeNode = (OctreeNode*) node;
-	}
-	unbound();
-}
-
 void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) 
 {
 	if (child->getListenerCount() == 0)
@@ -1441,11 +1245,6 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c
 	assert_states_valid(this);
 }
 
-void LLSpatialGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child)
-{
-	unbound();
-}
-
 void LLSpatialGroup::destroyGL(bool keep_occlusion) 
 {
 	setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY);
@@ -1476,7 +1275,11 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 
 	for (LLSpatialGroup::element_iter i = getDataBegin(); i != getDataEnd(); ++i)
 	{
-		LLDrawable* drawable = *i;
+		LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+		if(!drawable)
+		{
+			continue;
+		}
 		for (S32 j = 0; j < drawable->getNumFaces(); j++)
 		{
 			LLFace* facep = drawable->getFace(j);
@@ -1488,69 +1291,6 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 	}
 }
 
-BOOL LLSpatialGroup::rebound()
-{
-	if (!isState(DIRTY))
-	{	//return TRUE if we're not empty
-		return TRUE;
-	}
-	
-	if (mOctreeNode->getChildCount() == 1 && mOctreeNode->getElementCount() == 0)
-	{
-		LLSpatialGroup* group = (LLSpatialGroup*) mOctreeNode->getChild(0)->getListener(0);
-		group->rebound();
-		
-		//copy single child's bounding box
-		mBounds[0] = group->mBounds[0];
-		mBounds[1] = group->mBounds[1];
-		mExtents[0] = group->mExtents[0];
-		mExtents[1] = group->mExtents[1];
-		
-		group->setState(SKIP_FRUSTUM_CHECK);
-	}
-	else if (mOctreeNode->isLeaf())
-	{ //copy object bounding box if this is a leaf
-		boundObjects(TRUE, mExtents[0], mExtents[1]);
-		mBounds[0] = mObjectBounds[0];
-		mBounds[1] = mObjectBounds[1];
-	}
-	else
-	{
-		LLVector4a& newMin = mExtents[0];
-		LLVector4a& newMax = mExtents[1];
-		LLSpatialGroup* group = (LLSpatialGroup*) mOctreeNode->getChild(0)->getListener(0);
-		group->clearState(SKIP_FRUSTUM_CHECK);
-		group->rebound();
-		//initialize to first child
-		newMin = group->mExtents[0];
-		newMax = group->mExtents[1];
-
-		//first, rebound children
-		for (U32 i = 1; i < mOctreeNode->getChildCount(); i++)
-		{
-			group = (LLSpatialGroup*) mOctreeNode->getChild(i)->getListener(0);
-			group->clearState(SKIP_FRUSTUM_CHECK);
-			group->rebound();
-			const LLVector4a& max = group->mExtents[1];
-			const LLVector4a& min = group->mExtents[0];
-
-			newMax.setMax(newMax, max);
-			newMin.setMin(newMin, min);
-		}
-
-		boundObjects(FALSE, newMin, newMax);
-		
-		mBounds[0].setAdd(newMin, newMax);
-		mBounds[0].mul(0.5f);
-		mBounds[1].setSub(newMax, newMin);
-		mBounds[1].mul(0.5f);
-	}
-	
-	clearState(DIRTY);
-
-	return TRUE;
-}
-
 static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion");
 static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait");
 
@@ -1769,8 +1509,8 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera)
 
 //==============================================
 
-LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 buffer_usage)
-: mRenderByGroup(render_by_group), mBridge(NULL)
+LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 buffer_usage, LLViewerRegion* regionp)
+: mRenderByGroup(render_by_group), mBridge(NULL), mRegionp(regionp)
 {
 	mOcclusionEnabled = TRUE;
 	mDrawableType = 0;
@@ -1782,13 +1522,13 @@ LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32
 	mDepthMask = FALSE;
 	mSlopRatio = 0.25f;
 	mInfiniteFarClip = FALSE;
+	mVisitedTime = 0;
 
 	LLVector4a center, size;
 	center.splat(0.f);
 	size.splat(1.f);
 
-	mOctree = new LLSpatialGroup::OctreeRoot(center,size,
-											NULL);
+	mOctree = new OctreeRoot(center,size, NULL);
 	new LLSpatialGroup(mOctree, this);
 }
 
@@ -1799,6 +1539,10 @@ LLSpatialPartition::~LLSpatialPartition()
 	mOctree = NULL;
 }
 
+BOOL LLSpatialPartition::isVOCachePartition() const
+{
+	return mPartitionType == LLViewerRegion::PARTITION_VO_CACHE;
+}
 
 LLSpatialGroup *LLSpatialPartition::put(LLDrawable *drawablep, BOOL was_visible)
 {
@@ -1806,12 +1550,16 @@ LLSpatialGroup *LLSpatialPartition::put(LLDrawable *drawablep, BOOL was_visible)
 
 	//keep drawable from being garbage collected
 	LLPointer<LLDrawable> ptr = drawablep;
-		
-	assert_octree_valid(mOctree);
-	mOctree->insert(drawablep);
-	assert_octree_valid(mOctree);
+			
+	if(!drawablep->getGroup())
+	{
+		assert_octree_valid(mOctree);
+		mOctree->insert(drawablep->getEntry());
+		assert_octree_valid(mOctree);
+	}	
 	
 	LLSpatialGroup* group = drawablep->getSpatialGroup();
+	llassert(group != NULL);
 
 	if (group && was_visible && group->isOcclusionState(LLSpatialGroup::QUERY_PENDING))
 	{
@@ -1829,7 +1577,7 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
 	}
 	else
 	{
-		drawablep->setSpatialGroup(NULL);
+		drawablep->setGroup(NULL);
 	}
 
 	assert_octree_valid(mOctree);
@@ -1881,13 +1629,13 @@ void LLSpatialPartition::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL
 	put(drawablep, was_visible);
 }
 
-class LLSpatialShift : public LLSpatialGroup::OctreeTraveler
+class LLSpatialShift : public OctreeTraveler
 {
 public:
 	const LLVector4a& mOffset;
 
 	LLSpatialShift(const LLVector4a& offset) : mOffset(offset) { }
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch) 
+	virtual void visit(const OctreeNode* branch) 
 	{ 
 		((LLSpatialGroup*) branch->getListener(0))->shift(mOffset); 
 	}
@@ -1899,17 +1647,17 @@ void LLSpatialPartition::shift(const LLVector4a &offset)
 	shifter.traverse(mOctree);
 }
 
-class LLOctreeCull : public LLSpatialGroup::OctreeTraveler
+class LLOctreeCull : public LLViewerOctreeCull
 {
 public:
-	LLOctreeCull(LLCamera* camera)
-		: mCamera(camera), mRes(0) { }
+	LLOctreeCull(LLCamera* camera) : LLViewerOctreeCull(camera) {}
 
-	virtual bool earlyFail(LLSpatialGroup* group)
+	virtual bool earlyFail(LLviewerOctreeGroup* base_group)
 	{
+		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
 		group->checkOcclusion();
 
-		if (group->mOctreeNode->getParent() &&	//never occlusion cull the root node
+		if (group->getOctreeNode()->getParent() &&	//never occlusion cull the root node
 		  	LLPipeline::sUseOcclusion &&			//ignore occlusion if disabled
 			group->isOcclusionState(LLSpatialGroup::OCCLUDED))
 		{
@@ -1919,79 +1667,30 @@ public:
 		
 		return false;
 	}
-	
-	virtual void traverse(const LLSpatialGroup::OctreeNode* n)
-	{
-		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
-
-		if (earlyFail(group))
-		{
-			return;
-		}
 		
-		if (mRes == 2 || 
-			(mRes && group->isState(LLSpatialGroup::SKIP_FRUSTUM_CHECK)))
-		{	//fully in, just add everything
-			LLSpatialGroup::OctreeTraveler::traverse(n);
-		}
-		else
-		{
-			mRes = frustumCheck(group);
-				
-			if (mRes)
-			{ //at least partially in, run on down
-				LLSpatialGroup::OctreeTraveler::traverse(n);
-			}
-
-			mRes = 0;
-		}
-	}
-	
-	virtual S32 frustumCheck(const LLSpatialGroup* group)
+	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
-		S32 res = mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]);
+		S32 res = AABBInFrustumNoFarClipGroupBounds(group);
 		if (res != 0)
 		{
-			res = llmin(res, AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist));
+			res = llmin(res, AABBSphereIntersectGroupExtents(group));
 		}
 		return res;
 	}
 
-	virtual S32 frustumCheckObjects(const LLSpatialGroup* group)
+	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
-		S32 res = mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]);
+		S32 res = AABBInFrustumNoFarClipObjectBounds(group);
 		if (res != 0)
 		{
-			res = llmin(res, AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist));
+			res = llmin(res, AABBSphereIntersectObjectExtents(group));
 		}
 		return res;
 	}
 
-	virtual bool checkObjects(const LLSpatialGroup::OctreeNode* branch, const LLSpatialGroup* group)
-	{
-		if (branch->getElementCount() == 0) //no elements
-		{
-			return false;
-		}
-		else if (branch->getChildCount() == 0) //leaf state, already checked tightest bounding box
-		{
-			return true;
-		}
-		else if (mRes == 1 && !frustumCheckObjects(group)) //no objects in frustum
-		{
-			return false;
-		}
-		
-		return true;
-	}
-
-	virtual void preprocess(LLSpatialGroup* group)
-	{
-		
-	}
-	
-	virtual void processGroup(LLSpatialGroup* group)
+	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
+		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
 		if (group->needsUpdate() ||
 			group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1)
 		{
@@ -1999,21 +1698,6 @@ public:
 		}
 		gPipeline.markNotCulled(group, *mCamera);
 	}
-	
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch) 
-	{	
-		LLSpatialGroup* group = (LLSpatialGroup*) branch->getListener(0);
-
-		preprocess(group);
-		
-		if (checkObjects(branch, group))
-		{
-			processGroup(group);
-		}
-	}
-
-	LLCamera *mCamera;
-	S32 mRes;
 };
 
 class LLOctreeCullNoFarClip : public LLOctreeCull
@@ -2022,14 +1706,14 @@ public:
 	LLOctreeCullNoFarClip(LLCamera* camera) 
 		: LLOctreeCull(camera) { }
 
-	virtual S32 frustumCheck(const LLSpatialGroup* group)
+	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
-		return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]);
+		return AABBInFrustumNoFarClipGroupBounds(group);
 	}
 
-	virtual S32 frustumCheckObjects(const LLSpatialGroup* group)
+	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
-		S32 res = mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]);
+		S32 res = AABBInFrustumNoFarClipObjectBounds(group);
 		return res;
 	}
 };
@@ -2040,14 +1724,14 @@ public:
 	LLOctreeCullShadow(LLCamera* camera)
 		: LLOctreeCull(camera) { }
 
-	virtual S32 frustumCheck(const LLSpatialGroup* group)
+	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
-		return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]);
+		return AABBInFrustumGroupBounds(group);
 	}
 
-	virtual S32 frustumCheckObjects(const LLSpatialGroup* group)
+	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
-		return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
+		return AABBInFrustumObjectBounds(group);
 	}
 };
 
@@ -2057,9 +1741,11 @@ public:
 	LLOctreeCullVisExtents(LLCamera* camera, LLVector4a& min, LLVector4a& max)
 		: LLOctreeCullShadow(camera), mMin(min), mMax(max), mEmpty(TRUE) { }
 
-	virtual bool earlyFail(LLSpatialGroup* group)
+	virtual bool earlyFail(LLviewerOctreeGroup* base_group)
 	{
-		if (group->mOctreeNode->getParent() &&	//never occlusion cull the root node
+		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
+
+		if (group->getOctreeNode()->getParent() &&	//never occlusion cull the root node
 			LLPipeline::sUseOcclusion &&			//ignore occlusion if disabled
 			group->isOcclusionState(LLSpatialGroup::OCCLUDED))
 		{
@@ -2069,7 +1755,7 @@ public:
 		return false;
 	}
 
-	virtual void traverse(const LLSpatialGroup::OctreeNode* n)
+	virtual void traverse(const OctreeNode* n)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
 
@@ -2078,10 +1764,10 @@ public:
 			return;
 		}
 		
-		if ((mRes && group->isState(LLSpatialGroup::SKIP_FRUSTUM_CHECK)) ||
+		if ((mRes && group->hasState(LLSpatialGroup::SKIP_FRUSTUM_CHECK)) ||
 			mRes == 2)
 		{	//don't need to do frustum check
-			LLSpatialGroup::OctreeTraveler::traverse(n);
+			OctreeTraveler::traverse(n);
 		}
 		else
 		{  
@@ -2089,31 +1775,35 @@ public:
 				
 			if (mRes)
 			{ //at least partially in, run on down
-				LLSpatialGroup::OctreeTraveler::traverse(n);
+				OctreeTraveler::traverse(n);
 			}
 
 			mRes = 0;
 		}
 	}
 
-	virtual void processGroup(LLSpatialGroup* group)
+	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
-		llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->isEmpty())
+		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
+		
+		llassert(!group->hasState(LLSpatialGroup::DIRTY) && !group->isEmpty())
 		
 		if (mRes < 2)
 		{
-			if (mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]) > 0)
+			if (AABBInFrustumObjectBounds(group) > 0)
 			{
 				mEmpty = FALSE;
-				update_min_max(mMin, mMax, group->mObjectExtents[0]);
-				update_min_max(mMin, mMax, group->mObjectExtents[1]);
+				const LLVector4a* exts = group->getObjectExtents();
+				update_min_max(mMin, mMax, exts[0]);
+				update_min_max(mMin, mMax, exts[1]);
 			}
 		}
 		else
 		{
 			mEmpty = FALSE;
-			update_min_max(mMin, mMax, group->mExtents[0]);
-			update_min_max(mMin, mMax, group->mExtents[1]);
+			const LLVector4a* exts = group->getExtents();
+			update_min_max(mMin, mMax, exts[0]);
+			update_min_max(mMin, mMax, exts[1]);
 		}
 	}
 
@@ -2128,10 +1818,12 @@ public:
 	LLOctreeCullDetectVisible(LLCamera* camera)
 		: LLOctreeCullShadow(camera), mResult(FALSE) { }
 
-	virtual bool earlyFail(LLSpatialGroup* group)
+	virtual bool earlyFail(LLviewerOctreeGroup* base_group)
 	{
+		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
+
 		if (mResult || //already found a node, don't check any more
-			(group->mOctreeNode->getParent() &&	//never occlusion cull the root node
+			(group->getOctreeNode()->getParent() &&	//never occlusion cull the root node
 			 LLPipeline::sUseOcclusion &&			//ignore occlusion if disabled
 			 group->isOcclusionState(LLSpatialGroup::OCCLUDED)))
 		{
@@ -2141,9 +1833,9 @@ public:
 		return false;
 	}
 
-	virtual void processGroup(LLSpatialGroup* group)
+	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
-		if (group->isVisible())
+		if (base_group->isVisible())
 		{
 			mResult = TRUE;
 		}
@@ -2158,17 +1850,21 @@ public:
 	LLOctreeSelect(LLCamera* camera, std::vector<LLDrawable*>* results)
 		: LLOctreeCull(camera), mResults(results) { }
 
-	virtual bool earlyFail(LLSpatialGroup* group) { return false; }
-	virtual void preprocess(LLSpatialGroup* group) { }
+	virtual bool earlyFail(LLviewerOctreeGroup* group) { return false; }
+	virtual void preprocess(LLviewerOctreeGroup* group) { }
 
-	virtual void processGroup(LLSpatialGroup* group)
+	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
-		LLSpatialGroup::OctreeNode* branch = group->mOctreeNode;
+		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
+		OctreeNode* branch = group->getOctreeNode();
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
-			LLDrawable* drawable = *i;
-			
+			LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+			if(!drawable)
+			{
+				continue;
+			}
 			if (!drawable->isDead())
 			{
 				if (drawable->isSpatialBridge())
@@ -2281,17 +1977,21 @@ void drawBoxOutline(const LLVector4a& pos, const LLVector4a& size)
 	drawBoxOutline(reinterpret_cast<const LLVector3&>(pos), reinterpret_cast<const LLVector3&>(size));
 }
 
-class LLOctreeDirty : public LLOctreeTraveler<LLDrawable>
+class LLOctreeDirty : public OctreeTraveler
 {
 public:
-	virtual void visit(const LLOctreeNode<LLDrawable>* state)
+	virtual void visit(const OctreeNode* state)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0);
 		group->destroyGL();
 
 		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 		{
-			LLDrawable* drawable = *i;
+			LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+			if(!drawable)
+			{
+				continue;
+			}
 			if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup)
 			{
 				gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE);
@@ -2350,6 +2050,13 @@ BOOL LLSpatialPartition::visibleObjectsInFrustum(LLCamera& camera)
 
 S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* results, BOOL for_select)
 {
+	bool is_vo_cache_part = (mPartitionType == LLViewerRegion::PARTITION_VO_CACHE);
+	
+	if(is_vo_cache_part && mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame())
+	{
+		return 0; //no need to visit more than once per frame
+	}		
+
 #if LL_OCTREE_PARANOIA_CHECK
 	((LLSpatialGroup*)mOctree->getListener(0))->checkStates();
 #endif
@@ -2364,18 +2071,18 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* result
 #endif
 
 	
-	if (for_select)
+	if (for_select && !is_vo_cache_part)
 	{
 		LLOctreeSelect selecter(&camera, results);
 		selecter.traverse(mOctree);
 	}
-	else if (LLPipeline::sShadowRender)
+	else if (LLPipeline::sShadowRender && !is_vo_cache_part)
 	{
 		LLFastTimer ftm(FTM_FRUSTUM_CULL);
 		LLOctreeCullShadow culler(&camera);
 		culler.traverse(mOctree);
 	}
-	else if (mInfiniteFarClip || !LLPipeline::sUseFarClip)
+	else if ((mInfiniteFarClip || !LLPipeline::sUseFarClip) && !is_vo_cache_part)
 	{
 		LLFastTimer ftm(FTM_FRUSTUM_CULL);		
 		LLOctreeCullNoFarClip culler(&camera);
@@ -2383,6 +2090,11 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* result
 	}
 	else
 	{
+		if(is_vo_cache_part)
+		{
+			mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame();
+		}
+
 		LLFastTimer ftm(FTM_FRUSTUM_CULL);		
 		LLOctreeCull culler(&camera);
 		culler.traverse(mOctree);
@@ -2402,9 +2114,10 @@ BOOL earlyFail(LLCamera* camera, LLSpatialGroup* group)
 	LLVector4a fudge;
 	fudge.splat(vel);
 
-	const LLVector4a& c = group->mBounds[0];
+	const LLVector4a* bounds = group->getBounds();
+	const LLVector4a& c = bounds[0];
 	LLVector4a r;
-	r.setAdd(group->mBounds[1], fudge);
+	r.setAdd(bounds[1], fudge);
 
 	/*if (r.magVecSquared() > 1024.0*1024.0)
 	{
@@ -2529,7 +2242,8 @@ void pushBufferVerts(LLSpatialGroup* group, U32 mask)
 	}
 	else
 	{
-		drawBox(group->mBounds[0], group->mBounds[1]);
+		const LLVector4a* bounds = group->getBounds();
+		drawBox(bounds[0], bounds[1]);
 	}
 }
 
@@ -2593,13 +2307,19 @@ void renderOctree(LLSpatialGroup* group)
 			gGL.diffuseColor4f(1,0,0,group->mBuilt);
 			gGL.flush();
 			glLineWidth(5.f);
-			drawBoxOutline(group->mObjectBounds[0], group->mObjectBounds[1]);
+
+			const LLVector4a* bounds = group->getObjectBounds();
+			drawBoxOutline(bounds[0], bounds[1]);
 			gGL.flush();
 			glLineWidth(1.f);
 			gGL.flush();
 			for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 			{
-				LLDrawable* drawable = *i;
+				LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+				if(!drawable)
+				{
+					continue;
+				}
 				if (!group->mSpatialPartition->isBridge())
 				{
 					gGL.pushMatrix();
@@ -2657,9 +2377,10 @@ void renderOctree(LLSpatialGroup* group)
 	gGL.diffuseColor4fv(col.mV);
 	LLVector4a fudge;
 	fudge.splat(0.001f);
-	LLVector4a size = group->mObjectBounds[1];
-	size.mul(1.01f);
-	size.add(fudge);
+
+	//LLVector4a size = group->mObjectBounds[1];
+	//size.mul(1.01f);
+	//size.add(fudge);
 
 	//{
 	//	LLGLDepthTest depth(GL_TRUE, GL_FALSE);
@@ -2675,7 +2396,9 @@ void renderOctree(LLSpatialGroup* group)
 		//drawBoxOutline(group->mObjectBounds[0], group->mObjectBounds[1]);
 
 		gGL.diffuseColor4f(0,1,1,1);
-		drawBoxOutline(group->mBounds[0],group->mBounds[1]);
+
+		const LLVector4a* bounds = group->getBounds();
+		drawBoxOutline(bounds[0], bounds[1]);
 		
 		//draw bounding box for draw info
 		/*if (group->mSpatialPartition->mRenderByGroup)
@@ -3442,9 +3165,13 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
 
 void renderPhysicsShapes(LLSpatialGroup* group)
 {
-	for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+	for (OctreeNode::const_element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
-		LLDrawable* drawable = *i;
+		LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+		if(!drawable)
+		{
+			continue;
+		}
 		LLVOVolume* volume = drawable->getVOVolume();
 		if (volume && !volume->isAttachment() && volume->getPhysicsShapeType() != LLViewerObject::PHYSICS_SHAPE_NONE )
 		{
@@ -4001,17 +3728,18 @@ void renderAgentTarget(LLVOAvatar* avatar)
 	}
 }
 
-class LLOctreeRenderNonOccluded : public LLOctreeTraveler<LLDrawable>
+class LLOctreeRenderNonOccluded : public OctreeTraveler
 {
 public:
 	LLCamera* mCamera;
 	LLOctreeRenderNonOccluded(LLCamera* camera): mCamera(camera) {}
 	
-	virtual void traverse(const LLSpatialGroup::OctreeNode* node)
+	virtual void traverse(const OctreeNode* node)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 		
-		if (!mCamera || mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]))
+		const LLVector4a* bounds = group->getBounds();
+		if (!mCamera || mCamera->AABBInFrustumNoFarClip(bounds[0], bounds[1]))
 		{
 			node->accept(this);
 			stop_glerror();
@@ -4051,17 +3779,17 @@ public:
 		}
 	}
 
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch)
+	virtual void visit(const OctreeNode* branch)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) branch->getListener(0);
-
-		if (group->isState(LLSpatialGroup::GEOM_DIRTY) || (mCamera && !mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1])))
+		const LLVector4a* bounds = group->getBounds();
+		if (group->hasState(LLSpatialGroup::GEOM_DIRTY) || (mCamera && !mCamera->AABBInFrustumNoFarClip(bounds[0], bounds[1])))
 		{
 			return;
 		}
 
-		LLVector4a nodeCenter = group->mBounds[0];
-		LLVector4a octCenter = group->mOctreeNode->getCenter();
+		LLVector4a nodeCenter = bounds[0];
+		LLVector4a octCenter = group->getOctreeNode()->getCenter();
 
 		group->rebuildGeom();
 		group->rebuildMesh();
@@ -4071,15 +3799,20 @@ public:
 			if (!group->isEmpty())
 			{
 				gGL.diffuseColor3f(0,0,1);
-				drawBoxOutline(group->mObjectBounds[0],
-								group->mObjectBounds[1]);
+
+				const LLVector4a* obj_bounds = group->getObjectBounds();
+				drawBoxOutline(obj_bounds[0], obj_bounds[1]);
 			}
 		}
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
-			LLDrawable* drawable = *i;
-					
+			LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+			if(!drawable)
+			{
+				continue;
+			}
+
 			if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BBOXES))
 			{
 				renderBoundingBox(drawable);			
@@ -4201,17 +3934,18 @@ public:
 };
 
 
-class LLOctreeRenderPhysicsShapes : public LLOctreeTraveler<LLDrawable>
+class LLOctreeRenderPhysicsShapes : public OctreeTraveler
 {
 public:
 	LLCamera* mCamera;
 	LLOctreeRenderPhysicsShapes(LLCamera* camera): mCamera(camera) {}
 	
-	virtual void traverse(const LLSpatialGroup::OctreeNode* node)
+	virtual void traverse(const OctreeNode* node)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 		
-		if (!mCamera || mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]))
+		const LLVector4a* bounds = group->getBounds();
+		if (!mCamera || mCamera->AABBInFrustumNoFarClip(bounds[0], bounds[1]))
 		{
 			node->accept(this);
 			stop_glerror();
@@ -4229,23 +3963,24 @@ public:
 		}
 	}
 
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch)
+	virtual void visit(const OctreeNode* branch)
 	{
 		
 	}
 };
 
-class LLOctreePushBBoxVerts : public LLOctreeTraveler<LLDrawable>
+class LLOctreePushBBoxVerts : public OctreeTraveler
 {
 public:
 	LLCamera* mCamera;
 	LLOctreePushBBoxVerts(LLCamera* camera): mCamera(camera) {}
 	
-	virtual void traverse(const LLSpatialGroup::OctreeNode* node)
+	virtual void traverse(const OctreeNode* node)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 		
-		if (!mCamera || mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]))
+		const LLVector4a* bounds = group->getBounds();
+		if (!mCamera || mCamera->AABBInFrustum(bounds[0], bounds[1]))
 		{
 			node->accept(this);
 
@@ -4256,19 +3991,23 @@ public:
 		}
 	}
 
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch)
+	virtual void visit(const OctreeNode* branch)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) branch->getListener(0);
 
-		if (group->isState(LLSpatialGroup::GEOM_DIRTY) || (mCamera && !mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1])))
+		const LLVector4a* bounds = group->getBounds();
+		if (group->hasState(LLSpatialGroup::GEOM_DIRTY) || (mCamera && !mCamera->AABBInFrustumNoFarClip(bounds[0], bounds[1])))
 		{
 			return;
 		}
 
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
-			LLDrawable* drawable = *i;
-						
+			LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+			if(!drawable)
+			{
+				continue;
+			}
 			renderBoundingBox(drawable, FALSE);			
 		}
 	}
@@ -4280,7 +4019,7 @@ void LLSpatialPartition::renderIntersectingBBoxes(LLCamera* camera)
 	pusher.traverse(mOctree);
 }
 
-class LLOctreeStateCheck : public LLOctreeTraveler<LLDrawable>
+class LLOctreeStateCheck : public OctreeTraveler
 {
 public:
 	U32 mInheritedMask[LLViewerCamera::NUM_CAMERAS];
@@ -4293,7 +4032,7 @@ public:
 		}
 	}
 
-	virtual void traverse(const LLSpatialGroup::OctreeNode* node)
+	virtual void traverse(const OctreeNode* node)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 		
@@ -4320,7 +4059,7 @@ public:
 	}
 	
 
-	virtual void visit(const LLOctreeNode<LLDrawable>* state)
+	virtual void visit(const OctreeNode* state)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0);
 
@@ -4332,7 +4071,7 @@ public:
 			}
 		}
 
-		if (group->isState(LLSpatialGroup::DIRTY))
+		if (group->hasState(LLSpatialGroup::DIRTY))
 		{
 			assert_parent_state(group, LLSpatialGroup::DIRTY);
 		}
@@ -4343,7 +4082,7 @@ public:
 		LLSpatialGroup* parent = group->getParent();
 		while (parent)
 		{
-			if (!parent->isState(state))
+			if (!parent->hasState(state))
 			{
 				llerrs << "Spatial group failed parent state check." << llendl;
 			}
@@ -4458,7 +4197,7 @@ BOOL LLSpatialPartition::isVisible(const LLVector3& v)
 	return TRUE;
 }
 
-class LLOctreeIntersect : public LLSpatialGroup::OctreeTraveler
+class LLOctreeIntersect : public OctreeTraveler
 {
 public:
 	LLVector3 mStart;
@@ -4485,21 +4224,21 @@ public:
 	{
 	}
 	
-	virtual void visit(const LLSpatialGroup::OctreeNode* branch) 
+	virtual void visit(const OctreeNode* branch) 
 	{	
-		for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+		for (OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
 		{
 			check(*i);
 		}
 	}
 
-	virtual LLDrawable* check(const LLSpatialGroup::OctreeNode* node)
+	virtual LLDrawable* check(const OctreeNode* node)
 	{
 		node->accept(this);
 	
 		for (U32 i = 0; i < node->getChildCount(); i++)
 		{
-			const LLSpatialGroup::OctreeNode* child = node->getChild(i);
+			const OctreeNode* child = node->getChild(i);
 			LLVector3 res;
 
 			LLSpatialGroup* group = (LLSpatialGroup*) child->getListener(0);
@@ -4507,8 +4246,9 @@ public:
 			LLVector4a size;
 			LLVector4a center;
 			
-			size = group->mBounds[1];
-			center = group->mBounds[0];
+			const LLVector4a* bounds = group->getBounds();
+			size = bounds[1];
+			center = bounds[0];
 			
 			LLVector3 local_start = mStart;
 			LLVector3 local_end   = mEnd;
@@ -4535,8 +4275,9 @@ public:
 		return mHit;
 	}
 
-	virtual bool check(LLDrawable* drawable)
+	virtual bool check(LLViewerOctreeEntry* entry)
 	{	
+		LLDrawable* drawable = (LLDrawable*)entry->getDrawable();
 		LLVector3 local_start = mStart;
 		LLVector3 local_end = mEnd;
 
@@ -4922,5 +4663,21 @@ void LLCullResult::assertDrawMapsEmpty()
 	}
 }
 
+LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) : LLSpatialPartition(0, FALSE, 0, regionp)
+{
+	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
+}
+
+void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
+{
+	llassert(entry->hasVOCacheEntry());
 
+	mOctree->insert(entry);
+}
+	
+void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
+{
+	entry->getVOCacheEntry()->setGroup(NULL);
 
+	llassert(!entry->getGroup());
+}
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index f050df2b39..dd189d751d 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -50,12 +50,8 @@ class LLSpatialBridge;
 class LLSpatialGroup;
 class LLTextureAtlas;
 class LLTextureAtlasSlot;
+class LLViewerRegion;
 
-S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad);
-S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &radius_squared);
-
-S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad);
-S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared);
 void pushVerts(LLFace* face, U32 mask);
 
 // get index buffer for binary encoded axis vertex buffer given a box at center being viewed by given camera
@@ -192,13 +188,13 @@ public:
 };
 
 LL_ALIGN_PREFIX(16)
-class LLSpatialGroup : public LLOctreeListener<LLDrawable>
+class LLSpatialGroup : public LLviewerOctreeGroup
 {
 	friend class LLSpatialPartition;
 	friend class LLOctreeStateCheck;
 public:
 
-	LLSpatialGroup(const LLSpatialGroup& rhs)
+	LLSpatialGroup(const LLSpatialGroup& rhs) : LLviewerOctreeGroup(rhs)
 	{
 		*this = rhs;
 	}
@@ -231,14 +227,8 @@ public:
 	typedef std::map<LLFace*, buffer_list_t> buffer_texture_map_t;
 	typedef std::map<U32, buffer_texture_map_t> buffer_map_t;
 
-	typedef LLOctreeListener<LLDrawable>	BaseType;
-	typedef LLOctreeListener<LLDrawable>	OctreeListener;
-	typedef LLTreeNode<LLDrawable>			TreeNode;
-	typedef LLOctreeNode<LLDrawable>		OctreeNode;
-	typedef LLOctreeRoot<LLDrawable>		OctreeRoot;
-	typedef LLOctreeTraveler<LLDrawable>	OctreeTraveler;
-	typedef LLOctreeNode<LLDrawable>::element_iter element_iter;
-	typedef LLOctreeNode<LLDrawable>::element_list element_list;
+	typedef LLOctreeNode<LLViewerOctreeEntry>::element_iter element_iter;
+	typedef LLOctreeNode<LLViewerOctreeEntry>::element_list element_list;
 
 	struct CompareDistanceGreater
 	{
@@ -275,18 +265,15 @@ public:
 
 	typedef enum
 	{
-		DEAD					= 0x00000001,
-		DIRTY					= 0x00000002,
-		OBJECT_DIRTY			= 0x00000004,
-		GEOM_DIRTY				= 0x00000008,
-		ALPHA_DIRTY				= 0x00000010,
-		SKIP_FRUSTUM_CHECK		= 0x00000020,
-		IN_IMAGE_QUEUE			= 0x00000040,
-		IMAGE_DIRTY				= 0x00000080,
-		MESH_DIRTY				= 0x00000100,
-		NEW_DRAWINFO			= 0x00000200,
-		IN_BUILD_Q1				= 0x00000400,
-		IN_BUILD_Q2				= 0x00000800,
+		DEAD					= LLviewerOctreeGroup::INVALID_STATE,
+		GEOM_DIRTY				= (DEAD << 1),
+		ALPHA_DIRTY				= (GEOM_DIRTY << 1),
+		IN_IMAGE_QUEUE			= (ALPHA_DIRTY << 1),
+		IMAGE_DIRTY				= (IN_IMAGE_QUEUE << 1),
+		MESH_DIRTY				= (IMAGE_DIRTY << 1),
+		NEW_DRAWINFO			= (MESH_DIRTY << 1),
+		IN_BUILD_Q1				= (NEW_DRAWINFO << 1),
+		IN_BUILD_Q2				= (IN_BUILD_Q1 << 1),
 		STATE_MASK				= 0x0000FFFF,
 	} eSpatialState;
 
@@ -301,12 +288,8 @@ public:
 	LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part);
 
 	BOOL isHUDGroup() ;
-	BOOL isDead()							{ return isState(DEAD); }
-	BOOL isState(U32 state) const;	
+	BOOL isDead()							{ return hasState(DEAD); }
 	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }
-	U32 getState()							{ return mState; }
-	void setState(U32 state);	
-	void clearState(U32 state);	
 	
 	void clearDrawMap();
 	void validate();
@@ -315,23 +298,20 @@ public:
 	
 	void setState(U32 state, S32 mode);
 	void clearState(U32 state, S32 mode);
+	void clearState(U32 state)     {mState &= ~state;}	
 
 	void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 	void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 
 	LLSpatialGroup* getParent();
-
 	
-	BOOL addObject(LLDrawable *drawablep, BOOL add_all = FALSE, BOOL from_octree = FALSE);
+	BOOL addObject(LLDrawable *drawablep);
 	BOOL removeObject(LLDrawable *drawablep, BOOL from_octree = FALSE);
 	BOOL updateInGroup(LLDrawable *drawablep, BOOL immediate = FALSE); // Update position if it's in the group
 	BOOL isVisible() const;
 	BOOL isRecentlyVisible() const;
 	void setVisible();
 	void shift(const LLVector4a &offset);
-	BOOL boundObjects(BOOL empty, LLVector4a& newMin, LLVector4a& newMax);
-	void unbound();
-	BOOL rebound();
 	void checkOcclusion(); //read back last occlusion query (if any)
 	void doOcclusion(LLCamera* camera); //issue occlusion query
 	void destroyGL(bool keep_occlusion = false);
@@ -343,6 +323,7 @@ public:
 	void rebuildGeom();
 	void rebuildMesh();
 
+	void setState(U32 state)       {mState |= state;}
 	void dirtyGeom() { setState(GEOM_DIRTY); }
 	void dirtyMesh() { setState(MESH_DIRTY); }
 
@@ -356,13 +337,11 @@ public:
 	void drawObjectBox(LLColor4 col);
 
 	 //LISTENER FUNCTIONS
-	virtual void handleInsertion(const TreeNode* node, LLDrawable* face);
-	virtual void handleRemoval(const TreeNode* node, LLDrawable* face);
+	virtual void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* face);
+	virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face);
 	virtual void handleDestruction(const TreeNode* node);
-	virtual void handleStateChange(const TreeNode* node);
 	virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
-	virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child);
-
+	
 //-------------------
 //for atlas use
 //-------------------
@@ -384,21 +363,6 @@ public:
 
 public:
 
-	typedef enum
-	{
-		BOUNDS = 0,
-		EXTENTS = 2,
-		OBJECT_BOUNDS = 4,
-		OBJECT_EXTENTS = 6,
-		VIEW_ANGLE = 8,
-		LAST_VIEW_ANGLE = 9,
-		V4_COUNT = 10
-	} eV4Index;
-
-	LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
-	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
-	LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
 	LL_ALIGN_16(LLVector4a mViewAngle);
 	LL_ALIGN_16(LLVector4a mLastUpdateViewAngle);
 
@@ -419,7 +383,6 @@ private:
 protected:
 	virtual ~LLSpatialGroup();
 
-	U32 mState;
 	U32 mOcclusionState[LLViewerCamera::NUM_CAMERAS];
 	U32 mOcclusionIssued[LLViewerCamera::NUM_CAMERAS];
 
@@ -434,7 +397,6 @@ public:
 	F32 mSurfaceArea; //used by volumes to track estimated surface area of geometry in this node
 
 	F32 mBuilt;
-	OctreeNode* mOctreeNode;
 	LLSpatialPartition* mSpatialPartition;
 	
 	LLPointer<LLVertexBuffer> mVertexBuffer;
@@ -469,7 +431,7 @@ public:
 class LLSpatialPartition: public LLGeometryManager
 {
 public:
-	LLSpatialPartition(U32 data_mask,  BOOL render_by_group, U32 mBufferUsage);
+	LLSpatialPartition(U32 data_mask,  BOOL render_by_group, U32 mBufferUsage, LLViewerRegion* regionp);
 	virtual ~LLSpatialPartition();
 
 	LLSpatialGroup *put(LLDrawable *drawablep, BOOL was_visible = FALSE);
@@ -511,9 +473,10 @@ public:
 	void resetVertexBuffers();
 	BOOL isOcclusionEnabled();
 	BOOL getVisibleExtents(LLCamera& camera, LLVector3& visMin, LLVector3& visMax);
+	BOOL isVOCachePartition() const;
 
 public:
-	LLSpatialGroup::OctreeNode* mOctree;
+	OctreeNode*      mOctree;
 	LLSpatialBridge* mBridge; // NULL for non-LLSpatialBridge instances, otherwise, mBridge == this
 							// use a pointer instead of making "isBridge" and "asBridge" virtual so it's safe
 							// to call asBridge() from the destructor
@@ -528,6 +491,8 @@ public:
 	BOOL mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering
 	U32 mDrawableType;
 	U32 mPartitionType;
+	U32 mVisitedTime;
+	LLViewerRegion* mRegionp; // the region this partition belongs to.
 };
 
 // class for creating bridges between spatial partitions
@@ -539,7 +504,7 @@ protected:
 public:
 	typedef std::vector<LLPointer<LLSpatialBridge> > bridge_vector_t;
 	
-	LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask);
+	LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask, LLViewerRegion* regionp);
 	
 	void destroyTree();
 
@@ -562,7 +527,7 @@ public:
 
 };
 
-class LLCullResult 
+class LLCullResult
 {
 public:
 	LLCullResult();
@@ -661,7 +626,7 @@ private:
 class LLWaterPartition : public LLSpatialPartition
 {
 public:
-	LLWaterPartition();
+	LLWaterPartition(LLViewerRegion* regionp);
 	virtual void getGeometry(LLSpatialGroup* group) {  }
 	virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
 };
@@ -670,14 +635,27 @@ public:
 class LLVoidWaterPartition : public LLWaterPartition
 {
 public:
-	LLVoidWaterPartition();
+	LLVoidWaterPartition(LLViewerRegion* regionp);
+};
+
+//spatial partition for hole and edge water (implemented in LLVOWater.cpp)
+class LLVOCachePartition : public LLSpatialPartition
+{
+public:
+	LLVOCachePartition(LLViewerRegion* regionp);
+
+	void addEntry(LLViewerOctreeEntry* entry);
+	void removeEntry(LLViewerOctreeEntry* entry);
+
+	virtual void getGeometry(LLSpatialGroup* group) {  }
+	virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
 };
 
 //spatial partition for terrain (impelmented in LLVOSurfacePatch.cpp)
 class LLTerrainPartition : public LLSpatialPartition
 {
 public:
-	LLTerrainPartition();
+	LLTerrainPartition(LLViewerRegion* regionp);
 	virtual void getGeometry(LLSpatialGroup* group);
 	virtual LLVertexBuffer* createVertexBuffer(U32 type_mask, U32 usage);
 };
@@ -686,7 +664,7 @@ public:
 class LLTreePartition : public LLSpatialPartition
 {
 public:
-	LLTreePartition();
+	LLTreePartition(LLViewerRegion* regionp);
 	virtual void getGeometry(LLSpatialGroup* group) { }
 	virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
 
@@ -696,7 +674,7 @@ public:
 class LLParticlePartition : public LLSpatialPartition
 {
 public:
-	LLParticlePartition();
+	LLParticlePartition(LLViewerRegion* regionp);
 	virtual void rebuildGeom(LLSpatialGroup* group);
 	virtual void getGeometry(LLSpatialGroup* group);
 	virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count);
@@ -708,14 +686,14 @@ protected:
 class LLHUDParticlePartition : public LLParticlePartition
 {
 public:
-	LLHUDParticlePartition();
+	LLHUDParticlePartition(LLViewerRegion* regionp);
 };
 
 //spatial partition for grass (implemented in LLVOGrass.cpp)
 class LLGrassPartition : public LLSpatialPartition
 {
 public:
-	LLGrassPartition();
+	LLGrassPartition(LLViewerRegion* regionp);
 	virtual void getGeometry(LLSpatialGroup* group);
 	virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count);
 protected:
@@ -745,7 +723,7 @@ class LLVolumeGeometryManager: public LLGeometryManager
 class LLVolumePartition : public LLSpatialPartition, public LLVolumeGeometryManager
 {
 public:
-	LLVolumePartition();
+	LLVolumePartition(LLViewerRegion* regionp);
 	virtual void rebuildGeom(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildGeom(group); }
 	virtual void getGeometry(LLSpatialGroup* group) { LLVolumeGeometryManager::getGeometry(group); }
 	virtual void rebuildMesh(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildMesh(group); }
@@ -756,7 +734,7 @@ public:
 class LLVolumeBridge : public LLSpatialBridge, public LLVolumeGeometryManager
 {
 public:
-	LLVolumeBridge(LLDrawable* drawable);
+	LLVolumeBridge(LLDrawable* drawable, LLViewerRegion* regionp);
 	virtual void rebuildGeom(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildGeom(group); }
 	virtual void getGeometry(LLSpatialGroup* group) { LLVolumeGeometryManager::getGeometry(group); }
 	virtual void rebuildMesh(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildMesh(group); }
@@ -766,7 +744,7 @@ public:
 class LLHUDBridge : public LLVolumeBridge
 {
 public:
-	LLHUDBridge(LLDrawable* drawablep);
+	LLHUDBridge(LLDrawable* drawablep, LLViewerRegion* regionp);
 	virtual void shiftPos(const LLVector4a& vec);
 	virtual F32 calcPixelArea(LLSpatialGroup* group, LLCamera& camera);
 };
@@ -775,7 +753,7 @@ public:
 class LLBridgePartition : public LLSpatialPartition
 {
 public:
-	LLBridgePartition();
+	LLBridgePartition(LLViewerRegion* regionp);
 	virtual void getGeometry(LLSpatialGroup* group) { }
 	virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) {  }
 };
@@ -783,7 +761,7 @@ public:
 class LLHUDPartition : public LLBridgePartition
 {
 public:
-	LLHUDPartition();
+	LLHUDPartition(LLViewerRegion* regionp);
 	virtual void shift(const LLVector4a &offset);
 };
 
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index c60b4155a0..a5ccf97d1e 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -49,6 +49,8 @@
 #include "llviewertexturelist.h"
 #include "llvovolume.h"
 #include "llviewerstats.h"
+#include "llworld.h"
+#include "llviewerobjectlist.h"
 
 // For avatar texture view
 #include "llvoavatarself.h"
@@ -515,6 +517,9 @@ void LLGLTexMemBar::draw()
 	F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024);
 	F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024);
 	U32 total_http_requests = LLAppViewer::getTextureFetch()->getCurlRequest().getTotalIssuedRequests() ;
+	U32 total_active_cached_objects = LLWorld::getInstance()->getNumOfActiveCachedObjects();
+	U32 total_objects = gObjectList.getNumObjects();
+
 	//----------------------------------------------------------------------------
 	LLGLSUIDefault gls_ui;
 	LLColor4 text_color(1.f, 1.f, 1.f, 0.75f);
@@ -536,8 +541,8 @@ void LLGLTexMemBar::draw()
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*4,
 											 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 
-	text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d",
-					total_texture_downloaded, total_object_downloaded, total_http_requests);
+	text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB #Objs/#cached: %d/%d Tot Htp: %d",
+					total_texture_downloaded, total_object_downloaded, total_objects, total_active_cached_objects, total_http_requests);
 	//, cache_entries, cache_max_entries
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3,
 											 text_color, LLFontGL::LEFT, LLFontGL::TOP);
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index ec7d91ec4f..67d400af2d 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4490,12 +4490,22 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 
 	LLUUID		id;
 	U32			local_id;
-	S32			i;
+	S32			i = 0;
 	S32			num_objects;
 
 	num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
 
-	for (i = 0; i < num_objects; i++)
+	mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
+	LLViewerRegion* regionp = NULL;
+	bool remove_from_cache = !local_id; //if the first local id is 0, physically remove all objects from VO cache.
+	if(remove_from_cache)
+	{
+		i++;
+
+		LLHost host(gMessageSystem->getSenderIP(), gMessageSystem->getSenderPort());
+		regionp = LLWorld::getInstance()->getRegion(host);
+	}
+	for (; i < num_objects; i++)
 	{
 		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
 
@@ -4530,10 +4540,15 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 				// Do the kill
 				gObjectList.killObject(objectp);
 			}
-			else
+			//else
+			//{
+			//	LL_WARNS("Messaging") << "Object in UUID lookup, but not on object list in kill!" << LL_ENDL;
+			//	gObjectList.mNumUnknownKills++;
+			//}
+
+			if(remove_from_cache)
 			{
-				LL_WARNS("Messaging") << "Object in UUID lookup, but not on object list in kill!" << LL_ENDL;
-				gObjectList.mNumUnknownKills++;
+				regionp->killCacheEntry(local_id);
 			}
 		}
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index aba1d131e1..dbccb2a4d9 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -100,6 +100,7 @@
 #include "lltrans.h"
 #include "llsdutil.h"
 #include "llmediaentry.h"
+#include "llvocache.h"
 
 //#define DEBUG_UPDATE_TYPE
 
@@ -344,7 +345,7 @@ void LLViewerObject::markDead()
 			childp = mChildList.back();
 			if (childp->getPCode() != LL_PCODE_LEGACY_AVATAR)
 			{
-				//llinfos << "Marking child " << childp->getLocalID() << " as dead." << llendl;
+				//llinfos << "Marking child " << childp->getLocalID() << " as dead." << llendl;				
 				childp->setParent(NULL); // LLViewerObject::markDead 1
 				childp->markDead();
 			}
@@ -885,10 +886,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 	}
 
 	// Coordinates of objects on simulators are region-local.
-	U64 region_handle;
-	mesgsys->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle);
+	U64 region_handle = 0;	
 	
+	if(mesgsys != NULL)
 	{
+		mesgsys->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle);
 		LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromHandle(region_handle);
 		if(regionp != mRegionp && regionp && mRegionp)//region cross
 		{
@@ -914,11 +916,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		return retval;
 	}
 
-	U16 time_dilation16;
-	mesgsys->getU16Fast(_PREHASH_RegionData, _PREHASH_TimeDilation, time_dilation16);
-	F32 time_dilation = ((F32) time_dilation16) / 65535.f;
-	mTimeDilation = time_dilation;
-	mRegionp->setTimeDilation(time_dilation);
+	if(mesgsys != NULL)
+	{
+		U16 time_dilation16;
+		mesgsys->getU16Fast(_PREHASH_RegionData, _PREHASH_TimeDilation, time_dilation16);
+		F32 time_dilation = ((F32) time_dilation16) / 65535.f;
+		mTimeDilation = time_dilation;
+		mRegionp->setTimeDilation(time_dilation);
+	}
 
 	// this will be used to determine if we've really changed position
 	// Use getPosition, not getPositionRegion, since this is what we're comparing directly against.
@@ -1692,13 +1697,16 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 				// Preload these five flags for every object.
 				// Finer shades require the object to be selected, and the selection manager
 				// stores the extended permission info.
-				U32 flags;
-				mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, block_num);
-				// keep local flags and overwrite remote-controlled flags
-				mFlags = (mFlags & FLAGS_LOCAL) | flags;
+				if(mesgsys != NULL)
+				{
+					U32 flags;
+					mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, block_num);
+					// keep local flags and overwrite remote-controlled flags
+					mFlags = (mFlags & FLAGS_LOCAL) | flags;
 
 					// ...new objects that should come in selected need to be added to the selected list
-				mCreateSelected = ((flags & FLAGS_CREATE_SELECTED) != 0);
+					mCreateSelected = ((flags & FLAGS_CREATE_SELECTED) != 0);
+				}
 			}
 			break;
 
@@ -1726,10 +1734,21 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 			{
 				// No parent now, new parent in message -> attach to that parent if possible
 				LLUUID parent_uuid;
-				LLViewerObjectList::getUUIDFromLocal(parent_uuid,
+
+				if(mesgsys != NULL)
+				{
+					LLViewerObjectList::getUUIDFromLocal(parent_uuid,
 														parent_id,
 														mesgsys->getSenderIP(),
 														mesgsys->getSenderPort());
+				}
+				else
+				{
+					LLViewerObjectList::getUUIDFromLocal(parent_uuid,
+														parent_id,
+														mRegionp->getHost().getAddress(),
+														mRegionp->getHost().getPort());
+				}
 
 				LLViewerObject *sent_parentp = gObjectList.findObject(parent_uuid);
 
@@ -1805,9 +1824,18 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 					//
 					
 					//parent_id
-					U32 ip = mesgsys->getSenderIP();
-					U32 port = mesgsys->getSenderPort();
+					U32 ip, port; 
 					
+					if(mesgsys != NULL)
+					{
+						ip = mesgsys->getSenderIP();
+						port = mesgsys->getSenderPort();
+					}
+					else
+					{
+						ip = mRegionp->getHost().getAddress();
+						port = mRegionp->getHost().getPort();
+					}
 					gObjectList.orphanize(this, parent_id, ip, port);
 
 					// Hide particles, icon and HUD
@@ -1845,10 +1873,21 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 				else
 				{
 					LLUUID parent_uuid;
-					LLViewerObjectList::getUUIDFromLocal(parent_uuid,
+
+					if(mesgsys != NULL)
+					{
+						LLViewerObjectList::getUUIDFromLocal(parent_uuid,
 														parent_id,
 														gMessageSystem->getSenderIP(),
 														gMessageSystem->getSenderPort());
+					}
+					else
+					{
+						LLViewerObjectList::getUUIDFromLocal(parent_uuid,
+														parent_id,
+														mRegionp->getHost().getAddress(),
+														mRegionp->getHost().getPort());
+					}
 					sent_parentp = gObjectList.findObject(parent_uuid);
 					
 					if (isAvatar())
@@ -1869,8 +1908,18 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 						//
 						// Switching parents, but we don't know the new parent.
 						//
-						U32 ip = mesgsys->getSenderIP();
-						U32 port = mesgsys->getSenderPort();
+						U32 ip, port; 
+					
+						if(mesgsys != NULL)
+						{
+							ip = mesgsys->getSenderIP();
+							port = mesgsys->getSenderPort();
+						}
+						else
+						{
+							ip = mRegionp->getHost().getAddress();
+							port = mRegionp->getHost().getPort();
+						}
 
 						// We're an orphan, flag things appropriately.
 						gObjectList.orphanize(this, parent_id, ip, port);
@@ -1954,7 +2003,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 
 	new_rot.normQuat();
 
-	if (sPingInterpolate)
+	if (sPingInterpolate && mesgsys != NULL)
 	{ 
 		LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(mesgsys->getSender());
 		if (cdp)
@@ -1977,16 +2026,18 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 
 	// If we're going to skip this message, why are we 
 	// doing all the parenting, etc above?
-	U32 packet_id = mesgsys->getCurrentRecvPacketID(); 
-	if (packet_id < mLatestRecvPacketID && 
-		mLatestRecvPacketID - packet_id < 65536)
+	if(mesgsys != NULL)
 	{
-		//skip application of this message, it's old
-		return retval;
+		U32 packet_id = mesgsys->getCurrentRecvPacketID(); 
+		if (packet_id < mLatestRecvPacketID && 
+			mLatestRecvPacketID - packet_id < 65536)
+		{
+			//skip application of this message, it's old
+			return retval;
+		}
+		mLatestRecvPacketID = packet_id;
 	}
 
-	mLatestRecvPacketID = packet_id;
-
 	// Set the change flags for scale
 	if (new_scale != getScale())
 	{
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 88bb087742..a1db1f7237 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -76,6 +76,7 @@
 #include "object_flags.h"
 
 #include "llappviewer.h"
+#include "llvocache.h"
 
 extern F32 gMinObjectDistance;
 extern BOOL gAnimateTextures;
@@ -228,9 +229,15 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp,
 										   U32 i, 
 										   const EObjectUpdateType update_type, 
 										   LLDataPacker* dpp, 
-										   BOOL just_created)
+										   bool just_created,
+										   bool from_cache)
 {
-	LLMessageSystem* msg = gMessageSystem;
+	LLMessageSystem* msg = NULL;
+	
+	if(!from_cache)
+	{
+		msg = gMessageSystem;
+	}
 
 	// ignore returned flags
 	objectp->processUpdateMessage(msg, user_data, i, update_type, dpp);
@@ -254,7 +261,18 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp,
 	// RN: this must be called after we have a drawable 
 	// (from gPipeline.addObject)
 	// so that the drawable parent is set properly
-	findOrphans(objectp, msg->getSenderIP(), msg->getSenderPort());
+	if(msg != NULL)
+	{
+		findOrphans(objectp, msg->getSenderIP(), msg->getSenderPort());
+	}
+	else
+	{
+		LLViewerRegion* regionp = objectp->getRegion();
+		if(regionp != NULL)
+		{
+			findOrphans(objectp, regionp->getHost().getAddress(), regionp->getHost().getPort());
+		}
+	}
 	
 	// If we're just wandering around, don't create new objects selected.
 	if (just_created 
@@ -277,6 +295,82 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp,
 
 static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Objects");
 
+LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry* entry, LLViewerRegion* regionp)
+{
+	LLDataPacker *cached_dpp = entry->getDP();
+
+	if (!cached_dpp)
+	{
+		return NULL; //nothing cached.
+	}
+	
+	LLViewerObject *objectp;
+	U32			    local_id;
+	LLPCode		    pcode = 0;
+	LLUUID		    fullid;
+	LLViewerStatsRecorder& recorder = LLViewerStatsRecorder::instance();
+
+	// Cache Hit.
+	cached_dpp->reset();
+	cached_dpp->unpackUUID(fullid, "ID");
+	cached_dpp->unpackU32(local_id, "LocalID");
+	cached_dpp->unpackU8(pcode, "PCode");
+
+	objectp = findObject(fullid);
+
+	if (objectp)
+	{
+		if(!objectp->isDead() && (objectp->mLocalID != entry->getLocalID() ||
+			objectp->getRegion() != regionp))
+		{
+			removeFromLocalIDTable(objectp);
+			setUUIDAndLocal(fullid, entry->getLocalID(),
+							regionp->getHost().getAddress(),
+							regionp->getHost().getPort());
+				
+			if (objectp->mLocalID != entry->getLocalID())
+			{	// Update local ID in object with the one sent from the region
+				objectp->mLocalID = entry->getLocalID();
+			}
+			
+			if (objectp->getRegion() != regionp)
+			{	// Object changed region, so update it
+				objectp->updateRegion(regionp); // for LLVOAvatar
+			}
+		}
+
+		//return TRUE; //already loaded.
+	}
+
+	bool justCreated = false;
+	if (!objectp)
+	{
+		objectp = createObjectFromCache(pcode, regionp, fullid, entry->getLocalID());
+		
+		if (!objectp)
+		{
+			llinfos << "createObject failure for object: " << fullid << llendl;
+			recorder.objectUpdateFailure(entry->getLocalID(), OUT_FULL_CACHED, 0);
+			return NULL;
+		}
+		justCreated = true;
+		mNumNewObjects++;
+		sCacheHitRate.addValue(100.f);
+	}
+
+	if (objectp->isDead())
+	{
+		llwarns << "Dead object " << objectp->mID << " in UUID map 1!" << llendl;
+	}
+		
+	processUpdateCore(objectp, NULL, 0, OUT_FULL_CACHED, cached_dpp, justCreated, true);
+		
+	recorder.log(0.2f);
+	LLVOAvatar::cullAvatarsByPixelArea();
+
+	return objectp;
+}
+
 void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 											 void **user_data,
 											 const EObjectUpdateType update_type,
@@ -382,14 +476,8 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 		}
 		else if (compressed)
 		{
-			S32							uncompressed_length = 2048;
-			compressed_dp.reset();
-
-			U32 flags = 0;
-			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
-			{
-				mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i);
-			}
+			S32	uncompressed_length = 2048;
+			compressed_dp.reset();			
 			
 			uncompressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data);
 			mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compressed_dpbuffer, 0, i);
@@ -540,9 +628,15 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			processUpdateCore(objectp, user_data, i, update_type, &compressed_dp, justCreated);
 			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
-				bCached = true;
-				LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp);
-				recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);
+				U32 flags = 0;
+				mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i);
+			
+				if(!(flags & FLAGS_TEMPORARY_ON_REZ))
+				{
+					bCached = true;
+					LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp);
+					recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);
+				}
 			}
 		}
 		else if (cached) // Cache hit only?
@@ -1887,7 +1981,30 @@ LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLVi
 	return objectp;
 }
 
+LLViewerObject *LLViewerObjectList::createObjectFromCache(const LLPCode pcode, LLViewerRegion *regionp, const LLUUID &uuid, const U32 local_id)
+{
+	llassert_always(uuid.notNull());
 
+	LLViewerObject *objectp = LLViewerObject::createObject(uuid, pcode, regionp);
+	if (!objectp)
+	{
+// 		llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << " id:" << fullid << llendl;
+		return NULL;
+	}
+
+	objectp->mLocalID = local_id;
+	mUUIDObjectMap[uuid] = objectp;
+	setUUIDAndLocal(uuid,
+					local_id,
+					regionp->getHost().getAddress(),
+					regionp->getHost().getPort());
+	mObjects.push_back(objectp);
+	
+	updateActive(objectp);
+
+	return objectp;
+}
+ 
 LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRegion *regionp,
 												 const LLUUID &uuid, const U32 local_id, const LLHost &sender)
 {
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 9936432a71..1476f44215 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -40,6 +40,7 @@
 class LLCamera;
 class LLNetMap;
 class LLDebugBeacon;
+class LLVOCacheEntry;
 
 const U32 CLOSE_BIN_SIZE = 10;
 const U32 NUM_BINS = 128;
@@ -65,6 +66,7 @@ public:
 	
 	inline LLViewerObject *findObject(const LLUUID &id);
 	LLViewerObject *createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp); // Create a viewer-side object
+	LLViewerObject *createObjectFromCache(const LLPCode pcode, LLViewerRegion *regionp, const LLUUID &uuid, const U32 local_id);
 	LLViewerObject *createObject(const LLPCode pcode, LLViewerRegion *regionp,
 								 const LLUUID &uuid, const U32 local_id, const LLHost &sender);
 
@@ -78,7 +80,9 @@ public:
 	void cleanDeadObjects(const BOOL use_timer = TRUE);	// Clean up the dead object list.
 
 	// Simulator and viewer side object updates...
-	void processUpdateCore(LLViewerObject* objectp, void** data, U32 block, const EObjectUpdateType update_type, LLDataPacker* dpp, BOOL justCreated);
+	void processUpdateCore(LLViewerObject* objectp, void** data, U32 block, const EObjectUpdateType update_type, 
+		                   LLDataPacker* dpp, bool justCreated, bool from_cache = false);
+	LLViewerObject* processObjectUpdateFromCache(LLVOCacheEntry* entry, LLViewerRegion* regionp);
 	void processObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type, bool cached=false, bool compressed=false);
 	void processCompressedObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type);
 	void processCachedObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type);
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
new file mode 100644
index 0000000000..05f977036c
--- /dev/null
+++ b/indra/newview/llvieweroctree.cpp
@@ -0,0 +1,704 @@
+/** 
+ * @file llvieweroctree.cpp
+ * @brief LLViewerOctreeGroup class implementation and supporting functions
+ *
+ * $LicenseInfo:firstyear=2003&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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 "llviewerprecompiledheaders.h"
+#include "llvieweroctree.h"
+
+//-----------------------------------------------------------------------------------
+//static variables definitions
+//-----------------------------------------------------------------------------------
+U32 LLViewerOctreeEntryData::sCurVisible = 0;
+
+//-----------------------------------------------------------------------------------
+//some global functions definitions
+//-----------------------------------------------------------------------------------
+S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad)
+{
+	return AABBSphereIntersectR2(min, max, origin, rad*rad);
+}
+
+S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &r)
+{
+	F32 d = 0.f;
+	F32 t;
+	
+	if ((min-origin).magVecSquared() < r &&
+		(max-origin).magVecSquared() < r)
+	{
+		return 2;
+	}
+
+	for (U32 i = 0; i < 3; i++)
+	{
+		if (origin.mV[i] < min.mV[i])
+		{
+			t = min.mV[i] - origin.mV[i];
+			d += t*t;
+		}
+		else if (origin.mV[i] > max.mV[i])
+		{
+			t = origin.mV[i] - max.mV[i];
+			d += t*t;
+		}
+
+		if (d > r)
+		{
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
+
+S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad)
+{
+	return AABBSphereIntersectR2(min, max, origin, rad*rad);
+}
+
+S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &r)
+{
+	F32 d = 0.f;
+	F32 t;
+	
+	LLVector4a origina;
+	origina.load3(origin.mV);
+
+	LLVector4a v;
+	v.setSub(min, origina);
+	
+	if (v.dot3(v) < r)
+	{
+		v.setSub(max, origina);
+		if (v.dot3(v) < r)
+		{
+			return 2;
+		}
+	}
+
+
+	for (U32 i = 0; i < 3; i++)
+	{
+		if (origin.mV[i] < min[i])
+		{
+			t = min[i] - origin.mV[i];
+			d += t*t;
+		}
+		else if (origin.mV[i] > max[i])
+		{
+			t = origin.mV[i] - max[i];
+			d += t*t;
+		}
+
+		if (d > r)
+		{
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------------
+//class LLViewerOctreeEntry definitions
+//-----------------------------------------------------------------------------------
+LLViewerOctreeEntry::LLViewerOctreeEntry() : mGroup(NULL)
+{
+	mPositionGroup.clear();
+	mExtents[0].clear();
+	mExtents[1].clear();
+	mBinRadius = 0.f;
+	mBinIndex = -1;
+
+	for(S32 i = 0; i < NUM_DATA_TYPE; i++)
+	{
+		mData[i] = NULL;
+	}
+}
+
+LLViewerOctreeEntry::~LLViewerOctreeEntry()
+{
+	llassert(!mGroup);
+}
+
+void LLViewerOctreeEntry::addData(LLViewerOctreeEntryData* data)
+{
+	//llassert(mData[data->getDataType()] == NULL);	
+	llassert(data != NULL);
+
+	mData[data->getDataType()] = data;
+}
+
+void LLViewerOctreeEntry::removeData(LLViewerOctreeEntryData* data)
+{
+	//llassert(data->getDataType() != LLVOCACHEENTRY); //can not remove VOCache entry
+
+	if(!mData[data->getDataType()])
+	{
+		return;
+	}
+
+	mData[data->getDataType()] = NULL;
+	
+	if(mGroup != NULL && !mData[LLDRAWABLE])
+	{
+		LLviewerOctreeGroup* group = mGroup;
+		mGroup = NULL;
+		group->removeFromGroup(data);
+
+		llassert(mBinIndex == -1);				
+	}
+}
+
+//called by group handleDestruction() ONLY when group is destroyed by octree.
+void LLViewerOctreeEntry::nullGroup()
+{
+	mGroup = NULL;
+}
+
+void LLViewerOctreeEntry::setGroup(LLviewerOctreeGroup* group)
+{
+	if(mGroup == group)
+	{
+		return;
+	}
+
+	if(mGroup)
+	{
+		LLviewerOctreeGroup* group = mGroup;
+		mGroup = NULL;
+		group->removeFromGroup(this);
+
+		llassert(mBinIndex == -1);
+	}
+
+	mGroup = group;
+}
+
+//-----------------------------------------------------------------------------------
+//class LLViewerOctreeEntryData definitions
+//-----------------------------------------------------------------------------------
+LLViewerOctreeEntryData::~LLViewerOctreeEntryData()
+{
+	if(mEntry)
+	{
+		mEntry->removeData(this);
+	}
+}
+
+LLViewerOctreeEntryData::LLViewerOctreeEntryData(LLViewerOctreeEntry::eEntryDataType_t data_type)
+	: mDataType(data_type),
+	  mEntry(NULL)
+{
+}
+
+//virtual
+void LLViewerOctreeEntryData::setOctreeEntry(LLViewerOctreeEntry* entry)
+{
+	if(mEntry.notNull())
+	{
+		return; 
+	}
+
+	if(!entry)
+	{
+		mEntry = new LLViewerOctreeEntry();
+	}
+	else
+	{
+		mEntry = entry;
+	}
+	mEntry->addData(this);
+}
+
+void LLViewerOctreeEntryData::setSpatialExtents(const LLVector3& min, const LLVector3& max)
+{ 
+	mEntry->mExtents[0].load3(min.mV); 
+	mEntry->mExtents[1].load3(max.mV);
+}
+
+void LLViewerOctreeEntryData::setSpatialExtents(const LLVector4a& min, const LLVector4a& max)
+{ 
+	mEntry->mExtents[0] = min; 
+	mEntry->mExtents[1] = max;
+}
+
+void LLViewerOctreeEntryData::setPositionGroup(const LLVector4a& pos)
+{
+	mEntry->mPositionGroup = pos;
+}
+
+const LLVector4a* LLViewerOctreeEntryData::getSpatialExtents() const 
+{
+	return mEntry->getSpatialExtents();
+}
+
+//virtual
+void LLViewerOctreeEntryData::setGroup(LLviewerOctreeGroup* group)
+{
+	mEntry->setGroup(group);
+}
+
+void LLViewerOctreeEntryData::shift(const LLVector4a &shift_vector)
+{
+	mEntry->mExtents[0].add(shift_vector);
+	mEntry->mExtents[1].add(shift_vector);
+	mEntry->mPositionGroup.add(shift_vector);
+}
+
+LLviewerOctreeGroup* LLViewerOctreeEntryData::getGroup()const        
+{
+	return mEntry.notNull() ? mEntry->mGroup : NULL;
+}
+
+const LLVector4a& LLViewerOctreeEntryData::getPositionGroup() const  
+{
+	return mEntry->getPositionGroup();
+}	
+
+//virtual
+bool LLViewerOctreeEntryData::isVisible() const
+{
+	if(mEntry)
+	{
+		return mEntry->mVisible == sCurVisible;
+	}
+	return false;
+}
+
+//virtual
+bool LLViewerOctreeEntryData::isRecentlyVisible() const
+{
+	if(!mEntry)
+	{
+		return false;
+	}
+
+	if(isVisible())
+	{
+		return true;
+	}
+	if(getGroup() && getGroup()->isRecentlyVisible())
+	{
+		setVisible();
+		return true;
+	}
+
+	return (sCurVisible - mEntry->mVisible < getMinVisFrameRange());
+}
+
+void LLViewerOctreeEntryData::setVisible() const
+{
+	if(mEntry)
+	{
+		mEntry->mVisible = sCurVisible;
+	}
+}
+
+//-----------------------------------------------------------------------------------
+//class LLviewerOctreeGroup definitions
+//-----------------------------------------------------------------------------------
+
+LLviewerOctreeGroup::~LLviewerOctreeGroup()
+{
+}
+
+LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) :
+	mOctreeNode(node),
+	mState(CLEAN)
+{
+	LLVector4a tmp;
+	tmp.splat(0.f);
+	mExtents[0] = mExtents[1] = mObjectBounds[0] = mObjectBounds[0] = mObjectBounds[1] = 
+		mObjectExtents[0] = mObjectExtents[1] = tmp;
+	
+	mBounds[0] = node->getCenter();
+	mBounds[1] = node->getSize();
+
+	mOctreeNode->addListener(this);
+}
+
+bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data)
+{
+	return removeFromGroup(data->getEntry());
+}
+
+bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry)
+{
+	llassert(entry != NULL);
+	llassert(!entry->getGroup());
+
+	unbound();
+	if (mOctreeNode)
+	{
+		if (!mOctreeNode->remove(entry))
+		{
+			OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << llendl;
+			return false;
+		}
+	}
+	setState(OBJECT_DIRTY);
+
+	return true;
+}
+
+//virtual 
+void LLviewerOctreeGroup::unbound()
+{
+	if (isDirty())
+	{
+		return;
+	}
+
+	setState(DIRTY);
+	
+	//all the parent nodes need to rebound this child
+	if (mOctreeNode)
+	{
+		OctreeNode* parent = (OctreeNode*) mOctreeNode->getParent();
+		while (parent != NULL)
+		{
+			LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) parent->getListener(0);
+			if (!group || group->isDirty())
+			{
+				return;
+			}
+			
+			group->setState(DIRTY);
+			parent = (OctreeNode*) parent->getParent();
+		}
+	}
+}
+	
+//virtual 
+void LLviewerOctreeGroup::rebound()
+{
+	if (!isDirty())
+	{	
+		return;
+	}
+	
+	if (mOctreeNode->getChildCount() == 1 && mOctreeNode->getElementCount() == 0)
+	{
+		LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0);
+		group->rebound();
+		
+		//copy single child's bounding box
+		mBounds[0] = group->mBounds[0];
+		mBounds[1] = group->mBounds[1];
+		mExtents[0] = group->mExtents[0];
+		mExtents[1] = group->mExtents[1];
+		
+		group->setState(SKIP_FRUSTUM_CHECK);
+	}
+	else if (mOctreeNode->isLeaf())
+	{ //copy object bounding box if this is a leaf
+		boundObjects(TRUE, mExtents[0], mExtents[1]);
+		mBounds[0] = mObjectBounds[0];
+		mBounds[1] = mObjectBounds[1];
+	}
+	else
+	{
+		LLVector4a& newMin = mExtents[0];
+		LLVector4a& newMax = mExtents[1];
+		LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) mOctreeNode->getChild(0)->getListener(0);
+		group->clearState(SKIP_FRUSTUM_CHECK);
+		group->rebound();
+		//initialize to first child
+		newMin = group->mExtents[0];
+		newMax = group->mExtents[1];
+
+		//first, rebound children
+		for (U32 i = 1; i < mOctreeNode->getChildCount(); i++)
+		{
+			group = (LLviewerOctreeGroup*) mOctreeNode->getChild(i)->getListener(0);
+			group->clearState(SKIP_FRUSTUM_CHECK);
+			group->rebound();
+			const LLVector4a& max = group->mExtents[1];
+			const LLVector4a& min = group->mExtents[0];
+
+			newMax.setMax(newMax, max);
+			newMin.setMin(newMin, min);
+		}
+
+		boundObjects(FALSE, newMin, newMax);
+		
+		mBounds[0].setAdd(newMin, newMax);
+		mBounds[0].mul(0.5f);
+		mBounds[1].setSub(newMax, newMin);
+		mBounds[1].mul(0.5f);
+	}
+	
+	clearState(DIRTY);
+
+	return;
+}
+
+//virtual 
+void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj)
+{
+	obj->setGroup(this);	
+	unbound();
+	setState(OBJECT_DIRTY);
+}
+	
+//virtual 
+void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj)
+{
+	obj->setGroup(NULL);
+	unbound();
+	setState(OBJECT_DIRTY);
+}
+	
+//virtual 
+void LLviewerOctreeGroup::handleDestruction(const TreeNode* node)
+{
+	for (OctreeNode::element_iter i = mOctreeNode->getDataBegin(); i != mOctreeNode->getDataEnd(); ++i)
+	{
+		LLViewerOctreeEntry* obj = *i;
+		if (obj && obj->getGroup() == this)
+		{
+			obj->nullGroup();
+		}
+	}
+}
+	
+//virtual 
+void LLviewerOctreeGroup::handleStateChange(const TreeNode* node)
+{
+	//drop bounding box upon state change
+	if (mOctreeNode != node)
+	{
+		mOctreeNode = (OctreeNode*) node;
+	}
+	unbound();
+}
+	
+//virtual 
+void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child)
+{
+	llerrs << "can not access here. It is an abstract class." << llendl;
+
+	//((LLviewerOctreeGroup*)child->getListener(0))->unbound();
+}
+	
+//virtual 
+void LLviewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child)
+{
+	unbound();
+}
+
+LLviewerOctreeGroup* LLviewerOctreeGroup::getParent()
+{
+	if(!mOctreeNode)
+	{
+		return NULL;
+	}
+	
+	OctreeNode* parent = mOctreeNode->getOctParent();
+
+	if (parent)
+	{
+		return (LLviewerOctreeGroup*) parent->getListener(0);
+	}
+
+	return NULL;
+}
+
+//virtual 
+bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut)
+{
+	const OctreeNode* node = mOctreeNode;
+
+	if (node->isEmpty())
+	{	//don't do anything if there are no objects
+		if (empty && mOctreeNode->getParent())
+		{	//only root is allowed to be empty
+			OCT_ERRS << "Empty leaf found in octree." << llendl;
+		}
+		return false;
+	}
+
+	LLVector4a& newMin = mObjectExtents[0];
+	LLVector4a& newMax = mObjectExtents[1];
+	
+	if (hasState(OBJECT_DIRTY))
+	{ //calculate new bounding box
+		clearState(OBJECT_DIRTY);
+
+		//initialize bounding box to first element
+		OctreeNode::const_element_iter i = node->getDataBegin();
+		LLViewerOctreeEntry* entry = *i;
+		const LLVector4a* minMax = entry->getSpatialExtents();
+
+		newMin = minMax[0];
+		newMax = minMax[1];
+
+		for (++i; i != node->getDataEnd(); ++i)
+		{
+			entry = *i;
+			minMax = entry->getSpatialExtents();
+			
+			update_min_max(newMin, newMax, minMax[0]);
+			update_min_max(newMin, newMax, minMax[1]);
+		}
+		
+		mObjectBounds[0].setAdd(newMin, newMax);
+		mObjectBounds[0].mul(0.5f);
+		mObjectBounds[1].setSub(newMax, newMin);
+		mObjectBounds[1].mul(0.5f);
+	}
+	
+	if (empty)
+	{
+		minOut = newMin;
+		maxOut = newMax;
+	}
+	else
+	{
+		minOut.setMin(minOut, newMin);
+		maxOut.setMax(maxOut, newMax);
+	}
+		
+	return TRUE;
+}
+
+//virtual 
+BOOL LLviewerOctreeGroup::isVisible() const
+{
+	return TRUE;
+}
+
+//-----------------------------------------------------------------------------------
+//class LLViewerOctreeCull definitions
+//-----------------------------------------------------------------------------------
+
+//virtual 
+bool LLViewerOctreeCull::earlyFail(LLviewerOctreeGroup* group)
+{	
+	return false;
+}
+	
+//virtual 
+void LLViewerOctreeCull::traverse(const OctreeNode* n)
+{
+	LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) n->getListener(0);
+
+	if (earlyFail(group))
+	{
+		return;
+	}
+		
+	if (mRes == 2 || 
+		(mRes && group->hasState(LLviewerOctreeGroup::SKIP_FRUSTUM_CHECK)))
+	{	//fully in, just add everything
+		OctreeTraveler::traverse(n);
+	}
+	else
+	{
+		mRes = frustumCheck(group);
+				
+		if (mRes)
+		{ //at least partially in, run on down
+			OctreeTraveler::traverse(n);
+		}
+
+		mRes = 0;
+	}
+}
+	
+S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group)
+{
+	return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist);
+}
+
+S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group)
+{
+	return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist);
+}
+
+S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
+}
+
+//virtual 
+bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group)
+{
+	if (branch->getElementCount() == 0) //no elements
+	{
+		return false;
+	}
+	else if (branch->getChildCount() == 0) //leaf state, already checked tightest bounding box
+	{
+		return true;
+	}
+	else if (mRes == 1 && !frustumCheckObjects(group)) //no objects in frustum
+	{
+		return false;
+	}
+		
+	return true;
+}
+
+//virtual 
+void LLViewerOctreeCull::preprocess(LLviewerOctreeGroup* group)
+{		
+}
+	
+//virtual 
+void LLViewerOctreeCull::processGroup(LLviewerOctreeGroup* group)
+{
+}
+	
+//virtual 
+void LLViewerOctreeCull::visit(const OctreeNode* branch) 
+{	
+	LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0);
+
+	preprocess(group);
+		
+	if (checkObjects(branch, group))
+	{
+		processGroup(group);
+	}
+}
+
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
new file mode 100644
index 0000000000..c063e96ea5
--- /dev/null
+++ b/indra/newview/llvieweroctree.h
@@ -0,0 +1,274 @@
+/** 
+ * @file llvieweroctree.h
+ * @brief LLViewerObjectOctree.cpp header file, defining all supporting classes.
+ *
+ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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$
+ */
+
+#ifndef LL_VIEWEROCTREE_H
+#define LL_VIEWEROCTREE_H
+
+#include <vector>
+#include <map>
+
+#include "v2math.h"
+#include "v3math.h"
+#include "v4math.h"
+#include "m4math.h"
+#include "llvector4a.h"
+#include "llquaternion.h"
+#include "lloctree.h"
+#include "llcamera.h"
+
+class LLViewerOctreeEntryData;
+class LLviewerOctreeGroup;
+class LLViewerOctreeEntry;
+
+typedef LLOctreeListener<LLViewerOctreeEntry>	OctreeListener;
+typedef LLTreeNode<LLViewerOctreeEntry>			TreeNode;
+typedef LLOctreeNode<LLViewerOctreeEntry>		OctreeNode;
+typedef LLOctreeRoot<LLViewerOctreeEntry>		OctreeRoot;
+typedef LLOctreeTraveler<LLViewerOctreeEntry>	OctreeTraveler;
+
+S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad);
+S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &radius_squared);
+
+S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad);
+S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared);
+
+//defines data needed for octree of an entry
+LL_ALIGN_PREFIX(16)
+class LLViewerOctreeEntry : public LLRefCount
+{
+	friend class LLViewerOctreeEntryData;
+
+public:
+	typedef enum
+	{
+		LLDRAWABLE = 0,
+		LLVOCACHEENTRY,
+		NUM_DATA_TYPE
+	}eEntryDataType_t;
+
+	~LLViewerOctreeEntry();
+public:
+	LLViewerOctreeEntry();
+	
+	void nullGroup(); //called by group handleDestruction() only
+	void setGroup(LLviewerOctreeGroup* group);
+	void removeData(LLViewerOctreeEntryData* data);
+
+	LLViewerOctreeEntryData* getData(U32 data_type)const {return mData[data_type];}
+	bool                     hasData(U32 data_type)const {return mData[data_type] != NULL;}
+
+	LLViewerOctreeEntryData* getDrawable() const {return mData[LLDRAWABLE];}
+	bool                     hasDrawable() const {return mData[LLDRAWABLE] != NULL;}
+	LLViewerOctreeEntryData* getVOCacheEntry() const {return mData[LLVOCACHEENTRY];}
+	bool                     hasVOCacheEntry() const {return mData[LLVOCACHEENTRY] != NULL;}
+
+	const LLVector4a* getSpatialExtents() const {return mExtents;} 
+	const LLVector4a& getPositionGroup() const  {return mPositionGroup;}	
+	LLviewerOctreeGroup* getGroup()const        {return mGroup;}
+	
+	F32  getBinRadius() const                   {return mBinRadius;}
+	S32	 getBinIndex() const			        {return mBinIndex; }
+	void setBinIndex(S32 index) const	        {mBinIndex = index; }
+
+private:
+	void addData(LLViewerOctreeEntryData* data);			
+
+private:
+	LLViewerOctreeEntryData*    mData[NUM_DATA_TYPE]; //do not use LLPointer here.
+	LLviewerOctreeGroup*        mGroup;
+
+	//aligned members
+	LL_ALIGN_16(LLVector4a		mExtents[2]);
+	LL_ALIGN_16(LLVector4a		mPositionGroup);
+	F32				            mBinRadius;
+	mutable S32		            mBinIndex;
+	mutable U32		            mVisible;	
+
+} LL_ALIGN_POSTFIX(16);
+
+//defines an abstract class for entry data
+LL_ALIGN_PREFIX(16)
+class LLViewerOctreeEntryData : public LLRefCount
+{
+protected:
+	~LLViewerOctreeEntryData();
+
+public:
+	LLViewerOctreeEntryData(const LLViewerOctreeEntryData& rhs)
+	{
+		*this = rhs;
+	}
+	LLViewerOctreeEntryData(LLViewerOctreeEntry::eEntryDataType_t data_type);
+	
+	LLViewerOctreeEntry::eEntryDataType_t getDataType() const {return mDataType;}
+	LLViewerOctreeEntry* getEntry() {return mEntry;}
+	
+	virtual void setOctreeEntry(LLViewerOctreeEntry* entry);
+
+	virtual S32  getMinVisFrameRange()const = 0;
+
+	F32                  getBinRadius() const   {return mEntry->getBinRadius();}
+	const LLVector4a*    getSpatialExtents() const;
+	LLviewerOctreeGroup* getGroup()const;
+	const LLVector4a&    getPositionGroup() const;
+
+	void setBinRadius(F32 rad)  {mEntry->mBinRadius = rad;}
+	void setSpatialExtents(const LLVector3& min, const LLVector3& max);
+	void setSpatialExtents(const LLVector4a& min, const LLVector4a& max);
+	void setPositionGroup(const LLVector4a& pos);
+	
+	virtual void setGroup(LLviewerOctreeGroup* group);
+	void         shift(const LLVector4a &shift_vector);
+
+	U32          getVisible() const {return mEntry ? mEntry->mVisible : 0;}
+	void         setVisible() const;
+	virtual bool isVisible() const;
+	virtual bool isRecentlyVisible() const;	
+	
+	static S32 getCurrentFrame() { return sCurVisible; }
+
+protected:
+	LLVector4a& getGroupPosition()  {return mEntry->mPositionGroup;}
+	void        initVisible(U32 visible) {mEntry->mVisible = visible;}
+
+	static void incrementVisible() {sCurVisible++;}
+protected:
+	LLPointer<LLViewerOctreeEntry>        mEntry;
+	LLViewerOctreeEntry::eEntryDataType_t mDataType;
+	static  U32                           sCurVisible; // Counter for what value of mVisible means currently visible
+}LL_ALIGN_POSTFIX(16);
+
+
+//defines an octree group for an octree node, which contains multiple entries.
+LL_ALIGN_PREFIX(16)
+class LLviewerOctreeGroup : public LLOctreeListener<LLViewerOctreeEntry>
+{
+	friend class LLViewerOctreeCull;
+protected:
+	~LLviewerOctreeGroup();
+
+public:
+	enum
+	{
+		CLEAN              = 0x00000000,
+		DIRTY              = 0x00000001,
+		OBJECT_DIRTY       = 0x00000002,
+		SKIP_FRUSTUM_CHECK = 0x00000004,
+		INVALID_STATE      = 0x00000008,
+	};
+
+public:
+	LLviewerOctreeGroup(OctreeNode* node);
+	LLviewerOctreeGroup(const LLviewerOctreeGroup& rhs)
+	{
+		*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);
+
+	virtual void unbound();
+	virtual void rebound();
+
+	virtual BOOL isVisible() const;
+	virtual BOOL isRecentlyVisible() const = 0;
+
+	U32  getState()				   {return mState; }
+	bool isDirty() const           {return mState & DIRTY;}
+	bool hasState(U32 state) const {return mState & state;}
+	void setState(U32 state)       {mState |= state;}
+	void clearState(U32 state)     {mState &= ~state;}	
+
+	//LISTENER FUNCTIONS
+	virtual void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj);
+	virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj);
+	virtual void handleDestruction(const TreeNode* node);
+	virtual void handleStateChange(const TreeNode* node);
+	virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
+	virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child);
+
+	OctreeNode*          getOctreeNode() {return mOctreeNode;}
+	LLviewerOctreeGroup* getParent();
+
+	const LLVector4a* getBounds() const        {return mBounds;}
+	const LLVector4a* getExtents() const       {return mExtents;}
+	const LLVector4a* getObjectBounds() const  {return mObjectBounds;}
+	const LLVector4a* getObjectExtents() const {return mObjectExtents;}
+
+private:
+	virtual bool boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut);	
+	
+protected:
+	U32         mState;
+	OctreeNode* mOctreeNode;
+	
+	LL_ALIGN_16(LLVector4a mBounds[2]);       // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
+	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
+	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
+
+}LL_ALIGN_POSTFIX(16);
+
+class LLViewerOctreeCull : public OctreeTraveler
+{
+public:
+	LLViewerOctreeCull(LLCamera* camera)
+		: mCamera(camera), mRes(0) { }
+
+	virtual bool earlyFail(LLviewerOctreeGroup* group);
+	virtual void traverse(const OctreeNode* n);
+	
+	S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group);
+	S32 AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group);
+	S32 AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group);
+	S32 AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group);
+	S32 AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group);
+	S32 AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group);
+	
+	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 void visit(const OctreeNode* branch);
+	
+protected:
+	LLCamera *mCamera;
+	S32 mRes;
+};
+
+#endif
\ No newline at end of file
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 6bd9f66b9c..8acdc08b00 100644
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -151,8 +151,8 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 bo
 
 	if (group != NULL)
 	{
-		LLVector3 center(group->mOctreeNode->getCenter().getF32ptr());
-		LLVector3 size(group->mOctreeNode->getSize().getF32ptr());
+		LLVector3 center(group->getOctreeNode()->getCenter().getF32ptr());
+		LLVector3 size(group->getOctreeNode()->getSize().getF32ptr());
 		size += LLVector3(0.01f, 0.01f, 0.01f);
 		mMinObjPos = center - size;
 		mMaxObjPos = center + size;
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 31e3820a21..15c95aa30a 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -70,6 +70,7 @@
 #include "stringize.h"
 #include "llviewercontrol.h"
 #include "llsdserialize.h"
+#include "llvieweroctree.h"
 
 #ifdef LL_WINDOWS
 	#pragma warning(disable:4355)
@@ -133,7 +134,14 @@ public:
 	// Misc
 	LLVLComposition *mCompositionp;		// Composition layer for the surface
 
-	LLVOCacheEntry::vocache_entry_map_t		mCacheMap;
+	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.
+	LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //visible root entries of a linked set.
+	std::set< LLPointer<LLVOCacheEntry> > mDummyEntries; //dummy vo cache entries, for LLSpatialBridge use.
+	std::set< LLSpatialGroup* >         mVisibleGroups; //visible llspatialgroup
+	LLVOCachePartition*                 mVOCachePartition;
+
 	// time?
 	// LRU info?
 
@@ -291,7 +299,8 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 	mCacheLoaded(FALSE),
 	mCacheDirty(FALSE),
 	mReleaseNotesRequested(FALSE),
-	mCapabilitiesReceived(false)
+	mCapabilitiesReceived(false),
+	mDead(FALSE)
 {
 	mWidth = region_width_meters;
 	mImpl->mOriginGlobal = from_region_handle(handle); 
@@ -323,17 +332,20 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 
 	//create object partitions
 	//MUST MATCH declaration of eObjectPartitions
-	mImpl->mObjectPartition.push_back(new LLHUDPartition());		//PARTITION_HUD
-	mImpl->mObjectPartition.push_back(new LLTerrainPartition());	//PARTITION_TERRAIN
-	mImpl->mObjectPartition.push_back(new LLVoidWaterPartition());	//PARTITION_VOIDWATER
-	mImpl->mObjectPartition.push_back(new LLWaterPartition());		//PARTITION_WATER
-	mImpl->mObjectPartition.push_back(new LLTreePartition());		//PARTITION_TREE
-	mImpl->mObjectPartition.push_back(new LLParticlePartition());	//PARTITION_PARTICLE
-	mImpl->mObjectPartition.push_back(new LLGrassPartition());		//PARTITION_GRASS
-	mImpl->mObjectPartition.push_back(new LLVolumePartition());	//PARTITION_VOLUME
-	mImpl->mObjectPartition.push_back(new LLBridgePartition());	//PARTITION_BRIDGE
-	mImpl->mObjectPartition.push_back(new LLHUDParticlePartition());//PARTITION_HUD_PARTICLE
+	mImpl->mObjectPartition.push_back(new LLHUDPartition(this));		//PARTITION_HUD
+	mImpl->mObjectPartition.push_back(new LLTerrainPartition(this));	//PARTITION_TERRAIN
+	mImpl->mObjectPartition.push_back(new LLVoidWaterPartition(this));	//PARTITION_VOIDWATER
+	mImpl->mObjectPartition.push_back(new LLWaterPartition(this));		//PARTITION_WATER
+	mImpl->mObjectPartition.push_back(new LLTreePartition(this));		//PARTITION_TREE
+	mImpl->mObjectPartition.push_back(new LLParticlePartition(this));	//PARTITION_PARTICLE
+	mImpl->mObjectPartition.push_back(new LLGrassPartition(this));		//PARTITION_GRASS
+	mImpl->mObjectPartition.push_back(new LLVolumePartition(this));	//PARTITION_VOLUME
+	mImpl->mObjectPartition.push_back(new LLBridgePartition(this));	//PARTITION_BRIDGE
+	mImpl->mObjectPartition.push_back(new LLHUDParticlePartition(this));//PARTITION_HUD_PARTICLE
+	mImpl->mObjectPartition.push_back(new LLVOCachePartition(this)); //PARTITION_VO_CACHE
 	mImpl->mObjectPartition.push_back(NULL);						//PARTITION_NONE
+
+	mImpl->mVOCachePartition = (LLVOCachePartition*)getSpatialPartition(PARTITION_VO_CACHE);
 }
 
 
@@ -354,6 +366,12 @@ void LLViewerRegion::initStats()
 
 LLViewerRegion::~LLViewerRegion() 
 {
+	mDead = TRUE;
+	mImpl->mActiveSet.clear();
+	mImpl->mVisibleEntries.clear();
+	mImpl->mVisibleGroups.clear();
+	mImpl->mWaitingSet.clear();
+
 	gVLManager.cleanupData(this);
 	// Can't do this on destruction, because the neighbor pointers might be invalid.
 	// This should be reference counted...
@@ -437,10 +455,6 @@ void LLViewerRegion::saveObjectCache()
 		mCacheDirty = FALSE;
 	}
 
-	for(LLVOCacheEntry::vocache_entry_map_t::iterator iter = mImpl->mCacheMap.begin(); iter != mImpl->mCacheMap.end(); ++iter)
-	{
-		delete iter->second;
-	}
 	mImpl->mCacheMap.clear();
 }
 
@@ -718,8 +732,199 @@ void LLViewerRegion::dirtyHeights()
 	}
 }
 
+void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry)
+{
+	LLPointer<LLViewerOctreeEntry> oct_entry;
+	U32 state = LLVOCacheEntry::INACTIVE;
+
+	if(old_entry)
+	{
+		oct_entry = old_entry->getEntry();
+		state = old_entry->getState();		
+
+		while(old_entry->getNumOfChildren() > 0)
+		{
+			new_entry->addChild(old_entry->getNextChild());
+		}
+
+		killCacheEntry(old_entry);
+	}
+
+	mImpl->mCacheMap[new_entry->getLocalID()] = new_entry;
+	if(oct_entry.notNull())
+	{
+		new_entry->setOctreeEntry(oct_entry);
+	}
+
+	if(state == LLVOCacheEntry::ACTIVE)
+	{
+		llassert(new_entry->getEntry()->hasDrawable());
+		mImpl->mActiveSet.insert(new_entry);
+	}
+	else if(state == LLVOCacheEntry::WAITING)
+	{
+		mImpl->mWaitingSet.insert(new_entry);
+	}
+	else if(old_entry && oct_entry)
+	{
+		addToVOCacheTree(new_entry);
+	}
+	new_entry->setState(state);
+}
+
+//physically delete the cache entry
+void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry)
+{	
+	if(!entry)
+	{
+		return;
+	}
+
+	//1, remove from active list and waiting list
+	if(entry->isState(LLVOCacheEntry::ACTIVE))
+	{
+		mImpl->mActiveSet.erase(entry);
+	}
+	else if(entry->isState(LLVOCacheEntry::WAITING))
+	{
+		mImpl->mWaitingSet.erase(entry);
+	}	
+
+	//2, kill LLViewerObject if exists
+	//this should be done by the rendering pipeline automatically.
+
+	//3, remove from mVOCachePartition
+	if(entry->isState(LLVOCacheEntry::INACTIVE) && entry->getEntry())
+	{
+		removeFromVOCacheTree(entry);
+	}
+
+	entry->setState(LLVOCacheEntry::INACTIVE);
+	//4, remove from mCacheMap, real deletion
+	mImpl->mCacheMap.erase(entry->getLocalID());
+}
+
+//physically delete the cache entry	
+void LLViewerRegion::killCacheEntry(U32 local_id) 
+{
+	killCacheEntry(getCacheEntry(local_id));
+}
+
+U32 LLViewerRegion::getNumOfActiveCachedObjects() const
+{
+	return  mImpl->mActiveSet.size();
+}
+
+void LLViewerRegion::addActiveCacheEntry(LLVOCacheEntry* entry)
+{
+	if(!entry || mDead)
+	{
+		return;
+	}
+
+	if(entry->isState(LLVOCacheEntry::WAITING))
+	{
+		mImpl->mWaitingSet.erase(entry);
+	}
+
+	entry->setState(LLVOCacheEntry::ACTIVE);
+	entry->setVisible();
+
+	llassert(entry->getEntry()->hasDrawable());
+	mImpl->mActiveSet.insert(entry);
+}
+
+void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep)
+{
+	if(mDead)
+	{
+		return;
+	}
+	if(entry->isDummy())
+	{
+		mImpl->mDummyEntries.insert(entry); //keep a copy to prevent from being deleted.
+		addToVOCacheTree(entry);
+	}
+	else if(!drawablep->getParent()) //root node
+	{
+		addToVOCacheTree(entry);
+		mImpl->mVisibleEntries.erase(entry);
+	}
+	else //child node
+	{
+		LLViewerOctreeEntry* parent_oct_entry = drawablep->getParent()->getEntry();
+		if(parent_oct_entry && parent_oct_entry->hasVOCacheEntry())
+		{
+			LLVOCacheEntry* parent = (LLVOCacheEntry*)parent_oct_entry->getVOCacheEntry();
+			parent->addChild(entry);
+		}
+	}
+
+	mImpl->mActiveSet.erase(entry);
+	mImpl->mWaitingSet.erase(entry);
+	entry->setState(LLVOCacheEntry::INACTIVE);
+}
+
+void LLViewerRegion::addVisibleGroup(LLSpatialGroup* group)
+{
+	if(mDead || group->isEmpty() || group->isDead())
+	{
+		return;
+	}
+
+	mImpl->mVisibleGroups.insert(group);
+}
+
+void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
+{
+	static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
+
+	if(mDead || !entry || !entry->getEntry())
+	{
+		return;
+	}
+	llassert(!entry->getGroup());
+
+	mImpl->mVOCachePartition->addEntry(entry->getEntry());
+}
+
+void LLViewerRegion::removeFromVOCacheTree(LLVOCacheEntry* entry)
+{
+	if(mDead || !entry || !entry->getEntry())
+	{
+		return;
+	}
+
+	mImpl->mVOCachePartition->removeEntry(entry->getEntry());
+}
+
+//add the visible root entry of a linked set
+void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
+{
+	if(mDead || !entry || !entry->getNumOfChildren())
+	{
+		return; //no child entries
+	}
+
+	mImpl->mVisibleEntries.insert(entry);
+}
+
+void LLViewerRegion::clearVisibleGroup(LLSpatialGroup* group)
+{
+	if(mDead)
+	{
+		return;
+	}
+
+	llassert(!group->getOctreeNode() || group->isEmpty());
+
+	mImpl->mVisibleGroups.erase(group);
+}
+
 BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 {
+	LLTimer update_timer;
+
 	// did_update returns TRUE if we did at least one significant update
 	BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time);
 	
@@ -729,9 +934,168 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 		mParcelOverlay->idleUpdate();
 	}
 
+	if(update_timer.getElapsedTimeF32() > max_update_time)
+	{
+		return did_update;
+	}
+
+	//kill invisible objects
+	std::vector<LLDrawable*> delete_list;
+	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
+		iter != mImpl->mActiveSet.end(); ++iter)
+	{
+		if(!(*iter)->isRecentlyVisible())
+		{
+			killObject((*iter), delete_list);
+		}
+	}
+	for(S32 i = 0; i < delete_list.size(); i++)
+	{
+		gObjectList.killObject(delete_list[i]->getVObj());
+	}
+	delete_list.clear();
+
+	bool timeout = false;
+	S32 new_object_count = 64; //minimum number of new objects to be added
+	//add childrens of visible objects to the rendering pipeline
+	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
+	{
+		LLVOCacheEntry* entry = *iter;				
+		LLVOCacheEntry* child = entry->getNextChild();
+		while(child != NULL)
+		{
+			if(child->isState(LLVOCacheEntry::INACTIVE))
+			{
+				addNewObject(child);
+				
+				if(new_object_count-- < 0 && update_timer.getElapsedTimeF32() > max_update_time)
+				{
+					timeout = true;
+					break;
+				}
+			}
+			child = entry->getNextChild();
+		}
+		if(!child)
+		{
+			if(entry->isDummy())
+			{
+				mImpl->mDummyEntries.erase(entry);
+			}
+
+			iter = mImpl->mVisibleEntries.erase(iter);
+		}
+		else
+		{
+			break; //timeout
+		}
+	}
+	if(timeout)
+	{
+		mImpl->mVisibleGroups.clear();
+		return did_update;
+	}
+
+	//add objects in the visible groups to the rendering pipeline
+	std::set< LLSpatialGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
+	while(group_iter != mImpl->mVisibleGroups.end())
+	{
+		LLSpatialGroup* group = *group_iter;
+		if(!group->getOctreeNode() || group->isEmpty())
+		{
+			mImpl->mVisibleGroups.erase(group_iter);
+			group_iter = mImpl->mVisibleGroups.begin();
+			continue;
+		}
+
+		std::vector<LLViewerOctreeEntry*> entry_list;
+		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+		{
+			//group data contents could change during creating new objects, so copy all contents first.
+			entry_list.push_back(*i);
+		}
+		
+		for(S32 i = 0; i < entry_list.size(); i++)
+		{
+			LLViewerOctreeEntry* entry = entry_list[i];
+			if(entry && entry->hasVOCacheEntry())
+			{
+				LLVOCacheEntry* vo_entry = (LLVOCacheEntry*)entry->getVOCacheEntry();
+				if(vo_entry->isDummy())
+				{
+					addVisibleCacheEntry(vo_entry); //for LLSpatialBridge.
+				}
+				else if(vo_entry->isState(LLVOCacheEntry::INACTIVE))
+				{
+					addNewObject(vo_entry);
+					if(new_object_count-- < 0 && update_timer.getElapsedTimeF32() > max_update_time)
+					{
+						timeout = true;
+						break;
+					}
+				}
+			}
+		}
+		entry_list.clear();
+
+		if(timeout)
+		{
+			break;
+		}
+		mImpl->mVisibleGroups.erase(group);
+		group_iter = mImpl->mVisibleGroups.begin();
+	}
+	mImpl->mVisibleGroups.clear();
+
 	return did_update;
 }
 
+void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list)
+{
+	//kill the object.
+	LLDrawable* drawablep = (LLDrawable*)entry->getEntry()->getDrawable();
+	llassert(drawablep);
+
+	if(!drawablep->getParent())
+	{
+		LLViewerObject::const_child_list_t& child_list = drawablep->getVObj()->getChildren();
+		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
+			iter != child_list.end(); iter++)
+		{
+			LLViewerObject* child = *iter;
+			if(child->mDrawable->isRecentlyVisible())
+			{
+				//set the parent group visible if any of its children visible.
+				drawablep->getSpatialGroup()->setVisible();
+				return;
+			}
+		}
+		delete_list.push_back(drawablep);				
+	}				
+}
+
+LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry)
+{
+	LLViewerObject* obj = NULL;
+	if(!entry->getEntry()->hasDrawable()) //not added to the rendering pipeline yet
+	{
+		//add the object
+		obj = gObjectList.processObjectUpdateFromCache(entry, this);
+		if(obj)
+		{
+			if(!entry->isState(LLVOCacheEntry::ACTIVE))
+			{
+				mImpl->mWaitingSet.insert(entry);
+				entry->setState(LLVOCacheEntry::WAITING);
+			}
+		}
+	}
+	else
+	{
+		llerrs << "Object is already created." << llendl;
+	}
+	return obj;
+}
 
 // As above, but forcibly do the update.
 void LLViewerRegion::forceUpdate()
@@ -1191,8 +1555,9 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 {
 	U32 local_id = objectp->getLocalID();
 	U32 crc = objectp->getCRC();
+	eCacheUpdateResult result;
 
-	LLVOCacheEntry* entry = get_if_there(mImpl->mCacheMap, local_id, (LLVOCacheEntry*)NULL);
+	LLVOCacheEntry* entry = getCacheEntry(local_id);
 
 	if (entry)
 	{
@@ -1201,41 +1566,79 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 		{
 			// Record a hit
 			entry->recordDupe();
-			return CACHE_UPDATE_DUPE;
+			result = CACHE_UPDATE_DUPE;
 		}
+		else
+		{
+			// Update the cache entry
+			LLPointer<LLVOCacheEntry> new_entry = new LLVOCacheEntry(local_id, crc, dp);
+			replaceCacheEntry(entry, new_entry);
+			entry = new_entry;
 
-		// Update the cache entry
-		mImpl->mCacheMap.erase(local_id);
-		delete entry;
+			result = CACHE_UPDATE_CHANGED;
+		}
+	}
+	else
+	{
+		// we haven't seen this object before
+		// Create new entry and add to map
+		result = CACHE_UPDATE_ADDED;
+		//if (mImpl->mCacheMap.size() > MAX_OBJECT_CACHE_ENTRIES)
+		//{
+		//	delete mImpl->mCacheMap.begin()->second ;
+		//	mImpl->mCacheMap.erase(mImpl->mCacheMap.begin());
+		//	result = CACHE_UPDATE_REPLACED;
+		//
+		//}
 		entry = new LLVOCacheEntry(local_id, crc, dp);
+
 		mImpl->mCacheMap[local_id] = entry;
-		return CACHE_UPDATE_CHANGED;
 	}
 
-	// we haven't seen this object before
-
-	// Create new entry and add to map
-	eCacheUpdateResult result = CACHE_UPDATE_ADDED;
-	if (mImpl->mCacheMap.size() > MAX_OBJECT_CACHE_ENTRIES)
+	if(objectp->mDrawable.notNull() && !entry->getEntry())
 	{
-		delete mImpl->mCacheMap.begin()->second ;
-		mImpl->mCacheMap.erase(mImpl->mCacheMap.begin());
-		result = CACHE_UPDATE_REPLACED;
-		
+		entry->setOctreeEntry(objectp->mDrawable->getEntry());
+	}
+	if(entry->getEntry() && entry->getEntry()->hasDrawable() && entry->isState(LLVOCacheEntry::INACTIVE))
+	{
+		addActiveCacheEntry(entry);
 	}
-	entry = new LLVOCacheEntry(local_id, crc, dp);
 
-	mImpl->mCacheMap[local_id] = entry;
 	return result;
 }
 
+LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id)
+{
+	static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
+
+	if(!vo_cache_culling_enabled)
+	{
+		return NULL;
+	}
+
+	LLVOCacheEntry* entry = getCacheEntry(local_id);
+	removeFromVOCacheTree(entry);
+
+	return entry;
+}
+
+LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id)
+{
+	LLVOCacheEntry::vocache_entry_map_t::iterator iter = mImpl->mCacheMap.find(local_id);
+	if(iter != mImpl->mCacheMap.end())
+	{
+		return iter->second;
+	}
+	return NULL;
+}
+
 // Get data packer for this object, if we have cached data
 // AND the CRC matches. JC
 LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc, U8 &cache_miss_type)
 {
 	//llassert(mCacheLoaded);  This assert failes often, changing to early-out -- davep, 2010/10/18
 
-	LLVOCacheEntry* entry = get_if_there(mImpl->mCacheMap, local_id, (LLVOCacheEntry*)NULL);
+	LLVOCacheEntry* entry = getCacheEntry(local_id);
 
 	if (entry)
 	{
@@ -1244,20 +1647,21 @@ LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc, U8 &cache_miss_type)
 		{
 			// Record a hit
 			entry->recordHit();
-		cache_miss_type = CACHE_MISS_TYPE_NONE;
+			cache_miss_type = CACHE_MISS_TYPE_NONE;
+
 			return entry->getDP(crc);
 		}
 		else
 		{
 			// llinfos << "CRC miss for " << local_id << llendl;
-		cache_miss_type = CACHE_MISS_TYPE_CRC;
+			cache_miss_type = CACHE_MISS_TYPE_CRC;
 			mCacheMissCRC.put(local_id);
 		}
 	}
 	else
 	{
 		// llinfos << "Cache miss for " << local_id << llendl;
-	cache_miss_type = CACHE_MISS_TYPE_FULL;
+		cache_miss_type = CACHE_MISS_TYPE_FULL;
 		mCacheMissFull.put(local_id);
 	}
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index c9fffaf30e..17654a8bc7 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -66,7 +66,8 @@ class LLDataPacker;
 class LLDataPackerBinaryBuffer;
 class LLHost;
 class LLBBox;
-
+class LLSpatialGroup;
+class LLDrawable;
 class LLViewerRegionImpl;
 
 class LLViewerRegion: public LLCapabilityProvider // implements this interface
@@ -85,6 +86,7 @@ public:
 		PARTITION_VOLUME,
 		PARTITION_BRIDGE,
 		PARTITION_HUD_PARTICLE,
+		PARTITION_VO_CACHE,
 		PARTITION_NONE,
 		NUM_PARTITIONS
 	} eObjectPartitions;
@@ -216,6 +218,12 @@ public:
 	F32	getWidth() const						{ return mWidth; }
 
 	BOOL idleUpdate(F32 max_update_time);
+	void addVisibleGroup(LLSpatialGroup* group);
+	void addVisibleCacheEntry(LLVOCacheEntry* entry);
+	void addActiveCacheEntry(LLVOCacheEntry* entry);
+	void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep);	
+	void killCacheEntry(U32 local_id); //physically delete the cache entry	
+	void clearVisibleGroup(LLSpatialGroup* group);
 
 	// Like idleUpdate, but forces everything to complete regardless of
 	// how long it takes.
@@ -305,7 +313,8 @@ public:
 	} eCacheUpdateResult;
 
 	// handle a full update message
-	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);
+	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);	
+	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
 	LLDataPacker *getDP(U32 local_id, U32 crc, U8 &cache_miss_type);
 	void requestCacheMisses();
 	void addCacheMissFull(const U32 local_id);
@@ -322,6 +331,7 @@ public:
     virtual std::string getDescription() const;
 	std::string getHttpUrl() const { return mHttpUrl ;}
 
+	U32 getNumOfActiveCachedObjects() const;
 	LLSpatialPartition* getSpatialPartition(U32 type);
 
 	bool objectIsReturnable(const LLVector3& pos, const std::vector<LLBBox>& boxes) const;
@@ -331,6 +341,15 @@ public:
 	void getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegions );
 	void getNeighboringRegionsStatus( std::vector<S32>& regions );
 	
+private:
+	void addToVOCacheTree(LLVOCacheEntry* entry);
+	LLViewerObject* addNewObject(LLVOCacheEntry* entry);
+	void killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list);
+	LLVOCacheEntry* getCacheEntry(U32 local_id);
+	void removeFromVOCacheTree(LLVOCacheEntry* entry);
+	void replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
+	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
+
 public:
 	struct CompareDistance
 	{
@@ -408,18 +427,17 @@ private:
 	// Maps local ids to cache entries.
 	// Regions can have order 10,000 objects, so assume
 	// a structure of size 2^14 = 16,000
-	BOOL									mCacheLoaded;
-	BOOL                                    mCacheDirty;
+	BOOL	mCacheLoaded;
+	BOOL    mCacheDirty;
+	BOOL	mAlive;					// can become false if circuit disconnects
+	BOOL	mCapabilitiesReceived;
+	BOOL    mReleaseNotesRequested;
+	BOOL    mDead;  //if true, this region is in the process of deleting.
 
 	LLDynamicArray<U32>						mCacheMissFull;
 	LLDynamicArray<U32>						mCacheMissCRC;
-
-	bool	mAlive;					// can become false if circuit disconnects
-	bool	mCapabilitiesReceived;
-	caps_received_signal_t mCapabilitiesReceivedSignal;
-
-	BOOL mReleaseNotesRequested;
 	
+	caps_received_signal_t mCapabilitiesReceivedSignal;		
 	LLSD mSimulatorFeatures;
 };
 
diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp
index 91e485d01b..2d5292b5f3 100644
--- a/indra/newview/llviewerstatsrecorder.cpp
+++ b/indra/newview/llviewerstatsrecorder.cpp
@@ -220,7 +220,7 @@ void LLViewerStatsRecorder::writeToLog( F32 interval )
 		}
 		else
 		{
-			llwarns << "Couldn't open " << STATS_FILE_NAME << " for logging." << llendl;
+			//llwarns << "Couldn't open " << STATS_FILE_NAME << " for logging." << llendl;
 			return;
 		}
 	}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index fd892db3d3..a11653b77d 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -808,8 +808,10 @@ U32  LLVOAvatarSelf::processUpdateMessage(LLMessageSystem *mesgsys,
 		updateMeshTextures();
 
 		// unpack the texture UUIDs to the texture slots
-		retval = unpackTEMessage(mesgsys, _PREHASH_ObjectData, block_num);
-
+		if(mesgsys != NULL)
+		{
+			retval = unpackTEMessage(mesgsys, _PREHASH_ObjectData, block_num);
+		}
 		// need to trigger a few operations to get the avatar to use the new bakes
 		for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
 		{
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 7db19c5c1b..17e0ef3bdb 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -29,6 +29,8 @@
 #include "llerror.h"
 #include "llregionhandle.h"
 #include "llviewercontrol.h"
+#include "llviewerobjectlist.h"
+#include "lldrawable.h"
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
@@ -46,12 +48,13 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes)
 //---------------------------------------------------------------------------
 
 LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp)
-	:
+	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY),
 	mLocalID(local_id),
 	mCRC(crc),
 	mHitCount(0),
 	mDupeCount(0),
-	mCRCChangeCount(0)
+	mCRCChangeCount(0),
+	mState(INACTIVE)
 {
 	mBuffer = new U8[dp.getBufferSize()];
 	mDP.assignBuffer(mBuffer, dp.getBufferSize());
@@ -59,19 +62,22 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 }
 
 LLVOCacheEntry::LLVOCacheEntry()
-	:
+	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY),
 	mLocalID(0),
 	mCRC(0),
 	mHitCount(0),
 	mDupeCount(0),
 	mCRCChangeCount(0),
-	mBuffer(NULL)
+	mBuffer(NULL),
+	mState(INACTIVE)
 {
 	mDP.assignBuffer(mBuffer, 0);
 }
 
 LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
-	: mBuffer(NULL)
+	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), 
+	mBuffer(NULL),
+	mState(INACTIVE)
 {
 	S32 size = -1;
 	BOOL success;
@@ -138,8 +144,57 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 LLVOCacheEntry::~LLVOCacheEntry()
 {
 	mDP.freeBuffer();
+	//llassert(mState == INACTIVE);
 }
 
+//virtual 
+void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
+{
+	if(!entry && mDP.getBufferSize() > 0)
+	{
+		LLUUID fullid;
+		mDP.reset();
+		mDP.unpackUUID(fullid, "ID");
+		mDP.reset();
+
+		LLViewerObject* obj = gObjectList.findObject(fullid);
+		if(obj && obj->mDrawable)
+		{
+			entry = obj->mDrawable->getEntry();
+		}
+	}
+
+	LLViewerOctreeEntryData::setOctreeEntry(entry);
+}
+
+//virtual 
+S32  LLVOCacheEntry::getMinVisFrameRange()const
+{
+	const S32 MIN_RANGE = 128; //frames
+
+	return MIN_RANGE;
+}
+
+void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
+{
+	llassert(entry != NULL);
+
+	mChildrenList.push_back(entry);
+}
+	
+LLVOCacheEntry* LLVOCacheEntry::getNextChild()
+{
+	S32 size = mChildrenList.size();
+	if(!size)
+	{
+		return NULL;
+	}
+
+	LLVOCacheEntry* entry = mChildrenList[size - 1];
+	mChildrenList.pop_back(); //remove the entry;
+
+	return entry;
+}
 
 // New CRC means the object has changed.
 void LLVOCacheEntry::assignCRC(U32 crc, LLDataPackerBinaryBuffer &dp)
@@ -170,6 +225,16 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc)
 	return &mDP;
 }
 
+LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP()
+{
+	if (mDP.getBufferSize() == 0)
+	{
+		//llinfos << "Not getting cache entry, invalid!" << llendl;
+		return NULL;
+	}
+	
+	return &mDP;
+}
 
 void LLVOCacheEntry::recordHit()
 {
@@ -625,11 +690,10 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 				{
 					for (S32 i = 0; i < num_entries; i++)
 					{
-						LLVOCacheEntry* entry = new LLVOCacheEntry(&apr_file);
+						LLPointer<LLVOCacheEntry> entry = new LLVOCacheEntry(&apr_file);
 						if (!entry->getLocalID())
 						{
 							llwarns << "Aborting cache file load for " << filename << ", cache file corruption!" << llendl;
-							delete entry ;
 							success = false ;
 							break ;
 						}
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 14e3b4c793..85538e8043 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -31,34 +31,57 @@
 #include "lldatapacker.h"
 #include "lldlinked.h"
 #include "lldir.h"
-
+#include "llvieweroctree.h"
 
 //---------------------------------------------------------------------------
 // Cache entries
 class LLVOCacheEntry;
 
-class LLVOCacheEntry
+class LLVOCacheEntry : public LLViewerOctreeEntryData
 {
+public:
+	enum
+	{
+		INACTIVE = 0,
+		WAITING,
+		ACTIVE
+	};
+
+protected:
+	~LLVOCacheEntry();
 public:
 	LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp);
 	LLVOCacheEntry(LLAPRFile* apr_file);
-	LLVOCacheEntry();
-	~LLVOCacheEntry();
+	LLVOCacheEntry();	
+
+	void setState(U32 state) {mState = state;}
+	bool isState(U32 state)  {return mState == state;}
+	U32  getState() const    {return mState;}
 
 	U32 getLocalID() const			{ return mLocalID; }
 	U32 getCRC() const				{ return mCRC; }
 	S32 getHitCount() const			{ return mHitCount; }
 	S32 getCRCChangeCount() const	{ return mCRCChangeCount; }
+	S32 getMinVisFrameRange()const;
 
 	void dump() const;
 	BOOL writeToFile(LLAPRFile* apr_file) const;
 	void assignCRC(U32 crc, LLDataPackerBinaryBuffer &dp);
 	LLDataPackerBinaryBuffer *getDP(U32 crc);
+	LLDataPackerBinaryBuffer *getDP();
 	void recordHit();
 	void recordDupe() { mDupeCount++; }
+	
+	/*virtual*/ void setOctreeEntry(LLViewerOctreeEntry* entry);
+
+	void addChild(LLVOCacheEntry* entry);
+	LLVOCacheEntry* getNextChild();
+	S32 getNumOfChildren() {return mChildrenList.size();}
+	bool isDummy() {return !mBuffer;}
 
 public:
-	typedef std::map<U32, LLVOCacheEntry*>	vocache_entry_map_t;
+	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	vocache_entry_map_t;
+	typedef std::set<LLVOCacheEntry*>                   vocache_entry_set_t;
 
 protected:
 	U32							mLocalID;
@@ -68,6 +91,9 @@ protected:
 	S32							mCRCChangeCount;
 	LLDataPackerBinaryBuffer	mDP;
 	U8							*mBuffer;
+
+	U32                         mState;
+	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 };
 
 //
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 4dca87652d..d378ed2577 100644
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -603,8 +603,8 @@ U32 LLVOGrass::getPartitionType() const
 	return LLViewerRegion::PARTITION_GRASS;
 }
 
-LLGrassPartition::LLGrassPartition()
-: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW_ARB)
+LLGrassPartition::LLGrassPartition(LLViewerRegion* regionp)
+: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW_ARB, regionp)
 {
 	mDrawableType = LLPipeline::RENDER_TYPE_GRASS;
 	mPartitionType = LLViewerRegion::PARTITION_GRASS;
@@ -624,9 +624,9 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
 	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
-		LLDrawable* drawablep = *i;
+		LLDrawable* drawablep = (LLDrawable*)(*i)->getDrawable();
 		
-		if (drawablep->isDead())
+		if (!drawablep || drawablep->isDead())
 		{
 			continue;
 		}
@@ -738,8 +738,10 @@ void LLGrassPartition::getGeometry(LLSpatialGroup* group)
 			LLDrawInfo* info = new LLDrawInfo(start,end,count,offset,facep->getTexture(), 
 				//facep->getTexture(),
 				buffer, fullbright); 
-			info->mExtents[0] = group->mObjectExtents[0];
-			info->mExtents[1] = group->mObjectExtents[1];
+
+			const LLVector4a* exts = group->getObjectExtents();
+			info->mExtents[0] = exts[0];
+			info->mExtents[1] = exts[1];
 			info->mVSize = vsize;
 			draw_vec.push_back(info);
 			//for alpha sorting
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index fa34a6f1f5..29c78f85f2 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -489,8 +489,8 @@ U32 LLVOPartGroup::getPartitionType() const
 	return LLViewerRegion::PARTITION_PARTICLE; 
 }
 
-LLParticlePartition::LLParticlePartition()
-: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW_ARB)
+LLParticlePartition::LLParticlePartition(LLViewerRegion* regionp)
+: LLSpatialPartition(LLDrawPoolAlpha::VERTEX_DATA_MASK | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, GL_STREAM_DRAW_ARB, regionp)
 {
 	mRenderPass = LLRenderPass::PASS_ALPHA;
 	mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES;
@@ -499,8 +499,8 @@ LLParticlePartition::LLParticlePartition()
 	mLODPeriod = 1;
 }
 
-LLHUDParticlePartition::LLHUDParticlePartition() :
-	LLParticlePartition()
+LLHUDParticlePartition::LLHUDParticlePartition(LLViewerRegion* regionp) :
+	LLParticlePartition(regionp)
 {
 	mDrawableType = LLPipeline::RENDER_TYPE_HUD_PARTICLES;
 	mPartitionType = LLViewerRegion::PARTITION_HUD_PARTICLE;
@@ -510,7 +510,7 @@ static LLFastTimer::DeclareTimer FTM_REBUILD_PARTICLE_VBO("Particle VBO");
 
 void LLParticlePartition::rebuildGeom(LLSpatialGroup* group)
 {
-	if (group->isDead() || !group->isState(LLSpatialGroup::GEOM_DIRTY))
+	if (group->isDead() || !group->hasState(LLSpatialGroup::GEOM_DIRTY))
 	{
 		return;
 	}
@@ -558,9 +558,9 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
 	LLViewerCamera* camera = LLViewerCamera::getInstance();
 	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
-		LLDrawable* drawablep = *i;
+		LLDrawable* drawablep = (LLDrawable*)(*i)->getDrawable();
 		
-		if (drawablep->isDead())
+		if (!drawablep || drawablep->isDead())
 		{
 			continue;
 		}
@@ -699,8 +699,10 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 			LLDrawInfo* info = new LLDrawInfo(start,end,count,offset,facep->getTexture(), 
 				//facep->getTexture(),
 				buffer, fullbright); 
-			info->mExtents[0] = group->mObjectExtents[0];
-			info->mExtents[1] = group->mObjectExtents[1];
+
+			const LLVector4a* exts = group->getObjectExtents();
+			info->mExtents[0] = exts[0];
+			info->mExtents[1] = exts[1];
 			info->mVSize = vsize;
 			draw_vec.push_back(info);
 			//for alpha sorting
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index cb905d02da..d5b3f2fd14 100644
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -1058,8 +1058,8 @@ U32 LLVOSurfacePatch::getPartitionType() const
 	return LLViewerRegion::PARTITION_TERRAIN; 
 }
 
-LLTerrainPartition::LLTerrainPartition()
-: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK, FALSE, GL_DYNAMIC_DRAW_ARB)
+LLTerrainPartition::LLTerrainPartition(LLViewerRegion* regionp)
+: LLSpatialPartition(LLDrawPoolTerrain::VERTEX_DATA_MASK, FALSE, GL_DYNAMIC_DRAW_ARB, regionp)
 {
 	mOcclusionEnabled = FALSE;
 	mInfiniteFarClip = TRUE;
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 6687ce432f..fe1ef10f7f 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -1290,8 +1290,8 @@ U32 LLVOTree::getPartitionType() const
 	return LLViewerRegion::PARTITION_TREE; 
 }
 
-LLTreePartition::LLTreePartition()
-: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB)
+LLTreePartition::LLTreePartition(LLViewerRegion* regionp)
+: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB, regionp)
 {
 	mDrawableType = LLPipeline::RENDER_TYPE_TREE;
 	mPartitionType = LLViewerRegion::PARTITION_TREE;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 813fa72cc3..51a3ace61b 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -3912,8 +3912,8 @@ U32 LLVOVolume::getPartitionType() const
 	return LLViewerRegion::PARTITION_VOLUME;
 }
 
-LLVolumePartition::LLVolumePartition()
-: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB)
+LLVolumePartition::LLVolumePartition(LLViewerRegion* regionp)
+: LLSpatialPartition(LLVOVolume::VERTEX_DATA_MASK, TRUE, GL_DYNAMIC_DRAW_ARB, regionp)
 {
 	mLODPeriod = 32;
 	mDepthMask = FALSE;
@@ -3923,8 +3923,8 @@ LLVolumePartition::LLVolumePartition()
 	mBufferUsage = GL_DYNAMIC_DRAW_ARB;
 }
 
-LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep)
-: LLSpatialBridge(drawablep, TRUE, LLVOVolume::VERTEX_DATA_MASK)
+LLVolumeBridge::LLVolumeBridge(LLDrawable* drawablep, LLViewerRegion* regionp)
+: LLSpatialBridge(drawablep, TRUE, LLVOVolume::VERTEX_DATA_MASK, regionp)
 {
 	mDepthMask = FALSE;
 	mLODPeriod = 32;
@@ -4146,9 +4146,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 	group->mLastUpdateViewAngle = group->mViewAngle;
 
-	if (!group->isState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::ALPHA_DIRTY))
+	if (!group->hasState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::ALPHA_DIRTY))
 	{
-		if (group->isState(LLSpatialGroup::MESH_DIRTY) && !LLPipeline::sDelayVBUpdate)
+		if (group->hasState(LLSpatialGroup::MESH_DIRTY) && !LLPipeline::sDelayVBUpdate)
 		{
 			rebuildMesh(group);
 		}
@@ -4186,7 +4186,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 	group->mSurfaceArea = 0;
 	
 	//cache object box size since it might be used for determining visibility
-	group->mObjectBoxSize = group->mObjectBounds[1].getLength3().getF32();
+	const LLVector4a* bounds = group->getObjectBounds();
+	group->mObjectBoxSize = bounds[1].getLength3().getF32();
 
 	group->clearDrawMap();
 
@@ -4213,9 +4214,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 		//get all the faces into a list
 		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 		{
-			LLDrawable* drawablep = *drawable_iter;
+			LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable();
 		
-			if (drawablep->isDead() || drawablep->isState(LLDrawable::FORCE_INVISIBLE) )
+			if (!drawablep || drawablep->isDead() || drawablep->isState(LLDrawable::FORCE_INVISIBLE) )
 			{
 				continue;
 			}
@@ -4619,8 +4620,11 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 		//drawables have been rebuilt, clear rebuild status
 		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 		{
-			LLDrawable* drawablep = *drawable_iter;
-			drawablep->clearState(LLDrawable::REBUILD_ALL);
+			LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable();
+			if(drawablep)
+			{
+				drawablep->clearState(LLDrawable::REBUILD_ALL);
+			}
 		}
 	}
 
@@ -4646,7 +4650,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 {
 	llassert(group);
-	if (group && group->isState(LLSpatialGroup::MESH_DIRTY) && !group->isState(LLSpatialGroup::GEOM_DIRTY))
+	if (group && group->hasState(LLSpatialGroup::MESH_DIRTY) && !group->hasState(LLSpatialGroup::GEOM_DIRTY))
 	{
 		LLFastTimer ftm(FTM_REBUILD_VOLUME_VB);
 		LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); //make sure getgeometryvolume shows up in the right place in timers
@@ -4659,9 +4663,9 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 
 		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 		{
-			LLDrawable* drawablep = *drawable_iter;
+			LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable();
 
-			if (!drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL) && !drawablep->isState(LLDrawable::RIGGED) )
+			if (drawablep && !drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL) && !drawablep->isState(LLDrawable::RIGGED) )
 			{
 				LLVOVolume* vobj = drawablep->getVOVolume();
 				vobj->preRebuild();
@@ -4727,7 +4731,11 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 			llwarns << "Not all mapped vertex buffers are unmapped!" << llendl ; 
 			for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 			{
-				LLDrawable* drawablep = *drawable_iter;
+				LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable();
+				if(!drawablep)
+				{
+					continue;
+				}
 				for (S32 i = 0; i < drawablep->getNumFaces(); ++i)
 				{
 					LLFace* face = drawablep->getFace(i);
@@ -5200,9 +5208,9 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun
 
 	for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 	{
-		LLDrawable* drawablep = *drawable_iter;
+		LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable();
 		
-		if (drawablep->isDead())
+		if (!drawablep || drawablep->isDead())
 		{
 			continue;
 		}
@@ -5240,7 +5248,7 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun
 	group->mBufferUsage = usage;
 }
 
-LLHUDPartition::LLHUDPartition()
+LLHUDPartition::LLHUDPartition(LLViewerRegion* regionp) : LLBridgePartition(regionp)
 {
 	mPartitionType = LLViewerRegion::PARTITION_HUD;
 	mDrawableType = LLPipeline::RENDER_TYPE_HUD;
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index e8a1c3d1d6..50e7ed7bb5 100644
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -298,15 +298,15 @@ U32 LLVOVoidWater::getPartitionType() const
 	return LLViewerRegion::PARTITION_VOIDWATER;
 }
 
-LLWaterPartition::LLWaterPartition()
-: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB)
+LLWaterPartition::LLWaterPartition(LLViewerRegion* regionp)
+: LLSpatialPartition(0, FALSE, GL_DYNAMIC_DRAW_ARB, regionp)
 {
 	mInfiniteFarClip = TRUE;
 	mDrawableType = LLPipeline::RENDER_TYPE_WATER;
 	mPartitionType = LLViewerRegion::PARTITION_WATER;
 }
 
-LLVoidWaterPartition::LLVoidWaterPartition()
+LLVoidWaterPartition::LLVoidWaterPartition(LLViewerRegion* regionp) : LLWaterPartition(regionp)
 {
 	mOcclusionEnabled = FALSE;
 	mDrawableType = LLPipeline::RENDER_TYPE_VOIDWATER;
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 9e495c46b1..0a622997f7 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -133,6 +133,9 @@ void LLWorld::destroyClass()
 	{
 		mEdgeWaterObjects[i] = NULL;
 	}
+
+	//make all visible drawbles invisible.
+	LLDrawable::incrementVisible();
 }
 
 
@@ -599,7 +602,8 @@ void LLWorld::updateVisibilities()
 		if (part)
 		{
 			LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0);
-			if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1]))
+			const LLVector4a* bounds = group->getBounds();
+			if (LLViewerCamera::getInstance()->AABBInFrustum(bounds[0], bounds[1]))
 			{
 				mCulledRegionList.erase(curiter);
 				mVisibleRegionList.push_back(regionp);
@@ -622,7 +626,8 @@ void LLWorld::updateVisibilities()
 		if (part)
 		{
 			LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0);
-			if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1]))
+			const LLVector4a* bounds = group->getBounds();
+			if (LLViewerCamera::getInstance()->AABBInFrustum(bounds[0], bounds[1]))
 			{
 				regionp->calculateCameraDistance();
 				regionp->getLand().updatePatchVisibilities(gAgent);
@@ -644,8 +649,8 @@ void LLWorld::updateVisibilities()
 void LLWorld::updateRegions(F32 max_update_time)
 {
 	LLTimer update_timer;
-	BOOL did_one = FALSE;
-	
+	BOOL did_one = FALSE;	
+
 	// Perform idle time updates for the regions (and associated surfaces)
 	for (region_list_t::iterator iter = mRegionList.begin();
 		 iter != mRegionList.end(); ++iter)
@@ -660,6 +665,13 @@ void LLWorld::updateRegions(F32 max_update_time)
 			did_one = TRUE;
 		}
 	}
+
+	mNumOfActiveCachedObjects = 0;
+	for (region_list_t::iterator iter = mRegionList.begin();
+		 iter != mRegionList.end(); ++iter)
+	{
+		mNumOfActiveCachedObjects += (*iter)->getNumOfActiveCachedObjects();
+	}
 }
 
 void LLWorld::updateParticles()
diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h
index f350009d10..8187142b2b 100644
--- a/indra/newview/llworld.h
+++ b/indra/newview/llworld.h
@@ -144,6 +144,7 @@ public:
 	U64 getSpaceTimeUSec() const;
 
 	void getInfo(LLSD& info);
+	U32  getNumOfActiveCachedObjects() const {return mNumOfActiveCachedObjects;}
 
 public:
 	typedef std::list<LLViewerRegion*> region_list_t;
@@ -181,7 +182,7 @@ private:
 	S32 mLastPacketsIn;
 	S32 mLastPacketsOut;
 	S32 mLastPacketsLost;
-
+	U32 mNumOfActiveCachedObjects;
 	U64 mSpaceTimeUSec;
 
 	BOOL mClassicCloudsEnabled;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4582de805f..e06577c512 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1378,18 +1378,18 @@ S32 LLPipeline::setLightingDetail(S32 level)
 	return mLightingDetail;
 }
 
-class LLOctreeDirtyTexture : public LLOctreeTraveler<LLDrawable>
+class LLOctreeDirtyTexture : public OctreeTraveler
 {
 public:
 	const std::set<LLViewerFetchedTexture*>& mTextures;
 
 	LLOctreeDirtyTexture(const std::set<LLViewerFetchedTexture*>& textures) : mTextures(textures) { }
 
-	virtual void visit(const LLOctreeNode<LLDrawable>* node)
+	virtual void visit(const OctreeNode* node)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
 
-		if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->isEmpty())
+		if (!group->hasState(LLSpatialGroup::GEOM_DIRTY) && !group->isEmpty())
 		{
 			for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
 			{
@@ -1578,11 +1578,9 @@ void LLPipeline::addPool(LLDrawPool *new_poolp)
 
 void LLPipeline::allocDrawable(LLViewerObject *vobj)
 {
-	LLDrawable *drawable = new LLDrawable();
+	LLDrawable *drawable = new LLDrawable(vobj);
 	vobj->mDrawable = drawable;
 	
-	drawable->mVObjp     = vobj;
-	
 	//encompass completely sheared objects by taking 
 	//the most extreme point possible (<1,1,0.5>)
 	drawable->setRadius(LLVector3(1,1,0.5f).scaleVec(vobj->getScale()).length());
@@ -2006,7 +2004,7 @@ void check_references(LLSpatialGroup* group, LLDrawable* drawable)
 {
 	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
-		if (drawable == *i)
+		if (drawable == (LLDrawable*)(*i)->getDrawable())
 		{
 			llerrs << "LLDrawable deleted while actively reference by LLPipeline." << llendl;
 		}
@@ -2028,8 +2026,11 @@ void check_references(LLSpatialGroup* group, LLFace* face)
 {
 	for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 	{
-		LLDrawable* drawable = *i;
-		check_references(drawable, face);
+		LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
+		if(drawable)
+		{
+			check_references(drawable, face);
+		}
 	}			
 }
 
@@ -2351,6 +2352,10 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 				{
 					part->cull(camera);
 				}
+				else if(part->mPartitionType == LLViewerRegion::PARTITION_VO_CACHE)
+				{
+					part->cull(camera);
+				}
 			}
 		}
 	}
@@ -2420,15 +2425,20 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
 		return;
 	}
 
+	const LLVector4a* bounds = group->getBounds();
 	if (sMinRenderSize > 0.f && 
-			llmax(llmax(group->mBounds[1][0], group->mBounds[1][1]), group->mBounds[1][2]) < sMinRenderSize)
+			llmax(llmax(bounds[1][0], bounds[1][1]), bounds[1][2]) < sMinRenderSize)
 	{
 		return;
 	}
 
 	assertInitialized();
 	
-	if (!group->mSpatialPartition->mRenderByGroup)
+	if(group->mSpatialPartition->mPartitionType == LLViewerRegion::PARTITION_VO_CACHE)
+	{
+		group->mSpatialPartition->mRegionp->addVisibleGroup(group);
+	}
+	else if (!group->mSpatialPartition->mRenderByGroup)
 	{ //render by drawable
 		sCull->pushDrawableGroup(group);
 	}
@@ -2980,14 +2990,14 @@ void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority)
 
 		if (priority)
 		{
-			if (!group->isState(LLSpatialGroup::IN_BUILD_Q1))
+			if (!group->hasState(LLSpatialGroup::IN_BUILD_Q1))
 			{
 				llassert_always(!mGroupQ1Locked);
 
 				mGroupQ1.push_back(group);
 				group->setState(LLSpatialGroup::IN_BUILD_Q1);
 
-				if (group->isState(LLSpatialGroup::IN_BUILD_Q2))
+				if (group->hasState(LLSpatialGroup::IN_BUILD_Q2))
 				{
 					LLSpatialGroup::sg_vector_t::iterator iter = std::find(mGroupQ2.begin(), mGroupQ2.end(), group);
 					if (iter != mGroupQ2.end())
@@ -2998,7 +3008,7 @@ void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority)
 				}
 			}
 		}
-		else if (!group->isState(LLSpatialGroup::IN_BUILD_Q2 | LLSpatialGroup::IN_BUILD_Q1))
+		else if (!group->hasState(LLSpatialGroup::IN_BUILD_Q2 | LLSpatialGroup::IN_BUILD_Q1))
 		{
 			llassert_always(!mGroupQ2Locked);
 			mGroupQ2.push_back(group);
@@ -3073,7 +3083,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 			group->setVisible();
 			for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 			{
-				markVisible(*i, camera);
+				markVisible((LLDrawable*)(*i)->getDrawable(), camera);
 			}
 
 			if (!sDelayVBUpdate)
@@ -3160,8 +3170,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
 	{
 		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 		{
-			LLDrawable* drawablep = *i;
-			stateSort(drawablep, camera);
+			stateSort((LLDrawable*)(*i)->getDrawable(), camera);
 		}
 
 		if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
@@ -3280,7 +3289,10 @@ void forAllDrawables(LLCullResult::sg_iterator begin,
 	{
 		for (LLSpatialGroup::element_iter j = (*i)->getDataBegin(); j != (*i)->getDataEnd(); ++j)
 		{
-			func(*j);	
+			if((*j)->hasDrawable())
+			{
+				func((LLDrawable*)(*j)->getDrawable());	
+			}
 		}
 	}
 }
@@ -3508,7 +3520,7 @@ void LLPipeline::postSort(LLCamera& camera)
 			continue;
 		}
 
-		if (group->isState(LLSpatialGroup::NEW_DRAWINFO) && group->isState(LLSpatialGroup::GEOM_DIRTY))
+		if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY))
 		{ //no way this group is going to be drawable without a rebuild
 			group->rebuildGeom();
 		}
-- 
cgit v1.2.3


From 9bc8028ab52ef5d56fa8a3915d927b5a050d8ead Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 16 Oct 2012 11:40:02 -0600
Subject: Some minor performance tuning-up for SH-3333.

---
 indra/newview/llviewerregion.cpp | 2 +-
 indra/newview/llvocache.cpp      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 15c95aa30a..0c0522d32f 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1066,7 +1066,7 @@ void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>&
 			if(child->mDrawable->isRecentlyVisible())
 			{
 				//set the parent group visible if any of its children visible.
-				drawablep->getSpatialGroup()->setVisible();
+				((LLViewerOctreeEntryData*)drawablep)->setVisible();
 				return;
 			}
 		}
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 17e0ef3bdb..236ce11c7e 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -170,7 +170,7 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
 //virtual 
 S32  LLVOCacheEntry::getMinVisFrameRange()const
 {
-	const S32 MIN_RANGE = 128; //frames
+	const S32 MIN_RANGE = 64; //frames
 
 	return MIN_RANGE;
 }
-- 
cgit v1.2.3


From e6ca5471a2a816a24888ae1b38332531b22b7254 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 17 Oct 2012 00:06:22 -0700
Subject: SH-3275  Update viewer metrics system to be more flexible put
 template parameter back in LLUnit units added free function operators for
 mathematical manipulation of unit values converted texture memory tracking to
 units

---
 indra/newview/lltexturefetch.cpp      |  2 +-
 indra/newview/lltextureview.cpp       | 20 ++++++++--------
 indra/newview/llviewerobject.cpp      |  2 +-
 indra/newview/llviewerstats.cpp       | 28 +++++++++++------------
 indra/newview/llviewerstats.h         | 12 +++++-----
 indra/newview/llviewertexture.cpp     | 43 +++++++++++++++++++----------------
 indra/newview/llviewertexture.h       | 15 ++++++------
 indra/newview/llviewertexturelist.cpp | 20 ++++++++--------
 indra/newview/llviewerwindow.cpp      |  2 +-
 indra/newview/llvoavatarself.cpp      |  2 +-
 indra/newview/llworld.cpp             |  6 ++---
 11 files changed, 79 insertions(+), 73 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index f2caa01644..8ddaac5cc8 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2316,7 +2316,7 @@ S32 LLTextureFetch::update(F32 max_time_ms)
 
 	if(mCurlGetRequest)
 	{
-		LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bits>(mCurlGetRequest->getTotalReceivedBits());
+		LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bits>(mCurlGetRequest->getTotalReceivedBits());
 		//gTextureList.sTextureBits += mCurlGetRequest->getTotalReceivedBits();
 	}
 
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index c60b4155a0..a88233e120 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -503,13 +503,13 @@ private:
 
 void LLGLTexMemBar::draw()
 {
-	S32 bound_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sBoundTextureMemoryInBytes);
- 	S32 max_bound_mem = LLViewerTexture::sMaxBoundTextureMemInMegaBytes;
-	S32 total_mem = BYTES_TO_MEGA_BYTES(LLViewerTexture::sTotalTextureMemoryInBytes);
-	S32 max_total_mem = LLViewerTexture::sMaxTotalTextureMemInMegaBytes;
+	LLUnit::Megabytes<S32> bound_mem = LLViewerTexture::sBoundTextureMemory;
+ 	LLUnit::Megabytes<S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
+	LLUnit::Megabytes<S32> total_mem = LLViewerTexture::sTotalTextureMemory;
+	LLUnit::Megabytes<S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;
-	F32 cache_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getUsage()) ;
-	F32 cache_max_usage = (F32)BYTES_TO_MEGA_BYTES(LLAppViewer::getTextureCache()->getMaxUsage()) ;
+	F32 cache_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
+	F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
 	F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024);
@@ -526,10 +526,10 @@ void LLGLTexMemBar::draw()
 											 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 
 	text = llformat("GL Tot: %d/%d MB Bound: %d/%d MB FBO: %d MB Raw Tot: %d MB Bias: %.2f Cache: %.1f/%.1f MB",
-					total_mem,
-					max_total_mem,
-					bound_mem,
-					max_bound_mem,
+					total_mem.value(),
+					max_total_mem.value(),
+					bound_mem.value(),
+					max_bound_mem.value(),
 					LLRenderTarget::sBytesAllocated/(1024*1024),
 					LLImageRaw::sGlobalRawMemory >> 20,	discard_bias,
 					cache_usage, cache_max_usage);
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 989a1c4e5a..747dfd3250 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2033,7 +2033,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		// If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps
 		if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
 		{
-			LLStatViewer::AGENT_POSITION_SNAP.sample<LLUnits::Meters>(diff.length());
+			LLStatViewer::AGENT_POSITION_SNAP.sample<LLTrace::Meters>(diff.length());
 			//LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() );
 		}
 	}
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index f0ad04e0ba..ccc0c9ba59 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -89,7 +89,7 @@ LLTrace::Count<>	FPS("fpsstat"),
 					FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"),
 					TEX_BAKES("texbakes"),
 					TEX_REBAKES("texrebakes");
-LLTrace::Count<LLUnits::Kilobits>	KBIT("kbitstat"),
+LLTrace::Count<LLTrace::Kilobits>	KBIT("kbitstat"),
 									LAYERS_KBIT("layerskbitstat"),
 									OBJECT_KBIT("objectkbitstat"),
 									ASSET_KBIT("assetkbitstat"),
@@ -97,7 +97,7 @@ LLTrace::Count<LLUnits::Kilobits>	KBIT("kbitstat"),
 									ACTUAL_IN_KBIT("actualinkbit"),
 									ACTUAL_OUT_KBIT("actualoutkbit");
 
-LLTrace::Count<LLUnits::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
+LLTrace::Count<LLTrace::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
 								TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
 								MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
 								FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
@@ -146,10 +146,10 @@ LLTrace::Measurement<>		NUM_IMAGES("numimagesstat"),
 							WINDOW_WIDTH("windowwidth", "Window width"),
 							WINDOW_HEIGHT("windowheight", "Window height");
 
-LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
+LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
 
 
-LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes"),
+LLTrace::Measurement<LLTrace::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes"),
 										SIM_PHYSICS_MEM("physicsmemoryallocated"),
 										GL_TEX_MEM("gltexmemstat"),
 										GL_BOUND_MEM("glboundmemstat"),
@@ -159,7 +159,7 @@ LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes"),
 										MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
 
 
-SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
+SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
 										SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS),
 										SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS),
 										SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS),
@@ -174,7 +174,7 @@ SimMeasurement<LLUnits::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_
 										SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
 										SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
 
-LLTrace::Measurement<LLUnits::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+LLTrace::Measurement<LLTrace::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
 											FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
 											LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
 											REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
@@ -266,10 +266,10 @@ void LLViewerStats::updateFrameStats(const F64 time_diff)
 
 		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
 		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
-		LLStatViewer::DELTA_BANDWIDTH.sample<LLUnits::Bits>(delta_bandwidth);
+		LLStatViewer::DELTA_BANDWIDTH.sample<LLTrace::Bits>(delta_bandwidth);
 		//setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);
 
-		LLStatViewer::MAX_BANDWIDTH.sample<LLUnits::Bits>(max_bandwidth);
+		LLStatViewer::MAX_BANDWIDTH.sample<LLTrace::Bits>(max_bandwidth);
 		//setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
 		
 	}
@@ -360,27 +360,27 @@ void update_statistics()
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
-		LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(cdp->getPingDelay());
+		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(cdp->getPingDelay());
 		//stats.mSimPingStat.addValue(cdp->getPingDelay());
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
-		LLStatViewer::SIM_PING.sample<LLUnits::Seconds>(10000);
+		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10000);
 		//stats.mSimPingStat.addValue(10000);
 	}
 
 	//stats.mFPSStat.addValue(1);
 	LLStatViewer::FPS.add(1);
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	LLStatViewer::LAYERS_KBIT.add<LLUnits::Bits>(layer_bits);
+	LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits);
 	//stats.mLayersKBitStat.addValue(layer_bits/1024.f);
-	LLStatViewer::OBJECT_KBIT.add<LLUnits::Bits>(gObjectBits);
+	LLStatViewer::OBJECT_KBIT.add<LLTrace::Bits>(gObjectBits);
 	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
 	//stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
 	LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending());
-	LLStatViewer::ASSET_KBIT.add<LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
+	LLStatViewer::ASSET_KBIT.add<LLTrace::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
 	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
@@ -419,7 +419,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			gTotalTextureBytes = LLUnits::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value();
+			gTotalTextureBytes = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value();
 			texture_stats_timer.reset();
 		}
 	}
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 40109bcea3..b182a40403 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -88,7 +88,7 @@ extern LLTrace::Count<>						FPS,
 											TEX_REBAKES;
 
 
-extern LLTrace::Count<LLUnits::Kilobits>	KBIT,
+extern LLTrace::Count<LLTrace::Kilobits>	KBIT,
 											LAYERS_KBIT,
 											OBJECT_KBIT,
 											ASSET_KBIT,
@@ -96,7 +96,7 @@ extern LLTrace::Count<LLUnits::Kilobits>	KBIT,
 											ACTUAL_IN_KBIT,
 											ACTUAL_OUT_KBIT;
 
-extern LLTrace::Count<LLUnits::Seconds>		AVATAR_EDIT_TIME,
+extern LLTrace::Count<LLTrace::Seconds>		AVATAR_EDIT_TIME,
 											TOOLBOX_TIME,
 											MOUSELOOK_TIME,
 											FPS_10_TIME,
@@ -145,9 +145,9 @@ extern LLTrace::Measurement<>				NUM_IMAGES,
 											WINDOW_WIDTH,
 											WINDOW_HEIGHT;
 
-extern LLTrace::Measurement<LLUnits::Meters> AGENT_POSITION_SNAP;
+extern LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP;
 
-extern LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES,
+extern LLTrace::Measurement<LLTrace::Bytes>	SIM_UNACKED_BYTES,
 											DELTA_BANDWIDTH,
 											MAX_BANDWIDTH,
 											SIM_PHYSICS_MEM,
@@ -156,7 +156,7 @@ extern LLTrace::Measurement<LLUnits::Bytes>	SIM_UNACKED_BYTES,
 											RAW_MEM,
 											FORMATTED_MEM;
 
-extern SimMeasurement<LLUnits::Milliseconds>	SIM_FRAME_TIME,
+extern SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME,
 												SIM_NET_TIME,
 												SIM_OTHER_TIME,
 												SIM_PHYSICS_TIME,
@@ -172,7 +172,7 @@ extern SimMeasurement<LLUnits::Milliseconds>	SIM_FRAME_TIME,
 												SIM_PUMP_IO_TIME;
 
 
-extern LLTrace::Measurement<LLUnits::Milliseconds>	FRAMETIME_JITTER,
+extern LLTrace::Measurement<LLTrace::Milliseconds>	FRAMETIME_JITTER,
 													FRAMETIME_SLEW,
 													LOGIN_SECONDS,
 													REGION_CROSSING_TIME,
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index b0f8f60d1e..f64134b8b7 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -64,6 +64,11 @@
 #include "lltexturecache.h"
 ///////////////////////////////////////////////////////////////////////////////
 
+// extern
+const LLUnit::Megabytes<S32> gMinVideoRam = 32;
+const LLUnit::Megabytes<S32> gMaxVideoRam = 512;
+
+
 // statics
 LLPointer<LLViewerTexture>        LLViewerTexture::sNullImagep = NULL;
 LLPointer<LLViewerTexture>        LLViewerTexture::sBlackImagep = NULL;
@@ -82,11 +87,11 @@ S32 LLViewerTexture::sAuxCount = 0;
 LLFrameTimer LLViewerTexture::sEvaluationTimer;
 F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
 F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
-S32 LLViewerTexture::sBoundTextureMemoryInBytes = 0;
-S32 LLViewerTexture::sTotalTextureMemoryInBytes = 0;
-S32 LLViewerTexture::sMaxBoundTextureMemInMegaBytes = 0;
-S32 LLViewerTexture::sMaxTotalTextureMemInMegaBytes = 0;
-S32 LLViewerTexture::sMaxDesiredTextureMemInBytes = 0 ;
+LLUnit::Bytes<S32> LLViewerTexture::sBoundTextureMemory = 0;
+LLUnit::Bytes<S32> LLViewerTexture::sTotalTextureMemory = 0;
+LLUnit::Megabytes<S32> LLViewerTexture::sMaxBoundTextureMem = 0;
+LLUnit::Megabytes<S32> LLViewerTexture::sMaxTotalTextureMem = 0;
+LLUnit::Bytes<S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
 S8  LLViewerTexture::sCameraMovingDiscardBias = 0 ;
 F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
 S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
@@ -518,17 +523,17 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		LLViewerMediaTexture::updateClass() ;
 	}
 
-	sBoundTextureMemoryInBytes = LLImageGL::sBoundTextureMemoryInBytes;//in bytes
-	sTotalTextureMemoryInBytes = LLImageGL::sGlobalTextureMemoryInBytes;//in bytes
-	sMaxBoundTextureMemInMegaBytes = gTextureList.getMaxResidentTexMem();//in MB	
-	sMaxTotalTextureMemInMegaBytes = gTextureList.getMaxTotalTextureMem() ;//in MB
-	sMaxDesiredTextureMemInBytes = MEGA_BYTES_TO_BYTES(sMaxTotalTextureMemInMegaBytes) ; //in Bytes, by default and when total used texture memory is small.
+	sBoundTextureMemory = LLImageGL::sBoundTextureMemory;//in bytes
+	sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;//in bytes
+	sMaxBoundTextureMem = gTextureList.getMaxResidentTexMem();//in MB	
+	sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem() ;//in MB
+	sMaxDesiredTextureMem = sMaxTotalTextureMem ; //in Bytes, by default and when total used texture memory is small.
 
-	if (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) >= sMaxBoundTextureMemInMegaBytes ||
-		BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) >= sMaxTotalTextureMemInMegaBytes)
+	if (sBoundTextureMemory >= sMaxBoundTextureMem ||
+		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{
 		//when texture memory overflows, lower down the threashold to release the textures more aggressively.
-		sMaxDesiredTextureMemInBytes = llmin((S32)(sMaxDesiredTextureMemInBytes * 0.75f) , MEGA_BYTES_TO_BYTES(MAX_VIDEO_RAM_IN_MEGA_BYTES)) ;//512 MB
+		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, (LLUnit::Bytes<S32>)gMaxVideoRam) ;//512 MB
 	
 		// If we are using more texture memory than we should,
 		// scale up the desired discard level
@@ -544,8 +549,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sEvaluationTimer.reset();
 	}
 	else if (sDesiredDiscardBias > 0.0f &&
-			 BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < sMaxBoundTextureMemInMegaBytes * texmem_lower_bound_scale &&
-			 BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < sMaxTotalTextureMemInMegaBytes * texmem_lower_bound_scale)
+			 sBoundTextureMemory < sMaxBoundTextureMem * texmem_lower_bound_scale &&
+			 sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale)
 	{			 
 		// If we are using less texture memory than we should,
 		// scale down the desired discard level
@@ -563,8 +568,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 	sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1);
 	sCameraMovingDiscardBias = (S8)(sCameraMovingBias);
 
-	LLViewerTexture::sFreezeImageScalingDown = (BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) < 0.75f * sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale) &&
-				(BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) < 0.75f * sMaxTotalTextureMemInMegaBytes * texmem_middle_bound_scale) ;
+	LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < 0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale) &&
+				(sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale) ;
 }
 
 //end of static functions
@@ -3301,13 +3306,13 @@ void LLViewerLODTexture::processTextureStats()
 				scaleDown() ;
 			}
 			// Limit the amount of GL memory bound each frame
-			else if ( BYTES_TO_MEGA_BYTES(sBoundTextureMemoryInBytes) > sMaxBoundTextureMemInMegaBytes * texmem_middle_bound_scale &&
+			else if ( sBoundTextureMemory > sMaxBoundTextureMem * texmem_middle_bound_scale &&
 				(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel))
 			{
 				scaleDown() ;
 			}
 			// Only allow GL to have 2x the video card memory
-			else if ( BYTES_TO_MEGA_BYTES(sTotalTextureMemoryInBytes) > sMaxTotalTextureMemInMegaBytes*texmem_middle_bound_scale &&
+			else if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale &&
 				(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel))
 			{
 				scaleDown() ;
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 2ea9a07e9a..aa1e2010b4 100755
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -34,12 +34,13 @@
 #include "llgltypes.h"
 #include "llrender.h"
 #include "llmetricperformancetester.h"
+#include "llunit.h"
 
 #include <map>
 #include <list>
 
-#define MIN_VIDEO_RAM_IN_MEGA_BYTES    32
-#define MAX_VIDEO_RAM_IN_MEGA_BYTES    512 // 512MB max for performance reasons.
+extern const LLUnit::Megabytes<S32> gMinVideoRam;
+extern const LLUnit::Megabytes<S32> gMaxVideoRam;
 
 class LLFace;
 class LLImageGL ;
@@ -322,11 +323,11 @@ public:
 	static LLFrameTimer sEvaluationTimer;
 	static F32 sDesiredDiscardBias;
 	static F32 sDesiredDiscardScale;
-	static S32 sBoundTextureMemoryInBytes;
-	static S32 sTotalTextureMemoryInBytes;
-	static S32 sMaxBoundTextureMemInMegaBytes;
-	static S32 sMaxTotalTextureMemInMegaBytes;
-	static S32 sMaxDesiredTextureMemInBytes ;
+	static LLUnit::Bytes<S32> sBoundTextureMemory;
+	static LLUnit::Bytes<S32> sTotalTextureMemory;
+	static LLUnit::Megabytes<S32> sMaxBoundTextureMem;
+	static LLUnit::Megabytes<S32> sMaxTotalTextureMem;
+	static LLUnit::Bytes<S32> sMaxDesiredTextureMem ;
 	static S8  sCameraMovingDiscardBias;
 	static F32 sCameraMovingBias;
 	static S32 sMaxSculptRez ;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 56ccf3b1f0..d355432e8a 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -606,8 +606,8 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	if(gTeleportDisplay)
 	{
 		if(!cleared)
-	{
-		clearFetchingRequests();
+		{
+			clearFetchingRequests();
 			gPipeline.clearRebuildGroups();
 			cleared = TRUE;
 		}
@@ -623,10 +623,10 @@ void LLViewerTextureList::updateImages(F32 max_time)
 		using namespace LLStatViewer;
 		NUM_IMAGES.sample(sNumImages);
 		NUM_RAW_IMAGES.sample(LLImageRaw::sRawImageCount);
-		GL_TEX_MEM.sample<LLUnits::Bytes>(LLImageGL::sGlobalTextureMemoryInBytes);
-		GL_BOUND_MEM.sample<LLUnits::Bytes>(LLImageGL::sBoundTextureMemoryInBytes);
-		RAW_MEM.sample<LLUnits::Bytes>(LLImageRaw::sGlobalRawMemory);
-		FORMATTED_MEM.sample<LLUnits::Bytes>(LLImageFormatted::sGlobalFormattedMemory);
+		GL_TEX_MEM.sample(LLImageGL::sGlobalTextureMemory);
+		GL_BOUND_MEM.sample(LLImageGL::sBoundTextureMemory);
+		RAW_MEM.sample<LLTrace::Bytes>(LLImageRaw::sGlobalRawMemory);
+		FORMATTED_MEM.sample<LLTrace::Bytes>(LLImageFormatted::sGlobalFormattedMemory);
 	}
 
 	{
@@ -1184,7 +1184,7 @@ S32 LLViewerTextureList::getMinVideoRamSetting()
 {
 	S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped());
 	//min texture mem sets to 64M if total physical mem is more than 1.5GB
-	return (system_ram > 1500) ? 64 : MIN_VIDEO_RAM_IN_MEGA_BYTES ;
+	return (system_ram > 1500) ? 64 : gMinVideoRam.value() ;
 }
 
 //static
@@ -1234,7 +1234,7 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
 	else
 		max_texmem = llmin(max_texmem, (S32)(system_ram));
 		
-	max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), MAX_VIDEO_RAM_IN_MEGA_BYTES); 
+	max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), gMaxVideoRam.value()); 
 	
 	return max_texmem;
 }
@@ -1322,7 +1322,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size);
+	LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bytes>(received_size);
 	LLStatViewer::TEXTURE_PACKETS.add(1);
 	
 	U8 codec;
@@ -1396,7 +1396,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 		received_size = msg->getReceiveSize() ;		
 	}
 
-	LLStatViewer::TEXTURE_KBIT.add<LLUnits::Bytes>(received_size);
+	LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bytes>(received_size);
 	LLStatViewer::TEXTURE_PACKETS.add(1);
 	
 	//llprintline("Start decode, image header...");
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 8161caf5e4..2062f07650 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -4740,7 +4740,7 @@ void LLViewerWindow::stopGL(BOOL save_state)
 		gGLManager.mIsDisabled = TRUE;
 		stop_glerror();
 		
-		llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemoryInBytes << " bytes" << llendl;
+		llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemory.value() << " bytes" << llendl;
 	}
 }
 
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 3e8b07b6dc..9f0921ff59 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2790,7 +2790,7 @@ void LLVOAvatarSelf::deleteScratchTextures()
 
 		sScratchTexNames.deleteAllData();
 		sScratchTexLastBindTime.deleteAllData();
-		LLImageGL::sGlobalTextureMemoryInBytes -= sScratchTexBytes;
+		LLImageGL::sGlobalTextureMemory -= sScratchTexBytes;
 		sScratchTexBytes = 0;
 	}
 }
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 604741ff27..dced5a847b 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -703,11 +703,11 @@ void LLWorld::updateNetStats()
 	S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 
-	LLStatViewer::ACTUAL_IN_KBIT.add<LLUnits::Bits>(actual_in_bits);
-	LLStatViewer::ACTUAL_OUT_KBIT.add<LLUnits::Bits>(actual_out_bits);
+	LLStatViewer::ACTUAL_IN_KBIT.add<LLTrace::Bits>(actual_in_bits);
+	LLStatViewer::ACTUAL_OUT_KBIT.add<LLTrace::Bits>(actual_out_bits);
 	//LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
 	//LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
-	LLStatViewer::KBIT.add<LLUnits::Bits>(bits);
+	LLStatViewer::KBIT.add<LLTrace::Bits>(bits);
 	//LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
 	LLStatViewer::PACKETS_IN.add(packets_in);
 	LLStatViewer::PACKETS_OUT.add(packets_out);
-- 
cgit v1.2.3


From a52d203a4f1d2988e8ffba16258f3f132f22f56d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 17 Oct 2012 20:00:07 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system started
 conversion of llviewerassetstats removed old, dead LLViewerStats code made
 units tracing require units declaration clean up of units handling

---
 indra/newview/llagent.cpp                       |   2 -
 indra/newview/llappviewer.cpp                   |   5 +-
 indra/newview/llappviewer.h                     |   3 +-
 indra/newview/llcompilequeue.cpp                |   2 -
 indra/newview/llfloaterjoystick.cpp             |   2 +-
 indra/newview/llfloaterregioninfo.cpp           |   2 -
 indra/newview/llfloatersnapshot.cpp             |   1 -
 indra/newview/llgesturemgr.cpp                  |   2 -
 indra/newview/lllandmarklist.cpp                |   1 -
 indra/newview/llnearbychatbar.cpp               |   1 -
 indra/newview/llpanelface.cpp                   |   1 -
 indra/newview/llpanelpermissions.cpp            |   1 -
 indra/newview/llpreviewgesture.cpp              |   2 -
 indra/newview/llpreviewnotecard.cpp             |   2 -
 indra/newview/llpreviewscript.cpp               |   6 -
 indra/newview/llselectmgr.cpp                   |   1 -
 indra/newview/llsidepaneltaskinfo.cpp           |   1 -
 indra/newview/llspatialpartition.cpp            |   4 +-
 indra/newview/llstartup.cpp                     |   1 -
 indra/newview/lltexlayer.cpp                    |   1 -
 indra/newview/lltextureview.cpp                 |   6 +-
 indra/newview/lltooldraganddrop.cpp             |   3 -
 indra/newview/lltoolplacer.cpp                  |   1 -
 indra/newview/llviewerassetstats.cpp            |  27 +++++
 indra/newview/llviewerassetstats.h              |   7 ++
 indra/newview/llviewerdisplay.cpp               |   4 +-
 indra/newview/llviewerjoystick.cpp              |   6 +-
 indra/newview/llviewermenufile.cpp              |   9 --
 indra/newview/llviewermessage.cpp               | 155 ++----------------------
 indra/newview/llviewerobject.cpp                |   1 -
 indra/newview/llviewerobjectlist.cpp            |   4 -
 indra/newview/llviewerstats.cpp                 |  95 +++++----------
 indra/newview/llviewerstats.h                   |   8 +-
 indra/newview/llviewertexturelist.cpp           |   6 +-
 indra/newview/llviewerwindow.cpp                |  12 +-
 indra/newview/llvoavatar.cpp                    |   4 +-
 indra/newview/llvoavatarself.cpp                |  13 +-
 indra/newview/llwearablelist.cpp                |   1 -
 indra/newview/pipeline.cpp                      |  16 +--
 indra/newview/tests/llviewerassetstats_test.cpp |  13 +-
 40 files changed, 123 insertions(+), 309 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index a41efbe0b2..ac33f09718 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -754,7 +754,6 @@ void LLAgent::setFlying(BOOL fly)
 		if( !was_flying )
 		{
 			LLStatViewer::FLY.add(1);
-			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_FLY_COUNT);
 		}
 		setControlFlags(AGENT_CONTROL_FLY);
 	}
@@ -3811,7 +3810,6 @@ bool LLAgent::teleportCore(bool is_local)
 
 	// local logic
 	LLStatViewer::TELEPORT.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TELEPORT_COUNT);
 	if (is_local)
 	{
 		gAgent.setTeleportState( LLAgent::TELEPORT_LOCAL );
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6e0b298b2a..4ab0e3336a 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -277,7 +277,7 @@ LLPumpIO* gServicePump = NULL;
 
 U64 gFrameTime = 0;
 F32 gFrameTimeSeconds = 0.f;
-F32 gFrameIntervalSeconds = 0.f;
+LLUnit::Seconds<F32> gFrameIntervalSeconds = 0.f;
 F32 gFPSClamped = 10.f;						// Pretend we start at target rate.
 F32 gFrameDTClamped = 0.f;					// Time between adjacent checks to network for packets
 U64	gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
@@ -1395,7 +1395,7 @@ bool LLAppViewer::mainLoop()
 				{
 					S32 work_pending = 0;
 					S32 io_pending = 0;
-					F32 max_time = llmin(gFrameIntervalSeconds*10.f, 1.f);
+					F32 max_time = llmin(gFrameIntervalSeconds.value() *10.f, 1.f);
 
 					{
 						LLFastTimer ftm(FTM_TEXTURE_CACHE);
@@ -4811,7 +4811,6 @@ void LLAppViewer::idleNetwork()
 		}
 	}
 	LLStatViewer::NUM_NEW_OBJECTS.sample(gObjectList.mNumNewObjects);
-	//LLViewerStats::getInstance()->mNumNewObjectsStat.addValue(gObjectList.mNumNewObjects);
 
 	// Retransmit unacknowledged packets.
 	gXferManager->retransmitUnackedPackets();
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index cdf4426469..d9d888c626 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -31,6 +31,7 @@
 #include "llcontrol.h"
 #include "llsys.h"			// for LLOSInfo
 #include "lltimer.h"
+#include "llunit.h"
 
 class LLCommandLineParser;
 class LLFrameTimer;
@@ -321,7 +322,7 @@ extern LLPumpIO* gServicePump;
 
 extern U64      gFrameTime;					// The timestamp of the most-recently-processed frame
 extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
-extern F32		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
+extern LLUnit::Seconds<F32>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
 extern F32		gFPSClamped;				// Frames per second, smoothed, weighted toward last frame
 extern F32		gFrameDTClamped;
 extern U64		gStartTime;
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 6739910c38..033c8f4865 100644
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -436,8 +436,6 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 	}
 	else
 	{
-		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
 		{
 			LLSD args;
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index d0c22d25f2..f7b2670b8e 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -61,7 +61,7 @@ void LLFloaterJoystick::draw()
 	for (U32 i = 0; i < 6; i++)
 	{
 		F32 value = joystick->getJoystickAxis(i);
-		mAxisStats[i]->addValue(value * gFrameIntervalSeconds);
+		mAxisStats[i]->addValue(value * gFrameIntervalSeconds.value());
 		if (mAxisStatsBar[i])
 		{
 			F32 minbar, maxbar;
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 8234841966..6cce013105 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -2491,8 +2491,6 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 		}
 		else
 		{
-			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
 			{
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 4a58e0186c..0d90037e7b 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -993,7 +993,6 @@ void LLSnapshotLivePreview::saveTexture()
 	}
 
 	LLStatViewer::SNAPSHOT.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_SNAPSHOT_COUNT );
 	
 	mDataSize = 0;
 }
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 63ef8c3d21..27a29d3ace 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -1137,8 +1137,6 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs,
 	}
 	else
 	{
-		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 			LL_ERR_FILE_EMPTY == status)
 		{
diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp
index 1666425cbe..2a131eff58 100644
--- a/indra/newview/lllandmarklist.cpp
+++ b/indra/newview/lllandmarklist.cpp
@@ -141,7 +141,6 @@ void LLLandmarkList::processGetAssetReply(
 	}
 	else
 	{
-		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 		// SJB: No use case for a notification here. Use lldebugs instead
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
 		{
diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index 0aced5c575..23cbfae044 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -639,7 +639,6 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32
 	gAgent.sendReliableMessage();
 
 	LLStatViewer::CHAT_COUNT.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CHAT_COUNT);
 }
 
 class LLChatCommandHandler : public LLCommandHandler
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 52ed24f06d..39ded21183 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -1050,7 +1050,6 @@ BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item)
 void LLPanelFace::onCommitTexture( const LLSD& data )
 {
 	LLStatViewer::EDIT_TEXTURE.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 	sendTexture();
 }
 
diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp
index 51ab7649a4..8027783bd8 100644
--- a/indra/newview/llpanelpermissions.cpp
+++ b/indra/newview/llpanelpermissions.cpp
@@ -915,7 +915,6 @@ bool callback_deed_to_group(const LLSD& notification, const LLSD& response)
 		if(group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
 		{
 			LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
-//			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
 		}
 	}
 	return false;
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index 4082d272f2..cbb4d5f964 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -883,8 +883,6 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs,
 		}
 		else
 		{
-			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
 			{
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index b93b97f1e0..97c9de4b72 100644
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -339,8 +339,6 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 		}
 		else
 		{
-			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
 			{
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 059d5d4061..7607df5a55 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -943,7 +943,6 @@ void LLScriptEdCore::onBtnInsertFunction(LLUICtrl *ui, void* userdata)
 void LLScriptEdCore::doSave( BOOL close_after_save )
 {
 	LLStatViewer::LSL_SAVES.add(1);
-	//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
 
 	if( mSaveCallback )
 	{
@@ -1148,7 +1147,6 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data )
 void LLScriptEdCore::onBtnSaveToFile( void* userdata )
 {
 	LLStatViewer::LSL_SAVES.add(1);
-	//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_LSL_SAVE_COUNT );
 
 	LLScriptEdCore* self = (LLScriptEdCore*) userdata;
 
@@ -1671,8 +1669,6 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset
 		}
 		else
 		{
-			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
 			{
@@ -1903,8 +1899,6 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
 		}
 		else
 		{
-			//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-
 			if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 				LL_ERR_FILE_EMPTY == status)
 			{
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index fd03d7c0be..36ce7bb60e 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1551,7 +1551,6 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item)
 
 				// apply texture for the selected faces
 				LLStatViewer::EDIT_TEXTURE.add(1);
-				//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 				object->setTEImage(te, image);
 				dialog_refresh_all();
 
diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp
index c351b1a128..8fb56eb6d8 100644
--- a/indra/newview/llsidepaneltaskinfo.cpp
+++ b/indra/newview/llsidepaneltaskinfo.cpp
@@ -945,7 +945,6 @@ static bool callback_deed_to_group(const LLSD& notification, const LLSD& respons
 		if (group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
 		{
 			LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
-//			LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
 		}
 	}
 	return FALSE;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 5083478392..c4c9b0bd4c 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1580,7 +1580,7 @@ void LLSpatialGroup::checkOcclusion()
 					LLFastTimer t(FTM_OCCLUSION_WAIT);
 					while (!available && max_loop-- > 0)
 					{
-						F32 max_time = llmin(gFrameIntervalSeconds*10.f, 1.f);
+						F32 max_time = llmin(gFrameIntervalSeconds.value()*10.f, 1.f);
 						//do some usefu work while we wait
 						LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
 						LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
@@ -2574,7 +2574,7 @@ void renderOctree(LLSpatialGroup* group)
 	LLVector4 col;
 	if (group->mBuilt > 0.f)
 	{
-		group->mBuilt -= 2.f * gFrameIntervalSeconds;
+		group->mBuilt -= 2.f * gFrameIntervalSeconds.value();
 		if (group->mBufferUsage == GL_STATIC_DRAW_ARB)
 		{
 			col.setVec(1.0f, 0, 0, group->mBuilt*0.5f);
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index cb3c90ea2a..bf47bd44c3 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2072,7 +2072,6 @@ bool idle_startup()
 		{
 			LLNotificationsUtil::add("ClothingLoading");
 			LLStatViewer::LOADING_WEARABLES_LONG_DELAY.add(1);
-			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_WEARABLES_TOO_LONG);
 			LLStartUp::setStartupState( STATE_CLEANUP );
 			return TRUE;
 		}
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index e354a5c59d..909745c5b6 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -461,7 +461,6 @@ void LLTexLayerSetBuffer::doUpload()
 {
 	llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl;
 	LLStatViewer::TEX_BAKES.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_BAKES);
 
 	// Don't need caches since we're baked now.  (note: we won't *really* be baked 
 	// until this image is sent to the server and the Avatar Appearance message is received.)
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index a88233e120..d734620f10 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -512,8 +512,8 @@ void LLGLTexMemBar::draw()
 	F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
-	F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024);
-	F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024);
+	LLUnit::Megabytes<F32> total_texture_downloaded = gTotalTextureData;
+	LLUnit::Megabytes<F32> total_object_downloaded = gTotalObjectData;
 	U32 total_http_requests = LLAppViewer::getTextureFetch()->getCurlRequest().getTotalIssuedRequests() ;
 	//----------------------------------------------------------------------------
 	LLGLSUIDefault gls_ui;
@@ -537,7 +537,7 @@ void LLGLTexMemBar::draw()
 											 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 
 	text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB Tot Htp: %d",
-					total_texture_downloaded, total_object_downloaded, total_http_requests);
+					total_texture_downloaded.value(), total_object_downloaded.value(), total_http_requests);
 	//, cache_entries, cache_max_entries
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3,
 											 text_color, LLFontGL::LEFT, LLFontGL::TOP);
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 791da59a1a..652847aac9 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1063,7 +1063,6 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
 	}
 	LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
 	LLStatViewer::EDIT_TEXTURE.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 	S32 num_faces = hit_obj->getNumTEs();
 	for( S32 face = 0; face < num_faces; face++ )
 	{
@@ -1132,7 +1131,6 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
 	// update viewer side image in anticipation of update from simulator
 	LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
 	LLStatViewer::EDIT_TEXTURE.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_EDIT_TEXTURE_COUNT );
 	hit_obj->setTEImage(hit_face, image);
 	dialog_refresh_all();
 
@@ -1357,7 +1355,6 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
 
 	LLStatViewer::OBJECT_REZ.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_REZ_COUNT);
 }
 
 void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj,
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index cf5a6e3762..329249eee8 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -434,7 +434,6 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
 
 	LLStatViewer::OBJECT_CREATE.add(1);
-	//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CREATE_COUNT);
 
 	return TRUE;
 }
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index e556743cbf..44e4c54142 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -84,6 +84,30 @@
 // ------------------------------------------------------
 LLViewerAssetStats * gViewerAssetStatsMain(0);
 LLViewerAssetStats * gViewerAssetStatsThread1(0);
+LLTrace::Count<> LLViewerAssetStats::sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests enqueued"),
+																LLTrace::Count<>("enqueuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests enqueued"),
+																LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", "Number of texture asset http requests enqueued"),
+																LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", "Number of texture asset udp requests enqueued"),
+																LLTrace::Count<>("enqueuedassetrequestswearableudp", "Number of wearable asset requests enqueued"),
+																LLTrace::Count<>("enqueuedassetrequestssoundudp", "Number of sound asset requests enqueued"),
+																LLTrace::Count<>("enqueuedassetrequestsgestureudp", "Number of gesture asset requests enqueued"),
+																LLTrace::Count<>("enqueuedassetrequestsother", "Number of other asset requests enqueued")};
+LLTrace::Count<> LLViewerAssetStats::sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests dequeued"),
+																LLTrace::Count<>("dequeuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests dequeued"),
+																LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", "Number of texture asset http requests dequeued"),
+																LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", "Number of texture asset udp requests dequeued"),
+																LLTrace::Count<>("dequeuedassetrequestswearableudp", "Number of wearable asset requests dequeued"),
+																LLTrace::Count<>("dequeuedassetrequestssoundudp", "Number of sound asset requests dequeued"),
+																LLTrace::Count<>("dequeuedassetrequestsgestureudp", "Number of gesture asset requests dequeued"),
+																LLTrace::Count<>("dequeuedassetrequestsother", "Number of other asset requests dequeued")};
+LLTrace::Measurement<LLTrace::Seconds> LLViewerAssetStats::sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", "Time spent responding to temporary texture asset http requests"),
+																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", "Time spent responding to temporary texture asset udp requests"),
+																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", "Time spent responding to texture asset http requests"),
+																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", "Time spent responding to texture asset udp requests"),
+																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", "Time spent responding to wearable asset requests"),
+																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", "Time spent responding to sound asset requests"),
+																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", "Time spent responding to gesture asset requests"),
+																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", "Time spent responding to other asset requests")};
 
 
 // ------------------------------------------------------
@@ -234,6 +258,7 @@ LLViewerAssetStats::recordGetEnqueued(LLViewerAssetType::EType at, bool with_htt
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 	
 	++(mCurRegionStats->mRequests[int(eac)].mEnqueued);
+	sEnqueued[int(eac)].add(1);
 }
 	
 void
@@ -242,6 +267,7 @@ LLViewerAssetStats::recordGetDequeued(LLViewerAssetType::EType at, bool with_htt
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
 	++(mCurRegionStats->mRequests[int(eac)].mDequeued);
+	sDequeued[int(eac)].add(1);
 }
 
 void
@@ -250,6 +276,7 @@ LLViewerAssetStats::recordGetServiced(LLViewerAssetType::EType at, bool with_htt
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
 	mCurRegionStats->mRequests[int(eac)].mResponse.record(duration);
+	sResponse[int(eac)].sample<LLTrace::Seconds>(duration);
 }
 
 void
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 8319752230..a750db2cc2 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -37,6 +37,7 @@
 #include "llsimplestat.h"
 #include "llsd.h"
 #include "llvoavatar.h"
+#include "lltrace.h"
 
 /**
  * @class LLViewerAssetStats
@@ -240,6 +241,7 @@ public:
 
 protected:
 	typedef std::map<region_handle_t, LLPointer<PerRegionStats> > PerRegionContainer;
+	typedef std::map<region_handle_t, LLTrace::Recording > PerRegionRecordingContainer;
 
 	// Region of the currently-active region.  Always valid but may
 	// be zero after construction or when explicitly set.  Unchanged
@@ -251,8 +253,13 @@ protected:
 	// Always points to a collection contained in mRegionStats.
 	LLPointer<PerRegionStats> mCurRegionStats;
 
+	static LLTrace::Count<> sEnqueued[EVACCount];
+	static LLTrace::Count<> sDequeued[EVACCount];
+	static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount];
+
 	// Metrics data for all regions during one collection cycle
 	PerRegionContainer mRegionStats;
+	PerRegionRecordingContainer mRegionRecordings;
 
 	// Time of last reset
 	duration_t mResetTimestamp;
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index ffeea2f4df..169b45c14e 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -607,7 +607,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 		{
 			LLFastTimer t(FTM_DISPLAY_UPDATE_GEOM);
-			const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time
+			const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds.value(); // 50 ms/second update time
 			gPipeline.createObjects(max_geom_update_time);
 			gPipeline.processPartitionQ();
 			gPipeline.updateGeom(max_geom_update_time);
@@ -760,7 +760,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 			{
 				LLFastTimer t(FTM_IMAGE_UPDATE_LIST);
-				F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds; // 50 ms/second decode time
+				F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds.value(); // 50 ms/second decode time
 				max_image_decode_time = llclamp(max_image_decode_time, 0.002f, 0.005f ); // min 2ms/frame, max 5ms/frame)
 				gTextureList.updateImages(max_image_decode_time);
 			}
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index f6e840adcd..f4155df4d1 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -501,7 +501,7 @@ void LLViewerJoystick::moveObjects(bool reset)
 	};
 
 	F32 cur_delta[6];
-	F32 time = gFrameIntervalSeconds;
+	F32 time = gFrameIntervalSeconds.value();
 
 	// avoid making ridicously big movements if there's a big drop in fps 
 	if (time > .2f)
@@ -665,7 +665,7 @@ void LLViewerJoystick::moveAvatar(bool reset)
 	};
 
 	// time interval in seconds between this frame and the previous
-	F32 time = gFrameIntervalSeconds;
+	F32 time = gFrameIntervalSeconds.value();
 
 	// avoid making ridicously big movements if there's a big drop in fps 
 	if (time > .2f)
@@ -878,7 +878,7 @@ void LLViewerJoystick::moveFlycam(bool reset)
 		gSavedSettings.getF32("FlycamAxisDeadZone6")
 	};
 
-	F32 time = gFrameIntervalSeconds;
+	F32 time = gFrameIntervalSeconds.value();
 
 	// avoid making ridiculously big movements if there's a big drop in fps 
 	if (time > .2f)
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 7ce8cdcfd8..50ca8db267 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -1097,19 +1097,16 @@ void upload_new_resource(
 	if( LLAssetType::AT_SOUND == asset_type )
 	{
 		LLStatViewer::UPLOAD_SOUND.add(1);
-		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_SOUND_COUNT );
 	}
 	else
 	if( LLAssetType::AT_TEXTURE == asset_type )
 	{
 		LLStatViewer::UPLOAD_TEXTURE.add(1);
-		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
 	}
 	else
 	if( LLAssetType::AT_ANIMATION == asset_type)
 	{
 		LLStatViewer::ANIMATION_UPLOADS.add(1);
-		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_UPLOAD_ANIM_COUNT );
 	}
 
 	if(LLInventoryType::IT_NONE == inv_type)
@@ -1235,20 +1232,14 @@ void increase_new_upload_stats(LLAssetType::EType asset_type)
 	if ( LLAssetType::AT_SOUND == asset_type )
 	{
 		LLStatViewer::UPLOAD_SOUND.add(1);
-		//LLViewerStats::getInstance()->incStat(
-		//	LLViewerStats::ST_UPLOAD_SOUND_COUNT );
 	}
 	else if ( LLAssetType::AT_TEXTURE == asset_type )
 	{
 		LLStatViewer::UPLOAD_TEXTURE.add(1);
-		//LLViewerStats::getInstance()->incStat(
-		//	LLViewerStats::ST_UPLOAD_TEXTURE_COUNT );
 	}
 	else if ( LLAssetType::AT_ANIMATION == asset_type )
 	{
 		LLStatViewer::ANIMATION_UPLOADS.add(1);
-		//LLViewerStats::getInstance()->incStat(
-		//	LLViewerStats::ST_UPLOAD_ANIM_COUNT );
 	}
 }
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index b3e1c9bdbe..82caa05983 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4416,18 +4416,18 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 
 // *TODO: Remove this dependency, or figure out a better way to handle
 // this hack.
-extern U32 gObjectBits;
+extern LLUnit::Bits<U32> gObjectData;
 
 void process_object_update(LLMessageSystem *mesgsys, void **user_data)
 {	
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectBits += mesgsys->getReceiveSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4439,11 +4439,11 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectBits += mesgsys->getReceiveSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4455,11 +4455,11 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data)
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectBits += mesgsys->getReceiveSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4471,11 +4471,11 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 {
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectBits += mesgsys->getReceiveSize() * 8;
+		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
 	}
 
 	gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
@@ -4763,140 +4763,6 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data)
 		{
 			llwarns << "Unknown sim stat identifier: " << stat_id << llendl;
 		}
-		//switch (stat_id)
-		//{
-		//case LL_SIM_STAT_TIME_DILATION:
-		//	LLStatViewer::SIM_TIME_DILATION.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_FPS:
-		//	LLStatViewer::SIM_FPS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimFPS.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_PHYSFPS:
-		//	LLStatViewer::SIM_PHYSICS_FPS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_AGENTUPS:
-		//	LLStatViewer::SIM_AGENT_UPS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_FRAMEMS:
-		//	LLStatViewer::SIM_FRAME_TIME.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_NETMS:
-		//	LLStatViewer::SIM_NET_TIME.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMOTHERMS:
-		//	LLStatViewer::SIM_PHYSICS_OTHER_TIME.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMPHYSICSMS:
-		//	LLStatViewer::SIM_PHYSICS_TIME.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_AGENTMS:
-		//	LLStatViewer::SIM_AGENTS_TIME.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_IMAGESMS:
-		//	LLStatViewer::SIM_IMAGES_TIME.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SCRIPTMS:
-		//	LLStatViewer::SIM_SCRIPTS_TIME.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_NUMTASKS:
-		//	LLStatViewer::SIM_OBJECTS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimObjects.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_NUMTASKSACTIVE:
-		//	LLStatViewer::SIM_ACTIVE_OBJECTS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_NUMAGENTMAIN:
-		//	LLStatViewer::SIM_MAIN_AGENTS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_NUMAGENTCHILD:
-		//	LLStatViewer::SIM_CHILD_AGENTS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_NUMSCRIPTSACTIVE:
-		//	LLStatViewer::SIM_ACTIVE_SCRIPTS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SCRIPT_EPS:
-		//	LLStatViewer::SIM_SCRIPT_EPS.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_INPPS:
-		//	LLStatViewer::SIM_IN_PACKETS_PER_SEC.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_OUTPPS:
-		//	LLStatViewer::SIM_OUT_PACKETS_PER_SEC.sample(stat_value);
-		//	//LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_PENDING_DOWNLOADS:
-		//	LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_PENDING_UPLOADS:
-		//	LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_PENDING_LOCAL_UPLOADS:
-		//	LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_TOTAL_UNACKED_BYTES:
-		//	LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f);
-		//	break;
-		//case LL_SIM_STAT_PHYSICS_PINNED_TASKS:
-		//	LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_PHYSICS_LOD_TASKS:
-		//	LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMPHYSICSSTEPMS:
-		//	LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMPHYSICSSHAPEMS:
-		//	LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMPHYSICSOTHERMS:
-		//	LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMPHYSICSMEMORY:
-		//	LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMSPARETIME:
-		//	LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMSLEEPTIME:
-		//	LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_IOPUMPTIME:
-		//	LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_PCTSCRIPTSRUN:
-		//	LLViewerStats::getInstance()->mSimPctScriptsRun.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SIMAISTEPTIMEMS:
-		//	LLViewerStats::getInstance()->mSimSimAIStepMsec.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_SKIPPEDAISILSTEPS_PS:
-		//	LLViewerStats::getInstance()->mSimSimSkippedSilhouetteSteps.addValue(stat_value);
-		//	break;
-		//case LL_SIM_STAT_PCTSTEPPEDCHARACTERS:
-		//	LLViewerStats::getInstance()->mSimSimPctSteppedCharacters.addValue(stat_value);
-		//	break;
-		//default:
-		//	// Used to be a commented out warning.
- 	//		LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL;
-		//  break;
-		//}
 	}
 
 	/*
@@ -5968,7 +5834,6 @@ void process_alert_core(const std::string& message, BOOL modal)
 	if ( message == "You died and have been teleported to your home location")
 	{
 		LLStatViewer::KILLED.add(1);
-		//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT);
 	}
 	else if( message == "Home position set." )
 	{
@@ -7395,8 +7260,6 @@ void onCovenantLoadComplete(LLVFS *vfs,
 	}
 	else
 	{
-		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
-		
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
 		    LL_ERR_FILE_EMPTY == status)
 		{
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 747dfd3250..ca404858cf 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2034,7 +2034,6 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
 		{
 			LLStatViewer::AGENT_POSITION_SNAP.sample<LLTrace::Meters>(diff.length());
-			//LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() );
 		}
 	}
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 2f171f89d7..14a2ac3384 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1033,10 +1033,6 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	LLStatViewer::NUM_ACTIVE_OBJECTS.sample(idle_count);
 	LLStatViewer::NUM_SIZE_CULLED.sample(mNumSizeCulled);
 	LLStatViewer::NUM_VIS_CULLED.sample(mNumVisCulled);
-	//LLViewerStats::getInstance()->mNumObjectsStat.addValue((S32) mObjects.size());
-	//LLViewerStats::getInstance()->mNumActiveObjectsStat.addValue(idle_count);
-	//LLViewerStats::getInstance()->mNumSizeCulledStat.addValue(mNumSizeCulled);
-	//LLViewerStats::getInstance()->mNumVisCulledStat.addValue(mNumVisCulled);
 }
 
 void LLViewerObjectList::fetchObjectCosts()
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index ccc0c9ba59..963d2ebb81 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -206,72 +206,53 @@ void LLViewerStats::resetStats()
 
 void LLViewerStats::updateFrameStats(const F64 time_diff)
 {
+	LLTrace::Seconds time_diff_seconds(time_diff);
 	if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0)
 	{
-		LLStatViewer::LOSS_5_PERCENT_TIME.add(time_diff);
-		//incStat(ST_LOSS_05_SECONDS, time_diff);
+		LLStatViewer::LOSS_5_PERCENT_TIME.add(time_diff_seconds);
 	}
 	
 	F32 sim_fps = getRecording().getLastValue(LLStatViewer::SIM_FPS);
 	if (0.f < sim_fps && sim_fps < 20.f)
 	{
-		LLStatViewer::SIM_20_FPS_TIME.add(time_diff);
-		//incStat(ST_SIM_FPS_20_SECONDS, time_diff);
+		LLStatViewer::SIM_20_FPS_TIME.add(time_diff_seconds);
 	}
 	
 	F32 sim_physics_fps = getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS);
 
 	if (0.f < sim_physics_fps && sim_physics_fps < 20.f)
 	{
-		LLStatViewer::SIM_PHYSICS_20_FPS_TIME.add(time_diff);
-		//incStat(ST_PHYS_FPS_20_SECONDS, time_diff);
+		LLStatViewer::SIM_PHYSICS_20_FPS_TIME.add(time_diff_seconds);
 	}
 		
 	if (time_diff >= 0.5)
 	{
-		LLStatViewer::FPS_2_TIME.add(time_diff);
-		//incStat(ST_FPS_2_SECONDS, time_diff);
+		LLStatViewer::FPS_2_TIME.add(time_diff_seconds);
 	}
 	if (time_diff >= 0.125)
 	{
-		LLStatViewer::FPS_8_TIME.add(time_diff);
-		//incStat(ST_FPS_8_SECONDS, time_diff);
+		LLStatViewer::FPS_8_TIME.add(time_diff_seconds);
 	}
 	if (time_diff >= 0.1)
 	{
-		LLStatViewer::FPS_10_TIME.add(time_diff);
-		//incStat(ST_FPS_10_SECONDS, time_diff);
+		LLStatViewer::FPS_10_TIME.add(time_diff_seconds);
 	}
 
 	if (gFrameCount && mLastTimeDiff > 0.0)
 	{
 		// new "stutter" meter
 		LLStatViewer::FRAMETIME_DOUBLED.add(time_diff >= 2.0 * mLastTimeDiff ? 1 : 0);
-		//setStat(ST_FPS_DROP_50_RATIO,
-		//		(getStat(ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + 
-		//		 (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount);
-			
 
 		// old stats that were never really used
-		LLStatViewer::FRAMETIME_JITTER.sample(mLastTimeDiff - time_diff);
-		//setStat(ST_FRAMETIME_JITTER,
-		//		(getStat(ST_FRAMETIME_JITTER) * (gFrameCount - 1) + 
-		//		 fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount);
+		LLStatViewer::FRAMETIME_JITTER.sample<LLTrace::Milliseconds>(mLastTimeDiff - time_diff);
 			
 		F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
-		LLStatViewer::FRAMETIME_SLEW.sample(average_frametime - time_diff);
-		//setStat(ST_FRAMETIME_SLEW,
-		//		(getStat(ST_FRAMETIME_SLEW) * (gFrameCount - 1) + 
-		//		 fabs(average_frametime - time_diff) / average_frametime) / gFrameCount);
+		LLStatViewer::FRAMETIME_SLEW.sample<LLTrace::Milliseconds>(average_frametime - time_diff);
 
 		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
 		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
 		LLStatViewer::DELTA_BANDWIDTH.sample<LLTrace::Bits>(delta_bandwidth);
-		//setStat(ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);
-
 		LLStatViewer::MAX_BANDWIDTH.sample<LLTrace::Bits>(max_bandwidth);
-		//setStat(ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
-		
 	}
 	
 	mLastTimeDiff = time_diff;
@@ -299,10 +280,13 @@ F32		gAveLandCompression = 0.f, gAveWaterCompression = 0.f;
 F32		gBestLandCompression = 1.f, gBestWaterCompression = 1.f;
 F32		gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f;
 
-U32		gTotalWorldBytes = 0, gTotalObjectBytes = 0, gTotalTextureBytes = 0, gSimPingCount = 0;
-U32		gObjectBits = 0;
+LLUnit::Bytes<U32>		gTotalWorldData = 0, 
+						gTotalObjectData = 0, 
+						gTotalTextureData = 0;
+U32		gSimPingCount = 0;
+LLUnit::Bits<U32>		gObjectData = 0;
 F32		gAvgSimPing = 0.f;
-U32     gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
+LLUnit::Bytes<U32>     gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
 
 extern U32  gVisCompared;
 extern U32  gVisTested;
@@ -311,8 +295,8 @@ LLFrameTimer gTextureTimer;
 
 void update_statistics()
 {
-	gTotalWorldBytes += gVLManager.getTotalBytes();
-	gTotalObjectBytes += gObjectBits / 8;
+	gTotalWorldData += gVLManager.getTotalBytes();
+	gTotalObjectData += gObjectData;
 
 	// make sure we have a valid time delta for this frame
 	if (gFrameIntervalSeconds > 0.f)
@@ -320,68 +304,48 @@ void update_statistics()
 		if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
 		{
 			LLStatViewer::MOUSELOOK_TIME.add(gFrameIntervalSeconds);
-			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_MOUSELOOK_SECONDS, gFrameIntervalSeconds);
 		}
 		else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
 		{
 			LLStatViewer::AVATAR_EDIT_TIME.add(gFrameIntervalSeconds);
-			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_AVATAR_EDIT_SECONDS, gFrameIntervalSeconds);
 		}
 		else if (LLFloaterReg::instanceVisible("build"))
 		{
 			LLStatViewer::TOOLBOX_TIME.add(gFrameIntervalSeconds);
-			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TOOLBOX_SECONDS, gFrameIntervalSeconds);
 		}
 	}
 	LLStatViewer::ENABLE_VBO.sample((F64)gSavedSettings.getBOOL("RenderVBOEnable"));
-	//stats.setStat(LLViewerStats::ST_ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
 	LLStatViewer::LIGHTING_DETAIL.sample((F64)gPipeline.getLightingDetail());
-	//stats.setStat(LLViewerStats::ST_LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
 	LLStatViewer::DRAW_DISTANCE.sample((F64)gSavedSettings.getF32("RenderFarClip"));
-	//stats.setStat(LLViewerStats::ST_DRAW_DIST, (F64)gSavedSettings.getF32("RenderFarClip"));
 	LLStatViewer::CHAT_BUBBLES.sample((F64)gSavedSettings.getBOOL("UseChatBubbles"));
-	//stats.setStat(LLViewerStats::ST_CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
 
-	LLStatViewer::FRAME_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Frame"));
-	//stats.setStat(LLViewerStats::ST_FRAME_SECS, gDebugView->mFastTimerView->getTime("Frame"));
+	LLStatViewer::FRAME_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Frame"));
 	F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle");
 	F64 network_secs = gDebugView->mFastTimerView->getTime("Network");
-	LLStatViewer::UPDATE_STACKTIME.sample(idle_secs - network_secs);
-	//stats.setStat(LLViewerStats::ST_UPDATE_SECS, idle_secs - network_secs);
-	LLStatViewer::NETWORK_STACKTIME.sample(network_secs);
-	//stats.setStat(LLViewerStats::ST_NETWORK_SECS, network_secs);
-	LLStatViewer::IMAGE_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Update Images"));
-	//stats.setStat(LLViewerStats::ST_IMAGE_SECS, gDebugView->mFastTimerView->getTime("Update Images"));
-	LLStatViewer::REBUILD_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Sort Draw State"));
-	//stats.setStat(LLViewerStats::ST_REBUILD_SECS, gDebugView->mFastTimerView->getTime("Sort Draw State"));
-	LLStatViewer::RENDER_STACKTIME.sample(gDebugView->mFastTimerView->getTime("Geometry"));
-	//stats.setStat(LLViewerStats::ST_RENDER_SECS, gDebugView->mFastTimerView->getTime("Geometry"));
+	LLStatViewer::UPDATE_STACKTIME.sample<LLTrace::Seconds>(idle_secs - network_secs);
+	LLStatViewer::NETWORK_STACKTIME.sample<LLTrace::Seconds>(network_secs);
+	LLStatViewer::IMAGE_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Update Images"));
+	LLStatViewer::REBUILD_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Sort Draw State"));
+	LLStatViewer::RENDER_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Geometry"));
 		
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
 		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(cdp->getPingDelay());
-		//stats.mSimPingStat.addValue(cdp->getPingDelay());
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
 		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10000);
-		//stats.mSimPingStat.addValue(10000);
 	}
 
-	//stats.mFPSStat.addValue(1);
 	LLStatViewer::FPS.add(1);
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
 	LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits);
-	//stats.mLayersKBitStat.addValue(layer_bits/1024.f);
-	LLStatViewer::OBJECT_KBIT.add<LLTrace::Bits>(gObjectBits);
-	//stats.mObjectKBitStat.addValue(gObjectBits/1024.f);
-	//stats.mVFSPendingOperations.addValue(LLVFile::getVFSThread()->getPending());
+	LLStatViewer::OBJECT_KBIT.add(gObjectData);
 	LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending());
 	LLStatViewer::ASSET_KBIT.add<LLTrace::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
-	//stats.mAssetKBitStat.addValue(gTransferManager.getTransferBitsIn(LLTCT_ASSET)/1024.f);
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
 	if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
@@ -403,14 +367,13 @@ void update_statistics()
 			avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames;
 		}
 		LLStatViewer::VISIBLE_AVATARS.sample((F64)avg_visible_avatars);
-		//stats.setStat(LLViewerStats::ST_VISIBLE_AVATARS, (F64)avg_visible_avatars);
 	}
 	LLWorld::getInstance()->updateNetStats();
 	LLWorld::getInstance()->requestCacheMisses();
 	
 	// Reset all of these values.
 	gVLManager.resetBitCounts();
-	gObjectBits = 0;
+	gObjectData = 0;
 //	gDecodedBits = 0;
 
 	// Only update texture stats periodically so that they are less noisy
@@ -419,7 +382,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			gTotalTextureBytes = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value();
+			gTotalTextureData = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value();
 			texture_stats_timer.reset();
 		}
 	}
@@ -559,9 +522,9 @@ void send_stats()
 
 	LLSD &download = body["downloads"];
 
-	download["world_kbytes"] = gTotalWorldBytes / 1024.0;
-	download["object_kbytes"] = gTotalObjectBytes / 1024.0;
-	download["texture_kbytes"] = gTotalTextureBytes / 1024.0;
+	download["world_kbytes"] = LLTrace::Kilobytes(gTotalWorldData).value();
+	download["object_kbytes"] = LLTrace::Kilobytes(gTotalObjectData).value();
+	download["texture_kbytes"] = LLTrace::Kilobytes(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 b182a40403..06f65b2cdd 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -57,7 +57,7 @@ struct SimMeasurement : public LLTrace::Measurement<T>, public SimMeasurementSam
 
 	/*virtual*/ void sample(F64 value)
 	{
-		LLTrace::Measurement<T>::sample(value);
+		LLTrace::Measurement<T>::sample(T(value));
 	}
 };
 
@@ -318,7 +318,7 @@ void update_statistics();
 void send_stats();
 
 extern LLFrameTimer gTextureTimer;
-extern U32	gTotalTextureBytes;
-extern U32  gTotalObjectBytes;
-extern U32  gTotalTextureBytesPerBoostLevel[] ;
+extern LLUnit::Bytes<U32>	gTotalTextureData;
+extern LLUnit::Bytes<U32>  gTotalObjectData;
+extern LLUnit::Bytes<U32>  gTotalTextureBytesPerBoostLevel[] ;
 #endif // LL_LLVIEWERSTATS_H
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index d355432e8a..b9d5751412 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -709,7 +709,7 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 	// Update the decode priority for N images each frame
 	{
         static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities");         // default: 32
-		const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds) + 1, MAX_PRIO_UPDATES);
+		const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds.value()) + 1, MAX_PRIO_UPDATES);
 		S32 update_counter = llmin(max_update_count, mUUIDMap.size());
 		uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID);
 		while ((update_counter-- > 0) && !mUUIDMap.empty())
@@ -943,11 +943,11 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
 	static const F32 MIN_PRIORITY_THRESHOLD = gSavedSettings.getF32("TextureFetchUpdatePriorityThreshold"); // default: 0.0
 	static const bool SKIP_LOW_PRIO = gSavedSettings.getBOOL("TextureFetchUpdateSkipLowPriority");          // default: false
 
-	size_t max_priority_count = llmin((S32) (MAX_HIGH_PRIO_COUNT*MAX_HIGH_PRIO_COUNT*gFrameIntervalSeconds)+1, MAX_HIGH_PRIO_COUNT);
+	size_t max_priority_count = llmin((S32) (MAX_HIGH_PRIO_COUNT*MAX_HIGH_PRIO_COUNT*gFrameIntervalSeconds.value())+1, MAX_HIGH_PRIO_COUNT);
 	max_priority_count = llmin(max_priority_count, mImageList.size());
 	
 	size_t total_update_count = mUUIDMap.size();
-	size_t max_update_count = llmin((S32) (MAX_UPDATE_COUNT*MAX_UPDATE_COUNT*gFrameIntervalSeconds)+1, MAX_UPDATE_COUNT);
+	size_t max_update_count = llmin((S32) (MAX_UPDATE_COUNT*MAX_UPDATE_COUNT*gFrameIntervalSeconds.value())+1, MAX_UPDATE_COUNT);
 	max_update_count = llmin(max_update_count, total_update_count);	
 	
 	// MAX_HIGH_PRIO_COUNT high priority entries
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 2062f07650..06daf15c08 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -731,7 +731,7 @@ public:
 			{
 				if(gTotalTextureBytesPerBoostLevel[i] > 0)
 				{
-					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, (F32)gTotalTextureBytesPerBoostLevel[i] / (1024 * 1024)));
+					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit::Megabytes<F32>(gTotalTextureBytesPerBoostLevel[i]).value()));
 					ypos += y_inc;
 				}
 			}
@@ -1405,8 +1405,8 @@ BOOL LLViewerWindow::handlePaint(LLWindow *window,  S32 x,  S32 y, S32 width,  S
 		LLTrace::Recording& recording = LLViewerStats::instance().getRecording();
 		temp_str = llformat( "FPS %3.1f Phy FPS %2.1f Time Dil %1.3f",		/* Flawfinder: ignore */
 				recording.getPerSec(LLStatViewer::FPS), //mFPSStat.getMeanPerSec(),
-				recording.getMean(LLStatViewer::SIM_PHYSICS_FPS), //LLViewerStats::getInstance()->mSimPhysicsFPS.getPrev(0),
-				recording.getMean(LLStatViewer::SIM_TIME_DILATION)); //LLViewerStats::getInstance()->mSimTimeDilation.getPrev(0));
+				recording.getLastValue(LLStatViewer::SIM_PHYSICS_FPS), 
+				recording.getLastValue(LLStatViewer::SIM_TIME_DILATION));
 		S32 len = temp_str.length();
 		TextOutA(hdc, 0, 0, temp_str.c_str(), len); 
 
@@ -2185,9 +2185,7 @@ void LLViewerWindow::reshape(S32 width, S32 height)
 		}
 
 		LLStatViewer::WINDOW_WIDTH.sample((F64)width);
-		//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_WIDTH, (F64)width);
 		LLStatViewer::WINDOW_HEIGHT.sample((F64)height);
-		//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_WINDOW_HEIGHT, (F64)height);
 
 		LLLayoutStack::updateClass();
 	}
@@ -3237,8 +3235,8 @@ void LLViewerWindow::updateMouseDelta()
 		static F32 fdy = 0.f;
 
 		F32 amount = 16.f;
-		fdx = fdx + ((F32) dx - fdx) * llmin(gFrameIntervalSeconds*amount,1.f);
-		fdy = fdy + ((F32) dy - fdy) * llmin(gFrameIntervalSeconds*amount,1.f);
+		fdx = fdx + ((F32) dx - fdx) * llmin(gFrameIntervalSeconds.value()*amount,1.f);
+		fdy = fdy + ((F32) dy - fdy) * llmin(gFrameIntervalSeconds.value()*amount,1.f);
 
 		mCurrentMouseDelta.set(llround(fdx), llround(fdy));
 		mouse_vel.setVec(fdx,fdy);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index d366455a62..97c1b07ebc 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -7813,14 +7813,14 @@ void LLVOAvatar::cullAvatarsByPixelArea()
 		if (gFrameTimeSeconds != sUnbakedUpdateTime) // only update once per frame
 		{
 			sUnbakedUpdateTime = gFrameTimeSeconds;
-			sUnbakedTime += gFrameIntervalSeconds;
+			sUnbakedTime += gFrameIntervalSeconds.value();
 		}
 		if (grey_avatars > 0)
 		{
 			if (gFrameTimeSeconds != sGreyUpdateTime) // only update once per frame
 			{
 				sGreyUpdateTime = gFrameTimeSeconds;
-				sGreyTime += gFrameIntervalSeconds;
+				sGreyTime += gFrameIntervalSeconds.value();
 			}
 		}
 	}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 9f0921ff59..7c20e8eae7 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -910,18 +910,11 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 		if (mLastRegionHandle != 0)
 		{
 			++mRegionCrossingCount;
-			F64 delta = (F64)mRegionCrossingTimer.getElapsedTimeF32();
-			//F64 avg = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_AVG);
-			//F64 delta_avg = (delta + avg*(mRegionCrossingCount-1)) / mRegionCrossingCount;
+			LLTrace::Seconds delta = mRegionCrossingTimer.getElapsedTimeF32();
 			LLStatViewer::REGION_CROSSING_TIME.sample(delta);
-			//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_AVG, delta_avg);
-			//
-			//F64 max = (mRegionCrossingCount == 1) ? 0 : LLViewerStats::getInstance()->getStat(LLViewerStats::ST_CROSSING_MAX);
-			//max = llmax(delta, max);
-			//LLViewerStats::getInstance()->setStat(LLViewerStats::ST_CROSSING_MAX, max);
 
 			// Diagnostics
-			llinfos << "Region crossing took " << (F32)(delta * 1000.0) << " ms " << llendl;
+			llinfos << "Region crossing took " << (F32)(delta * 1000.0).value() << " ms " << llendl;
 		}
 		if (regionp)
 		{
@@ -2589,7 +2582,6 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
 					gAgentAvatarp->invalidateComposite(layer_set, TRUE);
 					found = TRUE;
 					LLStatViewer::TEX_REBAKES.add(1);
-					//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES);
 				}
 			}
 		}
@@ -2635,7 +2627,6 @@ void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug)
 
 			invalidateComposite(layer_set, TRUE);
 			LLStatViewer::TEX_REBAKES.add(1);
-			//LLViewerStats::getInstance()->incStat(LLViewerStats::ST_TEX_REBAKES);
 		}
 		else
 		{
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp
index 20033d6fe4..0eb00f7191 100644
--- a/indra/newview/llwearablelist.cpp
+++ b/indra/newview/llwearablelist.cpp
@@ -136,7 +136,6 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
 		{
 			LLFile::remove(std::string(filename));
 		}
-		//LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
 
 		LL_WARNS("Wearable") << "Wearable download failed: " << LLAssetStorage::getErrorString( status ) << " " << uuid << LL_ENDL;
 		switch( status )
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 4582de805f..75af605ad7 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4892,7 +4892,7 @@ void LLPipeline::renderDebug()
 		{
 			DebugBlip& blip = *iter;
 
-			blip.mAge += gFrameIntervalSeconds;
+			blip.mAge += gFrameIntervalSeconds.value();
 			if (blip.mAge > 2.f)
 			{
 				mDebugBlips.erase(iter++);
@@ -4902,7 +4902,7 @@ void LLPipeline::renderDebug()
 				iter++;
 			}
 
-			blip.mPosition.mV[2] += gFrameIntervalSeconds*2.f;
+			blip.mPosition.mV[2] += gFrameIntervalSeconds.value()*2.f;
 
 			gGL.color4fv(blip.mColor.mV);
 			gGL.vertex3fv(blip.mPosition.mV);
@@ -5713,7 +5713,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)
 				{
 					if (farthest_light->fade >= 0.f)
 					{
-						farthest_light->fade = -gFrameIntervalSeconds;
+						farthest_light->fade = -(gFrameIntervalSeconds.value());
 					}
 				}
 				else
@@ -5809,12 +5809,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
 				if (fade >= 0.f)
 				{
 					fade = fade / LIGHT_FADE_TIME;
-					((Light*) (&(*iter)))->fade += gFrameIntervalSeconds;
+					((Light*) (&(*iter)))->fade += gFrameIntervalSeconds.value();
 				}
 				else
 				{
 					fade = 1.f + fade / LIGHT_FADE_TIME;
-					((Light*) (&(*iter)))->fade -= gFrameIntervalSeconds;
+					((Light*) (&(*iter)))->fade -= gFrameIntervalSeconds.value();
 				}
 				fade = llclamp(fade,0.f,1.f);
 				light_color *= fade;
@@ -7129,7 +7129,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 			}
 			else if (transition_time < 1.f)
 			{ //currently in a transition, continue interpolating
-				transition_time += 1.f/CameraFocusTransitionTime*gFrameIntervalSeconds;
+				transition_time += 1.f/CameraFocusTransitionTime*gFrameIntervalSeconds.value();
 				transition_time = llmin(transition_time, 1.f);
 
 				F32 t = cosf(transition_time*F_PI+F_PI)*0.5f+0.5f;
@@ -9121,7 +9121,7 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 	
 	if (!mHighlightSet.empty())
 	{
-		F32 transition = gFrameIntervalSeconds/RenderHighlightFadeTime;
+		F32 transition = gFrameIntervalSeconds.value()/RenderHighlightFadeTime;
 
 		LLGLDisable test(GL_ALPHA_TEST);
 		LLGLDepthTest depth(GL_FALSE);
@@ -9756,7 +9756,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 	if (gen_shadow)
 	{
-		F32 fade_amt = gFrameIntervalSeconds * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
+		F32 fade_amt = gFrameIntervalSeconds.value() * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
 
 		//update shadow targets
 		for (U32 i = 0; i < 2; i++)
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index f8923b9868..4a190fbe23 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -220,7 +220,18 @@ get_region(const LLSD & sd, U64 region_handle1)
 namespace tut
 {
 	struct tst_viewerassetstats_index
-	{};
+	{
+		tst_viewerassetstats_index()
+		{
+			LLTrace::init();
+		}
+
+		~tst_viewerassetstats_index()
+		{
+			LLTrace::cleanup();
+		}
+
+	};
 	typedef test_group<tst_viewerassetstats_index> tst_viewerassetstats_index_t;
 	typedef tst_viewerassetstats_index_t::object tst_viewerassetstats_index_object_t;
 	tut::tst_viewerassetstats_index_t tut_tst_viewerassetstats_index("tst_viewerassetstats_test");
-- 
cgit v1.2.3


From 1fadd6138eebf980776f80b9642f4c19279fcadd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 18 Oct 2012 17:32:44 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system fixed trace
 recording on background threads hitting null pointer

---
 indra/newview/llviewerstats.cpp | 8 +++++---
 indra/newview/llviewerstats.h   | 7 ++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 963d2ebb81..03cc9b12e3 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -149,9 +149,7 @@ LLTrace::Measurement<>		NUM_IMAGES("numimagesstat"),
 LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
 
 
-LLTrace::Measurement<LLTrace::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes"),
-										SIM_PHYSICS_MEM("physicsmemoryallocated"),
-										GL_TEX_MEM("gltexmemstat"),
+LLTrace::Measurement<LLTrace::Bytes>	GL_TEX_MEM("gltexmemstat"),
 										GL_BOUND_MEM("glboundmemstat"),
 										RAW_MEM("rawmemstat"),
 										FORMATTED_MEM("formattedmemstat"),
@@ -174,6 +172,10 @@ SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_
 										SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
 										SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
 
+SimMeasurement<LLTrace::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES),
+								SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
+
+
 LLTrace::Measurement<LLTrace::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
 											FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
 											LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 06f65b2cdd..78c4b89f71 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -147,10 +147,8 @@ extern LLTrace::Measurement<>				NUM_IMAGES,
 
 extern LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP;
 
-extern LLTrace::Measurement<LLTrace::Bytes>	SIM_UNACKED_BYTES,
-											DELTA_BANDWIDTH,
+extern LLTrace::Measurement<LLTrace::Bytes>	DELTA_BANDWIDTH,
 											MAX_BANDWIDTH,
-											SIM_PHYSICS_MEM,
 											GL_TEX_MEM,
 											GL_BOUND_MEM,
 											RAW_MEM,
@@ -171,6 +169,9 @@ extern SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME,
 												SIM_SLEEP_TIME,
 												SIM_PUMP_IO_TIME;
 
+extern SimMeasurement<LLTrace::Bytes>			SIM_UNACKED_BYTES,
+												SIM_PHYSICS_MEM;
+
 
 extern LLTrace::Measurement<LLTrace::Milliseconds>	FRAMETIME_JITTER,
 													FRAMETIME_SLEW,
-- 
cgit v1.2.3


From bd52d784f904cb0b46be5826f6c7df31b214fc09 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 18 Oct 2012 23:53:37 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system created param
 block skeleton for asset stats removed most of llviewerassetstats logic

---
 indra/newview/llappviewer.cpp                   |  22 +-
 indra/newview/lltexturefetch.cpp                | 201 +-----
 indra/newview/llviewerassetstats.cpp            | 867 +++++++++++-------------
 indra/newview/llviewerassetstats.h              | 141 +---
 indra/newview/llviewerassetstorage.cpp          |   6 +-
 indra/newview/tests/llviewerassetstats_test.cpp | 118 ++--
 6 files changed, 494 insertions(+), 861 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 4ab0e3336a..559f427de6 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4278,10 +4278,6 @@ void LLAppViewer::idle()
 				gObjectList.mNumUnknownUpdates = 0;
 			}
 
-			// ViewerMetrics FPS piggy-backing on the debug timer.
-			// The 5-second interval is nice for this purpose.  If the object debug
-			// bit moves or is disabled, please give this a suitable home.
-			LLViewerAssetStatsFF::record_fps_main(gFPSClamped);
 			LLViewerAssetStatsFF::record_avatar_stats();
 		}
 	}
@@ -5220,17 +5216,7 @@ void LLAppViewer::metricsUpdateRegion(U64 region_handle)
 {
 	if (0 != region_handle)
 	{
-		LLViewerAssetStatsFF::set_region_main(region_handle);
-		if (LLAppViewer::sTextureFetch)
-		{
-			// Send a region update message into 'thread1' to get the new region.
-			LLAppViewer::sTextureFetch->commandSetRegion(region_handle);
-		}
-		else
-		{
-			// No 'thread1', a.k.a. TextureFetch, so update directly
-			LLViewerAssetStatsFF::set_region_thread1(region_handle);
-		}
+		LLViewerAssetStatsFF::set_region(region_handle);
 	}
 }
 
@@ -5241,7 +5227,7 @@ void LLAppViewer::metricsUpdateRegion(U64 region_handle)
  */
 void LLAppViewer::metricsSend(bool enable_reporting)
 {
-	if (! gViewerAssetStatsMain)
+	if (! gViewerAssetStats)
 		return;
 
 	if (LLAppViewer::sTextureFetch)
@@ -5254,7 +5240,7 @@ void LLAppViewer::metricsSend(bool enable_reporting)
 
 			// Make a copy of the main stats to send into another thread.
 			// Receiving thread takes ownership.
-			LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStatsMain));
+			LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStats));
 			
 			// Send a report request into 'thread1' to get the rest of the data
 			// and provide some additional parameters while here.
@@ -5273,6 +5259,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.
-	gViewerAssetStatsMain->reset();
+	gViewerAssetStats->reset();
 }
 
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 8ddaac5cc8..903fd6acee 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -368,15 +368,15 @@ public:
 
 			if (worker->mMetricsStartTime)
 			{
-				LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
-															  true,
-															  LLImageBase::TYPE_AVATAR_BAKE == worker->mType,
-															  LLViewerAssetStatsFF::get_timestamp() - worker->mMetricsStartTime);
+				LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE,
+													true,
+													LLImageBase::TYPE_AVATAR_BAKE == worker->mType,
+													LLViewerAssetStatsFF::get_timestamp() - worker->mMetricsStartTime);
 				worker->mMetricsStartTime = 0;
 			}
-			LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 true,
-														 LLImageBase::TYPE_AVATAR_BAKE == worker->mType);
+			LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE,
+												true,
+												LLImageBase::TYPE_AVATAR_BAKE == worker->mType);
 		}
 		else
 		{
@@ -400,109 +400,6 @@ private:
 	bool mFollowRedir;
 };
 
-//////////////////////////////////////////////////////////////////////////////
-
-// Cross-thread messaging for asset metrics.
-
-/**
- * @brief Base class for cross-thread requests made of the fetcher
- *
- * I believe the intent of the LLQueuedThread class was to
- * have these operations derived from LLQueuedThread::QueuedRequest
- * but the texture fetcher has elected to manage the queue
- * in its own manner.  So these are free-standing objects which are
- * managed in simple FIFO order on the mCommands queue of the
- * LLTextureFetch object.
- *
- * What each represents is a simple command sent from an
- * outside thread into the TextureFetch thread to be processed
- * in order and in a timely fashion (though not an absolute
- * higher priority than other operations of the thread).
- * Each operation derives a new class from the base customizing
- * members, constructors and the doWork() method to effect
- * the command.
- *
- * The flow is one-directional.  There are two global instances
- * of the LLViewerAssetStats collector, one for the main program's
- * thread pointed to by gViewerAssetStatsMain and one for the
- * TextureFetch thread pointed to by gViewerAssetStatsThread1.
- * Common operations has each thread recording metrics events
- * into the respective collector unconcerned with locking and
- * the state of any other thread.  But when the agent moves into
- * a different region or the metrics timer expires and a report
- * needs to be sent back to the grid, messaging across threads
- * is required to distribute data and perform global actions.
- * In pseudo-UML, it looks like:
- *
- *                       Main                 Thread1
- *                        .                      .
- *                        .                      .
- *                     +-----+                   .
- *                     | AM  |                   .
- *                     +--+--+                   .
- *      +-------+         |                      .
- *      | Main  |      +--+--+                   .
- *      |       |      | SRE |---.               .
- *      | Stats |      +-----+    \              .
- *      |       |         |        \  (uuid)  +-----+
- *      | Coll. |      +--+--+      `-------->| SR  |
- *      +-------+      | MSC |                +--+--+
- *         | ^         +-----+                   |
- *         | |  (uuid)  / .                   +-----+ (uuid)
- *         |  `--------'  .                   | MSC |---------.
- *         |              .                   +-----+         |
- *         |           +-----+                   .            v
- *         |           | TE  |                   .        +-------+
- *         |           +--+--+                   .        | Thd1  |
- *         |              |                      .        |       |
- *         |           +-----+                   .        | Stats |
- *          `--------->| RSC |                   .        |       |
- *                     +--+--+                   .        | Coll. |
- *                        |                      .        +-------+
- *                     +--+--+                   .            |
- *                     | SME |---.               .            |
- *                     +-----+    \              .            |
- *                        .        \ (clone)  +-----+         |
- *                        .         `-------->| SM  |         |
- *                        .                   +--+--+         |
- *                        .                      |            |
- *                        .                   +-----+         |
- *                        .                   | RSC |<--------'
- *                        .                   +-----+
- *                        .                      |
- *                        .                   +-----+
- *                        .                   | CP  |--> HTTP POST
- *                        .                   +-----+
- *                        .                      .
- *                        .                      .
- *
- *
- * Key:
- *
- * SRE - Set Region Enqueued.  Enqueue a 'Set Region' command in
- *       the other thread providing the new UUID of the region.
- *       TFReqSetRegion carries the data.
- * SR  - Set Region.  New region UUID is sent to the thread-local
- *       collector.
- * SME - Send Metrics Enqueued.  Enqueue a 'Send Metrics' command
- *       including an ownership transfer of a cloned LLViewerAssetStats.
- *       TFReqSendMetrics carries the data.
- * SM  - Send Metrics.  Global metrics reporting operation.  Takes
- *       the cloned stats from the command, merges it with the
- *       thread's local stats, converts to LLSD and sends it on
- *       to the grid.
- * AM  - Agent Moved.  Agent has completed some sort of move to a
- *       new region.
- * TE  - Timer Expired.  Metrics timer has expired (on the order
- *       of 10 minutes).
- * CP  - CURL Post
- * MSC - Modify Stats Collector.  State change in the thread-local
- *       collector.  Typically a region change which affects the
- *       global pointers used to find the 'current stats'.
- * RSC - Read Stats Collector.  Extract collector data cloning it
- *       (i.e. deep copy) when necessary.
- *
- */
 class LLTextureFetch::TFRequest // : public LLQueuedThread::QueuedRequest
 {
 public:
@@ -521,36 +418,6 @@ public:
 namespace 
 {
 
-/**
- * @brief Implements a 'Set Region' cross-thread command.
- *
- * When an agent moves to a new region, subsequent metrics need
- * to be binned into a new or existing stats collection in 1:1
- * relationship with the region.  We communicate this region
- * change across the threads involved in the communication with
- * this message.
- *
- * Corresponds to LLTextureFetch::commandSetRegion()
- */
-class TFReqSetRegion : public LLTextureFetch::TFRequest
-{
-public:
-	TFReqSetRegion(U64 region_handle)
-		: LLTextureFetch::TFRequest(),
-		  mRegionHandle(region_handle)
-		{}
-	TFReqSetRegion & operator=(const TFReqSetRegion &);	// Not defined
-
-	virtual ~TFReqSetRegion()
-		{}
-
-	virtual bool doWork(LLTextureFetch * fetcher);
-		
-public:
-	const U64 mRegionHandle;
-};
-
-
 /**
  * @brief Implements a 'Send Metrics' cross-thread command.
  *
@@ -1104,9 +971,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			{
 				mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
 			}
-			LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 false,
-														 LLImageBase::TYPE_AVATAR_BAKE == mType);
+			LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE,
+												false,
+												LLImageBase::TYPE_AVATAR_BAKE == mType);
 			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
 			
 			return false;
@@ -1121,7 +988,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			//{
 			//   mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
 			//}
-			//LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE, false,
+			//LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false,
 			//                                             LLImageBase::TYPE_AVATAR_BAKE == mType);
 			//setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
 			return false;
@@ -1150,15 +1017,15 @@ bool LLTextureFetchWorker::doWork(S32 param)
 
 			if (mMetricsStartTime)
 			{
-				LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
-															  false,
-															  LLImageBase::TYPE_AVATAR_BAKE == mType,
-															  LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime);
+				LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE,
+													false,
+													LLImageBase::TYPE_AVATAR_BAKE == mType,
+													LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime);
 				mMetricsStartTime = 0;
 			}
-			LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 false,
-														 LLImageBase::TYPE_AVATAR_BAKE == mType);
+			LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE,
+												false,
+												LLImageBase::TYPE_AVATAR_BAKE == mType);
 		}
 		else
 		{
@@ -1167,9 +1034,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			{
 				mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
 			}
-			LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
-														 false,
-														 LLImageBase::TYPE_AVATAR_BAKE == mType);
+			LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE,
+												false,
+												LLImageBase::TYPE_AVATAR_BAKE == mType);
 			setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
 		}
 		return false;
@@ -1226,9 +1093,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				{
 					mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
 				}
-				LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
-															 true,
-															 LLImageBase::TYPE_AVATAR_BAKE == mType);
+				LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE,
+													true,
+													LLImageBase::TYPE_AVATAR_BAKE == mType);
 
 				// Will call callbackHttpGet when curl request completes
 				std::vector<std::string> headers;
@@ -2848,13 +2715,6 @@ void LLTextureFetch::dump()
 
 // cross-thread command methods
 
-void LLTextureFetch::commandSetRegion(U64 region_handle)
-{
-	TFReqSetRegion * req = new TFReqSetRegion(region_handle);
-
-	cmdEnqueue(req);
-}
-
 void LLTextureFetch::commandSendMetrics(const std::string & caps_url,
 										const LLUUID & session_id,
 										const LLUUID & agent_id,
@@ -2922,19 +2782,6 @@ void LLTextureFetch::cmdDoWork()
 namespace
 {
 
-/**
- * Implements the 'Set Region' command.
- *
- * Thread:  Thread1 (TextureFetch)
- */
-bool
-TFReqSetRegion::doWork(LLTextureFetch *)
-{
-	LLViewerAssetStatsFF::set_region_thread1(mRegionHandle);
-
-	return true;
-}
-
 
 TFReqSendMetrics::~TFReqSendMetrics()
 {
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 44e4c54142..cc15d6433f 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -82,95 +82,7 @@
 // ------------------------------------------------------
 // Global data definitions
 // ------------------------------------------------------
-LLViewerAssetStats * gViewerAssetStatsMain(0);
-LLViewerAssetStats * gViewerAssetStatsThread1(0);
-LLTrace::Count<> LLViewerAssetStats::sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests enqueued"),
-																LLTrace::Count<>("enqueuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests enqueued"),
-																LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", "Number of texture asset http requests enqueued"),
-																LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", "Number of texture asset udp requests enqueued"),
-																LLTrace::Count<>("enqueuedassetrequestswearableudp", "Number of wearable asset requests enqueued"),
-																LLTrace::Count<>("enqueuedassetrequestssoundudp", "Number of sound asset requests enqueued"),
-																LLTrace::Count<>("enqueuedassetrequestsgestureudp", "Number of gesture asset requests enqueued"),
-																LLTrace::Count<>("enqueuedassetrequestsother", "Number of other asset requests enqueued")};
-LLTrace::Count<> LLViewerAssetStats::sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", "Number of temporary texture asset http requests dequeued"),
-																LLTrace::Count<>("dequeuedassetrequeststemptextureudp", "Number of temporary texture asset udp requests dequeued"),
-																LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", "Number of texture asset http requests dequeued"),
-																LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", "Number of texture asset udp requests dequeued"),
-																LLTrace::Count<>("dequeuedassetrequestswearableudp", "Number of wearable asset requests dequeued"),
-																LLTrace::Count<>("dequeuedassetrequestssoundudp", "Number of sound asset requests dequeued"),
-																LLTrace::Count<>("dequeuedassetrequestsgestureudp", "Number of gesture asset requests dequeued"),
-																LLTrace::Count<>("dequeuedassetrequestsother", "Number of other asset requests dequeued")};
-LLTrace::Measurement<LLTrace::Seconds> LLViewerAssetStats::sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", "Time spent responding to temporary texture asset http requests"),
-																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", "Time spent responding to temporary texture asset udp requests"),
-																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", "Time spent responding to texture asset http requests"),
-																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", "Time spent responding to texture asset udp requests"),
-																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", "Time spent responding to wearable asset requests"),
-																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", "Time spent responding to sound asset requests"),
-																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", "Time spent responding to gesture asset requests"),
-																					LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", "Time spent responding to other asset requests")};
-
-
-// ------------------------------------------------------
-// Local declarations
-// ------------------------------------------------------
-namespace
-{
-
-static LLViewerAssetStats::EViewerAssetCategories
-asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp);
-
-}
-
-// ------------------------------------------------------
-// LLViewerAssetStats::PerRegionStats struct definition
-// ------------------------------------------------------
-void
-LLViewerAssetStats::PerRegionStats::reset()
-{
-	for (int i(0); i < LL_ARRAY_SIZE(mRequests); ++i)
-	{
-		mRequests[i].mEnqueued.reset();
-		mRequests[i].mDequeued.reset();
-		mRequests[i].mResponse.reset();
-	}
-	mFPS.reset();
-	
-	mTotalTime = 0;
-	mStartTimestamp = LLViewerAssetStatsFF::get_timestamp();
-}
-
-
-void
-LLViewerAssetStats::PerRegionStats::merge(const LLViewerAssetStats::PerRegionStats & src)
-{
-	// mRegionHandle, mTotalTime, mStartTimestamp are left alone.
-	
-	// mFPS
-	if (src.mFPS.getCount() && mFPS.getCount())
-	{
-		mFPS.merge(src.mFPS);
-	}
-
-	// Avatar stats - data all comes from main thread, so leave alone.
-
-	// Requests
-	for (int i = 0; i < LL_ARRAY_SIZE(mRequests); ++i)
-	{
-		mRequests[i].mEnqueued.merge(src.mRequests[i].mEnqueued);
-		mRequests[i].mDequeued.merge(src.mRequests[i].mDequeued);
-		mRequests[i].mResponse.merge(src.mRequests[i].mResponse);
-	}
-
-}
-
-
-void
-LLViewerAssetStats::PerRegionStats::accumulateTime(duration_t now)
-{
-	mTotalTime += (now - mStartTimestamp);
-	mStartTimestamp = now;
-}
-
+LLViewerAssetStats * gViewerAssetStats(0);
 
 // ------------------------------------------------------
 // LLViewerAssetStats class definition
@@ -183,47 +95,25 @@ LLViewerAssetStats::LLViewerAssetStats()
 
 
 LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
-	: mRegionHandle(src.mRegionHandle),
-	  mResetTimestamp(src.mResetTimestamp),
-	  mPhaseStats(src.mPhaseStats),
-	  mAvatarRezStates(src.mAvatarRezStates)
+:	mRegionHandle(src.mRegionHandle),
+	mPhaseStats(src.mPhaseStats),
+	mAvatarRezStates(src.mAvatarRezStates),
+	mRegionRecordings(src.mRegionRecordings)
 {
-	const PerRegionContainer::const_iterator it_end(src.mRegionStats.end());
-	for (PerRegionContainer::const_iterator it(src.mRegionStats.begin()); it_end != it; ++it)
-	{
-		mRegionStats[it->first] = new PerRegionStats(*it->second);
-	}
-	mCurRegionStats = mRegionStats[mRegionHandle];
+	mCurRecording = &mRegionRecordings[mRegionHandle];
 }
 
 
-void
-LLViewerAssetStats::reset()
+void LLViewerAssetStats::reset()
 {
 	// Empty the map of all region stats
-	mRegionStats.clear();
-
-	// If we have a current stats, reset it, otherwise, as at construction,
-	// create a new one as we must always have a current stats block.
-	if (mCurRegionStats)
-	{
-		mCurRegionStats->reset();
-	}
-	else
-	{
-		mCurRegionStats = new PerRegionStats(mRegionHandle);
-	}
+	mRegionRecordings.clear();
 
-	// And add reference to map
-	mRegionStats[mRegionHandle] = mCurRegionStats;
-
-	// Start timestamp consistent with per-region collector
-	mResetTimestamp = mCurRegionStats->mStartTimestamp;
+	// initialize new recording for current region
+	mCurRecording = &mRegionRecordings[mRegionHandle];
 }
 
-
-void
-LLViewerAssetStats::setRegion(region_handle_t region_handle)
+void LLViewerAssetStats::setRegion(region_handle_t region_handle)
 {
 	if (region_handle == mRegionHandle)
 	{
@@ -231,207 +121,386 @@ LLViewerAssetStats::setRegion(region_handle_t region_handle)
 		return;
 	}
 
-	// Get duration for current set
-	const duration_t now = LLViewerAssetStatsFF::get_timestamp();
-	mCurRegionStats->accumulateTime(now);
+	mCurRecording->stop();
+	mCurRecording = &mRegionRecordings[region_handle];
+	mCurRecording->start();
 
-	// Prepare new set
-	PerRegionContainer::iterator new_stats = mRegionStats.find(region_handle);
-	if (mRegionStats.end() == new_stats)
-	{
-		// Haven't seen this region_id before, create a new block and make it current.
-		mCurRegionStats = new PerRegionStats(region_handle);
-		mRegionStats[region_handle] = mCurRegionStats;
-	}
-	else
-	{
-		mCurRegionStats = new_stats->second;
-	}
-	mCurRegionStats->mStartTimestamp = now;
 	mRegionHandle = region_handle;
 }
 
-
-void
-LLViewerAssetStats::recordGetEnqueued(LLViewerAssetType::EType at, bool with_http, bool is_temp)
+void LLViewerAssetStats::recordAvatarStats()
 {
-	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
-	
-	++(mCurRegionStats->mRequests[int(eac)].mEnqueued);
-	sEnqueued[int(eac)].add(1);
+	LLVOAvatar::getNearbyRezzedStats(mAvatarRezStates);
+	mPhaseStats.clear();
+	mPhaseStats["cloud"] = LLViewerStats::PhaseMap::getPhaseStats("cloud");
+	mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray");
 }
+
+struct AssetRequestType : public LLInitParam::Block<AssetRequestType>
+{
+	Optional<S32>	enqueued,
+					dequeued,
+					resp_count;
+	Optional<F64>	resp_min,
+					resp_max,
+					resp_mean;
 	
-void
-LLViewerAssetStats::recordGetDequeued(LLViewerAssetType::EType at, bool with_http, bool is_temp)
+	AssetRequestType()
+	:	enqueued("enqueued"),
+		dequeued("dequeued"),
+		resp_count("resp_count"),
+		resp_min("resp_min"),
+		resp_max("resp_max"),
+		resp_mean("resp_mean")
+	{}
+};
+
+struct FPSStats : public LLInitParam::Block<FPSStats>
 {
-	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
+	Optional<S32>	count;
+	Optional<F64>	min,
+					max,
+					mean;
+	FPSStats()
+	:	count("count"),
+		min("min"),
+		max("max"),
+		mean("mean")
+	{}
+};
+
+struct RegionStats : public LLInitParam::Block<RegionStats>
+{
+	Optional<AssetRequestType>	get_texture_temp_http,
+								get_texture_temp_udp,
+								get_texture_non_temp_http,
+								get_texture_non_temp_udp,
+								get_wearable_udp,
+								get_sound_udp,
+								get_gesture_udp,
+								get_other;
+	Optional<FPSStats>			fps;
+	Mandatory<S32>				grid_x,
+								grid_y;
+	Mandatory<F64>				duration;
+
+	RegionStats()
+	:	get_texture_temp_http("get_texture_temp_http"),
+		get_texture_temp_udp("get_texture_temp_udp"),
+		get_texture_non_temp_http("get_texture_non_temp_http"),
+		get_texture_non_temp_udp("get_texture_non_temp_udp"),
+		get_wearable_udp("get_wearable_udp"),
+		get_sound_udp("get_sound_udp"),
+		get_gesture_udp("get_gesture_udp"),
+		get_other("get_other"),
+		fps("fps"),
+		grid_x("grid_x"),
+		grid_y("grid_y"),
+		duration("duration")
+	{}
+};
+
+struct AvatarRezState : public LLInitParam::Block<AvatarRezState>
+{
+	Mandatory<S32>	cloud,
+					gray,
+					textured;
+	AvatarRezState()
+	:	cloud("cloud"),
+		gray("gray"),
+		textured("textured")
+	{}
+};
+
+struct AvatarPhaseStats : public LLInitParam::Block<AvatarPhaseStats>
+{
+	Mandatory<LLSD>	cloud,
+					cloud_or_gray;
 
-	++(mCurRegionStats->mRequests[int(eac)].mDequeued);
-	sDequeued[int(eac)].add(1);
-}
+	AvatarPhaseStats()
+	:	cloud("cloud"),
+		cloud_or_gray("cloud-or-gray")
+	{}
+};
 
-void
-LLViewerAssetStats::recordGetServiced(LLViewerAssetType::EType at, bool with_http, bool is_temp, duration_t duration)
+struct AvatarInfo : public LLInitParam::Block<AvatarInfo>
 {
-	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
+	Mandatory<AvatarRezState> nearby;
+	Mandatory<AvatarPhaseStats> phase_stats;
 
-	mCurRegionStats->mRequests[int(eac)].mResponse.record(duration);
-	sResponse[int(eac)].sample<LLTrace::Seconds>(duration);
-}
+	AvatarInfo()
+	:	nearby("nearby"),
+		phase_stats("phase_stats")
+	{}
+};
 
-void
-LLViewerAssetStats::recordFPS(F32 fps)
+struct AssetStats : public LLInitParam::Block<AssetStats>
 {
-	mCurRegionStats->mFPS.record(fps);
-}
+	Multiple<RegionStats>	regions;
+	Mandatory<F64>			duration;
+
+	AssetStats()
+	:	regions("regions"),
+		duration("duration")
+	{}
+
+};
+
+//LLSD LLViewerAssetStats::asLLSD(bool compact_output)
+//{
+//	// Top-level tags
+//	static const LLSD::String tags[LLViewerAssetStatsFF::EVACCount] = 
+//		{
+//			LLSD::String("get_texture_temp_http"),
+//			LLSD::String("get_texture_temp_udp"),
+//			LLSD::String("get_texture_non_temp_http"),
+//			LLSD::String("get_texture_non_temp_udp"),
+//			LLSD::String("get_wearable_udp"),
+//			LLSD::String("get_sound_udp"),
+//			LLSD::String("get_gesture_udp"),
+//			LLSD::String("get_other")
+//		};
+//
+//	// Stats Group Sub-tags.
+//	static const LLSD::String enq_tag("enqueued");
+//	static const LLSD::String deq_tag("dequeued");
+//	static const LLSD::String rcnt_tag("resp_count");
+//	static const LLSD::String rmin_tag("resp_min");
+//	static const LLSD::String rmax_tag("resp_max");
+//	static const LLSD::String rmean_tag("resp_mean");
+//
+//	// MMM Group Sub-tags.
+//	static const LLSD::String cnt_tag("count");
+//	static const LLSD::String min_tag("min");
+//	static const LLSD::String max_tag("max");
+//	static const LLSD::String mean_tag("mean");
+//
+//	// Avatar sub-tags
+//	static const LLSD::String avatar_tag("avatar");
+//	static const LLSD::String avatar_nearby_tag("nearby");
+//	static const LLSD::String avatar_phase_stats_tag("phase_stats");
+//	
+//	const duration_t now = LLViewerAssetStatsFF::get_timestamp();
+//	mCurRegionStats->accumulateTime(now);
+//
+//	LLSD regions = LLSD::emptyArray();
+//	for (PerRegionContainer::iterator it = mRegionStats.begin();
+//		 mRegionStats.end() != it;
+//		 ++it)
+//	{
+//		if (0 == it->first)
+//		{
+//			// Never emit NULL UUID/handle in results.
+//			continue;
+//		}
+//
+//		PerRegionStats & stats = *it->second;
+//		
+//		LLSD reg_stat = LLSD::emptyMap();
+//		
+//		for (int i = 0; i < LL_ARRAY_SIZE(tags); ++i)
+//		{
+//			PerRegionStats::prs_group & group(stats.mRequests[i]);
+//			
+//			if ((! compact_output) ||
+//				group.mEnqueued.getCount() ||
+//				group.mDequeued.getCount() ||
+//				group.mResponse.getCount())
+//			{
+//				LLSD & slot = reg_stat[tags[i]];
+//				slot = LLSD::emptyMap();
+//				slot[enq_tag] = LLSD(S32(stats.mRequests[i].mEnqueued.getCount()));
+//				slot[deq_tag] = LLSD(S32(stats.mRequests[i].mDequeued.getCount()));
+//				slot[rcnt_tag] = LLSD(S32(stats.mRequests[i].mResponse.getCount()));
+//				slot[rmin_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMin() * 1.0e-6));
+//				slot[rmax_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMax() * 1.0e-6));
+//				slot[rmean_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMean() * 1.0e-6));
+//			}
+//		}
+//
+//		if ((! compact_output) || stats.mFPS.getCount())
+//		{
+//			LLSD & slot = reg_stat["fps"];
+//			slot = LLSD::emptyMap();
+//			slot[cnt_tag] = LLSD(S32(stats.mFPS.getCount()));
+//			slot[min_tag] = LLSD(F64(stats.mFPS.getMin()));
+//			slot[max_tag] = LLSD(F64(stats.mFPS.getMax()));
+//			slot[mean_tag] = LLSD(F64(stats.mFPS.getMean()));
+//		}
+//		U32 grid_x(0), grid_y(0);
+//		grid_from_region_handle(it->first, &grid_x, &grid_y);
+//		reg_stat["grid_x"] = LLSD::Integer(grid_x);
+//		reg_stat["grid_y"] = LLSD::Integer(grid_y);
+//		reg_stat["duration"] = LLSD::Real(stats.mTotalTime * 1.0e-6);		
+//		regions.append(reg_stat);
+//	}
+//
+//	LLSD ret = LLSD::emptyMap();
+//	ret["regions"] = regions;
+//	ret["duration"] = LLSD::Real((now - mResetTimestamp) * 1.0e-6);
+//	LLSD avatar_info;
+//	avatar_info[avatar_nearby_tag] = LLSD::emptyArray();
+//	for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat)
+//	{
+//		std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat);
+//		avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat];
+//	}
+//	avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD();
+//	avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD();
+//	ret[avatar_tag] = avatar_info;
+//	
+//	return ret;
+//}
 
-void
-LLViewerAssetStats::recordAvatarStats()
-{
-	std::vector<S32> rez_counts;
-	LLVOAvatar::getNearbyRezzedStats(rez_counts);
-	mAvatarRezStates = rez_counts;
-	mPhaseStats.clear();
-	mPhaseStats["cloud"] = LLViewerStats::PhaseMap::getPhaseStats("cloud");
-	mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray");
-}
+// ------------------------------------------------------
+// Global free-function definitions (LLViewerAssetStatsFF namespace)
+// ------------------------------------------------------
 
-LLSD
-LLViewerAssetStats::asLLSD(bool compact_output)
+namespace LLViewerAssetStatsFF
 {
-	// Top-level tags
-	static const LLSD::String tags[EVACCount] = 
+	static EViewerAssetCategories asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp)
+	{
+		// For statistical purposes, we divide GETs into several
+		// populations of asset fetches:
+		//  - textures which are de-prioritized in the asset system
+		//  - wearables (clothing, bodyparts) which directly affect
+		//    user experiences when they log in
+		//  - sounds
+		//  - gestures
+		//  - everything else.
+		//
+		llassert_always(50 == LLViewerAssetType::AT_COUNT);
+
+		// Multiple asset definitions are floating around so this requires some
+		// maintenance and attention.
+		static const EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] =
 		{
-			LLSD::String("get_texture_temp_http"),
-			LLSD::String("get_texture_temp_udp"),
-			LLSD::String("get_texture_non_temp_http"),
-			LLSD::String("get_texture_non_temp_udp"),
-			LLSD::String("get_wearable_udp"),
-			LLSD::String("get_sound_udp"),
-			LLSD::String("get_gesture_udp"),
-			LLSD::String("get_other")
+			EVACTextureTempHTTPGet,			// (0) AT_TEXTURE
+			EVACSoundUDPGet,				// AT_SOUND
+			EVACOtherGet,					// AT_CALLINGCARD
+			EVACOtherGet,					// AT_LANDMARK
+			EVACOtherGet,					// AT_SCRIPT
+			EVACWearableUDPGet,				// AT_CLOTHING
+			EVACOtherGet,					// AT_OBJECT
+			EVACOtherGet,					// AT_NOTECARD
+			EVACOtherGet,					// AT_CATEGORY
+			EVACOtherGet,					// AT_ROOT_CATEGORY
+			EVACOtherGet,					// (10) AT_LSL_TEXT
+			EVACOtherGet,					// AT_LSL_BYTECODE
+			EVACOtherGet,					// AT_TEXTURE_TGA
+			EVACWearableUDPGet,				// AT_BODYPART
+			EVACOtherGet,					// AT_TRASH
+			EVACOtherGet,					// AT_SNAPSHOT_CATEGORY
+			EVACOtherGet,					// AT_LOST_AND_FOUND
+			EVACSoundUDPGet,				// AT_SOUND_WAV
+			EVACOtherGet,					// AT_IMAGE_TGA
+			EVACOtherGet,					// AT_IMAGE_JPEG
+			EVACGestureUDPGet,				// (20) AT_ANIMATION
+			EVACGestureUDPGet,				// AT_GESTURE
+			EVACOtherGet,					// AT_SIMSTATE
+			EVACOtherGet,					// AT_FAVORITE
+			EVACOtherGet,					// AT_LINK
+			EVACOtherGet,					// AT_LINK_FOLDER
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// (30)
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// (40)
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					//
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// AT_MESH
+			// (50)
 		};
 
-	// Stats Group Sub-tags.
-	static const LLSD::String enq_tag("enqueued");
-	static const LLSD::String deq_tag("dequeued");
-	static const LLSD::String rcnt_tag("resp_count");
-	static const LLSD::String rmin_tag("resp_min");
-	static const LLSD::String rmax_tag("resp_max");
-	static const LLSD::String rmean_tag("resp_mean");
-
-	// MMM Group Sub-tags.
-	static const LLSD::String cnt_tag("count");
-	static const LLSD::String min_tag("min");
-	static const LLSD::String max_tag("max");
-	static const LLSD::String mean_tag("mean");
-
-	// Avatar sub-tags
-	static const LLSD::String avatar_tag("avatar");
-	static const LLSD::String avatar_nearby_tag("nearby");
-	static const LLSD::String avatar_phase_stats_tag("phase_stats");
-	
-	const duration_t now = LLViewerAssetStatsFF::get_timestamp();
-	mCurRegionStats->accumulateTime(now);
-
-	LLSD regions = LLSD::emptyArray();
-	for (PerRegionContainer::iterator it = mRegionStats.begin();
-		 mRegionStats.end() != it;
-		 ++it)
-	{
-		if (0 == it->first)
+		if (at < 0 || at >= LLViewerAssetType::AT_COUNT)
 		{
-			// Never emit NULL UUID/handle in results.
-			continue;
+			return EVACOtherGet;
 		}
-
-		PerRegionStats & stats = *it->second;
-		
-		LLSD reg_stat = LLSD::emptyMap();
-		
-		for (int i = 0; i < LL_ARRAY_SIZE(tags); ++i)
+		EViewerAssetCategories ret(asset_to_bin_map[at]);
+		if (EVACTextureTempHTTPGet == ret)
 		{
-			PerRegionStats::prs_group & group(stats.mRequests[i]);
-			
-			if ((! compact_output) ||
-				group.mEnqueued.getCount() ||
-				group.mDequeued.getCount() ||
-				group.mResponse.getCount())
+			// Indexed with [is_temp][with_http]
+			static const EViewerAssetCategories texture_bin_map[2][2] =
 			{
-				LLSD & slot = reg_stat[tags[i]];
-				slot = LLSD::emptyMap();
-				slot[enq_tag] = LLSD(S32(stats.mRequests[i].mEnqueued.getCount()));
-				slot[deq_tag] = LLSD(S32(stats.mRequests[i].mDequeued.getCount()));
-				slot[rcnt_tag] = LLSD(S32(stats.mRequests[i].mResponse.getCount()));
-				slot[rmin_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMin() * 1.0e-6));
-				slot[rmax_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMax() * 1.0e-6));
-				slot[rmean_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMean() * 1.0e-6));
-			}
-		}
-
-		if ((! compact_output) || stats.mFPS.getCount())
-		{
-			LLSD & slot = reg_stat["fps"];
-			slot = LLSD::emptyMap();
-			slot[cnt_tag] = LLSD(S32(stats.mFPS.getCount()));
-			slot[min_tag] = LLSD(F64(stats.mFPS.getMin()));
-			slot[max_tag] = LLSD(F64(stats.mFPS.getMax()));
-			slot[mean_tag] = LLSD(F64(stats.mFPS.getMean()));
-		}
-		U32 grid_x(0), grid_y(0);
-		grid_from_region_handle(it->first, &grid_x, &grid_y);
-		reg_stat["grid_x"] = LLSD::Integer(grid_x);
-		reg_stat["grid_y"] = LLSD::Integer(grid_y);
-		reg_stat["duration"] = LLSD::Real(stats.mTotalTime * 1.0e-6);		
-		regions.append(reg_stat);
-	}
-
-	LLSD ret = LLSD::emptyMap();
-	ret["regions"] = regions;
-	ret["duration"] = LLSD::Real((now - mResetTimestamp) * 1.0e-6);
-	LLSD avatar_info;
-	avatar_info[avatar_nearby_tag] = LLSD::emptyArray();
-	for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat)
-	{
-		std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat);
-		avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat];
-	}
-	avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD();
-	avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD();
-	ret[avatar_tag] = avatar_info;
-	
-	return ret;
-}
-
-void
-LLViewerAssetStats::merge(const LLViewerAssetStats & src)
-{
-	// mRegionHandle, mCurRegionStats and mResetTimestamp are left untouched.
-	// Just merge the stats bodies
+				{
+					EVACTextureNonTempUDPGet,
+					EVACTextureNonTempHTTPGet,
+				},
+				{
+					EVACTextureTempUDPGet,
+					EVACTextureTempHTTPGet,
+				}
+			};
 
-	const PerRegionContainer::const_iterator it_end(src.mRegionStats.end());
-	for (PerRegionContainer::const_iterator it(src.mRegionStats.begin()); it_end != it; ++it)
-	{
-		PerRegionContainer::iterator dst(mRegionStats.find(it->first));
-		if (mRegionStats.end() == dst)
-		{
-			// Destination is missing data, just make a private copy
-			mRegionStats[it->first] = new PerRegionStats(*it->second);
-		}
-		else
-		{
-			dst->second->merge(*it->second);
+			ret = texture_bin_map[is_temp][with_http];
 		}
+		return ret;
 	}
-}
-
-
-// ------------------------------------------------------
-// Global free-function definitions (LLViewerAssetStatsFF namespace)
-// ------------------------------------------------------
-
-namespace LLViewerAssetStatsFF
-{
+static LLTrace::Count<> sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", 
+														"Number of temporary texture asset http requests enqueued"),
+													LLTrace::Count<>("enqueuedassetrequeststemptextureudp", 
+														"Number of temporary texture asset udp requests enqueued"),
+													LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", 
+														"Number of texture asset http requests enqueued"),
+													LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", 
+														"Number of texture asset udp requests enqueued"),
+													LLTrace::Count<>("enqueuedassetrequestswearableudp", 
+														"Number of wearable asset requests enqueued"),
+													LLTrace::Count<>("enqueuedassetrequestssoundudp", 
+														"Number of sound asset requests enqueued"),
+													LLTrace::Count<>("enqueuedassetrequestsgestureudp", 
+														"Number of gesture asset requests enqueued"),
+													LLTrace::Count<>("enqueuedassetrequestsother", 
+														"Number of other asset requests enqueued")};
+
+static LLTrace::Count<> sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", 
+													"Number of temporary texture asset http requests dequeued"),
+												LLTrace::Count<>("dequeuedassetrequeststemptextureudp", 
+													"Number of temporary texture asset udp requests dequeued"),
+												LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", 
+													"Number of texture asset http requests dequeued"),
+												LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", 
+													"Number of texture asset udp requests dequeued"),
+												LLTrace::Count<>("dequeuedassetrequestswearableudp", 
+													"Number of wearable asset requests dequeued"),
+												LLTrace::Count<>("dequeuedassetrequestssoundudp", 
+													"Number of sound asset requests dequeued"),
+												LLTrace::Count<>("dequeuedassetrequestsgestureudp", 
+													"Number of gesture asset requests dequeued"),
+												LLTrace::Count<>("dequeuedassetrequestsother", 
+													"Number of other asset requests dequeued")};
+static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", 
+																			"Time spent responding to temporary texture asset http requests"),
+																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", 
+																			"Time spent responding to temporary texture asset udp requests"),
+																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", 
+																			"Time spent responding to texture asset http requests"),
+																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", 
+																			"Time spent responding to texture asset udp requests"),
+																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", 
+																			"Time spent responding to wearable asset requests"),
+																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", 
+																			"Time spent responding to sound asset requests"),
+																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", 
+																			"Time spent responding to gesture asset requests"),
+																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", 
+																			"Time spent responding to other asset requests")};
 
 //
 // Target thread is elaborated in the function name.  This could
@@ -452,227 +521,59 @@ namespace LLViewerAssetStatsFF
 
 // 'main' thread - initial program thread
 
-void
-set_region_main(LLViewerAssetStats::region_handle_t region_handle)
+void set_region(LLViewerAssetStats::region_handle_t region_handle)
 {
-	if (! gViewerAssetStatsMain)
+	if (! gViewerAssetStats)
 		return;
 
-	gViewerAssetStatsMain->setRegion(region_handle);
+	gViewerAssetStats->setRegion(region_handle);
 }
 
-void
-record_enqueue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp)
+void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
-	if (! gViewerAssetStatsMain)
-		return;
-
-	gViewerAssetStatsMain->recordGetEnqueued(at, with_http, is_temp);
-}
-
-void
-record_dequeue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp)
-{
-	if (! gViewerAssetStatsMain)
-		return;
-
-	gViewerAssetStatsMain->recordGetDequeued(at, with_http, is_temp);
-}
-
-void
-record_response_main(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration)
-{
-	if (! gViewerAssetStatsMain)
-		return;
-
-	gViewerAssetStatsMain->recordGetServiced(at, with_http, is_temp, duration);
-}
-
-void
-record_fps_main(F32 fps)
-{
-	if (! gViewerAssetStatsMain)
-		return;
-
-	gViewerAssetStatsMain->recordFPS(fps);
-}
-
-void
-record_avatar_stats()
-{
-	if (! gViewerAssetStatsMain)
-		return;
+	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	gViewerAssetStatsMain->recordAvatarStats();
+	sEnqueued[int(eac)].add(1);
 }
 
-// 'thread1' - should be for TextureFetch thread
-
-void
-set_region_thread1(LLViewerAssetStats::region_handle_t region_handle)
+void record_dequeue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
-	if (! gViewerAssetStatsThread1)
-		return;
-
-	gViewerAssetStatsThread1->setRegion(region_handle);
-}
-
-void
-record_enqueue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp)
-{
-	if (! gViewerAssetStatsThread1)
-		return;
+	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	gViewerAssetStatsThread1->recordGetEnqueued(at, with_http, is_temp);
+	sDequeued[int(eac)].add(1);
 }
 
-void
-record_dequeue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp)
+void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration)
 {
-	if (! gViewerAssetStatsThread1)
-		return;
+	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	gViewerAssetStatsThread1->recordGetDequeued(at, with_http, is_temp);
+	sResponse[int(eac)].sample<LLTrace::Seconds>(duration);
 }
 
-void
-record_response_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration)
+void record_avatar_stats()
 {
-	if (! gViewerAssetStatsThread1)
+	if (! gViewerAssetStats)
 		return;
 
-	gViewerAssetStatsThread1->recordGetServiced(at, with_http, is_temp, duration);
+	gViewerAssetStats->recordAvatarStats();
 }
 
-
-void
-init()
+void init()
 {
-	if (! gViewerAssetStatsMain)
+	if (! gViewerAssetStats)
 	{
-		gViewerAssetStatsMain = new LLViewerAssetStats();
-	}
-	if (! gViewerAssetStatsThread1)
-	{
-		gViewerAssetStatsThread1 = new LLViewerAssetStats();
+		gViewerAssetStats = new LLViewerAssetStats();
 	}
 }
 
 void
 cleanup()
 {
-	delete gViewerAssetStatsMain;
-	gViewerAssetStatsMain = 0;
-
-	delete gViewerAssetStatsThread1;
-	gViewerAssetStatsThread1 = 0;
+	delete gViewerAssetStats;
+	gViewerAssetStats = 0;
 }
 
 
 } // namespace LLViewerAssetStatsFF
 
 
-// ------------------------------------------------------
-// Local function definitions
-// ------------------------------------------------------
-
-namespace
-{
-
-LLViewerAssetStats::EViewerAssetCategories
-asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp)
-{
-	// For statistical purposes, we divide GETs into several
-	// populations of asset fetches:
-	//  - textures which are de-prioritized in the asset system
-	//  - wearables (clothing, bodyparts) which directly affect
-	//    user experiences when they log in
-	//  - sounds
-	//  - gestures
-	//  - everything else.
-	//
-	llassert_always(50 == LLViewerAssetType::AT_COUNT);
-
-	// Multiple asset definitions are floating around so this requires some
-	// maintenance and attention.
-	static const LLViewerAssetStats::EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] =
-		{
-			LLViewerAssetStats::EVACTextureTempHTTPGet,			// (0) AT_TEXTURE
-			LLViewerAssetStats::EVACSoundUDPGet,				// AT_SOUND
-			LLViewerAssetStats::EVACOtherGet,					// AT_CALLINGCARD
-			LLViewerAssetStats::EVACOtherGet,					// AT_LANDMARK
-			LLViewerAssetStats::EVACOtherGet,					// AT_SCRIPT
-			LLViewerAssetStats::EVACWearableUDPGet,				// AT_CLOTHING
-			LLViewerAssetStats::EVACOtherGet,					// AT_OBJECT
-			LLViewerAssetStats::EVACOtherGet,					// AT_NOTECARD
-			LLViewerAssetStats::EVACOtherGet,					// AT_CATEGORY
-			LLViewerAssetStats::EVACOtherGet,					// AT_ROOT_CATEGORY
-			LLViewerAssetStats::EVACOtherGet,					// (10) AT_LSL_TEXT
-			LLViewerAssetStats::EVACOtherGet,					// AT_LSL_BYTECODE
-			LLViewerAssetStats::EVACOtherGet,					// AT_TEXTURE_TGA
-			LLViewerAssetStats::EVACWearableUDPGet,				// AT_BODYPART
-			LLViewerAssetStats::EVACOtherGet,					// AT_TRASH
-			LLViewerAssetStats::EVACOtherGet,					// AT_SNAPSHOT_CATEGORY
-			LLViewerAssetStats::EVACOtherGet,					// AT_LOST_AND_FOUND
-			LLViewerAssetStats::EVACSoundUDPGet,				// AT_SOUND_WAV
-			LLViewerAssetStats::EVACOtherGet,					// AT_IMAGE_TGA
-			LLViewerAssetStats::EVACOtherGet,					// AT_IMAGE_JPEG
-			LLViewerAssetStats::EVACGestureUDPGet,				// (20) AT_ANIMATION
-			LLViewerAssetStats::EVACGestureUDPGet,				// AT_GESTURE
-			LLViewerAssetStats::EVACOtherGet,					// AT_SIMSTATE
-			LLViewerAssetStats::EVACOtherGet,					// AT_FAVORITE
-			LLViewerAssetStats::EVACOtherGet,					// AT_LINK
-			LLViewerAssetStats::EVACOtherGet,					// AT_LINK_FOLDER
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// (30)
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// (40)
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					//
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// 
-			LLViewerAssetStats::EVACOtherGet,					// AT_MESH
-																// (50)
-		};
-	
-	if (at < 0 || at >= LLViewerAssetType::AT_COUNT)
-	{
-		return LLViewerAssetStats::EVACOtherGet;
-	}
-	LLViewerAssetStats::EViewerAssetCategories ret(asset_to_bin_map[at]);
-	if (LLViewerAssetStats::EVACTextureTempHTTPGet == ret)
-	{
-		// Indexed with [is_temp][with_http]
-		static const LLViewerAssetStats::EViewerAssetCategories texture_bin_map[2][2] =
-			{
-				{
-					LLViewerAssetStats::EVACTextureNonTempUDPGet,
-					LLViewerAssetStats::EVACTextureNonTempHTTPGet,
-				},
-				{
-					LLViewerAssetStats::EVACTextureTempUDPGet,
-					LLViewerAssetStats::EVACTextureTempHTTPGet,
-				}
-			};
-
-		ret = texture_bin_map[is_temp][with_http];
-	}
-	return ret;
-}
-
-} // anonymous namespace
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index a750db2cc2..469609ea1f 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -77,20 +77,6 @@
 class LLViewerAssetStats
 {
 public:
-	enum EViewerAssetCategories
-	{
-		EVACTextureTempHTTPGet,			//< Texture GETs - temp/baked, HTTP
-		EVACTextureTempUDPGet,			//< Texture GETs - temp/baked, UDP
-		EVACTextureNonTempHTTPGet,		//< Texture GETs - perm, HTTP
-		EVACTextureNonTempUDPGet,		//< Texture GETs - perm, UDP
-		EVACWearableUDPGet,				//< Wearable GETs
-		EVACSoundUDPGet,				//< Sound GETs
-		EVACGestureUDPGet,				//< Gesture GETs
-		EVACOtherGet,					//< Other GETs
-		
-		EVACCount						// Must be last
-	};
-
 	/**
 	 * Type for duration and other time values in the metrics.  Selected
 	 * for compatibility with the pre-existing timestamp on the texture
@@ -105,61 +91,6 @@ public:
 	 */
 	typedef U64 region_handle_t;
 
-	/**
-	 * @brief Collected data for a single region visited by the avatar.
-	 *
-	 * Fairly simple, for each asset bin enumerated above a count
-	 * of enqueue and dequeue operations and simple stats on response
-	 * times for completed requests.
-	 */
-	class PerRegionStats : public LLRefCount
-	{
-	public:
-		PerRegionStats(const region_handle_t region_handle)
-			: LLRefCount(),
-			  mRegionHandle(region_handle)
-			{
-				reset();
-			}
-
-		PerRegionStats(const PerRegionStats & src)
-			: LLRefCount(),
-			  mRegionHandle(src.mRegionHandle),
-			  mTotalTime(src.mTotalTime),
-			  mStartTimestamp(src.mStartTimestamp),
-			  mFPS(src.mFPS)
-			{
-				for (int i = 0; i < LL_ARRAY_SIZE(mRequests); ++i)
-				{
-					mRequests[i] = src.mRequests[i];
-				}
-			}
-
-		// Default assignment and destructor are correct.
-		
-		void reset();
-
-		void merge(const PerRegionStats & src);
-		
-		// Apply current running time to total and reset start point.
-		// Return current timestamp as a convenience.
-		void accumulateTime(duration_t now);
-		
-	public:
-		region_handle_t		mRegionHandle;
-		duration_t			mTotalTime;
-		duration_t			mStartTimestamp;
-		LLSimpleStatMMM<>	mFPS;
-		
-		struct prs_group
-		{
-			LLSimpleStatCounter			mEnqueued;
-			LLSimpleStatCounter			mDequeued;
-			LLSimpleStatMMM<duration_t>	mResponse;
-		}
-		mRequests [EVACCount];
-	};
-
 public:
 	LLViewerAssetStats();
 	LLViewerAssetStats(const LLViewerAssetStats &);
@@ -175,26 +106,9 @@ public:
 	// collection calls.
 	void setRegion(region_handle_t region_handle);
 
-	// Asset GET Requests
-	void recordGetEnqueued(LLViewerAssetType::EType at, bool with_http, bool is_temp);
-	void recordGetDequeued(LLViewerAssetType::EType at, bool with_http, bool is_temp);
-	void recordGetServiced(LLViewerAssetType::EType at, bool with_http, bool is_temp, duration_t duration);
-
-	// Frames-Per-Second Samples
-	void recordFPS(F32 fps);
-
 	// Avatar-related statistics
 	void recordAvatarStats();
 
-	// Merge a source instance into a destination instance.  This is
-	// conceptually an 'operator+=()' method:
-	// - counts are added
-	// - minimums are min'd
-	// - maximums are max'd
-	// - other scalars are ignored ('this' wins)
-	//
-	void merge(const LLViewerAssetStats & src);
-	
 	// Retrieve current metrics for all visited regions (NULL region UUID/handle excluded)
     // Returned LLSD is structured as follows:
 	//
@@ -240,7 +154,6 @@ public:
 	LLSD asLLSD(bool compact_output);
 
 protected:
-	typedef std::map<region_handle_t, LLPointer<PerRegionStats> > PerRegionContainer;
 	typedef std::map<region_handle_t, LLTrace::Recording > PerRegionRecordingContainer;
 
 	// Region of the currently-active region.  Always valid but may
@@ -248,22 +161,12 @@ protected:
 	// by a reset() call.
 	region_handle_t mRegionHandle;
 
-	// Pointer to metrics collection for currently-active region.  Always
-	// valid and unchanged after reset() though contents will be changed.
-	// Always points to a collection contained in mRegionStats.
-	LLPointer<PerRegionStats> mCurRegionStats;
-
-	static LLTrace::Count<> sEnqueued[EVACCount];
-	static LLTrace::Count<> sDequeued[EVACCount];
-	static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount];
+	// Pointer to metrics collection for currently-active region.  
+	LLTrace::Recording*			mCurRecording;
 
 	// Metrics data for all regions during one collection cycle
-	PerRegionContainer mRegionStats;
 	PerRegionRecordingContainer mRegionRecordings;
 
-	// Time of last reset
-	duration_t mResetTimestamp;
-
 	// Nearby avatar stats
 	std::vector<S32> mAvatarRezStates;
 	LLViewerStats::phase_stats_t mPhaseStats;
@@ -284,12 +187,24 @@ protected:
  *  - Main:  main() program execution thread
  *  - Thread1:  TextureFetch worker thread
  */
-extern LLViewerAssetStats * gViewerAssetStatsMain;
-
-extern LLViewerAssetStats * gViewerAssetStatsThread1;
+extern LLViewerAssetStats * gViewerAssetStats;
 
 namespace LLViewerAssetStatsFF
 {
+	enum EViewerAssetCategories
+	{
+		EVACTextureTempHTTPGet,			//< Texture GETs - temp/baked, HTTP
+		EVACTextureTempUDPGet,			//< Texture GETs - temp/baked, UDP
+		EVACTextureNonTempHTTPGet,		//< Texture GETs - perm, HTTP
+		EVACTextureNonTempUDPGet,		//< Texture GETs - perm, UDP
+		EVACWearableUDPGet,				//< Wearable GETs
+		EVACSoundUDPGet,				//< Sound GETs
+		EVACGestureUDPGet,				//< Gesture GETs
+		EVACOtherGet,					//< Other GETs
+
+		EVACCount						// Must be last
+	};
+
 /**
  * @brief Allocation and deallocation of globals.
  *
@@ -314,31 +229,17 @@ inline LLViewerAssetStats::duration_t get_timestamp()
 /**
  * Region context, event and duration loggers for the Main thread.
  */
-void set_region_main(LLViewerAssetStats::region_handle_t region_handle);
+void set_region(LLViewerAssetStats::region_handle_t region_handle);
 
-void record_enqueue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp);
+void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp);
 
-void record_dequeue_main(LLViewerAssetType::EType at, bool with_http, bool is_temp);
+void record_dequeue(LLViewerAssetType::EType at, bool with_http, bool is_temp);
 
-void record_response_main(LLViewerAssetType::EType at, bool with_http, bool is_temp,
+void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp,
 						  LLViewerAssetStats::duration_t duration);
 
-void record_fps_main(F32 fps);
-
 void record_avatar_stats();
 
-/**
- * Region context, event and duration loggers for Thread 1.
- */
-void set_region_thread1(LLViewerAssetStats::region_handle_t region_handle);
-
-void record_enqueue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp);
-
-void record_dequeue_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp);
-
-void record_response_thread1(LLViewerAssetType::EType at, bool with_http, bool is_temp,
-						  LLViewerAssetStats::duration_t duration);
-
 } // namespace LLViewerAssetStatsFF
 
 #endif // LL_LLVIEWERASSETSTATUS_H
diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp
index d042f62830..6f41abbd8a 100644
--- a/indra/newview/llviewerassetstorage.cpp
+++ b/indra/newview/llviewerassetstorage.cpp
@@ -73,8 +73,8 @@ protected:
 			{
 				// Okay, it appears this request was used for useful things.  Record
 				// the expected dequeue and duration of request processing.
-				LLViewerAssetStatsFF::record_dequeue_main(mType, false, false);
-				LLViewerAssetStatsFF::record_response_main(mType, false, false,
+				LLViewerAssetStatsFF::record_dequeue(mType, false, false);
+				LLViewerAssetStatsFF::record_response(mType, false, false,
 														   (LLViewerAssetStatsFF::get_timestamp()
 															- mMetricsStartTime));
 				mMetricsStartTime = 0;
@@ -373,7 +373,7 @@ void LLViewerAssetStorage::_queueDataRequest(
 			LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(mUpstreamHost, LLTCT_ASSET);
 			ttcp->requestTransfer(spa, tpvf, 100.f + (is_priority ? 1.f : 0.f));
 
-			LLViewerAssetStatsFF::record_enqueue_main(atype, false, false);
+			LLViewerAssetStatsFF::record_enqueue(atype, false, false);
 		}
 	}
 	else
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index 4a190fbe23..e0126ce8d3 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -243,11 +243,11 @@ namespace tut
 		// Check that helpers aren't bothered by missing global stats
 		ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain));
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_response_main(LLViewerAssetType::AT_GESTURE, false, false, 12300000ULL);
+		LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_GESTURE, false, false, 12300000ULL);
 	}
 
 	// Create a non-global instance and check the structure
@@ -326,13 +326,13 @@ namespace tut
 	void tst_viewerassetstats_index_object_t::test<4>()
 	{
 		gViewerAssetStatsMain = new LLViewerAssetStats();
-		LLViewerAssetStatsFF::set_region_main(region1_handle);
+		LLViewerAssetStatsFF::set_region(region1_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
 		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
@@ -364,13 +364,13 @@ namespace tut
 	{
 		gViewerAssetStatsThread1 = new LLViewerAssetStats();
 		gViewerAssetStatsMain = new LLViewerAssetStats();
-		LLViewerAssetStatsFF::set_region_main(region1_handle);
+		LLViewerAssetStatsFF::set_region(region1_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
 		LLSD sd = gViewerAssetStatsThread1->asLLSD(false);
 		ensure("Other collector is empty", is_no_stats_map(sd));
@@ -393,8 +393,6 @@ namespace tut
 		
 		delete gViewerAssetStatsMain;
 		gViewerAssetStatsMain = NULL;
-		delete gViewerAssetStatsThread1;
-		gViewerAssetStatsThread1 = NULL;
 
 		ensure("sd[get_texture_non_temp_udp][enqueued] is reset", (0 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger()));
 		ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger()));
@@ -406,20 +404,20 @@ namespace tut
 	{
 		gViewerAssetStatsMain = new LLViewerAssetStats();
 
-		LLViewerAssetStatsFF::set_region_main(region1_handle);
+		LLViewerAssetStatsFF::set_region(region1_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
-		LLViewerAssetStatsFF::set_region_main(region2_handle);
+		LLViewerAssetStatsFF::set_region(region2_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
 		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
 
@@ -465,35 +463,35 @@ namespace tut
 	{
 		gViewerAssetStatsMain = new LLViewerAssetStats();
 
-		LLViewerAssetStatsFF::set_region_main(region1_handle);
+		LLViewerAssetStatsFF::set_region(region1_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
-		LLViewerAssetStatsFF::set_region_main(region2_handle);
+		LLViewerAssetStatsFF::set_region(region2_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
-		LLViewerAssetStatsFF::set_region_main(region1_handle);
+		LLViewerAssetStatsFF::set_region(region1_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, true, true);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, true, true);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, true, true);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, true, true);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
-		LLViewerAssetStatsFF::set_region_main(region2_handle);
+		LLViewerAssetStatsFF::set_region(region2_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
 		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
 
@@ -538,30 +536,30 @@ namespace tut
 	{
 		gViewerAssetStatsThread1 = new LLViewerAssetStats();
 		gViewerAssetStatsMain = new LLViewerAssetStats();
-		LLViewerAssetStatsFF::set_region_main(region1_handle);
+		LLViewerAssetStatsFF::set_region(region1_handle);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_TEXTURE, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, false, true);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, false, true);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, true);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, true);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, true, false);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, true, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, true, false);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, true, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_BODYPART, true, true);
-		LLViewerAssetStatsFF::record_dequeue_main(LLViewerAssetType::AT_BODYPART, true, true);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, true, true);
+		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, true, true);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, false, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, false, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, false, true);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, false, true);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, true, false);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, false);
 
-		LLViewerAssetStatsFF::record_enqueue_main(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
+		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
 
 		LLSD sd = gViewerAssetStatsThread1->asLLSD(false);
 		ensure("Other collector is empty", is_no_stats_map(sd));
-- 
cgit v1.2.3


From 6c7167b1f2363ab9412c4ded3b22c829018f6e45 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 19 Oct 2012 17:00:29 -0600
Subject: fix a gTextureTimer bug: it starts too early.

---
 indra/newview/lltexturefetch.cpp | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index f2caa01644..338cb8d70f 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -1919,6 +1919,10 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
 		}
 		mOriginFetchSource = mFetchSource;
 	}
+
+	//reset the texture timer.
+	gTextureTimer.reset();
+	gTextureTimer.pause();
 }
 
 LLTextureFetch::~LLTextureFetch()
-- 
cgit v1.2.3


From 176ffa54b44f2ef73f23e3252dd439f52fab3265 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 19 Oct 2012 19:35:01 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system finished most of
 conversion of llviewerassetstats ported some param block fixes from
 viewer-chui converted viewer asset stats to param block format

---
 indra/newview/llsimplestat.h                    |  58 +--
 indra/newview/lltexturefetch.cpp                |  48 +-
 indra/newview/llviewerassetstats.cpp            | 627 ++++++++++++++----------
 indra/newview/llviewerassetstats.h              |  90 +++-
 indra/newview/llviewerstats.cpp                 |   4 +-
 indra/newview/llviewerstats.h                   |   3 +-
 indra/newview/tests/llviewerassetstats_test.cpp | 510 ++-----------------
 7 files changed, 564 insertions(+), 776 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llsimplestat.h b/indra/newview/llsimplestat.h
index 9d7780c4f9..80ce99b774 100644
--- a/indra/newview/llsimplestat.h
+++ b/indra/newview/llsimplestat.h
@@ -99,43 +99,43 @@ public:
 	 * values back to zero.
 	 */
 	void reset()
-		{
-			mCount = 0;
-			mMin = Value(0);
-			mMax = Value(0);
-			mTotal = Value(0);
-		}
+	{
+		mCount = 0;
+		mMin = Value(0);
+		mMax = Value(0);
+		mTotal = Value(0);
+	}
 
 	void record(Value v)
+	{
+		if (mCount)
+		{
+			mMin = llmin(mMin, v);
+			mMax = llmax(mMax, v);
+		}
+		else
 		{
-			if (mCount)
-			{
-				mMin = llmin(mMin, v);
-				mMax = llmax(mMax, v);
-			}
-			else
-			{
-				mMin = v;
-				mMax = v;
-			}
-			mTotal += v;
-			++mCount;
+			mMin = v;
+			mMax = v;
 		}
+		mTotal += v;
+		++mCount;
+	}
 
 	void merge(const LLSimpleStatMMM<VALUE_T> & src)
+	{
+		if (! mCount)
+		{
+			*this = src;
+		}
+		else if (src.mCount)
 		{
-			if (! mCount)
-			{
-				*this = src;
-			}
-			else if (src.mCount)
-			{
-				mMin = llmin(mMin, src.mMin);
-				mMax = llmax(mMax, src.mMax);
-				mCount += src.mCount;
-				mTotal += src.mTotal;
-			}
+			mMin = llmin(mMin, src.mMin);
+			mMax = llmax(mMax, src.mMax);
+			mCount += src.mCount;
+			mTotal += src.mTotal;
 		}
+	}
 	
 	inline U32 getCount() const		{ return mCount; }
 	inline Value getMin() const		{ return mMin; }
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 903fd6acee..ac83fe0ca8 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -53,6 +53,7 @@
 #include "llviewerstatsrecorder.h"
 #include "llviewerassetstats.h"
 #include "llworld.h"
+#include "llsdparam.h"
 #include "llsdutil.h"
 #include "llstartup.h"
 #include "llviewerstats.h"
@@ -2867,8 +2868,8 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
 
 	}; // class lcl_responder
 	
-	if (! gViewerAssetStatsThread1)
-		return true;
+	//if (! gViewerAssetStatsThread1)
+	//	return true;
 
 	static volatile bool reporting_started(false);
 	static volatile S32 report_sequence(0);
@@ -2878,31 +2879,42 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
 	// but leave it in 'this'.  Destructor will rid us of it.
 	LLViewerAssetStats & main_stats = *mMainStats;
 
-	// Merge existing stats into those from main, convert to LLSD
-	main_stats.merge(*gViewerAssetStatsThread1);
-	LLSD merged_llsd = main_stats.asLLSD(true);
-
-	// Add some additional meta fields to the content
-	merged_llsd["session_id"] = mSessionID;
-	merged_llsd["agent_id"] = mAgentID;
-	merged_llsd["message"] = "ViewerAssetMetrics";					// Identifies the type of metrics
-	merged_llsd["sequence"] = report_sequence;						// Sequence number
-	merged_llsd["initial"] = ! reporting_started;					// Initial data from viewer
-	merged_llsd["break"] = LLTextureFetch::svMetricsDataBreak;		// Break in data prior to this report
-		
+	LLViewerAssetStats::AssetStats stats;
+	main_stats.getStats(stats);
+	//LLSD merged_llsd = main_stats.asLLSD();
+
+	stats.session_id = mSessionID;
+	stats.agent_id = mAgentID;
+	stats.message = "ViewerAssetMetrics";
+	stats.sequence = static_cast<bool>(report_sequence);
+	stats.initial = static_cast<bool>(!reporting_started);
+	stats.break_ = static_cast<bool>(LLTextureFetch::svMetricsDataBreak);
+	//// Add some additional meta fields to the content
+	//merged_llsd["session_id"] = mSessionID;
+	//merged_llsd["agent_id"] = mAgentID;
+	//merged_llsd["message"] = "ViewerAssetMetrics";					// Identifies the type of metrics
+	//merged_llsd["sequence"] = report_sequence;						// Sequence number
+	//merged_llsd["initial"] = ! reporting_started;					// Initial data from viewer
+	//merged_llsd["break"] = LLTextureFetch::svMetricsDataBreak;		// Break in data prior to this report
+	
+	LLSD sd;
+	LLParamSDParser parser;
+	parser.writeSD(sd, stats);
+
 	// Update sequence number
 	if (S32_MAX == ++report_sequence)
 		report_sequence = 0;
 
 	// Limit the size of the stats report if necessary.
-	merged_llsd["truncated"] = truncate_viewer_metrics(10, merged_llsd);
+	
+	sd["truncated"] = truncate_viewer_metrics(10, sd);
 
 	if (! mCapsURL.empty())
 	{
 		LLCurlRequest::headers_t headers;
 		fetcher->getCurlRequest().post(mCapsURL,
 									   headers,
-									   merged_llsd,
+									   sd,
 									   new lcl_responder(fetcher,
 														 report_sequence,
                                                          report_sequence,
@@ -2917,10 +2929,10 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
 	// In QA mode, Metrics submode, log the result for ease of testing
 	if (fetcher->isQAMode())
 	{
-		LL_INFOS("Textures") << ll_pretty_print_sd(merged_llsd) << LL_ENDL;
+		LL_INFOS("Textures") << ll_pretty_print_sd(sd) << LL_ENDL;
 	}
 
-	gViewerAssetStatsThread1->reset();
+	//gViewerAssetStatsThread1->reset();
 
 	return true;
 }
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index cc15d6433f..0b820f866e 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -31,6 +31,8 @@
 
 #include "stdtypes.h"
 #include "llvoavatar.h"
+#include "llsdparam.h"
+#include "llsdutil.h"
 
 /*
  * Classes and utility functions for per-thread and per-region
@@ -78,6 +80,152 @@
  *
  */
 
+namespace LLViewerAssetStatsFF
+{
+	static EViewerAssetCategories asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp)
+	{
+		// For statistical purposes, we divide GETs into several
+		// populations of asset fetches:
+		//  - textures which are de-prioritized in the asset system
+		//  - wearables (clothing, bodyparts) which directly affect
+		//    user experiences when they log in
+		//  - sounds
+		//  - gestures
+		//  - everything else.
+		//
+		llassert_always(50 == LLViewerAssetType::AT_COUNT);
+
+		// Multiple asset definitions are floating around so this requires some
+		// maintenance and attention.
+		static const EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] =
+		{
+			EVACTextureTempHTTPGet,			// (0) AT_TEXTURE
+			EVACSoundUDPGet,				// AT_SOUND
+			EVACOtherGet,					// AT_CALLINGCARD
+			EVACOtherGet,					// AT_LANDMARK
+			EVACOtherGet,					// AT_SCRIPT
+			EVACWearableUDPGet,				// AT_CLOTHING
+			EVACOtherGet,					// AT_OBJECT
+			EVACOtherGet,					// AT_NOTECARD
+			EVACOtherGet,					// AT_CATEGORY
+			EVACOtherGet,					// AT_ROOT_CATEGORY
+			EVACOtherGet,					// (10) AT_LSL_TEXT
+			EVACOtherGet,					// AT_LSL_BYTECODE
+			EVACOtherGet,					// AT_TEXTURE_TGA
+			EVACWearableUDPGet,				// AT_BODYPART
+			EVACOtherGet,					// AT_TRASH
+			EVACOtherGet,					// AT_SNAPSHOT_CATEGORY
+			EVACOtherGet,					// AT_LOST_AND_FOUND
+			EVACSoundUDPGet,				// AT_SOUND_WAV
+			EVACOtherGet,					// AT_IMAGE_TGA
+			EVACOtherGet,					// AT_IMAGE_JPEG
+			EVACGestureUDPGet,				// (20) AT_ANIMATION
+			EVACGestureUDPGet,				// AT_GESTURE
+			EVACOtherGet,					// AT_SIMSTATE
+			EVACOtherGet,					// AT_FAVORITE
+			EVACOtherGet,					// AT_LINK
+			EVACOtherGet,					// AT_LINK_FOLDER
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// (30)
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// (40)
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					//
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// 
+			EVACOtherGet,					// AT_MESH
+			// (50)
+		};
+
+		if (at < 0 || at >= LLViewerAssetType::AT_COUNT)
+		{
+			return EVACOtherGet;
+		}
+		EViewerAssetCategories ret(asset_to_bin_map[at]);
+		if (EVACTextureTempHTTPGet == ret)
+		{
+			// Indexed with [is_temp][with_http]
+			static const EViewerAssetCategories texture_bin_map[2][2] =
+			{
+				{
+					EVACTextureNonTempUDPGet,
+						EVACTextureNonTempHTTPGet,
+				},
+				{
+					EVACTextureTempUDPGet,
+						EVACTextureTempHTTPGet,
+					}
+			};
+
+			ret = texture_bin_map[is_temp][with_http];
+		}
+		return ret;
+	}
+	static LLTrace::Count<> sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", 
+		"Number of temporary texture asset http requests enqueued"),
+		LLTrace::Count<>("enqueuedassetrequeststemptextureudp", 
+		"Number of temporary texture asset udp requests enqueued"),
+		LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", 
+		"Number of texture asset http requests enqueued"),
+		LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", 
+		"Number of texture asset udp requests enqueued"),
+		LLTrace::Count<>("enqueuedassetrequestswearableudp", 
+		"Number of wearable asset requests enqueued"),
+		LLTrace::Count<>("enqueuedassetrequestssoundudp", 
+		"Number of sound asset requests enqueued"),
+		LLTrace::Count<>("enqueuedassetrequestsgestureudp", 
+		"Number of gesture asset requests enqueued"),
+		LLTrace::Count<>("enqueuedassetrequestsother", 
+		"Number of other asset requests enqueued")};
+
+	static LLTrace::Count<> sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", 
+		"Number of temporary texture asset http requests dequeued"),
+		LLTrace::Count<>("dequeuedassetrequeststemptextureudp", 
+		"Number of temporary texture asset udp requests dequeued"),
+		LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", 
+		"Number of texture asset http requests dequeued"),
+		LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", 
+		"Number of texture asset udp requests dequeued"),
+		LLTrace::Count<>("dequeuedassetrequestswearableudp", 
+		"Number of wearable asset requests dequeued"),
+		LLTrace::Count<>("dequeuedassetrequestssoundudp", 
+		"Number of sound asset requests dequeued"),
+		LLTrace::Count<>("dequeuedassetrequestsgestureudp", 
+		"Number of gesture asset requests dequeued"),
+		LLTrace::Count<>("dequeuedassetrequestsother", 
+		"Number of other asset requests dequeued")};
+	static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", 
+		"Time spent responding to temporary texture asset http requests"),
+		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", 
+		"Time spent responding to temporary texture asset udp requests"),
+		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", 
+		"Time spent responding to texture asset http requests"),
+		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", 
+		"Time spent responding to texture asset udp requests"),
+		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", 
+		"Time spent responding to wearable asset requests"),
+		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", 
+		"Time spent responding to sound asset requests"),
+		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", 
+		"Time spent responding to gesture asset requests"),
+		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", 
+		"Time spent responding to other asset requests")};
+}
 
 // ------------------------------------------------------
 // Global data definitions
@@ -88,7 +236,8 @@ LLViewerAssetStats * gViewerAssetStats(0);
 // LLViewerAssetStats class definition
 // ------------------------------------------------------
 LLViewerAssetStats::LLViewerAssetStats()
-	: mRegionHandle(U64(0))
+:	mRegionHandle(U64(0)),
+	mCurRecording(NULL)
 {
 	reset();
 }
@@ -110,7 +259,10 @@ void LLViewerAssetStats::reset()
 	mRegionRecordings.clear();
 
 	// initialize new recording for current region
-	mCurRecording = &mRegionRecordings[mRegionHandle];
+	if (mRegionHandle)
+	{
+		mCurRecording = &mRegionRecordings[mRegionHandle];
+	}
 }
 
 void LLViewerAssetStats::setRegion(region_handle_t region_handle)
@@ -121,9 +273,15 @@ void LLViewerAssetStats::setRegion(region_handle_t region_handle)
 		return;
 	}
 
-	mCurRecording->stop();
-	mCurRecording = &mRegionRecordings[region_handle];
-	mCurRecording->start();
+	if (mCurRecording)
+	{
+		mCurRecording->pause();
+	}
+	if (region_handle)
+	{
+		mCurRecording = &mRegionRecordings[region_handle];
+		mCurRecording->start();
+	}
 
 	mRegionHandle = region_handle;
 }
@@ -136,116 +294,169 @@ void LLViewerAssetStats::recordAvatarStats()
 	mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray");
 }
 
-struct AssetRequestType : public LLInitParam::Block<AssetRequestType>
+void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 {
-	Optional<S32>	enqueued,
-					dequeued,
-					resp_count;
-	Optional<F64>	resp_min,
-					resp_max,
-					resp_mean;
+	using namespace LLViewerAssetStatsFF;
+
+	if (mCurRecording)
+	{
+		mCurRecording->update();
+	}
 	
-	AssetRequestType()
-	:	enqueued("enqueued"),
-		dequeued("dequeued"),
-		resp_count("resp_count"),
-		resp_min("resp_min"),
-		resp_max("resp_max"),
-		resp_mean("resp_mean")
-	{}
-};
-
-struct FPSStats : public LLInitParam::Block<FPSStats>
-{
-	Optional<S32>	count;
-	Optional<F64>	min,
-					max,
-					mean;
-	FPSStats()
-	:	count("count"),
-		min("min"),
-		max("max"),
-		mean("mean")
-	{}
-};
-
-struct RegionStats : public LLInitParam::Block<RegionStats>
-{
-	Optional<AssetRequestType>	get_texture_temp_http,
-								get_texture_temp_udp,
-								get_texture_non_temp_http,
-								get_texture_non_temp_udp,
-								get_wearable_udp,
-								get_sound_udp,
-								get_gesture_udp,
-								get_other;
-	Optional<FPSStats>			fps;
-	Mandatory<S32>				grid_x,
-								grid_y;
-	Mandatory<F64>				duration;
-
-	RegionStats()
-	:	get_texture_temp_http("get_texture_temp_http"),
-		get_texture_temp_udp("get_texture_temp_udp"),
-		get_texture_non_temp_http("get_texture_non_temp_http"),
-		get_texture_non_temp_udp("get_texture_non_temp_udp"),
-		get_wearable_udp("get_wearable_udp"),
-		get_sound_udp("get_sound_udp"),
-		get_gesture_udp("get_gesture_udp"),
-		get_other("get_other"),
-		fps("fps"),
-		grid_x("grid_x"),
-		grid_y("grid_y"),
-		duration("duration")
-	{}
-};
-
-struct AvatarRezState : public LLInitParam::Block<AvatarRezState>
-{
-	Mandatory<S32>	cloud,
-					gray,
-					textured;
-	AvatarRezState()
-	:	cloud("cloud"),
-		gray("gray"),
-		textured("textured")
-	{}
-};
-
-struct AvatarPhaseStats : public LLInitParam::Block<AvatarPhaseStats>
-{
-	Mandatory<LLSD>	cloud,
-					cloud_or_gray;
+	if (mRegionRecordings.empty())
+	{
+		stats.regions.add().empty.setProvided();
+	}
+	else
+	{
+		for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end();
+			it != end_it;
+			++it)
+		{
+			RegionStats& r = stats.regions.add();
+			LLTrace::Recording& rec = it->second;
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACTextureTempHTTPGet]) 
+				|| rec.getSum(sDequeued[EVACTextureTempHTTPGet])
+				|| rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
+			{
+				r.get_texture_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureTempHTTPGet]))
+										.dequeued(rec.getSum(sDequeued[EVACTextureTempHTTPGet]))
+										.resp_count(rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
+										.resp_min(rec.getMin(sResponse[EVACTextureTempHTTPGet]).value())
+										.resp_max(rec.getMax(sResponse[EVACTextureTempHTTPGet]).value())
+										.resp_mean(rec.getMean(sResponse[EVACTextureTempHTTPGet]).value());
+			}
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACTextureTempUDPGet]) 
+				|| rec.getSum(sDequeued[EVACTextureTempUDPGet])
+				|| rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
+			{
+				r.get_texture_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureTempUDPGet]))
+										.dequeued(rec.getSum(sDequeued[EVACTextureTempUDPGet]))
+										.resp_count(rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
+										.resp_min(rec.getMin(sResponse[EVACTextureTempUDPGet]).value())
+										.resp_max(rec.getMax(sResponse[EVACTextureTempUDPGet]).value())
+										.resp_mean(rec.getMean(sResponse[EVACTextureTempUDPGet]).value());
+			}
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]) 
+				|| rec.getSum(sDequeued[EVACTextureNonTempHTTPGet])
+				|| rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
+			{
+				r.get_texture_non_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]))
+											.dequeued(rec.getSum(sDequeued[EVACTextureNonTempHTTPGet]))
+											.resp_count(rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
+											.resp_min(rec.getMin(sResponse[EVACTextureNonTempHTTPGet]).value())
+											.resp_max(rec.getMax(sResponse[EVACTextureNonTempHTTPGet]).value())
+											.resp_mean(rec.getMean(sResponse[EVACTextureNonTempHTTPGet]).value());
+			}
+
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]) 
+				|| rec.getSum(sDequeued[EVACTextureNonTempUDPGet])
+				|| rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
+			{
+				r.get_texture_non_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]))
+											.dequeued(rec.getSum(sDequeued[EVACTextureNonTempUDPGet]))
+											.resp_count(rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
+											.resp_min(rec.getMin(sResponse[EVACTextureNonTempUDPGet]).value())
+											.resp_max(rec.getMax(sResponse[EVACTextureNonTempUDPGet]).value())
+											.resp_mean(rec.getMean(sResponse[EVACTextureNonTempUDPGet]).value());
+			}
+
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACWearableUDPGet]) 
+				|| rec.getSum(sDequeued[EVACWearableUDPGet])
+				|| rec.getSum(sResponse[EVACWearableUDPGet]).value())
+			{
+				r.get_wearable_udp	.enqueued(rec.getSum(sEnqueued[EVACWearableUDPGet]))
+									.dequeued(rec.getSum(sDequeued[EVACWearableUDPGet]))
+									.resp_count(rec.getSum(sResponse[EVACWearableUDPGet]).value())
+									.resp_min(rec.getMin(sResponse[EVACWearableUDPGet]).value())
+									.resp_max(rec.getMax(sResponse[EVACWearableUDPGet]).value())
+									.resp_mean(rec.getMean(sResponse[EVACWearableUDPGet]).value());
+			}
+
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACSoundUDPGet]) 
+				|| rec.getSum(sDequeued[EVACSoundUDPGet])
+				|| rec.getSum(sResponse[EVACSoundUDPGet]).value())
+			{
+				r.get_sound_udp	.enqueued(rec.getSum(sEnqueued[EVACSoundUDPGet]))
+								.dequeued(rec.getSum(sDequeued[EVACSoundUDPGet]))
+								.resp_count(rec.getSum(sResponse[EVACSoundUDPGet]).value())
+								.resp_min(rec.getMin(sResponse[EVACSoundUDPGet]).value())
+								.resp_max(rec.getMax(sResponse[EVACSoundUDPGet]).value())
+								.resp_mean(rec.getMean(sResponse[EVACSoundUDPGet]).value());
+			}
+
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACGestureUDPGet]) 
+				|| rec.getSum(sDequeued[EVACGestureUDPGet])
+				|| rec.getSum(sResponse[EVACGestureUDPGet]).value())
+			{
+				r.get_gesture_udp	.enqueued(rec.getSum(sEnqueued[EVACGestureUDPGet]))
+									.dequeued(rec.getSum(sDequeued[EVACGestureUDPGet]))
+									.resp_count(rec.getSum(sResponse[EVACGestureUDPGet]).value())
+									.resp_min(rec.getMin(sResponse[EVACGestureUDPGet]).value())
+									.resp_max(rec.getMax(sResponse[EVACGestureUDPGet]).value())
+									.resp_mean(rec.getMean(sResponse[EVACGestureUDPGet]).value());
+			}
+
+			if (!compact_output
+				|| rec.getSum(sEnqueued[EVACOtherGet]) 
+				|| rec.getSum(sDequeued[EVACOtherGet])
+				|| rec.getSum(sResponse[EVACOtherGet]).value())
+			{
+				r.get_other	.enqueued(rec.getSum(sEnqueued[EVACOtherGet]))
+							.dequeued(rec.getSum(sDequeued[EVACOtherGet]))
+							.resp_count(rec.getSum(sResponse[EVACOtherGet]).value())
+							.resp_min(rec.getMin(sResponse[EVACOtherGet]).value())
+							.resp_max(rec.getMax(sResponse[EVACOtherGet]).value())
+							.resp_mean(rec.getMean(sResponse[EVACOtherGet]).value());
+			}
+
+			S32 fps = rec.getSum(LLStatViewer::FPS_SAMPLE);
+			if (!compact_output || fps != 0)
+			{
+				r.fps.count(fps);
+				r.fps.min(rec.getMin(LLStatViewer::FPS_SAMPLE));
+				r.fps.max(rec.getMax(LLStatViewer::FPS_SAMPLE));
+				r.fps.mean(rec.getMean(LLStatViewer::FPS_SAMPLE));
+			}
+			U32 grid_x(0), grid_y(0);
+			grid_from_region_handle(it->first, &grid_x, &grid_y);
+			r.grid_x(grid_x);
+			r.grid_y(grid_y);
+			r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value());
+		}
+	}
 
-	AvatarPhaseStats()
-	:	cloud("cloud"),
-		cloud_or_gray("cloud-or-gray")
-	{}
-};
+	stats.duration(mCurRecording ? LLUnit::Microseconds<F64>(mCurRecording->getDuration()).value() : 0.0);
+	//stats.avatar.setProvided(true);
 
-struct AvatarInfo : public LLInitParam::Block<AvatarInfo>
-{
-	Mandatory<AvatarRezState> nearby;
-	Mandatory<AvatarPhaseStats> phase_stats;
+	for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat)
+	{
+		stats.avatar.nearby	.cloud(mAvatarRezStates[0])
+							.gray(mAvatarRezStates[1])
+							.textured(mAvatarRezStates[2]);
+	}
 
-	AvatarInfo()
-	:	nearby("nearby"),
-		phase_stats("phase_stats")
-	{}
-};
+	stats.avatar.phase_stats	.cloud(mPhaseStats["cloud"].asLLSD())
+								.cloud_or_gray(mPhaseStats["cloud-or-gray"].asLLSD());
+}
 
-struct AssetStats : public LLInitParam::Block<AssetStats>
+LLSD LLViewerAssetStats::asLLSD(bool compact_output)
 {
-	Multiple<RegionStats>	regions;
-	Mandatory<F64>			duration;
-
-	AssetStats()
-	:	regions("regions"),
-		duration("duration")
-	{}
-
-};
-
+	LLParamSDParser parser;
+	LLSD sd;
+	AssetStats stats;
+	getStats(stats, compact_output);
+	parser.writeSD(sd, stats);
+	llinfos << ll_pretty_print_sd(sd) << llendl;
+	return sd;
+}
 //LLSD LLViewerAssetStats::asLLSD(bool compact_output)
 //{
 //	// Top-level tags
@@ -358,150 +569,6 @@ struct AssetStats : public LLInitParam::Block<AssetStats>
 
 namespace LLViewerAssetStatsFF
 {
-	static EViewerAssetCategories asset_type_to_category(const LLViewerAssetType::EType at, bool with_http, bool is_temp)
-	{
-		// For statistical purposes, we divide GETs into several
-		// populations of asset fetches:
-		//  - textures which are de-prioritized in the asset system
-		//  - wearables (clothing, bodyparts) which directly affect
-		//    user experiences when they log in
-		//  - sounds
-		//  - gestures
-		//  - everything else.
-		//
-		llassert_always(50 == LLViewerAssetType::AT_COUNT);
-
-		// Multiple asset definitions are floating around so this requires some
-		// maintenance and attention.
-		static const EViewerAssetCategories asset_to_bin_map[LLViewerAssetType::AT_COUNT] =
-		{
-			EVACTextureTempHTTPGet,			// (0) AT_TEXTURE
-			EVACSoundUDPGet,				// AT_SOUND
-			EVACOtherGet,					// AT_CALLINGCARD
-			EVACOtherGet,					// AT_LANDMARK
-			EVACOtherGet,					// AT_SCRIPT
-			EVACWearableUDPGet,				// AT_CLOTHING
-			EVACOtherGet,					// AT_OBJECT
-			EVACOtherGet,					// AT_NOTECARD
-			EVACOtherGet,					// AT_CATEGORY
-			EVACOtherGet,					// AT_ROOT_CATEGORY
-			EVACOtherGet,					// (10) AT_LSL_TEXT
-			EVACOtherGet,					// AT_LSL_BYTECODE
-			EVACOtherGet,					// AT_TEXTURE_TGA
-			EVACWearableUDPGet,				// AT_BODYPART
-			EVACOtherGet,					// AT_TRASH
-			EVACOtherGet,					// AT_SNAPSHOT_CATEGORY
-			EVACOtherGet,					// AT_LOST_AND_FOUND
-			EVACSoundUDPGet,				// AT_SOUND_WAV
-			EVACOtherGet,					// AT_IMAGE_TGA
-			EVACOtherGet,					// AT_IMAGE_JPEG
-			EVACGestureUDPGet,				// (20) AT_ANIMATION
-			EVACGestureUDPGet,				// AT_GESTURE
-			EVACOtherGet,					// AT_SIMSTATE
-			EVACOtherGet,					// AT_FAVORITE
-			EVACOtherGet,					// AT_LINK
-			EVACOtherGet,					// AT_LINK_FOLDER
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// (30)
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// (40)
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					//
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// 
-			EVACOtherGet,					// AT_MESH
-			// (50)
-		};
-
-		if (at < 0 || at >= LLViewerAssetType::AT_COUNT)
-		{
-			return EVACOtherGet;
-		}
-		EViewerAssetCategories ret(asset_to_bin_map[at]);
-		if (EVACTextureTempHTTPGet == ret)
-		{
-			// Indexed with [is_temp][with_http]
-			static const EViewerAssetCategories texture_bin_map[2][2] =
-			{
-				{
-					EVACTextureNonTempUDPGet,
-					EVACTextureNonTempHTTPGet,
-				},
-				{
-					EVACTextureTempUDPGet,
-					EVACTextureTempHTTPGet,
-				}
-			};
-
-			ret = texture_bin_map[is_temp][with_http];
-		}
-		return ret;
-	}
-static LLTrace::Count<> sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", 
-														"Number of temporary texture asset http requests enqueued"),
-													LLTrace::Count<>("enqueuedassetrequeststemptextureudp", 
-														"Number of temporary texture asset udp requests enqueued"),
-													LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", 
-														"Number of texture asset http requests enqueued"),
-													LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", 
-														"Number of texture asset udp requests enqueued"),
-													LLTrace::Count<>("enqueuedassetrequestswearableudp", 
-														"Number of wearable asset requests enqueued"),
-													LLTrace::Count<>("enqueuedassetrequestssoundudp", 
-														"Number of sound asset requests enqueued"),
-													LLTrace::Count<>("enqueuedassetrequestsgestureudp", 
-														"Number of gesture asset requests enqueued"),
-													LLTrace::Count<>("enqueuedassetrequestsother", 
-														"Number of other asset requests enqueued")};
-
-static LLTrace::Count<> sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", 
-													"Number of temporary texture asset http requests dequeued"),
-												LLTrace::Count<>("dequeuedassetrequeststemptextureudp", 
-													"Number of temporary texture asset udp requests dequeued"),
-												LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", 
-													"Number of texture asset http requests dequeued"),
-												LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", 
-													"Number of texture asset udp requests dequeued"),
-												LLTrace::Count<>("dequeuedassetrequestswearableudp", 
-													"Number of wearable asset requests dequeued"),
-												LLTrace::Count<>("dequeuedassetrequestssoundudp", 
-													"Number of sound asset requests dequeued"),
-												LLTrace::Count<>("dequeuedassetrequestsgestureudp", 
-													"Number of gesture asset requests dequeued"),
-												LLTrace::Count<>("dequeuedassetrequestsother", 
-													"Number of other asset requests dequeued")};
-static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", 
-																			"Time spent responding to temporary texture asset http requests"),
-																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", 
-																			"Time spent responding to temporary texture asset udp requests"),
-																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", 
-																			"Time spent responding to texture asset http requests"),
-																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", 
-																			"Time spent responding to texture asset udp requests"),
-																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", 
-																			"Time spent responding to wearable asset requests"),
-																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", 
-																			"Time spent responding to sound asset requests"),
-																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", 
-																			"Time spent responding to gesture asset requests"),
-																		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", 
-																			"Time spent responding to other asset requests")};
-
 //
 // Target thread is elaborated in the function name.  This could
 // have been something 'templatey' like specializations iterated
@@ -577,3 +644,59 @@ cleanup()
 } // namespace LLViewerAssetStatsFF
 
 
+
+LLViewerAssetStats::AssetRequestType::AssetRequestType() 
+:	enqueued("enqueued"),
+	dequeued("dequeued"),
+	resp_count("resp_count"),
+	resp_min("resp_min"),
+	resp_max("resp_max"),
+	resp_mean("resp_mean")
+{}
+
+LLViewerAssetStats::FPSStats::FPSStats() 
+:	count("count"),
+	min("min"),
+	max("max"),
+	mean("mean")
+{}
+
+LLViewerAssetStats::RegionStats::RegionStats() 
+:	get_texture_temp_http("get_texture_temp_http"),
+	get_texture_temp_udp("get_texture_temp_udp"),
+	get_texture_non_temp_http("get_texture_non_temp_http"),
+	get_texture_non_temp_udp("get_texture_non_temp_udp"),
+	get_wearable_udp("get_wearable_udp"),
+	get_sound_udp("get_sound_udp"),
+	get_gesture_udp("get_gesture_udp"),
+	get_other("get_other"),
+	fps("fps"),
+	grid_x("grid_x"),
+	grid_y("grid_y"),
+	duration("duration")
+{}
+
+LLViewerAssetStats::AvatarRezState::AvatarRezState() 
+:	cloud("cloud"),
+	gray("gray"),
+	textured("textured")
+{}
+
+LLViewerAssetStats::AvatarInfo::AvatarInfo() 
+:	nearby("nearby"),
+	phase_stats("phase_stats")
+{
+
+}
+
+LLViewerAssetStats::AssetStats::AssetStats() 
+:	regions("regions"),
+	duration("duration"),
+	avatar("avatar"),
+	session_id("session_id"),
+	agent_id("agent_id"),
+	message("message"),
+	sequence("sequence"),
+	initial("initial"),
+	break_("break")
+{}
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 469609ea1f..2f50c52730 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -91,6 +91,90 @@ public:
 	 */
 	typedef U64 region_handle_t;
 
+	struct AssetRequestType : public LLInitParam::Block<AssetRequestType>
+	{
+		Mandatory<S32>	enqueued,
+						dequeued,
+						resp_count;
+		Mandatory<F64>	resp_min,
+						resp_max,
+						resp_mean;
+	
+		AssetRequestType();
+	};
+
+	struct FPSStats : public LLInitParam::Block<FPSStats>
+	{
+		Mandatory<S32>	count;
+		Mandatory<F64>	min,
+						max,
+						mean;
+		FPSStats();
+	};
+
+	struct RegionStats : public LLInitParam::Block<RegionStats>
+	{
+		Optional<LLInitParam::Flag>				empty;
+		Optional<AssetRequestType>	get_texture_temp_http,
+									get_texture_temp_udp,
+									get_texture_non_temp_http,
+									get_texture_non_temp_udp,
+									get_wearable_udp,
+									get_sound_udp,
+									get_gesture_udp,
+									get_other;
+		Optional<FPSStats>			fps;
+		Optional<S32>				grid_x,
+									grid_y;
+		Optional<F64>				duration;
+
+		RegionStats();
+	};
+
+	struct AvatarRezState : public LLInitParam::Block<AvatarRezState>
+	{
+		Mandatory<S32>	cloud,
+						gray,
+						textured;
+		AvatarRezState();
+	};
+
+	struct AvatarPhaseStats : public LLInitParam::Block<AvatarPhaseStats>
+	{
+		Mandatory<LLSD>	cloud,
+						cloud_or_gray;
+
+		AvatarPhaseStats()
+		:	cloud("cloud"),
+			cloud_or_gray("cloud-or-gray")
+		{}
+	};
+
+	struct AvatarInfo : public LLInitParam::Block<AvatarInfo>
+	{
+		Optional<AvatarRezState> nearby;
+		Optional<AvatarPhaseStats> phase_stats;
+
+		AvatarInfo();
+	};
+
+	struct AssetStats : public LLInitParam::Block<AssetStats>
+	{
+		Multiple<RegionStats>	regions;
+		Mandatory<F64>			duration;
+		Mandatory<AvatarInfo>	avatar;
+
+		Mandatory<LLUUID>		session_id,
+								agent_id;
+
+		Mandatory<std::string>	message;
+		Mandatory<S32>			sequence;
+		Mandatory<bool>			initial,
+								break_;
+
+		AssetStats();
+	};
+
 public:
 	LLViewerAssetStats();
 	LLViewerAssetStats(const LLViewerAssetStats &);
@@ -146,11 +230,7 @@ public:
 	//   }
 	// }
 	//
-	// @param	compact_output		If true, omits from conversion any mmm_block
-	//								or stats_block that would contain all zero data.
-	//								Useful for transmission when the receiver knows
-	//								what is expected and will assume zero for missing
-	//								blocks.
+	void getStats(AssetStats& stats, bool compact_output);
 	LLSD asLLSD(bool compact_output);
 
 protected:
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 03cc9b12e3..04b0c30b40 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -128,7 +128,8 @@ SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DIL
 							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS),
 							SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS);
 
-LLTrace::Measurement<>		NUM_IMAGES("numimagesstat"),
+LLTrace::Measurement<>		FPS_SAMPLE("fpssample"),
+							NUM_IMAGES("numimagesstat"),
 							NUM_RAW_IMAGES("numrawimagesstat"),
 							NUM_OBJECTS("numobjectsstat"),
 							NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
@@ -343,6 +344,7 @@ void update_statistics()
 	}
 
 	LLStatViewer::FPS.add(1);
+	LLStatViewer::FPS_SAMPLE.sample(LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS));
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
 	LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits);
 	LLStatViewer::OBJECT_KBIT.add(gObjectData);
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 78c4b89f71..34731481f5 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -127,7 +127,8 @@ extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_PHYSICS_PINNED_TASKS,
 											SIM_PHYSICS_LOD_TASKS;
 
-extern LLTrace::Measurement<>				NUM_IMAGES,
+extern LLTrace::Measurement<>				FPS_SAMPLE,
+											NUM_IMAGES,
 											NUM_RAW_IMAGES,
 											NUM_OBJECTS,
 											NUM_ACTIVE_OBJECTS,
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index e0126ce8d3..f9d30408ac 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -37,6 +37,11 @@
 #include "llregionhandle.h"
 #include "../llvoavatar.h"
 
+namespace LLStatViewer
+{
+	LLTrace::Measurement<>		FPS_SAMPLE("fpssample");
+}
+
 void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts)
 {
 	counts.resize(3);
@@ -241,7 +246,7 @@ namespace tut
 	void tst_viewerassetstats_index_object_t::test<1>()
 	{
 		// Check that helpers aren't bothered by missing global stats
-		ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain));
+		ensure("Global gViewerAssetStats should be NULL", (NULL == gViewerAssetStats));
 
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
 
@@ -254,11 +259,11 @@ namespace tut
 	template<> template<>
 	void tst_viewerassetstats_index_object_t::test<2>()
 	{
-		ensure("Global gViewerAssetStatsMain should be NULL", (NULL == gViewerAssetStatsMain));
+		ensure("Global gViewerAssetStats should be NULL", (NULL == gViewerAssetStats));
 
 		LLViewerAssetStats * it = new LLViewerAssetStats();
 
-		ensure("Global gViewerAssetStatsMain should still be NULL", (NULL == gViewerAssetStatsMain));
+		ensure("Global gViewerAssetStats should still be NULL", (NULL == gViewerAssetStats));
 
 		LLSD sd_full = it->asLLSD(false);
 
@@ -325,7 +330,7 @@ namespace tut
 	template<> template<>
 	void tst_viewerassetstats_index_object_t::test<4>()
 	{
-		gViewerAssetStatsMain = new LLViewerAssetStats();
+		gViewerAssetStats = new LLViewerAssetStats();
 		LLViewerAssetStatsFF::set_region(region1_handle);
 
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
@@ -334,7 +339,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
 		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
-		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
+		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = sd["regions"][0];
@@ -348,11 +353,11 @@ namespace tut
 
 		// Reset and check zeros...
 		// Reset leaves current region in place
-		gViewerAssetStatsMain->reset();
-		sd = gViewerAssetStatsMain->asLLSD(false)["regions"][region1_handle_str];
+		gViewerAssetStats->reset();
+		sd = gViewerAssetStats->asLLSD(false)["regions"][region1_handle_str];
 		
-		delete gViewerAssetStatsMain;
-		gViewerAssetStatsMain = NULL;
+		delete gViewerAssetStats;
+		gViewerAssetStats = NULL;
 
 		ensure("sd[get_texture_non_temp_udp][enqueued] is reset", (0 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger()));
 		ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger()));
@@ -362,8 +367,7 @@ namespace tut
 	template<> template<>
 	void tst_viewerassetstats_index_object_t::test<5>()
 	{
-		gViewerAssetStatsThread1 = new LLViewerAssetStats();
-		gViewerAssetStatsMain = new LLViewerAssetStats();
+		gViewerAssetStats = new LLViewerAssetStats();
 		LLViewerAssetStatsFF::set_region(region1_handle);
 
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
@@ -372,9 +376,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
 		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
-		LLSD sd = gViewerAssetStatsThread1->asLLSD(false);
-		ensure("Other collector is empty", is_no_stats_map(sd));
-		sd = gViewerAssetStatsMain->asLLSD(false);
+		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = sd["regions"][0];
@@ -388,11 +390,11 @@ namespace tut
 
 		// Reset and check zeros...
 		// Reset leaves current region in place
-		gViewerAssetStatsMain->reset();
-		sd = gViewerAssetStatsMain->asLLSD(false)["regions"][0];
+		gViewerAssetStats->reset();
+		sd = gViewerAssetStats->asLLSD(false)["regions"][0];
 		
-		delete gViewerAssetStatsMain;
-		gViewerAssetStatsMain = NULL;
+		delete gViewerAssetStats;
+		gViewerAssetStats = NULL;
 
 		ensure("sd[get_texture_non_temp_udp][enqueued] is reset", (0 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger()));
 		ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger()));
@@ -402,7 +404,7 @@ namespace tut
 	template<> template<>
 	void tst_viewerassetstats_index_object_t::test<6>()
 	{
-		gViewerAssetStatsMain = new LLViewerAssetStats();
+		gViewerAssetStats = new LLViewerAssetStats();
 
 		LLViewerAssetStatsFF::set_region(region1_handle);
 
@@ -419,7 +421,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
-		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
+		LLSD sd = gViewerAssetStats->asLLSD(false);
 
 		// std::cout << sd << std::endl;
 		
@@ -444,14 +446,14 @@ namespace tut
 
 		// Reset and check zeros...
 		// Reset leaves current region in place
-		gViewerAssetStatsMain->reset();
-		sd = gViewerAssetStatsMain->asLLSD(false);
+		gViewerAssetStats->reset();
+		sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
 		ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle));
 		sd2 = sd["regions"][0];
 		
-		delete gViewerAssetStatsMain;
-		gViewerAssetStatsMain = NULL;
+		delete gViewerAssetStats;
+		gViewerAssetStats = NULL;
 
 		ensure("sd2[get_texture_non_temp_udp][enqueued] is reset", (0 == sd2["get_texture_non_temp_udp"]["enqueued"].asInteger()));
 		ensure("sd2[get_gesture_udp][enqueued] is reset", (0 == sd2["get_gesture_udp"]["enqueued"].asInteger()));
@@ -461,7 +463,7 @@ namespace tut
 	template<> template<>
 	void tst_viewerassetstats_index_object_t::test<7>()
 	{
-		gViewerAssetStatsMain = new LLViewerAssetStats();
+		gViewerAssetStats = new LLViewerAssetStats();
 
 		LLViewerAssetStatsFF::set_region(region1_handle);
 
@@ -493,7 +495,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
-		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
+		LLSD sd = gViewerAssetStats->asLLSD(false);
 
 		ensure("Correct double-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar"));
 		ensure("Correct double-slot LLSD array regions", is_double_slot_array(sd["regions"], region1_handle, region2_handle));
@@ -502,6 +504,8 @@ namespace tut
 		ensure("Region1 is present in results", sd1.isMap());
 		ensure("Region2 is present in results", sd2.isMap());
 		
+		llinfos << ll_pretty_print_sd(sd1) << llendl;
+
 		// Check a few points on the tree for content
 		ensure("sd1[get_texture_non_temp_udp][enqueued] is 1", (1 == sd1["get_texture_non_temp_udp"]["enqueued"].asInteger()));
 		ensure("sd1[get_texture_temp_udp][enqueued] is 0", (0 == sd1["get_texture_temp_udp"]["enqueued"].asInteger()));
@@ -516,15 +520,15 @@ namespace tut
 
 		// Reset and check zeros...
 		// Reset leaves current region in place
-		gViewerAssetStatsMain->reset();
-		sd = gViewerAssetStatsMain->asLLSD(false);
+		gViewerAssetStats->reset();
+		sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar"));
 		ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle));
 		sd2 = get_region(sd, region2_handle);
 		ensure("Region2 is present in results", sd2.isMap());
 		
-		delete gViewerAssetStatsMain;
-		gViewerAssetStatsMain = NULL;
+		delete gViewerAssetStats;
+		gViewerAssetStats = NULL;
 
 		ensure_equals("sd2[get_texture_non_temp_udp][enqueued] is reset", sd2["get_texture_non_temp_udp"]["enqueued"].asInteger(), 0);
 		ensure_equals("sd2[get_gesture_udp][enqueued] is reset", sd2["get_gesture_udp"]["enqueued"].asInteger(), 0);
@@ -534,8 +538,7 @@ namespace tut
 	template<> template<>
 	void tst_viewerassetstats_index_object_t::test<8>()
 	{
-		gViewerAssetStatsThread1 = new LLViewerAssetStats();
-		gViewerAssetStatsMain = new LLViewerAssetStats();
+		gViewerAssetStats = new LLViewerAssetStats();
 		LLViewerAssetStatsFF::set_region(region1_handle);
 
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
@@ -561,9 +564,7 @@ namespace tut
 
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
 
-		LLSD sd = gViewerAssetStatsThread1->asLLSD(false);
-		ensure("Other collector is empty", is_no_stats_map(sd));
-		sd = gViewerAssetStatsMain->asLLSD(false);
+		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = get_region(sd, region1_handle);
@@ -581,445 +582,14 @@ namespace tut
 
 		// Reset and check zeros...
 		// Reset leaves current region in place
-		gViewerAssetStatsMain->reset();
-		sd = get_region(gViewerAssetStatsMain->asLLSD(false), region1_handle);
+		gViewerAssetStats->reset();
+		sd = get_region(gViewerAssetStats->asLLSD(false), region1_handle);
 		ensure("Region1 is present in results", sd.isMap());
 		
-		delete gViewerAssetStatsMain;
-		gViewerAssetStatsMain = NULL;
-		delete gViewerAssetStatsThread1;
-		gViewerAssetStatsThread1 = NULL;
+		delete gViewerAssetStats;
+		gViewerAssetStats = NULL;
 
 		ensure_equals("sd[get_texture_non_temp_udp][enqueued] is reset", sd["get_texture_non_temp_udp"]["enqueued"].asInteger(), 0);
 		ensure_equals("sd[get_gesture_udp][dequeued] is reset", sd["get_gesture_udp"]["dequeued"].asInteger(), 0);
 	}
-
-
-	// LLViewerAssetStats::merge() basic functions work
-	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<9>()
-	{
-		LLViewerAssetStats s1;
-		LLViewerAssetStats s2;
-
-		s1.setRegion(region1_handle);
-		s2.setRegion(region1_handle);
-
-		s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 5000000);
-		s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 6000000);
-		s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 8000000);
-		s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 7000000);
-		s1.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 9000000);
-		
-		s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 2000000);
-		s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 3000000);
-		s2.recordGetServiced(LLViewerAssetType::AT_TEXTURE, true, true, 4000000);
-
-		s2.merge(s1);
-
-		LLSD s2_llsd = get_region(s2.asLLSD(false), region1_handle);
-		ensure("Region1 is present in results", s2_llsd.isMap());
-		
-		ensure_equals("count after merge", s2_llsd["get_texture_temp_http"]["resp_count"].asInteger(), 8);
-		ensure_approximately_equals("min after merge", s2_llsd["get_texture_temp_http"]["resp_min"].asReal(), 2.0, 22);
-		ensure_approximately_equals("max after merge", s2_llsd["get_texture_temp_http"]["resp_max"].asReal(), 9.0, 22);
-		ensure_approximately_equals("max after merge", s2_llsd["get_texture_temp_http"]["resp_mean"].asReal(), 5.5, 22);
-	}
-
-	// LLViewerAssetStats::merge() basic functions work without corrupting source data
-	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<10>()
-	{
-		LLViewerAssetStats s1;
-		LLViewerAssetStats s2;
-
-		s1.setRegion(region1_handle);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 23289200);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 282900);
-
-		
-		s2.setRegion(region2_handle);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 6500000);
-		s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 10000);
-
-		{
-			s2.merge(s1);
-			
-			LLSD src = s1.asLLSD(false);
-			LLSD dst = s2.asLLSD(false);
-
-			ensure_equals("merge src has single region", src["regions"].size(), 1);
-			ensure_equals("merge dst has dual regions", dst["regions"].size(), 2);
-			
-			// Remove time stamps, they're a problem
-			src.erase("duration");
-			src["regions"][0].erase("duration");
-			dst.erase("duration");
-			dst["regions"][0].erase("duration");
-			dst["regions"][1].erase("duration");
-
-			LLSD s1_llsd = get_region(src, region1_handle);
-			ensure("Region1 is present in src", s1_llsd.isMap());
-			LLSD s2_llsd = get_region(dst, region1_handle);
-			ensure("Region1 is present in dst", s2_llsd.isMap());
-
-			ensure("result from src is in dst", llsd_equals(s1_llsd, s2_llsd));
-		}
-
-		s1.setRegion(region1_handle);
-		s2.setRegion(region1_handle);
-		s1.reset();
-		s2.reset();
-		
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 23289200);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 282900);
-
-		
-		s2.setRegion(region1_handle);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 6500000);
-		s2.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 10000);
-
-		{
-			s2.merge(s1);
-			
-			LLSD src = s1.asLLSD(false);
-			LLSD dst = s2.asLLSD(false);
-
-			ensure_equals("merge src has single region (p2)", src["regions"].size(), 1);
-			ensure_equals("merge dst has single region (p2)", dst["regions"].size(), 1);
-
-			// Remove time stamps, they're a problem
-			src.erase("duration");
-			src["regions"][0].erase("duration");
-			dst.erase("duration");
-			dst["regions"][0].erase("duration");
-			
-			LLSD s1_llsd = get_region(src, region1_handle);
-			ensure("Region1 is present in src", s1_llsd.isMap());
-			LLSD s2_llsd = get_region(dst, region1_handle);
-			ensure("Region1 is present in dst", s2_llsd.isMap());
-
-			ensure_equals("src counts okay (enq)", s1_llsd["get_other"]["enqueued"].asInteger(), 4);
-			ensure_equals("src counts okay (deq)", s1_llsd["get_other"]["dequeued"].asInteger(), 4);
-			ensure_equals("src resp counts okay", s1_llsd["get_other"]["resp_count"].asInteger(), 2);
-			ensure_approximately_equals("src respmin okay", s1_llsd["get_other"]["resp_min"].asReal(), 0.2829, 20);
-			ensure_approximately_equals("src respmax okay", s1_llsd["get_other"]["resp_max"].asReal(), 23.2892, 20);
-			
-			ensure_equals("dst counts okay (enq)", s2_llsd["get_other"]["enqueued"].asInteger(), 12);
-			ensure_equals("src counts okay (deq)", s2_llsd["get_other"]["dequeued"].asInteger(), 11);
-			ensure_equals("dst resp counts okay", s2_llsd["get_other"]["resp_count"].asInteger(), 4);
-			ensure_approximately_equals("dst respmin okay", s2_llsd["get_other"]["resp_min"].asReal(), 0.010, 20);
-			ensure_approximately_equals("dst respmax okay", s2_llsd["get_other"]["resp_max"].asReal(), 23.2892, 20);
-		}
-	}
-
-
-    // Maximum merges are interesting when one side contributes nothing
-	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<11>()
-	{
-		LLViewerAssetStats s1;
-		LLViewerAssetStats s2;
-
-		s1.setRegion(region1_handle);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		// Want to test negative numbers here but have to work in U64
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
-
-		s2.setRegion(region1_handle);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		{
-			s2.merge(s1);
-			
-			LLSD src = s1.asLLSD(false);
-			LLSD dst = s2.asLLSD(false);
-
-			ensure_equals("merge src has single region", src["regions"].size(), 1);
-			ensure_equals("merge dst has single region", dst["regions"].size(), 1);
-			
-			// Remove time stamps, they're a problem
-			src.erase("duration");
-			src["regions"][0].erase("duration");
-			dst.erase("duration");
-			dst["regions"][0].erase("duration");
-
-			LLSD s2_llsd = get_region(dst, region1_handle);
-			ensure("Region1 is present in dst", s2_llsd.isMap());
-			
-			ensure_equals("dst counts come from src only", s2_llsd["get_other"]["resp_count"].asInteger(), 3);
-
-			ensure_approximately_equals("dst maximum with count 0 does not contribute to merged maximum",
-										s2_llsd["get_other"]["resp_max"].asReal(), F64(0.0), 20);
-		}
-
-		// Other way around
-		s1.setRegion(region1_handle);
-		s2.setRegion(region1_handle);
-		s1.reset();
-		s2.reset();
-
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		// Want to test negative numbers here but have to work in U64
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 0);
-
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		{
-			s1.merge(s2);
-			
-			LLSD src = s2.asLLSD(false);
-			LLSD dst = s1.asLLSD(false);
-
-			ensure_equals("merge src has single region", src["regions"].size(), 1);
-			ensure_equals("merge dst has single region", dst["regions"].size(), 1);
-			
-			// Remove time stamps, they're a problem
-			src.erase("duration");
-			src["regions"][0].erase("duration");
-			dst.erase("duration");
-			dst["regions"][0].erase("duration");
-
-			LLSD s2_llsd = get_region(dst, region1_handle);
-			ensure("Region1 is present in dst", s2_llsd.isMap());
-
-			ensure_equals("dst counts come from src only (flipped)", s2_llsd["get_other"]["resp_count"].asInteger(), 3);
-
-			ensure_approximately_equals("dst maximum with count 0 does not contribute to merged maximum (flipped)",
-										s2_llsd["get_other"]["resp_max"].asReal(), F64(0.0), 20);
-		}
-	}
-
-    // Minimum merges are interesting when one side contributes nothing
-	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<12>()
-	{
-		LLViewerAssetStats s1;
-		LLViewerAssetStats s2;
-
-		s1.setRegion(region1_handle);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 3800000);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2700000);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2900000);
-
-		s2.setRegion(region1_handle);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		{
-			s2.merge(s1);
-			
-			LLSD src = s1.asLLSD(false);
-			LLSD dst = s2.asLLSD(false);
-
-			ensure_equals("merge src has single region", src["regions"].size(), 1);
-			ensure_equals("merge dst has single region", dst["regions"].size(), 1);
-			
-			// Remove time stamps, they're a problem
-			src.erase("duration");
-			src["regions"][0].erase("duration");
-			dst.erase("duration");
-			dst["regions"][0].erase("duration");
-
-			LLSD s2_llsd = get_region(dst, region1_handle);
-			ensure("Region1 is present in dst", s2_llsd.isMap());
-
-			ensure_equals("dst counts come from src only", s2_llsd["get_other"]["resp_count"].asInteger(), 3);
-
-			ensure_approximately_equals("dst minimum with count 0 does not contribute to merged minimum",
-										s2_llsd["get_other"]["resp_min"].asReal(), F64(2.7), 20);
-		}
-
-		// Other way around
-		s1.setRegion(region1_handle);
-		s2.setRegion(region1_handle);
-		s1.reset();
-		s2.reset();
-
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s1.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 3800000);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2700000);
-		s1.recordGetServiced(LLViewerAssetType::AT_LSL_BYTECODE, true, true, 2900000);
-
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetEnqueued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-		s2.recordGetDequeued(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
-
-		{
-			s1.merge(s2);
-			
-			LLSD src = s2.asLLSD(false);
-			LLSD dst = s1.asLLSD(false);
-
-			ensure_equals("merge src has single region", src["regions"].size(), 1);
-			ensure_equals("merge dst has single region", dst["regions"].size(), 1);
-			
-			// Remove time stamps, they're a problem
-			src.erase("duration");
-			src["regions"][0].erase("duration");
-			dst.erase("duration");
-			dst["regions"][0].erase("duration");
-
-			LLSD s2_llsd = get_region(dst, region1_handle);
-			ensure("Region1 is present in dst", s2_llsd.isMap());
-
-			ensure_equals("dst counts come from src only (flipped)", s2_llsd["get_other"]["resp_count"].asInteger(), 3);
-
-			ensure_approximately_equals("dst minimum with count 0 does not contribute to merged minimum (flipped)",
-										s2_llsd["get_other"]["resp_min"].asReal(), F64(2.7), 20);
-		}
-	}
-
 }
-- 
cgit v1.2.3


From b9303e9e80ef5c0992c45b0032a219ce9b57d6e8 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 19 Oct 2012 19:42:23 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system removed spam and
 dead code

---
 indra/newview/llviewerassetstats.cpp | 106 -----------------------------------
 1 file changed, 106 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 0b820f866e..e4f64f3076 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -454,114 +454,8 @@ LLSD LLViewerAssetStats::asLLSD(bool compact_output)
 	AssetStats stats;
 	getStats(stats, compact_output);
 	parser.writeSD(sd, stats);
-	llinfos << ll_pretty_print_sd(sd) << llendl;
 	return sd;
 }
-//LLSD LLViewerAssetStats::asLLSD(bool compact_output)
-//{
-//	// Top-level tags
-//	static const LLSD::String tags[LLViewerAssetStatsFF::EVACCount] = 
-//		{
-//			LLSD::String("get_texture_temp_http"),
-//			LLSD::String("get_texture_temp_udp"),
-//			LLSD::String("get_texture_non_temp_http"),
-//			LLSD::String("get_texture_non_temp_udp"),
-//			LLSD::String("get_wearable_udp"),
-//			LLSD::String("get_sound_udp"),
-//			LLSD::String("get_gesture_udp"),
-//			LLSD::String("get_other")
-//		};
-//
-//	// Stats Group Sub-tags.
-//	static const LLSD::String enq_tag("enqueued");
-//	static const LLSD::String deq_tag("dequeued");
-//	static const LLSD::String rcnt_tag("resp_count");
-//	static const LLSD::String rmin_tag("resp_min");
-//	static const LLSD::String rmax_tag("resp_max");
-//	static const LLSD::String rmean_tag("resp_mean");
-//
-//	// MMM Group Sub-tags.
-//	static const LLSD::String cnt_tag("count");
-//	static const LLSD::String min_tag("min");
-//	static const LLSD::String max_tag("max");
-//	static const LLSD::String mean_tag("mean");
-//
-//	// Avatar sub-tags
-//	static const LLSD::String avatar_tag("avatar");
-//	static const LLSD::String avatar_nearby_tag("nearby");
-//	static const LLSD::String avatar_phase_stats_tag("phase_stats");
-//	
-//	const duration_t now = LLViewerAssetStatsFF::get_timestamp();
-//	mCurRegionStats->accumulateTime(now);
-//
-//	LLSD regions = LLSD::emptyArray();
-//	for (PerRegionContainer::iterator it = mRegionStats.begin();
-//		 mRegionStats.end() != it;
-//		 ++it)
-//	{
-//		if (0 == it->first)
-//		{
-//			// Never emit NULL UUID/handle in results.
-//			continue;
-//		}
-//
-//		PerRegionStats & stats = *it->second;
-//		
-//		LLSD reg_stat = LLSD::emptyMap();
-//		
-//		for (int i = 0; i < LL_ARRAY_SIZE(tags); ++i)
-//		{
-//			PerRegionStats::prs_group & group(stats.mRequests[i]);
-//			
-//			if ((! compact_output) ||
-//				group.mEnqueued.getCount() ||
-//				group.mDequeued.getCount() ||
-//				group.mResponse.getCount())
-//			{
-//				LLSD & slot = reg_stat[tags[i]];
-//				slot = LLSD::emptyMap();
-//				slot[enq_tag] = LLSD(S32(stats.mRequests[i].mEnqueued.getCount()));
-//				slot[deq_tag] = LLSD(S32(stats.mRequests[i].mDequeued.getCount()));
-//				slot[rcnt_tag] = LLSD(S32(stats.mRequests[i].mResponse.getCount()));
-//				slot[rmin_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMin() * 1.0e-6));
-//				slot[rmax_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMax() * 1.0e-6));
-//				slot[rmean_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMean() * 1.0e-6));
-//			}
-//		}
-//
-//		if ((! compact_output) || stats.mFPS.getCount())
-//		{
-//			LLSD & slot = reg_stat["fps"];
-//			slot = LLSD::emptyMap();
-//			slot[cnt_tag] = LLSD(S32(stats.mFPS.getCount()));
-//			slot[min_tag] = LLSD(F64(stats.mFPS.getMin()));
-//			slot[max_tag] = LLSD(F64(stats.mFPS.getMax()));
-//			slot[mean_tag] = LLSD(F64(stats.mFPS.getMean()));
-//		}
-//		U32 grid_x(0), grid_y(0);
-//		grid_from_region_handle(it->first, &grid_x, &grid_y);
-//		reg_stat["grid_x"] = LLSD::Integer(grid_x);
-//		reg_stat["grid_y"] = LLSD::Integer(grid_y);
-//		reg_stat["duration"] = LLSD::Real(stats.mTotalTime * 1.0e-6);		
-//		regions.append(reg_stat);
-//	}
-//
-//	LLSD ret = LLSD::emptyMap();
-//	ret["regions"] = regions;
-//	ret["duration"] = LLSD::Real((now - mResetTimestamp) * 1.0e-6);
-//	LLSD avatar_info;
-//	avatar_info[avatar_nearby_tag] = LLSD::emptyArray();
-//	for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat)
-//	{
-//		std::string rez_status_name = LLVOAvatar::rezStatusToString(rez_stat);
-//		avatar_info[avatar_nearby_tag][rez_status_name] = mAvatarRezStates[rez_stat];
-//	}
-//	avatar_info[avatar_phase_stats_tag]["cloud"] = mPhaseStats["cloud"].asLLSD();
-//	avatar_info[avatar_phase_stats_tag]["cloud-or-gray"] = mPhaseStats["cloud-or-gray"].asLLSD();
-//	ret[avatar_tag] = avatar_info;
-//	
-//	return ret;
-//}
 
 // ------------------------------------------------------
 // Global free-function definitions (LLViewerAssetStatsFF namespace)
-- 
cgit v1.2.3


From bfe85fb24b30a24e08b48fdb2c734da0143fe845 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 20 Oct 2012 10:46:57 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system fixed build

---
 indra/newview/lltexturefetch.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index ac83fe0ca8..2a72e77672 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2880,7 +2880,7 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
 	LLViewerAssetStats & main_stats = *mMainStats;
 
 	LLViewerAssetStats::AssetStats stats;
-	main_stats.getStats(stats);
+	main_stats.getStats(stats, true);
 	//LLSD merged_llsd = main_stats.asLLSD();
 
 	stats.session_id = mSessionID;
-- 
cgit v1.2.3


From d8a83466deb4ce7eab047ab6e0c4a6aeee40982c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 22 Oct 2012 10:42:26 -0700
Subject: SH-3405 WIP convert existing stats to lltrace system removed spam and
 dead code

---
 indra/newview/tests/llviewerassetstats_test.cpp | 2 --
 1 file changed, 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index f9d30408ac..fc5cd781e6 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -504,8 +504,6 @@ namespace tut
 		ensure("Region1 is present in results", sd1.isMap());
 		ensure("Region2 is present in results", sd2.isMap());
 		
-		llinfos << ll_pretty_print_sd(sd1) << llendl;
-
 		// Check a few points on the tree for content
 		ensure("sd1[get_texture_non_temp_udp][enqueued] is 1", (1 == sd1["get_texture_non_temp_udp"]["enqueued"].asInteger()));
 		ensure("sd1[get_texture_temp_udp][enqueued] is 0", (0 == sd1["get_texture_temp_udp"]["enqueued"].asInteger()));
-- 
cgit v1.2.3


From 87097e546fa9e160264400f6d9d79d536abbb2fa Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 25 Oct 2012 17:00:34 -0600
Subject: more for SH-3333: avoid repeatedly creating/killing a same object
 from object cache due to occlusion culling.

---
 indra/newview/llvocache.cpp | 47 +++++++++++++++++++++++++++++++++++++++------
 indra/newview/llvocache.h   |  4 +++-
 2 files changed, 44 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 236ce11c7e..fbab5c60e3 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -54,7 +54,9 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mHitCount(0),
 	mDupeCount(0),
 	mCRCChangeCount(0),
-	mState(INACTIVE)
+	mState(INACTIVE),
+	mRepeatedVisCounter(0),
+	mVisFrameRange(64)
 {
 	mBuffer = new U8[dp.getBufferSize()];
 	mDP.assignBuffer(mBuffer, dp.getBufferSize());
@@ -69,7 +71,9 @@ LLVOCacheEntry::LLVOCacheEntry()
 	mDupeCount(0),
 	mCRCChangeCount(0),
 	mBuffer(NULL),
-	mState(INACTIVE)
+	mState(INACTIVE),
+	mRepeatedVisCounter(0),
+	mVisFrameRange(64)
 {
 	mDP.assignBuffer(mBuffer, 0);
 }
@@ -77,7 +81,9 @@ LLVOCacheEntry::LLVOCacheEntry()
 LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), 
 	mBuffer(NULL),
-	mState(INACTIVE)
+	mState(INACTIVE),
+	mRepeatedVisCounter(0),
+	mVisFrameRange(64)
 {
 	S32 size = -1;
 	BOOL success;
@@ -167,12 +173,41 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
 	LLViewerOctreeEntryData::setOctreeEntry(entry);
 }
 
+void LLVOCacheEntry::setState(U32 state)
+{
+	mState = state;
+
+	if(mState == ACTIVE)
+	{
+		const S32 MIN_REAVTIVE_INTERVAL = 20;
+		U32 last_visible = getVisible();
+		
+		setVisible();
+
+		if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mVisFrameRange)
+		{
+			mRepeatedVisCounter++;
+		}
+		else
+		{
+			mRepeatedVisCounter = 0;
+			mVisFrameRange = 64;
+		}
+
+		if(mRepeatedVisCounter > 2) 
+		{
+			//if repeatedly becomes visible immediately after invisible, enlarge the visible frame range
+
+			mRepeatedVisCounter = 0;
+			mVisFrameRange *= 2;
+		}
+	}
+}
+
 //virtual 
 S32  LLVOCacheEntry::getMinVisFrameRange()const
 {
-	const S32 MIN_RANGE = 64; //frames
-
-	return MIN_RANGE;
+	return mVisFrameRange;
 }
 
 void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 85538e8043..2228e3e43b 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -54,7 +54,7 @@ public:
 	LLVOCacheEntry(LLAPRFile* apr_file);
 	LLVOCacheEntry();	
 
-	void setState(U32 state) {mState = state;}
+	void setState(U32 state);
 	bool isState(U32 state)  {return mState == state;}
 	U32  getState() const    {return mState;}
 
@@ -92,6 +92,8 @@ protected:
 	LLDataPackerBinaryBuffer	mDP;
 	U8							*mBuffer;
 
+	S32                         mVisFrameRange;
+	S32                         mRepeatedVisCounter; //number of repeatedly visible within a short time.
 	U32                         mState;
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 };
-- 
cgit v1.2.3


From 09591242f90fa9b24a0be2aad02e91041ac0fcc7 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 25 Oct 2012 18:20:36 -0600
Subject: avoid redundant object creation.

---
 indra/newview/llviewerobjectlist.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index a1db1f7237..d41eee5926 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -338,8 +338,10 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 				objectp->updateRegion(regionp); // for LLVOAvatar
 			}
 		}
-
-		//return TRUE; //already loaded.
+		else
+		{
+			return objectp; //already loaded.
+		}
 	}
 
 	bool justCreated = false;
-- 
cgit v1.2.3


From e35a220bf7dd47132174c81181d5f59fb0d54c5d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 29 Oct 2012 17:13:15 -0600
Subject: for SH-3459: interesting store object bounding information in viewer
 cache

---
 indra/newview/llvocache.cpp | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index fbab5c60e3..f389867484 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -89,6 +89,8 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	BOOL success;
 
 	mDP.assignBuffer(mBuffer, 0);
+	setOctreeEntry(NULL);
+
 	success = check_read(apr_file, &mLocalID, sizeof(U32));
 	if(success)
 	{
@@ -107,6 +109,21 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 		success = check_read(apr_file, &mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
+	{
+		LLVector4 pos;
+		success = check_read(apr_file, (void*)pos.mV, sizeof(LLVector4));
+
+		LLVector4a pos_;
+		pos_.load4a(pos.mV);
+		setPositionGroup(pos_);
+	}
+	if(success)
+	{
+		F32 rad;
+		success = check_read(apr_file, &rad, sizeof(F32));
+		setBinRadius(rad);
+	}
+	if(success)
 	{
 		success = check_read(apr_file, &size, sizeof(S32));
 
@@ -144,6 +161,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 		mDupeCount = 0;
 		mCRCChangeCount = 0;
 		mBuffer = NULL;
+		mEntry = NULL;
 	}
 }
 
@@ -289,6 +307,11 @@ void LLVOCacheEntry::dump() const
 
 BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 {
+	if(!mEntry)
+	{
+		return FALSE;
+	}
+
 	BOOL success;
 	success = check_write(apr_file, (void*)&mLocalID, sizeof(U32));
 	if(success)
@@ -308,6 +331,17 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 		success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
+	{
+		const LLVector4a pos_ = getPositionGroup() ;
+		LLVector4 pos(pos_[0], pos_[1], pos_[2], pos_[3]);
+		success = check_write(apr_file, pos.mV, sizeof(LLVector4));		
+	}
+	if(success)
+	{
+		F32 rad = getBinRadius();
+		success = check_write(apr_file, (void*)&rad, sizeof(F32));
+	}
+	if(success)
 	{
 		S32 size = mDP.getBufferSize();
 		success = check_write(apr_file, (void*)&size, sizeof(S32));
-- 
cgit v1.2.3


From 5ae116f89b8459963ccb6ae9125d94ffaa79025e Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 31 Oct 2012 17:05:53 -0600
Subject: for SH-3471: create a simplified version of octree for object cache
 entries.

---
 indra/newview/llspatialpartition.cpp | 108 ++++++----------------
 indra/newview/llspatialpartition.h   |  49 ++--------
 indra/newview/llvieweroctree.cpp     |  48 +++++++++-
 indra/newview/llvieweroctree.h       |  39 +++++++-
 indra/newview/llviewerregion.cpp     | 174 ++++++++++++++++++++++++-----------
 indra/newview/llviewerregion.h       |  14 ++-
 indra/newview/llvocache.cpp          |  77 ++++++++++++++++
 indra/newview/llvocache.h            |  13 +++
 indra/newview/pipeline.cpp           |  20 ++--
 9 files changed, 346 insertions(+), 196 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index debb790c58..e9ece331d1 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -264,11 +264,7 @@ LLSpatialGroup::~LLSpatialGroup()
 	{
 		llerrs << "Illegal deletion of LLSpatialGroup!" << llendl;
 	}*/
-	if(isVisible())
-	{
-		mSpatialPartition->mRegionp->clearVisibleGroup(this);
-	}
-
+	
 	if (gDebugGL)
 	{
 		gPipeline.checkReferences(this);
@@ -434,16 +430,6 @@ BOOL LLSpatialGroup::isRecentlyVisible() const
 	return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < MIN_VIS_FRAME_RANGE ;
 }
 
-BOOL LLSpatialGroup::isVisible() const
-{
-	return mVisible[LLViewerCamera::sCurCameraID] >= LLDrawable::getCurrentFrame() ? TRUE : FALSE;
-}
-
-void LLSpatialGroup::setVisible()
-{
-	mVisible[LLViewerCamera::sCurCameraID] = LLDrawable::getCurrentFrame();
-}
-
 void LLSpatialGroup::validate()
 {
 	ll_assert_aligned(this,64);
@@ -1165,12 +1151,6 @@ BOOL LLSpatialGroup::changeLOD()
 
 void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* entry)
 {
-	if(mSpatialPartition->isVOCachePartition())
-	{
-		LLviewerOctreeGroup::handleInsertion(node, entry);
-		return;
-	}
-		
 	addObject((LLDrawable*)entry->getDrawable());
 	unbound();
 	setState(OBJECT_DIRTY);
@@ -1178,10 +1158,7 @@ void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry*
 
 void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* entry)
 {
-	if(!mSpatialPartition->isVOCachePartition())
-	{
-		removeObject((LLDrawable*)entry->getDrawable(), TRUE);
-	}
+	removeObject((LLDrawable*)entry->getDrawable(), TRUE);
 	LLviewerOctreeGroup::handleRemoval(node, entry);
 }
 
@@ -1189,12 +1166,6 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
 {
 	setState(DEAD);
 
-	if(mSpatialPartition->isVOCachePartition())
-	{
-		LLviewerOctreeGroup::handleDestruction(node);
-		return;
-	}
-
 	for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
 	{
 		LLViewerOctreeEntry* entry = *i;
@@ -1510,8 +1481,9 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera)
 //==============================================
 
 LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 buffer_usage, LLViewerRegion* regionp)
-: mRenderByGroup(render_by_group), mBridge(NULL), mRegionp(regionp)
+: mRenderByGroup(render_by_group), mBridge(NULL)
 {
+	mRegionp = regionp;
 	mOcclusionEnabled = TRUE;
 	mDrawableType = 0;
 	mPartitionType = LLViewerRegion::PARTITION_NONE;
@@ -1521,27 +1493,14 @@ LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32
 	mBufferUsage = buffer_usage;
 	mDepthMask = FALSE;
 	mSlopRatio = 0.25f;
-	mInfiniteFarClip = FALSE;
-	mVisitedTime = 0;
-
-	LLVector4a center, size;
-	center.splat(0.f);
-	size.splat(1.f);
+	mInfiniteFarClip = FALSE;	
 
-	mOctree = new OctreeRoot(center,size, NULL);
 	new LLSpatialGroup(mOctree, this);
 }
 
 
 LLSpatialPartition::~LLSpatialPartition()
-{
-	delete mOctree;
-	mOctree = NULL;
-}
-
-BOOL LLSpatialPartition::isVOCachePartition() const
-{
-	return mPartitionType == LLViewerRegion::PARTITION_VO_CACHE;
+{	
 }
 
 LLSpatialGroup *LLSpatialPartition::put(LLDrawable *drawablep, BOOL was_visible)
@@ -2050,12 +2009,7 @@ BOOL LLSpatialPartition::visibleObjectsInFrustum(LLCamera& camera)
 
 S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* results, BOOL for_select)
 {
-	bool is_vo_cache_part = (mPartitionType == LLViewerRegion::PARTITION_VO_CACHE);
-	
-	if(is_vo_cache_part && mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame())
-	{
-		return 0; //no need to visit more than once per frame
-	}		
+	llassert(results != NULL && for_select);
 
 #if LL_OCTREE_PARANOIA_CHECK
 	((LLSpatialGroup*)mOctree->getListener(0))->checkStates();
@@ -2070,19 +2024,34 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* result
 	((LLSpatialGroup*)mOctree->getListener(0))->validate();
 #endif
 
+	LLOctreeSelect selecter(&camera, results);
+	selecter.traverse(mOctree);
 	
-	if (for_select && !is_vo_cache_part)
+	return 0;
+}
+
+S32 LLSpatialPartition::cull(LLCamera &camera)
+{
+#if LL_OCTREE_PARANOIA_CHECK
+	((LLSpatialGroup*)mOctree->getListener(0))->checkStates();
+#endif
 	{
-		LLOctreeSelect selecter(&camera, results);
-		selecter.traverse(mOctree);
+		LLFastTimer ftm(FTM_CULL_REBOUND);		
+		LLSpatialGroup* group = (LLSpatialGroup*) mOctree->getListener(0);
+		group->rebound();
 	}
-	else if (LLPipeline::sShadowRender && !is_vo_cache_part)
+
+#if LL_OCTREE_PARANOIA_CHECK
+	((LLSpatialGroup*)mOctree->getListener(0))->validate();
+#endif
+
+	if (LLPipeline::sShadowRender)
 	{
 		LLFastTimer ftm(FTM_FRUSTUM_CULL);
 		LLOctreeCullShadow culler(&camera);
 		culler.traverse(mOctree);
 	}
-	else if ((mInfiniteFarClip || !LLPipeline::sUseFarClip) && !is_vo_cache_part)
+	else if (mInfiniteFarClip || !LLPipeline::sUseFarClip)
 	{
 		LLFastTimer ftm(FTM_FRUSTUM_CULL);		
 		LLOctreeCullNoFarClip culler(&camera);
@@ -2090,11 +2059,6 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* result
 	}
 	else
 	{
-		if(is_vo_cache_part)
-		{
-			mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame();
-		}
-
 		LLFastTimer ftm(FTM_FRUSTUM_CULL);		
 		LLOctreeCull culler(&camera);
 		culler.traverse(mOctree);
@@ -4663,21 +4627,3 @@ void LLCullResult::assertDrawMapsEmpty()
 	}
 }
 
-LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp) : LLSpatialPartition(0, FALSE, 0, regionp)
-{
-	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
-}
-
-void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
-{
-	llassert(entry->hasVOCacheEntry());
-
-	mOctree->insert(entry);
-}
-	
-void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
-{
-	entry->getVOCacheEntry()->setGroup(NULL);
-
-	llassert(!entry->getGroup());
-}
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index dd189d751d..079c0f58f0 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -45,6 +45,7 @@
 #define SG_STATE_INHERIT_MASK (OCCLUDED)
 #define SG_INITIAL_STATE_MASK (DIRTY | GEOM_DIRTY)
 
+class LLViewerOctreePartition;
 class LLSpatialPartition;
 class LLSpatialBridge;
 class LLSpatialGroup;
@@ -225,10 +226,7 @@ public:
 	typedef std::map<U32, drawmap_elem_t > draw_map_t;	
 	typedef std::vector<LLPointer<LLVertexBuffer> > buffer_list_t;
 	typedef std::map<LLFace*, buffer_list_t> buffer_texture_map_t;
-	typedef std::map<U32, buffer_texture_map_t> buffer_map_t;
-
-	typedef LLOctreeNode<LLViewerOctreeEntry>::element_iter element_iter;
-	typedef LLOctreeNode<LLViewerOctreeEntry>::element_list element_list;
+	typedef std::map<U32, buffer_texture_map_t> buffer_map_t;	
 
 	struct CompareDistanceGreater
 	{
@@ -308,9 +306,7 @@ public:
 	BOOL addObject(LLDrawable *drawablep);
 	BOOL removeObject(LLDrawable *drawablep, BOOL from_octree = FALSE);
 	BOOL updateInGroup(LLDrawable *drawablep, BOOL immediate = FALSE); // Update position if it's in the group
-	BOOL isVisible() const;
 	BOOL isRecentlyVisible() const;
-	void setVisible();
 	void shift(const LLVector4a &offset);
 	void checkOcclusion(); //read back last occlusion query (if any)
 	void doOcclusion(LLCamera* camera); //issue occlusion query
@@ -325,14 +321,7 @@ public:
 
 	void setState(U32 state)       {mState |= state;}
 	void dirtyGeom() { setState(GEOM_DIRTY); }
-	void dirtyMesh() { setState(MESH_DIRTY); }
-
-	//octree wrappers to make code more readable
-	element_list& getData() { return mOctreeNode->getData(); }
-	element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
-	element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
-	U32 getElementCount() const { return mOctreeNode->getElementCount(); }
-	bool isEmpty() const { return mOctreeNode->isEmpty(); }
+	void dirtyMesh() { setState(MESH_DIRTY); }		
 
 	void drawObjectBox(LLColor4 col);
 
@@ -404,8 +393,7 @@ public:
 
 	U32 mBufferUsage;
 	draw_map_t mDrawMap;
-	
-	S32 mVisible[LLViewerCamera::NUM_CAMERAS];
+		
 	F32 mDistance;
 	F32 mDepth;
 	F32 mLastUpdateDistance;
@@ -428,7 +416,7 @@ public:
 	virtual LLVertexBuffer* createVertexBuffer(U32 type_mask, U32 usage);
 };
 
-class LLSpatialPartition: public LLGeometryManager
+class LLSpatialPartition: public LLViewerOctreePartition, public LLGeometryManager
 {
 public:
 	LLSpatialPartition(U32 data_mask,  BOOL render_by_group, U32 mBufferUsage, LLViewerRegion* regionp);
@@ -458,7 +446,8 @@ public:
 	virtual void rebuildMesh(LLSpatialGroup* group);
 
 	BOOL visibleObjectsInFrustum(LLCamera& camera);
-	S32 cull(LLCamera &camera, std::vector<LLDrawable *>* results = NULL, BOOL for_select = FALSE); // Cull on arbitrary frustum
+	/*virtual*/ S32 cull(LLCamera &camera); // Cull on arbitrary frustum
+	S32 cull(LLCamera &camera, std::vector<LLDrawable *>* results, BOOL for_select); // Cull on arbitrary frustum
 	
 	BOOL isVisible(const LLVector3& v);
 	bool isHUDPartition() ;
@@ -473,26 +462,21 @@ public:
 	void resetVertexBuffers();
 	BOOL isOcclusionEnabled();
 	BOOL getVisibleExtents(LLCamera& camera, LLVector3& visMin, LLVector3& visMax);
-	BOOL isVOCachePartition() const;
-
+	
 public:
-	OctreeNode*      mOctree;
 	LLSpatialBridge* mBridge; // NULL for non-LLSpatialBridge instances, otherwise, mBridge == this
 							// use a pointer instead of making "isBridge" and "asBridge" virtual so it's safe
 							// to call asBridge() from the destructor
 	BOOL mOcclusionEnabled; // if TRUE, occlusion culling is performed
 	BOOL mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane
 	U32 mBufferUsage;
+	U32   mDrawableType;
 	const BOOL mRenderByGroup;
 	U32 mLODSeed;
 	U32 mLODPeriod;	//number of frames between LOD updates for a given spatial group (staggered by mLODSeed)
 	U32 mVertexDataMask;
 	F32 mSlopRatio; //percentage distance must change before drawables receive LOD update (default is 0.25);
-	BOOL mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering
-	U32 mDrawableType;
-	U32 mPartitionType;
-	U32 mVisitedTime;
-	LLViewerRegion* mRegionp; // the region this partition belongs to.
+	BOOL mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering	
 };
 
 // class for creating bridges between spatial partitions
@@ -638,19 +622,6 @@ public:
 	LLVoidWaterPartition(LLViewerRegion* regionp);
 };
 
-//spatial partition for hole and edge water (implemented in LLVOWater.cpp)
-class LLVOCachePartition : public LLSpatialPartition
-{
-public:
-	LLVOCachePartition(LLViewerRegion* regionp);
-
-	void addEntry(LLViewerOctreeEntry* entry);
-	void removeEntry(LLViewerOctreeEntry* entry);
-
-	virtual void getGeometry(LLSpatialGroup* group) {  }
-	virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
-};
-
 //spatial partition for terrain (impelmented in LLVOSurfacePatch.cpp)
 class LLTerrainPartition : public LLSpatialPartition
 {
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 05f977036c..143f2a6819 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -26,6 +26,7 @@
 
 #include "llviewerprecompiledheaders.h"
 #include "llvieweroctree.h"
+#include "llviewerregion.h"
 
 //-----------------------------------------------------------------------------------
 //static variables definitions
@@ -324,6 +325,10 @@ void LLViewerOctreeEntryData::setVisible() const
 
 LLviewerOctreeGroup::~LLviewerOctreeGroup()
 {
+	if(LLViewerRegion::sCurRegionp && isVisible())
+	{
+		LLViewerRegion::sCurRegionp->clearVisibleGroup(this);
+	}
 }
 
 LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) :
@@ -482,8 +487,10 @@ void LLviewerOctreeGroup::handleDestruction(const TreeNode* node)
 		if (obj && obj->getGroup() == this)
 		{
 			obj->nullGroup();
+			//obj->setGroup(NULL);
 		}
 	}
+	mOctreeNode = NULL;
 }
 	
 //virtual 
@@ -500,8 +507,17 @@ void LLviewerOctreeGroup::handleStateChange(const TreeNode* node)
 //virtual 
 void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child)
 {
-	llerrs << "can not access here. It is an abstract class." << llendl;
+	if (child->getListenerCount() == 0)
+	{
+		new LLviewerOctreeGroup(child);
+	}
+	else
+	{
+		OCT_ERRS << "LLSpatialGroup redundancy detected." << llendl;
+	}
 
+	unbound();
+	
 	//((LLviewerOctreeGroup*)child->getListener(0))->unbound();
 }
 	
@@ -589,7 +605,35 @@ bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4
 //virtual 
 BOOL LLviewerOctreeGroup::isVisible() const
 {
-	return TRUE;
+	return mVisible[LLViewerCamera::sCurCameraID] >= LLViewerOctreeEntryData::getCurrentFrame() ? TRUE : FALSE;
+}
+
+//virtual 
+BOOL LLviewerOctreeGroup::isRecentlyVisible() const 
+{
+	return FALSE;
+}
+
+void LLviewerOctreeGroup::setVisible()
+{
+	mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
+}
+//-----------------------------------------------------------------------------------
+//class LLViewerOctreePartition definitions
+//-----------------------------------------------------------------------------------
+LLViewerOctreePartition::LLViewerOctreePartition() : mRegionp(NULL)
+{
+	LLVector4a center, size;
+	center.splat(0.f);
+	size.splat(1.f);
+
+	mOctree = new OctreeRoot(center,size, NULL);
+}
+	
+LLViewerOctreePartition::~LLViewerOctreePartition()
+{
+	delete mOctree;
+	mOctree = NULL;
 }
 
 //-----------------------------------------------------------------------------------
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index c063e96ea5..498ec3e75d 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -37,8 +37,9 @@
 #include "llvector4a.h"
 #include "llquaternion.h"
 #include "lloctree.h"
-#include "llcamera.h"
+#include "llviewercamera.h"
 
+class LLViewerRegion;
 class LLViewerOctreeEntryData;
 class LLviewerOctreeGroup;
 class LLViewerOctreeEntry;
@@ -181,6 +182,9 @@ public:
 	};
 
 public:
+	typedef LLOctreeNode<LLViewerOctreeEntry>::element_iter element_iter;
+	typedef LLOctreeNode<LLViewerOctreeEntry>::element_list element_list;
+
 	LLviewerOctreeGroup(OctreeNode* node);
 	LLviewerOctreeGroup(const LLviewerOctreeGroup& rhs)
 	{
@@ -203,8 +207,10 @@ public:
 	virtual void unbound();
 	virtual void rebound();
 
-	virtual BOOL isVisible() const;
-	virtual BOOL isRecentlyVisible() const = 0;
+	void setVisible();
+	BOOL isVisible() const;
+	virtual BOOL isRecentlyVisible() const;
+	bool isEmpty() const { return mOctreeNode->isEmpty(); }
 
 	U32  getState()				   {return mState; }
 	bool isDirty() const           {return mState & DIRTY;}
@@ -228,20 +234,43 @@ public:
 	const LLVector4a* getObjectBounds() const  {return mObjectBounds;}
 	const LLVector4a* getObjectExtents() const {return mObjectExtents;}
 
+	//octree wrappers to make code more readable
+	element_list& getData() { return mOctreeNode->getData(); }
+	element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
+	element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
+	U32 getElementCount() const { return mOctreeNode->getElementCount(); }	
+
 private:
 	virtual bool boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut);	
 	
 protected:
 	U32         mState;
-	OctreeNode* mOctreeNode;
-	
+	OctreeNode* mOctreeNode;	
+
 	LL_ALIGN_16(LLVector4a mBounds[2]);       // bounding box (center, size) of this node and all its children (tight fit to objects)
 	LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
 	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
 	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
 
+public:
+	S32         mVisible[LLViewerCamera::NUM_CAMERAS];
 }LL_ALIGN_POSTFIX(16);
 
+class LLViewerOctreePartition
+{
+public:
+	LLViewerOctreePartition();
+	virtual ~LLViewerOctreePartition();
+
+	// Cull on arbitrary frustum
+	virtual S32 cull(LLCamera &camera) = 0;
+
+public:	
+	U32              mPartitionType;
+	OctreeNode*      mOctree;
+	LLViewerRegion*  mRegionp; // the region this partition belongs to.
+};
+
 class LLViewerOctreeCull : public OctreeTraveler
 {
 public:
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 0c0522d32f..1adab15d70 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -86,6 +86,8 @@ const F32 CAP_REQUEST_TIMEOUT = 18;
 // Even though we gave up on login, keep trying for caps after we are logged in:
 const S32 MAX_CAP_REQUEST_ATTEMPTS = 30;
 
+LLViewerRegion* LLViewerRegion::sCurRegionp = NULL;
+
 typedef std::map<std::string, std::string> CapabilityMap;
 
 class LLViewerRegionImpl {
@@ -139,7 +141,7 @@ public:
 	LLVOCacheEntry::vocache_entry_set_t mWaitingSet; //entries waiting for LLDrawable to be generated.
 	LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //visible root entries of a linked set.
 	std::set< LLPointer<LLVOCacheEntry> > mDummyEntries; //dummy vo cache entries, for LLSpatialBridge use.
-	std::set< LLSpatialGroup* >         mVisibleGroups; //visible llspatialgroup
+	std::set< LLviewerOctreeGroup* >      mVisibleGroups; //visible llspatialgroup
 	LLVOCachePartition*                 mVOCachePartition;
 
 	// time?
@@ -165,7 +167,7 @@ public:
 	LLCapabilityListener mCapabilityListener;
 
 	//spatial partitions for objects in this region
-	std::vector<LLSpatialPartition*> mObjectPartition;
+	std::vector<LLViewerOctreePartition*> mObjectPartition;
 };
 
 // support for secondlife:///app/region/{REGION} SLapps
@@ -345,7 +347,7 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 	mImpl->mObjectPartition.push_back(new LLVOCachePartition(this)); //PARTITION_VO_CACHE
 	mImpl->mObjectPartition.push_back(NULL);						//PARTITION_NONE
 
-	mImpl->mVOCachePartition = (LLVOCachePartition*)getSpatialPartition(PARTITION_VO_CACHE);
+	mImpl->mVOCachePartition = getVOCachePartition();
 }
 
 
@@ -384,12 +386,12 @@ LLViewerRegion::~LLViewerRegion()
 	delete mParcelOverlay;
 	delete mImpl->mLandp;
 	delete mImpl->mEventPoll;
-	LLHTTPSender::clearSender(mImpl->mHost);
-	
-	saveObjectCache();
+	LLHTTPSender::clearSender(mImpl->mHost);	
 
 	std::for_each(mImpl->mObjectPartition.begin(), mImpl->mObjectPartition.end(), DeletePointer());
 
+	saveObjectCache();
+
 	delete mImpl;
 	mImpl = NULL;
 }
@@ -865,13 +867,13 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 	entry->setState(LLVOCacheEntry::INACTIVE);
 }
 
-void LLViewerRegion::addVisibleGroup(LLSpatialGroup* group)
+void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
 {
-	if(mDead || group->isEmpty() || group->isDead())
+	if(mDead || group->isEmpty())
 	{
 		return;
 	}
-
+	group->setVisible();
 	mImpl->mVisibleGroups.insert(group);
 }
 
@@ -909,7 +911,7 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 	mImpl->mVisibleEntries.insert(entry);
 }
 
-void LLViewerRegion::clearVisibleGroup(LLSpatialGroup* group)
+void LLViewerRegion::clearVisibleGroup(LLviewerOctreeGroup* group)
 {
 	if(mDead)
 	{
@@ -920,44 +922,18 @@ void LLViewerRegion::clearVisibleGroup(LLSpatialGroup* group)
 
 	mImpl->mVisibleGroups.erase(group);
 }
-
-BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
-{
-	LLTimer update_timer;
-
-	// did_update returns TRUE if we did at least one significant update
-	BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time);
 	
-	if (mParcelOverlay)
-	{
-		// Hopefully not a significant time sink...
-		mParcelOverlay->idleUpdate();
-	}
-
-	if(update_timer.getElapsedTimeF32() > max_update_time)
-	{
-		return did_update;
-	}
-
-	//kill invisible objects
-	std::vector<LLDrawable*> delete_list;
-	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
-		iter != mImpl->mActiveSet.end(); ++iter)
-	{
-		if(!(*iter)->isRecentlyVisible())
-		{
-			killObject((*iter), delete_list);
-		}
-	}
-	for(S32 i = 0; i < delete_list.size(); i++)
+//return time left
+F32 LLViewerRegion::addLinkedSetChildren(F32 max_time, S32& max_num_objects)
+{
+	if(mImpl->mVisibleEntries.empty())
 	{
-		gObjectList.killObject(delete_list[i]->getVObj());
+		return max_time;
 	}
-	delete_list.clear();
 
+	LLTimer update_timer;
 	bool timeout = false;
-	S32 new_object_count = 64; //minimum number of new objects to be added
-	//add childrens of visible objects to the rendering pipeline
+
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
 	{
 		LLVOCacheEntry* entry = *iter;				
@@ -968,9 +944,9 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 			{
 				addNewObject(child);
 				
-				if(new_object_count-- < 0 && update_timer.getElapsedTimeF32() > max_update_time)
+				if(max_num_objects-- < 0 && update_timer.getElapsedTimeF32() > max_time)
 				{
-					timeout = true;
+					timeout = true; //timeout
 					break;
 				}
 			}
@@ -982,7 +958,10 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 			{
 				mImpl->mDummyEntries.erase(entry);
 			}
-
+		}
+		
+		if(!timeout)
+		{
 			iter = mImpl->mVisibleEntries.erase(iter);
 		}
 		else
@@ -990,17 +969,28 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 			break; //timeout
 		}
 	}
+
 	if(timeout)
 	{
-		mImpl->mVisibleGroups.clear();
-		return did_update;
+		return -1.f;
 	}
+	return max_time - update_timer.getElapsedTimeF32(); //time left
+}
 
-	//add objects in the visible groups to the rendering pipeline
-	std::set< LLSpatialGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
+F32 LLViewerRegion::addVisibleObjects(F32 max_time, S32& max_num_objects)
+{
+	if(mImpl->mVisibleGroups.empty())
+	{
+		return max_time;
+	}
+
+	LLTimer update_timer;
+	bool timeout = false;
+
+	std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
 	while(group_iter != mImpl->mVisibleGroups.end())
 	{
-		LLSpatialGroup* group = *group_iter;
+		LLviewerOctreeGroup* group = *group_iter;
 		if(!group->getOctreeNode() || group->isEmpty())
 		{
 			mImpl->mVisibleGroups.erase(group_iter);
@@ -1009,7 +999,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 		}
 
 		std::vector<LLViewerOctreeEntry*> entry_list;
-		for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+		for (LLviewerOctreeGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 		{
 			//group data contents could change during creating new objects, so copy all contents first.
 			entry_list.push_back(*i);
@@ -1028,7 +1018,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 				else if(vo_entry->isState(LLVOCacheEntry::INACTIVE))
 				{
 					addNewObject(vo_entry);
-					if(new_object_count-- < 0 && update_timer.getElapsedTimeF32() > max_update_time)
+					if(max_num_objects-- < 0 && update_timer.getElapsedTimeF32() > max_time)
 					{
 						timeout = true;
 						break;
@@ -1044,12 +1034,75 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 		}
 		mImpl->mVisibleGroups.erase(group);
 		group_iter = mImpl->mVisibleGroups.begin();
+	}	
+
+	if(timeout)
+	{
+		return -1.0f;
 	}
-	mImpl->mVisibleGroups.clear();
+	return max_time - update_timer.getElapsedTimeF32();
+}
+
+BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
+{
+	LLTimer update_timer;
 
+	// did_update returns TRUE if we did at least one significant update
+	BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time);
+	
+	if (mParcelOverlay)
+	{
+		// Hopefully not a significant time sink...
+		mParcelOverlay->idleUpdate();
+	}
+
+	max_update_time -= update_timer.getElapsedTimeF32();
+	if(max_update_time < 0.f)
+	{
+		return did_update;
+	}
+
+	sCurRegionp = this;
+
+	//kill invisible objects
+	max_update_time = killInvisibleObjects(max_update_time);
+
+	S32 new_object_count = 64; //minimum number of new objects to be added
+	
+	//add childrens of visible objects to the rendering pipeline
+	max_update_time = addLinkedSetChildren(max_update_time, new_object_count);
+
+	//add objects in the visible groups to the rendering pipeline
+	if(max_update_time > 0.f)
+	{
+		addVisibleObjects(max_update_time, new_object_count);
+	}
+
+	mImpl->mVisibleGroups.clear();
+	sCurRegionp = NULL;
 	return did_update;
 }
 
+F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
+{
+	std::vector<LLDrawable*> delete_list;
+	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
+		iter != mImpl->mActiveSet.end(); ++iter)
+	{
+		if(!(*iter)->isRecentlyVisible())
+		{
+			killObject((*iter), delete_list);
+		}
+	}
+	for(S32 i = 0; i < delete_list.size(); i++)
+	{
+		gObjectList.killObject(delete_list[i]->getVObj());
+	}
+	delete_list.clear();
+
+	return max_time;
+}
+
 void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list)
 {
 	//kill the object.
@@ -2189,9 +2242,18 @@ void LLViewerRegion::logActiveCapabilities() const
 
 LLSpatialPartition* LLViewerRegion::getSpatialPartition(U32 type)
 {
-	if (type < mImpl->mObjectPartition.size())
+	if (type < mImpl->mObjectPartition.size() && type < PARTITION_VO_CACHE)
+	{
+		return (LLSpatialPartition*)mImpl->mObjectPartition[type];
+	}
+	return NULL;
+}
+
+LLVOCachePartition* LLViewerRegion::getVOCachePartition()
+{
+	if(PARTITION_VO_CACHE < mImpl->mObjectPartition.size())
 	{
-		return mImpl->mObjectPartition[type];
+		return (LLVOCachePartition*)mImpl->mObjectPartition[PARTITION_VO_CACHE];
 	}
 	return NULL;
 }
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 17654a8bc7..86d3ee0d8c 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -69,6 +69,8 @@ class LLBBox;
 class LLSpatialGroup;
 class LLDrawable;
 class LLViewerRegionImpl;
+class LLviewerOctreeGroup;
+class LLVOCachePartition;
 
 class LLViewerRegion: public LLCapabilityProvider // implements this interface
 {
@@ -85,7 +87,7 @@ public:
 		PARTITION_GRASS,
 		PARTITION_VOLUME,
 		PARTITION_BRIDGE,
-		PARTITION_HUD_PARTICLE,
+		PARTITION_HUD_PARTICLE,		
 		PARTITION_VO_CACHE,
 		PARTITION_NONE,
 		NUM_PARTITIONS
@@ -218,12 +220,12 @@ public:
 	F32	getWidth() const						{ return mWidth; }
 
 	BOOL idleUpdate(F32 max_update_time);
-	void addVisibleGroup(LLSpatialGroup* group);
+	void addVisibleGroup(LLviewerOctreeGroup* group);
 	void addVisibleCacheEntry(LLVOCacheEntry* entry);
 	void addActiveCacheEntry(LLVOCacheEntry* entry);
 	void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep);	
 	void killCacheEntry(U32 local_id); //physically delete the cache entry	
-	void clearVisibleGroup(LLSpatialGroup* group);
+	void clearVisibleGroup(LLviewerOctreeGroup* group);
 
 	// Like idleUpdate, but forces everything to complete regardless of
 	// how long it takes.
@@ -333,6 +335,7 @@ public:
 
 	U32 getNumOfActiveCachedObjects() const;
 	LLSpatialPartition* getSpatialPartition(U32 type);
+	LLVOCachePartition* getVOCachePartition();
 
 	bool objectIsReturnable(const LLVector3& pos, const std::vector<LLBBox>& boxes) const;
 	bool childrenObjectReturnable( const std::vector<LLBBox>& boxes ) const;
@@ -350,6 +353,10 @@ private:
 	void replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
 	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
 
+	F32 killInvisibleObjects(F32 max_time);
+	F32 addLinkedSetChildren(F32 max_time, S32& max_num_objects);
+	F32 addVisibleObjects(F32 max_time, S32& max_num_objects);
+
 public:
 	struct CompareDistance
 	{
@@ -384,6 +391,7 @@ public:
 	LLDynamicArray<U32> mMapAvatars;
 	LLDynamicArray<LLUUID> mMapAvatarIDs;
 
+	static LLViewerRegion* sCurRegionp;
 private:
 	LLViewerRegionImpl * mImpl;
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index f389867484..d4938fd216 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -31,6 +31,7 @@
 #include "llviewercontrol.h"
 #include "llviewerobjectlist.h"
 #include "lldrawable.h"
+#include "llviewerregion.h"
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
@@ -355,6 +356,82 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 	return success ;
 }
 
+//-------------------------------------------------------------------
+//LLVOCachePartition
+//-------------------------------------------------------------------
+LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
+{
+	mRegionp = regionp;
+	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
+	mVisitedTime = 0;
+
+	new LLviewerOctreeGroup(mOctree);
+}
+
+void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
+{
+	llassert(entry->hasVOCacheEntry());
+
+	mOctree->insert(entry);
+}
+	
+void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
+{
+	entry->getVOCacheEntry()->setGroup(NULL);
+
+	llassert(!entry->getGroup());
+}
+	
+class LLVOCacheOctreeCull : public LLViewerOctreeCull
+{
+public:
+	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp) : LLViewerOctreeCull(camera), mRegionp(regionp) {}
+
+	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
+	{
+		S32 res = AABBInFrustumNoFarClipGroupBounds(group);
+		if (res != 0)
+		{
+			res = llmin(res, AABBSphereIntersectGroupExtents(group));
+		}
+		return res;
+	}
+
+	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
+	{
+		S32 res = AABBInFrustumNoFarClipObjectBounds(group);
+		if (res != 0)
+		{
+			res = llmin(res, AABBSphereIntersectObjectExtents(group));
+		}
+		return res;
+	}
+
+	virtual void processGroup(LLviewerOctreeGroup* base_group)
+	{
+		mRegionp->addVisibleGroup(base_group);
+	}
+
+private:
+	LLViewerRegion* mRegionp;
+};
+
+S32 LLVOCachePartition::cull(LLCamera &camera)
+{
+	if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame())
+	{
+		return 0; //already visited.
+	}
+	mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame();
+
+	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
+		
+	LLVOCacheOctreeCull culler(&camera, mRegionp);
+	culler.traverse(mOctree);
+
+	return 0;
+}
+
 //-------------------------------------------------------------------
 //LLVOCache
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 2228e3e43b..675c12a3eb 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -98,6 +98,19 @@ protected:
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 };
 
+class LLVOCachePartition : public LLViewerOctreePartition
+{
+public:
+	LLVOCachePartition(LLViewerRegion* regionp);
+
+	void addEntry(LLViewerOctreeEntry* entry);
+	void removeEntry(LLViewerOctreeEntry* entry);
+	/*virtual*/ S32 cull(LLCamera &camera);
+
+private:
+	U32 mVisitedTime;
+};
+
 //
 //Note: LLVOCache is not thread-safe
 //
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e06577c512..850714f676 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -86,6 +86,7 @@
 #include "llviewerregion.h" // for audio debugging.
 #include "llviewerwindow.h" // For getSpinAxis
 #include "llvoavatarself.h"
+#include "llvocache.h"
 #include "llvoground.h"
 #include "llvosky.h"
 #include "llvotree.h"
@@ -2352,12 +2353,15 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 				{
 					part->cull(camera);
 				}
-				else if(part->mPartitionType == LLViewerRegion::PARTITION_VO_CACHE)
-				{
-					part->cull(camera);
-				}
 			}
 		}
+
+		//scan the VO Cache tree
+		LLVOCachePartition* vo_part = region->getVOCachePartition();
+		if(vo_part)
+		{
+			vo_part->cull(camera);
+		}
 	}
 
 	if (bound_shader)
@@ -2433,12 +2437,8 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
 	}
 
 	assertInitialized();
-	
-	if(group->mSpatialPartition->mPartitionType == LLViewerRegion::PARTITION_VO_CACHE)
-	{
-		group->mSpatialPartition->mRegionp->addVisibleGroup(group);
-	}
-	else if (!group->mSpatialPartition->mRenderByGroup)
+		
+	if (!group->mSpatialPartition->mRenderByGroup)
 	{ //render by drawable
 		sCull->pushDrawableGroup(group);
 	}
-- 
cgit v1.2.3


From 819adb5eb4d7f982121f3dbd82750e05d26864d9 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 1 Nov 2012 00:26:44 -0700
Subject: SH-3405 FIX convert existing stats to lltrace system final removal of
 remaining LLStat code

---
 indra/newview/llagentcamera.cpp      |  4 ++--
 indra/newview/llappviewer.cpp        |  3 +++
 indra/newview/llfasttimerview.cpp    |  1 -
 indra/newview/llfloaterjoystick.cpp  | 17 +++++++++++++----
 indra/newview/llfloaterjoystick.h    |  1 -
 indra/newview/llhudnametag.cpp       |  5 +++--
 indra/newview/llstatusbar.cpp        |  4 ++--
 indra/newview/llsurface.h            |  1 -
 indra/newview/lltexturefetch.cpp     | 10 +++++-----
 indra/newview/lltexturefetch.h       |  7 +++----
 indra/newview/llviewercamera.cpp     | 13 +++++++++----
 indra/newview/llviewercamera.h       | 28 ++++++++++++++--------------
 indra/newview/llviewerdisplay.cpp    |  6 ++++--
 indra/newview/llviewermessage.cpp    | 22 ----------------------
 indra/newview/llviewerobjectlist.cpp |  4 ++--
 indra/newview/llviewerobjectlist.h   |  4 ++--
 indra/newview/llviewerregion.cpp     |  9 +++++----
 indra/newview/llviewerregion.h       |  6 ++----
 indra/newview/llviewerstats.cpp      | 33 ++++++++++++++++++---------------
 indra/newview/llviewerstats.h        |  1 -
 indra/newview/llviewertexturelist.h  |  1 -
 indra/newview/llviewerwindow.cpp     | 11 +++++------
 indra/newview/llviewerwindow.h       |  7 ++++---
 indra/newview/llvoavatar.cpp         |  6 ------
 indra/newview/llworld.cpp            | 17 ++++-------------
 indra/newview/pipeline.cpp           |  6 +++---
 26 files changed, 103 insertions(+), 124 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 751b73e1eb..8d80e3aa0a 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1081,8 +1081,8 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 	LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot.getWorldRotation();
 	LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot.getWorldRotation();
 
-	if 	((gViewerWindow->getMouseVelocityStat()->getCurrent() < 0.01f) &&
-		 (root_at * last_at_axis > 0.95f))
+	if 	(LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f
+		&& (root_at * last_at_axis > 0.95f))
 	{
 		LLVector3 vel = gAgentAvatarp->getVelocity();
 		if (vel.magVecSquared() > 4.f)
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 559f427de6..2d090f0f74 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4305,6 +4305,9 @@ void LLAppViewer::idle()
 		update_statistics();
 	}
 
+	LLTrace::get_frame_recording().nextPeriod();
+
+
 	////////////////////////////////////////
 	//
 	// Handle the regular UI idle callbacks as well as
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 4dfb93f1bc..065b20ba2b 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -46,7 +46,6 @@
 #include "llviewertexturelist.h"
 #include "llui.h"
 #include "llviewercontrol.h"
-#include "llstat.h"
 
 #include "llfasttimer.h"
 #include "lltreeiterators.h"
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index f7b2670b8e..e2813a8272 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -33,7 +33,7 @@
 #include "llerror.h"
 #include "llrect.h"
 #include "llstring.h"
-#include "llstat.h"
+#include "lltrace.h"
 
 // project includes
 #include "lluictrlfactory.h"
@@ -42,6 +42,16 @@
 #include "llviewerjoystick.h"
 #include "llcheckboxctrl.h"
 
+static LLTrace::Measurement<> sJoystickAxes[6] = 
+{
+	LLTrace::Measurement<>("Joystick axis 1"),
+	LLTrace::Measurement<>("Joystick axis 2"),
+	LLTrace::Measurement<>("Joystick axis 3"),
+	LLTrace::Measurement<>("Joystick axis 4"),
+	LLTrace::Measurement<>("Joystick axis 5"),
+	LLTrace::Measurement<>("Joystick axis 6")
+};
+
 LLFloaterJoystick::LLFloaterJoystick(const LLSD& data)
 	: LLFloater(data)
 {
@@ -61,7 +71,7 @@ void LLFloaterJoystick::draw()
 	for (U32 i = 0; i < 6; i++)
 	{
 		F32 value = joystick->getJoystickAxis(i);
-		mAxisStats[i]->addValue(value * gFrameIntervalSeconds.value());
+		sJoystickAxes[i].sample(value * gFrameIntervalSeconds.value());
 		if (mAxisStatsBar[i])
 		{
 			F32 minbar, maxbar;
@@ -85,12 +95,11 @@ BOOL LLFloaterJoystick::postBuild()
 	for (U32 i = 0; i < 6; i++)
 	{
 		std::string stat_name(llformat("Joystick axis %d", i));
-		mAxisStats[i] = new LLStat(stat_name, 4);
 		std::string axisname = llformat("axis%d", i);
 		mAxisStatsBar[i] = getChild<LLStatBar>(axisname);
 		if (mAxisStatsBar[i])
 		{
-			mAxisStatsBar[i]->setStat(mAxisStats[i]);
+			mAxisStatsBar[i]->setStat(stat_name);
 			mAxisStatsBar[i]->setRange(-range, range, range * 0.25f, range * 0.5f);
 		}
 	}
diff --git a/indra/newview/llfloaterjoystick.h b/indra/newview/llfloaterjoystick.h
index dfdb108ff8..9c3752540d 100644
--- a/indra/newview/llfloaterjoystick.h
+++ b/indra/newview/llfloaterjoystick.h
@@ -84,7 +84,6 @@ private:
 	LLCheckBoxCtrl	*mCheckFlycamEnabled;
 
 	// stats view 
-	LLStat* mAxisStats[6];
 	LLStatBar* mAxisStatsBar[6];
 };
 
diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index 482294c8a6..56fbdb429a 100644
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -30,6 +30,7 @@
 #include "llhudnametag.h"
 
 #include "llrender.h"
+#include "lltracerecording.h"
 
 #include "llagent.h"
 #include "llviewercontrol.h"
@@ -899,8 +900,8 @@ void LLHUDNameTag::updateAll()
 //		}
 	}
 
-	LLStat* camera_vel_stat = LLViewerCamera::getInstance()->getVelocityStat();
-	F32 camera_vel = camera_vel_stat->getCurrent();
+	LLTrace::Count<>* camera_vel_stat = LLViewerCamera::getVelocityStat();
+	F32 camera_vel = LLTrace::get_frame_recording().getLastRecordingPeriod().getPerSec(*camera_vel_stat);
 	if (camera_vel > MAX_STABLE_CAMERA_VELOCITY)
 	{
 		return;
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 5720395d05..b945ec2318 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild()
 	sgp.rect(r);
 	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	sgp.mouse_opaque(false);
-	sgp.stat.count_stat(&LLStatViewer::KBIT);
+	sgp.stat.count_stat_float(&LLStatViewer::KBIT);
 	sgp.units("Kbps");
 	sgp.precision(0);
 	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
@@ -212,7 +212,7 @@ BOOL LLStatusBar::postBuild()
 	pgp.rect(r);
 	pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	pgp.mouse_opaque(false);
-	pgp.stat.measurement_stat(&LLStatViewer::PACKETS_LOST_PERCENT);
+	pgp.stat.measurement_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT);
 	pgp.units("%");
 	pgp.min(0.f);
 	pgp.max(5.f);
diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h
index 9d24bf8771..33a64ae7d5 100644
--- a/indra/newview/llsurface.h
+++ b/indra/newview/llsurface.h
@@ -45,7 +45,6 @@
 class LLTimer;
 class LLUUID;
 class LLAgent;
-class LLStat;
 
 static const U8 NO_EDGE    = 0x00;
 static const U8 EAST_EDGE  = 0x01;
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 2a72e77672..fa0e3acf5e 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -59,8 +59,8 @@
 #include "llviewerstats.h"
 
 bool LLTextureFetchDebugger::sDebuggerEnabled = false ;
-LLStat LLTextureFetch::sCacheHitRate("texture_cache_hits", 128);
-LLStat LLTextureFetch::sCacheReadLatency("texture_cache_read_latency", 128);
+LLTrace::Measurement<> LLTextureFetch::sCacheHitRate("texture_cache_hits");
+LLTrace::Measurement<> LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
 
 //////////////////////////////////////////////////////////////////////////////
 class LLTextureFetchWorker : public LLWorkerClass
@@ -895,7 +895,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			LL_DEBUGS("Texture") << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize()
 								 << " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight())
 								 << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
-			LLTextureFetch::sCacheHitRate.addValue(100.f);
+			LLTextureFetch::sCacheHitRate.sample(100.f);
 		}
 		else
 		{
@@ -912,7 +912,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			}
 			
 			// fall through
-			LLTextureFetch::sCacheHitRate.addValue(0.f);
+			LLTextureFetch::sCacheHitRate.sample(0.f);
 		}
 	}
 
@@ -2039,7 +2039,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
 			F32 cache_read_time = worker->mCacheReadTime;
 			if (cache_read_time != 0.f)
 			{
-				sCacheReadLatency.addValue(cache_read_time * 1000.f);
+				sCacheReadLatency.sample(cache_read_time * 1000.f);
 			}
 			res = true;
 			LL_DEBUGS("Texture") << id << ": Request Finished. State: " << worker->mState << " Discard: " << discard_level << LL_ENDL;
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 7ffa58660e..4ec67c8cdb 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -35,8 +35,7 @@
 #include "lltextureinfo.h"
 #include "llapr.h"
 #include "llimageworker.h"
-#include "llstat.h"
-//#include "lltexturecache.h"
+#include "lltrace.h"
 
 class LLViewerTexture;
 class LLTextureFetchWorker;
@@ -166,8 +165,8 @@ private:
 	LLMutex mQueueMutex;        //to protect mRequestMap and mCommands only
 	LLMutex mNetworkQueueMutex; //to protect mNetworkQueue, mHTTPTextureQueue and mCancelQueue.
 
-	static LLStat sCacheHitRate;
-	static LLStat sCacheReadLatency;
+	static LLTrace::Measurement<> sCacheHitRate;
+	static LLTrace::Measurement<> sCacheReadLatency;
 
 	LLTextureCache* mTextureCache;
 	LLImageDecodeThread* mImageDecodeThread;
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index a437a8b3b5..831304f428 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -49,10 +49,14 @@
 #include "llglheaders.h"
 #include "llquaternion.h"
 #include "llwindow.h"			// getPixelAspectRatio()
+#include "lltracerecording.h"
 
 // System includes
 #include <iomanip> // for setprecision
 
+LLTrace::Count<> LLViewerCamera::sVelocityStat("camera_velocity");
+LLTrace::Count<> LLViewerCamera::sAngularVelocityStat("camera_angular_velocity");
+
 U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
 
 //glu pick matrix implementation borrowed from Mesa3D
@@ -163,11 +167,12 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
 	F32 drot;
 	rotation.getAngleAxis(&drot, &x, &y, &z);
 
-	mVelocityStat.addValue(dpos);
-	mAngularVelocityStat.addValue(drot);
+	sVelocityStat.add(dpos);
+	sAngularVelocityStat.add(drot);
 	
-	mAverageSpeed = mVelocityStat.getMeanPerSec() ;
-	mAverageAngularSpeed = mAngularVelocityStat.getMeanPerSec() ;
+	LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording();
+	mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat);
+	mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat);
 	mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect()));
 
 	// update pixel meter ratio using default fov, not modified one
diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h
index b857c7fe89..399eed7695 100644
--- a/indra/newview/llviewercamera.h
+++ b/indra/newview/llviewercamera.h
@@ -29,10 +29,10 @@
 
 #include "llcamera.h"
 #include "llsingleton.h"
-#include "llstat.h"
 #include "lltimer.h"
 #include "m4math.h"
 #include "llcoord.h"
+#include "lltrace.h"
 
 class LLViewerObject;
 
@@ -100,12 +100,12 @@ public:
 	BOOL projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoordGL &out_point, const BOOL clamp = TRUE) const;
 	BOOL projectPosAgentToScreenEdge(const LLVector3 &pos_agent, LLCoordGL &out_point) const;
 
-	const LLVector3* getVelocityDir() const {return &mVelocityDir;}
-	LLStat *getVelocityStat() { return &mVelocityStat; }
-	LLStat *getAngularVelocityStat() { return &mAngularVelocityStat; }
-	F32     getCosHalfFov() {return mCosHalfCameraFOV;}
-	F32     getAverageSpeed() {return mAverageSpeed ;}
-	F32     getAverageAngularSpeed() {return mAverageAngularSpeed;}
+	const LLVector3*         getVelocityDir() const    {return &mVelocityDir;}
+	static LLTrace::Count<>* getVelocityStat()		   {return &sVelocityStat; }
+	static LLTrace::Count<>* getAngularVelocityStat()  {return &sAngularVelocityStat; }
+	F32                      getCosHalfFov()           {return mCosHalfCameraFOV;}
+	F32                      getAverageSpeed()         {return mAverageSpeed ;}
+	F32                      getAverageAngularSpeed()  {return mAverageAngularSpeed;}
 
 	void getPixelVectors(const LLVector3 &pos_agent, LLVector3 &up, LLVector3 &right);
 	LLVector3 roundToPixel(const LLVector3 &pos_agent);
@@ -117,9 +117,9 @@ public:
 	F32 getDefaultFOV() { return mCameraFOVDefault; }
 
 	BOOL cameraUnderWater() const;
-
-	const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; }
 	BOOL areVertsVisible(LLViewerObject* volumep, BOOL all_verts);
+
+	const LLVector3 &getPointOfInterest()		{ return mLastPointOfInterest; }
 	F32 getPixelMeterRatio() const				{ return mPixelMeterRatio; }
 	S32 getScreenPixelArea() const				{ return mScreenPixelArea; }
 
@@ -130,12 +130,12 @@ public:
 protected:
 	void calcProjection(const F32 far_distance) const;
 
-	LLStat mVelocityStat;
-	LLStat mAngularVelocityStat;
-	LLVector3 mVelocityDir ;
-	F32       mAverageSpeed ;
-	F32       mAverageAngularSpeed ;
+	static LLTrace::Count<> sVelocityStat;
+	static LLTrace::Count<> sAngularVelocityStat;
 
+	LLVector3			mVelocityDir ;
+	F32					mAverageSpeed ;
+	F32					mAverageAngularSpeed ;
 	mutable LLMatrix4	mProjectionMatrix;	// Cache of perspective matrix
 	mutable LLMatrix4	mModelviewMatrix;
 	F32					mCameraFOVDefault;
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 169b45c14e..41a08398bb 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -748,8 +748,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			
 			{
 				LLFastTimer t(FTM_IMAGE_UPDATE_CLASS);
-				LLViewerTexture::updateClass(LLViewerCamera::getInstance()->getVelocityStat()->getMean(),
-											LLViewerCamera::getInstance()->getAngularVelocityStat()->getMean());
+				LLTrace::Count<>* velocity_stat = LLViewerCamera::getVelocityStat();
+				LLTrace::Count<>* angular_velocity_stat = LLViewerCamera::getAngularVelocityStat();
+				LLViewerTexture::updateClass(LLTrace::get_frame_recording().getPeriodMeanPerSec(*velocity_stat),
+											LLTrace::get_frame_recording().getPeriodMeanPerSec(*angular_velocity_stat));
 			}
 
 			
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 82caa05983..acbe836c29 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4765,28 +4765,6 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data)
 		}
 	}
 
-	/*
-	msg->getF32Fast(_PREHASH_Statistics, _PREHASH_PhysicsTimeDilation, time_dilation);
-	LLViewerStats::getInstance()->mSimTDStat.addValue(time_dilation);
-
-	// Process information
-	//	{	CpuUsage			F32				}
-	//	{	SimMemTotal			F32				}
-	//	{	SimMemRSS			F32				}
-	//	{	ProcessUptime		F32				}
-	F32 cpu_usage;
-	F32 sim_mem_total;
-	F32 sim_mem_rss;
-	F32 process_uptime;
-	msg->getF32Fast(_PREHASH_Statistics, _PREHASH_CpuUsage, cpu_usage);
-	msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemTotal, sim_mem_total);
-	msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemRSS, sim_mem_rss);
-	msg->getF32Fast(_PREHASH_Statistics, _PREHASH_ProcessUptime, process_uptime);
-	LLViewerStats::getInstance()->mSimCPUUsageStat.addValue(cpu_usage);
-	LLViewerStats::getInstance()->mSimMemTotalStat.addValue(sim_mem_total);
-	LLViewerStats::getInstance()->mSimMemRSSStat.addValue(sim_mem_rss);
-	*/
-
 	//
 	// Various hacks that aren't statistics, but are being handled here.
 	//
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 14a2ac3384..9c6045943f 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -93,7 +93,7 @@ extern LLPipeline	gPipeline;
 U32						LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check.
 std::map<U64, U32>		LLViewerObjectList::sIPAndPortToIndex;
 std::map<U64, LLUUID>	LLViewerObjectList::sIndexAndLocalIDToUUID;
-LLStat					LLViewerObjectList::sCacheHitRate("object_cache_hits", 128);
+LLTrace::Measurement<>	LLViewerObjectList::sCacheHitRate("object_cache_hits");
 
 LLViewerObjectList::LLViewerObjectList()
 {
@@ -520,7 +520,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			}
 			justCreated = TRUE;
 			mNumNewObjects++;
-			sCacheHitRate.addValue(cached ? 100.f : 0.f);
+			sCacheHitRate.sample(cached ? 100.f : 0.f);
 
 		}
 
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 9936432a71..ca4110230f 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -31,8 +31,8 @@
 #include <set>
 
 // common includes
-#include "llstat.h"
 #include "llstring.h"
+#include "lltrace.h"
 
 // project includes
 #include "llviewerobject.h"
@@ -194,7 +194,7 @@ protected:
 	std::vector<OrphanInfo> mOrphanChildren;	// UUID's of orphaned objects
 	S32 mNumOrphans;
 
-	static LLStat sCacheHitRate;
+	static LLTrace::Measurement<> sCacheHitRate;
 
 	typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 31e3820a21..652e0ee70b 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -291,7 +291,9 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 	mCacheLoaded(FALSE),
 	mCacheDirty(FALSE),
 	mReleaseNotesRequested(FALSE),
-	mCapabilitiesReceived(false)
+	mCapabilitiesReceived(false),
+	mBitsReceived(0.f),
+	mPacketsReceived(0.f)
 {
 	mWidth = region_width_meters;
 	mImpl->mOriginGlobal = from_region_handle(handle); 
@@ -909,9 +911,8 @@ void LLViewerRegion::updateNetStats()
 	mPacketsLost =				cdp->getPacketsLost();
 	mPingDelay =				cdp->getPingDelay();
 
-	mBitStat.addValue(mBitsIn - mLastBitsIn);
-	mPacketsStat.addValue(mPacketsIn - mLastPacketsIn);
-	mPacketsLostStat.addValue(mPacketsLost);
+	mBitsReceived += mBitsIn - mLastBitsIn;
+	mPacketsReceived += mPacketsIn - mLastPacketsIn;
 }
 
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index c9fffaf30e..756c0dc61f 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -34,7 +34,6 @@
 
 #include "lldarray.h"
 #include "llwind.h"
-#include "llstat.h"
 #include "v3dmath.h"
 #include "llstring.h"
 #include "llregionflags.h"
@@ -351,9 +350,8 @@ public:
 	LLWind  mWind;
 	LLViewerParcelOverlay	*mParcelOverlay;
 
-	LLStat	mBitStat;
-	LLStat	mPacketsStat;
-	LLStat	mPacketsLostStat;
+	F32		mBitsReceived;
+	F32		mPacketsReceived;
 
 	LLMatrix4 mRenderMatrix;
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 04b0c30b40..a42368cec4 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -94,8 +94,8 @@ LLTrace::Count<LLTrace::Kilobits>	KBIT("kbitstat"),
 									OBJECT_KBIT("objectkbitstat"),
 									ASSET_KBIT("assetkbitstat"),
 									TEXTURE_KBIT("texturekbitstat"),
-									ACTUAL_IN_KBIT("actualinkbit"),
-									ACTUAL_OUT_KBIT("actualoutkbit");
+									ACTUAL_IN_KBIT("actualinkbitstat"),
+									ACTUAL_OUT_KBIT("actualoutkbitstat");
 
 LLTrace::Count<LLTrace::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
 								TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
@@ -276,20 +276,25 @@ void LLViewerStats::addToMessage(LLSD &body) const
 
 // *NOTE:Mani The following methods used to exist in viewer.cpp
 // Moving them here, but not merging them into LLViewerStats yet.
-U32		gTotalLandIn = 0, gTotalLandOut = 0;
-U32		gTotalWaterIn = 0, gTotalWaterOut = 0;
-
-F32		gAveLandCompression = 0.f, gAveWaterCompression = 0.f;
-F32		gBestLandCompression = 1.f, gBestWaterCompression = 1.f;
-F32		gWorstLandCompression = 0.f, gWorstWaterCompression = 0.f;
+U32		gTotalLandIn = 0, 
+		gTotalLandOut = 0,
+		gTotalWaterIn = 0, 
+		gTotalWaterOut = 0;
+
+F32		gAveLandCompression = 0.f, 
+		gAveWaterCompression = 0.f,
+		gBestLandCompression = 1.f,
+		gBestWaterCompression = 1.f,
+		gWorstLandCompression = 0.f, 
+		gWorstWaterCompression = 0.f;
 
 LLUnit::Bytes<U32>		gTotalWorldData = 0, 
 						gTotalObjectData = 0, 
 						gTotalTextureData = 0;
-U32		gSimPingCount = 0;
+U32						gSimPingCount = 0;
 LLUnit::Bits<U32>		gObjectData = 0;
-F32		gAvgSimPing = 0.f;
-LLUnit::Bytes<U32>     gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
+F32						gAvgSimPing = 0.f;
+LLUnit::Bytes<U32>		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
 
 extern U32  gVisCompared;
 extern U32  gVisTested;
@@ -334,13 +339,13 @@ void update_statistics()
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
-		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(cdp->getPingDelay());
+		LLStatViewer::SIM_PING.sample<LLTrace::Milliseconds>(cdp->getPingDelay());
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
-		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10000);
+		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10);
 	}
 
 	LLStatViewer::FPS.add(1);
@@ -390,8 +395,6 @@ void update_statistics()
 			texture_stats_timer.reset();
 		}
 	}
-
-	LLTrace::get_frame_recording().nextPeriod();
 }
 
 class ViewerStatsResponder : public LLHTTPClient::Responder
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 34731481f5..eda7b3329d 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -27,7 +27,6 @@
 #ifndef LL_LLVIEWERSTATS_H
 #define LL_LLVIEWERSTATS_H
 
-#include "llstat.h"
 #include "llstatenums.h"
 #include "lltextureinfo.h"
 #include "lltracerecording.h"
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index a00f48b5a2..e3df71cca2 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -30,7 +30,6 @@
 #include "lluuid.h"
 //#include "message.h"
 #include "llgl.h"
-#include "llstat.h"
 #include "llviewertexture.h"
 #include "llui.h"
 #include <list>
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 06daf15c08..b7415669bb 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -77,7 +77,6 @@
 #include "llmediaentry.h"
 #include "llurldispatcher.h"
 #include "raytrace.h"
-#include "llstat.h"
 
 // newview includes
 #include "llagent.h"
@@ -249,6 +248,9 @@ std::string	LLViewerWindow::sSnapshotDir;
 
 std::string	LLViewerWindow::sMovieBaseName;
 
+LLTrace::Measurement<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity");
+
+
 class RecordToChatConsole : public LLError::Recorder, public LLSingleton<RecordToChatConsole>
 {
 public:
@@ -1541,8 +1543,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
 	mResDirty(false),
 	mStatesDirty(false),
 	mCurrResolutionIndex(0),
-	mProgressView(NULL),
-	mMouseVelocityStat(new LLStat("Mouse Velocity"))
+	mProgressView(NULL)
 {
 	// gKeyboard is still NULL, so it doesn't do LLWindowListener any good to
 	// pass its value right now. Instead, pass it a nullary function that
@@ -2072,8 +2073,6 @@ LLViewerWindow::~LLViewerWindow()
 
 	delete mDebugText;
 	mDebugText = NULL;
-
-	delete mMouseVelocityStat;
 }
 
 
@@ -3247,7 +3246,7 @@ void LLViewerWindow::updateMouseDelta()
 		mouse_vel.setVec((F32) dx, (F32) dy);
 	}
     
-	mMouseVelocityStat->addValue(mouse_vel.magVec());
+	sMouseVelocityStat.sample(mouse_vel.magVec());
 }
 
 void LLViewerWindow::updateKeyboardFocus()
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 5f475fe145..be2d6d885e 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -44,12 +44,12 @@
 #include "llmousehandler.h"
 #include "llhandle.h"
 #include "llinitparam.h"
+#include "lltrace.h"
 
 #include <boost/function.hpp>
 #include <boost/signals2.hpp>
 #include <boost/scoped_ptr.hpp>
 
-class LLStat;
 class LLView;
 class LLViewerObject;
 class LLUUID;
@@ -250,7 +250,7 @@ public:
 	S32				getCurrentMouseDX()		const	{ return mCurrentMouseDelta.mX; }
 	S32				getCurrentMouseDY()		const	{ return mCurrentMouseDelta.mY; }
 	LLCoordGL		getCurrentMouseDelta()	const	{ return mCurrentMouseDelta; }
-	LLStat*			getMouseVelocityStat()		{ return mMouseVelocityStat; }
+	static LLTrace::Measurement<>*	getMouseVelocityStat()		{ return &sMouseVelocityStat; }
 	BOOL			getLeftMouseDown()	const	{ return mLeftMouseDown; }
 	BOOL			getMiddleMouseDown()	const	{ return mMiddleMouseDown; }
 	BOOL			getRightMouseDown()	const	{ return mRightMouseDown; }
@@ -427,7 +427,6 @@ private:
 	LLCoordGL		mCurrentMousePoint;			// last mouse position in GL coords
 	LLCoordGL		mLastMousePoint;		// Mouse point at last frame.
 	LLCoordGL		mCurrentMouseDelta;		//amount mouse moved this frame
-	LLStat*			mMouseVelocityStat;
 	BOOL			mLeftMouseDown;
 	BOOL			mMiddleMouseDown;
 	BOOL			mRightMouseDown;
@@ -482,6 +481,8 @@ private:
 	
 	// Object temporarily hovered over while dragging
 	LLPointer<LLViewerObject>	mDragHoveredObject;
+
+	static LLTrace::Measurement<>	sMouseVelocityStat;
 };
 
 //
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 97c1b07ebc..3c1f8ca6b0 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -4318,8 +4318,6 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 	//--------------------------------------------------------------------
 	// render all geometry attached to the skeleton
 	//--------------------------------------------------------------------
-	static LLStat render_stat;
-
 	LLViewerJointMesh::sRenderPass = pass;
 
 	if (pass == AVATAR_RENDER_PASS_SINGLE)
@@ -4372,10 +4370,6 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 	
 	LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE;
 	
-	//llinfos << "Avatar render: " << render_timer.getElapsedTimeF32() << llendl;
-
-	//render_stat.addValue(render_timer.getElapsedTimeF32()*1000.f);
-
 	return num_indices;
 }
 
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index dced5a847b..e140f3b23b 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -692,8 +692,10 @@ void LLWorld::updateNetStats()
 	{
 		LLViewerRegion* regionp = *iter;
 		regionp->updateNetStats();
-		bits += regionp->mBitStat.getCurrent();
-		packets += llfloor( regionp->mPacketsStat.getCurrent() );
+		bits += regionp->mBitsReceived;
+		packets += llfloor( regionp->mPacketsReceived );
+		regionp->mBitsReceived = 0.f;
+		regionp->mPacketsReceived = 0.f;
 	}
 
 	S32 packets_in = gMessageSystem->mPacketsIn - mLastPacketsIn;
@@ -705,26 +707,15 @@ void LLWorld::updateNetStats()
 
 	LLStatViewer::ACTUAL_IN_KBIT.add<LLTrace::Bits>(actual_in_bits);
 	LLStatViewer::ACTUAL_OUT_KBIT.add<LLTrace::Bits>(actual_out_bits);
-	//LLViewerStats::getInstance()->mActualInKBitStat.addValue(actual_in_bits/1024.f);
-	//LLViewerStats::getInstance()->mActualOutKBitStat.addValue(actual_out_bits/1024.f);
 	LLStatViewer::KBIT.add<LLTrace::Bits>(bits);
-	//LLViewerStats::getInstance()->mKBitStat.addValue(bits/1024.f);
 	LLStatViewer::PACKETS_IN.add(packets_in);
 	LLStatViewer::PACKETS_OUT.add(packets_out);
 	LLStatViewer::PACKETS_LOST.add(packets_lost);
 	LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));
-	//LLViewerStats::getInstance()->mPacketsInStat.addValue(packets_in);
-	//LLViewerStats::getInstance()->mPacketsOutStat.addValue(packets_out);
-	//LLViewerStats::getInstance()->mPacketsLostStat.addValue(gMessageSystem->mDroppedPackets);
 	if (packets_in)
 	{
 		LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));
-	//	LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(100.f*((F32)packets_lost/(F32)packets_in));
 	}
-	//else
-	//{
-	//	LLViewerStats::getInstance()->mPacketsLostPercentStat.addValue(0.f);
-	//}
 
 	mLastPacketsIn = gMessageSystem->mPacketsIn;
 	mLastPacketsOut = gMessageSystem->mPacketsOut;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 75af605ad7..1e050d2588 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -488,7 +488,6 @@ void LLPipeline::init()
 	getPool(LLDrawPool::POOL_BUMP);
 	getPool(LLDrawPool::POOL_GLOW);
 
-	//LLViewerStats::getInstance()->mTrianglesDrawnStat.reset();
 	resetFrameStats();
 
 	for (U32 i = 0; i < NUM_RENDER_TYPES; ++i)
@@ -1769,7 +1768,6 @@ void LLPipeline::resetFrameStats()
 	assertInitialized();
 
 	LLStatViewer::TRIANGLES_DRAWN.add(mTrianglesDrawn);
-	//LLViewerStats::getInstance()->mTrianglesDrawnStat.addValue(mTrianglesDrawn/1000.f);
 
 	if (mBatchCount > 0)
 	{
@@ -9756,7 +9754,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 	if (gen_shadow)
 	{
-		F32 fade_amt = gFrameIntervalSeconds.value() * llmax(LLViewerCamera::getInstance()->getVelocityStat()->getCurrentPerSec(), 1.f);
+		LLTrace::Measurement<>* velocity_stat = LLViewerCamera::getVelocityStat();
+		F32 fade_amt = gFrameIntervalSeconds.value() 
+			* llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*velocity_stat), 1.0);
 
 		//update shadow targets
 		for (U32 i = 0; i < 2; i++)
-- 
cgit v1.2.3


From 8e6341b9194b1fb27d92d8f5e6739390ac882941 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 1 Nov 2012 17:05:26 -0600
Subject: more for SH-3459: interesting store object bounding information in
 viewer cache

---
 indra/newview/llvocache.cpp | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index d4938fd216..db6aa9cd00 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -110,6 +110,17 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 		success = check_read(apr_file, &mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
+	{
+		F32 ext[8];
+		success = check_read(apr_file, (void*)ext, sizeof(F32) * 8);
+
+		LLVector4a exts[2];
+		exts[0].load4a(ext);
+		exts[1].load4a(&ext[4]);
+	
+		setSpatialExtents(exts[0], exts[1]);
+	}
+	if(success)
 	{
 		LLVector4 pos;
 		success = check_read(apr_file, (void*)pos.mV, sizeof(LLVector4));
@@ -332,6 +343,17 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 		success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
+	{
+		const LLVector4a* exts = getSpatialExtents() ;
+		LLVector4 ext(exts[0][0], exts[0][1], exts[0][2], exts[0][3]);
+		success = check_write(apr_file, ext.mV, sizeof(LLVector4));		
+		if(success)
+		{
+			ext.set(exts[1][0], exts[1][1], exts[1][2], exts[1][3]);
+			success = check_write(apr_file, ext.mV, sizeof(LLVector4));		
+		}
+	}
+	if(success)
 	{
 		const LLVector4a pos_ = getPositionGroup() ;
 		LLVector4 pos(pos_[0], pos_[1], pos_[2], pos_[3]);
-- 
cgit v1.2.3


From 74fe126590fba03752d1d8d88dd3bb59c6900026 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 1 Nov 2012 17:52:11 -0700
Subject: SH-3405 FIX convert existing stats to lltrace system output of
 floater_stats is now identical to pre-lltrace system (with some tweaks)

---
 indra/newview/llviewercamera.cpp                     |  1 -
 indra/newview/llworld.cpp                            |  1 -
 indra/newview/pipeline.cpp                           |  4 ++--
 indra/newview/skins/default/xui/en/floater_stats.xml | 16 +++++++++++++---
 4 files changed, 15 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index 831304f428..f74897daa7 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -170,7 +170,6 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
 	sVelocityStat.add(dpos);
 	sAngularVelocityStat.add(drot);
 	
-	LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording();
 	mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat);
 	mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat);
 	mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect()));
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index e140f3b23b..126dc59929 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -711,7 +711,6 @@ void LLWorld::updateNetStats()
 	LLStatViewer::PACKETS_IN.add(packets_in);
 	LLStatViewer::PACKETS_OUT.add(packets_out);
 	LLStatViewer::PACKETS_LOST.add(packets_lost);
-	LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));
 	if (packets_in)
 	{
 		LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1e050d2588..bf353cd1e0 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -9754,9 +9754,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 	if (gen_shadow)
 	{
-		LLTrace::Measurement<>* velocity_stat = LLViewerCamera::getVelocityStat();
+		LLTrace::Count<>* velocity_stat = LLViewerCamera::getVelocityStat();
 		F32 fade_amt = gFrameIntervalSeconds.value() 
-			* llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*velocity_stat), 1.0);
+			* llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecordingPeriod().getDuration().value(), 1.0);
 
 		//update shadow targets
 		for (U32 i = 0; i < 2; i++)
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index f9eb16d224..273954ee3e 100644
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -104,6 +104,7 @@
 				 label="KTris Drawn per Frame"
 				 unit_label="/fr"
 				 stat="trianglesdrawnstat"
+         unit_scale="0.001"
 				 bar_min="0"
 				 bar_max="10000"
 				 tick_spacing="1000"
@@ -116,6 +117,7 @@
 				 name="ktrissec"
 				 label="KTris Drawn per Sec"
 				 unit_label="/sec"
+         unit_scale="0.001"
 				 stat="trianglesdrawnstat"
 				 bar_min="0"
 				 bar_max="200000"
@@ -222,6 +224,8 @@
 				 name="gltexmemstat"
 				 label="GL Mem"
 				 stat="gltexmemstat"
+         unit_label="MB"
+         unit_scale="0.000001"
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
@@ -235,11 +239,13 @@
 				 name="formattedmemstat"
 				 label="Formatted Mem"
 				 stat="formattedmemstat"
+         unit_label="MB"
+         unit_scale="0.000001"
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
 				 label_spacing="200.f" 
-				 precision="1"
+				 precision="3"
 				 show_per_sec="false" 
          show_bar="false">
         </stat_bar>
@@ -247,12 +253,14 @@
 			  <stat_bar
 				 name="rawmemstat"
 				 label="Raw Mem"
+         unit_label="MB"
+         unit_scale="0.000001"
 				 stat="rawmemstat"
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
 				 label_spacing="200.f" 
-				 precision="1"
+				 precision="3"
 				 show_per_sec="false" 
          show_bar="false">
         </stat_bar>
@@ -261,11 +269,13 @@
 				 name="glboundmemstat"
 				 label="Bound Mem"
 				 stat="glboundmemstat"
+         unit_label="MB"
+         unit_scale="0.000001"
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
 				 label_spacing="200.f" 
-				 precision="1"
+				 precision="3"
 				 show_per_sec="false" 
          show_bar="false">
         </stat_bar>
-- 
cgit v1.2.3


From bb6bda9eef48f5b08b56af46321b79fe7f1d49d7 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 1 Nov 2012 19:55:06 -0700
Subject: SH-3499  Ensure asset stats output is correct added support for
 specifying predicates for xui and llsd serialization

---
 indra/newview/tests/llviewerassetstats_test.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index fc5cd781e6..26a76eda2c 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -266,6 +266,7 @@ namespace tut
 		ensure("Global gViewerAssetStats should still be NULL", (NULL == gViewerAssetStats));
 
 		LLSD sd_full = it->asLLSD(false);
+		llinfos << ll_pretty_print_sd(sd_full) << llendl;
 
 		// Default (NULL) region ID doesn't produce LLSD results so should
 		// get an empty map back from output
-- 
cgit v1.2.3


From f8eaee753174d0cab4e4edcf795f422706d6f302 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 2 Nov 2012 20:03:44 -0700
Subject: SH-3499  Ensure asset stats output is correct improvements to
 predicate API default rules encapsulated in LLInitParam removed empty flag
 from viewer asset stats

---
 indra/newview/llviewerassetstats.cpp | 254 +++++++++++++++++------------------
 indra/newview/llviewerassetstats.h   |   1 -
 2 files changed, 127 insertions(+), 128 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index e4f64f3076..df43c4b344 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -303,138 +303,133 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 		mCurRecording->update();
 	}
 	
-	if (mRegionRecordings.empty())
-	{
-		stats.regions.add().empty.setProvided();
-	}
-	else
+	stats.regions.setProvided();
+	
+	for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end();
+		it != end_it;
+		++it)
 	{
-		for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end();
-			it != end_it;
-			++it)
+		RegionStats& r = stats.regions.add();
+		LLTrace::Recording& rec = it->second;
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACTextureTempHTTPGet]) 
+			|| rec.getSum(sDequeued[EVACTextureTempHTTPGet])
+			|| rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
 		{
-			RegionStats& r = stats.regions.add();
-			LLTrace::Recording& rec = it->second;
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACTextureTempHTTPGet]) 
-				|| rec.getSum(sDequeued[EVACTextureTempHTTPGet])
-				|| rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
-			{
-				r.get_texture_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureTempHTTPGet]))
-										.dequeued(rec.getSum(sDequeued[EVACTextureTempHTTPGet]))
-										.resp_count(rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
-										.resp_min(rec.getMin(sResponse[EVACTextureTempHTTPGet]).value())
-										.resp_max(rec.getMax(sResponse[EVACTextureTempHTTPGet]).value())
-										.resp_mean(rec.getMean(sResponse[EVACTextureTempHTTPGet]).value());
-			}
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACTextureTempUDPGet]) 
-				|| rec.getSum(sDequeued[EVACTextureTempUDPGet])
-				|| rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
-			{
-				r.get_texture_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureTempUDPGet]))
-										.dequeued(rec.getSum(sDequeued[EVACTextureTempUDPGet]))
-										.resp_count(rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
-										.resp_min(rec.getMin(sResponse[EVACTextureTempUDPGet]).value())
-										.resp_max(rec.getMax(sResponse[EVACTextureTempUDPGet]).value())
-										.resp_mean(rec.getMean(sResponse[EVACTextureTempUDPGet]).value());
-			}
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]) 
-				|| rec.getSum(sDequeued[EVACTextureNonTempHTTPGet])
-				|| rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
-			{
-				r.get_texture_non_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]))
-											.dequeued(rec.getSum(sDequeued[EVACTextureNonTempHTTPGet]))
-											.resp_count(rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
-											.resp_min(rec.getMin(sResponse[EVACTextureNonTempHTTPGet]).value())
-											.resp_max(rec.getMax(sResponse[EVACTextureNonTempHTTPGet]).value())
-											.resp_mean(rec.getMean(sResponse[EVACTextureNonTempHTTPGet]).value());
-			}
-
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]) 
-				|| rec.getSum(sDequeued[EVACTextureNonTempUDPGet])
-				|| rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
-			{
-				r.get_texture_non_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]))
-											.dequeued(rec.getSum(sDequeued[EVACTextureNonTempUDPGet]))
-											.resp_count(rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
-											.resp_min(rec.getMin(sResponse[EVACTextureNonTempUDPGet]).value())
-											.resp_max(rec.getMax(sResponse[EVACTextureNonTempUDPGet]).value())
-											.resp_mean(rec.getMean(sResponse[EVACTextureNonTempUDPGet]).value());
-			}
-
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACWearableUDPGet]) 
-				|| rec.getSum(sDequeued[EVACWearableUDPGet])
-				|| rec.getSum(sResponse[EVACWearableUDPGet]).value())
-			{
-				r.get_wearable_udp	.enqueued(rec.getSum(sEnqueued[EVACWearableUDPGet]))
-									.dequeued(rec.getSum(sDequeued[EVACWearableUDPGet]))
-									.resp_count(rec.getSum(sResponse[EVACWearableUDPGet]).value())
-									.resp_min(rec.getMin(sResponse[EVACWearableUDPGet]).value())
-									.resp_max(rec.getMax(sResponse[EVACWearableUDPGet]).value())
-									.resp_mean(rec.getMean(sResponse[EVACWearableUDPGet]).value());
-			}
-
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACSoundUDPGet]) 
-				|| rec.getSum(sDequeued[EVACSoundUDPGet])
-				|| rec.getSum(sResponse[EVACSoundUDPGet]).value())
-			{
-				r.get_sound_udp	.enqueued(rec.getSum(sEnqueued[EVACSoundUDPGet]))
-								.dequeued(rec.getSum(sDequeued[EVACSoundUDPGet]))
-								.resp_count(rec.getSum(sResponse[EVACSoundUDPGet]).value())
-								.resp_min(rec.getMin(sResponse[EVACSoundUDPGet]).value())
-								.resp_max(rec.getMax(sResponse[EVACSoundUDPGet]).value())
-								.resp_mean(rec.getMean(sResponse[EVACSoundUDPGet]).value());
-			}
-
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACGestureUDPGet]) 
-				|| rec.getSum(sDequeued[EVACGestureUDPGet])
-				|| rec.getSum(sResponse[EVACGestureUDPGet]).value())
-			{
-				r.get_gesture_udp	.enqueued(rec.getSum(sEnqueued[EVACGestureUDPGet]))
-									.dequeued(rec.getSum(sDequeued[EVACGestureUDPGet]))
-									.resp_count(rec.getSum(sResponse[EVACGestureUDPGet]).value())
-									.resp_min(rec.getMin(sResponse[EVACGestureUDPGet]).value())
-									.resp_max(rec.getMax(sResponse[EVACGestureUDPGet]).value())
-									.resp_mean(rec.getMean(sResponse[EVACGestureUDPGet]).value());
-			}
-
-			if (!compact_output
-				|| rec.getSum(sEnqueued[EVACOtherGet]) 
-				|| rec.getSum(sDequeued[EVACOtherGet])
-				|| rec.getSum(sResponse[EVACOtherGet]).value())
-			{
-				r.get_other	.enqueued(rec.getSum(sEnqueued[EVACOtherGet]))
-							.dequeued(rec.getSum(sDequeued[EVACOtherGet]))
-							.resp_count(rec.getSum(sResponse[EVACOtherGet]).value())
-							.resp_min(rec.getMin(sResponse[EVACOtherGet]).value())
-							.resp_max(rec.getMax(sResponse[EVACOtherGet]).value())
-							.resp_mean(rec.getMean(sResponse[EVACOtherGet]).value());
-			}
-
-			S32 fps = rec.getSum(LLStatViewer::FPS_SAMPLE);
-			if (!compact_output || fps != 0)
-			{
-				r.fps.count(fps);
-				r.fps.min(rec.getMin(LLStatViewer::FPS_SAMPLE));
-				r.fps.max(rec.getMax(LLStatViewer::FPS_SAMPLE));
-				r.fps.mean(rec.getMean(LLStatViewer::FPS_SAMPLE));
-			}
-			U32 grid_x(0), grid_y(0);
-			grid_from_region_handle(it->first, &grid_x, &grid_y);
-			r.grid_x(grid_x);
-			r.grid_y(grid_y);
-			r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value());
+			r.get_texture_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureTempHTTPGet]))
+									.dequeued(rec.getSum(sDequeued[EVACTextureTempHTTPGet]))
+									.resp_count(rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
+									.resp_min(rec.getMin(sResponse[EVACTextureTempHTTPGet]).value())
+									.resp_max(rec.getMax(sResponse[EVACTextureTempHTTPGet]).value())
+									.resp_mean(rec.getMean(sResponse[EVACTextureTempHTTPGet]).value());
+		}
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACTextureTempUDPGet]) 
+			|| rec.getSum(sDequeued[EVACTextureTempUDPGet])
+			|| rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
+		{
+			r.get_texture_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureTempUDPGet]))
+									.dequeued(rec.getSum(sDequeued[EVACTextureTempUDPGet]))
+									.resp_count(rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
+									.resp_min(rec.getMin(sResponse[EVACTextureTempUDPGet]).value())
+									.resp_max(rec.getMax(sResponse[EVACTextureTempUDPGet]).value())
+									.resp_mean(rec.getMean(sResponse[EVACTextureTempUDPGet]).value());
+		}
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]) 
+			|| rec.getSum(sDequeued[EVACTextureNonTempHTTPGet])
+			|| rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
+		{
+			r.get_texture_non_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]))
+										.dequeued(rec.getSum(sDequeued[EVACTextureNonTempHTTPGet]))
+										.resp_count(rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
+										.resp_min(rec.getMin(sResponse[EVACTextureNonTempHTTPGet]).value())
+										.resp_max(rec.getMax(sResponse[EVACTextureNonTempHTTPGet]).value())
+										.resp_mean(rec.getMean(sResponse[EVACTextureNonTempHTTPGet]).value());
+		}
+
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]) 
+			|| rec.getSum(sDequeued[EVACTextureNonTempUDPGet])
+			|| rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
+		{
+			r.get_texture_non_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]))
+										.dequeued(rec.getSum(sDequeued[EVACTextureNonTempUDPGet]))
+										.resp_count(rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
+										.resp_min(rec.getMin(sResponse[EVACTextureNonTempUDPGet]).value())
+										.resp_max(rec.getMax(sResponse[EVACTextureNonTempUDPGet]).value())
+										.resp_mean(rec.getMean(sResponse[EVACTextureNonTempUDPGet]).value());
+		}
+
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACWearableUDPGet]) 
+			|| rec.getSum(sDequeued[EVACWearableUDPGet])
+			|| rec.getSum(sResponse[EVACWearableUDPGet]).value())
+		{
+			r.get_wearable_udp	.enqueued(rec.getSum(sEnqueued[EVACWearableUDPGet]))
+								.dequeued(rec.getSum(sDequeued[EVACWearableUDPGet]))
+								.resp_count(rec.getSum(sResponse[EVACWearableUDPGet]).value())
+								.resp_min(rec.getMin(sResponse[EVACWearableUDPGet]).value())
+								.resp_max(rec.getMax(sResponse[EVACWearableUDPGet]).value())
+								.resp_mean(rec.getMean(sResponse[EVACWearableUDPGet]).value());
+		}
+
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACSoundUDPGet]) 
+			|| rec.getSum(sDequeued[EVACSoundUDPGet])
+			|| rec.getSum(sResponse[EVACSoundUDPGet]).value())
+		{
+			r.get_sound_udp	.enqueued(rec.getSum(sEnqueued[EVACSoundUDPGet]))
+							.dequeued(rec.getSum(sDequeued[EVACSoundUDPGet]))
+							.resp_count(rec.getSum(sResponse[EVACSoundUDPGet]).value())
+							.resp_min(rec.getMin(sResponse[EVACSoundUDPGet]).value())
+							.resp_max(rec.getMax(sResponse[EVACSoundUDPGet]).value())
+							.resp_mean(rec.getMean(sResponse[EVACSoundUDPGet]).value());
+		}
+
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACGestureUDPGet]) 
+			|| rec.getSum(sDequeued[EVACGestureUDPGet])
+			|| rec.getSum(sResponse[EVACGestureUDPGet]).value())
+		{
+			r.get_gesture_udp	.enqueued(rec.getSum(sEnqueued[EVACGestureUDPGet]))
+								.dequeued(rec.getSum(sDequeued[EVACGestureUDPGet]))
+								.resp_count(rec.getSum(sResponse[EVACGestureUDPGet]).value())
+								.resp_min(rec.getMin(sResponse[EVACGestureUDPGet]).value())
+								.resp_max(rec.getMax(sResponse[EVACGestureUDPGet]).value())
+								.resp_mean(rec.getMean(sResponse[EVACGestureUDPGet]).value());
 		}
+
+		if (!compact_output
+			|| rec.getSum(sEnqueued[EVACOtherGet]) 
+			|| rec.getSum(sDequeued[EVACOtherGet])
+			|| rec.getSum(sResponse[EVACOtherGet]).value())
+		{
+			r.get_other	.enqueued(rec.getSum(sEnqueued[EVACOtherGet]))
+						.dequeued(rec.getSum(sDequeued[EVACOtherGet]))
+						.resp_count(rec.getSum(sResponse[EVACOtherGet]).value())
+						.resp_min(rec.getMin(sResponse[EVACOtherGet]).value())
+						.resp_max(rec.getMax(sResponse[EVACOtherGet]).value())
+						.resp_mean(rec.getMean(sResponse[EVACOtherGet]).value());
+		}
+
+		S32 fps = rec.getSum(LLStatViewer::FPS_SAMPLE);
+		if (!compact_output || fps != 0)
+		{
+			r.fps.count(fps);
+			r.fps.min(rec.getMin(LLStatViewer::FPS_SAMPLE));
+			r.fps.max(rec.getMax(LLStatViewer::FPS_SAMPLE));
+			r.fps.mean(rec.getMean(LLStatViewer::FPS_SAMPLE));
+		}
+		U32 grid_x(0), grid_y(0);
+		grid_from_region_handle(it->first, &grid_x, &grid_y);
+		r.grid_x(grid_x);
+		r.grid_y(grid_y);
+		r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value());
 	}
 
 	stats.duration(mCurRecording ? LLUnit::Microseconds<F64>(mCurRecording->getDuration()).value() : 0.0);
-	//stats.avatar.setProvided(true);
+	stats.avatar.setProvided(true);
 
 	for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat)
 	{
@@ -453,7 +448,12 @@ LLSD LLViewerAssetStats::asLLSD(bool compact_output)
 	LLSD sd;
 	AssetStats stats;
 	getStats(stats, compact_output);
-	parser.writeSD(sd, stats);
+	LLInitParam::predicate_rule_t rule = LLInitParam::default_parse_rules();
+	if (!compact_output)
+	{
+		rule.allow(LLInitParam::EMPTY);
+	}
+	parser.writeSD(sd, stats, rule);
 	return sd;
 }
 
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 2f50c52730..f1ce3aeaa2 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -114,7 +114,6 @@ public:
 
 	struct RegionStats : public LLInitParam::Block<RegionStats>
 	{
-		Optional<LLInitParam::Flag>				empty;
 		Optional<AssetRequestType>	get_texture_temp_http,
 									get_texture_temp_udp,
 									get_texture_non_temp_http,
-- 
cgit v1.2.3


From 0007114cf5a60779319ab8cbd0a23a0d462b8010 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 5 Nov 2012 16:10:57 -0800
Subject: SH-3499 WIP Ensure asset stats output is correct fixed copy behavior
 of recordings and accumulator buffers

---
 indra/newview/llappviewer.cpp                   |  2 ++
 indra/newview/llviewerassetstats.cpp            | 36 +++++++---------------
 indra/newview/llviewerassetstats.h              | 41 +++----------------------
 indra/newview/tests/llviewerassetstats_test.cpp |  5 +++
 4 files changed, 23 insertions(+), 61 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 2d090f0f74..838a982cb4 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -5244,6 +5244,8 @@ void LLAppViewer::metricsSend(bool enable_reporting)
 			// Make a copy of the main stats to send into another thread.
 			// Receiving thread takes ownership.
 			LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStats));
+
+			main_stats->updateStats();
 			
 			// Send a report request into 'thread1' to get the rest of the data
 			// and provide some additional parameters while here.
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index df43c4b344..000d061bec 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -246,9 +246,11 @@ LLViewerAssetStats::LLViewerAssetStats()
 LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 :	mRegionHandle(src.mRegionHandle),
 	mPhaseStats(src.mPhaseStats),
-	mAvatarRezStates(src.mAvatarRezStates),
-	mRegionRecordings(src.mRegionRecordings)
+	mAvatarRezStates(src.mAvatarRezStates)
 {
+	src.mCurRecording->update();
+	mRegionRecordings = src.mRegionRecordings;
+	
 	mCurRecording = &mRegionRecordings[mRegionHandle];
 }
 
@@ -294,14 +296,17 @@ void LLViewerAssetStats::recordAvatarStats()
 	mPhaseStats["cloud-or-gray"] = LLViewerStats::PhaseMap::getPhaseStats("cloud-or-gray");
 }
 
-void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
+void LLViewerAssetStats::updateStats()
 {
-	using namespace LLViewerAssetStatsFF;
-
-	if (mCurRecording)
+	if (mCurRecording && mCurRecording->isStarted())
 	{
 		mCurRecording->update();
 	}
+}
+
+void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
+{
+	using namespace LLViewerAssetStatsFF;
 	
 	stats.regions.setProvided();
 	
@@ -463,25 +468,6 @@ LLSD LLViewerAssetStats::asLLSD(bool compact_output)
 
 namespace LLViewerAssetStatsFF
 {
-//
-// Target thread is elaborated in the function name.  This could
-// have been something 'templatey' like specializations iterated
-// over a set of constants but with so few, this is clearer I think.
-//
-// As for the threads themselves... rather than do fine-grained
-// locking as we gather statistics, this code creates a collector
-// for each thread, allocated and run independently.  Logging
-// happens at relatively infrequent intervals and at that time
-// the data is sent to a single thread to be aggregated into
-// a single entity with locks, thread safety and other niceties.
-//
-// A particularly fussy implementation would distribute the
-// per-thread pointers across separate cache lines.  But that should
-// be beyond current requirements.
-//
-
-// 'main' thread - initial program thread
-
 void set_region(LLViewerAssetStats::region_handle_t region_handle)
 {
 	if (! gViewerAssetStats)
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index f1ce3aeaa2..835df89149 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -192,43 +192,12 @@ public:
 	// Avatar-related statistics
 	void recordAvatarStats();
 
+	// gather latest metrics data
+	// call from main thread
+	void updateStats();
+
 	// Retrieve current metrics for all visited regions (NULL region UUID/handle excluded)
-    // Returned LLSD is structured as follows:
-	//
-	// &stats_group = {
-	//   enqueued   : int,
-	//   dequeued   : int,
-	//   resp_count : int,
-	//   resp_min   : float,
-	//   resp_max   : float,
-	//   resp_mean  : float
-	// }
-	//
-	// &mmm_group = {
-	//   count : int,
-	//   min   : float,
-	//   max   : float,
-	//   mean  : float
-	// }
-	//
-	// {
-	//   duration: int
-	//   regions: {
-	//     $: {			// Keys are strings of the region's handle in hex
-	//       duration:                 : int,
-	//		 fps:					   : &mmm_group,
-	//       get_texture_temp_http     : &stats_group,
-	//       get_texture_temp_udp      : &stats_group,
-	//       get_texture_non_temp_http : &stats_group,
-	//       get_texture_non_temp_udp  : &stats_group,
-	//       get_wearable_udp          : &stats_group,
-	//       get_sound_udp             : &stats_group,
-	//       get_gesture_udp           : &stats_group,
-	//       get_other                 : &stats_group
-	//     }
-	//   }
-	// }
-	//
+    // Uses AssetStats structure seen above
 	void getStats(AssetStats& stats, bool compact_output);
 	LLSD asLLSD(bool compact_output);
 
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index 26a76eda2c..1f299abe41 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -340,6 +340,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
 		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
+		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
@@ -377,6 +378,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
 		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
+		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
@@ -422,6 +424,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
+		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 
 		// std::cout << sd << std::endl;
@@ -496,6 +499,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
+		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 
 		ensure("Correct double-key LLSD map root", is_triple_key_map(sd, "duration", "regions", "avatar"));
@@ -563,6 +567,7 @@ namespace tut
 
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
 
+		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
-- 
cgit v1.2.3


From 860ff2f7e2a7fe932dfb7c148f0dbc0067018038 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 7 Nov 2012 00:38:21 -0800
Subject: SH-3499 WIP Ensure asset stats output is correct fixed trace data
 gathering and routing from background thread simplified slave->master thread
 communication (eliminated redundant recording and proxy object) improved
 performance of fast timer data gathering (slow iterators)

---
 indra/newview/llviewerassetstats.cpp            | 2 +-
 indra/newview/llviewerstats.cpp                 | 5 ++++-
 indra/newview/tests/llviewerassetstats_test.cpp | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 000d061bec..bad2f5b4cd 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -494,7 +494,7 @@ void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp,
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sResponse[int(eac)].sample<LLTrace::Seconds>(duration);
+	sResponse[int(eac)].sample<LLTrace::Microseconds>(duration);
 }
 
 void record_avatar_stats()
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index a42368cec4..317fe5eaf8 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -349,7 +349,10 @@ void update_statistics()
 	}
 
 	LLStatViewer::FPS.add(1);
-	LLStatViewer::FPS_SAMPLE.sample(LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS));
+	if (LLTrace::get_frame_recording().getTotalRecording().getSampleCount(LLStatViewer::FPS))
+	{
+		LLStatViewer::FPS_SAMPLE.sample(LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS));
+	}
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
 	LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits);
 	LLStatViewer::OBJECT_KBIT.add(gObjectData);
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index 1f299abe41..ecdd78a1da 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -266,7 +266,6 @@ namespace tut
 		ensure("Global gViewerAssetStats should still be NULL", (NULL == gViewerAssetStats));
 
 		LLSD sd_full = it->asLLSD(false);
-		llinfos << ll_pretty_print_sd(sd_full) << llendl;
 
 		// Default (NULL) region ID doesn't produce LLSD results so should
 		// get an empty map back from output
-- 
cgit v1.2.3


From ed17c181dd37f56b808838748d289ee7bb5567ec Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 7 Nov 2012 15:32:12 -0800
Subject: SH-3499 WIP Ensure asset stats output is correct further fixes to
 implicit conversion of unit types

---
 indra/newview/llviewertexture.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index f64134b8b7..ceb8d3155c 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -533,7 +533,7 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{
 		//when texture memory overflows, lower down the threashold to release the textures more aggressively.
-		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, (LLUnit::Bytes<S32>)gMaxVideoRam) ;//512 MB
+		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit::Bytes<S32>(gMaxVideoRam));
 	
 		// If we are using more texture memory than we should,
 		// scale up the desired discard level
@@ -3312,7 +3312,7 @@ void LLViewerLODTexture::processTextureStats()
 				scaleDown() ;
 			}
 			// Only allow GL to have 2x the video card memory
-			else if ( sTotalTextureMemory > sMaxTotalTextureMem*texmem_middle_bound_scale &&
+			else if ( sTotalTextureMemory > sMaxTotalTextureMem * texmem_middle_bound_scale &&
 				(!getBoundRecently() || mDesiredDiscardLevel >= mCachedRawDiscardLevel))
 			{
 				scaleDown() ;
-- 
cgit v1.2.3


From c2859e4663c405950b6f433270ae558852330c76 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 8 Nov 2012 21:36:47 -0700
Subject: for SH-3472: prioritize object loading

---
 indra/newview/lldrawable.cpp         |  17 +-
 indra/newview/llviewerobjectlist.cpp |  85 +++++-----
 indra/newview/llviewerobjectlist.h   |   2 +-
 indra/newview/llvieweroctree.cpp     |   9 +-
 indra/newview/llvieweroctree.h       |   8 +-
 indra/newview/llviewerregion.cpp     | 317 ++++++++++++++++++++++-------------
 indra/newview/llviewerregion.h       |   6 +-
 indra/newview/llvocache.cpp          | 136 +++++++++++----
 indra/newview/llvocache.h            |  69 ++++++--
 9 files changed, 423 insertions(+), 226 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index e29551e83c..c782fbfe7e 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -470,7 +470,13 @@ void LLDrawable::makeActive()
 		}
 		updatePartition();
 	}
-
+	else if (!isRoot() && !mParent->isActive()) //this should not happen, but occasionally it does...
+	{
+		mParent->makeActive();
+		//NOTE: linked set will now NEVER become static
+		mParent->setState(LLDrawable::ACTIVE_CHILD);
+	}
+	
 	llassert(isAvatar() || isRoot() || mParent->isActive());
 }
 
@@ -1093,6 +1099,11 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat
 	{
 		part->put(this);
 	}
+
+	if(mDrawable->getEntry()->hasVOCacheEntry())
+	{
+		((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry())->setBridgeChild();
+	}
 }
 
 LLSpatialBridge::~LLSpatialBridge()
@@ -1470,9 +1481,9 @@ void LLSpatialBridge::cleanupReferences()
 		dummy_entry = new LLVOCacheEntry();
 		dummy_entry->setOctreeEntry(mEntry);
 		dummy_entry->addChild((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry());
-		llassert(!mDrawable->getParent());
+		//llassert(!mDrawable->getParent());
 		
-		mDrawable->mParent = this;
+		//mDrawable->mParent = this;
 	}
 
 	LLDrawable::cleanupReferences();
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index d41eee5926..f3552e2c2b 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -376,7 +376,7 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 											 void **user_data,
 											 const EObjectUpdateType update_type,
-											 bool cached, bool compressed)
+											 bool compressed)
 {
 	LLFastTimer t(FTM_PROCESS_OBJECTS);	
 	
@@ -395,7 +395,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 	num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
 
 	// I don't think this case is ever hit.  TODO* Test this.
-	if (!cached && !compressed && update_type != OUT_FULL)
+	if (!compressed && update_type != OUT_FULL)
 	{
 		//llinfos << "TEST: !cached && !compressed && update_type != OUT_FULL" << llendl;
 		gTerseObjectUpdates += num_objects;
@@ -439,7 +439,6 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 
 	U8 compressed_dpbuffer[2048];
 	LLDataPackerBinaryBuffer compressed_dp(compressed_dpbuffer, 2048);
-	LLDataPacker *cached_dpp = NULL;
 	LLViewerStatsRecorder& recorder = LLViewerStatsRecorder::instance();
 
 	for (i = 0; i < num_objects; i++)
@@ -449,34 +448,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 		BOOL justCreated = FALSE;
 		S32	msg_size = 0;
 
-		if (cached)
-		{
-			U32 id;
-			U32 crc;
-			mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, id, i);
-			mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_CRC, crc, i);
-			msg_size += sizeof(U32) * 2;
-		
-			// Lookup data packer and add this id to cache miss lists if necessary.
-			U8 cache_miss_type = LLViewerRegion::CACHE_MISS_TYPE_NONE;
-			cached_dpp = regionp->getDP(id, crc, cache_miss_type);
-			if (cached_dpp)
-			{
-				// Cache Hit.
-				cached_dpp->reset();
-				cached_dpp->unpackUUID(fullid, "ID");
-				cached_dpp->unpackU32(local_id, "LocalID");
-				cached_dpp->unpackU8(pcode, "PCode");
-			}
-			else
-			{
-				// Cache Miss.
-				recorder.cacheMissEvent(id, update_type, cache_miss_type, msg_size);
-
-				continue; // no data packer, skip this object
-			}
-		}
-		else if (compressed)
+		if (compressed)
 		{
 			S32	uncompressed_length = 2048;
 			compressed_dp.reset();			
@@ -575,9 +547,6 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 					continue;
 				}
 			}
-			else if (cached) // Cache hit only?
-			{
-			}
 			else
 			{
 				if (update_type != OUT_FULL)
@@ -610,7 +579,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			}
 			justCreated = TRUE;
 			mNumNewObjects++;
-			sCacheHitRate.addValue(cached ? 100.f : 0.f);
+			sCacheHitRate.addValue(0.f);
 
 		}
 
@@ -641,11 +610,6 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 				}
 			}
 		}
-		else if (cached) // Cache hit only?
-		{
-			objectp->mLocalID = local_id;
-			processUpdateCore(objectp, user_data, i, update_type, cached_dpp, justCreated);
-		}
 		else
 		{
 			if (update_type == OUT_FULL)
@@ -668,14 +632,51 @@ void LLViewerObjectList::processCompressedObjectUpdate(LLMessageSystem *mesgsys,
 											 void **user_data,
 											 const EObjectUpdateType update_type)
 {
-	processObjectUpdate(mesgsys, user_data, update_type, false, true);
+	processObjectUpdate(mesgsys, user_data, update_type, true);
 }
 
 void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
 											 void **user_data,
 											 const EObjectUpdateType update_type)
 {
-	processObjectUpdate(mesgsys, user_data, update_type, true, false);
+	//processObjectUpdate(mesgsys, user_data, update_type, true, false);
+
+	S32 num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
+	gFullObjectUpdates += num_objects;
+
+	U64 region_handle;
+	mesgsys->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle);	
+	LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(region_handle);
+	if (!regionp)
+	{
+		llwarns << "Object update from unknown region! " << region_handle << llendl;
+		return;
+	}
+
+	LLViewerStatsRecorder& recorder = LLViewerStatsRecorder::instance();
+
+	for (S32 i = 0; i < num_objects; i++)
+	{
+		S32	msg_size = 0;
+		U32 id;
+		U32 crc;
+		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, id, i);
+		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_CRC, crc, i);
+		msg_size += sizeof(U32) * 2;
+		
+		// Lookup data packer and add this id to cache miss lists if necessary.
+		U8 cache_miss_type = LLViewerRegion::CACHE_MISS_TYPE_NONE;
+		if(!regionp->probeCache(id, crc, cache_miss_type))
+		{
+			// Cache Miss.
+			recorder.cacheMissEvent(id, update_type, cache_miss_type, msg_size);
+
+			continue; // no data packer, skip this object
+		}
+		sCacheHitRate.addValue(100.f);
+	}
+
+	return;
 }	
 
 void LLViewerObjectList::dirtyAllObjectInventory()
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 1476f44215..17c8c86ff5 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -83,7 +83,7 @@ public:
 	void processUpdateCore(LLViewerObject* objectp, void** data, U32 block, const EObjectUpdateType update_type, 
 		                   LLDataPacker* dpp, bool justCreated, bool from_cache = false);
 	LLViewerObject* processObjectUpdateFromCache(LLVOCacheEntry* entry, LLViewerRegion* regionp);
-	void processObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type, bool cached=false, bool compressed=false);
+	void processObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type, bool compressed=false);
 	void processCompressedObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type);
 	void processCachedObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type);
 	void updateApparentAngles(LLAgent &agent);
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 143f2a6819..b6e0674a95 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -126,13 +126,14 @@ S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LL
 //-----------------------------------------------------------------------------------
 //class LLViewerOctreeEntry definitions
 //-----------------------------------------------------------------------------------
-LLViewerOctreeEntry::LLViewerOctreeEntry() : mGroup(NULL)
+LLViewerOctreeEntry::LLViewerOctreeEntry() 
+	: mGroup(NULL),
+	  mBinRadius(0.f),
+	  mBinIndex(-1)
 {
 	mPositionGroup.clear();
 	mExtents[0].clear();
-	mExtents[1].clear();
-	mBinRadius = 0.f;
-	mBinIndex = -1;
+	mExtents[1].clear();	
 
 	for(S32 i = 0; i < NUM_DATA_TYPE; i++)
 	{
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 498ec3e75d..b89014119c 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -135,7 +135,7 @@ public:
 	const LLVector4a*    getSpatialExtents() const;
 	LLviewerOctreeGroup* getGroup()const;
 	const LLVector4a&    getPositionGroup() const;
-
+	
 	void setBinRadius(F32 rad)  {mEntry->mBinRadius = rad;}
 	void setSpatialExtents(const LLVector3& min, const LLVector3& max);
 	void setSpatialExtents(const LLVector4a& min, const LLVector4a& max);
@@ -247,9 +247,9 @@ protected:
 	U32         mState;
 	OctreeNode* mOctreeNode;	
 
-	LL_ALIGN_16(LLVector4a mBounds[2]);       // bounding box (center, size) of this node and all its children (tight fit to objects)
-	LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
-	LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
+	LL_ALIGN_16(LLVector4a mBounds[2]);        // bounding box (center, size) of this node and all its children (tight fit to objects)
+	LL_ALIGN_16(LLVector4a mObjectBounds[2]);  // bounding box (center, size) of objects in this node
+	LL_ALIGN_16(LLVector4a mExtents[2]);       // extents (min, max) of this node and all its children
 	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
 
 public:
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 1adab15d70..24bd68825b 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -100,6 +100,8 @@ public:
 			mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN),
 			mSeedCapAttempts(0),
 			mHttpResponderID(0),
+			mLastCameraUpdate(0),
+			mLastCameraOrigin(),
 		    // I'd prefer to set the LLCapabilityListener name to match the region
 		    // name -- it's disappointing that's not available at construction time.
 		    // We could instead store an LLCapabilityListener*, making
@@ -136,13 +138,14 @@ public:
 	// Misc
 	LLVLComposition *mCompositionp;		// Composition layer for the surface
 
-	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.
-	LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //visible root entries of a linked set.
+	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<LLVOCacheEntry> > mDummyEntries; //dummy vo cache entries, for LLSpatialBridge use.
-	std::set< LLviewerOctreeGroup* >      mVisibleGroups; //visible llspatialgroup
-	LLVOCachePartition*                 mVOCachePartition;
+	std::set< LLviewerOctreeGroup* >      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.
 
 	// time?
 	// LRU info?
@@ -168,6 +171,9 @@ public:
 
 	//spatial partitions for objects in this region
 	std::vector<LLViewerOctreePartition*> mObjectPartition;
+
+	LLVector3 mLastCameraOrigin;
+	U32       mLastCameraUpdate;
 };
 
 // support for secondlife:///app/region/{REGION} SLapps
@@ -736,27 +742,16 @@ void LLViewerRegion::dirtyHeights()
 
 void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry)
 {
-	LLPointer<LLViewerOctreeEntry> oct_entry;
 	U32 state = LLVOCacheEntry::INACTIVE;
 
 	if(old_entry)
 	{
-		oct_entry = old_entry->getEntry();
+		new_entry->copy(old_entry);
 		state = old_entry->getState();		
-
-		while(old_entry->getNumOfChildren() > 0)
-		{
-			new_entry->addChild(old_entry->getNextChild());
-		}
-
 		killCacheEntry(old_entry);
 	}
 
 	mImpl->mCacheMap[new_entry->getLocalID()] = new_entry;
-	if(oct_entry.notNull())
-	{
-		new_entry->setOctreeEntry(oct_entry);
-	}
 
 	if(state == LLVOCacheEntry::ACTIVE)
 	{
@@ -767,7 +762,7 @@ void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry
 	{
 		mImpl->mWaitingSet.insert(new_entry);
 	}
-	else if(old_entry && oct_entry)
+	else if(old_entry && new_entry->getEntry())
 	{
 		addToVOCacheTree(new_entry);
 	}
@@ -790,19 +785,23 @@ void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry)
 	else if(entry->isState(LLVOCacheEntry::WAITING))
 	{
 		mImpl->mWaitingSet.erase(entry);
-	}	
-
-	//2, kill LLViewerObject if exists
-	//this should be done by the rendering pipeline automatically.
-
-	//3, remove from mVOCachePartition
-	if(entry->isState(LLVOCacheEntry::INACTIVE) && entry->getEntry())
+	}
+	else if(entry->isState(LLVOCacheEntry::IN_QUEUE))
 	{
+		mImpl->mVisibleEntries.erase(entry);
+	}
+	else if(entry->isState(LLVOCacheEntry::INACTIVE))
+	{
+		//remove from mVOCachePartition
 		removeFromVOCacheTree(entry);
 	}
 
+	//kill LLViewerObject if exists
+	//this should be done by the rendering pipeline automatically.
+	
 	entry->setState(LLVOCacheEntry::INACTIVE);
-	//4, remove from mCacheMap, real deletion
+	
+	//remove from mCacheMap, real deletion
 	mImpl->mCacheMap.erase(entry->getLocalID());
 }
 
@@ -885,7 +884,10 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
-	llassert(!entry->getGroup());
+	if(entry->getGroup()) //already in octree.
+	{
+		return;
+	}
 
 	mImpl->mVOCachePartition->addEntry(entry->getEntry());
 }
@@ -896,18 +898,31 @@ void LLViewerRegion::removeFromVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
+	if(!entry->getGroup())
+	{
+		return;
+	}
 
 	mImpl->mVOCachePartition->removeEntry(entry->getEntry());
 }
 
-//add the visible root entry of a linked set
+//add the visible entries
 void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 {
-	if(mDead || !entry || !entry->getNumOfChildren())
+	if(mDead || !entry)
 	{
-		return; //no child entries
+		return; 
 	}
 
+	if(entry->isState(LLVOCacheEntry::IN_QUEUE))
+	{
+		return;
+	}
+
+	if(entry->isState(LLVOCacheEntry::INACTIVE))
+	{
+		entry->setState(LLVOCacheEntry::IN_QUEUE);
+	}
 	mImpl->mVisibleEntries.insert(entry);
 }
 
@@ -922,124 +937,148 @@ void LLViewerRegion::clearVisibleGroup(LLviewerOctreeGroup* group)
 
 	mImpl->mVisibleGroups.erase(group);
 }
-	
-//return time left
-F32 LLViewerRegion::addLinkedSetChildren(F32 max_time, S32& max_num_objects)
+
+F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 {
-	if(mImpl->mVisibleEntries.empty())
+	if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty())
 	{
 		return max_time;
 	}
 
 	LLTimer update_timer;
-	bool timeout = false;
+
+	const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin();
+	const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame();
+	bool needs_update = ((cur_frame - mImpl->mLastCameraUpdate) > 5) && ((camera_origin - mImpl->mLastCameraOrigin).lengthSquared() > 10.f);	
+
+	//process visible entries
+	max_time *= 0.5f; //only use up to half available time to update entries.
 
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
 	{
-		LLVOCacheEntry* entry = *iter;				
-		LLVOCacheEntry* child = entry->getNextChild();
-		while(child != NULL)
+		LLVOCacheEntry* vo_entry = *iter;
+		vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);
+
+		if(vo_entry->getState() < LLVOCacheEntry::WAITING && !vo_entry->isDummy())
+		{			
+			mImpl->mWaitingList.insert(vo_entry);
+		}
+
+		LLVOCacheEntry* child;
+		S32 num_child = vo_entry->getNumOfChildren();
+		S32 num_done = 0;
+		for(S32 i = 0; i < num_child; i++)
 		{
-			if(child->isState(LLVOCacheEntry::INACTIVE))
+			child = vo_entry->getChild(i);
+			if(child->getState() < LLVOCacheEntry::WAITING)
 			{
-				addNewObject(child);
-				
-				if(max_num_objects-- < 0 && update_timer.getElapsedTimeF32() > max_time)
-				{
-					timeout = true; //timeout
-					break;
-				}
+				child->setSceneContribution(vo_entry->getSceneContribution());
+				mImpl->mWaitingList.insert(child);
 			}
-			child = entry->getNextChild();
-		}
-		if(!child)
-		{
-			if(entry->isDummy())
+			else
 			{
-				mImpl->mDummyEntries.erase(entry);
+				num_done++;
 			}
 		}
-		
-		if(!timeout)
+		if(num_done == num_child)
 		{
-			iter = mImpl->mVisibleEntries.erase(iter);
+			vo_entry->clearChildrenList();
+		}
+
+		if(!vo_entry->getNumOfChildren())
+		{
+			if(vo_entry->isDummy())
+			{
+				mImpl->mDummyEntries.erase(vo_entry);
+				iter = mImpl->mVisibleEntries.erase(iter);
+			}
+			else if(vo_entry->getState() >= LLVOCacheEntry::WAITING)
+			{
+				iter = mImpl->mVisibleEntries.erase(iter);
+			}
+			else
+			{
+				++iter;
+			}
 		}
 		else
 		{
-			break; //timeout
+			++iter;
 		}
-	}
 
-	if(timeout)
-	{
-		return -1.f;
-	}
-	return max_time - update_timer.getElapsedTimeF32(); //time left
-}
-
-F32 LLViewerRegion::addVisibleObjects(F32 max_time, S32& max_num_objects)
-{
-	if(mImpl->mVisibleGroups.empty())
-	{
-		return max_time;
+		//if(update_timer.getElapsedTimeF32() > max_time)
+		//{
+		//	break;
+		//}
 	}
 
-	LLTimer update_timer;
-	bool timeout = false;
-
+	//process visible groups
 	std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
-	while(group_iter != mImpl->mVisibleGroups.end())
+	for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
 	{
 		LLviewerOctreeGroup* group = *group_iter;
 		if(!group->getOctreeNode() || group->isEmpty())
 		{
-			mImpl->mVisibleGroups.erase(group_iter);
-			group_iter = mImpl->mVisibleGroups.begin();
 			continue;
 		}
 
-		std::vector<LLViewerOctreeEntry*> entry_list;
 		for (LLviewerOctreeGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
 		{
-			//group data contents could change during creating new objects, so copy all contents first.
-			entry_list.push_back(*i);
-		}
-		
-		for(S32 i = 0; i < entry_list.size(); i++)
-		{
-			LLViewerOctreeEntry* entry = entry_list[i];
-			if(entry && entry->hasVOCacheEntry())
+			if((*i)->hasVOCacheEntry())
 			{
-				LLVOCacheEntry* vo_entry = (LLVOCacheEntry*)entry->getVOCacheEntry();
+				LLVOCacheEntry* vo_entry = (LLVOCacheEntry*)(*i)->getVOCacheEntry();
 				if(vo_entry->isDummy())
 				{
 					addVisibleCacheEntry(vo_entry); //for LLSpatialBridge.
+					continue;
 				}
-				else if(vo_entry->isState(LLVOCacheEntry::INACTIVE))
-				{
-					addNewObject(vo_entry);
-					if(max_num_objects-- < 0 && update_timer.getElapsedTimeF32() > max_time)
-					{
-						timeout = true;
-						break;
-					}
-				}
+
+				vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);				
+				mImpl->mWaitingList.insert(vo_entry);
 			}
 		}
-		entry_list.clear();
 
-		if(timeout)
-		{
-			break;
-		}
-		mImpl->mVisibleGroups.erase(group);
-		group_iter = mImpl->mVisibleGroups.begin();
-	}	
+		//if(update_timer.getElapsedTimeF32() > max_time)
+		//{
+		//	break;
+		//}
+	}
+	mImpl->mVisibleGroups.clear();
+
+	if(needs_update)
+	{
+		mImpl->mLastCameraOrigin = camera_origin;
+		mImpl->mLastCameraUpdate = cur_frame;
+	}
+
+	return 2.0f * max_time - update_timer.getElapsedTimeF32();
+}
+
+F32 LLViewerRegion::createVisibleObjects(F32 max_time)
+{
+	if(mImpl->mWaitingList.empty())
+	{
+		return max_time;
+	}
 
-	if(timeout)
+	LLTimer update_timer;
+	S32 max_num_objects = 64; //minimum number of new objects to be added
+	for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin();
+		iter != mImpl->mWaitingList.end(); ++iter)
 	{
-		return -1.0f;
+		LLVOCacheEntry* vo_entry = *iter;
+			
+		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
+		{
+			addNewObject(vo_entry);
+			if(max_num_objects-- < 0 && update_timer.getElapsedTimeF32() > max_time)
+			{
+				break;
+			}
+		}
 	}
+	mImpl->mWaitingList.clear();
+
 	return max_time - update_timer.getElapsedTimeF32();
 }
 
@@ -1057,7 +1096,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	}
 
 	max_update_time -= update_timer.getElapsedTimeF32();
-	if(max_update_time < 0.f)
+	if(max_update_time < 0.f || mImpl->mCacheMap.empty())
 	{
 		return did_update;
 	}
@@ -1065,20 +1104,14 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	sCurRegionp = this;
 
 	//kill invisible objects
-	max_update_time = killInvisibleObjects(max_update_time);
-
-	S32 new_object_count = 64; //minimum number of new objects to be added
+	max_update_time = killInvisibleObjects(max_update_time);	
 	
-	//add childrens of visible objects to the rendering pipeline
-	max_update_time = addLinkedSetChildren(max_update_time, new_object_count);
-
-	//add objects in the visible groups to the rendering pipeline
-	if(max_update_time > 0.f)
-	{
-		addVisibleObjects(max_update_time, new_object_count);
-	}
+	max_update_time = updateVisibleEntries(max_update_time);
+	createVisibleObjects(max_update_time);
 
 	mImpl->mVisibleGroups.clear();
+	mImpl->mWaitingList.clear();
+
 	sCurRegionp = NULL;
 	return did_update;
 }
@@ -1687,7 +1720,7 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id)
 
 // Get data packer for this object, if we have cached data
 // AND the CRC matches. JC
-LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc, U8 &cache_miss_type)
+bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U8 &cache_miss_type)
 {
 	//llassert(mCacheLoaded);  This assert failes often, changing to early-out -- davep, 2010/10/18
 
@@ -1702,7 +1735,51 @@ LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc, U8 &cache_miss_type)
 			entry->recordHit();
 			cache_miss_type = CACHE_MISS_TYPE_NONE;
 
-			return entry->getDP(crc);
+			if(entry->getGroup() || !entry->isState(LLVOCacheEntry::INACTIVE))
+			{
+				return true;
+			}
+
+			addVisibleCacheEntry(entry);
+#if 0
+			if(entry->isBridgeChild()) //bridge child
+			{
+				addVisibleCacheEntry(entry);
+			}
+			else
+			{
+				U32 parent_id = entry->getParentID();
+				if(parent_id > 0) //has parent
+				{
+					LLVOCacheEntry* parent = getCacheEntry(parent_id);
+				
+					if(parent) //parent cached
+					{
+						parent->addChild(entry);
+
+						if(parent->isState(LLVOCacheEntry::INACTIVE))
+						{
+							//addToVOCacheTree(parent);
+							addVisibleCacheEntry(parent);
+						}
+						else //parent visible
+						{
+							addVisibleCacheEntry(parent);
+						}
+					}
+					else //parent not cached. This should not happen, but just in case...
+					{
+						addVisibleCacheEntry(entry);
+					}
+				}
+				else //root node
+				{
+					//addToVOCacheTree(entry);
+					addVisibleCacheEntry(entry);
+				}
+			}
+#endif
+			return true;
 		}
 		else
 		{
@@ -1718,7 +1795,7 @@ LLDataPacker *LLViewerRegion::getDP(U32 local_id, U32 crc, U8 &cache_miss_type)
 		mCacheMissFull.put(local_id);
 	}
 
-	return NULL;
+	return false;
 }
 
 void LLViewerRegion::addCacheMissFull(const U32 local_id)
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 86d3ee0d8c..9a47227f1c 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -317,7 +317,7 @@ public:
 	// handle a full update message
 	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);	
 	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
-	LLDataPacker *getDP(U32 local_id, U32 crc, U8 &cache_miss_type);
+	bool probeCache(U32 local_id, U32 crc, U8 &cache_miss_type);
 	void requestCacheMisses();
 	void addCacheMissFull(const U32 local_id);
 
@@ -354,8 +354,8 @@ private:
 	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
 
 	F32 killInvisibleObjects(F32 max_time);
-	F32 addLinkedSetChildren(F32 max_time, S32& max_num_objects);
-	F32 addVisibleObjects(F32 max_time, S32& max_num_objects);
+	F32 createVisibleObjects(F32 max_time);
+	F32 updateVisibleEntries(F32 max_time); //update visible entries
 
 public:
 	struct CompareDistance
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index db6aa9cd00..ec8585852b 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -32,6 +32,7 @@
 #include "llviewerobjectlist.h"
 #include "lldrawable.h"
 #include "llviewerregion.h"
+#include "pipeline.h"
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
@@ -57,11 +58,24 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mCRCChangeCount(0),
 	mState(INACTIVE),
 	mRepeatedVisCounter(0),
-	mVisFrameRange(64)
+	mVisFrameRange(64),
+	mSceneContrib(0.f)
 {
 	mBuffer = new U8[dp.getBufferSize()];
 	mDP.assignBuffer(mBuffer, dp.getBufferSize());
 	mDP = dp;
+
+	if(dp.getBufferSize() > 0)
+	{
+		U32 parent_id = 0;
+		dp.reset();
+		dp.unpackU32(parent_id, "ParentID");
+		dp.reset();
+		if(parent_id > 0)
+		{
+			mState |= CHILD; //is a child
+		}
+	}
 }
 
 LLVOCacheEntry::LLVOCacheEntry()
@@ -74,7 +88,8 @@ LLVOCacheEntry::LLVOCacheEntry()
 	mBuffer(NULL),
 	mState(INACTIVE),
 	mRepeatedVisCounter(0),
-	mVisFrameRange(64)
+	mVisFrameRange(64),
+	mSceneContrib(0.f)
 {
 	mDP.assignBuffer(mBuffer, 0);
 }
@@ -84,7 +99,8 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	mBuffer(NULL),
 	mState(INACTIVE),
 	mRepeatedVisCounter(0),
-	mVisFrameRange(64)
+	mVisFrameRange(64),
+	mSceneContrib(0.f)
 {
 	S32 size = -1;
 	BOOL success;
@@ -110,6 +126,10 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 		success = check_read(apr_file, &mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
+	{
+		success = check_read(apr_file, &mState, sizeof(U32));
+	}
+	if(success)
 	{
 		F32 ext[8];
 		success = check_read(apr_file, (void*)ext, sizeof(F32) * 8);
@@ -174,6 +194,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 		mCRCChangeCount = 0;
 		mBuffer = NULL;
 		mEntry = NULL;
+		mState = 0;
 	}
 }
 
@@ -203,11 +224,40 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
 	LLViewerOctreeEntryData::setOctreeEntry(entry);
 }
 
+void LLVOCacheEntry::setBridgeChild()
+{
+	mState |= BRIDGE_CHILD;
+}
+	
+void LLVOCacheEntry::clearBridgeChild()
+{
+	mState &= ~BRIDGE_CHILD;
+}
+
+void LLVOCacheEntry::copy(LLVOCacheEntry* entry)
+{
+	//copy LLViewerOctreeEntry
+	LLViewerOctreeEntry* oct_entry = entry->getEntry();
+	if(!oct_entry)
+	{
+		setOctreeEntry(oct_entry);
+	}
+
+	//copy children
+	S32 num_children = entry->getNumOfChildren();
+	for(S32 i = 0; i < num_children; i++)
+	{
+		addChild(entry->getChild(i));
+	}
+}
+
 void LLVOCacheEntry::setState(U32 state)
 {
-	mState = state;
+	mState &= 0xffff0000; //clear the low 16 bits
+	state &= 0x0000ffff;  //clear the high 16 bits;
+	mState |= state;
 
-	if(mState == ACTIVE)
+	if(getState() == ACTIVE)
 	{
 		const S32 MIN_REAVTIVE_INTERVAL = 20;
 		U32 last_visible = getVisible();
@@ -247,37 +297,6 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 	mChildrenList.push_back(entry);
 }
 	
-LLVOCacheEntry* LLVOCacheEntry::getNextChild()
-{
-	S32 size = mChildrenList.size();
-	if(!size)
-	{
-		return NULL;
-	}
-
-	LLVOCacheEntry* entry = mChildrenList[size - 1];
-	mChildrenList.pop_back(); //remove the entry;
-
-	return entry;
-}
-
-// New CRC means the object has changed.
-void LLVOCacheEntry::assignCRC(U32 crc, LLDataPackerBinaryBuffer &dp)
-{
-	if (  (mCRC != crc)
-		||(mDP.getBufferSize() == 0))
-	{
-		mCRC = crc;
-		mHitCount = 0;
-		mCRCChangeCount++;
-
-		mDP.freeBuffer();
-		mBuffer = new U8[dp.getBufferSize()];
-		mDP.assignBuffer(mBuffer, dp.getBufferSize());
-		mDP = dp;
-	}
-}
-
 LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc)
 {
 	if (  (mCRC != crc)
@@ -343,6 +362,11 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 		success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
+	{
+		U32 state = mState & 0xffff0000; //only store the high 16 bits.
+		success = check_write(apr_file, (void*)&state, sizeof(U32));
+	}
+	if(success)
 	{
 		const LLVector4a* exts = getSpatialExtents() ;
 		LLVector4 ext(exts[0][0], exts[0][1], exts[0][2], exts[0][3]);
@@ -378,6 +402,46 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 	return success ;
 }
 
+void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update)
+{
+	if(!needs_update && getVisible() >= last_update)
+	{
+		return; //no need to update
+	}
+
+	const LLVector4a& center = getPositionGroup();
+	
+	LLVector4a origin;
+	origin.load3(camera_origin.mV);
+
+	LLVector4a lookAt;
+	lookAt.setSub(center, origin);
+	F32 squared_dist = lookAt.dot3(lookAt).getF32();
+
+	F32 rad = getBinRadius();
+	mSceneContrib = rad * rad / squared_dist;
+
+	setVisible();
+}
+
+U32 LLVOCacheEntry::getParentID()
+{
+	if(!(mState & CHILD))
+	{
+		return 0; //not a child
+	}
+
+	U32 parent_id = 0;
+	LLDataPackerBinaryBuffer* dp = getDP();
+	if(dp)
+	{
+		dp->reset();
+		dp->unpackU32(parent_id, "ParentID");
+		dp->reset();
+	}
+	return parent_id;
+}
+
 //-------------------------------------------------------------------
 //LLVOCachePartition
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 675c12a3eb..ded29dd990 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -36,17 +36,47 @@
 //---------------------------------------------------------------------------
 // Cache entries
 class LLVOCacheEntry;
+class LLCamera;
 
 class LLVOCacheEntry : public LLViewerOctreeEntryData
 {
 public:
 	enum
 	{
-		INACTIVE = 0,
-		WAITING,
-		ACTIVE
+		INACTIVE = 0x00000000,     //not visible
+		IN_QUEUE = 0x00000001,     //in visible queue, object to be created
+		WAITING  = 0x00000002,     //object creation request sent
+		ACTIVE   = 0x00000004      //object created, and in rendering pipeline.
 	};
 
+	enum
+	{
+		CHILD        = 0x00010000, //has parent
+		BRIDGE_CHILD = 0x00020000  //is a child of a spatial bridge.
+	};
+
+	struct CompareVOCacheEntry
+	{
+		bool operator()(const LLVOCacheEntry* const& lhs, const LLVOCacheEntry* const& rhs)
+		{
+			F32 lpa = lhs->getSceneContribution();
+			F32 rpa = rhs->getSceneContribution();
+
+			//larger pixel area first
+			if(lpa > rpa)		
+			{
+				return true;
+			}
+			else if(lpa < rpa)
+			{
+				return false;
+			}
+			else
+			{
+				return lhs < rhs;
+			}			
+		}
+	};
 protected:
 	~LLVOCacheEntry();
 public:
@@ -55,33 +85,45 @@ public:
 	LLVOCacheEntry();	
 
 	void setState(U32 state);
-	bool isState(U32 state)  {return mState == state;}
-	U32  getState() const    {return mState;}
+	bool isState(U32 state)   {return (mState & 0xffff) == state;}
+	U32  getState() const     {return (mState & 0xffff);}
+	U32  getFullState() const {return mState;}
+
+	void setBridgeChild();  
+	void clearBridgeChild(); 
+	bool isBridgeChild()     {return mState & BRIDGE_CHILD;}
 
 	U32 getLocalID() const			{ return mLocalID; }
 	U32 getCRC() const				{ return mCRC; }
 	S32 getHitCount() const			{ return mHitCount; }
 	S32 getCRCChangeCount() const	{ return mCRCChangeCount; }
-	S32 getMinVisFrameRange()const;
+	S32 getMinVisFrameRange()const;	
+	U32 getParentID();
+
+	void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update);
+	void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;}
+	F32 getSceneContribution() const             { return mSceneContrib;}
 
 	void dump() const;
 	BOOL writeToFile(LLAPRFile* apr_file) const;
-	void assignCRC(U32 crc, LLDataPackerBinaryBuffer &dp);
 	LLDataPackerBinaryBuffer *getDP(U32 crc);
 	LLDataPackerBinaryBuffer *getDP();
 	void recordHit();
 	void recordDupe() { mDupeCount++; }
 	
+	void copy(LLVOCacheEntry* entry); //copy variables 
 	/*virtual*/ void setOctreeEntry(LLViewerOctreeEntry* entry);
 
 	void addChild(LLVOCacheEntry* entry);
-	LLVOCacheEntry* getNextChild();
-	S32 getNumOfChildren() {return mChildrenList.size();}
-	bool isDummy() {return !mBuffer;}
+	LLVOCacheEntry* getChild(S32 i) {return mChildrenList[i];}
+	S32  getNumOfChildren()         {return mChildrenList.size();}
+	void clearChildrenList()        {mChildrenList.clear();}
+	bool isDummy()                  {return !mBuffer;}	
 
 public:
-	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	vocache_entry_map_t;
-	typedef std::set<LLVOCacheEntry*>                   vocache_entry_set_t;
+	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;
+	typedef std::set<LLVOCacheEntry*>                      vocache_entry_set_t;
+	typedef std::set<LLVOCacheEntry*, CompareVOCacheEntry> vocache_entry_priority_list_t;	
 
 protected:
 	U32							mLocalID;
@@ -92,9 +134,10 @@ protected:
 	LLDataPackerBinaryBuffer	mDP;
 	U8							*mBuffer;
 
+	F32                         mSceneContrib; //projected scene contributuion of this object.
 	S32                         mVisFrameRange;
 	S32                         mRepeatedVisCounter; //number of repeatedly visible within a short time.
-	U32                         mState;
+	U32                         mState; //high 16 bits reserved for special use.
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 };
 
-- 
cgit v1.2.3


From 0bb0bd514b235948c1a21c81ab0e8ab6223b1990 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 8 Nov 2012 23:42:18 -0800
Subject: SH-3499 WIP Ensure asset stats output is correct Finished making
 LLUnit implicitly convertible to/from scalar integer values cleaned up test
 code

---
 indra/newview/llappviewer.cpp        |  2 +-
 indra/newview/llappviewer.h          |  2 +-
 indra/newview/lldrawpoolwater.cpp    |  2 +-
 indra/newview/lltextureview.cpp      | 18 +++++++++---------
 indra/newview/llviewerassetstats.cpp |  4 ++--
 indra/newview/llviewermessage.cpp    | 20 ++++++++++----------
 indra/newview/llviewerstats.cpp      |  6 +++---
 indra/newview/llviewerstats.h        |  6 +++---
 indra/newview/llviewertexture.cpp    | 18 +++++++++---------
 indra/newview/llviewertexture.h      | 14 +++++++-------
 indra/newview/llviewerwindow.cpp     |  2 +-
 11 files changed, 47 insertions(+), 47 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 838a982cb4..ac659c409b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -277,7 +277,7 @@ LLPumpIO* gServicePump = NULL;
 
 U64 gFrameTime = 0;
 F32 gFrameTimeSeconds = 0.f;
-LLUnit::Seconds<F32> gFrameIntervalSeconds = 0.f;
+LLUnit<LLUnits::Seconds, F32> gFrameIntervalSeconds = 0.f;
 F32 gFPSClamped = 10.f;						// Pretend we start at target rate.
 F32 gFrameDTClamped = 0.f;					// Time between adjacent checks to network for packets
 U64	gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index d9d888c626..f2bea7cdb2 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -322,7 +322,7 @@ extern LLPumpIO* gServicePump;
 
 extern U64      gFrameTime;					// The timestamp of the most-recently-processed frame
 extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
-extern LLUnit::Seconds<F32>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
+extern LLUnit<LLUnits::Seconds, F32>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
 extern F32		gFPSClamped;				// Frames per second, smoothed, weighted toward last frame
 extern F32		gFrameDTClamped;
 extern U64		gStartTime;
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 4f6eaa5a5b..61f5ecc46f 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -463,7 +463,7 @@ void LLDrawPoolWater::renderReflection(LLFace* face)
 
 	gGL.getTexUnit(0)->bind(mHBTex[dr]);
 
-	LLOverrideFaceColor override(this, face->getFaceColor().mV);
+	LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV));
 	face->renderIndexed();
 }
 
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index d734620f10..288c1233e5 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -503,17 +503,17 @@ private:
 
 void LLGLTexMemBar::draw()
 {
-	LLUnit::Megabytes<S32> bound_mem = LLViewerTexture::sBoundTextureMemory;
- 	LLUnit::Megabytes<S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
-	LLUnit::Megabytes<S32> total_mem = LLViewerTexture::sTotalTextureMemory;
-	LLUnit::Megabytes<S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
+	LLUnit<LLUnits::Megabytes, S32> bound_mem = LLViewerTexture::sBoundTextureMemory;
+ 	LLUnit<LLUnits::Megabytes, S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
+	LLUnit<LLUnits::Megabytes, S32> total_mem = LLViewerTexture::sTotalTextureMemory;
+	LLUnit<LLUnits::Megabytes, S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;
 	F32 cache_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
 	F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
-	LLUnit::Megabytes<F32> total_texture_downloaded = gTotalTextureData;
-	LLUnit::Megabytes<F32> total_object_downloaded = gTotalObjectData;
+	LLUnit<LLUnits::Megabytes, F32> total_texture_downloaded = gTotalTextureData;
+	LLUnit<LLUnits::Megabytes, F32> total_object_downloaded = gTotalObjectData;
 	U32 total_http_requests = LLAppViewer::getTextureFetch()->getCurlRequest().getTotalIssuedRequests() ;
 	//----------------------------------------------------------------------------
 	LLGLSUIDefault gls_ui;
@@ -661,7 +661,7 @@ void LLGLTexSizeBar::draw()
 
 	if(LLImageGL::sCurTexSizeBar == mIndex)
 	{
-		F32 text_color[] = {1.f, 1.f, 1.f, 0.75f};	
+		LLColor4 text_color(1.f, 1.f, 1.f, 0.75f);	
 		std::string text;
 	
 		text = llformat("%d", mTopLoaded) ;
@@ -673,8 +673,8 @@ void LLGLTexSizeBar::draw()
 									 text_color, LLFontGL::LEFT, LLFontGL::TOP);
 	}
 
-	F32 loaded_color[] = {1.0f, 0.0f, 0.0f, 0.75f};
-	F32 bound_color[] = {1.0f, 1.0f, 0.0f, 0.75f};
+	LLColor4 loaded_color(1.0f, 0.0f, 0.0f, 0.75f);
+	LLColor4 bound_color(1.0f, 1.0f, 0.0f, 0.75f);
 	gl_rect_2d(mLeft, mBottom + (S32)(mTopLoaded * mScale), (mLeft + mRight) / 2, mBottom, loaded_color) ;
 	gl_rect_2d((mLeft + mRight) / 2, mBottom + (S32)(mTopBound * mScale), mRight, mBottom, bound_color) ;
 }
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index bad2f5b4cd..73a2e24424 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -430,10 +430,10 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 		grid_from_region_handle(it->first, &grid_x, &grid_y);
 		r.grid_x(grid_x);
 		r.grid_y(grid_y);
-		r.duration(LLUnit::Microseconds<F64>(rec.getDuration()).value());
+		r.duration(LLUnit<LLUnits::Microseconds, F64>(rec.getDuration()).value());
 	}
 
-	stats.duration(mCurRecording ? LLUnit::Microseconds<F64>(mCurRecording->getDuration()).value() : 0.0);
+	stats.duration(mCurRecording ? LLUnit<LLUnits::Microseconds, F64>(mCurRecording->getDuration()).value() : 0.0);
 	stats.avatar.setProvided(true);
 
 	for (S32 rez_stat=0; rez_stat < mAvatarRezStates.size(); ++rez_stat)
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index acbe836c29..197d91593c 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -2587,7 +2587,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 				LLSD args;
 				args["SUBJECT"] = subj;
 				args["MESSAGE"] = mes;
-				LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).time_stamp(timestamp));
+				LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).time_stamp(LLDate(timestamp)));
 			}
 
 			// Also send down the old path for now.
@@ -4416,18 +4416,18 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 
 // *TODO: Remove this dependency, or figure out a better way to handle
 // this hack.
-extern LLUnit::Bits<U32> gObjectData;
+extern LLUnit<LLUnits::Bits, U32> gObjectData;
 
 void process_object_update(LLMessageSystem *mesgsys, void **user_data)
 {	
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4439,11 +4439,11 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4455,11 +4455,11 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data)
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4471,11 +4471,11 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 {
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit::Bytes<U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
 	}
 
 	gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 317fe5eaf8..36b1179e04 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -288,13 +288,13 @@ F32		gAveLandCompression = 0.f,
 		gWorstLandCompression = 0.f, 
 		gWorstWaterCompression = 0.f;
 
-LLUnit::Bytes<U32>		gTotalWorldData = 0, 
+LLUnit<LLUnits::Bytes, U32>		gTotalWorldData = 0, 
 						gTotalObjectData = 0, 
 						gTotalTextureData = 0;
 U32						gSimPingCount = 0;
-LLUnit::Bits<U32>		gObjectData = 0;
+LLUnit<LLUnits::Bits, U32>		gObjectData = 0;
 F32						gAvgSimPing = 0.f;
-LLUnit::Bytes<U32>		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
+LLUnit<LLUnits::Bytes, U32>		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
 
 extern U32  gVisCompared;
 extern U32  gVisTested;
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index eda7b3329d..14ee41dba0 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -319,7 +319,7 @@ void update_statistics();
 void send_stats();
 
 extern LLFrameTimer gTextureTimer;
-extern LLUnit::Bytes<U32>	gTotalTextureData;
-extern LLUnit::Bytes<U32>  gTotalObjectData;
-extern LLUnit::Bytes<U32>  gTotalTextureBytesPerBoostLevel[] ;
+extern LLUnit<LLUnits::Bytes, U32>	gTotalTextureData;
+extern LLUnit<LLUnits::Bytes, U32>  gTotalObjectData;
+extern LLUnit<LLUnits::Bytes, U32>  gTotalTextureBytesPerBoostLevel[] ;
 #endif // LL_LLVIEWERSTATS_H
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index ceb8d3155c..f4e8e3eae1 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -65,8 +65,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 // extern
-const LLUnit::Megabytes<S32> gMinVideoRam = 32;
-const LLUnit::Megabytes<S32> gMaxVideoRam = 512;
+const LLUnit<LLUnits::Megabytes, S32> gMinVideoRam = 32;
+const LLUnit<LLUnits::Megabytes, S32> gMaxVideoRam = 512;
 
 
 // statics
@@ -87,11 +87,11 @@ S32 LLViewerTexture::sAuxCount = 0;
 LLFrameTimer LLViewerTexture::sEvaluationTimer;
 F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
 F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
-LLUnit::Bytes<S32> LLViewerTexture::sBoundTextureMemory = 0;
-LLUnit::Bytes<S32> LLViewerTexture::sTotalTextureMemory = 0;
-LLUnit::Megabytes<S32> LLViewerTexture::sMaxBoundTextureMem = 0;
-LLUnit::Megabytes<S32> LLViewerTexture::sMaxTotalTextureMem = 0;
-LLUnit::Bytes<S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
+LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sBoundTextureMemory = 0;
+LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sTotalTextureMemory = 0;
+LLUnit<LLUnits::Megabytes, S32> LLViewerTexture::sMaxBoundTextureMem = 0;
+LLUnit<LLUnits::Megabytes, S32> LLViewerTexture::sMaxTotalTextureMem = 0;
+LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
 S8  LLViewerTexture::sCameraMovingDiscardBias = 0 ;
 F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
 S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
@@ -532,8 +532,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 	if (sBoundTextureMemory >= sMaxBoundTextureMem ||
 		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{
-		//when texture memory overflows, lower down the threashold to release the textures more aggressively.
-		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit::Bytes<S32>(gMaxVideoRam));
+		//when texture memory overflows, lower down the threshold to release the textures more aggressively.
+		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<LLUnits::Bytes, S32>(gMaxVideoRam));
 	
 		// If we are using more texture memory than we should,
 		// scale up the desired discard level
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index aa1e2010b4..e9efb751f8 100755
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -39,8 +39,8 @@
 #include <map>
 #include <list>
 
-extern const LLUnit::Megabytes<S32> gMinVideoRam;
-extern const LLUnit::Megabytes<S32> gMaxVideoRam;
+extern const LLUnit<LLUnits::Megabytes, S32> gMinVideoRam;
+extern const LLUnit<LLUnits::Megabytes, S32> gMaxVideoRam;
 
 class LLFace;
 class LLImageGL ;
@@ -323,11 +323,11 @@ public:
 	static LLFrameTimer sEvaluationTimer;
 	static F32 sDesiredDiscardBias;
 	static F32 sDesiredDiscardScale;
-	static LLUnit::Bytes<S32> sBoundTextureMemory;
-	static LLUnit::Bytes<S32> sTotalTextureMemory;
-	static LLUnit::Megabytes<S32> sMaxBoundTextureMem;
-	static LLUnit::Megabytes<S32> sMaxTotalTextureMem;
-	static LLUnit::Bytes<S32> sMaxDesiredTextureMem ;
+	static LLUnit<LLUnits::Bytes, S32> sBoundTextureMemory;
+	static LLUnit<LLUnits::Bytes, S32> sTotalTextureMemory;
+	static LLUnit<LLUnits::Megabytes, S32> sMaxBoundTextureMem;
+	static LLUnit<LLUnits::Megabytes, S32> sMaxTotalTextureMem;
+	static LLUnit<LLUnits::Bytes, S32> sMaxDesiredTextureMem ;
 	static S8  sCameraMovingDiscardBias;
 	static F32 sCameraMovingBias;
 	static S32 sMaxSculptRez ;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index b7415669bb..8e72ca1d74 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -733,7 +733,7 @@ public:
 			{
 				if(gTotalTextureBytesPerBoostLevel[i] > 0)
 				{
-					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit::Megabytes<F32>(gTotalTextureBytesPerBoostLevel[i]).value()));
+					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit<LLUnits::Megabytes, F32>(gTotalTextureBytesPerBoostLevel[i]).value()));
 					ypos += y_inc;
 				}
 			}
-- 
cgit v1.2.3


From a3e3e8b4ccd96e98da73acf1c584bbfa5a8b2b56 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 12 Nov 2012 19:08:14 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system simplified
 llfasttimer code down to 2 classes llunit unit conversion now done in
 floating point or 64 bit integer precision, depending on source type

---
 indra/newview/llfasttimerview.cpp | 98 +++++++++++++++++++++++----------------
 indra/newview/llfasttimerview.h   |  8 ++--
 indra/newview/pipeline.cpp        |  2 +-
 3 files changed, 62 insertions(+), 46 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 065b20ba2b..0934028a8c 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240;
 static S32 FTV_NUM_TIMERS;
 const S32 FTV_MAX_DEPTH = 8;
 
-std::vector<LLFastTimer::NamedTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
+std::vector<LLFastTimer::DeclareTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
-typedef LLTreeDFSIter<LLFastTimer::NamedTimer, LLFastTimer::NamedTimer::child_const_iter> timer_tree_iterator_t;
+typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_iterator_t;
 
 BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
 
-static timer_tree_iterator_t begin_timer_tree(LLFastTimer::NamedTimer& id) 
+static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) 
 { 
 	return timer_tree_iterator_t(&id, 
-							boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::beginChildren), _1), 
-							boost::bind(boost::mem_fn(&LLFastTimer::NamedTimer::endChildren), _1));
+							boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), 
+							boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1));
 }
 
 static timer_tree_iterator_t end_timer_tree() 
@@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mScrollIndex = 0;
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
-	FTV_NUM_TIMERS = LLFastTimer::NamedTimer::instanceCount();
+	FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount();
 	mPrintStats = -1;	
 }
 
@@ -139,13 +139,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	{
 		S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
 		bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
-		mPrintStats = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - bar_idx;
+		mPrintStats = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx;
 		return TRUE;
 	}
 	return LLFloater::handleRightMouseDown(x, y, mask);
 }
 
-LLFastTimer::NamedTimer* LLFastTimerView::getLegendID(S32 y)
+LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y)
 {
 	S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5;
 
@@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (x < mBarRect.mLeft) 
 	{
-		LLFastTimer::NamedTimer* idp = getLegendID(y);
+		LLFastTimer::DeclareTimer* idp = getLegendID(y);
 		if (idp)
 		{
 			idp->setCollapsed(!idp->getCollapsed());
@@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
-		mScrollIndex = llround( lerp * (F32)(LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+		mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
 		mScrollIndex = llclamp(	mScrollIndex, 0, LLFastTimer::getLastFrameIndex());
 		return TRUE;
 	}
@@ -288,7 +288,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	}
 	else if (x < mBarRect.mLeft) 
 	{
-		LLFastTimer::NamedTimer* timer_id = getLegendID(y);
+		LLFastTimer::DeclareTimer* timer_id = getLegendID(y);
 		if (timer_id)
 		{
 			mHoverID = timer_id;
@@ -299,6 +299,23 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 }
 
 
+static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1)
+{
+	F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond();
+
+	std::string tooltip;
+	if (history_index < 0)
+	{
+		// by default, show average number of call
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getCountAverage() * ms_multiplier), (S32)timer.getCallAverage());
+	}
+	else
+	{
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getHistoricalCount(history_index) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index));
+	}
+	return tooltip;
+}
+
 BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 {
 	if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y))
@@ -309,8 +326,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLRect screen_rect;
 			localRectToScreen(mToolTipRect, &screen_rect);
 
+			std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
+
 			LLToolTipMgr::instance().show(LLToolTip::Params()
-				.message(mHoverTimer->getToolTip(LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex))
+				.message(tooltip)
 				.sticky_rect(screen_rect)
 				.delay_time(0.f));
 
@@ -322,10 +341,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 		// tooltips for timer legend
 		if (x < mBarRect.mLeft) 
 		{
-			LLFastTimer::NamedTimer* idp = getLegendID(y);
+			LLFastTimer::DeclareTimer* idp = getLegendID(y);
 			if (idp)
 			{
-				LLToolTipMgr::instance().show(idp->getToolTip());
+				LLToolTipMgr::instance().show(get_tooltip(*idp));
 
 				return TRUE;
 			}
@@ -340,13 +359,13 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	LLFastTimer::sPauseHistory = TRUE;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::NamedTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+							llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
 static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true);
 
-static std::map<LLFastTimer::NamedTimer*, LLColor4> sTimerColors;
+static std::map<LLFastTimer::DeclareTimer*, LLColor4> sTimerColors;
 
 void LLFastTimerView::draw()
 {
@@ -426,7 +445,7 @@ void LLFastTimerView::draw()
 		it != timer_tree_iterator_t();
 		++it)
 	{
-		LLFastTimer::NamedTimer* idp = (*it);
+		LLFastTimer::DeclareTimer* idp = (*it);
 
 		const F32 HUE_INCREMENT = 0.23f;
 		hue = fmodf(hue + HUE_INCREMENT, 1.f);
@@ -446,12 +465,12 @@ void LLFastTimerView::draw()
 		LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
 		S32 cur_line = 0;
 		ft_display_idx.clear();
-		std::map<LLFastTimer::NamedTimer*, S32> display_line;
+		std::map<LLFastTimer::DeclareTimer*, S32> display_line;
 		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			LLFastTimer::NamedTimer* idp = (*it);
+			LLFastTimer::DeclareTimer* idp = (*it);
 			display_line[idp] = cur_line;
 			ft_display_idx.push_back(idp);
 			cur_line++;
@@ -471,7 +490,7 @@ void LLFastTimerView::draw()
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
-				S32 hidx = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
+				S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
 				U64 ticks = idp->getHistoricalCount(hidx);
 				ms = (F32)((F64)ticks * iclock_freq);
 				calls = (S32)idp->getHistoricalCalls(hidx);
@@ -509,7 +528,7 @@ void LLFastTimerView::draw()
 
 			x += dx;
 			BOOL is_child_of_hover_item = (idp == mHoverID);
-			LLFastTimer::NamedTimer* next_parent = idp->getParent();
+			LLFastTimer::DeclareTimer* next_parent = idp->getParent();
 			while(!is_child_of_hover_item && next_parent)
 			{
 				is_child_of_hover_item = (mHoverID == next_parent);
@@ -687,7 +706,7 @@ void LLFastTimerView::draw()
 			S32 tidx;
 			if (j >= 0)
 			{
-				tidx = LLFastTimer::NamedTimer::HISTORY_NUM - j - 1 - mScrollIndex;
+				tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex;
 			}
 			else
 			{
@@ -701,14 +720,14 @@ void LLFastTimerView::draw()
 			std::vector<S32> deltax;
 			xpos.push_back(xleft);
 			
-			LLFastTimer::NamedTimer* prev_id = NULL;
+			LLFastTimer::DeclareTimer* prev_id = NULL;
 
 			S32 i = 0;
 			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 				it != end_timer_tree();
 				++it, ++i)
 			{
-				LLFastTimer::NamedTimer* idp = (*it);
+				LLFastTimer::DeclareTimer* idp = (*it);
 				F32 frac = tidx == -1
 					? (F32)idp->getCountAverage() / (F32)totalticks 
 					: (F32)idp->getHistoricalCount(tidx) / (F32)totalticks;
@@ -735,7 +754,7 @@ void LLFastTimerView::draw()
 				{
 					U64 sublevelticks = 0;
 
-					for (LLFastTimer::NamedTimer::child_const_iter it = prev_id->beginChildren();
+					for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren();
 						it != prev_id->endChildren();
 						++it)
 					{
@@ -777,7 +796,7 @@ void LLFastTimerView::draw()
 					S32 scale_offset = 0;
 
 					BOOL is_child_of_hover_item = (idp == mHoverID);
-					LLFastTimer::NamedTimer* next_parent = idp->getParent();
+					LLFastTimer::DeclareTimer* next_parent = idp->getParent();
 					while(!is_child_of_hover_item && next_parent)
 					{
 						is_child_of_hover_item = (mHoverID == next_parent);
@@ -842,10 +861,10 @@ void LLFastTimerView::draw()
 
 			//highlight visible range
 			{
-				S32 first_frame = LLFastTimer::NamedTimer::HISTORY_NUM - mScrollIndex;
+				S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex;
 				S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 				
-				F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::NamedTimer::HISTORY_NUM-1);
+				F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1);
 				
 				F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
 				F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
@@ -872,7 +891,7 @@ void LLFastTimerView::draw()
 				it != end_timer_tree();
 				++it)
 			{
-				LLFastTimer::NamedTimer* idp = (*it);
+				LLFastTimer::DeclareTimer* idp = (*it);
 				
 				//fatten highlighted timer
 				if (mHoverID == idp)
@@ -896,8 +915,8 @@ void LLFastTimerView::draw()
 
 				gGL.color4f(col[0], col[1], col[2], alpha);				
 				gGL.begin(LLRender::TRIANGLE_STRIP);
-				for (U32 j = llmax(0, LLFastTimer::NamedTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex());
-					j < LLFastTimer::NamedTimer::HISTORY_NUM;
+				for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex());
+					j < LLFastTimer::DeclareTimer::HISTORY_NUM;
 					j++)
 				{
 					U64 ticks = idp->getHistoricalCount(j);
@@ -918,7 +937,7 @@ void LLFastTimerView::draw()
 						//normalize to highlighted timer
 						cur_max = llmax(cur_max, ticks);
 					}
-					F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::NamedTimer::HISTORY_NUM-1)*j;
+					F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j;
 					F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks;
 					gGL.vertex2f(x,y);
 					gGL.vertex2f(x,mGraphRect.mBottom);
@@ -973,7 +992,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLFastTimer::NamedTimer* idp = (*it);
+			LLFastTimer::DeclareTimer* idp = (*it);
 
 			if (!first)
 			{
@@ -995,7 +1014,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLFastTimer::NamedTimer* idp = (*it);
+			LLFastTimer::DeclareTimer* idp = (*it);
 
 			if (!first)
 			{
@@ -1033,11 +1052,8 @@ void LLFastTimerView::draw()
 
 F64 LLFastTimerView::getTime(const std::string& name)
 {
-	const LLFastTimer::NamedTimer* timerp = LLFastTimer::getTimerByName(name);
-	if (timerp)
-	{
-		return (F64)timerp->getCountAverage() / (F64)LLFastTimer::countsPerSecond();
-	}
+	//TODO: replace calls to this with use of timer object directly
+	//llstatic_assert(false, "TODO: implement");
 	return 0.0;
 }
 
@@ -1552,9 +1568,9 @@ void	LLFastTimerView::onClickCloseBtn()
 	setVisible(false);
 }
 
-LLFastTimer::NamedTimer& LLFastTimerView::getFrameTimer()
+LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer()
 {
-	return FTM_FRAME.getNamedTimer();
+	return FTM_FRAME;
 }
 
 
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 5766cfa0b0..01a3501e4b 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -46,7 +46,7 @@ private:
 	static LLSD analyzePerformanceLogDefault(std::istream& is) ;
 	static void exportCharts(const std::string& base, const std::string& target);
 	void onPause();
-	LLFastTimer::NamedTimer& getFrameTimer();
+	LLFastTimer::DeclareTimer& getFrameTimer();
 
 public:
 
@@ -59,7 +59,7 @@ public:
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
 
-	LLFastTimer::NamedTimer* getLegendID(S32 y);
+	LLFastTimer::DeclareTimer* getLegendID(S32 y);
 	F64 getTime(const std::string& name);
 
 protected:
@@ -85,8 +85,8 @@ private:
 	U64 mMaxCountTotal;
 	LLRect mBarRect;
 	S32	mScrollIndex;
-	LLFastTimer::NamedTimer* mHoverID;
-	LLFastTimer::NamedTimer* mHoverTimer;
+	LLFastTimer::DeclareTimer* mHoverID;
+	LLFastTimer::DeclareTimer* mHoverTimer;
 	LLRect					mToolTipRect;
 	S32 mHoverBarIndex;
 	LLFrameTimer mHighlightTimer;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index bf353cd1e0..5ac5ae892a 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2715,7 +2715,7 @@ void LLPipeline::updateGeom(F32 max_dtime)
 		
 	S32 count = 0;
 	
-	max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, max_dtime);
+	max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnit<LLUnits::Seconds, F32>(max_dtime));
 	LLSpatialGroup* last_group = NULL;
 	LLSpatialBridge* last_bridge = NULL;
 
-- 
cgit v1.2.3


From 9d77e030d9a0d23cebce616631677459eec1612c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 14 Nov 2012 23:52:27 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system cleaning up build
 moved most includes of windows.h to llwin32headers.h to disable min/max
 macros, etc streamlined Time class and consolidated functionality in
 BlockTimer class llfasttimer is no longer included via llstring.h, so had to
 add it manually in several places

---
 indra/newview/llappviewer.cpp     |  32 +++++------
 indra/newview/llfasttimerview.cpp | 117 ++++++++++++++++++--------------------
 indra/newview/llfasttimerview.h   |   8 +--
 indra/newview/llviewermenufile.h  |   1 +
 4 files changed, 75 insertions(+), 83 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ac659c409b..c6ed8d5071 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -679,7 +679,7 @@ bool LLAppViewer::init()
 	// into the log files during normal startup until AFTER
 	// we run the "program crashed last time" error handler below.
 	//
-	LLFastTimer::reset();
+	LLTrace::BlockTimer::reset();
 
 	// initialize SSE options
 	LLVector4a::initClass();
@@ -1222,7 +1222,7 @@ bool LLAppViewer::mainLoop()
 	while (!LLApp::isExiting())
 	{
 		LLFastTimer _(FTM_FRAME);
-		LLFastTimer::nextFrame(); 
+		LLTrace::BlockTimer::nextFrame(); 
 		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
 
 		//clear call stack records
@@ -1552,9 +1552,9 @@ bool LLAppViewer::cleanup()
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
 		llinfos << "Analyzing performance" << llendl;
-		std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
-		std::string current_name  = LLFastTimer::sLogName + ".slp"; 
-		std::string report_name   = LLFastTimer::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -1900,9 +1900,9 @@ bool LLAppViewer::cleanup()
 	{
 		llinfos << "Analyzing performance" << llendl;
 		
-		std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp";
-		std::string current_name  = LLFastTimer::sLogName + ".slp"; 
-		std::string report_name   = LLFastTimer::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -2031,10 +2031,10 @@ bool LLAppViewer::initThreads()
 													enable_threads && true,
 													app_metrics_qa_mode);	
 
-	if (LLFastTimer::sLog || LLFastTimer::sMetricLog)
+	if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog)
 	{
-		LLFastTimer::sLogLock = new LLMutex(NULL);
-		mFastTimerLogThread = new LLFastTimerLogThread(LLFastTimer::sLogName);
+		LLTrace::BlockTimer::sLogLock = new LLMutex(NULL);
+		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName);
 		mFastTimerLogThread->start();
 	}
 
@@ -2445,13 +2445,13 @@ bool LLAppViewer::initConfiguration()
 
 	if (clp.hasOption("logperformance"))
 	{
-		LLFastTimer::sLog = TRUE;
-		LLFastTimer::sLogName = std::string("performance");		
+		LLTrace::BlockTimer::sLog = true;
+		LLTrace::BlockTimer::sLogName = std::string("performance");		
 	}
 	
 	if (clp.hasOption("logmetrics"))
  	{
- 		LLFastTimer::sMetricLog = TRUE ;
+ 		LLTrace::BlockTimer::sMetricLog = true ;
 		// '--logmetrics' can be specified with a named test metric argument so the data gathering is done only on that test
 		// In the absence of argument, every metric is gathered (makes for a rather slow run and hard to decipher report...)
 		std::string test_name = clp.getOption("logmetrics")[0];
@@ -2459,11 +2459,11 @@ bool LLAppViewer::initConfiguration()
 		if (test_name == "")
 		{
 			llwarns << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << llendl;
-			LLFastTimer::sLogName = DEFAULT_METRIC_NAME;
+			LLTrace::BlockTimer::sLogName = DEFAULT_METRIC_NAME;
 		}
 		else
 		{
-			LLFastTimer::sLogName = test_name;
+			LLTrace::BlockTimer::sLogName = test_name;
 		}
  	}
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 0934028a8c..d0bb75225c 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -61,17 +61,17 @@ static const S32 LINE_GRAPH_HEIGHT = 240;
 static S32 FTV_NUM_TIMERS;
 const S32 FTV_MAX_DEPTH = 8;
 
-std::vector<LLFastTimer::DeclareTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
+std::vector<LLTrace::BlockTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
-typedef LLTreeDFSIter<LLFastTimer::DeclareTimer, LLFastTimer::DeclareTimer::child_const_iter> timer_tree_iterator_t;
+typedef LLTreeDFSIter<LLTrace::BlockTimer, LLTrace::BlockTimer::child_const_iter> timer_tree_iterator_t;
 
 BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
 
-static timer_tree_iterator_t begin_timer_tree(LLFastTimer::DeclareTimer& id) 
+static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id) 
 { 
 	return timer_tree_iterator_t(&id, 
-							boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::beginChildren), _1), 
-							boost::bind(boost::mem_fn(&LLFastTimer::DeclareTimer::endChildren), _1));
+							boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1), 
+							boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1));
 }
 
 static timer_tree_iterator_t end_timer_tree() 
@@ -92,18 +92,18 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mScrollIndex = 0;
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
-	FTV_NUM_TIMERS = LLFastTimer::DeclareTimer::instanceCount();
+	FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount();
 	mPrintStats = -1;	
 }
 
 void LLFastTimerView::onPause()
 {
-	LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory;
+	LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory;
 	// reset scroll to bottom when unpausing
-	if (!LLFastTimer::sPauseHistory)
+	if (!LLTrace::BlockTimer::sPauseHistory)
 	{
 		mScrollIndex = 0;
-		LLFastTimer::sResetHistory = true;
+		LLTrace::BlockTimer::sResetHistory = true;
 		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
 	}
 	else
@@ -139,13 +139,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	{
 		S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
 		bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
-		mPrintStats = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - bar_idx;
+		mPrintStats = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx;
 		return TRUE;
 	}
 	return LLFloater::handleRightMouseDown(x, y, mask);
 }
 
-LLFastTimer::DeclareTimer* LLFastTimerView::getLegendID(S32 y)
+LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y)
 {
 	S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5;
 
@@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (x < mBarRect.mLeft) 
 	{
-		LLFastTimer::DeclareTimer* idp = getLegendID(y);
+		LLTrace::BlockTimer* idp = getLegendID(y);
 		if (idp)
 		{
 			idp->setCollapsed(!idp->getCollapsed());
@@ -208,16 +208,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 		gFocusMgr.setMouseCapture(this);
 		return TRUE;
 	}
-	//else
-	//{
-	//	// pause/unpause
-	//	LLFastTimer::sPauseHistory = !LLFastTimer::sPauseHistory;
-	//	// reset scroll to bottom when unpausing
-	//	if (!LLFastTimer::sPauseHistory)
-	//	{
-	//		mScrollIndex = 0;
-	//	}
-	//}
+
 	return LLFloater::handleMouseDown(x, y, mask);
 }
 
@@ -235,14 +226,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
-		mScrollIndex = llround( lerp * (F32)(LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
-		mScrollIndex = llclamp(	mScrollIndex, 0, LLFastTimer::getLastFrameIndex());
+		mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+		mScrollIndex = llclamp(	mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex());
 		return TRUE;
 	}
 	mHoverTimer = NULL;
 	mHoverID = NULL;
 
-	if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, 
 								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
@@ -288,7 +279,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	}
 	else if (x < mBarRect.mLeft) 
 	{
-		LLFastTimer::DeclareTimer* timer_id = getLegendID(y);
+		LLTrace::BlockTimer* timer_id = getLegendID(y);
 		if (timer_id)
 		{
 			mHoverID = timer_id;
@@ -299,7 +290,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 }
 
 
-static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_index = -1)
+static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1)
 {
 	F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond();
 
@@ -318,7 +309,7 @@ static std::string get_tooltip(LLFastTimer::DeclareTimer& timer, S32 history_ind
 
 BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 {
-	if(LLFastTimer::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		// tooltips for timer bars
 		if (mHoverTimer)
@@ -326,7 +317,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLRect screen_rect;
 			localRectToScreen(mToolTipRect, &screen_rect);
 
-			std::string tooltip = get_tooltip(*mHoverTimer, LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
+			std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
 
 			LLToolTipMgr::instance().show(LLToolTip::Params()
 				.message(tooltip)
@@ -341,7 +332,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 		// tooltips for timer legend
 		if (x < mBarRect.mLeft) 
 		{
-			LLFastTimer::DeclareTimer* idp = getLegendID(y);
+			LLTrace::BlockTimer* idp = getLegendID(y);
 			if (idp)
 			{
 				LLToolTipMgr::instance().show(get_tooltip(*idp));
@@ -356,16 +347,16 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	LLFastTimer::sPauseHistory = TRUE;
+	LLTrace::BlockTimer::sPauseHistory = TRUE;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(LLFastTimer::getLastFrameIndex(), (S32)LLFastTimer::DeclareTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+							llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_TIMER("Timers", true);
+static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true);
 
-static std::map<LLFastTimer::DeclareTimer*, LLColor4> sTimerColors;
+static std::map<LLTrace::BlockTimer*, LLColor4> sTimerColors;
 
 void LLFastTimerView::draw()
 {
@@ -429,7 +420,7 @@ void LLFastTimerView::draw()
 		y -= (texth + 2);
 	}
 
-	S32 histmax = llmin(LLFastTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY);
+	S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY);
 		
 	// Draw the legend
 	xleft = margin;
@@ -445,7 +436,7 @@ void LLFastTimerView::draw()
 		it != timer_tree_iterator_t();
 		++it)
 	{
-		LLFastTimer::DeclareTimer* idp = (*it);
+		LLTrace::BlockTimer* idp = (*it);
 
 		const F32 HUE_INCREMENT = 0.23f;
 		hue = fmodf(hue + HUE_INCREMENT, 1.f);
@@ -465,12 +456,12 @@ void LLFastTimerView::draw()
 		LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
 		S32 cur_line = 0;
 		ft_display_idx.clear();
-		std::map<LLFastTimer::DeclareTimer*, S32> display_line;
+		std::map<LLTrace::BlockTimer*, S32> display_line;
 		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			LLFastTimer::DeclareTimer* idp = (*it);
+			LLTrace::BlockTimer* idp = (*it);
 			display_line[idp] = cur_line;
 			ft_display_idx.push_back(idp);
 			cur_line++;
@@ -490,7 +481,7 @@ void LLFastTimerView::draw()
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
-				S32 hidx = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
+				S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
 				U64 ticks = idp->getHistoricalCount(hidx);
 				ms = (F32)((F64)ticks * iclock_freq);
 				calls = (S32)idp->getHistoricalCalls(hidx);
@@ -528,7 +519,7 @@ void LLFastTimerView::draw()
 
 			x += dx;
 			BOOL is_child_of_hover_item = (idp == mHoverID);
-			LLFastTimer::DeclareTimer* next_parent = idp->getParent();
+			LLTrace::BlockTimer* next_parent = idp->getParent();
 			while(!is_child_of_hover_item && next_parent)
 			{
 				is_child_of_hover_item = (mHoverID == next_parent);
@@ -570,18 +561,18 @@ void LLFastTimerView::draw()
 	barw = width - xleft - margin;
 
 	// Draw the history bars
-	if (LLFastTimer::getLastFrameIndex() >= 0)
+	if (LLTrace::BlockTimer::getLastFrameIndex() >= 0)
 	{	
 		LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin));
 
 		U64 totalticks;
-		if (!LLFastTimer::sPauseHistory)
+		if (!LLTrace::BlockTimer::sPauseHistory)
 		{
 			U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex);
 
-			if (LLFastTimer::getCurFrameIndex() >= 10)
+			if (LLTrace::BlockTimer::getCurFrameIndex() >= 10)
 			{
-				U64 framec = LLFastTimer::getCurFrameIndex();
+				U64 framec = LLTrace::BlockTimer::getCurFrameIndex();
 				U64 avg = (U64)mAvgCountTotal;
 				mAvgCountTotal = (avg*framec + ticks) / (framec + 1);
 				if (ticks > mMaxCountTotal)
@@ -592,14 +583,14 @@ void LLFastTimerView::draw()
 
 			if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100)
 			{
-				LLFastTimer::sResetHistory = true;
+				LLTrace::BlockTimer::sResetHistory = true;
 			}
 
-			if (LLFastTimer::getCurFrameIndex() < 10 || LLFastTimer::sResetHistory)
+			if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory)
 			{
 				mAvgCountTotal = ticks;
 				mMaxCountTotal = ticks;
-				LLFastTimer::sResetHistory = false;
+				LLTrace::BlockTimer::sResetHistory = false;
 			}
 		}
 
@@ -706,7 +697,7 @@ void LLFastTimerView::draw()
 			S32 tidx;
 			if (j >= 0)
 			{
-				tidx = LLFastTimer::DeclareTimer::HISTORY_NUM - j - 1 - mScrollIndex;
+				tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex;
 			}
 			else
 			{
@@ -720,14 +711,14 @@ void LLFastTimerView::draw()
 			std::vector<S32> deltax;
 			xpos.push_back(xleft);
 			
-			LLFastTimer::DeclareTimer* prev_id = NULL;
+			LLTrace::BlockTimer* prev_id = NULL;
 
 			S32 i = 0;
 			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 				it != end_timer_tree();
 				++it, ++i)
 			{
-				LLFastTimer::DeclareTimer* idp = (*it);
+				LLTrace::BlockTimer* idp = (*it);
 				F32 frac = tidx == -1
 					? (F32)idp->getCountAverage() / (F32)totalticks 
 					: (F32)idp->getHistoricalCount(tidx) / (F32)totalticks;
@@ -754,7 +745,7 @@ void LLFastTimerView::draw()
 				{
 					U64 sublevelticks = 0;
 
-					for (LLFastTimer::DeclareTimer::child_const_iter it = prev_id->beginChildren();
+					for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren();
 						it != prev_id->endChildren();
 						++it)
 					{
@@ -796,7 +787,7 @@ void LLFastTimerView::draw()
 					S32 scale_offset = 0;
 
 					BOOL is_child_of_hover_item = (idp == mHoverID);
-					LLFastTimer::DeclareTimer* next_parent = idp->getParent();
+					LLTrace::BlockTimer* next_parent = idp->getParent();
 					while(!is_child_of_hover_item && next_parent)
 					{
 						is_child_of_hover_item = (mHoverID == next_parent);
@@ -861,10 +852,10 @@ void LLFastTimerView::draw()
 
 			//highlight visible range
 			{
-				S32 first_frame = LLFastTimer::DeclareTimer::HISTORY_NUM - mScrollIndex;
+				S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex;
 				S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 				
-				F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1);
+				F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1);
 				
 				F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
 				F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
@@ -891,7 +882,7 @@ void LLFastTimerView::draw()
 				it != end_timer_tree();
 				++it)
 			{
-				LLFastTimer::DeclareTimer* idp = (*it);
+				LLTrace::BlockTimer* idp = (*it);
 				
 				//fatten highlighted timer
 				if (mHoverID == idp)
@@ -915,8 +906,8 @@ void LLFastTimerView::draw()
 
 				gGL.color4f(col[0], col[1], col[2], alpha);				
 				gGL.begin(LLRender::TRIANGLE_STRIP);
-				for (U32 j = llmax(0, LLFastTimer::DeclareTimer::HISTORY_NUM - LLFastTimer::getLastFrameIndex());
-					j < LLFastTimer::DeclareTimer::HISTORY_NUM;
+				for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex());
+					j < LLTrace::BlockTimer::HISTORY_NUM;
 					j++)
 				{
 					U64 ticks = idp->getHistoricalCount(j);
@@ -937,7 +928,7 @@ void LLFastTimerView::draw()
 						//normalize to highlighted timer
 						cur_max = llmax(cur_max, ticks);
 					}
-					F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLFastTimer::DeclareTimer::HISTORY_NUM-1)*j;
+					F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j;
 					F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks;
 					gGL.vertex2f(x,y);
 					gGL.vertex2f(x,mGraphRect.mBottom);
@@ -992,7 +983,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLFastTimer::DeclareTimer* idp = (*it);
+			LLTrace::BlockTimer* idp = (*it);
 
 			if (!first)
 			{
@@ -1014,7 +1005,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLFastTimer::DeclareTimer* idp = (*it);
+			LLTrace::BlockTimer* idp = (*it);
 
 			if (!first)
 			{
@@ -1551,13 +1542,13 @@ void LLFastTimerView::outputAllMetrics()
 //static
 void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
 {
-	if(LLFastTimer::sLog)
+	if(LLTrace::BlockTimer::sLog)
 	{
 		doAnalysisDefault(baseline, target, output) ;
 		return ;
 	}
 
-	if(LLFastTimer::sMetricLog)
+	if(LLTrace::BlockTimer::sMetricLog)
 	{
 		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
 		return ;
@@ -1568,7 +1559,7 @@ void	LLFastTimerView::onClickCloseBtn()
 	setVisible(false);
 }
 
-LLFastTimer::DeclareTimer& LLFastTimerView::getFrameTimer()
+LLTrace::BlockTimer& LLFastTimerView::getFrameTimer()
 {
 	return FTM_FRAME;
 }
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 01a3501e4b..d7f7f27cd4 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -46,7 +46,7 @@ private:
 	static LLSD analyzePerformanceLogDefault(std::istream& is) ;
 	static void exportCharts(const std::string& base, const std::string& target);
 	void onPause();
-	LLFastTimer::DeclareTimer& getFrameTimer();
+	LLTrace::BlockTimer& getFrameTimer();
 
 public:
 
@@ -59,7 +59,7 @@ public:
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
 
-	LLFastTimer::DeclareTimer* getLegendID(S32 y);
+	LLTrace::BlockTimer* getLegendID(S32 y);
 	F64 getTime(const std::string& name);
 
 protected:
@@ -85,8 +85,8 @@ private:
 	U64 mMaxCountTotal;
 	LLRect mBarRect;
 	S32	mScrollIndex;
-	LLFastTimer::DeclareTimer* mHoverID;
-	LLFastTimer::DeclareTimer* mHoverTimer;
+	LLTrace::BlockTimer* mHoverID;
+	LLTrace::BlockTimer* mHoverTimer;
 	LLRect					mToolTipRect;
 	S32 mHoverBarIndex;
 	LLFrameTimer mHighlightTimer;
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 3136358b83..6bba375f50 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -31,6 +31,7 @@
 #include "llassetstorage.h"
 #include "llinventorytype.h"
 #include "llfilepicker.h"
+#include <queue>
 
 class LLTransactionID;
 
-- 
cgit v1.2.3


From c136b432140f892a56d4996d5ed77e903ff0b32d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 15 Nov 2012 19:46:09 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system eliminated min and
 max macros from windows.h got rest of viewer to compile against llfasttimer
 changes

---
 indra/newview/llappviewer.cpp           | 2 +-
 indra/newview/llfasttimerview.cpp       | 8 ++++----
 indra/newview/llfloatermodelpreview.cpp | 2 --
 indra/newview/llviewerstatsrecorder.h   | 2 +-
 indra/newview/llxmlrpctransaction.cpp   | 2 ++
 5 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c6ed8d5071..9d4ed833b8 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2033,7 +2033,7 @@ bool LLAppViewer::initThreads()
 
 	if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog)
 	{
-		LLTrace::BlockTimer::sLogLock = new LLMutex(NULL);
+		LLTrace::BlockTimer::setLogLock(new LLMutex(NULL));
 		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName);
 		mFastTimerLogThread->start();
 	}
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index d0bb75225c..7a5c9dba46 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mScrollIndex = 0;
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
-	FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount();
+	FTV_NUM_TIMERS = LLInstanceTracker<LLTrace::BlockTimer>::instanceCount();
 	mPrintStats = -1;	
 }
 
@@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
-		mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, 
+		mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, 
 								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
 		if (mHoverBarIndex == 0)
 		{
@@ -292,7 +292,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1)
 {
-	F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond();
+	F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond();
 
 	std::string tooltip;
 	if (history_index < 0)
@@ -364,7 +364,7 @@ void LLFastTimerView::draw()
 	
 	std::string tdesc;
 
-	F64 clock_freq = (F64)LLFastTimer::countsPerSecond();
+	F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond();
 	F64 iclock_freq = 1000.0 / clock_freq;
 	
 	S32 margin = 10;
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index a071f338ba..a5e3cd404d 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -113,8 +113,6 @@
 #include "llviewernetwork.h"
 #include "llviewershadermgr.h"
 #include "glod/glod.h"
-#include <boost/algorithm/string.hpp>
-
 
 const S32 SLM_SUPPORTED_VERSION = 3;
 
diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h
index ce6dd63ec5..d1744f4910 100644
--- a/indra/newview/llviewerstatsrecorder.h
+++ b/indra/newview/llviewerstatsrecorder.h
@@ -32,7 +32,7 @@
 // for analysis.
 
 // This is normally 0.  Set to 1 to enable viewer stats recording
-#define LL_RECORD_VIEWER_STATS	1
+#define LL_RECORD_VIEWER_STATS	0
 
 
 #include "llframetimer.h"
diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp
index 0da70d398b..583196fb7a 100644
--- a/indra/newview/llxmlrpctransaction.cpp
+++ b/indra/newview/llxmlrpctransaction.cpp
@@ -25,6 +25,8 @@
  */
 
 #include "llviewerprecompiledheaders.h"
+// include this to get winsock2 because openssl attempts to include winsock1
+#include "llwin32headerslean.h"
 #include <openssl/x509_vfy.h>
 #include <openssl/ssl.h>
 #include "llsecapi.h"
-- 
cgit v1.2.3


From 6db6cb39f41e921e75970d1570a74cf35d353a35 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 16 Nov 2012 23:02:53 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system got new fast timer
 code to compile and run

---
 indra/newview/llagentcamera.cpp      |  5 +++--
 indra/newview/llappviewer.cpp        |  8 ++++----
 indra/newview/llinventorypanel.cpp   |  3 ++-
 indra/newview/llstartup.cpp          |  2 +-
 indra/newview/llviewerobjectlist.cpp |  6 +++---
 indra/newview/llviewerwindow.cpp     |  3 ++-
 indra/newview/pipeline.cpp           | 35 ++++-------------------------------
 7 files changed, 19 insertions(+), 43 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 8d80e3aa0a..4e6079e3f2 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1137,13 +1137,14 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_CAMERA("Camera");
+
 //-----------------------------------------------------------------------------
 // updateCamera()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::updateCamera()
 {
-	static LLFastTimer::DeclareTimer ftm("Camera");
-	LLFastTimer t(ftm);
+	LLFastTimer t(FTM_UPDATE_CAMERA);
 
 	// - changed camera_skyward to the new global "mCameraUpVector"
 	mCameraUpVector = LLVector3::z_axis;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 9d4ed833b8..547eb2fefe 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4126,6 +4126,8 @@ static LLFastTimer::DeclareTimer FTM_WORLD_UPDATE("Update World");
 static LLFastTimer::DeclareTimer FTM_NETWORK("Network");
 static LLFastTimer::DeclareTimer FTM_AGENT_NETWORK("Agent Network");
 static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager");
+static LLFastTimer::DeclareTimer FTM_AGENT_POSITION("Agent Position");
+static LLFastTimer::DeclareTimer FTM_HUD_EFFECTS("HUD Effects");
 
 ///////////////////////////////////////////////////////
 // idle()
@@ -4362,8 +4364,7 @@ void LLAppViewer::idle()
 
 	{
 		// Handle pending gesture processing
-		static LLFastTimer::DeclareTimer ftm("Agent Position");
-		LLFastTimer t(ftm);
+		LLFastTimer t(FTM_AGENT_POSITION);
 		LLGestureMgr::instance().update();
 
 		gAgent.updateAgentPosition(gFrameDTClamped, yaw, current_mouse.mX, current_mouse.mY);
@@ -4410,8 +4411,7 @@ void LLAppViewer::idle()
 	//
 
 	{
-		static LLFastTimer::DeclareTimer ftm("HUD Effects");
-		LLFastTimer t(ftm);
+		LLFastTimer t(FTM_HUD_EFFECTS);
 		LLSelectMgr::getInstance()->updateEffects();
 		LLHUDManager::getInstance()->cleanupEffects();
 		LLHUDManager::getInstance()->sendEffects();
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index f7567baa2b..4c10717ce8 100644
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -396,9 +396,10 @@ LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState()
 	return getFilter()->getShowFolderState();
 }
 
+static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh");
+
 void LLInventoryPanel::modelChanged(U32 mask)
 {
-	static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh");
 	LLFastTimer t2(FTM_REFRESH);
 
 	bool handled = false;
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index bf47bd44c3..5f6772bf0b 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2184,7 +2184,7 @@ bool idle_startup()
 		LLAppViewer::instance()->handleLoginComplete();
 
 		// reset timers now that we are running "logged in" logic
-		LLFastTimer::reset();
+		LLTrace::BlockTimer::reset();
 
 		LLAgentPicksInfo::getInstance()->requestNumberOfPicks();
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 9c6045943f..1bd028688a 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -850,6 +850,8 @@ private:
 	LLSD mObjectIDs;
 };
 
+static LLFastTimer::DeclareTimer FTM_IDLE_COPY("Idle Copy");
+
 void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 {
 	// Update globals
@@ -900,10 +902,8 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 
 	U32 idle_count = 0;
 	
-	static LLFastTimer::DeclareTimer idle_copy("Idle Copy");
-
 	{
-		LLFastTimer t(idle_copy);
+		LLFastTimer t(FTM_IDLE_COPY);
 
  		for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
 			active_iter != mActiveObjects.end(); active_iter++)
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 8e72ca1d74..dea55fd0b0 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2760,11 +2760,12 @@ void append_xui_tooltip(LLView* viewp, LLToolTip::Params& params)
 	}
 }
 
+static LLFastTimer::DeclareTimer ftm("Update UI");
+
 // Update UI based on stored mouse position from mouse-move
 // event processing.
 void LLViewerWindow::updateUI()
 {
-	static LLFastTimer::DeclareTimer ftm("Update UI");
 	LLFastTimer t(ftm);
 
 	static std::string last_handle_msg;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 5ac5ae892a..acf3a4e74c 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1886,6 +1886,8 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list)
 
 static LLFastTimer::DeclareTimer FTM_OCTREE_BALANCE("Balance Octree");
 static LLFastTimer::DeclareTimer FTM_UPDATE_MOVE("Update Move");
+static LLFastTimer::DeclareTimer FTM_RETEXTURE("Retexture");
+static LLFastTimer::DeclareTimer FTM_MOVED_LIST("Moved List");
 
 void LLPipeline::updateMove()
 {
@@ -1899,8 +1901,7 @@ void LLPipeline::updateMove()
 	assertInitialized();
 
 	{
-		static LLFastTimer::DeclareTimer ftm("Retexture");
-		LLFastTimer t(ftm);
+		LLFastTimer t(FTM_RETEXTURE);
 
 		for (LLDrawable::drawable_set_t::iterator iter = mRetexturedList.begin();
 			 iter != mRetexturedList.end(); ++iter)
@@ -1915,8 +1916,7 @@ void LLPipeline::updateMove()
 	}
 
 	{
-		static LLFastTimer::DeclareTimer ftm("Moved List");
-		LLFastTimer t(ftm);
+		LLFastTimer t(FTM_MOVED_LIST);
 		updateMovedList(mMovedList);
 	}
 
@@ -3688,33 +3688,6 @@ void LLPipeline::postSort(LLCamera& camera)
 		}
 	}
 
-	/*static LLFastTimer::DeclareTimer FTM_TRANSFORM_WAIT("Transform Fence");
-	static LLFastTimer::DeclareTimer FTM_TRANSFORM_DO_WORK("Transform Work");
-	if (use_transform_feedback)
-	{ //using transform feedback, wait for transform feedback to complete
-		LLFastTimer t(FTM_TRANSFORM_WAIT);
-
-		S32 done = 0;
-		//glGetQueryivARB(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, GL_CURRENT_QUERY, &count);
-		
-		glGetQueryObjectivARB(mMeshDirtyQueryObject, GL_QUERY_RESULT_AVAILABLE, &done);
-		
-		while (!done)
-		{ 
-			{
-				LLFastTimer t(FTM_TRANSFORM_DO_WORK);
-				F32 max_time = llmin(gFrameIntervalSeconds*10.f, 1.f);
-				//do some useful work while we wait
-				LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
-				LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
-				LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread
-			}
-			glGetQueryObjectivARB(mMeshDirtyQueryObject, GL_QUERY_RESULT_AVAILABLE, &done);
-		}
-
-		mTransformFeedbackPrimitives = 0;
-	}*/
-						
 	//LLSpatialGroup::sNoDelete = FALSE;
 	llpushcallstacks ;
 }
-- 
cgit v1.2.3


From ed3d96069a5ecce17974812dbc9ab65ff8a6db4f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 19 Nov 2012 22:22:54 -0700
Subject: for SH-3352: Create pixel shader to accumulate frame-to-frame
 absolute pixel differences

---
 .../class1/interface/twotexturecompareF.glsl       | 42 ++++++++++++++++++++++
 .../class1/interface/twotexturecompareV.glsl       | 41 +++++++++++++++++++++
 indra/newview/llviewershadermgr.cpp                | 18 ++++++++++
 indra/newview/llviewershadermgr.h                  |  2 ++
 4 files changed, 103 insertions(+)
 create mode 100644 indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
new file mode 100644
index 0000000000..ec5f18e9bd
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
@@ -0,0 +1,42 @@
+/** 
+ * @file twotexturecompareF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2007, 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$
+ */
+
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor
+#endif
+
+uniform sampler2D tex0;
+uniform sampler2D tex1;
+
+VARYING vec2 vary_texcoord0;
+VARYING vec2 vary_texcoord1;
+
+void main() 
+{
+	frag_color = texture2D(tex0, vary_texcoord0.xy) - texture2D(tex1, vary_texcoord0.xy);
+	frag_color[3] = 1.f;
+}
diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl
new file mode 100644
index 0000000000..67c6674f0c
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareV.glsl
@@ -0,0 +1,41 @@
+/** 
+ * @file twotexturecompareV.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2007, 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$
+ */
+ 
+uniform mat4 modelview_projection_matrix;
+
+ATTRIBUTE vec3 position;
+ATTRIBUTE vec2 texcoord0;
+ATTRIBUTE vec2 texcoord1;
+
+VARYING vec2 vary_texcoord0;
+VARYING vec2 vary_texcoord1;
+
+void main()
+{
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	vary_texcoord0 = texcoord0;
+	vary_texcoord1 = texcoord1;
+}
+
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 4b0e0598f6..5295573709 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -78,6 +78,7 @@ LLGLSLShader	gGlowCombineProgram;
 LLGLSLShader	gSplatTextureRectProgram;
 LLGLSLShader	gGlowCombineFXAAProgram;
 LLGLSLShader	gTwoTextureAddProgram;
+LLGLSLShader	gTwoTextureCompareProgram;
 LLGLSLShader	gOneTextureNoColorProgram;
 LLGLSLShader	gDebugProgram;
 LLGLSLShader	gClipProgram;
@@ -672,6 +673,7 @@ void LLViewerShaderMgr::unloadShaders()
 	gSplatTextureRectProgram.unload();
 	gGlowCombineFXAAProgram.unload();
 	gTwoTextureAddProgram.unload();
+	gTwoTextureCompareProgram.unload();
 	gOneTextureNoColorProgram.unload();
 	gSolidColorProgram.unload();
 
@@ -2706,6 +2708,22 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
 		}
 	}
 
+	if (success)
+	{
+		gTwoTextureCompareProgram.mName = "Two Texture Compare Shader";
+		gTwoTextureCompareProgram.mShaderFiles.clear();
+		gTwoTextureCompareProgram.mShaderFiles.push_back(make_pair("interface/twotexturecompareV.glsl", GL_VERTEX_SHADER_ARB));
+		gTwoTextureCompareProgram.mShaderFiles.push_back(make_pair("interface/twotexturecompareF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gTwoTextureCompareProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+		success = gTwoTextureCompareProgram.createShader(NULL, NULL);
+		if (success)
+		{
+			gTwoTextureCompareProgram.bind();
+			gTwoTextureCompareProgram.uniform1i("tex0", 0);
+			gTwoTextureCompareProgram.uniform1i("tex1", 1);
+		}
+	}
+
 	if (success)
 	{
 		gOneTextureNoColorProgram.mName = "One Texture No Color Shader";
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index d6dd645e8c..8a706daa8f 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -233,6 +233,8 @@ extern LLGLSLShader			gAlphaMaskProgram;
 
 //output tex0[tc0] + tex1[tc1]
 extern LLGLSLShader			gTwoTextureAddProgram;
+//output tex0[tc0] - tex1[tc1]
+extern LLGLSLShader			gTwoTextureCompareProgram;
 						
 extern LLGLSLShader			gOneTextureNoColorProgram;
 
-- 
cgit v1.2.3


From c180fe2ae2b5d2e00149f9902717e02ed7042143 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 19 Nov 2012 22:28:12 -0700
Subject: for SH-3561: capture the frame buffer contents and compare pixel
 differences between frames.

---
 indra/newview/CMakeLists.txt                       |   2 +
 indra/newview/app_settings/settings.xml            |  14 +-
 indra/newview/lldebugview.cpp                      |  10 +-
 indra/newview/llscenemonitor.cpp                   | 358 +++++++++++++++++++++
 indra/newview/llscenemonitor.h                     |  87 +++++
 indra/newview/llviewerdisplay.cpp                  |   8 +
 indra/newview/llviewermenu.cpp                     |  10 +-
 indra/newview/llviewertexture.cpp                  |   6 +
 indra/newview/llviewertexture.h                    |   1 +
 indra/newview/llvoavatar.cpp                       |   6 +
 indra/newview/llworld.cpp                          |   4 +-
 indra/newview/skins/default/xui/en/menu_viewer.xml |  10 +
 12 files changed, 510 insertions(+), 6 deletions(-)
 create mode 100644 indra/newview/llscenemonitor.cpp
 create mode 100644 indra/newview/llscenemonitor.h

(limited to 'indra/newview')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index c81ade6937..377075ffd5 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -459,6 +459,7 @@ set(viewer_SOURCE_FILES
     llremoteparcelrequest.cpp
     llsavedsettingsglue.cpp
     llsaveoutfitcombobtn.cpp
+	llscenemonitor.cpp
     llsceneview.cpp
     llscreenchannel.cpp
     llscriptfloater.cpp
@@ -1025,6 +1026,7 @@ set(viewer_HEADER_FILES
     llrootview.h
     llsavedsettingsglue.h
     llsaveoutfitcombobtn.h
+	llscenemonitor.h
     llsceneview.h
     llscreenchannel.h
     llscriptfloater.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 13c95c2381..c6cfe3b616 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9469,6 +9469,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>SceneLoadingMonitorEnabled</key>
+    <map>
+      <key>Comment</key>
+      <string>Enabled scene loading monitor if set</string>
+      <key>Persist</key>
+      <integer>0</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>
     <key>ScriptHelpFollowsCursor</key>
     <map>
       <key>Comment</key>
@@ -10864,7 +10875,7 @@
       <key>Type</key>
       <string>F32</string>
       <key>Value</key>
-      <integer>0.0</integer>
+      <real>0.0</real>
     </map>
     <key>TextureFetchUpdateSkipLowPriority</key>
     <map>
@@ -12492,6 +12503,7 @@
       <key>Type</key>
       <string>LLSD</string>
       <key>Value</key>
+      <array />
     </map>
     <key>VFSOldSize</key>
     <map>
diff --git a/indra/newview/lldebugview.cpp b/indra/newview/lldebugview.cpp
index aeecf054b8..86f0213282 100644
--- a/indra/newview/lldebugview.cpp
+++ b/indra/newview/lldebugview.cpp
@@ -40,7 +40,7 @@
 #include "llsceneview.h"
 #include "llviewertexture.h"
 #include "llfloaterreg.h"
-
+#include "llscenemonitor.h"
 //
 // Globals
 //
@@ -66,6 +66,7 @@ LLDebugView::~LLDebugView()
 	gDebugView = NULL;
 	gTextureView = NULL;
 	gSceneView = NULL;
+	gSceneMonitorView = NULL;
 }
 
 void LLDebugView::init()
@@ -98,6 +99,13 @@ void LLDebugView::init()
 	gSceneView->setVisible(FALSE);
 	addChild(gSceneView);
 	gSceneView->setRect(rect);
+
+	gSceneMonitorView = new LLSceneMonitorView(r);
+	gSceneMonitorView->setFollowsTop();
+	gSceneMonitorView->setFollowsLeft();
+	gSceneMonitorView->setVisible(FALSE);
+	addChild(gSceneMonitorView);
+	gSceneMonitorView->setRect(rect);
 	
 	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
 									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
new file mode 100644
index 0000000000..8597767c61
--- /dev/null
+++ b/indra/newview/llscenemonitor.cpp
@@ -0,0 +1,358 @@
+/** 
+ * @file llscenemonitor.cpp
+ * @brief monitor the scene loading process.
+ *
+ * $LicenseInfo:firstyear=2003&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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 "llviewerprecompiledheaders.h"
+#include "llrendertarget.h"
+#include "llscenemonitor.h"
+#include "llviewerwindow.h"
+#include "llviewerdisplay.h"
+#include "llviewercontrol.h"
+#include "llviewershadermgr.h"
+#include "llui.h"
+#include "llstartup.h"
+#include "llappviewer.h"
+#include "llwindow.h"
+#include "llpointer.h"
+
+LLSceneMonitorView* gSceneMonitorView = NULL;
+
+LLSceneMonitor::LLSceneMonitor() : mEnabled(false), mDiff(NULL), mNeedsUpdateDiff(FALSE)
+{
+	mFrames[0] = NULL;
+	mFrames[1] = NULL;
+}
+
+LLSceneMonitor::~LLSceneMonitor()
+{
+	destroyClass();
+}
+
+void LLSceneMonitor::destroyClass()
+{
+	reset();
+}
+
+void LLSceneMonitor::reset()
+{
+	delete mFrames[0];
+	delete mFrames[1];
+	delete mDiff;
+
+	mFrames[0] = NULL;
+	mFrames[1] = NULL;
+	mDiff = NULL;
+}
+
+void LLSceneMonitor::setEnabled(bool enabled)
+{
+	if(enabled == (bool)gSavedSettings.getBOOL("SceneLoadingMonitorEnabled"))
+	{
+		return;
+	}
+	gSavedSettings.setBOOL("SceneLoadingMonitorEnabled", enabled);
+}
+
+bool LLSceneMonitor::preCapture()
+{
+	static LLCachedControl<bool> enabled(gSavedSettings,"SceneLoadingMonitorEnabled");
+	static LLFrameTimer timer;	
+
+	mCurTarget = NULL;
+	if (!LLGLSLShader::sNoFixedFunction)
+	{
+		return false;
+	}
+	if(mEnabled != (BOOL)enabled)
+	{
+		if(mEnabled)
+		{
+			reset();
+			unfreezeScene();
+		}
+		else
+		{
+			freezeScene();
+		}
+
+		mEnabled = (BOOL)enabled;
+	}
+
+	if(!mEnabled)
+	{
+		return false;
+	}
+
+	if (LLStartUp::getStartupState() < STATE_STARTED)
+	{
+		return false;
+	}
+
+	if(LLAppViewer::instance()->logoutRequestSent())
+	{
+		return false;
+	}
+
+	if(gWindowResized || gHeadlessClient || gTeleportDisplay || gRestoreGL || gDisconnected)
+	{
+		return false;
+	}
+
+	if (   !gViewerWindow->getActive()
+		|| !gViewerWindow->getWindow()->getVisible() 
+		|| gViewerWindow->getWindow()->getMinimized() )
+	{
+		return false;
+	}
+
+	if(timer.getElapsedTimeF32() < 1.0f)
+	{
+		return false;
+	}
+	timer.reset();
+	
+	S32 width = gViewerWindow->getWorldViewWidthRaw();
+	S32 height = gViewerWindow->getWorldViewHeightRaw();
+	
+	if(!mFrames[0])
+	{
+		mFrames[0] = new LLRenderTarget();
+		mFrames[0]->allocate(width, height, GL_RGB, false, false, LLTexUnit::TT_TEXTURE, true);
+		gGL.getTexUnit(0)->bind(mFrames[0]);
+		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+		mCurTarget = mFrames[0];
+	}
+	else if(!mFrames[1])
+	{
+		mFrames[1] = new LLRenderTarget();
+		mFrames[1]->allocate(width, height, GL_RGB, false, false, LLTexUnit::TT_TEXTURE, true);
+		gGL.getTexUnit(0)->bind(mFrames[1]);
+		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+		mCurTarget = mFrames[1];
+	}
+	else //swap
+	{
+		mCurTarget = mFrames[0];
+		mFrames[0] = mFrames[1];
+		mFrames[1] = mCurTarget;
+	}
+	
+	if(mCurTarget->getWidth() != width || mCurTarget->getHeight() != height) //size changed
+	{
+		mCurTarget->resize(width, height, GL_RGB);
+	}
+
+	return true;
+}
+
+void LLSceneMonitor::postCapture()
+{
+	mCurTarget = NULL;
+	mNeedsUpdateDiff = TRUE;
+}
+
+void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp)
+{
+	mAvatarPauseHandles.push_back(avatarp->requestPause());
+}
+
+void LLSceneMonitor::freezeScene()
+{
+	//freeze all avatars
+	for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
+		iter != LLCharacter::sInstances.end(); ++iter)
+	{
+		freezeAvatar((LLCharacter*)(*iter));
+	}
+
+	// freeze everything else
+	gSavedSettings.setBOOL("FreezeTime", TRUE);
+}
+
+void LLSceneMonitor::unfreezeScene()
+{
+	//thaw all avatars
+	mAvatarPauseHandles.clear();
+
+	// thaw everything else
+	gSavedSettings.setBOOL("FreezeTime", FALSE);
+}
+
+LLRenderTarget* LLSceneMonitor::getDiffTarget() const 
+{
+	return mDiff;
+}
+
+void LLSceneMonitor::capture()
+{
+	static U32 count = 0;
+	if(count == gFrameCount)
+	{
+		return;
+	}
+	count = gFrameCount;
+
+	preCapture();
+
+	if(!mCurTarget)
+	{
+		return;
+	}
+	
+	U32 old_FBO = LLRenderTarget::sCurFBO;
+
+	gGL.getTexUnit(0)->bind(mCurTarget);
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer.
+		
+	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, mCurTarget->getWidth(), mCurTarget->getHeight()); //copy the content
+	
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);		
+	glBindFramebuffer(GL_FRAMEBUFFER, old_FBO);
+
+	postCapture();
+}
+
+void LLSceneMonitor::compare()
+{
+	if(!mNeedsUpdateDiff)
+	{
+		return;
+	}
+
+	if(!mFrames[0] || !mFrames[1])
+	{
+		return;
+	}
+	if(mFrames[0]->getWidth() != mFrames[1]->getWidth() || mFrames[0]->getHeight() != mFrames[1]->getHeight())
+	{
+		return; //size does not match
+	}
+
+	if (!LLGLSLShader::sNoFixedFunction)
+	{
+		return;
+	}
+
+	S32 width = mFrames[0]->getWidth();
+	S32 height = mFrames[0]->getHeight();
+	if(!mDiff)
+	{
+		mDiff = new LLRenderTarget();
+		mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true);
+	}
+	else if(mDiff->getWidth() != width || mDiff->getHeight() != height)
+	{
+		mDiff->resize(width, height, GL_RGBA);
+	}
+	mDiff->bindTarget();
+	mDiff->clear();
+
+	gTwoTextureCompareProgram.bind();
+	
+	gGL.getTexUnit(0)->activate();
+	gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(0)->bind(mFrames[0]);
+	gGL.getTexUnit(0)->activate();
+
+	gGL.getTexUnit(1)->activate();
+	gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(1)->bind(mFrames[1]);
+	gGL.getTexUnit(1)->activate();	
+			
+	gl_rect_2d_simple_tex(width, height);
+	
+	gGL.flush();
+	mDiff->flush();
+
+	gTwoTextureCompareProgram.unbind();
+	
+	gGL.getTexUnit(0)->disable();
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(1)->disable();
+	gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+
+	mNeedsUpdateDiff = FALSE;
+}
+
+//-------------------------------------------------------------------------------------------------------------
+//definition of class LLSceneMonitorView
+//-------------------------------------------------------------------------------------------------------------
+LLSceneMonitorView::LLSceneMonitorView(const LLRect& rect)
+	:	LLFloater(LLSD())
+{
+	setRect(rect);
+	setVisible(FALSE);
+	
+	setCanMinimize(false);
+	setCanClose(true);
+}
+
+void LLSceneMonitorView::onClickCloseBtn()
+{
+	setVisible(false);	
+}
+
+void LLSceneMonitorView::setVisible(BOOL visible)
+{
+	if(visible != (BOOL)LLSceneMonitor::getInstance()->isEnabled())
+	{
+		LLSceneMonitor::getInstance()->setEnabled(visible);
+	}
+
+	LLView::setVisible(visible);
+}
+
+void LLSceneMonitorView::draw()
+{
+	if (!LLGLSLShader::sNoFixedFunction)
+	{
+		return;
+	}
+	LLRenderTarget* target = LLSceneMonitor::getInstance()->getDiffTarget();
+	if(!target)
+	{
+		return;
+	}
+
+	S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f);
+	S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f);
+	
+	LLRect new_rect;
+	new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
+	setRect(new_rect);
+
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
+	
+	gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target);//, LLColor4(0.f, 0.f, 0.f, 0.25f));
+
+	LLView::draw();
+}
+
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
new file mode 100644
index 0000000000..941039cefd
--- /dev/null
+++ b/indra/newview/llscenemonitor.h
@@ -0,0 +1,87 @@
+/** 
+ * @file llscenemonitor.h
+ * @brief monitor the process of scene loading
+ *
+ * $LicenseInfo:firstyear=2003&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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$
+ */
+
+#ifndef LL_LLSCENE_MONITOR_H
+#define LL_LLSCENE_MONITOR_H
+
+#include "llsingleton.h"
+#include "llmath.h"
+#include "llfloater.h"
+#include "llcharacter.h"
+
+class LLCharacter;
+class LLRenderTarget;
+
+class LLSceneMonitor :  public LLSingleton<LLSceneMonitor>
+{
+public:
+	LLSceneMonitor();
+	~LLSceneMonitor();
+
+	void destroyClass();
+	
+	void freezeAvatar(LLCharacter* avatarp);
+	void setEnabled(bool enabled);
+
+	void capture(); //capture the main frame buffer
+	void compare(); //compare the stored two buffers.	
+
+	LLRenderTarget* getDiffTarget() const;
+	bool isEnabled()const {return mEnabled;}
+	
+private:
+	void freezeScene();
+	void unfreezeScene();
+	void reset();
+	bool preCapture();
+	void postCapture();
+	
+private:
+	BOOL mEnabled;
+	BOOL mNeedsUpdateDiff;
+	LLRenderTarget* mFrames[2];
+	LLRenderTarget* mDiff;
+	LLRenderTarget* mCurTarget;
+
+	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
+};
+
+class LLSceneMonitorView : public LLFloater
+{
+public:
+	LLSceneMonitorView(const LLRect& rect);
+
+	virtual void draw();
+	virtual void setVisible(BOOL visible);
+
+protected:
+	virtual void onClickCloseBtn();
+};
+
+extern LLSceneMonitorView* gSceneMonitorView;
+
+#endif
+
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index ffeea2f4df..c12144df6f 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -77,6 +77,7 @@
 #include "llwlparammanager.h"
 #include "llwaterparammanager.h"
 #include "llpostprocess.h"
+#include "llscenemonitor.h"
 
 extern LLPointer<LLViewerTexture> gStartTexture;
 extern bool gShiftFrame;
@@ -989,6 +990,11 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 		LLPipeline::sUnderWaterRender = FALSE;
 
+		{
+			//capture the frame buffer.
+			LLSceneMonitor::getInstance()->capture();
+		}
+
 		LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI");
 		if (!for_snapshot)
 		{
@@ -1403,6 +1409,8 @@ void render_ui_2d()
 	//  Menu overlays, HUD, etc
 	gViewerWindow->setup2DRender();
 
+	LLSceneMonitor::getInstance()->compare();
+
 	F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor();
 	S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion();
 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 4ec498dc33..4dfcf1efce 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -121,6 +121,7 @@
 #include "llwindow.h"
 #include "llpathfindingmanager.h"
 #include "boost/unordered_map.hpp"
+#include "llscenemonitor.h"
 
 using namespace LLVOAvatarDefines;
 
@@ -528,7 +529,10 @@ class LLAdvancedToggleConsole : public view_listener_t
 		{
 			toggle_visibility( (void*)gSceneView);
 		}
-
+		else if ("scene monitor" == console_type)
+		{
+			toggle_visibility( (void*)gSceneMonitorView);
+		}
 #if MEM_TRACK_MEM
 		else if ("memory view" == console_type)
 		{
@@ -556,9 +560,9 @@ class LLAdvancedCheckConsole : public view_listener_t
 		{
 			new_value = LLFloaterReg::instanceVisible("fast_timers");
 		}
-		else if ("scene view" == console_type)
+		else if ("scene monitor" == console_type)
 		{
-			new_value = get_visibility( (void*) gSceneView);
+			new_value = get_visibility( (void*) gSceneMonitorView);
 		}
 #if MEM_TRACK_MEM
 		else if ("memory view" == console_type)
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index b0f8f60d1e..45b6bf2828 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -953,6 +953,12 @@ void LLViewerTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw)
 	//nothing here.
 }
 
+BOOL LLViewerTexture::setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height)
+{
+	llassert(mGLTexturep.notNull()) ;
+	return mGLTexturep->setSubImageFromFrameBuffer(fb_x, fb_y, x_pos, y_pos, width, height);
+}
+
 void LLViewerTexture::setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes)
 {
 	llassert(mGLTexturep.notNull()) ;
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 2ea9a07e9a..7095e97b39 100755
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -211,6 +211,7 @@ public:
 	BOOL       createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0, BOOL to_create = TRUE, S32 category = LLViewerTexture::OTHER);
 	virtual void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ;
 
+	BOOL       setSubImageFromFrameBuffer(S32 fb_x, S32 fb_y, S32 x_pos, S32 y_pos, S32 width, S32 height);
 	void       setFilteringOption(LLTexUnit::eTextureFilterOptions option);
 	void       setExplicitFormat(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format = 0, BOOL swap_bytes = FALSE);
 	void       setAddressMode(LLTexUnit::eTextureAddressMode mode);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index d366455a62..1fab3b68d5 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -102,6 +102,7 @@
 
 #include "lldebugmessagebox.h"
 #include "llsdutil.h"
+#include "llscenemonitor.h"
 
 extern F32 SPEED_ADJUST_MAX;
 extern F32 SPEED_ADJUST_MAX_SEC;
@@ -771,6 +772,11 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 	mLastPelvisToFoot = 0.0f;
 	mPelvisFixup = 0.0f;
 	mLastPelvisFixup = 0.0f;
+
+	if(LLSceneMonitor::getInstance()->isEnabled())
+	{
+		LLSceneMonitor::getInstance()->freezeAvatar((LLCharacter*)this);
+	}
 }
 
 std::string LLVOAvatar::avString() const
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 0a622997f7..aed2835e4a 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -55,7 +55,7 @@
 #include "message.h"
 #include "pipeline.h"
 #include "llappviewer.h"		// for do_disconnect()
-
+#include "llscenemonitor.h"
 #include <deque>
 #include <queue>
 #include <map>
@@ -136,6 +136,8 @@ void LLWorld::destroyClass()
 
 	//make all visible drawbles invisible.
 	LLDrawable::incrementVisible();
+
+	LLSceneMonitor::getInstance()->destroyClass();
 }
 
 
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index c6d9f9ef8f..7923cc9f62 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -1981,6 +1981,16 @@
                function="Advanced.ToggleConsole"
                parameter="scene view" />
             </menu_item_check>
+            <menu_item_check
+                 label="Scene Loading Monitor"
+                 name="Scene Loading Monitor">
+              <menu_item_check.on_check
+               function="Advanced.CheckConsole"
+               parameter="scene monitor" />
+              <menu_item_check.on_click
+               function="Advanced.ToggleConsole"
+               parameter="scene monitor" />
+            </menu_item_check>
             <menu_item_call
               enabled="false"
               visible="false"
-- 
cgit v1.2.3


From 5d51175cd79b15cf036cd7e6bd646a1a0777eb7f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 20 Nov 2012 15:55:04 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system fixes to merge

---
 indra/newview/gpu_table.txt      | 10 ----------
 indra/newview/lltexturefetch.cpp | 12 ++++++------
 indra/newview/lltexturefetch.h   |  2 +-
 indra/newview/lltextureview.cpp  |  4 ++--
 4 files changed, 9 insertions(+), 19 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/gpu_table.txt b/indra/newview/gpu_table.txt
index 2a07b5ed70..5e8189caa5 100644
--- a/indra/newview/gpu_table.txt
+++ b/indra/newview/gpu_table.txt
@@ -371,17 +371,10 @@ NVIDIA GTX 690M							.*NVIDIA .*GTX *69*M.*					5	1	0	0
 NVIDIA G100								.*NVIDIA .*G10.*						3	1	1	4.2
 NVIDIA GT 120							.*NVIDIA .*GT *12.*						2	1	0	0
 NVIDIA GT 130							.*NVIDIA .*GT *13.*						2	1	0	0
-NVIDIA GT 140							.*NVIDIA .*GT *140.*					2	1	0	0
-NVIDIA GT 150							.*NVIDIA .*GT *150.*					2	1	0	0
-NVIDIA GT 160							.*NVIDIA .*GT *160.*					2	1	0	0
 NVIDIA GTS 150							.*NVIDIA .*GTS *15.*					2	1	0	0
 NVIDIA 205								.*NVIDIA .*GeForce 205.*				2	1	1	3.3
 NVIDIA 210								.*NVIDIA .*GeForce 210.*				3	1	1	3.3
 NVIDIA GT 220							.*NVIDIA .*GT *22.*						2	1	1	3.3
-NVIDIA GT 230							.*NVIDIA .*GT *230.*					2	1	1	3.3
-NVIDIA GT 240							.*NVIDIA .*GT *240.*					2	1	1	3.3
-NVIDIA GT 250							.*NVIDIA .*GT *250.*					2	1	1	3.3
-NVIDIA GT 260							.*NVIDIA .*GT *260.*					2	1	1	3.3
 NVIDIA GTS 240							.*NVIDIA .*GTS *24.*					4	1	1	3.3
 NVIDIA GTS 250							.*NVIDIA .*GTS *25.*					4	1	1	3.3
 NVIDIA GTX 260							.*NVIDIA .*GTX *26.*					4	1	1	3.3
@@ -394,11 +387,9 @@ NVIDIA GT 320							.*NVIDIA .*GT *32.*						3	1	0	0
 NVIDIA GT 330							.*NVIDIA .*GT *33.*						3	1	0	0
 NVIDIA GT 340							.*NVIDIA .*GT *34.*						3	1	0	0
 NVIDIA 405								.*NVIDIA .* 405.*						3	1	0	0
-NVIDIA GT 415							.*NVIDIA .*GT *415.*					3	1	1	4.2
 NVIDIA GT 420							.*NVIDIA .*GT *42.*						3	1	1	4.2
 NVIDIA GT 430							.*NVIDIA .*GT *43.*						3	1	1	4.1
 NVIDIA GT 440							.*NVIDIA .*GT *44.*						4	1	0	0
-NVIDIA GT 450							.*NVIDIA .*GT *45.*						4	1	0	0
 NVIDIA GTS 450							.*NVIDIA .*GTS *45.*					4	1	1	4.2
 NVIDIA GTX 460							.*NVIDIA .*GTX *46.*					5	1	1	4.2
 NVIDIA GTX 470							.*NVIDIA .*GTX *47.*					5	1	1	4.2
@@ -407,7 +398,6 @@ NVIDIA 510								.*NVIDIA .* 510.*						3	1	0	0
 NVIDIA GT 520							.*NVIDIA .*GT *52.*						3	1	1	4.2
 NVIDIA GT 530							.*NVIDIA .*GT *53.*						3	1	1	4.2
 NVIDIA GT 540							.*NVIDIA .*GT *54.*						3	1	1	4.2
-NVIDIA GT 550							.*NVIDIA .*GT *55.*						3	1	1	4.2
 NVIDIA GTX 550							.*NVIDIA .*GTX *55.*					5	1	1	4.2
 NVIDIA GTX 560							.*NVIDIA .*GTX *56.*					5	1	1	4.2
 NVIDIA GTX 570							.*NVIDIA .*GTX *57.*					5	1	1	4.2
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 885292131f..9f1c7855be 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -2280,7 +2280,7 @@ void LLTextureFetchWorker::recordTextureStart(bool is_http)
 	{
 		mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
 	}
-	LLViewerAssetStatsFF::record_enqueue_thread1(LLViewerAssetType::AT_TEXTURE,
+	LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE,
 												 is_http,
 												 LLImageBase::TYPE_AVATAR_BAKE == mType);
 }
@@ -2291,13 +2291,13 @@ void LLTextureFetchWorker::recordTextureDone(bool is_http)
 {
 	if (mMetricsStartTime)
 	{
-		LLViewerAssetStatsFF::record_response_thread1(LLViewerAssetType::AT_TEXTURE,
+		LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE,
 													  is_http,
 													  LLImageBase::TYPE_AVATAR_BAKE == mType,
 													  LLViewerAssetStatsFF::get_timestamp() - mMetricsStartTime);
 		mMetricsStartTime = 0;
 	}
-	LLViewerAssetStatsFF::record_dequeue_thread1(LLViewerAssetType::AT_TEXTURE,
+	LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE,
 												 is_http,
 												 LLImageBase::TYPE_AVATAR_BAKE == mType);
 }
@@ -2826,9 +2826,9 @@ S32 LLTextureFetch::update(F32 max_time_ms)
 
 	{
 		mNetworkQueueMutex.lock();										// +Mfnq
-	mMaxBandwidth = band_width ;
+		mMaxBandwidth = band_width ;
 
-		gTextureList.sTextureBits += mHTTPTextureBits;
+		LLStatViewer::TEXTURE_KBIT.add(mHTTPTextureBits);
 		mHTTPTextureBits = 0;
 
 		mNetworkQueueMutex.unlock();									// -Mfnq
@@ -3702,7 +3702,7 @@ AssetReportHandler stats_handler;
 bool
 TFReqSetRegion::doWork(LLTextureFetch *)
 {
-	LLViewerAssetStatsFF::set_region_thread1(mRegionHandle);
+	LLViewerAssetStatsFF::set_region(mRegionHandle);
 
 	return true;
 }
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 90d0c7e04b..2c1e7502e5 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -329,7 +329,7 @@ private:
 	LLTextureInfo mTextureInfo;
 
 	// XXX possible delete
-	U32 mHTTPTextureBits;												// Mfnq
+	LLUnit<LLUnits::Bits, U32> mHTTPTextureBits;												// Mfnq
 
 	// XXX possible delete
 	//debug use
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 5331bb03cb..1d54e50bb9 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -514,8 +514,8 @@ void LLGLTexMemBar::draw()
 	F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
-	F32 total_texture_downloaded = (F32)gTotalTextureBytes / (1024 * 1024);
-	F32 total_object_downloaded = (F32)gTotalObjectBytes / (1024 * 1024);
+	LLUnit<LLUnits::Bytes, F32> total_texture_downloaded = gTotalTextureData;
+	LLUnit<LLUnits::Bytes, F32> total_object_downloaded = gTotalObjectData;
 	U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests() ;
 	//----------------------------------------------------------------------------
 	LLGLSUIDefault gls_ui;
-- 
cgit v1.2.3


From 551411247b8e4701e4768f61717b644750af83a7 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 20 Nov 2012 21:37:04 -0700
Subject: fix a crash caused by object cache for SH-3333.

---
 indra/newview/llviewerregion.cpp |  2 +-
 indra/newview/llvocache.cpp      | 12 ++++++------
 indra/newview/llvocache.h        |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 24bd68825b..e275b44e92 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -746,7 +746,7 @@ void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry
 
 	if(old_entry)
 	{
-		new_entry->copy(old_entry);
+		old_entry->copyTo(new_entry);
 		state = old_entry->getState();		
 		killCacheEntry(old_entry);
 	}
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index ec8585852b..8ea79dbae6 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -234,20 +234,20 @@ void LLVOCacheEntry::clearBridgeChild()
 	mState &= ~BRIDGE_CHILD;
 }
 
-void LLVOCacheEntry::copy(LLVOCacheEntry* entry)
+void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry)
 {
 	//copy LLViewerOctreeEntry
-	LLViewerOctreeEntry* oct_entry = entry->getEntry();
-	if(!oct_entry)
+	if(mEntry.notNull())
 	{
-		setOctreeEntry(oct_entry);
+		new_entry->setOctreeEntry(mEntry);
+		mEntry = NULL;
 	}
 
 	//copy children
-	S32 num_children = entry->getNumOfChildren();
+	S32 num_children = getNumOfChildren();
 	for(S32 i = 0; i < num_children; i++)
 	{
-		addChild(entry->getChild(i));
+		new_entry->addChild(getChild(i));
 	}
 }
 
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index ded29dd990..4d058ffdac 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -111,7 +111,7 @@ public:
 	void recordHit();
 	void recordDupe() { mDupeCount++; }
 	
-	void copy(LLVOCacheEntry* entry); //copy variables 
+	void copyTo(LLVOCacheEntry* new_entry); //copy variables 
 	/*virtual*/ void setOctreeEntry(LLViewerOctreeEntry* entry);
 
 	void addChild(LLVOCacheEntry* entry);
-- 
cgit v1.2.3


From ced00c47328f69a5426e6c69dce59c8f29856c51 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 20 Nov 2012 21:37:53 -0700
Subject: more for SH-3352: Create pixel shader to accumulate frame-to-frame
 absolute pixel differences

---
 .../shaders/class1/interface/twotexturecompareF.glsl        | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
index ec5f18e9bd..92aa7602a4 100644
--- a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
@@ -38,5 +38,18 @@ VARYING vec2 vary_texcoord1;
 void main() 
 {
 	frag_color = texture2D(tex0, vary_texcoord0.xy) - texture2D(tex1, vary_texcoord0.xy);
+	
+	if(frag_color[0] < 0.f)
+	{
+		frag_color[0] = -frag_color[0];
+	}
+	if(frag_color[1] < 0.f)
+	{
+		frag_color[1] = -frag_color[1];
+	}
+	if(frag_color[2] < 0.f)
+	{
+		frag_color[2] = -frag_color[2];
+	}
 	frag_color[3] = 1.f;
 }
-- 
cgit v1.2.3


From 6ae6abae26200c80a15d2e2d899ae6970602ff04 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 21 Nov 2012 13:29:15 -0700
Subject: more for SH-3571: display frame-to-frame pixel differences on screen

---
 indra/newview/app_settings/settings.xml            |  2 +-
 .../class1/interface/twotexturecompareF.glsl       |  2 +-
 indra/newview/llscenemonitor.cpp                   | 43 +++++++++++-----------
 indra/newview/llscenemonitor.h                     |  4 +-
 indra/newview/llviewerdisplay.cpp                  |  9 ++++-
 5 files changed, 33 insertions(+), 27 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c6cfe3b616..7fc7a7ad3b 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9474,7 +9474,7 @@
       <key>Comment</key>
       <string>Enabled scene loading monitor if set</string>
       <key>Persist</key>
-      <integer>0</integer>
+      <integer>1</integer>
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
index 92aa7602a4..336ca21b96 100644
--- a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
@@ -51,5 +51,5 @@ void main()
 	{
 		frag_color[2] = -frag_color[2];
 	}
-	frag_color[3] = 1.f;
+	frag_color[3] = 0.95f;
 }
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 8597767c61..0730281d85 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -39,7 +39,12 @@
 
 LLSceneMonitorView* gSceneMonitorView = NULL;
 
-LLSceneMonitor::LLSceneMonitor() : mEnabled(false), mDiff(NULL), mNeedsUpdateDiff(FALSE)
+LLSceneMonitor::LLSceneMonitor() : 
+	mEnabled(FALSE), 
+	mDiff(NULL), 
+	mCurTarget(NULL), 
+	mNeedsUpdateDiff(FALSE), 
+	mDebugViewerVisible(FALSE)
 {
 	mFrames[0] = NULL;
 	mFrames[1] = NULL;
@@ -66,18 +71,14 @@ void LLSceneMonitor::reset()
 	mDiff = NULL;
 }
 
-void LLSceneMonitor::setEnabled(bool enabled)
+void LLSceneMonitor::setDebugViewerVisible(BOOL visible) 
 {
-	if(enabled == (bool)gSavedSettings.getBOOL("SceneLoadingMonitorEnabled"))
-	{
-		return;
-	}
-	gSavedSettings.setBOOL("SceneLoadingMonitorEnabled", enabled);
+	mDebugViewerVisible = visible;
 }
 
 bool LLSceneMonitor::preCapture()
 {
-	static LLCachedControl<bool> enabled(gSavedSettings,"SceneLoadingMonitorEnabled");
+	static LLCachedControl<bool> monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled");
 	static LLFrameTimer timer;	
 
 	mCurTarget = NULL;
@@ -85,7 +86,9 @@ bool LLSceneMonitor::preCapture()
 	{
 		return false;
 	}
-	if(mEnabled != (BOOL)enabled)
+
+	BOOL enabled = (BOOL)monitor_enabled || mDebugViewerVisible;
+	if(mEnabled != enabled)
 	{
 		if(mEnabled)
 		{
@@ -97,7 +100,7 @@ bool LLSceneMonitor::preCapture()
 			freezeScene();
 		}
 
-		mEnabled = (BOOL)enabled;
+		mEnabled = enabled;
 	}
 
 	if(!mEnabled)
@@ -260,8 +263,8 @@ void LLSceneMonitor::compare()
 		return;
 	}
 
-	S32 width = mFrames[0]->getWidth();
-	S32 height = mFrames[0]->getHeight();
+	S32 width = gViewerWindow->getWindowWidthRaw();
+	S32 height = gViewerWindow->getWindowHeightRaw();
 	if(!mDiff)
 	{
 		mDiff = new LLRenderTarget();
@@ -288,7 +291,6 @@ void LLSceneMonitor::compare()
 			
 	gl_rect_2d_simple_tex(width, height);
 	
-	gGL.flush();
 	mDiff->flush();
 
 	gTwoTextureCompareProgram.unbind();
@@ -321,10 +323,7 @@ void LLSceneMonitorView::onClickCloseBtn()
 
 void LLSceneMonitorView::setVisible(BOOL visible)
 {
-	if(visible != (BOOL)LLSceneMonitor::getInstance()->isEnabled())
-	{
-		LLSceneMonitor::getInstance()->setEnabled(visible);
-	}
+	LLSceneMonitor::getInstance()->setDebugViewerVisible(visible);
 
 	LLView::setVisible(visible);
 }
@@ -341,17 +340,17 @@ void LLSceneMonitorView::draw()
 		return;
 	}
 
-	S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f);
-	S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f);
+	S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f);
+	S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f);
 	
 	LLRect new_rect;
 	new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
 	setRect(new_rect);
 
-	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-	gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
+	//gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	//gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
 	
-	gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target);//, LLColor4(0.f, 0.f, 0.f, 0.25f));
+	gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target);
 
 	LLView::draw();
 }
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 941039cefd..648429f97b 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -44,7 +44,7 @@ public:
 	void destroyClass();
 	
 	void freezeAvatar(LLCharacter* avatarp);
-	void setEnabled(bool enabled);
+	void setDebugViewerVisible(BOOL visible);
 
 	void capture(); //capture the main frame buffer
 	void compare(); //compare the stored two buffers.	
@@ -62,6 +62,8 @@ private:
 private:
 	BOOL mEnabled;
 	BOOL mNeedsUpdateDiff;
+	BOOL mDebugViewerVisible;
+
 	LLRenderTarget* mFrames[2];
 	LLRenderTarget* mDiff;
 	LLRenderTarget* mCurTarget;
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index c12144df6f..270ab26149 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1228,6 +1228,13 @@ void render_ui(F32 zoom_factor, int subfield)
 		glh_set_current_modelview(glh_copy_matrix(gGLLastModelView));
 	}
 	
+	{
+		gGL.pushMatrix();
+		gViewerWindow->setup2DRender();
+		LLSceneMonitor::getInstance()->compare();
+		gGL.popMatrix();
+	}
+
 	{
 		BOOL to_texture = gPipeline.canUseVertexShaders() &&
 							LLPipeline::sRenderGlow;
@@ -1409,8 +1416,6 @@ void render_ui_2d()
 	//  Menu overlays, HUD, etc
 	gViewerWindow->setup2DRender();
 
-	LLSceneMonitor::getInstance()->compare();
-
 	F32 zoom_factor = LLViewerCamera::getInstance()->getZoomFactor();
 	S16 sub_region = LLViewerCamera::getInstance()->getZoomSubRegion();
 
-- 
cgit v1.2.3


From 1c894c05c10ef37be6507ee4bc4e9173506adfb6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Nov 2012 17:26:12 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system hunting down bad
 values and crashes

---
 indra/newview/app_settings/logcontrol.xml |  1 +
 indra/newview/llappviewer.cpp             |  3 ++-
 indra/newview/llviewerassetstats.cpp      | 25 ++++++++++++++++++++++++-
 indra/newview/llviewerassetstats.h        |  7 ++++++-
 4 files changed, 33 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index 92a241857e..b9ae7ebf0b 100644
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -42,6 +42,7 @@
 						</array>
 					<key>tags</key>
 						<array>
+              <string>FastTimers</string>
 						<!-- sample entry for debugging specific items	
 						     <string>Avatar</string>
 						     <string>Voice</string>		
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index f73fc4b990..839094fc47 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -438,7 +438,7 @@ LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ;
 //----------------------------------------------------------------------------
 // Metrics logging control constants
 //----------------------------------------------------------------------------
-static const F32 METRICS_INTERVAL_DEFAULT = 600.0;
+static const F32 METRICS_INTERVAL_DEFAULT = 30.0;
 static const F32 METRICS_INTERVAL_QA = 30.0;
 static F32 app_metrics_interval = METRICS_INTERVAL_DEFAULT;
 static bool app_metrics_qa_mode = false;
@@ -5308,6 +5308,7 @@ void LLAppViewer::metricsSend(bool enable_reporting)
 			// Make a copy of the main stats to send into another thread.
 			// Receiving thread takes ownership.
 			LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStats));
+			main_stats->stop();
 
 			main_stats->updateStats();
 			
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 73a2e24424..d79d98aaaf 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -239,7 +239,7 @@ LLViewerAssetStats::LLViewerAssetStats()
 :	mRegionHandle(U64(0)),
 	mCurRecording(NULL)
 {
-	reset();
+	start();
 }
 
 
@@ -252,6 +252,29 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 	mRegionRecordings = src.mRegionRecordings;
 	
 	mCurRecording = &mRegionRecordings[mRegionHandle];
+	mCurRecording->stop();
+	LLStopWatchControlsMixin::initTo(src.getPlayState());
+}
+
+void LLViewerAssetStats::handleStart()
+{
+	if (mCurRecording)
+	{
+		mCurRecording->start();
+	}
+}
+
+void LLViewerAssetStats::handleStop()
+{
+	if (mCurRecording)
+	{
+		mCurRecording->stop();
+	}
+}
+
+void LLViewerAssetStats::handleReset()
+{
+	reset();
 }
 
 
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 835df89149..5b25d791a9 100644
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -74,7 +74,7 @@
  * LLViewerAssetStatsFF is provided for conditional test-and-call
  * operations.
  */
-class LLViewerAssetStats
+class LLViewerAssetStats : public LLStopWatchControlsMixin<LLViewerAssetStats>
 {
 public:
 	/**
@@ -177,6 +177,7 @@ public:
 public:
 	LLViewerAssetStats();
 	LLViewerAssetStats(const LLViewerAssetStats &);
+
 	// Default destructor is correct.
 	LLViewerAssetStats & operator=(const LLViewerAssetStats &);			// Not defined
 
@@ -202,6 +203,10 @@ public:
 	LLSD asLLSD(bool compact_output);
 
 protected:
+	void handleStart();
+	void handleStop();
+	void handleReset();
+
 	typedef std::map<region_handle_t, LLTrace::Recording > PerRegionRecordingContainer;
 
 	// Region of the currently-active region.  Always valid but may
-- 
cgit v1.2.3


From 93aca485ba08a82a6bd3a2fc31deca18af0d1478 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Nov 2012 20:17:37 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system fixed precision of
 fast timer counts

---
 indra/newview/llappviewer.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 547eb2fefe..1ecbc00257 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1341,6 +1341,7 @@ bool LLAppViewer::mainLoop()
 					gGLActive = FALSE;
 				}
 
+				LLTrace::get_frame_recording().nextPeriod();
 			}
 
 			pingMainloopTimeout("Main:Sleep");
@@ -4307,9 +4308,6 @@ void LLAppViewer::idle()
 		update_statistics();
 	}
 
-	LLTrace::get_frame_recording().nextPeriod();
-
-
 	////////////////////////////////////////
 	//
 	// Handle the regular UI idle callbacks as well as
-- 
cgit v1.2.3


From ca37317a1473bb79ef8de4f683231700cb9e062c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 30 Nov 2012 15:48:22 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system fixed crash when
 sending viewer asset stats

---
 indra/newview/llappviewer.cpp        |  2 +-
 indra/newview/llviewerassetstats.cpp | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 713ae789a7..fb95c9ec5b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -438,7 +438,7 @@ LLAppViewer::LLUpdaterInfo *LLAppViewer::sUpdaterInfo = NULL ;
 //----------------------------------------------------------------------------
 // Metrics logging control constants
 //----------------------------------------------------------------------------
-static const F32 METRICS_INTERVAL_DEFAULT = 30.0;
+static const F32 METRICS_INTERVAL_DEFAULT = 600.0;
 static const F32 METRICS_INTERVAL_QA = 30.0;
 static F32 app_metrics_interval = METRICS_INTERVAL_DEFAULT;
 static bool app_metrics_qa_mode = false;
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index d79d98aaaf..58936c3220 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -250,9 +250,18 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 {
 	src.mCurRecording->update();
 	mRegionRecordings = src.mRegionRecordings;
-	
+
 	mCurRecording = &mRegionRecordings[mRegionHandle];
 	mCurRecording->stop();
+
+	// assume this is being passed to another thread, so make sure we have unique copies of recording data
+	for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end();
+		it != end_it;
+		++it)
+	{
+		it->second.makeUnique();
+	}
+
 	LLStopWatchControlsMixin::initTo(src.getPlayState());
 }
 
-- 
cgit v1.2.3


From 21409a3aaaef71102195d65fc35cebdb5d941a26 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 30 Nov 2012 22:50:06 -0700
Subject: for SH-3350 and SH-3353: Report frame-to-frame visual deltas as an
 LLStat

---
 .../class1/interface/onetexturefilterF.glsl        |  49 ++++++
 .../class1/interface/onetexturefilterV.glsl        |  38 +++++
 .../class1/interface/twotexturecompareF.glsl       |  16 +-
 indra/newview/llscenemonitor.cpp                   | 188 ++++++++++++++-------
 indra/newview/llscenemonitor.h                     |  17 +-
 indra/newview/llspatialpartition.cpp               |  22 ++-
 indra/newview/llspatialpartition.h                 |   2 +
 indra/newview/llviewershadermgr.cpp                |  17 ++
 indra/newview/llviewershadermgr.h                  |   4 +-
 indra/newview/pipeline.cpp                         |   5 +-
 10 files changed, 271 insertions(+), 87 deletions(-)
 create mode 100644 indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl
 create mode 100644 indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl
new file mode 100644
index 0000000000..f1400c9b44
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterF.glsl
@@ -0,0 +1,49 @@
+/** 
+ * @file onetexturefilterF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2007, 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$
+ */
+
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor
+#endif
+
+uniform sampler2D tex0;
+uniform float tolerance;
+
+VARYING vec2 vary_texcoord0;
+
+void main() 
+{
+	frag_color = texture2D(tex0, vary_texcoord0.xy);
+	
+	if(frag_color[0] + frag_color[1] + frag_color[2] < tolerance)
+	{
+		discard;
+	}
+	else
+	{		
+		frag_color[3] = 0.95f;	
+	}	
+}
diff --git a/indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl
new file mode 100644
index 0000000000..a33ef7e92c
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/onetexturefilterV.glsl
@@ -0,0 +1,38 @@
+/** 
+ * @file onetexturefilterV.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2007, 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$
+ */
+ 
+uniform mat4 modelview_projection_matrix;
+
+ATTRIBUTE vec3 position;
+ATTRIBUTE vec2 texcoord0;
+
+VARYING vec2 vary_texcoord0;
+
+void main()
+{
+	gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+	vary_texcoord0 = texcoord0;
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
index 336ca21b96..050114b37e 100644
--- a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
@@ -37,19 +37,5 @@ VARYING vec2 vary_texcoord1;
 
 void main() 
 {
-	frag_color = texture2D(tex0, vary_texcoord0.xy) - texture2D(tex1, vary_texcoord0.xy);
-	
-	if(frag_color[0] < 0.f)
-	{
-		frag_color[0] = -frag_color[0];
-	}
-	if(frag_color[1] < 0.f)
-	{
-		frag_color[1] = -frag_color[1];
-	}
-	if(frag_color[2] < 0.f)
-	{
-		frag_color[2] = -frag_color[2];
-	}
-	frag_color[3] = 0.95f;
+	frag_color = abs(texture2D(tex0, vary_texcoord0.xy) - texture2D(tex1, vary_texcoord0.xy));
 }
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 0730281d85..adeada04ca 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -36,18 +36,24 @@
 #include "llappviewer.h"
 #include "llwindow.h"
 #include "llpointer.h"
+#include "llspatialpartition.h"
 
 LLSceneMonitorView* gSceneMonitorView = NULL;
 
 LLSceneMonitor::LLSceneMonitor() : 
 	mEnabled(FALSE), 
-	mDiff(NULL), 
+	mDiff(NULL),
+	mDiffResult(0.f),
+	mDiffTolerance(0.1f),
 	mCurTarget(NULL), 
-	mNeedsUpdateDiff(FALSE), 
-	mDebugViewerVisible(FALSE)
+	mNeedsUpdateDiff(FALSE),
+	mHasNewDiff(FALSE),
+	mHasNewQueryResult(FALSE),
+	mDebugViewerVisible(FALSE),
+	mQueryObject(0)
 {
 	mFrames[0] = NULL;
-	mFrames[1] = NULL;
+	mFrames[1] = NULL;	
 }
 
 LLSceneMonitor::~LLSceneMonitor()
@@ -69,6 +75,15 @@ void LLSceneMonitor::reset()
 	mFrames[0] = NULL;
 	mFrames[1] = NULL;
 	mDiff = NULL;
+	mCurTarget = NULL;
+
+	unfreezeScene();
+
+	if(mQueryObject > 0)
+	{
+		release_occlusion_query_object_name(mQueryObject);
+		mQueryObject = 0;
+	}
 }
 
 void LLSceneMonitor::setDebugViewerVisible(BOOL visible) 
@@ -108,28 +123,6 @@ bool LLSceneMonitor::preCapture()
 		return false;
 	}
 
-	if (LLStartUp::getStartupState() < STATE_STARTED)
-	{
-		return false;
-	}
-
-	if(LLAppViewer::instance()->logoutRequestSent())
-	{
-		return false;
-	}
-
-	if(gWindowResized || gHeadlessClient || gTeleportDisplay || gRestoreGL || gDisconnected)
-	{
-		return false;
-	}
-
-	if (   !gViewerWindow->getActive()
-		|| !gViewerWindow->getWindow()->getVisible() 
-		|| gViewerWindow->getWindow()->getMinimized() )
-	{
-		return false;
-	}
-
 	if(timer.getElapsedTimeF32() < 1.0f)
 	{
 		return false;
@@ -174,12 +167,6 @@ bool LLSceneMonitor::preCapture()
 	return true;
 }
 
-void LLSceneMonitor::postCapture()
-{
-	mCurTarget = NULL;
-	mNeedsUpdateDiff = TRUE;
-}
-
 void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp)
 {
 	mAvatarPauseHandles.push_back(avatarp->requestPause());
@@ -207,19 +194,14 @@ void LLSceneMonitor::unfreezeScene()
 	gSavedSettings.setBOOL("FreezeTime", FALSE);
 }
 
-LLRenderTarget* LLSceneMonitor::getDiffTarget() const 
-{
-	return mDiff;
-}
-
 void LLSceneMonitor::capture()
 {
-	static U32 count = 0;
-	if(count == gFrameCount)
+	static U32 last_capture_time = 0;
+	if(last_capture_time == gFrameCount)
 	{
 		return;
 	}
-	count = gFrameCount;
+	last_capture_time = gFrameCount;
 
 	preCapture();
 
@@ -239,7 +221,8 @@ void LLSceneMonitor::capture()
 	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);		
 	glBindFramebuffer(GL_FRAMEBUFFER, old_FBO);
 
-	postCapture();
+	mCurTarget = NULL;
+	mNeedsUpdateDiff = TRUE;
 }
 
 void LLSceneMonitor::compare()
@@ -248,6 +231,7 @@ void LLSceneMonitor::compare()
 	{
 		return;
 	}
+	mNeedsUpdateDiff = FALSE;
 
 	if(!mFrames[0] || !mFrames[1])
 	{
@@ -258,11 +242,6 @@ void LLSceneMonitor::compare()
 		return; //size does not match
 	}
 
-	if (!LLGLSLShader::sNoFixedFunction)
-	{
-		return;
-	}
-
 	S32 width = gViewerWindow->getWindowWidthRaw();
 	S32 height = gViewerWindow->getWindowHeightRaw();
 	if(!mDiff)
@@ -274,9 +253,10 @@ void LLSceneMonitor::compare()
 	{
 		mDiff->resize(width, height, GL_RGBA);
 	}
+
 	mDiff->bindTarget();
 	mDiff->clear();
-
+	
 	gTwoTextureCompareProgram.bind();
 	
 	gGL.getTexUnit(0)->activate();
@@ -288,21 +268,108 @@ void LLSceneMonitor::compare()
 	gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(1)->bind(mFrames[1]);
 	gGL.getTexUnit(1)->activate();	
-			
+	
 	gl_rect_2d_simple_tex(width, height);
 	
-	mDiff->flush();
+	mDiff->flush();	
 
 	gTwoTextureCompareProgram.unbind();
-	
+
 	gGL.getTexUnit(0)->disable();
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(1)->disable();
 	gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
 
-	mNeedsUpdateDiff = FALSE;
+	mHasNewDiff = TRUE;
+	
+	//send out the query request.
+	queryDiff();
+}
+
+void LLSceneMonitor::queryDiff()
+{
+	if(mDebugViewerVisible)
+	{
+		return;
+	}
+
+	calcDiffAggregate();
+}
+
+//calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it.
+void LLSceneMonitor::calcDiffAggregate()
+{
+	if(!mHasNewDiff && !mDebugViewerVisible)
+	{
+		return;
+	}	
+
+	if(!mQueryObject)
+	{
+		mQueryObject = get_new_occlusion_query_object_name();
+	}
+
+	LLGLDepthTest depth(true, false, GL_ALWAYS);
+	if(!mDebugViewerVisible)
+	{
+		glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+	}
+
+	LLGLSLShader* cur_shader = NULL;
+	
+	cur_shader = LLGLSLShader::sCurBoundShaderPtr;
+	gOneTextureFilterProgram.bind();
+	gOneTextureFilterProgram.uniform1f("tolerance", mDiffTolerance);
+
+	if(mHasNewDiff)
+	{
+		glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject);
+	}
+
+	gl_draw_scaled_target(0, 0, mDiff->getWidth() * 0.5f, mDiff->getHeight() * 0.5f, mDiff);
+
+	if(mHasNewDiff)
+	{
+		glEndQueryARB(GL_SAMPLES_PASSED_ARB);
+		mHasNewDiff = FALSE;	
+		mHasNewQueryResult = TRUE;
+	}
+		
+	gOneTextureFilterProgram.unbind();
+	
+	if(cur_shader != NULL)
+	{
+		cur_shader->bind();
+	}
+	
+	if(!mDebugViewerVisible)
+	{
+		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+	}	
 }
 
+void LLSceneMonitor::fetchQueryResult()
+{
+	if(!mHasNewQueryResult)
+	{
+		return;
+	}
+	mHasNewQueryResult = FALSE;
+
+	GLuint available = 0;
+	glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available);
+	if(!available)
+	{
+		return;
+	}
+
+	GLuint count = 0;
+	glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count);
+	
+	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * 0.25f);
+
+	//llinfos << count << " : " << mDiffResult << llendl;
+}
 //-------------------------------------------------------------------------------------------------------------
 //definition of class LLSceneMonitorView
 //-------------------------------------------------------------------------------------------------------------
@@ -330,27 +397,26 @@ void LLSceneMonitorView::setVisible(BOOL visible)
 
 void LLSceneMonitorView::draw()
 {
-	if (!LLGLSLShader::sNoFixedFunction)
-	{
-		return;
-	}
-	LLRenderTarget* target = LLSceneMonitor::getInstance()->getDiffTarget();
+	const LLRenderTarget* target = LLSceneMonitor::getInstance()->getDiffTarget();
 	if(!target)
 	{
 		return;
 	}
 
-	S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f);
-	S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f);
+	S32 height = target->getHeight() * 0.5f;
+	S32 width = target->getWidth() * 0.5f;
+	//S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f);
+	//S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f);
 	
 	LLRect new_rect;
 	new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
 	setRect(new_rect);
 
-	//gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-	//gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
+	//draw background
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
 	
-	gl_draw_scaled_target(0, 0, getRect().getWidth(), getRect().getHeight(), target);
+	LLSceneMonitor::getInstance()->calcDiffAggregate();
 
 	LLView::draw();
 }
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 648429f97b..db5ac3eeef 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -48,8 +48,14 @@ public:
 
 	void capture(); //capture the main frame buffer
 	void compare(); //compare the stored two buffers.	
+	void queryDiff();	
+	void fetchQueryResult();
+	void calcDiffAggregate();
+	void setDiffTolerance(F32 tol) {mDiffTolerance = tol;}
 
-	LLRenderTarget* getDiffTarget() const;
+	const LLRenderTarget* getDiffTarget() const {return mDiff;}
+	F32  getDiffTolerance() const {return mDiffTolerance;}
+	F32  getDiffResult() const { return mDiffResult;}
 	bool isEnabled()const {return mEnabled;}
 	
 private:
@@ -57,17 +63,22 @@ private:
 	void unfreezeScene();
 	void reset();
 	bool preCapture();
-	void postCapture();
-	
+
 private:
 	BOOL mEnabled;
 	BOOL mNeedsUpdateDiff;
+	BOOL mHasNewDiff;
+	BOOL mHasNewQueryResult;
 	BOOL mDebugViewerVisible;
 
 	LLRenderTarget* mFrames[2];
 	LLRenderTarget* mDiff;
 	LLRenderTarget* mCurTarget;
 
+	GLuint  mQueryObject; //used for glQuery
+	F32     mDiffResult;  //aggregate results of mDiff.
+	F32     mDiffTolerance; //pixels are filtered out when R+G+B < mDiffTolerance
+
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
 };
 
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index e9ece331d1..b7694074a5 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -126,6 +126,16 @@ protected:
 
 static LLOcclusionQueryPool sQueryPool;
 
+GLuint get_new_occlusion_query_object_name()
+{
+	return sQueryPool.allocate();
+}
+
+void release_occlusion_query_object_name(GLuint name)
+{
+	sQueryPool.release(name);
+}
+
 //static counter for frame to switch LOD on
 
 void sg_assert(BOOL expr)
@@ -283,7 +293,7 @@ LLSpatialGroup::~LLSpatialGroup()
 		{
 			if (mOcclusionQuery[i])
 			{
-				sQueryPool.release(mOcclusionQuery[i]);
+				release_occlusion_query_object_name(mOcclusionQuery[i]);
 			}
 		}
 	}
@@ -879,7 +889,7 @@ void LLSpatialGroup::setOcclusionState(U32 state, S32 mode)
 
 				if ((state & DISCARD_QUERY) && mOcclusionQuery[i])
 				{
-					sQueryPool.release(mOcclusionQuery[i]);
+					release_occlusion_query_object_name(mOcclusionQuery[i]);
 					mOcclusionQuery[i] = 0;
 				}
 			}
@@ -890,7 +900,7 @@ void LLSpatialGroup::setOcclusionState(U32 state, S32 mode)
 		mOcclusionState[LLViewerCamera::sCurCameraID] |= state;
 		if ((state & DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
 		{
-			sQueryPool.release(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
+			release_occlusion_query_object_name(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
 			mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0;
 		}
 	}
@@ -1237,7 +1247,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 		{
 			if (mOcclusionQuery[i])
 			{
-				sQueryPool.release(mOcclusionQuery[i]);
+				release_occlusion_query_object_name(mOcclusionQuery[i]);
 				mOcclusionQuery[i] = 0;
 			}
 		}
@@ -1318,7 +1328,7 @@ void LLSpatialGroup::checkOcclusion()
 				}
 				else if (mOcclusionQuery[LLViewerCamera::sCurCameraID])
 				{ //delete the query to avoid holding onto hundreds of pending queries
-					sQueryPool.release(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
+					release_occlusion_query_object_name(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
 					mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0;
 				}
 				
@@ -1390,7 +1400,7 @@ void LLSpatialGroup::doOcclusion(LLCamera* camera)
 					if (!mOcclusionQuery[LLViewerCamera::sCurCameraID])
 					{
 						LLFastTimer t(FTM_OCCLUSION_ALLOCATE);
-						mOcclusionQuery[LLViewerCamera::sCurCameraID] = sQueryPool.allocate();
+						mOcclusionQuery[LLViewerCamera::sCurCameraID] = get_new_occlusion_query_object_name();
 					}
 
 					// Depth clamp all water to avoid it being culled as a result of being
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 079c0f58f0..57e986fb80 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -58,6 +58,8 @@ void pushVerts(LLFace* face, U32 mask);
 // get index buffer for binary encoded axis vertex buffer given a box at center being viewed by given camera
 U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center);
 U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center);
+GLuint get_new_occlusion_query_object_name();
+void release_occlusion_query_object_name(GLuint name);
 
 class LLDrawInfo : public LLRefCount 
 {
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 5295573709..1aa36eafee 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -79,6 +79,7 @@ LLGLSLShader	gSplatTextureRectProgram;
 LLGLSLShader	gGlowCombineFXAAProgram;
 LLGLSLShader	gTwoTextureAddProgram;
 LLGLSLShader	gTwoTextureCompareProgram;
+LLGLSLShader	gOneTextureFilterProgram;
 LLGLSLShader	gOneTextureNoColorProgram;
 LLGLSLShader	gDebugProgram;
 LLGLSLShader	gClipProgram;
@@ -674,6 +675,7 @@ void LLViewerShaderMgr::unloadShaders()
 	gGlowCombineFXAAProgram.unload();
 	gTwoTextureAddProgram.unload();
 	gTwoTextureCompareProgram.unload();
+	gOneTextureFilterProgram.unload();
 	gOneTextureNoColorProgram.unload();
 	gSolidColorProgram.unload();
 
@@ -2724,6 +2726,21 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
 		}
 	}
 
+	if (success)
+	{
+		gOneTextureFilterProgram.mName = "One Texture Filter Shader";
+		gOneTextureFilterProgram.mShaderFiles.clear();
+		gOneTextureFilterProgram.mShaderFiles.push_back(make_pair("interface/onetexturefilterV.glsl", GL_VERTEX_SHADER_ARB));
+		gOneTextureFilterProgram.mShaderFiles.push_back(make_pair("interface/onetexturefilterF.glsl", GL_FRAGMENT_SHADER_ARB));
+		gOneTextureFilterProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+		success = gOneTextureFilterProgram.createShader(NULL, NULL);
+		if (success)
+		{
+			gOneTextureFilterProgram.bind();
+			gOneTextureFilterProgram.uniform1i("tex0", 0);
+		}
+	}
+
 	if (success)
 	{
 		gOneTextureNoColorProgram.mName = "One Texture No Color Shader";
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index 8a706daa8f..3e7c615f23 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -235,7 +235,9 @@ extern LLGLSLShader			gAlphaMaskProgram;
 extern LLGLSLShader			gTwoTextureAddProgram;
 //output tex0[tc0] - tex1[tc1]
 extern LLGLSLShader			gTwoTextureCompareProgram;
-						
+//discard some fragments based on user-set color tolerance
+extern LLGLSLShader			gOneTextureFilterProgram;
+
 extern LLGLSLShader			gOneTextureNoColorProgram;
 
 //object shaders
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 850714f676..d8af7a5cfb 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -112,6 +112,7 @@
 #include "llfloaterpathfindingconsole.h"
 #include "llfloaterpathfindingcharacters.h"
 #include "llpathfindingpathtool.h"
+#include "llscenemonitor.h"
 
 #ifdef _DEBUG
 // Debug indices is disabled for now for debug performance - djs 4/24/02
@@ -3161,7 +3162,9 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 		}
 	}
 		
-	postSort(camera);	
+	postSort(camera);
+
+	LLSceneMonitor::getInstance()->fetchQueryResult();
 }
 
 void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
-- 
cgit v1.2.3


From ca2207bd35c33b13b122f875a5a7d218f94ca3fc Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 1 Dec 2012 00:17:04 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system fixed scale of
 reported times moved reset calls to happen at same time so we don't show
 partial results

---
 indra/newview/llappviewer.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index fb95c9ec5b..b9bdb7cd08 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1235,6 +1235,8 @@ bool LLAppViewer::mainLoop()
 	{
 		LLFastTimer _(FTM_FRAME);
 		LLTrace::BlockTimer::nextFrame(); 
+		LLTrace::get_frame_recording().nextPeriod();
+
 		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
 
 		//clear call stack records
@@ -1352,8 +1354,6 @@ bool LLAppViewer::mainLoop()
 					LLFloaterSnapshot::update(); // take snapshots
 					gGLActive = FALSE;
 				}
-
-				LLTrace::get_frame_recording().nextPeriod();
 			}
 
 			pingMainloopTimeout("Main:Sleep");
-- 
cgit v1.2.3


From 4f9a5d0554c16a81625574a7a4ad6d5070e649e3 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 1 Dec 2012 12:49:01 -0800
Subject: fix for gcc compile errors

---
 indra/newview/app_settings/logcontrol.xml | 1 -
 1 file changed, 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index b9ae7ebf0b..92a241857e 100644
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -42,7 +42,6 @@
 						</array>
 					<key>tags</key>
 						<array>
-              <string>FastTimers</string>
 						<!-- sample entry for debugging specific items	
 						     <string>Avatar</string>
 						     <string>Voice</string>		
-- 
cgit v1.2.3


From 0270ce079c2090cd25244516648ac1691db00a0d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Sun, 2 Dec 2012 22:12:43 -0700
Subject: more for SH-3350, add debug texts

---
 indra/newview/llscenemonitor.cpp | 43 ++++++++++++++++++++++++++++++++++------
 indra/newview/llscenemonitor.h   |  5 +++++
 2 files changed, 42 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index adeada04ca..43f9e9208b 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -40,6 +40,18 @@
 
 LLSceneMonitorView* gSceneMonitorView = NULL;
 
+//
+//The procedures of monitoring when the scene finishes loading visually, 
+//i.e., no pixel differences among frames, are:
+//1, freeze all dynamic objects and avatars;
+//2, (?) disable all sky and water;
+//3, capture frames periodically, by calling "capture()";
+//4, compute pixel differences between two latest captured frames, by calling "compare()", results are stored at mDiff;
+//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "queryDiff() -> calcDiffAggregate()";
+//6, use gl occlusion query to fetch the result from GPU, by calling "fetchQueryResult()";
+//END.
+//
+
 LLSceneMonitor::LLSceneMonitor() : 
 	mEnabled(FALSE), 
 	mDiff(NULL),
@@ -50,7 +62,9 @@ LLSceneMonitor::LLSceneMonitor() :
 	mHasNewDiff(FALSE),
 	mHasNewQueryResult(FALSE),
 	mDebugViewerVisible(FALSE),
-	mQueryObject(0)
+	mQueryObject(0),
+	mSamplingTime(1.0f),
+	mDiffPixelRatio(0.5f)
 {
 	mFrames[0] = NULL;
 	mFrames[1] = NULL;	
@@ -123,7 +137,7 @@ bool LLSceneMonitor::preCapture()
 		return false;
 	}
 
-	if(timer.getElapsedTimeF32() < 1.0f)
+	if(timer.getElapsedTimeF32() < mSamplingTime)
 	{
 		return false;
 	}
@@ -326,7 +340,7 @@ void LLSceneMonitor::calcDiffAggregate()
 		glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject);
 	}
 
-	gl_draw_scaled_target(0, 0, mDiff->getWidth() * 0.5f, mDiff->getHeight() * 0.5f, mDiff);
+	gl_draw_scaled_target(0, 0, mDiff->getWidth() * mDiffPixelRatio, mDiff->getHeight() * mDiffPixelRatio, mDiff);
 
 	if(mHasNewDiff)
 	{
@@ -366,7 +380,7 @@ void LLSceneMonitor::fetchQueryResult()
 	GLuint count = 0;
 	glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count);
 	
-	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * 0.25f);
+	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
 	//llinfos << count << " : " << mDiffResult << llendl;
 }
@@ -403,8 +417,9 @@ void LLSceneMonitorView::draw()
 		return;
 	}
 
-	S32 height = target->getHeight() * 0.5f;
-	S32 width = target->getWidth() * 0.5f;
+	F32 ratio = LLSceneMonitor::getInstance()->getDiffPixelRatio();
+	S32 height = target->getHeight() * ratio;
+	S32 width = target->getWidth() * ratio;
 	//S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f);
 	//S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f);
 	
@@ -418,6 +433,22 @@ void LLSceneMonitorView::draw()
 	
 	LLSceneMonitor::getInstance()->calcDiffAggregate();
 
+	//show some texts
+	LLColor4 color = LLColor4::white;
+	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
+
+	S32 lines = 0;
+	std::string num_str = llformat("Frame difference: %.6f", LLSceneMonitor::getInstance()->getDiffResult());
+	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
+	lines++;
+
+	num_str = llformat("Pixel tolerance: (R+G+B) < %.4f", LLSceneMonitor::getInstance()->getDiffTolerance());
+	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
+	lines++;
+
+	num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime());
+	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
+
 	LLView::draw();
 }
 
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index db5ac3eeef..ce25467a21 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -56,6 +56,8 @@ public:
 	const LLRenderTarget* getDiffTarget() const {return mDiff;}
 	F32  getDiffTolerance() const {return mDiffTolerance;}
 	F32  getDiffResult() const { return mDiffResult;}
+	F32  getSamplingTime() const { return mSamplingTime;}
+	F32  getDiffPixelRatio() const { return mDiffPixelRatio;}
 	bool isEnabled()const {return mEnabled;}
 	
 private:
@@ -79,6 +81,9 @@ private:
 	F32     mDiffResult;  //aggregate results of mDiff.
 	F32     mDiffTolerance; //pixels are filtered out when R+G+B < mDiffTolerance
 
+	F32     mSamplingTime; //time interval to capture frames, in seconds
+	F32     mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension
+
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
 };
 
-- 
cgit v1.2.3


From 13e4edf1cd664864afa585bc83bbe99d4f743326 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sun, 2 Dec 2012 23:00:36 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system started moving fast
 timer historical stats over to LLTrace periodic recording

---
 indra/newview/llfasttimerview.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 7a5c9dba46..6aca8f4426 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -294,15 +294,17 @@ static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -
 {
 	F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond();
 
+	LLTrace::PeriodicRecording& frame_stats = LLTrace::get_frame_recording();
+
 	std::string tooltip;
 	if (history_index < 0)
 	{
 		// by default, show average number of call
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getCountAverage() * ms_multiplier), (S32)timer.getCallAverage());
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPeriodMean(timer) * ms_multiplier), (S32)timer.getCallAverage());
 	}
 	else
 	{
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(timer.getHistoricalCount(history_index) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index));
 	}
 	return tooltip;
 }
-- 
cgit v1.2.3


From 407e5013f3845208e0a60e26e8f0a7fad997df5d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 3 Dec 2012 19:54:53 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system converted fast
 timer view over to new lltrace mechanisms

---
 indra/newview/llappviewer.cpp     |  33 +-
 indra/newview/llfasttimerview.cpp | 778 ++++++++++++++++++--------------------
 indra/newview/llfasttimerview.h   |  32 +-
 indra/newview/llstartup.cpp       |   2 +-
 indra/newview/llviewermenu.cpp    |   2 +-
 5 files changed, 404 insertions(+), 443 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index b9bdb7cd08..c986954867 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -592,7 +592,7 @@ public:
 		
 		while (!LLAppViewer::instance()->isQuitting())
 		{
-			LLFastTimer::writeLog(os);
+			LLTrace::TimeBlock::writeLog(os);
 			os.flush();
 			ms_sleep(32);
 		}
@@ -680,7 +680,6 @@ bool LLAppViewer::init()
 	// into the log files during normal startup until AFTER
 	// we run the "program crashed last time" error handler below.
 	//
-	LLTrace::BlockTimer::reset();
 
 	// initialize SSE options
 	LLVector4a::initClass();
@@ -1234,7 +1233,7 @@ bool LLAppViewer::mainLoop()
 	while (!LLApp::isExiting())
 	{
 		LLFastTimer _(FTM_FRAME);
-		LLTrace::BlockTimer::nextFrame(); 
+		LLTrace::TimeBlock::nextFrame(); 
 		LLTrace::get_frame_recording().nextPeriod();
 
 		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
@@ -1565,9 +1564,9 @@ bool LLAppViewer::cleanup()
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
 		llinfos << "Analyzing performance" << llendl;
-		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
-		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
-		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::TimeBlock::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::TimeBlock::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -1926,9 +1925,9 @@ bool LLAppViewer::cleanup()
 	{
 		llinfos << "Analyzing performance" << llendl;
 		
-		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
-		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
-		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::TimeBlock::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::TimeBlock::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -2051,10 +2050,10 @@ bool LLAppViewer::initThreads()
 													enable_threads && true,
 													app_metrics_qa_mode);	
 
-	if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog)
+	if (LLTrace::TimeBlock::sLog || LLTrace::TimeBlock::sMetricLog)
 	{
-		LLTrace::BlockTimer::setLogLock(new LLMutex(NULL));
-		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName);
+		LLTrace::TimeBlock::setLogLock(new LLMutex(NULL));
+		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::TimeBlock::sLogName);
 		mFastTimerLogThread->start();
 	}
 
@@ -2463,13 +2462,13 @@ bool LLAppViewer::initConfiguration()
 
 	if (clp.hasOption("logperformance"))
 	{
-		LLTrace::BlockTimer::sLog = true;
-		LLTrace::BlockTimer::sLogName = std::string("performance");		
+		LLTrace::TimeBlock::sLog = true;
+		LLTrace::TimeBlock::sLogName = std::string("performance");		
 	}
 	
 	if (clp.hasOption("logmetrics"))
  	{
- 		LLTrace::BlockTimer::sMetricLog = true ;
+ 		LLTrace::TimeBlock::sMetricLog = true ;
 		// '--logmetrics' can be specified with a named test metric argument so the data gathering is done only on that test
 		// In the absence of argument, every metric is gathered (makes for a rather slow run and hard to decipher report...)
 		std::string test_name = clp.getOption("logmetrics")[0];
@@ -2477,11 +2476,11 @@ bool LLAppViewer::initConfiguration()
 		if (test_name == "")
 		{
 			llwarns << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << llendl;
-			LLTrace::BlockTimer::sLogName = DEFAULT_METRIC_NAME;
+			LLTrace::TimeBlock::sLogName = DEFAULT_METRIC_NAME;
 		}
 		else
 		{
-			LLTrace::BlockTimer::sLogName = test_name;
+			LLTrace::TimeBlock::sLogName = test_name;
 		}
  	}
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 6aca8f4426..acf3799f27 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -57,21 +57,19 @@
 static const S32 MAX_VISIBLE_HISTORY = 10;
 static const S32 LINE_GRAPH_HEIGHT = 240;
 
-//static const int FTV_DISPLAY_NUM  = (sizeof(ft_display_table)/sizeof(ft_display_table[0]));
-static S32 FTV_NUM_TIMERS;
 const S32 FTV_MAX_DEPTH = 8;
 
-std::vector<LLTrace::BlockTimer*> ft_display_idx; // line of table entry for display purposes (for collapse)
+std::vector<LLTrace::TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
-typedef LLTreeDFSIter<LLTrace::BlockTimer, LLTrace::BlockTimer::child_const_iter> timer_tree_iterator_t;
+typedef LLTreeDFSIter<LLTrace::TimeBlock, LLTrace::TimeBlock::child_const_iter> timer_tree_iterator_t;
 
 BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
 
-static timer_tree_iterator_t begin_timer_tree(LLTrace::BlockTimer& id) 
+static timer_tree_iterator_t begin_timer_tree(LLTrace::TimeBlock& id) 
 { 
 	return timer_tree_iterator_t(&id, 
-							boost::bind(boost::mem_fn(&LLTrace::BlockTimer::beginChildren), _1), 
-							boost::bind(boost::mem_fn(&LLTrace::BlockTimer::endChildren), _1));
+							boost::bind(boost::mem_fn(&LLTrace::TimeBlock::beginChildren), _1), 
+							boost::bind(boost::mem_fn(&LLTrace::TimeBlock::endChildren), _1));
 }
 
 static timer_tree_iterator_t end_timer_tree() 
@@ -81,29 +79,25 @@ static timer_tree_iterator_t end_timer_tree()
 
 LLFastTimerView::LLFastTimerView(const LLSD& key)
 :	LLFloater(key),
-	mHoverTimer(NULL)
-{
-	mDisplayMode = 0;
-	mAvgCountTotal = 0;
-	mMaxCountTotal = 0;
-	mDisplayCenter = ALIGN_CENTER;
-	mDisplayCalls = 0;
-	mDisplayHz = 0;
-	mScrollIndex = 0;
-	mHoverID = NULL;
-	mHoverBarIndex = -1;
-	FTV_NUM_TIMERS = LLInstanceTracker<LLTrace::BlockTimer>::instanceCount();
-	mPrintStats = -1;	
-}
+	mHoverTimer(NULL),
+	mDisplayMode(0),
+	mDisplayCenter(ALIGN_CENTER),
+	mDisplayCalls(false),
+	mDisplayHz(false),
+	mScrollIndex(0),
+	mHoverID(NULL),
+	mHoverBarIndex(-1),
+	mPrintStats(-1)
+{}
 
 void LLFastTimerView::onPause()
 {
-	LLTrace::BlockTimer::sPauseHistory = !LLTrace::BlockTimer::sPauseHistory;
+	LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory;
 	// reset scroll to bottom when unpausing
-	if (!LLTrace::BlockTimer::sPauseHistory)
+	if (!LLTrace::TimeBlock::sPauseHistory)
 	{
 		mScrollIndex = 0;
-		LLTrace::BlockTimer::sResetHistory = true;
+		LLTrace::TimeBlock::sResetHistory = true;
 		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
 	}
 	else
@@ -139,13 +133,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	{
 		S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
 		bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
-		mPrintStats = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - bar_idx;
+		mPrintStats = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - bar_idx;
 		return TRUE;
 	}
 	return LLFloater::handleRightMouseDown(x, y, mask);
 }
 
-LLTrace::BlockTimer* LLFastTimerView::getLegendID(S32 y)
+LLTrace::TimeBlock* LLFastTimerView::getLegendID(S32 y)
 {
 	S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5;
 
@@ -172,7 +166,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (x < mBarRect.mLeft) 
 	{
-		LLTrace::BlockTimer* idp = getLegendID(y);
+		LLTrace::TimeBlock* idp = getLegendID(y);
 		if (idp)
 		{
 			idp->setCollapsed(!idp->getCollapsed());
@@ -223,19 +217,21 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 {
+	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
-		mScrollIndex = llround( lerp * (F32)(LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
-		mScrollIndex = llclamp(	mScrollIndex, 0, LLTrace::BlockTimer::getLastFrameIndex());
+		mScrollIndex = llround( lerp * (F32)(LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+		mScrollIndex = llclamp(	mScrollIndex, 0, frame_recording.getNumPeriods());
 		return TRUE;
 	}
 	mHoverTimer = NULL;
 	mHoverID = NULL;
 
-	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
-		mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, 
+		mHoverBarIndex = llmin(LLTrace::get_frame_recording().getNumPeriods() - 1, 
 								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
 		if (mHoverBarIndex == 0)
 		{
@@ -279,7 +275,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	}
 	else if (x < mBarRect.mLeft) 
 	{
-		LLTrace::BlockTimer* timer_id = getLegendID(y);
+		LLTrace::TimeBlock* timer_id = getLegendID(y);
 		if (timer_id)
 		{
 			mHoverID = timer_id;
@@ -290,28 +286,28 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 }
 
 
-static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1)
+static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index = -1)
 {
-	F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond();
+	F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond();
 
-	LLTrace::PeriodicRecording& frame_stats = LLTrace::get_frame_recording();
+	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
 
 	std::string tooltip;
 	if (history_index < 0)
 	{
 		// by default, show average number of call
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPeriodMean(timer) * ms_multiplier), (S32)timer.getCallAverage());
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier), (S32)frame_recording.getPeriodMean(timer.callCount()));
 	}
 	else
 	{
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_stats.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)timer.getHistoricalCalls(history_index));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount()));
 	}
 	return tooltip;
 }
 
 BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 {
-	if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		// tooltips for timer bars
 		if (mHoverTimer)
@@ -319,7 +315,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLRect screen_rect;
 			localRectToScreen(mToolTipRect, &screen_rect);
 
-			std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
+			std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
 
 			LLToolTipMgr::instance().show(LLToolTip::Params()
 				.message(tooltip)
@@ -334,7 +330,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 		// tooltips for timer legend
 		if (x < mBarRect.mLeft) 
 		{
-			LLTrace::BlockTimer* idp = getLegendID(y);
+			LLTrace::TimeBlock* idp = getLegendID(y);
 			if (idp)
 			{
 				LLToolTipMgr::instance().show(get_tooltip(*idp));
@@ -349,26 +345,27 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	LLTrace::BlockTimer::sPauseHistory = TRUE;
+	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+
+	LLTrace::TimeBlock::sPauseHistory = TRUE;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(LLTrace::BlockTimer::getLastFrameIndex(), (S32)LLTrace::BlockTimer::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+							llmin(frame_recording.getNumPeriods(), (S32)LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
-static LLTrace::BlockTimer FTM_RENDER_TIMER("Timers", true);
+static LLTrace::TimeBlock FTM_RENDER_TIMER("Timers", true);
 
-static std::map<LLTrace::BlockTimer*, LLColor4> sTimerColors;
+static std::map<LLTrace::TimeBlock*, LLColor4> sTimerColors;
 
 void LLFastTimerView::draw()
 {
 	LLFastTimer t(FTM_RENDER_TIMER);
-	
+
+	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+
 	std::string tdesc;
 
-	F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond();
-	F64 iclock_freq = 1000.0 / clock_freq;
-	
 	S32 margin = 10;
 	S32 height = getRect().getHeight();
 	S32 width = getRect().getWidth();
@@ -422,7 +419,7 @@ void LLFastTimerView::draw()
 		y -= (texth + 2);
 	}
 
-	S32 histmax = llmin(LLTrace::BlockTimer::getLastFrameIndex()+1, MAX_VISIBLE_HISTORY);
+	S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY);
 		
 	// Draw the legend
 	xleft = margin;
@@ -438,7 +435,7 @@ void LLFastTimerView::draw()
 		it != timer_tree_iterator_t();
 		++it)
 	{
-		LLTrace::BlockTimer* idp = (*it);
+		LLTrace::TimeBlock* idp = (*it);
 
 		const F32 HUE_INCREMENT = 0.23f;
 		hue = fmodf(hue + HUE_INCREMENT, 1.f);
@@ -458,12 +455,12 @@ void LLFastTimerView::draw()
 		LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
 		S32 cur_line = 0;
 		ft_display_idx.clear();
-		std::map<LLTrace::BlockTimer*, S32> display_line;
+		std::map<LLTrace::TimeBlock*, S32> display_line;
 		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			LLTrace::BlockTimer* idp = (*it);
+			LLTrace::TimeBlock* idp = (*it);
 			display_line[idp] = cur_line;
 			ft_display_idx.push_back(idp);
 			cur_line++;
@@ -479,20 +476,18 @@ void LLFastTimerView::draw()
 			}
 			gl_rect_2d(left - scale_offset, top + scale_offset, right + scale_offset, bottom - scale_offset, sTimerColors[idp]);
 
-			F32 ms = 0;
+			LLUnit<LLUnits::Milliseconds, F32> ms = 0;
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
-				S32 hidx = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
-				U64 ticks = idp->getHistoricalCount(hidx);
-				ms = (F32)((F64)ticks * iclock_freq);
-				calls = (S32)idp->getHistoricalCalls(hidx);
+				S32 hidx = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
+				ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp);
+				calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount());
 			}
 			else
 			{
-				U64 ticks = idp->getCountAverage();
-				ms = (F32)((F64)ticks * iclock_freq);
-				calls = (S32)idp->getCallAverage();
+				ms = frame_recording.getPeriodMean(*idp);
+				calls = frame_recording.getPeriodMean(idp->callCount());
 			}
 
 			if (mDisplayCalls)
@@ -521,7 +516,7 @@ void LLFastTimerView::draw()
 
 			x += dx;
 			BOOL is_child_of_hover_item = (idp == mHoverID);
-			LLTrace::BlockTimer* next_parent = idp->getParent();
+			LLTrace::TimeBlock* next_parent = idp->getParent();
 			while(!is_child_of_hover_item && next_parent)
 			{
 				is_child_of_hover_item = (mHoverID == next_parent);
@@ -563,419 +558,386 @@ void LLFastTimerView::draw()
 	barw = width - xleft - margin;
 
 	// Draw the history bars
-	if (LLTrace::BlockTimer::getLastFrameIndex() >= 0)
-	{	
-		LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin));
-
-		U64 totalticks;
-		if (!LLTrace::BlockTimer::sPauseHistory)
-		{
-			U64 ticks = getFrameTimer().getHistoricalCount(mScrollIndex);
-
-			if (LLTrace::BlockTimer::getCurFrameIndex() >= 10)
-			{
-				U64 framec = LLTrace::BlockTimer::getCurFrameIndex();
-				U64 avg = (U64)mAvgCountTotal;
-				mAvgCountTotal = (avg*framec + ticks) / (framec + 1);
-				if (ticks > mMaxCountTotal)
-				{
-					mMaxCountTotal = ticks;
-				}
-			}
-
-			if (ticks < mAvgCountTotal/100 || ticks > mAvgCountTotal*100)
-			{
-				LLTrace::BlockTimer::sResetHistory = true;
-			}
+	LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin));
 
-			if (LLTrace::BlockTimer::getCurFrameIndex() < 10 || LLTrace::BlockTimer::sResetHistory)
-			{
-				mAvgCountTotal = ticks;
-				mMaxCountTotal = ticks;
-				LLTrace::BlockTimer::sResetHistory = false;
-			}
-		}
+	LLUnit<LLUnits::Seconds, F64> total_time;
 
-		if (mDisplayMode == 0)
-		{
-			totalticks = mAvgCountTotal*2;
-		}
-		else if (mDisplayMode == 1)
-		{
-			totalticks = mMaxCountTotal;
-		}
-		else if (mDisplayMode == 2)
-		{
-			// Calculate the max total ticks for the current history
-			totalticks = 0;
-			for (S32 j=0; j<histmax; j++)
-			{
-				U64 ticks = getFrameTimer().getHistoricalCount(j);
+	mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer()));
 
-				if (ticks > totalticks)
-					totalticks = ticks;
-			}
-		}
-		else
-		{
-			totalticks = (U64)(clock_freq * .1); // 100 ms
-		}
+	if (mDisplayMode == 0)
+	{
+		total_time = frame_recording.getPeriodMean(getFrameTimer())*2;
+	}
+	else if (mDisplayMode == 1)
+	{
+		total_time = mAllTimeMax;
+	}
+	else if (mDisplayMode == 2)
+	{
+		// Calculate the max total ticks for the current history
+		total_time = frame_recording.getPeriodMax(getFrameTimer());
+	}
+	else
+	{
+		total_time = LLUnit<LLUnits::Milliseconds, F32>(100);
+	}
 		
-		// Draw MS ticks
-		{
-			U32 ms = (U32)((F64)totalticks * iclock_freq) ;
+	// Draw MS ticks
+	{
+		LLUnit<LLUnits::Milliseconds, U32> ms = total_time;
 
-			tdesc = llformat("%.1f ms |", (F32)ms*.25f);
-			x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										 LLFontGL::LEFT, LLFontGL::TOP);
+		tdesc = llformat("%.1f ms |", (F32)ms*.25f);
+		x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
+		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+										LLFontGL::LEFT, LLFontGL::TOP);
 			
-			tdesc = llformat("%.1f ms |", (F32)ms*.50f);
-			x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										 LLFontGL::LEFT, LLFontGL::TOP);
+		tdesc = llformat("%.1f ms |", (F32)ms*.50f);
+		x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc);
+		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+										LLFontGL::LEFT, LLFontGL::TOP);
 			
-			tdesc = llformat("%.1f ms |", (F32)ms*.75f);
-			x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										 LLFontGL::LEFT, LLFontGL::TOP);
+		tdesc = llformat("%.1f ms |", (F32)ms*.75f);
+		x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
+		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+										LLFontGL::LEFT, LLFontGL::TOP);
 			
-			tdesc = llformat( "%d ms |", ms);
-			x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										 LLFontGL::LEFT, LLFontGL::TOP);
-		}
+		tdesc = llformat( "%d ms |", (U32)ms);
+		x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc);
+		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+										LLFontGL::LEFT, LLFontGL::TOP);
+	}
 
-		// Draw borders
-		{
-			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-			gGL.color4f(0.5f,0.5f,0.5f,0.5f);
+	// Draw borders
+	{
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+		gGL.color4f(0.5f,0.5f,0.5f,0.5f);
 
-			S32 by = y + 2;
+		S32 by = y + 2;
 			
-			y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
+		y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
 
-			//heading
-			gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE);
+		//heading
+		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE);
 
-			//tree view
-			gl_rect_2d(5, by, xleft-10, 5, FALSE);
+		//tree view
+		gl_rect_2d(5, by, xleft-10, 5, FALSE);
 
-			by = y + 5;
-			//average bar
-			gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE);
+		by = y + 5;
+		//average bar
+		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE);
 			
-			by -= barh*2+dy;
+		by -= barh*2+dy;
 			
-			//current frame bar
-			gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE);
+		//current frame bar
+		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE);
 			
-			by -= barh+dy+1;
+		by -= barh+dy+1;
 			
-			//history bars
-			gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE);			
+		//history bars
+		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE);			
 			
-			by = LINE_GRAPH_HEIGHT-barh-dy-7;
+		by = LINE_GRAPH_HEIGHT-barh-dy-7;
 			
-			//line graph
-			mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5);
+		//line graph
+		mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5);
 			
-			gl_rect_2d(mGraphRect, FALSE);
-		}
+		gl_rect_2d(mGraphRect, FALSE);
+	}
 		
-		mBarStart.clear();
-		mBarEnd.clear();
+	mBarStart.clear();
+	mBarEnd.clear();
 
-		// Draw bars for each history entry
-		// Special: -1 = show running average
-		gGL.getTexUnit(0)->bind(box_imagep->getImage());
-		for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++)
+	// Draw bars for each history entry
+	// Special: -1 = show running average
+	gGL.getTexUnit(0)->bind(box_imagep->getImage());
+	for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++)
+	{
+		mBarStart.push_back(std::vector<S32>());
+		mBarEnd.push_back(std::vector<S32>());
+		int sublevel_dx[FTV_MAX_DEPTH];
+		int sublevel_left[FTV_MAX_DEPTH];
+		int sublevel_right[FTV_MAX_DEPTH];
+		S32 tidx;
+		if (j >= 0)
 		{
-			mBarStart.push_back(std::vector<S32>());
-			mBarEnd.push_back(std::vector<S32>());
-			int sublevel_dx[FTV_MAX_DEPTH];
-			int sublevel_left[FTV_MAX_DEPTH];
-			int sublevel_right[FTV_MAX_DEPTH];
-			S32 tidx;
-			if (j >= 0)
-			{
-				tidx = LLTrace::BlockTimer::HISTORY_NUM - j - 1 - mScrollIndex;
-			}
-			else
-			{
-				tidx = -1;
-			}
+			tidx = LLTrace::TimeBlock::HISTORY_NUM - j - 1 - mScrollIndex;
+		}
+		else
+		{
+			tidx = -1;
+		}
 			
-			x = xleft;
+		x = xleft;
 			
-			// draw the bars for each stat
-			std::vector<S32> xpos;
-			std::vector<S32> deltax;
-			xpos.push_back(xleft);
+		// draw the bars for each stat
+		std::vector<S32> xpos;
+		std::vector<S32> deltax;
+		xpos.push_back(xleft);
 			
-			LLTrace::BlockTimer* prev_id = NULL;
+		LLTrace::TimeBlock* prev_id = NULL;
 
-			S32 i = 0;
-			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-				it != end_timer_tree();
-				++it, ++i)
-			{
-				LLTrace::BlockTimer* idp = (*it);
-				F32 frac = tidx == -1
-					? (F32)idp->getCountAverage() / (F32)totalticks 
-					: (F32)idp->getHistoricalCount(tidx) / (F32)totalticks;
+		S32 i = 0;
+		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+			it != end_timer_tree();
+			++it, ++i)
+		{
+			LLTrace::TimeBlock* idp = (*it);
+			F32 frac = tidx == -1
+				? (frame_recording.getPeriodMean(*idp) / total_time) 
+				: (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value());
 		
-				dx = llround(frac * (F32)barw);
-				S32 prev_delta_x = deltax.empty() ? 0 : deltax.back();
-				deltax.push_back(dx);
+			dx = llround(frac * (F32)barw);
+			S32 prev_delta_x = deltax.empty() ? 0 : deltax.back();
+			deltax.push_back(dx);
+				
+			int level = idp->getDepth() - 1;
 				
-				int level = idp->getDepth() - 1;
+			while ((S32)xpos.size() > level + 1)
+			{
+				xpos.pop_back();
+			}
+			left = xpos.back();
 				
-				while ((S32)xpos.size() > level + 1)
+			if (level == 0)
+			{
+				sublevel_left[level] = xleft;
+				sublevel_dx[level] = dx;
+				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
+			}
+			else if (prev_id && prev_id->getDepth() < idp->getDepth())
+			{
+				U64 sublevelticks = 0;
+
+				for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren();
+					it != prev_id->endChildren();
+					++it)
 				{
-					xpos.pop_back();
+					sublevelticks += (tidx == -1)
+						? frame_recording.getPeriodMean(**it)
+						: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it);
 				}
-				left = xpos.back();
-				
-				if (level == 0)
+
+				F32 subfrac = (F32)sublevelticks / (F32)total_time;
+				sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f);
+
+				if (mDisplayCenter == ALIGN_CENTER)
 				{
-					sublevel_left[level] = xleft;
-					sublevel_dx[level] = dx;
-					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
+					left += (prev_delta_x - sublevel_dx[level])/2;
 				}
-				else if (prev_id && prev_id->getDepth() < idp->getDepth())
+				else if (mDisplayCenter == ALIGN_RIGHT)
 				{
-					U64 sublevelticks = 0;
-
-					for (LLTrace::BlockTimer::child_const_iter it = prev_id->beginChildren();
-						it != prev_id->endChildren();
-						++it)
-					{
-						sublevelticks += (tidx == -1)
-							? (*it)->getCountAverage() 
-							: (*it)->getHistoricalCount(tidx);
-					}
-
-					F32 subfrac = (F32)sublevelticks / (F32)totalticks;
-					sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f);
-
-					if (mDisplayCenter == ALIGN_CENTER)
-					{
-						left += (prev_delta_x - sublevel_dx[level])/2;
-					}
-					else if (mDisplayCenter == ALIGN_RIGHT)
-					{
-						left += (prev_delta_x - sublevel_dx[level]);
-					}
-
-					sublevel_left[level] = left;
-					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
-				}				
-
-				right = left + dx;
-				xpos.back() = right;
-				xpos.push_back(left);
+					left += (prev_delta_x - sublevel_dx[level]);
+				}
+
+				sublevel_left[level] = left;
+				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
+			}				
+
+			right = left + dx;
+			xpos.back() = right;
+			xpos.push_back(left);
 				
-				mBarStart.back().push_back(left);
-				mBarEnd.back().push_back(right);
+			mBarStart.back().push_back(left);
+			mBarEnd.back().push_back(right);
 
-				top = y;
-				bottom = y - barh;
+			top = y;
+			bottom = y - barh;
 
-				if (right > left)
-				{
-					//U32 rounded_edges = 0;
-					LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color;
-					S32 scale_offset = 0;
-
-					BOOL is_child_of_hover_item = (idp == mHoverID);
-					LLTrace::BlockTimer* next_parent = idp->getParent();
-					while(!is_child_of_hover_item && next_parent)
-					{
-						is_child_of_hover_item = (mHoverID == next_parent);
-						if (next_parent->getParent() == next_parent) break;
-						next_parent = next_parent->getParent();
-					}
-
-					if (idp == mHoverID)
-					{
-						scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
-						//color = lerp(color, LLColor4::black, -0.4f);
-					}
-					else if (mHoverID != NULL && !is_child_of_hover_item)
-					{
-						color = lerp(color, LLColor4::grey, 0.8f);
-					}
-
-					gGL.color4fv(color.mV);
-					F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-					F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-					gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment);
+			if (right > left)
+			{
+				//U32 rounded_edges = 0;
+				LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color;
+				S32 scale_offset = 0;
 
+				BOOL is_child_of_hover_item = (idp == mHoverID);
+				LLTrace::TimeBlock* next_parent = idp->getParent();
+				while(!is_child_of_hover_item && next_parent)
+				{
+					is_child_of_hover_item = (mHoverID == next_parent);
+					if (next_parent->getParent() == next_parent) break;
+					next_parent = next_parent->getParent();
 				}
 
-				if ((*it)->getCollapsed())
+				if (idp == mHoverID)
 				{
-					it.skipDescendants();
+					scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
+					//color = lerp(color, LLColor4::black, -0.4f);
 				}
-		
-				prev_id = idp;
+				else if (mHoverID != NULL && !is_child_of_hover_item)
+				{
+					color = lerp(color, LLColor4::grey, 0.8f);
+				}
+
+				gGL.color4fv(color.mV);
+				F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
+				F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
+				gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment);
+
 			}
-			y -= (barh + dy);
-			if (j < 0)
-				y -= barh;
+
+			if ((*it)->getCollapsed())
+			{
+				it.skipDescendants();
+			}
+		
+			prev_id = idp;
 		}
+		y -= (barh + dy);
+		if (j < 0)
+			y -= barh;
+	}
 		
-		//draw line graph history
-		{
-			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-			LLLocalClipRect clip(mGraphRect);
+	//draw line graph history
+	{
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+		LLLocalClipRect clip(mGraphRect);
 			
-			//normalize based on last frame's maximum
-			static U64 last_max = 0;
-			static F32 alpha_interp = 0.f;
-			U64 max_ticks = llmax(last_max, (U64) 1);			
-			F32 ms = (F32)((F64)max_ticks * iclock_freq);
+		//normalize based on last frame's maximum
+		static LLUnit<LLUnits::Seconds, F32> max_time = 0.000001;
+		static U32 max_calls = 0;
+		static F32 alpha_interp = 0.f;
 			
-			//display y-axis range
-			std::string tdesc;
-			 if (mDisplayCalls)
-				tdesc = llformat("%d calls", (int)max_ticks);
-			else if (mDisplayHz)
-				tdesc = llformat("%d Hz", (int)max_ticks);
-			else
-				tdesc = llformat("%4.2f ms", ms);
+		//display y-axis range
+		std::string tdesc;
+		if (mDisplayCalls)
+			tdesc = llformat("%d calls", (int)max_calls);
+		else if (mDisplayHz)
+			tdesc = llformat("%d Hz", (int)(1.f / max_time.value()));
+		else
+			tdesc = llformat("%4.2f ms", LLUnit<LLUnits::Milliseconds, F32>(max_time).value());
 							
-			x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5;
-			y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
+		x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5;
+		y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
  
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										 LLFontGL::LEFT, LLFontGL::TOP);
+		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+										LLFontGL::LEFT, LLFontGL::TOP);
 
-			//highlight visible range
-			{
-				S32 first_frame = LLTrace::BlockTimer::HISTORY_NUM - mScrollIndex;
-				S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
+		//highlight visible range
+		{
+			S32 first_frame = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex;
+			S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 				
-				F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1);
+			F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::TimeBlock::HISTORY_NUM-1);
 				
-				F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
-				F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
+			F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
+			F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
 				
-				gGL.color4f(0.5f,0.5f,0.5f,0.3f);
-				gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom);
+			gGL.color4f(0.5f,0.5f,0.5f,0.3f);
+			gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom);
 				
-				if (mHoverBarIndex >= 0)
-				{
-					S32 bar_frame = first_frame - mHoverBarIndex;
-					F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame;
+			if (mHoverBarIndex >= 0)
+			{
+				S32 bar_frame = first_frame - mHoverBarIndex;
+				F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame;
 
-					gGL.color4f(0.5f,0.5f,0.5f,1);
+				gGL.color4f(0.5f,0.5f,0.5f,1);
 				
-					gGL.begin(LLRender::LINES);
-					gGL.vertex2i((S32)bar, mGraphRect.mBottom);
-					gGL.vertex2i((S32)bar, mGraphRect.mTop);
-					gGL.end();
-				}
+				gGL.begin(LLRender::LINES);
+				gGL.vertex2i((S32)bar, mGraphRect.mBottom);
+				gGL.vertex2i((S32)bar, mGraphRect.mTop);
+				gGL.end();
 			}
+		}
 			
-			U64 cur_max = 0;
-			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-				it != end_timer_tree();
-				++it)
-			{
-				LLTrace::BlockTimer* idp = (*it);
+		LLUnit<LLUnits::Seconds, F32> cur_max = 0;
+		U32 cur_max_calls = 0;
+		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+			it != end_timer_tree();
+			++it)
+		{
+			LLTrace::TimeBlock* idp = (*it);
 				
-				//fatten highlighted timer
-				if (mHoverID == idp)
-				{
-					gGL.flush();
-					glLineWidth(3);
-				}
+			//fatten highlighted timer
+			if (mHoverID == idp)
+			{
+				gGL.flush();
+				glLineWidth(3);
+			}
 			
-				const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV;
+			const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV;
 				
-				F32 alpha = 1.f;
+			F32 alpha = 1.f;
 				
-				if (mHoverID != NULL &&
-					idp != mHoverID)
-				{	//fade out non-highlighted timers
-					if (idp->getParent() != mHoverID)
-					{
-						alpha = alpha_interp;
-					}
-				}
-
-				gGL.color4f(col[0], col[1], col[2], alpha);				
-				gGL.begin(LLRender::TRIANGLE_STRIP);
-				for (U32 j = llmax(0, LLTrace::BlockTimer::HISTORY_NUM - LLTrace::BlockTimer::getLastFrameIndex());
-					j < LLTrace::BlockTimer::HISTORY_NUM;
-					j++)
+			if (mHoverID != NULL &&
+				idp != mHoverID)
+			{	//fade out non-highlighted timers
+				if (idp->getParent() != mHoverID)
 				{
-					U64 ticks = idp->getHistoricalCount(j);
-
-					if (mDisplayHz)
-					{
-						F64 tc = (F64) (ticks+1) * iclock_freq;
-						tc = 1000.f/tc;
-						ticks = llmin((U64) tc, (U64) 1024);
-					}
-					else if (mDisplayCalls)
-					{
-						ticks = (S32)idp->getHistoricalCalls(j);
-					}
-										
-					if (alpha == 1.f)
-					{ 
-						//normalize to highlighted timer
-						cur_max = llmax(cur_max, ticks);
-					}
-					F32 x = mGraphRect.mLeft + ((F32) (mGraphRect.getWidth()))/(LLTrace::BlockTimer::HISTORY_NUM-1)*j;
-					F32 y = mGraphRect.mBottom + (F32) mGraphRect.getHeight()/max_ticks*ticks;
-					gGL.vertex2f(x,y);
-					gGL.vertex2f(x,mGraphRect.mBottom);
-				}
-				gGL.end();
-				
-				if (mHoverID == idp)
-				{
-					gGL.flush();
-					glLineWidth(1);
+					alpha = alpha_interp;
 				}
+			}
 
-				if (idp->getCollapsed())
-				{	
-					//skip hidden timers
-					it.skipDescendants();
+			gGL.color4f(col[0], col[1], col[2], alpha);				
+			gGL.begin(LLRender::TRIANGLE_STRIP);
+			for (U32 j = frame_recording.getNumPeriods();
+				j < LLTrace::TimeBlock::HISTORY_NUM;
+				j++)
+			{
+				LLUnit<LLUnits::Seconds, F32> time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
+				U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount());
+
+				if (alpha == 1.f)
+				{ 
+					//normalize to highlighted timer
+					cur_max = llmax(cur_max, time);
+					cur_max_calls = llmax(cur_max_calls, calls);
 				}
+				F32 x = mGraphRect.mLeft + j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1);
+				F32 y = mDisplayHz 
+					? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
+					: mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time);
+				gGL.vertex2f(x,y);
+				gGL.vertex2f(x,mGraphRect.mBottom);
 			}
-			
-			//interpolate towards new maximum
-			last_max = (U64) lerp((F32)last_max, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f));
-			if (last_max - cur_max <= 1 ||  cur_max - last_max  <= 1)
+			gGL.end();
+				
+			if (mHoverID == idp)
 			{
-				last_max = cur_max;
+				gGL.flush();
+				glLineWidth(1);
 			}
-			F32 alpha_target = last_max > cur_max ?
-								llmin((F32) last_max/ (F32) cur_max - 1.f,1.f) :
-								llmin((F32) cur_max/ (F32) last_max - 1.f,1.f);
-			alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f));
 
-			if (mHoverID != NULL)
-			{
-				x = (mGraphRect.mRight + mGraphRect.mLeft)/2;
-				y = mGraphRect.mBottom + 8;
-
-				LLFontGL::getFontMonospace()->renderUTF8(
-					mHoverID->getName(), 
-					0, 
-					x, y, 
-					LLColor4::white,
-					LLFontGL::LEFT, LLFontGL::BOTTOM);
-			}					
+			if (idp->getCollapsed())
+			{	
+				//skip hidden timers
+				it.skipDescendants();
+			}
+		}
+			
+		//interpolate towards new maximum
+		max_time = lerp((F32)max_time, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f));
+		if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
+		{
+			max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max));
+		}
+
+		max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f));
+		if (llabs(max_calls - cur_max) <= 1)
+		{
+			max_calls = cur_max_calls;
 		}
+
+		// TODO: make sure alpha is correct in DisplayHz mode
+		F32 alpha_target = (max_time > cur_max)
+			? llmin((F32) max_time/ (F32) cur_max - 1.f,1.f) 
+			: llmin((F32) cur_max/ (F32) max_time - 1.f,1.f);
+		alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f));
+
+		if (mHoverID != NULL)
+		{
+			x = (mGraphRect.mRight + mGraphRect.mLeft)/2;
+			y = mGraphRect.mBottom + 8;
+
+			LLFontGL::getFontMonospace()->renderUTF8(
+				mHoverID->getName(), 
+				0, 
+				x, y, 
+				LLColor4::white,
+				LLFontGL::LEFT, LLFontGL::BOTTOM);
+		}					
 	}
 
+
 	// Output stats for clicked bar to log
 	if (mPrintStats >= 0)
 	{
@@ -985,7 +947,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLTrace::BlockTimer* idp = (*it);
+			LLTrace::TimeBlock* idp = (*it);
 
 			if (!first)
 			{
@@ -1007,7 +969,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLTrace::BlockTimer* idp = (*it);
+			LLTrace::TimeBlock* idp = (*it);
 
 			if (!first)
 			{
@@ -1015,16 +977,16 @@ void LLFastTimerView::draw()
 			}
 			first = false;
 
-			U64 ticks;
+			LLUnit<LLUnits::Seconds, F32> ticks;
 			if (mPrintStats > 0)
 			{
-				ticks = idp->getHistoricalCount(mPrintStats);
+				ticks = frame_recording.getPrevRecordingPeriod(mPrintStats).getSum(*idp);
 			}
 			else
 			{
-				ticks = idp->getCountAverage();
+				ticks = frame_recording.getPeriodMean(*idp);
 			}
-			F32 ms = (F32)((F64)ticks * iclock_freq);
+			LLUnit<LLUnits::Milliseconds, F32> ms = ticks;
 
 			timer_stat += llformat("%.1f",ms);
 
@@ -1544,13 +1506,13 @@ void LLFastTimerView::outputAllMetrics()
 //static
 void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
 {
-	if(LLTrace::BlockTimer::sLog)
+	if(LLTrace::TimeBlock::sLog)
 	{
 		doAnalysisDefault(baseline, target, output) ;
 		return ;
 	}
 
-	if(LLTrace::BlockTimer::sMetricLog)
+	if(LLTrace::TimeBlock::sMetricLog)
 	{
 		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
 		return ;
@@ -1561,7 +1523,7 @@ void	LLFastTimerView::onClickCloseBtn()
 	setVisible(false);
 }
 
-LLTrace::BlockTimer& LLFastTimerView::getFrameTimer()
+LLTrace::TimeBlock& LLFastTimerView::getFrameTimer()
 {
 	return FTM_FRAME;
 }
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index d7f7f27cd4..55adae4147 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -29,6 +29,7 @@
 
 #include "llfloater.h"
 #include "llfasttimer.h"
+#include "llunit.h"
 
 class LLFastTimerView : public LLFloater
 {
@@ -46,7 +47,7 @@ private:
 	static LLSD analyzePerformanceLogDefault(std::istream& is) ;
 	static void exportCharts(const std::string& base, const std::string& target);
 	void onPause();
-	LLTrace::BlockTimer& getFrameTimer();
+	LLTrace::TimeBlock& getFrameTimer();
 
 public:
 
@@ -59,7 +60,7 @@ public:
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
 
-	LLTrace::BlockTimer* getLegendID(S32 y);
+	LLTrace::TimeBlock* getLegendID(S32 y);
 	F64 getTime(const std::string& name);
 
 protected:
@@ -78,20 +79,19 @@ private:
 		ALIGN_COUNT
 	} ChildAlignment;
 
-	ChildAlignment mDisplayCenter;
-	S32 mDisplayCalls;
-	S32 mDisplayHz;
-	U64 mAvgCountTotal;
-	U64 mMaxCountTotal;
-	LLRect mBarRect;
-	S32	mScrollIndex;
-	LLTrace::BlockTimer* mHoverID;
-	LLTrace::BlockTimer* mHoverTimer;
-	LLRect					mToolTipRect;
-	S32 mHoverBarIndex;
-	LLFrameTimer mHighlightTimer;
-	S32 mPrintStats;
-	LLRect mGraphRect;
+	ChildAlignment                mDisplayCenter;
+	bool                          mDisplayCalls,
+								  mDisplayHz;
+	LLUnit<LLUnits::Seconds, F64> mAllTimeMax;
+	LLRect                        mBarRect;
+	S32						      mScrollIndex;
+	LLTrace::TimeBlock*           mHoverID;
+	LLTrace::TimeBlock*           mHoverTimer;
+	LLRect						  mToolTipRect;
+	S32                           mHoverBarIndex;
+	LLFrameTimer                  mHighlightTimer;
+	S32                           mPrintStats;
+	LLRect                        mGraphRect;
 };
 
 #endif
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 511e6ec2ab..69999071e7 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2184,7 +2184,7 @@ bool idle_startup()
 		LLAppViewer::instance()->handleLoginComplete();
 
 		// reset timers now that we are running "logged in" logic
-		LLTrace::BlockTimer::reset();
+		LLTrace::TimeBlock::reset();
 
 		LLAgentPicksInfo::getInstance()->requestNumberOfPicks();
 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 1ba78f18d3..781a420648 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -7296,7 +7296,7 @@ void handle_dump_avatar_local_textures(void*)
 
 void handle_dump_timers()
 {
-	LLFastTimer::dumpCurTimes();
+	LLTrace::TimeBlock::dumpCurTimes();
 }
 
 void handle_debug_avatar_textures(void*)
-- 
cgit v1.2.3


From 6c7825107f6ebb3dd8697a52aeb5d29a93060dc4 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 4 Dec 2012 19:10:02 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system added copy
 constructor to periodic recording to allow snapshot generation in fast timer
 view fixed build errors

---
 indra/newview/llfasttimerview.cpp | 47 ++++++++++++++++++++++++++-------------
 indra/newview/llfasttimerview.h   |  3 +++
 indra/newview/llstartup.cpp       |  3 ---
 3 files changed, 34 insertions(+), 19 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index acf3799f27..a06fac6bb6 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -87,21 +87,38 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mScrollIndex(0),
 	mHoverID(NULL),
 	mHoverBarIndex(-1),
-	mPrintStats(-1)
+	mPrintStats(-1),
+	mRecording(&LLTrace::get_frame_recording())
 {}
 
+LLFastTimerView::~LLFastTimerView()
+{
+	if (mRecording != &LLTrace::get_frame_recording())
+	{
+		delete mRecording;
+	}
+	mRecording = NULL;
+}
+
 void LLFastTimerView::onPause()
 {
 	LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory;
 	// reset scroll to bottom when unpausing
 	if (!LLTrace::TimeBlock::sPauseHistory)
 	{
+		mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording());
 		mScrollIndex = 0;
 		LLTrace::TimeBlock::sResetHistory = true;
 		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
 	}
 	else
 	{
+		if (mRecording != &LLTrace::get_frame_recording())
+		{
+			delete mRecording;
+		}
+		mRecording = &LLTrace::get_frame_recording();
+
 		getChild<LLButton>("pause_btn")->setLabel(getString("run"));
 	}
 }
@@ -133,7 +150,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	{
 		S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
 		bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
-		mPrintStats = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - bar_idx;
+		mPrintStats = mScrollIndex + bar_idx;
 		return TRUE;
 	}
 	return LLFloater::handleRightMouseDown(x, y, mask);
@@ -217,7 +234,7 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 {
-	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+	LLTrace::PeriodicRecording& frame_recording = *mRecording;
 
 	if (hasMouseCapture())
 	{
@@ -231,7 +248,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 	if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y))
 	{
-		mHoverBarIndex = llmin(LLTrace::get_frame_recording().getNumPeriods() - 1, 
+		mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1, 
 								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
 		if (mHoverBarIndex == 0)
 		{
@@ -286,12 +303,10 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 }
 
 
-static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index = -1)
+static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLTrace::PeriodicRecording& frame_recording)
 {
 	F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond();
 
-	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
-
 	std::string tooltip;
 	if (history_index < 0)
 	{
@@ -315,7 +330,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLRect screen_rect;
 			localRectToScreen(mToolTipRect, &screen_rect);
 
-			std::string tooltip = get_tooltip(*mHoverTimer, LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex);
+			std::string tooltip = get_tooltip(*mHoverTimer, mScrollIndex + mHoverBarIndex, *mRecording);
 
 			LLToolTipMgr::instance().show(LLToolTip::Params()
 				.message(tooltip)
@@ -333,7 +348,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLTrace::TimeBlock* idp = getLegendID(y);
 			if (idp)
 			{
-				LLToolTipMgr::instance().show(get_tooltip(*idp));
+				LLToolTipMgr::instance().show(get_tooltip(*idp, -1,  *mRecording));
 
 				return TRUE;
 			}
@@ -345,7 +360,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+	LLTrace::PeriodicRecording& frame_recording = *mRecording;
 
 	LLTrace::TimeBlock::sPauseHistory = TRUE;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
@@ -362,7 +377,7 @@ void LLFastTimerView::draw()
 {
 	LLFastTimer t(FTM_RENDER_TIMER);
 
-	LLTrace::PeriodicRecording& frame_recording = LLTrace::get_frame_recording();
+	LLTrace::PeriodicRecording& frame_recording = *mRecording;
 
 	std::string tdesc;
 
@@ -480,7 +495,7 @@ void LLFastTimerView::draw()
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
-				S32 hidx = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex - mHoverBarIndex;
+				S32 hidx = mScrollIndex + mHoverBarIndex;
 				ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp);
 				calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount());
 			}
@@ -660,7 +675,7 @@ void LLFastTimerView::draw()
 		S32 tidx;
 		if (j >= 0)
 		{
-			tidx = LLTrace::TimeBlock::HISTORY_NUM - j - 1 - mScrollIndex;
+			tidx = j + 1 + mScrollIndex;
 		}
 		else
 		{
@@ -870,8 +885,8 @@ void LLFastTimerView::draw()
 			gGL.color4f(col[0], col[1], col[2], alpha);				
 			gGL.begin(LLRender::TRIANGLE_STRIP);
 			for (U32 j = frame_recording.getNumPeriods();
-				j < LLTrace::TimeBlock::HISTORY_NUM;
-				j++)
+				j > 0;
+				j--)
 			{
 				LLUnit<LLUnits::Seconds, F32> time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
 				U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount());
@@ -882,7 +897,7 @@ void LLFastTimerView::draw()
 					cur_max = llmax(cur_max, time);
 					cur_max_calls = llmax(cur_max_calls, calls);
 				}
-				F32 x = mGraphRect.mLeft + j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1);
+				F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1);
 				F32 y = mDisplayHz 
 					? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
 					: mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time);
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 55adae4147..6474c2f524 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -30,11 +30,13 @@
 #include "llfloater.h"
 #include "llfasttimer.h"
 #include "llunit.h"
+#include "lltracerecording.h"
 
 class LLFastTimerView : public LLFloater
 {
 public:
 	LLFastTimerView(const LLSD&);
+	~LLFastTimerView();
 	BOOL postBuild();
 
 	static BOOL sAnalyzePerformance;
@@ -92,6 +94,7 @@ private:
 	LLFrameTimer                  mHighlightTimer;
 	S32                           mPrintStats;
 	LLRect                        mGraphRect;
+	LLTrace::PeriodicRecording*	  mRecording;
 };
 
 #endif
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 69999071e7..648fb0f7b7 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2183,9 +2183,6 @@ bool idle_startup()
 
 		LLAppViewer::instance()->handleLoginComplete();
 
-		// reset timers now that we are running "logged in" logic
-		LLTrace::TimeBlock::reset();
-
 		LLAgentPicksInfo::getInstance()->requestNumberOfPicks();
 
 		LLIMFloater::initIMFloater();
-- 
cgit v1.2.3


From 60800dacdd7e9b66ed654af471f2b9e9680cd981 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 6 Dec 2012 00:37:15 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system fixed gcc compile
 error made LLCopyOnWritePointer contain an LLPointer, not derive from it
 added type trait to control periodicrecording mean value type

---
 indra/newview/llfasttimerview.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index a06fac6bb6..704b914b78 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -501,7 +501,7 @@ void LLFastTimerView::draw()
 			}
 			else
 			{
-				ms = frame_recording.getPeriodMean(*idp);
+				ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
 				calls = frame_recording.getPeriodMean(idp->callCount());
 			}
 
@@ -511,7 +511,7 @@ void LLFastTimerView::draw()
 			}
 			else
 			{
-				tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms);
+				tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value());
 			}
 			dx = (texth+4) + idp->getDepth()*8;
 
-- 
cgit v1.2.3


From c99886d94389babc78e92bbfa5084fdd785915af Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 7 Dec 2012 15:20:12 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system improved unit tests
 for LLUnit renamed LLUnit to LLUnitImplicit with LLUnit being reserved for
 explicit units

---
 indra/newview/llfasttimerview.cpp | 30 +++++++++++++++---------------
 indra/newview/pipeline.cpp        |  2 +-
 2 files changed, 16 insertions(+), 16 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 704b914b78..1c63022527 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -311,11 +311,11 @@ static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLT
 	if (history_index < 0)
 	{
 		// by default, show average number of call
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier), (S32)frame_recording.getPeriodMean(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier).value(), (S32)frame_recording.getPeriodMean(timer.callCount()));
 	}
 	else
 	{
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount()));
 	}
 	return tooltip;
 }
@@ -601,22 +601,22 @@ void LLFastTimerView::draw()
 	{
 		LLUnit<LLUnits::Milliseconds, U32> ms = total_time;
 
-		tdesc = llformat("%.1f ms |", (F32)ms*.25f);
+		tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f);
 		x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
 		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
 										LLFontGL::LEFT, LLFontGL::TOP);
 			
-		tdesc = llformat("%.1f ms |", (F32)ms*.50f);
+		tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f);
 		x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc);
 		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
 										LLFontGL::LEFT, LLFontGL::TOP);
 			
-		tdesc = llformat("%.1f ms |", (F32)ms*.75f);
+		tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f);
 		x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
 		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
 										LLFontGL::LEFT, LLFontGL::TOP);
 			
-		tdesc = llformat( "%d ms |", (U32)ms);
+		tdesc = llformat( "%d ms |", (U32)ms.value());
 		x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc);
 		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
 										LLFontGL::LEFT, LLFontGL::TOP);
@@ -728,11 +728,11 @@ void LLFastTimerView::draw()
 					++it)
 				{
 					sublevelticks += (tidx == -1)
-						? frame_recording.getPeriodMean(**it)
-						: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it);
+						? frame_recording.getPeriodMean(**it).value()
+						: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
 				}
 
-				F32 subfrac = (F32)sublevelticks / (F32)total_time;
+				F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
 				sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f);
 
 				if (mDisplayCenter == ALIGN_CENTER)
@@ -819,7 +819,7 @@ void LLFastTimerView::draw()
 		else if (mDisplayHz)
 			tdesc = llformat("%d Hz", (int)(1.f / max_time.value()));
 		else
-			tdesc = llformat("%4.2f ms", LLUnit<LLUnits::Milliseconds, F32>(max_time).value());
+			tdesc = llformat("%4.2f ms", max_time.value());
 							
 		x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5;
 		y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
@@ -900,7 +900,7 @@ void LLFastTimerView::draw()
 				F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1);
 				F32 y = mDisplayHz 
 					? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
-					: mGraphRect.mBottom + time * ((F32)mGraphRect.getHeight() / max_time);
+					: mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight();
 				gGL.vertex2f(x,y);
 				gGL.vertex2f(x,mGraphRect.mBottom);
 			}
@@ -920,22 +920,22 @@ void LLFastTimerView::draw()
 		}
 			
 		//interpolate towards new maximum
-		max_time = lerp((F32)max_time, (F32) cur_max, LLCriticalDamp::getInterpolant(0.1f));
+		max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f));
 		if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
 		{
 			max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max));
 		}
 
 		max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f));
-		if (llabs(max_calls - cur_max) <= 1)
+		if (llabs((S32)(max_calls - cur_max_calls)) <= 1)
 		{
 			max_calls = cur_max_calls;
 		}
 
 		// TODO: make sure alpha is correct in DisplayHz mode
 		F32 alpha_target = (max_time > cur_max)
-			? llmin((F32) max_time/ (F32) cur_max - 1.f,1.f) 
-			: llmin((F32) cur_max/ (F32) max_time - 1.f,1.f);
+			? llmin(max_time / cur_max - 1.f,1.f) 
+			: llmin(cur_max/ max_time - 1.f,1.f);
 		alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f));
 
 		if (mHoverID != NULL)
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 813fc7db6a..3be19c3920 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2747,7 +2747,7 @@ void LLPipeline::updateGeom(F32 max_dtime)
 		
 	S32 count = 0;
 	
-	max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnit<LLUnits::Seconds, F32>(max_dtime));
+	max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnitImplicit<LLUnits::Seconds, F32>(max_dtime));
 	LLSpatialGroup* last_group = NULL;
 	LLSpatialBridge* last_bridge = NULL;
 
-- 
cgit v1.2.3


From 8c2e3bea71ea15b805a9e2a288744f10d195d803 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sun, 9 Dec 2012 23:19:11 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system added ability to
 query self time of block timers indepedently

---
 indra/newview/llfasttimerview.cpp | 428 +++++++++++++++++++-------------------
 1 file changed, 210 insertions(+), 218 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 1c63022527..8014b5712b 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -381,9 +381,9 @@ void LLFastTimerView::draw()
 
 	std::string tdesc;
 
-	S32 margin = 10;
-	S32 height = getRect().getHeight();
-	S32 width = getRect().getWidth();
+	const S32 margin = 10;
+	const S32 height = getRect().getHeight();
+	const S32 width = getRect().getWidth();
 	
 	LLRect new_rect;
 	new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
@@ -391,22 +391,17 @@ void LLFastTimerView::draw()
 
 	S32 left, top, right, bottom;
 	S32 x, y, barw, barh, dx, dy;
-	S32 texth, textw;
+	const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
 	LLPointer<LLUIImage> box_imagep = LLUI::getUIImage("Rounded_Square");
 
 	// Draw the window background
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
 	
-	S32 xleft = margin;
-	S32 ytop = margin;
-	
 	// Draw some help
 	{
-		
-		x = xleft;
-		y = height - ytop;
-		texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
+		x = margin;
+		y = height - margin;
 
 		char modedesc[][32] = {
 			"2 x Average ",
@@ -422,9 +417,8 @@ void LLFastTimerView::draw()
 
 		tdesc = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]);
 		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-		textw = LLFontGL::getFontMonospace()->getWidth(tdesc);
 
-		x = xleft, y -= (texth + 2);
+		x = margin, y -= (texth + 2);
 		tdesc = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]);
 		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
 		y -= (texth + 2);
@@ -436,36 +430,38 @@ void LLFastTimerView::draw()
 
 	S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY);
 		
-	// Draw the legend
-	xleft = margin;
-	ytop = y;
-
+	const S32 ytop = y;
 	y -= (texth + 2);
 
-	sTimerColors[&getFrameTimer()] = LLColor4::grey;
+	// generate unique colors
+	{
+		sTimerColors[&getFrameTimer()] = LLColor4::grey;
 
-	F32 hue = 0.f;
+		F32 hue = 0.f;
 
-	for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-		it != timer_tree_iterator_t();
-		++it)
-	{
-		LLTrace::TimeBlock* idp = (*it);
+		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+			it != timer_tree_iterator_t();
+			++it)
+		{
+			LLTrace::TimeBlock* idp = (*it);
 
-		const F32 HUE_INCREMENT = 0.23f;
-		hue = fmodf(hue + HUE_INCREMENT, 1.f);
-		// saturation increases with depth
-		F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f);
-		// lightness alternates with depth
-		F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f;
+			const F32 HUE_INCREMENT = 0.23f;
+			hue = fmodf(hue + HUE_INCREMENT, 1.f);
+			// saturation increases with depth
+			F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f);
+			// lightness alternates with depth
+			F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f;
 
-		LLColor4 child_color;
-		child_color.setHSL(hue, saturation, lightness);
+			LLColor4 child_color;
+			child_color.setHSL(hue, saturation, lightness);
 
-		sTimerColors[idp] = child_color;
+			sTimerColors[idp] = child_color;
+		}
 	}
 
+	// draw legend
 	const S32 LEGEND_WIDTH = 220;
+	const S32 x_start = margin + LEGEND_WIDTH + 8;
 	{
 		LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
 		S32 cur_line = 0;
@@ -480,7 +476,7 @@ void LLFastTimerView::draw()
 			ft_display_idx.push_back(idp);
 			cur_line++;
 
-			x = xleft;
+			x = margin;
 
 			left = x; right = x + texth;
 			top = y; bottom = y - texth;
@@ -547,8 +543,6 @@ void LLFastTimerView::draw()
 
 			y -= (texth + 2);
 
-			textw = dx + LLFontGL::getFontMonospace()->getWidth(idp->getName()) + 40;
-
 			if (idp->getCollapsed()) 
 			{
 				it.skipDescendants();
@@ -556,11 +550,8 @@ void LLFastTimerView::draw()
 		}
 	}
 
-	xleft += LEGEND_WIDTH + 8;
-	// ytop = ytop;
-
 	// update rectangle that includes timer bars
-	mBarRect.mLeft = xleft;
+	mBarRect.mLeft = x_start;
 	mBarRect.mRight = getRect().getWidth();
 	mBarRect.mTop = ytop - (LLFontGL::getFontMonospace()->getLineHeight() + 4);
 	mBarRect.mBottom = margin + LINE_GRAPH_HEIGHT;
@@ -570,238 +561,239 @@ void LLFastTimerView::draw()
 	dy = barh>>2; // spacing between bars
 	if (dy < 1) dy = 1;
 	barh -= dy;
-	barw = width - xleft - margin;
+	barw = width - x_start - margin;
 
 	// Draw the history bars
-	LLLocalClipRect clip(LLRect(xleft, ytop, getRect().getWidth() - margin, margin));
-
 	LLUnit<LLUnits::Seconds, F64> total_time;
-
-	mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer()));
-
-	if (mDisplayMode == 0)
+	switch(mDisplayMode)
 	{
+	case 0:
 		total_time = frame_recording.getPeriodMean(getFrameTimer())*2;
-	}
-	else if (mDisplayMode == 1)
-	{
+		break;
+	case 1:
 		total_time = mAllTimeMax;
-	}
-	else if (mDisplayMode == 2)
-	{
+		break;
+	case 2:
 		// Calculate the max total ticks for the current history
 		total_time = frame_recording.getPeriodMax(getFrameTimer());
-	}
-	else
-	{
+		break;
+	default:
 		total_time = LLUnit<LLUnits::Milliseconds, F32>(100);
+		break;
 	}
-		
-	// Draw MS ticks
+
+	if (total_time > 0)
 	{
-		LLUnit<LLUnits::Milliseconds, U32> ms = total_time;
+		LLLocalClipRect clip(LLRect(x_start, ytop, getRect().getWidth() - margin, margin));
 
-		tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f);
-		x = xleft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										LLFontGL::LEFT, LLFontGL::TOP);
+		mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer()));
+		
+		// Draw MS ticks
+		{
+			LLUnit<LLUnits::Milliseconds, U32> ms = total_time;
+
+			tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f);
+			x = x_start + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
+			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+											LLFontGL::LEFT, LLFontGL::TOP);
 			
-		tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f);
-		x = xleft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										LLFontGL::LEFT, LLFontGL::TOP);
+			tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f);
+			x = x_start + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc);
+			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+											LLFontGL::LEFT, LLFontGL::TOP);
 			
-		tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f);
-		x = xleft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										LLFontGL::LEFT, LLFontGL::TOP);
+			tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f);
+			x = x_start + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
+			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+											LLFontGL::LEFT, LLFontGL::TOP);
 			
-		tdesc = llformat( "%d ms |", (U32)ms.value());
-		x = xleft + barw - LLFontGL::getFontMonospace()->getWidth(tdesc);
-		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										LLFontGL::LEFT, LLFontGL::TOP);
-	}
+			tdesc = llformat( "%d ms |", (U32)ms.value());
+			x = x_start + barw - LLFontGL::getFontMonospace()->getWidth(tdesc);
+			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
+											LLFontGL::LEFT, LLFontGL::TOP);
+		}
 
-	// Draw borders
-	{
-		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-		gGL.color4f(0.5f,0.5f,0.5f,0.5f);
+		// Draw borders
+		{
+			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+			gGL.color4f(0.5f,0.5f,0.5f,0.5f);
 
-		S32 by = y + 2;
+			S32 by = y + 2;
 			
-		y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
+			y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
 
-		//heading
-		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, y+5, FALSE);
+			//heading
+			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, y+5, FALSE);
 
-		//tree view
-		gl_rect_2d(5, by, xleft-10, 5, FALSE);
+			//tree view
+			gl_rect_2d(5, by, x_start-10, 5, FALSE);
 
-		by = y + 5;
-		//average bar
-		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE);
+			by = y + 5;
+			//average bar
+			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE);
 			
-		by -= barh*2+dy;
+			by -= barh*2+dy;
 			
-		//current frame bar
-		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE);
+			//current frame bar
+			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE);
 			
-		by -= barh+dy+1;
+			by -= barh+dy+1;
 			
-		//history bars
-		gl_rect_2d(xleft-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE);			
+			//history bars
+			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE);			
 			
-		by = LINE_GRAPH_HEIGHT-barh-dy-7;
+			by = LINE_GRAPH_HEIGHT-barh-dy-7;
 			
-		//line graph
-		mGraphRect = LLRect(xleft-5, by, getRect().getWidth()-5, 5);
+			//line graph
+			mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5);
 			
-		gl_rect_2d(mGraphRect, FALSE);
-	}
+			gl_rect_2d(mGraphRect, FALSE);
+		}
 		
-	mBarStart.clear();
-	mBarEnd.clear();
+		mBarStart.clear();
+		mBarEnd.clear();
 
-	// Draw bars for each history entry
-	// Special: -1 = show running average
-	gGL.getTexUnit(0)->bind(box_imagep->getImage());
-	for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++)
-	{
-		mBarStart.push_back(std::vector<S32>());
-		mBarEnd.push_back(std::vector<S32>());
-		int sublevel_dx[FTV_MAX_DEPTH];
-		int sublevel_left[FTV_MAX_DEPTH];
-		int sublevel_right[FTV_MAX_DEPTH];
-		S32 tidx;
-		if (j >= 0)
+		// Draw bars for each history entry
+		// Special: -1 = show running average
+		gGL.getTexUnit(0)->bind(box_imagep->getImage());
+		for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++)
 		{
-			tidx = j + 1 + mScrollIndex;
-		}
-		else
-		{
-			tidx = -1;
-		}
+			mBarStart.push_back(std::vector<S32>());
+			mBarEnd.push_back(std::vector<S32>());
+			int sublevel_dx[FTV_MAX_DEPTH];
+			int sublevel_left[FTV_MAX_DEPTH];
+			int sublevel_right[FTV_MAX_DEPTH];
+			S32 tidx;
+			if (j >= 0)
+			{
+				tidx = j + 1 + mScrollIndex;
+			}
+			else
+			{
+				tidx = -1;
+			}
 			
-		x = xleft;
+			x = x_start;
 			
-		// draw the bars for each stat
-		std::vector<S32> xpos;
-		std::vector<S32> deltax;
-		xpos.push_back(xleft);
+			// draw the bars for each stat
+			std::vector<S32> xpos;
+			std::vector<S32> deltax;
+			xpos.push_back(x_start);
 			
-		LLTrace::TimeBlock* prev_id = NULL;
+			LLTrace::TimeBlock* prev_id = NULL;
 
-		S32 i = 0;
-		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-			it != end_timer_tree();
-			++it, ++i)
-		{
-			LLTrace::TimeBlock* idp = (*it);
-			F32 frac = tidx == -1
-				? (frame_recording.getPeriodMean(*idp) / total_time) 
-				: (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value());
+			S32 i = 0;
+			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+				it != end_timer_tree();
+				++it, ++i)
+			{
+				LLTrace::TimeBlock* idp = (*it);
+				F32 frac = tidx == -1
+					? (frame_recording.getPeriodMean(*idp) / total_time) 
+					: (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value());
 		
-			dx = llround(frac * (F32)barw);
-			S32 prev_delta_x = deltax.empty() ? 0 : deltax.back();
-			deltax.push_back(dx);
+				dx = llround(frac * (F32)barw);
+				S32 prev_delta_x = deltax.empty() ? 0 : deltax.back();
+				deltax.push_back(dx);
 				
-			int level = idp->getDepth() - 1;
+				int level = idp->getDepth() - 1;
 				
-			while ((S32)xpos.size() > level + 1)
-			{
-				xpos.pop_back();
-			}
-			left = xpos.back();
-				
-			if (level == 0)
-			{
-				sublevel_left[level] = xleft;
-				sublevel_dx[level] = dx;
-				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
-			}
-			else if (prev_id && prev_id->getDepth() < idp->getDepth())
-			{
-				U64 sublevelticks = 0;
-
-				for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren();
-					it != prev_id->endChildren();
-					++it)
+				while ((S32)xpos.size() > level + 1)
 				{
-					sublevelticks += (tidx == -1)
-						? frame_recording.getPeriodMean(**it).value()
-						: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
+					xpos.pop_back();
 				}
-
-				F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
-				sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f);
-
-				if (mDisplayCenter == ALIGN_CENTER)
+				left = xpos.back();
+				
+				if (level == 0)
 				{
-					left += (prev_delta_x - sublevel_dx[level])/2;
+					sublevel_left[level] = x_start;
+					sublevel_dx[level] = dx;
+					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
 				}
-				else if (mDisplayCenter == ALIGN_RIGHT)
+				else if (prev_id && prev_id->getDepth() < idp->getDepth())
 				{
-					left += (prev_delta_x - sublevel_dx[level]);
-				}
-
-				sublevel_left[level] = left;
-				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
-			}				
-
-			right = left + dx;
-			xpos.back() = right;
-			xpos.push_back(left);
+					U64 sublevelticks = 0;
+
+					for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren();
+						it != prev_id->endChildren();
+						++it)
+					{
+						sublevelticks += (tidx == -1)
+							? frame_recording.getPeriodMean(**it).value()
+							: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
+					}
+
+					F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
+					sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f);
+
+					if (mDisplayCenter == ALIGN_CENTER)
+					{
+						left += (prev_delta_x - sublevel_dx[level])/2;
+					}
+					else if (mDisplayCenter == ALIGN_RIGHT)
+					{
+						left += (prev_delta_x - sublevel_dx[level]);
+					}
+
+					sublevel_left[level] = left;
+					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
+				}				
+
+				right = left + dx;
+				xpos.back() = right;
+				xpos.push_back(left);
 				
-			mBarStart.back().push_back(left);
-			mBarEnd.back().push_back(right);
+				mBarStart.back().push_back(left);
+				mBarEnd.back().push_back(right);
 
-			top = y;
-			bottom = y - barh;
+				top = y;
+				bottom = y - barh;
 
-			if (right > left)
-			{
-				//U32 rounded_edges = 0;
-				LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color;
-				S32 scale_offset = 0;
-
-				BOOL is_child_of_hover_item = (idp == mHoverID);
-				LLTrace::TimeBlock* next_parent = idp->getParent();
-				while(!is_child_of_hover_item && next_parent)
+				if (right > left)
 				{
-					is_child_of_hover_item = (mHoverID == next_parent);
-					if (next_parent->getParent() == next_parent) break;
-					next_parent = next_parent->getParent();
-				}
+					//U32 rounded_edges = 0;
+					LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color;
+					S32 scale_offset = 0;
+
+					BOOL is_child_of_hover_item = (idp == mHoverID);
+					LLTrace::TimeBlock* next_parent = idp->getParent();
+					while(!is_child_of_hover_item && next_parent)
+					{
+						is_child_of_hover_item = (mHoverID == next_parent);
+						if (next_parent->getParent() == next_parent) break;
+						next_parent = next_parent->getParent();
+					}
+
+					if (idp == mHoverID)
+					{
+						scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
+						//color = lerp(color, LLColor4::black, -0.4f);
+					}
+					else if (mHoverID != NULL && !is_child_of_hover_item)
+					{
+						color = lerp(color, LLColor4::grey, 0.8f);
+					}
+
+					gGL.color4fv(color.mV);
+					F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
+					F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
+					gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment);
 
-				if (idp == mHoverID)
-				{
-					scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
-					//color = lerp(color, LLColor4::black, -0.4f);
 				}
-				else if (mHoverID != NULL && !is_child_of_hover_item)
+
+				if ((*it)->getCollapsed())
 				{
-					color = lerp(color, LLColor4::grey, 0.8f);
+					it.skipDescendants();
 				}
-
-				gGL.color4fv(color.mV);
-				F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-				F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-				gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment);
-
-			}
-
-			if ((*it)->getCollapsed())
-			{
-				it.skipDescendants();
-			}
 		
-			prev_id = idp;
+				prev_id = idp;
+			}
+			y -= (barh + dy);
+			if (j < 0)
+				y -= barh;
 		}
-		y -= (barh + dy);
-		if (j < 0)
-			y -= barh;
 	}
-		
+
 	//draw line graph history
 	{
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-- 
cgit v1.2.3


From f2bf13b87768c97ec6a36a183013413bf4b905f0 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 12 Dec 2012 11:00:24 -0700
Subject: fix for SH-3622: crash on LLViewerRegion::updateVisibleEntries

---
 indra/newview/llviewerregion.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index e275b44e92..ab692308b0 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -777,25 +777,25 @@ void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry)
 		return;
 	}
 
-	//1, remove from active list and waiting list
+	//remove from active list and waiting list
 	if(entry->isState(LLVOCacheEntry::ACTIVE))
 	{
 		mImpl->mActiveSet.erase(entry);
 	}
-	else if(entry->isState(LLVOCacheEntry::WAITING))
-	{
-		mImpl->mWaitingSet.erase(entry);
-	}
-	else if(entry->isState(LLVOCacheEntry::IN_QUEUE))
-	{
-		mImpl->mVisibleEntries.erase(entry);
-	}
-	else if(entry->isState(LLVOCacheEntry::INACTIVE))
+	else
 	{
+		if(entry->isState(LLVOCacheEntry::WAITING))
+		{
+			mImpl->mWaitingSet.erase(entry);
+		}
+		
 		//remove from mVOCachePartition
 		removeFromVOCacheTree(entry);
 	}
 
+	//remove from the forced visible list
+	mImpl->mVisibleEntries.erase(entry);
+
 	//kill LLViewerObject if exists
 	//this should be done by the rendering pipeline automatically.
 	
-- 
cgit v1.2.3


From 834a956a70bb49f1a242681bd611df4bbb7e4cc8 Mon Sep 17 00:00:00 2001
From: Andrew Meadows <andrew@lindenlab.com>
Date: Thu, 13 Dec 2012 15:43:10 -0800
Subject: We now handle local_id=0 in KillObject as a prefix to deleted
 local_id's. This is the real viewer-side work that was the motivation for
 MAINT-2123. Reviewed with Bao.

---
 indra/newview/llappviewer.cpp        |  5 ---
 indra/newview/llviewermessage.cpp    | 80 ++++++++++++++++++------------------
 indra/newview/llviewerobjectlist.cpp | 12 +-----
 indra/newview/llviewerobjectlist.h   |  1 -
 4 files changed, 40 insertions(+), 58 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index bffa1708ec..777fe4b8f1 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4267,11 +4267,6 @@ void LLAppViewer::idle()
 				llinfos << "Dead object updates: " << gObjectList.mNumDeadObjectUpdates << llendl;
 				gObjectList.mNumDeadObjectUpdates = 0;
 			}
-			if (gObjectList.mNumUnknownKills)
-			{
-				llinfos << "Kills on unknown objects: " << gObjectList.mNumUnknownKills << llendl;
-				gObjectList.mNumUnknownKills = 0;
-			}
 			if (gObjectList.mNumUnknownUpdates)
 			{
 				llinfos << "Unknown object updates: " << gObjectList.mNumUnknownUpdates << llendl;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 67d400af2d..62d4e779d0 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4483,40 +4483,42 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 
 static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Kill Objects");
 
+const U32 KILLOBJECT_DELETE_OPCODE = 0;
+
 
 void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 {
 	LLFastTimer t(FTM_PROCESS_OBJECTS);
 
-	LLUUID		id;
-	U32			local_id;
-	S32			i = 0;
-	S32			num_objects;
-
-	num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
+	LLUUID id;
 
-	mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
+	U32 ip = mesgsys->getSenderIP();
+	U32 port = mesgsys->getSenderPort();
 	LLViewerRegion* regionp = NULL;
-	bool remove_from_cache = !local_id; //if the first local id is 0, physically remove all objects from VO cache.
-	if(remove_from_cache)
 	{
-		i++;
-
-		LLHost host(gMessageSystem->getSenderIP(), gMessageSystem->getSenderPort());
+		LLHost host(ip, port);
 		regionp = LLWorld::getInstance()->getRegion(host);
 	}
-	for (; i < num_objects; i++)
+
+	bool delete_object = false;
+	S32	num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
+	for (S32 i = 0; i < num_objects; ++i)
 	{
+		U32	local_id;
 		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
+		if (local_id == KILLOBJECT_DELETE_OPCODE)
+		{
+			// This local_id is invalid, but was sent by the server to flag
+			// all subsequent local_id's as objects that were actually deleted
+			// rather than unsubscribed from interestlist.
+			delete_object = true;
+			continue;
+		}
 
-		LLViewerObjectList::getUUIDFromLocal(id,
-											local_id,
-											gMessageSystem->getSenderIP(),
-											gMessageSystem->getSenderPort());
+		LLViewerObjectList::getUUIDFromLocal(id, local_id, ip, port); 
 		if (id == LLUUID::null)
 		{
 			LL_DEBUGS("Messaging") << "Unknown kill for local " << local_id << LL_ENDL;
-			gObjectList.mNumUnknownKills++;
 			continue;
 		}
 		else
@@ -4524,39 +4526,35 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 			LL_DEBUGS("Messaging") << "Kill message for local " << local_id << LL_ENDL;
 		}
 
-		// ...don't kill the avatar
-		if (!(id == gAgentID))
+		if (id == gAgentID)
 		{
-			LLViewerObject *objectp = gObjectList.findObject(id);
-			if (objectp)
-			{
-				// Display green bubble on kill
-				if ( gShowObjectUpdates )
-				{
-					LLColor4 color(0.f,1.f,0.f,1.f);
-					gPipeline.addDebugBlip(objectp->getPositionAgent(), color);
-				}
-
-				// Do the kill
-				gObjectList.killObject(objectp);
-			}
-			//else
-			//{
-			//	LL_WARNS("Messaging") << "Object in UUID lookup, but not on object list in kill!" << LL_ENDL;
-			//	gObjectList.mNumUnknownKills++;
-			//}
+			// never kill our avatar
+			continue;
+		}
 
-			if(remove_from_cache)
+		LLViewerObject *objectp = gObjectList.findObject(id);
+		if (objectp)
+		{
+			// Display green bubble on kill
+			if ( gShowObjectUpdates )
 			{
-				regionp->killCacheEntry(local_id);
+				LLColor4 color(0.f,1.f,0.f,1.f);
+				gPipeline.addDebugBlip(objectp->getPositionAgent(), color);
 			}
+
+			// Do the kill
+			gObjectList.killObject(objectp);
+		}
+
+		if(delete_object)
+		{
+			regionp->killCacheEntry(local_id);
 		}
 
 		// We should remove the object from selection after it is marked dead by gObjectList to make LLToolGrab,
         // which is using the object, release the mouse capture correctly when the object dies.
         // See LLToolGrab::handleHoverActive() and LLToolGrab::handleHoverNonPhysical().
 		LLSelectMgr::getInstance()->removeObjectFromSelections(id);
-
 	}
 }
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index f3552e2c2b..5b2214f3b3 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -107,7 +107,6 @@ LLViewerObjectList::LLViewerObjectList()
 	mNumNewObjects = 0;
 	mWasPaused = FALSE;
 	mNumDeadObjectUpdates = 0;
-	mNumUnknownKills = 0;
 	mNumUnknownUpdates = 0;
 }
 
@@ -1342,16 +1341,7 @@ BOOL LLViewerObjectList::killObject(LLViewerObject *objectp)
 
 	if (objectp)
 	{
-		if (objectp->isDead())
-		{
-			// This object is already dead.  Don't need to do more.
-			return TRUE;
-		}
-		else
-		{
-			objectp->markDead();
-		}
-
+		objectp->markDead(); // does the right thing if object already dead
 		return TRUE;
 	}
 
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 17c8c86ff5..3b26df7de6 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -191,7 +191,6 @@ public:
 
 	S32 mNumUnknownUpdates;
 	S32 mNumDeadObjectUpdates;
-	S32 mNumUnknownKills;
 	S32 mNumDeadObjects;
 protected:
 	std::vector<U64>	mOrphanParents;	// LocalID/ip,port of orphaned objects
-- 
cgit v1.2.3


From 1f56e57008f5a50c9e75fc0b4512c483ac359a52 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 18 Dec 2012 00:58:26 -0800
Subject: SH-3468 WIP add memory tracking base class created memory tracking
 trace type instrumented a few classes with memory tracking

---
 indra/newview/lldrawable.h     | 35 ++++++++++++++++++-----------------
 indra/newview/llface.h         | 10 +++++-----
 indra/newview/llviewerobject.h |  6 +++++-
 3 files changed, 28 insertions(+), 23 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 4608d16fec..f15090fb87 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -59,7 +59,9 @@ const U32 SILHOUETTE_HIGHLIGHT = 0;
 
 // All data for new renderer goes into this class.
 LL_ALIGN_PREFIX(16)
-class LLDrawable : public LLRefCount
+class LLDrawable 
+:	public LLRefCount,
+	public LLTrace::MemTrackable<LLDrawable>
 {
 public:
 	LLDrawable(const LLDrawable& rhs)
@@ -316,24 +318,23 @@ public:
 private:
 	typedef std::vector<LLFace*> face_list_t;
 	
-	U32				mState;
-	S32				mRenderType;
-	LLPointer<LLViewerObject> mVObjp;
-	face_list_t     mFaces;
-	LLSpatialGroup* mSpatialGroupp;
-	LLPointer<LLDrawable> mSpatialBridge;
+	U32							mState;
+	S32							mRenderType;
+	LLPointer<LLViewerObject>	mVObjp;
+	face_list_t					mFaces;
+	LLSpatialGroup*				mSpatialGroupp;
+	LLPointer<LLDrawable>		mSpatialBridge;
 	
-	mutable U32		mVisible;
-	F32				mRadius;
-	F32				mBinRadius;
-	mutable S32		mBinIndex;
-	S32				mGeneration;
-	
-	LLVector3		mCurrentScale;
-	
-	static U32 sCurVisible; // Counter for what value of mVisible means currently visible
+	mutable U32					mVisible;
+	F32							mRadius;
+	F32							mBinRadius;
+	mutable S32					mBinIndex;
+	S32							mGeneration;
 
-	static U32 sNumZombieDrawables;
+	LLVector3					mCurrentScale;
+	
+	static U32					sCurVisible; // Counter for what value of mVisible means currently visible
+	static U32					sNumZombieDrawables;
 	static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
 } LL_ALIGN_POSTFIX(16);
 
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index de4d03351c..15c9e7856f 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -262,11 +262,11 @@ public:
 	
 	LLVector2		mTexExtents[2];
 	F32				mDistance;
-	F32			mLastUpdateTime;
-	F32			mLastSkinTime;
-	F32			mLastMoveTime;
-	LLMatrix4*	mTextureMatrix;
-	LLDrawInfo* mDrawInfo;
+	F32				mLastUpdateTime;
+	F32				mLastSkinTime;
+	F32				mLastMoveTime;
+	LLMatrix4*		mTextureMatrix;
+	LLDrawInfo*		mDrawInfo;
 
 private:
 	LLPointer<LLVertexBuffer> mVertexBuffer;
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 97cf0a4850..14ea8ded38 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -107,7 +107,11 @@ struct PotentialReturnableObject
 
 //============================================================================
 
-class LLViewerObject : public LLPrimitive, public LLRefCount, public LLGLUpdate
+class LLViewerObject 
+:	public LLPrimitive, 
+	public LLRefCount, 
+	public LLGLUpdate,
+	public LLTrace::MemTrackable<LLViewerObject>
 {
 protected:
 	~LLViewerObject(); // use unref()
-- 
cgit v1.2.3


From e1247d631f24065a31d9668915cb8bc84f3abc7f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 18 Dec 2012 14:36:46 -0700
Subject: fix for SH-3619: some objects are missing

---
 indra/newview/lldrawable.cpp     | 13 ------
 indra/newview/llvieweroctree.cpp | 50 ++++++++++++++++++--
 indra/newview/llvieweroctree.h   | 19 ++++++--
 indra/newview/llviewerregion.cpp | 98 ++++++++++++----------------------------
 indra/newview/llviewerregion.h   |  1 +
 indra/newview/llvocache.cpp      | 49 ++++++++++----------
 indra/newview/llvocache.h        |  2 -
 indra/newview/llworld.cpp        |  1 +
 8 files changed, 116 insertions(+), 117 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index c782fbfe7e..1b7a98ba54 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1473,19 +1473,6 @@ void LLSpatialBridge::shiftPos(const LLVector4a& vec)
 
 void LLSpatialBridge::cleanupReferences()
 {	
-	LLPointer<LLVOCacheEntry> dummy_entry;
-	if (mDrawable && mDrawable->isDead() && mDrawable->getEntry()->hasVOCacheEntry())
-	{
-		//create a dummy entry to insert the entire LLSpatialBridge to the vo_cache partition so it can be reloaded.
-
-		dummy_entry = new LLVOCacheEntry();
-		dummy_entry->setOctreeEntry(mEntry);
-		dummy_entry->addChild((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry());
-		//llassert(!mDrawable->getParent());
-		
-		//mDrawable->mParent = this;
-	}
-
 	LLDrawable::cleanupReferences();
 	if (mDrawable)
 	{
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index b6e0674a95..7f502a6c51 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -675,6 +675,8 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n)
 	}
 }
 	
+//------------------------------------------
+//agent space group culling
 S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group)
 {
 	return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]);
@@ -685,6 +687,14 @@ S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGrou
 	return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist);
 }
 
+S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]);
+}
+//------------------------------------------
+
+//------------------------------------------
+//agent space object set culling
 S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group)
 {
 	return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]);
@@ -695,15 +705,47 @@ S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGro
 	return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist);
 }
 
-S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group)
+S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group)
 {
-	return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]);
+	return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
 }
+//------------------------------------------
 
-S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group)
+//------------------------------------------
+//local regional space group culling
+S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group)
 {
-	return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
+	return mCamera->AABBInRegionFrustumNoFarClip(group->mBounds[0], group->mBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInRegionFrustum(group->mBounds[0], group->mBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift)
+{
+	return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist);
+}
+//------------------------------------------
+
+//------------------------------------------
+//local regional space object culling
+S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInRegionFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group)
+{
+	return mCamera->AABBInRegionFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]);
+}
+
+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)
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index b89014119c..f6ad3ac327 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -280,13 +280,26 @@ public:
 	virtual bool earlyFail(LLviewerOctreeGroup* group);
 	virtual void traverse(const OctreeNode* n);
 	
-	S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group);
+	//agent space group cull
+	S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group);	
 	S32 AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group);
-	S32 AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group);
-	S32 AABBSphereIntersectObjectExtents(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);
 	
+	//local region space group cull
+	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);	
+	
 	virtual S32 frustumCheck(const LLviewerOctreeGroup* group) = 0;
 	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) = 0;
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index ab692308b0..33e8348660 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -87,6 +87,7 @@ const F32 CAP_REQUEST_TIMEOUT = 18;
 const S32 MAX_CAP_REQUEST_ATTEMPTS = 30;
 
 LLViewerRegion* LLViewerRegion::sCurRegionp = NULL;
+BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
 
 typedef std::map<std::string, std::string> CapabilityMap;
 
@@ -141,7 +142,6 @@ 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<LLVOCacheEntry> > mDummyEntries; //dummy vo cache entries, for LLSpatialBridge use.
 	std::set< LLviewerOctreeGroup* >      mVisibleGroups; //visible groupa
 	LLVOCachePartition*                   mVOCachePartition;
 	LLVOCacheEntry::vocache_entry_set_t   mVisibleEntries; //must-be-created visible entries wait for objects creation.	
@@ -841,17 +841,8 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 	{
 		return;
 	}
-	if(entry->isDummy())
-	{
-		mImpl->mDummyEntries.insert(entry); //keep a copy to prevent from being deleted.
-		addToVOCacheTree(entry);
-	}
-	else if(!drawablep->getParent()) //root node
-	{
-		addToVOCacheTree(entry);
-		mImpl->mVisibleEntries.erase(entry);
-	}
-	else //child node
+
+	if(drawablep->getParent()) //child object
 	{
 		LLViewerOctreeEntry* parent_oct_entry = drawablep->getParent()->getEntry();
 		if(parent_oct_entry && parent_oct_entry->hasVOCacheEntry())
@@ -860,7 +851,19 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 			parent->addChild(entry);
 		}
 	}
+	else //insert to vo cache tree.
+	{
+		//shift to the local regional space from agent space
+		const LLVector3 pos = drawablep->getVObj()->getPositionRegion();
+		LLVector4a vec(pos[0], pos[1], pos[2]);
+		LLVector4a shift; 
+		shift.setSub(vec, entry->getPositionGroup());
+		entry->shift(shift);
+		
+		addToVOCacheTree(entry);
+	}
 
+	mImpl->mVisibleEntries.erase(entry);
 	mImpl->mActiveSet.erase(entry);
 	mImpl->mWaitingSet.erase(entry);
 	entry->setState(LLVOCacheEntry::INACTIVE);
@@ -878,7 +881,10 @@ void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
 
 void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 {
-	static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
+	if(!sVOCacheCullingEnabled)
+	{
+		return;
+	}
 
 	if(mDead || !entry || !entry->getEntry())
 	{
@@ -954,12 +960,13 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	//process visible entries
 	max_time *= 0.5f; //only use up to half available time to update entries.
 
+#if 1
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
 	{
 		LLVOCacheEntry* vo_entry = *iter;
 		vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);
 
-		if(vo_entry->getState() < LLVOCacheEntry::WAITING && !vo_entry->isDummy())
+		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{			
 			mImpl->mWaitingList.insert(vo_entry);
 		}
@@ -987,12 +994,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 		if(!vo_entry->getNumOfChildren())
 		{
-			if(vo_entry->isDummy())
-			{
-				mImpl->mDummyEntries.erase(vo_entry);
-				iter = mImpl->mVisibleEntries.erase(iter);
-			}
-			else if(vo_entry->getState() >= LLVOCacheEntry::WAITING)
+			if(vo_entry->getState() >= LLVOCacheEntry::WAITING)
 			{
 				iter = mImpl->mVisibleEntries.erase(iter);
 			}
@@ -1011,6 +1013,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		//	break;
 		//}
 	}
+#endif
 
 	//process visible groups
 	std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
@@ -1027,11 +1030,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 			if((*i)->hasVOCacheEntry())
 			{
 				LLVOCacheEntry* vo_entry = (LLVOCacheEntry*)(*i)->getVOCacheEntry();
-				if(vo_entry->isDummy())
-				{
-					addVisibleCacheEntry(vo_entry); //for LLSpatialBridge.
-					continue;
-				}
 
 				vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);				
 				mImpl->mWaitingList.insert(vo_entry);
@@ -1118,6 +1116,11 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 
 F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 {
+	if(!sVOCacheCullingEnabled)
+	{
+		return max_time;
+	}
+
 	std::vector<LLDrawable*> delete_list;
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
 		iter != mImpl->mActiveSet.end(); ++iter)
@@ -1695,13 +1698,6 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 
 LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id)
 {
-	static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
-
-	if(!vo_cache_culling_enabled)
-	{
-		return NULL;
-	}
-
 	LLVOCacheEntry* entry = getCacheEntry(local_id);
 	removeFromVOCacheTree(entry);
 
@@ -1741,44 +1737,6 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U8 &cache_miss_type)
 			}
 
 			addVisibleCacheEntry(entry);
-#if 0
-			if(entry->isBridgeChild()) //bridge child
-			{
-				addVisibleCacheEntry(entry);
-			}
-			else
-			{
-				U32 parent_id = entry->getParentID();
-				if(parent_id > 0) //has parent
-				{
-					LLVOCacheEntry* parent = getCacheEntry(parent_id);
-				
-					if(parent) //parent cached
-					{
-						parent->addChild(entry);
-
-						if(parent->isState(LLVOCacheEntry::INACTIVE))
-						{
-							//addToVOCacheTree(parent);
-							addVisibleCacheEntry(parent);
-						}
-						else //parent visible
-						{
-							addVisibleCacheEntry(parent);
-						}
-					}
-					else //parent not cached. This should not happen, but just in case...
-					{
-						addVisibleCacheEntry(entry);
-					}
-				}
-				else //root node
-				{
-					//addToVOCacheTree(entry);
-					addVisibleCacheEntry(entry);
-				}
-			}
-#endif
 			return true;
 		}
 		else
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 9a47227f1c..dbc59cee8f 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -392,6 +392,7 @@ public:
 	LLDynamicArray<LLUUID> mMapAvatarIDs;
 
 	static LLViewerRegion* sCurRegionp;
+	static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
 private:
 	LLViewerRegionImpl * mImpl;
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 8ea79dbae6..59645fdbe9 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -424,24 +424,6 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool
 	setVisible();
 }
 
-U32 LLVOCacheEntry::getParentID()
-{
-	if(!(mState & CHILD))
-	{
-		return 0; //not a child
-	}
-
-	U32 parent_id = 0;
-	LLDataPackerBinaryBuffer* dp = getDP();
-	if(dp)
-	{
-		dp->reset();
-		dp->unpackU32(parent_id, "ParentID");
-		dp->reset();
-	}
-	return parent_id;
-}
-
 //-------------------------------------------------------------------
 //LLVOCachePartition
 //-------------------------------------------------------------------
@@ -471,24 +453,31 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
 class LLVOCacheOctreeCull : public LLViewerOctreeCull
 {
 public:
-	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp) : LLViewerOctreeCull(camera), mRegionp(regionp) {}
+	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift) : LLViewerOctreeCull(camera), mRegionp(regionp) 
+	{
+		mLocalShift = shift;
+	}
 
 	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
-		S32 res = AABBInFrustumNoFarClipGroupBounds(group);
+		//S32 res = AABBInRegionFrustumGroupBounds(group);
+		
+		S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
 		if (res != 0)
 		{
-			res = llmin(res, AABBSphereIntersectGroupExtents(group));
+			res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift));
 		}
 		return res;
 	}
 
 	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
-		S32 res = AABBInFrustumNoFarClipObjectBounds(group);
+		//S32 res = AABBInRegionFrustumObjectBounds(group);
+
+		S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
 		if (res != 0)
 		{
-			res = llmin(res, AABBSphereIntersectObjectExtents(group));
+			res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift));
 		}
 		return res;
 	}
@@ -500,10 +489,16 @@ public:
 
 private:
 	LLViewerRegion* mRegionp;
+	LLVector3       mLocalShift; //shift vector from agent space to local region space.
 };
 
 S32 LLVOCachePartition::cull(LLCamera &camera)
 {
+	if(!LLViewerRegion::sVOCacheCullingEnabled)
+	{
+		return 0;
+	}
+
 	if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame())
 	{
 		return 0; //already visited.
@@ -511,8 +506,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
 	mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame();
 
 	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
-		
-	LLVOCacheOctreeCull culler(&camera, mRegionp);
+
+	//localize the camera
+	LLVector3 region_agent = mRegionp->getOriginAgent();
+	camera.calcRegionFrustumPlanes(region_agent);
+
+	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent);
 	culler.traverse(mOctree);
 
 	return 0;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 4d058ffdac..f5cc5d2f75 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -98,7 +98,6 @@ public:
 	S32 getHitCount() const			{ return mHitCount; }
 	S32 getCRCChangeCount() const	{ return mCRCChangeCount; }
 	S32 getMinVisFrameRange()const;	
-	U32 getParentID();
 
 	void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update);
 	void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;}
@@ -118,7 +117,6 @@ public:
 	LLVOCacheEntry* getChild(S32 i) {return mChildrenList[i];}
 	S32  getNumOfChildren()         {return mChildrenList.size();}
 	void clearChildrenList()        {mChildrenList.clear();}
-	bool isDummy()                  {return !mBuffer;}	
 
 public:
 	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index aed2835e4a..7a7d6a7b43 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -110,6 +110,7 @@ LLWorld::LLWorld() :
 	gGL.getTexUnit(0)->bind(mDefaultWaterTexturep);
 	mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP);
 
+	LLViewerRegion::sVOCacheCullingEnabled = (BOOL)gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
 }
 
 
-- 
cgit v1.2.3


From c219282f5de753a044cecb53bd806145f68add9a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 18 Dec 2012 20:07:25 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system removed some
 potential data races got memory stats recording in trace system

---
 indra/newview/llappviewer.cpp     |  2 +-
 indra/newview/llfasttimerview.cpp | 52 +++++++++++++++++++++++++--------------
 indra/newview/llfasttimerview.h   |  1 +
 3 files changed, 35 insertions(+), 20 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c986954867..4209e6612e 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1233,8 +1233,8 @@ bool LLAppViewer::mainLoop()
 	while (!LLApp::isExiting())
 	{
 		LLFastTimer _(FTM_FRAME);
-		LLTrace::TimeBlock::nextFrame(); 
 		LLTrace::get_frame_recording().nextPeriod();
+		LLTrace::TimeBlock::logStats();
 
 		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 8014b5712b..2cf7939e5c 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -58,6 +58,7 @@ static const S32 MAX_VISIBLE_HISTORY = 10;
 static const S32 LINE_GRAPH_HEIGHT = 240;
 
 const S32 FTV_MAX_DEPTH = 8;
+const S32 HISTORY_NUM = 300;
 
 std::vector<LLTrace::TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
@@ -77,6 +78,19 @@ static timer_tree_iterator_t end_timer_tree()
 	return timer_tree_iterator_t(); 
 }
 
+S32 get_depth(const TimeBlock* blockp)
+{
+	S32 depth = 0;
+	TimeBlock* timerp = blockp->mParent;
+	while(timerp)
+	{
+		depth++;
+		if (timerp->getParent() == timerp) break;
+		timerp = timerp->mParent;
+	}
+	return depth;
+}
+
 LLFastTimerView::LLFastTimerView(const LLSD& key)
 :	LLFloater(key),
 	mHoverTimer(NULL),
@@ -88,7 +102,8 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mHoverID(NULL),
 	mHoverBarIndex(-1),
 	mPrintStats(-1),
-	mRecording(&LLTrace::get_frame_recording())
+	mRecording(&LLTrace::get_frame_recording()),
+	mPauseHistory(false)
 {}
 
 LLFastTimerView::~LLFastTimerView()
@@ -102,13 +117,12 @@ LLFastTimerView::~LLFastTimerView()
 
 void LLFastTimerView::onPause()
 {
-	LLTrace::TimeBlock::sPauseHistory = !LLTrace::TimeBlock::sPauseHistory;
+	mPauseHistory = !mPauseHistory;
 	// reset scroll to bottom when unpausing
-	if (!LLTrace::TimeBlock::sPauseHistory)
+	if (!mPauseHistory)
 	{
 		mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording());
 		mScrollIndex = 0;
-		LLTrace::TimeBlock::sResetHistory = true;
 		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
 	}
 	else
@@ -239,14 +253,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
-		mScrollIndex = llround( lerp * (F32)(LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+		mScrollIndex = llround( lerp * (F32)(HISTORY_NUM - MAX_VISIBLE_HISTORY));
 		mScrollIndex = llclamp(	mScrollIndex, 0, frame_recording.getNumPeriods());
 		return TRUE;
 	}
 	mHoverTimer = NULL;
 	mHoverID = NULL;
 
-	if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(mPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1, 
 								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
@@ -322,7 +336,7 @@ static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLT
 
 BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 {
-	if(LLTrace::TimeBlock::sPauseHistory && mBarRect.pointInRect(x, y))
+	if(mPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		// tooltips for timer bars
 		if (mHoverTimer)
@@ -362,10 +376,10 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
 	LLTrace::PeriodicRecording& frame_recording = *mRecording;
 
-	LLTrace::TimeBlock::sPauseHistory = TRUE;
+	mPauseHistory = true;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(frame_recording.getNumPeriods(), (S32)LLTrace::TimeBlock::HISTORY_NUM - MAX_VISIBLE_HISTORY));
+							llmin(frame_recording.getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
@@ -448,9 +462,9 @@ void LLFastTimerView::draw()
 			const F32 HUE_INCREMENT = 0.23f;
 			hue = fmodf(hue + HUE_INCREMENT, 1.f);
 			// saturation increases with depth
-			F32 saturation = clamp_rescale((F32)idp->getDepth(), 0.f, 3.f, 0.f, 1.f);
+			F32 saturation = clamp_rescale((F32)get_depth(idp), 0.f, 3.f, 0.f, 1.f);
 			// lightness alternates with depth
-			F32 lightness = idp->getDepth() % 2 ? 0.5f : 0.6f;
+			F32 lightness = get_depth(idp) % 2 ? 0.5f : 0.6f;
 
 			LLColor4 child_color;
 			child_color.setHSL(hue, saturation, lightness);
@@ -509,15 +523,15 @@ void LLFastTimerView::draw()
 			{
 				tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value());
 			}
-			dx = (texth+4) + idp->getDepth()*8;
+			dx = (texth+4) + get_depth(idp)*8;
 
 			LLColor4 color = LLColor4::white;
-			if (idp->getDepth() > 0)
+			if (get_depth(idp) > 0)
 			{
 				S32 line_start_y = (top + bottom) / 2;
 				S32 line_end_y = line_start_y + ((texth + 2) * (cur_line - display_line[idp->getParent()])) - texth;
 				gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color);
-				S32 line_x = x + (texth + 4) + ((idp->getDepth() - 1) * 8);
+				S32 line_x = x + (texth + 4) + ((get_depth(idp) - 1) * 8);
 				gl_line_2d(line_x, line_start_y, line_x, line_end_y, color);
 				if (idp->getCollapsed() && !idp->getChildren().empty())
 				{
@@ -696,7 +710,7 @@ void LLFastTimerView::draw()
 				S32 prev_delta_x = deltax.empty() ? 0 : deltax.back();
 				deltax.push_back(dx);
 				
-				int level = idp->getDepth() - 1;
+				int level = get_depth(idp) - 1;
 				
 				while ((S32)xpos.size() > level + 1)
 				{
@@ -710,7 +724,7 @@ void LLFastTimerView::draw()
 					sublevel_dx[level] = dx;
 					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
 				}
-				else if (prev_id && prev_id->getDepth() < idp->getDepth())
+				else if (prev_id && prev_id->getDepth() < get_depth(idp))
 				{
 					U64 sublevelticks = 0;
 
@@ -821,10 +835,10 @@ void LLFastTimerView::draw()
 
 		//highlight visible range
 		{
-			S32 first_frame = LLTrace::TimeBlock::HISTORY_NUM - mScrollIndex;
+			S32 first_frame = HISTORY_NUM - mScrollIndex;
 			S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 				
-			F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(LLTrace::TimeBlock::HISTORY_NUM-1);
+			F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1);
 				
 			F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
 			F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
@@ -889,7 +903,7 @@ void LLFastTimerView::draw()
 					cur_max = llmax(cur_max, time);
 					cur_max_calls = llmax(cur_max_calls, calls);
 				}
-				F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(LLTrace::TimeBlock::HISTORY_NUM-1);
+				F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1);
 				F32 y = mDisplayHz 
 					? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
 					: mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight();
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 6474c2f524..07662bb795 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -95,6 +95,7 @@ private:
 	S32                           mPrintStats;
 	LLRect                        mGraphRect;
 	LLTrace::PeriodicRecording*	  mRecording;
+	bool						  mPauseHistory;
 };
 
 #endif
-- 
cgit v1.2.3


From 4e22f3e3ef15e24d7e9e0ad156e60d4cd1b2d5c9 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 18 Dec 2012 23:16:50 -0700
Subject: fix for SH-3624: Object deletion does not work

---
 indra/newview/lldrawable.cpp         |  5 -----
 indra/newview/llviewerobject.cpp     | 16 ++++++++++++++++
 indra/newview/llviewerobject.h       |  1 +
 indra/newview/llviewerobjectlist.cpp |  3 ++-
 indra/newview/llviewerobjectlist.h   |  2 +-
 indra/newview/llviewerregion.cpp     |  6 +++++-
 indra/newview/llvocache.cpp          | 22 ----------------------
 indra/newview/llvocache.h            | 18 ++++++++----------
 8 files changed, 33 insertions(+), 40 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 1b7a98ba54..3c68ac231e 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1099,11 +1099,6 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat
 	{
 		part->put(this);
 	}
-
-	if(mDrawable->getEntry()->hasVOCacheEntry())
-	{
-		((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry())->setBridgeChild();
-	}
 }
 
 LLSpatialBridge::~LLSpatialBridge()
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index dbccb2a4d9..2aa0e15fc3 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -323,6 +323,22 @@ void LLViewerObject::deleteTEImages()
 	mTEImages = NULL;
 }
 
+//if enabled, add this object to vo cache tree when removed from rendering.
+void LLViewerObject::EnableToCacheTree(bool enabled)
+{
+	if(mDrawable.notNull() && mDrawable->getEntry() && mDrawable->getEntry()->hasVOCacheEntry())
+	{
+		if(enabled)
+		{
+			((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry())->addState(LLVOCacheEntry::ADD_TO_CACHE_TREE);
+		}
+		else
+		{
+			((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry())->clearState(LLVOCacheEntry::ADD_TO_CACHE_TREE);
+		}
+	}
+}
+
 void LLViewerObject::markDead()
 {
 	if (!mDead)
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 02b4f84785..74b86600d4 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -132,6 +132,7 @@ public:
 	BOOL isDead() const									{return mDead;}
 	BOOL isOrphaned() const								{ return mOrphaned; }
 	BOOL isParticleSource() const;
+	void EnableToCacheTree(bool enabled);
 
 	virtual LLVOAvatar* asAvatar();
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 5b2214f3b3..6e7ce103b5 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1326,7 +1326,7 @@ void LLViewerObjectList::removeDrawable(LLDrawable* drawablep)
 	}
 }
 
-BOOL LLViewerObjectList::killObject(LLViewerObject *objectp)
+BOOL LLViewerObjectList::killObject(LLViewerObject *objectp, bool cache_enabled)
 {
 	// Don't ever kill gAgentAvatarp, just force it to the agent's region
 	// unless region is NULL which is assumed to mean you are logging out.
@@ -1341,6 +1341,7 @@ BOOL LLViewerObjectList::killObject(LLViewerObject *objectp)
 
 	if (objectp)
 	{
+		objectp->EnableToCacheTree(cache_enabled); //enable to add to VO cache tree if set.
 		objectp->markDead(); // does the right thing if object already dead
 		return TRUE;
 	}
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 3b26df7de6..0e2b34cb34 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -72,7 +72,7 @@ public:
 
 	LLViewerObject *replaceObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); // TomY: hack to switch VO instances on the fly
 	
-	BOOL killObject(LLViewerObject *objectp);
+	BOOL killObject(LLViewerObject *objectp, bool cache_enabled = false);
 	void killObjects(LLViewerRegion *regionp); // Kill all objects owned by a particular region.
 	void killAllObjects();
 	void removeDrawable(LLDrawable* drawablep);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 33e8348660..c4b6cacae2 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -894,6 +894,10 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
+	if(!entry->hasState(LLVOCacheEntry::ADD_TO_CACHE_TREE))
+	{
+		return; //can not add to vo cache tree.
+	}
 
 	mImpl->mVOCachePartition->addEntry(entry->getEntry());
 }
@@ -1132,7 +1136,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 	}
 	for(S32 i = 0; i < delete_list.size(); i++)
 	{
-		gObjectList.killObject(delete_list[i]->getVObj());
+		gObjectList.killObject(delete_list[i]->getVObj(), true);
 	}
 	delete_list.clear();
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 59645fdbe9..86cfbb1d74 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -64,18 +64,6 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mBuffer = new U8[dp.getBufferSize()];
 	mDP.assignBuffer(mBuffer, dp.getBufferSize());
 	mDP = dp;
-
-	if(dp.getBufferSize() > 0)
-	{
-		U32 parent_id = 0;
-		dp.reset();
-		dp.unpackU32(parent_id, "ParentID");
-		dp.reset();
-		if(parent_id > 0)
-		{
-			mState |= CHILD; //is a child
-		}
-	}
 }
 
 LLVOCacheEntry::LLVOCacheEntry()
@@ -224,16 +212,6 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
 	LLViewerOctreeEntryData::setOctreeEntry(entry);
 }
 
-void LLVOCacheEntry::setBridgeChild()
-{
-	mState |= BRIDGE_CHILD;
-}
-	
-void LLVOCacheEntry::clearBridgeChild()
-{
-	mState &= ~BRIDGE_CHILD;
-}
-
 void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry)
 {
 	//copy LLViewerOctreeEntry
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index f5cc5d2f75..c631e12739 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -51,8 +51,7 @@ public:
 
 	enum
 	{
-		CHILD        = 0x00010000, //has parent
-		BRIDGE_CHILD = 0x00020000  //is a child of a spatial bridge.
+		ADD_TO_CACHE_TREE = 0x00010000, //has parent
 	};
 
 	struct CompareVOCacheEntry
@@ -85,14 +84,13 @@ public:
 	LLVOCacheEntry();	
 
 	void setState(U32 state);
-	bool isState(U32 state)   {return (mState & 0xffff) == state;}
-	U32  getState() const     {return (mState & 0xffff);}
-	U32  getFullState() const {return mState;}
-
-	void setBridgeChild();  
-	void clearBridgeChild(); 
-	bool isBridgeChild()     {return mState & BRIDGE_CHILD;}
-
+	void clearState(U32 state) {mState &= ~state;}
+	void addState(U32 state)   {mState |= state;}
+	bool isState(U32 state)    {return (mState & 0xffff) == state;}
+	bool hasState(U32 state)   {return mState & state;}
+	U32  getState() const      {return (mState & 0xffff);}
+	U32  getFullState() const  {return mState;}
+	
 	U32 getLocalID() const			{ return mLocalID; }
 	U32 getCRC() const				{ return mCRC; }
 	S32 getHitCount() const			{ return mHitCount; }
-- 
cgit v1.2.3


From 1fbd45672fcb1e5bfc194712fc7d0d4847a651cd Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 19 Dec 2012 23:21:31 -0700
Subject: fix for SH-3640: Can not edit objects

---
 indra/newview/llscenemonitor.cpp  | 6 ++++++
 indra/newview/llscenemonitor.h    | 1 +
 indra/newview/llviewerdisplay.cpp | 2 ++
 3 files changed, 9 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 43f9e9208b..4872200f24 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -211,6 +211,7 @@ void LLSceneMonitor::unfreezeScene()
 void LLSceneMonitor::capture()
 {
 	static U32 last_capture_time = 0;
+
 	if(last_capture_time == gFrameCount)
 	{
 		return;
@@ -239,6 +240,11 @@ void LLSceneMonitor::capture()
 	mNeedsUpdateDiff = TRUE;
 }
 
+bool LLSceneMonitor::needsUpdate() const
+{
+	return mNeedsUpdateDiff;
+}
+
 void LLSceneMonitor::compare()
 {
 	if(!mNeedsUpdateDiff)
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index ce25467a21..02e3d57d46 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -59,6 +59,7 @@ public:
 	F32  getSamplingTime() const { return mSamplingTime;}
 	F32  getDiffPixelRatio() const { return mDiffPixelRatio;}
 	bool isEnabled()const {return mEnabled;}
+	bool needsUpdate() const;
 	
 private:
 	void freezeScene();
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 270ab26149..31b2220fc8 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1228,10 +1228,12 @@ void render_ui(F32 zoom_factor, int subfield)
 		glh_set_current_modelview(glh_copy_matrix(gGLLastModelView));
 	}
 	
+	if(LLSceneMonitor::getInstance()->needsUpdate())
 	{
 		gGL.pushMatrix();
 		gViewerWindow->setup2DRender();
 		LLSceneMonitor::getInstance()->compare();
+		gViewerWindow->setup3DRender();
 		gGL.popMatrix();
 	}
 
-- 
cgit v1.2.3


From 013f04cabec8e110ee659d9b3f75a4d25f114b7b Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 21 Dec 2012 00:13:21 -0800
Subject: SH-3468 WIP add memory tracking base class improvements on lifetime
 of lltrace core data structures tweaks to thread local pointer handling so
 that static constructors/destructors can safely call functions that use
 lltrace

---
 indra/newview/llfasttimerview.cpp | 78 ++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 38 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 2cf7939e5c..56e5710726 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -54,23 +54,25 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
+using namespace LLTrace;
+
 static const S32 MAX_VISIBLE_HISTORY = 10;
 static const S32 LINE_GRAPH_HEIGHT = 240;
 
 const S32 FTV_MAX_DEPTH = 8;
 const S32 HISTORY_NUM = 300;
 
-std::vector<LLTrace::TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
+std::vector<TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
-typedef LLTreeDFSIter<LLTrace::TimeBlock, LLTrace::TimeBlock::child_const_iter> timer_tree_iterator_t;
+typedef LLTreeDFSIter<TimeBlock, TimeBlock::child_const_iter> timer_tree_iterator_t;
 
 BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
 
-static timer_tree_iterator_t begin_timer_tree(LLTrace::TimeBlock& id) 
+static timer_tree_iterator_t begin_timer_tree(TimeBlock& id) 
 { 
 	return timer_tree_iterator_t(&id, 
-							boost::bind(boost::mem_fn(&LLTrace::TimeBlock::beginChildren), _1), 
-							boost::bind(boost::mem_fn(&LLTrace::TimeBlock::endChildren), _1));
+							boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), 
+							boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1));
 }
 
 static timer_tree_iterator_t end_timer_tree() 
@@ -81,12 +83,12 @@ static timer_tree_iterator_t end_timer_tree()
 S32 get_depth(const TimeBlock* blockp)
 {
 	S32 depth = 0;
-	TimeBlock* timerp = blockp->mParent;
+	TimeBlock* timerp = blockp->getParent();
 	while(timerp)
 	{
 		depth++;
 		if (timerp->getParent() == timerp) break;
-		timerp = timerp->mParent;
+		timerp = timerp->getParent();
 	}
 	return depth;
 }
@@ -102,13 +104,13 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mHoverID(NULL),
 	mHoverBarIndex(-1),
 	mPrintStats(-1),
-	mRecording(&LLTrace::get_frame_recording()),
+	mRecording(&get_frame_recording()),
 	mPauseHistory(false)
 {}
 
 LLFastTimerView::~LLFastTimerView()
 {
-	if (mRecording != &LLTrace::get_frame_recording())
+	if (mRecording != &get_frame_recording())
 	{
 		delete mRecording;
 	}
@@ -121,17 +123,17 @@ void LLFastTimerView::onPause()
 	// reset scroll to bottom when unpausing
 	if (!mPauseHistory)
 	{
-		mRecording = new LLTrace::PeriodicRecording(LLTrace::get_frame_recording());
+		mRecording = new PeriodicRecording(get_frame_recording());
 		mScrollIndex = 0;
 		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
 	}
 	else
 	{
-		if (mRecording != &LLTrace::get_frame_recording())
+		if (mRecording != &get_frame_recording())
 		{
 			delete mRecording;
 		}
-		mRecording = &LLTrace::get_frame_recording();
+		mRecording = &get_frame_recording();
 
 		getChild<LLButton>("pause_btn")->setLabel(getString("run"));
 	}
@@ -170,7 +172,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	return LLFloater::handleRightMouseDown(x, y, mask);
 }
 
-LLTrace::TimeBlock* LLFastTimerView::getLegendID(S32 y)
+TimeBlock* LLFastTimerView::getLegendID(S32 y)
 {
 	S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5;
 
@@ -197,7 +199,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (x < mBarRect.mLeft) 
 	{
-		LLTrace::TimeBlock* idp = getLegendID(y);
+		TimeBlock* idp = getLegendID(y);
 		if (idp)
 		{
 			idp->setCollapsed(!idp->getCollapsed());
@@ -248,7 +250,7 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 {
-	LLTrace::PeriodicRecording& frame_recording = *mRecording;
+	PeriodicRecording& frame_recording = *mRecording;
 
 	if (hasMouseCapture())
 	{
@@ -306,7 +308,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	}
 	else if (x < mBarRect.mLeft) 
 	{
-		LLTrace::TimeBlock* timer_id = getLegendID(y);
+		TimeBlock* timer_id = getLegendID(y);
 		if (timer_id)
 		{
 			mHoverID = timer_id;
@@ -317,9 +319,9 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 }
 
 
-static std::string get_tooltip(LLTrace::TimeBlock& timer, S32 history_index, LLTrace::PeriodicRecording& frame_recording)
+static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicRecording& frame_recording)
 {
-	F64 ms_multiplier = 1000.0 / (F64)LLTrace::TimeBlock::countsPerSecond();
+	F64 ms_multiplier = 1000.0 / (F64)TimeBlock::countsPerSecond();
 
 	std::string tooltip;
 	if (history_index < 0)
@@ -359,7 +361,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 		// tooltips for timer legend
 		if (x < mBarRect.mLeft) 
 		{
-			LLTrace::TimeBlock* idp = getLegendID(y);
+			TimeBlock* idp = getLegendID(y);
 			if (idp)
 			{
 				LLToolTipMgr::instance().show(get_tooltip(*idp, -1,  *mRecording));
@@ -374,7 +376,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	LLTrace::PeriodicRecording& frame_recording = *mRecording;
+	PeriodicRecording& frame_recording = *mRecording;
 
 	mPauseHistory = true;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
@@ -383,15 +385,15 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	return TRUE;
 }
 
-static LLTrace::TimeBlock FTM_RENDER_TIMER("Timers", true);
+static TimeBlock FTM_RENDER_TIMER("Timers", true);
 
-static std::map<LLTrace::TimeBlock*, LLColor4> sTimerColors;
+static std::map<TimeBlock*, LLColor4> sTimerColors;
 
 void LLFastTimerView::draw()
 {
 	LLFastTimer t(FTM_RENDER_TIMER);
 
-	LLTrace::PeriodicRecording& frame_recording = *mRecording;
+	PeriodicRecording& frame_recording = *mRecording;
 
 	std::string tdesc;
 
@@ -457,7 +459,7 @@ void LLFastTimerView::draw()
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			LLTrace::TimeBlock* idp = (*it);
+			TimeBlock* idp = (*it);
 
 			const F32 HUE_INCREMENT = 0.23f;
 			hue = fmodf(hue + HUE_INCREMENT, 1.f);
@@ -480,12 +482,12 @@ void LLFastTimerView::draw()
 		LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
 		S32 cur_line = 0;
 		ft_display_idx.clear();
-		std::map<LLTrace::TimeBlock*, S32> display_line;
+		std::map<TimeBlock*, S32> display_line;
 		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			LLTrace::TimeBlock* idp = (*it);
+			TimeBlock* idp = (*it);
 			display_line[idp] = cur_line;
 			ft_display_idx.push_back(idp);
 			cur_line++;
@@ -541,7 +543,7 @@ void LLFastTimerView::draw()
 
 			x += dx;
 			BOOL is_child_of_hover_item = (idp == mHoverID);
-			LLTrace::TimeBlock* next_parent = idp->getParent();
+			TimeBlock* next_parent = idp->getParent();
 			while(!is_child_of_hover_item && next_parent)
 			{
 				is_child_of_hover_item = (mHoverID == next_parent);
@@ -694,14 +696,14 @@ void LLFastTimerView::draw()
 			std::vector<S32> deltax;
 			xpos.push_back(x_start);
 			
-			LLTrace::TimeBlock* prev_id = NULL;
+			TimeBlock* prev_id = NULL;
 
 			S32 i = 0;
 			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
 				it != end_timer_tree();
 				++it, ++i)
 			{
-				LLTrace::TimeBlock* idp = (*it);
+				TimeBlock* idp = (*it);
 				F32 frac = tidx == -1
 					? (frame_recording.getPeriodMean(*idp) / total_time) 
 					: (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value());
@@ -724,11 +726,11 @@ void LLFastTimerView::draw()
 					sublevel_dx[level] = dx;
 					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
 				}
-				else if (prev_id && prev_id->getDepth() < get_depth(idp))
+				else if (prev_id && get_depth(prev_id) < get_depth(idp))
 				{
 					U64 sublevelticks = 0;
 
-					for (LLTrace::TimeBlock::child_const_iter it = prev_id->beginChildren();
+					for (TimeBlock::child_const_iter it = prev_id->beginChildren();
 						it != prev_id->endChildren();
 						++it)
 					{
@@ -770,7 +772,7 @@ void LLFastTimerView::draw()
 					S32 scale_offset = 0;
 
 					BOOL is_child_of_hover_item = (idp == mHoverID);
-					LLTrace::TimeBlock* next_parent = idp->getParent();
+					TimeBlock* next_parent = idp->getParent();
 					while(!is_child_of_hover_item && next_parent)
 					{
 						is_child_of_hover_item = (mHoverID == next_parent);
@@ -866,7 +868,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLTrace::TimeBlock* idp = (*it);
+			TimeBlock* idp = (*it);
 				
 			//fatten highlighted timer
 			if (mHoverID == idp)
@@ -968,7 +970,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLTrace::TimeBlock* idp = (*it);
+			TimeBlock* idp = (*it);
 
 			if (!first)
 			{
@@ -990,7 +992,7 @@ void LLFastTimerView::draw()
 			it != end_timer_tree();
 			++it)
 		{
-			LLTrace::TimeBlock* idp = (*it);
+			TimeBlock* idp = (*it);
 
 			if (!first)
 			{
@@ -1527,13 +1529,13 @@ void LLFastTimerView::outputAllMetrics()
 //static
 void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
 {
-	if(LLTrace::TimeBlock::sLog)
+	if(TimeBlock::sLog)
 	{
 		doAnalysisDefault(baseline, target, output) ;
 		return ;
 	}
 
-	if(LLTrace::TimeBlock::sMetricLog)
+	if(TimeBlock::sMetricLog)
 	{
 		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
 		return ;
@@ -1544,7 +1546,7 @@ void	LLFastTimerView::onClickCloseBtn()
 	setVisible(false);
 }
 
-LLTrace::TimeBlock& LLFastTimerView::getFrameTimer()
+TimeBlock& LLFastTimerView::getFrameTimer()
 {
 	return FTM_FRAME;
 }
-- 
cgit v1.2.3


From 019836a39667889d4347277cde82270113992bb6 Mon Sep 17 00:00:00 2001
From: Andrew Meadows <andrew@lindenlab.com>
Date: Fri, 4 Jan 2013 03:02:54 +0000
Subject: More fixes for linux build of lltrace changes

---
 indra/newview/llworldmapmessage.h | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llworldmapmessage.h b/indra/newview/llworldmapmessage.h
index 12b6ef4792..ac1ea1607c 100644
--- a/indra/newview/llworldmapmessage.h
+++ b/indra/newview/llworldmapmessage.h
@@ -27,6 +27,8 @@
 #ifndef LL_LLWORLDMAPMESSAGE_H
 #define LL_LLWORLDMAPMESSAGE_H
 
+#include "boost/function.hpp"
+
 // Handling of messages (send and process) as well as SLURL callback if necessary
 class LLMessageSystem;
 
-- 
cgit v1.2.3


From cbff0e7ab8afeebb6ddab854d35ea12ef9a9930a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 4 Jan 2013 13:48:35 -0800
Subject: SH-3468 WIP add memory tracking base class attempted fix for gcc
 compile errors can't use typeid() on a class that doesn't have a method
 defined in a translation unit fix is to force classes deriving from
 LLMemTrackable to use their own static member named sMemStat

---
 indra/newview/lldrawable.cpp     | 1 +
 indra/newview/lldrawable.h       | 1 +
 indra/newview/llviewerobject.cpp | 3 +++
 indra/newview/llviewerobject.h   | 4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 09bbafd54a..6ef437cefb 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -58,6 +58,7 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
+LLTrace::MemStat	LLDrawable::sMemStat("LLDrawable");
 
 
 ////////////////////////
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index f15090fb87..abfdea2699 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -314,6 +314,7 @@ public:
 	LLSpatialBridge* getSpatialBridge() { return (LLSpatialBridge*) (LLDrawable*) mSpatialBridge; }
 	
 	static F32 sCurPixelAngle; //current pixels per radian
+	static LLTrace::MemStat sMemStat;
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index fff1875ad6..ee8bb50e4e 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -112,6 +112,9 @@ BOOL		LLViewerObject::sMapDebug = TRUE;
 LLColor4	LLViewerObject::sEditSelectColor(	1.0f, 1.f, 0.f, 0.3f);	// Edit OK
 LLColor4	LLViewerObject::sNoEditSelectColor(	1.0f, 0.f, 0.f, 0.3f);	// Can't edit
 S32			LLViewerObject::sAxisArrowLength(50);
+LLTrace::MemStat	LLViewerObject::sMemStat("LLViewerObject");
+
+
 BOOL		LLViewerObject::sPulseEnabled(FALSE);
 BOOL		LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
 
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 14ea8ded38..153f44601c 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -670,8 +670,6 @@ protected:
 	void deleteParticleSource();
 	void setParticleSource(const LLPartSysData& particle_parameters, const LLUUID& owner_id);
 	
-public:
-		
 private:
 	void setNameValueList(const std::string& list);		// clears nv pairs and then individually adds \n separated NV pairs from \0 terminated string
 	void deleteTEImages(); // correctly deletes list of images
@@ -750,6 +748,8 @@ protected:
 
 	static			S32			sAxisArrowLength;
 
+	static			LLTrace::MemStat sMemStat;
+
 	// These two caches are only correct for non-parented objects right now!
 	mutable LLVector3		mPositionRegion;
 	mutable LLVector3		mPositionAgent;
-- 
cgit v1.2.3


From 4ebd4b3616d9d69e9b6deb73aa1f1e16f5673225 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 4 Jan 2013 14:09:02 -0800
Subject: SH-3468 WIP add memory tracking base class further compile error
 fixes

---
 indra/newview/llviewerobject.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 153f44601c..bdff88f8ca 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -634,7 +634,8 @@ public:
 	LLPointer<LLHUDText> mText;
 	LLPointer<LLHUDIcon> mIcon;
 
-	static			BOOL		sUseSharedDrawables;
+	static	BOOL				sUseSharedDrawables;
+	static	LLTrace::MemStat	sMemStat;
 
 protected:
 	// delete an item in the inventory, but don't tell the
@@ -748,7 +749,6 @@ protected:
 
 	static			S32			sAxisArrowLength;
 
-	static			LLTrace::MemStat sMemStat;
 
 	// These two caches are only correct for non-parented objects right now!
 	mutable LLVector3		mPositionRegion;
-- 
cgit v1.2.3


From 222941d83c9a8e9fc1a488f0092f233b71a63db3 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 4 Jan 2013 20:40:21 -0800
Subject: SH-3468 WIP add memory tracking base class further compile error
 fixes

---
 indra/newview/llviewerstats.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 14ee41dba0..6b95c9359d 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -38,7 +38,7 @@ namespace LLStatViewer
 struct SimMeasurementSampler : public LLInstanceTracker<SimMeasurementSampler, ESimStatID>
 {
 	SimMeasurementSampler(ESimStatID id)
-	:	LLInstanceTracker(id)
+	:	LLInstanceTracker<SimMeasurementSampler, ESimStatID>(id)
 	{}
 	virtual ~SimMeasurementSampler() {}
 	virtual void sample(F64 value) = 0;
-- 
cgit v1.2.3


From 386e918583fe25532f401c6b50c49632d7410d39 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 9 Jan 2013 11:21:45 -0800
Subject: SH-3468 WIP add memory tracking base class fix for linux build issues

---
 indra/newview/llviewerassetstats.cpp | 287 ++++++++++++++++++++---------------
 1 file changed, 161 insertions(+), 126 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 58936c3220..b4da9521f4 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -176,55 +176,90 @@ namespace LLViewerAssetStatsFF
 		}
 		return ret;
 	}
-	static LLTrace::Count<> sEnqueued[EVACCount] = {LLTrace::Count<>("enqueuedassetrequeststemptexturehttp", 
-		"Number of temporary texture asset http requests enqueued"),
-		LLTrace::Count<>("enqueuedassetrequeststemptextureudp", 
-		"Number of temporary texture asset udp requests enqueued"),
-		LLTrace::Count<>("enqueuedassetrequestsnontemptexturehttp", 
-		"Number of texture asset http requests enqueued"),
-		LLTrace::Count<>("enqueuedassetrequestsnontemptextureudp", 
-		"Number of texture asset udp requests enqueued"),
-		LLTrace::Count<>("enqueuedassetrequestswearableudp", 
-		"Number of wearable asset requests enqueued"),
-		LLTrace::Count<>("enqueuedassetrequestssoundudp", 
-		"Number of sound asset requests enqueued"),
-		LLTrace::Count<>("enqueuedassetrequestsgestureudp", 
-		"Number of gesture asset requests enqueued"),
-		LLTrace::Count<>("enqueuedassetrequestsother", 
-		"Number of other asset requests enqueued")};
-
-	static LLTrace::Count<> sDequeued[EVACCount] = {LLTrace::Count<>("dequeuedassetrequeststemptexturehttp", 
-		"Number of temporary texture asset http requests dequeued"),
-		LLTrace::Count<>("dequeuedassetrequeststemptextureudp", 
-		"Number of temporary texture asset udp requests dequeued"),
-		LLTrace::Count<>("dequeuedassetrequestsnontemptexturehttp", 
-		"Number of texture asset http requests dequeued"),
-		LLTrace::Count<>("dequeuedassetrequestsnontemptextureudp", 
-		"Number of texture asset udp requests dequeued"),
-		LLTrace::Count<>("dequeuedassetrequestswearableudp", 
-		"Number of wearable asset requests dequeued"),
-		LLTrace::Count<>("dequeuedassetrequestssoundudp", 
-		"Number of sound asset requests dequeued"),
-		LLTrace::Count<>("dequeuedassetrequestsgestureudp", 
-		"Number of gesture asset requests dequeued"),
-		LLTrace::Count<>("dequeuedassetrequestsother", 
-		"Number of other asset requests dequeued")};
-	static LLTrace::Measurement<LLTrace::Seconds> sResponse[EVACCount] = {LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptexturehttp", 
-		"Time spent responding to temporary texture asset http requests"),
-		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimestemptextureudp", 
-		"Time spent responding to temporary texture asset udp requests"),
-		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptexturehttp", 
-		"Time spent responding to texture asset http requests"),
-		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesnontemptextureudp", 
-		"Time spent responding to texture asset udp requests"),
-		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimeswearableudp", 
-		"Time spent responding to wearable asset requests"),
-		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimessoundudp", 
-		"Time spent responding to sound asset requests"),
-		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesgestureudp", 
-		"Time spent responding to gesture asset requests"),
-		LLTrace::Measurement<LLTrace::Seconds>("assetresponsetimesother", 
-		"Time spent responding to other asset requests")};
+
+	static LLTrace::Count<> sEnqueueAssetRequestsTempTextureHTTP   ("enqueuedassetrequeststemptexturehttp", 
+																	"Number of temporary texture asset http requests enqueued"),
+							sEnqueueAssetRequestsTempTextureUDP    ("enqueuedassetrequeststemptextureudp", 
+																	"Number of temporary texture asset udp requests enqueued"),
+							sEnqueueAssetRequestsNonTempTextureHTTP("enqueuedassetrequestsnontemptexturehttp", 
+																	"Number of texture asset http requests enqueued"),
+							sEnqueueAssetRequestsNonTempTextureUDP ("enqueuedassetrequestsnontemptextureudp", 
+																	"Number of texture asset udp requests enqueued"),
+							sEnqueuedAssetRequestsWearableUdp      ("enqueuedassetrequestswearableudp", 
+																	"Number of wearable asset requests enqueued"),
+							sEnqueuedAssetRequestsSoundUdp         ("enqueuedassetrequestssoundudp", 
+																	"Number of sound asset requests enqueued"),
+							sEnqueuedAssetRequestsGestureUdp       ("enqueuedassetrequestsgestureudp", 
+																	"Number of gesture asset requests enqueued"),
+							sEnqueuedAssetRequestsOther            ("enqueuedassetrequestsother", 
+																	"Number of other asset requests enqueued");
+
+	static LLTrace::Count<>* sEnqueued[EVACCount] = {		
+		&sEnqueueAssetRequestsTempTextureHTTP,   
+		&sEnqueueAssetRequestsTempTextureUDP,  
+		&sEnqueueAssetRequestsNonTempTextureHTTP,
+		&sEnqueueAssetRequestsNonTempTextureUDP,
+		&sEnqueuedAssetRequestsWearableUdp,
+		&sEnqueuedAssetRequestsSoundUdp,
+		&sEnqueuedAssetRequestsGestureUdp,
+		&sEnqueuedAssetRequestsOther            
+	};
+
+	static LLTrace::Count<> sDequeueAssetRequestsTempTextureHTTP   ("dequeuedassetrequeststemptexturehttp", 
+																	"Number of temporary texture asset http requests dequeued"),
+							sDequeueAssetRequestsTempTextureUDP    ("dequeuedassetrequeststemptextureudp", 
+																	"Number of temporary texture asset udp requests dequeued"),
+							sDequeueAssetRequestsNonTempTextureHTTP("dequeuedassetrequestsnontemptexturehttp", 
+																	"Number of texture asset http requests dequeued"),
+							sDequeueAssetRequestsNonTempTextureUDP ("dequeuedassetrequestsnontemptextureudp", 
+																	"Number of texture asset udp requests dequeued"),
+							sDequeuedAssetRequestsWearableUdp      ("dequeuedassetrequestswearableudp", 
+																	"Number of wearable asset requests dequeued"),
+							sDequeuedAssetRequestsSoundUdp         ("dequeuedassetrequestssoundudp", 
+																	"Number of sound asset requests dequeued"),
+							sDequeuedAssetRequestsGestureUdp       ("dequeuedassetrequestsgestureudp", 
+																	"Number of gesture asset requests dequeued"),
+							sDequeuedAssetRequestsOther            ("dequeuedassetrequestsother", 
+																	"Number of other asset requests dequeued");
+
+	static LLTrace::Count<>* sDequeued[EVACCount] = {
+		&sDequeueAssetRequestsTempTextureHTTP,   
+		&sDequeueAssetRequestsTempTextureUDP,  
+		&sDequeueAssetRequestsNonTempTextureHTTP,
+		&sDequeueAssetRequestsNonTempTextureUDP,
+		&sDequeuedAssetRequestsWearableUdp,
+		&sDequeuedAssetRequestsSoundUdp,
+		&sDequeuedAssetRequestsGestureUdp,
+		&sDequeuedAssetRequestsOther            
+	};
+
+	static LLTrace::Measurement<LLTrace::Seconds>	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp", 
+																							"Time spent responding to temporary texture asset http requests"),
+													sResponseAssetRequestsTempTextureUDP    ("assetresponsetimestemptextureudp", 
+																							"Time spent responding to temporary texture asset udp requests"),
+													sResponseAssetRequestsNonTempTextureHTTP("assetresponsetimesnontemptexturehttp", 
+																							"Time spent responding to texture asset http requests"),
+													sResponseAssetRequestsNonTempTextureUDP ("assetresponsetimesnontemptextureudp", 
+																							"Time spent responding to texture asset udp requests"),
+													sResponsedAssetRequestsWearableUdp      ("assetresponsetimeswearableudp", 
+																							"Time spent responding to wearable asset requests"),
+													sResponsedAssetRequestsSoundUdp         ("assetresponsetimessoundudp", 
+																							"Time spent responding to sound asset requests"),
+													sResponsedAssetRequestsGestureUdp       ("assetresponsetimesgestureudp", 
+																							"Time spent responding to gesture asset requests"),
+													sResponsedAssetRequestsOther            ("assetresponsetimesother", 
+																							"Time spent responding to other asset requests");
+
+	static LLTrace::Measurement<LLTrace::Seconds>* sResponse[EVACCount] = {
+		&sResponseAssetRequestsTempTextureHTTP,   
+		&sResponseAssetRequestsTempTextureUDP,  
+		&sResponseAssetRequestsNonTempTextureHTTP,
+		&sResponseAssetRequestsNonTempTextureUDP,
+		&sResponsedAssetRequestsWearableUdp,
+		&sResponsedAssetRequestsSoundUdp,
+		&sResponsedAssetRequestsGestureUdp,
+		&sResponsedAssetRequestsOther            
+	};
 }
 
 // ------------------------------------------------------
@@ -262,7 +297,7 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 		it->second.makeUnique();
 	}
 
-	LLStopWatchControlsMixin::initTo(src.getPlayState());
+	LLStopWatchControlsMixin<LLViewerAssetStats>::initTo(src.getPlayState());
 }
 
 void LLViewerAssetStats::handleStart()
@@ -349,108 +384,108 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 		RegionStats& r = stats.regions.add();
 		LLTrace::Recording& rec = it->second;
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACTextureTempHTTPGet]) 
-			|| rec.getSum(sDequeued[EVACTextureTempHTTPGet])
-			|| rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
+			|| rec.getSum(*sEnqueued[EVACTextureTempHTTPGet]) 
+			|| rec.getSum(*sDequeued[EVACTextureTempHTTPGet])
+			|| rec.getSum(*sResponse[EVACTextureTempHTTPGet]).value())
 		{
-			r.get_texture_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureTempHTTPGet]))
-									.dequeued(rec.getSum(sDequeued[EVACTextureTempHTTPGet]))
-									.resp_count(rec.getSum(sResponse[EVACTextureTempHTTPGet]).value())
-									.resp_min(rec.getMin(sResponse[EVACTextureTempHTTPGet]).value())
-									.resp_max(rec.getMax(sResponse[EVACTextureTempHTTPGet]).value())
-									.resp_mean(rec.getMean(sResponse[EVACTextureTempHTTPGet]).value());
+			r.get_texture_temp_http	.enqueued((S32)rec.getSum(*sEnqueued[EVACTextureTempHTTPGet]))
+									.dequeued((S32)rec.getSum(*sDequeued[EVACTextureTempHTTPGet]))
+									.resp_count((S32)rec.getSum(*sResponse[EVACTextureTempHTTPGet]).value())
+									.resp_min(rec.getMin(*sResponse[EVACTextureTempHTTPGet]).value())
+									.resp_max(rec.getMax(*sResponse[EVACTextureTempHTTPGet]).value())
+									.resp_mean(rec.getMean(*sResponse[EVACTextureTempHTTPGet]).value());
 		}
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACTextureTempUDPGet]) 
-			|| rec.getSum(sDequeued[EVACTextureTempUDPGet])
-			|| rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
+			|| rec.getSum(*sEnqueued[EVACTextureTempUDPGet]) 
+			|| rec.getSum(*sDequeued[EVACTextureTempUDPGet])
+			|| rec.getSum(*sResponse[EVACTextureTempUDPGet]).value())
 		{
-			r.get_texture_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureTempUDPGet]))
-									.dequeued(rec.getSum(sDequeued[EVACTextureTempUDPGet]))
-									.resp_count(rec.getSum(sResponse[EVACTextureTempUDPGet]).value())
-									.resp_min(rec.getMin(sResponse[EVACTextureTempUDPGet]).value())
-									.resp_max(rec.getMax(sResponse[EVACTextureTempUDPGet]).value())
-									.resp_mean(rec.getMean(sResponse[EVACTextureTempUDPGet]).value());
+			r.get_texture_temp_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACTextureTempUDPGet]))
+									.dequeued((S32)rec.getSum(*sDequeued[EVACTextureTempUDPGet]))
+									.resp_count((S32)rec.getSum(*sResponse[EVACTextureTempUDPGet]).value())
+									.resp_min(rec.getMin(*sResponse[EVACTextureTempUDPGet]).value())
+									.resp_max(rec.getMax(*sResponse[EVACTextureTempUDPGet]).value())
+									.resp_mean(rec.getMean(*sResponse[EVACTextureTempUDPGet]).value());
 		}
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]) 
-			|| rec.getSum(sDequeued[EVACTextureNonTempHTTPGet])
-			|| rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
+			|| rec.getSum(*sEnqueued[EVACTextureNonTempHTTPGet]) 
+			|| rec.getSum(*sDequeued[EVACTextureNonTempHTTPGet])
+			|| rec.getSum(*sResponse[EVACTextureNonTempHTTPGet]).value())
 		{
-			r.get_texture_non_temp_http	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempHTTPGet]))
-										.dequeued(rec.getSum(sDequeued[EVACTextureNonTempHTTPGet]))
-										.resp_count(rec.getSum(sResponse[EVACTextureNonTempHTTPGet]).value())
-										.resp_min(rec.getMin(sResponse[EVACTextureNonTempHTTPGet]).value())
-										.resp_max(rec.getMax(sResponse[EVACTextureNonTempHTTPGet]).value())
-										.resp_mean(rec.getMean(sResponse[EVACTextureNonTempHTTPGet]).value());
+			r.get_texture_non_temp_http	.enqueued((S32)rec.getSum(*sEnqueued[EVACTextureNonTempHTTPGet]))
+										.dequeued((S32)rec.getSum(*sDequeued[EVACTextureNonTempHTTPGet]))
+										.resp_count((S32)rec.getSum(*sResponse[EVACTextureNonTempHTTPGet]).value())
+										.resp_min(rec.getMin(*sResponse[EVACTextureNonTempHTTPGet]).value())
+										.resp_max(rec.getMax(*sResponse[EVACTextureNonTempHTTPGet]).value())
+										.resp_mean(rec.getMean(*sResponse[EVACTextureNonTempHTTPGet]).value());
 		}
 
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]) 
-			|| rec.getSum(sDequeued[EVACTextureNonTempUDPGet])
-			|| rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
+			|| rec.getSum(*sEnqueued[EVACTextureNonTempUDPGet]) 
+			|| rec.getSum(*sDequeued[EVACTextureNonTempUDPGet])
+			|| rec.getSum(*sResponse[EVACTextureNonTempUDPGet]).value())
 		{
-			r.get_texture_non_temp_udp	.enqueued(rec.getSum(sEnqueued[EVACTextureNonTempUDPGet]))
-										.dequeued(rec.getSum(sDequeued[EVACTextureNonTempUDPGet]))
-										.resp_count(rec.getSum(sResponse[EVACTextureNonTempUDPGet]).value())
-										.resp_min(rec.getMin(sResponse[EVACTextureNonTempUDPGet]).value())
-										.resp_max(rec.getMax(sResponse[EVACTextureNonTempUDPGet]).value())
-										.resp_mean(rec.getMean(sResponse[EVACTextureNonTempUDPGet]).value());
+			r.get_texture_non_temp_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACTextureNonTempUDPGet]))
+										.dequeued((S32)rec.getSum(*sDequeued[EVACTextureNonTempUDPGet]))
+										.resp_count((S32)rec.getSum(*sResponse[EVACTextureNonTempUDPGet]).value())
+										.resp_min(rec.getMin(*sResponse[EVACTextureNonTempUDPGet]).value())
+										.resp_max(rec.getMax(*sResponse[EVACTextureNonTempUDPGet]).value())
+										.resp_mean(rec.getMean(*sResponse[EVACTextureNonTempUDPGet]).value());
 		}
 
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACWearableUDPGet]) 
-			|| rec.getSum(sDequeued[EVACWearableUDPGet])
-			|| rec.getSum(sResponse[EVACWearableUDPGet]).value())
+			|| rec.getSum(*sEnqueued[EVACWearableUDPGet]) 
+			|| rec.getSum(*sDequeued[EVACWearableUDPGet])
+			|| rec.getSum(*sResponse[EVACWearableUDPGet]).value())
 		{
-			r.get_wearable_udp	.enqueued(rec.getSum(sEnqueued[EVACWearableUDPGet]))
-								.dequeued(rec.getSum(sDequeued[EVACWearableUDPGet]))
-								.resp_count(rec.getSum(sResponse[EVACWearableUDPGet]).value())
-								.resp_min(rec.getMin(sResponse[EVACWearableUDPGet]).value())
-								.resp_max(rec.getMax(sResponse[EVACWearableUDPGet]).value())
-								.resp_mean(rec.getMean(sResponse[EVACWearableUDPGet]).value());
+			r.get_wearable_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACWearableUDPGet]))
+								.dequeued((S32)rec.getSum(*sDequeued[EVACWearableUDPGet]))
+								.resp_count((S32)rec.getSum(*sResponse[EVACWearableUDPGet]).value())
+								.resp_min(rec.getMin(*sResponse[EVACWearableUDPGet]).value())
+								.resp_max(rec.getMax(*sResponse[EVACWearableUDPGet]).value())
+								.resp_mean(rec.getMean(*sResponse[EVACWearableUDPGet]).value());
 		}
 
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACSoundUDPGet]) 
-			|| rec.getSum(sDequeued[EVACSoundUDPGet])
-			|| rec.getSum(sResponse[EVACSoundUDPGet]).value())
+			|| rec.getSum(*sEnqueued[EVACSoundUDPGet]) 
+			|| rec.getSum(*sDequeued[EVACSoundUDPGet])
+			|| rec.getSum(*sResponse[EVACSoundUDPGet]).value())
 		{
-			r.get_sound_udp	.enqueued(rec.getSum(sEnqueued[EVACSoundUDPGet]))
-							.dequeued(rec.getSum(sDequeued[EVACSoundUDPGet]))
-							.resp_count(rec.getSum(sResponse[EVACSoundUDPGet]).value())
-							.resp_min(rec.getMin(sResponse[EVACSoundUDPGet]).value())
-							.resp_max(rec.getMax(sResponse[EVACSoundUDPGet]).value())
-							.resp_mean(rec.getMean(sResponse[EVACSoundUDPGet]).value());
+			r.get_sound_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACSoundUDPGet]))
+							.dequeued((S32)rec.getSum(*sDequeued[EVACSoundUDPGet]))
+							.resp_count((S32)rec.getSum(*sResponse[EVACSoundUDPGet]).value())
+							.resp_min(rec.getMin(*sResponse[EVACSoundUDPGet]).value())
+							.resp_max(rec.getMax(*sResponse[EVACSoundUDPGet]).value())
+							.resp_mean(rec.getMean(*sResponse[EVACSoundUDPGet]).value());
 		}
 
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACGestureUDPGet]) 
-			|| rec.getSum(sDequeued[EVACGestureUDPGet])
-			|| rec.getSum(sResponse[EVACGestureUDPGet]).value())
+			|| rec.getSum(*sEnqueued[EVACGestureUDPGet]) 
+			|| rec.getSum(*sDequeued[EVACGestureUDPGet])
+			|| rec.getSum(*sResponse[EVACGestureUDPGet]).value())
 		{
-			r.get_gesture_udp	.enqueued(rec.getSum(sEnqueued[EVACGestureUDPGet]))
-								.dequeued(rec.getSum(sDequeued[EVACGestureUDPGet]))
-								.resp_count(rec.getSum(sResponse[EVACGestureUDPGet]).value())
-								.resp_min(rec.getMin(sResponse[EVACGestureUDPGet]).value())
-								.resp_max(rec.getMax(sResponse[EVACGestureUDPGet]).value())
-								.resp_mean(rec.getMean(sResponse[EVACGestureUDPGet]).value());
+			r.get_gesture_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACGestureUDPGet]))
+								.dequeued((S32)rec.getSum(*sDequeued[EVACGestureUDPGet]))
+								.resp_count((S32)rec.getSum(*sResponse[EVACGestureUDPGet]).value())
+								.resp_min(rec.getMin(*sResponse[EVACGestureUDPGet]).value())
+								.resp_max(rec.getMax(*sResponse[EVACGestureUDPGet]).value())
+								.resp_mean(rec.getMean(*sResponse[EVACGestureUDPGet]).value());
 		}
 
 		if (!compact_output
-			|| rec.getSum(sEnqueued[EVACOtherGet]) 
-			|| rec.getSum(sDequeued[EVACOtherGet])
-			|| rec.getSum(sResponse[EVACOtherGet]).value())
+			|| rec.getSum(*sEnqueued[EVACOtherGet]) 
+			|| rec.getSum(*sDequeued[EVACOtherGet])
+			|| rec.getSum(*sResponse[EVACOtherGet]).value())
 		{
-			r.get_other	.enqueued(rec.getSum(sEnqueued[EVACOtherGet]))
-						.dequeued(rec.getSum(sDequeued[EVACOtherGet]))
-						.resp_count(rec.getSum(sResponse[EVACOtherGet]).value())
-						.resp_min(rec.getMin(sResponse[EVACOtherGet]).value())
-						.resp_max(rec.getMax(sResponse[EVACOtherGet]).value())
-						.resp_mean(rec.getMean(sResponse[EVACOtherGet]).value());
+			r.get_other	.enqueued((S32)rec.getSum(*sEnqueued[EVACOtherGet]))
+						.dequeued((S32)rec.getSum(*sDequeued[EVACOtherGet]))
+						.resp_count((S32)rec.getSum(*sResponse[EVACOtherGet]).value())
+						.resp_min(rec.getMin(*sResponse[EVACOtherGet]).value())
+						.resp_max(rec.getMax(*sResponse[EVACOtherGet]).value())
+						.resp_mean(rec.getMean(*sResponse[EVACOtherGet]).value());
 		}
 
-		S32 fps = rec.getSum(LLStatViewer::FPS_SAMPLE);
+		S32 fps = (S32)rec.getSum(LLStatViewer::FPS_SAMPLE);
 		if (!compact_output || fps != 0)
 		{
 			r.fps.count(fps);
@@ -512,21 +547,21 @@ void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sEnqueued[int(eac)].add(1);
+	sEnqueued[int(eac)]->add(1);
 }
 
 void record_dequeue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sDequeued[int(eac)].add(1);
+	sDequeued[int(eac)]->add(1);
 }
 
 void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sResponse[int(eac)].sample<LLTrace::Microseconds>(duration);
+	sResponse[int(eac)]->sample<LLTrace::Microseconds>(duration);
 }
 
 void record_avatar_stats()
-- 
cgit v1.2.3


From 8b836f776a69b81b08e7f6429ee707f56825c51a Mon Sep 17 00:00:00 2001
From: Andrew Meadows <andrew@lindenlab.com>
Date: Thu, 10 Jan 2013 00:14:46 +0000
Subject: gcc fixes

---
 indra/newview/llfloaterjoystick.cpp | 22 ++++++++++++++--------
 indra/newview/llvosky.cpp           |  2 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index e2813a8272..ab7fc1cf3f 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -42,14 +42,20 @@
 #include "llviewerjoystick.h"
 #include "llcheckboxctrl.h"
 
-static LLTrace::Measurement<> sJoystickAxes[6] = 
+static LLTrace::Measurement<> sJoystickAxis1("Joystick axis 1"),
+								sJoystickAxis2("Joystick axis 2"),
+								sJoystickAxis3("Joystick axis 3"),
+								sJoystickAxis4("Joystick axis 4"),
+								sJoystickAxis5("Joystick axis 5"),
+								sJoystickAxis6("Joystick axis 6");
+static LLTrace::Measurement<>* sJoystickAxes[6] = 
 {
-	LLTrace::Measurement<>("Joystick axis 1"),
-	LLTrace::Measurement<>("Joystick axis 2"),
-	LLTrace::Measurement<>("Joystick axis 3"),
-	LLTrace::Measurement<>("Joystick axis 4"),
-	LLTrace::Measurement<>("Joystick axis 5"),
-	LLTrace::Measurement<>("Joystick axis 6")
+	&sJoystickAxis1,
+	&sJoystickAxis2,
+	&sJoystickAxis3,
+	&sJoystickAxis4,
+	&sJoystickAxis5,
+	&sJoystickAxis6
 };
 
 LLFloaterJoystick::LLFloaterJoystick(const LLSD& data)
@@ -71,7 +77,7 @@ void LLFloaterJoystick::draw()
 	for (U32 i = 0; i < 6; i++)
 	{
 		F32 value = joystick->getJoystickAxis(i);
-		sJoystickAxes[i].sample(value * gFrameIntervalSeconds.value());
+		sJoystickAxes[i]->sample(value * gFrameIntervalSeconds.value());
 		if (mAxisStatsBar[i])
 		{
 			F32 minbar, maxbar;
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 31358df85f..82de61cda2 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -2146,7 +2146,7 @@ void LLVOSky::updateFog(const F32 distance)
 		
 		// get the water param manager variables
 		float water_fog_density = LLWaterParamManager::getInstance()->getFogDensity();
-		LLColor4 water_fog_color = LLDrawPoolWater::sWaterFogColor.mV;
+		LLColor4 water_fog_color(LLDrawPoolWater::sWaterFogColor.mV);
 		
 		// adjust the color based on depth.  We're doing linear approximations
 		float depth_scale = gSavedSettings.getF32("WaterGLFogDepthScale");
-- 
cgit v1.2.3


From 90b5937c74f6712dfee1e90568d174a1aaca5ed7 Mon Sep 17 00:00:00 2001
From: Andrew Meadows <andrew@lindenlab.com>
Date: Thu, 10 Jan 2013 04:19:16 +0000
Subject: gcc fixes

---
 indra/newview/llfasttimerview.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 56e5710726..6409767285 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -514,7 +514,7 @@ void LLFastTimerView::draw()
 			else
 			{
 				ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
-				calls = frame_recording.getPeriodMean(idp->callCount());
+				calls = frame_recording.getPeriodMean((F32)idp->callCount());
 			}
 
 			if (mDisplayCalls)
@@ -736,7 +736,7 @@ void LLFastTimerView::draw()
 					{
 						sublevelticks += (tidx == -1)
 							? frame_recording.getPeriodMean(**it).value()
-							: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
+							: (U64)frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
 					}
 
 					F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
@@ -934,7 +934,7 @@ void LLFastTimerView::draw()
 			max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max));
 		}
 
-		max_calls = lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f));
+		max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)));
 		if (llabs((S32)(max_calls - cur_max_calls)) <= 1)
 		{
 			max_calls = cur_max_calls;
@@ -1011,7 +1011,7 @@ void LLFastTimerView::draw()
 			}
 			LLUnit<LLUnits::Milliseconds, F32> ms = ticks;
 
-			timer_stat += llformat("%.1f",ms);
+			timer_stat += llformat("%.1f",ms.value());
 
 			if (idp->getCollapsed())
 			{
-- 
cgit v1.2.3


From 27bec2b2f21f19a7c04707b03f83c8caa855872d Mon Sep 17 00:00:00 2001
From: Andrew Meadows <andrew@lindenlab.com>
Date: Thu, 10 Jan 2013 05:06:11 +0000
Subject: yet more gcc fixes

---
 indra/newview/llfasttimerview.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 6409767285..32ed662548 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -514,7 +514,7 @@ void LLFastTimerView::draw()
 			else
 			{
 				ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
-				calls = frame_recording.getPeriodMean((F32)idp->callCount());
+				calls = (S32)frame_recording.getPeriodMean((F32)idp->callCount());
 			}
 
 			if (mDisplayCalls)
@@ -728,7 +728,7 @@ void LLFastTimerView::draw()
 				}
 				else if (prev_id && get_depth(prev_id) < get_depth(idp))
 				{
-					U64 sublevelticks = 0;
+					F64 sublevelticks = 0;
 
 					for (TimeBlock::child_const_iter it = prev_id->beginChildren();
 						it != prev_id->endChildren();
@@ -736,7 +736,7 @@ void LLFastTimerView::draw()
 					{
 						sublevelticks += (tidx == -1)
 							? frame_recording.getPeriodMean(**it).value()
-							: (U64)frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
+							: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
 					}
 
 					F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
-- 
cgit v1.2.3


From 7cc37d949e9319a5b60641ff8453a0fed763d817 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 9 Jan 2013 22:43:10 -0700
Subject: fix the merge errors from the changeset 3eadda9666cf

---
 indra/newview/lldrawable.cpp         | 16 ++++++++++------
 indra/newview/llspatialpartition.cpp |  2 --
 indra/newview/llviewerobjectlist.cpp |  6 ++----
 indra/newview/llvieweroctree.cpp     |  9 +++++++++
 indra/newview/llvieweroctree.h       | 15 +++++++++++++--
 5 files changed, 34 insertions(+), 14 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index d91c7b0e1a..ba970671af 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1009,13 +1009,15 @@ bool LLDrawable::isRecentlyVisible() const
 
 void LLDrawable::setGroup(LLviewerOctreeGroup *groupp)
 {
-    //precondition: mGroupp MUST be null or DEAD or mGroupp MUST NOT contain this
-	llassert(!getGroup() || getGroup()->isDead() || !getGroup()->hasElement(this));
+	LLSpatialGroup* cur_groupp = (LLSpatialGroup*)getGroup();
+    
+	//precondition: mGroupp MUST be null or DEAD or mGroupp MUST NOT contain this
+	//llassert(!cur_groupp || cur_groupp->isDead() || !cur_groupp->hasElement(this));
 
 	//precondition: groupp MUST be null or groupp MUST contain this
-	llassert(!groupp || groupp->hasElement(this));
+	llassert(!groupp || (LLSpatialGroup*)groupp->hasElement(this));
 
-	if (getGroup() != groupp && getVOVolume())
+	if (cur_groupp != groupp && getVOVolume())
 	{ //NULL out vertex buffer references for volumes on spatial group change to maintain
 		//requirement that every face vertex buffer is either NULL or points to a vertex buffer
 		//contained by its drawable's spatial group
@@ -1031,8 +1033,8 @@ void LLDrawable::setGroup(LLviewerOctreeGroup *groupp)
 
 	//postcondition: if next group is NULL, previous group must be dead OR NULL OR binIndex must be -1
 	//postcondition: if next group is NOT NULL, binIndex must not be -1
-	llassert(groupp == NULL ? (getGroup() == NULL || getGroup()->isDead()) || getBinIndex() == -1 :
-							getBinIndex() != -1);
+	//llassert(groupp == NULL ? (cur_groupp == NULL || cur_groupp->isDead()) || (!getEntry() || getEntry()->getBinIndex() == -1) :
+	//						(getEntry() && getEntry()->getBinIndex() != -1));
 
 	LLViewerOctreeEntryData::setGroup(groupp);
 }
@@ -1498,6 +1500,8 @@ void LLSpatialBridge::cleanupReferences()
 				{
 					drawable->setGroup(NULL);				
 				}
+			}
+		}
 
 		LLDrawable* drawablep = mDrawable;
 		mDrawable = NULL;
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index bcafe2e008..0e2109c4af 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1549,8 +1549,6 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
 		drawablep->setGroup(NULL);
 	}
 
-	drawablep->setSpatialGroup(NULL);
-
 	assert_octree_valid(mOctree);
 	
 	return TRUE;
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 0543d11644..0335cd769b 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -356,7 +356,7 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 		}
 		justCreated = true;
 		mNumNewObjects++;
-		sCacheHitRate.addValue(100.f);
+		sCacheHitRate.sample(100.f);
 	}
 
 	if (objectp->isDead())
@@ -578,8 +578,6 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			}
 			justCreated = TRUE;
 			mNumNewObjects++;
-			sCacheHitRate.sample(cached ? 100.f : 0.f);
-
 		}
 
 
@@ -672,7 +670,7 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
 
 			continue; // no data packer, skip this object
 		}
-		sCacheHitRate.addValue(100.f);
+		sCacheHitRate.sample(100.f);
 	}
 
 	return;
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 7f502a6c51..cfa24c32ed 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -347,6 +347,15 @@ LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) :
 	mOctreeNode->addListener(this);
 }
 
+bool LLviewerOctreeGroup::hasElement(LLViewerOctreeEntryData* data) 
+{ 
+	if(!data->getEntry())
+	{
+		return false;
+	}
+	return std::find(getDataBegin(), getDataEnd(), data->getEntry()) != getDataEnd(); 
+}
+
 bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntryData* data)
 {
 	return removeFromGroup(data->getEntry());
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index f6ad3ac327..5bcaeb85da 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -94,6 +94,16 @@ public:
 	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);			
 
@@ -238,8 +248,9 @@ public:
 	element_list& getData() { return mOctreeNode->getData(); }
 	element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
 	element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
-	U32 getElementCount() const { return mOctreeNode->getElementCount(); }	
-
+	U32 getElementCount() const { return mOctreeNode->getElementCount(); }
+	bool hasElement(LLViewerOctreeEntryData* data);
+	
 private:
 	virtual bool boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut);	
 	
-- 
cgit v1.2.3


From c539004c7ebec31d7e61209e7110ec96c867aaa6 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 9 Jan 2013 23:37:22 -0700
Subject: fix a type casting error.

---
 indra/newview/llfasttimerview.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 32ed662548..ba298ed819 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -514,7 +514,7 @@ void LLFastTimerView::draw()
 			else
 			{
 				ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
-				calls = (S32)frame_recording.getPeriodMean((F32)idp->callCount());
+				calls = (S32)frame_recording.getPeriodMean(idp->callCount());
 			}
 
 			if (mDisplayCalls)
-- 
cgit v1.2.3


From 1a888f786c274ee6eaed54272718eeef5e685dbf Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 9 Jan 2013 23:05:07 -0800
Subject: SH-3468 WIP add memory tracking base class made LLTrace::MemTrackable
 support custom alignment LLDrawable now uses MemTrackable new and delete
 operators

---
 indra/newview/lldrawable.h | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index abfdea2699..c22cce246b 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -61,7 +61,7 @@ const U32 SILHOUETTE_HIGHLIGHT = 0;
 LL_ALIGN_PREFIX(16)
 class LLDrawable 
 :	public LLRefCount,
-	public LLTrace::MemTrackable<LLDrawable>
+	public LLTrace::MemTrackable<LLDrawable, 16>
 {
 public:
 	LLDrawable(const LLDrawable& rhs)
@@ -77,16 +77,6 @@ public:
 
 	static void initClass();
 
-	void* operator new(size_t size)
-	{
-		return ll_aligned_malloc_16(size);
-	}
-
-	void operator delete(void* ptr)
-	{
-		ll_aligned_free_16(ptr);
-	}
-
 	LLDrawable()				{ init(); }
 	
 	void markDead();			// Mark this drawable as dead
-- 
cgit v1.2.3


From 0c3df70dffdc6b19abaa91bfd14f2d08a66e95dd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 9 Jan 2013 23:15:32 -0800
Subject: added newline to fix gcc builds

---
 indra/newview/llvieweroctree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 5bcaeb85da..a35c551949 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -324,4 +324,4 @@ protected:
 	S32 mRes;
 };
 
-#endif
\ No newline at end of file
+#endif
-- 
cgit v1.2.3


From d89d9cd10ff1fbe6f1f86f0b282075e775ed1b51 Mon Sep 17 00:00:00 2001
From: Andrew Meadows <andrew@lindenlab.com>
Date: Fri, 11 Jan 2013 01:52:09 +0000
Subject: gcc fixes

---
 indra/newview/llfasttimerview.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 32ed662548..ba298ed819 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -514,7 +514,7 @@ void LLFastTimerView::draw()
 			else
 			{
 				ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
-				calls = (S32)frame_recording.getPeriodMean((F32)idp->callCount());
+				calls = (S32)frame_recording.getPeriodMean(idp->callCount());
 			}
 
 			if (mDisplayCalls)
-- 
cgit v1.2.3


From 840540be186904b1e711d79dede0c771c967950c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 10 Jan 2013 18:42:39 -0800
Subject: SH-3405 WIP convert existing stats to lltrace system fixed gcc errors
 in llscenemonitor.cpp

---
 indra/newview/llscenemonitor.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 4872200f24..189697dcf0 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -346,7 +346,7 @@ void LLSceneMonitor::calcDiffAggregate()
 		glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject);
 	}
 
-	gl_draw_scaled_target(0, 0, mDiff->getWidth() * mDiffPixelRatio, mDiff->getHeight() * mDiffPixelRatio, mDiff);
+	gl_draw_scaled_target(0, 0, S32(mDiff->getWidth() * mDiffPixelRatio), S32(mDiff->getHeight() * mDiffPixelRatio), mDiff);
 
 	if(mHasNewDiff)
 	{
@@ -424,8 +424,8 @@ void LLSceneMonitorView::draw()
 	}
 
 	F32 ratio = LLSceneMonitor::getInstance()->getDiffPixelRatio();
-	S32 height = target->getHeight() * ratio;
-	S32 width = target->getWidth() * ratio;
+	S32 height = (S32)(target->getHeight() * ratio);
+	S32 width = (S32)(target->getWidth() * ratio);
 	//S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f);
 	//S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f);
 	
-- 
cgit v1.2.3


From d81388f65b0fec29bd83cfee84e0291f1db15bf6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 10 Jan 2013 19:24:47 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system fix for gcc build
 error

---
 indra/newview/lltexturefetch.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 9f1c7855be..d62101d159 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -3742,11 +3742,12 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher)
 	main_stats.getStats(stats, true);
 	//LLSD merged_llsd = main_stats.asLLSD();
 
+	bool initial_report = !reporting_started;
 	stats.session_id = mSessionID;
 	stats.agent_id = mAgentID;
 	stats.message = "ViewerAssetMetrics";
 	stats.sequence = static_cast<bool>(report_sequence);
-	stats.initial = static_cast<bool>(!reporting_started);
+	stats.initial = initial_report;
 	stats.break_ = static_cast<bool>(LLTextureFetch::svMetricsDataBreak);
 
 	LLSD sd;
-- 
cgit v1.2.3


From 44cc14fbee8c9cb033dcb94d9c54f532427a5768 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 11 Jan 2013 13:11:07 -0800
Subject: fix for mac builds

---
 indra/newview/llfasttimerview.cpp | 2 +-
 indra/newview/llvowlsky.cpp       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 32ed662548..ba298ed819 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -514,7 +514,7 @@ void LLFastTimerView::draw()
 			else
 			{
 				ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
-				calls = (S32)frame_recording.getPeriodMean((F32)idp->callCount());
+				calls = (S32)frame_recording.getPeriodMean(idp->callCount());
 			}
 
 			if (mDisplayCalls)
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index 7f17fd3e56..717f215d3d 100644
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -394,7 +394,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 			segment->flush();
 		}
 	
-		llinfos << "completed in " << llformat("%.2f", timer.getElapsedTimeF32()) << "seconds" << llendl;
+		llinfos << "completed in " << llformat("%.2f", timer.getElapsedTimeF32().value()) << "seconds" << llendl;
 	}
 #else
 	mStripsVerts = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB);
-- 
cgit v1.2.3


From 85df1df3c34115efa0e18d116f7923b88ec1dadf Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 11 Jan 2013 14:24:52 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system gcc 4.1 fixes

---
 indra/newview/llviewerstatsrecorder.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp
index 91e485d01b..cdb7bde123 100644
--- a/indra/newview/llviewerstatsrecorder.cpp
+++ b/indra/newview/llviewerstatsrecorder.cpp
@@ -216,7 +216,10 @@ void LLViewerStatsRecorder::writeToLog( F32 interval )
 				<< "Texture Fetch bps\t"
 				<< "\n";
 
-			fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile );
+			if (fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ) != data_msg.str().size())
+			{
+				llwarns << "Failed to write log file." << llendl;
+			}
 		}
 		else
 		{
@@ -249,7 +252,10 @@ void LLViewerStatsRecorder::writeToLog( F32 interval )
 		<< "\t" << (mTextureFetchSize * 8 / delta_time)
 		<< "\n";
 
-	fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile );
+	if (fwrite(data_msg.str().c_str(), 1, data_msg.str().size(), mObjectCacheFile ) != data_msg.str().size())
+	{
+		llwarns << "Failed to write log file." << llendl;
+	}
 	clearStats();
 }
 
-- 
cgit v1.2.3


From 512d7381eca7bc53bb31e9528e5a7c5df189e82d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 11 Jan 2013 15:45:20 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system gcc 4.1 fixes

---
 indra/newview/llviewerstats.cpp   |  2 +-
 indra/newview/llviewertexture.cpp | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 077c9f43a4..136a4d0a9e 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -394,7 +394,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			gTotalTextureData = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT)).value();
+			gTotalTextureData = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT));
 			texture_stats_timer.reset();
 		}
 	}
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 1ffa83c529..7a142b481f 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -533,7 +533,7 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{
 		//when texture memory overflows, lower down the threshold to release the textures more aggressively.
-		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<LLUnits::Bytes, S32>(gMaxVideoRam));
+		sMaxDesiredTextureMem = (S32)llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<LLUnits::Bytes, S32>(gMaxVideoRam));
 	
 		// If we are using more texture memory than we should,
 		// scale up the desired discard level
@@ -549,8 +549,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sEvaluationTimer.reset();
 	}
 	else if (sDesiredDiscardBias > 0.0f &&
-			 sBoundTextureMemory < sMaxBoundTextureMem * texmem_lower_bound_scale &&
-			 sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale)
+			 sBoundTextureMemory < (S32)(sMaxBoundTextureMem * texmem_lower_bound_scale) &&
+			 sTotalTextureMemory < (S32)(sMaxTotalTextureMem * texmem_lower_bound_scale))
 	{			 
 		// If we are using less texture memory than we should,
 		// scale down the desired discard level
@@ -568,8 +568,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 	sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1);
 	sCameraMovingDiscardBias = (S8)(sCameraMovingBias);
 
-	LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < 0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale) &&
-				(sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale) ;
+	LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < (S32)(0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale)) &&
+				(sTotalTextureMemory < (S32)(0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale));
 }
 
 //end of static functions
-- 
cgit v1.2.3


From 91a8383b4a0bbd2d48d2d84678f5bcc3701c2b9f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 11 Jan 2013 16:30:05 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system gcc 4.1 fixes

---
 indra/newview/llviewertexture.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 7a142b481f..1ffa83c529 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -533,7 +533,7 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{
 		//when texture memory overflows, lower down the threshold to release the textures more aggressively.
-		sMaxDesiredTextureMem = (S32)llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<LLUnits::Bytes, S32>(gMaxVideoRam));
+		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<LLUnits::Bytes, S32>(gMaxVideoRam));
 	
 		// If we are using more texture memory than we should,
 		// scale up the desired discard level
@@ -549,8 +549,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sEvaluationTimer.reset();
 	}
 	else if (sDesiredDiscardBias > 0.0f &&
-			 sBoundTextureMemory < (S32)(sMaxBoundTextureMem * texmem_lower_bound_scale) &&
-			 sTotalTextureMemory < (S32)(sMaxTotalTextureMem * texmem_lower_bound_scale))
+			 sBoundTextureMemory < sMaxBoundTextureMem * texmem_lower_bound_scale &&
+			 sTotalTextureMemory < sMaxTotalTextureMem * texmem_lower_bound_scale)
 	{			 
 		// If we are using less texture memory than we should,
 		// scale down the desired discard level
@@ -568,8 +568,8 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 	sCameraMovingBias = llmax(0.2f * camera_moving_speed, 2.0f * camera_angular_speed - 1);
 	sCameraMovingDiscardBias = (S8)(sCameraMovingBias);
 
-	LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < (S32)(0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale)) &&
-				(sTotalTextureMemory < (S32)(0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale));
+	LLViewerTexture::sFreezeImageScalingDown = (sBoundTextureMemory < 0.75f * sMaxBoundTextureMem * texmem_middle_bound_scale) &&
+				(sTotalTextureMemory < 0.75f * sMaxTotalTextureMem * texmem_middle_bound_scale) ;
 }
 
 //end of static functions
-- 
cgit v1.2.3


From 6272ca1ad82fd9818a1dd937a890ed982f0bdc4a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 11 Jan 2013 16:52:43 -0800
Subject: SH-3405 WIP convert existing stats to lltrace system more gcc fixes

---
 indra/newview/llviewerregion.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 7d2e08c1c6..570bf9264c 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1001,7 +1001,10 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		{
 			if(vo_entry->getState() >= LLVOCacheEntry::WAITING)
 			{
-				iter = mImpl->mVisibleEntries.erase(iter);
+				LLVOCacheEntry::vocache_entry_set_t::iterator next_iter = iter;
+				++next_iter;
+				mImpl->mVisibleEntries.erase(iter);
+				iter = next_iter;
 			}
 			else
 			{
-- 
cgit v1.2.3


From 7378259aa551c395b67e40196487584eaf5e8007 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 15 Jan 2013 14:14:29 -0700
Subject: for SH-3667: Create an extendable recording tied to scene load time

---
 indra/newview/llagent.cpp        |  8 ++++++++
 indra/newview/llagent.h          |  2 ++
 indra/newview/llscenemonitor.cpp | 23 ++++++++++++++++++++++-
 indra/newview/llscenemonitor.h   |  5 +++++
 4 files changed, 37 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 14235bcee4..24c9da8e17 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1046,6 +1046,14 @@ const LLVector3d &LLAgent::getPositionGlobal() const
 	return mPositionGlobal;
 }
 
+bool LLAgent::isPositionChanged() const
+{
+	LLVector3d diff;
+	diff = mPositionGlobal - mLastPositionGlobal;
+	
+	return diff.lengthSquared() > 1.0;
+}
+
 //-----------------------------------------------------------------------------
 // getPositionAgent()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 99904e118c..a1e899b45d 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -250,6 +250,8 @@ public:
 	
 	const LLVector3d &getLastPositionGlobal() const { return mLastPositionGlobal; }
 	void			setLastPositionGlobal(const LLVector3d &pos) { mLastPositionGlobal = pos; }
+
+	bool            isPositionChanged() const;
 private:
 	std::set<U64>	mRegionsVisited;		// Stat - what distinct regions has the avatar been to?
 	F64				mDistanceTraveled;		// Stat - how far has the avatar moved?
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 4872200f24..7a960f7baa 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -37,6 +37,7 @@
 #include "llwindow.h"
 #include "llpointer.h"
 #include "llspatialpartition.h"
+#include "llagent.h"
 
 LLSceneMonitorView* gSceneMonitorView = NULL;
 
@@ -67,7 +68,10 @@ LLSceneMonitor::LLSceneMonitor() :
 	mDiffPixelRatio(0.5f)
 {
 	mFrames[0] = NULL;
-	mFrames[1] = NULL;	
+	mFrames[1] = NULL;
+
+	mRecording = new LLTrace::ExtendableRecording();
+	mRecording->start();
 }
 
 LLSceneMonitor::~LLSceneMonitor()
@@ -78,6 +82,9 @@ LLSceneMonitor::~LLSceneMonitor()
 void LLSceneMonitor::destroyClass()
 {
 	reset();
+
+	delete mRecording;
+	mRecording = NULL;
 }
 
 void LLSceneMonitor::reset()
@@ -137,6 +144,11 @@ bool LLSceneMonitor::preCapture()
 		return false;
 	}
 
+	if(gAgent.isPositionChanged())
+	{
+		mRecording->reset();
+	}
+
 	if(timer.getElapsedTimeF32() < mSamplingTime)
 	{
 		return false;
@@ -388,6 +400,10 @@ void LLSceneMonitor::fetchQueryResult()
 	
 	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
+	if(mDiffResult > 0.01f)
+	{
+		mRecording->extend();
+	}
 	//llinfos << count << " : " << mDiffResult << llendl;
 }
 //-------------------------------------------------------------------------------------------------------------
@@ -454,6 +470,11 @@ void LLSceneMonitorView::draw()
 
 	num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime());
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
+	lines++;
+
+	num_str = llformat("Scene Loading time: %.3f seconds", (F32)LLSceneMonitor::getInstance()->getRecording()->getAcceptedRecording().getDuration().value());
+	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
+	lines++;
 
 	LLView::draw();
 }
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 02e3d57d46..93e6c20bb9 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -31,6 +31,7 @@
 #include "llmath.h"
 #include "llfloater.h"
 #include "llcharacter.h"
+#include "lltracerecording.h"
 
 class LLCharacter;
 class LLRenderTarget;
@@ -61,6 +62,8 @@ public:
 	bool isEnabled()const {return mEnabled;}
 	bool needsUpdate() const;
 	
+	LLTrace::ExtendableRecording* getRecording() const {return mRecording;}
+
 private:
 	void freezeScene();
 	void unfreezeScene();
@@ -86,6 +89,8 @@ private:
 	F32     mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension
 
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
+
+	LLTrace::ExtendableRecording* mRecording;
 };
 
 class LLSceneMonitorView : public LLFloater
-- 
cgit v1.2.3


From 670d03ceb83b92c9bb98d10bb37fba6f75971a2f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 15 Jan 2013 14:28:32 -0800
Subject: SH-3406 WIP convert fast timers to lltrace system fixed
 LLExtendableRecording to actually accumulator recording time period renamed
 and updated LLStopWatchControlsMixin::initTo to setPlayState

---
 indra/newview/llviewerassetstats.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index b4da9521f4..890394dd22 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -297,7 +297,7 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 		it->second.makeUnique();
 	}
 
-	LLStopWatchControlsMixin<LLViewerAssetStats>::initTo(src.getPlayState());
+	LLStopWatchControlsMixin<LLViewerAssetStats>::setPlayState(src.getPlayState());
 }
 
 void LLViewerAssetStats::handleStart()
-- 
cgit v1.2.3


From 45a7fe901aa4cd7af14fa1cb894da46a988e3aa2 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 15 Jan 2013 23:01:40 -0700
Subject: for SH-3653: Can we repurpose
 ObjectUpdateCached:ObjectData:UpdateFlags field to carry spatial+size data?

---
 indra/newview/llviewerobjectlist.cpp |  4 +-
 indra/newview/llviewerregion.cpp     | 81 ++++++++++++++++--------------------
 indra/newview/llviewerregion.h       | 35 ++++++++++++++--
 3 files changed, 70 insertions(+), 50 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 0335cd769b..dce963c5c5 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -657,13 +657,15 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
 		S32	msg_size = 0;
 		U32 id;
 		U32 crc;
+		U32 flags;
 		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, id, i);
 		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_CRC, crc, i);
+		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i);
 		msg_size += sizeof(U32) * 2;
 		
 		// Lookup data packer and add this id to cache miss lists if necessary.
 		U8 cache_miss_type = LLViewerRegion::CACHE_MISS_TYPE_NONE;
-		if(!regionp->probeCache(id, crc, cache_miss_type))
+		if(!regionp->probeCache(id, crc, flags, cache_miss_type))
 		{
 			// Cache Miss.
 			recorder.cacheMissEvent(id, update_type, cache_miss_type, msg_size);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 7d2e08c1c6..f44c8ffe46 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1718,9 +1718,26 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id)
 	return NULL;
 }
 
+//estimate weight of cache missed object
+F32 LLViewerRegion::calcObjectWeight(U32 flags)
+{
+	LLVector3 pos((F32)(flags & 0xff), (F32)((flags >> 8) & 0xff), (F32)((flags >> 16) & 0xff) * 16.f);
+	F32 rad = (F32)((flags >> 24) & 0xff);
+
+	pos += getOriginAgent();
+	pos -= LLViewerCamera::getInstance()->getOrigin();
+
+	return rad * rad / pos.lengthSquared();
+}
+
+void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight)
+{
+	mCacheMissList.insert(CacheMissItem(id, miss_type, weight));
+}
+
 // Get data packer for this object, if we have cached data
 // AND the CRC matches. JC
-bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U8 &cache_miss_type)
+bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type)
 {
 	//llassert(mCacheLoaded);  This assert failes often, changing to early-out -- davep, 2010/10/18
 
@@ -1746,15 +1763,14 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U8 &cache_miss_type)
 		else
 		{
 			// llinfos << "CRC miss for " << local_id << llendl;
-			cache_miss_type = CACHE_MISS_TYPE_CRC;
-			mCacheMissCRC.put(local_id);
+
+			addCacheMiss(local_id, CACHE_MISS_TYPE_CRC, calcObjectWeight(flags));
 		}
 	}
 	else
 	{
 		// llinfos << "Cache miss for " << local_id << llendl;
-		cache_miss_type = CACHE_MISS_TYPE_FULL;
-		mCacheMissFull.put(local_id);
+		addCacheMiss(local_id, CACHE_MISS_TYPE_FULL, calcObjectWeight(flags));
 	}
 
 	return false;
@@ -1762,49 +1778,22 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U8 &cache_miss_type)
 
 void LLViewerRegion::addCacheMissFull(const U32 local_id)
 {
-	mCacheMissFull.put(local_id);
+	addCacheMiss(local_id, CACHE_MISS_TYPE_FULL, 100.f);
 }
 
 void LLViewerRegion::requestCacheMisses()
 {
-	S32 full_count = mCacheMissFull.count();
-	S32 crc_count = mCacheMissCRC.count();
-	if (full_count == 0 && crc_count == 0) return;
+	if (!mCacheMissList.size()) 
+	{
+		return;
+	}
 
 	LLMessageSystem* msg = gMessageSystem;
 	BOOL start_new_message = TRUE;
 	S32 blocks = 0;
-	S32 i;
-
-	// Send full cache miss updates.  For these, we KNOW we don't
-	// have a viewer object.
-	for (i = 0; i < full_count; i++)
-	{
-		if (start_new_message)
-		{
-			msg->newMessageFast(_PREHASH_RequestMultipleObjects);
-			msg->nextBlockFast(_PREHASH_AgentData);
-			msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-			msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-			start_new_message = FALSE;
-		}
-
-		msg->nextBlockFast(_PREHASH_ObjectData);
-		msg->addU8Fast(_PREHASH_CacheMissType, CACHE_MISS_TYPE_FULL);
-		msg->addU32Fast(_PREHASH_ID, mCacheMissFull[i]);
-		blocks++;
-
-		if (blocks >= 255)
-		{
-			sendReliableMessage();
-			start_new_message = TRUE;
-			blocks = 0;
-		}
-	}
-
-	// Send CRC miss updates.  For these, we _might_ have a viewer object,
-	// but probably not.
-	for (i = 0; i < crc_count; i++)
+	
+	//send requests for all cache-missed objects
+	for (CacheMissItem::cache_miss_list_t::iterator iter = mCacheMissList.begin(); iter != mCacheMissList.end(); ++iter)
 	{
 		if (start_new_message)
 		{
@@ -1816,8 +1805,8 @@ void LLViewerRegion::requestCacheMisses()
 		}
 
 		msg->nextBlockFast(_PREHASH_ObjectData);
-		msg->addU8Fast(_PREHASH_CacheMissType, CACHE_MISS_TYPE_CRC);
-		msg->addU32Fast(_PREHASH_ID, mCacheMissCRC[i]);
+		msg->addU8Fast(_PREHASH_CacheMissType, (*iter).mType);
+		msg->addU32Fast(_PREHASH_ID, (*iter).mID);
 		blocks++;
 
 		if (blocks >= 255)
@@ -1832,14 +1821,14 @@ void LLViewerRegion::requestCacheMisses()
 	if (!start_new_message)
 	{
 		sendReliableMessage();
-	}
-	mCacheMissFull.reset();
-	mCacheMissCRC.reset();
+	}	
 
 	mCacheDirty = TRUE ;
 	// llinfos << "KILLDEBUG Sent cache miss full " << full_count << " crc " << crc_count << llendl;
-	LLViewerStatsRecorder::instance().requestCacheMissesEvent(full_count + crc_count);
+	LLViewerStatsRecorder::instance().requestCacheMissesEvent(mCacheMissList.size());
 	LLViewerStatsRecorder::instance().log(0.2f);
+
+	mCacheMissList.clear();
 }
 
 void LLViewerRegion::dumpCache()
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 9252923aa3..4f0087ba7c 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -169,6 +169,9 @@ public:
 	const LLVector3d &getOriginGlobal() const;
 	LLVector3 getOriginAgent() const;
 
+	//estimate weight of cache missed object
+	F32 calcObjectWeight(U32 flags);
+
 	// Center is at the height of the water table.
 	const LLVector3d &getCenterGlobal() const;
 	LLVector3 getCenterAgent() const;
@@ -316,7 +319,7 @@ public:
 	// handle a full update message
 	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);	
 	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
-	bool probeCache(U32 local_id, U32 crc, U8 &cache_miss_type);
+	bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type);
 	void requestCacheMisses();
 	void addCacheMissFull(const U32 local_id);
 
@@ -356,6 +359,7 @@ private:
 	F32 createVisibleObjects(F32 max_time);
 	F32 updateVisibleEntries(F32 max_time); //update visible entries
 
+	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight);
 public:
 	struct CompareDistance
 	{
@@ -441,8 +445,33 @@ private:
 	BOOL    mReleaseNotesRequested;
 	BOOL    mDead;  //if true, this region is in the process of deleting.
 
-	LLDynamicArray<U32>						mCacheMissFull;
-	LLDynamicArray<U32>						mCacheMissCRC;
+	class CacheMissItem
+	{
+	public:
+		CacheMissItem(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight) : mID(id), mType(miss_type), mWeight(weight){}
+
+		U32                            mID;     //local object id
+		LLViewerRegion::eCacheMissType mType;   //cache miss type
+		F32                            mWeight; //importance of this object to the current camera.
+	
+		struct Compare
+		{
+			bool operator()(const CacheMissItem& lhs, const CacheMissItem& rhs)
+			{
+				if(lhs.mWeight == rhs.mWeight) //larger weight first
+				{
+					return &lhs < &rhs;
+				}
+				else 
+				{
+					return lhs.mWeight > rhs.mWeight; //larger weight first
+				}
+			}
+		};
+
+		typedef std::set<CacheMissItem, Compare> cache_miss_list_t;
+	};
+	CacheMissItem::cache_miss_list_t        mCacheMissList;
 	
 	caps_received_signal_t mCapabilitiesReceivedSignal;		
 	LLSD mSimulatorFeatures;
-- 
cgit v1.2.3


From 3ed1bee350ed93f81a484a7c073c12708e73e946 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 16 Jan 2013 22:03:48 -0700
Subject: trivial: convert to unix line endings.

---
 indra/newview/llviewerregion.h | 52 +++++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 4f0087ba7c..de14c0fe27 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -445,32 +445,32 @@ private:
 	BOOL    mReleaseNotesRequested;
 	BOOL    mDead;  //if true, this region is in the process of deleting.
 
-	class CacheMissItem
-	{
-	public:
-		CacheMissItem(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight) : mID(id), mType(miss_type), mWeight(weight){}
-
-		U32                            mID;     //local object id
-		LLViewerRegion::eCacheMissType mType;   //cache miss type
-		F32                            mWeight; //importance of this object to the current camera.
-	
-		struct Compare
-		{
-			bool operator()(const CacheMissItem& lhs, const CacheMissItem& rhs)
-			{
-				if(lhs.mWeight == rhs.mWeight) //larger weight first
-				{
-					return &lhs < &rhs;
-				}
-				else 
-				{
-					return lhs.mWeight > rhs.mWeight; //larger weight first
-				}
-			}
-		};
-
-		typedef std::set<CacheMissItem, Compare> cache_miss_list_t;
-	};
+	class CacheMissItem
+	{
+	public:
+		CacheMissItem(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight) : mID(id), mType(miss_type), mWeight(weight){}
+
+		U32                            mID;     //local object id
+		LLViewerRegion::eCacheMissType mType;   //cache miss type
+		F32                            mWeight; //importance of this object to the current camera.
+	
+		struct Compare
+		{
+			bool operator()(const CacheMissItem& lhs, const CacheMissItem& rhs)
+			{
+				if(lhs.mWeight == rhs.mWeight) //larger weight first
+				{
+					return &lhs < &rhs;
+				}
+				else 
+				{
+					return lhs.mWeight > rhs.mWeight; //larger weight first
+				}
+			}
+		};
+
+		typedef std::set<CacheMissItem, Compare> cache_miss_list_t;
+	};
 	CacheMissItem::cache_miss_list_t        mCacheMissList;
 	
 	caps_received_signal_t mCapabilitiesReceivedSignal;		
-- 
cgit v1.2.3


From 1e95127e359124d8bcad93d263d6e3c9ae13263b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 16 Jan 2013 22:04:26 -0700
Subject: for SH-3663: Get windlight cloud animation and water animation to
 stop when pausing world updates

---
 indra/newview/llscenemonitor.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index bafd245aa0..2f1c4e065a 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -38,6 +38,7 @@
 #include "llpointer.h"
 #include "llspatialpartition.h"
 #include "llagent.h"
+#include "pipeline.h"
 
 LLSceneMonitorView* gSceneMonitorView = NULL;
 
@@ -209,6 +210,9 @@ void LLSceneMonitor::freezeScene()
 
 	// freeze everything else
 	gSavedSettings.setBOOL("FreezeTime", TRUE);
+
+	gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, 
+		LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES);
 }
 
 void LLSceneMonitor::unfreezeScene()
@@ -218,6 +222,9 @@ void LLSceneMonitor::unfreezeScene()
 
 	// thaw everything else
 	gSavedSettings.setBOOL("FreezeTime", FALSE);
+
+	gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, 
+		LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES);
 }
 
 void LLSceneMonitor::capture()
-- 
cgit v1.2.3


From 096b2738c2213281b463d0de093c08a406f53946 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 24 Jan 2013 01:18:49 -0800
Subject: SH-3275 WIP interesting Update viewer metrics system to be more
 flexible clean up LLFastTimerView so it can be converted to handling LLTrace
 data

---
 indra/newview/llfasttimerview.cpp | 1924 +++++++++++++++++++------------------
 indra/newview/llfasttimerview.h   |   19 +-
 2 files changed, 985 insertions(+), 958 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index ba298ed819..59a52fdaea 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -106,7 +106,9 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mPrintStats(-1),
 	mRecording(&get_frame_recording()),
 	mPauseHistory(false)
-{}
+{
+	mBarRects = new std::vector<LLRect>[MAX_VISIBLE_HISTORY];
+}
 
 LLFastTimerView::~LLFastTimerView()
 {
@@ -115,6 +117,7 @@ LLFastTimerView::~LLFastTimerView()
 		delete mRecording;
 	}
 	mRecording = NULL;
+	delete [] mBarRects;
 }
 
 void LLFastTimerView::onPause()
@@ -250,13 +253,11 @@ BOOL LLFastTimerView::handleMouseUp(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 {
-	PeriodicRecording& frame_recording = *mRecording;
-
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
 		mScrollIndex = llround( lerp * (F32)(HISTORY_NUM - MAX_VISIBLE_HISTORY));
-		mScrollIndex = llclamp(	mScrollIndex, 0, frame_recording.getNumPeriods());
+		mScrollIndex = llclamp(	mScrollIndex, 0, mRecording->getNumPeriods());
 		return TRUE;
 	}
 	mHoverTimer = NULL;
@@ -281,8 +282,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			++it, ++i)
 		{
 			// is mouse over bar for this timer?
-			if (x > mBarStart[mHoverBarIndex][i] &&
-				x < mBarEnd[mHoverBarIndex][i])
+			if (mBarRects[mHoverBarIndex][i].pointInRect(x, y))
 			{
 				mHoverID = (*it);
 				if (mHoverTimer != *it)
@@ -294,10 +294,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 					mHoverTimer = (*it);
 				}
 
-				mToolTipRect.set(mBarStart[mHoverBarIndex][i], 
-					mBarRect.mBottom + llround(((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex + 1)) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f))),
-					mBarEnd[mHoverBarIndex][i],
-					mBarRect.mBottom + llround((F32)(MAX_VISIBLE_HISTORY - mHoverBarIndex) * ((F32)mBarRect.getHeight() / ((F32)MAX_VISIBLE_HISTORY + 2.f))));
+				mToolTipRect = mBarRects[mHoverBarIndex][i];
 			}
 
 			if ((*it)->getCollapsed())
@@ -376,16 +373,16 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	PeriodicRecording& frame_recording = *mRecording;
-
 	mPauseHistory = true;
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(frame_recording.getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY));
+							llmin(mRecording->getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
 static TimeBlock FTM_RENDER_TIMER("Timers", true);
+static const S32 MARGIN = 10;
+static const S32 LEGEND_WIDTH = 220;
 
 static std::map<TimeBlock*, LLColor4> sTimerColors;
 
@@ -393,574 +390,558 @@ void LLFastTimerView::draw()
 {
 	LLFastTimer t(FTM_RENDER_TIMER);
 
-	PeriodicRecording& frame_recording = *mRecording;
-
-	std::string tdesc;
-
-	const S32 margin = 10;
-	const S32 height = getRect().getHeight();
-	const S32 width = getRect().getWidth();
-	
-	LLRect new_rect;
-	new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
-	setRect(new_rect);
-
-	S32 left, top, right, bottom;
-	S32 x, y, barw, barh, dx, dy;
-	const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
-	LLPointer<LLUIImage> box_imagep = LLUI::getUIImage("Rounded_Square");
+	generateUniqueColors();
 
 	// Draw the window background
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-	gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.f, 0.f, 0.f, 0.25f));
-	
-	// Draw some help
-	{
-		x = margin;
-		y = height - margin;
-
-		char modedesc[][32] = {
-			"2 x Average ",
-			"Max         ",
-			"Recent Max  ",
-			"100 ms      "
-		};
-		char centerdesc[][32] = {
-			"Left      ",
-			"Centered  ",
-			"Ordered   "
-		};
+	gl_rect_2d(getLocalRect(), LLColor4(0.f, 0.f, 0.f, 0.25f));
 
-		tdesc = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]);
-		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+	S32 y = drawHelp(getRect().getHeight() - MARGIN);
+	drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() - 2));
 
-		x = margin, y -= (texth + 2);
-		tdesc = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]);
-		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-		y -= (texth + 2);
+	// update rectangle that includes timer bars
+	const S32 LEGEND_WIDTH = 220;
 
-		LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"),
-										 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-		y -= (texth + 2);
-	}
+	mBarRect.mLeft = MARGIN + LEGEND_WIDTH + 8;
+	mBarRect.mTop = y;
+	mBarRect.mRight = getRect().getWidth() - MARGIN;
+	mBarRect.mBottom = MARGIN + LINE_GRAPH_HEIGHT;
 
-	S32 histmax = llmin(frame_recording.getNumPeriods()+1, MAX_VISIBLE_HISTORY);
+	drawBars();
+	drawLineGraph();
+	printLineStats();
+	LLView::draw();
 		
-	const S32 ytop = y;
-	y -= (texth + 2);
-
-	// generate unique colors
-	{
-		sTimerColors[&getFrameTimer()] = LLColor4::grey;
-
-		F32 hue = 0.f;
-
-		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-			it != timer_tree_iterator_t();
-			++it)
-		{
-			TimeBlock* idp = (*it);
-
-			const F32 HUE_INCREMENT = 0.23f;
-			hue = fmodf(hue + HUE_INCREMENT, 1.f);
-			// saturation increases with depth
-			F32 saturation = clamp_rescale((F32)get_depth(idp), 0.f, 3.f, 0.f, 1.f);
-			// lightness alternates with depth
-			F32 lightness = get_depth(idp) % 2 ? 0.5f : 0.6f;
-
-			LLColor4 child_color;
-			child_color.setHSL(hue, saturation, lightness);
+	mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(getFrameTimer()));
+	mHoverID = NULL;
+	mHoverBarIndex = -1;
+}
 
-			sTimerColors[idp] = child_color;
-		}
-	}
+F64 LLFastTimerView::getTime(const std::string& name)
+{
+	//TODO: replace calls to this with use of timer object directly
+	//llstatic_assert(false, "TODO: implement");
+	return 0.0;
+}
 
-	// draw legend
-	const S32 LEGEND_WIDTH = 220;
-	const S32 x_start = margin + LEGEND_WIDTH + 8;
-	{
-		LLLocalClipRect clip(LLRect(margin, y, LEGEND_WIDTH, margin));
-		S32 cur_line = 0;
-		ft_display_idx.clear();
-		std::map<TimeBlock*, S32> display_line;
-		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-			it != timer_tree_iterator_t();
-			++it)
-		{
-			TimeBlock* idp = (*it);
-			display_line[idp] = cur_line;
-			ft_display_idx.push_back(idp);
-			cur_line++;
+void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch)
+{
+	//read result back into raw image
+	glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData());
 
-			x = margin;
+	//write results to disk
+	LLPointer<LLImagePNG> result = new LLImagePNG();
+	result->encode(scratch, 0.f);
 
-			left = x; right = x + texth;
-			top = y; bottom = y - texth;
-			S32 scale_offset = 0;
-			if (idp == mHoverID)
-			{
-				scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f);
-			}
-			gl_rect_2d(left - scale_offset, top + scale_offset, right + scale_offset, bottom - scale_offset, sTimerColors[idp]);
+	std::string ext = result->getExtension();
+	std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str());
+	
+	std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename);
+	result->save(out_file);
+}
 
-			LLUnit<LLUnits::Milliseconds, F32> ms = 0;
-			S32 calls = 0;
-			if (mHoverBarIndex > 0 && mHoverID)
-			{
-				S32 hidx = mScrollIndex + mHoverBarIndex;
-				ms = frame_recording.getPrevRecordingPeriod(hidx).getSum(*idp);
-				calls = frame_recording.getPrevRecordingPeriod(hidx).getSum(idp->callCount());
-			}
-			else
-			{
-				ms = LLUnit<LLUnits::Seconds, F64>(frame_recording.getPeriodMean(*idp));
-				calls = (S32)frame_recording.getPeriodMean(idp->callCount());
-			}
+//static
+void LLFastTimerView::exportCharts(const std::string& base, const std::string& target)
+{
+	//allocate render target for drawing charts 
+	LLRenderTarget buffer;
+	buffer.allocate(1024,512, GL_RGB, FALSE, FALSE);
+	
 
-			if (mDisplayCalls)
-			{
-				tdesc = llformat("%s (%d)",idp->getName().c_str(),calls);
-			}
-			else
-			{
-				tdesc = llformat("%s [%.1f]",idp->getName().c_str(),ms.value());
-			}
-			dx = (texth+4) + get_depth(idp)*8;
+	LLSD cur;
 
-			LLColor4 color = LLColor4::white;
-			if (get_depth(idp) > 0)
-			{
-				S32 line_start_y = (top + bottom) / 2;
-				S32 line_end_y = line_start_y + ((texth + 2) * (cur_line - display_line[idp->getParent()])) - texth;
-				gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color);
-				S32 line_x = x + (texth + 4) + ((get_depth(idp) - 1) * 8);
-				gl_line_2d(line_x, line_start_y, line_x, line_end_y, color);
-				if (idp->getCollapsed() && !idp->getChildren().empty())
-				{
-					gl_line_2d(line_x+4, line_start_y-3, line_x+4, line_start_y+4, color);
-				}
-			}
+	LLSD base_data;
 
-			x += dx;
-			BOOL is_child_of_hover_item = (idp == mHoverID);
-			TimeBlock* next_parent = idp->getParent();
-			while(!is_child_of_hover_item && next_parent)
-			{
-				is_child_of_hover_item = (mHoverID == next_parent);
-				if (next_parent->getParent() == next_parent) break;
-				next_parent = next_parent->getParent();
-			}
+	{ //read base log into memory
+		S32 i = 0;
+		std::ifstream is(base.c_str());
+		while (!is.eof() && LLSDSerialize::fromXML(cur, is))
+		{
+			base_data[i++] = cur;
+		}
+		is.close();
+	}
 
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, 
-											x, y, 
-											color, 
-											LLFontGL::LEFT, LLFontGL::TOP, 
-											is_child_of_hover_item ? LLFontGL::BOLD : LLFontGL::NORMAL);
+	LLSD cur_data;
+	std::set<std::string> chart_names;
 
-			y -= (texth + 2);
+	{ //read current log into memory
+		S32 i = 0;
+		std::ifstream is(target.c_str());
+		while (!is.eof() && LLSDSerialize::fromXML(cur, is))
+		{
+			cur_data[i++] = cur;
 
-			if (idp->getCollapsed()) 
+			for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter)
 			{
-				it.skipDescendants();
+				std::string label = iter->first;
+				chart_names.insert(label);
 			}
 		}
+		is.close();
 	}
 
-	// update rectangle that includes timer bars
-	mBarRect.mLeft = x_start;
-	mBarRect.mRight = getRect().getWidth();
-	mBarRect.mTop = ytop - (LLFontGL::getFontMonospace()->getLineHeight() + 4);
-	mBarRect.mBottom = margin + LINE_GRAPH_HEIGHT;
-
-	y = ytop;
-	barh = (ytop - margin - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2);
-	dy = barh>>2; // spacing between bars
-	if (dy < 1) dy = 1;
-	barh -= dy;
-	barw = width - x_start - margin;
-
-	// Draw the history bars
-	LLUnit<LLUnits::Seconds, F64> total_time;
-	switch(mDisplayMode)
+	//get time domain
+	LLSD::Real cur_total_time = 0.0;
+
+	for (U32 i = 0; i < cur_data.size(); ++i)
 	{
-	case 0:
-		total_time = frame_recording.getPeriodMean(getFrameTimer())*2;
-		break;
-	case 1:
-		total_time = mAllTimeMax;
-		break;
-	case 2:
-		// Calculate the max total ticks for the current history
-		total_time = frame_recording.getPeriodMax(getFrameTimer());
-		break;
-	default:
-		total_time = LLUnit<LLUnits::Milliseconds, F32>(100);
-		break;
+		cur_total_time += cur_data[i]["Total"]["Time"].asReal();
 	}
 
-	if (total_time > 0)
+	LLSD::Real base_total_time = 0.0;
+	for (U32 i = 0; i < base_data.size(); ++i)
 	{
-		LLLocalClipRect clip(LLRect(x_start, ytop, getRect().getWidth() - margin, margin));
-
-		mAllTimeMax = llmax(mAllTimeMax, frame_recording.getLastRecordingPeriod().getSum(getFrameTimer()));
-		
-		// Draw MS ticks
-		{
-			LLUnit<LLUnits::Milliseconds, U32> ms = total_time;
+		base_total_time += base_data[i]["Total"]["Time"].asReal();
+	}
 
-			tdesc = llformat("%.1f ms |", (F32)ms.value()*.25f);
-			x = x_start + barw/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-											LLFontGL::LEFT, LLFontGL::TOP);
-			
-			tdesc = llformat("%.1f ms |", (F32)ms.value()*.50f);
-			x = x_start + barw/2 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-											LLFontGL::LEFT, LLFontGL::TOP);
-			
-			tdesc = llformat("%.1f ms |", (F32)ms.value()*.75f);
-			x = x_start + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-											LLFontGL::LEFT, LLFontGL::TOP);
-			
-			tdesc = llformat( "%d ms |", (U32)ms.value());
-			x = x_start + barw - LLFontGL::getFontMonospace()->getWidth(tdesc);
-			LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-											LLFontGL::LEFT, LLFontGL::TOP);
-		}
+	//allocate raw scratch space
+	LLPointer<LLImageRaw> scratch = new LLImageRaw(1024, 512, 3);
 
-		// Draw borders
-		{
-			gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-			gGL.color4f(0.5f,0.5f,0.5f,0.5f);
+	gGL.pushMatrix();
+	gGL.loadIdentity();
+	gGL.matrixMode(LLRender::MM_PROJECTION);
+	gGL.loadIdentity();
+	gGL.ortho(-0.05f, 1.05f, -0.05f, 1.05f, -1.0f, 1.0f);
 
-			S32 by = y + 2;
-			
-			y -= ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
+	//render charts
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	
+	buffer.bindTarget();
 
-			//heading
-			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, y+5, FALSE);
+	for (std::set<std::string>::iterator iter = chart_names.begin(); iter != chart_names.end(); ++iter)
+	{
+		std::string label = *iter;
+	
+		LLSD::Real max_time = 0.0;
+		LLSD::Integer max_calls = 0;
+		LLSD::Real max_execution = 0.0;
 
-			//tree view
-			gl_rect_2d(5, by, x_start-10, 5, FALSE);
+		std::vector<LLSD::Real> cur_execution;
+		std::vector<LLSD::Real> cur_times;
+		std::vector<LLSD::Integer> cur_calls;
 
-			by = y + 5;
-			//average bar
-			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-5, FALSE);
-			
-			by -= barh*2+dy;
-			
-			//current frame bar
-			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-barh-dy-2, FALSE);
-			
-			by -= barh+dy+1;
-			
-			//history bars
-			gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-barh-dy-2, FALSE);			
-			
-			by = LINE_GRAPH_HEIGHT-barh-dy-7;
-			
-			//line graph
-			mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5);
-			
-			gl_rect_2d(mGraphRect, FALSE);
-		}
-		
-		mBarStart.clear();
-		mBarEnd.clear();
+		std::vector<LLSD::Real> base_execution;
+		std::vector<LLSD::Real> base_times;
+		std::vector<LLSD::Integer> base_calls;
 
-		// Draw bars for each history entry
-		// Special: -1 = show running average
-		gGL.getTexUnit(0)->bind(box_imagep->getImage());
-		for (S32 j=-1; j<histmax && y > LINE_GRAPH_HEIGHT; j++)
+		for (U32 i = 0; i < cur_data.size(); ++i)
 		{
-			mBarStart.push_back(std::vector<S32>());
-			mBarEnd.push_back(std::vector<S32>());
-			int sublevel_dx[FTV_MAX_DEPTH];
-			int sublevel_left[FTV_MAX_DEPTH];
-			int sublevel_right[FTV_MAX_DEPTH];
-			S32 tidx;
-			if (j >= 0)
+			LLSD::Real time = cur_data[i][label]["Time"].asReal();
+			LLSD::Integer calls = cur_data[i][label]["Calls"].asInteger();
+
+			LLSD::Real execution = 0.0;
+			if (calls > 0)
 			{
-				tidx = j + 1 + mScrollIndex;
+				execution = time/calls;
+				cur_execution.push_back(execution);
+				cur_times.push_back(time);
 			}
-			else
+
+			cur_calls.push_back(calls);
+		}
+
+		for (U32 i = 0; i < base_data.size(); ++i)
+		{
+			LLSD::Real time = base_data[i][label]["Time"].asReal();
+			LLSD::Integer calls = base_data[i][label]["Calls"].asInteger();
+
+			LLSD::Real execution = 0.0;
+			if (calls > 0)
 			{
-				tidx = -1;
+				execution = time/calls;
+				base_execution.push_back(execution);
+				base_times.push_back(time);
 			}
-			
-			x = x_start;
-			
-			// draw the bars for each stat
-			std::vector<S32> xpos;
-			std::vector<S32> deltax;
-			xpos.push_back(x_start);
-			
-			TimeBlock* prev_id = NULL;
 
-			S32 i = 0;
-			for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-				it != end_timer_tree();
-				++it, ++i)
-			{
-				TimeBlock* idp = (*it);
-				F32 frac = tidx == -1
-					? (frame_recording.getPeriodMean(*idp) / total_time) 
-					: (frame_recording.getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value());
+			base_calls.push_back(calls);
+		}
+
+		std::sort(base_calls.begin(), base_calls.end());
+		std::sort(base_times.begin(), base_times.end());
+		std::sort(base_execution.begin(), base_execution.end());
+
+		std::sort(cur_calls.begin(), cur_calls.end());
+		std::sort(cur_times.begin(), cur_times.end());
+		std::sort(cur_execution.begin(), cur_execution.end());
+
+		//remove outliers
+		const U32 OUTLIER_CUTOFF = 512;
+		if (base_times.size() > OUTLIER_CUTOFF)
+		{ 
+			ll_remove_outliers(base_times, 1.f);
+		}
+
+		if (base_execution.size() > OUTLIER_CUTOFF)
+		{ 
+			ll_remove_outliers(base_execution, 1.f);
+		}
+
+		if (cur_times.size() > OUTLIER_CUTOFF)
+		{ 
+			ll_remove_outliers(cur_times, 1.f);
+		}
+
+		if (cur_execution.size() > OUTLIER_CUTOFF)
+		{ 
+			ll_remove_outliers(cur_execution, 1.f);
+		}
+
+
+		max_time = llmax(base_times.empty() ? 0.0 : *base_times.rbegin(), cur_times.empty() ? 0.0 : *cur_times.rbegin());
+		max_calls = llmax(base_calls.empty() ? 0 : *base_calls.rbegin(), cur_calls.empty() ? 0 : *cur_calls.rbegin());
+		max_execution = llmax(base_execution.empty() ? 0.0 : *base_execution.rbegin(), cur_execution.empty() ? 0.0 : *cur_execution.rbegin());
+
+
+		LLVector3 last_p;
+
+		//====================================
+		// basic
+		//====================================
+		buffer.clear();
+
+		last_p.clear();
+
+		LLGLDisable cull(GL_CULL_FACE);
+
+		LLVector3 base_col(0, 0.7f, 0.f);
+		LLVector3 cur_col(1.f, 0.f, 0.f);
+
+		gGL.setSceneBlendType(LLRender::BT_ADD);
+
+		gGL.color3fv(base_col.mV);
+		for (U32 i = 0; i < base_times.size(); ++i)
+		{
+			gGL.begin(LLRender::TRIANGLE_STRIP);
+			gGL.vertex3fv(last_p.mV);
+			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+			last_p.set((F32)i/(F32) base_times.size(), base_times[i]/max_time, 0.f);
+			gGL.vertex3fv(last_p.mV);
+			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+			gGL.end();
+		}
 		
-				dx = llround(frac * (F32)barw);
-				S32 prev_delta_x = deltax.empty() ? 0 : deltax.back();
-				deltax.push_back(dx);
-				
-				int level = get_depth(idp) - 1;
-				
-				while ((S32)xpos.size() > level + 1)
-				{
-					xpos.pop_back();
-				}
-				left = xpos.back();
+		gGL.flush();
+
+		
+		last_p.clear();
+		{
+			LLGLEnable blend(GL_BLEND);
+						
+			gGL.color3fv(cur_col.mV);
+			for (U32 i = 0; i < cur_times.size(); ++i)
+			{
+				gGL.begin(LLRender::TRIANGLE_STRIP);
+				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+				gGL.vertex3fv(last_p.mV);
+				last_p.set((F32) i / (F32) cur_times.size(), cur_times[i]/max_time, 0.f);
+				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+				gGL.vertex3fv(last_p.mV);
+				gGL.end();
+			}
+			
+			gGL.flush();
+		}
+
+		saveChart(label, "time", scratch);
+		
+		//======================================
+		// calls
+		//======================================
+		buffer.clear();
+
+		last_p.clear();
+
+		gGL.color3fv(base_col.mV);
+		for (U32 i = 0; i < base_calls.size(); ++i)
+		{
+			gGL.begin(LLRender::TRIANGLE_STRIP);
+			gGL.vertex3fv(last_p.mV);
+			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+			last_p.set((F32) i / (F32) base_calls.size(), (F32)base_calls[i]/max_calls, 0.f);
+			gGL.vertex3fv(last_p.mV);
+			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+			gGL.end();
+		}
+		
+		gGL.flush();
+
+		{
+			LLGLEnable blend(GL_BLEND);
+			gGL.color3fv(cur_col.mV);
+			last_p.clear();
+
+			for (U32 i = 0; i < cur_calls.size(); ++i)
+			{
+				gGL.begin(LLRender::TRIANGLE_STRIP);
+				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+				gGL.vertex3fv(last_p.mV);
+				last_p.set((F32) i / (F32) cur_calls.size(), (F32) cur_calls[i]/max_calls, 0.f);
+				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+				gGL.vertex3fv(last_p.mV);
+				gGL.end();
 				
-				if (level == 0)
-				{
-					sublevel_left[level] = x_start;
-					sublevel_dx[level] = dx;
-					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
-				}
-				else if (prev_id && get_depth(prev_id) < get_depth(idp))
-				{
-					F64 sublevelticks = 0;
-
-					for (TimeBlock::child_const_iter it = prev_id->beginChildren();
-						it != prev_id->endChildren();
-						++it)
-					{
-						sublevelticks += (tidx == -1)
-							? frame_recording.getPeriodMean(**it).value()
-							: frame_recording.getPrevRecordingPeriod(tidx).getSum(**it).value();
-					}
-
-					F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
-					sublevel_dx[level] = (int)(subfrac * (F32)barw + .5f);
-
-					if (mDisplayCenter == ALIGN_CENTER)
-					{
-						left += (prev_delta_x - sublevel_dx[level])/2;
-					}
-					else if (mDisplayCenter == ALIGN_RIGHT)
-					{
-						left += (prev_delta_x - sublevel_dx[level]);
-					}
-
-					sublevel_left[level] = left;
-					sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
-				}				
-
-				right = left + dx;
-				xpos.back() = right;
-				xpos.push_back(left);
+			}
+			
+			gGL.flush();
+		}
+
+		saveChart(label, "calls", scratch);
+
+		//======================================
+		// execution
+		//======================================
+		buffer.clear();
+
+
+		gGL.color3fv(base_col.mV);
+		U32 count = 0;
+		U32 total_count = base_execution.size();
+
+		last_p.clear();
+
+		for (std::vector<LLSD::Real>::iterator iter = base_execution.begin(); iter != base_execution.end(); ++iter)
+		{
+			gGL.begin(LLRender::TRIANGLE_STRIP);
+			gGL.vertex3fv(last_p.mV);
+			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+			last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f);
+			gGL.vertex3fv(last_p.mV);
+			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+			gGL.end();
+			count++;
+		}
+
+		last_p.clear();
 				
-				mBarStart.back().push_back(left);
-				mBarEnd.back().push_back(right);
+		{
+			LLGLEnable blend(GL_BLEND);
+			gGL.color3fv(cur_col.mV);
+			count = 0;
+			total_count = cur_execution.size();
+
+			for (std::vector<LLSD::Real>::iterator iter = cur_execution.begin(); iter != cur_execution.end(); ++iter)
+			{
+				gGL.begin(LLRender::TRIANGLE_STRIP);
+				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+				gGL.vertex3fv(last_p.mV);
+				last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f);			
+				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
+				gGL.vertex3fv(last_p.mV);
+				gGL.end();
+				count++;
+			}
 
-				top = y;
-				bottom = y - barh;
+			gGL.flush();
+		}
 
-				if (right > left)
-				{
-					//U32 rounded_edges = 0;
-					LLColor4 color = sTimerColors[idp];//*ft_display_table[i].color;
-					S32 scale_offset = 0;
-
-					BOOL is_child_of_hover_item = (idp == mHoverID);
-					TimeBlock* next_parent = idp->getParent();
-					while(!is_child_of_hover_item && next_parent)
-					{
-						is_child_of_hover_item = (mHoverID == next_parent);
-						if (next_parent->getParent() == next_parent) break;
-						next_parent = next_parent->getParent();
-					}
-
-					if (idp == mHoverID)
-					{
-						scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
-						//color = lerp(color, LLColor4::black, -0.4f);
-					}
-					else if (mHoverID != NULL && !is_child_of_hover_item)
-					{
-						color = lerp(color, LLColor4::grey, 0.8f);
-					}
-
-					gGL.color4fv(color.mV);
-					F32 start_fragment = llclamp((F32)(left - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-					F32 end_fragment = llclamp((F32)(right - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-					gl_segmented_rect_2d_fragment_tex(sublevel_left[level], top - level + scale_offset, sublevel_right[level], bottom + level - scale_offset, box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 16, start_fragment, end_fragment);
+		saveChart(label, "execution", scratch);
+	}
 
-				}
+	buffer.flush();
 
-				if ((*it)->getCollapsed())
-				{
-					it.skipDescendants();
-				}
-		
-				prev_id = idp;
+	gGL.popMatrix();
+	gGL.matrixMode(LLRender::MM_MODELVIEW);
+	gGL.popMatrix();
+}
+
+//static
+LLSD LLFastTimerView::analyzePerformanceLogDefault(std::istream& is)
+{
+	LLSD ret;
+
+	LLSD cur;
+
+	LLSD::Real total_time = 0.0;
+	LLSD::Integer total_frames = 0;
+
+	typedef std::map<std::string,LLViewerStats::StatsAccumulator> stats_map_t;
+	stats_map_t time_stats;
+	stats_map_t sample_stats;
+
+	while (!is.eof() && LLSDSerialize::fromXML(cur, is))
+	{
+		for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter)
+		{
+			std::string label = iter->first;
+
+			F64 time = iter->second["Time"].asReal();
+
+			// Skip the total figure
+			if(label.compare("Total") != 0)
+			{
+				total_time += time;
+			}			
+
+			if (time > 0.0)
+			{
+				LLSD::Integer samples = iter->second["Calls"].asInteger();
+
+				time_stats[label].push(time);
+				sample_stats[label].push(samples);
 			}
-			y -= (barh + dy);
-			if (j < 0)
-				y -= barh;
 		}
+		total_frames++;
+	}
+
+	for(stats_map_t::iterator it = time_stats.begin(); it != time_stats.end(); ++it)
+	{
+		std::string label = it->first;
+		ret[label]["TotalTime"] = time_stats[label].mSum;
+		ret[label]["MeanTime"] = time_stats[label].getMean();
+		ret[label]["MaxTime"] = time_stats[label].getMaxValue();
+		ret[label]["MinTime"] = time_stats[label].getMinValue();
+		ret[label]["StdDevTime"] = time_stats[label].getStdDev();
+		
+		ret[label]["Samples"] = sample_stats[label].mSum;
+		ret[label]["MaxSamples"] = sample_stats[label].getMaxValue();
+		ret[label]["MinSamples"] = sample_stats[label].getMinValue();
+		ret[label]["StdDevSamples"] = sample_stats[label].getStdDev();
+
+		ret[label]["Frames"] = (LLSD::Integer)time_stats[label].getCount();
 	}
+		
+	ret["SessionTime"] = total_time;
+	ret["FrameCount"] = total_frames;
+
+	return ret;
+
+}
+
+//static
+void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target, std::string output)
+{
+	// Open baseline and current target, exit if one is inexistent
+	std::ifstream base_is(baseline.c_str());
+	std::ifstream target_is(target.c_str());
+	if (!base_is.is_open() || !target_is.is_open())
+	{
+		llwarns << "'-analyzeperformance' error : baseline or current target file inexistent" << llendl;
+		base_is.close();
+		target_is.close();
+		return;
+	}
+
+	//analyze baseline
+	LLSD base = analyzePerformanceLogDefault(base_is);
+	base_is.close();
+
+	//analyze current
+	LLSD current = analyzePerformanceLogDefault(target_is);
+	target_is.close();
+
+	//output comparision
+	std::ofstream os(output.c_str());
+
+	LLSD::Real session_time = current["SessionTime"].asReal();
+	os <<
+		"Label, "
+		"% Change, "
+		"% of Session, "
+		"Cur Min, "
+		"Cur Max, "
+		"Cur Mean/sample, "
+		"Cur Mean/frame, "
+		"Cur StdDev/frame, "
+		"Cur Total, "
+		"Cur Frames, "
+		"Cur Samples, "
+		"Base Min, "
+		"Base Max, "
+		"Base Mean/sample, "
+		"Base Mean/frame, "
+		"Base StdDev/frame, "
+		"Base Total, "
+		"Base Frames, "
+		"Base Samples\n"; 
 
-	//draw line graph history
+	for (LLSD::map_iterator iter = base.beginMap();  iter != base.endMap(); ++iter)
 	{
-		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-		LLLocalClipRect clip(mGraphRect);
-			
-		//normalize based on last frame's maximum
-		static LLUnit<LLUnits::Seconds, F32> max_time = 0.000001;
-		static U32 max_calls = 0;
-		static F32 alpha_interp = 0.f;
-			
-		//display y-axis range
-		std::string tdesc;
-		if (mDisplayCalls)
-			tdesc = llformat("%d calls", (int)max_calls);
-		else if (mDisplayHz)
-			tdesc = llformat("%d Hz", (int)(1.f / max_time.value()));
-		else
-			tdesc = llformat("%4.2f ms", max_time.value());
-							
-		x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(tdesc)-5;
-		y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
- 
-		LLFontGL::getFontMonospace()->renderUTF8(tdesc, 0, x, y, LLColor4::white,
-										LLFontGL::LEFT, LLFontGL::TOP);
-
-		//highlight visible range
-		{
-			S32 first_frame = HISTORY_NUM - mScrollIndex;
-			S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
-				
-			F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1);
-				
-			F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
-			F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
-				
-			gGL.color4f(0.5f,0.5f,0.5f,0.3f);
-			gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom);
-				
-			if (mHoverBarIndex >= 0)
-			{
-				S32 bar_frame = first_frame - mHoverBarIndex;
-				F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame;
+		LLSD::String label = iter->first;
 
-				gGL.color4f(0.5f,0.5f,0.5f,1);
-				
-				gGL.begin(LLRender::LINES);
-				gGL.vertex2i((S32)bar, mGraphRect.mBottom);
-				gGL.vertex2i((S32)bar, mGraphRect.mTop);
-				gGL.end();
-			}
-		}
-			
-		LLUnit<LLUnits::Seconds, F32> cur_max = 0;
-		U32 cur_max_calls = 0;
-		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
-			it != end_timer_tree();
-			++it)
+		if (current[label]["Samples"].asInteger() == 0 ||
+			base[label]["Samples"].asInteger() == 0)
 		{
-			TimeBlock* idp = (*it);
-				
-			//fatten highlighted timer
-			if (mHoverID == idp)
-			{
-				gGL.flush();
-				glLineWidth(3);
-			}
+			//cannot compare
+			continue;
+		}	
+		LLSD::Real a = base[label]["TotalTime"].asReal() / base[label]["Samples"].asReal();
+		LLSD::Real b = current[label]["TotalTime"].asReal() / current[label]["Samples"].asReal();
 			
-			const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV;
-				
-			F32 alpha = 1.f;
-				
-			if (mHoverID != NULL &&
-				idp != mHoverID)
-			{	//fade out non-highlighted timers
-				if (idp->getParent() != mHoverID)
-				{
-					alpha = alpha_interp;
-				}
-			}
+		LLSD::Real diff = b-a;
 
-			gGL.color4f(col[0], col[1], col[2], alpha);				
-			gGL.begin(LLRender::TRIANGLE_STRIP);
-			for (U32 j = frame_recording.getNumPeriods();
-				j > 0;
-				j--)
-			{
-				LLUnit<LLUnits::Seconds, F32> time = llmax(frame_recording.getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
-				U32 calls = frame_recording.getPrevRecordingPeriod(j).getSum(idp->callCount());
-
-				if (alpha == 1.f)
-				{ 
-					//normalize to highlighted timer
-					cur_max = llmax(cur_max, time);
-					cur_max_calls = llmax(cur_max_calls, calls);
-				}
-				F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1);
-				F32 y = mDisplayHz 
-					? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
-					: mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight();
-				gGL.vertex2f(x,y);
-				gGL.vertex2f(x,mGraphRect.mBottom);
-			}
-			gGL.end();
-				
-			if (mHoverID == idp)
-			{
-				gGL.flush();
-				glLineWidth(1);
-			}
+		LLSD::Real perc = diff/a * 100;
 
-			if (idp->getCollapsed())
-			{	
-				//skip hidden timers
-				it.skipDescendants();
-			}
-		}
-			
-		//interpolate towards new maximum
-		max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f));
-		if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
-		{
-			max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max));
-		}
+		os << llformat("%s, %.2f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d\n",
+			label.c_str(), 
+			(F32) perc, 
+			(F32) (current[label]["TotalTime"].asReal()/session_time * 100.0), 
 
-		max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)));
-		if (llabs((S32)(max_calls - cur_max_calls)) <= 1)
-		{
-			max_calls = cur_max_calls;
-		}
+			(F32) current[label]["MinTime"].asReal(), 
+			(F32) current[label]["MaxTime"].asReal(), 
+			(F32) b, 
+			(F32) current[label]["MeanTime"].asReal(), 
+			(F32) current[label]["StdDevTime"].asReal(),
+			(F32) current[label]["TotalTime"].asReal(), 
+			current[label]["Frames"].asInteger(),
+			current[label]["Samples"].asInteger(),
+			(F32) base[label]["MinTime"].asReal(), 
+			(F32) base[label]["MaxTime"].asReal(), 
+			(F32) a, 
+			(F32) base[label]["MeanTime"].asReal(), 
+			(F32) base[label]["StdDevTime"].asReal(),
+			(F32) base[label]["TotalTime"].asReal(), 
+			base[label]["Frames"].asInteger(),
+			base[label]["Samples"].asInteger());			
+	}
 
-		// TODO: make sure alpha is correct in DisplayHz mode
-		F32 alpha_target = (max_time > cur_max)
-			? llmin(max_time / cur_max - 1.f,1.f) 
-			: llmin(cur_max/ max_time - 1.f,1.f);
-		alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f));
+	exportCharts(baseline, target);
+
+	os.flush();
+	os.close();
+}
 
-		if (mHoverID != NULL)
+//static
+void LLFastTimerView::outputAllMetrics()
+{
+	if (LLMetricPerformanceTesterBasic::hasMetricPerformanceTesters())
+	{
+		for (LLMetricPerformanceTesterBasic::name_tester_map_t::iterator iter = LLMetricPerformanceTesterBasic::sTesterMap.begin(); 
+			iter != LLMetricPerformanceTesterBasic::sTesterMap.end(); ++iter)
 		{
-			x = (mGraphRect.mRight + mGraphRect.mLeft)/2;
-			y = mGraphRect.mBottom + 8;
+			LLMetricPerformanceTesterBasic* tester = ((LLMetricPerformanceTesterBasic*)iter->second);	
+			tester->outputTestResults();
+		}
+	}
+}
 
-			LLFontGL::getFontMonospace()->renderUTF8(
-				mHoverID->getName(), 
-				0, 
-				x, y, 
-				LLColor4::white,
-				LLFontGL::LEFT, LLFontGL::BOTTOM);
-		}					
+//static
+void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
+{
+	if(TimeBlock::sLog)
+	{
+		doAnalysisDefault(baseline, target, output) ;
+		return ;
+	}
+
+	if(TimeBlock::sMetricLog)
+	{
+		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
+		return ;
 	}
+}
+void	LLFastTimerView::onClickCloseBtn()
+{
+	setVisible(false);
+}
 
+TimeBlock& LLFastTimerView::getFrameTimer()
+{
+	return FTM_FRAME;
+}
 
+void LLFastTimerView::printLineStats()
+{
 	// Output stats for clicked bar to log
 	if (mPrintStats >= 0)
 	{
@@ -1003,11 +984,11 @@ void LLFastTimerView::draw()
 			LLUnit<LLUnits::Seconds, F32> ticks;
 			if (mPrintStats > 0)
 			{
-				ticks = frame_recording.getPrevRecordingPeriod(mPrintStats).getSum(*idp);
+				ticks = mRecording->getPrevRecordingPeriod(mPrintStats).getSum(*idp);
 			}
 			else
 			{
-				ticks = frame_recording.getPeriodMean(*idp);
+				ticks = mRecording->getPeriodMean(*idp);
 			}
 			LLUnit<LLUnits::Milliseconds, F32> ms = ticks;
 
@@ -1021,534 +1002,567 @@ void LLFastTimerView::draw()
 		llinfos << timer_stat << llendl;
 		mPrintStats = -1;
 	}
-		
-	mHoverID = NULL;
-	mHoverBarIndex = -1;
-
-	LLView::draw();
-}
-
-F64 LLFastTimerView::getTime(const std::string& name)
-{
-	//TODO: replace calls to this with use of timer object directly
-	//llstatic_assert(false, "TODO: implement");
-	return 0.0;
-}
-
-void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch)
-{
-	//read result back into raw image
-	glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData());
-
-	//write results to disk
-	LLPointer<LLImagePNG> result = new LLImagePNG();
-	result->encode(scratch, 0.f);
-
-	std::string ext = result->getExtension();
-	std::string filename = llformat("%s_%s.%s", label.c_str(), suffix, ext.c_str());
-	
-	std::string out_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, filename);
-	result->save(out_file);
 }
 
-//static
-void LLFastTimerView::exportCharts(const std::string& base, const std::string& target)
+void LLFastTimerView::drawLineGraph()
 {
-	//allocate render target for drawing charts 
-	LLRenderTarget buffer;
-	buffer.allocate(1024,512, GL_RGB, FALSE, FALSE);
-	
-
-	LLSD cur;
-
-	LLSD base_data;
-
-	{ //read base log into memory
-		S32 i = 0;
-		std::ifstream is(base.c_str());
-		while (!is.eof() && LLSDSerialize::fromXML(cur, is))
-		{
-			base_data[i++] = cur;
-		}
-		is.close();
-	}
-
-	LLSD cur_data;
-	std::set<std::string> chart_names;
-
-	{ //read current log into memory
-		S32 i = 0;
-		std::ifstream is(target.c_str());
-		while (!is.eof() && LLSDSerialize::fromXML(cur, is))
-		{
-			cur_data[i++] = cur;
-
-			for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter)
-			{
-				std::string label = iter->first;
-				chart_names.insert(label);
-			}
-		}
-		is.close();
-	}
-
-	//get time domain
-	LLSD::Real cur_total_time = 0.0;
-
-	for (U32 i = 0; i < cur_data.size(); ++i)
-	{
-		cur_total_time += cur_data[i]["Total"]["Time"].asReal();
-	}
-
-	LLSD::Real base_total_time = 0.0;
-	for (U32 i = 0; i < base_data.size(); ++i)
-	{
-		base_total_time += base_data[i]["Total"]["Time"].asReal();
-	}
-
-	//allocate raw scratch space
-	LLPointer<LLImageRaw> scratch = new LLImageRaw(1024, 512, 3);
-
-	gGL.pushMatrix();
-	gGL.loadIdentity();
-	gGL.matrixMode(LLRender::MM_PROJECTION);
-	gGL.loadIdentity();
-	gGL.ortho(-0.05f, 1.05f, -0.05f, 1.05f, -1.0f, 1.0f);
-
-	//render charts
+	//draw line graph history
+	S32 x = mBarRect.mLeft;
+	S32 y = LINE_GRAPH_HEIGHT;
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-	
-	buffer.bindTarget();
-
-	for (std::set<std::string>::iterator iter = chart_names.begin(); iter != chart_names.end(); ++iter)
-	{
-		std::string label = *iter;
-	
-		LLSD::Real max_time = 0.0;
-		LLSD::Integer max_calls = 0;
-		LLSD::Real max_execution = 0.0;
-
-		std::vector<LLSD::Real> cur_execution;
-		std::vector<LLSD::Real> cur_times;
-		std::vector<LLSD::Integer> cur_calls;
+	LLLocalClipRect clip(mGraphRect);
+
+	//normalize based on last frame's maximum
+	static LLUnit<LLUnits::Seconds, F32> max_time = 0.000001;
+	static U32 max_calls = 0;
+	static F32 alpha_interp = 0.f;
+
+	//display y-axis range
+	std::string axis_label;
+	if (mDisplayCalls)
+		axis_label = llformat("%d calls", (int)max_calls);
+	else if (mDisplayHz)
+		axis_label = llformat("%d Hz", (int)(1.f / max_time.value()));
+	else
+		axis_label = llformat("%4.2f ms", max_time.value());
 
-		std::vector<LLSD::Real> base_execution;
-		std::vector<LLSD::Real> base_times;
-		std::vector<LLSD::Integer> base_calls;
+	x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5;
+	y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
 
-		for (U32 i = 0; i < cur_data.size(); ++i)
-		{
-			LLSD::Real time = cur_data[i][label]["Time"].asReal();
-			LLSD::Integer calls = cur_data[i][label]["Calls"].asInteger();
+	LLFontGL::getFontMonospace()->renderUTF8(axis_label, 0, x, y, LLColor4::white,
+		LLFontGL::LEFT, LLFontGL::TOP);
 
-			LLSD::Real execution = 0.0;
-			if (calls > 0)
-			{
-				execution = time/calls;
-				cur_execution.push_back(execution);
-				cur_times.push_back(time);
-			}
+	//highlight visible range
+	{
+		S32 first_frame = HISTORY_NUM - mScrollIndex;
+		S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 
-			cur_calls.push_back(calls);
-		}
+		F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1);
 
-		for (U32 i = 0; i < base_data.size(); ++i)
+		F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
+		F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
+
+		gGL.color4f(0.5f,0.5f,0.5f,0.3f);
+		gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom);
+
+		if (mHoverBarIndex >= 0)
 		{
-			LLSD::Real time = base_data[i][label]["Time"].asReal();
-			LLSD::Integer calls = base_data[i][label]["Calls"].asInteger();
+			S32 bar_frame = first_frame - mHoverBarIndex;
+			F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame;
 
-			LLSD::Real execution = 0.0;
-			if (calls > 0)
-			{
-				execution = time/calls;
-				base_execution.push_back(execution);
-				base_times.push_back(time);
-			}
+			gGL.color4f(0.5f,0.5f,0.5f,1);
 
-			base_calls.push_back(calls);
+			gGL.begin(LLRender::LINES);
+			gGL.vertex2i((S32)bar, mGraphRect.mBottom);
+			gGL.vertex2i((S32)bar, mGraphRect.mTop);
+			gGL.end();
 		}
+	}
 
-		std::sort(base_calls.begin(), base_calls.end());
-		std::sort(base_times.begin(), base_times.end());
-		std::sort(base_execution.begin(), base_execution.end());
+	LLUnit<LLUnits::Seconds, F32> cur_max = 0;
+	U32 cur_max_calls = 0;
+	for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+		it != end_timer_tree();
+		++it)
+	{
+		TimeBlock* idp = (*it);
 
-		std::sort(cur_calls.begin(), cur_calls.end());
-		std::sort(cur_times.begin(), cur_times.end());
-		std::sort(cur_execution.begin(), cur_execution.end());
+		//fatten highlighted timer
+		if (mHoverID == idp)
+		{
+			gGL.flush();
+			glLineWidth(3);
+		}
 
-		//remove outliers
-		const U32 OUTLIER_CUTOFF = 512;
-		if (base_times.size() > OUTLIER_CUTOFF)
-		{ 
-			ll_remove_outliers(base_times, 1.f);
+		const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV;
+
+		F32 alpha = 1.f;
+
+		if (mHoverID != NULL &&
+			idp != mHoverID)
+		{	//fade out non-highlighted timers
+			if (idp->getParent() != mHoverID)
+			{
+				alpha = alpha_interp;
+			}
 		}
 
-		if (base_execution.size() > OUTLIER_CUTOFF)
-		{ 
-			ll_remove_outliers(base_execution, 1.f);
+		gGL.color4f(col[0], col[1], col[2], alpha);				
+		gGL.begin(LLRender::TRIANGLE_STRIP);
+		for (U32 j = mRecording->getNumPeriods();
+			j > 0;
+			j--)
+		{
+			LLUnit<LLUnits::Seconds, F32> time = llmax(mRecording->getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
+			U32 calls = mRecording->getPrevRecordingPeriod(j).getSum(idp->callCount());
+
+			if (alpha == 1.f)
+			{ 
+				//normalize to highlighted timer
+				cur_max = llmax(cur_max, time);
+				cur_max_calls = llmax(cur_max_calls, calls);
+			}
+			F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1);
+			F32 y = mDisplayHz 
+				? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
+				: mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight();
+			gGL.vertex2f(x,y);
+			gGL.vertex2f(x,mGraphRect.mBottom);
 		}
+		gGL.end();
 
-		if (cur_times.size() > OUTLIER_CUTOFF)
-		{ 
-			ll_remove_outliers(cur_times, 1.f);
+		if (mHoverID == idp)
+		{
+			gGL.flush();
+			glLineWidth(1);
 		}
 
-		if (cur_execution.size() > OUTLIER_CUTOFF)
-		{ 
-			ll_remove_outliers(cur_execution, 1.f);
+		if (idp->getCollapsed())
+		{	
+			//skip hidden timers
+			it.skipDescendants();
 		}
+	}
 
+	//interpolate towards new maximum
+	max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f));
+	if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
+	{
+		max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max));
+	}
 
-		max_time = llmax(base_times.empty() ? 0.0 : *base_times.rbegin(), cur_times.empty() ? 0.0 : *cur_times.rbegin());
-		max_calls = llmax(base_calls.empty() ? 0 : *base_calls.rbegin(), cur_calls.empty() ? 0 : *cur_calls.rbegin());
-		max_execution = llmax(base_execution.empty() ? 0.0 : *base_execution.rbegin(), cur_execution.empty() ? 0.0 : *cur_execution.rbegin());
+	max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)));
+	if (llabs((S32)(max_calls - cur_max_calls)) <= 1)
+	{
+		max_calls = cur_max_calls;
+	}
 
+	// TODO: make sure alpha is correct in DisplayHz mode
+	F32 alpha_target = (max_time > cur_max)
+		? llmin(max_time / cur_max - 1.f,1.f) 
+		: llmin(cur_max/ max_time - 1.f,1.f);
+	alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f));
 
-		LLVector3 last_p;
+	if (mHoverID != NULL)
+	{
+		x = (mGraphRect.mRight + mGraphRect.mLeft)/2;
+		y = mGraphRect.mBottom + 8;
+
+		LLFontGL::getFontMonospace()->renderUTF8(
+			mHoverID->getName(), 
+			0, 
+			x, y, 
+			LLColor4::white,
+			LLFontGL::LEFT, LLFontGL::BOTTOM);
+	}					
+}
 
-		//====================================
-		// basic
-		//====================================
-		buffer.clear();
+void LLFastTimerView::drawLegend( S32 y )
+{
+	// draw legend
+	S32 dx;
+	S32 x = MARGIN;
+	const S32 TEXT_HEIGHT = (S32)LLFontGL::getFontMonospace()->getLineHeight();
 
-		last_p.clear();
+	{
+		LLLocalClipRect clip(LLRect(MARGIN, y, LEGEND_WIDTH, MARGIN));
+		S32 cur_line = 0;
+		ft_display_idx.clear();
+		std::map<TimeBlock*, S32> display_line;
+		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+			it != timer_tree_iterator_t();
+			++it)
+		{
+			TimeBlock* idp = (*it);
+			display_line[idp] = cur_line;
+			ft_display_idx.push_back(idp);
+			cur_line++;
 
-		LLGLDisable cull(GL_CULL_FACE);
+			x = MARGIN;
 
-		LLVector3 base_col(0, 0.7f, 0.f);
-		LLVector3 cur_col(1.f, 0.f, 0.f);
+			LLRect bar_rect(x, y, x + TEXT_HEIGHT, y - TEXT_HEIGHT);
+			S32 scale_offset = 0;
+			if (idp == mHoverID)
+			{
+				scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f);
+			}
+			bar_rect.stretch(scale_offset);
+			gl_rect_2d(bar_rect, sTimerColors[idp]);
 
-		gGL.setSceneBlendType(LLRender::BT_ADD);
+			LLUnit<LLUnits::Milliseconds, F32> ms = 0;
+			S32 calls = 0;
+			if (mHoverBarIndex > 0 && mHoverID)
+			{
+				S32 hidx = mScrollIndex + mHoverBarIndex;
+				ms = mRecording->getPrevRecordingPeriod(hidx).getSum(*idp);
+				calls = mRecording->getPrevRecordingPeriod(hidx).getSum(idp->callCount());
+			}
+			else
+			{
+				ms = LLUnit<LLUnits::Seconds, F64>(mRecording->getPeriodMean(*idp));
+				calls = (S32)mRecording->getPeriodMean(idp->callCount());
+			}
 
-		gGL.color3fv(base_col.mV);
-		for (U32 i = 0; i < base_times.size(); ++i)
-		{
-			gGL.begin(LLRender::TRIANGLE_STRIP);
-			gGL.vertex3fv(last_p.mV);
-			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-			last_p.set((F32)i/(F32) base_times.size(), base_times[i]/max_time, 0.f);
-			gGL.vertex3fv(last_p.mV);
-			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-			gGL.end();
-		}
-		
-		gGL.flush();
+			std::string timer_label;
+			if (mDisplayCalls)
+			{
+				timer_label = llformat("%s (%d)",idp->getName().c_str(),calls);
+			}
+			else
+			{
+				timer_label = llformat("%s [%.1f]",idp->getName().c_str(),ms.value());
+			}
+			dx = (TEXT_HEIGHT+4) + get_depth(idp)*8;
 
-		
-		last_p.clear();
-		{
-			LLGLEnable blend(GL_BLEND);
-						
-			gGL.color3fv(cur_col.mV);
-			for (U32 i = 0; i < cur_times.size(); ++i)
+			LLColor4 color = LLColor4::white;
+			if (get_depth(idp) > 0)
 			{
-				gGL.begin(LLRender::TRIANGLE_STRIP);
-				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-				gGL.vertex3fv(last_p.mV);
-				last_p.set((F32) i / (F32) cur_times.size(), cur_times[i]/max_time, 0.f);
-				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-				gGL.vertex3fv(last_p.mV);
-				gGL.end();
+				S32 line_start_y = bar_rect.getCenterY();
+				S32 line_end_y = line_start_y + ((TEXT_HEIGHT + 2) * (cur_line - display_line[idp->getParent()])) - TEXT_HEIGHT;
+				gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color);
+				S32 line_x = x + (TEXT_HEIGHT + 4) + ((get_depth(idp) - 1) * 8);
+				gl_line_2d(line_x, line_start_y, line_x, line_end_y, color);
+				if (idp->getCollapsed() && !idp->getChildren().empty())
+				{
+					gl_line_2d(line_x+4, line_start_y-3, line_x+4, line_start_y+4, color);
+				}
 			}
-			
-			gGL.flush();
-		}
 
-		saveChart(label, "time", scratch);
-		
-		//======================================
-		// calls
-		//======================================
-		buffer.clear();
+			x += dx;
+			BOOL is_child_of_hover_item = (idp == mHoverID);
+			TimeBlock* next_parent = idp->getParent();
+			while(!is_child_of_hover_item && next_parent)
+			{
+				is_child_of_hover_item = (mHoverID == next_parent);
+				if (next_parent->getParent() == next_parent) break;
+				next_parent = next_parent->getParent();
+			}
 
-		last_p.clear();
+			LLFontGL::getFontMonospace()->renderUTF8(timer_label, 0, 
+				x, y, 
+				color, 
+				LLFontGL::LEFT, LLFontGL::TOP, 
+				is_child_of_hover_item ? LLFontGL::BOLD : LLFontGL::NORMAL);
 
-		gGL.color3fv(base_col.mV);
-		for (U32 i = 0; i < base_calls.size(); ++i)
-		{
-			gGL.begin(LLRender::TRIANGLE_STRIP);
-			gGL.vertex3fv(last_p.mV);
-			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-			last_p.set((F32) i / (F32) base_calls.size(), (F32)base_calls[i]/max_calls, 0.f);
-			gGL.vertex3fv(last_p.mV);
-			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-			gGL.end();
+			y -= (TEXT_HEIGHT + 2);
+
+			if (idp->getCollapsed()) 
+			{
+				it.skipDescendants();
+			}
 		}
-		
-		gGL.flush();
+	}
+}
+
+void LLFastTimerView::generateUniqueColors()
+{
+	// generate unique colors
+	{
+		sTimerColors[&getFrameTimer()] = LLColor4::grey;
+
+		F32 hue = 0.f;
 
+		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+			it != timer_tree_iterator_t();
+			++it)
 		{
-			LLGLEnable blend(GL_BLEND);
-			gGL.color3fv(cur_col.mV);
-			last_p.clear();
+			TimeBlock* idp = (*it);
 
-			for (U32 i = 0; i < cur_calls.size(); ++i)
-			{
-				gGL.begin(LLRender::TRIANGLE_STRIP);
-				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-				gGL.vertex3fv(last_p.mV);
-				last_p.set((F32) i / (F32) cur_calls.size(), (F32) cur_calls[i]/max_calls, 0.f);
-				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-				gGL.vertex3fv(last_p.mV);
-				gGL.end();
-				
-			}
-			
-			gGL.flush();
+			const F32 HUE_INCREMENT = 0.23f;
+			hue = fmodf(hue + HUE_INCREMENT, 1.f);
+			// saturation increases with depth
+			F32 saturation = clamp_rescale((F32)get_depth(idp), 0.f, 3.f, 0.f, 1.f);
+			// lightness alternates with depth
+			F32 lightness = get_depth(idp) % 2 ? 0.5f : 0.6f;
+
+			LLColor4 child_color;
+			child_color.setHSL(hue, saturation, lightness);
+
+			sTimerColors[idp] = child_color;
 		}
+	}
+}
 
-		saveChart(label, "calls", scratch);
+S32 LLFastTimerView::drawHelp( S32 y )
+{
+	// Draw some help
+	{
+		const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
 
-		//======================================
-		// execution
-		//======================================
-		buffer.clear();
+		char modedesc[][32] = {
+			"2 x Average ",
+			"Max         ",
+			"Recent Max  ",
+			"100 ms      "
+		};
+		char centerdesc[][32] = {
+			"Left      ",
+			"Centered  ",
+			"Ordered   "
+		};
+
+		std::string text;
+		text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]);
+		LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+
+		y -= (texth + 2);
+		text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]);
+		LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+		y -= (texth + 2);
+
+		LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"),
+			0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+		y -= (texth + 2);
+	}	return y;
+}
+
+void LLFastTimerView::drawTicks( LLUnit<LLUnits::Seconds, F64> total_time )
+{
+	// Draw MS ticks
+	{
+		LLUnit<LLUnits::Milliseconds, U32> ms = total_time;
+		std::string tick_label;
+		S32 x;
+		S32 barw = mBarRect.getWidth();
+
+		tick_label = llformat("%.1f ms |", (F32)ms.value()*.25f);
+		x = mBarRect.mLeft + barw/4 - LLFontGL::getFontMonospace()->getWidth(tick_label);
+		LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white,
+			LLFontGL::LEFT, LLFontGL::TOP);
+
+		tick_label = llformat("%.1f ms |", (F32)ms.value()*.50f);
+		x = mBarRect.mLeft + barw/2 - LLFontGL::getFontMonospace()->getWidth(tick_label);
+		LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white,
+			LLFontGL::LEFT, LLFontGL::TOP);
+
+		tick_label = llformat("%.1f ms |", (F32)ms.value()*.75f);
+		x = mBarRect.mLeft + (barw*3)/4 - LLFontGL::getFontMonospace()->getWidth(tick_label);
+		LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white,
+			LLFontGL::LEFT, LLFontGL::TOP);
+
+		tick_label = llformat( "%d ms |", (U32)ms.value());
+		x = mBarRect.mLeft + barw - LLFontGL::getFontMonospace()->getWidth(tick_label);
+		LLFontGL::getFontMonospace()->renderUTF8(tick_label, 0, x, mBarRect.mTop, LLColor4::white,
+			LLFontGL::LEFT, LLFontGL::TOP);
+	}
+}
+
+void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32 dy )
+{
+	// Draw borders
+	{
+		S32 by = y + 6 + (S32)LLFontGL::getFontMonospace()->getLineHeight();	
+
+		//heading
+		gl_rect_2d(x_start-5, by, getRect().getWidth()-5, y+5, LLColor4::grey, FALSE);
 
+		//tree view
+		gl_rect_2d(5, by, x_start-10, 5, LLColor4::grey, FALSE);
 
-		gGL.color3fv(base_col.mV);
-		U32 count = 0;
-		U32 total_count = base_execution.size();
+		by = y + 5;
+		//average bar
+		gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-bar_height-dy-5, LLColor4::grey, FALSE);
 
-		last_p.clear();
+		by -= bar_height*2+dy;
 
-		for (std::vector<LLSD::Real>::iterator iter = base_execution.begin(); iter != base_execution.end(); ++iter)
-		{
-			gGL.begin(LLRender::TRIANGLE_STRIP);
-			gGL.vertex3fv(last_p.mV);
-			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-			last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f);
-			gGL.vertex3fv(last_p.mV);
-			gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-			gGL.end();
-			count++;
-		}
+		//current frame bar
+		gl_rect_2d(x_start-5, by, getRect().getWidth()-5, by-bar_height-dy-2, LLColor4::grey, FALSE);
 
-		last_p.clear();
-				
-		{
-			LLGLEnable blend(GL_BLEND);
-			gGL.color3fv(cur_col.mV);
-			count = 0;
-			total_count = cur_execution.size();
+		by -= bar_height+dy+1;
 
-			for (std::vector<LLSD::Real>::iterator iter = cur_execution.begin(); iter != cur_execution.end(); ++iter)
-			{
-				gGL.begin(LLRender::TRIANGLE_STRIP);
-				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-				gGL.vertex3fv(last_p.mV);
-				last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f);			
-				gGL.vertex3f(last_p.mV[0], 0.f, 0.f);
-				gGL.vertex3fv(last_p.mV);
-				gGL.end();
-				count++;
-			}
+		//history bars
+		gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-bar_height-dy-2, LLColor4::grey, FALSE);			
 
-			gGL.flush();
-		}
+		by = LINE_GRAPH_HEIGHT-bar_height-dy-7;
 
-		saveChart(label, "execution", scratch);
-	}
+		//line graph
+		mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5);
 
-	buffer.flush();
+		gl_rect_2d(mGraphRect, FALSE);
+	}
+}
 
-	gGL.popMatrix();
-	gGL.matrixMode(LLRender::MM_MODELVIEW);
-	gGL.popMatrix();
+LLUnit<LLUnits::Seconds, F64> LLFastTimerView::getTotalTime()
+{
+	LLUnit<LLUnits::Seconds, F64> total_time;
+	switch(mDisplayMode)
+	{
+	case 0:
+		total_time = mRecording->getPeriodMean(getFrameTimer())*2;
+		break;
+	case 1:
+		total_time = mAllTimeMax;
+		break;
+	case 2:
+		// Calculate the max total ticks for the current history
+		total_time = mRecording->getPeriodMax(getFrameTimer());
+		break;
+	default:
+		total_time = LLUnit<LLUnits::Milliseconds, F32>(100);
+		break;
+	}
+	return total_time;
 }
 
-//static
-LLSD LLFastTimerView::analyzePerformanceLogDefault(std::istream& is)
+void LLFastTimerView::drawBars()
 {
-	LLSD ret;
+	LLUnit<LLUnits::Seconds, F64> total_time = getTotalTime();
+	if (total_time <= 0.0) return;
 
-	LLSD cur;
+	LLPointer<LLUIImage> box_imagep = LLUI::getUIImage("Rounded_Square");
+	LLLocalClipRect clip(mBarRect);
 
-	LLSD::Real total_time = 0.0;
-	LLSD::Integer total_frames = 0;
+	S32 bar_height = (mBarRect.mTop - MARGIN - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2);
+	S32 vpad = llmax(1, bar_height / 4); // spacing between bars
+	bar_height -= vpad;
 
-	typedef std::map<std::string,LLViewerStats::StatsAccumulator> stats_map_t;
-	stats_map_t time_stats;
-	stats_map_t sample_stats;
+	drawTicks(total_time);
+	S32 y = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
+	drawBorders(y, mBarRect.mLeft, bar_height, vpad);
 
-	while (!is.eof() && LLSDSerialize::fromXML(cur, is))
+	// Draw bars for each history entry
+	// Special: -1 = show running average
+	gGL.getTexUnit(0)->bind(box_imagep->getImage());
+	const S32 histmax = llmin(mRecording->getNumPeriods()+1, MAX_VISIBLE_HISTORY);
+
+	for (S32 j = -1; j < histmax && y > LINE_GRAPH_HEIGHT; j++)
 	{
-		for (LLSD::map_iterator iter = cur.beginMap(); iter != cur.endMap(); ++iter)
+		mBarRects[llmax(j, 0)].clear();
+		int sublevel_dx[FTV_MAX_DEPTH];
+		int sublevel_left[FTV_MAX_DEPTH];
+		int sublevel_right[FTV_MAX_DEPTH];
+		S32 tidx = (j >= 0)
+			? j + 1 + mScrollIndex
+			: -1;
+
+		// draw the bars for each stat
+		std::vector<S32> xpos;
+		S32 deltax = 0;
+		xpos.push_back(mBarRect.mLeft);
+
+		TimeBlock* prev_id = NULL;
+
+		S32 i = 0;
+		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+			it != end_timer_tree();
+			++it, ++i)
 		{
-			std::string label = iter->first;
+			TimeBlock* idp = (*it);
+			F32 frac = tidx == -1
+				? (mRecording->getPeriodMean(*idp) / total_time) 
+				: (mRecording->getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value());
 
-			F64 time = iter->second["Time"].asReal();
+			S32 dx = llround(frac * (F32)mBarRect.getWidth());
+			S32 prev_delta_x = deltax;
+			deltax = dx;
 
-			// Skip the total figure
-			if(label.compare("Total") != 0)
+			const int level = get_depth(idp) - 1;
+			while ((S32)xpos.size() > level + 1)
 			{
-				total_time += time;
-			}			
+				xpos.pop_back();
+			}
 
-			if (time > 0.0)
-			{
-				LLSD::Integer samples = iter->second["Calls"].asInteger();
+			LLRect bar_rect;
+			bar_rect.setLeftTopAndSize(xpos.back(), y, dx, bar_height);
+			mBarRects[llmax(j, 0)].push_back(bar_rect);
 
-				time_stats[label].push(time);
-				sample_stats[label].push(samples);
+			if (level == 0)
+			{
+				sublevel_left[level] = mBarRect.mLeft;
+				sublevel_dx[level] = dx;
+				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
 			}
-		}
-		total_frames++;
-	}
+			else if (prev_id && get_depth(prev_id) < get_depth(idp))
+			{
+				F64 sublevelticks = 0;
 
-	for(stats_map_t::iterator it = time_stats.begin(); it != time_stats.end(); ++it)
-	{
-		std::string label = it->first;
-		ret[label]["TotalTime"] = time_stats[label].mSum;
-		ret[label]["MeanTime"] = time_stats[label].getMean();
-		ret[label]["MaxTime"] = time_stats[label].getMaxValue();
-		ret[label]["MinTime"] = time_stats[label].getMinValue();
-		ret[label]["StdDevTime"] = time_stats[label].getStdDev();
-		
-		ret[label]["Samples"] = sample_stats[label].mSum;
-		ret[label]["MaxSamples"] = sample_stats[label].getMaxValue();
-		ret[label]["MinSamples"] = sample_stats[label].getMinValue();
-		ret[label]["StdDevSamples"] = sample_stats[label].getStdDev();
+				for (TimeBlock::child_const_iter it = prev_id->beginChildren();
+					it != prev_id->endChildren();
+					++it)
+				{
+					sublevelticks += (tidx == -1)
+						? mRecording->getPeriodMean(**it).value()
+						: mRecording->getPrevRecordingPeriod(tidx).getSum(**it).value();
+				}
 
-		ret[label]["Frames"] = (LLSD::Integer)time_stats[label].getCount();
-	}
-		
-	ret["SessionTime"] = total_time;
-	ret["FrameCount"] = total_frames;
+				F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
+				sublevel_dx[level] = (int)(subfrac * (F32)mBarRect.getWidth() + .5f);
 
-	return ret;
+				if (mDisplayCenter == ALIGN_CENTER)
+				{
+					bar_rect.mLeft += (prev_delta_x - sublevel_dx[level])/2;
+				}
+				else if (mDisplayCenter == ALIGN_RIGHT)
+				{
+					bar_rect.mLeft += (prev_delta_x - sublevel_dx[level]);
+				}
 
-}
+				sublevel_left[level] = bar_rect.mLeft;
+				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
+			}				
 
-//static
-void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target, std::string output)
-{
-	// Open baseline and current target, exit if one is inexistent
-	std::ifstream base_is(baseline.c_str());
-	std::ifstream target_is(target.c_str());
-	if (!base_is.is_open() || !target_is.is_open())
-	{
-		llwarns << "'-analyzeperformance' error : baseline or current target file inexistent" << llendl;
-		base_is.close();
-		target_is.close();
-		return;
-	}
+			xpos.back() = bar_rect.mRight;
+			xpos.push_back(bar_rect.mLeft);
 
-	//analyze baseline
-	LLSD base = analyzePerformanceLogDefault(base_is);
-	base_is.close();
+			if (bar_rect.getWidth() > 0)
+			{
+				LLColor4 color = sTimerColors[idp];
+				S32 scale_offset = 0;
 
-	//analyze current
-	LLSD current = analyzePerformanceLogDefault(target_is);
-	target_is.close();
+				BOOL is_child_of_hover_item = (idp == mHoverID);
+				TimeBlock* next_parent = idp->getParent();
+				while(!is_child_of_hover_item && next_parent)
+				{
+					is_child_of_hover_item = (mHoverID == next_parent);
+					if (next_parent->getParent() == next_parent) break;
+					next_parent = next_parent->getParent();
+				}
 
-	//output comparision
-	std::ofstream os(output.c_str());
+				if (idp == mHoverID)
+				{
+					scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
+					//color = lerp(color, LLColor4::black, -0.4f);
+				}
+				else if (mHoverID != NULL && !is_child_of_hover_item)
+				{
+					color = lerp(color, LLColor4::grey, 0.8f);
+				}
 
-	LLSD::Real session_time = current["SessionTime"].asReal();
-	os <<
-		"Label, "
-		"% Change, "
-		"% of Session, "
-		"Cur Min, "
-		"Cur Max, "
-		"Cur Mean/sample, "
-		"Cur Mean/frame, "
-		"Cur StdDev/frame, "
-		"Cur Total, "
-		"Cur Frames, "
-		"Cur Samples, "
-		"Base Min, "
-		"Base Max, "
-		"Base Mean/sample, "
-		"Base Mean/frame, "
-		"Base StdDev/frame, "
-		"Base Total, "
-		"Base Frames, "
-		"Base Samples\n"; 
+				gGL.color4fv(color.mV);
+				F32 start_fragment = llclamp((F32)(bar_rect.mLeft - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
+				F32 end_fragment = llclamp((F32)(bar_rect.mRight - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
+				gl_segmented_rect_2d_fragment_tex(
+					sublevel_left[level], 
+					bar_rect.mTop - level + scale_offset, 
+					sublevel_right[level], 
+					bar_rect.mBottom + level - scale_offset, 
+					box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 
+					16, 
+					start_fragment, end_fragment);
+			}
 
-	for (LLSD::map_iterator iter = base.beginMap();  iter != base.endMap(); ++iter)
-	{
-		LLSD::String label = iter->first;
+			if ((*it)->getCollapsed())
+			{
+				it.skipDescendants();
+			}
+
+			prev_id = idp;
+		}
+		y -= (bar_height + vpad);
+		if (j < 0)
+			y -= bar_height;
+	}
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+}
 
-		if (current[label]["Samples"].asInteger() == 0 ||
-			base[label]["Samples"].asInteger() == 0)
-		{
-			//cannot compare
-			continue;
-		}	
-		LLSD::Real a = base[label]["TotalTime"].asReal() / base[label]["Samples"].asReal();
-		LLSD::Real b = current[label]["TotalTime"].asReal() / current[label]["Samples"].asReal();
-			
-		LLSD::Real diff = b-a;
 
-		LLSD::Real perc = diff/a * 100;
 
-		os << llformat("%s, %.2f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d, %.4f, %.4f, %.4f, %.4f, %.4f, %.4f, %d, %d\n",
-			label.c_str(), 
-			(F32) perc, 
-			(F32) (current[label]["TotalTime"].asReal()/session_time * 100.0), 
 
-			(F32) current[label]["MinTime"].asReal(), 
-			(F32) current[label]["MaxTime"].asReal(), 
-			(F32) b, 
-			(F32) current[label]["MeanTime"].asReal(), 
-			(F32) current[label]["StdDevTime"].asReal(),
-			(F32) current[label]["TotalTime"].asReal(), 
-			current[label]["Frames"].asInteger(),
-			current[label]["Samples"].asInteger(),
-			(F32) base[label]["MinTime"].asReal(), 
-			(F32) base[label]["MaxTime"].asReal(), 
-			(F32) a, 
-			(F32) base[label]["MeanTime"].asReal(), 
-			(F32) base[label]["StdDevTime"].asReal(),
-			(F32) base[label]["TotalTime"].asReal(), 
-			base[label]["Frames"].asInteger(),
-			base[label]["Samples"].asInteger());			
-	}
 
-	exportCharts(baseline, target);
 
-	os.flush();
-	os.close();
-}
 
-//static
-void LLFastTimerView::outputAllMetrics()
-{
-	if (LLMetricPerformanceTesterBasic::hasMetricPerformanceTesters())
-	{
-		for (LLMetricPerformanceTesterBasic::name_tester_map_t::iterator iter = LLMetricPerformanceTesterBasic::sTesterMap.begin(); 
-			iter != LLMetricPerformanceTesterBasic::sTesterMap.end(); ++iter)
-		{
-			LLMetricPerformanceTesterBasic* tester = ((LLMetricPerformanceTesterBasic*)iter->second);	
-			tester->outputTestResults();
-		}
-	}
-}
 
-//static
-void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
-{
-	if(TimeBlock::sLog)
-	{
-		doAnalysisDefault(baseline, target, output) ;
-		return ;
-	}
 
-	if(TimeBlock::sMetricLog)
-	{
-		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
-		return ;
-	}
-}
-void	LLFastTimerView::onClickCloseBtn()
-{
-	setVisible(false);
-}
 
-TimeBlock& LLFastTimerView::getFrameTimer()
-{
-	return FTM_FRAME;
-}
 
 
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 07662bb795..09be137027 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -62,15 +62,28 @@ public:
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
 
+
+
 	LLTrace::TimeBlock* getLegendID(S32 y);
 	F64 getTime(const std::string& name);
 
 protected:
 	virtual	void	onClickCloseBtn();
+
 private:	
-	typedef std::vector<std::vector<S32> > bar_positions_t;
-	bar_positions_t mBarStart;
-	bar_positions_t mBarEnd;
+	void drawTicks(LLUnit<LLUnits::Seconds, F64> total_time);
+	void drawLineGraph();
+	void drawLegend(S32 y);
+	S32 drawHelp(S32 y);
+	void drawBorders( S32 y, const S32 x_start, S32 barh, S32 dy);
+	void drawBars();
+
+	void printLineStats();
+	void generateUniqueColors();
+	LLUnit<LLUnits::Seconds, F64> getTotalTime();
+
+
+	std::vector<LLRect>* mBarRects;
 	S32 mDisplayMode;
 
 	typedef enum child_alignment
-- 
cgit v1.2.3


From 173806c4b1d18fe0188c1d189e7044fa977268ae Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 24 Jan 2013 17:10:37 -0700
Subject: for SH-3665: more post processing of the frame difference image

---
 .../class1/interface/twotexturecompareF.glsl       | 17 +++++
 indra/newview/llscenemonitor.cpp                   | 76 ++++++++++++++++++++++
 indra/newview/llscenemonitor.h                     |  8 +++
 indra/newview/llviewershadermgr.cpp                |  1 +
 4 files changed, 102 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
index 050114b37e..6eeb2596b2 100644
--- a/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/twotexturecompareF.glsl
@@ -31,6 +31,10 @@ out vec4 frag_color;
 
 uniform sampler2D tex0;
 uniform sampler2D tex1;
+uniform sampler2D dither_tex;
+uniform float dither_scale;
+uniform float dither_scale_s;
+uniform float dither_scale_t;
 
 VARYING vec2 vary_texcoord0;
 VARYING vec2 vary_texcoord1;
@@ -38,4 +42,17 @@ VARYING vec2 vary_texcoord1;
 void main() 
 {
 	frag_color = abs(texture2D(tex0, vary_texcoord0.xy) - texture2D(tex1, vary_texcoord0.xy));
+
+	vec2 dither_coord;
+	dither_coord[0] = vary_texcoord0[0] * dither_scale_s;
+	dither_coord[1] = vary_texcoord0[1] * dither_scale_t;
+	vec4 dither_vec = texture(dither_tex, dither_coord.xy);
+
+	for(int i = 0; i < 3; i++)
+	{
+		if(frag_color[i] < dither_vec[i] * dither_scale)
+		{
+			frag_color[i] = 0.f;
+		}
+	}
 }
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 2f1c4e065a..9de6b52d12 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -86,6 +86,7 @@ void LLSceneMonitor::destroyClass()
 
 	delete mRecording;
 	mRecording = NULL;
+	mDitheringTexture = NULL;
 }
 
 void LLSceneMonitor::reset()
@@ -108,6 +109,67 @@ void LLSceneMonitor::reset()
 	}
 }
 
+void LLSceneMonitor::generateDitheringTexture(S32 width, S32 height)
+{
+#if 1
+	//4 * 4 matrix
+	mDitherMatrixWidth = 4;	
+	S32 dither_matrix[4][4] = 
+	{
+		{1, 9, 3, 11}, 
+		{13, 5, 15, 7}, 
+		{4, 12, 2, 10}, 
+		{16, 8, 14, 6}
+	};
+	
+	mDitherScale = 255.f / 17;
+#else
+	//8 * 8 matrix
+	mDitherMatrixWidth = 16;	
+	S32 dither_matrix[16][16] = 
+	{
+		{1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, 
+		{33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, 
+		{9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, 
+		{41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24},
+		{3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62},
+		{35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30},
+		{11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54},
+		{43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22},
+		{1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, 
+		{33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, 
+		{9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, 
+		{41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24},
+		{3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62},
+		{35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30},
+		{11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54},
+		{43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22}
+	};
+
+	mDitherScale = 255.f / 65;
+#endif
+
+	LLPointer<LLImageRaw> image_raw = new LLImageRaw(mDitherMatrixWidth, mDitherMatrixWidth, 3);
+	U8* data = image_raw->getData();
+	for (S32 i = 0; i < mDitherMatrixWidth; i++)
+	{
+		for (S32 j = 0; j < mDitherMatrixWidth; j++)
+		{
+			U8 val = dither_matrix[i][j];
+			*data++ = val;
+			*data++ = val;
+			*data++ = val;
+		}
+	}
+
+	mDitheringTexture = LLViewerTextureManager::getLocalTexture(image_raw.get(), FALSE) ;
+	mDitheringTexture->setAddressMode(LLTexUnit::TAM_WRAP);
+	mDitheringTexture->setFilteringOption(LLTexUnit::TFO_POINT);
+	
+	mDitherScaleS = (F32)width / mDitherMatrixWidth;
+	mDitherScaleT = (F32)height / mDitherMatrixWidth;
+}
+
 void LLSceneMonitor::setDebugViewerVisible(BOOL visible) 
 {
 	mDebugViewerVisible = visible;
@@ -287,10 +349,13 @@ void LLSceneMonitor::compare()
 	{
 		mDiff = new LLRenderTarget();
 		mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true);
+
+		generateDitheringTexture(width, height);
 	}
 	else if(mDiff->getWidth() != width || mDiff->getHeight() != height)
 	{
 		mDiff->resize(width, height, GL_RGBA);
+		generateDitheringTexture(width, height);
 	}
 
 	mDiff->bindTarget();
@@ -298,6 +363,10 @@ void LLSceneMonitor::compare()
 	
 	gTwoTextureCompareProgram.bind();
 	
+	gTwoTextureCompareProgram.uniform1f("dither_scale", mDitherScale);
+	gTwoTextureCompareProgram.uniform1f("dither_scale_s", mDitherScaleS);
+	gTwoTextureCompareProgram.uniform1f("dither_scale_t", mDitherScaleT);
+
 	gGL.getTexUnit(0)->activate();
 	gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(0)->bind(mFrames[0]);
@@ -308,6 +377,11 @@ void LLSceneMonitor::compare()
 	gGL.getTexUnit(1)->bind(mFrames[1]);
 	gGL.getTexUnit(1)->activate();	
 	
+	gGL.getTexUnit(2)->activate();
+	gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(2)->bind(mDitheringTexture);
+	gGL.getTexUnit(2)->activate();	
+
 	gl_rect_2d_simple_tex(width, height);
 	
 	mDiff->flush();	
@@ -318,6 +392,8 @@ void LLSceneMonitor::compare()
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(1)->disable();
 	gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(2)->disable();
+	gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE);
 
 	mHasNewDiff = TRUE;
 	
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 93e6c20bb9..709650e206 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -35,6 +35,7 @@
 
 class LLCharacter;
 class LLRenderTarget;
+class LLViewerTexture;
 
 class LLSceneMonitor :  public LLSingleton<LLSceneMonitor>
 {
@@ -69,6 +70,7 @@ private:
 	void unfreezeScene();
 	void reset();
 	bool preCapture();
+	void generateDitheringTexture(S32 width, S32 height);
 
 private:
 	BOOL mEnabled;
@@ -88,6 +90,12 @@ private:
 	F32     mSamplingTime; //time interval to capture frames, in seconds
 	F32     mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension
 
+	LLPointer<LLViewerTexture> mDitheringTexture;
+	S32                        mDitherMatrixWidth;
+	F32                        mDitherScale;
+	F32                        mDitherScaleS;
+	F32                        mDitherScaleT;
+
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
 
 	LLTrace::ExtendableRecording* mRecording;
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 1aa36eafee..dd86ef4f34 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -2723,6 +2723,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
 			gTwoTextureCompareProgram.bind();
 			gTwoTextureCompareProgram.uniform1i("tex0", 0);
 			gTwoTextureCompareProgram.uniform1i("tex1", 1);
+			gTwoTextureCompareProgram.uniform1i("dither_tex", 2);
 		}
 	}
 
-- 
cgit v1.2.3


From 3660f8b632d1288cefeeff66c3b62522b4bbacbc Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 24 Jan 2013 17:11:33 -0700
Subject: more for SH-3653: Can we repurpose
 ObjectUpdateCached:ObjectData:UpdateFlags field to carry spatial+size data?

---
 indra/newview/llviewerregion.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 45d43bdf74..e5cb2a1b08 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1724,13 +1724,13 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id)
 //estimate weight of cache missed object
 F32 LLViewerRegion::calcObjectWeight(U32 flags)
 {
-	LLVector3 pos((F32)(flags & 0xff), (F32)((flags >> 8) & 0xff), (F32)((flags >> 16) & 0xff) * 16.f);
+	LLVector3 pos((F32)(flags & 0xff) + 0.5f, (F32)((flags >> 8) & 0xff) + 0.5f, (F32)((flags >> 16) & 0xff) * 16.f + 8.0f);
 	F32 rad = (F32)((flags >> 24) & 0xff);
 
 	pos += getOriginAgent();
 	pos -= LLViewerCamera::getInstance()->getOrigin();
 
-	return rad * rad / pos.lengthSquared();
+	return 100.f * rad * rad / pos.lengthSquared();
 }
 
 void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight)
-- 
cgit v1.2.3


From 3a555a2ff84d9b340e33673d7a03f37c966f06e6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 24 Jan 2013 19:53:17 -0800
Subject: SH-3275 WIP interesting Update viewer metrics system to be more
 flexible removed LLFastTimerView::getFrameTimer() dead code elimination fixed
 off by one array access crash

---
 indra/newview/llfasttimerview.cpp | 31 +++++++++++++------------------
 indra/newview/llfasttimerview.h   |  1 -
 2 files changed, 13 insertions(+), 19 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 59a52fdaea..7858378f00 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -107,7 +107,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mRecording(&get_frame_recording()),
 	mPauseHistory(false)
 {
-	mBarRects = new std::vector<LLRect>[MAX_VISIBLE_HISTORY];
+	mBarRects = new std::vector<LLRect>[MAX_VISIBLE_HISTORY + 1];
 }
 
 LLFastTimerView::~LLFastTimerView()
@@ -189,7 +189,7 @@ TimeBlock* LLFastTimerView::getLegendID(S32 y)
 
 BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask)
 {
-	for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+	for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 		it != end_timer_tree();
 		++it)
 	{
@@ -277,7 +277,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 		}
 
 		S32 i = 0;
-		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 			it != end_timer_tree();
 			++it, ++i)
 		{
@@ -412,7 +412,7 @@ void LLFastTimerView::draw()
 	printLineStats();
 	LLView::draw();
 		
-	mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(getFrameTimer()));
+	mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(FTM_FRAME));
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
 }
@@ -935,11 +935,6 @@ void	LLFastTimerView::onClickCloseBtn()
 	setVisible(false);
 }
 
-TimeBlock& LLFastTimerView::getFrameTimer()
-{
-	return FTM_FRAME;
-}
-
 void LLFastTimerView::printLineStats()
 {
 	// Output stats for clicked bar to log
@@ -947,7 +942,7 @@ void LLFastTimerView::printLineStats()
 	{
 		std::string legend_stat;
 		bool first = true;
-		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 			it != end_timer_tree();
 			++it)
 		{
@@ -969,7 +964,7 @@ void LLFastTimerView::printLineStats()
 
 		std::string timer_stat;
 		first = true;
-		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 			it != end_timer_tree();
 			++it)
 		{
@@ -1061,7 +1056,7 @@ void LLFastTimerView::drawLineGraph()
 
 	LLUnit<LLUnits::Seconds, F32> cur_max = 0;
 	U32 cur_max_calls = 0;
-	for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+	for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 		it != end_timer_tree();
 		++it)
 	{
@@ -1169,7 +1164,7 @@ void LLFastTimerView::drawLegend( S32 y )
 		S32 cur_line = 0;
 		ft_display_idx.clear();
 		std::map<TimeBlock*, S32> display_line;
-		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+		for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 			it != timer_tree_iterator_t();
 			++it)
 		{
@@ -1258,11 +1253,11 @@ void LLFastTimerView::generateUniqueColors()
 {
 	// generate unique colors
 	{
-		sTimerColors[&getFrameTimer()] = LLColor4::grey;
+		sTimerColors[&FTM_FRAME] = LLColor4::grey;
 
 		F32 hue = 0.f;
 
-		for (timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+		for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 			it != timer_tree_iterator_t();
 			++it)
 		{
@@ -1388,14 +1383,14 @@ LLUnit<LLUnits::Seconds, F64> LLFastTimerView::getTotalTime()
 	switch(mDisplayMode)
 	{
 	case 0:
-		total_time = mRecording->getPeriodMean(getFrameTimer())*2;
+		total_time = mRecording->getPeriodMean(FTM_FRAME)*2;
 		break;
 	case 1:
 		total_time = mAllTimeMax;
 		break;
 	case 2:
 		// Calculate the max total ticks for the current history
-		total_time = mRecording->getPeriodMax(getFrameTimer());
+		total_time = mRecording->getPeriodMax(FTM_FRAME);
 		break;
 	default:
 		total_time = LLUnit<LLUnits::Milliseconds, F32>(100);
@@ -1443,7 +1438,7 @@ void LLFastTimerView::drawBars()
 		TimeBlock* prev_id = NULL;
 
 		S32 i = 0;
-		for(timer_tree_iterator_t it = begin_timer_tree(getFrameTimer());
+		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 			it != end_timer_tree();
 			++it, ++i)
 		{
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 09be137027..7eee3c1cb5 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -49,7 +49,6 @@ private:
 	static LLSD analyzePerformanceLogDefault(std::istream& is) ;
 	static void exportCharts(const std::string& base, const std::string& target);
 	void onPause();
-	LLTrace::TimeBlock& getFrameTimer();
 
 public:
 
-- 
cgit v1.2.3


From 8144fa95701122f24c36b8ae2a51a5ce720614a6 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 25 Jan 2013 18:10:35 -0700
Subject: for SH-3781: LLTrace issues

---
 indra/newview/llscenemonitor.cpp | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 9de6b52d12..4eb44bcc00 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -463,6 +463,7 @@ void LLSceneMonitor::calcDiffAggregate()
 	}	
 }
 
+static LLTrace::Measurement<> sFramePixelDiff("FramePixelDifference");
 void LLSceneMonitor::fetchQueryResult()
 {
 	if(!mHasNewQueryResult)
@@ -486,6 +487,7 @@ void LLSceneMonitor::fetchQueryResult()
 	if(mDiffResult > 0.01f)
 	{
 		mRecording->extend();
+		sFramePixelDiff.sample(mDiffResult);
 	}
 	//llinfos << count << " : " << mDiffResult << llendl;
 }
-- 
cgit v1.2.3


From 2c68d5367c5c44aceb4ff23d9672c35642e030f7 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sun, 27 Jan 2013 21:35:20 -0800
Subject: SH-3275 WIP interesting Update viewer metrics system to be more
 flexible fixed memory leak fixed glitching of fast timer display

---
 indra/newview/llfasttimerview.cpp | 245 ++++++++++++++++++--------------------
 indra/newview/llfasttimerview.h   |  19 ++-
 2 files changed, 128 insertions(+), 136 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 7858378f00..948b6f8e89 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -107,7 +107,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mRecording(&get_frame_recording()),
 	mPauseHistory(false)
 {
-	mBarRects = new std::vector<LLRect>[MAX_VISIBLE_HISTORY + 1];
+	mTimerBars = new std::vector<TimerBar>[MAX_VISIBLE_HISTORY + 1];
 }
 
 LLFastTimerView::~LLFastTimerView()
@@ -117,7 +117,7 @@ LLFastTimerView::~LLFastTimerView()
 		delete mRecording;
 	}
 	mRecording = NULL;
-	delete [] mBarRects;
+	delete [] mTimerBars;
 }
 
 void LLFastTimerView::onPause()
@@ -282,7 +282,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			++it, ++i)
 		{
 			// is mouse over bar for this timer?
-			if (mBarRects[mHoverBarIndex][i].pointInRect(x, y))
+			if (mTimerBars[mHoverBarIndex][i].mRect.pointInRect(x, y))
 			{
 				mHoverID = (*it);
 				if (mHoverTimer != *it)
@@ -294,7 +294,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 					mHoverTimer = (*it);
 				}
 
-				mToolTipRect = mBarRects[mHoverBarIndex][i];
+				mToolTipRect = mTimerBars[mHoverBarIndex][i].mRect;
 			}
 
 			if ((*it)->getCollapsed())
@@ -1311,11 +1311,11 @@ S32 LLFastTimerView::drawHelp( S32 y )
 	}	return y;
 }
 
-void LLFastTimerView::drawTicks( LLUnit<LLUnits::Seconds, F64> total_time )
+void LLFastTimerView::drawTicks()
 {
 	// Draw MS ticks
 	{
-		LLUnit<LLUnits::Milliseconds, U32> ms = total_time;
+		LLUnit<LLUnits::Milliseconds, U32> ms = mTotalTimeDisplay;
 		std::string tick_label;
 		S32 x;
 		S32 barw = mBarRect.getWidth();
@@ -1377,187 +1377,170 @@ void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32
 	}
 }
 
-LLUnit<LLUnits::Seconds, F64> LLFastTimerView::getTotalTime()
+void LLFastTimerView::updateTotalTime()
 {
-	LLUnit<LLUnits::Seconds, F64> total_time;
 	switch(mDisplayMode)
 	{
 	case 0:
-		total_time = mRecording->getPeriodMean(FTM_FRAME)*2;
+		mTotalTimeDisplay = mRecording->getPeriodMean(FTM_FRAME)*2;
 		break;
 	case 1:
-		total_time = mAllTimeMax;
+		mTotalTimeDisplay = mAllTimeMax;
 		break;
 	case 2:
 		// Calculate the max total ticks for the current history
-		total_time = mRecording->getPeriodMax(FTM_FRAME);
+		mTotalTimeDisplay = mRecording->getPeriodMax(FTM_FRAME);
 		break;
 	default:
-		total_time = LLUnit<LLUnits::Milliseconds, F32>(100);
+		mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F32>(100);
 		break;
 	}
-	return total_time;
 }
 
 void LLFastTimerView::drawBars()
 {
-	LLUnit<LLUnits::Seconds, F64> total_time = getTotalTime();
-	if (total_time <= 0.0) return;
+	updateTotalTime();
+	if (mTotalTimeDisplay <= 0.0) return;
 
-	LLPointer<LLUIImage> box_imagep = LLUI::getUIImage("Rounded_Square");
 	LLLocalClipRect clip(mBarRect);
 
 	S32 bar_height = (mBarRect.mTop - MARGIN - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2);
 	S32 vpad = llmax(1, bar_height / 4); // spacing between bars
 	bar_height -= vpad;
 
-	drawTicks(total_time);
+	drawTicks();
 	S32 y = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
 	drawBorders(y, mBarRect.mLeft, bar_height, vpad);
 
 	// Draw bars for each history entry
 	// Special: -1 = show running average
-	gGL.getTexUnit(0)->bind(box_imagep->getImage());
+	LLPointer<LLUIImage> bar_image = LLUI::getUIImage("Rounded_Square");
+	gGL.getTexUnit(0)->bind(bar_image->getImage());
 	const S32 histmax = llmin(mRecording->getNumPeriods()+1, MAX_VISIBLE_HISTORY);
 
 	for (S32 j = -1; j < histmax && y > LINE_GRAPH_HEIGHT; j++)
 	{
-		mBarRects[llmax(j, 0)].clear();
-		int sublevel_dx[FTV_MAX_DEPTH];
-		int sublevel_left[FTV_MAX_DEPTH];
-		int sublevel_right[FTV_MAX_DEPTH];
-		S32 tidx = (j >= 0)
+		S32 history_index = (j >= 0)
 			? j + 1 + mScrollIndex
 			: -1;
+		S32 rect_index = llmax(j, 0);
+		mTimerBars[rect_index].clear();
 
-		// draw the bars for each stat
-		std::vector<S32> xpos;
-		S32 deltax = 0;
-		xpos.push_back(mBarRect.mLeft);
+		updateTimerBars(&FTM_FRAME, LLRect(mBarRect.mLeft, 0, mBarRect.mRight, -bar_height), mTimerBars[rect_index], history_index);
 
-		TimeBlock* prev_id = NULL;
-
-		S32 i = 0;
-		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-			it != end_timer_tree();
-			++it, ++i)
+		for (std::vector<TimerBar>::iterator it = mTimerBars[rect_index].begin(), end_it = mTimerBars[rect_index].end();
+			it != end_it;
+			++it)
 		{
-			TimeBlock* idp = (*it);
-			F32 frac = tidx == -1
-				? (mRecording->getPeriodMean(*idp) / total_time) 
-				: (mRecording->getPrevRecordingPeriod(tidx).getSum(*idp).value() / total_time.value());
-
-			S32 dx = llround(frac * (F32)mBarRect.getWidth());
-			S32 prev_delta_x = deltax;
-			deltax = dx;
-
-			const int level = get_depth(idp) - 1;
-			while ((S32)xpos.size() > level + 1)
-			{
-				xpos.pop_back();
-			}
-
-			LLRect bar_rect;
-			bar_rect.setLeftTopAndSize(xpos.back(), y, dx, bar_height);
-			mBarRects[llmax(j, 0)].push_back(bar_rect);
-
-			if (level == 0)
-			{
-				sublevel_left[level] = mBarRect.mLeft;
-				sublevel_dx[level] = dx;
-				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
-			}
-			else if (prev_id && get_depth(prev_id) < get_depth(idp))
-			{
-				F64 sublevelticks = 0;
-
-				for (TimeBlock::child_const_iter it = prev_id->beginChildren();
-					it != prev_id->endChildren();
-					++it)
-				{
-					sublevelticks += (tidx == -1)
-						? mRecording->getPeriodMean(**it).value()
-						: mRecording->getPrevRecordingPeriod(tidx).getSum(**it).value();
-				}
-
-				F32 subfrac = (F32)sublevelticks / (F32)total_time.value();
-				sublevel_dx[level] = (int)(subfrac * (F32)mBarRect.getWidth() + .5f);
+			TimerBar& timer_bar = *it;
+			gGL.color4fv(timer_bar.mColor.mV);
+			gl_segmented_rect_2d_fragment_tex(timer_bar.mRect.mLeft, timer_bar.mRect.mTop, timer_bar.mRect.mRight, timer_bar.mRect.mBottom,
+				bar_image->getTextureWidth(), bar_image->getTextureHeight(), 
+				16, 
+				timer_bar.mStartFraction, timer_bar.mEndFraction);
 
-				if (mDisplayCenter == ALIGN_CENTER)
-				{
-					bar_rect.mLeft += (prev_delta_x - sublevel_dx[level])/2;
-				}
-				else if (mDisplayCenter == ALIGN_RIGHT)
-				{
-					bar_rect.mLeft += (prev_delta_x - sublevel_dx[level]);
-				}
-
-				sublevel_left[level] = bar_rect.mLeft;
-				sublevel_right[level] = sublevel_left[level] + sublevel_dx[level];
-			}				
+		}
+			
+		y -= (bar_height + vpad);
+		if (j < 0)
+			y -= bar_height;
+	}
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+}
 
-			xpos.back() = bar_rect.mRight;
-			xpos.push_back(bar_rect.mLeft);
+LLRect LLFastTimerView::updateTimerBars(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 history_index)
+{
+	F32 self_time_frame_fraction = history_index == -1
+		? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) 
+		: (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
 
-			if (bar_rect.getWidth() > 0)
-			{
-				LLColor4 color = sTimerColors[idp];
-				S32 scale_offset = 0;
+	S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth());
+	LLRect child_rect = bar_rect;
 
-				BOOL is_child_of_hover_item = (idp == mHoverID);
-				TimeBlock* next_parent = idp->getParent();
-				while(!is_child_of_hover_item && next_parent)
-				{
-					is_child_of_hover_item = (mHoverID == next_parent);
-					if (next_parent->getParent() == next_parent) break;
-					next_parent = next_parent->getParent();
-				}
+	if (mDisplayCenter == ALIGN_CENTER)
+	{
+		child_rect.mLeft += self_time_width / 2;
+		self_time_width -= self_time_width / 2;
+	}
+	else if (mDisplayCenter == ALIGN_RIGHT)
+	{
+		child_rect.mLeft += self_time_width;
+		self_time_width = 0;
+	}
 
-				if (idp == mHoverID)
-				{
-					scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
-					//color = lerp(color, LLColor4::black, -0.4f);
-				}
-				else if (mHoverID != NULL && !is_child_of_hover_item)
-				{
-					color = lerp(color, LLColor4::grey, 0.8f);
-				}
+	if (child_rect.getHeight() > 3)
+	{
+		child_rect.mTop -= 1;
+		child_rect.mBottom += 1;
+	}
+	child_rect.mRight = child_rect.mLeft;
 
-				gGL.color4fv(color.mV);
-				F32 start_fragment = llclamp((F32)(bar_rect.mLeft - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-				F32 end_fragment = llclamp((F32)(bar_rect.mRight - sublevel_left[level]) / (F32)sublevel_dx[level], 0.f, 1.f);
-				gl_segmented_rect_2d_fragment_tex(
-					sublevel_left[level], 
-					bar_rect.mTop - level + scale_offset, 
-					sublevel_right[level], 
-					bar_rect.mBottom + level - scale_offset, 
-					box_imagep->getTextureWidth(), box_imagep->getTextureHeight(), 
-					16, 
-					start_fragment, end_fragment);
-			}
+	// reserve a spot for this bar to be rendered before its children
+	// even though we don't know its size yet
+	S32 first_child_left = child_rect.mLeft;
+	S32 bar_rect_index = bars.size();
+	bars.push_back(TimerBar());
 
-			if ((*it)->getCollapsed())
-			{
-				it.skipDescendants();
-			}
+	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
+	{
+		child_rect = updateTimerBars(*it, child_rect, bars, history_index);
 
-			prev_id = idp;
-		}
-		y -= (bar_height + vpad);
-		if (j < 0)
-			y -= bar_height;
+		// advance for next child
+		child_rect.mLeft = child_rect.mRight;
 	}
-	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-}
 
+	// now loop through children and figure out portion of bar image covered by each bar, now that we know the
+	// sum of all children
+	//S32 total_width_children = child_rect.mRight - first_child_left;
+	//S32 child_bar_index = bar_rect_index + 1;
+	//F32 bar_fraction_start = 0.f;
+	//for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
+	//	it != end_it; 
+	//	++it)
+	//{
+	//	TimerBar& child_timer_bar = bars[child_bar_index];
 
+	//	child_timer_bar.mStartFraction = bar_fraction_start;
+	//	child_timer_bar.mEndFraction = (F32)child_timer_bar.mRect.getWidth() / (F32)total_width_children;
 
+	//	bar_fraction_start = child_timer_bar.mEndFraction;
 
+	//	// advance for next child
+	//	child_bar_index++;
+	//}
 
 
+	bar_rect.mRight = child_rect.mRight + self_time_width;
 
+	if (bar_rect.getWidth() > 0)
+	{
+		LLColor4 color = sTimerColors[time_block];
+		S32 scale_offset = 0;
 
+		BOOL is_child_of_hover_item = (time_block == mHoverID);
+		TimeBlock* next_parent = time_block->getParent();
+		while(!is_child_of_hover_item && next_parent)
+		{
+			is_child_of_hover_item = (mHoverID == next_parent);
+			if (next_parent->getParent() == next_parent) break;
+			next_parent = next_parent->getParent();
+		}
 
+		if (time_block == mHoverID)
+		{
+			scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
+		}
+		else if (mHoverID != NULL && !is_child_of_hover_item)
+		{
+			color = lerp(color, LLColor4::grey, 0.8f);
+		}
 
+		bar_rect.mTop += scale_offset;
+		bar_rect.mBottom -= scale_offset;
 
+		bars[bar_rect_index].mRect = bar_rect;
+		bars[bar_rect_index].mColor = color;
+	}
 
+	return bar_rect;
+}
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 7eee3c1cb5..86781b626c 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -70,7 +70,7 @@ protected:
 	virtual	void	onClickCloseBtn();
 
 private:	
-	void drawTicks(LLUnit<LLUnits::Seconds, F64> total_time);
+	void drawTicks();
 	void drawLineGraph();
 	void drawLegend(S32 y);
 	S32 drawHelp(S32 y);
@@ -79,10 +79,18 @@ private:
 
 	void printLineStats();
 	void generateUniqueColors();
-	LLUnit<LLUnits::Seconds, F64> getTotalTime();
+	void updateTotalTime();
 
-
-	std::vector<LLRect>* mBarRects;
+	struct TimerBar
+	{
+		LLRect		mRect;
+		LLColor4	mColor;
+		F32			mStartFraction,
+					mEndFraction;
+	};
+	LLRect updateTimerBars(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 history_index);
+
+	std::vector<TimerBar>* mTimerBars;
 	S32 mDisplayMode;
 
 	typedef enum child_alignment
@@ -96,7 +104,8 @@ private:
 	ChildAlignment                mDisplayCenter;
 	bool                          mDisplayCalls,
 								  mDisplayHz;
-	LLUnit<LLUnits::Seconds, F64> mAllTimeMax;
+	LLUnit<LLUnits::Seconds, F64> mAllTimeMax,
+								  mTotalTimeDisplay;
 	LLRect                        mBarRect;
 	S32						      mScrollIndex;
 	LLTrace::TimeBlock*           mHoverID;
-- 
cgit v1.2.3


From a441664c109e4fca4154dbf80e108c27b3e9e601 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 31 Jan 2013 00:50:54 -0800
Subject: SH-3275 WIP interesting Update viewer metrics system to be more
 flexible fast timer bars render correctly

---
 indra/newview/llfasttimerview.cpp | 263 +++++++++++++++++++++-----------------
 indra/newview/llfasttimerview.h   |  18 ++-
 2 files changed, 164 insertions(+), 117 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 948b6f8e89..c75f25c0f0 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -58,9 +58,8 @@ using namespace LLTrace;
 
 static const S32 MAX_VISIBLE_HISTORY = 10;
 static const S32 LINE_GRAPH_HEIGHT = 240;
-
-const S32 FTV_MAX_DEPTH = 8;
-const S32 HISTORY_NUM = 300;
+static const S32 HISTORY_NUM = 300;
+static const S32 MIN_BAR_HEIGHT = 3;
 
 std::vector<TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
@@ -123,20 +122,25 @@ LLFastTimerView::~LLFastTimerView()
 void LLFastTimerView::onPause()
 {
 	mPauseHistory = !mPauseHistory;
+	updatePauseState();
+}
+
+void LLFastTimerView::updatePauseState()
+{
 	// reset scroll to bottom when unpausing
 	if (!mPauseHistory)
-	{
-		mRecording = new PeriodicRecording(get_frame_recording());
-		mScrollIndex = 0;
-		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
-	}
-	else
 	{
 		if (mRecording != &get_frame_recording())
 		{
 			delete mRecording;
 		}
 		mRecording = &get_frame_recording();
+		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
+	}
+	else
+	{
+		mRecording = new PeriodicRecording(get_frame_recording());
+		mScrollIndex = 0;
 
 		getChild<LLButton>("pause_btn")->setLabel(getString("run"));
 	}
@@ -177,7 +181,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 
 TimeBlock* LLFastTimerView::getLegendID(S32 y)
 {
-	S32 idx = (getRect().getHeight() - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 5;
+	S32 idx = (mBarRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 1;
 
 	if (idx >= 0 && idx < (S32)ft_display_idx.size())
 	{
@@ -282,7 +286,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			++it, ++i)
 		{
 			// is mouse over bar for this timer?
-			if (mTimerBars[mHoverBarIndex][i].mRect.pointInRect(x, y))
+			if (mTimerBars[mHoverBarIndex][i].mVisibleRect.pointInRect(x, y))
 			{
 				mHoverID = (*it);
 				if (mHoverTimer != *it)
@@ -294,7 +298,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 					mHoverTimer = (*it);
 				}
 
-				mToolTipRect = mTimerBars[mHoverBarIndex][i].mRect;
+				mToolTipRect = mTimerBars[mHoverBarIndex][i].mVisibleRect;
 			}
 
 			if ((*it)->getCollapsed())
@@ -374,6 +378,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
 	mPauseHistory = true;
+	updatePauseState();
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
 							llmin(mRecording->getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY));
@@ -397,7 +402,7 @@ void LLFastTimerView::draw()
 	gl_rect_2d(getLocalRect(), LLColor4(0.f, 0.f, 0.f, 0.25f));
 
 	S32 y = drawHelp(getRect().getHeight() - MARGIN);
-	drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() - 2));
+	drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 2));
 
 	// update rectangle that includes timer bars
 	const S32 LEGEND_WIDTH = 220;
@@ -1074,7 +1079,7 @@ void LLFastTimerView::drawLineGraph()
 		F32 alpha = 1.f;
 
 		if (mHoverID != NULL &&
-			idp != mHoverID)
+			mHoverID != idp)
 		{	//fade out non-highlighted timers
 			if (idp->getParent() != mHoverID)
 			{
@@ -1281,34 +1286,33 @@ void LLFastTimerView::generateUniqueColors()
 S32 LLFastTimerView::drawHelp( S32 y )
 {
 	// Draw some help
-	{
-		const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
-
-		char modedesc[][32] = {
-			"2 x Average ",
-			"Max         ",
-			"Recent Max  ",
-			"100 ms      "
-		};
-		char centerdesc[][32] = {
-			"Left      ",
-			"Centered  ",
-			"Ordered   "
-		};
-
-		std::string text;
-		text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]);
-		LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-
-		y -= (texth + 2);
-		text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]);
-		LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-		y -= (texth + 2);
-
-		LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"),
-			0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-		y -= (texth + 2);
-	}	return y;
+	const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
+
+	char modedesc[][32] = {
+		"2 x Average ",
+		"Max         ",
+		"Recent Max  ",
+		"100 ms      "
+	};
+	char centerdesc[][32] = {
+		"Left      ",
+		"Centered  ",
+		"Ordered   "
+	};
+
+	std::string text;
+	text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]);
+	LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+
+	y -= (texth + 2);
+	text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]);
+	LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+	y -= (texth + 2);
+
+	LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"),
+		0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
+	y -= (texth + 2);
+	return y;
 }
 
 void LLFastTimerView::drawTicks()
@@ -1425,21 +1429,13 @@ void LLFastTimerView::drawBars()
 			: -1;
 		S32 rect_index = llmax(j, 0);
 		mTimerBars[rect_index].clear();
+		mTimerBars[rect_index].reserve(LLInstanceTracker<LLTrace::TimeBlock>::instanceCount());
 
-		updateTimerBars(&FTM_FRAME, LLRect(mBarRect.mLeft, 0, mBarRect.mRight, -bar_height), mTimerBars[rect_index], history_index);
-
-		for (std::vector<TimerBar>::iterator it = mTimerBars[rect_index].begin(), end_it = mTimerBars[rect_index].end();
-			it != end_it;
-			++it)
-		{
-			TimerBar& timer_bar = *it;
-			gGL.color4fv(timer_bar.mColor.mV);
-			gl_segmented_rect_2d_fragment_tex(timer_bar.mRect.mLeft, timer_bar.mRect.mTop, timer_bar.mRect.mRight, timer_bar.mRect.mBottom,
-				bar_image->getTextureWidth(), bar_image->getTextureHeight(), 
-				16, 
-				timer_bar.mStartFraction, timer_bar.mEndFraction);
-
-		}
+		LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[rect_index][0].mWidth, y-bar_height);
+		updateTimerBarWidths(&FTM_FRAME, mTimerBars[rect_index], history_index);
+		mTimerBars[rect_index][0].mVisibleRect = frame_bar_rect;
+		updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[rect_index], history_index, true);
+		drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[rect_index], 0, bar_image);
 			
 		y -= (bar_height + vpad);
 		if (j < 0)
@@ -1448,99 +1444,136 @@ void LLFastTimerView::drawBars()
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 }
 
-LLRect LLFastTimerView::updateTimerBars(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 history_index)
+
+S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index)
 {
 	F32 self_time_frame_fraction = history_index == -1
 		? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) 
 		: (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
 
 	S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth());
-	LLRect child_rect = bar_rect;
+	S32 full_width = self_time_width;
 
-	if (mDisplayCenter == ALIGN_CENTER)
+	// reserve a spot for this bar to be rendered before its children
+	// even though we don't know its size yet
+	S32 bar_rect_index = bars.size();
+	bars.push_back(TimerBar());
+
+	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
 	{
-		child_rect.mLeft += self_time_width / 2;
-		self_time_width -= self_time_width / 2;
+		full_width += updateTimerBarWidths(*it, bars, history_index);
 	}
-	else if (mDisplayCenter == ALIGN_RIGHT)
+
+	TimerBar& timer_bar = bars[bar_rect_index];
+
+	timer_bar.mWidth = full_width;
+	timer_bar.mSelfWidth = self_time_width;
+	timer_bar.mColor = sTimerColors[time_block];
+
+	BOOL is_child_of_hover_item = (time_block == mHoverID);
+	TimeBlock* next_parent = time_block->getParent();
+	while(!is_child_of_hover_item && next_parent)
 	{
-		child_rect.mLeft += self_time_width;
-		self_time_width = 0;
+		is_child_of_hover_item = (mHoverID == next_parent);
+		if (next_parent->getParent() == next_parent) break;
+		next_parent = next_parent->getParent();
 	}
 
-	if (child_rect.getHeight() > 3)
+	if (mHoverID != NULL 
+		&& time_block != mHoverID 
+		&& !is_child_of_hover_item)
 	{
-		child_rect.mTop -= 1;
-		child_rect.mBottom += 1;
+		timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f);
 	}
-	child_rect.mRight = child_rect.mLeft;
 
-	// reserve a spot for this bar to be rendered before its children
-	// even though we don't know its size yet
-	S32 first_child_left = child_rect.mLeft;
-	S32 bar_rect_index = bars.size();
-	bars.push_back(TimerBar());
+	return full_width;
+}
 
-	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
+S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars, S32 history_index, bool draw)
+{
+	TimerBar& timer_bar = bars[timer_bar_index];
+	S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth;
+	LLRect children_rect = timer_bar.mVisibleRect;
+
+	if (mDisplayCenter == ALIGN_CENTER)
+	{
+		children_rect.mLeft += timer_bar.mSelfWidth / 2;
+	}
+	else if (mDisplayCenter == ALIGN_RIGHT)
+	{
+		children_rect.mLeft += timer_bar.mSelfWidth;
+	}
+	children_rect.mRight = children_rect.mLeft + timer_bar.mWidth - timer_bar.mSelfWidth;
+
+	if (children_rect.getHeight() > MIN_BAR_HEIGHT)
 	{
-		child_rect = updateTimerBars(*it, child_rect, bars, history_index);
+		children_rect.mTop -= 1;
+		children_rect.mBottom += 1;
+	}
+	timer_bar.mChildrenRect = children_rect;
+	timer_bar.mVisible = draw;
 
-		// advance for next child
-		child_rect.mLeft = child_rect.mRight;
+	if (time_block->getCollapsed())
+	{
+		draw = false;
 	}
 
-	// now loop through children and figure out portion of bar image covered by each bar, now that we know the
-	// sum of all children
-	//S32 total_width_children = child_rect.mRight - first_child_left;
-	//S32 child_bar_index = bar_rect_index + 1;
-	//F32 bar_fraction_start = 0.f;
-	//for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
-	//	it != end_it; 
-	//	++it)
-	//{
-	//	TimerBar& child_timer_bar = bars[child_bar_index];
+	//now loop through children and figure out portion of bar image covered by each bar, now that we know the
+	//sum of all children
+	F32 bar_fraction_start = 0.f;
+	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
+		it != end_it; 
+		++it)
+	{
+		timer_bar_index++;
 
-	//	child_timer_bar.mStartFraction = bar_fraction_start;
-	//	child_timer_bar.mEndFraction = (F32)child_timer_bar.mRect.getWidth() / (F32)total_width_children;
+		TimerBar& child_timer_bar = bars[timer_bar_index];
+		TimeBlock* child_time_block = *it;
 
-	//	bar_fraction_start = child_timer_bar.mEndFraction;
+		child_timer_bar.mStartFraction = bar_fraction_start;
+		child_timer_bar.mEndFraction = child_time_width > 0
+			? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width
+			: 1.f;
+		child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), 
+			children_rect.mTop, 
+			children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), 
+			children_rect.mBottom);
 
-	//	// advance for next child
-	//	child_bar_index++;
-	//}
+		timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars, history_index, draw);
 
+		bar_fraction_start = child_timer_bar.mEndFraction;
+	}
+	return timer_bar_index;
+}
 
-	bar_rect.mRight = child_rect.mRight + self_time_width;
+S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 bar_index, LLPointer<LLUIImage>& bar_image)
+{
+	TimerBar& timer_bar = bars[bar_index];
 
-	if (bar_rect.getWidth() > 0)
+	// animate scale of bar when hovering over that particular timer
+	if (bar_rect.getWidth() > 0 && timer_bar.mVisible)
 	{
-		LLColor4 color = sTimerColors[time_block];
+		LLRect render_rect(bar_rect);
 		S32 scale_offset = 0;
-
-		BOOL is_child_of_hover_item = (time_block == mHoverID);
-		TimeBlock* next_parent = time_block->getParent();
-		while(!is_child_of_hover_item && next_parent)
-		{
-			is_child_of_hover_item = (mHoverID == next_parent);
-			if (next_parent->getParent() == next_parent) break;
-			next_parent = next_parent->getParent();
-		}
-
 		if (time_block == mHoverID)
 		{
 			scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
-		}
-		else if (mHoverID != NULL && !is_child_of_hover_item)
-		{
-			color = lerp(color, LLColor4::grey, 0.8f);
+			render_rect.mTop += scale_offset;
+			render_rect.mBottom -= scale_offset;
 		}
 
-		bar_rect.mTop += scale_offset;
-		bar_rect.mBottom -= scale_offset;
+		gGL.color4fv(timer_bar.mColor.mV);
+		gl_segmented_rect_2d_fragment_tex(render_rect,
+			bar_image->getTextureWidth(), bar_image->getTextureHeight(), 
+			16, 
+			timer_bar.mStartFraction, timer_bar.mEndFraction);
+	}
 
-		bars[bar_rect_index].mRect = bar_rect;
-		bars[bar_rect_index].mColor = color;
+	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
+	{
+		++bar_index;
+		bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image);
 	}
 
-	return bar_rect;
+	return bar_index;
 }
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 86781b626c..b3e428908a 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -83,12 +83,26 @@ private:
 
 	struct TimerBar
 	{
-		LLRect		mRect;
+		TimerBar()
+		:	mWidth(0),
+			mSelfWidth(0),
+			mVisible(true),
+			mStartFraction(0.f),
+			mEndFraction(1.f)
+		{}
+		S32			mWidth;
+		S32			mSelfWidth;
+		LLRect		mVisibleRect,
+					mChildrenRect;
 		LLColor4	mColor;
+		bool		mVisible;
 		F32			mStartFraction,
 					mEndFraction;
 	};
-	LLRect updateTimerBars(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 history_index);
+	S32 updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index);
+	S32 updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars, S32 history_index, bool draw);
+	S32 drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 bar_index, LLPointer<LLUIImage>& bar_image);
+	void updatePauseState();
 
 	std::vector<TimerBar>* mTimerBars;
 	S32 mDisplayMode;
-- 
cgit v1.2.3


From eb6c8959ca5b8b3c100114d4d659a48bb4d56b2c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 2 Feb 2013 01:09:52 -0800
Subject: SH-3275 WIP interesting Update viewer metrics system to be more
 flexible fixed most fast timer display and interaction issues

---
 indra/newview/llfasttimerview.cpp | 198 +++++++++++++++++++++-----------------
 indra/newview/llfasttimerview.h   |   8 +-
 2 files changed, 111 insertions(+), 95 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index c75f25c0f0..1562d0e13d 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -58,7 +58,6 @@ using namespace LLTrace;
 
 static const S32 MAX_VISIBLE_HISTORY = 10;
 static const S32 LINE_GRAPH_HEIGHT = 240;
-static const S32 HISTORY_NUM = 300;
 static const S32 MIN_BAR_HEIGHT = 3;
 
 std::vector<TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
@@ -121,14 +120,15 @@ LLFastTimerView::~LLFastTimerView()
 
 void LLFastTimerView::onPause()
 {
-	mPauseHistory = !mPauseHistory;
-	updatePauseState();
+	setPauseState(!mPauseHistory);
 }
 
-void LLFastTimerView::updatePauseState()
+void LLFastTimerView::setPauseState(bool pause_state)
 {
+	if (pause_state == mPauseHistory) return;
+
 	// reset scroll to bottom when unpausing
-	if (!mPauseHistory)
+	if (!pause_state)
 	{
 		if (mRecording != &get_frame_recording())
 		{
@@ -144,6 +144,8 @@ void LLFastTimerView::updatePauseState()
 
 		getChild<LLButton>("pause_btn")->setLabel(getString("run"));
 	}
+
+	mPauseHistory = pause_state;
 }
 
 BOOL LLFastTimerView::postBuild()
@@ -260,7 +262,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
-		mScrollIndex = llround( lerp * (F32)(HISTORY_NUM - MAX_VISIBLE_HISTORY));
+		mScrollIndex = llround( lerp * (F32)(mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY));
 		mScrollIndex = llclamp(	mScrollIndex, 0, mRecording->getNumPeriods());
 		return TRUE;
 	}
@@ -269,8 +271,9 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 	if(mPauseHistory && mBarRect.pointInRect(x, y))
 	{
-		mHoverBarIndex = llmin(mRecording->getNumPeriods() - 1, 
-								MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight()));
+		mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1,
+								mRecording->getNumPeriods() - 1,
+								MAX_VISIBLE_HISTORY);
 		if (mHoverBarIndex == 0)
 		{
 			return TRUE;
@@ -322,17 +325,15 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicRecording& frame_recording)
 {
-	F64 ms_multiplier = 1000.0 / (F64)TimeBlock::countsPerSecond();
-
 	std::string tooltip;
-	if (history_index < 0)
+	if (history_index == 0)
 	{
 		// by default, show average number of call
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPeriodMean(timer) * ms_multiplier).value(), (S32)frame_recording.getPeriodMean(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount()));
 	}
 	else
 	{
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer) * ms_multiplier).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount()));
 	}
 	return tooltip;
 }
@@ -347,7 +348,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLRect screen_rect;
 			localRectToScreen(mToolTipRect, &screen_rect);
 
-			std::string tooltip = get_tooltip(*mHoverTimer, mScrollIndex + mHoverBarIndex, *mRecording);
+			std::string tooltip = get_tooltip(*mHoverTimer, mHoverBarIndex > 0 ? mScrollIndex + mHoverBarIndex : 0, *mRecording);
 
 			LLToolTipMgr::instance().show(LLToolTip::Params()
 				.message(tooltip)
@@ -365,7 +366,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			TimeBlock* idp = getLegendID(y);
 			if (idp)
 			{
-				LLToolTipMgr::instance().show(get_tooltip(*idp, -1,  *mRecording));
+				LLToolTipMgr::instance().show(get_tooltip(*idp, 0, *mRecording));
 
 				return TRUE;
 			}
@@ -377,11 +378,10 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 
 BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	mPauseHistory = true;
-	updatePauseState();
+	setPauseState(true);
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(mRecording->getNumPeriods(), (S32)HISTORY_NUM - MAX_VISIBLE_HISTORY));
+							llmin(mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
@@ -1004,8 +1004,11 @@ void LLFastTimerView::printLineStats()
 	}
 }
 
+static LLFastTimer::DeclareTimer FTM_DRAW_LINE_GRAPH("Draw line graph");
+
 void LLFastTimerView::drawLineGraph()
 {
+	LLFastTimer _(FTM_DRAW_LINE_GRAPH);
 	//draw line graph history
 	S32 x = mBarRect.mLeft;
 	S32 y = LINE_GRAPH_HEIGHT;
@@ -1024,7 +1027,7 @@ void LLFastTimerView::drawLineGraph()
 	else if (mDisplayHz)
 		axis_label = llformat("%d Hz", (int)(1.f / max_time.value()));
 	else
-		axis_label = llformat("%4.2f ms", max_time.value());
+		axis_label = llformat("%4.2f ms", LLUnit<LLUnits::Milliseconds, F32>(max_time).value());
 
 	x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5;
 	y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
@@ -1034,10 +1037,10 @@ void LLFastTimerView::drawLineGraph()
 
 	//highlight visible range
 	{
-		S32 first_frame = HISTORY_NUM - mScrollIndex;
+		S32 first_frame = mRecording->getNumPeriods() - mScrollIndex;
 		S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 
-		F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(HISTORY_NUM-1);
+		F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(mRecording->getNumPeriods()-1);
 
 		F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
 		F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
@@ -1045,9 +1048,9 @@ void LLFastTimerView::drawLineGraph()
 		gGL.color4f(0.5f,0.5f,0.5f,0.3f);
 		gl_rect_2d((S32) left, mGraphRect.mTop, (S32) right, mGraphRect.mBottom);
 
-		if (mHoverBarIndex >= 0)
+		if (mHoverBarIndex > 0)
 		{
-			S32 bar_frame = first_frame - mHoverBarIndex;
+			S32 bar_frame = first_frame - mHoverBarIndex - 1;
 			F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame;
 
 			gGL.color4f(0.5f,0.5f,0.5f,1);
@@ -1102,7 +1105,7 @@ void LLFastTimerView::drawLineGraph()
 				cur_max = llmax(cur_max, time);
 				cur_max_calls = llmax(cur_max_calls, calls);
 			}
-			F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(HISTORY_NUM-1);
+			F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording->getNumPeriods()-1);
 			F32 y = mDisplayHz 
 				? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
 				: mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight();
@@ -1123,7 +1126,7 @@ void LLFastTimerView::drawLineGraph()
 			it.skipDescendants();
 		}
 	}
-
+	
 	//interpolate towards new maximum
 	max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f));
 	if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
@@ -1408,7 +1411,7 @@ void LLFastTimerView::drawBars()
 
 	LLLocalClipRect clip(mBarRect);
 
-	S32 bar_height = (mBarRect.mTop - MARGIN - LINE_GRAPH_HEIGHT) / (MAX_VISIBLE_HISTORY + 2);
+	S32 bar_height = mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2);
 	S32 vpad = llmax(1, bar_height / 4); // spacing between bars
 	bar_height -= vpad;
 
@@ -1420,33 +1423,34 @@ void LLFastTimerView::drawBars()
 	// Special: -1 = show running average
 	LLPointer<LLUIImage> bar_image = LLUI::getUIImage("Rounded_Square");
 	gGL.getTexUnit(0)->bind(bar_image->getImage());
-	const S32 histmax = llmin(mRecording->getNumPeriods()+1, MAX_VISIBLE_HISTORY);
+	const S32 histmax = llmin(mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1;
 
-	for (S32 j = -1; j < histmax && y > LINE_GRAPH_HEIGHT; j++)
+	for (S32 bar_index = 0; bar_index < histmax && y > LINE_GRAPH_HEIGHT; bar_index++)
 	{
-		S32 history_index = (j >= 0)
-			? j + 1 + mScrollIndex
+		S32 history_index = (bar_index > 0)
+			? bar_index + mScrollIndex
 			: -1;
-		S32 rect_index = llmax(j, 0);
-		mTimerBars[rect_index].clear();
-		mTimerBars[rect_index].reserve(LLInstanceTracker<LLTrace::TimeBlock>::instanceCount());
-
-		LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[rect_index][0].mWidth, y-bar_height);
-		updateTimerBarWidths(&FTM_FRAME, mTimerBars[rect_index], history_index);
-		mTimerBars[rect_index][0].mVisibleRect = frame_bar_rect;
-		updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[rect_index], history_index, true);
-		drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[rect_index], 0, bar_image);
-			
+		mTimerBars[bar_index].clear();
+		mTimerBars[bar_index].reserve(LLInstanceTracker<LLTrace::TimeBlock>::instanceCount());
+
+		updateTimerBarWidths(&FTM_FRAME, mTimerBars[bar_index], history_index, true);
+		LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[bar_index][0].mWidth, y-bar_height);
+		mTimerBars[bar_index][0].mVisibleRect = frame_bar_rect;
+		updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[bar_index]);
+		drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[bar_index], 0, bar_image);
+				
 		y -= (bar_height + vpad);
-		if (j < 0)
+		if (bar_index == 0)
 			y -= bar_height;
 	}
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 }
 
+static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
-S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index)
+S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index, bool visible)
 {
+	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
 	F32 self_time_frame_fraction = history_index == -1
 		? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) 
 		: (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
@@ -1454,43 +1458,57 @@ S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::v
 	S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth());
 	S32 full_width = self_time_width;
 
+	bool children_visible = visible;
+
 	// reserve a spot for this bar to be rendered before its children
 	// even though we don't know its size yet
 	S32 bar_rect_index = bars.size();
-	bars.push_back(TimerBar());
+	if (visible)
+	{
+		bars.push_back(TimerBar());
+	}
 
+	if (time_block->getCollapsed())
+	{
+		children_visible = false;
+	}
 	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
 	{
-		full_width += updateTimerBarWidths(*it, bars, history_index);
+		full_width += updateTimerBarWidths(*it, bars, history_index, children_visible);
 	}
 
-	TimerBar& timer_bar = bars[bar_rect_index];
+	if (visible)
+	{
+		TimerBar& timer_bar = bars[bar_rect_index];
 
-	timer_bar.mWidth = full_width;
-	timer_bar.mSelfWidth = self_time_width;
-	timer_bar.mColor = sTimerColors[time_block];
+		timer_bar.mWidth = full_width;
+		timer_bar.mSelfWidth = self_time_width;
+		timer_bar.mColor = sTimerColors[time_block];
 
-	BOOL is_child_of_hover_item = (time_block == mHoverID);
-	TimeBlock* next_parent = time_block->getParent();
-	while(!is_child_of_hover_item && next_parent)
-	{
-		is_child_of_hover_item = (mHoverID == next_parent);
-		if (next_parent->getParent() == next_parent) break;
-		next_parent = next_parent->getParent();
-	}
+		BOOL is_child_of_hover_item = (time_block == mHoverID);
+		TimeBlock* next_parent = time_block->getParent();
+		while(!is_child_of_hover_item && next_parent)
+		{
+			is_child_of_hover_item = (mHoverID == next_parent);
+			if (next_parent->getParent() == next_parent) break;
+			next_parent = next_parent->getParent();
+		}
 
-	if (mHoverID != NULL 
-		&& time_block != mHoverID 
-		&& !is_child_of_hover_item)
-	{
-		timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f);
+		if (mHoverID != NULL 
+			&& time_block != mHoverID 
+			&& !is_child_of_hover_item)
+		{
+			timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f);
+		}
 	}
-
 	return full_width;
 }
 
-S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars, S32 history_index, bool draw)
+static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions");
+
+S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars)
 {
+	LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS);
 	TimerBar& timer_bar = bars[timer_bar_index];
 	S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth;
 	LLRect children_rect = timer_bar.mVisibleRect;
@@ -1511,37 +1529,34 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32
 		children_rect.mBottom += 1;
 	}
 	timer_bar.mChildrenRect = children_rect;
-	timer_bar.mVisible = draw;
-
-	if (time_block->getCollapsed())
-	{
-		draw = false;
-	}
 
 	//now loop through children and figure out portion of bar image covered by each bar, now that we know the
 	//sum of all children
-	F32 bar_fraction_start = 0.f;
-	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
-		it != end_it; 
-		++it)
+	if (!time_block->getCollapsed())
 	{
-		timer_bar_index++;
+		F32 bar_fraction_start = 0.f;
+		for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
+			it != end_it; 
+			++it)
+		{
+			timer_bar_index++;
 
-		TimerBar& child_timer_bar = bars[timer_bar_index];
-		TimeBlock* child_time_block = *it;
+			TimerBar& child_timer_bar = bars[timer_bar_index];
+			TimeBlock* child_time_block = *it;
 
-		child_timer_bar.mStartFraction = bar_fraction_start;
-		child_timer_bar.mEndFraction = child_time_width > 0
-			? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width
-			: 1.f;
-		child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), 
-			children_rect.mTop, 
-			children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), 
-			children_rect.mBottom);
+			child_timer_bar.mStartFraction = bar_fraction_start;
+			child_timer_bar.mEndFraction = child_time_width > 0
+				? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width
+				: 1.f;
+			child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), 
+				children_rect.mTop, 
+				children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), 
+				children_rect.mBottom);
 
-		timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars, history_index, draw);
+			timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars);
 
-		bar_fraction_start = child_timer_bar.mEndFraction;
+			bar_fraction_start = child_timer_bar.mEndFraction;
+		}
 	}
 	return timer_bar_index;
 }
@@ -1551,7 +1566,7 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, st
 	TimerBar& timer_bar = bars[bar_index];
 
 	// animate scale of bar when hovering over that particular timer
-	if (bar_rect.getWidth() > 0 && timer_bar.mVisible)
+	if (bar_rect.getWidth() > 0)
 	{
 		LLRect render_rect(bar_rect);
 		S32 scale_offset = 0;
@@ -1569,10 +1584,13 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, st
 			timer_bar.mStartFraction, timer_bar.mEndFraction);
 	}
 
-	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
+	if (!time_block->getCollapsed())
 	{
-		++bar_index;
-		bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image);
+		for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
+		{
+			++bar_index;
+			bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image);
+		}
 	}
 
 	return bar_index;
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index b3e428908a..f9ceb4423b 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -61,8 +61,6 @@ public:
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
 
-
-
 	LLTrace::TimeBlock* getLegendID(S32 y);
 	F64 getTime(const std::string& name);
 
@@ -99,10 +97,10 @@ private:
 		F32			mStartFraction,
 					mEndFraction;
 	};
-	S32 updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index);
-	S32 updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars, S32 history_index, bool draw);
+	S32 updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index, bool visible);
+	S32 updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars);
 	S32 drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 bar_index, LLPointer<LLUIImage>& bar_image);
-	void updatePauseState();
+	void setPauseState(bool pause_state);
 
 	std::vector<TimerBar>* mTimerBars;
 	S32 mDisplayMode;
-- 
cgit v1.2.3


From b49cdb1c7aee0f02e9f7eedee9295424e4dec213 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 5 Feb 2013 11:31:45 -0800
Subject: SH-3275 WIP interesting Update viewer metrics system to be more
 flexible quantized fast timer range to nearest 20ms for easier reading

---
 indra/newview/llfasttimerview.cpp | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 1562d0e13d..7d23687e21 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1402,6 +1402,8 @@ void LLFastTimerView::updateTotalTime()
 		mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F32>(100);
 		break;
 	}
+
+	mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F64>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds, F64>().value() / (20.f)) * 20.f);
 }
 
 void LLFastTimerView::drawBars()
-- 
cgit v1.2.3


From 438cbfe489cc34261ac600bbb22983164e59b1d9 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 7 Feb 2013 20:07:31 -0800
Subject: SH-3275 WIP interesting Update viewer metrics system to be more
 flexible fix for timings for recursive fast timers not being correct

---
 indra/newview/llfasttimerview.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 7d23687e21..1a1a4a8b44 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1403,7 +1403,7 @@ void LLFastTimerView::updateTotalTime()
 		break;
 	}
 
-	mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F64>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds, F64>().value() / (20.f)) * 20.f);
+	mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F32>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds, F32>().value() / (20.f)) * 20.f);
 }
 
 void LLFastTimerView::drawBars()
-- 
cgit v1.2.3


From f19254e633095f4eccbca40c87c38feb0fa5d083 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 9 Feb 2013 01:04:35 -0800
Subject: SH-3275 FIX interesting Update viewer metrics system to be more
 flexible moved image timings under "Update Images" fast timer

---
 indra/newview/llviewertexturelist.cpp | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 3106a351e0..6f8b439049 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -599,9 +599,11 @@ static LLFastTimer::DeclareTimer FTM_IMAGE_FETCH("Fetch");
 static LLFastTimer::DeclareTimer FTM_FAST_CACHE_IMAGE_FETCH("Fast Cache Fetch");
 static LLFastTimer::DeclareTimer FTM_IMAGE_CREATE("Create");
 static LLFastTimer::DeclareTimer FTM_IMAGE_STATS("Stats");
+static LLFastTimer::DeclareTimer FTM_UPDATE_IMAGES("Update Images");
 
 void LLViewerTextureList::updateImages(F32 max_time)
 {
+	LLFastTimer _(FTM_UPDATE_IMAGES);
 	static BOOL cleared = FALSE;
 	if(gTeleportDisplay)
 	{
-- 
cgit v1.2.3


From a6bb68b6e530df91d03abfc062c700ebc4e856aa Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 13 Feb 2013 15:21:20 -0800
Subject: SH-3275 FIX interesting Update viewer metrics system to be more
 flexible fix for inaccurate optimization of full block time calculations

---
 indra/newview/llfasttimerview.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 1a1a4a8b44..3893b0e772 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1403,7 +1403,7 @@ void LLFastTimerView::updateTotalTime()
 		break;
 	}
 
-	mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F32>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds, F32>().value() / (20.f)) * 20.f);
+	mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F32>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds>().value() / 20.f) * 20.f);
 }
 
 void LLFastTimerView::drawBars()
-- 
cgit v1.2.3


From bd60fdbe44d9f996686d31cf48a3f2ca664dd301 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 28 Feb 2013 22:49:05 -0700
Subject: for SH-3824: interesting: Ensure viewer can handle object updates
 from entire region gracefully

---
 indra/newview/llviewerobject.cpp     | 134 +++++++++++++++++++++++++++++++++++
 indra/newview/llviewerobject.h       |  12 ++++
 indra/newview/llviewerobjectlist.cpp |  51 ++++++++++++-
 indra/newview/llviewerregion.cpp     | 134 +++++++++++++++++++++++++++++------
 indra/newview/llviewerregion.h       |  19 ++++-
 indra/newview/llvocache.cpp          |  28 ++++++--
 indra/newview/llvocache.h            |   4 ++
 7 files changed, 354 insertions(+), 28 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index f5f5bdffbd..e50509374d 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -123,6 +123,7 @@ BOOL		LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
 F64			LLViewerObject::sMaxUpdateInterpolationTime = 3.0;		// For motion interpolation: after X seconds with no updates, don't predict object motion
 F64			LLViewerObject::sPhaseOutUpdateInterpolationTime = 2.0;	// For motion interpolation: after Y seconds with no updates, taper off motion prediction
 
+std::map<std::string, U32> LLViewerObject::sObjectDataMap;
 
 static LLFastTimer::DeclareTimer FTM_CREATE_OBJECT("Create Object");
 
@@ -501,6 +502,8 @@ void LLViewerObject::initVOClasses()
 	LLVOGrass::initClass();
 	LLVOWater::initClass();
 	LLVOVolume::initClass();
+
+	initObjectDataMap();
 }
 
 void LLViewerObject::cleanupVOClasses()
@@ -510,6 +513,118 @@ void LLViewerObject::cleanupVOClasses()
 	LLVOTree::cleanupClass();
 	LLVOAvatar::cleanupClass();
 	LLVOVolume::cleanupClass();
+
+	sObjectDataMap.clear();
+}
+
+//object data map for compressed && !OUT_TERSE_IMPROVED
+//static
+void LLViewerObject::initObjectDataMap()
+{
+	U32 count = 0;
+
+	sObjectDataMap["ID"] = count; //full id //LLUUID
+	count += sizeof(LLUUID);
+
+	sObjectDataMap["LocalID"] = count; //U32
+	count += sizeof(U32);
+
+	sObjectDataMap["PCode"] = count;   //U8
+	count += sizeof(U8);
+
+	sObjectDataMap["State"] = count;   //U8
+	count += sizeof(U8);
+
+	sObjectDataMap["CRC"] = count;     //U32
+	count += sizeof(U32);
+
+	sObjectDataMap["Material"] = count; //U8
+	count += sizeof(U8);
+
+	sObjectDataMap["ClickAction"] = count; //U8
+	count += sizeof(U8);
+
+	sObjectDataMap["Scale"] = count; //LLVector3
+	count += sizeof(LLVector3);
+
+	sObjectDataMap["Pos"] = count;   //LLVector3
+	count += sizeof(LLVector3);
+
+	sObjectDataMap["Rot"] = count;    //LLVector3
+	count += sizeof(LLVector3);
+
+	sObjectDataMap["SpecialCode"] = count; //U32
+	count += sizeof(U32);
+
+	sObjectDataMap["Owner"] = count; //LLUUID
+	count += sizeof(LLUUID);
+
+	sObjectDataMap["Omega"] = count; //LLVector3, when SpecialCode & 0x80 is set
+	count += sizeof(LLVector3);
+
+	//ParentID is after Omega if there is Omega, otherwise is after Owner
+	sObjectDataMap["ParentID"] = count;//U32, when SpecialCode & 0x20 is set
+	count += sizeof(U32);
+
+	//-------
+	//The rest items are not included here
+	//-------
+}
+
+//static 
+void LLViewerObject::unpackVector3(LLDataPackerBinaryBuffer* dp, LLVector3& value, std::string name)
+{
+	dp->shift(sObjectDataMap[name]);
+	dp->unpackVector3(value, name.c_str());
+	dp->reset();
+}
+
+//static 
+void LLViewerObject::unpackUUID(LLDataPackerBinaryBuffer* dp, LLUUID& value, std::string name)
+{
+	dp->shift(sObjectDataMap[name]);
+	dp->unpackUUID(value, name.c_str());
+	dp->reset();
+}
+	
+//static 
+void LLViewerObject::unpackU32(LLDataPackerBinaryBuffer* dp, U32& value, std::string name)
+{
+	dp->shift(sObjectDataMap[name]);
+	dp->unpackU32(value, name.c_str());
+	dp->reset();
+}
+	
+//static 
+void LLViewerObject::unpackU8(LLDataPackerBinaryBuffer* dp, U8& value, std::string name)
+{
+	dp->shift(sObjectDataMap[name]);
+	dp->unpackU8(value, name.c_str());
+	dp->reset();
+}
+
+//static 
+U32 LLViewerObject::unpackParentID(LLDataPackerBinaryBuffer* dp, U32& parent_id)
+{
+	dp->shift(sObjectDataMap["SpecialCode"]);
+	U32 value;
+	dp->unpackU32(value, "SpecialCode");
+
+	parent_id = 0;
+	if(value & 0x20)
+	{
+		S32 offset = sObjectDataMap["ParentID"];
+		if(!(value & 0x80))
+		{
+			offset -= sizeof(LLVector3);
+		}
+
+		dp->shift(offset);
+		dp->unpackU32(parent_id, "ParentID");
+	}
+	dp->reset();
+
+	return parent_id;
 }
 
 // Replaces all name value pairs with data from \n delimited list
@@ -890,6 +1005,25 @@ U32 LLViewerObject::checkMediaURL(const std::string &media_url)
     return retval;
 }
 
+//extract spatial information from object update message
+//return parent_id
+//static
+U32 LLViewerObject::extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector3& pos, LLVector3& scale, LLQuaternion& rot)
+{
+	U32	parent_id = 0;
+	
+	LLViewerObject::unpackVector3(dp, scale, "Scale");
+	LLViewerObject::unpackVector3(dp, pos, "Pos");
+	
+	LLVector3 vec;
+	LLViewerObject::unpackVector3(dp, vec, "Rot");
+	rot.unpackFromVector3(vec);
+	
+	LLViewerObject::unpackParentID(dp, parent_id);
+	
+	return parent_id;
+}
+
 U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 					 void **user_data,
 					 U32 block_num,
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 20254bfe02..2db30f1e24 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -70,6 +70,7 @@ class LLViewerRegion;
 class LLViewerObjectMedia;
 class LLVOInventoryListener;
 class LLVOAvatar;
+class LLDataPackerBinaryBuffer;
 
 typedef enum e_object_update_type
 {
@@ -162,6 +163,7 @@ public:
         INVALID_UPDATE = 0x80000000
     };
 
+	static  U32     extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector3& pos, LLVector3& scale, LLQuaternion& rot);
 	virtual U32		processUpdateMessage(LLMessageSystem *mesgsys,
 										void **user_data,
 										U32 block_num,
@@ -539,6 +541,13 @@ public:
 	friend class LLViewerObjectList;
 	friend class LLViewerMediaList;
 
+public:
+	static void unpackVector3(LLDataPackerBinaryBuffer* dp, LLVector3& value, std::string name);
+	static void unpackUUID(LLDataPackerBinaryBuffer* dp, LLUUID& value, std::string name);
+	static void unpackU32(LLDataPackerBinaryBuffer* dp, U32& value, std::string name);
+	static void unpackU8(LLDataPackerBinaryBuffer* dp, U8& value, std::string name);
+	static U32 unpackParentID(LLDataPackerBinaryBuffer* dp, U32& parent_id);
+
 public:
 	//counter-translation
 	void resetChildrenPosition(const LLVector3& offset, BOOL simplified = FALSE) ;
@@ -562,6 +571,8 @@ private:
 	// Motion prediction between updates
 	void interpolateLinearMotion(const F64 & time, const F32 & dt);
 
+	static void initObjectDataMap();
+
 public:
 	//
 	// Viewer-side only types - use the LL_PCODE_APP mask.
@@ -610,6 +621,7 @@ private:
 	// Grabbed from UPDATE_FLAGS
 	U32				mFlags;
 
+	static std::map<std::string, U32> sObjectDataMap;
 public:
 	// Sent to sim in UPDATE_FLAGS, received in ObjectPhysicsProperties
 	U8              mPhysicsShapeType;
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index dce963c5c5..995c3e7351 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -455,12 +455,54 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			uncompressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data);
 			mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compressed_dpbuffer, 0, i);
 			compressed_dp.assignBuffer(compressed_dpbuffer, uncompressed_length);
+#if 0
+			if (compressed)
+			{
+				if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
+				{
+					U32 flags = 0;
+					mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i);
+					
+					if(!(flags & FLAGS_TEMPORARY_ON_REZ))
+					{
+						//bCached = true;
+						
+						compressed_dp.unpackU32(local_id, "LocalID");
 
+						//-------------
+						compressed_dp.unpackUUID(fullid, "ID");
+						//if(fullid == LLUUID("1e5183db-8f28-47f1-abe0-23de9f9042b7"))
+						{
+							llinfos << fullid << llendl;
+						}
+						//-------------
+
+						U32 crc;
+						compressed_dp.unpackU32(crc, "CRC");
+						/*LLViewerRegion::eCacheUpdateResult result = */regionp->cacheFullUpdate(local_id, crc, compressed_dp);
+						//recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);
+						
+						continue; //do not creat LLViewerObject for cacheable object, object cache will do the job.
+					}
+				}
+			}
+#endif
 			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
-				compressed_dp.unpackUUID(fullid, "ID");
-				compressed_dp.unpackU32(local_id, "LocalID");
-				compressed_dp.unpackU8(pcode, "PCode");
+				U32 flags = 0;
+				mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i);
+			
+				if(flags & FLAGS_TEMPORARY_ON_REZ)
+				{
+					compressed_dp.unpackUUID(fullid, "ID");
+					compressed_dp.unpackU32(local_id, "LocalID");
+					compressed_dp.unpackU8(pcode, "PCode");
+				}
+				else //send to object cache
+				{
+					regionp->cacheFullUpdate(compressed_dp);
+					continue;
+				}
 			}
 			else
 			{
@@ -594,6 +636,8 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 				objectp->mLocalID = local_id;
 			}
 			processUpdateCore(objectp, user_data, i, update_type, &compressed_dp, justCreated);
+
+#if 0
 			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
 				U32 flags = 0;
@@ -606,6 +650,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 					recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);
 				}
 			}
+#endif
 		}
 		else
 		{
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index e5cb2a1b08..040b39bc43 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -880,7 +880,7 @@ void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
 	mImpl->mVisibleGroups.insert(group);
 }
 
-void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
+void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry, bool forced)
 {
 	if(!sVOCacheCullingEnabled)
 	{
@@ -895,7 +895,7 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
-	if(!entry->hasState(LLVOCacheEntry::ADD_TO_CACHE_TREE))
+	if(!forced && !entry->hasState(LLVOCacheEntry::ADD_TO_CACHE_TREE))
 	{
 		return; //can not add to vo cache tree.
 	}
@@ -1647,14 +1647,91 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features)
 	mSimulatorFeatures = sim_features;
 }
 
-LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp)
+void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry)
+{
+	if(entry != NULL && !entry->getEntry())
+	{
+		entry->setOctreeEntry(NULL);
+	}
+	else 
+	{
+		return; //not new entry, no post processing.
+	}
+
+	LLVector3 pos;
+	LLVector3 scale;
+	LLQuaternion rot;
+	U32 parent_id = LLViewerObject::extractSpatialExtents(entry->getDP(), pos, scale, rot);
+	
+	entry->setBoundingInfo(pos, scale);
+	
+	if(parent_id > 0) //has parent
+	{
+		//1, find parent, update position
+		LLVOCacheEntry* parent = getCacheEntry(parent_id);
+		
+		//2, if can not, put into the orphan lists: a parents list and a children list
+		if(!parent)
+		{
+			std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(parent_id);
+			if(iter != mOrphanMap.end())
+			{
+				iter->second.addChild(entry->getLocalID());
+			}
+			else 
+			{
+				OrphanList o_list(entry->getLocalID());
+				mOrphanMap[parent_id] = o_list;
+			}
+			
+			return;
+		}
+		else
+		{
+			entry->updateBoundingInfo(parent);
+		}
+	}
+	
+	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
+	{
+		addToVOCacheTree(entry, true);
+	}
+
+	if(!parent_id) //a potential parent
+	{
+		//find all children and update their bounding info
+		std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(entry->getLocalID());
+		if(iter != mOrphanMap.end())
+		{
+			std::set<U32>* children = mOrphanMap[parent_id].getChildList();
+			for(std::set<U32>::iterator child_iter = children->begin(); child_iter != children->end(); ++child_iter)
+			{
+				LLVOCacheEntry* child = getCacheEntry(*child_iter);
+				if(child)
+				{
+					child->updateBoundingInfo(entry);
+					addToVOCacheTree(child);
+				}
+			}
+			
+			mOrphanMap.erase(entry->getLocalID());
+		}
+	}
+	
+	return ;
+}
+
+LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerBinaryBuffer &dp)
 {
-	U32 local_id = objectp->getLocalID();
-	U32 crc = objectp->getCRC();
 	eCacheUpdateResult result;
+	U32 crc;
+	U32 local_id;
 
-	LLVOCacheEntry* entry = getCacheEntry(local_id);
+	LLViewerObject::unpackU32(&dp, local_id, "LocalID");
+	LLViewerObject::unpackU32(&dp, crc, "CRC");
 
+	LLVOCacheEntry* entry = getCacheEntry(local_id);
+	
 	if (entry)
 	{
 		// we've seen this object before
@@ -1668,9 +1745,22 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 		{
 			// Update the cache entry
 			LLPointer<LLVOCacheEntry> new_entry = new LLVOCacheEntry(local_id, crc, dp);
-			replaceCacheEntry(entry, new_entry);
-			entry = new_entry;
-
+			
+			//if visible, update it
+			if(!entry->isState(LLVOCacheEntry::INACTIVE))
+			{
+				replaceCacheEntry(entry, new_entry);
+			}
+			else //invisible
+			{
+				//remove old entry
+				killCacheEntry(entry);
+				entry = new_entry;
+				
+				mImpl->mCacheMap[local_id] = entry;
+				postProcesNewEntry(entry);
+			}
+			
 			result = CACHE_UPDATE_CHANGED;
 		}
 	}
@@ -1679,17 +1769,21 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 		// we haven't seen this object before
 		// Create new entry and add to map
 		result = CACHE_UPDATE_ADDED;
-		//if (mImpl->mCacheMap.size() > MAX_OBJECT_CACHE_ENTRIES)
-		//{
-		//	delete mImpl->mCacheMap.begin()->second ;
-		//	mImpl->mCacheMap.erase(mImpl->mCacheMap.begin());
-		//	result = CACHE_UPDATE_REPLACED;
-		//
-		//}
 		entry = new LLVOCacheEntry(local_id, crc, dp);
-
+		
 		mImpl->mCacheMap[local_id] = entry;
+		
+		postProcesNewEntry(entry);
 	}
+	
+	return result;
+}
+
+LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp)
+{
+	eCacheUpdateResult result = cacheFullUpdate(dp);
+
+	LLVOCacheEntry* entry = mImpl->mCacheMap[objectp->getLocalID()];
 
 	if(objectp->mDrawable.notNull() && !entry->getEntry())
 	{
@@ -1754,13 +1848,13 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 			// Record a hit
 			entry->recordHit();
 			cache_miss_type = CACHE_MISS_TYPE_NONE;
-
+			
 			if(entry->getGroup() || !entry->isState(LLVOCacheEntry::INACTIVE))
 			{
 				return true;
 			}
-
-			addVisibleCacheEntry(entry);
+			//addVisibleCacheEntry(entry);
+			addToVOCacheTree(entry, true);
 			return true;
 		}
 		else
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index de14c0fe27..6da8c191a4 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -317,6 +317,7 @@ public:
 	} eCacheUpdateResult;
 
 	// handle a full update message
+	eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp);
 	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);	
 	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
 	bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type);
@@ -347,7 +348,7 @@ public:
 	void getNeighboringRegionsStatus( std::vector<S32>& regions );
 	
 private:
-	void addToVOCacheTree(LLVOCacheEntry* entry);
+	void addToVOCacheTree(LLVOCacheEntry* entry, bool forced = false);
 	LLViewerObject* addNewObject(LLVOCacheEntry* entry);
 	void killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list);
 	LLVOCacheEntry* getCacheEntry(U32 local_id);
@@ -360,6 +361,7 @@ private:
 	F32 updateVisibleEntries(F32 max_time); //update visible entries
 
 	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight);
+	void postProcesNewEntry(LLVOCacheEntry* entry);
 public:
 	struct CompareDistance
 	{
@@ -445,6 +447,21 @@ private:
 	BOOL    mReleaseNotesRequested;
 	BOOL    mDead;  //if true, this region is in the process of deleting.
 
+	class OrphanList
+	{
+	public:
+		OrphanList(){}
+		OrphanList(U32 child_id){addChild(child_id);}
+		
+		void addChild(U32 child_id) {mChildList.insert(child_id);}
+		std::set<U32>* getChildList() {return &mChildList;}
+		
+	private:
+		std::set<U32> mChildList;
+	};
+	
+	std::map<U32, OrphanList> mOrphanMap;
+	
 	class CacheMissItem
 	{
 	public:
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 86cfbb1d74..26c3e04b92 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -198,10 +198,8 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
 	if(!entry && mDP.getBufferSize() > 0)
 	{
 		LLUUID fullid;
-		mDP.reset();
-		mDP.unpackUUID(fullid, "ID");
-		mDP.reset();
-
+		LLViewerObject::unpackUUID(&mDP, fullid, "ID");
+		
 		LLViewerObject* obj = gObjectList.findObject(fullid);
 		if(obj && obj->mDrawable)
 		{
@@ -402,6 +400,28 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool
 	setVisible();
 }
 
+void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scale)
+{
+	LLVector4a center, newMin, newMax;
+	center.load3(pos.mV);
+	LLVector4a size;
+	size.load3(scale.mV);
+	newMin.setSub(center, size);
+	newMax.setAdd(center, size);
+	
+	setPositionGroup(center);
+	setSpatialExtents(newMin, newMax);
+	setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f));
+}
+
+void LLVOCacheEntry::updateBoundingInfo(LLVOCacheEntry* parent)
+{
+	//LLVector4a old_pos = getPositionGroup();
+	//parent->getPositionRegion() + (getPosition() * parent->getRotation());
+	
+	shift(parent->getPositionGroup());
+}
+
 //-------------------------------------------------------------------
 //LLVOCachePartition
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index c631e12739..7c1706e650 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -116,6 +116,10 @@ public:
 	S32  getNumOfChildren()         {return mChildrenList.size();}
 	void clearChildrenList()        {mChildrenList.clear();}
 
+	//called from processing object update message
+	void setBoundingInfo(const LLVector3& pos, const LLVector3& scale);
+	void updateBoundingInfo(LLVOCacheEntry* parent);
+	
 public:
 	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;
 	typedef std::set<LLVOCacheEntry*>                      vocache_entry_set_t;
-- 
cgit v1.2.3


From 03b7fb589a9b5628418364c970ea402448f312be Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 4 Mar 2013 11:48:07 -0700
Subject: trivial: convert to unix line endings.

---
 indra/newview/llviewerregion.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 040b39bc43..b287e0da9c 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1692,8 +1692,8 @@ void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry)
 		}
 	}
 	
-	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
-	{
+	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
+	{
 		addToVOCacheTree(entry, true);
 	}
 
-- 
cgit v1.2.3


From f07b9c2c69f1f6882dcf249aacf33cdfacf878ab Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 6 Mar 2013 11:08:25 -0800
Subject: renamed LLTrace stat gathering classes/methods to make the structure
 of LLTrace clearer Count becomes CountStatHandle Count.sum becomes sum(Count,
 value), etc.

---
 indra/newview/llagent.cpp             |   4 +-
 indra/newview/llappviewer.cpp         |   2 +-
 indra/newview/lldrawable.cpp          |   2 +-
 indra/newview/lldrawable.h            |   2 +-
 indra/newview/llfloaterjoystick.cpp   |  14 +--
 indra/newview/llfloatersnapshot.cpp   |   2 +-
 indra/newview/llhudnametag.cpp        |   2 +-
 indra/newview/llnearbychatbar.cpp     |   2 +-
 indra/newview/llpanelface.cpp         |   2 +-
 indra/newview/llpreviewscript.cpp     |   4 +-
 indra/newview/llselectmgr.cpp         |   4 +-
 indra/newview/llstartup.cpp           |   2 +-
 indra/newview/lltexlayer.cpp          |   2 +-
 indra/newview/lltexturefetch.cpp      |  12 +-
 indra/newview/lltexturefetch.h        |   4 +-
 indra/newview/lltooldraganddrop.cpp   |   6 +-
 indra/newview/lltoolplacer.cpp        |   2 +-
 indra/newview/llviewerassetstats.cpp  |  12 +-
 indra/newview/llviewercamera.cpp      |   4 +-
 indra/newview/llviewercamera.h        |   8 +-
 indra/newview/llviewerdisplay.cpp     |   4 +-
 indra/newview/llviewermenufile.cpp    |  12 +-
 indra/newview/llviewermessage.cpp     |   2 +-
 indra/newview/llviewerobject.cpp      |   4 +-
 indra/newview/llviewerobject.h        |   2 +-
 indra/newview/llviewerobjectlist.cpp  |  14 +--
 indra/newview/llviewerobjectlist.h    |   2 +-
 indra/newview/llviewerstats.cpp       | 222 +++++++++++++++++-----------------
 indra/newview/llviewerstats.h         |  35 +++---
 indra/newview/llviewertexturelist.cpp |  20 +--
 indra/newview/llviewerwindow.cpp      |   8 +-
 indra/newview/llviewerwindow.h        |   4 +-
 indra/newview/llvoavatarself.cpp      |   6 +-
 indra/newview/llworld.cpp             |  14 +--
 indra/newview/pipeline.cpp            |   4 +-
 35 files changed, 220 insertions(+), 225 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 14235bcee4..4fb298df13 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -752,7 +752,7 @@ void LLAgent::setFlying(BOOL fly)
 		}
 		if( !was_flying )
 		{
-			LLStatViewer::FLY.add(1);
+			add(LLStatViewer::FLY, 1);
 		}
 		setControlFlags(AGENT_CONTROL_FLY);
 	}
@@ -3806,7 +3806,7 @@ bool LLAgent::teleportCore(bool is_local)
 	gAgentCamera.resetView(FALSE);
 
 	// local logic
-	LLStatViewer::TELEPORT.add(1);
+	add(LLStatViewer::TELEPORT, 1);
 	if (is_local)
 	{
 		gAgent.setTeleportState( LLAgent::TELEPORT_LOCAL );
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 3d7770c765..c00fddbb24 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4865,7 +4865,7 @@ void LLAppViewer::idleNetwork()
 			gPrintMessagesThisFrame = FALSE;
 		}
 	}
-	LLStatViewer::NUM_NEW_OBJECTS.sample(gObjectList.mNumNewObjects);
+	sample(LLStatViewer::NUM_NEW_OBJECTS, gObjectList.mNumNewObjects);
 
 	// Retransmit unacknowledged packets.
 	gXferManager->retransmitUnackedPackets();
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index ba970671af..9c3d9f4d34 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -59,7 +59,7 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
-LLTrace::MemStat	LLDrawable::sMemStat("LLDrawable");
+LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 
 
 ////////////////////////
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 161f550bb6..3691bbf71b 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -292,7 +292,7 @@ public:
 	F32				mDistanceWRTCamera;
 
 	static F32 sCurPixelAngle; //current pixels per radian
-	static LLTrace::MemStat sMemStat;
+	static LLTrace::MemStatHandle sMemStat;
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index ab7fc1cf3f..25c119d9e1 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -42,13 +42,13 @@
 #include "llviewerjoystick.h"
 #include "llcheckboxctrl.h"
 
-static LLTrace::Measurement<> sJoystickAxis1("Joystick axis 1"),
-								sJoystickAxis2("Joystick axis 2"),
-								sJoystickAxis3("Joystick axis 3"),
-								sJoystickAxis4("Joystick axis 4"),
-								sJoystickAxis5("Joystick axis 5"),
-								sJoystickAxis6("Joystick axis 6");
-static LLTrace::Measurement<>* sJoystickAxes[6] = 
+static LLTrace::MeasurementStatHandle<> sJoystickAxis1("Joystick axis 1"),
+										sJoystickAxis2("Joystick axis 2"),
+										sJoystickAxis3("Joystick axis 3"),
+										sJoystickAxis4("Joystick axis 4"),
+										sJoystickAxis5("Joystick axis 5"),
+										sJoystickAxis6("Joystick axis 6");
+static LLTrace::MeasurementStatHandle<>* sJoystickAxes[6] = 
 {
 	&sJoystickAxis1,
 	&sJoystickAxis2,
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 0d90037e7b..04fc572220 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -992,7 +992,7 @@ void LLSnapshotLivePreview::saveTexture()
 		llwarns << "Error encoding snapshot" << llendl;
 	}
 
-	LLStatViewer::SNAPSHOT.add(1);
+	add(LLStatViewer::SNAPSHOT, 1);
 	
 	mDataSize = 0;
 }
diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index 56fbdb429a..c12916ec6b 100644
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -900,7 +900,7 @@ void LLHUDNameTag::updateAll()
 //		}
 	}
 
-	LLTrace::Count<>* camera_vel_stat = LLViewerCamera::getVelocityStat();
+	LLTrace::CountStatHandle<>* camera_vel_stat = LLViewerCamera::getVelocityStat();
 	F32 camera_vel = LLTrace::get_frame_recording().getLastRecordingPeriod().getPerSec(*camera_vel_stat);
 	if (camera_vel > MAX_STABLE_CAMERA_VELOCITY)
 	{
diff --git a/indra/newview/llnearbychatbar.cpp b/indra/newview/llnearbychatbar.cpp
index 23cbfae044..142aaa795b 100644
--- a/indra/newview/llnearbychatbar.cpp
+++ b/indra/newview/llnearbychatbar.cpp
@@ -638,7 +638,7 @@ void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32
 
 	gAgent.sendReliableMessage();
 
-	LLStatViewer::CHAT_COUNT.add(1);
+	add(LLStatViewer::CHAT_COUNT, 1);
 }
 
 class LLChatCommandHandler : public LLCommandHandler
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 39ded21183..88f2c5ff52 100644
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -1049,7 +1049,7 @@ BOOL LLPanelFace::onDragTexture(LLUICtrl*, LLInventoryItem* item)
 
 void LLPanelFace::onCommitTexture( const LLSD& data )
 {
-	LLStatViewer::EDIT_TEXTURE.add(1);
+	add(LLStatViewer::EDIT_TEXTURE, 1);
 	sendTexture();
 }
 
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 050db136bc..f87a958fbc 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -942,7 +942,7 @@ void LLScriptEdCore::onBtnInsertFunction(LLUICtrl *ui, void* userdata)
 
 void LLScriptEdCore::doSave( BOOL close_after_save )
 {
-	LLStatViewer::LSL_SAVES.add(1);
+	add(LLStatViewer::LSL_SAVES, 1);
 
 	if( mSaveCallback )
 	{
@@ -1146,7 +1146,7 @@ void LLScriptEdCore::onBtnLoadFromFile( void* data )
 
 void LLScriptEdCore::onBtnSaveToFile( void* userdata )
 {
-	LLStatViewer::LSL_SAVES.add(1);
+	add(LLStatViewer::LSL_SAVES, 1);
 
 	LLScriptEdCore* self = (LLScriptEdCore*) userdata;
 
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 36ce7bb60e..bdbb1bb797 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -1550,7 +1550,7 @@ void LLObjectSelection::applyNoCopyTextureToTEs(LLViewerInventoryItem* item)
 				}
 
 				// apply texture for the selected faces
-				LLStatViewer::EDIT_TEXTURE.add(1);
+				add(LLStatViewer::EDIT_TEXTURE, 1);
 				object->setTEImage(te, image);
 				dialog_refresh_all();
 
@@ -3424,7 +3424,7 @@ bool LLSelectMgr::confirmDelete(const LLSD& notification, const LLSD& response,
 			gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR);
 
 			// Keep track of how many objects have been deleted.
-			LLStatViewer::DELETE_OBJECT.add(LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount());
+			add(LLStatViewer::DELETE_OBJECT, LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount());
 		}
 		break;
 	case 1:
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 648fb0f7b7..2effec7d3a 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2071,7 +2071,7 @@ bool idle_startup()
 		if (wearables_time > MAX_WEARABLES_TIME)
 		{
 			LLNotificationsUtil::add("ClothingLoading");
-			LLStatViewer::LOADING_WEARABLES_LONG_DELAY.add(1);
+			add(LLStatViewer::LOADING_WEARABLES_LONG_DELAY, 1);
 			LLStartUp::setStartupState( STATE_CLEANUP );
 			return TRUE;
 		}
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index fad7a73008..d6cd881894 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -460,7 +460,7 @@ BOOL LLTexLayerSetBuffer::requestUpdateImmediate()
 void LLTexLayerSetBuffer::doUpload()
 {
 	llinfos << "Uploading baked " << mTexLayerSet->getBodyRegionName() << llendl;
-	LLStatViewer::TEX_BAKES.add(1);
+	add(LLStatViewer::TEX_BAKES, 1);
 
 	// Don't need caches since we're baked now.  (note: we won't *really* be baked 
 	// until this image is sent to the server and the Avatar Appearance message is received.)
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index fba636e8ef..0dc2601e60 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -65,8 +65,8 @@
 #include "bufferstream.h"
 
 bool LLTextureFetchDebugger::sDebuggerEnabled = false ;
-LLTrace::Measurement<> LLTextureFetch::sCacheHitRate("texture_cache_hits");
-LLTrace::Measurement<> LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
+LLTrace::MeasurementStatHandle<> LLTextureFetch::sCacheHitRate("texture_cache_hits");
+LLTrace::MeasurementStatHandle<> LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
 
 
 //////////////////////////////////////////////////////////////////////////////
@@ -1237,7 +1237,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			LL_DEBUGS("Texture") << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize()
 								 << " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight())
 								 << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
-			LLTextureFetch::sCacheHitRate.sample(100.f);
+			sample(LLTextureFetch::sCacheHitRate, 100.f);
 		}
 		else
 		{
@@ -1254,7 +1254,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			}
 			
 			// fall through
-			LLTextureFetch::sCacheHitRate.sample(0.f);
+			sample(LLTextureFetch::sCacheHitRate, 0.f);
 		}
 	}
 
@@ -2706,7 +2706,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
 			F32 cache_read_time = worker->mCacheReadTime;
 			if (cache_read_time != 0.f)
 			{
-				sCacheReadLatency.sample(cache_read_time * 1000.f);
+				sample(sCacheReadLatency, cache_read_time * 1000.f);
 			}
 			res = true;
 			LL_DEBUGS("Texture") << id << ": Request Finished. State: " << worker->mState << " Discard: " << discard_level << LL_ENDL;
@@ -2832,7 +2832,7 @@ S32 LLTextureFetch::update(F32 max_time_ms)
 		mNetworkQueueMutex.lock();										// +Mfnq
 		mMaxBandwidth = band_width ;
 
-		LLStatViewer::TEXTURE_KBIT.add(mHTTPTextureBits);
+		add(LLStatViewer::TEXTURE_KBIT, mHTTPTextureBits);
 		mHTTPTextureBits = 0;
 
 		mNetworkQueueMutex.unlock();									// -Mfnq
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 2c1e7502e5..2e398023fe 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -308,8 +308,8 @@ private:
 	LLMutex mQueueMutex;        //to protect mRequestMap and mCommands only
 	LLMutex mNetworkQueueMutex; //to protect mNetworkQueue, mHTTPTextureQueue and mCancelQueue.
 
-	static LLTrace::Measurement<> sCacheHitRate;
-	static LLTrace::Measurement<> sCacheReadLatency;
+	static LLTrace::MeasurementStatHandle<> sCacheHitRate;
+	static LLTrace::MeasurementStatHandle<> sCacheReadLatency;
 
 	LLTextureCache* mTextureCache;
 	LLImageDecodeThread* mImageDecodeThread;
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index 652847aac9..90ae0b428b 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -1062,7 +1062,7 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
 		return;
 	}
 	LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
-	LLStatViewer::EDIT_TEXTURE.add(1);
+	add(LLStatViewer::EDIT_TEXTURE, 1);
 	S32 num_faces = hit_obj->getNumTEs();
 	for( S32 face = 0; face < num_faces; face++ )
 	{
@@ -1130,7 +1130,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
 	}
 	// update viewer side image in anticipation of update from simulator
 	LLViewerTexture* image = LLViewerTextureManager::getFetchedTexture(asset_id);
-	LLStatViewer::EDIT_TEXTURE.add(1);
+	add(LLStatViewer::EDIT_TEXTURE, 1);
 	hit_obj->setTEImage(hit_face, image);
 	dialog_refresh_all();
 
@@ -1354,7 +1354,7 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
 
-	LLStatViewer::OBJECT_REZ.add(1);
+	add(LLStatViewer::OBJECT_REZ, 1);
 }
 
 void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj,
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index 329249eee8..c026ddd42e 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -433,7 +433,7 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
 	effectp->setDuration(LL_HUD_DUR_SHORT);
 	effectp->setColor(LLColor4U(gAgent.getEffectColor()));
 
-	LLStatViewer::OBJECT_CREATE.add(1);
+	add(LLStatViewer::OBJECT_CREATE, 1);
 
 	return TRUE;
 }
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 890394dd22..0c72c3c5aa 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -177,7 +177,7 @@ namespace LLViewerAssetStatsFF
 		return ret;
 	}
 
-	static LLTrace::Count<> sEnqueueAssetRequestsTempTextureHTTP   ("enqueuedassetrequeststemptexturehttp", 
+	static LLTrace::CountStatHandle<> sEnqueueAssetRequestsTempTextureHTTP   ("enqueuedassetrequeststemptexturehttp", 
 																	"Number of temporary texture asset http requests enqueued"),
 							sEnqueueAssetRequestsTempTextureUDP    ("enqueuedassetrequeststemptextureudp", 
 																	"Number of temporary texture asset udp requests enqueued"),
@@ -194,7 +194,7 @@ namespace LLViewerAssetStatsFF
 							sEnqueuedAssetRequestsOther            ("enqueuedassetrequestsother", 
 																	"Number of other asset requests enqueued");
 
-	static LLTrace::Count<>* sEnqueued[EVACCount] = {		
+	static LLTrace::CountStatHandle<>* sEnqueued[EVACCount] = {		
 		&sEnqueueAssetRequestsTempTextureHTTP,   
 		&sEnqueueAssetRequestsTempTextureUDP,  
 		&sEnqueueAssetRequestsNonTempTextureHTTP,
@@ -205,7 +205,7 @@ namespace LLViewerAssetStatsFF
 		&sEnqueuedAssetRequestsOther            
 	};
 
-	static LLTrace::Count<> sDequeueAssetRequestsTempTextureHTTP   ("dequeuedassetrequeststemptexturehttp", 
+	static LLTrace::CountStatHandle<> sDequeueAssetRequestsTempTextureHTTP   ("dequeuedassetrequeststemptexturehttp", 
 																	"Number of temporary texture asset http requests dequeued"),
 							sDequeueAssetRequestsTempTextureUDP    ("dequeuedassetrequeststemptextureudp", 
 																	"Number of temporary texture asset udp requests dequeued"),
@@ -222,7 +222,7 @@ namespace LLViewerAssetStatsFF
 							sDequeuedAssetRequestsOther            ("dequeuedassetrequestsother", 
 																	"Number of other asset requests dequeued");
 
-	static LLTrace::Count<>* sDequeued[EVACCount] = {
+	static LLTrace::CountStatHandle<>* sDequeued[EVACCount] = {
 		&sDequeueAssetRequestsTempTextureHTTP,   
 		&sDequeueAssetRequestsTempTextureUDP,  
 		&sDequeueAssetRequestsNonTempTextureHTTP,
@@ -233,7 +233,7 @@ namespace LLViewerAssetStatsFF
 		&sDequeuedAssetRequestsOther            
 	};
 
-	static LLTrace::Measurement<LLTrace::Seconds>	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp", 
+	static LLTrace::MeasurementStatHandle<LLTrace::Seconds>	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp", 
 																							"Time spent responding to temporary texture asset http requests"),
 													sResponseAssetRequestsTempTextureUDP    ("assetresponsetimestemptextureudp", 
 																							"Time spent responding to temporary texture asset udp requests"),
@@ -250,7 +250,7 @@ namespace LLViewerAssetStatsFF
 													sResponsedAssetRequestsOther            ("assetresponsetimesother", 
 																							"Time spent responding to other asset requests");
 
-	static LLTrace::Measurement<LLTrace::Seconds>* sResponse[EVACCount] = {
+	static LLTrace::MeasurementStatHandle<LLTrace::Seconds>* sResponse[EVACCount] = {
 		&sResponseAssetRequestsTempTextureHTTP,   
 		&sResponseAssetRequestsTempTextureUDP,  
 		&sResponseAssetRequestsNonTempTextureHTTP,
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index f74897daa7..6e0a2c88a8 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -54,8 +54,8 @@
 // System includes
 #include <iomanip> // for setprecision
 
-LLTrace::Count<> LLViewerCamera::sVelocityStat("camera_velocity");
-LLTrace::Count<> LLViewerCamera::sAngularVelocityStat("camera_angular_velocity");
+LLTrace::CountStatHandle<> LLViewerCamera::sVelocityStat("camera_velocity");
+LLTrace::CountStatHandle<> LLViewerCamera::sAngularVelocityStat("camera_angular_velocity");
 
 U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
 
diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h
index 607bfa7199..ffec284f72 100644
--- a/indra/newview/llviewercamera.h
+++ b/indra/newview/llviewercamera.h
@@ -101,8 +101,8 @@ public:
 	BOOL projectPosAgentToScreenEdge(const LLVector3 &pos_agent, LLCoordGL &out_point) const;
 
 	const LLVector3* getVelocityDir() const {return &mVelocityDir;}
-	static LLTrace::Count<>* getVelocityStat()		   {return &sVelocityStat; }
-	static LLTrace::Count<>* getAngularVelocityStat()  {return &sAngularVelocityStat; }
+	static LLTrace::CountStatHandle<>* getVelocityStat()		   {return &sVelocityStat; }
+	static LLTrace::CountStatHandle<>* getAngularVelocityStat()  {return &sAngularVelocityStat; }
 	F32     getCosHalfFov() {return mCosHalfCameraFOV;}
 	F32     getAverageSpeed() {return mAverageSpeed ;}
 	F32     getAverageAngularSpeed() {return mAverageAngularSpeed;}
@@ -130,8 +130,8 @@ public:
 protected:
 	void calcProjection(const F32 far_distance) const;
 
-	static LLTrace::Count<> sVelocityStat;
-	static LLTrace::Count<> sAngularVelocityStat;
+	static LLTrace::CountStatHandle<> sVelocityStat;
+	static LLTrace::CountStatHandle<> sAngularVelocityStat;
 
 	LLVector3 mVelocityDir ;
 	F32       mAverageSpeed ;
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index fe83f80caa..2aec25b7aa 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -749,8 +749,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			
 			{
 				LLFastTimer t(FTM_IMAGE_UPDATE_CLASS);
-				LLTrace::Count<>* velocity_stat = LLViewerCamera::getVelocityStat();
-				LLTrace::Count<>* angular_velocity_stat = LLViewerCamera::getAngularVelocityStat();
+				LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat();
+				LLTrace::CountStatHandle<>* angular_velocity_stat = LLViewerCamera::getAngularVelocityStat();
 				LLViewerTexture::updateClass(LLTrace::get_frame_recording().getPeriodMeanPerSec(*velocity_stat),
 											LLTrace::get_frame_recording().getPeriodMeanPerSec(*angular_velocity_stat));
 			}
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index 50ca8db267..b7282a8493 100644
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -1096,17 +1096,17 @@ void upload_new_resource(
 	
 	if( LLAssetType::AT_SOUND == asset_type )
 	{
-		LLStatViewer::UPLOAD_SOUND.add(1);
+		add(LLStatViewer::UPLOAD_SOUND, 1);
 	}
 	else
 	if( LLAssetType::AT_TEXTURE == asset_type )
 	{
-		LLStatViewer::UPLOAD_TEXTURE.add(1);
+		add(LLStatViewer::UPLOAD_TEXTURE, 1);
 	}
 	else
 	if( LLAssetType::AT_ANIMATION == asset_type)
 	{
-		LLStatViewer::ANIMATION_UPLOADS.add(1);
+		add(LLStatViewer::ANIMATION_UPLOADS, 1);
 	}
 
 	if(LLInventoryType::IT_NONE == inv_type)
@@ -1231,15 +1231,15 @@ void increase_new_upload_stats(LLAssetType::EType asset_type)
 {
 	if ( LLAssetType::AT_SOUND == asset_type )
 	{
-		LLStatViewer::UPLOAD_SOUND.add(1);
+		add(LLStatViewer::UPLOAD_SOUND, 1);
 	}
 	else if ( LLAssetType::AT_TEXTURE == asset_type )
 	{
-		LLStatViewer::UPLOAD_TEXTURE.add(1);
+		add(LLStatViewer::UPLOAD_TEXTURE, 1);
 	}
 	else if ( LLAssetType::AT_ANIMATION == asset_type )
 	{
-		LLStatViewer::ANIMATION_UPLOADS.add(1);
+		add(LLStatViewer::ANIMATION_UPLOADS, 1);
 	}
 }
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7a2025ed5b..db169b86a4 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -5824,7 +5824,7 @@ void process_alert_core(const std::string& message, BOOL modal)
 	// HACK -- handle callbacks for specific alerts. It also is localized in notifications.xml
 	if ( message == "You died and have been teleported to your home location")
 	{
-		LLStatViewer::KILLED.add(1);
+		add(LLStatViewer::KILLED, 1);
 	}
 	else if( message == "Home position set." )
 	{
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index f5f5bdffbd..a5bd57145d 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -113,7 +113,7 @@ BOOL		LLViewerObject::sMapDebug = TRUE;
 LLColor4	LLViewerObject::sEditSelectColor(	1.0f, 1.f, 0.f, 0.3f);	// Edit OK
 LLColor4	LLViewerObject::sNoEditSelectColor(	1.0f, 0.f, 0.f, 0.3f);	// Can't edit
 S32			LLViewerObject::sAxisArrowLength(50);
-LLTrace::MemStat	LLViewerObject::sMemStat("LLViewerObject");
+LLTrace::MemStatHandle	LLViewerObject::sMemStat("LLViewerObject");
 
 
 BOOL		LLViewerObject::sPulseEnabled(FALSE);
@@ -2103,7 +2103,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		// If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps
 		if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
 		{
-			LLStatViewer::AGENT_POSITION_SNAP.sample<LLTrace::Meters>(diff.length());
+			sample(LLStatViewer::AGENT_POSITION_SNAP, LLTrace::Meters(diff.length()));
 		}
 	}
 
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 20254bfe02..aa30d1c790 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -636,7 +636,7 @@ public:
 	LLPointer<LLHUDIcon> mIcon;
 
 	static	BOOL				sUseSharedDrawables;
-	static	LLTrace::MemStat	sMemStat;
+	static	LLTrace::MemStatHandle	sMemStat;
 
 protected:
 	// delete an item in the inventory, but don't tell the
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 0335cd769b..176ee49d31 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -94,7 +94,7 @@ extern LLPipeline	gPipeline;
 U32						LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check.
 std::map<U64, U32>		LLViewerObjectList::sIPAndPortToIndex;
 std::map<U64, LLUUID>	LLViewerObjectList::sIndexAndLocalIDToUUID;
-LLTrace::Measurement<>	LLViewerObjectList::sCacheHitRate("object_cache_hits");
+LLTrace::MeasurementStatHandle<>	LLViewerObjectList::sCacheHitRate("object_cache_hits");
 
 LLViewerObjectList::LLViewerObjectList()
 {
@@ -356,7 +356,7 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 		}
 		justCreated = true;
 		mNumNewObjects++;
-		sCacheHitRate.sample(100.f);
+		sample(sCacheHitRate, 100.f);
 	}
 
 	if (objectp->isDead())
@@ -670,7 +670,7 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
 
 			continue; // no data packer, skip this object
 		}
-		sCacheHitRate.sample(100.f);
+		sample(sCacheHitRate, 100.f);
 	}
 
 	return;
@@ -1123,10 +1123,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	}
 	*/
 
-	LLStatViewer::NUM_OBJECTS.sample(mObjects.size());
-	LLStatViewer::NUM_ACTIVE_OBJECTS.sample(idle_count);
-	LLStatViewer::NUM_SIZE_CULLED.sample(mNumSizeCulled);
-	LLStatViewer::NUM_VIS_CULLED.sample(mNumVisCulled);
+	sample(LLStatViewer::NUM_OBJECTS, mObjects.size());
+	sample(LLStatViewer::NUM_ACTIVE_OBJECTS, idle_count);
+	sample(LLStatViewer::NUM_SIZE_CULLED, mNumSizeCulled);
+	sample(LLStatViewer::NUM_VIS_CULLED, mNumVisCulled);
 }
 
 void LLViewerObjectList::fetchObjectCosts()
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index b92be61fae..cb11ef1f5e 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -198,7 +198,7 @@ protected:
 	std::vector<OrphanInfo> mOrphanChildren;	// UUID's of orphaned objects
 	S32 mNumOrphans;
 
-	static LLTrace::Measurement<> sCacheHitRate;
+	static LLTrace::MeasurementStatHandle<> sCacheHitRate;
 
 	typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 136a4d0a9e..921c681e2a 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -64,48 +64,48 @@
 namespace LLStatViewer
 {
 
-LLTrace::Count<>	FPS("fpsstat"),
-					PACKETS_IN("packetsinstat"),
-					PACKETS_LOST("packetsloststat"),
-					PACKETS_OUT("packetsoutstat"),
-					TEXTURE_PACKETS("texturepacketsstat"),
-					TRIANGLES_DRAWN("trianglesdrawnstat"),
-					CHAT_COUNT("chatcount", "Chat messages sent"),
-					IM_COUNT("imcount", "IMs sent"),
-					OBJECT_CREATE("objectcreate"),
-					OBJECT_REZ("objectrez", "Object rez count"),
-					LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load"),
-					LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"),
-					LSL_SAVES("lslsaves", "Number of times user has saved a script"),
-					ANIMATION_UPLOADS("animationuploads", "Animations uploaded"),
-					FLY("fly", "Fly count"),
-					TELEPORT("teleport", "Teleport count"),
-					DELETE_OBJECT("deleteobject", "Objects deleted"),
-					SNAPSHOT("snapshot", "Snapshots taken"),
-					UPLOAD_SOUND("uploadsound", "Sounds uploaded"),
-					UPLOAD_TEXTURE("uploadtexture", "Textures uploaded"),
-					EDIT_TEXTURE("edittexture", "Changes to textures on objects"),
-					KILLED("killed", "Number of times killed"),
-					FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"),
-					TEX_BAKES("texbakes"),
-					TEX_REBAKES("texrebakes");
-LLTrace::Count<LLTrace::Kilobits>	KBIT("kbitstat"),
-									LAYERS_KBIT("layerskbitstat"),
-									OBJECT_KBIT("objectkbitstat"),
-									ASSET_KBIT("assetkbitstat"),
-									TEXTURE_KBIT("texturekbitstat"),
-									ACTUAL_IN_KBIT("actualinkbitstat"),
-									ACTUAL_OUT_KBIT("actualoutkbitstat");
-
-LLTrace::Count<LLTrace::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
-								TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
-								MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
-								FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
-								FPS_8_TIME("fps8time", "Seconds below 8 FPS"),
-								FPS_2_TIME("fps2time", "Seconds below 2 FPS"),
-								SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
-								SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
-								LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
+LLTrace::CountStatHandle<>	FPS("fpsstat"),
+							PACKETS_IN("packetsinstat"),
+							PACKETS_LOST("packetsloststat"),
+							PACKETS_OUT("packetsoutstat"),
+							TEXTURE_PACKETS("texturepacketsstat"),
+							TRIANGLES_DRAWN("trianglesdrawnstat"),
+							CHAT_COUNT("chatcount", "Chat messages sent"),
+							IM_COUNT("imcount", "IMs sent"),
+							OBJECT_CREATE("objectcreate"),
+							OBJECT_REZ("objectrez", "Object rez count"),
+							LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load"),
+							LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"),
+							LSL_SAVES("lslsaves", "Number of times user has saved a script"),
+							ANIMATION_UPLOADS("animationuploads", "Animations uploaded"),
+							FLY("fly", "Fly count"),
+							TELEPORT("teleport", "Teleport count"),
+							DELETE_OBJECT("deleteobject", "Objects deleted"),
+							SNAPSHOT("snapshot", "Snapshots taken"),
+							UPLOAD_SOUND("uploadsound", "Sounds uploaded"),
+							UPLOAD_TEXTURE("uploadtexture", "Textures uploaded"),
+							EDIT_TEXTURE("edittexture", "Changes to textures on objects"),
+							KILLED("killed", "Number of times killed"),
+							FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"),
+							TEX_BAKES("texbakes"),
+							TEX_REBAKES("texrebakes");
+LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT("kbitstat"),
+											LAYERS_KBIT("layerskbitstat"),
+											OBJECT_KBIT("objectkbitstat"),
+											ASSET_KBIT("assetkbitstat"),
+											TEXTURE_KBIT("texturekbitstat"),
+											ACTUAL_IN_KBIT("actualinkbitstat"),
+											ACTUAL_OUT_KBIT("actualoutkbitstat");
+
+LLTrace::CountStatHandle<LLTrace::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
+											TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
+											MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
+											FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
+											FPS_8_TIME("fps8time", "Seconds below 8 FPS"),
+											FPS_2_TIME("fps2time", "Seconds below 2 FPS"),
+											SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
+											SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
+											LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
 
 SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DILATION),
 							SIM_FPS("simfps", "", LL_SIM_STAT_FPS),
@@ -128,34 +128,34 @@ SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DIL
 							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS),
 							SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS);
 
-LLTrace::Measurement<>		FPS_SAMPLE("fpssample"),
-							NUM_IMAGES("numimagesstat"),
-							NUM_RAW_IMAGES("numrawimagesstat"),
-							NUM_OBJECTS("numobjectsstat"),
-							NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
-							NUM_NEW_OBJECTS("numnewobjectsstat"),
-							NUM_SIZE_CULLED("numsizeculledstat"),
-							NUM_VIS_CULLED("numvisculledstat"),
-							ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
-							LIGHTING_DETAIL("lightingdetail", "Lighting Detail"),
-							VISIBLE_AVATARS("visibleavatars", "Visible Avatars"),
-							SHADER_OBJECTS("shaderobjects", "Object Shaders"),
-							DRAW_DISTANCE("drawdistance", "Draw Distance"),
-							CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"),
-							PENDING_VFS_OPERATIONS("vfspendingoperations"), 
-							PACKETS_LOST_PERCENT("packetslostpercentstat"),
-							WINDOW_WIDTH("windowwidth", "Window width"),
-							WINDOW_HEIGHT("windowheight", "Window height");
+LLTrace::MeasurementStatHandle<>	FPS_SAMPLE("fpssample"),
+									NUM_IMAGES("numimagesstat"),
+									NUM_RAW_IMAGES("numrawimagesstat"),
+									NUM_OBJECTS("numobjectsstat"),
+									NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
+									NUM_NEW_OBJECTS("numnewobjectsstat"),
+									NUM_SIZE_CULLED("numsizeculledstat"),
+									NUM_VIS_CULLED("numvisculledstat"),
+									ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
+									LIGHTING_DETAIL("lightingdetail", "Lighting Detail"),
+									VISIBLE_AVATARS("visibleavatars", "Visible Avatars"),
+									SHADER_OBJECTS("shaderobjects", "Object Shaders"),
+									DRAW_DISTANCE("drawdistance", "Draw Distance"),
+									CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"),
+									PENDING_VFS_OPERATIONS("vfspendingoperations"), 
+									PACKETS_LOST_PERCENT("packetslostpercentstat"),
+									WINDOW_WIDTH("windowwidth", "Window width"),
+									WINDOW_HEIGHT("windowheight", "Window height");
 	
-LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
+LLTrace::MeasurementStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
 
 
-LLTrace::Measurement<LLTrace::Bytes>	GL_TEX_MEM("gltexmemstat"),
-										GL_BOUND_MEM("glboundmemstat"),
-										RAW_MEM("rawmemstat"),
-										FORMATTED_MEM("formattedmemstat"),
-										DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
-										MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
+LLTrace::MeasurementStatHandle<LLTrace::Bytes>	GL_TEX_MEM("gltexmemstat"),
+												GL_BOUND_MEM("glboundmemstat"),
+												RAW_MEM("rawmemstat"),
+												FORMATTED_MEM("formattedmemstat"),
+												DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
+												MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
 
 	
 SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
@@ -177,17 +177,17 @@ SimMeasurement<LLTrace::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_
 								SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
 
 
-LLTrace::Measurement<LLTrace::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
-											FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
-											LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
-											REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
-											FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
-											UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
-											NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
-											IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
-											REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
-											RENDER_STACKTIME("renderstacktime", "RENDER_SECS"),
-											SIM_PING("simpingstat");
+LLTrace::MeasurementStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+														FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
+														LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
+														REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
+														FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
+														UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
+														NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
+														IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
+														REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
+														RENDER_STACKTIME("renderstacktime", "RENDER_SECS"),
+														SIM_PING("simpingstat");
 	
 }
 
@@ -212,50 +212,50 @@ void LLViewerStats::updateFrameStats(const F64 time_diff)
 	LLTrace::Seconds time_diff_seconds(time_diff);
 	if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0)
 	{
-		LLStatViewer::LOSS_5_PERCENT_TIME.add(time_diff_seconds);
+		add(LLStatViewer::LOSS_5_PERCENT_TIME, time_diff_seconds);
 	}
 	
 	F32 sim_fps = getRecording().getLastValue(LLStatViewer::SIM_FPS);
 	if (0.f < sim_fps && sim_fps < 20.f)
 	{
-		LLStatViewer::SIM_20_FPS_TIME.add(time_diff_seconds);
+		add(LLStatViewer::SIM_20_FPS_TIME, time_diff_seconds);
 	}
 	
 	F32 sim_physics_fps = getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS);
 
 	if (0.f < sim_physics_fps && sim_physics_fps < 20.f)
 	{
-		LLStatViewer::SIM_PHYSICS_20_FPS_TIME.add(time_diff_seconds);
+		add(LLStatViewer::SIM_PHYSICS_20_FPS_TIME, time_diff_seconds);
 	}
 		
 	if (time_diff >= 0.5)
 	{
-		LLStatViewer::FPS_2_TIME.add(time_diff_seconds);
+		add(LLStatViewer::FPS_2_TIME, time_diff_seconds);
 	}
 	if (time_diff >= 0.125)
 	{
-		LLStatViewer::FPS_8_TIME.add(time_diff_seconds);
+		add(LLStatViewer::FPS_8_TIME, time_diff_seconds);
 	}
 	if (time_diff >= 0.1)
 	{
-		LLStatViewer::FPS_10_TIME.add(time_diff_seconds);
+		add(LLStatViewer::FPS_10_TIME, time_diff_seconds);
 	}
 
 	if (gFrameCount && mLastTimeDiff > 0.0)
 	{
 		// new "stutter" meter
-		LLStatViewer::FRAMETIME_DOUBLED.add(time_diff >= 2.0 * mLastTimeDiff ? 1 : 0);
+		add(LLStatViewer::FRAMETIME_DOUBLED, time_diff >= 2.0 * mLastTimeDiff ? 1 : 0);
 
 		// old stats that were never really used
-		LLStatViewer::FRAMETIME_JITTER.sample<LLTrace::Milliseconds>(mLastTimeDiff - time_diff);
+		sample(LLStatViewer::FRAMETIME_JITTER, LLTrace::Milliseconds(mLastTimeDiff - time_diff));
 			
 		F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
-		LLStatViewer::FRAMETIME_SLEW.sample<LLTrace::Milliseconds>(average_frametime - time_diff);
+		sample(LLStatViewer::FRAMETIME_SLEW, LLTrace::Milliseconds(average_frametime - time_diff));
 
 		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
 		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
-		LLStatViewer::DELTA_BANDWIDTH.sample<LLTrace::Bits>(delta_bandwidth);
-		LLStatViewer::MAX_BANDWIDTH.sample<LLTrace::Bits>(max_bandwidth);
+		sample(LLStatViewer::DELTA_BANDWIDTH, LLTrace::Bits(delta_bandwidth));
+		sample(LLStatViewer::MAX_BANDWIDTH, LLTrace::Bits(max_bandwidth));
 	}
 	
 	mLastTimeDiff = time_diff;
@@ -311,53 +311,53 @@ void update_statistics()
 	{
 		if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
 		{
-			LLStatViewer::MOUSELOOK_TIME.add(gFrameIntervalSeconds);
+			add(LLStatViewer::MOUSELOOK_TIME, gFrameIntervalSeconds);
 		}
 		else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
 		{
-			LLStatViewer::AVATAR_EDIT_TIME.add(gFrameIntervalSeconds);
+			add(LLStatViewer::AVATAR_EDIT_TIME, gFrameIntervalSeconds);
 		}
 		else if (LLFloaterReg::instanceVisible("build"))
 		{
-			LLStatViewer::TOOLBOX_TIME.add(gFrameIntervalSeconds);
+			add(LLStatViewer::TOOLBOX_TIME, gFrameIntervalSeconds);
 		}
 	}
-	LLStatViewer::ENABLE_VBO.sample((F64)gSavedSettings.getBOOL("RenderVBOEnable"));
-	LLStatViewer::LIGHTING_DETAIL.sample((F64)gPipeline.getLightingDetail());
-	LLStatViewer::DRAW_DISTANCE.sample((F64)gSavedSettings.getF32("RenderFarClip"));
-	LLStatViewer::CHAT_BUBBLES.sample((F64)gSavedSettings.getBOOL("UseChatBubbles"));
+	sample(LLStatViewer::ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
+	sample(LLStatViewer::LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
+	sample(LLStatViewer::DRAW_DISTANCE, (F64)gSavedSettings.getF32("RenderFarClip"));
+	sample(LLStatViewer::CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
 
-	LLStatViewer::FRAME_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Frame"));
+	sample(LLStatViewer::FRAME_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Frame")));
 	F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle");
 	F64 network_secs = gDebugView->mFastTimerView->getTime("Network");
-	LLStatViewer::UPDATE_STACKTIME.sample<LLTrace::Seconds>(idle_secs - network_secs);
-	LLStatViewer::NETWORK_STACKTIME.sample<LLTrace::Seconds>(network_secs);
-	LLStatViewer::IMAGE_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Update Images"));
-	LLStatViewer::REBUILD_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Sort Draw State"));
-	LLStatViewer::RENDER_STACKTIME.sample<LLTrace::Seconds>(gDebugView->mFastTimerView->getTime("Geometry"));
+	sample(LLStatViewer::UPDATE_STACKTIME, LLTrace::Seconds(idle_secs - network_secs));
+	sample(LLStatViewer::NETWORK_STACKTIME, LLTrace::Seconds(network_secs));
+	sample(LLStatViewer::IMAGE_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Update Images")));
+	sample(LLStatViewer::REBUILD_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Sort Draw State")));
+	sample(LLStatViewer::RENDER_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Geometry")));
 		
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
-		LLStatViewer::SIM_PING.sample<LLTrace::Milliseconds>(cdp->getPingDelay());
+		sample(LLStatViewer::SIM_PING, LLTrace::Milliseconds(cdp->getPingDelay()));
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
-		LLStatViewer::SIM_PING.sample<LLTrace::Seconds>(10);
+		sample(LLStatViewer::SIM_PING, LLTrace::Seconds(10));
 	}
 
-	LLStatViewer::FPS.add(1);
+	add(LLStatViewer::FPS, 1);
 	if (LLTrace::get_frame_recording().getTotalRecording().getSampleCount(LLStatViewer::FPS))
 	{
-		LLStatViewer::FPS_SAMPLE.sample(LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS));
+		sample(LLStatViewer::FPS_SAMPLE, LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS));
 	}
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	LLStatViewer::LAYERS_KBIT.add<LLTrace::Bits>(layer_bits);
-	LLStatViewer::OBJECT_KBIT.add(gObjectData);
-	LLStatViewer::PENDING_VFS_OPERATIONS.sample(LLVFile::getVFSThread()->getPending());
-	LLStatViewer::ASSET_KBIT.add<LLTrace::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET));
+	add(LLStatViewer::LAYERS_KBIT, LLTrace::Bits(layer_bits));
+	add(LLStatViewer::OBJECT_KBIT, gObjectData);
+	sample(LLStatViewer::PENDING_VFS_OPERATIONS, LLVFile::getVFSThread()->getPending());
+	add(LLStatViewer::ASSET_KBIT, LLTrace::Bits(gTransferManager.getTransferBitsIn(LLTCT_ASSET)));
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
 	if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
@@ -378,7 +378,7 @@ void update_statistics()
 			visible_avatar_frames = 1.f;
 			avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames;
 		}
-		LLStatViewer::VISIBLE_AVATARS.sample((F64)avg_visible_avatars);
+		sample(LLStatViewer::VISIBLE_AVATARS, (F64)avg_visible_avatars);
 	}
 	LLWorld::getInstance()->updateNetStats();
 	LLWorld::getInstance()->requestCacheMisses();
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 6b95c9359d..a82c64317e 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -41,26 +41,21 @@ struct SimMeasurementSampler : public LLInstanceTracker<SimMeasurementSampler, E
 	:	LLInstanceTracker<SimMeasurementSampler, ESimStatID>(id)
 	{}
 	virtual ~SimMeasurementSampler() {}
-	virtual void sample(F64 value) = 0;
 };
 
 template<typename T = F64>
-struct SimMeasurement : public LLTrace::Measurement<T>, public SimMeasurementSampler
+struct SimMeasurement : public LLTrace::MeasurementStatHandle<T>, public SimMeasurementSampler
 {
 	SimMeasurement(const char* name, const char* description, ESimStatID stat_id)
-	:	LLTrace::Measurement<T>(name, description),
+	:	LLTrace::MeasurementStatHandle<T>(name, description),
 		SimMeasurementSampler(stat_id)	
 	{}
 
 	using SimMeasurementSampler::getInstance;
-
-	/*virtual*/ void sample(F64 value)
-	{
-		LLTrace::Measurement<T>::sample(T(value));
-	}
 };
 
-extern LLTrace::Count<>						FPS,
+
+extern LLTrace::CountStatHandle<>						FPS,
 											PACKETS_IN,
 											PACKETS_LOST,
 											PACKETS_OUT,
@@ -87,7 +82,7 @@ extern LLTrace::Count<>						FPS,
 											TEX_REBAKES;
 
 
-extern LLTrace::Count<LLTrace::Kilobits>	KBIT,
+extern LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT,
 											LAYERS_KBIT,
 											OBJECT_KBIT,
 											ASSET_KBIT,
@@ -95,7 +90,7 @@ extern LLTrace::Count<LLTrace::Kilobits>	KBIT,
 											ACTUAL_IN_KBIT,
 											ACTUAL_OUT_KBIT;
 
-extern LLTrace::Count<LLTrace::Seconds>		AVATAR_EDIT_TIME,
+extern LLTrace::CountStatHandle<LLTrace::Seconds>		AVATAR_EDIT_TIME,
 											TOOLBOX_TIME,
 											MOUSELOOK_TIME,
 											FPS_10_TIME,
@@ -126,7 +121,7 @@ extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_PHYSICS_PINNED_TASKS,
 											SIM_PHYSICS_LOD_TASKS;
 
-extern LLTrace::Measurement<>				FPS_SAMPLE,
+extern LLTrace::MeasurementStatHandle<>		FPS_SAMPLE,
 											NUM_IMAGES,
 											NUM_RAW_IMAGES,
 											NUM_OBJECTS,
@@ -145,14 +140,14 @@ extern LLTrace::Measurement<>				FPS_SAMPLE,
 											WINDOW_WIDTH,
 											WINDOW_HEIGHT;
 
-extern LLTrace::Measurement<LLTrace::Meters> AGENT_POSITION_SNAP;
+extern LLTrace::MeasurementStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP;
 
-extern LLTrace::Measurement<LLTrace::Bytes>	DELTA_BANDWIDTH,
-											MAX_BANDWIDTH,
-											GL_TEX_MEM,
-											GL_BOUND_MEM,
-											RAW_MEM,
-											FORMATTED_MEM;
+extern LLTrace::MeasurementStatHandle<LLTrace::Bytes>	DELTA_BANDWIDTH,
+														MAX_BANDWIDTH,
+														GL_TEX_MEM,
+														GL_BOUND_MEM,
+														RAW_MEM,
+														FORMATTED_MEM;
 
 extern SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME,
 												SIM_NET_TIME,
@@ -173,7 +168,7 @@ extern SimMeasurement<LLTrace::Bytes>			SIM_UNACKED_BYTES,
 												SIM_PHYSICS_MEM;
 
 
-extern LLTrace::Measurement<LLTrace::Milliseconds>	FRAMETIME_JITTER,
+extern LLTrace::MeasurementStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER,
 													FRAMETIME_SLEW,
 													LOGIN_SECONDS,
 													REGION_CROSSING_TIME,
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 6f8b439049..899ef985ff 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -623,12 +623,12 @@ void LLViewerTextureList::updateImages(F32 max_time)
 
 	{
 		using namespace LLStatViewer;
-		NUM_IMAGES.sample(sNumImages);
-		NUM_RAW_IMAGES.sample(LLImageRaw::sRawImageCount);
-		GL_TEX_MEM.sample(LLImageGL::sGlobalTextureMemory);
-		GL_BOUND_MEM.sample(LLImageGL::sBoundTextureMemory);
-		RAW_MEM.sample<LLTrace::Bytes>(LLImageRaw::sGlobalRawMemory);
-		FORMATTED_MEM.sample<LLTrace::Bytes>(LLImageFormatted::sGlobalFormattedMemory);
+		sample(NUM_IMAGES, sNumImages);
+		sample(NUM_RAW_IMAGES, LLImageRaw::sRawImageCount);
+		sample(GL_TEX_MEM, LLImageGL::sGlobalTextureMemory);
+		sample(GL_BOUND_MEM, LLImageGL::sBoundTextureMemory);
+		sample(RAW_MEM, LLTrace::Bytes(LLImageRaw::sGlobalRawMemory));
+		sample(FORMATTED_MEM, LLTrace::Bytes(LLImageFormatted::sGlobalFormattedMemory));
 	}
 
 	{
@@ -1324,8 +1324,8 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bytes>(received_size);
-	LLStatViewer::TEXTURE_PACKETS.add(1);
+	add(LLStatViewer::TEXTURE_KBIT, LLTrace::Bytes(received_size));
+	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	U8 codec;
 	U16 packets;
@@ -1398,8 +1398,8 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 		received_size = msg->getReceiveSize() ;		
 	}
 
-	LLStatViewer::TEXTURE_KBIT.add<LLTrace::Bytes>(received_size);
-	LLStatViewer::TEXTURE_PACKETS.add(1);
+	add(LLStatViewer::TEXTURE_KBIT, LLTrace::Bytes(received_size));
+	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	//llprintline("Start decode, image header...");
 	msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, id);
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 70792cd0a0..0bd0b2a769 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -248,7 +248,7 @@ std::string	LLViewerWindow::sSnapshotDir;
 
 std::string	LLViewerWindow::sMovieBaseName;
 
-LLTrace::Measurement<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity");
+LLTrace::MeasurementStatHandle<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity");
 
 
 class RecordToChatConsole : public LLError::Recorder, public LLSingleton<RecordToChatConsole>
@@ -2186,8 +2186,8 @@ void LLViewerWindow::reshape(S32 width, S32 height)
 			}
 		}
 
-		LLStatViewer::WINDOW_WIDTH.sample((F64)width);
-		LLStatViewer::WINDOW_HEIGHT.sample((F64)height);
+		sample(LLStatViewer::WINDOW_WIDTH, width);
+		sample(LLStatViewer::WINDOW_HEIGHT, height);
 
 		LLLayoutStack::updateClass();
 	}
@@ -3250,7 +3250,7 @@ void LLViewerWindow::updateMouseDelta()
 		mouse_vel.setVec((F32) dx, (F32) dy);
 	}
     
-	sMouseVelocityStat.sample(mouse_vel.magVec());
+	sample(sMouseVelocityStat, mouse_vel.magVec());
 }
 
 void LLViewerWindow::updateKeyboardFocus()
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index be2d6d885e..004a59fda5 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -250,7 +250,7 @@ public:
 	S32				getCurrentMouseDX()		const	{ return mCurrentMouseDelta.mX; }
 	S32				getCurrentMouseDY()		const	{ return mCurrentMouseDelta.mY; }
 	LLCoordGL		getCurrentMouseDelta()	const	{ return mCurrentMouseDelta; }
-	static LLTrace::Measurement<>*	getMouseVelocityStat()		{ return &sMouseVelocityStat; }
+	static LLTrace::MeasurementStatHandle<>*	getMouseVelocityStat()		{ return &sMouseVelocityStat; }
 	BOOL			getLeftMouseDown()	const	{ return mLeftMouseDown; }
 	BOOL			getMiddleMouseDown()	const	{ return mMiddleMouseDown; }
 	BOOL			getRightMouseDown()	const	{ return mRightMouseDown; }
@@ -482,7 +482,7 @@ private:
 	// Object temporarily hovered over while dragging
 	LLPointer<LLViewerObject>	mDragHoveredObject;
 
-	static LLTrace::Measurement<>	sMouseVelocityStat;
+	static LLTrace::MeasurementStatHandle<>	sMouseVelocityStat;
 };
 
 //
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index cd033c84bf..4ecb7f2fc7 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -913,7 +913,7 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 		{
 			++mRegionCrossingCount;
 			LLTrace::Seconds delta = mRegionCrossingTimer.getElapsedTimeF32();
-			LLStatViewer::REGION_CROSSING_TIME.sample(delta);
+			sample(LLStatViewer::REGION_CROSSING_TIME, delta);
 
 			// Diagnostics
 			llinfos << "Region crossing took " << (F32)(delta * 1000.0).value() << " ms " << llendl;
@@ -2583,7 +2583,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
 					llinfos << "TAT: rebake - matched entry " << (S32)index << llendl;
 					gAgentAvatarp->invalidateComposite(layer_set, TRUE);
 					found = TRUE;
-					LLStatViewer::TEX_REBAKES.add(1);
+					add(LLStatViewer::TEX_REBAKES, 1);
 				}
 			}
 		}
@@ -2628,7 +2628,7 @@ void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug)
 			}
 
 			invalidateComposite(layer_set, TRUE);
-			LLStatViewer::TEX_REBAKES.add(1);
+			add(LLStatViewer::TEX_REBAKES, 1);
 		}
 		else
 		{
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 06e2302b0b..e088f94d64 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -720,15 +720,15 @@ void LLWorld::updateNetStats()
 	S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 
-	LLStatViewer::ACTUAL_IN_KBIT.add<LLTrace::Bits>(actual_in_bits);
-	LLStatViewer::ACTUAL_OUT_KBIT.add<LLTrace::Bits>(actual_out_bits);
-	LLStatViewer::KBIT.add<LLTrace::Bits>(bits);
-	LLStatViewer::PACKETS_IN.add(packets_in);
-	LLStatViewer::PACKETS_OUT.add(packets_out);
-	LLStatViewer::PACKETS_LOST.add(packets_lost);
+	add(LLStatViewer::ACTUAL_IN_KBIT, LLTrace::Bits(actual_in_bits));
+	add(LLStatViewer::ACTUAL_OUT_KBIT, LLTrace::Bits(actual_out_bits));
+	add(LLStatViewer::KBIT, LLTrace::Bits(bits));
+	add(LLStatViewer::PACKETS_IN, packets_in);
+	add(LLStatViewer::PACKETS_OUT, packets_out);
+	add(LLStatViewer::PACKETS_LOST, packets_lost);
 	if (packets_in)
 	{
-		LLStatViewer::PACKETS_LOST_PERCENT.sample(100.f*((F32)packets_lost/(F32)packets_in));
+		sample(LLStatViewer::PACKETS_LOST_PERCENT, 100.f * ((F32)packets_lost/(F32)packets_in));
 	}
 
 	mLastPacketsIn = gMessageSystem->mPacketsIn;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 8d3075d1e1..355fa1350b 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1800,7 +1800,7 @@ void LLPipeline::resetFrameStats()
 {
 	assertInitialized();
 
-	LLStatViewer::TRIANGLES_DRAWN.add(mTrianglesDrawn);
+	add(LLStatViewer::TRIANGLES_DRAWN, mTrianglesDrawn);
 
 	if (mBatchCount > 0)
 	{
@@ -9805,7 +9805,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 	if (gen_shadow)
 	{
-		LLTrace::Count<>* velocity_stat = LLViewerCamera::getVelocityStat();
+		LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat();
 		F32 fade_amt = gFrameIntervalSeconds.value() 
 			* llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecordingPeriod().getDuration().value(), 1.0);
 
-- 
cgit v1.2.3


From 50b32cf2bdb93fad14770aa0f6b92fb3815ebdf0 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 7 Mar 2013 23:54:11 -0700
Subject: for SH-3937: interesting: implement the new cache probe logic

---
 indra/newview/llviewerobject.cpp     |  16 -----
 indra/newview/llviewerobject.h       |   3 +-
 indra/newview/llviewerobjectlist.cpp |  59 ++++++++----------
 indra/newview/llviewerobjectlist.h   |   2 +-
 indra/newview/llviewerregion.cpp     | 116 +++++++++++++++++++++++++++++------
 indra/newview/llviewerregion.h       |  11 ++--
 indra/newview/llvocache.cpp          |  81 +++++-------------------
 indra/newview/llvocache.h            |  26 ++++----
 8 files changed, 161 insertions(+), 153 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index e50509374d..bf7590c640 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -328,22 +328,6 @@ void LLViewerObject::deleteTEImages()
 	mTEImages = NULL;
 }
 
-//if enabled, add this object to vo cache tree when removed from rendering.
-void LLViewerObject::EnableToCacheTree(bool enabled)
-{
-	if(mDrawable.notNull() && mDrawable->getEntry() && mDrawable->getEntry()->hasVOCacheEntry())
-	{
-		if(enabled)
-		{
-			((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry())->addState(LLVOCacheEntry::ADD_TO_CACHE_TREE);
-		}
-		else
-		{
-			((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry())->clearState(LLVOCacheEntry::ADD_TO_CACHE_TREE);
-		}
-	}
-}
-
 void LLViewerObject::markDead()
 {
 	if (!mDead)
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 2db30f1e24..eda9692e19 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -137,8 +137,7 @@ public:
 	BOOL isDead() const									{return mDead;}
 	BOOL isOrphaned() const								{ return mOrphaned; }
 	BOOL isParticleSource() const;
-	void EnableToCacheTree(bool enabled);
-
+	
 	virtual LLVOAvatar* asAvatar();
 
 	static void initVOClasses();
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 995c3e7351..4c959447c6 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -446,6 +446,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 		LLTimer update_timer;
 		BOOL justCreated = FALSE;
 		S32	msg_size = 0;
+		bool remove_from_cache = false; //remove from object cache if it is a full-update or terse update
 
 		if (compressed)
 		{
@@ -455,38 +456,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			uncompressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data);
 			mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compressed_dpbuffer, 0, i);
 			compressed_dp.assignBuffer(compressed_dpbuffer, uncompressed_length);
-#if 0
-			if (compressed)
-			{
-				if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
-				{
-					U32 flags = 0;
-					mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, i);
-					
-					if(!(flags & FLAGS_TEMPORARY_ON_REZ))
-					{
-						//bCached = true;
-						
-						compressed_dp.unpackU32(local_id, "LocalID");
 
-						//-------------
-						compressed_dp.unpackUUID(fullid, "ID");
-						//if(fullid == LLUUID("1e5183db-8f28-47f1-abe0-23de9f9042b7"))
-						{
-							llinfos << fullid << llendl;
-						}
-						//-------------
-
-						U32 crc;
-						compressed_dp.unpackU32(crc, "CRC");
-						/*LLViewerRegion::eCacheUpdateResult result = */regionp->cacheFullUpdate(local_id, crc, compressed_dp);
-						//recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);
-						
-						continue; //do not creat LLViewerObject for cacheable object, object cache will do the job.
-					}
-				}
-			}
-#endif
 			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
 			{
 				U32 flags = 0;
@@ -506,6 +476,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			}
 			else
 			{
+				remove_from_cache = true;
 				compressed_dp.unpackU32(local_id, "LocalID");
 				getUUIDFromLocal(fullid,
 								 local_id,
@@ -535,6 +506,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 		}
 		else // OUT_FULL only?
 		{
+			remove_from_cache = true;
 			mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_FullID, fullid, i);
 			mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
 			msg_size += sizeof(LLUUID);
@@ -542,6 +514,11 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			// llinfos << "Full Update, obj " << local_id << ", global ID" << fullid << "from " << mesgsys->getSender() << llendl;
 		}
 		objectp = findObject(fullid);
+		
+		if(remove_from_cache)
+		{
+			objectp = regionp->forceToRemoveFromCache(local_id, objectp);
+		}
 
 		// This looks like it will break if the local_id of the object doesn't change
 		// upon boundary crossing, but we check for region id matching later...
@@ -618,11 +595,11 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 				recorder.objectUpdateFailure(local_id, update_type, msg_size);
 				continue;
 			}
+
 			justCreated = TRUE;
 			mNumNewObjects++;
 		}
 
-
 		if (objectp->isDead())
 		{
 			llwarns << "Dead object " << objectp->mID << " in UUID map 1!" << llendl;
@@ -1371,7 +1348,7 @@ void LLViewerObjectList::removeDrawable(LLDrawable* drawablep)
 	}
 }
 
-BOOL LLViewerObjectList::killObject(LLViewerObject *objectp, bool cache_enabled)
+BOOL LLViewerObjectList::killObject(LLViewerObject *objectp)
 {
 	// Don't ever kill gAgentAvatarp, just force it to the agent's region
 	// unless region is NULL which is assumed to mean you are logging out.
@@ -1386,7 +1363,6 @@ BOOL LLViewerObjectList::killObject(LLViewerObject *objectp, bool cache_enabled)
 
 	if (objectp)
 	{
-		objectp->EnableToCacheTree(cache_enabled); //enable to add to VO cache tree if set.
 		objectp->markDead(); // does the right thing if object already dead
 		return TRUE;
 	}
@@ -2113,6 +2089,15 @@ S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const
 
 void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port)
 {
+	if(childp->getRegion())
+	{
+		LLVOCacheEntry* entry = childp->getRegion()->getCacheEntry(childp->getLocalID());
+		if(entry != NULL && !entry->isTouched())
+		{
+			return; //object cache will take care of this.
+		}
+	}
+
 #ifdef ORPHAN_SPAM
 	llinfos << "Orphaning object " << childp->getID() << " with parent " << parent_id << llendl;
 #endif
@@ -2168,6 +2153,12 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 		return;
 	}
 
+	//search object cache to get orphans
+	if(objectp->getRegion())
+	{
+		objectp->getRegion()->findOrphans(objectp->getLocalID());
+	}
+
 	// See if we are a parent of an orphan.
 	// Note:  This code is fairly inefficient but it should happen very rarely.
 	// It can be sped up if this is somehow a performance issue...
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index b92be61fae..49931fe75c 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -72,7 +72,7 @@ public:
 
 	LLViewerObject *replaceObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); // TomY: hack to switch VO instances on the fly
 	
-	BOOL killObject(LLViewerObject *objectp, bool cache_enabled = false);
+	BOOL killObject(LLViewerObject *objectp);
 	void killObjects(LLViewerRegion *regionp); // Kill all objects owned by a particular region.
 	void killAllObjects();
 	void removeDrawable(LLDrawable* drawablep);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index b287e0da9c..704b3b644f 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -460,7 +460,11 @@ void LLViewerRegion::saveObjectCache()
 
 	if(LLVOCache::hasInstance())
 	{
-		LLVOCache::getInstance()->writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty) ;
+		//NOTE: !!!!!!!!!!
+		//set this to be true when support full region cache probe!!!!
+		BOOL full_region_cache_probe = FALSE;
+
+		LLVOCache::getInstance()->writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, full_region_cache_probe) ;
 		mCacheDirty = FALSE;
 	}
 
@@ -744,11 +748,13 @@ void LLViewerRegion::dirtyHeights()
 void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry)
 {
 	U32 state = LLVOCacheEntry::INACTIVE;
+	bool in_vo_tree = false;
 
 	if(old_entry)
 	{
 		old_entry->copyTo(new_entry);
-		state = old_entry->getState();		
+		state = old_entry->getState();
+		in_vo_tree = (state == LLVOCacheEntry::INACTIVE && old_entry->getGroup() != NULL);
 		killCacheEntry(old_entry);
 	}
 
@@ -763,7 +769,7 @@ void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry
 	{
 		mImpl->mWaitingSet.insert(new_entry);
 	}
-	else if(old_entry && new_entry->getEntry())
+	else if(!old_entry || in_vo_tree)
 	{
 		addToVOCacheTree(new_entry);
 	}
@@ -880,7 +886,7 @@ void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
 	mImpl->mVisibleGroups.insert(group);
 }
 
-void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry, bool forced)
+void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 {
 	if(!sVOCacheCullingEnabled)
 	{
@@ -895,10 +901,6 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry, bool forced)
 	{
 		return;
 	}
-	if(!forced && !entry->hasState(LLVOCacheEntry::ADD_TO_CACHE_TREE))
-	{
-		return; //can not add to vo cache tree.
-	}
 
 	mImpl->mVOCachePartition->addEntry(entry->getEntry());
 }
@@ -1039,6 +1041,17 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 			{
 				LLVOCacheEntry* vo_entry = (LLVOCacheEntry*)(*i)->getVOCacheEntry();
 
+				if(vo_entry->getParentID() > 0) //is a child
+				{
+					LLVOCacheEntry* parent = getCacheEntry(vo_entry->getParentID());
+					
+					//make sure the parent is active
+					if(!parent || !parent->isState(LLVOCacheEntry::ACTIVE))
+					{
+						continue;
+					}
+				}
+
 				vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);				
 				mImpl->mWaitingList.insert(vo_entry);
 			}
@@ -1140,7 +1153,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 	}
 	for(S32 i = 0; i < delete_list.size(); i++)
 	{
-		gObjectList.killObject(delete_list[i]->getVObj(), true);
+		gObjectList.killObject(delete_list[i]->getVObj());
 	}
 	delete_list.clear();
 
@@ -1194,6 +1207,28 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry)
 	return obj;
 }
 
+//remove from object cache if the object receives a full-update or terse update
+LLViewerObject* LLViewerRegion::forceToRemoveFromCache(U32 local_id, LLViewerObject* objectp)
+{
+	LLVOCacheEntry* entry = getCacheEntry(local_id);
+	if (!entry)
+	{
+		return objectp; //not in the cache, do nothing.
+	}
+	if(!objectp) //object not created
+	{
+		entry->setTouched(FALSE); //mark this entry invalid
+
+		//create a new object before delete it from cache.
+		objectp = gObjectList.processObjectUpdateFromCache(entry, this);
+	}
+
+	//remove from cache.
+	killCacheEntry(entry);
+
+	return objectp;
+}
+
 // As above, but forcibly do the update.
 void LLViewerRegion::forceUpdate()
 {
@@ -1647,15 +1682,32 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features)
 	mSimulatorFeatures = sim_features;
 }
 
-void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry)
+//this is called when the parent is not cacheable.
+//move all orphan children out of cache and insert to rendering octree.
+void LLViewerRegion::findOrphans(U32 parent_id)
+{
+	std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(parent_id);
+	if(iter != mOrphanMap.end())
+	{
+		std::set<U32>* children = mOrphanMap[parent_id].getChildList();
+		for(std::set<U32>::iterator child_iter = children->begin(); child_iter != children->end(); ++child_iter)
+		{
+			forceToRemoveFromCache(*child_iter, NULL);
+		}
+			
+		mOrphanMap.erase(parent_id);
+	}
+}
+
+void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 {
 	if(entry != NULL && !entry->getEntry())
 	{
 		entry->setOctreeEntry(NULL);
 	}
-	else 
+	else if(entry->getGroup() != NULL)
 	{
-		return; //not new entry, no post processing.
+		return; //already in octree, no post processing.
 	}
 
 	LLVector3 pos;
@@ -1667,11 +1719,13 @@ void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry)
 	
 	if(parent_id > 0) //has parent
 	{
+		entry->setParentID(parent_id);
+	
 		//1, find parent, update position
 		LLVOCacheEntry* parent = getCacheEntry(parent_id);
 		
-		//2, if can not, put into the orphan lists: a parents list and a children list
-		if(!parent)
+		//2, if can not, put into the orphan list.
+		if(!parent || !parent->getGroup())
 		{
 			std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(parent_id);
 			if(iter != mOrphanMap.end())
@@ -1680,6 +1734,24 @@ void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry)
 			}
 			else 
 			{
+				//check if the parent is an uncacheable object
+				if(!parent)
+				{
+					LLUUID parent_uuid;
+					LLViewerObjectList::getUUIDFromLocal(parent_uuid,
+															parent_id,
+															getHost().getAddress(),
+															getHost().getPort());
+					LLViewerObject *parent_objp = gObjectList.findObject(parent_uuid);
+					if(parent_objp)
+					{
+						//parent is not cacheable, remove child from the cache.
+						forceToRemoveFromCache(entry->getLocalID(), NULL);
+						return;
+					}
+				}
+
+				//otherwise insert to the orphan list
 				OrphanList o_list(entry->getLocalID());
 				mOrphanMap[parent_id] = o_list;
 			}
@@ -1688,13 +1760,14 @@ void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry)
 		}
 		else
 		{
+			//update the child position to the region space.
 			entry->updateBoundingInfo(parent);
 		}
 	}
 	
 	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
 	{
-		addToVOCacheTree(entry, true);
+		addToVOCacheTree(entry);
 	}
 
 	if(!parent_id) //a potential parent
@@ -1709,6 +1782,7 @@ void LLViewerRegion::postProcesNewEntry(LLVOCacheEntry* entry)
 				LLVOCacheEntry* child = getCacheEntry(*child_iter);
 				if(child)
 				{
+					//update the child position to the region space.
 					child->updateBoundingInfo(entry);
 					addToVOCacheTree(child);
 				}
@@ -1758,7 +1832,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
 				entry = new_entry;
 				
 				mImpl->mCacheMap[local_id] = entry;
-				postProcesNewEntry(entry);
+				decodeBoundingInfo(entry);
 			}
 			
 			result = CACHE_UPDATE_CHANGED;
@@ -1773,7 +1847,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
 		
 		mImpl->mCacheMap[local_id] = entry;
 		
-		postProcesNewEntry(entry);
+		decodeBoundingInfo(entry);
 	}
 	
 	return result;
@@ -1784,6 +1858,10 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 	eCacheUpdateResult result = cacheFullUpdate(dp);
 
 	LLVOCacheEntry* entry = mImpl->mCacheMap[objectp->getLocalID()];
+	if(!entry)
+	{
+		return result;
+	}
 
 	if(objectp->mDrawable.notNull() && !entry->getEntry())
 	{
@@ -1853,8 +1931,8 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 			{
 				return true;
 			}
-			//addVisibleCacheEntry(entry);
-			addToVOCacheTree(entry, true);
+
+			decodeBoundingInfo(entry);
 			return true;
 		}
 		else
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 6da8c191a4..4fc74ee7c3 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -320,9 +320,13 @@ public:
 	eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp);
 	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);	
 	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
+	LLVOCacheEntry* getCacheEntry(U32 local_id);
 	bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type);
 	void requestCacheMisses();
 	void addCacheMissFull(const U32 local_id);
+	//remove from object cache if the object receives a full-update or terse update
+	LLViewerObject* forceToRemoveFromCache(U32 local_id, LLViewerObject* objectp);
+	void findOrphans(U32 parent_id);
 
 	void dumpCache();
 
@@ -348,10 +352,9 @@ public:
 	void getNeighboringRegionsStatus( std::vector<S32>& regions );
 	
 private:
-	void addToVOCacheTree(LLVOCacheEntry* entry, bool forced = false);
+	void addToVOCacheTree(LLVOCacheEntry* entry);
 	LLViewerObject* addNewObject(LLVOCacheEntry* entry);
-	void killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list);
-	LLVOCacheEntry* getCacheEntry(U32 local_id);
+	void killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list);	
 	void removeFromVOCacheTree(LLVOCacheEntry* entry);
 	void replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
 	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
@@ -361,7 +364,7 @@ private:
 	F32 updateVisibleEntries(F32 max_time); //update visible entries
 
 	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight);
-	void postProcesNewEntry(LLVOCacheEntry* entry);
+	void decodeBoundingInfo(LLVOCacheEntry* entry);
 public:
 	struct CompareDistance
 	{
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 26c3e04b92..a9e0dd39d5 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -59,7 +59,9 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mState(INACTIVE),
 	mRepeatedVisCounter(0),
 	mVisFrameRange(64),
-	mSceneContrib(0.f)
+	mSceneContrib(0.f),
+	mTouched(TRUE),
+	mParentID(0)
 {
 	mBuffer = new U8[dp.getBufferSize()];
 	mDP.assignBuffer(mBuffer, dp.getBufferSize());
@@ -77,7 +79,9 @@ LLVOCacheEntry::LLVOCacheEntry()
 	mState(INACTIVE),
 	mRepeatedVisCounter(0),
 	mVisFrameRange(64),
-	mSceneContrib(0.f)
+	mSceneContrib(0.f),
+	mTouched(TRUE),
+	mParentID(0)
 {
 	mDP.assignBuffer(mBuffer, 0);
 }
@@ -88,7 +92,9 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	mState(INACTIVE),
 	mRepeatedVisCounter(0),
 	mVisFrameRange(64),
-	mSceneContrib(0.f)
+	mSceneContrib(0.f),
+	mTouched(FALSE),
+	mParentID(0)
 {
 	S32 size = -1;
 	BOOL success;
@@ -114,36 +120,6 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 		success = check_read(apr_file, &mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
-	{
-		success = check_read(apr_file, &mState, sizeof(U32));
-	}
-	if(success)
-	{
-		F32 ext[8];
-		success = check_read(apr_file, (void*)ext, sizeof(F32) * 8);
-
-		LLVector4a exts[2];
-		exts[0].load4a(ext);
-		exts[1].load4a(&ext[4]);
-	
-		setSpatialExtents(exts[0], exts[1]);
-	}
-	if(success)
-	{
-		LLVector4 pos;
-		success = check_read(apr_file, (void*)pos.mV, sizeof(LLVector4));
-
-		LLVector4a pos_;
-		pos_.load4a(pos.mV);
-		setPositionGroup(pos_);
-	}
-	if(success)
-	{
-		F32 rad;
-		success = check_read(apr_file, &rad, sizeof(F32));
-		setBinRadius(rad);
-	}
-	if(success)
 	{
 		success = check_read(apr_file, &size, sizeof(S32));
 
@@ -229,9 +205,7 @@ void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry)
 
 void LLVOCacheEntry::setState(U32 state)
 {
-	mState &= 0xffff0000; //clear the low 16 bits
-	state &= 0x0000ffff;  //clear the high 16 bits;
-	mState |= state;
+	mState = state;
 
 	if(getState() == ACTIVE)
 	{
@@ -298,6 +272,7 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP()
 
 void LLVOCacheEntry::recordHit()
 {
+	setTouched();
 	mHitCount++;
 }
 
@@ -338,33 +313,6 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 		success = check_write(apr_file, (void*)&mCRCChangeCount, sizeof(S32));
 	}
 	if(success)
-	{
-		U32 state = mState & 0xffff0000; //only store the high 16 bits.
-		success = check_write(apr_file, (void*)&state, sizeof(U32));
-	}
-	if(success)
-	{
-		const LLVector4a* exts = getSpatialExtents() ;
-		LLVector4 ext(exts[0][0], exts[0][1], exts[0][2], exts[0][3]);
-		success = check_write(apr_file, ext.mV, sizeof(LLVector4));		
-		if(success)
-		{
-			ext.set(exts[1][0], exts[1][1], exts[1][2], exts[1][3]);
-			success = check_write(apr_file, ext.mV, sizeof(LLVector4));		
-		}
-	}
-	if(success)
-	{
-		const LLVector4a pos_ = getPositionGroup() ;
-		LLVector4 pos(pos_[0], pos_[1], pos_[2], pos_[3]);
-		success = check_write(apr_file, pos.mV, sizeof(LLVector4));		
-	}
-	if(success)
-	{
-		F32 rad = getBinRadius();
-		success = check_write(apr_file, (void*)&rad, sizeof(F32));
-	}
-	if(success)
 	{
 		S32 size = mDP.getBufferSize();
 		success = check_write(apr_file, (void*)&size, sizeof(S32));
@@ -958,7 +906,7 @@ void LLVOCache::purgeEntries(U32 size)
 	mNumEntries = mHandleEntryMap.size() ;
 }
 
-void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) 
+void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, BOOL full_region_cache_probe) 
 {
 	if(!mEnabled)
 	{
@@ -1031,7 +979,10 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 	
 			for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter)
 			{
-				success = iter->second->writeToFile(&apr_file) ;
+				if(!full_region_cache_probe || iter->second->isTouched())
+				{
+					success = iter->second->writeToFile(&apr_file) ;
+				}
 			}
 		}
 	}
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 7c1706e650..a64944f562 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -41,7 +41,7 @@ class LLCamera;
 class LLVOCacheEntry : public LLViewerOctreeEntryData
 {
 public:
-	enum
+	enum //low 16-bit state
 	{
 		INACTIVE = 0x00000000,     //not visible
 		IN_QUEUE = 0x00000001,     //in visible queue, object to be created
@@ -49,11 +49,6 @@ public:
 		ACTIVE   = 0x00000004      //object created, and in rendering pipeline.
 	};
 
-	enum
-	{
-		ADD_TO_CACHE_TREE = 0x00010000, //has parent
-	};
-
 	struct CompareVOCacheEntry
 	{
 		bool operator()(const LLVOCacheEntry* const& lhs, const LLVOCacheEntry* const& rhs)
@@ -84,12 +79,10 @@ public:
 	LLVOCacheEntry();	
 
 	void setState(U32 state);
-	void clearState(U32 state) {mState &= ~state;}
-	void addState(U32 state)   {mState |= state;}
-	bool isState(U32 state)    {return (mState & 0xffff) == state;}
+	//void clearState(U32 state) {mState &= ~state;}
+	bool isState(U32 state)    {return mState == state;}
 	bool hasState(U32 state)   {return mState & state;}
-	U32  getState() const      {return (mState & 0xffff);}
-	U32  getFullState() const  {return mState;}
+	U32  getState() const      {return mState;}
 	
 	U32 getLocalID() const			{ return mLocalID; }
 	U32 getCRC() const				{ return mCRC; }
@@ -111,6 +104,9 @@ public:
 	void copyTo(LLVOCacheEntry* new_entry); //copy variables 
 	/*virtual*/ void setOctreeEntry(LLViewerOctreeEntry* entry);
 
+	void setParentID(U32 id) {mParentID = id;}
+	U32  getParentID() const {return mParentID;}
+
 	void addChild(LLVOCacheEntry* entry);
 	LLVOCacheEntry* getChild(S32 i) {return mChildrenList[i];}
 	S32  getNumOfChildren()         {return mChildrenList.size();}
@@ -119,6 +115,9 @@ public:
 	//called from processing object update message
 	void setBoundingInfo(const LLVector3& pos, const LLVector3& scale);
 	void updateBoundingInfo(LLVOCacheEntry* parent);
+
+	void setTouched(BOOL touched = TRUE) {mTouched = touched;}
+	BOOL isTouched() const {return mTouched;}
 	
 public:
 	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;
@@ -127,6 +126,7 @@ public:
 
 protected:
 	U32							mLocalID;
+	U32                         mParentID;
 	U32							mCRC;
 	S32							mHitCount;
 	S32							mDupeCount;
@@ -139,6 +139,8 @@ protected:
 	S32                         mRepeatedVisCounter; //number of repeatedly visible within a short time.
 	U32                         mState; //high 16 bits reserved for special use.
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
+
+	BOOL                        mTouched; //if set, this entry is valid, otherwise it is invalid.
 };
 
 class LLVOCachePartition : public LLViewerOctreePartition
@@ -199,7 +201,7 @@ public:
 	void removeCache(ELLPath location) ;
 
 	void readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) ;
-	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) ;
+	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, BOOL full_region_cache_probe);
 	void removeEntry(U64 handle) ;
 
 	void setReadOnly(BOOL read_only) {mReadOnly = read_only;} 
-- 
cgit v1.2.3


From 81edcde603b82233662d13d58f8b0c7955b5a7e1 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 8 Mar 2013 11:14:03 -0700
Subject: remove some redundant code for SH-3937: interesting: implement the
 new cache probe logic

---
 indra/newview/llviewerobjectlist.cpp | 9 ---------
 1 file changed, 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 4c959447c6..6202a7b6cc 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -2089,15 +2089,6 @@ S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const
 
 void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port)
 {
-	if(childp->getRegion())
-	{
-		LLVOCacheEntry* entry = childp->getRegion()->getCacheEntry(childp->getLocalID());
-		if(entry != NULL && !entry->isTouched())
-		{
-			return; //object cache will take care of this.
-		}
-	}
-
 #ifdef ORPHAN_SPAM
 	llinfos << "Orphaning object " << childp->getID() << " with parent " << parent_id << llendl;
 #endif
-- 
cgit v1.2.3


From 4e3fddf271e6ff4557f594b6a8c036ab2a4e413f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 8 Mar 2013 17:08:00 -0800
Subject: fixed remaining sample and add calls

---
 indra/newview/llfloaterjoystick.cpp  |  2 +-
 indra/newview/llviewerassetstats.cpp |  6 +++---
 indra/newview/llviewercamera.cpp     |  4 ++--
 indra/newview/llviewerstats.h        | 13 ++++++++++++-
 4 files changed, 18 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index 25c119d9e1..7fcebc965a 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -77,7 +77,7 @@ void LLFloaterJoystick::draw()
 	for (U32 i = 0; i < 6; i++)
 	{
 		F32 value = joystick->getJoystickAxis(i);
-		sJoystickAxes[i]->sample(value * gFrameIntervalSeconds.value());
+		sample(*sJoystickAxes[i], value * gFrameIntervalSeconds.value());
 		if (mAxisStatsBar[i])
 		{
 			F32 minbar, maxbar;
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 0c72c3c5aa..8623af52ff 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -547,21 +547,21 @@ void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sEnqueued[int(eac)]->add(1);
+	add(*sEnqueued[int(eac)], 1);
 }
 
 void record_dequeue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sDequeued[int(eac)]->add(1);
+	add(*sDequeued[int(eac)], 1);
 }
 
 void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp, LLViewerAssetStats::duration_t duration)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sResponse[int(eac)]->sample<LLTrace::Microseconds>(duration);
+	sample(*sResponse[int(eac)], LLTrace::Microseconds(duration));
 }
 
 void record_avatar_stats()
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index 6e0a2c88a8..9ca5f07f35 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -167,8 +167,8 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
 	F32 drot;
 	rotation.getAngleAxis(&drot, &x, &y, &z);
 
-	sVelocityStat.add(dpos);
-	sAngularVelocityStat.add(drot);
+	add(sVelocityStat, dpos);
+	add(sAngularVelocityStat, drot);
 	
 	mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat);
 	mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat);
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index a82c64317e..069a726e5e 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -41,6 +41,8 @@ struct SimMeasurementSampler : public LLInstanceTracker<SimMeasurementSampler, E
 	:	LLInstanceTracker<SimMeasurementSampler, ESimStatID>(id)
 	{}
 	virtual ~SimMeasurementSampler() {}
+
+	virtual void sample(F64 value) = 0;
 };
 
 template<typename T = F64>
@@ -52,9 +54,18 @@ struct SimMeasurement : public LLTrace::MeasurementStatHandle<T>, public SimMeas
 	{}
 
 	using SimMeasurementSampler::getInstance;
-};
 
+	/*virtual*/ void sample(F64 value)
+	{
+		LLTrace::sample(*this, value);
+	}
+};
 
+template<typename T, typename VALUE_T>
+void sample(SimMeasurement<T>& measurement, VALUE_T value)
+{
+	LLTrace::sample(measurement, value);
+}
 extern LLTrace::CountStatHandle<>						FPS,
 											PACKETS_IN,
 											PACKETS_LOST,
-- 
cgit v1.2.3


From 79dc4a1190a2954a7f1338596aa2d63ea3a96fff Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 11 Mar 2013 11:34:22 -0600
Subject: for SH-3976: interesting: make new object cache be able to handle
 shadows.

---
 indra/newview/llvocache.cpp | 9 +--------
 indra/newview/llvocache.h   | 3 ---
 2 files changed, 1 insertion(+), 11 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index a9e0dd39d5..ac97f1b6ce 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -377,8 +377,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 {
 	mRegionp = regionp;
 	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
-	mVisitedTime = 0;
-
+	
 	new LLviewerOctreeGroup(mOctree);
 }
 
@@ -445,12 +444,6 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
 		return 0;
 	}
 
-	if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame())
-	{
-		return 0; //already visited.
-	}
-	mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame();
-
 	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
 
 	//localize the camera
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index a64944f562..ca25583922 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -151,9 +151,6 @@ public:
 	void addEntry(LLViewerOctreeEntry* entry);
 	void removeEntry(LLViewerOctreeEntry* entry);
 	/*virtual*/ S32 cull(LLCamera &camera);
-
-private:
-	U32 mVisitedTime;
 };
 
 //
-- 
cgit v1.2.3


From 27bb36b1e796add58f319555bf761e417f7957ef Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 11 Mar 2013 21:23:15 -0600
Subject: for SH-3979: interesting: can not edit objects with new object cache
 code

---
 indra/newview/llviewerobject.cpp     | 20 +++++++++++++++-----
 indra/newview/llviewerobject.h       |  1 +
 indra/newview/llviewerobjectlist.cpp |  7 ++++---
 indra/newview/llviewerregion.cpp     | 18 ++++++++++++++----
 indra/newview/llviewerregion.h       |  4 ++--
 indra/newview/llvocache.cpp          |  3 +++
 indra/newview/llvocache.h            |  4 ++++
 7 files changed, 43 insertions(+), 14 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index bf7590c640..dca159f982 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -1838,11 +1838,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 				{
 					U32 flags;
 					mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, block_num);
-					// keep local flags and overwrite remote-controlled flags
-					mFlags = (mFlags & FLAGS_LOCAL) | flags;
-
-					// ...new objects that should come in selected need to be added to the selected list
-					mCreateSelected = ((flags & FLAGS_CREATE_SELECTED) != 0);
+					loadFlags(flags);					
 				}
 			}
 			break;
@@ -2343,7 +2339,21 @@ BOOL LLViewerObject::isActive() const
 	return TRUE;
 }
 
+//load flags from cache or from message
+void LLViewerObject::loadFlags(U32 flags)
+{
+	if(flags == (U32)(-1))
+	{
+		return; //invalid
+	}
+
+	// keep local flags and overwrite remote-controlled flags
+	mFlags = (mFlags & FLAGS_LOCAL) | flags;
 
+	// ...new objects that should come in selected need to be added to the selected list
+	mCreateSelected = ((flags & FLAGS_CREATE_SELECTED) != 0);
+	return;
+}
 
 void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index eda9692e19..a1f63faf5b 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -511,6 +511,7 @@ public:
 	virtual void	updateRegion(LLViewerRegion *regionp);
 
 	void updateFlags(BOOL physics_changed = FALSE);
+	void loadFlags(U32 flags); //load flags from cache or from message
 	BOOL setFlags(U32 flag, BOOL state);
 	BOOL setFlagsWithoutUpdate(U32 flag, BOOL state);
 	void setPhysicsShapeType(U8 type);
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 6202a7b6cc..873b6e1d03 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -365,7 +365,8 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 	}
 		
 	processUpdateCore(objectp, NULL, 0, OUT_FULL_CACHED, cached_dpp, justCreated, true);
-		
+	objectp->loadFlags(entry->getUpdateFlags()); //just in case, reload update flags from cache.
+
 	recorder.log(0.2f);
 	LLVOAvatar::cullAvatarsByPixelArea();
 
@@ -470,7 +471,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 				}
 				else //send to object cache
 				{
-					regionp->cacheFullUpdate(compressed_dp);
+					regionp->cacheFullUpdate(compressed_dp, flags);
 					continue;
 				}
 			}
@@ -623,7 +624,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 				if(!(flags & FLAGS_TEMPORARY_ON_REZ))
 				{
 					bCached = true;
-					LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp);
+					LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp, flags);
 					recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);
 				}
 			}
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 704b3b644f..c74e7158b6 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1795,7 +1795,7 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 	return ;
 }
 
-LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerBinaryBuffer &dp)
+LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerBinaryBuffer &dp, U32 flags)
 {
 	eCacheUpdateResult result;
 	U32 crc;
@@ -1849,14 +1849,16 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
 		
 		decodeBoundingInfo(entry);
 	}
-	
+	entry->setUpdateFlags(flags);
+
 	return result;
 }
 
-LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp)
+LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags)
 {
-	eCacheUpdateResult result = cacheFullUpdate(dp);
+	eCacheUpdateResult result = cacheFullUpdate(dp, flags);
 
+#if 0
 	LLVOCacheEntry* entry = mImpl->mCacheMap[objectp->getLocalID()];
 	if(!entry)
 	{
@@ -1871,6 +1873,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 	{
 		addActiveCacheEntry(entry);
 	}
+#endif
 
 	return result;
 }
@@ -1926,7 +1929,14 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 			// Record a hit
 			entry->recordHit();
 			cache_miss_type = CACHE_MISS_TYPE_NONE;
+			entry->setUpdateFlags(flags);
 			
+			if(entry->isState(LLVOCacheEntry::ACTIVE))
+			{
+				((LLDrawable*)entry->getEntry()->getDrawable())->getVObj()->loadFlags(flags);
+				return true;
+			}
+
 			if(entry->getGroup() || !entry->isState(LLVOCacheEntry::INACTIVE))
 			{
 				return true;
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 4fc74ee7c3..a903f61cbc 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -317,8 +317,8 @@ public:
 	} eCacheUpdateResult;
 
 	// handle a full update message
-	eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp);
-	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp);	
+	eCacheUpdateResult cacheFullUpdate(LLDataPackerBinaryBuffer &dp, U32 flags);
+	eCacheUpdateResult cacheFullUpdate(LLViewerObject* objectp, LLDataPackerBinaryBuffer &dp, U32 flags);	
 	LLVOCacheEntry* getCacheEntryForOctree(U32 local_id);
 	LLVOCacheEntry* getCacheEntry(U32 local_id);
 	bool probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index ac97f1b6ce..5f112675dc 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -53,6 +53,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY),
 	mLocalID(local_id),
 	mCRC(crc),
+	mUpdateFlags(-1),
 	mHitCount(0),
 	mDupeCount(0),
 	mCRCChangeCount(0),
@@ -72,6 +73,7 @@ LLVOCacheEntry::LLVOCacheEntry()
 	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY),
 	mLocalID(0),
 	mCRC(0),
+	mUpdateFlags(-1),
 	mHitCount(0),
 	mDupeCount(0),
 	mCRCChangeCount(0),
@@ -89,6 +91,7 @@ LLVOCacheEntry::LLVOCacheEntry()
 LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY), 
 	mBuffer(NULL),
+	mUpdateFlags(-1),
 	mState(INACTIVE),
 	mRepeatedVisCounter(0),
 	mVisFrameRange(64),
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index ca25583922..64eb876919 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -119,6 +119,9 @@ public:
 	void setTouched(BOOL touched = TRUE) {mTouched = touched;}
 	BOOL isTouched() const {return mTouched;}
 	
+	void setUpdateFlags(U32 flags) {mUpdateFlags = flags;}
+	U32  getUpdateFlags() const    {return mUpdateFlags;}
+
 public:
 	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;
 	typedef std::set<LLVOCacheEntry*>                      vocache_entry_set_t;
@@ -128,6 +131,7 @@ protected:
 	U32							mLocalID;
 	U32                         mParentID;
 	U32							mCRC;
+	U32                         mUpdateFlags; //receive from sim
 	S32							mHitCount;
 	S32							mDupeCount;
 	S32							mCRCChangeCount;
-- 
cgit v1.2.3


From 4624848a6894be669cdb19a82101ea168c407ecd Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 13 Mar 2013 22:31:19 -0600
Subject: revert changes for SH-3653: Can we repurpose
 ObjectUpdateCached:ObjectData:UpdateFlags field to carry spatial+size data?

---
 indra/newview/llviewerregion.cpp | 22 +++++-----------------
 indra/newview/llviewerregion.h   | 17 +++--------------
 2 files changed, 8 insertions(+), 31 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index c74e7158b6..bf4bff60d7 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1896,21 +1896,9 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id)
 	return NULL;
 }
 
-//estimate weight of cache missed object
-F32 LLViewerRegion::calcObjectWeight(U32 flags)
+void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type)
 {
-	LLVector3 pos((F32)(flags & 0xff) + 0.5f, (F32)((flags >> 8) & 0xff) + 0.5f, (F32)((flags >> 16) & 0xff) * 16.f + 8.0f);
-	F32 rad = (F32)((flags >> 24) & 0xff);
-
-	pos += getOriginAgent();
-	pos -= LLViewerCamera::getInstance()->getOrigin();
-
-	return 100.f * rad * rad / pos.lengthSquared();
-}
-
-void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight)
-{
-	mCacheMissList.insert(CacheMissItem(id, miss_type, weight));
+	mCacheMissList.insert(CacheMissItem(id, miss_type));
 }
 
 // Get data packer for this object, if we have cached data
@@ -1949,13 +1937,13 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 		{
 			// llinfos << "CRC miss for " << local_id << llendl;
 
-			addCacheMiss(local_id, CACHE_MISS_TYPE_CRC, calcObjectWeight(flags));
+			addCacheMiss(local_id, CACHE_MISS_TYPE_CRC);
 		}
 	}
 	else
 	{
 		// llinfos << "Cache miss for " << local_id << llendl;
-		addCacheMiss(local_id, CACHE_MISS_TYPE_FULL, calcObjectWeight(flags));
+		addCacheMiss(local_id, CACHE_MISS_TYPE_FULL);
 	}
 
 	return false;
@@ -1963,7 +1951,7 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 
 void LLViewerRegion::addCacheMissFull(const U32 local_id)
 {
-	addCacheMiss(local_id, CACHE_MISS_TYPE_FULL, 100.f);
+	addCacheMiss(local_id, CACHE_MISS_TYPE_FULL);
 }
 
 void LLViewerRegion::requestCacheMisses()
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index a903f61cbc..15c2b36e38 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -169,9 +169,6 @@ public:
 	const LLVector3d &getOriginGlobal() const;
 	LLVector3 getOriginAgent() const;
 
-	//estimate weight of cache missed object
-	F32 calcObjectWeight(U32 flags);
-
 	// Center is at the height of the water table.
 	const LLVector3d &getCenterGlobal() const;
 	LLVector3 getCenterAgent() const;
@@ -363,7 +360,7 @@ private:
 	F32 createVisibleObjects(F32 max_time);
 	F32 updateVisibleEntries(F32 max_time); //update visible entries
 
-	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight);
+	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type);
 	void decodeBoundingInfo(LLVOCacheEntry* entry);
 public:
 	struct CompareDistance
@@ -468,24 +465,16 @@ private:
 	class CacheMissItem
 	{
 	public:
-		CacheMissItem(U32 id, LLViewerRegion::eCacheMissType miss_type, F32 weight) : mID(id), mType(miss_type), mWeight(weight){}
+		CacheMissItem(U32 id, LLViewerRegion::eCacheMissType miss_type) : mID(id), mType(miss_type){}
 
 		U32                            mID;     //local object id
 		LLViewerRegion::eCacheMissType mType;   //cache miss type
-		F32                            mWeight; //importance of this object to the current camera.
 	
 		struct Compare
 		{
 			bool operator()(const CacheMissItem& lhs, const CacheMissItem& rhs)
 			{
-				if(lhs.mWeight == rhs.mWeight) //larger weight first
-				{
-					return &lhs < &rhs;
-				}
-				else 
-				{
-					return lhs.mWeight > rhs.mWeight; //larger weight first
-				}
+				return lhs.mID < rhs.mID; //smaller ID first.
 			}
 		};
 
-- 
cgit v1.2.3


From bdf562036a8ce864bf211b7696b1d74334030f4b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 13 Mar 2013 22:38:00 -0600
Subject: for SH-3913: the viewer should notify the region at connect time if
 it does not have a cache file

---
 indra/newview/llviewerregion.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index bf4bff60d7..bca2108964 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2164,7 +2164,13 @@ void LLViewerRegion::unpackRegionHandshake()
 	msg->addUUID("AgentID", gAgent.getID());
 	msg->addUUID("SessionID", gAgent.getSessionID());
 	msg->nextBlock("RegionInfo");
-	msg->addU32("Flags", 0x0 );
+
+	U32 flags = 0x00000001; //set the bit 0 to be 1 to ask sim to send all cacheable objects.
+	if(mImpl->mCacheMap.empty())
+	{
+		flags |= 0x00000002; //set the bit 1 to be 1 to tell sim the cache file is empty, no need to send cache probes.
+	}
+	msg->addU32("Flags", flags );
 	msg->sendReliable(host);
 }
 
-- 
cgit v1.2.3


From 7b4d27ecbcb5ac702459be97cbf6b81354850658 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 14 Mar 2013 19:36:50 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 collapsed Orientation enums to all use LLView::EOrientation added ability to
 display stat bar horizontally

---
 indra/newview/lltoolbarview.cpp                      | 6 +++---
 indra/newview/llviewermessage.cpp                    | 2 +-
 indra/newview/skins/default/xui/en/floater_stats.xml | 1 +
 3 files changed, 5 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp
index 81ad96f39e..da7b259377 100644
--- a/indra/newview/lltoolbarview.cpp
+++ b/indra/newview/lltoolbarview.cpp
@@ -517,7 +517,7 @@ void LLToolBarView::draw()
 	{
 		if (mToolbars[i])
 		{
-			LLLayoutStack::ELayoutOrientation orientation = LLToolBarEnums::getOrientation(mToolbars[i]->getSideType());
+			LLView::EOrientation orientation = LLToolBarEnums::getOrientation(mToolbars[i]->getSideType());
 
 			if (orientation == LLLayoutStack::HORIZONTAL)
 			{
@@ -535,8 +535,8 @@ void LLToolBarView::draw()
 	for (S32 i = TOOLBAR_FIRST; i <= TOOLBAR_LAST; i++)
 	{
 		mToolbars[i]->getParent()->setVisible(mShowToolbars 
-											&& (mToolbars[i]->hasButtons() 
-											|| isToolDragged()));
+												&& (mToolbars[i]->hasButtons() 
+													|| isToolDragged()));
 	}
 
 	// Draw drop zones if drop of a tool is active
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index db169b86a4..483e42d296 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4065,7 +4065,7 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 		{
 			LLTracker::stopTracking(NULL);
 		}
-		else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() )
+		else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() && look_at.isExactlyZero())
 		{
 			//look at the beacon
 			LLVector3 global_agent_pos = agent_pos;
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 273954ee3e..93d9945800 100644
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -35,6 +35,7 @@
 			 setting="OpenDebugStatBasic">
 			<stat_bar
 			   name="fps"
+         orientation="horizontal"
 			   label="FPS"
 			   unit_label="fps"
 			   stat="fpsstat"
-- 
cgit v1.2.3


From ba54846697aded3a19cb91d53436d3ab26fa0aed Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 14 Mar 2013 20:54:28 -0600
Subject: for SH-3968: Rendering issues when scene loading monitoring code
 disabled on Mac.

---
 indra/newview/llscenemonitor.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 189697dcf0..82ab90e325 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -410,6 +410,7 @@ void LLSceneMonitorView::onClickCloseBtn()
 
 void LLSceneMonitorView::setVisible(BOOL visible)
 {
+	visible = visible && LLGLSLShader::sNoFixedFunction;
 	LLSceneMonitor::getInstance()->setDebugViewerVisible(visible);
 
 	LLView::setVisible(visible);
-- 
cgit v1.2.3


From 8de397b19ec9e2f6206fd5ae57dba96c70e78b74 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 18 Mar 2013 08:43:03 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 changed LLCriticalDamp to LLSmoothInterpolation and sped up interpolator
 lookup improvements to stats display of llstatbar added scene load stats
 floater accessed with ctrl|shift|2

---
 indra/newview/llagentcamera.cpp                    |  14 +-
 indra/newview/llappviewer.cpp                      |   4 +-
 indra/newview/lldrawable.cpp                       |   2 +-
 indra/newview/llfasttimerview.cpp                  |   6 +-
 indra/newview/llfloatercolorpicker.cpp             |   4 +-
 indra/newview/llfloatersnapshot.cpp                |   4 +-
 indra/newview/llfolderviewitem.cpp                 |   6 +-
 indra/newview/llfollowcam.cpp                      |  10 +-
 indra/newview/llhudnametag.cpp                     |   2 +-
 indra/newview/llmaniprotate.cpp                    |  18 +-
 indra/newview/llmanipscale.cpp                     |   4 +-
 indra/newview/llmaniptranslate.cpp                 |  12 +-
 indra/newview/llnetmap.cpp                         |   2 +-
 indra/newview/lltexturectrl.cpp                    |   4 +-
 indra/newview/llviewerdisplay.cpp                  |   2 +-
 indra/newview/llviewerfloaterreg.cpp               |   1 +
 indra/newview/llviewerstats.cpp                    |   4 +-
 indra/newview/llviewerstats.h                      |   4 +-
 indra/newview/llvoavatar.cpp                       |   8 +-
 indra/newview/llworldmapview.cpp                   |   4 +-
 .../default/xui/en/floater_scene_load_stats.xml    | 549 +++++++++++++++++++++
 .../newview/skins/default/xui/en/floater_stats.xml |  49 --
 indra/newview/skins/default/xui/en/menu_viewer.xml |   8 +
 23 files changed, 615 insertions(+), 106 deletions(-)
 create mode 100644 indra/newview/skins/default/xui/en/floater_scene_load_stats.xml

(limited to 'indra/newview')

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 4e6079e3f2..6648431459 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -336,7 +336,7 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 			LLVector3 agent_at_axis = gAgent.getAtAxis();
 			agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector());
 			agent_at_axis.normalize();
-			gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLCriticalDamp::getInterpolant(0.3f)));
+			gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f)));
 		}
 
 		setFocusOnAvatar(TRUE, ANIMATE);
@@ -1246,7 +1246,7 @@ void LLAgentCamera::updateCamera()
 	gAgentCamera.clearPanKeys();
 
 	// lerp camera focus offset
-	mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLCriticalDamp::getInterpolant(CAMERA_FOCUS_HALF_LIFE));
+	mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLSmoothInterpolation::getInterpolant(CAMERA_FOCUS_HALF_LIFE));
 
 	if ( mCameraMode == CAMERA_MODE_FOLLOW )
 	{
@@ -1364,7 +1364,7 @@ void LLAgentCamera::updateCamera()
 		{
 			const F32 SMOOTHING_HALF_LIFE = 0.02f;
 			
-			F32 smoothing = LLCriticalDamp::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE);
+			F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE);
 					
 			if (!mFocusObject)  // we differentiate on avatar mode 
 			{
@@ -1394,7 +1394,7 @@ void LLAgentCamera::updateCamera()
 	}
 
 	
-	mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLCriticalDamp::getInterpolant(FOV_ZOOM_HALF_LIFE));
+	mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE));
 
 //	llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl;
 
@@ -1809,7 +1809,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 			if (mTargetCameraDistance != mCurrentCameraDistance)
 			{
-				F32 camera_lerp_amt = LLCriticalDamp::getInterpolant(CAMERA_ZOOM_HALF_LIFE);
+				F32 camera_lerp_amt = LLSmoothInterpolation::getInterpolant(CAMERA_ZOOM_HALF_LIFE);
 
 				mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt);
 			}
@@ -1827,7 +1827,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 			if (isAgentAvatarValid())
 			{
 				LLVector3d camera_lag_d;
-				F32 lag_interp = LLCriticalDamp::getInterpolant(CAMERA_LAG_HALF_LIFE);
+				F32 lag_interp = LLSmoothInterpolation::getInterpolant(CAMERA_LAG_HALF_LIFE);
 				LLVector3 target_lag;
 				LLVector3 vel = gAgent.getVelocity();
 
@@ -1872,7 +1872,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 				}
 				else
 				{
-					mCameraLag = lerp(mCameraLag, LLVector3::zero, LLCriticalDamp::getInterpolant(0.15f));
+					mCameraLag = lerp(mCameraLag, LLVector3::zero, LLSmoothInterpolation::getInterpolant(0.15f));
 				}
 
 				camera_lag_d.setVec(mCameraLag);
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c00fddbb24..0cb7c7b030 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4210,7 +4210,7 @@ void LLAppViewer::idle()
 	LLFrameTimer::updateFrameCount();
 	LLEventTimer::updateClass();
 	LLNotificationsUI::LLToast::updateClass();
-	LLCriticalDamp::updateInterpolants();
+	LLSmoothInterpolation::updateInterpolants();
 	LLMortician::updateClass();
 	LLFilePickerThread::clearDead();  //calls LLFilePickerThread::notify()
 
@@ -4865,7 +4865,7 @@ void LLAppViewer::idleNetwork()
 			gPrintMessagesThisFrame = FALSE;
 		}
 	}
-	sample(LLStatViewer::NUM_NEW_OBJECTS, gObjectList.mNumNewObjects);
+	add(LLStatViewer::NUM_NEW_OBJECTS, gObjectList.mNumNewObjects);
 
 	// Retransmit unacknowledged packets.
 	gXferManager->retransmitUnackedPackets();
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 9c3d9f4d34..a0c71b0f73 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -557,7 +557,7 @@ F32 LLDrawable::updateXform(BOOL undamped)
 
 	if (damped && isVisible())
 	{
-		F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f);
+		F32 lerp_amt = llclamp(LLSmoothInterpolation::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f);
 		LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt);
 		dist_squared = dist_vec_squared(new_pos, target_pos);
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 3893b0e772..f55535b6e3 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1128,13 +1128,13 @@ void LLFastTimerView::drawLineGraph()
 	}
 	
 	//interpolate towards new maximum
-	max_time = lerp(max_time.value(), cur_max.value(), LLCriticalDamp::getInterpolant(0.1f));
+	max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f));
 	if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
 	{
 		max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max));
 	}
 
-	max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLCriticalDamp::getInterpolant(0.1f)));
+	max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f)));
 	if (llabs((S32)(max_calls - cur_max_calls)) <= 1)
 	{
 		max_calls = cur_max_calls;
@@ -1144,7 +1144,7 @@ void LLFastTimerView::drawLineGraph()
 	F32 alpha_target = (max_time > cur_max)
 		? llmin(max_time / cur_max - 1.f,1.f) 
 		: llmin(cur_max/ max_time - 1.f,1.f);
-	alpha_interp = lerp(alpha_interp, alpha_target, LLCriticalDamp::getInterpolant(0.1f));
+	alpha_interp = lerp(alpha_interp, alpha_target, LLSmoothInterpolation::getInterpolant(0.1f));
 
 	if (mHoverID != NULL)
 	{
diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp
index 05d73c2416..e2beb272e6 100644
--- a/indra/newview/llfloatercolorpicker.cpp
+++ b/indra/newview/llfloatercolorpicker.cpp
@@ -525,11 +525,11 @@ void LLFloaterColorPicker::draw()
 
 	if (gFocusMgr.childHasMouseCapture(getDragHandle()))
 	{
-		mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
+		mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME));
 	}
 	else
 	{
-		mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
+		mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME));
 	}
 
 	mPipetteBtn->setToggleState(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 04fc572220..285f52fcd6 100644
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -478,7 +478,7 @@ void LLSnapshotLivePreview::draw()
 		{
 			if (mFlashAlpha < 1.f)
 			{
-				mFlashAlpha = lerp(mFlashAlpha, 1.f, LLCriticalDamp::getInterpolant(0.02f));
+				mFlashAlpha = lerp(mFlashAlpha, 1.f, LLSmoothInterpolation::getInterpolant(0.02f));
 			}
 			else
 			{
@@ -487,7 +487,7 @@ void LLSnapshotLivePreview::draw()
 		}
 		else
 		{
-			mFlashAlpha = lerp(mFlashAlpha, 0.f, LLCriticalDamp::getInterpolant(0.15f));
+			mFlashAlpha = lerp(mFlashAlpha, 0.f, LLSmoothInterpolation::getInterpolant(0.15f));
 		}
 
 		// Draw shining animation if appropriate.
diff --git a/indra/newview/llfolderviewitem.cpp b/indra/newview/llfolderviewitem.cpp
index 3aa16b4413..4eb84224bc 100644
--- a/indra/newview/llfolderviewitem.cpp
+++ b/indra/newview/llfolderviewitem.cpp
@@ -1293,7 +1293,7 @@ S32 LLFolderViewFolder::arrange( S32* width, S32* height, S32 filter_generation)
 	// animate current height towards target height
 	if (llabs(mCurHeight - mTargetHeight) > 1.f)
 	{
-		mCurHeight = lerp(mCurHeight, mTargetHeight, LLCriticalDamp::getInterpolant(mIsOpen ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT));
+		mCurHeight = lerp(mCurHeight, mTargetHeight, LLSmoothInterpolation::getInterpolant(mIsOpen ? FOLDER_OPEN_TIME_CONSTANT : FOLDER_CLOSE_TIME_CONSTANT));
 
 		requestArrange();
 
@@ -2538,11 +2538,11 @@ void LLFolderViewFolder::draw()
 	}
 	else if (mIsOpen)
 	{
-		mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLCriticalDamp::getInterpolant(0.04f));
+		mControlLabelRotation = lerp(mControlLabelRotation, -90.f, LLSmoothInterpolation::getInterpolant(0.04f));
 	}
 	else
 	{
-		mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLCriticalDamp::getInterpolant(0.025f));
+		mControlLabelRotation = lerp(mControlLabelRotation, 0.f, LLSmoothInterpolation::getInterpolant(0.025f));
 	}
 
 	bool possibly_has_children = false;
diff --git a/indra/newview/llfollowcam.cpp b/indra/newview/llfollowcam.cpp
index b670af1782..d6dc964802 100644
--- a/indra/newview/llfollowcam.cpp
+++ b/indra/newview/llfollowcam.cpp
@@ -328,11 +328,11 @@ void LLFollowCam::update()
 				F32 force = focusOffsetDistance - focusThresholdNormalizedByDistance;
 			*/
 
-			F32 focusLagLerp = LLCriticalDamp::getInterpolant( mFocusLag );
+			F32 focusLagLerp = LLSmoothInterpolation::getInterpolant( mFocusLag );
 			focus_pt_agent = lerp( focus_pt_agent, whereFocusWantsToBe, focusLagLerp );
 			mSimulatedFocusGlobal = gAgent.getPosGlobalFromAgent(focus_pt_agent);
 		}
-		mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f));
+		mRelativeFocus = lerp(mRelativeFocus, (focus_pt_agent - mSubjectPosition) * ~mSubjectRotation, LLSmoothInterpolation::getInterpolant(0.05f));
 	}// if focus is not locked ---------------------------------------------
 
 
@@ -415,7 +415,7 @@ void LLFollowCam::update()
 		//-------------------------------------------------------------------------------------------------
 		if ( distanceFromPositionToIdealPosition > mPositionThreshold )
 		{
-			F32 positionPullLerp = LLCriticalDamp::getInterpolant( mPositionLag );
+			F32 positionPullLerp = LLSmoothInterpolation::getInterpolant( mPositionLag );
 			simulated_pos_agent = lerp( simulated_pos_agent, whereCameraPositionWantsToBe, positionPullLerp );
 		}
 
@@ -435,7 +435,7 @@ void LLFollowCam::update()
 		updateBehindnessConstraint(gAgent.getPosAgentFromGlobal(mSimulatedFocusGlobal), simulated_pos_agent);
 		mSimulatedPositionGlobal = gAgent.getPosGlobalFromAgent(simulated_pos_agent);
 
-		mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLCriticalDamp::getInterpolant(0.05f));
+		mRelativePos = lerp(mRelativePos, (simulated_pos_agent - mSubjectPosition) * ~mSubjectRotation, LLSmoothInterpolation::getInterpolant(0.05f));
 	} // if position is not locked -----------------------------------------------------------
 
 
@@ -490,7 +490,7 @@ BOOL LLFollowCam::updateBehindnessConstraint(LLVector3 focus, LLVector3& cam_pos
 
 		if ( cameraOffsetAngle > mBehindnessMaxAngle )
 		{
-			F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLCriticalDamp::getInterpolant(mBehindnessLag);
+			F32 fraction = ((cameraOffsetAngle - mBehindnessMaxAngle) / cameraOffsetAngle) * LLSmoothInterpolation::getInterpolant(mBehindnessLag);
 			cam_position = focus + horizontalSubjectBack * (slerp(fraction, camera_offset_rotation, LLQuaternion::DEFAULT));
 			cam_position.mV[VZ] = cameraZ; // clamp z value back to what it was before we started messing with it
 			constraint_active = TRUE;
diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index c12916ec6b..3ac11f906b 100644
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -981,7 +981,7 @@ void LLHUDNameTag::updateAll()
 //		{
 //			continue;
 //		}
-		(*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLCriticalDamp::getInterpolant(POSITION_DAMPING_TC));
+		(*this_object_it)->mPositionOffset = lerp((*this_object_it)->mPositionOffset, (*this_object_it)->mTargetPositionOffset, LLSmoothInterpolation::getInterpolant(POSITION_DAMPING_TC));
 	}
 }
 
diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp
index 826e8d560a..0468560e96 100644
--- a/indra/newview/llmaniprotate.cpp
+++ b/indra/newview/llmaniprotate.cpp
@@ -240,7 +240,7 @@ void LLManipRotate::render()
 
 		if (mManipPart == LL_ROT_Z)
 		{
-			mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+			mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 			gGL.pushMatrix();
 			{
 				// selected part
@@ -251,7 +251,7 @@ void LLManipRotate::render()
 		}
 		else if (mManipPart == LL_ROT_Y)
 		{
-			mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+			mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 			gGL.pushMatrix();
 			{
 				gGL.rotatef( 90.f, 1.f, 0.f, 0.f );
@@ -262,7 +262,7 @@ void LLManipRotate::render()
 		}
 		else if (mManipPart == LL_ROT_X)
 		{
-			mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+			mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 			gGL.pushMatrix();
 			{
 				gGL.rotatef( 90.f, 0.f, 1.f, 0.f );
@@ -273,13 +273,13 @@ void LLManipRotate::render()
 		}
 		else if (mManipPart == LL_ROT_ROLL)
 		{
-			mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+			mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 		}
 		else if (mManipPart == LL_NO_PART)
 		{
 			if (mHighlightedPart == LL_NO_PART)
 			{
-				mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+				mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, 1.f), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 			}
 
 			LLGLEnable cull_face(GL_CULL_FACE);
@@ -294,7 +294,7 @@ void LLManipRotate::render()
 				{
 					if (mHighlightedPart == LL_ROT_Z)
 					{
-						mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+						mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, SELECTED_MANIPULATOR_SCALE, 1.f), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 						gGL.scalef(mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ], mManipulatorScales.mV[VZ]);
 						// hovering over part
 						gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 0.f, 1.f, 1.f ), LLColor4( 0.f, 0.f, 1.f, 0.5f ), CIRCLE_STEPS, i);
@@ -312,7 +312,7 @@ void LLManipRotate::render()
 					gGL.rotatef( 90.f, 1.f, 0.f, 0.f );
 					if (mHighlightedPart == LL_ROT_Y)
 					{
-						mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+						mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, SELECTED_MANIPULATOR_SCALE, 1.f, 1.f), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 						gGL.scalef(mManipulatorScales.mV[VY], mManipulatorScales.mV[VY], mManipulatorScales.mV[VY]);
 						// hovering over part
 						gl_ring( mRadiusMeters, width_meters, LLColor4( 0.f, 1.f, 0.f, 1.f ), LLColor4( 0.f, 1.f, 0.f, 0.5f ), CIRCLE_STEPS, i);
@@ -330,7 +330,7 @@ void LLManipRotate::render()
 					gGL.rotatef( 90.f, 0.f, 1.f, 0.f );
 					if (mHighlightedPart == LL_ROT_X)
 					{
-						mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+						mManipulatorScales = lerp(mManipulatorScales, LLVector4(SELECTED_MANIPULATOR_SCALE, 1.f, 1.f, 1.f), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 						gGL.scalef(mManipulatorScales.mV[VX], mManipulatorScales.mV[VX], mManipulatorScales.mV[VX]);
 	
 						// hovering over part
@@ -346,7 +346,7 @@ void LLManipRotate::render()
 
 				if (mHighlightedPart == LL_ROT_ROLL)
 				{
-					mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+					mManipulatorScales = lerp(mManipulatorScales, LLVector4(1.f, 1.f, 1.f, SELECTED_MANIPULATOR_SCALE), LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 				}
 				
 			}
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index 00a0bf8894..2d09fb6fe5 100644
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -535,11 +535,11 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
 	{
 		if (mHighlightedPart == MANIPULATOR_IDS[i])
 		{
-			mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+			mManipulatorScales[i] = lerp(mManipulatorScales[i], SELECTED_MANIPULATOR_SCALE, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 		}
 		else
 		{
-			mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
+			mManipulatorScales[i] = lerp(mManipulatorScales[i], 1.f, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE));
 		}
 	}
 
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 362308c176..cf5c646893 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -1921,18 +1921,18 @@ void LLManipTranslate::renderTranslationHandles()
 			{
 				if (index == mManipPart - LL_X_ARROW || index == mHighlightedPart - LL_X_ARROW)
 				{
-					mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
-					mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
+					mArrowScales.mV[index] = lerp(mArrowScales.mV[index], SELECTED_ARROW_SCALE, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
+					mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
 				}
 				else if (index == mManipPart - LL_YZ_PLANE || index == mHighlightedPart - LL_YZ_PLANE)
 				{
-					mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
-					mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
+					mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
+					mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], SELECTED_ARROW_SCALE, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
 				}
 				else
 				{
-					mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
-					mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLCriticalDamp::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
+					mArrowScales.mV[index] = lerp(mArrowScales.mV[index], 1.f, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
+					mPlaneScales.mV[index] = lerp(mPlaneScales.mV[index], 1.f, LLSmoothInterpolation::getInterpolant(MANIPULATOR_SCALE_HALF_LIFE ));
 				}
 			}
 
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index 1bda7640bd..0abfb59ffd 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -162,7 +162,7 @@ void LLNetMap::draw()
 	static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true);
 	if (auto_center)
 	{
-		mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(0.1f));
+		mCurPan = lerp(mCurPan, mTargetPan, LLSmoothInterpolation::getInterpolant(0.1f));
 	}
 
 	// Prepare a scissor region
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index ec36cf48c2..e227722b29 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -549,11 +549,11 @@ void LLFloaterTexturePicker::draw()
 
 	if (gFocusMgr.childHasMouseCapture(getDragHandle()))
 	{
-		mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
+		mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME));
 	}
 	else
 	{
-		mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
+		mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLSmoothInterpolation::getInterpolant(CONTEXT_FADE_TIME));
 	}
 
 	updateImageStats();
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 2aec25b7aa..0889c3ec6c 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -1041,7 +1041,7 @@ void render_hud_attachments()
 	// clamp target zoom level to reasonable values
 	gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f);
 	// smoothly interpolate current zoom level
-	gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLCriticalDamp::getInterpolant(0.03f));
+	gAgentCamera.mHUDCurZoom = lerp(gAgentCamera.mHUDCurZoom, gAgentCamera.mHUDTargetZoom, LLSmoothInterpolation::getInterpolant(0.03f));
 
 	if (LLPipeline::sShowHUDAttachments && !gDisconnected && setup_hud_matrices())
 	{
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 69586e3634..e72ea4b826 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -297,6 +297,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>);
 	LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>);
 	LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
+	LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
 	LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>);
 	LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>);
 	LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>);
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 921c681e2a..0e2c53ee5b 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -88,7 +88,8 @@ LLTrace::CountStatHandle<>	FPS("fpsstat"),
 							KILLED("killed", "Number of times killed"),
 							FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"),
 							TEX_BAKES("texbakes"),
-							TEX_REBAKES("texrebakes");
+							TEX_REBAKES("texrebakes"),
+							NUM_NEW_OBJECTS("numnewobjectsstat");
 LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT("kbitstat"),
 											LAYERS_KBIT("layerskbitstat"),
 											OBJECT_KBIT("objectkbitstat"),
@@ -133,7 +134,6 @@ LLTrace::MeasurementStatHandle<>	FPS_SAMPLE("fpssample"),
 									NUM_RAW_IMAGES("numrawimagesstat"),
 									NUM_OBJECTS("numobjectsstat"),
 									NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
-									NUM_NEW_OBJECTS("numnewobjectsstat"),
 									NUM_SIZE_CULLED("numsizeculledstat"),
 									NUM_VIS_CULLED("numvisculledstat"),
 									ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 069a726e5e..00e8c66b54 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -90,7 +90,8 @@ extern LLTrace::CountStatHandle<>						FPS,
 											KILLED,
 											FRAMETIME_DOUBLED,
 											TEX_BAKES,
-											TEX_REBAKES;
+											TEX_REBAKES,
+											NUM_NEW_OBJECTS;
 
 
 extern LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT,
@@ -137,7 +138,6 @@ extern LLTrace::MeasurementStatHandle<>		FPS_SAMPLE,
 											NUM_RAW_IMAGES,
 											NUM_OBJECTS,
 											NUM_ACTIVE_OBJECTS,
-											NUM_NEW_OBJECTS,
 											NUM_SIZE_CULLED,
 											NUM_VIS_CULLED,
 											ENABLE_VBO,
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 1d43f96fb7..5a07cdf7c9 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2917,7 +2917,7 @@ void LLVOAvatar::idleUpdateWindEffect()
 		LLVector3 velocity = getVelocity();
 		F32 speed = velocity.length();
 		//RN: velocity varies too much frame to frame for this to work
-		mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLCriticalDamp::getInterpolant(0.02f));
+		mRippleAccel.clearVec();//lerp(mRippleAccel, (velocity - mLastVel) * time_delta, LLSmoothInterpolation::getInterpolant(0.02f));
 		mLastVel = velocity;
 		LLVector4 wind;
 		wind.setVec(getRegion()->mWind.getVelocityNoisy(getPositionAgent(), 4.f) - velocity);
@@ -2940,11 +2940,11 @@ void LLVOAvatar::idleUpdateWindEffect()
 		F32 interp;
 		if (wind.mV[VW] > mWindVec.mV[VW])
 		{
-			interp = LLCriticalDamp::getInterpolant(0.2f);
+			interp = LLSmoothInterpolation::getInterpolant(0.2f);
 		}
 		else
 		{
-			interp = LLCriticalDamp::getInterpolant(0.4f);
+			interp = LLSmoothInterpolation::getInterpolant(0.4f);
 		}
 		mWindVec = lerp(mWindVec, wind, interp);
 	
@@ -3794,7 +3794,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 
 			// Set the root rotation, but do so incrementally so that it
 			// lags in time by some fixed amount.
-			//F32 u = LLCriticalDamp::getInterpolant(PELVIS_LAG);
+			//F32 u = LLSmoothInterpolation::getInterpolant(PELVIS_LAG);
 			F32 pelvis_lag_time = 0.f;
 			if (self_in_mouselook)
 			{
diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp
index ccc513b80d..f821cb1ec1 100644
--- a/indra/newview/llworldmapview.cpp
+++ b/indra/newview/llworldmapview.cpp
@@ -302,8 +302,8 @@ void LLWorldMapView::draw()
 	mVisibleRegions.clear();
 
 	// animate pan if necessary
-	sPanX = lerp(sPanX, sTargetPanX, LLCriticalDamp::getInterpolant(0.1f));
-	sPanY = lerp(sPanY, sTargetPanY, LLCriticalDamp::getInterpolant(0.1f));
+	sPanX = lerp(sPanX, sTargetPanX, LLSmoothInterpolation::getInterpolant(0.1f));
+	sPanY = lerp(sPanY, sTargetPanY, LLSmoothInterpolation::getInterpolant(0.1f));
 
 	const S32 width = getRect().getWidth();
 	const S32 height = getRect().getHeight();
diff --git a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
new file mode 100644
index 0000000000..fd3cb37f8f
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
@@ -0,0 +1,549 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+ legacy_header_height="18"
+ can_resize="true"
+ height="400"
+ layout="topleft"
+ name="Scene Load Statistics"
+ save_rect="true"
+ save_visibility="true"
+ title="SCENE LOAD STATISTICS"
+ width="260">
+    <scroll_container
+     follows="top|left|bottom|right"
+     height="380"
+     layout="topleft"
+     left="0"
+     name="statistics_scroll"
+     reserve_scroll_corner="true"
+     top="20"
+     width="260">
+      <container_view
+       follows="top|left|bottom|right"
+       height="378"
+       layout="topleft"
+       left="2"
+       name="statistics_view"
+       top="20"
+       width="245" >
+        <!--Basic Section-->
+		  <stat_view
+			 name="basic"
+			 label="Basic"
+			 show_label="true"
+			 setting="OpenDebugStatBasic">
+			<stat_bar
+			   name="bandwidth"
+			   label="Bandwidth"
+			   unit_label="kbps"
+         orientation="horizontal"
+			   stat="kbitstat"
+			   bar_max="5000"
+			   tick_spacing="500"
+			   label_spacing="1000"
+				 precision="0"
+			   show_bar="true"
+			   show_history="false">
+			</stat_bar>
+			<stat_bar
+			   name="packet_loss"
+			   label="Packet Loss"
+			   unit_label=" %"
+			   stat="packetslostpercentstat"
+			   bar_max="5"
+			   tick_spacing="0.5"
+			   label_spacing="1"
+			   precision="3"
+			   show_bar="false"
+			   show_mean="true">
+			</stat_bar>
+		  </stat_view>
+          <!--Advanced Section-->
+      <stat_view
+			 name="advanced"
+			 label="Advanced"
+			 show_label="true"
+			 setting="OpenDebugStatAdvanced">
+			<stat_view
+			   name="render"
+			   label="Render"
+			   show_label="true"
+			   setting="OpenDebugStatRender">
+			  <stat_bar
+				 name="objs"
+				 label="Total Objects"
+				 unit_label=""
+				 stat="numobjectsstat"
+				 bar_max="50000"
+				 tick_spacing="5000"
+				 label_spacing="10000"
+				 precision="0"
+				 show_bar="false">
+			  </stat_bar>
+			  <stat_bar
+				 name="newobjs"
+				 label="New Objects"
+				 unit_label="/sec"
+				 stat="numnewobjectsstat"
+				 bar_max="2000"
+				 tick_spacing="200"
+				 label_spacing="400"
+				 show_bar="false">
+			  </stat_bar>
+       <stat_bar
+				 name="object_cache_hits"
+				 label="Object Cache Hit Rate"
+				 stat="object_cache_hits"
+				 bar_max="100"
+         unit_label="%"
+				 tick_spacing="20"
+				 label_spacing="20"
+				 show_history="true"
+				 show_bar="false">
+        </stat_bar>
+			</stat_view>
+        <!--Texture Stats-->
+			<stat_view
+			   name="texture"
+			   label="Texture"
+			   show_label="true">
+			  <stat_bar
+				 name="texture_cache_hits"
+				 label="Cache Hit Rate"
+				 stat="texture_cache_hits"
+				 bar_max="100.f"
+         unit_label="%"
+				 tick_spacing="20"
+				 label_spacing="20"
+				 show_history="true"
+				 show_bar="false">
+        </stat_bar>
+        <stat_bar
+				 name="texture_cache_read_latency"
+				 label="Cache Read Latency"
+         unit_label="msec"
+				 stat="texture_cache_read_latency"
+				 bar_max="1000.f"
+				 tick_spacing="100"
+				 label_spacing="200"
+				 show_history="true"
+				 show_bar="false">
+        </stat_bar>
+        <stat_bar
+				 name="numimagesstat"
+				 label="Count"
+				 stat="numimagesstat" 
+				 bar_max="8000.f" 
+				 tick_spacing="2000.f"
+				 label_spacing="4000.f" 
+				 show_bar="false">
+			  </stat_bar>
+
+			  <stat_bar
+				 name="numrawimagesstat"
+				 label="Raw Count"
+				 stat="numrawimagesstat"
+				 bar_max="8000.f" 
+				 tick_spacing="2000.f"
+				 label_spacing="4000.f" 
+				 show_bar="false">
+			  </stat_bar>
+			</stat_view>
+        <!--Network Stats-->
+			<stat_view
+			   name="network"
+			   label="Network"
+			   show_label="true"
+			   setting="OpenDebugStatNet">
+			  <stat_bar
+				 name="packetsinstat"
+				 label="Packets In"
+				 stat="packetsinstat"
+				 unit_label="/sec" 
+				 bar_max="1024.f" 
+				 tick_spacing="128.f"
+				 label_spacing="256.f" 
+				 precision="1"
+				 show_bar="false">
+			  </stat_bar>
+
+			  <stat_bar
+				 name="packetsoutstat"
+				 label="Packets Out"
+				 stat="packetsoutstat"
+				 unit_label="/sec"  
+				 bar_max="1024.f" 
+				 tick_spacing="128.f"
+				 label_spacing="256.f" 
+				 precision="1"
+				 show_bar="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="objectkbitstat"
+				 label="Objects"
+				 stat="objectkbitstat"
+         unit_label="kbps"
+         bar_max="1024.f"
+         tick_spacing="128.f"
+         label_spacing="256.f"
+         precision="1"
+				 show_bar="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="texturekbitstat"
+				 label="Texture"
+				 stat="texturekbitstat"
+         unit_label="kbps"
+         bar_max="1024.f"
+         tick_spacing="128.f"
+         label_spacing="256.f"
+         precision="1"
+				 show_bar="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="assetkbitstat"
+				 label="Asset"
+				 stat="assetkbitstat"
+         unit_label="kbps"
+         bar_max="1024.f"
+         tick_spacing="128.f"
+         label_spacing="256.f"
+         precision="1"
+				 show_bar="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="layerskbitstat"
+				 label="Layers"
+				 stat="layerskbitstat"
+         unit_label="kbps"
+         bar_max="1024.f"
+         tick_spacing="128.f"
+         label_spacing="256.f"
+         precision="1"
+				 show_bar="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="actualinkbitstat"
+				 label="Actual In"
+				 stat="actualinkbitstat"
+         unit_label="kbps"
+         bar_max="1024.f"
+         tick_spacing="128.f"
+         label_spacing="256.f"
+         precision="1"
+				 show_bar="false"
+				 show_history="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="actualoutkbitstat"
+				 label="Actual Out"
+				 stat="actualoutkbitstat"
+         unit_label="kbps"
+         bar_max="1024.f"
+         tick_spacing="128.f"
+         label_spacing="256.f"
+         precision="1"
+				 show_bar="false"
+				 show_history="false">
+			  </stat_bar>
+
+			  <stat_bar
+				 name="vfspendingoperations"
+				 label="VFS Pending Operations"
+				 stat="vfspendingoperations"
+				 unit_label=" Ops."
+				 show_bar="false" >
+			  </stat_bar>
+			</stat_view>
+		  </stat_view>
+        <!--Sim Stats-->
+		  <stat_view
+			 name="sim"
+			 label="Simulator"
+			 show_label="true"
+			 setting="OpenDebugStatSim">
+	
+			<stat_bar
+			   name="simobjects"
+			   label="Objects"
+			   stat="simobjects"
+			   precision="0"
+			   bar_max="30000.f" 
+			   tick_spacing="5000.f"
+			   label_spacing="10000.f" 
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+
+			<stat_bar
+			   name="simactiveobjects"
+			   label="Active Objects"
+			   stat="simactiveobjects"
+			   precision="0"
+			   bar_max="5000.f" 
+			   tick_spacing="750.f"
+			   label_spacing="1250.f" 
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+
+			<stat_bar
+			   name="simactivescripts"
+			   label="Active Scripts"
+			   stat="simactivescripts"
+			   precision="0"
+			   bar_max="15000.f" 
+			   tick_spacing="1875.f"
+			   label_spacing="3750.f"  
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+        
+
+			<stat_bar
+			   name="siminpps"
+			   label="Packets In"
+			   stat="siminpps"
+			   unit_label="pps"
+			   precision="0"
+			   bar_max="2000.f" 
+			   tick_spacing="250.f"
+			   label_spacing="1000.f" 
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+
+			<stat_bar
+			   name="simoutpps"
+			   label="Packets Out"
+			   stat="simoutpps"
+			   unit_label="pps" 
+			   precision="0"
+			   bar_max="2000.f" 
+			   tick_spacing="250.f"
+			   label_spacing="1000.f" 
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+
+			<stat_bar
+			   name="simpendingdownloads"
+			   label="Pending Downloads"
+			   stat="simpendingdownloads"
+			   precision="0"
+			   bar_max="800.f" 
+			   tick_spacing="100.f"
+			   label_spacing="200.f" 
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+
+			<stat_bar
+			   name="simpendinguploads"
+			   label="Pending Uploads"
+			   stat="simpendinguploads"
+			   precision="0"
+			   bar_max="100.f" 
+			   tick_spacing="25.f"
+			   label_spacing="50.f" 
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+
+			<stat_bar
+			   name="simtotalunackedbytes"
+			   label="Total Unacked Bytes"
+			   stat="simtotalunackedbytes"
+			   unit_label="kb"
+			   precision="1"
+			   bar_max="100000.f" 
+			   tick_spacing="25000.f"
+			   label_spacing="50000.f" 
+			   show_bar="false"
+			   show_mean="false" >
+			</stat_bar>
+
+			<stat_view
+			   name="simperf"
+			   label="Time (ms)"
+			   show_label="true">
+			  <stat_bar
+				 name="simframemsec"
+				 label="Total Frame Time"
+				 stat="simframemsec"
+				 unit_label="ms"
+				 precision="3"
+				 bar_max="40.f" 
+				 tick_spacing="10.f"
+				 label_spacing="20.f" 
+				 show_bar="false"
+				 show_mean="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="simnetmsec"
+				 label="Net Time"
+				 stat="simnetmsec"
+				 unit_label="ms"
+				 precision="3"
+				 bar_max="40.f" 
+				 tick_spacing="10.f"
+				 label_spacing="20.f" 
+				 show_bar="false"
+				 show_mean="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="simsimphysicsmsec"
+				 label="Physics Time"
+				 stat="simsimphysicsmsec"
+				 unit_label="ms"
+				 precision="3"
+				 bar_max="40.f" 
+				 tick_spacing="10.f"
+				 label_spacing="20.f" 
+				 show_bar="false"
+				 show_mean="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="simsimothermsec"
+				 label="Simulation Time"
+				 stat="simsimothermsec"
+				 unit_label="ms"
+				 precision="3"
+				 bar_max="40.f" 
+				 tick_spacing="10.f"
+				 label_spacing="20.f" 
+				 show_bar="false"
+				 show_mean="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="simagentmsec"
+				 label="Agent Time"
+				 stat="simagentmsec"
+				 unit_label="ms"
+				 precision="3"
+				 bar_max="40.f" 
+				 tick_spacing="10.f"
+				 label_spacing="20.f" 
+				 show_bar="false"
+				 show_mean="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="simimagesmsec"
+				 label="Images Time"
+				 stat="simimagesmsec"
+				 unit_label="ms"
+				 precision="3"
+				 bar_max="40.f" 
+				 tick_spacing="10.f"
+				 label_spacing="20.f" 
+				 show_bar="false"
+				 show_mean="false" >
+			  </stat_bar>
+
+			  <stat_bar
+				 name="simscriptmsec"
+				 label="Script Time"
+				 stat="simscriptmsec"
+				 unit_label="ms"
+				 precision="3"
+				 bar_max="40.f" 
+				 tick_spacing="10.f"
+				 label_spacing="20.f" 
+				 show_bar="false"
+				 show_mean="false" >
+			  </stat_bar>
+
+        <stat_bar
+         name="simsparemsec"
+         label="Spare Time"
+         stat="simsparemsec"
+         unit_label="ms"
+         precision="3"
+         bar_max="40.f"
+         tick_spacing="10.f"
+         label_spacing="20.f"
+         show_bar="false"
+         show_mean="false" >
+        </stat_bar>
+        <!--2nd level time blocks under 'Details' second-->
+          <stat_view
+ 			     name="timedetails"
+			     label="Time Details (ms)"
+			     show_label="true">
+            <stat_bar
+             name="simsimphysicsstepmsec"
+             label="  Physics Step"
+             stat="simsimphysicsstepmsec"
+             unit_label="ms"
+             precision="3"
+             bar_max="40.f"
+             tick_spacing="10.f"
+             label_spacing="20.f"
+             show_bar="false"
+             show_mean="false" >
+            </stat_bar>
+            <stat_bar
+             name="simsimphysicsshapeupdatemsec"
+             label="  Update Phys Shapes"
+             stat="simsimphysicsshapeupdatemsec"
+             unit_label="ms"
+             precision="3"
+             bar_max="40.f"
+             tick_spacing="10.f"
+             label_spacing="20.f"
+             show_bar="false"
+             show_mean="false" >
+            </stat_bar>
+            <stat_bar
+             name="simsimphysicsothermsec"
+             label="  Physics Other"
+             stat="simsimphysicsothermsec"
+             unit_label="ms"
+             precision="3"
+             bar_max="40.f"
+             tick_spacing="10.f"
+             label_spacing="20.f"
+             show_bar="false"
+             show_mean="false" >
+            </stat_bar>
+            <stat_bar
+             name="simsleepmsec"
+             label="  Sleep Time"
+             stat="simsleepmsec"
+             unit_label="ms"
+             precision="3"
+             bar_max="40.f"
+             tick_spacing="10.f"
+             label_spacing="20.f"
+             show_bar="false"
+             show_mean="false" >
+            </stat_bar>
+            <stat_bar
+             name="simpumpiomsec"
+             label="  Pump IO"
+             stat="simpumpiomsec"
+             unit_label="ms"
+             precision="3"
+             bar_max="40.f"
+             tick_spacing="10.f"
+             label_spacing="20.f"
+             show_bar="false"
+             show_mean="false" >
+            </stat_bar>
+			</stat_view>
+			</stat_view>
+		  </stat_view>
+		</container_view>
+    </scroll_container>
+</floater>
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 93d9945800..a3f2fb0b9c 100644
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -70,7 +70,6 @@
 			   tick_spacing="0.5"
 			   label_spacing="1"
 			   precision="3"
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="true">
 			</stat_bar>
@@ -85,7 +84,6 @@
 			   label_spacing="1000"
 				 precision="0"
 			   show_bar="false"
-			   show_per_sec="false"
 			   show_mean="false">
 			</stat_bar>
 		  </stat_view>
@@ -137,7 +135,6 @@
 				 tick_spacing="5000"
 				 label_spacing="10000"
 				 precision="0"
-				 show_per_sec="false"
 				 show_bar="false">
 			  </stat_bar>
 			  <stat_bar
@@ -149,7 +146,6 @@
 				 bar_max="2000"
 				 tick_spacing="200"
 				 label_spacing="400"
-				 show_per_sec="true"
 				 show_bar="false">
 			  </stat_bar>
        <stat_bar
@@ -162,7 +158,6 @@
 				 tick_spacing="20"
 				 label_spacing="20"
 				 show_history="true"
-         show_per_sec="false"
 				 show_bar="false">
         </stat_bar>
 			</stat_view>
@@ -181,7 +176,6 @@
 				 tick_spacing="20"
 				 label_spacing="20"
 				 show_history="true"
-         show_per_sec="false"
 				 show_bar="false">
         </stat_bar>
         <stat_bar
@@ -194,7 +188,6 @@
 				 tick_spacing="100"
 				 label_spacing="200"
 				 show_history="true"
-         show_per_sec="false"
 				 show_bar="false">
         </stat_bar>
         <stat_bar
@@ -205,7 +198,6 @@
 				 bar_max="8000.f" 
 				 tick_spacing="2000.f"
 				 label_spacing="4000.f" 
-				 show_per_sec="false"
 				 show_bar="false">
 			  </stat_bar>
 
@@ -217,7 +209,6 @@
 				 bar_max="8000.f" 
 				 tick_spacing="2000.f"
 				 label_spacing="4000.f" 
-				 show_per_sec="false"
 				 show_bar="false">
 			  </stat_bar>
 
@@ -232,7 +223,6 @@
 				 tick_spacing="100.f"
 				 label_spacing="200.f" 
 				 precision="1"
-				 show_per_sec="false" 
          show_bar="false">
         </stat_bar>
 
@@ -247,7 +237,6 @@
 				 tick_spacing="100.f"
 				 label_spacing="200.f" 
 				 precision="3"
-				 show_per_sec="false" 
          show_bar="false">
         </stat_bar>
 
@@ -262,7 +251,6 @@
 				 tick_spacing="100.f"
 				 label_spacing="200.f" 
 				 precision="3"
-				 show_per_sec="false" 
          show_bar="false">
         </stat_bar>
 
@@ -277,7 +265,6 @@
 				 tick_spacing="100.f"
 				 label_spacing="200.f" 
 				 precision="3"
-				 show_per_sec="false" 
          show_bar="false">
         </stat_bar>
 			</stat_view>
@@ -398,7 +385,6 @@
 				 label="VFS Pending Operations"
 				 stat="vfspendingoperations"
 				 unit_label=" Ops."
-				 show_per_sec="false"
 				 show_bar="false" >
 			  </stat_bar>
 			</stat_view>
@@ -418,7 +404,6 @@
 			   bar_max="1.f" 
 			   tick_spacing="0.16666f"
 			   label_spacing="0.33333f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -432,7 +417,6 @@
 			   bar_max="45.f" 
 			   tick_spacing="7.5f"
 			   label_spacing="15.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -446,7 +430,6 @@
 			   bar_max="45.f" 
 			   tick_spacing="7.5.f"
 			   label_spacing="15.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -464,7 +447,6 @@
 				 bar_max="500.f" 
 				 tick_spacing="50.f"
 				 label_spacing="100.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -478,7 +460,6 @@
 				 bar_max="500.f" 
 				 tick_spacing="50.f"
 				 label_spacing="100.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -493,7 +474,6 @@
 				 bar_max="1024.f" 
 				 tick_spacing="128.f"
 				 label_spacing="256.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -508,7 +488,6 @@
 			   bar_max="100.f" 
 			   tick_spacing="25.f"
 			   label_spacing="50.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -522,7 +501,6 @@
 			   bar_max="80.f" 
 			   tick_spacing="10.f"
 			   label_spacing="40.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -536,7 +514,6 @@
 			   bar_max="40.f" 
 			   tick_spacing="5.f"
 			   label_spacing="10.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -550,7 +527,6 @@
 			   bar_max="30000.f" 
 			   tick_spacing="5000.f"
 			   label_spacing="10000.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -564,7 +540,6 @@
 			   bar_max="5000.f" 
 			   tick_spacing="750.f"
 			   label_spacing="1250.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -578,7 +553,6 @@
 			   bar_max="15000.f" 
 			   tick_spacing="1875.f"
 			   label_spacing="3750.f"  
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -592,7 +566,6 @@
             tick_spacing="10"
             label_spacing="20"
             precision="3"
-            show_per_sec="false"
             show_bar="false"
             show_mean="true">
         </stat_bar>
@@ -607,7 +580,6 @@
 			   bar_max="5000.f" 
 			   tick_spacing="750.f"
 			   label_spacing="1250.f"  
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -626,7 +598,6 @@
               bar_max="40.f"
               tick_spacing="10.f"
               label_spacing="20.f"
-              show_per_sec="false"
               show_bar="false"
               show_mean="false" >
           </stat_bar>
@@ -640,7 +611,6 @@
               bar_max="45"
               tick_spacing="4"
               label_spacing="8"
-              show_per_sec="false"
               show_bar="false">
           </stat_bar>
           <stat_bar
@@ -653,7 +623,6 @@
               tick_spacing="10"
               label_spacing="20"
               precision="1"
-              show_per_sec="false"
               show_bar="false"
               show_mean="true">
           </stat_bar>
@@ -669,7 +638,6 @@
 			   bar_max="2000.f" 
 			   tick_spacing="250.f"
 			   label_spacing="1000.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -684,7 +652,6 @@
 			   bar_max="2000.f" 
 			   tick_spacing="250.f"
 			   label_spacing="1000.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -698,7 +665,6 @@
 			   bar_max="800.f" 
 			   tick_spacing="100.f"
 			   label_spacing="200.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -712,7 +678,6 @@
 			   bar_max="100.f" 
 			   tick_spacing="25.f"
 			   label_spacing="50.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -727,7 +692,6 @@
 			   bar_max="100000.f" 
 			   tick_spacing="25000.f"
 			   label_spacing="50000.f" 
-			   show_per_sec="false"
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -746,7 +710,6 @@
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
 				 label_spacing="20.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -761,7 +724,6 @@
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
 				 label_spacing="20.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -776,7 +738,6 @@
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
 				 label_spacing="20.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -791,7 +752,6 @@
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
 				 label_spacing="20.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -806,7 +766,6 @@
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
 				 label_spacing="20.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -821,7 +780,6 @@
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
 				 label_spacing="20.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -836,7 +794,6 @@
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
 				 label_spacing="20.f" 
-				 show_per_sec="false"
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -851,7 +808,6 @@
          bar_max="40.f"
          tick_spacing="10.f"
          label_spacing="20.f"
-         show_per_sec="false"
          show_bar="false"
          show_mean="false" >
         </stat_bar>
@@ -870,7 +826,6 @@
              bar_max="40.f"
              tick_spacing="10.f"
              label_spacing="20.f"
-             show_per_sec="false"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -884,7 +839,6 @@
              bar_max="40.f"
              tick_spacing="10.f"
              label_spacing="20.f"
-             show_per_sec="false"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -898,7 +852,6 @@
              bar_max="40.f"
              tick_spacing="10.f"
              label_spacing="20.f"
-             show_per_sec="false"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -912,7 +865,6 @@
              bar_max="40.f"
              tick_spacing="10.f"
              label_spacing="20.f"
-             show_per_sec="false"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -926,7 +878,6 @@
              bar_max="40.f"
              tick_spacing="10.f"
              label_spacing="20.f"
-             show_per_sec="false"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 8fe955aed8..5b6a6f908a 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -1384,6 +1384,14 @@
                  function="Floater.Toggle"
                  parameter="stats" />
             </menu_item_check>
+            <menu_item_call
+             label="Scene Load Statistics"
+             name="Scene Load Statistics"
+             shortcut="control|shift|2">
+                <on_click
+                 function="Floater.Show"
+                 parameter="scene_load_stats" />
+            </menu_item_call>
       <menu_item_check
         label="Show Draw Weight for Avatars"
         name="Avatar Rendering Cost">
-- 
cgit v1.2.3


From df6dfc4d1d3f9efc0035b3596dfbd9ea251328b6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 18 Mar 2013 16:19:21 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 cleaned up xml file

---
 .../default/xui/en/floater_scene_load_stats.xml    | 979 +++++++++------------
 1 file changed, 435 insertions(+), 544 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
index fd3cb37f8f..9dbf59ef4d 100644
--- a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
@@ -1,549 +1,440 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<floater
- legacy_header_height="18"
- can_resize="true"
- height="400"
- layout="topleft"
- name="Scene Load Statistics"
- save_rect="true"
- save_visibility="true"
- title="SCENE LOAD STATISTICS"
- width="260">
-    <scroll_container
-     follows="top|left|bottom|right"
-     height="380"
-     layout="topleft"
-     left="0"
-     name="statistics_scroll"
-     reserve_scroll_corner="true"
-     top="20"
-     width="260">
-      <container_view
-       follows="top|left|bottom|right"
-       height="378"
-       layout="topleft"
-       left="2"
-       name="statistics_view"
-       top="20"
-       width="245" >
-        <!--Basic Section-->
-		  <stat_view
-			 name="basic"
-			 label="Basic"
-			 show_label="true"
-			 setting="OpenDebugStatBasic">
-			<stat_bar
-			   name="bandwidth"
-			   label="Bandwidth"
-			   unit_label="kbps"
-         orientation="horizontal"
-			   stat="kbitstat"
-			   bar_max="5000"
-			   tick_spacing="500"
-			   label_spacing="1000"
-				 precision="0"
-			   show_bar="true"
-			   show_history="false">
-			</stat_bar>
-			<stat_bar
-			   name="packet_loss"
-			   label="Packet Loss"
-			   unit_label=" %"
-			   stat="packetslostpercentstat"
-			   bar_max="5"
-			   tick_spacing="0.5"
-			   label_spacing="1"
-			   precision="3"
-			   show_bar="false"
-			   show_mean="true">
-			</stat_bar>
+<floater legacy_header_height="18"
+         can_resize="true"
+         height="400"
+         layout="topleft"
+         name="Scene Load Statistics"
+         save_rect="true"
+         save_visibility="true"
+         title="SCENE LOAD STATISTICS"
+         width="260">
+    <button top="20"
+            bottom="60"
+            left="10"
+            width="100"
+            label="Pause"
+            name="playpause"/>
+    <scroll_container follows="top|left|bottom|right"
+                      height="380"
+                      layout="topleft"
+                      left="0"
+                      name="statistics_scroll"
+                      reserve_scroll_corner="true"
+                      top="60"
+                      width="260">
+      <container_view follows="top|left|bottom|right"
+                      height="378"
+                      layout="topleft"
+                      left="2"
+                      name="statistics_view"
+                      top="20"
+                      width="245" >
+<!--Basic Section-->
+		  <stat_view name="basic"
+                 label="Basic"
+                 show_label="true"
+                 setting="OpenDebugStatBasic">
+			  <stat_bar name="bandwidth"
+                  label="Bandwidth"
+                  unit_label="kbps"
+                  orientation="horizontal"
+                  stat="kbitstat"
+                  bar_max="5000"
+                  tick_spacing="500"
+                  label_spacing="1000"
+                  precision="0"
+                  show_bar="true"
+                  show_history="false"/>
+			  <stat_bar name="packet_loss"
+                  label="Packet Loss"
+                  unit_label=" %"
+                  stat="packetslostpercentstat"
+                  bar_max="5"
+                  tick_spacing="0.5"
+                  label_spacing="1"
+                  precision="3"
+                  show_bar="false"
+                  show_mean="true"/>
 		  </stat_view>
-          <!--Advanced Section-->
-      <stat_view
-			 name="advanced"
-			 label="Advanced"
-			 show_label="true"
-			 setting="OpenDebugStatAdvanced">
-			<stat_view
-			   name="render"
-			   label="Render"
-			   show_label="true"
-			   setting="OpenDebugStatRender">
-			  <stat_bar
-				 name="objs"
-				 label="Total Objects"
-				 unit_label=""
-				 stat="numobjectsstat"
-				 bar_max="50000"
-				 tick_spacing="5000"
-				 label_spacing="10000"
-				 precision="0"
-				 show_bar="false">
-			  </stat_bar>
-			  <stat_bar
-				 name="newobjs"
-				 label="New Objects"
-				 unit_label="/sec"
-				 stat="numnewobjectsstat"
-				 bar_max="2000"
-				 tick_spacing="200"
-				 label_spacing="400"
-				 show_bar="false">
-			  </stat_bar>
-       <stat_bar
-				 name="object_cache_hits"
-				 label="Object Cache Hit Rate"
-				 stat="object_cache_hits"
-				 bar_max="100"
-         unit_label="%"
-				 tick_spacing="20"
-				 label_spacing="20"
-				 show_history="true"
-				 show_bar="false">
-        </stat_bar>
-			</stat_view>
-        <!--Texture Stats-->
-			<stat_view
-			   name="texture"
-			   label="Texture"
-			   show_label="true">
-			  <stat_bar
-				 name="texture_cache_hits"
-				 label="Cache Hit Rate"
-				 stat="texture_cache_hits"
-				 bar_max="100.f"
-         unit_label="%"
-				 tick_spacing="20"
-				 label_spacing="20"
-				 show_history="true"
-				 show_bar="false">
-        </stat_bar>
-        <stat_bar
-				 name="texture_cache_read_latency"
-				 label="Cache Read Latency"
-         unit_label="msec"
-				 stat="texture_cache_read_latency"
-				 bar_max="1000.f"
-				 tick_spacing="100"
-				 label_spacing="200"
-				 show_history="true"
-				 show_bar="false">
-        </stat_bar>
-        <stat_bar
-				 name="numimagesstat"
-				 label="Count"
-				 stat="numimagesstat" 
-				 bar_max="8000.f" 
-				 tick_spacing="2000.f"
-				 label_spacing="4000.f" 
-				 show_bar="false">
-			  </stat_bar>
-
-			  <stat_bar
-				 name="numrawimagesstat"
-				 label="Raw Count"
-				 stat="numrawimagesstat"
-				 bar_max="8000.f" 
-				 tick_spacing="2000.f"
-				 label_spacing="4000.f" 
-				 show_bar="false">
-			  </stat_bar>
-			</stat_view>
-        <!--Network Stats-->
-			<stat_view
-			   name="network"
-			   label="Network"
-			   show_label="true"
-			   setting="OpenDebugStatNet">
-			  <stat_bar
-				 name="packetsinstat"
-				 label="Packets In"
-				 stat="packetsinstat"
-				 unit_label="/sec" 
-				 bar_max="1024.f" 
-				 tick_spacing="128.f"
-				 label_spacing="256.f" 
-				 precision="1"
-				 show_bar="false">
-			  </stat_bar>
-
-			  <stat_bar
-				 name="packetsoutstat"
-				 label="Packets Out"
-				 stat="packetsoutstat"
-				 unit_label="/sec"  
-				 bar_max="1024.f" 
-				 tick_spacing="128.f"
-				 label_spacing="256.f" 
-				 precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="objectkbitstat"
-				 label="Objects"
-				 stat="objectkbitstat"
-         unit_label="kbps"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         label_spacing="256.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="texturekbitstat"
-				 label="Texture"
-				 stat="texturekbitstat"
-         unit_label="kbps"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         label_spacing="256.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="assetkbitstat"
-				 label="Asset"
-				 stat="assetkbitstat"
-         unit_label="kbps"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         label_spacing="256.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="layerskbitstat"
-				 label="Layers"
-				 stat="layerskbitstat"
-         unit_label="kbps"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         label_spacing="256.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="actualinkbitstat"
-				 label="Actual In"
-				 stat="actualinkbitstat"
-         unit_label="kbps"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         label_spacing="256.f"
-         precision="1"
-				 show_bar="false"
-				 show_history="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="actualoutkbitstat"
-				 label="Actual Out"
-				 stat="actualoutkbitstat"
-         unit_label="kbps"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         label_spacing="256.f"
-         precision="1"
-				 show_bar="false"
-				 show_history="false">
-			  </stat_bar>
-
-			  <stat_bar
-				 name="vfspendingoperations"
-				 label="VFS Pending Operations"
-				 stat="vfspendingoperations"
-				 unit_label=" Ops."
-				 show_bar="false" >
-			  </stat_bar>
-			</stat_view>
+<!--Advanced Section-->
+      <stat_view name="advanced"
+                 label="Advanced"
+                 show_label="true"
+                 setting="OpenDebugStatAdvanced">
+			  <stat_view name="render"
+                   label="Render"
+                   show_label="true"
+                   setting="OpenDebugStatRender">
+          <stat_bar name="objs"
+                    label="Total Objects"
+                    unit_label=""
+                    stat="numobjectsstat"
+                    bar_max="50000"
+                    tick_spacing="5000"
+                    label_spacing="10000"
+                    precision="0"
+                    show_bar="false"/>
+			    <stat_bar name="newobjs"
+                    label="New Objects"
+                    unit_label="/sec"
+                    stat="numnewobjectsstat"
+                    bar_max="2000"
+                    tick_spacing="200"
+                    label_spacing="400"
+                    show_bar="false"/>
+         <stat_bar name="object_cache_hits"
+                   label="Object Cache Hit Rate"
+                   stat="object_cache_hits"
+                   bar_max="100"
+                   unit_label="%"
+                   tick_spacing="20"
+                   label_spacing="20"
+                   show_history="true"
+                   show_bar="false"/>
+			  </stat_view>
+<!--Texture Stats-->
+			  <stat_view name="texture"
+                   label="Texture"
+                   show_label="true">
+			    <stat_bar name="texture_cache_hits"
+                    label="Cache Hit Rate"
+                    stat="texture_cache_hits"
+                    bar_max="100.f"
+                    unit_label="%"
+                    tick_spacing="20"
+                    label_spacing="20"
+                    show_history="true"
+                    show_bar="false"/>
+          <stat_bar name="texture_cache_read_latency"
+                    label="Cache Read Latency"
+                    unit_label="msec"
+                    stat="texture_cache_read_latency"
+                    bar_max="1000.f"
+                    tick_spacing="100"
+                    label_spacing="200"
+                    show_history="true"
+                    show_bar="false"/>
+          <stat_bar name="numimagesstat"
+                    label="Count"
+                    stat="numimagesstat" 
+                    bar_max="8000.f" 
+                    tick_spacing="2000.f"
+                    label_spacing="4000.f" 
+                    show_bar="false"/>
+			    <stat_bar name="numrawimagesstat"
+                    label="Raw Count"
+                    stat="numrawimagesstat"
+                    bar_max="8000.f" 
+                    tick_spacing="2000.f"
+                    label_spacing="4000.f" 
+                    show_bar="false"/>
+			  </stat_view>
+<!--Network Stats-->
+			  <stat_view name="network"
+                   label="Network"
+                   show_label="true"
+                   setting="OpenDebugStatNet">
+			    <stat_bar name="packetsinstat"
+                    label="Packets In"
+                    stat="packetsinstat"
+                    unit_label="/sec" 
+                    bar_max="1024.f" 
+                    tick_spacing="128.f"
+                    label_spacing="256.f" 
+                    precision="1"
+                    show_bar="false"/>
+			    <stat_bar name="packetsoutstat"
+                    label="Packets Out"
+                    stat="packetsoutstat"
+                    unit_label="/sec"  
+                    bar_max="1024.f" 
+                    tick_spacing="128.f"
+                    label_spacing="256.f" 
+                    precision="1"
+                    show_bar="false"/>
+			    <stat_bar name="objectkbitstat"
+                    label="Objects"
+                    stat="objectkbitstat"
+                    unit_label="kbps"
+                    bar_max="1024.f"
+                    tick_spacing="128.f"
+                    label_spacing="256.f"
+                    precision="1"
+                    show_bar="false"/>
+			    <stat_bar name="texturekbitstat"
+                    label="Texture"
+                    stat="texturekbitstat"
+                    unit_label="kbps"
+                    bar_max="1024.f"
+                    tick_spacing="128.f"
+                    label_spacing="256.f"
+                    precision="1"
+                    show_bar="false"/>
+			    <stat_bar name="assetkbitstat"
+                    label="Asset"
+                    stat="assetkbitstat"
+                    unit_label="kbps"
+                    bar_max="1024.f"
+                    tick_spacing="128.f"
+                    label_spacing="256.f"
+                    precision="1"
+                    show_bar="false"/>
+			    <stat_bar name="layerskbitstat"
+                    label="Layers"
+                    stat="layerskbitstat"
+                    unit_label="kbps"
+                    bar_max="1024.f"
+                    tick_spacing="128.f"
+                    label_spacing="256.f"
+                    precision="1"
+                    show_bar="false"/>
+			    <stat_bar name="actualinkbitstat"
+                    label="Actual In"
+                    stat="actualinkbitstat"
+                    unit_label="kbps"
+                    bar_max="1024.f"
+                    tick_spacing="128.f"
+                    label_spacing="256.f"
+                    precision="1"
+                    show_bar="false"
+                    show_history="false"/>
+			    <stat_bar name="actualoutkbitstat"
+                    label="Actual Out"
+                    stat="actualoutkbitstat"
+                    unit_label="kbps"
+                    bar_max="1024.f"
+                    tick_spacing="128.f"
+                    label_spacing="256.f"
+                    precision="1"
+                    show_bar="false"
+                    show_history="false"/>
+			    <stat_bar name="vfspendingoperations"
+                    label="VFS Pending Operations"
+                    stat="vfspendingoperations"
+                    unit_label=" Ops."
+                    show_bar="false"/>
+			  </stat_view>
 		  </stat_view>
-        <!--Sim Stats-->
-		  <stat_view
-			 name="sim"
-			 label="Simulator"
-			 show_label="true"
-			 setting="OpenDebugStatSim">
-	
-			<stat_bar
-			   name="simobjects"
-			   label="Objects"
-			   stat="simobjects"
-			   precision="0"
-			   bar_max="30000.f" 
-			   tick_spacing="5000.f"
-			   label_spacing="10000.f" 
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simactiveobjects"
-			   label="Active Objects"
-			   stat="simactiveobjects"
-			   precision="0"
-			   bar_max="5000.f" 
-			   tick_spacing="750.f"
-			   label_spacing="1250.f" 
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simactivescripts"
-			   label="Active Scripts"
-			   stat="simactivescripts"
-			   precision="0"
-			   bar_max="15000.f" 
-			   tick_spacing="1875.f"
-			   label_spacing="3750.f"  
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-        
-
-			<stat_bar
-			   name="siminpps"
-			   label="Packets In"
-			   stat="siminpps"
-			   unit_label="pps"
-			   precision="0"
-			   bar_max="2000.f" 
-			   tick_spacing="250.f"
-			   label_spacing="1000.f" 
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simoutpps"
-			   label="Packets Out"
-			   stat="simoutpps"
-			   unit_label="pps" 
-			   precision="0"
-			   bar_max="2000.f" 
-			   tick_spacing="250.f"
-			   label_spacing="1000.f" 
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simpendingdownloads"
-			   label="Pending Downloads"
-			   stat="simpendingdownloads"
-			   precision="0"
-			   bar_max="800.f" 
-			   tick_spacing="100.f"
-			   label_spacing="200.f" 
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simpendinguploads"
-			   label="Pending Uploads"
-			   stat="simpendinguploads"
-			   precision="0"
-			   bar_max="100.f" 
-			   tick_spacing="25.f"
-			   label_spacing="50.f" 
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simtotalunackedbytes"
-			   label="Total Unacked Bytes"
-			   stat="simtotalunackedbytes"
-			   unit_label="kb"
-			   precision="1"
-			   bar_max="100000.f" 
-			   tick_spacing="25000.f"
-			   label_spacing="50000.f" 
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_view
-			   name="simperf"
-			   label="Time (ms)"
-			   show_label="true">
-			  <stat_bar
-				 name="simframemsec"
-				 label="Total Frame Time"
-				 stat="simframemsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 label_spacing="20.f" 
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simnetmsec"
-				 label="Net Time"
-				 stat="simnetmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 label_spacing="20.f" 
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simsimphysicsmsec"
-				 label="Physics Time"
-				 stat="simsimphysicsmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 label_spacing="20.f" 
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simsimothermsec"
-				 label="Simulation Time"
-				 stat="simsimothermsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 label_spacing="20.f" 
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simagentmsec"
-				 label="Agent Time"
-				 stat="simagentmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 label_spacing="20.f" 
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simimagesmsec"
-				 label="Images Time"
-				 stat="simimagesmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 label_spacing="20.f" 
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simscriptmsec"
-				 label="Script Time"
-				 stat="simscriptmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 label_spacing="20.f" 
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-        <stat_bar
-         name="simsparemsec"
-         label="Spare Time"
-         stat="simsparemsec"
-         unit_label="ms"
-         precision="3"
-         bar_max="40.f"
-         tick_spacing="10.f"
-         label_spacing="20.f"
-         show_bar="false"
-         show_mean="false" >
-        </stat_bar>
-        <!--2nd level time blocks under 'Details' second-->
-          <stat_view
- 			     name="timedetails"
-			     label="Time Details (ms)"
-			     show_label="true">
-            <stat_bar
-             name="simsimphysicsstepmsec"
-             label="  Physics Step"
-             stat="simsimphysicsstepmsec"
-             unit_label="ms"
-             precision="3"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             label_spacing="20.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simsimphysicsshapeupdatemsec"
-             label="  Update Phys Shapes"
-             stat="simsimphysicsshapeupdatemsec"
-             unit_label="ms"
-             precision="3"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             label_spacing="20.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simsimphysicsothermsec"
-             label="  Physics Other"
-             stat="simsimphysicsothermsec"
-             unit_label="ms"
-             precision="3"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             label_spacing="20.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simsleepmsec"
-             label="  Sleep Time"
-             stat="simsleepmsec"
-             unit_label="ms"
-             precision="3"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             label_spacing="20.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simpumpiomsec"
-             label="  Pump IO"
-             stat="simpumpiomsec"
-             unit_label="ms"
-             precision="3"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             label_spacing="20.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-			</stat_view>
-			</stat_view>
+<!--Sim Stats-->
+		  <stat_view name="sim"
+                 label="Simulator"
+                 show_label="true"
+                 setting="OpenDebugStatSim">
+			  <stat_bar name="simobjects"
+                  label="Objects"
+                  stat="simobjects"
+                  precision="0"
+                  bar_max="30000.f" 
+                  tick_spacing="5000.f"
+                  label_spacing="10000.f" 
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_bar name="simactiveobjects"
+                  label="Active Objects"
+                  stat="simactiveobjects"
+                  precision="0"
+                  bar_max="5000.f" 
+                  tick_spacing="750.f"
+                  label_spacing="1250.f" 
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_bar name="simactivescripts"
+                  label="Active Scripts"
+                  stat="simactivescripts"
+                  precision="0"
+                  bar_max="15000.f" 
+                  tick_spacing="1875.f"
+                  label_spacing="3750.f"  
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_bar name="siminpps"
+                  label="Packets In"
+                  stat="siminpps"
+                  unit_label="pps"
+                  precision="0"
+                  bar_max="2000.f" 
+                  tick_spacing="250.f"
+                  label_spacing="1000.f" 
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_bar name="simoutpps"
+                  label="Packets Out"
+                  stat="simoutpps"
+                  unit_label="pps" 
+                  precision="0"
+                  bar_max="2000.f" 
+                  tick_spacing="250.f"
+                  label_spacing="1000.f" 
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_bar name="simpendingdownloads"
+                  label="Pending Downloads"
+                  stat="simpendingdownloads"
+                  precision="0"
+                  bar_max="800.f" 
+                  tick_spacing="100.f"
+                  label_spacing="200.f" 
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_bar name="simpendinguploads"
+                  label="Pending Uploads"
+                  stat="simpendinguploads"
+                  precision="0"
+                  bar_max="100.f" 
+                  tick_spacing="25.f"
+                  label_spacing="50.f" 
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_bar name="simtotalunackedbytes"
+                  label="Total Unacked Bytes"
+                  stat="simtotalunackedbytes"
+                  unit_label="kb"
+                  precision="1"
+                  bar_max="100000.f" 
+                  tick_spacing="25000.f"
+                  label_spacing="50000.f" 
+                  show_bar="false"
+                  show_mean="false"/>
+			  <stat_view name="simperf"
+                   label="Time (ms)"
+                   show_label="true">
+			    <stat_bar name="simframemsec"
+                    label="Total Frame Time"
+                    stat="simframemsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f" 
+                    tick_spacing="10.f"
+                    label_spacing="20.f" 
+                    show_bar="false"
+                    show_mean="false"/>
+			    <stat_bar name="simnetmsec"
+                    label="Net Time"
+                    stat="simnetmsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f" 
+                    tick_spacing="10.f"
+                    label_spacing="20.f" 
+                    show_bar="false"
+                    show_mean="false"/>
+			    <stat_bar name="simsimphysicsmsec"
+                    label="Physics Time"
+                    stat="simsimphysicsmsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f" 
+                    tick_spacing="10.f"
+                    label_spacing="20.f" 
+                    show_bar="false"
+                    show_mean="false"/>
+			    <stat_bar name="simsimothermsec"
+                    label="Simulation Time"
+                    stat="simsimothermsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f" 
+                    tick_spacing="10.f"
+                    label_spacing="20.f" 
+                    show_bar="false"
+                    show_mean="false"/>
+			    <stat_bar name="simagentmsec"
+                    label="Agent Time"
+                    stat="simagentmsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f" 
+                    tick_spacing="10.f"
+                    label_spacing="20.f" 
+                    show_bar="false"
+                    show_mean="false"/>
+			    <stat_bar name="simimagesmsec"
+                    label="Images Time"
+                    stat="simimagesmsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f" 
+                    tick_spacing="10.f"
+                    label_spacing="20.f" 
+                    show_bar="false"
+                    show_mean="false"/>
+			    <stat_bar name="simscriptmsec"
+                    label="Script Time"
+                    stat="simscriptmsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f" 
+                    tick_spacing="10.f"
+                    label_spacing="20.f" 
+                    show_bar="false"
+                    show_mean="false"/>
+          <stat_bar name="simsparemsec"
+                    label="Spare Time"
+                    stat="simsparemsec"
+                    unit_label="ms"
+                    precision="3"
+                    bar_max="40.f"
+                    tick_spacing="10.f"
+                    label_spacing="20.f"
+                    show_bar="false"
+                    show_mean="false"/>
+<!--2nd level time blocks under 'Details' second-->
+          <stat_view name="timedetails"
+                     label="Time Details (ms)"
+                     show_label="true">
+            <stat_bar name="simsimphysicsstepmsec"
+                      label="  Physics Step"
+                      stat="simsimphysicsstepmsec"
+                      unit_label="ms"
+                      precision="3"
+                      bar_max="40.f"
+                      tick_spacing="10.f"
+                      label_spacing="20.f"
+                      show_bar="false"
+                      show_mean="false"/>
+            <stat_bar name="simsimphysicsshapeupdatemsec"
+                      label="  Update Phys Shapes"
+                      stat="simsimphysicsshapeupdatemsec"
+                      unit_label="ms"
+                      precision="3"
+                      bar_max="40.f"
+                      tick_spacing="10.f"
+                      label_spacing="20.f"
+                      show_bar="false"
+                      show_mean="false"/>
+            <stat_bar name="simsimphysicsothermsec"
+                      label="  Physics Other"
+                      stat="simsimphysicsothermsec"
+                      unit_label="ms"
+                      precision="3"
+                      bar_max="40.f"
+                      tick_spacing="10.f"
+                      label_spacing="20.f"
+                      show_bar="false"
+                      show_mean="false"/>
+            <stat_bar name="simsleepmsec"
+                      label="  Sleep Time"
+                      stat="simsleepmsec"
+                      unit_label="ms"
+                      precision="3"
+                      bar_max="40.f"
+                      tick_spacing="10.f"
+                      label_spacing="20.f"
+                      show_bar="false"
+                      show_mean="false"/>
+            <stat_bar name="simpumpiomsec"
+                      label="  Pump IO"
+                      stat="simpumpiomsec"
+                      unit_label="ms"
+                      precision="3"
+                      bar_max="40.f"
+                      tick_spacing="10.f"
+                      label_spacing="20.f"
+                      show_bar="false"
+                      show_mean="false"/>
+          </stat_view>
+			  </stat_view>
 		  </stat_view>
-		</container_view>
-    </scroll_container>
+    </container_view>
+  </scroll_container>
 </floater>
-- 
cgit v1.2.3


From f59bd5f89ffd2dadbd3d7514cfa8e8cc97172201 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 18 Mar 2013 23:38:23 -0700
Subject: fix for change in LLTrace API

---
 indra/newview/llscenemonitor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 4eb44bcc00..9f657887f1 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -487,7 +487,7 @@ void LLSceneMonitor::fetchQueryResult()
 	if(mDiffResult > 0.01f)
 	{
 		mRecording->extend();
-		sFramePixelDiff.sample(mDiffResult);
+		sample(sFramePixelDiff, mDiffResult);
 	}
 	//llinfos << count << " : " << mDiffResult << llendl;
 }
-- 
cgit v1.2.3


From 041024e8e5d1f27ab77dc4fa2c1e38b8266e7b41 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 19 Mar 2013 11:00:13 -0700
Subject: build fix

---
 indra/newview/llscenemonitor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 9f657887f1..c69f276aa2 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -463,7 +463,7 @@ void LLSceneMonitor::calcDiffAggregate()
 	}	
 }
 
-static LLTrace::Measurement<> sFramePixelDiff("FramePixelDifference");
+static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference");
 void LLSceneMonitor::fetchQueryResult()
 {
 	if(!mHasNewQueryResult)
-- 
cgit v1.2.3


From 933691ad133b552be3fdd26b0d9d26a09c3a7aa5 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 20 Mar 2013 16:29:48 -0600
Subject: for SH-4004: interesting: need debug option to clear viewer cache
 while still logged in

---
 indra/newview/llappviewer.cpp                      |  8 ++++++++
 indra/newview/llappviewer.h                        |  1 +
 indra/newview/llviewermenu.cpp                     | 19 +++++++++++++++++++
 indra/newview/llvocache.cpp                        | 14 +++++++++-----
 indra/newview/llvocache.h                          |  2 +-
 indra/newview/skins/default/xui/en/menu_viewer.xml | 10 ++++++++++
 6 files changed, 48 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0cb7c7b030..dc07c8f13b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4006,6 +4006,14 @@ void LLAppViewer::purgeCache()
 	gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), "*.*");
 }
 
+//purge cache immediately, do not wait until the next login.
+void LLAppViewer::purgeCacheImmediate()
+{
+	LL_INFOS("AppCache") << "Purging Object Cache and Texture Cache immediately..." << LL_ENDL;
+	LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE);
+	LLVOCache::getInstance()->removeCache(LL_PATH_CACHE, true);
+}
+
 std::string LLAppViewer::getSecondLifeTitle() const
 {
 	return LLTrans::getString("APP_NAME");
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 58237d573d..06c06c4af2 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -170,6 +170,7 @@ public:
 	void addOnIdleCallback(const boost::function<void()>& cb); // add a callback to fire (once) when idle
 
 	void purgeCache(); // Clear the local cache. 
+	void purgeCacheImmediate(); //clear local cache immediately.
 	
 	// mute/unmute the system's master audio
 	virtual void setMasterSystemAudioMute(bool mute);
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 9a0cb432be..d66287f172 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -7572,6 +7572,23 @@ void handle_web_browser_test(const LLSD& param)
 	LLWeb::loadURLInternal(url);
 }
 
+bool callback_clear_cache_immediately(const LLSD& notification, const LLSD& response)
+{
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	if ( option == 0 ) // YES
+	{
+		//clear cache
+		LLAppViewer::instance()->purgeCacheImmediate();
+	}
+
+	return false;
+}
+
+void handle_cache_clear_immediately()
+{
+	LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache_immediately);
+}
+
 void handle_web_content_test(const LLSD& param)
 {
 	std::string url = param.asString();
@@ -8492,6 +8509,8 @@ void initialize_menus()
 	
 	//Develop (Texture Fetch Debug Console)
 	view_listener_t::addMenu(new LLDevelopTextureFetchDebugger(), "Develop.SetTexFetchDebugger");
+	//Develop (clear cache immediately)
+	commit.add("Develop.ClearCache", boost::bind(&handle_cache_clear_immediately) );
 
 	// Admin >Object
 	view_listener_t::addMenu(new LLAdminForceTakeCopy(), "Admin.ForceTakeCopy");
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 5f112675dc..a08e01784c 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -563,13 +563,19 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version)
 	}	
 }
 	
-void LLVOCache::removeCache(ELLPath location) 
+void LLVOCache::removeCache(ELLPath location, bool started) 
 {
+	if(started)
+	{
+		removeCache();
+		return;
+	}
+
 	if(mReadOnly)
 	{
 		llwarns << "Not removing cache at " << location << ": Cache is currently in read-only mode." << llendl;
 		return ;
-	}
+	}	
 
 	llinfos << "about to remove the object cache due to settings." << llendl ;
 
@@ -592,10 +598,8 @@ void LLVOCache::removeCache()
 		return ;
 	}
 
-	llinfos << "about to remove the object cache due to some error." << llendl ;
-
 	std::string mask = "*";
-	llinfos << "Removing cache at " << mObjectCacheDirName << llendl;
+	llinfos << "Removing object cache at " << mObjectCacheDirName << llendl;
 	gDirUtilp->deleteFilesInDir(mObjectCacheDirName, mask); 
 
 	clearCacheInMemory() ;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 64eb876919..c26bebb451 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -199,7 +199,7 @@ public:
 	~LLVOCache() ;
 
 	void initCache(ELLPath location, U32 size, U32 cache_version) ;
-	void removeCache(ELLPath location) ;
+	void removeCache(ELLPath location, bool started = false) ;
 
 	void readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) ;
 	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, BOOL full_region_cache_probe);
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 5b6a6f908a..7e5b5ed1e9 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2758,6 +2758,16 @@
                  function="ToggleControl"
                  parameter="RenderHoverGlowEnable" />
             </menu_item_check>
+          <menu_item_separator />
+          
+          <menu_item_call
+            enabled="true"
+            label="Clear Cache Immediately"
+            name="Cache Clear">
+            <menu_item_call.on_click
+             function="Develop.ClearCache" />
+          </menu_item_call>
+          
         </menu>
 
         <menu
-- 
cgit v1.2.3


From bbfb7b9ea1dc025d672968e39908b2327d14878a Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 20 Mar 2013 22:49:45 -0600
Subject: for SH-3918: Viewer should respond to cache probes in order received
 (don't sort response)

---
 indra/newview/llviewerregion.cpp | 4 ++++
 indra/newview/llviewerregion.h   | 4 ++++
 2 files changed, 8 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index bca2108964..b052c87064 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1898,7 +1898,11 @@ LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id)
 
 void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type)
 {
+#if 0
 	mCacheMissList.insert(CacheMissItem(id, miss_type));
+#else
+	mCacheMissList.push_back(CacheMissItem(id, miss_type));
+#endif
 }
 
 // Get data packer for this object, if we have cached data
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 15c2b36e38..22936fb103 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -470,6 +470,7 @@ private:
 		U32                            mID;     //local object id
 		LLViewerRegion::eCacheMissType mType;   //cache miss type
 	
+#if 0
 		struct Compare
 		{
 			bool operator()(const CacheMissItem& lhs, const CacheMissItem& rhs)
@@ -479,6 +480,9 @@ private:
 		};
 
 		typedef std::set<CacheMissItem, Compare> cache_miss_list_t;
+#else
+		typedef std::list<CacheMissItem> cache_miss_list_t;
+#endif
 	};
 	CacheMissItem::cache_miss_list_t        mCacheMissList;
 	
-- 
cgit v1.2.3


From 1f507c3cfca0c7722ebeaf71883fbaa83988e1a9 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 21 Mar 2013 00:37:20 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 copied over scene load frame differencing changes from viewer-interesting
 made periodicrecording flexible enough to allow for indefinite number of
 periods added scene loading stats floater fixed collapsing behavior of
 container views

---
 indra/newview/CMakeLists.txt                       |  10 +-
 indra/newview/llagent.cpp                          |   8 ++
 indra/newview/llagent.h                            |   2 +
 indra/newview/llfasttimerview.cpp                  |   8 +-
 indra/newview/llfloatersceneloadstats.cpp          |  37 +++++++
 indra/newview/llfloatersceneloadstats.h            |  39 ++++++++
 indra/newview/llscenemonitor.cpp                   | 108 ++++++++++++++++++++-
 indra/newview/llscenemonitor.h                     |  13 +++
 indra/newview/llviewerfloaterreg.cpp               |  35 +++----
 indra/newview/llworld.cpp                          |   2 +-
 .../default/xui/en/floater_scene_load_stats.xml    |  84 ++++++++++++----
 11 files changed, 299 insertions(+), 47 deletions(-)
 create mode 100644 indra/newview/llfloatersceneloadstats.cpp
 create mode 100644 indra/newview/llfloatersceneloadstats.h

(limited to 'indra/newview')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 16d82d5a0a..575400941f 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -239,6 +239,7 @@ set(viewer_SOURCE_FILES
     llfloaterregiondebugconsole.cpp
     llfloaterregioninfo.cpp
     llfloaterreporter.cpp
+    llfloatersceneloadstats.cpp
     llfloaterscriptdebug.cpp
     llfloaterscriptlimits.cpp
     llfloatersearch.cpp
@@ -462,7 +463,7 @@ set(viewer_SOURCE_FILES
     llremoteparcelrequest.cpp
     llsavedsettingsglue.cpp
     llsaveoutfitcombobtn.cpp
-	llscenemonitor.cpp
+    llscenemonitor.cpp
     llsceneview.cpp
     llscreenchannel.cpp
     llscriptfloater.cpp
@@ -587,7 +588,7 @@ set(viewer_SOURCE_FILES
     llviewernetwork.cpp
     llviewerobject.cpp
     llviewerobjectlist.cpp
-	llvieweroctree.cpp
+    llvieweroctree.cpp
     llviewerparcelmedia.cpp
     llviewerparcelmediaautoplay.cpp
     llviewerparcelmgr.cpp
@@ -816,6 +817,7 @@ set(viewer_HEADER_FILES
     llfloaterregiondebugconsole.h
     llfloaterregioninfo.h
     llfloaterreporter.h
+    llfloatersceneloadstats.h
     llfloaterscriptdebug.h
     llfloaterscriptlimits.h
     llfloatersearch.h
@@ -1030,7 +1032,7 @@ set(viewer_HEADER_FILES
     llrootview.h
     llsavedsettingsglue.h
     llsaveoutfitcombobtn.h
-	llscenemonitor.h
+    llscenemonitor.h
     llsceneview.h
     llscreenchannel.h
     llscriptfloater.h
@@ -1155,7 +1157,7 @@ set(viewer_HEADER_FILES
     llviewernetwork.h
     llviewerobject.h
     llviewerobjectlist.h
-	llvieweroctree.h
+    llvieweroctree.h
     llviewerparcelmedia.h
     llviewerparcelmediaautoplay.h
     llviewerparcelmgr.h
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 4fb298df13..4e60127ef3 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1046,6 +1046,14 @@ const LLVector3d &LLAgent::getPositionGlobal() const
 	return mPositionGlobal;
 }
 
+bool LLAgent::isPositionChanged() const
+{
+	LLVector3d diff;
+	diff = mPositionGlobal - mLastPositionGlobal;
+	
+	return diff.lengthSquared() > 1.0;
+}
+
 //-----------------------------------------------------------------------------
 // getPositionAgent()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 99904e118c..a1e899b45d 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -250,6 +250,8 @@ public:
 	
 	const LLVector3d &getLastPositionGlobal() const { return mLastPositionGlobal; }
 	void			setLastPositionGlobal(const LLVector3d &pos) { mLastPositionGlobal = pos; }
+
+	bool            isPositionChanged() const;
 private:
 	std::set<U64>	mRegionsVisited;		// Stat - what distinct regions has the avatar been to?
 	F64				mDistanceTraveled;		// Stat - how far has the avatar moved?
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index f55535b6e3..6caa89a611 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -263,7 +263,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
 		mScrollIndex = llround( lerp * (F32)(mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY));
-		mScrollIndex = llclamp(	mScrollIndex, 0, mRecording->getNumPeriods());
+		mScrollIndex = llclamp(	mScrollIndex, 0, (S32)mRecording->getNumPeriods());
 		return TRUE;
 	}
 	mHoverTimer = NULL;
@@ -272,7 +272,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if(mPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1,
-								mRecording->getNumPeriods() - 1,
+								(S32)mRecording->getNumPeriods() - 1,
 								MAX_VISIBLE_HISTORY);
 		if (mHoverBarIndex == 0)
 		{
@@ -381,7 +381,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	setPauseState(true);
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin(mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY));
+							llmin((S32)mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
@@ -1425,7 +1425,7 @@ void LLFastTimerView::drawBars()
 	// Special: -1 = show running average
 	LLPointer<LLUIImage> bar_image = LLUI::getUIImage("Rounded_Square");
 	gGL.getTexUnit(0)->bind(bar_image->getImage());
-	const S32 histmax = llmin(mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1;
+	const S32 histmax = llmin((S32)mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1;
 
 	for (S32 bar_index = 0; bar_index < histmax && y > LINE_GRAPH_HEIGHT; bar_index++)
 	{
diff --git a/indra/newview/llfloatersceneloadstats.cpp b/indra/newview/llfloatersceneloadstats.cpp
new file mode 100644
index 0000000000..95e8fbf4dd
--- /dev/null
+++ b/indra/newview/llfloatersceneloadstats.cpp
@@ -0,0 +1,37 @@
+/** 
+ * @file llfloatersceneloadstats.cpp
+ * @author Richard Nelson
+ * @brief debug floater for measuring various scene load statistics
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2013, 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 "llviewerprecompiledheaders.h"
+
+#include "llfloatersceneloadstats.h"
+
+
+LLFloaterSceneLoadStats::LLFloaterSceneLoadStats( const LLSD& key ) 
+:	LLFloater(key)
+{
+
+}
diff --git a/indra/newview/llfloatersceneloadstats.h b/indra/newview/llfloatersceneloadstats.h
new file mode 100644
index 0000000000..095541f2f6
--- /dev/null
+++ b/indra/newview/llfloatersceneloadstats.h
@@ -0,0 +1,39 @@
+/** 
+ * @file llfloatersceneloadstats.h
+ * @brief debug floater for measuring various scene load statistics
+ *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2013, 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$
+ */
+
+#ifndef LL_FLOATERSCENELOADSTATS_H
+#define LL_FLOATERSCENELOADSTATS_H
+
+#include "llfloater.h"
+
+class LLFloaterSceneLoadStats : public LLFloater
+{
+	friend class LLFloaterReg;
+private:
+	LLFloaterSceneLoadStats(const LLSD& key);
+};
+
+#endif // LL_FLOATERSCENELOADSTATS_H
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 189697dcf0..c69f276aa2 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -37,6 +37,8 @@
 #include "llwindow.h"
 #include "llpointer.h"
 #include "llspatialpartition.h"
+#include "llagent.h"
+#include "pipeline.h"
 
 LLSceneMonitorView* gSceneMonitorView = NULL;
 
@@ -67,7 +69,10 @@ LLSceneMonitor::LLSceneMonitor() :
 	mDiffPixelRatio(0.5f)
 {
 	mFrames[0] = NULL;
-	mFrames[1] = NULL;	
+	mFrames[1] = NULL;
+
+	mRecording = new LLTrace::ExtendableRecording();
+	mRecording->start();
 }
 
 LLSceneMonitor::~LLSceneMonitor()
@@ -78,6 +83,10 @@ LLSceneMonitor::~LLSceneMonitor()
 void LLSceneMonitor::destroyClass()
 {
 	reset();
+
+	delete mRecording;
+	mRecording = NULL;
+	mDitheringTexture = NULL;
 }
 
 void LLSceneMonitor::reset()
@@ -100,6 +109,67 @@ void LLSceneMonitor::reset()
 	}
 }
 
+void LLSceneMonitor::generateDitheringTexture(S32 width, S32 height)
+{
+#if 1
+	//4 * 4 matrix
+	mDitherMatrixWidth = 4;	
+	S32 dither_matrix[4][4] = 
+	{
+		{1, 9, 3, 11}, 
+		{13, 5, 15, 7}, 
+		{4, 12, 2, 10}, 
+		{16, 8, 14, 6}
+	};
+	
+	mDitherScale = 255.f / 17;
+#else
+	//8 * 8 matrix
+	mDitherMatrixWidth = 16;	
+	S32 dither_matrix[16][16] = 
+	{
+		{1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, 
+		{33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, 
+		{9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, 
+		{41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24},
+		{3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62},
+		{35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30},
+		{11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54},
+		{43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22},
+		{1, 49, 13, 61, 4, 52, 16, 64, 1, 49, 13, 61, 4, 52, 16, 64}, 
+		{33, 17, 45, 29, 36, 20, 48, 32, 33, 17, 45, 29, 36, 20, 48, 32}, 
+		{9, 57, 5, 53, 12, 60, 8, 56, 9, 57, 5, 53, 12, 60, 8, 56}, 
+		{41, 25, 37, 21, 44, 28, 40, 24, 41, 25, 37, 21, 44, 28, 40, 24},
+		{3, 51, 15, 63, 2, 50, 14, 62, 3, 51, 15, 63, 2, 50, 14, 62},
+		{35, 19, 47, 31, 34, 18, 46, 30, 35, 19, 47, 31, 34, 18, 46, 30},
+		{11, 59, 7, 55, 10, 58, 6, 54, 11, 59, 7, 55, 10, 58, 6, 54},
+		{43, 27, 39, 23, 42, 26, 38, 22, 43, 27, 39, 23, 42, 26, 38, 22}
+	};
+
+	mDitherScale = 255.f / 65;
+#endif
+
+	LLPointer<LLImageRaw> image_raw = new LLImageRaw(mDitherMatrixWidth, mDitherMatrixWidth, 3);
+	U8* data = image_raw->getData();
+	for (S32 i = 0; i < mDitherMatrixWidth; i++)
+	{
+		for (S32 j = 0; j < mDitherMatrixWidth; j++)
+		{
+			U8 val = dither_matrix[i][j];
+			*data++ = val;
+			*data++ = val;
+			*data++ = val;
+		}
+	}
+
+	mDitheringTexture = LLViewerTextureManager::getLocalTexture(image_raw.get(), FALSE) ;
+	mDitheringTexture->setAddressMode(LLTexUnit::TAM_WRAP);
+	mDitheringTexture->setFilteringOption(LLTexUnit::TFO_POINT);
+	
+	mDitherScaleS = (F32)width / mDitherMatrixWidth;
+	mDitherScaleT = (F32)height / mDitherMatrixWidth;
+}
+
 void LLSceneMonitor::setDebugViewerVisible(BOOL visible) 
 {
 	mDebugViewerVisible = visible;
@@ -137,6 +207,11 @@ bool LLSceneMonitor::preCapture()
 		return false;
 	}
 
+	if(gAgent.isPositionChanged())
+	{
+		mRecording->reset();
+	}
+
 	if(timer.getElapsedTimeF32() < mSamplingTime)
 	{
 		return false;
@@ -197,6 +272,9 @@ void LLSceneMonitor::freezeScene()
 
 	// freeze everything else
 	gSavedSettings.setBOOL("FreezeTime", TRUE);
+
+	gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, 
+		LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES);
 }
 
 void LLSceneMonitor::unfreezeScene()
@@ -206,6 +284,9 @@ void LLSceneMonitor::unfreezeScene()
 
 	// thaw everything else
 	gSavedSettings.setBOOL("FreezeTime", FALSE);
+
+	gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, 
+		LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES);
 }
 
 void LLSceneMonitor::capture()
@@ -268,10 +349,13 @@ void LLSceneMonitor::compare()
 	{
 		mDiff = new LLRenderTarget();
 		mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true);
+
+		generateDitheringTexture(width, height);
 	}
 	else if(mDiff->getWidth() != width || mDiff->getHeight() != height)
 	{
 		mDiff->resize(width, height, GL_RGBA);
+		generateDitheringTexture(width, height);
 	}
 
 	mDiff->bindTarget();
@@ -279,6 +363,10 @@ void LLSceneMonitor::compare()
 	
 	gTwoTextureCompareProgram.bind();
 	
+	gTwoTextureCompareProgram.uniform1f("dither_scale", mDitherScale);
+	gTwoTextureCompareProgram.uniform1f("dither_scale_s", mDitherScaleS);
+	gTwoTextureCompareProgram.uniform1f("dither_scale_t", mDitherScaleT);
+
 	gGL.getTexUnit(0)->activate();
 	gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(0)->bind(mFrames[0]);
@@ -289,6 +377,11 @@ void LLSceneMonitor::compare()
 	gGL.getTexUnit(1)->bind(mFrames[1]);
 	gGL.getTexUnit(1)->activate();	
 	
+	gGL.getTexUnit(2)->activate();
+	gGL.getTexUnit(2)->enable(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(2)->bind(mDitheringTexture);
+	gGL.getTexUnit(2)->activate();	
+
 	gl_rect_2d_simple_tex(width, height);
 	
 	mDiff->flush();	
@@ -299,6 +392,8 @@ void LLSceneMonitor::compare()
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gGL.getTexUnit(1)->disable();
 	gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(2)->disable();
+	gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE);
 
 	mHasNewDiff = TRUE;
 	
@@ -368,6 +463,7 @@ void LLSceneMonitor::calcDiffAggregate()
 	}	
 }
 
+static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference");
 void LLSceneMonitor::fetchQueryResult()
 {
 	if(!mHasNewQueryResult)
@@ -388,6 +484,11 @@ void LLSceneMonitor::fetchQueryResult()
 	
 	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
+	if(mDiffResult > 0.01f)
+	{
+		mRecording->extend();
+		sample(sFramePixelDiff, mDiffResult);
+	}
 	//llinfos << count << " : " << mDiffResult << llendl;
 }
 //-------------------------------------------------------------------------------------------------------------
@@ -454,6 +555,11 @@ void LLSceneMonitorView::draw()
 
 	num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime());
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
+	lines++;
+
+	num_str = llformat("Scene Loading time: %.3f seconds", (F32)LLSceneMonitor::getInstance()->getRecording()->getAcceptedRecording().getDuration().value());
+	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
+	lines++;
 
 	LLView::draw();
 }
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 02e3d57d46..709650e206 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -31,9 +31,11 @@
 #include "llmath.h"
 #include "llfloater.h"
 #include "llcharacter.h"
+#include "lltracerecording.h"
 
 class LLCharacter;
 class LLRenderTarget;
+class LLViewerTexture;
 
 class LLSceneMonitor :  public LLSingleton<LLSceneMonitor>
 {
@@ -61,11 +63,14 @@ public:
 	bool isEnabled()const {return mEnabled;}
 	bool needsUpdate() const;
 	
+	LLTrace::ExtendableRecording* getRecording() const {return mRecording;}
+
 private:
 	void freezeScene();
 	void unfreezeScene();
 	void reset();
 	bool preCapture();
+	void generateDitheringTexture(S32 width, S32 height);
 
 private:
 	BOOL mEnabled;
@@ -85,7 +90,15 @@ private:
 	F32     mSamplingTime; //time interval to capture frames, in seconds
 	F32     mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension
 
+	LLPointer<LLViewerTexture> mDitheringTexture;
+	S32                        mDitherMatrixWidth;
+	F32                        mDitherScale;
+	F32                        mDitherScaleS;
+	F32                        mDitherScaleT;
+
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
+
+	LLTrace::ExtendableRecording* mRecording;
 };
 
 class LLSceneMonitorView : public LLFloater
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index e72ea4b826..792c55441d 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -28,63 +28,62 @@
 #include "llviewerprecompiledheaders.h"
 
 #include "llfloaterreg.h"
-
 #include "llviewerfloaterreg.h"
-#include "llfloaterautoreplacesettings.h"
-#include "llcompilequeue.h"
+
 #include "llcallfloater.h"
+#include "llcommandhandler.h"
+#include "llcompilequeue.h"
 #include "llfasttimerview.h"
 #include "llfloaterabout.h"
 #include "llfloaterauction.h"
+#include "llfloaterautoreplacesettings.h"
 #include "llfloateravatar.h"
 #include "llfloateravatarpicker.h"
 #include "llfloateravatartextures.h"
 #include "llfloaterbeacons.h"
 #include "llfloaterbuildoptions.h"
+#include "llfloaterbulkpermission.h"
+#include "llfloaterbump.h"
 #include "llfloaterbuy.h"
 #include "llfloaterbuycontents.h"
 #include "llfloaterbuycurrency.h"
 #include "llfloaterbuycurrencyhtml.h"
 #include "llfloaterbuyland.h"
-#include "llfloaterbulkpermission.h"
-#include "llfloaterbump.h"
 #include "llfloaterbvhpreview.h"
 #include "llfloatercamera.h"
 #include "llfloaterdeleteenvpreset.h"
+#include "llfloaterdestinations.h"
 #include "llfloaterdisplayname.h"
 #include "llfloatereditdaycycle.h"
 #include "llfloatereditsky.h"
 #include "llfloatereditwater.h"
 #include "llfloaterenvironmentsettings.h"
 #include "llfloaterevent.h"
-#include "llfloaterdestinations.h"
 #include "llfloaterfonttest.h"
 #include "llfloatergesture.h"
 #include "llfloatergodtools.h"
 #include "llfloatergroups.h"
 #include "llfloaterhardwaresettings.h"
 #include "llfloaterhelpbrowser.h"
-#include "llfloaterwebcontent.h"
-#include "llfloaterwebprofile.h"
-#include "llfloatermediasettings.h"
 #include "llfloaterhud.h"
 #include "llfloaterimagepreview.h"
-#include "llimfloater.h"
 #include "llfloaterinspect.h"
 #include "llfloaterinventory.h"
 #include "llfloaterjoystick.h"
 #include "llfloaterland.h"
 #include "llfloaterlandholdings.h"
 #include "llfloatermap.h"
+#include "llfloatermediasettings.h"
 #include "llfloatermemleak.h"
+#include "llfloatermodelpreview.h"
 #include "llfloaternamedesc.h"
 #include "llfloaternotificationsconsole.h"
 #include "llfloaterobjectweights.h"
 #include "llfloateropenobject.h"
 #include "llfloateroutbox.h"
 #include "llfloaterpathfindingcharacters.h"
-#include "llfloaterpathfindinglinksets.h"
 #include "llfloaterpathfindingconsole.h"
+#include "llfloaterpathfindinglinksets.h"
 #include "llfloaterpay.h"
 #include "llfloaterperms.h"
 #include "llfloaterpostprocess.h"
@@ -93,6 +92,7 @@
 #include "llfloaterregiondebugconsole.h"
 #include "llfloaterregioninfo.h"
 #include "llfloaterreporter.h"
+#include "llfloatersceneloadstats.h"
 #include "llfloaterscriptdebug.h"
 #include "llfloaterscriptlimits.h"
 #include "llfloatersearch.h"
@@ -107,15 +107,18 @@
 #include "llfloatertestlistview.h"
 #include "llfloatertexturefetchdebugger.h"
 #include "llfloatertools.h"
-#include "llfloatertos.h"
 #include "llfloatertopobjects.h"
+#include "llfloatertos.h"
 #include "llfloatertoybox.h"
 #include "llfloatertranslationsettings.h"
 #include "llfloateruipreview.h"
 #include "llfloatervoiceeffect.h"
+#include "llfloaterwebcontent.h"
+#include "llfloaterwebprofile.h"
 #include "llfloaterwhitelistentry.h"
 #include "llfloaterwindowsize.h"
 #include "llfloaterworldmap.h"
+#include "llimfloater.h"
 #include "llimfloatercontainer.h"
 #include "llinspectavatar.h"
 #include "llinspectgroup.h"
@@ -124,6 +127,7 @@
 #include "llinspecttoast.h"
 #include "llmoveview.h"
 #include "llnearbychat.h"
+#include "llnearbychatbar.h"
 #include "llpanelblockedlist.h"
 #include "llpanelclassified.h"
 #include "llpreviewanim.h"
@@ -132,11 +136,8 @@
 #include "llpreviewscript.h"
 #include "llpreviewsound.h"
 #include "llpreviewtexture.h"
-#include "llsyswellwindow.h"
 #include "llscriptfloater.h"
-#include "llfloatermodelpreview.h"
-#include "llcommandhandler.h"
-#include "llnearbychatbar.h"
+#include "llsyswellwindow.h"
 
 // *NOTE: Please add files in alphabetical order to keep merges easy.
 
@@ -297,8 +298,8 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>);
 	LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>);
 	LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
-	LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
 	LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>);
+	LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSceneLoadStats>);
 	LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>);
 	LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>);
 	LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSearch>);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index e088f94d64..aba9df24c9 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1172,7 +1172,7 @@ void send_agent_resume()
 	}
 
 	// Resume data collection to ignore invalid rates
-	LLViewerStats::instance().getRecording().resume();//getInstance()->mFPSStat.reset();
+	LLViewerStats::instance().getRecording().resume();
 
 	LLAppViewer::instance()->resumeMainloopTimeout();
 }
diff --git a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
index 9dbf59ef4d..f4021d210a 100644
--- a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
@@ -15,7 +15,7 @@
             label="Pause"
             name="playpause"/>
     <scroll_container follows="top|left|bottom|right"
-                      height="380"
+                      bottom="400"
                       layout="topleft"
                       left="0"
                       name="statistics_scroll"
@@ -34,19 +34,28 @@
                  label="Basic"
                  show_label="true"
                  setting="OpenDebugStatBasic">
-			  <stat_bar name="bandwidth"
+        <stat_bar name="frame difference"
+                  label="Frame Pixel Difference"
+                  orientation="horizontal"
+                  unit_label="%"
+                  stat="FramePixelDifference"
+                  bar_max="100"
+                  tick_spacing="10"
+                  label_spacing="20"
+                  unit_scale="100"
+                  precision="0"/>
+        <stat_bar name="bandwidth"
                   label="Bandwidth"
-                  unit_label="kbps"
                   orientation="horizontal"
+                  unit_label="kbps"
                   stat="kbitstat"
                   bar_max="5000"
                   tick_spacing="500"
                   label_spacing="1000"
-                  precision="0"
-                  show_bar="true"
-                  show_history="false"/>
+                  precision="0"/>
 			  <stat_bar name="packet_loss"
                   label="Packet Loss"
+                  orientation="horizontal"
                   unit_label=" %"
                   stat="packetslostpercentstat"
                   bar_max="5"
@@ -67,6 +76,7 @@
                    setting="OpenDebugStatRender">
           <stat_bar name="objs"
                     label="Total Objects"
+                    orientation="horizontal"
                     unit_label=""
                     stat="numobjectsstat"
                     bar_max="50000"
@@ -74,23 +84,25 @@
                     label_spacing="10000"
                     precision="0"
                     show_bar="false"/>
-			    <stat_bar name="newobjs"
+          <stat_bar name="newobjs"
                     label="New Objects"
+                    orientation="horizontal"
                     unit_label="/sec"
                     stat="numnewobjectsstat"
                     bar_max="2000"
                     tick_spacing="200"
                     label_spacing="400"
                     show_bar="false"/>
-         <stat_bar name="object_cache_hits"
-                   label="Object Cache Hit Rate"
-                   stat="object_cache_hits"
-                   bar_max="100"
-                   unit_label="%"
-                   tick_spacing="20"
-                   label_spacing="20"
-                   show_history="true"
-                   show_bar="false"/>
+          <stat_bar name="object_cache_hits"
+                    label="Object Cache Hit Rate"
+                    orientation="horizontal"
+                    stat="object_cache_hits"
+                    bar_max="100"
+                    unit_label="%"
+                    tick_spacing="20"
+                    label_spacing="20"
+                    show_history="true"
+                    show_bar="false"/>
 			  </stat_view>
 <!--Texture Stats-->
 			  <stat_view name="texture"
@@ -98,6 +110,7 @@
                    show_label="true">
 			    <stat_bar name="texture_cache_hits"
                     label="Cache Hit Rate"
+                    orientation="horizontal"
                     stat="texture_cache_hits"
                     bar_max="100.f"
                     unit_label="%"
@@ -107,6 +120,7 @@
                     show_bar="false"/>
           <stat_bar name="texture_cache_read_latency"
                     label="Cache Read Latency"
+                    orientation="horizontal"
                     unit_label="msec"
                     stat="texture_cache_read_latency"
                     bar_max="1000.f"
@@ -116,6 +130,7 @@
                     show_bar="false"/>
           <stat_bar name="numimagesstat"
                     label="Count"
+                    orientation="horizontal"
                     stat="numimagesstat" 
                     bar_max="8000.f" 
                     tick_spacing="2000.f"
@@ -123,6 +138,7 @@
                     show_bar="false"/>
 			    <stat_bar name="numrawimagesstat"
                     label="Raw Count"
+                    orientation="horizontal"
                     stat="numrawimagesstat"
                     bar_max="8000.f" 
                     tick_spacing="2000.f"
@@ -136,6 +152,7 @@
                    setting="OpenDebugStatNet">
 			    <stat_bar name="packetsinstat"
                     label="Packets In"
+                    orientation="horizontal"
                     stat="packetsinstat"
                     unit_label="/sec" 
                     bar_max="1024.f" 
@@ -145,6 +162,7 @@
                     show_bar="false"/>
 			    <stat_bar name="packetsoutstat"
                     label="Packets Out"
+                    orientation="horizontal"
                     stat="packetsoutstat"
                     unit_label="/sec"  
                     bar_max="1024.f" 
@@ -154,6 +172,7 @@
                     show_bar="false"/>
 			    <stat_bar name="objectkbitstat"
                     label="Objects"
+                    orientation="horizontal"
                     stat="objectkbitstat"
                     unit_label="kbps"
                     bar_max="1024.f"
@@ -163,6 +182,7 @@
                     show_bar="false"/>
 			    <stat_bar name="texturekbitstat"
                     label="Texture"
+                    orientation="horizontal"
                     stat="texturekbitstat"
                     unit_label="kbps"
                     bar_max="1024.f"
@@ -172,6 +192,7 @@
                     show_bar="false"/>
 			    <stat_bar name="assetkbitstat"
                     label="Asset"
+                    orientation="horizontal"
                     stat="assetkbitstat"
                     unit_label="kbps"
                     bar_max="1024.f"
@@ -181,6 +202,7 @@
                     show_bar="false"/>
 			    <stat_bar name="layerskbitstat"
                     label="Layers"
+                    orientation="horizontal"
                     stat="layerskbitstat"
                     unit_label="kbps"
                     bar_max="1024.f"
@@ -190,26 +212,27 @@
                     show_bar="false"/>
 			    <stat_bar name="actualinkbitstat"
                     label="Actual In"
+                    orientation="horizontal"
                     stat="actualinkbitstat"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
                     label_spacing="256.f"
                     precision="1"
-                    show_bar="false"
-                    show_history="false"/>
+                    show_bar="false"/>
 			    <stat_bar name="actualoutkbitstat"
                     label="Actual Out"
+                    orientation="horizontal"
                     stat="actualoutkbitstat"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
                     label_spacing="256.f"
                     precision="1"
-                    show_bar="false"
-                    show_history="false"/>
+                    show_bar="false"/>
 			    <stat_bar name="vfspendingoperations"
                     label="VFS Pending Operations"
+                    orientation="horizontal"
                     stat="vfspendingoperations"
                     unit_label=" Ops."
                     show_bar="false"/>
@@ -222,6 +245,7 @@
                  setting="OpenDebugStatSim">
 			  <stat_bar name="simobjects"
                   label="Objects"
+                  orientation="horizontal"
                   stat="simobjects"
                   precision="0"
                   bar_max="30000.f" 
@@ -231,6 +255,7 @@
                   show_mean="false"/>
 			  <stat_bar name="simactiveobjects"
                   label="Active Objects"
+                  orientation="horizontal"
                   stat="simactiveobjects"
                   precision="0"
                   bar_max="5000.f" 
@@ -240,6 +265,7 @@
                   show_mean="false"/>
 			  <stat_bar name="simactivescripts"
                   label="Active Scripts"
+                  orientation="horizontal"
                   stat="simactivescripts"
                   precision="0"
                   bar_max="15000.f" 
@@ -249,6 +275,7 @@
                   show_mean="false"/>
 			  <stat_bar name="siminpps"
                   label="Packets In"
+                  orientation="horizontal"
                   stat="siminpps"
                   unit_label="pps"
                   precision="0"
@@ -259,6 +286,7 @@
                   show_mean="false"/>
 			  <stat_bar name="simoutpps"
                   label="Packets Out"
+                  orientation="horizontal"
                   stat="simoutpps"
                   unit_label="pps" 
                   precision="0"
@@ -269,6 +297,7 @@
                   show_mean="false"/>
 			  <stat_bar name="simpendingdownloads"
                   label="Pending Downloads"
+                  orientation="horizontal"
                   stat="simpendingdownloads"
                   precision="0"
                   bar_max="800.f" 
@@ -278,6 +307,7 @@
                   show_mean="false"/>
 			  <stat_bar name="simpendinguploads"
                   label="Pending Uploads"
+                  orientation="horizontal"
                   stat="simpendinguploads"
                   precision="0"
                   bar_max="100.f" 
@@ -287,6 +317,7 @@
                   show_mean="false"/>
 			  <stat_bar name="simtotalunackedbytes"
                   label="Total Unacked Bytes"
+                  orientation="horizontal"
                   stat="simtotalunackedbytes"
                   unit_label="kb"
                   precision="1"
@@ -300,6 +331,7 @@
                    show_label="true">
 			    <stat_bar name="simframemsec"
                     label="Total Frame Time"
+                    orientation="horizontal"
                     stat="simframemsec"
                     unit_label="ms"
                     precision="3"
@@ -310,6 +342,7 @@
                     show_mean="false"/>
 			    <stat_bar name="simnetmsec"
                     label="Net Time"
+                    orientation="horizontal"
                     stat="simnetmsec"
                     unit_label="ms"
                     precision="3"
@@ -320,6 +353,7 @@
                     show_mean="false"/>
 			    <stat_bar name="simsimphysicsmsec"
                     label="Physics Time"
+                    orientation="horizontal"
                     stat="simsimphysicsmsec"
                     unit_label="ms"
                     precision="3"
@@ -330,6 +364,7 @@
                     show_mean="false"/>
 			    <stat_bar name="simsimothermsec"
                     label="Simulation Time"
+                    orientation="horizontal"
                     stat="simsimothermsec"
                     unit_label="ms"
                     precision="3"
@@ -340,6 +375,7 @@
                     show_mean="false"/>
 			    <stat_bar name="simagentmsec"
                     label="Agent Time"
+                    orientation="horizontal"
                     stat="simagentmsec"
                     unit_label="ms"
                     precision="3"
@@ -350,6 +386,7 @@
                     show_mean="false"/>
 			    <stat_bar name="simimagesmsec"
                     label="Images Time"
+                    orientation="horizontal"
                     stat="simimagesmsec"
                     unit_label="ms"
                     precision="3"
@@ -360,6 +397,7 @@
                     show_mean="false"/>
 			    <stat_bar name="simscriptmsec"
                     label="Script Time"
+                    orientation="horizontal"
                     stat="simscriptmsec"
                     unit_label="ms"
                     precision="3"
@@ -370,6 +408,7 @@
                     show_mean="false"/>
           <stat_bar name="simsparemsec"
                     label="Spare Time"
+                    orientation="horizontal"
                     stat="simsparemsec"
                     unit_label="ms"
                     precision="3"
@@ -384,6 +423,7 @@
                      show_label="true">
             <stat_bar name="simsimphysicsstepmsec"
                       label="  Physics Step"
+                      orientation="horizontal"
                       stat="simsimphysicsstepmsec"
                       unit_label="ms"
                       precision="3"
@@ -394,6 +434,7 @@
                       show_mean="false"/>
             <stat_bar name="simsimphysicsshapeupdatemsec"
                       label="  Update Phys Shapes"
+                      orientation="horizontal"
                       stat="simsimphysicsshapeupdatemsec"
                       unit_label="ms"
                       precision="3"
@@ -404,6 +445,7 @@
                       show_mean="false"/>
             <stat_bar name="simsimphysicsothermsec"
                       label="  Physics Other"
+                      orientation="horizontal"
                       stat="simsimphysicsothermsec"
                       unit_label="ms"
                       precision="3"
@@ -414,6 +456,7 @@
                       show_mean="false"/>
             <stat_bar name="simsleepmsec"
                       label="  Sleep Time"
+                      orientation="horizontal"
                       stat="simsleepmsec"
                       unit_label="ms"
                       precision="3"
@@ -424,6 +467,7 @@
                       show_mean="false"/>
             <stat_bar name="simpumpiomsec"
                       label="  Pump IO"
+                      orientation="horizontal"
                       stat="simpumpiomsec"
                       unit_label="ms"
                       precision="3"
-- 
cgit v1.2.3


From 0c63f95b9e1368607126b8d2edbcd91172e61db5 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 21 Mar 2013 17:26:43 -0700
Subject: BUILDFIX fix for gcc build

---
 indra/newview/llfloatersceneloadstats.cpp | 5 ++++-
 indra/newview/llfloatersceneloadstats.h   | 4 ++++
 2 files changed, 8 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloatersceneloadstats.cpp b/indra/newview/llfloatersceneloadstats.cpp
index 95e8fbf4dd..8aa93eae96 100644
--- a/indra/newview/llfloatersceneloadstats.cpp
+++ b/indra/newview/llfloatersceneloadstats.cpp
@@ -32,6 +32,9 @@
 
 LLFloaterSceneLoadStats::LLFloaterSceneLoadStats( const LLSD& key ) 
 :	LLFloater(key)
-{
+{}
 
+BOOL LLFloaterSceneLoadStats::postBuild()
+{
+	return TRUE;
 }
diff --git a/indra/newview/llfloatersceneloadstats.h b/indra/newview/llfloatersceneloadstats.h
index 095541f2f6..aa414bf544 100644
--- a/indra/newview/llfloatersceneloadstats.h
+++ b/indra/newview/llfloatersceneloadstats.h
@@ -34,6 +34,10 @@ class LLFloaterSceneLoadStats : public LLFloater
 	friend class LLFloaterReg;
 private:
 	LLFloaterSceneLoadStats(const LLSD& key);
+
+public:
+	BOOL postBuild();
+
 };
 
 #endif // LL_FLOATERSCENELOADSTATS_H
-- 
cgit v1.2.3


From cf4798b8f90eebaa62dcb8817538f1e3965b6bc9 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 22 Mar 2013 14:00:09 -0700
Subject: BUILDFIX gcc and vc fixes

---
 indra/newview/llviewerobjectlist.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 5ccb19ab2e..922d386818 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -262,7 +262,7 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp,
 	// so that the drawable parent is set properly
 	if(msg != NULL)
 	{
-	findOrphans(objectp, msg->getSenderIP(), msg->getSenderPort());
+		findOrphans(objectp, msg->getSenderIP(), msg->getSenderPort());
 	}
 	else
 	{
@@ -451,9 +451,9 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 
 		if (compressed)
 		{
-			S32							uncompressed_length = 2048;
-			compressed_dp.reset();
-
+			S32	uncompressed_length = 2048;
+			compressed_dp.reset();			
+			
 			uncompressed_length = mesgsys->getSizeFast(_PREHASH_ObjectData, i, _PREHASH_Data);
 			mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_Data, compressed_dpbuffer, 0, i);
 			compressed_dp.assignBuffer(compressed_dpbuffer, uncompressed_length);
@@ -626,9 +626,9 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 					bCached = true;
 					LLViewerRegion::eCacheUpdateResult result = objectp->mRegionp->cacheFullUpdate(objectp, compressed_dp, flags);
 					recorder.cacheFullUpdate(local_id, update_type, result, objectp, msg_size);
+				}
 			}
 #endif
-		}
 		}
 		else
 		{
-- 
cgit v1.2.3


From 935dce7d6b0a343cef5b13f53d6da5d0c2dc6a73 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 25 Mar 2013 00:18:06 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 fixed some compile errors made label spacing automatic on stat bars fixed
 infinite values coming from stats

---
 indra/newview/llfloaterjoystick.cpp                |  4 +-
 indra/newview/llworld.cpp                          |  3 +-
 .../default/xui/en/floater_scene_load_stats.xml    | 42 +------------
 .../newview/skins/default/xui/en/floater_stats.xml | 71 +++-------------------
 indra/newview/tests/llviewerassetstats_test.cpp    |  2 +-
 5 files changed, 17 insertions(+), 105 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index 7fcebc965a..dbdf3e5e9f 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -85,7 +85,7 @@ void LLFloaterJoystick::draw()
 			if (llabs(value) > maxbar)
 			{
 				F32 range = llabs(value);
-				mAxisStatsBar[i]->setRange(-range, range, range * 0.25f, range * 0.5f);
+				mAxisStatsBar[i]->setRange(-range, range, range * 0.25f);
 			}
 		}
 	}
@@ -106,7 +106,7 @@ BOOL LLFloaterJoystick::postBuild()
 		if (mAxisStatsBar[i])
 		{
 			mAxisStatsBar[i]->setStat(stat_name);
-			mAxisStatsBar[i]->setRange(-range, range, range * 0.25f, range * 0.5f);
+			mAxisStatsBar[i]->setRange(-range, range, range * 0.25f);
 		}
 	}
 	
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 12eea513da..9401773886 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -728,7 +728,8 @@ void LLWorld::updateNetStats()
 	add(LLStatViewer::PACKETS_LOST, packets_lost);
 	if (packets_in)
 	{
-		sample(LLStatViewer::PACKETS_LOST_PERCENT, 100.f * ((F32)packets_lost/(F32)packets_in));
+		F32 packet_loss = 100.f * ((F32)packets_lost/(F32)packets_in);
+		sample(LLStatViewer::PACKETS_LOST_PERCENT, packet_loss);
 	}
 
 	mLastPacketsIn = gMessageSystem->mPacketsIn;
diff --git a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
index f4021d210a..246e8bb256 100644
--- a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
@@ -8,7 +8,8 @@
          save_visibility="true"
          title="SCENE LOAD STATISTICS"
          width="260">
-    <button top="20"
+    <button follows="top|left"
+            top="20"
             bottom="60"
             left="10"
             width="100"
@@ -41,7 +42,6 @@
                   stat="FramePixelDifference"
                   bar_max="100"
                   tick_spacing="10"
-                  label_spacing="20"
                   unit_scale="100"
                   precision="0"/>
         <stat_bar name="bandwidth"
@@ -51,7 +51,6 @@
                   stat="kbitstat"
                   bar_max="5000"
                   tick_spacing="500"
-                  label_spacing="1000"
                   precision="0"/>
 			  <stat_bar name="packet_loss"
                   label="Packet Loss"
@@ -60,7 +59,6 @@
                   stat="packetslostpercentstat"
                   bar_max="5"
                   tick_spacing="0.5"
-                  label_spacing="1"
                   precision="3"
                   show_bar="false"
                   show_mean="true"/>
@@ -81,7 +79,6 @@
                     stat="numobjectsstat"
                     bar_max="50000"
                     tick_spacing="5000"
-                    label_spacing="10000"
                     precision="0"
                     show_bar="false"/>
           <stat_bar name="newobjs"
@@ -91,7 +88,6 @@
                     stat="numnewobjectsstat"
                     bar_max="2000"
                     tick_spacing="200"
-                    label_spacing="400"
                     show_bar="false"/>
           <stat_bar name="object_cache_hits"
                     label="Object Cache Hit Rate"
@@ -100,7 +96,6 @@
                     bar_max="100"
                     unit_label="%"
                     tick_spacing="20"
-                    label_spacing="20"
                     show_history="true"
                     show_bar="false"/>
 			  </stat_view>
@@ -115,7 +110,6 @@
                     bar_max="100.f"
                     unit_label="%"
                     tick_spacing="20"
-                    label_spacing="20"
                     show_history="true"
                     show_bar="false"/>
           <stat_bar name="texture_cache_read_latency"
@@ -125,7 +119,6 @@
                     stat="texture_cache_read_latency"
                     bar_max="1000.f"
                     tick_spacing="100"
-                    label_spacing="200"
                     show_history="true"
                     show_bar="false"/>
           <stat_bar name="numimagesstat"
@@ -134,7 +127,6 @@
                     stat="numimagesstat" 
                     bar_max="8000.f" 
                     tick_spacing="2000.f"
-                    label_spacing="4000.f" 
                     show_bar="false"/>
 			    <stat_bar name="numrawimagesstat"
                     label="Raw Count"
@@ -142,7 +134,6 @@
                     stat="numrawimagesstat"
                     bar_max="8000.f" 
                     tick_spacing="2000.f"
-                    label_spacing="4000.f" 
                     show_bar="false"/>
 			  </stat_view>
 <!--Network Stats-->
@@ -157,7 +148,6 @@
                     unit_label="/sec" 
                     bar_max="1024.f" 
                     tick_spacing="128.f"
-                    label_spacing="256.f" 
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="packetsoutstat"
@@ -167,7 +157,6 @@
                     unit_label="/sec"  
                     bar_max="1024.f" 
                     tick_spacing="128.f"
-                    label_spacing="256.f" 
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="objectkbitstat"
@@ -177,7 +166,6 @@
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
-                    label_spacing="256.f"
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="texturekbitstat"
@@ -187,7 +175,6 @@
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
-                    label_spacing="256.f"
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="assetkbitstat"
@@ -197,7 +184,6 @@
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
-                    label_spacing="256.f"
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="layerskbitstat"
@@ -207,7 +193,6 @@
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
-                    label_spacing="256.f"
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="actualinkbitstat"
@@ -217,7 +202,6 @@
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
-                    label_spacing="256.f"
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="actualoutkbitstat"
@@ -227,7 +211,6 @@
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
-                    label_spacing="256.f"
                     precision="1"
                     show_bar="false"/>
 			    <stat_bar name="vfspendingoperations"
@@ -250,7 +233,6 @@
                   precision="0"
                   bar_max="30000.f" 
                   tick_spacing="5000.f"
-                  label_spacing="10000.f" 
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_bar name="simactiveobjects"
@@ -260,7 +242,6 @@
                   precision="0"
                   bar_max="5000.f" 
                   tick_spacing="750.f"
-                  label_spacing="1250.f" 
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_bar name="simactivescripts"
@@ -270,7 +251,6 @@
                   precision="0"
                   bar_max="15000.f" 
                   tick_spacing="1875.f"
-                  label_spacing="3750.f"  
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_bar name="siminpps"
@@ -281,7 +261,6 @@
                   precision="0"
                   bar_max="2000.f" 
                   tick_spacing="250.f"
-                  label_spacing="1000.f" 
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_bar name="simoutpps"
@@ -292,7 +271,6 @@
                   precision="0"
                   bar_max="2000.f" 
                   tick_spacing="250.f"
-                  label_spacing="1000.f" 
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_bar name="simpendingdownloads"
@@ -302,7 +280,6 @@
                   precision="0"
                   bar_max="800.f" 
                   tick_spacing="100.f"
-                  label_spacing="200.f" 
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_bar name="simpendinguploads"
@@ -312,7 +289,6 @@
                   precision="0"
                   bar_max="100.f" 
                   tick_spacing="25.f"
-                  label_spacing="50.f" 
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_bar name="simtotalunackedbytes"
@@ -323,7 +299,6 @@
                   precision="1"
                   bar_max="100000.f" 
                   tick_spacing="25000.f"
-                  label_spacing="50000.f" 
                   show_bar="false"
                   show_mean="false"/>
 			  <stat_view name="simperf"
@@ -337,7 +312,6 @@
                     precision="3"
                     bar_max="40.f" 
                     tick_spacing="10.f"
-                    label_spacing="20.f" 
                     show_bar="false"
                     show_mean="false"/>
 			    <stat_bar name="simnetmsec"
@@ -348,7 +322,6 @@
                     precision="3"
                     bar_max="40.f" 
                     tick_spacing="10.f"
-                    label_spacing="20.f" 
                     show_bar="false"
                     show_mean="false"/>
 			    <stat_bar name="simsimphysicsmsec"
@@ -359,7 +332,6 @@
                     precision="3"
                     bar_max="40.f" 
                     tick_spacing="10.f"
-                    label_spacing="20.f" 
                     show_bar="false"
                     show_mean="false"/>
 			    <stat_bar name="simsimothermsec"
@@ -370,7 +342,6 @@
                     precision="3"
                     bar_max="40.f" 
                     tick_spacing="10.f"
-                    label_spacing="20.f" 
                     show_bar="false"
                     show_mean="false"/>
 			    <stat_bar name="simagentmsec"
@@ -381,7 +352,6 @@
                     precision="3"
                     bar_max="40.f" 
                     tick_spacing="10.f"
-                    label_spacing="20.f" 
                     show_bar="false"
                     show_mean="false"/>
 			    <stat_bar name="simimagesmsec"
@@ -392,7 +362,6 @@
                     precision="3"
                     bar_max="40.f" 
                     tick_spacing="10.f"
-                    label_spacing="20.f" 
                     show_bar="false"
                     show_mean="false"/>
 			    <stat_bar name="simscriptmsec"
@@ -403,7 +372,6 @@
                     precision="3"
                     bar_max="40.f" 
                     tick_spacing="10.f"
-                    label_spacing="20.f" 
                     show_bar="false"
                     show_mean="false"/>
           <stat_bar name="simsparemsec"
@@ -414,7 +382,6 @@
                     precision="3"
                     bar_max="40.f"
                     tick_spacing="10.f"
-                    label_spacing="20.f"
                     show_bar="false"
                     show_mean="false"/>
 <!--2nd level time blocks under 'Details' second-->
@@ -429,7 +396,6 @@
                       precision="3"
                       bar_max="40.f"
                       tick_spacing="10.f"
-                      label_spacing="20.f"
                       show_bar="false"
                       show_mean="false"/>
             <stat_bar name="simsimphysicsshapeupdatemsec"
@@ -440,7 +406,6 @@
                       precision="3"
                       bar_max="40.f"
                       tick_spacing="10.f"
-                      label_spacing="20.f"
                       show_bar="false"
                       show_mean="false"/>
             <stat_bar name="simsimphysicsothermsec"
@@ -451,7 +416,6 @@
                       precision="3"
                       bar_max="40.f"
                       tick_spacing="10.f"
-                      label_spacing="20.f"
                       show_bar="false"
                       show_mean="false"/>
             <stat_bar name="simsleepmsec"
@@ -462,7 +426,6 @@
                       precision="3"
                       bar_max="40.f"
                       tick_spacing="10.f"
-                      label_spacing="20.f"
                       show_bar="false"
                       show_mean="false"/>
             <stat_bar name="simpumpiomsec"
@@ -473,7 +436,6 @@
                       precision="3"
                       bar_max="40.f"
                       tick_spacing="10.f"
-                      label_spacing="20.f"
                       show_bar="false"
                       show_mean="false"/>
           </stat_view>
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index a3f2fb0b9c..f98fcc349e 100644
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -31,18 +31,17 @@
 		  <stat_view
 			 name="basic"
 			 label="Basic"
+       follows="left|top|right"
 			 show_label="true"
 			 setting="OpenDebugStatBasic">
 			<stat_bar
 			   name="fps"
-         orientation="horizontal"
 			   label="FPS"
 			   unit_label="fps"
 			   stat="fpsstat"
 			   bar_min="0"
 			   bar_max="60"
 			   tick_spacing="6"
-			   label_spacing="12"
 			   precision="1"
 			   show_bar="true"
 			   show_history="true">
@@ -55,7 +54,6 @@
 			   bar_min="0"
 			   bar_max="5000"
 			   tick_spacing="500"
-			   label_spacing="1000"
 				 precision="0"
 			   show_bar="true"
 			   show_history="false">
@@ -68,7 +66,6 @@
 			   bar_min="0"
 			   bar_max="5"
 			   tick_spacing="0.5"
-			   label_spacing="1"
 			   precision="3"
 			   show_bar="false"
 			   show_mean="true">
@@ -81,7 +78,6 @@
 			   bar_min="0"
 			   bar_max="5000"
 			   tick_spacing="500"
-			   label_spacing="1000"
 				 precision="0"
 			   show_bar="false"
 			   show_mean="false">
@@ -91,11 +87,13 @@
       <stat_view
 			 name="advanced"
 			 label="Advanced"
+       follows="left|top|right"       
 			 show_label="true"
 			 setting="OpenDebugStatAdvanced">
 			<stat_view
 			   name="render"
 			   label="Render"
+         follows="left|top|right"
 			   show_label="true"
 			   setting="OpenDebugStatRender">
 			  <stat_bar
@@ -107,7 +105,6 @@
 				 bar_min="0"
 				 bar_max="10000"
 				 tick_spacing="1000"
-				 label_spacing="2000"
 				 precision="0"
 				 show_per_sec="false"
          show_bar="false">
@@ -121,7 +118,6 @@
 				 bar_min="0"
 				 bar_max="200000"
 				 tick_spacing="25000"
-				 label_spacing="50000"
 				 precision="0"
          show_bar="false">
         </stat_bar>
@@ -133,7 +129,6 @@
 				 bar_min="0"
 				 bar_max="50000"
 				 tick_spacing="5000"
-				 label_spacing="10000"
 				 precision="0"
 				 show_bar="false">
 			  </stat_bar>
@@ -145,7 +140,6 @@
 				 bar_min="0"
 				 bar_max="2000"
 				 tick_spacing="200"
-				 label_spacing="400"
 				 show_bar="false">
 			  </stat_bar>
        <stat_bar
@@ -156,7 +150,6 @@
 				 bar_max="100"
          unit_label="%"
 				 tick_spacing="20"
-				 label_spacing="20"
 				 show_history="true"
 				 show_bar="false">
         </stat_bar>
@@ -165,6 +158,7 @@
 			<stat_view
 			   name="texture"
 			   label="Texture"
+         follows="left|top|right"
 			   show_label="true">
 			  <stat_bar
 				 name="texture_cache_hits"
@@ -174,7 +168,6 @@
 				 bar_max="100.f"
          unit_label="%"
 				 tick_spacing="20"
-				 label_spacing="20"
 				 show_history="true"
 				 show_bar="false">
         </stat_bar>
@@ -186,7 +179,6 @@
 				 bar_min="0.f"
 				 bar_max="1000.f"
 				 tick_spacing="100"
-				 label_spacing="200"
 				 show_history="true"
 				 show_bar="false">
         </stat_bar>
@@ -197,7 +189,6 @@
 				 bar_min="0.f"
 				 bar_max="8000.f" 
 				 tick_spacing="2000.f"
-				 label_spacing="4000.f" 
 				 show_bar="false">
 			  </stat_bar>
 
@@ -208,7 +199,6 @@
 				 bar_min="0.f"
 				 bar_max="8000.f" 
 				 tick_spacing="2000.f"
-				 label_spacing="4000.f" 
 				 show_bar="false">
 			  </stat_bar>
 
@@ -221,7 +211,6 @@
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
-				 label_spacing="200.f" 
 				 precision="1"
          show_bar="false">
         </stat_bar>
@@ -235,7 +224,6 @@
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
-				 label_spacing="200.f" 
 				 precision="3"
          show_bar="false">
         </stat_bar>
@@ -249,7 +237,6 @@
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
-				 label_spacing="200.f" 
 				 precision="3"
          show_bar="false">
         </stat_bar>
@@ -263,7 +250,6 @@
 				 bar_min="0.f"
 				 bar_max="400.f" 
 				 tick_spacing="100.f"
-				 label_spacing="200.f" 
 				 precision="3"
          show_bar="false">
         </stat_bar>
@@ -272,6 +258,7 @@
 			<stat_view
 			   name="network"
 			   label="Network"
+         follows="left|top|right"
 			   show_label="true"
 			   setting="OpenDebugStatNet">
 			  <stat_bar
@@ -282,7 +269,6 @@
          bar_min="0.f"
 				 bar_max="1024.f" 
 				 tick_spacing="128.f"
-				 label_spacing="256.f" 
 				 precision="1"
 				 show_bar="false">
 			  </stat_bar>
@@ -295,7 +281,6 @@
          bar_min="0.f"
 				 bar_max="1024.f" 
 				 tick_spacing="128.f"
-				 label_spacing="256.f" 
 				 precision="1"
 				 show_bar="false" >
 			  </stat_bar>
@@ -308,7 +293,6 @@
          bar_min="0.f"
          bar_max="1024.f"
          tick_spacing="128.f"
-         label_spacing="256.f"
          precision="1"
 				 show_bar="false" >
 			  </stat_bar>
@@ -321,7 +305,6 @@
          bar_min="0.f"
          bar_max="1024.f"
          tick_spacing="128.f"
-         label_spacing="256.f"
          precision="1"
 				 show_bar="false" >
 			  </stat_bar>
@@ -334,7 +317,6 @@
          bar_min="0.f"
          bar_max="1024.f"
          tick_spacing="128.f"
-         label_spacing="256.f"
          precision="1"
 				 show_bar="false" >
 			  </stat_bar>
@@ -347,7 +329,6 @@
          bar_min="0.f"
          bar_max="1024.f"
          tick_spacing="128.f"
-         label_spacing="256.f"
          precision="1"
 				 show_bar="false" >
 			  </stat_bar>
@@ -360,7 +341,6 @@
          bar_min="0.f"
          bar_max="1024.f"
          tick_spacing="128.f"
-         label_spacing="256.f"
          precision="1"
 				 show_bar="false"
 				 show_history="false" >
@@ -374,7 +354,6 @@
          bar_min="0.f"
          bar_max="1024.f"
          tick_spacing="128.f"
-         label_spacing="256.f"
          precision="1"
 				 show_bar="false"
 				 show_history="false">
@@ -393,6 +372,7 @@
 		  <stat_view
 			 name="sim"
 			 label="Simulator"
+       follows="left|top|right"
 			 show_label="true"
 			 setting="OpenDebugStatSim">
 			<stat_bar
@@ -403,7 +383,6 @@
 			   bar_min="0.f"
 			   bar_max="1.f" 
 			   tick_spacing="0.16666f"
-			   label_spacing="0.33333f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -416,7 +395,6 @@
 			   bar_min="0.f"
 			   bar_max="45.f" 
 			   tick_spacing="7.5f"
-			   label_spacing="15.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -429,7 +407,6 @@
 			   bar_min="0.f"
 			   bar_max="45.f" 
 			   tick_spacing="7.5.f"
-			   label_spacing="15.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -437,6 +414,7 @@
 			<stat_view
 			   name="physicsdetail"
 			   label="Physics Details"
+         follows="left|top|right"
 			   show_label="true">
 			  <stat_bar
 				 name="physicspinnedtasks"
@@ -446,7 +424,6 @@
 				 bar_min="0.f"
 				 bar_max="500.f" 
 				 tick_spacing="50.f"
-				 label_spacing="100.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -459,7 +436,6 @@
 				 bar_min="0.f"
 				 bar_max="500.f" 
 				 tick_spacing="50.f"
-				 label_spacing="100.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -473,7 +449,6 @@
 				 bar_min="0.f"
 				 bar_max="1024.f" 
 				 tick_spacing="128.f"
-				 label_spacing="256.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -487,7 +462,6 @@
 			   bar_min="0.f"
 			   bar_max="100.f" 
 			   tick_spacing="25.f"
-			   label_spacing="50.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -500,7 +474,6 @@
 			   bar_min="0.f"
 			   bar_max="80.f" 
 			   tick_spacing="10.f"
-			   label_spacing="40.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -513,7 +486,6 @@
 			   bar_min="0.f"
 			   bar_max="40.f" 
 			   tick_spacing="5.f"
-			   label_spacing="10.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -526,7 +498,6 @@
 			   bar_min="0.f"
 			   bar_max="30000.f" 
 			   tick_spacing="5000.f"
-			   label_spacing="10000.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -539,7 +510,6 @@
 			   bar_min="0.f"
 			   bar_max="5000.f" 
 			   tick_spacing="750.f"
-			   label_spacing="1250.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -552,7 +522,6 @@
 			   bar_min="0.f"
 			   bar_max="15000.f" 
 			   tick_spacing="1875.f"
-			   label_spacing="3750.f"  
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -564,7 +533,6 @@
             bar_min="0"
             bar_max="100"
             tick_spacing="10"
-            label_spacing="20"
             precision="3"
             show_bar="false"
             show_mean="true">
@@ -579,7 +547,6 @@
 			   bar_min="0.f"
 			   bar_max="5000.f" 
 			   tick_spacing="750.f"
-			   label_spacing="1250.f"  
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -587,6 +554,7 @@
         <stat_view
             name="simpathfinding"
             label="Pathfinding"
+            follows="left|top|right"
             show_label="true">
           <stat_bar
               name="simsimaistepmsec"
@@ -597,7 +565,6 @@
               bar_min="0.f"
               bar_max="40.f"
               tick_spacing="10.f"
-              label_spacing="20.f"
               show_bar="false"
               show_mean="false" >
           </stat_bar>
@@ -610,7 +577,6 @@
               bar_min="0"
               bar_max="45"
               tick_spacing="4"
-              label_spacing="8"
               show_bar="false">
           </stat_bar>
           <stat_bar
@@ -621,7 +587,6 @@
               bar_min="0"
               bar_max="100"
               tick_spacing="10"
-              label_spacing="20"
               precision="1"
               show_bar="false"
               show_mean="true">
@@ -637,7 +602,6 @@
 			   bar_min="0.f"
 			   bar_max="2000.f" 
 			   tick_spacing="250.f"
-			   label_spacing="1000.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -651,7 +615,6 @@
 			   bar_min="0.f"
 			   bar_max="2000.f" 
 			   tick_spacing="250.f"
-			   label_spacing="1000.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -664,7 +627,6 @@
 			   bar_min="0.f"
 			   bar_max="800.f" 
 			   tick_spacing="100.f"
-			   label_spacing="200.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -677,7 +639,6 @@
 			   bar_min="0.f"
 			   bar_max="100.f" 
 			   tick_spacing="25.f"
-			   label_spacing="50.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -691,7 +652,6 @@
 			   bar_min="0.f"
 			   bar_max="100000.f" 
 			   tick_spacing="25000.f"
-			   label_spacing="50000.f" 
 			   show_bar="false"
 			   show_mean="false" >
 			</stat_bar>
@@ -699,6 +659,7 @@
 			<stat_view
 			   name="simperf"
 			   label="Time (ms)"
+         follows="left|top|right"
 			   show_label="true">
 			  <stat_bar
 				 name="simframemsec"
@@ -709,7 +670,6 @@
 				 bar_min="0.f"
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
-				 label_spacing="20.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -723,7 +683,6 @@
 				 bar_min="0.f"
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
-				 label_spacing="20.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -737,7 +696,6 @@
 				 bar_min="0.f"
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
-				 label_spacing="20.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -751,7 +709,6 @@
 				 bar_min="0.f"
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
-				 label_spacing="20.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -765,7 +722,6 @@
 				 bar_min="0.f"
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
-				 label_spacing="20.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -779,7 +735,6 @@
 				 bar_min="0.f"
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
-				 label_spacing="20.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -793,7 +748,6 @@
 				 bar_min="0.f"
 				 bar_max="40.f" 
 				 tick_spacing="10.f"
-				 label_spacing="20.f" 
 				 show_bar="false"
 				 show_mean="false" >
 			  </stat_bar>
@@ -807,7 +761,6 @@
          bar_min="0.f"
          bar_max="40.f"
          tick_spacing="10.f"
-         label_spacing="20.f"
          show_bar="false"
          show_mean="false" >
         </stat_bar>
@@ -815,6 +768,7 @@
           <stat_view
  			     name="timedetails"
 			     label="Time Details (ms)"
+           follows="left|top|right"
 			     show_label="true">
             <stat_bar
              name="simsimphysicsstepmsec"
@@ -825,7 +779,6 @@
              bar_min="0.f"
              bar_max="40.f"
              tick_spacing="10.f"
-             label_spacing="20.f"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -838,7 +791,6 @@
              bar_min="0.f"
              bar_max="40.f"
              tick_spacing="10.f"
-             label_spacing="20.f"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -851,7 +803,6 @@
              bar_min="0.f"
              bar_max="40.f"
              tick_spacing="10.f"
-             label_spacing="20.f"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -864,7 +815,6 @@
              bar_min="0.f"
              bar_max="40.f"
              tick_spacing="10.f"
-             label_spacing="20.f"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
@@ -877,7 +827,6 @@
              bar_min="0.f"
              bar_max="40.f"
              tick_spacing="10.f"
-             label_spacing="20.f"
              show_bar="false"
              show_mean="false" >
             </stat_bar>
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index ecdd78a1da..41d141255b 100644
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -39,7 +39,7 @@
 
 namespace LLStatViewer
 {
-	LLTrace::Measurement<>		FPS_SAMPLE("fpssample");
+	LLTrace::<>		FPS_SAMPLE("fpssample");
 }
 
 void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts)
-- 
cgit v1.2.3


From 0ddeaa196731299e443d96e9f2797d8247c0de97 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 25 Mar 2013 18:45:42 -0600
Subject: for SH-3927: Interesting: Viewer should send predicted camera
 position to simulator to control object load order

---
 indra/newview/llface.cpp          | 2 --
 indra/newview/llviewercamera.h    | 2 +-
 indra/newview/llviewermessage.cpp | 3 +++
 3 files changed, 4 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 28e4b32793..56619563cf 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -2346,8 +2346,6 @@ F32 LLFace::calcImportanceToCamera(F32 cos_angle_to_view_dir, F32 dist)
 			return 0.f ;
 		}
 		
-		//F32 camera_relative_speed = camera_moving_speed * (lookAt * LLViewerCamera::getInstance()->getVelocityDir()) ;
-		
 		S32 i = 0 ;
 		for(i = 0; i < FACE_IMPORTANCE_LEVEL && dist > FACE_IMPORTANCE_TO_CAMERA_OVER_DISTANCE[i][0]; ++i);
 		i = llmin(i, FACE_IMPORTANCE_LEVEL - 1) ;
diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h
index ffec284f72..d7835d8567 100644
--- a/indra/newview/llviewercamera.h
+++ b/indra/newview/llviewercamera.h
@@ -100,7 +100,7 @@ public:
 	BOOL projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoordGL &out_point, const BOOL clamp = TRUE) const;
 	BOOL projectPosAgentToScreenEdge(const LLVector3 &pos_agent, LLCoordGL &out_point) const;
 
-	const LLVector3* getVelocityDir() const {return &mVelocityDir;}
+	LLVector3 getVelocityDir() const {return mVelocityDir;}
 	static LLTrace::CountStatHandle<>* getVelocityStat()		   {return &sVelocityStat; }
 	static LLTrace::CountStatHandle<>* getAngularVelocityStat()  {return &sAngularVelocityStat; }
 	F32     getCosHalfFov() {return mCosHalfCameraFOV;}
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 4b1c9c5574..8dc72ba5b4 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4222,6 +4222,9 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 	LLQuaternion head_rotation = gAgent.getHeadRotation();
 
 	camera_pos_agent = gAgentCamera.getCameraPositionAgent();
+	LLVector3 camera_velocity = LLViewerCamera::getInstance()->getVelocityDir() * LLViewerCamera::getInstance()->getAverageSpeed();
+	F32 time_delta = 1.0f; //predict the camera position in 1 second
+	camera_pos_agent += camera_velocity * time_delta;
 
 	render_state = gAgent.getRenderState();
 
-- 
cgit v1.2.3


From cd46f3d08cef6f43c29447e36c920d10ec184a18 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 25 Mar 2013 20:21:04 -0700
Subject: BUILDFIX gcc fix

---
 indra/newview/tests/llviewerassetstats_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index ecdd78a1da..ae93778534 100644
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -39,7 +39,7 @@
 
 namespace LLStatViewer
 {
-	LLTrace::Measurement<>		FPS_SAMPLE("fpssample");
+	LLTrace::MeasurementStatHandle<>		FPS_SAMPLE("fpssample");
 }
 
 void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts)
-- 
cgit v1.2.3


From 268ea2902d1108a1b30909340ca10ee0bea9f147 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 25 Mar 2013 21:23:59 -0600
Subject: for SH-3833: dump frame diff values from the scene loading monitor to
 a log file

---
 indra/newview/llappviewer.cpp    |  9 +++++++++
 indra/newview/llscenemonitor.cpp | 41 +++++++++++++++++++++++++++++++++++++---
 indra/newview/llscenemonitor.h   | 11 +++++++++++
 3 files changed, 58 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0cb7c7b030..fb1ef3ff3b 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -97,6 +97,7 @@
 #include "llcallfloater.h"
 #include "llfloatertexturefetchdebugger.h"
 #include "llspellcheck.h"
+#include "llscenemonitor.h"
 
 // Linden library includes
 #include "llavatarnamecache.h"
@@ -1561,6 +1562,14 @@ bool LLAppViewer::cleanup()
 	// workaround for DEV-35406 crash on shutdown
 	LLEventPumps::instance().reset();
 
+	//dump scene loading monitor results
+	if(LLSceneMonitor::getInstance()->hasResults())
+	{
+		std::string file_name = "scene_monitor_results.csv";
+		LLSceneMonitor::getInstance()->dumpToFile(
+			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, file_name));
+	}
+
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
 		llinfos << "Analyzing performance" << llendl;
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 0145f6f37e..5cde573855 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -486,11 +486,46 @@ void LLSceneMonitor::fetchQueryResult()
 
 	if(mDiffResult > 0.01f)
 	{
-		mRecording->extend();
-		sample(sFramePixelDiff, mDiffResult);
+		addMonitorResult();
 	}
-	//llinfos << count << " : " << mDiffResult << llendl;
 }
+
+void LLSceneMonitor::addMonitorResult()
+{
+	mRecording->extend();
+	sample(sFramePixelDiff, mDiffResult);
+
+	ll_monitor_result_t result;
+	result.mTimeStamp = LLImageGL::sLastFrameTime;
+	result.mDiff = mDiffResult;
+	mMonitorResults.push_back(result);
+}
+
+//dump results to a file _scene_monitor_results.csv
+void LLSceneMonitor::dumpToFile(std::string file_name)
+{
+	if(mMonitorResults.empty())
+	{
+		return; //nothing to dump
+	}
+
+	std::ofstream os(file_name.c_str());
+
+	//total scene loading time
+	os << llformat("Scene Loading time: %.4f seconds\n", (F32)getRecording()->getAcceptedRecording().getDuration().value());
+
+	S32 num_results = mMonitorResults.size();
+	for(S32 i = 0; i < num_results; i++)
+	{
+		os << llformat("%.4f %.4f\n", mMonitorResults[i].mTimeStamp, mMonitorResults[i].mDiff);
+	}
+
+	os.flush();
+	os.close();
+
+	mMonitorResults.clear();
+}
+
 //-------------------------------------------------------------------------------------------------------------
 //definition of class LLSceneMonitorView
 //-------------------------------------------------------------------------------------------------------------
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 709650e206..b2bc4763cf 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -64,6 +64,8 @@ public:
 	bool needsUpdate() const;
 	
 	LLTrace::ExtendableRecording* getRecording() const {return mRecording;}
+	void dumpToFile(std::string file_name);
+	bool hasResults() const { return !mMonitorResults.empty();}
 
 private:
 	void freezeScene();
@@ -72,6 +74,7 @@ private:
 	bool preCapture();
 	void generateDitheringTexture(S32 width, S32 height);
 
+	void addMonitorResult();
 private:
 	BOOL mEnabled;
 	BOOL mNeedsUpdateDiff;
@@ -99,6 +102,14 @@ private:
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
 
 	LLTrace::ExtendableRecording* mRecording;
+
+	//---------------------------------------
+	typedef struct _monitor_result
+	{
+		F32 mTimeStamp;
+		F32 mDiff;
+	} ll_monitor_result_t;
+	std::vector<ll_monitor_result_t> mMonitorResults;
 };
 
 class LLSceneMonitorView : public LLFloater
-- 
cgit v1.2.3


From 5334c15852b0669be74546d4fa11c58a279dda2d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 28 Mar 2013 16:31:49 -0600
Subject: change scene loading monitor frame diff filter threshold value.

---
 indra/newview/llscenemonitor.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 5cde573855..8655aa4521 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -483,15 +483,18 @@ void LLSceneMonitor::fetchQueryResult()
 	glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count);
 	
 	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
-
-	if(mDiffResult > 0.01f)
-	{
-		addMonitorResult();
-	}
+	
+	addMonitorResult();
 }
 
 void LLSceneMonitor::addMonitorResult()
 {
+	const F32 diff_threshold = 0.001f;
+	if(mDiffResult < diff_threshold)
+	{
+		return;
+	}
+
 	mRecording->extend();
 	sample(sFramePixelDiff, mDiffResult);
 
-- 
cgit v1.2.3


From 7a33d88886d9f9d83d3d12c95bb41e0093159d58 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 28 Mar 2013 16:52:36 -0600
Subject: freeze particle system when monitor scene loading

---
 indra/newview/llscenemonitor.cpp  |  9 +++++++++
 indra/newview/llviewerpartsim.cpp | 14 ++++++++++++++
 indra/newview/llviewerpartsim.h   |  2 ++
 3 files changed, 25 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 8655aa4521..afb03ff268 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -39,6 +39,7 @@
 #include "llspatialpartition.h"
 #include "llagent.h"
 #include "pipeline.h"
+#include "llviewerpartsim.h"
 
 LLSceneMonitorView* gSceneMonitorView = NULL;
 
@@ -273,8 +274,12 @@ void LLSceneMonitor::freezeScene()
 	// freeze everything else
 	gSavedSettings.setBOOL("FreezeTime", TRUE);
 
+	//disable sky, water and clouds
 	gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, 
 		LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES);
+
+	//disable particle system
+	LLViewerPartSim::getInstance()->enable(false);
 }
 
 void LLSceneMonitor::unfreezeScene()
@@ -285,8 +290,12 @@ void LLSceneMonitor::unfreezeScene()
 	// thaw everything else
 	gSavedSettings.setBOOL("FreezeTime", FALSE);
 
+	//enable sky, water and clouds
 	gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_SKY, LLPipeline::RENDER_TYPE_WL_SKY, 
 		LLPipeline::RENDER_TYPE_WATER, LLPipeline::RENDER_TYPE_CLOUDS, LLPipeline::END_RENDER_TYPES);
+
+	//enable particle system
+	LLViewerPartSim::getInstance()->enable(true);
 }
 
 void LLSceneMonitor::capture()
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 8acdc08b00..a23a15da32 100644
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -467,6 +467,20 @@ LLViewerPartSim::LLViewerPartSim()
 	mID = ++id_seed;
 }
 
+//enable/disable particle system
+void LLViewerPartSim::enable(bool enabled)
+{
+	if(!enabled && sMaxParticleCount > 0)
+	{
+		sMaxParticleCount = 0; //disable
+	}
+	else if(enabled && sMaxParticleCount < 1)
+	{
+		sMaxParticleCount = llmin(gSavedSettings.getS32("RenderMaxPartCount"), LL_MAX_PARTICLE_COUNT);
+	}
+
+	return;
+}
 
 void LLViewerPartSim::destroyClass()
 {
diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h
index c91fcf0691..27bfcd4343 100644
--- a/indra/newview/llviewerpartsim.h
+++ b/indra/newview/llviewerpartsim.h
@@ -134,6 +134,8 @@ public:
 	typedef std::vector<LLViewerPartGroup *> group_list_t;
 	typedef std::vector<LLPointer<LLViewerPartSource> > source_list_t;
 
+	void enable(bool enabled);
+
 	void shift(const LLVector3 &offset);
 
 	void updateSimulation();
-- 
cgit v1.2.3


From 51e5997bd6f7f7d66a5843cf1d0b749b143460a8 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 29 Mar 2013 17:54:04 -0600
Subject: delay removing invalid objects from cache in case region is logged
 out too soon.

---
 indra/newview/llviewerregion.cpp | 9 +++++----
 indra/newview/llviewerregion.h   | 1 +
 indra/newview/llvocache.cpp      | 4 ++--
 indra/newview/llvocache.h        | 2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index d8f9ecf248..ed67d50dfd 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -460,11 +460,10 @@ void LLViewerRegion::saveObjectCache()
 
 	if(LLVOCache::hasInstance())
 	{
-		//NOTE: !!!!!!!!!!
-		//set this to be true when support full region cache probe!!!!
-		BOOL full_region_cache_probe = FALSE;
+		const F32 start_time_threshold = 600.0f; //seconds
+		bool removal_enabled = mRegionTimer.getElapsedTimeF32() > start_time_threshold; //allow to remove invalid objects from object cache file.
 
-		LLVOCache::getInstance()->writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, full_region_cache_probe) ;
+		LLVOCache::getInstance()->writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled) ;
 		mCacheDirty = FALSE;
 	}
 
@@ -2176,6 +2175,8 @@ void LLViewerRegion::unpackRegionHandshake()
 	}
 	msg->addU32("Flags", flags );
 	msg->sendReliable(host);
+
+	mRegionTimer.reset(); //reset region timer.
 }
 
 void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 22936fb103..2248cf5269 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -399,6 +399,7 @@ public:
 	static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
 private:
 	LLViewerRegionImpl * mImpl;
+	LLFrameTimer         mRegionTimer;
 
 	F32			mWidth;			// Width of region on a side (meters)
 	U64			mHandle;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index a08e01784c..caa87eb1eb 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -906,7 +906,7 @@ void LLVOCache::purgeEntries(U32 size)
 	mNumEntries = mHandleEntryMap.size() ;
 }
 
-void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, BOOL full_region_cache_probe) 
+void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled) 
 {
 	if(!mEnabled)
 	{
@@ -979,7 +979,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 	
 			for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter)
 			{
-				if(!full_region_cache_probe || iter->second->isTouched())
+				if(!removal_enabled || iter->second->isTouched())
 				{
 					success = iter->second->writeToFile(&apr_file) ;
 				}
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index c26bebb451..5f2dd63051 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -202,7 +202,7 @@ public:
 	void removeCache(ELLPath location, bool started = false) ;
 
 	void readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) ;
-	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, BOOL full_region_cache_probe);
+	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled);
 	void removeEntry(U64 handle) ;
 
 	void setReadOnly(BOOL read_only) {mReadOnly = read_only;} 
-- 
cgit v1.2.3


From da02b9f69471baa407188e2921b5c56c9b8d9415 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 29 Mar 2013 17:54:55 -0600
Subject: save cache file when first login to a region.

---
 indra/newview/llviewerregion.cpp | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index ed67d50dfd..64cf33a9eb 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -442,6 +442,10 @@ void LLViewerRegion::loadObjectCache()
 	if(LLVOCache::hasInstance())
 	{
 		LLVOCache::getInstance()->readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ;
+		if (mImpl->mCacheMap.empty())
+		{
+			mCacheDirty = TRUE;
+		}
 	}
 }
 
-- 
cgit v1.2.3


From 449222f5f0dbe2a4bd5cbc397298c02a3f3348b0 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 1 Apr 2013 13:44:08 -0600
Subject: trivial: convert to unix line endings.

---
 indra/newview/llviewerregion.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 64cf33a9eb..bed047ff0b 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -442,9 +442,9 @@ void LLViewerRegion::loadObjectCache()
 	if(LLVOCache::hasInstance())
 	{
 		LLVOCache::getInstance()->readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ;
-		if (mImpl->mCacheMap.empty())
-		{
-			mCacheDirty = TRUE;
+		if (mImpl->mCacheMap.empty())
+		{
+			mCacheDirty = TRUE;
 		}
 	}
 }
-- 
cgit v1.2.3


From 2bc378c7f4f4356d444f175cc47708bb452c0d2c Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 4 Apr 2013 15:27:00 -0600
Subject: for SH-4053: interesting: visible objects are delayed to appear with
 new interest list

---
 indra/newview/llvieweroctree.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index cfa24c32ed..3c7c710825 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -528,7 +528,7 @@ void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNo
 
 	unbound();
 	
-	//((LLviewerOctreeGroup*)child->getListener(0))->unbound();
+	((LLviewerOctreeGroup*)child->getListener(0))->unbound();
 }
 	
 //virtual 
-- 
cgit v1.2.3


From b4967dfa4f3817c890644cb9a545264b65fd747a Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 4 Apr 2013 15:48:15 -0600
Subject: add debug code for LLViewerOctree

---
 indra/newview/llvieweroctree.cpp | 44 ++++++++++++++++++++++++++++++++++++++++
 indra/newview/llvieweroctree.h   | 11 ++++++++++
 2 files changed, 55 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 3c7c710825..158fc4b0a9 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -32,6 +32,7 @@
 //static variables definitions
 //-----------------------------------------------------------------------------------
 U32 LLViewerOctreeEntryData::sCurVisible = 0;
+BOOL LLViewerOctreeDebug::sInDebug = FALSE;
 
 //-----------------------------------------------------------------------------------
 //some global functions definitions
@@ -798,3 +799,46 @@ void LLViewerOctreeCull::visit(const OctreeNode* branch)
 	}
 }
 
+//--------------------------------------------------------------
+//class LLViewerOctreeDebug
+//virtual 
+void LLViewerOctreeDebug::visit(const OctreeNode* branch)
+{
+#if 0
+	llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl;
+	for (U32 i = 0; i < branch->getChildCount(); i++)
+	{
+		llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl;
+	}
+#endif
+	LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0);
+	processGroup(group);	
+}
+
+//virtual 
+void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group)
+{
+#if 0
+	const LLVector4a* vec4 = group->getBounds();
+	LLVector3 vec[2];
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl;
+
+	vec4 = group->getExtents();
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl;
+
+	vec4 = group->getObjectBounds();
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl;
+
+	vec4 = group->getObjectExtents();
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl;
+#endif
+}
+//--------------------------------------------------------------
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index a35c551949..21cc934d77 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -324,4 +324,15 @@ protected:
 	S32 mRes;
 };
 
+//scan the octree, output the info of each node for debug use.
+class LLViewerOctreeDebug : public OctreeTraveler
+{
+public:
+	virtual void processGroup(LLviewerOctreeGroup* group);
+	virtual void visit(const OctreeNode* branch);
+
+public:
+	static BOOL sInDebug;
+};
+
 #endif
-- 
cgit v1.2.3


From 164273afbb8131c5961266b7cb2c1e1d7973ea0b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 4 Apr 2013 16:47:36 -0600
Subject: fix some warnings caused by scenen loading monitoring when quit
 viewer.

---
 indra/newview/llscenemonitor.cpp | 7 +++++++
 indra/newview/llscenemonitor.h   | 1 +
 2 files changed, 8 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index afb03ff268..3a2171a014 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -65,6 +65,7 @@ LLSceneMonitor::LLSceneMonitor() :
 	mHasNewDiff(FALSE),
 	mHasNewQueryResult(FALSE),
 	mDebugViewerVisible(FALSE),
+	mQuitting(FALSE),
 	mQueryObject(0),
 	mSamplingTime(1.0f),
 	mDiffPixelRatio(0.5f)
@@ -78,6 +79,7 @@ LLSceneMonitor::LLSceneMonitor() :
 
 LLSceneMonitor::~LLSceneMonitor()
 {
+	mQuitting = TRUE;
 	destroyClass();
 }
 
@@ -287,6 +289,11 @@ void LLSceneMonitor::unfreezeScene()
 	//thaw all avatars
 	mAvatarPauseHandles.clear();
 
+	if(mQuitting)
+	{
+		return; //we are quitting viewer.
+	}
+
 	// thaw everything else
 	gSavedSettings.setBOOL("FreezeTime", FALSE);
 
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index b2bc4763cf..c897b237b6 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -81,6 +81,7 @@ private:
 	BOOL mHasNewDiff;
 	BOOL mHasNewQueryResult;
 	BOOL mDebugViewerVisible;
+	BOOL mQuitting;
 
 	LLRenderTarget* mFrames[2];
 	LLRenderTarget* mDiff;
-- 
cgit v1.2.3


From 446849f23c06ab2bda5333ba31e22bd09f1083fb Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 10 Apr 2013 11:32:33 -0600
Subject: trivial: convert to unix line endings.

---
 indra/newview/llvieweroctree.cpp | 86 ++++++++++++++++++++--------------------
 1 file changed, 43 insertions(+), 43 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 158fc4b0a9..926d791d1f 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -799,46 +799,46 @@ void LLViewerOctreeCull::visit(const OctreeNode* branch)
 	}
 }
 
-//--------------------------------------------------------------
-//class LLViewerOctreeDebug
-//virtual 
-void LLViewerOctreeDebug::visit(const OctreeNode* branch)
-{
-#if 0
-	llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl;
-	for (U32 i = 0; i < branch->getChildCount(); i++)
-	{
-		llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl;
-	}
-#endif
-	LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0);
-	processGroup(group);	
-}
-
-//virtual 
-void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group)
-{
-#if 0
-	const LLVector4a* vec4 = group->getBounds();
-	LLVector3 vec[2];
-	vec[0].set(vec4[0].getF32ptr());
-	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl;
-
-	vec4 = group->getExtents();
-	vec[0].set(vec4[0].getF32ptr());
-	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl;
-
-	vec4 = group->getObjectBounds();
-	vec[0].set(vec4[0].getF32ptr());
-	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl;
-
-	vec4 = group->getObjectExtents();
-	vec[0].set(vec4[0].getF32ptr());
-	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl;
-#endif
-}
-//--------------------------------------------------------------
+//--------------------------------------------------------------
+//class LLViewerOctreeDebug
+//virtual 
+void LLViewerOctreeDebug::visit(const OctreeNode* branch)
+{
+#if 0
+	llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl;
+	for (U32 i = 0; i < branch->getChildCount(); i++)
+	{
+		llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl;
+	}
+#endif
+	LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0);
+	processGroup(group);	
+}
+
+//virtual 
+void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group)
+{
+#if 0
+	const LLVector4a* vec4 = group->getBounds();
+	LLVector3 vec[2];
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl;
+
+	vec4 = group->getExtents();
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl;
+
+	vec4 = group->getObjectBounds();
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl;
+
+	vec4 = group->getObjectExtents();
+	vec[0].set(vec4[0].getF32ptr());
+	vec[1].set(vec4[1].getF32ptr());
+	llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl;
+#endif
+}
+//--------------------------------------------------------------
-- 
cgit v1.2.3


From dd1ad64fc45503ed816824d3631c82eeff22c286 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 10 Apr 2013 11:40:11 -0600
Subject: trivial: convert to unix line endings.

---
 indra/newview/llvieweroctree.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 21cc934d77..b6faf4c7ba 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -324,15 +324,15 @@ protected:
 	S32 mRes;
 };
 
-//scan the octree, output the info of each node for debug use.
-class LLViewerOctreeDebug : public OctreeTraveler
-{
-public:
-	virtual void processGroup(LLviewerOctreeGroup* group);
-	virtual void visit(const OctreeNode* branch);
-
-public:
-	static BOOL sInDebug;
+//scan the octree, output the info of each node for debug use.
+class LLViewerOctreeDebug : public OctreeTraveler
+{
+public:
+	virtual void processGroup(LLviewerOctreeGroup* group);
+	virtual void visit(const OctreeNode* branch);
+
+public:
+	static BOOL sInDebug;
 };
 
 #endif
-- 
cgit v1.2.3


From 7e4c8b94d82680891116bd954289171b8f620bbc Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 10 Apr 2013 20:24:51 -0600
Subject: fix a logout crash

---
 indra/newview/llscenemonitor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index c06d9d2689..15fe77f028 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -523,7 +523,7 @@ void LLSceneMonitor::addMonitorResult()
 //dump results to a file _scene_monitor_results.csv
 void LLSceneMonitor::dumpToFile(std::string file_name)
 {
-	if(mMonitorResults.empty())
+	if(mMonitorResults.empty() || !getRecording())
 	{
 		return; //nothing to dump
 	}
-- 
cgit v1.2.3


From 07ca6fce7c9cffe1b8f215f25bb826fedf57a5b7 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 10 Apr 2013 21:51:56 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 removed PeriodicRecording::getTotalRecording as it was showing up at the top
 on the profiler renamed getPrevRecordingPeriod, etc. to getPrevRecording

---
 indra/newview/llagentcamera.cpp       |  2 +-
 indra/newview/llfasttimerview.cpp     | 16 ++++++++--------
 indra/newview/llfloaterabout.cpp      |  2 +-
 indra/newview/llhudnametag.cpp        |  2 +-
 indra/newview/llviewerstats.cpp       |  7 ++++---
 indra/newview/llviewertexturelist.cpp |  4 +---
 indra/newview/pipeline.cpp            |  2 +-
 7 files changed, 17 insertions(+), 18 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 420220d21a..7c9fbccd7f 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1082,7 +1082,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 	LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot.getWorldRotation();
 	LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot.getWorldRotation();
 
-	if 	(LLTrace::get_frame_recording().getLastRecordingPeriod().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f
+	if 	(LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f
 		&& (root_at * last_at_axis > 0.95f))
 	{
 		LLVector3 vel = gAgentAvatarp->getVelocity();
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 80d845c70e..45ffe56ac1 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -333,7 +333,7 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco
 	}
 	else
 	{
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPrevRecordingPeriod(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecordingPeriod(history_index).getSum(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount()));
 	}
 	return tooltip;
 }
@@ -417,7 +417,7 @@ void LLFastTimerView::draw()
 	printLineStats();
 	LLView::draw();
 		
-	mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecordingPeriod().getSum(FTM_FRAME));
+	mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecording().getSum(FTM_FRAME));
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
 }
@@ -984,7 +984,7 @@ void LLFastTimerView::printLineStats()
 			LLUnit<LLUnits::Seconds, F32> ticks;
 			if (mPrintStats > 0)
 			{
-				ticks = mRecording->getPrevRecordingPeriod(mPrintStats).getSum(*idp);
+				ticks = mRecording->getPrevRecording(mPrintStats).getSum(*idp);
 			}
 			else
 			{
@@ -1096,8 +1096,8 @@ void LLFastTimerView::drawLineGraph()
 			j > 0;
 			j--)
 		{
-			LLUnit<LLUnits::Seconds, F32> time = llmax(mRecording->getPrevRecordingPeriod(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
-			U32 calls = mRecording->getPrevRecordingPeriod(j).getSum(idp->callCount());
+			LLUnit<LLUnits::Seconds, F32> time = llmax(mRecording->getPrevRecording(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
+			U32 calls = mRecording->getPrevRecording(j).getSum(idp->callCount());
 
 			if (alpha == 1.f)
 			{ 
@@ -1197,8 +1197,8 @@ void LLFastTimerView::drawLegend( S32 y )
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
 				S32 hidx = mScrollIndex + mHoverBarIndex;
-				ms = mRecording->getPrevRecordingPeriod(hidx).getSum(*idp);
-				calls = mRecording->getPrevRecordingPeriod(hidx).getSum(idp->callCount());
+				ms = mRecording->getPrevRecording(hidx).getSum(*idp);
+				calls = mRecording->getPrevRecording(hidx).getSum(idp->callCount());
 			}
 			else
 			{
@@ -1455,7 +1455,7 @@ S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::v
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
 	F32 self_time_frame_fraction = history_index == -1
 		? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) 
-		: (mRecording->getPrevRecordingPeriod(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
+		: (mRecording->getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
 
 	S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth());
 	S32 full_width = self_time_width;
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 58701ca3c9..93502daac7 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -296,7 +296,7 @@ LLSD LLFloaterAbout::getInfo()
 
 	if (gPacketsIn > 0)
 	{
-		LLTrace::Recording cur_frame = LLTrace::get_frame_recording().snapshotCurRecordingPeriod();
+		LLTrace::Recording cur_frame = LLTrace::get_frame_recording().snapshotCurRecording();
 		info["PACKETS_LOST"] = cur_frame.getSum(LLStatViewer::PACKETS_LOST);
 		info["PACKETS_IN"] = F32(gPacketsIn);
 		info["PACKETS_PCT"] = 100.f*info["PACKETS_LOST"].asReal() / info["PACKETS_IN"].asReal();
diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index 3ac11f906b..cdfe776589 100644
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -901,7 +901,7 @@ void LLHUDNameTag::updateAll()
 	}
 
 	LLTrace::CountStatHandle<>* camera_vel_stat = LLViewerCamera::getVelocityStat();
-	F32 camera_vel = LLTrace::get_frame_recording().getLastRecordingPeriod().getPerSec(*camera_vel_stat);
+	F32 camera_vel = LLTrace::get_frame_recording().getLastRecording().getPerSec(*camera_vel_stat);
 	if (camera_vel > MAX_STABLE_CAMERA_VELOCITY)
 	{
 		return;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index fa4eb73180..13a005dcbf 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -348,11 +348,12 @@ void update_statistics()
 		sample(LLStatViewer::SIM_PING, LLTrace::Seconds(10));
 	}
 
-	add(LLStatViewer::FPS, 1);
-	if (LLTrace::get_frame_recording().getTotalRecording().getSampleCount(LLStatViewer::FPS))
+	if (LLViewerStats::instance().getRecording().getSum(LLStatViewer::FPS))
 	{
-		sample(LLStatViewer::FPS_SAMPLE, LLTrace::get_frame_recording().getTotalRecording().getPerSec(LLStatViewer::FPS));
+		sample(LLStatViewer::FPS_SAMPLE, LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::FPS));
 	}
+	add(LLStatViewer::FPS, 1);
+
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
 	add(LLStatViewer::LAYERS_KBIT, LLTrace::Bits(layer_bits));
 	add(LLStatViewer::OBJECT_KBIT, gObjectData);
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 0066c09720..1bb4041bbd 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -617,9 +617,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 	cleared = FALSE;
 
-	LLTrace::Recording& recording = LLTrace::get_frame_recording().getTotalRecording();
-
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(recording.getPerSec(LLStatViewer::TEXTURE_KBIT).value());
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_KBIT).value());
 
 	{
 		using namespace LLStatViewer;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 26ceaf512a..1b5148e560 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -9816,7 +9816,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 	{
 		LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat();
 		F32 fade_amt = gFrameIntervalSeconds.value() 
-			* llmax(LLTrace::get_frame_recording().getLastRecordingPeriod().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecordingPeriod().getDuration().value(), 1.0);
+			* llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0);
 
 		//update shadow targets
 		for (U32 i = 0; i < 2; i++)
-- 
cgit v1.2.3


From 49933aadb1b7044e947575bc377b34826e94fe99 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 11 Apr 2013 06:38:03 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 removed MeanValueType<T>

---
 indra/newview/llviewertexturelist.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 1bb4041bbd..ae677f541b 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -617,7 +617,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 	cleared = FALSE;
 
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_KBIT).value());
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_KBIT));
 
 	{
 		using namespace LLStatViewer;
-- 
cgit v1.2.3


From 81943ecbe53779a226da4bbdf2c8b1ae39eba11b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 11 Apr 2013 11:51:16 -0600
Subject: for SH-4095: add an option to turn off new interest list code

---
 indra/newview/llviewerregion.cpp | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index bed047ff0b..84e9c8ea9a 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -465,8 +465,8 @@ void LLViewerRegion::saveObjectCache()
 	if(LLVOCache::hasInstance())
 	{
 		const F32 start_time_threshold = 600.0f; //seconds
-		bool removal_enabled = mRegionTimer.getElapsedTimeF32() > start_time_threshold; //allow to remove invalid objects from object cache file.
-
+		bool removal_enabled = sVOCacheCullingEnabled && (mRegionTimer.getElapsedTimeF32() > start_time_threshold); //allow to remove invalid objects from object cache file.
+		
 		LLVOCache::getInstance()->writeToCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap, mCacheDirty, removal_enabled) ;
 		mCacheDirty = FALSE;
 	}
@@ -1120,8 +1120,13 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	max_update_time -= update_timer.getElapsedTimeF32();
 	if(max_update_time < 0.f || mImpl->mCacheMap.empty())
 	{
-	return did_update;
-}
+		return did_update;
+	}
+
+	if(!sVOCacheCullingEnabled)
+	{
+		return did_update;
+	}
 
 	sCurRegionp = this;
 
@@ -1704,6 +1709,12 @@ void LLViewerRegion::findOrphans(U32 parent_id)
 
 void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 {
+	if(!sVOCacheCullingEnabled)
+	{
+		gObjectList.processObjectUpdateFromCache(entry, this);
+		return;
+	}
+
 	if(entry != NULL && !entry->getEntry())
 	{
 		entry->setOctreeEntry(NULL);
@@ -1882,12 +1893,17 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
 }
 
 LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id)
+{
+	if(!sVOCacheCullingEnabled)
 	{
+		return NULL;
+	}
+
 	LLVOCacheEntry* entry = getCacheEntry(local_id);
 	removeFromVOCacheTree(entry);
 		
 	return entry;
-	}
+}
 
 LLVOCacheEntry* LLViewerRegion::getCacheEntry(U32 local_id)
 {
@@ -2172,10 +2188,14 @@ void LLViewerRegion::unpackRegionHandshake()
 	msg->addUUID("SessionID", gAgent.getSessionID());
 	msg->nextBlock("RegionInfo");
 
-	U32 flags = 0x00000001; //set the bit 0 to be 1 to ask sim to send all cacheable objects.
-	if(mImpl->mCacheMap.empty())
+	U32 flags = 0;
+	if(sVOCacheCullingEnabled)
 	{
-		flags |= 0x00000002; //set the bit 1 to be 1 to tell sim the cache file is empty, no need to send cache probes.
+		flags = 0x00000001; //set the bit 0 to be 1 to ask sim to send all cacheable objects.
+		if(mImpl->mCacheMap.empty())
+		{
+			flags |= 0x00000002; //set the bit 1 to be 1 to tell sim the cache file is empty, no need to send cache probes.
+		}
 	}
 	msg->addU32("Flags", flags );
 	msg->sendReliable(host);
-- 
cgit v1.2.3


From 1a820f8df90a21a8614b79f3dc973bb7dc903def Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 11 Apr 2013 15:25:04 -0600
Subject: delay removing pre-fetched textures in case the login process is very
 long.

---
 indra/newview/llviewertexturelist.cpp | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 0066c09720..0a81c9deb0 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -60,7 +60,7 @@
 #include "llxuiparser.h"
 #include "lltracerecording.h"
 #include "llviewerdisplay.h"
-
+#include "llstartup.h"
 ////////////////////////////////////////////////////////////////////////////
 
 void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
@@ -710,7 +710,17 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 {
 	// Update the decode priority for N images each frame
 	{
-        static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities");         // default: 32
+		F32 lazy_flush_timeout = 30.f; // stop decoding
+		F32 max_inactive_time  = 20.f; // actually delete
+		S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference
+		if(LLStartUp::getStartupState() < STATE_STARTED)
+		{
+			//do not remove pre-fetched images if viewer does not finish logging in.
+			lazy_flush_timeout = 30000.f;
+			max_inactive_time = 20000.f;
+		}
+        
+		static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities");         // default: 32
 		const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds.value()) + 1, MAX_PRIO_UPDATES);
 		S32 update_counter = llmin(max_update_count, mUUIDMap.size());
 		uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateUUID);
@@ -732,15 +742,11 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 
 			//
 			// Flush formatted images using a lazy flush
-			//
-			const F32 LAZY_FLUSH_TIMEOUT = 30.f; // stop decoding
-			const F32 MAX_INACTIVE_TIME  = 20.f; // actually delete
-			S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference
-			
+			//						
 			S32 num_refs = imagep->getNumRefs();
 			if (num_refs == min_refs)
 			{
-				if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > LAZY_FLUSH_TIMEOUT)
+				if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > lazy_flush_timeout)
 				{
 					// Remove the unused image from the image list
 					deleteImage(imagep);
@@ -752,7 +758,7 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 			{
 				if(imagep->hasSavedRawImage())
 				{
-					if(imagep->getElapsedLastReferencedSavedRawImageTime() > MAX_INACTIVE_TIME)
+					if(imagep->getElapsedLastReferencedSavedRawImageTime() > max_inactive_time)
 					{
 						imagep->destroySavedRawImage() ;
 					}
@@ -769,7 +775,7 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 				}
 				else if(imagep->isInactive())
 				{
-					if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > MAX_INACTIVE_TIME)
+					if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > max_inactive_time)
 					{
 						imagep->setDeletionCandidate() ;
 					}
-- 
cgit v1.2.3


From c05fa390dc57b072da4b69b4e08743fd62bf4ce5 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 11 Apr 2013 15:25:35 -0600
Subject: add LLTrace::MemTrackable to LLVOCachePartition

---
 indra/newview/llvocache.cpp | 2 ++
 indra/newview/llvocache.h   | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index caa87eb1eb..1dd149631a 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -34,6 +34,8 @@
 #include "llviewerregion.h"
 #include "pipeline.h"
 
+LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
+
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
 	return apr_file->read(src, n_bytes) == n_bytes ;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 5f2dd63051..4b775a4288 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -147,7 +147,7 @@ protected:
 	BOOL                        mTouched; //if set, this entry is valid, otherwise it is invalid.
 };
 
-class LLVOCachePartition : public LLViewerOctreePartition
+class LLVOCachePartition : public LLViewerOctreePartition, public LLTrace::MemTrackable<LLVOCachePartition>
 {
 public:
 	LLVOCachePartition(LLViewerRegion* regionp);
@@ -155,6 +155,8 @@ public:
 	void addEntry(LLViewerOctreeEntry* entry);
 	void removeEntry(LLViewerOctreeEntry* entry);
 	/*virtual*/ S32 cull(LLCamera &camera);
+
+	static	LLTrace::MemStatHandle	sMemStat;
 };
 
 //
-- 
cgit v1.2.3


From ae028e79872f166db8e514ca3b442c7807d6ebdb Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 11 Apr 2013 19:08:57 -0700
Subject: removed unused data structures

---
 indra/newview/llviewerprecompiledheaders.h | 1 -
 1 file changed, 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index 0316f79973..cafe28356d 100644
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -83,7 +83,6 @@
 #include "llsys.h"
 #include "llthread.h"
 #include "lltimer.h"
-#include "lluuidhashmap.h"
 #include "stdenums.h"
 #include "stdtypes.h"
 #include "timing.h"
-- 
cgit v1.2.3


From bdc6d58b7e84bc81977148995b0028f7420eee65 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 11 Apr 2013 19:12:27 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 added ability to query periodic timer for specific number of periods used
 that to do smaller time averaged window for camera speed

---
 indra/newview/llviewercamera.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index 9ca5f07f35..1f5bdc8589 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -170,7 +170,7 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
 	add(sVelocityStat, dpos);
 	add(sAngularVelocityStat, drot);
 	
-	mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat);
+	mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat, 50);
 	mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat);
 	mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect()));
 
-- 
cgit v1.2.3


From 9b48f536c112dc68f8cbda9870587f0d16b9bc9d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 11 Apr 2013 19:41:36 -0700
Subject: deleted unused .cpp file

---
 indra/newview/lltoastalertpanel.cpp | 1 -
 1 file changed, 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltoastalertpanel.cpp b/indra/newview/lltoastalertpanel.cpp
index 3f75f8da5e..85232f4a0b 100644
--- a/indra/newview/lltoastalertpanel.cpp
+++ b/indra/newview/lltoastalertpanel.cpp
@@ -42,7 +42,6 @@
 #include "lllineeditor.h"
 #include "lluictrlfactory.h"
 #include "llnotifications.h"
-#include "llfunctorregistry.h"
 #include "llrootview.h"
 #include "lltransientfloatermgr.h"
 #include "llviewercontrol.h" // for gSavedSettings
-- 
cgit v1.2.3


From 4687803c8e5371cab2bdf2636397b9043edf0299 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 12 Apr 2013 16:10:21 -0600
Subject: fix the crash for SH-4004: interesting: need debug option to clear
 viewer cache while still logged in

---
 indra/newview/llvocache.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 1dd149631a..f90bddcba9 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -593,7 +593,12 @@ void LLVOCache::removeCache(ELLPath location, bool started)
 
 void LLVOCache::removeCache() 
 {
-	llassert_always(mInitialized) ;
+	if(!mInitialized)
+	{
+		//OK to remove cache even it is not initialized.
+		llwarns << "Object cache is not initialized yet." << llendl;
+	}
+
 	if(mReadOnly)
 	{
 		llwarns << "Not clearing object cache: Cache is currently in read-only mode." << llendl;
-- 
cgit v1.2.3


From a904e7b21b64a87073a446445de46318832d1eb1 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 12 Apr 2013 15:25:34 -0700
Subject: converted #define guarded log spam to use keyword-controlled logging

---
 indra/newview/llviewerobjectlist.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index b26be5bc63..dde387509a 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -2067,7 +2067,7 @@ S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const
 void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port)
 {
 #ifdef ORPHAN_SPAM
-	llinfos << "Orphaning object " << childp->getID() << " with parent " << parent_id << llendl;
+	LL_DEBUGS("ORPHANS") << "Orphaning object " << childp->getID() << " with parent " << parent_id << llendl;
 #endif
 
 	// We're an orphan, flag things appropriately.
-- 
cgit v1.2.3


From 39d8ea6327ad96b4977dfec991a20d66e2442b50 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 12 Apr 2013 15:55:34 -0700
Subject: BUILDFIX: attempted gcc fix

---
 indra/newview/llviewerobjectlist.cpp | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index dde387509a..04c9fc2f94 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -2066,9 +2066,7 @@ S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const
 
 void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port)
 {
-#ifdef ORPHAN_SPAM
-	LL_DEBUGS("ORPHANS") << "Orphaning object " << childp->getID() << " with parent " << parent_id << llendl;
-#endif
+	LL_DEBUGS("ORPHANS") << "Orphaning object " << childp->getID() << " with parent " << parent_id << LL_ENDL;
 
 	// We're an orphan, flag things appropriately.
 	childp->mOrphaned = TRUE;
@@ -2156,11 +2154,11 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 				continue;
 			}
 
+			LL_DEBUGS("ORPHANS") << "Reunited parent " << objectp->mID 
+				<< " with child " << childp->mID << LL_ENDL;
+			LL_DEBUGS("ORPHANS") << "Glob: " << objectp->getPositionGlobal() << LL_ENDL;
+			LL_DEBUGS("ORPHANS") << "Agent: " << objectp->getPositionAgent() << LL_ENDL;
 #ifdef ORPHAN_SPAM
-			llinfos << "Reunited parent " << objectp->mID 
-				<< " with child " << childp->mID << llendl;
-			llinfos << "Glob: " << objectp->getPositionGlobal() << llendl;
-			llinfos << "Agent: " << objectp->getPositionAgent() << llendl;
 			addDebugBeacon(objectp->getPositionAgent(),"");
 #endif
 			gPipeline.markMoved(objectp->mDrawable);				
-- 
cgit v1.2.3


From 674df12bc9e81b9b4290f74a96116dbbf1e7f77c Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 17 Apr 2013 23:00:36 -0600
Subject: for SH-4105: interesting: new viewer does not handle orphaned child
 prims in ObjectUpdateCompressed messages

---
 indra/newview/llviewerobject.cpp |  10 ++--
 indra/newview/llviewerregion.cpp | 105 ++++++++++++++-------------------------
 indra/newview/llviewerregion.h   |  30 ++---------
 indra/newview/llvocache.cpp      |   8 ---
 indra/newview/llvocache.h        |   3 +-
 5 files changed, 48 insertions(+), 108 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index d5d804bc57..ef28c3ad53 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -995,7 +995,13 @@ U32 LLViewerObject::checkMediaURL(const std::string &media_url)
 U32 LLViewerObject::extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector3& pos, LLVector3& scale, LLQuaternion& rot)
 {
 	U32	parent_id = 0;
-	
+	LLViewerObject::unpackParentID(dp, parent_id);
+	if(parent_id > 0)
+	{
+		//is a child, no need to decode further.
+		return parent_id;
+	}
+
 	LLViewerObject::unpackVector3(dp, scale, "Scale");
 	LLViewerObject::unpackVector3(dp, pos, "Pos");
 	
@@ -1003,8 +1009,6 @@ U32 LLViewerObject::extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector
 	LLViewerObject::unpackVector3(dp, vec, "Rot");
 	rot.unpackFromVector3(vec);
 	
-	LLViewerObject::unpackParentID(dp, parent_id);
-	
 	return parent_id;
 }
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 84e9c8ea9a..a2ff232d02 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1020,11 +1020,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		{
 			++iter;
 		}
-
-		//if(update_timer.getElapsedTimeF32() > max_time)
-		//{
-		//	break;
-		//}
 	}
 #endif
 
@@ -1046,24 +1041,14 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 				if(vo_entry->getParentID() > 0) //is a child
 				{
-					LLVOCacheEntry* parent = getCacheEntry(vo_entry->getParentID());
-					
-					//make sure the parent is active
-					if(!parent || !parent->isState(LLVOCacheEntry::ACTIVE))
-					{
-						continue;
-					}
+					//child visibility depends on its parent.
+					continue;
 				}
 
 				vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);				
 				mImpl->mWaitingList.insert(vo_entry);
 			}
 		}
-
-		//if(update_timer.getElapsedTimeF32() > max_time)
-		//{
-		//	break;
-		//}
 	}
 	mImpl->mVisibleGroups.clear();
 
@@ -1145,6 +1130,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 
 F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 {
+#if 1
 	if(!sVOCacheCullingEnabled)
 	{
 		return max_time;
@@ -1164,7 +1150,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 		gObjectList.killObject(delete_list[i]->getVObj());
 	}
 	delete_list.clear();
-
+#endif
 	return max_time;
 }
 
@@ -1694,15 +1680,15 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features)
 //move all orphan children out of cache and insert to rendering octree.
 void LLViewerRegion::findOrphans(U32 parent_id)
 {
-	std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(parent_id);
+	orphan_list_t::iterator iter = mOrphanMap.find(parent_id);
 	if(iter != mOrphanMap.end())
 	{
-		std::set<U32>* children = mOrphanMap[parent_id].getChildList();
-		for(std::set<U32>::iterator child_iter = children->begin(); child_iter != children->end(); ++child_iter)
+		std::vector<U32>* children = &mOrphanMap[parent_id];
+		for(S32 i = 0; i < children->size(); i++)
 		{
-			forceToRemoveFromCache(*child_iter, NULL);
+			forceToRemoveFromCache((*children)[i], NULL);
 		}
-			
+		children->clear();
 		mOrphanMap.erase(parent_id);
 	}
 }
@@ -1727,58 +1713,42 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 	LLVector3 pos;
 	LLVector3 scale;
 	LLQuaternion rot;
+
+	//decode spatial info and parent info
 	U32 parent_id = LLViewerObject::extractSpatialExtents(entry->getDP(), pos, scale, rot);
 	
-	entry->setBoundingInfo(pos, scale);
-	
 	if(parent_id > 0) //has parent
 	{
 		entry->setParentID(parent_id);
 	
-		//1, find parent, update position
+		//1, find the parent in cache
 		LLVOCacheEntry* parent = getCacheEntry(parent_id);
 		
-		//2, if can not, put into the orphan list.
-		if(!parent || !parent->getGroup())
+		//2, parent is not in the cache, put into the orphan list.
+		if(!parent)
 		{
-			std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(parent_id);
-			if(iter != mOrphanMap.end())
+			mOrphanMap[parent_id].push_back(entry->getLocalID());
+		}
+		else //parent in cache
+		{
+			if(!parent->isState(LLVOCacheEntry::INACTIVE)) 
 			{
-				iter->second.addChild(entry->getLocalID());
+				//parent is visible, so is the child.
+				addVisibleCacheEntry(entry);
 			}
-			else 
+			else
 			{
-				//check if the parent is an uncacheable object
-				if(!parent)
-				{
-					LLUUID parent_uuid;
-					LLViewerObjectList::getUUIDFromLocal(parent_uuid,
-															parent_id,
-															getHost().getAddress(),
-															getHost().getPort());
-					LLViewerObject *parent_objp = gObjectList.findObject(parent_uuid);
-					if(parent_objp)
-					{
-						//parent is not cacheable, remove child from the cache.
-						forceToRemoveFromCache(entry->getLocalID(), NULL);
-						return;
-					}
-				}
-
-				//otherwise insert to the orphan list
-				OrphanList o_list(entry->getLocalID());
-				mOrphanMap[parent_id] = o_list;
+				parent->addChild(entry);
 			}
-			
-			return;
-		}
-		else
-		{
-			//update the child position to the region space.
-			entry->updateBoundingInfo(parent);
 		}
+
+		return;
 	}
 	
+	//
+	//no parent
+	//
+	entry->setBoundingInfo(pos, scale);
 	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
 	{
 		addToVOCacheTree(entry);
@@ -1787,21 +1757,20 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 	if(!parent_id) //a potential parent
 	{
 		//find all children and update their bounding info
-		std::map<U32, OrphanList>::iterator iter = mOrphanMap.find(entry->getLocalID());
+		orphan_list_t::iterator iter = mOrphanMap.find(entry->getLocalID());
 		if(iter != mOrphanMap.end())
-		{
-			std::set<U32>* children = mOrphanMap[parent_id].getChildList();
-			for(std::set<U32>::iterator child_iter = children->begin(); child_iter != children->end(); ++child_iter)
+		{			
+			std::vector<U32>* orphans = &mOrphanMap[entry->getLocalID()];
+			S32 size = orphans->size();
+			for(S32 i = 0; i < size; i++)
 			{
-				LLVOCacheEntry* child = getCacheEntry(*child_iter);
+				LLVOCacheEntry* child = getCacheEntry((*orphans)[i]);
 				if(child)
 				{
-					//update the child position to the region space.
-					child->updateBoundingInfo(entry);
-					addToVOCacheTree(child);
+					entry->addChild(child);
 				}
 			}
-			
+			orphans->clear();
 			mOrphanMap.erase(entry->getLocalID());
 		}
 	}
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 2248cf5269..410c903f18 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -447,21 +447,9 @@ private:
 	BOOL	mCapabilitiesReceived;
 	BOOL    mReleaseNotesRequested;
 	BOOL    mDead;  //if true, this region is in the process of deleting.
-
-	class OrphanList
-	{
-	public:
-		OrphanList(){}
-		OrphanList(U32 child_id){addChild(child_id);}
-		
-		void addChild(U32 child_id) {mChildList.insert(child_id);}
-		std::set<U32>* getChildList() {return &mChildList;}
-		
-	private:
-		std::set<U32> mChildList;
-	};
 	
-	std::map<U32, OrphanList> mOrphanMap;
+	typedef std::map<U32, std::vector<U32> > orphan_list_t;
+	orphan_list_t mOrphanMap;
 	
 	class CacheMissItem
 	{
@@ -471,21 +459,9 @@ private:
 		U32                            mID;     //local object id
 		LLViewerRegion::eCacheMissType mType;   //cache miss type
 	
-#if 0
-		struct Compare
-		{
-			bool operator()(const CacheMissItem& lhs, const CacheMissItem& rhs)
-			{
-				return lhs.mID < rhs.mID; //smaller ID first.
-			}
-		};
-
-		typedef std::set<CacheMissItem, Compare> cache_miss_list_t;
-#else
 		typedef std::list<CacheMissItem> cache_miss_list_t;
-#endif
 	};
-	CacheMissItem::cache_miss_list_t        mCacheMissList;
+	CacheMissItem::cache_miss_list_t   mCacheMissList;
 	
 	caps_received_signal_t mCapabilitiesReceivedSignal;		
 	LLSD mSimulatorFeatures;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index f90bddcba9..eba768fef4 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -367,14 +367,6 @@ void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scal
 	setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f));
 }
 
-void LLVOCacheEntry::updateBoundingInfo(LLVOCacheEntry* parent)
-{
-	//LLVector4a old_pos = getPositionGroup();
-	//parent->getPositionRegion() + (getPosition() * parent->getRotation());
-	
-	shift(parent->getPositionGroup());
-}
-
 //-------------------------------------------------------------------
 //LLVOCachePartition
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 4b775a4288..2aec88537c 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -114,8 +114,7 @@ public:
 
 	//called from processing object update message
 	void setBoundingInfo(const LLVector3& pos, const LLVector3& scale);
-	void updateBoundingInfo(LLVOCacheEntry* parent);
-
+	
 	void setTouched(BOOL touched = TRUE) {mTouched = touched;}
 	BOOL isTouched() const {return mTouched;}
 	
-- 
cgit v1.2.3


From c978364e1eec987c70769e66d3b9342b321acbc4 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 22 Apr 2013 22:11:41 -0600
Subject: for SH-4133: create a debug tool to show textures in active fetching

---
 indra/newview/llviewertexture.cpp | 29 +++++++++++++++++++++++++++++
 indra/newview/llviewertexture.h   |  7 ++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 7edfa6adfa..12835002d3 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -698,6 +698,28 @@ void LLViewerTexture::setBoostLevel(S32 level)
 
 }
 
+bool LLViewerTexture::isActiveFetching()
+{
+	return false;
+}
+
+bool LLViewerTexture::bindDebugImage(const S32 stage)
+{
+	if (stage < 0) return false;
+
+	bool res = true;
+	if (LLViewerTexture::sCheckerBoardImagep.notNull() && (this != LLViewerTexture::sCheckerBoardImagep.get()))
+	{
+		res = gGL.getTexUnit(stage)->bind(LLViewerTexture::sCheckerBoardImagep);
+	}
+
+	if(!res)
+	{
+		return bindDefaultImage(stage);
+	}
+
+	return res;
+}
 
 bool LLViewerTexture::bindDefaultImage(S32 stage) 
 {
@@ -1990,6 +2012,13 @@ bool LLViewerFetchedTexture::setDebugFetching(S32 debug_level)
 	return true;
 }
 
+bool LLViewerFetchedTexture::isActiveFetching()
+{
+	static LLCachedControl<bool> monitor_enabled(gSavedSettings,"DebugShowTextureInfo");
+
+	return mFetchState > 7 && mFetchState < 10 && monitor_enabled; //in state of WAIT_HTTP_REQ or DECODE_IMAGE.
+}
+
 bool LLViewerFetchedTexture::updateFetch()
 {
 	static LLCachedControl<bool> textures_decode_disabled(gSavedSettings,"TextureDecodeDisabled");
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 0a9778ce76..d69a0ffb72 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -167,8 +167,10 @@ public:
 	virtual void dump();	// debug info to llinfos
 	
 	/*virtual*/ bool bindDefaultImage(const S32 stage = 0) ;
+	/*virtual*/ bool bindDebugImage(const S32 stage = 0) ;
 	/*virtual*/ void forceImmediateUpdate() ;
-	
+	/*virtual*/ bool isActiveFetching();
+
 	const LLUUID& getID() const { return mID; }
 	
 	void setBoostLevel(S32 level);
@@ -506,6 +508,9 @@ public:
 	void        loadFromFastCache();
 	void        setInFastCacheList(bool in_list) { mInFastCacheList = in_list; }
 	bool        isInFastCacheList() { return mInFastCacheList; }
+
+	/*virtual*/bool  isActiveFetching(); //is actively in fetching by the fetching pipeline.
+
 protected:
 	/*virtual*/ void switchToCachedImage();
 	S32 getCurrentDiscardLevelForFetching() ;
-- 
cgit v1.2.3


From c6737163854981d94fde8bdd440eaf4bbc816b4f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 23 Apr 2013 18:52:34 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 convert scene monitor to use extendable periodic recording

---
 indra/newview/llscenemonitor.cpp | 2 +-
 indra/newview/llscenemonitor.h   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 15fe77f028..7f7e61cc88 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -73,7 +73,7 @@ LLSceneMonitor::LLSceneMonitor() :
 	mFrames[0] = NULL;
 	mFrames[1] = NULL;
 
-	mRecording = new LLTrace::ExtendableRecording();
+	mRecording = new LLTrace::ExtendablePeriodicRecording();
 	mRecording->start();
 }
 
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index c897b237b6..45a5241924 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -63,7 +63,7 @@ public:
 	bool isEnabled()const {return mEnabled;}
 	bool needsUpdate() const;
 	
-	LLTrace::ExtendableRecording* getRecording() const {return mRecording;}
+	LLTrace::ExtendablePeriodicRecording* getRecording() const {return mRecording;}
 	void dumpToFile(std::string file_name);
 	bool hasResults() const { return !mMonitorResults.empty();}
 
@@ -102,7 +102,7 @@ private:
 
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
 
-	LLTrace::ExtendableRecording* mRecording;
+	LLTrace::ExtendablePeriodicRecording* mRecording;
 
 	//---------------------------------------
 	typedef struct _monitor_result
-- 
cgit v1.2.3


From 84af0e9852486231b5ef0cde7ad1704d41689a3a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 24 Apr 2013 14:13:45 -0700
Subject: SH-4080 WIP interesting: random crash on Mac potential fix for
 crasher cleaned up llsingleton

---
 indra/newview/lltoolselect.h        | 2 +-
 indra/newview/llviewertexturelist.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltoolselect.h b/indra/newview/lltoolselect.h
index baa27f6071..74dababe8c 100644
--- a/indra/newview/lltoolselect.h
+++ b/indra/newview/lltoolselect.h
@@ -34,7 +34,7 @@
 
 class LLObjectSelection;
 
-class LLToolSelect : public LLTool, public LLSingleton<LLToolSelect>
+class LLToolSelect : public LLTool
 {
 public:
 	LLToolSelect( LLToolComposite* composite );
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index e3df71cca2..7ce4a8fc70 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -34,6 +34,7 @@
 #include "llui.h"
 #include <list>
 #include <set>
+#include "lluiimage.h"
 
 const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128;
 
-- 
cgit v1.2.3


From 6244679b34bfb450bc83fd1ccd8c765028bb6735 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 1 May 2013 10:57:09 -0600
Subject: performance optimization: only scan 32 objects per frame looking for
 invisibles.

---
 indra/newview/llvieweroctree.cpp |  2 +-
 indra/newview/llviewerregion.cpp | 31 +++++++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 926d791d1f..2acacccbe6 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -524,7 +524,7 @@ void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNo
 	}
 	else
 	{
-		OCT_ERRS << "LLSpatialGroup redundancy detected." << llendl;
+		OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << llendl;
 	}
 
 	unbound();
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index a2ff232d02..57fbaefce3 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1122,7 +1122,6 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	createVisibleObjects(max_update_time);
 
 	mImpl->mVisibleGroups.clear();
-	mImpl->mWaitingList.clear();
 
 	sCurRegionp = NULL;
 	return did_update;
@@ -1135,16 +1134,40 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 	{
 		return max_time;
 	}
+	if(mImpl->mActiveSet.empty())
+	{
+		return max_time;
+	}
+
+	static LLVOCacheEntry* last_visited_entry = NULL;
 
+	const size_t MAX_UPDATE = 32; 
 	std::vector<LLDrawable*> delete_list;
-	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
-		iter != mImpl->mActiveSet.end(); ++iter)
-	{
+	S32 update_counter = llmin(MAX_UPDATE, mImpl->mActiveSet.size());
+	LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(last_visited_entry);	
+	
+	for(; update_counter > 0; --update_counter, ++iter)
+	{	
+		if(iter == mImpl->mActiveSet.end())
+		{
+			iter = mImpl->mActiveSet.begin();
+		}
+
 		if(!(*iter)->isRecentlyVisible())
 		{
 			killObject((*iter), delete_list);
 		}
 	}
+
+	if(iter == mImpl->mActiveSet.end())
+	{
+		last_visited_entry = NULL;
+	}
+	else
+	{
+		last_visited_entry = *iter;
+	}
+
 	for(S32 i = 0; i < delete_list.size(); i++)
 	{
 		gObjectList.killObject(delete_list[i]->getVObj());
-- 
cgit v1.2.3


From 34403a6138922da2d97c24b8413e3693ab1d788f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 2 May 2013 13:02:16 -0700
Subject: SH-4080 WIP interesting: random crash on Mac changed sCurCameraID to
 enum in attempt to pinpoint memory stompage

---
 indra/newview/llviewercamera.cpp | 2 +-
 indra/newview/llviewercamera.h   | 2 +-
 indra/newview/pipeline.cpp       | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index 1f5bdc8589..45302ebb74 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -57,7 +57,7 @@
 LLTrace::CountStatHandle<> LLViewerCamera::sVelocityStat("camera_velocity");
 LLTrace::CountStatHandle<> LLViewerCamera::sAngularVelocityStat("camera_angular_velocity");
 
-U32 LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
+LLViewerCamera::eCameraID LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
 
 //glu pick matrix implementation borrowed from Mesa3D
 glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height, GLint* viewport)
diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h
index d7835d8567..7b2887d725 100644
--- a/indra/newview/llviewercamera.h
+++ b/indra/newview/llviewercamera.h
@@ -80,7 +80,7 @@ public:
 		NUM_CAMERAS
 	} eCameraID;
 
-	static U32 sCurCameraID;
+	static eCameraID sCurCameraID;
 
 	LLViewerCamera();
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1b5148e560..acf3e7aa07 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2252,7 +2252,7 @@ BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3&
 	min = LLVector3(X,X,X);
 	max = LLVector3(-X,-X,-X);
 
-	U32 saved_camera_id = LLViewerCamera::sCurCameraID;
+	LLViewerCamera::eCameraID saved_camera_id = LLViewerCamera::sCurCameraID;
 	LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
 
 	BOOL res = TRUE;
@@ -9437,7 +9437,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 				mShadowFrustPoints[j].clear();
 			}
 
-			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+j;
+			LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j);
 
 			//restore render matrices
 			glh_set_current_modelview(saved_view);
@@ -9821,7 +9821,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		//update shadow targets
 		for (U32 i = 0; i < 2; i++)
 		{ //for each current shadow
-			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
+			LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i);
 
 			if (mShadowSpotLight[i].notNull() && 
 				(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
@@ -9940,7 +9940,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 
 			static LLCullResult result[2];
 
-			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
+			LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4);
 
 			renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width);
 
-- 
cgit v1.2.3


From 6b81b8629e67d82a7620e48781ded73b6e6126ea Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sun, 5 May 2013 17:45:35 -0700
Subject: Spring cleaning: removed unused .cpp and.h files, and cleaned up
 header dependencies

---
 indra/newview/llagent.cpp                  |  50 ++++++------
 indra/newview/llagent.h                    |   1 +
 indra/newview/llagentwearables.cpp         |   1 +
 indra/newview/llavatariconctrl.cpp         |   1 +
 indra/newview/llcallingcard.cpp            |  20 ++---
 indra/newview/lldrawable.cpp               |   2 +-
 indra/newview/lldrawable.h                 |   2 +-
 indra/newview/lldrawpoolavatar.cpp         |   4 +-
 indra/newview/llface.h                     |   6 +-
 indra/newview/llfloateravatartextures.cpp  |   1 +
 indra/newview/llgroupiconctrl.cpp          |  12 +--
 indra/newview/llgroupmgr.cpp               |   2 +
 indra/newview/llhudicon.h                  |   3 -
 indra/newview/llhudmanager.h               |   8 +-
 indra/newview/llimfloater.cpp              |   2 +
 indra/newview/llimview.cpp                 |   1 +
 indra/newview/llimview.h                   |   3 +-
 indra/newview/llinspectavatar.cpp          |   2 +
 indra/newview/llinventorybridge.cpp        |   1 +
 indra/newview/llinventoryicon.cpp          |   3 +
 indra/newview/llinventoryicon.h            |   5 +-
 indra/newview/llinventorymodel.h           |   4 +-
 indra/newview/lllocalbitmaps.cpp           |   1 +
 indra/newview/lllocalbitmaps.h             |   2 +
 indra/newview/llpanelclassified.cpp        |   1 +
 indra/newview/llpaneleditwearable.cpp      |   1 +
 indra/newview/llpanelpeople.h              |   1 +
 indra/newview/llpanelprofile.cpp           |   1 +
 indra/newview/llpanelvoiceeffect.cpp       |   1 +
 indra/newview/llspeakers.cpp               |   2 +
 indra/newview/lltexlayer.cpp               |   1 +
 indra/newview/lltoolpie.cpp                |   1 +
 indra/newview/lltoolselect.cpp             |   1 +
 indra/newview/llviewerassetstats.h         |   1 +
 indra/newview/llvieweraudio.cpp            |   1 +
 indra/newview/llviewerjointmesh.cpp        |   1 -
 indra/newview/llviewerjointmesh.h          |   8 --
 indra/newview/llviewerobject.cpp           |   1 +
 indra/newview/llviewerobject.h             |  27 +++----
 indra/newview/llviewerobjectlist.cpp       |   8 ++
 indra/newview/llviewerobjectlist.h         |  10 +--
 indra/newview/llvieweroctree.cpp           |   1 +
 indra/newview/llvieweroctree.h             |   3 -
 indra/newview/llviewerpartsim.h            |   2 -
 indra/newview/llviewerprecompiledheaders.h |   6 --
 indra/newview/llviewerregion.cpp           |  56 +++++++------
 indra/newview/llviewerregion.h             |   1 +
 indra/newview/llviewerwindow.cpp           |   1 +
 indra/newview/llvoavatar.cpp               | 122 ++++++++++++++++-------------
 indra/newview/llvoavatar.h                 |   5 +-
 indra/newview/llvoavatarself.cpp           |   1 +
 indra/newview/llvocache.cpp                |  56 ++++---------
 indra/newview/llvocache.h                  |  20 ++---
 indra/newview/llvoicechannel.cpp           |   2 +
 indra/newview/llvoiceclient.h              |   1 -
 indra/newview/llvoinventorylistener.h      |   4 +-
 indra/newview/llvosurfacepatch.h           |   2 +
 indra/newview/llvovolume.cpp               |   2 +-
 indra/newview/llwearable.h                 |   2 +-
 indra/newview/llworld.cpp                  |   5 +-
 indra/newview/pipeline.h                   |  14 ----
 61 files changed, 232 insertions(+), 278 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 4e60127ef3..2e0fc039c4 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -2852,10 +2852,10 @@ BOOL LLAgent::isInGroup(const LLUUID& group_id, BOOL ignore_god_mode /* FALSE */
 	if (!ignore_god_mode && isGodlike())
 		return true;
 
-	S32 count = mGroups.count();
-	for(S32 i = 0; i < count; ++i)
+	U32 count = mGroups.size();
+	for(U32 i = 0; i < count; ++i)
 	{
-		if(mGroups.get(i).mID == group_id)
+		if(mGroups[i].mID == group_id)
 		{
 			return TRUE;
 		}
@@ -2872,12 +2872,12 @@ BOOL LLAgent::hasPowerInGroup(const LLUUID& group_id, U64 power) const
 	// GP_NO_POWERS can also mean no power is enough to grant an ability.
 	if (GP_NO_POWERS == power) return FALSE;
 
-	S32 count = mGroups.count();
-	for(S32 i = 0; i < count; ++i)
+	U32 count = mGroups.size();
+	for(U32 i = 0; i < count; ++i)
 	{
-		if(mGroups.get(i).mID == group_id)
+		if(mGroups[i].mID == group_id)
 		{
-			return (BOOL)((mGroups.get(i).mPowers & power) > 0);
+			return (BOOL)((mGroups[i].mPowers & power) > 0);
 		}
 	}
 	return FALSE;
@@ -2893,12 +2893,12 @@ U64 LLAgent::getPowerInGroup(const LLUUID& group_id) const
 	if (isGodlike())
 		return GP_ALL_POWERS;
 	
-	S32 count = mGroups.count();
-	for(S32 i = 0; i < count; ++i)
+	U32 count = mGroups.size();
+	for(U32 i = 0; i < count; ++i)
 	{
-		if(mGroups.get(i).mID == group_id)
+		if(mGroups[i].mID == group_id)
 		{
-			return (mGroups.get(i).mPowers);
+			return (mGroups[i].mPowers);
 		}
 	}
 
@@ -2907,12 +2907,12 @@ U64 LLAgent::getPowerInGroup(const LLUUID& group_id) const
 
 BOOL LLAgent::getGroupData(const LLUUID& group_id, LLGroupData& data) const
 {
-	S32 count = mGroups.count();
+	S32 count = mGroups.size();
 	for(S32 i = 0; i < count; ++i)
 	{
-		if(mGroups.get(i).mID == group_id)
+		if(mGroups[i].mID == group_id)
 		{
-			data = mGroups.get(i);
+			data = mGroups[i];
 			return TRUE;
 		}
 	}
@@ -2921,12 +2921,12 @@ BOOL LLAgent::getGroupData(const LLUUID& group_id, LLGroupData& data) const
 
 S32 LLAgent::getGroupContribution(const LLUUID& group_id) const
 {
-	S32 count = mGroups.count();
+	S32 count = mGroups.size();
 	for(S32 i = 0; i < count; ++i)
 	{
-		if(mGroups.get(i).mID == group_id)
+		if(mGroups[i].mID == group_id)
 		{
-			S32 contribution = mGroups.get(i).mContribution;
+			S32 contribution = mGroups[i].mContribution;
 			return contribution;
 		}
 	}
@@ -2935,12 +2935,12 @@ S32 LLAgent::getGroupContribution(const LLUUID& group_id) const
 
 BOOL LLAgent::setGroupContribution(const LLUUID& group_id, S32 contribution)
 {
-	S32 count = mGroups.count();
+	S32 count = mGroups.size();
 	for(S32 i = 0; i < count; ++i)
 	{
-		if(mGroups.get(i).mID == group_id)
+		if(mGroups[i].mID == group_id)
 		{
-			mGroups.get(i).mContribution = contribution;
+			mGroups[i].mContribution = contribution;
 			LLMessageSystem* msg = gMessageSystem;
 			msg->newMessage("SetGroupContribution");
 			msg->nextBlock("AgentData");
@@ -2958,13 +2958,13 @@ BOOL LLAgent::setGroupContribution(const LLUUID& group_id, S32 contribution)
 
 BOOL LLAgent::setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOOL list_in_profile)
 {
-	S32 count = mGroups.count();
+	S32 count = mGroups.size();
 	for(S32 i = 0; i < count; ++i)
 	{
-		if(mGroups.get(i).mID == group_id)
+		if(mGroups[i].mID == group_id)
 		{
-			mGroups.get(i).mAcceptNotices = accept_notices;
-			mGroups.get(i).mListInProfile = list_in_profile;
+			mGroups[i].mAcceptNotices = accept_notices;
+			mGroups[i].mListInProfile = list_in_profile;
 			LLMessageSystem* msg = gMessageSystem;
 			msg->newMessage("SetGroupAcceptNotices");
 			msg->nextBlock("AgentData");
@@ -2984,7 +2984,7 @@ BOOL LLAgent::setUserGroupFlags(const LLUUID& group_id, BOOL accept_notices, BOO
 
 BOOL LLAgent::canJoinGroups() const
 {
-	return mGroups.count() < gMaxAgentGroups;
+	return (S32)mGroups.size() < gMaxAgentGroups;
 }
 
 LLQuaternion LLAgent::getHeadRotation()
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index a1e899b45d..f8dcfb9789 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -34,6 +34,7 @@
 #include "llcharacter.h"
 #include "llcoordframe.h"			// for mFrameAgent
 #include "llvoavatardefines.h"
+#include "lldarray.h"
 
 #include <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index e441f21f90..49e754a720 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -39,6 +39,7 @@
 #include "llinventoryfunctions.h"
 #include "llinventoryobserver.h"
 #include "llinventorypanel.h"
+#include "lllocaltextureobject.h"
 #include "llmd5.h"
 #include "llnotificationsutil.h"
 #include "lloutfitobserver.h"
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index b539ac38ed..5f5bded3ad 100755
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -37,6 +37,7 @@
 #include "lluictrlfactory.h"
 #include "llagentdata.h"
 #include "llimfloater.h"
+#include "llviewertexture.h"
 
 // library includes
 #include "llavatarnamecache.h"
diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp
index 0d55c4429a..c34c09bf87 100644
--- a/indra/newview/llcallingcard.cpp
+++ b/indra/newview/llcallingcard.cpp
@@ -32,13 +32,10 @@
 
 #include "llcallingcard.h"
 
-#include <vector>
 #include <algorithm>
-//#include <iterator>
 
 #include "indra_constants.h"
-#include "llavatarnamecache.h"
-#include "llcachename.h"
+//#include "llcachename.h"
 #include "llstl.h"
 #include "lltimer.h"
 #include "lluuid.h"
@@ -46,18 +43,13 @@
 
 #include "llagent.h"
 #include "llavatarnamecache.h"
-#include "llbutton.h"
 #include "llinventoryobserver.h"
 #include "llinventorymodel.h"
 #include "llnotifications.h"
-#include "llnotificationsutil.h"
-#include "llresmgr.h"
 #include "llslurl.h"
 #include "llimview.h"
 #include "llviewercontrol.h"
-#include "llviewernetwork.h"
 #include "llviewerobjectlist.h"
-#include "llviewerwindow.h"
 #include "llvoavatar.h"
 #include "llavataractions.h"
 
@@ -104,8 +96,6 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id,
 LLAvatarTracker::LLAvatarTracker() :
 	mTrackingData(NULL),
 	mTrackedAgentValid(false),
-	//mInventory(NULL),
-	//mInventoryObserver(NULL),
 	mModifyMask(0x0)	
 {
 }
@@ -639,11 +629,11 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg)
 					payload["from_id"] = agent_id;
 					if(LLRelationship::GRANT_MODIFY_OBJECTS & new_rights)
 					{
-						LLNotificationsUtil::add("GrantedModifyRights",args, payload);
+						LLNotifications::instance().add("GrantedModifyRights",args, payload);
 					}
 					else
 					{
-						LLNotificationsUtil::add("RevokedModifyRights",args, payload);
+						LLNotifications::instance().add("RevokedModifyRights",args, payload);
 					}
 				}
 				(mBuddyInfo[agent_id])->setRightsFrom(new_rights);
@@ -728,7 +718,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id,
 	if (online)
 	{
 		notification =
-			LLNotificationsUtil::add("FriendOnline",
+			LLNotifications::instance().add("FriendOnline",
 									 args,
 									 payload.with("respond_on_mousedown", TRUE),
 									 boost::bind(&LLAvatarActions::startIM, agent_id));
@@ -736,7 +726,7 @@ static void on_avatar_name_cache_notify(const LLUUID& agent_id,
 	else
 	{
 		notification =
-			LLNotificationsUtil::add("FriendOffline", args, payload);
+			LLNotifications::instance().add("FriendOffline", args, payload);
 	}
 
 	// If there's an open IM session with this agent, send a notification there too.
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 4d72dd1343..dbd4142d44 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -79,7 +79,7 @@ LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 // static
 U32 LLDrawable::sNumZombieDrawables = 0;
 F32 LLDrawable::sCurPixelAngle = 0;
-LLDynamicArrayPtr<LLPointer<LLDrawable> > LLDrawable::sDeadList;
+LLDynamicArray<LLPointer<LLDrawable>, 32 > LLDrawable::sDeadList;
 
 #define FORCE_INVISIBLE_AREA 16.f
 
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 26796b92d0..e400a8b5f2 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -309,7 +309,7 @@ private:
 	LLVector3		mCurrentScale;
 	
 	static U32 sNumZombieDrawables;
-	static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
+	static LLDynamicArray<LLPointer<LLDrawable>, 32> sDeadList;
 } LL_ALIGN_POSTFIX(16);
 
 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 294cecc703..67dbe6de8b 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -421,7 +421,7 @@ void LLDrawPoolAvatar::renderShadow(S32 pass)
 	
 	if (pass == 0)
 	{
-		avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
+		avatarp->renderSkinned();
 	}
 	else
 	{
@@ -1246,7 +1246,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 
 	if( !single_avatar || (avatarp == single_avatar) )
 	{
-		avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE);
+		avatarp->renderSkinned();
 	}
 }
 
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index 15c9e7856f..dda4bc9b3c 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -28,7 +28,6 @@
 #define LL_LLFACE_H
 
 #include "llstrider.h"
-
 #include "llrender.h"
 #include "v2math.h"
 #include "v3math.h"
@@ -37,7 +36,6 @@
 #include "v4coloru.h"
 #include "llquaternion.h"
 #include "xform.h"
-#include "lldarrayptr.h"
 #include "llvertexbuffer.h"
 #include "llviewertexture.h"
 #include "lldrawable.h"
@@ -47,10 +45,8 @@ class LLFacePool;
 class LLVolume;
 class LLViewerTexture;
 class LLTextureEntry;
-class LLVertexProgram;
-class LLViewerTexture;
-class LLGeometryManager;
 class LLTextureAtlasSlot;
+class LLDrawInfo;
 
 const F32 MIN_ALPHA_SIZE = 1024.f;
 const F32 MIN_TEX_ANIM_SIZE = 512.f;
diff --git a/indra/newview/llfloateravatartextures.cpp b/indra/newview/llfloateravatartextures.cpp
index 4e10b4fc2c..0fc9150314 100644
--- a/indra/newview/llfloateravatartextures.cpp
+++ b/indra/newview/llfloateravatartextures.cpp
@@ -36,6 +36,7 @@
 #include "lluictrlfactory.h"
 #include "llviewerobjectlist.h"
 #include "llvoavatarself.h"
+#include "lllocaltextureobject.h"
 
 using namespace LLVOAvatarDefines;
 
diff --git a/indra/newview/llgroupiconctrl.cpp b/indra/newview/llgroupiconctrl.cpp
index 2f9810775b..2bcee69b91 100644
--- a/indra/newview/llgroupiconctrl.cpp
+++ b/indra/newview/llgroupiconctrl.cpp
@@ -29,17 +29,7 @@
 #include "llgroupiconctrl.h"
 
 #include "llagent.h"
-/*
-#include "llavatarconstants.h"
-#include "llcallingcard.h" // for LLAvatarTracker
-#include "llavataractions.h"
-#include "llmenugl.h"
-#include "lluictrlfactory.h"
-
-#include "llcachename.h"
-#include "llagentdata.h"
-#include "llimfloater.h"
-*/
+#include "llviewertexture.h"
 
 static LLDefaultChildRegistry::Register<LLGroupIconCtrl> g_i("group_icon");
 
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index 81eb1d397e..eb83015f4a 100644
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -41,6 +41,7 @@
 #include "llui.h"
 #include "message.h"
 #include "roles_constants.h"
+#include "llhttpclient.h"
 #include "lltransactiontypes.h"
 #include "llstatusbar.h"
 #include "lleconomy.h"
@@ -50,6 +51,7 @@
 #include "llnotificationsutil.h"
 #include "lluictrlfactory.h"
 #include "lltrans.h"
+#include "llviewerregion.h"
 #include <boost/regex.hpp>
 
 #if LL_MSVC
diff --git a/indra/newview/llhudicon.h b/indra/newview/llhudicon.h
index 644daa0299..2bbc9c839d 100644
--- a/indra/newview/llhudicon.h
+++ b/indra/newview/llhudicon.h
@@ -28,7 +28,6 @@
 #define LL_LLHUDICON_H
 
 #include "llpointer.h"
-#include "lldarrayptr.h"
 
 #include "llhudobject.h"
 #include "v4color.h"
@@ -42,8 +41,6 @@
 #include "lldarray.h"
 
 // Renders a 2D icon billboard floating at the location specified.
-class LLDrawable;
-class LLViewerObject;
 class LLViewerTexture;
 
 class LLHUDIcon : public LLHUDObject
diff --git a/indra/newview/llhudmanager.h b/indra/newview/llhudmanager.h
index 09e79acbfc..effea8f034 100644
--- a/indra/newview/llhudmanager.h
+++ b/indra/newview/llhudmanager.h
@@ -30,13 +30,9 @@
 // Responsible for managing all HUD elements.
 
 #include "llhudobject.h"
-#include "lldarrayptr.h"
+#include "lldarray.h"
 
-class LLViewerObject;
 class LLHUDEffect;
-//Ventrella 9/16/05
-class LLHUDAnimalControls;
-// End Ventrella
 class LLMessageSystem;
 
 class LLHUDManager : public LLSingleton<LLHUDManager>
@@ -59,7 +55,7 @@ public:
 	static LLColor4 sChildColor;
 
 protected:
-	LLDynamicArrayPtr<LLPointer<LLHUDEffect>				> mHUDEffects;
+	LLDynamicArray<LLPointer<LLHUDEffect>, 32> mHUDEffects;
 };
 
 #endif // LL_LLHUDMANAGER_H
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 63eedcdfea..f68012e306 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -38,6 +38,7 @@
 #include "llchiclet.h"
 #include "llchicletbar.h"
 #include "llfloaterreg.h"
+#include "llhttpclient.h"
 #include "llimfloatercontainer.h" // to replace separate IM Floaters with multifloater container
 #include "llinventoryfunctions.h"
 #include "lllayoutstack.h"
@@ -49,6 +50,7 @@
 #include "lltrans.h"
 #include "llchathistory.h"
 #include "llnotifications.h"
+#include "llviewerregion.h"
 #include "llviewerwindow.h"
 #include "llvoicechannel.h"
 #include "lltransientfloatermgr.h"
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 4000570872..080e1e7ad6 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -63,6 +63,7 @@
 #include "lltoolbarview.h"
 #include "llviewercontrol.h"
 #include "llviewerparcelmgr.h"
+#include "llviewerregion.h"
 
 
 const static std::string ADHOC_NAME_SUFFIX(" Conference");
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 7c2cd03d97..3b97ad0901 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -33,13 +33,12 @@
 
 #include "lllogchat.h"
 #include "llvoicechannel.h"
-
+#include "lldarray.h"
 
 class LLAvatarName;
 class LLFriendObserver;
 class LLCallDialogManager;	
 class LLIMSpeakerMgr;
-
 /**
  * Timeout Timer for outgoing Ad-Hoc/Group IM sessions which being initialized by the server
  */
diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index 17d0b0ffbb..4f727bbd7d 100644
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -37,6 +37,7 @@
 #include "lldateutil.h"
 #include "llfloaterreporter.h"
 #include "llfloaterworldmap.h"
+#include "llhttpclient.h"
 #include "llimview.h"
 #include "llinspect.h"
 #include "llmutelist.h"
@@ -46,6 +47,7 @@
 #include "llviewermenu.h"
 #include "llvoiceclient.h"
 #include "llviewerobjectlist.h"
+#include "llviewerregion.h"
 #include "lltransientfloatermgr.h"
 #include "llnotificationsutil.h"
 
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 949de312be..927ae090c6 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -68,6 +68,7 @@
 #include "llviewermenu.h"
 #include "llviewermessage.h"
 #include "llviewerobjectlist.h"
+#include "llviewerregion.h"
 #include "llviewerwindow.h"
 #include "llvoavatarself.h"
 #include "llwearablelist.h"
diff --git a/indra/newview/llinventoryicon.cpp b/indra/newview/llinventoryicon.cpp
index 34734d57c5..0684734111 100644
--- a/indra/newview/llinventoryicon.cpp
+++ b/indra/newview/llinventoryicon.cpp
@@ -30,6 +30,7 @@
 #include "lldictionary.h"
 #include "llinventorydefines.h"
 #include "llui.h"
+#include "lluiimage.h"
 #include "llwearabletype.h"
 
 struct IconEntry : public LLDictionaryEntry
@@ -47,6 +48,8 @@ public:
 	LLIconDictionary();
 };
 
+typedef LLPointer<LLUIImage> LLUIImagePtr;
+
 LLIconDictionary::LLIconDictionary()
 {
 	addEntry(LLInventoryIcon::ICONNAME_TEXTURE, 				new IconEntry("Inv_Texture"));
diff --git a/indra/newview/llinventoryicon.h b/indra/newview/llinventoryicon.h
index c7e2998a20..cbcddc26a9 100644
--- a/indra/newview/llinventoryicon.h
+++ b/indra/newview/llinventoryicon.h
@@ -30,7 +30,6 @@
 
 #include "llassettype.h"
 #include "llinventorytype.h"
-#include "lluiimage.h"
 
 class LLInventoryIcon
 {
@@ -87,11 +86,11 @@ public:
 										  BOOL item_is_multi = FALSE);
 	static const std::string& getIconName(EIconName idx);
 
-	static LLUIImagePtr getIcon(LLAssetType::EType asset_type,
+	static LLPointer<class LLUIImage> getIcon(LLAssetType::EType asset_type,
 								LLInventoryType::EType inventory_type = LLInventoryType::IT_NONE,
 								U32 misc_flag = 0, // different meanings depending on item type
 								BOOL item_is_multi = FALSE);
-	static LLUIImagePtr getIcon(EIconName idx);
+	static LLPointer<class LLUIImage> getIcon(EIconName idx);
 
 protected:
 	static EIconName assignWearableIcon(U32 misc_flag);
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index 8382e875b4..88463c4aa9 100644
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -31,7 +31,7 @@
 #include "llfoldertype.h"
 #include "lldarray.h"
 #include "llframetimer.h"
-#include "llhttpclient.h"
+#include "llcurl.h"
 #include "lluuid.h"
 #include "llpermissionsflags.h"
 #include "llstring.h"
@@ -79,7 +79,7 @@ public:
 	typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
 	typedef std::set<LLUUID> changed_items_t;
 
-	class fetchInventoryResponder : public LLHTTPClient::Responder
+	class fetchInventoryResponder : public LLCurl::Responder
 	{
 	public:
 		fetchInventoryResponder(const LLSD& request_sd) : mRequestSD(request_sd) {};
diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index 97ba5b634a..ce04629104 100644
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -48,6 +48,7 @@
 /* misc headers */
 #include "llscrolllistctrl.h"
 #include "llfilepicker.h"
+#include "lllocaltextureobject.h"
 #include "llviewertexturelist.h"
 #include "llviewerobjectlist.h"
 #include "llviewerobject.h"
diff --git a/indra/newview/lllocalbitmaps.h b/indra/newview/lllocalbitmaps.h
index 7a23c7ef6e..f99fc66f4b 100644
--- a/indra/newview/lllocalbitmaps.h
+++ b/indra/newview/lllocalbitmaps.h
@@ -33,6 +33,8 @@
 #include "llvoavatardefines.h"
 
 class LLScrollListCtrl;
+class LLImageRaw;
+class LLViewerObject;
 
 class LLLocalBitmap
 {
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 6889b98ab1..a86f722db9 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -52,6 +52,7 @@
 #include "llfloaterworldmap.h"
 #include "llviewergenericmessage.h"	// send_generic_message
 #include "llviewerregion.h"
+#include "llviewertexture.h"
 #include "lltrans.h"
 #include "llscrollcontainer.h"
 #include "llstatusbar.h"
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 6b9edcb07c..79713ddb12 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -30,6 +30,7 @@
 #include "llpanel.h"
 #include "llwearable.h"
 #include "lluictrl.h"
+#include "lllocaltextureobject.h"
 #include "llscrollingpanellist.h"
 #include "llvisualparam.h"
 #include "lltoolmorph.h"
diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h
index 46c58cd139..76f260cca1 100644
--- a/indra/newview/llpanelpeople.h
+++ b/indra/newview/llpanelpeople.h
@@ -38,6 +38,7 @@ class LLFilterEditor;
 class LLGroupList;
 class LLMenuButton;
 class LLTabContainer;
+class LLNetMap;
 
 class LLPanelPeople 
 	: public LLPanel
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index e2e7006773..435797bf80 100755
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -36,6 +36,7 @@
 #include "lltabcontainer.h"
 #include "llviewercontrol.h"
 #include "llviewernetwork.h"
+#include "llweb.h"
 
 static const std::string PANEL_PICKS = "panel_picks";
 
diff --git a/indra/newview/llpanelvoiceeffect.cpp b/indra/newview/llpanelvoiceeffect.cpp
index 5fec6d967d..59ed53815b 100644
--- a/indra/newview/llpanelvoiceeffect.cpp
+++ b/indra/newview/llpanelvoiceeffect.cpp
@@ -35,6 +35,7 @@
 #include "lltrans.h"
 #include "lltransientfloatermgr.h"
 #include "llvoiceclient.h"
+#include "llweb.h"
 
 static LLRegisterPanelClassWrapper<LLPanelVoiceEffect> t_panel_voice_effect("panel_voice_effect");
 
diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp
index 07d2f1ad6f..5ad8165a72 100644
--- a/indra/newview/llspeakers.cpp
+++ b/indra/newview/llspeakers.cpp
@@ -33,7 +33,9 @@
 #include "llimview.h"
 #include "llsdutil.h"
 #include "lluicolortable.h"
+#include "llhttpclient.h"
 #include "llviewerobjectlist.h"
+#include "llviewerregion.h"
 #include "llvoavatar.h"
 #include "llworld.h"
 
diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp
index d6cd881894..1c2bbbed27 100644
--- a/indra/newview/lltexlayer.cpp
+++ b/indra/newview/lltexlayer.cpp
@@ -31,6 +31,7 @@
 #include "llagent.h"
 #include "llimagej2c.h"
 #include "llimagetga.h"
+#include "lllocaltextureobject.h"
 #include "llnotificationsutil.h"
 #include "llvfile.h"
 #include "llvfs.h"
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index a0c12df834..61d879278d 100644
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -42,6 +42,7 @@
 #include "llfloaterscriptdebug.h"
 #include "lltooltip.h"
 #include "llhudeffecttrail.h"
+#include "llhudicon.h"
 #include "llhudmanager.h"
 #include "llkeyboard.h"
 #include "llmediaentry.h"
diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp
index 7c604a04bf..0a9153eecb 100644
--- a/indra/newview/lltoolselect.cpp
+++ b/indra/newview/lltoolselect.cpp
@@ -32,6 +32,7 @@
 #include "llagentcamera.h"
 #include "llviewercontrol.h"
 #include "lldrawable.h"
+#include "llhudicon.h"
 #include "llmanip.h"
 #include "llmenugl.h"
 #include "llselectmgr.h"
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 5b25d791a9..56eaa13df9 100644
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -38,6 +38,7 @@
 #include "llsd.h"
 #include "llvoavatar.h"
 #include "lltrace.h"
+#include "llinitparam.h"
 
 /**
  * @class LLViewerAssetStats
diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp
index 8d8c401dac..4e97dfb201 100644
--- a/indra/newview/llvieweraudio.cpp
+++ b/indra/newview/llvieweraudio.cpp
@@ -36,6 +36,7 @@
 #include "llviewerwindow.h"
 #include "llvoiceclient.h"
 #include "llviewermedia.h"
+#include "llviewerregion.h"
 #include "llprogressview.h"
 #include "llcallbacklist.h"
 #include "llstartup.h"
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 5d1aa870a3..1850ed45d1 100644
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -128,7 +128,6 @@ BOOL LLSkinJoint::setupSkinJoint( LLViewerJoint *joint)
 //-----------------------------------------------------------------------------
 
 BOOL LLViewerJointMesh::sPipelineRender = FALSE;
-EAvatarRenderPass LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE;
 U32 LLViewerJointMesh::sClothingMaskImageName = 0;
 LLColor4 LLViewerJointMesh::sClothingInnerColor;
 
diff --git a/indra/newview/llviewerjointmesh.h b/indra/newview/llviewerjointmesh.h
index dd5dae1dc1..614d87f2b1 100644
--- a/indra/newview/llviewerjointmesh.h
+++ b/indra/newview/llviewerjointmesh.h
@@ -37,13 +37,6 @@ class LLFace;
 class LLCharacter;
 class LLTexLayerSet;
 
-typedef enum e_avatar_render_pass
-{
-	AVATAR_RENDER_PASS_SINGLE,
-	AVATAR_RENDER_PASS_CLOTHING_INNER,
-	AVATAR_RENDER_PASS_CLOTHING_OUTER
-} EAvatarRenderPass;
-
 class LLSkinJoint
 {
 public:
@@ -84,7 +77,6 @@ public:
 	static BOOL					sPipelineRender;
 	//RN: this is here for testing purposes
 	static U32					sClothingMaskImageName;
-	static EAvatarRenderPass	sRenderPass;
 	static LLColor4				sClothingInnerColor;
 
 public:
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index ef28c3ad53..50b14183c7 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -39,6 +39,7 @@
 #include "llfloaterreg.h"
 #include "llfontgl.h"
 #include "llframetimer.h"
+#include "llhudicon.h"
 #include "llinventory.h"
 #include "llinventorydefines.h"
 #include "llmaterialtable.h"
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 942eb67823..536106fb1e 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -30,8 +30,7 @@
 #include <map>
 
 #include "llassetstorage.h"
-#include "lldarrayptr.h"
-#include "llhudicon.h"
+//#include "llhudicon.h"
 #include "llinventory.h"
 #include "llrefcount.h"
 #include "llprimitive.h"
@@ -43,34 +42,30 @@
 #include "v3math.h"
 #include "llvertexbuffer.h"
 #include "llbbox.h"
-#include "llbbox.h"
 
 class LLAgent;			// TODO: Get rid of this.
 class LLAudioSource;
 class LLAudioSourceVO;
-class LLDataPacker;
 class LLColor4;
-class LLFrameTimer;
+class LLDataPacker;
+class LLDataPackerBinaryBuffer;
 class LLDrawable;
-class LLHost;
 class LLHUDText;
-class LLWorld;
-class LLNameValue;
-class LLNetMap;
+class LLHost;
 class LLMessageSystem;
+class LLNameValue;
 class LLPartSysData;
-class LLPrimitive;
 class LLPipeline;
 class LLTextureEntry;
-class LLViewerTexture;
+class LLVOAvatar;
+class LLVOInventoryListener;
 class LLViewerInventoryItem;
 class LLViewerObject;
+class LLViewerObjectMedia;
 class LLViewerPartSourceScript;
 class LLViewerRegion;
-class LLViewerObjectMedia;
-class LLVOInventoryListener;
-class LLVOAvatar;
-class LLDataPackerBinaryBuffer;
+class LLViewerTexture;
+class LLWorld;
 
 typedef enum e_object_update_type
 {
@@ -645,7 +640,7 @@ public:
 
 	// TODO: Make all this stuff private.  JC
 	LLPointer<LLHUDText> mText;
-	LLPointer<LLHUDIcon> mIcon;
+	LLPointer<class LLHUDIcon> mIcon;
 
 	static			BOOL		sUseSharedDrawables;
 	static	LLTrace::MemStatHandle	sMemStat;
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 4d0d3e8718..6ffd3d8fa4 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -47,6 +47,7 @@
 #include "lltooltip.h"
 #include "llworld.h"
 #include "llstring.h"
+#include "llhudicon.h"
 #include "llhudnametag.h"
 #include "lldrawable.h"
 #include "llflexibleobject.h"
@@ -2275,3 +2276,10 @@ bool LLViewerObjectList::OrphanInfo::operator!=(const OrphanInfo &rhs) const
 }
 
 
+LLDebugBeacon::~LLDebugBeacon()
+{
+	if (mHUDObject.notNull())
+	{
+		mHUDObject->markDead();
+	}
+}
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index a7a4969768..65447156e7 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -237,20 +237,14 @@ protected:
 class LLDebugBeacon
 {
 public:
-	~LLDebugBeacon()
-	{
-		if (mHUDObject.notNull())
-		{
-			mHUDObject->markDead();
-		}
-	}
+	~LLDebugBeacon();
 
 	LLVector3 mPositionAgent;
 	std::string mString;
 	LLColor4 mColor;
 	LLColor4 mTextColor;
 	S32 mLineWidth;
-	LLPointer<LLHUDObject> mHUDObject;
+	LLPointer<class LLHUDObject> mHUDObject;
 };
 
 
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 926d791d1f..0eb1745cd5 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -331,6 +331,7 @@ LLviewerOctreeGroup::~LLviewerOctreeGroup()
 	{
 		LLViewerRegion::sCurRegionp->clearVisibleGroup(this);
 	}
+	llassert(LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false);
 }
 
 LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) :
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index b6faf4c7ba..2f601d66f3 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -78,9 +78,6 @@ public:
 	void setGroup(LLviewerOctreeGroup* group);
 	void removeData(LLViewerOctreeEntryData* data);
 
-	LLViewerOctreeEntryData* getData(U32 data_type)const {return mData[data_type];}
-	bool                     hasData(U32 data_type)const {return mData[data_type] != NULL;}
-
 	LLViewerOctreeEntryData* getDrawable() const {return mData[LLDRAWABLE];}
 	bool                     hasDrawable() const {return mData[LLDRAWABLE] != NULL;}
 	LLViewerOctreeEntryData* getVOCacheEntry() const {return mData[LLVOCACHEENTRY];}
diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h
index 27bfcd4343..5c71b4c49e 100644
--- a/indra/newview/llviewerpartsim.h
+++ b/indra/newview/llviewerpartsim.h
@@ -27,7 +27,6 @@
 #ifndef LL_LLVIEWERPARTSIM_H
 #define LL_LLVIEWERPARTSIM_H
 
-#include "lldarrayptr.h"
 #include "llframetimer.h"
 #include "llpointer.h"
 #include "llpartdata.h"
@@ -36,7 +35,6 @@
 class LLViewerTexture;
 class LLViewerPart;
 class LLViewerRegion;
-class LLViewerTexture;
 class LLVOPartGroup;
 
 #define LL_MAX_PARTICLE_COUNT 8192
diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index cafe28356d..137849234d 100644
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -54,11 +54,9 @@
 
 // Library headers from llcommon project:
 #include "bitpack.h"
-#include "lldeleteutils.h"
 #include "imageids.h"
 #include "indra_constants.h"
 #include "llinitparam.h"
-
 #include "llallocator.h"
 #include "llapp.h"
 #include "llcriticaldamp.h"
@@ -67,11 +65,7 @@
 #include "llerror.h"
 #include "llfasttimer.h"
 #include "llframetimer.h"
-#include "llhash.h"
-#include "lllocalidhashmap.h"
-#include "llnametable.h"
 #include "llpointer.h"
-#include "llpriqueuemap.h"
 #include "llprocessor.h"
 #include "llrefcount.h"
 #include "llsafehandle.h"
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index a2ff232d02..e85c566394 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -94,28 +94,29 @@ typedef std::map<std::string, std::string> CapabilityMap;
 class LLViewerRegionImpl {
 public:
 	LLViewerRegionImpl(LLViewerRegion * region, LLHost const & host)
-		:	mHost(host),
-			mCompositionp(NULL),
-			mEventPoll(NULL),
-			mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS),
-			mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN),
-			mSeedCapAttempts(0),
-			mHttpResponderID(0),
-			mLastCameraUpdate(0),
-			mLastCameraOrigin(),
-		    // I'd prefer to set the LLCapabilityListener name to match the region
-		    // name -- it's disappointing that's not available at construction time.
-		    // We could instead store an LLCapabilityListener*, making
-		    // setRegionNameAndZone() replace the instance. Would that pose
-		    // consistency problems? Can we even request a capability before calling
-		    // setRegionNameAndZone()?
-		    // For testability -- the new Michael Feathers paradigm --
-		    // LLCapabilityListener binds all the globals it expects to need at
-		    // construction time.
-		    mCapabilityListener(host.getString(), gMessageSystem, *region,
-		                        gAgent.getID(), gAgent.getSessionID())
-	{
-	}
+	:	mHost(host),
+		mCompositionp(NULL),
+		mEventPoll(NULL),
+		mSeedCapMaxAttempts(MAX_CAP_REQUEST_ATTEMPTS),
+		mSeedCapMaxAttemptsBeforeLogin(MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN),
+		mSeedCapAttempts(0),
+		mHttpResponderID(0),
+		mLastCameraUpdate(0),
+		mLastCameraOrigin(),
+		mVOCachePartition(NULL),
+		mLandp(NULL),
+		// I'd prefer to set the LLCapabilityListener name to match the region
+		// name -- it's disappointing that's not available at construction time.
+		// We could instead store an LLCapabilityListener*, making
+		// setRegionNameAndZone() replace the instance. Would that pose
+		// consistency problems? Can we even request a capability before calling
+		// setRegionNameAndZone()?
+		// For testability -- the new Michael Feathers paradigm --
+		// LLCapabilityListener binds all the globals it expects to need at
+		// construction time.
+		mCapabilityListener(host.getString(), gMessageSystem, *region,
+		                    gAgent.getID(), gAgent.getSessionID())
+	{}
 
 	void buildCapabilityNames(LLSD& capabilityNames);
 
@@ -439,7 +440,7 @@ void LLViewerRegion::loadObjectCache()
 	// Presume success.  If it fails, we don't want to try again.
 	mCacheLoaded = TRUE;
 
-	if(LLVOCache::hasInstance())
+	if(LLVOCache::instanceExists())
 	{
 		LLVOCache::getInstance()->readFromCache(mHandle, mImpl->mCacheID, mImpl->mCacheMap) ;
 		if (mImpl->mCacheMap.empty())
@@ -462,7 +463,7 @@ void LLViewerRegion::saveObjectCache()
 		return;
 	}
 
-	if(LLVOCache::hasInstance())
+	if(LLVOCache::instanceExists())
 	{
 		const F32 start_time_threshold = 600.0f; //seconds
 		bool removal_enabled = sVOCacheCullingEnabled && (mRegionTimer.getElapsedTimeF32() > start_time_threshold); //allow to remove invalid objects from object cache file.
@@ -755,7 +756,7 @@ void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry
 
 	if(old_entry)
 	{
-		old_entry->copyTo(new_entry);
+		old_entry->moveTo(new_entry);
 		state = old_entry->getState();
 		in_vo_tree = (state == LLVOCacheEntry::INACTIVE && old_entry->getGroup() != NULL);
 		killCacheEntry(old_entry);
@@ -942,6 +943,11 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 	mImpl->mVisibleEntries.insert(entry);
 }
 
+bool LLViewerRegion::hasVisibleGroup(LLviewerOctreeGroup* group)
+{
+	return mImpl->mVisibleGroups.find(group) != mImpl->mVisibleGroups.end();
+}
+
 void LLViewerRegion::clearVisibleGroup(LLviewerOctreeGroup* group)
 {
 	if(mDead)
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 410c903f18..a73898317b 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -225,6 +225,7 @@ public:
 	void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep);	
 	void killCacheEntry(U32 local_id); //physically delete the cache entry	
 	void clearVisibleGroup(LLviewerOctreeGroup* group);
+	bool hasVisibleGroup(LLviewerOctreeGroup* group);
 
 	// Like idleUpdate, but forces everything to complete regardless of
 	// how long it takes.
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index fea44a38c6..08d296b88e 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -38,6 +38,7 @@
 #include "llagent.h"
 #include "llagentcamera.h"
 #include "llfloaterreg.h"
+#include "llhudicon.h"
 #include "llmeshrepository.h"
 #include "llpanellogin.h"
 #include "llviewerkeyboard.h"
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 5a07cdf7c9..1381cf9314 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -55,7 +55,6 @@
 #include "lldriverparam.h"
 #include "lleditingmotion.h"
 #include "llemote.h"
-//#include "llfirstuse.h"
 #include "llfloatertools.h"
 #include "llheadrotmotion.h"
 #include "llhudeffecttrail.h"
@@ -80,10 +79,12 @@
 #include "lltexlayer.h"
 #include "lltoolmorph.h"
 #include "llviewercamera.h"
+#include "llviewerjointmesh.h"
 #include "llviewertexturelist.h"
 #include "llviewermenu.h"
 #include "llviewerobjectlist.h"
 #include "llviewerparcelmgr.h"
+#include "llviewerregion.h"
 #include "llviewershadermgr.h"
 #include "llviewerstats.h"
 #include "llvoavatarself.h"
@@ -216,6 +217,24 @@ struct LLTextureMaskData
 	S32					mLastDiscardLevel;
 };
 
+// Simple utility functions to eventually replace the common 2-line
+// idiom scattered throughout the viewer codebase.  Note that where
+// possible we would rather be using smart pointers of some sort.
+
+template <class T>
+inline void delete_and_clear(T*& ptr)
+{
+	delete ptr;
+	ptr = NULL;
+}
+
+template <class T>
+inline void delete_and_clear_array(T*& array_ptr)
+{
+	delete[] array_ptr;
+	array_ptr = NULL;
+}
+
 /*********************************************************************************
  **                                                                             **
  ** Begin private LLVOAvatar Support classes
@@ -824,14 +843,14 @@ LLVOAvatar::~LLVOAvatar()
 	mRoot.removeAllChildren();
 	mJointMap.clear();
 
-	deleteAndClearArray(mSkeleton);
-	deleteAndClearArray(mCollisionVolumes);
+	delete_and_clear_array(mSkeleton);
+	delete_and_clear_array(mCollisionVolumes);
 
 	mNumJoints = 0;
 
 	for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
 	{
-		deleteAndClear(mBakedTextureDatas[i].mTexLayerSet);
+		delete_and_clear(mBakedTextureDatas[i].mTexLayerSet);
 		mBakedTextureDatas[i].mMeshes.clear();
 
 		for (morph_list_t::iterator iter2 = mBakedTextureDatas[i].mMaskedMorphs.begin();
@@ -845,9 +864,9 @@ LLVOAvatar::~LLVOAvatar()
 	std::for_each(mAttachmentPoints.begin(), mAttachmentPoints.end(), DeletePairedPointer());
 	mAttachmentPoints.clear();
 
-	deleteAndClear(mTexSkinColor);
-	deleteAndClear(mTexHairColor);
-	deleteAndClear(mTexEyeColor);
+	delete_and_clear(mTexSkinColor);
+	delete_and_clear(mTexHairColor);
+	delete_and_clear(mTexEyeColor);
 
 	std::for_each(mMeshes.begin(), mMeshes.end(), DeletePairedPointer());
 	mMeshes.clear();
@@ -1234,7 +1253,7 @@ void LLVOAvatar::initClass()
 	// parse avatar_lad.xml
 	if (sAvatarXmlInfo)
 	{ //this can happen if a login attempt failed
-		deleteAndClear(sAvatarXmlInfo);
+		delete_and_clear(sAvatarXmlInfo);
 	}
 	sAvatarXmlInfo = new LLVOAvatarXmlInfo;
 	if (!sAvatarXmlInfo->parseXmlSkeletonNode(root))
@@ -1278,7 +1297,7 @@ void LLVOAvatar::initClass()
 
 void LLVOAvatar::cleanupClass()
 {
-	deleteAndClear(sAvatarXmlInfo);
+	delete_and_clear(sAvatarXmlInfo);
 	sSkeletonXMLTree.cleanup();
 	sXMLTree.cleanup();
 }
@@ -4188,7 +4207,7 @@ U32 LLVOAvatar::renderSkinnedAttachments()
 //-----------------------------------------------------------------------------
 // renderSkinned()
 //-----------------------------------------------------------------------------
-U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
+U32 LLVOAvatar::renderSkinned()
 {
 	U32 num_indices = 0;
 
@@ -4324,57 +4343,50 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass)
 	//--------------------------------------------------------------------
 	// render all geometry attached to the skeleton
 	//--------------------------------------------------------------------
-	LLViewerJointMesh::sRenderPass = pass;
-
-	if (pass == AVATAR_RENDER_PASS_SINGLE)
-	{
 
-		bool should_alpha_mask = shouldAlphaMask();
-		LLGLState test(GL_ALPHA_TEST, should_alpha_mask);
+	bool should_alpha_mask = shouldAlphaMask();
+	LLGLState test(GL_ALPHA_TEST, should_alpha_mask);
 		
-		if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction)
-		{
-			gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f);
-		}
+	if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction)
+	{
+		gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f);
+	}
 		
-		BOOL first_pass = TRUE;
-		if (!LLDrawPoolAvatar::sSkipOpaque)
+	BOOL first_pass = TRUE;
+	if (!LLDrawPoolAvatar::sSkipOpaque)
+	{
+		if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender)
 		{
-			if (!isSelf() || gAgent.needsRenderHead() || LLPipeline::sShadowRender)
+			if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy)
 			{
-				if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy)
-				{
-					num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy);
-					first_pass = FALSE;
-				}
-			}
-			if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy)
-			{
-				num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy);
-				first_pass = FALSE;
-			}
-			
-			if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy)
-			{
-				num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy);
+				num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy);
 				first_pass = FALSE;
 			}
 		}
-
-		if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction)
+		if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy)
 		{
-			gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
+			num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy);
+			first_pass = FALSE;
 		}
-
-		if (!LLDrawPoolAvatar::sSkipTransparent || LLPipeline::sImpostorRender)
+			
+		if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy)
 		{
-			LLGLState blend(GL_BLEND, !mIsDummy);
-			LLGLState test(GL_ALPHA_TEST, !mIsDummy);
-			num_indices += renderTransparent(first_pass);
+			num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy);
+			first_pass = FALSE;
 		}
 	}
-	
-	LLViewerJointMesh::sRenderPass = AVATAR_RENDER_PASS_SINGLE;
+
+	if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction)
+	{
+		gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
+	}
+
+	if (!LLDrawPoolAvatar::sSkipTransparent || LLPipeline::sImpostorRender)
+	{
+		LLGLState blend(GL_BLEND, !mIsDummy);
+		LLGLState test(GL_ALPHA_TEST, !mIsDummy);
+		num_indices += renderTransparent(first_pass);
+	}
 	
 	return num_indices;
 }
@@ -5331,7 +5343,7 @@ LLVector3	LLVOAvatar::getPosAgentFromGlobal(const LLVector3d &position)
 //-----------------------------------------------------------------------------
 BOOL LLVOAvatar::allocateCharacterJoints( U32 num )
 {
-	deleteAndClearArray(mSkeleton);
+	delete_and_clear_array(mSkeleton);
 	mNumJoints = 0;
 
 	mSkeleton = new LLViewerJoint[num];
@@ -5355,7 +5367,7 @@ BOOL LLVOAvatar::allocateCharacterJoints( U32 num )
 //-----------------------------------------------------------------------------
 BOOL LLVOAvatar::allocateCollisionVolumes( U32 num )
 {
-	deleteAndClearArray(mCollisionVolumes);
+	delete_and_clear_array(mCollisionVolumes);
 	mNumCollisionVolumes = 0;
 
 	mCollisionVolumes = new LLViewerJointCollisionVolume[num];
@@ -7870,9 +7882,9 @@ LLVOAvatar::LLVOAvatarXmlInfo::~LLVOAvatarXmlInfo()
 	std::for_each(mMeshInfoList.begin(), mMeshInfoList.end(), DeletePointer());
 	std::for_each(mSkeletalDistortionInfoList.begin(), mSkeletalDistortionInfoList.end(), DeletePointer());		
 	std::for_each(mAttachmentInfoList.begin(), mAttachmentInfoList.end(), DeletePointer());
-	deleteAndClear(mTexSkinColorInfo);
-	deleteAndClear(mTexHairColorInfo);
-	deleteAndClear(mTexEyeColorInfo);
+	delete_and_clear(mTexSkinColorInfo);
+	delete_and_clear(mTexHairColorInfo);
+	delete_and_clear(mTexEyeColorInfo);
 	std::for_each(mLayerInfoList.begin(), mLayerInfoList.end(), DeletePointer());		
 	std::for_each(mDriverInfoList.begin(), mDriverInfoList.end(), DeletePointer());
 	std::for_each(mMorphMaskInfoList.begin(), mMorphMaskInfoList.end(), DeletePointer());
@@ -8203,7 +8215,7 @@ BOOL LLVOAvatar::LLVOAvatarXmlInfo::parseXmlColorNodes(LLXmlTreeNode* root)
 				mTexSkinColorInfo = new LLTexGlobalColorInfo;
 				if( !mTexSkinColorInfo->parseXml( color_node ) )
 				{
-					deleteAndClear(mTexSkinColorInfo);
+					delete_and_clear(mTexSkinColorInfo);
 					llwarns << "avatar file: mTexSkinColor->parseXml() failed" << llendl;
 					return FALSE;
 				}
@@ -8218,7 +8230,7 @@ BOOL LLVOAvatar::LLVOAvatarXmlInfo::parseXmlColorNodes(LLXmlTreeNode* root)
 				mTexHairColorInfo = new LLTexGlobalColorInfo;
 				if( !mTexHairColorInfo->parseXml( color_node ) )
 				{
-					deleteAndClear(mTexHairColorInfo);
+					delete_and_clear(mTexHairColorInfo);
 					llwarns << "avatar file: mTexHairColor->parseXml() failed" << llendl;
 					return FALSE;
 				}
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 1adb680962..87d3e40b8c 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -33,7 +33,7 @@
 #include <string>
 #include <vector>
 
-#include <boost/signals2.hpp>
+#include <boost/signals2/trackable.hpp>
 
 #include "imageids.h"			// IMG_INVISIBLE
 #include "llchat.h"
@@ -69,6 +69,7 @@ class LLHUDEffectSpiral;
 class LLTexGlobalColor;
 class LLVOAvatarBoneInfo;
 class LLVOAvatarSkeletonInfo;
+class LLViewerJointMesh;
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 // LLVOAvatar
@@ -435,7 +436,7 @@ public:
 	bool		isVisuallyMuted() const;
 
 	U32 		renderRigid();
-	U32 		renderSkinned(EAvatarRenderPass pass);
+	U32 		renderSkinned();
 	F32			getLastSkinTime() { return mLastSkinTime; }
 	U32			renderSkinnedAttachments();
 	U32 		renderTransparent(BOOL first_pass);
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 4275552117..69f998f0f3 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -43,6 +43,7 @@
 #include "llhudeffecttrail.h"
 #include "llhudmanager.h"
 #include "llinventoryfunctions.h"
+#include "lllocaltextureobject.h"
 #include "llnotificationsutil.h"
 #include "llselectmgr.h"
 #include "lltoolgrab.h"	// for needsRenderBeam
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index eba768fef4..b67a6bbacd 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -170,7 +170,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 LLVOCacheEntry::~LLVOCacheEntry()
 {
 	mDP.freeBuffer();
-	//llassert(mState == INACTIVE);
+	llassert(mState == INACTIVE);
 }
 
 //virtual 
@@ -191,7 +191,7 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
 	LLViewerOctreeEntryData::setOctreeEntry(entry);
 }
 
-void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry)
+void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry)
 {
 	//copy LLViewerOctreeEntry
 	if(mEntry.notNull())
@@ -206,6 +206,7 @@ void LLVOCacheEntry::copyTo(LLVOCacheEntry* new_entry)
 	{
 		new_entry->addChild(getChild(i));
 	}
+	mChildrenList.clear();
 }
 
 void LLVOCacheEntry::setState(U32 state)
@@ -465,37 +466,10 @@ const U32 INVALID_TIME = 0 ;
 const char* object_cache_dirname = "objectcache";
 const char* header_filename = "object.cache";
 
-LLVOCache* LLVOCache::sInstance = NULL;
-
-//static 
-LLVOCache* LLVOCache::getInstance() 
-{	
-	if(!sInstance)
-	{
-		sInstance = new LLVOCache() ;
-	}
-	return sInstance ;
-}
-
-//static 
-BOOL LLVOCache::hasInstance() 
-{
-	return sInstance != NULL ;
-}
-
-//static 
-void LLVOCache::destroyClass() 
-{
-	if(sInstance)
-	{
-		delete sInstance ;
-		sInstance = NULL ;
-	}
-}
 
 LLVOCache::LLVOCache():
-	mInitialized(FALSE),
-	mReadOnly(TRUE),
+	mInitialized(false),
+	mReadOnly(true),
 	mNumEntries(0),
 	mCacheSize(1)
 {
@@ -532,7 +506,7 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version)
 		llwarns << "Cache already initialized." << llendl;
 		return ;
 	}
-	mInitialized = TRUE ;
+	mInitialized = true;
 
 	setDirNames(location);
 	if (!mReadOnly)
@@ -580,7 +554,7 @@ void LLVOCache::removeCache(ELLPath location, bool started)
 	LLFile::rmdir(cache_dir);
 
 	clearCacheInMemory();
-	mInitialized = FALSE ;
+	mInitialized = false;
 }
 
 void LLVOCache::removeCache() 
@@ -607,23 +581,23 @@ void LLVOCache::removeCache()
 
 void LLVOCache::removeEntry(HeaderEntryInfo* entry) 
 {
-	llassert_always(mInitialized) ;
+	llassert_always(mInitialized);
 	if(mReadOnly)
 	{
-		return ;
+		return;
 	}
 	if(!entry)
 	{
-		return ;
+		return;
 	}
 
-	header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry) ;
+	header_entry_queue_t::iterator iter = mHeaderEntryQueue.find(entry);
 	if(iter != mHeaderEntryQueue.end())
 	{		
-		mHandleEntryMap.erase(entry->mHandle) ;		
-		mHeaderEntryQueue.erase(iter) ;
-		removeFromCache(entry) ;
-		delete entry ;
+		mHandleEntryMap.erase(entry->mHandle);		
+		mHeaderEntryQueue.erase(iter);
+		removeFromCache(entry);
+		delete entry;
 
 		mNumEntries = mHandleEntryMap.size() ;
 	}
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 2aec88537c..fc0634f133 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -29,7 +29,6 @@
 
 #include "lluuid.h"
 #include "lldatapacker.h"
-#include "lldlinked.h"
 #include "lldir.h"
 #include "llvieweroctree.h"
 
@@ -101,7 +100,7 @@ public:
 	void recordHit();
 	void recordDupe() { mDupeCount++; }
 	
-	void copyTo(LLVOCacheEntry* new_entry); //copy variables 
+	void moveTo(LLVOCacheEntry* new_entry); //copy variables 
 	/*virtual*/ void setOctreeEntry(LLViewerOctreeEntry* entry);
 
 	void setParentID(U32 id) {mParentID = id;}
@@ -161,9 +160,10 @@ public:
 //
 //Note: LLVOCache is not thread-safe
 //
-class LLVOCache
+class LLVOCache : public LLSingleton<LLVOCache>
 {
 private:
+	friend LLSingleton<LLVOCache>;
 	struct HeaderEntryInfo
 	{
 		HeaderEntryInfo() : mIndex(0), mHandle(0), mTime(0) {}
@@ -206,7 +206,7 @@ public:
 	void writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache, bool removal_enabled);
 	void removeEntry(U64 handle) ;
 
-	void setReadOnly(BOOL read_only) {mReadOnly = read_only;} 
+	void setReadOnly(bool read_only) {mReadOnly = read_only;} 
 
 private:
 	void setDirNames(ELLPath location);	
@@ -222,9 +222,9 @@ private:
 	BOOL updateEntry(const HeaderEntryInfo* entry);
 	
 private:
-	BOOL                 mEnabled;
-	BOOL                 mInitialized ;
-	BOOL                 mReadOnly ;
+	bool                 mEnabled;
+	bool                 mInitialized ;
+	bool                 mReadOnly ;
 	HeaderMetaInfo       mMetaInfo;
 	U32                  mCacheSize;
 	U32                  mNumEntries;
@@ -233,12 +233,6 @@ private:
 	LLVolatileAPRPool*   mLocalAPRFilePoolp ; 	
 	header_entry_queue_t mHeaderEntryQueue;
 	handle_entry_map_t   mHandleEntryMap;	
-
-	static LLVOCache* sInstance ;
-public:
-	static LLVOCache* getInstance() ;
-	static BOOL       hasInstance() ;	
-	static void       destroyClass() ;
 };
 
 #endif
diff --git a/indra/newview/llvoicechannel.cpp b/indra/newview/llvoicechannel.cpp
index bd12328a6b..0e76a978db 100644
--- a/indra/newview/llvoicechannel.cpp
+++ b/indra/newview/llvoicechannel.cpp
@@ -28,12 +28,14 @@
 
 #include "llagent.h"
 #include "llfloaterreg.h"
+#include "llhttpclient.h"
 #include "llimview.h"
 #include "llnotifications.h"
 #include "llnotificationsutil.h"
 #include "llpanel.h"
 #include "llrecentpeople.h"
 #include "llviewercontrol.h"
+#include "llviewerregion.h"
 #include "llvoicechannel.h"
 
 
diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h
index c9aeea35a9..1b362545ec 100644
--- a/indra/newview/llvoiceclient.h
+++ b/indra/newview/llvoiceclient.h
@@ -34,7 +34,6 @@ class LLVOAvatar;
 #include "lliosocket.h"
 #include "v3math.h"
 #include "llframetimer.h"
-#include "llviewerregion.h"
 #include "llcallingcard.h"   // for LLFriendObserver
 #include "llsecapi.h"
 #include "llcontrol.h"
diff --git a/indra/newview/llvoinventorylistener.h b/indra/newview/llvoinventorylistener.h
index bf14d19b01..c50c475478 100644
--- a/indra/newview/llvoinventorylistener.h
+++ b/indra/newview/llvoinventorylistener.h
@@ -30,7 +30,9 @@
 #ifndef LL_LLVOINVENTORYLISTENER_H
 #define LL_LLVOINVENTORYLISTENER_H
 
-#include "llviewerobject.h"
+#include "llinventory.h"
+
+class LLViewerObject;
 
 class LLVOInventoryListener
 {
diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h
index a15878368e..21693e85e1 100644
--- a/indra/newview/llvosurfacepatch.h
+++ b/indra/newview/llvosurfacepatch.h
@@ -33,6 +33,8 @@
 class LLSurfacePatch;
 class LLDrawPool;
 class LLVector2;
+class LLFacePool;
+class LLFace;
 
 class LLVOSurfacePatch : public LLStaticViewerObject
 {
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 12f268d324..89a2f2ee19 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -406,7 +406,7 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
 				dp->dumpBufferToLog();
 				llwarns << "Flushing cache files" << llendl;
 
-				if(LLVOCache::hasInstance() && getRegion())
+				if(LLVOCache::instanceExists() && getRegion())
 				{
 					LLVOCache::getInstance()->removeEntry(getRegion()->getHandle()) ;
 				}
diff --git a/indra/newview/llwearable.h b/indra/newview/llwearable.h
index 3d8c53a755..ce5c882c00 100644
--- a/indra/newview/llwearable.h
+++ b/indra/newview/llwearable.h
@@ -34,12 +34,12 @@
 #include "llassetstorage.h"
 #include "llwearabletype.h"
 #include "llfile.h"
-#include "lllocaltextureobject.h"
 
 class LLViewerInventoryItem;
 class LLVisualParam;
 class LLTexGlobalColorInfo;
 class LLTexGlobalColor;
+class LLLocalTextureObject;
 
 class LLWearable
 {
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 9401773886..a123c12811 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -123,10 +123,7 @@ void LLWorld::destroyClass()
 		LLViewerRegion* region_to_delete = *region_it++;
 		removeRegion(region_to_delete->getHost());
 	}
-	if(LLVOCache::hasInstance())
-	{
-		LLVOCache::getInstance()->destroyClass() ;
-	}
+	LLVOCache::deleteSingleton();
 	LLViewerPartSim::getInstance()->destroyClass();
 
 	mDefaultWaterTexturep = NULL ;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 36abeca295..720ddf79f5 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -29,8 +29,6 @@
 
 #include "llcamera.h"
 #include "llerror.h"
-#include "lldarrayptr.h"
-#include "lldqueueptr.h"
 #include "lldrawpool.h"
 #include "llspatialpartition.h"
 #include "m4math.h"
@@ -42,25 +40,13 @@
 
 #include <stack>
 
-#include <stack>
-
-#include <stack>
-
 class LLViewerTexture;
-class LLEdge;
 class LLFace;
 class LLViewerObject;
-class LLAgent;
-class LLDisplayPrimitive;
 class LLTextureEntry;
-class LLRenderFunc;
-class LLCubeMap;
 class LLCullResult;
 class LLVOAvatar;
 class LLGLSLShader;
-class LLCurlRequest;
-
-class LLMeshResponder;
 
 typedef enum e_avatar_skinning_method
 {
-- 
cgit v1.2.3


From 43f063fe2c814e28da69f2f5c373497a6d621460 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 9 May 2013 17:19:05 -0700
Subject: SH-4080 WIP interesting: random crash on Mac added controls for
 curtain delay

---
 indra/newview/app_settings/settings.xml | 24 +++++++++++++++++++++++-
 indra/newview/llviewerdisplay.cpp       | 10 ++++------
 indra/newview/llvieweroctree.cpp        |  2 +-
 3 files changed, 28 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 94a8550938..8a1c37d242 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -19,7 +19,7 @@
             <string>
                 Time before automatically setting AFK (away from keyboard) mode (seconds, 0=never).
                 Valid values are: 0, 120, 300, 600, 1800
-</string>
+    </string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -14117,5 +14117,27 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
+  <key>TeleportArrivalDelay</key>
+  <map>
+    <key>Comment</key>
+    <string>Time to wait before displaying world during teleport (seconds)</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>2</real>
+  </map>
+  <key>TeleportLocalDelay</key>
+  <map>
+    <key>Comment</key>
+    <string>Delay to prevent teleports after starting an in-sim teleport. (seconds)</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>1</real>
+  </map>
 </map>
 </llsd>
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 0889c3ec6c..970862892c 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -85,9 +85,6 @@ extern bool gShiftFrame;
 LLPointer<LLViewerTexture> gDisconnectedImagep = NULL;
 
 // used to toggle renderer back on after teleport
-const F32 TELEPORT_RENDER_DELAY = 20.f; // Max time a teleport is allowed to take before we raise the curtain
-const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived.
-const F32 TELEPORT_LOCAL_DELAY = 1.0f;  // Delay to prevent teleports after starting an in-sim teleport.
 BOOL		 gTeleportDisplay = FALSE;
 LLFrameTimer gTeleportDisplayTimer;
 LLFrameTimer gTeleportArrivalTimer;
@@ -373,7 +370,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	{
 		LLFastTimer t(FTM_TELEPORT_DISPLAY);
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport");
-		const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived.
+		static LLCachedControl<F32> teleport_arrival_delay(gSavedSettings, "TeleportArrivalDelay");
+		static LLCachedControl<F32> teleport_local_delay(gSavedSettings, "TeleportLocalDelay");
 
 		S32 attach_count = 0;
 		if (isAgentAvatarValid())
@@ -441,7 +439,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		case LLAgent::TELEPORT_ARRIVING:
 			// Make the user wait while content "pre-caches"
 			{
-				F32 arrival_fraction = (gTeleportArrivalTimer.getElapsedTimeF32() / TELEPORT_ARRIVAL_DELAY);
+				F32 arrival_fraction = (gTeleportArrivalTimer.getElapsedTimeF32() / teleport_arrival_delay());
 				if( arrival_fraction > 1.f )
 				{
 					arrival_fraction = 1.f;
@@ -458,7 +456,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			// Short delay when teleporting in the same sim (progress screen active but not shown - did not
 			// fall-through from TELEPORT_START)
 			{
-				if( gTeleportDisplayTimer.getElapsedTimeF32() > TELEPORT_LOCAL_DELAY )
+				if( gTeleportDisplayTimer.getElapsedTimeF32() > teleport_local_delay() )
 				{
 					//LLFirstUse::useTeleport();
 					gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 0eb1745cd5..0fa1f5bef3 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -331,7 +331,7 @@ LLviewerOctreeGroup::~LLviewerOctreeGroup()
 	{
 		LLViewerRegion::sCurRegionp->clearVisibleGroup(this);
 	}
-	llassert(LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false);
+	llassert(!LLViewerRegion::sCurRegionp || LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false);
 }
 
 LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) :
-- 
cgit v1.2.3


From 41b4374760dd060a7f51a4a837851d5a03b7242a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 10 May 2013 17:57:12 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 renamed LLView::handleVisibilityChange to onVisibilityChange to reflect
 standard naming conventions for handlers vs. reactors

---
 indra/newview/llfloaterregioninfo.cpp        | 2 +-
 indra/newview/llfloaterregioninfo.h          | 2 +-
 indra/newview/llmediactrl.cpp                | 2 +-
 indra/newview/llmediactrl.h                  | 2 +-
 indra/newview/llpanelnearbymedia.cpp         | 2 +-
 indra/newview/llpanelnearbymedia.h           | 2 +-
 indra/newview/llpanelplaceprofile.cpp        | 4 ++--
 indra/newview/llpanelplaceprofile.h          | 2 +-
 indra/newview/llpanelplaces.cpp              | 4 ++--
 indra/newview/llpanelplaces.h                | 2 +-
 indra/newview/llpanelvoicedevicesettings.cpp | 2 +-
 indra/newview/llpanelvoicedevicesettings.h   | 2 +-
 indra/newview/llpanelvolumepulldown.cpp      | 2 +-
 indra/newview/llpanelvolumepulldown.h        | 2 +-
 indra/newview/llsidepaneltaskinfo.cpp        | 2 +-
 indra/newview/llsidepaneltaskinfo.h          | 2 +-
 16 files changed, 18 insertions(+), 18 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 6cce013105..34c1127826 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -2865,7 +2865,7 @@ void LLPanelEnvironmentInfo::onOpen(const LLSD& key)
 }
 
 // virtual
-void LLPanelEnvironmentInfo::handleVisibilityChange(BOOL new_visibility)
+void LLPanelEnvironmentInfo::onVisibilityChange(BOOL new_visibility)
 {
 	// If hiding (user switched to another tab or closed the floater),
 	// display user's preferred environment.
diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h
index f0499f1903..dd961e21b2 100644
--- a/indra/newview/llfloaterregioninfo.h
+++ b/indra/newview/llfloaterregioninfo.h
@@ -402,7 +402,7 @@ public:
 	/*virtual*/ void onOpen(const LLSD& key);
 
 	// LLView
-	/*virtual*/ void handleVisibilityChange(BOOL new_visibility);
+	/*virtual*/ void onVisibilityChange(BOOL new_visibility);
 
 	// LLPanelRegionInfo
 	/*virtual*/ bool refreshFromRegion(LLViewerRegion* region);
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 99b4707158..b67ddf9b25 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -422,7 +422,7 @@ BOOL LLMediaCtrl::handleKeyHere( KEY key, MASK mask )
 
 ////////////////////////////////////////////////////////////////////////////////
 //
-void LLMediaCtrl::handleVisibilityChange ( BOOL new_visibility )
+void LLMediaCtrl::onVisibilityChange ( BOOL new_visibility )
 {
 	llinfos << "visibility changed to " << (new_visibility?"true":"false") << llendl;
 	if(mMediaSource)
diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h
index 7f2a5e1642..964ae08530 100644
--- a/indra/newview/llmediactrl.h
+++ b/indra/newview/llmediactrl.h
@@ -149,7 +149,7 @@ public:
 
 		// over-rides
 		virtual BOOL handleKeyHere( KEY key, MASK mask);
-		virtual void handleVisibilityChange ( BOOL new_visibility );
+		virtual void onVisibilityChange ( BOOL new_visibility );
 		virtual BOOL handleUnicodeCharHere(llwchar uni_char);
 		virtual void reshape( S32 width, S32 height, BOOL called_from_parent = TRUE);
 		virtual void draw();
diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp
index a50d9074f7..74c810ea79 100644
--- a/indra/newview/llpanelnearbymedia.cpp
+++ b/indra/newview/llpanelnearbymedia.cpp
@@ -202,7 +202,7 @@ void LLPanelNearByMedia::onTopLost()
 
 
 /*virtual*/ 
-void LLPanelNearByMedia::handleVisibilityChange ( BOOL new_visibility )
+void LLPanelNearByMedia::onVisibilityChange ( BOOL new_visibility )
 {
 	if (new_visibility)	
 	{
diff --git a/indra/newview/llpanelnearbymedia.h b/indra/newview/llpanelnearbymedia.h
index c3634de9b4..a9c1b190cf 100644
--- a/indra/newview/llpanelnearbymedia.h
+++ b/indra/newview/llpanelnearbymedia.h
@@ -48,7 +48,7 @@ public:
 	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
 	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
 	/*virtual*/ void onTopLost();
-	/*virtual*/ void handleVisibilityChange ( BOOL new_visibility );
+	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 	/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
 	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
 
diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp
index ce8057eead..b74547a9d7 100644
--- a/indra/newview/llpanelplaceprofile.cpp
+++ b/indra/newview/llpanelplaceprofile.cpp
@@ -302,9 +302,9 @@ void LLPanelPlaceProfile::processParcelInfo(const LLParcelData& parcel_data)
 }
 
 // virtual
-void LLPanelPlaceProfile::handleVisibilityChange(BOOL new_visibility)
+void LLPanelPlaceProfile::onVisibilityChange(BOOL new_visibility)
 {
-	LLPanel::handleVisibilityChange(new_visibility);
+	LLPanel::onVisibilityChange(new_visibility);
 
 	LLViewerParcelMgr* parcel_mgr = LLViewerParcelMgr::getInstance();
 	if (!parcel_mgr)
diff --git a/indra/newview/llpanelplaceprofile.h b/indra/newview/llpanelplaceprofile.h
index a33fc12ce4..01adfd4940 100644
--- a/indra/newview/llpanelplaceprofile.h
+++ b/indra/newview/llpanelplaceprofile.h
@@ -47,7 +47,7 @@ public:
 
 	/*virtual*/ void processParcelInfo(const LLParcelData& parcel_data);
 
-	/*virtual*/ void handleVisibilityChange(BOOL new_visibility);
+	/*virtual*/ void onVisibilityChange(BOOL new_visibility);
 
 	// Displays information about the currently selected parcel
 	// without sending a request to the server.
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index 6c2a01fc82..dc18cc6081 100644
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -998,9 +998,9 @@ void LLPanelPlaces::togglePlaceInfoPanel(BOOL visible)
 }
 
 // virtual
-void LLPanelPlaces::handleVisibilityChange(BOOL new_visibility)
+void LLPanelPlaces::onVisibilityChange(BOOL new_visibility)
 {
-	LLPanel::handleVisibilityChange(new_visibility);
+	LLPanel::onVisibilityChange(new_visibility);
 
 	if (!new_visibility && mPlaceInfoType == AGENT_INFO_TYPE)
 	{
diff --git a/indra/newview/llpanelplaces.h b/indra/newview/llpanelplaces.h
index 85bdc2c4e1..b6019ca32e 100644
--- a/indra/newview/llpanelplaces.h
+++ b/indra/newview/llpanelplaces.h
@@ -102,7 +102,7 @@ private:
 	void togglePickPanel(BOOL visible);
 	void togglePlaceInfoPanel(BOOL visible);
 
-	/*virtual*/ void handleVisibilityChange(BOOL new_visibility);
+	/*virtual*/ void onVisibilityChange(BOOL new_visibility);
 
 	void updateVerbs();
 
diff --git a/indra/newview/llpanelvoicedevicesettings.cpp b/indra/newview/llpanelvoicedevicesettings.cpp
index 6be2ea6481..1782afddd9 100644
--- a/indra/newview/llpanelvoicedevicesettings.cpp
+++ b/indra/newview/llpanelvoicedevicesettings.cpp
@@ -85,7 +85,7 @@ BOOL LLPanelVoiceDeviceSettings::postBuild()
 }
 
 // virtual
-void LLPanelVoiceDeviceSettings::handleVisibilityChange ( BOOL new_visibility )
+void LLPanelVoiceDeviceSettings::onVisibilityChange ( BOOL new_visibility )
 {
 	if (new_visibility)
 	{
diff --git a/indra/newview/llpanelvoicedevicesettings.h b/indra/newview/llpanelvoicedevicesettings.h
index ba3bcad0dc..83464f476a 100644
--- a/indra/newview/llpanelvoicedevicesettings.h
+++ b/indra/newview/llpanelvoicedevicesettings.h
@@ -44,7 +44,7 @@ public:
 	void initialize();
 	void cleanup();
 
-	/*virtual*/ void handleVisibilityChange ( BOOL new_visibility );
+	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 
 	void setUseTuningMode(bool use) { mUseTuningMode = use; };
 	
diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp
index aea7b33d7f..cb00f742cc 100644
--- a/indra/newview/llpanelvolumepulldown.cpp
+++ b/indra/newview/llpanelvolumepulldown.cpp
@@ -87,7 +87,7 @@ void LLPanelVolumePulldown::onMouseLeave(S32 x, S32 y, MASK mask)
 }
 
 /*virtual*/ 
-void LLPanelVolumePulldown::handleVisibilityChange ( BOOL new_visibility )
+void LLPanelVolumePulldown::onVisibilityChange ( BOOL new_visibility )
 {
 	if (new_visibility)	
 	{
diff --git a/indra/newview/llpanelvolumepulldown.h b/indra/newview/llpanelvolumepulldown.h
index 0d86e6bd28..b843fab756 100644
--- a/indra/newview/llpanelvolumepulldown.h
+++ b/indra/newview/llpanelvolumepulldown.h
@@ -42,7 +42,7 @@ class LLPanelVolumePulldown : public LLPanel
 	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
 	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
 	/*virtual*/ void onTopLost();
-	/*virtual*/ void handleVisibilityChange ( BOOL new_visibility );
+	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 	/*virtual*/ BOOL postBuild();
 	
  private:
diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp
index 986ac14140..191e0abefd 100644
--- a/indra/newview/llsidepaneltaskinfo.cpp
+++ b/indra/newview/llsidepaneltaskinfo.cpp
@@ -162,7 +162,7 @@ BOOL LLSidepanelTaskInfo::postBuild()
 	return TRUE;
 }
 
-/*virtual*/ void LLSidepanelTaskInfo::handleVisibilityChange ( BOOL visible )
+/*virtual*/ void LLSidepanelTaskInfo::onVisibilityChange ( BOOL visible )
 {
 	if (visible)
 	{
diff --git a/indra/newview/llsidepaneltaskinfo.h b/indra/newview/llsidepaneltaskinfo.h
index 05edcda5ed..a1479ef0e7 100644
--- a/indra/newview/llsidepaneltaskinfo.h
+++ b/indra/newview/llsidepaneltaskinfo.h
@@ -50,7 +50,7 @@ public:
 	virtual ~LLSidepanelTaskInfo();
 
 	/*virtual*/	BOOL postBuild();
-	/*virtual*/ void handleVisibilityChange ( BOOL new_visibility );
+	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 
 	void setObjectSelection(LLObjectSelectionHandle selection);
 
-- 
cgit v1.2.3


From 3a0e45ff088278cba5314974be6539b05009b8da Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 10 May 2013 17:57:12 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 renamed LLView::handleVisibilityChange to onVisibilityChange to reflect
 standard naming conventions for handlers vs. reactors

---
 indra/newview/app_settings/settings.xml |  11 ++
 indra/newview/llagent.cpp               |   8 --
 indra/newview/llagent.h                 |   1 -
 indra/newview/llfloaterbuyland.cpp      |   4 +-
 indra/newview/llfloaterland.cpp         |   4 +-
 indra/newview/llfloaterland.h           |   2 +-
 indra/newview/llimfloater.cpp           |   2 +-
 indra/newview/llimfloater.h             |   2 +-
 indra/newview/llmediactrl.cpp           |   4 +-
 indra/newview/llmediactrl.h             |   2 +-
 indra/newview/llpaneloutfitedit.cpp     |   4 +-
 indra/newview/llpaneloutfitedit.h       |   2 +-
 indra/newview/llpaneltopinfobar.cpp     |   4 +-
 indra/newview/llpaneltopinfobar.h       |   2 +-
 indra/newview/llpreviewgesture.cpp      |   4 +-
 indra/newview/llpreviewgesture.h        |   2 +-
 indra/newview/llscenemonitor.cpp        | 183 +++++++++++++++-----------------
 indra/newview/llscenemonitor.h          |  22 ++--
 indra/newview/llsidepanelappearance.cpp |   4 +-
 indra/newview/llsidepanelappearance.h   |   2 +-
 20 files changed, 128 insertions(+), 141 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 8a1c37d242..ed8d0bf10d 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9469,6 +9469,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>SceneLoadingMonitorSampleTime</key>
+    <map>
+      <key>Comment</key>
+      <string>Time between screen samples when monitor scene load (seconds)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>1</real>
+    </map>
     <key>ScriptHelpFollowsCursor</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 2e0fc039c4..6b996edb76 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -1046,14 +1046,6 @@ const LLVector3d &LLAgent::getPositionGlobal() const
 	return mPositionGlobal;
 }
 
-bool LLAgent::isPositionChanged() const
-{
-	LLVector3d diff;
-	diff = mPositionGlobal - mLastPositionGlobal;
-	
-	return diff.lengthSquared() > 1.0;
-}
-
 //-----------------------------------------------------------------------------
 // getPositionAgent()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index f8dcfb9789..46dad1dc20 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -252,7 +252,6 @@ public:
 	const LLVector3d &getLastPositionGlobal() const { return mLastPositionGlobal; }
 	void			setLastPositionGlobal(const LLVector3d &pos) { mLastPositionGlobal = pos; }
 
-	bool            isPositionChanged() const;
 private:
 	std::set<U64>	mRegionsVisited;		// Stat - what distinct regions has the avatar been to?
 	F64				mDistanceTraveled;		// Stat - how far has the avatar moved?
diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp
index 8223e89b64..c1cea58801 100644
--- a/indra/newview/llfloaterbuyland.cpp
+++ b/indra/newview/llfloaterbuyland.cpp
@@ -202,7 +202,7 @@ public:
 	virtual void draw();
 	virtual BOOL canClose();
 
-	void onVisibilityChange ( const LLSD& new_visibility );
+	void onVisibilityChanged ( const LLSD& new_visibility );
 	
 };
 
@@ -1008,7 +1008,7 @@ BOOL LLFloaterBuyLandUI::canClose()
 	return can_close;
 }
 
-void LLFloaterBuyLandUI::onVisibilityChange ( const LLSD& new_visibility )
+void LLFloaterBuyLandUI::onVisibilityChanged ( const LLSD& new_visibility )
 {
 	if (new_visibility.asBoolean())
 	{
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index be743d57d2..a2675d6d3e 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -225,7 +225,7 @@ void LLFloaterLand::onOpen(const LLSD& key)
 	refresh();
 }
 
-void LLFloaterLand::onVisibilityChange(const LLSD& visible)
+void LLFloaterLand::onVisibilityChanged(const LLSD& visible)
 {
 	if (!visible.asBoolean())
 	{
@@ -255,7 +255,7 @@ LLFloaterLand::LLFloaterLand(const LLSD& seed)
 
 BOOL LLFloaterLand::postBuild()
 {	
-	setVisibleCallback(boost::bind(&LLFloaterLand::onVisibilityChange, this, _2));
+	setVisibleCallback(boost::bind(&LLFloaterLand::onVisibilityChanged, this, _2));
 	
 	LLTabContainer* tab = getChild<LLTabContainer>("landtab");
 
diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h
index 4f1c10274a..dccdfc9acb 100644
--- a/indra/newview/llfloaterland.h
+++ b/indra/newview/llfloaterland.h
@@ -88,7 +88,7 @@ private:
 	LLFloaterLand(const LLSD& seed);
 	virtual ~LLFloaterLand();
 		
-	void onVisibilityChange(const LLSD& visible);
+	void onVisibilityChanged(const LLSD& visible);
 
 protected:
 
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index f68012e306..f27eaba760 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -165,7 +165,7 @@ void LLIMFloater::newIMCallback(const LLSD& data){
 	}
 }
 
-void LLIMFloater::onVisibilityChange(const LLSD& new_visibility)
+void LLIMFloater::onVisibilityChanged(const LLSD& new_visibility)
 {
 	bool visible = new_visibility.asBoolean();
 
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index f7cd35b5eb..9bdcc113d6 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -88,7 +88,7 @@ public:
 	// called when docked floater's position has been set by chiclet
 	void setPositioned(bool b) { mPositioned = b; };
 
-	void onVisibilityChange(const LLSD& new_visibility);
+	void onVisibilityChanged(const LLSD& new_visibility);
 	void processIMTyping(const LLIMInfo* im_info, BOOL typing);
 	void processAgentListUpdates(const LLSD& body);
 	void processSessionUpdate(const LLSD& session_update);
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index b67ddf9b25..baf5a3a839 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -392,7 +392,7 @@ BOOL LLMediaCtrl::postBuild ()
 
 	mContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>(
 		"menu_media_ctrl.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance());
-	setVisibleCallback(boost::bind(&LLMediaCtrl::onVisibilityChange, this, _2));
+	setVisibleCallback(boost::bind(&LLMediaCtrl::onVisibilityChanged, this, _2));
 
 	return TRUE;
 }
@@ -450,7 +450,7 @@ BOOL LLMediaCtrl::handleUnicodeCharHere(llwchar uni_char)
 
 ////////////////////////////////////////////////////////////////////////////////
 //
-void LLMediaCtrl::onVisibilityChange ( const LLSD& new_visibility )
+void LLMediaCtrl::onVisibilityChanged ( const LLSD& new_visibility )
 {
 	// set state of frequent updates automatically if visibility changes
 	if ( new_visibility.asBoolean() )
diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h
index 964ae08530..db501cdb8c 100644
--- a/indra/newview/llmediactrl.h
+++ b/indra/newview/llmediactrl.h
@@ -171,7 +171,7 @@ public:
 		void convertInputCoords(S32& x, S32& y);
 
 	private:
-		void onVisibilityChange ( const LLSD& new_visibility );
+		void onVisibilityChanged ( const LLSD& new_visibility );
 		void onPopup(const LLSD& notification, const LLSD& response);
 
 		const S32 mTextureDepthBytes;
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 36234b9536..26496ec9e2 100644
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -488,7 +488,7 @@ BOOL LLPanelOutfitEdit::postBuild()
 	childSetCommitCallback("shop_btn_1", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL);
 	childSetCommitCallback("shop_btn_2", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL);
 
-	setVisibleCallback(boost::bind(&LLPanelOutfitEdit::onVisibilityChange, this, _2));
+	setVisibleCallback(boost::bind(&LLPanelOutfitEdit::onVisibilityChanged, this, _2));
 
 	mWearablesGearMenuBtn = getChild<LLMenuButton>("wearables_gear_menu_btn");
 	mGearMenuBtn = getChild<LLMenuButton>("gear_menu_btn");
@@ -774,7 +774,7 @@ void LLPanelOutfitEdit::onPlusBtnClicked(void)
 	}
 }
 
-void LLPanelOutfitEdit::onVisibilityChange(const LLSD &in_visible_chain)
+void LLPanelOutfitEdit::onVisibilityChanged(const LLSD &in_visible_chain)
 {
 	showAddWearablesPanel(false);
 	mWearableItemsList->resetSelection();
diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h
index 5d4b8d4644..30870daf40 100644
--- a/indra/newview/llpaneloutfitedit.h
+++ b/indra/newview/llpaneloutfitedit.h
@@ -145,7 +145,7 @@ public:
 	void updatePlusButton();
 	void onPlusBtnClicked(void);
 
-	void onVisibilityChange(const LLSD &in_visible_chain);
+	void onVisibilityChanged(const LLSD &in_visible_chain);
 
 	void applyFolderViewFilter(EFolderViewItemType type);
 	void applyListViewFilter(EListViewItemType type);
diff --git a/indra/newview/llpaneltopinfobar.cpp b/indra/newview/llpaneltopinfobar.cpp
index 1830086da2..fa371bd0ca 100644
--- a/indra/newview/llpaneltopinfobar.cpp
+++ b/indra/newview/llpaneltopinfobar.cpp
@@ -169,7 +169,7 @@ BOOL LLPanelTopInfoBar::postBuild()
 	mParcelMgrConnection = LLViewerParcelMgr::getInstance()->addAgentParcelChangedCallback(
 			boost::bind(&LLPanelTopInfoBar::onAgentParcelChange, this));
 
-	setVisibleCallback(boost::bind(&LLPanelTopInfoBar::onVisibilityChange, this, _2));
+	setVisibleCallback(boost::bind(&LLPanelTopInfoBar::onVisibilityChanged, this, _2));
 
 	return TRUE;
 }
@@ -186,7 +186,7 @@ void LLPanelTopInfoBar::onNavBarShowParcelPropertiesCtrlChanged()
 
 // when panel is shown, all minimized floaters should be shifted downwards to prevent overlapping of
 // PanelTopInfoBar. See EXT-7951.
-void LLPanelTopInfoBar::onVisibilityChange(const LLSD& show)
+void LLPanelTopInfoBar::onVisibilityChanged(const LLSD& show)
 {
 	// this height is used as a vertical offset for ALREADY MINIMIZED floaters
 	// when PanelTopInfoBar visibility changes
diff --git a/indra/newview/llpaneltopinfobar.h b/indra/newview/llpaneltopinfobar.h
index d58d95be90..f37bd9c048 100644
--- a/indra/newview/llpaneltopinfobar.h
+++ b/indra/newview/llpaneltopinfobar.h
@@ -57,7 +57,7 @@ public:
 	/**
 	 * Called when the top info bar gets shown or hidden
 	 */
-	void onVisibilityChange(const LLSD& show);
+	void onVisibilityChanged(const LLSD& show);
 
 	boost::signals2::connection setResizeCallback( const resize_signal_t::slot_type& cb );
 
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index cbb4d5f964..bda603262d 100644
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -253,7 +253,7 @@ void LLPreviewGesture::onUpdateSucceeded()
 	refresh();
 }
 
-void LLPreviewGesture::onVisibilityChange ( const LLSD& new_visibility )
+void LLPreviewGesture::onVisibilityChanged ( const LLSD& new_visibility )
 {
 	if (new_visibility.asBoolean())
 	{
@@ -333,7 +333,7 @@ LLPreviewGesture::~LLPreviewGesture()
 
 BOOL LLPreviewGesture::postBuild()
 {
-	setVisibleCallback(boost::bind(&LLPreviewGesture::onVisibilityChange, this, _2));
+	setVisibleCallback(boost::bind(&LLPreviewGesture::onVisibilityChanged, this, _2));
 	
 	LLLineEditor* edit;
 	LLComboBox* combo;
diff --git a/indra/newview/llpreviewgesture.h b/indra/newview/llpreviewgesture.h
index fd4fcf9d8f..7ce5706a0d 100644
--- a/indra/newview/llpreviewgesture.h
+++ b/indra/newview/llpreviewgesture.h
@@ -102,7 +102,7 @@ protected:
 	// "Sound", "Chat", or "Wait"
 	LLScrollListItem* addStep(const enum EStepType step_type);
 	
-	void onVisibilityChange ( const LLSD& new_visibility );
+	void onVisibilityChanged ( const LLSD& new_visibility );
 	
 	static std::string getLabel(std::vector<std::string> labels);
 	static void updateLabel(LLScrollListItem* item);
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 7f7e61cc88..5a5fd6f333 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -56,18 +56,16 @@ LLSceneMonitorView* gSceneMonitorView = NULL;
 //
 
 LLSceneMonitor::LLSceneMonitor() : 
-	mEnabled(FALSE), 
+	mEnabled(false), 
 	mDiff(NULL),
 	mDiffResult(0.f),
 	mDiffTolerance(0.1f),
-	mCurTarget(NULL), 
-	mNeedsUpdateDiff(FALSE),
-	mHasNewDiff(FALSE),
-	mHasNewQueryResult(FALSE),
-	mDebugViewerVisible(FALSE),
-	mQuitting(FALSE),
+	mNeedsUpdateDiff(false),
+	mHasNewDiff(false),
+	mHasNewQueryResult(false),
+	mDebugViewerVisible(false),
+	mQuitting(false),
 	mQueryObject(0),
-	mSamplingTime(1.0f),
 	mDiffPixelRatio(0.5f)
 {
 	mFrames[0] = NULL;
@@ -79,7 +77,7 @@ LLSceneMonitor::LLSceneMonitor() :
 
 LLSceneMonitor::~LLSceneMonitor()
 {
-	mQuitting = TRUE;
+	mQuitting = true;
 	destroyClass();
 }
 
@@ -101,7 +99,6 @@ void LLSceneMonitor::reset()
 	mFrames[0] = NULL;
 	mFrames[1] = NULL;
 	mDiff = NULL;
-	mCurTarget = NULL;
 
 	unfreezeScene();
 
@@ -173,54 +170,15 @@ void LLSceneMonitor::generateDitheringTexture(S32 width, S32 height)
 	mDitherScaleT = (F32)height / mDitherMatrixWidth;
 }
 
-void LLSceneMonitor::setDebugViewerVisible(BOOL visible) 
+void LLSceneMonitor::setDebugViewerVisible(bool visible) 
 {
 	mDebugViewerVisible = visible;
 }
 
-bool LLSceneMonitor::preCapture()
+LLRenderTarget& LLSceneMonitor::getCaptureTarget()
 {
-	static LLCachedControl<bool> monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled");
-	static LLFrameTimer timer;	
-
-	mCurTarget = NULL;
-	if (!LLGLSLShader::sNoFixedFunction)
-	{
-		return false;
-	}
-
-	BOOL enabled = (BOOL)monitor_enabled || mDebugViewerVisible;
-	if(mEnabled != enabled)
-	{
-		if(mEnabled)
-		{
-			reset();
-			unfreezeScene();
-		}
-		else
-		{
-			freezeScene();
-		}
-
-		mEnabled = enabled;
-	}
-
-	if(!mEnabled)
-	{
-		return false;
-	}
-
-	if(gAgent.isPositionChanged())
-	{
-		mRecording->reset();
-	}
+	LLRenderTarget* cur_target = NULL;
 
-	if(timer.getElapsedTimeF32() < mSamplingTime)
-	{
-		return false;
-	}
-	timer.reset();
-	
 	S32 width = gViewerWindow->getWorldViewWidthRaw();
 	S32 height = gViewerWindow->getWorldViewHeightRaw();
 	
@@ -232,7 +190,7 @@ bool LLSceneMonitor::preCapture()
 		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 
-		mCurTarget = mFrames[0];
+		cur_target = mFrames[0];
 	}
 	else if(!mFrames[1])
 	{
@@ -242,21 +200,22 @@ bool LLSceneMonitor::preCapture()
 		gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
 		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 
-		mCurTarget = mFrames[1];
+		cur_target = mFrames[1];
 	}
 	else //swap
 	{
-		mCurTarget = mFrames[0];
+		cur_target = mFrames[0];
 		mFrames[0] = mFrames[1];
-		mFrames[1] = mCurTarget;
+		mFrames[1] = cur_target;
 	}
 	
-	if(mCurTarget->getWidth() != width || mCurTarget->getHeight() != height) //size changed
+	if(cur_target->getWidth() != width || cur_target->getHeight() != height) //size changed
 	{
-		mCurTarget->resize(width, height, GL_RGB);
+		cur_target->resize(width, height, GL_RGB);
 	}
 
-	return true;
+	// we're promising the target exists
+	return *cur_target;
 }
 
 void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp)
@@ -308,33 +267,56 @@ void LLSceneMonitor::unfreezeScene()
 void LLSceneMonitor::capture()
 {
 	static U32 last_capture_time = 0;
+	static LLCachedControl<bool> monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled");
+	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
+	static LLFrameTimer timer;	
 
-	if(last_capture_time == gFrameCount)
+	LLTrace::Recording* last_frame_recording = LLTrace::get_frame_recording()->getPrevRecording();
+	if (last_frame_recording->getMax(LLViewerCamera::getVelocityStat()) > 0.001f
+		|| last_frame_recording->getMax(LLViewerCamera::getAngularVelocityStat() > 0.01f)
 	{
-		return;
+		mRecording->reset();
 	}
-	last_capture_time = gFrameCount;
 
-	preCapture();
-
-	if(!mCurTarget)
+	bool enabled = monitor_enabled || mDebugViewerVisible;
+	if(mEnabled != enabled)
 	{
-		return;
+		if(mEnabled)
+		{
+			reset();
+			unfreezeScene();
+		}
+		else
+		{
+			freezeScene();
+		}
+
+		mEnabled = enabled;
 	}
-	
-	U32 old_FBO = LLRenderTarget::sCurFBO;
 
-	gGL.getTexUnit(0)->bind(mCurTarget);
-	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer.
+	if(timer.getElapsedTimeF32() > scene_load_sample_time()
+		&& mEnabled
+		&& LLGLShader::sNoFixedFunction
+		&& last_capture_time != gFrameCount)
+	{
+		timer.reset();
+		last_capture_time = gFrameCount;
+
+		LLRenderTarget& cur_target = getCaptureTarget();
+
+		U32 old_FBO = LLRenderTarget::sCurFBO;
+
+		gGL.getTexUnit(0)->bind(&cur_target);
+		glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); //point to the main frame buffer.
 		
-	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, mCurTarget->getWidth(), mCurTarget->getHeight()); //copy the content
+		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, cur_target.getWidth(), cur_target.getHeight()); //copy the content
 	
-	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
-	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);		
-	glBindFramebuffer(GL_FRAMEBUFFER, old_FBO);
+		glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);		
+		glBindFramebuffer(GL_FRAMEBUFFER, old_FBO);
 
-	mCurTarget = NULL;
-	mNeedsUpdateDiff = TRUE;
+		mNeedsUpdateDiff = true;
+	}
 }
 
 bool LLSceneMonitor::needsUpdate() const
@@ -342,27 +324,33 @@ bool LLSceneMonitor::needsUpdate() const
 	return mNeedsUpdateDiff;
 }
 
+static LLFastTimer::DeclareTimer FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture");
+static LLFastTimer::DeclareTimer FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Diff");
+
 void LLSceneMonitor::compare()
 {
 	if(!mNeedsUpdateDiff)
 	{
 		return;
 	}
-	mNeedsUpdateDiff = FALSE;
+	mNeedsUpdateDiff = false;
 
 	if(!mFrames[0] || !mFrames[1])
 	{
 		return;
 	}
 	if(mFrames[0]->getWidth() != mFrames[1]->getWidth() || mFrames[0]->getHeight() != mFrames[1]->getHeight())
-	{
-		return; //size does not match
+	{	//size does not match
+		return; 
 	}
 
+	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
+
 	S32 width = gViewerWindow->getWindowWidthRaw();
 	S32 height = gViewerWindow->getWindowHeightRaw();
 	if(!mDiff)
 	{
+		LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE);
 		mDiff = new LLRenderTarget();
 		mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true);
 
@@ -370,6 +358,7 @@ void LLSceneMonitor::compare()
 	}
 	else if(mDiff->getWidth() != width || mDiff->getHeight() != height)
 	{
+		LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE);
 		mDiff->resize(width, height, GL_RGBA);
 		generateDitheringTexture(width, height);
 	}
@@ -411,9 +400,8 @@ void LLSceneMonitor::compare()
 	gGL.getTexUnit(2)->disable();
 	gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE);
 
-	mHasNewDiff = TRUE;
+	mHasNewDiff = true;
 	
-	//send out the query request.
 	queryDiff();
 }
 
@@ -430,6 +418,8 @@ void LLSceneMonitor::queryDiff()
 //calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it.
 void LLSceneMonitor::calcDiffAggregate()
 {
+	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
+
 	if(!mHasNewDiff && !mDebugViewerVisible)
 	{
 		return;
@@ -462,8 +452,8 @@ void LLSceneMonitor::calcDiffAggregate()
 	if(mHasNewDiff)
 	{
 		glEndQueryARB(GL_SAMPLES_PASSED_ARB);
-		mHasNewDiff = FALSE;	
-		mHasNewQueryResult = TRUE;
+		mHasNewDiff = false;	
+		mHasNewQueryResult = true;
 	}
 		
 	gOneTextureFilterProgram.unbind();
@@ -482,11 +472,13 @@ void LLSceneMonitor::calcDiffAggregate()
 static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference");
 void LLSceneMonitor::fetchQueryResult()
 {
+	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
+
 	if(!mHasNewQueryResult)
 	{
 		return;
 	}
-	mHasNewQueryResult = FALSE;
+	mHasNewQueryResult = false;
 
 	GLuint available = 0;
 	glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available);
@@ -500,25 +492,22 @@ void LLSceneMonitor::fetchQueryResult()
 	
 	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
-	addMonitorResult();
-}
+	sample(sFramePixelDiff, mDiffResult);
 
-void LLSceneMonitor::addMonitorResult()
-{
 	const F32 diff_threshold = 0.001f;
-	if(mDiffResult < diff_threshold)
+	if(mDiffResult > diff_threshold)
 	{
-		return;
-	}
-
 		mRecording->extend();
-		sample(sFramePixelDiff, mDiffResult);
+	}
+}
 
+void LLSceneMonitor::addMonitorResult()
+{
 	ll_monitor_result_t result;
 	result.mTimeStamp = LLImageGL::sLastFrameTime;
 	result.mDiff = mDiffResult;
 	mMonitorResults.push_back(result);
-	}
+}
 
 //dump results to a file _scene_monitor_results.csv
 void LLSceneMonitor::dumpToFile(std::string file_name)
@@ -563,12 +552,10 @@ void LLSceneMonitorView::onClickCloseBtn()
 	setVisible(false);	
 }
 
-void LLSceneMonitorView::setVisible(BOOL visible)
+void LLSceneMonitorView::onVisibilityChange(BOOL visible)
 {
 	visible = visible && LLGLSLShader::sNoFixedFunction;
 	LLSceneMonitor::getInstance()->setDebugViewerVisible(visible);
-
-	LLView::setVisible(visible);
 }
 
 void LLSceneMonitorView::draw()
@@ -608,7 +595,7 @@ void LLSceneMonitorView::draw()
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
 	lines++;
 
-	num_str = llformat("Sampling time: %.3f seconds", LLSceneMonitor::getInstance()->getSamplingTime());
+	num_str = llformat("Sampling time: %.3f seconds", gSavedSettings->getF32("SceneLoadingMonitorSampleTime"));
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
 	lines++;
 
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 45a5241924..08d2335a90 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -46,7 +46,7 @@ public:
 	void destroyClass();
 	
 	void freezeAvatar(LLCharacter* avatarp);
-	void setDebugViewerVisible(BOOL visible);
+	void setDebugViewerVisible(bool visible);
 
 	void capture(); //capture the main frame buffer
 	void compare(); //compare the stored two buffers.	
@@ -58,7 +58,6 @@ public:
 	const LLRenderTarget* getDiffTarget() const {return mDiff;}
 	F32  getDiffTolerance() const {return mDiffTolerance;}
 	F32  getDiffResult() const { return mDiffResult;}
-	F32  getSamplingTime() const { return mSamplingTime;}
 	F32  getDiffPixelRatio() const { return mDiffPixelRatio;}
 	bool isEnabled()const {return mEnabled;}
 	bool needsUpdate() const;
@@ -71,27 +70,25 @@ private:
 	void freezeScene();
 	void unfreezeScene();
 	void reset();
-	bool preCapture();
+	LLRenderTarget& getCaptureTarget();
 	void generateDitheringTexture(S32 width, S32 height);
 
 	void addMonitorResult();
 private:
-	BOOL mEnabled;
-	BOOL mNeedsUpdateDiff;
-	BOOL mHasNewDiff;
-	BOOL mHasNewQueryResult;
-	BOOL mDebugViewerVisible;
-	BOOL mQuitting;
+	bool mEnabled;
+	bool mNeedsUpdateDiff;
+	bool mHasNewDiff;
+	bool mHasNewQueryResult;
+	bool mDebugViewerVisible;
+	bool mQuitting;
 
 	LLRenderTarget* mFrames[2];
 	LLRenderTarget* mDiff;
-	LLRenderTarget* mCurTarget;
 
 	GLuint  mQueryObject; //used for glQuery
 	F32     mDiffResult;  //aggregate results of mDiff.
 	F32     mDiffTolerance; //pixels are filtered out when R+G+B < mDiffTolerance
 
-	F32     mSamplingTime; //time interval to capture frames, in seconds
 	F32     mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension
 
 	LLPointer<LLViewerTexture> mDitheringTexture;
@@ -119,7 +116,8 @@ public:
 	LLSceneMonitorView(const LLRect& rect);
 
 	virtual void draw();
-	virtual void setVisible(BOOL visible);
+
+	virtual void onVisibilityChange(BOOL visible);
 
 protected:
 	virtual void onClickCloseBtn();
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index d909a218e3..e0fb09d86d 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -142,7 +142,7 @@ BOOL LLSidepanelAppearance::postBuild()
 	mCurrOutfitPanel = getChild<LLPanel>("panel_currentlook");
 
 
-	setVisibleCallback(boost::bind(&LLSidepanelAppearance::onVisibilityChange,this,_2));
+	setVisibleCallback(boost::bind(&LLSidepanelAppearance::onVisibilityChanged,this,_2));
 
 	return TRUE;
 }
@@ -181,7 +181,7 @@ void LLSidepanelAppearance::onOpen(const LLSD& key)
 	mOpened = true;
 }
 
-void LLSidepanelAppearance::onVisibilityChange(const LLSD &new_visibility)
+void LLSidepanelAppearance::onVisibilityChanged(const LLSD &new_visibility)
 {
 	LLSD visibility;
 	visibility["visible"] = new_visibility.asBoolean();
diff --git a/indra/newview/llsidepanelappearance.h b/indra/newview/llsidepanelappearance.h
index 6dd3520266..8564827a17 100644
--- a/indra/newview/llsidepanelappearance.h
+++ b/indra/newview/llsidepanelappearance.h
@@ -67,7 +67,7 @@ public:
 
 private:
 	void onFilterEdit(const std::string& search_string);
-	void onVisibilityChange ( const LLSD& new_visibility );
+	void onVisibilityChanged ( const LLSD& new_visibility );
 
 	void onOpenOutfitButtonClicked();
 	void onEditAppearanceButtonClicked();
-- 
cgit v1.2.3


From edf731c180a61dc49255ebb25342b6256e8d6065 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 10 May 2013 22:24:18 -0700
Subject: BUILDFIX - bad logic in scene monitor frame recording

---
 indra/newview/llscenemonitor.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 5a5fd6f333..2e819c8efe 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -271,9 +271,9 @@ void LLSceneMonitor::capture()
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static LLFrameTimer timer;	
 
-	LLTrace::Recording* last_frame_recording = LLTrace::get_frame_recording()->getPrevRecording();
-	if (last_frame_recording->getMax(LLViewerCamera::getVelocityStat()) > 0.001f
-		|| last_frame_recording->getMax(LLViewerCamera::getAngularVelocityStat() > 0.01f)
+	LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording();
+	if (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f
+		|| last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f)
 	{
 		mRecording->reset();
 	}
@@ -296,7 +296,7 @@ void LLSceneMonitor::capture()
 
 	if(timer.getElapsedTimeF32() > scene_load_sample_time()
 		&& mEnabled
-		&& LLGLShader::sNoFixedFunction
+		&& LLGLSLShader::sNoFixedFunction
 		&& last_capture_time != gFrameCount)
 	{
 		timer.reset();
@@ -595,7 +595,7 @@ void LLSceneMonitorView::draw()
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
 	lines++;
 
-	num_str = llformat("Sampling time: %.3f seconds", gSavedSettings->getF32("SceneLoadingMonitorSampleTime"));
+	num_str = llformat("Sampling time: %.3f seconds", gSavedSettings.getF32("SceneLoadingMonitorSampleTime"));
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
 	lines++;
 
-- 
cgit v1.2.3


From 405aa5b1ba7b786da05136fc9cc1f0a664111ce8 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 13 May 2013 11:04:10 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 added log output for scene monitoring

---
 indra/newview/llscenemonitor.cpp | 14 ++++----------
 indra/newview/llscenemonitor.h   |  2 +-
 2 files changed, 5 insertions(+), 11 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 2e819c8efe..9546c786d1 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -50,7 +50,7 @@ LLSceneMonitorView* gSceneMonitorView = NULL;
 //2, (?) disable all sky and water;
 //3, capture frames periodically, by calling "capture()";
 //4, compute pixel differences between two latest captured frames, by calling "compare()", results are stored at mDiff;
-//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "queryDiff() -> calcDiffAggregate()";
+//5, compute the number of pixels in mDiff above some tolerance threshold in GPU, by calling "calcDiffAggregate()";
 //6, use gl occlusion query to fetch the result from GPU, by calling "fetchQueryResult()";
 //END.
 //
@@ -402,17 +402,10 @@ void LLSceneMonitor::compare()
 
 	mHasNewDiff = true;
 	
-	queryDiff();
-}
-
-void LLSceneMonitor::queryDiff()
-{
-	if(mDebugViewerVisible)
+	if (!mDebugViewerVisible)
 	{
-		return;
+		calcDiffAggregate();
 	}
-
-	calcDiffAggregate();
 }
 
 //calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it.
@@ -492,6 +485,7 @@ void LLSceneMonitor::fetchQueryResult()
 	
 	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
+	LL_DEBUGS("SceneMonitor") << "Frame difference: " << mDiffResult << LL_ENDL;
 	sample(sFramePixelDiff, mDiffResult);
 
 	const F32 diff_threshold = 0.001f;
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 08d2335a90..6dccbbe335 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -39,6 +39,7 @@ class LLViewerTexture;
 
 class LLSceneMonitor :  public LLSingleton<LLSceneMonitor>
 {
+	LOG_CLASS(LLSceneMonitor);
 public:
 	LLSceneMonitor();
 	~LLSceneMonitor();
@@ -50,7 +51,6 @@ public:
 
 	void capture(); //capture the main frame buffer
 	void compare(); //compare the stored two buffers.	
-	void queryDiff();	
 	void fetchQueryResult();
 	void calcDiffAggregate();
 	void setDiffTolerance(F32 tol) {mDiffTolerance = tol;}
-- 
cgit v1.2.3


From 35f1fcc399f07571fc6b7d7af00e7d4e1e07418d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 13 May 2013 11:44:42 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 improved precision of scene diff log output

---
 indra/newview/llscenemonitor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 9546c786d1..3d8e1513dd 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -485,7 +485,7 @@ void LLSceneMonitor::fetchQueryResult()
 	
 	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
-	LL_DEBUGS("SceneMonitor") << "Frame difference: " << mDiffResult << LL_ENDL;
+	LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
 	sample(sFramePixelDiff, mDiffResult);
 
 	const F32 diff_threshold = 0.001f;
-- 
cgit v1.2.3


From 12c34dc30f0cb6270c11e100fcaceb3fa6b27e81 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 16 May 2013 00:53:01 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 renamed LLView::handleVisibilityChange to onVisibilityChange to reflect
 cleaned up scene monitor stats recording, now all trace stats dumped to csv
 also fixed extendablerecording, periodicrecording, etc. to properly implement
 start/stop/etc

---
 indra/newview/app_settings/settings.xml |  25 +++-
 indra/newview/llappviewer.cpp           |  11 +-
 indra/newview/llscenemonitor.cpp        | 196 +++++++++++++++++++++++---------
 indra/newview/llscenemonitor.h          |  15 ++-
 indra/newview/llstartup.cpp             |   6 +-
 indra/newview/llworld.cpp               |   2 +-
 6 files changed, 186 insertions(+), 69 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ed8d0bf10d..94f032be67 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6847,6 +6847,17 @@
       <string>F32</string>
       <key>Value</key>
       <real>6.0</real>
+    </map>
+    <key>ClothingLoadingDelay</key>
+    <map>
+      <key>Comment</key>
+      <string>Time to wait for avatar appearance to resolve before showing world (seconds)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>10.0</real>
     </map>
 	<key>PreferredMaturity</key>
     <map>
@@ -7403,7 +7414,6 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
-
   <key>OctreeMaxNodeCapacity</key>
   <map>
     <key>Comment</key>
@@ -9478,7 +9488,18 @@
       <key>Type</key>
       <string>F32</string>
       <key>Value</key>
-      <real>1</real>
+      <real>0.25</real>
+    </map>
+    <key>SceneLoadingPixelDiffThreshold</key>
+    <map>
+      <key>Comment</key>
+      <string>Amount of pixels changed required to consider the scene as still loading (fraction of pixels on screen)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>0.0003</real>
     </map>
     <key>ScriptHelpFollowsCursor</key>
     <map>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0b0db432c8..3a3fe2b656 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1203,6 +1203,8 @@ LLFastTimer::DeclareTimer FTM_FRAME("Frame", true);
 
 bool LLAppViewer::mainLoop()
 {
+	llinfos << "***********************Entering main_loop***********************" << llendflush;
+
 	mMainloopTimeout = new LLWatchdogTimeout();
 	
 	//-------------------------------------------
@@ -1539,7 +1541,7 @@ bool LLAppViewer::mainLoop()
 
 	destroyMainloopTimeout();
 
-	llinfos << "Exiting main_loop" << llendflush;
+	llinfos << "***********************Exiting main_loop***********************" << llendflush;
 
 	return true;
 }
@@ -1568,11 +1570,9 @@ bool LLAppViewer::cleanup()
 	LLEventPumps::instance().reset();
 
 	//dump scene loading monitor results
-	if(LLSceneMonitor::getInstance()->hasResults())
+	if(LLSceneMonitor::instance().hasResults())
 	{
-		std::string file_name = "scene_monitor_results.csv";
-		LLSceneMonitor::getInstance()->dumpToFile(
-			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, file_name));
+		LLSceneMonitor::instance().dumpToFile(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "scene_monitor_results.csv"));
 	}
 
 	if (LLFastTimerView::sAnalyzePerformance)
@@ -4257,6 +4257,7 @@ void LLAppViewer::idle()
 	{
 		if (gRenderStartTime.getElapsedTimeF32() > qas)
 		{
+			llinfos << "Quitting after " << qas << " seconds. See setting \"QuitAfterSeconds\"." << llendl;
 			LLAppViewer::instance()->forceQuit();
 		}
 	}
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 3d8e1513dd..c101fe7deb 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -60,11 +60,8 @@ LLSceneMonitor::LLSceneMonitor() :
 	mDiff(NULL),
 	mDiffResult(0.f),
 	mDiffTolerance(0.1f),
-	mNeedsUpdateDiff(false),
-	mHasNewDiff(false),
-	mHasNewQueryResult(false),
+	mDiffState(WAITING_FOR_NEXT_DIFF),
 	mDebugViewerVisible(false),
-	mQuitting(false),
 	mQueryObject(0),
 	mDiffPixelRatio(0.5f)
 {
@@ -72,12 +69,11 @@ LLSceneMonitor::LLSceneMonitor() :
 	mFrames[1] = NULL;
 
 	mRecording = new LLTrace::ExtendablePeriodicRecording();
-	mRecording->start();
 }
 
 LLSceneMonitor::~LLSceneMonitor()
 {
-	mQuitting = true;
+	mDiffState = VIEWER_QUITTING;
 	destroyClass();
 }
 
@@ -100,6 +96,8 @@ void LLSceneMonitor::reset()
 	mFrames[1] = NULL;
 	mDiff = NULL;
 
+	mRecording->reset();
+
 	unfreezeScene();
 
 	if(mQueryObject > 0)
@@ -248,7 +246,7 @@ void LLSceneMonitor::unfreezeScene()
 	//thaw all avatars
 	mAvatarPauseHandles.clear();
 
-	if(mQuitting)
+	if(mDiffState == VIEWER_QUITTING)
 	{
 		return; //we are quitting viewer.
 	}
@@ -267,7 +265,7 @@ void LLSceneMonitor::unfreezeScene()
 void LLSceneMonitor::capture()
 {
 	static U32 last_capture_time = 0;
-	static LLCachedControl<bool> monitor_enabled(gSavedSettings,"SceneLoadingMonitorEnabled");
+	static LLCachedControl<bool> monitor_enabled(gSavedSettings, "SceneLoadingMonitorEnabled");
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static LLFrameTimer timer;	
 
@@ -275,7 +273,7 @@ void LLSceneMonitor::capture()
 	if (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f
 		|| last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f)
 	{
-		mRecording->reset();
+		reset();
 	}
 
 	bool enabled = monitor_enabled || mDebugViewerVisible;
@@ -283,11 +281,11 @@ void LLSceneMonitor::capture()
 	{
 		if(mEnabled)
 		{
-			reset();
 			unfreezeScene();
 		}
 		else
 		{
+			reset();
 			freezeScene();
 		}
 
@@ -299,7 +297,10 @@ void LLSceneMonitor::capture()
 		&& LLGLSLShader::sNoFixedFunction
 		&& last_capture_time != gFrameCount)
 	{
+		mRecording->resume();
+
 		timer.reset();
+
 		last_capture_time = gFrameCount;
 
 		LLRenderTarget& cur_target = getCaptureTarget();
@@ -315,13 +316,13 @@ void LLSceneMonitor::capture()
 		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);		
 		glBindFramebuffer(GL_FRAMEBUFFER, old_FBO);
 
-		mNeedsUpdateDiff = true;
+		mDiffState = NEED_DIFF;
 	}
 }
 
 bool LLSceneMonitor::needsUpdate() const
 {
-	return mNeedsUpdateDiff;
+	return mDiffState == NEED_DIFF;
 }
 
 static LLFastTimer::DeclareTimer FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture");
@@ -329,11 +330,10 @@ static LLFastTimer::DeclareTimer FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Dif
 
 void LLSceneMonitor::compare()
 {
-	if(!mNeedsUpdateDiff)
+	if(mDiffState != NEED_DIFF)
 	{
 		return;
 	}
-	mNeedsUpdateDiff = false;
 
 	if(!mFrames[0] || !mFrames[1])
 	{
@@ -345,6 +345,7 @@ void LLSceneMonitor::compare()
 	}
 
 	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
+	mDiffState = EXECUTE_DIFF;
 
 	S32 width = gViewerWindow->getWindowWidthRaw();
 	S32 height = gViewerWindow->getWindowHeightRaw();
@@ -400,8 +401,6 @@ void LLSceneMonitor::compare()
 	gGL.getTexUnit(2)->disable();
 	gGL.getTexUnit(2)->unbind(LLTexUnit::TT_TEXTURE);
 
-	mHasNewDiff = true;
-	
 	if (!mDebugViewerVisible)
 	{
 		calcDiffAggregate();
@@ -413,7 +412,7 @@ void LLSceneMonitor::calcDiffAggregate()
 {
 	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
 
-	if(!mHasNewDiff && !mDebugViewerVisible)
+	if(mDiffState != EXECUTE_DIFF && !mDebugViewerVisible)
 	{
 		return;
 	}	
@@ -435,18 +434,17 @@ void LLSceneMonitor::calcDiffAggregate()
 	gOneTextureFilterProgram.bind();
 	gOneTextureFilterProgram.uniform1f("tolerance", mDiffTolerance);
 
-	if(mHasNewDiff)
+	if(mDiffState == EXECUTE_DIFF)
 	{
 		glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mQueryObject);
 	}
 
 	gl_draw_scaled_target(0, 0, S32(mDiff->getWidth() * mDiffPixelRatio), S32(mDiff->getHeight() * mDiffPixelRatio), mDiff);
 
-	if(mHasNewDiff)
+	if(mDiffState == EXECUTE_DIFF)
 	{
 		glEndQueryARB(GL_SAMPLES_PASSED_ARB);
-		mHasNewDiff = false;	
-		mHasNewQueryResult = true;
+		mDiffState = WAIT_ON_RESULT;
 	}
 		
 	gOneTextureFilterProgram.unbind();
@@ -467,31 +465,30 @@ void LLSceneMonitor::fetchQueryResult()
 {
 	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
 
-	if(!mHasNewQueryResult)
-	{
-		return;
-	}
-	mHasNewQueryResult = false;
-
-	GLuint available = 0;
-	glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available);
-	if(!available)
+	if(mDiffState == WAIT_ON_RESULT)
 	{
-		return;
-	}
+		mDiffState = WAITING_FOR_NEXT_DIFF;
 
-	GLuint count = 0;
-	glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count);
+		GLuint available = 0;
+		glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_AVAILABLE_ARB, &available);
+		if(available)
+		{
+			GLuint count = 0;
+			glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count);
 	
-	mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
+			mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
-	LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
-	sample(sFramePixelDiff, mDiffResult);
+			LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
+			sample(sFramePixelDiff, mDiffResult);
 
-	const F32 diff_threshold = 0.001f;
-	if(mDiffResult > diff_threshold)
-	{
-		mRecording->extend();
+			mRecording->getPotentialRecording().nextPeriod();
+
+			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
+			if(mDiffResult > diff_threshold())
+			{
+				mRecording->extend();
+			}
+		}
 	}
 }
 
@@ -503,29 +500,124 @@ void LLSceneMonitor::addMonitorResult()
 	mMonitorResults.push_back(result);
 }
 
-//dump results to a file _scene_monitor_results.csv
+//dump results to a file _scene_xmonitor_results.csv
 void LLSceneMonitor::dumpToFile(std::string file_name)
 {
-	if(mMonitorResults.empty() || !getRecording())
-	{
-		return; //nothing to dump
-	}
+	LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; 
 
 	std::ofstream os(file_name.c_str());
 
 	//total scene loading time
-	os << llformat("Scene Loading time: %.4f seconds\n", (F32)getRecording()->getAcceptedRecording().getDuration().value());
+	os << std::setprecision(4);
+
+	LLTrace::PeriodicRecording& scene_load_recording = mRecording->getAcceptedRecording();
+	U32 frame_count = scene_load_recording.getNumPeriods();
+
+	LLUnit<LLUnits::Seconds, F64> frame_time;
+
+	os << "Stat";
+	for (S32 frame = 0; frame < frame_count; frame++)
+	{
+		frame_time += scene_load_recording.getPrevRecording(frame_count - frame).getDuration();
+		os << ", " << frame_time.value();
+	}
+	os << std::endl;
+
+	for (LLTrace::CountStatHandle<F64>::instance_iter it = LLTrace::CountStatHandle<F64>::beginInstances(), end_it = LLTrace::CountStatHandle<F64>::endInstances();
+		it != end_it;
+		++it)
+	{
+		std::ostringstream row;
+		row << it->getName();
+
+		S32 samples = 0;
+
+		for (S32 i = frame_count - 1; i >= 0; --i)
+		{
+			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it);
+		}
+
+		row << std::endl;
+
+		if (samples > 0)
+		{
+			os << row.str();
+		}
+	}
+
+	for (LLTrace::CountStatHandle<S64>::instance_iter it = LLTrace::CountStatHandle<S64>::beginInstances(), end_it = LLTrace::CountStatHandle<S64>::endInstances();
+		it != end_it;
+		++it)
+	{
+		std::ostringstream row;
+		row << it->getName();
+
+		S32 samples = 0;
+
+		for (S32 i = frame_count - 1; i >= 0; --i)
+		{
+			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it);
+		}
+
+		row << std::endl;
+
+		if (samples > 0)
+		{
+			os << row.str();
+		}
+	}
+
+	for (LLTrace::MeasurementStatHandle<F64>::instance_iter it = LLTrace::MeasurementStatHandle<F64>::beginInstances(), end_it = LLTrace::MeasurementStatHandle<F64>::endInstances();
+		it != end_it;
+		++it)
+	{
+		std::ostringstream row;
+		row << it->getName();
+
+		S32 samples = 0;
 
-	S32 num_results = mMonitorResults.size();
-	for(S32 i = 0; i < num_results; i++)
+		for (S32 i = frame_count - 1; i >= 0; --i)
+		{
+			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
+		}
+
+		row << std::endl;
+
+		if (samples > 0)
+		{
+			os << row.str();
+		}
+	}
+
+	for (LLTrace::MeasurementStatHandle<S64>::instance_iter it = LLTrace::MeasurementStatHandle<S64>::beginInstances(), end_it = LLTrace::MeasurementStatHandle<S64>::endInstances();
+		it != end_it;
+		++it)
 	{
-		os << llformat("%.4f %.4f\n", mMonitorResults[i].mTimeStamp, mMonitorResults[i].mDiff);
+		std::ostringstream row;
+		row << it->getName();
+
+		S32 samples = 0;
+
+		for (S32 i = frame_count - 1; i >= 0; --i)
+		{
+			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
+		}
+
+		row << std::endl;
+
+		if (samples > 0)
+		{
+			os << row.str();
+		}
 	}
 
 	os.flush();
 	os.close();
 
-	mMonitorResults.clear();
 }
 
 //-------------------------------------------------------------------------------------------------------------
@@ -563,8 +655,6 @@ void LLSceneMonitorView::draw()
 	F32 ratio = LLSceneMonitor::getInstance()->getDiffPixelRatio();
 	S32 height = (S32)(target->getHeight() * ratio);
 	S32 width = (S32)(target->getWidth() * ratio);
-	//S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.5f);
-	//S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.5f);
 	
 	LLRect new_rect;
 	new_rect.setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height);
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 6dccbbe335..f43c455f2f 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -64,7 +64,7 @@ public:
 	
 	LLTrace::ExtendablePeriodicRecording* getRecording() const {return mRecording;}
 	void dumpToFile(std::string file_name);
-	bool hasResults() const { return !mMonitorResults.empty();}
+	bool hasResults() const { return mRecording->getAcceptedRecording().getDuration() != 0;}
 
 private:
 	void freezeScene();
@@ -76,11 +76,16 @@ private:
 	void addMonitorResult();
 private:
 	bool mEnabled;
-	bool mNeedsUpdateDiff;
-	bool mHasNewDiff;
-	bool mHasNewQueryResult;
 	bool mDebugViewerVisible;
-	bool mQuitting;
+
+	enum EDiffState
+	{
+		WAITING_FOR_NEXT_DIFF,
+		NEED_DIFF,
+		EXECUTE_DIFF,
+		WAIT_ON_RESULT,
+		VIEWER_QUITTING
+	}	mDiffState;
 
 	LLRenderTarget* mFrames[2];
 	LLRenderTarget* mDiff;
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index cf2b491d6c..f748344cc8 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2048,7 +2048,7 @@ bool idle_startup()
 		static LLFrameTimer wearables_timer;
 
 		const F32 wearables_time = wearables_timer.getElapsedTimeF32();
-		const F32 MAX_WEARABLES_TIME = 10.f;
+		static LLCachedControl<F32> max_wearables_time(gSavedSettings, "ClothingLoadingDelay");
 
 		if (!gAgent.isGenderChosen() && isAgentAvatarValid())
 		{
@@ -2068,7 +2068,7 @@ bool idle_startup()
 		
 		display_startup();
 
-		if (wearables_time > MAX_WEARABLES_TIME)
+		if (wearables_time > max_wearables_time())
 		{
 			LLNotificationsUtil::add("ClothingLoading");
 			add(LLStatViewer::LOADING_WEARABLES_LONG_DELAY, 1);
@@ -2102,7 +2102,7 @@ bool idle_startup()
 		display_startup();
 		update_texture_fetch();
 		display_startup();
-		set_startup_status(0.9f + 0.1f * wearables_time / MAX_WEARABLES_TIME,
+		set_startup_status(0.9f + 0.1f * wearables_time / max_wearables_time(),
 						 LLTrans::getString("LoginDownloadingClothing").c_str(),
 						 gAgent.mMOTD.c_str());
 		display_startup();
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index a123c12811..c88df93119 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -135,7 +135,7 @@ void LLWorld::destroyClass()
 	//make all visible drawbles invisible.
 	LLDrawable::incrementVisible();
 
-	LLSceneMonitor::getInstance()->destroyClass();
+	LLSceneMonitor::deleteSingleton();
 }
 
 
-- 
cgit v1.2.3


From 7006cbe3a24a88da4182f5930bb0fe712c43ce8c Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 16 May 2013 16:58:04 -0600
Subject: fix for SH-4080: interesting: random crash on Mac

---
 indra/newview/llvieweroctree.cpp |  6 +-----
 indra/newview/llviewerregion.cpp | 31 +++++--------------------------
 indra/newview/llviewerregion.h   |  3 ---
 3 files changed, 6 insertions(+), 34 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 0670b47f52..62108f0512 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -327,11 +327,7 @@ void LLViewerOctreeEntryData::setVisible() const
 
 LLviewerOctreeGroup::~LLviewerOctreeGroup()
 {
-	if(LLViewerRegion::sCurRegionp && isVisible())
-	{
-		LLViewerRegion::sCurRegionp->clearVisibleGroup(this);
-	}
-	llassert(!LLViewerRegion::sCurRegionp || LLViewerRegion::sCurRegionp->hasVisibleGroup(this) == false);
+	//empty here
 }
 
 LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) :
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 2ba0d939be..85da75510b 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -86,7 +86,6 @@ const F32 CAP_REQUEST_TIMEOUT = 18;
 // Even though we gave up on login, keep trying for caps after we are logged in:
 const S32 MAX_CAP_REQUEST_ATTEMPTS = 30;
 
-LLViewerRegion* LLViewerRegion::sCurRegionp = NULL;
 BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
 
 typedef std::map<std::string, std::string> CapabilityMap;
@@ -143,7 +142,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< LLviewerOctreeGroup* >      mVisibleGroups; //visible groupa
+	std::set< LLPointer<LLviewerOctreeGroup> >      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.
@@ -943,23 +942,6 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 	mImpl->mVisibleEntries.insert(entry);
 }
 
-bool LLViewerRegion::hasVisibleGroup(LLviewerOctreeGroup* group)
-{
-	return mImpl->mVisibleGroups.find(group) != mImpl->mVisibleGroups.end();
-}
-
-void LLViewerRegion::clearVisibleGroup(LLviewerOctreeGroup* group)
-{
-	if(mDead)
-	{
-		return;
-	}
-
-	llassert(!group->getOctreeNode() || group->isEmpty());
-
-	mImpl->mVisibleGroups.erase(group);
-}
-
 F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 {
 	if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty())
@@ -1030,11 +1012,12 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 #endif
 
 	//process visible groups
-	std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
+	std::set< LLPointer<LLviewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
 	for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
 	{
-		LLviewerOctreeGroup* group = *group_iter;
-		if(!group->getOctreeNode() || group->isEmpty())
+		LLPointer<LLviewerOctreeGroup> group = *group_iter;
+		if(group->getNumRefs() < 3 || //group to be deleted
+			!group->getOctreeNode() || group->isEmpty()) //group empty
 		{
 			continue;
 		}
@@ -1056,7 +1039,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 			}
 		}
 	}
-	mImpl->mVisibleGroups.clear();
 
 	if(needs_update)
 	{
@@ -1119,8 +1101,6 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 		return did_update;
 	}
 
-	sCurRegionp = this;
-
 	//kill invisible objects
 	max_update_time = killInvisibleObjects(max_update_time);	
 	
@@ -1129,7 +1109,6 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 
 	mImpl->mVisibleGroups.clear();
 
-	sCurRegionp = NULL;
 	return did_update;
 }
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index a73898317b..fefd4209aa 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -224,8 +224,6 @@ public:
 	void addActiveCacheEntry(LLVOCacheEntry* entry);
 	void removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep);	
 	void killCacheEntry(U32 local_id); //physically delete the cache entry	
-	void clearVisibleGroup(LLviewerOctreeGroup* group);
-	bool hasVisibleGroup(LLviewerOctreeGroup* group);
 
 	// Like idleUpdate, but forces everything to complete regardless of
 	// how long it takes.
@@ -396,7 +394,6 @@ public:
 	LLDynamicArray<U32> mMapAvatars;
 	LLDynamicArray<LLUUID> mMapAvatarIDs;
 
-	static LLViewerRegion* sCurRegionp;
 	static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
 private:
 	LLViewerRegionImpl * mImpl;
-- 
cgit v1.2.3


From 30f8173e9a06f150535e8791786d908f34038c6e Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 16 May 2013 17:04:57 -0600
Subject: more correct setting to enable object cache culling.

---
 indra/newview/llworld.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index a123c12811..5609c22b39 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -110,7 +110,7 @@ LLWorld::LLWorld() :
 	gGL.getTexUnit(0)->bind(mDefaultWaterTexturep);
 	mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP);
 
-	LLViewerRegion::sVOCacheCullingEnabled = (BOOL)gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
+	LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled") && gSavedSettings.getBOOL("ObjectCacheEnabled");
 }
 
 
-- 
cgit v1.2.3


From f850ae03b399a5cc7aa32f82b8ed996518a86a2a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 20 May 2013 00:01:57 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 fixed copy construction of Recorders, eliminated most zero-length frames
 fixed reset behavior of periodic recordings and extendable recordings to
 clear entire history removed busy-loop recording of stats from worker
 threads...stats reported only when work is done

---
 indra/newview/llscenemonitor.cpp  | 4 ++--
 indra/newview/llviewerdisplay.cpp | 2 ++
 indra/newview/pipeline.cpp        | 2 --
 3 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index c101fe7deb..c2e00384a1 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -481,13 +481,13 @@ void LLSceneMonitor::fetchQueryResult()
 			LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
 			sample(sFramePixelDiff, mDiffResult);
 
-			mRecording->getPotentialRecording().nextPeriod();
-
 			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
 			if(mDiffResult > diff_threshold())
 			{
 				mRecording->extend();
 			}
+
+			mRecording->getPotentialRecording().nextPeriod();
 		}
 	}
 }
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 970862892c..5974c84596 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -803,6 +803,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 			}
 		}
 
+		LLSceneMonitor::getInstance()->fetchQueryResult();
+		
 		LLGLState::checkStates();
 		LLGLState::checkClientArrays();
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index acf3e7aa07..3f6269e768 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3233,8 +3233,6 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	}
 		
 	postSort(camera);	
-
-	LLSceneMonitor::getInstance()->fetchQueryResult();
 }
 
 void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
-- 
cgit v1.2.3


From 1225a7a3cc29e3b6429fa0af87204599e98bee3e Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 20 May 2013 00:49:57 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 further improvements that should eliminate more short duration recording
 periods

---
 indra/newview/llscenemonitor.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index c2e00384a1..b7517a057e 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -486,8 +486,10 @@ void LLSceneMonitor::fetchQueryResult()
 			{
 				mRecording->extend();
 			}
-
-			mRecording->getPotentialRecording().nextPeriod();
+			else
+			{
+				mRecording->getPotentialRecording().nextPeriod();
+			}
 		}
 	}
 }
-- 
cgit v1.2.3


From fbce0030494ccb6fa8f6cf45e1ec95a2fa922bcd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 20 May 2013 12:47:23 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 killed LLFastTimerView::getTime fixed block time stats always being 0

---
 indra/newview/llfasttimerview.cpp |  7 -------
 indra/newview/llfasttimerview.h   |  1 -
 indra/newview/llviewerstats.cpp   | 21 +++++++++++++--------
 3 files changed, 13 insertions(+), 16 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 45ffe56ac1..b78dd08bf1 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -422,13 +422,6 @@ void LLFastTimerView::draw()
 	mHoverBarIndex = -1;
 }
 
-F64 LLFastTimerView::getTime(const std::string& name)
-{
-	//TODO: replace calls to this with use of timer object directly
-	//llstatic_assert(false, "TODO: implement");
-	return 0.0;
-}
-
 void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch)
 {
 	//read result back into raw image
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 8b9ad290bc..341adacd65 100644
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -62,7 +62,6 @@ public:
 	virtual void draw();
 
 	LLTrace::TimeBlock* getLegendID(S32 y);
-	F64 getTime(const std::string& name);
 
 protected:
 	virtual	void	onClickCloseBtn();
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 13a005dcbf..002f0c7aa3 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -322,19 +322,24 @@ void update_statistics()
 			add(LLStatViewer::TOOLBOX_TIME, gFrameIntervalSeconds);
 		}
 	}
+
+	LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording();
+
 	sample(LLStatViewer::ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
 	sample(LLStatViewer::LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
 	sample(LLStatViewer::DRAW_DISTANCE, (F64)gSavedSettings.getF32("RenderFarClip"));
 	sample(LLStatViewer::CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
 
-	sample(LLStatViewer::FRAME_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Frame")));
-	F64 idle_secs = gDebugView->mFastTimerView->getTime("Idle");
-	F64 network_secs = gDebugView->mFastTimerView->getTime("Network");
-	sample(LLStatViewer::UPDATE_STACKTIME, LLTrace::Seconds(idle_secs - network_secs));
-	sample(LLStatViewer::NETWORK_STACKTIME, LLTrace::Seconds(network_secs));
-	sample(LLStatViewer::IMAGE_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Update Images")));
-	sample(LLStatViewer::REBUILD_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Sort Draw State")));
-	sample(LLStatViewer::RENDER_STACKTIME, LLTrace::Seconds(gDebugView->mFastTimerView->getTime("Geometry")));
+	typedef LLInstanceTracker<LLTrace::TraceType<LLTrace::TimeBlockAccumulator>, std::string> trace_type_t;
+
+	sample(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Frame")).as<LLUnits::Seconds>());
+	LLUnit<LLUnits::Seconds, F64> idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
+	LLUnit<LLUnits::Seconds, F64> network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
+	sample(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs);
+	sample(LLStatViewer::NETWORK_STACKTIME, network_secs);
+	sample(LLStatViewer::IMAGE_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Update Images")).as<LLUnits::Seconds>());
+	sample(LLStatViewer::REBUILD_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Sort Draw State")).as<LLUnits::Seconds>());
+	sample(LLStatViewer::RENDER_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Render Geometry")).as<LLUnits::Seconds>());
 		
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
-- 
cgit v1.2.3


From 13f43fdc5bd046f7857f06254c84b8993bdcc50a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 20 May 2013 18:56:40 -0700
Subject: BUILDFIX: mac gcc fix

---
 indra/newview/llvocache.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index fc0634f133..7409b94d60 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -163,7 +163,6 @@ public:
 class LLVOCache : public LLSingleton<LLVOCache>
 {
 private:
-	friend LLSingleton<LLVOCache>;
 	struct HeaderEntryInfo
 	{
 		HeaderEntryInfo() : mIndex(0), mHandle(0), mTime(0) {}
@@ -194,6 +193,7 @@ private:
 	typedef std::set<HeaderEntryInfo*, header_entry_less> header_entry_queue_t;
 	typedef std::map<U64, HeaderEntryInfo*> handle_entry_map_t;
 private:
+    friend class LLSingleton<LLVOCache>;
 	LLVOCache() ;
 
 public:
-- 
cgit v1.2.3


From ab5106535758393e02b075d1e404e4e1fcf81abf Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 20 May 2013 19:27:50 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 removed extra dereference for copy on write pointer moved copyonwrite
 mechanism to RecordingBuffers from individual buffer fixed logic that was
 leaving scene unfrozen when camera moved during metrics gathering

---
 indra/newview/llscenemonitor.cpp                     | 6 ++++--
 indra/newview/llviewerstats.cpp                      | 2 +-
 indra/newview/skins/default/xui/en/floater_stats.xml | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index b7517a057e..b303dfbdb4 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -270,10 +270,12 @@ void LLSceneMonitor::capture()
 	static LLFrameTimer timer;	
 
 	LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording();
-	if (last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f
-		|| last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f)
+	if (mEnabled 
+		&&	(last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f
+			|| last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f))
 	{
 		reset();
+		freezeScene();
 	}
 
 	bool enabled = monitor_enabled || mDebugViewerVisible;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 002f0c7aa3..e8196e9655 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -64,7 +64,7 @@
 namespace LLStatViewer
 {
 
-LLTrace::CountStatHandle<>	FPS("fpsstat"),
+LLTrace::CountStatHandle<>	FPS("framesrendered"),
 							PACKETS_IN("packetsinstat"),
 							PACKETS_LOST("packetsloststat"),
 							PACKETS_OUT("packetsoutstat"),
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index f98fcc349e..0493f487d4 100644
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -38,7 +38,7 @@
 			   name="fps"
 			   label="FPS"
 			   unit_label="fps"
-			   stat="fpsstat"
+			   stat="framesrendered"
 			   bar_min="0"
 			   bar_max="60"
 			   tick_spacing="6"
-- 
cgit v1.2.3


From e8daeb177deccff29182ee97c143b0350e8c727c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 22 May 2013 21:19:46 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 clean up of llscenemonitor.cpp

---
 indra/newview/llscenemonitor.cpp | 8 --------
 indra/newview/llscenemonitor.h   | 9 ---------
 2 files changed, 17 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index b303dfbdb4..94c2e40bb1 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -496,14 +496,6 @@ void LLSceneMonitor::fetchQueryResult()
 	}
 }
 
-void LLSceneMonitor::addMonitorResult()
-{
-	ll_monitor_result_t result;
-	result.mTimeStamp = LLImageGL::sLastFrameTime;
-	result.mDiff = mDiffResult;
-	mMonitorResults.push_back(result);
-}
-
 //dump results to a file _scene_xmonitor_results.csv
 void LLSceneMonitor::dumpToFile(std::string file_name)
 {
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index f43c455f2f..3351ed0579 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -73,7 +73,6 @@ private:
 	LLRenderTarget& getCaptureTarget();
 	void generateDitheringTexture(S32 width, S32 height);
 
-	void addMonitorResult();
 private:
 	bool mEnabled;
 	bool mDebugViewerVisible;
@@ -105,14 +104,6 @@ private:
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
 
 	LLTrace::ExtendablePeriodicRecording* mRecording;
-
-	//---------------------------------------
-	typedef struct _monitor_result
-	{
-		F32 mTimeStamp;
-		F32 mDiff;
-	} ll_monitor_result_t;
-	std::vector<ll_monitor_result_t> mMonitorResults;
 };
 
 class LLSceneMonitorView : public LLFloater
-- 
cgit v1.2.3


From 16616ae48d86da75b3809fa6be6c846a9d420603 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 23 May 2013 18:25:21 -0600
Subject: for SH-4145: Interesting: Implement occlusion culling for object
 cache

---
 indra/newview/llappviewer.cpp        |  31 +-
 indra/newview/llappviewer.h          |   3 +-
 indra/newview/lldrawable.cpp         |   2 +-
 indra/newview/lldrawpoolalpha.cpp    |  10 +-
 indra/newview/llscenemonitor.cpp     |   4 +-
 indra/newview/llspatialpartition.cpp | 678 ++---------------------------------
 indra/newview/llspatialpartition.h   |  79 +---
 indra/newview/llvieweroctree.cpp     | 620 +++++++++++++++++++++++++++++++-
 indra/newview/llvieweroctree.h       |  99 ++++-
 indra/newview/llviewerwindow.cpp     |   4 +-
 indra/newview/llvocache.cpp          |  41 ++-
 indra/newview/llvovolume.cpp         |  12 +-
 indra/newview/pipeline.cpp           |  16 +-
 13 files changed, 845 insertions(+), 754 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0b0db432c8..cb813ea889 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1415,18 +1415,7 @@ bool LLAppViewer::mainLoop()
 					S32 io_pending = 0;
 					F32 max_time = llmin(gFrameIntervalSeconds.value() *10.f, 1.f);
 
-					{
-						LLFastTimer ftm(FTM_TEXTURE_CACHE);
- 						work_pending += LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
-					}
-					{
-						LLFastTimer ftm(FTM_DECODE);
-	 					work_pending += LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
-					}
-					{
-						LLFastTimer ftm(FTM_DECODE);
-	 					work_pending += LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread
-					}
+					work_pending += updateTextureThreads(max_time);
 
 					{
 						LLFastTimer ftm(FTM_VFS);
@@ -1544,6 +1533,24 @@ bool LLAppViewer::mainLoop()
 	return true;
 }
 
+S32 LLAppViewer::updateTextureThreads(F32 max_time)
+{
+	S32 work_pending = 0;
+	{
+		LLFastTimer ftm(FTM_TEXTURE_CACHE);
+ 		work_pending += LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
+	}
+	{
+		LLFastTimer ftm(FTM_DECODE);
+	 	work_pending += LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
+	}
+	{
+		LLFastTimer ftm(FTM_DECODE);
+	 	work_pending += LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread
+	}
+	return work_pending;
+}
+
 void LLAppViewer::flushVFSIO()
 {
 	while (1)
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 627652dc30..30e208d01c 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -171,7 +171,8 @@ public:
 
 	void purgeCache(); // Clear the local cache. 
 	void purgeCacheImmediate(); //clear local cache immediately.
-	
+	S32  updateTextureThreads(F32 max_time);
+
 	// mute/unmute the system's master audio
 	virtual void setMasterSystemAudioMute(bool mute);
 	virtual bool getMasterSystemAudioMute();	
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 4d72dd1343..17f610829d 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1145,7 +1145,7 @@ LLSpatialBridge::~LLSpatialBridge()
 	LLSpatialGroup* group = getSpatialGroup();
 	if (group)
 	{
-		group->mSpatialPartition->remove(this, group);
+		group->getSpatialPartition()->remove(this, group);
 	}
 	}
 
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 313b310e1e..7020db917b 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -351,7 +351,7 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask)
 	for (LLCullResult::sg_iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
 	{
 		LLSpatialGroup* group = *i;
-		if (group->mSpatialPartition->mRenderByGroup &&
+		if (group->getSpatialPartition()->mRenderByGroup &&
 			!group->isDead())
 		{
 			LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];	
@@ -389,15 +389,15 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 	{
 		LLSpatialGroup* group = *i;
 		llassert(group);
-		llassert(group->mSpatialPartition);
+		llassert(group->getSpatialPartition());
 
-		if (group->mSpatialPartition->mRenderByGroup &&
+		if (group->getSpatialPartition()->mRenderByGroup &&
 		    !group->isDead())
 		{
 			bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow.
 				// All particle systems seem to come off the wire with texture entries which claim that they glow.  This is probably a bug in the data.  Suppress.
-				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_PARTICLE &&
-				group->mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE;
+				group->getSpatialPartition()->mPartitionType != LLViewerRegion::PARTITION_PARTICLE &&
+				group->getSpatialPartition()->mPartitionType != LLViewerRegion::PARTITION_HUD_PARTICLE;
 
 			LLSpatialGroup::drawmap_elem_t& draw_info = group->mDrawMap[LLRenderPass::PASS_ALPHA];
 
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 15fe77f028..c592fd0a38 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -107,7 +107,7 @@ void LLSceneMonitor::reset()
 
 	if(mQueryObject > 0)
 	{
-		release_occlusion_query_object_name(mQueryObject);
+		LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(mQueryObject);
 		mQueryObject = 0;
 	}
 }
@@ -437,7 +437,7 @@ void LLSceneMonitor::calcDiffAggregate()
 
 	if(!mQueryObject)
 	{
-		mQueryObject = get_new_occlusion_query_object_name();
+		mQueryObject = LLOcclusionCullingGroup::getNewOcclusionQueryObjectName();
 	}
 
 	LLGLDepthTest depth(true, false, GL_ALWAYS);
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 53f5658815..3f426d8f8a 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -51,32 +51,16 @@
 #include "llvoavatar.h"
 #include "llvolumemgr.h"
 #include "lltextureatlas.h"
-#include "llglslshader.h"
 #include "llviewershadermgr.h"
 
 static LLFastTimer::DeclareTimer FTM_FRUSTUM_CULL("Frustum Culling");
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound Partition");
 
-const F32 SG_OCCLUSION_FUDGE = 0.25f;
-#define SG_DISCARD_TOLERANCE 0.01f
-
-#if LL_OCTREE_PARANOIA_CHECK
-#define assert_octree_valid(x) x->validate()
-#define assert_states_valid(x) ((LLSpatialGroup*) x->mSpatialPartition->mOctree->getListener(0))->checkStates()
-#else
-#define assert_octree_valid(x)
-#define assert_states_valid(x)
-#endif
-
 extern bool gShiftFrame;
 
 static U32 sZombieGroups = 0;
 U32 LLSpatialGroup::sNodeCount = 0;
 
-#define LL_TRACK_PENDING_OCCLUSION_QUERIES 0
-
-std::set<GLuint> LLSpatialGroup::sPendingQueries;
-
 U32 gOctreeMaxCapacity;
 
 BOOL LLSpatialGroup::sNoDelete = FALSE;
@@ -84,57 +68,6 @@ BOOL LLSpatialGroup::sNoDelete = FALSE;
 static F32 sLastMaxTexPriority = 1.f;
 static F32 sCurMaxTexPriority = 1.f;
 
-class LLOcclusionQueryPool : public LLGLNamePool
-{
-public:
-	LLOcclusionQueryPool()
-	{
-		mCurQuery = 1;
-	}
-
-protected:
-
-	std::list<GLuint> mAvailableName;
-	GLuint mCurQuery;
-		
-	virtual GLuint allocateName()
-	{
-		GLuint ret = 0;
-
-		if (!mAvailableName.empty())
-		{
-			ret = mAvailableName.front();
-			mAvailableName.pop_front();
-		}
-		else
-		{
-			ret = mCurQuery++;
-		}
-
-		return ret;
-	}
-
-	virtual void releaseName(GLuint name)
-	{
-#if LL_TRACK_PENDING_OCCLUSION_QUERIES
-		LLSpatialGroup::sPendingQueries.erase(name);
-#endif
-		llassert(std::find(mAvailableName.begin(), mAvailableName.end(), name) == mAvailableName.end());
-		mAvailableName.push_back(name);
-	}
-};
-
-static LLOcclusionQueryPool sQueryPool;
-
-GLuint get_new_occlusion_query_object_name()
-{
-	return sQueryPool.allocate();
-}
-
-void release_occlusion_query_object_name(GLuint name)
-{
-	sQueryPool.release(name);
-}
 
 //static counter for frame to switch LOD on
 
@@ -148,97 +81,6 @@ void sg_assert(BOOL expr)
 #endif
 }
 
-typedef enum
-{
-	b000 = 0x00,
-	b001 = 0x01,
-	b010 = 0x02,
-	b011 = 0x03,
-	b100 = 0x04,
-	b101 = 0x05,
-	b110 = 0x06,
-	b111 = 0x07,
-} eLoveTheBits;
-
-//contact Runitai Linden for a copy of the SL object used to write this table
-//basically, you give the table a bitmask of the look-at vector to a node and it
-//gives you a triangle fan index array
-static U16 sOcclusionIndices[] =
-{
-	 //000
-		b111, b110, b010, b011, b001, b101, b100, b110,
-	 //001 
-		b011, b010, b000, b001, b101, b111, b110, b010,
-	 //010
-		b101, b100, b110, b111, b011, b001, b000, b100,
-	 //011 
-		b001, b000, b100, b101, b111, b011, b010, b000,
-	 //100 
-		b110, b000, b010, b011, b111, b101, b100, b000,
-	 //101 
-		b010, b100, b000, b001, b011, b111, b110, b100,
-	 //110
-		b100, b010, b110, b111, b101, b001, b000, b010,
-	 //111
-		b000, b110, b100, b101, b001, b011, b010, b110,
-};
-
-U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center)
-{
-	LLVector4a origin;
-	origin.load3(camera->getOrigin().mV);
-
-	S32 cypher = center.greaterThan(origin).getGatheredBits() & 0x7;
-	
-	return cypher*8;
-}
-
-U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center)
-{
-	LLVector4a origin;
-	origin.load3(camera->getOrigin().mV);
-
-	S32 cypher = center.greaterThan(origin).getGatheredBits() & 0x7;
-	
-	return (U8*) (sOcclusionIndices+cypher*8);
-}
-
-//create a vertex buffer for efficiently rendering cubes
-LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage)
-{
-	LLVertexBuffer* ret = new LLVertexBuffer(type_mask, usage);
-
-	ret->allocateBuffer(8, 64, true);
-
-	LLStrider<LLVector3> pos;
-	LLStrider<U16> idx;
-
-	ret->getVertexStrider(pos);
-	ret->getIndexStrider(idx);
-
-	pos[0] = LLVector3(-1,-1,-1);
-	pos[1] = LLVector3(-1,-1, 1);
-	pos[2] = LLVector3(-1, 1,-1);
-	pos[3] = LLVector3(-1, 1, 1);
-	pos[4] = LLVector3( 1,-1,-1);
-	pos[5] = LLVector3( 1,-1, 1);
-	pos[6] = LLVector3( 1, 1,-1);
-	pos[7] = LLVector3( 1, 1, 1);
-
-	for (U32 i = 0; i < 64; i++)
-	{
-		idx[i] = sOcclusionIndices[i];
-	}
-
-	ret->flush();
-
-	return ret;
-}
-
-static LLFastTimer::DeclareTimer FTM_BUILD_OCCLUSION("Build Occlusion");
-
-BOOL earlyFail(LLCamera* camera, LLSpatialGroup* group);
-
 //returns:
 //	0 if sphere and AABB are not intersecting 
 //	1 if they are
@@ -285,18 +127,7 @@ LLSpatialGroup::~LLSpatialGroup()
 		sZombieGroups--;
 	}
 	
-	sNodeCount--;
-
-	if (gGLManager.mHasOcclusionQuery)
-	{
-		for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; ++i)
-		{
-			if (mOcclusionQuery[i])
-			{
-				release_occlusion_query_object_name(mOcclusionQuery[i]);
-			}
-		}
-	}
+	sNodeCount--;	
 
 	clearDrawMap();
 	clearAtlasList() ;
@@ -431,7 +262,7 @@ void LLSpatialGroup::clearDrawMap()
 
 BOOL LLSpatialGroup::isHUDGroup() 
 {
-	return mSpatialPartition && mSpatialPartition->isHUDPartition() ; 
+	return getSpatialPartition() && getSpatialPartition()->isHUDPartition() ; 
 }
 
 BOOL LLSpatialGroup::isRecentlyVisible() const
@@ -461,7 +292,7 @@ void LLSpatialGroup::validate()
 		sg_assert(drawable->getSpatialGroup() == this);
 		if (drawable->getSpatialBridge())
 		{
-			sg_assert(drawable->getSpatialBridge() == mSpatialPartition->asBridge());
+			sg_assert(drawable->getSpatialBridge() == getSpatialPartition()->asBridge());
 		}
 
 		/*if (drawable->isSpatialBridge())
@@ -501,14 +332,6 @@ void LLSpatialGroup::validate()
 #endif
 }
 
-void LLSpatialGroup::checkStates()
-{
-#if LL_OCTREE_PARANOIA_CHECK
-	//LLOctreeStateCheck checker;
-	//checker.traverse(mOctreeNode);
-#endif
-}
-
 void LLSpatialGroup::validateDrawMap()
 {
 #if LL_OCTREE_PARANOIA_CHECK
@@ -574,7 +397,7 @@ void LLSpatialGroup::rebuildGeom()
 {
 	if (!isDead())
 	{
-		mSpatialPartition->rebuildGeom(this);
+		getSpatialPartition()->rebuildGeom(this);
 
 		if (hasState(LLSpatialGroup::MESH_DIRTY))
 		{
@@ -587,7 +410,7 @@ void LLSpatialGroup::rebuildMesh()
 {
 	if (!isDead())
 	{
-		mSpatialPartition->rebuildMesh(this);
+		getSpatialPartition()->rebuildMesh(this);
 	}
 }
 
@@ -665,23 +488,7 @@ void LLSpatialPartition::rebuildMesh(LLSpatialGroup* group)
 
 LLSpatialGroup* LLSpatialGroup::getParent()
 {
-	if (isDead())
-	{
-		return NULL;
-	}
-
-	if(!mOctreeNode)
-	{
-		return NULL;
-	}
-	OctreeNode* parent = mOctreeNode->getOctParent();
-
-	if (parent)
-	{
-		return (LLSpatialGroup*) parent->getListener(0);
-	}
-
-	return NULL;
+	return (LLSpatialGroup*)LLviewerOctreeGroup::getParent();
 }
 
 BOOL LLSpatialGroup::removeObject(LLDrawable *drawablep, BOOL from_octree)
@@ -735,10 +542,10 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
 	mObjectExtents[0].add(offset);
 	mObjectExtents[1].add(offset);
 
-	if (!mSpatialPartition->mRenderByGroup && 
-		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE &&
-		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN &&
-		mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE)
+	if (!getSpatialPartition()->mRenderByGroup && 
+		getSpatialPartition()->mPartitionType != LLViewerRegion::PARTITION_TREE &&
+		getSpatialPartition()->mPartitionType != LLViewerRegion::PARTITION_TERRAIN &&
+		getSpatialPartition()->mPartitionType != LLViewerRegion::PARTITION_BRIDGE)
 	{
 		setState(GEOM_DIRTY);
 		gPipeline.markRebuild(this, TRUE);
@@ -839,135 +646,15 @@ void LLSpatialGroup::clearState(U32 state, S32 mode)
 	}
 }
 
-//=====================================
-//		Occlusion State Set/Clear
-//=====================================
-class LLSpatialSetOcclusionState : public OctreeTraveler
-{
-public:
-	U32 mState;
-	LLSpatialSetOcclusionState(U32 state) : mState(state) { }
-	virtual void visit(const OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->setOcclusionState(mState); }	
-};
-
-class LLSpatialSetOcclusionStateDiff : public LLSpatialSetOcclusionState
-{
-public:
-	LLSpatialSetOcclusionStateDiff(U32 state) : LLSpatialSetOcclusionState(state) { }
-
-	virtual void traverse(const OctreeNode* n)
-	{
-		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
-		
-		if (!group->isOcclusionState(mState))
-		{
-			OctreeTraveler::traverse(n);
-		}
-	}
-};
-
-
-void LLSpatialGroup::setOcclusionState(U32 state, S32 mode) 
-{
-	if (mode > STATE_MODE_SINGLE)
-	{
-		if (mode == STATE_MODE_DIFF)
-		{
-			LLSpatialSetOcclusionStateDiff setter(state);
-			setter.traverse(mOctreeNode);
-		}
-		else if (mode == STATE_MODE_BRANCH)
-		{
-			LLSpatialSetOcclusionState setter(state);
-			setter.traverse(mOctreeNode);
-		}
-		else
-		{
-			for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
-			{
-				mOcclusionState[i] |= state;
-
-				if ((state & DISCARD_QUERY) && mOcclusionQuery[i])
-				{
-					release_occlusion_query_object_name(mOcclusionQuery[i]);
-					mOcclusionQuery[i] = 0;
-				}
-			}
-		}
-	}
-	else
-	{
-		mOcclusionState[LLViewerCamera::sCurCameraID] |= state;
-		if ((state & DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
-		{
-			release_occlusion_query_object_name(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
-			mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0;
-		}
-	}
-}
-
-class LLSpatialClearOcclusionState : public OctreeTraveler
-{
-public:
-	U32 mState;
-	
-	LLSpatialClearOcclusionState(U32 state) : mState(state) { }
-	virtual void visit(const OctreeNode* branch) { ((LLSpatialGroup*) branch->getListener(0))->clearOcclusionState(mState); }
-};
-
-class LLSpatialClearOcclusionStateDiff : public LLSpatialClearOcclusionState
-{
-public:
-	LLSpatialClearOcclusionStateDiff(U32 state) : LLSpatialClearOcclusionState(state) { }
-
-	virtual void traverse(const OctreeNode* n)
-	{
-		LLSpatialGroup* group = (LLSpatialGroup*) n->getListener(0);
-		
-		if (group->isOcclusionState(mState))
-		{
-			OctreeTraveler::traverse(n);
-		}
-	}
-};
-
-void LLSpatialGroup::clearOcclusionState(U32 state, S32 mode)
-{
-	if (mode > STATE_MODE_SINGLE)
-	{
-		if (mode == STATE_MODE_DIFF)
-		{
-			LLSpatialClearOcclusionStateDiff clearer(state);
-			clearer.traverse(mOctreeNode);
-		}
-		else if (mode == STATE_MODE_BRANCH)
-		{
-			LLSpatialClearOcclusionState clearer(state);
-			clearer.traverse(mOctreeNode);
-		}
-		else
-		{
-			for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
-			{
-				mOcclusionState[i] &= ~state;
-			}
-		}
-	}
-	else
-	{
-		mOcclusionState[LLViewerCamera::sCurCameraID] &= ~state;
-	}
-}
 //======================================
 //		Octree Listener Implementation
 //======================================
 
-LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLviewerOctreeGroup(node),
+LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLOcclusionCullingGroup(node, part),
 	mObjectBoxSize(1.f),
 	mGeometryBytes(0),
 	mSurfaceArea(0.f),
-	mBuilt(0.f),
-	mSpatialPartition(part),
+	mBuilt(0.f),	
 	mVertexBuffer(NULL), 
 	mBufferUsage(part->mBufferUsage),
 	mDistance(0.f),
@@ -990,21 +677,6 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLv
 	setState(SG_INITIAL_STATE_MASK);
 	gPipeline.markRebuild(this, TRUE);
 
-	part->mLODSeed = (part->mLODSeed+1)%part->mLODPeriod;
-	mLODHash = part->mLODSeed;
-
-	OctreeNode* oct_parent = node->getOctParent();
-
-	LLSpatialGroup* parent = oct_parent ? (LLSpatialGroup*) oct_parent->getListener(0) : NULL;
-
-	for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
-	{
-		mOcclusionQuery[i] = 0;
-		mOcclusionIssued[i] = 0;
-		mOcclusionState[i] = parent ? SG_STATE_INHERIT_MASK & parent->mOcclusionState[i] : 0;
-		mVisible[i] = 0;
-	}
-
 	mRadius = 1;
 	mPixelArea = 1024.f;
 }
@@ -1030,10 +702,10 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 #endif
 	if (!isEmpty())
 	{
-		mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].getLength3().getF32() :
+		mRadius = getSpatialPartition()->mRenderByGroup ? mObjectBounds[1].getLength3().getF32() :
 						(F32) mOctreeNode->getSize().getLength3().getF32();
-		mDistance = mSpatialPartition->calcDistance(this, camera);
-		mPixelArea = mSpatialPartition->calcPixelArea(this, camera);
+		mDistance = getSpatialPartition()->calcDistance(this, camera);
+		mPixelArea = getSpatialPartition()->calcPixelArea(this, camera);
 	}
 }
 
@@ -1056,7 +728,7 @@ F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera)
 
 		if (!group->hasState(LLSpatialGroup::ALPHA_DIRTY))
 		{
-			if (!group->mSpatialPartition->isBridge())
+			if (!group->getSpatialPartition()->isBridge())
 			{
 				LLVector4a view_angle = eye;
 
@@ -1124,11 +796,6 @@ F32 LLSpatialGroup::getUpdateUrgency() const
 	}
 }
 
-BOOL LLSpatialGroup::needsUpdate()
-{
-	return (LLDrawable::getCurrentFrame()%mSpatialPartition->mLODPeriod == mLODHash) ? TRUE : FALSE;
-}
-
 BOOL LLSpatialGroup::changeLOD()
 {
 	if (hasState(ALPHA_DIRTY | OBJECT_DIRTY))
@@ -1136,11 +803,11 @@ BOOL LLSpatialGroup::changeLOD()
 		return TRUE;
 	}
 
-	if (mSpatialPartition->mSlopRatio > 0.f)
+	if (getSpatialPartition()->mSlopRatio > 0.f)
 	{
 		F32 ratio = (mDistance - mLastUpdateDistance)/(llmax(mLastUpdateDistance, mRadius));
 
-		if (fabsf(ratio) >= mSpatialPartition->mSlopRatio)
+		if (fabsf(ratio) >= getSpatialPartition()->mSlopRatio)
 		{
 			return TRUE;
 		}
@@ -1193,7 +860,7 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
 	}
 	
 	//clean up avatar attachment stats
-	LLSpatialBridge* bridge = mSpatialPartition->asBridge();
+	LLSpatialBridge* bridge = getSpatialPartition()->asBridge();
 	if (bridge)
 	{
 		if (bridge->mAvatar.notNull())
@@ -1214,7 +881,7 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c
 {
 	if (child->getListenerCount() == 0)
 	{
-		new LLSpatialGroup(child, mSpatialPartition);
+		new LLSpatialGroup(child, getSpatialPartition());
 	}
 	else
 	{
@@ -1243,14 +910,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 
 	if (!keep_occlusion)
 	{
-		for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
-		{
-			if (mOcclusionQuery[i])
-			{
-				release_occlusion_query_object_name(mOcclusionQuery[i]);
-				mOcclusionQuery[i] = 0;
-			}
-		}
+		releaseOcclusionQueryObjectNames();
 	}
 
 
@@ -1272,233 +932,13 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait");
-
-void LLSpatialGroup::checkOcclusion()
-{
-	if (LLPipeline::sUseOcclusion > 1)
-	{
-		LLFastTimer t(FTM_OCCLUSION_READBACK);
-		LLSpatialGroup* parent = getParent();
-		if (parent && parent->isOcclusionState(LLSpatialGroup::OCCLUDED))
-		{	//if the parent has been marked as occluded, the child is implicitly occluded
-			clearOcclusionState(QUERY_PENDING | DISCARD_QUERY);
-		}
-		else if (isOcclusionState(QUERY_PENDING))
-		{	//otherwise, if a query is pending, read it back
-
-			GLuint available = 0;
-			if (mOcclusionQuery[LLViewerCamera::sCurCameraID])
-			{
-				glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available);
-
-				static LLCachedControl<bool> wait_for_query(gSavedSettings, "RenderSynchronousOcclusion");
-
-				if (wait_for_query && mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount)
-				{ //query was issued last frame, wait until it's available
-					S32 max_loop = 1024;
-					LLFastTimer t(FTM_OCCLUSION_WAIT);
-					while (!available && max_loop-- > 0)
-					{
-						F32 max_time = llmin(gFrameIntervalSeconds.value()*10.f, 1.f);
-						//do some usefu work while we wait
-						LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
-						LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
-						LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread
-						
-						glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available);
-					}
-				}
-			}
-			else
-			{
-				available = 1;
-			}
-
-			if (available)
-			{ //result is available, read it back, otherwise wait until next frame
-				GLuint res = 1;
-				if (!isOcclusionState(DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
-				{
-					glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_ARB, &res);	
-#if LL_TRACK_PENDING_OCCLUSION_QUERIES
-					sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
-#endif
-				}
-				else if (mOcclusionQuery[LLViewerCamera::sCurCameraID])
-				{ //delete the query to avoid holding onto hundreds of pending queries
-					release_occlusion_query_object_name(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
-					mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0;
-				}
-				
-				if (isOcclusionState(DISCARD_QUERY))
-				{
-					res = 2;
-				}
-
-				if (res > 0)
-				{
-					assert_states_valid(this);
-					clearOcclusionState(LLSpatialGroup::OCCLUDED, LLSpatialGroup::STATE_MODE_DIFF);
-					assert_states_valid(this);
-				}
-				else
-				{
-					assert_states_valid(this);
-					
-					setOcclusionState(LLSpatialGroup::OCCLUDED, LLSpatialGroup::STATE_MODE_DIFF);
-					
-					assert_states_valid(this);
-				}
-
-				clearOcclusionState(QUERY_PENDING | DISCARD_QUERY);
-			}
-		}
-		else if (mSpatialPartition->isOcclusionEnabled() && isOcclusionState(LLSpatialGroup::OCCLUDED))
-		{	//check occlusion has been issued for occluded node that has not had a query issued
-			assert_states_valid(this);
-			clearOcclusionState(LLSpatialGroup::OCCLUDED, LLSpatialGroup::STATE_MODE_DIFF);
-			assert_states_valid(this);
-		}
-	}
-}
-
-static LLFastTimer::DeclareTimer FTM_PUSH_OCCLUSION_VERTS("Push Occlusion");
-static LLFastTimer::DeclareTimer FTM_SET_OCCLUSION_STATE("Occlusion State");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_ALLOCATE("Allocate");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_BUILD("Build");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_BEGIN_QUERY("Begin Query");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_END_QUERY("End Query");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw");
-
-
-
-void LLSpatialGroup::doOcclusion(LLCamera* camera)
-{
-	if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1)
-	{
-		// Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension
-		if (earlyFail(camera, this))
-		{
-			LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL);
-			setOcclusionState(LLSpatialGroup::DISCARD_QUERY);
-			assert_states_valid(this);
-			clearOcclusionState(LLSpatialGroup::OCCLUDED, LLSpatialGroup::STATE_MODE_DIFF);
-			assert_states_valid(this);
-		}
-		else
-		{
-			if (!isOcclusionState(QUERY_PENDING) || isOcclusionState(DISCARD_QUERY))
-			{
-				{ //no query pending, or previous query to be discarded
-					LLFastTimer t(FTM_RENDER_OCCLUSION);
-
-					if (!mOcclusionQuery[LLViewerCamera::sCurCameraID])
-					{
-						LLFastTimer t(FTM_OCCLUSION_ALLOCATE);
-						mOcclusionQuery[LLViewerCamera::sCurCameraID] = get_new_occlusion_query_object_name();
-					}
-
-					// Depth clamp all water to avoid it being culled as a result of being
-					// behind the far clip plane, and in the case of edge water to avoid
-					// it being culled while still visible.
-					bool const use_depth_clamp = gGLManager.mHasDepthClamp &&
-												(mSpatialPartition->mDrawableType == LLDrawPool::POOL_WATER ||						
-												mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER);
-
-					LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0);				
-						
-#if !LL_DARWIN					
-					U32 mode = gGLManager.mHasOcclusionQuery2 ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED_ARB;
-#else
-					U32 mode = GL_SAMPLES_PASSED_ARB;
-#endif
-					
-#if LL_TRACK_PENDING_OCCLUSION_QUERIES
-					sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
-#endif
-
-					{
-						LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS);
-						
-						//store which frame this query was issued on
-						mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount;
-
-						{
-							LLFastTimer t(FTM_OCCLUSION_BEGIN_QUERY);
-							glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]);					
-						}
-					
-						LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
-						llassert(shader);
-
-						shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mBounds[0].getF32ptr());
-						shader->uniform3f(LLShaderMgr::BOX_SIZE, mBounds[1][0]+SG_OCCLUSION_FUDGE, 
-																 mBounds[1][1]+SG_OCCLUSION_FUDGE, 
-																 mBounds[1][2]+SG_OCCLUSION_FUDGE);
-
-						if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER)
-						{
-							LLFastTimer t(FTM_OCCLUSION_DRAW_WATER);
-
-							LLGLSquashToFarClip squash(glh_get_current_projection(), 1);
-							if (camera->getOrigin().isExactlyZero())
-							{ //origin is invalid, draw entire box
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);				
-							}
-							else
-							{
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
-							}
-						}
-						else
-						{
-							LLFastTimer t(FTM_OCCLUSION_DRAW);
-							if (camera->getOrigin().isExactlyZero())
-							{ //origin is invalid, draw entire box
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);				
-							}
-							else
-							{
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
-							}
-						}
-
-
-						{
-							LLFastTimer t(FTM_OCCLUSION_END_QUERY);
-							glEndQueryARB(mode);
-						}
-					}
-				}
-
-				{
-					LLFastTimer t(FTM_SET_OCCLUSION_STATE);
-					setOcclusionState(LLSpatialGroup::QUERY_PENDING);
-					clearOcclusionState(LLSpatialGroup::DISCARD_QUERY);
-				}
-			}
-		}
-	}
-}
-
 //==============================================
 
 LLSpatialPartition::LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 buffer_usage, LLViewerRegion* regionp)
 : mRenderByGroup(render_by_group), mBridge(NULL)
 {
-	mRegionp = regionp;
-	mOcclusionEnabled = TRUE;
-	mDrawableType = 0;
-	mPartitionType = LLViewerRegion::PARTITION_NONE;
-	mLODSeed = 0;
-	mLODPeriod = 1;
+	mRegionp = regionp;		
+	mPartitionType = LLViewerRegion::PARTITION_NONE;		
 	mVertexDataMask = data_mask;
 	mBufferUsage = buffer_usage;
 	mDepthMask = FALSE;
@@ -1566,11 +1006,11 @@ void LLSpatialPartition::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL
 		
 	BOOL was_visible = curp ? curp->isVisible() : FALSE;
 
-	if (curp && curp->mSpatialPartition != this)
+	if (curp && curp->getSpatialPartition() != this)
 	{
 		//keep drawable from being garbage collected
 		LLPointer<LLDrawable> ptr = drawablep;
-		if (curp->mSpatialPartition->remove(drawablep, curp))
+		if (curp->getSpatialPartition()->remove(drawablep, curp))
 		{
 			put(drawablep, was_visible);
 			return;
@@ -1961,7 +1401,7 @@ public:
 			{
 				continue;
 			}
-			if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup)
+			if (drawable->getVObj().notNull() && !group->getSpatialPartition()->mRenderByGroup)
 			{
 				gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE);
 			}
@@ -1985,11 +1425,6 @@ void LLSpatialPartition::resetVertexBuffers()
 	dirty.traverse(mOctree);
 }
 
-BOOL LLSpatialPartition::isOcclusionEnabled()
-{
-	return mOcclusionEnabled || LLPipeline::sUseOcclusion > 2;
-}
-
 BOOL LLSpatialPartition::getVisibleExtents(LLCamera& camera, LLVector3& visMin, LLVector3& visMax)
 {
 	LLVector4a visMina, visMaxa;
@@ -2075,51 +1510,6 @@ S32 LLSpatialPartition::cull(LLCamera &camera)
 	return 0;
 }
 
-BOOL earlyFail(LLCamera* camera, LLSpatialGroup* group)
-{
-	if (camera->getOrigin().isExactlyZero())
-	{
-		return FALSE;
-	}
-
-	const F32 vel = SG_OCCLUSION_FUDGE*2.f;
-	LLVector4a fudge;
-	fudge.splat(vel);
-
-	const LLVector4a* bounds = group->getBounds();
-	const LLVector4a& c = bounds[0];
-	LLVector4a r;
-	r.setAdd(bounds[1], fudge);
-
-	/*if (r.magVecSquared() > 1024.0*1024.0)
-	{
-		return TRUE;
-	}*/
-
-	LLVector4a e;
-	e.load3(camera->getOrigin().mV);
-	
-	LLVector4a min;
-	min.setSub(c,r);
-	LLVector4a max;
-	max.setAdd(c,r);
-	
-	S32 lt = e.lessThan(min).getGatheredBits() & 0x7;
-	if (lt)
-	{
-		return FALSE;
-	}
-
-	S32 gt = e.greaterThan(max).getGatheredBits() & 0x7;
-	if (gt)
-	{
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-
 void pushVerts(LLDrawInfo* params, U32 mask)
 {
 	LLRenderPass::applyModelMatrix(*params);
@@ -2191,7 +1581,7 @@ void pushBufferVerts(LLVertexBuffer* buffer, U32 mask)
 
 void pushBufferVerts(LLSpatialGroup* group, U32 mask)
 {
-	if (group->mSpatialPartition->mRenderByGroup)
+	if (group->getSpatialPartition()->mRenderByGroup)
 	{
 		if (!group->mDrawMap.empty())
 		{
@@ -2292,7 +1682,7 @@ void renderOctree(LLSpatialGroup* group)
 				{
 					continue;
 				}
-				if (!group->mSpatialPartition->isBridge())
+				if (!group->getSpatialPartition()->isBridge())
 				{
 					gGL.pushMatrix();
 					LLVector3 trans = drawable->getRegion()->getOriginAgent();
@@ -2324,7 +1714,7 @@ void renderOctree(LLSpatialGroup* group)
 					}
 				}
 
-				if (!group->mSpatialPartition->isBridge())
+				if (!group->getSpatialPartition()->isBridge())
 				{
 					gGL.popMatrix();
 				}
@@ -2336,7 +1726,7 @@ void renderOctree(LLSpatialGroup* group)
 	else
 	{
 		if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->isEmpty() 
-			&& group->mSpatialPartition->mRenderByGroup)
+			&& group->getSpatialPartition()->mRenderByGroup)
 		{
 			col.setVec(0.8f, 0.4f, 0.1f, 0.1f);
 		}
@@ -2373,7 +1763,7 @@ void renderOctree(LLSpatialGroup* group)
 		drawBoxOutline(bounds[0], bounds[1]);
 		
 		//draw bounding box for draw info
-		/*if (group->mSpatialPartition->mRenderByGroup)
+		/*if (group->getSpatialPartition()->mRenderByGroup)
 		{
 			gGL.diffuseColor4f(1.0f, 0.75f, 0.25f, 0.6f);
 			for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
@@ -3147,7 +2537,7 @@ void renderPhysicsShapes(LLSpatialGroup* group)
 		LLVOVolume* volume = drawable->getVOVolume();
 		if (volume && !volume->isAttachment() && volume->getPhysicsShapeType() != LLViewerObject::PHYSICS_SHAPE_NONE )
 		{
-			if (!group->mSpatialPartition->isBridge())
+			if (!group->getSpatialPartition()->isBridge())
 			{
 				gGL.pushMatrix();
 				LLVector3 trans = drawable->getRegion()->getOriginAgent();
@@ -4225,9 +3615,9 @@ public:
 			LLVector3 local_start = mStart;
 			LLVector3 local_end   = mEnd;
 
-			if (group->mSpatialPartition->isBridge())
+			if (group->getSpatialPartition()->isBridge())
 			{
-				LLMatrix4 local_matrix = group->mSpatialPartition->asBridge()->mDrawable->getRenderMatrix();
+				LLMatrix4 local_matrix = group->getSpatialPartition()->asBridge()->mDrawable->getRenderMatrix();
 				local_matrix.invert();
 				
 				local_start = mStart * local_matrix;
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index b592e73403..406e796d4d 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -55,12 +55,6 @@ class LLViewerRegion;
 
 void pushVerts(LLFace* face, U32 mask);
 
-// get index buffer for binary encoded axis vertex buffer given a box at center being viewed by given camera
-U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center);
-U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center);
-GLuint get_new_occlusion_query_object_name();
-void release_occlusion_query_object_name(GLuint name);
-
 class LLDrawInfo : public LLRefCount 
 {
 protected:
@@ -191,13 +185,13 @@ public:
 };
 
 LL_ALIGN_PREFIX(16)
-class LLSpatialGroup : public LLviewerOctreeGroup
+class LLSpatialGroup : public LLOcclusionCullingGroup
 {
 	friend class LLSpatialPartition;
 	friend class LLOctreeStateCheck;
 public:
 
-	LLSpatialGroup(const LLSpatialGroup& rhs) : LLviewerOctreeGroup(rhs)
+	LLSpatialGroup(const LLSpatialGroup& rhs) : LLOcclusionCullingGroup(rhs)
 	{
 		*this = rhs;
 	}
@@ -218,7 +212,6 @@ public:
 		return *this;
 	}
 
-	static std::set<GLuint> sPendingQueries; //pending occlusion queries
 	static U32 sNodeCount;
 	static BOOL sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE
 
@@ -256,17 +249,7 @@ public:
 
 	typedef enum
 	{
-		OCCLUDED				= 0x00010000,
-		QUERY_PENDING			= 0x00020000,
-		ACTIVE_OCCLUSION		= 0x00040000,
-		DISCARD_QUERY			= 0x00080000,
-		EARLY_FAIL				= 0x00100000,
-	} eOcclusionState;
-
-	typedef enum
-	{
-		DEAD					= LLviewerOctreeGroup::INVALID_STATE,
-		GEOM_DIRTY				= (DEAD << 1),
+		GEOM_DIRTY				= LLviewerOctreeGroup::INVALID_STATE,
 		ALPHA_DIRTY				= (GEOM_DIRTY << 1),
 		IN_IMAGE_QUEUE			= (ALPHA_DIRTY << 1),
 		IMAGE_DIRTY				= (IN_IMAGE_QUEUE << 1),
@@ -275,33 +258,19 @@ public:
 		IN_BUILD_Q1				= (NEW_DRAWINFO << 1),
 		IN_BUILD_Q2				= (IN_BUILD_Q1 << 1),
 		STATE_MASK				= 0x0000FFFF,
-	} eSpatialState;
-
-	typedef enum
-	{
-		STATE_MODE_SINGLE = 0,		//set one node
-		STATE_MODE_BRANCH,			//set entire branch
-		STATE_MODE_DIFF,			//set entire branch as long as current state is different
-		STATE_MODE_ALL_CAMERAS,		//used for occlusion state, set state for all cameras
-	} eSetStateMode;
+	} eSpatialState;	
 
 	LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part);
 
-	BOOL isHUDGroup() ;
-	BOOL isDead()							{ return hasState(DEAD); }
-	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }
+	BOOL isHUDGroup() ;	
 	
 	void clearDrawMap();
 	void validate();
-	void checkStates();
 	void validateDrawMap();
 	
 	void setState(U32 state, S32 mode);
 	void clearState(U32 state, S32 mode);
-	void clearState(U32 state)     {mState &= ~state;}	
-
-	void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
-	void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
+	void clearState(U32 state)     {mState &= ~state;}		
 
 	LLSpatialGroup* getParent();
 
@@ -309,13 +278,10 @@ public:
 	BOOL removeObject(LLDrawable *drawablep, BOOL from_octree = FALSE);
 	BOOL updateInGroup(LLDrawable *drawablep, BOOL immediate = FALSE); // Update position if it's in the group
 	BOOL isRecentlyVisible() const;
-	void shift(const LLVector4a &offset);
-	void checkOcclusion(); //read back last occlusion query (if any)
-	void doOcclusion(LLCamera* camera); //issue occlusion query
+	void shift(const LLVector4a &offset);	
 	void destroyGL(bool keep_occlusion = false);
 	
 	void updateDistance(LLCamera& camera);
-	BOOL needsUpdate();
 	F32 getUpdateUrgency() const;
 	BOOL changeLOD();
 	void rebuildGeom();
@@ -327,6 +293,8 @@ public:
 
 	void drawObjectBox(LLColor4 col);
 
+	LLSpatialPartition* getSpatialPartition() {return (LLSpatialPartition*)mSpatialPartition;}
+
 	 //LISTENER FUNCTIONS
 	virtual void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* face);
 	virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face);
@@ -372,12 +340,8 @@ private:
 //-------------------
 
 protected:
-	virtual ~LLSpatialGroup();
-
-	U32 mOcclusionState[LLViewerCamera::NUM_CAMERAS];
-	U32 mOcclusionIssued[LLViewerCamera::NUM_CAMERAS];
-
-	S32 mLODHash;
+	virtual ~LLSpatialGroup();	
+	
 	static S32 sLODSeed;
 
 public:
@@ -387,11 +351,9 @@ public:
 	U32 mGeometryBytes; //used by volumes to track how many bytes of geometry data are in this node
 	F32 mSurfaceArea; //used by volumes to track estimated surface area of geometry in this node
 
-	F32 mBuilt;
-	LLSpatialPartition* mSpatialPartition;
+	F32 mBuilt;	
 	
-	LLPointer<LLVertexBuffer> mVertexBuffer;
-	GLuint					mOcclusionQuery[LLViewerCamera::NUM_CAMERAS];
+	LLPointer<LLVertexBuffer> mVertexBuffer;	
 
 	U32 mBufferUsage;
 	draw_map_t mDrawMap;
@@ -461,21 +423,18 @@ public:
 	void renderDebug();
 	void renderIntersectingBBoxes(LLCamera* camera);
 	void restoreGL();
-	void resetVertexBuffers();
-	BOOL isOcclusionEnabled();
+	void resetVertexBuffers();	
+
 	BOOL getVisibleExtents(LLCamera& camera, LLVector3& visMin, LLVector3& visMax);
 
 public:
 	LLSpatialBridge* mBridge; // NULL for non-LLSpatialBridge instances, otherwise, mBridge == this
 							// use a pointer instead of making "isBridge" and "asBridge" virtual so it's safe
-							// to call asBridge() from the destructor
-	BOOL mOcclusionEnabled; // if TRUE, occlusion culling is performed
+							// to call asBridge() from the destructor	
+	
 	BOOL mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane
-	U32 mBufferUsage;
-	U32   mDrawableType;
-	const BOOL mRenderByGroup;
-	U32 mLODSeed;
-	U32 mLODPeriod;	//number of frames between LOD updates for a given spatial group (staggered by mLODSeed)
+	U32 mBufferUsage;	
+	const BOOL mRenderByGroup;	
 	U32 mVertexDataMask;
 	F32 mSlopRatio; //percentage distance must change before drawables receive LOD update (default is 0.25);
 	BOOL mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 926d791d1f..844075089f 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -27,6 +27,11 @@
 #include "llviewerprecompiledheaders.h"
 #include "llvieweroctree.h"
 #include "llviewerregion.h"
+#include "pipeline.h"
+#include "llviewercontrol.h"
+#include "llappviewer.h"
+#include "llglslshader.h"
+#include "llviewershadermgr.h"
 
 //-----------------------------------------------------------------------------------
 //static variables definitions
@@ -37,6 +42,100 @@ BOOL LLViewerOctreeDebug::sInDebug = FALSE;
 //-----------------------------------------------------------------------------------
 //some global functions definitions
 //-----------------------------------------------------------------------------------
+typedef enum
+{
+	b000 = 0x00,
+	b001 = 0x01,
+	b010 = 0x02,
+	b011 = 0x03,
+	b100 = 0x04,
+	b101 = 0x05,
+	b110 = 0x06,
+	b111 = 0x07,
+} eLoveTheBits;
+
+//contact Runitai Linden for a copy of the SL object used to write this table
+//basically, you give the table a bitmask of the look-at vector to a node and it
+//gives you a triangle fan index array
+static U16 sOcclusionIndices[] =
+{
+	 //000
+		b111, b110, b010, b011, b001, b101, b100, b110,
+	 //001 
+		b011, b010, b000, b001, b101, b111, b110, b010,
+	 //010
+		b101, b100, b110, b111, b011, b001, b000, b100,
+	 //011 
+		b001, b000, b100, b101, b111, b011, b010, b000,
+	 //100 
+		b110, b000, b010, b011, b111, b101, b100, b000,
+	 //101 
+		b010, b100, b000, b001, b011, b111, b110, b100,
+	 //110
+		b100, b010, b110, b111, b101, b001, b000, b010,
+	 //111
+		b000, b110, b100, b101, b001, b011, b010, b110,
+};
+
+U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center)
+{
+	LLVector4a origin;
+	origin.load3(camera->getOrigin().mV);
+
+	S32 cypher = center.greaterThan(origin).getGatheredBits() & 0x7;
+	
+	return cypher*8;
+}
+
+U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center)
+{
+	LLVector4a origin;
+	origin.load3(camera->getOrigin().mV);
+
+	S32 cypher = center.greaterThan(origin).getGatheredBits() & 0x7;
+	
+	return (U8*) (sOcclusionIndices+cypher*8);
+}
+
+//create a vertex buffer for efficiently rendering cubes
+LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage)
+{
+	LLVertexBuffer* ret = new LLVertexBuffer(type_mask, usage);
+
+	ret->allocateBuffer(8, 64, true);
+
+	LLStrider<LLVector3> pos;
+	LLStrider<U16> idx;
+
+	ret->getVertexStrider(pos);
+	ret->getIndexStrider(idx);
+
+	pos[0] = LLVector3(-1,-1,-1);
+	pos[1] = LLVector3(-1,-1, 1);
+	pos[2] = LLVector3(-1, 1,-1);
+	pos[3] = LLVector3(-1, 1, 1);
+	pos[4] = LLVector3( 1,-1,-1);
+	pos[5] = LLVector3( 1,-1, 1);
+	pos[6] = LLVector3( 1, 1,-1);
+	pos[7] = LLVector3( 1, 1, 1);
+
+	for (U32 i = 0; i < 64; i++)
+	{
+		idx[i] = sOcclusionIndices[i];
+	}
+
+	ret->flush();
+
+	return ret;
+}
+
+
+#define LL_TRACK_PENDING_OCCLUSION_QUERIES 0
+
+const F32 SG_OCCLUSION_FUDGE = 0.25f;
+#define SG_DISCARD_TOLERANCE 0.01f
+
+
 S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad)
 {
 	return AABBSphereIntersectR2(min, max, origin, rad*rad);
@@ -540,6 +639,11 @@ void LLviewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const Oct
 
 LLviewerOctreeGroup* LLviewerOctreeGroup::getParent()
 {
+	if (isDead())
+	{
+		return NULL;
+	}
+
 	if(!mOctreeNode)
 	{
 		return NULL;
@@ -629,10 +733,519 @@ void LLviewerOctreeGroup::setVisible()
 {
 	mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
 }
+
+void LLviewerOctreeGroup::checkStates()
+{
+#if LL_OCTREE_PARANOIA_CHECK
+	//LLOctreeStateCheck checker;
+	//checker.traverse(mOctreeNode);
+#endif
+}
+
+//-------------------------------------------------------------------------------------------
+//occulsion culling functions and classes
+//-------------------------------------------------------------------------------------------
+std::set<U32> LLOcclusionCullingGroup::sPendingQueries;
+class LLOcclusionQueryPool : public LLGLNamePool
+{
+public:
+	LLOcclusionQueryPool()
+	{
+		mCurQuery = 1;
+	}
+
+protected:
+
+	std::list<GLuint> mAvailableName;
+	GLuint mCurQuery;
+		
+	virtual GLuint allocateName()
+	{
+		GLuint ret = 0;
+
+		if (!mAvailableName.empty())
+		{
+			ret = mAvailableName.front();
+			mAvailableName.pop_front();
+		}
+		else
+		{
+			ret = mCurQuery++;
+		}
+
+		return ret;
+	}
+
+	virtual void releaseName(GLuint name)
+	{
+#if LL_TRACK_PENDING_OCCLUSION_QUERIES
+		LLSpatialGroup::sPendingQueries.erase(name);
+#endif
+		llassert(std::find(mAvailableName.begin(), mAvailableName.end(), name) == mAvailableName.end());
+		mAvailableName.push_back(name);
+	}
+};
+
+static LLOcclusionQueryPool sQueryPool;
+U32 LLOcclusionCullingGroup::getNewOcclusionQueryObjectName()
+{
+	return sQueryPool.allocate();
+}
+
+void LLOcclusionCullingGroup::releaseOcclusionQueryObjectName(GLuint name)
+{
+	sQueryPool.release(name);
+}
+
+//=====================================
+//		Occlusion State Set/Clear
+//=====================================
+class LLSpatialSetOcclusionState : public OctreeTraveler
+{
+public:
+	U32 mState;
+	LLSpatialSetOcclusionState(U32 state) : mState(state) { }
+	virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->setOcclusionState(mState); }	
+};
+
+class LLSpatialSetOcclusionStateDiff : public LLSpatialSetOcclusionState
+{
+public:
+	LLSpatialSetOcclusionStateDiff(U32 state) : LLSpatialSetOcclusionState(state) { }
+
+	virtual void traverse(const OctreeNode* n)
+	{
+		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0);
+		
+		if (!group->isOcclusionState(mState))
+		{
+			OctreeTraveler::traverse(n);
+		}
+	}
+};
+
+
+LLOcclusionCullingGroup::LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part) : 
+	LLviewerOctreeGroup(node),
+	mSpatialPartition(part)
+{
+	part->mLODSeed = (part->mLODSeed+1)%part->mLODPeriod;
+	mLODHash = part->mLODSeed;
+
+	OctreeNode* oct_parent = node->getOctParent();
+	LLOcclusionCullingGroup* parent = oct_parent ? (LLOcclusionCullingGroup*) oct_parent->getListener(0) : NULL;
+
+	for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
+	{
+		mOcclusionQuery[i] = 0;
+		mOcclusionIssued[i] = 0;
+		mOcclusionState[i] = parent ? SG_STATE_INHERIT_MASK & parent->mOcclusionState[i] : 0;
+		mVisible[i] = 0;
+	}
+}
+
+LLOcclusionCullingGroup::~LLOcclusionCullingGroup()
+{
+	releaseOcclusionQueryObjectNames();
+}
+
+BOOL LLOcclusionCullingGroup::needsUpdate()
+{
+	return (LLDrawable::getCurrentFrame() % mSpatialPartition->mLODPeriod == mLODHash) ? TRUE : FALSE;
+}
+
+//virtual 
+void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child)
+{
+	if (child->getListenerCount() == 0)
+	{
+		new LLOcclusionCullingGroup(child, mSpatialPartition);
+	}
+	else
+	{
+		OCT_ERRS << "LLOcclusionCullingGroup redundancy detected." << llendl;
+	}
+
+	unbound();
+	
+	((LLviewerOctreeGroup*)child->getListener(0))->unbound();
+}
+
+void LLOcclusionCullingGroup::releaseOcclusionQueryObjectNames()
+{
+	if (gGLManager.mHasOcclusionQuery)
+	{
+		for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; ++i)
+		{
+			if (mOcclusionQuery[i])
+			{
+				releaseOcclusionQueryObjectName(mOcclusionQuery[i]);
+				mOcclusionQuery[i] = 0;
+			}
+		}
+	}
+}
+
+void LLOcclusionCullingGroup::setOcclusionState(U32 state, S32 mode) 
+{
+	if (mode > STATE_MODE_SINGLE)
+	{
+		if (mode == STATE_MODE_DIFF)
+		{
+			LLSpatialSetOcclusionStateDiff setter(state);
+			setter.traverse(mOctreeNode);
+		}
+		else if (mode == STATE_MODE_BRANCH)
+		{
+			LLSpatialSetOcclusionState setter(state);
+			setter.traverse(mOctreeNode);
+		}
+		else
+		{
+			for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
+			{
+				mOcclusionState[i] |= state;
+
+				if ((state & DISCARD_QUERY) && mOcclusionQuery[i])
+				{
+					releaseOcclusionQueryObjectName(mOcclusionQuery[i]);
+					mOcclusionQuery[i] = 0;
+				}
+			}
+		}
+	}
+	else
+	{
+		mOcclusionState[LLViewerCamera::sCurCameraID] |= state;
+		if ((state & DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
+		{
+			releaseOcclusionQueryObjectName(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
+			mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0;
+		}
+	}
+}
+
+class LLSpatialClearOcclusionState : public OctreeTraveler
+{
+public:
+	U32 mState;
+	
+	LLSpatialClearOcclusionState(U32 state) : mState(state) { }
+	virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->clearOcclusionState(mState); }
+};
+
+class LLSpatialClearOcclusionStateDiff : public LLSpatialClearOcclusionState
+{
+public:
+	LLSpatialClearOcclusionStateDiff(U32 state) : LLSpatialClearOcclusionState(state) { }
+
+	virtual void traverse(const OctreeNode* n)
+	{
+		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0);
+		
+		if (group->isOcclusionState(mState))
+		{
+			OctreeTraveler::traverse(n);
+		}
+	}
+};
+
+void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode)
+{
+	if (mode > STATE_MODE_SINGLE)
+	{
+		if (mode == STATE_MODE_DIFF)
+		{
+			LLSpatialClearOcclusionStateDiff clearer(state);
+			clearer.traverse(mOctreeNode);
+		}
+		else if (mode == STATE_MODE_BRANCH)
+		{
+			LLSpatialClearOcclusionState clearer(state);
+			clearer.traverse(mOctreeNode);
+		}
+		else
+		{
+			for (U32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
+			{
+				mOcclusionState[i] &= ~state;
+			}
+		}
+	}
+	else
+	{
+		mOcclusionState[LLViewerCamera::sCurCameraID] &= ~state;
+	}
+}
+
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait");
+
+BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera)
+{
+	if (camera->getOrigin().isExactlyZero())
+	{
+		return FALSE;
+	}
+
+	const F32 vel = SG_OCCLUSION_FUDGE*2.f;
+	LLVector4a fudge;
+	fudge.splat(vel);
+
+	const LLVector4a* bounds = getBounds();
+	const LLVector4a& c = bounds[0];
+	LLVector4a r;
+	r.setAdd(bounds[1], fudge);
+
+	/*if (r.magVecSquared() > 1024.0*1024.0)
+	{
+		return TRUE;
+	}*/
+
+	LLVector4a e;
+	e.load3(camera->getOrigin().mV);
+	
+	LLVector4a min;
+	min.setSub(c,r);
+	LLVector4a max;
+	max.setAdd(c,r);
+	
+	S32 lt = e.lessThan(min).getGatheredBits() & 0x7;
+	if (lt)
+	{
+		return FALSE;
+	}
+
+	S32 gt = e.greaterThan(max).getGatheredBits() & 0x7;
+	if (gt)
+	{
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+void LLOcclusionCullingGroup::checkOcclusion()
+{
+	if (LLPipeline::sUseOcclusion > 1)
+	{
+		LLFastTimer t(FTM_OCCLUSION_READBACK);
+		LLOcclusionCullingGroup* parent = (LLOcclusionCullingGroup*)getParent();
+		if (parent && parent->isOcclusionState(LLOcclusionCullingGroup::OCCLUDED))
+		{	//if the parent has been marked as occluded, the child is implicitly occluded
+			clearOcclusionState(QUERY_PENDING | DISCARD_QUERY);
+		}
+		else if (isOcclusionState(QUERY_PENDING))
+		{	//otherwise, if a query is pending, read it back
+
+			GLuint available = 0;
+			if (mOcclusionQuery[LLViewerCamera::sCurCameraID])
+			{
+				glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available);
+
+				static LLCachedControl<bool> wait_for_query(gSavedSettings, "RenderSynchronousOcclusion");
+
+				if (wait_for_query && mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount)
+				{ //query was issued last frame, wait until it's available
+					S32 max_loop = 1024;
+					LLFastTimer t(FTM_OCCLUSION_WAIT);
+					while (!available && max_loop-- > 0)
+					{
+						//do some usefu work while we wait
+						F32 max_time = llmin(gFrameIntervalSeconds.value()*10.f, 1.f);
+						LLAppViewer::instance()->updateTextureThreads(max_time);
+						
+						glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_AVAILABLE_ARB, &available);
+					}
+				}
+			}
+			else
+			{
+				available = 1;
+			}
+
+			if (available)
+			{ //result is available, read it back, otherwise wait until next frame
+				GLuint res = 1;
+				if (!isOcclusionState(DISCARD_QUERY) && mOcclusionQuery[LLViewerCamera::sCurCameraID])
+				{
+					glGetQueryObjectuivARB(mOcclusionQuery[LLViewerCamera::sCurCameraID], GL_QUERY_RESULT_ARB, &res);	
+#if LL_TRACK_PENDING_OCCLUSION_QUERIES
+					sPendingQueries.erase(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
+#endif
+				}
+				else if (mOcclusionQuery[LLViewerCamera::sCurCameraID])
+				{ //delete the query to avoid holding onto hundreds of pending queries
+					releaseOcclusionQueryObjectName(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
+					mOcclusionQuery[LLViewerCamera::sCurCameraID] = 0;
+				}
+				
+				if (isOcclusionState(DISCARD_QUERY))
+				{
+					res = 2;
+				}
+
+				if (res > 0)
+				{
+					assert_states_valid(this);
+					clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF);
+					assert_states_valid(this);
+				}
+				else
+				{
+					assert_states_valid(this);
+					
+					setOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF);
+					
+					assert_states_valid(this);
+				}
+
+				clearOcclusionState(QUERY_PENDING | DISCARD_QUERY);
+			}
+		}
+		else if (mSpatialPartition->isOcclusionEnabled() && isOcclusionState(LLOcclusionCullingGroup::OCCLUDED))
+		{	//check occlusion has been issued for occluded node that has not had a query issued
+			assert_states_valid(this);
+			clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF);
+			assert_states_valid(this);
+		}
+	}
+}
+
+static LLFastTimer::DeclareTimer FTM_PUSH_OCCLUSION_VERTS("Push Occlusion");
+static LLFastTimer::DeclareTimer FTM_SET_OCCLUSION_STATE("Occlusion State");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_ALLOCATE("Allocate");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_BUILD("Build");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_BEGIN_QUERY("Begin Query");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_END_QUERY("End Query");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water");
+static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw");
+
+void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera)
+{
+	if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1)
+	{
+		// Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension
+		if (earlyFail(camera))
+		{
+			LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL);
+			setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY);
+			assert_states_valid(this);
+			clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF);
+			assert_states_valid(this);
+		}
+		else
+		{
+			if (!isOcclusionState(QUERY_PENDING) || isOcclusionState(DISCARD_QUERY))
+			{
+				{ //no query pending, or previous query to be discarded
+					LLFastTimer t(FTM_RENDER_OCCLUSION);
+
+					if (!mOcclusionQuery[LLViewerCamera::sCurCameraID])
+					{
+						LLFastTimer t(FTM_OCCLUSION_ALLOCATE);
+						mOcclusionQuery[LLViewerCamera::sCurCameraID] = getNewOcclusionQueryObjectName();
+					}
+
+					// Depth clamp all water to avoid it being culled as a result of being
+					// behind the far clip plane, and in the case of edge water to avoid
+					// it being culled while still visible.
+					bool const use_depth_clamp = gGLManager.mHasDepthClamp &&
+												(mSpatialPartition->mDrawableType == LLDrawPool::POOL_WATER ||						
+												mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER);
+
+					LLGLEnable clamp(use_depth_clamp ? GL_DEPTH_CLAMP : 0);				
+						
+#if !LL_DARWIN					
+					U32 mode = gGLManager.mHasOcclusionQuery2 ? GL_ANY_SAMPLES_PASSED : GL_SAMPLES_PASSED_ARB;
+#else
+					U32 mode = GL_SAMPLES_PASSED_ARB;
+#endif
+					
+#if LL_TRACK_PENDING_OCCLUSION_QUERIES
+					sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
+#endif
+
+					{
+						LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS);
+						
+						//store which frame this query was issued on
+						mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount;
+
+						{
+							LLFastTimer t(FTM_OCCLUSION_BEGIN_QUERY);
+							glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]);					
+						}
+					
+						LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
+						llassert(shader);
+
+						shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mBounds[0].getF32ptr());
+						shader->uniform3f(LLShaderMgr::BOX_SIZE, mBounds[1][0]+SG_OCCLUSION_FUDGE, 
+																 mBounds[1][1]+SG_OCCLUSION_FUDGE, 
+																 mBounds[1][2]+SG_OCCLUSION_FUDGE);
+
+						if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER)
+						{
+							LLFastTimer t(FTM_OCCLUSION_DRAW_WATER);
+
+							LLGLSquashToFarClip squash(glh_get_current_projection(), 1);
+							if (camera->getOrigin().isExactlyZero())
+							{ //origin is invalid, draw entire box
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);				
+							}
+							else
+							{
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
+							}
+						}
+						else
+						{
+							LLFastTimer t(FTM_OCCLUSION_DRAW);
+							if (camera->getOrigin().isExactlyZero())
+							{ //origin is invalid, draw entire box
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, b111*8);				
+							}
+							else
+							{
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
+							}
+						}
+
+
+						{
+							LLFastTimer t(FTM_OCCLUSION_END_QUERY);
+							glEndQueryARB(mode);
+						}
+					}
+				}
+
+				{
+					LLFastTimer t(FTM_SET_OCCLUSION_STATE);
+					setOcclusionState(LLOcclusionCullingGroup::QUERY_PENDING);
+					clearOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY);
+				}
+			}
+		}
+	}
+}
+//-------------------------------------------------------------------------------------------
+//end of occulsion culling functions and classes
+//-------------------------------------------------------------------------------------------
+
 //-----------------------------------------------------------------------------------
 //class LLViewerOctreePartition definitions
 //-----------------------------------------------------------------------------------
-LLViewerOctreePartition::LLViewerOctreePartition() : mRegionp(NULL)
+LLViewerOctreePartition::LLViewerOctreePartition() : 
+	mRegionp(NULL), 
+	mOcclusionEnabled(TRUE), 
+	mDrawableType(0),
+	mLODSeed(0),
+	mLODPeriod(1)
 {
 	LLVector4a center, size;
 	center.splat(0.f);
@@ -647,6 +1260,11 @@ LLViewerOctreePartition::~LLViewerOctreePartition()
 	mOctree = NULL;
 }
 
+BOOL LLViewerOctreePartition::isOcclusionEnabled()
+{
+	return mOcclusionEnabled || LLPipeline::sUseOcclusion > 2;
+}
+
 //-----------------------------------------------------------------------------------
 //class LLViewerOctreeCull definitions
 //-----------------------------------------------------------------------------------
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index b6faf4c7ba..ed77e4bb7e 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -43,6 +43,7 @@ class LLViewerRegion;
 class LLViewerOctreeEntryData;
 class LLviewerOctreeGroup;
 class LLViewerOctreeEntry;
+class LLViewerOctreePartition;
 
 typedef LLOctreeListener<LLViewerOctreeEntry>	OctreeListener;
 typedef LLTreeNode<LLViewerOctreeEntry>			TreeNode;
@@ -50,6 +51,18 @@ typedef LLOctreeNode<LLViewerOctreeEntry>		OctreeNode;
 typedef LLOctreeRoot<LLViewerOctreeEntry>		OctreeRoot;
 typedef LLOctreeTraveler<LLViewerOctreeEntry>	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()
+#else
+#define assert_octree_valid(x)
+#define assert_states_valid(x)
+#endif
+
+// get index buffer for binary encoded axis vertex buffer given a box at center being viewed by given camera
+U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center);
+U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center);
+
 S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad);
 S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &radius_squared);
 
@@ -181,14 +194,15 @@ class LLviewerOctreeGroup : public LLOctreeListener<LLViewerOctreeEntry>
 protected:
 	~LLviewerOctreeGroup();
 
-public:
+public:	
 	enum
 	{
 		CLEAN              = 0x00000000,
 		DIRTY              = 0x00000001,
 		OBJECT_DIRTY       = 0x00000002,
 		SKIP_FRUSTUM_CHECK = 0x00000004,
-		INVALID_STATE      = 0x00000008,
+		DEAD               = 0x00000008,
+		INVALID_STATE      = 0x00000010,
 	};
 
 public:
@@ -216,6 +230,8 @@ public:
 
 	virtual void unbound();
 	virtual void rebound();
+	
+	BOOL isDead()							{ return hasState(DEAD); }	
 
 	void setVisible();
 	BOOL isVisible() const;
@@ -251,9 +267,11 @@ public:
 	U32 getElementCount() const { return mOctreeNode->getElementCount(); }
 	bool hasElement(LLViewerOctreeEntryData* data);
 	
+protected:
+	void checkStates();
 private:
-	virtual bool boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut);	
-	
+	virtual bool boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut);			
+
 protected:
 	U32         mState;
 	OctreeNode* mOctreeNode;	
@@ -261,12 +279,76 @@ protected:
 	LL_ALIGN_16(LLVector4a mBounds[2]);        // bounding box (center, size) of this node and all its children (tight fit to objects)
 	LL_ALIGN_16(LLVector4a mObjectBounds[2]);  // bounding box (center, size) of objects in this node
 	LL_ALIGN_16(LLVector4a mExtents[2]);       // extents (min, max) of this node and all its children
-	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
+	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node	
 
 public:
-	S32         mVisible[LLViewerCamera::NUM_CAMERAS];
+	S32         mVisible[LLViewerCamera::NUM_CAMERAS];	
+
 }LL_ALIGN_POSTFIX(16);
 
+//octree group which has capability to support occlusion culling
+//LL_ALIGN_PREFIX(16)
+class LLOcclusionCullingGroup : public LLviewerOctreeGroup
+{
+public:
+	typedef enum
+	{
+		OCCLUDED				= 0x00010000,
+		QUERY_PENDING			= 0x00020000,
+		ACTIVE_OCCLUSION		= 0x00040000,
+		DISCARD_QUERY			= 0x00080000,
+		EARLY_FAIL				= 0x00100000,
+	} eOcclusionState;
+
+	typedef enum
+	{
+		STATE_MODE_SINGLE = 0,		//set one node
+		STATE_MODE_BRANCH,			//set entire branch
+		STATE_MODE_DIFF,			//set entire branch as long as current state is different
+		STATE_MODE_ALL_CAMERAS,		//used for occlusion state, set state for all cameras
+	} eSetStateMode;
+
+public:
+	LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part);
+	LLOcclusionCullingGroup(const LLOcclusionCullingGroup& rhs) : LLviewerOctreeGroup(rhs)
+	{
+		*this = rhs;
+	}
+	~LLOcclusionCullingGroup();
+
+	void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
+	void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
+	void checkOcclusion(); //read back last occlusion query (if any)
+	void doOcclusion(LLCamera* camera); //issue occlusion query
+	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }		
+	
+	BOOL needsUpdate();
+
+	//virtual 
+	void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
+
+	static U32 getNewOcclusionQueryObjectName();
+	static void releaseOcclusionQueryObjectName(U32 name);
+
+protected:
+	void releaseOcclusionQueryObjectNames();
+
+private:	
+	BOOL earlyFail(LLCamera* camera);
+
+protected:
+	U32         mOcclusionState[LLViewerCamera::NUM_CAMERAS];
+	U32         mOcclusionIssued[LLViewerCamera::NUM_CAMERAS];
+
+	S32         mLODHash;
+
+	LLViewerOctreePartition* mSpatialPartition;
+	U32		                 mOcclusionQuery[LLViewerCamera::NUM_CAMERAS];
+
+public:		
+	static std::set<U32> sPendingQueries;
+};//LL_ALIGN_POSTFIX(16);
+
 class LLViewerOctreePartition
 {
 public:
@@ -275,11 +357,16 @@ public:
 
 	// Cull on arbitrary frustum
 	virtual S32 cull(LLCamera &camera) = 0;
+	BOOL isOcclusionEnabled();
 
 public:	
 	U32              mPartitionType;
+	U32              mDrawableType;
 	OctreeNode*      mOctree;
 	LLViewerRegion*  mRegionp; // the region this partition belongs to.
+	BOOL             mOcclusionEnabled; // if TRUE, occlusion culling is performed
+	U32              mLODSeed;
+	U32              mLODPeriod;	//number of frames between LOD updates for a given spatial group (staggered by mLODSeed)
 };
 
 class LLViewerOctreeCull : public OctreeTraveler
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index fea44a38c6..eb004106c3 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -594,9 +594,9 @@ public:
 			
 			ypos += y_inc;
 
-			if (!LLSpatialGroup::sPendingQueries.empty())
+			if (!LLOcclusionCullingGroup::sPendingQueries.empty())
 			{
-				addText(xpos,ypos, llformat("%d Queries pending", LLSpatialGroup::sPendingQueries.size()));
+				addText(xpos,ypos, llformat("%d Queries pending", LLOcclusionCullingGroup::sPendingQueries.size()));
 				ypos += y_inc;
 			}
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index eba768fef4..6261540765 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -372,10 +372,11 @@ void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scal
 //-------------------------------------------------------------------
 LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 {
+	mLODPeriod = 16;
 	mRegionp = regionp;
 	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
 	
-	new LLviewerOctreeGroup(mOctree);
+	new LLOcclusionCullingGroup(mOctree, this);
 }
 
 void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
@@ -400,11 +401,31 @@ public:
 		mLocalShift = shift;
 	}
 
+	virtual bool earlyFail(LLviewerOctreeGroup* base_group)
+	{
+		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
+		if(group->needsUpdate())
+		{
+			return false; //needs to issue new occlusion culling check.
+		}
+
+		group->checkOcclusion();
+
+		if (group->getOctreeNode()->getParent() &&	//never occlusion cull the root node
+		  	LLPipeline::sUseOcclusion &&			//ignore occlusion if disabled			
+			group->isOcclusionState(LLSpatialGroup::OCCLUDED))
+		{
+			return true;
+		}
+		
+		return false;
+	}
+
 	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
-		//S32 res = AABBInRegionFrustumGroupBounds(group);
+		S32 res = AABBInRegionFrustumGroupBounds(group);
 		
-		S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
+		//S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
 		if (res != 0)
 		{
 			res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift));
@@ -414,9 +435,9 @@ public:
 
 	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
-		//S32 res = AABBInRegionFrustumObjectBounds(group);
+		S32 res = AABBInRegionFrustumObjectBounds(group);
 
-		S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
+		//S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
 		if (res != 0)
 		{
 			res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift));
@@ -426,7 +447,15 @@ public:
 
 	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
-		mRegionp->addVisibleGroup(base_group);
+		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
+		if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1)
+		{
+			((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera);
+			group->setVisible();
+			return; //wait for occlusion culling results
+		}
+
+		mRegionp->addVisibleGroup(group);
 	}
 
 private:
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 12f268d324..d1c1602437 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4190,7 +4190,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 	
 	LLVOAvatar* pAvatarVO = NULL;
 
-	LLSpatialBridge* bridge = group->mSpatialPartition->asBridge();
+	LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge();
 	if (bridge)
 	{
 		if (bridge->mAvatar.isNull())
@@ -4227,10 +4227,10 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 	std::vector<LLFace*> simple_faces;
 
 	std::vector<LLFace*> alpha_faces;
-	U32 useage = group->mSpatialPartition->mBufferUsage;
+	U32 useage = group->getSpatialPartition()->mBufferUsage;
 
-	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcVertexSize(group->mSpatialPartition->mVertexDataMask);
-	U32 max_total = (gSavedSettings.getS32("RenderMaxNodeSize")*1024)/LLVertexBuffer::calcVertexSize(group->mSpatialPartition->mVertexDataMask);
+	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcVertexSize(group->getSpatialPartition()->mVertexDataMask);
+	U32 max_total = (gSavedSettings.getS32("RenderMaxNodeSize")*1024)/LLVertexBuffer::calcVertexSize(group->getSpatialPartition()->mVertexDataMask);
 	max_vertices = llmin(max_vertices, (U32) 65535);
 
 	U32 cur_total = 0;
@@ -4837,7 +4837,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 #endif
 	
 	//calculate maximum number of vertices to store in a single buffer
-	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcVertexSize(group->mSpatialPartition->mVertexDataMask);
+	U32 max_vertices = (gSavedSettings.getS32("RenderMaxVBOSize")*1024)/LLVertexBuffer::calcVertexSize(group->getSpatialPartition()->mVertexDataMask);
 	max_vertices = llmin(max_vertices, (U32) 65535);
 
 	{
@@ -5228,7 +5228,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32 &index_count)
 {	
 	//initialize to default usage for this partition
-	U32 usage = group->mSpatialPartition->mBufferUsage;
+	U32 usage = group->getSpatialPartition()->mBufferUsage;
 	
 	//clear off any old faces
 	mFaceList.clear();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1b5148e560..a8156b46ed 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -1663,7 +1663,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 	if (drawablep->getSpatialGroup())
 	{
 		LLFastTimer t(FTM_REMOVE_FROM_SPATIAL_PARTITION);
-		if (!drawablep->getSpatialGroup()->mSpatialPartition->remove(drawablep, drawablep->getSpatialGroup()))
+		if (!drawablep->getSpatialGroup()->getSpatialPartition()->remove(drawablep, drawablep->getSpatialGroup()))
 		{
 #ifdef LL_RELEASE_FOR_DOWNLOAD
 			llwarns << "Couldn't remove object from spatial group!" << llendl;
@@ -2480,7 +2480,7 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
 
 	assertInitialized();
 	
-	if (!group->mSpatialPartition->mRenderByGroup)
+	if (!group->getSpatialPartition()->mRenderByGroup)
 	{ //render by drawable
 		sCull->pushDrawableGroup(group);
 	}
@@ -2729,7 +2729,7 @@ void LLPipeline::rebuildGroups()
 		{
 			group->rebuildGeom();
 			
-			if (group->mSpatialPartition->mRenderByGroup)
+			if (group->getSpatialPartition()->mRenderByGroup)
 			{
 				count++;
 			}
@@ -3052,9 +3052,9 @@ void LLPipeline::markMeshDirty(LLSpatialGroup* group)
 
 void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority)
 {
-	if (group && !group->isDead() && group->mSpatialPartition)
+	if (group && !group->isDead() && group->getSpatialPartition())
 	{
-		if (group->mSpatialPartition->mPartitionType == LLViewerRegion::PARTITION_HUD)
+		if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_HUD)
 		{
 			priority = TRUE;
 		}
@@ -3631,7 +3631,7 @@ void LLPipeline::postSort(LLCamera& camera)
 			
 			if (alpha != group->mDrawMap.end())
 			{ //store alpha groups for sorting
-				LLSpatialBridge* bridge = group->mSpatialPartition->asBridge();
+				LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge();
 				if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
 				{
 					if (bridge)
@@ -5202,7 +5202,7 @@ void LLPipeline::renderDebug()
 				continue;
 			}
 
-			LLSpatialBridge* bridge = group->mSpatialPartition->asBridge();
+			LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge();
 
 			if (bridge && (!bridge->mDrawable || bridge->mDrawable->isDead()))
 			{
@@ -9990,7 +9990,7 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu
 		LLSpatialGroup* group = *i;
 		if (!group->isDead() &&
 			(!sUseOcclusion || !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) &&
-			gPipeline.hasRenderType(group->mSpatialPartition->mDrawableType) &&
+			gPipeline.hasRenderType(group->getSpatialPartition()->mDrawableType) &&
 			group->mDrawMap.find(type) != group->mDrawMap.end())
 		{
 			pass->renderGroup(group,type,mask,texture);
-- 
cgit v1.2.3


From b5f98560c796d62e45ebd0e410254b79958c7f47 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 23 May 2013 23:21:41 -0600
Subject: add a debug setting "UseObjectCacheOcclusion" to enable/disable
 object cache occlusion culling

---
 indra/newview/app_settings/settings.xml | 11 ++++++++
 indra/newview/llvocache.cpp             | 50 ++++++++++++++++++++-------------
 2 files changed, 41 insertions(+), 20 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 94f032be67..8efc4a80e6 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12405,6 +12405,17 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
+  <key>UseObjectCacheOcclusion</key>
+  <map>
+    <key>Comment</key>
+    <string>Enable object cache level object culling based on occlusion (coverage) by other objects</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+  </map>
   <key>RenderSynchronousOcclusion</key>
   <map>
     <key>Comment</key>
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 1a6ad90a78..fdb14aa8d2 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -397,28 +397,33 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
 class LLVOCacheOctreeCull : public LLViewerOctreeCull
 {
 public:
-	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift) : LLViewerOctreeCull(camera), mRegionp(regionp) 
+	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion) 
+		: LLViewerOctreeCull(camera), 
+		  mRegionp(regionp)
 	{
 		mLocalShift = shift;
+		mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion);
 	}
 
 	virtual bool earlyFail(LLviewerOctreeGroup* base_group)
 	{
-		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
-		if(group->needsUpdate())
+		if( mUseObjectCacheOcclusion &&
+			base_group->getOctreeNode()->getParent()) //never occlusion cull the root node
 		{
-			return false; //needs to issue new occlusion culling check.
-		}
+			LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
+			if(group->needsUpdate())
+			{
+				return false; //needs to issue new occlusion culling check.
+			}
 
-		group->checkOcclusion();
+			group->checkOcclusion();
 
-		if (group->getOctreeNode()->getParent() &&	//never occlusion cull the root node
-		  	LLPipeline::sUseOcclusion &&			//ignore occlusion if disabled			
-			group->isOcclusionState(LLSpatialGroup::OCCLUDED))
-		{
-			return true;
+			if (group->isOcclusionState(LLSpatialGroup::OCCLUDED))
+			{
+				return true;
+			}
 		}
-		
+
 		return false;
 	}
 
@@ -448,24 +453,29 @@ public:
 
 	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
-		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
-		if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1)
+		if(mUseObjectCacheOcclusion && base_group->getOctreeNode()->getParent())
 		{
-			((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera);
-			group->setVisible();
-			return; //wait for occlusion culling results
+			LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
+			if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1)
+			{
+				((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera);
+				group->setVisible();
+				return; //wait for occlusion culling results
+			}
 		}
-
-		mRegionp->addVisibleGroup(group);
+		mRegionp->addVisibleGroup(base_group);
 	}
 
 private:
 	LLViewerRegion* mRegionp;
 	LLVector3       mLocalShift; //shift vector from agent space to local region space.
+	bool            mUseObjectCacheOcclusion;
 };
 
 S32 LLVOCachePartition::cull(LLCamera &camera)
 {
+	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
+
 	if(!LLViewerRegion::sVOCacheCullingEnabled)
 	{
 		return 0;
@@ -477,7 +487,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	camera.calcRegionFrustumPlanes(region_agent);
 
-	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent);
+	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion);
 	culler.traverse(mOctree);
 
 	return 0;
-- 
cgit v1.2.3


From 6827febd3027decb1bd8da013b6af413114239a9 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 28 May 2013 14:55:37 -0600
Subject: change the way to handle creating/destroying a same object repeatedly

---
 indra/newview/lldrawable.cpp     |  2 +-
 indra/newview/lldrawable.h       |  2 +-
 indra/newview/llvieweroctree.cpp |  2 +-
 indra/newview/llvieweroctree.h   |  2 +-
 indra/newview/llvocache.cpp      | 30 +++++++++---------------------
 indra/newview/llvocache.h        |  7 +++----
 6 files changed, 16 insertions(+), 29 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 92b3ee4a26..0b935ced31 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1101,7 +1101,7 @@ LLSpatialPartition* LLDrawable::getSpatialPartition()
 }
 
 //virtual
-S32 LLDrawable::getMinVisFrameRange() const
+S32 LLDrawable::getMinFrameRange() const
 {
 const S32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one.
 
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index e400a8b5f2..4d31356ede 100644
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -193,7 +193,7 @@ public:
 
 	LLSpatialPartition* getSpatialPartition();
 	
-	virtual S32 getMinVisFrameRange()const;
+	virtual S32 getMinFrameRange()const;
 	void removeFromOctree();
 
 	void setSpatialBridge(LLSpatialBridge* bridge) { mSpatialBridge = (LLDrawable*) bridge; }
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index d9e1774c6d..d631985e82 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -409,7 +409,7 @@ bool LLViewerOctreeEntryData::isRecentlyVisible() const
 		return true;
 	}
 
-	return (sCurVisible - mEntry->mVisible < getMinVisFrameRange());
+	return (sCurVisible - mEntry->mVisible < getMinFrameRange());
 }
 
 void LLViewerOctreeEntryData::setVisible() const
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 1d3533e95c..0a96676be1 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -149,7 +149,7 @@ public:
 	
 	virtual void setOctreeEntry(LLViewerOctreeEntry* entry);
 
-	virtual S32  getMinVisFrameRange()const = 0;
+	virtual S32  getMinFrameRange()const = 0;
 
 	F32                  getBinRadius() const   {return mEntry->getBinRadius();}
 	const LLVector4a*    getSpatialExtents() const;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index fdb14aa8d2..bcd9dda652 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -60,8 +60,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mDupeCount(0),
 	mCRCChangeCount(0),
 	mState(INACTIVE),
-	mRepeatedVisCounter(0),
-	mVisFrameRange(64),
+	mMinFrameRange(64),
 	mSceneContrib(0.f),
 	mTouched(TRUE),
 	mParentID(0)
@@ -81,8 +80,7 @@ LLVOCacheEntry::LLVOCacheEntry()
 	mCRCChangeCount(0),
 	mBuffer(NULL),
 	mState(INACTIVE),
-	mRepeatedVisCounter(0),
-	mVisFrameRange(64),
+	mMinFrameRange(64),
 	mSceneContrib(0.f),
 	mTouched(TRUE),
 	mParentID(0)
@@ -95,8 +93,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	mBuffer(NULL),
 	mUpdateFlags(-1),
 	mState(INACTIVE),
-	mRepeatedVisCounter(0),
-	mVisFrameRange(64),
+	mMinFrameRange(64),
 	mSceneContrib(0.f),
 	mTouched(FALSE),
 	mParentID(0)
@@ -215,35 +212,26 @@ void LLVOCacheEntry::setState(U32 state)
 
 	if(getState() == ACTIVE)
 	{
-		const S32 MIN_REAVTIVE_INTERVAL = 20;
+		const S32 MIN_REAVTIVE_INTERVAL = 32;
 		U32 last_visible = getVisible();
 		
 		setVisible();
 
-		if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mVisFrameRange)
+		if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mMinFrameRange)
 		{
-			mRepeatedVisCounter++;
+			mMinFrameRange = llmin(mMinFrameRange * 2, 2048);
 		}
 		else
 		{
-			mRepeatedVisCounter = 0;
-			mVisFrameRange = 64;
-		}
-
-		if(mRepeatedVisCounter > 2) 
-		{
-			//if repeatedly becomes visible immediately after invisible, enlarge the visible frame range
-
-			mRepeatedVisCounter = 0;
-			mVisFrameRange *= 2;
+			mMinFrameRange = 64; //reset
 		}
 	}
 }
 
 //virtual 
-S32  LLVOCacheEntry::getMinVisFrameRange()const
+S32  LLVOCacheEntry::getMinFrameRange()const
 {
-	return mVisFrameRange;
+	return mMinFrameRange;
 }
 
 void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 7409b94d60..8a4975c786 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -87,7 +87,7 @@ public:
 	U32 getCRC() const				{ return mCRC; }
 	S32 getHitCount() const			{ return mHitCount; }
 	S32 getCRCChangeCount() const	{ return mCRCChangeCount; }
-	S32 getMinVisFrameRange()const;	
+	S32 getMinFrameRange()const;	
 
 	void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update);
 	void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;}
@@ -116,7 +116,7 @@ public:
 	
 	void setTouched(BOOL touched = TRUE) {mTouched = touched;}
 	BOOL isTouched() const {return mTouched;}
-	
+
 	void setUpdateFlags(U32 flags) {mUpdateFlags = flags;}
 	U32  getUpdateFlags() const    {return mUpdateFlags;}
 
@@ -137,8 +137,7 @@ protected:
 	U8							*mBuffer;
 
 	F32                         mSceneContrib; //projected scene contributuion of this object.
-	S32                         mVisFrameRange;
-	S32                         mRepeatedVisCounter; //number of repeatedly visible within a short time.
+	S32                         mMinFrameRange;
 	U32                         mState; //high 16 bits reserved for special use.
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 
-- 
cgit v1.2.3


From e4e01ea7cce42ca5eac28ceff2b111e52dfd939b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 28 May 2013 17:44:50 -0600
Subject: fix for SH-4214: Crash on Linux readFromCache: ASSERT (mInitialized)

---
 indra/newview/llappviewer.cpp | 1 +
 indra/newview/llworld.cpp     | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index cd881208ab..d36c33cdd7 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4974,6 +4974,7 @@ void LLAppViewer::disconnectViewer()
 	{
 		LLWorld::getInstance()->destroyClass();
 	}
+	LLVOCache::deleteSingleton();
 
 	// call all self-registered classes
 	LLDestroyClassList::instance().fireCallbacks();
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 9603849b10..367abcb40e 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -123,7 +123,7 @@ void LLWorld::destroyClass()
 		LLViewerRegion* region_to_delete = *region_it++;
 		removeRegion(region_to_delete->getHost());
 	}
-	LLVOCache::deleteSingleton();
+	
 	LLViewerPartSim::getInstance()->destroyClass();
 
 	mDefaultWaterTexturep = NULL ;
-- 
cgit v1.2.3


From 52e8b2a1a279e13a39a95b32a301780998b8d8c4 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 28 May 2013 18:25:12 -0600
Subject: for SH-4004: interesting: need debug option to clear viewer cache
 while still logged in

---
 indra/newview/llappviewer.cpp    | 2 +-
 indra/newview/lltexturecache.cpp | 4 ++--
 indra/newview/lltexturecache.h   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index d36c33cdd7..a602f0d78e 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4031,7 +4031,7 @@ void LLAppViewer::purgeCache()
 void LLAppViewer::purgeCacheImmediate()
 {
 	LL_INFOS("AppCache") << "Purging Object Cache and Texture Cache immediately..." << LL_ENDL;
-	LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE);
+	LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE, false);
 	LLVOCache::getInstance()->removeCache(LL_PATH_CACHE, true);
 }
 
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index 305f6fca0f..f03cc22949 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -919,7 +919,7 @@ void LLTextureCache::setDirNames(ELLPath location)
 	mFastCacheFileName =  gDirUtilp->getExpandedFilename(location, textures_dirname, fast_cache_filename);
 }
 
-void LLTextureCache::purgeCache(ELLPath location)
+void LLTextureCache::purgeCache(ELLPath location, bool remove_dir)
 {
 	LLMutexLock lock(&mHeaderMutex);
 
@@ -945,7 +945,7 @@ void LLTextureCache::purgeCache(ELLPath location)
 	}
 
 	//remove the current texture cache.
-	purgeAllTextures(true);
+	purgeAllTextures(remove_dir);
 }
 
 //is called in the main thread before initCache(...) is called.
diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h
index e3fc957fd2..5a68c31a6d 100644
--- a/indra/newview/lltexturecache.h
+++ b/indra/newview/lltexturecache.h
@@ -104,7 +104,7 @@ public:
 
 	/*virtual*/ S32 update(F32 max_time_ms);	
 	
-	void purgeCache(ELLPath location);
+	void purgeCache(ELLPath location, bool remove_dir = true);
 	void setReadOnly(BOOL read_only) ;
 	S64 initCache(ELLPath location, S64 maxsize, BOOL texture_cache_mismatch);
 
-- 
cgit v1.2.3


From 9ae76d12157641033431381959ef4f798a119b8d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 29 May 2013 17:00:50 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 fixed copy construction behavior of Recordings to not zero out data split
 measurement into event and sample, with sample representing a continuous
 function

---
 indra/newview/llappviewer.cpp          |   2 +-
 indra/newview/llfloaterjoystick.cpp    |  14 ++--
 indra/newview/llscenemonitor.cpp       |  57 +++++++++++++--
 indra/newview/llstartup.cpp            |   2 +-
 indra/newview/llstatusbar.cpp          |   2 +-
 indra/newview/lltexturefetch.cpp       |  10 +--
 indra/newview/lltexturefetch.h         |   4 +-
 indra/newview/llviewerassetstats.cpp   |   9 ++-
 indra/newview/llviewerassetstats.h     |   2 +-
 indra/newview/llviewerassetstorage.cpp |   2 +-
 indra/newview/llviewerobject.cpp       |   2 +-
 indra/newview/llviewerobjectlist.cpp   |   2 +-
 indra/newview/llviewerobjectlist.h     |   2 +-
 indra/newview/llviewerstats.cpp        | 125 +++++++++++++++++----------------
 indra/newview/llviewerstats.h          | 103 ++++++++++++++-------------
 indra/newview/llviewerwindow.cpp       |  19 +++--
 indra/newview/llviewerwindow.h         |   4 +-
 indra/newview/llvoavatarself.cpp       |   2 +-
 indra/newview/pipeline.cpp             |  28 +-------
 indra/newview/pipeline.h               |  11 +--
 20 files changed, 211 insertions(+), 191 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 3a3fe2b656..edf874d744 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1244,7 +1244,7 @@ bool LLAppViewer::mainLoop()
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
 
-		LLTrace::getMasterThreadRecorder().pullFromSlaveThreads();
+		LLTrace::getUIThreadRecorder().pullFromSlaveThreads();
 
 		//clear call stack records
 		llclearcallstacks;
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index dbdf3e5e9f..b71ab4c53b 100644
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -42,13 +42,13 @@
 #include "llviewerjoystick.h"
 #include "llcheckboxctrl.h"
 
-static LLTrace::MeasurementStatHandle<> sJoystickAxis1("Joystick axis 1"),
-										sJoystickAxis2("Joystick axis 2"),
-										sJoystickAxis3("Joystick axis 3"),
-										sJoystickAxis4("Joystick axis 4"),
-										sJoystickAxis5("Joystick axis 5"),
-										sJoystickAxis6("Joystick axis 6");
-static LLTrace::MeasurementStatHandle<>* sJoystickAxes[6] = 
+static LLTrace::SampleStatHandle<>	sJoystickAxis1("Joystick axis 1"),
+									sJoystickAxis2("Joystick axis 2"),
+									sJoystickAxis3("Joystick axis 3"),
+									sJoystickAxis4("Joystick axis 4"),
+									sJoystickAxis5("Joystick axis 5"),
+									sJoystickAxis6("Joystick axis 6");
+static LLTrace::SampleStatHandle<>* sJoystickAxes[6] = 
 {
 	&sJoystickAxis1,
 	&sJoystickAxis2,
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 94c2e40bb1..15f2f6d762 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -462,7 +462,7 @@ void LLSceneMonitor::calcDiffAggregate()
 	}	
 }
 
-static LLTrace::MeasurementStatHandle<> sFramePixelDiff("FramePixelDifference");
+static LLTrace::EventStatHandle<> sFramePixelDiff("FramePixelDifference");
 void LLSceneMonitor::fetchQueryResult()
 {
 	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
@@ -481,16 +481,18 @@ void LLSceneMonitor::fetchQueryResult()
 			mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
 			LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
-			sample(sFramePixelDiff, mDiffResult);
+			record(sFramePixelDiff, mDiffResult);
 
 			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
 			if(mDiffResult > diff_threshold())
 			{
 				mRecording->extend();
+				llassert(mRecording->getAcceptedRecording().getLastRecording().getSum(LLStatViewer::FPS));
 			}
 			else
 			{
 				mRecording->getPotentialRecording().nextPeriod();
+				llassert(mRecording->getPotentialRecording().getLastRecording().getSum(LLStatViewer::FPS));
 			}
 		}
 	}
@@ -503,7 +505,6 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 	std::ofstream os(file_name.c_str());
 
-	//total scene loading time
 	os << std::setprecision(4);
 
 	LLTrace::PeriodicRecording& scene_load_recording = mRecording->getAcceptedRecording();
@@ -565,7 +566,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (LLTrace::MeasurementStatHandle<F64>::instance_iter it = LLTrace::MeasurementStatHandle<F64>::beginInstances(), end_it = LLTrace::MeasurementStatHandle<F64>::endInstances();
+	for (LLTrace::EventStatHandle<F64>::instance_iter it = LLTrace::EventStatHandle<F64>::beginInstances(), end_it = LLTrace::EventStatHandle<F64>::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -588,7 +589,53 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (LLTrace::MeasurementStatHandle<S64>::instance_iter it = LLTrace::MeasurementStatHandle<S64>::beginInstances(), end_it = LLTrace::MeasurementStatHandle<S64>::endInstances();
+	for (LLTrace::EventStatHandle<S64>::instance_iter it = LLTrace::EventStatHandle<S64>::beginInstances(), end_it = LLTrace::EventStatHandle<S64>::endInstances();
+		it != end_it;
+		++it)
+	{
+		std::ostringstream row;
+		row << it->getName();
+
+		S32 samples = 0;
+
+		for (S32 i = frame_count - 1; i >= 0; --i)
+		{
+			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
+		}
+
+		row << std::endl;
+
+		if (samples > 0)
+		{
+			os << row.str();
+		}
+	}
+
+	for (LLTrace::SampleStatHandle<F64>::instance_iter it = LLTrace::SampleStatHandle<F64>::beginInstances(), end_it = LLTrace::SampleStatHandle<F64>::endInstances();
+		it != end_it;
+		++it)
+	{
+		std::ostringstream row;
+		row << it->getName();
+
+		S32 samples = 0;
+
+		for (S32 i = frame_count - 1; i >= 0; --i)
+		{
+			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
+		}
+
+		row << std::endl;
+
+		if (samples > 0)
+		{
+			os << row.str();
+		}
+	}
+
+	for (LLTrace::SampleStatHandle<S64>::instance_iter it = LLTrace::SampleStatHandle<S64>::beginInstances(), end_it = LLTrace::SampleStatHandle<S64>::endInstances();
 		it != end_it;
 		++it)
 	{
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index f748344cc8..f060e8933b 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2071,7 +2071,7 @@ bool idle_startup()
 		if (wearables_time > max_wearables_time())
 		{
 			LLNotificationsUtil::add("ClothingLoading");
-			add(LLStatViewer::LOADING_WEARABLES_LONG_DELAY, 1);
+			record(LLStatViewer::LOADING_WEARABLES_LONG_DELAY, wearables_time);
 			LLStartUp::setStartupState( STATE_CLEANUP );
 			return TRUE;
 		}
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index b945ec2318..f3406d9f8d 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -212,7 +212,7 @@ BOOL LLStatusBar::postBuild()
 	pgp.rect(r);
 	pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	pgp.mouse_opaque(false);
-	pgp.stat.measurement_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT);
+	pgp.stat.sample_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT);
 	pgp.units("%");
 	pgp.min(0.f);
 	pgp.max(5.f);
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 8bf7bcc398..910cb24bb2 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -65,8 +65,8 @@
 #include "bufferstream.h"
 
 bool LLTextureFetchDebugger::sDebuggerEnabled = false ;
-LLTrace::MeasurementStatHandle<> LLTextureFetch::sCacheHitRate("texture_cache_hits");
-LLTrace::MeasurementStatHandle<> LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
+LLTrace::SampleStatHandle<> LLTextureFetch::sCacheHitRate("texture_cache_hits");
+LLTrace::SampleStatHandle<> LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
 
 
 //////////////////////////////////////////////////////////////////////////////
@@ -1833,7 +1833,7 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe
 	if (log_to_viewer_log || log_to_sim)
 	{
 		U64 timeNow = LLTimer::getTotalTime();
-		mFetcher->mTextureInfo.setRequestStartTime(mID, mMetricsStartTime);
+		mFetcher->mTextureInfo.setRequestStartTime(mID, mMetricsStartTime.value());
 		mFetcher->mTextureInfo.setRequestType(mID, LLTextureInfoDetails::REQUEST_TYPE_HTTP);
 		mFetcher->mTextureInfo.setRequestSize(mID, mRequestedSize);
 		mFetcher->mTextureInfo.setRequestOffset(mID, mRequestedOffset);
@@ -2278,7 +2278,7 @@ bool LLTextureFetchWorker::writeToCacheComplete()
 // Threads:  Ttf
 void LLTextureFetchWorker::recordTextureStart(bool is_http)
 {
-	if (! mMetricsStartTime)
+	if (! mMetricsStartTime.value())
 	{
 		mMetricsStartTime = LLViewerAssetStatsFF::get_timestamp();
 	}
@@ -2291,7 +2291,7 @@ void LLTextureFetchWorker::recordTextureStart(bool is_http)
 // Threads:  Ttf
 void LLTextureFetchWorker::recordTextureDone(bool is_http)
 {
-	if (mMetricsStartTime)
+	if (mMetricsStartTime.value())
 	{
 		LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_TEXTURE,
 													  is_http,
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 4dcb9dd4b8..573b32c4bd 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -308,8 +308,8 @@ private:
 	LLMutex mQueueMutex;        //to protect mRequestMap and mCommands only
 	LLMutex mNetworkQueueMutex; //to protect mNetworkQueue, mHTTPTextureQueue and mCancelQueue.
 
-	static LLTrace::MeasurementStatHandle<> sCacheHitRate;
-	static LLTrace::MeasurementStatHandle<> sCacheReadLatency;
+	static LLTrace::SampleStatHandle<> sCacheHitRate;
+	static LLTrace::SampleStatHandle<> sCacheReadLatency;
 
 	LLTextureCache* mTextureCache;
 	LLImageDecodeThread* mImageDecodeThread;
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 8623af52ff..0bbf2cbbea 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -233,7 +233,7 @@ namespace LLViewerAssetStatsFF
 		&sDequeuedAssetRequestsOther            
 	};
 
-	static LLTrace::MeasurementStatHandle<LLTrace::Seconds>	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp", 
+	static LLTrace::EventStatHandle<LLTrace::Seconds>	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp",
 																							"Time spent responding to temporary texture asset http requests"),
 													sResponseAssetRequestsTempTextureUDP    ("assetresponsetimestemptextureudp", 
 																							"Time spent responding to temporary texture asset udp requests"),
@@ -250,7 +250,7 @@ namespace LLViewerAssetStatsFF
 													sResponsedAssetRequestsOther            ("assetresponsetimesother", 
 																							"Time spent responding to other asset requests");
 
-	static LLTrace::MeasurementStatHandle<LLTrace::Seconds>* sResponse[EVACCount] = {
+	static LLTrace::EventStatHandle<LLTrace::Seconds>* sResponse[EVACCount] = {
 		&sResponseAssetRequestsTempTextureHTTP,   
 		&sResponseAssetRequestsTempTextureUDP,  
 		&sResponseAssetRequestsNonTempTextureHTTP,
@@ -283,7 +283,6 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 	mPhaseStats(src.mPhaseStats),
 	mAvatarRezStates(src.mAvatarRezStates)
 {
-	src.mCurRecording->update();
 	mRegionRecordings = src.mRegionRecordings;
 
 	mCurRecording = &mRegionRecordings[mRegionHandle];
@@ -485,7 +484,7 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 						.resp_mean(rec.getMean(*sResponse[EVACOtherGet]).value());
 		}
 
-		S32 fps = (S32)rec.getSum(LLStatViewer::FPS_SAMPLE);
+		S32 fps = (S32)rec.getLastValue(LLStatViewer::FPS_SAMPLE);
 		if (!compact_output || fps != 0)
 		{
 			r.fps.count(fps);
@@ -561,7 +560,7 @@ void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp,
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	sample(*sResponse[int(eac)], LLTrace::Microseconds(duration));
+	record(*sResponse[int(eac)], LLTrace::Microseconds(duration));
 }
 
 void record_avatar_stats()
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 56eaa13df9..af99710aca 100644
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -83,7 +83,7 @@ public:
 	 * for compatibility with the pre-existing timestamp on the texture
 	 * fetcher class, LLTextureFetch.
 	 */
-	typedef U64 duration_t;
+	typedef LLUnit<LLUnits::Microseconds, U64> duration_t;
 
 	/**
 	 * Type for the region identifier used in stats.  Currently uses
diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp
index 6f41abbd8a..5c2dd20ec3 100644
--- a/indra/newview/llviewerassetstorage.cpp
+++ b/indra/newview/llviewerassetstorage.cpp
@@ -69,7 +69,7 @@ public:
 protected:
 	void recordMetrics()
 		{
-			if (mMetricsStartTime)
+			if (mMetricsStartTime.value())
 			{
 				// Okay, it appears this request was used for useful things.  Record
 				// the expected dequeue and duration of request processing.
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 50b14183c7..d912918129 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2222,7 +2222,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		// If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps
 		if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
 		{
-			sample(LLStatViewer::AGENT_POSITION_SNAP, LLTrace::Meters(diff.length()));
+			record(LLStatViewer::AGENT_POSITION_SNAP, LLTrace::Meters(diff.length()));
 		}
 	}
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 6ffd3d8fa4..c6ac7af93c 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -95,7 +95,7 @@ extern LLPipeline	gPipeline;
 U32						LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check.
 std::map<U64, U32>		LLViewerObjectList::sIPAndPortToIndex;
 std::map<U64, LLUUID>	LLViewerObjectList::sIndexAndLocalIDToUUID;
-LLTrace::MeasurementStatHandle<>	LLViewerObjectList::sCacheHitRate("object_cache_hits");
+LLTrace::SampleStatHandle<>	LLViewerObjectList::sCacheHitRate("object_cache_hits");
 
 LLViewerObjectList::LLViewerObjectList()
 {
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 65447156e7..464554245e 100644
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -198,7 +198,7 @@ protected:
 	std::vector<OrphanInfo> mOrphanChildren;	// UUID's of orphaned objects
 	S32 mNumOrphans;
 
-	static LLTrace::MeasurementStatHandle<> sCacheHitRate;
+	static LLTrace::SampleStatHandle<> sCacheHitRate;
 
 	typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index e8196e9655..635611c02e 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -74,7 +74,6 @@ LLTrace::CountStatHandle<>	FPS("framesrendered"),
 							IM_COUNT("imcount", "IMs sent"),
 							OBJECT_CREATE("objectcreate"),
 							OBJECT_REZ("objectrez", "Object rez count"),
-							LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load"),
 							LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"),
 							LSL_SAVES("lslsaves", "Number of times user has saved a script"),
 							ANIMATION_UPLOADS("animationuploads", "Animations uploaded"),
@@ -98,13 +97,7 @@ LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT("kbitstat"),
 											ACTUAL_IN_KBIT("actualinkbitstat"),
 											ACTUAL_OUT_KBIT("actualoutkbitstat");
 
-LLTrace::CountStatHandle<LLTrace::Seconds> AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearence"),
-											TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
-											MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
-											FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
-											FPS_8_TIME("fps8time", "Seconds below 8 FPS"),
-											FPS_2_TIME("fps2time", "Seconds below 2 FPS"),
-											SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
+LLTrace::CountStatHandle<LLTrace::Seconds>	SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
 											SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
 											LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
 
@@ -129,36 +122,34 @@ SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DIL
 							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS),
 							SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS);
 
-LLTrace::MeasurementStatHandle<>	FPS_SAMPLE("fpssample"),
-									NUM_IMAGES("numimagesstat"),
-									NUM_RAW_IMAGES("numrawimagesstat"),
-									NUM_OBJECTS("numobjectsstat"),
-									NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
-									NUM_SIZE_CULLED("numsizeculledstat"),
-									NUM_VIS_CULLED("numvisculledstat"),
-									ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
-									LIGHTING_DETAIL("lightingdetail", "Lighting Detail"),
-									VISIBLE_AVATARS("visibleavatars", "Visible Avatars"),
-									SHADER_OBJECTS("shaderobjects", "Object Shaders"),
-									DRAW_DISTANCE("drawdistance", "Draw Distance"),
-									CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled"),
-									PENDING_VFS_OPERATIONS("vfspendingoperations"), 
-									PACKETS_LOST_PERCENT("packetslostpercentstat"),
-									WINDOW_WIDTH("windowwidth", "Window width"),
-									WINDOW_HEIGHT("windowheight", "Window height");
+LLTrace::SampleStatHandle<>	FPS_SAMPLE("fpssample"),
+							NUM_IMAGES("numimagesstat"),
+							NUM_RAW_IMAGES("numrawimagesstat"),
+							NUM_OBJECTS("numobjectsstat"),
+							NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
+							NUM_SIZE_CULLED("numsizeculledstat"),
+							NUM_VIS_CULLED("numvisculledstat"),
+							ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
+							LIGHTING_DETAIL("lightingdetail", "Lighting Detail"),
+							VISIBLE_AVATARS("visibleavatars", "Visible Avatars"),
+							SHADER_OBJECTS("shaderobjects", "Object Shaders"),
+							DRAW_DISTANCE("drawdistance", "Draw Distance"),
+							PENDING_VFS_OPERATIONS("vfspendingoperations"),
+							PACKETS_LOST_PERCENT("packetslostpercentstat"),
+							WINDOW_WIDTH("windowwidth", "Window width"),
+							WINDOW_HEIGHT("windowheight", "Window height");
 	
-LLTrace::MeasurementStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
+static LLTrace::SampleStatHandle<S64> CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled");
 
-
-LLTrace::MeasurementStatHandle<LLTrace::Bytes>	GL_TEX_MEM("gltexmemstat"),
-												GL_BOUND_MEM("glboundmemstat"),
-												RAW_MEM("rawmemstat"),
-												FORMATTED_MEM("formattedmemstat"),
-												DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
-												MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
+LLTrace::SampleStatHandle<LLTrace::Bytes>	GL_TEX_MEM("gltexmemstat"),
+											GL_BOUND_MEM("glboundmemstat"),
+											RAW_MEM("rawmemstat"),
+											FORMATTED_MEM("formattedmemstat"),
+											DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
+											MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
 
 	
-SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
+SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
 										SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS),
 										SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS),
 										SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS),
@@ -173,21 +164,32 @@ SimMeasurement<LLTrace::Milliseconds> SIM_FRAME_TIME("simframemsec", "", LL_SIM_
 										SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
 										SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
 	
-SimMeasurement<LLTrace::Bytes> SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES),
+SimMeasurement<LLTrace::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES),
 								SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
 
+LLTrace::SampleStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+													FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
+													SIM_PING("simpingstat");
+
+LLTrace::EventStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
+
+LLTrace::EventStatHandle<>	LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load");
+
+LLTrace::EventStatHandle<LLTrace::Milliseconds>	REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
+												FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
+												UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
+												NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
+												IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
+												REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
+												RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
+
+LLTrace::EventStatHandle<LLTrace::Seconds>	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
+											TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
+											MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
+											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::MeasurementStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
-														FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
-														LOGIN_SECONDS("loginseconds", "Time between LoginRequest and LoginReply"),
-														REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
-														FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
-														UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
-														NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
-														IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
-														REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
-														RENDER_STACKTIME("renderstacktime", "RENDER_SECS"),
-														SIM_PING("simpingstat");
 	
 }
 
@@ -230,15 +232,15 @@ void LLViewerStats::updateFrameStats(const F64 time_diff)
 		
 	if (time_diff >= 0.5)
 	{
-		add(LLStatViewer::FPS_2_TIME, time_diff_seconds);
+		record(LLStatViewer::FPS_2_TIME, time_diff_seconds);
 	}
 	if (time_diff >= 0.125)
 	{
-		add(LLStatViewer::FPS_8_TIME, time_diff_seconds);
+		record(LLStatViewer::FPS_8_TIME, time_diff_seconds);
 	}
 	if (time_diff >= 0.1)
 	{
-		add(LLStatViewer::FPS_10_TIME, time_diff_seconds);
+		record(LLStatViewer::FPS_10_TIME, time_diff_seconds);
 	}
 
 	if (gFrameCount && mLastTimeDiff > 0.0)
@@ -311,35 +313,36 @@ void update_statistics()
 	{
 		if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
 		{
-			add(LLStatViewer::MOUSELOOK_TIME, gFrameIntervalSeconds);
+			record(LLStatViewer::MOUSELOOK_TIME, gFrameIntervalSeconds);
 		}
 		else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
 		{
-			add(LLStatViewer::AVATAR_EDIT_TIME, gFrameIntervalSeconds);
+			record(LLStatViewer::AVATAR_EDIT_TIME, gFrameIntervalSeconds);
 		}
 		else if (LLFloaterReg::instanceVisible("build"))
 		{
-			add(LLStatViewer::TOOLBOX_TIME, gFrameIntervalSeconds);
+			record(LLStatViewer::TOOLBOX_TIME, gFrameIntervalSeconds);
 		}
 	}
 
 	LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording();
 
-	sample(LLStatViewer::ENABLE_VBO, (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
+	sample(LLStatViewer::ENABLE_VBO,      (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
 	sample(LLStatViewer::LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
-	sample(LLStatViewer::DRAW_DISTANCE, (F64)gSavedSettings.getF32("RenderFarClip"));
-	sample(LLStatViewer::CHAT_BUBBLES, (F64)gSavedSettings.getBOOL("UseChatBubbles"));
+	sample(LLStatViewer::DRAW_DISTANCE,   (F64)gSavedSettings.getF32("RenderFarClip"));
+	sample(LLStatViewer::CHAT_BUBBLES,    gSavedSettings.getBOOL("UseChatBubbles"));
 
 	typedef LLInstanceTracker<LLTrace::TraceType<LLTrace::TimeBlockAccumulator>, std::string> trace_type_t;
 
-	sample(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Frame")).as<LLUnits::Seconds>());
 	LLUnit<LLUnits::Seconds, F64> idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
 	LLUnit<LLUnits::Seconds, F64> network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
-	sample(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs);
-	sample(LLStatViewer::NETWORK_STACKTIME, network_secs);
-	sample(LLStatViewer::IMAGE_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Update Images")).as<LLUnits::Seconds>());
-	sample(LLStatViewer::REBUILD_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Sort Draw State")).as<LLUnits::Seconds>());
-	sample(LLStatViewer::RENDER_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Render Geometry")).as<LLUnits::Seconds>());
+
+	record(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_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")));
 		
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index e94ba23163..c0ac6d220f 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -46,10 +46,10 @@ struct SimMeasurementSampler : public LLInstanceTracker<SimMeasurementSampler, E
 };
 
 template<typename T = F64>
-struct SimMeasurement : public LLTrace::MeasurementStatHandle<T>, public SimMeasurementSampler
+struct SimMeasurement : public LLTrace::SampleStatHandle<T>, public SimMeasurementSampler
 {
 	SimMeasurement(const char* name, const char* description, ESimStatID stat_id)
-	:	LLTrace::MeasurementStatHandle<T>(name, description),
+	:	LLTrace::SampleStatHandle<T>(name, description),
 		SimMeasurementSampler(stat_id)	
 	{}
 
@@ -66,7 +66,8 @@ void sample(SimMeasurement<T>& measurement, VALUE_T value)
 {
 	LLTrace::sample(measurement, value);
 }
-extern LLTrace::CountStatHandle<>						FPS,
+
+extern LLTrace::CountStatHandle<>			FPS,
 											PACKETS_IN,
 											PACKETS_LOST,
 											PACKETS_OUT,
@@ -76,7 +77,6 @@ extern LLTrace::CountStatHandle<>						FPS,
 											IM_COUNT,
 											OBJECT_CREATE,
 											OBJECT_REZ,
-											LOADING_WEARABLES_LONG_DELAY,
 											LOGIN_TIMEOUTS,
 											LSL_SAVES,
 											ANIMATION_UPLOADS,
@@ -102,15 +102,9 @@ extern LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT,
 											ACTUAL_IN_KBIT,
 											ACTUAL_OUT_KBIT;
 
-extern LLTrace::CountStatHandle<LLTrace::Seconds>		AVATAR_EDIT_TIME,
-											TOOLBOX_TIME,
-											MOUSELOOK_TIME,
-											FPS_10_TIME,
-											FPS_8_TIME,
-											FPS_2_TIME,
-											SIM_20_FPS_TIME,
-											SIM_PHYSICS_20_FPS_TIME,
-											LOSS_5_PERCENT_TIME;
+extern LLTrace::CountStatHandle<LLTrace::Seconds>		SIM_20_FPS_TIME,
+														SIM_PHYSICS_20_FPS_TIME,
+														LOSS_5_PERCENT_TIME;
 
 extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_FPS,
@@ -133,32 +127,29 @@ extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_PHYSICS_PINNED_TASKS,
 											SIM_PHYSICS_LOD_TASKS;
 
-extern LLTrace::MeasurementStatHandle<>		FPS_SAMPLE,
-											NUM_IMAGES,
-											NUM_RAW_IMAGES,
-											NUM_OBJECTS,
-											NUM_ACTIVE_OBJECTS,
-											NUM_SIZE_CULLED,
-											NUM_VIS_CULLED,
-											ENABLE_VBO,
-											LIGHTING_DETAIL,
-											VISIBLE_AVATARS,
-											SHADER_OBJECTS,
-											DRAW_DISTANCE,
-											CHAT_BUBBLES,
-											PENDING_VFS_OPERATIONS,
-											PACKETS_LOST_PERCENT,
-											WINDOW_WIDTH,
-											WINDOW_HEIGHT;
-
-extern LLTrace::MeasurementStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP;
-
-extern LLTrace::MeasurementStatHandle<LLTrace::Bytes>	DELTA_BANDWIDTH,
-														MAX_BANDWIDTH,
-														GL_TEX_MEM,
-														GL_BOUND_MEM,
-														RAW_MEM,
-														FORMATTED_MEM;
+extern LLTrace::SampleStatHandle<>		FPS_SAMPLE,
+										NUM_IMAGES,
+										NUM_RAW_IMAGES,
+										NUM_OBJECTS,
+										NUM_ACTIVE_OBJECTS,
+										NUM_SIZE_CULLED,
+										NUM_VIS_CULLED,
+										ENABLE_VBO,
+										LIGHTING_DETAIL,
+										VISIBLE_AVATARS,
+										SHADER_OBJECTS,
+										DRAW_DISTANCE,
+										PENDING_VFS_OPERATIONS,
+										PACKETS_LOST_PERCENT,
+										WINDOW_WIDTH,
+										WINDOW_HEIGHT;
+
+extern LLTrace::SampleStatHandle<LLTrace::Bytes>	DELTA_BANDWIDTH,
+													MAX_BANDWIDTH,
+													GL_TEX_MEM,
+													GL_BOUND_MEM,
+													RAW_MEM,
+													FORMATTED_MEM;
 
 extern SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME,
 												SIM_NET_TIME,
@@ -179,17 +170,29 @@ extern SimMeasurement<LLTrace::Bytes>			SIM_UNACKED_BYTES,
 												SIM_PHYSICS_MEM;
 
 
-extern LLTrace::MeasurementStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER,
-													FRAMETIME_SLEW,
-													LOGIN_SECONDS,
-													REGION_CROSSING_TIME,
-													FRAME_STACKTIME,
-													UPDATE_STACKTIME,
-													NETWORK_STACKTIME,
-													IMAGE_STACKTIME,
-													REBUILD_STACKTIME,
-													RENDER_STACKTIME,
-													SIM_PING;
+extern LLTrace::SampleStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER,
+														FRAMETIME_SLEW,
+														SIM_PING;
+
+extern LLTrace::EventStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP;
+
+extern LLTrace::EventStatHandle<>	LOADING_WEARABLES_LONG_DELAY;
+
+extern LLTrace::EventStatHandle<LLTrace::Milliseconds>	REGION_CROSSING_TIME,
+														FRAME_STACKTIME,
+														UPDATE_STACKTIME,
+														NETWORK_STACKTIME,
+														IMAGE_STACKTIME,
+														REBUILD_STACKTIME,
+														RENDER_STACKTIME;
+
+extern LLTrace::EventStatHandle<LLTrace::Seconds>	AVATAR_EDIT_TIME,
+													TOOLBOX_TIME,
+													MOUSELOOK_TIME,
+													FPS_10_TIME,
+													FPS_8_TIME,
+													FPS_2_TIME;
+
 }
 
 class LLViewerStats : public LLSingleton<LLViewerStats>
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 08d296b88e..5299e7d2c1 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -249,7 +249,7 @@ std::string	LLViewerWindow::sSnapshotDir;
 
 std::string	LLViewerWindow::sMovieBaseName;
 
-LLTrace::MeasurementStatHandle<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity");
+LLTrace::SampleStatHandle<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity");
 
 
 class RecordToChatConsole : public LLError::Recorder, public LLSingleton<RecordToChatConsole>
@@ -456,6 +456,8 @@ public:
 		
 		if (gSavedSettings.getBOOL("DebugShowRenderInfo"))
 		{
+			LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording();
+
 			if (gPipeline.getUseVertexShaders() == 0)
 			{
 				addText(xpos, ypos, "Shaders Disabled");
@@ -561,7 +563,7 @@ public:
 			addText(xpos, ypos, llformat("%d Unique Textures", LLImageGL::sUniqueCount));
 			ypos += y_inc;
 
-			addText(xpos, ypos, llformat("%d Render Calls", gPipeline.mBatchCount));
+			addText(xpos, ypos, llformat("%d Render Calls", last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize)));
             ypos += y_inc;
 
 			addText(xpos, ypos, llformat("%d/%d Objects Active", gObjectList.getNumActiveObjects(), gObjectList.getNumObjects()));
@@ -576,15 +578,10 @@ public:
 			gPipeline.mTextureMatrixOps = 0;
 			gPipeline.mMatrixOpCount = 0;
 
-			if (gPipeline.mBatchCount > 0)
-			{
-				addText(xpos, ypos, llformat("Batch min/max/mean: %d/%d/%d", gPipeline.mMinBatchSize, gPipeline.mMaxBatchSize, 
-					gPipeline.mTrianglesDrawn/gPipeline.mBatchCount));
-
-				gPipeline.mMinBatchSize = gPipeline.mMaxBatchSize;
-				gPipeline.mMaxBatchSize = 0;
-				gPipeline.mBatchCount = 0;
-			}
+ 			if (last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize) > 0)
+  			{
+ 				addText(xpos, ypos, llformat("Batch min/max/mean: %d/%d/%d", last_frame_recording.getMin(LLPipeline::sStatBatchSize), last_frame_recording.getMax(LLPipeline::sStatBatchSize), last_frame_recording.getMean(LLPipeline::sStatBatchSize)));
+  			}
             ypos += y_inc;
 
 			addText(xpos, ypos, llformat("UI Verts/Calls: %d/%d", LLRender::sUIVerts, LLRender::sUICalls));
diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h
index 004a59fda5..9fbb06a41e 100644
--- a/indra/newview/llviewerwindow.h
+++ b/indra/newview/llviewerwindow.h
@@ -250,7 +250,7 @@ public:
 	S32				getCurrentMouseDX()		const	{ return mCurrentMouseDelta.mX; }
 	S32				getCurrentMouseDY()		const	{ return mCurrentMouseDelta.mY; }
 	LLCoordGL		getCurrentMouseDelta()	const	{ return mCurrentMouseDelta; }
-	static LLTrace::MeasurementStatHandle<>*	getMouseVelocityStat()		{ return &sMouseVelocityStat; }
+	static LLTrace::SampleStatHandle<>*	getMouseVelocityStat()		{ return &sMouseVelocityStat; }
 	BOOL			getLeftMouseDown()	const	{ return mLeftMouseDown; }
 	BOOL			getMiddleMouseDown()	const	{ return mMiddleMouseDown; }
 	BOOL			getRightMouseDown()	const	{ return mRightMouseDown; }
@@ -482,7 +482,7 @@ private:
 	// Object temporarily hovered over while dragging
 	LLPointer<LLViewerObject>	mDragHoveredObject;
 
-	static LLTrace::MeasurementStatHandle<>	sMouseVelocityStat;
+	static LLTrace::SampleStatHandle<>	sMouseVelocityStat;
 };
 
 //
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 69f998f0f3..b6f48b4a66 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -914,7 +914,7 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 		{
 			++mRegionCrossingCount;
 			LLTrace::Seconds delta = mRegionCrossingTimer.getElapsedTimeF32();
-			sample(LLStatViewer::REGION_CROSSING_TIME, delta);
+			record(LLStatViewer::REGION_CROSSING_TIME, delta);
 
 			// Diagnostics
 			llinfos << "Region crossing took " << (F32)(delta * 1000.0).value() << " ms " << llendl;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 3f6269e768..6a0ef13894 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -198,6 +198,7 @@ BOOL LLPipeline::CameraOffset;
 F32 LLPipeline::CameraMaxCoF;
 F32 LLPipeline::CameraDoFResScale;
 F32 LLPipeline::RenderAutoHideSurfaceAreaLimit;
+LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
 
 const F32 BACKLIGHT_DAY_MAGNITUDE_AVATAR = 0.2f;
 const F32 BACKLIGHT_NIGHT_MAGNITUDE_AVATAR = 0.1f;
@@ -403,17 +404,9 @@ bool addDeferredAttachments(LLRenderTarget& target)
 
 LLPipeline::LLPipeline() :
 	mBackfaceCull(FALSE),
-	mBatchCount(0),
 	mMatrixOpCount(0),
 	mTextureMatrixOps(0),
-	mMaxBatchSize(0),
-	mMinBatchSize(0),
-	mMeanBatchSize(0),
-	mTrianglesDrawn(0),
 	mNumVisibleNodes(0),
-	mVerticesRelit(0),
-	mLightingChanges(0),
-	mGeometryChanges(0),
 	mNumVisibleFaces(0),
 
 	mInitialized(FALSE),
@@ -1809,17 +1802,7 @@ void LLPipeline::resetFrameStats()
 {
 	assertInitialized();
 
-	add(LLStatViewer::TRIANGLES_DRAWN, mTrianglesDrawn);
-
-	if (mBatchCount > 0)
-	{
-		mMeanBatchSize = gPipeline.mTrianglesDrawn/gPipeline.mBatchCount;
-	}
-	mTrianglesDrawn = 0;
 	sCompiles        = 0;
-	mVerticesRelit   = 0;
-	mLightingChanges = 0;
-	mGeometryChanges = 0;
 	mNumVisibleFaces = 0;
 
 	if (mOldRenderDebugMask != mRenderDebugMask)
@@ -1827,7 +1810,6 @@ void LLPipeline::resetFrameStats()
 		gObjectList.clearDebugText();
 		mOldRenderDebugMask = mRenderDebugMask;
 	}
-		
 }
 
 //external functions for asynchronous updating
@@ -2585,7 +2567,6 @@ BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority)
 	if (update_complete && assertInitialized())
 	{
 		drawablep->setState(LLDrawable::BUILT);
-		mGeometryChanges++;
 	}
 	return update_complete;
 }
@@ -3347,7 +3328,6 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera)
 		}
 	}
 	
-
 	mNumVisibleFaces += drawablep->getNumFaces();
 }
 
@@ -4516,10 +4496,8 @@ void LLPipeline::addTrianglesDrawn(S32 index_count, U32 render_type)
 		count = index_count/3;
 	}
 
-	mTrianglesDrawn += count;
-	mBatchCount++;
-	mMaxBatchSize = llmax(mMaxBatchSize, count);
-	mMinBatchSize = llmin(mMinBatchSize, count);
+	record(sStatBatchSize, count);
+	add(LLStatViewer::TRIANGLES_DRAWN, count);
 
 	if (LLPipeline::sRenderFrameTest)
 	{
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 720ddf79f5..ec976d3ecc 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -492,23 +492,14 @@ public:
 	LLQuaternion			mFlyCamRotation;
 
 	BOOL					 mBackfaceCull;
-	S32						 mBatchCount;
 	S32						 mMatrixOpCount;
 	S32						 mTextureMatrixOps;
-	S32						 mMaxBatchSize;
-	S32						 mMinBatchSize;
-	S32						 mMeanBatchSize;
-	S32						 mTrianglesDrawn;
 	S32						 mNumVisibleNodes;
-	S32						 mVerticesRelit;
 
 	S32						 mDebugTextureUploadCost;
 	S32						 mDebugSculptUploadCost;
 	S32						 mDebugMeshUploadCost;
 
-	S32						 mLightingChanges;
-	S32						 mGeometryChanges;
-
 	S32						 mNumVisibleFaces;
 
 	static S32				sCompiles;
@@ -542,6 +533,8 @@ public:
 	static S32				sVisibleLightCount;
 	static F32				sMinRenderSize;	
 
+	static LLTrace::EventStatHandle<S64> sStatBatchSize;
+
 	//screen texture
 	U32 					mScreenWidth;
 	U32 					mScreenHeight;
-- 
cgit v1.2.3


From fe7959591633e4c6bda570c6fd19d7fdfec15454 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 29 May 2013 20:44:36 -0700
Subject: BUILDFIX: fixed unit test compile error

---
 indra/newview/tests/llviewerassetstats_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index ae93778534..819728aad6 100644
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -39,7 +39,7 @@
 
 namespace LLStatViewer
 {
-	LLTrace::MeasurementStatHandle<>		FPS_SAMPLE("fpssample");
+	LLTrace::SampleStatHandle<>		FPS_SAMPLE("fpssample");
 }
 
 void LLVOAvatar::getNearbyRezzedStats(std::vector<S32>& counts)
-- 
cgit v1.2.3


From 626d5e3b3d935e0ba616408b1736bd10f5ea9990 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 30 May 2013 16:09:36 -0600
Subject: remove a debug assertion

---
 indra/newview/llvocache.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index bcd9dda652..5e2d2efc5e 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -167,7 +167,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 LLVOCacheEntry::~LLVOCacheEntry()
 {
 	mDP.freeBuffer();
-	llassert(mState == INACTIVE);
+	//llassert(mState == INACTIVE);
 }
 
 //virtual 
-- 
cgit v1.2.3


From e50e6004082223fdc0bfd78bc697d48a7f45b379 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 30 May 2013 20:15:48 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 reverted SlaveThreadRecorder update gating moved processTimes() outside of
 Recording, so it is called only once per frame refined sample merge logic so
 that multi-threaded samples do not stomp on linear history of a stat

---
 indra/newview/llappviewer.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index a049aabe74..ff481d6278 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1241,6 +1241,7 @@ bool LLAppViewer::mainLoop()
 	while (!LLApp::isExiting())
 	{
 		LLFastTimer _(FTM_FRAME);
+		LLTrace::TimeBlock::processTimes();
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
 
-- 
cgit v1.2.3


From a6e80e3526af3890e688e53329be040e899fe203 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 31 May 2013 15:22:29 -0600
Subject: revert changes for SH-3927: Interesting: Viewer should send predicted
 camera position to simulator to control object load order

---
 indra/newview/llviewermessage.cpp | 3 ---
 1 file changed, 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 8dc72ba5b4..4b1c9c5574 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4222,9 +4222,6 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 	LLQuaternion head_rotation = gAgent.getHeadRotation();
 
 	camera_pos_agent = gAgentCamera.getCameraPositionAgent();
-	LLVector3 camera_velocity = LLViewerCamera::getInstance()->getVelocityDir() * LLViewerCamera::getInstance()->getAverageSpeed();
-	F32 time_delta = 1.0f; //predict the camera position in 1 second
-	camera_pos_agent += camera_velocity * time_delta;
 
 	render_state = gAgent.getRenderState();
 
-- 
cgit v1.2.3


From 9def3590f41dee3cba7760e4443fdc71f5fb2db6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 31 May 2013 16:01:46 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 fixed multithreading lltrace causing values to be interpolated towards 0
 added Radians unit improved sceneloadmonitor restart heuristic to use
 accumulated camera motion

---
 indra/newview/llappviewer.cpp    |  5 +----
 indra/newview/llscenemonitor.cpp | 32 +++++++++++++-------------------
 indra/newview/llscenemonitor.h   |  9 ++++-----
 3 files changed, 18 insertions(+), 28 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ff481d6278..451ea76a02 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1578,10 +1578,7 @@ bool LLAppViewer::cleanup()
 	LLEventPumps::instance().reset();
 
 	//dump scene loading monitor results
-	if(LLSceneMonitor::instance().hasResults())
-	{
-		LLSceneMonitor::instance().dumpToFile(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "scene_monitor_results.csv"));
-	}
+	LLSceneMonitor::instance().dumpToFile(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "scene_monitor_results.csv"));
 
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index a28c2eac20..7eb48eb575 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -67,22 +67,13 @@ LLSceneMonitor::LLSceneMonitor() :
 {
 	mFrames[0] = NULL;
 	mFrames[1] = NULL;
-
-	mRecording = new LLTrace::ExtendablePeriodicRecording();
 }
 
 LLSceneMonitor::~LLSceneMonitor()
 {
 	mDiffState = VIEWER_QUITTING;
-	destroyClass();
-}
-
-void LLSceneMonitor::destroyClass()
-{
 	reset();
 
-	delete mRecording;
-	mRecording = NULL;
 	mDitheringTexture = NULL;
 }
 
@@ -96,7 +87,8 @@ void LLSceneMonitor::reset()
 	mFrames[1] = NULL;
 	mDiff = NULL;
 
-	mRecording->reset();
+	mMonitorRecording.reset();
+	mSceneLoadRecording.reset();
 
 	unfreezeScene();
 
@@ -269,10 +261,9 @@ void LLSceneMonitor::capture()
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static LLFrameTimer timer;	
 
-	LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording();
 	if (mEnabled 
-		&&	(last_frame_recording.getSum(*LLViewerCamera::getVelocityStat()) > 0.001f
-			|| last_frame_recording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.01f))
+		&&	(mMonitorRecording.getSum(*LLViewerCamera::getVelocityStat()) > 0.1f
+			|| mMonitorRecording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.05f))
 	{
 		reset();
 		freezeScene();
@@ -299,7 +290,8 @@ void LLSceneMonitor::capture()
 		&& LLGLSLShader::sNoFixedFunction
 		&& last_capture_time != gFrameCount)
 	{
-		mRecording->resume();
+		mSceneLoadRecording.resume();
+		mMonitorRecording.resume();
 
 		timer.reset();
 
@@ -486,13 +478,13 @@ void LLSceneMonitor::fetchQueryResult()
 			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
 			if(mDiffResult > diff_threshold())
 			{
-				mRecording->extend();
-				llassert(mRecording->getAcceptedRecording().getLastRecording().getSum(LLStatViewer::FPS));
+				mSceneLoadRecording.extend();
+				llassert(mSceneLoadRecording.getAcceptedRecording().getLastRecording().getSum(LLStatViewer::FPS));
 			}
 			else
 			{
-				mRecording->getPotentialRecording().nextPeriod();
-				llassert(mRecording->getPotentialRecording().getLastRecording().getSum(LLStatViewer::FPS));
+				mSceneLoadRecording.getPotentialRecording().nextPeriod();
+				llassert(mSceneLoadRecording.getPotentialRecording().getLastRecording().getSum(LLStatViewer::FPS));
 			}
 		}
 	}
@@ -501,13 +493,15 @@ void LLSceneMonitor::fetchQueryResult()
 //dump results to a file _scene_xmonitor_results.csv
 void LLSceneMonitor::dumpToFile(std::string file_name)
 {
+	if (!hasResults()) return;
+
 	LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; 
 
 	std::ofstream os(file_name.c_str());
 
 	os << std::setprecision(4);
 
-	LLTrace::PeriodicRecording& scene_load_recording = mRecording->getAcceptedRecording();
+	LLTrace::PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording();
 	U32 frame_count = scene_load_recording.getNumPeriods();
 
 	LLUnit<LLUnits::Seconds, F64> frame_time;
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 3351ed0579..6af58b707a 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -44,8 +44,6 @@ public:
 	LLSceneMonitor();
 	~LLSceneMonitor();
 
-	void destroyClass();
-	
 	void freezeAvatar(LLCharacter* avatarp);
 	void setDebugViewerVisible(bool visible);
 
@@ -62,9 +60,9 @@ public:
 	bool isEnabled()const {return mEnabled;}
 	bool needsUpdate() const;
 	
-	LLTrace::ExtendablePeriodicRecording* getRecording() const {return mRecording;}
+	const LLTrace::ExtendablePeriodicRecording* getRecording() const {return &mSceneLoadRecording;}
 	void dumpToFile(std::string file_name);
-	bool hasResults() const { return mRecording->getAcceptedRecording().getDuration() != 0;}
+	bool hasResults() const { return mSceneLoadRecording.getAcceptedRecording().getDuration() != 0;}
 
 private:
 	void freezeScene();
@@ -103,7 +101,8 @@ private:
 
 	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
 
-	LLTrace::ExtendablePeriodicRecording* mRecording;
+	LLTrace::ExtendablePeriodicRecording mSceneLoadRecording;
+	LLTrace::Recording					 mMonitorRecording;
 };
 
 class LLSceneMonitorView : public LLFloater
-- 
cgit v1.2.3


From fd21ddd9d0adf7342fe89d371868c3f7f7ca9f5f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 31 May 2013 23:40:10 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 made recordings auto-update when executing query while active

---
 indra/newview/llscenemonitor.cpp     | 2 +-
 indra/newview/llviewerassetstats.cpp | 2 +-
 indra/newview/llviewerstats.h        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 7eb48eb575..bb1cfaa9a8 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -240,7 +240,7 @@ void LLSceneMonitor::unfreezeScene()
 
 	if(mDiffState == VIEWER_QUITTING)
 	{
-		return; //we are quitting viewer.
+		return;
 	}
 
 	// thaw everything else
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 0bbf2cbbea..062dabdd13 100644
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -286,13 +286,13 @@ LLViewerAssetStats::LLViewerAssetStats(const LLViewerAssetStats & src)
 	mRegionRecordings = src.mRegionRecordings;
 
 	mCurRecording = &mRegionRecordings[mRegionHandle];
-	mCurRecording->stop();
 
 	// assume this is being passed to another thread, so make sure we have unique copies of recording data
 	for (PerRegionRecordingContainer::iterator it = mRegionRecordings.begin(), end_it = mRegionRecordings.end();
 		it != end_it;
 		++it)
 	{
+		it->second.stop();
 		it->second.makeUnique();
 	}
 
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index c0ac6d220f..ca8c347afa 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -207,7 +207,7 @@ public:
 
 	void updateFrameStats(const F64 time_diff);
 	
-	void addToMessage(LLSD &body) const;
+	void addToMessage(LLSD &body);
 
 	struct  StatsAccumulator
 	{
-- 
cgit v1.2.3


From aa7024ffbacdd9e8ac0bfaca86d54f2dd9e1dda7 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 31 May 2013 23:41:30 -0700
Subject: BUILDFIX - const correctness

---
 indra/newview/llviewerstats.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 635611c02e..06a53787e7 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -263,7 +263,7 @@ void LLViewerStats::updateFrameStats(const F64 time_diff)
 	mLastTimeDiff = time_diff;
 }
 
-void LLViewerStats::addToMessage(LLSD &body) const
+void LLViewerStats::addToMessage(LLSD &body)
 {
 	LLSD &misc = body["misc"];
 	
-- 
cgit v1.2.3


From 233201f8227f92e93061d3e2393a17b42dfa3dd1 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sun, 2 Jun 2013 22:49:17 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 removed unnecessary templates from accumulator types...now always track data
 in double precision floating point, using templated accessors to convert to
 and from arbitrary types

---
 indra/newview/llscenemonitor.cpp | 36 +++++++-----------------------------
 1 file changed, 7 insertions(+), 29 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index bb1cfaa9a8..1bbd6ae2b9 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -493,6 +493,7 @@ void LLSceneMonitor::fetchQueryResult()
 //dump results to a file _scene_xmonitor_results.csv
 void LLSceneMonitor::dumpToFile(std::string file_name)
 {
+	using namespace LLTrace;
 	if (!hasResults()) return;
 
 	LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; 
@@ -501,7 +502,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 	os << std::setprecision(4);
 
-	LLTrace::PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording();
+	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording();
 	U32 frame_count = scene_load_recording.getNumPeriods();
 
 	LLUnit<LLUnits::Seconds, F64> frame_time;
@@ -514,7 +515,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	}
 	os << std::endl;
 
-	for (LLTrace::CountStatHandle<F64>::instance_iter it = LLTrace::CountStatHandle<F64>::beginInstances(), end_it = LLTrace::CountStatHandle<F64>::endInstances();
+	for (CountStatHandle<F64>::instance_iter it = CountStatHandle<F64>::beginInstances(), end_it = CountStatHandle<F64>::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -537,7 +538,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (LLTrace::CountStatHandle<S64>::instance_iter it = LLTrace::CountStatHandle<S64>::beginInstances(), end_it = LLTrace::CountStatHandle<S64>::endInstances();
+	for (CountStatHandle<S64>::instance_iter it = CountStatHandle<S64>::beginInstances(), end_it = CountStatHandle<S64>::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -560,7 +561,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (LLTrace::EventStatHandle<F64>::instance_iter it = LLTrace::EventStatHandle<F64>::beginInstances(), end_it = LLTrace::EventStatHandle<F64>::endInstances();
+	for (EventStatHandle<F64>::instance_iter it = EventStatHandle<F64>::beginInstances(), end_it = EventStatHandle<F64>::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -583,7 +584,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (LLTrace::EventStatHandle<S64>::instance_iter it = LLTrace::EventStatHandle<S64>::beginInstances(), end_it = LLTrace::EventStatHandle<S64>::endInstances();
+	for (EventStatHandle<S64>::instance_iter it = EventStatHandle<S64>::beginInstances(), end_it = EventStatHandle<S64>::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -606,30 +607,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (LLTrace::SampleStatHandle<F64>::instance_iter it = LLTrace::SampleStatHandle<F64>::beginInstances(), end_it = LLTrace::SampleStatHandle<F64>::endInstances();
-		it != end_it;
-		++it)
-	{
-		std::ostringstream row;
-		row << it->getName();
-
-		S32 samples = 0;
-
-		for (S32 i = frame_count - 1; i >= 0; --i)
-		{
-			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
-		}
-
-		row << std::endl;
-
-		if (samples > 0)
-		{
-			os << row.str();
-		}
-	}
-
-	for (LLTrace::SampleStatHandle<S64>::instance_iter it = LLTrace::SampleStatHandle<S64>::beginInstances(), end_it = LLTrace::SampleStatHandle<S64>::endInstances();
+	for (TraceType<SampleAccumulator>::instance_iter it = TraceType<SampleAccumulator>::beginInstances(), end_it = TraceType<SampleAccumulator>::endInstances();
 		it != end_it;
 		++it)
 	{
-- 
cgit v1.2.3


From 5b48107dbf969529267874bff9a0a4b892b348cf Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 4 Jun 2013 08:33:11 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 added labels to LLUnit types added memstat dumps to llscenemonitor

---
 indra/newview/llscenemonitor.cpp | 58 +++++++++++-----------------------------
 1 file changed, 16 insertions(+), 42 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 1bbd6ae2b9..1a5b43c703 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -492,18 +492,18 @@ void LLSceneMonitor::fetchQueryResult()
 
 //dump results to a file _scene_xmonitor_results.csv
 void LLSceneMonitor::dumpToFile(std::string file_name)
-{
-	using namespace LLTrace;
+{	using namespace LLTrace;
+
 	if (!hasResults()) return;
 
 	LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; 
 
 	std::ofstream os(file_name.c_str());
 
-	os << std::setprecision(4);
+	os << std::setprecision(3);
 
 	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording();
-	U32 frame_count = scene_load_recording.getNumPeriods();
+	const U32 frame_count = scene_load_recording.getNumPeriods();
 
 	LLUnit<LLUnits::Seconds, F64> frame_time;
 
@@ -515,7 +515,8 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	}
 	os << std::endl;
 
-	for (CountStatHandle<F64>::instance_iter it = CountStatHandle<F64>::beginInstances(), end_it = CountStatHandle<F64>::endInstances();
+	typedef TraceType<CountAccumulator> trace_count;
+	for (trace_count::instance_iter it = trace_count::beginInstances(), end_it = trace_count::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -538,30 +539,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (CountStatHandle<S64>::instance_iter it = CountStatHandle<S64>::beginInstances(), end_it = CountStatHandle<S64>::endInstances();
-		it != end_it;
-		++it)
-	{
-		std::ostringstream row;
-		row << it->getName();
-
-		S32 samples = 0;
-
-		for (S32 i = frame_count - 1; i >= 0; --i)
-		{
-			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it);
-		}
-
-		row << std::endl;
-
-		if (samples > 0)
-		{
-			os << row.str();
-		}
-	}
+	typedef TraceType<EventAccumulator> trace_event;
 
-	for (EventStatHandle<F64>::instance_iter it = EventStatHandle<F64>::beginInstances(), end_it = EventStatHandle<F64>::endInstances();
+	for (trace_event::instance_iter it = trace_event::beginInstances(), end_it = trace_event::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -584,7 +564,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (EventStatHandle<S64>::instance_iter it = EventStatHandle<S64>::beginInstances(), end_it = EventStatHandle<S64>::endInstances();
+	typedef TraceType<SampleAccumulator> trace_sample;
+
+	for (trace_sample::instance_iter it = trace_sample::beginInstances(), end_it = trace_sample::endInstances();
 		it != end_it;
 		++it)
 	{
@@ -607,27 +589,19 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		}
 	}
 
-	for (TraceType<SampleAccumulator>::instance_iter it = TraceType<SampleAccumulator>::beginInstances(), end_it = TraceType<SampleAccumulator>::endInstances();
+	typedef TraceType<MemStatAccumulator> trace_mem;
+	for (trace_mem::instance_iter it = trace_mem::beginInstances(), end_it = trace_mem::endInstances();
 		it != end_it;
 		++it)
 	{
-		std::ostringstream row;
-		row << it->getName();
-
-		S32 samples = 0;
+		os << it->getName();
 
 		for (S32 i = frame_count - 1; i >= 0; --i)
 		{
-			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
+			os << ", " << scene_load_recording.getPrevRecording(i).getSum(*it).as<LLUnits::Megabytes>().value();
 		}
 
-		row << std::endl;
-
-		if (samples > 0)
-		{
-			os << row.str();
-		}
+		os << std::endl;
 	}
 
 	os.flush();
-- 
cgit v1.2.3


From 715385eed7b2276963015861d7e6b8196e6ae5cd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 4 Jun 2013 10:54:12 -0700
Subject: BUILDFIX: don't multiple define class statics...use inline static
 method instead

---
 indra/newview/llscenemonitor.cpp | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 1a5b43c703..f7abb982e1 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -523,12 +523,18 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		std::ostringstream row;
 		row << it->getName();
 
+		const char* unit_label = it->getUnitLabel();
+		if(unit_label[0])
+		{
+			row << "(" << unit_label << ")";
+		}
+
 		S32 samples = 0;
 
-		for (S32 i = frame_count - 1; i >= 0; --i)
+		for (S32 frame = 0; frame < frame_count; frame++)
 		{
-			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(i).getSum(*it);
+			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it);
 		}
 
 		row << std::endl;
@@ -550,10 +556,10 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		S32 samples = 0;
 
-		for (S32 i = frame_count - 1; i >= 0; --i)
+		for (S32 frame = 0; frame < frame_count; frame++)
 		{
-			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
+			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it);
 		}
 
 		row << std::endl;
@@ -575,10 +581,10 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		S32 samples = 0;
 
-		for (S32 i = frame_count - 1; i >= 0; --i)
+		for (S32 frame = 0; frame < frame_count; frame++)
 		{
-			samples += scene_load_recording.getPrevRecording(i).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(i).getMean(*it);
+			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
+			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it);
 		}
 
 		row << std::endl;
@@ -596,9 +602,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	{
 		os << it->getName();
 
-		for (S32 i = frame_count - 1; i >= 0; --i)
+		for (S32 frame = 0; frame < frame_count; frame++)
 		{
-			os << ", " << scene_load_recording.getPrevRecording(i).getSum(*it).as<LLUnits::Megabytes>().value();
+			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it).value();
 		}
 
 		os << std::endl;
@@ -606,7 +612,6 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 	os.flush();
 	os.close();
-
 }
 
 //-------------------------------------------------------------------------------------------------------------
-- 
cgit v1.2.3


From a74b5dfa923f8eeccc9b786143f0f832de3ad450 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 4 Jun 2013 19:45:33 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 fixed mem stat tracking...now properly tracks memory footprint with floating
 point precision cleaned up macros for unit declaration renamed units to SI
 standard for 1024 multiples (kibibytes, etc) fixed units output for scene
 monitor dump

---
 indra/newview/llscenemonitor.cpp  | 16 ++++++++++++++--
 indra/newview/lltextureview.cpp   | 12 ++++++------
 indra/newview/llviewerstats.cpp   |  8 ++++----
 indra/newview/llviewerstats.h     |  2 +-
 indra/newview/llviewertexture.cpp |  8 ++++----
 indra/newview/llviewertexture.h   |  8 ++++----
 indra/newview/llviewerwindow.cpp  |  2 +-
 7 files changed, 34 insertions(+), 22 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index f7abb982e1..dccf8a2a17 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -554,6 +554,12 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		std::ostringstream row;
 		row << it->getName();
 
+		const char* unit_label = it->getUnitLabel();
+		if(unit_label[0])
+		{
+			row << "(" << unit_label << ")";
+		}
+
 		S32 samples = 0;
 
 		for (S32 frame = 0; frame < frame_count; frame++)
@@ -579,6 +585,12 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		std::ostringstream row;
 		row << it->getName();
 
+		const char* unit_label = it->getUnitLabel();
+		if(unit_label[0])
+		{
+			row << "(" << unit_label << ")";
+		}
+
 		S32 samples = 0;
 
 		for (S32 frame = 0; frame < frame_count; frame++)
@@ -600,11 +612,11 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		it != end_it;
 		++it)
 	{
-		os << it->getName();
+		os << it->getName() << "(KiB)";
 
 		for (S32 frame = 0; frame < frame_count; frame++)
 		{
-			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it).value();
+			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).as<LLUnits::Kibibytes>().value();
 		}
 
 		os << std::endl;
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 7a6351c880..0df7b46b52 100644
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -507,13 +507,13 @@ private:
 
 void LLGLTexMemBar::draw()
 {
-	LLUnit<LLUnits::Megabytes, S32> bound_mem = LLViewerTexture::sBoundTextureMemory;
- 	LLUnit<LLUnits::Megabytes, S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
-	LLUnit<LLUnits::Megabytes, S32> total_mem = LLViewerTexture::sTotalTextureMemory;
-	LLUnit<LLUnits::Megabytes, S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
+	LLUnit<LLUnits::Mibibytes, S32> bound_mem = LLViewerTexture::sBoundTextureMemory;
+ 	LLUnit<LLUnits::Mibibytes, S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
+	LLUnit<LLUnits::Mibibytes, S32> total_mem = LLViewerTexture::sTotalTextureMemory;
+	LLUnit<LLUnits::Mibibytes, S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;
-	F32 cache_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
-	F32 cache_max_usage = (F32)LLTrace::Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
+	F32 cache_usage = (F32)LLTrace::Mibibytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
+	F32 cache_max_usage = (F32)LLTrace::Mibibytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
 	LLUnit<LLUnits::Bytes, F32> total_texture_downloaded = gTotalTextureData;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 06a53787e7..d29d1ebe5f 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -89,7 +89,7 @@ LLTrace::CountStatHandle<>	FPS("framesrendered"),
 							TEX_BAKES("texbakes"),
 							TEX_REBAKES("texrebakes"),
 							NUM_NEW_OBJECTS("numnewobjectsstat");
-LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT("kbitstat"),
+LLTrace::CountStatHandle<LLTrace::Kibibits>	KBIT("kbitstat"),
 											LAYERS_KBIT("layerskbitstat"),
 											OBJECT_KBIT("objectkbitstat"),
 											ASSET_KBIT("assetkbitstat"),
@@ -552,9 +552,9 @@ void send_stats()
 
 	LLSD &download = body["downloads"];
 
-	download["world_kbytes"] = LLTrace::Kilobytes(gTotalWorldData).value();
-	download["object_kbytes"] = LLTrace::Kilobytes(gTotalObjectData).value();
-	download["texture_kbytes"] = LLTrace::Kilobytes(gTotalTextureData).value();
+	download["world_kbytes"] = LLTrace::Kibibytes(gTotalWorldData).value();
+	download["object_kbytes"] = LLTrace::Kibibytes(gTotalObjectData).value();
+	download["texture_kbytes"] = LLTrace::Kibibytes(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 ca8c347afa..7ad1e5d053 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -94,7 +94,7 @@ extern LLTrace::CountStatHandle<>			FPS,
 											NUM_NEW_OBJECTS;
 
 
-extern LLTrace::CountStatHandle<LLTrace::Kilobits>	KBIT,
+extern LLTrace::CountStatHandle<LLTrace::Kibibits>	KBIT,
 											LAYERS_KBIT,
 											OBJECT_KBIT,
 											ASSET_KBIT,
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 12835002d3..a3cd2efd66 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -65,8 +65,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 // extern
-const LLUnit<LLUnits::Megabytes, S32> gMinVideoRam = 32;
-const LLUnit<LLUnits::Megabytes, S32> gMaxVideoRam = 512;
+const LLUnit<LLUnits::Mibibytes, S32> gMinVideoRam = 32;
+const LLUnit<LLUnits::Mibibytes, S32> gMaxVideoRam = 512;
 
 
 // statics
@@ -89,8 +89,8 @@ F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
 F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
 LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sBoundTextureMemory = 0;
 LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sTotalTextureMemory = 0;
-LLUnit<LLUnits::Megabytes, S32> LLViewerTexture::sMaxBoundTextureMem = 0;
-LLUnit<LLUnits::Megabytes, S32> LLViewerTexture::sMaxTotalTextureMem = 0;
+LLUnit<LLUnits::Mibibytes, S32> LLViewerTexture::sMaxBoundTextureMem = 0;
+LLUnit<LLUnits::Mibibytes, S32> LLViewerTexture::sMaxTotalTextureMem = 0;
 LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
 S8  LLViewerTexture::sCameraMovingDiscardBias = 0 ;
 F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index d69a0ffb72..ff1aef181b 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -39,8 +39,8 @@
 #include <map>
 #include <list>
 
-extern const LLUnit<LLUnits::Megabytes, S32> gMinVideoRam;
-extern const LLUnit<LLUnits::Megabytes, S32> gMaxVideoRam;
+extern const LLUnit<LLUnits::Mibibytes, S32> gMinVideoRam;
+extern const LLUnit<LLUnits::Mibibytes, S32> gMaxVideoRam;
 
 class LLFace;
 class LLImageGL ;
@@ -329,8 +329,8 @@ public:
 	static F32 sDesiredDiscardScale;
 	static LLUnit<LLUnits::Bytes, S32> sBoundTextureMemory;
 	static LLUnit<LLUnits::Bytes, S32> sTotalTextureMemory;
-	static LLUnit<LLUnits::Megabytes, S32> sMaxBoundTextureMem;
-	static LLUnit<LLUnits::Megabytes, S32> sMaxTotalTextureMem;
+	static LLUnit<LLUnits::Mibibytes, S32> sMaxBoundTextureMem;
+	static LLUnit<LLUnits::Mibibytes, S32> sMaxTotalTextureMem;
 	static LLUnit<LLUnits::Bytes, S32> sMaxDesiredTextureMem ;
 	static S8  sCameraMovingDiscardBias;
 	static F32 sCameraMovingBias;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index ed85667469..9523037b36 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -734,7 +734,7 @@ public:
 			{
 				if(gTotalTextureBytesPerBoostLevel[i] > 0)
 				{
-					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit<LLUnits::Megabytes, F32>(gTotalTextureBytesPerBoostLevel[i]).value()));
+					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit<LLUnits::Mibibytes, F32>(gTotalTextureBytesPerBoostLevel[i]).value()));
 					ypos += y_inc;
 				}
 			}
-- 
cgit v1.2.3


From a6dbd8e089b7d0f462a8ed753258a442b1861541 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 5 Jun 2013 18:01:25 -0600
Subject: fix for SH-4227: interesting: long delay between root and child prim
 loading.

---
 indra/newview/llviewerobject.cpp     | 28 +++++++++++++++++++++-
 indra/newview/llviewerobjectlist.cpp |  4 ++++
 indra/newview/llviewerregion.cpp     | 46 ++++++++++++++++++++++++++++++++++--
 indra/newview/llviewerregion.h       |  5 ++++
 4 files changed, 80 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index d912918129..f13e6b7f43 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -343,6 +343,10 @@ void LLViewerObject::markDead()
 
 		// Mark itself as dead
 		mDead = TRUE;
+		if(mRegionp)
+		{
+			mRegionp->removeFromCreatedList(getLocalID()); 
+		}
 		gObjectList.cleanupReferences(this);
 
 		LLViewerObject *childp;
@@ -1046,6 +1050,17 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		}
 		else
 		{
+			if(regionp != mRegionp)
+			{
+				if(mRegionp)
+				{
+					mRegionp->removeFromCreatedList(getLocalID()); 
+				}
+				if(regionp)
+				{
+					regionp->addToCreatedList(getLocalID()); 
+				}
+			}
 			mRegionp = regionp ;
 		}
 	}	
@@ -5454,7 +5469,18 @@ void LLViewerObject::setRegion(LLViewerRegion *regionp)
 	{
 		llwarns << "viewer object set region to NULL" << llendl;
 	}
-	
+	if(regionp != mRegionp)
+	{
+		if(mRegionp)
+		{
+			mRegionp->removeFromCreatedList(getLocalID()); 
+		}
+		if(regionp)
+		{
+			regionp->addToCreatedList(getLocalID()); 
+		}
+	}
+
 	mLatestRecvPacketID = 0;
 	mRegionp = regionp;
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index c6ac7af93c..dc3be24e3a 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -2045,6 +2045,10 @@ LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRe
 // 		llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << " id:" << fullid << llendl;
 		return NULL;
 	}
+	if(regionp)
+	{
+		regionp->addToCreatedList(local_id); 
+	}
 
 	mUUIDObjectMap[fullid] = objectp;
 	setUUIDAndLocal(fullid,
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 85da75510b..b7d8c470b5 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -146,6 +146,7 @@ public:
 	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.
+	std::set<U32>                          mNonCacheableCreatedList; //list of local ids of all non-cacheable objects
 
 	// time?
 	// LRU info?
@@ -1694,7 +1695,9 @@ void LLViewerRegion::findOrphans(U32 parent_id)
 		std::vector<U32>* children = &mOrphanMap[parent_id];
 		for(S32 i = 0; i < children->size(); i++)
 		{
-			forceToRemoveFromCache((*children)[i], NULL);
+			//parent is visible, so is the child.
+			LLVOCacheEntry* child = getCacheEntry((*children)[i]);
+			addVisibleCacheEntry(child);
 		}
 		children->clear();
 		mOrphanMap.erase(parent_id);
@@ -1735,7 +1738,16 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 		//2, parent is not in the cache, put into the orphan list.
 		if(!parent)
 		{
-			mOrphanMap[parent_id].push_back(entry->getLocalID());
+			//check if parent is non-cacheable and already created
+			if(isNonCacheableObjectCreated(parent_id))
+			{
+				//parent is visible, so is the child.
+				addVisibleCacheEntry(entry);
+			}
+			else
+			{
+				mOrphanMap[parent_id].push_back(entry->getLocalID());
+			}
 		}
 		else //parent in cache
 		{
@@ -1901,6 +1913,36 @@ void LLViewerRegion::addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_ty
 #endif
 }
 
+//check if a non-cacheable object is already created.
+bool LLViewerRegion::isNonCacheableObjectCreated(U32 local_id)
+{
+	if(mImpl && local_id > 0 && mImpl->mNonCacheableCreatedList.find(local_id) != mImpl->mNonCacheableCreatedList.end())
+	{
+		return true;
+	}
+	return false;
+}
+
+void LLViewerRegion::removeFromCreatedList(U32 local_id)
+{	
+	if(mImpl && local_id > 0)
+	{
+		std::set<U32>::iterator iter = mImpl->mNonCacheableCreatedList.find(local_id);
+		if(iter != mImpl->mNonCacheableCreatedList.end())
+		{
+			mImpl->mNonCacheableCreatedList.erase(iter);
+		}
+	}
+}
+
+void LLViewerRegion::addToCreatedList(U32 local_id)
+{
+	if(mImpl && local_id > 0)
+	{
+		mImpl->mNonCacheableCreatedList.insert(local_id);
+	}
+}
+
 // Get data packer for this object, if we have cached data
 // AND the CRC matches. JC
 bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss_type)
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index fefd4209aa..196f363611 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -347,6 +347,9 @@ public:
 	void getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegions );
 	void getNeighboringRegionsStatus( std::vector<S32>& regions );
 	
+	void removeFromCreatedList(U32 local_id);
+	void addToCreatedList(U32 local_id);
+
 private:
 	void addToVOCacheTree(LLVOCacheEntry* entry);
 	LLViewerObject* addNewObject(LLVOCacheEntry* entry);
@@ -361,6 +364,8 @@ private:
 
 	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type);
 	void decodeBoundingInfo(LLVOCacheEntry* entry);
+	bool isNonCacheableObjectCreated(U32 local_id);	
+
 public:
 	struct CompareDistance
 	{
-- 
cgit v1.2.3


From 042b7aec26905cdfded007d6507abccb44947d8a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 5 Jun 2013 20:25:21 -0700
Subject: BUILDFIX: fixed llviewerassetstats test and render2dutils changes
 that were dropped in merge

---
 indra/newview/tests/llviewerassetstats_test.cpp | 58 +++++--------------------
 1 file changed, 10 insertions(+), 48 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index 561c2bb286..50266cd117 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -343,8 +343,8 @@ namespace tut
 		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
 		gViewerAssetStats->updateStats();
-		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
+		LLSD sd = gViewerAssetStats->asLLSD(false);
+		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = sd["regions"][0];
 		
@@ -367,47 +367,9 @@ namespace tut
 		ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger()));
 	}
 
-	// Create two global instances and verify no interactions
-	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<5>()
-	{
-		gViewerAssetStats = new LLViewerAssetStats();
-		LLViewerAssetStatsFF::set_region(region1_handle);
-
-		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_TEXTURE, false, false);
-		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
-
-		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
-		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
-
-		gViewerAssetStats->updateStats();
-		LLSD sd = gViewerAssetStatsMain->asLLSD(false);
-		ensure("Correct single-key LLSD map root", is_triple_key_map(sd, "regions", "duration", "avatar"));
-		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
-		sd = sd["regions"][0];
-		
-		// Check a few points on the tree for content
-		ensure("sd[get_texture_non_temp_udp][enqueued] is 1", (1 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger()));
-		ensure("sd[get_texture_temp_udp][enqueued] is 0", (0 == sd["get_texture_temp_udp"]["enqueued"].asInteger()));
-		ensure("sd[get_texture_non_temp_http][enqueued] is 0", (0 == sd["get_texture_non_temp_http"]["enqueued"].asInteger()));
-		ensure("sd[get_texture_temp_http][enqueued] is 0", (0 == sd["get_texture_temp_http"]["enqueued"].asInteger()));
-		ensure("sd[get_gesture_udp][dequeued] is 0", (0 == sd["get_gesture_udp"]["dequeued"].asInteger()));
-
-		// Reset and check zeros...
-		// Reset leaves current region in place
-		gViewerAssetStats->reset();
-		sd = gViewerAssetStats->asLLSD(false)["regions"][0];
-		
-		delete gViewerAssetStats;
-		gViewerAssetStats = NULL;
-
-		ensure("sd[get_texture_non_temp_udp][enqueued] is reset", (0 == sd["get_texture_non_temp_udp"]["enqueued"].asInteger()));
-		ensure("sd[get_gesture_udp][dequeued] is reset", (0 == sd["get_gesture_udp"]["dequeued"].asInteger()));
-	}
-
     // Check multiple region collection
 	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<6>()
+	void tst_viewerassetstats_index_object_t::test<5>()
 	{
 		gViewerAssetStats = new LLViewerAssetStats();
 
@@ -452,8 +414,8 @@ namespace tut
 
 		// Reset and check zeros...
 		// Reset leaves current region in place
-		gViewerAssetStatsMain->reset();
-		sd = gViewerAssetStatsMain->asLLSD(false);
+		gViewerAssetStats->reset();
+		sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle));
 		sd2 = sd["regions"][0];
@@ -467,7 +429,7 @@ namespace tut
 
     // Check multiple region collection jumping back-and-forth between regions
 	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<7>()
+	void tst_viewerassetstats_index_object_t::test<6>()
 	{
 		gViewerAssetStats = new LLViewerAssetStats();
 
@@ -525,8 +487,8 @@ namespace tut
 
 		// Reset and check zeros...
 		// Reset leaves current region in place
-		gViewerAssetStatsMain->reset();
-		sd = gViewerAssetStatsMain->asLLSD(false);
+		gViewerAssetStats->reset();
+		sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "duration", "regions"));
 		ensure("Correct single-slot LLSD array regions (p2)", is_single_slot_array(sd["regions"], region2_handle));
 		sd2 = get_region(sd, region2_handle);
@@ -541,7 +503,7 @@ namespace tut
 
 	// Non-texture assets ignore transport and persistence flags
 	template<> template<>
-	void tst_viewerassetstats_index_object_t::test<8>()
+	void tst_viewerassetstats_index_object_t::test<7>()
 	{
 		gViewerAssetStats = new LLViewerAssetStats();
 		LLViewerAssetStatsFF::set_region(region1_handle);
@@ -570,7 +532,7 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
 
 		gViewerAssetStats->updateStats();
-		sd = gViewerAssetStatsMain->asLLSD(false);
+		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
 		sd = get_region(sd, region1_handle);
-- 
cgit v1.2.3


From 427490edb566edf18da0b879f9d30a04dda0e9e0 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 10 Jun 2013 22:43:29 -0600
Subject: possible fix and new debug code for SH-4241: viewer crash shortly
 after login in LLViewerRegion::addNewObject

---
 indra/newview/lldrawable.cpp     |  4 +++-
 indra/newview/llviewerregion.cpp | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 93fb484f06..598b0d2ff4 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -133,7 +133,9 @@ void LLDrawable::init(bool new_entry)
 			getRegion()->addVisibleCacheEntry(vo_entry); //to load all children.
 		}
 	
-		getRegion()->addActiveCacheEntry(vo_entry);		
+		getRegion()->addActiveCacheEntry(vo_entry);
+
+		llassert_always(!vo_entry->getGroup()); //not in the object cache octree.
 	}
 	
 	llassert(!vo_entry || vo_entry->getEntry() == mEntry);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 55137168ee..29528a1117 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -953,6 +953,8 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
+	
+	llassert_always(!entry->getParentID() && !entry->getEntry()->hasDrawable());
 
 	mImpl->mVOCachePartition->addEntry(entry->getEntry());
 }
@@ -993,6 +995,11 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 
 F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 {
+	if(mDead)
+	{
+		return max_time;
+	}
+
 	if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty())
 	{
 		return max_time;
@@ -1100,6 +1107,10 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 {
+	if(mDead)
+	{
+		return max_time;
+	}
 	if(mImpl->mWaitingList.empty())
 	{
 		return max_time;
@@ -1120,8 +1131,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 				break;
 			}
 		}
-	}
-	mImpl->mWaitingList.clear();
+	}	
 
 	return max_time - update_timer.getElapsedTimeF32();
 }
@@ -1156,6 +1166,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	max_update_time = updateVisibleEntries(max_update_time);
 	createVisibleObjects(max_update_time);
 
+	mImpl->mWaitingList.clear();
 	mImpl->mVisibleGroups.clear();
 
 	return did_update;
-- 
cgit v1.2.3


From db2abd49c3b41af612cbb6fed4c1626c37b4e14b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 12 Jun 2013 11:30:43 -0600
Subject: fix for SH-4244: interesting: objects on adjacent region are not
 visible.

---
 indra/newview/llvocache.cpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 5e2d2efc5e..1f3af78e77 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -417,9 +417,11 @@ public:
 
 	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
+#if 1
 		S32 res = AABBInRegionFrustumGroupBounds(group);
-		
-		//S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
+#else	
+		S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
+#endif
 		if (res != 0)
 		{
 			res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift));
@@ -429,9 +431,11 @@ public:
 
 	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
+#if 1
 		S32 res = AABBInRegionFrustumObjectBounds(group);
-
-		//S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
+#else
+		S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
+#endif
 		if (res != 0)
 		{
 			res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift));
-- 
cgit v1.2.3


From 9fd3af3c389ed491b515cbb5136b344b069913e4 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 13 Jun 2013 15:29:15 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 changed Units macros and argument order to make it more clear optimized units
 for integer types fixed merging of periodicrecordings...should eliminate
 duplicate entries in sceneloadmonitor history

---
 indra/newview/llappviewer.cpp        |   2 +-
 indra/newview/llappviewer.h          |   2 +-
 indra/newview/llfasttimerview.cpp    | 303 +++++++++++++++++++----------------
 indra/newview/llfasttimerview.h      |  77 ++++-----
 indra/newview/llscenemonitor.cpp     |   4 +-
 indra/newview/lltexturefetch.h       |   2 +-
 indra/newview/lltextureview.cpp      |  12 +-
 indra/newview/llviewerassetstats.cpp |   4 +-
 indra/newview/llviewerassetstats.h   |   2 +-
 indra/newview/llviewermessage.cpp    |  18 +--
 indra/newview/llviewerstats.cpp      |  10 +-
 indra/newview/llviewerstats.h        |   6 +-
 indra/newview/llviewertexture.cpp    |  16 +-
 indra/newview/llviewertexture.h      |  14 +-
 indra/newview/llviewerwindow.cpp     |   2 +-
 indra/newview/pipeline.cpp           |   2 +-
 16 files changed, 251 insertions(+), 225 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 42bf9b657b..ef24ba21ee 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -296,7 +296,7 @@ LLPumpIO* gServicePump = NULL;
 
 U64 gFrameTime = 0;
 F32 gFrameTimeSeconds = 0.f;
-LLUnit<LLUnits::Seconds, F32> gFrameIntervalSeconds = 0.f;
+LLUnit<F32, LLUnits::Seconds> gFrameIntervalSeconds = 0.f;
 F32 gFPSClamped = 10.f;						// Pretend we start at target rate.
 F32 gFrameDTClamped = 0.f;					// Time between adjacent checks to network for packets
 U64	gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 2e75de445f..ad662d8ea1 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -337,7 +337,7 @@ extern LLPumpIO* gServicePump;
 
 extern U64      gFrameTime;					// The timestamp of the most-recently-processed frame
 extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
-extern LLUnit<LLUnits::Seconds, F32>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
+extern LLUnit<F32, LLUnits::Seconds>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
 extern F32		gFPSClamped;				// Frames per second, smoothed, weighted toward last frame
 extern F32		gFrameDTClamped;
 extern U64		gStartTime;
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 40526d3357..8e061ec87c 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -101,21 +101,15 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mScrollIndex(0),
 	mHoverID(NULL),
 	mHoverBarIndex(-1),
-	mPrintStats(-1),
-	mRecording(&get_frame_recording()),
-	mPauseHistory(false)
+	mStatsIndex(-1),
+	mPauseHistory(false),
+	mRecording(512)
 {
-	mTimerBars = new std::vector<TimerBar>[MAX_VISIBLE_HISTORY + 1];
+	mTimerBarRows.resize(MAX_VISIBLE_HISTORY);
 }
 
 LLFastTimerView::~LLFastTimerView()
 {
-	if (mRecording != &get_frame_recording())
-	{
-		delete mRecording;
-	}
-	mRecording = NULL;
-	delete [] mTimerBars;
 }
 
 void LLFastTimerView::onPause()
@@ -130,16 +124,11 @@ void LLFastTimerView::setPauseState(bool pause_state)
 	// reset scroll to bottom when unpausing
 	if (!pause_state)
 	{
-		if (mRecording != &get_frame_recording())
-		{
-			delete mRecording;
-		}
-		mRecording = &get_frame_recording();
+		
 		getChild<LLButton>("pause_btn")->setLabel(getString("pause"));
 	}
 	else
 	{
-		mRecording = new PeriodicRecording(get_frame_recording());
 		mScrollIndex = 0;
 
 		getChild<LLButton>("pause_btn")->setLabel(getString("run"));
@@ -175,7 +164,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	{
 		S32 bar_idx = MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight());
 		bar_idx = llclamp(bar_idx, 0, MAX_VISIBLE_HISTORY);
-		mPrintStats = mScrollIndex + bar_idx;
+		mStatsIndex = mScrollIndex + bar_idx;
 		return TRUE;
 	}
 	return LLFloater::handleRightMouseDown(x, y, mask);
@@ -262,8 +251,8 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if (hasMouseCapture())
 	{
 		F32 lerp = llclamp(1.f - (F32) (x - mGraphRect.mLeft) / (F32) mGraphRect.getWidth(), 0.f, 1.f);
-		mScrollIndex = llround( lerp * (F32)(mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY));
-		mScrollIndex = llclamp(	mScrollIndex, 0, (S32)mRecording->getNumPeriods());
+		mScrollIndex = llround( lerp * (F32)(mRecording.getNumRecordedPeriods() - MAX_VISIBLE_HISTORY));
+		mScrollIndex = llclamp(	mScrollIndex, 0, (S32)mRecording.getNumRecordedPeriods());
 		return TRUE;
 	}
 	mHoverTimer = NULL;
@@ -272,7 +261,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	if(mPauseHistory && mBarRect.pointInRect(x, y))
 	{
 		mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1,
-								(S32)mRecording->getNumPeriods() - 1,
+								(S32)mRecording.getNumRecordedPeriods() - 1,
 								MAX_VISIBLE_HISTORY);
 		if (mHoverBarIndex == 0)
 		{
@@ -289,7 +278,8 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			++it, ++i)
 		{
 			// is mouse over bar for this timer?
-			if (mTimerBars[mHoverBarIndex][i].mVisibleRect.pointInRect(x, y))
+			TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1];
+			if (row.mBars[i].mVisibleRect.pointInRect(x, y - row.mBottom))
 			{
 				mHoverID = (*it);
 				if (mHoverTimer != *it)
@@ -301,7 +291,8 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 					mHoverTimer = (*it);
 				}
 
-				mToolTipRect = mTimerBars[mHoverBarIndex][i].mVisibleRect;
+				mToolTipRect = row.mBars[i].mVisibleRect;
+				mToolTipRect.translate(0, row.mBottom);
 			}
 
 			if ((*it)->getCollapsed())
@@ -329,11 +320,11 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco
 	if (history_index == 0)
 	{
 		// by default, show average number of call
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<F64, LLUnits::Milliseconds>(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount()));
 	}
 	else
 	{
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<LLUnits::Milliseconds, F64>(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<F64, LLUnits::Milliseconds>(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount()));
 	}
 	return tooltip;
 }
@@ -348,7 +339,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			LLRect screen_rect;
 			localRectToScreen(mToolTipRect, &screen_rect);
 
-			std::string tooltip = get_tooltip(*mHoverTimer, mHoverBarIndex > 0 ? mScrollIndex + mHoverBarIndex : 0, *mRecording);
+			std::string tooltip = get_tooltip(*mHoverTimer, mHoverBarIndex > 0 ? mScrollIndex + mHoverBarIndex : 0, mRecording);
 
 			LLToolTipMgr::instance().show(LLToolTip::Params()
 				.message(tooltip)
@@ -366,7 +357,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 			TimeBlock* idp = getLegendID(y);
 			if (idp)
 			{
-				LLToolTipMgr::instance().show(get_tooltip(*idp, 0, *mRecording));
+				LLToolTipMgr::instance().show(get_tooltip(*idp, 0, mRecording));
 
 				return TRUE;
 			}
@@ -381,7 +372,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	setPauseState(true);
 	mScrollIndex = llclamp(	mScrollIndex + clicks,
 							0,
-							llmin((S32)mRecording->getNumPeriods(), (S32)mRecording->getNumPeriods() - MAX_VISIBLE_HISTORY));
+							llmin((S32)mRecording.getNumRecordedPeriods(), (S32)mRecording.getNumRecordedPeriods() - MAX_VISIBLE_HISTORY));
 	return TRUE;
 }
 
@@ -389,12 +380,19 @@ static TimeBlock FTM_RENDER_TIMER("Timers", true);
 static const S32 MARGIN = 10;
 static const S32 LEGEND_WIDTH = 220;
 
-static std::map<TimeBlock*, LLColor4> sTimerColors;
+static std::vector<LLColor4> sTimerColors;
 
 void LLFastTimerView::draw()
 {
 	LLFastTimer t(FTM_RENDER_TIMER);
 	
+	if (!mPauseHistory)
+	{
+		mRecording.appendRecording(LLTrace::get_frame_recording().getLastRecording());
+		mTimerBarRows.pop_back();
+		mTimerBarRows.push_front(TimerBarRow());
+	}
+
 	generateUniqueColors();
 
 	// Draw the window background
@@ -417,11 +415,20 @@ void LLFastTimerView::draw()
 	printLineStats();
 	LLView::draw();
 		
-	mAllTimeMax = llmax(mAllTimeMax, mRecording->getLastRecording().getSum(FTM_FRAME));
+	mAllTimeMax = llmax(mAllTimeMax, mRecording.getLastRecording().getSum(FTM_FRAME));
 	mHoverID = NULL;
 	mHoverBarIndex = -1;
 }
 
+void LLFastTimerView::onOpen(const LLSD& key)
+{
+	if (mRecording.getNumRecordedPeriods() == 0)
+	{
+		mRecording.appendPeriodicRecording(LLTrace::get_frame_recording());
+	}
+}
+
+
 void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch)
 {
 	//read result back into raw image
@@ -828,7 +835,7 @@ void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target
 	LLSD current = analyzePerformanceLogDefault(target_is);
 	target_is.close();
 
-	//output comparision
+	//output comparison
 	std::ofstream os(output.c_str());
 
 	LLSD::Real session_time = current["SessionTime"].asReal();
@@ -936,7 +943,7 @@ void	LLFastTimerView::onClickCloseBtn()
 void LLFastTimerView::printLineStats()
 {
 	// Output stats for clicked bar to log
-	if (mPrintStats >= 0)
+	if (mStatsIndex >= 0)
 	{
 		std::string legend_stat;
 		bool first = true;
@@ -974,16 +981,16 @@ void LLFastTimerView::printLineStats()
 			}
 			first = false;
 
-			LLUnit<LLUnits::Seconds, F32> ticks;
-			if (mPrintStats > 0)
+			LLUnit<F32, LLUnits::Seconds> ticks;
+			if (mStatsIndex == 0)
 			{
-				ticks = mRecording->getPrevRecording(mPrintStats).getSum(*idp);
+				ticks = mRecording.getPeriodMean(*idp);
 			}
 			else
 			{
-				ticks = mRecording->getPeriodMean(*idp);
+				ticks = mRecording.getPrevRecording(mStatsIndex).getSum(*idp);
 			}
-			LLUnit<LLUnits::Milliseconds, F32> ms = ticks;
+			LLUnit<F32, LLUnits::Milliseconds> ms = ticks;
 
 			timer_stat += llformat("%.1f",ms.value());
 
@@ -993,7 +1000,7 @@ void LLFastTimerView::printLineStats()
 			}
 		}
 		llinfos << timer_stat << llendl;
-		mPrintStats = -1;
+		mStatsIndex = -1;
 	}
 }
 
@@ -1009,7 +1016,7 @@ void LLFastTimerView::drawLineGraph()
 	LLLocalClipRect clip(mGraphRect);
 
 	//normalize based on last frame's maximum
-	static LLUnit<LLUnits::Seconds, F32> max_time = 0.000001;
+	static LLUnit<F32, LLUnits::Seconds> max_time = 0.000001;
 	static U32 max_calls = 0;
 	static F32 alpha_interp = 0.f;
 
@@ -1020,7 +1027,7 @@ void LLFastTimerView::drawLineGraph()
 	else if (mDisplayHz)
 		axis_label = llformat("%d Hz", (int)(1.f / max_time.value()));
 	else
-		axis_label = llformat("%4.2f ms", LLUnit<LLUnits::Milliseconds, F32>(max_time).value());
+		axis_label = llformat("%4.2f ms", LLUnit<F32, LLUnits::Milliseconds>(max_time).value());
 
 	x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5;
 	y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
@@ -1030,10 +1037,10 @@ void LLFastTimerView::drawLineGraph()
 
 	//highlight visible range
 	{
-		S32 first_frame = mRecording->getNumPeriods() - mScrollIndex;
+		S32 first_frame = mRecording.getNumRecordedPeriods() - mScrollIndex;
 		S32 last_frame = first_frame - MAX_VISIBLE_HISTORY;
 
-		F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(mRecording->getNumPeriods()-1);
+		F32 frame_delta = ((F32) (mGraphRect.getWidth()))/(mRecording.getNumRecordedPeriods()-1);
 
 		F32 right = (F32) mGraphRect.mLeft + frame_delta*first_frame;
 		F32 left = (F32) mGraphRect.mLeft + frame_delta*last_frame;
@@ -1055,7 +1062,7 @@ void LLFastTimerView::drawLineGraph()
 		}
 	}
 
-	LLUnit<LLUnits::Seconds, F32> cur_max = 0;
+	LLUnit<F32, LLUnits::Seconds> cur_max = 0;
 	U32 cur_max_calls = 0;
 	for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 		it != end_timer_tree();
@@ -1070,7 +1077,7 @@ void LLFastTimerView::drawLineGraph()
 			glLineWidth(3);
 		}
 
-		const F32 * col = sTimerColors[idp].mV;// ft_display_table[idx].color->mV;
+		const F32 * col = sTimerColors[idp->getIndex()].mV;// ft_display_table[idx].color->mV;
 
 		F32 alpha = 1.f;
 
@@ -1085,12 +1092,13 @@ void LLFastTimerView::drawLineGraph()
 
 		gGL.color4f(col[0], col[1], col[2], alpha);				
 		gGL.begin(LLRender::TRIANGLE_STRIP);
-		for (U32 j = mRecording->getNumPeriods();
+		for (U32 j = mRecording.getNumRecordedPeriods();
 			j > 0;
 			j--)
 		{
-			LLUnit<LLUnits::Seconds, F32> time = llmax(mRecording->getPrevRecording(j).getSum(*idp), LLUnit<LLUnits::Seconds, F64>(0.000001));
-			U32 calls = mRecording->getPrevRecording(j).getSum(idp->callCount());
+			LLTrace::Recording& recording = mRecording.getPrevRecording(j);
+			LLUnit<F32, LLUnits::Seconds> time = llmax(recording.getSum(*idp), LLUnit<F64, LLUnits::Seconds>(0.000001));
+			U32 calls = recording.getSum(idp->callCount());
 
 			if (alpha == 1.f)
 			{ 
@@ -1098,7 +1106,7 @@ void LLFastTimerView::drawLineGraph()
 				cur_max = llmax(cur_max, time);
 				cur_max_calls = llmax(cur_max_calls, calls);
 			}
-			F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording->getNumPeriods()-1);
+			F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording.getNumRecordedPeriods()-1);
 			F32 y = mDisplayHz 
 				? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
 				: mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight();
@@ -1124,7 +1132,7 @@ void LLFastTimerView::drawLineGraph()
 	max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f));
 	if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
 	{
-		max_time = llmax(LLUnit<LLUnits::Microseconds, F32>(1), LLUnit<LLUnits::Microseconds, F32>(cur_max));
+		max_time = llmax(LLUnit<F32, LLUnits::Microseconds>(1), LLUnit<F32, LLUnits::Microseconds>(cur_max));
 	}
 
 	max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f)));
@@ -1183,20 +1191,20 @@ void LLFastTimerView::drawLegend( S32 y )
 				scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f);
 			}
 			bar_rect.stretch(scale_offset);
-			gl_rect_2d(bar_rect, sTimerColors[idp]);
+			gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]);
 
-			LLUnit<LLUnits::Milliseconds, F32> ms = 0;
+			LLUnit<F32, LLUnits::Milliseconds> ms = 0;
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
 				S32 hidx = mScrollIndex + mHoverBarIndex;
-				ms = mRecording->getPrevRecording(hidx).getSum(*idp);
-				calls = mRecording->getPrevRecording(hidx).getSum(idp->callCount());
+				ms = mRecording.getPrevRecording(hidx).getSum(*idp);
+				calls = mRecording.getPrevRecording(hidx).getSum(idp->callCount());
 			}
 			else
 			{
-				ms = LLUnit<LLUnits::Seconds, F64>(mRecording->getPeriodMean(*idp));
-				calls = (S32)mRecording->getPeriodMean(idp->callCount());
+				ms = LLUnit<F64, LLUnits::Seconds>(mRecording.getPeriodMean(*idp));
+				calls = (S32)mRecording.getPeriodMean(idp->callCount());
 			}
 
 			std::string timer_label;
@@ -1254,7 +1262,8 @@ void LLFastTimerView::generateUniqueColors()
 {
 	// generate unique colors
 	{
-		sTimerColors[&FTM_FRAME] = LLColor4::grey;
+		sTimerColors.reserve(LLTrace::TimeBlock::getNumIndices());
+		sTimerColors[FTM_FRAME.getIndex()] = LLColor4::grey;
 
 		F32 hue = 0.f;
 
@@ -1274,7 +1283,7 @@ void LLFastTimerView::generateUniqueColors()
 			LLColor4 child_color;
 			child_color.setHSL(hue, saturation, lightness);
 
-			sTimerColors[idp] = child_color;
+			sTimerColors[idp->getIndex()] = child_color;
 		}
 	}
 }
@@ -1315,7 +1324,7 @@ void LLFastTimerView::drawTicks()
 {
 	// Draw MS ticks
 	{
-		LLUnit<LLUnits::Milliseconds, U32> ms = mTotalTimeDisplay;
+		LLUnit<U32, LLUnits::Milliseconds> ms = mTotalTimeDisplay;
 		std::string tick_label;
 		S32 x;
 		S32 barw = mBarRect.getWidth();
@@ -1382,127 +1391,127 @@ void LLFastTimerView::updateTotalTime()
 	switch(mDisplayMode)
 	{
 	case 0:
-		mTotalTimeDisplay = mRecording->getPeriodMean(FTM_FRAME)*2;
+		mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME)*2;
 		break;
 	case 1:
 		mTotalTimeDisplay = mAllTimeMax;
 		break;
 	case 2:
 		// Calculate the max total ticks for the current history
-		mTotalTimeDisplay = mRecording->getPeriodMax(FTM_FRAME);
+		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME);
 		break;
 	default:
-		mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F32>(100);
+		mTotalTimeDisplay = LLUnit<F32, LLUnits::Milliseconds>(100);
 		break;
 	}
 
-	mTotalTimeDisplay = LLUnit<LLUnits::Milliseconds, F32>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds>().value() / 20.f) * 20.f);
+	mTotalTimeDisplay = LLUnit<F32, LLUnits::Milliseconds>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds>().value() / 20.f) * 20.f);
 }
 
 void LLFastTimerView::drawBars()
 {
-	updateTotalTime();
-	if (mTotalTimeDisplay <= 0.0) return;
-
 	LLLocalClipRect clip(mBarRect);
 
 	S32 bar_height = mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2);
-	S32 vpad = llmax(1, bar_height / 4); // spacing between bars
+	const S32 vpad = llmax(1, bar_height / 4); // spacing between bars
 	bar_height -= vpad;
 
+	updateTotalTime();
+	if (mTotalTimeDisplay <= 0.0) return;
+
 	drawTicks();
-	S32 y = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
-	drawBorders(y, mBarRect.mLeft, bar_height, vpad);
+	const S32 bars_top = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
+	drawBorders(bars_top, mBarRect.mLeft, bar_height, vpad);
 
 	// Draw bars for each history entry
-	// Special: -1 = show running average
+	// Special: 0 = show running average
 	LLPointer<LLUIImage> bar_image = LLUI::getUIImage("Rounded_Square");
+
+	const S32 image_width = bar_image->getTextureWidth();
+	const S32 image_height = bar_image->getTextureHeight();
+
 	gGL.getTexUnit(0)->bind(bar_image->getImage());
-	const S32 histmax = llmin((S32)mRecording->getNumPeriods(), MAX_VISIBLE_HISTORY) + 1;
+	{	
+		const S32 histmax = llmin((S32)mRecording.getNumRecordedPeriods(), MAX_VISIBLE_HISTORY);
 
-	for (S32 bar_index = 0; bar_index < histmax && y > LINE_GRAPH_HEIGHT; bar_index++)
-	{
-		S32 history_index = (bar_index > 0)
-			? bar_index + mScrollIndex
-			: -1;
-		mTimerBars[bar_index].clear();
-		mTimerBars[bar_index].reserve(LLInstanceTracker<LLTrace::TimeBlock>::instanceCount());
-
-		updateTimerBarWidths(&FTM_FRAME, mTimerBars[bar_index], history_index, true);
-		LLRect frame_bar_rect(mBarRect.mLeft, y, mBarRect.mLeft + mTimerBars[bar_index][0].mWidth, y-bar_height);
-		mTimerBars[bar_index][0].mVisibleRect = frame_bar_rect;
-		updateTimerBarFractions(&FTM_FRAME, 0, mTimerBars[bar_index]);
-		drawBar(&FTM_FRAME, frame_bar_rect, mTimerBars[bar_index], 0, bar_image);
-				
-		y -= (bar_height + vpad);
-		if (bar_index == 0)
-			y -= bar_height;
-	}
+		llassert(mTimerBarRows.size() >= histmax);
+
+		// update widths
+		updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1);
+		mAverageTimerRow.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, -bar_height);
+		updateTimerBarFractions(&FTM_FRAME, mAverageTimerRow);
+
+		for (S32 history_index = 0; history_index < histmax; history_index++)
+		{
+			TimerBarRow& row = mTimerBarRows[history_index];
+			if (row.mBars.empty())
+			{
+				row.mBars.reserve(LLInstanceTracker<LLTrace::TimeBlock>::instanceCount());
+				updateTimerBarWidths(&FTM_FRAME, row, history_index);
+				row.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + row.mBars[0].mWidth, -1);
+				updateTimerBarFractions(&FTM_FRAME, row);
+			}
+		}
+
+		// draw bars
+		LLRect frame_bar_rect(	mBarRect.mLeft, 
+								bars_top, 
+								mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, 
+								bars_top - bar_height);
+		mAverageTimerRow.mBottom = frame_bar_rect.mBottom;
+		drawBar(&FTM_FRAME, frame_bar_rect, mAverageTimerRow, image_width, image_height, false);
+		frame_bar_rect.translate(0, -(bar_height + vpad + bar_height));
+
+		for(S32 bar_index = mScrollIndex; bar_index < llmin(histmax, mScrollIndex + MAX_VISIBLE_HISTORY); ++bar_index)
+		{
+			TimerBarRow& row = mTimerBarRows[bar_index];
+			row.mBottom = frame_bar_rect.mBottom;
+			drawBar(&FTM_FRAME, frame_bar_rect, row, image_width, image_height, false);
+
+			frame_bar_rect.translate(0, -(bar_height + vpad));
+		}
+
+	}	
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 }
 
 static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
-S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index, bool visible)
+S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible)
 {
+	std::vector<TimerBar>& bars = row.mBars;
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
-	F32 self_time_frame_fraction = history_index == -1
-		? (mRecording->getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) 
-		: (mRecording->getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
+	const F32 self_time_frame_fraction = history_index == -1
+										? (mRecording.getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) 
+										: (mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
 
-	S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth());
+	const S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth());
 	S32 full_width = self_time_width;
 
-	bool children_visible = visible;
-
 	// reserve a spot for this bar to be rendered before its children
 	// even though we don't know its size yet
-	S32 bar_rect_index = bars.size();
-	if (visible)
-	{
-		bars.push_back(TimerBar());
-	}
+	bars.push_back(TimerBar());
+	TimerBar& timer_bar = bars.back();
 
-	if (time_block->getCollapsed())
-	{
-		children_visible = false;
-	}
+	const bool children_visible = visible && !time_block->getCollapsed();
 	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
 	{
-		full_width += updateTimerBarWidths(*it, bars, history_index, children_visible);
+		full_width += updateTimerBarWidths(*it, row, history_index, children_visible);
 	}
 
-	if (visible)
-	{
-		TimerBar& timer_bar = bars[bar_rect_index];
-
-		timer_bar.mWidth = full_width;
-		timer_bar.mSelfWidth = self_time_width;
-		timer_bar.mColor = sTimerColors[time_block];
-
-		BOOL is_child_of_hover_item = (time_block == mHoverID);
-		TimeBlock* next_parent = time_block->getParent();
-		while(!is_child_of_hover_item && next_parent)
-		{
-			is_child_of_hover_item = (mHoverID == next_parent);
-			if (next_parent->getParent() == next_parent) break;
-			next_parent = next_parent->getParent();
-		}
-
-		if (mHoverID != NULL 
-			&& time_block != mHoverID 
-			&& !is_child_of_hover_item)
-		{
-			timer_bar.mColor = lerp(timer_bar.mColor, LLColor4::grey, 0.8f);
-		}
-	}
+	timer_bar.mWidth     = full_width;
+	timer_bar.mSelfWidth = self_time_width;
+	timer_bar.mTimeBlock = time_block;
+	timer_bar.mVisible   = visible;
+	
 	return full_width;
 }
 
 static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions");
 
-S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars)
+S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index)
 {
+	std::vector<TimerBar>& bars = row.mBars;
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS);
 	TimerBar& timer_bar = bars[timer_bar_index];
 	S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth;
@@ -1518,11 +1527,6 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32
 	}
 	children_rect.mRight = children_rect.mLeft + timer_bar.mWidth - timer_bar.mSelfWidth;
 
-	if (children_rect.getHeight() > MIN_BAR_HEIGHT)
-	{
-		children_rect.mTop -= 1;
-		children_rect.mBottom += 1;
-	}
 	timer_bar.mChildrenRect = children_rect;
 
 	//now loop through children and figure out portion of bar image covered by each bar, now that we know the
@@ -1548,7 +1552,7 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32
 				children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), 
 				children_rect.mBottom);
 
-			timer_bar_index = updateTimerBarFractions(child_time_block, timer_bar_index, bars);
+			timer_bar_index = updateTimerBarFractions(child_time_block, row, timer_bar_index);
 
 			bar_fraction_start = child_timer_bar.mEndFraction;
 		}
@@ -1556,25 +1560,29 @@ S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32
 	return timer_bar_index;
 }
 
-S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 bar_index, LLPointer<LLUIImage>& bar_image)
+S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index)
 {
-	TimerBar& timer_bar = bars[bar_index];
+	TimerBar& timer_bar = row.mBars[bar_index];
+
+	hovered |= mHoverID == time_block;
 
 	// animate scale of bar when hovering over that particular timer
 	if (bar_rect.getWidth() > 0)
 	{
 		LLRect render_rect(bar_rect);
 		S32 scale_offset = 0;
-		if (time_block == mHoverID)
+		if (mHoverID == time_block)
 		{
 			scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 3.f);
 			render_rect.mTop += scale_offset;
 			render_rect.mBottom -= scale_offset;
 		}
 
-		gGL.color4fv(timer_bar.mColor.mV);
+		LLColor4 color = sTimerColors[time_block->getIndex()];
+		if (!hovered) color = lerp(color, LLColor4::grey, 0.8f);
+		gGL.color4fv(color.mV);
 		gl_segmented_rect_2d_fragment_tex(render_rect,
-			bar_image->getTextureWidth(), bar_image->getTextureHeight(), 
+			image_width, image_height, 
 			16, 
 			timer_bar.mStartFraction, timer_bar.mEndFraction);
 	}
@@ -1584,7 +1592,20 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, st
 		for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
 		{
 			++bar_index;
-			bar_index = drawBar(*it, timer_bar.mChildrenRect, bars, bar_index, bar_image);
+			LLRect children_rect = timer_bar.mChildrenRect;
+			children_rect.translate(0, row.mBottom);
+			if (bar_rect.getHeight() > MIN_BAR_HEIGHT)
+			{
+				// shrink as we go down a level
+				children_rect.mTop = bar_rect.mTop - 1;
+				children_rect.mBottom = bar_rect.mBottom + 1;
+			}
+			else
+			{
+				children_rect.mTop = bar_rect.mTop;
+				children_rect.mBottom = bar_rect.mBottom;
+			}
+			bar_index = drawBar(*it, children_rect, row, image_width, image_height, hovered, bar_index);
 		}
 	}
 
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 341adacd65..c20cadd6d7 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -31,6 +31,7 @@
 #include "llfasttimer.h"
 #include "llunit.h"
 #include "lltracerecording.h"
+#include <deque>
 
 class LLFastTimerView : public LLFloater
 {
@@ -60,13 +61,11 @@ public:
 	virtual BOOL handleToolTip(S32 x, S32 y, MASK mask);
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
-
+	virtual void onOpen(const LLSD& key);
 	LLTrace::TimeBlock* getLegendID(S32 y);
 
-protected:
-	virtual	void	onClickCloseBtn();
-
 private:	
+	virtual	void	onClickCloseBtn();
 	void drawTicks();
 	void drawLineGraph();
 	void drawLegend(S32 y);
@@ -87,47 +86,53 @@ private:
 			mStartFraction(0.f),
 			mEndFraction(1.f)
 		{}
-		S32			mWidth;
-		S32			mSelfWidth;
-		LLRect		mVisibleRect,
-					mChildrenRect;
-		LLColor4	mColor;
-		bool		mVisible;
-		F32			mStartFraction,
-					mEndFraction;
+		S32					mWidth;
+		S32					mSelfWidth;
+		LLRect				mVisibleRect,
+							mChildrenRect;
+		LLTrace::TimeBlock* mTimeBlock;
+		bool				mVisible;
+		F32					mStartFraction,
+							mEndFraction;
 	};
-	S32 updateTimerBarWidths(LLTrace::TimeBlock* time_block, std::vector<TimerBar>& bars, S32 history_index, bool visible);
-	S32 updateTimerBarFractions(LLTrace::TimeBlock* time_block, S32 timer_bar_index, std::vector<TimerBar>& bars);
-	S32 drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, std::vector<TimerBar>& bars, S32 bar_index, LLPointer<LLUIImage>& bar_image);
+
+	struct TimerBarRow
+	{
+		S32						mBottom;
+		std::vector<TimerBar>	mBars;
+	};
+
+	S32 updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible = true);
+	S32 updateTimerBarFractions(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
+	S32 drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index = 0);
 	void setPauseState(bool pause_state);
 
-	std::vector<TimerBar>* mTimerBars;
-	S32 mDisplayMode;
+	std::deque<TimerBarRow> mTimerBarRows;
+	TimerBarRow				mAverageTimerRow;
 
-	typedef enum child_alignment
+	enum ChildAlignment
 	{
 		ALIGN_LEFT,
 		ALIGN_CENTER,
 		ALIGN_RIGHT,
 		ALIGN_COUNT
-	} ChildAlignment;
-
-	ChildAlignment mDisplayCenter;
-	bool                          mDisplayCalls,
-								  mDisplayHz;
-	LLUnit<LLUnits::Seconds, F64> mAllTimeMax,
-								  mTotalTimeDisplay;
-	LLRect mBarRect;
-	S32	mScrollIndex;
-	LLTrace::TimeBlock*           mHoverID;
-	LLTrace::TimeBlock*           mHoverTimer;
-	LLRect					mToolTipRect;
-	S32 mHoverBarIndex;
-	LLFrameTimer mHighlightTimer;
-	S32 mPrintStats;
-	LLRect mGraphRect;
-	LLTrace::PeriodicRecording*	  mRecording;
-	bool						  mPauseHistory;
+	}								mDisplayCenter;
+	bool							mDisplayCalls,
+									mDisplayHz,
+									mPauseHistory;
+	LLUnit<F64, LLUnits::Seconds>	mAllTimeMax,
+									mTotalTimeDisplay;
+	S32								mScrollIndex,
+									mHoverBarIndex,
+									mStatsIndex;
+	S32								mDisplayMode;
+	LLTrace::TimeBlock*				mHoverID;
+	LLTrace::TimeBlock*				mHoverTimer;
+	LLRect							mToolTipRect,
+									mGraphRect,
+									mBarRect;
+	LLFrameTimer					mHighlightTimer;
+	LLTrace::PeriodicRecording		mRecording;
 };
 
 #endif
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index dccf8a2a17..3d9e0ab4c3 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -503,9 +503,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	os << std::setprecision(3);
 
 	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording();
-	const U32 frame_count = scene_load_recording.getNumPeriods();
+	const U32 frame_count = scene_load_recording.getNumRecordedPeriods();
 
-	LLUnit<LLUnits::Seconds, F64> frame_time;
+	LLUnit<F64, LLUnits::Seconds> frame_time;
 
 	os << "Stat";
 	for (S32 frame = 0; frame < frame_count; frame++)
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 2530beb722..7fc58e230c 100755
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -330,7 +330,7 @@ private:
 	LLTextureInfo mTextureInfo;
 
 	// XXX possible delete
-	LLUnit<LLUnits::Bits, U32> mHTTPTextureBits;												// Mfnq
+	LLUnit<U32, LLUnits::Bits> mHTTPTextureBits;												// Mfnq
 
 	// XXX possible delete
 	//debug use
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index c9ec5d9bf6..766b66efa0 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -507,17 +507,17 @@ private:
 
 void LLGLTexMemBar::draw()
 {
-	LLUnit<LLUnits::Mibibytes, S32> bound_mem = LLViewerTexture::sBoundTextureMemory;
- 	LLUnit<LLUnits::Mibibytes, S32> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
-	LLUnit<LLUnits::Mibibytes, S32> total_mem = LLViewerTexture::sTotalTextureMemory;
-	LLUnit<LLUnits::Mibibytes, S32> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
+	LLUnit<S32, LLUnits::Mibibytes> bound_mem = LLViewerTexture::sBoundTextureMemory;
+ 	LLUnit<S32, LLUnits::Mibibytes> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
+	LLUnit<S32, LLUnits::Mibibytes> total_mem = LLViewerTexture::sTotalTextureMemory;
+	LLUnit<S32, LLUnits::Mibibytes> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;
 	F32 cache_usage = (F32)LLTrace::Mibibytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
 	F32 cache_max_usage = (F32)LLTrace::Mibibytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
-	LLUnit<LLUnits::Bytes, F32> total_texture_downloaded = gTotalTextureData;
-	LLUnit<LLUnits::Bytes, F32> total_object_downloaded = gTotalObjectData;
+	LLUnit<F32, LLUnits::Bytes> total_texture_downloaded = gTotalTextureData;
+	LLUnit<F32, LLUnits::Bytes> total_object_downloaded = gTotalObjectData;
 	U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests() ;
 	U32 total_active_cached_objects = LLWorld::getInstance()->getNumOfActiveCachedObjects();
 	U32 total_objects = gObjectList.getNumObjects();
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 3a6ee636d4..dc4c9fe4ad 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -486,10 +486,10 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 		grid_from_region_handle(it->first, &grid_x, &grid_y);
 		r.grid_x(grid_x);
 		r.grid_y(grid_y);
-		r.duration(LLUnit<LLUnits::Microseconds, F64>(rec.getDuration()).value());
+		r.duration(LLUnit<F64, LLUnits::Microseconds>(rec.getDuration()).value());
 	}
 
-	stats.duration(mCurRecording ? LLUnit<LLUnits::Microseconds, F64>(mCurRecording->getDuration()).value() : 0.0);
+	stats.duration(mCurRecording ? LLUnit<F64, LLUnits::Microseconds>(mCurRecording->getDuration()).value() : 0.0);
 }
 
 LLSD LLViewerAssetStats::asLLSD(bool compact_output)
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 1a8770f8a7..e03b7c53a6 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -83,7 +83,7 @@ public:
 	 * for compatibility with the pre-existing timestamp on the texture
 	 * fetcher class, LLTextureFetch.
 	 */
-	typedef LLUnit<LLUnits::Microseconds, U64> duration_t;
+	typedef LLUnit<U64, LLUnits::Microseconds> duration_t;
 
 	/**
 	 * Type for the region identifier used in stats.  Currently uses
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index f2a3ffc3dc..0309acdad2 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4480,18 +4480,18 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 
 // *TODO: Remove this dependency, or figure out a better way to handle
 // this hack.
-extern LLUnit<LLUnits::Bits, U32> gObjectData;
+extern LLUnit<U32, LLUnits::Bits> gObjectData;
 
 void process_object_update(LLMessageSystem *mesgsys, void **user_data)
 {	
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4503,11 +4503,11 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4519,11 +4519,11 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data)
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4535,11 +4535,11 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 {
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<LLUnits::Bytes, U32>)mesgsys->getReceiveSize();
+		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
 	}
 
 	gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index be477f7f9a..7ddee48b38 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -290,13 +290,13 @@ F32		gAveLandCompression = 0.f,
 		gWorstLandCompression = 0.f, 
 		gWorstWaterCompression = 0.f;
 
-LLUnit<LLUnits::Bytes, U32>		gTotalWorldData = 0, 
+LLUnit<U32, LLUnits::Bytes>		gTotalWorldData = 0, 
 						gTotalObjectData = 0, 
 						gTotalTextureData = 0;
 U32						gSimPingCount = 0;
-LLUnit<LLUnits::Bits, U32>		gObjectData = 0;
+LLUnit<U32, LLUnits::Bits>		gObjectData = 0;
 F32		gAvgSimPing = 0.f;
-LLUnit<LLUnits::Bytes, U32>		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
+LLUnit<U32, LLUnits::Bytes>		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
 
 extern U32  gVisCompared;
 extern U32  gVisTested;
@@ -334,8 +334,8 @@ void update_statistics()
 
 	typedef LLInstanceTracker<LLTrace::TraceType<LLTrace::TimeBlockAccumulator>, std::string> trace_type_t;
 
-	LLUnit<LLUnits::Seconds, F64> idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
-	LLUnit<LLUnits::Seconds, F64> network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
+	LLUnit<F64, LLUnits::Seconds> idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
+	LLUnit<F64, LLUnits::Seconds> network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
 
 	record(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Frame")));
 	record(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs);
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index bfba7bca9a..4e48a61264 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -331,7 +331,7 @@ void update_statistics();
 void send_stats();
 
 extern LLFrameTimer gTextureTimer;
-extern LLUnit<LLUnits::Bytes, U32>	gTotalTextureData;
-extern LLUnit<LLUnits::Bytes, U32>  gTotalObjectData;
-extern LLUnit<LLUnits::Bytes, U32>  gTotalTextureBytesPerBoostLevel[] ;
+extern LLUnit<U32, LLUnits::Bytes>	gTotalTextureData;
+extern LLUnit<U32, LLUnits::Bytes>  gTotalObjectData;
+extern LLUnit<U32, LLUnits::Bytes>  gTotalTextureBytesPerBoostLevel[] ;
 #endif // LL_LLVIEWERSTATS_H
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index e0a88bfad6..f468df0674 100755
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -66,8 +66,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 // extern
-const LLUnit<LLUnits::Mibibytes, S32> gMinVideoRam = 32;
-const LLUnit<LLUnits::Mibibytes, S32> gMaxVideoRam = 512;
+const LLUnit<S32, LLUnits::Mibibytes> gMinVideoRam = 32;
+const LLUnit<S32, LLUnits::Mibibytes> gMaxVideoRam = 512;
 
 
 // statics
@@ -88,11 +88,11 @@ S32 LLViewerTexture::sAuxCount = 0;
 LLFrameTimer LLViewerTexture::sEvaluationTimer;
 F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
 F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
-LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sBoundTextureMemory = 0;
-LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sTotalTextureMemory = 0;
-LLUnit<LLUnits::Mibibytes, S32> LLViewerTexture::sMaxBoundTextureMem = 0;
-LLUnit<LLUnits::Mibibytes, S32> LLViewerTexture::sMaxTotalTextureMem = 0;
-LLUnit<LLUnits::Bytes, S32> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
+LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sBoundTextureMemory = 0;
+LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sTotalTextureMemory = 0;
+LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxBoundTextureMem = 0;
+LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxTotalTextureMem = 0;
+LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
 S8  LLViewerTexture::sCameraMovingDiscardBias = 0 ;
 F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
 S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
@@ -542,7 +542,7 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{
 		//when texture memory overflows, lower down the threshold to release the textures more aggressively.
-		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<LLUnits::Bytes, S32>(gMaxVideoRam));
+		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<S32, LLUnits::Bytes>(gMaxVideoRam));
 	
 		// If we are using more texture memory than we should,
 		// scale up the desired discard level
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index e939731cf2..529b812f41 100755
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -39,8 +39,8 @@
 #include <map>
 #include <list>
 
-extern const LLUnit<LLUnits::Mibibytes, S32> gMinVideoRam;
-extern const LLUnit<LLUnits::Mibibytes, S32> gMaxVideoRam;
+extern const LLUnit<S32, LLUnits::Mibibytes> gMinVideoRam;
+extern const LLUnit<S32, LLUnits::Mibibytes> gMaxVideoRam;
 
 class LLFace;
 class LLImageGL ;
@@ -205,11 +205,11 @@ public:
 	static LLFrameTimer sEvaluationTimer;
 	static F32 sDesiredDiscardBias;
 	static F32 sDesiredDiscardScale;
-	static LLUnit<LLUnits::Bytes, S32> sBoundTextureMemory;
-	static LLUnit<LLUnits::Bytes, S32> sTotalTextureMemory;
-	static LLUnit<LLUnits::Mibibytes, S32> sMaxBoundTextureMem;
-	static LLUnit<LLUnits::Mibibytes, S32> sMaxTotalTextureMem;
-	static LLUnit<LLUnits::Bytes, S32> sMaxDesiredTextureMem ;
+	static LLUnit<S32, LLUnits::Bytes> sBoundTextureMemory;
+	static LLUnit<S32, LLUnits::Bytes> sTotalTextureMemory;
+	static LLUnit<S32, LLUnits::Mibibytes> sMaxBoundTextureMem;
+	static LLUnit<S32, LLUnits::Mibibytes> sMaxTotalTextureMem;
+	static LLUnit<S32, LLUnits::Bytes> sMaxDesiredTextureMem ;
 	static S8  sCameraMovingDiscardBias;
 	static F32 sCameraMovingBias;
 	static S32 sMaxSculptRez ;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 349849a267..97f7baa98d 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -738,7 +738,7 @@ public:
 			{
 				if(gTotalTextureBytesPerBoostLevel[i] > 0)
 				{
-					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit<LLUnits::Mibibytes, F32>(gTotalTextureBytesPerBoostLevel[i]).value()));
+					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit<F32, LLUnits::Mibibytes>(gTotalTextureBytesPerBoostLevel[i]).value()));
 					ypos += y_inc;
 				}
 			}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index dd5c153d55..7cf30e1661 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2792,7 +2792,7 @@ void LLPipeline::updateGeom(F32 max_dtime)
 		
 	S32 count = 0;
 	
-	max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnitImplicit<LLUnits::Seconds, F32>(max_dtime));
+	max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, LLUnitImplicit<F32, LLUnits::Seconds>(max_dtime));
 	LLSpatialGroup* last_group = NULL;
 	LLSpatialBridge* last_bridge = NULL;
 
-- 
cgit v1.2.3


From fc88265cffe3553803314c6e895a1e3a3c988171 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 13 Jun 2013 18:47:51 -0600
Subject: fix for SH-4241: viewer crash shortly after login in
 LLViewerRegion::addNewObject and SH-4261: interesting: crash in
 LLViewerRegion::addToVOCacheTree

---
 indra/newview/lldrawable.cpp         |  2 +-
 indra/newview/llviewerobjectlist.cpp |  3 +-
 indra/newview/llviewerregion.cpp     | 90 +++++++++++++++++++++++++-----------
 indra/newview/llviewerregion.h       |  2 +-
 indra/newview/llvocache.cpp          |  3 +-
 5 files changed, 69 insertions(+), 31 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 598b0d2ff4..22a7c350d6 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -135,7 +135,7 @@ void LLDrawable::init(bool new_entry)
 	
 		getRegion()->addActiveCacheEntry(vo_entry);
 
-		llassert_always(!vo_entry->getGroup()); //not in the object cache octree.
+		llassert(!vo_entry->getGroup()); //not in the object cache octree.
 	}
 	
 	llassert(!vo_entry || vo_entry->getEntry() == mEntry);
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 83ebfc2ec3..ea004560d2 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -340,7 +340,8 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 		}
 		else
 		{
-			return objectp; //already loaded.
+			//should fall through if already loaded because may need to update the object.
+			//return objectp; //already loaded.
 		}
 	}
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 29528a1117..a2fd440895 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -797,21 +797,25 @@ void LLViewerRegion::dirtyHeights()
 	}
 }
 
-void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry)
+void LLViewerRegion::replaceVisibleCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry)
 {
-	U32 state = LLVOCacheEntry::INACTIVE;
-	bool in_vo_tree = false;
-
-	if(old_entry)
-	{
-		old_entry->moveTo(new_entry);
-		state = old_entry->getState();
-		in_vo_tree = (state == LLVOCacheEntry::INACTIVE && old_entry->getGroup() != NULL);
-		killCacheEntry(old_entry);
-	}
-
-	mImpl->mCacheMap[new_entry->getLocalID()] = new_entry;
+	//save old entry
+	old_entry->moveTo(new_entry);
+	U32 state = old_entry->getState();
+	U32 old_parent_id = old_entry->getParentID();
 
+	//kill old entry
+	killCacheEntry(old_entry);
+	
+	//parse new entry
+	U32	new_parent_id = 0;
+	LLViewerObject::unpackParentID(new_entry->getDP(), new_parent_id);
+	
+	//store new entry
+	mImpl->mCacheMap[new_entry->getLocalID()] = new_entry;	
+	
+	//process entry state
+	new_entry->setState(state);
 	if(state == LLVOCacheEntry::ACTIVE)
 	{
 		llassert(new_entry->getEntry()->hasDrawable());
@@ -821,11 +825,16 @@ void LLViewerRegion::replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry
 	{
 		mImpl->mWaitingSet.insert(new_entry);
 	}
-	else if(!old_entry || in_vo_tree)
+	
+	//process parent info
+	if(!old_parent_id && new_parent_id > 0) //becomes a child
 	{
-		addToVOCacheTree(new_entry);
+		new_entry->clearChildrenList();
 	}
-	new_entry->setState(state);
+	new_entry->setParentID(new_parent_id);
+
+	//update the object
+	gObjectList.processObjectUpdateFromCache(new_entry, this);
 }
 
 //physically delete the cache entry
@@ -901,14 +910,17 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 		return;
 	}
 
-	if(drawablep->getParent()) //child object
+	if(entry->getParentID() > 0) //is a child
 	{
-		LLViewerOctreeEntry* parent_oct_entry = drawablep->getParent()->getEntry();
-		if(parent_oct_entry && parent_oct_entry->hasVOCacheEntry())
+		LLVOCacheEntry* parent = getCacheEntry(entry->getParentID());
+		if(parent)
 		{
-			LLVOCacheEntry* parent = (LLVOCacheEntry*)parent_oct_entry->getVOCacheEntry();
 			parent->addChild(entry);
 		}
+		else //parent is not in the cache, put into the orphan list.
+		{
+			mOrphanMap[entry->getParentID()].push_back(entry->getLocalID());
+		}
 	}
 	else //insert to vo cache tree.
 	{
@@ -953,8 +965,12 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
-	
-	llassert_always(!entry->getParentID() && !entry->getEntry()->hasDrawable());
+	if(entry->getParentID() > 0)
+	{
+		return; //no child prim in cache octree.
+	}
+
+	llassert(!entry->getEntry()->hasDrawable());
 
 	mImpl->mVOCachePartition->addEntry(entry->getEntry());
 }
@@ -1264,7 +1280,12 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry)
 	}
 	else
 	{
-		llerrs << "Object is already created." << llendl;
+		//should not hit here any more, but does not hurt either, just put it back to active list
+		addActiveCacheEntry(entry);
+
+		//object is already created, crash here for debug use.
+		llwarns << "Object is already created." << llendl;
+		llassert(!entry->getEntry()->hasDrawable());
 	}
 	return obj;
 }
@@ -1774,6 +1795,23 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 	if(entry != NULL && !entry->getEntry())
 	{
 		entry->setOctreeEntry(NULL);
+		
+		if(entry->getEntry()->hasDrawable()) //already in the rendering pipeline
+		{
+			addActiveCacheEntry(entry);
+		
+			//set parent id
+			U32	parent_id = 0;
+			LLViewerObject::unpackParentID(entry->getDP(), parent_id);
+			if(parent_id > 0)
+			{
+				entry->setParentID(parent_id);
+			}
+
+			//update the object
+			gObjectList.processObjectUpdateFromCache(entry, this);
+			return; //done
+		}
 	}
 	else if(entry->getGroup() != NULL)
 	{
@@ -1805,8 +1843,8 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 			}
 			else
 			{
-			mOrphanMap[parent_id].push_back(entry->getLocalID());
-		}
+			    mOrphanMap[parent_id].push_back(entry->getLocalID());
+		    }
 		}
 		else //parent in cache
 		{
@@ -1885,7 +1923,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
 			//if visible, update it
 			if(!entry->isState(LLVOCacheEntry::INACTIVE))
 			{
-				replaceCacheEntry(entry, new_entry);
+				replaceVisibleCacheEntry(entry, new_entry);
 			}
 			else //invisible
 			{
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index f3c4c080c1..78a6c782a9 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -367,7 +367,7 @@ private:
 	LLViewerObject* addNewObject(LLVOCacheEntry* entry);
 	void killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list);	
 	void removeFromVOCacheTree(LLVOCacheEntry* entry);
-	void replaceCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
+	void replaceVisibleCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
 	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
 
 	F32 killInvisibleObjects(F32 max_time);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 1f3af78e77..9816fb9af0 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -102,8 +102,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	BOOL success;
 
 	mDP.assignBuffer(mBuffer, 0);
-	setOctreeEntry(NULL);
-
+	
 	success = check_read(apr_file, &mLocalID, sizeof(U32));
 	if(success)
 	{
-- 
cgit v1.2.3


From 1bc1d532cff1539bb5366f87b602970f1d2a8929 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 14 Jun 2013 16:20:22 -0600
Subject: fix for SH-4244: interesting: objects on adjacent region are not
 visible. and SH-4264: interesting: Content near edges of screen does not load

---
 indra/newview/llvocache.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 9816fb9af0..68f21ed2b3 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -416,7 +416,7 @@ public:
 
 	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
-#if 1
+#if 0
 		S32 res = AABBInRegionFrustumGroupBounds(group);
 #else	
 		S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
@@ -430,7 +430,7 @@ public:
 
 	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
-#if 1
+#if 0
 		S32 res = AABBInRegionFrustumObjectBounds(group);
 #else
 		S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
-- 
cgit v1.2.3


From 3f2de87340b1c831ea59e4a3ca960d49f343c9fd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 17 Jun 2013 01:18:21 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 added getAs and setAs to LLUnit to make it clearer how you specify units
 removed accidental 0-based indexing of periodicRecording history... should
 now be consistently 1-based, with 0 accessing current active recording
 removed per frame timer updates of all historical timer bars in fast timer
 display added missing assignment operator to recordings

---
 indra/newview/llfasttimerview.cpp | 257 ++++++++++++++++++++++----------------
 indra/newview/llfasttimerview.h   |  31 +++--
 indra/newview/llscenemonitor.cpp  |   2 +-
 3 files changed, 169 insertions(+), 121 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 8e061ec87c..231ece4bbd 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -56,7 +56,7 @@
 
 using namespace LLTrace;
 
-static const S32 MAX_VISIBLE_HISTORY = 10;
+static const S32 MAX_VISIBLE_HISTORY = 12;
 static const S32 LINE_GRAPH_HEIGHT = 240;
 static const S32 MIN_BAR_HEIGHT = 3;
 
@@ -105,7 +105,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 	mPauseHistory(false),
 	mRecording(512)
 {
-	mTimerBarRows.resize(MAX_VISIBLE_HISTORY);
+	mTimerBarRows.resize(512);
 }
 
 LLFastTimerView::~LLFastTimerView()
@@ -272,32 +272,36 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			mHoverBarIndex = 0;
 		}
 
-		S32 i = 0;
-		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-			it != end_timer_tree();
-			++it, ++i)
+		TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1];
+
+		TimerBar* hover_bar = NULL;
+		LLUnit<F32, LLUnits::Seconds> mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay;
+		for (std::vector<TimerBar>::iterator it = row.mBars.begin(), end_it = row.mBars.end();
+			it != end_it;
+			++it)
 		{
-			// is mouse over bar for this timer?
-			TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1];
-			if (row.mBars[i].mVisibleRect.pointInRect(x, y - row.mBottom))
+			if (it->mSelfStart > mouse_time_offset)
 			{
-				mHoverID = (*it);
-				if (mHoverTimer != *it)
-				{
-					// could be that existing tooltip is for a parent and is thus
-					// covering region for this new timer, go ahead and unblock 
-					// so we can create a new tooltip
-					LLToolTipMgr::instance().unblockToolTips();
-					mHoverTimer = (*it);
-				}
-
-				mToolTipRect = row.mBars[i].mVisibleRect;
-				mToolTipRect.translate(0, row.mBottom);
+				break;
 			}
+			hover_bar = &(*it);
+		}
 
-			if ((*it)->getCollapsed())
+		if (hover_bar)
+		{
+			mHoverID = hover_bar->mTimeBlock;
+			mHoverTimer = mHoverID;
+			if (mHoverTimer != mHoverID)
 			{
-				it.skipDescendants();
+				// could be that existing tooltip is for a parent and is thus
+				// covering region for this new timer, go ahead and unblock 
+				// so we can create a new tooltip
+				LLToolTipMgr::instance().unblockToolTips();
+				mHoverTimer = mHoverID;
+				mToolTipRect.set(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(),
+								row.mTop,
+								mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(),
+								row.mBottom);
 			}
 		}
 	}
@@ -422,9 +426,14 @@ void LLFastTimerView::draw()
 
 void LLFastTimerView::onOpen(const LLSD& key)
 {
-	if (mRecording.getNumRecordedPeriods() == 0)
+	setPauseState(false);
+	mRecording.reset();
+	mRecording.appendPeriodicRecording(LLTrace::get_frame_recording());
+	for(std::deque<TimerBarRow>::iterator it = mTimerBarRows.begin(), end_it = mTimerBarRows.end();
+		it != end_it; 
+		++it)
 	{
-		mRecording.appendPeriodicRecording(LLTrace::get_frame_recording());
+		it->mBars.clear();
 	}
 }
 
@@ -1077,6 +1086,7 @@ void LLFastTimerView::drawLineGraph()
 			glLineWidth(3);
 		}
 
+		llassert(idp->getIndex() < sTimerColors.size());
 		const F32 * col = sTimerColors[idp->getIndex()].mV;// ft_display_table[idx].color->mV;
 
 		F32 alpha = 1.f;
@@ -1191,6 +1201,7 @@ void LLFastTimerView::drawLegend( S32 y )
 				scale_offset = llfloor(sinf(mHighlightTimer.getElapsedTimeF32() * 6.f) * 2.f);
 			}
 			bar_rect.stretch(scale_offset);
+			llassert(idp->getIndex() < sTimerColors.size());
 			gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]);
 
 			LLUnit<F32, LLUnits::Milliseconds> ms = 0;
@@ -1262,7 +1273,7 @@ void LLFastTimerView::generateUniqueColors()
 {
 	// generate unique colors
 	{
-		sTimerColors.reserve(LLTrace::TimeBlock::getNumIndices());
+		sTimerColors.resize(LLTrace::TimeBlock::getNumIndices());
 		sTimerColors[FTM_FRAME.getIndex()] = LLColor4::grey;
 
 		F32 hue = 0.f;
@@ -1283,6 +1294,7 @@ void LLFastTimerView::generateUniqueColors()
 			LLColor4 child_color;
 			child_color.setHSL(hue, saturation, lightness);
 
+			llassert(idp->getIndex() < sTimerColors.size());
 			sTimerColors[idp->getIndex()] = child_color;
 		}
 	}
@@ -1377,7 +1389,7 @@ void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32
 		//history bars
 		gl_rect_2d(x_start-5, by, getRect().getWidth()-5, LINE_GRAPH_HEIGHT-bar_height-dy-2, LLColor4::grey, FALSE);			
 
-		by = LINE_GRAPH_HEIGHT-bar_height-dy-7;
+		by = LINE_GRAPH_HEIGHT-dy;
 
 		//line graph
 		mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5);
@@ -1391,21 +1403,21 @@ void LLFastTimerView::updateTotalTime()
 	switch(mDisplayMode)
 	{
 	case 0:
-		mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME)*2;
+		mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME, 100)*2;
 		break;
 	case 1:
-		mTotalTimeDisplay = mAllTimeMax;
+		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME);
 		break;
 	case 2:
 		// Calculate the max total ticks for the current history
-		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME);
+		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20);
 		break;
 	default:
 		mTotalTimeDisplay = LLUnit<F32, LLUnits::Milliseconds>(100);
 		break;
 	}
 
-	mTotalTimeDisplay = LLUnit<F32, LLUnits::Milliseconds>(llceil(mTotalTimeDisplay.as<LLUnits::Milliseconds>().value() / 20.f) * 20.f);
+	mTotalTimeDisplay = LLUnit<F32, LLUnits::Milliseconds>(llceil(mTotalTimeDisplay.getAs<LLUnits::Milliseconds>() / 20.f) * 20.f);
 }
 
 void LLFastTimerView::drawBars()
@@ -1432,41 +1444,44 @@ void LLFastTimerView::drawBars()
 
 	gGL.getTexUnit(0)->bind(bar_image->getImage());
 	{	
-		const S32 histmax = llmin((S32)mRecording.getNumRecordedPeriods(), MAX_VISIBLE_HISTORY);
-
-		llassert(mTimerBarRows.size() >= histmax);
+		const S32 histmax = (S32)mRecording.getNumRecordedPeriods();
 
 		// update widths
 		updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1);
-		mAverageTimerRow.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, -bar_height);
-		updateTimerBarFractions(&FTM_FRAME, mAverageTimerRow);
+		updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow);
 
-		for (S32 history_index = 0; history_index < histmax; history_index++)
+		for (S32 history_index = 1; history_index <= histmax; history_index++)
 		{
-			TimerBarRow& row = mTimerBarRows[history_index];
+			llassert(history_index <= mTimerBarRows.size());
+			TimerBarRow& row = mTimerBarRows[history_index - 1];
 			if (row.mBars.empty())
 			{
 				row.mBars.reserve(LLInstanceTracker<LLTrace::TimeBlock>::instanceCount());
 				updateTimerBarWidths(&FTM_FRAME, row, history_index);
-				row.mBars[0].mVisibleRect = LLRect(mBarRect.mLeft, 0, mBarRect.mLeft + row.mBars[0].mWidth, -1);
-				updateTimerBarFractions(&FTM_FRAME, row);
+				updateTimerBarOffsets(&FTM_FRAME, row);
 			}
 		}
 
 		// draw bars
-		LLRect frame_bar_rect(	mBarRect.mLeft, 
-								bars_top, 
-								mBarRect.mLeft + mAverageTimerRow.mBars[0].mWidth, 
-								bars_top - bar_height);
+		LLRect frame_bar_rect;
+		frame_bar_rect.setLeftTopAndSize(mBarRect.mLeft, 
+										bars_top, 
+										llround((mAverageTimerRow.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth()), 
+										bar_height);
+		mAverageTimerRow.mTop = frame_bar_rect.mTop;
 		mAverageTimerRow.mBottom = frame_bar_rect.mBottom;
-		drawBar(&FTM_FRAME, frame_bar_rect, mAverageTimerRow, image_width, image_height, false);
+		drawBar(frame_bar_rect, mAverageTimerRow, image_width, image_height);
 		frame_bar_rect.translate(0, -(bar_height + vpad + bar_height));
 
 		for(S32 bar_index = mScrollIndex; bar_index < llmin(histmax, mScrollIndex + MAX_VISIBLE_HISTORY); ++bar_index)
 		{
+			llassert(bar_index < mTimerBarRows.size());
 			TimerBarRow& row = mTimerBarRows[bar_index];
+			row.mTop = frame_bar_rect.mTop;
 			row.mBottom = frame_bar_rect.mBottom;
-			drawBar(&FTM_FRAME, frame_bar_rect, row, image_width, image_height, false);
+			frame_bar_rect.mRight = frame_bar_rect.mLeft 
+									+ llround((row.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth());
+ 			drawBar(frame_bar_rect, row, image_width, image_height);
 
 			frame_bar_rect.translate(0, -(bar_height + vpad));
 		}
@@ -1477,97 +1492,115 @@ void LLFastTimerView::drawBars()
 
 static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
-S32 LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible)
+LLUnit<F32, LLUnits::Seconds> LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible)
 {
-	std::vector<TimerBar>& bars = row.mBars;
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
-	const F32 self_time_frame_fraction = history_index == -1
-										? (mRecording.getPeriodMean(time_block->selfTime()) / mTotalTimeDisplay) 
-										: (mRecording.getPrevRecording(history_index).getSum(time_block->selfTime()) / mTotalTimeDisplay);
+	const LLUnit<F32, LLUnits::Seconds> self_time = history_index == -1
+										? mRecording.getPeriodMean(time_block->selfTime()) 
+										: mRecording.getPrevRecording(history_index).getSum(time_block->selfTime());
 
-	const S32 self_time_width = llround(self_time_frame_fraction * (F32)mBarRect.getWidth());
-	S32 full_width = self_time_width;
+	LLUnit<F32, LLUnits::Seconds> full_time = self_time;
 
 	// reserve a spot for this bar to be rendered before its children
 	// even though we don't know its size yet
+	std::vector<TimerBar>& bars = row.mBars;
+	S32 bar_index = bars.size();
 	bars.push_back(TimerBar());
-	TimerBar& timer_bar = bars.back();
 
 	const bool children_visible = visible && !time_block->getCollapsed();
 	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
 	{
-		full_width += updateTimerBarWidths(*it, row, history_index, children_visible);
+		full_time += updateTimerBarWidths(*it, row, history_index, children_visible);
 	}
 
-	timer_bar.mWidth     = full_width;
-	timer_bar.mSelfWidth = self_time_width;
-	timer_bar.mTimeBlock = time_block;
-	timer_bar.mVisible   = visible;
+	TimerBar& timer_bar = bars[bar_index];
+	timer_bar.mTotalTime  = full_time;
+	timer_bar.mSelfTime   = self_time;
+	timer_bar.mTimeBlock  = time_block;
+	timer_bar.mVisible    = visible;
 	
-	return full_width;
+	return full_time;
 }
 
 static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions");
 
-S32 LLFastTimerView::updateTimerBarFractions(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index)
+S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index)
 {
-	std::vector<TimerBar>& bars = row.mBars;
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS);
+
+	std::vector<TimerBar>& bars = row.mBars;
+	llassert(timer_bar_index < bars.size());
 	TimerBar& timer_bar = bars[timer_bar_index];
-	S32 child_time_width = timer_bar.mWidth - timer_bar.mSelfWidth;
-	LLRect children_rect = timer_bar.mVisibleRect;
+	const LLUnit<F32, LLUnits::Seconds> child_time_width = timer_bar.mTotalTime - timer_bar.mSelfTime;
+	timer_bar.mChildrenStart = timer_bar.mSelfStart;
 
 	if (mDisplayCenter == ALIGN_CENTER)
 	{
-		children_rect.mLeft += timer_bar.mSelfWidth / 2;
+		timer_bar.mChildrenStart += timer_bar.mSelfTime / 2;
 	}
 	else if (mDisplayCenter == ALIGN_RIGHT)
 	{
-		children_rect.mLeft += timer_bar.mSelfWidth;
+		timer_bar.mChildrenStart += timer_bar.mSelfTime;
 	}
-	children_rect.mRight = children_rect.mLeft + timer_bar.mWidth - timer_bar.mSelfWidth;
-
-	timer_bar.mChildrenRect = children_rect;
+	timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime;
 
 	//now loop through children and figure out portion of bar image covered by each bar, now that we know the
 	//sum of all children
-	if (!time_block->getCollapsed())
+	F32 bar_fraction_start = 0.f;
+	TimerBar* last_child_timer_bar = NULL;
+
+	bool first_child = true;
+	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
+		it != end_it; 
+		++it)
 	{
-		F32 bar_fraction_start = 0.f;
-		for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
-			it != end_it; 
-			++it)
+		timer_bar_index++;
+		
+		llassert(timer_bar_index < bars.size());
+		TimerBar& child_timer_bar = bars[timer_bar_index];
+		TimeBlock* child_time_block = *it;
+
+		if (last_child_timer_bar)
 		{
-			timer_bar_index++;
+			last_child_timer_bar->mLastChild = false;
+		}
+		child_timer_bar.mLastChild = true;
+		last_child_timer_bar = &child_timer_bar;
 
-			TimerBar& child_timer_bar = bars[timer_bar_index];
-			TimeBlock* child_time_block = *it;
+		child_timer_bar.mFirstChild = first_child;
+		if (first_child)
+		{
+			first_child = false;
+		}
 
-			child_timer_bar.mStartFraction = bar_fraction_start;
-			child_timer_bar.mEndFraction = child_time_width > 0
-				? bar_fraction_start + (F32)child_timer_bar.mWidth / child_time_width
-				: 1.f;
-			child_timer_bar.mVisibleRect.set(children_rect.mLeft + llround(child_timer_bar.mStartFraction * children_rect.getWidth()), 
-				children_rect.mTop, 
-				children_rect.mLeft + llround(child_timer_bar.mEndFraction * children_rect.getWidth()), 
-				children_rect.mBottom);
+		child_timer_bar.mStartFraction = bar_fraction_start;
+		child_timer_bar.mEndFraction = child_time_width > 0
+										? bar_fraction_start + child_timer_bar.mTotalTime / child_time_width
+										: 1.f;
+		child_timer_bar.mSelfStart = timer_bar.mChildrenStart 
+									+ child_timer_bar.mStartFraction 
+										* (timer_bar.mChildrenEnd - timer_bar.mChildrenStart);
+		child_timer_bar.mSelfEnd =	timer_bar.mChildrenStart 
+									+ child_timer_bar.mEndFraction 
+										* (timer_bar.mChildrenEnd - timer_bar.mChildrenStart);
 
-			timer_bar_index = updateTimerBarFractions(child_time_block, row, timer_bar_index);
+		timer_bar_index = updateTimerBarOffsets(child_time_block, row, timer_bar_index);
 
-			bar_fraction_start = child_timer_bar.mEndFraction;
-		}
+		bar_fraction_start = child_timer_bar.mEndFraction;
 	}
 	return timer_bar_index;
 }
 
-S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index)
+S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index)
 {
+	llassert(bar_index < row.mBars.size());	
 	TimerBar& timer_bar = row.mBars[bar_index];
+	LLTrace::TimeBlock* time_block = timer_bar.mTimeBlock;
 
 	hovered |= mHoverID == time_block;
 
 	// animate scale of bar when hovering over that particular timer
-	if (bar_rect.getWidth() > 0)
+	if ((F32)bar_rect.getWidth() * (timer_bar.mEndFraction - timer_bar.mStartFraction) > 2.f)
 	{
 		LLRect render_rect(bar_rect);
 		S32 scale_offset = 0;
@@ -1578,8 +1611,9 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, Ti
 			render_rect.mBottom -= scale_offset;
 		}
 
+		llassert(time_block->getIndex() < sTimerColors.size());
 		LLColor4 color = sTimerColors[time_block->getIndex()];
-		if (!hovered) color = lerp(color, LLColor4::grey, 0.8f);
+		if (!hovered) color = lerp(color, LLColor4::grey, 0.2f);
 		gGL.color4fv(color.mV);
 		gl_segmented_rect_2d_fragment_tex(render_rect,
 			image_width, image_height, 
@@ -1587,26 +1621,33 @@ S32 LLFastTimerView::drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, Ti
 			timer_bar.mStartFraction, timer_bar.mEndFraction);
 	}
 
-	if (!time_block->getCollapsed())
+	LLRect children_rect;
+	children_rect.mLeft  = llround(timer_bar.mChildrenStart / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft;
+	children_rect.mRight = llround(timer_bar.mChildrenEnd   / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft;
+
+	if (bar_rect.getHeight() > MIN_BAR_HEIGHT)
 	{
-		for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
+		// shrink as we go down a level
+		children_rect.mTop = bar_rect.mTop - 1;
+		children_rect.mBottom = bar_rect.mBottom + 1;
+	}
+	else
+	{
+		children_rect.mTop = bar_rect.mTop;
+		children_rect.mBottom = bar_rect.mBottom;
+	}
+
+	bar_index++;
+	const U32 num_bars = row.mBars.size();
+	if (bar_index < num_bars && row.mBars[bar_index].mFirstChild)
+	{
+		bool is_last = false;
+		do
 		{
-			++bar_index;
-			LLRect children_rect = timer_bar.mChildrenRect;
-			children_rect.translate(0, row.mBottom);
-			if (bar_rect.getHeight() > MIN_BAR_HEIGHT)
-			{
-				// shrink as we go down a level
-				children_rect.mTop = bar_rect.mTop - 1;
-				children_rect.mBottom = bar_rect.mBottom + 1;
-			}
-			else
-			{
-				children_rect.mTop = bar_rect.mTop;
-				children_rect.mBottom = bar_rect.mBottom;
-			}
-			bar_index = drawBar(*it, children_rect, row, image_width, image_height, hovered, bar_index);
+			is_last = row.mBars[bar_index].mLastChild;
+			bar_index = drawBar(children_rect, row, image_width, image_height, hovered, bar_index);
 		}
+		while(!is_last && bar_index < num_bars);
 	}
 
 	return bar_index;
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index c20cadd6d7..d9ae6348da 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -80,31 +80,38 @@ private:
 	struct TimerBar
 	{
 		TimerBar()
-		:	mWidth(0),
-			mSelfWidth(0),
+		:	mTotalTime(0),
+			mSelfTime(0),
 			mVisible(true),
 			mStartFraction(0.f),
-			mEndFraction(1.f)
+			mEndFraction(1.f),
+			mFirstChild(false),
+			mLastChild(false)
 		{}
-		S32					mWidth;
-		S32					mSelfWidth;
-		LLRect				mVisibleRect,
-							mChildrenRect;
+		LLUnit<F32, LLUnits::Seconds>	mTotalTime,
+										mSelfTime,
+										mChildrenStart,
+										mChildrenEnd,
+										mSelfStart,
+										mSelfEnd;
 		LLTrace::TimeBlock* mTimeBlock;
-		bool				mVisible;
+		bool				mVisible,
+							mFirstChild,
+							mLastChild;
 		F32					mStartFraction,
 							mEndFraction;
 	};
 
 	struct TimerBarRow
 	{
-		S32						mBottom;
+		S32						mBottom,
+								mTop;
 		std::vector<TimerBar>	mBars;
 	};
 
-	S32 updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible = true);
-	S32 updateTimerBarFractions(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
-	S32 drawBar(LLTrace::TimeBlock* time_block, LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index = 0);
+	LLUnit<F32, LLUnits::Seconds> updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible = true);
+	S32 updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
+	S32 drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, S32 bar_index = 0);
 	void setPauseState(bool pause_state);
 
 	std::deque<TimerBarRow> mTimerBarRows;
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 3d9e0ab4c3..8086745471 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -616,7 +616,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		for (S32 frame = 0; frame < frame_count; frame++)
 		{
-			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).as<LLUnits::Kibibytes>().value();
+			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).getAs<LLUnits::Kibibytes>();
 		}
 
 		os << std::endl;
-- 
cgit v1.2.3


From 9ed2f4d3cb02d5161bd8bb77cb7befa7feedf2d9 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 17 Jun 2013 15:24:15 -0600
Subject: add a debug setting "InvisibleObjectsInMemoryTime" to adjust the time
 invisible objects stay in memory.

---
 indra/newview/app_settings/settings.xml | 11 +++++++++++
 indra/newview/lldrawable.cpp            |  4 ++--
 indra/newview/lldrawable.h              |  2 +-
 indra/newview/llvieweroctree.h          |  2 +-
 indra/newview/llvocache.cpp             | 20 ++++++++++++++------
 indra/newview/llvocache.h               |  7 +++++--
 6 files changed, 34 insertions(+), 12 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 4d5b0c62e4..29427bbaa3 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4590,6 +4590,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>InvisibleObjectsInMemoryTime</key>
+    <map>
+      <key>Comment</key>
+      <string>Number of frames invisible objects stay in memory before being removed. 0 means never to remove.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>U32</string>
+      <key>Value</key>
+      <integer>64</integer>
+    </map>
     <key>JoystickAvatarEnabled</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 22a7c350d6..30d1b7fdba 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1098,9 +1098,9 @@ LLSpatialPartition* LLDrawable::getSpatialPartition()
 }
 
 //virtual
-S32 LLDrawable::getMinFrameRange() const
+U32 LLDrawable::getMinFrameRange() const
 {
-const S32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one.
+	const U32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one.
 
 	return MIN_VIS_FRAME_RANGE ;
 }
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 98f0b51a97..ebda188618 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -193,7 +193,7 @@ public:
 
 	LLSpatialPartition* getSpatialPartition();
 	
-	virtual S32 getMinFrameRange()const;
+	virtual U32 getMinFrameRange()const;
 	void removeFromOctree();
 
 	void setSpatialBridge(LLSpatialBridge* bridge) { mSpatialBridge = (LLDrawable*) bridge; }
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 0a96676be1..7f2ca6ed2d 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -149,7 +149,7 @@ public:
 	
 	virtual void setOctreeEntry(LLViewerOctreeEntry* entry);
 
-	virtual S32  getMinFrameRange()const = 0;
+	virtual U32  getMinFrameRange()const = 0;
 
 	F32                  getBinRadius() const   {return mEntry->getBinRadius();}
 	const LLVector4a*    getSpatialExtents() const;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 68f21ed2b3..93daf2e171 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -50,6 +50,14 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes)
 //---------------------------------------------------------------------------
 // LLVOCacheEntry
 //---------------------------------------------------------------------------
+//return number of frames invisible objects should stay in memory
+//static 
+U32 LLVOCacheEntry::getInvisibleObjectsLiveTime()
+{
+	static LLCachedControl<U32> inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime");
+
+	return inv_obj_time - 1; //make 0 to be the maximum 
+}
 
 LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp)
 	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY),
@@ -60,7 +68,6 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mDupeCount(0),
 	mCRCChangeCount(0),
 	mState(INACTIVE),
-	mMinFrameRange(64),
 	mSceneContrib(0.f),
 	mTouched(TRUE),
 	mParentID(0)
@@ -68,6 +75,7 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mBuffer = new U8[dp.getBufferSize()];
 	mDP.assignBuffer(mBuffer, dp.getBufferSize());
 	mDP = dp;
+	mMinFrameRange = getInvisibleObjectsLiveTime();
 }
 
 LLVOCacheEntry::LLVOCacheEntry()
@@ -80,12 +88,12 @@ LLVOCacheEntry::LLVOCacheEntry()
 	mCRCChangeCount(0),
 	mBuffer(NULL),
 	mState(INACTIVE),
-	mMinFrameRange(64),
 	mSceneContrib(0.f),
 	mTouched(TRUE),
 	mParentID(0)
 {
 	mDP.assignBuffer(mBuffer, 0);
+	mMinFrameRange = getInvisibleObjectsLiveTime();
 }
 
 LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
@@ -93,7 +101,6 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	mBuffer(NULL),
 	mUpdateFlags(-1),
 	mState(INACTIVE),
-	mMinFrameRange(64),
 	mSceneContrib(0.f),
 	mTouched(FALSE),
 	mParentID(0)
@@ -101,6 +108,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	S32 size = -1;
 	BOOL success;
 
+	mMinFrameRange = getInvisibleObjectsLiveTime();
 	mDP.assignBuffer(mBuffer, 0);
 	
 	success = check_read(apr_file, &mLocalID, sizeof(U32));
@@ -218,17 +226,17 @@ void LLVOCacheEntry::setState(U32 state)
 
 		if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mMinFrameRange)
 		{
-			mMinFrameRange = llmin(mMinFrameRange * 2, 2048);
+			mMinFrameRange = llmin(mMinFrameRange * 2, getInvisibleObjectsLiveTime() * 32);
 		}
 		else
 		{
-			mMinFrameRange = 64; //reset
+			mMinFrameRange = getInvisibleObjectsLiveTime(); //reset
 		}
 	}
 }
 
 //virtual 
-S32  LLVOCacheEntry::getMinFrameRange()const
+U32  LLVOCacheEntry::getMinFrameRange()const
 {
 	return mMinFrameRange;
 }
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index e46fec9dc3..b8a7ccac99 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -88,7 +88,7 @@ public:
 	U32 getCRC() const				{ return mCRC; }
 	S32 getHitCount() const			{ return mHitCount; }
 	S32 getCRCChangeCount() const	{ return mCRCChangeCount; }
-	S32 getMinFrameRange()const;	
+	U32 getMinFrameRange()const;	
 
 	void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update);
 	void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;}
@@ -121,6 +121,9 @@ public:
 	void setUpdateFlags(U32 flags) {mUpdateFlags = flags;}
 	U32  getUpdateFlags() const    {return mUpdateFlags;}
 
+private:
+	static U32  getInvisibleObjectsLiveTime();
+
 public:
 	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;
 	typedef std::set<LLVOCacheEntry*>                      vocache_entry_set_t;
@@ -138,7 +141,7 @@ protected:
 	U8							*mBuffer;
 
 	F32                         mSceneContrib; //projected scene contributuion of this object.
-	S32                         mMinFrameRange;
+	U32                         mMinFrameRange;
 	U32                         mState; //high 16 bits reserved for special use.
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 
-- 
cgit v1.2.3


From d136c4c29686c565b5a46503aa67a9c958b4145d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 18 Jun 2013 23:41:53 -0700
Subject: SH-4246 FIX interesting: fast timers significantly decreases
 framerate removed implicit flushes on reads from recorders for better
 performance made sure stack timers were updated on recorder deactivate faster
 rendering and better ui for fast timer view

---
 indra/newview/llfasttimerview.cpp                  | 316 +++++++++++----------
 indra/newview/llfasttimerview.h                    |  33 +--
 .../skins/default/xui/en/floater_fast_timers.xml   |  69 +++++
 3 files changed, 247 insertions(+), 171 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 231ece4bbd..1355b58f8b 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -30,12 +30,14 @@
 
 #include "llviewerwindow.h"
 #include "llrect.h"
+#include "llcombobox.h"
 #include "llerror.h"
 #include "llgl.h"
 #include "llimagepng.h"
 #include "llrender.h"
 #include "llrendertarget.h"
 #include "lllocalcliprect.h"
+#include "lllayoutstack.h"
 #include "llmath.h"
 #include "llfontgl.h"
 #include "llsdserialize.h"
@@ -59,6 +61,8 @@ using namespace LLTrace;
 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;
 
 std::vector<TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
@@ -95,17 +99,15 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 :	LLFloater(key),
 	mHoverTimer(NULL),
 	mDisplayMode(0),
-	mDisplayCenter(ALIGN_CENTER),
-	mDisplayCalls(false),
-	mDisplayHz(false),
+	mDisplayType(TIME),
 	mScrollIndex(0),
 	mHoverID(NULL),
 	mHoverBarIndex(-1),
 	mStatsIndex(-1),
 	mPauseHistory(false),
-	mRecording(512)
+	mRecording(NUM_FRAMES_HISTORY)
 {
-	mTimerBarRows.resize(512);
+	mTimerBarRows.resize(NUM_FRAMES_HISTORY);
 }
 
 LLFastTimerView::~LLFastTimerView()
@@ -172,7 +174,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 
 TimeBlock* LLFastTimerView::getLegendID(S32 y)
 {
-	S32 idx = (mBarRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight()+2) - 1;
+	S32 idx = (mLegendRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight() + 2);
 
 	if (idx >= 0 && idx < (S32)ft_display_idx.size())
 	{
@@ -208,26 +210,6 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 		//left click drills down by expanding timers
 		mHoverTimer->setCollapsed(false);
 	}
-	else if (mask & MASK_ALT)
-	{
-		if (mask & MASK_CONTROL)
-		{
-			mDisplayHz = !mDisplayHz;	
-		}
-		else
-		{
-			mDisplayCalls = !mDisplayCalls;
-		}
-	}
-	else if (mask & MASK_SHIFT)
-	{
-		if (++mDisplayMode > 3)
-			mDisplayMode = 0;
-	}
-	else if (mask & MASK_CONTROL)
-	{
-		mDisplayCenter = (ChildAlignment)((mDisplayCenter + 1) % ALIGN_COUNT);
-	}
 	else if (mGraphRect.pointInRect(x, y))
 	{
 		gFocusMgr.setMouseCapture(this);
@@ -260,7 +242,10 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 	if(mPauseHistory && mBarRect.pointInRect(x, y))
 	{
-		mHoverBarIndex = llmin((mBarRect.mTop - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1,
+		//const S32 bars_top = mBarRect.mTop;
+		const S32 bars_top = mBarRect.mTop - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 4);
+
+		mHoverBarIndex = llmin((bars_top - y) / (mBarRect.getHeight() / (MAX_VISIBLE_HISTORY + 2)) - 1,
 								(S32)mRecording.getNumRecordedPeriods() - 1,
 								MAX_VISIBLE_HISTORY);
 		if (mHoverBarIndex == 0)
@@ -272,25 +257,33 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			mHoverBarIndex = 0;
 		}
 
-		TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mHoverBarIndex - 1];
+		TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mScrollIndex + mHoverBarIndex - 1];
 
 		TimerBar* hover_bar = NULL;
 		LLUnit<F32, LLUnits::Seconds> mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay;
-		for (std::vector<TimerBar>::iterator it = row.mBars.begin(), end_it = row.mBars.end();
-			it != end_it;
-			++it)
+		for (int bar_index = 0, end_index = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount(); 
+			bar_index < end_index; 
+			++bar_index)
 		{
-			if (it->mSelfStart > mouse_time_offset)
+			TimerBar& bar = row.mBars[bar_index];
+			if (bar.mSelfStart > mouse_time_offset)
 			{
 				break;
 			}
-			hover_bar = &(*it);
+			if (bar.mSelfEnd > mouse_time_offset)
+			{
+				hover_bar = &bar;
+				if (bar.mTimeBlock->getCollapsed())
+				{
+					// stop on first collapsed timeblock, since we can't select any children
+					break;
+				}
+			}
 		}
 
 		if (hover_bar)
 		{
 			mHoverID = hover_bar->mTimeBlock;
-			mHoverTimer = mHoverID;
 			if (mHoverTimer != mHoverID)
 			{
 				// could be that existing tooltip is for a parent and is thus
@@ -300,7 +293,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 				mHoverTimer = mHoverID;
 				mToolTipRect.set(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(),
 								row.mTop,
-								mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(),
+								mBarRect.mLeft + (hover_bar->mSelfEnd / mTotalTimeDisplay) * mBarRect.getWidth(),
 								row.mBottom);
 			}
 		}
@@ -324,7 +317,7 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco
 	if (history_index == 0)
 	{
 		// by default, show average number of call
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<F64, LLUnits::Milliseconds>(frame_recording.getPeriodMean(timer)).value(), (S32)frame_recording.getPeriodMean(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<F64, LLUnits::Milliseconds>(frame_recording.getPeriodMean (timer, RUNNING_AVERAGE_WIDTH)).value(), (S32)frame_recording.getPeriodMean(timer.callCount(), RUNNING_AVERAGE_WIDTH));
 	}
 	else
 	{
@@ -397,22 +390,34 @@ void LLFastTimerView::draw()
 		mTimerBarRows.push_front(TimerBarRow());
 	}
 
+	mDisplayMode = llclamp(getChild<LLComboBox>("time_scale_combo")->getCurrentIndex(), 0, 3);
+	mDisplayType = (EDisplayType)llclamp(getChild<LLComboBox>("metric_combo")->getCurrentIndex(), 0, 2);
+
 	generateUniqueColors();
 
+	LLView::drawChildren();
+	//getChild<LLLayoutStack>("timer_bars_stack")->updateLayout();
+	//getChild<LLLayoutStack>("legend_stack")->updateLayout();
+	LLView* bars_panel = getChildView("bars_panel");
+	bars_panel->localRectToOtherView(bars_panel->getLocalRect(), &mBarRect, this);
+
+	LLView* lines_panel = getChildView("lines_panel");
+	lines_panel->localRectToOtherView(lines_panel->getLocalRect(), &mGraphRect, this);
+
+	LLView* legend_panel = getChildView("legend");
+	legend_panel->localRectToOtherView(legend_panel->getLocalRect(), &mLegendRect, this);
+
 	// Draw the window background
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gl_rect_2d(getLocalRect(), LLColor4(0.f, 0.f, 0.f, 0.25f));
 	
-	S32 y = drawHelp(getRect().getHeight() - MARGIN);
-	drawLegend(y - ((S32)LLFontGL::getFontMonospace()->getLineHeight() + 2));
-
-	// update rectangle that includes timer bars
-	const S32 LEGEND_WIDTH = 220;
+	drawHelp(getRect().getHeight() - MARGIN);
+	drawLegend();
 
-	mBarRect.mLeft = MARGIN + LEGEND_WIDTH + 8;
-	mBarRect.mTop = y;
-	mBarRect.mRight = getRect().getWidth() - MARGIN;
-	mBarRect.mBottom = MARGIN + LINE_GRAPH_HEIGHT;
+	//mBarRect.mLeft = MARGIN + LEGEND_WIDTH + 8;
+	//mBarRect.mTop = y;
+	//mBarRect.mRight = getRect().getWidth() - MARGIN;
+	//mBarRect.mBottom = MARGIN + LINE_GRAPH_HEIGHT;
 
 	drawBars();
 	drawLineGraph();
@@ -433,7 +438,8 @@ void LLFastTimerView::onOpen(const LLSD& key)
 		it != end_it; 
 		++it)
 	{
-		it->mBars.clear();
+		delete []it->mBars;
+		it->mBars = NULL;
 	}
 }
 
@@ -993,7 +999,7 @@ void LLFastTimerView::printLineStats()
 			LLUnit<F32, LLUnits::Seconds> ticks;
 			if (mStatsIndex == 0)
 			{
-				ticks = mRecording.getPeriodMean(*idp);
+				ticks = mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH);
 			}
 			else
 			{
@@ -1019,8 +1025,6 @@ void LLFastTimerView::drawLineGraph()
 {
 	LLFastTimer _(FTM_DRAW_LINE_GRAPH);
 	//draw line graph history
-	S32 x = mBarRect.mLeft;
-	S32 y = LINE_GRAPH_HEIGHT;
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	LLLocalClipRect clip(mGraphRect);
 
@@ -1029,21 +1033,6 @@ void LLFastTimerView::drawLineGraph()
 	static U32 max_calls = 0;
 	static F32 alpha_interp = 0.f;
 
-	//display y-axis range
-	std::string axis_label;
-	if (mDisplayCalls)
-		axis_label = llformat("%d calls", (int)max_calls);
-	else if (mDisplayHz)
-		axis_label = llformat("%d Hz", (int)(1.f / max_time.value()));
-	else
-		axis_label = llformat("%4.2f ms", LLUnit<F32, LLUnits::Milliseconds>(max_time).value());
-
-	x = mGraphRect.mRight - LLFontGL::getFontMonospace()->getWidth(axis_label)-5;
-	y = mGraphRect.mTop - LLFontGL::getFontMonospace()->getLineHeight();
-
-	LLFontGL::getFontMonospace()->renderUTF8(axis_label, 0, x, y, LLColor4::white,
-		LLFontGL::LEFT, LLFontGL::TOP);
-
 	//highlight visible range
 	{
 		S32 first_frame = mRecording.getNumRecordedPeriods() - mScrollIndex;
@@ -1059,7 +1048,7 @@ void LLFastTimerView::drawLineGraph()
 
 		if (mHoverBarIndex > 0)
 		{
-			S32 bar_frame = first_frame - mHoverBarIndex - 1;
+			S32 bar_frame = first_frame - (mScrollIndex + mHoverBarIndex) - 1;
 			F32 bar = (F32) mGraphRect.mLeft + frame_delta*bar_frame;
 
 			gGL.color4f(0.5f,0.5f,0.5f,1);
@@ -1090,6 +1079,7 @@ void LLFastTimerView::drawLineGraph()
 		const F32 * col = sTimerColors[idp->getIndex()].mV;// ft_display_table[idx].color->mV;
 
 		F32 alpha = 1.f;
+		bool is_hover_timer = true;
 
 		if (mHoverID != NULL &&
 			mHoverID != idp)
@@ -1097,11 +1087,15 @@ void LLFastTimerView::drawLineGraph()
 			if (idp->getParent() != mHoverID)
 			{
 				alpha = alpha_interp;
+				is_hover_timer = false;
 			}
 		}
 
 		gGL.color4f(col[0], col[1], col[2], alpha);				
 		gGL.begin(LLRender::TRIANGLE_STRIP);
+		F32 call_scale_factor = (F32)mGraphRect.getHeight() / (F32)max_calls;
+		F32 time_scale_factor = (F32)mGraphRect.getHeight() / max_time.value();
+		F32 hz_scale_factor = (F32) mGraphRect.getHeight() / (1.f / max_time.value());
 		for (U32 j = mRecording.getNumRecordedPeriods();
 			j > 0;
 			j--)
@@ -1110,16 +1104,26 @@ void LLFastTimerView::drawLineGraph()
 			LLUnit<F32, LLUnits::Seconds> time = llmax(recording.getSum(*idp), LLUnit<F64, LLUnits::Seconds>(0.000001));
 			U32 calls = recording.getSum(idp->callCount());
 
-			if (alpha == 1.f)
+			if (is_hover_timer)
 			{ 
 				//normalize to highlighted timer
 				cur_max = llmax(cur_max, time);
 				cur_max_calls = llmax(cur_max_calls, calls);
 			}
 			F32 x = mGraphRect.mRight - j * (F32)(mGraphRect.getWidth())/(mRecording.getNumRecordedPeriods()-1);
-			F32 y = mDisplayHz 
-				? mGraphRect.mBottom + (1.f / time.value()) * ((F32) mGraphRect.getHeight() / (1.f / max_time.value()))
-				: mGraphRect.mBottom + time / max_time * (F32)mGraphRect.getHeight();
+			F32 y;
+			switch(mDisplayType)
+			{
+			case TIME:
+				y = mGraphRect.mBottom + time.value() * time_scale_factor;
+				break;
+			case CALLS:
+				y = mGraphRect.mBottom + (F32)calls * call_scale_factor;
+				break;
+			case HZ:
+				y = mGraphRect.mBottom + (1.f / time.value()) * hz_scale_factor;
+				break;
+			}
 			gGL.vertex2f(x,y);
 			gGL.vertex2f(x,mGraphRect.mBottom);
 		}
@@ -1140,7 +1144,7 @@ void LLFastTimerView::drawLineGraph()
 	
 	//interpolate towards new maximum
 	max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f));
-	if (max_time - cur_max <= 1 ||  cur_max - max_time  <= 1)
+	if (llabs((max_time - cur_max).value()) <= 1)
 	{
 		max_time = llmax(LLUnit<F32, LLUnits::Microseconds>(1), LLUnit<F32, LLUnits::Microseconds>(cur_max));
 	}
@@ -1159,8 +1163,8 @@ void LLFastTimerView::drawLineGraph()
 
 	if (mHoverID != NULL)
 	{
-		x = (mGraphRect.mRight + mGraphRect.mLeft)/2;
-		y = mGraphRect.mBottom + 8;
+		S32 x = (mGraphRect.mRight + mGraphRect.mLeft)/2;
+		S32 y = mGraphRect.mBottom + 8;
 
 		LLFontGL::getFontMonospace()->renderUTF8(
 			mHoverID->getName(), 
@@ -1168,18 +1172,40 @@ void LLFastTimerView::drawLineGraph()
 			x, y, 
 			LLColor4::white,
 			LLFontGL::LEFT, LLFontGL::BOTTOM);
-	}					
+	}
+
+	//display y-axis range
+	std::string axis_label;
+	switch(mDisplayType)
+	{
+	case TIME:
+		axis_label = llformat("%4.2f ms", LLUnit<F32, LLUnits::Milliseconds>(max_time).value());
+		break;
+	case CALLS:
+		axis_label = llformat("%d calls", (int)max_calls);
+		break;
+	case HZ:
+		axis_label = llformat("%4.2f Hz", max_time.value() ? 1.f / max_time.value() : 0.f);
+		break;
+	}
+
+	LLFontGL* font = LLFontGL::getFontMonospace();
+	S32 x = mGraphRect.mRight - font->getWidth(axis_label)-5;
+	S32 y = mGraphRect.mTop - font->getLineHeight();;
+
+	font->renderUTF8(axis_label, 0, x, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
 }
 
-void LLFastTimerView::drawLegend( S32 y )
+void LLFastTimerView::drawLegend()
 {
 	// draw legend
 	S32 dx;
-	S32 x = MARGIN;
+	S32 x = mLegendRect.mLeft;
+	S32 y = mLegendRect.mTop;
 	const S32 TEXT_HEIGHT = (S32)LLFontGL::getFontMonospace()->getLineHeight();
 
 	{
-		LLLocalClipRect clip(LLRect(MARGIN, y, LEGEND_WIDTH, MARGIN));
+		LLLocalClipRect clip(mLegendRect);
 		S32 cur_line = 0;
 		ft_display_idx.clear();
 		std::map<TimeBlock*, S32> display_line;
@@ -1214,18 +1240,22 @@ void LLFastTimerView::drawLegend( S32 y )
 			}
 			else
 			{
-				ms = LLUnit<F64, LLUnits::Seconds>(mRecording.getPeriodMean(*idp));
-				calls = (S32)mRecording.getPeriodMean(idp->callCount());
+				ms = LLUnit<F64, LLUnits::Seconds>(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH));
+				calls = (S32)mRecording.getPeriodMean(idp->callCount(), RUNNING_AVERAGE_WIDTH);
 			}
 
 			std::string timer_label;
-			if (mDisplayCalls)
-			{
-				timer_label = llformat("%s (%d)",idp->getName().c_str(),calls);
-			}
-			else
+			switch(mDisplayType)
 			{
+			case TIME:
 				timer_label = llformat("%s [%.1f]",idp->getName().c_str(),ms.value());
+				break;
+			case CALLS:
+				timer_label = llformat("%s (%d)",idp->getName().c_str(),calls);
+				break;
+			case HZ:
+				timer_label = llformat("%.1f", ms.value() ? (1.f / ms.value()) : 0.f);
+				break;
 			}
 			dx = (TEXT_HEIGHT+4) + get_depth(idp)*8;
 
@@ -1300,36 +1330,16 @@ void LLFastTimerView::generateUniqueColors()
 	}
 }
 
-S32 LLFastTimerView::drawHelp( S32 y )
+void LLFastTimerView::drawHelp( S32 y )
 {
 	// Draw some help
 	const S32 texth = (S32)LLFontGL::getFontMonospace()->getLineHeight();
 
-	char modedesc[][32] = {
-		"2 x Average ",
-		"Max         ",
-		"Recent Max  ",
-		"100 ms      "
-	};
-	char centerdesc[][32] = {
-		"Left      ",
-		"Centered  ",
-		"Ordered   "
-	};
-
-	std::string text;
-	text = llformat("Full bar = %s [Click to pause/reset] [SHIFT-Click to toggle]",modedesc[mDisplayMode]);
-	LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-
 	y -= (texth + 2);
-	text = llformat("Justification = %s [CTRL-Click to toggle]",centerdesc[mDisplayCenter]);
-	LLFontGL::getFontMonospace()->renderUTF8(text, 0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
 	y -= (texth + 2);
 
-	LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts] [ALT-SHIFT-Click sub hidden]"),
+	LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts]"),
 		0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
-	y -= (texth + 2);
-	return y;
 }
 
 void LLFastTimerView::drawTicks()
@@ -1392,7 +1402,7 @@ void LLFastTimerView::drawBorders( S32 y, const S32 x_start, S32 bar_height, S32
 		by = LINE_GRAPH_HEIGHT-dy;
 
 		//line graph
-		mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5);
+		//mGraphRect = LLRect(x_start-5, by, getRect().getWidth()-5, 5);
 
 		gl_rect_2d(mGraphRect, FALSE);
 	}
@@ -1403,7 +1413,7 @@ void LLFastTimerView::updateTotalTime()
 	switch(mDisplayMode)
 	{
 	case 0:
-		mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME, 100)*2;
+		mTotalTimeDisplay = mRecording.getPeriodMean(FTM_FRAME, RUNNING_AVERAGE_WIDTH)*2;
 		break;
 	case 1:
 		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME);
@@ -1447,18 +1457,27 @@ void LLFastTimerView::drawBars()
 		const S32 histmax = (S32)mRecording.getNumRecordedPeriods();
 
 		// update widths
-		updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1);
-		updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow);
-
-		for (S32 history_index = 1; history_index <= histmax; history_index++)
+		if (!mPauseHistory)
 		{
-			llassert(history_index <= mTimerBarRows.size());
-			TimerBarRow& row = mTimerBarRows[history_index - 1];
-			if (row.mBars.empty())
+			U32 bar_index = 0;
+			if (!mAverageTimerRow.mBars)
 			{
-				row.mBars.reserve(LLInstanceTracker<LLTrace::TimeBlock>::instanceCount());
-				updateTimerBarWidths(&FTM_FRAME, row, history_index);
-				updateTimerBarOffsets(&FTM_FRAME, row);
+				mAverageTimerRow.mBars = new TimerBar[LLInstanceTracker<LLTrace::TimeBlock>::instanceCount()];
+			}
+			updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1, bar_index);
+			updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow);
+
+			for (S32 history_index = 1; history_index <= histmax; history_index++)
+			{
+				llassert(history_index <= mTimerBarRows.size());
+				TimerBarRow& row = mTimerBarRows[history_index - 1];
+				bar_index = 0;
+				if (!row.mBars)
+				{
+					row.mBars = new TimerBar[LLInstanceTracker<LLTrace::TimeBlock>::instanceCount()];
+					updateTimerBarWidths(&FTM_FRAME, row, history_index, bar_index);
+					updateTimerBarOffsets(&FTM_FRAME, row);
+				}
 			}
 		}
 
@@ -1492,32 +1511,28 @@ void LLFastTimerView::drawBars()
 
 static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
-LLUnit<F32, LLUnits::Seconds> LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible)
+LLUnit<F32, LLUnits::Seconds> LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
 {
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
 	const LLUnit<F32, LLUnits::Seconds> self_time = history_index == -1
-										? mRecording.getPeriodMean(time_block->selfTime()) 
+										? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) 
 										: mRecording.getPrevRecording(history_index).getSum(time_block->selfTime());
 
 	LLUnit<F32, LLUnits::Seconds> full_time = self_time;
 
 	// reserve a spot for this bar to be rendered before its children
 	// even though we don't know its size yet
-	std::vector<TimerBar>& bars = row.mBars;
-	S32 bar_index = bars.size();
-	bars.push_back(TimerBar());
+	TimerBar& timer_bar = row.mBars[bar_index];
+	bar_index++;
 
-	const bool children_visible = visible && !time_block->getCollapsed();
 	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
 	{
-		full_time += updateTimerBarWidths(*it, row, history_index, children_visible);
+		full_time += updateTimerBarWidths(*it, row, history_index, bar_index);
 	}
 
-	TimerBar& timer_bar = bars[bar_index];
 	timer_bar.mTotalTime  = full_time;
 	timer_bar.mSelfTime   = self_time;
 	timer_bar.mTimeBlock  = time_block;
-	timer_bar.mVisible    = visible;
 	
 	return full_time;
 }
@@ -1528,21 +1543,16 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 {
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS);
 
-	std::vector<TimerBar>& bars = row.mBars;
-	llassert(timer_bar_index < bars.size());
-	TimerBar& timer_bar = bars[timer_bar_index];
-	const LLUnit<F32, LLUnits::Seconds> child_time_width = timer_bar.mTotalTime - timer_bar.mSelfTime;
-	timer_bar.mChildrenStart = timer_bar.mSelfStart;
+	TimerBar& timer_bar = row.mBars[timer_bar_index];
+	const LLUnit<F32, LLUnits::Seconds> bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime;
+	timer_bar.mChildrenStart = timer_bar.mSelfStart + timer_bar.mSelfTime / 2;
+	timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime;
 
-	if (mDisplayCenter == ALIGN_CENTER)
+	if (timer_bar_index == 0)
 	{
-		timer_bar.mChildrenStart += timer_bar.mSelfTime / 2;
+		timer_bar.mSelfStart = 0.f;
+		timer_bar.mSelfEnd = bar_time;
 	}
-	else if (mDisplayCenter == ALIGN_RIGHT)
-	{
-		timer_bar.mChildrenStart += timer_bar.mSelfTime;
-	}
-	timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime;
 
 	//now loop through children and figure out portion of bar image covered by each bar, now that we know the
 	//sum of all children
@@ -1556,8 +1566,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 	{
 		timer_bar_index++;
 		
-		llassert(timer_bar_index < bars.size());
-		TimerBar& child_timer_bar = bars[timer_bar_index];
+		TimerBar& child_timer_bar = row.mBars[timer_bar_index];
 		TimeBlock* child_time_block = *it;
 
 		if (last_child_timer_bar)
@@ -1574,15 +1583,15 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 		}
 
 		child_timer_bar.mStartFraction = bar_fraction_start;
-		child_timer_bar.mEndFraction = child_time_width > 0
-										? bar_fraction_start + child_timer_bar.mTotalTime / child_time_width
+		child_timer_bar.mEndFraction = bar_time > 0
+										? bar_fraction_start + child_timer_bar.mTotalTime / bar_time
 										: 1.f;
-		child_timer_bar.mSelfStart = timer_bar.mChildrenStart 
-									+ child_timer_bar.mStartFraction 
-										* (timer_bar.mChildrenEnd - timer_bar.mChildrenStart);
-		child_timer_bar.mSelfEnd =	timer_bar.mChildrenStart 
-									+ child_timer_bar.mEndFraction 
-										* (timer_bar.mChildrenEnd - timer_bar.mChildrenStart);
+		child_timer_bar.mSelfStart = timer_bar.mChildrenStart 
+									+ child_timer_bar.mStartFraction 
+										* (timer_bar.mChildrenEnd - timer_bar.mChildrenStart);
+		child_timer_bar.mSelfEnd =	timer_bar.mChildrenStart 
+									+ child_timer_bar.mEndFraction 
+										* (timer_bar.mChildrenEnd - timer_bar.mChildrenStart);
 
 		timer_bar_index = updateTimerBarOffsets(child_time_block, row, timer_bar_index);
 
@@ -1591,16 +1600,15 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 	return timer_bar_index;
 }
 
-S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, S32 bar_index)
+S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, bool visible, S32 bar_index)
 {
-	llassert(bar_index < row.mBars.size());	
 	TimerBar& timer_bar = row.mBars[bar_index];
 	LLTrace::TimeBlock* time_block = timer_bar.mTimeBlock;
 
 	hovered |= mHoverID == time_block;
 
 	// animate scale of bar when hovering over that particular timer
-	if ((F32)bar_rect.getWidth() * (timer_bar.mEndFraction - timer_bar.mStartFraction) > 2.f)
+	if (visible && (F32)bar_rect.getWidth() * (timer_bar.mEndFraction - timer_bar.mStartFraction) > 2.f)
 	{
 		LLRect render_rect(bar_rect);
 		S32 scale_offset = 0;
@@ -1637,15 +1645,17 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width,
 		children_rect.mBottom = bar_rect.mBottom;
 	}
 
+	bool children_visible = visible && !time_block->getCollapsed();
+
 	bar_index++;
-	const U32 num_bars = row.mBars.size();
+	const U32 num_bars = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount();
 	if (bar_index < num_bars && row.mBars[bar_index].mFirstChild)
 	{
 		bool is_last = false;
 		do
 		{
 			is_last = row.mBars[bar_index].mLastChild;
-			bar_index = drawBar(children_rect, row, image_width, image_height, hovered, bar_index);
+			bar_index = drawBar(children_rect, row, image_width, image_height, hovered, children_visible, bar_index);
 		}
 		while(!is_last && bar_index < num_bars);
 	}
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index d9ae6348da..d931f25a7e 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -68,8 +68,8 @@ private:
 	virtual	void	onClickCloseBtn();
 	void drawTicks();
 	void drawLineGraph();
-	void drawLegend(S32 y);
-	S32 drawHelp(S32 y);
+	void drawLegend();
+	void drawHelp(S32 y);
 	void drawBorders( S32 y, const S32 x_start, S32 barh, S32 dy);
 	void drawBars();
 
@@ -82,7 +82,6 @@ private:
 		TimerBar()
 		:	mTotalTime(0),
 			mSelfTime(0),
-			mVisible(true),
 			mStartFraction(0.f),
 			mEndFraction(1.f),
 			mFirstChild(false),
@@ -104,29 +103,26 @@ private:
 
 	struct TimerBarRow
 	{
-		S32						mBottom,
-								mTop;
-		std::vector<TimerBar>	mBars;
+		S32			mBottom,
+					mTop;
+		TimerBar*	mBars;
 	};
 
-	LLUnit<F32, LLUnits::Seconds> updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, bool visible = true);
+	LLUnit<F32, LLUnits::Seconds> updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
 	S32 updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
-	S32 drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, S32 bar_index = 0);
+	S32 drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, bool visible = true, S32 bar_index = 0);
 	void setPauseState(bool pause_state);
 
 	std::deque<TimerBarRow> mTimerBarRows;
 	TimerBarRow				mAverageTimerRow;
 
-	enum ChildAlignment
+	enum EDisplayType
 	{
-		ALIGN_LEFT,
-		ALIGN_CENTER,
-		ALIGN_RIGHT,
-		ALIGN_COUNT
-	}								mDisplayCenter;
-	bool							mDisplayCalls,
-									mDisplayHz,
-									mPauseHistory;
+		TIME,
+		CALLS,
+		HZ
+	}								mDisplayType;
+	bool							mPauseHistory;
 	LLUnit<F64, LLUnits::Seconds>	mAllTimeMax,
 									mTotalTimeDisplay;
 	S32								mScrollIndex,
@@ -137,7 +133,8 @@ private:
 	LLTrace::TimeBlock*				mHoverTimer;
 	LLRect							mToolTipRect,
 									mGraphRect,
-									mBarRect;
+									mBarRect,
+									mLegendRect;
 	LLFrameTimer					mHighlightTimer;
 	LLTrace::PeriodicRecording		mRecording;
 };
diff --git a/indra/newview/skins/default/xui/en/floater_fast_timers.xml b/indra/newview/skins/default/xui/en/floater_fast_timers.xml
index 77adb5524e..671f116df3 100755
--- a/indra/newview/skins/default/xui/en/floater_fast_timers.xml
+++ b/indra/newview/skins/default/xui/en/floater_fast_timers.xml
@@ -16,6 +16,27 @@
  width="700">
   <string name="pause" >Pause</string>
   <string name="run">Run</string>
+  <combo_box name="time_scale_combo"
+             follows="left|top"
+             left="10"
+             top="5"
+             width="150"
+             height="20">
+    <item label="2x Average"/>
+    <item label="Max"/>
+    <item label="Recent Max"/>
+    <item label="100ms"/>
+  </combo_box>
+  <combo_box name="metric_combo"
+             follows="left|top"
+             left_pad="10"
+             top="5"
+             width="150"
+             height="20">
+    <item label="Time"/>
+    <item label="Number of Calls"/>
+    <item label="Hz"/>
+  </combo_box>
   <button follows="top|right" 
           name="pause_btn"
           left="-200"
@@ -24,4 +45,52 @@
           height="40"
           label="Pause"
           font="SansSerifHuge"/>
+  <layout_stack name="legend_stack"
+                orientation="horizontal"
+                left="0"
+                top="50"
+                right="695"
+                bottom="500"
+                follows="all">
+    <layout_panel name="legend_panel"
+                  auto_resize="false"
+                  user_resize="true"
+                  width="220"
+                  height="450"
+                  min_width="100">
+      <panel top="0"
+             left="0"
+             width="220"
+             height="440"
+             name="legend"
+             follows="all"/>
+    </layout_panel>
+    <layout_panel name="timers_panel"
+                  auto_resize="true"
+                  user_resize="true"
+                  height="450"
+                  width="475"
+                  min_width="100">
+      <layout_stack name="timer_bars_stack"
+                    orientation="vertical"
+                    left="0"
+                    top="0"
+                    width="475"
+                    height="445"
+                    follows="all">
+        <layout_panel name="bars_panel"
+                      auto_resize="true"
+                      user_resize="true"
+                      top="0"
+                      width="475"
+                      height="210"/>
+        <layout_panel name="lines_panel"
+                      auto_resize="false"
+                      user_resize="true"
+                      width="475"
+                      min_height="50"
+                      height="240"/>
+      </layout_stack>
+    </layout_panel>
+  </layout_stack>
 </floater>
-- 
cgit v1.2.3


From c5fc8f90060aa7a6c8fbb72313172423b01eddc5 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 19 Jun 2013 08:23:53 -0700
Subject: SH-4246 FIX interesting: fast timers significantly decreases
 framerate moved collapsed flag to fast timer tree node

---
 indra/newview/llappviewer.cpp     |  2 +-
 indra/newview/lldrawable.cpp      |  2 +-
 indra/newview/llfasttimerview.cpp | 28 ++++++++++++++--------------
 indra/newview/llviewerdisplay.cpp |  2 +-
 4 files changed, 17 insertions(+), 17 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ef24ba21ee..8c51bd4198 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1248,7 +1248,7 @@ static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback");
 static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
 static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
 
-LLFastTimer::DeclareTimer FTM_FRAME("Frame", true);
+LLFastTimer::DeclareTimer FTM_FRAME("Frame");
 
 bool LLAppViewer::mainLoop()
 {
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 22a7c350d6..8430c32551 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -300,7 +300,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep)
 	return count;
 }
 
-static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face", true);
+static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face");
 
 LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)
 {
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 1355b58f8b..ec307b841e 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -152,13 +152,13 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	if (mHoverTimer )
 	{
 		// right click collapses timers
-		if (!mHoverTimer->getCollapsed())
+		if (!mHoverTimer->getTreeNode().mCollapsed)
 		{
-			mHoverTimer->setCollapsed(true);
+			mHoverTimer->getTreeNode().mCollapsed = true;
 		}
 		else if (mHoverTimer->getParent())
 		{
-			mHoverTimer->getParent()->setCollapsed(true);
+			mHoverTimer->getParent()->getTreeNode().mCollapsed = true;
 		}
 		return TRUE;
 	}
@@ -190,7 +190,7 @@ BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask)
 		it != end_timer_tree();
 		++it)
 	{
-		(*it)->setCollapsed(false);
+		(*it)->getTreeNode().mCollapsed = false;
 	}
 	return TRUE;
 }
@@ -202,13 +202,13 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 		TimeBlock* idp = getLegendID(y);
 		if (idp)
 		{
-			idp->setCollapsed(!idp->getCollapsed());
+			idp->getTreeNode().mCollapsed = !idp->getTreeNode().mCollapsed;
 		}
 	}
 	else if (mHoverTimer)
 	{
 		//left click drills down by expanding timers
-		mHoverTimer->setCollapsed(false);
+		mHoverTimer->getTreeNode().mCollapsed = false;
 	}
 	else if (mGraphRect.pointInRect(x, y))
 	{
@@ -273,7 +273,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 			if (bar.mSelfEnd > mouse_time_offset)
 			{
 				hover_bar = &bar;
-				if (bar.mTimeBlock->getCollapsed())
+				if (bar.mTimeBlock->getTreeNode().mCollapsed)
 				{
 					// stop on first collapsed timeblock, since we can't select any children
 					break;
@@ -373,7 +373,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	return TRUE;
 }
 
-static TimeBlock FTM_RENDER_TIMER("Timers", true);
+static TimeBlock FTM_RENDER_TIMER("Timers");
 static const S32 MARGIN = 10;
 static const S32 LEGEND_WIDTH = 220;
 
@@ -975,7 +975,7 @@ void LLFastTimerView::printLineStats()
 			first = false;
 			legend_stat += idp->getName();
 
-			if (idp->getCollapsed())
+			if (idp->getTreeNode().mCollapsed)
 			{
 				it.skipDescendants();
 			}
@@ -1009,7 +1009,7 @@ void LLFastTimerView::printLineStats()
 
 			timer_stat += llformat("%.1f",ms.value());
 
-			if (idp->getCollapsed())
+			if (idp->getTreeNode().mCollapsed)
 			{
 				it.skipDescendants();
 			}
@@ -1135,7 +1135,7 @@ void LLFastTimerView::drawLineGraph()
 			glLineWidth(1);
 		}
 
-		if (idp->getCollapsed())
+		if (idp->getTreeNode().mCollapsed)
 		{	
 			//skip hidden timers
 			it.skipDescendants();
@@ -1267,7 +1267,7 @@ void LLFastTimerView::drawLegend()
 				gl_line_2d(x + dx - 8, line_start_y, x + dx, line_start_y, color);
 				S32 line_x = x + (TEXT_HEIGHT + 4) + ((get_depth(idp) - 1) * 8);
 				gl_line_2d(line_x, line_start_y, line_x, line_end_y, color);
-				if (idp->getCollapsed() && !idp->getChildren().empty())
+				if (idp->getTreeNode().mCollapsed && !idp->getChildren().empty())
 				{
 					gl_line_2d(line_x+4, line_start_y-3, line_x+4, line_start_y+4, color);
 				}
@@ -1291,7 +1291,7 @@ void LLFastTimerView::drawLegend()
 
 			y -= (TEXT_HEIGHT + 2);
 
-			if (idp->getCollapsed()) 
+			if (idp->getTreeNode().mCollapsed) 
 			{
 				it.skipDescendants();
 			}
@@ -1645,7 +1645,7 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width,
 		children_rect.mBottom = bar_rect.mBottom;
 	}
 
-	bool children_visible = visible && !time_block->getCollapsed();
+	bool children_visible = visible && !time_block->getTreeNode().mCollapsed;
 
 	bar_index++;
 	const U32 num_bars = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount();
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 7ad4743d82..bd85056d70 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -210,7 +210,7 @@ void display_stats()
 }
 
 static LLFastTimer::DeclareTimer FTM_PICK("Picking");
-static LLFastTimer::DeclareTimer FTM_RENDER("Render", true);
+static LLFastTimer::DeclareTimer FTM_RENDER("Render");
 static LLFastTimer::DeclareTimer FTM_UPDATE_SKY("Update Sky");
 static LLFastTimer::DeclareTimer FTM_UPDATE_TEXTURES("Update Textures");
 static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE("Update Images");
-- 
cgit v1.2.3


From b38170e6817b3f69274d9b5953584a1278a17ca2 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 19 Jun 2013 11:45:44 -0600
Subject: fix for SH-4245: Interesting: crash in
 LLSpatialGroup::handleDestruction

---
 indra/newview/llspatialpartition.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 45130efeb9..b9d4c016c2 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -841,11 +841,16 @@ void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* en
 
 void LLSpatialGroup::handleDestruction(const TreeNode* node)
 {
+	if(isDead())
+	{
+		return;
+	}
 	setState(DEAD);
 	
-	for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
+	for (element_iter i = getDataBegin(); getElementCount() > 0 && i != getDataEnd();)
 	{
 		LLViewerOctreeEntry* entry = *i;
+
 		if (entry->getGroup() == this)
 		{
 			if(entry->hasDrawable())
@@ -853,10 +858,14 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
 				((LLDrawable*)entry->getDrawable())->setGroup(NULL);
 			}
 			else
-		{
+			{
 				llerrs << "No Drawable found in the entry." << llendl;
 			}
 		}
+		else
+		{
+			++i;
+		}
 	}
 	
 	//clean up avatar attachment stats
-- 
cgit v1.2.3


From 3fe19d883d2856cd7d104810b794eee82d642a3e Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 19 Jun 2013 20:30:41 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 scene monitor output is cleaned up, no duplicate first frame, less scientific
 notation periodic recording extension now works more cleanly

---
 indra/newview/llfasttimerview.h  | 11 ++++++++---
 indra/newview/llscenemonitor.cpp | 26 +++++++++++++++-----------
 indra/newview/llscenemonitor.h   |  2 +-
 3 files changed, 24 insertions(+), 15 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index d931f25a7e..9d88bb2d3f 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -103,6 +103,11 @@ private:
 
 	struct TimerBarRow
 	{
+		TimerBarRow() 
+		:	mBottom(0),
+			mTop(0),
+			mBars(NULL)
+		{}
 		S32			mBottom,
 					mTop;
 		TimerBar*	mBars;
@@ -118,9 +123,9 @@ private:
 
 	enum EDisplayType
 	{
-		TIME,
-		CALLS,
-		HZ
+		DISPLAY_TIME,
+		DISPLAY_CALLS,
+		DISPLAY_HZ
 	}								mDisplayType;
 	bool							mPauseHistory;
 	LLUnit<F64, LLUnits::Seconds>	mAllTimeMax,
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 8086745471..ed9eeb9330 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -500,7 +500,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 	std::ofstream os(file_name.c_str());
 
-	os << std::setprecision(3);
+	os << std::setprecision(10);
 
 	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording();
 	const U32 frame_count = scene_load_recording.getNumRecordedPeriods();
@@ -508,12 +508,12 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	LLUnit<F64, LLUnits::Seconds> frame_time;
 
 	os << "Stat";
-	for (S32 frame = 0; frame < frame_count; frame++)
+	for (S32 frame = 1; frame <= frame_count; frame++)
 	{
 		frame_time += scene_load_recording.getPrevRecording(frame_count - frame).getDuration();
 		os << ", " << frame_time.value();
 	}
-	os << std::endl;
+	os << '\n';
 
 	typedef TraceType<CountAccumulator> trace_count;
 	for (trace_count::instance_iter it = trace_count::beginInstances(), end_it = trace_count::endInstances();
@@ -521,6 +521,8 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		++it)
 	{
 		std::ostringstream row;
+		row << std::setprecision(10);
+
 		row << it->getName();
 
 		const char* unit_label = it->getUnitLabel();
@@ -531,13 +533,13 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		S32 samples = 0;
 
-		for (S32 frame = 0; frame < frame_count; frame++)
+		for (S32 frame = 1; frame <= frame_count; frame++)
 		{
 			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
 			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it);
 		}
 
-		row << std::endl;
+		row << '\n';
 
 		if (samples > 0)
 		{
@@ -552,6 +554,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		++it)
 	{
 		std::ostringstream row;
+		row << std::setprecision(10);
 		row << it->getName();
 
 		const char* unit_label = it->getUnitLabel();
@@ -562,13 +565,13 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		S32 samples = 0;
 
-		for (S32 frame = 0; frame < frame_count; frame++)
+		for (S32 frame = 1; frame <= frame_count; frame++)
 		{
 			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
 			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it);
 		}
 
-		row << std::endl;
+		row << '\n';
 
 		if (samples > 0)
 		{
@@ -583,6 +586,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 		++it)
 	{
 		std::ostringstream row;
+		row << std::setprecision(10);
 		row << it->getName();
 
 		const char* unit_label = it->getUnitLabel();
@@ -593,13 +597,13 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		S32 samples = 0;
 
-		for (S32 frame = 0; frame < frame_count; frame++)
+		for (S32 frame = 1; frame <= frame_count; frame++)
 		{
 			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
 			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it);
 		}
 
-		row << std::endl;
+		row << '\n'; 
 
 		if (samples > 0)
 		{
@@ -614,12 +618,12 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	{
 		os << it->getName() << "(KiB)";
 
-		for (S32 frame = 0; frame < frame_count; frame++)
+		for (S32 frame = 1; frame <= frame_count; frame++)
 		{
 			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).getAs<LLUnits::Kibibytes>();
 		}
 
-		os << std::endl;
+		os << '\n';
 	}
 
 	os.flush();
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 6af58b707a..9717310da4 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -37,7 +37,7 @@ class LLCharacter;
 class LLRenderTarget;
 class LLViewerTexture;
 
-class LLSceneMonitor :  public LLSingleton<LLSceneMonitor>
+class LLSceneMonitor : public LLSingleton<LLSceneMonitor>
 {
 	LOG_CLASS(LLSceneMonitor);
 public:
-- 
cgit v1.2.3


From ba9bffd0195e6606daa39760eec75ede954b4040 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 19 Jun 2013 20:39:59 -0700
Subject: BUILDFIX: forgot a file

---
 indra/newview/llfasttimerview.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index ec307b841e..f956851129 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -99,7 +99,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key)
 :	LLFloater(key),
 	mHoverTimer(NULL),
 	mDisplayMode(0),
-	mDisplayType(TIME),
+	mDisplayType(DISPLAY_TIME),
 	mScrollIndex(0),
 	mHoverID(NULL),
 	mHoverBarIndex(-1),
@@ -1114,13 +1114,13 @@ void LLFastTimerView::drawLineGraph()
 			F32 y;
 			switch(mDisplayType)
 			{
-			case TIME:
+			case DISPLAY_TIME:
 				y = mGraphRect.mBottom + time.value() * time_scale_factor;
 				break;
-			case CALLS:
+			case DISPLAY_CALLS:
 				y = mGraphRect.mBottom + (F32)calls * call_scale_factor;
 				break;
-			case HZ:
+			case DISPLAY_HZ:
 				y = mGraphRect.mBottom + (1.f / time.value()) * hz_scale_factor;
 				break;
 			}
@@ -1178,13 +1178,13 @@ void LLFastTimerView::drawLineGraph()
 	std::string axis_label;
 	switch(mDisplayType)
 	{
-	case TIME:
+	case DISPLAY_TIME:
 		axis_label = llformat("%4.2f ms", LLUnit<F32, LLUnits::Milliseconds>(max_time).value());
 		break;
-	case CALLS:
+	case DISPLAY_CALLS:
 		axis_label = llformat("%d calls", (int)max_calls);
 		break;
-	case HZ:
+	case DISPLAY_HZ:
 		axis_label = llformat("%4.2f Hz", max_time.value() ? 1.f / max_time.value() : 0.f);
 		break;
 	}
@@ -1247,13 +1247,13 @@ void LLFastTimerView::drawLegend()
 			std::string timer_label;
 			switch(mDisplayType)
 			{
-			case TIME:
+			case DISPLAY_TIME:
 				timer_label = llformat("%s [%.1f]",idp->getName().c_str(),ms.value());
 				break;
-			case CALLS:
+			case DISPLAY_CALLS:
 				timer_label = llformat("%s (%d)",idp->getName().c_str(),calls);
 				break;
-			case HZ:
+			case DISPLAY_HZ:
 				timer_label = llformat("%.1f", ms.value() ? (1.f / ms.value()) : 0.f);
 				break;
 			}
-- 
cgit v1.2.3


From 92339583e6454bd6e769a6dcb0ad2eee31abfb1f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 21 Jun 2013 13:02:20 -0600
Subject: for SH-4241: viewer crash shortly after login in
 LLViewerRegion::addNewObject

---
 indra/newview/llviewerregion.cpp | 2 +-
 indra/newview/llvocache.cpp      | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index a2fd440895..c3c791c158 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -992,7 +992,7 @@ void LLViewerRegion::removeFromVOCacheTree(LLVOCacheEntry* entry)
 //add the visible entries
 void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 {
-	if(mDead || !entry)
+	if(mDead || !entry || !entry->getEntry())
 	{
 		return; 
 	}
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 93daf2e171..216a91e1dc 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -244,6 +244,13 @@ U32  LLVOCacheEntry::getMinFrameRange()const
 void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 {
 	llassert(entry != NULL);
+	llassert(entry->getParentID() == mLocalID);
+	llassert(entry->getEntry() != NULL);
+
+	if(!entry || !entry->getEntry() || entry->getParentID() != mLocalID)
+	{
+		return;
+	}
 
 	mChildrenList.push_back(entry);
 }
-- 
cgit v1.2.3


From 916b68d1cb706b2dc469219f1976f10baadaea08 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 21 Jun 2013 14:32:26 -0600
Subject: trivial: convert to unix line endings.

---
 indra/newview/llvocache.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 216a91e1dc..b3c7b80c29 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -244,7 +244,7 @@ U32  LLVOCacheEntry::getMinFrameRange()const
 void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 {
 	llassert(entry != NULL);
-	llassert(entry->getParentID() == mLocalID);
+	llassert(entry->getParentID() == mLocalID);
 	llassert(entry->getEntry() != NULL);
 
 	if(!entry || !entry->getEntry() || entry->getParentID() != mLocalID)
-- 
cgit v1.2.3


From fe3cfb30d504155850ddf3752d2f55e6311990d6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 22 Jun 2013 00:34:25 -0700
Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics
 removed LLTrace unit typedefs

---
 indra/newview/lltextureview.cpp       |  4 +-
 indra/newview/llviewerassetstats.cpp  |  6 +--
 indra/newview/llviewerobject.cpp      |  2 +-
 indra/newview/llviewerstats.cpp       | 84 +++++++++++++++---------------
 indra/newview/llviewerstats.h         | 97 +++++++++++++++++------------------
 indra/newview/llviewertexturelist.cpp |  8 +--
 indra/newview/llvoavatarself.cpp      |  2 +-
 indra/newview/llworld.cpp             |  6 +--
 8 files changed, 104 insertions(+), 105 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 18df9a7b54..72ed3d4485 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -512,8 +512,8 @@ void LLGLTexMemBar::draw()
 	LLUnit<S32, LLUnits::Mibibytes> total_mem = LLViewerTexture::sTotalTextureMemory;
 	LLUnit<S32, LLUnits::Mibibytes> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;
-	F32 cache_usage = (F32)LLTrace::Mibibytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
-	F32 cache_max_usage = (F32)LLTrace::Mibibytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
+	F32 cache_usage = (F32)LLUnit<F32, LLUnits::Mibibytes>(LLAppViewer::getTextureCache()->getUsage()).value() ;
+	F32 cache_max_usage = (F32)LLUnit<F32, LLUnits::Mibibytes>(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
 	LLUnit<F32, LLUnits::Bytes> total_texture_downloaded = gTotalTextureData;
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index bada565d3d..6ab2aefc34 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -233,7 +233,7 @@ namespace LLViewerAssetStatsFF
 		&sDequeuedAssetRequestsOther            
 	};
 
-	static LLTrace::EventStatHandle<LLTrace::Seconds>	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp",
+	static LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp",
 																							"Time spent responding to temporary texture asset http requests"),
 													sResponseAssetRequestsTempTextureUDP    ("assetresponsetimestemptextureudp", 
 																							"Time spent responding to temporary texture asset udp requests"),
@@ -250,7 +250,7 @@ namespace LLViewerAssetStatsFF
 													sResponsedAssetRequestsOther            ("assetresponsetimesother", 
 																							"Time spent responding to other asset requests");
 
-	static LLTrace::EventStatHandle<LLTrace::Seconds>* sResponse[EVACCount] = {
+	static LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >* sResponse[EVACCount] = {
 		&sResponseAssetRequestsTempTextureHTTP,   
 		&sResponseAssetRequestsTempTextureUDP,  
 		&sResponseAssetRequestsNonTempTextureHTTP,
@@ -539,7 +539,7 @@ void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp,
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	record(*sResponse[int(eac)], LLTrace::Microseconds(duration));
+	record(*sResponse[int(eac)], LLUnit<F64, LLUnits::Microseconds>(duration));
 }
 
 void init()
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 6362ccfba6..5ae08a8b9e 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -2262,7 +2262,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		// If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps
 		if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
 		{
-			record(LLStatViewer::AGENT_POSITION_SNAP, LLTrace::Meters(diff.length()));
+			record(LLStatViewer::AGENT_POSITION_SNAP, LLUnit<F64, LLUnits::Meters>(diff.length()));
 		}
 	}
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 7ddee48b38..3d4c75cec3 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -89,17 +89,17 @@ LLTrace::CountStatHandle<>	FPS("framesrendered"),
 							TEX_BAKES("texbakes"),
 							TEX_REBAKES("texrebakes"),
 							NUM_NEW_OBJECTS("numnewobjectsstat");
-LLTrace::CountStatHandle<LLTrace::Kibibits>	KBIT("kbitstat"),
-											LAYERS_KBIT("layerskbitstat"),
-											OBJECT_KBIT("objectkbitstat"),
-											ASSET_KBIT("assetkbitstat"),
-											TEXTURE_KBIT("texturekbitstat"),
-											ACTUAL_IN_KBIT("actualinkbitstat"),
-											ACTUAL_OUT_KBIT("actualoutkbitstat");
-
-LLTrace::CountStatHandle<LLTrace::Seconds>	SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
-											SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
-											LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
+LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibits> >	KBIT("kbitstat"),
+															LAYERS_KBIT("layerskbitstat"),
+															OBJECT_KBIT("objectkbitstat"),
+															ASSET_KBIT("assetkbitstat"),
+															TEXTURE_KBIT("texturekbitstat"),
+															ACTUAL_IN_KBIT("actualinkbitstat"),
+															ACTUAL_OUT_KBIT("actualoutkbitstat");
+
+LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >	SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
+															SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
+															LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
 
 SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DILATION),
 							SIM_FPS("simfps", "", LL_SIM_STAT_FPS),
@@ -141,15 +141,15 @@ LLTrace::SampleStatHandle<>	FPS_SAMPLE("fpssample"),
 	
 static LLTrace::SampleStatHandle<S64> CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled");
 
-LLTrace::SampleStatHandle<LLTrace::Bytes>	GL_TEX_MEM("gltexmemstat"),
-											GL_BOUND_MEM("glboundmemstat"),
-											RAW_MEM("rawmemstat"),
-											FORMATTED_MEM("formattedmemstat"),
-											DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
-											MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
+LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Megabytes> >	GL_TEX_MEM("gltexmemstat"),
+															GL_BOUND_MEM("glboundmemstat"),
+															RAW_MEM("rawmemstat"),
+															FORMATTED_MEM("formattedmemstat");
+LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
+															MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
 
 	
-SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
+SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
 										SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS),
 										SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS),
 										SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS),
@@ -164,18 +164,18 @@ SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME("simframemsec", "", LL_SIM_
 										SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
 										SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
 	
-SimMeasurement<LLTrace::Bytes>	SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES),
-								SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
+SimMeasurement<LLUnit<F64, LLUnits::Bytes> >	SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES),
+												SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
 
-LLTrace::SampleStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
 													FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
 													SIM_PING("simpingstat");
 
-LLTrace::EventStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
+LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Meters> > AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
 
 LLTrace::EventStatHandle<>	LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load");
 	
-LLTrace::EventStatHandle<LLTrace::Milliseconds>	REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
+LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
 												FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
 												UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
 												NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
@@ -183,12 +183,12 @@ LLTrace::EventStatHandle<LLTrace::Milliseconds>	REGION_CROSSING_TIME("regioncros
 												REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
 												RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
 	
-LLTrace::EventStatHandle<LLTrace::Seconds>	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
-											TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
-											MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
-											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<LLUnit<F64, LLUnits::Seconds> >	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
+															TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
+															MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
+															FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
+															FPS_8_TIME("fps8time", "Seconds below 8 FPS"),
+															FPS_2_TIME("fps2time", "Seconds below 2 FPS");
 
 
 }
@@ -211,7 +211,7 @@ void LLViewerStats::resetStats()
 
 void LLViewerStats::updateFrameStats(const F64 time_diff)
 {
-	LLTrace::Seconds time_diff_seconds(time_diff);
+	LLUnit<F64, LLUnits::Seconds> time_diff_seconds(time_diff);
 	if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0)
 	{
 		add(LLStatViewer::LOSS_5_PERCENT_TIME, time_diff_seconds);
@@ -249,15 +249,15 @@ void LLViewerStats::updateFrameStats(const F64 time_diff)
 		add(LLStatViewer::FRAMETIME_DOUBLED, time_diff >= 2.0 * mLastTimeDiff ? 1 : 0);
 
 		// old stats that were never really used
-		sample(LLStatViewer::FRAMETIME_JITTER, LLTrace::Milliseconds(mLastTimeDiff - time_diff));
+		sample(LLStatViewer::FRAMETIME_JITTER, LLUnit<F64, LLUnits::Milliseconds> (mLastTimeDiff - time_diff));
 			
 		F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
-		sample(LLStatViewer::FRAMETIME_SLEW, LLTrace::Milliseconds(average_frametime - time_diff));
+		sample(LLStatViewer::FRAMETIME_SLEW, LLUnit<F64, LLUnits::Milliseconds> (average_frametime - time_diff));
 
 		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
 		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
-		sample(LLStatViewer::DELTA_BANDWIDTH, LLTrace::Bits(delta_bandwidth));
-		sample(LLStatViewer::MAX_BANDWIDTH, LLTrace::Bits(max_bandwidth));
+		sample(LLStatViewer::DELTA_BANDWIDTH, LLUnit<F64, LLUnits::Bits>(delta_bandwidth));
+		sample(LLStatViewer::MAX_BANDWIDTH, LLUnit<F64, LLUnits::Bits>(max_bandwidth));
 	}
 	
 	mLastTimeDiff = time_diff;
@@ -347,13 +347,13 @@ void update_statistics()
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
-		sample(LLStatViewer::SIM_PING, LLTrace::Milliseconds(cdp->getPingDelay()));
+		sample(LLStatViewer::SIM_PING, LLUnit<F64, LLUnits::Milliseconds> (cdp->getPingDelay()));
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
-		sample(LLStatViewer::SIM_PING, LLTrace::Seconds(10));
+		sample(LLStatViewer::SIM_PING, LLUnit<F64, LLUnits::Seconds>(10));
 	}
 
 	if (LLViewerStats::instance().getRecording().getSum(LLStatViewer::FPS))
@@ -363,10 +363,10 @@ void update_statistics()
 	add(LLStatViewer::FPS, 1);
 
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	add(LLStatViewer::LAYERS_KBIT, LLTrace::Bits(layer_bits));
+	add(LLStatViewer::LAYERS_KBIT, LLUnit<F64, LLUnits::Bits>(layer_bits));
 	add(LLStatViewer::OBJECT_KBIT, gObjectData);
 	sample(LLStatViewer::PENDING_VFS_OPERATIONS, LLVFile::getVFSThread()->getPending());
-	add(LLStatViewer::ASSET_KBIT, LLTrace::Bits(gTransferManager.getTransferBitsIn(LLTCT_ASSET)));
+	add(LLStatViewer::ASSET_KBIT, LLUnit<F64, LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)));
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
 	if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
@@ -403,7 +403,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			gTotalTextureData = LLTrace::Bytes(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT));
+			gTotalTextureData = LLUnit<F64, LLUnits::Bytes>(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT));
 			texture_stats_timer.reset();
 		}
 	}
@@ -552,9 +552,9 @@ void send_stats()
 
 	LLSD &download = body["downloads"];
 
-	download["world_kbytes"] = LLTrace::Kibibytes(gTotalWorldData).value();
-	download["object_kbytes"] = LLTrace::Kibibytes(gTotalObjectData).value();
-	download["texture_kbytes"] = LLTrace::Kibibytes(gTotalTextureData).value();
+	download["world_kbytes"] = LLUnit<F64, LLUnits::Kibibytes>(gTotalWorldData).value();
+	download["object_kbytes"] = LLUnit<F64, LLUnits::Kibibytes>(gTotalObjectData).value();
+	download["texture_kbytes"] = LLUnit<F64, LLUnits::Kibibytes>(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 4e48a61264..879f0067b9 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -94,17 +94,17 @@ extern LLTrace::CountStatHandle<>			FPS,
 											NUM_NEW_OBJECTS;
 
 
-extern LLTrace::CountStatHandle<LLTrace::Kibibits>	KBIT,
-											LAYERS_KBIT,
-											OBJECT_KBIT,
-											ASSET_KBIT,
-											TEXTURE_KBIT,
-											ACTUAL_IN_KBIT,
-											ACTUAL_OUT_KBIT;
-
-extern LLTrace::CountStatHandle<LLTrace::Seconds>		SIM_20_FPS_TIME,
-														SIM_PHYSICS_20_FPS_TIME,
-														LOSS_5_PERCENT_TIME;
+extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibits> >	KBIT,
+																	LAYERS_KBIT,
+																	OBJECT_KBIT,
+																	ASSET_KBIT,
+																	TEXTURE_KBIT,
+																	ACTUAL_IN_KBIT,
+																	ACTUAL_OUT_KBIT;
+
+extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >		SIM_20_FPS_TIME,
+																	SIM_PHYSICS_20_FPS_TIME,
+																	LOSS_5_PERCENT_TIME;
 
 extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_FPS,
@@ -144,41 +144,40 @@ extern LLTrace::SampleStatHandle<>		FPS_SAMPLE,
 										WINDOW_WIDTH,
 										WINDOW_HEIGHT;
 
-extern LLTrace::SampleStatHandle<LLTrace::Bytes>	DELTA_BANDWIDTH,
-													MAX_BANDWIDTH,
-													GL_TEX_MEM,
-													GL_BOUND_MEM,
-													RAW_MEM,
-													FORMATTED_MEM;
-
-extern SimMeasurement<LLTrace::Milliseconds>	SIM_FRAME_TIME,
-												SIM_NET_TIME,
-												SIM_OTHER_TIME,
-												SIM_PHYSICS_TIME,
-												SIM_PHYSICS_STEP_TIME,
-												SIM_PHYSICS_SHAPE_UPDATE_TIME,
-												SIM_PHYSICS_OTHER_TIME,
-												SIM_AI_TIME,
-												SIM_AGENTS_TIME,
-												SIM_IMAGES_TIME,
-												SIM_SCRIPTS_TIME,
-												SIM_SPARE_TIME,
-												SIM_SLEEP_TIME,
-												SIM_PUMP_IO_TIME;
-
-extern SimMeasurement<LLTrace::Bytes>			SIM_UNACKED_BYTES,
-												SIM_PHYSICS_MEM;
-
-
-extern LLTrace::SampleStatHandle<LLTrace::Milliseconds>	FRAMETIME_JITTER,
-														FRAMETIME_SLEW,
-														SIM_PING;
-
-extern LLTrace::EventStatHandle<LLTrace::Meters> AGENT_POSITION_SNAP;
+extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Megabytes> >	GL_TEX_MEM,
+																	GL_BOUND_MEM,
+																	RAW_MEM,
+																	FORMATTED_MEM;
+extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	DELTA_BANDWIDTH,
+																	MAX_BANDWIDTH;
+extern SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME,
+															SIM_NET_TIME,
+															SIM_OTHER_TIME,
+															SIM_PHYSICS_TIME,
+															SIM_PHYSICS_STEP_TIME,
+															SIM_PHYSICS_SHAPE_UPDATE_TIME,
+															SIM_PHYSICS_OTHER_TIME,
+															SIM_AI_TIME,
+															SIM_AGENTS_TIME,
+															SIM_IMAGES_TIME,
+															SIM_SCRIPTS_TIME,
+															SIM_SPARE_TIME,
+															SIM_SLEEP_TIME,
+															SIM_PUMP_IO_TIME;
+
+extern SimMeasurement<LLUnit<F64, LLUnits::Bytes> >	SIM_UNACKED_BYTES,
+													SIM_PHYSICS_MEM;
+
+
+extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	FRAMETIME_JITTER,
+																		FRAMETIME_SLEW,
+																		SIM_PING;
+
+extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Meters> > AGENT_POSITION_SNAP;
 
 extern LLTrace::EventStatHandle<>	LOADING_WEARABLES_LONG_DELAY;
 
-extern LLTrace::EventStatHandle<LLTrace::Milliseconds>	REGION_CROSSING_TIME,
+extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROSSING_TIME,
 														FRAME_STACKTIME,
 														UPDATE_STACKTIME,
 														NETWORK_STACKTIME,
@@ -186,12 +185,12 @@ extern LLTrace::EventStatHandle<LLTrace::Milliseconds>	REGION_CROSSING_TIME,
 														REBUILD_STACKTIME,
 														RENDER_STACKTIME;
 
-extern LLTrace::EventStatHandle<LLTrace::Seconds>	AVATAR_EDIT_TIME,
-													TOOLBOX_TIME,
-													MOUSELOOK_TIME,
-													FPS_10_TIME,
-													FPS_8_TIME,
-													FPS_2_TIME;
+extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >	AVATAR_EDIT_TIME,
+																TOOLBOX_TIME,
+																MOUSELOOK_TIME,
+																FPS_10_TIME,
+																FPS_8_TIME,
+																FPS_2_TIME;
 
 }
 
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 5003ec7e7b..431a3b330c 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -671,8 +671,8 @@ void LLViewerTextureList::updateImages(F32 max_time)
 		sample(NUM_RAW_IMAGES, LLImageRaw::sRawImageCount);
 		sample(GL_TEX_MEM, LLImageGL::sGlobalTextureMemory);
 		sample(GL_BOUND_MEM, LLImageGL::sBoundTextureMemory);
-		sample(RAW_MEM, LLTrace::Bytes(LLImageRaw::sGlobalRawMemory));
-		sample(FORMATTED_MEM, LLTrace::Bytes(LLImageFormatted::sGlobalFormattedMemory));
+		sample(RAW_MEM, LLUnit<F64, LLUnits::Bytes>(LLImageRaw::sGlobalRawMemory));
+		sample(FORMATTED_MEM, LLUnit<F64, LLUnits::Bytes>(LLImageFormatted::sGlobalFormattedMemory));
 	}
 
 	{
@@ -1374,7 +1374,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	add(LLStatViewer::TEXTURE_KBIT, LLTrace::Bytes(received_size));
+	add(LLStatViewer::TEXTURE_KBIT, LLUnit<F64, LLUnits::Bytes>(received_size));
 	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	U8 codec;
@@ -1448,7 +1448,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 		received_size = msg->getReceiveSize() ;		
 	}
 
-	add(LLStatViewer::TEXTURE_KBIT, LLTrace::Bytes(received_size));
+	add(LLStatViewer::TEXTURE_KBIT, LLUnit<F64, LLUnits::Bytes>(received_size));
 	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	//llprintline("Start decode, image header...");
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 7d99b11360..67da311c5a 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -900,7 +900,7 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 		if (mLastRegionHandle != 0)
 		{
 			++mRegionCrossingCount;
-			LLTrace::Seconds delta = mRegionCrossingTimer.getElapsedTimeF32();
+			LLUnit<F64, LLUnits::Seconds> delta = mRegionCrossingTimer.getElapsedTimeF32();
 			record(LLStatViewer::REGION_CROSSING_TIME, delta);
 
 			// Diagnostics
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index b49152508c..a95adbf442 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -732,9 +732,9 @@ void LLWorld::updateNetStats()
 	S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
 	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 
-	add(LLStatViewer::ACTUAL_IN_KBIT, LLTrace::Bits(actual_in_bits));
-	add(LLStatViewer::ACTUAL_OUT_KBIT, LLTrace::Bits(actual_out_bits));
-	add(LLStatViewer::KBIT, LLTrace::Bits(bits));
+	add(LLStatViewer::ACTUAL_IN_KBIT, LLUnit<F64, LLUnits::Bits>(actual_in_bits));
+	add(LLStatViewer::ACTUAL_OUT_KBIT, LLUnit<F64, LLUnits::Bits>(actual_out_bits));
+	add(LLStatViewer::KBIT, LLUnit<F64, LLUnits::Bits>(bits));
 	add(LLStatViewer::PACKETS_IN, packets_in);
 	add(LLStatViewer::PACKETS_OUT, packets_out);
 	add(LLStatViewer::PACKETS_LOST, packets_lost);
-- 
cgit v1.2.3


From 8bddaeec6647e735415f9bd72a4e1313e11fe720 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/newview/llscenemonitor.cpp  | 26 +++++++++++--------
 indra/newview/llstartup.cpp       | 54 ++++++++++++++++-----------------------
 indra/newview/llviewercamera.cpp  |  2 +-
 indra/newview/llviewerdisplay.cpp | 15 ++++++++---
 4 files changed, 49 insertions(+), 48 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index ed9eeb9330..a4d693ec0b 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -260,14 +260,7 @@ void LLSceneMonitor::capture()
 	static LLCachedControl<bool> monitor_enabled(gSavedSettings, "SceneLoadingMonitorEnabled");
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static LLFrameTimer timer;	
-
-	if (mEnabled 
-		&&	(mMonitorRecording.getSum(*LLViewerCamera::getVelocityStat()) > 0.1f
-			|| mMonitorRecording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.05f))
-	{
-		reset();
-		freezeScene();
-	}
+	static bool force_capture = true;
 
 	bool enabled = monitor_enabled || mDebugViewerVisible;
 	if(mEnabled != enabled)
@@ -275,6 +268,7 @@ void LLSceneMonitor::capture()
 		if(mEnabled)
 		{
 			unfreezeScene();
+			force_capture = true;
 		}
 		else
 		{
@@ -285,11 +279,23 @@ void LLSceneMonitor::capture()
 		mEnabled = enabled;
 	}
 
-	if(timer.getElapsedTimeF32() > scene_load_sample_time()
+	if (mEnabled 
+		&&	(mMonitorRecording.getSum(*LLViewerCamera::getVelocityStat()) > 0.1f
+		|| mMonitorRecording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.05f))
+	{
+		reset();
+		freezeScene();
+		force_capture = true;
+	}
+
+	if((timer.getElapsedTimeF32() > scene_load_sample_time() 
+			|| force_capture)
 		&& mEnabled
 		&& LLGLSLShader::sNoFixedFunction
 		&& last_capture_time != gFrameCount)
 	{
+		force_capture = false;
+
 		mSceneLoadRecording.resume();
 		mMonitorRecording.resume();
 
@@ -479,12 +485,10 @@ void LLSceneMonitor::fetchQueryResult()
 			if(mDiffResult > diff_threshold())
 			{
 				mSceneLoadRecording.extend();
-				llassert(mSceneLoadRecording.getAcceptedRecording().getLastRecording().getSum(LLStatViewer::FPS));
 			}
 			else
 			{
 				mSceneLoadRecording.getPotentialRecording().nextPeriod();
-				llassert(mSceneLoadRecording.getPotentialRecording().getLastRecording().getSum(LLStatViewer::FPS));
 			}
 		}
 	}
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index de8d549055..097ea7cc8d 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2054,6 +2054,7 @@ bool idle_startup()
 		const F32 wearables_time = wearables_timer.getElapsedTimeF32();
 		static LLCachedControl<F32> max_wearables_time(gSavedSettings, "ClothingLoadingDelay");
 
+		display_startup();
 		if (!gAgent.isGenderChosen() && isAgentAvatarValid())
 		{
 			// No point in waiting for clothing, we don't even
@@ -2067,50 +2068,39 @@ bool idle_startup()
 			LLNotificationsUtil::add("WelcomeChooseSex", LLSD(), LLSD(),
 				callback_choose_gender);
 			LLStartUp::setStartupState( STATE_CLEANUP );
-			return TRUE;
 		}
-		
-		display_startup();
-
-		if (wearables_time > max_wearables_time())
+		else if (wearables_time >= max_wearables_time())
 		{
 			LLNotificationsUtil::add("ClothingLoading");
 			record(LLStatViewer::LOADING_WEARABLES_LONG_DELAY, wearables_time);
 			LLStartUp::setStartupState( STATE_CLEANUP );
-			return TRUE;
 		}
-
-		if (gAgent.isFirstLogin())
+		else if (gAgent.isFirstLogin()
+				&& isAgentAvatarValid()
+				&& gAgentAvatarp->isFullyLoaded())
 		{
 			// wait for avatar to be completely loaded
-			if (isAgentAvatarValid()
-				&& gAgentAvatarp->isFullyLoaded())
-			{
-				//llinfos << "avatar fully loaded" << llendl;
-				LLStartUp::setStartupState( STATE_CLEANUP );
-				return TRUE;
-			}
+			//llinfos << "avatar fully loaded" << llendl;
+			LLStartUp::setStartupState( STATE_CLEANUP );
+		}
+		// OK to just get the wearables
+		else if (!gAgent.isFirstLogin() && gAgentWearables.areWearablesLoaded() )
+		{
+			// We have our clothing, proceed.
+			//llinfos << "wearables loaded" << llendl;
+			LLStartUp::setStartupState( STATE_CLEANUP );
 		}
 		else
 		{
-			// OK to just get the wearables
-			if ( gAgentWearables.areWearablesLoaded() )
-			{
-				// We have our clothing, proceed.
-				//llinfos << "wearables loaded" << llendl;
-				LLStartUp::setStartupState( STATE_CLEANUP );
-				return TRUE;
-			}
+			display_startup();
+			update_texture_fetch();
+			display_startup();
+			set_startup_status(0.9f + 0.1f * wearables_time / max_wearables_time(),
+				LLTrans::getString("LoginDownloadingClothing").c_str(),
+				gAgent.mMOTD.c_str());
+			display_startup();
 		}
-
-		display_startup();
-		update_texture_fetch();
-		display_startup();
-		set_startup_status(0.9f + 0.1f * wearables_time / max_wearables_time(),
-						 LLTrans::getString("LoginDownloadingClothing").c_str(),
-						 gAgent.mMOTD.c_str());
-		display_startup();
-		return TRUE;
+		//fall through this frame to STATE_CLEANUP
 	}
 
 	if (STATE_CLEANUP == LLStartUp::getStartupState())
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index ebc4f09edb..57a0195d23 100755
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -155,7 +155,7 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
 
 	setOriginAndLookAt(origin, up_direction, point_of_interest);
 
-	mVelocityDir = center - last_position ; 
+	mVelocityDir = origin - last_position ; 
 	F32 dpos = mVelocityDir.normVec() ;
 	LLQuaternion rotation;
 	rotation.shortestArc(last_axis, getAtAxis());
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 1de8493749..ee5793fe6a 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -106,6 +106,7 @@ LLFrameTimer gRecentMemoryTime;
 void pre_show_depth_buffer();
 void post_show_depth_buffer();
 void render_ui(F32 zoom_factor = 1.f, int subfield = 0);
+void swap();
 void render_hud_attachments();
 void render_ui_3d();
 void render_ui_2d();
@@ -344,7 +345,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	// Bail out if we're in the startup state and don't want to try to
 	// render the world.
 	//
-	if (LLStartUp::getStartupState() < STATE_STARTED)
+	if (LLStartUp::getStartupState() < STATE_WEARABLES_WAIT)
 	{
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Startup");
 		display_startup();
@@ -553,6 +554,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	{
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected");
 		render_ui();
+		swap();
 	}
 	
 	//////////////////////////
@@ -1021,6 +1023,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		{
 			LLFastTimer t(FTM_RENDER_UI);
 			render_ui();
+			swap();
 		}
 
 		
@@ -1244,8 +1247,6 @@ BOOL setup_hud_matrices(const LLRect& screen_region)
 	return TRUE;
 }
 
-static LLFastTimer::DeclareTimer FTM_SWAP("Swap");
-
 void render_ui(F32 zoom_factor, int subfield)
 {
 	LLGLState::checkStates();
@@ -1322,10 +1323,16 @@ void render_ui(F32 zoom_factor, int subfield)
 		glh_set_current_modelview(saved_view);
 		gGL.popMatrix();
 	}
+}
+
+static LLFastTimer::DeclareTimer FTM_SWAP("Swap");
+
+void swap()
+{
+	LLFastTimer t(FTM_SWAP);
 
 	if (gDisplaySwapBuffers)
 	{
-		LLFastTimer t(FTM_SWAP);
 		gViewerWindow->getWindow()->swapBuffers();
 	}
 	gDisplaySwapBuffers = TRUE;
-- 
cgit v1.2.3


From d95d69cbc4063fae1d93ce2f0c4d22d3ef9c8edd Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 24 Jun 2013 11:42:32 -0600
Subject: fix for SH-4284: interesting: viewer does not render cacheable
 objects on far corner of region when camera moves

---
 indra/newview/llvieweroctree.cpp |  5 ++++
 indra/newview/llvieweroctree.h   |  1 +
 indra/newview/llvocache.cpp      | 51 +++++++++++++++++++++++++++++++++++-----
 indra/newview/llvocache.h        |  7 ++++++
 4 files changed, 58 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index d631985e82..576dbfd2c2 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -1022,6 +1022,11 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera)
 	return TRUE;
 }
 
+U32 LLOcclusionCullingGroup::getLastOcclusionIssuedTime()
+{
+	return mOcclusionIssued[LLViewerCamera::sCurCameraID];
+}
+
 void LLOcclusionCullingGroup::checkOcclusion()
 {
 	if (LLPipeline::sUseOcclusion > 1)
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 7f2ca6ed2d..e210d8f478 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -320,6 +320,7 @@ public:
 	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }		
 	
 	BOOL needsUpdate();
+	U32  getLastOcclusionIssuedTime();
 
 	//virtual 
 	void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index b3c7b80c29..f23375adfa 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -399,9 +399,10 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
 class LLVOCacheOctreeCull : public LLViewerOctreeCull
 {
 public:
-	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion) 
+	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) 
 		: LLViewerOctreeCull(camera), 
-		  mRegionp(regionp)
+		  mRegionp(regionp),
+		  mPartition(part)
 	{
 		mLocalShift = shift;
 		mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion);
@@ -422,6 +423,7 @@ public:
 
 			if (group->isOcclusionState(LLSpatialGroup::OCCLUDED))
 			{
+				mPartition->addOccluders(group);
 				return true;
 			}
 		}
@@ -473,9 +475,10 @@ public:
 	}
 
 private:
-	LLViewerRegion* mRegionp;
-	LLVector3       mLocalShift; //shift vector from agent space to local region space.
-	bool            mUseObjectCacheOcclusion;
+	LLVOCachePartition* mPartition;
+	LLViewerRegion*     mRegionp;
+	LLVector3           mLocalShift; //shift vector from agent space to local region space.
+	bool                mUseObjectCacheOcclusion;
 };
 
 S32 LLVOCachePartition::cull(LLCamera &camera)
@@ -493,12 +496,48 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	camera.calcRegionFrustumPlanes(region_agent);
 
-	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion);
+	mOccludedGroups.clear();
+	
+	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion, this);
 	culler.traverse(mOctree);
 
+	if(!mOccludedGroups.empty())
+	{
+		processOccluders(&camera);
+		mOccludedGroups.clear();
+	}
+
 	return 0;
 }
 
+void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
+{
+	LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp;
+
+	const U32 MIN_WAIT_TIME = 16; //wait 16 frames to issue a new occlusion request
+	U32 last_issued_time = group->getLastOcclusionIssuedTime();
+	if(gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME)
+	{
+		return;
+	}
+
+	if(group && !group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
+	{
+		group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+		mOccludedGroups.insert(group);
+	}
+}
+
+void LLVOCachePartition::processOccluders(LLCamera* camera)
+{
+	for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
+	{
+		LLOcclusionCullingGroup* group = *iter;
+		group->doOcclusion(camera);
+		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+	}
+}
+
 //-------------------------------------------------------------------
 //LLVOCache
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index b8a7ccac99..1aa58528db 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -156,8 +156,15 @@ public:
 	void addEntry(LLViewerOctreeEntry* entry);
 	void removeEntry(LLViewerOctreeEntry* entry);
 	/*virtual*/ S32 cull(LLCamera &camera);
+	void addOccluders(LLviewerOctreeGroup* gp);
 
 	static	LLTrace::MemStatHandle	sMemStat;
+
+private:	
+	void processOccluders(LLCamera* camera);
+
+private:
+	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
 };
 
 //
-- 
cgit v1.2.3


From eb8d0bed7b8b068231efc6c0c30b719b4c171c7f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 24 Jun 2013 23:36:05 -0600
Subject: fix for SH-4264: interesting: Content near edges of screen does not
 load

---
 indra/newview/llviewerobject.cpp |  5 -----
 indra/newview/llviewerregion.cpp | 40 ++++++++++++++++++++++++----------------
 2 files changed, 24 insertions(+), 21 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 5ae08a8b9e..4e514ddfd1 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -1026,11 +1026,6 @@ U32 LLViewerObject::extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector
 {
 	U32	parent_id = 0;
 	LLViewerObject::unpackParentID(dp, parent_id);
-	if(parent_id > 0)
-	{
-		//is a child, no need to decode further.
-		return parent_id;
-	}
 
 	LLViewerObject::unpackVector3(dp, scale, "Scale");
 	LLViewerObject::unpackVector3(dp, pos, "Pos");
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index dd4c7f2aff..d27b37d029 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -910,19 +910,19 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 		return;
 	}
 
+	bool is_orphan = false;
+	LLVOCacheEntry* parent = NULL;
 	if(entry->getParentID() > 0) //is a child
 	{
-		LLVOCacheEntry* parent = getCacheEntry(entry->getParentID());
-		if(parent)
-		{
-			parent->addChild(entry);
-		}
-		else //parent is not in the cache, put into the orphan list.
+		parent = getCacheEntry(entry->getParentID());
+		if(!parent)
 		{
+			is_orphan = true;
 			mOrphanMap[entry->getParentID()].push_back(entry->getLocalID());
 		}
 	}
-	else //insert to vo cache tree.
+	
+	if(!is_orphan)//insert to vo cache tree.
 	{
 		//shift to the local regional space from agent space
 		const LLVector3 pos = drawablep->getVObj()->getPositionRegion();
@@ -931,6 +931,11 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 		shift.setSub(vec, entry->getPositionGroup());
 		entry->shift(shift);
 		
+		if(parent) //is a child
+		{
+			entry->shift(parent->getPositionGroup());
+			parent->addChild(entry);
+		}
 		addToVOCacheTree(entry);
 	}
 
@@ -965,10 +970,6 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
-	if(entry->getParentID() > 0)
-	{
-		return; //no child prim in cache octree.
-	}
 
 	llassert(!entry->getEntry()->hasDrawable());
 
@@ -1102,7 +1103,8 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 				if(vo_entry->getParentID() > 0) //is a child
 				{
-					//child visibility depends on its parent.
+					//child visibility depends on its parent, force its parent to be visible
+					addVisibleCacheEntry(getCacheEntry(vo_entry->getParentID()));
 					continue;
 				}
 
@@ -1832,21 +1834,22 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 		//1, find the parent in cache
 		LLVOCacheEntry* parent = getCacheEntry(parent_id);
 		
-		//2, parent is not in the cache, put into the orphan list.
-		if(!parent)
+		//2, parent is not in the cache or not probed, put into the orphan list.
+		if(!parent || !parent->getEntry())
 		{
 			//check if parent is non-cacheable and already created
-			if(isNonCacheableObjectCreated(parent_id))
+			if(!parent && isNonCacheableObjectCreated(parent_id))
 			{
 				//parent is visible, so is the child.
 				addVisibleCacheEntry(entry);
 			}
 			else
 			{
+				entry->setBoundingInfo(pos, scale);
 			    mOrphanMap[parent_id].push_back(entry->getLocalID());
 		    }
 		}
-		else //parent in cache
+		else //parent in cache octree or probed
 		{
 			if(!parent->isState(LLVOCacheEntry::INACTIVE)) 
 			{
@@ -1855,6 +1858,9 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 			}
 			else
 			{
+				entry->setBoundingInfo(pos, scale);
+				entry->shift(parent->getPositionGroup());
+				addToVOCacheTree(entry);
 				parent->addChild(entry);
 			}
 		}
@@ -1884,6 +1890,8 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 				LLVOCacheEntry* child = getCacheEntry((*orphans)[i]);
 				if(child)
 				{
+					child->shift(entry->getPositionGroup());
+					addToVOCacheTree(child);
 					entry->addChild(child);
 				}
 			}
-- 
cgit v1.2.3


From c0fd2a15e49c4fc7578da4aa74c44e33cf45a3a1 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 25 Jun 2013 17:32:17 -0600
Subject: fix for SH-4284: interesting: viewer does not render cacheable
 objects on far corner of region when camera moves

---
 indra/newview/llvocache.cpp | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index f23375adfa..7eeabcba2e 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -414,9 +414,10 @@ public:
 			base_group->getOctreeNode()->getParent()) //never occlusion cull the root node
 		{
 			LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
-			if(group->needsUpdate())
+			if(group->needsUpdate())//needs to issue new occlusion culling check.
 			{
-				return false; //needs to issue new occlusion culling check.
+				mPartition->addOccluders(group);
+				return true;
 			}
 
 			group->checkOcclusion();
@@ -461,16 +462,6 @@ public:
 
 	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
-		if(mUseObjectCacheOcclusion && base_group->getOctreeNode()->getParent())
-		{
-			LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
-			if (group->needsUpdate() || group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1)
-			{
-				((LLOcclusionCullingGroup*)group)->doOcclusion(mCamera);
-				group->setVisible();
-				return; //wait for occlusion culling results
-			}
-		}
 		mRegionp->addVisibleGroup(base_group);
 	}
 
-- 
cgit v1.2.3


From 88fee7f87fc4a987a05002fedfcae11d6b42ba59 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 26 Jun 2013 17:08:03 -0600
Subject: more fix for SH-4284: interesting: viewer does not render cacheable
 objects on far corner of region when camera moves

---
 indra/newview/llvieweroctree.cpp | 30 ++++++++++++++++++++----------
 indra/newview/llvieweroctree.h   |  4 ++--
 indra/newview/llvocache.cpp      | 12 ++++++------
 indra/newview/llvocache.h        |  2 +-
 4 files changed, 29 insertions(+), 19 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 576dbfd2c2..7b3186d40a 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -978,7 +978,7 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode)
 static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion");
 static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait");
 
-BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera)
+BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds)
 {
 	if (camera->getOrigin().isExactlyZero())
 	{
@@ -989,7 +989,6 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera)
 	LLVector4a fudge;
 	fudge.splat(vel);
 
-	const LLVector4a* bounds = getBounds();
 	const LLVector4a& c = bounds[0];
 	LLVector4a r;
 	r.setAdd(bounds[1], fudge);
@@ -1125,12 +1124,23 @@ static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer");
 static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water");
 static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw");
 
-void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera)
+void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* region_agent)
 {
 	if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1)
 	{
+		//move mBounds to the agent space if necessary
+		LLVector4a bounds[2];
+		bounds[0] = mBounds[0];
+		bounds[1] = mBounds[1];
+		if(region_agent != NULL)
+		{
+			LLVector4a shift((*region_agent)[0], (*region_agent)[1], (*region_agent)[2]);
+			bounds[0].sub(shift);
+			bounds[1].sub(shift);
+		}
+
 		// Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension
-		if (earlyFail(camera))
+		if (earlyFail(camera, bounds))
 		{
 			LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL);
 			setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY);
@@ -1184,10 +1194,10 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera)
 						LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
 						llassert(shader);
 
-						shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mBounds[0].getF32ptr());
-						shader->uniform3f(LLShaderMgr::BOX_SIZE, mBounds[1][0]+SG_OCCLUSION_FUDGE, 
-																 mBounds[1][1]+SG_OCCLUSION_FUDGE, 
-																 mBounds[1][2]+SG_OCCLUSION_FUDGE);
+						shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, bounds[0].getF32ptr());
+						shader->uniform3f(LLShaderMgr::BOX_SIZE, bounds[1][0]+SG_OCCLUSION_FUDGE, 
+																 bounds[1][1]+SG_OCCLUSION_FUDGE, 
+																 bounds[1][2]+SG_OCCLUSION_FUDGE);
 
 						if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER)
 						{
@@ -1201,7 +1211,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera)
 							}
 							else
 							{
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0]));
 							}
 						}
 						else
@@ -1214,7 +1224,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera)
 							}
 							else
 							{
-								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, mBounds[0]));
+								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, bounds[0]));
 							}
 						}
 
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index e210d8f478..980a67367c 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -316,7 +316,7 @@ public:
 	void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 	void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 	void checkOcclusion(); //read back last occlusion query (if any)
-	void doOcclusion(LLCamera* camera); //issue occlusion query
+	void doOcclusion(LLCamera* camera, const LLVector3* region_agent = NULL); //issue occlusion query
 	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }		
 	
 	BOOL needsUpdate();
@@ -332,7 +332,7 @@ protected:
 	void releaseOcclusionQueryObjectNames();
 
 private:	
-	BOOL earlyFail(LLCamera* camera);
+	BOOL earlyFail(LLCamera* camera, const LLVector4a* bounds);
 
 protected:
 	U32         mOcclusionState[LLViewerCamera::NUM_CAMERAS];
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 7eeabcba2e..60d78890b5 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -494,7 +494,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
 
 	if(!mOccludedGroups.empty())
 	{
-		processOccluders(&camera);
+		processOccluders(&camera, &region_agent);
 		mOccludedGroups.clear();
 	}
 
@@ -505,26 +505,26 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
 {
 	LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp;
 
-	const U32 MIN_WAIT_TIME = 16; //wait 16 frames to issue a new occlusion request
+	const U32 MIN_WAIT_TIME = 19; //wait 19 frames to issue a new occlusion request
 	U32 last_issued_time = group->getLastOcclusionIssuedTime();
-	if(gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME)
+	if(!group->needsUpdate() && gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME)
 	{
 		return;
 	}
 
-	if(group && !group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
+	if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
 	{
 		group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
 		mOccludedGroups.insert(group);
 	}
 }
 
-void LLVOCachePartition::processOccluders(LLCamera* camera)
+void LLVOCachePartition::processOccluders(LLCamera* camera, const LLVector3* region_agent)
 {
 	for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
 	{
 		LLOcclusionCullingGroup* group = *iter;
-		group->doOcclusion(camera);
+		group->doOcclusion(camera, region_agent);
 		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
 	}
 }
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 1aa58528db..bf75cafac5 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -161,7 +161,7 @@ public:
 	static	LLTrace::MemStatHandle	sMemStat;
 
 private:	
-	void processOccluders(LLCamera* camera);
+	void processOccluders(LLCamera* camera, const LLVector3* region_agent);
 
 private:
 	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
-- 
cgit v1.2.3


From 808d3eff198d65e5a870abb670786935fc8356bd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/newview/llappviewer.cpp        |  4 +++-
 indra/newview/llviewerassetstats.cpp | 15 ++++++++-------
 2 files changed, 11 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

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.2.3


From ffa7123bb5187e1da491a8f475d696053d9c9ee4 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 28 Jun 2013 20:45:20 -0700
Subject: SH-4299 FIX Interesting: High fps shown temporarily off scale in
 statistics console added ability to force uniqueness of LLCopyOnWritePointer
 converted more variables to units added convenience function for unit
 constants

---
 indra/newview/llappviewer.cpp                |   2 -
 indra/newview/llclassifiedstatsresponder.cpp |  17 ++--
 indra/newview/llfasttimerview.cpp            |  10 +-
 indra/newview/llscenemonitor.cpp             |   2 +-
 indra/newview/lltexturefetch.cpp             | 132 ++++++++++++++-------------
 indra/newview/lltextureinfo.cpp              |  80 ++++++++--------
 indra/newview/lltextureinfo.h                |  32 +++----
 indra/newview/lltextureinfodetails.cpp       |   4 +-
 indra/newview/lltextureinfodetails.h         |  14 +--
 indra/newview/lltexturestats.cpp             |   3 +-
 indra/newview/lltexturestatsuploader.cpp     |   8 +-
 indra/newview/lltexturestatsuploader.h       |   4 +-
 indra/newview/llviewerstats.cpp              |  10 +-
 13 files changed, 154 insertions(+), 164 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 7c5cd520da..9308f0f4e9 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1294,8 +1294,6 @@ 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();
 
diff --git a/indra/newview/llclassifiedstatsresponder.cpp b/indra/newview/llclassifiedstatsresponder.cpp
index e3cd83e174..1e1c9039fb 100755
--- a/indra/newview/llclassifiedstatsresponder.cpp
+++ b/indra/newview/llclassifiedstatsresponder.cpp
@@ -38,10 +38,8 @@
 #include "message.h"
 
 LLClassifiedStatsResponder::LLClassifiedStatsResponder(LLUUID classified_id)
-:
-mClassifiedID(classified_id)
-{
-}
+:	mClassifiedID(classified_id)
+{}
 
 /*virtual*/
 void LLClassifiedStatsResponder::result(const LLSD& content)
@@ -53,12 +51,11 @@ void LLClassifiedStatsResponder::result(const LLSD& content)
 	S32 search_map = content["search_map_clicks"].asInteger();
 	S32 search_profile = content["search_profile_clicks"].asInteger();
 
-	LLPanelClassifiedInfo::setClickThrough(
-		mClassifiedID, 
-		teleport + search_teleport, 
-		map + search_map,
-		profile + search_profile,
-		true);
+	LLPanelClassifiedInfo::setClickThrough(	mClassifiedID, 
+											teleport + search_teleport, 
+											map + search_map,
+											profile + search_profile,
+											true);
 }
 
 /*virtual*/
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index d3a97fde0e..7a5e1dcad0 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1101,7 +1101,7 @@ void LLFastTimerView::drawLineGraph()
 			j--)
 		{
 			LLTrace::Recording& recording = mRecording.getPrevRecording(j);
-			LLUnit<F32, LLUnits::Seconds> time = llmax(recording.getSum(*idp), LLUnit<F64, LLUnits::Seconds>(0.000001));
+			LLUnit<F32, LLUnits::Seconds> time = llmax(recording.getSum(*idp), LLUnits::Seconds::fromValue(0.000001));
 			U32 calls = recording.getSum(idp->callCount());
 
 			if (is_hover_timer)
@@ -1126,7 +1126,7 @@ void LLFastTimerView::drawLineGraph()
 			}
 			gGL.vertex2f(x,y);
 			gGL.vertex2f(x,mGraphRect.mBottom);
-}
+		}
 		gGL.end();
 
 		if (mHoverID == idp)
@@ -1146,7 +1146,7 @@ void LLFastTimerView::drawLineGraph()
 	max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f));
 	if (llabs((max_time - cur_max).value()) <= 1)
 	{
-		max_time = llmax(LLUnit<F32, LLUnits::Microseconds>(1), LLUnit<F32, LLUnits::Microseconds>(cur_max));
+		max_time = llmax(LLUnits::Microseconds::fromValue(1.f), LLUnits::Microseconds::fromValue(cur_max));
 	}
 
 	max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f)));
@@ -1423,11 +1423,11 @@ void LLFastTimerView::updateTotalTime()
 		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20);
 		break;
 	default:
-		mTotalTimeDisplay = LLUnit<F32, LLUnits::Milliseconds>(100);
+		mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(100);
 		break;
 	}
 
-	mTotalTimeDisplay = LLUnit<F32, LLUnits::Milliseconds>(llceil(mTotalTimeDisplay.getAs<LLUnits::Milliseconds>() / 20.f) * 20.f);
+	mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil(mTotalTimeDisplay.valueAs<LLUnits::Milliseconds>() / 20.f) * 20.f);
 }
 
 void LLFastTimerView::drawBars()
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index a4d693ec0b..342b45863a 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -624,7 +624,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).getAs<LLUnits::Kibibytes>();
+			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).valueAs<LLUnits::Kibibytes>();
 		}
 
 		os << '\n';
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 4b9a950b98..0390649a1c 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -504,81 +504,85 @@ private:
 	static const char* sStateDescs[];
 	e_state mState;
 	void setState(e_state new_state);
-	e_write_to_cache_state mWriteToCacheState;
-	LLTextureFetch* mFetcher;
+
+	e_write_to_cache_state		mWriteToCacheState;
+	LLTextureFetch*             mFetcher;
 	LLPointer<LLImageFormatted> mFormattedImage;
-	LLPointer<LLImageRaw> mRawImage;
-	LLPointer<LLImageRaw> mAuxImage;
-	FTType mFTType;
-	LLUUID mID;
-	LLHost mHost;
-	std::string mUrl;
-	U8 mType;
-	F32 mImagePriority;
-	U32 mWorkPriority;
-	F32 mRequestedPriority;
-	S32 mDesiredDiscard;
-	S32 mSimRequestedDiscard;
-	S32 mRequestedDiscard;
-	S32 mLoadedDiscard;
-	S32 mDecodedDiscard;
-	LLFrameTimer mRequestedTimer;
-	LLFrameTimer mFetchTimer;
-	LLTimer			mCacheReadTimer;
-	F32				mCacheReadTime;
-	LLTextureCache::handle_t mCacheReadHandle;
-	LLTextureCache::handle_t mCacheWriteHandle;
-	S32 mRequestedSize;
-	S32 mRequestedOffset;
-	S32 mDesiredSize;
-	S32 mFileSize;
-	S32 mCachedSize;	
-	e_request_state mSentRequest;
-	handle_t mDecodeHandle;
-	BOOL mLoaded;
-	BOOL mDecoded;
-	BOOL mWritten;
-	BOOL mNeedsAux;
-	BOOL mHaveAllData;
-	BOOL mInLocalCache;
-	BOOL mInCache;
-	bool mCanUseHTTP ;
-	bool mCanUseNET ; //can get from asset server.
-	S32 mRetryAttempt;
-	S32 mActiveCount;
-	LLCore::HttpStatus mGetStatus;
-	std::string mGetReason;
+	LLPointer<LLImageRaw>       mRawImage,
+								mAuxImage;
+	FTType                      mFTType;
+	LLUUID                      mID;
+	LLHost                      mHost;
+	std::string                 mUrl;
+	U8                          mType;
+	F32                         mImagePriority;
+	U32                         mWorkPriority;
+	F32                         mRequestedPriority;
+	S32                         mDesiredDiscard,
+								mSimRequestedDiscard,
+								mRequestedDiscard,
+								mLoadedDiscard,
+								mDecodedDiscard;
+	LLFrameTimer                mRequestedTimer,
+								mFetchTimer;
+	LLTimer						mCacheReadTimer;
+	F32							mCacheReadTime;
+	LLTextureCache::handle_t    mCacheReadHandle,
+								mCacheWriteHandle;
+	S32                         mRequestedSize,
+								mRequestedOffset,
+								mDesiredSize,
+								mFileSize,
+								mCachedSize;
+	e_request_state             mSentRequest;
+	handle_t                    mDecodeHandle;
+	BOOL                        mLoaded;
+	BOOL                        mDecoded;
+	BOOL                        mWritten;
+	BOOL                        mNeedsAux;
+	BOOL                        mHaveAllData;
+	BOOL                        mInLocalCache;
+	BOOL                        mInCache;
+	bool                        mCanUseHTTP,
+								mCanUseNET ; //can get from asset server.
+	S32                         mRetryAttempt;
+	S32                         mActiveCount;
+	LLCore::HttpStatus          mGetStatus;
+	std::string                 mGetReason;
 	
 	// Work Data
-	LLMutex mWorkMutex;
+	LLMutex						mWorkMutex;
 	struct PacketData
 	{
-		PacketData(U8* data, S32 size) { mData = data; mSize = size; }
+		PacketData(U8* data, S32 size) 
+		:	mData(data), mSize(size) 
+		{}
 		~PacketData() { clearData(); }
 		void clearData() { delete[] mData; mData = NULL; }
-		U8* mData;
-		U32 mSize;
+
+		U8*		mData;
+		U32		mSize;
 	};
-	std::vector<PacketData*> mPackets;
-	S32 mFirstPacket;
-	S32 mLastPacket;
-	U16 mTotalPackets;
-	U8 mImageCodec;
+	std::vector<PacketData*>	mPackets;
+	S32							mFirstPacket;
+	S32							mLastPacket;
+	U16							mTotalPackets;
+	U8							mImageCodec;
 
 	LLViewerAssetStats::duration_t mMetricsStartTime;
 
-	LLCore::HttpHandle		mHttpHandle;				// Handle of any active request
-	LLCore::BufferArray	*	mHttpBufferArray;			// Refcounted pointer to response data 
-	int						mHttpPolicyClass;
-	bool					mHttpActive;				// Active request to http library
-	unsigned int			mHttpReplySize;				// Actual received data size
-	unsigned int			mHttpReplyOffset;			// Actual received data offset
-	bool					mHttpHasResource;			// Counts against Fetcher's mHttpSemaphore
+	LLCore::HttpHandle			mHttpHandle;				// Handle of any active request
+	LLCore::BufferArray	*		mHttpBufferArray;			// Refcounted pointer to response data 
+	S32							mHttpPolicyClass;
+	bool						mHttpActive;				// Active request to http library
+	U32							mHttpReplySize,				// Actual received data size
+								mHttpReplyOffset;			// Actual received data offset
+	bool						mHttpHasResource;			// Counts against Fetcher's mHttpSemaphore
 
 	// State history
-	U32						mCacheReadCount;
-	U32						mCacheWriteCount;
-	U32						mResourceWaitCount;			// Requests entering WAIT_HTTP_RESOURCE2
+	U32							mCacheReadCount,
+								mCacheWriteCount,
+								mResourceWaitCount;			// Requests entering WAIT_HTTP_RESOURCE2
 };
 
 //////////////////////////////////////////////////////////////////////////////
@@ -2390,7 +2394,7 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
 	  mFetcherLocked(FALSE)
 {
 	mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
-	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), gSavedSettings.getU32("TextureLoggingThreshold"));
+	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), LLUnits::Bytes::fromValue(gSavedSettings.getU32("TextureLoggingThreshold")));
 
 	LLTextureFetchDebugger::sDebuggerEnabled = gSavedSettings.getBOOL("TextureFetchDebuggerEnabled");
 	if(LLTextureFetchDebugger::isEnabled())
@@ -3369,7 +3373,7 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
 
 		if (log_to_viewer_log || log_to_sim)
 		{
-			U64 timeNow = LLTimer::getTotalTime();
+			LLUnit<U64, LLUnits::Microseconds> timeNow = LLTimer::getTotalTime();
 			mTextureInfo.setRequestSize(id, worker->mFileSize);
 			mTextureInfo.setRequestCompleteTimeAndLog(id, timeNow);
 		}
diff --git a/indra/newview/lltextureinfo.cpp b/indra/newview/lltextureinfo.cpp
index adfdbc997e..3ae85d56da 100755
--- a/indra/newview/lltextureinfo.cpp
+++ b/indra/newview/lltextureinfo.cpp
@@ -29,26 +29,28 @@
 #include "lltextureinfo.h"
 #include "lltexturestats.h"
 #include "llviewercontrol.h"
+#include "lltrace.h"
+
+static LLTrace::CountStatHandle<S32> sTextureDownloadsStarted("texture_downloads_started", "number of texture downloads initiated");
+static LLTrace::CountStatHandle<S32> sTextureDownloadsCompleted("texture_downloads_completed", "number of texture downloads completed");
+static LLTrace::CountStatHandle<LLUnit<S32, LLUnits::Bytes> > sTextureDataDownloaded("texture_data_downloaded", "amount of texture data downloaded");
+static LLTrace::CountStatHandle<LLUnit<U32, LLUnits::Milliseconds> > sTexureDownloadTime("texture_download_time", "amount of time spent fetching textures");
 
 LLTextureInfo::LLTextureInfo() : 
 	mLogTextureDownloadsToViewerLog(false),
 	mLogTextureDownloadsToSimulator(false),
-	mTotalBytes(0),
-	mTotalMilliseconds(0),
-	mTextureDownloadsStarted(0),
-	mTextureDownloadsCompleted(0),
 	mTextureDownloadProtocol("NONE"),
-	mTextureLogThreshold(100 * 1024),
-	mCurrentStatsBundleStartTime(0)
+	mTextureLogThreshold(LLUnits::Kibibytes::fromValue(100))
 {
 	mTextures.clear();
+	mRecording.start();
 }
 
-void LLTextureInfo::setUpLogging(bool writeToViewerLog, bool sendToSim, U32 textureLogThreshold)
+void LLTextureInfo::setUpLogging(bool writeToViewerLog, bool sendToSim, LLUnit<U32, LLUnits::Bytes> textureLogThreshold)
 {
 	mLogTextureDownloadsToViewerLog = writeToViewerLog;
 	mLogTextureDownloadsToSimulator = sendToSim;
-	mTextureLogThreshold = textureLogThreshold;
+	mTextureLogThreshold = LLUnit<U32, LLUnits::Bytes>(textureLogThreshold);
 }
 
 LLTextureInfo::~LLTextureInfo()
@@ -94,7 +96,7 @@ void LLTextureInfo::setRequestStartTime(const LLUUID& id, U64 startTime)
 		addRequest(id);
 	}
 	mTextures[id]->mStartTime = startTime;
-	mTextureDownloadsStarted++;
+	add(sTextureDownloadsStarted, 1);
 }
 
 void LLTextureInfo::setRequestSize(const LLUUID& id, U32 size)
@@ -124,16 +126,19 @@ void LLTextureInfo::setRequestType(const LLUUID& id, LLTextureInfoDetails::LLReq
 	mTextures[id]->mType = type;
 }
 
-void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, U64 completeTime)
+void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, LLUnit<U64, LLUnits::Microseconds> completeTime)
 {
 	if (!has(id))
 	{
 		addRequest(id);
 	}
-	mTextures[id]->mCompleteTime = completeTime;
+	
+	LLTextureInfoDetails& details = *mTextures[id];
+
+	details.mCompleteTime = completeTime;
 
 	std::string protocol = "NONE";
-	switch(mTextures[id]->mType)
+	switch(details.mType)
 	{
 	case LLTextureInfoDetails::REQUEST_TYPE_HTTP:
 		protocol = "HTTP";
@@ -150,24 +155,23 @@ void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, U64 completeT
 
 	if (mLogTextureDownloadsToViewerLog)
 	{
-		llinfos << "texture=" << id 
-			<< " start=" << mTextures[id]->mStartTime 
-			<< " end=" << mTextures[id]->mCompleteTime
-			<< " size=" << mTextures[id]->mSize
-			<< " offset=" << mTextures[id]->mOffset
-			<< " length_in_ms=" << (mTextures[id]->mCompleteTime - mTextures[id]->mStartTime) / 1000
-			<< " protocol=" << protocol
-			<< llendl;
+		llinfos << "texture="   << id 
+			    << " start="    << details.mStartTime 
+			    << " end="      << details.mCompleteTime
+			    << " size="     << details.mSize
+			    << " offset="   << details.mOffset
+			    << " length="   << LLUnit<U32, LLUnits::Milliseconds>(details.mCompleteTime - details.mStartTime)
+			    << " protocol=" << protocol
+			    << llendl;
 	}
 
 	if(mLogTextureDownloadsToSimulator)
 	{
-		S32 texture_stats_upload_threshold = mTextureLogThreshold;
-		mTotalBytes += mTextures[id]->mSize;
-		mTotalMilliseconds += mTextures[id]->mCompleteTime - mTextures[id]->mStartTime;
-		mTextureDownloadsCompleted++;
+		add(sTextureDataDownloaded, details.mSize);
+		add(sTexureDownloadTime, details.mCompleteTime - details.mStartTime);
+		add(sTextureDownloadsCompleted, 1);
 		mTextureDownloadProtocol = protocol;
-		if (mTotalBytes >= texture_stats_upload_threshold)
+		if (mRecording.getSum(sTextureDataDownloaded) >= mTextureLogThreshold)
 		{
 			LLSD texture_data;
 			std::stringstream startTime;
@@ -189,35 +193,33 @@ LLSD LLTextureInfo::getAverages()
 {
 	LLSD averagedTextureData;
 	S32 averageDownloadRate;
-	if(mTotalMilliseconds == 0)
+	LLUnit<U32, LLUnits::Milliseconds> download_time = mRecording.getSum(sTexureDownloadTime);
+	if(download_time == 0)
 	{
 		averageDownloadRate = 0;
 	}
 	else
 	{
-		averageDownloadRate = (mTotalBytes * 8) / mTotalMilliseconds;
+		averageDownloadRate = mRecording.getSum(sTextureDataDownloaded).valueAs<LLUnits::Bits>() / download_time.valueAs<LLUnits::Seconds>();
 	}
 
-	averagedTextureData["bits_per_second"] = averageDownloadRate;
-	averagedTextureData["bytes_downloaded"] = mTotalBytes;
-	averagedTextureData["texture_downloads_started"] = mTextureDownloadsStarted;
-	averagedTextureData["texture_downloads_completed"] = mTextureDownloadsCompleted;
-	averagedTextureData["transport"] = mTextureDownloadProtocol;
+	averagedTextureData["bits_per_second"]             = averageDownloadRate;
+	averagedTextureData["bytes_downloaded"]            = mRecording.getSum(sTextureDataDownloaded).valueAs<LLUnits::Bytes>();
+	averagedTextureData["texture_downloads_started"]   = mRecording.getSum(sTextureDownloadsStarted);
+	averagedTextureData["texture_downloads_completed"] = mRecording.getSum(sTextureDownloadsCompleted);
+	averagedTextureData["transport"]                   = mTextureDownloadProtocol;
 
 	return averagedTextureData;
 }
 
 void LLTextureInfo::resetTextureStatistics()
 {
-	mTotalMilliseconds = 0;
-	mTotalBytes = 0;
-	mTextureDownloadsStarted = 0;
-	mTextureDownloadsCompleted = 0;
+	mRecording.restart();
 	mTextureDownloadProtocol = "NONE";
 	mCurrentStatsBundleStartTime = LLTimer::getTotalTime();
 }
 
-U32 LLTextureInfo::getRequestStartTime(const LLUUID& id)
+LLUnit<U32, LLUnits::Microseconds> LLTextureInfo::getRequestStartTime(const LLUUID& id)
 {
 	if (!has(id))
 	{
@@ -230,7 +232,7 @@ U32 LLTextureInfo::getRequestStartTime(const LLUUID& id)
 	}
 }
 
-U32 LLTextureInfo::getRequestSize(const LLUUID& id)
+LLUnit<U32, LLUnits::Bytes> LLTextureInfo::getRequestSize(const LLUUID& id)
 {
 	if (!has(id))
 	{
@@ -269,7 +271,7 @@ LLTextureInfoDetails::LLRequestType LLTextureInfo::getRequestType(const LLUUID&
 	}
 }
 
-U32 LLTextureInfo::getRequestCompleteTime(const LLUUID& id)
+LLUnit<U32, LLUnits::Microseconds> LLTextureInfo::getRequestCompleteTime(const LLUUID& id)
 {
 	if (!has(id))
 	{
diff --git a/indra/newview/lltextureinfo.h b/indra/newview/lltextureinfo.h
index 2ccbcc5fd2..a861a12668 100755
--- a/indra/newview/lltextureinfo.h
+++ b/indra/newview/lltextureinfo.h
@@ -29,6 +29,7 @@
 
 #include "lluuid.h"
 #include "lltextureinfodetails.h"
+#include "lltracerecording.h"
 #include <map>
 
 class LLTextureInfo
@@ -37,18 +38,18 @@ public:
 	LLTextureInfo();
 	~LLTextureInfo();
 
-	void setUpLogging(bool writeToViewerLog, bool sendToSim, U32 textureLogThreshold);
+	void setUpLogging(bool writeToViewerLog, bool sendToSim, LLUnit<U32, LLUnits::Bytes> textureLogThreshold);
 	bool has(const LLUUID& id);
 	void setRequestStartTime(const LLUUID& id, U64 startTime);
 	void setRequestSize(const LLUUID& id, U32 size);
 	void setRequestOffset(const LLUUID& id, U32 offset);
 	void setRequestType(const LLUUID& id, LLTextureInfoDetails::LLRequestType type);
-	void setRequestCompleteTimeAndLog(const LLUUID& id, U64 completeTime);
-	U32 getRequestStartTime(const LLUUID& id);
-	U32 getRequestSize(const LLUUID& id);
+	void setRequestCompleteTimeAndLog(const LLUUID& id, LLUnit<U64, LLUnits::Microseconds> completeTime);
+	LLUnit<U32, LLUnits::Microseconds>getRequestStartTime(const LLUUID& id);
+	LLUnit<U32, LLUnits::Bytes> getRequestSize(const LLUUID& id);
 	U32 getRequestOffset(const LLUUID& id);
 	LLTextureInfoDetails::LLRequestType getRequestType(const LLUUID& id);
-	U32 getRequestCompleteTime(const LLUUID& id);
+	LLUnit<U32, LLUnits::Microseconds> getRequestCompleteTime(const LLUUID& id);
 	void resetTextureStatistics();
 	U32 getTextureInfoMapSize();
 	LLSD getAverages();
@@ -56,19 +57,14 @@ public:
 private:
 	void addRequest(const LLUUID& id);
 
-	std::map<LLUUID, LLTextureInfoDetails *> mTextures;
-
-	LLSD mAverages;
-
-	bool mLogTextureDownloadsToViewerLog;
-	bool mLogTextureDownloadsToSimulator;
-	S32 mTotalBytes;
-	S32 mTotalMilliseconds;
-	S32 mTextureDownloadsStarted;
-	S32 mTextureDownloadsCompleted;
-	std::string mTextureDownloadProtocol;
-	U32 mTextureLogThreshold; // in bytes
-	U64 mCurrentStatsBundleStartTime;
+	std::map<LLUUID, LLTextureInfoDetails *>	mTextures;
+	LLSD										mAverages;
+	bool										mLogTextureDownloadsToViewerLog,
+												mLogTextureDownloadsToSimulator;
+	std::string									mTextureDownloadProtocol;
+	LLUnit<U32, LLUnits::Bytes>					mTextureLogThreshold; 
+	LLUnit<U64, LLUnits::Microseconds>			mCurrentStatsBundleStartTime;
+	LLTrace::Recording							mRecording;
 };
 
 #endif // LL_LLTEXTUREINFO_H
diff --git a/indra/newview/lltextureinfodetails.cpp b/indra/newview/lltextureinfodetails.cpp
index 0d750db3bf..cab16eb922 100755
--- a/indra/newview/lltextureinfodetails.cpp
+++ b/indra/newview/lltextureinfodetails.cpp
@@ -28,7 +28,9 @@
 
 #include "lltextureinfodetails.h"
 
-LLTextureInfoDetails::LLTextureInfoDetails() : mStartTime(0), mCompleteTime(0), mSize(0), mType(REQUEST_TYPE_NONE), mOffset(0)
+LLTextureInfoDetails::LLTextureInfoDetails() 
+:	mType(REQUEST_TYPE_NONE), 
+	mOffset(0)
 {
 }
 
diff --git a/indra/newview/lltextureinfodetails.h b/indra/newview/lltextureinfodetails.h
index 4a3cd29084..28e957a7df 100755
--- a/indra/newview/lltextureinfodetails.h
+++ b/indra/newview/lltextureinfodetails.h
@@ -28,10 +28,10 @@
 #define LL_LLTEXTUREINFODETAILS_H
 
 #include "lluuid.h"
+#include "llunit.h"
 
-class LLTextureInfoDetails
+struct LLTextureInfoDetails
 {
-public:
 	enum LLRequestType
 	{
 		REQUEST_TYPE_NONE,
@@ -39,11 +39,11 @@ public:
 		REQUEST_TYPE_UDP
 	};
 
-	U32 mStartTime;
-	U32 mCompleteTime;
-	U32 mOffset;
-	U32 mSize;
-	LLRequestType mType;
+	LLUnit<U32, LLUnits::Microseconds>	mStartTime,
+										mCompleteTime;
+	U32									mOffset;
+	LLUnit<U32, LLUnits::Bytes>			mSize;
+	LLRequestType						mType;
 
 	LLTextureInfoDetails();
 };
diff --git a/indra/newview/lltexturestats.cpp b/indra/newview/lltexturestats.cpp
index f820ae65df..52fe78abf3 100755
--- a/indra/newview/lltexturestats.cpp
+++ b/indra/newview/lltexturestats.cpp
@@ -48,8 +48,7 @@ void send_texture_stats_to_sim(const LLSD &texture_stats)
 	texture_stats_report["stats_data"] = texture_stats;
 
 	std::string texture_cap_url = gAgent.getRegion()->getCapability("TextureStats");
-	LLTextureStatsUploader tsu;
 	llinfos << "uploading texture stats data to simulator" << llendl;
-	tsu.uploadStatsToSimulator(texture_cap_url, texture_stats);
+	LLTextureStatsUploader::uploadStatsToSimulator(texture_cap_url, texture_stats);
 }
 
diff --git a/indra/newview/lltexturestatsuploader.cpp b/indra/newview/lltexturestatsuploader.cpp
index 23ba09cb91..92ec63a113 100755
--- a/indra/newview/lltexturestatsuploader.cpp
+++ b/indra/newview/lltexturestatsuploader.cpp
@@ -30,14 +30,8 @@
 
 #include "llhttpclient.h"
 
-LLTextureStatsUploader::LLTextureStatsUploader()
-{
-}
-
-LLTextureStatsUploader::~LLTextureStatsUploader()
-{
-}
 
+// static
 void LLTextureStatsUploader::uploadStatsToSimulator(const std::string texture_cap_url, const LLSD &texture_stats)
 {
 	if ( texture_cap_url != "" )
diff --git a/indra/newview/lltexturestatsuploader.h b/indra/newview/lltexturestatsuploader.h
index 6b02aeb845..ac268c2516 100755
--- a/indra/newview/lltexturestatsuploader.h
+++ b/indra/newview/lltexturestatsuploader.h
@@ -34,9 +34,7 @@
 class LLTextureStatsUploader
 {
 public:
-	LLTextureStatsUploader();
-	~LLTextureStatsUploader();
-	void uploadStatsToSimulator(const std::string texture_cap_url, const LLSD &texture_stats);
+	static void uploadStatsToSimulator(const std::string texture_cap_url, const LLSD &texture_stats);
 };
 
 #endif // LL_LLTEXTURESTATSUPLOADER_H
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 3d4c75cec3..244c150b29 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -291,9 +291,9 @@ F32		gAveLandCompression = 0.f,
 		gWorstWaterCompression = 0.f;
 
 LLUnit<U32, LLUnits::Bytes>		gTotalWorldData = 0, 
-						gTotalObjectData = 0, 
-						gTotalTextureData = 0;
-U32						gSimPingCount = 0;
+								gTotalObjectData = 0, 
+								gTotalTextureData = 0;
+U32								gSimPingCount = 0;
 LLUnit<U32, LLUnits::Bits>		gObjectData = 0;
 F32		gAvgSimPing = 0.f;
 LLUnit<U32, LLUnits::Bytes>		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
@@ -353,7 +353,7 @@ void update_statistics()
 	}
 	else
 	{
-		sample(LLStatViewer::SIM_PING, LLUnit<F64, LLUnits::Seconds>(10));
+		sample(LLStatViewer::SIM_PING, LLUnits::Seconds::fromValue(10));
 	}
 
 	if (LLViewerStats::instance().getRecording().getSum(LLStatViewer::FPS))
@@ -403,7 +403,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			gTotalTextureData = LLUnit<F64, LLUnits::Bytes>(LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT));
+			gTotalTextureData = LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT);
 			texture_stats_timer.reset();
 		}
 	}
-- 
cgit v1.2.3


From 2fc422f39ddaca25c69e8cf2092a9d66840379f3 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sun, 30 Jun 2013 13:32:34 -0700
Subject: fixed memory leak due to implementation of LLThreadLocalSingleton
 removed LLThreadLocalSingleton collapsed all thread recorder classes to
 single type, LLTrace::ThreadRecorder moved fasttimer stack head to
 llthreadlocalsingletonpointer via ThreadRecorder

---
 indra/newview/llappviewer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 9308f0f4e9..348eb43b5e 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1297,7 +1297,7 @@ bool LLAppViewer::mainLoop()
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
 
-		LLTrace::getUIThreadRecorder().pullFromSlaveThreads();
+		LLTrace::getUIThreadRecorder().pullFromChildren();
 
 		//clear call stack records
 		llclearcallstacks;
-- 
cgit v1.2.3


From 04bdc8ba83c297945dd60489c241b88adf892ff4 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 1 Jul 2013 17:04:01 -0700
Subject: SH-4294 FIX Interesting: Statistics Texture cache hit rate is always
 0% also, removed LLTrace::init and cleanup removed derived class
 implementation of memory stat for LLMemTrackable is automatic now

---
 indra/newview/llappviewer.cpp                   |  2 +-
 indra/newview/lldrawable.cpp                    |  1 -
 indra/newview/lldrawable.h                      |  1 -
 indra/newview/llfasttimerview.cpp               | 10 +++++-----
 indra/newview/llviewerobject.cpp                |  2 --
 indra/newview/llviewerobject.h                  |  1 -
 indra/newview/llvocache.cpp                     |  2 --
 indra/newview/llvocache.h                       |  3 ---
 indra/newview/tests/llviewerassetstats_test.cpp |  6 ++++--
 9 files changed, 10 insertions(+), 18 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 348eb43b5e..e77f793a43 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1297,7 +1297,7 @@ bool LLAppViewer::mainLoop()
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
 
-		LLTrace::getUIThreadRecorder().pullFromChildren();
+		LLTrace::get_master_thread_recorder()->pullFromChildren();
 
 		//clear call stack records
 		llclearcallstacks;
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 628f7f7bfb..3dddf4b554 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -59,7 +59,6 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
-LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 
 
 ////////////////////////
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index b7c5aeb5a8..4558597d89 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -293,7 +293,6 @@ public:
 	F32				mDistanceWRTCamera;
 
 	static F32 sCurPixelAngle; //current pixels per radian
-	static LLTrace::MemStatHandle sMemStat;
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 7a5e1dcad0..d922659435 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -430,18 +430,18 @@ void LLFastTimerView::draw()
 					}
 
 void LLFastTimerView::onOpen(const LLSD& key)
-				{
+{
 	setPauseState(false);
 	mRecording.reset();
 	mRecording.appendPeriodicRecording(LLTrace::get_frame_recording());
 	for(std::deque<TimerBarRow>::iterator it = mTimerBarRows.begin(), end_it = mTimerBarRows.end();
 		it != end_it; 
-				++it)
-			{
+		++it)
+	{
 		delete []it->mBars;
 		it->mBars = NULL;
-					}
-					}
+	}
+}
 										
 
 void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch)
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 4e514ddfd1..c633e3acdd 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -114,8 +114,6 @@ BOOL		LLViewerObject::sMapDebug = TRUE;
 LLColor4	LLViewerObject::sEditSelectColor(	1.0f, 1.f, 0.f, 0.3f);	// Edit OK
 LLColor4	LLViewerObject::sNoEditSelectColor(	1.0f, 0.f, 0.f, 0.3f);	// Can't edit
 S32			LLViewerObject::sAxisArrowLength(50);
-LLTrace::MemStatHandle	LLViewerObject::sMemStat("LLViewerObject");
-
 
 BOOL		LLViewerObject::sPulseEnabled(FALSE);
 BOOL		LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 5556a4c7d3..63da7152b3 100755
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -661,7 +661,6 @@ public:
 	LLPointer<class LLHUDIcon> mIcon;
 
 	static			BOOL		sUseSharedDrawables;
-	static	LLTrace::MemStatHandle	sMemStat;
 
 protected:
 	// delete an item in the inventory, but don't tell the
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 60d78890b5..d87eb5d3db 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -34,8 +34,6 @@
 #include "llviewerregion.h"
 #include "pipeline.h"
 
-LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
-
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
 	return apr_file->read(src, n_bytes) == n_bytes ;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index bf75cafac5..c43c42908f 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -35,7 +35,6 @@
 
 //---------------------------------------------------------------------------
 // Cache entries
-class LLVOCacheEntry;
 class LLCamera;
 
 class LLVOCacheEntry : public LLViewerOctreeEntryData
@@ -158,8 +157,6 @@ public:
 	/*virtual*/ S32 cull(LLCamera &camera);
 	void addOccluders(LLviewerOctreeGroup* gp);
 
-	static	LLTrace::MemStatHandle	sMemStat;
-
 private:	
 	void processOccluders(LLCamera* camera, const LLVector3* region_agent);
 
diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index b9712e5e9c..bd42b59df2 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -35,6 +35,7 @@
 #include "lluuid.h"
 #include "llsdutil.h"
 #include "llregionhandle.h"
+#include "lltracethreadrecorder.h"
 #include "../llvoavatar.h"
 
 namespace LLStatViewer
@@ -231,14 +232,15 @@ namespace tut
 	{
 		tst_viewerassetstats_index()
 		{
-			LLTrace::init();
+			LLTrace::set_master_thread_recorder(&mThreadRecorder);
 		}
 
 		~tst_viewerassetstats_index()
 		{
-			LLTrace::cleanup();
+			LLTrace::set_master_thread_recorder(NULL);
 		}
 
+		LLTrace::ThreadRecorder mThreadRecorder;
 	};
 	typedef test_group<tst_viewerassetstats_index> tst_viewerassetstats_index_t;
 	typedef tst_viewerassetstats_index_t::object tst_viewerassetstats_index_object_t;
-- 
cgit v1.2.3


From 8208a40412fac35593d4b8b13f43c6be5e4d6990 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 1 Jul 2013 18:50:51 -0700
Subject: BUILDFIX: reverted changes that attempted to automate mem track stat
 definition as they don't work on gcc/clang

---
 indra/newview/lldrawable.cpp     | 1 +
 indra/newview/lldrawable.h       | 1 +
 indra/newview/llviewerobject.cpp | 2 ++
 indra/newview/llviewerobject.h   | 1 +
 indra/newview/llvocache.cpp      | 2 ++
 indra/newview/llvocache.h        | 2 ++
 6 files changed, 9 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 3dddf4b554..628f7f7bfb 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -59,6 +59,7 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
+LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 
 
 ////////////////////////
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 4558597d89..b7c5aeb5a8 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -293,6 +293,7 @@ public:
 	F32				mDistanceWRTCamera;
 
 	static F32 sCurPixelAngle; //current pixels per radian
+	static LLTrace::MemStatHandle sMemStat;
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index c633e3acdd..4e514ddfd1 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -114,6 +114,8 @@ BOOL		LLViewerObject::sMapDebug = TRUE;
 LLColor4	LLViewerObject::sEditSelectColor(	1.0f, 1.f, 0.f, 0.3f);	// Edit OK
 LLColor4	LLViewerObject::sNoEditSelectColor(	1.0f, 0.f, 0.f, 0.3f);	// Can't edit
 S32			LLViewerObject::sAxisArrowLength(50);
+LLTrace::MemStatHandle	LLViewerObject::sMemStat("LLViewerObject");
+
 
 BOOL		LLViewerObject::sPulseEnabled(FALSE);
 BOOL		LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 63da7152b3..5556a4c7d3 100755
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -661,6 +661,7 @@ public:
 	LLPointer<class LLHUDIcon> mIcon;
 
 	static			BOOL		sUseSharedDrawables;
+	static	LLTrace::MemStatHandle	sMemStat;
 
 protected:
 	// delete an item in the inventory, but don't tell the
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index d87eb5d3db..60d78890b5 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -34,6 +34,8 @@
 #include "llviewerregion.h"
 #include "pipeline.h"
 
+LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
+
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
 	return apr_file->read(src, n_bytes) == n_bytes ;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index c43c42908f..c42374e154 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -157,6 +157,8 @@ public:
 	/*virtual*/ S32 cull(LLCamera &camera);
 	void addOccluders(LLviewerOctreeGroup* gp);
 
+	static	LLTrace::MemStatHandle	sMemStat;
+
 private:	
 	void processOccluders(LLCamera* camera, const LLVector3* region_agent);
 
-- 
cgit v1.2.3


From 2410b48c605e98c5380dd23bbd138e4516ae311d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 1 Jul 2013 22:05:57 -0600
Subject: revert the changeset 54cf2fe4820a for SH-4264 to fix SH-4315:
 Interesting: Viewer crash on login on Mac in
 LLViewerRegion::updateVisibleEntries(float) and SH-4316: Interesting Viewer
 Crash/freeze on Login to Levy region on Aditi with cleared cache on Windows
 XP

---
 indra/newview/llviewerregion.cpp | 42 ++++++++++++++++------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index d27b37d029..ca2a77c224 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -910,19 +910,19 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 		return;
 	}
 
-	bool is_orphan = false;
-	LLVOCacheEntry* parent = NULL;
 	if(entry->getParentID() > 0) //is a child
 	{
-		parent = getCacheEntry(entry->getParentID());
-		if(!parent)
+		LLVOCacheEntry* parent = getCacheEntry(entry->getParentID());
+		if(parent)
+		{
+			parent->addChild(entry);
+		}
+		else //parent not in cache.
 		{
-			is_orphan = true;
 			mOrphanMap[entry->getParentID()].push_back(entry->getLocalID());
 		}
 	}
-	
-	if(!is_orphan)//insert to vo cache tree.
+	else //insert to vo cache tree.
 	{
 		//shift to the local regional space from agent space
 		const LLVector3 pos = drawablep->getVObj()->getPositionRegion();
@@ -931,11 +931,6 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 		shift.setSub(vec, entry->getPositionGroup());
 		entry->shift(shift);
 		
-		if(parent) //is a child
-		{
-			entry->shift(parent->getPositionGroup());
-			parent->addChild(entry);
-		}
 		addToVOCacheTree(entry);
 	}
 
@@ -970,6 +965,10 @@ void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 	{
 		return;
 	}
+	if(entry->getParentID() > 0)
+	{
+		return; //no child prim in cache octree.
+	}
 
 	llassert(!entry->getEntry()->hasDrawable());
 
@@ -1103,8 +1102,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 				if(vo_entry->getParentID() > 0) //is a child
 				{
-					//child visibility depends on its parent, force its parent to be visible
-					addVisibleCacheEntry(getCacheEntry(vo_entry->getParentID()));
+					//child visibility depends on its parent.
 					continue;
 				}
 
@@ -1834,22 +1832,21 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 		//1, find the parent in cache
 		LLVOCacheEntry* parent = getCacheEntry(parent_id);
 		
-		//2, parent is not in the cache or not probed, put into the orphan list.
-		if(!parent || !parent->getEntry())
+		//2, parent is not in the cache, put into the orphan list.
+		if(!parent)
 		{
 			//check if parent is non-cacheable and already created
-			if(!parent && isNonCacheableObjectCreated(parent_id))
+			if(isNonCacheableObjectCreated(parent_id))
 			{
 				//parent is visible, so is the child.
 				addVisibleCacheEntry(entry);
 			}
 			else
 			{
-				entry->setBoundingInfo(pos, scale);
-			    mOrphanMap[parent_id].push_back(entry->getLocalID());
+				mOrphanMap[parent_id].push_back(entry->getLocalID());
 		    }
 		}
-		else //parent in cache octree or probed
+		else //parent in cache.
 		{
 			if(!parent->isState(LLVOCacheEntry::INACTIVE)) 
 			{
@@ -1858,9 +1855,6 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 			}
 			else
 			{
-				entry->setBoundingInfo(pos, scale);
-				entry->shift(parent->getPositionGroup());
-				addToVOCacheTree(entry);
 				parent->addChild(entry);
 			}
 		}
@@ -1890,8 +1884,6 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 				LLVOCacheEntry* child = getCacheEntry((*orphans)[i]);
 				if(child)
 				{
-					child->shift(entry->getPositionGroup());
-					addToVOCacheTree(child);
 					entry->addChild(child);
 				}
 			}
-- 
cgit v1.2.3


From e88c469de6b0e800ad9a2c11467d948ad891bdd9 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 2 Jul 2013 17:48:19 -0600
Subject: fix for SH-4264: interesting: Content near edges of screen does not
 load

---
 indra/newview/llviewerregion.cpp | 33 ++++++++++++-------
 indra/newview/llvocache.cpp      | 68 +++++++++++++++++++++++++++++++++++++++-
 indra/newview/llvocache.h        |  8 +++--
 3 files changed, 94 insertions(+), 15 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index ca2a77c224..b80d87ef07 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -905,11 +905,21 @@ void LLViewerRegion::addActiveCacheEntry(LLVOCacheEntry* entry)
 
 void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* drawablep)
 {
-	if(mDead)
+	if(mDead || !entry)
 	{
 		return;
 	}
 
+	//shift to the local regional space from agent space
+	if(drawablep != NULL && drawablep->getVObj().notNull())
+	{
+		const LLVector3& pos = drawablep->getVObj()->getPositionRegion();
+		LLVector4a shift;
+		shift.load3(pos.mV);
+		shift.sub(entry->getPositionGroup());
+		entry->shift(shift);
+	}
+
 	if(entry->getParentID() > 0) //is a child
 	{
 		LLVOCacheEntry* parent = getCacheEntry(entry->getParentID());
@@ -919,18 +929,13 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 		}
 		else //parent not in cache.
 		{
+			//this happens only when parent is not cacheable.
 			mOrphanMap[entry->getParentID()].push_back(entry->getLocalID());
 		}
 	}
 	else //insert to vo cache tree.
-	{
-		//shift to the local regional space from agent space
-		const LLVector3 pos = drawablep->getVObj()->getPositionRegion();
-		LLVector4a vec(pos[0], pos[1], pos[2]);
-		LLVector4a shift; 
-		shift.setSub(vec, entry->getPositionGroup());
-		entry->shift(shift);
-		
+	{		
+		entry->updateParentBoundingInfo();
 		addToVOCacheTree(entry);
 	}
 
@@ -1843,6 +1848,7 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 			}
 			else
 			{
+				entry->setBoundingInfo(pos, scale);
 				mOrphanMap[parent_id].push_back(entry->getLocalID());
 		    }
 		}
@@ -1855,6 +1861,7 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 			}
 			else
 			{
+				entry->setBoundingInfo(pos, scale);
 				parent->addChild(entry);
 			}
 		}
@@ -2055,7 +2062,7 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 		{
 			// Record a hit
 			entry->recordHit();
-		cache_miss_type = CACHE_MISS_TYPE_NONE;
+			cache_miss_type = CACHE_MISS_TYPE_NONE;
 			entry->setUpdateFlags(flags);
 			
 			if(entry->isState(LLVOCacheEntry::ACTIVE))
@@ -2064,7 +2071,11 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 				return true;
 			}
 
-			if(entry->getGroup() || !entry->isState(LLVOCacheEntry::INACTIVE))
+			if(entry->getGroup() || !entry->isState(LLVOCacheEntry::INACTIVE)) //already probed
+			{
+				return true;
+			}
+			if(entry->getParentID() > 0) //already probed
 			{
 				return true;
 			}
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 60d78890b5..69c32db13e 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -253,6 +253,12 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 	}
 
 	mChildrenList.push_back(entry);
+
+	//update parent bbox
+	if(getEntry() != NULL && isState(INACTIVE))
+	{
+		updateParentBoundingInfo(entry);
+	}
 }
 	
 LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc)
@@ -367,9 +373,69 @@ void LLVOCacheEntry::setBoundingInfo(const LLVector3& pos, const LLVector3& scal
 	
 	setPositionGroup(center);
 	setSpatialExtents(newMin, newMax);
-	setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f));
+
+	if(getNumOfChildren() > 0) //has children
+	{
+		updateParentBoundingInfo();
+	}
+	else
+	{
+		setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f));
+	}
+}
+
+//make the parent bounding box to include all children
+void LLVOCacheEntry::updateParentBoundingInfo()
+{
+	if(mChildrenList.empty())
+	{
+		return;
+	}
+
+	for(S32 i = 0; i < mChildrenList.size(); i++)
+	{
+		updateParentBoundingInfo(mChildrenList[i]);
+	}
 }
 
+//make the parent bounding box to include this child
+void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child)
+{
+	const LLVector4a* child_exts = child->getSpatialExtents();
+	LLVector4a newMin, newMax;
+	newMin = child_exts[0];
+	newMax = child_exts[1];
+	
+	//move to regional space.
+	{
+		const LLVector4a& parent_pos = getPositionGroup();
+		newMin.add(parent_pos);
+		newMax.add(parent_pos);
+	}
+
+	//update parent's bbox(min, max)
+	const LLVector4a* parent_exts = getSpatialExtents();
+	update_min_max(newMin, newMax, parent_exts[0]);
+	update_min_max(newMin, newMax, parent_exts[1]);
+	for(S32 i = 0; i < 4; i++)
+	{
+		llclamp(newMin[i], 0.f, 256.f);
+		llclamp(newMax[i], 0.f, 256.f);
+	}
+	setSpatialExtents(newMin, newMax);
+
+	//update parent's bbox center
+	LLVector4a center;
+	center.setAdd(newMin, newMax);
+	center.mul(0.5f);
+	setPositionGroup(center);	
+
+	//update parent's bbox size vector
+	LLVector4a size;
+	size.setSub(newMax, newMin);
+	size.mul(0.5f);
+	setBinRadius(llmin(size.getLength3().getF32() * 4.f, 256.f));
+}
 //-------------------------------------------------------------------
 //LLVOCachePartition
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index bf75cafac5..f077ae1fe1 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -111,10 +111,10 @@ public:
 	LLVOCacheEntry* getChild(S32 i) {return mChildrenList[i];}
 	S32  getNumOfChildren()         {return mChildrenList.size();}
 	void clearChildrenList()        {mChildrenList.clear();}
-
-	//called from processing object update message
-	void setBoundingInfo(const LLVector3& pos, const LLVector3& scale);
 	
+	void setBoundingInfo(const LLVector3& pos, const LLVector3& scale); //called from processing object update message	
+	void updateParentBoundingInfo();
+
 	void setTouched(BOOL touched = TRUE) {mTouched = touched;}
 	BOOL isTouched() const {return mTouched;}
 
@@ -124,6 +124,8 @@ public:
 private:
 	static U32  getInvisibleObjectsLiveTime();
 
+	void updateParentBoundingInfo(const LLVOCacheEntry* child);	
+
 public:
 	typedef std::map<U32, LLPointer<LLVOCacheEntry> >	   vocache_entry_map_t;
 	typedef std::set<LLVOCacheEntry*>                      vocache_entry_set_t;
-- 
cgit v1.2.3


From d122318bef2ff0eced7641dc24f411f792bd2935 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 8 Jul 2013 00:55:17 -0700
Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in
 statistics console added percentage/ratio units added auto-range and auto
 tick calculation to stat bar to automate display stats

---
 indra/newview/llappviewer.cpp                      |    6 -
 indra/newview/lldebugview.cpp                      |    1 -
 indra/newview/lldebugview.h                        |    2 -
 indra/newview/llfloaterjoystick.cpp                |    4 +-
 indra/newview/llfloaterreporter.cpp                |    2 +-
 indra/newview/lltexturectrl.h                      |    4 -
 indra/newview/lltexturefetch.cpp                   |   14 +-
 indra/newview/lltexturefetch.h                     |    4 +-
 indra/newview/llviewermenu.cpp                     |   14 -
 indra/newview/llviewerobjectlist.cpp               |   11 +-
 indra/newview/llviewerobjectlist.h                 |    4 +-
 indra/newview/llviewerstats.cpp                    |  122 +-
 indra/newview/llviewerstats.h                      |   16 +-
 indra/newview/llviewerthrottle.cpp                 |    6 +-
 indra/newview/llworld.cpp                          |   15 +-
 indra/newview/pipeline.cpp                         |    2 +-
 .../newview/skins/default/xui/en/floater_stats.xml | 1211 ++++++--------------
 17 files changed, 466 insertions(+), 972 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index e77f793a43..5f6b183fcc 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2070,8 +2070,6 @@ bool LLAppViewer::cleanup()
 
 	ll_close_fail_log();
 
-	MEM_TRACK_RELEASE
-
     llinfos << "Goodbye!" << llendflush;
 
 	// return 0;
@@ -2099,11 +2097,7 @@ void watchdog_killer_callback()
 
 bool LLAppViewer::initThreads()
 {
-#if MEM_TRACK_MEM
-	static const bool enable_threads = false;
-#else
 	static const bool enable_threads = true;
-#endif
 
 	LLImage::initClass(gSavedSettings.getBOOL("TextureNewByteRange"),gSavedSettings.getS32("TextureReverseByteRange"));
 
diff --git a/indra/newview/lldebugview.cpp b/indra/newview/lldebugview.cpp
index 1264f05d77..63dd59b020 100755
--- a/indra/newview/lldebugview.cpp
+++ b/indra/newview/lldebugview.cpp
@@ -55,7 +55,6 @@ static LLDefaultChildRegistry::Register<LLDebugView> r("debug_view");
 LLDebugView::LLDebugView(const LLDebugView::Params& p)
 :	LLView(p),
 	mFastTimerView(NULL),
-	mMemoryView(NULL),
 	mDebugConsolep(NULL),
 	mFloaterSnapRegion(NULL)
 {}
diff --git a/indra/newview/lldebugview.h b/indra/newview/lldebugview.h
index 5aec77ad62..a6490c876c 100755
--- a/indra/newview/lldebugview.h
+++ b/indra/newview/lldebugview.h
@@ -36,7 +36,6 @@
 class LLButton;
 class LLStatusPanel;
 class LLFastTimerView;
-class LLMemoryView;
 class LLConsole;
 class LLTextureView;
 class LLFloaterStats;
@@ -61,7 +60,6 @@ public:
 	void setStatsVisible(BOOL visible);
 	
 	LLFastTimerView* mFastTimerView;
-	LLMemoryView*	 mMemoryView;
 	LLConsole*		 mDebugConsolep;
 	LLView*			 mFloaterSnapRegion;
 };
diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index b71ab4c53b..adcecbbb7a 100755
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -85,7 +85,7 @@ void LLFloaterJoystick::draw()
 			if (llabs(value) > maxbar)
 			{
 				F32 range = llabs(value);
-				mAxisStatsBar[i]->setRange(-range, range, range * 0.25f);
+				mAxisStatsBar[i]->setRange(-range, range);
 			}
 		}
 	}
@@ -106,7 +106,7 @@ BOOL LLFloaterJoystick::postBuild()
 		if (mAxisStatsBar[i])
 		{
 			mAxisStatsBar[i]->setStat(stat_name);
-			mAxisStatsBar[i]->setRange(-range, range, range * 0.25f);
+			mAxisStatsBar[i]->setRange(-range, range);
 		}
 	}
 	
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index 35b63c5480..b42118a0c1 100755
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -784,7 +784,7 @@ void LLFloaterReporter::takeScreenshot()
 	image_in_list->createGLTexture(0, raw, 0, TRUE, LLGLTexture::OTHER);
 	
 	// the texture picker then uses that texture
-	LLTexturePicker* texture = getChild<LLTextureCtrl>("screenshot");
+	LLTextureCtrl* texture = getChild<LLTextureCtrl>("screenshot");
 	if (texture)
 	{
 		texture->setImageAssetID(mResourceDatap->mAssetInfo.mUuid);
diff --git a/indra/newview/lltexturectrl.h b/indra/newview/lltexturectrl.h
index ad79042ef1..15ca7bed92 100755
--- a/indra/newview/lltexturectrl.h
+++ b/indra/newview/lltexturectrl.h
@@ -227,8 +227,4 @@ private:
 	S32						 	mLabelWidth;
 };
 
-// XUI HACK: When floaters converted, switch this file to lltexturepicker.h/cpp
-// and class to LLTexturePicker
-#define LLTexturePicker LLTextureCtrl
-
 #endif  // LL_LLTEXTURECTRL_H
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 0390649a1c..6716391f41 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -64,9 +64,9 @@
 #include "bufferarray.h"
 #include "bufferstream.h"
 
-bool LLTextureFetchDebugger::sDebuggerEnabled = false ;
-LLTrace::SampleStatHandle<> LLTextureFetch::sCacheHitRate("texture_cache_hits");
-LLTrace::SampleStatHandle<> LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
+bool LLTextureFetchDebugger::sDebuggerEnabled = false;
+LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > LLTextureFetch::sCacheHitRate("texture_cache_hits");
+LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> > LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
 
 
 //////////////////////////////////////////////////////////////////////////////
@@ -1251,7 +1251,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			LL_DEBUGS("Texture") << mID << ": Cached. Bytes: " << mFormattedImage->getDataSize()
 								 << " Size: " << llformat("%dx%d",mFormattedImage->getWidth(),mFormattedImage->getHeight())
 								 << " Desired Discard: " << mDesiredDiscard << " Desired Size: " << mDesiredSize << LL_ENDL;
-			sample(LLTextureFetch::sCacheHitRate, 100.f);
+			record(LLTextureFetch::sCacheHitRate, LLUnits::Ratio::fromValue(1));
 		}
 		else
 		{
@@ -1269,7 +1269,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			}
 			
 			// fall through
-			sample(LLTextureFetch::sCacheHitRate, 0.f);
+			record(LLTextureFetch::sCacheHitRate, LLUnits::Ratio::fromValue(0));
 		}
 	}
 
@@ -2762,10 +2762,10 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
 			discard_level = worker->mDecodedDiscard;
 			raw = worker->mRawImage;
 			aux = worker->mAuxImage;
-			F32 cache_read_time = worker->mCacheReadTime;
+			LLUnit<F32, LLUnits::Seconds> cache_read_time = worker->mCacheReadTime;
 			if (cache_read_time != 0.f)
 			{
-				sample(sCacheReadLatency, cache_read_time * 1000.f);
+				record(sCacheReadLatency, cache_read_time);
 			}
 			res = true;
 			LL_DEBUGS("Texture") << id << ": Request Finished. State: " << worker->mState << " Discard: " << discard_level << LL_ENDL;
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 7fc58e230c..109f2bd401 100755
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -309,8 +309,8 @@ private:
 	LLMutex mQueueMutex;        //to protect mRequestMap and mCommands only
 	LLMutex mNetworkQueueMutex; //to protect mNetworkQueue, mHTTPTextureQueue and mCancelQueue.
 
-	static LLTrace::SampleStatHandle<> sCacheHitRate;
-	static LLTrace::SampleStatHandle<> sCacheReadLatency;
+	static LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > sCacheHitRate;
+	static LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> > sCacheReadLatency;
 
 	LLTextureCache* mTextureCache;
 	LLImageDecodeThread* mImageDecodeThread;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index fb199ba879..9f67aad297 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -475,14 +475,12 @@ void init_menus()
 	gAttachSubMenu = gMenuBarView->findChildMenuByName("Attach Object", TRUE);
 	gDetachSubMenu = gMenuBarView->findChildMenuByName("Detach Object", TRUE);
 
-#if !MEM_TRACK_MEM
 	// Don't display the Memory console menu if the feature is turned off
 	LLMenuItemCheckGL *memoryMenu = gMenuBarView->getChild<LLMenuItemCheckGL>("Memory", TRUE);
 	if (memoryMenu)
 	{
 		memoryMenu->setVisible(FALSE);
 	}
-#endif
 
 	gMenuBarView->createJumpKeys();
 
@@ -528,12 +526,6 @@ class LLAdvancedToggleConsole : public view_listener_t
 			toggle_visibility( (void*)gSceneView);
 		}
 
-#if MEM_TRACK_MEM
-		else if ("memory view" == console_type)
-		{
-			toggle_visibility( (void*)gDebugView->mMemoryView );
-		}
-#endif
 		return true;
 	}
 };
@@ -559,12 +551,6 @@ class LLAdvancedCheckConsole : public view_listener_t
 		{
 			new_value = get_visibility( (void*) gSceneView);
 		}
-#if MEM_TRACK_MEM
-		else if ("memory view" == console_type)
-		{
-			new_value = get_visibility( (void*)gDebugView->mMemoryView );
-		}
-#endif
 		
 		return new_value;
 	}
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index b215869a3e..8299c84663 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -95,12 +95,10 @@ extern LLPipeline	gPipeline;
 U32						LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check.
 std::map<U64, U32>		LLViewerObjectList::sIPAndPortToIndex;
 std::map<U64, LLUUID>	LLViewerObjectList::sIndexAndLocalIDToUUID;
-LLTrace::SampleStatHandle<>	LLViewerObjectList::sCacheHitRate("object_cache_hits");
+LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> >	LLViewerObjectList::sCacheHitRate("object_cache_hits");
 
 LLViewerObjectList::LLViewerObjectList()
 {
-	mNumVisCulled = 0;
-	mNumSizeCulled = 0;
 	mCurLazyUpdateIndex = 0;
 	mCurBin = 0;
 	mNumDeadObjects = 0;
@@ -358,7 +356,7 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 		}
 		justCreated = true;
 		mNumNewObjects++;
-		sample(sCacheHitRate, 100.f);
+		sample(sCacheHitRate, LLUnits::Percent::fromValue(100.f));
 	}
 
 	if (objectp->isDead())
@@ -1091,9 +1089,6 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	fetchObjectCosts();
 	fetchPhysicsFlags();
 
-	mNumSizeCulled = 0;
-	mNumVisCulled = 0;
-
 	// update max computed render cost
 	LLVOVolume::updateRenderComplexity();
 
@@ -1155,8 +1150,6 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 
 	sample(LLStatViewer::NUM_OBJECTS, mObjects.size());
 	sample(LLStatViewer::NUM_ACTIVE_OBJECTS, idle_count);
-	sample(LLStatViewer::NUM_SIZE_CULLED, mNumSizeCulled);
-	sample(LLStatViewer::NUM_VIS_CULLED, mNumVisCulled);
 }
 
 void LLViewerObjectList::fetchObjectCosts()
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 464554245e..741c7c7db9 100755
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -170,8 +170,6 @@ public:
 
 	// Statistics data (see also LLViewerStats)
 	S32 mNumNewObjects;
-	S32 mNumSizeCulled;
-	S32 mNumVisCulled;
 
 	// if we paused in the last frame
 	// used to discount stats from this frame
@@ -198,7 +196,7 @@ protected:
 	std::vector<OrphanInfo> mOrphanChildren;	// UUID's of orphaned objects
 	S32 mNumOrphans;
 
-	static LLTrace::SampleStatHandle<> sCacheHitRate;
+	static LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > sCacheHitRate;
 
 	typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 244c150b29..d753619daa 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -64,15 +64,14 @@
 namespace LLStatViewer
 {
 
-LLTrace::CountStatHandle<>	FPS("framesrendered"),
-							PACKETS_IN("packetsinstat"),
-							PACKETS_LOST("packetsloststat"),
-							PACKETS_OUT("packetsoutstat"),
-							TEXTURE_PACKETS("texturepacketsstat"),
-							TRIANGLES_DRAWN("trianglesdrawnstat"),
+LLTrace::CountStatHandle<>	FPS("FPS", "Frames rendered"),
+							PACKETS_IN("Packets In", "Packets received"),
+							PACKETS_LOST("packetsloststat", "Packets lost"),
+							PACKETS_OUT("packetsoutstat", "Packets sent"),
+							TEXTURE_PACKETS("texturepacketsstat", "Texture data packets received"),
 							CHAT_COUNT("chatcount", "Chat messages sent"),
 							IM_COUNT("imcount", "IMs sent"),
-							OBJECT_CREATE("objectcreate"),
+							OBJECT_CREATE("objectcreate", "Number of objects created"),
 							OBJECT_REZ("objectrez", "Object rez count"),
 							LOGIN_TIMEOUTS("logintimeouts", "Number of login attempts that timed out"),
 							LSL_SAVES("lslsaves", "Number of times user has saved a script"),
@@ -86,34 +85,35 @@ LLTrace::CountStatHandle<>	FPS("framesrendered"),
 							EDIT_TEXTURE("edittexture", "Changes to textures on objects"),
 							KILLED("killed", "Number of times killed"),
 							FRAMETIME_DOUBLED("frametimedoubled", "Ratio of frames 2x longer than previous"),
-							TEX_BAKES("texbakes"),
-							TEX_REBAKES("texrebakes"),
-							NUM_NEW_OBJECTS("numnewobjectsstat");
-LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibits> >	KBIT("kbitstat"),
-															LAYERS_KBIT("layerskbitstat"),
-															OBJECT_KBIT("objectkbitstat"),
-															ASSET_KBIT("assetkbitstat"),
-															TEXTURE_KBIT("texturekbitstat"),
-															ACTUAL_IN_KBIT("actualinkbitstat"),
-															ACTUAL_OUT_KBIT("actualoutkbitstat");
+							TEX_BAKES("texbakes", "Number of times avatar textures have been baked"),
+							TEX_REBAKES("texrebakes", "Number of times avatar textures have been forced to rebake"),
+							NUM_NEW_OBJECTS("numnewobjectsstat", "Number of objects in scene that were not previously in cache");
+
+LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> > TRIANGLES_DRAWN("trianglesdrawnstat");
+
+LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibits> >	KBIT("Bandwidth", "Network data received"),
+															LAYERS_KBIT("layerskbitstat", "Network data received for layer data (terrain)"),
+															OBJECT_KBIT("objectkbitstat", "Network data received for objects"),
+															ASSET_KBIT("assetkbitstat", "Network data received for assets (animations, sounds)"),
+															TEXTURE_KBIT("texturekbitstat", "Network data received for textures"),
+															ACTUAL_IN_KBIT("actualinkbitstat", "Incoming network data"),
+															ACTUAL_OUT_KBIT("actualoutkbitstat", "Outgoing network data");
 
 LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >	SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
 															SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
 															LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
 
-SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DILATION),
-							SIM_FPS("simfps", "", LL_SIM_STAT_FPS),
-							SIM_PHYSICS_FPS("simphysicsfps", "", LL_SIM_STAT_PHYSFPS),
+SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "Simulator time scale", LL_SIM_STAT_TIME_DILATION),
+							SIM_FPS("simfps", "Simulator framerate", LL_SIM_STAT_FPS),
+							SIM_PHYSICS_FPS("simphysicsfps", "Simulator physics framerate", LL_SIM_STAT_PHYSFPS),
 							SIM_AGENT_UPS("simagentups", "", LL_SIM_STAT_AGENTUPS),
 							SIM_SCRIPT_EPS("simscripteps", "", LL_SIM_STAT_SCRIPT_EPS),
 							SIM_SKIPPED_SILHOUETTE("simsimskippedsilhouettesteps", "", LL_SIM_STAT_SKIPPEDAISILSTEPS_PS),
-							SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters", "", LL_SIM_STAT_PCTSTEPPEDCHARACTERS),
-							SIM_MAIN_AGENTS("simmainagents", "", LL_SIM_STAT_NUMAGENTMAIN),
-							SIM_CHILD_AGENTS("simchildagents", "", LL_SIM_STAT_NUMAGENTCHILD),
+							SIM_MAIN_AGENTS("simmainagents", "Number of avatars in current region", LL_SIM_STAT_NUMAGENTMAIN),
+							SIM_CHILD_AGENTS("simchildagents", "Number of avatars in neighboring regions", LL_SIM_STAT_NUMAGENTCHILD),
 							SIM_OBJECTS("simobjects", "", LL_SIM_STAT_NUMTASKS),
-							SIM_ACTIVE_OBJECTS("simactiveobjects", "", LL_SIM_STAT_NUMTASKSACTIVE),
-							SIM_ACTIVE_SCRIPTS("simactivescripts", "", LL_SIM_STAT_NUMSCRIPTSACTIVE),
-							SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun", "", LL_SIM_STAT_PCTSCRIPTSRUN),
+							SIM_ACTIVE_OBJECTS("simactiveobjects", "Number of scripted and/or mocing objects", LL_SIM_STAT_NUMTASKSACTIVE),
+							SIM_ACTIVE_SCRIPTS("simactivescripts", "Number of scripted objects", LL_SIM_STAT_NUMSCRIPTSACTIVE),
 							SIM_IN_PACKETS_PER_SEC("siminpps", "", LL_SIM_STAT_INPPS),
 							SIM_OUT_PACKETS_PER_SEC("simoutpps", "", LL_SIM_STAT_OUTPPS),
 							SIM_PENDING_DOWNLOADS("simpendingdownloads", "", LL_SIM_STAT_PENDING_DOWNLOADS),
@@ -122,23 +122,25 @@ SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "", LL_SIM_STAT_TIME_DIL
 							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS),
 							SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS);
 
+SimMeasurement<LLUnit<F64, LLUnits::Percent> >	SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun", "", LL_SIM_STAT_PCTSCRIPTSRUN),
+												SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters", "", LL_SIM_STAT_PCTSTEPPEDCHARACTERS);
+
 LLTrace::SampleStatHandle<>	FPS_SAMPLE("fpssample"),
 							NUM_IMAGES("numimagesstat"),
 							NUM_RAW_IMAGES("numrawimagesstat"),
 							NUM_OBJECTS("numobjectsstat"),
 							NUM_ACTIVE_OBJECTS("numactiveobjectsstat"),
-							NUM_SIZE_CULLED("numsizeculledstat"),
-							NUM_VIS_CULLED("numvisculledstat"),
 							ENABLE_VBO("enablevbo", "Vertex Buffers Enabled"),
 							LIGHTING_DETAIL("lightingdetail", "Lighting Detail"),
 							VISIBLE_AVATARS("visibleavatars", "Visible Avatars"),
 							SHADER_OBJECTS("shaderobjects", "Object Shaders"),
 							DRAW_DISTANCE("drawdistance", "Draw Distance"),
 							PENDING_VFS_OPERATIONS("vfspendingoperations"),
-							PACKETS_LOST_PERCENT("packetslostpercentstat"),
 							WINDOW_WIDTH("windowwidth", "Window width"),
 							WINDOW_HEIGHT("windowheight", "Window height");
-	
+
+LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > PACKETS_LOST_PERCENT("packetslostpercentstat");
+
 static LLTrace::SampleStatHandle<S64> CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled");
 
 LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Megabytes> >	GL_TEX_MEM("gltexmemstat"),
@@ -150,38 +152,38 @@ LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	DELTA_BANDWIDTH("del
 
 	
 SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
-										SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS),
-										SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS),
-										SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS),
-										SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec", "", LL_SIM_STAT_SIMPHYSICSSTEPMS),
-										SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec", "", LL_SIM_STAT_SIMPHYSICSSHAPEMS),
-										SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec", "", LL_SIM_STAT_SIMPHYSICSOTHERMS),
-										SIM_AI_TIME("simsimaistepmsec", "", LL_SIM_STAT_SIMAISTEPTIMEMS),
-										SIM_AGENTS_TIME("simagentmsec", "", LL_SIM_STAT_AGENTMS),
-										SIM_IMAGES_TIME("simimagesmsec", "", LL_SIM_STAT_IMAGESMS),
-										SIM_SCRIPTS_TIME("simscriptmsec", "", LL_SIM_STAT_SCRIPTMS),
-										SIM_SPARE_TIME("simsparemsec", "", LL_SIM_STAT_SIMSPARETIME),
-										SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
-										SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
+													SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS),
+													SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS),
+													SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS),
+													SIM_PHYSICS_STEP_TIME("simsimphysicsstepmsec", "", LL_SIM_STAT_SIMPHYSICSSTEPMS),
+													SIM_PHYSICS_SHAPE_UPDATE_TIME("simsimphysicsshapeupdatemsec", "", LL_SIM_STAT_SIMPHYSICSSHAPEMS),
+													SIM_PHYSICS_OTHER_TIME("simsimphysicsothermsec", "", LL_SIM_STAT_SIMPHYSICSOTHERMS),
+													SIM_AI_TIME("simsimaistepmsec", "", LL_SIM_STAT_SIMAISTEPTIMEMS),
+													SIM_AGENTS_TIME("simagentmsec", "", LL_SIM_STAT_AGENTMS),
+													SIM_IMAGES_TIME("simimagesmsec", "", LL_SIM_STAT_IMAGESMS),
+													SIM_SCRIPTS_TIME("simscriptmsec", "", LL_SIM_STAT_SCRIPTMS),
+													SIM_SPARE_TIME("simsparemsec", "", LL_SIM_STAT_SIMSPARETIME),
+													SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
+													SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
 	
-SimMeasurement<LLUnit<F64, LLUnits::Bytes> >	SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES),
-												SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
+SimMeasurement<LLUnit<F64, LLUnits::Kilobytes> >	SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES);
+SimMeasurement<LLUnit<F64, LLUnits::Megabytes> >	SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
 
 LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
-													FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
-													SIM_PING("simpingstat");
+																FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
+																SIM_PING("simpingstat");
 
 LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Meters> > AGENT_POSITION_SNAP("agentpositionsnap", "agent position corrections");
 
 LLTrace::EventStatHandle<>	LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load");
 	
 LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
-												FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
-												UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
-												NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
-												IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
-												REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
-												RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
+																FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
+																UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
+																NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
+																IMAGE_STACKTIME("imagestacktime", "IMAGE_SECS"),
+																REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
+																RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
 	
 LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
 															TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
@@ -189,8 +191,6 @@ LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >	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");
-
-
 }
 
 LLViewerStats::LLViewerStats() 
@@ -378,17 +378,7 @@ void update_statistics()
 		gTextureTimer.unpause();
 	}
 	
-	{
-		static F32 visible_avatar_frames = 0.f;
-		static F32 avg_visible_avatars = 0;
-		F32 visible_avatars = (F32)LLVOAvatar::sNumVisibleAvatars;
-		if (visible_avatars > 0.f)
-		{
-			visible_avatar_frames = 1.f;
-			avg_visible_avatars = (avg_visible_avatars * (F32)(visible_avatar_frames - 1.f) + visible_avatars) / visible_avatar_frames;
-		}
-		sample(LLStatViewer::VISIBLE_AVATARS, (F64)avg_visible_avatars);
-	}
+	sample(LLStatViewer::VISIBLE_AVATARS, LLVOAvatar::sNumVisibleAvatars);
 	LLWorld::getInstance()->updateNetStats();
 	LLWorld::getInstance()->requestCacheMisses();
 	
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 879f0067b9..59d4df124b 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -72,7 +72,6 @@ extern LLTrace::CountStatHandle<>			FPS,
 											PACKETS_LOST,
 											PACKETS_OUT,
 											TEXTURE_PACKETS,
-											TRIANGLES_DRAWN,
 											CHAT_COUNT,
 											IM_COUNT,
 											OBJECT_CREATE,
@@ -93,6 +92,7 @@ extern LLTrace::CountStatHandle<>			FPS,
 											TEX_REBAKES,
 											NUM_NEW_OBJECTS;
 
+extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> > TRIANGLES_DRAWN;
 
 extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibits> >	KBIT,
 																	LAYERS_KBIT,
@@ -112,13 +112,11 @@ extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_AGENT_UPS,
 											SIM_SCRIPT_EPS,
 											SIM_SKIPPED_SILHOUETTE,
-											SIM_SKIPPED_CHARACTERS_PERCENTAGE,
 											SIM_MAIN_AGENTS,
 											SIM_CHILD_AGENTS,
 											SIM_OBJECTS,
 											SIM_ACTIVE_OBJECTS,
 											SIM_ACTIVE_SCRIPTS,
-											SIM_PERCENTAGE_SCRIPTS_RUN,
 											SIM_IN_PACKETS_PER_SEC,
 											SIM_OUT_PACKETS_PER_SEC,
 											SIM_PENDING_DOWNLOADS,
@@ -127,23 +125,25 @@ extern SimMeasurement<>						SIM_TIME_DILATION,
 											SIM_PHYSICS_PINNED_TASKS,
 											SIM_PHYSICS_LOD_TASKS;
 
+extern SimMeasurement<LLUnit<F64, LLUnits::Percent> >	SIM_PERCENTAGE_SCRIPTS_RUN,
+														SIM_SKIPPED_CHARACTERS_PERCENTAGE;
+
 extern LLTrace::SampleStatHandle<>		FPS_SAMPLE,
 										NUM_IMAGES,
 										NUM_RAW_IMAGES,
 										NUM_OBJECTS,
 										NUM_ACTIVE_OBJECTS,
-										NUM_SIZE_CULLED,
-										NUM_VIS_CULLED,
 										ENABLE_VBO,
 										LIGHTING_DETAIL,
 										VISIBLE_AVATARS,
 										SHADER_OBJECTS,
 										DRAW_DISTANCE,
 										PENDING_VFS_OPERATIONS,
-										PACKETS_LOST_PERCENT,
 										WINDOW_WIDTH,
 										WINDOW_HEIGHT;
 
+extern LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > PACKETS_LOST_PERCENT;
+
 extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Megabytes> >	GL_TEX_MEM,
 																	GL_BOUND_MEM,
 																	RAW_MEM,
@@ -165,8 +165,8 @@ extern SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME,
 															SIM_SLEEP_TIME,
 															SIM_PUMP_IO_TIME;
 
-extern SimMeasurement<LLUnit<F64, LLUnits::Bytes> >	SIM_UNACKED_BYTES,
-													SIM_PHYSICS_MEM;
+extern SimMeasurement<LLUnit<F64, LLUnits::Kilobytes> >	SIM_UNACKED_BYTES;
+extern SimMeasurement<LLUnit<F64, LLUnits::Megabytes> >	SIM_PHYSICS_MEM;
 
 
 extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	FRAMETIME_JITTER,
diff --git a/indra/newview/llviewerthrottle.cpp b/indra/newview/llviewerthrottle.cpp
index 34f2c8f6e6..b8de5871ea 100755
--- a/indra/newview/llviewerthrottle.cpp
+++ b/indra/newview/llviewerthrottle.cpp
@@ -48,8 +48,8 @@ const F32 MIN_FRACTIONAL = 0.2f;
 const F32 MIN_BANDWIDTH = 50.f;
 const F32 MAX_BANDWIDTH = 3000.f;
 const F32 STEP_FRACTIONAL = 0.1f;
-const F32 TIGHTEN_THROTTLE_THRESHOLD = 3.0f; // packet loss % per s
-const F32 EASE_THROTTLE_THRESHOLD = 0.5f; // packet loss % per s
+const LLUnit<F32, LLUnits::Percent> TIGHTEN_THROTTLE_THRESHOLD = 3.0f; // packet loss % per s
+const LLUnit<F32, LLUnits::Percent> EASE_THROTTLE_THRESHOLD = 0.5f; // packet loss % per s
 const F32 DYNAMIC_UPDATE_DURATION = 5.0f; // seconds
 
 LLViewerThrottle gViewerThrottle;
@@ -304,7 +304,7 @@ void LLViewerThrottle::updateDynamicThrottle()
 	}
 	mUpdateTimer.reset();
 
-	F32 mean_packets_lost = LLViewerStats::instance().getRecording().getMean(LLStatViewer::PACKETS_LOST_PERCENT);
+	LLUnit<F32, LLUnits::Percent> mean_packets_lost = LLViewerStats::instance().getRecording().getMean(LLStatViewer::PACKETS_LOST_PERCENT);
 	if (mean_packets_lost > TIGHTEN_THROTTLE_THRESHOLD)
 	{
 		if (mThrottleFrac <= MIN_FRACTIONAL || mCurrentBandwidth / 1024.0f <= MIN_BANDWIDTH)
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index a95adbf442..d45a62b223 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -711,7 +711,7 @@ void LLWorld::renderPropertyLines()
 
 void LLWorld::updateNetStats()
 {
-	F32 bits = 0.f;
+	LLUnit<F64, LLUnits::Bits> bits = 0.f;
 	U32 packets = 0;
 
 	for (region_list_t::iterator iter = mActiveRegionList.begin();
@@ -729,19 +729,18 @@ void LLWorld::updateNetStats()
 	S32 packets_out = gMessageSystem->mPacketsOut - mLastPacketsOut;
 	S32 packets_lost = gMessageSystem->mDroppedPackets - mLastPacketsLost;
 
-	S32 actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
-	S32 actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
+	LLUnit<F64, LLUnits::Bits> actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
+	LLUnit<F64, LLUnits::Bits> actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 
-	add(LLStatViewer::ACTUAL_IN_KBIT, LLUnit<F64, LLUnits::Bits>(actual_in_bits));
-	add(LLStatViewer::ACTUAL_OUT_KBIT, LLUnit<F64, LLUnits::Bits>(actual_out_bits));
-	add(LLStatViewer::KBIT, LLUnit<F64, LLUnits::Bits>(bits));
+	add(LLStatViewer::ACTUAL_IN_KBIT, actual_in_bits);
+	add(LLStatViewer::ACTUAL_OUT_KBIT, actual_out_bits);
+	add(LLStatViewer::KBIT, bits);
 	add(LLStatViewer::PACKETS_IN, packets_in);
 	add(LLStatViewer::PACKETS_OUT, packets_out);
 	add(LLStatViewer::PACKETS_LOST, packets_lost);
 	if (packets_in)
 	{
-		F32 packet_loss = 100.f * ((F32)packets_lost/(F32)packets_in);
-		sample(LLStatViewer::PACKETS_LOST_PERCENT, packet_loss);
+		sample(LLStatViewer::PACKETS_LOST_PERCENT, LLUnits::Ratio::fromValue((F32)packets_lost/(F32)packets_in));
 	}
 
 	mLastPacketsIn = gMessageSystem->mPacketsIn;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c2f5b9b861..76ecd84e11 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4686,7 +4686,7 @@ void LLPipeline::addTrianglesDrawn(S32 index_count, U32 render_type)
 	}
 
 	record(sStatBatchSize, count);
-	add(LLStatViewer::TRIANGLES_DRAWN, count);
+	add(LLStatViewer::TRIANGLES_DRAWN, LLUnits::Triangles::fromValue(count));
 
 	if (LLPipeline::sRenderFrameTest)
 	{
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 0493f487d4..def660e1e4 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -1,838 +1,379 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<floater
- legacy_header_height="18"
- can_resize="true"
- height="400"
- layout="topleft"
- name="Statistics"
- help_topic="statistics"
- save_rect="true"
- save_visibility="true"
- title="STATISTICS"
- width="260">
-    <scroll_container
-     follows="top|left|bottom|right"
-     height="380"
-     layout="topleft"
-     left="0"
-     name="statistics_scroll"
-     reserve_scroll_corner="true"
-     top="20"
-     width="260">
-      <container_view
-       follows="top|left|bottom|right"
-       height="378"
-       layout="topleft"
-       left="2"
-       name="statistics_view"
-       top="20"
-       width="245" >
-        <!--Basic Section-->
-		  <stat_view
-			 name="basic"
-			 label="Basic"
-       follows="left|top|right"
-			 show_label="true"
-			 setting="OpenDebugStatBasic">
-			<stat_bar
-			   name="fps"
-			   label="FPS"
-			   unit_label="fps"
-			   stat="framesrendered"
-			   bar_min="0"
-			   bar_max="60"
-			   tick_spacing="6"
-			   precision="1"
-			   show_bar="true"
-			   show_history="true">
-			</stat_bar>
-			<stat_bar
-			   name="bandwidth"
-			   label="Bandwidth"
-			   unit_label="kbps"
-			   stat="kbitstat"
-			   bar_min="0"
-			   bar_max="5000"
-			   tick_spacing="500"
-				 precision="0"
-			   show_bar="true"
-			   show_history="false">
-			</stat_bar>
-			<stat_bar
-			   name="packet_loss"
-			   label="Packet Loss"
-			   unit_label=" %"
-			   stat="packetslostpercentstat"
-			   bar_min="0"
-			   bar_max="5"
-			   tick_spacing="0.5"
-			   precision="3"
-			   show_bar="false"
-			   show_mean="true">
-			</stat_bar>
-			<stat_bar
-			   name="ping"
-			   label="Ping Sim"
-			   unit_label="msec"
-			   stat="simpingstat"
-			   bar_min="0"
-			   bar_max="5000"
-			   tick_spacing="500"
-				 precision="0"
-			   show_bar="false"
-			   show_mean="false">
-			</stat_bar>
-		  </stat_view>
-          <!--Advanced Section-->
-      <stat_view
-			 name="advanced"
-			 label="Advanced"
-       follows="left|top|right"       
-			 show_label="true"
-			 setting="OpenDebugStatAdvanced">
-			<stat_view
-			   name="render"
-			   label="Render"
-         follows="left|top|right"
-			   show_label="true"
-			   setting="OpenDebugStatRender">
-			  <stat_bar
-				 name="ktrisframe"
-				 label="KTris Drawn per Frame"
-				 unit_label="/fr"
-				 stat="trianglesdrawnstat"
-         unit_scale="0.001"
-				 bar_min="0"
-				 bar_max="10000"
-				 tick_spacing="1000"
-				 precision="0"
-				 show_per_sec="false"
-         show_bar="false">
-        </stat_bar>
-			  <stat_bar
-				 name="ktrissec"
-				 label="KTris Drawn per Sec"
-				 unit_label="/sec"
-         unit_scale="0.001"
-				 stat="trianglesdrawnstat"
-				 bar_min="0"
-				 bar_max="200000"
-				 tick_spacing="25000"
-				 precision="0"
-         show_bar="false">
-        </stat_bar>
-			  <stat_bar
-				 name="objs"
-				 label="Total Objects"
-				 unit_label=""
-				 stat="numobjectsstat"
-				 bar_min="0"
-				 bar_max="50000"
-				 tick_spacing="5000"
-				 precision="0"
-				 show_bar="false">
-			  </stat_bar>
-			  <stat_bar
-				 name="newobjs"
-				 label="New Objects"
-				 unit_label="/sec"
-				 stat="numnewobjectsstat"
-				 bar_min="0"
-				 bar_max="2000"
-				 tick_spacing="200"
-				 show_bar="false">
-			  </stat_bar>
-       <stat_bar
-				 name="object_cache_hits"
-				 label="Object Cache Hit Rate"
-				 stat="object_cache_hits"
-				 bar_min="0"
-				 bar_max="100"
-         unit_label="%"
-				 tick_spacing="20"
-				 show_history="true"
-				 show_bar="false">
-        </stat_bar>
-			</stat_view>
-        <!--Texture Stats-->
-			<stat_view
-			   name="texture"
-			   label="Texture"
-         follows="left|top|right"
-			   show_label="true">
-			  <stat_bar
-				 name="texture_cache_hits"
-				 label="Cache Hit Rate"
-				 stat="texture_cache_hits"
-				 bar_min="0.f"
-				 bar_max="100.f"
-         unit_label="%"
-				 tick_spacing="20"
-				 show_history="true"
-				 show_bar="false">
-        </stat_bar>
-        <stat_bar
-				 name="texture_cache_read_latency"
-				 label="Cache Read Latency"
-         unit_label="msec"
-				 stat="texture_cache_read_latency"
-				 bar_min="0.f"
-				 bar_max="1000.f"
-				 tick_spacing="100"
-				 show_history="true"
-				 show_bar="false">
-        </stat_bar>
-        <stat_bar
-				 name="numimagesstat"
-				 label="Count"
-				 stat="numimagesstat" 
-				 bar_min="0.f"
-				 bar_max="8000.f" 
-				 tick_spacing="2000.f"
-				 show_bar="false">
-			  </stat_bar>
-
-			  <stat_bar
-				 name="numrawimagesstat"
-				 label="Raw Count"
-				 stat="numrawimagesstat"
-				 bar_min="0.f"
-				 bar_max="8000.f" 
-				 tick_spacing="2000.f"
-				 show_bar="false">
-			  </stat_bar>
-
-			  <stat_bar
-				 name="gltexmemstat"
-				 label="GL Mem"
-				 stat="gltexmemstat"
-         unit_label="MB"
-         unit_scale="0.000001"
-				 bar_min="0.f"
-				 bar_max="400.f" 
-				 tick_spacing="100.f"
-				 precision="1"
-         show_bar="false">
-        </stat_bar>
-
-			  <stat_bar
-				 name="formattedmemstat"
-				 label="Formatted Mem"
-				 stat="formattedmemstat"
-         unit_label="MB"
-         unit_scale="0.000001"
-				 bar_min="0.f"
-				 bar_max="400.f" 
-				 tick_spacing="100.f"
-				 precision="3"
-         show_bar="false">
-        </stat_bar>
-
-			  <stat_bar
-				 name="rawmemstat"
-				 label="Raw Mem"
-         unit_label="MB"
-         unit_scale="0.000001"
-				 stat="rawmemstat"
-				 bar_min="0.f"
-				 bar_max="400.f" 
-				 tick_spacing="100.f"
-				 precision="3"
-         show_bar="false">
-        </stat_bar>
-
-			  <stat_bar
-				 name="glboundmemstat"
-				 label="Bound Mem"
-				 stat="glboundmemstat"
-         unit_label="MB"
-         unit_scale="0.000001"
-				 bar_min="0.f"
-				 bar_max="400.f" 
-				 tick_spacing="100.f"
-				 precision="3"
-         show_bar="false">
-        </stat_bar>
-			</stat_view>
-        <!--Network Stats-->
-			<stat_view
-			   name="network"
-			   label="Network"
-         follows="left|top|right"
-			   show_label="true"
-			   setting="OpenDebugStatNet">
-			  <stat_bar
-				 name="packetsinstat"
-				 label="Packets In"
-				 stat="packetsinstat"
-				 unit_label="/sec" 
-         bar_min="0.f"
-				 bar_max="1024.f" 
-				 tick_spacing="128.f"
-				 precision="1"
-				 show_bar="false">
-			  </stat_bar>
-
-			  <stat_bar
-				 name="packetsoutstat"
-				 label="Packets Out"
-				 stat="packetsoutstat"
-				 unit_label="/sec"  
-         bar_min="0.f"
-				 bar_max="1024.f" 
-				 tick_spacing="128.f"
-				 precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="objectkbitstat"
-				 label="Objects"
-				 stat="objectkbitstat"
-         unit_label="kbps"
-         bar_min="0.f"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="texturekbitstat"
-				 label="Texture"
-				 stat="texturekbitstat"
-         unit_label="kbps"
-         bar_min="0.f"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="assetkbitstat"
-				 label="Asset"
-				 stat="assetkbitstat"
-         unit_label="kbps"
-         bar_min="0.f"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="layerskbitstat"
-				 label="Layers"
-				 stat="layerskbitstat"
-         unit_label="kbps"
-         bar_min="0.f"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         precision="1"
-				 show_bar="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="actualinkbitstat"
-				 label="Actual In"
-				 stat="actualinkbitstat"
-         unit_label="kbps"
-         bar_min="0.f"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         precision="1"
-				 show_bar="false"
-				 show_history="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="actualoutkbitstat"
-				 label="Actual Out"
-				 stat="actualoutkbitstat"
-         unit_label="kbps"
-         bar_min="0.f"
-         bar_max="1024.f"
-         tick_spacing="128.f"
-         precision="1"
-				 show_bar="false"
-				 show_history="false">
-			  </stat_bar>
-
-			  <stat_bar
-				 name="vfspendingoperations"
-				 label="VFS Pending Operations"
-				 stat="vfspendingoperations"
-				 unit_label=" Ops."
-				 show_bar="false" >
-			  </stat_bar>
-			</stat_view>
-		  </stat_view>
-        <!--Sim Stats-->
-		  <stat_view
-			 name="sim"
-			 label="Simulator"
-       follows="left|top|right"
-			 show_label="true"
-			 setting="OpenDebugStatSim">
-			<stat_bar
-			   name="simtimedilation"
-			   label="Time Dilation"
-			   stat="simtimedilation"
-			   precision="3"
-			   bar_min="0.f"
-			   bar_max="1.f" 
-			   tick_spacing="0.16666f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simfps"
-			   label="Sim FPS"
-			   stat="simfps"
-			   precision="1"
-			   bar_min="0.f"
-			   bar_max="45.f" 
-			   tick_spacing="7.5f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simphysicsfps"
-			   label="Physics FPS"
-			   stat="simphysicsfps"
-			   precision="1"
-			   bar_min="0.f"
-			   bar_max="45.f" 
-			   tick_spacing="7.5.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_view
-			   name="physicsdetail"
-			   label="Physics Details"
-         follows="left|top|right"
-			   show_label="true">
-			  <stat_bar
-				 name="physicspinnedtasks"
-				 label="Pinned Objects"
-				 stat="physicspinnedtasks"
-				 precision="0" 
-				 bar_min="0.f"
-				 bar_max="500.f" 
-				 tick_spacing="50.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="physicslodtasks"
-				 label="Low LOD Objects"
-				 stat="physicslodtasks"
-				 precision="0"
-				 bar_min="0.f"
-				 bar_max="500.f" 
-				 tick_spacing="50.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="physicsmemoryallocated"
-				 label="Memory Allocated"
-				 stat="physicsmemoryallocated"
-				 unit_label="MB"
-				 precision="1"
-				 bar_min="0.f"
-				 bar_max="1024.f" 
-				 tick_spacing="128.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-		  </stat_view>
-
-			<stat_bar
-			   name="simagentups"
-			   label="Agent Updates/Sec"
-			   stat="simagentups"
-			   precision="1"
-			   bar_min="0.f"
-			   bar_max="100.f" 
-			   tick_spacing="25.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simmainagents"
-			   label="Main Agents"
-			   stat="simmainagents"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="80.f" 
-			   tick_spacing="10.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simchildagents"
-			   label="Child Agents"
-			   stat="simchildagents"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="40.f" 
-			   tick_spacing="5.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simobjects"
-			   label="Objects"
-			   stat="simobjects"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="30000.f" 
-			   tick_spacing="5000.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simactiveobjects"
-			   label="Active Objects"
-			   stat="simactiveobjects"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="5000.f" 
-			   tick_spacing="750.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simactivescripts"
-			   label="Active Scripts"
-			   stat="simactivescripts"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="15000.f" 
-			   tick_spacing="1875.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-        <stat_bar
-            name="simpctscriptsrun"
-            label="Scripts Run"
-            unit_label=" %"
-            stat="simpctscriptsrun"
-            bar_min="0"
-            bar_max="100"
-            tick_spacing="10"
-            precision="3"
-            show_bar="false"
-            show_mean="true">
-        </stat_bar>
-
-			<stat_bar
-			   name="simscripteps"
-			   label="Script Events"
-			   stat="simscripteps"
-			   unit_label="eps"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="5000.f" 
-			   tick_spacing="750.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-        <stat_view
-            name="simpathfinding"
-            label="Pathfinding"
-            follows="left|top|right"
-            show_label="true">
-          <stat_bar
-              name="simsimaistepmsec"
-              label="  AI Step Time"
-              stat="simsimaistepmsec"
-              unit_label="ms"
-              precision="3"
-              bar_min="0.f"
-              bar_max="40.f"
-              tick_spacing="10.f"
-              show_bar="false"
-              show_mean="false" >
-          </stat_bar>
-          <stat_bar
-              name="simsimskippedsilhouettesteps"
-              label="  Skipped Silhouette Steps"
-              stat="simsimskippedsilhouettesteps"
-              unit_label="/sec"
-              precision="0"
-              bar_min="0"
-              bar_max="45"
-              tick_spacing="4"
-              show_bar="false">
-          </stat_bar>
-          <stat_bar
-              name="simsimpctsteppedcharacters"
-              label="  Characters Updated"
-              unit_label=" %"
-              stat="simsimpctsteppedcharacters"
-              bar_min="0"
-              bar_max="100"
-              tick_spacing="10"
-              precision="1"
-              show_bar="false"
-              show_mean="true">
-          </stat_bar>
+<floater legacy_header_height="18"
+         can_resize="true"
+         height="400"
+         layout="topleft"
+         name="Statistics"
+         help_topic="statistics"
+         save_rect="true"
+         save_visibility="true"
+         title="STATISTICS"
+         width="260">
+  <scroll_container follows="all"
+                    height="380"
+                    layout="topleft"
+                    left="0"
+                    name="statistics_scroll"
+                    reserve_scroll_corner="true"
+                    top="20"
+                    width="260">
+    <container_view follows="all"
+                    height="378"
+                    layout="topleft"
+                    left="2"
+                    name="statistics_view"
+                    top="20"
+                    width="245" >
+     <stat_view name="basic"
+                 label="Basic"
+                 follows="left|top|right"
+                 show_label="true"
+                 show_bar="true"
+                 setting="OpenDebugStatBasic">
+        <stat_bar name="fps"
+                  label="FPS"
+                  unit_label="frames"
+                  stat="FPS"
+                  decimal_digits="1"
+                  bar_max="60"
+                  show_bar="true"
+                  show_history="true"/>
+        <stat_bar name="bandwidth"
+                  label="Bandwidth"
+                  stat="Bandwidth"
+                  show_bar="true"/>
+        <stat_bar name="packet_loss"
+                  label="Packet Loss"
+                  stat="packetslostpercentstat"
+                  decimal_digits="3"/>
+        <stat_bar name="ping"
+                  label="Ping Sim"
+                  stat="simpingstat"
+                  show_mean="false"/>
+      </stat_view>
+
+     <stat_view name="advanced"
+                 label="Advanced"
+                 follows="left|top|right"
+                 show_bar="true"
+                 show_label="true"
+                 setting="OpenDebugStatAdvanced">
+        <stat_view name="render"
+                   label="Render"
+                   follows="left|top|right"
+                   show_bar="true"
+                   show_label="true"
+                   setting="OpenDebugStatRender">
+          <stat_bar name="ktrisframe"
+                    label="KTris per Frame"
+                    unit_label="ktris/fr"
+                    stat="trianglesdrawnstat"
+                    show_per_sec="false"/>
+          <stat_bar name="ktrissec"
+                    label="KTris per Sec"
+                    stat="trianglesdrawnstat"/>
+          <stat_bar name="objs"
+                    label="Total Objects"
+                    stat="numobjectsstat"/>
+          <stat_bar name="newobjs"
+                    label="New Objects"
+                    stat="numnewobjectsstat"
+                    bar_max="2000"/>
+          <stat_bar name="object_cache_hits"
+                    label="Object Cache Hit Rate"
+                    stat="object_cache_hits"
+                    bar_max="100"
+                    show_history="true"/>
         </stat_view>
-
-			<stat_bar
-			   name="siminpps"
-			   label="Packets In"
-			   stat="siminpps"
-			   unit_label="pps"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="2000.f" 
-			   tick_spacing="250.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simoutpps"
-			   label="Packets Out"
-			   stat="simoutpps"
-			   unit_label="pps" 
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="2000.f" 
-			   tick_spacing="250.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simpendingdownloads"
-			   label="Pending Downloads"
-			   stat="simpendingdownloads"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="800.f" 
-			   tick_spacing="100.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simpendinguploads"
-			   label="Pending Uploads"
-			   stat="simpendinguploads"
-			   precision="0"
-			   bar_min="0.f"
-			   bar_max="100.f" 
-			   tick_spacing="25.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_bar
-			   name="simtotalunackedbytes"
-			   label="Total Unacked Bytes"
-			   stat="simtotalunackedbytes"
-			   unit_label="kb"
-			   precision="1"
-			   bar_min="0.f"
-			   bar_max="100000.f" 
-			   tick_spacing="25000.f"
-			   show_bar="false"
-			   show_mean="false" >
-			</stat_bar>
-
-			<stat_view
-			   name="simperf"
-			   label="Time (ms)"
-         follows="left|top|right"
-			   show_label="true">
-			  <stat_bar
-				 name="simframemsec"
-				 label="Total Frame Time"
-				 stat="simframemsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_min="0.f"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simnetmsec"
-				 label="Net Time"
-				 stat="simnetmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_min="0.f"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simsimphysicsmsec"
-				 label="Physics Time"
-				 stat="simsimphysicsmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_min="0.f"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simsimothermsec"
-				 label="Simulation Time"
-				 stat="simsimothermsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_min="0.f"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simagentmsec"
-				 label="Agent Time"
-				 stat="simagentmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_min="0.f"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simimagesmsec"
-				 label="Images Time"
-				 stat="simimagesmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_min="0.f"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-			  <stat_bar
-				 name="simscriptmsec"
-				 label="Script Time"
-				 stat="simscriptmsec"
-				 unit_label="ms"
-				 precision="3"
-				 bar_min="0.f"
-				 bar_max="40.f" 
-				 tick_spacing="10.f"
-				 show_bar="false"
-				 show_mean="false" >
-			  </stat_bar>
-
-        <stat_bar
-         name="simsparemsec"
-         label="Spare Time"
-         stat="simsparemsec"
-         unit_label="ms"
-         precision="3"
-         bar_min="0.f"
-         bar_max="40.f"
-         tick_spacing="10.f"
-         show_bar="false"
-         show_mean="false" >
-        </stat_bar>
-        <!--2nd level time blocks under 'Details' second-->
-          <stat_view
- 			     name="timedetails"
-			     label="Time Details (ms)"
-           follows="left|top|right"
-			     show_label="true">
-            <stat_bar
-             name="simsimphysicsstepmsec"
-             label="  Physics Step"
-             stat="simsimphysicsstepmsec"
-             unit_label="ms"
-             precision="3"
-             bar_min="0.f"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simsimphysicsshapeupdatemsec"
-             label="  Update Phys Shapes"
-             stat="simsimphysicsshapeupdatemsec"
-             unit_label="ms"
-             precision="3"
-             bar_min="0.f"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simsimphysicsothermsec"
-             label="  Physics Other"
-             stat="simsimphysicsothermsec"
-             unit_label="ms"
-             precision="3"
-             bar_min="0.f"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simsleepmsec"
-             label="  Sleep Time"
-             stat="simsleepmsec"
-             unit_label="ms"
-             precision="3"
-             bar_min="0.f"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-            <stat_bar
-             name="simpumpiomsec"
-             label="  Pump IO"
-             stat="simpumpiomsec"
-             unit_label="ms"
-             precision="3"
-             bar_min="0.f"
-             bar_max="40.f"
-             tick_spacing="10.f"
-             show_bar="false"
-             show_mean="false" >
-            </stat_bar>
-			</stat_view>
-			</stat_view>
-		  </stat_view>
-		</container_view>
-    </scroll_container>
+        <stat_view name="texture"
+                   label="Texture"
+                   follows="left|top|right"
+                   show_bar="true"
+                   show_label="true">
+          <stat_bar name="texture_cache_hits"
+                    label="Cache Hit Rate"
+                    stat="texture_cache_hits"
+                    bar_max="100"
+                    show_history="true"/>
+          <stat_bar name="texture_cache_read_latency"
+                    label="Cache Read Latency"
+                    stat="texture_cache_read_latency"
+                    show_history="true"/>
+          <stat_bar name="numimagesstat"
+                    label="Count"
+                    stat="numimagesstat"/>
+          <stat_bar name="numrawimagesstat"
+                    label="Raw Count"
+                    stat="numrawimagesstat"/>
+          <stat_bar name="gltexmemstat"
+                    label="GL Mem"
+                    stat="gltexmemstat"
+                    decimal_digits="1"/>
+          <stat_bar name="formattedmemstat"
+                    label="Formatted Mem"
+                    stat="formattedmemstat"
+                    decimal_digits="3"/>
+          <stat_bar name="rawmemstat"
+                    label="Raw Mem"
+                    stat="rawmemstat"
+                    decimal_digits="3"/>
+          <stat_bar name="glboundmemstat"
+                    label="Bound Mem"
+                    stat="glboundmemstat"
+                    decimal_digits="3"/>
+        </stat_view>
+        
+        <stat_view name="network"
+                   label="Network"
+                   follows="left|top|right"
+                   show_bar="true"         
+                   show_label="true"
+                   setting="OpenDebugStatNet">
+          <stat_bar name="packetsinstat"
+                    label="Packets In"
+                    stat="Packets In"
+                    decimal_digits="1"/>
+          <stat_bar name="packetsoutstat"
+                    label="Packets Out"
+                    stat="packetsoutstat"
+                    decimal_digits="1"/>
+          <stat_bar name="objectkbitstat"
+                    label="Objects"
+                    stat="objectkbitstat"
+                    decimal_digits="1"/>
+          <stat_bar name="texturekbitstat"
+                    label="Texture"
+                    stat="texturekbitstat"
+                    decimal_digits="1"/>
+          <stat_bar name="assetkbitstat"
+                    label="Asset"
+                    stat="assetkbitstat"
+                    decimal_digits="1"/>
+          <stat_bar name="layerskbitstat"
+                    label="Layers"
+                    stat="layerskbitstat"
+                    decimal_digits="1"/>
+          <stat_bar name="actualinkbitstat"
+                    label="Actual In"
+                    stat="actualinkbitstat"
+                    decimal_digits="1"/>
+          <stat_bar name="actualoutkbitstat"
+                    label="Actual Out"
+                    stat="actualoutkbitstat"
+                    decimal_digits="1"
+                    show_history="false"/>
+          <stat_bar name="vfspendingoperations"
+                    label="VFS Pending Operations"
+                    stat="vfspendingoperations"
+                    unit_label="Ops."/>
+        </stat_view>
+      </stat_view>
+
+      <stat_view name="sim"
+                 label="Simulator"
+                 follows="left|top|right"
+                 show_bar="true"       
+                 show_label="true"
+                 setting="OpenDebugStatSim">
+        <stat_bar name="simtimedilation"
+                  label="Time Dilation"
+                  stat="simtimedilation"
+                  decimal_digits="3"
+                  bar_max="1" 
+                  show_mean="false"/>
+        <stat_bar name="simfps"
+                  label="Sim FPS"
+                  stat="simfps"
+                  decimal_digits="1"
+                  bar_max="45" 
+                  show_mean="false"/>
+        <stat_bar name="simphysicsfps"
+                  label="Physics FPS"
+                  stat="simphysicsfps"
+                  decimal_digits="1"
+                  bar_max="45" 
+                  show_mean="false"/>
+        <stat_view name="physicsdetail"
+                   label="Physics Details"
+                   follows="left|top|right"
+                   show_bar="true"         
+                   show_label="true">
+          <stat_bar name="physicspinnedtasks"
+                    label="Pinned Objects"
+                    stat="physicspinnedtasks"
+                    show_mean="false"/>
+          <stat_bar name="physicslodtasks"
+                    label="Low LOD Objects"
+                    stat="physicslodtasks"
+                    show_mean="false"/>
+          <stat_bar name="physicsmemoryallocated"
+                    label="Memory Allocated"
+                    stat="physicsmemoryallocated"
+                    decimal_digits="1"
+                    show_mean="false"/>
+        </stat_view>
+        <stat_bar name="simagentups"
+                  label="Agent Updates/Sec"
+                  stat="simagentups"
+                  decimal_digits="1"
+                  show_mean="false"/>
+        <stat_bar name="simmainagents"
+                  label="Main Agents"
+                  stat="simmainagents"
+                  bar_max="80" 
+                  show_mean="false"/>
+        <stat_bar name="simchildagents"
+                  label="Child Agents"
+                  stat="simchildagents"
+                  show_mean="false"/>
+        <stat_bar name="simobjects"
+                  label="Objects"
+                  stat="simobjects"
+                  bar_max="30000" 
+                  show_mean="false"/>
+        <stat_bar name="simactiveobjects"
+                  label="Active Objects"
+                  stat="simactiveobjects"
+                  bar_max="5000" 
+                  show_mean="false"/>
+        <stat_bar name="simactivescripts"
+                  label="Active Scripts"
+                  stat="simactivescripts"
+                  bar_max="15000" 
+                  show_mean="false"/>
+        <stat_bar name="simpctscriptsrun"
+                  label="Scripts Run"
+                  stat="simpctscriptsrun"
+                  bar_max="100"
+                  decimal_digits="3"
+                  show_mean="true"/>
+        <stat_bar name="simscripteps"
+                  label="Script Events"
+                  stat="simscripteps"
+                  unit_label="eps"
+                  show_mean="false"/>
+        <stat_view name="simpathfinding"
+                   label="Pathfinding"
+                   follows="left|top|right"
+                   show_bar="true"        
+                   show_label="true">
+          <stat_bar name="simsimaistepmsec"
+                    label="AI Step Time"
+                    stat="simsimaistepmsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simsimskippedsilhouettesteps"
+                    label="Skipped Silhouette Steps"
+                    stat="simsimskippedsilhouettesteps"
+                    unit_label="/sec"
+                    bar_max="45"/>
+          <stat_bar name="simsimpctsteppedcharacters"
+                    stat="simsimpctsteppedcharacters"
+                    bar_max="100"
+                    decimal_digits="1"
+                    show_mean="true"/>
+        </stat_view>
+        <stat_bar name="siminpps"
+                  label="Packets In"
+                  stat="siminpps"
+                  unit_label="pkt/sec"
+                  show_mean="false"/>
+        <stat_bar name="simoutpps"
+                  label="Packets Out"
+                  stat="simoutpps"
+                  unit_label="pkt/sec" 
+                  show_mean="false"/>
+        <stat_bar name="simpendingdownloads"
+                  label="Pending Downloads"
+                  stat="simpendingdownloads"
+                  show_mean="false"/>
+        <stat_bar name="simpendinguploads"
+                  label="Pending Uploads"
+                  stat="simpendinguploads"
+                  show_mean="false"/>
+        <stat_bar name="simtotalunackedbytes"
+                  label="Total Unacked Bytes"
+                  stat="simtotalunackedbytes"
+                  decimal_digits="1"
+                  show_mean="false"/>
+        <stat_view name="simperf"
+                   label="Time"
+                   follows="left|top|right"
+                   show_bar="true"
+                   show_label="true">
+          <stat_bar name="simframemsec"
+                    label="Total Frame Time"
+                    stat="simframemsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simnetmsec"
+                    label="Net Time"
+                    stat="simnetmsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simsimphysicsmsec"
+                    label="Physics Time"
+                    stat="simsimphysicsmsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simsimothermsec"
+                    label="Simulation Time"
+                    stat="simsimothermsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simagentmsec"
+                    label="Agent Time"
+                    stat="simagentmsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simimagesmsec"
+                    label="Images Time"
+                    stat="simimagesmsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simscriptmsec"
+                    label="Script Time"
+                    stat="simscriptmsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_bar name="simsparemsec"
+                    label="Spare Time"
+                    stat="simsparemsec"
+                    decimal_digits="3"
+                    show_mean="false"/>
+          <stat_view name="timedetails"
+                     label="Time Details"
+                     follows="left|top|right"
+                     show_bar="true"
+                     show_label="true">
+            <stat_bar name="simsimphysicsstepmsec"
+                      label="Physics Step"
+                      stat="simsimphysicsstepmsec"
+                      decimal_digits="3"
+                      show_mean="false"/>
+            <stat_bar name="simsimphysicsshapeupdatemsec"
+                      label="Update Phys Shapes"
+                      stat="simsimphysicsshapeupdatemsec"
+                      decimal_digits="3"
+                      show_mean="false"/>
+            <stat_bar name="simsimphysicsothermsec"
+                      label="Physics Other"
+                      stat="simsimphysicsothermsec"
+                      decimal_digits="3"
+                      show_mean="false"/>
+            <stat_bar name="simsleepmsec"
+                      label="Sleep Time"
+                      stat="simsleepmsec"
+                      decimal_digits="3"
+                      show_mean="false"/>
+            <stat_bar name="simpumpiomsec"
+                      label="Pump IO"
+                      stat="simpumpiomsec"
+                      decimal_digits="3"
+                      show_mean="false"/>
+          </stat_view>
+        </stat_view>
+      </stat_view>
+    </container_view>
+  </scroll_container>
 </floater>
-- 
cgit v1.2.3


From c95042db3e8d2f1a938e7d6e9ca625700d634639 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 12 Jul 2013 00:52:31 -0700
Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in
 statistics console improved calculation of display range for stat bars

---
 .../newview/skins/default/xui/en/floater_stats.xml | 110 +++++++--------------
 1 file changed, 37 insertions(+), 73 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index def660e1e4..ad7094c6d8 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -35,10 +35,9 @@
                   unit_label="frames"
                   stat="FPS"
                   decimal_digits="1"
-                  bar_max="60"
                   show_bar="true"
                   show_history="true"/>
-        <stat_bar name="bandwidth"
+       <!-- <stat_bar name="bandwidth"
                   label="Bandwidth"
                   stat="Bandwidth"
                   show_bar="true"/>
@@ -48,8 +47,7 @@
                   decimal_digits="3"/>
         <stat_bar name="ping"
                   label="Ping Sim"
-                  stat="simpingstat"
-                  show_mean="false"/>
+                  stat="simpingstat"/>
       </stat_view>
 
      <stat_view name="advanced"
@@ -179,20 +177,17 @@
                   label="Time Dilation"
                   stat="simtimedilation"
                   decimal_digits="3"
-                  bar_max="1" 
-                  show_mean="false"/>
+                  bar_max="1" />
         <stat_bar name="simfps"
                   label="Sim FPS"
                   stat="simfps"
                   decimal_digits="1"
-                  bar_max="45" 
-                  show_mean="false"/>
+                  bar_max="45" />
         <stat_bar name="simphysicsfps"
                   label="Physics FPS"
                   stat="simphysicsfps"
                   decimal_digits="1"
-                  bar_max="45" 
-                  show_mean="false"/>
+                  bar_max="45" />
         <stat_view name="physicsdetail"
                    label="Physics Details"
                    follows="left|top|right"
@@ -200,58 +195,47 @@
                    show_label="true">
           <stat_bar name="physicspinnedtasks"
                     label="Pinned Objects"
-                    stat="physicspinnedtasks"
-                    show_mean="false"/>
+                    stat="physicspinnedtasks"/>
           <stat_bar name="physicslodtasks"
                     label="Low LOD Objects"
-                    stat="physicslodtasks"
-                    show_mean="false"/>
+                    stat="physicslodtasks"/>
           <stat_bar name="physicsmemoryallocated"
                     label="Memory Allocated"
                     stat="physicsmemoryallocated"
-                    decimal_digits="1"
-                    show_mean="false"/>
+                    decimal_digits="1"/>
         </stat_view>
         <stat_bar name="simagentups"
                   label="Agent Updates/Sec"
                   stat="simagentups"
-                  decimal_digits="1"
-                  show_mean="false"/>
+                  decimal_digits="1"/>
         <stat_bar name="simmainagents"
                   label="Main Agents"
                   stat="simmainagents"
-                  bar_max="80" 
-                  show_mean="false"/>
+                  bar_max="80"/>
         <stat_bar name="simchildagents"
                   label="Child Agents"
-                  stat="simchildagents"
-                  show_mean="false"/>
+                  stat="simchildagents"/>
         <stat_bar name="simobjects"
                   label="Objects"
                   stat="simobjects"
-                  bar_max="30000" 
-                  show_mean="false"/>
+                  bar_max="30000" />
         <stat_bar name="simactiveobjects"
                   label="Active Objects"
                   stat="simactiveobjects"
-                  bar_max="5000" 
-                  show_mean="false"/>
+                  bar_max="5000"/>
         <stat_bar name="simactivescripts"
                   label="Active Scripts"
                   stat="simactivescripts"
-                  bar_max="15000" 
-                  show_mean="false"/>
+                  bar_max="15000"/>
         <stat_bar name="simpctscriptsrun"
                   label="Scripts Run"
                   stat="simpctscriptsrun"
                   bar_max="100"
-                  decimal_digits="3"
-                  show_mean="true"/>
+                  decimal_digits="3"/>
         <stat_bar name="simscripteps"
                   label="Script Events"
                   stat="simscripteps"
-                  unit_label="eps"
-                  show_mean="false"/>
+                  unit_label="eps"/>
         <stat_view name="simpathfinding"
                    label="Pathfinding"
                    follows="left|top|right"
@@ -260,8 +244,7 @@
           <stat_bar name="simsimaistepmsec"
                     label="AI Step Time"
                     stat="simsimaistepmsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simsimskippedsilhouettesteps"
                     label="Skipped Silhouette Steps"
                     stat="simsimskippedsilhouettesteps"
@@ -270,32 +253,26 @@
           <stat_bar name="simsimpctsteppedcharacters"
                     stat="simsimpctsteppedcharacters"
                     bar_max="100"
-                    decimal_digits="1"
-                    show_mean="true"/>
+                    decimal_digits="1"/>
         </stat_view>
         <stat_bar name="siminpps"
                   label="Packets In"
                   stat="siminpps"
-                  unit_label="pkt/sec"
-                  show_mean="false"/>
+                  unit_label="pkt/sec"/>
         <stat_bar name="simoutpps"
                   label="Packets Out"
                   stat="simoutpps"
-                  unit_label="pkt/sec" 
-                  show_mean="false"/>
+                  unit_label="pkt/sec"/>
         <stat_bar name="simpendingdownloads"
                   label="Pending Downloads"
-                  stat="simpendingdownloads"
-                  show_mean="false"/>
+                  stat="simpendingdownloads"/>
         <stat_bar name="simpendinguploads"
                   label="Pending Uploads"
-                  stat="simpendinguploads"
-                  show_mean="false"/>
+                  stat="simpendinguploads"/>
         <stat_bar name="simtotalunackedbytes"
                   label="Total Unacked Bytes"
                   stat="simtotalunackedbytes"
-                  decimal_digits="1"
-                  show_mean="false"/>
+                  decimal_digits="1"/>
         <stat_view name="simperf"
                    label="Time"
                    follows="left|top|right"
@@ -304,43 +281,35 @@
           <stat_bar name="simframemsec"
                     label="Total Frame Time"
                     stat="simframemsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simnetmsec"
                     label="Net Time"
                     stat="simnetmsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simsimphysicsmsec"
                     label="Physics Time"
                     stat="simsimphysicsmsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simsimothermsec"
                     label="Simulation Time"
                     stat="simsimothermsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simagentmsec"
                     label="Agent Time"
                     stat="simagentmsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simimagesmsec"
                     label="Images Time"
                     stat="simimagesmsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simscriptmsec"
                     label="Script Time"
                     stat="simscriptmsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_bar name="simsparemsec"
                     label="Spare Time"
                     stat="simsparemsec"
-                    decimal_digits="3"
-                    show_mean="false"/>
+                    decimal_digits="3"/>
           <stat_view name="timedetails"
                      label="Time Details"
                      follows="left|top|right"
@@ -349,30 +318,25 @@
             <stat_bar name="simsimphysicsstepmsec"
                       label="Physics Step"
                       stat="simsimphysicsstepmsec"
-                      decimal_digits="3"
-                      show_mean="false"/>
+                      decimal_digits="3"/>
             <stat_bar name="simsimphysicsshapeupdatemsec"
                       label="Update Phys Shapes"
                       stat="simsimphysicsshapeupdatemsec"
-                      decimal_digits="3"
-                      show_mean="false"/>
+                      decimal_digits="3"/>
             <stat_bar name="simsimphysicsothermsec"
                       label="Physics Other"
                       stat="simsimphysicsothermsec"
-                      decimal_digits="3"
-                      show_mean="false"/>
+                      decimal_digits="3"/>
             <stat_bar name="simsleepmsec"
                       label="Sleep Time"
                       stat="simsleepmsec"
-                      decimal_digits="3"
-                      show_mean="false"/>
+                      decimal_digits="3"/>
             <stat_bar name="simpumpiomsec"
                       label="Pump IO"
                       stat="simpumpiomsec"
-                      decimal_digits="3"
-                      show_mean="false"/>
+                      decimal_digits="3"/>
           </stat_view>
-        </stat_view>
+        </stat_view>-->
       </stat_view>
     </container_view>
   </scroll_container>
-- 
cgit v1.2.3


From 11e14cd3b0f58225a96b9b7a9839a7f030fe4045 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 15 Jul 2013 11:05:57 -0700
Subject: SH-4299Interesting: High fps shown temporarily off scale in
 statistics console various fixes to lltrace start() on started recording no
 longer resets fixed various instances of unit forgetfullness in lltrace
 recording split now has gapless timing scene monitor now guarantees min
 sample time renamed a bunch of stats added names to debug thread view on
 windows

---
 indra/newview/llappviewer.cpp                      |  1 +
 indra/newview/llscenemonitor.cpp                   | 36 ++++++++++-----
 indra/newview/llscenemonitor.h                     |  2 +-
 indra/newview/llstatusbar.cpp                      |  2 +-
 indra/newview/lltexturefetch.cpp                   |  4 +-
 indra/newview/lltexturefetch.h                     |  8 ++--
 indra/newview/lltextureview.cpp                    |  4 +-
 indra/newview/llviewerassetstats.cpp               | 47 +++++++++----------
 indra/newview/llviewerstats.cpp                    | 52 ++++++++++++----------
 indra/newview/llviewerstats.h                      | 14 +++---
 indra/newview/llviewertexturelist.cpp              |  6 +--
 indra/newview/llviewerwindow.cpp                   |  2 +
 indra/newview/llworld.cpp                          | 10 ++---
 .../default/xui/en/floater_scene_load_stats.xml    | 28 ++++++------
 .../newview/skins/default/xui/en/floater_stats.xml | 32 ++++++-------
 15 files changed, 135 insertions(+), 113 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 5f6b183fcc..47492aaa31 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1294,6 +1294,7 @@ bool LLAppViewer::mainLoop()
 	{
 		LLFastTimer _(FTM_FRAME);
 		LLTrace::TimeBlock::processTimes();
+		llassert(LLStatViewer::FPS.getPrimaryAccumulator()->getSampleCount() <= 1);
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
 
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 342b45863a..eec4a703a1 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -256,7 +256,7 @@ void LLSceneMonitor::unfreezeScene()
 
 void LLSceneMonitor::capture()
 {
-	static U32 last_capture_time = 0;
+	static U32 last_capture_frame = 0;
 	static LLCachedControl<bool> monitor_enabled(gSavedSettings, "SceneLoadingMonitorEnabled");
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static LLFrameTimer timer;	
@@ -268,11 +268,11 @@ void LLSceneMonitor::capture()
 		if(mEnabled)
 		{
 			unfreezeScene();
+			reset();
 			force_capture = true;
 		}
 		else
 		{
-			reset();
 			freezeScene();
 		}
 
@@ -280,8 +280,8 @@ void LLSceneMonitor::capture()
 	}
 
 	if (mEnabled 
-		&&	(mMonitorRecording.getSum(*LLViewerCamera::getVelocityStat()) > 0.1f
-		|| mMonitorRecording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.05f))
+		&& (mMonitorRecording.getSum(*LLViewerCamera::getVelocityStat()) > 0.1f
+			|| mMonitorRecording.getSum(*LLViewerCamera::getAngularVelocityStat()) > 0.05f))
 	{
 		reset();
 		freezeScene();
@@ -290,9 +290,10 @@ void LLSceneMonitor::capture()
 
 	if((timer.getElapsedTimeF32() > scene_load_sample_time() 
 			|| force_capture)
+		&& mDiffState == WAITING_FOR_NEXT_DIFF
 		&& mEnabled
 		&& LLGLSLShader::sNoFixedFunction
-		&& last_capture_time != gFrameCount)
+		&& last_capture_frame != gFrameCount)
 	{
 		force_capture = false;
 
@@ -301,7 +302,7 @@ void LLSceneMonitor::capture()
 
 		timer.reset();
 
-		last_capture_time = gFrameCount;
+		last_capture_frame = gFrameCount;
 
 		LLRenderTarget& cur_target = getCaptureTarget();
 
@@ -465,7 +466,11 @@ void LLSceneMonitor::fetchQueryResult()
 {
 	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
 
-	if(mDiffState == WAIT_ON_RESULT)
+	// also throttle timing here, to avoid going below sample time due to phasing with frame capture
+	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
+	static LLFrameTimer timer;	
+
+	if(mDiffState == WAIT_ON_RESULT && timer.getElapsedTimeF32() > scene_load_sample_time)
 	{
 		mDiffState = WAITING_FOR_NEXT_DIFF;
 
@@ -479,7 +484,7 @@ void LLSceneMonitor::fetchQueryResult()
 			mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
 
 			LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
-			record(sFramePixelDiff, mDiffResult);
+			record(sFramePixelDiff, sqrtf(mDiffResult));
 
 			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
 			if(mDiffResult > diff_threshold())
@@ -488,7 +493,7 @@ void LLSceneMonitor::fetchQueryResult()
 			}
 			else
 			{
-				mSceneLoadRecording.getPotentialRecording().nextPeriod();
+				mSceneLoadRecording.nextPeriod();
 			}
 		}
 	}
@@ -506,7 +511,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 	os << std::setprecision(10);
 
-	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getAcceptedRecording();
+	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getResults();
 	const U32 frame_count = scene_load_recording.getNumRecordedPeriods();
 
 	LLUnit<F64, LLUnits::Seconds> frame_time;
@@ -519,6 +524,15 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	}
 	os << '\n';
 
+	os << "Sample period(s)";
+	for (S32 frame = 1; frame <= frame_count; frame++)
+	{
+		frame_time = scene_load_recording.getPrevRecording(frame_count - frame).getDuration();
+		os << ", " << frame_time.value();
+	}
+	os << '\n';
+
+
 	typedef TraceType<CountAccumulator> trace_count;
 	for (trace_count::instance_iter it = trace_count::beginInstances(), end_it = trace_count::endInstances();
 		it != end_it;
@@ -697,7 +711,7 @@ void LLSceneMonitorView::draw()
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
 	lines++;
 
-	num_str = llformat("Scene Loading time: %.3f seconds", (F32)LLSceneMonitor::getInstance()->getRecording()->getAcceptedRecording().getDuration().value());
+	num_str = llformat("Scene Loading time: %.3f seconds", (F32)LLSceneMonitor::getInstance()->getRecording()->getResults().getDuration().value());
 	LLFontGL::getFontMonospace()->renderUTF8(num_str, 0, 5, getRect().getHeight() - line_height * lines, color, LLFontGL::LEFT, LLFontGL::TOP);
 	lines++;
 
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 9717310da4..7088d529d6 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.getAcceptedRecording().getDuration() != 0;}
+	bool hasResults() const { return mSceneLoadRecording.getResults().getDuration() != 0;}
 
 private:
 	void freezeScene();
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index f3406d9f8d..b385d5cdfa 100755
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -198,7 +198,7 @@ BOOL LLStatusBar::postBuild()
 	sgp.rect(r);
 	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
 	sgp.mouse_opaque(false);
-	sgp.stat.count_stat_float(&LLStatViewer::KBIT);
+	sgp.stat.count_stat_float(&LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED);
 	sgp.units("Kbps");
 	sgp.precision(0);
 	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 6716391f41..d85247c4ec 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -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() << "/" << mFetcher->mMaxBandwidth
+								 << " Bandwidth(kbps): " << mFetcher->getTextureBandwidth().value() << "/" << mFetcher->mMaxBandwidth
 								 << LL_ENDL;
 
 			// Will call callbackHttpGet when curl request completes
@@ -2891,7 +2891,7 @@ S32 LLTextureFetch::update(F32 max_time_ms)
 		mNetworkQueueMutex.lock();										// +Mfnq
 		mMaxBandwidth = band_width;
 
-		add(LLStatViewer::TEXTURE_KBIT, mHTTPTextureBits);
+		add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, mHTTPTextureBits);
 		mHTTPTextureBits = 0;
 
 		mNetworkQueueMutex.unlock();									// -Mfnq
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 109f2bd401..38272b40dc 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(F32 bandwidth) { mTextureBandwidth = bandwidth; }
+	void setTextureBandwidth(LLUnit<F32, LLUnits::Kibibits> bandwidth) { mTextureBandwidth = bandwidth; }
 	
     // Threads:  T* (but not safe)
-	F32 getTextureBandwidth() { return mTextureBandwidth; }
+	LLUnit<F32, LLUnits::Kibibits> getTextureBandwidth() { return mTextureBandwidth; }
 	
     // Threads:  T*
 	BOOL isFromLocalCache(const LLUUID& id);
@@ -325,8 +325,8 @@ private:
 	queue_t mHTTPTextureQueue;											// Mfnq
 	typedef std::map<LLHost,std::set<LLUUID> > cancel_queue_t;
 	cancel_queue_t mCancelQueue;										// Mfnq
-	F32 mTextureBandwidth;												// <none>
-	F32 mMaxBandwidth;													// Mfnq
+	LLUnit<F32, LLUnits::Kibibits> mTextureBandwidth;					// <none>
+	LLUnit<F32, LLUnits::Kibibits> mMaxBandwidth;						// Mfnq
 	LLTextureInfo mTextureInfo;
 
 	// XXX possible delete
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 72ed3d4485..20e8a522cd 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -586,8 +586,8 @@ void LLGLTexMemBar::draw()
 
 
 	left = 550;
-	F32 bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
-	F32 max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
+	LLUnit<F32, LLUnits::Kibibits> bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
+	LLUnit<F32, LLUnits::Kibibits> 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, max_bandwidth);
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 80412c215f..5f11a2b519 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -153,29 +153,29 @@ namespace LLViewerAssetStatsFF
 		};
 
 		if (at < 0 || at >= LLViewerAssetType::AT_COUNT)
-{
+		{
 			return EVACOtherGet;
-}
+		}
 		EViewerAssetCategories ret(asset_to_bin_map[at]);
 		if (EVACTextureTempHTTPGet == ret)
 		{
 			// Indexed with [is_temp][with_http]
 			static const EViewerAssetCategories texture_bin_map[2][2] =
-{
-	{
+			{
+				{
 					EVACTextureNonTempUDPGet,
-						EVACTextureNonTempHTTPGet,
+					EVACTextureNonTempHTTPGet,
 				},
 				{
 					EVACTextureTempUDPGet,
-						EVACTextureTempHTTPGet,
-	}
+					EVACTextureTempHTTPGet,
+				}
 			};
 	
 			ret = texture_bin_map[is_temp][with_http];
 		}
 		return ret;
-}
+	}
 
 	static LLTrace::CountStatHandle<> sEnqueueAssetRequestsTempTextureHTTP   ("enqueuedassetrequeststemptexturehttp", 
 																	"Number of temporary texture asset http requests enqueued"),
@@ -384,50 +384,50 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 									.resp_min(rec.getMin(*sResponse[EVACTextureTempHTTPGet]).value())
 									.resp_max(rec.getMax(*sResponse[EVACTextureTempHTTPGet]).value())
 									.resp_mean(rec.getMean(*sResponse[EVACTextureTempHTTPGet]).value());
-}
+		}
 		if (!compact_output
 			|| rec.getSum(*sEnqueued[EVACTextureTempUDPGet]) 
 			|| rec.getSum(*sDequeued[EVACTextureTempUDPGet])
 			|| rec.getSum(*sResponse[EVACTextureTempUDPGet]).value())
-{
+		{
 			r.get_texture_temp_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACTextureTempUDPGet]))
 									.dequeued((S32)rec.getSum(*sDequeued[EVACTextureTempUDPGet]))
 									.resp_count((S32)rec.getSum(*sResponse[EVACTextureTempUDPGet]).value())
 									.resp_min(rec.getMin(*sResponse[EVACTextureTempUDPGet]).value())
 									.resp_max(rec.getMax(*sResponse[EVACTextureTempUDPGet]).value())
 									.resp_mean(rec.getMean(*sResponse[EVACTextureTempUDPGet]).value());
-}
+		}
 		if (!compact_output
 			|| rec.getSum(*sEnqueued[EVACTextureNonTempHTTPGet]) 
 			|| rec.getSum(*sDequeued[EVACTextureNonTempHTTPGet])
 			|| rec.getSum(*sResponse[EVACTextureNonTempHTTPGet]).value())
-{
+		{
 			r.get_texture_non_temp_http	.enqueued((S32)rec.getSum(*sEnqueued[EVACTextureNonTempHTTPGet]))
 										.dequeued((S32)rec.getSum(*sDequeued[EVACTextureNonTempHTTPGet]))
 										.resp_count((S32)rec.getSum(*sResponse[EVACTextureNonTempHTTPGet]).value())
 										.resp_min(rec.getMin(*sResponse[EVACTextureNonTempHTTPGet]).value())
 										.resp_max(rec.getMax(*sResponse[EVACTextureNonTempHTTPGet]).value())
 										.resp_mean(rec.getMean(*sResponse[EVACTextureNonTempHTTPGet]).value());
-}
+		}
 
 		if (!compact_output
 			|| rec.getSum(*sEnqueued[EVACTextureNonTempUDPGet]) 
 			|| rec.getSum(*sDequeued[EVACTextureNonTempUDPGet])
 			|| rec.getSum(*sResponse[EVACTextureNonTempUDPGet]).value())
-{
+		{
 			r.get_texture_non_temp_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACTextureNonTempUDPGet]))
 										.dequeued((S32)rec.getSum(*sDequeued[EVACTextureNonTempUDPGet]))
 										.resp_count((S32)rec.getSum(*sResponse[EVACTextureNonTempUDPGet]).value())
 										.resp_min(rec.getMin(*sResponse[EVACTextureNonTempUDPGet]).value())
 										.resp_max(rec.getMax(*sResponse[EVACTextureNonTempUDPGet]).value())
 										.resp_mean(rec.getMean(*sResponse[EVACTextureNonTempUDPGet]).value());
-}
+		}
 
 		if (!compact_output
 			|| rec.getSum(*sEnqueued[EVACWearableUDPGet]) 
 			|| rec.getSum(*sDequeued[EVACWearableUDPGet])
 			|| rec.getSum(*sResponse[EVACWearableUDPGet]).value())
-{
+		{
 			r.get_wearable_udp	.enqueued((S32)rec.getSum(*sEnqueued[EVACWearableUDPGet]))
 								.dequeued((S32)rec.getSum(*sDequeued[EVACWearableUDPGet]))
 								.resp_count((S32)rec.getSum(*sResponse[EVACWearableUDPGet]).value())
@@ -478,16 +478,16 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 		S32 fps = (S32)rec.getLastValue(LLStatViewer::FPS_SAMPLE);
 		if (!compact_output || fps != 0)
 		{
-			r.fps.count(fps);
-			r.fps.min(rec.getMin(LLStatViewer::FPS_SAMPLE));
-			r.fps.max(rec.getMax(LLStatViewer::FPS_SAMPLE));
-			r.fps.mean(rec.getMean(LLStatViewer::FPS_SAMPLE));
+			r.fps	.count(fps)
+					.min(rec.getMin(LLStatViewer::FPS_SAMPLE))
+					.max(rec.getMax(LLStatViewer::FPS_SAMPLE))
+					.mean(rec.getMean(LLStatViewer::FPS_SAMPLE));
 		}
 		U32 grid_x(0), grid_y(0);
 		grid_from_region_handle(it->first, &grid_x, &grid_y);
-		r.grid_x(grid_x);
-		r.grid_y(grid_y);
-		r.duration(LLUnit<F64, LLUnits::Microseconds>(rec.getDuration()).value());
+		r	.grid_x(grid_x)
+			.grid_y(grid_y)
+			.duration(LLUnit<F64, LLUnits::Microseconds>(rec.getDuration()).value());
 	}
 
 	stats.duration(mCurRecording ? LLUnit<F64, LLUnits::Microseconds>(mCurRecording->getDuration()).value() : 0.0);
@@ -526,6 +526,7 @@ void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
+	llinfos << "enqueue " << int(eac) << llendl;
 	add(*sEnqueued[int(eac)], 1);
 }
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index d753619daa..69a6c00a8f 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -89,19 +89,22 @@ LLTrace::CountStatHandle<>	FPS("FPS", "Frames rendered"),
 							TEX_REBAKES("texrebakes", "Number of times avatar textures have been forced to rebake"),
 							NUM_NEW_OBJECTS("numnewobjectsstat", "Number of objects in scene that were not previously in cache");
 
-LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> > TRIANGLES_DRAWN("trianglesdrawnstat");
-
-LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibits> >	KBIT("Bandwidth", "Network data received"),
-															LAYERS_KBIT("layerskbitstat", "Network data received for layer data (terrain)"),
-															OBJECT_KBIT("objectkbitstat", "Network data received for objects"),
-															ASSET_KBIT("assetkbitstat", "Network data received for assets (animations, sounds)"),
-															TEXTURE_KBIT("texturekbitstat", "Network data received for textures"),
-															ACTUAL_IN_KBIT("actualinkbitstat", "Incoming network data"),
-															ACTUAL_OUT_KBIT("actualoutkbitstat", "Outgoing network data");
-
-LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >	SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
-															SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
-															LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
+LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> > 
+							TRIANGLES_DRAWN("trianglesdrawnstat");
+
+LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	
+							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"),
+							ASSET_UDP_DATA_RECEIVED("assetudpdatareceived", "Network data received for assets (animations, sounds) over UDP message system"),
+							TEXTURE_NETWORK_DATA_RECEIVED("texturedatareceived", "Network data received for textures"),
+							MESSAGE_SYSTEM_DATA_IN("messagedatain", "Incoming message system network data"),
+							MESSAGE_SYSTEM_DATA_OUT("messagedataout", "Outgoing message system network data");
+
+LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >	
+							SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
+							SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
+							LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
 
 SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "Simulator time scale", LL_SIM_STAT_TIME_DILATION),
 							SIM_FPS("simfps", "Simulator framerate", LL_SIM_STAT_FPS),
@@ -122,8 +125,9 @@ SimMeasurement<>			SIM_TIME_DILATION("simtimedilation", "Simulator time scale",
 							SIM_PHYSICS_PINNED_TASKS("physicspinnedtasks", "", LL_SIM_STAT_PHYSICS_PINNED_TASKS),
 							SIM_PHYSICS_LOD_TASKS("physicslodtasks", "", LL_SIM_STAT_PHYSICS_LOD_TASKS);
 
-SimMeasurement<LLUnit<F64, LLUnits::Percent> >	SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun", "", LL_SIM_STAT_PCTSCRIPTSRUN),
-												SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters", "", LL_SIM_STAT_PCTSTEPPEDCHARACTERS);
+SimMeasurement<LLUnit<F64, LLUnits::Percent> >	
+							SIM_PERCENTAGE_SCRIPTS_RUN("simpctscriptsrun", "", LL_SIM_STAT_PCTSCRIPTSRUN),
+							SIM_SKIPPED_CHARACTERS_PERCENTAGE("simsimpctsteppedcharacters", "", LL_SIM_STAT_PCTSTEPPEDCHARACTERS);
 
 LLTrace::SampleStatHandle<>	FPS_SAMPLE("fpssample"),
 							NUM_IMAGES("numimagesstat"),
@@ -139,9 +143,11 @@ LLTrace::SampleStatHandle<>	FPS_SAMPLE("fpssample"),
 							WINDOW_WIDTH("windowwidth", "Window width"),
 							WINDOW_HEIGHT("windowheight", "Window height");
 
-LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > PACKETS_LOST_PERCENT("packetslostpercentstat");
+LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > 
+							PACKETS_LOST_PERCENT("packetslostpercentstat");
 
-static LLTrace::SampleStatHandle<S64> CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled");
+static LLTrace::SampleStatHandle<bool> 
+							CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled");
 
 LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Megabytes> >	GL_TEX_MEM("gltexmemstat"),
 															GL_BOUND_MEM("glboundmemstat"),
@@ -197,12 +203,10 @@ LLViewerStats::LLViewerStats()
 :	mLastTimeDiff(0.0)
 {
 	mRecording.start();
-	LLTrace::get_frame_recording().start();
 }
 
 LLViewerStats::~LLViewerStats()
-{
-}
+{}
 
 void LLViewerStats::resetStats()
 {
@@ -363,10 +367,10 @@ void update_statistics()
 	add(LLStatViewer::FPS, 1);
 
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	add(LLStatViewer::LAYERS_KBIT, LLUnit<F64, LLUnits::Bits>(layer_bits));
-	add(LLStatViewer::OBJECT_KBIT, gObjectData);
+	add(LLStatViewer::LAYERS_NETWORK_DATA_RECEIVED, LLUnit<F64, LLUnits::Bits>(layer_bits));
+	add(LLStatViewer::OBJECT_NETWORK_DATA_RECEIVED, gObjectData);
 	sample(LLStatViewer::PENDING_VFS_OPERATIONS, LLVFile::getVFSThread()->getPending());
-	add(LLStatViewer::ASSET_KBIT, LLUnit<F64, LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)));
+	add(LLStatViewer::ASSET_UDP_DATA_RECEIVED, LLUnit<F64, LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)));
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
 	if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
@@ -393,7 +397,7 @@ void update_statistics()
 		static LLFrameTimer texture_stats_timer;
 		if (texture_stats_timer.getElapsedTimeF32() >= texture_stats_freq)
 		{
-			gTotalTextureData = LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_KBIT);
+			gTotalTextureData = LLViewerStats::instance().getRecording().getSum(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED);
 			texture_stats_timer.reset();
 		}
 	}
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 59d4df124b..3b7079ae4b 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -94,13 +94,13 @@ extern LLTrace::CountStatHandle<>			FPS,
 
 extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> > TRIANGLES_DRAWN;
 
-extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibits> >	KBIT,
-																	LAYERS_KBIT,
-																	OBJECT_KBIT,
-																	ASSET_KBIT,
-																	TEXTURE_KBIT,
-																	ACTUAL_IN_KBIT,
-																	ACTUAL_OUT_KBIT;
+extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	ACTIVE_MESSAGE_DATA_RECEIVED,
+																	LAYERS_NETWORK_DATA_RECEIVED,
+																	OBJECT_NETWORK_DATA_RECEIVED,
+																	ASSET_UDP_DATA_RECEIVED,
+																	TEXTURE_NETWORK_DATA_RECEIVED,
+																	MESSAGE_SYSTEM_DATA_IN,
+																	MESSAGE_SYSTEM_DATA_OUT;
 
 extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >		SIM_20_FPS_TIME,
 																	SIM_PHYSICS_20_FPS_TIME,
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 431a3b330c..dfd7ac983d 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -663,7 +663,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 	cleared = FALSE;
 
-	LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_KBIT));
+	LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED));
 
 	{
 		using namespace LLStatViewer;
@@ -1374,7 +1374,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	add(LLStatViewer::TEXTURE_KBIT, LLUnit<F64, LLUnits::Bytes>(received_size));
+	add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, LLUnit<F64, LLUnits::Bytes>(received_size));
 	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	U8 codec;
@@ -1448,7 +1448,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 		received_size = msg->getReceiveSize() ;		
 	}
 
-	add(LLStatViewer::TEXTURE_KBIT, LLUnit<F64, LLUnits::Bytes>(received_size));
+	add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, LLUnit<F64, LLUnits::Bytes>(received_size));
 	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	//llprintline("Start decode, image header...");
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 85e4e6bc08..10e354f2e3 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -215,6 +215,7 @@
 // Globals
 //
 void render_ui(F32 zoom_factor = 1.f, int subfield = 0);
+void swap();
 
 extern BOOL gDebugClicks;
 extern BOOL gDisplaySwapBuffers;
@@ -4405,6 +4406,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
 					// Required for showing the GUI in snapshots and performing bloom composite overlay
 					// Call even if show_ui is FALSE
 					render_ui(scale_factor, subfield);
+					swap();
 				}
 				
 				for (U32 out_y = 0; out_y < read_height ; out_y++)
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index d45a62b223..3dfe4c5e5f 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -732,9 +732,9 @@ void LLWorld::updateNetStats()
 	LLUnit<F64, LLUnits::Bits> actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
 	LLUnit<F64, LLUnits::Bits> actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
 
-	add(LLStatViewer::ACTUAL_IN_KBIT, actual_in_bits);
-	add(LLStatViewer::ACTUAL_OUT_KBIT, actual_out_bits);
-	add(LLStatViewer::KBIT, bits);
+	add(LLStatViewer::MESSAGE_SYSTEM_DATA_IN, actual_in_bits);
+	add(LLStatViewer::MESSAGE_SYSTEM_DATA_OUT, actual_out_bits);
+	add(LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED, bits);
 	add(LLStatViewer::PACKETS_IN, packets_in);
 	add(LLStatViewer::PACKETS_OUT, packets_out);
 	add(LLStatViewer::PACKETS_LOST, packets_lost);
@@ -743,8 +743,8 @@ void LLWorld::updateNetStats()
 		sample(LLStatViewer::PACKETS_LOST_PERCENT, LLUnits::Ratio::fromValue((F32)packets_lost/(F32)packets_in));
 	}
 
-	mLastPacketsIn = gMessageSystem->mPacketsIn;
-	mLastPacketsOut = gMessageSystem->mPacketsOut;
+	mLastPacketsIn   = gMessageSystem->mPacketsIn;
+	mLastPacketsOut  = gMessageSystem->mPacketsOut;
 	mLastPacketsLost = gMessageSystem->mDroppedPackets;
 }
 
diff --git a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
index 246e8bb256..71ff961c59 100644
--- a/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_scene_load_stats.xml
@@ -45,10 +45,10 @@
                   unit_scale="100"
                   precision="0"/>
         <stat_bar name="bandwidth"
-                  label="Bandwidth"
+                  label="UDP Data Received"
                   orientation="horizontal"
                   unit_label="kbps"
-                  stat="kbitstat"
+                  stat="activemessagedatareceived"
                   bar_max="5000"
                   tick_spacing="500"
                   precision="0"/>
@@ -159,55 +159,55 @@
                     tick_spacing="128.f"
                     precision="1"
                     show_bar="false"/>
-			    <stat_bar name="objectkbitstat"
+			    <stat_bar name="objectdatareceived"
                     label="Objects"
                     orientation="horizontal"
-                    stat="objectkbitstat"
+                    stat="objectdatareceived"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
                     precision="1"
                     show_bar="false"/>
-			    <stat_bar name="texturekbitstat"
+			    <stat_bar name="texturedatareceived"
                     label="Texture"
                     orientation="horizontal"
-                    stat="texturekbitstat"
+                    stat="texturedatareceived"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
                     precision="1"
                     show_bar="false"/>
-			    <stat_bar name="assetkbitstat"
+			    <stat_bar name="assetudpdatareceived"
                     label="Asset"
                     orientation="horizontal"
-                    stat="assetkbitstat"
+                    stat="assetudpdatareceived"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
                     precision="1"
                     show_bar="false"/>
-			    <stat_bar name="layerskbitstat"
+			    <stat_bar name="layersdatareceived"
                     label="Layers"
                     orientation="horizontal"
-                    stat="layerskbitstat"
+                    stat="layersdatareceived"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
                     precision="1"
                     show_bar="false"/>
-			    <stat_bar name="actualinkbitstat"
+			    <stat_bar name="messagedatain"
                     label="Actual In"
                     orientation="horizontal"
-                    stat="actualinkbitstat"
+                    stat="messagedatain"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
                     precision="1"
                     show_bar="false"/>
-			    <stat_bar name="actualoutkbitstat"
+			    <stat_bar name="messagedataout"
                     label="Actual Out"
                     orientation="horizontal"
-                    stat="actualoutkbitstat"
+                    stat="messagedataout"
                     unit_label="kbps"
                     bar_max="1024.f"
                     tick_spacing="128.f"
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index ad7094c6d8..ba43c24ad3 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -37,9 +37,9 @@
                   decimal_digits="1"
                   show_bar="true"
                   show_history="true"/>
-       <!-- <stat_bar name="bandwidth"
-                  label="Bandwidth"
-                  stat="Bandwidth"
+       <stat_bar name="bandwidth"
+                  label="UDP Data Received"
+                  stat="activemessagedatareceived"
                   show_bar="true"/>
         <stat_bar name="packet_loss"
                   label="Packet Loss"
@@ -135,29 +135,29 @@
                     label="Packets Out"
                     stat="packetsoutstat"
                     decimal_digits="1"/>
-          <stat_bar name="objectkbitstat"
+          <stat_bar name="objectdatareceived"
                     label="Objects"
-                    stat="objectkbitstat"
+                    stat="objectdatareceived"
                     decimal_digits="1"/>
-          <stat_bar name="texturekbitstat"
+          <stat_bar name="texturedatareceived"
                     label="Texture"
-                    stat="texturekbitstat"
+                    stat="texturedatareceived"
                     decimal_digits="1"/>
-          <stat_bar name="assetkbitstat"
+          <stat_bar name="assetudpdatareceived"
                     label="Asset"
-                    stat="assetkbitstat"
+                    stat="assetudpdatareceived"
                     decimal_digits="1"/>
-          <stat_bar name="layerskbitstat"
+          <stat_bar name="layersdatareceived"
                     label="Layers"
-                    stat="layerskbitstat"
+                    stat="layersdatareceived"
                     decimal_digits="1"/>
-          <stat_bar name="actualinkbitstat"
+          <stat_bar name="messagedatain"
                     label="Actual In"
-                    stat="actualinkbitstat"
+                    stat="messagedatain"
                     decimal_digits="1"/>
-          <stat_bar name="actualoutkbitstat"
+          <stat_bar name="messagedataout"
                     label="Actual Out"
-                    stat="actualoutkbitstat"
+                    stat="messagedataout"
                     decimal_digits="1"
                     show_history="false"/>
           <stat_bar name="vfspendingoperations"
@@ -336,7 +336,7 @@
                       stat="simpumpiomsec"
                       decimal_digits="3"/>
           </stat_view>
-        </stat_view>-->
+        </stat_view>
       </stat_view>
     </container_view>
   </scroll_container>
-- 
cgit v1.2.3


From 551ec2a56607bc6f9182f4e6410ef7f921bcac10 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 15 Jul 2013 14:11:05 -0700
Subject: BUILDFIX: improper type passed to llformat

---
 indra/newview/lltextureview.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 20e8a522cd..c1b5309f82 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -590,7 +590,7 @@ void LLGLTexMemBar::draw()
 	LLUnit<F32, LLUnits::Kibibits> 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, max_bandwidth);
+	text = llformat("BW:%.0f/%.0f",bandwidth.value(), max_bandwidth.value());
 	LLFontGL::getFontMonospace()->renderUTF8(text, 0, left, v_offset + line_height*2,
 											 color, LLFontGL::LEFT, LLFontGL::TOP);
 	
-- 
cgit v1.2.3


From bd078122e3a87e958fb6b0ea9caeef885298d527 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 15 Jul 2013 21:00:19 -0700
Subject: SH-4299 FIX: Interesting: High fps shown temporarily off scale in
 statistics console timing of scene load recording extension now guaranteed >
 requested time step removed double add of recorded data removed spam

---
 indra/newview/app_settings/settings.xml |  4 ++--
 indra/newview/llscenemonitor.cpp        | 11 +++++++----
 indra/newview/llviewerassetstats.cpp    |  1 -
 3 files changed, 9 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index a255793017..5bbe56bc0e 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9844,13 +9844,13 @@
     <key>SceneLoadingPixelDiffThreshold</key>
     <map>
       <key>Comment</key>
-      <string>Amount of pixels changed required to consider the scene as still loading (fraction of pixels on screen)</string>
+      <string>Amount of pixels changed required to consider the scene as still loading (square root of fraction of pixels on screen)</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
       <string>F32</string>
       <key>Value</key>
-      <real>0.0003</real>
+      <real>0.02</real>
     </map>
     <key>ScriptHelpFollowsCursor</key>
     <map>
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index eec4a703a1..2f48be12fb 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -290,7 +290,6 @@ void LLSceneMonitor::capture()
 
 	if((timer.getElapsedTimeF32() > scene_load_sample_time() 
 			|| force_capture)
-		&& mDiffState == WAITING_FOR_NEXT_DIFF
 		&& mEnabled
 		&& LLGLSLShader::sNoFixedFunction
 		&& last_capture_frame != gFrameCount)
@@ -470,7 +469,8 @@ void LLSceneMonitor::fetchQueryResult()
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static LLFrameTimer timer;	
 
-	if(mDiffState == WAIT_ON_RESULT && timer.getElapsedTimeF32() > scene_load_sample_time)
+	F32 elapsed_time = timer.getElapsedTimeF32();
+	if(mDiffState == WAIT_ON_RESULT && elapsed_time > scene_load_sample_time)
 	{
 		mDiffState = WAITING_FOR_NEXT_DIFF;
 
@@ -481,21 +481,24 @@ void LLSceneMonitor::fetchQueryResult()
 			GLuint count = 0;
 			glGetQueryObjectuivARB(mQueryObject, GL_QUERY_RESULT_ARB, &count);
 	
-			mDiffResult = count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio); //0.5 -> (front face + back face)
+			mDiffResult = sqrtf(count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio)); //0.5 -> (front face + back face)
 
 			LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
-			record(sFramePixelDiff, sqrtf(mDiffResult));
+			record(sFramePixelDiff, mDiffResult);
 
 			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
 			if(mDiffResult > diff_threshold())
 			{
 				mSceneLoadRecording.extend();
+				llassert(mSceneLoadRecording.getResults().getLastRecording().getDuration() > scene_load_sample_time);
 			}
 			else
 			{
 				mSceneLoadRecording.nextPeriod();
 			}
 		}
+
+		timer.reset();
 	}
 }
 
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 5f11a2b519..579567bb14 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -526,7 +526,6 @@ void record_enqueue(LLViewerAssetType::EType at, bool with_http, bool is_temp)
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	llinfos << "enqueue " << int(eac) << llendl;
 	add(*sEnqueued[int(eac)], 1);
 }
 
-- 
cgit v1.2.3


From 29930baf23fbd8cd147cd78f60d01496479ae78e Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 17 Jul 2013 10:56:47 -0700
Subject: SH-4299 WIP: Interesting: High fps shown temporarily off scale in
 statistics console made unit types work with ostreams fixed timing of scene
 monitor recordings to better respect requested time diff

---
 indra/newview/llscenemonitor.cpp | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 2f48be12fb..3f4f872174 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -469,8 +469,8 @@ void LLSceneMonitor::fetchQueryResult()
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static LLFrameTimer timer;	
 
-	F32 elapsed_time = timer.getElapsedTimeF32();
-	if(mDiffState == WAIT_ON_RESULT && elapsed_time > scene_load_sample_time)
+	if(mDiffState == WAIT_ON_RESULT 
+		&& !LLAppViewer::instance()->quitRequested())
 	{
 		mDiffState = WAITING_FOR_NEXT_DIFF;
 
@@ -487,14 +487,20 @@ void LLSceneMonitor::fetchQueryResult()
 			record(sFramePixelDiff, mDiffResult);
 
 			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
-			if(mDiffResult > diff_threshold())
-			{
-				mSceneLoadRecording.extend();
-				llassert(mSceneLoadRecording.getResults().getLastRecording().getDuration() > scene_load_sample_time);
-			}
-			else
+			F32 elapsed_time = timer.getElapsedTimeF32();
+
+			if (elapsed_time > scene_load_sample_time)
 			{
-				mSceneLoadRecording.nextPeriod();
+				if(mDiffResult > diff_threshold())
+				{
+					mSceneLoadRecording.extend();
+					llinfos << mSceneLoadRecording.getResults().getLastRecording().getDuration() << llendl;
+					llassert_always(mSceneLoadRecording.getResults().getLastRecording().getDuration() > scene_load_sample_time);
+				}
+				else
+				{
+					mSceneLoadRecording.nextPeriod();
+				}
 			}
 		}
 
-- 
cgit v1.2.3


From 075a7bcc980b0ca0d2888d344b6afa8ab5b52d85 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 18 Jul 2013 15:09:45 -0700
Subject: SH-4297 WIP interesting: viewer-interesting starts loading cached
 scene late dependency cleanup - removed a lot of unecessary includes

---
 indra/newview/llappviewer.h   |  2 +-
 indra/newview/llsecapi.h      |  3 ++-
 indra/newview/llviewerstats.h | 17 ++++++++++-------
 3 files changed, 13 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 68e9ebeff3..e7dd605044 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -271,7 +271,7 @@ private:
 	LLWatchdogTimeout* mMainloopTimeout;
 
 	// For performance and metric gathering
-	LLThread*	mFastTimerLogThread;
+	class LLThread*	mFastTimerLogThread;
 
 	// for tracking viewer<->region circuit death
 	bool mAgentRegionLastAlive;
diff --git a/indra/newview/llsecapi.h b/indra/newview/llsecapi.h
index 28765fbfb1..c01d318f56 100755
--- a/indra/newview/llsecapi.h
+++ b/indra/newview/llsecapi.h
@@ -28,9 +28,10 @@
 #ifndef LLSECAPI_H
 #define LLSECAPI_H
 #include <vector>
+#include "llwin32headerslean.h"
 #include <openssl/x509.h>
 #include <ostream>
-#include "llthread.h"
+#include "llpointer.h"
 
 #ifdef LL_WINDOWS
 #pragma warning(disable:4250)
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 3b7079ae4b..ee1a73de9f 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -48,6 +48,8 @@ struct SimMeasurementSampler : public LLInstanceTracker<SimMeasurementSampler, E
 template<typename T = F64>
 struct SimMeasurement : public LLTrace::SampleStatHandle<T>, public SimMeasurementSampler
 {
+	typedef SimMeasurement<T> self_t;
+
 	SimMeasurement(const char* name, const char* description, ESimStatID stat_id)
 	:	LLTrace::SampleStatHandle<T>(name, description),
 		SimMeasurementSampler(stat_id)	
@@ -55,17 +57,18 @@ struct SimMeasurement : public LLTrace::SampleStatHandle<T>, public SimMeasureme
 
 	using SimMeasurementSampler::getInstance;
 
+	//friend void sample(self_t& measurement, T value)
+	//{
+	//	LLTrace::sample(static_cast<LLTrace::SampleStatHandle<T>& >(measurement), value);
+	//}
+
 	/*virtual*/ void sample(F64 value)
 	{
-		LLTrace::sample(*this, value);
+		LLTrace::sample(static_cast<LLTrace::SampleStatHandle<T>& >(*this), value);
+		//LLStatViewer::sample(*this, value);
 	}
-};
 
-template<typename T, typename VALUE_T>
-void sample(SimMeasurement<T>& measurement, VALUE_T value)
-{
-	LLTrace::sample(measurement, value);
-}
+};
 
 extern LLTrace::CountStatHandle<>			FPS,
 											PACKETS_IN,
-- 
cgit v1.2.3


From e40065f82c797eab41006a448c838f4f1089a2e8 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 19 Jul 2013 15:03:05 -0700
Subject: BUILDFIX: #include and dependency cleanup

---
 indra/newview/llscenemonitor.cpp | 14 +++++---------
 indra/newview/llscenemonitor.h   | 36 ++++++++++++++++++------------------
 2 files changed, 23 insertions(+), 27 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 3f4f872174..29dd140158 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -89,6 +89,7 @@ void LLSceneMonitor::reset()
 
 	mMonitorRecording.reset();
 	mSceneLoadRecording.reset();
+	mRecordingTimer.reset();
 
 	unfreezeScene();
 
@@ -259,7 +260,6 @@ void LLSceneMonitor::capture()
 	static U32 last_capture_frame = 0;
 	static LLCachedControl<bool> monitor_enabled(gSavedSettings, "SceneLoadingMonitorEnabled");
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
-	static LLFrameTimer timer;	
 	static bool force_capture = true;
 
 	bool enabled = monitor_enabled || mDebugViewerVisible;
@@ -288,7 +288,7 @@ void LLSceneMonitor::capture()
 		force_capture = true;
 	}
 
-	if((timer.getElapsedTimeF32() > scene_load_sample_time() 
+	if((mRecordingTimer.getElapsedTimeF32() > scene_load_sample_time() 
 			|| force_capture)
 		&& mEnabled
 		&& LLGLSLShader::sNoFixedFunction
@@ -299,8 +299,6 @@ void LLSceneMonitor::capture()
 		mSceneLoadRecording.resume();
 		mMonitorRecording.resume();
 
-		timer.reset();
-
 		last_capture_frame = gFrameCount;
 
 		LLRenderTarget& cur_target = getCaptureTarget();
@@ -467,7 +465,6 @@ void LLSceneMonitor::fetchQueryResult()
 
 	// also throttle timing here, to avoid going below sample time due to phasing with frame capture
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
-	static LLFrameTimer timer;	
 
 	if(mDiffState == WAIT_ON_RESULT 
 		&& !LLAppViewer::instance()->quitRequested())
@@ -483,11 +480,11 @@ void LLSceneMonitor::fetchQueryResult()
 	
 			mDiffResult = sqrtf(count * 0.5f / (mDiff->getWidth() * mDiff->getHeight() * mDiffPixelRatio * mDiffPixelRatio)); //0.5 -> (front face + back face)
 
-			LL_DEBUGS("SceneMonitor") << "Frame difference: " << std::setprecision(4) << mDiffResult << LL_ENDL;
+			LL_DEBUGS("SceneMonitor") << "Frame difference: " << mDiffResult << LL_ENDL;
 			record(sFramePixelDiff, mDiffResult);
 
 			static LLCachedControl<F32> diff_threshold(gSavedSettings,"SceneLoadingPixelDiffThreshold");
-			F32 elapsed_time = timer.getElapsedTimeF32();
+			F32 elapsed_time = mRecordingTimer.getElapsedTimeF32();
 
 			if (elapsed_time > scene_load_sample_time)
 			{
@@ -501,10 +498,9 @@ void LLSceneMonitor::fetchQueryResult()
 				{
 					mSceneLoadRecording.nextPeriod();
 				}
+				mRecordingTimer.reset();
 			}
 		}
-
-		timer.reset();
 	}
 }
 
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index 7088d529d6..b857389243 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -72,8 +72,8 @@ private:
 	void generateDitheringTexture(S32 width, S32 height);
 
 private:
-	bool mEnabled;
-	bool mDebugViewerVisible;
+	bool									mEnabled,
+											mDebugViewerVisible;
 
 	enum EDiffState
 	{
@@ -82,27 +82,27 @@ private:
 		EXECUTE_DIFF,
 		WAIT_ON_RESULT,
 		VIEWER_QUITTING
-	}	mDiffState;
+	}										mDiffState;
 
-	LLRenderTarget* mFrames[2];
-	LLRenderTarget* mDiff;
+	LLRenderTarget*							mFrames[2];
+	LLRenderTarget*							mDiff;
 
-	GLuint  mQueryObject; //used for glQuery
-	F32     mDiffResult;  //aggregate results of mDiff.
-	F32     mDiffTolerance; //pixels are filtered out when R+G+B < mDiffTolerance
+	GLuint									mQueryObject; //used for glQuery
+	F32										mDiffResult,  //aggregate results of mDiff.
+											mDiffTolerance, //pixels are filtered out when R+G+B < mDiffTolerance
+											mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension
 
-	F32     mDiffPixelRatio; //ratio of pixels used for comparison against the original mDiff size along one dimension
+	LLPointer<LLViewerTexture>				mDitheringTexture;
+	S32										mDitherMatrixWidth;
+	F32										mDitherScale,
+											mDitherScaleS,
+											mDitherScaleT;
 
-	LLPointer<LLViewerTexture> mDitheringTexture;
-	S32                        mDitherMatrixWidth;
-	F32                        mDitherScale;
-	F32                        mDitherScaleS;
-	F32                        mDitherScaleT;
+	std::vector<LLAnimPauseRequest>			mAvatarPauseHandles;
 
-	std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
-
-	LLTrace::ExtendablePeriodicRecording mSceneLoadRecording;
-	LLTrace::Recording					 mMonitorRecording;
+	LLFrameTimer							mRecordingTimer;
+	LLTrace::ExtendablePeriodicRecording	mSceneLoadRecording;
+	LLTrace::Recording						mMonitorRecording;
 };
 
 class LLSceneMonitorView : public LLFloater
-- 
cgit v1.2.3


From 4ff19b8f63f3814e98049064254323716f0fd422 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Sat, 20 Jul 2013 09:41:55 -0700
Subject: removed debug spam fast timer data now resets on login

---
 indra/newview/llappviewer.cpp    | 1 -
 indra/newview/llscenemonitor.cpp | 1 -
 indra/newview/llscenemonitor.h   | 2 +-
 indra/newview/llstartup.cpp      | 1 +
 4 files changed, 2 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 47492aaa31..5f6b183fcc 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1294,7 +1294,6 @@ bool LLAppViewer::mainLoop()
 	{
 		LLFastTimer _(FTM_FRAME);
 		LLTrace::TimeBlock::processTimes();
-		llassert(LLStatViewer::FPS.getPrimaryAccumulator()->getSampleCount() <= 1);
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
 
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 29dd140158..022a950ece 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -491,7 +491,6 @@ void LLSceneMonitor::fetchQueryResult()
 				if(mDiffResult > diff_threshold())
 				{
 					mSceneLoadRecording.extend();
-					llinfos << mSceneLoadRecording.getResults().getLastRecording().getDuration() << llendl;
 					llassert_always(mSceneLoadRecording.getResults().getLastRecording().getDuration() > scene_load_sample_time);
 				}
 				else
diff --git a/indra/newview/llscenemonitor.h b/indra/newview/llscenemonitor.h
index b857389243..f94232e536 100644
--- a/indra/newview/llscenemonitor.h
+++ b/indra/newview/llscenemonitor.h
@@ -100,7 +100,7 @@ private:
 
 	std::vector<LLAnimPauseRequest>			mAvatarPauseHandles;
 
-	LLFrameTimer							mRecordingTimer;
+	LLTimer									mRecordingTimer;
 	LLTrace::ExtendablePeriodicRecording	mSceneLoadRecording;
 	LLTrace::Recording						mMonitorRecording;
 };
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 097ea7cc8d..536c030637 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1185,6 +1185,7 @@ bool idle_startup()
 				// create the default proximal channel
 				LLVoiceChannel::initClass();
 				LLStartUp::setStartupState( STATE_WORLD_INIT);
+				LLTrace::get_frame_recording().reset();
 			}
 			else
 			{
-- 
cgit v1.2.3


From 40a7c63e897cee5905270602be4387f5eb4fc2b8 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 22 Jul 2013 18:22:08 -0700
Subject: fixed crash on exit

---
 indra/newview/llappviewer.cpp | 1 -
 1 file changed, 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 47492aaa31..5f6b183fcc 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1294,7 +1294,6 @@ bool LLAppViewer::mainLoop()
 	{
 		LLFastTimer _(FTM_FRAME);
 		LLTrace::TimeBlock::processTimes();
-		llassert(LLStatViewer::FPS.getPrimaryAccumulator()->getSampleCount() <= 1);
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
 
-- 
cgit v1.2.3


From 50c472c24216ad0c3890cb8bb9cf638e75642f0c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 23 Jul 2013 18:47:16 -0700
Subject: renamed mVarianceSum to mSumOfSquares to be more clear fixed
 normalization assertions to work with megaprims added is_zero() utility
 function fixed unit declarations to be more clear fixed texture cache hit
 rate always being 0

---
 indra/newview/llface.cpp          | 10 +++++-----
 indra/newview/llfasttimerview.cpp |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 94f06eb1d0..aadbbbacbb 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -819,14 +819,14 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 
 		// Catch potential badness from normalization before it happens
 		//
-		llassert(mat_normal.mMatrix[0].isFinite3() && (mat_normal.mMatrix[0].dot3(mat_normal.mMatrix[0]).getF32() > F_APPROXIMATELY_ZERO));
-		llassert(mat_normal.mMatrix[1].isFinite3() && (mat_normal.mMatrix[1].dot3(mat_normal.mMatrix[1]).getF32() > F_APPROXIMATELY_ZERO));
-		llassert(mat_normal.mMatrix[2].isFinite3() && (mat_normal.mMatrix[2].dot3(mat_normal.mMatrix[2]).getF32() > F_APPROXIMATELY_ZERO));
-
 		mat_normal.mMatrix[0].normalize3fast();
 		mat_normal.mMatrix[1].normalize3fast();
 		mat_normal.mMatrix[2].normalize3fast();
-		
+
+		llassert(mat_normal.mMatrix[0].isFinite3());
+		llassert(mat_normal.mMatrix[1].isFinite3());
+		llassert(mat_normal.mMatrix[2].isFinite3());
+
 		LLVector4a v[4];
 
 		//get 4 corners of bounding box
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index d922659435..b61889ccfa 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1338,7 +1338,7 @@ void LLFastTimerView::drawHelp( S32 y )
 	y -= (texth + 2);
 	y -= (texth + 2);
 
-	LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected] [ALT-Click toggle counts]"),
+	LLFontGL::getFontMonospace()->renderUTF8(std::string("[Right-Click log selected]"),
 		0, MARGIN, y, LLColor4::white, LLFontGL::LEFT, LLFontGL::TOP);
 }
 
-- 
cgit v1.2.3


From 1e8f9fd80d0ac4e0eab656ed8e8e32f91ab8b533 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 24 Jul 2013 19:36:43 -0700
Subject: SH-4376 FIX: Interesting: in Statistics, replace the text "0" with
 "n/a" when there are no samples during the time period. added hasValue to
 SampleAccumulator so we don't print a value when we don't have a single
 sample yet added some disabled log output for scene load timing

---
 indra/newview/llappviewer.cpp     | 11 ++++++++---
 indra/newview/llviewermessage.cpp |  4 +++-
 indra/newview/llviewerobject.cpp  |  2 ++
 indra/newview/pipeline.cpp        | 12 ++++++------
 4 files changed, 19 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 5f6b183fcc..8ad5784f40 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -660,8 +660,13 @@ LLTextureCache* LLAppViewer::sTextureCache = NULL;
 LLImageDecodeThread* LLAppViewer::sImageDecodeThread = NULL; 
 LLTextureFetch* LLAppViewer::sTextureFetch = NULL; 
 
-LLAppViewer::LLAppViewer() : 
-	mMarkerFile(),
+std::string getRuntime()
+{
+	return llformat("%g", LLTimer::getElapsedSeconds());
+}
+
+LLAppViewer::LLAppViewer() 
+:	mMarkerFile(),
 	mLogoutMarkerFile(),
 	mReportedCrash(false),
 	mNumSessions(0),
@@ -1300,7 +1305,7 @@ bool LLAppViewer::mainLoop()
 		LLTrace::get_master_thread_recorder()->pullFromChildren();
 
 		//clear call stack records
-		llclearcallstacks;
+		LL_CLEAR_CALLSTACKS();
 
 		//check memory availability information
 		checkMemory() ;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index c33efd4255..970f6913cb 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -358,7 +358,7 @@ void process_logout_reply(LLMessageSystem* msg, void**)
 		{
 			LL_INFOS("Messaging") << "process_logout_reply item not found: " << item_id << LL_ENDL;
 		}
-	}
+	}	
     LLAppViewer::instance()->forceQuit();
 }
 
@@ -366,6 +366,8 @@ void process_layer_data(LLMessageSystem *mesgsys, void **user_data)
 {
 	LLViewerRegion *regionp = LLWorld::getInstance()->getRegion(mesgsys->getSender());
 
+	LL_DEBUGS_ONCE("SceneLoadTiming") << "Received layer data" << LL_ENDL;
+
 	if(!regionp)
 	{
 		llwarns << "Invalid region for layer data." << llendl;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 4e514ddfd1..e834febad5 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -1043,6 +1043,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 					 const EObjectUpdateType update_type,
 					 LLDataPacker *dp)
 {
+	LL_DEBUGS_ONCE("SceneLoadTiming") << "Received viewer object data" << LL_ENDL;
+
 	U32 retval = 0x0;
 	
 	// If region is removed from the list it is also deleted.
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 34d7e0ab64..870ee6a103 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3757,7 +3757,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 	assertInitialized();
 
-	llpushcallstacks ;
+	LL_PUSH_CALLSTACKS();
 	//rebuild drawable geometry
 	for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i)
 	{
@@ -3768,12 +3768,12 @@ void LLPipeline::postSort(LLCamera& camera)
 			group->rebuildGeom();
 		}
 	}
-	llpushcallstacks ;
+	LL_PUSH_CALLSTACKS();
 	//rebuild groups
 	sCull->assertDrawMapsEmpty();
 
 	rebuildPriorityGroups();
-	llpushcallstacks ;
+	LL_PUSH_CALLSTACKS();
 
 	
 	//build render map
@@ -3884,7 +3884,7 @@ void LLPipeline::postSort(LLCamera& camera)
 		std::sort(sCull->beginAlphaGroups(), sCull->endAlphaGroups(), LLSpatialGroup::CompareDepthGreater());
 	}
 
-	llpushcallstacks ;
+	LL_PUSH_CALLSTACKS();
 	// only render if the flag is set. The flag is only set if we are in edit mode or the toggle is set in the menus
 	if (LLFloaterReg::instanceVisible("beacons") && !sShadowRender)
 	{
@@ -3937,7 +3937,7 @@ void LLPipeline::postSort(LLCamera& camera)
 			forAllVisibleDrawables(renderSoundHighlights);
 		}
 	}
-	llpushcallstacks ;
+	LL_PUSH_CALLSTACKS();
 	// If managing your telehub, draw beacons at telehub and currently selected spawnpoint.
 	if (LLFloaterTelehub::renderBeacons())
 	{
@@ -3973,7 +3973,7 @@ void LLPipeline::postSort(LLCamera& camera)
 	}
 
 	//LLSpatialGroup::sNoDelete = FALSE;
-	llpushcallstacks ;
+	LL_PUSH_CALLSTACKS();
 }
 
 
-- 
cgit v1.2.3


From 3430444212a14a7f40d8b1afdbefc68c3319562d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 24 Jul 2013 22:41:02 -0700
Subject: BUIDLFIX: forgot to extract value from units object for calling
 llformat

---
 indra/newview/llappviewer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 8ad5784f40..9193037a6c 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -662,7 +662,7 @@ LLTextureFetch* LLAppViewer::sTextureFetch = NULL;
 
 std::string getRuntime()
 {
-	return llformat("%g", LLTimer::getElapsedSeconds());
+	return llformat("%g", LLTimer::getElapsedSeconds().value());
 }
 
 LLAppViewer::LLAppViewer() 
-- 
cgit v1.2.3


From dce3f9bc8f9b838e5ffc6ff584bee1080076c039 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 24 Jul 2013 23:07:34 -0700
Subject: SH-4297 WIP interesting: viewer-interesting starts loading cached
 scene late added commented out log timestamp override for scene load
 performance monitoring

---
 indra/newview/llappviewer.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 9193037a6c..a208745822 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2153,6 +2153,7 @@ void LLAppViewer::initLoggingAndGetLastDuration()
 	LLError::initForApplication(
 				gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, ""));
 	LLError::setFatalFunction(errorCallback);
+	//LLError::setTimeFunction(getRuntime);
 
 	// Remove the last ".old" log file.
 	std::string old_log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,
-- 
cgit v1.2.3


From 83a628a431b569555ea68588e18a49159acbfd0c Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 25 Jul 2013 16:53:01 -0600
Subject: fix for SH-4298: Interesting: Viewer crash in LLViewerOctreeCull and
 SH-4341: Interesting: Viewer crash in LLViewerOctreeCull

---
 indra/newview/llvieweroctree.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 7b3186d40a..bba3d26e09 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -464,15 +464,16 @@ bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry)
 	llassert(!entry->getGroup());
 
 	unbound();
+	setState(OBJECT_DIRTY);
+
 	if (mOctreeNode)
 	{
-		if (!mOctreeNode->remove(entry))
+		if (!mOctreeNode->remove(entry)) //this could cause *this* pointer to be destroyed, so no more function calls after this.
 		{
 			OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << llendl;
 			return false;
 		}
-	}
-	setState(OBJECT_DIRTY);
+	}	
 
 	return true;
 }
@@ -580,9 +581,10 @@ void LLviewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEn
 //virtual 
 void LLviewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj)
 {
-	obj->setGroup(NULL);
 	unbound();
 	setState(OBJECT_DIRTY);
+
+	obj->setGroup(NULL); //this could cause *this* pointer to be destroyed. So no more function calls after this.	
 }
 	
 //virtual 
-- 
cgit v1.2.3


From 4cca9ba279f908f206fa5e32adccf1038f05cc7f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 29 Jul 2013 10:15:10 -0600
Subject: fix for SH-4293: texture console takes a while to settle down on
 Interesting viewer.

---
 indra/newview/llviewerregion.cpp |  4 +++-
 indra/newview/llviewerregion.h   |  1 +
 indra/newview/llvocache.cpp      | 10 +++-------
 indra/newview/llvocache.h        |  1 +
 indra/newview/llworld.cpp        |  5 +++++
 5 files changed, 13 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index b80d87ef07..cd8466d948 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -87,6 +87,7 @@ const F32 CAP_REQUEST_TIMEOUT = 18;
 const S32 MAX_CAP_REQUEST_ATTEMPTS = 30;
 
 BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
+S32  LLViewerRegion::sLastCameraUpdated = 0;
 
 typedef std::map<std::string, std::string> CapabilityMap;
 
@@ -992,6 +993,7 @@ void LLViewerRegion::removeFromVOCacheTree(LLVOCacheEntry* entry)
 	}
 
 	mImpl->mVOCachePartition->removeEntry(entry->getEntry());
+	entry->mLastCameraUpdated = sLastCameraUpdated;
 }
 
 //add the visible entries
@@ -1219,7 +1221,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 			iter = mImpl->mActiveSet.begin();
 		}
 
-		if(!(*iter)->isRecentlyVisible())
+		if(!(*iter)->isRecentlyVisible() && (*iter)->mLastCameraUpdated != sLastCameraUpdated)
 		{
 			killObject((*iter), delete_list);
 		}
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 29483662e8..2ac934d19c 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -411,6 +411,7 @@ public:
 	LLDynamicArray<LLUUID> mMapAvatarIDs;
 
 	static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
+	static S32  sLastCameraUpdated;
 private:
 	LLViewerRegionImpl * mImpl;
 	LLFrameTimer         mRegionTimer;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 69c32db13e..6e0243e985 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -219,18 +219,14 @@ void LLVOCacheEntry::setState(U32 state)
 
 	if(getState() == ACTIVE)
 	{
-		const S32 MIN_REAVTIVE_INTERVAL = 32;
+		const S32 MIN_REAVTIVE_INTERVAL = 128;
 		U32 last_visible = getVisible();
 		
 		setVisible();
 
-		if(getVisible() - last_visible < MIN_REAVTIVE_INTERVAL + mMinFrameRange)
+		if(getVisible() - last_visible > MIN_REAVTIVE_INTERVAL + mMinFrameRange)
 		{
-			mMinFrameRange = llmin(mMinFrameRange * 2, getInvisibleObjectsLiveTime() * 32);
-		}
-		else
-		{
-			mMinFrameRange = getInvisibleObjectsLiveTime(); //reset
+			mLastCameraUpdated = 0; //reset
 		}
 	}
 }
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 0248298eb5..816ef88dc4 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -130,6 +130,7 @@ public:
 	typedef std::set<LLVOCacheEntry*>                      vocache_entry_set_t;
 	typedef std::set<LLVOCacheEntry*, CompareVOCacheEntry> vocache_entry_priority_list_t;	
 
+	S32                         mLastCameraUpdated;
 protected:
 	U32							mLocalID;
 	U32                         mParentID;
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 3dfe4c5e5f..ea0e38824b 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -666,6 +666,11 @@ void LLWorld::updateRegions(F32 max_update_time)
 	LLTimer update_timer;
 	BOOL did_one = FALSE;
 	
+	if(LLViewerCamera::getInstance()->isChanged())
+	{
+		LLViewerRegion::sLastCameraUpdated = LLViewerOctreeEntryData::getCurrentFrame();
+	}
+
 	// Perform idle time updates for the regions (and associated surfaces)
 	for (region_list_t::iterator iter = mRegionList.begin();
 		 iter != mRegionList.end(); ++iter)
-- 
cgit v1.2.3


From a2e22732f195dc075a733c79f15156752f522a43 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 30 Jul 2013 19:13:45 -0700
Subject: Summer cleaning - removed a lot of llcommon dependencies to speed up
 build times consolidated most indra-specific constants in llcommon under
 indra_constants.h fixed issues with operations on mixed unit types (implicit
 and explicit) made LL_INFOS() style macros variadic in order to subsume other
 logging methods such as ll_infos added optional tag output to error recorders

---
 indra/newview/CMakeLists.txt                       |   3 +-
 indra/newview/app_settings/logcontrol.xml          |   1 +
 indra/newview/llaccountingcost.h                   |  55 ++++++
 indra/newview/llagent.cpp                          |  45 +++--
 indra/newview/llagent.h                            |   6 +-
 indra/newview/llagentlistener.cpp                  |   2 +-
 indra/newview/llagentpicksinfo.cpp                 |   4 +-
 indra/newview/llagentpilot.cpp                     |  27 +--
 indra/newview/llagentpilot.h                       |   3 +-
 indra/newview/llagentwearables.cpp                 |  14 +-
 indra/newview/llagentwearables.h                   |   2 +-
 indra/newview/llagentwearablesfetch.cpp            |  14 +-
 indra/newview/llappearancemgr.cpp                  | 119 +++++------
 indra/newview/llappviewer.cpp                      |  72 +++----
 indra/newview/llappviewer.h                        |   8 +-
 indra/newview/llappviewerwin32.cpp                 |  15 +-
 indra/newview/llavataractions.cpp                  |  18 +-
 indra/newview/llavataractions.h                    |   1 -
 indra/newview/llavatariconctrl.cpp                 |   1 -
 indra/newview/llavatarlist.cpp                     |   2 +-
 indra/newview/llavatarpropertiesprocessor.cpp      |   1 -
 indra/newview/llavatarpropertiesprocessor.h        |   8 +
 indra/newview/llblocklist.cpp                      |   2 +-
 indra/newview/llchatbar.cpp                        |   1 -
 indra/newview/llcofwearables.cpp                   |   2 +-
 indra/newview/llcolorswatch.cpp                    |  15 +-
 indra/newview/llcolorswatch.h                      |  29 ++-
 indra/newview/llcompilequeue.cpp                   | 212 +++-----------------
 indra/newview/llcompilequeue.h                     |  22 +--
 indra/newview/llconversationlog.cpp                |  66 +++----
 indra/newview/llconversationlog.h                  |   7 +-
 indra/newview/llconversationloglist.cpp            |   6 +-
 indra/newview/lldebugmessagebox.h                  |   1 -
 indra/newview/lldebugview.cpp                      |   1 -
 indra/newview/lldrawable.cpp                       |   8 +-
 indra/newview/lldrawable.h                         |   3 +-
 indra/newview/lldrawpoolsky.cpp                    |   2 -
 indra/newview/llfavoritesbar.cpp                   |  24 +--
 indra/newview/llfeaturemanager.cpp                 |   1 -
 indra/newview/llfirstuse.cpp                       |   5 +
 indra/newview/llfloaterabout.cpp                   |   1 -
 indra/newview/llfloaterbulkpermission.cpp          |  19 +-
 indra/newview/llfloaterbulkpermission.h            |   6 +-
 indra/newview/llfloatercolorpicker.cpp             |   7 +-
 indra/newview/llfloatercolorpicker.h               |   5 +-
 indra/newview/llfloaterevent.cpp                   |   1 -
 indra/newview/llfloatergesture.cpp                 |   8 +-
 indra/newview/llfloatergroups.cpp                  |  10 +-
 indra/newview/llfloaterlandholdings.cpp            |   8 +-
 indra/newview/llfloateroutbox.cpp                  |   4 +-
 indra/newview/llfloaterpreference.cpp              |   5 +-
 indra/newview/llfloatertopobjects.h                |  16 ++
 indra/newview/llfloaterworldmap.cpp                |  33 ++--
 indra/newview/llfloaterworldmap.h                  |   5 +-
 indra/newview/llfriendcard.cpp                     |  30 +--
 indra/newview/llgiveinventory.cpp                  |  22 +--
 indra/newview/llgroupactions.cpp                   |   6 +-
 indra/newview/llgroupiconctrl.cpp                  |  28 +--
 indra/newview/llgrouplist.cpp                      |   6 +-
 indra/newview/llgroupmgr.h                         |  11 ++
 indra/newview/llhudicon.h                          |   1 -
 indra/newview/llhudmanager.cpp                     |  18 +-
 indra/newview/llhudmanager.h                       |   3 +-
 indra/newview/llimview.cpp                         |  26 +--
 indra/newview/llimview.h                           |   7 +-
 indra/newview/llinventorybridge.cpp                |  78 ++++----
 indra/newview/llinventoryitemslist.h               |   4 +-
 indra/newview/llinventorymodel.cpp                 | 124 ++++++------
 indra/newview/llinventorymodel.h                   |   5 +-
 indra/newview/llinventoryobserver.cpp              |   6 +-
 indra/newview/llinventorypanel.cpp                 |  10 +-
 indra/newview/llinventorypanel.h                   |   1 -
 indra/newview/lllogchat.cpp                        |   4 +-
 indra/newview/llmanip.cpp                          |   4 +-
 indra/newview/llmaniprotate.cpp                    |   4 +-
 indra/newview/llmanipscale.cpp                     |   4 +-
 indra/newview/llmaniptranslate.cpp                 |  12 +-
 indra/newview/llnamelistctrl.cpp                   |   2 +-
 indra/newview/llpanelavatar.cpp                    |   1 -
 indra/newview/llpanelcontents.h                    |   1 -
 indra/newview/llpaneleditwearable.cpp              |   2 +-
 indra/newview/llpanelface.cpp                      |  14 +-
 indra/newview/llpanelgrouplandmoney.cpp            |  32 +--
 indra/newview/llpanelgrouplandmoney.h              |   5 +-
 indra/newview/llpanellandmarkinfo.cpp              |   6 +-
 indra/newview/llpanellogin.cpp                     |   7 +-
 indra/newview/llpanelme.cpp                        |   1 -
 indra/newview/llpanelobjectinventory.cpp           |   6 +-
 indra/newview/llpanelpicks.cpp                     |   1 -
 indra/newview/llpanelteleporthistory.cpp           |  22 +--
 indra/newview/llpanelteleporthistory.h             |   2 +-
 indra/newview/llphysicsshapebuilderutil.h          |   2 +
 indra/newview/llpreview.cpp                        |   1 -
 indra/newview/llpreviewgesture.cpp                 |   8 +-
 indra/newview/llpreviewscript.cpp                  |   6 +-
 indra/newview/llpreviewscript.h                    |   3 +-
 indra/newview/llscriptfloater.cpp                  |   2 +-
 indra/newview/llselectmgr.cpp                      |   3 +
 indra/newview/llselectmgr.h                        |  27 +++
 indra/newview/llspeakers.cpp                       |   2 +-
 indra/newview/llstartup.cpp                        |   7 +-
 indra/newview/llstartup.h                          |  12 ++
 indra/newview/llstatusbar.cpp                      |   1 -
 indra/newview/llsurface.cpp                        |   2 +-
 indra/newview/llsurfacepatch.cpp                   |   7 +-
 indra/newview/lltexturectrl.cpp                    |   8 +-
 indra/newview/lltoastgroupnotifypanel.h            |   1 -
 indra/newview/lltool.cpp                           |   2 +-
 indra/newview/lltoolbrush.cpp                      |   2 +-
 indra/newview/lltooldraganddrop.cpp                |  46 ++---
 indra/newview/lltooldraganddrop.h                  |   2 -
 indra/newview/lltoolfocus.cpp                      |   8 +-
 indra/newview/lltoolgrab.cpp                       |  12 +-
 indra/newview/lltoolgun.cpp                        |   4 +-
 indra/newview/lltoolpie.cpp                        |  10 +-
 indra/newview/lltoolplacer.cpp                     |   2 +-
 indra/newview/lltoolselectland.cpp                 |   8 +-
 indra/newview/lltoolselectrect.cpp                 |   5 +-
 indra/newview/lltracker.cpp                        |   1 -
 indra/newview/lltracker.h                          |   5 +-
 indra/newview/llviewerassettype.h                  |   1 +
 indra/newview/llviewerdisplay.cpp                  |   5 +
 indra/newview/llviewergesture.h                    |   1 -
 indra/newview/llviewerinventory.h                  |   4 +-
 indra/newview/llviewerjointattachment.cpp          |   2 +-
 indra/newview/llviewerjointmesh.cpp                |   9 +-
 indra/newview/llviewerkeyboard.cpp                 |   8 +-
 indra/newview/llviewermenu.cpp                     |  26 +--
 indra/newview/llviewermessage.cpp                  |  19 +-
 indra/newview/llviewermessage.h                    |   1 -
 indra/newview/llviewerobject.cpp                   |  11 +-
 indra/newview/llviewerobjectlist.cpp               |  13 +-
 indra/newview/llviewerparcelmgr.cpp                |  13 +-
 indra/newview/llviewerparcelmgr.h                  |   3 +-
 indra/newview/llviewerparceloverlay.cpp            |  89 +++++----
 indra/newview/llviewerparceloverlay.h              |   7 +-
 indra/newview/llviewerprecompiledheaders.h         |   4 -
 indra/newview/llviewerregion.cpp                   |  40 ++--
 indra/newview/llviewerregion.h                     |   5 +-
 indra/newview/llviewerstats.cpp                    |  20 +-
 indra/newview/llviewerstats.h                      |  51 ++++-
 indra/newview/llviewertexteditor.cpp               |   2 +-
 indra/newview/llviewertexture.cpp                  |   1 -
 indra/newview/llviewertexturelist.cpp              |  81 ++++----
 indra/newview/llviewerwearable.h                   |   1 +
 indra/newview/llviewerwindow.cpp                   |   3 +-
 indra/newview/llvlcomposition.cpp                  |   1 -
 indra/newview/llvlmanager.cpp                      |  22 ++-
 indra/newview/llvlmanager.h                        |   3 +-
 indra/newview/llvoavatar.cpp                       |  39 ++--
 indra/newview/llvoavatar.h                         |   5 +-
 indra/newview/llvoavatarself.cpp                   |  20 +-
 indra/newview/llvoavatarself.h                     |   4 +-
 indra/newview/llvograss.cpp                        |   1 -
 indra/newview/llvograss.h                          |   1 -
 indra/newview/llvoicevivox.cpp                     |   4 +-
 indra/newview/llvopartgroup.cpp                    |   2 +-
 indra/newview/llvosky.cpp                          |   2 -
 indra/newview/llvotree.h                           |   1 -
 indra/newview/llvotreenew.h                        | 218 ---------------------
 indra/newview/llvovolume.cpp                       |   1 -
 indra/newview/llvowater.cpp                        |   1 -
 indra/newview/llwaterparammanager.cpp              |   4 +-
 indra/newview/llwearableitemslist.h                |   2 +-
 indra/newview/llwind.h                             |   2 +
 indra/newview/llwlparammanager.cpp                 |   4 +-
 indra/newview/llworld.cpp                          |  10 +-
 indra/newview/llworld.h                            |   6 +-
 indra/newview/llworldmap.h                         |  12 ++
 indra/newview/llworldmapview.cpp                   |   2 +-
 indra/newview/pipeline.cpp                         |   2 -
 indra/newview/roles_constants.h                    | 192 ++++++++++++++++++
 .../newview/skins/default/xui/en/floater_stats.xml |   3 +-
 indra/newview/skins/default/xui/en/strings.xml     |   1 +
 174 files changed, 1309 insertions(+), 1347 deletions(-)
 create mode 100755 indra/newview/llaccountingcost.h
 delete mode 100755 indra/newview/llvotreenew.h
 create mode 100755 indra/newview/roles_constants.h

(limited to 'indra/newview')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 3689c2856d..1b779e5c99 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -682,6 +682,7 @@ set(viewer_HEADER_FILES
     CMakeLists.txt
     ViewerInstall.cmake
     groupchatlistener.h
+    llaccountingcost.h
     llaccountingcostmanager.h
     llagent.h
     llagentaccess.h
@@ -1221,7 +1222,6 @@ set(viewer_HEADER_FILES
     llvosky.h
     llvosurfacepatch.h
     llvotree.h
-    llvotreenew.h
     llvovolume.h
     llvowater.h
     llvowlsky.h
@@ -1250,6 +1250,7 @@ set(viewer_HEADER_FILES
     macmain.h
     noise.h
     pipeline.h
+    roles_constants.h
     VertexCache.h
     VorbisFramework.h
     )
diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index 92a241857e..b500c37098 100755
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -42,6 +42,7 @@
 						</array>
 					<key>tags</key>
 						<array>
+							<string>SceneLoadTiming</string>
 						<!-- sample entry for debugging specific items	
 						     <string>Avatar</string>
 						     <string>Voice</string>		
diff --git a/indra/newview/llaccountingcost.h b/indra/newview/llaccountingcost.h
new file mode 100755
index 0000000000..bc770fe1d2
--- /dev/null
+++ b/indra/newview/llaccountingcost.h
@@ -0,0 +1,55 @@
+/** 
+ * @file llaccountingcost.h
+ * @
+ *
+ * $LicenseInfo:firstyear=2001&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$
+ */
+
+#ifndef LL_ACCOUNTINGQUOTA_H
+#define LL_ACCOUNTINGQUOTA_H
+
+//SelectionQuota atm does not require a id
+struct SelectionCost
+{
+	SelectionCost( /*LLTransactionID transactionId, */ F32 physicsCost, F32 networkCost, F32 simulationCost )
+	//: mTransactionId( transactionId)
+	: mPhysicsCost( physicsCost )
+	, mNetworkCost( networkCost )
+	, mSimulationCost( simulationCost )
+	{
+	}
+	SelectionCost()
+	: mPhysicsCost( 0.0f )
+	, mNetworkCost( 0.0f )
+	, mSimulationCost( 0.0f )
+	{}
+	
+	F32 mPhysicsCost, mNetworkCost, mSimulationCost;	
+	//LLTransactionID mTransactionId;
+};
+
+typedef enum { Roots = 0 , Prims } eSelectionType;
+
+#endif
+
+
+
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 8ec74bb268..460ae62522 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -2991,7 +2991,7 @@ LLQuaternion LLAgent::getHeadRotation()
 	return rot;
 }
 
-void LLAgent::sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request)
+void LLAgent::sendAnimationRequests(const std::vector<LLUUID> &anim_ids, EAnimRequest request)
 {
 	if (gAgentID.isNull())
 	{
@@ -3006,7 +3006,7 @@ void LLAgent::sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimReque
 	msg->addUUIDFast(_PREHASH_AgentID, getID());
 	msg->addUUIDFast(_PREHASH_SessionID, getSessionID());
 
-	for (S32 i = 0; i < anim_ids.count(); i++)
+	for (S32 i = 0; i < anim_ids.size(); i++)
 	{
 		if (anim_ids[i].isNull())
 		{
@@ -3204,10 +3204,10 @@ void LLAgent::processAgentDropGroup(LLMessageSystem *msg, void **)
 	// Remove the group if it already exists remove it and add the new data to pick up changes.
 	LLGroupData gd;
 	gd.mID = group_id;
-	S32 index = gAgent.mGroups.find(gd);
-	if (index != -1)
+	std::vector<LLGroupData>::iterator found_it = std::find(gAgent.mGroups.begin(), gAgent.mGroups.end(), gd);
+	if (found_it != gAgent.mGroups.end())
 	{
-		gAgent.mGroups.remove(index);
+		gAgent.mGroups.erase(found_it);
 		if (gAgent.getGroupID() == group_id)
 		{
 			gAgent.mGroupID.setNull();
@@ -3281,10 +3281,10 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode
 			// and add the new data to pick up changes.
 			LLGroupData gd;
 			gd.mID = group_id;
-			S32 index = gAgent.mGroups.find(gd);
-			if (index != -1)
+			std::vector<LLGroupData>::iterator found_it = std::find(gAgent.mGroups.begin(), gAgent.mGroups.end(), gd);
+			if (found_it != gAgent.mGroups.end())
 			{
-				gAgent.mGroups.remove(index);
+				gAgent.mGroups.erase(found_it);
 				if (gAgent.getGroupID() == group_id)
 				{
 					gAgent.mGroupID.setNull();
@@ -3337,7 +3337,6 @@ void LLAgent::processAgentGroupDataUpdate(LLMessageSystem *msg, void **)
 	
 	S32 count = msg->getNumberOfBlocksFast(_PREHASH_GroupData);
 	LLGroupData group;
-	S32 index = -1;
 	bool need_floater_update = false;
 	for(S32 i = 0; i < count; ++i)
 	{
@@ -3352,12 +3351,12 @@ void LLAgent::processAgentGroupDataUpdate(LLMessageSystem *msg, void **)
 		{
 			need_floater_update = true;
 			// Remove the group if it already exists remove it and add the new data to pick up changes.
-			index = gAgent.mGroups.find(group);
-			if (index != -1)
+			std::vector<LLGroupData>::iterator found_it = std::find(gAgent.mGroups.begin(), gAgent.mGroups.end(), group);
+			if (found_it != gAgent.mGroups.end())
 			{
-				gAgent.mGroups.remove(index);
+				gAgent.mGroups.erase(found_it);
 			}
-			gAgent.mGroups.put(group);
+			gAgent.mGroups.push_back(group);
 		}
 		if (need_floater_update)
 		{
@@ -3396,7 +3395,6 @@ class LLAgentGroupDataUpdateViewerNode : public LLHTTPNode
 		{
 
 			LLGroupData group;
-			S32 index = -1;
 			bool need_floater_update = false;
 
 			group.mID = (*iter_group)["GroupID"].asUUID();
@@ -3413,12 +3411,12 @@ class LLAgentGroupDataUpdateViewerNode : public LLHTTPNode
 			{
 				need_floater_update = true;
 				// Remove the group if it already exists remove it and add the new data to pick up changes.
-				index = gAgent.mGroups.find(group);
-				if (index != -1)
+				std::vector<LLGroupData>::iterator found_it = std::find(gAgent.mGroups.begin(), gAgent.mGroups.end(), group);
+				if (found_it != gAgent.mGroups.end())
 				{
-					gAgent.mGroups.remove(index);
+					gAgent.mGroups.erase(found_it);
 				}
-				gAgent.mGroups.put(group);
+				gAgent.mGroups.push_back(group);
 			}
 			if (need_floater_update)
 			{
@@ -4203,11 +4201,12 @@ void LLAgent::fidget()
 
 void LLAgent::stopFidget()
 {
-	LLDynamicArray<LLUUID> anims;
-	anims.put(ANIM_AGENT_STAND_1);
-	anims.put(ANIM_AGENT_STAND_2);
-	anims.put(ANIM_AGENT_STAND_3);
-	anims.put(ANIM_AGENT_STAND_4);
+	std::vector<LLUUID> anims;
+	anims.reserve(4);
+	anims.push_back(ANIM_AGENT_STAND_1);
+	anims.push_back(ANIM_AGENT_STAND_2);
+	anims.push_back(ANIM_AGENT_STAND_3);
+	anims.push_back(ANIM_AGENT_STAND_4);
 
 	gAgent.sendAnimationRequests(anims, ANIM_REQUEST_STOP);
 }
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 4153fbbfff..093a65682a 100755
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -29,13 +29,11 @@
 
 #include "indra_constants.h"
 #include "llevent.h" 				// LLObservable base class
-#include "llagentconstants.h"
 #include "llagentdata.h" 			// gAgentID, gAgentSessionID
 #include "llcharacter.h"
 #include "llcoordframe.h"			// for mFrameAgent
 #include "llavatarappearancedefines.h"
 #include "llpermissionsflags.h"
-#include "lldarray.h"
 
 #include <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
@@ -431,7 +429,7 @@ public:
 	void            stopCurrentAnimations();
 	void			requestStopMotion(LLMotion* motion);
 	void			onAnimStop(const LLUUID& id);
-	void			sendAnimationRequests(LLDynamicArray<LLUUID> &anim_ids, EAnimRequest request);
+	void			sendAnimationRequests(const std::vector<LLUUID> &anim_ids, EAnimRequest request);
 	void			sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request);
 	void			endAnimationUpdateUI();
 	void			unpauseAnimation() { mPauseRequest = NULL; }
@@ -800,7 +798,7 @@ protected:
 	// Only used for building titles.
 	BOOL			isGroupMember() const 		{ return !mGroupID.isNull(); } 
 public:
-	LLDynamicArray<LLGroupData> mGroups;
+	std::vector<LLGroupData> mGroups;
 
 	//--------------------------------------------------------------------
 	// Group Title
diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp
index a4c0b056ac..87c44a391d 100755
--- a/indra/newview/llagentlistener.cpp
+++ b/indra/newview/llagentlistener.cpp
@@ -504,7 +504,7 @@ void LLAgentListener::lookAt(LLSD const & event_data) const
 void LLAgentListener::getGroups(const LLSD& event) const
 {
     LLSD reply(LLSD::emptyArray());
-    for (LLDynamicArray<LLGroupData>::const_iterator
+    for (std::vector<LLGroupData>::const_iterator
              gi(mAgent.mGroups.begin()), gend(mAgent.mGroups.end());
          gi != gend; ++gi)
     {
diff --git a/indra/newview/llagentpicksinfo.cpp b/indra/newview/llagentpicksinfo.cpp
index 192ed141c7..7a04cfb48b 100755
--- a/indra/newview/llagentpicksinfo.cpp
+++ b/indra/newview/llagentpicksinfo.cpp
@@ -28,9 +28,11 @@
 #include "llagentpicksinfo.h"
 
 #include "llagent.h"
-#include "llavatarconstants.h"
 #include "llavatarpropertiesprocessor.h"
 
+const S32 MAX_AVATAR_PICKS = 10;
+
+
 class LLAgentPicksInfo::LLAgentPicksObserver : public LLAvatarPropertiesObserver
 {
 public:
diff --git a/indra/newview/llagentpilot.cpp b/indra/newview/llagentpilot.cpp
index c7872fc5f6..0dd107f349 100755
--- a/indra/newview/llagentpilot.cpp
+++ b/indra/newview/llagentpilot.cpp
@@ -97,11 +97,12 @@ void LLAgentPilot::loadTxt(const std::string& filename)
 		llinfos << "Opening pilot file " << filename << llendl;
 	}
 
-	mActions.reset();
+	mActions.clear();
 	S32 num_actions;
 
 	file >> num_actions;
 
+	mActions.reserve(num_actions);
 	for (S32 i = 0; i < num_actions; i++)
 	{
 		S32 action_type;
@@ -109,7 +110,7 @@ void LLAgentPilot::loadTxt(const std::string& filename)
 		file >> new_action.mTime >> action_type;
 		file >> new_action.mTarget.mdV[VX] >> new_action.mTarget.mdV[VY] >> new_action.mTarget.mdV[VZ];
 		new_action.mType = (EActionType)action_type;
-		mActions.put(new_action);
+		mActions.push_back(new_action);
 	}
 
 	mOverrideCamera = false;
@@ -137,7 +138,7 @@ void LLAgentPilot::loadXML(const std::string& filename)
 		llinfos << "Opening pilot file " << filename << llendl;
 	}
 
-	mActions.reset();
+	mActions.clear();
 	LLSD record;
 	while (!file.eof() && LLSDParser::PARSE_FAILURE != LLSDSerialize::fromXML(record, file))
 	{
@@ -150,7 +151,7 @@ void LLAgentPilot::loadXML(const std::string& filename)
 		action.mCameraXAxis = ll_vector3_from_sd(record["camera_xaxis"]);
 		action.mCameraYAxis = ll_vector3_from_sd(record["camera_yaxis"]);
 		action.mCameraZAxis = ll_vector3_from_sd(record["camera_zaxis"]);
-		mActions.put(action);
+		mActions.push_back(action);
 	}
 	mOverrideCamera = true;
 	file.close();
@@ -174,10 +175,10 @@ void LLAgentPilot::saveTxt(const std::string& filename)
 		llinfos << "Couldn't open " << filename << ", aborting agentpilot save!" << llendl;
 	}
 
-	file << mActions.count() << '\n';
+	file << mActions.size() << '\n';
 
 	S32 i;
-	for (i = 0; i < mActions.count(); i++)
+	for (i = 0; i < mActions.size(); i++)
 	{
 		file << mActions[i].mTime << "\t" << mActions[i].mType << "\t";
 		file << std::setprecision(32) << mActions[i].mTarget.mdV[VX] << "\t" << mActions[i].mTarget.mdV[VY] << "\t" << mActions[i].mTarget.mdV[VZ];
@@ -198,7 +199,7 @@ void LLAgentPilot::saveXML(const std::string& filename)
 	}
 
 	S32 i;
-	for (i = 0; i < mActions.count(); i++)
+	for (i = 0; i < mActions.size(); i++)
 	{
 		Action& action = mActions[i];
 		LLSD record;
@@ -217,7 +218,7 @@ void LLAgentPilot::saveXML(const std::string& filename)
 
 void LLAgentPilot::startRecord()
 {
-	mActions.reset();
+	mActions.clear();
 	mTimer.reset();
 	addAction(STRAIGHT);
 	mRecording = TRUE;
@@ -244,7 +245,7 @@ void LLAgentPilot::addAction(enum EActionType action_type)
 	action.mCameraYAxis = cam->getYAxis();
 	action.mCameraZAxis = cam->getZAxis();
 	mLastRecordTime = (F32)action.mTime;
-	mActions.put(action);
+	mActions.push_back(action);
 }
 
 void LLAgentPilot::startPlayback()
@@ -255,7 +256,7 @@ void LLAgentPilot::startPlayback()
 		mCurrentAction = 0;
 		mTimer.reset();
 
-		if (mActions.count())
+		if (mActions.size())
 		{
 			llinfos << "Starting playback, moving to waypoint 0" << llendl;
 			gAgent.startAutoPilotGlobal(mActions[0].mTarget);
@@ -291,7 +292,7 @@ void LLAgentPilot::moveCamera()
 	if (!getOverrideCamera())
 		return;
 
-	if (mCurrentAction<mActions.count())
+	if (mCurrentAction<mActions.size())
 	{
 		S32 start_index = llmax(mCurrentAction-1,0);
 		S32 end_index = mCurrentAction;
@@ -331,7 +332,7 @@ void LLAgentPilot::updateTarget()
 {
 	if (mPlaying)
 	{
-		if (mCurrentAction < mActions.count())
+		if (mCurrentAction < mActions.size())
 		{
 			if (0 == mCurrentAction)
 			{
@@ -355,7 +356,7 @@ void LLAgentPilot::updateTarget()
 				//gAgent.stopAutoPilot();
 				mCurrentAction++;
 
-				if (mCurrentAction < mActions.count())
+				if (mCurrentAction < mActions.size())
 				{
 					gAgent.startAutoPilotGlobal(mActions[mCurrentAction].mTarget);
 					moveCamera();
diff --git a/indra/newview/llagentpilot.h b/indra/newview/llagentpilot.h
index dd1709ec0c..f6b6376086 100755
--- a/indra/newview/llagentpilot.h
+++ b/indra/newview/llagentpilot.h
@@ -30,7 +30,6 @@
 #include "stdtypes.h"
 #include "lltimer.h"
 #include "v3dmath.h"
-#include "lldarray.h"
 
 // Class that drives the agent around according to a "script".
 
@@ -113,7 +112,7 @@ private:
 		LLVector3		mCameraZAxis;
 	};
 
-	LLDynamicArray<Action>	mActions;
+	std::vector<Action>	mActions;
 	LLTimer					mTimer;
 
 };
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index e158dc7505..4a25b8c205 100755
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -958,7 +958,7 @@ public:
 	{
 		llinfos << "One item created " << inv_item.asString() << llendl;
 		LLViewerInventoryItem *item = gInventory.getItem(inv_item);
-		mItemsToLink.put(item);
+		mItemsToLink.push_back(item);
 		updatePendingWearable(inv_item);
 	}
 	~OnWearableItemCreatedCB()
@@ -1235,7 +1235,7 @@ void LLAgentWearables::removeWearableFinal(const LLWearableType::EType type, boo
 
 // Assumes existing wearables are not dirty.
 void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& items,
-										 const LLDynamicArray< LLViewerWearable* >& wearables,
+										 const std::vector< LLViewerWearable* >& wearables,
 										 BOOL remove)
 {
 	llinfos << "setWearableOutfit() start" << llendl;
@@ -1254,8 +1254,8 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
 		}
 	}
 
-	S32 count = wearables.count();
-	llassert(items.count() == count);
+	S32 count = wearables.size();
+	llassert(items.size() == count);
 
 	S32 i;
 	for (i = 0; i < count; i++)
@@ -1538,7 +1538,7 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj
 
 	std::set<LLUUID> requested_item_ids;
 	std::set<LLUUID> current_item_ids;
-	for (S32 i=0; i<obj_item_array.count(); i++)
+	for (S32 i=0; i<obj_item_array.size(); i++)
 		requested_item_ids.insert(obj_item_array[i].get()->getLinkedUUID());
 
 	// Build up list of objects to be removed and items currently attached.
@@ -1624,7 +1624,7 @@ void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remo
 void LLAgentWearables::userAttachMultipleAttachments(LLInventoryModel::item_array_t& obj_item_array)
 {
 	// Build a compound message to send all the objects that need to be rezzed.
-	S32 obj_count = obj_item_array.count();
+	S32 obj_count = obj_item_array.size();
 
 	// Limit number of packets to send
 	const S32 MAX_PACKETS_TO_SEND = 10;
@@ -1655,7 +1655,7 @@ void LLAgentWearables::userAttachMultipleAttachments(LLInventoryModel::item_arra
 			msg->addBOOLFast(_PREHASH_FirstDetachAll, false );
 		}
 
-		const LLInventoryItem* item = obj_item_array.get(i).get();
+		const LLInventoryItem* item = obj_item_array.at(i).get();
 		msg->nextBlockFast(_PREHASH_ObjectData );
 		msg->addUUIDFast(_PREHASH_ItemID, item->getLinkedUUID());
 		msg->addUUIDFast(_PREHASH_OwnerID, item->getPermissions().getOwner());
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index 5be4648636..02d24892b5 100755
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -107,7 +107,7 @@ private:
 	/*virtual*/void	wearableUpdated(LLWearable *wearable, BOOL removed);
 public:
 	void			setWearableItem(LLInventoryItem* new_item, LLViewerWearable* wearable, bool do_append = false);
-	void			setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLViewerWearable* >& wearables, BOOL remove);
+	void			setWearableOutfit(const LLInventoryItem::item_array_t& items, const std::vector< LLViewerWearable* >& wearables, BOOL remove);
 	void			setWearableName(const LLUUID& item_id, const std::string& new_name);
 	// *TODO: Move this into llappearance/LLWearableData ?
 	void			addLocalTextureObject(const LLWearableType::EType wearable_type, const LLAvatarAppearanceDefines::ETextureIndex texture_type, U32 wearable_index);
diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp
index 8b6b6db525..4a8d122dd8 100755
--- a/indra/newview/llagentwearablesfetch.cpp
+++ b/indra/newview/llagentwearablesfetch.cpp
@@ -54,7 +54,7 @@ void order_my_outfits_cb()
 		//My Outfits should at least contain saved initial outfit and one another outfit
 		if (cats->size() < 2)
 		{
-			llwarning("My Outfits category was not populated properly", 0);
+			LL_WARNS() << "My Outfits category was not populated properly" << LL_ENDL;
 			return;
 		}
 
@@ -127,7 +127,7 @@ void LLInitialWearablesFetch::processContents()
 									LLInventoryModel::EXCLUDE_TRASH, is_wearable);
 
 	LLAppearanceMgr::instance().setAttachmentInvLinkEnable(true);
-	if (wearable_array.count() > 0)
+	if (wearable_array.size() > 0)
 	{
 		gAgentWearables.notifyLoadingStarted();
 		LLAppearanceMgr::instance().updateAppearanceFromCOF();
@@ -326,7 +326,7 @@ void LLLibraryOutfitsFetch::folderDone()
 	
 	// Early out if we already have items in My Outfits
 	// except the case when My Outfits contains just initial outfit
-	if (cat_array.count() > 1)
+	if (cat_array.size() > 1)
 	{
 		mOutfitsPopulated = true;
 		return;
@@ -342,9 +342,9 @@ void LLLibraryOutfitsFetch::folderDone()
 									cat_array, wearable_array, 
 									LLInventoryModel::EXCLUDE_TRASH,
 									matchFolderFunctor);
-	if (cat_array.count() > 0)
+	if (cat_array.size() > 0)
 	{
-		const LLViewerInventoryCategory *cat = cat_array.get(0);
+		const LLViewerInventoryCategory *cat = cat_array.at(0);
 		mLibraryClothingID = cat->getUUID();
 	}
 
@@ -374,7 +374,7 @@ void LLLibraryOutfitsFetch::outfitsDone()
 	gInventory.collectDescendents(mLibraryClothingID, cat_array, wearable_array, 
 								  LLInventoryModel::EXCLUDE_TRASH);
 	
-	llassert(cat_array.count() > 0);
+	llassert(cat_array.size() > 0);
 	for (LLInventoryModel::cat_array_t::const_iterator iter = cat_array.begin();
 		 iter != cat_array.end();
 		 ++iter)
@@ -401,7 +401,7 @@ void LLLibraryOutfitsFetch::outfitsDone()
 									matchFolderFunctor);
 	if (cat_array.size() > 0)
 	{
-		const LLViewerInventoryCategory *cat = cat_array.get(0);
+		const LLViewerInventoryCategory *cat = cat_array.at(0);
 		mImportedClothingID = cat->getUUID();
 	}
 	
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index fd9236c8b3..a18448da6e 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -148,11 +148,11 @@ LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string
 									item_array,
 									LLInventoryModel::EXCLUDE_TRASH,
 									has_name);
-	if (0 == cat_array.count())
+	if (0 == cat_array.size())
 		return LLUUID();
 	else
 	{
-		LLViewerInventoryCategory *cat = cat_array.get(0);
+		LLViewerInventoryCategory *cat = cat_array.at(0);
 		if (cat)
 			return cat->getUUID();
 		else
@@ -754,9 +754,9 @@ void LLWearableHoldingPattern::onAllComplete()
 	}
 
 	// Activate all gestures in this folder
-	if (mGestItems.count() > 0)
+	if (mGestItems.size() > 0)
 	{
-		LL_DEBUGS("Avatar") << self_av_string() << "Activating " << mGestItems.count() << " gestures" << LL_ENDL;
+		LL_DEBUGS("Avatar") << self_av_string() << "Activating " << mGestItems.size() << " gestures" << LL_ENDL;
 		
 		LLGestureMgr::instance().activateGestures(mGestItems);
 		
@@ -779,7 +779,7 @@ void LLWearableHoldingPattern::onAllComplete()
 	// Update attachments to match those requested.
 	if (isAgentAvatarValid())
 	{
-		LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.count() << " attachments" << LL_ENDL;
+		LL_DEBUGS("Avatar") << self_av_string() << "Updating " << mObjItems.size() << " attachments" << LL_ENDL;
 		LLAgentWearables::userUpdateAttachments(mObjItems);
 	}
 
@@ -1155,9 +1155,9 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items)
 	// encountered, so we actually keep the *last* of each duplicate
 	// item.  This is needed to give the right priority when adding
 	// duplicate items to an existing outfit.
-	for (S32 i=items.count()-1; i>=0; i--)
+	for (S32 i=items.size()-1; i>=0; i--)
 	{
-		LLViewerInventoryItem *item = items.get(i);
+		LLViewerInventoryItem *item = items.at(i);
 		LLUUID item_id = item->getLinkedUUID();
 		if (items_seen.find(item_id)!=items_seen.end())
 			continue;
@@ -1168,7 +1168,7 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items)
 		 it != tmp_list.end();
 		 ++it)
 	{
-		new_items.put(*it);
+		new_items.push_back(*it);
 	}
 	items = new_items;
 }
@@ -1464,7 +1464,7 @@ void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LL
 	LLInventoryModel::cat_array_t* cats;
 	LLInventoryModel::item_array_t* items;
 	gInventory.getDirectDescendentsOf(src_id, cats, items);
-	llinfos << "copying " << items->count() << " items" << llendl;
+	llinfos << "copying " << items->size() << " items" << llendl;
 	for (LLInventoryModel::item_array_t::const_iterator iter = items->begin();
 		 iter != items->end();
 		 ++iter)
@@ -1644,9 +1644,9 @@ void LLAppearanceMgr::purgeBaseOutfitLink(const LLUUID& category)
 	LLInventoryModel::item_array_t items;
 	gInventory.collectDescendents(category, cats, items,
 								  LLInventoryModel::EXCLUDE_TRASH);
-	for (S32 i = 0; i < items.count(); ++i)
+	for (S32 i = 0; i < items.size(); ++i)
 	{
-		LLViewerInventoryItem *item = items.get(i);
+		LLViewerInventoryItem *item = items.at(i);
 		if (item->getActualType() != LLAssetType::AT_LINK_FOLDER)
 			continue;
 		if (item->getIsLinkType())
@@ -1666,9 +1666,9 @@ void LLAppearanceMgr::purgeCategory(const LLUUID& category, bool keep_outfit_lin
 	LLInventoryModel::item_array_t items;
 	gInventory.collectDescendents(category, cats, items,
 								  LLInventoryModel::EXCLUDE_TRASH);
-	for (S32 i = 0; i < items.count(); ++i)
+	for (S32 i = 0; i < items.size(); ++i)
 	{
-		LLViewerInventoryItem *item = items.get(i);
+		LLViewerInventoryItem *item = items.at(i);
 		if (keep_outfit_links && (item->getActualType() == LLAssetType::AT_LINK_FOLDER))
 			continue;
 		if (item->getIsLinkType())
@@ -1718,9 +1718,9 @@ void LLAppearanceMgr::linkAll(const LLUUID& cat_uuid,
 							  LLInventoryModel::item_array_t& items,
 							  LLPointer<LLInventoryCallback> cb)
 {
-	for (S32 i=0; i<items.count(); i++)
+	for (S32 i=0; i<items.size(); i++)
 	{
-		const LLInventoryItem* item = items.get(i).get();
+		const LLInventoryItem* item = items.at(i).get();
 		link_inventory_item(gAgent.getID(),
 							item->getLinkedUUID(),
 							cat_uuid,
@@ -1749,9 +1749,9 @@ void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append)
 	{
 		LLInventoryModel::item_array_t gest_items;
 		getDescendentsOfAssetType(cof, gest_items, LLAssetType::AT_GESTURE, false);
-		for(S32 i = 0; i  < gest_items.count(); ++i)
+		for(S32 i = 0; i  < gest_items.size(); ++i)
 		{
-			LLViewerInventoryItem *gest_item = gest_items.get(i);
+			LLViewerInventoryItem *gest_item = gest_items.at(i);
 			if ( LLGestureMgr::instance().isGestureActive( gest_item->getLinkedUUID()) )
 			{
 				LLGestureMgr::instance().deactivateGesture( gest_item->getLinkedUUID() );
@@ -1798,10 +1798,10 @@ void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append)
 	
 	// Create links to new COF contents.
 	LLInventoryModel::item_array_t all_items;
-	all_items += body_items;
-	all_items += wear_items;
-	all_items += obj_items;
-	all_items += gest_items;
+	std::copy(body_items.begin(), body_items.end(), std::back_inserter(all_items));
+	std::copy(wear_items.begin(), wear_items.end(), std::back_inserter(all_items));
+	std::copy(obj_items.begin(), obj_items.end(), std::back_inserter(all_items));
+	std::copy(gest_items.begin(), gest_items.end(), std::back_inserter(all_items));
 
 	// Will link all the above items.
 	LLPointer<LLInventoryCallback> link_waiter = new LLUpdateAppearanceOnDestroy;
@@ -1856,7 +1856,8 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo
 {
 	lldebugs << "updateAgentWearables()" << llendl;
 	LLInventoryItem::item_array_t items;
-	LLDynamicArray< LLViewerWearable* > wearables;
+	std::vector< LLViewerWearable* > wearables;
+	wearables.reserve(32);
 
 	// For each wearable type, find the wearables of that type.
 	for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
@@ -1871,14 +1872,14 @@ void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, boo
 				LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(data.mItemID);
 				if( item && (item->getAssetUUID() == wearable->getAssetID()) )
 				{
-					items.put(item);
-					wearables.put(wearable);
+					items.push_back(item);
+					wearables.push_back(wearable);
 				}
 			}
 		}
 	}
 
-	if(wearables.count() > 0)
+	if(wearables.size() > 0)
 	{
 		gAgentWearables.setWearableOutfit(items, wearables, !append);
 	}
@@ -1905,7 +1906,7 @@ bool sort_by_actual_description(const LLInventoryItem* item1, const LLInventoryI
 {
 	if (!item1 || !item2) 
 	{
-		llwarning("either item1 or item2 is NULL", 0);
+		LL_WARNS() << "either item1 or item2 is NULL" << LL_ENDL;
 		return true;
 	}
 
@@ -1922,7 +1923,7 @@ void item_array_diff(LLInventoryModel::item_array_t& full_list,
 		 ++it)
 	{
 		LLViewerInventoryItem *item = *it;
-		if (keep_list.find(item) < 0) // Why on earth does LLDynamicArray need to redefine find()?
+		if (std::find(keep_list.begin(), keep_list.end(), item) == keep_list.end())
 		{
 			kill_list.push_back(item);
 		}
@@ -2036,7 +2037,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 	dumpItemArray(wear_items,"asset_dump: wear_item");
 	dumpItemArray(obj_items,"asset_dump: obj_item");
 
-	if(!wear_items.count())
+	if(!wear_items.size())
 	{
 		LLNotificationsUtil::add("CouldNotPutOnOutfit");
 		return;
@@ -2056,9 +2057,9 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 	// callback will be called (and this object deleted)
 	// before the final getNextData().
 
-	for(S32 i = 0; i  < wear_items.count(); ++i)
+	for(S32 i = 0; i  < wear_items.size(); ++i)
 	{
-		LLViewerInventoryItem *item = wear_items.get(i);
+		LLViewerInventoryItem *item = wear_items.at(i);
 		LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL;
 
 		// Fault injection: use debug setting to test asset 
@@ -2301,10 +2302,10 @@ void LLAppearanceMgr::wearOutfitByName(const std::string& name)
 									has_name);
 	bool copy_items = false;
 	LLInventoryCategory* cat = NULL;
-	if (cat_array.count() > 0)
+	if (cat_array.size() > 0)
 	{
 		// Just wear the first one that matches
-		cat = cat_array.get(0);
+		cat = cat_array.at(0);
 	}
 	else
 	{
@@ -2313,9 +2314,9 @@ void LLAppearanceMgr::wearOutfitByName(const std::string& name)
 										item_array,
 										LLInventoryModel::EXCLUDE_TRASH,
 										has_name);
-		if(cat_array.count() > 0)
+		if(cat_array.size() > 0)
 		{
-			cat = cat_array.get(0);
+			cat = cat_array.at(0);
 			copy_items = true;
 		}
 	}
@@ -2426,10 +2427,10 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update
 								  LLInventoryModel::EXCLUDE_TRASH);
 	bool linked_already = false;
 	U32 count = 0;
-	for (S32 i=0; i<item_array.count(); i++)
+	for (S32 i=0; i<item_array.size(); i++)
 	{
 		// Are these links to the same object?
-		const LLViewerInventoryItem* inv_item = item_array.get(i).get();
+		const LLViewerInventoryItem* inv_item = item_array.at(i).get();
 		const LLWearableType::EType wearable_type = inv_item->getWearableType();
 
 		const bool is_body_part =    (wearable_type == LLWearableType::WT_SHAPE) 
@@ -2502,12 +2503,12 @@ LLInventoryModel::item_array_t LLAppearanceMgr::findCOFItemLinks(const LLUUID& i
 									  cat_array,
 									  item_array,
 									  LLInventoryModel::EXCLUDE_TRASH);
-		for (S32 i=0; i<item_array.count(); i++)
+		for (S32 i=0; i<item_array.size(); i++)
 		{
-			const LLViewerInventoryItem* inv_item = item_array.get(i).get();
+			const LLViewerInventoryItem* inv_item = item_array.at(i).get();
 			if (inv_item->getLinkedUUID() == vitem->getLinkedUUID())
 			{
-				result.put(item_array.get(i));
+				result.push_back(item_array.at(i));
 			}
 		}
 	}
@@ -2579,9 +2580,9 @@ void LLAppearanceMgr::removeCOFItemLinks(const LLUUID& item_id)
 								  cat_array,
 								  item_array,
 								  LLInventoryModel::EXCLUDE_TRASH);
-	for (S32 i=0; i<item_array.count(); i++)
+	for (S32 i=0; i<item_array.size(); i++)
 	{
-		const LLInventoryItem* item = item_array.get(i).get();
+		const LLInventoryItem* item = item_array.at(i).get();
 		if (item->getIsLinkType() && item->getLinkedUUID() == item_id)
 		{
 			gInventory.purgeObject(item->getUUID());
@@ -2611,7 +2612,7 @@ bool sort_by_linked_uuid(const LLViewerInventoryItem* item1, const LLViewerInven
 {
 	if (!item1 || !item2)
 	{
-		llwarning("item1, item2 cannot be null, something is very wrong", 0);
+		LL_WARNS() << "item1, item2 cannot be null, something is very wrong" << LL_ENDL;
 		return true;
 	}
 
@@ -2653,7 +2654,7 @@ void LLAppearanceMgr::updateIsDirty()
 		gInventory.collectDescendentsIf(base_outfit, outfit_cats, outfit_items,
 									  LLInventoryModel::EXCLUDE_TRASH, collector);
 
-		if(outfit_items.count() != cof_items.count())
+		if(outfit_items.size() != cof_items.size())
 		{
 			// Current outfit folder should have one more item than the outfit folder.
 			// this one item is the link back to the outfit folder itself.
@@ -2667,8 +2668,8 @@ void LLAppearanceMgr::updateIsDirty()
 
 		for (U32 i = 0; i < cof_items.size(); ++i)
 		{
-			LLViewerInventoryItem *item1 = cof_items.get(i);
-			LLViewerInventoryItem *item2 = outfit_items.get(i);
+			LLViewerInventoryItem *item1 = cof_items.at(i);
+			LLViewerInventoryItem *item2 = outfit_items.at(i);
 
 			if (item1->getLinkedUUID() != item2->getLinkedUUID() || 
 				item1->getName() != item2->getName() ||
@@ -2839,9 +2840,9 @@ void LLAppearanceMgr::divvyWearablesByType(const LLInventoryModel::item_array_t&
 	items_by_type.resize(LLWearableType::WT_COUNT);
 	if (items.empty()) return;
 
-	for (S32 i=0; i<items.count(); i++)
+	for (S32 i=0; i<items.size(); i++)
 	{
-		LLViewerInventoryItem *item = items.get(i);
+		LLViewerInventoryItem *item = items.at(i);
 		if (!item)
 		{
 			LL_WARNS("Appearance") << "NULL item found" << llendl;
@@ -2879,7 +2880,7 @@ struct WearablesOrderComparator
 	{
 		if (!item1 || !item2)
 		{
-			llwarning("either item1 or item2 is NULL", 0);
+			LL_WARNS() << "either item1 or item2 is NULL" << LL_ENDL;
 			return true;
 		}
 		
@@ -3122,9 +3123,9 @@ public:
 		LLInventoryModel::item_array_t item_array;
 		gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(),
 									  cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH);
-		for (S32 i=0; i<item_array.count(); i++)
+		for (S32 i=0; i<item_array.size(); i++)
 		{
-			const LLViewerInventoryItem* inv_item = item_array.get(i).get();
+			const LLViewerInventoryItem* inv_item = item_array.at(i).get();
 			local_items.insert(inv_item->getUUID());
 			LL_DEBUGS("Avatar") << "item_id: " << inv_item->getUUID()
 								<< " linked_item_id: " << inv_item->getLinkedUUID()
@@ -3159,9 +3160,9 @@ LLSD LLAppearanceMgr::dumpCOF() const
 	LLInventoryModel::cat_array_t cat_array;
 	LLInventoryModel::item_array_t item_array;
 	gInventory.collectDescendents(getCOF(),cat_array,item_array,LLInventoryModel::EXCLUDE_TRASH);
-	for (S32 i=0; i<item_array.count(); i++)
+	for (S32 i=0; i<item_array.size(); i++)
 	{
-		const LLViewerInventoryItem* inv_item = item_array.get(i).get();
+		const LLViewerInventoryItem* inv_item = item_array.at(i).get();
 		LLSD item;
 		LLUUID item_id(inv_item->getUUID());
 		md5.update((unsigned char*)item_id.mData, 16);
@@ -3505,7 +3506,7 @@ void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg)
 	llinfos << llendl;
 	llinfos << str << llendl;
 	S32 hitcount = 0;
-	for(S32 i=0; i<items.count(); i++)
+	for(S32 i=0; i<items.size(); i++)
 	{
 		LLViewerInventoryItem *item = items.get(i);
 		if (item)
@@ -3513,15 +3514,15 @@ void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg)
 		llinfos << i <<" "<< item->getName() <<llendl;
 	}
 #endif
-	llinfos << msg << " count " << items.count() << llendl;
+	llinfos << msg << " count " << items.size() << llendl;
 }
 
 void LLAppearanceMgr::dumpItemArray(const LLInventoryModel::item_array_t& items,
 									const std::string& msg)
 {
-	for (S32 i=0; i<items.count(); i++)
+	for (S32 i=0; i<items.size(); i++)
 	{
-		LLViewerInventoryItem *item = items.get(i);
+		LLViewerInventoryItem *item = items.at(i);
 		LLViewerInventoryItem *linked_item = item ? item->getLinkedItem() : NULL;
 		LLUUID asset_id;
 		if (linked_item)
@@ -3703,7 +3704,7 @@ public:
 									  cat_array,
 									  item_array,
 									  LLInventoryModel::EXCLUDE_TRASH);
-		S32 count = item_array.count();
+		S32 count = item_array.size();
 		if(!count)
 		{
 			llwarns << "Nothing fetched in category " << mComplete.front()
@@ -3715,11 +3716,11 @@ public:
 			return;
 		}
 
-		llinfos << "stage1 got " << item_array.count() << " items, passing to stage2 " << llendl;
+		llinfos << "stage1 got " << item_array.size() << " items, passing to stage2 " << llendl;
 		uuid_vec_t ids;
 		for(S32 i = 0; i < count; ++i)
 		{
-			ids.push_back(item_array.get(i)->getUUID());
+			ids.push_back(item_array.at(i)->getUUID());
 		}
 		
 		gInventory.removeObserver(this);
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index a208745822..9c954e5a67 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -294,12 +294,12 @@ U32	gFrameCount = 0;
 U32 gForegroundFrameCount = 0; // number of frames that app window was in foreground
 LLPumpIO* gServicePump = NULL;
 
-U64 gFrameTime = 0;
-F32 gFrameTimeSeconds = 0.f;
-LLUnit<F32, LLUnits::Seconds> gFrameIntervalSeconds = 0.f;
+LLUnitImplicit<U64, LLUnits::Microseconds> gFrameTime = 0;
+LLUnitImplicit<F32, LLUnits::Seconds> gFrameTimeSeconds = 0.f;
+LLUnitImplicit<F32, LLUnits::Seconds> gFrameIntervalSeconds = 0.f;
 F32 gFPSClamped = 10.f;						// Pretend we start at target rate.
 F32 gFrameDTClamped = 0.f;					// Time between adjacent checks to network for packets
-U64	gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
+LLUnitImplicit<U64, LLUnits::Microseconds>	gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
 U32 gFrameStalls = 0;
 const F64 FRAME_STALL_THRESHOLD = 1.0;
 
@@ -662,7 +662,7 @@ LLTextureFetch* LLAppViewer::sTextureFetch = NULL;
 
 std::string getRuntime()
 {
-	return llformat("%g", LLTimer::getElapsedSeconds().value());
+	return llformat("%.4f", (F32)LLTimer::getElapsedSeconds().value());
 }
 
 LLAppViewer::LLAppViewer() 
@@ -1260,7 +1260,7 @@ LLFastTimer::DeclareTimer FTM_FRAME("Frame");
 
 bool LLAppViewer::mainLoop()
 {
-	llinfos << "***********************Entering main_loop***********************" << llendflush;
+	llinfos << "***********************Entering main_loop***********************" << LL_ENDL;
 
 	mMainloopTimeout = new LLWatchdogTimeout();
 	
@@ -1465,7 +1465,7 @@ bool LLAppViewer::mainLoop()
 					ms_sleep(500);
 				}
 
-				const F64 max_idle_time = llmin(.005*10.0*gFrameTimeSeconds, 0.005); // 5 ms a second
+				const F64 max_idle_time = llmin(.005*10.0*gFrameTimeSeconds, LLUnitImplicit<F32, LLUnits::Seconds>(0.005f)); // 5 ms a second
 				idleTimer.reset();
 				S32 total_work_pending = 0;
 				S32 total_io_pending = 0;	
@@ -1588,7 +1588,7 @@ bool LLAppViewer::mainLoop()
 
 	destroyMainloopTimeout();
 
-	llinfos << "***********************Exiting main_loop***********************" << llendflush;
+	llinfos << "***********************Exiting main_loop***********************" << LL_ENDL;
 
 	return true;
 }
@@ -1621,7 +1621,7 @@ void LLAppViewer::flushVFSIO()
 		{
 			break;
 		}
-		llinfos << "Waiting for pending IO to finish: " << pending << llendflush;
+		llinfos << "Waiting for pending IO to finish: " << pending << LL_ENDL;
 		ms_sleep(100);
 	}
 }
@@ -1685,7 +1685,7 @@ bool LLAppViewer::cleanup()
 	
 	disconnectViewer();
 
-	llinfos << "Viewer disconnected" << llendflush;
+	llinfos << "Viewer disconnected" << LL_ENDL;
 
 	display_cleanup(); 
 
@@ -1693,7 +1693,7 @@ bool LLAppViewer::cleanup()
 
 	LLError::logToFixedBuffer(NULL);
 
-	llinfos << "Cleaning Up" << llendflush;
+	llinfos << "Cleaning Up" << LL_ENDL;
 
 	// shut down mesh streamer
 	gMeshRepo.shutdown();
@@ -1708,7 +1708,7 @@ bool LLAppViewer::cleanup()
 		LLHUDObject::updateAll();
 		LLHUDManager::getInstance()->cleanupEffects();
 		LLHUDObject::cleanupHUDObjects();
-		llinfos << "HUD Objects cleaned up" << llendflush;
+		llinfos << "HUD Objects cleaned up" << LL_ENDL;
 	}
 
 	LLKeyframeDataCache::clear();
@@ -1739,7 +1739,7 @@ bool LLAppViewer::cleanup()
 
 	LLCalc::cleanUp();
 
-	llinfos << "Global stuff deleted" << llendflush;
+	llinfos << "Global stuff deleted" << LL_ENDL;
 
 	if (gAudiop)
 	{
@@ -1763,7 +1763,7 @@ bool LLAppViewer::cleanup()
 	// such that we can suck rectangle information out of
 	// it.
 	cleanupSavedSettings();
-	llinfos << "Settings patched up" << llendflush;
+	llinfos << "Settings patched up" << LL_ENDL;
 
 	// delete some of the files left around in the cache.
 	removeCacheFiles("*.wav");
@@ -1774,29 +1774,29 @@ bool LLAppViewer::cleanup()
 	removeCacheFiles("*.bodypart");
 	removeCacheFiles("*.clothing");
 
-	llinfos << "Cache files removed" << llendflush;
+	llinfos << "Cache files removed" << LL_ENDL;
 
 	// Wait for any pending VFS IO
 	flushVFSIO();
-	llinfos << "Shutting down Views" << llendflush;
+	llinfos << "Shutting down Views" << LL_ENDL;
 
 	// Destroy the UI
 	if( gViewerWindow)
 		gViewerWindow->shutdownViews();
 
-	llinfos << "Cleaning up Inventory" << llendflush;
+	llinfos << "Cleaning up Inventory" << LL_ENDL;
 	
 	// Cleanup Inventory after the UI since it will delete any remaining observers
 	// (Deleted observers should have already removed themselves)
 	gInventory.cleanupInventory();
 
-	llinfos << "Cleaning up Selections" << llendflush;
+	llinfos << "Cleaning up Selections" << LL_ENDL;
 	
 	// Clean up selection managers after UI is destroyed, as UI may be observing them.
 	// Clean up before GL is shut down because we might be holding on to objects with texture references
 	LLSelectMgr::cleanupGlobals();
 	
-	llinfos << "Shutting down OpenGL" << llendflush;
+	llinfos << "Shutting down OpenGL" << LL_ENDL;
 
 	// Shut down OpenGL
 	if( gViewerWindow)
@@ -1808,10 +1808,10 @@ bool LLAppViewer::cleanup()
 		// Therefore must do this before destroying the message system.
 		delete gViewerWindow;
 		gViewerWindow = NULL;
-		llinfos << "ViewerWindow deleted" << llendflush;
+		llinfos << "ViewerWindow deleted" << LL_ENDL;
 	}
 
-	llinfos << "Cleaning up Keyboard & Joystick" << llendflush;
+	llinfos << "Cleaning up Keyboard & Joystick" << LL_ENDL;
 	
 	// viewer UI relies on keyboard so keep it aound until viewer UI isa gone
 	delete gKeyboard;
@@ -1820,7 +1820,7 @@ bool LLAppViewer::cleanup()
 	// Turn off Space Navigator and similar devices
 	LLViewerJoystick::getInstance()->terminate();
 	
-	llinfos << "Cleaning up Objects" << llendflush;
+	llinfos << "Cleaning up Objects" << LL_ENDL;
 	
 	LLViewerObject::cleanupVOClasses();
 
@@ -1842,11 +1842,11 @@ bool LLAppViewer::cleanup()
 	LLVolumeMgr* volume_manager = LLPrimitive::getVolumeManager();
 	if (!volume_manager->cleanup())
 	{
-		llwarns << "Remaining references in the volume manager!" << llendflush;
+		llwarns << "Remaining references in the volume manager!" << LL_ENDL;
 	}
 	LLPrimitive::cleanupVolumeManager();
 
-	llinfos << "Additional Cleanup..." << llendflush;	
+	llinfos << "Additional Cleanup..." << LL_ENDL;	
 	
 	LLViewerParcelMgr::cleanupGlobals();
 
@@ -1867,10 +1867,10 @@ bool LLAppViewer::cleanup()
 	// Also after shutting down the messaging system since it has VFS dependencies
 
 	//
-	llinfos << "Cleaning up VFS" << llendflush;
+	llinfos << "Cleaning up VFS" << LL_ENDL;
 	LLVFile::cleanupClass();
 
-	llinfos << "Saving Data" << llendflush;
+	llinfos << "Saving Data" << LL_ENDL;
 	
 	// Store the time of our current logoff
 	gSavedPerAccountSettings.setU32("LastLogoff", time_corrected());
@@ -1897,7 +1897,7 @@ bool LLAppViewer::cleanup()
 	else
 	{
 		gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
-		llinfos << "Saved settings" << llendflush;
+		llinfos << "Saved settings" << LL_ENDL;
 	}
 
 	std::string warnings_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, getSettingsFilename("Default", "Warnings"));
@@ -1914,7 +1914,7 @@ bool LLAppViewer::cleanup()
 
 	if (mPurgeOnExit)
 	{
-		llinfos << "Purging all cache files on exit" << llendflush;
+		llinfos << "Purging all cache files on exit" << LL_ENDL;
 		gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), "*.*");
 	}
 
@@ -1931,7 +1931,7 @@ bool LLAppViewer::cleanup()
 	// Stop the plugin read thread if it's running.
 	LLPluginProcessParent::setUseReadThread(false);
 
-	llinfos << "Shutting down Threads" << llendflush;
+	llinfos << "Shutting down Threads" << LL_ENDL;
 
 	// Let threads finish
 	LLTimer idleTimer;
@@ -1969,7 +1969,7 @@ bool LLAppViewer::cleanup()
 	sTextureFetch->shutDownTextureCacheThread() ;
 	sTextureFetch->shutDownImageDecodeThread() ;
 
-	llinfos << "Shutting down message system" << llendflush;
+	llinfos << "Shutting down message system" << LL_ENDL;
 	end_messaging_system();
 
 	// *NOTE:Mani - The following call is not thread safe. 
@@ -2008,7 +2008,7 @@ bool LLAppViewer::cleanup()
 
 	LLMetricPerformanceTesterBasic::cleanClass() ;
 
-	llinfos << "Cleaning up Media and Textures" << llendflush;
+	llinfos << "Cleaning up Media and Textures" << LL_ENDL;
 
 	//Note:
 	//LLViewerMedia::cleanupClass() has to be put before gTextureList.shutdown()
@@ -2031,7 +2031,7 @@ bool LLAppViewer::cleanup()
 	}
 #endif
 
-	llinfos << "Misc Cleanup" << llendflush;
+	llinfos << "Misc Cleanup" << LL_ENDL;
 	
 	// For safety, the LLVFS has to be deleted *after* LLVFSThread. This should be cleaned up.
 	// (LLVFS doesn't know about LLVFSThread so can't kill pending requests) -Steve
@@ -2051,7 +2051,7 @@ bool LLAppViewer::cleanup()
 	// is at the right resolution before we launch IE.
 	if (!gLaunchFileOnQuit.empty())
 	{
-		llinfos << "Launch file on quit." << llendflush;
+		llinfos << "Launch file on quit." << LL_ENDL;
 #if LL_WINDOWS
 		// Indicate an application is starting.
 		SetCursor(LoadCursor(NULL, IDC_WAIT));
@@ -2061,7 +2061,7 @@ bool LLAppViewer::cleanup()
 		ms_sleep(1000);
 
 		LLWeb::loadURLExternal( gLaunchFileOnQuit, false );
-		llinfos << "File launched." << llendflush;
+		llinfos << "File launched." << LL_ENDL;
 	}
 	llinfos << "Cleaning up LLProxy." << llendl;
 	LLProxy::cleanupClass();
@@ -2075,7 +2075,7 @@ bool LLAppViewer::cleanup()
 
 	ll_close_fail_log();
 
-    llinfos << "Goodbye!" << llendflush;
+    llinfos << "Goodbye!" << LL_ENDL;
 
 	// return 0;
 	return true;
@@ -4559,7 +4559,7 @@ void LLAppViewer::idle()
 	{
 		LLFastTimer t(FTM_NETWORK);
 		// Update spaceserver timeinfo
-	    LLWorld::getInstance()->setSpaceTimeUSec(LLWorld::getInstance()->getSpaceTimeUSec() + (U32)(dt_raw * SEC_TO_MICROSEC));
+	    LLWorld::getInstance()->setSpaceTimeUSec(LLWorld::getInstance()->getSpaceTimeUSec() + LLUnits::Seconds::fromValue(dt_raw));
     
     
 	    //////////////////////////////////////
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index e7dd605044..60a1045f58 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -334,12 +334,12 @@ extern U32 gForegroundFrameCount;
 
 extern LLPumpIO* gServicePump;
 
-extern U64      gFrameTime;					// The timestamp of the most-recently-processed frame
-extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
-extern LLUnit<F32, LLUnits::Seconds>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
+extern LLUnitImplicit<U64, LLUnits::Microseconds>	gStartTime;
+extern LLUnitImplicit<U64, LLUnits::Microseconds>   gFrameTime;					// The timestamp of the most-recently-processed frame
+extern LLUnitImplicit<F32, LLUnits::Seconds>		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
+extern LLUnitImplicit<F32, LLUnits::Seconds>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
 extern F32		gFPSClamped;				// Frames per second, smoothed, weighted toward last frame
 extern F32		gFrameDTClamped;
-extern U64		gStartTime;
 extern U32 		gFrameStalls;
 
 extern LLTimer gRenderStartTime;
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index b7cdcb058b..f08d2c2a03 100755
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -53,7 +53,6 @@
 #include <stdlib.h>
 
 #include "llweb.h"
-#include "llsecondlifeurls.h"
 
 #include "llviewernetwork.h"
 #include "llmd5.h"
@@ -307,14 +306,14 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 		// app cleanup if there was a problem.
 		//
 #if WINDOWS_CRT_MEM_CHECKS
-    llinfos << "CRT Checking memory:" << llendflush;
+    llinfos << "CRT Checking memory:" << LL_ENDL;
 	if (!_CrtCheckMemory())
 	{
-		llwarns << "_CrtCheckMemory() failed at prior to cleanup!" << llendflush;
+		llwarns << "_CrtCheckMemory() failed at prior to cleanup!" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << " No corruption detected." << llendflush;
+		llinfos << " No corruption detected." << LL_ENDL;
 	}
 #endif
 	
@@ -323,14 +322,14 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	viewer_app_ptr->cleanup();
 	
 #if WINDOWS_CRT_MEM_CHECKS
-    llinfos << "CRT Checking memory:" << llendflush;
+    llinfos << "CRT Checking memory:" << LL_ENDL;
 	if (!_CrtCheckMemory())
 	{
-		llwarns << "_CrtCheckMemory() failed after cleanup!" << llendflush;
+		llwarns << "_CrtCheckMemory() failed after cleanup!" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << " No corruption detected." << llendflush;
+		llinfos << " No corruption detected." << LL_ENDL;
 	}
 #endif
 	 
@@ -568,7 +567,7 @@ bool LLAppViewerWin32::initHardwareTest()
 			if (OSBTN_NO== button)
 			{
 				LL_INFOS("AppInit") << "User quitting after failed DirectX 9 detection" << LL_ENDL;
-				LLWeb::loadURLExternal(DIRECTX_9_URL, false);
+				LLWeb::loadURLExternal("http://secondlife.com/support/, false);
 				return false;
 			}
 			gWarningSettings.setBOOL("AboutDirectX9", FALSE);
diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index b513a52ff7..1d774e6eac 100755
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -33,7 +33,6 @@
 
 #include "llavatarnamecache.h"	// IDEVO
 #include "llsd.h"
-#include "lldarray.h"
 #include "llnotifications.h"
 #include "llnotificationsutil.h"
 #include "roles_constants.h"    // for GP_MEMBER_INVITE
@@ -74,6 +73,12 @@
 #include "llslurl.h"			// IDEVO
 #include "llsidepanelinventory.h"
 
+// Flags for kick message
+const U32 KICK_FLAGS_DEFAULT	= 0x0;
+const U32 KICK_FLAGS_FREEZE		= 1 << 0;
+const U32 KICK_FLAGS_UNFREEZE	= 1 << 1;
+
+
 // static
 void LLAvatarActions::requestFriendshipDialog(const LLUUID& id, const std::string& name)
 {
@@ -164,7 +169,7 @@ void LLAvatarActions::offerTeleport(const LLUUID& invitee)
 	if (invitee.isNull())
 		return;
 
-	LLDynamicArray<LLUUID> ids;
+	std::vector<LLUUID> ids;
 	ids.push_back(invitee);
 	offerTeleport(ids);
 }
@@ -242,8 +247,9 @@ void LLAvatarActions::startAdhocCall(const uuid_vec_t& ids, const LLUUID& floate
 		return;
 	}
 
-	// convert vector into LLDynamicArray for addSession
-	LLDynamicArray<LLUUID> id_array;
+	// convert vector into std::vector for addSession
+	std::vector<LLUUID> id_array;
+	id_array.reserve(ids.size());
 	for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
 	{
 		id_array.push_back(*it);
@@ -288,7 +294,9 @@ bool LLAvatarActions::canCall()
 void LLAvatarActions::startConference(const uuid_vec_t& ids, const LLUUID& floater_id)
 {
 	// *HACK: Copy into dynamic array
-	LLDynamicArray<LLUUID> id_array;
+	std::vector<LLUUID> id_array;
+
+	id_array.reserve(ids.size());
 	for (uuid_vec_t::const_iterator it = ids.begin(); it != ids.end(); ++it)
 	{
 		id_array.push_back(*it);
diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h
index 6e1198cd09..dd5f5eddf4 100755
--- a/indra/newview/llavataractions.h
+++ b/indra/newview/llavataractions.h
@@ -27,7 +27,6 @@
 #ifndef LL_LLAVATARACTIONS_H
 #define LL_LLAVATARACTIONS_H
 
-#include "lldarray.h"
 #include "llsd.h"
 #include "lluuid.h"
 
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index f34ad23769..0d1ecc9c47 100755
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -32,7 +32,6 @@
 
 // viewer includes
 #include "llagent.h"
-#include "llavatarconstants.h"
 #include "llcallingcard.h" // for LLAvatarTracker
 #include "llavataractions.h"
 #include "llmenugl.h"
diff --git a/indra/newview/llavatarlist.cpp b/indra/newview/llavatarlist.cpp
index 9f02f301a1..8846d1317d 100755
--- a/indra/newview/llavatarlist.cpp
+++ b/indra/newview/llavatarlist.cpp
@@ -586,7 +586,7 @@ bool LLAvatarItemComparator::compare(const LLPanel* item1, const LLPanel* item2)
 	
 	if (!avatar_item1 || !avatar_item2)
 	{
-		llerror("item1 and item2 cannot be null", 0);
+		LL_ERRS() << "item1 and item2 cannot be null" << LL_ENDL;
 		return true;
 	}
 
diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp
index 706bc42ea0..f095ef25d1 100755
--- a/indra/newview/llavatarpropertiesprocessor.cpp
+++ b/indra/newview/llavatarpropertiesprocessor.cpp
@@ -36,7 +36,6 @@
 #include "llstartup.h"
 
 // Linden library includes
-#include "llavatarconstants.h"	// AVATAR_TRANSACTED, etc.
 #include "lldate.h"
 #include "lltrans.h"
 #include "llui.h"				// LLUI::getLanguage()
diff --git a/indra/newview/llavatarpropertiesprocessor.h b/indra/newview/llavatarpropertiesprocessor.h
index fdb88a41a1..1dcd2c9b90 100755
--- a/indra/newview/llavatarpropertiesprocessor.h
+++ b/indra/newview/llavatarpropertiesprocessor.h
@@ -33,6 +33,14 @@
 #include <list>
 #include <map>
 
+// For Flags in AvatarPropertiesReply
+const U32 AVATAR_ALLOW_PUBLISH			= 0x1 << 0;	// whether profile is externally visible or not
+const U32 AVATAR_MATURE_PUBLISH			= 0x1 << 1;	// profile is "mature"
+const U32 AVATAR_IDENTIFIED				= 0x1 << 2;	// whether avatar has provided payment info
+const U32 AVATAR_TRANSACTED				= 0x1 << 3;	// whether avatar has actively used payment info
+const U32 AVATAR_ONLINE					= 0x1 << 4; // the online status of this avatar, if known.
+const U32 AVATAR_AGEVERIFIED			= 0x1 << 5;	// whether avatar has been age-verified
+
 /*
 *TODO Vadim: This needs some refactoring:
 - Remove EAvatarProcessorType in favor of separate observers, derived from a common parent (to get rid of void*).
diff --git a/indra/newview/llblocklist.cpp b/indra/newview/llblocklist.cpp
index 066cb71677..5133ceb64f 100755
--- a/indra/newview/llblocklist.cpp
+++ b/indra/newview/llblocklist.cpp
@@ -246,7 +246,7 @@ bool LLBlockListItemComparator::compare(const LLPanel* item1, const LLPanel* ite
 
 	if (!blocked_item1 || !blocked_item2)
 	{
-		llerror("blocked_item1 and blocked_item2 cannot be null", 0);
+		LL_ERRS() << "blocked_item1 and blocked_item2 cannot be null" << LL_ENDL;
 		return true;
 	}
 
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index b883941963..9b57587237 100755
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -28,7 +28,6 @@
 
 #include "llchatbar.h"
 
-#include "imageids.h"
 #include "llfontgl.h"
 #include "llrect.h"
 #include "llerror.h"
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index e86d6930e8..b5bb303b65 100755
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -477,7 +477,7 @@ void LLCOFWearables::populateAttachmentsAndBodypartsLists(const LLInventoryModel
 {
 	for (U32 i = 0; i < cof_items.size(); ++i)
 	{
-		LLViewerInventoryItem* item = cof_items.get(i);
+		LLViewerInventoryItem* item = cof_items.at(i);
 		if (!item) continue;
 
 		const LLAssetType::EType item_type = item->getType();
diff --git a/indra/newview/llcolorswatch.cpp b/indra/newview/llcolorswatch.cpp
index f1f7da5fd1..a03178adf6 100755
--- a/indra/newview/llcolorswatch.cpp
+++ b/indra/newview/llcolorswatch.cpp
@@ -37,13 +37,11 @@
 #include "llui.h"
 #include "llrender.h"
 #include "lluiconstants.h"
-#include "llviewercontrol.h"
 #include "llbutton.h"
-#include "lltextbox.h"
 #include "llfloatercolorpicker.h"
 #include "llviewborder.h"
-#include "llviewertexturelist.h"
 #include "llfocusmgr.h"
+#include "lltextbox.h"
 
 static LLDefaultChildRegistry::Register<LLColorSwatchCtrl> r("color_swatch");
 
@@ -239,16 +237,9 @@ void LLColorSwatchCtrl::draw()
 	}
 	else
 	{
-		if (!mFallbackImageName.empty())
+		if (mFallbackImage.notNull())
 		{
-			LLPointer<LLViewerFetchedTexture> fallback_image = LLViewerTextureManager::getFetchedTextureFromFile(mFallbackImageName, FTT_LOCAL_FILE, TRUE, 
-				LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
-			if( fallback_image->getComponents() == 4 )
-			{	
-				gl_rect_2d_checkerboard( interior );
-			}	
-			gl_draw_scaled_image( interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), fallback_image, LLColor4::white % alpha);
-			fallback_image->addTextureStats( (F32)(interior.getWidth() * interior.getHeight()) );
+			mFallbackImage->draw(interior.mLeft, interior.mBottom, interior.getWidth(), interior.getHeight(), LLColor4::white % alpha);
 		}
 		else
 		{
diff --git a/indra/newview/llcolorswatch.h b/indra/newview/llcolorswatch.h
index 5bdd1712d2..df907567ab 100755
--- a/indra/newview/llcolorswatch.h
+++ b/indra/newview/llcolorswatch.h
@@ -30,16 +30,13 @@
 #include "lluictrl.h"
 #include "v4color.h"
 #include "llfloater.h"
-#include "llviewertexture.h"
 #include "lltextbox.h"
 
 //
 // Classes
 //
 class LLColor4;
-class LLTextBox;
 class LLFloaterColorPicker;
-class LLViewerTexture;
 
 class LLColorSwatchCtrl
 : public LLUICtrl
@@ -87,7 +84,7 @@ public:
 	void			setCanApplyImmediately(BOOL apply) { mCanApplyImmediately = apply; }
 	void			setOnCancelCallback(commit_callback_t cb) { mOnCancelCallback = cb; }
 	void			setOnSelectCallback(commit_callback_t cb) { mOnSelectCallback = cb; }
-	void			setFallbackImageName(const std::string& name) { mFallbackImageName = name; }
+	void			setFallbackImage(LLPointer<LLUIImage> image) { mFallbackImage = image; }
 
 	void			showPicker(BOOL take_focus);
 
@@ -103,20 +100,20 @@ public:
 	void			closeFloaterColorPicker();
 
 protected:
-	BOOL			mValid;
-	LLColor4		mColor;
-	LLUIColor		mBorderColor;
-	LLTextBox*		mCaption;
-	LLHandle<LLFloater> mPickerHandle;
-	LLViewBorder*	mBorder;
-	BOOL			mCanApplyImmediately;
-	commit_callback_t mOnCancelCallback;
-	commit_callback_t mOnSelectCallback;
-	S32             mLabelWidth;
-	S32             mLabelHeight;
+	bool					mValid;
+	LLColor4				mColor;
+	LLUIColor				mBorderColor;
+	LLTextBox*				mCaption;
+	LLHandle<LLFloater>		mPickerHandle;
+	class LLViewBorder*		mBorder;
+	bool					mCanApplyImmediately;
+	commit_callback_t		mOnCancelCallback,
+							mOnSelectCallback;
+	S32						mLabelWidth,
+							mLabelHeight;
 
 	LLPointer<LLUIImage> mAlphaGradientImage;
-	std::string		mFallbackImageName;
+	LLPointer<LLUIImage> mFallbackImage;
 };
 
 #endif  // LL_LLBUTTON_H
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index d70d575eab..055a69727e 100755
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -45,7 +45,6 @@
 #include "llviewerobject.h"
 #include "llviewerobjectlist.h"
 #include "llviewerregion.h"
-#include "lscript_rt_interface.h"
 #include "llviewercontrol.h"
 #include "llviewerobject.h"
 #include "llviewerregion.h"
@@ -154,7 +153,7 @@ void LLFloaterScriptQueue::onCloseBtn(void* user_data)
 
 void LLFloaterScriptQueue::addObject(const LLUUID& id)
 {
-	mObjectIDs.put(id);
+	mObjectIDs.push_back(id);
 }
 
 BOOL LLFloaterScriptQueue::start()
@@ -163,7 +162,7 @@ BOOL LLFloaterScriptQueue::start()
 
 	LLStringUtil::format_map_t args;
 	args["[START]"] = mStartString;
-	args["[COUNT]"] = llformat ("%d", mObjectIDs.count());
+	args["[COUNT]"] = llformat ("%d", mObjectIDs.size());
 	buffer = getString ("Starting", args);
 	
 	getChild<LLScrollListCtrl>("queue output")->addSimpleElement(buffer, ADD_BOTTOM);
@@ -173,18 +172,18 @@ BOOL LLFloaterScriptQueue::start()
 
 BOOL LLFloaterScriptQueue::isDone() const
 {
-	return (mCurrentObjectID.isNull() && (mObjectIDs.count() == 0));
+	return (mCurrentObjectID.isNull() && (mObjectIDs.size() == 0));
 }
 
 // go to the next object. If no objects left, it falls out silently
 // and waits to be killed by the window being closed.
 BOOL LLFloaterScriptQueue::nextObject()
 {
-	S32 count;
+	U32 count;
 	BOOL successful_start = FALSE;
 	do
 	{
-		count = mObjectIDs.count();
+		count = mObjectIDs.size();
 		llinfos << "LLFloaterScriptQueue::nextObject() - " << count
 				<< " objects left to process." << llendl;
 		mCurrentObjectID.setNull();
@@ -195,7 +194,7 @@ BOOL LLFloaterScriptQueue::nextObject()
 		llinfos << "LLFloaterScriptQueue::nextObject() "
 				<< (successful_start ? "successful" : "unsuccessful")
 				<< llendl; 
-	} while((mObjectIDs.count() > 0) && !successful_start);
+	} while((mObjectIDs.size() > 0) && !successful_start);
 	if(isDone() && !mDone)
 	{
 		mDone = true;
@@ -212,13 +211,13 @@ BOOL LLFloaterScriptQueue::popNext()
 	// get the first element off of the container, and attempt to get
 	// the inventory.
 	BOOL rv = FALSE;
-	S32 count = mObjectIDs.count();
+	S32 count = mObjectIDs.size();
 	if(mCurrentObjectID.isNull() && (count > 0))
 	{
-		mCurrentObjectID = mObjectIDs.get(0);
+		mCurrentObjectID = mObjectIDs.at(0);
 		llinfos << "LLFloaterScriptQueue::popNext() - mCurrentID: "
 				<< mCurrentObjectID << llendl;
-		mObjectIDs.remove(0);
+		mObjectIDs.erase(mObjectIDs.begin());
 		LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID);
 		if(obj)
 		{
@@ -306,7 +305,7 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
 				item->getPermissions().allowCopyBy(gAgent.getID(), gAgent.getGroupID()) )
 			{
 				LLPointer<LLViewerInventoryItem> script = new LLViewerInventoryItem(item);
-				mCurrentScripts.put(script);
+				mCurrentScripts.push_back(script);
 				asset_item_map.insert(std::make_pair(item->getAssetUUID(), item));
 			}
 		}
@@ -388,37 +387,7 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 			}
 			else
 			{
-				// It's now in the file, now compile it.
-				buffer = LLTrans::getString("CompileQueueDownloadedCompiling") + (": ") + data->mScriptName;
-
-				// Write script to local file for compilation.
-				LLFILE *fp = LLFile::fopen(filename, "wb");	 /*Flawfinder: ignore*/
-				if (fp)
-				{
-					const S32 buf_size = 65536;
-					U8 copy_buf[buf_size];
-					
-					while (file.read(copy_buf, buf_size)) 	 /*Flawfinder: ignore*/
-					{
-						if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1)
-						{
-							// return a bad file error if we can't write the whole thing
-							status = LL_ERR_CANNOT_OPEN_FILE;
-						}
-					}
-
-					fclose(fp);
-				}
-				else
-				{
-					llerrs << "Unable to find object to compile" << llendl;
-				}
-
-				// TODO: babbage: No compile if no cap.
-				queue->compile(filename, data->mItemId);
-					
-				// Delete it after we're done compiling?
-				LLFile::remove(filename);
+				buffer = LLTrans::getString("CompileQueueServiceUnavailable") + (": ") + data->mScriptName;
 			}
 		}
 	}
@@ -455,138 +424,6 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 	delete data;
 }
 
-// static
-void LLFloaterCompileQueue::onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
-{
-	llinfos << "LLFloaterCompileQueue::onSaveTextComplete()" << llendl;
-	if (status)
-	{
-		llwarns << "Unable to save text for script." << llendl;
-		LLSD args;
-		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
-		LLNotificationsUtil::add("CompileQueueSaveText", args);
-	}
-}
-
-// static
-void LLFloaterCompileQueue::onSaveBytecodeComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
-{
-	llinfos << "LLFloaterCompileQueue::onSaveBytecodeComplete()" << llendl;
-	LLCompileQueueData* data = (LLCompileQueueData*)user_data;
-	LLFloaterCompileQueue* queue = LLFloaterReg::findTypedInstance<LLFloaterCompileQueue>("compile_queue", data->mQueueID);
-	if(queue && (0 == status) && data)
-	{
-		queue->saveItemByItemID(data->mItemId);
-		queue->removeItemByItemID(data->mItemId);
-	}
-	else
-	{
-		llwarns << "Unable to save bytecode for script." << llendl;
-		LLSD args;
-		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
-		LLNotificationsUtil::add("CompileQueueSaveBytecode", args);
-	}
-	delete data;
-	data = NULL;
-}
-
-// compile the file given and save it out.
-void LLFloaterCompileQueue::compile(const std::string& filename,
-									const LLUUID& item_id)
-{
-	LLUUID new_asset_id;
-	LLTransactionID tid;
-	tid.generate();
-	new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-	
-	std::string uuid_string;
-	new_asset_id.toString(uuid_string);
-	std::string dst_filename;
-	dst_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".lso";
-	std::string err_filename;
-	err_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_string) + ".out";
-
-	gAssetStorage->storeAssetData(filename, tid,
-								  LLAssetType::AT_LSL_TEXT,
-								  &onSaveTextComplete, NULL, FALSE);
-
-	const BOOL compile_to_mono = FALSE;
-	if(!lscript_compile(filename.c_str(), dst_filename.c_str(),
-						err_filename.c_str(), compile_to_mono,
-						uuid_string.c_str(), gAgent.isGodlike()))
-	{
-		llwarns << "compile failed" << llendl;
-		removeItemByItemID(item_id);
-	}
-	else
-	{
-		llinfos << "compile successful." << llendl;
-		
-		// Save LSL bytecode
-		LLCompileQueueData* data = new LLCompileQueueData(getKey().asUUID(), item_id);
-		gAssetStorage->storeAssetData(dst_filename, new_asset_id,
-									LLAssetType::AT_LSL_BYTECODE,
-									&LLFloaterCompileQueue::onSaveBytecodeComplete,
-									(void*)data, FALSE);
-	}
-}
-
-void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id)
-{
-	llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl;
-	for(S32 i = 0; i < mCurrentScripts.count(); )
-	{
-		if(asset_id == mCurrentScripts.get(i)->getUUID())
-		{
-			mCurrentScripts.remove(i);
-		}
-		else
-		{
-			++i;
-		}
-	}
-	if(mCurrentScripts.count() == 0)
-	{
-		nextObject();
-	}
-}
-
-const LLInventoryItem* LLFloaterCompileQueue::findItemByItemID(const LLUUID& asset_id) const
-{
-	LLInventoryItem* result = NULL;
-	S32 count = mCurrentScripts.count();
-	for(S32 i = 0; i < count; ++i)
-	{
-		if(asset_id == mCurrentScripts.get(i)->getUUID())
-		{
-			result = mCurrentScripts.get(i);
-		}
-	}
-	return result;
-}
-
-void LLFloaterCompileQueue::saveItemByItemID(const LLUUID& asset_id)
-{
-	llinfos << "LLFloaterCompileQueue::saveItemByAssetID()" << llendl;
-	LLViewerObject* viewer_object = gObjectList.findObject(mCurrentObjectID);
-	if(viewer_object)
-	{
-		S32 count = mCurrentScripts.count();
-		for(S32 i = 0; i < count; ++i)
-		{
-			if(asset_id == mCurrentScripts.get(i)->getUUID())
-			{
-				// *FIX: this auto-resets active to TRUE. That might
-				// be a bad idea.
-				viewer_object->saveScript(mCurrentScripts.get(i), TRUE, false);
-			}
-		}
-	}
-	else
-	{
-		llwarns << "Unable to finish save!" << llendl;
-	}
-}
 
 ///----------------------------------------------------------------------------
 /// Class LLFloaterResetQueue
@@ -608,8 +445,7 @@ void LLFloaterResetQueue::handleInventory(LLViewerObject* viewer_obj,
 {
 	// find all of the lsl, leaving off duplicates. We'll remove
 	// all matching asset uuids on compilation success.
-	LLDynamicArray<const char*> names;
-	
+
 	LLInventoryObject::object_list_t::const_iterator it = inv->begin();
 	LLInventoryObject::object_list_t::const_iterator end = inv->end();
 	for ( ; it != end; ++it)
@@ -660,8 +496,6 @@ void LLFloaterRunQueue::handleInventory(LLViewerObject* viewer_obj,
 {
 	// find all of the lsl, leaving off duplicates. We'll remove
 	// all matching asset uuids on compilation success.
-	LLDynamicArray<const char*> names;
-	
 	LLInventoryObject::object_list_t::const_iterator it = inv->begin();
 	LLInventoryObject::object_list_t::const_iterator end = inv->end();
 	for ( ; it != end; ++it)
@@ -710,13 +544,31 @@ LLFloaterNotRunQueue::~LLFloaterNotRunQueue()
 { 
 }
 
+void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id)
+{
+	llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl;
+	for(S32 i = 0; i < mCurrentScripts.size(); )
+	{
+		if(asset_id == mCurrentScripts.at(i)->getUUID())
+		{
+			vector_replace_with_last(mCurrentScripts, mCurrentScripts.begin() + i);
+		}
+		else
+		{
+			++i;
+		}
+	}
+	if(mCurrentScripts.empty())
+	{
+		nextObject();
+	}
+}
+
 void LLFloaterNotRunQueue::handleInventory(LLViewerObject* viewer_obj,
 										  LLInventoryObject::object_list_t* inv)
 {
 	// find all of the lsl, leaving off duplicates. We'll remove
 	// all matching asset uuids on compilation success.
-	LLDynamicArray<const char*> names;
-	
 	LLInventoryObject::object_list_t::const_iterator it = inv->begin();
 	LLInventoryObject::object_list_t::const_iterator end = inv->end();
 	for ( ; it != end; ++it)
diff --git a/indra/newview/llcompilequeue.h b/indra/newview/llcompilequeue.h
index 4ddab29d00..28f4625de8 100755
--- a/indra/newview/llcompilequeue.h
+++ b/indra/newview/llcompilequeue.h
@@ -27,11 +27,9 @@
 #ifndef LL_LLCOMPILEQUEUE_H
 #define LL_LLCOMPILEQUEUE_H
 
-#include "lldarray.h"
 #include "llinventory.h"
 #include "llviewerobject.h"
 #include "llvoinventorylistener.h"
-#include "llmap.h"
 #include "lluuid.h"
 
 #include "llfloater.h"
@@ -96,7 +94,7 @@ protected:
 	LLButton* mCloseBtn;
 
 	// Object Queue
-	LLDynamicArray<LLUUID> mObjectIDs;
+	std::vector<LLUUID> mObjectIDs;
 	LLUUID mCurrentObjectID;
 	bool mDone;
 
@@ -146,24 +144,6 @@ protected:
 								LLAssetType::EType type,
 								void* user_data, S32 status, LLExtStat ext_status);
 
-	static void onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status);
-
-	static void onSaveBytecodeComplete(const LLUUID& asset_id,
-									   void* user_data,
-									   S32 status, LLExtStat ext_status);
-
-	// compile the file given and save it out.
-	void compile(const std::string& filename, const LLUUID& asset_id);
-	
-	// remove any object in mScriptScripts with the matching uuid.
-	void removeItemByAssetID(const LLUUID& asset_id);
-
-	// save the items indicated by the item id.
-	void saveItemByItemID(const LLUUID& item_id);
-
-	// find InventoryItem given item id.
-	const LLInventoryItem* findItemByItemID(const LLUUID& item_id) const;
-	
 protected:
 	LLViewerInventoryItem::item_array_t mCurrentScripts;
 
diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index 7883e4cb89..7ecc572a8a 100755
--- a/indra/newview/llconversationlog.cpp
+++ b/indra/newview/llconversationlog.cpp
@@ -37,21 +37,16 @@
 
 const int CONVERSATION_LIFETIME = 30; // lifetime of LLConversation is 30 days by spec
 
-struct ConversationParams
-{
-	ConversationParams(time_t time)
-	:	mTime(time),
-		mTimestamp(LLConversation::createTimestamp(time))
-	{}
-
-	time_t		mTime;
-	std::string	mTimestamp;
-	SessionType	mConversationType;
-	std::string	mConversationName;
-	std::string	mHistoryFileName;
-	LLUUID		mSessionID;
-	LLUUID		mParticipantID;
-	bool		mHasOfflineIMs;
+struct ConversationParams : public LLInitParam::Block<ConversationParams>
+{
+	Mandatory<LLUnit<U64, LLUnits::Seconds> >	time;
+	Mandatory<std::string>						timestamp;
+	Mandatory<SessionType>						conversation_type;
+	Mandatory<std::string>						conversation_name,
+												history_filename;
+	Mandatory<LLUUID>							session_id,
+												participant_id;
+	Mandatory<bool>								has_offline_ims;
 };
 
 /************************************************************************/
@@ -59,14 +54,14 @@ struct ConversationParams
 /************************************************************************/
 
 LLConversation::LLConversation(const ConversationParams& params)
-:	mTime(params.mTime),
-	mTimestamp(params.mTimestamp),
-	mConversationType(params.mConversationType),
-	mConversationName(params.mConversationName),
-	mHistoryFileName(params.mHistoryFileName),
-	mSessionID(params.mSessionID),
-	mParticipantID(params.mParticipantID),
-	mHasOfflineIMs(params.mHasOfflineIMs)
+:	mTime(params.time),
+	mTimestamp(params.timestamp),
+	mConversationType(params.conversation_type),
+	mConversationName(params.conversation_name),
+	mHistoryFileName(params.history_filename),
+	mSessionID(params.session_id),
+	mParticipantID(params.participant_id),
+	mHasOfflineIMs(params.has_offline_ims)
 {
 	setListenIMFloaterOpened();
 }
@@ -118,11 +113,11 @@ void LLConversation::onIMFloaterShown(const LLUUID& session_id)
 }
 
 // static
-const std::string LLConversation::createTimestamp(const time_t& utc_time)
+const std::string LLConversation::createTimestamp(const LLUnit<U64, LLUnits::Seconds>& utc_time)
 {
 	std::string timeStr;
 	LLSD substitution;
-	substitution["datetime"] = (S32) utc_time;
+	substitution["datetime"] = (S32)utc_time.value();
 
 	timeStr = "["+LLTrans::getString ("TimeMonth")+"]/["
 				 +LLTrans::getString ("TimeDay")+"]/["
@@ -137,8 +132,8 @@ const std::string LLConversation::createTimestamp(const time_t& utc_time)
 
 bool LLConversation::isOlderThan(U32 days) const
 {
-	time_t now = time_corrected();
-	U32 age = (U32)((now - mTime) / SEC_PER_DAY); // age of conversation in days
+	LLUnit<U64, LLUnits::Seconds> now = time_corrected();
+	LLUnit<U32, LLUnits::Days> age = now - mTime;
 
 	return age > days;
 }
@@ -485,7 +480,7 @@ bool LLConversationLog::saveToFile(const std::string& filename)
 		// [1343222639] 2 0 0 Ad-hoc Conference| c3g67c89-c479-4c97-b21d-32869bcfe8rc 68f1c33e-4135-3e3e-a897-8c9b23115c09 Ad-hoc Conference hash597394a0-9982-766d-27b8-c75560213b9a|
 
 		fprintf(fp, "[%lld] %d %d %d %s| %s %s %s|\n",
-				(S64)conv_it->getTime(),
+				(S64)conv_it->getTime().value(),
 				(S32)conv_it->getConversationType(),
 				(S32)0,
 				(S32)conv_it->hasOfflineMessages(),
@@ -539,13 +534,14 @@ bool LLConversationLog::loadFromFile(const std::string& filename)
 				conv_id_buffer,
 				history_file_name);
 
-		ConversationParams params((time_t)time);
-		params.mConversationType = (SessionType)stype;
-		params.mHasOfflineIMs = has_offline_ims;
-		params.mConversationName = std::string(conv_name_buffer);
-		params.mParticipantID = LLUUID(part_id_buffer);
-		params.mSessionID = LLUUID(conv_id_buffer);
-		params.mHistoryFileName = std::string(history_file_name);
+		ConversationParams params;
+		params.time(time)
+			.conversation_type((SessionType)stype)
+			.has_offline_ims(has_offline_ims)
+			.conversation_name(conv_name_buffer)
+			.participant_id(LLUUID(part_id_buffer))
+			.session_id(LLUUID(conv_id_buffer))
+			.history_filename(history_file_name);
 
 		LLConversation conversation(params);
 
diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h
index 265b1f0ef0..5d94cb6497 100755
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -55,7 +55,8 @@ public:
 	const LLUUID&		getSessionID()			const	{ return mSessionID; }
 	const LLUUID&		getParticipantID()		const	{ return mParticipantID; }
 	const std::string&	getTimestamp()			const	{ return mTimestamp; }
-	const time_t&		getTime()				const	{ return mTime; }
+	const LLUnit<U64, LLUnits::Seconds>&
+						getTime()				const	{ return mTime; }
 	bool				hasOfflineMessages()	const	{ return mHasOfflineIMs; }
 
 	void setConversationName(std::string conv_name) { mConversationName = conv_name; }
@@ -75,7 +76,7 @@ public:
 	/*
 	 * returns string representation(in form of: mm/dd/yyyy hh:mm) of time when conversation was started
 	 */
-	static const std::string createTimestamp(const time_t& utc_time);
+	static const std::string createTimestamp(const LLUnit<U64, LLUnits::Seconds>& utc_time);
 
 private:
 
@@ -87,7 +88,7 @@ private:
 
 	boost::signals2::connection mIMFloaterShowedConnection;
 
-	time_t			mTime; // last interaction time
+	LLUnit<U64, LLUnits::Seconds> mTime; // last interaction time
 	SessionType		mConversationType;
 	std::string		mConversationName;
 	std::string		mHistoryFileName;
diff --git a/indra/newview/llconversationloglist.cpp b/indra/newview/llconversationloglist.cpp
index 5ab108b39f..bd5e0b8f88 100755
--- a/indra/newview/llconversationloglist.cpp
+++ b/indra/newview/llconversationloglist.cpp
@@ -490,7 +490,7 @@ bool LLConversationLogListItemComparator::compare(const LLPanel* item1, const LL
 
 	if (!conversation_item1 || !conversation_item2)
 	{
-		llerror("conversation_item1 and conversation_item2 cannot be null", 0);
+		LL_ERRS() << "conversation_item1 and conversation_item2 cannot be null" << LL_ENDL;
 		return true;
 	}
 
@@ -518,8 +518,8 @@ bool LLConversationLogListNameComparator::doCompare(const LLConversationLogListI
 
 bool LLConversationLogListDateComparator::doCompare(const LLConversationLogListItem* conversation1, const LLConversationLogListItem* conversation2) const
 {
-	time_t date1 = conversation1->getConversation()->getTime();
-	time_t date2 = conversation2->getConversation()->getTime();
+	LLUnit<U64, LLUnits::Seconds> date1 = conversation1->getConversation()->getTime();
+	LLUnit<U64, LLUnits::Seconds> date2 = conversation2->getConversation()->getTime();
 	const LLUUID& id1 = conversation1->getConversation()->getParticipantID();
 	const LLUUID& id2 = conversation2->getConversation()->getParticipantID();
 
diff --git a/indra/newview/lldebugmessagebox.h b/indra/newview/lldebugmessagebox.h
index 211af9e074..87a0910662 100755
--- a/indra/newview/lldebugmessagebox.h
+++ b/indra/newview/lldebugmessagebox.h
@@ -28,7 +28,6 @@
 #ifndef LL_LLDEBUGMESSAGEBOX_H
 #define LL_LLDEBUGMESSAGEBOX_H
 
-#include "lldarray.h"
 #include "llfloater.h"
 #include "v3math.h"
 #include "lltextbox.h"
diff --git a/indra/newview/lldebugview.cpp b/indra/newview/lldebugview.cpp
index 63dd59b020..98c1685feb 100755
--- a/indra/newview/lldebugview.cpp
+++ b/indra/newview/lldebugview.cpp
@@ -33,7 +33,6 @@
 #include "llconsole.h"
 #include "lltextureview.h"
 #include "llresmgr.h"
-#include "imageids.h"
 #include "llviewercontrol.h"
 #include "llviewerwindow.h"
 #include "llappviewer.h"
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 628f7f7bfb..c59ce04646 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -79,7 +79,7 @@ LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 // static
 U32 LLDrawable::sNumZombieDrawables = 0;
 F32 LLDrawable::sCurPixelAngle = 0;
-LLDynamicArray<LLPointer<LLDrawable>, 32 > LLDrawable::sDeadList;
+std::vector<LLPointer<LLDrawable> > LLDrawable::sDeadList;
 
 #define FORCE_INVISIBLE_AREA 16.f
 
@@ -196,7 +196,7 @@ void LLDrawable::markDead()
 
 	// We're dead.  Free up all of our references to other objects
 	cleanupReferences();
-//	sDeadList.put(this);
+//	sDeadList.push_back(this);
 }
 
 LLVOVolume* LLDrawable::getVOVolume() const
@@ -277,7 +277,7 @@ void LLDrawable::cleanupDeadDrawables()
 {
 	/*
 	S32 i;
-	for (i = 0; i < sDeadList.count(); i++)
+	for (i = 0; i < sDeadList.size(); i++)
 	{
 		if (sDeadList[i]->getNumRefs() > 1)
 		{
@@ -286,7 +286,7 @@ void LLDrawable::cleanupDeadDrawables()
 		}
 	}
 	*/
-	sDeadList.reset();
+	sDeadList.clear();
 }
 
 S32 LLDrawable::findReferences(LLDrawable *drawablep)
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index b7c5aeb5a8..08fbd7d211 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -38,7 +38,6 @@
 #include "llvector4a.h"
 #include "llquaternion.h"
 #include "xform.h"
-#include "lldarray.h"
 #include "llviewerobject.h"
 #include "llrect.h"
 #include "llappviewer.h" // for gFrameTimeSeconds
@@ -310,7 +309,7 @@ private:
 	LLVector3		mCurrentScale;
 	
 	static U32 sNumZombieDrawables;
-	static LLDynamicArray<LLPointer<LLDrawable>, 32> sDeadList;
+	static std::vector<LLPointer<LLDrawable> > sDeadList;
 } LL_ALIGN_POSTFIX(16);
 
 
diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp
index 7f7d9f65c6..edc368c29e 100755
--- a/indra/newview/lldrawpoolsky.cpp
+++ b/indra/newview/lldrawpoolsky.cpp
@@ -28,8 +28,6 @@
 
 #include "lldrawpoolsky.h"
 
-#include "imageids.h"
-
 #include "llagent.h"
 #include "lldrawable.h"
 #include "llface.h"
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index 6d90667194..fc531a0c74 100755
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -727,7 +727,7 @@ void LLFavoritesBarCtrl::updateButtons()
 	int first_changed_item_index = 0;
 	int rightest_point = getRect().mRight - mMoreTextBox->getRect().getWidth();
 	//lets find first changed button
-	while (child_it != childs->end() && first_changed_item_index < mItems.count())
+	while (child_it != childs->end() && first_changed_item_index < mItems.size())
 	{
 		LLFavoriteLandmarkButton* button = dynamic_cast<LLFavoriteLandmarkButton*> (*child_it);
 		if (button)
@@ -749,7 +749,7 @@ void LLFavoritesBarCtrl::updateButtons()
 	}
 	// now first_changed_item_index should contains a number of button that need to change
 
-	if (first_changed_item_index <= mItems.count())
+	if (first_changed_item_index <= mItems.size())
 	{
 		// Rebuild the buttons only
 		// child_list_t is a linked list, so safe to erase from the middle if we pre-increment the iterator
@@ -787,7 +787,7 @@ void LLFavoritesBarCtrl::updateButtons()
 		//last_right_edge is saving coordinates
 		LLButton* last_new_button = NULL;
 		int j = first_changed_item_index;
-		for (; j < mItems.count(); j++)
+		for (; j < mItems.size(); j++)
 		{
 			last_new_button = createButton(mItems[j], button_params, last_right_edge);
 			if (!last_new_button)
@@ -801,7 +801,7 @@ void LLFavoritesBarCtrl::updateButtons()
 		}
 		mFirstDropDownItem = j;
 		// Chevron button
-		if (mFirstDropDownItem < mItems.count())
+		if (mFirstDropDownItem < mItems.size())
 		{
 			// if updateButton had been called it means:
 			//or there are some new favorites, or width had been changed
@@ -963,9 +963,9 @@ void LLFavoritesBarCtrl::updateMenuItems(LLToggleableMenu* menu)
 
 	U32 widest_item = 0;
 
-	for (S32 i = mFirstDropDownItem; i < mItems.count(); i++)
+	for (S32 i = mFirstDropDownItem; i < mItems.size(); i++)
 	{
-		LLViewerInventoryItem* item = mItems.get(i);
+		LLViewerInventoryItem* item = mItems.at(i);
 		const std::string& item_name = item->getName();
 
 		LLFavoriteLandmarkMenuItem::Params item_params;
@@ -1221,12 +1221,12 @@ BOOL LLFavoritesBarCtrl::isClipboardPasteable() const
 		return FALSE;
 	}
 
-	LLDynamicArray<LLUUID> objects;
+	std::vector<LLUUID> objects;
 	LLClipboard::instance().pasteFromClipboard(objects);
-	S32 count = objects.count();
+	S32 count = objects.size();
 	for(S32 i = 0; i < count; i++)
 	{
-		const LLUUID &item_id = objects.get(i);
+		const LLUUID &item_id = objects.at(i);
 
 		// Can't paste folders
 		const LLInventoryCategory *cat = gInventory.getCategory(item_id);
@@ -1250,13 +1250,13 @@ void LLFavoritesBarCtrl::pasteFromClipboard() const
 	if(model && isClipboardPasteable())
 	{
 		LLInventoryItem* item = NULL;
-		LLDynamicArray<LLUUID> objects;
+		std::vector<LLUUID> objects;
 		LLClipboard::instance().pasteFromClipboard(objects);
-		S32 count = objects.count();
+		S32 count = objects.size();
 		LLUUID parent_id(mFavoriteFolderId);
 		for(S32 i = 0; i < count; i++)
 		{
-			item = model->getItem(objects.get(i));
+			item = model->getItem(objects.at(i));
 			if (item)
 			{
 				copy_inventory_item(
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index ddb9d3bc43..c05f27d2ee 100755
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -36,7 +36,6 @@
 
 #include "llsys.h"
 #include "llgl.h"
-#include "llsecondlifeurls.h"
 
 #include "llappviewer.h"
 #include "llhttpclient.h"
diff --git a/indra/newview/llfirstuse.cpp b/indra/newview/llfirstuse.cpp
index e2850f5181..2e1afc68b4 100755
--- a/indra/newview/llfirstuse.cpp
+++ b/indra/newview/llfirstuse.cpp
@@ -96,6 +96,11 @@ void LLFirstUse::newInventory(bool enable)
 	// firstUseNotification("FirstInventoryOffer", enable, "HintInventory", LLSD(), LLSD().with("target", "inventory_btn").with("direction", "left"));
 }
 
+// first clean starts at 3 AM
+const S32 SANDBOX_FIRST_CLEAN_HOUR = 3;
+// clean every <n> hours
+const S32 SANDBOX_CLEAN_FREQ = 12;
+
 // static
 void LLFirstUse::useSandbox()
 {
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 93502daac7..229a55ad23 100755
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -34,7 +34,6 @@
 // Viewer includes
 #include "llagent.h"
 #include "llappviewer.h" 
-#include "llsecondlifeurls.h"
 #include "llvoiceclient.h"
 #include "lluictrlfactory.h"
 #include "llviewertexteditor.h"
diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp
index 39b6e465f3..086da158ad 100755
--- a/indra/newview/llfloaterbulkpermission.cpp
+++ b/indra/newview/llfloaterbulkpermission.cpp
@@ -36,7 +36,6 @@
 #include "llviewerobject.h"
 #include "llviewerobjectlist.h"
 #include "llviewerregion.h"
-#include "lscript_rt_interface.h"
 #include "llviewercontrol.h"
 #include "llviewerinventory.h"
 #include "llviewerobject.h"
@@ -75,17 +74,17 @@ void LLFloaterBulkPermission::doApply()
 	class ModifiableGatherer : public LLSelectedNodeFunctor
 	{
 	public:
-		ModifiableGatherer(LLDynamicArray<LLUUID>& q) : mQueue(q) {}
+		ModifiableGatherer(std::vector<LLUUID>& q) : mQueue(q) { mQueue.reserve(32); }
 		virtual bool apply(LLSelectNode* node)
 		{
 			if( node->allowOperationOnNode(PERM_MODIFY, GP_OBJECT_MANIPULATE) )
 			{
-				mQueue.put(node->getObject()->getID());
+				mQueue.push_back(node->getObject()->getID());
 			}
 			return true;
 		}
 	private:
-		LLDynamicArray<LLUUID>& mQueue;
+		std::vector<LLUUID>& mQueue;
 	};
 	LLScrollListCtrl* list = getChild<LLScrollListCtrl>("queue output");
 	list->deleteAllItems();
@@ -169,7 +168,7 @@ void LLFloaterBulkPermission::onCommitCopy()
 
 BOOL LLFloaterBulkPermission::start()
 {
-	// note: number of top-level objects to modify is mObjectIDs.count().
+	// note: number of top-level objects to modify is mObjectIDs.size().
 	getChild<LLScrollListCtrl>("queue output")->setCommentText(getString("start_text"));
 	return nextObject();
 }
@@ -181,7 +180,7 @@ BOOL LLFloaterBulkPermission::nextObject()
 	BOOL successful_start = FALSE;
 	do
 	{
-		count = mObjectIDs.count();
+		count = mObjectIDs.size();
 		//llinfos << "Objects left to process = " << count << llendl;
 		mCurrentObjectID.setNull();
 		if(count > 0)
@@ -189,7 +188,7 @@ BOOL LLFloaterBulkPermission::nextObject()
 			successful_start = popNext();
 			//llinfos << (successful_start ? "successful" : "unsuccessful") << llendl; 
 		}
-	} while((mObjectIDs.count() > 0) && !successful_start);
+	} while((mObjectIDs.size() > 0) && !successful_start);
 
 	if(isDone() && !mDone)
 	{
@@ -205,12 +204,12 @@ BOOL LLFloaterBulkPermission::popNext()
 {
 	// get the head element from the container, and attempt to get its inventory.
 	BOOL rv = FALSE;
-	S32 count = mObjectIDs.count();
+	S32 count = mObjectIDs.size();
 	if(mCurrentObjectID.isNull() && (count > 0))
 	{
-		mCurrentObjectID = mObjectIDs.get(0);
+		mCurrentObjectID = mObjectIDs.at(0);
 		//llinfos << "mCurrentID: " << mCurrentObjectID << llendl;
-		mObjectIDs.remove(0);
+		mObjectIDs.erase(mObjectIDs.begin());
 		LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID);
 		if(obj)
 		{
diff --git a/indra/newview/llfloaterbulkpermission.h b/indra/newview/llfloaterbulkpermission.h
index 7dd05df7ee..88532ed124 100755
--- a/indra/newview/llfloaterbulkpermission.h
+++ b/indra/newview/llfloaterbulkpermission.h
@@ -28,11 +28,9 @@
 #ifndef LL_LLBULKPERMISSION_H
 #define LL_LLBULKPERMISSION_H
 
-#include "lldarray.h"
 #include "llinventory.h"
 #include "llviewerobject.h"
 #include "llvoinventorylistener.h"
-#include "llmap.h"
 #include "lluuid.h"
 
 #include "llfloater.h"
@@ -78,7 +76,7 @@ private:
 	void onUncheckAll() { doCheckUncheckAll(FALSE); }
 	
 	// returns true if this is done
-	BOOL isDone() const { return (mCurrentObjectID.isNull() || (mObjectIDs.count() == 0)); }
+	BOOL isDone() const { return (mCurrentObjectID.isNull() || (mObjectIDs.size() == 0)); }
 
 	//Read the settings and Apply the permissions
 	void doApply();
@@ -90,7 +88,7 @@ private:
 	LLButton* mCloseBtn;
 
 	// Object Queue
-	LLDynamicArray<LLUUID> mObjectIDs;
+	std::vector<LLUUID> mObjectIDs;
 	LLUUID mCurrentObjectID;
 	BOOL mDone;
 
diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp
index 6aebe85e7a..9425f5645e 100755
--- a/indra/newview/llfloatercolorpicker.cpp
+++ b/indra/newview/llfloatercolorpicker.cpp
@@ -162,12 +162,7 @@ void LLFloaterColorPicker::createUI ()
 	// create palette
 	for ( S32 each = 0; each < numPaletteColumns * numPaletteRows; ++each )
 	{
-		std::ostringstream codec;
-		codec << "ColorPaletteEntry" << std::setfill ( '0' ) << std::setw ( 2 ) << each + 1;
-
-		// argh!
-		const std::string s ( codec.str () );
-		mPalette.push_back ( new LLColor4 ( LLUIColorTable::instance().getColor ( s )  ) );
+		mPalette.push_back(new LLColor4(LLUIColorTable::instance().getColor(llformat("ColorPaletteEntry%02d", each + 1))));
 	}
 }
 
diff --git a/indra/newview/llfloatercolorpicker.h b/indra/newview/llfloatercolorpicker.h
index bab0617712..d4d22b643a 100755
--- a/indra/newview/llfloatercolorpicker.h
+++ b/indra/newview/llfloatercolorpicker.h
@@ -33,7 +33,6 @@
 #include "llpointer.h"
 #include "llcolorswatch.h"
 #include "llspinctrl.h"
-#include "lltextureentry.h"
 
 class LLButton;
 class LLLineEditor;
@@ -121,7 +120,7 @@ class LLFloaterColorPicker
 			   void onClickPipette ( );
 		static void onTextCommit ( LLUICtrl* ctrl, void* data );
 		static void onImmediateCheck ( LLUICtrl* ctrl, void* data );
-			   void onColorSelect( const LLTextureEntry& te );
+			   void onColorSelect( const class LLTextureEntry& te );
 	private:
 		// draws color selection palette
 		void drawPalette ();
@@ -171,7 +170,7 @@ class LLFloaterColorPicker
 		const S32 mPaletteRegionHeight;
 
 		// image used to compose color grid
-		LLPointer<LLViewerTexture> mRGBImage;
+		LLPointer<class LLViewerTexture> mRGBImage;
 
 		// current swatch in use
 		LLColorSwatchCtrl* mSwatch;
diff --git a/indra/newview/llfloaterevent.cpp b/indra/newview/llfloaterevent.cpp
index a6dafda3e6..3e303e0932 100755
--- a/indra/newview/llfloaterevent.cpp
+++ b/indra/newview/llfloaterevent.cpp
@@ -45,7 +45,6 @@
 #include "llmediactrl.h"
 #include "llfloaterworldmap.h"
 #include "llinventorymodel.h"
-#include "llsecondlifeurls.h"
 #include "llslurl.h"
 #include "lltextbox.h"
 #include "lltexteditor.h"
diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp
index 56051ff684..1452d53265 100755
--- a/indra/newview/llfloatergesture.cpp
+++ b/indra/newview/llfloatergesture.cpp
@@ -400,9 +400,9 @@ bool LLFloaterGesture::isActionEnabled(const LLSD& command)
 		if(!LLClipboard::instance().hasContents())
 			return false;
 
-		LLDynamicArray<LLUUID> ids;
+		std::vector<LLUUID> ids;
 		LLClipboard::instance().pasteFromClipboard(ids);
-		for(LLDynamicArray<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
+		for(std::vector<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
 		{
 			LLInventoryItem* item = gInventory.getItem(*it);
 			
@@ -514,7 +514,7 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command)
 	}
 	else if ("paste" == command_name)
 	{
-		LLDynamicArray<LLUUID> ids;
+		std::vector<LLUUID> ids;
 		LLClipboard::instance().pasteFromClipboard(ids);
 		if(ids.empty() || !gInventory.isCategoryComplete(mGestureFolderID))
 			return;
@@ -522,7 +522,7 @@ void LLFloaterGesture::onCopyPasteAction(const LLSD& command)
 		llassert(gesture_dir);
 		LLPointer<GestureCopiedCallback> cb = new GestureCopiedCallback(this);
 
-		for(LLDynamicArray<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
+		for(std::vector<LLUUID>::iterator it = ids.begin(); it != ids.end(); it++)
 		{
 			LLInventoryItem* item = gInventory.getItem(*it);
 			if(gesture_dir && item && item->getInventoryType() == LLInventoryType::IT_GESTURE)
diff --git a/indra/newview/llfloatergroups.cpp b/indra/newview/llfloatergroups.cpp
index d84364a68a..dbe7fee108 100755
--- a/indra/newview/llfloatergroups.cpp
+++ b/indra/newview/llfloatergroups.cpp
@@ -171,7 +171,7 @@ void LLPanelGroups::reset()
 	{
 		group_list->operateOnAll(LLCtrlListInterface::OP_DELETE);
 	}
-	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count()));
+	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.size()));
 	getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",gMaxAgentGroups));
 
 	init_group_list(getChild<LLScrollListCtrl>("group list"), gAgent.getGroupID());
@@ -182,7 +182,7 @@ BOOL LLPanelGroups::postBuild()
 {
 	childSetCommitCallback("group list", onGroupList, this);
 
-	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.count()));
+	getChild<LLUICtrl>("groupcount")->setTextArg("[COUNT]", llformat("%d",gAgent.mGroups.size()));
 	getChild<LLUICtrl>("groupcount")->setTextArg("[MAX]", llformat("%d",gMaxAgentGroups));
 
 	LLScrollListCtrl *list = getChild<LLScrollListCtrl>("group list");
@@ -341,7 +341,7 @@ void LLPanelGroups::onGroupList(LLUICtrl* ctrl, void* userdata)
 
 void init_group_list(LLScrollListCtrl* group_list, const LLUUID& highlight_id, U64 powers_mask)
 {
-	S32 count = gAgent.mGroups.count();
+	S32 count = gAgent.mGroups.size();
 	LLUUID id;
 	if (!group_list) return;
 
@@ -349,8 +349,8 @@ void init_group_list(LLScrollListCtrl* group_list, const LLUUID& highlight_id, U
 
 	for(S32 i = 0; i < count; ++i)
 	{
-		id = gAgent.mGroups.get(i).mID;
-		LLGroupData* group_datap = &gAgent.mGroups.get(i);
+		id = gAgent.mGroups.at(i).mID;
+		LLGroupData* group_datap = &gAgent.mGroups.at(i);
 		if ((powers_mask == GP_ALL_POWERS) || ((group_datap->mPowers & powers_mask) != 0))
 		{
 			std::string style = "NORMAL";
diff --git a/indra/newview/llfloaterlandholdings.cpp b/indra/newview/llfloaterlandholdings.cpp
index 98e9b74278..ea94dcd7b6 100755
--- a/indra/newview/llfloaterlandholdings.cpp
+++ b/indra/newview/llfloaterlandholdings.cpp
@@ -72,19 +72,19 @@ BOOL LLFloaterLandHoldings::postBuild()
 	grant_list->sortByColumnIndex(0, TRUE);
 	grant_list->setDoubleClickCallback(onGrantList, this);
 
-	S32 count = gAgent.mGroups.count();
+	S32 count = gAgent.mGroups.size();
 	for(S32 i = 0; i < count; ++i)
 	{
-		LLUUID id(gAgent.mGroups.get(i).mID);
+		LLUUID id(gAgent.mGroups.at(i).mID);
 
 		LLSD element;
 		element["id"] = id;
 		element["columns"][0]["column"] = "group";
-		element["columns"][0]["value"] = gAgent.mGroups.get(i).mName;
+		element["columns"][0]["value"] = gAgent.mGroups.at(i).mName;
 		element["columns"][0]["font"] = "SANSSERIF";
 
 		LLUIString areastr = getString("area_string");
-		areastr.setArg("[AREA]", llformat("%d", gAgent.mGroups.get(i).mContribution));
+		areastr.setArg("[AREA]", llformat("%d", gAgent.mGroups.at(i).mContribution));
 		element["columns"][1]["column"] = "area";
 		element["columns"][1]["value"] = areastr;
 		element["columns"][1]["font"] = "SANSSERIF";
diff --git a/indra/newview/llfloateroutbox.cpp b/indra/newview/llfloateroutbox.cpp
index 29a3e6ac3a..1e9cf62067 100755
--- a/indra/newview/llfloateroutbox.cpp
+++ b/indra/newview/llfloateroutbox.cpp
@@ -281,7 +281,7 @@ void LLFloaterOutbox::setStatusString(const std::string& statusString)
 
 void LLFloaterOutbox::updateFolderCount()
 {
-	S32 item_count = 0;
+	U32 item_count = 0;
 
 	if (mOutboxId.notNull())
 	{
@@ -289,7 +289,7 @@ void LLFloaterOutbox::updateFolderCount()
 		LLInventoryModel::item_array_t * items;
 		gInventory.getDirectDescendentsOf(mOutboxId, cats, items);
 
-		item_count = cats->count() + items->count();
+		item_count = cats->size() + items->size();
 	}
 	
 	mOutboxItemCount = item_count;
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 55b03986d0..9cb7d95e61 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -37,7 +37,6 @@
 #include "message.h"
 #include "llfloaterautoreplacesettings.h"
 #include "llagent.h"
-#include "llavatarconstants.h"
 #include "llcheckboxctrl.h"
 #include "llcolorswatch.h"
 #include "llcombobox.h"
@@ -113,6 +112,10 @@
 const F32 MAX_USER_FAR_CLIP = 512.f;
 const F32 MIN_USER_FAR_CLIP = 64.f;
 const F32 BANDWIDTH_UPDATER_TIMEOUT = 0.5f;
+char const* const VISIBILITY_DEFAULT = "default";
+char const* const VISIBILITY_HIDDEN = "hidden";
+char const* const VISIBILITY_VISIBLE = "visible";
+char const* const VISIBILITY_INVISIBLE = "invisible";
 
 //control value for middle mouse as talk2push button
 const static std::string MIDDLE_MOUSE_CV = "MiddleMouse";
diff --git a/indra/newview/llfloatertopobjects.h b/indra/newview/llfloatertopobjects.h
index 6edc46cf79..28d2aa58e2 100755
--- a/indra/newview/llfloatertopobjects.h
+++ b/indra/newview/llfloatertopobjects.h
@@ -31,6 +31,22 @@
 
 class LLUICtrl;
 
+// Bits for simulator performance query flags
+enum LAND_STAT_FLAGS
+{
+	STAT_FILTER_BY_PARCEL	= 0x00000001,
+	STAT_FILTER_BY_OWNER	= 0x00000002,
+	STAT_FILTER_BY_OBJECT	= 0x00000004,
+	STAT_FILTER_BY_PARCEL_NAME	= 0x00000008,
+	STAT_REQUEST_LAST_ENTRY	= 0x80000000,
+};
+
+enum LAND_STAT_REPORT_TYPE
+{
+	STAT_REPORT_TOP_SCRIPTS = 0,
+	STAT_REPORT_TOP_COLLIDERS
+};
+
 class LLFloaterTopObjects : public LLFloater
 {
 	friend class LLFloaterReg;
diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp
index 137b5446cf..3f947ce32c 100755
--- a/indra/newview/llfloaterworldmap.cpp
+++ b/indra/newview/llfloaterworldmap.cpp
@@ -570,9 +570,9 @@ void LLFloaterWorldMap::trackLandmark( const LLUUID& landmark_item_id )
 	buildLandmarkIDLists();
 	BOOL found = FALSE;
 	S32 idx;
-	for (idx = 0; idx < mLandmarkItemIDList.count(); idx++)
+	for (idx = 0; idx < mLandmarkItemIDList.size(); idx++)
 	{
-		if ( mLandmarkItemIDList.get(idx) == landmark_item_id)
+		if ( mLandmarkItemIDList.at(idx) == landmark_item_id)
 		{
 			found = TRUE;
 			break;
@@ -581,13 +581,13 @@ void LLFloaterWorldMap::trackLandmark( const LLUUID& landmark_item_id )
 	
 	if (found && iface->setCurrentByID( landmark_item_id ) ) 
 	{
-		LLUUID asset_id = mLandmarkAssetIDList.get( idx );
+		LLUUID asset_id = mLandmarkAssetIDList.at( idx );
 		std::string name;
 		LLComboBox* combo = getChild<LLComboBox>( "landmark combo");
 		if (combo) name = combo->getSimple();
 		mTrackedStatus = LLTracker::TRACKING_LANDMARK;
-		LLTracker::trackLandmark(mLandmarkAssetIDList.get( idx ),	// assetID
-								 mLandmarkItemIDList.get( idx ), // itemID
+		LLTracker::trackLandmark(mLandmarkAssetIDList.at( idx ),	// assetID
+								 mLandmarkItemIDList.at( idx ), // itemID
 								 name);			// name
 		
 		if( asset_id != sHomeID )
@@ -911,15 +911,15 @@ void LLFloaterWorldMap::buildLandmarkIDLists()
 		list->operateOnSelection(LLCtrlListInterface::OP_DELETE);
 	}
 	
-	mLandmarkItemIDList.reset();
-	mLandmarkAssetIDList.reset();
+	mLandmarkItemIDList.clear();
+	mLandmarkAssetIDList.clear();
 	
 	// Get all of the current landmarks
-	mLandmarkAssetIDList.put( LLUUID::null );
-	mLandmarkItemIDList.put( LLUUID::null );
+	mLandmarkAssetIDList.push_back( LLUUID::null );
+	mLandmarkItemIDList.push_back( LLUUID::null );
 	
-	mLandmarkAssetIDList.put( sHomeID );
-	mLandmarkItemIDList.put( sHomeID );
+	mLandmarkAssetIDList.push_back( sHomeID );
+	mLandmarkItemIDList.push_back( sHomeID );
 	
 	LLInventoryModel::cat_array_t cats;
 	LLInventoryModel::item_array_t items;
@@ -932,15 +932,18 @@ void LLFloaterWorldMap::buildLandmarkIDLists()
 	
 	std::sort(items.begin(), items.end(), LLViewerInventoryItem::comparePointers());
 	
-	S32 count = items.count();
+	mLandmarkAssetIDList.reserve(mLandmarkAssetIDList.size() + items.size());
+	mLandmarkItemIDList.reserve(mLandmarkItemIDList.size() + items.size());
+
+	S32 count = items.size();
 	for(S32 i = 0; i < count; ++i)
 	{
-		LLInventoryItem* item = items.get(i);
+		LLInventoryItem* item = items.at(i);
 		
 		list->addSimpleElement(item->getName(), ADD_BOTTOM, item->getUUID());
 		
-		mLandmarkAssetIDList.put( item->getAssetUUID() );
-		mLandmarkItemIDList.put( item->getUUID() );
+		mLandmarkAssetIDList.push_back( item->getAssetUUID() );
+		mLandmarkItemIDList.push_back( item->getUUID() );
 	}
 	
 	list->selectFirstItem();
diff --git a/indra/newview/llfloaterworldmap.h b/indra/newview/llfloaterworldmap.h
index e3b83b2579..84ca5a7a71 100755
--- a/indra/newview/llfloaterworldmap.h
+++ b/indra/newview/llfloaterworldmap.h
@@ -32,7 +32,6 @@
 #ifndef LL_LLFLOATERWORLDMAP_H
 #define LL_LLFLOATERWORLDMAP_H
 
-#include "lldarray.h"
 #include "llfloater.h"
 #include "llhudtext.h"
 #include "llmapimagetype.h"
@@ -166,8 +165,8 @@ private:
 	// enable/disable teleport destination coordinates 
 	void enableTeleportCoordsDisplay( bool enabled );
 
-	LLDynamicArray<LLUUID>	mLandmarkAssetIDList;
-	LLDynamicArray<LLUUID>	mLandmarkItemIDList;
+	std::vector<LLUUID>	mLandmarkAssetIDList;
+	std::vector<LLUUID>	mLandmarkItemIDList;
 
 	static const LLUUID	sHomeID;
 
diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp
index 16ed3f990c..1771a8f491 100755
--- a/indra/newview/llfriendcard.cpp
+++ b/indra/newview/llfriendcard.cpp
@@ -67,10 +67,10 @@ inline const std::string get_friend_all_subfolder_name()
 
 void move_from_to_arrays(LLInventoryModel::cat_array_t& from, LLInventoryModel::cat_array_t& to)
 {
-	while (from.count() > 0)
+	while (from.size() > 0)
 	{
-		to.put(from.get(0));
-		from.remove(0);
+		to.push_back(from.at(0));
+		from.erase(from.begin());
 	}
 }
 
@@ -82,7 +82,7 @@ const LLUUID& get_folder_uuid(const LLUUID& parentFolderUUID, LLInventoryCollect
 	gInventory.collectDescendentsIf(parentFolderUUID, cats, items,
 		LLInventoryModel::EXCLUDE_TRASH, matchFunctor);
 
-	S32 cats_count = cats.count();
+	S32 cats_count = cats.size();
 
 	if (cats_count > 1)
 	{
@@ -92,7 +92,7 @@ const LLUUID& get_folder_uuid(const LLUUID& parentFolderUUID, LLInventoryCollect
 			<< LL_ENDL;
 	}
 
-	return (cats_count >= 1) ? cats.get(0)->getUUID() : LLUUID::null;
+	return (cats_count >= 1) ? cats.at(0)->getUUID() : LLUUID::null;
 }
 
 /**
@@ -207,7 +207,7 @@ bool LLFriendCardsManager::isItemInAnyFriendsList(const LLViewerInventoryItem* i
 	LLInventoryModel::item_array_t items;
 	findMatchedFriendCards(item->getCreatorUUID(), items);
 
-	return items.count() > 0;
+	return items.size() > 0;
 }
 
 
@@ -242,9 +242,9 @@ bool LLFriendCardsManager::isObjDirectDescendentOfCategory(const LLInventoryObje
 			{
 				LLUUID creator_id = item->getCreatorUUID();
 				LLViewerInventoryItem* cur_item = NULL;
-				for ( S32 i = items->count() - 1; i >= 0; --i )
+				for ( S32 i = items->size() - 1; i >= 0; --i )
 				{
-					cur_item = items->get(i);
+					cur_item = items->at(i);
 					if ( creator_id == cur_item->getCreatorUUID() )
 					{
 						result = true;
@@ -259,9 +259,9 @@ bool LLFriendCardsManager::isObjDirectDescendentOfCategory(const LLInventoryObje
 			// Note: UUID's of compared items also may be not equal.
 			std::string obj_name = obj->getName();
 			LLViewerInventoryItem* cur_item = NULL;
-			for ( S32 i = items->count() - 1; i >= 0; --i )
+			for ( S32 i = items->size() - 1; i >= 0; --i )
 			{
-				cur_item = items->get(i);
+				cur_item = items->at(i);
 				if ( obj->getType() != cur_item->getType() )
 					continue;
 				if ( obj_name == cur_item->getName() )
@@ -279,9 +279,9 @@ bool LLFriendCardsManager::isObjDirectDescendentOfCategory(const LLInventoryObje
 		// then return true. Note: UUID's of compared items also may be not equal.
 		std::string obj_name = obj->getName();
 		LLViewerInventoryCategory* cur_cat = NULL;
-		for ( S32 i = cats->count() - 1; i >= 0; --i )
+		for ( S32 i = cats->size() - 1; i >= 0; --i )
 		{
-			cur_cat = cats->get(i);
+			cur_cat = cats->at(i);
 			if ( obj->getType() != cur_cat->getType() )
 				continue;
 			if ( obj_name == cur_cat->getName() )
@@ -381,10 +381,10 @@ void LLFriendCardsManager::findMatchedFriendCards(const LLUUID& avatarID, LLInve
 	LLInventoryModel::cat_array_t subFolders;
 	subFolders.push_back(friendFolder);
 
-	while (subFolders.count() > 0)
+	while (subFolders.size() > 0)
 	{
-		LLViewerInventoryCategory* cat = subFolders.get(0);
-		subFolders.remove(0);
+		LLViewerInventoryCategory* cat = subFolders.at(0);
+		subFolders.erase(subFolders.begin());
 
 		gInventory.collectDescendentsIf(cat->getUUID(), cats, items, 
 			LLInventoryModel::EXCLUDE_TRASH, matchFunctor);
diff --git a/indra/newview/llgiveinventory.cpp b/indra/newview/llgiveinventory.cpp
index 72bea8db10..2ecd9fa7f7 100755
--- a/indra/newview/llgiveinventory.cpp
+++ b/indra/newview/llgiveinventory.cpp
@@ -248,11 +248,11 @@ bool LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent,
 		items,
 		LLInventoryModel::EXCLUDE_TRASH,
 		giveable);
-	S32 count = cats.count();
+	S32 count = cats.size();
 	bool complete = true;
 	for(S32 i = 0; i < count; ++i)
 	{
-		if (!gInventory.isCategoryComplete(cats.get(i)->getUUID()))
+		if (!gInventory.isCategoryComplete(cats.at(i)->getUUID()))
 		{
 			complete = false;
 			break;
@@ -263,7 +263,7 @@ bool LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent,
 		LLNotificationsUtil::add("IncompleteInventory");
 		give_successful = false;
 	}
-	count = items.count() + cats.count();
+	count = items.size() + cats.size();
 	if (count > MAX_ITEMS)
 	{
 		LLNotificationsUtil::add("TooManyItems");
@@ -447,10 +447,10 @@ bool LLGiveInventory::handleCopyProtectedCategory(const LLSD& notification, cons
 				items,
 				LLInventoryModel::EXCLUDE_TRASH,
 				remove);
-			S32 count = items.count();
+			S32 count = items.size();
 			for(S32 i = 0; i < count; ++i)
 			{
-				gInventory.deleteObject(items.get(i)->getUUID());
+				gInventory.deleteObject(items.at(i)->getUUID());
 			}
 			gInventory.notifyObservers();
 
@@ -504,7 +504,7 @@ bool LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,
 	// MAX ITEMS is based on (sizeof(uuid)+2) * count must be <
 	// MTUBYTES or 18 * count < 1200 => count < 1200/18 =>
 	// 66. I've cut it down a bit from there to give some pad.
-	S32 count = items.count() + cats.count();
+	S32 count = items.size() + cats.size();
 	if (count > MAX_ITEMS)
 	{
 		LLNotificationsUtil::add("TooManyItems");
@@ -530,21 +530,21 @@ bool LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,
 		memcpy(pos, &(cat->getUUID()), UUID_BYTES);		/* Flawfinder: ignore */
 		pos += UUID_BYTES;
 		S32 i;
-		count = cats.count();
+		count = cats.size();
 		for(i = 0; i < count; ++i)
 		{
 			memcpy(pos, &type, sizeof(U8));		/* Flawfinder: ignore */
 			pos += sizeof(U8);
-			memcpy(pos, &(cats.get(i)->getUUID()), UUID_BYTES);		/* Flawfinder: ignore */
+			memcpy(pos, &(cats.at(i)->getUUID()), UUID_BYTES);		/* Flawfinder: ignore */
 			pos += UUID_BYTES;
 		}
-		count = items.count();
+		count = items.size();
 		for(i = 0; i < count; ++i)
 		{
-			type = (U8)items.get(i)->getType();
+			type = (U8)items.at(i)->getType();
 			memcpy(pos, &type, sizeof(U8));		/* Flawfinder: ignore */
 			pos += sizeof(U8);
-			memcpy(pos, &(items.get(i)->getUUID()), UUID_BYTES);		/* Flawfinder: ignore */
+			memcpy(pos, &(items.at(i)->getUUID()), UUID_BYTES);		/* Flawfinder: ignore */
 			pos += UUID_BYTES;
 		}
 		pack_instant_message(
diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp
index a0f2918bd7..0324629c6e 100755
--- a/indra/newview/llgroupactions.cpp
+++ b/indra/newview/llgroupactions.cpp
@@ -210,17 +210,17 @@ void LLGroupActions::leave(const LLUUID& group_id)
 	if (group_id.isNull())
 		return;
 
-	S32 count = gAgent.mGroups.count();
+	S32 count = gAgent.mGroups.size();
 	S32 i;
 	for (i = 0; i < count; ++i)
 	{
-		if(gAgent.mGroups.get(i).mID == group_id)
+		if(gAgent.mGroups.at(i).mID == group_id)
 			break;
 	}
 	if (i < count)
 	{
 		LLSD args;
-		args["GROUP"] = gAgent.mGroups.get(i).mName;
+		args["GROUP"] = gAgent.mGroups.at(i).mName;
 		LLSD payload;
 		payload["group_id"] = group_id;
 		LLNotificationsUtil::add("GroupLeaveConfirmMember", args, payload, onLeaveGroup);
diff --git a/indra/newview/llgroupiconctrl.cpp b/indra/newview/llgroupiconctrl.cpp
index 2d0fc26c2a..6abf9ea637 100755
--- a/indra/newview/llgroupiconctrl.cpp
+++ b/indra/newview/llgroupiconctrl.cpp
@@ -30,33 +30,21 @@
 
 #include "llagent.h"
 #include "llviewertexture.h"
-/*
-#include "llavatarconstants.h"
-#include "llcallingcard.h" // for LLAvatarTracker
-#include "llavataractions.h"
-#include "llmenugl.h"
-#include "lluictrlfactory.h"
-
-#include "llcachename.h"
-#include "llagentdata.h"
-#include "llfloaterimsession.h"
-*/
 
 static LLDefaultChildRegistry::Register<LLGroupIconCtrl> g_i("group_icon");
 
 LLGroupIconCtrl::Params::Params()
-:	group_id("group_id")
-,	draw_tooltip("draw_tooltip", true)
-,	default_icon_name("default_icon_name")
-{
-}
+:	group_id("group_id"),
+	draw_tooltip("draw_tooltip", true),
+	default_icon_name("default_icon_name")
+{}
 
 
 LLGroupIconCtrl::LLGroupIconCtrl(const LLGroupIconCtrl::Params& p)
-:	LLIconCtrl(p)
-,	mGroupId(LLUUID::null)
-,	mDrawTooltip(p.draw_tooltip)
-,	mDefaultIconName(p.default_icon_name)
+:	LLIconCtrl(p),
+	mGroupId(LLUUID::null),
+	mDrawTooltip(p.draw_tooltip),
+	mDefaultIconName(p.default_icon_name)
 {
 	mPriority = LLViewerFetchedTexture::BOOST_ICON;
 
diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp
index aba3d74d87..b1b7a87ae8 100755
--- a/indra/newview/llgrouplist.cpp
+++ b/indra/newview/llgrouplist.cpp
@@ -163,7 +163,7 @@ static bool findInsensitive(std::string haystack, const std::string& needle_uppe
 void LLGroupList::refresh()
 {
 	const LLUUID& 		highlight_id	= gAgent.getGroupID();
-	S32					count			= gAgent.mGroups.count();
+	S32					count			= gAgent.mGroups.size();
 	LLUUID				id;
 	bool				have_filter		= !mNameFilter.empty();
 
@@ -171,8 +171,8 @@ void LLGroupList::refresh()
 
 	for(S32 i = 0; i < count; ++i)
 	{
-		id = gAgent.mGroups.get(i).mID;
-		const LLGroupData& group_data = gAgent.mGroups.get(i);
+		id = gAgent.mGroups.at(i).mID;
+		const LLGroupData& group_data = gAgent.mGroups.at(i);
 		if (have_filter && !findInsensitive(group_data.mName, mNameFilter))
 			continue;
 		addNewItem(id, group_data.mName, group_data.mInsigniaID, ADD_BOTTOM);
diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h
index d8c1ab7ef5..d107fceb49 100755
--- a/indra/newview/llgroupmgr.h
+++ b/indra/newview/llgroupmgr.h
@@ -35,6 +35,17 @@
 
 class LLMessageSystem;
 
+
+enum LLGroupChange
+{
+	GC_PROPERTIES,
+	GC_MEMBER_DATA,
+	GC_ROLE_DATA,
+	GC_ROLE_MEMBER_DATA,
+	GC_TITLES,
+	GC_ALL
+};
+
 class LLGroupMgrObserver
 {
 public:
diff --git a/indra/newview/llhudicon.h b/indra/newview/llhudicon.h
index 87455ec3f4..e00a985ddc 100755
--- a/indra/newview/llhudicon.h
+++ b/indra/newview/llhudicon.h
@@ -38,7 +38,6 @@
 #include "llfontgl.h"
 #include <set>
 #include <vector>
-#include "lldarray.h"
 
 // Renders a 2D icon billboard floating at the location specified.
 class LLViewerTexture;
diff --git a/indra/newview/llhudmanager.cpp b/indra/newview/llhudmanager.cpp
index 8f14b53db0..8ad432fbad 100755
--- a/indra/newview/llhudmanager.cpp
+++ b/indra/newview/llhudmanager.cpp
@@ -60,7 +60,7 @@ void LLHUDManager::updateEffects()
 {
 	LLFastTimer ftm(FTM_HUD_EFFECTS);
 	S32 i;
-	for (i = 0; i < mHUDEffects.count(); i++)
+	for (i = 0; i < mHUDEffects.size(); i++)
 	{
 		LLHUDEffect *hep = mHUDEffects[i];
 		if (hep->isDead())
@@ -74,7 +74,7 @@ void LLHUDManager::updateEffects()
 void LLHUDManager::sendEffects()
 {
 	S32 i;
-	for (i = 0; i < mHUDEffects.count(); i++)
+	for (i = 0; i < mHUDEffects.size(); i++)
 	{
 		LLHUDEffect *hep = mHUDEffects[i];
 		if (hep->isDead())
@@ -105,18 +105,18 @@ void LLHUDManager::sendEffects()
 //static
 void LLHUDManager::shutdownClass()
 {
-	getInstance()->mHUDEffects.reset();
+	getInstance()->mHUDEffects.clear();
 }
 
 void LLHUDManager::cleanupEffects()
 {
 	S32 i = 0;
 
-	while (i < mHUDEffects.count())
+	while (i < mHUDEffects.size())
 	{
 		if (mHUDEffects[i]->isDead())
 		{
-			mHUDEffects.remove(i);
+			mHUDEffects.erase(mHUDEffects.begin() + i);
 		}
 		else
 		{
@@ -140,7 +140,7 @@ LLHUDEffect *LLHUDManager::createViewerEffect(const U8 type, BOOL send_to_sim, B
 	hep->setNeedsSendToSim(send_to_sim);
 	hep->setOriginatedHere(originated_here);
 
-	mHUDEffects.put(hep);
+	mHUDEffects.push_back(hep);
 	return hep;
 }
 
@@ -159,20 +159,20 @@ void LLHUDManager::processViewerEffect(LLMessageSystem *mesgsys, void **user_dat
 		effectp = NULL;
 		LLHUDEffect::getIDType(mesgsys, k, effect_id, effect_type);
 		S32 i;
-		for (i = 0; i < LLHUDManager::getInstance()->mHUDEffects.count(); i++)
+		for (i = 0; i < LLHUDManager::getInstance()->mHUDEffects.size(); i++)
 		{
 			LLHUDEffect *cur_effectp = LLHUDManager::getInstance()->mHUDEffects[i];
 			if (!cur_effectp)
 			{
 				llwarns << "Null effect in effect manager, skipping" << llendl;
-				LLHUDManager::getInstance()->mHUDEffects.remove(i);
+				LLHUDManager::getInstance()->mHUDEffects.erase(LLHUDManager::getInstance()->mHUDEffects.begin() + i);
 				i--;
 				continue;
 			}
 			if (cur_effectp->isDead())
 			{
 	//			llwarns << "Dead effect in effect manager, removing" << llendl;
-				LLHUDManager::getInstance()->mHUDEffects.remove(i);
+				LLHUDManager::getInstance()->mHUDEffects.erase(LLHUDManager::getInstance()->mHUDEffects.begin() + i);
 				i--;
 				continue;
 			}
diff --git a/indra/newview/llhudmanager.h b/indra/newview/llhudmanager.h
index effea8f034..9c5d49decd 100755
--- a/indra/newview/llhudmanager.h
+++ b/indra/newview/llhudmanager.h
@@ -30,7 +30,6 @@
 // Responsible for managing all HUD elements.
 
 #include "llhudobject.h"
-#include "lldarray.h"
 
 class LLHUDEffect;
 class LLMessageSystem;
@@ -55,7 +54,7 @@ public:
 	static LLColor4 sChildColor;
 
 protected:
-	LLDynamicArray<LLPointer<LLHUDEffect>, 32> mHUDEffects;
+	std::vector<LLPointer<LLHUDEffect> > mHUDEffects;
 };
 
 #endif // LL_LLHUDMANAGER_H
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 7e18d37fe1..89ea5ff73a 100755
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -2397,7 +2397,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload
 					llinfos << "Corrected session name is " << correct_session_name << llendl; 
 					break;
 				default: 
-					llwarning("Received an empty session name from a server and failed to generate a new proper session name", 0);
+					LL_WARNS() << "Received an empty session name from a server and failed to generate a new proper session name" << LL_ENDL;
 					break;
 				}
 			}
@@ -2782,8 +2782,8 @@ LLUUID LLIMMgr::addSession(
 	EInstantMessage dialog,
 	const LLUUID& other_participant_id, bool voice)
 {
-	LLDynamicArray<LLUUID> ids;
-	ids.put(other_participant_id);
+	std::vector<LLUUID> ids;
+	ids.push_back(other_participant_id);
 	LLUUID session_id = addSession(name, dialog, other_participant_id, ids, voice);
 	return session_id;
 }
@@ -2794,17 +2794,17 @@ LLUUID LLIMMgr::addSession(
 	const std::string& name,
 	EInstantMessage dialog,
 	const LLUUID& other_participant_id,
-	const LLDynamicArray<LLUUID>& ids, bool voice,
+	const std::vector<LLUUID>& ids, bool voice,
 	const LLUUID& floater_id)
 {
-	if (0 == ids.getLength())
+	if (ids.empty())
 	{
 		return LLUUID::null;
 	}
 
 	if (name.empty())
 	{
-		llwarning("Session name cannot be null!", 0);
+		LL_WARNS() << "Session name cannot be null!" << LL_ENDL;
 		return LLUUID::null;
 	}
 
@@ -3245,9 +3245,9 @@ bool LLIMMgr::isNonFriendSessionNotified(const LLUUID& session_id)
 
 void LLIMMgr::noteOfflineUsers(
 	const LLUUID& session_id,
-	const LLDynamicArray<LLUUID>& ids)
+	const std::vector<LLUUID>& ids)
 {
-	S32 count = ids.count();
+	S32 count = ids.size();
 	if(count == 0)
 	{
 		const std::string& only_user = LLTrans::getString("only_user_message");
@@ -3260,11 +3260,11 @@ void LLIMMgr::noteOfflineUsers(
 		LLIMModel& im_model = LLIMModel::instance();
 		for(S32 i = 0; i < count; ++i)
 		{
-			info = at.getBuddyInfo(ids.get(i));
+			info = at.getBuddyInfo(ids.at(i));
 			LLAvatarName av_name;
 			if (info
 				&& !info->isOnline()
-				&& LLAvatarNameCache::get(ids.get(i), &av_name))
+				&& LLAvatarNameCache::get(ids.at(i), &av_name))
 			{
 				LLUIString offline = LLTrans::getString("offline_message");
 				// Use display name only because this user is your friend
@@ -3276,7 +3276,7 @@ void LLIMMgr::noteOfflineUsers(
 }
 
 void LLIMMgr::noteMutedUsers(const LLUUID& session_id,
-								  const LLDynamicArray<LLUUID>& ids)
+								  const std::vector<LLUUID>& ids)
 {
 	// Don't do this if we don't have a mute list.
 	LLMuteList *ml = LLMuteList::getInstance();
@@ -3285,14 +3285,14 @@ void LLIMMgr::noteMutedUsers(const LLUUID& session_id,
 		return;
 	}
 
-	S32 count = ids.count();
+	S32 count = ids.size();
 	if(count > 0)
 	{
 		LLIMModel* im_model = LLIMModel::getInstance();
 		
 		for(S32 i = 0; i < count; ++i)
 		{
-			if( ml->isMuted(ids.get(i)) )
+			if( ml->isMuted(ids.at(i)) )
 			{
 				LLUIString muted = LLTrans::getString("muted_message");
 
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 2d036cbc2f..382b0e0a77 100755
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -33,7 +33,6 @@
 
 #include "lllogchat.h"
 #include "llvoicechannel.h"
-#include "lldarray.h"
 
 class LLAvatarName;
 class LLFriendObserver;
@@ -354,7 +353,7 @@ public:
 	LLUUID addSession(const std::string& name,
 					  EInstantMessage dialog,
 					  const LLUUID& other_participant_id,
-					  const LLDynamicArray<LLUUID>& ids, bool voice = false,
+					  const std::vector<LLUUID>& ids, bool voice = false,
 					  const LLUUID& floater_id = LLUUID::null);
 
 	/**
@@ -457,8 +456,8 @@ private:
 	// prints a simple message if they are not online. Used to help
 	// reduce 'hello' messages to the linden employees unlucky enough
 	// to have their calling card in the default inventory.
-	void noteOfflineUsers(const LLUUID& session_id, const LLDynamicArray<LLUUID>& ids);
-	void noteMutedUsers(const LLUUID& session_id, const LLDynamicArray<LLUUID>& ids);
+	void noteOfflineUsers(const LLUUID& session_id, const std::vector<LLUUID>& ids);
+	void noteMutedUsers(const LLUUID& session_id, const std::vector<LLUUID>& ids);
 
 	void processIMTypingCore(const LLIMInfo* im_info, BOOL typing);
 
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index c8ee8135a6..6915ba4557 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -328,7 +328,7 @@ void LLInvFVBridge::removeBatch(std::vector<LLFolderViewModelItem*>& batch)
 		if (cat)
 		{
 			gInventory.collectDescendents( cat->getUUID(), descendent_categories, descendent_items, FALSE );
-			for (j=0; j<descendent_items.count(); j++)
+			for (j=0; j<descendent_items.size(); j++)
 			{
 				if(LLAssetType::AT_GESTURE == descendent_items[j]->getType())
 				{
@@ -490,12 +490,12 @@ BOOL LLInvFVBridge::isClipboardPasteable() const
 	}
 
 	// In normal mode, we need to check each element of the clipboard to know if we can paste or not
-	LLDynamicArray<LLUUID> objects;
+	std::vector<LLUUID> objects;
 	LLClipboard::instance().pasteFromClipboard(objects);
-	S32 count = objects.count();
+	S32 count = objects.size();
 	for(S32 i = 0; i < count; i++)
 	{
-		const LLUUID &item_id = objects.get(i);
+		const LLUUID &item_id = objects.at(i);
 
 		// Folders are pastable if all items in there are copyable
 		const LLInventoryCategory *cat = model->getCategory(item_id);
@@ -530,12 +530,12 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const
 		return FALSE;
 	}
 
-	LLDynamicArray<LLUUID> objects;
+	std::vector<LLUUID> objects;
 	LLClipboard::instance().pasteFromClipboard(objects);
-	S32 count = objects.count();
+	S32 count = objects.size();
 	for(S32 i = 0; i < count; i++)
 	{
-		const LLInventoryItem *item = model->getItem(objects.get(i));
+		const LLInventoryItem *item = model->getItem(objects.at(i));
 		if (item)
 		{
 			if (!LLAssetType::lookupCanLink(item->getActualType()))
@@ -543,7 +543,7 @@ BOOL LLInvFVBridge::isClipboardPasteableAsLink() const
 				return FALSE;
 			}
 		}
-		const LLViewerInventoryCategory *cat = model->getCategory(objects.get(i));
+		const LLViewerInventoryCategory *cat = model->getCategory(objects.at(i));
 		if (cat && LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
 		{
 			return FALSE;
@@ -861,7 +861,7 @@ BOOL LLInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const
 		}
 
 		*id = obj->getUUID();
-		//object_ids.put(obj->getUUID());
+		//object_ids.push_back(obj->getUUID());
 
 		if (*type == DAD_CATEGORY)
 		{
@@ -2048,15 +2048,15 @@ BOOL LLFolderBridge::isClipboardPasteable() const
 			return FALSE;
 		}
 
-		LLDynamicArray<LLUUID> objects;
+		std::vector<LLUUID> objects;
 		LLClipboard::instance().pasteFromClipboard(objects);
 		const LLViewerInventoryCategory *current_cat = getCategory();
 
 		// Search for the direct descendent of current Friends subfolder among all pasted items,
 		// and return false if is found.
-		for(S32 i = objects.count() - 1; i >= 0; --i)
+		for(S32 i = objects.size() - 1; i >= 0; --i)
 		{
-			const LLUUID &obj_id = objects.get(i);
+			const LLUUID &obj_id = objects.at(i);
 			if ( LLFriendCardsManager::instance().isObjDirectDescendentOfCategory(model->getObject(obj_id), current_cat) )
 			{
 				return FALSE;
@@ -2086,12 +2086,12 @@ BOOL LLFolderBridge::isClipboardPasteableAsLink() const
 	{
 		const BOOL is_in_friend_folder = LLFriendCardsManager::instance().isCategoryInFriendFolder( current_cat );
 		const LLUUID &current_cat_id = current_cat->getUUID();
-		LLDynamicArray<LLUUID> objects;
+		std::vector<LLUUID> objects;
 		LLClipboard::instance().pasteFromClipboard(objects);
-		S32 count = objects.count();
+		S32 count = objects.size();
 		for(S32 i = 0; i < count; i++)
 		{
-			const LLUUID &obj_id = objects.get(i);
+			const LLUUID &obj_id = objects.at(i);
 			const LLInventoryCategory *cat = model->getCategory(obj_id);
 			if (cat)
 			{
@@ -2165,9 +2165,9 @@ int get_folder_levels(LLInventoryCategory* inv_cat)
 
 	int max_child_levels = 0;
 
-	for (S32 i=0; i < cats->count(); ++i)
+	for (S32 i=0; i < cats->size(); ++i)
 	{
-		LLInventoryCategory* category = cats->get(i);
+		LLInventoryCategory* category = cats->at(i);
 		max_child_levels = llmax(max_child_levels, get_folder_levels(category));
 	}
 
@@ -2277,7 +2277,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 		if (is_movable)
 		{
 			model->collectDescendents(cat_id, descendent_categories, descendent_items, FALSE);
-			for (S32 i=0; i < descendent_categories.count(); ++i)
+			for (S32 i=0; i < descendent_categories.size(); ++i)
 			{
 				LLInventoryCategory* category = descendent_categories[i];
 				if(LLFolderType::lookupIsProtectedType(category->getPreferredType()))
@@ -2290,7 +2290,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 		}
 		if (is_movable && move_is_into_trash)
 		{
-			for (S32 i=0; i < descendent_items.count(); ++i)
+			for (S32 i=0; i < descendent_items.size(); ++i)
 			{
 				LLInventoryItem* item = descendent_items[i];
 				if (get_is_item_worn(item->getUUID()))
@@ -2302,7 +2302,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 		}
 		if (is_movable && move_is_into_landmarks)
 		{
-			for (S32 i=0; i < descendent_items.count(); ++i)
+			for (S32 i=0; i < descendent_items.size(); ++i)
 			{
 				LLViewerInventoryItem* item = descendent_items[i];
 
@@ -2326,7 +2326,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 			}
 			else
 			{
-				int dragged_folder_count = descendent_categories.count();
+				int dragged_folder_count = descendent_categories.size();
 				int existing_item_count = 0;
 				int existing_folder_count = 0;
 				
@@ -2365,8 +2365,8 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 
 					model->collectDescendents(master_folder->getUUID(), existing_categories, existing_items, FALSE);
 					
-					existing_folder_count += existing_categories.count();
-					existing_item_count += existing_items.count();
+					existing_folder_count += existing_categories.size();
+					existing_item_count += existing_items.size();
 				}
 				else
 				{
@@ -2376,7 +2376,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 				}
 
 				const int nested_folder_count = existing_folder_count + dragged_folder_count;
-				const int nested_item_count = existing_item_count + descendent_items.count();
+				const int nested_item_count = existing_item_count + descendent_items.size();
 				
 				if (nested_folder_count > gSavedSettings.getU32("InventoryOutboxMaxFolderCount"))
 				{
@@ -2391,7 +2391,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 				
 				if (is_movable == TRUE)
 				{
-					for (S32 i=0; i < descendent_items.count(); ++i)
+					for (S32 i=0; i < descendent_items.size(); ++i)
 					{
 						LLInventoryItem* item = descendent_items[i];
 						if (!can_move_to_outbox(item, tooltip_msg))
@@ -2447,7 +2447,7 @@ BOOL LLFolderBridge::dragCategoryIntoFolder(LLInventoryCategory* inv_cat,
 			// Look for any gestures and deactivate them
 			if (move_is_into_trash)
 			{
-				for (S32 i=0; i < descendent_items.count(); i++)
+				for (S32 i=0; i < descendent_items.size(); i++)
 				{
 					LLInventoryItem* item = descendent_items[i];
 					if (item->getType() == LLAssetType::AT_GESTURE
@@ -2711,13 +2711,13 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
 		S32 item_count(0);
 		if( item_array )
 		{			
-			item_count = item_array->count();
+			item_count = item_array->size();
 		}
 		
 		S32 cat_count(0);
 		if( cat_array )
 		{			
-			cat_count = cat_array->count();
+			cat_count = cat_array->size();
 		}
 
 		// Move to next if current folder empty
@@ -2735,7 +2735,7 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
 		{
 			for (S32 i = 0; i < item_count; ++i)
 			{
-				ids.push_back(item_array->get(i)->getUUID());
+				ids.push_back(item_array->at(i)->getUUID());
 			}
 			outfit = new LLRightClickInventoryFetchObserver(ids);
 		}
@@ -2744,7 +2744,7 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
 		{
 			for (S32 i = 0; i < cat_count; ++i)
 			{
-				ids.push_back(cat_array->get(i)->getUUID());
+				ids.push_back(cat_array->at(i)->getUUID());
 			}
 			categories = new LLRightClickInventoryFetchDescendentsObserver(ids);
 		}
@@ -3153,7 +3153,7 @@ void LLFolderBridge::pasteFromClipboard()
 		const BOOL move_is_into_outfit = (getCategory() && getCategory()->getPreferredType()==LLFolderType::FT_OUTFIT);
 		const BOOL move_is_into_outbox = model->isObjectDescendentOf(mUUID, outbox_id);
 
-		LLDynamicArray<LLUUID> objects;
+		std::vector<LLUUID> objects;
 		LLClipboard::instance().pasteFromClipboard(objects);
 
 		if (move_is_into_outbox)
@@ -3166,7 +3166,7 @@ void LLFolderBridge::pasteFromClipboard()
 
 				BOOL can_list = TRUE;
 
-				for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin();
+				for (std::vector<LLUUID>::const_iterator iter = objects.begin();
 					(iter != objects.end()) && (can_list == TRUE);
 					++iter)
 				{
@@ -3197,7 +3197,7 @@ void LLFolderBridge::pasteFromClipboard()
 
 		const LLUUID parent_id(mUUID);
 
-		for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin();
+		for (std::vector<LLUUID>::const_iterator iter = objects.begin();
 			 iter != objects.end();
 			 ++iter)
 		{
@@ -3289,9 +3289,9 @@ void LLFolderBridge::pasteLinkFromClipboard()
 
 		const LLUUID parent_id(mUUID);
 
-		LLDynamicArray<LLUUID> objects;
+		std::vector<LLUUID> objects;
 		LLClipboard::instance().pasteFromClipboard(objects);
-		for (LLDynamicArray<LLUUID>::const_iterator iter = objects.begin();
+		for (std::vector<LLUUID>::const_iterator iter = objects.begin();
 			 iter != objects.end();
 			 ++iter)
 		{
@@ -3352,7 +3352,7 @@ BOOL LLFolderBridge::checkFolderForContentsOfType(LLInventoryModel* model, LLInv
 								item_array,
 								LLInventoryModel::EXCLUDE_TRASH,
 								is_type);
-	return ((item_array.count() > 0) ? TRUE : FALSE );
+	return ((item_array.size() > 0) ? TRUE : FALSE );
 }
 
 void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t&   items, menuentry_vec_t& disabled_items)
@@ -4044,7 +4044,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
 					
 					gInventory.collectDescendents(master_folder->getUUID(), existing_categories, existing_items, FALSE);
 					
-					existing_item_count += existing_items.count();
+					existing_item_count += existing_items.size();
 				}
 				
 				if (existing_item_count > gSavedSettings.getU32("InventoryOutboxMaxItemCount"))
@@ -4341,8 +4341,8 @@ bool check_category(LLInventoryModel* model,
 	LLInventoryModel::item_array_t descendent_items;
 	model->collectDescendents(cat_id, descendent_categories, descendent_items, TRUE);
 
-	S32 num_descendent_categories = descendent_categories.count();
-	S32 num_descendent_items = descendent_items.count();
+	S32 num_descendent_categories = descendent_categories.size();
+	S32 num_descendent_items = descendent_items.size();
 
 	if (num_descendent_categories + num_descendent_items == 0)
 	{
diff --git a/indra/newview/llinventoryitemslist.h b/indra/newview/llinventoryitemslist.h
index b183a2052d..1aa230df99 100755
--- a/indra/newview/llinventoryitemslist.h
+++ b/indra/newview/llinventoryitemslist.h
@@ -29,8 +29,6 @@
 #ifndef LL_LLINVENTORYITEMSLIST_H
 #define LL_LLINVENTORYITEMSLIST_H
 
-#include "lldarray.h"
-
 // newview
 #include "llflatlistview.h"
 
@@ -46,7 +44,7 @@ public:
 
 	virtual ~LLInventoryItemsList();
 
-	void refreshList(const LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array);
+	void refreshList(const std::vector<LLPointer<LLViewerInventoryItem> > item_array);
 
 	boost::signals2::connection setRefreshCompleteCallback(const commit_signal_t::slot_type& cb);
 
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 935fe2b4d0..81c72fd320 100755
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -112,7 +112,7 @@ bool LLCanCache::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
 			S32 descendents_actual = 0;
 			if(cats && items)
 			{
-				descendents_actual = cats->count() + items->count();
+				descendents_actual = cats->size() + items->size();
 			}
 			if(descendents_server == descendents_actual)
 			{
@@ -389,12 +389,12 @@ const LLUUID LLInventoryModel::findCategoryUUIDForType(LLFolderType::EType prefe
 		cats = get_ptr_in_map(mParentChildCategoryTree, root_id);
 		if(cats)
 		{
-			S32 count = cats->count();
+			S32 count = cats->size();
 			for(S32 i = 0; i < count; ++i)
 			{
-				if(cats->get(i)->getPreferredType() == preferred_type)
+				if(cats->at(i)->getPreferredType() == preferred_type)
 				{
-					rv = cats->get(i)->getUUID();
+					rv = cats->at(i)->getUUID();
 					break;
 				}
 			}
@@ -426,12 +426,12 @@ const LLUUID LLInventoryModel::findLibraryCategoryUUIDForType(LLFolderType::ETyp
 		cats = get_ptr_in_map(mParentChildCategoryTree, root_id);
 		if(cats)
 		{
-			S32 count = cats->count();
+			S32 count = cats->size();
 			for(S32 i = 0; i < count; ++i)
 			{
-				if(cats->get(i)->getPreferredType() == preferred_type)
+				if(cats->at(i)->getPreferredType() == preferred_type)
 				{
-					rv = cats->get(i)->getUUID();
+					rv = cats->at(i)->getUUID();
 					break;
 				}
 			}
@@ -631,13 +631,13 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id,
 	cat_array_t* cat_array = get_ptr_in_map(mParentChildCategoryTree, id);
 	if(cat_array)
 	{
-		S32 count = cat_array->count();
+		S32 count = cat_array->size();
 		for(S32 i = 0; i < count; ++i)
 		{
-			LLViewerInventoryCategory* cat = cat_array->get(i);
+			LLViewerInventoryCategory* cat = cat_array->at(i);
 			if(add(cat,NULL))
 			{
-				cats.put(cat);
+				cats.push_back(cat);
 			}
 			collectDescendentsIf(cat->getUUID(), cats, items, include_trash, add);
 		}
@@ -651,10 +651,10 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id,
 	// Note: if making it fully recursive, need more checking against infinite loops.
 	if (follow_folder_links && item_array)
 	{
-		S32 count = item_array->count();
+		S32 count = item_array->size();
 		for(S32 i = 0; i < count; ++i)
 		{
-			item = item_array->get(i);
+			item = item_array->at(i);
 			if (item && item->getActualType() == LLAssetType::AT_LINK_FOLDER)
 			{
 				LLViewerInventoryCategory *linked_cat = item->getLinkedCategory();
@@ -668,7 +668,7 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id,
 						// BAP should this be added here?  May not
 						// matter if it's only being used in current
 						// outfit traversal.
-						cats.put(LLPointer<LLViewerInventoryCategory>(linked_cat));
+						cats.push_back(LLPointer<LLViewerInventoryCategory>(linked_cat));
 					}
 					collectDescendentsIf(linked_cat->getUUID(), cats, items, include_trash, add, FALSE);
 				}
@@ -679,13 +679,13 @@ void LLInventoryModel::collectDescendentsIf(const LLUUID& id,
 	// Move onto items
 	if(item_array)
 	{
-		S32 count = item_array->count();
+		S32 count = item_array->size();
 		for(S32 i = 0; i < count; ++i)
 		{
-			item = item_array->get(i);
+			item = item_array->at(i);
 			if(add(NULL, item))
 			{
-				items.put(item);
+				items.push_back(item);
 			}
 		}
 	}
@@ -793,7 +793,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 	}
 #endif
 
-	LLViewerInventoryItem* old_item = getItem(item->getUUID());
+	LLPointer<LLViewerInventoryItem> old_item = getItem(item->getUUID());
 	LLPointer<LLViewerInventoryItem> new_item;
 	if(old_item)
 	{
@@ -809,12 +809,12 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 			item_array = get_ptr_in_map(mParentChildItemTree, old_parent_id);
 			if(item_array)
 			{
-				item_array->removeObj(old_item);
+				vector_replace_with_last(*item_array, old_item);
 			}
 			item_array = get_ptr_in_map(mParentChildItemTree, new_parent_id);
 			if(item_array)
 			{
-				item_array->put(old_item);
+				item_array->push_back(old_item);
 			}
 			mask |= LLInventoryObserver::STRUCTURE;
 		}
@@ -840,7 +840,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 			{
 				// *FIX: bit of a hack to call update server from here...
 				new_item->updateServer(TRUE);
-				item_array->put(new_item);
+				item_array->push_back(new_item);
 			}
 			else
 			{
@@ -868,7 +868,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 			item_array_t* item_array = get_ptr_in_map(mParentChildItemTree, parent_id);
 			if(item_array)
 			{
-				item_array->put(new_item);
+				item_array->push_back(new_item);
 			}
 			else
 			{
@@ -883,7 +883,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 					// *FIX: bit of a hack to call update server from
 					// here...
 					new_item->updateServer(TRUE);
-					item_array->put(new_item);
+					item_array->push_back(new_item);
 				}
 				else
 				{
@@ -965,7 +965,7 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
 		return;
 	}
 
-	LLViewerInventoryCategory* old_cat = getCategory(cat->getUUID());
+	LLPointer<LLViewerInventoryCategory> old_cat = getCategory(cat->getUUID());
 	if(old_cat)
 	{
 		// We already have an old category, modify it's values
@@ -979,12 +979,12 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
 			cat_array = getUnlockedCatArray(old_parent_id);
 			if(cat_array)
 			{
-				cat_array->removeObj(old_cat);
+				vector_replace_with_last(*cat_array, old_cat);
 			}
 			cat_array = getUnlockedCatArray(new_parent_id);
 			if(cat_array)
 			{
-				cat_array->put(old_cat);
+				cat_array->push_back(old_cat);
 			}
 			mask |= LLInventoryObserver::STRUCTURE;
             mask |= LLInventoryObserver::INTERNAL;
@@ -1008,7 +1008,7 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
 		cat_array = getUnlockedCatArray(cat->getParentUUID());
 		if(cat_array)
 		{
-			cat_array->put(new_cat);
+			cat_array->push_back(new_cat);
 		}
 
 		// make space in the tree for this category's children.
@@ -1037,27 +1037,27 @@ void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)
 				<< cat_id << llendl;
 		return;
 	}
-	LLViewerInventoryCategory* cat = getCategory(object_id);
+	LLPointer<LLViewerInventoryCategory> cat = getCategory(object_id);
 	if(cat && (cat->getParentUUID() != cat_id))
 	{
 		cat_array_t* cat_array;
 		cat_array = getUnlockedCatArray(cat->getParentUUID());
-		if(cat_array) cat_array->removeObj(cat);
+		if(cat_array) vector_replace_with_last(*cat_array, cat);
 		cat_array = getUnlockedCatArray(cat_id);
 		cat->setParent(cat_id);
-		if(cat_array) cat_array->put(cat);
+		if(cat_array) cat_array->push_back(cat);
 		addChangedMask(LLInventoryObserver::STRUCTURE, object_id);
 		return;
 	}
-	LLViewerInventoryItem* item = getItem(object_id);
+	LLPointer<LLViewerInventoryItem> item = getItem(object_id);
 	if(item && (item->getParentUUID() != cat_id))
 	{
 		item_array_t* item_array;
 		item_array = getUnlockedItemArray(item->getParentUUID());
-		if(item_array) item_array->removeObj(item);
+		if(item_array) vector_replace_with_last(*item_array, item);
 		item_array = getUnlockedItemArray(cat_id);
 		item->setParent(cat_id);
-		if(item_array) item_array->put(item);
+		if(item_array) item_array->push_back(item);
 		addChangedMask(LLInventoryObserver::STRUCTURE, object_id);
 		return;
 	}
@@ -1143,14 +1143,14 @@ void LLInventoryModel::deleteObject(const LLUUID& id)
 	item_array_t* item_list = getUnlockedItemArray(parent_id);
 	if(item_list)
 	{
-		LLViewerInventoryItem* item = (LLViewerInventoryItem*)((LLInventoryObject*)obj);
-		item_list->removeObj(item);
+		LLPointer<LLViewerInventoryItem> item = (LLViewerInventoryItem*)((LLInventoryObject*)obj);
+		vector_replace_with_last(*item_list, item);
 	}
 	cat_array_t* cat_list = getUnlockedCatArray(parent_id);
 	if(cat_list)
 	{
-		LLViewerInventoryCategory* cat = (LLViewerInventoryCategory*)((LLInventoryObject*)obj);
-		cat_list->removeObj(cat);
+		LLPointer<LLViewerInventoryCategory> cat = (LLViewerInventoryCategory*)((LLInventoryObject*)obj);
+		vector_replace_with_last(*cat_list, cat);
 	}
 	item_list = getUnlockedItemArray(id);
 	if(item_list)
@@ -1282,7 +1282,7 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
 							   categories,
 							   items,
 							   INCLUDE_TRASH);
-			S32 count = items.count();
+			S32 count = items.size();
 
 			item_map_t::iterator item_map_end = mItemMap.end();
 			cat_map_t::iterator cat_map_end = mCategoryMap.end();
@@ -1290,7 +1290,7 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
 
 			for(S32 i = 0; i < count; ++i)
 			{
-				uu_id = items.get(i)->getUUID();
+				uu_id = items.at(i)->getUUID();
 
 				// This check prevents the deletion of a previously deleted item.
 				// This is necessary because deletion is not done in a hierarchical
@@ -1302,10 +1302,10 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
 				}
 			}
 
-			count = categories.count();
+			count = categories.size();
 			for(S32 i = 0; i < count; ++i)
 			{
-				uu_id = categories.get(i)->getUUID();
+				uu_id = categories.at(i)->getUUID();
 				if (mCategoryMap.find(uu_id) != cat_map_end)
 				{
 					deleteObject(uu_id);
@@ -1481,11 +1481,11 @@ bool LLInventoryModel::fetchDescendentsOf(const LLUUID& folder_id) const
 	//item_array_t* items = get_ptr_in_map(mParentChildItemTree, folder_id);
 	//if(categories)
 	//{
-	//	known_descendents += categories->count();
+	//	known_descendents += categories->size();
 	//}
 	//if(items)
 	//{
-	//	known_descendents += items->count();
+	//	known_descendents += items->size();
 	//}
 	return cat->fetch();
 }
@@ -1499,7 +1499,7 @@ void LLInventoryModel::cache(
 	LLViewerInventoryCategory* root_cat = getCategory(parent_folder_id);
 	if(!root_cat) return;
 	cat_array_t categories;
-	categories.put(root_cat);
+	categories.push_back(root_cat);
 	item_array_t items;
 
 	LLCanCache can_cache(this);
@@ -1612,7 +1612,7 @@ void LLInventoryModel::accountForUpdate(const LLCategoryUpdate& update) const
 			S32 descendents_actual = 0;
 			if(cats && items)
 			{
-				descendents_actual = cats->count() + items->count();
+				descendents_actual = cats->size() + items->size();
 			}
 			if(descendents_server == descendents_actual)
 			{
@@ -1727,12 +1727,12 @@ LLInventoryModel::EHasChildren LLInventoryModel::categoryHasChildren(
 
 	// Shouldn't have to run this, but who knows.
 	parent_cat_map_t::const_iterator cat_it = mParentChildCategoryTree.find(cat->getUUID());
-	if (cat_it != mParentChildCategoryTree.end() && cat_it->second->count() > 0)
+	if (cat_it != mParentChildCategoryTree.end() && cat_it->second->size() > 0)
 	{
 		return CHILDREN_YES;
 	}
 	parent_item_map_t::const_iterator item_it = mParentChildItemTree.find(cat->getUUID());
-	if (item_it != mParentChildItemTree.end() && item_it->second->count() > 0)
+	if (item_it != mParentChildItemTree.end() && item_it->second->size() > 0)
 	{
 		return CHILDREN_YES;
 	}
@@ -1752,7 +1752,7 @@ bool LLInventoryModel::isCategoryComplete(const LLUUID& cat_id) const
 		S32 descendents_actual = 0;
 		if(cats && items)
 		{
-			descendents_actual = cats->count() + items->count();
+			descendents_actual = cats->size() + items->size();
 		}
 		if(descendents_server == descendents_actual)
 		{
@@ -1850,7 +1850,7 @@ bool LLInventoryModel::loadSkeleton(
 			// found to generate a set of categories we should add. We
 			// will go through each category loaded and if the version
 			// does not match, invalidate the version.
-			S32 count = categories.count();
+			S32 count = categories.size();
 			cat_set_t::iterator not_cached = temp_cats.end();
 			std::set<LLUUID> cached_ids;
 			for(S32 i = 0; i < count; ++i)
@@ -2060,7 +2060,7 @@ void LLInventoryModel::buildParentChildMap()
 	for(cat_map_t::iterator cit = mCategoryMap.begin(); cit != mCategoryMap.end(); ++cit)
 	{
 		LLViewerInventoryCategory* cat = cit->second;
-		cats.put(cat);
+		cats.push_back(cat);
 		if (mParentChildCategoryTree.count(cat->getUUID()) == 0)
 		{
 			llassert_always(mCategoryLock[cat->getUUID()] == false);
@@ -2088,16 +2088,16 @@ void LLInventoryModel::buildParentChildMap()
 	// Now we have a structure with all of the categories that we can
 	// iterate over and insert into the correct place in the child
 	// category tree. 
-	S32 count = cats.count();
+	S32 count = cats.size();
 	S32 i;
 	S32 lost = 0;
 	for(i = 0; i < count; ++i)
 	{
-		LLViewerInventoryCategory* cat = cats.get(i);
+		LLViewerInventoryCategory* cat = cats.at(i);
 		catsp = getUnlockedCatArray(cat->getParentUUID());
 		if(catsp)
 		{
-			catsp->put(cat);
+			catsp->push_back(cat);
 		}
 		else
 		{
@@ -2130,7 +2130,7 @@ void LLInventoryModel::buildParentChildMap()
 			catsp = getUnlockedCatArray(cat->getParentUUID());
 			if(catsp)
 			{
-				catsp->put(cat);
+				catsp->push_back(cat);
 			}
 			else
 			{		
@@ -2157,20 +2157,20 @@ void LLInventoryModel::buildParentChildMap()
 		for(item_map_t::iterator iit = mItemMap.begin(); iit != mItemMap.end(); ++iit)
 		{
 			item = (*iit).second;
-			items.put(item);
+			items.push_back(item);
 		}
 	}
-	count = items.count();
+	count = items.size();
 	lost = 0;
 	uuid_vec_t lost_item_ids;
 	for(i = 0; i < count; ++i)
 	{
 		LLPointer<LLViewerInventoryItem> item;
-		item = items.get(i);
+		item = items.at(i);
 		itemsp = getUnlockedItemArray(item->getParentUUID());
 		if(itemsp)
 		{
-			itemsp->put(item);
+			itemsp->push_back(item);
 		}
 		else
 		{
@@ -2187,7 +2187,7 @@ void LLInventoryModel::buildParentChildMap()
 			itemsp = getUnlockedItemArray(item->getParentUUID());
 			if(itemsp)
 			{
-				itemsp->put(item);
+				itemsp->push_back(item);
 			}
 			else
 			{
@@ -2355,7 +2355,7 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
 			LLPointer<LLViewerInventoryCategory> inv_cat = new LLViewerInventoryCategory(LLUUID::null);
 			if(inv_cat->importFileLocal(file))
 			{
-				categories.put(inv_cat);
+				categories.push_back(inv_cat);
 			}
 			else
 			{
@@ -2383,7 +2383,7 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
 				}
 				else
 				{
-					items.put(inv_item);
+					items.push_back(inv_item);
 				}
 			}
 			else
@@ -2423,7 +2423,7 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
 	}
 
 	fprintf(file, "\tinv_cache_version\t%d\n",sCurrentInvCacheVersion);
-	S32 count = categories.count();
+	S32 count = categories.size();
 	S32 i;
 	for(i = 0; i < count; ++i)
 	{
@@ -2434,7 +2434,7 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
 		}
 	}
 
-	count = items.count();
+	count = items.size();
 	for(i = 0; i < count; ++i)
 	{
 		items[i]->exportFile(file);
diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h
index 964adf5e50..69dba495d7 100755
--- a/indra/newview/llinventorymodel.h
+++ b/indra/newview/llinventorymodel.h
@@ -29,7 +29,6 @@
 
 #include "llassettype.h"
 #include "llfoldertype.h"
-#include "lldarray.h"
 #include "llframetimer.h"
 #include "llcurl.h"
 #include "lluuid.h"
@@ -75,8 +74,8 @@ public:
 		CHILDREN_MAYBE
 	};
 
-	typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t;
-	typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
+	typedef std::vector<LLPointer<LLViewerInventoryCategory> > cat_array_t;
+	typedef std::vector<LLPointer<LLViewerInventoryItem> > item_array_t;
 	typedef std::set<LLUUID> changed_items_t;
 
 	class fetchInventoryResponder : public LLCurl::Responder
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 9db175ec2e..1083a6b37d 100755
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -398,7 +398,7 @@ BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInven
 		// from memory.
 		return TRUE;
 	}
-	const S32 current_num_known_descendents = cats->count() + items->count();
+	const S32 current_num_known_descendents = cats->size() + items->size();
 	
 	// Got the number of descendents that we were expecting, so we're done.
 	if (current_num_known_descendents == expected_num_descendents)
@@ -724,7 +724,7 @@ void LLInventoryCategoriesObserver::changed(U32 mask)
 			continue;
 		}
 		
-		const S32 current_num_known_descendents = cats->count() + items->count();
+		const S32 current_num_known_descendents = cats->size() + items->size();
 
 		LLCategoryData& cat_data = (*iter).second;
 
@@ -791,7 +791,7 @@ bool LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t
 		}
 		else
 		{
-			current_num_known_descendents = cats->count() + items->count();
+			current_num_known_descendents = cats->size() + items->size();
 		}
 	}
 
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 4fdb05bc82..8190887ba6 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -1024,7 +1024,7 @@ bool LLInventoryPanel::beginIMSession()
 
 	std::string name;
 
-	LLDynamicArray<LLUUID> members;
+	std::vector<LLUUID> members;
 	EInstantMessage type = IM_SESSION_CONFERENCE_START;
 
 	std::set<LLFolderViewItem*>::const_iterator iter;
@@ -1052,7 +1052,7 @@ bool LLInventoryPanel::beginIMSession()
 												item_array,
 												LLInventoryModel::EXCLUDE_TRASH,
 												is_buddy);
-				S32 count = item_array.count();
+				S32 count = item_array.size();
 				if(count > 0)
 				{
 					//*TODO by what to replace that?
@@ -1063,10 +1063,10 @@ bool LLInventoryPanel::beginIMSession()
 					LLUUID id;
 					for(S32 i = 0; i < count; ++i)
 					{
-						id = item_array.get(i)->getCreatorUUID();
+						id = item_array.at(i)->getCreatorUUID();
 						if(at.isBuddyOnline(id))
 						{
-							members.put(id);
+							members.push_back(id);
 						}
 					}
 				}
@@ -1086,7 +1086,7 @@ bool LLInventoryPanel::beginIMSession()
 
 						if(at.isBuddyOnline(id))
 						{
-							members.put(id);
+							members.push_back(id);
 						}
 					}
 				} //if IT_CALLINGCARD
diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h
index 00a90325ad..8b50a43a84 100755
--- a/indra/newview/llinventorypanel.h
+++ b/indra/newview/llinventorypanel.h
@@ -29,7 +29,6 @@
 #define LL_LLINVENTORYPANEL_H
 
 #include "llassetstorage.h"
-#include "lldarray.h"
 #include "llfolderviewitem.h"
 #include "llfolderviewmodelinventory.h"
 #include "llfloater.h"
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index 2d7454b636..60272749ff 100755
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -292,7 +292,7 @@ void LLLogChat::saveHistory(const std::string& filename,
 	if (tmp_filename.empty())
 	{
 		std::string warn = "Chat history filename [" + filename + "] is empty!";
-		llwarning(warn, 666);
+		LL_WARNS() << warn << LL_ENDL;
 		llassert(tmp_filename.size());
 		return;
 	}
@@ -662,7 +662,7 @@ void LLChatLogFormatter::format(const LLSD& im, std::ostream& ostr) const
 {
 	if (!im.isMap())
 	{
-		llwarning("invalid LLSD type of an instant message", 0);
+		LL_WARNS() << "invalid LLSD type of an instant message" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp
index a7d6cb5eac..edb2d5e024 100755
--- a/indra/newview/llmanip.cpp
+++ b/indra/newview/llmanip.cpp
@@ -226,11 +226,11 @@ BOOL LLManip::handleHover(S32 x, S32 y, MASK mask)
 			setMouseCapture( FALSE );
 		}
 
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLManip (active)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLManip (active)" << llendl;
 	}
 	else
 	{
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLManip (inactive)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLManip (inactive)" << llendl;
 	}
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);
 	return TRUE;
diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp
index 9b05c75617..e2be3331ed 100755
--- a/indra/newview/llmaniprotate.cpp
+++ b/indra/newview/llmaniprotate.cpp
@@ -519,12 +519,12 @@ BOOL LLManipRotate::handleHover(S32 x, S32 y, MASK mask)
 			drag(x, y);
 		}
 
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipRotate (active)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipRotate (active)" << llendl;		
 	}
 	else
 	{
 		highlightManipulators(x, y);
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipRotate (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipRotate (inactive)" << llendl;		
 	}
 
 	gViewerWindow->setCursor(UI_CURSOR_TOOLROTATE);
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index 15788d6ffd..b4348f2a0e 100755
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -413,7 +413,7 @@ BOOL LLManipScale::handleHover(S32 x, S32 y, MASK mask)
 		{
 			drag( x, y );
 		}
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipScale (active)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipScale (active)" << llendl;		
 	}
 	else
 	{
@@ -543,7 +543,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
 		}
 	}
 
-	lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipScale (inactive)" << llendl;
+	LL_DEBUGS("UserInput") << "hover handled by LLManipScale (inactive)" << llendl;
 }
 
 
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 01337cfaed..cfea8a3330 100755
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -412,7 +412,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	// Bail out if mouse not down.
 	if( !hasMouseCapture() )
 	{
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (inactive)" << llendl;		
 		// Always show cursor
 		// gViewerWindow->setCursor(UI_CURSOR_ARROW);
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
@@ -448,7 +448,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	// rotation above.
 	if( x == mLastHoverMouseX && y == mLastHoverMouseY && !rotated)
 	{
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (mouse unmoved)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (mouse unmoved)" << llendl;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
@@ -461,7 +461,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	{
 		if (abs(mMouseDownX - x) < MOUSE_DRAG_SLOP && abs(mMouseDownY - y) < MOUSE_DRAG_SLOP )
 		{
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (mouse inside slop)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (mouse inside slop)" << llendl;
 			gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 			return TRUE;
 		}
@@ -478,7 +478,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 
 				// When we make the copy, we don't want to do any other processing.
 				// If so, the object will also be moved, and the copy will be offset.
-				lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (made copy)" << llendl;
+				LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (made copy)" << llendl;
 				gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 			}
 		}
@@ -531,7 +531,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 
 		if (relative_move.magVecSquared() > max_drag_distance * max_drag_distance)
 		{
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (too far)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (too far)" << llendl;
 			gViewerWindow->setCursor(UI_CURSOR_NOLOCKED);
 			return TRUE;
 		}
@@ -776,7 +776,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	gAgentCamera.clearFocusObject();
 	dialog_refresh_all();		// ??? is this necessary?
 
-	lldebugst(LLERR_USER_INPUT) << "hover handled by LLManipTranslate (active)" << llendl;
+	LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (active)" << llendl;
 	gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 	return TRUE;
 }
diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp
index 7f396b7b7e..3417651ddb 100755
--- a/indra/newview/llnamelistctrl.cpp
+++ b/indra/newview/llnamelistctrl.cpp
@@ -125,7 +125,7 @@ BOOL LLNameListCtrl::handleDragAndDrop(
 	}
 
 	handled = TRUE;
-	lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLNameListCtrl " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLNameListCtrl " << getName() << llendl;
 
 	return handled;
 }
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index 679b1bdcda..b6a9aae213 100755
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -29,7 +29,6 @@
 
 #include "llagent.h"
 #include "llavataractions.h"
-#include "llavatarconstants.h"	// AVATAR_ONLINE
 #include "llcallingcard.h"
 #include "llcombobox.h"
 #include "lldateutil.h"			// ageFromDate()
diff --git a/indra/newview/llpanelcontents.h b/indra/newview/llpanelcontents.h
index 62ccb64a4c..ad62e13bc2 100755
--- a/indra/newview/llpanelcontents.h
+++ b/indra/newview/llpanelcontents.h
@@ -31,7 +31,6 @@
 #include "llpanel.h"
 #include "llinventory.h"
 #include "lluuid.h"
-#include "llmap.h"
 #include "llviewerobject.h"
 #include "llvoinventorylistener.h"
 
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index a499fa1d87..5bdd88dd50 100755
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -1071,7 +1071,7 @@ void LLPanelEditWearable::saveChanges(bool force_save_as)
 			LLAppearanceMgr::instance().findCOFItemLinks(mWearablePtr->getItemID());
 		if (links.size()>0)
 		{
-			link_item = links.get(0).get();
+			link_item = links.at(0).get();
 			if (link_item && link_item->getIsLinkType())
 			{
 				description = link_item->getActualDescription();
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index 7ef427fa3e..df37a188fa 100755
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -1323,7 +1323,7 @@ void LLPanelFace::updateUI()
 				// to avoid getting overwritten with the default on some UI state changes.
 				//
 				if (!material->getSpecularID().isNull())
-		{
+				{
 					getChild<LLColorSwatchCtrl>("shinycolorswatch")->setOriginal(material->getSpecularLightColor());
 					getChild<LLColorSwatchCtrl>("shinycolorswatch")->set(material->getSpecularLightColor(),TRUE);
 				}
@@ -1334,9 +1334,9 @@ void LLPanelFace::updateUI()
 		
 				if ( ((channel_to_edit == LLRender::NORMAL_MAP) && material->getNormalID().isNull())
 					||((channel_to_edit == LLRender::SPECULAR_MAP) && material->getSpecularID().isNull()))
-		{
+				{
 					channel_to_edit = LLRender::DIFFUSE_MAP;
-		}
+				}
 
 				LLSelectMgr::getInstance()->setTextureChannel(channel_to_edit);
 
@@ -1345,15 +1345,15 @@ void LLPanelFace::updateUI()
 				texture_ctrl->setImageAssetID(material->getNormalID());
 
 				if (!material->getNormalID().isNull())
-		{
+				{
 					material->getNormalOffset(offset_x,offset_y);
 					material->getNormalRepeat(repeat_x,repeat_y);
 
 					if (identical_planar_texgen)
-				{
+					{
 						repeat_x *= 2.0f;
 						repeat_y *= 2.0f;
-				}
+					}
 			
 					rot = material->getNormalRotation();
 					getChild<LLUICtrl>("bumpyScaleU")->setValue(repeat_x);
@@ -1398,7 +1398,7 @@ void LLPanelFace::updateUI()
 		if(mColorSwatch)
 		{
 			mColorSwatch->setEnabled( FALSE );			
-			mColorSwatch->setFallbackImageName("locked_image.j2c" );
+			mColorSwatch->setFallbackImage(LLUI::getUIImage("locked_image.j2c") );
 			mColorSwatch->setValid(FALSE);
 		}
 		getChildView("color trans")->setEnabled(FALSE);
diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp
index c927aeacb3..524305e3fe 100755
--- a/indra/newview/llpanelgrouplandmoney.cpp
+++ b/indra/newview/llpanelgrouplandmoney.cpp
@@ -131,7 +131,7 @@ public:
 
 
 
-	static LLMap<LLUUID, LLGroupMoneyTabEventHandler*> sInstanceIDs;
+	static std::map<LLUUID, LLGroupMoneyTabEventHandler*> sInstanceIDs;
 	static std::map<LLPanel*, LLGroupMoneyTabEventHandler*> sTabsToHandlers;
 protected:
 	LLGroupMoneyTabEventHandlerImpl* mImplementationp;
@@ -534,7 +534,7 @@ void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg)
 
 
 //static
-LLMap<LLUUID, LLPanelGroupLandMoney*> LLPanelGroupLandMoney::sGroupIDs;
+std::map<LLUUID, LLPanelGroupLandMoney*> LLPanelGroupLandMoney::sGroupIDs;
 
 LLPanelGroupLandMoney::LLPanelGroupLandMoney() :
 	LLPanelGroupTab() 
@@ -547,13 +547,13 @@ LLPanelGroupLandMoney::LLPanelGroupLandMoney() :
 	//will then only be working for the last panel for a given group id :(
 
 	//FIXME - add to setGroupID()
-	//LLPanelGroupLandMoney::sGroupIDs.addData(group_id, this);
+	//LLPanelGroupLandMoney::sGroupIDs.insert(group_id, this);
 }
 
 LLPanelGroupLandMoney::~LLPanelGroupLandMoney()
 {
 	delete mImplementationp;
-	LLPanelGroupLandMoney::sGroupIDs.removeData(mGroupID);
+	LLPanelGroupLandMoney::sGroupIDs.erase(mGroupID);
 }
 
 void LLPanelGroupLandMoney::activate()
@@ -821,15 +821,15 @@ void LLPanelGroupLandMoney::processPlacesReply(LLMessageSystem* msg, void**)
 	LLUUID group_id;
 	msg->getUUID("AgentData", "QueryID", group_id);
 
-	LLPanelGroupLandMoney* selfp = sGroupIDs.getIfThere(group_id);
-	if(!selfp)
+	group_id_map_t::iterator found_it = sGroupIDs.find(group_id);
+	if(found_it == sGroupIDs.end())
 	{
 		llinfos << "Group Panel Land L$ " << group_id << " no longer in existence."
 				<< llendl;
 		return;
 	}
 
-	selfp->mImplementationp->processGroupLand(msg);
+	found_it->second->mImplementationp->processGroupLand(msg);
 }
 
 
@@ -885,7 +885,7 @@ void LLGroupMoneyTabEventHandlerImpl::updateButtons()
 //** LLGroupMoneyTabEventHandler Functions **
 //*******************************************
 
-LLMap<LLUUID, LLGroupMoneyTabEventHandler*> LLGroupMoneyTabEventHandler::sInstanceIDs;
+std::map<LLUUID, LLGroupMoneyTabEventHandler*> LLGroupMoneyTabEventHandler::sInstanceIDs;
 std::map<LLPanel*, LLGroupMoneyTabEventHandler*> LLGroupMoneyTabEventHandler::sTabsToHandlers;
 
 LLGroupMoneyTabEventHandler::LLGroupMoneyTabEventHandler(LLButton* earlier_buttonp,
@@ -922,13 +922,13 @@ LLGroupMoneyTabEventHandler::LLGroupMoneyTabEventHandler(LLButton* earlier_butto
 		tab_containerp->setCommitCallback(boost::bind(&LLGroupMoneyTabEventHandler::onClickTab, this));
 	}
 
-	sInstanceIDs.addData(mImplementationp->mPanelID, this);
+	sInstanceIDs.insert(std::make_pair(mImplementationp->mPanelID, this));
 	sTabsToHandlers[panelp] = this;
 }
 
 LLGroupMoneyTabEventHandler::~LLGroupMoneyTabEventHandler()
 {
-	sInstanceIDs.removeData(mImplementationp->mPanelID);
+	sInstanceIDs.erase(mImplementationp->mPanelID);
 	sTabsToHandlers.erase(mImplementationp->mTabPanelp);
 
 	delete mImplementationp;
@@ -1122,10 +1122,10 @@ void LLPanelGroupLandMoney::processGroupAccountDetailsReply(LLMessageSystem* msg
 
 	LLUUID request_id;
 	msg->getUUIDFast(_PREHASH_MoneyData, _PREHASH_RequestID, request_id );
-	LLGroupMoneyTabEventHandler* selfp = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
+	LLGroupMoneyTabEventHandler* selfp = get_ptr_in_map(LLGroupMoneyTabEventHandler::sInstanceIDs, request_id);
 	if (!selfp)
 	{
-		llwarns << "GroupAccountDetails recieved for non-existent group panel." << llendl;
+		llwarns << "GroupAccountDetails received for non-existent group panel." << llendl;
 		return;
 	}
 
@@ -1302,7 +1302,7 @@ void LLPanelGroupLandMoney::processGroupAccountTransactionsReply(LLMessageSystem
 
 	LLGroupMoneyTabEventHandler* self;
 
-	self = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
+	self = get_ptr_in_map(LLGroupMoneyTabEventHandler::sInstanceIDs, request_id);
 	if (!self)
 	{
 		llwarns << "GroupAccountTransactions recieved for non-existent group panel." << llendl;
@@ -1482,7 +1482,7 @@ void LLPanelGroupLandMoney::processGroupAccountSummaryReply(LLMessageSystem* msg
 
 	LLGroupMoneyTabEventHandler* self;
 
-	self = LLGroupMoneyTabEventHandler::sInstanceIDs.getIfThere(request_id);
+	self = get_ptr_in_map(LLGroupMoneyTabEventHandler::sInstanceIDs, request_id);
 	if (!self)
 	{
 		llwarns << "GroupAccountSummary recieved for non-existent group L$ planning tab." << llendl;
@@ -1494,9 +1494,9 @@ void LLPanelGroupLandMoney::processGroupAccountSummaryReply(LLMessageSystem* msg
 
 void LLPanelGroupLandMoney::setGroupID(const LLUUID& id)
 {
-	LLPanelGroupLandMoney::sGroupIDs.removeData(mGroupID);
+	LLPanelGroupLandMoney::sGroupIDs.erase(mGroupID);
 	LLPanelGroupTab::setGroupID(id);
-	LLPanelGroupLandMoney::sGroupIDs.addData(mGroupID, this);
+	LLPanelGroupLandMoney::sGroupIDs.insert(std::make_pair(mGroupID, this));
 
 
 	bool can_view = gAgent.isInGroup(mGroupID);
diff --git a/indra/newview/llpanelgrouplandmoney.h b/indra/newview/llpanelgrouplandmoney.h
index ac3518ee19..3cec6065e7 100755
--- a/indra/newview/llpanelgrouplandmoney.h
+++ b/indra/newview/llpanelgrouplandmoney.h
@@ -28,7 +28,7 @@
 #define LL_PANEL_GROUP_LAND_MONEY_H
 
 #include "llpanelgroup.h"
-#include "llmap.h"
+#include <map>
 #include "lluuid.h"
 
 class LLPanelGroupLandMoney : public LLPanelGroupTab
@@ -47,7 +47,8 @@ public:
 
 	static void processPlacesReply(LLMessageSystem* msg, void**);
 
-	static LLMap<LLUUID, LLPanelGroupLandMoney*> sGroupIDs;
+	typedef std::map<LLUUID, LLPanelGroupLandMoney*> group_id_map_t;
+	static group_id_map_t sGroupIDs;
 
 	static void processGroupAccountDetailsReply(LLMessageSystem* msg,  void** data);
 	static void processGroupAccountTransactionsReply(LLMessageSystem* msg, void** data);
diff --git a/indra/newview/llpanellandmarkinfo.cpp b/indra/newview/llpanellandmarkinfo.cpp
index 5c9b968ac9..79815e7be5 100755
--- a/indra/newview/llpanellandmarkinfo.cpp
+++ b/indra/newview/llpanellandmarkinfo.cpp
@@ -446,9 +446,9 @@ void LLPanelLandmarkInfo::populateFoldersList()
 	typedef std::vector<folder_pair_t> folder_vec_t;
 	folder_vec_t folders;
 	// Sort the folders by their full name.
-	for (S32 i = 0; i < cats.count(); i++)
+	for (S32 i = 0; i < cats.size(); i++)
 	{
-		const LLViewerInventoryCategory* cat = cats.get(i);
+		const LLViewerInventoryCategory* cat = cats.at(i);
 		std::string cat_full_name = getFullFolderName(cat);
 		folders.push_back(folder_pair_t(cat->getUUID(), cat_full_name));
 	}
@@ -487,6 +487,6 @@ static void collectLandmarkFolders(LLInventoryModel::cat_array_t& cats)
 	}
 	else
 	{
-		cats.put(favorites_cat);
+		cats.push_back(favorites_cat);
 	}
 }
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index bcb90bcb56..c96173f550 100755
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -33,7 +33,6 @@
 #include "llfloaterreg.h"
 #include "llfontgl.h"
 #include "llmd5.h"
-#include "llsecondlifeurls.h"
 #include "v4color.h"
 
 #include "llappviewer.h"
@@ -545,13 +544,13 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential,
 	LLStringUtil::trim(username);
 	std::string password = sInstance->getChild<LLUICtrl>("password_edit")->getValue().asString();
 
-	LL_INFOS2("Credentials", "Authentication") << "retrieving username:" << username << LL_ENDL;
+	LL_INFOS("Credentials", "Authentication") << "retrieving username:" << username << LL_ENDL;
 	// determine if the username is a first/last form or not.
 	size_t separator_index = username.find_first_of(' ');
 	if (separator_index == username.npos
 		&& !LLGridManager::getInstance()->isSystemGrid())
 	{
-		LL_INFOS2("Credentials", "Authentication") << "account: " << username << LL_ENDL;
+		LL_INFOS("Credentials", "Authentication") << "account: " << username << LL_ENDL;
 		// single username, so this is a 'clear' identifier
 		identifier["type"] = CRED_IDENTIFIER_TYPE_ACCOUNT;
 		identifier["account_name"] = username;
@@ -586,7 +585,7 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential,
 		
 		if (last.find_first_of(' ') == last.npos)
 		{
-			LL_INFOS2("Credentials", "Authentication") << "agent: " << username << LL_ENDL;
+			LL_INFOS("Credentials", "Authentication") << "agent: " << username << LL_ENDL;
 			// traditional firstname / lastname
 			identifier["type"] = CRED_IDENTIFIER_TYPE_AGENT;
 			identifier["first_name"] = first;
diff --git a/indra/newview/llpanelme.cpp b/indra/newview/llpanelme.cpp
index a9af56f750..4a3840c498 100755
--- a/indra/newview/llpanelme.cpp
+++ b/indra/newview/llpanelme.cpp
@@ -30,7 +30,6 @@
 
 // Viewer includes
 #include "llpanelprofile.h"
-#include "llavatarconstants.h"
 #include "llagent.h"
 #include "llagentcamera.h"
 #include "llagentwearables.h"
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index d7130820ab..94cb90b993 100755
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -1753,7 +1753,7 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li
 	LLUIColor item_color = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE);
 
 	// Find all in the first pass
-	LLDynamicArray<obj_folder_pair*> child_categories;
+	std::vector<obj_folder_pair*> child_categories;
 	LLTaskInvFVBridge* bridge;
 	LLFolderViewItem* view;
 
@@ -1780,7 +1780,7 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li
 				p.font_color = item_color;
 				p.font_highlight_color = item_color;
 				view = LLUICtrlFactory::create<LLFolderViewFolder>(p);
-				child_categories.put(new obj_folder_pair(obj,
+				child_categories.push_back(new obj_folder_pair(obj,
 														 (LLFolderViewFolder*)view));
 			}
 			else
@@ -1802,7 +1802,7 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li
 	}
 
 	// now, for each category, do the second pass
-	for(S32 i = 0; i < child_categories.count(); i++)
+	for(S32 i = 0; i < child_categories.size(); i++)
 	{
 		createViewsForCategory(inventory, child_categories[i]->first,
 							   child_categories[i]->second );
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index cfbc8f1a94..f2ef2ec003 100755
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -30,7 +30,6 @@
 
 #include "llagent.h"
 #include "llagentpicksinfo.h"
-#include "llavatarconstants.h"
 #include "llcommandhandler.h"
 #include "lldispatcher.h"
 #include "llflatlistview.h"
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 0756faf5c0..018efbbc5c 100755
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -416,7 +416,7 @@ BOOL LLTeleportHistoryPanel::postBuild()
 				// All accordion tabs are collapsed initially
 				setAccordionCollapsedByUser(tab, true);
 
-				mItemContainers.put(tab);
+				mItemContainers.push_back(tab);
 
 				LLFlatListView* fl = getFlatListViewFromTab(tab);
 				if (fl)
@@ -432,14 +432,14 @@ BOOL LLTeleportHistoryPanel::postBuild()
 		// Open first 2 accordion tabs
 		if (mItemContainers.size() > 1)
 		{
-			LLAccordionCtrlTab* tab = mItemContainers.get(mItemContainers.size() - 1);
+			LLAccordionCtrlTab* tab = mItemContainers.at(mItemContainers.size() - 1);
 			tab->setDisplayChildren(true);
 			setAccordionCollapsedByUser(tab, false);
 		}
 
 		if (mItemContainers.size() > 2)
 		{
-			LLAccordionCtrlTab* tab = mItemContainers.get(mItemContainers.size() - 2);
+			LLAccordionCtrlTab* tab = mItemContainers.at(mItemContainers.size() - 2);
 			tab->setDisplayChildren(true);
 			setAccordionCollapsedByUser(tab, false);
 		}
@@ -683,7 +683,7 @@ void LLTeleportHistoryPanel::refresh()
 			tab_idx = mItemContainers.size() - 1 - tab_idx;
 			if (tab_idx >= 0)
 			{
-				LLAccordionCtrlTab* tab = mItemContainers.get(tab_idx);
+				LLAccordionCtrlTab* tab = mItemContainers.at(tab_idx);
 				tab->setVisible(true);
 
 				// Expand all accordion tabs when filtering
@@ -730,7 +730,7 @@ void LLTeleportHistoryPanel::refresh()
 
 	for (S32 n = mItemContainers.size() - 1; n >= 0; --n)
 	{
-		LLAccordionCtrlTab* tab = mItemContainers.get(n);
+		LLAccordionCtrlTab* tab = mItemContainers.at(n);
 		LLFlatListView* fv = getFlatListViewFromTab(tab);
 		if (fv)
 		{
@@ -792,7 +792,7 @@ void LLTeleportHistoryPanel::replaceItem(S32 removed_index)
 	// to point to the right item in LLTeleportHistoryStorage
 	for (S32 tab_idx = mItemContainers.size() - 1; tab_idx >= 0; --tab_idx)
 	{
-		LLAccordionCtrlTab* tab = mItemContainers.get(tab_idx);
+		LLAccordionCtrlTab* tab = mItemContainers.at(tab_idx);
 		if (!tab->getVisible())
 			continue;
 
@@ -846,7 +846,7 @@ void LLTeleportHistoryPanel::showTeleportHistory()
 
 	for (S32 n = mItemContainers.size() - 1; n >= 0; --n)
 	{
-		LLAccordionCtrlTab* tab = mItemContainers.get(n);
+		LLAccordionCtrlTab* tab = mItemContainers.at(n);
 		if (tab)
 		{
 			tab->setVisible(false);
@@ -873,7 +873,7 @@ void LLTeleportHistoryPanel::handleItemSelect(LLFlatListView* selected)
 
 	for (S32 n = 0; n < tabs_cnt; n++)
 	{
-		LLAccordionCtrlTab* tab = mItemContainers.get(n);
+		LLAccordionCtrlTab* tab = mItemContainers.at(n);
 
 		if (!tab->getVisible())
 			continue;
@@ -958,7 +958,7 @@ void LLTeleportHistoryPanel::onExpandAllFolders()
 
 	for (S32 n = 0; n < tabs_cnt; n++)
 	{
-		mItemContainers.get(n)->setDisplayChildren(true);
+		mItemContainers.at(n)->setDisplayChildren(true);
 	}
 	mHistoryAccordion->arrange();
 }
@@ -969,7 +969,7 @@ void LLTeleportHistoryPanel::onCollapseAllFolders()
 
 	for (S32 n = 0; n < tabs_cnt; n++)
 	{
-		mItemContainers.get(n)->setDisplayChildren(false);
+		mItemContainers.at(n)->setDisplayChildren(false);
 	}
 	mHistoryAccordion->arrange();
 
@@ -1024,7 +1024,7 @@ bool LLTeleportHistoryPanel::isActionEnabled(const LLSD& userdata) const
 
 	for (S32 n = 0; n < tabs_cnt; n++)
 	{
-		LLAccordionCtrlTab* tab = mItemContainers.get(n);
+		LLAccordionCtrlTab* tab = mItemContainers.at(n);
 		if (!tab->getVisible())
 			continue;
 
diff --git a/indra/newview/llpanelteleporthistory.h b/indra/newview/llpanelteleporthistory.h
index 47b607a2f4..b88861c5c6 100755
--- a/indra/newview/llpanelteleporthistory.h
+++ b/indra/newview/llpanelteleporthistory.h
@@ -112,7 +112,7 @@ private:
 	bool				mDirty;
 	S32				mCurrentItem;
 
-	typedef LLDynamicArray<LLAccordionCtrlTab*> item_containers_t;
+	typedef std::vector<LLAccordionCtrlTab*> item_containers_t;
 	item_containers_t mItemContainers;
 
 	ContextMenu mContextMenu;
diff --git a/indra/newview/llphysicsshapebuilderutil.h b/indra/newview/llphysicsshapebuilderutil.h
index 7dedfb05e2..bd5b7d799c 100755
--- a/indra/newview/llphysicsshapebuilderutil.h
+++ b/indra/newview/llphysicsshapebuilderutil.h
@@ -41,6 +41,8 @@
 #define SHAPE_BUILDER_IMPLICIT_THRESHOLD_TWIST 0.09f
 #define SHAPE_BUILDER_IMPLICIT_THRESHOLD_SHEAR 0.05f
 
+const F32 COLLISION_TOLERANCE = 0.1f;
+
 const F32 SHAPE_BUILDER_ENTRY_SNAP_SCALE_BIN_SIZE = 0.15f;
 const F32 SHAPE_BUILDER_ENTRY_SNAP_PARAMETER_BIN_SIZE = 0.010f;
 const F32 SHAPE_BUILDER_CONVEXIFICATION_SIZE = 2.f * COLLISION_TOLERANCE;
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index 04934b13f1..3675d8694d 100755
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -25,7 +25,6 @@
  */
 
 #include "llviewerprecompiledheaders.h"
-#include "stdenums.h"
 
 #include "llpreview.h"
 
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index bda603262d..36877696f5 100755
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -546,10 +546,10 @@ void LLPreviewGesture::addAnimations()
 	// Copy into something we can sort
 	std::vector<LLInventoryItem*> animations;
 
-	S32 count = items.count();
+	S32 count = items.size();
 	for(i = 0; i < count; ++i)
 	{
-		animations.push_back( items.get(i) );
+		animations.push_back( items.at(i) );
 	}
 
 	// Do the sort
@@ -592,10 +592,10 @@ void LLPreviewGesture::addSounds()
 	std::vector<LLInventoryItem*> sounds;
 
 	S32 i;
-	S32 count = items.count();
+	S32 count = items.size();
 	for(i = 0; i < count; ++i)
 	{
-		sounds.push_back( items.get(i) );
+		sounds.push_back( items.at(i) );
 	}
 
 	// Do the sort
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 516ecedbc8..bfc779c057 100755
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -1069,15 +1069,15 @@ struct LLEntryAndEdCore
 
 void LLScriptEdCore::deleteBridges()
 {
-	S32 count = mBridges.count();
+	S32 count = mBridges.size();
 	LLEntryAndEdCore* eandc;
 	for(S32 i = 0; i < count; i++)
 	{
-		eandc = mBridges.get(i);
+		eandc = mBridges.at(i);
 		delete eandc;
 		mBridges[i] = NULL;
 	}
-	mBridges.reset();
+	mBridges.clear();
 }
 
 // virtual
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 7563cecd9d..a799f3c167 100755
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -27,7 +27,6 @@
 #ifndef LL_LLPREVIEWSCRIPT_H
 #define LL_LLPREVIEWSCRIPT_H
 
-#include "lldarray.h"
 #include "llpreview.h"
 #include "lltabcontainer.h"
 #include "llinventory.h"
@@ -138,7 +137,7 @@ private:
 	BOOL			mForceClose;
 	LLPanel*		mCodePanel;
 	LLScrollListCtrl* mErrorList;
-	LLDynamicArray<LLEntryAndEdCore*> mBridges;
+	std::vector<LLEntryAndEdCore*> mBridges;
 	LLHandle<LLFloater>	mLiveHelpHandle;
 	LLKeywordToken* mLastHelpToken;
 	LLFrameTimer	mLiveHelpTimer;
diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp
index 0e0da6bdc7..b5edeb4a0e 100755
--- a/indra/newview/llscriptfloater.cpp
+++ b/indra/newview/llscriptfloater.cpp
@@ -234,7 +234,7 @@ void LLScriptFloater::onMouseDown()
 			// Remove new message icon
 			if (NULL == chicletp)
 			{
-				llerror("Dock chiclet for LLScriptFloater doesn't exist", 0);
+				LL_ERRS() << "Dock chiclet for LLScriptFloater doesn't exist" << LL_ENDL;
 			}
 			else
 			{
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index b47c2de768..06ad834f35 100755
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -104,6 +104,9 @@ const F32 SILHOUETTE_UPDATE_THRESHOLD_SQUARED = 0.02f;
 const S32 MAX_ACTION_QUEUE_SIZE = 20;
 const S32 MAX_SILS_PER_FRAME = 50;
 const S32 MAX_OBJECTS_PER_PACKET = 254;
+// For linked sets
+const S32 MAX_CHILDREN_PER_TASK = 255;
+const S32 MAX_CHILDREN_PER_PHYSICAL_TASK = 32;
 
 //
 // Globals
diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h
index d4b736640c..a68328167a 100755
--- a/indra/newview/llselectmgr.h
+++ b/indra/newview/llselectmgr.h
@@ -56,6 +56,33 @@ class LLColor4;
 class LLVector3;
 class LLSelectNode;
 
+const U8 UPD_NONE      		= 0x00;
+const U8 UPD_POSITION  		= 0x01;
+const U8 UPD_ROTATION  		= 0x02;
+const U8 UPD_SCALE     		= 0x04;
+const U8 UPD_LINKED_SETS 	= 0x08;
+const U8 UPD_UNIFORM 		= 0x10;	// used with UPD_SCALE
+
+// This is used by the DeRezObject message to determine where to put
+// derezed tasks.
+enum EDeRezDestination
+{
+	DRD_SAVE_INTO_AGENT_INVENTORY = 0,
+	DRD_ACQUIRE_TO_AGENT_INVENTORY = 1,		// try to leave copy in world
+	DRD_SAVE_INTO_TASK_INVENTORY = 2,
+	DRD_ATTACHMENT = 3,
+	DRD_TAKE_INTO_AGENT_INVENTORY = 4,		// delete from world
+	DRD_FORCE_TO_GOD_INVENTORY = 5,			// force take copy
+	DRD_TRASH = 6,
+	DRD_ATTACHMENT_TO_INV = 7,
+	DRD_ATTACHMENT_EXISTS = 8,
+	DRD_RETURN_TO_OWNER = 9,				// back to owner's inventory
+	DRD_RETURN_TO_LAST_OWNER = 10,			// deeded object back to last owner's inventory
+
+	DRD_COUNT = 11
+};
+
+
 const S32 SELECT_ALL_TES = -1;
 const S32 SELECT_MAX_TES = 32;
 
diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp
index dacea187c3..75e6b4f1a5 100755
--- a/indra/newview/llspeakers.cpp
+++ b/indra/newview/llspeakers.cpp
@@ -1038,7 +1038,7 @@ void LLLocalSpeakerMgr::updateSpeakerList()
 		if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY)
 		{
 			LLVOAvatar* avatarp = (LLVOAvatar*)gObjectList.findObject(speaker_id);
-			if (!avatarp || dist_vec_squared(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS_SQUARED)
+			if (!avatarp || dist_vec_squared(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS * CHAT_NORMAL_RADIUS)
 			{
 				setSpeakerNotInChannel(speakerp);
 			}
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 536c030637..e0b96e43a6 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -82,7 +82,6 @@
 #include "llvfs.h"
 #include "llxorcipher.h"	// saved password, MAC address
 #include "llwindow.h"
-#include "imageids.h"
 #include "message.h"
 #include "v3math.h"
 
@@ -241,6 +240,7 @@ static LLVector3 gAgentStartLookAt(1.0f, 0.f, 0.f);
 static std::string gAgentStartLocation = "safe";
 static bool mLoginStatePastUI = false;
 
+const S32 DEFAULT_MAX_AGENT_GROUPS = 25;
 
 boost::scoped_ptr<LLEventPump> LLStartUp::sStateWatcher(new LLEventStream("StartupState"));
 boost::scoped_ptr<LLStartupListener> LLStartUp::sListener(new LLStartupListener());
@@ -1431,8 +1431,8 @@ bool idle_startup()
 
 		LL_DEBUGS("AppInit") << "Initializing camera..." << LL_ENDL;
 		gFrameTime    = totalTime();
-		F32 last_time = gFrameTimeSeconds;
-		gFrameTimeSeconds = (S64)(gFrameTime - gStartTime)/SEC_TO_MICROSEC;
+		LLUnit<F32, LLUnits::Seconds> last_time = gFrameTimeSeconds;
+		gFrameTimeSeconds = (gFrameTime - gStartTime);
 
 		gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
 		if (gFrameIntervalSeconds < 0.f)
@@ -1933,6 +1933,7 @@ bool idle_startup()
 
 		LL_DEBUGS("AppInit") << "Initialization complete" << LL_ENDL;
 
+		LL_DEBUGS("SceneLoadTiming", "Start") << "Scene Load Started " << LL_ENDL;
 		gRenderStartTime.reset();
 		gForegroundTime.reset();
 
diff --git a/indra/newview/llstartup.h b/indra/newview/llstartup.h
index 760e38890b..e39810713a 100755
--- a/indra/newview/llstartup.h
+++ b/indra/newview/llstartup.h
@@ -45,6 +45,18 @@ bool login_alert_done(const LLSD& notification, const LLSD& response);
 extern std::string SCREEN_HOME_FILENAME;
 extern std::string SCREEN_LAST_FILENAME;
 
+// start location constants
+enum EStartLocation
+{
+	START_LOCATION_ID_LAST,
+	START_LOCATION_ID_HOME,
+	START_LOCATION_ID_DIRECT,
+	START_LOCATION_ID_PARCEL,
+	START_LOCATION_ID_TELEHUB,
+	START_LOCATION_ID_URL,
+	START_LOCATION_ID_COUNT
+};
+
 typedef enum {
 	STATE_FIRST,					// Initial startup
 	STATE_BROWSER_INIT,             // Initialize web browser for login screen
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index b385d5cdfa..c1d15947de 100755
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -72,7 +72,6 @@
 #include "lltrans.h"
 
 // library includes
-#include "imageids.h"
 #include "llfloaterreg.h"
 #include "llfontgl.h"
 #include "llrect.h"
diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp
index 93c7f54101..88eec48703 100755
--- a/indra/newview/llsurface.cpp
+++ b/indra/newview/llsurface.cpp
@@ -34,7 +34,7 @@
 #include "llpatchvertexarray.h"
 #include "patch_dct.h"
 #include "patch_code.h"
-#include "bitpack.h"
+#include "llbitpack.h"
 #include "llviewerobjectlist.h"
 #include "llregionhandle.h"
 #include "llagent.h"
diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp
index a9ba2bce9c..af51f9c7de 100755
--- a/indra/newview/llsurfacepatch.cpp
+++ b/indra/newview/llsurfacepatch.cpp
@@ -33,7 +33,6 @@
 #include "llsurface.h"
 #include "pipeline.h"
 #include "llagent.h"
-#include "timing.h"
 #include "llsky.h"
 #include "llviewercamera.h"
 
@@ -44,11 +43,11 @@
 #include "noise.h"
 
 extern bool gShiftFrame;
-extern U64 gFrameTime;
+extern LLUnitImplicit<U64, LLUnits::Microseconds> gFrameTime;
 extern LLPipeline gPipeline;
 
-LLSurfacePatch::LLSurfacePatch() :
-	mHasReceivedData(FALSE),
+LLSurfacePatch::LLSurfacePatch() 
+:	mHasReceivedData(FALSE),
 	mSTexUpdate(FALSE),
 	mDirty(FALSE),
 	mDirtyZStats(TRUE),
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index 3276b2b9e1..c09fe180f1 100755
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -354,7 +354,7 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop(
 	}
 
 	handled = TRUE;
-	lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFloaterTexturePicker " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLFloaterTexturePicker " << getName() << llendl;
 
 	return handled;
 }
@@ -666,10 +666,10 @@ const LLUUID& LLFloaterTexturePicker::findItemID(const LLUUID& asset_id, BOOL co
 							LLInventoryModel::INCLUDE_TRASH,
 							asset_id_matches);
 
-	if (items.count())
+	if (items.size())
 	{
 		// search for copyable version first
-		for (S32 i = 0; i < items.count(); i++)
+		for (S32 i = 0; i < items.size(); i++)
 		{
 			LLInventoryItem* itemp = items[i];
 			LLPermissions item_permissions = itemp->getPermissions();
@@ -1436,7 +1436,7 @@ BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
 	}
 
 	handled = TRUE;
-	lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLTextureCtrl " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLTextureCtrl " << getName() << llendl;
 
 	return handled;
 }
diff --git a/indra/newview/lltoastgroupnotifypanel.h b/indra/newview/lltoastgroupnotifypanel.h
index dfdc6ae559..431fd32da2 100755
--- a/indra/newview/lltoastgroupnotifypanel.h
+++ b/indra/newview/lltoastgroupnotifypanel.h
@@ -29,7 +29,6 @@
 
 #include "llfontgl.h"
 #include "lltoastpanel.h"
-#include "lldarray.h"
 #include "lltimer.h"
 #include "llviewermessage.h"
 #include "llnotificationptr.h"
diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp
index 2d8ce95347..f4499f2da8 100755
--- a/indra/newview/lltool.cpp
+++ b/indra/newview/lltool.cpp
@@ -103,7 +103,7 @@ BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
 BOOL LLTool::handleHover(S32 x, S32 y, MASK mask)
 {
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);
-	lldebugst(LLERR_USER_INPUT) << "hover handled by a tool" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by a tool" << llendl;		
 	// by default, do nothing, say we handled it
 	return TRUE;
 }
diff --git a/indra/newview/lltoolbrush.cpp b/indra/newview/lltoolbrush.cpp
index 08d82ea9cb..96b742aebc 100755
--- a/indra/newview/lltoolbrush.cpp
+++ b/indra/newview/lltoolbrush.cpp
@@ -401,7 +401,7 @@ BOOL LLToolBrushLand::handleMouseDown(S32 x, S32 y, MASK mask)
 
 BOOL LLToolBrushLand::handleHover( S32 x, S32 y, MASK mask )
 {
-	lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolBrushLand ("
+	LL_DEBUGS("UserInput") << "hover handled by LLToolBrushLand ("
 								<< (hasMouseCapture() ? "active":"inactive")
 								<< ")" << llendl;
 	mMouseX = x;
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index a4dce9efe8..ca28397d52 100755
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -255,7 +255,7 @@ void LLCategoryDropDescendentsObserver::done()
 			LLInventoryModel::EXCLUDE_TRASH);
 	}
 
-	S32 count = items.count();
+	S32 count = items.size();
 	if (count)
 	{
 		std::set<LLUUID> unique_ids;
@@ -407,16 +407,16 @@ void LLToolDragAndDrop::beginDrag(EDragAndDropType type,
 				items,
 				LLInventoryModel::EXCLUDE_TRASH,
 				is_not_preferred);
-			S32 count = cats.count();
+			S32 count = cats.size();
 			S32 i;
 			for(i = 0; i < count; ++i)
 			{
-				folder_ids.push_back(cats.get(i)->getUUID());
+				folder_ids.push_back(cats.at(i)->getUUID());
 			}
-			count = items.count();
+			count = items.size();
 			for(i = 0; i < count; ++i)
 			{
-				item_ids.push_back(items.get(i)->getUUID());
+				item_ids.push_back(items.at(i)->getUUID());
 			}
 			if (!folder_ids.empty() || !item_ids.empty())
 			{
@@ -478,7 +478,7 @@ void LLToolDragAndDrop::beginMultiDrag(
 					items,
 					LLInventoryModel::EXCLUDE_TRASH,
 					is_not_preferred);
-				S32 cat_count = cats.count();
+				S32 cat_count = cats.size();
 				for(S32 i = 0; i < cat_count; ++i)
 				{
 					cat_ids.insert(cat->getUUID());
@@ -597,7 +597,7 @@ BOOL LLToolDragAndDrop::handleHover( S32 x, S32 y, MASK mask )
 	ECursorType cursor = acceptanceToCursor(acceptance);
 	gViewerWindow->getWindow()->setCursor( cursor );
 
-	lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolDragAndDrop" << llendl;
+	LL_DEBUGS("UserInput") << "hover handled by LLToolDragAndDrop" << llendl;
 	return TRUE;
 }
 
@@ -2245,7 +2245,7 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory(
 					items,
 					LLInventoryModel::EXCLUDE_TRASH,
 					droppable);
-	cats.put(cat);
+	cats.push_back(cat);
  	if (droppable.countNoCopy() > 0)
  	{
  		llwarns << "*** Need to confirm this step" << llendl;
@@ -2487,7 +2487,7 @@ EAcceptance LLToolDragAndDrop::dad3dCategoryOnLand(
 									items,
 									LLInventoryModel::EXCLUDE_TRASH,
 									droppable);
-	if(items.count() > 0)
+	if(items.size() > 0)
 	{
 		rv = ACCEPT_YES_SINGLE;
 	}
@@ -2514,14 +2514,14 @@ EAcceptance LLToolDragAndDrop::dad3dAssetOnLand(
 	LLViewerInventoryItem::item_array_t items;
 	LLViewerInventoryItem::item_array_t copyable_items;
 	locateMultipleInventory(items, cats);
-	if(!items.count()) return ACCEPT_NO;
+	if(!items.size()) return ACCEPT_NO;
 	EAcceptance rv = ACCEPT_NO;
-	for (S32 i = 0; i < items.count(); i++)
+	for (S32 i = 0; i < items.size(); i++)
 	{
 		LLInventoryItem* item = items[i];
 		if(item->getPermissions().allowCopyBy(gAgent.getID()))
 		{
-			copyable_items.put(item);
+			copyable_items.push_back(item);
 			rv = ACCEPT_YES_SINGLE;
 		}
 	}
@@ -2593,21 +2593,21 @@ LLInventoryObject* LLToolDragAndDrop::locateInventory(
 LLInventoryObject* LLToolDragAndDrop::locateMultipleInventory(LLViewerInventoryCategory::cat_array_t& cats,
 															  LLViewerInventoryItem::item_array_t& items)
 {
-	if(mCargoIDs.count() == 0) return NULL;
+	if(mCargoIDs.size() == 0) return NULL;
 	if((mSource == SOURCE_AGENT) || (mSource == SOURCE_LIBRARY))
 	{
 		// The object should be in user inventory.
-		for (S32 i = 0; i < mCargoIDs.count(); i++)
+		for (S32 i = 0; i < mCargoIDs.size(); i++)
 		{
 			LLInventoryItem* item = gInventory.getItem(mCargoIDs[i]);
 			if (item)
 			{
-				items.put(item);
+				items.push_back(item);
 			}
 			LLInventoryCategory* category = gInventory.getCategory(mCargoIDs[i]);
 			if (category)
 			{
-				cats.put(category);
+				cats.push_back(category);
 			}
 		}
 	}
@@ -2621,23 +2621,23 @@ LLInventoryObject* LLToolDragAndDrop::locateMultipleInventory(LLViewerInventoryC
 			   || (mCargoType == DAD_ROOT_CATEGORY))
 			{
 				// The object should be in user inventory.
-				for (S32 i = 0; i < mCargoIDs.count(); i++)
+				for (S32 i = 0; i < mCargoIDs.size(); i++)
 				{
 					LLInventoryCategory* category = (LLInventoryCategory*)obj->getInventoryObject(mCargoIDs[i]);
 					if (category)
 					{
-						cats.put(category);
+						cats.push_back(category);
 					}
 				}
 			}
 			else
 			{
-				for (S32 i = 0; i < mCargoIDs.count(); i++)
+				for (S32 i = 0; i < mCargoIDs.size(); i++)
 				{
 					LLInventoryItem* item = (LLInventoryItem*)obj->getInventoryObject(mCargoIDs[i]);
 					if (item)
 					{
-						items.put(item);
+						items.push_back(item);
 					}
 				}
 			}
@@ -2649,11 +2649,11 @@ LLInventoryObject* LLToolDragAndDrop::locateMultipleInventory(LLViewerInventoryC
 		card = (LLPreviewNotecard*)LLPreview::find(mSourceID);
 		if(card)
 		{
-			items.put((LLInventoryItem*)card->getDragItem());
+			items.push_back((LLInventoryItem*)card->getDragItem());
 		}
 	}
-	if(items.count()) return items[0];
-	if(cats.count()) return cats[0];
+	if(items.size()) return items[0];
+	if(cats.size()) return cats[0];
 	return NULL;
 }
 */
diff --git a/indra/newview/lltooldraganddrop.h b/indra/newview/lltooldraganddrop.h
index f17300a76a..99b794ce58 100755
--- a/indra/newview/lltooldraganddrop.h
+++ b/indra/newview/lltooldraganddrop.h
@@ -31,9 +31,7 @@
 #include "lltool.h"
 #include "llview.h"
 #include "lluuid.h"
-#include "stdenums.h"
 #include "llassetstorage.h"
-#include "lldarray.h"
 #include "llpermissions.h"
 #include "llwindow.h"
 #include "llviewerinventory.h"
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp
index 857b0f0714..a320d37084 100755
--- a/indra/newview/lltoolfocus.cpp
+++ b/indra/newview/lltoolfocus.cpp
@@ -334,7 +334,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 	{
 		if (!mValidClickPoint)
 		{
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolFocus [invalid point]" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [invalid point]" << llendl;
 			gViewerWindow->setCursor(UI_CURSOR_NO);
 			gViewerWindow->showCursor();
 			return TRUE;
@@ -361,7 +361,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 
 				gViewerWindow->moveCursorToCenter();
 			}
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolFocus [active]" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [active]" << llendl;
 		}
 		else if (	gCameraBtnPan ||
 					mask == MASK_PAN ||
@@ -389,7 +389,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 
 				gViewerWindow->moveCursorToCenter();
 			}
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPan" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPan" << llendl;
 		}
 		else if (gCameraBtnZoom)
 		{
@@ -421,7 +421,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 				gViewerWindow->moveCursorToCenter();
 			}
 
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolZoom" << llendl;		
+			LL_DEBUGS("UserInput") << "hover handled by LLToolZoom" << llendl;		
 		}
 	}
 
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index 9907da0f0e..a9216568c2 100755
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -707,7 +707,7 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
 	// HACK to avoid assert: error checking system makes sure that the cursor is set during every handleHover.  This is actually a no-op since the cursor is hidden.
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);  
 
-	lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGrab (active) [cursor hidden]" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (active) [cursor hidden]" << llendl;		
 }
  
 
@@ -871,7 +871,7 @@ void LLToolGrab::handleHoverNonPhysical(S32 x, S32 y, MASK mask)
 void LLToolGrab::handleHoverInactive(S32 x, S32 y, MASK mask)
 {
 	// JC - TODO - change cursor based on gGrabBtnVertical, gGrabBtnSpin
-	lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGrab (inactive-not over editable object)" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (inactive-not over editable object)" << llendl;		
 	gViewerWindow->setCursor(UI_CURSOR_TOOLGRAB);
 }
 
@@ -881,7 +881,7 @@ void LLToolGrab::handleHoverFailed(S32 x, S32 y, MASK mask)
 	if( GRAB_NOOBJECT == mMode )
 	{
 		gViewerWindow->setCursor(UI_CURSOR_NO);
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGrab (not on object)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (not on object)" << llendl;		
 	}
 	else
 	{
@@ -894,13 +894,13 @@ void LLToolGrab::handleHoverFailed(S32 x, S32 y, MASK mask)
 			{
 			case GRAB_LOCKED:
 				gViewerWindow->setCursor(UI_CURSOR_GRABLOCKED);
-				lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGrab (grab failed, no move permission)" << llendl;		
+				LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed, no move permission)" << llendl;		
 				break;
 
 //  Non physical now handled by handleHoverActive - CRO				
 //			case GRAB_NONPHYSICAL:
 //				gViewerWindow->setCursor(UI_CURSOR_ARROW);
-//				lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGrab (grab failed, nonphysical)" << llendl;		
+//				LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed, nonphysical)" << llendl;		
 //				break;
 			default:
 				llassert(0);
@@ -909,7 +909,7 @@ void LLToolGrab::handleHoverFailed(S32 x, S32 y, MASK mask)
 		else
 		{
 			gViewerWindow->setCursor(UI_CURSOR_ARROW);
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGrab (grab failed but within slop)" << llendl;		
+			LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed but within slop)" << llendl;		
 		}
 	}
 }
diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp
index c1735adc9c..17795af65d 100755
--- a/indra/newview/lltoolgun.cpp
+++ b/indra/newview/lltoolgun.cpp
@@ -116,11 +116,11 @@ BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask)
 			gViewerWindow->hideCursor();
 		}
 
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGun (mouselook)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLToolGun (mouselook)" << llendl;
 	}
 	else
 	{
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolGun (not mouselook)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLToolGun (not mouselook)" << llendl;
 	}
 
 	// HACK to avoid assert: error checking system makes sure that the cursor is set during every handleHover.  This is actually a no-op since the cursor is hidden.
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index c912d81a03..fe520b26df 100755
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -558,7 +558,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
 		// could disable it here.
 		show_highlight = true;
 		// cursor set by media object
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
 	}
 	else if (!mMouseOutsideSlop 
 		&& mMouseButtonDown 
@@ -595,7 +595,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
 			show_highlight = true;
 			ECursorType cursor = cursorFromObject(click_action_object);
 			gViewerWindow->setCursor(cursor);
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
 		}
 		
 		else if ((object && !object->isAvatar() && object->flagUsePhysics()) 
@@ -603,19 +603,19 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
 		{
 			show_highlight = true;
 			gViewerWindow->setCursor(UI_CURSOR_TOOLGRAB);
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
 		}
 		else if ( (object && object->flagHandleTouch()) 
 				  || (parent && parent->flagHandleTouch()))
 		{
 			show_highlight = true;
 			gViewerWindow->setCursor(UI_CURSOR_HAND);
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
 		}
 		else
 		{
 			gViewerWindow->setCursor(UI_CURSOR_ARROW);
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
 		}
 	}
 
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index b7718847ae..3b1b40a7f0 100755
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -518,7 +518,7 @@ BOOL LLToolPlacer::placeObject(S32 x, S32 y, MASK mask)
 
 BOOL LLToolPlacer::handleHover(S32 x, S32 y, MASK mask)
 {
-	lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPlacer" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by LLToolPlacer" << llendl;		
 	gViewerWindow->setCursor(UI_CURSOR_TOOLCREATE);
 	return TRUE;
 }
diff --git a/indra/newview/lltoolselectland.cpp b/indra/newview/lltoolselectland.cpp
index a48388c591..d44ac53db0 100755
--- a/indra/newview/lltoolselectland.cpp
+++ b/indra/newview/lltoolselectland.cpp
@@ -168,13 +168,13 @@ BOOL LLToolSelectLand::handleHover(S32 x, S32 y, MASK mask)
 				roundXY(mWestSouthBottom);
 				roundXY(mEastNorthTop);
 
-				lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (active, land)" << llendl;
+				LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, land)" << llendl;
 				gViewerWindow->setCursor(UI_CURSOR_ARROW);
 			}
 			else
 			{
 				mDragEndValid = FALSE;
-				lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (active, no land)" << llendl;
+				LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, no land)" << llendl;
 				gViewerWindow->setCursor(UI_CURSOR_NO);
 			}
 
@@ -183,13 +183,13 @@ BOOL LLToolSelectLand::handleHover(S32 x, S32 y, MASK mask)
 		}
 		else
 		{
-			lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (active, in slop)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, in slop)" << llendl;
 			gViewerWindow->setCursor(UI_CURSOR_ARROW);
 		}
 	}
 	else
 	{
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectLand (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (inactive)" << llendl;		
 		gViewerWindow->setCursor(UI_CURSOR_ARROW);
 	}
 
diff --git a/indra/newview/lltoolselectrect.cpp b/indra/newview/lltoolselectrect.cpp
index a3f4e5a18c..271a417fb9 100755
--- a/indra/newview/lltoolselectrect.cpp
+++ b/indra/newview/lltoolselectrect.cpp
@@ -32,7 +32,6 @@
 // Library includes
 #include "llgl.h"
 #include "llrender.h"
-#include "lldarray.h"
 
 // Viewer includes
 #include "llviewercontrol.h"
@@ -145,11 +144,11 @@ BOOL LLToolSelectRect::handleHover(S32 x, S32 y, MASK mask)
 			return LLToolSelect::handleHover(x, y, mask);
 		}
 
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectRect (active)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectRect (active)" << llendl;		
 	}
 	else
 	{
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolSelectRect (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectRect (inactive)" << llendl;		
 	}
 
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);
diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp
index cbd16e873d..34cbd25fd8 100755
--- a/indra/newview/lltracker.cpp
+++ b/indra/newview/lltracker.cpp
@@ -28,7 +28,6 @@
 
 // library includes
 #include "llcoord.h"
-#include "lldarray.h"
 #include "llfontgl.h"
 #include "llgl.h"
 #include "llrender.h"
diff --git a/indra/newview/lltracker.h b/indra/newview/lltracker.h
index 8e916af315..e62a7d8407 100755
--- a/indra/newview/lltracker.h
+++ b/indra/newview/lltracker.h
@@ -33,7 +33,6 @@
 #ifndef LL_LLTRACKER_H
 #define LL_LLTRACKER_H
 
-#include "lldarray.h"
 #include "llpointer.h"
 #include "llstring.h"
 #include "lluuid.h"
@@ -138,8 +137,8 @@ protected:
 	std::string				mTrackedLandmarkName;
 	LLUUID					mTrackedLandmarkAssetID;
 	LLUUID					mTrackedLandmarkItemID;
-	LLDynamicArray<LLUUID>	mLandmarkAssetIDList;
-	LLDynamicArray<LLUUID>	mLandmarkItemIDList;
+	std::vector<LLUUID>	mLandmarkAssetIDList;
+	std::vector<LLUUID>	mLandmarkItemIDList;
 	BOOL					mHasReachedLandmark;
 	BOOL 					mHasLandmarkPosition;
 	BOOL					mLandmarkHasBeenVisited;
diff --git a/indra/newview/llviewerassettype.h b/indra/newview/llviewerassettype.h
index ec8b822917..9ad8ea7eeb 100755
--- a/indra/newview/llviewerassettype.h
+++ b/indra/newview/llviewerassettype.h
@@ -29,6 +29,7 @@
 
 #include <string>
 #include "llassettype.h"
+#include "llui.h" //EDragAndDropType
 
 // This class is similar to llassettype, but contains methods
 // only used by the viewer.
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 78a0ed3ffa..557403b914 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -98,6 +98,11 @@ BOOL gWindowResized = FALSE;
 BOOL gSnapshot = FALSE;
 BOOL gShaderProfileFrame = FALSE;
 
+// This is how long the sim will try to teleport you before giving up.
+const F32 TELEPORT_EXPIRY = 15.0f;
+// Additional time (in seconds) to wait per attachment
+const F32 TELEPORT_EXPIRY_PER_ATTACHMENT = 3.f;
+
 U32 gRecentFrameCount = 0; // number of 'recent' frames
 LLFrameTimer gRecentFPSTime;
 LLFrameTimer gRecentMemoryTime;
diff --git a/indra/newview/llviewergesture.h b/indra/newview/llviewergesture.h
index 8dba10226b..8b621850ea 100755
--- a/indra/newview/llviewergesture.h
+++ b/indra/newview/llviewergesture.h
@@ -30,7 +30,6 @@
 #include "llanimationstates.h"
 #include "lluuid.h"
 #include "llstring.h"
-#include "lldarray.h"
 #include "llgesture.h"
 
 class LLMessageSystem;
diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h
index ab19a12014..a10eda947d 100755
--- a/indra/newview/llviewerinventory.h
+++ b/indra/newview/llviewerinventory.h
@@ -49,7 +49,7 @@ class LLViewerInventoryCategory;
 class LLViewerInventoryItem : public LLInventoryItem, public boost::signals2::trackable
 {
 public:
-	typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t;
+	typedef std::vector<LLPointer<LLViewerInventoryItem> > item_array_t;
 	
 protected:
 	~LLViewerInventoryItem( void ); // ref counted
@@ -181,7 +181,7 @@ public:
 class LLViewerInventoryCategory  : public LLInventoryCategory
 {
 public:
-	typedef LLDynamicArray<LLPointer<LLViewerInventoryCategory> > cat_array_t;
+	typedef std::vector<LLPointer<LLViewerInventoryCategory> > cat_array_t;
 	
 protected:
 	~LLViewerInventoryCategory();
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp
index 3a04bbed4f..0e99e161c4 100755
--- a/indra/newview/llviewerjointattachment.cpp
+++ b/indra/newview/llviewerjointattachment.cpp
@@ -28,7 +28,6 @@
 
 #include "llviewerjointattachment.h"
 
-#include "llagentconstants.h"
 #include "llviewercontrol.h"
 #include "lldrawable.h"
 #include "llgl.h"
@@ -46,6 +45,7 @@
 #include "llglheaders.h"
 
 extern LLPipeline gPipeline;
+const F32 MAX_ATTACHMENT_DIST = 3.5f; // meters?
 
 //-----------------------------------------------------------------------------
 // LLViewerJointAttachment()
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 64454a03d1..6cf39d319b 100755
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -29,7 +29,6 @@
 //-----------------------------------------------------------------------------
 #include "llviewerprecompiledheaders.h"
 
-#include "imageids.h"
 #include "llfasttimer.h"
 #include "llrender.h"
 
@@ -116,7 +115,7 @@ void LLViewerJointMesh::uploadJointMatrices()
 	BOOL hardware_skinning = (poolp && poolp->getVertexShaderLevel() > 0) ? TRUE : FALSE;
 
 	//calculate joint matrices
-	for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.count(); joint_num++)
+	for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); joint_num++)
 	{
 		LLMatrix4 joint_mat = *reference_mesh->mJointRenderData[joint_num]->mWorldMatrix;
 
@@ -132,7 +131,7 @@ void LLViewerJointMesh::uploadJointMatrices()
 	S32 j = 0;
 
 	//upload joint pivots
-	for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.count(); joint_num++)
+	for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); joint_num++)
 	{
 		LLSkinJoint *sj = reference_mesh->mJointRenderData[joint_num]->mSkinJoint;
 		if (sj)
@@ -172,7 +171,7 @@ void LLViewerJointMesh::uploadJointMatrices()
 		GLfloat mat[45*4];
 		memset(mat, 0, sizeof(GLfloat)*45*4);
 
-		for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.count(); joint_num++)
+		for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); joint_num++)
 		{
 			gJointMatUnaligned[joint_num].transpose();
 
@@ -193,7 +192,7 @@ void LLViewerJointMesh::uploadJointMatrices()
 	else
 	{
 		//load gJointMatUnaligned into gJointMatAligned
-		for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.count(); ++joint_num)
+		for (joint_num = 0; joint_num < reference_mesh->mJointRenderData.size(); ++joint_num)
 		{
 			gJointMatAligned[joint_num].loadu(gJointMatUnaligned[joint_num]);
 		}
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index 49ac2735ca..e05df2389e 100755
--- a/indra/newview/llviewerkeyboard.cpp
+++ b/indra/newview/llviewerkeyboard.cpp
@@ -676,7 +676,7 @@ BOOL LLViewerKeyboard::handleKey(KEY translated_key,  MASK translated_mask, BOOL
 		return FALSE;
 	}
 
-	lldebugst(LLERR_USER_INPUT) << "keydown -" << translated_key << "-" << llendl;
+	LL_DEBUGS("UserInput") << "keydown -" << translated_key << "-" << llendl;
 	// skip skipped keys
 	if(mKeysSkippedByUI.find(translated_key) != mKeysSkippedByUI.end()) 
 	{
@@ -729,7 +729,7 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c
 
 	if (!function)
 	{
-		llerrs << "Can't bind key to function " << function_name << ", no function with this name found" << llendl;
+		LL_ERRS() << "Can't bind key to function " << function_name << ", no function with this name found" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -742,13 +742,13 @@ BOOL LLViewerKeyboard::bindKey(const S32 mode, const KEY key, const MASK mask, c
 
 	if (index >= MAX_KEY_BINDINGS)
 	{
-		llerrs << "LLKeyboard::bindKey() - too many keys for mode " << mode << llendl;
+		LL_ERRS() << "LLKeyboard::bindKey() - too many keys for mode " << mode << LL_ENDL;
 		return FALSE;
 	}
 
 	if (mode >= MODE_COUNT)
 	{
-		llerror("LLKeyboard::bindKey() - unknown mode passed", mode);
+		LL_ERRS() << "LLKeyboard::bindKey() - unknown mode passed" << mode << LL_ENDL;
 		return FALSE;
 	}
 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 9f67aad297..427fd89afb 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -123,6 +123,7 @@
 #include "lltoolgrab.h"
 #include "llwindow.h"
 #include "llpathfindingmanager.h"
+#include "llstartup.h"
 #include "boost/unordered_map.hpp"
 
 using namespace LLAvatarAppearanceDefines;
@@ -4159,13 +4160,16 @@ static bool get_derezzable_objects(
 	EDeRezDestination dest,
 	std::string& error,
 	LLViewerRegion*& first_region,
-	LLDynamicArray<LLViewerObjectPtr>* derez_objectsp,
+	std::vector<LLViewerObjectPtr>* derez_objectsp,
 	bool only_check = false)
 {
 	bool found = false;
 
 	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-	
+
+	if (derez_objectsp)
+		derez_objectsp->reserve(selection->getRootObjectCount());
+
 	// Check conditions that we can't deal with, building a list of
 	// everything that we'll actually be derezzing.
 	for (LLObjectSelection::valid_root_iterator iter = selection->valid_root_begin();
@@ -4244,7 +4248,7 @@ static bool get_derezzable_objects(
 				break;
 
 			if (derez_objectsp)
-				derez_objectsp->put(object);
+				derez_objectsp->push_back(object);
 
 		}
 	}
@@ -4264,9 +4268,9 @@ static void derez_objects(
 	const LLUUID& dest_id,
 	LLViewerRegion*& first_region,
 	std::string& error,
-	LLDynamicArray<LLViewerObjectPtr>* objectsp)
+	std::vector<LLViewerObjectPtr>* objectsp)
 {
-	LLDynamicArray<LLViewerObjectPtr> derez_objects;
+	std::vector<LLViewerObjectPtr> derez_objects;
 
 	if (!objectsp) // if objects to derez not specified
 	{
@@ -4293,13 +4297,13 @@ static void derez_objects(
 	// satisfy anybody.
 	const S32 MAX_ROOTS_PER_PACKET = 250;
 	const S32 MAX_PACKET_COUNT = 254;
-	F32 packets = ceil((F32)objectsp->count() / (F32)MAX_ROOTS_PER_PACKET);
+	F32 packets = ceil((F32)objectsp->size() / (F32)MAX_ROOTS_PER_PACKET);
 	if(packets > (F32)MAX_PACKET_COUNT)
 	{
 		error = "AcquireErrorTooManyObjects";
 	}
 
-	if(error.empty() && objectsp->count() > 0)
+	if(error.empty() && objectsp->size() > 0)
 	{
 		U8 d = (U8)dest;
 		LLUUID tid;
@@ -4324,11 +4328,11 @@ static void derez_objects(
 			msg->addU8Fast(_PREHASH_PacketCount, packet_count);
 			msg->addU8Fast(_PREHASH_PacketNumber, packet_number);
 			objects_in_packet = 0;
-			while((object_index < objectsp->count())
+			while((object_index < objectsp->size())
 				  && (objects_in_packet++ < MAX_ROOTS_PER_PACKET))
 
 			{
-				LLViewerObject* object = objectsp->get(object_index++);
+				LLViewerObject* object = objectsp->at(object_index++);
 				msg->nextBlockFast(_PREHASH_ObjectData);
 				msg->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
 				// VEFFECT: DerezObject
@@ -4408,7 +4412,7 @@ private:
 
 	LLObjectSelectionHandle mObjectSelection;
 
-	LLDynamicArray<LLViewerObjectPtr> mReturnableObjects;
+	std::vector<LLViewerObjectPtr> mReturnableObjects;
 	std::string mError;
 	LLViewerRegion* mFirstRegion;
 };
@@ -5280,7 +5284,7 @@ public:
 	};
 
 	LLObjectSelectionHandle mObjectSelection;
-	LLDynamicArray<LLViewerObjectPtr> mReturnableObjects;
+	std::vector<LLViewerObjectPtr> mReturnableObjects;
 	std::string mError;
 	LLViewerRegion *mFirstRegion;
 };
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 970f6913cb..864418ad95 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -149,6 +149,11 @@ LLFrameTimer gThrottleTimer;
 const U32 OFFER_THROTTLE_MAX_COUNT=5; //number of items per time period
 const F32 OFFER_THROTTLE_TIME=10.f; //time period in seconds
 
+// Agent Update Flags (U8)
+const U8 AU_FLAGS_NONE      		= 0x00;
+const U8 AU_FLAGS_HIDETITLE      	= 0x01;
+const U8 AU_FLAGS_CLIENT_AUTOPILOT	= 0x02;
+
 //script permissions
 const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] = 
 	{ 
@@ -665,7 +670,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response)
 		S32 max_groups = gMaxAgentGroups;
 		if(gAgent.isInGroup(group_id)) ++max_groups;
 
-		if(gAgent.mGroups.count() < max_groups)
+		if(gAgent.mGroups.size() < max_groups)
 		{
 			accept_invite = true;
 		}
@@ -3799,15 +3804,15 @@ public:
 				is_card);
 		}
 		LLSD args;
-		if ( land_items.count() > 0 )
+		if ( land_items.size() > 0 )
 		{	// Show notification that they can now teleport to landmarks.  Use a random landmark from the inventory
-			S32 random_land = ll_rand( land_items.count() - 1 );
+			S32 random_land = ll_rand( land_items.size() - 1 );
 			args["NAME"] = land_items[random_land]->getName();
 			LLNotificationsUtil::add("TeleportToLandmark",args);
 		}
-		if ( card_items.count() > 0 )
+		if ( card_items.size() > 0 )
 		{	// Show notification that they can now contact people.  Use a random calling card from the inventory
-			S32 random_card = ll_rand( card_items.count() - 1 );
+			S32 random_card = ll_rand( card_items.size() - 1 );
 			args["NAME"] = card_items[random_card]->getName();
 			LLNotificationsUtil::add("TeleportToPerson",args);
 		}
@@ -6803,7 +6808,7 @@ bool handle_lure_callback(const LLSD& notification, const LLSD& response)
 
 void handle_lure(const LLUUID& invitee)
 {
-	LLDynamicArray<LLUUID> ids;
+	std::vector<LLUUID> ids;
 	ids.push_back(invitee);
 	handle_lure(ids);
 }
@@ -6819,7 +6824,7 @@ void handle_lure(const uuid_vec_t& ids)
 	edit_args["REGION"] = gAgent.getRegion()->getName();
 
 	LLSD payload;
-	for (LLDynamicArray<LLUUID>::const_iterator it = ids.begin();
+	for (std::vector<LLUUID>::const_iterator it = ids.begin();
 		it != ids.end();
 		++it)
 	{
diff --git a/indra/newview/llviewermessage.h b/indra/newview/llviewermessage.h
index 3237f3fbdd..d8f5c71f8d 100755
--- a/indra/newview/llviewermessage.h
+++ b/indra/newview/llviewermessage.h
@@ -33,7 +33,6 @@
 #include "lltransactiontypes.h"
 #include "lluuid.h"
 #include "message.h"
-#include "stdenums.h"
 #include "llnotifications.h"
 #include "llextendedstatus.h"
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index e834febad5..51328dc802 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -29,7 +29,6 @@
 #include "llviewerobject.h"
 
 #include "llaudioengine.h"
-#include "imageids.h"
 #include "indra_constants.h"
 #include "llmath.h"
 #include "llflexibleobject.h"
@@ -53,7 +52,6 @@
 #include "llxfermanager.h"
 #include "message.h"
 #include "object_flags.h"
-#include "timing.h"
 
 #include "llaudiosourcevo.h"
 #include "llagent.h"
@@ -126,6 +124,15 @@ F64			LLViewerObject::sPhaseOutUpdateInterpolationTime = 2.0;	// For motion inte
 
 std::map<std::string, U32> LLViewerObject::sObjectDataMap;
 
+// The maximum size of an object extra parameters binary (packed) block
+#define MAX_OBJECT_PARAMS_SIZE 1024
+
+// At 45 Hz collisions seem stable and objects seem
+// to settle down at a reasonable rate.
+// JC 3/18/2003
+
+const F32 PHYSICS_TIMESTEP = 1.f / 45.f;
+
 static LLFastTimer::DeclareTimer FTM_CREATE_OBJECT("Create Object");
 
 // static
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 8299c84663..4072ab524e 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -29,7 +29,6 @@
 #include "llviewerobjectlist.h"
 
 #include "message.h"
-#include "timing.h"
 #include "llfasttimer.h"
 #include "llrender.h"
 #include "llwindow.h"		// decBusyCount()
@@ -997,14 +996,14 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 
 	// update global timer
 	F32 last_time = gFrameTimeSeconds;
-	U64 time = totalTime();				 // this will become the new gFrameTime when the update is done
+	LLUnit<U64, LLUnits::Microseconds> time = totalTime();				 // this will become the new gFrameTime when the update is done
 	// Time _can_ go backwards, for example if the user changes the system clock.
 	// It doesn't cause any fatal problems (just some oddness with stats), so we shouldn't assert here.
 //	llassert(time > gFrameTime);
-	F64 time_diff = U64_to_F64(time - gFrameTime)/(F64)SEC_TO_MICROSEC;
+	LLUnit<F64, LLUnits::Seconds> time_diff = time - gFrameTime;
 	gFrameTime	= time;
-	F64 time_since_start = U64_to_F64(gFrameTime - gStartTime)/(F64)SEC_TO_MICROSEC;
-	gFrameTimeSeconds = (F32)time_since_start;
+	LLUnit<F64, LLUnits::Seconds> time_since_start = gFrameTime - gStartTime;
+	gFrameTimeSeconds = time_since_start;
 
 	gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
 	if (gFrameIntervalSeconds < 0.f)
@@ -1102,7 +1101,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	/*
 	// Debugging code for viewing orphans, and orphaned parents
 	LLUUID id;
-	for (i = 0; i < mOrphanParents.count(); i++)
+	for (i = 0; i < mOrphanParents.size(); i++)
 	{
 		id = sIndexAndLocalIDToUUID[mOrphanParents[i]];
 		LLViewerObject *objectp = findObject(id);
@@ -1119,7 +1118,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	}
 
 	LLColor4 text_color;
-	for (i = 0; i < mOrphanChildren.count(); i++)
+	for (i = 0; i < mOrphanChildren.size(); i++)
 	{
 		OrphanInfo oi = mOrphanChildren[i];
 		LLViewerObject *objectp = findObject(oi.mChildInfo);
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index 4cdb568d17..b25d042d28 100755
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -36,7 +36,6 @@
 #include "llnotifications.h"
 #include "llnotificationsutil.h"
 #include "llparcel.h"
-#include "llsecondlifeurls.h"
 #include "message.h"
 #include "llfloaterreg.h"
 
@@ -591,13 +590,13 @@ void LLViewerParcelMgr::deselectLand()
 
 void LLViewerParcelMgr::addObserver(LLParcelObserver* observer)
 {
-	mObservers.put(observer);
+	mObservers.push_back(observer);
 }
 
 
 void LLViewerParcelMgr::removeObserver(LLParcelObserver* observer)
 {
-	mObservers.removeObj(observer);
+	vector_replace_with_last(mObservers, observer);
 }
 
 
@@ -606,16 +605,16 @@ void LLViewerParcelMgr::removeObserver(LLParcelObserver* observer)
 // from the list.
 void LLViewerParcelMgr::notifyObservers()
 {
-	LLDynamicArray<LLParcelObserver*> observers;
-	S32 count = mObservers.count();
+	std::vector<LLParcelObserver*> observers;
+	S32 count = mObservers.size();
 	S32 i;
 	for(i = 0; i < count; ++i)
 	{
-		observers.put(mObservers.get(i));
+		observers.push_back(mObservers.at(i));
 	}
 	for(i = 0; i < count; ++i)
 	{
-		observers.get(i)->changed();
+		observers.at(i)->changed();
 	}
 }
 
diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h
index 6183b7e90e..e2c8dc0ff2 100755
--- a/indra/newview/llviewerparcelmgr.h
+++ b/indra/newview/llviewerparcelmgr.h
@@ -28,7 +28,6 @@
 #define LL_LLVIEWERPARCELMGR_H
 
 #include "v3dmath.h"
-#include "lldarray.h"
 #include "llframetimer.h"
 #include "llsingleton.h"
 #include "llparcelselection.h"
@@ -334,7 +333,7 @@ private:
 	LLVector3d					mHoverWestSouth;
 	LLVector3d					mHoverEastNorth;
 
-	LLDynamicArray<LLParcelObserver*> mObservers;
+	std::vector<LLParcelObserver*> mObservers;
 
 	BOOL						mTeleportInProgress;
 	teleport_finished_signal_t	mTeleportFinishedSignal;
diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp
index a1c12c5cd6..e29eef2dda 100755
--- a/indra/newview/llviewerparceloverlay.cpp
+++ b/indra/newview/llviewerparceloverlay.cpp
@@ -432,9 +432,12 @@ void LLViewerParcelOverlay::updatePropertyLines()
 	const LLColor4U auction_coloru = LLUIColorTable::instance().getColor("PropertyColorAuction").get();
 
 	// Build into dynamic arrays, then copy into static arrays.
-	LLDynamicArray<LLVector3, 256> new_vertex_array;
-	LLDynamicArray<LLColor4U, 256> new_color_array;
-	LLDynamicArray<LLVector2, 256> new_coord_array;
+	std::vector<LLVector3> new_vertex_array;
+	new_vertex_array.reserve(256);
+	std::vector<LLColor4U> new_color_array;
+	new_color_array.reserve(256);
+	std::vector<LLVector2> new_coord_array;
+	new_coord_array.reserve(256);
 
 	U8 overlay = 0;
 	BOOL add_edge = FALSE;
@@ -599,7 +602,7 @@ void LLViewerParcelOverlay::updatePropertyLines()
 	// Now copy into static arrays for faster rendering.
 	// Attempt to recycle old arrays if possible to avoid memory
 	// shuffling.
-	S32 new_vertex_count = new_vertex_array.count();
+	S32 new_vertex_count = new_vertex_array.size();
 	
 	if (!(mVertexArray && mColorArray && new_vertex_count == mVertexCount))
 	{
@@ -623,7 +626,7 @@ void LLViewerParcelOverlay::updatePropertyLines()
 	F32* vertex = mVertexArray;
 	for (i = 0; i < mVertexCount; i++)
 	{
-		const LLVector3& point = new_vertex_array.get(i);
+		const LLVector3& point = new_vertex_array.at(i);
 		*vertex = point.mV[VX];
 		vertex++;
 		*vertex = point.mV[VY];
@@ -635,7 +638,7 @@ void LLViewerParcelOverlay::updatePropertyLines()
 	U8* colorp = mColorArray;
 	for (i = 0; i < mVertexCount; i++)
 	{
-		const LLColor4U& color = new_color_array.get(i);
+		const LLColor4U& color = new_color_array.at(i);
 		*colorp = color.mV[VRED];
 		colorp++;
 		*colorp = color.mV[VGREEN];
@@ -652,9 +655,9 @@ void LLViewerParcelOverlay::updatePropertyLines()
 
 
 void LLViewerParcelOverlay::addPropertyLine(
-				LLDynamicArray<LLVector3, 256>& vertex_array,
-				LLDynamicArray<LLColor4U, 256>& color_array,
-				LLDynamicArray<LLVector2, 256>& coord_array,
+				std::vector<LLVector3>& vertex_array,
+				std::vector<LLColor4U>& color_array,
+				std::vector<LLVector2>& coord_array,
 				const F32 start_x, const F32 start_y, 
 				const U32 edge,
 				const LLColor4U& color)
@@ -662,6 +665,10 @@ void LLViewerParcelOverlay::addPropertyLine(
 	LLColor4U underwater( color );
 	underwater.mV[VALPHA] /= 2;
 
+	vertex_array.reserve(16);
+	color_array.reserve(16);
+	coord_array.reserve(16);
+
 	LLSurface& land = mRegion->getLand();
 
 	F32 dx;
@@ -716,11 +723,11 @@ void LLViewerParcelOverlay::addPropertyLine(
 	// First part, only one vertex
 	outside_z = land.resolveHeightRegion( outside_x, outside_y );
 
-	if (outside_z > 20.f) color_array.put( color );
-	else color_array.put( underwater );
+	if (outside_z > 20.f) color_array.push_back( color );
+	else color_array.push_back( underwater );
 
-	vertex_array.put( LLVector3(outside_x, outside_y, outside_z) );
-	coord_array.put(  LLVector2(outside_x - start_x, 0.f) );
+	vertex_array.push_back( LLVector3(outside_x, outside_y, outside_z) );
+	coord_array.push_back(  LLVector2(outside_x - start_x, 0.f) );
 
 	inside_x += dx * LINE_WIDTH;
 	inside_y += dy * LINE_WIDTH;
@@ -732,17 +739,17 @@ void LLViewerParcelOverlay::addPropertyLine(
 	inside_z = land.resolveHeightRegion( inside_x, inside_y );
 	outside_z = land.resolveHeightRegion( outside_x, outside_y );
 
-	if (inside_z > 20.f) color_array.put( color );
-	else color_array.put( underwater );
+	if (inside_z > 20.f) color_array.push_back( color );
+	else color_array.push_back( underwater );
 
-	if (outside_z > 20.f) color_array.put( color );
-	else color_array.put( underwater );
+	if (outside_z > 20.f) color_array.push_back( color );
+	else color_array.push_back( underwater );
 
-	vertex_array.put( LLVector3(inside_x, inside_y, inside_z) );
-	vertex_array.put( LLVector3(outside_x, outside_y, outside_z) );
+	vertex_array.push_back( LLVector3(inside_x, inside_y, inside_z) );
+	vertex_array.push_back( LLVector3(outside_x, outside_y, outside_z) );
 
-	coord_array.put(  LLVector2(outside_x - start_x, 1.f) );
-	coord_array.put(  LLVector2(outside_x - start_x, 0.f) );
+	coord_array.push_back(  LLVector2(outside_x - start_x, 1.f) );
+	coord_array.push_back(  LLVector2(outside_x - start_x, 0.f) );
 
 	inside_x += dx * (dx - LINE_WIDTH);
 	inside_y += dy * (dy - LINE_WIDTH);
@@ -758,17 +765,17 @@ void LLViewerParcelOverlay::addPropertyLine(
 		inside_z = land.resolveHeightRegion( inside_x, inside_y );
 		outside_z = land.resolveHeightRegion( outside_x, outside_y );
 
-		if (inside_z > 20.f) color_array.put( color );
-		else color_array.put( underwater );
+		if (inside_z > 20.f) color_array.push_back( color );
+		else color_array.push_back( underwater );
 
-		if (outside_z > 20.f) color_array.put( color );
-		else color_array.put( underwater );
+		if (outside_z > 20.f) color_array.push_back( color );
+		else color_array.push_back( underwater );
 
-		vertex_array.put( LLVector3(inside_x, inside_y, inside_z) );
-		vertex_array.put( LLVector3(outside_x, outside_y, outside_z) );
+		vertex_array.push_back( LLVector3(inside_x, inside_y, inside_z) );
+		vertex_array.push_back( LLVector3(outside_x, outside_y, outside_z) );
 
-		coord_array.put(  LLVector2(outside_x - start_x, 1.f) );
-		coord_array.put(  LLVector2(outside_x - start_x, 0.f) );
+		coord_array.push_back(  LLVector2(outside_x - start_x, 1.f) );
+		coord_array.push_back(  LLVector2(outside_x - start_x, 0.f) );
 
 		inside_x += dx;
 		inside_y += dy;
@@ -787,17 +794,17 @@ void LLViewerParcelOverlay::addPropertyLine(
 	inside_z = land.resolveHeightRegion( inside_x, inside_y );
 	outside_z = land.resolveHeightRegion( outside_x, outside_y );
 
-	if (inside_z > 20.f) color_array.put( color );
-	else color_array.put( underwater );
+	if (inside_z > 20.f) color_array.push_back( color );
+	else color_array.push_back( underwater );
 
-	if (outside_z > 20.f) color_array.put( color );
-	else color_array.put( underwater );
+	if (outside_z > 20.f) color_array.push_back( color );
+	else color_array.push_back( underwater );
 
-	vertex_array.put( LLVector3(inside_x, inside_y, inside_z) );
-	vertex_array.put( LLVector3(outside_x, outside_y, outside_z) );
+	vertex_array.push_back( LLVector3(inside_x, inside_y, inside_z) );
+	vertex_array.push_back( LLVector3(outside_x, outside_y, outside_z) );
 
-	coord_array.put(  LLVector2(outside_x - start_x, 1.f) );
-	coord_array.put(  LLVector2(outside_x - start_x, 0.f) );
+	coord_array.push_back(  LLVector2(outside_x - start_x, 1.f) );
+	coord_array.push_back(  LLVector2(outside_x - start_x, 0.f) );
 
 	inside_x += dx * LINE_WIDTH;
 	inside_y += dy * LINE_WIDTH;
@@ -808,11 +815,11 @@ void LLViewerParcelOverlay::addPropertyLine(
 	// Last edge is not drawn to the edge
 	outside_z = land.resolveHeightRegion( outside_x, outside_y );
 
-	if (outside_z > 20.f) color_array.put( color );
-	else color_array.put( underwater );
+	if (outside_z > 20.f) color_array.push_back( color );
+	else color_array.push_back( underwater );
 
-	vertex_array.put( LLVector3(outside_x, outside_y, outside_z) );
-	coord_array.put(  LLVector2(outside_x - start_x, 0.f) );
+	vertex_array.push_back( LLVector3(outside_x, outside_y, outside_z) );
+	coord_array.push_back(  LLVector2(outside_x - start_x, 0.f) );
 }
 
 
diff --git a/indra/newview/llviewerparceloverlay.h b/indra/newview/llviewerparceloverlay.h
index 7445d5bf1d..14a2af5354 100755
--- a/indra/newview/llviewerparceloverlay.h
+++ b/indra/newview/llviewerparceloverlay.h
@@ -31,7 +31,6 @@
 // One of these structures per region.
 
 #include "llbbox.h"
-#include "lldarray.h"
 #include "llframetimer.h"
 #include "lluuid.h"
 #include "llviewertexture.h"
@@ -88,9 +87,9 @@ private:
 	U8		ownership(S32 row, S32 col) const	
 				{ return 0x7 & mOwnership[row * mParcelGridsPerEdge + col]; }
 
-	void	addPropertyLine(LLDynamicArray<LLVector3, 256>& vertex_array,
-				LLDynamicArray<LLColor4U, 256>& color_array,
-				LLDynamicArray<LLVector2, 256>& coord_array,
+	void	addPropertyLine(std::vector<LLVector3>& vertex_array,
+				std::vector<LLColor4U>& color_array,
+				std::vector<LLVector2>& coord_array,
 				const F32 start_x, const F32 start_y, 
 				const U32 edge, 
 				const LLColor4U& color);
diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index 5df456dab6..999d9092bd 100755
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -51,8 +51,6 @@
 #endif
 
 // Library headers from llcommon project:
-#include "bitpack.h"
-#include "imageids.h"
 #include "indra_constants.h"
 #include "llinitparam.h"
 #include "llallocator.h"
@@ -74,9 +72,7 @@
 #include "llstring.h"
 #include "llsys.h"
 #include "lltimer.h"
-#include "stdenums.h"
 #include "stdtypes.h"
-#include "timing.h"
 #include "u64.h"
 
 // Library includes from llmath project
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index b80d87ef07..d4de33cc38 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -85,6 +85,7 @@ const S32 MAX_SEED_CAP_ATTEMPTS_BEFORE_LOGIN = 3;
 const F32 CAP_REQUEST_TIMEOUT = 18;
 // Even though we gave up on login, keep trying for caps after we are logged in:
 const S32 MAX_CAP_REQUEST_ATTEMPTS = 30;
+const U32 DEFAULT_MAX_REGION_WIDE_PRIM_COUNT = 15000;
 
 BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
 
@@ -229,7 +230,7 @@ public:
 
     void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
     {
-		LL_WARNS2("AppInit", "Capabilities") << "[status:" << statusNum << ":] " << content << LL_ENDL;
+		LL_WARNS("AppInit", "Capabilities") << "[status:" << statusNum << ":] " << content << LL_ENDL;
 		LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle);
 		if (regionp)
 		{
@@ -242,12 +243,12 @@ public:
 		LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle);
 		if(!regionp) //region was removed
 		{
-			LL_WARNS2("AppInit", "Capabilities") << "Received results for region that no longer exists!" << LL_ENDL;
+			LL_WARNS("AppInit", "Capabilities") << "Received results for region that no longer exists!" << LL_ENDL;
 			return ;
 		}
 		if( mID != regionp->getHttpResponderID() ) // region is no longer referring to this responder
 		{
-			LL_WARNS2("AppInit", "Capabilities") << "Received results for a stale http responder!" << LL_ENDL;
+			LL_WARNS("AppInit", "Capabilities") << "Received results for a stale http responder!" << LL_ENDL;
 			return ;
 		}
 
@@ -256,8 +257,7 @@ public:
 		{
 			regionp->setCapability(iter->first, iter->second);
 			
-			LL_DEBUGS2("AppInit", "Capabilities") << "got capability for " 
-				<< iter->first << LL_ENDL;
+			LL_DEBUGS("AppInit", "Capabilities") << "got capability for " << iter->first << LL_ENDL;
 
 			/* HACK we're waiting for the ServerReleaseNotes */
 			if (iter->first == "ServerReleaseNotes" && regionp->getReleaseNotesRequested())
@@ -1616,10 +1616,10 @@ public:
 		S32 target_index = input["body"]["Index"][0]["Prey"].asInteger();
 		S32 you_index    = input["body"]["Index"][0]["You" ].asInteger();
 
-		LLDynamicArray<U32>* avatar_locs = &region->mMapAvatars;
-		LLDynamicArray<LLUUID>* avatar_ids = &region->mMapAvatarIDs;
-		avatar_locs->reset();
-		avatar_ids->reset();
+		std::vector<U32>* avatar_locs = &region->mMapAvatars;
+		std::vector<LLUUID>* avatar_ids = &region->mMapAvatarIDs;
+		avatar_locs->clear();
+		avatar_ids->clear();
 
 		//llinfos << "coarse locations agent[0] " << input["body"]["AgentData"][0]["AgentID"].asUUID() << llendl;
 		//llinfos << "my agent id = " << gAgent.getID() << llendl;
@@ -1659,13 +1659,13 @@ public:
 				pos |= y;
 				pos <<= 8;
 				pos |= z;
-				avatar_locs->put(pos);
+				avatar_locs->push_back(pos);
 				//llinfos << "next pos: " << x << "," << y << "," << z << ": " << pos << llendl;
 				if(has_agent_data) // for backwards compatibility with old message format
 				{
 					LLUUID agent_id(agents_it->get("AgentID").asUUID());
 					//llinfos << "next agent: " << agent_id.asString() << llendl;
-					avatar_ids->put(agent_id);
+					avatar_ids->push_back(agent_id);
 				}
 			}
 			if (has_agent_data)
@@ -1686,8 +1686,8 @@ LLHTTPRegistration<CoarseLocationUpdate>
 void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg)
 {
 	//llinfos << "CoarseLocationUpdate" << llendl;
-	mMapAvatars.reset();
-	mMapAvatarIDs.reset(); // only matters in a rare case but it's good to be safe.
+	mMapAvatars.clear();
+	mMapAvatarIDs.clear(); // only matters in a rare case but it's good to be safe.
 
 	U8 x_pos = 0;
 	U8 y_pos = 0;
@@ -1736,10 +1736,10 @@ void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg)
 			pos |= y_pos;
 			pos <<= 8;
 			pos |= z_pos;
-			mMapAvatars.put(pos);
+			mMapAvatars.push_back(pos);
 			if(has_agent_data)
 			{
-				mMapAvatarIDs.put(agent_id);
+				mMapAvatarIDs.push_back(agent_id);
 			}
 		}
 	}
@@ -2468,7 +2468,7 @@ void LLViewerRegion::failedSeedCapability()
 	std::string url = getCapability("Seed");
 	if ( url.empty() )
 	{
-		LL_WARNS2("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url for retries!" << LL_ENDL;
+		LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities, and can not determine url for retries!" << LL_ENDL;
 		return;
 	}
 	// After a few attempts, continue login.  We will keep trying once in-world:
@@ -2494,7 +2494,7 @@ void LLViewerRegion::failedSeedCapability()
 	else
 	{
 		// *TODO: Give a user pop-up about this error?
-		LL_WARNS2("AppInit", "Capabilities") << "Failed to get seed capabilities from '" << url << "' after " << mImpl->mSeedCapAttempts << " attempts.  Giving up!" << LL_ENDL;
+		LL_WARNS("AppInit", "Capabilities") << "Failed to get seed capabilities from '" << url << "' after " << mImpl->mSeedCapAttempts << " attempts.  Giving up!" << LL_ENDL;
 	}
 }
 
@@ -2510,7 +2510,7 @@ public:
 	
     void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
     {
-		LL_WARNS2("AppInit", "SimulatorFeatures") << "[status:" << statusNum << "]: " << content << LL_ENDL;
+		LL_WARNS("AppInit", "SimulatorFeatures") << "[status:" << statusNum << "]: " << content << LL_ENDL;
 		retry();
     }
 
@@ -2519,7 +2519,7 @@ public:
 		LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle);
 		if(!regionp) //region is removed or responder is not created.
 		{
-			LL_WARNS2("AppInit", "SimulatorFeatures") << "Received results for region that no longer exists!" << LL_ENDL;
+			LL_WARNS("AppInit", "SimulatorFeatures") << "Received results for region that no longer exists!" << LL_ENDL;
 			return ;
 		}
 		
@@ -2532,7 +2532,7 @@ private:
 		if (mAttempt < mMaxAttempts)
 		{
 			mAttempt++;
-			LL_WARNS2("AppInit", "SimulatorFeatures") << "Re-trying '" << mRetryURL << "'.  Retry #" << mAttempt << LL_ENDL;
+			LL_WARNS("AppInit", "SimulatorFeatures") << "Re-trying '" << mRetryURL << "'.  Retry #" << mAttempt << LL_ENDL;
 			LLHTTPClient::get(mRetryURL, new SimulatorFeaturesReceived(*this), LLSD(), CAP_REQUEST_TIMEOUT);
 		}
 	}
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 29483662e8..cc314dc43b 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -32,7 +32,6 @@
 #include <string>
 #include <boost/signals2.hpp>
 
-#include "lldarray.h"
 #include "llwind.h"
 #include "v3dmath.h"
 #include "llstring.h"
@@ -407,8 +406,8 @@ public:
 	// messaging system in which the previous message only sends and parses the 
 	// positions stored in the first array so they're maintained separately until 
 	// we stop supporting the old CoarseLocationUpdate message.
-	LLDynamicArray<U32> mMapAvatars;
-	LLDynamicArray<LLUUID> mMapAvatarIDs;
+	std::vector<U32> mMapAvatars;
+	std::vector<LLUUID> mMapAvatarIDs;
 
 	static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
 private:
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 69a6c00a8f..94be8e2a83 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -92,6 +92,9 @@ LLTrace::CountStatHandle<>	FPS("FPS", "Frames rendered"),
 LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> > 
 							TRIANGLES_DRAWN("trianglesdrawnstat");
 
+LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Kilotriangles> >
+							TRIANGLES_DRAWN_PER_FRAME("trianglesdrawnperframestat");
+
 LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	
 							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)"),
@@ -213,38 +216,37 @@ void LLViewerStats::resetStats()
 	LLViewerStats::instance().mRecording.reset();
 }
 
-void LLViewerStats::updateFrameStats(const F64 time_diff)
+void LLViewerStats::updateFrameStats(const LLUnit<F64, LLUnits::Seconds> time_diff)
 {
-	LLUnit<F64, LLUnits::Seconds> time_diff_seconds(time_diff);
 	if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0)
 	{
-		add(LLStatViewer::LOSS_5_PERCENT_TIME, time_diff_seconds);
+		add(LLStatViewer::LOSS_5_PERCENT_TIME, time_diff);
 	}
 	
 	F32 sim_fps = getRecording().getLastValue(LLStatViewer::SIM_FPS);
 	if (0.f < sim_fps && sim_fps < 20.f)
 	{
-		add(LLStatViewer::SIM_20_FPS_TIME, time_diff_seconds);
+		add(LLStatViewer::SIM_20_FPS_TIME, time_diff);
 	}
 	
 	F32 sim_physics_fps = getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS);
 
 	if (0.f < sim_physics_fps && sim_physics_fps < 20.f)
 	{
-		add(LLStatViewer::SIM_PHYSICS_20_FPS_TIME, time_diff_seconds);
+		add(LLStatViewer::SIM_PHYSICS_20_FPS_TIME, time_diff);
 	}
 		
 	if (time_diff >= 0.5)
 	{
-		record(LLStatViewer::FPS_2_TIME, time_diff_seconds);
+		record(LLStatViewer::FPS_2_TIME, time_diff);
 	}
 	if (time_diff >= 0.125)
 	{
-		record(LLStatViewer::FPS_8_TIME, time_diff_seconds);
+		record(LLStatViewer::FPS_8_TIME, time_diff);
 	}
 	if (time_diff >= 0.1)
 	{
-		record(LLStatViewer::FPS_10_TIME, time_diff_seconds);
+		record(LLStatViewer::FPS_10_TIME, time_diff);
 	}
 
 	if (gFrameCount && mLastTimeDiff > 0.0)
@@ -331,6 +333,8 @@ void update_statistics()
 
 	LLTrace::Recording& last_frame_recording = LLTrace::get_frame_recording().getLastRecording();
 
+	record(LLStatViewer::TRIANGLES_DRAWN_PER_FRAME, last_frame_recording.getSum(LLStatViewer::TRIANGLES_DRAWN));
+
 	sample(LLStatViewer::ENABLE_VBO,      (F64)gSavedSettings.getBOOL("RenderVBOEnable"));
 	sample(LLStatViewer::LIGHTING_DETAIL, (F64)gPipeline.getLightingDetail());
 	sample(LLStatViewer::DRAW_DISTANCE,   (F64)gSavedSettings.getF32("RenderFarClip"));
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index ee1a73de9f..9fed558e03 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -27,11 +27,56 @@
 #ifndef LL_LLVIEWERSTATS_H
 #define LL_LLVIEWERSTATS_H
 
-#include "llstatenums.h"
 #include "lltextureinfo.h"
 #include "lltracerecording.h"
 #include "lltrace.h"
 
+
+enum ESimStatID
+{
+	LL_SIM_STAT_TIME_DILATION         =  0,
+	LL_SIM_STAT_FPS                   =  1,
+	LL_SIM_STAT_PHYSFPS               =  2,
+	LL_SIM_STAT_AGENTUPS              =  3,
+	LL_SIM_STAT_FRAMEMS               =  4,
+	LL_SIM_STAT_NETMS                 =  5,
+	LL_SIM_STAT_SIMOTHERMS            =  6,
+	LL_SIM_STAT_SIMPHYSICSMS          =  7,
+	LL_SIM_STAT_AGENTMS               =  8,
+	LL_SIM_STAT_IMAGESMS              =  9,
+	LL_SIM_STAT_SCRIPTMS              = 10,
+	LL_SIM_STAT_NUMTASKS              = 11,
+	LL_SIM_STAT_NUMTASKSACTIVE        = 12,
+	LL_SIM_STAT_NUMAGENTMAIN          = 13,
+	LL_SIM_STAT_NUMAGENTCHILD         = 14,
+	LL_SIM_STAT_NUMSCRIPTSACTIVE      = 15,
+	LL_SIM_STAT_LSLIPS                = 16,
+	LL_SIM_STAT_INPPS                 = 17,
+	LL_SIM_STAT_OUTPPS                = 18,
+	LL_SIM_STAT_PENDING_DOWNLOADS     = 19,
+	LL_SIM_STAT_PENDING_UPLOADS       = 20,
+	LL_SIM_STAT_VIRTUAL_SIZE_KB       = 21,
+	LL_SIM_STAT_RESIDENT_SIZE_KB      = 22,
+	LL_SIM_STAT_PENDING_LOCAL_UPLOADS = 23,
+	LL_SIM_STAT_TOTAL_UNACKED_BYTES   = 24,
+	LL_SIM_STAT_PHYSICS_PINNED_TASKS  = 25,
+	LL_SIM_STAT_PHYSICS_LOD_TASKS     = 26,
+	LL_SIM_STAT_SIMPHYSICSSTEPMS      = 27,
+	LL_SIM_STAT_SIMPHYSICSSHAPEMS     = 28,
+	LL_SIM_STAT_SIMPHYSICSOTHERMS     = 29,
+	LL_SIM_STAT_SIMPHYSICSMEMORY      = 30,
+	LL_SIM_STAT_SCRIPT_EPS            = 31,
+	LL_SIM_STAT_SIMSPARETIME          = 32,
+	LL_SIM_STAT_SIMSLEEPTIME          = 33,
+	LL_SIM_STAT_IOPUMPTIME            = 34,
+	LL_SIM_STAT_PCTSCRIPTSRUN         = 35,
+	LL_SIM_STAT_REGION_IDLE           = 36, // dataserver only
+	LL_SIM_STAT_REGION_IDLE_POSSIBLE  = 37, // dataserver only
+	LL_SIM_STAT_SIMAISTEPTIMEMS       = 38,
+	LL_SIM_STAT_SKIPPEDAISILSTEPS_PS  = 39,
+	LL_SIM_STAT_PCTSTEPPEDCHARACTERS  = 40
+};
+
 namespace LLStatViewer
 {
 
@@ -207,7 +252,7 @@ public:
 	LLViewerStats();
 	~LLViewerStats();
 
-	void updateFrameStats(const F64 time_diff);
+	void updateFrameStats(const LLUnit<F64, LLUnits::Seconds> time_diff);
 	
 	void addToMessage(LLSD &body);
 
@@ -323,7 +368,7 @@ public:
 private:
 	LLTrace::Recording				mRecording;
 
-	F64 mLastTimeDiff;  // used for time stat updates
+	LLUnit<F64, LLUnits::Seconds> mLastTimeDiff;  // used for time stat updates
 };
 
 static const F32 SEND_STATS_PERIOD = 300.0f;
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 8036a4e258..16b51c457a 100755
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -920,7 +920,7 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask,
 	}
 
 	handled = TRUE;
-	lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLViewerTextEditor " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLViewerTextEditor " << getName() << llendl;
 
 	return handled;
 }
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 2872c277b1..ed74bc744a 100755
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -29,7 +29,6 @@
 #include "llviewertexture.h"
 
 // Library includes
-#include "imageids.h"
 #include "llmath.h"
 #include "llerror.h"
 #include "llgl.h"
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index dfd7ac983d..9b89ee2ec9 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -30,7 +30,6 @@
 
 #include "llviewertexturelist.h"
 
-#include "imageids.h"
 #include "llgl.h" // fot gathering stats from GL
 #include "llimagegl.h"
 #include "llimagebmp.h"
@@ -285,18 +284,18 @@ void LLViewerTextureList::shutdown()
 
 void LLViewerTextureList::dump()
 {
-	llinfos << "LLViewerTextureList::dump()" << llendl;
+	LL_INFOS() << "LLViewerTextureList::dump()" << LL_ENDL;
 	for (image_priority_list_t::iterator it = mImageList.begin(); it != mImageList.end(); ++it)
 	{
 		LLViewerFetchedTexture* image = *it;
 
-		llinfos << "priority " << image->getDecodePriority()
+		LL_INFOS() << "priority " << image->getDecodePriority()
 		<< " boost " << image->getBoostLevel()
 		<< " size " << image->getWidth() << "x" << image->getHeight()
 		<< " discard " << image->getDiscardLevel()
 		<< " desired " << image->getDesiredDiscardLevel()
 		<< " http://asset.siva.lindenlab.com/" << image->getID() << ".texture"
-		<< llendl;
+		<< LL_ENDL;
 	}
 }
 
@@ -337,7 +336,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
 	std::string full_path = gDirUtilp->findSkinnedFilename("textures", filename);
 	if (full_path.empty())
 	{
-		llwarns << "Failed to find local image file: " << filename << llendl;
+		llwarns << "Failed to find local image file: " << filename << LL_ENDL;
 		return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
 	}
 
@@ -378,7 +377,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
 		LLViewerFetchedTexture *texture = imagep.get();
 		if (texture->getUrl().empty())
 		{
-			llwarns << "Requested texture " << new_id << " already exists but does not have a URL" << llendl;
+			llwarns << "Requested texture " << new_id << " already exists but does not have a URL" << LL_ENDL;
 		}
 		else if (texture->getUrl() != url)
 		{
@@ -386,7 +385,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
 			// e.g. could be two avatars wearing the same outfit.
 			LL_DEBUGS("Avatar") << "Requested texture " << new_id
 								<< " already exists with a different url, requested: " << url
-								<< " current: " << texture->getUrl() << llendl;
+								<< " current: " << texture->getUrl() << LL_ENDL;
 		}
 		
 	}
@@ -401,7 +400,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
 			imagep = new LLViewerLODTexture(url, f_type, new_id, usemipmaps);
 			break ;
 		default:
-			llerrs << "Invalid texture type " << texture_type << llendl ;
+			LL_ERRS() << "Invalid texture type " << texture_type << LL_ENDL ;
 		}		
 		
 		if (internal_format && primary_format)
@@ -458,18 +457,18 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
 		if (request_from_host.isOk() &&
 			!texture->getTargetHost().isOk())
 		{
-			llwarns << "Requested texture " << image_id << " already exists but does not have a host" << llendl;
+			llwarns << "Requested texture " << image_id << " already exists but does not have a host" << LL_ENDL;
 		}
 		else if (request_from_host.isOk() &&
 				 texture->getTargetHost().isOk() &&
 				 request_from_host != texture->getTargetHost())
 		{
 			llwarns << "Requested texture " << image_id << " already exists with a different target host, requested: " 
-					<< request_from_host << " current: " << texture->getTargetHost() << llendl;
+					<< request_from_host << " current: " << texture->getTargetHost() << LL_ENDL;
 		}
 		if (f_type != FTT_DEFAULT && imagep->getFTType() != f_type)
 		{
-			llwarns << "FTType mismatch: requested " << f_type << " image has " << imagep->getFTType() << llendl;
+			llwarns << "FTType mismatch: requested " << f_type << " image has " << imagep->getFTType() << LL_ENDL;
 		}
 		
 	}
@@ -505,7 +504,7 @@ LLViewerFetchedTexture* LLViewerTextureList::createImage(const LLUUID &image_id,
 		imagep = new LLViewerLODTexture(image_id, f_type, request_from_host, usemipmaps);
 		break ;
 	default:
-		llerrs << "Invalid texture type " << texture_type << llendl ;
+		LL_ERRS() << "Invalid texture type " << texture_type << LL_ENDL ;
 	}
 	
 	if (internal_format && primary_format)
@@ -555,11 +554,11 @@ void LLViewerTextureList::addImageToList(LLViewerFetchedTexture *image)
 	llassert(image);
 	if (image->isInImageList())
 	{
-		llerrs << "LLViewerTextureList::addImageToList - Image already in list" << llendl;
+		LL_ERRS() << "LLViewerTextureList::addImageToList - Image already in list" << LL_ENDL;
 	}
 	if((mImageList.insert(image)).second != true) 
 	{
-		llerrs << "Error happens when insert image to mImageList!" << llendl ;
+		LL_ERRS() << "Error happens when insert image to mImageList!" << LL_ENDL ;
 	}
 	
 	image->setInImageList(TRUE) ;
@@ -572,20 +571,20 @@ void LLViewerTextureList::removeImageFromList(LLViewerFetchedTexture *image)
 	llassert(image);
 	if (!image->isInImageList())
 	{
-		llinfos << "RefCount: " << image->getNumRefs() << llendl ;
+		LL_INFOS() << "RefCount: " << image->getNumRefs() << LL_ENDL ;
 		uuid_map_t::iterator iter = mUUIDMap.find(image->getID());
 		if(iter == mUUIDMap.end() || iter->second != image)
 		{
-			llinfos << "Image is not in mUUIDMap!" << llendl ;
+			LL_INFOS() << "Image is not in mUUIDMap!" << LL_ENDL ;
 		}
-		llerrs << "LLViewerTextureList::removeImageFromList - Image not in list" << llendl;
+		LL_ERRS() << "LLViewerTextureList::removeImageFromList - Image not in list" << LL_ENDL;
 	}
 
 	S32 count = mImageList.erase(image) ;
 	if(count != 1) 
 	{
-		llinfos << image->getID() << llendl ;
-		llerrs << "Error happens when remove image from mImageList: " << count << llendl ;
+		LL_INFOS() << image->getID() << LL_ENDL ;
+		LL_ERRS() << "Error happens when remove image from mImageList: " << count << LL_ENDL ;
 	}
       
 	image->setInImageList(FALSE) ;
@@ -595,7 +594,7 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
 {
 	if (!new_image)
 	{
-		llwarning("No image to add to image list", 0);
+		LL_WARNS() << "No image to add to image list" << LL_ENDL;
 		return;
 	}
 	LLUUID image_id = new_image->getID();
@@ -603,7 +602,7 @@ void LLViewerTextureList::addImage(LLViewerFetchedTexture *new_image)
 	LLViewerFetchedTexture *image = findImage(image_id);
 	if (image)
 	{
-		llwarns << "Image with ID " << image_id << " already in list" << llendl;
+		LL_WARNS() << "Image with ID " << image_id << " already in list" << LL_ENDL;
 	}
 	sNumImages++;
 	
@@ -901,7 +900,7 @@ void LLViewerTextureList::setDebugFetching(LLViewerFetchedTexture* tex, S32 debu
  << " host " << target_host
  << " boost " << imagep->getBoostLevel()
  << " imageid " << imagep->getID()
- << llendl;
+ << LL_ENDL;
  imagep->dump();
  }
  return type_from_host;
@@ -1175,13 +1174,13 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename,
 	if (compressedImage.isNull())
 	{
 		image->setLastError("Couldn't convert the image to jpeg2000.");
-		llinfos << "Couldn't convert to j2c, file : " << filename << llendl;
+		LL_INFOS() << "Couldn't convert to j2c, file : " << filename << LL_ENDL;
 		return FALSE;
 	}
 	if (!compressedImage->save(out_filename))
 	{
 		image->setLastError("Couldn't create the jpeg2000 image for upload.");
-		llinfos << "Couldn't create output file : " << out_filename << llendl;
+		LL_INFOS() << "Couldn't create output file : " << out_filename << LL_ENDL;
 		return FALSE;
 	}
 	// Test to see if the encode and save worked
@@ -1189,7 +1188,7 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename,
 	if (!integrity_test->loadAndValidate( out_filename ))
 	{
 		image->setLastError("The created jpeg2000 image is corrupt.");
-		llinfos << "Image file : " << out_filename << " is corrupt" << llendl;
+		LL_INFOS() << "Image file : " << out_filename << " is corrupt" << LL_ENDL;
 		return FALSE;
 	}
 	return TRUE;
@@ -1214,13 +1213,13 @@ LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImage
 		// Read the blocks and precincts size settings
 		S32 block_size = gSavedSettings.getS32("Jpeg2000BlocksSize");
 		S32 precinct_size = gSavedSettings.getS32("Jpeg2000PrecinctsSize");
-		llinfos << "Advanced JPEG2000 Compression: precinct = " << precinct_size << ", block = " << block_size << llendl;
+		LL_INFOS() << "Advanced JPEG2000 Compression: precinct = " << precinct_size << ", block = " << block_size << LL_ENDL;
 		compressedImage->initEncode(*raw_image, block_size, precinct_size, 0);
 	}
 	
 	if (!compressedImage->encode(raw_image, 0.0f))
 	{
-		llinfos << "convertToUploadFile : encode returns with error!!" << llendl;
+		LL_INFOS() << "convertToUploadFile : encode returns with error!!" << LL_ENDL;
 		// Clear up the pointer so we don't leak that one
 		compressedImage = NULL;
 	}
@@ -1276,11 +1275,11 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
 			max_texmem = 128;
 		}
 
-		llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << llendl;
+		llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << LL_ENDL;
 	}
 
 	S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB
-	//llinfos << "*** DETECTED " << system_ram << " MB of system memory." << llendl;
+	//LL_INFOS() << "*** DETECTED " << system_ram << " MB of system memory." << LL_ENDL;
 	if (get_recommended)
 		max_texmem = llmin(max_texmem, (S32)(system_ram/2));
 	else
@@ -1344,8 +1343,8 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem)
 		mMaxTotalTextureMemInMegaBytes = system_ram - min_non_texture_mem ;
 	}
 	
-	llinfos << "Total Video Memory set to: " << vb_mem << " MB" << llendl;
-	llinfos << "Available Texture Memory set to: " << (vb_mem - fb_mem) << " MB" << llendl;
+	LL_INFOS() << "Total Video Memory set to: " << vb_mem << " MB" << LL_ENDL;
+	LL_INFOS() << "Available Texture Memory set to: " << (vb_mem - fb_mem) << " MB" << LL_ENDL;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1394,8 +1393,8 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		// msg->getSizeFast() is probably trying to tell us there
 		// was an error.
-		llerrs << "image header chunk size was negative: "
-		<< data_size << llendl;
+		LL_ERRS() << "image header chunk size was negative: "
+		<< data_size << LL_ENDL;
 		return;
 	}
 	
@@ -1464,13 +1463,13 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 	{
 		// msg->getSizeFast() is probably trying to tell us there
 		// was an error.
-		llerrs << "image data chunk size was negative: "
-		<< data_size << llendl;
+		LL_ERRS() << "image data chunk size was negative: "
+		<< data_size << LL_ENDL;
 		return;
 	}
 	if (data_size > MTUBYTES)
 	{
-		llerrs << "image data chunk too large: " << data_size << " bytes" << llendl;
+		LL_ERRS() << "image data chunk too large: " << data_size << " bytes" << LL_ENDL;
 		return;
 	}
 	U8 *data = new U8[data_size];
@@ -1507,7 +1506,7 @@ void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **
 	LLViewerFetchedTexture* image = gTextureList.findImage( image_id );
 	if( image )
 	{
-		llwarns << "not in db" << llendl;
+		llwarns << "not in db" << LL_ENDL;
 		image->setIsMissingAsset();
 	}
 }
@@ -1634,7 +1633,7 @@ LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::s
 	if (found_it != mUIImages.end())
 	{
 		// image already loaded!
-		llerrs << "UI Image " << name << " already loaded." << llendl;
+		LL_ERRS() << "UI Image " << name << " already loaded." << LL_ENDL;
 	}
 
 	return loadUIImageByName(name, filename, use_mips, scale_rect, clip_rect);
@@ -1737,7 +1736,7 @@ bool LLUIImageList::initFromFile()
 	std::vector<std::string>::const_iterator pi(textures_paths.begin()), pend(textures_paths.end());
 	if (pi == pend)
 	{
-		llwarns << "No textures.xml found in skins directories" << llendl;
+		llwarns << "No textures.xml found in skins directories" << LL_ENDL;
 		return false;
 	}
 
@@ -1745,12 +1744,12 @@ bool LLUIImageList::initFromFile()
 	LLXMLNodePtr root;
 	if (!LLXMLNode::parseFile(*pi, root, NULL))
 	{
-		llwarns << "Unable to parse UI image list file " << *pi << llendl;
+		llwarns << "Unable to parse UI image list file " << *pi << LL_ENDL;
 		return false;
 	}
 	if (!root->hasAttribute("version"))
 	{
-		llwarns << "No valid version number in UI image list file " << *pi << llendl;
+		llwarns << "No valid version number in UI image list file " << *pi << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llviewerwearable.h b/indra/newview/llviewerwearable.h
index 65566f23a5..8f49e3c4e2 100644
--- a/indra/newview/llviewerwearable.h
+++ b/indra/newview/llviewerwearable.h
@@ -29,6 +29,7 @@
 
 #include "llwearable.h"
 #include "llavatarappearancedefines.h"
+#include "llextendedstatus.h"
 
 class LLVOAvatar;
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 10e354f2e3..4ec9485aee 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -76,7 +76,6 @@
 #include "message.h"
 #include "object_flags.h"
 #include "lltimer.h"
-#include "timing.h"
 #include "llviewermenu.h"
 #include "lltooltip.h"
 #include "llmediaentry.h"
@@ -3025,7 +3024,7 @@ void LLViewerWindow::updateUI()
 
 			if( !handled )
 			{
-				lldebugst(LLERR_USER_INPUT) << "hover not handled by mouse captor" << llendl;
+				LL_DEBUGS("UserInput") << "hover not handled by mouse captor" << llendl;
 			}
 		}
 		else
diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp
index 94760e3c83..cd2075b122 100755
--- a/indra/newview/llvlcomposition.cpp
+++ b/indra/newview/llvlcomposition.cpp
@@ -28,7 +28,6 @@
 
 #include "llvlcomposition.h"
 
-#include "imageids.h"
 #include "llerror.h"
 #include "v3math.h"
 #include "llsurface.h"
diff --git a/indra/newview/llvlmanager.cpp b/indra/newview/llvlmanager.cpp
index d8de979f56..b231abc9c5 100755
--- a/indra/newview/llvlmanager.cpp
+++ b/indra/newview/llvlmanager.cpp
@@ -29,23 +29,27 @@
 #include "llvlmanager.h"
 
 #include "indra_constants.h"
-#include "bitpack.h"
 #include "patch_code.h"
 #include "patch_dct.h"
 #include "llviewerregion.h"
 #include "llframetimer.h"
 #include "llsurface.h"
+#include "llbitpack.h"
+
+const	char	LAND_LAYER_CODE					= 'L';
+const	char	WIND_LAYER_CODE					= '7';
+const	char	CLOUD_LAYER_CODE				= '8';
 
 LLVLManager gVLManager;
 
 LLVLManager::~LLVLManager()
 {
 	S32 i;
-	for (i = 0; i < mPacketData.count(); i++)
+	for (i = 0; i < mPacketData.size(); i++)
 	{
 		delete mPacketData[i];
 	}
-	mPacketData.reset();
+	mPacketData.clear();
 }
 
 void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size)
@@ -67,7 +71,7 @@ void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size)
 		llerrs << "Unknown layer type!" << (S32)vl_datap->mType << llendl;
 	}
 
-	mPacketData.put(vl_datap);
+	mPacketData.push_back(vl_datap);
 }
 
 void LLVLManager::unpackData(const S32 num_packets)
@@ -75,7 +79,7 @@ void LLVLManager::unpackData(const S32 num_packets)
 	static LLFrameTimer decode_timer;
 	
 	S32 i;
-	for (i = 0; i < mPacketData.count(); i++)
+	for (i = 0; i < mPacketData.size(); i++)
 	{
 		LLVLData *datap = mPacketData[i];
 
@@ -98,11 +102,11 @@ void LLVLManager::unpackData(const S32 num_packets)
 		}
 	}
 
-	for (i = 0; i < mPacketData.count(); i++)
+	for (i = 0; i < mPacketData.size(); i++)
 	{
 		delete mPacketData[i];
 	}
-	mPacketData.reset();
+	mPacketData.clear();
 
 }
 
@@ -134,12 +138,12 @@ S32 LLVLManager::getTotalBytes() const
 void LLVLManager::cleanupData(LLViewerRegion *regionp)
 {
 	S32 cur = 0;
-	while (cur < mPacketData.count())
+	while (cur < mPacketData.size())
 	{
 		if (mPacketData[cur]->mRegionp == regionp)
 		{
 			delete mPacketData[cur];
-			mPacketData.remove(cur);
+			mPacketData.erase(mPacketData.begin() + cur);
 		}
 		else
 		{
diff --git a/indra/newview/llvlmanager.h b/indra/newview/llvlmanager.h
index 74b4823a5c..0733aebaae 100755
--- a/indra/newview/llvlmanager.h
+++ b/indra/newview/llvlmanager.h
@@ -30,7 +30,6 @@
 // This class manages the data coming in for viewer layers from the network.
 
 #include "stdtypes.h"
-#include "lldarray.h"
 
 class LLVLData;
 class LLViewerRegion;
@@ -55,7 +54,7 @@ public:
 	void cleanupData(LLViewerRegion *regionp);
 protected:
 
-	LLDynamicArray<LLVLData *> mPacketData;
+	std::vector<LLVLData *> mPacketData;
 	U32 mLandBits;
 	U32 mWindBits;
 	U32 mCloudBits;
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 11b027a417..04c1bd3968 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -66,6 +66,7 @@
 #include "llmutelist.h"
 #include "llmoveview.h"
 #include "llnotificationsutil.h"
+#include "llphysicsshapebuilderutil.h"
 #include "llquantize.h"
 #include "llrand.h"
 #include "llregionhandle.h"
@@ -116,16 +117,16 @@ using namespace LLAvatarAppearanceDefines;
 //-----------------------------------------------------------------------------
 // Global constants
 //-----------------------------------------------------------------------------
-const LLUUID ANIM_AGENT_BODY_NOISE = LLUUID("9aa8b0a6-0c6f-9518-c7c3-4f41f2c001ad"); //"body_noise"
-const LLUUID ANIM_AGENT_BREATHE_ROT	= LLUUID("4c5a103e-b830-2f1c-16bc-224aa0ad5bc8");  //"breathe_rot"
-const LLUUID ANIM_AGENT_EDITING	= LLUUID("2a8eba1d-a7f8-5596-d44a-b4977bf8c8bb");  //"editing"
-const LLUUID ANIM_AGENT_EYE	= LLUUID("5c780ea8-1cd1-c463-a128-48c023f6fbea");  //"eye"
-const LLUUID ANIM_AGENT_FLY_ADJUST = LLUUID("db95561f-f1b0-9f9a-7224-b12f71af126e");  //"fly_adjust"
-const LLUUID ANIM_AGENT_HAND_MOTION	= LLUUID("ce986325-0ba7-6e6e-cc24-b17c4b795578");  //"hand_motion"
-const LLUUID ANIM_AGENT_HEAD_ROT = LLUUID("e6e8d1dd-e643-fff7-b238-c6b4b056a68d");  //"head_rot"
-const LLUUID ANIM_AGENT_PELVIS_FIX = LLUUID("0c5dd2a2-514d-8893-d44d-05beffad208b");  //"pelvis_fix"
-const LLUUID ANIM_AGENT_TARGET = LLUUID("0e4896cb-fba4-926c-f355-8720189d5b55");  //"target"
-const LLUUID ANIM_AGENT_WALK_ADJUST	= LLUUID("829bc85b-02fc-ec41-be2e-74cc6dd7215d");  //"walk_adjust"
+const LLUUID ANIM_AGENT_BODY_NOISE     = LLUUID("9aa8b0a6-0c6f-9518-c7c3-4f41f2c001ad"); //"body_noise"
+const LLUUID ANIM_AGENT_BREATHE_ROT	   = LLUUID("4c5a103e-b830-2f1c-16bc-224aa0ad5bc8");  //"breathe_rot"
+const LLUUID ANIM_AGENT_EDITING	       = LLUUID("2a8eba1d-a7f8-5596-d44a-b4977bf8c8bb");  //"editing"
+const LLUUID ANIM_AGENT_EYE	           = LLUUID("5c780ea8-1cd1-c463-a128-48c023f6fbea");  //"eye"
+const LLUUID ANIM_AGENT_FLY_ADJUST     = LLUUID("db95561f-f1b0-9f9a-7224-b12f71af126e");  //"fly_adjust"
+const LLUUID ANIM_AGENT_HAND_MOTION	   = LLUUID("ce986325-0ba7-6e6e-cc24-b17c4b795578");  //"hand_motion"
+const LLUUID ANIM_AGENT_HEAD_ROT       = LLUUID("e6e8d1dd-e643-fff7-b238-c6b4b056a68d");  //"head_rot"
+const LLUUID ANIM_AGENT_PELVIS_FIX     = LLUUID("0c5dd2a2-514d-8893-d44d-05beffad208b");  //"pelvis_fix"
+const LLUUID ANIM_AGENT_TARGET         = LLUUID("0e4896cb-fba4-926c-f355-8720189d5b55");  //"target"
+const LLUUID ANIM_AGENT_WALK_ADJUST	   = LLUUID("829bc85b-02fc-ec41-be2e-74cc6dd7215d");  //"walk_adjust"
 const LLUUID ANIM_AGENT_PHYSICS_MOTION = LLUUID("7360e029-3cb8-ebc4-863e-212df440d987");  //"physics_motion"
 
 
@@ -1313,7 +1314,7 @@ void LLVOAvatar::getSpatialExtents(LLVector4a& newMin, LLVector4a& newMax)
 	for (polymesh_map_t::iterator i = mPolyMeshes.begin(); i != mPolyMeshes.end(); ++i)
 	{
 		LLPolyMesh* mesh = i->second;
-		for (S32 joint_num = 0; joint_num < mesh->mJointRenderData.count(); joint_num++)
+		for (S32 joint_num = 0; joint_num < mesh->mJointRenderData.size(); joint_num++)
 		{
 			LLVector4a trans;
 			trans.load3( mesh->mJointRenderData[joint_num]->mWorldMatrix->getTranslation().mV);
@@ -1638,7 +1639,7 @@ void LLVOAvatar::releaseMeshData()
 		return;
 	}
 
-	//llinfos << "Releasing" << llendl;
+	LL_DEBUGS() << "Releasing mesh data" << LL_ENDL;
 
 	// cleanup mesh data
 	for (avatar_joint_list_t::iterator iter = mMeshLOD.begin();
@@ -7120,30 +7121,32 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 }
 
 // static
-void LLVOAvatar::getAnimLabels( LLDynamicArray<std::string>* labels )
+void LLVOAvatar::getAnimLabels( std::vector<std::string>* labels )
 {
 	S32 i;
+	labels->reserve(gUserAnimStatesCount);
 	for( i = 0; i < gUserAnimStatesCount; i++ )
 	{
-		labels->put( LLAnimStateLabels::getStateLabel( gUserAnimStates[i].mName ) );
+		labels->push_back( LLAnimStateLabels::getStateLabel( gUserAnimStates[i].mName ) );
 	}
 
 	// Special case to trigger away (AFK) state
-	labels->put( "Away From Keyboard" );
+	labels->push_back( "Away From Keyboard" );
 }
 
 // static 
-void LLVOAvatar::getAnimNames( LLDynamicArray<std::string>* names )
+void LLVOAvatar::getAnimNames( std::vector<std::string>* names )
 {
 	S32 i;
 
+	names->reserve(gUserAnimStatesCount);
 	for( i = 0; i < gUserAnimStatesCount; i++ )
 	{
-		names->put( std::string(gUserAnimStates[i].mName) );
+		names->push_back( std::string(gUserAnimStates[i].mName) );
 	}
 
 	// Special case to trigger away (AFK) state
-	names->put( "enter_away_from_keyboard_state" );
+	names->push_back( "enter_away_from_keyboard_state" );
 }
 
 // static
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 0544d7395d..2c86ed63d1 100755
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -35,7 +35,6 @@
 
 #include <boost/signals2/trackable.hpp>
 
-#include "imageids.h"			// IMG_INVISIBLE
 #include "llavatarappearance.h"
 #include "llchat.h"
 #include "lldrawpoolalpha.h"
@@ -853,8 +852,8 @@ public:
 	std::string		getFullname() const; // Returns "FirstName LastName"
 	std::string		avString() const; // Frequently used string in log messages "Avatar '<full name'"
 protected:
-	static void		getAnimLabels(LLDynamicArray<std::string>* labels);
-	static void		getAnimNames(LLDynamicArray<std::string>* names);	
+	static void		getAnimLabels(std::vector<std::string>* labels);
+	static void		getAnimNames(std::vector<std::string>* names);	
 private:
     bool            mNameIsSet;
 	std::string  	mTitle;
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 67da311c5a..117169678e 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -143,8 +143,7 @@ struct LocalTextureData
 // Static Data
 //-----------------------------------------------------------------------------
 S32 LLVOAvatarSelf::sScratchTexBytes = 0;
-LLMap< LLGLenum, LLGLuint*> LLVOAvatarSelf::sScratchTexNames;
-LLMap< LLGLenum, F32*> LLVOAvatarSelf::sScratchTexLastBindTime;
+std::map< LLGLenum, LLGLuint*> LLVOAvatarSelf::sScratchTexNames;
 
 
 /*********************************************************************************
@@ -2543,11 +2542,11 @@ BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const
 													asset_id_matches);
 
 					BOOL can_grab = FALSE;
-					lldebugs << "item count for asset " << texture_id << ": " << items.count() << llendl;
-					if (items.count())
+					lldebugs << "item count for asset " << texture_id << ": " << items.size() << llendl;
+					if (items.size())
 					{
 						// search for full permissions version
-						for (S32 i = 0; i < items.count(); i++)
+						for (S32 i = 0; i < items.size(); i++)
 						{
 							LLViewerInventoryItem* itemp = items[i];
 												if (itemp->getIsFullPerm())
@@ -3060,11 +3059,11 @@ BOOL LLVOAvatarSelf::needsRenderBeam()
 // static
 void LLVOAvatarSelf::deleteScratchTextures()
 {
-	for( LLGLuint* namep = sScratchTexNames.getFirstData(); 
-		 namep; 
-		 namep = sScratchTexNames.getNextData() )
+	for(std::map< LLGLenum, LLGLuint*>::iterator it = sScratchTexNames.begin(), end_it = sScratchTexNames.end();
+		it != end_it;
+		++it)
 	{
-		LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, 0, -1, 1, (U32 *)namep );
+		LLImageGL::deleteTextures(LLTexUnit::TT_TEXTURE, 0, -1, 1, (U32 *)it->second );
 		stop_glerror();
 	}
 
@@ -3072,8 +3071,7 @@ void LLVOAvatarSelf::deleteScratchTextures()
 	{
 		lldebugs << "Clearing Scratch Textures " << (sScratchTexBytes/1024) << "KB" << llendl;
 
-		sScratchTexNames.deleteAllData();
-		sScratchTexLastBindTime.deleteAllData();
+		delete_and_clear(sScratchTexNames);
 		LLImageGL::sGlobalTextureMemory -= sScratchTexBytes;
 		sScratchTexBytes = 0;
 	}
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index 3b7b6bac64..be98f8dfa9 100755
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -30,6 +30,7 @@
 
 #include "llviewertexture.h"
 #include "llvoavatar.h"
+#include <map>
 
 struct LocalTextureData;
 
@@ -276,8 +277,7 @@ public:
 	static void		deleteScratchTextures();
 private:
 	static S32 		sScratchTexBytes;
-	static LLMap< LLGLenum, LLGLuint*> sScratchTexNames;
-	static LLMap< LLGLenum, F32*> sScratchTexLastBindTime;
+	static std::map< LLGLenum, LLGLuint*> sScratchTexNames;
 
 /**                    Textures
  **                                                                            **
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 88ce6df916..62fe6e7b12 100755
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -28,7 +28,6 @@
 
 #include "llvograss.h"
 
-#include "imageids.h"
 #include "llviewercontrol.h"
 
 #include "llagentcamera.h"
diff --git a/indra/newview/llvograss.h b/indra/newview/llvograss.h
index 122806766d..28203c65ae 100755
--- a/indra/newview/llvograss.h
+++ b/indra/newview/llvograss.h
@@ -28,7 +28,6 @@
 #define LL_LLVOGRASS_H
 
 #include "llviewerobject.h"
-#include "lldarray.h"
 #include <map>
 
 class LLSurfacePatch;
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 9b5d981aa5..df5d413407 100755
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -6547,8 +6547,8 @@ void LLVivoxVoiceClient::expireVoiceFonts()
 	// Give a warning notification if any voice fonts are due to expire.
 	if (will_expire)
 	{
-		S32 seconds = gSavedSettings.getS32("VoiceEffectExpiryWarningTime");
-		args["INTERVAL"] = llformat("%d", seconds / SEC_PER_DAY);
+		LLUnit<S32, LLUnits::Seconds> seconds = gSavedSettings.getS32("VoiceEffectExpiryWarningTime");
+		args["INTERVAL"] = llformat("%d", LLUnit<S32, LLUnits::Days>(seconds).value());
 
 		LLNotificationsUtil::add("VoiceEffectsWillExpire", args);
 	}
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 87f6f5c4a4..487227f006 100755
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -46,7 +46,7 @@
 
 const F32 MAX_PART_LIFETIME = 120.f;
 
-extern U64 gFrameTime;
+extern LLUnitImplicit<U64, LLUnits::Microseconds> gFrameTime;
 
 LLPointer<LLVertexBuffer> LLVOPartGroup::sVB = NULL;
 S32 LLVOPartGroup::sVBSlotFree[];
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 0a119e853a..85e8fd8bf4 100755
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -28,11 +28,9 @@
 
 #include "llvosky.h"
 
-#include "imageids.h"
 #include "llfeaturemanager.h"
 #include "llviewercontrol.h"
 #include "llframetimer.h"
-#include "timing.h"
 
 #include "llagent.h"
 #include "llagentcamera.h"
diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h
index 2ecb0303a1..a6077f4a7a 100755
--- a/indra/newview/llvotree.h
+++ b/indra/newview/llvotree.h
@@ -28,7 +28,6 @@
 #define LL_LLVOTREE_H
 
 #include "llviewerobject.h"
-#include "lldarray.h"
 #include "xform.h"
 
 class LLFace;
diff --git a/indra/newview/llvotreenew.h b/indra/newview/llvotreenew.h
deleted file mode 100755
index 0bb07008ca..0000000000
--- a/indra/newview/llvotreenew.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/** 
- * @file llvotreenew.h
- * @brief LLVOTreeNew class header file
- *
- * $LicenseInfo:firstyear=2003&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, 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$
- */
-
-#ifndef LL_LLVOTREENEW_H
-#define LL_LLVOTREENEW_H
-
-#include "llviewerobject.h"
-#include "lldarray.h"
-#include "xform.h"
-
-#include "lltreeparams.h"
-#include "llstrider.h"
-#include "v2math.h"
-#include "v3math.h"
-#include "llviewertexture.h"
-
-class LLFace;
-class LLDrawPool;
-
-// number of static arrays created
-const U8 MAX_SPECIES = 16;	// max species of trees
-const U8 MAX_PARTS = 15;	// trunk, 2 or 3 branches per species?
-const U8 MAX_RES = 6;		// max # cross sections for a branch curve
-const U8 MAX_FLARE = 6;		// max # cross sections for flare of trunk
-const U8 MAX_LEVELS = 3;
-
-// initial vertex array allocations
-const U32 NUM_INIT_VERTS = 5000;			// number of vertices/normals/texcoords
-const U32 NUM_INIT_INDICES = 15000;			// number of indices to vert array (3 vertices per triangle, roughly 3x)
-const U32 NUM_TIMES_TO_DOUBLE = 2;			// if we go over initial allocations, num times to double each step
-
-// for finding the closest parts...
-
-// the parts are searched based on:
-const F32 MAX_LOBES_DIFF = 2;
-const F32 MAX_LOBEDEPTH_DIFF = .3f;
-const F32 MAX_CURVEBACK_DIFF = 20.0f;
-const F32 MAX_CURVE_DIFF = 15.0f;
-const F32 MAX_CURVE_V_DIFF = 20.0f;
-
-const F32 CURVEV_DIVIDER = 10.0f;	// curveV/CURVEV_DIVIDER = # branch variances...
-const U8 MAX_VARS = 3;				// max number of variations of branches
-
-const U8 MAX_RAND_NUMS = 100;		// max number of rand numbers to pregenerate and store
-
-// texture params
-const F32 WIDTH_OF_BARK = .48f;
-
-class LLVOTreeNew : public LLViewerObject
-{
-public:
-
-	// Some random number generators using the pre-generated random numbers
-	// return +- negPos
-	static S32 llrand_signed(S32 negPos)
-	{
-		return (ll_rand((U32)negPos * 2) - negPos);
-	};
-
-	static S32 llrand_signed(S32 negPos, U32 index)
-	{
-		return lltrunc((sRandNums[index % MAX_RAND_NUMS] * (negPos * 2.0f) - negPos));
-	};
-	
-	static S32 llrand_unsigned(S32 pos, U32 index)
-	{
-		return lltrunc((sRandNums[index % MAX_RAND_NUMS] * pos));
-	};
-
-	// return +- negPos
-	static F32 llfrand_signed(F32 negPos)
-	{
-		return (ll_frand(negPos * 2.0f) - negPos);
-	};
-
-	static F32 llfrand_signed(F32 negPos, U32 index)
-	{
-		return (sRandNums[index % MAX_RAND_NUMS] * negPos * 2.0f) - negPos;
-	};
-
-	static F32 llfrand_unsigned(F32 pos, U32 index)
-	{
-		return sRandNums[index % MAX_RAND_NUMS] * pos;
-	};
-
-	// return between 0-pos
-	static F32 llfrand_unsigned(F32 pos)
-	{
-		return ll_frand(pos);
-	};
-
-	static void cleanupTextures() {};	// not needed anymore
-
-	struct TreePart
-	{
-		F32 mRadius;		// scale x/y
-		F32 mLength;		// scale z
-		F32 mCurve;
-		F32 mCurveV;
-		F32 mCurveRes;
-		F32 mCurveBack;
-		U8 mLobes;
-		F32 mLobeDepth;
-		U8 mLevel;
-		U32 mNumTris;
-		U8 mVertsPerSection;
-		U8 mNumVariants;
-
-		// first index into the drawpool arrays for this particular branch
-		U32 mIndiceIndex[MAX_VARS];
-		U32 mOffsets[MAX_VARS][MAX_RES];		// offsets for the partial branch pieces
-		// local section frames for this branch
-		LLMatrix4 mFrames[MAX_VARS][(MAX_RES*(MAX_RES + 1))/2];	// (0...n) + (1...n) + ... + (n-1..n)
-		LLDynamicArray<LLVector3> mFaceNormals;
-
-	};
-
-	LLVOTreeNew(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
-	virtual ~LLVOTreeNew();
-
-	/*virtual*/ 
-	U32 processUpdateMessage(LLMessageSystem *mesgsys,
-											void **user_data,
-											U32 block_num, const EObjectUpdateType update_type,
-											LLDataPacker *dp);
-
-	/*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
-
-	/*virtual*/ void render(LLAgent &agent);
-	/*virtual*/ void updateTextures();
-
-	/*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
-	/*virtual*/ BOOL		updateGeometry(LLDrawable *drawable);
-
-	F32 CalcZStep(TreePart *part, U8 section);
-
-	void createPart(U8 level, F32 length, F32 radius, LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &normals, 
-							LLStrider<LLVector2> &tex_coords, U32 *indices, 
-							U32 &curVertexIndex, U32 &curTexCoordIndex,
-							U32 &curNormalIndex, U32 &curIndiceIndex);
-
-	S32 findSimilarPart(U8 level);
-
-	F32 CalculateSectionRadius(U8 level, F32 y, F32 stemLength, F32 stemRadius);
-	//F32 CalculateVerticalAttraction(U8 level, LLMatrix4 &sectionFrame);
-
-	void createSection(LLMatrix4 &frame, TreePart *part, F32 sectionRadius, F32 stemZ, 
-							  LLStrider<LLVector3> &vertices, LLStrider<LLVector2> &tex_coords, U32 *indices, 
-							  U32 &curVertexIndex, U32 &curTexCoordIndex, U32 &curIndiceIndex, U8 curSection, BOOL firstBranch);
-
-	void genIndicesAndFaceNormalsForLastSection(TreePart *part, U8 numVerts, LLStrider<LLVector3> &vertices, U32 curVertexIndex, U32 *indices, U32 &curIndiceIndex, BOOL firstBranch);
-
-	void genVertexNormals(TreePart *part, LLStrider<LLVector3> &normals, U8 numSections, U32 curNormalOffset);
-
-	void drawTree(LLDrawPool &draw_pool, const LLMatrix4 &frame, U8 level, F32 offsetChild, F32 curLength, F32 parentLength, F32 curRadius, F32 parentRadius, U8 part, U8 variant, U8 startSection);
-	void drawTree(LLDrawPool &draw_pool);
-
-	
-	//LLTreeParams mParams;
-	U8 mSpecies;
-	LLPointer<LLViewerTexture> mTreeImagep;
-	LLMatrix4 mTrunkFlareFrames[MAX_FLARE];
-	F32 mSegSplitsError[3];
-	U32 mRandOffset[MAX_LEVELS];
-
-	U32 mNumTrisDrawn;
-	U32 mTotalIndices;
-	U32 mTotalVerts;
-
-	static void initClass();
-
-	// tree params
-	static LLTreeParams sParameters;
-
-	// next indexes used to drawpool arrays
-	static U32 sNextVertexIndex[MAX_SPECIES];
-	static U32 sNextIndiceIndex[MAX_SPECIES];
-
-	// tree parts
-	static U32 sNextPartIndex[MAX_PARTS];
-	static TreePart sTreeParts[MAX_SPECIES][MAX_PARTS];
-
-	// species images
-	static LLUUID sTreeImageIDs[MAX_SPECIES];
-
-	// random numbers
-	static F32 sRandNums[MAX_RAND_NUMS];
-
-	// usage data
-	static U32 sTreePartsUsed[MAX_SPECIES][MAX_PARTS][MAX_VARS];
-	
-	
-};
-
-#endif
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 006011c2e7..632f4d178a 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -47,7 +47,6 @@
 #include "message.h"
 #include "llpluginclassmedia.h" // for code in the mediaEvent handler
 #include "object_flags.h"
-#include "llagentconstants.h"
 #include "lldrawable.h"
 #include "lldrawpoolavatar.h"
 #include "lldrawpoolbump.h"
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index 50e7ed7bb5..fc85a670b5 100755
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -28,7 +28,6 @@
 
 #include "llvowater.h"
 
-#include "imageids.h"
 #include "llviewercontrol.h"
 
 #include "lldrawable.h"
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index 4f52ff9778..ec1f0389ea 100755
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -89,7 +89,7 @@ void LLWaterParamManager::loadAllPresets()
 
 void LLWaterParamManager::loadPresetsFromDir(const std::string& dir)
 {
-	LL_INFOS2("AppInit", "Shaders") << "Loading water presets from " << dir << LL_ENDL;
+	LL_INFOS("AppInit", "Shaders") << "Loading water presets from " << dir << LL_ENDL;
 
 	LLDirIterator dir_iter(dir, "*.xml");
 	while (1)
@@ -119,7 +119,7 @@ bool LLWaterParamManager::loadPreset(const std::string& path)
 		return false;
 	}
 
-	LL_DEBUGS2("AppInit", "Shaders") << "Loading water " << name << LL_ENDL;
+	LL_DEBUGS("AppInit", "Shaders") << "Loading water " << name << LL_ENDL;
 
 	LLSD params_data;
 	LLPointer<LLSDParser> parser = new LLSDXMLParser();
diff --git a/indra/newview/llwearableitemslist.h b/indra/newview/llwearableitemslist.h
index a8a5ef3117..58a00c5be0 100755
--- a/indra/newview/llwearableitemslist.h
+++ b/indra/newview/llwearableitemslist.h
@@ -258,7 +258,7 @@ public:
 
 		if (!wearable_item1 || !wearable_item2)
 		{
-			llwarning("item1 and item2 cannot be null", 0);
+			LL_WARNS() << "item1 and item2 cannot be null" << LL_ENDL;
 			return true;
 		}
 
diff --git a/indra/newview/llwind.h b/indra/newview/llwind.h
index 3b57f07124..e73d1baa58 100755
--- a/indra/newview/llwind.h
+++ b/indra/newview/llwind.h
@@ -35,6 +35,8 @@ class LLVector3;
 class LLBitPack;
 class LLGroupHeader;
 
+const F32 WIND_SCALE_HACK		= 2.0f;	// hack to make wind speeds more realistic
+
 
 class LLWind  
 {
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index 6077208799..c729d6ff4f 100755
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -272,7 +272,7 @@ void LLWLParamManager::loadAllPresets()
 
 void LLWLParamManager::loadPresetsFromDir(const std::string& dir)
 {
-	LL_INFOS2("AppInit", "Shaders") << "Loading sky presets from " << dir << LL_ENDL;
+	LL_INFOS("AppInit", "Shaders") << "Loading sky presets from " << dir << LL_ENDL;
 
 	LLDirIterator dir_iter(dir, "*.xml");
 	while (1)
@@ -302,7 +302,7 @@ bool LLWLParamManager::loadPreset(const std::string& path)
 		return false;
 	}
 
-	LL_DEBUGS2("AppInit", "Shaders") << "Loading sky " << name << LL_ENDL;
+	LL_DEBUGS("AppInit", "Shaders") << "Loading sky " << name << LL_ENDL;
 
 	LLSD params_data;
 	LLPointer<LLSDParser> parser = new LLSDXMLParser();
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 3dfe4c5e5f..9659da6bf1 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -971,12 +971,12 @@ LLViewerTexture* LLWorld::getDefaultWaterTexture()
 	return mDefaultWaterTexturep;
 }
 
-void LLWorld::setSpaceTimeUSec(const U64 space_time_usec)
+void LLWorld::setSpaceTimeUSec(const LLUnitImplicit<U64, LLUnits::Microseconds> space_time_usec)
 {
 	mSpaceTimeUSec = space_time_usec;
 }
 
-U64 LLWorld::getSpaceTimeUSec() const
+LLUnitImplicit<U64, LLUnits::Microseconds> LLWorld::getSpaceTimeUSec() const
 {
 	return mSpaceTimeUSec;
 }
@@ -1244,13 +1244,13 @@ void LLWorld::getAvatars(uuid_vec_t* avatar_ids, std::vector<LLVector3d>* positi
 	{
 		LLViewerRegion* regionp = *iter;
 		const LLVector3d& origin_global = regionp->getOriginGlobal();
-		S32 count = regionp->mMapAvatars.count();
+		S32 count = regionp->mMapAvatars.size();
 		for (S32 i = 0; i < count; i++)
 		{
-			LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars.get(i), origin_global);
+			LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars.at(i), origin_global);
 			if(dist_vec_squared(pos_global, relative_to) <= radius_squared)
 			{
-				LLUUID uuid = regionp->mMapAvatarIDs.get(i);
+				LLUUID uuid = regionp->mMapAvatarIDs.at(i);
 				// if this avatar doesn't already exist in the list, add it
 				if(uuid.notNull() && avatar_ids != NULL && std::find(avatar_ids->begin(), avatar_ids->end(), uuid) == avatar_ids->end())
 				{
diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h
index d94c27c428..c74ac3fa6f 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 U64 space_time_usec);
-	U64 getSpaceTimeUSec() const;
+	void setSpaceTimeUSec(const LLUnitImplicit<U64, LLUnits::Microseconds> space_time_usec);
+	LLUnitImplicit<U64, LLUnits::Microseconds> getSpaceTimeUSec() const;
 
 	void getInfo(LLSD& info);
 	U32  getNumOfActiveCachedObjects() const {return mNumOfActiveCachedObjects;}
@@ -189,7 +189,7 @@ private:
 	S32 mLastPacketsOut;
 	S32 mLastPacketsLost;
 	U32 mNumOfActiveCachedObjects;
-	U64 mSpaceTimeUSec;
+	LLUnitImplicit<U64, LLUnits::Microseconds> mSpaceTimeUSec;
 
 	BOOL mClassicCloudsEnabled;
 
diff --git a/indra/newview/llworldmap.h b/indra/newview/llworldmap.h
index d514b2f14c..1a168e4b4d 100755
--- a/indra/newview/llworldmap.h
+++ b/indra/newview/llworldmap.h
@@ -38,6 +38,18 @@
 #include "llviewertexture.h"
 #include "llgltexture.h"
 
+// map item types
+const U32 MAP_ITEM_TELEHUB = 0x01;
+const U32 MAP_ITEM_PG_EVENT = 0x02;
+const U32 MAP_ITEM_MATURE_EVENT = 0x03;
+//const U32 MAP_ITEM_POPULAR = 0x04;		// No longer supported, 2009-03-02 KLW
+//const U32 MAP_ITEM_AGENT_COUNT = 0x05;
+const U32 MAP_ITEM_AGENT_LOCATIONS = 0x06;
+const U32 MAP_ITEM_LAND_FOR_SALE = 0x07;
+const U32 MAP_ITEM_CLASSIFIED = 0x08;
+const U32 MAP_ITEM_ADULT_EVENT = 0x09;
+const U32 MAP_ITEM_LAND_FOR_SALE_ADULT = 0x0a;
+
 // Description of objects like hubs, events, land for sale, people and more (TBD).
 // Note: we don't store a "type" in there so we need to store instances of this class in 
 // well known objects (i.e. list of objects which type is "well known").
diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp
index 6759328b84..977d967a76 100755
--- a/indra/newview/llworldmapview.cpp
+++ b/indra/newview/llworldmapview.cpp
@@ -1723,7 +1723,7 @@ BOOL LLWorldMapView::handleHover( S32 x, S32 y, MASK mask )
 		{
 			gViewerWindow->setCursor( UI_CURSOR_CROSS );
 		}
-		lldebugst(LLERR_USER_INPUT) << "hover handled by LLWorldMapView" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLWorldMapView" << llendl;		
 		return TRUE;
 	}
 }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 870ee6a103..1d9137c161 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -30,7 +30,6 @@
 
 // library includes
 #include "llaudioengine.h" // For debugging.
-#include "imageids.h"
 #include "llerror.h"
 #include "llviewercontrol.h"
 #include "llfasttimer.h"
@@ -40,7 +39,6 @@
 #include "llprimitive.h"
 #include "llvolume.h"
 #include "material_codes.h"
-#include "timing.h"
 #include "v3color.h"
 #include "llui.h" 
 #include "llglheaders.h"
diff --git a/indra/newview/roles_constants.h b/indra/newview/roles_constants.h
new file mode 100755
index 0000000000..effd15ea72
--- /dev/null
+++ b/indra/newview/roles_constants.h
@@ -0,0 +1,192 @@
+/** 
+ * @file roles_constants.h
+ * @brief General Roles Constants
+ *
+ * $LicenseInfo:firstyear=2006&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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$
+ */
+
+#ifndef LL_ROLES_CONSTANTS_H
+#define LL_ROLES_CONSTANTS_H
+
+// This value includes the everyone group.
+const S32 MAX_ROLES = 10;
+
+enum LLRoleMemberChangeType
+{
+	RMC_ADD,
+	RMC_REMOVE,
+	RMC_NONE
+};
+
+enum LLRoleChangeType
+{
+	RC_UPDATE_NONE,
+	RC_UPDATE_DATA,
+	RC_UPDATE_POWERS,
+	RC_UPDATE_ALL,
+	RC_CREATE,
+	RC_DELETE
+};
+
+//
+// Powers
+//
+
+// KNOWN HOLES: use these for any single bit powers you need
+// bit 0x1 << 46
+// bit 0x1 << 49 and above
+
+// These powers were removed to make group roles simpler
+// bit 0x1 << 41 (GP_ACCOUNTING_VIEW)
+// bit 0x1 << 46 (GP_PROPOSAL_VIEW)
+
+const U64 GP_NO_POWERS = 0x0;
+const U64 GP_ALL_POWERS = 0xFFFFFFFFFFFFFFFFLL;
+
+// Membership
+const U64 GP_MEMBER_INVITE		= 0x1 << 1;		// Invite member
+const U64 GP_MEMBER_EJECT			= 0x1 << 2;		// Eject member from group
+const U64 GP_MEMBER_OPTIONS		= 0x1 << 3;		// Toggle "Open enrollment" and change "Signup Fee"
+const U64 GP_MEMBER_VISIBLE_IN_DIR = 0x1LL << 47;
+
+// Roles
+const U64 GP_ROLE_CREATE			= 0x1 << 4;		// Create new roles
+const U64 GP_ROLE_DELETE			= 0x1 << 5;		// Delete roles
+const U64 GP_ROLE_PROPERTIES		= 0x1 << 6;		// Change Role Names, Titles, and Descriptions (Of roles the user is in, only, or any role in group?)
+const U64 GP_ROLE_ASSIGN_MEMBER_LIMITED = 0x1 << 7; // Assign Member to a Role that the assigner is in
+const U64 GP_ROLE_ASSIGN_MEMBER	= 0x1 << 8;		// Assign Member to Role
+const U64 GP_ROLE_REMOVE_MEMBER	= 0x1 << 9;		// Remove Member from Role
+const U64 GP_ROLE_CHANGE_ACTIONS	= 0x1 << 10;	// Change actions a role can perform
+
+// Group Identity
+const U64 GP_GROUP_CHANGE_IDENTITY = 0x1 << 11;	// Charter, insignia, 'Show In Group List', 'Publish on the web', 'Mature', all 'Show Member In Group Profile' checkboxes
+
+// Parcel Management
+const U64 GP_LAND_DEED			= 0x1 << 12;	// Deed Land and Buy Land for Group
+const U64 GP_LAND_RELEASE			= 0x1 << 13;	// Release Land (to Gov. Linden)
+const U64 GP_LAND_SET_SALE_INFO	= 0x1 << 14;	// Set for sale info (Toggle "For Sale", Set Price, Set Target, Toggle "Sell objects with the land")
+const U64 GP_LAND_DIVIDE_JOIN		= 0x1 << 15;	// Divide and Join Parcels
+
+// Parcel Identity
+const U64 GP_LAND_FIND_PLACES		= 0x1 << 17;	// Toggle "Show in Find Places" and Set Category.
+const U64 GP_LAND_CHANGE_IDENTITY = 0x1 << 18;	// Change Parcel Identity: Parcel Name, Parcel Description, Snapshot, 'Publish on the web', and 'Mature' checkbox
+const U64 GP_LAND_SET_LANDING_POINT = 0x1 << 19;	// Set Landing Point
+
+// Parcel Settings
+const U64 GP_LAND_CHANGE_MEDIA	= 0x1 << 20;	// Change Media Settings
+const U64 GP_LAND_EDIT			= 0x1 << 21;	// Toggle Edit Land
+const U64 GP_LAND_OPTIONS			= 0x1 << 22;	// Toggle Set Home Point, Fly, Outside Scripts, Create/Edit Objects, Landmark, and Damage checkboxes
+
+// Parcel Powers
+const U64 GP_LAND_ALLOW_EDIT_LAND = 0x1 << 23;	// Bypass Edit Land Restriction
+const U64 GP_LAND_ALLOW_FLY		= 0x1 << 24;	// Bypass Fly Restriction
+const U64 GP_LAND_ALLOW_CREATE	= 0x1 << 25;	// Bypass Create/Edit Objects Restriction
+const U64 GP_LAND_ALLOW_LANDMARK	= 0x1 << 26;	// Bypass Landmark Restriction
+const U64 GP_LAND_ALLOW_SET_HOME	= 0x1 << 28;	// Bypass Set Home Point Restriction
+const U64 GP_LAND_ALLOW_HOLD_EVENT	= 0x1LL << 41;	// Allowed to hold events on group-owned land
+
+
+// Parcel Access
+const U64 GP_LAND_MANAGE_ALLOWED	= 0x1 << 29;	// Manage Allowed List
+const U64 GP_LAND_MANAGE_BANNED	= 0x1 << 30;	// Manage Banned List
+const U64 GP_LAND_MANAGE_PASSES	= 0x1LL << 31;	// Change Sell Pass Settings
+const U64 GP_LAND_ADMIN			= 0x1LL << 32;	// Eject and Freeze Users on the land
+
+// Parcel Content
+const U64 GP_LAND_RETURN_GROUP_SET	= 0x1LL << 33;	// Return objects on parcel that are set to group
+const U64 GP_LAND_RETURN_NON_GROUP	= 0x1LL << 34;	// Return objects on parcel that are not set to group
+const U64 GP_LAND_RETURN_GROUP_OWNED= 0x1LL << 48;	// Return objects on parcel that are owned by the group
+
+// Select a power-bit based on an object's relationship to a parcel.
+const U64 GP_LAND_RETURN		= GP_LAND_RETURN_GROUP_OWNED 
+								| GP_LAND_RETURN_GROUP_SET	
+								| GP_LAND_RETURN_NON_GROUP;
+
+const U64 GP_LAND_GARDENING		= 0x1LL << 35;	// Parcel Gardening - plant and move linden trees
+
+// Object Management
+const U64 GP_OBJECT_DEED			= 0x1LL << 36;	// Deed Object
+const U64 GP_OBJECT_MANIPULATE		= 0x1LL << 38;	// Manipulate Group Owned Objects (Move, Copy, Mod)
+const U64 GP_OBJECT_SET_SALE		= 0x1LL << 39;	// Set Group Owned Object for Sale
+
+// Accounting
+const U64 GP_ACCOUNTING_ACCOUNTABLE = 0x1LL << 40;	// Pay Group Liabilities and Receive Group Dividends
+
+// Notices
+const U64 GP_NOTICES_SEND			= 0x1LL << 42;	// Send Notices
+const U64 GP_NOTICES_RECEIVE		= 0x1LL << 43;	// Receive Notices and View Notice History
+
+// Proposals
+// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856:
+const U64 GP_PROPOSAL_START		= 0x1LL << 44;	// Start Proposal
+// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856:
+const U64 GP_PROPOSAL_VOTE		= 0x1LL << 45;	// Vote on Proposal
+
+// Group chat moderation related
+const U64 GP_SESSION_JOIN = 0x1LL << 16; //can join session
+const U64 GP_SESSION_VOICE = 0x1LL << 27; //can hear/talk
+const U64 GP_SESSION_MODERATOR = 0x1LL << 37; //can mute people's session
+
+const U64 GP_DEFAULT_MEMBER = GP_ACCOUNTING_ACCOUNTABLE
+								| GP_LAND_ALLOW_SET_HOME
+								| GP_NOTICES_RECEIVE
+								| GP_SESSION_JOIN
+								| GP_SESSION_VOICE
+								;
+
+const U64 GP_DEFAULT_OFFICER = GP_DEFAULT_MEMBER // Superset of GP_DEFAULT_MEMBER
+								| GP_GROUP_CHANGE_IDENTITY
+								| GP_LAND_ADMIN
+								| GP_LAND_ALLOW_EDIT_LAND
+								| GP_LAND_ALLOW_FLY
+								| GP_LAND_ALLOW_CREATE
+								| GP_LAND_ALLOW_LANDMARK
+								| GP_LAND_CHANGE_IDENTITY
+								| GP_LAND_CHANGE_MEDIA
+								| GP_LAND_DEED
+								| GP_LAND_DIVIDE_JOIN
+								| GP_LAND_EDIT
+								| GP_LAND_FIND_PLACES
+								| GP_LAND_GARDENING
+								| GP_LAND_MANAGE_ALLOWED
+								| GP_LAND_MANAGE_BANNED
+								| GP_LAND_MANAGE_PASSES
+								| GP_LAND_OPTIONS
+								| GP_LAND_RELEASE
+								| GP_LAND_RETURN_GROUP_OWNED
+								| GP_LAND_RETURN_GROUP_SET
+								| GP_LAND_RETURN_NON_GROUP
+								| GP_LAND_SET_LANDING_POINT
+								| GP_LAND_SET_SALE_INFO
+								| GP_MEMBER_EJECT
+								| GP_MEMBER_INVITE	
+								| GP_MEMBER_OPTIONS
+								| GP_MEMBER_VISIBLE_IN_DIR
+								| GP_NOTICES_SEND
+								| GP_OBJECT_DEED
+								| GP_OBJECT_MANIPULATE
+								| GP_OBJECT_SET_SALE
+								| GP_ROLE_ASSIGN_MEMBER_LIMITED
+								| GP_ROLE_PROPERTIES
+								| GP_SESSION_MODERATOR
+								;
+#endif
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index ba43c24ad3..d4dbb487f1 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -65,8 +65,7 @@
           <stat_bar name="ktrisframe"
                     label="KTris per Frame"
                     unit_label="ktris/fr"
-                    stat="trianglesdrawnstat"
-                    show_per_sec="false"/>
+                    stat="trianglesdrawnperframestat"/>
           <stat_bar name="ktrissec"
                     label="KTris per Sec"
                     stat="trianglesdrawnstat"/>
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 29393bf749..9f02e90ea3 100755
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -2402,6 +2402,7 @@ Drag folders to this area and click "Send to Marketplace" to list them for sale
 
 	<!-- compile queue-->
 	<string name="CompileQueueDownloadedCompiling">Downloaded, now compiling</string>
+	<string name="CompileQueueServiceUnavailable">Script compilation service not available</string>
 	<string name="CompileQueueScriptNotFound">Script not found on server.</string>
 	<string name="CompileQueueProblemDownloading">Problem downloading</string>
 	<string name="CompileQueueInsufficientPermDownload">Insufficient permissions to download a script.</string>
-- 
cgit v1.2.3


From 910874a7e32bdfc456474e2d0ee84d190be3011e Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 30 Jul 2013 19:14:19 -0700
Subject: more cleanup

---
 indra/newview/llappviewer.cpp | 1 -
 1 file changed, 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 9c954e5a67..d544b992ef 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -93,7 +93,6 @@
 #include "llvocache.h"
 #include "llvopartgroup.h"
 #include "llweb.h"
-#include "llsecondlifeurls.h"
 #include "llupdaterservice.h"
 #include "llfloatertexturefetchdebugger.h"
 #include "llspellcheck.h"
-- 
cgit v1.2.3


From 15fe4b3bbaf139960f934b629c236092182ed297 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 30 Jul 2013 22:05:12 -0600
Subject: fix for SH-4297: interesting: viewer-interesting starts loading
 cached scene late

---
 indra/newview/app_settings/settings.xml | 11 ++++++
 indra/newview/llviewerregion.cpp        | 64 ++++++++++++++++++++++++---------
 indra/newview/llviewerregion.h          |  4 +--
 indra/newview/llvocache.cpp             | 10 ++++--
 4 files changed, 69 insertions(+), 20 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index f0be4e394e..2a4e10fb6f 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6295,6 +6295,17 @@
       <key>Value</key>
       <integer>130</integer>
     </map>
+    <key>NewObjectCreationThrottle</key>
+    <map>
+      <key>Comment</key>
+      <string>maximum number of new objects created per frame, -1 to disable this throttle</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>S32</string>
+      <key>Value</key>
+      <integer>64</integer>
+    </map>
     <key>NextOwnerCopy</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index cd8466d948..65e190a927 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -71,6 +71,7 @@
 #include "llviewercontrol.h"
 #include "llsdserialize.h"
 #include "llvieweroctree.h"
+#include "llviewerdisplay.h"
 
 #ifdef LL_WINDOWS
 	#pragma warning(disable:4355)
@@ -992,8 +993,7 @@ void LLViewerRegion::removeFromVOCacheTree(LLVOCacheEntry* entry)
 		return;
 	}
 
-	mImpl->mVOCachePartition->removeEntry(entry->getEntry());
-	entry->mLastCameraUpdated = sLastCameraUpdated;
+	mImpl->mVOCachePartition->removeEntry(entry->getEntry());	
 }
 
 //add the visible entries
@@ -1128,7 +1128,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	return 2.0f * max_time - update_timer.getElapsedTimeF32();
 }
 
-F32 LLViewerRegion::createVisibleObjects(F32 max_time)
+F32 LLViewerRegion::createVisibleObjects(F32 max_time, S32 throttle)
 {
 	if(mDead)
 	{
@@ -1139,8 +1139,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 		return max_time;
 	}
 
-	LLTimer update_timer;
-	S32 max_num_objects = 64; //minimum number of new objects to be added
+	LLTimer update_timer;	
 	for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin();
 		iter != mImpl->mWaitingList.end(); ++iter)
 	{
@@ -1149,7 +1148,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{
 			addNewObject(vo_entry);
-			if(max_num_objects-- < 0 && update_timer.getElapsedTimeF32() > max_time)
+			if(throttle > 0 && !(--throttle) && update_timer.getElapsedTimeF32() > max_time)
 			{
 				break;
 			}
@@ -1161,6 +1160,8 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 
 BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 {
+	static LLCachedControl<S32> new_object_creation_throttle(gSavedSettings,"NewObjectCreationThrottle");
+
 	LLTimer update_timer;
 
 	// did_update returns TRUE if we did at least one significant update
@@ -1171,23 +1172,54 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 		// Hopefully not a significant time sink...
 		mParcelOverlay->idleUpdate();
 	}
+	
+	if(!sVOCacheCullingEnabled)
+	{
+		return did_update;
+	}
+	if(mImpl->mCacheMap.empty())
+	{
+		return did_update;
+	}
+
+	max_update_time -= update_timer.getElapsedTimeF32();	
 
-	max_update_time -= update_timer.getElapsedTimeF32();
-	if(max_update_time < 0.f || mImpl->mCacheMap.empty())
+	//update the throttling number
+	static S32 throttle = new_object_creation_throttle;
+	if(LLStartUp::getStartupState() < STATE_STARTED || gTeleportDisplay)
 	{
-	return did_update;
-}
+		throttle = -1; //cancel the throttling
 
-	if(!sVOCacheCullingEnabled)
+		S32 occlusion = LLPipeline::sUseOcclusion;
+		LLPipeline::sUseOcclusion = 0; //disable occlusion
+		
+		//apply octree cullings here to pick up visible objects because rendering pipeline stops view culling at this moment
+		mImpl->mVOCachePartition->cull(*LLViewerCamera::getInstance());
+		
+		LLPipeline::sUseOcclusion = occlusion;
+	}	
+	else if(throttle < 0) //just recoved from the login/teleport screen
+	{
+		if(new_object_creation_throttle > 0)
+		{
+			throttle = 4096; //a big number
+		}
+	}
+	else
+	{
+		throttle = llmax((S32)new_object_creation_throttle, (S32)(throttle >> 1));
+	}
+
+	if(max_update_time < 0.f && throttle > 0 && throttle < new_object_creation_throttle * 2)
 	{
 		return did_update;
 	}
 
 	//kill invisible objects
-	max_update_time = killInvisibleObjects(max_update_time);	
+	max_update_time = killInvisibleObjects(max_update_time, throttle);	
 	
 	max_update_time = updateVisibleEntries(max_update_time);
-	createVisibleObjects(max_update_time);
+	createVisibleObjects(max_update_time, throttle);
 
 	mImpl->mWaitingList.clear();
 	mImpl->mVisibleGroups.clear();
@@ -1195,7 +1227,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	return did_update;
 }
 
-F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
+F32 LLViewerRegion::killInvisibleObjects(F32 max_time, S32 throttle)
 {
 #if 1
 	if(!sVOCacheCullingEnabled)
@@ -1209,7 +1241,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 
 	static LLVOCacheEntry* last_visited_entry = NULL;
 
-	const size_t MAX_UPDATE = 32; 
+	const size_t MAX_UPDATE = throttle < 0 ? mImpl->mActiveSet.size() : 64; 
 	std::vector<LLDrawable*> delete_list;
 	S32 update_counter = llmin(MAX_UPDATE, mImpl->mActiveSet.size());
 	LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(last_visited_entry);	
@@ -1823,7 +1855,7 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 	else if(entry->getGroup() != NULL)
 	{
 		return; //already in octree, no post processing.
-	}
+	}	
 
 	LLVector3 pos;
 	LLVector3 scale;
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 2ac934d19c..366462e22f 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -370,8 +370,8 @@ private:
 	void replaceVisibleCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
 	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
 
-	F32 killInvisibleObjects(F32 max_time);
-	F32 createVisibleObjects(F32 max_time);
+	F32 killInvisibleObjects(F32 max_time, S32 throttle);
+	F32 createVisibleObjects(F32 max_time, S32 throttle);
 	F32 updateVisibleEntries(F32 max_time); //update visible entries
 
 	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 6e0243e985..d1c27edce7 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -219,15 +219,21 @@ void LLVOCacheEntry::setState(U32 state)
 
 	if(getState() == ACTIVE)
 	{
-		const S32 MIN_REAVTIVE_INTERVAL = 128;
+		const S32 MIN_INTERVAL = 64 + mMinFrameRange;
 		U32 last_visible = getVisible();
 		
 		setVisible();
 
-		if(getVisible() - last_visible > MIN_REAVTIVE_INTERVAL + mMinFrameRange)
+		U32 cur_visible = getVisible();
+		if(cur_visible - last_visible > MIN_INTERVAL ||
+			cur_visible < MIN_INTERVAL)
 		{
 			mLastCameraUpdated = 0; //reset
 		}
+		else
+		{
+			mLastCameraUpdated = LLViewerRegion::sLastCameraUpdated;
+		}
 	}
 }
 
-- 
cgit v1.2.3


From c5651d05fd57b01703999cd3885fb45c69143419 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 31 Jul 2013 11:18:18 -0600
Subject: fix some compiling errors.

---
 indra/newview/llappviewerwin32.cpp | 2 +-
 indra/newview/llstartup.cpp        | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index f08d2c2a03..4805695e7f 100755
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -567,7 +567,7 @@ bool LLAppViewerWin32::initHardwareTest()
 			if (OSBTN_NO== button)
 			{
 				LL_INFOS("AppInit") << "User quitting after failed DirectX 9 detection" << LL_ENDL;
-				LLWeb::loadURLExternal("http://secondlife.com/support/, false);
+				LLWeb::loadURLExternal("http://secondlife.com/support/", false);
 				return false;
 			}
 			gWarningSettings.setBOOL("AboutDirectX9", FALSE);
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index e0b96e43a6..933cc74064 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -73,7 +73,6 @@
 #include "llsd.h"
 #include "llsdserialize.h"
 #include "llsdutil_math.h"
-#include "llsecondlifeurls.h"
 #include "llstring.h"
 #include "lluserrelations.h"
 #include "llversioninfo.h"
@@ -130,7 +129,6 @@
 #include "llpreviewscript.h"
 #include "llproxy.h"
 #include "llproductinforequest.h"
-#include "llsecondlifeurls.h"
 #include "llselectmgr.h"
 #include "llsky.h"
 #include "llstatview.h"
-- 
cgit v1.2.3


From e87ba587555d2a70e87dd0b204be2d586920d50f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 31 Jul 2013 14:49:12 -0700
Subject: BUILDFIX: bad argument to llformat

---
 indra/newview/llviewerstats.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 94be8e2a83..69198ed53d 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -593,7 +593,7 @@ void send_stats()
 	S32 window_height = gViewerWindow->getWindowHeightRaw();
 	S32 window_size = (window_width * window_height) / 1024;
 	misc["string_1"] = llformat("%d", window_size);
-	misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds);
+	misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds.value());
 
 // 	misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21
 // 	misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21
-- 
cgit v1.2.3


From bd5808765f7a74226d312afbb863c471528b8d1a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 31 Jul 2013 19:32:50 -0700
Subject: cleanup - renamed valueAs to valueInUnits and made it a symmetrical
 getter/setter

---
 indra/newview/llfasttimerview.cpp | 2 +-
 indra/newview/llscenemonitor.cpp  | 2 +-
 indra/newview/lltextureinfo.cpp   | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index b61889ccfa..4037b5ebdd 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -1427,7 +1427,7 @@ void LLFastTimerView::updateTotalTime()
 		break;
 	}
 
-	mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil(mTotalTimeDisplay.valueAs<LLUnits::Milliseconds>() / 20.f) * 20.f);
+	mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil(mTotalTimeDisplay.valueInUnits<LLUnits::Milliseconds>() / 20.f) * 20.f);
 }
 
 void LLFastTimerView::drawBars()
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 022a950ece..7fdee2b2ad 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -642,7 +642,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).valueAs<LLUnits::Kibibytes>();
+			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).valueInUnits<LLUnits::Kibibytes>();
 		}
 
 		os << '\n';
diff --git a/indra/newview/lltextureinfo.cpp b/indra/newview/lltextureinfo.cpp
index 3ae85d56da..d467fd4d97 100755
--- a/indra/newview/lltextureinfo.cpp
+++ b/indra/newview/lltextureinfo.cpp
@@ -200,11 +200,11 @@ LLSD LLTextureInfo::getAverages()
 	}
 	else
 	{
-		averageDownloadRate = mRecording.getSum(sTextureDataDownloaded).valueAs<LLUnits::Bits>() / download_time.valueAs<LLUnits::Seconds>();
+		averageDownloadRate = mRecording.getSum(sTextureDataDownloaded).valueInUnits<LLUnits::Bits>() / download_time.valueInUnits<LLUnits::Seconds>();
 	}
 
 	averagedTextureData["bits_per_second"]             = averageDownloadRate;
-	averagedTextureData["bytes_downloaded"]            = mRecording.getSum(sTextureDataDownloaded).valueAs<LLUnits::Bytes>();
+	averagedTextureData["bytes_downloaded"]            = mRecording.getSum(sTextureDataDownloaded).valueInUnits<LLUnits::Bytes>();
 	averagedTextureData["texture_downloads_started"]   = mRecording.getSum(sTextureDownloadsStarted);
 	averagedTextureData["texture_downloads_completed"] = mRecording.getSum(sTextureDownloadsCompleted);
 	averagedTextureData["transport"]                   = mTextureDownloadProtocol;
-- 
cgit v1.2.3


From d65243063c42b6df809873e917259e7db8d21ed4 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 31 Jul 2013 21:21:58 -0600
Subject: fix for SH-4290: Running viewer with SceneLoadingMonitorEnabled
 causes viewer to be unresponsive on login on low end machine

---
 indra/newview/llscenemonitor.cpp | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 022a950ece..918b2271d1 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -211,11 +211,19 @@ LLRenderTarget& LLSceneMonitor::getCaptureTarget()
 
 void LLSceneMonitor::freezeAvatar(LLCharacter* avatarp)
 {
-	mAvatarPauseHandles.push_back(avatarp->requestPause());
+	if(mEnabled)
+	{
+		mAvatarPauseHandles.push_back(avatarp->requestPause());
+	}
 }
 
 void LLSceneMonitor::freezeScene()
 {
+	if(!mEnabled)
+	{
+		return;
+	}
+
 	//freeze all avatars
 	for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
 		iter != LLCharacter::sInstances.end(); ++iter)
@@ -262,7 +270,7 @@ void LLSceneMonitor::capture()
 	static LLCachedControl<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
 	static bool force_capture = true;
 
-	bool enabled = monitor_enabled || mDebugViewerVisible;
+	bool enabled = LLGLSLShader::sNoFixedFunction && (monitor_enabled || mDebugViewerVisible);
 	if(mEnabled != enabled)
 	{
 		if(mEnabled)
@@ -288,10 +296,9 @@ void LLSceneMonitor::capture()
 		force_capture = true;
 	}
 
-	if((mRecordingTimer.getElapsedTimeF32() > scene_load_sample_time() 
+	if(mEnabled
+		&& (mRecordingTimer.getElapsedTimeF32() > scene_load_sample_time() 
 			|| force_capture)
-		&& mEnabled
-		&& LLGLSLShader::sNoFixedFunction
 		&& last_capture_frame != gFrameCount)
 	{
 		force_capture = false;
-- 
cgit v1.2.3


From 484f4230149e82345eccb38f9d4655b2a3f59984 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 31 Jul 2013 21:43:04 -0600
Subject: fix for SH-4393: Interesting: viewer crash in
 LLViewerRegion::addNewObject

---
 indra/newview/llviewerregion.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index e28ea6f988..c55ccce47a 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1303,6 +1303,16 @@ void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>&
 
 LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry)
 {
+	if(!entry || !entry->getEntry())
+	{
+		if(entry)
+		{
+			mImpl->mVisibleEntries.erase(entry);
+			entry->setState(LLVOCacheEntry::INACTIVE);
+		}
+		return NULL;
+	}
+
 	LLViewerObject* obj = NULL;
 	if(!entry->getEntry()->hasDrawable()) //not added to the rendering pipeline yet
 	{
-- 
cgit v1.2.3


From f58eb60b1e0bbdf2148255c61100cbc20d1ba1b0 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 1 Aug 2013 08:17:21 -0700
Subject: SH-4374 WIP Interesting: Statistics Object cache hit rate is always
 100%

---
 indra/newview/llviewerobjectlist.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 4072ab524e..e50e666421 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -355,7 +355,7 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 		}
 		justCreated = true;
 		mNumNewObjects++;
-		sample(sCacheHitRate, LLUnits::Percent::fromValue(100.f));
+		sample(sCacheHitRate, LLUnits::Ratio::fromValue(1));
 	}
 
 	if (objectp->isDead())
@@ -697,7 +697,7 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
 
 			continue; // no data packer, skip this object
 		}
-		sample(sCacheHitRate, 100.f);
+		//sample(sCacheHitRate, LLUnits::Ratio::fromValue(0));
 	}
 
 	return;
-- 
cgit v1.2.3


From 576b9339977f50edb11a799d7a274610263f9fdc Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 5 Aug 2013 14:48:26 -0600
Subject: fix for SH-4397: Object cache occlusion culling results are not
 always correct

---
 indra/newview/llspatialpartition.cpp |  6 ----
 indra/newview/llspatialpartition.h   |  1 -
 indra/newview/llvieweroctree.cpp     |  6 ++++
 indra/newview/llvieweroctree.h       |  7 ++--
 indra/newview/llviewerregion.cpp     |  3 ++
 indra/newview/llvocache.cpp          | 63 ++++++++++++++++++++++++------------
 indra/newview/llvocache.h            |  5 +--
 indra/newview/pipeline.cpp           | 13 +++++++-
 8 files changed, 71 insertions(+), 33 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index ad659baa9e..a5045e6a4c 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -265,12 +265,6 @@ BOOL LLSpatialGroup::isHUDGroup()
 	return getSpatialPartition() && getSpatialPartition()->isHUDPartition() ; 
 }
 
-BOOL LLSpatialGroup::isRecentlyVisible() const
-{
-	const S32 MIN_VIS_FRAME_RANGE = 2;
-	return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < MIN_VIS_FRAME_RANGE ;
-}
-
 void LLSpatialGroup::validate()
 {
 	ll_assert_aligned(this,64);
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 05ed70ab59..6202fb11cb 100755
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -290,7 +290,6 @@ public:
 	BOOL addObject(LLDrawable *drawablep);
 	BOOL removeObject(LLDrawable *drawablep, BOOL from_octree = FALSE);
 	BOOL updateInGroup(LLDrawable *drawablep, BOOL immediate = FALSE); // Update position if it's in the group
-	BOOL isRecentlyVisible() const;
 	void shift(const LLVector4a &offset);
 	void destroyGL(bool keep_occlusion = false);
 	
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index bba3d26e09..9b8a3c9269 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -853,6 +853,12 @@ BOOL LLOcclusionCullingGroup::needsUpdate()
 	return (LLDrawable::getCurrentFrame() % mSpatialPartition->mLODPeriod == mLODHash) ? TRUE : FALSE;
 }
 
+BOOL LLOcclusionCullingGroup::isRecentlyVisible() const
+{
+	const S32 MIN_VIS_FRAME_RANGE = 2;
+	return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < MIN_VIS_FRAME_RANGE ;
+}
+
 //virtual 
 void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child)
 {
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 980a67367c..7c85231ce0 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -317,14 +317,17 @@ public:
 	void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 	void checkOcclusion(); //read back last occlusion query (if any)
 	void doOcclusion(LLCamera* camera, const LLVector3* region_agent = NULL); //issue occlusion query
-	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }		
-	
+	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }
+
 	BOOL needsUpdate();
 	U32  getLastOcclusionIssuedTime();
 
 	//virtual 
 	void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
 
+	//virtual
+	BOOL isRecentlyVisible() const;
+
 	static U32 getNewOcclusionQueryObjectName();
 	static void releaseOcclusionQueryObjectName(U32 name);
 
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index c55ccce47a..47e59d3c00 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1183,6 +1183,9 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	}
 
 	max_update_time -= update_timer.getElapsedTimeF32();	
+	
+	//reset all occluders
+	mImpl->mVOCachePartition->resetOccluders();
 
 	//update the throttling number
 	static S32 throttle = new_object_creation_throttle;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index d1c27edce7..9beb81bcdd 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -490,9 +490,8 @@ public:
 
 			group->checkOcclusion();
 
-			if (group->isOcclusionState(LLSpatialGroup::OCCLUDED))
+			if (group->isOcclusionState(LLOcclusionCullingGroup::OCCLUDED))
 			{
-				mPartition->addOccluders(group);
 				return true;
 			}
 		}
@@ -530,7 +529,24 @@ public:
 
 	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
-		mRegionp->addVisibleGroup(base_group);
+		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
+		if(!group->isRecentlyVisible())//needs to issue new occlusion culling check.
+		{
+			mPartition->addOccluders(group);
+			group->setVisible();
+			return ; //wait for occlusion culling result
+		}
+
+		if(group->isOcclusionState(LLOcclusionCullingGroup::QUERY_PENDING) || 
+			group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
+		{
+			//keep waiting
+			group->setVisible();
+		}
+		else
+		{
+			mRegionp->addVisibleGroup(base_group);
+		}
 	}
 
 private:
@@ -555,17 +571,9 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	camera.calcRegionFrustumPlanes(region_agent);
 
-	mOccludedGroups.clear();
-	
 	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion, this);
 	culler.traverse(mOctree);
 
-	if(!mOccludedGroups.empty())
-	{
-		processOccluders(&camera, &region_agent);
-		mOccludedGroups.clear();
-	}
-
 	return 0;
 }
 
@@ -573,13 +581,6 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
 {
 	LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp;
 
-	const U32 MIN_WAIT_TIME = 19; //wait 19 frames to issue a new occlusion request
-	U32 last_issued_time = group->getLastOcclusionIssuedTime();
-	if(!group->needsUpdate() && gFrameCount > last_issued_time && gFrameCount < last_issued_time + MIN_WAIT_TIME)
-	{
-		return;
-	}
-
 	if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
 	{
 		group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
@@ -587,14 +588,34 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
 	}
 }
 
-void LLVOCachePartition::processOccluders(LLCamera* camera, const LLVector3* region_agent)
+void LLVOCachePartition::processOccluders(LLCamera* camera)
 {
+	if(mOccludedGroups.empty())
+	{
+		return;
+	}
+
+	LLVector3 region_agent = mRegionp->getOriginAgent();
 	for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
 	{
 		LLOcclusionCullingGroup* group = *iter;
-		group->doOcclusion(camera, region_agent);
-		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+		group->doOcclusion(camera, &region_agent);
+	}	
+}
+
+void LLVOCachePartition::resetOccluders()
+{
+	if(mOccludedGroups.empty())
+	{
+		return;
 	}
+
+	for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
+	{
+		LLOcclusionCullingGroup* group = *iter;
+		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+	}	
+	mOccludedGroups.clear();
 }
 
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 816ef88dc4..7de8185315 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -159,11 +159,12 @@ public:
 	void removeEntry(LLViewerOctreeEntry* entry);
 	/*virtual*/ S32 cull(LLCamera &camera);
 	void addOccluders(LLviewerOctreeGroup* gp);
+	void resetOccluders();
 
 	static	LLTrace::MemStatHandle	sMemStat;
 
-private:	
-	void processOccluders(LLCamera* camera, const LLVector3* region_agent);
+public:	
+	void processOccluders(LLCamera* camera);
 
 private:
 	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1d9137c161..1696f1962c 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2719,7 +2719,7 @@ void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderT
 
 void LLPipeline::doOcclusion(LLCamera& camera)
 {
-	if (LLPipeline::sUseOcclusion > 1 && sCull->hasOcclusionGroups())
+	if (LLPipeline::sUseOcclusion > 1)
 	{
 		LLVertexBuffer::unbind();
 
@@ -2765,6 +2765,17 @@ void LLPipeline::doOcclusion(LLCamera& camera)
 			group->clearOcclusionState(LLSpatialGroup::ACTIVE_OCCLUSION);
 		}
 	
+		//apply occlusion culling to object cache tree
+		for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
+			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
+		{
+			LLVOCachePartition* vo_part = (*iter)->getVOCachePartition();
+			if(vo_part)
+			{
+				vo_part->processOccluders(&camera);
+			}
+		}
+
 		if (bind_shader)
 		{
 			if (LLPipeline::sShadowRender)
-- 
cgit v1.2.3


From ddef4d7ff74ecff49e76afca58d1d3c2486e8af3 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 6 Aug 2013 16:35:46 -0600
Subject: revert some LLUnit changes to temporarily fix SH-4399: Interesting:
 Texture console MB Bound 0/384 and texture queue bounces once per second

---
 indra/newview/llappviewer.cpp        | 4 ++--
 indra/newview/llappviewer.h          | 2 +-
 indra/newview/llstartup.cpp          | 5 +++--
 indra/newview/llviewerobjectlist.cpp | 5 +++--
 indra/newview/llviewerstats.cpp      | 2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index d544b992ef..9d30830e71 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -294,7 +294,7 @@ U32 gForegroundFrameCount = 0; // number of frames that app window was in foregr
 LLPumpIO* gServicePump = NULL;
 
 LLUnitImplicit<U64, LLUnits::Microseconds> gFrameTime = 0;
-LLUnitImplicit<F32, LLUnits::Seconds> gFrameTimeSeconds = 0.f;
+F32 gFrameTimeSeconds = 0.f;
 LLUnitImplicit<F32, LLUnits::Seconds> 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
@@ -1464,7 +1464,7 @@ bool LLAppViewer::mainLoop()
 					ms_sleep(500);
 				}
 
-				const F64 max_idle_time = llmin(.005*10.0*gFrameTimeSeconds, LLUnitImplicit<F32, LLUnits::Seconds>(0.005f)); // 5 ms a second
+				const F64 max_idle_time = llmin(.005f*10.0f*gFrameTimeSeconds, (0.005f)); // 5 ms a second
 				idleTimer.reset();
 				S32 total_work_pending = 0;
 				S32 total_io_pending = 0;	
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 60a1045f58..76724a9662 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -336,7 +336,7 @@ extern LLPumpIO* gServicePump;
 
 extern LLUnitImplicit<U64, LLUnits::Microseconds>	gStartTime;
 extern LLUnitImplicit<U64, LLUnits::Microseconds>   gFrameTime;					// The timestamp of the most-recently-processed frame
-extern LLUnitImplicit<F32, LLUnits::Seconds>		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
+extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
 extern LLUnitImplicit<F32, LLUnits::Seconds>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
 extern F32		gFPSClamped;				// Frames per second, smoothed, weighted toward last frame
 extern F32		gFrameDTClamped;
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 933cc74064..b1ff047233 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1429,8 +1429,9 @@ bool idle_startup()
 
 		LL_DEBUGS("AppInit") << "Initializing camera..." << LL_ENDL;
 		gFrameTime    = totalTime();
-		LLUnit<F32, LLUnits::Seconds> last_time = gFrameTimeSeconds;
-		gFrameTimeSeconds = (gFrameTime - gStartTime);
+		F32 last_time = gFrameTimeSeconds;
+		const F64 SEC_TO_MICROSEC = 1000000.f;
+		gFrameTimeSeconds = (F32)((gFrameTime - gStartTime) / SEC_TO_MICROSEC);
 
 		gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
 		if (gFrameIntervalSeconds < 0.f)
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 4072ab524e..0b75d44096 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -1000,9 +1000,10 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	// Time _can_ go backwards, for example if the user changes the system clock.
 	// It doesn't cause any fatal problems (just some oddness with stats), so we shouldn't assert here.
 //	llassert(time > gFrameTime);
-	LLUnit<F64, LLUnits::Seconds> time_diff = time - gFrameTime;
+	const F64 SEC_TO_MICROSEC = 1000000.f;
+	F64 time_diff = U64_to_F64(time - gFrameTime)/SEC_TO_MICROSEC;
 	gFrameTime	= time;
-	LLUnit<F64, LLUnits::Seconds> time_since_start = gFrameTime - gStartTime;
+	F64 time_since_start = U64_to_F64(gFrameTime - gStartTime)/SEC_TO_MICROSEC;
 	gFrameTimeSeconds = time_since_start;
 
 	gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 69198ed53d..94be8e2a83 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -593,7 +593,7 @@ void send_stats()
 	S32 window_height = gViewerWindow->getWindowHeightRaw();
 	S32 window_size = (window_width * window_height) / 1024;
 	misc["string_1"] = llformat("%d", window_size);
-	misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds.value());
+	misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds);
 
 // 	misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21
 // 	misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21
-- 
cgit v1.2.3


From be8d04c358086d6650fe7a8195949ba6c11096ae Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 6 Aug 2013 18:03:23 -0600
Subject: fix for SH-4398: Interesting: viewer crash in
 LLVOCacheEntry::updateParentBoundingInfo

---
 indra/newview/llviewerregion.cpp | 15 +++++++++++++--
 indra/newview/llvocache.cpp      | 22 ++++++++++++++++++++++
 indra/newview/llvocache.h        |  2 ++
 3 files changed, 37 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 47e59d3c00..49bb05d88e 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -866,8 +866,19 @@ void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry)
 	//remove from the forced visible list
 	mImpl->mVisibleEntries.erase(entry);
 
-	//kill LLViewerObject if exists
-	//this should be done by the rendering pipeline automatically.
+	//disconnect from parent if it is a child
+	if(entry->getParentID() > 0)
+	{
+		LLVOCacheEntry* parent = getCacheEntry(entry->getParentID());
+		if(parent)
+		{
+			parent->removeChild(entry);
+		}
+	}
+	else if(entry->getNumOfChildren() > 0)//disconnect children if has any
+	{
+		entry->removeAllChildren();
+	}
 	
 	entry->setState(LLVOCacheEntry::INACTIVE);
 	
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 9beb81bcdd..1b68fee4c1 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -263,6 +263,28 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 	}
 }
 	
+void LLVOCacheEntry::removeChild(LLVOCacheEntry* entry)
+{
+	for(S32 i = 0; i < mChildrenList.size(); i++)
+	{
+		if(mChildrenList[i] == entry)
+		{
+			entry->setParentID(0);
+			mChildrenList[i] = mChildrenList[mChildrenList.size() - 1];
+			mChildrenList.pop_back();
+		}
+	}
+}
+
+void LLVOCacheEntry::removeAllChildren()
+{
+	for(S32 i = 0; i < mChildrenList.size(); i++)
+	{
+		mChildrenList[i]->setParentID(0);
+	}
+	mChildrenList.clear();
+}
+
 LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc)
 {
 	if (  (mCRC != crc)
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 7de8185315..ef9edf991b 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -107,6 +107,8 @@ public:
 	U32  getParentID() const {return mParentID;}
 
 	void addChild(LLVOCacheEntry* entry);
+	void removeChild(LLVOCacheEntry* entry);
+	void removeAllChildren();
 	LLVOCacheEntry* getChild(S32 i) {return mChildrenList[i];}
 	S32  getNumOfChildren()         {return mChildrenList.size();}
 	void clearChildrenList()        {mChildrenList.clear();}
-- 
cgit v1.2.3


From f6a342438c59548276f0ee9f3033b47229d5d6d3 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 7 Aug 2013 11:29:31 -0600
Subject: more fix for SH-4397: Object cache occlusion culling results are not
 always correct

---
 indra/newview/llvocache.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 1b68fee4c1..11f31fcb9a 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -551,6 +551,14 @@ public:
 
 	virtual void processGroup(LLviewerOctreeGroup* base_group)
 	{
+		if( !mUseObjectCacheOcclusion ||
+			!base_group->getOctreeNode()->getParent())
+		{ 
+			//no occlusion check
+			mRegionp->addVisibleGroup(base_group);
+			return;
+		}
+
 		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
 		if(!group->isRecentlyVisible())//needs to issue new occlusion culling check.
 		{
-- 
cgit v1.2.3


From a2c7b0485576c6bb92f6d0eddc762f5e37d5caac Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 7 Aug 2013 22:53:27 -0600
Subject: more fix for SH-4397: Object cache occlusion culling results are not
 always correct

---
 indra/newview/llspatialpartition.cpp | 2 +-
 indra/newview/llspatialpartition.h   | 2 +-
 indra/newview/llvieweroctree.h       | 2 +-
 indra/newview/llviewerregion.cpp     | 7 +------
 indra/newview/llvocache.cpp          | 8 ++++----
 indra/newview/llvocache.h            | 2 +-
 indra/newview/pipeline.cpp           | 7 ++++++-
 7 files changed, 15 insertions(+), 15 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index a5045e6a4c..a1b7bfe72a 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1476,7 +1476,7 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* result
 	return 0;
 	}
 	
-S32 LLSpatialPartition::cull(LLCamera &camera)
+S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion)
 {
 #if LL_OCTREE_PARANOIA_CHECK
 	((LLSpatialGroup*)mOctree->getListener(0))->checkStates();
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 6202fb11cb..1774baf0fe 100755
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -422,7 +422,7 @@ public:
 	virtual void rebuildMesh(LLSpatialGroup* group);
 
 	BOOL visibleObjectsInFrustum(LLCamera& camera);
-	/*virtual*/ S32 cull(LLCamera &camera); // Cull on arbitrary frustum
+	/*virtual*/ S32 cull(LLCamera &camera, bool do_occlusion=false); // Cull on arbitrary frustum
 	S32 cull(LLCamera &camera, std::vector<LLDrawable *>* results, BOOL for_select); // Cull on arbitrary frustum
 	
 	BOOL isVisible(const LLVector3& v);
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 7c85231ce0..7fdb5661d8 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -357,7 +357,7 @@ public:
 	virtual ~LLViewerOctreePartition();
 
 	// Cull on arbitrary frustum
-	virtual S32 cull(LLCamera &camera) = 0;
+	virtual S32 cull(LLCamera &camera, bool do_occlusion) = 0;
 	BOOL isOcclusionEnabled();
 
 public:	
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 49bb05d88e..117ccdea33 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1204,13 +1204,8 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	{
 		throttle = -1; //cancel the throttling
 
-		S32 occlusion = LLPipeline::sUseOcclusion;
-		LLPipeline::sUseOcclusion = 0; //disable occlusion
-		
 		//apply octree cullings here to pick up visible objects because rendering pipeline stops view culling at this moment
-		mImpl->mVOCachePartition->cull(*LLViewerCamera::getInstance());
-		
-		LLPipeline::sUseOcclusion = occlusion;
+		mImpl->mVOCachePartition->cull(*LLViewerCamera::getInstance(), false);
 	}	
 	else if(throttle < 0) //just recoved from the login/teleport screen
 	{
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 11f31fcb9a..82485d7fdc 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -495,7 +495,7 @@ public:
 		  mPartition(part)
 	{
 		mLocalShift = shift;
-		mUseObjectCacheOcclusion = (use_object_cache_occlusion && LLPipeline::sUseOcclusion);
+		mUseObjectCacheOcclusion = use_object_cache_occlusion;
 	}
 
 	virtual bool earlyFail(LLviewerOctreeGroup* base_group)
@@ -586,10 +586,10 @@ private:
 	bool                mUseObjectCacheOcclusion;
 };
 
-S32 LLVOCachePartition::cull(LLCamera &camera)
+S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 {
 	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
-
+	
 	if(!LLViewerRegion::sVOCacheCullingEnabled)
 	{
 		return 0;
@@ -601,7 +601,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	camera.calcRegionFrustumPlanes(region_agent);
 
-	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, use_object_cache_occlusion, this);
+	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, this);
 	culler.traverse(mOctree);
 
 	return 0;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index ef9edf991b..04463088fa 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -159,7 +159,7 @@ public:
 
 	void addEntry(LLViewerOctreeEntry* entry);
 	void removeEntry(LLViewerOctreeEntry* entry);
-	/*virtual*/ S32 cull(LLCamera &camera);
+	/*virtual*/ S32 cull(LLCamera &camera, bool do_occlusion);
 	void addOccluders(LLviewerOctreeGroup* gp);
 	void resetOccluders();
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1696f1962c..1abaaa49ac 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2408,6 +2408,11 @@ static LLFastTimer::DeclareTimer FTM_CULL("Object Culling");
 
 void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep)
 {
+	static LLCachedControl<bool> use_occlusion(gSavedSettings,"UseOcclusion");
+	static bool can_use_occlusion = LLGLSLShader::sNoFixedFunction
+									&& LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") 
+									&& gGLManager.mHasOcclusionQuery;
+
 	LLFastTimer t(FTM_CULL);
 
 	grabReferences(result);
@@ -2530,7 +2535,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 		LLVOCachePartition* vo_part = region->getVOCachePartition();
 		if(vo_part)
 		{
-			vo_part->cull(camera);
+			vo_part->cull(camera, can_use_occlusion && use_occlusion && !gUseWireframe);
 		}
 	}
 
-- 
cgit v1.2.3


From a6711a894c3c32ad24b47e36b2a52225713fd3ed Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 8 Aug 2013 16:45:55 -0600
Subject: fix for SH-4402: interesting: lower FPS with lots of objects in view

---
 indra/newview/llviewerregion.cpp | 108 ++++++++++++++++++++++++---------------
 indra/newview/llviewerregion.h   |  18 +++++--
 indra/newview/llvocache.cpp      |  37 ++++++++++++--
 indra/newview/llvocache.h        |   6 +++
 indra/newview/llworld.cpp        |   3 +-
 indra/newview/pipeline.cpp       |   2 +-
 6 files changed, 126 insertions(+), 48 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 117ccdea33..cfe765a1cb 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -90,6 +90,7 @@ const U32 DEFAULT_MAX_REGION_WIDE_PRIM_COUNT = 15000;
 
 BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
 S32  LLViewerRegion::sLastCameraUpdated = 0;
+S32  LLViewerRegion::sNewObjectCreationThrottle = 0;
 
 typedef std::map<std::string, std::string> CapabilityMap;
 
@@ -372,7 +373,9 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 	mCapabilitiesReceived(false),
 	mBitsReceived(0.f),
 	mPacketsReceived(0.f),
-	mDead(FALSE)
+	mDead(FALSE),
+	mLastVisitedEntry(NULL),
+	mInvisibilityCheckHistory(-1)
 {
 	mWidth = region_width_meters;
 	mImpl->mOriginGlobal = from_region_handle(handle); 
@@ -968,6 +971,11 @@ void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
 	mImpl->mVisibleGroups.insert(group);
 }
 
+U32 LLViewerRegion::getNumOfVisibleGroups() const
+{
+	return mImpl ? mImpl->mVisibleGroups.size() : 0;
+}
+
 void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
 {
 	if(!sVOCacheCullingEnabled)
@@ -1139,7 +1147,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	return 2.0f * max_time - update_timer.getElapsedTimeF32();
 }
 
-F32 LLViewerRegion::createVisibleObjects(F32 max_time, S32 throttle)
+F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 {
 	if(mDead)
 	{
@@ -1150,6 +1158,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time, S32 throttle)
 		return max_time;
 	}
 
+	S32 throttle = sNewObjectCreationThrottle;
 	LLTimer update_timer;	
 	for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin();
 		iter != mImpl->mWaitingList.end(); ++iter)
@@ -1170,9 +1179,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time, S32 throttle)
 }
 
 BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
-{
-	static LLCachedControl<S32> new_object_creation_throttle(gSavedSettings,"NewObjectCreationThrottle");
-
+{	
 	LLTimer update_timer;
 
 	// did_update returns TRUE if we did at least one significant update
@@ -1191,44 +1198,28 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	if(mImpl->mCacheMap.empty())
 	{
 		return did_update;
-	}
-
-	max_update_time -= update_timer.getElapsedTimeF32();	
+	}	
 	
 	//reset all occluders
 	mImpl->mVOCachePartition->resetOccluders();
 
-	//update the throttling number
-	static S32 throttle = new_object_creation_throttle;
-	if(LLStartUp::getStartupState() < STATE_STARTED || gTeleportDisplay)
-	{
-		throttle = -1; //cancel the throttling
+	max_update_time -= update_timer.getElapsedTimeF32();	
 
+	if(sNewObjectCreationThrottle < 0 && (LLStartUp::getStartupState() < STATE_STARTED || gTeleportDisplay))
+	{
 		//apply octree cullings here to pick up visible objects because rendering pipeline stops view culling at this moment
 		mImpl->mVOCachePartition->cull(*LLViewerCamera::getInstance(), false);
 	}	
-	else if(throttle < 0) //just recoved from the login/teleport screen
-	{
-		if(new_object_creation_throttle > 0)
-		{
-			throttle = 4096; //a big number
-		}
-	}
-	else
-	{
-		throttle = llmax((S32)new_object_creation_throttle, (S32)(throttle >> 1));
-	}
-
-	if(max_update_time < 0.f && throttle > 0 && throttle < new_object_creation_throttle * 2)
+	else if(max_update_time < 0.f)
 	{
 		return did_update;
 	}
 
 	//kill invisible objects
-	max_update_time = killInvisibleObjects(max_update_time, throttle);	
+	max_update_time = killInvisibleObjects(max_update_time);	
 	
 	max_update_time = updateVisibleEntries(max_update_time);
-	createVisibleObjects(max_update_time, throttle);
+	createVisibleObjects(max_update_time);
 
 	mImpl->mWaitingList.clear();
 	mImpl->mVisibleGroups.clear();
@@ -1236,7 +1227,35 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	return did_update;
 }
 
-F32 LLViewerRegion::killInvisibleObjects(F32 max_time, S32 throttle)
+//update the throttling number for new object creation
+void LLViewerRegion::calcNewObjectCreationThrottle()
+{
+	static LLCachedControl<S32> new_object_creation_throttle(gSavedSettings,"NewObjectCreationThrottle");
+
+	sNewObjectCreationThrottle = new_object_creation_throttle;
+	if(LLStartUp::getStartupState() < STATE_STARTED || gTeleportDisplay)
+	{
+		sNewObjectCreationThrottle = -1; //cancel the throttling		
+	}	
+	else if(sNewObjectCreationThrottle < 0) //just recoved from the login/teleport screen
+	{
+		if(new_object_creation_throttle > 0)
+		{
+			sNewObjectCreationThrottle = 4096; //a big number
+		}
+	}
+	else
+	{
+		sNewObjectCreationThrottle = llmax((S32)new_object_creation_throttle, (S32)(sNewObjectCreationThrottle >> 1));
+	}
+}
+
+BOOL LLViewerRegion::isViewerCameraStatic()
+{
+	return sLastCameraUpdated < LLViewerOctreeEntryData::getCurrentFrame();
+}
+
+F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 {
 #if 1
 	if(!sVOCacheCullingEnabled)
@@ -1248,12 +1267,16 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time, S32 throttle)
 		return max_time;
 	}
 
-	static LLVOCacheEntry* last_visited_entry = NULL;
-
-	const size_t MAX_UPDATE = throttle < 0 ? mImpl->mActiveSet.size() : 64; 
+	size_t max_update = sNewObjectCreationThrottle < 0 ? mImpl->mActiveSet.size() : 64; 
+	if(!mInvisibilityCheckHistory && isViewerCameraStatic())
+	{
+		//history is clean, reduce number of checking
+		max_update = llmax(max_update / 2, (size_t)8);
+	}
+	
 	std::vector<LLDrawable*> delete_list;
-	S32 update_counter = llmin(MAX_UPDATE, mImpl->mActiveSet.size());
-	LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(last_visited_entry);	
+	S32 update_counter = llmin(max_update, mImpl->mActiveSet.size());
+	LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(mLastVisitedEntry);	
 	
 	for(; update_counter > 0; --update_counter, ++iter)
 	{	
@@ -1262,7 +1285,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time, S32 throttle)
 			iter = mImpl->mActiveSet.begin();
 		}
 
-		if(!(*iter)->isRecentlyVisible() && (*iter)->mLastCameraUpdated != sLastCameraUpdated)
+		if(!(*iter)->isRecentlyVisible() && (*iter)->mLastCameraUpdated < sLastCameraUpdated)
 		{
 			killObject((*iter), delete_list);
 		}
@@ -1270,18 +1293,23 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time, S32 throttle)
 
 	if(iter == mImpl->mActiveSet.end())
 	{
-		last_visited_entry = NULL;
+		mLastVisitedEntry = NULL;
 	}
 	else
 	{
-		last_visited_entry = *iter;
+		mLastVisitedEntry = *iter;
 	}
 
-	for(S32 i = 0; i < delete_list.size(); i++)
+	mInvisibilityCheckHistory <<= 2;
+	if(!delete_list.empty())
 	{
-		gObjectList.killObject(delete_list[i]->getVObj());
+		mInvisibilityCheckHistory |= 1;
+		for(S32 i = 0; i < delete_list.size(); i++)
+		{
+			gObjectList.killObject(delete_list[i]->getVObj());
+		}
+		delete_list.clear();
 	}
-	delete_list.clear();
 #endif
 	return max_time;
 }
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index a8e0b7bba9..9d2a333b1b 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -220,6 +220,10 @@ public:
 	// can process the message.
 	static void processRegionInfo(LLMessageSystem* msg, void**);
 
+	//check if the viewer camera is static
+	static BOOL isViewerCameraStatic();
+	static void calcNewObjectCreationThrottle();
+
 	void setCacheID(const LLUUID& id);
 
 	F32	getWidth() const						{ return mWidth; }
@@ -345,6 +349,7 @@ public:
     virtual std::string getDescription() const;
 	std::string getHttpUrl() const { return mHttpUrl ;}
 
+	U32 getNumOfVisibleGroups() const;
 	U32 getNumOfActiveCachedObjects() const;
 	LLSpatialPartition* getSpatialPartition(U32 type);
 	LLVOCachePartition* getVOCachePartition();
@@ -359,7 +364,7 @@ public:
 	LLViewerRegionImpl * getRegionImplNC() { return mImpl; }
 
 	void removeFromCreatedList(U32 local_id);
-	void addToCreatedList(U32 local_id);
+	void addToCreatedList(U32 local_id);	
 
 private:
 	void addToVOCacheTree(LLVOCacheEntry* entry);
@@ -369,8 +374,8 @@ private:
 	void replaceVisibleCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
 	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
 
-	F32 killInvisibleObjects(F32 max_time, S32 throttle);
-	F32 createVisibleObjects(F32 max_time, S32 throttle);
+	F32 killInvisibleObjects(F32 max_time);
+	F32 createVisibleObjects(F32 max_time);
 	F32 updateVisibleEntries(F32 max_time); //update visible entries
 
 	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type);
@@ -411,6 +416,10 @@ public:
 
 	static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
 	static S32  sLastCameraUpdated;
+
+private:
+	static S32  sNewObjectCreationThrottle;
+
 private:
 	LLViewerRegionImpl * mImpl;
 	LLFrameTimer         mRegionTimer;
@@ -445,6 +454,9 @@ private:
 	F32		mCameraDistanceSquared;	// updated once per frame
 	U8		mCentralBakeVersion;
 	
+	LLVOCacheEntry* mLastVisitedEntry;
+	U32				mInvisibilityCheckHistory;	
+
 	// Information for Homestead / CR-53
 	S32 mClassID;
 	S32 mCPURatio;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 82485d7fdc..7dfa131ebf 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -34,6 +34,7 @@
 #include "llviewerregion.h"
 #include "pipeline.h"
 
+BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE;
 LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
@@ -467,8 +468,14 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 {
 	mLODPeriod = 16;
 	mRegionp = regionp;
-	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
-	
+	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;	
+	mDirty = FALSE;
+
+	for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
+	{
+		mCulledTime[i] = 0;
+		mCullHistory[i] = -1;
+	}
 	new LLOcclusionCullingGroup(mOctree, this);
 }
 
@@ -477,6 +484,7 @@ void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
 	llassert(entry->hasVOCacheEntry());
 
 	mOctree->insert(entry);
+	mDirty = TRUE;
 }
 	
 void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
@@ -595,7 +603,19 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		return 0;
 	}
 
+	if(mCulledTime[LLViewerCamera::sCurCameraID] == LLViewerOctreeEntryData::getCurrentFrame())
+	{
+		return 0; //already culled
+	}
+	mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
+
+	if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
+	{
+		return 0; //nothing changed, skip culling
+	}
+
 	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
+	mCullHistory[LLViewerCamera::sCurCameraID] <<= 2;
 
 	//localize the camera
 	LLVector3 region_agent = mRegionp->getOriginAgent();
@@ -604,7 +624,16 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, this);
 	culler.traverse(mOctree);
 
-	return 0;
+	if(mRegionp->getNumOfVisibleGroups() > 0)
+	{
+		mCullHistory[LLViewerCamera::sCurCameraID] |= 1;
+	}
+
+	if(!sNeedsOcclusionCheck)
+	{
+		sNeedsOcclusionCheck = !mOccludedGroups.empty();
+	}
+	return 1;
 }
 
 void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
@@ -646,6 +675,8 @@ void LLVOCachePartition::resetOccluders()
 		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
 	}	
 	mOccludedGroups.clear();
+	mDirty = FALSE;
+	sNeedsOcclusionCheck = FALSE;
 }
 
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 04463088fa..c448b97b80 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -168,7 +168,13 @@ public:
 public:	
 	void processOccluders(LLCamera* camera);
 
+public:
+	static BOOL sNeedsOcclusionCheck;
+
 private:
+	BOOL  mDirty;
+	U32   mCullHistory[LLViewerCamera::NUM_CAMERAS];
+	U32   mCulledTime[LLViewerCamera::NUM_CAMERAS];
 	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
 };
 
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index bfc5077c90..df5e3d835c 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -668,8 +668,9 @@ void LLWorld::updateRegions(F32 max_update_time)
 	
 	if(LLViewerCamera::getInstance()->isChanged())
 	{
-		LLViewerRegion::sLastCameraUpdated = LLViewerOctreeEntryData::getCurrentFrame();
+		LLViewerRegion::sLastCameraUpdated = LLViewerOctreeEntryData::getCurrentFrame() + 1;
 	}
+	LLViewerRegion::calcNewObjectCreationThrottle();
 
 	// Perform idle time updates for the regions (and associated surfaces)
 	for (region_list_t::iterator iter = mRegionList.begin();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1abaaa49ac..87c3bf7bdf 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2724,7 +2724,7 @@ void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderT
 
 void LLPipeline::doOcclusion(LLCamera& camera)
 {
-	if (LLPipeline::sUseOcclusion > 1)
+	if (LLPipeline::sUseOcclusion > 1 && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck))
 	{
 		LLVertexBuffer::unbind();
 
-- 
cgit v1.2.3


From c2601ec9c574ac3bd7a7f4001bc08572483028a6 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 9 Aug 2013 14:57:18 -0600
Subject: fix for SH-4394: Interesting: viewer culls lights behind the camera,
 changing the scene lighting

---
 indra/newview/pipeline.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 87c3bf7bdf..f6e1f8342a 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6135,6 +6135,13 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)
 			}
 		}
 		
+		//mark nearby lights not-removable.
+		for (light_set_t::iterator iter = mNearbyLights.begin();
+			 iter != mNearbyLights.end(); iter++)
+		{
+			const Light* light = &(*iter);
+			((LLViewerOctreeEntryData*) light->drawable)->setVisible();
+		}
 	}
 }
 
-- 
cgit v1.2.3


From 8d3daa141e9ea14f533559843d77ab5c0f715421 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/newview/llviewerobjectlist.cpp | 5 ++---
 indra/newview/llviewerobjectlist.h   | 2 --
 indra/newview/llviewerregion.cpp     | 1 +
 indra/newview/llviewerstats.cpp      | 3 +++
 indra/newview/llviewerstats.h        | 2 ++
 5 files changed, 8 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

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<U64, U32>		LLViewerObjectList::sIPAndPortToIndex;
 std::map<U64, LLUUID>	LLViewerObjectList::sIndexAndLocalIDToUUID;
-LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> >	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<OrphanInfo> mOrphanChildren;	// UUID's of orphaned objects
 	S32 mNumOrphans;
 
-	static LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > sCacheHitRate;
-
 	typedef std::vector<LLPointer<LLViewerObject> > 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<LLUnit<F64, LLUnits::Seconds> >	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<LLUnit<F32, LLUnits::Percent> > 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<LLUnit<F64, LLUnits::Seconds> >	AVATAR_EDIT_TIME
 																FPS_8_TIME,
 																FPS_2_TIME;
 
+extern LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > OBJECT_CACHE_HIT_RATE;
+
 }
 
 class LLViewerStats : public LLSingleton<LLViewerStats>
-- 
cgit v1.2.3


From e340009fc59d59e59b2e8d903a884acb76b178eb Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 9 Aug 2013 17:11:19 -0700
Subject: second phase summer cleaning replace llinfos, lldebugs, etc with new
 LL_INFOS(), LL_DEBUGS(), etc.

---
 indra/newview/llaccountingcostmanager.cpp          |   8 +-
 indra/newview/llagent.cpp                          | 100 ++++----
 indra/newview/llagentcamera.cpp                    |   8 +-
 indra/newview/llagentlistener.cpp                  |   8 +-
 indra/newview/llagentpicksinfo.cpp                 |   2 +-
 indra/newview/llagentpilot.cpp                     |  34 +--
 indra/newview/llagentwearables.cpp                 | 118 ++++-----
 indra/newview/llagentwearablesfetch.cpp            |  40 +--
 indra/newview/llappearancemgr.cpp                  | 236 +++++++++---------
 indra/newview/llappviewer.cpp                      | 230 +++++++++---------
 indra/newview/llappviewerwin32.cpp                 |  42 ++--
 indra/newview/llassetuploadqueue.cpp               |  10 +-
 indra/newview/llassetuploadresponders.cpp          |  46 ++--
 indra/newview/llattachmentsmgr.cpp                 |   2 +-
 indra/newview/llavataractions.cpp                  |   2 +-
 indra/newview/llavatariconctrl.cpp                 |   4 +-
 indra/newview/llavatarpropertiesprocessor.cpp      |   4 +-
 indra/newview/llbuycurrencyhtml.cpp                |   2 +-
 indra/newview/llcallbacklist.cpp                   |  30 +--
 indra/newview/llcallingcard.cpp                    |  34 +--
 indra/newview/llcaphttpsender.cpp                  |   4 +-
 indra/newview/llchannelmanager.cpp                 |   4 +-
 indra/newview/llchatbar.cpp                        |  14 +-
 indra/newview/llchiclet.cpp                        |   6 +-
 indra/newview/llchiclet.h                          |   8 +-
 indra/newview/llchicletbar.cpp                     |  22 +-
 indra/newview/llclassifiedstatsresponder.cpp       |   2 +-
 indra/newview/llcofwearables.cpp                   |   4 +-
 indra/newview/llcommandlineparser.cpp              |  16 +-
 indra/newview/llcompilequeue.cpp                   |  34 +--
 indra/newview/llconversationlog.cpp                |   8 +-
 indra/newview/llconversationmodel.cpp              |   6 +-
 indra/newview/lldaycyclemanager.cpp                |   2 +-
 indra/newview/lldebugmessagebox.cpp                |   6 +-
 indra/newview/lldrawable.cpp                       |  40 +--
 indra/newview/lldrawable.h                         |   8 +-
 indra/newview/lldrawpool.cpp                       |  12 +-
 indra/newview/lldrawpoolalpha.cpp                  |   2 +-
 indra/newview/lldrawpoolavatar.cpp                 |   6 +-
 indra/newview/lldrawpoolbump.cpp                   |  20 +-
 indra/newview/lldrawpoolwater.cpp                  |   2 +-
 indra/newview/lldrawpoolwlsky.cpp                  |  14 +-
 indra/newview/lldynamictexture.cpp                 |   2 +-
 indra/newview/llenvmanager.cpp                     |  18 +-
 indra/newview/llestateinfomodel.cpp                |  10 +-
 indra/newview/lleventnotifier.cpp                  |   2 +-
 indra/newview/lleventpoll.cpp                      |  42 ++--
 indra/newview/llexternaleditor.cpp                 |  18 +-
 indra/newview/llface.cpp                           |  82 +++----
 indra/newview/llface.h                             |   2 +-
 indra/newview/llfasttimerview.cpp                  |   6 +-
 indra/newview/llfavoritesbar.cpp                   |  22 +-
 indra/newview/llfeaturemanager.cpp                 |  18 +-
 indra/newview/llfilepicker.cpp                     |  16 +-
 indra/newview/llfloaterabout.cpp                   |   6 +-
 indra/newview/llfloaterauction.cpp                 |  22 +-
 indra/newview/llfloateravatarpicker.cpp            |   8 +-
 indra/newview/llfloateravatartextures.cpp          |   6 +-
 indra/newview/llfloaterbulkpermission.cpp          |  16 +-
 indra/newview/llfloaterbump.cpp                    |   4 +-
 indra/newview/llfloaterbuy.cpp                     |   6 +-
 indra/newview/llfloaterbuycontents.cpp             |   6 +-
 indra/newview/llfloaterbuycurrencyhtml.cpp         |   2 +-
 indra/newview/llfloaterbuyland.cpp                 |   2 +-
 indra/newview/llfloaterbvhpreview.cpp              |  10 +-
 indra/newview/llfloaterdeleteenvpreset.cpp         |   4 +-
 indra/newview/llfloaterdisplayname.cpp             |   2 +-
 indra/newview/llfloatereditdaycycle.cpp            |  22 +-
 indra/newview/llfloatereditsky.cpp                 |   6 +-
 indra/newview/llfloatereditwater.cpp               |   6 +-
 indra/newview/llfloatergodtools.cpp                |   8 +-
 indra/newview/llfloatergroupinvite.cpp             |   2 +-
 indra/newview/llfloaterimcontainer.cpp             |  14 +-
 indra/newview/llfloaterimnearbychat.cpp            |  14 +-
 indra/newview/llfloaterimnearbychathandler.cpp     |  18 +-
 indra/newview/llfloaterimsession.cpp               |  14 +-
 indra/newview/llfloaterland.cpp                    |  12 +-
 indra/newview/llfloaterlandholdings.cpp            |   2 +-
 indra/newview/llfloatermodelpreview.cpp            | 130 +++++-----
 indra/newview/llfloatermodeluploadbase.cpp         |   2 +-
 indra/newview/llfloaternotificationsconsole.cpp    |   2 +-
 indra/newview/llfloaterobjectweights.cpp           |   2 +-
 indra/newview/llfloaterpathfindingconsole.cpp      |   2 +-
 indra/newview/llfloaterpreference.cpp              |   2 +-
 indra/newview/llfloaterproperties.cpp              |  10 +-
 indra/newview/llfloaterregiondebugconsole.cpp      |   4 +-
 indra/newview/llfloaterregioninfo.cpp              |  80 +++---
 indra/newview/llfloaterreporter.cpp                |  22 +-
 indra/newview/llfloaterscriptlimits.cpp            |  60 ++---
 indra/newview/llfloatersettingsdebug.cpp           |   4 +-
 indra/newview/llfloatersidepanelcontainer.h        |   2 +-
 indra/newview/llfloatersnapshot.cpp                |  76 +++---
 indra/newview/llfloatertools.cpp                   |   6 +-
 indra/newview/llfloatertranslationsettings.cpp     |   2 +-
 indra/newview/llfloateruipreview.cpp               |   8 +-
 indra/newview/llfloaterwebcontent.cpp              |   8 +-
 indra/newview/llfloaterwebprofile.cpp              |   6 +-
 indra/newview/llfollowcam.cpp                      |   6 +-
 indra/newview/llfriendcard.cpp                     |  24 +-
 indra/newview/llgesturelistener.cpp                |   8 +-
 indra/newview/llgesturemgr.cpp                     |  28 +--
 indra/newview/llgiveinventory.cpp                  |  10 +-
 indra/newview/llgroupactions.cpp                   |   8 +-
 indra/newview/llgroupmgr.cpp                       | 112 ++++-----
 indra/newview/llhomelocationresponder.cpp          |   4 +-
 indra/newview/llhudeffect.cpp                      |   2 +-
 indra/newview/llhudeffectbeam.cpp                  |  10 +-
 indra/newview/llhudeffectlookat.cpp                |  12 +-
 indra/newview/llhudeffectpointat.cpp               |   8 +-
 indra/newview/llhudeffecttrail.cpp                 |   4 +-
 indra/newview/llhudmanager.cpp                     |  14 +-
 indra/newview/llhudnametag.cpp                     |   2 +-
 indra/newview/llhudobject.cpp                      |   6 +-
 indra/newview/llhudtext.cpp                        |   2 +-
 indra/newview/llimview.cpp                         |  50 ++--
 indra/newview/llinspectavatar.cpp                  |   2 +-
 indra/newview/llinspecttoast.cpp                   |   4 +-
 indra/newview/llinventorybridge.cpp                |  94 +++----
 indra/newview/llinventoryfilter.cpp                |   6 +-
 indra/newview/llinventoryfunctions.cpp             |   4 +-
 indra/newview/llinventoryitemslist.cpp             |   4 +-
 indra/newview/llinventorymodel.cpp                 | 270 ++++++++++-----------
 indra/newview/llinventorymodelbackgroundfetch.cpp  |  20 +-
 indra/newview/llinventoryobserver.cpp              |  26 +-
 indra/newview/llinventorypanel.cpp                 |   8 +-
 indra/newview/lljoystickbutton.cpp                 |  14 +-
 indra/newview/lllandmarkactions.cpp                |   6 +-
 indra/newview/lllandmarklist.cpp                   |   8 +-
 indra/newview/lllistcontextmenu.cpp                |   2 +-
 indra/newview/lllocalbitmaps.cpp                   |  32 +--
 indra/newview/lllocationhistory.cpp                |  14 +-
 indra/newview/lllocationinputctrl.cpp              |   4 +-
 indra/newview/lllogchat.cpp                        |   4 +-
 indra/newview/lllogininstance.cpp                  |  36 +--
 indra/newview/llmainlooprepeater.cpp               |   2 +-
 indra/newview/llmanip.cpp                          |   4 +-
 indra/newview/llmaniprotate.cpp                    |   8 +-
 indra/newview/llmanipscale.cpp                     |   6 +-
 indra/newview/llmaniptranslate.cpp                 |  24 +-
 indra/newview/llmarketplacefunctions.cpp           |  26 +-
 indra/newview/llmediactrl.cpp                      |   8 +-
 indra/newview/llmeshrepository.cpp                 |  98 ++++----
 indra/newview/llmimetypes.cpp                      |   4 +-
 indra/newview/llmoveview.cpp                       |   8 +-
 indra/newview/llmutelist.cpp                       |  28 +--
 indra/newview/llnamelistctrl.cpp                   |   8 +-
 indra/newview/llnavigationbar.cpp                  |   4 +-
 indra/newview/llnotificationhandlerutil.cpp        |   6 +-
 indra/newview/lloutfitslist.cpp                    |   4 +-
 indra/newview/llpanelavatar.cpp                    |   2 +-
 indra/newview/llpanelblockedlist.cpp               |   2 +-
 indra/newview/llpanelclassified.cpp                |  22 +-
 indra/newview/llpaneleditwearable.cpp              |  48 ++--
 indra/newview/llpanelface.cpp                      |  14 +-
 indra/newview/llpanelgroup.cpp                     |   2 +-
 indra/newview/llpanelgroupgeneral.cpp              |   6 +-
 indra/newview/llpanelgroupinvite.cpp               |   2 +-
 indra/newview/llpanelgrouplandmoney.cpp            |  38 +--
 indra/newview/llpanelgroupnotices.cpp              |  16 +-
 indra/newview/llpanelgrouproles.cpp                |  84 +++----
 indra/newview/llpanelland.cpp                      |   2 +-
 indra/newview/llpanellandmarkinfo.cpp              |   4 +-
 indra/newview/llpanellandmarks.cpp                 |  14 +-
 indra/newview/llpanellogin.cpp                     |  10 +-
 indra/newview/llpanelmaininventory.cpp             |   6 +-
 indra/newview/llpanelmarketplaceinboxinventory.cpp |   4 +-
 indra/newview/llpanelobject.cpp                    |  22 +-
 indra/newview/llpanelobjectinventory.cpp           |  46 ++--
 indra/newview/llpaneloutfitedit.cpp                |  14 +-
 indra/newview/llpanelpeople.cpp                    |  26 +-
 indra/newview/llpanelpermissions.cpp               |  12 +-
 indra/newview/llpanelpicks.cpp                     |  14 +-
 indra/newview/llpanelplaces.cpp                    |  12 +-
 indra/newview/llpanelprimmediacontrols.cpp         |   4 +-
 indra/newview/llpanelprofile.cpp                   |  12 +-
 indra/newview/llpanelsnapshot.cpp                  |   2 +-
 indra/newview/llpanelsnapshotoptions.cpp           |   2 +-
 indra/newview/llpanelsnapshotpostcard.cpp          |   2 +-
 indra/newview/llpanelteleporthistory.cpp           |   2 +-
 indra/newview/llpanelvolume.cpp                    |   4 +-
 indra/newview/llpanelwearing.cpp                   |   2 +-
 indra/newview/llpatchvertexarray.cpp               |   2 +-
 indra/newview/llpathfindingmanager.cpp             |  20 +-
 indra/newview/llpathfindingnavmesh.cpp             |  10 +-
 indra/newview/llphysicsmotion.cpp                  |   2 +-
 indra/newview/llplacesfolderview.cpp               |   2 +-
 indra/newview/llplacesinventorybridge.cpp          |   2 +-
 indra/newview/llpostcard.cpp                       |  18 +-
 indra/newview/llpreview.cpp                        |   4 +-
 indra/newview/llpreviewgesture.cpp                 |  16 +-
 indra/newview/llpreviewnotecard.cpp                |  32 +--
 indra/newview/llpreviewscript.cpp                  |  70 +++---
 indra/newview/llproductinforequest.cpp             |   6 +-
 indra/newview/llregioninfomodel.cpp                |   6 +-
 indra/newview/llremoteparcelrequest.cpp            |   4 +-
 indra/newview/llscreenchannel.cpp                  |  16 +-
 indra/newview/llscriptfloater.cpp                  |  14 +-
 indra/newview/llsechandler_basic.cpp               |   6 +-
 indra/newview/llselectmgr.cpp                      |  66 ++---
 indra/newview/llsidepanelappearance.cpp            |   2 +-
 indra/newview/llsidepanelinventory.cpp             |   2 +-
 indra/newview/llsidepaneliteminfo.cpp              |  12 +-
 indra/newview/llsidepaneltaskinfo.cpp              |  10 +-
 indra/newview/llspatialpartition.cpp               |  38 +--
 indra/newview/llspatialpartition.h                 |   4 +-
 indra/newview/llspeakers.cpp                       |  24 +-
 indra/newview/llspeakingindicatormanager.cpp       |   2 +-
 indra/newview/llstartup.cpp                        |  46 ++--
 indra/newview/llstatusbar.cpp                      |   2 +-
 indra/newview/llsurface.cpp                        |  20 +-
 indra/newview/llsurfacepatch.cpp                   |   2 +-
 indra/newview/llsyswellwindow.cpp                  |  14 +-
 indra/newview/llteleporthistory.cpp                |  10 +-
 indra/newview/llteleporthistorystorage.cpp         |  12 +-
 indra/newview/lltextureatlas.cpp                   |   6 +-
 indra/newview/lltexturecache.cpp                   |  70 +++---
 indra/newview/lltexturectrl.cpp                    |   8 +-
 indra/newview/lltexturefetch.cpp                   | 176 +++++++-------
 indra/newview/lltextureinfo.cpp                    |   4 +-
 indra/newview/lltexturestats.cpp                   |   2 +-
 indra/newview/lltexturestatsuploader.cpp           |   4 +-
 indra/newview/lltextureview.cpp                    |   6 +-
 indra/newview/lltoastalertpanel.cpp                |   4 +-
 indra/newview/lltoastgroupnotifypanel.cpp          |   2 +-
 indra/newview/lltoastimpanel.cpp                   |   6 +-
 indra/newview/lltoastscripttextbox.cpp             |   2 +-
 indra/newview/lltool.cpp                           |  26 +-
 indra/newview/lltoolbarview.cpp                    |  20 +-
 indra/newview/lltoolbrush.cpp                      |   4 +-
 indra/newview/lltooldraganddrop.cpp                |  82 +++----
 indra/newview/lltoolfocus.cpp                      |   8 +-
 indra/newview/lltoolgrab.cpp                       |  28 +--
 indra/newview/lltoolgun.cpp                        |   4 +-
 indra/newview/lltoolmgr.cpp                        |   2 +-
 indra/newview/lltoolobjpicker.cpp                  |   4 +-
 indra/newview/lltoolpie.cpp                        |  12 +-
 indra/newview/lltoolplacer.cpp                     |   6 +-
 indra/newview/lltoolselectland.cpp                 |   8 +-
 indra/newview/lltoolselectrect.cpp                 |   4 +-
 indra/newview/lltracker.cpp                        |   2 +-
 indra/newview/lltranslate.cpp                      |   2 +-
 indra/newview/lluploadfloaterobservers.cpp         |   4 +-
 indra/newview/llurl.cpp                            |  14 +-
 indra/newview/llurldispatcher.cpp                  |   2 +-
 indra/newview/llurlhistory.cpp                     |  10 +-
 indra/newview/llurlwhitelist.cpp                   |   2 +-
 indra/newview/llviewerassetstorage.cpp             |  22 +-
 indra/newview/llvieweraudio.cpp                    |   8 +-
 indra/newview/llviewerchat.cpp                     |   2 +-
 indra/newview/llviewercontrol.cpp                  |  12 +-
 indra/newview/llviewerdisplay.cpp                  |  12 +-
 indra/newview/llviewerdisplayname.cpp              |  12 +-
 indra/newview/llviewerfoldertype.cpp               |  12 +-
 indra/newview/llviewergenericmessage.cpp           |   6 +-
 indra/newview/llviewergesture.cpp                  |   4 +-
 indra/newview/llviewerinventory.cpp                |  46 ++--
 indra/newview/llviewerjointattachment.cpp          |   6 +-
 indra/newview/llviewerjointmesh.cpp                |   2 +-
 indra/newview/llviewerjoystick.cpp                 |  16 +-
 indra/newview/llviewerkeyboard.cpp                 |  18 +-
 indra/newview/llviewermedia.cpp                    | 100 ++++----
 indra/newview/llviewermedia_streamingaudio.cpp     |  14 +-
 indra/newview/llviewermediafocus.cpp               |  28 +--
 indra/newview/llviewermenu.cpp                     |  86 +++----
 indra/newview/llviewermenufile.cpp                 |  60 ++---
 indra/newview/llviewermessage.cpp                  |  24 +-
 indra/newview/llviewerobject.cpp                   | 202 +++++++--------
 indra/newview/llviewerobjectlist.cpp               | 114 ++++-----
 indra/newview/llviewerobjectlist.h                 |   2 +-
 indra/newview/llvieweroctree.cpp                   |  20 +-
 indra/newview/llviewerparcelmedia.cpp              |   4 +-
 indra/newview/llviewerparcelmgr.cpp                |  50 ++--
 indra/newview/llviewerparceloverlay.cpp            |   2 +-
 indra/newview/llviewerpartsim.cpp                  |  20 +-
 indra/newview/llviewerpartsource.cpp               |   4 +-
 indra/newview/llviewerregion.cpp                   |  60 ++---
 indra/newview/llviewershadermgr.cpp                |   2 +-
 indra/newview/llviewerstats.cpp                    |  22 +-
 indra/newview/llviewerstatsrecorder.cpp            |  16 +-
 indra/newview/llviewertexlayer.cpp                 |  24 +-
 indra/newview/llviewertexteditor.cpp               |  10 +-
 indra/newview/llviewertexture.cpp                  |  72 +++---
 indra/newview/llviewertexture.h                    |   2 +-
 indra/newview/llviewertexturelist.cpp              |  22 +-
 indra/newview/llviewerthrottle.cpp                 |   6 +-
 indra/newview/llviewerwearable.cpp                 |  16 +-
 indra/newview/llviewerwindow.cpp                   | 114 ++++-----
 indra/newview/llvlcomposition.cpp                  |  12 +-
 indra/newview/llvlmanager.cpp                      |   2 +-
 indra/newview/llvoavatar.cpp                       | 240 +++++++++---------
 indra/newview/llvoavatarself.cpp                   | 108 ++++-----
 indra/newview/llvocache.cpp                        |  54 ++---
 indra/newview/llvograss.cpp                        |  18 +-
 indra/newview/llvoicevisualizer.cpp                |   6 +-
 indra/newview/llvoicevivox.cpp                     |   2 +-
 indra/newview/llvopartgroup.cpp                    |   4 +-
 indra/newview/llvosurfacepatch.cpp                 |   4 +-
 indra/newview/llvotree.cpp                         |  18 +-
 indra/newview/llvovolume.cpp                       |  32 +--
 indra/newview/llvowlsky.cpp                        |  12 +-
 indra/newview/llwatchdog.cpp                       |   4 +-
 indra/newview/llwaterparammanager.cpp              |   4 +-
 indra/newview/llwearableitemslist.cpp              |  18 +-
 indra/newview/llwearablelist.cpp                   |   4 +-
 indra/newview/llweb.cpp                            |   2 +-
 indra/newview/llwebprofile.cpp                     |  24 +-
 indra/newview/llwldaycycle.cpp                     |  30 +--
 indra/newview/llwlparammanager.cpp                 |  16 +-
 indra/newview/llworld.cpp                          |  62 ++---
 indra/newview/llworldmapmessage.cpp                |   2 +-
 indra/newview/llworldmapview.cpp                   |   2 +-
 indra/newview/llxmlrpctransaction.cpp              |  20 +-
 indra/newview/pipeline.cpp                         | 126 +++++-----
 313 files changed, 3383 insertions(+), 3383 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp
index 7662a9689d..150b97baa5 100755
--- a/indra/newview/llaccountingcostmanager.cpp
+++ b/indra/newview/llaccountingcostmanager.cpp
@@ -58,7 +58,7 @@ public:
 	
 	void errorWithContent( U32 statusNum, const std::string& reason, const LLSD& content )
 	{
-		llwarns << "Transport error [status:" << statusNum << "]: " << content <<llendl;
+		LL_WARNS() << "Transport error [status:" << statusNum << "]: " << content <<LL_ENDL;
 		clearPendingRequests();
 
 		LLAccountingCostObserver* observer = mObserverHandle.get();
@@ -73,7 +73,7 @@ public:
 		//Check for error
 		if ( !content.isMap() || content.has("error") )
 		{
-			llwarns	<< "Error on fetched data"<< llendl;
+			LL_WARNS()	<< "Error on fetched data"<< LL_ENDL;
 		}
 		else if (content.has("selected"))
 		{
@@ -148,7 +148,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType,
 			}
 			else 
 			{
-				llinfos<<"Invalid selection type "<<llendl;
+				LL_INFOS()<<"Invalid selection type "<<LL_ENDL;
 				mObjectList.clear();
 				mPendingObjectQuota.clear();
 				return;
@@ -163,7 +163,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType,
 	else
 	{
 		//url was empty - warn & continue
-		llwarns<<"Supplied url is empty "<<llendl;
+		LL_WARNS()<<"Supplied url is empty "<<LL_ENDL;
 		mObjectList.clear();
 		mPendingObjectQuota.clear();
 	}
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 460ae62522..2d7008b4ef 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -811,7 +811,7 @@ void LLAgent::standUp()
 
 void LLAgent::handleServerBakeRegionTransition(const LLUUID& region_id)
 {
-	llinfos << "called" << llendl;
+	LL_INFOS() << "called" << LL_ENDL;
 
 
 	// Old-style appearance entering a server-bake region.
@@ -819,7 +819,7 @@ void LLAgent::handleServerBakeRegionTransition(const LLUUID& region_id)
 		!gAgentAvatarp->isUsingServerBakes() &&
 		(mRegionp->getCentralBakeVersion()>0))
 	{
-		llinfos << "update requested due to region transition" << llendl;
+		LL_INFOS() << "update requested due to region transition" << LL_ENDL;
 		LLAppearanceMgr::instance().requestServerAppearanceUpdate();
 	}
 	// new-style appearance entering a non-bake region,
@@ -846,8 +846,8 @@ void LLAgent::setRegion(LLViewerRegion *regionp)
 		// host_name = regionp->getHost().getHostName();
 
 		std::string ip = regionp->getHost().getString();
-		llinfos << "Moving agent into region: " << regionp->getName()
-				<< " located at " << ip << llendl;
+		LL_INFOS() << "Moving agent into region: " << regionp->getName()
+				<< " located at " << ip << LL_ENDL;
 		if (mRegionp)
 		{
 			// We've changed regions, we're now going to change our agent coordinate frame.
@@ -989,12 +989,12 @@ void LLAgent::sendMessage()
 {
 	if (gDisconnected)
 	{
-		llwarns << "Trying to send message when disconnected!" << llendl;
+		LL_WARNS() << "Trying to send message when disconnected!" << LL_ENDL;
 		return;
 	}
 	if (!mRegionp)
 	{
-		llerrs << "No region for agent yet!" << llendl;
+		LL_ERRS() << "No region for agent yet!" << LL_ENDL;
 		return;
 	}
 	gMessageSystem->sendMessage(mRegionp->getHost());
@@ -1008,12 +1008,12 @@ void LLAgent::sendReliableMessage()
 {
 	if (gDisconnected)
 	{
-		lldebugs << "Trying to send message when disconnected!" << llendl;
+		LL_DEBUGS() << "Trying to send message when disconnected!" << LL_ENDL;
 		return;
 	}
 	if (!mRegionp)
 	{
-		lldebugs << "LLAgent::sendReliableMessage No region for agent yet, not sending message!" << llendl;
+		LL_DEBUGS() << "LLAgent::sendReliableMessage No region for agent yet, not sending message!" << LL_ENDL;
 		return;
 	}
 	gMessageSystem->sendReliable(mRegionp->getHost());
@@ -1042,7 +1042,7 @@ void LLAgent::setPositionAgent(const LLVector3 &pos_agent)
 {
 	if (!pos_agent.isFinite())
 	{
-		llerrs << "setPositionAgent is not a number" << llendl;
+		LL_ERRS() << "setPositionAgent is not a number" << LL_ENDL;
 	}
 
 	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
@@ -1166,7 +1166,7 @@ void LLAgent::resetAxes(const LLVector3 &look_at)
 	LLVector3 cross(look_at % skyward);
 	if (cross.isNull())
 	{
-		llinfos << "LLAgent::resetAxes cross-product is zero" << llendl;
+		LL_INFOS() << "LLAgent::resetAxes cross-product is zero" << LL_ENDL;
 		return;
 	}
 
@@ -2297,7 +2297,7 @@ void LLAgent::setStartPosition( U32 location_id )
     object = gObjectList.findObject(gAgentID);
     if (! object)
     {
-        llinfos << "setStartPosition - Can't find agent viewerobject id " << gAgentID << llendl;
+        LL_INFOS() << "setStartPosition - Can't find agent viewerobject id " << gAgentID << LL_ENDL;
         return;
     }
     // we've got the viewer object
@@ -2398,7 +2398,7 @@ void LLAgent::requestStopMotion( LLMotion* motion )
 
 	// if motion is not looping, it could have stopped by running out of time
 	// so we need to tell the server this
-//	llinfos << "Sending stop for motion " << motion->getName() << llendl;
+//	LL_INFOS() << "Sending stop for motion " << motion->getName() << LL_ENDL;
 	sendAnimationRequest( anim_state, ANIM_REQUEST_STOP );
 }
 
@@ -2561,19 +2561,19 @@ void LLMaturityPreferencesResponder::result(const LLSD &pContent)
 
 	if (actualMaturity != mPreferredMaturity)
 	{
-		llwarns << "while attempting to change maturity preference from '" << LLViewerRegion::accessToString(mPreviousMaturity)
+		LL_WARNS() << "while attempting to change maturity preference from '" << LLViewerRegion::accessToString(mPreviousMaturity)
 			<< "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) << "', the server responded with '"
 			<< LLViewerRegion::accessToString(actualMaturity) << "' [value:" << static_cast<U32>(actualMaturity) << ", llsd:"
-			<< pContent << "]" << llendl;
+			<< pContent << "]" << LL_ENDL;
 	}
 	mAgent->handlePreferredMaturityResult(actualMaturity);
 }
 
 void LLMaturityPreferencesResponder::errorWithContent(U32 pStatus, const std::string& pReason, const LLSD& pContent)
 {
-	llwarns << "while attempting to change maturity preference from '" << LLViewerRegion::accessToString(mPreviousMaturity)
+	LL_WARNS() << "while attempting to change maturity preference from '" << LLViewerRegion::accessToString(mPreviousMaturity)
 		<< "' to '" << LLViewerRegion::accessToString(mPreferredMaturity) << "', we got an error with [status:"
-		<< pStatus << "]: " << (pContent.isDefined() ? pContent : LLSD(pReason)) << llendl;
+		<< pStatus << "]: " << (pContent.isDefined() ? pContent : LLSD(pReason)) << LL_ENDL;
 	mAgent->handlePreferredMaturityError();
 }
 
@@ -2622,8 +2622,8 @@ void LLAgent::handlePreferredMaturityResult(U8 pServerMaturity)
 		// server by re-sending our last known request.  Cap the re-tries at 3 just to be safe.
 		else if (++mMaturityPreferenceNumRetries <= 3)
 		{
-			llinfos << "Retrying attempt #" << mMaturityPreferenceNumRetries << " to set viewer preferred maturity to '"
-				<< LLViewerRegion::accessToString(mLastKnownRequestMaturity) << "'" << llendl;
+			LL_INFOS() << "Retrying attempt #" << mMaturityPreferenceNumRetries << " to set viewer preferred maturity to '"
+				<< LLViewerRegion::accessToString(mLastKnownRequestMaturity) << "'" << LL_ENDL;
 			sendMaturityPreferenceToServer(mLastKnownRequestMaturity);
 		}
 		// Else, the viewer is style out of sync with the server after 3 retries, so inform the user
@@ -2650,8 +2650,8 @@ void LLAgent::handlePreferredMaturityError()
 		// the server, but not quite sure why we are
 		if (mLastKnownRequestMaturity == mLastKnownResponseMaturity)
 		{
-			llwarns << "Got an error but maturity preference '" << LLViewerRegion::accessToString(mLastKnownRequestMaturity)
-				<< "' seems to be in sync with the server" << llendl;
+			LL_WARNS() << "Got an error but maturity preference '" << LLViewerRegion::accessToString(mLastKnownRequestMaturity)
+				<< "' seems to be in sync with the server" << LL_ENDL;
 			reportPreferredMaturitySuccess();
 		}
 		// Else, the more likely case is that the last request does not match the last response,
@@ -2705,7 +2705,7 @@ void LLAgent::reportPreferredMaturityError()
 	{
 		bool tmpIsDoSendMaturityPreferenceToServer = mIsDoSendMaturityPreferenceToServer;
 		mIsDoSendMaturityPreferenceToServer = false;
-		llinfos << "Setting viewer preferred maturity to '" << LLViewerRegion::accessToString(mLastKnownResponseMaturity) << "'" << llendl;
+		LL_INFOS() << "Setting viewer preferred maturity to '" << LLViewerRegion::accessToString(mLastKnownResponseMaturity) << "'" << LL_ENDL;
 		gSavedSettings.setU32("PreferredMaturity", static_cast<U32>(mLastKnownResponseMaturity));
 		mIsDoSendMaturityPreferenceToServer = tmpIsDoSendMaturityPreferenceToServer;
 	}
@@ -2754,8 +2754,8 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity)
 
 				LLSD body = LLSD::emptyMap();
 				body["access_prefs"] = access_prefs;
-				llinfos << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity)
-					<< "' via capability to: " << url << llendl;
+				LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity)
+					<< "' via capability to: " << url << LL_ENDL;
 				LLSD headers;
 				LLHTTPClient::post(url, body, responderPtr, headers, 30.0f);
 			}
@@ -3194,7 +3194,7 @@ void LLAgent::processAgentDropGroup(LLMessageSystem *msg, void **)
 
 	if (agent_id != gAgentID)
 	{
-		llwarns << "processAgentDropGroup for agent other than me" << llendl;
+		LL_WARNS() << "processAgentDropGroup for agent other than me" << LL_ENDL;
 		return;
 	}
 
@@ -3225,7 +3225,7 @@ void LLAgent::processAgentDropGroup(LLMessageSystem *msg, void **)
 	}
 	else
 	{
-		llwarns << "processAgentDropGroup, agent is not part of group " << group_id << llendl;
+		LL_WARNS() << "processAgentDropGroup, agent is not part of group " << group_id << LL_ENDL;
 	}
 }
 
@@ -3258,7 +3258,7 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode
 			body["AgentData"].isArray() &&
 			body["AgentData"][0].isMap() )
 		{
-			llinfos << "VALID DROP GROUP" << llendl;
+			LL_INFOS() << "VALID DROP GROUP" << LL_ENDL;
 
 			//there is only one set of data in the AgentData block
 			LLSD agent_data = body["AgentData"][0];
@@ -3270,8 +3270,8 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode
 
 			if (agent_id != gAgentID)
 			{
-				llwarns
-					<< "AgentDropGroup for agent other than me" << llendl;
+				LL_WARNS()
+					<< "AgentDropGroup for agent other than me" << LL_ENDL;
 
 				response->notFound();
 				return;
@@ -3302,9 +3302,9 @@ class LLAgentDropGroupViewerNode : public LLHTTPNode
 			}
 			else
 			{
-				llwarns
+				LL_WARNS()
 					<< "AgentDropGroup, agent is not part of group "
-					<< group_id << llendl;
+					<< group_id << LL_ENDL;
 			}
 
 			response->result(LLSD());
@@ -3331,7 +3331,7 @@ void LLAgent::processAgentGroupDataUpdate(LLMessageSystem *msg, void **)
 
 	if (agent_id != gAgentID)
 	{
-		llwarns << "processAgentGroupDataUpdate for agent other than me" << llendl;
+		LL_WARNS() << "processAgentGroupDataUpdate for agent other than me" << LL_ENDL;
 		return;
 	}	
 	
@@ -3380,7 +3380,7 @@ class LLAgentGroupDataUpdateViewerNode : public LLHTTPNode
 
 		if (agent_id != gAgentID)
 		{
-			llwarns << "processAgentGroupDataUpdate for agent other than me" << llendl;
+			LL_WARNS() << "processAgentGroupDataUpdate for agent other than me" << LL_ENDL;
 			return;
 		}	
 
@@ -3438,7 +3438,7 @@ void LLAgent::processAgentDataUpdate(LLMessageSystem *msg, void **)
 
 	if (agent_id != gAgentID)
 	{
-		llwarns << "processAgentDataUpdate for agent other than me" << llendl;
+		LL_WARNS() << "processAgentDataUpdate for agent other than me" << LL_ENDL;
 		return;
 	}
 
@@ -3606,7 +3606,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void *
 
 	if (!isAgentAvatarValid() || gAgentAvatarp->isDead())
 	{
-		llwarns << "No avatar for user in cached texture update!" << llendl;
+		LL_WARNS() << "No avatar for user in cached texture update!" << LL_ENDL;
 		return;
 	}
 
@@ -3643,7 +3643,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void *
 				{
 					if (texture_id.notNull())
 					{
-						//llinfos << "Received cached texture " << (U32)texture_index << ": " << texture_id << llendl;
+						//LL_INFOS() << "Received cached texture " << (U32)texture_index << ": " << texture_id << LL_ENDL;
 						gAgentAvatarp->setCachedBakedTexture((ETextureIndex)texture_index, texture_id);
 						//gAgentAvatarp->setTETexture( LLVOAvatar::sBakedTextureIndices[texture_index], texture_id );
 						gAgentQueryManager.mActiveCacheQueries[baked_index] = 0;
@@ -3658,7 +3658,7 @@ void LLAgent::processAgentCachedTextureResponse(LLMessageSystem *mesgsys, void *
 			}
 		}
 	}
-	llinfos << "Received cached texture response for " << num_results << " textures." << llendl;
+	LL_INFOS() << "Received cached texture response for " << num_results << " textures." << LL_ENDL;
 	gAgentAvatarp->outputRezTiming("Fetched agent wearables textures from cache. Will now load them");
 
 	gAgentAvatarp->updateMeshTextures();
@@ -3736,7 +3736,7 @@ bool LLAgent::teleportCore(bool is_local)
 {
 	if ((TELEPORT_NONE != mTeleportState) && (mTeleportState != TELEPORT_PENDING))
 	{
-		llwarns << "Attempt to teleport when already teleporting." << llendl;
+		LL_WARNS() << "Attempt to teleport when already teleporting." << LL_ENDL;
 		return false;
 	}
 
@@ -4046,7 +4046,7 @@ void LLAgent::doTeleportViaLocation(const LLVector3d& pos_global)
 	else if(regionp && 
 		teleportCore(regionp->getHandle() == to_region_handle_global((F32)pos_global.mdV[VX], (F32)pos_global.mdV[VY])))
 	{
-		llwarns << "Using deprecated teleportlocationrequest." << llendl; 
+		LL_WARNS() << "Using deprecated teleportlocationrequest." << LL_ENDL; 
 		// send the message
 		LLMessageSystem* msg = gMessageSystem;
 		msg->newMessageFast(_PREHASH_TeleportLocationRequest);
@@ -4257,7 +4257,7 @@ void LLAgent::dumpSentAppearance(const std::string& dump_prefix)
 	}
 	else
 	{
-		LL_DEBUGS("Avatar") << "dumping sent appearance message to " << fullpath << llendl;
+		LL_DEBUGS("Avatar") << "dumping sent appearance message to " << fullpath << LL_ENDL;
 	}
 
 	LLVisualParam* appearance_version_param = gAgentAvatarp->getVisualParam(11000);
@@ -4300,7 +4300,7 @@ void LLAgent::sendAgentSetAppearance()
 	gAgentAvatarp->bakedTextureOriginCounts(sb_count, host_count, both_count, neither_count);
 	if (both_count != 0 || neither_count != 0)
 	{
-		llwarns << "bad bake texture state " << sb_count << "," << host_count << "," << both_count << "," << neither_count << llendl;
+		LL_WARNS() << "bad bake texture state " << sb_count << "," << host_count << "," << both_count << "," << neither_count << LL_ENDL;
 	}
 	if (sb_count != 0 && host_count == 0)
 	{
@@ -4312,7 +4312,7 @@ void LLAgent::sendAgentSetAppearance()
 	}
 	else if (sb_count + host_count > 0)
 	{
-		llwarns << "unclear baked texture state, not sending appearance" << llendl;
+		LL_WARNS() << "unclear baked texture state, not sending appearance" << LL_ENDL;
 		return;
 	}
 	
@@ -4356,7 +4356,7 @@ void LLAgent::sendAgentSetAppearance()
 		// IMG_DEFAULT_AVATAR means not baked. 0 index should be ignored for baked textures
 		if (!gAgentAvatarp->isTextureDefined(texture_index, 0))
 		{
-			LL_DEBUGS("Avatar") << "texture not current for baked " << (S32)baked_index << " local " << (S32)texture_index << llendl;
+			LL_DEBUGS("Avatar") << "texture not current for baked " << (S32)baked_index << " local " << (S32)texture_index << LL_ENDL;
 			textures_current = FALSE;
 			break;
 		}
@@ -4424,7 +4424,7 @@ void LLAgent::sendAgentSetAppearance()
 		}
 	}
 
-	//llinfos << "Avatar XML num VisualParams transmitted = " << transmitted_params << llendl;
+	//LL_INFOS() << "Avatar XML num VisualParams transmitted = " << transmitted_params << LL_ENDL;
 	sendReliableMessage();
 }
 
@@ -4465,8 +4465,8 @@ void LLAgent::parseTeleportMessages(const std::string& xml_filename)
 
 	if (!success || !root || !root->hasName( "teleport_messages" ))
 	{
-		llerrs << "Problem reading teleport string XML file: " 
-			   << xml_filename << llendl;
+		LL_ERRS() << "Problem reading teleport string XML file: " 
+			   << xml_filename << LL_ENDL;
 		return;
 	}
 
@@ -4530,11 +4530,11 @@ void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& dire
 // static
 void LLAgent::dumpGroupInfo()
 {
-	llinfos << "group   " << gAgent.mGroupName << llendl;
-	llinfos << "ID      " << gAgent.mGroupID << llendl;
-	llinfos << "powers " << gAgent.mGroupPowers << llendl;
-	llinfos << "title   " << gAgent.mGroupTitle << llendl;
-	//llinfos << "insig   " << gAgent.mGroupInsigniaID << llendl;
+	LL_INFOS() << "group   " << gAgent.mGroupName << LL_ENDL;
+	LL_INFOS() << "ID      " << gAgent.mGroupID << LL_ENDL;
+	LL_INFOS() << "powers " << gAgent.mGroupPowers << LL_ENDL;
+	LL_INFOS() << "title   " << gAgent.mGroupTitle << LL_ENDL;
+	//LL_INFOS() << "insig   " << gAgent.mGroupInsigniaID << LL_ENDL;
 }
 
 // Draw a representation of current autopilot target
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index d02817df7b..93e0cddd64 100755
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -563,10 +563,10 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance)
 	if (mFocusObject->mDrawable.isNull())
 	{
 #ifdef LL_RELEASE_FOR_DOWNLOAD
-		llwarns << "Focus object with no drawable!" << llendl;
+		LL_WARNS() << "Focus object with no drawable!" << LL_ENDL;
 #else
 		mFocusObject->dump();
-		llerrs << "Focus object with no drawable!" << llendl;
+		LL_ERRS() << "Focus object with no drawable!" << LL_ENDL;
 #endif
 		obj_min_distance = 0.f;
 		return TRUE;
@@ -1385,7 +1385,7 @@ void LLAgentCamera::updateCamera()
 	
 	mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE));
 
-//	llinfos << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << llendl;
+//	LL_INFOS() << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << LL_ENDL;
 
 	LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal);
 	
@@ -1689,7 +1689,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 	{
 		if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
 		{
-			llwarns << "Null avatar drawable!" << llendl;
+			LL_WARNS() << "Null avatar drawable!" << LL_ENDL;
 			return LLVector3d::zero;
 		}
 		head_offset.clearVec();
diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp
index 87c44a391d..7887184a11 100755
--- a/indra/newview/llagentlistener.cpp
+++ b/indra/newview/llagentlistener.cpp
@@ -193,8 +193,8 @@ void LLAgentListener::requestSit(LLSD const & event_data) const
     }
 	else
 	{
-		llwarns << "LLAgent requestSit could not find the sit target: " 
-			<< event_data << llendl;
+		LL_WARNS() << "LLAgent requestSit could not find the sit target: " 
+			<< event_data << LL_ENDL;
 	}
 }
 
@@ -276,8 +276,8 @@ void LLAgentListener::requestTouch(LLSD const & event_data) const
     }
 	else
 	{
-		llwarns << "LLAgent requestTouch could not find the touch target " 
-			<< event_data["obj_uuid"].asUUID() << llendl;
+		LL_WARNS() << "LLAgent requestTouch could not find the touch target " 
+			<< event_data["obj_uuid"].asUUID() << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llagentpicksinfo.cpp b/indra/newview/llagentpicksinfo.cpp
index 7a04cfb48b..799060eeab 100755
--- a/indra/newview/llagentpicksinfo.cpp
+++ b/indra/newview/llagentpicksinfo.cpp
@@ -119,7 +119,7 @@ void LLAgentPicksInfo::onServerRespond(LLAvatarPicks* picks)
 {
 	if(!picks)
 	{
-		llerrs << "Unexpected value" << llendl;
+		LL_ERRS() << "Unexpected value" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llagentpilot.cpp b/indra/newview/llagentpilot.cpp
index 0dd107f349..44589f0d57 100755
--- a/indra/newview/llagentpilot.cpp
+++ b/indra/newview/llagentpilot.cpp
@@ -72,7 +72,7 @@ void LLAgentPilot::load()
 	}
 	else
 	{
-		lldebugs << "no autopilot file found" << llendl;
+		LL_DEBUGS() << "no autopilot file found" << LL_ENDL;
 		return;
 	}
 }
@@ -88,13 +88,13 @@ void LLAgentPilot::loadTxt(const std::string& filename)
 
 	if (!file)
 	{
-		lldebugs << "Couldn't open " << filename
-			<< ", aborting agentpilot load!" << llendl;
+		LL_DEBUGS() << "Couldn't open " << filename
+			<< ", aborting agentpilot load!" << LL_ENDL;
 		return;
 	}
 	else
 	{
-		llinfos << "Opening pilot file " << filename << llendl;
+		LL_INFOS() << "Opening pilot file " << filename << LL_ENDL;
 	}
 
 	mActions.clear();
@@ -129,13 +129,13 @@ void LLAgentPilot::loadXML(const std::string& filename)
 
 	if (!file)
 	{
-		lldebugs << "Couldn't open " << filename
-			<< ", aborting agentpilot load!" << llendl;
+		LL_DEBUGS() << "Couldn't open " << filename
+			<< ", aborting agentpilot load!" << LL_ENDL;
 		return;
 	}
 	else
 	{
-		llinfos << "Opening pilot file " << filename << llendl;
+		LL_INFOS() << "Opening pilot file " << filename << LL_ENDL;
 	}
 
 	mActions.clear();
@@ -172,7 +172,7 @@ void LLAgentPilot::saveTxt(const std::string& filename)
 
 	if (!file)
 	{
-		llinfos << "Couldn't open " << filename << ", aborting agentpilot save!" << llendl;
+		LL_INFOS() << "Couldn't open " << filename << ", aborting agentpilot save!" << LL_ENDL;
 	}
 
 	file << mActions.size() << '\n';
@@ -195,7 +195,7 @@ void LLAgentPilot::saveXML(const std::string& filename)
 
 	if (!file)
 	{
-		llinfos << "Couldn't open " << filename << ", aborting agentpilot save!" << llendl;
+		LL_INFOS() << "Couldn't open " << filename << ", aborting agentpilot save!" << LL_ENDL;
 	}
 
 	S32 i;
@@ -233,7 +233,7 @@ void LLAgentPilot::stopRecord()
 
 void LLAgentPilot::addAction(enum EActionType action_type)
 {
-	llinfos << "Adding waypoint: " << gAgent.getPositionGlobal() << llendl;
+	LL_INFOS() << "Adding waypoint: " << gAgent.getPositionGlobal() << LL_ENDL;
 	Action action;
 	action.mType = action_type;
 	action.mTarget = gAgent.getPositionGlobal();
@@ -258,14 +258,14 @@ void LLAgentPilot::startPlayback()
 
 		if (mActions.size())
 		{
-			llinfos << "Starting playback, moving to waypoint 0" << llendl;
+			LL_INFOS() << "Starting playback, moving to waypoint 0" << LL_ENDL;
 			gAgent.startAutoPilotGlobal(mActions[0].mTarget);
 			moveCamera();
 			mStarted = FALSE;
 		}
 		else
 		{
-			llinfos << "No autopilot data, cancelling!" << llendl;
+			LL_INFOS() << "No autopilot data, cancelling!" << LL_ENDL;
 			mPlaying = FALSE;
 		}
 	}
@@ -306,7 +306,7 @@ void LLAgentPilot::moveCamera()
 
 		if ((t<0.0)||(t>1.0))
 		{
-			llwarns << "mCurrentAction is invalid, t = " << t << llendl;
+			LL_WARNS() << "mCurrentAction is invalid, t = " << t << LL_ENDL;
 			return;
 		}
 		
@@ -345,7 +345,7 @@ void LLAgentPilot::updateTarget()
 				{
 					if (!mStarted)
 					{
-						llinfos << "At start, beginning playback" << llendl;
+						LL_INFOS() << "At start, beginning playback" << LL_ENDL;
 						mTimer.reset();
 						mStarted = TRUE;
 					}
@@ -369,17 +369,17 @@ void LLAgentPilot::updateTarget()
 					{
 						if ((mNumRuns < 0) || (mNumRuns > 0))
 						{
-							llinfos << "Looping, restarting playback" << llendl;
+							LL_INFOS() << "Looping, restarting playback" << LL_ENDL;
 							startPlayback();
 						}
 						else if (mQuitAfterRuns)
 						{
-							llinfos << "Done with all runs, quitting viewer!" << llendl;
+							LL_INFOS() << "Done with all runs, quitting viewer!" << LL_ENDL;
 							LLAppViewer::instance()->forceQuit();
 						}
 						else
 						{
-							llinfos << "Done with all runs, disabling pilot" << llendl;
+							LL_INFOS() << "Done with all runs, disabling pilot" << LL_ENDL;
 							stopPlayback();
 						}
 					}
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 4a25b8c205..40a25848a2 100755
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -91,48 +91,48 @@ void checkWearableAgainstInventory(LLViewerWearable *wearable)
 	{
 		if (!item->isWearableType())
 		{
-			llwarns << "wearable associated with non-wearable item" << llendl;
+			LL_WARNS() << "wearable associated with non-wearable item" << LL_ENDL;
 		}
 		if (item->getWearableType() != wearable->getType())
 		{
-			llwarns << "type mismatch: wearable " << wearable->getName()
+			LL_WARNS() << "type mismatch: wearable " << wearable->getName()
 					<< " has type " << wearable->getType()
 					<< " but inventory item " << item->getName()
-					<< " has type "  << item->getWearableType() << llendl;
+					<< " has type "  << item->getWearableType() << LL_ENDL;
 		}
 	}
 	else
 	{
-		llwarns << "wearable inventory item not found" << wearable->getName()
-				<< " itemID " << wearable->getItemID().asString() << llendl;
+		LL_WARNS() << "wearable inventory item not found" << wearable->getName()
+				<< " itemID " << wearable->getItemID().asString() << LL_ENDL;
 	}
 }
 
 void LLAgentWearables::dump()
 {
-	llinfos << "LLAgentWearablesDump" << llendl;
+	LL_INFOS() << "LLAgentWearablesDump" << LL_ENDL;
 	for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
 	{
 		U32 count = getWearableCount((LLWearableType::EType)i);
-		llinfos << "Type: " << i << " count " << count << llendl;
+		LL_INFOS() << "Type: " << i << " count " << count << LL_ENDL;
 		for (U32 j=0; j<count; j++)
 		{
 			LLViewerWearable* wearable = getViewerWearable((LLWearableType::EType)i,j);
 			if (wearable == NULL)
 			{
-				llinfos << "    " << j << " NULL wearable" << llendl;
+				LL_INFOS() << "    " << j << " NULL wearable" << LL_ENDL;
 			}
-			llinfos << "    " << j << " Name " << wearable->getName()
-					<< " description " << wearable->getDescription() << llendl;
+			LL_INFOS() << "    " << j << " Name " << wearable->getName()
+					<< " description " << wearable->getDescription() << LL_ENDL;
 			
 		}
 	}
-	llinfos << "Total items awaiting wearable update " << mItemsAwaitingWearableUpdate.size() << llendl;
+	LL_INFOS() << "Total items awaiting wearable update " << mItemsAwaitingWearableUpdate.size() << LL_ENDL;
 	for (std::set<LLUUID>::iterator it = mItemsAwaitingWearableUpdate.begin();
 		 it != mItemsAwaitingWearableUpdate.end();
 		 ++it)
 	{
-		llinfos << (*it).asString() << llendl;
+		LL_INFOS() << (*it).asString() << LL_ENDL;
 	}
 }
 
@@ -141,15 +141,15 @@ struct LLAgentDumper
 	LLAgentDumper(std::string name):
 		mName(name)
 	{
-		llinfos << llendl;
-		llinfos << "LLAgentDumper " << mName << llendl;
+		LL_INFOS() << LL_ENDL;
+		LL_INFOS() << "LLAgentDumper " << mName << LL_ENDL;
 		gAgentWearables.dump();
 	}
 
 	~LLAgentDumper()
 	{
-		llinfos << llendl;
-		llinfos << "~LLAgentDumper " << mName << llendl;
+		LL_INFOS() << LL_ENDL;
+		LL_INFOS() << "~LLAgentDumper " << mName << LL_ENDL;
 		gAgentWearables.dump();
 	}
 
@@ -191,7 +191,7 @@ void LLAgentWearables::setAvatarObject(LLVOAvatarSelf *avatar)
 // wearables
 LLAgentWearables::createStandardWearablesAllDoneCallback::~createStandardWearablesAllDoneCallback()
 {
-	llinfos << "destructor - all done?" << llendl;
+	LL_INFOS() << "destructor - all done?" << LL_ENDL;
 	gAgentWearables.createStandardWearablesAllDone();
 }
 
@@ -219,14 +219,14 @@ LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInvento
 	mCB(cb),
 	mDescription(description)
 {
-	llinfos << "constructor" << llendl;
+	LL_INFOS() << "constructor" << LL_ENDL;
 }
 
 void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& inv_item)
 {
 	if (mTodo & CALL_CREATESTANDARDDONE)
 	{
-		llinfos << "callback fired, inv_item " << inv_item.asString() << llendl;
+		LL_INFOS() << "callback fired, inv_item " << inv_item.asString() << LL_ENDL;
 	}
 
 	if (inv_item.isNull())
@@ -266,7 +266,7 @@ void LLAgentWearables::addWearabletoAgentInventoryDone(const LLWearableType::ETy
 													   const LLUUID& item_id,
 													   LLViewerWearable* wearable)
 {
-	llinfos << "type " << type << " index " << index << " item " << item_id.asString() << llendl;
+	LL_INFOS() << "type " << type << " index " << index << " item " << item_id.asString() << LL_ENDL;
 
 	if (item_id.isNull())
 		return;
@@ -344,7 +344,7 @@ void LLAgentWearables::sendAgentWearablesUpdate()
 	gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 	gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
 
-	lldebugs << "sendAgentWearablesUpdate()" << llendl;
+	LL_DEBUGS() << "sendAgentWearablesUpdate()" << LL_ENDL;
 	// MULTI-WEARABLE: DEPRECATED: HACK: index to 0- server database tables don't support concept of multiwearables.
 	for (S32 type=0; type < LLWearableType::WT_COUNT; ++type)
 	{
@@ -356,7 +356,7 @@ void LLAgentWearables::sendAgentWearablesUpdate()
 		LLViewerWearable* wearable = getViewerWearable((LLWearableType::EType)type, 0);
 		if (wearable)
 		{
-			//llinfos << "Sending wearable " << wearable->getName() << llendl;
+			//LL_INFOS() << "Sending wearable " << wearable->getName() << LL_ENDL;
 			LLUUID item_id = wearable->getItemID();
 			const LLViewerInventoryItem *item = gInventory.getItem(item_id);
 			if (item && item->getIsLinkType())
@@ -369,11 +369,11 @@ void LLAgentWearables::sendAgentWearablesUpdate()
 		}
 		else
 		{
-			//llinfos << "Not wearing wearable type " << LLWearableType::getTypeName((LLWearableType::EType)i) << llendl;
+			//LL_INFOS() << "Not wearing wearable type " << LLWearableType::getTypeName((LLWearableType::EType)i) << LL_ENDL;
 			gMessageSystem->addUUIDFast(_PREHASH_ItemID, LLUUID::null);
 		}
 
-		lldebugs << "       " << LLWearableType::getTypeLabel((LLWearableType::EType)type) << ": " << (wearable ? wearable->getAssetID() : LLUUID::null) << llendl;
+		LL_DEBUGS() << "       " << LLWearableType::getTypeLabel((LLWearableType::EType)type) << ": " << (wearable ? wearable->getAssetID() : LLUUID::null) << LL_ENDL;
 	}
 	gAgent.sendReliableMessage();
 }
@@ -402,7 +402,7 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32
 			std::string item_name = item->getName();
 			if (name_changed)
 			{
-				llinfos << "saveWearable changing name from "  << item->getName() << " to " << new_name << llendl;
+				LL_INFOS() << "saveWearable changing name from "  << item->getName() << " to " << new_name << LL_ENDL;
 				item_name = new_name;
 			}
 			// Update existing inventory item
@@ -462,20 +462,20 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
 {
 	if (!isWearableCopyable(type, index))
 	{
-		llwarns << "LLAgent::saveWearableAs() not copyable." << llendl;
+		LL_WARNS() << "LLAgent::saveWearableAs() not copyable." << LL_ENDL;
 		return;
 	}
 	LLViewerWearable* old_wearable = getViewerWearable(type, index);
 	if (!old_wearable)
 	{
-		llwarns << "LLAgent::saveWearableAs() no old wearable." << llendl;
+		LL_WARNS() << "LLAgent::saveWearableAs() no old wearable." << LL_ENDL;
 		return;
 	}
 
 	LLInventoryItem* item = gInventory.getItem(getWearableItemID(type,index));
 	if (!item)
 	{
-		llwarns << "LLAgent::saveWearableAs() no inventory item." << llendl;
+		LL_WARNS() << "LLAgent::saveWearableAs() no inventory item." << LL_ENDL;
 		return;
 	}
 	std::string trunc_name(new_name);
@@ -742,7 +742,7 @@ void LLAgentWearables::wearableUpdated(LLWearable *wearable, BOOL removed)
 		{
 			wearable->setDefinitionVersion(22);
 			U32 index = getWearableIndex(wearable);
-			llinfos << "forcing wearable type " << wearable->getType() << " to version 22 from 24" << llendl;
+			LL_INFOS() << "forcing wearable type " << wearable->getType() << " to version 22 from 24" << LL_ENDL;
 			saveWearable(wearable->getType(),index,TRUE);
 		}
 
@@ -831,7 +831,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
 		const LLUUID current_outfit_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT);
 		LLInitialWearablesFetch* outfit = new LLInitialWearablesFetch(current_outfit_id);
 		
-		//lldebugs << "processAgentInitialWearablesUpdate()" << llendl;
+		//LL_DEBUGS() << "processAgentInitialWearablesUpdate()" << LL_ENDL;
 		// Add wearables
 		// MULTI-WEARABLE: DEPRECATED: Message only supports one wearable per type, will be ignored in future.
 		gAgentWearables.mItemsAwaitingWearableUpdate.clear();
@@ -870,7 +870,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgs
 				outfit->add(wearable_data);
 			}
 			
-			lldebugs << "       " << LLWearableType::getTypeLabel(type) << llendl;
+			LL_DEBUGS() << "       " << LLWearableType::getTypeLabel(type) << LL_ENDL;
 		}
 		
 		// Get the complete information on the items in the inventory and set up an observer
@@ -898,7 +898,7 @@ void LLAgentWearables::recoverMissingWearable(const LLWearableType::EType type,
 {
 	// Try to recover by replacing missing wearable with a new one.
 	LLNotificationsUtil::add("ReplacedMissingWearable");
-	lldebugs << "Wearable " << LLWearableType::getTypeLabel(type) << " could not be downloaded.  Replaced inventory item with default wearable." << llendl;
+	LL_DEBUGS() << "Wearable " << LLWearableType::getTypeLabel(type) << " could not be downloaded.  Replaced inventory item with default wearable." << LL_ENDL;
 	LLViewerWearable* new_wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp);
 
 	setWearable(type,index,new_wearable);
@@ -939,7 +939,7 @@ void LLAgentWearables::addLocalTextureObject(const LLWearableType::EType wearabl
 	LLViewerWearable* wearable = getViewerWearable((LLWearableType::EType)wearable_type, wearable_index);
 	if (!wearable)
 	{
-		llerrs << "Tried to add local texture object to invalid wearable with type " << wearable_type << " and index " << wearable_index << llendl;
+		LL_ERRS() << "Tried to add local texture object to invalid wearable with type " << wearable_type << " and index " << wearable_index << LL_ENDL;
 		return;
 	}
 	LLLocalTextureObject lto;
@@ -952,18 +952,18 @@ public:
 	OnWearableItemCreatedCB():
 		mWearablesAwaitingItems(LLWearableType::WT_COUNT,NULL)
 	{
-		llinfos << "created callback" << llendl;
+		LL_INFOS() << "created callback" << LL_ENDL;
 	}
 	/* virtual */ void fire(const LLUUID& inv_item)
 	{
-		llinfos << "One item created " << inv_item.asString() << llendl;
+		LL_INFOS() << "One item created " << inv_item.asString() << LL_ENDL;
 		LLViewerInventoryItem *item = gInventory.getItem(inv_item);
 		mItemsToLink.push_back(item);
 		updatePendingWearable(inv_item);
 	}
 	~OnWearableItemCreatedCB()
 	{
-		llinfos << "All items created" << llendl;
+		LL_INFOS() << "All items created" << LL_ENDL;
 		LLPointer<LLInventoryCallback> link_waiter = new LLUpdateAppearanceOnDestroy;
 		LLAppearanceMgr::instance().linkAll(LLAppearanceMgr::instance().getCOF(),
 											mItemsToLink,
@@ -973,7 +973,7 @@ public:
 	{
 		if (!wearable)
 		{
-			llwarns << "no wearable" << llendl;
+			LL_WARNS() << "no wearable" << LL_ENDL;
 			return;
 		}
 		LLWearableType::EType type = wearable->getType();
@@ -983,7 +983,7 @@ public:
 		}
 		else
 		{
-			llwarns << "invalid type " << type << llendl;
+			LL_WARNS() << "invalid type " << type << LL_ENDL;
 		}
 	}
 	void updatePendingWearable(const LLUUID& inv_item)
@@ -991,12 +991,12 @@ public:
 		LLViewerInventoryItem *item = gInventory.getItem(inv_item);
 		if (!item)
 		{
-			llwarns << "no item found" << llendl;
+			LL_WARNS() << "no item found" << LL_ENDL;
 			return;
 		}
 		if (!item->isWearableType())
 		{
-			llwarns << "non-wearable item found" << llendl;
+			LL_WARNS() << "non-wearable item found" << LL_ENDL;
 			return;
 		}
 		if (item && item->isWearableType())
@@ -1010,7 +1010,7 @@ public:
 			}
 			else
 			{
-				llwarns << "invalid wearable type " << type << llendl;
+				LL_WARNS() << "invalid wearable type " << type << LL_ENDL;
 			}
 		}
 	}
@@ -1022,7 +1022,7 @@ private:
 
 void LLAgentWearables::createStandardWearables()
 {
-	llwarns << "Creating standard wearables" << llendl;
+	LL_WARNS() << "Creating standard wearables" << LL_ENDL;
 
 	if (!isAgentAvatarValid()) return;
 
@@ -1070,7 +1070,7 @@ void LLAgentWearables::createStandardWearables()
 
 void LLAgentWearables::createStandardWearablesDone(S32 type, U32 index)
 {
-	llinfos << "type " << type << " index " << index << llendl;
+	LL_INFOS() << "type " << type << " index " << index << LL_ENDL;
 
 	if (!isAgentAvatarValid()) return;
 	gAgentAvatarp->updateVisualParams();
@@ -1080,7 +1080,7 @@ void LLAgentWearables::createStandardWearablesAllDone()
 {
 	// ... because sendAgentWearablesUpdate will notify inventory
 	// observers.
-	llinfos << "all done?" << llendl;
+	LL_INFOS() << "all done?" << LL_ENDL;
 
 	mWearablesLoaded = TRUE; 
 	checkWearablesLoaded();
@@ -1238,7 +1238,7 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
 										 const std::vector< LLViewerWearable* >& wearables,
 										 BOOL remove)
 {
-	llinfos << "setWearableOutfit() start" << llendl;
+	LL_INFOS() << "setWearableOutfit() start" << LL_ENDL;
 
 	// TODO: Removed check for ensuring that teens don't remove undershirt and underwear. Handle later
 	if (remove)
@@ -1312,7 +1312,7 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
 
 	gAgentAvatarp->dumpAvatarTEs("setWearableOutfit");
 
-	lldebugs << "setWearableOutfit() end" << llendl;
+	LL_DEBUGS() << "setWearableOutfit() end" << LL_ENDL;
 }
 
 
@@ -1322,7 +1322,7 @@ void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLViewerWearab
 	//LLAgentDumper dumper("setWearableItem");
 	if (isWearingItem(new_item->getUUID()))
 	{
-		llwarns << "wearable " << new_item->getUUID() << " is already worn" << llendl;
+		LL_WARNS() << "wearable " << new_item->getUUID() << " is already worn" << LL_ENDL;
 		return;
 	}
 	
@@ -1339,7 +1339,7 @@ void LLAgentWearables::setWearableItem(LLInventoryItem* new_item, LLViewerWearab
 			if ((old_wearable->getAssetID() == new_wearable->getAssetID()) &&
 				(old_item_id == new_item->getUUID()))
 			{
-				lldebugs << "No change to wearable asset and item: " << LLWearableType::getTypeName(type) << llendl;
+				LL_DEBUGS() << "No change to wearable asset and item: " << LLWearableType::getTypeName(type) << LL_ENDL;
 				return;
 			}
 			
@@ -1403,8 +1403,8 @@ void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLViewerWeara
 		new_wearable->setItemID(new_item->getUUID());
 		const bool trigger_updated = false;
 		pushWearable(type, new_wearable, trigger_updated);
-		llinfos << "Added additional wearable for type " << type
-				<< " size is now " << getWearableCount(type) << llendl;
+		LL_INFOS() << "Added additional wearable for type " << type
+				<< " size is now " << getWearableCount(type) << LL_ENDL;
 		checkWearableAgainstInventory(new_wearable);
 	}
 	else
@@ -1426,11 +1426,11 @@ void LLAgentWearables::setWearableFinal(LLInventoryItem* new_item, LLViewerWeara
 			gInventory.addChangedMask(LLInventoryObserver::LABEL, old_item_id);
 			gInventory.notifyObservers();
 		}
-		llinfos << "Replaced current element 0 for type " << type
-				<< " size is now " << getWearableCount(type) << llendl;
+		LL_INFOS() << "Replaced current element 0 for type " << type
+				<< " size is now " << getWearableCount(type) << LL_ENDL;
 	}
 
-	//llinfos << "LLVOAvatar::setWearableItem()" << llendl;
+	//LL_INFOS() << "LLVOAvatar::setWearableItem()" << LL_ENDL;
 	queryWearableCache();
 	//new_wearable->writeToAvatar(TRUE);
 
@@ -1470,7 +1470,7 @@ void LLAgentWearables::queryWearableCache()
 
 			ETextureIndex te_index = LLAvatarAppearanceDictionary::bakedToLocalTextureIndex((EBakedTextureIndex)baked_index);
 
-			//llinfos << "Requesting texture for hash " << hash << " in baked texture slot " << baked_index << llendl;
+			//LL_INFOS() << "Requesting texture for hash " << hash << " in baked texture slot " << baked_index << LL_ENDL;
 			gMessageSystem->nextBlockFast(_PREHASH_WearableData);
 			gMessageSystem->addUUIDFast(_PREHASH_ID, hash_id);
 			gMessageSystem->addU8Fast(_PREHASH_TextureIndex, (U8)te_index);
@@ -1589,7 +1589,7 @@ void LLAgentWearables::userUpdateAttachments(LLInventoryModel::item_array_t& obj
 	}
 	// S32 remove_count = objects_to_remove.size();
 	// S32 add_count = items_to_add.size();
-	// llinfos << "remove " << remove_count << " add " << add_count << llendl;
+	// LL_INFOS() << "remove " << remove_count << " add " << add_count << LL_ENDL;
 
 	// Remove everything in objects_to_remove
 	userRemoveMultipleAttachments(objects_to_remove);
@@ -1816,20 +1816,20 @@ void LLAgentWearables::editWearable(const LLUUID& item_id)
 	LLViewerInventoryItem* item = gInventory.getLinkedItem(item_id);
 	if (!item)
 	{
-		llwarns << "Failed to get linked item" << llendl;
+		LL_WARNS() << "Failed to get linked item" << LL_ENDL;
 		return;
 	}
 
 	LLViewerWearable* wearable = gAgentWearables.getWearableFromItemID(item_id);
 	if (!wearable)
 	{
-		llwarns << "Cannot get wearable" << llendl;
+		LL_WARNS() << "Cannot get wearable" << LL_ENDL;
 		return;
 	}
 
 	if (!gAgentWearables.isWearableModifiable(item->getUUID()))
 	{
-		llwarns << "Cannot modify wearable" << llendl;
+		LL_WARNS() << "Cannot modify wearable" << LL_ENDL;
 		return;
 	}
 
@@ -1863,7 +1863,7 @@ void LLAgentWearables::updateServer()
 
 void LLAgentWearables::populateMyOutfitsFolder(void)
 {	
-	llinfos << "starting outfit population" << llendl;
+	LL_INFOS() << "starting outfit population" << LL_ENDL;
 
 	const LLUUID& my_outfits_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS);
 	LLLibraryOutfitsFetch* outfits = new LLLibraryOutfitsFetch(my_outfits_id);
diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp
index 4a8d122dd8..af0f02861d 100755
--- a/indra/newview/llagentwearablesfetch.cpp
+++ b/indra/newview/llagentwearablesfetch.cpp
@@ -39,7 +39,7 @@ void order_my_outfits_cb()
 	{
 		if (!LLApp::isRunning())
 		{
-			llwarns << "called during shutdown, skipping" << llendl;
+			LL_WARNS() << "called during shutdown, skipping" << LL_ENDL;
 			return;
 		}
 		
@@ -58,7 +58,7 @@ void order_my_outfits_cb()
 			return;
 		}
 
-		llinfos << "Starting updating My Outfits with wearables ordering information" << llendl;
+		LL_INFOS() << "Starting updating My Outfits with wearables ordering information" << LL_ENDL;
 
 		for (LLInventoryModel::cat_array_t::iterator outfit_iter = cats->begin();
 			outfit_iter != cats->end(); ++outfit_iter)
@@ -72,7 +72,7 @@ void order_my_outfits_cb()
 			LLAppearanceMgr::getInstance()->updateClothingOrderingInfo(cat_id);
 		}
 
-		llinfos << "Finished updating My Outfits with wearables ordering information" << llendl;
+		LL_INFOS() << "Finished updating My Outfits with wearables ordering information" << LL_ENDL;
 	}
 
 LLInitialWearablesFetch::LLInitialWearablesFetch(const LLUUID& cof_id) :
@@ -165,7 +165,7 @@ public:
 			LLViewerInventoryItem *item = gInventory.getItem(*it);
 			if (!item)
 			{
-				llwarns << "fetch failed!" << llendl;
+				LL_WARNS() << "fetch failed!" << LL_ENDL;
 				continue;
 			}
 
@@ -197,8 +197,8 @@ void LLInitialWearablesFetch::processWearablesMessage()
 			}
 			else
 			{
-				llinfos << "Invalid wearable, type " << wearable_data->mType << " itemID "
-				<< wearable_data->mItemID << " assetID " << wearable_data->mAssetID << llendl;
+				LL_INFOS() << "Invalid wearable, type " << wearable_data->mType << " itemID "
+				<< wearable_data->mItemID << " assetID " << wearable_data->mAssetID << LL_ENDL;
 				delete wearable_data;
 			}
 		}
@@ -249,7 +249,7 @@ LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const LLUUID& my_outfits_id) :
 	mCurrFetchStep(LOFS_FOLDER), 
 	mOutfitsPopulated(false) 
 {
-	llinfos << "created" << llendl;
+	LL_INFOS() << "created" << LL_ENDL;
 
 	mMyOutfitsID = LLUUID::null;
 	mClothingID = LLUUID::null;
@@ -260,12 +260,12 @@ LLLibraryOutfitsFetch::LLLibraryOutfitsFetch(const LLUUID& my_outfits_id) :
 
 LLLibraryOutfitsFetch::~LLLibraryOutfitsFetch()
 {
-	llinfos << "destroyed" << llendl;
+	LL_INFOS() << "destroyed" << LL_ENDL;
 }
 
 void LLLibraryOutfitsFetch::done()
 {
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	// Delay this until idle() routine, since it's a heavy operation and
 	// we also can't have it run within notifyObservers.
@@ -275,7 +275,7 @@ void LLLibraryOutfitsFetch::done()
 
 void LLLibraryOutfitsFetch::doneIdle()
 {
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	gInventory.addObserver(this); // Add this back in since it was taken out during ::done()
 	
@@ -301,7 +301,7 @@ void LLLibraryOutfitsFetch::doneIdle()
 			contentsDone();
 			break;
 		default:
-			llwarns << "Got invalid state for outfit fetch: " << mCurrFetchStep << llendl;
+			LL_WARNS() << "Got invalid state for outfit fetch: " << mCurrFetchStep << LL_ENDL;
 			mOutfitsPopulated = TRUE;
 			break;
 	}
@@ -317,7 +317,7 @@ void LLLibraryOutfitsFetch::doneIdle()
 
 void LLLibraryOutfitsFetch::folderDone()
 {
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	LLInventoryModel::cat_array_t cat_array;
 	LLInventoryModel::item_array_t wearable_array;
@@ -364,7 +364,7 @@ void LLLibraryOutfitsFetch::folderDone()
 
 void LLLibraryOutfitsFetch::outfitsDone()
 {
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	LLInventoryModel::cat_array_t cat_array;
 	LLInventoryModel::item_array_t wearable_array;
@@ -443,7 +443,7 @@ private:
 // Copy the clothing folders from the library into the imported clothing folder
 void LLLibraryOutfitsFetch::libraryDone()
 {
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	if (mImportedClothingID != LLUUID::null)
 	{
@@ -468,13 +468,13 @@ void LLLibraryOutfitsFetch::libraryDone()
 		const LLViewerInventoryCategory *cat = gInventory.getCategory(src_folder_id);
 		if (!cat)
 		{
-			llwarns << "Library folder import for uuid:" << src_folder_id << " failed to find folder." << llendl;
+			LL_WARNS() << "Library folder import for uuid:" << src_folder_id << " failed to find folder." << LL_ENDL;
 			continue;
 		}
 		
 		if (!LLAppearanceMgr::getInstance()->getCanMakeFolderIntoOutfit(src_folder_id))
 		{
-			llinfos << "Skipping non-outfit folder name:" << cat->getName() << llendl;
+			LL_INFOS() << "Skipping non-outfit folder name:" << cat->getName() << LL_ENDL;
 			continue;
 		}
 		
@@ -500,7 +500,7 @@ void LLLibraryOutfitsFetch::libraryDone()
 
 void LLLibraryOutfitsFetch::importedFolderFetch()
 {
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	// Fetch the contents of the Imported Clothing Folder
 	uuid_vec_t folders;
@@ -517,7 +517,7 @@ void LLLibraryOutfitsFetch::importedFolderFetch()
 
 void LLLibraryOutfitsFetch::importedFolderDone()
 {
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	LLInventoryModel::cat_array_t cat_array;
 	LLInventoryModel::item_array_t wearable_array;
@@ -549,7 +549,7 @@ void LLLibraryOutfitsFetch::importedFolderDone()
 
 void LLLibraryOutfitsFetch::contentsDone()
 {		
-	llinfos << "start" << llendl;
+	LL_INFOS() << "start" << LL_ENDL;
 
 	LLInventoryModel::cat_array_t cat_array;
 	LLInventoryModel::item_array_t wearable_array;
@@ -564,7 +564,7 @@ void LLLibraryOutfitsFetch::contentsDone()
 		const LLViewerInventoryCategory *cat = gInventory.getCategory(folder_id);
 		if (!cat)
 		{
-			llwarns << "Library folder import for uuid:" << folder_id << " failed to find folder." << llendl;
+			LL_WARNS() << "Library folder import for uuid:" << folder_id << " failed to find folder." << LL_ENDL;
 			continue;
 		}
 
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index a18448da6e..435fe9a32b 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -157,7 +157,7 @@ LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string
 			return cat->getUUID();
 		else
 		{
-			llwarns << "null cat" << llendl;
+			LL_WARNS() << "null cat" << LL_ENDL;
 			return LLUUID();
 		}
 	}
@@ -216,11 +216,11 @@ public:
 	// Request or re-request operation for specified item.
 	void addItem(const LLUUID& item_id)
 	{
-		LL_DEBUGS("Avatar") << "item_id " << item_id << llendl;
+		LL_DEBUGS("Avatar") << "item_id " << item_id << LL_ENDL;
 
 		if (!requestOperation(item_id))
 		{
-			LL_DEBUGS("Avatar") << "item_id " << item_id << " requestOperation false, skipping" << llendl;
+			LL_DEBUGS("Avatar") << "item_id " << item_id << " requestOperation false, skipping" << LL_ENDL;
 			return;
 	}
 
@@ -243,20 +243,20 @@ public:
 	{
 		if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateLateOpRate"))
 	{
-			llwarns << "Simulating late operation by punting handling to later" << llendl;
+			LL_WARNS() << "Simulating late operation by punting handling to later" << LL_ENDL;
 			doAfterInterval(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,src_id,dst_id,timestamp),
 							mRetryAfter);
 			return;
 		}
 		mPendingRequests--;
 		F32 elapsed = timestamp.getElapsedTimeF32();
-		LL_DEBUGS("Avatar") << "op done, src_id " << src_id << " dst_id " << dst_id << " after " << elapsed << " seconds" << llendl;
+		LL_DEBUGS("Avatar") << "op done, src_id " << src_id << " dst_id " << dst_id << " after " << elapsed << " seconds" << LL_ENDL;
 		if (mWaitTimes.find(src_id) == mWaitTimes.end())
 		{
 			// No longer waiting for this item - either serviced
 			// already or gave up after too many retries.
-			llwarns << "duplicate or late operation, src_id " << src_id << "dst_id " << dst_id
-					<< " elapsed " << elapsed << " after end " << (S32) mCompletionOrFailureCalled << llendl;
+			LL_WARNS() << "duplicate or late operation, src_id " << src_id << "dst_id " << dst_id
+					<< " elapsed " << elapsed << " after end " << (S32) mCompletionOrFailureCalled << LL_ENDL;
 		}
 		mTimeStats.push(elapsed);
 		mWaitTimes.erase(src_id);
@@ -291,13 +291,13 @@ public:
 		
 	void onFailure()
 	{
-		llinfos << "failed" << llendl;
+		LL_INFOS() << "failed" << LL_ENDL;
 		mOnFailureFunc();
 	}
 
 	void onCompletion()
 	{
-		llinfos << "done" << llendl;
+		LL_INFOS() << "done" << LL_ENDL;
 		mOnCompletionFunc();
 	}
 
@@ -316,7 +316,7 @@ public:
 		
 		if (!mWaitTimes.empty())
 		{
-			llwarns << "still waiting on " << mWaitTimes.size() << " items" << llendl;
+			LL_WARNS() << "still waiting on " << mWaitTimes.size() << " items" << LL_ENDL;
 			for (std::map<LLUUID,LLTimer>::iterator it = mWaitTimes.begin();
 				 it != mWaitTimes.end();)
 			{
@@ -331,13 +331,13 @@ public:
 					if (retries < mMaxRetries)
 		{
 						LL_DEBUGS("Avatar") << "Waited " << time_waited <<
-							" for " << curr_it->first << ", retrying" << llendl;
+							" for " << curr_it->first << ", retrying" << LL_ENDL;
 						mRetryCount++;
 						addItem(curr_it->first);
 		}
 		else
 		{
-						llwarns << "Giving up on " << curr_it->first << " after too many retries" << llendl;
+						LL_WARNS() << "Giving up on " << curr_it->first << " after too many retries" << LL_ENDL;
 						mWaitTimes.erase(curr_it);
 						mFailCount++;
 					}
@@ -354,16 +354,16 @@ public:
 
 	void reportStats()
 	{
-		LL_DEBUGS("Avatar") << "Phase: " << mTrackingPhase << llendl;
-		LL_DEBUGS("Avatar") << "mFailCount: " << mFailCount << llendl;
-		LL_DEBUGS("Avatar") << "mRetryCount: " << mRetryCount << llendl;
-		LL_DEBUGS("Avatar") << "Times: n " << mTimeStats.getCount() << " min " << mTimeStats.getMinValue() << " max " << mTimeStats.getMaxValue() << llendl;
-		LL_DEBUGS("Avatar") << "Mean " << mTimeStats.getMean() << " stddev " << mTimeStats.getStdDev() << llendl;
+		LL_DEBUGS("Avatar") << "Phase: " << mTrackingPhase << LL_ENDL;
+		LL_DEBUGS("Avatar") << "mFailCount: " << mFailCount << LL_ENDL;
+		LL_DEBUGS("Avatar") << "mRetryCount: " << mRetryCount << LL_ENDL;
+		LL_DEBUGS("Avatar") << "Times: n " << mTimeStats.getCount() << " min " << mTimeStats.getMinValue() << " max " << mTimeStats.getMaxValue() << LL_ENDL;
+		LL_DEBUGS("Avatar") << "Mean " << mTimeStats.getMean() << " stddev " << mTimeStats.getStdDev() << LL_ENDL;
 	}
 
 	virtual ~LLCallAfterInventoryBatchMgr()
 	{
-		LL_DEBUGS("Avatar") << "deleting" << llendl;
+		LL_DEBUGS("Avatar") << "deleting" << LL_ENDL;
 	}
 
 protected:
@@ -402,10 +402,10 @@ public:
 		{
 		LLViewerInventoryItem *item = gInventory.getItem(item_id);
 		llassert(item);
-		LL_DEBUGS("Avatar") << "copying item " << item_id << llendl;
+		LL_DEBUGS("Avatar") << "copying item " << item_id << LL_ENDL;
 		if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate"))
 		{
-			LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << llendl;
+			LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << LL_ENDL;
 			return true;
 		}
 		copy_inventory_item(
@@ -444,14 +444,14 @@ public:
 		{
 			if (item->getParentUUID() == mDstCatID)
 			{
-				LL_DEBUGS("Avatar") << "item " << item_id << " name " << item->getName() << " is already a child of " << mDstCatID << llendl;
+				LL_DEBUGS("Avatar") << "item " << item_id << " name " << item->getName() << " is already a child of " << mDstCatID << LL_ENDL;
 				return false;
 			}
-			LL_DEBUGS("Avatar") << "linking item " << item_id << " name " << item->getName() << " to " << mDstCatID << llendl;
+			LL_DEBUGS("Avatar") << "linking item " << item_id << " name " << item->getName() << " to " << mDstCatID << LL_ENDL;
 			// create an inventory item link.
 			if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate"))
 			{
-				LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << llendl;
+				LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << LL_ENDL;
 				return true;
 			}
 			link_inventory_item(gAgent.getID(),
@@ -470,7 +470,7 @@ public:
 			LLViewerInventoryCategory *catp = gInventory.getCategory(item_id);
 			if (!catp)
 			{
-				llwarns << "link request failed, id not found as inventory item or category " << item_id << llendl;
+				LL_WARNS() << "link request failed, id not found as inventory item or category " << item_id << LL_ENDL;
 				return false;
 			}
 			const LLUUID cof = LLAppearanceMgr::instance().getCOF();
@@ -482,10 +482,10 @@ public:
 	{
 				if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate"))
 		{
-					LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << llendl;
+					LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << LL_ENDL;
 					return true;
 				}
-				LL_DEBUGS("Avatar") << "linking folder " << item_id << " name " << catp->getName() << " to cof " << cof << llendl;
+				LL_DEBUGS("Avatar") << "linking folder " << item_id << " name " << catp->getName() << " to cof " << cof << LL_ENDL;
 				link_inventory_item(gAgent.getID(), item_id, cof, catp->getName(), "",
 									LLAssetType::AT_LINK_FOLDER, 
 									new LLBoostFuncInventoryCallback(
@@ -621,11 +621,11 @@ LLWearableHoldingPattern::LLWearableHoldingPattern():
 {
 	if (sActiveHoldingPatterns.size()>0)
 	{
-		llinfos << "Creating LLWearableHoldingPattern when "
+		LL_INFOS() << "Creating LLWearableHoldingPattern when "
 				<< sActiveHoldingPatterns.size()
 				<< " other attempts are active."
 				<< " Flagging others as invalid."
-				<< llendl;
+				<< LL_ENDL;
 		for (type_set_hp::iterator it = sActiveHoldingPatterns.begin();
 			 it != sActiveHoldingPatterns.end();
 			 ++it)
@@ -692,7 +692,7 @@ void LLWearableHoldingPattern::checkMissingWearables()
 	if (!isMostRecent())
 	{
 		// runway why don't we actually skip here?
-		llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+		LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 	}
 
 	std::vector<S32> found_by_type(LLWearableType::WT_COUNT,0);
@@ -710,7 +710,7 @@ void LLWearableHoldingPattern::checkMissingWearables()
 	{
 		if (requested_by_type[type] > found_by_type[type])
 		{
-			llwarns << self_av_string() << "got fewer wearables than requested, type " << type << ": requested " << requested_by_type[type] << ", found " << found_by_type[type] << llendl;
+			LL_WARNS() << self_av_string() << "got fewer wearables than requested, type " << type << ": requested " << requested_by_type[type] << ", found " << found_by_type[type] << LL_ENDL;
 		}
 		if (found_by_type[type] > 0)
 			continue;
@@ -727,7 +727,7 @@ void LLWearableHoldingPattern::checkMissingWearables()
 			mTypesToRecover.insert(type);
 			mTypesToLink.insert(type);
 			recoverMissingWearable((LLWearableType::EType)type);
-			llwarns << self_av_string() << "need to replace " << type << llendl; 
+			LL_WARNS() << self_av_string() << "need to replace " << type << LL_ENDL; 
 		}
 	}
 
@@ -750,7 +750,7 @@ void LLWearableHoldingPattern::onAllComplete()
 	if (!isMostRecent())
 	{
 		// runway need to skip here?
-		llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+		LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 	}
 
 	// Activate all gestures in this folder
@@ -802,7 +802,7 @@ void LLWearableHoldingPattern::onFetchCompletion()
 	if (!isMostRecent())
 	{
 		// runway skip here?
-		llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+		LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 	}
 
 	checkMissingWearables();
@@ -814,7 +814,7 @@ bool LLWearableHoldingPattern::pollFetchCompletion()
 	if (!isMostRecent())
 	{
 		// runway skip here?
-		llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+		LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 	}
 
 	bool completed = isFetchCompleted();
@@ -830,7 +830,7 @@ bool LLWearableHoldingPattern::pollFetchCompletion()
 		
 		if (timed_out)
 		{
-			llwarns << self_av_string() << "Exceeded max wait time for wearables, updating appearance based on what has arrived" << llendl;
+			LL_WARNS() << self_av_string() << "Exceeded max wait time for wearables, updating appearance based on what has arrived" << LL_ENDL;
 		}
 
 		onFetchCompletion();
@@ -842,11 +842,11 @@ void recovered_item_link_cb(const LLUUID& item_id, LLWearableType::EType type, L
 {
 	if (!holder->isMostRecent())
 		{
-			llwarns << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+			LL_WARNS() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 			// runway skip here?
 		}
 
-	llinfos << "Recovered item link for type " << type << llendl;
+	LL_INFOS() << "Recovered item link for type " << type << LL_ENDL;
 	holder->eraseTypeToLink(type);
 		// Add wearable to FoundData for actual wearing
 		LLViewerInventoryItem *item = gInventory.getItem(item_id);
@@ -870,12 +870,12 @@ void recovered_item_link_cb(const LLUUID& item_id, LLWearableType::EType type, L
 			}
 			else
 			{
-				llwarns << self_av_string() << "inventory item not found for recovered wearable" << llendl;
+				LL_WARNS() << self_av_string() << "inventory item not found for recovered wearable" << LL_ENDL;
 			}
 		}
 		else
 		{
-			llwarns << self_av_string() << "inventory link not found for recovered wearable" << llendl;
+			LL_WARNS() << self_av_string() << "inventory link not found for recovered wearable" << LL_ENDL;
 		}
 	}
 
@@ -884,7 +884,7 @@ void recovered_item_cb(const LLUUID& item_id, LLWearableType::EType type, LLView
 	if (!holder->isMostRecent())
 		{
 			// runway skip here?
-			llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+			LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 		}
 
 	LL_DEBUGS("Avatar") << self_av_string() << "Recovered item for type " << type << LL_ENDL;
@@ -910,13 +910,13 @@ void LLWearableHoldingPattern::recoverMissingWearable(LLWearableType::EType type
 	if (!isMostRecent())
 	{
 		// runway skip here?
-		llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+		LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 	}
 	
 		// Try to recover by replacing missing wearable with a new one.
 	LLNotificationsUtil::add("ReplacedMissingWearable");
-	lldebugs << "Wearable " << LLWearableType::getTypeLabel(type)
-			 << " could not be downloaded.  Replaced inventory item with default wearable." << llendl;
+	LL_DEBUGS() << "Wearable " << LLWearableType::getTypeLabel(type)
+			 << " could not be downloaded.  Replaced inventory item with default wearable." << LL_ENDL;
 	LLViewerWearable* wearable = LLWearableList::instance().createNewWearable(type, gAgentAvatarp);
 
 	// Add a new one in the lost and found folder.
@@ -960,7 +960,7 @@ bool LLWearableHoldingPattern::pollMissingWearables()
 	if (!isMostRecent())
 	{
 		// runway skip here?
-		llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+		LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 	}
 	
 	bool timed_out = isTimedOut();
@@ -1009,11 +1009,11 @@ void LLWearableHoldingPattern::handleLateArrivals()
 	}
 	if (!isMostRecent())
 	{
-		llwarns << self_av_string() << "Late arrivals not handled - outfit change no longer valid" << llendl;
+		LL_WARNS() << self_av_string() << "Late arrivals not handled - outfit change no longer valid" << LL_ENDL;
 	}
 	if (!mIsAllComplete)
 	{
-		llwarns << self_av_string() << "Late arrivals not handled - in middle of missing wearables processing" << llendl;
+		LL_WARNS() << self_av_string() << "Late arrivals not handled - in middle of missing wearables processing" << LL_ENDL;
 	}
 
 	LL_INFOS("Avatar") << self_av_string() << "Need to handle " << mLateArrivals.size() << " late arriving wearables" << LL_ENDL;
@@ -1092,19 +1092,19 @@ void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable)
 {
 	if (!isMostRecent())
 	{
-		llwarns << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << llendl;
+		LL_WARNS() << self_av_string() << "skipping because LLWearableHolding pattern is invalid (superceded by later outfit request)" << LL_ENDL;
 	}
 	
 	mResolved += 1;  // just counting callbacks, not successes.
 	LL_DEBUGS("Avatar") << self_av_string() << "resolved " << mResolved << "/" << getFoundList().size() << LL_ENDL;
 	if (!wearable)
 	{
-		llwarns << self_av_string() << "no wearable found" << llendl;
+		LL_WARNS() << self_av_string() << "no wearable found" << LL_ENDL;
 	}
 
 	if (mFired)
 	{
-		llwarns << self_av_string() << "called after holder fired" << llendl;
+		LL_WARNS() << self_av_string() << "called after holder fired" << LL_ENDL;
 		if (wearable)
 		{
 			mLateArrivals.insert(wearable);
@@ -1130,7 +1130,7 @@ void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable)
 			// Failing this means inventory or asset server are corrupted in a way we don't handle.
 			if ((data.mWearableType >= LLWearableType::WT_COUNT) || (wearable->getType() != data.mWearableType))
 			{
-				llwarns << self_av_string() << "recovered wearable but type invalid. inventory wearable type: " << data.mWearableType << " asset wearable type: " << wearable->getType() << llendl;
+				LL_WARNS() << self_av_string() << "recovered wearable but type invalid. inventory wearable type: " << data.mWearableType << " asset wearable type: " << wearable->getType() << LL_ENDL;
 				break;
 			}
 
@@ -1251,7 +1251,7 @@ const LLUUID LLAppearanceMgr::getBaseOutfitUUID()
 
 	if (outfit_cat->getPreferredType() != LLFolderType::FT_OUTFIT)
 	{
-		llwarns << "Expected outfit type:" << LLFolderType::FT_OUTFIT << " but got type:" << outfit_cat->getType() << " for folder name:" << outfit_cat->getName() << llendl;
+		LL_WARNS() << "Expected outfit type:" << LLFolderType::FT_OUTFIT << " but got type:" << outfit_cat->getType() << " for folder name:" << outfit_cat->getName() << LL_ENDL;
 		return LLUUID::null;
 	}
 
@@ -1440,10 +1440,10 @@ void LLAppearanceMgr::shallowCopyCategory(const LLUUID& src_id, const LLUUID& ds
 	LLInventoryCategory *src_cat = gInventory.getCategory(src_id);
 	if (!src_cat)
 	{
-		llwarns << "folder not found for src " << src_id.asString() << llendl;
+		LL_WARNS() << "folder not found for src " << src_id.asString() << LL_ENDL;
 		return;
 	}
-	llinfos << "starting, src_id " << src_id << " name " << src_cat->getName() << " dst_id " << dst_id << llendl;
+	LL_INFOS() << "starting, src_id " << src_id << " name " << src_cat->getName() << " dst_id " << dst_id << LL_ENDL;
 	LLUUID parent_id = dst_id;
 	if(parent_id.isNull())
 	{
@@ -1464,7 +1464,7 @@ void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LL
 	LLInventoryModel::cat_array_t* cats;
 	LLInventoryModel::item_array_t* items;
 	gInventory.getDirectDescendentsOf(src_id, cats, items);
-	llinfos << "copying " << items->size() << " items" << llendl;
+	LL_INFOS() << "copying " << items->size() << " items" << LL_ENDL;
 	for (LLInventoryModel::item_array_t::const_iterator iter = items->begin();
 		 iter != items->end();
 		 ++iter)
@@ -1504,7 +1504,7 @@ void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LL
 			case LLAssetType::AT_BODYPART:
 			case LLAssetType::AT_GESTURE:
 			{
-				llinfos << "copying inventory item " << item->getName() << llendl;
+				LL_INFOS() << "copying inventory item " << item->getName() << LL_ENDL;
 				copy_inventory_item(gAgent.getID(),
 									item->getPermissions().getOwner(),
 									item->getUUID(),
@@ -1676,7 +1676,7 @@ void LLAppearanceMgr::purgeCategory(const LLUUID& category, bool keep_outfit_lin
 #if 0
 			if (keep_items && keep_items->find(item) != LLInventoryModel::item_array_t::FAIL)
 			{
-				llinfos << "preserved item" << llendl;
+				LL_INFOS() << "preserved item" << LL_ENDL;
 			}
 			else
 			{
@@ -1854,7 +1854,7 @@ void LLAppearanceMgr::createBaseOutfitLink(const LLUUID& category, LLPointer<LLI
 
 void LLAppearanceMgr::updateAgentWearables(LLWearableHoldingPattern* holder, bool append)
 {
-	lldebugs << "updateAgentWearables()" << llendl;
+	LL_DEBUGS() << "updateAgentWearables()" << LL_ENDL;
 	LLInventoryItem::item_array_t items;
 	std::vector< LLViewerWearable* > wearables;
 	wearables.reserve(32);
@@ -1988,7 +1988,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 {
 	if (mIsInUpdateAppearanceFromCOF)
 	{
-		llwarns << "Called updateAppearanceFromCOF inside updateAppearanceFromCOF, skipping" << llendl;
+		LL_WARNS() << "Called updateAppearanceFromCOF inside updateAppearanceFromCOF, skipping" << LL_ENDL;
 		return;
 	}
 
@@ -2024,7 +2024,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 	LLUUID current_outfit_id = getCOF();
 
 	// Find all the wearables that are in the COF's subtree.
-	lldebugs << "LLAppearanceMgr::updateFromCOF()" << llendl;
+	LL_DEBUGS() << "LLAppearanceMgr::updateFromCOF()" << LL_ENDL;
 	LLInventoryModel::item_array_t wear_items;
 	LLInventoryModel::item_array_t obj_items;
 	LLInventoryModel::item_array_t gest_items;
@@ -2087,11 +2087,11 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 		{
 			if (!item)
 			{
-				llwarns << "Attempt to wear a null item " << llendl;
+				LL_WARNS() << "Attempt to wear a null item " << LL_ENDL;
 			}
 			else if (!linked_item)
 			{
-				llwarns << "Attempt to wear a broken link [ name:" << item->getName() << " ] " << llendl;
+				LL_WARNS() << "Attempt to wear a broken link [ name:" << item->getName() << " ] " << LL_ENDL;
 			}
 		}
 	}
@@ -2103,7 +2103,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 	{
 		LLFoundData& found = *it;
 
-		lldebugs << self_av_string() << "waiting for onWearableAssetFetch callback, asset " << found.mAssetID.asString() << llendl;
+		LL_DEBUGS() << self_av_string() << "waiting for onWearableAssetFetch callback, asset " << found.mAssetID.asString() << LL_ENDL;
 
 		// Fetch the wearables about to be worn.
 		LLWearableList::instance().getAsset(found.mAssetID,
@@ -2327,8 +2327,8 @@ void LLAppearanceMgr::wearOutfitByName(const std::string& name)
 	}
 	else
 	{
-		llwarns << "Couldn't find outfit " <<name<< " in wearOutfitByName()"
-				<< llendl;
+		LL_WARNS() << "Couldn't find outfit " <<name<< " in wearOutfitByName()"
+				<< LL_ENDL;
 	}
 }
 
@@ -2413,7 +2413,7 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update
 	const LLViewerInventoryItem *vitem = dynamic_cast<const LLViewerInventoryItem*>(item);
 	if (!vitem)
 	{
-		llwarns << "not an llviewerinventoryitem, failed" << llendl;
+		LL_WARNS() << "not an llviewerinventoryitem, failed" << LL_ENDL;
 		return;
 	}
 
@@ -2699,7 +2699,7 @@ void LLAppearanceMgr::copyLibraryGestures()
 		gInventory.findLibraryCategoryUUIDForType(LLFolderType::FT_GESTURE,false);
 	if (lib_gesture_cat_id.isNull())
 	{
-		llwarns << "Unable to copy gestures, source category not found" << llendl;
+		LL_WARNS() << "Unable to copy gestures, source category not found" << LL_ENDL;
 	}
 	LLUUID dst_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_GESTURE);
 
@@ -2748,7 +2748,7 @@ void LLAppearanceMgr::copyLibraryGestures()
 		LLUUID cat_id = findDescendentCategoryIDByName(lib_gesture_cat_id,folder_name);
 		if (cat_id.isNull())
 		{
-			llwarns << self_av_string() << "failed to find gesture folder for " << folder_name << llendl;
+			LL_WARNS() << self_av_string() << "failed to find gesture folder for " << folder_name << LL_ENDL;
 		}
 		else
 		{
@@ -2845,7 +2845,7 @@ void LLAppearanceMgr::divvyWearablesByType(const LLInventoryModel::item_array_t&
 		LLViewerInventoryItem *item = items.at(i);
 		if (!item)
 		{
-			LL_WARNS("Appearance") << "NULL item found" << llendl;
+			LL_WARNS("Appearance") << "NULL item found" << LL_ENDL;
 			continue;
 		}
 		// Ignore non-wearables.
@@ -3045,7 +3045,7 @@ public:
 	// Error
 	/*virtual*/ void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "appearance update request failed, status: " << status << " reason: " << reason << " code: " << content["code"].asInteger() << " error: \"" << content["error"].asString() << "\"" << llendl;
+		LL_WARNS() << "appearance update request failed, status: " << status << " reason: " << reason << " code: " << content["code"].asInteger() << " error: \"" << content["error"].asString() << "\"" << LL_ENDL;
 		if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage"))
 		{
 			dumpContents(gAgentAvatarp->getFullname() + "_appearance_request_error", content);
@@ -3060,7 +3060,7 @@ public:
 		F32 seconds_to_wait;
 		if (mRetryPolicy->shouldRetry(status,seconds_to_wait))
 		{
-			llinfos << "retrying" << llendl;
+			LL_INFOS() << "retrying" << LL_ENDL;
 			doAfterInterval(boost::bind(&LLAppearanceMgr::requestServerAppearanceUpdate,
 										LLAppearanceMgr::getInstance(),
 										LLCurl::ResponderPtr(this)),
@@ -3068,7 +3068,7 @@ public:
 		}
 		else
 		{
-			llwarns << "giving up after too many retries" << llendl;
+			LL_WARNS() << "giving up after too many retries" << LL_ENDL;
 		}
 	}	
 
@@ -3083,7 +3083,7 @@ public:
 
 	void debugCOF(const LLSD& content)
 	{
-		LL_DEBUGS("Avatar") << "AIS COF, version found: " << content["expected"].asInteger() << llendl;
+		LL_DEBUGS("Avatar") << "AIS COF, version found: " << content["expected"].asInteger() << LL_ENDL;
 		std::set<LLUUID> ais_items, local_items;
 		const LLSD& cof_raw = content["cof_raw"];
 		for (LLSD::array_const_iterator it = cof_raw.beginArray();
@@ -3098,14 +3098,14 @@ public:
 					LL_DEBUGS("Avatar") << "Link: item_id: " << item["item_id"].asUUID()
 										<< " linked_item_id: " << item["asset_id"].asUUID()
 										<< " name: " << item["name"].asString()
-										<< llendl; 
+										<< LL_ENDL; 
 				}
 				else if (item["type"].asInteger() == 25) // folder link
 				{
 					LL_DEBUGS("Avatar") << "Folder link: item_id: " << item["item_id"].asUUID()
 										<< " linked_item_id: " << item["asset_id"].asUUID()
 										<< " name: " << item["name"].asString()
-										<< llendl; 
+										<< LL_ENDL; 
 					
 				}
 				else
@@ -3113,12 +3113,12 @@ public:
 					LL_DEBUGS("Avatar") << "Other: item_id: " << item["item_id"].asUUID()
 										<< " linked_item_id: " << item["asset_id"].asUUID()
 										<< " name: " << item["name"].asString()
-										<< llendl; 
+										<< LL_ENDL; 
 				}
 			}
 		}
-		LL_DEBUGS("Avatar") << llendl;
-		LL_DEBUGS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() << llendl;
+		LL_DEBUGS("Avatar") << LL_ENDL;
+		LL_DEBUGS("Avatar") << "Local COF, version requested: " << content["observed"].asInteger() << LL_ENDL;
 		LLInventoryModel::cat_array_t cat_array;
 		LLInventoryModel::item_array_t item_array;
 		gInventory.collectDescendents(LLAppearanceMgr::instance().getCOF(),
@@ -3130,21 +3130,21 @@ public:
 			LL_DEBUGS("Avatar") << "item_id: " << inv_item->getUUID()
 								<< " linked_item_id: " << inv_item->getLinkedUUID()
 								<< " name: " << inv_item->getName()
-								<< llendl;
+								<< LL_ENDL;
 		}
-		LL_DEBUGS("Avatar") << llendl;
+		LL_DEBUGS("Avatar") << LL_ENDL;
 		for (std::set<LLUUID>::iterator it = local_items.begin(); it != local_items.end(); ++it)
 		{
 			if (ais_items.find(*it) == ais_items.end())
 			{
-				LL_DEBUGS("Avatar") << "LOCAL ONLY: " << *it << llendl;
+				LL_DEBUGS("Avatar") << "LOCAL ONLY: " << *it << LL_ENDL;
 			}
 		}
 		for (std::set<LLUUID>::iterator it = ais_items.begin(); it != ais_items.end(); ++it)
 		{
 			if (local_items.find(*it) == local_items.end())
 			{
-				LL_DEBUGS("Avatar") << "AIS ONLY: " << *it << llendl;
+				LL_DEBUGS("Avatar") << "AIS ONLY: " << *it << LL_ENDL;
 			}
 		}
 	}
@@ -3178,17 +3178,17 @@ LLSD LLAppearanceMgr::dumpCOF() const
 			const LLViewerInventoryItem* linked_item = inv_item->getLinkedItem();
 			if (NULL == linked_item)
 			{
-				llwarns << "Broken link for item '" << inv_item->getName()
+				LL_WARNS() << "Broken link for item '" << inv_item->getName()
 						<< "' (" << inv_item->getUUID()
-						<< ") during requestServerAppearanceUpdate" << llendl;
+						<< ") during requestServerAppearanceUpdate" << LL_ENDL;
 				continue;
 			}
 			// Some assets may be 'hidden' and show up as null in the viewer.
 			//if (linked_item->getAssetUUID().isNull())
 			//{
-			//	llwarns << "Broken link (null asset) for item '" << inv_item->getName()
+			//	LL_WARNS() << "Broken link (null asset) for item '" << inv_item->getName()
 			//			<< "' (" << inv_item->getUUID()
-			//			<< ") during requestServerAppearanceUpdate" << llendl;
+			//			<< ") during requestServerAppearanceUpdate" << LL_ENDL;
 			//	continue;
 			//}
 			LLUUID linked_asset_id(linked_item->getAssetUUID());
@@ -3198,10 +3198,10 @@ LLSD LLAppearanceMgr::dumpCOF() const
 		}
 		else if (LLAssetType::AT_LINK_FOLDER != inv_item->getActualType())
 		{
-			llwarns << "Non-link item '" << inv_item->getName()
+			LL_WARNS() << "Non-link item '" << inv_item->getName()
 					<< "' (" << inv_item->getUUID()
 					<< ") type " << (S32) inv_item->getActualType()
-					<< " during requestServerAppearanceUpdate" << llendl;
+					<< " during requestServerAppearanceUpdate" << LL_ENDL;
 			continue;
 		}
 		links.append(item);
@@ -3225,17 +3225,17 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond
 
 	if (!gAgent.getRegion())
 	{
-		llwarns << "Region not set, cannot request server appearance update" << llendl;
+		LL_WARNS() << "Region not set, cannot request server appearance update" << LL_ENDL;
 		return;
 	}
 	if (gAgent.getRegion()->getCentralBakeVersion()==0)
 	{
-		llwarns << "Region does not support baking" << llendl;
+		LL_WARNS() << "Region does not support baking" << LL_ENDL;
 	}
 	std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance");	
 	if (url.empty())
 	{
-		llwarns << "No cap for UpdateAvatarAppearance." << llendl;
+		LL_WARNS() << "No cap for UpdateAvatarAppearance." << LL_ENDL;
 		return;
 	}
 
@@ -3253,7 +3253,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond
 			body["cof_version"] = cof_version+999;
 		}
 	}
-	LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << llendl;
+	LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << LL_ENDL;
 
 	//LLCurl::ResponderPtr responder_ptr;
 	if (!responder_ptr.get())
@@ -3279,7 +3279,7 @@ public:
 
 	virtual void result(const LLSD &pContent)
 	{
-		llinfos << "Successfully incremented agent's COF." << llendl;
+		LL_INFOS() << "Successfully incremented agent's COF." << LL_ENDL;
 		S32 new_version = pContent["category"]["version"].asInteger();
 
 		// cof_version should have increased
@@ -3289,12 +3289,12 @@ public:
 	}
 	virtual void errorWithContent(U32 pStatus, const std::string& pReason, const LLSD& content)
 	{
-		llwarns << "While attempting to increment the agent's cof we got an error with [status:"
-				<< pStatus << "]: " << content << llendl;
+		LL_WARNS() << "While attempting to increment the agent's cof we got an error with [status:"
+				<< pStatus << "]: " << content << LL_ENDL;
 		F32 seconds_to_wait;
 		if (mRetryPolicy->shouldRetry(pStatus,seconds_to_wait))
 		{
-			llinfos << "retrying" << llendl;
+			LL_INFOS() << "retrying" << LL_ENDL;
 			doAfterInterval(boost::bind(&LLAppearanceMgr::incrementCofVersion,
 										LLAppearanceMgr::getInstance(),
 										LLHTTPClient::ResponderPtr(this)),
@@ -3302,7 +3302,7 @@ public:
 		}
 		else
 		{
-			llwarns << "giving up after too many retries" << llendl;
+			LL_WARNS() << "giving up after too many retries" << LL_ENDL;
 		}
 	}
 
@@ -3314,19 +3314,19 @@ void LLAppearanceMgr::incrementCofVersion(LLHTTPClient::ResponderPtr responder_p
 	// If we don't have a region, report it as an error
 	if (gAgent.getRegion() == NULL)
 	{
-		llwarns << "Region not set, cannot request cof_version increment" << llendl;
+		LL_WARNS() << "Region not set, cannot request cof_version increment" << LL_ENDL;
 		return;
 	}
 
 	std::string url = gAgent.getRegion()->getCapability("IncrementCofVersion");
 	if (url.empty())
 	{
-		llwarns << "No cap for IncrementCofVersion." << llendl;
+		LL_WARNS() << "No cap for IncrementCofVersion." << LL_ENDL;
 		return;
 	}
 
-	llinfos << "Requesting cof_version be incremented via capability to: "
-			<< url << llendl;
+	LL_INFOS() << "Requesting cof_version be incremented via capability to: "
+			<< url << LL_ENDL;
 	LLSD headers;
 	LLSD body = LLSD::emptyMap();
 
@@ -3351,7 +3351,7 @@ void show_created_outfit(LLUUID& folder_id, bool show_panel = true)
 	{
 		if (!LLApp::isRunning())
 		{
-			llwarns << "called during shutdown, skipping" << llendl;
+			LL_WARNS() << "called during shutdown, skipping" << LL_ENDL;
 			return;
 		}
 
@@ -3413,7 +3413,7 @@ void LLAppearanceMgr::removeItemsFromAvatar(const uuid_vec_t& ids_to_remove)
 {
 	if (ids_to_remove.empty())
 	{
-		llwarns << "called with empty list, nothing to do" << llendl;
+		LL_WARNS() << "called with empty list, nothing to do" << LL_ENDL;
 	}
 	for (uuid_vec_t::const_iterator it = ids_to_remove.begin(); it != ids_to_remove.end(); ++it)
 			{
@@ -3503,18 +3503,18 @@ void LLAppearanceMgr::dumpCat(const LLUUID& cat_id, const std::string& msg)
 	gInventory.collectDescendents(cat_id, cats, items, LLInventoryModel::EXCLUDE_TRASH);
 
 #ifdef DUMP_CAT_VERBOSE
-	llinfos << llendl;
-	llinfos << str << llendl;
+	LL_INFOS() << LL_ENDL;
+	LL_INFOS() << str << LL_ENDL;
 	S32 hitcount = 0;
 	for(S32 i=0; i<items.size(); i++)
 	{
 		LLViewerInventoryItem *item = items.get(i);
 		if (item)
 			hitcount++;
-		llinfos << i <<" "<< item->getName() <<llendl;
+		LL_INFOS() << i <<" "<< item->getName() <<LL_ENDL;
 	}
 #endif
-	llinfos << msg << " count " << items.size() << llendl;
+	LL_INFOS() << msg << " count " << items.size() << LL_ENDL;
 }
 
 void LLAppearanceMgr::dumpItemArray(const LLInventoryModel::item_array_t& items,
@@ -3557,13 +3557,13 @@ LLAppearanceMgr::~LLAppearanceMgr()
 
 void LLAppearanceMgr::setAttachmentInvLinkEnable(bool val)
 {
-	LL_DEBUGS("Avatar") << "setAttachmentInvLinkEnable => " << (int) val << llendl;
+	LL_DEBUGS("Avatar") << "setAttachmentInvLinkEnable => " << (int) val << LL_ENDL;
 	mAttachmentInvLinkEnabled = val;
 }
 
 void dumpAttachmentSet(const std::set<LLUUID>& atts, const std::string& msg)
 {
-       llinfos << msg << llendl;
+       LL_INFOS() << msg << LL_ENDL;
        for (std::set<LLUUID>::const_iterator it = atts.begin();
                it != atts.end();
                ++it)
@@ -3571,11 +3571,11 @@ void dumpAttachmentSet(const std::set<LLUUID>& atts, const std::string& msg)
                LLUUID item_id = *it;
                LLViewerInventoryItem *item = gInventory.getItem(item_id);
                if (item)
-                       llinfos << "atts " << item->getName() << llendl;
+                       LL_INFOS() << "atts " << item->getName() << LL_ENDL;
                else
-                       llinfos << "atts " << "UNKNOWN[" << item_id.asString() << "]" << llendl;
+                       LL_INFOS() << "atts " << "UNKNOWN[" << item_id.asString() << "]" << LL_ENDL;
        }
-       llinfos << llendl;
+       LL_INFOS() << LL_ENDL;
 }
 
 void LLAppearanceMgr::registerAttachment(const LLUUID& item_id)
@@ -3591,7 +3591,7 @@ void LLAppearanceMgr::registerAttachment(const LLUUID& item_id)
 	   }
 	   else
 	   {
-		   //llinfos << "no link changes, inv link not enabled" << llendl;
+		   //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL;
 	   }
 }
 
@@ -3605,7 +3605,7 @@ void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id)
 	   }
 	   else
 	   {
-		   //llinfos << "no link changes, inv link not enabled" << llendl;
+		   //LL_INFOS() << "no link changes, inv link not enabled" << LL_ENDL;
 	   }
 }
 
@@ -3671,8 +3671,8 @@ public:
 	}
 	virtual void done()
 	{
-		llinfos << this << " done with incomplete " << mIncomplete.size()
-				<< " complete " << mComplete.size() <<  " calling callable" << llendl;
+		LL_INFOS() << this << " done with incomplete " << mIncomplete.size()
+				<< " complete " << mComplete.size() <<  " calling callable" << LL_ENDL;
 
 		gInventory.removeObserver(this);
 		doOnIdleOneTime(mCallable);
@@ -3707,8 +3707,8 @@ public:
 		S32 count = item_array.size();
 		if(!count)
 		{
-			llwarns << "Nothing fetched in category " << mComplete.front()
-					<< llendl;
+			LL_WARNS() << "Nothing fetched in category " << mComplete.front()
+					<< LL_ENDL;
 			gInventory.removeObserver(this);
 			doOnIdleOneTime(mCallable);
 
@@ -3716,7 +3716,7 @@ public:
 			return;
 		}
 
-		llinfos << "stage1 got " << item_array.size() << " items, passing to stage2 " << llendl;
+		LL_INFOS() << "stage1 got " << item_array.size() << " items, passing to stage2 " << LL_ENDL;
 		uuid_vec_t ids;
 		for(S32 i = 0; i < count; ++i)
 		{
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index d544b992ef..0a1a78c5b4 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -688,7 +688,7 @@ LLAppViewer::LLAppViewer()
 {
 	if(NULL != sInstance)
 	{
-		llerrs << "Oh no! An instance of LLAppViewer already exists! LLAppViewer is sort of like a singleton." << llendl;
+		LL_ERRS() << "Oh no! An instance of LLAppViewer already exists! LLAppViewer is sort of like a singleton." << LL_ENDL;
 	}
 
 	setupErrorHandling();
@@ -1259,7 +1259,7 @@ LLFastTimer::DeclareTimer FTM_FRAME("Frame");
 
 bool LLAppViewer::mainLoop()
 {
-	llinfos << "***********************Entering main_loop***********************" << LL_ENDL;
+	LL_INFOS() << "***********************Entering main_loop***********************" << LL_ENDL;
 
 	mMainloopTimeout = new LLWatchdogTimeout();
 	
@@ -1326,7 +1326,7 @@ bool LLAppViewer::mainLoop()
 				LLFastTimer t2(FTM_MESSAGES);
 				if (!restoreErrorTrap())
 				{
-					llwarns << " Someone took over my signal/exception handler (post messagehandling)!" << llendl;
+					LL_WARNS() << " Someone took over my signal/exception handler (post messagehandling)!" << LL_ENDL;
 				}
 
 				gViewerWindow->getWindow()->gatherInput();
@@ -1460,7 +1460,7 @@ bool LLAppViewer::mainLoop()
 				if (mPeriodicSlowFrame
 					&& (gFrameCount % 10 == 0))
 				{
-					llinfos << "Periodic slow frame - sleeping 500 ms" << llendl;
+					LL_INFOS() << "Periodic slow frame - sleeping 500 ms" << LL_ENDL;
 					ms_sleep(500);
 				}
 
@@ -1550,14 +1550,14 @@ bool LLAppViewer::mainLoop()
 			if(mem_leak_instance)
 			{
 				mem_leak_instance->stop() ;				
-				llwarns << "Bad memory allocation in LLAppViewer::mainLoop()!" << llendl ;
+				LL_WARNS() << "Bad memory allocation in LLAppViewer::mainLoop()!" << LL_ENDL ;
 			}
 			else
 			{
 				//output possible call stacks to log file.
 				LLError::LLCallStacks::print() ;
 
-				llerrs << "Bad memory allocation in LLAppViewer::mainLoop()!" << llendl ;
+				LL_ERRS() << "Bad memory allocation in LLAppViewer::mainLoop()!" << LL_ENDL ;
 			}
 		}
 	}
@@ -1571,7 +1571,7 @@ bool LLAppViewer::mainLoop()
 		}
 		catch(std::bad_alloc)
 		{
-			llwarns << "Bad memory allocation when saveFinalSnapshot() is called!" << llendl ;
+			LL_WARNS() << "Bad memory allocation when saveFinalSnapshot() is called!" << LL_ENDL ;
 
 			//stop memory leaking simulation
 			LLFloaterMemLeak* mem_leak_instance =
@@ -1587,7 +1587,7 @@ bool LLAppViewer::mainLoop()
 
 	destroyMainloopTimeout();
 
-	llinfos << "***********************Exiting main_loop***********************" << LL_ENDL;
+	LL_INFOS() << "***********************Exiting main_loop***********************" << LL_ENDL;
 
 	return true;
 }
@@ -1620,7 +1620,7 @@ void LLAppViewer::flushVFSIO()
 		{
 			break;
 		}
-		llinfos << "Waiting for pending IO to finish: " << pending << LL_ENDL;
+		LL_INFOS() << "Waiting for pending IO to finish: " << pending << LL_ENDL;
 		ms_sleep(100);
 	}
 }
@@ -1638,7 +1638,7 @@ bool LLAppViewer::cleanup()
 
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
-		llinfos << "Analyzing performance" << llendl;
+		LL_INFOS() << "Analyzing performance" << LL_ENDL;
 		std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp";
 		std::string current_name  = LLTrace::TimeBlock::sLogName + ".slp"; 
 		std::string report_name   = LLTrace::TimeBlock::sLogName + "_report.csv";
@@ -1684,7 +1684,7 @@ bool LLAppViewer::cleanup()
 	
 	disconnectViewer();
 
-	llinfos << "Viewer disconnected" << LL_ENDL;
+	LL_INFOS() << "Viewer disconnected" << LL_ENDL;
 
 	display_cleanup(); 
 
@@ -1692,7 +1692,7 @@ bool LLAppViewer::cleanup()
 
 	LLError::logToFixedBuffer(NULL);
 
-	llinfos << "Cleaning Up" << LL_ENDL;
+	LL_INFOS() << "Cleaning Up" << LL_ENDL;
 
 	// shut down mesh streamer
 	gMeshRepo.shutdown();
@@ -1707,7 +1707,7 @@ bool LLAppViewer::cleanup()
 		LLHUDObject::updateAll();
 		LLHUDManager::getInstance()->cleanupEffects();
 		LLHUDObject::cleanupHUDObjects();
-		llinfos << "HUD Objects cleaned up" << LL_ENDL;
+		LL_INFOS() << "HUD Objects cleaned up" << LL_ENDL;
 	}
 
 	LLKeyframeDataCache::clear();
@@ -1738,7 +1738,7 @@ bool LLAppViewer::cleanup()
 
 	LLCalc::cleanUp();
 
-	llinfos << "Global stuff deleted" << LL_ENDL;
+	LL_INFOS() << "Global stuff deleted" << LL_ENDL;
 
 	if (gAudiop)
 	{
@@ -1762,7 +1762,7 @@ bool LLAppViewer::cleanup()
 	// such that we can suck rectangle information out of
 	// it.
 	cleanupSavedSettings();
-	llinfos << "Settings patched up" << LL_ENDL;
+	LL_INFOS() << "Settings patched up" << LL_ENDL;
 
 	// delete some of the files left around in the cache.
 	removeCacheFiles("*.wav");
@@ -1773,29 +1773,29 @@ bool LLAppViewer::cleanup()
 	removeCacheFiles("*.bodypart");
 	removeCacheFiles("*.clothing");
 
-	llinfos << "Cache files removed" << LL_ENDL;
+	LL_INFOS() << "Cache files removed" << LL_ENDL;
 
 	// Wait for any pending VFS IO
 	flushVFSIO();
-	llinfos << "Shutting down Views" << LL_ENDL;
+	LL_INFOS() << "Shutting down Views" << LL_ENDL;
 
 	// Destroy the UI
 	if( gViewerWindow)
 		gViewerWindow->shutdownViews();
 
-	llinfos << "Cleaning up Inventory" << LL_ENDL;
+	LL_INFOS() << "Cleaning up Inventory" << LL_ENDL;
 	
 	// Cleanup Inventory after the UI since it will delete any remaining observers
 	// (Deleted observers should have already removed themselves)
 	gInventory.cleanupInventory();
 
-	llinfos << "Cleaning up Selections" << LL_ENDL;
+	LL_INFOS() << "Cleaning up Selections" << LL_ENDL;
 	
 	// Clean up selection managers after UI is destroyed, as UI may be observing them.
 	// Clean up before GL is shut down because we might be holding on to objects with texture references
 	LLSelectMgr::cleanupGlobals();
 	
-	llinfos << "Shutting down OpenGL" << LL_ENDL;
+	LL_INFOS() << "Shutting down OpenGL" << LL_ENDL;
 
 	// Shut down OpenGL
 	if( gViewerWindow)
@@ -1807,10 +1807,10 @@ bool LLAppViewer::cleanup()
 		// Therefore must do this before destroying the message system.
 		delete gViewerWindow;
 		gViewerWindow = NULL;
-		llinfos << "ViewerWindow deleted" << LL_ENDL;
+		LL_INFOS() << "ViewerWindow deleted" << LL_ENDL;
 	}
 
-	llinfos << "Cleaning up Keyboard & Joystick" << LL_ENDL;
+	LL_INFOS() << "Cleaning up Keyboard & Joystick" << LL_ENDL;
 	
 	// viewer UI relies on keyboard so keep it aound until viewer UI isa gone
 	delete gKeyboard;
@@ -1819,7 +1819,7 @@ bool LLAppViewer::cleanup()
 	// Turn off Space Navigator and similar devices
 	LLViewerJoystick::getInstance()->terminate();
 	
-	llinfos << "Cleaning up Objects" << LL_ENDL;
+	LL_INFOS() << "Cleaning up Objects" << LL_ENDL;
 	
 	LLViewerObject::cleanupVOClasses();
 
@@ -1841,11 +1841,11 @@ bool LLAppViewer::cleanup()
 	LLVolumeMgr* volume_manager = LLPrimitive::getVolumeManager();
 	if (!volume_manager->cleanup())
 	{
-		llwarns << "Remaining references in the volume manager!" << LL_ENDL;
+		LL_WARNS() << "Remaining references in the volume manager!" << LL_ENDL;
 	}
 	LLPrimitive::cleanupVolumeManager();
 
-	llinfos << "Additional Cleanup..." << LL_ENDL;	
+	LL_INFOS() << "Additional Cleanup..." << LL_ENDL;	
 	
 	LLViewerParcelMgr::cleanupGlobals();
 
@@ -1866,10 +1866,10 @@ bool LLAppViewer::cleanup()
 	// Also after shutting down the messaging system since it has VFS dependencies
 
 	//
-	llinfos << "Cleaning up VFS" << LL_ENDL;
+	LL_INFOS() << "Cleaning up VFS" << LL_ENDL;
 	LLVFile::cleanupClass();
 
-	llinfos << "Saving Data" << LL_ENDL;
+	LL_INFOS() << "Saving Data" << LL_ENDL;
 	
 	// Store the time of our current logoff
 	gSavedPerAccountSettings.setU32("LastLogoff", time_corrected());
@@ -1884,19 +1884,19 @@ bool LLAppViewer::cleanup()
 	// *FIX:Mani This should get really saved in a "logoff" mode. 
 	if (gSavedSettings.getString("PerAccountSettingsFile").empty())
 	{
-		llinfos << "Not saving per-account settings; don't know the account name yet." << llendl;
+		LL_INFOS() << "Not saving per-account settings; don't know the account name yet." << LL_ENDL;
 	}
 	// Only save per account settings if the previous login succeeded, otherwise
 	// we might end up with a cleared out settings file in case a previous login
 	// failed after loading per account settings.
 	else if (!mSavePerAccountSettings)
 	{
-		llinfos << "Not saving per-account settings; last login was not successful." << llendl;
+		LL_INFOS() << "Not saving per-account settings; last login was not successful." << LL_ENDL;
 	}
 	else
 	{
 		gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
-		llinfos << "Saved settings" << LL_ENDL;
+		LL_INFOS() << "Saved settings" << LL_ENDL;
 	}
 
 	std::string warnings_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, getSettingsFilename("Default", "Warnings"));
@@ -1913,7 +1913,7 @@ bool LLAppViewer::cleanup()
 
 	if (mPurgeOnExit)
 	{
-		llinfos << "Purging all cache files on exit" << LL_ENDL;
+		LL_INFOS() << "Purging all cache files on exit" << LL_ENDL;
 		gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE,""), "*.*");
 	}
 
@@ -1930,7 +1930,7 @@ bool LLAppViewer::cleanup()
 	// Stop the plugin read thread if it's running.
 	LLPluginProcessParent::setUseReadThread(false);
 
-	llinfos << "Shutting down Threads" << LL_ENDL;
+	LL_INFOS() << "Shutting down Threads" << LL_ENDL;
 
 	// Let threads finish
 	LLTimer idleTimer;
@@ -1952,7 +1952,7 @@ bool LLAppViewer::cleanup()
 		}
 		else if(idle_time >= max_idle_time)
 		{
-			llwarns << "Quitting with pending background tasks." << llendl;
+			LL_WARNS() << "Quitting with pending background tasks." << LL_ENDL;
 			break;
 		}
 	}
@@ -1968,7 +1968,7 @@ bool LLAppViewer::cleanup()
 	sTextureFetch->shutDownTextureCacheThread() ;
 	sTextureFetch->shutDownImageDecodeThread() ;
 
-	llinfos << "Shutting down message system" << LL_ENDL;
+	LL_INFOS() << "Shutting down message system" << LL_ENDL;
 	end_messaging_system();
 
 	// *NOTE:Mani - The following call is not thread safe. 
@@ -1993,7 +1993,7 @@ bool LLAppViewer::cleanup()
 	
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
-		llinfos << "Analyzing performance" << llendl;
+		LL_INFOS() << "Analyzing performance" << LL_ENDL;
 		
 		std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp";
 		std::string current_name  = LLTrace::TimeBlock::sLogName + ".slp"; 
@@ -2007,7 +2007,7 @@ bool LLAppViewer::cleanup()
 
 	LLMetricPerformanceTesterBasic::cleanClass() ;
 
-	llinfos << "Cleaning up Media and Textures" << LL_ENDL;
+	LL_INFOS() << "Cleaning up Media and Textures" << LL_ENDL;
 
 	//Note:
 	//LLViewerMedia::cleanupClass() has to be put before gTextureList.shutdown()
@@ -2023,14 +2023,14 @@ bool LLAppViewer::cleanup()
 	LLLFSThread::cleanupClass();
 
 #ifndef LL_RELEASE_FOR_DOWNLOAD
-	llinfos << "Auditing VFS" << llendl;
+	LL_INFOS() << "Auditing VFS" << LL_ENDL;
 	if(gVFS)
 	{
 		gVFS->audit();
 	}
 #endif
 
-	llinfos << "Misc Cleanup" << LL_ENDL;
+	LL_INFOS() << "Misc Cleanup" << LL_ENDL;
 	
 	// For safety, the LLVFS has to be deleted *after* LLVFSThread. This should be cleaned up.
 	// (LLVFS doesn't know about LLVFSThread so can't kill pending requests) -Steve
@@ -2050,7 +2050,7 @@ bool LLAppViewer::cleanup()
 	// is at the right resolution before we launch IE.
 	if (!gLaunchFileOnQuit.empty())
 	{
-		llinfos << "Launch file on quit." << LL_ENDL;
+		LL_INFOS() << "Launch file on quit." << LL_ENDL;
 #if LL_WINDOWS
 		// Indicate an application is starting.
 		SetCursor(LoadCursor(NULL, IDC_WAIT));
@@ -2060,9 +2060,9 @@ bool LLAppViewer::cleanup()
 		ms_sleep(1000);
 
 		LLWeb::loadURLExternal( gLaunchFileOnQuit, false );
-		llinfos << "File launched." << LL_ENDL;
+		LL_INFOS() << "File launched." << LL_ENDL;
 	}
-	llinfos << "Cleaning up LLProxy." << llendl;
+	LL_INFOS() << "Cleaning up LLProxy." << LL_ENDL;
 	LLProxy::cleanupClass();
 
 	LLWearableType::cleanupClass();
@@ -2074,13 +2074,13 @@ bool LLAppViewer::cleanup()
 
 	ll_close_fail_log();
 
-    llinfos << "Goodbye!" << LL_ENDL;
+    LL_INFOS() << "Goodbye!" << LL_ENDL;
 
 	// return 0;
 	return true;
 }
 
-// A callback for llerrs to call during the watchdog error.
+// A callback for LL_ERRS() to call during the watchdog error.
 void watchdog_llerrs_callback(const std::string &error_string)
 {
 	gLLErrorActivated = true;
@@ -2096,7 +2096,7 @@ void watchdog_llerrs_callback(const std::string &error_string)
 void watchdog_killer_callback()
 {
 	LLError::setFatalFunction(watchdog_llerrs_callback);
-	llerrs << "Watchdog killer event" << llendl;
+	LL_ERRS() << "Watchdog killer event" << LL_ENDL;
 }
 
 bool LLAppViewer::initThreads()
@@ -2221,7 +2221,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key,
 {	
 	if (!mSettingsLocationList)
 	{
-		llerrs << "Invalid settings location list" << llendl;
+		LL_ERRS() << "Invalid settings location list" << LL_ENDL;
 	}
 
 	BOOST_FOREACH(const SettingsGroup& group, mSettingsLocationList->groups)
@@ -2232,19 +2232,19 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key,
 		ELLPath path_index = (ELLPath)group.path_index();
 		if(path_index <= LL_PATH_NONE || path_index >= LL_PATH_LAST)
 		{
-			llerrs << "Out of range path index in app_settings/settings_files.xml" << llendl;
+			LL_ERRS() << "Out of range path index in app_settings/settings_files.xml" << LL_ENDL;
 			return false;
 		}
 
 		BOOST_FOREACH(const SettingsFile& file, group.files)
 		{
-			llinfos << "Attempting to load settings for the group " << file.name()
-			    << " - from location " << location_key << llendl;
+			LL_INFOS() << "Attempting to load settings for the group " << file.name()
+			    << " - from location " << location_key << LL_ENDL;
 
 			LLControlGroup* settings_group = LLControlGroup::getInstance(file.name);
 			if(!settings_group)
 			{
-				llwarns << "No matching settings group for name " << file.name() << llendl;
+				LL_WARNS() << "No matching settings group for name " << file.name() << LL_ENDL;
 				continue;
 			}
 
@@ -2273,13 +2273,13 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key,
 
 			if(settings_group->loadFromFile(full_settings_path, set_defaults, file.persistent))
 			{	// success!
-				llinfos << "Loaded settings file " << full_settings_path << llendl;
+				LL_INFOS() << "Loaded settings file " << full_settings_path << LL_ENDL;
 			}
 			else
 			{	// failed to load
 				if(file.required)
 				{
-					llerrs << "Error: Cannot load required settings file from: " << full_settings_path << llendl;
+					LL_ERRS() << "Error: Cannot load required settings file from: " << full_settings_path << LL_ENDL;
 					return false;
 				}
 				else
@@ -2287,7 +2287,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key,
 					// only complain if we actually have a filename at this point
 					if (!full_settings_path.empty())
 					{
-						llinfos << "Cannot load " << full_settings_path << " - No settings found." << llendl;
+						LL_INFOS() << "Cannot load " << full_settings_path << " - No settings found." << LL_ENDL;
 					}
 				}
 			}
@@ -2327,17 +2327,17 @@ bool LLAppViewer::initConfiguration()
 	//Load settings files list
 	std::string settings_file_list = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "settings_files.xml");
 	//LLControlGroup settings_control("SettingsFiles");
-	//llinfos << "Loading settings file list " << settings_file_list << llendl;
+	//LL_INFOS() << "Loading settings file list " << settings_file_list << LL_ENDL;
 	//if (0 == settings_control.loadFromFile(settings_file_list))
 	//{
- //       llerrs << "Cannot load default configuration file " << settings_file_list << llendl;
+ //       LL_ERRS() << "Cannot load default configuration file " << settings_file_list << LL_ENDL;
 	//}
 
 	LLXMLNodePtr root;
 	BOOL success  = LLXMLNode::parseFile(settings_file_list, root, NULL);
 	if (!success)
 	{
-        llerrs << "Cannot load default configuration file " << settings_file_list << llendl;
+        LL_ERRS() << "Cannot load default configuration file " << settings_file_list << LL_ENDL;
 	}
 
 	mSettingsLocationList = new SettingsFiles();
@@ -2347,7 +2347,7 @@ bool LLAppViewer::initConfiguration()
 
 	if (!mSettingsLocationList->validateBlock())
 	{
-        llerrs << "Invalid settings file list " << settings_file_list << llendl;
+        LL_ERRS() << "Invalid settings file list " << settings_file_list << LL_ENDL;
 	}
 		
 	// The settings and command line parsing have a fragile
@@ -2429,9 +2429,9 @@ bool LLAppViewer::initConfiguration()
 
 	if(!initParseCommandLine(clp))
 	{
-		llwarns	<< "Error parsing command line options.	Command	Line options ignored."  << llendl;
+		LL_WARNS()	<< "Error parsing command line options.	Command	Line options ignored."  << LL_ENDL;
 		
-		llinfos	<< "Command	line usage:\n" << clp << llendl;
+		LL_INFOS()	<< "Command	line usage:\n" << clp << LL_ENDL;
 
 		std::ostringstream msg;
 		msg << LLTrans::getString("MBCmdLineError") << clp.getErrorMessage();
@@ -2449,8 +2449,8 @@ bool LLAppViewer::initConfiguration()
 			gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, 
 										   clp.getOption("settings")[0]);		
 		gSavedSettings.setString("ClientSettingsFile", user_settings_filename);
-		llinfos	<< "Using command line specified settings filename: " 
-			<< user_settings_filename << llendl;
+		LL_INFOS()	<< "Using command line specified settings filename: " 
+			<< user_settings_filename << LL_ENDL;
 	}
 
 	// - load overrides from user_settings 
@@ -2466,8 +2466,8 @@ bool LLAppViewer::initConfiguration()
 	{
 		std::string session_settings_filename = clp.getOption("sessionsettings")[0];		
 		gSavedSettings.setString("SessionSettingsFile", session_settings_filename);
-		llinfos	<< "Using session settings filename: " 
-			<< session_settings_filename << llendl;
+		LL_INFOS()	<< "Using session settings filename: " 
+			<< session_settings_filename << LL_ENDL;
 	}
 	loadSettingsFromDirectory("Session");
 
@@ -2475,8 +2475,8 @@ bool LLAppViewer::initConfiguration()
 	{
 		std::string user_session_settings_filename = clp.getOption("usersessionsettings")[0];		
 		gSavedSettings.setString("UserSessionSettingsFile", user_session_settings_filename);
-		llinfos	<< "Using user session settings filename: " 
-			<< user_session_settings_filename << llendl;
+		LL_INFOS()	<< "Using user session settings filename: " 
+			<< user_session_settings_filename << LL_ENDL;
 
 	}
 	loadSettingsFromDirectory("UserSession");
@@ -2489,7 +2489,7 @@ bool LLAppViewer::initConfiguration()
 	// ASAP or we might miss init issue etc.
 	if(clp.hasOption("disablecrashlogger"))
 	{
-		llwarns << "Crashes will be handled by system, stack trace logs and crash logger are both disabled" << llendl;
+		LL_WARNS() << "Crashes will be handled by system, stack trace logs and crash logger are both disabled" << LL_ENDL;
 		LLAppViewer::instance()->disableCrashlogger();
 	}
 
@@ -2504,7 +2504,7 @@ bool LLAppViewer::initConfiguration()
 	{
 		std::ostringstream msg;
 		msg << LLTrans::getString("MBCmdLineUsg") << "\n" << clp;
-		llinfos	<< msg.str() << llendl;
+		LL_INFOS()	<< msg.str() << LL_ENDL;
 
 		OSMessageBox(
 			msg.str().c_str(),
@@ -2519,7 +2519,7 @@ bool LLAppViewer::initConfiguration()
         const LLCommandLineParser::token_vector_t& set_values = clp.getOption("set");
         if(0x1 & set_values.size())
         {
-            llwarns << "Invalid '--set' parameter count." << llendl;
+            LL_WARNS() << "Invalid '--set' parameter count." << LL_ENDL;
         }
         else
         {
@@ -2538,13 +2538,13 @@ bool LLAppViewer::initConfiguration()
 				{
 					group_part = name.substr(0, pos);
 					name_part = name.substr(pos+1);
-					llinfos << "Setting " << group_part << "." << name_part << " to " << value << llendl;
+					LL_INFOS() << "Setting " << group_part << "." << name_part << " to " << value << LL_ENDL;
 					LLControlGroup* g = LLControlGroup::getInstance(group_part);
 					if (g) control = g->getControl(name_part);
 				}
 				else
 				{
-					llinfos << "Setting Global." << name << " to " << value << llendl;
+					LL_INFOS() << "Setting Global." << name << " to " << value << LL_ENDL;
 					control = gSavedSettings.getControl(name);
 				}
 
@@ -2554,7 +2554,7 @@ bool LLAppViewer::initConfiguration()
                 }
                 else
                 {
-					llwarns << "Failed --set " << name << ": setting name unknown." << llendl;
+					LL_WARNS() << "Failed --set " << name << ": setting name unknown." << LL_ENDL;
                 }
             }
         }
@@ -2583,10 +2583,10 @@ bool LLAppViewer::initConfiguration()
 		// '--logmetrics' can be specified with a named test metric argument so the data gathering is done only on that test
 		// In the absence of argument, every metric is gathered (makes for a rather slow run and hard to decipher report...)
 		std::string test_name = clp.getOption("logmetrics")[0];
-		llinfos << "'--logmetrics' argument : " << test_name << llendl;
+		LL_INFOS() << "'--logmetrics' argument : " << test_name << LL_ENDL;
 		if (test_name == "")
 		{
-			llwarns << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << llendl;
+			LL_WARNS() << "No '--logmetrics' argument given, will output all metrics to " << DEFAULT_METRIC_NAME << LL_ENDL;
 			LLTrace::TimeBlock::sLogName = DEFAULT_METRIC_NAME;
 		}
 		else
@@ -2600,7 +2600,7 @@ bool LLAppViewer::initConfiguration()
 		const LLCommandLineParser::token_vector_t& value = clp.getOption("graphicslevel");
         if(value.size() != 1)
         {
-			llwarns << "Usage: -graphicslevel <0-3>" << llendl;
+			LL_WARNS() << "Usage: -graphicslevel <0-3>" << LL_ENDL;
         }
         else
         {
@@ -2623,7 +2623,7 @@ bool LLAppViewer::initConfiguration()
 					break;
 				default:
 					mForceGraphicsDetail = FALSE;
-					llwarns << "Usage: -graphicslevel <0-3>" << llendl;
+					LL_WARNS() << "Usage: -graphicslevel <0-3>" << LL_ENDL;
 					break;
 			}
         }
@@ -2717,7 +2717,7 @@ bool LLAppViewer::initConfiguration()
 
 	//	if (!skin_def_tree.parseFile(skin_def_file))
 	//	{
-	//		llerrs << "Failed to parse skin definition." << llendl;
+	//		LL_ERRS() << "Failed to parse skin definition." << LL_ENDL;
 	//	}
 
 	//}
@@ -2909,10 +2909,10 @@ namespace {
 
 	void apply_update_callback(LLSD const & notification, LLSD const & response)
 	{
-		lldebugs << "LLUpdate user response: " << response << llendl;
+		LL_DEBUGS() << "LLUpdate user response: " << response << LL_ENDL;
 		if(response["OK_okcancelbuttons"].asBoolean())
 		{
-			llinfos << "LLUpdate restarting viewer" << llendl;
+			LL_INFOS() << "LLUpdate restarting viewer" << LL_ENDL;
 			static const bool install_if_ready = true;
 			// *HACK - this lets us launch the installer immediately for now
 			LLUpdaterService().startChecking(install_if_ready);
@@ -2921,7 +2921,7 @@ namespace {
 	
 	void apply_update_ok_callback(LLSD const & notification, LLSD const & response)
 	{
-		llinfos << "LLUpdate restarting viewer" << llendl;
+		LL_INFOS() << "LLUpdate restarting viewer" << LL_ENDL;
 		static const bool install_if_ready = true;
 		// *HACK - this lets us launch the installer immediately for now
 		LLUpdaterService().startChecking(install_if_ready);
@@ -3122,7 +3122,7 @@ void LLAppViewer::checkForCrash(void)
 #if LL_SEND_CRASH_REPORTS
 	if (gLastExecEvent == LAST_EXEC_FROZE)
     {
-        llinfos << "Last execution froze, sending a crash report." << llendl;
+        LL_INFOS() << "Last execution froze, sending a crash report." << LL_ENDL;
             
 		bool report_freeze = true;
 		handleCrashReporting(report_freeze);
@@ -3258,7 +3258,7 @@ bool LLAppViewer::initWindow()
 void LLAppViewer::writeDebugInfo()
 {
 	std::string debug_filename = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"debug_info.log");
-	llinfos << "Opening debug file " << debug_filename << llendl;
+	LL_INFOS() << "Opening debug file " << debug_filename << LL_ENDL;
 	llofstream out_file(debug_filename);
 	LLSDSerialize::toPrettyXML(gDebugInfo, out_file);
 	out_file.close();
@@ -3381,9 +3381,9 @@ void LLAppViewer::writeSystemInfo()
 
 void LLAppViewer::handleViewerCrash()
 {
-	llinfos << "Handle viewer crash entry." << llendl;
+	LL_INFOS() << "Handle viewer crash entry." << LL_ENDL;
 
-	llinfos << "Last render pool type: " << LLPipeline::sCurRenderPoolType << llendl ;
+	LL_INFOS() << "Last render pool type: " << LLPipeline::sCurRenderPoolType << LL_ENDL ;
 
 	LLMemory::logMemoryInfo(true) ;
 
@@ -3515,7 +3515,7 @@ void LLAppViewer::handleViewerCrash()
 		llofstream file(filename, llofstream::binary);
 		if(file.good())
 		{
-			llinfos << "Handle viewer crash generating stats log." << llendl;
+			LL_INFOS() << "Handle viewer crash generating stats log." << LL_ENDL;
 			gMessageSystem->summarizeLogs(file);
 			file.close();
 		}
@@ -3805,7 +3805,7 @@ void LLAppViewer::fastQuit(S32 error_code)
 
 void LLAppViewer::requestQuit()
 {
-	llinfos << "requestQuit" << llendl;
+	LL_INFOS() << "requestQuit" << LL_ENDL;
 
 	LLViewerRegion* region = gAgent.getRegion();
 	
@@ -3890,7 +3890,7 @@ static bool finish_early_exit(const LLSD& notification, const LLSD& response)
 
 void LLAppViewer::earlyExit(const std::string& name, const LLSD& substitutions)
 {
-   	llwarns << "app_early_exit: " << name << llendl;
+   	LL_WARNS() << "app_early_exit: " << name << LL_ENDL;
 	gDoDisconnect = TRUE;
 	LLNotificationsUtil::add(name, substitutions, LLSD(), finish_early_exit);
 }
@@ -3898,14 +3898,14 @@ void LLAppViewer::earlyExit(const std::string& name, const LLSD& substitutions)
 // case where we need the viewer to exit without any need for notifications
 void LLAppViewer::earlyExitNoNotify()
 {
-   	llwarns << "app_early_exit with no notification: " << llendl;
+   	LL_WARNS() << "app_early_exit with no notification: " << LL_ENDL;
 	gDoDisconnect = TRUE;
 	finish_early_exit( LLSD(), LLSD() );
 }
 
 void LLAppViewer::abortQuit()
 {
-    llinfos << "abortQuit()" << llendl;
+    LL_INFOS() << "abortQuit()" << LL_ENDL;
 	mQuitRequested = false;
 }
 
@@ -3937,7 +3937,7 @@ void LLAppViewer::migrateCacheDirectory()
 
 		if (gDirUtilp->fileExists(old_cache_dir))
 		{
-			llinfos << "Migrating cache from " << old_cache_dir << " to " << new_cache_dir << llendl;
+			LL_INFOS() << "Migrating cache from " << old_cache_dir << " to " << new_cache_dir << LL_ENDL;
 
 			// Migrate inventory cache to avoid pain to inventory database after mass update
 			S32 file_count = 0;
@@ -3955,7 +3955,7 @@ void LLAppViewer::migrateCacheDirectory()
 					file_count++;
 				}
 			}
-			llinfos << "Moved " << file_count << " files" << llendl;
+			LL_INFOS() << "Moved " << file_count << " files" << LL_ENDL;
 
 			// Nuke the old cache
 			gDirUtilp->setCacheDir(old_cache_dir);
@@ -3972,7 +3972,7 @@ void LLAppViewer::migrateCacheDirectory()
 #endif
 			if (LLFile::rmdir(old_cache_dir) != 0)
 			{
-				llwarns << "could not delete old cache directory " << old_cache_dir << llendl;
+				LL_WARNS() << "could not delete old cache directory " << old_cache_dir << LL_ENDL;
 			}
 		}
 	}
@@ -3981,10 +3981,10 @@ void LLAppViewer::migrateCacheDirectory()
 
 void dumpVFSCaches()
 {
-	llinfos << "======= Static VFS ========" << llendl;
+	LL_INFOS() << "======= Static VFS ========" << LL_ENDL;
 	gStaticVFS->listFiles();
 #if LL_WINDOWS
-	llinfos << "======= Dumping static VFS to StaticVFSDump ========" << llendl;
+	LL_INFOS() << "======= Dumping static VFS to StaticVFSDump ========" << LL_ENDL;
 	WCHAR w_str[MAX_PATH];
 	GetCurrentDirectory(MAX_PATH, w_str);
 	S32 res = LLFile::mkdir("StaticVFSDump");
@@ -3992,7 +3992,7 @@ void dumpVFSCaches()
 	{
 		if (errno != EEXIST)
 		{
-			llwarns << "Couldn't create dir StaticVFSDump" << llendl;
+			LL_WARNS() << "Couldn't create dir StaticVFSDump" << LL_ENDL;
 		}
 	}
 	SetCurrentDirectory(utf8str_to_utf16str("StaticVFSDump").c_str());
@@ -4000,16 +4000,16 @@ void dumpVFSCaches()
 	SetCurrentDirectory(w_str);
 #endif
 						
-	llinfos << "========= Dynamic VFS ====" << llendl;
+	LL_INFOS() << "========= Dynamic VFS ====" << LL_ENDL;
 	gVFS->listFiles();
 #if LL_WINDOWS
-	llinfos << "========= Dumping dynamic VFS to VFSDump ====" << llendl;
+	LL_INFOS() << "========= Dumping dynamic VFS to VFSDump ====" << LL_ENDL;
 	res = LLFile::mkdir("VFSDump");
 	if (res == -1)
 	{
 		if (errno != EEXIST)
 		{
-			llwarns << "Couldn't create dir VFSDump" << llendl;
+			LL_WARNS() << "Couldn't create dir VFSDump" << LL_ENDL;
 		}
 	}
 	SetCurrentDirectory(utf8str_to_utf16str("VFSDump").c_str());
@@ -4187,7 +4187,7 @@ bool LLAppViewer::initCache()
 			{
 				sscanf(found_file.substr(start_pos+1).c_str(), "%d", &old_salt);
 			}
-			LL_DEBUGS("AppCache") << "Default vfs data file not present, found: " << old_vfs_data_file << " Old salt: " << old_salt << llendl;
+			LL_DEBUGS("AppCache") << "Default vfs data file not present, found: " << old_vfs_data_file << " Old salt: " << old_salt << LL_ENDL;
 		}
 	}
 
@@ -4526,7 +4526,7 @@ void LLAppViewer::idle()
 	{
 		if (gRenderStartTime.getElapsedTimeF32() > qas)
 		{
-			llinfos << "Quitting after " << qas << " seconds. See setting \"QuitAfterSeconds\"." << llendl;
+			LL_INFOS() << "Quitting after " << qas << " seconds. See setting \"QuitAfterSeconds\"." << LL_ENDL;
 			LLAppViewer::instance()->forceQuit();
 		}
 	}
@@ -4610,7 +4610,7 @@ void LLAppViewer::idle()
 		// *FIX: (???) SAMANTHA
 		if (viewer_stats_timer.getElapsedTimeF32() >= SEND_STATS_PERIOD && !gDisconnected)
 		{
-			llinfos << "Transmitting sessions stats" << llendl;
+			LL_INFOS() << "Transmitting sessions stats" << LL_ENDL;
 			send_stats();
 			viewer_stats_timer.reset();
 		}
@@ -4622,12 +4622,12 @@ void LLAppViewer::idle()
 			object_debug_timer.reset();
 			if (gObjectList.mNumDeadObjectUpdates)
 			{
-				llinfos << "Dead object updates: " << gObjectList.mNumDeadObjectUpdates << llendl;
+				LL_INFOS() << "Dead object updates: " << gObjectList.mNumDeadObjectUpdates << LL_ENDL;
 				gObjectList.mNumDeadObjectUpdates = 0;
 			}
 			if (gObjectList.mNumUnknownUpdates)
 			{
-				llinfos << "Unknown object updates: " << gObjectList.mNumUnknownUpdates << llendl;
+				LL_INFOS() << "Unknown object updates: " << gObjectList.mNumUnknownUpdates << LL_ENDL;
 				gObjectList.mNumUnknownUpdates = 0;
 			}
 
@@ -5153,12 +5153,12 @@ void LLAppViewer::idleNetwork()
 
 		if( remaining_possible_decodes <= 0 )
 		{
-			llinfos << "Maxed out number of messages per frame at " << MESSAGE_MAX_PER_FRAME << llendl;
+			LL_INFOS() << "Maxed out number of messages per frame at " << MESSAGE_MAX_PER_FRAME << LL_ENDL;
 		}
 
 		if (gPrintMessagesThisFrame)
 		{
-			llinfos << "Decoded " << total_decoded << " msgs this frame!" << llendl;
+			LL_INFOS() << "Decoded " << total_decoded << " msgs this frame!" << LL_ENDL;
 			gPrintMessagesThisFrame = FALSE;
 		}
 	}
@@ -5197,7 +5197,7 @@ void LLAppViewer::disconnectViewer()
 	//	
 	// Save snapshot for next time, if we made it through initialization
 
-	llinfos << "Disconnecting viewer!" << llendl;
+	LL_INFOS() << "Disconnecting viewer!" << LL_ENDL;
 
 	// Dump our frame statistics
 
@@ -5256,12 +5256,12 @@ void LLAppViewer::disconnectViewer()
 
 void LLAppViewer::forceErrorLLError()
 {
-   	llerrs << "This is a deliberate llerror" << llendl;
+   	LL_ERRS() << "This is a deliberate llerror" << LL_ENDL;
 }
 
 void LLAppViewer::forceErrorBreakpoint()
 {
-   	llwarns << "Forcing a deliberate breakpoint" << llendl;
+   	LL_WARNS() << "Forcing a deliberate breakpoint" << LL_ENDL;
 #ifdef LL_WINDOWS
     DebugBreak();
 #endif
@@ -5270,7 +5270,7 @@ void LLAppViewer::forceErrorBreakpoint()
 
 void LLAppViewer::forceErrorBadMemoryAccess()
 {
-   	llwarns << "Forcing a deliberate bad memory access" << llendl;
+   	LL_WARNS() << "Forcing a deliberate bad memory access" << LL_ENDL;
     S32* crash = NULL;
     *crash = 0xDEADBEEF;  
     return;
@@ -5278,7 +5278,7 @@ void LLAppViewer::forceErrorBadMemoryAccess()
 
 void LLAppViewer::forceErrorInfiniteLoop()
 {
-   	llwarns << "Forcing a deliberate infinite loop" << llendl;
+   	LL_WARNS() << "Forcing a deliberate infinite loop" << LL_ENDL;
     while(true)
     {
         ;
@@ -5288,14 +5288,14 @@ void LLAppViewer::forceErrorInfiniteLoop()
  
 void LLAppViewer::forceErrorSoftwareException()
 {
-   	llwarns << "Forcing a deliberate exception" << llendl;
+   	LL_WARNS() << "Forcing a deliberate exception" << LL_ENDL;
     // *FIX: Any way to insure it won't be handled?
     throw; 
 }
 
 void LLAppViewer::forceErrorDriverCrash()
 {
-   	llwarns << "Forcing a deliberate driver crash" << llendl;
+   	LL_WARNS() << "Forcing a deliberate driver crash" << LL_ENDL;
 	glDeleteTextures(1, NULL);
 }
 
@@ -5343,7 +5343,7 @@ void LLAppViewer::pingMainloopTimeout(const std::string& state, F32 secs)
 {
 //	if(!restoreErrorTrap())
 //	{
-//		llwarns << "!!!!!!!!!!!!! Its an error trap!!!!" << state << llendl;
+//		LL_WARNS() << "!!!!!!!!!!!!! Its an error trap!!!!" << state << LL_ENDL;
 //	}
 	
 	if(mMainloopTimeout)
@@ -5402,7 +5402,7 @@ void LLAppViewer::handleLoginComplete()
 	writeDebugInfo();
 
 	// we logged in successfully, so save settings on logout
-	llinfos << "Login successful, per account settings will be saved on log out." << llendl;
+	LL_INFOS() << "Login successful, per account settings will be saved on log out." << LL_ENDL;
 	mSavePerAccountSettings=true;
 }
 
@@ -5505,7 +5505,7 @@ void LLAppViewer::launchUpdater()
 		// Although we already have the full set of paths with the filename
 		// appended, the linux-updater.bin command-line switches require us to
 		// snip the filename OFF and pass it as a separate switch argument. :-P
-		llinfos << "Got a XUI path: " << this_skin_path << llendl;
+		LL_INFOS() << "Got a XUI path: " << this_skin_path << LL_ENDL;
 		xml_search_paths.append(delim);
 		xml_search_paths.append(gDirUtilp->getDirName(this_skin_path));
 		delim = ",";
@@ -5527,9 +5527,9 @@ void LLAppViewer::launchUpdater()
 	GError *error = NULL;
 	if (!g_spawn_command_line_async(LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str(), &error))
 	{
-		llerrs << "Failed to launch updater: "
+		LL_ERRS() << "Failed to launch updater: "
 		       << error->message
-		       << llendl;
+		       << LL_ENDL;
 	}
 	if (error) {
 		g_error_free(error);
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index 4805695e7f..24d90a3cbe 100755
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -73,7 +73,7 @@
 extern "C" {
     void _wassert(const wchar_t * _Message, const wchar_t *_File, unsigned _Line)
     {
-        llerrs << _Message << llendl;
+        LL_ERRS() << _Message << LL_ENDL;
     }
 }
 #endif
@@ -89,7 +89,7 @@ void nvapi_error(NvAPI_Status status)
 {
     NvAPI_ShortString szDesc = {0};
 	NvAPI_GetErrorMessage(status, szDesc);
-	llwarns << szDesc << llendl;
+	LL_WARNS() << szDesc << LL_ENDL;
 
 	//should always trigger when asserts are enabled
 	//llassert(status == NVAPI_OK);
@@ -254,7 +254,7 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	bool ok = viewer_app_ptr->init();
 	if(!ok)
 	{
-		llwarns << "Application init failed." << llendl;
+		LL_WARNS() << "Application init failed." << LL_ENDL;
 		return -1;
 	}
 	
@@ -282,12 +282,12 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	// Have to wait until after logging is initialized to display LFH info
 	if (num_heaps > 0)
 	{
-		llinfos << "Attempted to enable LFH for " << num_heaps << " heaps." << llendl;
+		LL_INFOS() << "Attempted to enable LFH for " << num_heaps << " heaps." << LL_ENDL;
 		for(S32 i = 0; i < num_heaps; i++)
 		{
 			if (heap_enable_lfh_error[i])
 			{
-				llinfos << "  Failed to enable LFH for heap: " << i << " Error: " << heap_enable_lfh_error[i] << llendl;
+				LL_INFOS() << "  Failed to enable LFH for heap: " << i << " Error: " << heap_enable_lfh_error[i] << LL_ENDL;
 			}
 		}
 	}
@@ -306,14 +306,14 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 		// app cleanup if there was a problem.
 		//
 #if WINDOWS_CRT_MEM_CHECKS
-    llinfos << "CRT Checking memory:" << LL_ENDL;
+    LL_INFOS() << "CRT Checking memory:" << LL_ENDL;
 	if (!_CrtCheckMemory())
 	{
-		llwarns << "_CrtCheckMemory() failed at prior to cleanup!" << LL_ENDL;
+		LL_WARNS() << "_CrtCheckMemory() failed at prior to cleanup!" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << " No corruption detected." << LL_ENDL;
+		LL_INFOS() << " No corruption detected." << LL_ENDL;
 	}
 #endif
 	
@@ -322,14 +322,14 @@ int APIENTRY WINMAIN(HINSTANCE hInstance,
 	viewer_app_ptr->cleanup();
 	
 #if WINDOWS_CRT_MEM_CHECKS
-    llinfos << "CRT Checking memory:" << LL_ENDL;
+    LL_INFOS() << "CRT Checking memory:" << LL_ENDL;
 	if (!_CrtCheckMemory())
 	{
-		llwarns << "_CrtCheckMemory() failed after cleanup!" << LL_ENDL;
+		LL_WARNS() << "_CrtCheckMemory() failed after cleanup!" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << " No corruption detected." << LL_ENDL;
+		LL_INFOS() << " No corruption detected." << LL_ENDL;
 	}
 #endif
 	 
@@ -400,11 +400,11 @@ void LLAppViewerWin32::disableWinErrorReporting()
 				if( 0 == pAddERExcludedApplicationA( executable_name ) )
 				{
 					U32 error_code = GetLastError();
-					llinfos << "AddERExcludedApplication() failed with error code " << error_code << llendl;
+					LL_INFOS() << "AddERExcludedApplication() failed with error code " << error_code << LL_ENDL;
 				}
 				else
 				{
-					llinfos << "AddERExcludedApplication() success for " << executable_name << llendl;
+					LL_INFOS() << "AddERExcludedApplication() success for " << executable_name << LL_ENDL;
 				}
 			}
 			FreeLibrary( fault_rep_dll_handle );
@@ -435,7 +435,7 @@ void create_console()
 	h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
 	if (h_con_handle == -1)
 	{
-		llwarns << "create_console() failed to open stdout handle" << llendl;
+		LL_WARNS() << "create_console() failed to open stdout handle" << LL_ENDL;
 	}
 	else
 	{
@@ -449,7 +449,7 @@ void create_console()
 	h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
 	if (h_con_handle == -1)
 	{
-		llwarns << "create_console() failed to open stdin handle" << llendl;
+		LL_WARNS() << "create_console() failed to open stdin handle" << LL_ENDL;
 	}
 	else
 	{
@@ -463,7 +463,7 @@ void create_console()
 	h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
 	if (h_con_handle == -1)
 	{
-		llwarns << "create_console() failed to open stderr handle" << llendl;
+		LL_WARNS() << "create_console() failed to open stderr handle" << LL_ENDL;
 	}
 	else
 	{
@@ -490,7 +490,7 @@ bool LLAppViewerWin32::init()
 	// (Don't send our data to Microsoft--at least until we are Logo approved and have a way
 	// of getting the data back from them.)
 	//
-	// llinfos << "Turning off Windows error reporting." << llendl;
+	// LL_INFOS() << "Turning off Windows error reporting." << LL_ENDL;
 	disableWinErrorReporting();
 
 #ifndef LL_RELEASE_FOR_DOWNLOAD
@@ -669,7 +669,7 @@ bool LLAppViewerWin32::sendURLToOtherInstance(const std::string& url)
 
 	if (other_window != NULL)
 	{
-		lldebugs << "Found other window with the name '" << getWindowTitle() << "'" << llendl;
+		LL_DEBUGS() << "Found other window with the name '" << getWindowTitle() << "'" << LL_ENDL;
 		COPYDATASTRUCT cds;
 		const S32 SLURL_MESSAGE_TYPE = 0;
 		cds.dwData = SLURL_MESSAGE_TYPE;
@@ -677,8 +677,8 @@ bool LLAppViewerWin32::sendURLToOtherInstance(const std::string& url)
 		cds.lpData = (void*)url.c_str();
 
 		LRESULT msg_result = SendMessage(other_window, WM_COPYDATA, NULL, (LPARAM)&cds);
-		lldebugs << "SendMessage(WM_COPYDATA) to other window '" 
-				 << getWindowTitle() << "' returned " << msg_result << llendl;
+		LL_DEBUGS() << "SendMessage(WM_COPYDATA) to other window '" 
+				 << getWindowTitle() << "' returned " << msg_result << LL_ENDL;
 		return true;
 	}
 	return false;
@@ -710,7 +710,7 @@ std::string LLAppViewerWin32::generateSerialNumber()
 	}
 	else
 	{
-		llwarns << "GetVolumeInformation failed" << llendl;
+		LL_WARNS() << "GetVolumeInformation failed" << LL_ENDL;
 	}
 	return serial_md5;
 }
diff --git a/indra/newview/llassetuploadqueue.cpp b/indra/newview/llassetuploadqueue.cpp
index 4bdb690225..2b428aec4b 100755
--- a/indra/newview/llassetuploadqueue.cpp
+++ b/indra/newview/llassetuploadqueue.cpp
@@ -71,8 +71,8 @@ public:
 	
 	virtual void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
    	{
-		llwarns << "LLAssetUploadChainResponder Error [status:" 
-				<< statusNum << "]: " << content << llendl;
+		LL_WARNS() << "LLAssetUploadChainResponder Error [status:" 
+				<< statusNum << "]: " << content << LL_ENDL;
 		LLUpdateTaskInventoryResponder::errorWithContent(statusNum, reason, content);
    		LLAssetUploadQueue *queue = mSupplier->get();
    		if (queue)
@@ -102,7 +102,7 @@ public:
 		std::string uploader = content["uploader"];
 
 		mSupplier->log(std::string("Compiling " + mScriptName).c_str());
-		llinfos << "Compiling " << llendl;
+		LL_INFOS() << "Compiling " << LL_ENDL;
 
 		// postRaw takes ownership of mData and will delete it.
 		LLHTTPClient::postRaw(uploader, mData, mDataSize, this);
@@ -116,7 +116,7 @@ public:
 		if (content["compiled"])
 		{
 			mSupplier->log("Compilation succeeded");
-			llinfos << "Compiled!" << llendl;
+			LL_INFOS() << "Compiled!" << LL_ENDL;
 		}
 		else
 		{
@@ -127,7 +127,7 @@ public:
 				std::string str = line->asString();
 				str.erase(std::remove(str.begin(), str.end(), '\n'), str.end());
 				mSupplier->log(str);
-				llinfos << content["errors"] << llendl;
+				LL_INFOS() << content["errors"] << LL_ENDL;
 			}
 		}
 		LLUpdateTaskInventoryResponder::uploadComplete(content);
diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp
index 2564802387..d86e63589f 100755
--- a/indra/newview/llassetuploadresponders.cpp
+++ b/indra/newview/llassetuploadresponders.cpp
@@ -135,7 +135,7 @@ void on_new_single_inventory_upload_complete(
 			inventory_item_flags = (U32) server_response["inventory_flags"].asInteger();
 			if (inventory_item_flags != 0)
 			{
-				llinfos << "inventory_item_flags " << inventory_item_flags << llendl;
+				LL_INFOS() << "inventory_item_flags " << inventory_item_flags << LL_ENDL;
 			}
 		}
 		S32 creation_date_now = time_corrected();
@@ -173,7 +173,7 @@ void on_new_single_inventory_upload_complete(
 	}
 	else
 	{
-		llwarns << "Can't find a folder to put it in" << llendl;
+		LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL;
 	}
 
 	// remove the "Uploading..." message
@@ -197,7 +197,7 @@ LLAssetUploadResponder::LLAssetUploadResponder(const LLSD &post_data,
 {
 	if (!gVFS->getExists(vfile_id, asset_type))
 	{
-		llwarns << "LLAssetUploadResponder called with nonexistant vfile_id" << llendl;
+		LL_WARNS() << "LLAssetUploadResponder called with nonexistant vfile_id" << LL_ENDL;
 		mVFileID.setNull();
 		mAssetType = LLAssetType::AT_NONE;
 		return;
@@ -227,8 +227,8 @@ LLAssetUploadResponder::~LLAssetUploadResponder()
 // virtual
 void LLAssetUploadResponder::errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 {
-	llinfos << "LLAssetUploadResponder::error [status:" 
-			<< statusNum << "]: " << content << llendl;
+	LL_INFOS() << "LLAssetUploadResponder::error [status:" 
+			<< statusNum << "]: " << content << LL_ENDL;
 	LLSD args;
 	switch(statusNum)
 	{
@@ -253,7 +253,7 @@ void LLAssetUploadResponder::errorWithContent(U32 statusNum, const std::string&
 //virtual 
 void LLAssetUploadResponder::result(const LLSD& content)
 {
-	lldebugs << "LLAssetUploadResponder::result from capabilities" << llendl;
+	LL_DEBUGS() << "LLAssetUploadResponder::result from capabilities" << LL_ENDL;
 
 	std::string state = content["state"];
 
@@ -267,7 +267,7 @@ void LLAssetUploadResponder::result(const LLSD& content)
 		if (mFileName.empty())
 		{
 			// rename the file in the VFS to the actual asset id
-			// llinfos << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << llendl;
+			// LL_INFOS() << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << LL_ENDL;
 			gVFS->renameFile(mVFileID, mAssetType, content["new_asset"].asUUID(), mAssetType);
 		}
 		uploadComplete(content);
@@ -358,11 +358,11 @@ void LLNewAgentInventoryResponder::uploadFailure(const LLSD& content)
 //virtual 
 void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content)
 {
-	lldebugs << "LLNewAgentInventoryResponder::result from capabilities" << llendl;
+	LL_DEBUGS() << "LLNewAgentInventoryResponder::result from capabilities" << LL_ENDL;
 	
 	//std::ostringstream llsdxml;
 	//LLSDSerialize::toXML(content, llsdxml);
-	//llinfos << "upload complete content:\n " << llsdxml.str() << llendl;
+	//LL_INFOS() << "upload complete content:\n " << llsdxml.str() << LL_ENDL;
 
 	LLAssetType::EType asset_type = LLAssetType::lookup(mPostData["asset_type"].asString());
 	LLInventoryType::EType inventory_type = LLInventoryType::lookup(mPostData["inventory_type"].asString());
@@ -473,7 +473,7 @@ void LLSendTexLayerResponder::uploadComplete(const LLSD& content)
 	std::string result = content["state"];
 	LLUUID new_id = content["new_asset"];
 
-	llinfos << "result: " << result << " new_id: " << new_id << llendl;
+	LL_INFOS() << "result: " << result << " new_id: " << new_id << LL_ENDL;
 	if (result == "complete"
 		&& mBakedUploadData != NULL)
 	{	// Invoke 
@@ -489,8 +489,8 @@ void LLSendTexLayerResponder::uploadComplete(const LLSD& content)
 
 void LLSendTexLayerResponder::errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 {
-	llinfos << "LLSendTexLayerResponder error [status:"
-			<< statusNum << "]: " << content << llendl;
+	LL_INFOS() << "LLSendTexLayerResponder error [status:"
+			<< statusNum << "]: " << content << LL_ENDL;
 	
 	// Invoke the original callback with an error result
 	LLViewerTexLayerSetBuffer::onTextureUploadComplete(LLUUID(), (void*) mBakedUploadData, -1, LL_EXSTAT_NONE);
@@ -516,14 +516,14 @@ LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder(
 //virtual 
 void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content)
 {
-	llinfos << "LLUpdateAgentInventoryResponder::result from capabilities" << llendl;
+	LL_INFOS() << "LLUpdateAgentInventoryResponder::result from capabilities" << LL_ENDL;
 	LLUUID item_id = mPostData["item_id"];
 
 	LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem(item_id);
 	if(!item)
 	{
-		llwarns << "Inventory item for " << mVFileID
-			<< " is no longer in agent inventory." << llendl;
+		LL_WARNS() << "Inventory item for " << mVFileID
+			<< " is no longer in agent inventory." << LL_ENDL;
 		return;
 	}
 
@@ -533,8 +533,8 @@ void LLUpdateAgentInventoryResponder::uploadComplete(const LLSD& content)
 	gInventory.updateItem(new_item);
 	gInventory.notifyObservers();
 
-	llinfos << "Inventory item " << item->getName() << " saved into "
-		<< content["new_asset"].asString() << llendl;
+	LL_INFOS() << "Inventory item " << item->getName() << " saved into "
+		<< content["new_asset"].asString() << LL_ENDL;
 
 	LLInventoryType::EType inventory_type = new_item->getInventoryType();
 	switch(inventory_type)
@@ -630,7 +630,7 @@ LLUpdateTaskInventoryResponder::LLUpdateTaskInventoryResponder(const LLSD& post_
 //virtual 
 void LLUpdateTaskInventoryResponder::uploadComplete(const LLSD& content)
 {
-	llinfos << "LLUpdateTaskInventoryResponder::result from capabilities" << llendl;
+	LL_INFOS() << "LLUpdateTaskInventoryResponder::result from capabilities" << LL_ENDL;
 	LLUUID item_id = mPostData["item_id"];
 	LLUUID task_id = mPostData["task_id"];
 
@@ -711,9 +711,9 @@ public:
 	{
 		if (!gVFS->getExists(vfile_id, asset_type))
 		{
-			llwarns
+			LL_WARNS()
 				<< "LLAssetUploadResponder called with nonexistant "
-				<< "vfile_id " << vfile_id << llendl;
+				<< "vfile_id " << vfile_id << LL_ENDL;
 			mVFileID.setNull();
 			mAssetType = LLAssetType::AT_NONE;
 		}
@@ -1014,9 +1014,9 @@ void LLNewAgentInventoryVariablePriceResponder::errorWithContent(
 	const std::string& reason,
 	const LLSD& content)
 {
-	lldebugs 
+	LL_DEBUGS() 
 		<< "LLNewAgentInventoryVariablePrice::error " << statusNum 
-		<< " reason: " << reason << llendl;
+		<< " reason: " << reason << LL_ENDL;
 
 	if ( content.has("error") )
 	{
@@ -1060,7 +1060,7 @@ void LLNewAgentInventoryVariablePriceResponder::result(const LLSD& content)
 		if (mImpl->getFilename().empty())
 		{
 			// rename the file in the VFS to the actual asset id
-			// llinfos << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << llendl;
+			// LL_INFOS() << "Changing uploaded asset UUID to " << content["new_asset"].asUUID() << LL_ENDL;
 			gVFS->renameFile(
 				mImpl->getVFileID(),
 				asset_type,
diff --git a/indra/newview/llattachmentsmgr.cpp b/indra/newview/llattachmentsmgr.cpp
index ea0b8f00a4..256980eb04 100755
--- a/indra/newview/llattachmentsmgr.cpp
+++ b/indra/newview/llattachmentsmgr.cpp
@@ -110,7 +110,7 @@ void LLAttachmentsMgr::onIdle()
 		LLViewerInventoryItem* item = gInventory.getItem(attachment.mItemID);
 		if (!item)
 		{
-			llinfos << "Attempted to add non-existant item ID:" << attachment.mItemID << llendl;
+			LL_INFOS() << "Attempted to add non-existant item ID:" << attachment.mItemID << LL_ENDL;
 			continue;
 		}
 		S32 attachment_pt = attachment.mAttachmentPt;
diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index 1d774e6eac..9b874b7ddf 100755
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -979,7 +979,7 @@ bool LLAvatarActions::handleRemove(const LLSD& notification, const LLSD& respons
 
 			case 1: // NO
 			default:
-				llinfos << "No removal performed." << llendl;
+				LL_INFOS() << "No removal performed." << LL_ENDL;
 				break;
 			}
 		}
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index 0d1ecc9c47..7a49b77490 100755
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -60,7 +60,7 @@ bool LLAvatarIconIDCache::LLAvatarIconIDCacheItem::expired()
 
 void LLAvatarIconIDCache::load	()
 {
-	llinfos << "Loading avatar icon id cache." << llendl;
+	LL_INFOS() << "Loading avatar icon id cache." << LL_ENDL;
 	
 	// build filename for each user
 	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, mFilename);
@@ -105,7 +105,7 @@ void LLAvatarIconIDCache::save	()
 	llofstream file (resolved_filename);
 	if (!file.is_open())
 	{
-		llwarns << "can't open avatar icons cache file\"" << mFilename << "\" for writing" << llendl;
+		LL_WARNS() << "can't open avatar icons cache file\"" << mFilename << "\" for writing" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp
index f095ef25d1..856eb3414e 100755
--- a/indra/newview/llavatarpropertiesprocessor.cpp
+++ b/indra/newview/llavatarpropertiesprocessor.cpp
@@ -170,11 +170,11 @@ void LLAvatarPropertiesProcessor::sendAvatarPropertiesUpdate(const LLAvatarData*
 {
 	if (!gAgent.isInitialized() || (gAgent.getID() == LLUUID::null))
 	{
-		llwarns << "Sending avatarinfo update DENIED - invalid agent" << llendl;
+		LL_WARNS() << "Sending avatarinfo update DENIED - invalid agent" << LL_ENDL;
 		return;
 	}
 
-	llinfos << "Sending avatarinfo update" << llendl;
+	LL_INFOS() << "Sending avatarinfo update" << LL_ENDL;
 
 	// This value is required by sendAvatarPropertiesUpdate method.
 	//A profile should never be mature. (From the original code)
diff --git a/indra/newview/llbuycurrencyhtml.cpp b/indra/newview/llbuycurrencyhtml.cpp
index 459123a5d8..1c69dadb12 100755
--- a/indra/newview/llbuycurrencyhtml.cpp
+++ b/indra/newview/llbuycurrencyhtml.cpp
@@ -148,7 +148,7 @@ void LLBuyCurrencyHTML::showDialog( bool specific_sum_requested, const std::stri
 	}
 	else
 	{
-		llwarns << "Buy Currency (HTML) Floater not found" << llendl;
+		LL_WARNS() << "Buy Currency (HTML) Floater not found" << LL_ENDL;
 	};
 }
 
diff --git a/indra/newview/llcallbacklist.cpp b/indra/newview/llcallbacklist.cpp
index 79ec43dfe9..59ecbdd0ea 100755
--- a/indra/newview/llcallbacklist.cpp
+++ b/indra/newview/llcallbacklist.cpp
@@ -56,7 +56,7 @@ void LLCallbackList::addFunction( callback_t func, void *data)
 {
 	if (!func)
 	{
-		llerrs << "LLCallbackList::addFunction - function is NULL" << llendl;
+		LL_ERRS() << "LLCallbackList::addFunction - function is NULL" << LL_ENDL;
 		return;
 	}
 
@@ -234,14 +234,14 @@ void doPeriodically(bool_func_t callable, F32 seconds)
 void test1(void *data)
 {
 	S32 *s32_data = (S32 *)data;
-	llinfos << "testfunc1 " << *s32_data << llendl;
+	LL_INFOS() << "testfunc1 " << *s32_data << LL_ENDL;
 }
 
 
 void test2(void *data)
 {
 	S32 *s32_data = (S32 *)data;
-	llinfos << "testfunc2 " << *s32_data << llendl;
+	LL_INFOS() << "testfunc2 " << *s32_data << LL_ENDL;
 }
 
 
@@ -252,54 +252,54 @@ LLCallbackList::test()
 	S32 b = 2;
 	LLCallbackList *list = new LLCallbackList;
 
-	llinfos << "Testing LLCallbackList" << llendl;
+	LL_INFOS() << "Testing LLCallbackList" << LL_ENDL;
 
 	if (!list->deleteFunction(NULL))
 	{
-		llinfos << "passed 1" << llendl;
+		LL_INFOS() << "passed 1" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "error, removed function from empty list" << llendl;
+		LL_INFOS() << "error, removed function from empty list" << LL_ENDL;
 	}
 
-	// llinfos << "This should crash" << llendl;
+	// LL_INFOS() << "This should crash" << LL_ENDL;
 	// list->addFunction(NULL);
 
 	list->addFunction(&test1, &a);
 	list->addFunction(&test1, &a);
 
-	llinfos << "Expect: test1 1, test1 1" << llendl;
+	LL_INFOS() << "Expect: test1 1, test1 1" << LL_ENDL;
 	list->callFunctions();
 
 	list->addFunction(&test1, &b);
 	list->addFunction(&test2, &b);
 
-	llinfos << "Expect: test1 1, test1 1, test1 2, test2 2" << llendl;
+	LL_INFOS() << "Expect: test1 1, test1 1, test1 2, test2 2" << LL_ENDL;
 	list->callFunctions();
 
 	if (list->deleteFunction(&test1, &b))
 	{
-		llinfos << "passed 3" << llendl;
+		LL_INFOS() << "passed 3" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "error removing function" << llendl;
+		LL_INFOS() << "error removing function" << LL_ENDL;
 	}
 
-	llinfos << "Expect: test1 1, test1 1, test2 2" << llendl;
+	LL_INFOS() << "Expect: test1 1, test1 1, test2 2" << LL_ENDL;
 	list->callFunctions();
 
 	list->deleteAllFunctions();
 
-	llinfos << "Expect nothing" << llendl;
+	LL_INFOS() << "Expect nothing" << LL_ENDL;
 	list->callFunctions();
 
-	llinfos << "nothing :-)" << llendl;
+	LL_INFOS() << "nothing :-)" << LL_ENDL;
 
 	delete list;
 
-	llinfos << "test complete" << llendl;
+	LL_INFOS() << "test complete" << LL_ENDL;
 }
 
 #endif  // _DEBUG
diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp
index 3da77857c6..4fe451be46 100755
--- a/indra/newview/llcallingcard.cpp
+++ b/indra/newview/llcallingcard.cpp
@@ -253,21 +253,21 @@ S32 LLAvatarTracker::addBuddyList(const LLAvatarTracker::buddy_map_t& buds)
 			// IDEVO: is this necessary?  name is unused?
 			gCacheName->getFullName(agent_id, full_name);
 			addChangedMask(LLFriendObserver::ADD, agent_id);
-			lldebugs << "Added buddy " << agent_id
+			LL_DEBUGS() << "Added buddy " << agent_id
 					<< ", " << (mBuddyInfo[agent_id]->isOnline() ? "Online" : "Offline")
 					<< ", TO: " << mBuddyInfo[agent_id]->getRightsGrantedTo()
 					<< ", FROM: " << mBuddyInfo[agent_id]->getRightsGrantedFrom()
-					<< llendl;
+					<< LL_ENDL;
 		}
 		else
 		{
 			LLRelationship* e_r = (*existing_buddy).second;
 			LLRelationship* n_r = (*itr).second;
-			llwarns << "!! Add buddy for existing buddy: " << agent_id
+			LL_WARNS() << "!! Add buddy for existing buddy: " << agent_id
 					<< " [" << (e_r->isOnline() ? "Online" : "Offline") << "->" << (n_r->isOnline() ? "Online" : "Offline")
 					<< ", " <<  e_r->getRightsGrantedTo() << "->" << n_r->getRightsGrantedTo()
 					<< ", " <<  e_r->getRightsGrantedTo() << "->" << n_r->getRightsGrantedTo()
-					<< "]" << llendl;
+					<< "]" << LL_ENDL;
 		}
 	}
 	notifyObservers();
@@ -288,7 +288,7 @@ void LLAvatarTracker::copyBuddyList(buddy_map_t& buddies) const
 
 void LLAvatarTracker::terminateBuddy(const LLUUID& id)
 {
-	lldebugs << "LLAvatarTracker::terminateBuddy()" << llendl;
+	LL_DEBUGS() << "LLAvatarTracker::terminateBuddy()" << LL_ENDL;
 	LLRelationship* buddy = get_ptr_in_map(mBuddyInfo, id);
 	if(!buddy) return;
 	mBuddyInfo.erase(id);
@@ -326,12 +326,12 @@ void LLAvatarTracker::setBuddyOnline(const LLUUID& id, bool is_online)
 	{
 		info->online(is_online);
 		addChangedMask(LLFriendObserver::ONLINE, id);
-		lldebugs << "Set buddy " << id << (is_online ? " Online" : " Offline") << llendl;
+		LL_DEBUGS() << "Set buddy " << id << (is_online ? " Online" : " Offline") << LL_ENDL;
 	}
 	else
 	{
-		llwarns << "!! No buddy info found for " << id 
-				<< ", setting to " << (is_online ? "Online" : "Offline") << llendl;
+		LL_WARNS() << "!! No buddy info found for " << id 
+				<< ", setting to " << (is_online ? "Online" : "Offline") << LL_ENDL;
 	}
 }
 
@@ -378,7 +378,7 @@ void LLAvatarTracker::empower(const LLUUID& id, bool grant)
 
 void LLAvatarTracker::empowerList(const buddy_map_t& list, bool grant)
 {
-	llwarns << "LLAvatarTracker::empowerList() not implemented." << llendl;
+	LL_WARNS() << "LLAvatarTracker::empowerList() not implemented." << LL_ENDL;
 /*
 	LLMessageSystem* msg = gMessageSystem;
 	const char* message_name;
@@ -590,14 +590,14 @@ void LLAvatarTracker::agentFound(const LLUUID& prey,
 // 	static
 void LLAvatarTracker::processOnlineNotification(LLMessageSystem* msg, void**)
 {
-	lldebugs << "LLAvatarTracker::processOnlineNotification()" << llendl;
+	LL_DEBUGS() << "LLAvatarTracker::processOnlineNotification()" << LL_ENDL;
 	instance().processNotify(msg, true);
 }
 
 // 	static
 void LLAvatarTracker::processOfflineNotification(LLMessageSystem* msg, void**)
 {
-	lldebugs << "LLAvatarTracker::processOfflineNotification()" << llendl;
+	LL_DEBUGS() << "LLAvatarTracker::processOfflineNotification()" << LL_ENDL;
 	instance().processNotify(msg, false);
 }
 
@@ -649,7 +649,7 @@ void LLAvatarTracker::processChange(LLMessageSystem* msg)
 
 void LLAvatarTracker::processChangeUserRights(LLMessageSystem* msg, void**)
 {
-	lldebugs << "LLAvatarTracker::processChangeUserRights()" << llendl;
+	LL_DEBUGS() << "LLAvatarTracker::processChangeUserRights()" << LL_ENDL;
 	instance().processChange(msg);
 }
 
@@ -658,7 +658,7 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online)
 	S32 count = msg->getNumberOfBlocksFast(_PREHASH_AgentBlock);
 	BOOL chat_notify = gSavedSettings.getBOOL("ChatOnlineNotification");
 
-	lldebugs << "Received " << count << " online notifications **** " << llendl;
+	LL_DEBUGS() << "Received " << count << " online notifications **** " << LL_ENDL;
 	if(count > 0)
 	{
 		LLUUID agent_id;
@@ -680,8 +680,8 @@ void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online)
 			}
 			else
 			{
-				llwarns << "Received online notification for unknown buddy: " 
-					<< agent_id << " is " << (online ? "ONLINE" : "OFFLINE") << llendl;
+				LL_WARNS() << "Received online notification for unknown buddy: " 
+					<< agent_id << " is " << (online ? "ONLINE" : "OFFLINE") << LL_ENDL;
 			}
 
 			if(tracking_id == agent_id)
@@ -793,8 +793,8 @@ void LLTrackingData::agentFound(const LLUUID& prey,
 {
 	if(prey != mAvatarID)
 	{
-		llwarns << "LLTrackingData::agentFound() - found " << prey
-				<< " but looking for " << mAvatarID << llendl;
+		LL_WARNS() << "LLTrackingData::agentFound() - found " << prey
+				<< " but looking for " << mAvatarID << LL_ENDL;
 	}
 	mHaveInfo = true;
 	mAgentGone.setTimerExpirySec(OFFLINE_SECONDS);
diff --git a/indra/newview/llcaphttpsender.cpp b/indra/newview/llcaphttpsender.cpp
index 16bb48da93..b2524d14f8 100755
--- a/indra/newview/llcaphttpsender.cpp
+++ b/indra/newview/llcaphttpsender.cpp
@@ -40,8 +40,8 @@ void LLCapHTTPSender::send(const LLHost& host, const std::string& message,
 								  const LLSD& body, 
 								  LLHTTPClient::ResponderPtr response) const
 {
-	llinfos << "LLCapHTTPSender::send: message " << message
-			<< " to host " << host << llendl;
+	LL_INFOS() << "LLCapHTTPSender::send: message " << message
+			<< " to host " << host << LL_ENDL;
 	LLSD llsd;
 	llsd["message"] = message;
 	llsd["body"] = body;
diff --git a/indra/newview/llchannelmanager.cpp b/indra/newview/llchannelmanager.cpp
index 43757d0174..6c8d19d742 100755
--- a/indra/newview/llchannelmanager.cpp
+++ b/indra/newview/llchannelmanager.cpp
@@ -50,7 +50,7 @@ LLChannelManager::LLChannelManager()
 	
 	if(!gViewerWindow)
 	{
-		llerrs << "LLChannelManager::LLChannelManager() - viwer window is not initialized yet" << llendl;
+		LL_ERRS() << "LLChannelManager::LLChannelManager() - viwer window is not initialized yet" << LL_ENDL;
 	}
 }
 
@@ -249,7 +249,7 @@ LLNotificationsUI::LLScreenChannel* LLChannelManager::getNotificationScreenChann
 
 	if (channel == NULL)
 	{
-		llwarns << "Can't find screen channel by NotificationChannelUUID" << llendl;
+		LL_WARNS() << "Can't find screen channel by NotificationChannelUUID" << LL_ENDL;
 		llassert(!"Can't find screen channel by NotificationChannelUUID");
 	}
 
diff --git a/indra/newview/llchatbar.cpp b/indra/newview/llchatbar.cpp
index 9b57587237..0adf469858 100755
--- a/indra/newview/llchatbar.cpp
+++ b/indra/newview/llchatbar.cpp
@@ -521,10 +521,10 @@ void LLChatBar::onInputEditorKeystroke( LLLineEditor* caller, void* userdata )
 			}
 		}
 
-		//llinfos << "GESTUREDEBUG " << trigger 
+		//LL_INFOS() << "GESTUREDEBUG " << trigger 
 		//	<< " len " << length
 		//	<< " outlen " << out_str.getLength()
-		//	<< llendl;
+		//	<< LL_ENDL;
 	}
 }
 
@@ -588,22 +588,22 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL
 	{
 		if (type == CHAT_TYPE_WHISPER)
 		{
-			lldebugs << "You whisper " << utf8_text << llendl;
+			LL_DEBUGS() << "You whisper " << utf8_text << LL_ENDL;
 			gAgent.sendAnimationRequest(ANIM_AGENT_WHISPER, ANIM_REQUEST_START);
 		}
 		else if (type == CHAT_TYPE_NORMAL)
 		{
-			lldebugs << "You say " << utf8_text << llendl;
+			LL_DEBUGS() << "You say " << utf8_text << LL_ENDL;
 			gAgent.sendAnimationRequest(ANIM_AGENT_TALK, ANIM_REQUEST_START);
 		}
 		else if (type == CHAT_TYPE_SHOUT)
 		{
-			lldebugs << "You shout " << utf8_text << llendl;
+			LL_DEBUGS() << "You shout " << utf8_text << LL_ENDL;
 			gAgent.sendAnimationRequest(ANIM_AGENT_SHOUT, ANIM_REQUEST_START);
 		}
 		else
 		{
-			llinfos << "send_chat_from_viewer() - invalid volume" << llendl;
+			LL_INFOS() << "send_chat_from_viewer() - invalid volume" << LL_ENDL;
 			return;
 		}
 	}
@@ -611,7 +611,7 @@ void LLChatBar::sendChatFromViewer(const LLWString &wtext, EChatType type, BOOL
 	{
 		if (type != CHAT_TYPE_START && type != CHAT_TYPE_STOP)
 		{
-			lldebugs << "Channel chat: " << utf8_text << llendl;
+			LL_DEBUGS() << "Channel chat: " << utf8_text << LL_ENDL;
 		}
 	}
 
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp
index 88884042d4..06c452168c 100755
--- a/indra/newview/llchiclet.cpp
+++ b/indra/newview/llchiclet.cpp
@@ -192,7 +192,7 @@ void LLNotificationChiclet::createMenu()
 {
 	if(mContextMenu)
 	{
-		llwarns << "Menu already exists" << llendl;
+		LL_WARNS() << "Menu already exists" << LL_ENDL;
 		return;
 	}
 
@@ -372,7 +372,7 @@ bool LLIMChiclet::canCreateMenu()
 {
 	if(mPopupMenu)
 	{
-		llwarns << "Menu already exists" << llendl;
+		LL_WARNS() << "Menu already exists" << LL_ENDL;
 		return false;
 	}
 	if(getSessionId().isNull())
@@ -718,7 +718,7 @@ void LLChicletPanel::setChicletToggleState(const LLUUID& session_id, bool toggle
 {
 	if(session_id.isNull())
 	{
-		llwarns << "Null Session ID" << llendl;
+		LL_WARNS() << "Null Session ID" << LL_ENDL;
 	}
 
 	// toggle off all chiclets, except specified
diff --git a/indra/newview/llchiclet.h b/indra/newview/llchiclet.h
index efaf03384a..d5e3a55fdf 100755
--- a/indra/newview/llchiclet.h
+++ b/indra/newview/llchiclet.h
@@ -825,13 +825,13 @@ T* LLChicletPanel::createChiclet(const LLUUID& session_id, S32 index)
 	T* chiclet = LLUICtrlFactory::create<T>(params);
 	if(!chiclet)
 	{
-		llwarns << "Could not create chiclet" << llendl;
+		LL_WARNS() << "Could not create chiclet" << LL_ENDL;
 		return NULL;
 	}
 	if(!addChiclet(chiclet, index))
 	{
 		delete chiclet;
-		llwarns << "Could not add chiclet to chiclet panel" << llendl;
+		LL_WARNS() << "Could not add chiclet to chiclet panel" << LL_ENDL;
 		return NULL;
 	}
 
@@ -871,7 +871,7 @@ T* LLChicletPanel::findChiclet(const LLUUID& im_session_id)
 			T* result = dynamic_cast<T*>(chiclet);
 			if(!result)
 			{
-				llwarns << "Found chiclet but of wrong type " << llendl;
+				LL_WARNS() << "Found chiclet but of wrong type " << LL_ENDL;
 				continue;
 			}
 			return result;
@@ -891,7 +891,7 @@ template<class T> T* LLChicletPanel::getChiclet(S32 index)
 	T*result = dynamic_cast<T*>(chiclet);
 	if(!result && chiclet)
 	{
-		llwarns << "Found chiclet but of wrong type " << llendl;
+		LL_WARNS() << "Found chiclet but of wrong type " << LL_ENDL;
 	}
 	return result;
 }
diff --git a/indra/newview/llchicletbar.cpp b/indra/newview/llchicletbar.cpp
index a51c844775..28e367fbe1 100755
--- a/indra/newview/llchicletbar.cpp
+++ b/indra/newview/llchicletbar.cpp
@@ -90,16 +90,16 @@ void LLChicletBar::log(LLView* panel, const std::string& descr)
 void LLChicletBar::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
 	static S32 debug_calling_number = 0;
-	lldebugs << "**************************************** " << ++debug_calling_number << llendl;
+	LL_DEBUGS() << "**************************************** " << ++debug_calling_number << LL_ENDL;
 
 	S32 current_width = getRect().getWidth();
 	S32 delta_width = width - current_width;
-	lldebugs << "Reshaping: "
+	LL_DEBUGS() << "Reshaping: "
 		<< ", width: " << width
 		<< ", cur width: " << current_width
 		<< ", delta_width: " << delta_width
 		<< ", called_from_parent: " << called_from_parent
-		<< llendl;
+		<< LL_ENDL;
 
 	if (mChicletPanel)			log(mChicletPanel, "before");
 
@@ -155,7 +155,7 @@ void LLChicletBar::reshape(S32 width, S32 height, BOOL called_from_parent)
 
 	if (should_be_reshaped)
 	{
-		lldebugs << "Reshape all children with width: " << width << llendl;
+		LL_DEBUGS() << "Reshape all children with width: " << width << LL_ENDL;
 		LLPanel::reshape(width, height, called_from_parent);
 	}
 
@@ -174,23 +174,23 @@ S32 LLChicletBar::processWidthDecreased(S32 delta_width)
 		// we have some space to decrease chiclet panel
 		S32 shrink_by = llmin(-delta_width, chiclet_panel_shrink_headroom);
 
-		lldebugs << "delta_width: " << delta_width
+		LL_DEBUGS() << "delta_width: " << delta_width
 			<< ", panel_delta_min: " << chiclet_panel_shrink_headroom
 			<< ", shrink_by: " << shrink_by
-			<< llendl;
+			<< LL_ENDL;
 
 		// is chiclet panel wide enough to process resizing?
 		delta_width += chiclet_panel_shrink_headroom;
 
 		still_should_be_processed = delta_width < 0;
 
-		lldebugs << "Shrinking chiclet panel by " << shrink_by << " px" << llendl;
+		LL_DEBUGS() << "Shrinking chiclet panel by " << shrink_by << " px" << LL_ENDL;
 		mChicletPanel->getParent()->reshape(mChicletPanel->getParent()->getRect().getWidth() - shrink_by, mChicletPanel->getParent()->getRect().getHeight());
 		log(mChicletPanel, "after processing panel decreasing via chiclet panel");
 
-		lldebugs << "RS_CHICLET_PANEL"
+		LL_DEBUGS() << "RS_CHICLET_PANEL"
 			<< ", delta_width: " << delta_width
-			<< llendl;
+			<< LL_ENDL;
 	}
 
 	S32 extra_shrink_width = 0;
@@ -198,8 +198,8 @@ S32 LLChicletBar::processWidthDecreased(S32 delta_width)
 	if (still_should_be_processed)
 	{
 		extra_shrink_width = -delta_width;
-		llwarns << "There is no enough width to reshape all children: "
-			<< extra_shrink_width << llendl;
+		LL_WARNS() << "There is no enough width to reshape all children: "
+			<< extra_shrink_width << LL_ENDL;
 	}
 
 	return extra_shrink_width;
diff --git a/indra/newview/llclassifiedstatsresponder.cpp b/indra/newview/llclassifiedstatsresponder.cpp
index 1e1c9039fb..bc7815fba2 100755
--- a/indra/newview/llclassifiedstatsresponder.cpp
+++ b/indra/newview/llclassifiedstatsresponder.cpp
@@ -61,5 +61,5 @@ void LLClassifiedStatsResponder::result(const LLSD& content)
 /*virtual*/
 void LLClassifiedStatsResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llinfos << "LLClassifiedStatsResponder::error [status:" << status << "]: " << content << llendl;
+	LL_INFOS() << "LLClassifiedStatsResponder::error [status:" << status << "]: " << content << LL_ENDL;
 }
diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp
index b5bb303b65..b2cd90af22 100755
--- a/indra/newview/llcofwearables.cpp
+++ b/indra/newview/llcofwearables.cpp
@@ -382,14 +382,14 @@ void LLCOFWearables::refresh()
 	const LLUUID cof_id = LLAppearanceMgr::instance().getCOF();
 	if (cof_id.isNull())
 	{
-		llwarns << "COF ID cannot be NULL" << llendl;
+		LL_WARNS() << "COF ID cannot be NULL" << LL_ENDL;
 		return;
 	}
 
 	LLViewerInventoryCategory* catp = gInventory.getCategory(cof_id);
 	if (!catp)
 	{
-		llwarns << "COF category cannot be NULL" << llendl;
+		LL_WARNS() << "COF category cannot be NULL" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp
index 17d403bbe1..559a02bbd9 100755
--- a/indra/newview/llcommandlineparser.cpp
+++ b/indra/newview/llcommandlineparser.cpp
@@ -283,13 +283,13 @@ bool LLCommandLineParser::parseAndStoreResults(po::command_line_parser& clp)
     }
     catch(po::error& e)
     {
-        llwarns << "Caught Error:" << e.what() << llendl;
+        LL_WARNS() << "Caught Error:" << e.what() << LL_ENDL;
 		mErrorMsg = e.what();
         return false;
     }
     catch(LLCLPError& e)
     {
-        llwarns << "Caught Error:" << e.what() << llendl;
+        LL_WARNS() << "Caught Error:" << e.what() << LL_ENDL;
 		mErrorMsg = e.what();
         return false;
     }
@@ -329,7 +329,7 @@ bool LLCommandLineParser::parseAndStoreResults(po::command_line_parser& clp)
 			<< last_option << " "
 			<< last_value;
 
-        llwarns << msg.str() << llendl;
+        LL_WARNS() << msg.str() << LL_ENDL;
 		mErrorMsg = msg.str();
         return false;
     } 
@@ -401,7 +401,7 @@ void LLCommandLineParser::printOptions() const
         {
             oss << t_itr->c_str() << " ";
         }
-        llinfos << oss.str() << llendl;
+        LL_INFOS() << oss.str() << LL_ENDL;
     }
 }
 
@@ -446,7 +446,7 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value,
         case TYPE_BOOLEAN:
             if(value.size() > 1)
             {
-                llwarns << "Ignoring extra tokens." << llendl; 
+                LL_WARNS() << "Ignoring extra tokens." << LL_ENDL; 
             }
               
             if(value.size() > 0)
@@ -485,7 +485,7 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value,
                 {
 					if(value.size() > 1)
 					{
-						llwarns << "Ignoring extra tokens mapped to the setting: " << opt_name << "." << llendl; 
+						LL_WARNS() << "Ignoring extra tokens mapped to the setting: " << opt_name << "." << LL_ENDL; 
 					}
 
                     LLSD llsdValue;
@@ -498,10 +498,10 @@ void setControlValueCB(const LLCommandLineParser::token_vector_t& value,
     }
     else
     {
-        llwarns << "Command Line option mapping '" 
+        LL_WARNS() << "Command Line option mapping '" 
             << opt_name 
             << "' not found! Ignoring." 
-            << llendl;
+            << LL_ENDL;
     }
 }
 
diff --git a/indra/newview/llcompilequeue.cpp b/indra/newview/llcompilequeue.cpp
index 055a69727e..b0916d769a 100755
--- a/indra/newview/llcompilequeue.cpp
+++ b/indra/newview/llcompilequeue.cpp
@@ -111,8 +111,8 @@ void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object,
 											 S32,
 											 void* q_id)
 {
-	llinfos << "LLFloaterScriptQueue::inventoryChanged() for  object "
-			<< viewer_object->getID() << llendl;
+	LL_INFOS() << "LLFloaterScriptQueue::inventoryChanged() for  object "
+			<< viewer_object->getID() << LL_ENDL;
 
 	//Remove this listener from the object since its
 	//listener callback is now being executed.
@@ -137,8 +137,8 @@ void LLFloaterScriptQueue::inventoryChanged(LLViewerObject* viewer_object,
 		// something went wrong...
 		// note that we're not working on this one, and move onto the
 		// next object in the list.
-		llwarns << "No inventory for " << mCurrentObjectID
-				<< llendl;
+		LL_WARNS() << "No inventory for " << mCurrentObjectID
+				<< LL_ENDL;
 		nextObject();
 	}
 }
@@ -184,16 +184,16 @@ BOOL LLFloaterScriptQueue::nextObject()
 	do
 	{
 		count = mObjectIDs.size();
-		llinfos << "LLFloaterScriptQueue::nextObject() - " << count
-				<< " objects left to process." << llendl;
+		LL_INFOS() << "LLFloaterScriptQueue::nextObject() - " << count
+				<< " objects left to process." << LL_ENDL;
 		mCurrentObjectID.setNull();
 		if(count > 0)
 		{
 			successful_start = popNext();
 		}
-		llinfos << "LLFloaterScriptQueue::nextObject() "
+		LL_INFOS() << "LLFloaterScriptQueue::nextObject() "
 				<< (successful_start ? "successful" : "unsuccessful")
-				<< llendl; 
+				<< LL_ENDL; 
 	} while((mObjectIDs.size() > 0) && !successful_start);
 	if(isDone() && !mDone)
 	{
@@ -215,14 +215,14 @@ BOOL LLFloaterScriptQueue::popNext()
 	if(mCurrentObjectID.isNull() && (count > 0))
 	{
 		mCurrentObjectID = mObjectIDs.at(0);
-		llinfos << "LLFloaterScriptQueue::popNext() - mCurrentID: "
-				<< mCurrentObjectID << llendl;
+		LL_INFOS() << "LLFloaterScriptQueue::popNext() - mCurrentID: "
+				<< mCurrentObjectID << LL_ENDL;
 		mObjectIDs.erase(mObjectIDs.begin());
 		LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID);
 		if(obj)
 		{
-			llinfos << "LLFloaterScriptQueue::popNext() requesting inv for "
-					<< mCurrentObjectID << llendl;
+			LL_INFOS() << "LLFloaterScriptQueue::popNext() requesting inv for "
+					<< mCurrentObjectID << LL_ENDL;
 			LLUUID* id = new LLUUID(getKey().asUUID());
 			registerVOInventoryListener(obj,id);
 			requestVOInventory();
@@ -328,7 +328,7 @@ void LLFloaterCompileQueue::handleInventory(LLViewerObject *viewer_object,
 												 viewer_object->getID(),
 												 itemp->getUUID());
 
-			//llinfos << "ITEM NAME 2: " << names.get(i) << llendl;
+			//LL_INFOS() << "ITEM NAME 2: " << names.get(i) << LL_ENDL;
 			gAssetStorage->getInvItemAsset(viewer_object->getRegion()->getHost(),
 				gAgent.getID(),
 				gAgent.getSessionID(),
@@ -349,7 +349,7 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 										  LLAssetType::EType type,
 										  void* user_data, S32 status, LLExtStat ext_status)
 {
-	llinfos << "LLFloaterCompileQueue::scriptArrived()" << llendl;
+	LL_INFOS() << "LLFloaterCompileQueue::scriptArrived()" << LL_ENDL;
 	LLScriptQueueData* data = (LLScriptQueueData*)user_data;
 	if(!data)
 	{
@@ -360,7 +360,7 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 	std::string buffer;
 	if(queue && (0 == status))
 	{
-		//llinfos << "ITEM NAME 3: " << data->mScriptName << llendl;
+		//LL_INFOS() << "ITEM NAME 3: " << data->mScriptName << LL_ENDL;
 
 		// Dump this into a file on the local disk so we can compile it.
 		std::string filename;
@@ -414,7 +414,7 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
 			buffer = LLTrans::getString("CompileQueueUnknownFailure") + (" ") + data->mScriptName;
 		}
 
-		llwarns << "Problem downloading script asset." << llendl;
+		LL_WARNS() << "Problem downloading script asset." << LL_ENDL;
 		if(queue) queue->removeItemByItemID(data->mItemId);
 	}
 	if(queue && (buffer.size() > 0)) 
@@ -546,7 +546,7 @@ LLFloaterNotRunQueue::~LLFloaterNotRunQueue()
 
 void LLFloaterCompileQueue::removeItemByItemID(const LLUUID& asset_id)
 {
-	llinfos << "LLFloaterCompileQueue::removeItemByAssetID()" << llendl;
+	LL_INFOS() << "LLFloaterCompileQueue::removeItemByAssetID()" << LL_ENDL;
 	for(S32 i = 0; i < mCurrentScripts.size(); )
 	{
 		if(asset_id == mCurrentScripts.at(i)->getUUID())
diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index 7ecc572a8a..8dd148e304 100755
--- a/indra/newview/llconversationlog.cpp
+++ b/indra/newview/llconversationlog.cpp
@@ -455,14 +455,14 @@ bool LLConversationLog::saveToFile(const std::string& filename)
 {
 	if (!filename.size())
 	{
-		llwarns << "Call log list filename is empty!" << llendl;
+		LL_WARNS() << "Call log list filename is empty!" << LL_ENDL;
 		return false;
 	}
 
 	LLFILE* fp = LLFile::fopen(filename, "wb");
 	if (!fp)
 	{
-		llwarns << "Couldn't open call log list" << filename << llendl;
+		LL_WARNS() << "Couldn't open call log list" << filename << LL_ENDL;
 		return false;
 	}
 
@@ -496,14 +496,14 @@ bool LLConversationLog::loadFromFile(const std::string& filename)
 {
 	if(!filename.size())
 	{
-		llwarns << "Call log list filename is empty!" << llendl;
+		LL_WARNS() << "Call log list filename is empty!" << LL_ENDL;
 		return false;
 	}
 
 	LLFILE* fp = LLFile::fopen(filename, "rb");
 	if (!fp)
 	{
-		llwarns << "Couldn't open call log list" << filename << llendl;
+		LL_WARNS() << "Couldn't open call log list" << filename << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llconversationmodel.cpp b/indra/newview/llconversationmodel.cpp
index c74ce24872..fffc1c7ced 100755
--- a/indra/newview/llconversationmodel.cpp
+++ b/indra/newview/llconversationmodel.cpp
@@ -360,7 +360,7 @@ void LLConversationItemSession::setDistance(const LLUUID& participant_id, F64 di
 
 void LLConversationItemSession::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-    lldebugs << "LLConversationItemParticipant::buildContextMenu()" << llendl;
+    LL_DEBUGS() << "LLConversationItemParticipant::buildContextMenu()" << LL_ENDL;
     menuentry_vec_t items;
     menuentry_vec_t disabled_items;
 
@@ -431,7 +431,7 @@ const bool LLConversationItemSession::getTime(F64& time) const
 void LLConversationItemSession::dumpDebugData(bool dump_children)
 {
 	// Session info
-	llinfos << "Merov debug : session " << this << ", uuid = " << mUUID << ", name = " << mName << ", is loaded = " << mIsLoaded << llendl;
+	LL_INFOS() << "Merov debug : session " << this << ", uuid = " << mUUID << ", name = " << mName << ", is loaded = " << mIsLoaded << LL_ENDL;
 	// Children info
 	if (dump_children)
 	{
@@ -549,7 +549,7 @@ LLConversationItemSession* LLConversationItemParticipant::getParentSession()
 
 void LLConversationItemParticipant::dumpDebugData()
 {
-	llinfos << "Merov debug : participant, uuid = " << mUUID << ", name = " << mName << ", display name = " << mDisplayName << ", muted = " << isVoiceMuted() << ", moderator = " << mIsModerator << llendl;
+	LL_INFOS() << "Merov debug : participant, uuid = " << mUUID << ", name = " << mName << ", display name = " << mDisplayName << ", muted = " << isVoiceMuted() << ", moderator = " << mIsModerator << LL_ENDL;
 }
 
 void LLConversationItemParticipant::setDisplayModeratorRole(bool displayRole)
diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp
index 8af2f4ea33..131675310e 100755
--- a/indra/newview/lldaycyclemanager.cpp
+++ b/indra/newview/lldaycyclemanager.cpp
@@ -193,7 +193,7 @@ bool LLDayCycleManager::loadPreset(const std::string& path)
 	LLSD data = LLWLDayCycle::loadDayCycleFromPath(path);
 	if (data.isUndefined())
 	{
-		llwarns << "Error loading day cycle from " << path << llendl;
+		LL_WARNS() << "Error loading day cycle from " << path << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/lldebugmessagebox.cpp b/indra/newview/lldebugmessagebox.cpp
index 9ad812ab1e..c8b9b1ac63 100755
--- a/indra/newview/lldebugmessagebox.cpp
+++ b/indra/newview/lldebugmessagebox.cpp
@@ -112,7 +112,7 @@ LLDebugVarMessageBox::LLDebugVarMessageBox(const std::string& title, EDebugVarTy
 		addChild(mSlider3);
 		break;
 	default:
-		llwarns << "Unhandled var type " << var_type << llendl;
+		LL_WARNS() << "Unhandled var type " << var_type << LL_ENDL;
 		break;
 	}
 
@@ -234,7 +234,7 @@ void LLDebugVarMessageBox::sliderChanged(const LLSD& data)
 		break;
 	}
 	default:
-		llwarns << "Unhandled var type " << mVarType << llendl;
+		LL_WARNS() << "Unhandled var type " << mVarType << LL_ENDL;
 		break;
 	}
 }
@@ -263,7 +263,7 @@ void LLDebugVarMessageBox::draw()
 		  break;
 	  }
 	  default:
-		llwarns << "Unhandled var type " << mVarType << llendl;
+		LL_WARNS() << "Unhandled var type " << mVarType << LL_ENDL;
 		break;
 	}
 	mText->setText(text);
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index c59ce04646..ad3df55ef1 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -163,7 +163,7 @@ void LLDrawable::destroy()
 
 	if (LLSpatialGroup::sNoDelete)
 	{
-		llerrs << "Illegal deletion of LLDrawable!" << llendl;
+		LL_ERRS() << "Illegal deletion of LLDrawable!" << LL_ENDL;
 	}
 
 	std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
@@ -172,7 +172,7 @@ void LLDrawable::destroy()
 	
 	/*if (!(sNumZombieDrawables % 10))
 	{
-		llinfos << "- Zombie drawables: " << sNumZombieDrawables << llendl;
+		LL_INFOS() << "- Zombie drawables: " << sNumZombieDrawables << LL_ENDL;
 	}*/	
 
 }
@@ -181,7 +181,7 @@ void LLDrawable::markDead()
 {
 	if (isDead())
 	{
-		llwarns << "Warning!  Marking dead multiple times!" << llendl;
+		LL_WARNS() << "Warning!  Marking dead multiple times!" << LL_ENDL;
 		return;
 	}
 	setState(DEAD);
@@ -281,7 +281,7 @@ void LLDrawable::cleanupDeadDrawables()
 	{
 		if (sDeadList[i]->getNumRefs() > 1)
 		{
-			llwarns << "Dead drawable has " << sDeadList[i]->getNumRefs() << " remaining refs" << llendl;
+			LL_WARNS() << "Dead drawable has " << sDeadList[i]->getNumRefs() << " remaining refs" << LL_ENDL;
 			gPipeline.findReferences(sDeadList[i]);
 		}
 	}
@@ -294,7 +294,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep)
 	S32 count = 0;
 	if (mParent == drawablep)
 	{
-		llinfos << this << ": parent reference" << llendl;
+		LL_INFOS() << this << ": parent reference" << LL_ENDL;
 		count++;
 	}
 	return count;
@@ -311,7 +311,7 @@ LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)
 		face = new LLFace(this, mVObjp);
 	}
 
-	if (!face) llerrs << "Allocating new Face: " << mFaces.size() << llendl;
+	if (!face) LL_ERRS() << "Allocating new Face: " << mFaces.size() << LL_ENDL;
 	
 	if (face)
 	{
@@ -468,7 +468,7 @@ void LLDrawable::deleteFaces(S32 offset, S32 count)
 
 void LLDrawable::update()
 {
-	llerrs << "Shouldn't be called!" << llendl;
+	LL_ERRS() << "Shouldn't be called!" << LL_ENDL;
 }
 
 
@@ -490,7 +490,7 @@ void LLDrawable::makeActive()
 			pcode == LLViewerObject::LL_VO_GROUND ||
 			pcode == LLViewerObject::LL_VO_SKY)
 		{
-			llerrs << "Static viewer object has active drawable!" << llendl;
+			LL_ERRS() << "Static viewer object has active drawable!" << LL_ENDL;
 		}
 	}
 #endif
@@ -561,7 +561,7 @@ void LLDrawable::makeStatic(BOOL warning_enabled)
 			{
 				if (child_drawable->getParent() != this)
 				{
-					llwarns << "Child drawable has unknown parent." << llendl;
+					LL_WARNS() << "Child drawable has unknown parent." << LL_ENDL;
 				}
 				child_drawable->makeStatic(warning_enabled);
 			}
@@ -734,7 +734,7 @@ BOOL LLDrawable::updateMove()
 {
 	if (isDead())
 	{
-		llwarns << "Update move on dead drawable!" << llendl;
+		LL_WARNS() << "Update move on dead drawable!" << LL_ENDL;
 		return TRUE;
 	}
 	
@@ -809,7 +809,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
 {
 	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
-		llwarns << "Attempted to update distance for non-world camera." << llendl;
+		LL_WARNS() << "Attempted to update distance for non-world camera." << LL_ENDL;
 		return;
 	}
 
@@ -874,7 +874,7 @@ void LLDrawable::updateTexture()
 {
 	if (isDead())
 	{
-		llwarns << "Dead drawable updating texture!" << llendl;
+		LL_WARNS() << "Dead drawable updating texture!" << LL_ENDL;
 		return;
 	}
 	
@@ -900,7 +900,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
 {
 	if (isDead())
 	{
-		llwarns << "Shifting dead drawable" << llendl;
+		LL_WARNS() << "Shifting dead drawable" << LL_ENDL;
 		return;
 	}
 
@@ -1020,7 +1020,7 @@ F32 LLDrawable::getVisibilityRadius() const
 		{
 			return llmax(getRadius(), vov->getLightRadius());
 		} else {
-			// llwarns ?
+			// LL_WARNS() ?
 		}
 	}
 	return getRadius();
@@ -1317,26 +1317,26 @@ void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results,
 		{
 			if (isActive() && !mParent->isActive())
 			{
-				llerrs << "Active drawable has static parent!" << llendl;
+				LL_ERRS() << "Active drawable has static parent!" << LL_ENDL;
 			}
 			
 			if (isStatic() && !mParent->isStatic())
 			{
-				llerrs << "Static drawable has active parent!" << llendl;
+				LL_ERRS() << "Static drawable has active parent!" << LL_ENDL;
 			}
 			
 			if (mSpatialBridge)
 			{
-				llerrs << "Child drawable has spatial bridge!" << llendl;
+				LL_ERRS() << "Child drawable has spatial bridge!" << LL_ENDL;
 			}
 		}
 		else if (isActive() && !mSpatialBridge)
 		{
-			llerrs << "Active root drawable has no spatial bridge!" << llendl;
+			LL_ERRS() << "Active root drawable has no spatial bridge!" << LL_ENDL;
 		}
 		else if (isStatic() && mSpatialBridge.notNull())
 		{
-			llerrs << "Static drawable has spatial bridge!" << llendl;
+			LL_ERRS() << "Static drawable has spatial bridge!" << LL_ENDL;
 		}
 	}
 #endif
@@ -1512,7 +1512,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
 
 void LLSpatialBridge::makeActive()
 { //it is an error to make a spatial bridge active (it's already active)
-	llerrs << "makeActive called on spatial bridge" << llendl;
+	LL_ERRS() << "makeActive called on spatial bridge" << LL_ENDL;
 }
 
 void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate)
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 08fbd7d211..efb3e1d89d 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -71,7 +71,7 @@ public:
 
 	const LLDrawable& operator=(const LLDrawable& rhs)
 	{
-		llerrs << "Illegal operation!" << llendl;
+		LL_ERRS() << "Illegal operation!" << LL_ENDL;
 		return *this;
 	}
 
@@ -315,19 +315,19 @@ private:
 
 inline LLFace* LLDrawable::getFace(const S32 i) const
 {
-	//switch these asserts to llerrs -- davep
+	//switch these asserts to LL_ERRS() -- davep
 	//llassert((U32)i < mFaces.size());
 	//llassert(mFaces[i]);
 
 	if ((U32) i >= mFaces.size())
 	{
-		llwarns << "Invalid face index." << llendl;
+		LL_WARNS() << "Invalid face index." << LL_ENDL;
 		return NULL;
 	}
 
 	if (!mFaces[i])
 	{
-		llwarns << "Null face found." << llendl;
+		LL_WARNS() << "Null face found." << LL_ENDL;
 		return NULL;
 	}
 	
diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index 04e31e6486..deec199bc4 100755
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -113,7 +113,7 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0)
 		poolp = new LLDrawPoolWLSky();
 		break;
 	default:
-		llerrs << "Unknown draw pool type!" << llendl;
+		LL_ERRS() << "Unknown draw pool type!" << LL_ENDL;
 		return NULL;
 	}
 
@@ -257,7 +257,7 @@ void LLFacePool::destroy()
 {
 	if (!mReferences.empty())
 	{
-		llinfos << mReferences.size() << " references left on deletion of draw pool!" << llendl;
+		LL_INFOS() << mReferences.size() << " references left on deletion of draw pool!" << LL_ENDL;
 	}
 }
 
@@ -332,7 +332,7 @@ BOOL LLFacePool::verify() const
 		const LLFace* facep = *iter;
 		if (facep->getPool() != this)
 		{
-			llinfos << "Face in wrong pool!" << llendl;
+			LL_INFOS() << "Face in wrong pool!" << LL_ENDL;
 			facep->printDebugInfo();
 			ok = FALSE;
 		}
@@ -347,7 +347,7 @@ BOOL LLFacePool::verify() const
 
 void LLFacePool::printDebugInfo() const
 {
-	llinfos << "Pool " << this << " Type: " << getType() << llendl;
+	LL_INFOS() << "Pool " << this << " Type: " << getType() << LL_ENDL;
 }
 
 BOOL LLFacePool::LLOverrideFaceColor::sOverrideFaceColor = FALSE;
@@ -385,9 +385,9 @@ LLRenderPass::~LLRenderPass()
 LLDrawPool* LLRenderPass::instancePool()
 {
 #if LL_RELEASE_FOR_DOWNLOAD
-	llwarns << "Attempting to instance a render pass.  Invalid operation." << llendl;
+	LL_WARNS() << "Attempting to instance a render pass.  Invalid operation." << LL_ENDL;
 #else
-	llerrs << "Attempting to instance a render pass.  Invalid operation." << llendl;
+	LL_ERRS() << "Attempting to instance a render pass.  Invalid operation." << LL_ENDL;
 #endif
 	return NULL;
 }
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 0fed6d1d17..604a9b1530 100755
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -344,7 +344,7 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
 
 				if ((params.mVertexBuffer->getTypeMask() & mask) != mask)
 				{ //FIXME!
-					llwarns << "Missing required components, skipping render batch." << llendl;
+					LL_WARNS() << "Missing required components, skipping render batch." << LL_ENDL;
 					continue;
 				}
 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index c3afe63bdd..39d1b3de50 100755
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -1948,12 +1948,12 @@ void LLDrawPoolAvatar::addRiggedFace(LLFace* facep, U32 type)
 {
 	if (type >= NUM_RIGGED_PASSES)
 	{
-		llerrs << "Invalid rigged face type." << llendl;
+		LL_ERRS() << "Invalid rigged face type." << LL_ENDL;
 	}
 
 	if (facep->getRiggedIndex(type) != -1)
 	{
-		llerrs << "Tried to add a rigged face that's referenced elsewhere." << llendl;
+		LL_ERRS() << "Tried to add a rigged face that's referenced elsewhere." << LL_ENDL;
 	}	
 	
 	facep->setRiggedIndex(type, mRiggedFace[type].size());
@@ -1982,7 +1982,7 @@ void LLDrawPoolAvatar::removeRiggedFace(LLFace* facep)
 			}
 			else
 			{
-				llerrs << "Face reference data corrupt for rigged type " << i << llendl;
+				LL_ERRS() << "Face reference data corrupt for rigged type " << i << LL_ENDL;
 			}
 		}
 	}
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 155e289c9d..6c4226a9a6 100755
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -104,7 +104,7 @@ void LLStandardBumpmap::addstandard()
 	// can't assert; we destroyGL and restoreGL a lot during *first* startup, which populates this list already, THEN we explicitly init the list as part of *normal* startup.  Sigh.  So clear the list every time before we (re-)add the standard bumpmaps.
 	//llassert( LLStandardBumpmap::sStandardBumpmapCount == 0 );
 	clear();
-	llinfos << "Adding standard bumpmaps." << llendl;
+	LL_INFOS() << "Adding standard bumpmaps." << LL_ENDL;
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("None");		// BE_NO_BUMP
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Brightness");	// BE_BRIGHTNESS
 	gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount++] = LLStandardBumpmap("Darkness");	// BE_DARKNESS
@@ -113,7 +113,7 @@ void LLStandardBumpmap::addstandard()
 	LLFILE* file = LLFile::fopen( file_name, "rt" );	 /*Flawfinder: ignore*/
 	if( !file )
 	{
-		llwarns << "Could not open std_bump <" << file_name << ">" << llendl;
+		LL_WARNS() << "Could not open std_bump <" << file_name << ">" << LL_ENDL;
 		return;
 	}
 
@@ -122,13 +122,13 @@ void LLStandardBumpmap::addstandard()
 	S32 fields_read = fscanf( file, "LLStandardBumpmap version %d", &file_version );
 	if( fields_read != 1 )
 	{
-		llwarns << "Bad LLStandardBumpmap header" << llendl;
+		LL_WARNS() << "Bad LLStandardBumpmap header" << LL_ENDL;
 		return;
 	}
 
 	if( file_version > STD_BUMP_LATEST_FILE_VERSION )
 	{
-		llwarns << "LLStandardBumpmap has newer version (" << file_version << ") than viewer (" << STD_BUMP_LATEST_FILE_VERSION << ")" << llendl;
+		LL_WARNS() << "LLStandardBumpmap has newer version (" << file_version << ") than viewer (" << STD_BUMP_LATEST_FILE_VERSION << ")" << LL_ENDL;
 		return;
 	}
 
@@ -145,11 +145,11 @@ void LLStandardBumpmap::addstandard()
 		}
 		if( fields_read != 2 )
 		{
-			llwarns << "Bad LLStandardBumpmap entry" << llendl;
+			LL_WARNS() << "Bad LLStandardBumpmap entry" << LL_ENDL;
 			return;
 		}
 
-// 		llinfos << "Loading bumpmap: " << bump_image_id << " from viewerart" << llendl;
+// 		LL_INFOS() << "Loading bumpmap: " << bump_image_id << " from viewerart" << LL_ENDL;
 		gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mLabel = label;
 		gStandardBumpmapList[LLStandardBumpmap::sStandardBumpmapCount].mImage = 
 			LLViewerTextureManager::getFetchedTexture(LLUUID(bump_image_id));	
@@ -165,7 +165,7 @@ void LLStandardBumpmap::addstandard()
 // static
 void LLStandardBumpmap::clear()
 {
-	llinfos << "Clearing standard bumpmaps." << llendl;
+	LL_INFOS() << "Clearing standard bumpmaps." << LL_ENDL;
 	for( U32 i = 0; i < LLStandardBumpmap::sStandardBumpmapCount; i++ )
 	{
 		gStandardBumpmapList[i].mLabel.assign("");
@@ -927,7 +927,7 @@ void LLBumpImageList::init()
 
 void LLBumpImageList::clear()
 {
-	llinfos << "Clearing dynamic bumpmaps." << llendl;
+	LL_INFOS() << "Clearing dynamic bumpmaps." << LL_ENDL;
 	// these will be re-populated on-demand
 	mBrightnessEntries.clear();
 	mDarknessEntries.clear();
@@ -1003,7 +1003,7 @@ void LLBumpImageList::updateImages()
 
 			if( destroy )
 			{
-				//llinfos << "*** Destroying bright " << (void*)image << llendl;
+				//LL_INFOS() << "*** Destroying bright " << (void*)image << LL_ENDL;
 				mBrightnessEntries.erase(curiter);   // deletes the image thanks to reference counting
 			}
 		}
@@ -1030,7 +1030,7 @@ void LLBumpImageList::updateImages()
 
 			if( destroy )
 			{
-				//llinfos << "*** Destroying dark " << (void*)image << llendl;;
+				//LL_INFOS() << "*** Destroying dark " << (void*)image << LL_ENDL;;
 				mDarknessEntries.erase(curiter);  // deletes the image thanks to reference counting
 			}
 		}
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 9a5743919d..0e118c7420 100755
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -98,7 +98,7 @@ void LLDrawPoolWater::restoreGL()
 
 LLDrawPool *LLDrawPoolWater::instancePool()
 {
-	llerrs << "Should never be calling instancePool on a water pool!" << llendl;
+	LL_ERRS() << "Should never be calling instancePool on a water pool!" << LL_ENDL;
 	return NULL;
 }
 
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index b5faff7968..c3ba6c672d 100755
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -54,12 +54,12 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) :
 	LLDrawPool(POOL_WL_SKY)
 {
 	const std::string cloudNoiseFilename(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight", "clouds2.tga"));
-	llinfos << "loading WindLight cloud noise from " << cloudNoiseFilename << llendl;
+	LL_INFOS() << "loading WindLight cloud noise from " << cloudNoiseFilename << LL_ENDL;
 
 	LLPointer<LLImageFormatted> cloudNoiseFile(LLImageFormatted::createFromExtension(cloudNoiseFilename));
 
 	if(cloudNoiseFile.isNull()) {
-		llerrs << "Error: Failed to load cloud noise image " << cloudNoiseFilename << llendl;
+		LL_ERRS() << "Error: Failed to load cloud noise image " << cloudNoiseFilename << LL_ENDL;
 	}
 
 	if(cloudNoiseFile->load(cloudNoiseFilename))
@@ -69,8 +69,8 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) :
 		if(cloudNoiseFile->decode(sCloudNoiseRawImage, 0.0f))
 		{
 			//debug use			
-			lldebugs << "cloud noise raw image width: " << sCloudNoiseRawImage->getWidth() << " : height: " << sCloudNoiseRawImage->getHeight() << " : components: " << 
-				(S32)sCloudNoiseRawImage->getComponents() << " : data size: " << sCloudNoiseRawImage->getDataSize() << llendl ;
+			LL_DEBUGS() << "cloud noise raw image width: " << sCloudNoiseRawImage->getWidth() << " : height: " << sCloudNoiseRawImage->getHeight() << " : components: " << 
+				(S32)sCloudNoiseRawImage->getComponents() << " : data size: " << sCloudNoiseRawImage->getDataSize() << LL_ENDL ;
 			llassert_always(sCloudNoiseRawImage->getData()) ;
 
 			sCloudNoiseTexture = LLViewerTextureManager::getLocalTexture(sCloudNoiseRawImage.get(), TRUE);
@@ -86,7 +86,7 @@ LLDrawPoolWLSky::LLDrawPoolWLSky(void) :
 
 LLDrawPoolWLSky::~LLDrawPoolWLSky()
 {
-	//llinfos << "destructing wlsky draw pool." << llendl;
+	//LL_INFOS() << "destructing wlsky draw pool." << LL_ENDL;
 	sCloudNoiseTexture = NULL;
 	sCloudNoiseRawImage = NULL;
 }
@@ -196,7 +196,7 @@ void LLDrawPoolWLSky::renderStars(void) const
 	// If start_brightness is not set, exit
 	if( error )
 	{
-		llwarns << "star_brightness missing in mCurParams" << llendl;
+		LL_WARNS() << "star_brightness missing in mCurParams" << LL_ENDL;
 		return;
 	}
 
@@ -389,7 +389,7 @@ void LLDrawPoolWLSky::render(S32 pass)
 
 void LLDrawPoolWLSky::prerender()
 {
-	//llinfos << "wlsky prerendering pass." << llendl;
+	//LL_INFOS() << "wlsky prerendering pass." << LL_ENDL;
 }
 
 LLDrawPoolWLSky *LLDrawPoolWLSky::instancePool()
diff --git a/indra/newview/lldynamictexture.cpp b/indra/newview/lldynamictexture.cpp
index 29ad4f34d2..fa9a0712fa 100755
--- a/indra/newview/lldynamictexture.cpp
+++ b/indra/newview/lldynamictexture.cpp
@@ -99,7 +99,7 @@ void LLViewerDynamicTexture::generateGLTexture(LLGLint internal_format, LLGLenum
 {
 	if (mComponents < 1 || mComponents > 4)
 	{
-		llerrs << "Bad number of components in dynamic texture: " << mComponents << llendl;
+		LL_ERRS() << "Bad number of components in dynamic texture: " << mComponents << LL_ENDL;
 	}
 	
 	LLPointer<LLImageRaw> raw_image = new LLImageRaw(mFullWidth, mFullHeight, mComponents);
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp
index 86fe6754dc..755bf57cc0 100755
--- a/indra/newview/llenvmanager.cpp
+++ b/indra/newview/llenvmanager.cpp
@@ -40,7 +40,7 @@ std::string LLEnvPrefs::getWaterPresetName() const
 {
 	if (mWaterPresetName.empty())
 	{
-		llwarns << "Water preset name is empty" << llendl;
+		LL_WARNS() << "Water preset name is empty" << LL_ENDL;
 	}
 
 	return mWaterPresetName;
@@ -50,7 +50,7 @@ std::string LLEnvPrefs::getSkyPresetName() const
 {
 	if (mSkyPresetName.empty())
 	{
-		llwarns << "Sky preset name is empty" << llendl;
+		LL_WARNS() << "Sky preset name is empty" << LL_ENDL;
 	}
 
 	return mSkyPresetName;
@@ -60,7 +60,7 @@ std::string LLEnvPrefs::getDayCycleName() const
 {
 	if (mDayCycleName.empty())
 	{
-		llwarns << "Day cycle name is empty" << llendl;
+		LL_WARNS() << "Day cycle name is empty" << LL_ENDL;
 	}
 
 	return mDayCycleName;
@@ -196,7 +196,7 @@ bool LLEnvManagerNew::useSkyPreset(const std::string& name)
 
 	if (!sky_mgr.getParamSet(LLWLParamKey(name, LLEnvKey::SCOPE_LOCAL), param_set))
 	{
-		llwarns << "No sky preset named " << name << llendl;
+		LL_WARNS() << "No sky preset named " << name << LL_ENDL;
 		return false;
 	}
 
@@ -227,7 +227,7 @@ bool LLEnvManagerNew::useDayCycle(const std::string& name, LLEnvKey::EScope scop
 
 		if (!LLDayCycleManager::instance().getPreset(name, params))
 		{
-			llwarns << "No day cycle named " << name << llendl;
+			LL_WARNS() << "No day cycle named " << name << LL_ENDL;
 			return false;
 		}
 	}
@@ -255,7 +255,7 @@ void LLEnvManagerNew::setUseWaterPreset(const std::string& name)
 	// *TODO: make sure the preset exists.
 	if (name.empty())
 	{
-		llwarns << "Empty water preset name passed" << llendl;
+		LL_WARNS() << "Empty water preset name passed" << LL_ENDL;
 		return;
 	}
 
@@ -269,7 +269,7 @@ void LLEnvManagerNew::setUseSkyPreset(const std::string& name)
 	// *TODO: make sure the preset exists.
 	if (name.empty())
 	{
-		llwarns << "Empty sky preset name passed" << llendl;
+		LL_WARNS() << "Empty sky preset name passed" << LL_ENDL;
 		return;
 	}
 
@@ -282,7 +282,7 @@ void LLEnvManagerNew::setUseDayCycle(const std::string& name)
 {
 	if (!LLDayCycleManager::instance().presetExists(name))
 	{
-		llwarns << "Invalid day cycle name passed" << llendl;
+		LL_WARNS() << "Invalid day cycle name passed" << LL_ENDL;
 		return;
 	}
 
@@ -580,7 +580,7 @@ void LLEnvManagerNew::updateWaterFromPrefs(bool interpolate)
 		LLWaterParamSet params;
 		if (!water_mgr.getParamSet(water, params))
 		{
-			llwarns << "No water preset named " << water << ", falling back to defaults" << llendl;
+			LL_WARNS() << "No water preset named " << water << ", falling back to defaults" << LL_ENDL;
 			water_mgr.getParamSet("Default", params);
 
 			// *TODO: Fix user preferences accordingly.
diff --git a/indra/newview/llestateinfomodel.cpp b/indra/newview/llestateinfomodel.cpp
index 2669b0340f..761adc5942 100755
--- a/indra/newview/llestateinfomodel.cpp
+++ b/indra/newview/llestateinfomodel.cpp
@@ -93,7 +93,7 @@ void LLEstateInfoModel::update(const strings_t& strings)
 	LL_DEBUGS("Windlight Sync") << "Received estate info: "
 		<< "is_sun_fixed = " << getUseFixedSun()
 		<< ", sun_hour = " << getSunHour() << LL_ENDL;
-	lldebugs << getInfoDump() << llendl;
+	LL_DEBUGS() << getInfoDump() << LL_ENDL;
 
 	// Update region owner.
 	LLViewerRegion* regionp = gAgent.getRegion();
@@ -117,14 +117,14 @@ public:
 	// if we get a normal response, handle it here
 	virtual void result(const LLSD& content)
 	{
-		llinfos << "Committed estate info" << llendl;
+		LL_INFOS() << "Committed estate info" << LL_ENDL;
 		LLEstateInfoModel::instance().notifyCommit();
 	}
 
 	// if we get an error response
 	virtual void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "Failed to commit estate info [status:" << status << "]: " << content << llendl;
+		LL_WARNS() << "Failed to commit estate info [status:" << status << "]: " << content << LL_ENDL;
 	}
 };
 
@@ -155,7 +155,7 @@ bool LLEstateInfoModel::commitEstateInfoCaps()
 	LL_DEBUGS("Windlight Sync") << "Sending estate caps: "
 		<< "is_sun_fixed = " << getUseFixedSun()
 		<< ", sun_hour = " << getSunHour() << LL_ENDL;
-	lldebugs << body << LL_ENDL;
+	LL_DEBUGS() << body << LL_ENDL;
 
 	// we use a responder so that we can re-get the data after committing to the database
 	LLHTTPClient::post(url, body, new LLEstateChangeInfoResponder);
@@ -174,7 +174,7 @@ void LLEstateInfoModel::commitEstateInfoDataserver()
 	LL_DEBUGS("Windlight Sync") << "Sending estate info: "
 		<< "is_sun_fixed = " << getUseFixedSun()
 		<< ", sun_hour = " << getSunHour() << LL_ENDL;
-	lldebugs << getInfoDump() << LL_ENDL;
+	LL_DEBUGS() << getInfoDump() << LL_ENDL;
 
 	LLMessageSystem* msg = gMessageSystem;
 	msg->newMessage("EstateOwnerMessage");
diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp
index bedab75f98..e3c17f9877 100755
--- a/indra/newview/lleventnotifier.cpp
+++ b/indra/newview/lleventnotifier.cpp
@@ -167,7 +167,7 @@ bool LLEventNotifier::add(U32 eventId, F64 eventEpoch, const std::string& eventD
 {
 	LLEventNotification *new_enp = new LLEventNotification(eventId, eventEpoch, eventDateStr, eventName);
 	
-	llinfos << "Add event " << eventName << " id " << eventId << " date " << eventDateStr << llendl;
+	LL_INFOS() << "Add event " << eventName << " id " << eventId << " date " << eventDateStr << LL_ENDL;
 	if(!new_enp->isValid())
 	{
 		delete new_enp;
diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp
index c1630318e8..fbd9466afe 100755
--- a/indra/newview/lleventpoll.cpp
+++ b/indra/newview/lleventpoll.cpp
@@ -109,15 +109,15 @@ namespace
 		const std::string& pollURL, const LLHost& sender)
 	{
 		LLHTTPClient::ResponderPtr result = new LLEventPollResponder(pollURL, sender);
-		llinfos	<< "LLEventPollResponder::start <" << sCount << "> "
-				<< pollURL << llendl;
+		LL_INFOS()	<< "LLEventPollResponder::start <" << sCount << "> "
+				<< pollURL << LL_ENDL;
 		return result;
 	}
 
 	void LLEventPollResponder::stop()
 	{
-		llinfos	<< "LLEventPollResponder::stop	<" << mCount <<	"> "
-				<< mPollURL	<< llendl;
+		LL_INFOS()	<< "LLEventPollResponder::stop	<" << mCount <<	"> "
+				<< mPollURL	<< LL_ENDL;
 		// there should	be a way to	stop a LLHTTPClient	request	in progress
 		mDone =	true;
 	}
@@ -134,18 +134,18 @@ namespace
 		LLViewerRegion *regionp = gAgent.getRegion();
 		if (!regionp)
 		{
-			llerrs << "LLEventPoll initialized before region is added." << llendl;
+			LL_ERRS() << "LLEventPoll initialized before region is added." << LL_ENDL;
 		}
 		mSender = sender.getIPandPort();
-		llinfos << "LLEventPoll initialized with sender " << mSender << llendl;
+		LL_INFOS() << "LLEventPoll initialized with sender " << mSender << LL_ENDL;
 		makeRequest();
 	}
 
 	LLEventPollResponder::~LLEventPollResponder()
 	{
 		stop();
-		lldebugs <<	"LLEventPollResponder::~Impl <" <<	mCount << "> "
-				 <<	mPollURL <<	llendl;
+		LL_DEBUGS() <<	"LLEventPollResponder::~Impl <" <<	mCount << "> "
+				 <<	mPollURL <<	LL_ENDL;
 	}
 
 	// virtual 
@@ -172,8 +172,8 @@ namespace
 		request["ack"] = mAcknowledge;
 		request["done"]	= mDone;
 		
-		lldebugs <<	"LLEventPollResponder::makeRequest	<" << mCount <<	"> ack = "
-				 <<	LLSDXMLStreamer(mAcknowledge) << llendl;
+		LL_DEBUGS() <<	"LLEventPollResponder::makeRequest	<" << mCount <<	"> ack = "
+				 <<	LLSDXMLStreamer(mAcknowledge) << LL_ENDL;
 		LLHTTPClient::post(mPollURL, request, this);
 	}
 
@@ -207,13 +207,13 @@ namespace
 										+ mErrorCount * EVENT_POLL_ERROR_RETRY_SECONDS_INC
 									, this);
 
-			llwarns << "LLEventPollResponder error [status:" << status << "]: " << content << llendl;
+			LL_WARNS() << "LLEventPollResponder error [status:" << status << "]: " << content << LL_ENDL;
 		}
 		else
 		{
-			llwarns << "LLEventPollResponder error <" << mCount 
+			LL_WARNS() << "LLEventPollResponder error <" << mCount 
 					<< "> [status:" << status << "]: " << content
-					<<	(mDone ? " -- done"	: "") << llendl;
+					<<	(mDone ? " -- done"	: "") << LL_ENDL;
 			stop();
 
 			// At this point we have given up and the viewer will not receive HTTP messages from the simulator.
@@ -227,7 +227,7 @@ namespace
 			// continue running.
 			if(gAgent.getRegion() && gAgent.getRegion()->getHost().getIPandPort() == mSender)
 			{
-				llwarns << "Forcing disconnect due to stalled main region event poll."  << llendl;
+				LL_WARNS() << "Forcing disconnect due to stalled main region event poll."  << LL_ENDL;
 				LLAppViewer::instance()->forceDisconnect(LLTrans::getString("AgentLostConnection"));
 			}
 		}
@@ -236,8 +236,8 @@ namespace
 	//virtual
 	void LLEventPollResponder::result(const LLSD& content)
 	{
-		lldebugs <<	"LLEventPollResponder::result <" << mCount	<< ">"
-				 <<	(mDone ? " -- done"	: "") << llendl;
+		LL_DEBUGS() <<	"LLEventPollResponder::result <" << mCount	<< ">"
+				 <<	(mDone ? " -- done"	: "") << LL_ENDL;
 		
 		if (mDone) return;
 
@@ -246,7 +246,7 @@ namespace
 		if (!content.get("events") ||
 			!content.get("id"))
 		{
-			llwarns << "received event poll with no events or id key" << llendl;
+			LL_WARNS() << "received event poll with no events or id key" << LL_ENDL;
 			makeRequest();
 			return;
 		}
@@ -256,12 +256,12 @@ namespace
 
 		if(mAcknowledge.isUndefined())
 		{
-			llwarns << "LLEventPollResponder: id undefined" << llendl;
+			LL_WARNS() << "LLEventPollResponder: id undefined" << LL_ENDL;
 		}
 		
-		// was llinfos but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG
-		lldebugs  << "LLEventPollResponder::completed <" <<	mCount << "> " << events.size() << "events (id "
-				 <<	LLSDXMLStreamer(mAcknowledge) << ")" << llendl;
+		// was LL_INFOS() but now that CoarseRegionUpdate is TCP @ 1/second, it'd be too verbose for viewer logs. -MG
+		LL_DEBUGS()  << "LLEventPollResponder::completed <" <<	mCount << "> " << events.size() << "events (id "
+				 <<	LLSDXMLStreamer(mAcknowledge) << ")" << LL_ENDL;
 		
 		LLSD::array_const_iterator i = events.beginArray();
 		LLSD::array_const_iterator end = events.endArray();
diff --git a/indra/newview/llexternaleditor.cpp b/indra/newview/llexternaleditor.cpp
index 9480e54809..df9c848cb8 100755
--- a/indra/newview/llexternaleditor.cpp
+++ b/indra/newview/llexternaleditor.cpp
@@ -44,7 +44,7 @@ LLExternalEditor::EErrorCode LLExternalEditor::setCommand(const std::string& env
 	std::string cmd = findCommand(env_var, override);
 	if (cmd.empty())
 	{
-		llwarns << "Editor command is empty or not set" << llendl;
+		LL_WARNS() << "Editor command is empty or not set" << LL_ENDL;
 		return EC_NOT_SPECIFIED;
 	}
 
@@ -55,7 +55,7 @@ LLExternalEditor::EErrorCode LLExternalEditor::setCommand(const std::string& env
 	std::string bin_path = tokens[0];
 	if (!LLFile::isfile(bin_path))
 	{
-		llwarns << "Editor binary [" << bin_path << "] not found" << llendl;
+		LL_WARNS() << "Editor binary [" << bin_path << "] not found" << LL_ENDL;
 		return EC_BINARY_NOT_FOUND;
 	}
 
@@ -71,10 +71,10 @@ LLExternalEditor::EErrorCode LLExternalEditor::setCommand(const std::string& env
 	if (cmd.find(sFilenameMarker) == std::string::npos)
 	{
 		mProcessParams.args.add(sFilenameMarker);
-		llinfos << "Adding the filename marker (" << sFilenameMarker << ")" << llendl;
+		LL_INFOS() << "Adding the filename marker (" << sFilenameMarker << ")" << LL_ENDL;
 	}
 
-	llinfos << "Setting command [" << mProcessParams << "]" << llendl;
+	LL_INFOS() << "Setting command [" << mProcessParams << "]" << LL_ENDL;
 
 	return EC_SUCCESS;
 }
@@ -83,7 +83,7 @@ LLExternalEditor::EErrorCode LLExternalEditor::run(const std::string& file_path)
 {
 	if (std::string(mProcessParams.executable).empty() || mProcessParams.args.empty())
 	{
-		llwarns << "Editor command not set" << llendl;
+		LL_WARNS() << "Editor command not set" << LL_ENDL;
 		return EC_NOT_SPECIFIED;
 	}
 
@@ -181,12 +181,12 @@ std::string LLExternalEditor::findCommand(
 	if (!override.empty())	// try the supplied override first
 	{
 		cmd = override;
-		llinfos << "Using override" << llendl;
+		LL_INFOS() << "Using override" << LL_ENDL;
 	}
 	else if (!LLUI::sSettingGroups["config"]->getString(sSetting).empty())
 	{
 		cmd = LLUI::sSettingGroups["config"]->getString(sSetting);
-		llinfos << "Using setting" << llendl;
+		LL_INFOS() << "Using setting" << LL_ENDL;
 	}
 	else					// otherwise use the path specified by the environment variable
 	{
@@ -194,10 +194,10 @@ std::string LLExternalEditor::findCommand(
 		if (env_var_val)
 		{
 			cmd = env_var_val;
-			llinfos << "Using env var " << env_var << llendl;
+			LL_INFOS() << "Using env var " << env_var << LL_ENDL;
 		}
 	}
 
-	llinfos << "Found command [" << cmd << "]" << llendl;
+	LL_INFOS() << "Found command [" << cmd << "]" << LL_ENDL;
 	return cmd;
 }
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index aadbbbacbb..7882fe6f33 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -222,7 +222,7 @@ void LLFace::initClass()
 
 void LLFace::setWorldMatrix(const LLMatrix4 &mat)
 {
-	llerrs << "Faces on this drawable are not independently modifiable\n" << llendl;
+	LL_ERRS() << "Faces on this drawable are not independently modifiable\n" << LL_ENDL;
 }
 
 void LLFace::setPool(LLFacePool* pool)
@@ -234,7 +234,7 @@ void LLFace::setPool(LLFacePool* new_pool, LLViewerTexture *texturep)
 {
 	if (!new_pool)
 	{
-		llerrs << "Setting pool to null!" << llendl;
+		LL_ERRS() << "Setting pool to null!" << LL_ENDL;
 	}
 
 	if (new_pool != mDrawPoolp)
@@ -338,7 +338,7 @@ void LLFace::switchTexture(U32 ch, LLViewerTexture* new_texture)
 
 	if(!new_texture)
 	{
-		llerrs << "Can not switch to a null texture." << llendl;
+		LL_ERRS() << "Can not switch to a null texture." << LL_ENDL;
 		return;
 	}
 
@@ -420,7 +420,7 @@ void LLFace::setTextureIndex(U8 index)
 		{
 			if (mDrawInfo && !mDrawInfo->mTextureList.empty())
 			{
-				llerrs << "Face with no texture index references indexed texture draw info." << llendl;
+				LL_ERRS() << "Face with no texture index references indexed texture draw info." << LL_ENDL;
 			}
 		}
 	}
@@ -612,29 +612,29 @@ void LLFace::setDrawInfo(LLDrawInfo* draw_info)
 void LLFace::printDebugInfo() const
 {
 	LLFacePool *poolp = getPool();
-	llinfos << "Object: " << getViewerObject()->mID << llendl;
+	LL_INFOS() << "Object: " << getViewerObject()->mID << LL_ENDL;
 	if (getDrawable())
 	{
-		llinfos << "Type: " << LLPrimitive::pCodeToString(getDrawable()->getVObj()->getPCode()) << llendl;
+		LL_INFOS() << "Type: " << LLPrimitive::pCodeToString(getDrawable()->getVObj()->getPCode()) << LL_ENDL;
 	}
 	if (getTexture())
 	{
-		llinfos << "Texture: " << getTexture() << " Comps: " << (U32)getTexture()->getComponents() << llendl;
+		LL_INFOS() << "Texture: " << getTexture() << " Comps: " << (U32)getTexture()->getComponents() << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "No texture: " << llendl;
+		LL_INFOS() << "No texture: " << LL_ENDL;
 	}
 
-	llinfos << "Face: " << this << llendl;
-	llinfos << "State: " << getState() << llendl;
-	llinfos << "Geom Index Data:" << llendl;
-	llinfos << "--------------------" << llendl;
-	llinfos << "GI: " << mGeomIndex << " Count:" << mGeomCount << llendl;
-	llinfos << "Face Index Data:" << llendl;
-	llinfos << "--------------------" << llendl;
-	llinfos << "II: " << mIndicesIndex << " Count:" << mIndicesCount << llendl;
-	llinfos << llendl;
+	LL_INFOS() << "Face: " << this << LL_ENDL;
+	LL_INFOS() << "State: " << getState() << LL_ENDL;
+	LL_INFOS() << "Geom Index Data:" << LL_ENDL;
+	LL_INFOS() << "--------------------" << LL_ENDL;
+	LL_INFOS() << "GI: " << mGeomIndex << " Count:" << mGeomCount << LL_ENDL;
+	LL_INFOS() << "Face Index Data:" << LL_ENDL;
+	LL_INFOS() << "--------------------" << LL_ENDL;
+	LL_INFOS() << "II: " << mIndicesIndex << " Count:" << mIndicesCount << LL_ENDL;
+	LL_INFOS() << LL_ENDL;
 
 	if (poolp)
 	{
@@ -647,20 +647,20 @@ void LLFace::printDebugInfo() const
 			LLFace *facep = *iter;
 			if (facep == this)
 			{
-				llinfos << "Pool reference: " << pool_references << llendl;
+				LL_INFOS() << "Pool reference: " << pool_references << LL_ENDL;
 				pool_references++;
 			}
 		}
 
 		if (pool_references != 1)
 		{
-			llinfos << "Incorrect number of pool references!" << llendl;
+			LL_INFOS() << "Incorrect number of pool references!" << LL_ENDL;
 		}
 	}
 
 #if 0
-	llinfos << "Indices:" << llendl;
-	llinfos << "--------------------" << llendl;
+	LL_INFOS() << "Indices:" << LL_ENDL;
+	LL_INFOS() << "--------------------" << LL_ENDL;
 
 	const U32 *indicesp = getRawIndices();
 	S32 indices_count = getIndicesCount();
@@ -668,17 +668,17 @@ void LLFace::printDebugInfo() const
 
 	for (S32 i = 0; i < indices_count; i++)
 	{
-		llinfos << i << ":" << indicesp[i] << ":" << (S32)(indicesp[i] - geom_start) << llendl;
+		LL_INFOS() << i << ":" << indicesp[i] << ":" << (S32)(indicesp[i] - geom_start) << LL_ENDL;
 	}
-	llinfos << llendl;
+	LL_INFOS() << LL_ENDL;
 
-	llinfos << "Vertices:" << llendl;
-	llinfos << "--------------------" << llendl;
+	LL_INFOS() << "Vertices:" << LL_ENDL;
+	LL_INFOS() << "--------------------" << LL_ENDL;
 	for (S32 i = 0; i < mGeomCount; i++)
 	{
-		llinfos << mGeomIndex + i << ":" << poolp->getVertex(mGeomIndex + i) << llendl;
+		LL_INFOS() << mGeomIndex + i << ":" << poolp->getVertex(mGeomIndex + i) << LL_ENDL;
 	}
-	llinfos << llendl;
+	LL_INFOS() << LL_ENDL;
 #endif
 }
 
@@ -785,7 +785,7 @@ BOOL LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f,
 	
 		if (f >= volume.getNumVolumeFaces())
 		{
-			llwarns << "Generating bounding box for invalid face index!" << llendl;
+			LL_WARNS() << "Generating bounding box for invalid face index!" << LL_ENDL;
 			f = 0;
 		}
 
@@ -1213,13 +1213,13 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		{
 			if (gDebugGL)
 			{
-				llwarns	<< "Index buffer overflow!" << llendl;
-				llwarns << "Indices Count: " << mIndicesCount
+				LL_WARNS()	<< "Index buffer overflow!" << LL_ENDL;
+				LL_WARNS() << "Indices Count: " << mIndicesCount
 						<< " VF Num Indices: " << num_indices
 						<< " Indices Index: " << mIndicesIndex
-						<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
-				llwarns	<< " Face Index: " << f
-						<< " Pool Type: " << mPoolType << llendl;
+						<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << LL_ENDL;
+				LL_WARNS()	<< " Face Index: " << f
+						<< " Pool Type: " << mPoolType << LL_ENDL;
 			}
 			return FALSE;
 		}
@@ -1228,7 +1228,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		{
 			if (gDebugGL)
 			{
-				llwarns << "Vertex buffer overflow!" << llendl;
+				LL_WARNS() << "Vertex buffer overflow!" << LL_ENDL;
 			}
 			return FALSE;
 		}
@@ -2397,7 +2397,7 @@ BOOL LLFace::verify(const U32* indices_array) const
 	if ((mGeomIndex + mGeomCount) > mVertexBuffer->getNumVerts())
 	{
 		ok = FALSE;
-		llinfos << "Face references invalid vertices!" << llendl;
+		LL_INFOS() << "Face references invalid vertices!" << LL_ENDL;
 	}
 
 	S32 indices_count = (S32)getIndicesCount();
@@ -2410,13 +2410,13 @@ BOOL LLFace::verify(const U32* indices_array) const
 	if (indices_count > LL_MAX_INDICES_COUNT)
 	{
 		ok = FALSE;
-		llinfos << "Face has bogus indices count" << llendl;
+		LL_INFOS() << "Face has bogus indices count" << LL_ENDL;
 	}
 	
 	if (mIndicesIndex + mIndicesCount > mVertexBuffer->getNumIndices())
 	{
 		ok = FALSE;
-		llinfos << "Face references invalid indices!" << llendl;
+		LL_INFOS() << "Face references invalid indices!" << LL_ENDL;
 	}
 
 #if 0
@@ -2430,14 +2430,14 @@ BOOL LLFace::verify(const U32* indices_array) const
 		S32 delta = indicesp[i] - geom_start;
 		if (0 > delta)
 		{
-			llwarns << "Face index too low!" << llendl;
-			llinfos << "i:" << i << " Index:" << indicesp[i] << " GStart: " << geom_start << llendl;
+			LL_WARNS() << "Face index too low!" << LL_ENDL;
+			LL_INFOS() << "i:" << i << " Index:" << indicesp[i] << " GStart: " << geom_start << LL_ENDL;
 			ok = FALSE;
 		}
 		else if (delta >= geom_count)
 		{
-			llwarns << "Face index too high!" << llendl;
-			llinfos << "i:" << i << " Index:" << indicesp[i] << " GEnd: " << geom_start + geom_count << llendl;
+			LL_WARNS() << "Face index too high!" << LL_ENDL;
+			LL_INFOS() << "i:" << i << " Index:" << indicesp[i] << " GEnd: " << geom_start + geom_count << LL_ENDL;
 			ok = FALSE;
 		}
 	}
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index c4832b67cd..fc22daa4a3 100755
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -75,7 +75,7 @@ public:
 
 	const LLFace& operator=(const LLFace& rhs)
 	{
-		llerrs << "Illegal operation!" << llendl;
+		LL_ERRS() << "Illegal operation!" << LL_ENDL;
 		return *this;
 	}
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 4037b5ebdd..bb9e474098 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -836,7 +836,7 @@ void LLFastTimerView::doAnalysisDefault(std::string baseline, std::string target
 	std::ifstream target_is(target.c_str());
 	if (!base_is.is_open() || !target_is.is_open())
 	{
-		llwarns << "'-analyzeperformance' error : baseline or current target file inexistent" << llendl;
+		LL_WARNS() << "'-analyzeperformance' error : baseline or current target file inexistent" << LL_ENDL;
 		base_is.close();
 		target_is.close();
 		return;
@@ -980,7 +980,7 @@ void LLFastTimerView::printLineStats()
 				it.skipDescendants();
 			}
 		}
-		llinfos << legend_stat << llendl;
+		LL_INFOS() << legend_stat << LL_ENDL;
 
 		std::string timer_stat;
 		first = true;
@@ -1014,7 +1014,7 @@ void LLFastTimerView::printLineStats()
 				it.skipDescendants();
 			}
 		}
-		llinfos << timer_stat << llendl;
+		LL_INFOS() << timer_stat << LL_ENDL;
 		mStatsIndex = -1;
 	}
 }
diff --git a/indra/newview/llfavoritesbar.cpp b/indra/newview/llfavoritesbar.cpp
index fc531a0c74..3c47545121 100755
--- a/indra/newview/llfavoritesbar.cpp
+++ b/indra/newview/llfavoritesbar.cpp
@@ -478,7 +478,7 @@ BOOL LLFavoritesBarCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 				const LLUUID favorites_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE);
 				if (item->getParentUUID() == favorites_id)
 				{
-					llwarns << "Attemt to copy a favorite item into the same folder." << llendl;
+					LL_WARNS() << "Attemt to copy a favorite item into the same folder." << LL_ENDL;
 					break;
 				}
 
@@ -621,7 +621,7 @@ void LLFavoritesBarCtrl::handleNewFavoriteDragAndDrop(LLInventoryItem *item, con
 				cb);
 	}
 
-	llinfos << "Copied inventory item #" << item->getUUID() << " to favorites." << llendl;
+	LL_INFOS() << "Copied inventory item #" << item->getUUID() << " to favorites." << LL_ENDL;
 }
 
 //virtual
@@ -858,7 +858,7 @@ LLButton* LLFavoritesBarCtrl::createButton(const LLPointer<LLViewerInventoryItem
 	fav_btn = LLUICtrlFactory::create<LLFavoriteLandmarkButton>(fav_btn_params);
 	if (NULL == fav_btn)
 	{
-		llwarns << "Unable to create LLFavoriteLandmarkButton widget: " << item->getName() << llendl;
+		LL_WARNS() << "Unable to create LLFavoriteLandmarkButton widget: " << item->getName() << LL_ENDL;
 		return NULL;
 	}
 	
@@ -1146,7 +1146,7 @@ bool LLFavoritesBarCtrl::enableSelected(const LLSD& userdata)
 void LLFavoritesBarCtrl::doToSelected(const LLSD& userdata)
 {
 	std::string action = userdata.asString();
-	llinfos << "Action = " << action << " Item = " << mSelectedItemID.asString() << llendl;
+	LL_INFOS() << "Action = " << action << " Item = " << mSelectedItemID.asString() << LL_ENDL;
 	
 	LLViewerInventoryItem* item = gInventory.getItem(mSelectedItemID);
 	if (!item)
@@ -1473,14 +1473,14 @@ void LLFavoritesOrderStorage::saveFavoritesSLURLs()
 	// Do not change the file if we are not logged in yet.
 	if (!LLLoginInstance::getInstance()->authSuccess())
 	{
-		llwarns << "Cannot save favorites: not logged in" << llendl;
+		LL_WARNS() << "Cannot save favorites: not logged in" << LL_ENDL;
 		return;
 	}
 
 	std::string user_dir = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "");
 	if (user_dir.empty())
 	{
-		llwarns << "Cannot save favorites: empty user dir name" << llendl;
+		LL_WARNS() << "Cannot save favorites: empty user dir name" << LL_ENDL;
 		return;
 	}
 
@@ -1508,13 +1508,13 @@ void LLFavoritesOrderStorage::saveFavoritesSLURLs()
 		slurls_map_t::iterator slurl_iter = mSLURLs.find(value["asset_id"]);
 		if (slurl_iter != mSLURLs.end())
 		{
-			lldebugs << "Saving favorite: idx=" << LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID()) << ", SLURL=" <<  slurl_iter->second << ", value=" << value << llendl;
+			LL_DEBUGS() << "Saving favorite: idx=" << LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID()) << ", SLURL=" <<  slurl_iter->second << ", value=" << value << LL_ENDL;
 			value["slurl"] = slurl_iter->second;
 			user_llsd[LLFavoritesOrderStorage::instance().getSortIndex((*it)->getUUID())] = value;
 		}
 		else
 		{
-			llwarns << "Not saving favorite " << value["name"] << ": no matching SLURL" << llendl;
+			LL_WARNS() << "Not saving favorite " << value["name"] << ": no matching SLURL" << LL_ENDL;
 		}
 	}
 
@@ -1522,7 +1522,7 @@ void LLFavoritesOrderStorage::saveFavoritesSLURLs()
 	LLAvatarNameCache::get( gAgentID, &av_name );
 	// Note : use the "John Doe" and not the "john.doe" version of the name 
 	// as we'll compare it with the stored credentials in the login panel.
-	lldebugs << "Saved favorites for " << av_name.getUserName() << llendl;
+	LL_DEBUGS() << "Saved favorites for " << av_name.getUserName() << LL_ENDL;
 	fav_llsd[av_name.getUserName()] = user_llsd;
 
 	llofstream file;
@@ -1543,7 +1543,7 @@ void LLFavoritesOrderStorage::removeFavoritesRecordOfUser()
 	LLAvatarNameCache::get( gAgentID, &av_name );
 	// Note : use the "John Doe" and not the "john.doe" version of the name.
 	// See saveFavoritesSLURLs() here above for the reason why.
-	lldebugs << "Removed favorites for " << av_name.getUserName() << llendl;
+	LL_DEBUGS() << "Removed favorites for " << av_name.getUserName() << LL_ENDL;
 	if (fav_llsd.has(av_name.getUserName()))
 	{
 		fav_llsd.erase(av_name.getUserName());
@@ -1576,7 +1576,7 @@ void LLFavoritesOrderStorage::onLandmarkLoaded(const LLUUID& asset_id, LLLandmar
 
 void LLFavoritesOrderStorage::storeFavoriteSLURL(const LLUUID& asset_id, std::string& slurl)
 {
-	lldebugs << "Saving landmark SLURL: " << slurl << llendl;
+	LL_DEBUGS() << "Saving landmark SLURL: " << slurl << LL_ENDL;
 	mSLURLs[asset_id] = slurl;
 }
 
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index c05f27d2ee..01596f0b4b 100755
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -127,7 +127,7 @@ F32 LLFeatureList::getRecommendedValue(const std::string& name)
 
 BOOL LLFeatureList::maskList(LLFeatureList &mask)
 {
-	//llinfos << "Masking with " << mask.mName << llendl;
+	//LL_INFOS() << "Masking with " << mask.mName << LL_ENDL;
 	//
 	// Lookup the specified feature mask, and overlay it on top of the
 	// current feature mask.
@@ -265,7 +265,7 @@ BOOL LLFeatureManager::loadFeatureTables()
 
 BOOL LLFeatureManager::parseFeatureTable(std::string filename)
 {
-	llinfos << "Looking for feature table in " << filename << llendl;
+	LL_INFOS() << "Looking for feature table in " << filename << LL_ENDL;
 
 	llifstream file;
 	std::string name;
@@ -524,7 +524,7 @@ public:
 		{
 			// write to file
 
-			llinfos << "writing feature table to " << mFilename << llendl;
+			LL_INFOS() << "writing feature table to " << mFilename << LL_ENDL;
 			
 			S32 file_size = buffer->countAfter(channels.in(), NULL);
 			if (file_size > 0)
@@ -569,7 +569,7 @@ void fetch_feature_table(std::string table)
 
 	const std::string path       = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename);
 
-	llinfos << "LLFeatureManager fetching " << url << " into " << path << llendl;
+	LL_INFOS() << "LLFeatureManager fetching " << url << " into " << path << LL_ENDL;
 	
 	LLHTTPClient::get(url, new LLHTTPFeatureTableResponder(path));
 }
@@ -584,7 +584,7 @@ void fetch_gpu_table(std::string table)
 
 	const std::string path       = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename);
 
-	llinfos << "LLFeatureManager fetching " << url << " into " << path << llendl;
+	LL_INFOS() << "LLFeatureManager fetching " << url << " into " << path << LL_ENDL;
 	
 	LLHTTPClient::get(url, new LLHTTPFeatureTableResponder(path));
 }
@@ -621,7 +621,7 @@ void LLFeatureManager::applyRecommendedSettings()
 	// cap the level at 2 (high)
 	S32 level = llmax(GPU_CLASS_0, llmin(mGPUClass, GPU_CLASS_5));
 
-	llinfos << "Applying Recommended Features" << llendl;
+	LL_INFOS() << "Applying Recommended Features" << LL_ENDL;
 
 	setGraphicsLevel(level, false);
 	gSavedSettings.setU32("RenderQualityPerformance", level);
@@ -667,7 +667,7 @@ void LLFeatureManager::applyFeatures(bool skipFeatures)
 		LLControlVariable* ctrl = gSavedSettings.getControl(mIt->first);
 		if(ctrl == NULL)
 		{
-			llwarns << "AHHH! Control setting " << mIt->first << " does not exist!" << llendl;
+			LL_WARNS() << "AHHH! Control setting " << mIt->first << " does not exist!" << LL_ENDL;
 			continue;
 		}
 
@@ -690,7 +690,7 @@ void LLFeatureManager::applyFeatures(bool skipFeatures)
 		}
 		else
 		{
-			llwarns << "AHHH! Control variable is not a numeric type!" << llendl;
+			LL_WARNS() << "AHHH! Control variable is not a numeric type!" << LL_ENDL;
 		}
 	}
 }
@@ -863,7 +863,7 @@ void LLFeatureManager::applyBaseMasks()
 		}
 	}
 
-	//llinfos << "Masking features from gpu table match: " << gpustr << llendl;
+	//LL_INFOS() << "Masking features from gpu table match: " << gpustr << LL_ENDL;
 	maskFeatures(gpustr);
 
 	// now mask cpu type ones
diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp
index d13f85baa2..a288d8e4de 100755
--- a/indra/newview/llfilepicker.cpp
+++ b/indra/newview/llfilepicker.cpp
@@ -629,7 +629,7 @@ Boolean LLFilePicker::navOpenFilterProc(AEDesc *theItem, void *info, void *callB
 #endif
 						else if (filter == FFLOAD_SLOBJECT)
 						{
-							llwarns << "*** navOpenFilterProc: FFLOAD_SLOBJECT NOT IMPLEMENTED ***" << llendl;
+							LL_WARNS() << "*** navOpenFilterProc: FFLOAD_SLOBJECT NOT IMPLEMENTED ***" << LL_ENDL;
 						}
 						else if (filter == FFLOAD_RAW)
 						{
@@ -1061,13 +1061,13 @@ void LLFilePicker::add_to_selectedfiles(gpointer data, gpointer user_data)
 		{
 			display_name += (char)((*str >= 0x20 && *str <= 0x7E) ? *str : '?');
 		}
-		llwarns << "g_filename_to_utf8 failed on \"" << display_name << "\": " << error->message << llendl;
+		LL_WARNS() << "g_filename_to_utf8 failed on \"" << display_name << "\": " << error->message << LL_ENDL;
 	}
 
 	if (filename_utf8)
 	{
 		picker->mFiles.push_back(std::string(filename_utf8));
-		lldebugs << "ADDED FILE " << filename_utf8 << llendl;
+		LL_DEBUGS() << "ADDED FILE " << filename_utf8 << LL_ENDL;
 		g_free(filename_utf8);
 	}
 
@@ -1079,7 +1079,7 @@ void LLFilePicker::chooser_responder(GtkWidget *widget, gint response, gpointer
 {
 	LLFilePicker* picker = (LLFilePicker*)user_data;
 
-	lldebugs << "GTK DIALOG RESPONSE " << response << llendl;
+	LL_DEBUGS() << "GTK DIALOG RESPONSE " << response << LL_ENDL;
 
 	if (response == GTK_RESPONSE_ACCEPT)
 	{
@@ -1154,7 +1154,7 @@ GtkWindow* LLFilePicker::buildFilePicker(bool is_save, bool is_folder, std::stri
 		}
 		else
 		{
-			llwarns << "Hmm, couldn't get xwid to use for transient." << llendl;
+			LL_WARNS() << "Hmm, couldn't get xwid to use for transient." << LL_ENDL;
 		}
 #  endif //LL_X11
 
@@ -1467,8 +1467,8 @@ BOOL LLFilePicker::getSaveFile( ESaveFilter filter, const std::string& filename
 
 	reset();
 	
-	llinfos << "getSaveFile suggested filename is [" << filename
-		<< "]" << llendl;
+	LL_INFOS() << "getSaveFile suggested filename is [" << filename
+		<< "]" << LL_ENDL;
 	if (!filename.empty())
 	{
 		mFiles.push_back(gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + filename);
@@ -1498,7 +1498,7 @@ BOOL LLFilePicker::getOpenFile( ELoadFilter filter, bool blocking )
 	default: break;
 	}
 	mFiles.push_back(filename);
-	llinfos << "getOpenFile: Will try to open file: " << filename << llendl;
+	LL_INFOS() << "getOpenFile: Will try to open file: " << filename << LL_ENDL;
 	return TRUE;
 }
 
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 229a55ad23..84f0d115ae 100755
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -473,9 +473,9 @@ void LLServerReleaseNotesURLFetcher::startFetch()
 // virtual
 void LLServerReleaseNotesURLFetcher::completedHeader(U32 status, const std::string& reason, const LLSD& content)
 {
-	lldebugs << "Status: " << status << llendl;
-	lldebugs << "Reason: " << reason << llendl;
-	lldebugs << "Headers: " << content << llendl;
+	LL_DEBUGS() << "Status: " << status << LL_ENDL;
+	LL_DEBUGS() << "Reason: " << reason << LL_ENDL;
+	LL_DEBUGS() << "Headers: " << content << LL_ENDL;
 
 	LLFloaterAbout* floater_about = LLFloaterReg::getTypedInstance<LLFloaterAbout>("sl_about");
 	if (floater_about)
diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp
index 3c40e2d4bc..51b59a7a74 100755
--- a/indra/newview/llfloaterauction.cpp
+++ b/indra/newview/llfloaterauction.cpp
@@ -194,7 +194,7 @@ void LLFloaterAuction::onClickSnapshot(void* data)
 		{
 			gViewerWindow->playSnapshotAnimAndSound();
 		}
-		llinfos << "Writing TGA..." << llendl;
+		LL_INFOS() << "Writing TGA..." << LL_ENDL;
 
 		LLPointer<LLImageTGA> tga = new LLImageTGA;
 		tga->encode(raw);
@@ -202,7 +202,7 @@ void LLFloaterAuction::onClickSnapshot(void* data)
 		
 		raw->biasedScaleToPowerOfTwo(LLViewerTexture::MAX_IMAGE_SIZE_DEFAULT);
 
-		llinfos << "Writing J2C..." << llendl;
+		LL_INFOS() << "Writing J2C..." << LL_ENDL;
 
 		LLPointer<LLImageJ2C> j2c = new LLImageJ2C;
 		j2c->encode(raw, 0.0f);
@@ -214,7 +214,7 @@ void LLFloaterAuction::onClickSnapshot(void* data)
 	}
 	else
 	{
-		llwarns << "Unable to take snapshot" << llendl;
+		LL_WARNS() << "Unable to take snapshot" << LL_ENDL;
 	}
 }
 
@@ -359,8 +359,8 @@ void LLFloaterAuction::doResetParcel()
 		body["user_look_at"] = ll_sd_from_vector3( LLVector3::zero );
 		body["landing_type"] = (U8) LLParcel::L_DIRECT;
 
-		llinfos << "Sending parcel update to reset for auction via capability to: "
-			<< mParcelUpdateCapUrl << llendl;
+		LL_INFOS() << "Sending parcel update to reset for auction via capability to: "
+			<< mParcelUpdateCapUrl << LL_ENDL;
 		LLHTTPClient::post(mParcelUpdateCapUrl, body, new LLHTTPClient::Responder());
 
 		// Send a message to clear the object return time
@@ -509,8 +509,8 @@ void LLFloaterAuction::doSellToAnyone()
 		body["sale_price"] = parcelp->getArea();	// Sell for L$1 per square meter
 		body["auth_buyer_id"] = LLUUID::null;		// To anyone
 
-		llinfos << "Sending parcel update to sell to anyone for L$1 via capability to: "
-			<< mParcelUpdateCapUrl << llendl;
+		LL_INFOS() << "Sending parcel update to sell to anyone for L$1 via capability to: "
+			<< mParcelUpdateCapUrl << LL_ENDL;
 		LLHTTPClient::post(mParcelUpdateCapUrl, body, new LLHTTPClient::Responder());
 
 		// clean up floater, and get out
@@ -526,8 +526,8 @@ void LLFloaterAuction::doSellToAnyone()
 void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	std::string* name = (std::string*)(user_data);
-	llinfos << "Upload of asset '" << *name << "' " << asset_id
-			<< " returned " << status << llendl;
+	LL_INFOS() << "Upload of asset '" << *name << "' " << asset_id
+			<< " returned " << status << LL_ENDL;
 	delete name;
 
 	gViewerWindow->getWindow()->decBusyCount();
@@ -547,8 +547,8 @@ void auction_tga_upload_done(const LLUUID& asset_id, void* user_data, S32 status
 void auction_j2c_upload_done(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status) // StoreAssetData callback (fixed)
 {
 	std::string* name = (std::string*)(user_data);
-	llinfos << "Upload of asset '" << *name << "' " << asset_id
-			<< " returned " << status << llendl;
+	LL_INFOS() << "Upload of asset '" << *name << "' " << asset_id
+			<< " returned " << status << LL_ENDL;
 	delete name;
 
 	gViewerWindow->getWindow()->decBusyCount();
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp
index 76773f914d..8d5352e2a6 100755
--- a/indra/newview/llfloateravatarpicker.cpp
+++ b/indra/newview/llfloateravatarpicker.cpp
@@ -70,7 +70,7 @@ LLFloaterAvatarPicker* LLFloaterAvatarPicker::show(select_callback_t callback,
 		LLFloaterReg::showTypedInstance<LLFloaterAvatarPicker>("avatar_picker", LLSD(name));
 	if (!floater)
 	{
-		llwarns << "Cannot instantiate avatar picker" << llendl;
+		LL_WARNS() << "Cannot instantiate avatar picker" << LL_ENDL;
 		return NULL;
 	}
 	
@@ -468,7 +468,7 @@ public:
 	{
 		//std::ostringstream ss;
 		//LLSDSerialize::toPrettyXML(content, ss);
-		//llinfos << ss.str() << llendl;
+		//LL_INFOS() << ss.str() << LL_ENDL;
 
 		// in case of invalid characters, the avatar picker returns a 400
 		// just set it to process so it displays 'not found'
@@ -483,7 +483,7 @@ public:
 		}
 		else
 		{
-			llwarns << "avatar picker failed [status:" << status << "]: " << content << llendl;
+			LL_WARNS() << "avatar picker failed [status:" << status << "]: " << content << LL_ENDL;
 			
 		}
 	}
@@ -514,7 +514,7 @@ void LLFloaterAvatarPicker::find()
 		}
 		url += "?page_size=100&names=";
 		url += LLURI::escape(text);
-		llinfos << "avatar picker " << url << llendl;
+		LL_INFOS() << "avatar picker " << url << LL_ENDL;
 		LLHTTPClient::get(url, new LLAvatarPickerResponder(mQueryID, getKey().asString()));
 	}
 	else
diff --git a/indra/newview/llfloateravatartextures.cpp b/indra/newview/llfloateravatartextures.cpp
index 317bdd8d46..78807a8e99 100755
--- a/indra/newview/llfloateravatartextures.cpp
+++ b/indra/newview/llfloateravatartextures.cpp
@@ -187,16 +187,16 @@ void LLFloaterAvatarTextures::onClickDump(void* data)
 				}
 				if (id != IMG_DEFAULT_AVATAR)
 				{
-					llinfos << "TE " << i << " name:" << tex_entry->mName << " id:" << id << llendl;
+					LL_INFOS() << "TE " << i << " name:" << tex_entry->mName << " id:" << id << LL_ENDL;
 				}
 				else
 				{
-					llinfos << "TE " << i << " name:" << tex_entry->mName << " id:" << "<DEFAULT>" << llendl;
+					LL_INFOS() << "TE " << i << " name:" << tex_entry->mName << " id:" << "<DEFAULT>" << LL_ENDL;
 				}
 			}
 			else
 			{
-				llinfos << "TE " << i << " name:" << tex_entry->mName << " id:" << te->getID() << llendl;
+				LL_INFOS() << "TE " << i << " name:" << tex_entry->mName << " id:" << te->getID() << LL_ENDL;
 			}
 		}
 	}
diff --git a/indra/newview/llfloaterbulkpermission.cpp b/indra/newview/llfloaterbulkpermission.cpp
index 086da158ad..c202ca1b05 100755
--- a/indra/newview/llfloaterbulkpermission.cpp
+++ b/indra/newview/llfloaterbulkpermission.cpp
@@ -99,7 +99,7 @@ void LLFloaterBulkPermission::doApply()
 		mDone = FALSE;
 		if (!start())
 		{
-			llwarns << "Unexpected bulk permission change failure." << llendl;
+			LL_WARNS() << "Unexpected bulk permission change failure." << LL_ENDL;
 		}
 	}
 }
@@ -113,7 +113,7 @@ void LLFloaterBulkPermission::inventoryChanged(LLViewerObject* viewer_object,
 											 S32,
 											 void* q_id)
 {
-	//llinfos << "changed object: " << viewer_object->getID() << llendl;
+	//LL_INFOS() << "changed object: " << viewer_object->getID() << LL_ENDL;
 
 	//Remove this listener from the object since its
 	//listener callback is now being executed.
@@ -138,7 +138,7 @@ void LLFloaterBulkPermission::inventoryChanged(LLViewerObject* viewer_object,
 		// something went wrong...
 		// note that we're not working on this one, and move onto the
 		// next object in the list.
-		llwarns << "No inventory for " << mCurrentObjectID << llendl;
+		LL_WARNS() << "No inventory for " << mCurrentObjectID << LL_ENDL;
 		nextObject();
 	}
 }
@@ -181,12 +181,12 @@ BOOL LLFloaterBulkPermission::nextObject()
 	do
 	{
 		count = mObjectIDs.size();
-		//llinfos << "Objects left to process = " << count << llendl;
+		//LL_INFOS() << "Objects left to process = " << count << LL_ENDL;
 		mCurrentObjectID.setNull();
 		if(count > 0)
 		{
 			successful_start = popNext();
-			//llinfos << (successful_start ? "successful" : "unsuccessful") << llendl; 
+			//LL_INFOS() << (successful_start ? "successful" : "unsuccessful") << LL_ENDL; 
 		}
 	} while((mObjectIDs.size() > 0) && !successful_start);
 
@@ -208,12 +208,12 @@ BOOL LLFloaterBulkPermission::popNext()
 	if(mCurrentObjectID.isNull() && (count > 0))
 	{
 		mCurrentObjectID = mObjectIDs.at(0);
-		//llinfos << "mCurrentID: " << mCurrentObjectID << llendl;
+		//LL_INFOS() << "mCurrentID: " << mCurrentObjectID << LL_ENDL;
 		mObjectIDs.erase(mObjectIDs.begin());
 		LLViewerObject* obj = gObjectList.findObject(mCurrentObjectID);
 		if(obj)
 		{
-			//llinfos << "requesting inv for " << mCurrentObjectID << llendl;
+			//LL_INFOS() << "requesting inv for " << mCurrentObjectID << LL_ENDL;
 			LLUUID* id = new LLUUID(mID);
 			registerVOInventoryListener(obj,id);
 			requestVOInventory();
@@ -221,7 +221,7 @@ BOOL LLFloaterBulkPermission::popNext()
 		}
 		else
 		{
-			llinfos<<"NULL LLViewerObject" <<llendl;
+			LL_INFOS()<<"NULL LLViewerObject" <<LL_ENDL;
 		}
 	}
 
diff --git a/indra/newview/llfloaterbump.cpp b/indra/newview/llfloaterbump.cpp
index eeb81085bb..ad44c509d9 100755
--- a/indra/newview/llfloaterbump.cpp
+++ b/indra/newview/llfloaterbump.cpp
@@ -110,8 +110,8 @@ void LLFloaterBump::add(LLScrollListCtrl* list, LLMeanCollisionData* mcd)
 		action = "physical_object_collide";
 		break;
 	default:
-		llinfos << "LLFloaterBump::add unknown mean collision type "
-			<< mcd->mType << llendl;
+		LL_INFOS() << "LLFloaterBump::add unknown mean collision type "
+			<< mcd->mType << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llfloaterbuy.cpp b/indra/newview/llfloaterbuy.cpp
index 087b0007e1..5a9cdbba44 100755
--- a/indra/newview/llfloaterbuy.cpp
+++ b/indra/newview/llfloaterbuy.cpp
@@ -194,14 +194,14 @@ void LLFloaterBuy::inventoryChanged(LLViewerObject* obj,
 {
 	if (!obj)
 	{
-		llwarns << "No object in LLFloaterBuy::inventoryChanged" << llendl;
+		LL_WARNS() << "No object in LLFloaterBuy::inventoryChanged" << LL_ENDL;
 		return;
 	}
 
 	if (!inv)
 	{
-		llwarns << "No inventory in LLFloaterBuy::inventoryChanged"
-			<< llendl;
+		LL_WARNS() << "No inventory in LLFloaterBuy::inventoryChanged"
+			<< LL_ENDL;
 		removeVOInventoryListener();
 		return;
 	}
diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp
index aa6ace2a61..b32ac860aa 100755
--- a/indra/newview/llfloaterbuycontents.cpp
+++ b/indra/newview/llfloaterbuycontents.cpp
@@ -145,7 +145,7 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
 {
 	if (!obj)
 	{
-		llwarns << "No object in LLFloaterBuyContents::inventoryChanged" << llendl;
+		LL_WARNS() << "No object in LLFloaterBuyContents::inventoryChanged" << LL_ENDL;
 		return;
 	}
 
@@ -160,8 +160,8 @@ void LLFloaterBuyContents::inventoryChanged(LLViewerObject* obj,
 	
 	if (!inv)
 	{
-		llwarns << "No inventory in LLFloaterBuyContents::inventoryChanged"
-			<< llendl;
+		LL_WARNS() << "No inventory in LLFloaterBuyContents::inventoryChanged"
+			<< LL_ENDL;
 
 		return;
 	}
diff --git a/indra/newview/llfloaterbuycurrencyhtml.cpp b/indra/newview/llfloaterbuycurrencyhtml.cpp
index 013cf74c7b..0c408f556d 100755
--- a/indra/newview/llfloaterbuycurrencyhtml.cpp
+++ b/indra/newview/llfloaterbuycurrencyhtml.cpp
@@ -82,7 +82,7 @@ void LLFloaterBuyCurrencyHTML::navigateToFinalURL()
 	LLStringUtil::format( buy_currency_url, replace );
 
 	// write final URL to debug console
-	llinfos << "Buy currency HTML parsed URL is " << buy_currency_url << llendl;
+	LL_INFOS() << "Buy currency HTML parsed URL is " << buy_currency_url << LL_ENDL;
 
 	// kick off the navigation
 	mBrowser->navigateTo( buy_currency_url, "text/html" );
diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp
index 84e2956b29..da499f96d2 100755
--- a/indra/newview/llfloaterbuyland.cpp
+++ b/indra/newview/llfloaterbuyland.cpp
@@ -877,7 +877,7 @@ void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLXMLRPCVa
 			method = "buyLandPrep";
 			break;
 		default:
-			llwarns << "LLFloaterBuyLandUI: Unknown transaction type!" << llendl;
+			LL_WARNS() << "LLFloaterBuyLandUI: Unknown transaction type!" << LL_ENDL;
 			return;
 	}
 
diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp
index f2deb6a805..a22f5770bf 100755
--- a/indra/newview/llfloaterbvhpreview.cpp
+++ b/indra/newview/llfloaterbvhpreview.cpp
@@ -228,7 +228,7 @@ BOOL LLFloaterBvhPreview::postBuild()
 		
 		if (!infile.getFileHandle())
 		{
-			llwarns << "Can't open BVH file:" << mFilename << llendl;	
+			LL_WARNS() << "Can't open BVH file:" << mFilename << LL_ENDL;	
 		}
 		else
 		{
@@ -239,7 +239,7 @@ BOOL LLFloaterBvhPreview::postBuild()
 			if (file_size == infile.read(file_buffer, file_size))
 			{
 				file_buffer[file_size] = '\0';
-				llinfos << "Loading BVH file " << mFilename << llendl;
+				LL_INFOS() << "Loading BVH file " << mFilename << LL_ENDL;
 				ELoadStatus load_status = E_ST_OK;
 				S32 line_number = 0; 
 				loaderp = new LLBVHLoader(file_buffer, load_status, line_number);
@@ -247,11 +247,11 @@ BOOL LLFloaterBvhPreview::postBuild()
 				
 				if(load_status == E_ST_NO_XLT_FILE)
 				{
-					llwarns << "NOTE: No translation table found." << llendl;
+					LL_WARNS() << "NOTE: No translation table found." << LL_ENDL;
 				}
 				else
 				{
-					llwarns << "ERROR: [line: " << line_number << "] " << status << llendl;
+					LL_WARNS() << "ERROR: [line: " << line_number << "] " << status << LL_ENDL;
 				}
 			}
 
@@ -1009,7 +1009,7 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata)
 			}
 			else
 			{
-				llwarns << "Failure writing animation data." << llendl;
+				LL_WARNS() << "Failure writing animation data." << LL_ENDL;
 				LLNotificationsUtil::add("WriteAnimationFail");
 			}
 		}
diff --git a/indra/newview/llfloaterdeleteenvpreset.cpp b/indra/newview/llfloaterdeleteenvpreset.cpp
index d08aa81cfe..bb11c813b4 100755
--- a/indra/newview/llfloaterdeleteenvpreset.cpp
+++ b/indra/newview/llfloaterdeleteenvpreset.cpp
@@ -144,7 +144,7 @@ void LLFloaterDeleteEnvPreset::onBtnDelete()
 	}
 	else
 	{
-		llwarns << "Unrecognized key" << llendl;
+		LL_WARNS() << "Unrecognized key" << LL_ENDL;
 	}
 
 	LLSD args;
@@ -176,7 +176,7 @@ void LLFloaterDeleteEnvPreset::populatePresetsList()
 	}
 	else
 	{
-		llwarns << "Unrecognized key" << llendl;
+		LL_WARNS() << "Unrecognized key" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp
index e2cef5630b..596e8c0dbe 100755
--- a/indra/newview/llfloaterdisplayname.cpp
+++ b/indra/newview/llfloaterdisplayname.cpp
@@ -127,7 +127,7 @@ void LLFloaterDisplayName::onCacheSetName(bool success,
 
 	// Request failed, notify the user
 	std::string error_tag = content["error_tag"].asString();
-	llinfos << "set name failure error_tag " << error_tag << llendl;
+	LL_INFOS() << "set name failure error_tag " << error_tag << LL_ENDL;
 
 	// We might have a localized string for this message
 	// error_args will usually be empty from the server.
diff --git a/indra/newview/llfloatereditdaycycle.cpp b/indra/newview/llfloatereditdaycycle.cpp
index b63677b258..e987a0e0b1 100755
--- a/indra/newview/llfloatereditdaycycle.cpp
+++ b/indra/newview/llfloatereditdaycycle.cpp
@@ -172,7 +172,7 @@ void LLFloaterEditDayCycle::loadTrack()
 
 	// add sliders
 
-	lldebugs << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << llendl;
+	LL_DEBUGS() << "Adding " << LLWLParamManager::getInstance()->mDay.mTimeMap.size() << " keys to slider" << LL_ENDL;
 
 	LLWLDayCycle& cur_dayp = LLWLParamManager::instance().mDay;
 	for (std::map<F32, LLWLParamKey>::iterator it = cur_dayp.mTimeMap.begin(); it != cur_dayp.mTimeMap.end(); ++it)
@@ -192,12 +192,12 @@ void LLFloaterEditDayCycle::loadTrack()
 
 void LLFloaterEditDayCycle::applyTrack()
 {
-	lldebugs << "Applying track (" << mSliderToKey.size() << ")" << llendl;
+	LL_DEBUGS() << "Applying track (" << mSliderToKey.size() << ")" << LL_ENDL;
 
 	// if no keys, do nothing
 	if (mSliderToKey.size() == 0)
 	{
-		lldebugs << "No keys, not syncing" << llendl;
+		LL_DEBUGS() << "No keys, not syncing" << LL_ENDL;
 		return;
 	}
 
@@ -342,7 +342,7 @@ void LLFloaterEditDayCycle::onKeyTimeMoved()
 
 	// check to see if a key exists
 	LLWLParamKey key = mSliderToKey[cur_sldr].keyframe;
-	lldebugs << "Setting key time: " << time24 << LL_ENDL;
+	LL_DEBUGS() << "Setting key time: " << time24 << LL_ENDL;
 	mSliderToKey[cur_sldr].time = time24;
 
 	// if it exists, turn on check box
@@ -368,7 +368,7 @@ void LLFloaterEditDayCycle::onKeyTimeChanged()
 	F32 time = mKeysSlider->getCurSliderValue() / sHoursPerDay;
 
 	// now set the key's time in the sliderToKey map
-	lldebugs << "Setting key time: " << time << LL_ENDL;
+	LL_DEBUGS() << "Setting key time: " << time << LL_ENDL;
 	mSliderToKey[cur_sldr].time = time;
 
 	applyTrack();
@@ -564,7 +564,7 @@ void LLFloaterEditDayCycle::saveRegionDayCycle()
 #else // Temporary disabled ability to upload new region settings from the Day Cycle Editor.
 	if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings))
 	{
-		llwarns << "Error applying region environment settings" << llendl;
+		LL_WARNS() << "Error applying region environment settings" << LL_ENDL;
 		return;
 	}
 
@@ -637,7 +637,7 @@ void LLFloaterEditDayCycle::onRegionSettingsChange()
 		// Change preference if requested.
 		if (mMakeDefaultCheckBox->getValue())
 		{
-			LL_DEBUGS("Windlight") << "Changed environment preference to region settings" << llendl;
+			LL_DEBUGS("Windlight") << "Changed environment preference to region settings" << LL_ENDL;
 			LLEnvManagerNew::instance().setUseRegionSettings(true);
 		}
 
@@ -699,7 +699,7 @@ void LLFloaterEditDayCycle::onDayCycleSelected()
 	{
 		if (!LLDayCycleManager::instance().getPreset(dc_key.name, day_data))
 		{
-			llwarns << "No day cycle named " << dc_key.name << llendl;
+			LL_WARNS() << "No day cycle named " << dc_key.name << LL_ENDL;
 			return;
 		}
 	}
@@ -708,7 +708,7 @@ void LLFloaterEditDayCycle::onDayCycleSelected()
 		day_data = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle();
 		if (day_data.size() == 0)
 		{
-			llwarns << "Empty region day cycle" << llendl;
+			LL_WARNS() << "Empty region day cycle" << LL_ENDL;
 			llassert(day_data.size() > 0);
 			return;
 		}
@@ -742,7 +742,7 @@ void LLFloaterEditDayCycle::onBtnSave()
 	if (name.empty())
 	{
 		// *TODO: show an alert
-		llwarns << "Empty day cycle name" << llendl;
+		LL_WARNS() << "Empty day cycle name" << LL_ENDL;
 		return;
 	}
 
@@ -795,7 +795,7 @@ void LLFloaterEditDayCycle::onSaveConfirmed()
 	// Change preference if requested.
 	if (mMakeDefaultCheckBox->getValue())
 	{
-		LL_DEBUGS("Windlight") << name << " is now the new preferred day cycle" << llendl;
+		LL_DEBUGS("Windlight") << name << " is now the new preferred day cycle" << LL_ENDL;
 		LLEnvManagerNew::instance().setUseDayCycle(name);
 	}
 
diff --git a/indra/newview/llfloatereditsky.cpp b/indra/newview/llfloatereditsky.cpp
index 352361ce9e..d809211ea7 100755
--- a/indra/newview/llfloatereditsky.cpp
+++ b/indra/newview/llfloatereditsky.cpp
@@ -721,7 +721,7 @@ void LLFloaterEditSky::saveRegionSky()
 	LLWLParamKey key(getSelectedSkyPreset());
 	llassert(key.scope == LLEnvKey::SCOPE_REGION);
 
-	LL_DEBUGS("Windlight") << "Saving region sky preset: " << key.name  << llendl;
+	LL_DEBUGS("Windlight") << "Saving region sky preset: " << key.name  << LL_ENDL;
 	LLWLParamManager& wl_mgr = LLWLParamManager::instance();
 	wl_mgr.mCurParams.mName = key.name;
 	wl_mgr.setParamSet(key, wl_mgr.mCurParams);
@@ -819,7 +819,7 @@ void LLFloaterEditSky::onSaveConfirmed()
 	// Change preference if requested.
 	if (mMakeDefaultCheckBox->getValue())
 	{
-		LL_DEBUGS("Windlight") << key.name << " is now the new preferred sky preset" << llendl;
+		LL_DEBUGS("Windlight") << key.name << " is now the new preferred sky preset" << LL_ENDL;
 		LLEnvManagerNew::instance().setUseSkyPreset(key.name);
 	}
 
@@ -842,7 +842,7 @@ void LLFloaterEditSky::onBtnSave()
 	if (name.empty())
 	{
 		// *TODO: show an alert
-		llwarns << "Empty sky preset name" << llendl;
+		LL_WARNS() << "Empty sky preset name" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llfloatereditwater.cpp b/indra/newview/llfloatereditwater.cpp
index 64cfc4054f..43b44eae37 100755
--- a/indra/newview/llfloatereditwater.cpp
+++ b/indra/newview/llfloatereditwater.cpp
@@ -546,7 +546,7 @@ void LLFloaterEditWater::saveRegionWater()
 {
 	llassert(getCurrentScope() == LLEnvKey::SCOPE_REGION); // make sure we're editing region water
 
-	LL_DEBUGS("Windlight") << "Saving region water preset" << llendl;
+	LL_DEBUGS("Windlight") << "Saving region water preset" << LL_ENDL;
 
 	//LLWaterParamSet region_water = water_mgr.mCurParams;
 
@@ -665,7 +665,7 @@ void LLFloaterEditWater::onSaveConfirmed()
 	// Change preference if requested.
 	if (mMakeDefaultCheckBox->getEnabled() && mMakeDefaultCheckBox->getValue())
 	{
-		LL_DEBUGS("Windlight") << name << " is now the new preferred water preset" << llendl;
+		LL_DEBUGS("Windlight") << name << " is now the new preferred water preset" << LL_ENDL;
 		LLEnvManagerNew::instance().setUseWaterPreset(name);
 	}
 
@@ -688,7 +688,7 @@ void LLFloaterEditWater::onBtnSave()
 	if (name.empty())
 	{
 		// *TODO: show an alert
-		llwarns << "Empty water preset name" << llendl;
+		LL_WARNS() << "Empty water preset name" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp
index fe6223fbf5..6966ca5639 100755
--- a/indra/newview/llfloatergodtools.cpp
+++ b/indra/newview/llfloatergodtools.cpp
@@ -796,7 +796,7 @@ void LLPanelRegionTools::onSwapTerrain()
 
 void LLPanelRegionTools::onSelectRegion()
 {
-	llinfos << "LLPanelRegionTools::onSelectRegion" << llendl;
+	LL_INFOS() << "LLPanelRegionTools::onSelectRegion" << LL_ENDL;
 
 	LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(gAgent.getPositionGlobal());
 	if (!regionp)
@@ -1262,8 +1262,8 @@ void LLPanelRequestTools::sendRequest(const std::string& request,
 									  const std::string& parameter, 
 									  const LLHost& host)
 {
-	llinfos << "Sending request '" << request << "', '"
-			<< parameter << "' to " << host << llendl;
+	LL_INFOS() << "Sending request '" << request << "', '"
+			<< parameter << "' to " << host << LL_ENDL;
 	LLMessageSystem* msg = gMessageSystem;
 	msg->newMessage("GodlikeMessage");
 	msg->nextBlockFast(_PREHASH_AgentData);
@@ -1316,7 +1316,7 @@ void terrain_download_done(void** data, S32 status, LLExtStat ext_status)
 
 void test_callback(const LLTSCode status)
 {
-	llinfos << "Test transfer callback returned!" << llendl;
+	LL_INFOS() << "Test transfer callback returned!" << LL_ENDL;
 }
 
 
diff --git a/indra/newview/llfloatergroupinvite.cpp b/indra/newview/llfloatergroupinvite.cpp
index 49da4e64b3..e1639d9e63 100755
--- a/indra/newview/llfloatergroupinvite.cpp
+++ b/indra/newview/llfloatergroupinvite.cpp
@@ -115,7 +115,7 @@ void LLFloaterGroupInvite::showForGroup(const LLUUID& group_id, uuid_vec_t *agen
 	// Make sure group_id isn't null
 	if (group_id.isNull())
 	{
-		llwarns << "LLFloaterGroupInvite::showForGroup with null group_id!" << llendl;
+		LL_WARNS() << "LLFloaterGroupInvite::showForGroup with null group_id!" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp
index b40789db9c..c1cd3d1d93 100755
--- a/indra/newview/llfloaterimcontainer.cpp
+++ b/indra/newview/llfloaterimcontainer.cpp
@@ -412,7 +412,7 @@ bool LLFloaterIMContainer::onConversationModelEvent(const LLSD& event)
 	// For debug only
 	//std::ostringstream llsd_value;
 	//llsd_value << LLSDOStreamer<LLSDNotationFormatter>(event) << std::endl;
-	//llinfos << "LLFloaterIMContainer::onConversationModelEvent, event = " << llsd_value.str() << llendl;
+	//LL_INFOS() << "LLFloaterIMContainer::onConversationModelEvent, event = " << llsd_value.str() << LL_ENDL;
 	// end debug
 	
 	// Note: In conversations, the model is not responsible for creating the view, which is a good thing. This means that
@@ -1527,7 +1527,7 @@ LLConversationItem* LLFloaterIMContainer::addConversationListItem(const LLUUID&
 	}
 	if (!item)
 	{
-		llwarns << "Couldn't create conversation session item : " << display_name << llendl;
+		LL_WARNS() << "Couldn't create conversation session item : " << display_name << LL_ENDL;
 		return NULL;
 	}
 	item->renameItem(display_name);
@@ -1709,7 +1709,7 @@ bool LLFloaterIMContainer::isGroupModerator()
 	LLSpeakerMgr * speaker_manager = getSpeakerMgrForSelectedParticipant();
 	if (NULL == speaker_manager)
 	{
-		llwarns << "Speaker manager is missing" << llendl;
+		LL_WARNS() << "Speaker manager is missing" << LL_ENDL;
 		return false;
 	}
 
@@ -1801,7 +1801,7 @@ LLSpeakerMgr * LLFloaterIMContainer::getSpeakerMgrForSelectedParticipant()
 	LLFolderViewItem *selectedItem = mConversationsRoot->getCurSelectedItem();
 	if (NULL == selectedItem)
 	{
-		llwarns << "Current selected item is null" << llendl;
+		LL_WARNS() << "Current selected item is null" << LL_ENDL;
 		return NULL;
 	}
 
@@ -1819,7 +1819,7 @@ LLSpeakerMgr * LLFloaterIMContainer::getSpeakerMgrForSelectedParticipant()
 	}
 	if (NULL == conversation_uuidp)
 	{
-		llwarns << "Cannot find conversation item widget" << llendl;
+		LL_WARNS() << "Cannot find conversation item widget" << LL_ENDL;
 		return NULL;
 	}
 
@@ -1831,14 +1831,14 @@ LLSpeaker * LLFloaterIMContainer::getSpeakerOfSelectedParticipant(LLSpeakerMgr *
 {
 	if (NULL == speaker_managerp)
 	{
-		llwarns << "Speaker manager is missing" << llendl;
+		LL_WARNS() << "Speaker manager is missing" << LL_ENDL;
 		return NULL;
 	}
 
 	const LLConversationItem * participant_itemp = getCurSelectedViewModelItem();
 	if (NULL == participant_itemp)
 	{
-		llwarns << "Cannot evaluate current selected view model item" << llendl;
+		LL_WARNS() << "Cannot evaluate current selected view model item" << LL_ENDL;
 		return NULL;
 	}
 
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index 2287277acf..886af6ed15 100755
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -498,10 +498,10 @@ void LLFloaterIMNearbyChat::onChatBoxKeystroke()
 			mInputEditor->endOfDoc();
 		}
 
-		//llinfos << "GESTUREDEBUG " << trigger 
+		//LL_INFOS() << "GESTUREDEBUG " << trigger 
 		//	<< " len " << length
 		//	<< " outlen " << out_str.getLength()
-		//	<< llendl;
+		//	<< LL_ENDL;
 	}
 }
 
@@ -688,22 +688,22 @@ void LLFloaterIMNearbyChat::sendChatFromViewer(const LLWString &wtext, EChatType
 	{
 		if (type == CHAT_TYPE_WHISPER)
 		{
-			lldebugs << "You whisper " << utf8_text << llendl;
+			LL_DEBUGS() << "You whisper " << utf8_text << LL_ENDL;
 			gAgent.sendAnimationRequest(ANIM_AGENT_WHISPER, ANIM_REQUEST_START);
 		}
 		else if (type == CHAT_TYPE_NORMAL)
 		{
-			lldebugs << "You say " << utf8_text << llendl;
+			LL_DEBUGS() << "You say " << utf8_text << LL_ENDL;
 			gAgent.sendAnimationRequest(ANIM_AGENT_TALK, ANIM_REQUEST_START);
 		}
 		else if (type == CHAT_TYPE_SHOUT)
 		{
-			lldebugs << "You shout " << utf8_text << llendl;
+			LL_DEBUGS() << "You shout " << utf8_text << LL_ENDL;
 			gAgent.sendAnimationRequest(ANIM_AGENT_SHOUT, ANIM_REQUEST_START);
 		}
 		else
 		{
-			llinfos << "send_chat_from_viewer() - invalid volume" << llendl;
+			LL_INFOS() << "send_chat_from_viewer() - invalid volume" << LL_ENDL;
 			return;
 		}
 	}
@@ -711,7 +711,7 @@ void LLFloaterIMNearbyChat::sendChatFromViewer(const LLWString &wtext, EChatType
 	{
 		if (type != CHAT_TYPE_START && type != CHAT_TYPE_STOP)
 		{
-			lldebugs << "Channel chat: " << utf8_text << llendl;
+			LL_DEBUGS() << "Channel chat: " << utf8_text << LL_ENDL;
 		}
 	}
 
diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp
index 9ce5e12897..e0fcbb58f6 100755
--- a/indra/newview/llfloaterimnearbychathandler.cpp
+++ b/indra/newview/llfloaterimnearbychathandler.cpp
@@ -111,7 +111,7 @@ public:
 
 	virtual void deleteAllChildren()
 	{
-		LL_DEBUGS("NearbyChat") << "Clearing toast pool" << llendl;
+		LL_DEBUGS("NearbyChat") << "Clearing toast pool" << LL_ENDL;
 		m_toast_pool.clear();
 		m_active_toasts.clear();
 		LLScreenChannelBase::deleteAllChildren();
@@ -122,7 +122,7 @@ protected:
 	void	addToToastPool(LLToast* toast)
 	{
 		if (!toast) return;
-		LL_DEBUGS("NearbyChat") << "Pooling toast" << llendl;
+		LL_DEBUGS("NearbyChat") << "Pooling toast" << LL_ENDL;
 		toast->setVisible(FALSE);
 		toast->stopTimer();
 		toast->setIsHidden(true);
@@ -193,7 +193,7 @@ void LLFloaterIMNearbyChatScreenChannel::deactivateToast(LLToast* toast)
 		return;
 	}
 
-	LL_DEBUGS("NearbyChat") << "Deactivating toast" << llendl;
+	LL_DEBUGS("NearbyChat") << "Deactivating toast" << LL_ENDL;
 	m_active_toasts.erase(pos);
 }
 
@@ -204,7 +204,7 @@ void	LLFloaterIMNearbyChatScreenChannel::createOverflowToast(S32 bottom, F32 tim
 
 void LLFloaterIMNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool app_quitting)
 {	
-	LL_DEBUGS("NearbyChat") << "Toast destroyed (app_quitting=" << app_quitting << ")" << llendl;
+	LL_DEBUGS("NearbyChat") << "Toast destroyed (app_quitting=" << app_quitting << ")" << LL_ENDL;
 
 	if (app_quitting)
 	{
@@ -223,7 +223,7 @@ void LLFloaterIMNearbyChatScreenChannel::onToastDestroyed(LLToast* toast, bool a
 
 void LLFloaterIMNearbyChatScreenChannel::onToastFade(LLToast* toast)
 {	
-	LL_DEBUGS("NearbyChat") << "Toast fading" << llendl;
+	LL_DEBUGS("NearbyChat") << "Toast fading" << LL_ENDL;
 
 	//fade mean we put toast to toast pool
 	if(!toast)
@@ -277,7 +277,7 @@ bool	LLFloaterIMNearbyChatScreenChannel::createPoolToast()
 	// If the toast gets somehow prematurely destroyed, deactivate it to prevent crash (STORM-1352).
 	toast->setOnToastDestroyedCallback(boost::bind(&LLFloaterIMNearbyChatScreenChannel::onToastDestroyed, this, _1, false));
 
-	LL_DEBUGS("NearbyChat") << "Creating and pooling toast" << llendl;	
+	LL_DEBUGS("NearbyChat") << "Creating and pooling toast" << LL_ENDL;	
 	m_toast_pool.push_back(toast->getHandle());
 	return true;
 }
@@ -318,7 +318,7 @@ void LLFloaterIMNearbyChatScreenChannel::addChat(LLSD& chat)
 	if(m_toast_pool.empty())
 	{
 		//"pool" is empty - create one more panel
-		LL_DEBUGS("NearbyChat") << "Empty pool" << llendl;
+		LL_DEBUGS("NearbyChat") << "Empty pool" << LL_ENDL;
 		if(!createPoolToast())//created toast will go to pool. so next call will find it
 			return;
 		addChat(chat);
@@ -338,7 +338,7 @@ void LLFloaterIMNearbyChatScreenChannel::addChat(LLSD& chat)
 
 	//take 1st element from pool, (re)initialize it, put it in active toasts
 
-	LL_DEBUGS("NearbyChat") << "Getting toast from pool" << llendl;
+	LL_DEBUGS("NearbyChat") << "Getting toast from pool" << LL_ENDL;
 	LLToast* toast = m_toast_pool.back().get();
 
 	m_toast_pool.pop_back();
@@ -406,7 +406,7 @@ void LLFloaterIMNearbyChatScreenChannel::arrangeToasts()
 		LLToast* toast = it->get();
 		if (!toast)
 		{
-			llwarns << "NULL found in the active chat toasts list!" << llendl;
+			LL_WARNS() << "NULL found in the active chat toasts list!" << LL_ENDL;
 			continue;
 		}
 
diff --git a/indra/newview/llfloaterimsession.cpp b/indra/newview/llfloaterimsession.cpp
index 6116f693e6..af76551bd4 100644
--- a/indra/newview/llfloaterimsession.cpp
+++ b/indra/newview/llfloaterimsession.cpp
@@ -148,7 +148,7 @@ void LLFloaterIMSession::onClickCloseBtn()
 	}
 	else
 	{
-		llwarns << "Empty session with id: " << (mSessionID.asString()) << llendl;
+		LL_WARNS() << "Empty session with id: " << (mSessionID.asString()) << LL_ENDL;
 		return;
 	}
 
@@ -250,7 +250,7 @@ void LLFloaterIMSession::sendMsgFromInputEditor()
 	}
 	else
 	{
-		llinfos << "Cannot send IM to everyone unless you're a god." << llendl;
+		LL_INFOS() << "Cannot send IM to everyone unless you're a god." << LL_ENDL;
 	}
 }
 
@@ -1159,8 +1159,8 @@ public:
 
 	void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "Error inviting all agents to session [status:" 
-				<< statusNum << "]: " << content << llendl;
+		LL_WARNS() << "Error inviting all agents to session [status:" 
+				<< statusNum << "]: " << content << LL_ENDL;
 		//throw something back to the viewer here?
 	}
 
@@ -1179,7 +1179,7 @@ BOOL LLFloaterIMSession::inviteToSession(const uuid_vec_t& ids)
 
 		if( isInviteAllowed() && (count > 0) )
 		{
-			llinfos << "LLFloaterIMSession::inviteToSession() - inviting participants" << llendl;
+			LL_INFOS() << "LLFloaterIMSession::inviteToSession() - inviting participants" << LL_ENDL;
 
 			std::string url = region->getCapability("ChatSessionRequest");
 
@@ -1195,9 +1195,9 @@ BOOL LLFloaterIMSession::inviteToSession(const uuid_vec_t& ids)
 		}
 		else
 		{
-			llinfos << "LLFloaterIMSession::inviteToSession -"
+			LL_INFOS() << "LLFloaterIMSession::inviteToSession -"
 					<< " no need to invite agents for "
-					<< mDialog << llendl;
+					<< mDialog << LL_ENDL;
 			// successful add, because everyone that needed to get added
 			// was added.
 		}
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 2194c1112a..544eee396b 100755
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -936,7 +936,7 @@ void LLPanelLandGeneral::onClickRelease(void*)
 // static
 void LLPanelLandGeneral::onClickReclaim(void*)
 {
-	lldebugs << "LLPanelLandGeneral::onClickReclaim()" << llendl;
+	LL_DEBUGS() << "LLPanelLandGeneral::onClickReclaim()" << LL_ENDL;
 	LLViewerParcelMgr::getInstance()->reclaimParcel();
 }
 
@@ -1541,8 +1541,8 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo
 
 	if (!self)
 	{
-		llwarns << "Received message for nonexistent LLPanelLandObject"
-				<< llendl;
+		LL_WARNS() << "Received message for nonexistent LLPanelLandObject"
+				<< LL_ENDL;
 		return;
 	}
 	
@@ -1612,8 +1612,8 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo
 
 		self->mOwnerList->addNameItemRow(item_params);
 
-		lldebugs << "object owner " << owner_id << " (" << (is_group_owned ? "group" : "agent")
-				<< ") owns " << object_count << " objects." << llendl;
+		LL_DEBUGS() << "object owner " << owner_id << " (" << (is_group_owned ? "group" : "agent")
+				<< ") owns " << object_count << " objects." << LL_ENDL;
 	}
 	// check for no results
 	if (0 == self->mOwnerList->getItemCount())
@@ -1894,7 +1894,7 @@ BOOL LLPanelLandOptions::postBuild()
 	}
 	else
 	{
-		llwarns << "LLUICtrlFactory::getTexturePickerByName() returned NULL for 'snapshot_ctrl'" << llendl;
+		LL_WARNS() << "LLUICtrlFactory::getTexturePickerByName() returned NULL for 'snapshot_ctrl'" << LL_ENDL;
 	}
 
 
diff --git a/indra/newview/llfloaterlandholdings.cpp b/indra/newview/llfloaterlandholdings.cpp
index ea94dcd7b6..cf03087afb 100755
--- a/indra/newview/llfloaterlandholdings.cpp
+++ b/indra/newview/llfloaterlandholdings.cpp
@@ -194,7 +194,7 @@ void LLFloaterLandHoldings::processPlacesReply(LLMessageSystem* msg, void**)
 		if ( msg->getSizeFast(_PREHASH_QueryData, i, _PREHASH_ProductSKU) > 0 )
 		{
 			msg->getStringFast(	_PREHASH_QueryData, _PREHASH_ProductSKU, land_sku, i);
-			llinfos << "Land sku: " << land_sku << llendl;
+			LL_INFOS() << "Land sku: " << land_sku << LL_ENDL;
 			land_type = LLProductInfoRequestManager::instance().getDescriptionForSku(land_sku);
 		}
 		else
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 49ddcc7d18..0dcfdf61bb 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -292,14 +292,14 @@ bool validate_face(const LLVolumeFace& face)
 	{
 		if (face.mIndices[i] >= face.mNumVertices)
 		{
-			llwarns << "Face has invalid index." << llendl;
+			LL_WARNS() << "Face has invalid index." << LL_ENDL;
 			return false;
 		}
 	}
 
 	if (face.mNumIndices % 3 != 0 || face.mNumIndices == 0)
 	{
-		llwarns << "Face has invalid number of indices." << llendl;
+		LL_WARNS() << "Face has invalid number of indices." << LL_ENDL;
 		return false;
 	}
 
@@ -317,7 +317,7 @@ bool validate_face(const LLVolumeFace& face)
 
 		if (ll_is_degenerate(v1,v2,v3))
 		{
-			llwarns << "Degenerate face found!" << llendl;
+			LL_WARNS() << "Degenerate face found!" << LL_ENDL;
 			return false;
 		}
 	}*/
@@ -329,7 +329,7 @@ bool validate_model(const LLModel* mdl)
 {
 	if (mdl->getNumVolumeFaces() == 0)
 	{
-		llwarns << "Model has no faces!" << llendl;
+		LL_WARNS() << "Model has no faces!" << LL_ENDL;
 		return false;
 	}
 
@@ -337,13 +337,13 @@ bool validate_model(const LLModel* mdl)
 	{
 		if (mdl->getVolumeFace(i).mNumVertices == 0)
 		{
-			llwarns << "Face has no vertices." << llendl;
+			LL_WARNS() << "Face has no vertices." << LL_ENDL;
 			return false;
 		}
 
 		if (mdl->getVolumeFace(i).mNumIndices == 0)
 		{
-			llwarns << "Face has no indices." << llendl;
+			LL_WARNS() << "Face has no indices." << LL_ENDL;
 			return false;
 		}
 
@@ -362,7 +362,7 @@ BOOL stop_gloderror()
 
 	if (error != GLOD_NO_ERROR)
 	{
-		llwarns << "GLOD error detected, cannot generate LOD: " << std::hex << error << llendl;
+		LL_WARNS() << "GLOD error detected, cannot generate LOD: " << std::hex << error << LL_ENDL;
 		return TRUE;
 	}
 
@@ -930,7 +930,7 @@ void LLFloaterModelPreview::onPhysicsParamCommit(LLUICtrl* ctrl, void* data)
 {
 	if (LLConvexDecomposition::getInstance() == NULL)
 	{
-		llinfos << "convex decomposition tool is a stub on this platform. cannot get decomp." << llendl;
+		LL_INFOS() << "convex decomposition tool is a stub on this platform. cannot get decomp." << LL_ENDL;
 		return;
 	}
 
@@ -978,7 +978,7 @@ void LLFloaterModelPreview::onPhysicsStageExecute(LLUICtrl* ctrl, void* data)
 	{
 		if (!sInstance->mCurRequest.empty())
 		{
-			llinfos << "Decomposition request still pending." << llendl;
+			LL_INFOS() << "Decomposition request still pending." << LL_ENDL;
 			return;
 		}
 
@@ -1029,13 +1029,13 @@ void LLFloaterModelPreview::onPhysicsUseLOD(LLUICtrl* ctrl, void* userdata)
 	}
 	else
 	{
-		llwarns << "no iface" << llendl;
+		LL_WARNS() << "no iface" << LL_ENDL;
 		return;
 	}
 
 	if (which_mode <= 0)
 	{
-		llwarns << "which_mode out of range, " << which_mode << llendl;
+		LL_WARNS() << "which_mode out of range, " << which_mode << LL_ENDL;
 	}
 
 	S32 file_mode = iface->getItemCount() - 1;
@@ -1120,8 +1120,8 @@ void LLFloaterModelPreview::initDecompControls()
 		// protected against stub by stage_count being 0 for stub above
 		LLConvexDecomposition::getInstance()->registerCallback(j, LLPhysicsDecomp::llcdCallback);
 
-		//llinfos << "Physics decomp stage " << stage[j].mName << " (" << j << ") parameters:" << llendl;
-		//llinfos << "------------------------------------" << llendl;
+		//LL_INFOS() << "Physics decomp stage " << stage[j].mName << " (" << j << ") parameters:" << LL_ENDL;
+		//LL_INFOS() << "------------------------------------" << LL_ENDL;
 
 		for (S32 i = 0; i < param_count; ++i)
 		{
@@ -1135,12 +1135,12 @@ void LLFloaterModelPreview::initDecompControls()
 
 			std::string type = "unknown";
 
-			llinfos << name << " - " << description << llendl;
+			LL_INFOS() << name << " - " << description << LL_ENDL;
 
 			if (param[i].mType == LLCDParam::LLCD_FLOAT)
 			{
 				mDecompParams[param[i].mName] = LLSD(param[i].mDefault.mFloat);
-				//llinfos << "Type: float, Default: " << param[i].mDefault.mFloat << llendl;
+				//LL_INFOS() << "Type: float, Default: " << param[i].mDefault.mFloat << LL_ENDL;
 
 
 				LLUICtrl* ctrl = getChild<LLUICtrl>(name);
@@ -1190,7 +1190,7 @@ void LLFloaterModelPreview::initDecompControls()
 			else if (param[i].mType == LLCDParam::LLCD_INTEGER)
 			{
 				mDecompParams[param[i].mName] = LLSD(param[i].mDefault.mIntOrEnumValue);
-				//llinfos << "Type: integer, Default: " << param[i].mDefault.mIntOrEnumValue << llendl;
+				//LL_INFOS() << "Type: integer, Default: " << param[i].mDefault.mIntOrEnumValue << LL_ENDL;
 
 
 				LLUICtrl* ctrl = getChild<LLUICtrl>(name);
@@ -1216,7 +1216,7 @@ void LLFloaterModelPreview::initDecompControls()
 			else if (param[i].mType == LLCDParam::LLCD_BOOLEAN)
 			{
 				mDecompParams[param[i].mName] = LLSD(param[i].mDefault.mBool);
-				//llinfos << "Type: boolean, Default: " << (param[i].mDefault.mBool ? "True" : "False") << llendl;
+				//LL_INFOS() << "Type: boolean, Default: " << (param[i].mDefault.mBool ? "True" : "False") << LL_ENDL;
 
 				LLCheckBoxCtrl* check_box = getChild<LLCheckBoxCtrl>(name);
 				if (check_box)
@@ -1228,16 +1228,16 @@ void LLFloaterModelPreview::initDecompControls()
 			else if (param[i].mType == LLCDParam::LLCD_ENUM)
 			{
 				mDecompParams[param[i].mName] = LLSD(param[i].mDefault.mIntOrEnumValue);
-				//llinfos << "Type: enum, Default: " << param[i].mDefault.mIntOrEnumValue << llendl;
+				//LL_INFOS() << "Type: enum, Default: " << param[i].mDefault.mIntOrEnumValue << LL_ENDL;
 
 				{ //plug into combo box
 
-					//llinfos << "Accepted values: " << llendl;
+					//LL_INFOS() << "Accepted values: " << LL_ENDL;
 					LLComboBox* combo_box = getChild<LLComboBox>(name);
 					for (S32 k = 0; k < param[i].mDetails.mEnumValues.mNumEnums; ++k)
 					{
-						//llinfos << param[i].mDetails.mEnumValues.mEnumsArray[k].mValue
-						//	<< " - " << param[i].mDetails.mEnumValues.mEnumsArray[k].mName << llendl;
+						//LL_INFOS() << param[i].mDetails.mEnumValues.mEnumsArray[k].mValue
+						//	<< " - " << param[i].mDetails.mEnumValues.mEnumsArray[k].mName << LL_ENDL;
 
 						std::string name(param[i].mDetails.mEnumValues.mEnumsArray[k].mName);
 						std::string localized_name;
@@ -1250,9 +1250,9 @@ void LLFloaterModelPreview::initDecompControls()
 					combo_box->setCommitCallback(onPhysicsParamCommit, (void*) &param[i]);
 				}
 
-				//llinfos << "----" << llendl;
+				//LL_INFOS() << "----" << LL_ENDL;
 			}
-			//llinfos << "-----------------------------" << llendl;
+			//LL_INFOS() << "-----------------------------" << LL_ENDL;
 		}
 	}
 
@@ -1499,14 +1499,14 @@ bool LLModelLoader::doLoadModel()
 	
 	if (!dom)
 	{
-		llinfos<<" Error with dae - traditionally indicates a corrupt file."<<llendl;
+		LL_INFOS()<<" Error with dae - traditionally indicates a corrupt file."<<LL_ENDL;
 		setLoadState( ERROR_PARSING );
 		return false;
 	}
 	//Dom version
 	daeString domVersion = dae.getDomVersion();
 	std::string sldom(domVersion);
-	llinfos<<"Collada Importer Version: "<<sldom<<llendl;
+	LL_INFOS()<<"Collada Importer Version: "<<sldom<<LL_ENDL;
 	//Dae version
 	domVersionType docVersion = dom->getVersion();
 	//0=1.4
@@ -1516,7 +1516,7 @@ bool LLModelLoader::doLoadModel()
 	{ 
 		docVersion = VERSIONTYPE_COUNT;
 	}
-	llinfos<<"Dae version "<<colladaVersion[docVersion]<<llendl;
+	LL_INFOS()<<"Dae version "<<colladaVersion[docVersion]<<LL_ENDL;
 	
 	
 	daeDatabase* db = dae.getDatabase();
@@ -1526,14 +1526,14 @@ bool LLModelLoader::doLoadModel()
 	daeDocument* doc = dae.getDoc(mFilename);
 	if (!doc)
 	{
-		llwarns << "can't find internal doc" << llendl;
+		LL_WARNS() << "can't find internal doc" << LL_ENDL;
 		return false;
 	}
 	
 	daeElement* root = doc->getDomRoot();
 	if (!root)
 	{
-		llwarns << "document has no root" << llendl;
+		LL_WARNS() << "document has no root" << LL_ENDL;
 		return false;
 	}
 	
@@ -1698,7 +1698,7 @@ bool LLModelLoader::doLoadModel()
 							daeElement* pScene = root->getDescendant("visual_scene");
 							if ( !pScene )
 							{
-								llwarns<<"No visual scene - unable to parse bone offsets "<<llendl;
+								LL_WARNS()<<"No visual scene - unable to parse bone offsets "<<LL_ENDL;
 								missingSkeletonOrScene = true;
 							}
 							else
@@ -1736,7 +1736,7 @@ bool LLModelLoader::doLoadModel()
 									//Build a joint for the resolver to work with
 									char str[64]={0};
 									sprintf(str,"./%s",(*jointIt).first.c_str() );
-									//llwarns<<"Joint "<< str <<llendl;
+									//LL_WARNS()<<"Joint "<< str <<LL_ENDL;
 									
 									//Setup the resolver
                                     daeSIDResolver resolver( pSkeletonRootNode, str );
@@ -1769,7 +1769,7 @@ bool LLModelLoader::doLoadModel()
 											daeElement* pTranslateElement = getChildFromElement( pJoint, "translate" );
 											if ( pTranslateElement && pTranslateElement->typeID() != domTranslate::ID() )
 											{
-												llwarns<< "The found element is not a translate node" <<llendl;
+												LL_WARNS()<< "The found element is not a translate node" <<LL_ENDL;
 												missingSkeletonOrScene = true;
 											}
 											else
@@ -1793,7 +1793,7 @@ bool LLModelLoader::doLoadModel()
 								//mention it
 								if ( missingSkeletonOrScene  )
 								{
-									llwarns<< "Partial jointmap found in asset - did you mean to just have a partial map?" << llendl;
+									LL_WARNS()<< "Partial jointmap found in asset - did you mean to just have a partial map?" << LL_ENDL;
 								}
 							}//got skeleton?
 						}
@@ -1906,7 +1906,7 @@ bool LLModelLoader::doLoadModel()
 									
 									if ( mJointList.find( lookingForJoint ) != mJointList.end() )
 									{
-										//llinfos<<"joint "<<lookingForJoint.c_str()<<llendl;
+										//LL_INFOS()<<"joint "<<lookingForJoint.c_str()<<LL_ENDL;
 										LLMatrix4 jointTransform = mJointList[lookingForJoint];
 										LLJoint* pJoint = mPreview->getPreviewAvatar()->getJoint( lookingForJoint );
 										if ( pJoint )
@@ -1916,7 +1916,7 @@ bool LLModelLoader::doLoadModel()
 										else
 										{
 											//Most likely an error in the asset.
-											llwarns<<"Tried to apply joint position from .dae, but it did not exist in the avatar rig." << llendl;
+											LL_WARNS()<<"Tried to apply joint position from .dae, but it did not exist in the avatar rig." << LL_ENDL;
 										}
 									}
 								}
@@ -1944,7 +1944,7 @@ bool LLModelLoader::doLoadModel()
 							}
 							else
 							{
-								llwarns<<"Possibly misnamed/missing joint [" <<lookingForJoint.c_str()<<" ] "<<llendl;
+								LL_WARNS()<<"Possibly misnamed/missing joint [" <<lookingForJoint.c_str()<<" ] "<<LL_ENDL;
 							}
 						}
 						
@@ -1970,7 +1970,7 @@ bool LLModelLoader::doLoadModel()
 											{
 												if (pos.getCount() <= j+2)
 												{
-													llerrs << "Invalid position array size." << llendl;
+													LL_ERRS() << "Invalid position array size." << LL_ENDL;
 												}
 												
 												LLVector3 v(pos[j], pos[j+1], pos[j+2]);
@@ -2096,7 +2096,7 @@ bool LLModelLoader::doLoadModel()
 	
 	if (!scene)
 	{
-		llwarns << "document has no visual_scene" << llendl;
+		LL_WARNS() << "document has no visual_scene" << LL_ENDL;
 		setLoadState( ERROR_PARSING );
 		return true;
 	}
@@ -2311,7 +2311,7 @@ void LLModelLoader::processJointToNodeMapping( domNode* pNode )
 		}
 		else 
 		{
-			llinfos<<"Node is NULL"<<llendl;
+			LL_INFOS()<<"Node is NULL"<<LL_ENDL;
 		}
 
 	}
@@ -2382,7 +2382,7 @@ void LLModelPreview::critiqueJointToNodeMappingFromScene( void  )
 			}
 			else
 			{
-				llinfos<<"critiqueJointToNodeMappingFromScene is missing a: "<<name<<llendl;
+				LL_INFOS()<<"critiqueJointToNodeMappingFromScene is missing a: "<<name<<LL_ENDL;
 				result = false;				
 			}
 		}
@@ -2434,7 +2434,7 @@ bool LLModelPreview::isRigLegacy( const std::vector<std::string> &jointListFromA
 		}		
 		if ( !result )
 		{
-			llinfos<<" Asset did not contain the joint (if you're u/l a fully rigged asset w/joint positions - it is required)." << *masterJointIt<< llendl;
+			LL_INFOS()<<" Asset did not contain the joint (if you're u/l a fully rigged asset w/joint positions - it is required)." << *masterJointIt<< LL_ENDL;
 			break;
 		}
 	}	
@@ -2468,7 +2468,7 @@ bool LLModelPreview::isRigSuitableForJointPositionUpload( const std::vector<std:
 		}		
 		if ( !result )
 		{
-			llinfos<<" Asset did not contain the joint (if you're u/l a fully rigged asset w/joint positions - it is required)." << *masterJointIt<< llendl;
+			LL_INFOS()<<" Asset did not contain the joint (if you're u/l a fully rigged asset w/joint positions - it is required)." << *masterJointIt<< LL_ENDL;
 			break;
 		}
 	}	
@@ -2516,17 +2516,17 @@ bool LLModelLoader::isNodeAJoint( domNode* pNode )
 {
 	if ( !pNode )
 	{
-		llinfos<<"Created node is NULL"<<llendl;
+		LL_INFOS()<<"Created node is NULL"<<LL_ENDL;
 		return false;
 	}
 	
 	if ( pNode->getName() == NULL )
 	{
-		llinfos<<"Parsed node has no name "<<llendl;
+		LL_INFOS()<<"Parsed node has no name "<<LL_ENDL;
 		//Attempt to write the node id, if possible (aids in debugging the visual scene)
 		if ( pNode->getId() )
 		{
-			llinfos<<"Parsed node ID: "<<pNode->getId()<<llendl;
+			LL_INFOS()<<"Parsed node ID: "<<pNode->getId()<<LL_ENDL;
 		}
 		return false;
 	}
@@ -2545,7 +2545,7 @@ bool LLModelPreview::verifyCount( int expected, int result )
 {
 	if ( expected != result )
 	{
-		llinfos<< "Error: (expected/got)"<<expected<<"/"<<result<<"verts"<<llendl;
+		LL_INFOS()<< "Error: (expected/got)"<<expected<<"/"<<result<<"verts"<<LL_ENDL;
 		return false;
 	}
 	return true;
@@ -2567,7 +2567,7 @@ bool LLModelPreview::verifyController( domController* pController )
 
 		if ( !pElement )
 		{
-			llinfos<<"Can't resolve skin source"<<llendl;
+			LL_INFOS()<<"Can't resolve skin source"<<LL_ENDL;
 			return false;
 		}
 
@@ -2586,7 +2586,7 @@ bool LLModelPreview::verifyController( domController* pController )
 				domVertices* pVertices = pMesh->getVertices();
 				if ( !pVertices )
 				{ 
-					llinfos<<"No vertices!"<<llendl;
+					LL_INFOS()<<"No vertices!"<<LL_ENDL;
 					return false;
 				}
 
@@ -2672,7 +2672,7 @@ void LLModelLoader::extractTranslationViaSID( daeElement* pElement, LLMatrix4& t
 	}
 	else
 	{
-		llwarns<<"Element is nonexistent - empty/unsupported node."<<llendl;
+		LL_WARNS()<<"Element is nonexistent - empty/unsupported node."<<LL_ENDL;
 	}
 }
 //-----------------------------------------------------------------------------
@@ -2682,11 +2682,11 @@ void LLModelLoader::processJointNode( domNode* pNode, JointTransformMap& jointTr
 {
 	if (pNode->getName() == NULL)
 	{
-		llwarns << "nameless node, can't process" << llendl;
+		LL_WARNS() << "nameless node, can't process" << LL_ENDL;
 		return;
 	}
 
-	//llwarns<<"ProcessJointNode# Node:" <<pNode->getName()<<llendl;
+	//LL_WARNS()<<"ProcessJointNode# Node:" <<pNode->getName()<<LL_ENDL;
 
 	//1. handle the incoming node - extract out translation via SID or element
 
@@ -2714,12 +2714,12 @@ void LLModelLoader::processJointNode( domNode* pNode, JointTransformMap& jointTr
 		daeElement* pTranslateElement = getChildFromElement( pNode, "translate" );
 		if ( !pTranslateElement || pTranslateElement->typeID() != domTranslate::ID() )
 		{
-			//llwarns<< "The found element is not a translate node" <<llendl;
+			//LL_WARNS()<< "The found element is not a translate node" <<LL_ENDL;
 			daeSIDResolver jointResolver( pNode, "./matrix" );
 			domMatrix* pMatrix = daeSafeCast<domMatrix>( jointResolver.getElement() );
 			if ( pMatrix )
 			{
-				//llinfos<<"A matrix SID was however found!"<<llendl;
+				//LL_INFOS()<<"A matrix SID was however found!"<<LL_ENDL;
 				domFloat4x4 domArray = pMatrix->getValue();									
 				for ( int i = 0; i < 4; i++ )
 				{
@@ -2731,7 +2731,7 @@ void LLModelLoader::processJointNode( domNode* pNode, JointTransformMap& jointTr
 			}
 			else
 			{
-				llwarns<< "The found element is not translate or matrix node - most likely a corrupt export!" <<llendl;
+				LL_WARNS()<< "The found element is not translate or matrix node - most likely a corrupt export!" <<LL_ENDL;
 			}
 		}
 		else
@@ -2768,7 +2768,7 @@ daeElement* LLModelLoader::getChildFromElement( daeElement* pElement, std::strin
 	{
 		return pChildOfElement;
 	}
-	llwarns<< "Could not find a child [" << name << "] for the element: \"" << pElement->getAttribute("id") << "\"" << llendl;
+	LL_WARNS()<< "Could not find a child [" << name << "] for the element: \"" << pElement->getAttribute("id") << "\"" << LL_ENDL;
     return NULL;
 }
 
@@ -2850,7 +2850,7 @@ void LLModelLoader::processElement( daeElement* element, bool& badElement )
 
 					if (mTransform.determinant() < 0)
 					{ //negative scales are not supported
-						llinfos << "Negative scale detected, unsupported transform.  domInstance_geometry: " << LLModel::getElementLabel(instance_geo) << llendl;
+						LL_INFOS() << "Negative scale detected, unsupported transform.  domInstance_geometry: " << LLModel::getElementLabel(instance_geo) << LL_ENDL;
 						badElement = true;
 					}
 					
@@ -2880,7 +2880,7 @@ void LLModelLoader::processElement( daeElement* element, bool& badElement )
 		}
 		else 
 		{
-			llinfos<<"Unable to resolve geometry URL."<<llendl;
+			LL_INFOS()<<"Unable to resolve geometry URL."<<LL_ENDL;
 			badElement = true;			
 		}
 
@@ -3515,7 +3515,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
 
 	if (lod < LLModel::LOD_IMPOSTOR || lod > LLModel::NUM_LODS - 1)
 	{
-		llwarns << "Invalid level of detail: " << lod << llendl;
+		LL_WARNS() << "Invalid level of detail: " << lod << LL_ENDL;
 		assert(lod >= LLModel::LOD_IMPOSTOR && lod < LLModel::NUM_LODS);
 		return;
 	}
@@ -3538,7 +3538,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
 
 	if (mModelLoader)
 	{
-		llwarns << "Incompleted model load operation pending." << llendl;
+		LL_WARNS() << "Incompleted model load operation pending." << LL_ENDL;
 		return;
 	}
 	
@@ -3848,7 +3848,7 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim
 	// Allow LoD from -1 to LLModel::LOD_PHYSICS
 	if (which_lod < -1 || which_lod > LLModel::NUM_LODS - 1)
 	{
-		llwarns << "Invalid level of detail: " << which_lod << llendl;
+		LL_WARNS() << "Invalid level of detail: " << which_lod << LL_ENDL;
 		assert(which_lod >= -1 && which_lod < LLModel::NUM_LODS);
 		return;
 	}
@@ -4136,7 +4136,7 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim
 
 				if (!validate_face(target_model->getVolumeFace(names[i])))
 				{
-					llerrs << "Invalid face generated during LOD generation." << llendl;
+					LL_ERRS() << "Invalid face generated during LOD generation." << LL_ENDL;
 				}
 			}
 
@@ -4151,7 +4151,7 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim
 
 			if (!validate_model(target_model))
 			{
-				llerrs << "Invalid model generated when creating LODs" << llendl;
+				LL_ERRS() << "Invalid model generated when creating LODs" << LL_ENDL;
 			}
 
 			delete [] sizes;
@@ -4596,7 +4596,7 @@ void LLModelPreview::updateLodControls(S32 lod)
 {
 	if (lod < LLModel::LOD_IMPOSTOR || lod > LLModel::LOD_HIGH)
 	{
-		llwarns << "Invalid level of detail: " << lod << llendl;
+		LL_WARNS() << "Invalid level of detail: " << lod << LL_ENDL;
 		assert(lod >= LLModel::LOD_IMPOSTOR && lod <= LLModel::LOD_HIGH);
 		return;
 	}
@@ -4909,7 +4909,7 @@ void LLModelPreview::createPreviewAvatar( void )
 	}
 	else
 	{
-		llinfos<<"Failed to create preview avatar for upload model window"<<llendl;
+		LL_INFOS()<<"Failed to create preview avatar for upload model window"<<LL_ENDL;
 	}
 }
 
@@ -5839,7 +5839,7 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived()
 
 void LLFloaterModelPreview::setModelPhysicsFeeErrorStatus(U32 status, const std::string& reason)
 {
-	llwarns << "LLFloaterModelPreview::setModelPhysicsFeeErrorStatus(" << status << " : " << reason << ")" << llendl;
+	LL_WARNS() << "LLFloaterModelPreview::setModelPhysicsFeeErrorStatus(" << status << " : " << reason << ")" << LL_ENDL;
 	doOnIdleOneTime(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, true));
 }
 
@@ -5915,7 +5915,7 @@ void LLFloaterModelPreview::onPermissionsReceived(const LLSD& result)
 
 void LLFloaterModelPreview::setPermissonsErrorStatus(U32 status, const std::string& reason)
 {
-	llwarns << "LLFloaterModelPreview::setPermissonsErrorStatus(" << status << " : " << reason << ")" << llendl;
+	LL_WARNS() << "LLFloaterModelPreview::setPermissonsErrorStatus(" << status << " : " << reason << ")" << LL_ENDL;
 
 	LLNotificationsUtil::add("MeshUploadPermError");
 }
diff --git a/indra/newview/llfloatermodeluploadbase.cpp b/indra/newview/llfloatermodeluploadbase.cpp
index 6d3800bfa4..2ad2d32652 100755
--- a/indra/newview/llfloatermodeluploadbase.cpp
+++ b/indra/newview/llfloatermodeluploadbase.cpp
@@ -44,7 +44,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions()
 
 	if (!url.empty())
 	{
-		llinfos<< typeid(*this).name() <<"::requestAgentUploadPermissions() requesting for upload model permissions from: "<< url <<llendl;
+		LL_INFOS()<< typeid(*this).name() <<"::requestAgentUploadPermissions() requesting for upload model permissions from: "<< url <<LL_ENDL;
 		LLHTTPClient::get(url, new LLUploadModelPremissionsResponder(getPermObserverHandle()));
 	}
 	else
diff --git a/indra/newview/llfloaternotificationsconsole.cpp b/indra/newview/llfloaternotificationsconsole.cpp
index 4f35c325a8..c21e4ff7e8 100755
--- a/indra/newview/llfloaternotificationsconsole.cpp
+++ b/indra/newview/llfloaternotificationsconsole.cpp
@@ -257,7 +257,7 @@ void LLFloaterNotification::respond()
 	LLComboBox* responses_combo = getChild<LLComboBox>("response");
 	LLCtrlListInterface* response_list = responses_combo->getListInterface();
 	const std::string& trigger = response_list->getSelectedValue().asString();
-	//llinfos << trigger << llendl;
+	//LL_INFOS() << trigger << LL_ENDL;
 
 	LLSD response = mNote->getResponseTemplate();
 	response[trigger] = true;
diff --git a/indra/newview/llfloaterobjectweights.cpp b/indra/newview/llfloaterobjectweights.cpp
index 0862cd2897..94bf8974bb 100755
--- a/indra/newview/llfloaterobjectweights.cpp
+++ b/indra/newview/llfloaterobjectweights.cpp
@@ -207,7 +207,7 @@ void LLFloaterObjectWeights::refresh()
 		}
 		else
 		{
-			llwarns << "Failed to get region capabilities" << llendl;
+			LL_WARNS() << "Failed to get region capabilities" << LL_ENDL;
 		}
 	}
 }
diff --git a/indra/newview/llfloaterpathfindingconsole.cpp b/indra/newview/llfloaterpathfindingconsole.cpp
index 298454724b..012979508c 100755
--- a/indra/newview/llfloaterpathfindingconsole.cpp
+++ b/indra/newview/llfloaterpathfindingconsole.cpp
@@ -207,7 +207,7 @@ void LLFloaterPathfindingConsole::onOpen(const LLSD& pKey)
 	if ( LLPathingLib::getInstance() == NULL )
 	{ 
 		setConsoleState(kConsoleStateLibraryNotImplemented);
-		llwarns <<"Errror: cannot find pathing library implementation."<<llendl;
+		LL_WARNS() <<"Errror: cannot find pathing library implementation."<<LL_ENDL;
 	}
 	else
 	{	
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 9cb7d95e61..eaee2f0dc1 100755
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -829,7 +829,7 @@ void LLFloaterPreference::onBtnOK()
 	else
 	{
 		// Show beep, pop up dialog, etc.
-		llinfos << "Can't close preferences!" << llendl;
+		LL_INFOS() << "Can't close preferences!" << LL_ENDL;
 	}
 
 	LLPanelLogin::updateLocationSelectorsVisibility();	
diff --git a/indra/newview/llfloaterproperties.cpp b/indra/newview/llfloaterproperties.cpp
index 3f00ba39c7..a3bf99f054 100755
--- a/indra/newview/llfloaterproperties.cpp
+++ b/indra/newview/llfloaterproperties.cpp
@@ -561,7 +561,7 @@ void LLFloaterProperties::onClickOwner()
 // static
 void LLFloaterProperties::onCommitName()
 {
-	//llinfos << "LLFloaterProperties::onCommitName()" << llendl;
+	//LL_INFOS() << "LLFloaterProperties::onCommitName()" << LL_ENDL;
 	LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
 	if(!item)
 	{
@@ -597,7 +597,7 @@ void LLFloaterProperties::onCommitName()
 
 void LLFloaterProperties::onCommitDescription()
 {
-	//llinfos << "LLFloaterProperties::onCommitDescription()" << llendl;
+	//LL_INFOS() << "LLFloaterProperties::onCommitDescription()" << LL_ENDL;
 	LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
 	if(!item) return;
 
@@ -635,7 +635,7 @@ void LLFloaterProperties::onCommitDescription()
 // static
 void LLFloaterProperties::onCommitPermissions()
 {
-	//llinfos << "LLFloaterProperties::onCommitPermissions()" << llendl;
+	//LL_INFOS() << "LLFloaterProperties::onCommitPermissions()" << LL_ENDL;
 	LLViewerInventoryItem* item = (LLViewerInventoryItem*)findItem();
 	if(!item) return;
 	LLPermissions perm(item->getPermissions());
@@ -732,14 +732,14 @@ void LLFloaterProperties::onCommitPermissions()
 // static
 void LLFloaterProperties::onCommitSaleInfo()
 {
-	//llinfos << "LLFloaterProperties::onCommitSaleInfo()" << llendl;
+	//LL_INFOS() << "LLFloaterProperties::onCommitSaleInfo()" << LL_ENDL;
 	updateSaleInfo();
 }
 
 // static
 void LLFloaterProperties::onCommitSaleType()
 {
-	//llinfos << "LLFloaterProperties::onCommitSaleType()" << llendl;
+	//LL_INFOS() << "LLFloaterProperties::onCommitSaleType()" << LL_ENDL;
 	updateSaleInfo();
 }
 
diff --git a/indra/newview/llfloaterregiondebugconsole.cpp b/indra/newview/llfloaterregiondebugconsole.cpp
index 3a7ca17b73..bed34abee8 100755
--- a/indra/newview/llfloaterregiondebugconsole.cpp
+++ b/indra/newview/llfloaterregiondebugconsole.cpp
@@ -123,8 +123,8 @@ namespace
 			const LLSD& context,
 			const LLSD& input) const
 		{
-			llinfos << "Received response from the debug console: "
-				<< input << llendl;
+			LL_INFOS() << "Received response from the debug console: "
+				<< input << LL_ENDL;
 			sConsoleReplySignal(input["body"].asString());
 		}
 	};
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index bc8a208030..bdd97a51c8 100755
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -280,7 +280,7 @@ void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**)
 	LLDispatcher::unpackMessage(msg, request, invoice, strings);
 	if(invoice != getLastInvoice())
 	{
-		llwarns << "Mismatched Estate message: " << request << llendl;
+		LL_WARNS() << "Mismatched Estate message: " << request << LL_ENDL;
 		return;
 	}
 
@@ -558,7 +558,7 @@ void LLPanelRegionInfo::sendEstateOwnerMessage(
 	const LLUUID& invoice,
 	const strings_t& strings)
 {
-	llinfos << "Sending estate request '" << request << "'" << llendl;
+	LL_INFOS() << "Sending estate request '" << request << "'" << LL_ENDL;
 	msg->newMessage("EstateOwnerMessage");
 	msg->nextBlockFast(_PREHASH_AgentData);
 	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
@@ -653,7 +653,7 @@ BOOL LLPanelRegionGeneralInfo::postBuild()
 
 void LLPanelRegionGeneralInfo::onClickKick()
 {
-	llinfos << "LLPanelRegionGeneralInfo::onClickKick" << llendl;
+	LL_INFOS() << "LLPanelRegionGeneralInfo::onClickKick" << LL_ENDL;
 
 	// this depends on the grandparent view being a floater
 	// in order to set up floater dependency
@@ -690,7 +690,7 @@ void LLPanelRegionGeneralInfo::onKickCommit(const uuid_vec_t& ids)
 // static
 void LLPanelRegionGeneralInfo::onClickKickAll(void* userdata)
 {
-	llinfos << "LLPanelRegionGeneralInfo::onClickKickAll" << llendl;
+	LL_INFOS() << "LLPanelRegionGeneralInfo::onClickKickAll" << LL_ENDL;
 	LLNotificationsUtil::add("KickUsersFromRegion", 
 									LLSD(), 
 									LLSD(), 
@@ -718,7 +718,7 @@ bool LLPanelRegionGeneralInfo::onKickAllCommit(const LLSD& notification, const L
 // static
 void LLPanelRegionGeneralInfo::onClickMessage(void* userdata)
 {
-	llinfos << "LLPanelRegionGeneralInfo::onClickMessage" << llendl;
+	LL_INFOS() << "LLPanelRegionGeneralInfo::onClickMessage" << LL_ENDL;
 	LLNotificationsUtil::add("MessageRegion", 
 		LLSD(), 
 		LLSD(), 
@@ -733,7 +733,7 @@ bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const L
 	std::string text = response["message"].asString();
 	if (text.empty()) return false;
 
-	llinfos << "Message to everyone: " << text << llendl;
+	LL_INFOS() << "Message to everyone: " << text << LL_ENDL;
 	strings_t strings;
 	// [0] grid_x, unused here
 	// [1] grid_y, unused here
@@ -760,8 +760,8 @@ public:
 	/*virtual*/
 	void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "ConsoleRequestResponder error requesting mesh_rez_enabled [status:"
-				<< status << "]: " << content << llendl;
+		LL_WARNS() << "ConsoleRequestResponder error requesting mesh_rez_enabled [status:"
+				<< status << "]: " << content << LL_ENDL;
 	}
 };
 
@@ -773,8 +773,8 @@ public:
 	/* virtual */
 	void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "ConsoleRequestResponder error updating mesh enabled region setting [status:"
-				<< status << "]: " << content << llendl;
+		LL_WARNS() << "ConsoleRequestResponder error updating mesh enabled region setting [status:"
+				<< status << "]: " << content << LL_ENDL;
 	}
 };
 
@@ -806,7 +806,7 @@ void LLFloaterRegionInfo::requestMeshRezInfo()
 // strings[9] = 'Y' - block parcel search, 'N' - allow
 BOOL LLPanelRegionGeneralInfo::sendUpdate()
 {
-	llinfos << "LLPanelRegionGeneralInfo::sendUpdate()" << llendl;
+	LL_INFOS() << "LLPanelRegionGeneralInfo::sendUpdate()" << LL_ENDL;
 
 	// First try using a Cap.  If that fails use the old method.
 	LLSD body;
@@ -918,7 +918,7 @@ bool LLPanelRegionDebugInfo::refreshFromRegion(LLViewerRegion* region)
 // virtual
 BOOL LLPanelRegionDebugInfo::sendUpdate()
 {
-	llinfos << "LLPanelRegionDebugInfo::sendUpdate" << llendl;
+	LL_INFOS() << "LLPanelRegionDebugInfo::sendUpdate" << LL_ENDL;
 	strings_t strings;
 	std::string buffer;
 
@@ -1090,7 +1090,7 @@ BOOL LLPanelRegionTerrainInfo::validateTextureSizes()
 		S32 width = img->getFullWidth();
 		S32 height = img->getFullHeight();
 
-		//llinfos << "texture detail " << i << " is " << width << "x" << height << "x" << components << llendl;
+		//LL_INFOS() << "texture detail " << i << " is " << width << "x" << height << "x" << components << LL_ENDL;
 
 		if (components != 3)
 		{
@@ -1176,8 +1176,8 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region)
 			texture_ctrl = getChild<LLTextureCtrl>(buffer);
 			if(texture_ctrl)
 			{
-				lldebugs << "Detail Texture " << i << ": "
-						 << compp->getDetailTextureID(i) << llendl;
+				LL_DEBUGS() << "Detail Texture " << i << ": "
+						 << compp->getDetailTextureID(i) << LL_ENDL;
 				LLUUID tmp_id(compp->getDetailTextureID(i));
 				texture_ctrl->setImageAssetID(tmp_id);
 			}
@@ -1193,7 +1193,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region)
 	}
 	else
 	{
-		lldebugs << "no region set" << llendl;
+		LL_DEBUGS() << "no region set" << LL_ENDL;
 		getChild<LLUICtrl>("region_text")->setValue(LLSD(""));
 	}
 
@@ -1208,7 +1208,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region)
 // virtual
 BOOL LLPanelRegionTerrainInfo::sendUpdate()
 {
-	llinfos << "LLPanelRegionTerrainInfo::sendUpdate" << llendl;
+	LL_INFOS() << "LLPanelRegionTerrainInfo::sendUpdate" << LL_ENDL;
 	std::string buffer;
 	strings_t strings;
 	LLUUID invoice(LLFloaterRegionInfo::getLastInvoice());
@@ -1277,7 +1277,7 @@ void LLPanelRegionTerrainInfo::onClickDownloadRaw(void* data)
 	LLFilePicker& picker = LLFilePicker::instance();
 	if (!picker.getSaveFile(LLFilePicker::FFSAVE_RAW, "terrain.raw"))
 	{
-		llwarns << "No file" << llendl;
+		LL_WARNS() << "No file" << LL_ENDL;
 		return;
 	}
 	std::string filepath = picker.getFirstFile();
@@ -1297,7 +1297,7 @@ void LLPanelRegionTerrainInfo::onClickUploadRaw(void* data)
 	LLFilePicker& picker = LLFilePicker::instance();
 	if (!picker.getOpenFile(LLFilePicker::FFLOAD_RAW))
 	{
-		llwarns << "No file" << llendl;
+		LL_WARNS() << "No file" << LL_ENDL;
 		return;
 	}
 	std::string filepath = picker.getFirstFile();
@@ -2047,7 +2047,7 @@ void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl)
 
 bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg)
 {
-	llinfos << "LLPanelEstateInfo::estateUpdate()" << llendl;
+	LL_INFOS() << "LLPanelEstateInfo::estateUpdate()" << LL_ENDL;
 	return false;
 }
 
@@ -2147,7 +2147,7 @@ void LLPanelEstateInfo::refreshFromEstate()
 
 BOOL LLPanelEstateInfo::sendUpdate()
 {
-	llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl;
+	LL_INFOS() << "LLPanelEsateInfo::sendUpdate()" << LL_ENDL;
 
 	LLNotification::Params params("ChangeLindenEstate");
 	params.functor.function(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2));
@@ -2242,7 +2242,7 @@ public:
 	// if we get a normal response, handle it here
 	virtual void result(const LLSD& content)
 	{
-		LL_INFOS("Windlight") << "Successfully committed estate info" << llendl;
+		LL_INFOS("Windlight") << "Successfully committed estate info" << LL_ENDL;
 
 	    // refresh the panel from the database
 		LLPanelEstateInfo* panel = dynamic_cast<LLPanelEstateInfo*>(mpPanel.get());
@@ -2253,8 +2253,8 @@ public:
 	// if we get an error response
 	virtual void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llinfos << "LLEstateChangeInfoResponder::error [status:"
-			<< status << "]: " << content << llendl;
+		LL_INFOS() << "LLEstateChangeInfoResponder::error [status:"
+			<< status << "]: " << content << LL_ENDL;
 	}
 private:
 	LLHandle<LLPanel> mpPanel;
@@ -2289,7 +2289,7 @@ void LLPanelEstateInfo::clearAccessLists()
 // static
 void LLPanelEstateInfo::onClickMessageEstate(void* userdata)
 {
-	llinfos << "LLPanelEstateInfo::onClickMessageEstate" << llendl;
+	LL_INFOS() << "LLPanelEstateInfo::onClickMessageEstate" << LL_ENDL;
 	LLNotificationsUtil::add("MessageEstate", LLSD(), LLSD(), boost::bind(&LLPanelEstateInfo::onMessageCommit, (LLPanelEstateInfo*)userdata, _1, _2));
 }
 
@@ -2299,7 +2299,7 @@ bool LLPanelEstateInfo::onMessageCommit(const LLSD& notification, const LLSD& re
 	std::string text = response["message"].asString();
 	if(option != 0) return false;
 	if(text.empty()) return false;
-	llinfos << "Message to everyone: " << text << llendl;
+	LL_INFOS() << "Message to everyone: " << text << LL_ENDL;
 	strings_t strings;
 	//integers_t integers;
 	std::string name;
@@ -2376,7 +2376,7 @@ bool LLPanelEstateCovenant::refreshFromRegion(LLViewerRegion* region)
 // virtual 
 bool LLPanelEstateCovenant::estateUpdate(LLMessageSystem* msg)
 {
-	llinfos << "LLPanelEstateCovenant::estateUpdate()" << llendl;
+	LL_INFOS() << "LLPanelEstateCovenant::estateUpdate()" << LL_ENDL;
 	return true;
 }
 	
@@ -2510,7 +2510,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 									   LLAssetType::EType type,
 									   void* user_data, S32 status, LLExtStat ext_status)
 {
-	llinfos << "LLPanelEstateCovenant::onLoadComplete()" << llendl;
+	LL_INFOS() << "LLPanelEstateCovenant::onLoadComplete()" << LL_ENDL;
 	LLPanelEstateCovenant* panelp = (LLPanelEstateCovenant*)user_data;
 	if( panelp )
 	{
@@ -2529,7 +2529,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 			{
 				if( !panelp->mEditor->importBuffer( &buffer[0], file_length+1 ) )
 				{
-					llwarns << "Problem importing estate covenant." << llendl;
+					LL_WARNS() << "Problem importing estate covenant." << LL_ENDL;
 					LLNotificationsUtil::add("ProblemImportingEstateCovenant");
 				}
 				else
@@ -2559,7 +2559,7 @@ void LLPanelEstateCovenant::onLoadComplete(LLVFS *vfs,
 				LLNotificationsUtil::add("UnableToLoadNotecardAsset");
 			}
 
-			llwarns << "Problem loading notecard: " << status << llendl;
+			LL_WARNS() << "Problem loading notecard: " << status << LL_ENDL;
 		}
 		panelp->mAssetStatus = ASSET_LOADED;
 		panelp->setCovenantID(asset_uuid);
@@ -2681,7 +2681,7 @@ bool LLDispatchEstateUpdateInfo::operator()(
 		const LLUUID& invoice,
 		const sparam_t& strings)
 {
-	lldebugs << "Received estate update" << llendl;
+	LL_DEBUGS() << "Received estate update" << LL_ENDL;
 
 	// Update estate info model.
 	// This will call LLPanelEstateInfo::refreshFromEstate().
@@ -2723,22 +2723,22 @@ bool LLDispatchSetEstateAccess::operator()(
 	if (num_allowed_agents > 0
 		&& !(access_flags & ESTATE_ACCESS_ALLOWED_AGENTS))
 	{
-		llwarns << "non-zero count for allowed agents, but no corresponding flag" << llendl;
+		LL_WARNS() << "non-zero count for allowed agents, but no corresponding flag" << LL_ENDL;
 	}
 	if (num_allowed_groups > 0
 		&& !(access_flags & ESTATE_ACCESS_ALLOWED_GROUPS))
 	{
-		llwarns << "non-zero count for allowed groups, but no corresponding flag" << llendl;
+		LL_WARNS() << "non-zero count for allowed groups, but no corresponding flag" << LL_ENDL;
 	}
 	if (num_banned_agents > 0
 		&& !(access_flags & ESTATE_ACCESS_BANNED_AGENTS))
 	{
-		llwarns << "non-zero count for banned agents, but no corresponding flag" << llendl;
+		LL_WARNS() << "non-zero count for banned agents, but no corresponding flag" << LL_ENDL;
 	}
 	if (num_estate_managers > 0
 		&& !(access_flags & ESTATE_ACCESS_MANAGERS))
 	{
-		llwarns << "non-zero count for managers, but no corresponding flag" << llendl;
+		LL_WARNS() << "non-zero count for managers, but no corresponding flag" << LL_ENDL;
 	}
 
 	// grab the UUID's out of the string fields
@@ -3044,7 +3044,7 @@ void LLPanelEnvironmentInfo::fixEstateSun()
 	LLEstateInfoModel& estate_info = LLEstateInfoModel::instance();
 	if (estate_info.getUseFixedSun())
 	{
-		llinfos << "Switching estate to global sun" << llendl;
+		LL_INFOS() << "Switching estate to global sun" << LL_ENDL;
 		estate_info.setUseFixedSun(false);
 		estate_info.sendEstateInfo();
 	}
@@ -3185,7 +3185,7 @@ bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params)
 		LLWaterParamSet param_set;
 		if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set))
 		{
-			llwarns << "Error getting water preset: " << water_key.name << llendl;
+			LL_WARNS() << "Error getting water preset: " << water_key.name << LL_ENDL;
 			return false;
 		}
 
@@ -3204,7 +3204,7 @@ bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string&
 	LLWLParamSet param_set;
 	if (!LLWLParamManager::instance().getParamSet(preset, param_set))
 	{
-		llwarns << "Error getting sky params: " << preset.toLLSD() << llendl;
+		LL_WARNS() << "Error getting sky params: " << preset.toLLSD() << LL_ENDL;
 		return false;
 	}
 
@@ -3229,7 +3229,7 @@ bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sk
 	{
 		if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle))
 		{
-			llwarns << "Error getting day cycle " << dc.name << llendl;
+			LL_WARNS() << "Error getting day cycle " << dc.name << LL_ENDL;
 			return false;
 		}
 
@@ -3396,7 +3396,7 @@ void LLPanelEnvironmentInfo::onBtnApply()
 	new_region_settings.saveParams(day_cycle, sky_map, water_params, 0.0f);
 	if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings))
 	{
-		llwarns << "Error applying region environment settings" << llendl;
+		LL_WARNS() << "Error applying region environment settings" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index b42118a0c1..825159703c 100755
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -460,7 +460,7 @@ void LLFloaterReporter::showFromMenu(EReportType report_type)
 {
 	if (COMPLAINT_REPORT != report_type)
 	{
-		llwarns << "Unknown LLViewerReporter type : " << report_type << llendl;
+		LL_WARNS() << "Unknown LLViewerReporter type : " << report_type << LL_ENDL;
 		return;
 	}
 	
@@ -746,7 +746,7 @@ void LLFloaterReporter::takeScreenshot()
 	LLPointer<LLImageRaw> raw = new LLImageRaw;
 	if( !gViewerWindow->rawSnapshot(raw, IMAGE_WIDTH, IMAGE_HEIGHT, TRUE, FALSE, TRUE, FALSE))
 	{
-		llwarns << "Unable to take screenshot" << llendl;
+		LL_WARNS() << "Unable to take screenshot" << LL_ENDL;
 		return;
 	}
 	LLPointer<LLImageJ2C> upload_data = LLViewerTextureList::convertToUploadFile(raw);
@@ -765,7 +765,7 @@ void LLFloaterReporter::takeScreenshot()
 	}
 	else
 	{
-		llwarns << "Unknown LLFloaterReporter type" << llendl;
+		LL_WARNS() << "Unknown LLFloaterReporter type" << LL_ENDL;
 	}
 	mResourceDatap->mAssetInfo.mCreatorID = gAgentID;
 	mResourceDatap->mAssetInfo.setName("screenshot_name");
@@ -796,11 +796,11 @@ void LLFloaterReporter::takeScreenshot()
 
 void LLFloaterReporter::uploadImage()
 {
-	llinfos << "*** Uploading: " << llendl;
-	llinfos << "Type: " << LLAssetType::lookup(mResourceDatap->mAssetInfo.mType) << llendl;
-	llinfos << "UUID: " << mResourceDatap->mAssetInfo.mUuid << llendl;
-	llinfos << "Name: " << mResourceDatap->mAssetInfo.getName() << llendl;
-	llinfos << "Desc: " << mResourceDatap->mAssetInfo.getDescription() << llendl;
+	LL_INFOS() << "*** Uploading: " << LL_ENDL;
+	LL_INFOS() << "Type: " << LLAssetType::lookup(mResourceDatap->mAssetInfo.mType) << LL_ENDL;
+	LL_INFOS() << "UUID: " << mResourceDatap->mAssetInfo.mUuid << LL_ENDL;
+	LL_INFOS() << "Name: " << mResourceDatap->mAssetInfo.getName() << LL_ENDL;
+	LL_INFOS() << "Desc: " << mResourceDatap->mAssetInfo.getDescription() << LL_ENDL;
 
 	gAssetStorage->storeAssetData(mResourceDatap->mAssetInfo.mTransactionID,
 									mResourceDatap->mAssetInfo.mType,
@@ -824,20 +824,20 @@ void LLFloaterReporter::uploadDoneCallback(const LLUUID &uuid, void *user_data,
 
 		std::string err_msg("There was a problem uploading a report screenshot");
 		err_msg += " due to the following reason: " + args["REASON"].asString();
-		llwarns << err_msg << llendl;
+		LL_WARNS() << err_msg << LL_ENDL;
 		return;
 	}
 
 	if (data->mPreferredLocation != LLResourceData::INVALID_LOCATION)
 	{
-		llwarns << "Unknown report type : " << data->mPreferredLocation << llendl;
+		LL_WARNS() << "Unknown report type : " << data->mPreferredLocation << LL_ENDL;
 	}
 
 	LLFloaterReporter *self = LLFloaterReg::findTypedInstance<LLFloaterReporter>("reporter");
 	if (self)
 	{
 		self->mScreenID = uuid;
-		llinfos << "Got screen shot " << uuid << llendl;
+		LL_INFOS() << "Got screen shot " << uuid << LL_ENDL;
 		self->sendReportViaLegacy(self->gatherReport());
 		self->closeFloater();
 	}
diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp
index 13cb3c2eb0..2ed7bb842d 100755
--- a/indra/newview/llfloaterscriptlimits.cpp
+++ b/indra/newview/llfloaterscriptlimits.cpp
@@ -58,7 +58,7 @@
 // debug switches, won't work in release
 #ifndef LL_RELEASE_FOR_DOWNLOAD
 
-// dump responder replies to llinfos for debugging
+// dump responder replies to LL_INFOS() for debugging
 //#define DUMP_REPLIES_TO_LLINFOS
 
 #ifdef DUMP_REPLIES_TO_LLINFOS
@@ -106,7 +106,7 @@ BOOL LLFloaterScriptLimits::postBuild()
 	
 	if(!mTab)
 	{
-		llwarns << "Error! couldn't get scriptlimits_panels, aborting Script Information setup" << llendl;
+		LL_WARNS() << "Error! couldn't get scriptlimits_panels, aborting Script Information setup" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -195,7 +195,7 @@ void fetchScriptLimitsRegionInfoResponder::result(const LLSD& content)
 
 	OSMessageBox(nice_llsd.str(), "main cap response:", 0);
 
-	llinfos << "main cap response:" << content << llendl;
+	LL_INFOS() << "main cap response:" << content << LL_ENDL;
 
 #endif
 
@@ -210,7 +210,7 @@ void fetchScriptLimitsRegionInfoResponder::result(const LLSD& content)
 		LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits");
 		if(!instance)
 		{
-			llwarns << "Failed to get llfloaterscriptlimits instance" << llendl;
+			LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL;
 		}
 	}
 
@@ -223,7 +223,7 @@ void fetchScriptLimitsRegionInfoResponder::result(const LLSD& content)
 
 void fetchScriptLimitsRegionInfoResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llwarns << "fetchScriptLimitsRegionInfoResponder error [status:" << status << "]: " << content << llendl;
+	LL_WARNS() << "fetchScriptLimitsRegionInfoResponder error [status:" << status << "]: " << content << LL_ENDL;
 }
 
 void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref)
@@ -277,14 +277,14 @@ void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref)
 
 	OSMessageBox(nice_llsd.str(), "summary response:", 0);
 
-	llwarns << "summary response:" << *content << llendl;
+	LL_WARNS() << "summary response:" << *content << LL_ENDL;
 
 #endif
 
 	LLFloaterScriptLimits* instance = LLFloaterReg::getTypedInstance<LLFloaterScriptLimits>("script_limits");
 	if(!instance)
 	{
-		llwarns << "Failed to get llfloaterscriptlimits instance" << llendl;
+		LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL;
 	}
 	else
 	{
@@ -310,7 +310,7 @@ void fetchScriptLimitsRegionSummaryResponder::result(const LLSD& content_ref)
 
 void fetchScriptLimitsRegionSummaryResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llwarns << "fetchScriptLimitsRegionSummaryResponder error [status:" << status << "]: " << content << llendl;
+	LL_WARNS() << "fetchScriptLimitsRegionSummaryResponder error [status:" << status << "]: " << content << LL_ENDL;
 }
 
 void fetchScriptLimitsRegionDetailsResponder::result(const LLSD& content_ref)
@@ -385,7 +385,7 @@ result (map)
 
 	OSMessageBox(nice_llsd.str(), "details response:", 0);
 
-	llinfos << "details response:" << content << llendl;
+	LL_INFOS() << "details response:" << content << LL_ENDL;
 
 #endif
 
@@ -393,7 +393,7 @@ result (map)
 
 	if(!instance)
 	{
-		llwarns << "Failed to get llfloaterscriptlimits instance" << llendl;
+		LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL;
 	}
 	else
 	{
@@ -407,19 +407,19 @@ result (map)
 			}
 			else
 			{
-				llwarns << "Failed to get scriptlimits memory panel" << llendl;
+				LL_WARNS() << "Failed to get scriptlimits memory panel" << LL_ENDL;
 			}
 		}
 		else
 		{
-			llwarns << "Failed to get scriptlimits_panels" << llendl;
+			LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL;
 		}
 	}
 }
 
 void fetchScriptLimitsRegionDetailsResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llwarns << "fetchScriptLimitsRegionDetailsResponder error [status:" << status << "]: " << content << llendl;
+	LL_WARNS() << "fetchScriptLimitsRegionDetailsResponder error [status:" << status << "]: " << content << LL_ENDL;
 }
 
 void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref)
@@ -473,7 +473,7 @@ void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref)
 
 	OSMessageBox(nice_llsd.str(), "attachment response:", 0);
 	
-	llinfos << "attachment response:" << content << llendl;
+	LL_INFOS() << "attachment response:" << content << LL_ENDL;
 
 #endif
 
@@ -481,7 +481,7 @@ void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref)
 
 	if(!instance)
 	{
-		llwarns << "Failed to get llfloaterscriptlimits instance" << llendl;
+		LL_WARNS() << "Failed to get llfloaterscriptlimits instance" << LL_ENDL;
 	}
 	else
 	{
@@ -503,19 +503,19 @@ void fetchScriptLimitsAttachmentInfoResponder::result(const LLSD& content_ref)
 			}
 			else
 			{
-				llwarns << "Failed to get script_limits_my_avatar_panel" << llendl;
+				LL_WARNS() << "Failed to get script_limits_my_avatar_panel" << LL_ENDL;
 			}
 		}
 		else
 		{
-			llwarns << "Failed to get scriptlimits_panels" << llendl;
+			LL_WARNS() << "Failed to get scriptlimits_panels" << LL_ENDL;
 		}
 	}
 }
 
 void fetchScriptLimitsAttachmentInfoResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llwarns << "fetchScriptLimitsAttachmentInfoResponder error [status:" << status << "]: " << content << llendl;
+	LL_WARNS() << "fetchScriptLimitsAttachmentInfoResponder error [status:" << status << "]: " << content << LL_ENDL;
 }
 
 ///----------------------------------------------------------------------------
@@ -588,7 +588,7 @@ void LLPanelScriptLimitsRegionMemory::setParcelID(const LLUUID& parcel_id)
 // virtual
 void LLPanelScriptLimitsRegionMemory::setErrorStatus(U32 status, const std::string& reason)
 {
-	llwarns << "Can't handle remote parcel request."<< " Http Status: "<< status << ". Reason : "<< reason<<llendl;
+	LL_WARNS() << "Can't handle remote parcel request."<< " Http Status: "<< status << ". Reason : "<< reason<<LL_ENDL;
 }
 
 // callback from the name cache with an owner name to add to the list
@@ -627,7 +627,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content)
 	
 	if(!list)
 	{
-		llwarns << "Error getting the scripts_list control" << llendl;
+		LL_WARNS() << "Error getting the scripts_list control" << LL_ENDL;
 		return;
 	}
 
@@ -800,7 +800,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionSummary(LLSD content)
 	}
 	else
 	{
-		llwarns << "summary doesn't contain memory info" << llendl;
+		LL_WARNS() << "summary doesn't contain memory info" << LL_ENDL;
 		return;
 	}
 	
@@ -818,7 +818,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionSummary(LLSD content)
 	}
 	else
 	{
-		llwarns << "summary doesn't contain urls info" << llendl;
+		LL_WARNS() << "summary doesn't contain urls info" << LL_ENDL;
 		return;
 	}
 
@@ -922,9 +922,9 @@ BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain()
 		}
 		else
 		{
-			llwarns << "Can't get parcel info for script information request" << region_id
+			LL_WARNS() << "Can't get parcel info for script information request" << region_id
 					<< ". Region: "	<< region->getName()
-					<< " does not support RemoteParcelRequest" << llendl;
+					<< " does not support RemoteParcelRequest" << LL_ENDL;
 					
 			std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError");
 			getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting));
@@ -990,7 +990,7 @@ void LLPanelScriptLimitsRegionMemory::onClickRefresh(void* userdata)
 	}
 	else
 	{
-		llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after refresh button clicked" << llendl;
+		LL_WARNS() << "could not find LLPanelScriptLimitsRegionMemory instance after refresh button clicked" << LL_ENDL;
 		return;
 	}
 }
@@ -1036,7 +1036,7 @@ void LLPanelScriptLimitsRegionMemory::onClickHighlight(void* userdata)
 	}
 	else
 	{
-		llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << llendl;
+		LL_WARNS() << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << LL_ENDL;
 		return;
 	}
 }
@@ -1141,7 +1141,7 @@ void LLPanelScriptLimitsRegionMemory::onClickReturn(void* userdata)
 	}
 	else
 	{
-		llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << llendl;
+		LL_WARNS() << "could not find LLPanelScriptLimitsRegionMemory instance after highlight button clicked" << LL_ENDL;
 		return;
 	}
 }
@@ -1273,7 +1273,7 @@ void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content)
 	}
 	else
 	{
-		llwarns << "attachment details don't contain memory summary info" << llendl;
+		LL_WARNS() << "attachment details don't contain memory summary info" << LL_ENDL;
 		return;
 	}
 	
@@ -1291,7 +1291,7 @@ void LLPanelScriptLimitsAttachment::setAttachmentSummary(LLSD content)
 	}
 	else
 	{
-		llwarns << "attachment details don't contain urls summary info" << llendl;
+		LL_WARNS() << "attachment details don't contain urls summary info" << LL_ENDL;
 		return;
 	}
 
@@ -1343,7 +1343,7 @@ void LLPanelScriptLimitsAttachment::onClickRefresh(void* userdata)
 	}
 	else
 	{
-		llwarns << "could not find LLPanelScriptLimitsRegionMemory instance after refresh button clicked" << llendl;
+		LL_WARNS() << "could not find LLPanelScriptLimitsRegionMemory instance after refresh button clicked" << LL_ENDL;
 		return;
 	}
 }
diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp
index 07f5220ab7..fb202b4c40 100755
--- a/indra/newview/llfloatersettingsdebug.cpp
+++ b/indra/newview/llfloatersettingsdebug.cpp
@@ -194,8 +194,8 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
 
 	if (!spinner1 || !spinner2 || !spinner3 || !spinner4 || !color_swatch)
 	{
-		llwarns << "Could not find all desired controls by name"
-			<< llendl;
+		LL_WARNS() << "Could not find all desired controls by name"
+			<< LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h
index 491723471f..e3c77ab9a6 100755
--- a/indra/newview/llfloatersidepanelcontainer.h
+++ b/indra/newview/llfloatersidepanelcontainer.h
@@ -74,7 +74,7 @@ public:
 		T* panel = dynamic_cast<T*>(getPanel(floater_name, panel_name));
 		if (!panel)
 		{
-			llwarns << "Child named \"" << panel_name << "\" of type " << typeid(T*).name() << " not found" << llendl;
+			LL_WARNS() << "Child named \"" << panel_name << "\" of type " << typeid(T*).name() << " not found" << LL_ENDL;
 		}
 		return panel;
 	}
diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp
index 285f52fcd6..7e6bf4cd7e 100755
--- a/indra/newview/llfloatersnapshot.cpp
+++ b/indra/newview/llfloatersnapshot.cpp
@@ -328,7 +328,7 @@ F32 LLSnapshotLivePreview::getImageAspect()
 void LLSnapshotLivePreview::updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail, F32 delay) 
 {
 	// Invalidate current image.
-	lldebugs << "updateSnapshot: mSnapshotUpToDate = " << getSnapshotUpToDate() << llendl;
+	LL_DEBUGS() << "updateSnapshot: mSnapshotUpToDate = " << getSnapshotUpToDate() << LL_ENDL;
 	if (getSnapshotUpToDate())
 	{
 		S32 old_image_index = mCurImageIndex;
@@ -501,7 +501,7 @@ void LLSnapshotLivePreview::draw()
 		}
 		else if (mShineAnimTimer.getStarted())
 		{
-			lldebugs << "Drawing shining animation" << llendl;
+			LL_DEBUGS() << "Drawing shining animation" << LL_ENDL;
 			F32 shine_interp = llmin(1.f, mShineAnimTimer.getElapsedTimeF32() / SHINE_TIME);
 			
 			// draw "shine" effect
@@ -578,7 +578,7 @@ void LLSnapshotLivePreview::draw()
 		S32 old_image_index = (mCurImageIndex + 1) % 2;
 		if (mViewerImage[old_image_index].notNull() && mFallAnimTimer.getElapsedTimeF32() < FALL_TIME)
 		{
-			lldebugs << "Drawing fall animation" << llendl;
+			LL_DEBUGS() << "Drawing fall animation" << LL_ENDL;
 			F32 fall_interp = mFallAnimTimer.getElapsedTimeF32() / FALL_TIME;
 			F32 alpha = clamp_rescale(fall_interp, 0.f, 1.f, 0.8f, 0.4f);
 			LLColor4 image_color(1.f, 1.f, 1.f, alpha);
@@ -622,7 +622,7 @@ void LLSnapshotLivePreview::reshape(S32 width, S32 height, BOOL called_from_pare
 	LLView::reshape(width, height, called_from_parent);
 	if (old_rect.getWidth() != width || old_rect.getHeight() != height)
 	{
-		lldebugs << "window reshaped, updating thumbnail" << llendl;
+		LL_DEBUGS() << "window reshaped, updating thumbnail" << LL_ENDL;
 		updateSnapshot(FALSE, TRUE);
 	}
 }
@@ -755,7 +755,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 	LLSnapshotLivePreview* previewp = (LLSnapshotLivePreview*)snapshot_preview;
 	if (previewp->getWidth() == 0 || previewp->getHeight() == 0)
 	{
-		llwarns << "Incorrect dimensions: " << previewp->getWidth() << "x" << previewp->getHeight() << llendl;
+		LL_WARNS() << "Incorrect dimensions: " << previewp->getWidth() << "x" << previewp->getHeight() << LL_ENDL;
 		return FALSE;
 	}
 
@@ -769,7 +769,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 		previewp->mCameraRot = new_camera_rot;
 		// request a new snapshot whenever the camera moves, with a time delay
 		BOOL autosnap = gSavedSettings.getBOOL("AutoSnapshot");
-		lldebugs << "camera moved, updating thumbnail" << llendl;
+		LL_DEBUGS() << "camera moved, updating thumbnail" << LL_ENDL;
 		previewp->updateSnapshot(
 			autosnap, // whether a new snapshot is needed or merely invalidate the existing one
 			FALSE, // or if 1st arg is false, whether to produce a new thumbnail image.
@@ -788,7 +788,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 	// time to produce a snapshot
 	previewp->setThumbnailImageSize();
 
-	lldebugs << "producing snapshot" << llendl;
+	LL_DEBUGS() << "producing snapshot" << LL_ENDL;
 	if (!previewp->mPreviewImage)
 	{
 		previewp->mPreviewImage = new LLImageRaw;
@@ -824,7 +824,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 
 		if(previewp->getSnapshotType() == SNAPSHOT_TEXTURE)
 		{
-			lldebugs << "Encoding new image of format J2C" << llendl;
+			LL_DEBUGS() << "Encoding new image of format J2C" << LL_ENDL;
 			LLPointer<LLImageJ2C> formatted = new LLImageJ2C;
 			LLPointer<LLImageRaw> scaled = new LLImageRaw(
 				previewp->mPreviewImage->getData(),
@@ -846,7 +846,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 			previewp->mFormattedImage = NULL;
 			// now create the new one of the appropriate format.
 			LLFloaterSnapshot::ESnapshotFormat format = previewp->getSnapshotFormat();
-			lldebugs << "Encoding new image of format " << format << llendl;
+			LL_DEBUGS() << "Encoding new image of format " << format << LL_ENDL;
 
 			switch(format)
 			{
@@ -926,7 +926,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 	{
 		previewp->generateThumbnailImage() ;
 	}
-	lldebugs << "done creating snapshot" << llendl;
+	LL_DEBUGS() << "done creating snapshot" << LL_ENDL;
 	LLFloaterSnapshot::postUpdate();
 
 	return TRUE;
@@ -934,7 +934,7 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview )
 
 void LLSnapshotLivePreview::setSize(S32 w, S32 h)
 {
-	lldebugs << "setSize(" << w << ", " << h << ")" << llendl;
+	LL_DEBUGS() << "setSize(" << w << ", " << h << ")" << LL_ENDL;
 	setWidth(w);
 	setHeight(h);
 }
@@ -947,7 +947,7 @@ void LLSnapshotLivePreview::getSize(S32& w, S32& h) const
 
 void LLSnapshotLivePreview::saveTexture()
 {
-	lldebugs << "saving texture: " << mPreviewImage->getWidth() << "x" << mPreviewImage->getHeight() << llendl;
+	LL_DEBUGS() << "saving texture: " << mPreviewImage->getWidth() << "x" << mPreviewImage->getHeight() << LL_ENDL;
 	// gen a new uuid for this asset
 	LLTransactionID tid;
 	tid.generate();
@@ -960,7 +960,7 @@ void LLSnapshotLivePreview::saveTexture()
 												  mPreviewImage->getComponents());
 	
 	scaled->biasedScaleToPowerOfTwo(MAX_TEXTURE_SIZE);
-	lldebugs << "scaled texture to " << scaled->getWidth() << "x" << scaled->getHeight() << llendl;
+	LL_DEBUGS() << "scaled texture to " << scaled->getWidth() << "x" << scaled->getHeight() << LL_ENDL;
 
 	if (formatted->encode(scaled, 0.0f))
 	{
@@ -989,7 +989,7 @@ void LLSnapshotLivePreview::saveTexture()
 	else
 	{
 		LLNotificationsUtil::add("ErrorEncodingSnapshot");
-		llwarns << "Error encoding snapshot" << llendl;
+		LL_WARNS() << "Error encoding snapshot" << LL_ENDL;
 	}
 
 	add(LLStatViewer::SNAPSHOT, 1);
@@ -1015,7 +1015,7 @@ void LLSnapshotLivePreview::saveWeb()
 	LLImageJPEG* jpg = dynamic_cast<LLImageJPEG*>(mFormattedImage.get());
 	if(!jpg)
 	{
-		llwarns << "Formatted image not a JPEG" << llendl;
+		LL_WARNS() << "Formatted image not a JPEG" << LL_ENDL;
 		return;
 	}
 
@@ -1353,13 +1353,13 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 		if (width_ctrl->getValue().asInteger() == 0)
 		{
 			S32 w = gViewerWindow->getWindowWidthRaw();
-			lldebugs << "Initializing width spinner (" << width_ctrl->getName() << "): " << w << llendl;
+			LL_DEBUGS() << "Initializing width spinner (" << width_ctrl->getName() << "): " << w << LL_ENDL;
 			width_ctrl->setValue(w);
 		}
 		if (height_ctrl->getValue().asInteger() == 0)
 		{
 			S32 h = gViewerWindow->getWindowHeightRaw();
-			lldebugs << "Initializing height spinner (" << height_ctrl->getName() << "): " << h << llendl;
+			LL_DEBUGS() << "Initializing height spinner (" << height_ctrl->getName() << "): " << h << LL_ENDL;
 			height_ctrl->setValue(h);
 		}
 
@@ -1394,7 +1394,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 	BOOL got_snap = previewp && previewp->getSnapshotUpToDate();
 
 	// *TODO: Separate maximum size for Web images from postcards
-	lldebugs << "Is snapshot up-to-date? " << got_snap << llendl;
+	LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL;
 
 	LLLocale locale(LLLocale::USER_LOCALE);
 	std::string bytes_string;
@@ -1458,7 +1458,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshot* floater)
 		info["have-snapshot"] = got_snap;
 		current_panel->updateControls(info);
 	}
-	lldebugs << "finished updating controls" << llendl;
+	LL_DEBUGS() << "finished updating controls" << LL_ENDL;
 }
 
 // static
@@ -1505,7 +1505,7 @@ void LLFloaterSnapshot::Impl::checkAutoSnapshot(LLSnapshotLivePreview* previewp,
 	if (previewp)
 	{
 		BOOL autosnap = gSavedSettings.getBOOL("AutoSnapshot");
-		lldebugs << "updating " << (autosnap ? "snapshot" : "thumbnail") << llendl;
+		LL_DEBUGS() << "updating " << (autosnap ? "snapshot" : "thumbnail") << LL_ENDL;
 		previewp->updateSnapshot(autosnap, update_thumbnail, autosnap ? AUTO_SNAPSHOT_TIME_DELAY : 0.f);
 	}
 }
@@ -1518,7 +1518,7 @@ void LLFloaterSnapshot::Impl::onClickNewSnapshot(void* data)
 	if (previewp && view)
 	{
 		view->impl.setStatus(Impl::STATUS_READY);
-		lldebugs << "updating snapshot" << llendl;
+		LL_DEBUGS() << "updating snapshot" << LL_ENDL;
 		previewp->updateSnapshot(TRUE);
 	}
 }
@@ -1595,7 +1595,7 @@ void LLFloaterSnapshot::Impl::applyKeepAspectCheck(LLFloaterSnapshot* view, BOOL
 			previewp->getSize(w, h) ;
 			updateSpinners(view, previewp, w, h, TRUE); // may change w and h
 
-			lldebugs << "updating thumbnail" << llendl;
+			LL_DEBUGS() << "updating thumbnail" << LL_ENDL;
 			previewp->setSize(w, h) ;
 			previewp->updateSnapshot(FALSE, TRUE);
 			checkAutoSnapshot(previewp, TRUE);
@@ -1731,7 +1731,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
 		if (width == 0 || height == 0)
 		{
 			// take resolution from current window size
-			lldebugs << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << llendl;
+			LL_DEBUGS() << "Setting preview res from window: " << gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL;
 			previewp->setSize(gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw());
 		}
 		else if (width == -1 || height == -1)
@@ -1741,7 +1741,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
 			LLPanelSnapshot* spanel = getActivePanel(view);
 			if (spanel)
 			{
-				lldebugs << "Loading typed res from panel " << spanel->getName() << llendl;
+				LL_DEBUGS() << "Loading typed res from panel " << spanel->getName() << LL_ENDL;
 				new_width = spanel->getTypedPreviewWidth();
 				new_height = spanel->getTypedPreviewHeight();
 
@@ -1754,8 +1754,8 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
 			}
 			else
 			{
-				lldebugs << "No custom res chosen, setting preview res from window: "
-					<< gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << llendl;
+				LL_DEBUGS() << "No custom res chosen, setting preview res from window: "
+					<< gViewerWindow->getWindowWidthRaw() << "x" << gViewerWindow->getWindowHeightRaw() << LL_ENDL;
 				new_width = gViewerWindow->getWindowWidthRaw();
 				new_height = gViewerWindow->getWindowHeightRaw();
 			}
@@ -1766,7 +1766,7 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
 		else
 		{
 			// use the resolution from the selected pre-canned drop-down choice
-			lldebugs << "Setting preview res selected from combo: " << width << "x" << height << llendl;
+			LL_DEBUGS() << "Setting preview res selected from combo: " << width << "x" << height << LL_ENDL;
 			previewp->setSize(width, height);
 		}
 
@@ -1794,11 +1794,11 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, BOOL
 
 			// hide old preview as the aspect ratio could be wrong
 			checkAutoSnapshot(previewp, FALSE);
-			lldebugs << "updating thumbnail" << llendl;
+			LL_DEBUGS() << "updating thumbnail" << LL_ENDL;
 			getPreviewView(view)->updateSnapshot(FALSE, TRUE);
 			if(do_update)
 			{
-				lldebugs << "Will update controls" << llendl;
+				LL_DEBUGS() << "Will update controls" << LL_ENDL;
 				updateControls(view);
 				setNeedRefresh(view, true);
 			}
@@ -1841,7 +1841,7 @@ void LLFloaterSnapshot::Impl::onImageFormatChange(LLFloaterSnapshot* view)
 	if (view)
 	{
 		gSavedSettings.setS32("SnapshotFormat", getImageFormat(view));
-		lldebugs << "image format changed, updating snapshot" << llendl;
+		LL_DEBUGS() << "image format changed, updating snapshot" << LL_ENDL;
 		getPreviewView(view)->updateSnapshot(TRUE);
 		updateControls(view);
 		setNeedRefresh(view, false); // we're refreshing
@@ -1924,7 +1924,7 @@ void LLFloaterSnapshot::Impl::applyCustomResolution(LLFloaterSnapshot* view, S32
 {
 	bool need_refresh = false;
 
-	lldebugs << "applyCustomResolution(" << w << ", " << h << ")" << llendl;
+	LL_DEBUGS() << "applyCustomResolution(" << w << ", " << h << ")" << LL_ENDL;
 	if (!view) return;
 
 	LLSnapshotLivePreview* previewp = getPreviewView(view);
@@ -1942,7 +1942,7 @@ void LLFloaterSnapshot::Impl::applyCustomResolution(LLFloaterSnapshot* view, S32
 
 			previewp->setSize(w,h);
 			checkAutoSnapshot(previewp, FALSE);
-			lldebugs << "applied custom resolution, updating thumbnail" << llendl;
+			LL_DEBUGS() << "applied custom resolution, updating thumbnail" << LL_ENDL;
 			previewp->updateSnapshot(FALSE, TRUE);
 			comboSetCustom(view, "profile_size_combo");
 			comboSetCustom(view, "postcard_size_combo");
@@ -2157,7 +2157,7 @@ void LLFloaterSnapshot::onOpen(const LLSD& key)
 	LLSnapshotLivePreview* preview = LLFloaterSnapshot::Impl::getPreviewView(this);
 	if(preview)
 	{
-		lldebugs << "opened, updating snapshot" << llendl;
+		LL_DEBUGS() << "opened, updating snapshot" << LL_ENDL;
 		preview->updateSnapshot(TRUE);
 	}
 	focusFirstItem(FALSE);
@@ -2239,7 +2239,7 @@ void LLFloaterSnapshot::update()
 		return;
 	
 	BOOL changed = FALSE;
-	lldebugs << "npreviews: " << LLSnapshotLivePreview::sList.size() << llendl;
+	LL_DEBUGS() << "npreviews: " << LLSnapshotLivePreview::sList.size() << LL_ENDL;
 	for (std::set<LLSnapshotLivePreview*>::iterator iter = LLSnapshotLivePreview::sList.begin();
 		 iter != LLSnapshotLivePreview::sList.end(); ++iter)
 	{
@@ -2247,7 +2247,7 @@ void LLFloaterSnapshot::update()
 	}
 	if(changed)
 	{
-		lldebugs << "changed" << llendl;
+		LL_DEBUGS() << "changed" << LL_ENDL;
 		inst->impl.updateControls(inst);
 	}
 }
@@ -2261,7 +2261,7 @@ LLFloaterSnapshot* LLFloaterSnapshot::getInstance()
 // static
 void LLFloaterSnapshot::saveTexture()
 {
-	lldebugs << "saveTexture" << llendl;
+	LL_DEBUGS() << "saveTexture" << LL_ENDL;
 
 	// FIXME: duplicated code
 	LLFloaterSnapshot* instance = LLFloaterReg::findTypedInstance<LLFloaterSnapshot>("snapshot");
@@ -2283,7 +2283,7 @@ void LLFloaterSnapshot::saveTexture()
 // static
 BOOL LLFloaterSnapshot::saveLocal()
 {
-	lldebugs << "saveLocal" << llendl;
+	LL_DEBUGS() << "saveLocal" << LL_ENDL;
 	// FIXME: duplicated code
 	LLFloaterSnapshot* instance = LLFloaterReg::findTypedInstance<LLFloaterSnapshot>("snapshot");
 	if (!instance)
@@ -2384,7 +2384,7 @@ LLPointer<LLImageFormatted> LLFloaterSnapshot::getImageData()
 	LLPointer<LLImageFormatted> img = previewp->getFormattedImage();
 	if (!img.get())
 	{
-		llwarns << "Empty snapshot image data" << llendl;
+		LL_WARNS() << "Empty snapshot image data" << LL_ENDL;
 		llassert(img.get() != NULL);
 	}
 
diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp
index 14923eec3c..159a31d743 100755
--- a/indra/newview/llfloatertools.cpp
+++ b/indra/newview/llfloatertools.cpp
@@ -266,7 +266,7 @@ BOOL	LLFloaterTools::postBuild()
 			found->setClickedCallback(boost::bind(&LLFloaterTools::setObjectType, toolData[t]));
 			mButtons.push_back( found );
 		}else{
-			llwarns << "Tool button not found! DOA Pending." << llendl;
+			LL_WARNS() << "Tool button not found! DOA Pending." << LL_ENDL;
 		}
 	}
 	mCheckCopySelection = getChild<LLCheckBoxCtrl>("checkbox copy selection");
@@ -500,7 +500,7 @@ void LLFloaterTools::refresh()
 			}
 			else
 			{
-				llwarns << "Failed to get selected object" << llendl;
+				LL_WARNS() << "Failed to get selected object" << LL_ENDL;
 			}
 		}
 
@@ -1095,7 +1095,7 @@ void LLFloaterTools::setTool(const LLSD& user_data)
 	else if (control_name == "Land" )
 		LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool *) LLToolSelectLand::getInstance());
 	else
-		llwarns<<" no parameter name "<<control_name<<" found!! No Tool selected!!"<< llendl;
+		LL_WARNS()<<" no parameter name "<<control_name<<" found!! No Tool selected!!"<< LL_ENDL;
 }
 
 void LLFloaterTools::onFocusReceived()
diff --git a/indra/newview/llfloatertranslationsettings.cpp b/indra/newview/llfloatertranslationsettings.cpp
index 33f2c35239..965d29b09c 100755
--- a/indra/newview/llfloatertranslationsettings.cpp
+++ b/indra/newview/llfloatertranslationsettings.cpp
@@ -59,7 +59,7 @@ private:
 
 		if (!floater)
 		{
-			llwarns << "Cannot find translation settings floater" << llendl;
+			LL_WARNS() << "Cannot find translation settings floater" << LL_ENDL;
 			return;
 		}
 
diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp
index 0106a1615d..96a70d9345 100755
--- a/indra/newview/llfloateruipreview.cpp
+++ b/indra/newview/llfloateruipreview.cpp
@@ -607,7 +607,7 @@ void LLFloaterUIPreview::onClose(bool app_quitting)
 // *TODO: this is currently unlocalized.  Add to alerts/notifications.xml, someday, maybe.
 void LLFloaterUIPreview::popupAndPrintWarning(const std::string& warning)
 {
-	llwarns << warning << llendl;
+	LL_WARNS() << warning << LL_ENDL;
 	LLSD args;
 	args["MESSAGE"] = warning;
 	LLNotificationsUtil::add("GenericAlert", args);
@@ -960,7 +960,7 @@ void LLFloaterUIPreview::onClickEditFloater()
 		std::string file_name = mFileList->getSelectedItemLabel(1);	// get the file name of the currently-selected floater
 		if (file_name.empty())					// if no item is selected
 		{
-			llwarns << "No file selected" << llendl;
+			LL_WARNS() << "No file selected" << LL_ENDL;
 			return;															// ignore click
 		}
 		file_path = getLocalizedDirectory() + file_name;
@@ -1268,8 +1268,8 @@ void LLFloaterUIPreview::highlightChangedElements()
 			// if we still didn't find it...
 			if(NULL == element)												
 			{
-				llinfos << "Unable to find element in XuiDelta file named \"" << *iter << "\" in file \"" << mLiveFile->mFileName <<
-							"\". The element may no longer exist, the path may be incorrect, or it may not be a non-displayable element (not an LLView) such as a \"string\" type." << llendl;
+				LL_INFOS() << "Unable to find element in XuiDelta file named \"" << *iter << "\" in file \"" << mLiveFile->mFileName <<
+							"\". The element may no longer exist, the path may be incorrect, or it may not be a non-displayable element (not an LLView) such as a \"string\" type." << LL_ENDL;
 				failed = TRUE;
 				break;
 			}
diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp
index 3fe2518de6..bc445caa39 100755
--- a/indra/newview/llfloaterwebcontent.cpp
+++ b/indra/newview/llfloaterwebcontent.cpp
@@ -186,7 +186,7 @@ void LLFloaterWebContent::geometryChanged(S32 x, S32 y, S32 width, S32 height)
 						width + getRect().getWidth() - browser_rect.getWidth(), 
 						height + getRect().getHeight() - browser_rect.getHeight());
 
-	lldebugs << "geometry change: " << geom << llendl;
+	LL_DEBUGS() << "geometry change: " << geom << LL_ENDL;
 	
 	LLRect new_rect;
 	getParent()->screenRectToLocal(geom, &new_rect);
@@ -196,7 +196,7 @@ void LLFloaterWebContent::geometryChanged(S32 x, S32 y, S32 width, S32 height)
 // static
 void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p)
 {
-	lldebugs << "url = " << p.url() << ", target = " << p.target() << ", uuid = " << p.id() << llendl;
+	LL_DEBUGS() << "url = " << p.url() << ", target = " << p.target() << ", uuid = " << p.id() << LL_ENDL;
 
 	if (!p.id.isProvided())
 	{
@@ -215,11 +215,11 @@ void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p)
 		// and close the least recently opened one if this will put us over the limit.
 
 		LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class);
-		lldebugs << "total instance count is " << instances.size() << llendl;
+		LL_DEBUGS() << "total instance count is " << instances.size() << LL_ENDL;
 
 		for(LLFloaterReg::const_instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); iter++)
 		{
-			lldebugs << "    " << (*iter)->getKey()["target"] << llendl;
+			LL_DEBUGS() << "    " << (*iter)->getKey()["target"] << LL_ENDL;
 		}
 
 		if(instances.size() >= (size_t)browser_window_limit)
diff --git a/indra/newview/llfloaterwebprofile.cpp b/indra/newview/llfloaterwebprofile.cpp
index c41f6f148f..a46f1d8af2 100755
--- a/indra/newview/llfloaterwebprofile.cpp
+++ b/indra/newview/llfloaterwebprofile.cpp
@@ -47,11 +47,11 @@ void LLFloaterWebProfile::onOpen(const LLSD& key)
 // virtual
 void LLFloaterWebProfile::handleReshape(const LLRect& new_rect, bool by_user)
 {
-	lldebugs << "handleReshape: " << new_rect << llendl;
+	LL_DEBUGS() << "handleReshape: " << new_rect << LL_ENDL;
 
 	if (by_user && !isMinimized())
 	{
-		lldebugs << "Storing new rect" << llendl;
+		LL_DEBUGS() << "Storing new rect" << LL_ENDL;
 		gSavedSettings.setRect("WebProfileFloaterRect", new_rect);
 	}
 
@@ -68,7 +68,7 @@ LLFloater* LLFloaterWebProfile::create(const LLSD& key)
 void LLFloaterWebProfile::applyPreferredRect()
 {
 	const LLRect preferred_rect = gSavedSettings.getRect("WebProfileFloaterRect");
-	lldebugs << "Applying preferred rect: " << preferred_rect << llendl;
+	LL_DEBUGS() << "Applying preferred rect: " << preferred_rect << LL_ENDL;
 
 	// Don't override position that may have been set by floater stacking code.
 	LLRect new_rect = getRect();
diff --git a/indra/newview/llfollowcam.cpp b/indra/newview/llfollowcam.cpp
index 3110d0391f..612afc0d18 100755
--- a/indra/newview/llfollowcam.cpp
+++ b/indra/newview/llfollowcam.cpp
@@ -876,12 +876,12 @@ bool LLFollowCamMgr::isScriptedCameraSource(const LLUUID& source)
 void LLFollowCamMgr::dump()
 {
 	S32 param_count = 0;
-	llinfos << "Scripted camera active stack" << llendl;
+	LL_INFOS() << "Scripted camera active stack" << LL_ENDL;
 	for (param_stack_t::iterator param_it = sParamStack.begin();
 		param_it != sParamStack.end();
 		++param_it)
 	{
-		llinfos << param_count++ << 
+		LL_INFOS() << param_count++ << 
 			" rot_limit: " << (*param_it)->getBehindnessAngle() << 
 			" rot_lag: " << (*param_it)->getBehindnessLag() << 
 			" distance: " << (*param_it)->getDistance() << 
@@ -894,7 +894,7 @@ void LLFollowCamMgr::dump()
 			" pos: " << (*param_it)->getPosition() << 
 			" pos_lag: " << (*param_it)->getPositionLag() << 
 			" pos_lock: " << ((*param_it)->getPositionLocked() ? "Y" : "N") << 
-			" pos_thresh: " << (*param_it)->getPositionThreshold() << llendl;
+			" pos_thresh: " << (*param_it)->getPositionThreshold() << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llfriendcard.cpp b/indra/newview/llfriendcard.cpp
index 1771a8f491..6566ef5dca 100755
--- a/indra/newview/llfriendcard.cpp
+++ b/indra/newview/llfriendcard.cpp
@@ -172,14 +172,14 @@ LLFriendCardsManager::~LLFriendCardsManager()
 
 void LLFriendCardsManager::putAvatarData(const LLUUID& avatarID)
 {
-	llinfos << "Store avatar data, avatarID: " << avatarID << llendl;
+	LL_INFOS() << "Store avatar data, avatarID: " << avatarID << LL_ENDL;
 	std::pair< avatar_uuid_set_t::iterator, bool > pr;
 	pr = mBuddyIDSet.insert(avatarID);
 	if (pr.second == false)
 	{
-		llwarns << "Trying to add avatar UUID for the stored avatar: " 
+		LL_WARNS() << "Trying to add avatar UUID for the stored avatar: " 
 			<< avatarID
-			<< llendl;
+			<< LL_ENDL;
 	}
 }
 
@@ -189,7 +189,7 @@ const LLUUID LLFriendCardsManager::extractAvatarID(const LLUUID& avatarID)
 	avatar_uuid_set_t::iterator it = mBuddyIDSet.find(avatarID);
 	if (mBuddyIDSet.end() == it)
 	{
-		llwarns << "Call method for non-existent avatar name in the map: " << avatarID << llendl;
+		LL_WARNS() << "Call method for non-existent avatar name in the map: " << avatarID << LL_ENDL;
 	}
 	else
 	{
@@ -431,7 +431,7 @@ void LLFriendCardsManager::ensureFriendsFolderExists()
 		{
 			LLViewerInventoryCategory* cat = gInventory.getCategory(calling_cards_folder_ID);
 			std::string cat_name = cat ? cat->getName() : "unknown";
-			llwarns << "Failed to find \"" << cat_name << "\" category descendents in Category Tree." << llendl;
+			LL_WARNS() << "Failed to find \"" << cat_name << "\" category descendents in Category Tree." << LL_ENDL;
 		}
 
 		friends_folder_ID = gInventory.createNewCategory(calling_cards_folder_ID,
@@ -462,7 +462,7 @@ void LLFriendCardsManager::ensureFriendsAllFolderExists()
 		{
 			LLViewerInventoryCategory* cat = gInventory.getCategory(friends_folder_ID);
 			std::string cat_name = cat ? cat->getName() : "unknown";
-			llwarns << "Failed to find \"" << cat_name << "\" category descendents in Category Tree." << llendl;
+			LL_WARNS() << "Failed to find \"" << cat_name << "\" category descendents in Category Tree." << LL_ENDL;
 		}
 
 		friends_all_folder_ID = gInventory.createNewCategory(friends_folder_ID,
@@ -507,7 +507,7 @@ void LLFriendCardsManager::syncFriendsFolder()
 
 	// 2. Add missing Friend Cards for friends
 	LLAvatarTracker::buddy_map_t::const_iterator buddy_it = all_buddies.begin();
-	llinfos << "try to build friends, count: " << all_buddies.size() << llendl;
+	LL_INFOS() << "try to build friends, count: " << all_buddies.size() << LL_ENDL;
 	for(; buddy_it != all_buddies.end(); ++buddy_it)
 	{
 		const LLUUID& buddy_id = (*buddy_it).first;
@@ -535,26 +535,26 @@ void LLFriendCardsManager::addFriendCardToInventory(const LLUUID& avatarID)
 	LLAvatarNameCache::get(avatarID, &av_name);
 	const std::string& name = av_name.getAccountName();
 
-	lldebugs << "Processing buddy name: " << name 
+	LL_DEBUGS() << "Processing buddy name: " << name 
 		<< ", id: " << avatarID
-		<< llendl; 
+		<< LL_ENDL; 
 
 	if (shouldBeAdded && findFriendCardInventoryUUIDImpl(avatarID).notNull())
 	{
 		shouldBeAdded = false;
-		lldebugs << "is found in Inventory: " << name << llendl; 
+		LL_DEBUGS() << "is found in Inventory: " << name << LL_ENDL; 
 	}
 
 	if (shouldBeAdded && isAvatarDataStored(avatarID))
 	{
 		shouldBeAdded = false;
-		lldebugs << "is found in sentRequests: " << name << llendl; 
+		LL_DEBUGS() << "is found in sentRequests: " << name << LL_ENDL; 
 	}
 
 	if (shouldBeAdded)
 	{
 		putAvatarData(avatarID);
-		lldebugs << "Sent create_inventory_item for " << avatarID << ", " << name << llendl;
+		LL_DEBUGS() << "Sent create_inventory_item for " << avatarID << ", " << name << LL_ENDL;
 
 		// TODO: mantipov: Is CreateFriendCardCallback really needed? Probably not
 		LLPointer<LLInventoryCallback> cb = new CreateFriendCardCallback;
diff --git a/indra/newview/llgesturelistener.cpp b/indra/newview/llgesturelistener.cpp
index 2fff506681..6fd749d83e 100755
--- a/indra/newview/llgesturelistener.cpp
+++ b/indra/newview/llgesturelistener.cpp
@@ -101,12 +101,12 @@ void LLGestureListener::isGesturePlaying(const LLSD& event_data) const
 		}
 		else
 		{
-			llwarns << "isGesturePlaying did not find a gesture object for " << gesture_id << llendl;
+			LL_WARNS() << "isGesturePlaying did not find a gesture object for " << gesture_id << LL_ENDL;
 		}
 	}
 	else
 	{
-		llwarns << "isGesturePlaying didn't have 'id' value passed in" << llendl;
+		LL_WARNS() << "isGesturePlaying didn't have 'id' value passed in" << LL_ENDL;
 	}
 
 	LLSD reply = LLSD::emptyMap();
@@ -148,12 +148,12 @@ void LLGestureListener::startOrStopGesture(LLSD const & event_data, bool start)
 		}
 		else
 		{
-			llwarns << "startOrStopGesture did not find a gesture object for " << gesture_id << llendl;
+			LL_WARNS() << "startOrStopGesture did not find a gesture object for " << gesture_id << LL_ENDL;
 		}
 	}
 	else
 	{
-		llwarns << "startOrStopGesture didn't have 'id' value passed in" << llendl;
+		LL_WARNS() << "startOrStopGesture didn't have 'id' value passed in" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 876db96085..0b10fbb03f 100755
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -257,19 +257,19 @@ void LLGestureMgr::activateGestureWithAsset(const LLUUID& item_id,
 
 	if( !gAssetStorage )
 	{
-		llwarns << "LLGestureMgr::activateGestureWithAsset without valid gAssetStorage" << llendl;
+		LL_WARNS() << "LLGestureMgr::activateGestureWithAsset without valid gAssetStorage" << LL_ENDL;
 		return;
 	}
 	// If gesture is already active, nothing to do.
 	if (isGestureActive(item_id))
 	{
-		llwarns << "Tried to loadGesture twice " << item_id << llendl;
+		LL_WARNS() << "Tried to loadGesture twice " << item_id << LL_ENDL;
 		return;
 	}
 
 //	if (asset_id.isNull())
 //	{
-//		llwarns << "loadGesture() - gesture has no asset" << llendl;
+//		LL_WARNS() << "loadGesture() - gesture has no asset" << LL_ENDL;
 //		return;
 //	}
 
@@ -305,7 +305,7 @@ void LLGestureMgr::deactivateGesture(const LLUUID& item_id)
 	item_map_t::iterator it = mActive.find(base_item_id);
 	if (it == mActive.end())
 	{
-		llwarns << "deactivateGesture for inactive gesture " << item_id << llendl;
+		LL_WARNS() << "deactivateGesture for inactive gesture " << item_id << LL_ENDL;
 		return;
 	}
 
@@ -469,7 +469,7 @@ void LLGestureMgr::replaceGesture(const LLUUID& item_id, LLMultiGesture* new_ges
 	item_map_t::iterator it = mActive.find(base_item_id);
 	if (it == mActive.end())
 	{
-		llwarns << "replaceGesture for inactive gesture " << base_item_id << llendl;
+		LL_WARNS() << "replaceGesture for inactive gesture " << base_item_id << LL_ENDL;
 		return;
 	}
 
@@ -511,7 +511,7 @@ void LLGestureMgr::replaceGesture(const LLUUID& item_id, const LLUUID& new_asset
 	item_map_t::iterator it = LLGestureMgr::instance().mActive.find(base_item_id);
 	if (it == mActive.end())
 	{
-		llwarns << "replaceGesture for inactive gesture " << base_item_id << llendl;
+		LL_WARNS() << "replaceGesture for inactive gesture " << base_item_id << LL_ENDL;
 		return;
 	}
 
@@ -586,7 +586,7 @@ void LLGestureMgr::playGesture(LLMultiGesture* gesture)
 			}
 		default:
 			{
-				llwarns << "Unknown gesture step type: " << step->getType() << llendl;
+				LL_WARNS() << "Unknown gesture step type: " << step->getType() << LL_ENDL;
 			}
 		}
 	}
@@ -907,8 +907,8 @@ void LLGestureMgr::stepGesture(LLMultiGesture* gesture)
 			else if (gesture->mWaitTimer.getElapsedTimeF32() > MAX_WAIT_ANIM_SECS)
 			{
 				// we've waited too long for an animation
-				llinfos << "Waited too long for animations to stop, continuing gesture."
-					<< llendl;
+				LL_INFOS() << "Waited too long for animations to stop, continuing gesture."
+					<< LL_ENDL;
 				gesture->mWaitingAnimations = FALSE;
 				gesture->mCurrentStep++;
 			}
@@ -1129,7 +1129,7 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs,
 		}
 		else
 		{
-			llwarns << "Unable to load gesture" << llendl;
+			LL_WARNS() << "Unable to load gesture" << LL_ENDL;
 
 			self.mActive.erase(item_id);
 			
@@ -1149,7 +1149,7 @@ void LLGestureMgr::onLoadComplete(LLVFS *vfs,
 			LLDelayedGestureError::gestureFailedToLoad( item_id );
 		}
 
-		llwarns << "Problem loading gesture: " << status << llendl;
+		LL_WARNS() << "Problem loading gesture: " << status << LL_ENDL;
 		
 		LLGestureMgr::instance().mActive.erase(item_id);			
 	}
@@ -1185,7 +1185,7 @@ void LLGestureMgr::onAssetLoadComplete(LLVFS *vfs,
 		}
 	default:
 		{
-			llwarns << "Unexpected asset type: " << type << llendl;
+			LL_WARNS() << "Unexpected asset type: " << type << LL_ENDL;
 
 			// We don't want to return from this callback without
 			// an animation or sound callback being fired
@@ -1240,7 +1240,7 @@ bool LLGestureMgr::hasLoadingAssets(LLMultiGesture* gesture)
 			}
 		default:
 			{
-				llwarns << "Unknown gesture step type: " << step->getType() << llendl;
+				LL_WARNS() << "Unknown gesture step type: " << step->getType() << LL_ENDL;
 			}
 		}
 	}
@@ -1322,7 +1322,7 @@ void LLGestureMgr::removeObserver(LLGestureManagerObserver* observer)
 // from the list.
 void LLGestureMgr::notifyObservers()
 {
-	lldebugs << "LLGestureMgr::notifyObservers" << llendl;
+	LL_DEBUGS() << "LLGestureMgr::notifyObservers" << LL_ENDL;
 
 	for(std::vector<LLGestureManagerObserver*>::iterator iter = mObservers.begin(); 
 		iter != mObservers.end(); 
diff --git a/indra/newview/llgiveinventory.cpp b/indra/newview/llgiveinventory.cpp
index 2ecd9fa7f7..493dea62ff 100755
--- a/indra/newview/llgiveinventory.cpp
+++ b/indra/newview/llgiveinventory.cpp
@@ -192,7 +192,7 @@ bool LLGiveInventory::doGiveInventoryItem(const LLUUID& to_agent,
 
 {
 	bool res = true;
-	llinfos << "LLGiveInventory::giveInventory()" << llendl;
+	LL_INFOS() << "LLGiveInventory::giveInventory()" << LL_ENDL;
 	if (!isInventoryGiveAcceptable(item))
 	{
 		return false;
@@ -230,8 +230,8 @@ bool LLGiveInventory::doGiveInventoryCategory(const LLUUID& to_agent,
 	{
 		return false;
 	}
-	llinfos << "LLGiveInventory::giveInventoryCategory() - "
-		<< cat->getUUID() << llendl;
+	LL_INFOS() << "LLGiveInventory::giveInventoryCategory() - "
+		<< cat->getUUID() << LL_ENDL;
 
 	if (!isAgentAvatarValid())
 	{
@@ -484,8 +484,8 @@ bool LLGiveInventory::commitGiveInventoryCategory(const LLUUID& to_agent,
 	{
 		return false;
 	}
-	llinfos << "LLGiveInventory::commitGiveInventoryCategory() - "
-		<< cat->getUUID() << llendl;
+	LL_INFOS() << "LLGiveInventory::commitGiveInventoryCategory() - "
+		<< cat->getUUID() << LL_ENDL;
 
 	// add buddy to recent people list
 	LLRecentPeople::instance().add(to_agent);
diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp
index 0324629c6e..5c015c58c4 100755
--- a/indra/newview/llgroupactions.cpp
+++ b/indra/newview/llgroupactions.cpp
@@ -130,14 +130,14 @@ void LLGroupActions::startCall(const LLUUID& group_id)
 
 	if (!gAgent.getGroupData(group_id, gdata))
 	{
-		llwarns << "Error getting group data" << llendl;
+		LL_WARNS() << "Error getting group data" << LL_ENDL;
 		return;
 	}
 
 	LLUUID session_id = gIMMgr->addSession(gdata.mName, IM_SESSION_GROUP_START, group_id, true);
 	if (session_id == LLUUID::null)
 	{
-		llwarns << "Error adding session" << llendl;
+		LL_WARNS() << "Error adding session" << LL_ENDL;
 		return;
 	}
 
@@ -183,8 +183,8 @@ void LLGroupActions::join(const LLUUID& group_id)
 	}
 	else
 	{
-		llwarns << "LLGroupMgr::getInstance()->getGroupData(" << group_id 
-			<< ") was NULL" << llendl;
+		LL_WARNS() << "LLGroupMgr::getInstance()->getGroupData(" << group_id 
+			<< ") was NULL" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index ba4927e622..67778ebcab 100755
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -329,7 +329,7 @@ void LLGroupMgrGroupData::setRoleData(const LLUUID& role_id, LLRoleData role_dat
 	}
 	else
 	{
-		llwarns << "Change being made to non-existant role " << role_id << llendl;
+		LL_WARNS() << "Change being made to non-existant role " << role_id << LL_ENDL;
 	}
 }
 
@@ -343,7 +343,7 @@ void LLGroupMgrGroupData::createRole(const LLUUID& role_id, LLRoleData role_data
 {
 	if (mRoleChanges.find(role_id) != mRoleChanges.end())
 	{
-		llwarns << "create role for existing role! " << role_id << llendl;
+		LL_WARNS() << "create role for existing role! " << role_id << LL_ENDL;
 	}
 	else
 	{
@@ -380,7 +380,7 @@ void LLGroupMgrGroupData::addRolePower(const LLUUID &role_id, U64 power)
 	}
 	else
 	{
-		llwarns << "addRolePower: no role data found for " << role_id << llendl;
+		LL_WARNS() << "addRolePower: no role data found for " << role_id << LL_ENDL;
 	}
 }
 
@@ -394,7 +394,7 @@ void LLGroupMgrGroupData::removeRolePower(const LLUUID &role_id, U64 power)
 	}
 	else
 	{
-		llwarns << "removeRolePower: no role data found for " << role_id << llendl;
+		LL_WARNS() << "removeRolePower: no role data found for " << role_id << LL_ENDL;
 	}
 }
 
@@ -407,7 +407,7 @@ U64 LLGroupMgrGroupData::getRolePowers(const LLUUID& role_id)
 	}
 	else
 	{
-		llwarns << "getRolePowers: no role data found for " << role_id << llendl;
+		LL_WARNS() << "getRolePowers: no role data found for " << role_id << LL_ENDL;
 		return GP_NO_POWERS;
 	}
 }
@@ -491,8 +491,8 @@ bool LLGroupMgrGroupData::changeRoleMember(const LLUUID& role_id,
 	if (ri == mRoles.end()
 		|| mi == mMembers.end() )
 	{
-		if (ri == mRoles.end()) llwarns << "LLGroupMgrGroupData::changeRoleMember couldn't find role " << role_id << llendl;
-		if (mi == mMembers.end()) llwarns << "LLGroupMgrGroupData::changeRoleMember couldn't find member " << member_id << llendl;
+		if (ri == mRoles.end()) LL_WARNS() << "LLGroupMgrGroupData::changeRoleMember couldn't find role " << role_id << LL_ENDL;
+		if (mi == mMembers.end()) LL_WARNS() << "LLGroupMgrGroupData::changeRoleMember couldn't find member " << member_id << LL_ENDL;
 		return false;
 	}
 
@@ -501,13 +501,13 @@ bool LLGroupMgrGroupData::changeRoleMember(const LLUUID& role_id,
 
 	if (!grd || !gmd)
 	{
-		llwarns << "LLGroupMgrGroupData::changeRoleMember couldn't get member or role data." << llendl;
+		LL_WARNS() << "LLGroupMgrGroupData::changeRoleMember couldn't get member or role data." << LL_ENDL;
 		return false;
 	}
 
 	if (RMC_ADD == rmc)
 	{
-		llinfos << " adding member to role." << llendl;
+		LL_INFOS() << " adding member to role." << LL_ENDL;
 		grd->addMember(member_id);
 		gmd->addRole(role_id,grd);
 
@@ -517,7 +517,7 @@ bool LLGroupMgrGroupData::changeRoleMember(const LLUUID& role_id,
 	}
 	else if (RMC_REMOVE == rmc)
 	{
-		llinfos << " removing member from role." << llendl;
+		LL_INFOS() << " removing member from role." << LL_ENDL;
 		grd->removeMember(member_id);
 		gmd->removeRole(role_id);
 
@@ -536,9 +536,9 @@ bool LLGroupMgrGroupData::changeRoleMember(const LLUUID& role_id,
 		if (it->second.mChange == rmc)
 		{
 			// Already recorded this change?  Weird.
-			llinfos << "Received duplicate change for "
+			LL_INFOS() << "Received duplicate change for "
 					<< " role: " << role_id << " member " << member_id 
-					<< " change " << (rmc == RMC_ADD ? "ADD" : "REMOVE") << llendl;
+					<< " change " << (rmc == RMC_ADD ? "ADD" : "REMOVE") << LL_ENDL;
 		}
 		else
 		{
@@ -546,7 +546,7 @@ bool LLGroupMgrGroupData::changeRoleMember(const LLUUID& role_id,
 			// If that changes this will need more logic
 			if (rmc == RMC_NONE)
 			{
-				llwarns << "changeRoleMember: existing entry with 'RMC_NONE' change! This shouldn't happen." << llendl;
+				LL_WARNS() << "changeRoleMember: existing entry with 'RMC_NONE' change! This shouldn't happen." << LL_ENDL;
 				LLRoleMemberChange rc(role_id,member_id,rmc);
 				mRoleMemberChanges[role_member] = rc;
 			}
@@ -864,12 +864,12 @@ static void formatDateString(std::string &date_string)
 // static
 void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data)
 {
-	lldebugs << "LLGroupMgr::processGroupMembersReply" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::processGroupMembersReply" << LL_ENDL;
 	LLUUID agent_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group members reply for another agent!" << llendl;
+		LL_WARNS() << "Got group members reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -882,7 +882,7 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data)
 	LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id);
 	if (!group_datap || (group_datap->mMemberRequestID != request_id))
 	{
-		llwarns << "processGroupMembersReply: Received incorrect (stale?) group or request id" << llendl;
+		LL_WARNS() << "processGroupMembersReply: Received incorrect (stale?) group or request id" << LL_ENDL;
 		return;
 	}
 
@@ -920,7 +920,7 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data)
 					formatDateString(online_status); // reformat for sorting, e.g. 12/25/2008 -> 2008/12/25
 				}
 				
-				//llinfos << "Member " << member_id << " has powers " << std::hex << agent_powers << std::dec << llendl;
+				//LL_INFOS() << "Member " << member_id << " has powers " << std::hex << agent_powers << std::dec << LL_ENDL;
 				LLGroupMemberData* newdata = new LLGroupMemberData(member_id, 
 																	contribution, 
 																	agent_powers, 
@@ -931,14 +931,14 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data)
 				LLGroupMgrGroupData::member_list_t::iterator mit = group_datap->mMembers.find(member_id);
 				if (mit != group_datap->mMembers.end())
 				{
-					llinfos << " *** Received duplicate member data for agent " << member_id << llendl;
+					LL_INFOS() << " *** Received duplicate member data for agent " << member_id << LL_ENDL;
 				}
 #endif
 				group_datap->mMembers[member_id] = newdata;
 			}
 			else
 			{
-				llinfos << "Received null group member data." << llendl;
+				LL_INFOS() << "Received null group member data." << LL_ENDL;
 			}
 		}
 
@@ -970,12 +970,12 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data)
 //static 
 void LLGroupMgr::processGroupPropertiesReply(LLMessageSystem* msg, void** data)
 {
-	lldebugs << "LLGroupMgr::processGroupPropertiesReply" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::processGroupPropertiesReply" << LL_ENDL;
 	LLUUID agent_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group properties reply for another agent!" << llendl;
+		LL_WARNS() << "Got group properties reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -1037,12 +1037,12 @@ void LLGroupMgr::processGroupPropertiesReply(LLMessageSystem* msg, void** data)
 // static
 void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data)
 {
-	lldebugs << "LLGroupMgr::processGroupRoleDataReply" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::processGroupRoleDataReply" << LL_ENDL;
 	LLUUID agent_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group role data reply for another agent!" << llendl;
+		LL_WARNS() << "Got group role data reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -1055,7 +1055,7 @@ void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data)
 	LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id);
 	if (!group_datap || (group_datap->mRoleDataRequestID != request_id))
 	{
-		llwarns << "processGroupPropertiesReply: Received incorrect (stale?) group or request id" << llendl;
+		LL_WARNS() << "processGroupPropertiesReply: Received incorrect (stale?) group or request id" << LL_ENDL;
 		return;
 	}
 
@@ -1098,7 +1098,7 @@ void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data)
 
 
 
-		lldebugs << "Adding role data: " << name << " {" << role_id << "}" << llendl;
+		LL_DEBUGS() << "Adding role data: " << name << " {" << role_id << "}" << LL_ENDL;
 		LLGroupRoleData* rd = new LLGroupRoleData(role_id,name,title,desc,powers,member_count);
 		group_datap->mRoles[role_id] = rd;
 	}
@@ -1122,12 +1122,12 @@ void LLGroupMgr::processGroupRoleDataReply(LLMessageSystem* msg, void** data)
 // static
 void LLGroupMgr::processGroupRoleMembersReply(LLMessageSystem* msg, void** data)
 {
-	lldebugs << "LLGroupMgr::processGroupRoleMembersReply" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::processGroupRoleMembersReply" << LL_ENDL;
 	LLUUID agent_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group role members reply for another agent!" << llendl;
+		LL_WARNS() << "Got group role members reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -1143,7 +1143,7 @@ void LLGroupMgr::processGroupRoleMembersReply(LLMessageSystem* msg, void** data)
 	LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id);
 	if (!group_datap || (group_datap->mRoleMembersRequestID != request_id))
 	{
-		llwarns << "processGroupRoleMembersReply: Received incorrect (stale?) group or request id" << llendl;
+		LL_WARNS() << "processGroupRoleMembersReply: Received incorrect (stale?) group or request id" << LL_ENDL;
 		return;
 	}
 
@@ -1183,14 +1183,14 @@ void LLGroupMgr::processGroupRoleMembersReply(LLMessageSystem* msg, void** data)
 
 				if (rd && md)
 				{
-					lldebugs << "Adding role-member pair: " << role_id << ", " << member_id << llendl;
+					LL_DEBUGS() << "Adding role-member pair: " << role_id << ", " << member_id << LL_ENDL;
 					rd->addMember(member_id);
 					md->addRole(role_id,rd);
 				}
 				else
 				{
-					if (!rd) llwarns << "Received role data for unknown role " << role_id << " in group " << group_id << llendl;
-					if (!md) llwarns << "Received role data for unknown member " << member_id << " in group " << group_id << llendl;
+					if (!rd) LL_WARNS() << "Received role data for unknown role " << role_id << " in group " << group_id << LL_ENDL;
+					if (!md) LL_WARNS() << "Received role data for unknown member " << member_id << " in group " << group_id << LL_ENDL;
 				}
 			}
 		}
@@ -1204,7 +1204,7 @@ void LLGroupMgr::processGroupRoleMembersReply(LLMessageSystem* msg, void** data)
 		LLGroupRoleData* everyone = group_datap->mRoles[LLUUID::null];
 		if (!everyone)
 		{
-			llwarns << "Everyone role not found!" << llendl;
+			LL_WARNS() << "Everyone role not found!" << LL_ENDL;
 		}
 		else
 		{
@@ -1230,12 +1230,12 @@ void LLGroupMgr::processGroupRoleMembersReply(LLMessageSystem* msg, void** data)
 // static
 void LLGroupMgr::processGroupTitlesReply(LLMessageSystem* msg, void** data)
 {
-	lldebugs << "LLGroupMgr::processGroupTitlesReply" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::processGroupTitlesReply" << LL_ENDL;
 	LLUUID agent_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group properties reply for another agent!" << llendl;
+		LL_WARNS() << "Got group properties reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -1247,7 +1247,7 @@ void LLGroupMgr::processGroupTitlesReply(LLMessageSystem* msg, void** data)
 	LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id);
 	if (!group_datap || (group_datap->mTitlesRequestID != request_id))
 	{
-		llwarns << "processGroupTitlesReply: Received incorrect (stale?) group" << llendl;
+		LL_WARNS() << "processGroupTitlesReply: Received incorrect (stale?) group" << LL_ENDL;
 		return;
 	}
 
@@ -1263,7 +1263,7 @@ void LLGroupMgr::processGroupTitlesReply(LLMessageSystem* msg, void** data)
 
 		if (!title.mTitle.empty())
 		{
-			lldebugs << "LLGroupMgr adding title: " << title.mTitle << ", " << title.mRoleID << ", " << (title.mSelected ? 'Y' : 'N') << llendl;
+			LL_DEBUGS() << "LLGroupMgr adding title: " << title.mTitle << ", " << title.mRoleID << ", " << (title.mSelected ? 'Y' : 'N') << LL_ENDL;
 			group_datap->mTitles.push_back(title);
 		}
 	}
@@ -1275,7 +1275,7 @@ void LLGroupMgr::processGroupTitlesReply(LLMessageSystem* msg, void** data)
 // static
 void LLGroupMgr::processEjectGroupMemberReply(LLMessageSystem* msg, void ** data)
 {
-	lldebugs << "processEjectGroupMemberReply" << llendl;
+	LL_DEBUGS() << "processEjectGroupMemberReply" << LL_ENDL;
 	LLUUID group_id;
 	msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_GroupID, group_id);
 	BOOL success;
@@ -1291,7 +1291,7 @@ void LLGroupMgr::processEjectGroupMemberReply(LLMessageSystem* msg, void ** data
 // static
 void LLGroupMgr::processJoinGroupReply(LLMessageSystem* msg, void ** data)
 {
-	lldebugs << "processJoinGroupReply" << llendl;
+	LL_DEBUGS() << "processJoinGroupReply" << LL_ENDL;
 	LLUUID group_id;
 	BOOL success;
 	msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_GroupID, group_id);
@@ -1311,7 +1311,7 @@ void LLGroupMgr::processJoinGroupReply(LLMessageSystem* msg, void ** data)
 // static
 void LLGroupMgr::processLeaveGroupReply(LLMessageSystem* msg, void ** data)
 {
-	lldebugs << "processLeaveGroupReply" << llendl;
+	LL_DEBUGS() << "processLeaveGroupReply" << LL_ENDL;
 	LLUUID group_id;
 	BOOL success;
 	msg->getUUIDFast(_PREHASH_GroupData, _PREHASH_GroupID, group_id);
@@ -1473,7 +1473,7 @@ void LLGroupMgr::addGroup(LLGroupMgrGroupData* group_datap)
 
 void LLGroupMgr::sendGroupPropertiesRequest(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupPropertiesRequest" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupPropertiesRequest" << LL_ENDL;
 	// This will happen when we get the reply
 	//LLGroupMgrGroupData* group_datap = createGroupData(group_id);
 	
@@ -1489,7 +1489,7 @@ void LLGroupMgr::sendGroupPropertiesRequest(const LLUUID& group_id)
 
 void LLGroupMgr::sendGroupMembersRequest(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupMembersRequest" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupMembersRequest" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = createGroupData(group_id);
 	if (group_datap->mMemberRequestID.isNull())
 	{
@@ -1511,7 +1511,7 @@ void LLGroupMgr::sendGroupMembersRequest(const LLUUID& group_id)
 
 void LLGroupMgr::sendGroupRoleDataRequest(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupRoleDataRequest" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupRoleDataRequest" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = createGroupData(group_id);
 	if (group_datap->mRoleDataRequestID.isNull())
 	{
@@ -1532,7 +1532,7 @@ void LLGroupMgr::sendGroupRoleDataRequest(const LLUUID& group_id)
 
 void LLGroupMgr::sendGroupRoleMembersRequest(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupRoleMembersRequest" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupRoleMembersRequest" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = createGroupData(group_id);
 	
 	if (group_datap->mRoleMembersRequestID.isNull())
@@ -1542,9 +1542,9 @@ void LLGroupMgr::sendGroupRoleMembersRequest(const LLUUID& group_id)
 			|| !group_datap->isRoleDataComplete())
 		{
 			// *TODO: KLW FIXME: Should we start a member or role data request?
-			llinfos << " Pending: " << (group_datap->mPendingRoleMemberRequest ? "Y" : "N")
+			LL_INFOS() << " Pending: " << (group_datap->mPendingRoleMemberRequest ? "Y" : "N")
 				<< " MemberDataComplete: " << (group_datap->mMemberDataComplete ? "Y" : "N")
-				<< " RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << llendl;
+				<< " RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << LL_ENDL;
 			group_datap->mPendingRoleMemberRequest = TRUE;
 			return;
 		}
@@ -1566,7 +1566,7 @@ void LLGroupMgr::sendGroupRoleMembersRequest(const LLUUID& group_id)
 
 void LLGroupMgr::sendGroupTitlesRequest(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupTitlesRequest" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupTitlesRequest" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = createGroupData(group_id);
 	
 	group_datap->mTitles.clear();
@@ -1585,7 +1585,7 @@ void LLGroupMgr::sendGroupTitlesRequest(const LLUUID& group_id)
 
 void LLGroupMgr::sendGroupTitleUpdate(const LLUUID& group_id, const LLUUID& title_role_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupTitleUpdate" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupTitleUpdate" << LL_ENDL;
 
 	LLMessageSystem* msg = gMessageSystem;
 	msg->newMessage("GroupTitleUpdate");
@@ -1644,7 +1644,7 @@ void LLGroupMgr::sendCreateGroupRequest(const std::string& name,
 
 void LLGroupMgr::sendUpdateGroupInfo(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendUpdateGroupInfo" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendUpdateGroupInfo" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = createGroupData(group_id);
 
 	LLMessageSystem* msg = gMessageSystem;
@@ -1673,7 +1673,7 @@ void LLGroupMgr::sendUpdateGroupInfo(const LLUUID& group_id)
 
 void LLGroupMgr::sendGroupRoleMemberChanges(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupRoleMemberChanges" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupRoleMemberChanges" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = createGroupData(group_id);
 
 	if (group_datap->mRoleMemberChanges.empty()) return;
@@ -2027,7 +2027,7 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content)
 
 void LLGroupMgr::sendGroupRoleChanges(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::sendGroupRoleChanges" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::sendGroupRoleChanges" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = getGroupData(group_id);
 
 	if (group_datap && group_datap->pendingRoleChanges())
@@ -2042,7 +2042,7 @@ void LLGroupMgr::sendGroupRoleChanges(const LLUUID& group_id)
 
 void LLGroupMgr::cancelGroupRoleChanges(const LLUUID& group_id)
 {
-	lldebugs << "LLGroupMgr::cancelGroupRoleChanges" << llendl;
+	LL_DEBUGS() << "LLGroupMgr::cancelGroupRoleChanges" << LL_ENDL;
 	LLGroupMgrGroupData* group_datap = getGroupData(group_id);
 
 	if (group_datap) group_datap->cancelRoleChanges();
@@ -2057,7 +2057,7 @@ bool LLGroupMgr::parseRoleActions(const std::string& xml_filename)
 	
 	if (!success || !root || !root->hasName( "role_actions" ))
 	{
-		llerrs << "Problem reading UI role_actions file: " << xml_filename << llendl;
+		LL_ERRS() << "Problem reading UI role_actions file: " << xml_filename << LL_ENDL;
 		return false;
 	}
 
@@ -2076,12 +2076,12 @@ bool LLGroupMgr::parseRoleActions(const std::string& xml_filename)
 		std::string action_set_name;
 		if (action_set->getAttributeString("name", action_set_name))
 		{
-			lldebugs << "Loading action set " << action_set_name << llendl;
+			LL_DEBUGS() << "Loading action set " << action_set_name << LL_ENDL;
 			role_action_data->mName = action_set_name;
 		}
 		else
 		{
-			llwarns << "Unable to parse action set with no name" << llendl;
+			LL_WARNS() << "Unable to parse action set with no name" << LL_ENDL;
 			delete role_action_set;
 			delete role_action_data;
 			continue;
@@ -2117,12 +2117,12 @@ bool LLGroupMgr::parseRoleActions(const std::string& xml_filename)
 			std::string action_name;
 			if (action->getAttributeString("name", action_name))
 			{
-				lldebugs << "Loading action " << action_name << llendl;
+				LL_DEBUGS() << "Loading action " << action_name << LL_ENDL;
 				role_action->mName = action_name;
 			}
 			else
 			{
-				llwarns << "Unable to parse action with no name" << llendl;
+				LL_WARNS() << "Unable to parse action with no name" << LL_ENDL;
 				delete role_action;
 				continue;
 			}
diff --git a/indra/newview/llhomelocationresponder.cpp b/indra/newview/llhomelocationresponder.cpp
index 37428c4a44..eefa8bd42a 100755
--- a/indra/newview/llhomelocationresponder.cpp
+++ b/indra/newview/llhomelocationresponder.cpp
@@ -90,7 +90,7 @@ void LLHomeLocationResponder::result( const LLSD& content )
 	
   if( ! error )
   {
-    llinfos << "setting home position" << llendl;
+    LL_INFOS() << "setting home position" << LL_ENDL;
 		
     LLViewerRegion *viewer_region = gAgent.getRegion();
     gAgent.setHomePosRegion( viewer_region->getHandle(), agent_pos );
@@ -99,5 +99,5 @@ void LLHomeLocationResponder::result( const LLSD& content )
 
 void LLHomeLocationResponder::errorWithContent( U32 status, const std::string& reason, const LLSD& content )
 {
-	llwarns << "LLHomeLocationResponder error [status:" << status << "]: " << content << llendl;
+	LL_WARNS() << "LLHomeLocationResponder error [status:" << status << "]: " << content << LL_ENDL;
 }
diff --git a/indra/newview/llhudeffect.cpp b/indra/newview/llhudeffect.cpp
index 159ec6c803..eff5587610 100755
--- a/indra/newview/llhudeffect.cpp
+++ b/indra/newview/llhudeffect.cpp
@@ -71,7 +71,7 @@ void LLHUDEffect::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 
 void LLHUDEffect::render()
 {
-	llerrs << "Never call this!" << llendl;
+	LL_ERRS() << "Never call this!" << LL_ENDL;
 }
 
 void LLHUDEffect::setID(const LLUUID &id)
diff --git a/indra/newview/llhudeffectbeam.cpp b/indra/newview/llhudeffectbeam.cpp
index 8abad3d292..54e683e048 100755
--- a/indra/newview/llhudeffectbeam.cpp
+++ b/indra/newview/llhudeffectbeam.cpp
@@ -78,7 +78,7 @@ void LLHUDEffectBeam::packData(LLMessageSystem *mesgsys)
 {
 	if (!mSourceObject)
 	{
-		llwarns << "Missing source object!" << llendl;
+		LL_WARNS() << "Missing source object!" << LL_ENDL;
 	}
 
 	// Pack the default data
@@ -115,7 +115,7 @@ void LLHUDEffectBeam::packData(LLMessageSystem *mesgsys)
 
 void LLHUDEffectBeam::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 {
-	llerrs << "Got beam!" << llendl;
+	LL_ERRS() << "Got beam!" << LL_ENDL;
 	BOOL use_target_object;
 	LLVector3d new_target;
 	U8 packed_data[41];
@@ -126,7 +126,7 @@ void LLHUDEffectBeam::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
 	if (size != 41)
 	{
-		llwarns << "Beam effect with bad size " << size << llendl;
+		LL_WARNS() << "Beam effect with bad size " << size << LL_ENDL;
 		return;
 	}
 	mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, 41, blocknum);
@@ -172,7 +172,7 @@ void LLHUDEffectBeam::setSourceObject(LLViewerObject *objp)
 {
 	if (objp->isDead())
 	{
-		llwarns << "HUDEffectBeam: Source object is dead!" << llendl;
+		LL_WARNS() << "HUDEffectBeam: Source object is dead!" << LL_ENDL;
 		mSourceObject = NULL;
 		return;
 	}
@@ -210,7 +210,7 @@ void LLHUDEffectBeam::setTargetObject(LLViewerObject *objp)
 {
 	if (mTargetObject->isDead())
 	{
-		llwarns << "HUDEffectBeam: Target object is dead!" << llendl;
+		LL_WARNS() << "HUDEffectBeam: Target object is dead!" << LL_ENDL;
 	}
 
 	mTargetObject = objp;
diff --git a/indra/newview/llhudeffectlookat.cpp b/indra/newview/llhudeffectlookat.cpp
index 9dde65ceb6..f3a48625a4 100755
--- a/indra/newview/llhudeffectlookat.cpp
+++ b/indra/newview/llhudeffectlookat.cpp
@@ -204,7 +204,7 @@ static BOOL loadAttentions()
 	//-------------------------------------------------------------------------
 	if( !root->hasName( "linden_attentions" ) )
 	{
-		llwarns << "Invalid linden_attentions file header: " << filename << llendl;
+		LL_WARNS() << "Invalid linden_attentions file header: " << filename << LL_ENDL;
 		return FALSE;
 	}
 
@@ -212,7 +212,7 @@ static BOOL loadAttentions()
 	static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version");
 	if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") )
 	{
-		llwarns << "Invalid linden_attentions file version: " << version << llendl;
+		LL_WARNS() << "Invalid linden_attentions file version: " << version << LL_ENDL;
 		return FALSE;
 	}
 
@@ -322,7 +322,7 @@ void LLHUDEffectLookAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
 	if (size != PKT_SIZE)
 	{
-		llwarns << "LookAt effect with bad size " << size << llendl;
+		LL_WARNS() << "LookAt effect with bad size " << size << LL_ENDL;
 		return;
 	}
 	mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, PKT_SIZE, blocknum);
@@ -336,7 +336,7 @@ void LLHUDEffectLookAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	}
 	else
 	{
-		//llwarns << "Could not find source avatar for lookat effect" << llendl;
+		//LL_WARNS() << "Could not find source avatar for lookat effect" << LL_ENDL;
 		return;
 	}
 
@@ -356,7 +356,7 @@ void LLHUDEffectLookAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	}
 	else
 	{
-		//llwarns << "Could not find target object for lookat effect" << llendl;
+		//LL_WARNS() << "Could not find target object for lookat effect" << LL_ENDL;
 	}
 
 	U8 lookAtTypeUnpacked = 0;
@@ -400,7 +400,7 @@ BOOL LLHUDEffectLookAt::setLookAt(ELookAtType target_type, LLViewerObject *objec
 	
 	if (target_type >= LOOKAT_NUM_TARGETS)
 	{
-		llwarns << "Bad target_type " << (int)target_type << " - ignoring." << llendl;
+		LL_WARNS() << "Bad target_type " << (int)target_type << " - ignoring." << LL_ENDL;
 		return FALSE;
 	}
 
diff --git a/indra/newview/llhudeffectpointat.cpp b/indra/newview/llhudeffectpointat.cpp
index 114a633821..44c8db19c0 100755
--- a/indra/newview/llhudeffectpointat.cpp
+++ b/indra/newview/llhudeffectpointat.cpp
@@ -159,7 +159,7 @@ void LLHUDEffectPointAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
 	if (size != PKT_SIZE)
 	{
-		llwarns << "PointAt effect with bad size " << size << llendl;
+		LL_WARNS() << "PointAt effect with bad size " << size << LL_ENDL;
 		return;
 	}
 	mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, PKT_SIZE, blocknum);
@@ -176,7 +176,7 @@ void LLHUDEffectPointAt::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	}
 	else
 	{
-		//llwarns << "Could not find source avatar for pointat effect" << llendl;
+		//LL_WARNS() << "Could not find source avatar for pointat effect" << LL_ENDL;
 		return;
 	}
 
@@ -228,7 +228,7 @@ BOOL LLHUDEffectPointAt::setPointAt(EPointAtType target_type, LLViewerObject *ob
 	
 	if (target_type >= POINTAT_NUM_TARGETS)
 	{
-		llwarns << "Bad target_type " << (int)target_type << " - ignoring." << llendl;
+		LL_WARNS() << "Bad target_type " << (int)target_type << " - ignoring." << LL_ENDL;
 		return FALSE;
 	}
 
@@ -252,7 +252,7 @@ BOOL LLHUDEffectPointAt::setPointAt(EPointAtType target_type, LLViewerObject *ob
 		mLastSentOffsetGlobal = position;
 		setDuration(POINTAT_TIMEOUTS[target_type]);
 		setNeedsSendToSim(TRUE);
-//		llinfos << "Sending pointat data" << llendl;
+//		LL_INFOS() << "Sending pointat data" << LL_ENDL;
 	}
 
 	if (target_type == POINTAT_TARGET_CLEAR)
diff --git a/indra/newview/llhudeffecttrail.cpp b/indra/newview/llhudeffecttrail.cpp
index 39b526c1b5..8771219034 100755
--- a/indra/newview/llhudeffecttrail.cpp
+++ b/indra/newview/llhudeffecttrail.cpp
@@ -85,7 +85,7 @@ void LLHUDEffectSpiral::packData(LLMessageSystem *mesgsys)
 {
 	if (!mSourceObject)
 	{
-		//llwarns << "Missing object in trail pack!" << llendl;
+		//LL_WARNS() << "Missing object in trail pack!" << LL_ENDL;
 	}
 	LLHUDEffect::packData(mesgsys);
 
@@ -117,7 +117,7 @@ void LLHUDEffectSpiral::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	size_t size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
 	if (size != EFFECT_SIZE)
 	{
-		llwarns << "Spiral effect with bad size " << size << llendl;
+		LL_WARNS() << "Spiral effect with bad size " << size << LL_ENDL;
 		return;
 	}
 	mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, 
diff --git a/indra/newview/llhudmanager.cpp b/indra/newview/llhudmanager.cpp
index 8ad432fbad..fd28fdeab9 100755
--- a/indra/newview/llhudmanager.cpp
+++ b/indra/newview/llhudmanager.cpp
@@ -79,12 +79,12 @@ void LLHUDManager::sendEffects()
 		LLHUDEffect *hep = mHUDEffects[i];
 		if (hep->isDead())
 		{
-			llwarns << "Trying to send dead effect!" << llendl;
+			LL_WARNS() << "Trying to send dead effect!" << LL_ENDL;
 			continue;
 		}
 		if (hep->mType < LLHUDObject::LL_HUD_EFFECT_BEAM)
 		{
-			llwarns << "Trying to send effect of type " << hep->mType << " which isn't really an effect and shouldn't be in this list!" << llendl;
+			LL_WARNS() << "Trying to send effect of type " << hep->mType << " which isn't really an effect and shouldn't be in this list!" << LL_ENDL;
 			continue;
 		}
 		if (hep->getNeedsSendToSim() && hep->getOriginatedHere())
@@ -164,14 +164,14 @@ void LLHUDManager::processViewerEffect(LLMessageSystem *mesgsys, void **user_dat
 			LLHUDEffect *cur_effectp = LLHUDManager::getInstance()->mHUDEffects[i];
 			if (!cur_effectp)
 			{
-				llwarns << "Null effect in effect manager, skipping" << llendl;
+				LL_WARNS() << "Null effect in effect manager, skipping" << LL_ENDL;
 				LLHUDManager::getInstance()->mHUDEffects.erase(LLHUDManager::getInstance()->mHUDEffects.begin() + i);
 				i--;
 				continue;
 			}
 			if (cur_effectp->isDead())
 			{
-	//			llwarns << "Dead effect in effect manager, removing" << llendl;
+	//			LL_WARNS() << "Dead effect in effect manager, removing" << LL_ENDL;
 				LLHUDManager::getInstance()->mHUDEffects.erase(LLHUDManager::getInstance()->mHUDEffects.begin() + i);
 				i--;
 				continue;
@@ -180,7 +180,7 @@ void LLHUDManager::processViewerEffect(LLMessageSystem *mesgsys, void **user_dat
 			{
 				if (cur_effectp->getType() != effect_type)
 				{
-					llwarns << "Viewer effect update doesn't match old type!" << llendl;
+					LL_WARNS() << "Viewer effect update doesn't match old type!" << LL_ENDL;
 				}
 				effectp = cur_effectp;
 				break;
@@ -201,10 +201,10 @@ void LLHUDManager::processViewerEffect(LLMessageSystem *mesgsys, void **user_dat
 		}
 		else
 		{
-			llwarns << "Received viewer effect of type " << effect_type << " which isn't really an effect!" << llendl;
+			LL_WARNS() << "Received viewer effect of type " << effect_type << " which isn't really an effect!" << LL_ENDL;
 		}
 	}
 
-	//llinfos << "Got viewer effect: " << effect_id << llendl;
+	//LL_INFOS() << "Got viewer effect: " << effect_id << LL_ENDL;
 }
 
diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp
index 19a4165b49..31d832e524 100755
--- a/indra/newview/llhudnametag.cpp
+++ b/indra/newview/llhudnametag.cpp
@@ -538,7 +538,7 @@ void LLHUDNameTag::updateVisibility()
 
 	if (!mSourceObject)
 	{
-		//llwarns << "LLHUDNameTag::updateScreenPos -- mSourceObject is NULL!" << llendl;
+		//LL_WARNS() << "LLHUDNameTag::updateScreenPos -- mSourceObject is NULL!" << LL_ENDL;
 		mVisible = TRUE;
 		sVisibleTextObjects.push_back(LLPointer<LLHUDNameTag> (this));
 		return;
diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp
index 95d57d08d8..165201c8a1 100755
--- a/indra/newview/llhudobject.cpp
+++ b/indra/newview/llhudobject.cpp
@@ -123,7 +123,7 @@ void LLHUDObject::cleanupHUDObjects()
 		(*object_it)->markDead();
 		if ((*object_it)->getNumRefs() > 1)
 		{
-			llinfos << "LLHUDObject " << (LLHUDObject *)(*object_it) << " type " << (S32)(*object_it)->getType() << " has " << (*object_it)->getNumRefs() << " refs!" << llendl;			
+			LL_INFOS() << "LLHUDObject " << (LLHUDObject *)(*object_it) << " type " << (S32)(*object_it)->getType() << " has " << (*object_it)->getNumRefs() << " refs!" << LL_ENDL;			
 		}
 	}
 	sHUDObjects.clear();
@@ -146,7 +146,7 @@ LLHUDObject *LLHUDObject::addHUDObject(const U8 type)
 		hud_objectp = new LLHUDNameTag(type);
 		break;
 	default:
-		llwarns << "Unknown type of hud object:" << (U32) type << llendl;
+		LL_WARNS() << "Unknown type of hud object:" << (U32) type << LL_ENDL;
 	}
 	if (hud_objectp)
 	{
@@ -242,7 +242,7 @@ LLHUDEffect *LLHUDObject::addHUDEffect(const U8 type)
 		hud_objectp = new LLHUDEffectBlob(type);
 		break;
 	default:
-		llwarns << "Unknown type of hud effect:" << (U32) type << llendl;
+		LL_WARNS() << "Unknown type of hud effect:" << (U32) type << LL_ENDL;
 	}
 
 	if (hud_objectp)
diff --git a/indra/newview/llhudtext.cpp b/indra/newview/llhudtext.cpp
index 3c6bcd9829..f648d7baae 100755
--- a/indra/newview/llhudtext.cpp
+++ b/indra/newview/llhudtext.cpp
@@ -346,7 +346,7 @@ void LLHUDText::updateVisibility()
 
 	if (!mSourceObject)
 	{
-		//llwarns << "LLHUDText::updateScreenPos -- mSourceObject is NULL!" << llendl;
+		//LL_WARNS() << "LLHUDText::updateScreenPos -- mSourceObject is NULL!" << LL_ENDL;
 		mVisible = TRUE;
 		if (mOnHUDAttachment)
 		{
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 89ea5ff73a..236dc47169 100755
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -848,13 +848,13 @@ bool LLIMModel::newSession(const LLUUID& session_id, const std::string& name, co
 {
 	if (name.empty())
 	{
-		llwarns << "Attempt to create a new session with empty name; id = " << session_id << llendl;
+		LL_WARNS() << "Attempt to create a new session with empty name; id = " << session_id << LL_ENDL;
 		return false;
 	}
 
 	if (findIMSession(session_id))
 	{
-		llwarns << "IM Session " << session_id << " already exists" << llendl;
+		LL_WARNS() << "IM Session " << session_id << " already exists" << LL_ENDL;
 		return false;
 	}
 
@@ -900,7 +900,7 @@ void LLIMModel::getMessagesSilently(const LLUUID& session_id, std::list<LLSD>& m
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return;
 	}
 
@@ -922,7 +922,7 @@ void LLIMModel::sendNoUnreadMessages(const LLUUID& session_id)
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return;
 	}
 
@@ -942,7 +942,7 @@ bool LLIMModel::addToHistory(const LLUUID& session_id, const std::string& from,
 
 	if (!session) 
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return false;
 	}
 
@@ -1017,7 +1017,7 @@ LLIMModel::LLIMSession* LLIMModel::addMessageSilently(const LLUUID& session_id,
 
 	if (!session)
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return NULL;
 	}
 
@@ -1054,7 +1054,7 @@ const std::string LLIMModel::getName(const LLUUID& session_id) const
 
 	if (!session)
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return LLTrans::getString("no_session_message");
 	}
 
@@ -1066,7 +1066,7 @@ const S32 LLIMModel::getNumUnread(const LLUUID& session_id) const
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return -1;
 	}
 
@@ -1078,7 +1078,7 @@ const LLUUID& LLIMModel::getOtherParticipantID(const LLUUID& session_id) const
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << " does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << " does not exist " << LL_ENDL;
 		return LLUUID::null;
 	}
 
@@ -1090,7 +1090,7 @@ EInstantMessage LLIMModel::getType(const LLUUID& session_id) const
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return IM_COUNT;
 	}
 
@@ -1102,7 +1102,7 @@ LLVoiceChannel* LLIMModel::getVoiceChannel( const LLUUID& session_id ) const
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << "does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << "does not exist " << LL_ENDL;
 		return NULL;
 	}
 
@@ -1114,7 +1114,7 @@ LLIMSpeakerMgr* LLIMModel::getSpeakerManager( const LLUUID& session_id ) const
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << " does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << " does not exist " << LL_ENDL;
 		return NULL;
 	}
 
@@ -1126,7 +1126,7 @@ const std::string& LLIMModel::getHistoryFileName(const LLUUID& session_id) const
 	LLIMSession* session = findIMSession(session_id);
 	if (!session)
 	{
-		llwarns << "session " << session_id << " does not exist " << llendl;
+		LL_WARNS() << "session " << session_id << " does not exist " << LL_ENDL;
 		return LLStringUtil::null;
 	}
 
@@ -1413,8 +1413,8 @@ public:
 				mAgents);
 		}
 
-		llwarns << "LLStartConferenceChatResponder error [status:"
-				<< statusNum << "]: " << content << llendl;
+		LL_WARNS() << "LLStartConferenceChatResponder error [status:"
+				<< statusNum << "]: " << content << LL_ENDL;
 
 		//else throw an error back to the client?
 		//in theory we should have just have these error strings
@@ -1563,8 +1563,8 @@ public:
 
 	void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "LLViewerChatterBoxInvitationAcceptResponder error [status:"
-				<< statusNum << "]: " << content << llendl;
+		LL_WARNS() << "LLViewerChatterBoxInvitationAcceptResponder error [status:"
+				<< statusNum << "]: " << content << LL_ENDL;
 		//throw something back to the viewer here?
 		if ( gIMMgr )
 		{
@@ -1626,7 +1626,7 @@ LLUUID LLIMMgr::computeSessionID(
 
 	if (gAgent.isInGroup(session_id) && (session_id != other_participant_id))
 	{
-		llwarns << "Group session id different from group id: IM type = " << dialog << ", session id = " << session_id << ", group id = " << other_participant_id << llendl;
+		LL_WARNS() << "Group session id different from group id: IM type = " << dialog << ", session id = " << session_id << ", group id = " << other_participant_id << LL_ENDL;
 	}
 	return session_id;
 }
@@ -2372,7 +2372,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload
 			std::string correct_session_name = session_name;
 			if (session_name.empty())
 			{
-				llwarns << "Received an empty session name from a server" << llendl;
+				LL_WARNS() << "Received an empty session name from a server" << LL_ENDL;
 				
 				switch(type){
 				case IM_SESSION_CONFERENCE_START:
@@ -2394,7 +2394,7 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload
 							correct_session_name.append(ADHOC_NAME_SUFFIX); 
 						}
 					}
-					llinfos << "Corrected session name is " << correct_session_name << llendl; 
+					LL_INFOS() << "Corrected session name is " << correct_session_name << LL_ENDL; 
 					break;
 				default: 
 					LL_WARNS() << "Received an empty session name from a server and failed to generate a new proper session name" << LL_ENDL;
@@ -2634,10 +2634,10 @@ void LLIMMgr::addMessage(
 		// code, but the session has to be established inside the server before it can be left.
 		if (LLMuteList::getInstance()->isMuted(other_participant_id) && !LLMuteList::getInstance()->isLinden(from))
 		{
-			llwarns << "Leaving IM session from initiating muted resident " << from << llendl;
+			LL_WARNS() << "Leaving IM session from initiating muted resident " << from << LL_ENDL;
 			if(!gIMMgr->leaveSession(new_session_id))
 			{
-				llinfos << "Session " << new_session_id << " does not exist." << llendl;
+				LL_INFOS() << "Session " << new_session_id << " does not exist." << LL_ENDL;
 			}
 			return;
 		}
@@ -2852,7 +2852,7 @@ LLUUID LLIMMgr::addSession(
 	//we don't need to show notes about online/offline, mute/unmute users' statuses for existing sessions
 	if (!new_session) return session_id;
 	
-    llinfos << "LLIMMgr::addSession, new session added, name = " << name << ", session id = " << session_id << llendl;
+    LL_INFOS() << "LLIMMgr::addSession, new session added, name = " << name << ", session id = " << session_id << LL_ENDL;
     
 	//Per Plan's suggestion commented "explicit offline status warning" out to make Dessie happier (see EXT-3609)
 	//*TODO After February 2010 remove this commented out line if no one will be missing that warning
@@ -2889,7 +2889,7 @@ void LLIMMgr::removeSession(const LLUUID& session_id)
 
 	LLIMModel::getInstance()->clearSession(session_id);
 
-    llinfos << "LLIMMgr::removeSession, session removed, session id = " << session_id << llendl;
+    LL_INFOS() << "LLIMMgr::removeSession, session removed, session id = " << session_id << LL_ENDL;
 
 	notifyObserverSessionRemoved(session_id);
 }
@@ -2954,7 +2954,7 @@ void LLIMMgr::inviteToSession(
 	{
 		if (voice_invite && "VoiceInviteQuestionDefault" == question_type)
 		{
-			llinfos << "Rejecting voice call from initiating muted resident " << caller_name << llendl;
+			LL_INFOS() << "Rejecting voice call from initiating muted resident " << caller_name << LL_ENDL;
 			LLIncomingCallDialog::processCallResponse(1, payload);
 		}
 		return;
diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp
index 9c6db3676f..b75140238e 100755
--- a/indra/newview/llinspectavatar.cpp
+++ b/indra/newview/llinspectavatar.cpp
@@ -295,7 +295,7 @@ void LLInspectAvatar::processAvatarData(LLAvatarData* data)
 /*
 prep#
 			virtual void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
-				llwarns << "MuteVoiceResponder error [status:" << status << "]: " << content << llendl;
+				LL_WARNS() << "MuteVoiceResponder error [status:" << status << "]: " << content << LL_ENDL;
 	*/
 
 void LLInspectAvatar::updateVolumeSlider()
diff --git a/indra/newview/llinspecttoast.cpp b/indra/newview/llinspecttoast.cpp
index f4fe5dec01..0bc7bd188d 100755
--- a/indra/newview/llinspecttoast.cpp
+++ b/indra/newview/llinspecttoast.cpp
@@ -63,7 +63,7 @@ LLInspectToast::LLInspectToast(const LLSD& notification_id) :
 	mScreenChannel = dynamic_cast<LLScreenChannel*>(channel);
 	if(NULL == mScreenChannel)
 	{
-		llwarns << "Could not get requested screen channel." << llendl;
+		LL_WARNS() << "Could not get requested screen channel." << LL_ENDL;
 		return;
 	}
 
@@ -83,7 +83,7 @@ void LLInspectToast::onOpen(const LLSD& notification_id)
 	LLToast* toast = mScreenChannel->getToastByNotificationID(notification_id);
 	if (toast == NULL)
 	{
-		llwarns << "Could not get requested toast  from screen channel." << llendl;
+		LL_WARNS() << "Could not get requested toast  from screen channel." << LL_ENDL;
 		return;
 	}
 	mConnection = toast->setOnToastDestroyedCallback(boost::bind(&LLInspectToast::onToastDestroy, this, _1));
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 6915ba4557..8809530ad8 100755
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -733,7 +733,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id,
 
 void LLInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-	lldebugs << "LLInvFVBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLInvFVBridge::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 	if(isItemInTrash())
@@ -1032,7 +1032,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_TEXTURE:
 			if(!(inv_type == LLInventoryType::IT_TEXTURE || inv_type == LLInventoryType::IT_SNAPSHOT))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLTextureBridge(inventory, root, uuid, inv_type);
 			break;
@@ -1040,7 +1040,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_SOUND:
 			if(!(inv_type == LLInventoryType::IT_SOUND))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLSoundBridge(inventory, root, uuid);
 			break;
@@ -1048,7 +1048,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_LANDMARK:
 			if(!(inv_type == LLInventoryType::IT_LANDMARK))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLLandmarkBridge(inventory, root, uuid, flags);
 			break;
@@ -1056,7 +1056,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_CALLINGCARD:
 			if(!(inv_type == LLInventoryType::IT_CALLINGCARD))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLCallingCardBridge(inventory, root, uuid);
 			break;
@@ -1064,7 +1064,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_SCRIPT:
 			if(!(inv_type == LLInventoryType::IT_LSL))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLItemBridge(inventory, root, uuid);
 			break;
@@ -1072,7 +1072,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_OBJECT:
 			if(!(inv_type == LLInventoryType::IT_OBJECT || inv_type == LLInventoryType::IT_ATTACHMENT))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLObjectBridge(inventory, root, uuid, inv_type, flags);
 			break;
@@ -1080,7 +1080,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_NOTECARD:
 			if(!(inv_type == LLInventoryType::IT_NOTECARD))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLNotecardBridge(inventory, root, uuid);
 			break;
@@ -1088,7 +1088,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_ANIMATION:
 			if(!(inv_type == LLInventoryType::IT_ANIMATION))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLAnimationBridge(inventory, root, uuid);
 			break;
@@ -1096,7 +1096,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_GESTURE:
 			if(!(inv_type == LLInventoryType::IT_GESTURE))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLGestureBridge(inventory, root, uuid);
 			break;
@@ -1104,7 +1104,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_LSL_TEXT:
 			if(!(inv_type == LLInventoryType::IT_LSL))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLLSLTextBridge(inventory, root, uuid);
 			break;
@@ -1113,7 +1113,7 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 		case LLAssetType::AT_BODYPART:
 			if(!(inv_type == LLInventoryType::IT_WEARABLE))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLWearableBridge(inventory, root, uuid, asset_type, inv_type, (LLWearableType::EType)flags);
 			break;
@@ -1134,19 +1134,19 @@ LLInvFVBridge* LLInvFVBridge::createBridge(LLAssetType::EType asset_type,
 	    case LLAssetType::AT_MESH:
 			if(!(inv_type == LLInventoryType::IT_MESH))
 			{
-				llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+				LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 			}
 			new_listener = new LLMeshBridge(inventory, root, uuid);
 			break;
 
 		case LLAssetType::AT_IMAGE_TGA:
 		case LLAssetType::AT_IMAGE_JPEG:
-			//llwarns << LLAssetType::lookup(asset_type) << " asset type is unhandled for uuid " << uuid << llendl;
+			//LL_WARNS() << LLAssetType::lookup(asset_type) << " asset type is unhandled for uuid " << uuid << LL_ENDL;
 			break;
 
 		default:
-			llinfos << "Unhandled asset type (llassetstorage.h): "
-					<< (S32)asset_type << " (" << LLAssetType::lookup(asset_type) << ")" << llendl;
+			LL_INFOS() << "Unhandled asset type (llassetstorage.h): "
+					<< (S32)asset_type << " (" << LLAssetType::lookup(asset_type) << ")" << LL_ENDL;
 			break;
 	}
 
@@ -1427,7 +1427,7 @@ void LLItemBridge::performAction(LLInventoryModel* model, std::string action)
 	}
 	else if (isMarketplaceCopyAction(action))
 	{
-		llinfos << "Copy item to marketplace action!" << llendl;
+		LL_INFOS() << "Copy item to marketplace action!" << LL_ENDL;
 
 		LLInventoryItem* itemp = model->getItem(mUUID);
 		if (!itemp) return;
@@ -1594,7 +1594,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const
 
 	if (get_is_item_worn(mUUID))
 	{
-		// llinfos << "BOLD" << llendl;
+		// LL_INFOS() << "BOLD" << LL_ENDL;
 		font |= LLFontGL::BOLD;
 	}
 	else if(item && item->getIsLinkType())
@@ -2195,7 +2195,7 @@ int get_folder_path_length(const LLUUID& ancestor_id, const LLUUID& descendant_i
 		category = gInventory.getCategory(parent_id);
 	}
 
-	llwarns << "get_folder_path_length() couldn't trace a path from the descendant to the ancestor" << llendl;
+	LL_WARNS() << "get_folder_path_length() couldn't trace a path from the descendant to the ancestor" << LL_ENDL;
 	return -1;
 }
 
@@ -2586,7 +2586,7 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id,
 	LLViewerObject* object = gObjectList.findObject(object_id);
 	if(!object)
 	{
-		llinfos << "Object not found for drop." << llendl;
+		LL_INFOS() << "Object not found for drop." << LL_ENDL;
 		return FALSE;
 	}
 
@@ -2597,7 +2597,7 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id,
 
 	if (inventory_objects.empty())
 	{
-		llinfos << "Object contents not found for drop." << llendl;
+		LL_INFOS() << "Object contents not found for drop." << LL_ENDL;
 		return FALSE;
 	}
 
@@ -2613,7 +2613,7 @@ BOOL move_inv_category_world_to_agent(const LLUUID& object_id,
 		LLInventoryItem* item = dynamic_cast<LLInventoryItem*>(it->get());
 		if (!item)
 		{
-			llwarns << "Invalid inventory item for drop" << llendl;
+			LL_WARNS() << "Invalid inventory item for drop" << LL_ENDL;
 			continue;
 		}
 
@@ -2681,7 +2681,7 @@ void LLRightClickInventoryFetchDescendentsObserver::execute(bool clear_observer)
 	// Bail out immediately if no descendents
 	if( mComplete.empty() )
 	{
-		llwarns << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << llendl;
+		LL_WARNS() << "LLRightClickInventoryFetchDescendentsObserver::done with empty mCompleteFolders" << LL_ENDL;
 		if (clear_observer)
 		{
 		gInventory.removeObserver(this);
@@ -2839,8 +2839,8 @@ void LLInventoryCopyAndWearObserver::changed(U32 mask)
 			LLViewerInventoryCategory* category = gInventory.getCategory(mCatID);
 			if (NULL == category)
 			{
-				llwarns << "gInventory.getCategory(" << mCatID
-						<< ") was NULL" << llendl;
+				LL_WARNS() << "gInventory.getCategory(" << mCatID
+						<< ") was NULL" << LL_ENDL;
 			}
 			else
 			{
@@ -2946,7 +2946,7 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
 #endif
 	else if (isMarketplaceCopyAction(action))
 	{
-		llinfos << "Copy folder to marketplace action!" << llendl;
+		LL_INFOS() << "Copy folder to marketplace action!" << LL_ENDL;
 
 		LLInventoryCategory * cat = gInventory.getCategory(mUUID);
 		if (!cat) return;
@@ -2957,7 +2957,7 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
 #if ENABLE_MERCHANT_SEND_TO_MARKETPLACE_CONTEXT_MENU
 	else if (isMarketplaceSendAction(action))
 	{
-		llinfos << "Send to marketplace action!" << llendl;
+		LL_INFOS() << "Send to marketplace action!" << LL_ENDL;
 
 		LLInventoryCategory * cat = gInventory.getCategory(mUUID);
 		if (!cat) return;
@@ -2969,7 +2969,7 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
 
 void LLFolderBridge::openItem()
 {
-	lldebugs << "LLFolderBridge::openItem()" << llendl;
+	LL_DEBUGS() << "LLFolderBridge::openItem()" << LL_ENDL;
 	LLInventoryModel* model = getInventoryModel();
 	if(!model) return;
 	if(mUUID.isNull()) return;
@@ -3604,7 +3604,7 @@ void LLFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 
-	lldebugs << "LLFolderBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLFolderBridge::buildContextMenu()" << LL_ENDL;
 
 	LLInventoryModel* model = getInventoryModel();
 	if(!model) return;
@@ -3633,7 +3633,7 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop,
 {
 	LLInventoryItem* inv_item = (LLInventoryItem*)cargo_data;
 
-	//llinfos << "LLFolderBridge::dragOrDrop()" << llendl;
+	//LL_INFOS() << "LLFolderBridge::dragOrDrop()" << LL_ENDL;
 	BOOL accept = FALSE;
 	switch(cargo_type)
 	{
@@ -3682,7 +3682,7 @@ BOOL LLFolderBridge::dragOrDrop(MASK mask, BOOL drop,
 		case DAD_NONE:
 			break;
 		default:
-			llwarns << "Unhandled cargo type for drag&drop " << cargo_type << llendl;
+			LL_WARNS() << "Unhandled cargo type for drag&drop " << cargo_type << LL_ENDL;
 			break;
 	}
 	return accept;
@@ -4152,7 +4152,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
 		object = gObjectList.findObject(inv_item->getParentUUID());
 		if (!object)
 		{
-			llinfos << "Object not found for drop." << llendl;
+			LL_INFOS() << "Object not found for drop." << LL_ENDL;
 			return FALSE;
 		}
 
@@ -4318,7 +4318,7 @@ BOOL LLFolderBridge::dragItemIntoFolder(LLInventoryItem* inv_item,
 	}
 	else
 	{
-		llwarns << "unhandled drag source" << llendl;
+		LL_WARNS() << "unhandled drag source" << LL_ENDL;
 	}
 	return accept;
 }
@@ -4423,7 +4423,7 @@ bool LLTextureBridge::canSaveTexture(void)
 
 void LLTextureBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-	lldebugs << "LLTextureBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLTextureBridge::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 	if(isItemInTrash())
@@ -4493,7 +4493,7 @@ void LLSoundBridge::openSoundPreview(void* which)
 
 void LLSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-	lldebugs << "LLSoundBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLSoundBridge::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 
@@ -4554,7 +4554,7 @@ void LLLandmarkBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 
-	lldebugs << "LLLandmarkBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLLandmarkBridge::buildContextMenu()" << LL_ENDL;
 	if(isOutboxFolder())
 	{
 		addOutboxContextMenuOptions(flags, items, disabled_items);
@@ -4786,7 +4786,7 @@ void LLCallingCardBridge::openItem()
 
 void LLCallingCardBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-	lldebugs << "LLCallingCardBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLCallingCardBridge::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 
@@ -5052,7 +5052,7 @@ BOOL LLGestureBridge::removeItem()
 
 void LLGestureBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-	lldebugs << "LLGestureBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLGestureBridge::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 	if(isItemInTrash())
@@ -5112,7 +5112,7 @@ void LLAnimationBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 
-	lldebugs << "LLAnimationBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLAnimationBridge::buildContextMenu()" << LL_ENDL;
 	if(isOutboxFolder())
 	{
 		items.push_back(std::string("Delete"));
@@ -5295,7 +5295,7 @@ void rez_attachment(LLViewerInventoryItem* item, LLViewerJointAttachment* attach
 		(gAgentAvatarp->attachmentWasRequested(item_id) ||
 		 gAgentAvatarp->isWearingAttachment(item_id)))
 	{
-		llwarns << "duplicate attachment request, ignoring" << llendl;
+		LL_WARNS() << "duplicate attachment request, ignoring" << LL_ENDL;
 		return;
 	}
 	gAgentAvatarp->addAttachmentRequest(item_id);
@@ -5607,7 +5607,7 @@ void LLWearableBridge::openItem()
 
 void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-	lldebugs << "LLWearableBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLWearableBridge::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 	if(isItemInTrash())
@@ -5771,7 +5771,7 @@ void LLWearableBridge::onWearOnAvatarArrived( LLViewerWearable* wearable, void*
 			}
 			else
 			{
-				llinfos << "By the time wearable asset arrived, its inv item already pointed to a different asset." << llendl;
+				LL_INFOS() << "By the time wearable asset arrived, its inv item already pointed to a different asset." << LL_ENDL;
 			}
 		}
 	}
@@ -5798,7 +5798,7 @@ void LLWearableBridge::onWearAddOnAvatarArrived( LLViewerWearable* wearable, voi
 			}
 			else
 			{
-				llinfos << "By the time wearable asset arrived, its inv item already pointed to a different asset." << llendl;
+				LL_INFOS() << "By the time wearable asset arrived, its inv item already pointed to a different asset." << LL_ENDL;
 			}
 		}
 	}
@@ -5842,7 +5842,7 @@ BOOL LLWearableBridge::canRemoveFromAvatar(void* user_data)
 
 void LLWearableBridge::removeFromAvatar()
 {
-	llwarns << "safe to remove?" << llendl;
+	LL_WARNS() << "safe to remove?" << LL_ENDL;
 	if (get_is_item_worn(mUUID))
 	{
 		LLAppearanceMgr::instance().removeItemFromAvatar(mUUID);
@@ -5860,7 +5860,7 @@ std::string LLLinkItemBridge::sPrefix("Link: ");
 void LLLinkItemBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
 	// *TODO: Translate
-	lldebugs << "LLLink::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLLink::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 
@@ -5900,7 +5900,7 @@ void LLMeshBridge::openItem()
 
 void LLMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
-	lldebugs << "LLMeshBridge::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLMeshBridge::buildContextMenu()" << LL_ENDL;
 	std::vector<std::string> items;
 	std::vector<std::string> disabled_items;
 
@@ -5957,7 +5957,7 @@ LLUIImagePtr LLLinkFolderBridge::getIcon() const
 void LLLinkFolderBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 {
 	// *TODO: Translate
-	lldebugs << "LLLink::buildContextMenu()" << llendl;
+	LL_DEBUGS() << "LLLink::buildContextMenu()" << LL_ENDL;
 	menuentry_vec_t items;
 	menuentry_vec_t disabled_items;
 
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index 92f2d33073..baf93a0469 100755
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -123,7 +123,7 @@ bool LLInventoryFilter::checkFolder(const LLFolderViewModelItem* item) const
 	const LLFolderViewModelItemInventory* listener = dynamic_cast<const LLFolderViewModelItemInventory*>(item);
 	if (!listener)
 	{
-		llerrs << "Folder view event listener not found." << llendl;
+		LL_ERRS() << "Folder view event listener not found." << LL_ENDL;
 		return false;
 	}
 
@@ -741,7 +741,7 @@ void LLInventoryFilter::setModified(EFilterModified behavior)
 			mFirstSuccessGeneration = mCurrentGeneration;
 			break;
 		default:
-			llerrs << "Bad filter behavior specified" << llendl;
+			LL_ERRS() << "Bad filter behavior specified" << LL_ENDL;
 	}
 }
 
@@ -1085,7 +1085,7 @@ bool LLInventoryFilter::FilterOps::DateRange::validateBlock( bool   emit_errors
 		{
 			if (emit_errors)
 			{
-				llwarns << "max_date should be greater or equal to min_date" <<   llendl;
+				LL_WARNS() << "max_date should be greater or equal to min_date" <<   LL_ENDL;
 			}
 			valid = false;
 		}
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp
index f1a4889f5a..f16b9330be 100755
--- a/indra/newview/llinventoryfunctions.cpp
+++ b/indra/newview/llinventoryfunctions.cpp
@@ -436,7 +436,7 @@ void show_item_original(const LLUUID& item_uuid)
 	LLFloater* floater_inventory = LLFloaterReg::getInstance("inventory");
 	if (!floater_inventory)
 	{
-		llwarns << "Could not find My Inventory floater" << llendl;
+		LL_WARNS() << "Could not find My Inventory floater" << LL_ENDL;
 		return;
 	}
 
@@ -928,7 +928,7 @@ bool LLFindNonRemovableObjects::operator()(LLInventoryCategory* cat, LLInventory
 		return !get_is_category_removable(&gInventory, cat->getUUID());
 	}
 
-	llwarns << "Not a category and not an item?" << llendl;
+	LL_WARNS() << "Not a category and not an item?" << LL_ENDL;
 	return false;
 }
 
diff --git a/indra/newview/llinventoryitemslist.cpp b/indra/newview/llinventoryitemslist.cpp
index 348d7ebcec..a84aa452dc 100755
--- a/indra/newview/llinventoryitemslist.cpp
+++ b/indra/newview/llinventoryitemslist.cpp
@@ -208,7 +208,7 @@ void LLInventoryItemsList::addNewItem(LLViewerInventoryItem* item, bool rearrang
 {
 	if (!item)
 	{
-		llwarns << "No inventory item. Couldn't create flat list item." << llendl;
+		LL_WARNS() << "No inventory item. Couldn't create flat list item." << LL_ENDL;
 		llassert(item != NULL);
 	}
 
@@ -219,7 +219,7 @@ void LLInventoryItemsList::addNewItem(LLViewerInventoryItem* item, bool rearrang
 	bool is_item_added = addItem(list_item, item->getUUID(), ADD_BOTTOM, rearrange);
 	if (!is_item_added)
 	{
-		llwarns << "Couldn't add flat list item." << llendl;
+		LL_WARNS() << "Couldn't add flat list item." << LL_ENDL;
 		llassert(is_item_added);
 	}
 }
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp
index 81c72fd320..61accb01f1 100755
--- a/indra/newview/llinventorymodel.cpp
+++ b/indra/newview/llinventorymodel.cpp
@@ -513,13 +513,13 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
 	LLUUID id;
 	if(!isInventoryUsable())
 	{
-		llwarns << "Inventory is broken." << llendl;
+		LL_WARNS() << "Inventory is broken." << LL_ENDL;
 		return id;
 	}
 
 	if(LLFolderType::lookup(preferred_type) == LLFolderType::badLookup())
 	{
-		lldebugs << "Attempt to create undefined category." << llendl;
+		LL_DEBUGS() << "Attempt to create undefined category." << LL_ENDL;
 		return id;
 	}
 
@@ -781,7 +781,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 
 	if(!isInventoryUsable())
 	{
-		llwarns << "Inventory is broken." << llendl;
+		LL_WARNS() << "Inventory is broken." << LL_ENDL;
 		return mask;
 	}
 
@@ -844,7 +844,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 			}
 			else
 			{
-				llwarns << "Couldn't find parent-child item tree for " << new_item->getName() << llendl;
+				LL_WARNS() << "Couldn't find parent-child item tree for " << new_item->getName() << LL_ENDL;
 			}
 		}
 		else
@@ -873,8 +873,8 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 			else
 			{
 				// Whoops! No such parent, make one.
-				llinfos << "Lost item: " << new_item->getUUID() << " - "
-						<< new_item->getName() << llendl;
+				LL_INFOS() << "Lost item: " << new_item->getUUID() << " - "
+						<< new_item->getName() << LL_ENDL;
 				parent_id = findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
 				new_item->setParent(parent_id);
 				item_array = get_ptr_in_map(mParentChildItemTree, parent_id);
@@ -887,7 +887,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item)
 				}
 				else
 				{
-					llwarns << "Lost and found Not there!!" << llendl;
+					LL_WARNS() << "Lost and found Not there!!" << LL_ENDL;
 				}
 			}
 		}
@@ -961,7 +961,7 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
 
 	if(!isInventoryUsable())
 	{
-		llwarns << "Inventory is broken." << llendl;
+		LL_WARNS() << "Inventory is broken." << LL_ENDL;
 		return;
 	}
 
@@ -1024,17 +1024,17 @@ void LLInventoryModel::updateCategory(const LLViewerInventoryCategory* cat)
 
 void LLInventoryModel::moveObject(const LLUUID& object_id, const LLUUID& cat_id)
 {
-	lldebugs << "LLInventoryModel::moveObject()" << llendl;
+	LL_DEBUGS() << "LLInventoryModel::moveObject()" << LL_ENDL;
 	if(!isInventoryUsable())
 	{
-		llwarns << "Inventory is broken." << llendl;
+		LL_WARNS() << "Inventory is broken." << LL_ENDL;
 		return;
 	}
 
 	if((object_id == cat_id) || !is_in_map(mCategoryMap, cat_id))
 	{
-		llwarns << "Could not move inventory object " << object_id << " to "
-				<< cat_id << llendl;
+		LL_WARNS() << "Could not move inventory object " << object_id << " to "
+				<< cat_id << LL_ENDL;
 		return;
 	}
 	LLPointer<LLViewerInventoryCategory> cat = getCategory(object_id);
@@ -1126,15 +1126,15 @@ void LLInventoryModel::changeCategoryParent(LLViewerInventoryCategory* cat,
 // Delete a particular inventory object by ID.
 void LLInventoryModel::deleteObject(const LLUUID& id)
 {
-	lldebugs << "LLInventoryModel::deleteObject()" << llendl;
+	LL_DEBUGS() << "LLInventoryModel::deleteObject()" << LL_ENDL;
 	LLPointer<LLInventoryObject> obj = getObject(id);
 	if (!obj) 
 	{
-		llwarns << "Deleting non-existent object [ id: " << id << " ] " << llendl;
+		LL_WARNS() << "Deleting non-existent object [ id: " << id << " ] " << LL_ENDL;
 		return;
 	}
 	
-	lldebugs << "Deleting inventory object " << id << llendl;
+	LL_DEBUGS() << "Deleting inventory object " << id << LL_ENDL;
 	mLastItem = NULL;
 	LLUUID parent_id = obj->getParentUUID();
 	mCategoryMap.erase(id);
@@ -1173,7 +1173,7 @@ void LLInventoryModel::deleteObject(const LLUUID& id)
 // Delete a particular inventory item by ID, and remove it from the server.
 void LLInventoryModel::purgeObject(const LLUUID &id)
 {
-	lldebugs << "LLInventoryModel::purgeObject() [ id: " << id << " ] " << llendl;
+	LL_DEBUGS() << "LLInventoryModel::purgeObject() [ id: " << id << " ] " << LL_ENDL;
 	LLPointer<LLInventoryObject> obj = getObject(id);
 	if(obj)
 	{
@@ -1212,7 +1212,7 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
 	EHasChildren children = categoryHasChildren(id);
 	if(children == CHILDREN_NO)
 	{
-		llinfos << "Not purging descendents of " << id << llendl;
+		LL_INFOS() << "Not purging descendents of " << id << LL_ENDL;
 		return;
 	}
 	LLPointer<LLViewerInventoryCategory> cat = getCategory(id);
@@ -1221,8 +1221,8 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
 		if (LLClipboard::instance().hasContents() && LLClipboard::instance().isCutMode())
 		{
 			// Something on the clipboard is in "cut mode" and needs to be preserved
-			llinfos << "LLInventoryModel::purgeDescendentsOf " << cat->getName()
-			<< " iterate and purge non hidden items" << llendl;
+			LL_INFOS() << "LLInventoryModel::purgeDescendentsOf " << cat->getName()
+			<< " iterate and purge non hidden items" << LL_ENDL;
 			cat_array_t* categories;
 			item_array_t* items;
 			// Get the list of direct descendants in tha categoy passed as argument
@@ -1251,8 +1251,8 @@ void LLInventoryModel::purgeDescendentsOf(const LLUUID& id)
 		{
 			// Fast purge
 			// do the cache accounting
-			llinfos << "LLInventoryModel::purgeDescendentsOf " << cat->getName()
-				<< llendl;
+			LL_INFOS() << "LLInventoryModel::purgeDescendentsOf " << cat->getName()
+				<< LL_ENDL;
 			S32 descendents = cat->getDescendentCount();
 			if(descendents > 0)
 			{
@@ -1349,7 +1349,7 @@ void LLInventoryModel::notifyObservers()
 		// Within notifyObservers, something called notifyObservers
 		// again.  This type of recursion is unsafe because it causes items to be 
 		// processed twice, and this can easily lead to infinite loops.
-		llwarns << "Call was made to notifyObservers within notifyObservers!" << llendl;
+		LL_WARNS() << "Call was made to notifyObservers within notifyObservers!" << LL_ENDL;
 		return;
 	}
 
@@ -1378,7 +1378,7 @@ void LLInventoryModel::addChangedMask(U32 mask, const LLUUID& referent)
 		// Something marked an item for change within a call to notifyObservers
 		// (which is in the process of processing the list of items marked for change).
 		// This means the change may fail to be processed.
-		llwarns << "Adding changed mask within notify observers!  Change will likely be lost." << llendl;
+		LL_WARNS() << "Adding changed mask within notify observers!  Change will likely be lost." << LL_ENDL;
 	}
 	
 	mModifyMask |= mask; 
@@ -1404,8 +1404,8 @@ void  LLInventoryModel::fetchInventoryResponder::result(const LLSD& content)
 	agent_id = content["agent_id"].asUUID();
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a inventory update for the wrong agent: " << agent_id
-				<< llendl;
+		LL_WARNS() << "Got a inventory update for the wrong agent: " << agent_id
+				<< LL_ENDL;
 		return;
 	}*/
 	item_array_t items;
@@ -1418,8 +1418,8 @@ void  LLInventoryModel::fetchInventoryResponder::result(const LLSD& content)
 		LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
 		titem->unpackMessage(content["items"][i]);
 		
-		lldebugs << "LLInventoryModel::messageUpdateCore() item id:"
-				 << titem->getUUID() << llendl;
+		LL_DEBUGS() << "LLInventoryModel::messageUpdateCore() item id:"
+				 << titem->getUUID() << LL_ENDL;
 		items.push_back(titem);
 		// examine update for changes.
 		LLViewerInventoryItem* itemp = gInventory.getItem(titem->getUUID());
@@ -1458,7 +1458,7 @@ void  LLInventoryModel::fetchInventoryResponder::result(const LLSD& content)
 //If we get back an error (not found, etc...), handle it here
 void LLInventoryModel::fetchInventoryResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llwarns << "fetchInventory error [status:" << status << "]: " << content << llendl;
+	LL_WARNS() << "fetchInventory error [status:" << status << "]: " << content << LL_ENDL;
 	gInventory.notifyObservers();
 }
 
@@ -1466,14 +1466,14 @@ bool LLInventoryModel::fetchDescendentsOf(const LLUUID& folder_id) const
 {
 	if(folder_id.isNull()) 
 	{
-		llwarns << "Calling fetch descendents on NULL folder id!" << llendl;
+		LL_WARNS() << "Calling fetch descendents on NULL folder id!" << LL_ENDL;
 		return false;
 	}
 	LLViewerInventoryCategory* cat = getCategory(folder_id);
 	if(!cat)
 	{
-		llwarns << "Asked to fetch descendents of non-existent folder: "
-				<< folder_id << llendl;
+		LL_WARNS() << "Asked to fetch descendents of non-existent folder: "
+				<< folder_id << LL_ENDL;
 		return false;
 	}
 	//S32 known_descendents = 0;
@@ -1494,8 +1494,8 @@ void LLInventoryModel::cache(
 	const LLUUID& parent_folder_id,
 	const LLUUID& agent_id)
 {
-	lldebugs << "Caching " << parent_folder_id << " for " << agent_id
-			 << llendl;
+	LL_DEBUGS() << "Caching " << parent_folder_id << " for " << agent_id
+			 << LL_ENDL;
 	LLViewerInventoryCategory* root_cat = getCategory(parent_folder_id);
 	if(!root_cat) return;
 	cat_array_t categories;
@@ -1520,19 +1520,19 @@ void LLInventoryModel::cache(
 	gzip_filename.append(".gz");
 	if(gzip_file(inventory_filename, gzip_filename))
 	{
-		lldebugs << "Successfully compressed " << inventory_filename << llendl;
+		LL_DEBUGS() << "Successfully compressed " << inventory_filename << LL_ENDL;
 		LLFile::remove(inventory_filename);
 	}
 	else
 	{
-		llwarns << "Unable to compress " << inventory_filename << llendl;
+		LL_WARNS() << "Unable to compress " << inventory_filename << LL_ENDL;
 	}
 }
 
 
 void LLInventoryModel::addCategory(LLViewerInventoryCategory* category)
 {
-	//llinfos << "LLInventoryModel::addCategory()" << llendl;
+	//LL_INFOS() << "LLInventoryModel::addCategory()" << LL_ENDL;
 	if(category)
 	{
 		// We aren't displaying the Meshes folder
@@ -1561,7 +1561,7 @@ void LLInventoryModel::addItem(LLViewerInventoryItem* item)
 		if ((item->getType() == LLAssetType::AT_NONE)
 		    || LLAssetType::lookup(item->getType()) == LLAssetType::badLookup())
 		{
-			llwarns << "Got bad asset type for item [ name: " << item->getName() << " type: " << item->getType() << " inv-type: " << item->getInventoryType() << " ], ignoring." << llendl;
+			LL_WARNS() << "Got bad asset type for item [ name: " << item->getName() << " type: " << item->getType() << " inv-type: " << item->getInventoryType() << " ], ignoring." << LL_ENDL;
 			return;
 		}
 
@@ -1569,7 +1569,7 @@ void LLInventoryModel::addItem(LLViewerInventoryItem* item)
 		// The item will show up as a broken link.
 		if (item->getIsBrokenLink())
 		{
-			llinfos << "Adding broken link [ name: " << item->getName() << " itemID: " << item->getUUID() << " assetID: " << item->getAssetUUID() << " )  parent: " << item->getParentUUID() << llendl;
+			LL_INFOS() << "Adding broken link [ name: " << item->getName() << " itemID: " << item->getUUID() << " assetID: " << item->getAssetUUID() << " )  parent: " << item->getParentUUID() << LL_ENDL;
 		}
 
 		mItemMap[item->getUUID()] = item;
@@ -1579,7 +1579,7 @@ void LLInventoryModel::addItem(LLViewerInventoryItem* item)
 // Empty the entire contents
 void LLInventoryModel::empty()
 {
-//	llinfos << "LLInventoryModel::empty()" << llendl;
+//	LL_INFOS() << "LLInventoryModel::empty()" << LL_ENDL;
 	std::for_each(
 		mParentChildCategoryTree.begin(),
 		mParentChildCategoryTree.end(),
@@ -1620,9 +1620,9 @@ void LLInventoryModel::accountForUpdate(const LLCategoryUpdate& update) const
 				descendents_actual += update.mDescendentDelta;
 				cat->setDescendentCount(descendents_actual);
 				cat->setVersion(++version);
-				lldebugs << "accounted: '" << cat->getName() << "' "
+				LL_DEBUGS() << "accounted: '" << cat->getName() << "' "
 						 << version << " with " << descendents_actual
-						 << " descendents." << llendl;
+						 << " descendents." << LL_ENDL;
 			}
 		}
 		if(!accounted)
@@ -1630,13 +1630,13 @@ void LLInventoryModel::accountForUpdate(const LLCategoryUpdate& update) const
 			// Error condition, this means that the category did not register that
 			// it got new descendents (perhaps because it is still being loaded)
 			// which means its descendent count will be wrong.
-			llwarns << "Accounting failed for '" << cat->getName() << "' version:"
-					 << version << llendl;
+			LL_WARNS() << "Accounting failed for '" << cat->getName() << "' version:"
+					 << version << LL_ENDL;
 		}
 	}
 	else
 	{
-		llwarns << "No category found for update " << update.mCategoryID << llendl;
+		LL_WARNS() << "No category found for update " << update.mCategoryID << LL_ENDL;
 	}
 }
 
@@ -1676,18 +1676,18 @@ void LLInventoryModel::incrementCategoryVersion(const LLUUID& category_id)
 		if(LLViewerInventoryCategory::VERSION_UNKNOWN != version)
 		{
 			cat->setVersion(version + 1);
-			llinfos << "IncrementVersion: " << cat->getName() << " "
-					<< cat->getVersion() << llendl;
+			LL_INFOS() << "IncrementVersion: " << cat->getName() << " "
+					<< cat->getVersion() << LL_ENDL;
 		}
 		else
 		{
-			llinfos << "Attempt to increment version when unknown: "
-					<< category_id << llendl;
+			LL_INFOS() << "Attempt to increment version when unknown: "
+					<< category_id << LL_ENDL;
 		}
 	}
 	else
 	{
-		llinfos << "Attempt to increment category: " << category_id << llendl;
+		LL_INFOS() << "Attempt to increment category: " << category_id << LL_ENDL;
 	}
 }
 void LLInventoryModel::incrementCategorySetVersion(
@@ -1766,7 +1766,7 @@ bool LLInventoryModel::loadSkeleton(
 	const LLSD& options,
 	const LLUUID& owner_id)
 {
-	lldebugs << "importing inventory skeleton for " << owner_id << llendl;
+	LL_DEBUGS() << "importing inventory skeleton for " << owner_id << LL_ENDL;
 
 	typedef std::set<LLPointer<LLViewerInventoryCategory>, InventoryIDPtrLess> cat_set_t;
 	cat_set_t temp_cats;
@@ -1803,7 +1803,7 @@ bool LLInventoryModel::loadSkeleton(
 		}
 		else
 		{
-			llwarns << "Unable to import near " << name.asString() << llendl;
+			LL_WARNS() << "Unable to import near " << name.asString() << LL_ENDL;
             rv = false;
 		}
 	}
@@ -1840,7 +1840,7 @@ bool LLInventoryModel::loadSkeleton(
 			}
 			else
 			{
-				llinfos << "Unable to gunzip " << gzip_filename << llendl;
+				LL_INFOS() << "Unable to gunzip " << gzip_filename << LL_ENDL;
 			}
 		}
 		bool is_cache_obsolete = false;
@@ -1921,10 +1921,10 @@ bool LLInventoryModel::loadSkeleton(
 						if (item->getIsBrokenLink())
 						{
 							//bad_link_count++;
-							lldebugs << "Attempted to add cached link item without baseobj present ( name: "
+							LL_DEBUGS() << "Attempted to add cached link item without baseobj present ( name: "
 									 << item->getName() << " itemID: " << item->getUUID()
 									 << " assetID: " << item->getAssetUUID()
-									 << " ).  Ignoring and invalidating " << cat->getName() << " . " << llendl;
+									 << " ).  Ignoring and invalidating " << cat->getName() << " . " << LL_ENDL;
 							possible_broken_links.push_back(item);
 							continue;
 						}
@@ -1951,7 +1951,7 @@ bool LLInventoryModel::loadSkeleton(
 					{
 						bad_link_count++;
 						invalid_categories.insert(cit->second);
-						//llinfos << "link still broken: " << item->getName() << " in folder " << cat->getName() << llendl;
+						//LL_INFOS() << "link still broken: " << item->getName() << " in folder " << cat->getName() << LL_ENDL;
 					}
 					else
 					{
@@ -1963,11 +1963,11 @@ bool LLInventoryModel::loadSkeleton(
 					}
 				}
 
- 				llinfos << "Attempted to add " << bad_link_count
+ 				LL_INFOS() << "Attempted to add " << bad_link_count
  						<< " cached link items without baseobj present. "
 					    << good_link_count << " link items were successfully added. "
 					    << recovered_link_count << " links added in recovery. "
- 						<< "The corresponding categories were invalidated." << llendl;
+ 						<< "The corresponding categories were invalidated." << LL_ENDL;
 			}
 
 		}
@@ -1991,9 +1991,9 @@ bool LLInventoryModel::loadSkeleton(
 		{
 			LLViewerInventoryCategory* cat = (*invalid_cat_it).get();
 			cat->setVersion(NO_VERSION);
-			LL_DEBUGS("Inventory") << "Invalidating category name: " << cat->getName() << " UUID: " << cat->getUUID() << " due to invalid descendents cache" << llendl;
+			LL_DEBUGS("Inventory") << "Invalidating category name: " << cat->getName() << " UUID: " << cat->getUUID() << " due to invalid descendents cache" << LL_ENDL;
 		}
-		LL_INFOS("Inventory") << "Invalidated " << invalid_categories.size() << " categories due to invalid descendents cache" << llendl;
+		LL_INFOS("Inventory") << "Invalidated " << invalid_categories.size() << " categories due to invalid descendents cache" << LL_ENDL;
 
 		// At this point, we need to set the known descendents for each
 		// category which successfully cached so that we do not
@@ -2025,15 +2025,15 @@ bool LLInventoryModel::loadSkeleton(
 		if(is_cache_obsolete)
 		{
 			// If out of date, remove the gzipped file too.
-			llwarns << "Inv cache out of date, removing" << llendl;
+			LL_WARNS() << "Inv cache out of date, removing" << LL_ENDL;
 			LLFile::remove(gzip_filename);
 		}
 		categories.clear(); // will unref and delete entries
 	}
 
-	llinfos << "Successfully loaded " << cached_category_count
+	LL_INFOS() << "Successfully loaded " << cached_category_count
 			<< " categories and " << cached_item_count << " items from cache."
-			<< llendl;
+			<< LL_ENDL;
 
 	return rv;
 }
@@ -2043,7 +2043,7 @@ bool LLInventoryModel::loadSkeleton(
 // should be sufficient for our needs. 
 void LLInventoryModel::buildParentChildMap()
 {
-	llinfos << "LLInventoryModel::buildParentChildMap()" << llendl;
+	LL_INFOS() << "LLInventoryModel::buildParentChildMap()" << LL_ENDL;
 
 	// *NOTE: I am skipping the logic around folder version
 	// synchronization here because it seems if a folder is lost, we
@@ -2107,8 +2107,8 @@ void LLInventoryModel::buildParentChildMap()
 			// implement it, we would need a set or map of uuid pairs
 			// which would be (folder_id, new_parent_id) to be sent up
 			// to the server.
-			llinfos << "Lost categroy: " << cat->getUUID() << " - "
-					<< cat->getName() << llendl;
+			LL_INFOS() << "Lost categroy: " << cat->getUUID() << " - "
+					<< cat->getName() << LL_ENDL;
 			++lost;
 			// plop it into the lost & found.
 			LLFolderType::EType pref = cat->getPreferredType();
@@ -2134,13 +2134,13 @@ void LLInventoryModel::buildParentChildMap()
 			}
 			else
 			{		
-				llwarns << "Lost and found Not there!!" << llendl;
+				LL_WARNS() << "Lost and found Not there!!" << LL_ENDL;
 			}
 		}
 	}
 	if(lost)
 	{
-		llwarns << "Found  " << lost << " lost categories." << llendl;
+		LL_WARNS() << "Found  " << lost << " lost categories." << LL_ENDL;
 	}
 
 	const BOOL COF_exists = (findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT, FALSE) != LLUUID::null);
@@ -2174,8 +2174,8 @@ void LLInventoryModel::buildParentChildMap()
 		}
 		else
 		{
-			llinfos << "Lost item: " << item->getUUID() << " - "
-					<< item->getName() << llendl;
+			LL_INFOS() << "Lost item: " << item->getUUID() << " - "
+					<< item->getName() << LL_ENDL;
 			++lost;
 			// plop it into the lost & found.
 			//
@@ -2191,13 +2191,13 @@ void LLInventoryModel::buildParentChildMap()
 			}
 			else
 			{
-				llwarns << "Lost and found Not there!!" << llendl;
+				LL_WARNS() << "Lost and found Not there!!" << LL_ENDL;
 			}
 		}
 	}
 	if(lost)
 	{
-		llwarns << "Found " << lost << " lost items." << llendl;
+		LL_WARNS() << "Found " << lost << " lost items." << LL_ENDL;
 		LLMessageSystem* msg = gMessageSystem;
 		BOOL start_new_message = TRUE;
 		const LLUUID lnf = findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND);
@@ -2266,7 +2266,7 @@ void LLInventoryModel::buildParentChildMap()
 			// The inv tree is built.
 			mIsAgentInvUsable = true;
 
-			llinfos << "Inventory initialized, notifying observers" << llendl;
+			LL_INFOS() << "Inventory initialized, notifying observers" << LL_ENDL;
 			addChangedMask(LLInventoryObserver::ALL, LLUUID::null);
 			notifyObservers();
 		}
@@ -2313,14 +2313,14 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
 {
 	if(filename.empty())
 	{
-		llerrs << "Filename is Null!" << llendl;
+		LL_ERRS() << "Filename is Null!" << LL_ENDL;
 		return false;
 	}
-	llinfos << "LLInventoryModel::loadFromFile(" << filename << ")" << llendl;
+	LL_INFOS() << "LLInventoryModel::loadFromFile(" << filename << ")" << LL_ENDL;
 	LLFILE* file = LLFile::fopen(filename, "rb");		/*Flawfinder: ignore*/
 	if(!file)
 	{
-		llinfos << "unable to load inventory from: " << filename << llendl;
+		LL_INFOS() << "unable to load inventory from: " << filename << LL_ENDL;
 		return false;
 	}
 	// *NOTE: This buffer size is hard coded into scanf() below.
@@ -2359,7 +2359,7 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
 			}
 			else
 			{
-				llwarns << "loadInventoryFromFile().  Ignoring invalid inventory category: " << inv_cat->getName() << llendl;
+				LL_WARNS() << "loadInventoryFromFile().  Ignoring invalid inventory category: " << inv_cat->getName() << LL_ENDL;
 				//delete inv_cat; // automatic when inv_cat is reassigned or destroyed
 			}
 		}
@@ -2377,8 +2377,8 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
 				if(inv_item->getUUID().isNull())
 				{
 					//delete inv_item; // automatic when inv_cat is reassigned or destroyed
-					llwarns << "Ignoring inventory with null item id: "
-							<< inv_item->getName() << llendl;
+					LL_WARNS() << "Ignoring inventory with null item id: "
+							<< inv_item->getName() << LL_ENDL;
 						
 				}
 				else
@@ -2388,14 +2388,14 @@ bool LLInventoryModel::loadFromFile(const std::string& filename,
 			}
 			else
 			{
-				llwarns << "loadInventoryFromFile().  Ignoring invalid inventory item: " << inv_item->getName() << llendl;
+				LL_WARNS() << "loadInventoryFromFile().  Ignoring invalid inventory item: " << inv_item->getName() << LL_ENDL;
 				//delete inv_item; // automatic when inv_cat is reassigned or destroyed
 			}
 		}
 		else
 		{
-			llwarns << "Unknown token in inventory file '" << keyword << "'"
-					<< llendl;
+			LL_WARNS() << "Unknown token in inventory file '" << keyword << "'"
+					<< LL_ENDL;
 		}
 	}
 	fclose(file);
@@ -2411,14 +2411,14 @@ bool LLInventoryModel::saveToFile(const std::string& filename,
 {
 	if(filename.empty())
 	{
-		llerrs << "Filename is Null!" << llendl;
+		LL_ERRS() << "Filename is Null!" << LL_ENDL;
 		return false;
 	}
-	llinfos << "LLInventoryModel::saveToFile(" << filename << ")" << llendl;
+	LL_INFOS() << "LLInventoryModel::saveToFile(" << filename << ")" << LL_ENDL;
 	LLFILE* file = LLFile::fopen(filename, "wb");		/*Flawfinder: ignore*/
 	if(!file)
 	{
-		llwarns << "unable to save inventory to: " << filename << llendl;
+		LL_WARNS() << "unable to save inventory to: " << filename << LL_ENDL;
 		return false;
 	}
 
@@ -2523,8 +2523,8 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account)
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a inventory update for the wrong agent: " << agent_id
-				<< llendl;
+		LL_WARNS() << "Got a inventory update for the wrong agent: " << agent_id
+				<< LL_ENDL;
 		return false;
 	}
 	item_array_t items;
@@ -2536,8 +2536,8 @@ bool LLInventoryModel::messageUpdateCore(LLMessageSystem* msg, bool account)
 	{
 		LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
 		titem->unpackMessage(msg, _PREHASH_InventoryData, i);
-		lldebugs << "LLInventoryModel::messageUpdateCore() item id:"
-				 << titem->getUUID() << llendl;
+		LL_DEBUGS() << "LLInventoryModel::messageUpdateCore() item id:"
+				 << titem->getUUID() << LL_ENDL;
 		items.push_back(titem);
 		// examine update for changes.
 		LLViewerInventoryItem* itemp = gInventory.getItem(titem->getUUID());
@@ -2584,17 +2584,17 @@ void LLInventoryModel::removeInventoryItem(LLUUID agent_id, LLMessageSystem* msg
 {
 	LLUUID item_id;
 	S32 count = msg->getNumberOfBlocksFast(msg_label);
-	lldebugs << "Message has " << count << " item blocks" << llendl;
+	LL_DEBUGS() << "Message has " << count << " item blocks" << LL_ENDL;
 	uuid_vec_t item_ids;
 	update_map_t update;
 	for(S32 i = 0; i < count; ++i)
 	{
 		msg->getUUIDFast(msg_label, _PREHASH_ItemID, item_id, i);
-		lldebugs << "Checking for item-to-be-removed " << item_id << llendl;
+		LL_DEBUGS() << "Checking for item-to-be-removed " << item_id << LL_ENDL;
 		LLViewerInventoryItem* itemp = gInventory.getItem(item_id);
 		if(itemp)
 		{
-		lldebugs << "Item will be removed " << item_id << llendl;
+		LL_DEBUGS() << "Item will be removed " << item_id << LL_ENDL;
 			// we only bother with the delete and account if we found
 			// the item - this is usually a back-up for permissions,
 			// so frequently the item will already be gone.
@@ -2605,7 +2605,7 @@ void LLInventoryModel::removeInventoryItem(LLUUID agent_id, LLMessageSystem* msg
 	gInventory.accountForUpdate(update);
 	for(uuid_vec_t::iterator it = item_ids.begin(); it != item_ids.end(); ++it)
 	{
-		lldebugs << "Calling deleteObject " << *it << llendl;
+		LL_DEBUGS() << "Calling deleteObject " << *it << LL_ENDL;
 		gInventory.deleteObject(*it);
 	}
 }
@@ -2613,13 +2613,13 @@ void LLInventoryModel::removeInventoryItem(LLUUID agent_id, LLMessageSystem* msg
 // 	static
 void LLInventoryModel::processRemoveInventoryItem(LLMessageSystem* msg, void**)
 {
-	lldebugs << "LLInventoryModel::processRemoveInventoryItem()" << llendl;
+	LL_DEBUGS() << "LLInventoryModel::processRemoveInventoryItem()" << LL_ENDL;
 	LLUUID agent_id, item_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a RemoveInventoryItem for the wrong agent."
-				<< llendl;
+		LL_WARNS() << "Got a RemoveInventoryItem for the wrong agent."
+				<< LL_ENDL;
 		return;
 	}
 	LLInventoryModel::removeInventoryItem(agent_id, msg, _PREHASH_InventoryData);
@@ -2630,14 +2630,14 @@ void LLInventoryModel::processRemoveInventoryItem(LLMessageSystem* msg, void**)
 void LLInventoryModel::processUpdateInventoryFolder(LLMessageSystem* msg,
 													void**)
 {
-	lldebugs << "LLInventoryModel::processUpdateInventoryFolder()" << llendl;
+	LL_DEBUGS() << "LLInventoryModel::processUpdateInventoryFolder()" << LL_ENDL;
 	LLUUID agent_id, folder_id, parent_id;
 	//char name[DB_INV_ITEM_NAME_BUF_SIZE];
 	msg->getUUIDFast(_PREHASH_FolderData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got an UpdateInventoryFolder for the wrong agent."
-				<< llendl;
+		LL_WARNS() << "Got an UpdateInventoryFolder for the wrong agent."
+				<< LL_ENDL;
 		return;
 	}
 	LLPointer<LLViewerInventoryCategory> lastfolder; // hack
@@ -2715,14 +2715,14 @@ void LLInventoryModel::removeInventoryFolder(LLUUID agent_id,
 void LLInventoryModel::processRemoveInventoryFolder(LLMessageSystem* msg,
 													void**)
 {
-	lldebugs << "LLInventoryModel::processRemoveInventoryFolder()" << llendl;
+	LL_DEBUGS() << "LLInventoryModel::processRemoveInventoryFolder()" << LL_ENDL;
 	LLUUID agent_id, session_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_SessionID, session_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a RemoveInventoryFolder for the wrong agent."
-		<< llendl;
+		LL_WARNS() << "Got a RemoveInventoryFolder for the wrong agent."
+		<< LL_ENDL;
 		return;
 	}
 	LLInventoryModel::removeInventoryFolder( agent_id, msg );
@@ -2733,14 +2733,14 @@ void LLInventoryModel::processRemoveInventoryFolder(LLMessageSystem* msg,
 void LLInventoryModel::processRemoveInventoryObjects(LLMessageSystem* msg,
 													void**)
 {
-	lldebugs << "LLInventoryModel::processRemoveInventoryObjects()" << llendl;
+	LL_DEBUGS() << "LLInventoryModel::processRemoveInventoryObjects()" << LL_ENDL;
 	LLUUID agent_id, session_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_SessionID, session_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a RemoveInventoryObjects for the wrong agent."
-		<< llendl;
+		LL_WARNS() << "Got a RemoveInventoryObjects for the wrong agent."
+		<< LL_ENDL;
 		return;
 	}
 	LLInventoryModel::removeInventoryFolder( agent_id, msg );
@@ -2756,8 +2756,8 @@ void LLInventoryModel::processSaveAssetIntoInventory(LLMessageSystem* msg,
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a SaveAssetIntoInventory message for the wrong agent."
-				<< llendl;
+		LL_WARNS() << "Got a SaveAssetIntoInventory message for the wrong agent."
+				<< LL_ENDL;
 		return;
 	}
 
@@ -2767,8 +2767,8 @@ void LLInventoryModel::processSaveAssetIntoInventory(LLMessageSystem* msg,
 	// The viewer ignores the asset id because this message is only
 	// used for attachments/objects, so the asset id is not used in
 	// the viewer anyway.
-	lldebugs << "LLInventoryModel::processSaveAssetIntoInventory itemID="
-		<< item_id << llendl;
+	LL_DEBUGS() << "LLInventoryModel::processSaveAssetIntoInventory itemID="
+		<< item_id << LL_ENDL;
 	LLViewerInventoryItem* item = gInventory.getItem( item_id );
 	if( item )
 	{
@@ -2779,8 +2779,8 @@ void LLInventoryModel::processSaveAssetIntoInventory(LLMessageSystem* msg,
 	}
 	else
 	{
-		llinfos << "LLInventoryModel::processSaveAssetIntoInventory item"
-			" not found: " << item_id << llendl;
+		LL_INFOS() << "LLInventoryModel::processSaveAssetIntoInventory item"
+			" not found: " << item_id << LL_ENDL;
 	}
 	if(gViewerWindow)
 	{
@@ -2803,13 +2803,13 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**)
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a BulkUpdateInventory for the wrong agent." << llendl;
+		LL_WARNS() << "Got a BulkUpdateInventory for the wrong agent." << LL_ENDL;
 		return;
 	}
 	LLUUID tid;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_TransactionID, tid);
 #ifndef LL_RELEASE_FOR_DOWNLOAD
-	llinfos << "Bulk inventory: " << tid << llendl;
+	LL_INFOS() << "Bulk inventory: " << tid << LL_ENDL;
 #endif
 
 	update_map_t update;
@@ -2821,9 +2821,9 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**)
 	{
 		LLPointer<LLViewerInventoryCategory> tfolder = new LLViewerInventoryCategory(gAgent.getID());
 		tfolder->unpackMessage(msg, _PREHASH_FolderData, i);
-		llinfos << "unpacked folder '" << tfolder->getName() << "' ("
+		LL_INFOS() << "unpacked folder '" << tfolder->getName() << "' ("
 				<< tfolder->getUUID() << ") in " << tfolder->getParentUUID()
-				<< llendl;
+				<< LL_ENDL;
 		if(tfolder->getUUID().notNull())
 		{
 			folders.push_back(tfolder);
@@ -2863,8 +2863,8 @@ void LLInventoryModel::processBulkUpdateInventory(LLMessageSystem* msg, void**)
 	{
 		LLPointer<LLViewerInventoryItem> titem = new LLViewerInventoryItem;
 		titem->unpackMessage(msg, _PREHASH_ItemData, i);
-		llinfos << "unpacked item '" << titem->getName() << "' in "
-				<< titem->getParentUUID() << llendl;
+		LL_INFOS() << "unpacked item '" << titem->getName() << "' in "
+				<< titem->getParentUUID() << LL_ENDL;
 		U32 callback_id;
 		msg->getU32Fast(_PREHASH_ItemData, _PREHASH_CallbackID, callback_id);
 		if(titem->getUUID().notNull() ) // && callback_id.notNull() )
@@ -2970,7 +2970,7 @@ void LLInventoryModel::processInventoryDescendents(LLMessageSystem* msg,void**)
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a UpdateInventoryItem for the wrong agent." << llendl;
+		LL_WARNS() << "Got a UpdateInventoryItem for the wrong agent." << LL_ENDL;
 		return;
 	}
 	LLUUID parent_id;
@@ -2999,7 +2999,7 @@ void LLInventoryModel::processInventoryDescendents(LLMessageSystem* msg,void**)
 		// If the item has already been added (e.g. from link prefetch), then it doesn't need to be re-added.
 		if (gInventory.getItem(titem->getUUID()))
 		{
-			lldebugs << "Skipping prefetched item [ Name: " << titem->getName() << " | Type: " << titem->getActualType() << " | ItemUUID: " << titem->getUUID() << " ] " << llendl;
+			LL_DEBUGS() << "Skipping prefetched item [ Name: " << titem->getName() << " | Type: " << titem->getActualType() << " | ItemUUID: " << titem->getUUID() << " ] " << LL_ENDL;
 			continue;
 		}
 		gInventory.updateItem(titem);
@@ -3021,13 +3021,13 @@ void LLInventoryModel::processInventoryDescendents(LLMessageSystem* msg,void**)
 // static
 void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
 {
-	lldebugs << "LLInventoryModel::processMoveInventoryItem()" << llendl;
+	LL_DEBUGS() << "LLInventoryModel::processMoveInventoryItem()" << LL_ENDL;
 	LLUUID agent_id;
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got a MoveInventoryItem message for the wrong agent."
-				<< llendl;
+		LL_WARNS() << "Got a MoveInventoryItem message for the wrong agent."
+				<< LL_ENDL;
 		return;
 	}
 
@@ -3046,8 +3046,8 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
 			msg->getUUIDFast(_PREHASH_InventoryData, _PREHASH_FolderID, folder_id, i);
 			msg->getString("InventoryData", "NewName", new_name, i);
 
-			lldebugs << "moving item " << item_id << " to folder "
-					 << folder_id << llendl;
+			LL_DEBUGS() << "moving item " << item_id << " to folder "
+					 << folder_id << LL_ENDL;
 			update_list_t update;
 			LLCategoryUpdate old_folder(item->getParentUUID(), -1);
 			update.push_back(old_folder);
@@ -3065,7 +3065,7 @@ void LLInventoryModel::processMoveInventoryItem(LLMessageSystem* msg, void**)
 		}
 		else
 		{
-			llinfos << "LLInventoryModel::processMoveInventoryItem item not found: " << item_id << llendl;
+			LL_INFOS() << "LLInventoryModel::processMoveInventoryItem item not found: " << item_id << LL_ENDL;
 		}
 	}
 	if(anything_changed)
@@ -3221,7 +3221,7 @@ BOOL LLInventoryModel::getIsFirstTimeInViewer2()
 	// Do not call this before parentchild map is built.
 	if (!gInventory.mIsAgentInvUsable)
 	{
-		llwarns << "Parent Child Map not yet built; guessing as first time in viewer2." << llendl;
+		LL_WARNS() << "Parent Child Map not yet built; guessing as first time in viewer2." << LL_ENDL;
 		return TRUE;
 	}
 
@@ -3356,37 +3356,37 @@ void LLInventoryModel::rearrangeFavoriteLandmarks(const LLUUID& source_item_id,
 // *NOTE: DEBUG functionality
 void LLInventoryModel::dumpInventory() const
 {
-	llinfos << "\nBegin Inventory Dump\n**********************:" << llendl;
-	llinfos << "mCategory[] contains " << mCategoryMap.size() << " items." << llendl;
+	LL_INFOS() << "\nBegin Inventory Dump\n**********************:" << LL_ENDL;
+	LL_INFOS() << "mCategory[] contains " << mCategoryMap.size() << " items." << LL_ENDL;
 	for(cat_map_t::const_iterator cit = mCategoryMap.begin(); cit != mCategoryMap.end(); ++cit)
 	{
 		const LLViewerInventoryCategory* cat = cit->second;
 		if(cat)
 		{
-			llinfos << "  " <<  cat->getUUID() << " '" << cat->getName() << "' "
+			LL_INFOS() << "  " <<  cat->getUUID() << " '" << cat->getName() << "' "
 					<< cat->getVersion() << " " << cat->getDescendentCount()
-					<< llendl;
+					<< LL_ENDL;
 		}
 		else
 		{
-			llinfos << "  NULL!" << llendl;
+			LL_INFOS() << "  NULL!" << LL_ENDL;
 		}
 	}	
-	llinfos << "mItemMap[] contains " << mItemMap.size() << " items." << llendl;
+	LL_INFOS() << "mItemMap[] contains " << mItemMap.size() << " items." << LL_ENDL;
 	for(item_map_t::const_iterator iit = mItemMap.begin(); iit != mItemMap.end(); ++iit)
 	{
 		const LLViewerInventoryItem* item = iit->second;
 		if(item)
 		{
-			llinfos << "  " << item->getUUID() << " "
-					<< item->getName() << llendl;
+			LL_INFOS() << "  " << item->getUUID() << " "
+					<< item->getName() << LL_ENDL;
 		}
 		else
 		{
-			llinfos << "  NULL!" << llendl;
+			LL_INFOS() << "  NULL!" << LL_ENDL;
 		}
 	}
-	llinfos << "\n**********************\nEnd Inventory Dump" << llendl;
+	LL_INFOS() << "\n**********************\nEnd Inventory Dump" << LL_ENDL;
 }
 
 ///----------------------------------------------------------------------------
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index d88e0c3192..a8fda4fcf8 100755
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -200,7 +200,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
 		// No more categories to fetch, stop fetch process.
 		if (mFetchQueue.empty())
 		{
-			llinfos << "Inventory fetch completed" << llendl;
+			LL_INFOS() << "Inventory fetch completed" << LL_ENDL;
 
 			setAllFoldersFetched();
 			mBackgroundFetchActive = false;
@@ -216,7 +216,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
 			// Double timeouts on failure.
 			mMinTimeBetweenFetches = llmin(mMinTimeBetweenFetches * 2.f, 10.f);
 			mMaxTimeBetweenFetches = llmin(mMaxTimeBetweenFetches * 2.f, 120.f);
-			lldebugs << "Inventory fetch times grown to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
+			LL_DEBUGS() << "Inventory fetch times grown to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << LL_ENDL;
 			// fetch is no longer considered "timely" although we will wait for full time-out.
 			mTimelyFetchPending = FALSE;
 		}
@@ -289,7 +289,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
 						// Shrink timeouts based on success.
 						mMinTimeBetweenFetches = llmax(mMinTimeBetweenFetches * 0.8f, 0.3f);
 						mMaxTimeBetweenFetches = llmax(mMaxTimeBetweenFetches * 0.8f, 10.f);
-						lldebugs << "Inventory fetch times shrunk to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << llendl;
+						LL_DEBUGS() << "Inventory fetch times shrunk to (" << mMinTimeBetweenFetches << ", " << mMaxTimeBetweenFetches << ")" << LL_ENDL;
 					}
 
 					mTimelyFetchPending = FALSE;
@@ -417,8 +417,8 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
 
 			//if(agent_id != gAgent.getID())	//This should never happen.
 			//{
-			//	llwarns << "Got a UpdateInventoryItem for the wrong agent."
-			//			<< llendl;
+			//	LL_WARNS() << "Got a UpdateInventoryItem for the wrong agent."
+			//			<< LL_ENDL;
 			//	break;
 			//}
 
@@ -512,8 +512,8 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
 			LLSD folder_sd = *folder_it;
 			
 			// These folders failed on the dataserver.  We probably don't want to retry them.
-			llinfos << "Folder " << folder_sd["folder_id"].asString() 
-					<< "Error: " << folder_sd["error"].asString() << llendl;
+			LL_INFOS() << "Folder " << folder_sd["folder_id"].asString() 
+					<< "Error: " << folder_sd["error"].asString() << LL_ENDL;
 		}
 	}
 
@@ -521,7 +521,7 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
 	
 	if (fetcher->isBulkFetchProcessingComplete())
 	{
-		llinfos << "Inventory fetch completed" << llendl;
+		LL_INFOS() << "Inventory fetch completed" << LL_ENDL;
 		fetcher->setAllFoldersFetched();
 	}
 	
@@ -533,8 +533,8 @@ void LLInventoryModelFetchDescendentsResponder::errorWithContent(U32 status, con
 {
 	LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
 
-	llinfos << "LLInventoryModelFetchDescendentsResponder::error [status:"
-			<< status << "]: " << content << llendl;
+	LL_INFOS() << "LLInventoryModelFetchDescendentsResponder::error [status:"
+			<< status << "]: " << content << LL_ENDL;
 						
 	fetcher->incrFetchCount(-1);
 
diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp
index 1083a6b37d..8b7b12e844 100755
--- a/indra/newview/llinventoryobserver.cpp
+++ b/indra/newview/llinventoryobserver.cpp
@@ -149,10 +149,10 @@ LLInventoryFetchItemsObserver::LLInventoryFetchItemsObserver(const uuid_vec_t& i
 
 void LLInventoryFetchItemsObserver::changed(U32 mask)
 {
-	lldebugs << this << " remaining incomplete " << mIncomplete.size()
+	LL_DEBUGS() << this << " remaining incomplete " << mIncomplete.size()
 			 << " complete " << mComplete.size()
 			 << " wait period " << mFetchingPeriod.getRemainingTimeF32()
-			 << llendl;
+			 << LL_ENDL;
 
 	// scan through the incomplete items and move or erase them as
 	// appropriate.
@@ -176,7 +176,7 @@ void LLInventoryFetchItemsObserver::changed(U32 mask)
 				if (timeout_expired)
 				{
 					// Just concede that this item hasn't arrived in reasonable time and continue on.
-					llwarns << "Fetcher timed out when fetching inventory item UUID: " << item_id << LL_ENDL;
+					LL_WARNS() << "Fetcher timed out when fetching inventory item UUID: " << item_id << LL_ENDL;
 					it = mIncomplete.erase(it);
 				}
 				else
@@ -191,12 +191,12 @@ void LLInventoryFetchItemsObserver::changed(U32 mask)
 
 	if (mIncomplete.empty())
 	{
-		lldebugs << this << " done at remaining incomplete "
-				 << mIncomplete.size() << " complete " << mComplete.size() << llendl;
+		LL_DEBUGS() << this << " done at remaining incomplete "
+				 << mIncomplete.size() << " complete " << mComplete.size() << LL_ENDL;
 		done();
 	}
-	//llinfos << "LLInventoryFetchItemsObserver::changed() mComplete size " << mComplete.size() << llendl;
-	//llinfos << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << llendl;
+	//LL_INFOS() << "LLInventoryFetchItemsObserver::changed() mComplete size " << mComplete.size() << LL_ENDL;
+	//LL_INFOS() << "LLInventoryFetchItemsObserver::changed() mIncomplete size " << mIncomplete.size() << LL_ENDL;
 }
 
 void fetch_items_from_llsd(const LLSD& items_llsd)
@@ -224,12 +224,12 @@ void fetch_items_from_llsd(const LLSD& items_llsd)
 	{
 		if (!gAgent.getRegion())
 		{
-			llwarns << "Agent's region is null" << llendl;
+			LL_WARNS() << "Agent's region is null" << LL_ENDL;
 			break;
 		}
 
 		if (0 == body[i]["items"].size()) {
-			lldebugs << "Skipping body with no items to fetch" << llendl;
+			LL_DEBUGS() << "Skipping body with no items to fetch" << LL_ENDL;
 			continue;
 		}
 
@@ -391,7 +391,7 @@ BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInven
 	gInventory.getDirectDescendentsOf(cat->getUUID(), cats, items);
 	if (!cats || !items)
 	{
-		llwarns << "Category '" << cat->getName() << "' descendents corrupted, fetch failed." << llendl;
+		LL_WARNS() << "Category '" << cat->getName() << "' descendents corrupted, fetch failed." << LL_ENDL;
 		// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
 		// that the cat just doesn't have any items or subfolders).
 		// Unrecoverable, so just return done so that this observer can be cleared
@@ -411,7 +411,7 @@ BOOL LLInventoryFetchDescendentsObserver::isCategoryComplete(const LLViewerInven
 	// count and thus the category thinks it has fewer descendents than it actually has.
 	if (current_num_known_descendents >= expected_num_descendents)
 	{
-		llwarns << "Category '" << cat->getName() << "' expected descendentcount:" << expected_num_descendents << " descendents but got descendentcount:" << current_num_known_descendents << llendl;
+		LL_WARNS() << "Category '" << cat->getName() << "' expected descendentcount:" << expected_num_descendents << " descendents but got descendentcount:" << current_num_known_descendents << LL_ENDL;
 		const_cast<LLViewerInventoryCategory *>(cat)->setDescendentCount(current_num_known_descendents);
 		return TRUE;
 	}
@@ -714,7 +714,7 @@ void LLInventoryCategoriesObserver::changed(U32 mask)
 		gInventory.getDirectDescendentsOf(cat_id, cats, items);
 		if (!cats || !items)
 		{
-			llwarns << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << llendl;
+			LL_WARNS() << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << LL_ENDL;
 			// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
 			// that the cat just doesn't have any items or subfolders).
 			// Unrecoverable, so just skip this category.
@@ -781,7 +781,7 @@ bool LLInventoryCategoriesObserver::addCategory(const LLUUID& cat_id, callback_t
 		gInventory.getDirectDescendentsOf(cat_id, cats, items);
 		if (!cats || !items)
 		{
-			llwarns << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << llendl;
+			LL_WARNS() << "Category '" << category->getName() << "' descendents corrupted, fetch failed." << LL_ENDL;
 			// NULL means the call failed -- cats/items map doesn't exist (note: this does NOT mean
 			// that the cat just doesn't have any items or subfolders).
 			// Unrecoverable, so just return "false" meaning that the category can't be observed.
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 8190887ba6..7239a7e850 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -590,7 +590,7 @@ LLUUID LLInventoryPanel::getRootFolderID()
 				root_id = gInventory.findCategoryUUIDForType(preferred_type, false);
 				if (root_id.isNull())
 				{
-					llwarns << "Could not find folder of type " << preferred_type << llendl;
+					LL_WARNS() << "Could not find folder of type " << preferred_type << LL_ENDL;
 					root_id.generateNewID();
 				}
 			}
@@ -757,9 +757,9 @@ LLFolderViewItem* LLInventoryPanel::buildNewViews(const LLUUID& id)
   			if (objectp->getType() <= LLAssetType::AT_NONE ||
   				objectp->getType() >= LLAssetType::AT_COUNT)
   			{
-  				llwarns << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : "
+  				LL_WARNS() << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : "
   						<< ((S32) objectp->getType()) << " name " << objectp->getName() << " UUID " << objectp->getUUID()
-  						<< llendl;
+  						<< LL_ENDL;
   				return NULL;
   			}
   		
@@ -1161,7 +1161,7 @@ LLInventoryPanel* LLInventoryPanel::getActiveInventoryPanel(BOOL auto_open)
 	LLFloater* floater_inventory = LLFloaterReg::getInstance("inventory");
 	if (!floater_inventory)
 	{
-		llwarns << "Could not find My Inventory floater" << llendl;
+		LL_WARNS() << "Could not find My Inventory floater" << LL_ENDL;
 		return FALSE;
 	}
 
diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp
index 3d1f186bba..d38f90015e 100755
--- a/indra/newview/lljoystickbutton.cpp
+++ b/indra/newview/lljoystickbutton.cpp
@@ -121,7 +121,7 @@ void LLJoystick::updateSlop()
 		break;
 
 	default:
-		llerrs << "LLJoystick::LLJoystick() - bad switch case" << llendl;
+		LL_ERRS() << "LLJoystick::LLJoystick() - bad switch case" << LL_ENDL;
 		break;
 	}
 
@@ -132,7 +132,7 @@ bool LLJoystick::pointInCircle(S32 x, S32 y) const
 { 
 	if(this->getLocalRect().getHeight() != this->getLocalRect().getWidth())
 	{
-		llwarns << "Joystick shape is not square"<<llendl;
+		LL_WARNS() << "Joystick shape is not square"<<LL_ENDL;
 		return true;
 	}
 	//center is x and y coordinates of center of joystick circle, and also its radius
@@ -143,7 +143,7 @@ bool LLJoystick::pointInCircle(S32 x, S32 y) const
 
 BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask)
 {
-	//llinfos << "joystick mouse down " << x << ", " << y << llendl;
+	//LL_INFOS() << "joystick mouse down " << x << ", " << y << LL_ENDL;
 	bool handles = false;
 
 	if(pointInCircle(x, y))
@@ -160,7 +160,7 @@ BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask)
 
 BOOL LLJoystick::handleMouseUp(S32 x, S32 y, MASK mask)
 {
-	// llinfos << "joystick mouse up " << x << ", " << y << llendl;
+	// LL_INFOS() << "joystick mouse up " << x << ", " << y << LL_ENDL;
 
 	if( hasMouseCapture() )
 	{
@@ -271,7 +271,7 @@ void LLJoystickAgentTurn::onHeldDown()
 	F32 time = getElapsedHeldDownTime();
 	updateSlop();
 
-	//llinfos << "move forward/backward (and/or turn)" << llendl;
+	//LL_INFOS() << "move forward/backward (and/or turn)" << LL_ENDL;
 
 	S32 dx = mLastMouse.mX - mFirstMouse.mX + mInitialOffset.mX;
 	S32 dy = mLastMouse.mY - mFirstMouse.mY + mInitialOffset.mY;
@@ -353,7 +353,7 @@ void LLJoystickAgentSlide::onMouseUp()
 
 void LLJoystickAgentSlide::onHeldDown()
 {
-	//llinfos << "slide left/right (and/or move forward/backward)" << llendl;
+	//LL_INFOS() << "slide left/right (and/or move forward/backward)" << LL_ENDL;
 
 	updateSlop();
 
@@ -504,7 +504,7 @@ F32 LLJoystickCameraRotate::getOrbitRate()
 	if( time < NUDGE_TIME )
 	{
 		F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME;
-		//llinfos << rate << llendl;
+		//LL_INFOS() << rate << LL_ENDL;
 		return rate;
 	}
 	else
diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp
index 6625a194fb..f893daaeb2 100755
--- a/indra/newview/lllandmarkactions.cpp
+++ b/indra/newview/lllandmarkactions.cpp
@@ -233,7 +233,7 @@ bool LLLandmarkActions::canCreateLandmarkHere()
 	LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
 	if(!agent_parcel)
 	{
-		llwarns << "No agent region" << llendl;
+		LL_WARNS() << "No agent region" << LL_ENDL;
 		return false;
 	}
 	if (agent_parcel->getAllowLandmark()
@@ -252,13 +252,13 @@ void LLLandmarkActions::createLandmarkHere(
 {
 	if(!gAgent.getRegion())
 	{
-		llwarns << "No agent region" << llendl;
+		LL_WARNS() << "No agent region" << LL_ENDL;
 		return;
 	}
 	LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
 	if (!agent_parcel)
 	{
-		llwarns << "No agent parcel" << llendl;
+		LL_WARNS() << "No agent parcel" << LL_ENDL;
 		return;
 	}
 	if (!canCreateLandmarkHere())
diff --git a/indra/newview/lllandmarklist.cpp b/indra/newview/lllandmarklist.cpp
index 2a131eff58..8e0db738fb 100755
--- a/indra/newview/lllandmarklist.cpp
+++ b/indra/newview/lllandmarklist.cpp
@@ -141,7 +141,7 @@ void LLLandmarkList::processGetAssetReply(
 	}
 	else
 	{
-		// SJB: No use case for a notification here. Use lldebugs instead
+		// SJB: No use case for a notification here. Use LL_DEBUGS() instead
 		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
 		{
 			LL_WARNS("Landmarks") << "Missing Landmark" << LL_ENDL;
@@ -174,7 +174,7 @@ void LLLandmarkList::onRegionHandle(const LLUUID& landmark_id)
 
 	if (!landmark)
 	{
-		llwarns << "Got region handle but the landmark not found." << llendl;
+		LL_WARNS() << "Got region handle but the landmark not found." << LL_ENDL;
 		return;
 	}
 
@@ -183,7 +183,7 @@ void LLLandmarkList::onRegionHandle(const LLUUID& landmark_id)
 	LLVector3d pos;
 	if (!landmark->getGlobalPos(pos))
 	{
-		llwarns << "Got region handle but the landmark global position is still unknown." << llendl;
+		LL_WARNS() << "Got region handle but the landmark global position is still unknown." << LL_ENDL;
 		return;
 	}
 
@@ -196,7 +196,7 @@ void LLLandmarkList::makeCallbacks(const LLUUID& landmark_id)
 
 	if (!landmark)
 	{
-		llwarns << "Landmark to make callbacks for not found." << llendl;
+		LL_WARNS() << "Landmark to make callbacks for not found." << LL_ENDL;
 	}
 
 	// make all the callbacks here.
diff --git a/indra/newview/lllistcontextmenu.cpp b/indra/newview/lllistcontextmenu.cpp
index 6421ab42bf..a624c9fb87 100755
--- a/indra/newview/lllistcontextmenu.cpp
+++ b/indra/newview/lllistcontextmenu.cpp
@@ -80,7 +80,7 @@ void LLListContextMenu::show(LLView* spawning_view, const uuid_vec_t& uuids, S32
 	menup = createMenu();
 	if (!menup)
 	{
-		llwarns << "Context menu creation failed" << llendl;
+		LL_WARNS() << "Context menu creation failed" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp
index 8b088da12e..1948475530 100755
--- a/indra/newview/lllocalbitmaps.cpp
+++ b/indra/newview/lllocalbitmaps.cpp
@@ -111,8 +111,8 @@ LLLocalBitmap::LLLocalBitmap(std::string filename)
 	}
 	else
 	{
-		llwarns << "File of no valid extension given, local bitmap creation aborted." << "\n"
-			    << "Filename: " << mFilename << llendl;
+		LL_WARNS() << "File of no valid extension given, local bitmap creation aborted." << "\n"
+			    << "Filename: " << mFilename << LL_ENDL;
 		return; // no valid extension.
 	}
 
@@ -231,10 +231,10 @@ bool LLLocalBitmap::updateSelf(EUpdateType optional_firstupdate)
 					}
 					else
 					{
-						llwarns << "During the update process the following file was found" << "\n"
+						LL_WARNS() << "During the update process the following file was found" << "\n"
 							    << "but could not be opened or decoded for " << LL_LOCAL_UPDATE_RETRIES << " attempts." << "\n"
 								<< "Filename: " << mFilename << "\n"
-								<< "Disabling further update attempts for this file." << llendl;
+								<< "Disabling further update attempts for this file." << LL_ENDL;
 
 						LLSD notif_args;
 						notif_args["FNAME"] = mFilename;
@@ -250,9 +250,9 @@ bool LLLocalBitmap::updateSelf(EUpdateType optional_firstupdate)
 
 		else
 		{
-			llwarns << "During the update process, the following file was not found." << "\n" 
+			LL_WARNS() << "During the update process, the following file was not found." << "\n" 
 			        << "Filename: " << mFilename << "\n"
-				    << "Disabling further update attempts for this file." << llendl;
+				    << "Disabling further update attempts for this file." << LL_ENDL;
 
 			LLSD notif_args;
 			notif_args["FNAME"] = mFilename;
@@ -318,13 +318,13 @@ bool LLLocalBitmap::decodeBitmap(LLPointer<LLImageRaw> rawimg)
 
 		default:
 		{
-			// separating this into -several- llwarns calls because in the extremely unlikely case that this happens
+			// separating this into -several- LL_WARNS() calls because in the extremely unlikely case that this happens
 			// accessing mFilename and any other object properties might very well crash the viewer.
 			// getting here should be impossible, or there's been a pretty serious bug.
 
-			llwarns << "During a decode attempt, the following local bitmap had no properly assigned extension." << llendl;
-			llwarns << "Filename: " << mFilename << llendl;
-		    llwarns << "Disabling further update attempts for this file." << llendl;
+			LL_WARNS() << "During a decode attempt, the following local bitmap had no properly assigned extension." << LL_ENDL;
+			LL_WARNS() << "Filename: " << mFilename << LL_ENDL;
+		    LL_WARNS() << "Disabling further update attempts for this file." << LL_ENDL;
 			mLinkStatus = LS_BROKEN;
 		}
 	}
@@ -337,8 +337,8 @@ void LLLocalBitmap::replaceIDs(LLUUID old_id, LLUUID new_id)
 	// checking for misuse.
 	if (old_id == new_id)
 	{
-		llinfos << "An attempt was made to replace a texture with itself. (matching UUIDs)" << "\n"
-			    << "Texture UUID: " << old_id.asString() << llendl;
+		LL_INFOS() << "An attempt was made to replace a texture with itself. (matching UUIDs)" << "\n"
+			    << "Texture UUID: " << old_id.asString() << LL_ENDL;
 		return;
 	}
 
@@ -769,11 +769,11 @@ LLAvatarAppearanceDefines::ETextureIndex LLLocalBitmap::getTexIndex(
 
 		default:
 		{
-			llwarns << "Unknown wearable type: " << (int)type << "\n"
+			LL_WARNS() << "Unknown wearable type: " << (int)type << "\n"
 				    << "Baked Texture Index: " << (int)baked_texind << "\n"
 					<< "Filename: " << mFilename << "\n"
 					<< "TrackingID: " << mTrackingID << "\n"
-					<< "InworldID: " << mWorldID << llendl;
+					<< "InworldID: " << mWorldID << LL_ENDL;
 		}
 
 	}
@@ -845,8 +845,8 @@ bool LLLocalBitmapMgr::addUnit()
 			}
 			else
 			{
-				llwarns << "Attempted to add invalid or unreadable image file, attempt cancelled.\n"
-					    << "Filename: " << filename << llendl;
+				LL_WARNS() << "Attempted to add invalid or unreadable image file, attempt cancelled.\n"
+					    << "Filename: " << filename << LL_ENDL;
 
 				LLSD notif_args;
 				notif_args["FNAME"] = filename;
diff --git a/indra/newview/lllocationhistory.cpp b/indra/newview/lllocationhistory.cpp
index 5138c5e620..680b35b550 100755
--- a/indra/newview/lllocationhistory.cpp
+++ b/indra/newview/lllocationhistory.cpp
@@ -107,11 +107,11 @@ bool LLLocationHistory::getMatchingItems(const std::string& substring, location_
 
 void LLLocationHistory::dump() const
 {
-	llinfos << "Location history dump:" << llendl;
+	LL_INFOS() << "Location history dump:" << LL_ENDL;
 	int i = 0;
 	for (location_list_t::const_iterator it = mItems.begin(); it != mItems.end(); ++it, ++i)
 	{
-	    llinfos << "#" << std::setw(2) << std::setfill('0') << i << ": " << it->getLocation() << llendl;
+	    LL_INFOS() << "#" << std::setw(2) << std::setfill('0') << i << ": " << it->getLocation() << LL_ENDL;
 	}
 }
 
@@ -122,7 +122,7 @@ void LLLocationHistory::save() const
 
 	if (resolved_filename.empty())
 	{
-		llinfos << "can't get path to location history filename - probably not logged in yet." << llendl;
+		LL_INFOS() << "can't get path to location history filename - probably not logged in yet." << LL_ENDL;
 		return;
 	}
 
@@ -130,7 +130,7 @@ void LLLocationHistory::save() const
 	llofstream file (resolved_filename);
 	if (!file.is_open())
 	{
-		llwarns << "can't open location history file \"" << mFilename << "\" for writing" << llendl;
+		LL_WARNS() << "can't open location history file \"" << mFilename << "\" for writing" << LL_ENDL;
 		return;
 	}
 
@@ -144,7 +144,7 @@ void LLLocationHistory::save() const
 
 void LLLocationHistory::load()
 {
-	llinfos << "Loading location history." << llendl;
+	LL_INFOS() << "Loading location history." << LL_ENDL;
 	
 	// build filename for each user
 	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, mFilename);
@@ -152,7 +152,7 @@ void LLLocationHistory::load()
 
 	if (!file.is_open())
 	{
-		llwarns << "can't load location history from file \"" << mFilename << "\"" << llendl;
+		LL_WARNS() << "can't load location history from file \"" << mFilename << "\"" << LL_ENDL;
 		return;
 	}
 	
@@ -166,7 +166,7 @@ void LLLocationHistory::load()
 		std::istringstream iss(line);
 		if (parser->parse(iss, s_item, line.length()) == LLSDParser::PARSE_FAILURE)
 		{
-			llinfos<< "Parsing saved teleport history failed" << llendl;
+			LL_INFOS()<< "Parsing saved teleport history failed" << LL_ENDL;
 			break;
 		}
 
diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp
index 5022dba934..a6bd666b08 100755
--- a/indra/newview/lllocationinputctrl.cpp
+++ b/indra/newview/lllocationinputctrl.cpp
@@ -384,7 +384,7 @@ LLLocationInputCtrl::LLLocationInputCtrl(const LLLocationInputCtrl::Params& p)
 	mLocationContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_navbar.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 	if (!mLocationContextMenu)
 	{
-		llwarns << "Error loading navigation bar context menu" << llendl;
+		LL_WARNS() << "Error loading navigation bar context menu" << LL_ENDL;
 		
 	}
 	getTextEntry()->setRightMouseUpCallback(boost::bind(&LLLocationInputCtrl::onTextEditorRightClicked,this,_2,_3,_4));
@@ -777,7 +777,7 @@ void LLLocationInputCtrl::refreshLocation()
 	    (mTextEntry && mTextEntry->hasFocus()) ||
 	    (mAddLandmarkBtn->hasFocus()))
 	{
-		llwarns << "Location input should not be refreshed when having focus" << llendl;
+		LL_WARNS() << "Location input should not be refreshed when having focus" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index 60272749ff..e8424d840a 100755
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -300,7 +300,7 @@ void LLLogChat::saveHistory(const std::string& filename,
 	llofstream file (LLLogChat::makeLogFileName(filename), std::ios_base::app);
 	if (!file.is_open())
 	{
-		llwarns << "Couldn't open chat history log! - " + filename << llendl;
+		LL_WARNS() << "Couldn't open chat history log! - " + filename << LL_ENDL;
 		return;
 	}
 
@@ -337,7 +337,7 @@ void LLLogChat::loadChatHistory(const std::string& file_name, std::list<LLSD>& m
 {
 	if (file_name.empty())
 	{
-		llwarns << "Session name is Empty!" << llendl;
+		LL_WARNS() << "Session name is Empty!" << LL_ENDL;
 		return ;
 	}
 
diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp
index f681c12747..df59283bc4 100755
--- a/indra/newview/lllogininstance.cpp
+++ b/indra/newview/lllogininstance.cpp
@@ -202,7 +202,7 @@ MandatoryUpdateMachine::MandatoryUpdateMachine(LLLoginInstance & loginInstance,
 
 void MandatoryUpdateMachine::start(void)
 {
-	llinfos << "starting mandatory update machine" << llendl;
+	LL_INFOS() << "starting mandatory update machine" << LL_ENDL;
 	
 	if(mUpdaterService.isChecking()) {
 		switch(mUpdaterService.getState()) {
@@ -268,7 +268,7 @@ MandatoryUpdateMachine::CheckingForUpdate::CheckingForUpdate(MandatoryUpdateMach
 
 void MandatoryUpdateMachine::CheckingForUpdate::enter(void)
 {
-	llinfos << "entering checking for update" << llendl;
+	LL_INFOS() << "entering checking for update" << LL_ENDL;
 	
 	mProgressView = gViewerWindow->getProgressView();
 	mProgressView->setMessage("Looking for update...");
@@ -327,7 +327,7 @@ MandatoryUpdateMachine::Error::Error(MandatoryUpdateMachine & machine):
 
 void MandatoryUpdateMachine::Error::enter(void)
 {
-	llinfos << "entering error" << llendl;
+	LL_INFOS() << "entering error" << LL_ENDL;
 	LLNotificationsUtil::add("FailedRequiredUpdateInstall", LLSD(), LLSD(), boost::bind(&MandatoryUpdateMachine::Error::onButtonClicked, this, _1, _2));
 }
 
@@ -358,7 +358,7 @@ MandatoryUpdateMachine::ReadyToInstall::ReadyToInstall(MandatoryUpdateMachine &
 
 void MandatoryUpdateMachine::ReadyToInstall::enter(void)
 {
-	llinfos << "entering ready to install" << llendl;
+	LL_INFOS() << "entering ready to install" << LL_ENDL;
 	// Open update ready dialog.
 }
 
@@ -383,7 +383,7 @@ MandatoryUpdateMachine::StartingUpdaterService::StartingUpdaterService(Mandatory
 
 void MandatoryUpdateMachine::StartingUpdaterService::enter(void)
 {
-	llinfos << "entering start update service" << llendl;
+	LL_INFOS() << "entering start update service" << LL_ENDL;
 	LLNotificationsUtil::add("UpdaterServiceNotRunning", LLSD(), LLSD(), boost::bind(&MandatoryUpdateMachine::StartingUpdaterService::onButtonClicked, this, _1, _2));
 }
 
@@ -420,7 +420,7 @@ MandatoryUpdateMachine::WaitingForDownload::WaitingForDownload(MandatoryUpdateMa
 
 void MandatoryUpdateMachine::WaitingForDownload::enter(void)
 {
-	llinfos << "entering waiting for download" << llendl;
+	LL_INFOS() << "entering waiting for download" << LL_ENDL;
 	mProgressView = gViewerWindow->getProgressView();
 	mProgressView->setMessage("Downloading update...");
 	std::ostringstream stream;
@@ -589,7 +589,7 @@ void LLLoginInstance::constructAuthParams(LLPointer<LLCredential> user_credentia
 	unsigned char hashed_unique_id_string[MD5HEX_STR_SIZE];
 	if ( ! llHashedUniqueID(hashed_unique_id_string) )
 	{
-		llwarns << "Not providing a unique id in request params" << llendl;
+		LL_WARNS() << "Not providing a unique id in request params" << LL_ENDL;
 	}
 	request_params["start"] = construct_start_string();
 	request_params["skipoptional"] = mSkipOptionalUpdate;
@@ -621,7 +621,7 @@ bool LLLoginInstance::handleLoginEvent(const LLSD& event)
 
 	if(!(event.has("state") && event.has("change") && event.has("progress")))
 	{
-		llerrs << "Unknown message from LLLogin: " << event << llendl;
+		LL_ERRS() << "Unknown message from LLLogin: " << event << LL_ENDL;
 	}
 
 	mLoginState = event["state"].asString();
@@ -656,7 +656,7 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event)
 	// to reconnect or to end the attempt in failure.
 	if(reason_response == "tos")
 	{
-		llinfos << "LLLoginInstance::handleLoginFailure ToS" << llendl;
+		LL_INFOS() << "LLLoginInstance::handleLoginFailure ToS" << LL_ENDL;
 
 		LLSD data(LLSD::emptyMap());
 		data["message"] = message_response;
@@ -671,7 +671,7 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event)
 	}
 	else if(reason_response == "critical")
 	{
-		llinfos << "LLLoginInstance::handleLoginFailure Crit" << llendl;
+		LL_INFOS() << "LLLoginInstance::handleLoginFailure Crit" << LL_ENDL;
 
 		LLSD data(LLSD::emptyMap());
 		data["message"] = message_response;
@@ -696,27 +696,27 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event)
 	}
 	else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate"))
 	{
-		llinfos << "LLLoginInstance::handleLoginFailure update" << llendl;
+		LL_INFOS() << "LLLoginInstance::handleLoginFailure update" << LL_ENDL;
 
 		gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE);
 		updateApp(true, message_response);
 	}
 	else if(reason_response == "optional")
 	{
-		llinfos << "LLLoginInstance::handleLoginFailure optional" << llendl;
+		LL_INFOS() << "LLLoginInstance::handleLoginFailure optional" << LL_ENDL;
 
 		updateApp(false, message_response);
 	}
 	else
 	{	
-		llinfos << "LLLoginInstance::handleLoginFailure attemptComplete" << llendl;
+		LL_INFOS() << "LLLoginInstance::handleLoginFailure attemptComplete" << LL_ENDL;
 		attemptComplete();
 	}	
 }
 
 void LLLoginInstance::handleLoginSuccess(const LLSD& event)
 {
-	llinfos << "LLLoginInstance::handleLoginSuccess" << llendl;
+	LL_INFOS() << "LLLoginInstance::handleLoginSuccess" << LL_ENDL;
 
 	if(gSavedSettings.getBOOL("ForceMandatoryUpdate"))
 	{
@@ -740,7 +740,7 @@ void LLLoginInstance::handleDisconnect(const LLSD& event)
 {
     // placeholder
 
-	llinfos << "LLLoginInstance::handleDisconnect placeholder " << llendl;
+	LL_INFOS() << "LLLoginInstance::handleDisconnect placeholder " << LL_ENDL;
 }
 
 void LLLoginInstance::handleIndeterminate(const LLSD& event)
@@ -754,7 +754,7 @@ void LLLoginInstance::handleIndeterminate(const LLSD& event)
 	LLSD message = event.get("data").get("message");
 	if(message.isDefined())
 	{
-		llinfos << "LLLoginInstance::handleIndeterminate " << message.asString() << llendl;
+		LL_INFOS() << "LLLoginInstance::handleIndeterminate " << message.asString() << LL_ENDL;
 
 		LLSD progress_update;
 		progress_update["desc"] = message;
@@ -766,7 +766,7 @@ bool LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key)
 {
 	if(accepted)
 	{	
-		llinfos << "LLLoginInstance::handleTOSResponse: accepted" << llendl;
+		LL_INFOS() << "LLLoginInstance::handleTOSResponse: accepted" << LL_ENDL;
 
 		// Set the request data to true and retry login.
 		mRequestData["params"][key] = true; 
@@ -774,7 +774,7 @@ bool LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key)
 	}
 	else
 	{
-		llinfos << "LLLoginInstance::handleTOSResponse: attemptComplete" << llendl;
+		LL_INFOS() << "LLLoginInstance::handleTOSResponse: attemptComplete" << LL_ENDL;
 
 		attemptComplete();
 	}
diff --git a/indra/newview/llmainlooprepeater.cpp b/indra/newview/llmainlooprepeater.cpp
index 5c020e6d98..db8d2e4ede 100755
--- a/indra/newview/llmainlooprepeater.cpp
+++ b/indra/newview/llmainlooprepeater.cpp
@@ -81,7 +81,7 @@ bool LLMainLoopRepeater::onMessage(LLSD const & event)
 	try {
 		mQueue->pushFront(event);
 	} catch(LLThreadSafeQueueError & e) {
-		llwarns << "could not repeat message (" << e.what() << ")" << 
+		LL_WARNS() << "could not repeat message (" << e.what() << ")" << 
 			event.asString() << LL_ENDL;
 	}
 	return false;
diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp
index edb2d5e024..bbcdcb126d 100755
--- a/indra/newview/llmanip.cpp
+++ b/indra/newview/llmanip.cpp
@@ -226,11 +226,11 @@ BOOL LLManip::handleHover(S32 x, S32 y, MASK mask)
 			setMouseCapture( FALSE );
 		}
 
-		LL_DEBUGS("UserInput") << "hover handled by LLManip (active)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLManip (active)" << LL_ENDL;
 	}
 	else
 	{
-		LL_DEBUGS("UserInput") << "hover handled by LLManip (inactive)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLManip (inactive)" << LL_ENDL;
 	}
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);
 	return TRUE;
diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp
index e2be3331ed..224bfe3a17 100755
--- a/indra/newview/llmaniprotate.cpp
+++ b/indra/newview/llmaniprotate.cpp
@@ -519,12 +519,12 @@ BOOL LLManipRotate::handleHover(S32 x, S32 y, MASK mask)
 			drag(x, y);
 		}
 
-		LL_DEBUGS("UserInput") << "hover handled by LLManipRotate (active)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipRotate (active)" << LL_ENDL;		
 	}
 	else
 	{
 		highlightManipulators(x, y);
-		LL_DEBUGS("UserInput") << "hover handled by LLManipRotate (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipRotate (inactive)" << LL_ENDL;		
 	}
 
 	gViewerWindow->setCursor(UI_CURSOR_TOOLROTATE);
@@ -1272,9 +1272,9 @@ LLVector3 LLManipRotate::getConstraintAxis()
 		else
 		{
 #ifndef LL_RELEASE_FOR_DOWNLOAD
-			llerrs << "Got bogus hit part in LLManipRotate::getConstraintAxis():" << mManipPart << llendl;
+			LL_ERRS() << "Got bogus hit part in LLManipRotate::getConstraintAxis():" << mManipPart << LL_ENDL;
 #else
-			llwarns << "Got bogus hit part in LLManipRotate::getConstraintAxis():" << mManipPart << llendl;
+			LL_WARNS() << "Got bogus hit part in LLManipRotate::getConstraintAxis():" << mManipPart << LL_ENDL;
 #endif
 			axis.mV[0] = 1.f;
 		}
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index b4348f2a0e..a63f6f424c 100755
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -413,7 +413,7 @@ BOOL LLManipScale::handleHover(S32 x, S32 y, MASK mask)
 		{
 			drag( x, y );
 		}
-		LL_DEBUGS("UserInput") << "hover handled by LLManipScale (active)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipScale (active)" << LL_ENDL;		
 	}
 	else
 	{
@@ -524,7 +524,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
 				{
 					mHighlightedPart = manipulator->mManipID;
 
-					//llinfos << "Tried: " << mHighlightedPart << llendl;
+					//LL_INFOS() << "Tried: " << mHighlightedPart << LL_ENDL;
 					break;
 				}
 			}
@@ -543,7 +543,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
 		}
 	}
 
-	LL_DEBUGS("UserInput") << "hover handled by LLManipScale (inactive)" << llendl;
+	LL_DEBUGS("UserInput") << "hover handled by LLManipScale (inactive)" << LL_ENDL;
 }
 
 
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index cfea8a3330..3cccfaf13a 100755
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -355,7 +355,7 @@ BOOL LLManipTranslate::handleMouseDownOnPart( S32 x, S32 y, MASK mask )
 	if (!selectNode)
 	{
 		// didn't find the object in our selection...oh well
-		llwarns << "Trying to translate an unselected object" << llendl;
+		LL_WARNS() << "Trying to translate an unselected object" << LL_ENDL;
 		return TRUE;
 	}
 
@@ -363,7 +363,7 @@ BOOL LLManipTranslate::handleMouseDownOnPart( S32 x, S32 y, MASK mask )
 	if (!selected_object)
 	{
 		// somehow we lost the object!
-		llwarns << "Translate manip lost the object, no selected object" << llendl;
+		LL_WARNS() << "Translate manip lost the object, no selected object" << LL_ENDL;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
@@ -384,7 +384,7 @@ BOOL LLManipTranslate::handleMouseDownOnPart( S32 x, S32 y, MASK mask )
 		if (!LLViewerCamera::getInstance()->projectPosAgentToScreen(select_center_agent, mouse_pos))
 		{
 			// mouse_pos may be nonsense
-			llwarns << "Failed to project object center to screen" << llendl;
+			LL_WARNS() << "Failed to project object center to screen" << LL_ENDL;
 		}
 		else if (gSavedSettings.getBOOL("SnapToMouseCursor"))
 		{
@@ -412,7 +412,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	// Bail out if mouse not down.
 	if( !hasMouseCapture() )
 	{
-		LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (inactive)" << LL_ENDL;		
 		// Always show cursor
 		// gViewerWindow->setCursor(UI_CURSOR_ARROW);
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
@@ -448,7 +448,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	// rotation above.
 	if( x == mLastHoverMouseX && y == mLastHoverMouseY && !rotated)
 	{
-		LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (mouse unmoved)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (mouse unmoved)" << LL_ENDL;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
@@ -461,7 +461,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	{
 		if (abs(mMouseDownX - x) < MOUSE_DRAG_SLOP && abs(mMouseDownY - y) < MOUSE_DRAG_SLOP )
 		{
-			LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (mouse inside slop)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (mouse inside slop)" << LL_ENDL;
 			gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 			return TRUE;
 		}
@@ -478,7 +478,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 
 				// When we make the copy, we don't want to do any other processing.
 				// If so, the object will also be moved, and the copy will be offset.
-				LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (made copy)" << llendl;
+				LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (made copy)" << LL_ENDL;
 				gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 			}
 		}
@@ -495,7 +495,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	if (!selectNode)
 	{
 		// somehow we lost the object!
-		llwarns << "Translate manip lost the object, no selectNode" << llendl;
+		LL_WARNS() << "Translate manip lost the object, no selectNode" << LL_ENDL;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
@@ -504,7 +504,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	if (!object)
 	{
 		// somehow we lost the object!
-		llwarns << "Translate manip lost the object, no object in selectNode" << llendl;
+		LL_WARNS() << "Translate manip lost the object, no object in selectNode" << LL_ENDL;
 		gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 		return TRUE;
 	}
@@ -531,7 +531,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 
 		if (relative_move.magVecSquared() > max_drag_distance * max_drag_distance)
 		{
-			LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (too far)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (too far)" << LL_ENDL;
 			gViewerWindow->setCursor(UI_CURSOR_NOLOCKED);
 			return TRUE;
 		}
@@ -776,7 +776,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 	gAgentCamera.clearFocusObject();
 	dialog_refresh_all();		// ??? is this necessary?
 
-	LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (active)" << llendl;
+	LL_DEBUGS("UserInput") << "hover handled by LLManipTranslate (active)" << LL_ENDL;
 	gViewerWindow->setCursor(UI_CURSOR_TOOLTRANSLATE);
 	return TRUE;
 }
@@ -2250,7 +2250,7 @@ void LLManipTranslate::renderArrow(S32 which_arrow, S32 selected_arrow, F32 box_
 			axis.mV[0] = 1.0f;
 			break;
 		default:
-			llerrs << "renderArrow called with bad arrow " << which_arrow << llendl;
+			LL_ERRS() << "renderArrow called with bad arrow " << which_arrow << LL_ENDL;
 			break;
 		}
 
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index 0b009b68f7..83946a45cd 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -132,11 +132,11 @@ namespace LLMarketplaceImport
 
 			if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
 			{
-				llinfos << " SLM POST status: " << status << llendl;
-				llinfos << " SLM POST reason: " << reason << llendl;
-				llinfos << " SLM POST content: " << content.asString() << llendl;
+				LL_INFOS() << " SLM POST status: " << status << LL_ENDL;
+				LL_INFOS() << " SLM POST reason: " << reason << LL_ENDL;
+				LL_INFOS() << " SLM POST content: " << content.asString() << LL_ENDL;
 
-				llinfos << " SLM POST timer: " << slmPostTimer.getElapsedTimeF32() << llendl;
+				LL_INFOS() << " SLM POST timer: " << slmPostTimer.getElapsedTimeF32() << LL_ENDL;
 			}
 
 			if ((status == MarketplaceErrorCodes::IMPORT_REDIRECT) ||
@@ -145,7 +145,7 @@ namespace LLMarketplaceImport
 			{
 				if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
 				{
-					llinfos << " SLM POST clearing marketplace cookie due to authentication failure or timeout" << llendl;
+					LL_INFOS() << " SLM POST clearing marketplace cookie due to authentication failure or timeout" << LL_ENDL;
 				}
 
 				sMarketplaceCookie.clear();
@@ -179,11 +179,11 @@ namespace LLMarketplaceImport
 
 			if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
 			{
-				llinfos << " SLM GET status: " << status << llendl;
-				llinfos << " SLM GET reason: " << reason << llendl;
-				llinfos << " SLM GET content: " << content.asString() << llendl;
+				LL_INFOS() << " SLM GET status: " << status << LL_ENDL;
+				LL_INFOS() << " SLM GET reason: " << reason << LL_ENDL;
+				LL_INFOS() << " SLM GET content: " << content.asString() << LL_ENDL;
 
-				llinfos << " SLM GET timer: " << slmGetTimer.getElapsedTimeF32() << llendl;
+				LL_INFOS() << " SLM GET timer: " << slmGetTimer.getElapsedTimeF32() << LL_ENDL;
 			}
 			
 			if ((status == MarketplaceErrorCodes::IMPORT_AUTHENTICATION_ERROR) ||
@@ -191,7 +191,7 @@ namespace LLMarketplaceImport
 			{
 				if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
 				{
-					llinfos << " SLM GET clearing marketplace cookie due to authentication failure or timeout" << llendl;
+					LL_INFOS() << " SLM GET clearing marketplace cookie due to authentication failure or timeout" << LL_ENDL;
 				}
 
 				sMarketplaceCookie.clear();
@@ -256,7 +256,7 @@ namespace LLMarketplaceImport
 		
 		if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
 		{
-			llinfos << " SLM GET: " << url << llendl;
+			LL_INFOS() << " SLM GET: " << url << LL_ENDL;
 		}
 
 		slmGetTimer.start();
@@ -287,7 +287,7 @@ namespace LLMarketplaceImport
 		
 		if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
 		{
-			llinfos << " SLM GET: " << url << llendl;
+			LL_INFOS() << " SLM GET: " << url << LL_ENDL;
 		}
 
 		slmGetTimer.start();
@@ -321,7 +321,7 @@ namespace LLMarketplaceImport
 		
 		if (gSavedSettings.getBOOL("InventoryOutboxLogging"))
 		{
-			llinfos << " SLM POST: " << url << llendl;
+			LL_INFOS() << " SLM POST: " << url << LL_ENDL;
 		}
 
 		slmPostTimer.start();
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 9298d6952f..323445afa6 100755
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -424,7 +424,7 @@ BOOL LLMediaCtrl::handleKeyHere( KEY key, MASK mask )
 //
 void LLMediaCtrl::onVisibilityChange ( BOOL new_visibility )
 {
-	llinfos << "visibility changed to " << (new_visibility?"true":"false") << llendl;
+	LL_INFOS() << "visibility changed to " << (new_visibility?"true":"false") << LL_ENDL;
 	if(mMediaSource)
 	{
 		mMediaSource->setVisible( new_visibility );
@@ -548,7 +548,7 @@ void LLMediaCtrl::navigateTo( std::string url_in, std::string mime_type)
 	    (LLStringUtil::compareInsensitive(url_in.substr(0, protocol2.length()), protocol2) == 0))
 	{
 		// TODO: Print out/log this attempt?
-		// llinfos << "Rejecting attempt to load restricted website :" << urlIn << llendl;
+		// LL_INFOS() << "Rejecting attempt to load restricted website :" << urlIn << LL_ENDL;
 		return;
 	}
 	
@@ -569,7 +569,7 @@ void LLMediaCtrl::navigateToLocalPage( const std::string& subdir, const std::str
 
 	if (expanded_filename.empty())
 	{
-		llwarns << "File " << filename << "not found" << llendl;
+		LL_WARNS() << "File " << filename << "not found" << LL_ENDL;
 		return;
 	}
 	if (ensureMediaSourceExists())
@@ -677,7 +677,7 @@ bool LLMediaCtrl::ensureMediaSourceExists()
 		}
 		else
 		{
-			llwarns << "media source create failed " << llendl;
+			LL_WARNS() << "media source create failed " << LL_ENDL;
 			// return;
 		}
 	}
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 447b9d286f..84526d53ca 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -219,7 +219,7 @@ public:
 		{
 			if (!mProcessed)
 			{ //something went wrong, retry
-				llwarns << "Timeout or service unavailable, retrying." << llendl;
+				LL_WARNS() << "Timeout or service unavailable, retrying." << LL_ENDL;
 				LLMeshRepository::sHTTPRetryCount++;
 				LLMeshRepoThread::HeaderRequest req(mMeshParams);
 				LLMutexLock lock(gMeshRepo.mThread->mMutex);
@@ -258,7 +258,7 @@ public:
 		{
 			if (!mProcessed)
 			{
-				llwarns << "Killed without being processed, retrying." << llendl;
+				LL_WARNS() << "Killed without being processed, retrying." << LL_ENDL;
 				LLMeshRepository::sHTTPRetryCount++;
 				gMeshRepo.mThread->lockAndLoadMeshLOD(mMeshParams, mLOD);
 			}
@@ -359,16 +359,16 @@ void log_upload_error(S32 status, const LLSD& content, std::string stage, std::s
 	gMeshRepo.uploadError(args);
 
 	// Log details.
-	llwarns << "stage: " << stage << " http status: " << status << llendl;
+	LL_WARNS() << "stage: " << stage << " http status: " << status << LL_ENDL;
 	if (content.has("error"))
 	{
 		const LLSD& err = content["error"];
-		llwarns << "err: " << err << llendl;
-		llwarns << "mesh upload failed, stage '" << stage
+		LL_WARNS() << "err: " << err << LL_ENDL;
+		LL_WARNS() << "mesh upload failed, stage '" << stage
 				<< "' error '" << err["error"].asString()
 				<< "', message '" << err["message"].asString()
 				<< "', id '" << err["identifier"].asString()
-				<< "'" << llendl;
+				<< "'" << LL_ENDL;
 		if (err.has("errors"))
 		{
 			S32 error_num = 0;
@@ -378,13 +378,13 @@ void log_upload_error(S32 status, const LLSD& content, std::string stage, std::s
 				 ++it)
 			{
 				const LLSD& err_entry = *it;
-				llwarns << "error[" << error_num << "]:" << llendl;
+				LL_WARNS() << "error[" << error_num << "]:" << LL_ENDL;
 				for (LLSD::map_const_iterator map_it = err_entry.beginMap();
 					 map_it != err_entry.endMap();
 					 ++map_it)
 				{
-					llwarns << "\t" << map_it->first << ": "
-							<< map_it->second << llendl;
+					LL_WARNS() << "\t" << map_it->first << ": "
+							<< map_it->second << LL_ENDL;
 				}
 				error_num++;
 			}
@@ -392,7 +392,7 @@ void log_upload_error(S32 status, const LLSD& content, std::string stage, std::s
 	}
 	else
 	{
-		llwarns << "bad mesh, no error information available" << llendl;
+		LL_WARNS() << "bad mesh, no error information available" << LL_ENDL;
 	}
 }
 
@@ -448,7 +448,7 @@ public:
 		}
 		else
 		{
-			llwarns << "fee request failed" << llendl;
+			LL_WARNS() << "fee request failed" << LL_ENDL;
 			log_upload_error(status,cc,"fee",mModelData["name"]);
 			mThread->mWholeModelUploadURL = "";
 
@@ -516,7 +516,7 @@ public:
 		}
 		else
 		{
-			llwarns << "upload failed" << llendl;
+			LL_WARNS() << "upload failed" << LL_ENDL;
 			std::string model_name = mModelData["name"].asString();
 			log_upload_error(status,cc,"upload",model_name);
 
@@ -553,7 +553,7 @@ void LLMeshRepoThread::run()
 	LLCDResult res = LLConvexDecomposition::initThread();
 	if (res != LLCD_OK)
 	{
-		llwarns << "convex decomposition unable to be loaded" << llendl;
+		LL_WARNS() << "convex decomposition unable to be loaded" << LL_ENDL;
 	}
 
 	while (!LLApp::isQuitting())
@@ -662,7 +662,7 @@ void LLMeshRepoThread::run()
 	res = LLConvexDecomposition::quitThread();
 	if (res != LLCD_OK)
 	{
-		llwarns << "convex decomposition unable to be quit" << llendl;
+		LL_WARNS() << "convex decomposition unable to be quit" << LL_ENDL;
 	}
 
 	delete mCurlRequest;
@@ -742,7 +742,7 @@ std::string LLMeshRepoThread::constructUrl(LLUUID mesh_id)
 	}
 	else
 	{
-		llwarns << "Current region does not have GetMesh capability!  Cannot load " << mesh_id << ".mesh" << llendl;
+		LL_WARNS() << "Current region does not have GetMesh capability!  Cannot load " << mesh_id << ".mesh" << LL_ENDL;
 	}
 
 	return http_url;
@@ -1180,7 +1180,7 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat
 
 		if (!LLSDSerialize::fromBinary(header, stream, data_size))
 		{
-			llwarns << "Mesh header parse error.  Not a valid mesh asset!" << llendl;
+			LL_WARNS() << "Mesh header parse error.  Not a valid mesh asset!" << LL_ENDL;
 			return false;
 		}
 
@@ -1188,8 +1188,8 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat
 	}
 	else
 	{
-		llinfos
-			<< "Marking header as non-existent, will not retry." << llendl;
+		LL_INFOS()
+			<< "Marking header as non-existent, will not retry." << LL_ENDL;
 		header["404"] = 1;
 	}
 
@@ -1256,7 +1256,7 @@ bool LLMeshRepoThread::skinInfoReceived(const LLUUID& mesh_id, U8* data, S32 dat
 
 		if (!unzip_llsd(skin, stream, data_size))
 		{
-			llwarns << "Mesh skin info parse error.  Not a valid mesh asset!" << llendl;
+			LL_WARNS() << "Mesh skin info parse error.  Not a valid mesh asset!" << LL_ENDL;
 			return false;
 		}
 	}
@@ -1265,7 +1265,7 @@ bool LLMeshRepoThread::skinInfoReceived(const LLUUID& mesh_id, U8* data, S32 dat
 		LLMeshSkinInfo info(skin);
 		info.mMeshID = mesh_id;
 
-		//llinfos<<"info pelvis offset"<<info.mPelvisOffset<<llendl;
+		//LL_INFOS()<<"info pelvis offset"<<info.mPelvisOffset<<LL_ENDL;
 		mSkinInfoQ.push(info);
 	}
 
@@ -1284,7 +1284,7 @@ bool LLMeshRepoThread::decompositionReceived(const LLUUID& mesh_id, U8* data, S3
 
 		if (!unzip_llsd(decomp, stream, data_size))
 		{
-			llwarns << "Mesh decomposition parse error.  Not a valid mesh asset!" << llendl;
+			LL_WARNS() << "Mesh decomposition parse error.  Not a valid mesh asset!" << LL_ENDL;
 			return false;
 		}
 	}
@@ -1700,7 +1700,7 @@ void LLMeshUploadThread::doWholeModelUpload()
 
 	if (mWholeModelUploadURL.empty())
 	{
-		llinfos << "unable to upload, fee request failed" << llendl;
+		LL_INFOS() << "unable to upload, fee request failed" << LL_ENDL;
 	}
 	else
 	{
@@ -1914,21 +1914,21 @@ void LLMeshLODResponder::completedRaw(U32 status, const std::string& reason,
 
 	if (status < 200 || status > 400)
 	{
-		llwarns << status << ": " << reason << llendl;
+		LL_WARNS() << status << ": " << reason << LL_ENDL;
 	}
 
 	if (data_size < mRequestedBytes)
 	{
 		if (status == 499 || status == 503)
 		{ //timeout or service unavailable, try again
-			llwarns << "Timeout or service unavailable, retrying." << llendl;
+			LL_WARNS() << "Timeout or service unavailable, retrying." << LL_ENDL;
 			LLMeshRepository::sHTTPRetryCount++;
 			gMeshRepo.mThread->loadMeshLOD(mMeshParams, mLOD);
 		}
 		else
 		{
 			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
-			llwarns << "Unhandled status " << status << llendl;
+			LL_WARNS() << "Unhandled status " << status << LL_ENDL;
 		}
 		return;
 	}
@@ -1978,21 +1978,21 @@ void LLMeshSkinInfoResponder::completedRaw(U32 status, const std::string& reason
 
 	if (status < 200 || status > 400)
 	{
-		llwarns << status << ": " << reason << llendl;
+		LL_WARNS() << status << ": " << reason << LL_ENDL;
 	}
 
 	if (data_size < mRequestedBytes)
 	{
 		if (status == 499 || status == 503)
 		{ //timeout or service unavailable, try again
-			llwarns << "Timeout or service unavailable, retrying." << llendl;
+			LL_WARNS() << "Timeout or service unavailable, retrying." << LL_ENDL;
 			LLMeshRepository::sHTTPRetryCount++;
 			gMeshRepo.mThread->loadMeshSkinInfo(mMeshID);
 		}
 		else
 		{
 			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
-			llwarns << "Unhandled status " << status << llendl;
+			LL_WARNS() << "Unhandled status " << status << LL_ENDL;
 		}
 		return;
 	}
@@ -2041,21 +2041,21 @@ void LLMeshDecompositionResponder::completedRaw(U32 status, const std::string& r
 
 	if (status < 200 || status > 400)
 	{
-		llwarns << status << ": " << reason << llendl;
+		LL_WARNS() << status << ": " << reason << LL_ENDL;
 	}
 
 	if (data_size < mRequestedBytes)
 	{
 		if (status == 499 || status == 503)
 		{ //timeout or service unavailable, try again
-			llwarns << "Timeout or service unavailable, retrying." << llendl;
+			LL_WARNS() << "Timeout or service unavailable, retrying." << LL_ENDL;
 			LLMeshRepository::sHTTPRetryCount++;
 			gMeshRepo.mThread->loadMeshDecomposition(mMeshID);
 		}
 		else
 		{
 			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
-			llwarns << "Unhandled status " << status << llendl;
+			LL_WARNS() << "Unhandled status " << status << LL_ENDL;
 		}
 		return;
 	}
@@ -2105,21 +2105,21 @@ void LLMeshPhysicsShapeResponder::completedRaw(U32 status, const std::string& re
 
 	if (status < 200 || status > 400)
 	{
-		llwarns << status << ": " << reason << llendl;
+		LL_WARNS() << status << ": " << reason << LL_ENDL;
 	}
 
 	if (data_size < mRequestedBytes)
 	{
 		if (status == 499 || status == 503)
 		{ //timeout or service unavailable, try again
-			llwarns << "Timeout or service unavailable, retrying." << llendl;
+			LL_WARNS() << "Timeout or service unavailable, retrying." << LL_ENDL;
 			LLMeshRepository::sHTTPRetryCount++;
 			gMeshRepo.mThread->loadMeshPhysicsShape(mMeshID);
 		}
 		else
 		{
 			llassert(status == 499 || status == 503); //intentionally trigger a breakpoint
-			llwarns << "Unhandled status " << status << llendl;
+			LL_WARNS() << "Unhandled status " << status << LL_ENDL;
 		}
 		return;
 	}
@@ -2167,9 +2167,9 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
 
 	if (status < 200 || status > 400)
 	{
-		//llwarns
+		//LL_WARNS()
 		//	<< "Header responder failed with status: "
-		//	<< status << ": " << reason << llendl;
+		//	<< status << ": " << reason << LL_ENDL;
 
 		// 503 (service unavailable) or 499 (timeout)
 		// can be due to server load and can be retried
@@ -2182,7 +2182,7 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
 
 		if (status == 503 || status == 499)
 		{ //retry
-			llwarns << "Timeout or service unavailable, retrying." << llendl;
+			LL_WARNS() << "Timeout or service unavailable, retrying." << LL_ENDL;
 			LLMeshRepository::sHTTPRetryCount++;
 			LLMeshRepoThread::HeaderRequest req(mMeshParams);
 			LLMutexLock lock(gMeshRepo.mThread->mMutex);
@@ -2192,7 +2192,7 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
 		}
 		else
 		{
-			llwarns << "Unhandled status." << llendl;
+			LL_WARNS() << "Unhandled status." << LL_ENDL;
 		}
 	}
 
@@ -2214,9 +2214,9 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason,
 
 	if (!success)
 	{
-		llwarns
+		LL_WARNS()
 			<< "Unable to parse mesh header: "
-			<< status << ": " << reason << llendl;
+			<< status << ": " << reason << LL_ENDL;
 	}
 	else if (data && data_size > 0)
 	{
@@ -2310,11 +2310,11 @@ void LLMeshRepository::init()
 
 void LLMeshRepository::shutdown()
 {
-	llinfos << "Shutting down mesh repository." << llendl;
+	LL_INFOS() << "Shutting down mesh repository." << LL_ENDL;
 
 	for (U32 i = 0; i < mUploads.size(); ++i)
 	{
-		llinfos << "Discard the pending mesh uploads " << llendl;
+		LL_INFOS() << "Discard the pending mesh uploads " << LL_ENDL;
 		mUploads[i]->discard() ; //discard the uploading requests.
 	}
 
@@ -2329,7 +2329,7 @@ void LLMeshRepository::shutdown()
 
 	for (U32 i = 0; i < mUploads.size(); ++i)
 	{
-		llinfos << "Waiting for pending mesh upload " << i << "/" << mUploads.size() << llendl;
+		LL_INFOS() << "Waiting for pending mesh upload " << i << "/" << mUploads.size() << LL_ENDL;
 		while (!mUploads[i]->isStopped())
 		{
 			apr_sleep(10);
@@ -2342,7 +2342,7 @@ void LLMeshRepository::shutdown()
 	delete mMeshMutex;
 	mMeshMutex = NULL;
 
-	llinfos << "Shutting down decomposition system." << llendl;
+	LL_INFOS() << "Shutting down decomposition system." << LL_ENDL;
 
 	if (mDecompThread)
 	{
@@ -2688,7 +2688,7 @@ void LLMeshRepository::notifyMeshLoaded(const LLVolumeParams& mesh_params, LLVol
 		//make sure target volume is still valid
 		if (volume->getNumVolumeFaces() <= 0)
 		{
-			llwarns << "Mesh loading returned empty volume." << llendl;
+			LL_WARNS() << "Mesh loading returned empty volume." << LL_ENDL;
 		}
 		
 		{ //update system volume
@@ -2701,7 +2701,7 @@ void LLMeshRepository::notifyMeshLoaded(const LLVolumeParams& mesh_params, LLVol
 			}
 			else
 			{
-				llwarns << "Couldn't find system volume for given mesh." << llendl;
+				LL_WARNS() << "Couldn't find system volume for given mesh." << LL_ENDL;
 			}
 		}
 
@@ -3185,7 +3185,7 @@ void LLPhysicsDecomp::setMeshData(LLCDMeshData& mesh, bool vertex_based)
 
 		if (ret)
 		{
-			llerrs << "Convex Decomposition thread valid but could not set mesh data" << llendl;
+			LL_ERRS() << "Convex Decomposition thread valid but could not set mesh data" << LL_ENDL;
 		}
 	}
 }
@@ -3261,7 +3261,7 @@ void LLPhysicsDecomp::doDecomposition()
 
 	if (ret)
 	{
-		llwarns << "Convex Decomposition thread valid but could not execute stage " << stage << llendl;
+		LL_WARNS() << "Convex Decomposition thread valid but could not execute stage " << stage << LL_ENDL;
 		LLMutexLock lock(mMutex);
 
 		mCurRequest->mHull.clear();
@@ -3392,7 +3392,7 @@ void LLPhysicsDecomp::doDecompositionSingleHull()
 	LLCDResult ret = decomp->buildSingleHull() ;
 	if(ret)
 	{
-		llwarns << "Could not execute decomposition stage when attempting to create single hull." << llendl;
+		LL_WARNS() << "Could not execute decomposition stage when attempting to create single hull." << LL_ENDL;
 		make_box(mCurRequest);
 	}
 	else
diff --git a/indra/newview/llmimetypes.cpp b/indra/newview/llmimetypes.cpp
index e689e39b26..790a184068 100755
--- a/indra/newview/llmimetypes.cpp
+++ b/indra/newview/llmimetypes.cpp
@@ -55,8 +55,8 @@ bool LLMIMETypes::parseMIMETypes(const std::string& xml_filename)
 	bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root);
 	if ( ! success || root.isNull() || ! root->hasName( "mimetypes" ) )
 	{
-		llwarns << "Unable to read MIME type file: "
-			<< xml_filename << llendl;
+		LL_WARNS() << "Unable to read MIME type file: "
+			<< xml_filename << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp
index eb6591eb39..5c1292eed1 100755
--- a/indra/newview/llmoveview.cpp
+++ b/indra/newview/llmoveview.cpp
@@ -549,7 +549,7 @@ void LLPanelStandStopFlying::clearStandStopFlyingMode(EStandStopFlyingMode mode)
 		panel->mStopFlyingButton->setVisible(FALSE);
 		break;
 	default:
-		llerrs << "Unexpected EStandStopFlyingMode is passed: " << mode << llendl;
+		LL_ERRS() << "Unexpected EStandStopFlyingMode is passed: " << mode << LL_ENDL;
 	}
 
 }
@@ -614,7 +614,7 @@ void LLPanelStandStopFlying::reparent(LLFloaterMove* move_view)
 	LLPanel* parent = dynamic_cast<LLPanel*>(getParent());
 	if (!parent)
 	{
-		llwarns << "Stand/stop flying panel parent is unset, already attached?: " << mAttached << ", new parent: " << (move_view == NULL ? "NULL" : "Move Floater") << llendl;
+		LL_WARNS() << "Stand/stop flying panel parent is unset, already attached?: " << mAttached << ", new parent: " << (move_view == NULL ? "NULL" : "Move Floater") << LL_ENDL;
 		return;
 	}
 
@@ -636,7 +636,7 @@ void LLPanelStandStopFlying::reparent(LLFloaterMove* move_view)
 	{
 		if (!mOriginalParent.get())
 		{
-			llwarns << "Original parent of the stand / stop flying panel not found" << llendl;
+			LL_WARNS() << "Original parent of the stand / stop flying panel not found" << LL_ENDL;
 			return;
 		}
 
@@ -664,7 +664,7 @@ LLPanelStandStopFlying* LLPanelStandStopFlying::getStandStopFlyingPanel()
 	panel->setVisible(FALSE);
 	//LLUI::getRootView()->addChild(panel);
 
-	llinfos << "Build LLPanelStandStopFlying panel" << llendl;
+	LL_INFOS() << "Build LLPanelStandStopFlying panel" << LL_ENDL;
 
 	panel->updatePosition();
 	return panel;
diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp
index 54522bb7f6..e7924d96ce 100755
--- a/indra/newview/llmutelist.cpp
+++ b/indra/newview/llmutelist.cpp
@@ -234,21 +234,21 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags)
 		// Can't mute empty string by name
 		if (mute.mName.empty()) 
 		{
-			llwarns << "Trying to mute empty string by-name" << llendl;
+			LL_WARNS() << "Trying to mute empty string by-name" << LL_ENDL;
 			return FALSE;
 		}
 
 		// Null mutes must have uuid null
 		if (mute.mID.notNull())
 		{
-			llwarns << "Trying to add by-name mute with non-null id" << llendl;
+			LL_WARNS() << "Trying to add by-name mute with non-null id" << LL_ENDL;
 			return FALSE;
 		}
 
 		std::pair<string_set_t::iterator, bool> result = mLegacyMutes.insert(mute.mName);
 		if (result.second)
 		{
-			llinfos << "Muting by name " << mute.mName << llendl;
+			LL_INFOS() << "Muting by name " << mute.mName << LL_ENDL;
 			updateAdd(mute);
 			notifyObservers();
 			return TRUE;
@@ -296,7 +296,7 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags)
 			std::pair<mute_set_t::iterator, bool> result = mMutes.insert(localmute);
 			if (result.second)
 			{
-				llinfos << "Muting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl;
+				LL_INFOS() << "Muting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << LL_ENDL;
 				updateAdd(localmute);
 				notifyObservers();
 				if(!(localmute.mFlags & LLMute::flagParticles))
@@ -385,14 +385,14 @@ BOOL LLMuteList::remove(const LLMute& mute, U32 flags)
 		{
 			// The entry was actually removed.  Notify the server.
 			updateRemove(localmute);
-			llinfos << "Unmuting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl;
+			LL_INFOS() << "Unmuting " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << LL_ENDL;
 		}
 		else
 		{
 			// Flags were updated, the mute entry needs to be retransmitted to the server and re-added to the list.
 			mMutes.insert(localmute);
 			updateAdd(localmute);
-			llinfos << "Updating mute entry " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << llendl;
+			LL_INFOS() << "Updating mute entry " << localmute.mName << " id " << localmute.mID << " flags " << localmute.mFlags << LL_ENDL;
 		}
 		
 		// Must be after erase.
@@ -527,14 +527,14 @@ BOOL LLMuteList::loadFromFile(const std::string& filename)
 {
 	if(!filename.size())
 	{
-		llwarns << "Mute List Filename is Empty!" << llendl;
+		LL_WARNS() << "Mute List Filename is Empty!" << LL_ENDL;
 		return FALSE;
 	}
 
 	LLFILE* fp = LLFile::fopen(filename, "rb");		/*Flawfinder: ignore*/
 	if (!fp)
 	{
-		llwarns << "Couldn't open mute list " << filename << llendl;
+		LL_WARNS() << "Couldn't open mute list " << filename << LL_ENDL;
 		return FALSE;
 	}
 
@@ -577,14 +577,14 @@ BOOL LLMuteList::saveToFile(const std::string& filename)
 {
 	if(!filename.size())
 	{
-		llwarns << "Mute List Filename is Empty!" << llendl;
+		LL_WARNS() << "Mute List Filename is Empty!" << LL_ENDL;
 		return FALSE;
 	}
 
 	LLFILE* fp = LLFile::fopen(filename, "wb");		/*Flawfinder: ignore*/
 	if (!fp)
 	{
-		llwarns << "Couldn't open mute list " << filename << llendl;
+		LL_WARNS() << "Couldn't open mute list " << filename << LL_ENDL;
 		return FALSE;
 	}
 	// legacy mutes have null uuid
@@ -687,12 +687,12 @@ void LLMuteList::cache(const LLUUID& agent_id)
 
 void LLMuteList::processMuteListUpdate(LLMessageSystem* msg, void**)
 {
-	llinfos << "LLMuteList::processMuteListUpdate()" << llendl;
+	LL_INFOS() << "LLMuteList::processMuteListUpdate()" << LL_ENDL;
 	LLUUID agent_id;
 	msg->getUUIDFast(_PREHASH_MuteData, _PREHASH_AgentID, agent_id);
 	if(agent_id != gAgent.getID())
 	{
-		llwarns << "Got an mute list update for the wrong agent." << llendl;
+		LL_WARNS() << "Got an mute list update for the wrong agent." << LL_ENDL;
 		return;
 	}
 	std::string unclean_filename;
@@ -712,7 +712,7 @@ void LLMuteList::processMuteListUpdate(LLMessageSystem* msg, void**)
 
 void LLMuteList::processUseCachedMuteList(LLMessageSystem* msg, void**)
 {
-	llinfos << "LLMuteList::processUseCachedMuteList()" << llendl;
+	LL_INFOS() << "LLMuteList::processUseCachedMuteList()" << LL_ENDL;
 
 	std::string agent_id_string;
 	gAgent.getID().toString(agent_id_string);
@@ -723,7 +723,7 @@ void LLMuteList::processUseCachedMuteList(LLMessageSystem* msg, void**)
 
 void LLMuteList::onFileMuteList(void** user_data, S32 error_code, LLExtStat ext_status)
 {
-	llinfos << "LLMuteList::processMuteListFile()" << llendl;
+	LL_INFOS() << "LLMuteList::processMuteListFile()" << LL_ENDL;
 
 	std::string* local_filename_and_path = (std::string*)user_data;
 	if(local_filename_and_path && !local_filename_and_path->empty() && (error_code == 0))
diff --git a/indra/newview/llnamelistctrl.cpp b/indra/newview/llnamelistctrl.cpp
index 3417651ddb..80d3b2ee7b 100755
--- a/indra/newview/llnamelistctrl.cpp
+++ b/indra/newview/llnamelistctrl.cpp
@@ -72,7 +72,7 @@ LLNameListCtrl::LLNameListCtrl(const LLNameListCtrl::Params& p)
 LLScrollListItem* LLNameListCtrl::addNameItem(const LLUUID& agent_id, EAddPosition pos,
 								 BOOL enabled, const std::string& suffix)
 {
-	//llinfos << "LLNameListCtrl::addNameItem " << agent_id << llendl;
+	//LL_INFOS() << "LLNameListCtrl::addNameItem " << agent_id << LL_ENDL;
 
 	NameItem item;
 	item.value = agent_id;
@@ -125,7 +125,7 @@ BOOL LLNameListCtrl::handleDragAndDrop(
 	}
 
 	handled = TRUE;
-	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLNameListCtrl " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLNameListCtrl " << getName() << LL_ENDL;
 
 	return handled;
 }
@@ -178,7 +178,7 @@ void	LLNameListCtrl::mouseOverHighlightNthItem( S32 target_index )
 			}
 			else
 			{
-				llwarns << "highlighted name list item is NULL" << llendl;
+				LL_WARNS() << "highlighted name list item is NULL" << LL_ENDL;
 			}
 		}
 		if(target_index != -1)
@@ -192,7 +192,7 @@ void	LLNameListCtrl::mouseOverHighlightNthItem( S32 target_index )
 			}
 			else
 			{
-				llwarns << "target name item is NULL" << llendl;
+				LL_WARNS() << "target name item is NULL" << LL_ENDL;
 			}
 		}
 	}
diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp
index 95caa2731a..8c4849d28d 100755
--- a/indra/newview/llnavigationbar.cpp
+++ b/indra/newview/llnavigationbar.cpp
@@ -600,7 +600,7 @@ void LLNavigationBar::onRegionNameResponse(
 		LLVector3d region_pos = from_region_handle(region_handle);
 		LLVector3d global_pos = region_pos + (LLVector3d) local_coords;
 
-		llinfos << "Teleporting to: " << LLSLURL(region_name,	global_pos).getSLURLString()  << llendl;
+		LL_INFOS() << "Teleporting to: " << LLSLURL(region_name,	global_pos).getSLURLString()  << LL_ENDL;
 		gAgent.teleportViaLocation(global_pos);
 	}
 	else if (gSavedSettings.getBOOL("SearchFromAddressBar"))
@@ -614,7 +614,7 @@ void	LLNavigationBar::showTeleportHistoryMenu(LLUICtrl* btn_ctrl)
 	// Don't show the popup if teleport history is empty.
 	if (LLTeleportHistory::getInstance()->isEmpty())
 	{
-		lldebugs << "Teleport history is empty, will not show the menu." << llendl;
+		LL_DEBUGS() << "Teleport history is empty, will not show the menu." << LL_ENDL;
 		return;
 	}
 	
diff --git a/indra/newview/llnotificationhandlerutil.cpp b/indra/newview/llnotificationhandlerutil.cpp
index eb4601a469..aa4a90b4b8 100755
--- a/indra/newview/llnotificationhandlerutil.cpp
+++ b/indra/newview/llnotificationhandlerutil.cpp
@@ -130,7 +130,7 @@ void LLHandlerUtil::logToIMP2P(const LLNotificationPtr& notification, bool to_fi
 		if (from_id.isNull())
 		{
 			// Normal behavior for system generated messages, don't spam.
-			// llwarns << " from_id for notification " << notification->getName() << " is null " << llendl;
+			// LL_WARNS() << " from_id for notification " << notification->getName() << " is null " << LL_ENDL;
 			return;
 		}
 
@@ -153,9 +153,9 @@ void LLHandlerUtil::logGroupNoticeToIMGroup(
 	LLGroupData groupData;
 	if (!gAgent.getGroupData(payload["group_id"].asUUID(), groupData))
 	{
-		llwarns
+		LL_WARNS()
 						<< "Group notice for unknown group: "
-								<< payload["group_id"].asUUID() << llendl;
+								<< payload["group_id"].asUUID() << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index c15b6bd0d3..8e5df166cd 100755
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -90,7 +90,7 @@ const outfit_accordion_tab_params& get_accordion_tab_params()
 		}
 		else
 		{
-			llwarns << "Failed to read xml of Outfit's Accordion Tab from outfit_accordion_tab.xml" << llendl;
+			LL_WARNS() << "Failed to read xml of Outfit's Accordion Tab from outfit_accordion_tab.xml" << LL_ENDL;
 		}
 	}
 
@@ -204,7 +204,7 @@ private:
 		LLWearableType::EType type = LLWearableType::typeNameToType(data.asString());
 		if (type == LLWearableType::WT_NONE)
 		{
-			llwarns << "Invalid wearable type" << llendl;
+			LL_WARNS() << "Invalid wearable type" << LL_ENDL;
 			return;
 		}
 
diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp
index b6a9aae213..5d1b582d1f 100755
--- a/indra/newview/llpanelavatar.cpp
+++ b/indra/newview/llpanelavatar.cpp
@@ -97,7 +97,7 @@ LLDropTarget::~LLDropTarget()
 
 void LLDropTarget::doDrop(EDragAndDropType cargo_type, void* cargo_data)
 {
-	llinfos << "LLDropTarget::doDrop()" << llendl;
+	LL_INFOS() << "LLDropTarget::doDrop()" << LL_ENDL;
 }
 
 BOOL LLDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
diff --git a/indra/newview/llpanelblockedlist.cpp b/indra/newview/llpanelblockedlist.cpp
index 115114bb53..27dc1381b2 100755
--- a/indra/newview/llpanelblockedlist.cpp
+++ b/indra/newview/llpanelblockedlist.cpp
@@ -90,7 +90,7 @@ BOOL LLPanelBlockedList::postBuild()
 		mBlockedList->sortByType();
 		break;
 	default:
-		llwarns << "Unrecognized sort order for blocked list" << llendl;
+		LL_WARNS() << "Unrecognized sort order for blocked list" << LL_ENDL;
 		break;
 	}
 
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 50d0b4256b..62966e3a4e 100755
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -103,8 +103,8 @@ public:
 		const std::string& reason,
 		const LLSD& content)
 	{
-		llwarns << "Sending click message failed (" << status << "): [" << reason << "]" << llendl;
-		llwarns << "Content: [" << content << "]" << llendl;
+		LL_WARNS() << "Sending click message failed (" << status << "): [" << reason << "]" << LL_ENDL;
+		LL_WARNS() << "Content: [" << content << "]" << LL_ENDL;
 	}
 };
 
@@ -220,7 +220,7 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key)
 	setSnapshotId(key["classified_snapshot_id"]);
 	setFromSearch(key["from_search"]);
 
-	llinfos << "Opening classified [" << getClassifiedName() << "] (" << getClassifiedId() << ")" << llendl;
+	LL_INFOS() << "Opening classified [" << getClassifiedName() << "] (" << getClassifiedId() << ")" << LL_ENDL;
 
 	LLAvatarPropertiesProcessor::getInstance()->addObserver(getAvatarId(), this);
 	LLAvatarPropertiesProcessor::getInstance()->sendClassifiedInfoRequest(getClassifiedId());
@@ -231,7 +231,7 @@ void LLPanelClassifiedInfo::onOpen(const LLSD& key)
 	std::string url = gAgent.getRegion()->getCapability("SearchStatRequest");
 	if (!url.empty())
 	{
-		llinfos << "Classified stat request via capability" << llendl;
+		LL_INFOS() << "Classified stat request via capability" << LL_ENDL;
 		LLSD body;
 		body["classified_id"] = getClassifiedId();
 		LLHTTPClient::post(url, body, new LLClassifiedStatsResponder(getClassifiedId()));
@@ -389,9 +389,9 @@ void LLPanelClassifiedInfo::setClickThrough(
 	S32 profile,
 	bool from_new_table)
 {
-	llinfos << "Click-through data for classified " << classified_id << " arrived: ["
+	LL_INFOS() << "Click-through data for classified " << classified_id << " arrived: ["
 			<< teleport << ", " << map << ", " << profile << "] ("
-			<< (from_new_table ? "new" : "old") << ")" << llendl;
+			<< (from_new_table ? "new" : "old") << ")" << LL_ENDL;
 
 	for (panel_list_t::iterator iter = sAllPanels.begin(); iter != sAllPanels.end(); ++iter)
 	{
@@ -408,7 +408,7 @@ void LLPanelClassifiedInfo::setClickThrough(
 			continue;
 		}
 
-		llinfos << "Updating classified info panel" << llendl;
+		LL_INFOS() << "Updating classified info panel" << LL_ENDL;
 
 		// We need to check to see if the data came from the new stat_table 
 		// or the old classified table. We also need to cache the data from 
@@ -437,10 +437,10 @@ void LLPanelClassifiedInfo::setClickThrough(
 		// *HACK: remove this when there is enough room for click stats in the info panel
 		self->getChildView("click_through_text")->setToolTip(ct_str.getString());  
 
-		llinfos << "teleport: " << llformat("%d", self->mTeleportClicksNew + self->mTeleportClicksOld)
+		LL_INFOS() << "teleport: " << llformat("%d", self->mTeleportClicksNew + self->mTeleportClicksOld)
 				<< ", map: "    << llformat("%d", self->mMapClicksNew + self->mMapClicksOld)
 				<< ", profile: " << llformat("%d", self->mProfileClicksNew + self->mProfileClicksOld)
-				<< llendl;
+				<< LL_ENDL;
 	}
 }
 
@@ -550,8 +550,8 @@ void LLPanelClassifiedInfo::sendClickMessage(
 	body["region_name"]		= sim_name;
 
 	std::string url = gAgent.getRegion()->getCapability("SearchStatTracking");
-	llinfos << "Sending click msg via capability (url=" << url << ")" << llendl;
-	llinfos << "body: [" << body << "]" << llendl;
+	LL_INFOS() << "Sending click msg via capability (url=" << url << ")" << LL_ENDL;
+	LL_INFOS() << "body: [" << body << "]" << LL_ENDL;
 	LLHTTPClient::post(url, body, new LLClassifiedClickMessageResponder());
 }
 
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 5bdd88dd50..568931089e 100755
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -454,7 +454,7 @@ get_pickers_indexes<LLColorSwatchCtrl> (const LLEditWearableDictionary::Wearable
 {
         if (!wearable_entry)
         {
-                llwarns << "could not get LLColorSwatchCtrl indexes for null wearable entry." << llendl;
+                LL_WARNS() << "could not get LLColorSwatchCtrl indexes for null wearable entry." << LL_ENDL;
                 return null_texture_vec;
         }
         return wearable_entry->mColorSwatchCtrls;
@@ -467,7 +467,7 @@ get_pickers_indexes<LLTextureCtrl> (const LLEditWearableDictionary::WearableEntr
 {
         if (!wearable_entry)
         {
-                llwarns << "could not get LLTextureCtrl indexes for null wearable entry." << llendl;
+                LL_WARNS() << "could not get LLTextureCtrl indexes for null wearable entry." << LL_ENDL;
                 return null_texture_vec;
         }
         return wearable_entry->mTextureCtrls;
@@ -497,7 +497,7 @@ find_picker_ctrl_entry_if(LLWearableType::EType type, const Predicate pred)
                 = LLEditWearableDictionary::getInstance()->getWearable(type);
         if (!wearable_entry)
         {
-                llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
+                LL_WARNS() << "could not get wearable dictionary entry for wearable of type: " << type << LL_ENDL;
                 return NULL;
         }
         const texture_vec_t& indexes = get_pickers_indexes<CtrlType>(wearable_entry);
@@ -511,7 +511,7 @@ find_picker_ctrl_entry_if(LLWearableType::EType type, const Predicate pred)
                         = get_picker_entry<CtrlType>(te);
                 if (!entry)
                 {
-                        llwarns << "could not get picker dictionary entry (" << te << ") for wearable of type: " << type << llendl;
+                        LL_WARNS() << "could not get picker dictionary entry (" << te << ") for wearable of type: " << type << LL_ENDL;
                         continue;
                 }
                 if (pred(entry))
@@ -528,14 +528,14 @@ for_each_picker_ctrl_entry(LLPanel* panel, LLWearableType::EType type, function_
 {
         if (!panel)
         {
-                llwarns << "the panel wasn't passed for wearable of type: " << type << llendl;
+                LL_WARNS() << "the panel wasn't passed for wearable of type: " << type << LL_ENDL;
                 return;
         }
         const LLEditWearableDictionary::WearableEntry *wearable_entry
                 = LLEditWearableDictionary::getInstance()->getWearable(type);
         if (!wearable_entry)
         {
-                llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
+                LL_WARNS() << "could not get wearable dictionary entry for wearable of type: " << type << LL_ENDL;
                 return;
         }
         const texture_vec_t& indexes = get_pickers_indexes<CtrlType>(wearable_entry);
@@ -549,7 +549,7 @@ for_each_picker_ctrl_entry(LLPanel* panel, LLWearableType::EType type, function_
                         = get_picker_entry<CtrlType>(te);
                 if (!entry)
                 {
-                        llwarns << "could not get picker dictionary entry (" << te << ") for wearable of type: " << type << llendl;
+                        LL_WARNS() << "could not get picker dictionary entry (" << te << ") for wearable of type: " << type << LL_ENDL;
                         continue;
                 }
                 fun (panel, entry);
@@ -701,12 +701,12 @@ void LLPanelEditWearable::setWearablePanelVisibilityChangeCallback(LLPanel* body
                 }
                 else
                 {
-                        llwarns << "accordion_ctrl is NULL" << llendl;
+                        LL_WARNS() << "accordion_ctrl is NULL" << LL_ENDL;
                 }
         }
         else
         {
-                llwarns << "bodypart_panel is NULL" << llendl;
+                LL_WARNS() << "bodypart_panel is NULL" << LL_ENDL;
         }
 }
 
@@ -777,7 +777,7 @@ BOOL LLPanelEditWearable::postBuild()
                 const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
                 if (!wearable_entry)
                 {
-                        llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
+                        LL_WARNS() << "could not get wearable dictionary entry for wearable of type: " << type << LL_ENDL;
                         continue;
                 }
                 U8 num_subparts = wearable_entry->mSubparts.size();
@@ -790,7 +790,7 @@ BOOL LLPanelEditWearable::postBuild()
         
                         if (!subpart_entry)
                         {
-                                llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
+                                LL_WARNS() << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << LL_ENDL;
                                 continue;
                         }
         
@@ -800,7 +800,7 @@ BOOL LLPanelEditWearable::postBuild()
         
                         if (!tab)
                         {
-                                llwarns << "could not get llaccordionctrltab from UI with name: " << accordion_tab << llendl;
+                                LL_WARNS() << "could not get llaccordionctrltab from UI with name: " << accordion_tab << LL_ENDL;
                                 continue;
                         }
         
@@ -960,7 +960,7 @@ void LLPanelEditWearable::onTexturePickerCommit(const LLUICtrl* ctrl)
         const LLTextureCtrl* texture_ctrl = dynamic_cast<const LLTextureCtrl*>(ctrl);
         if (!texture_ctrl)
         {
-                llwarns << "got commit signal from not LLTextureCtrl." << llendl;
+                LL_WARNS() << "got commit signal from not LLTextureCtrl." << LL_ENDL;
                 return;
         }
 
@@ -988,7 +988,7 @@ void LLPanelEditWearable::onTexturePickerCommit(const LLUICtrl* ctrl)
                 }
                 else
                 {
-                        llwarns << "could not get texture picker dictionary entry for wearable of type: " << type << llendl;
+                        LL_WARNS() << "could not get texture picker dictionary entry for wearable of type: " << type << LL_ENDL;
                 }
         }
 }
@@ -1014,7 +1014,7 @@ void LLPanelEditWearable::onColorSwatchCommit(const LLUICtrl* ctrl)
                 }
                 else
                 {
-                        llwarns << "could not get color swatch dictionary entry for wearable of type: " << type << llendl;
+                        LL_WARNS() << "could not get color swatch dictionary entry for wearable of type: " << type << LL_ENDL;
                 }
         }
 }
@@ -1142,7 +1142,7 @@ void LLPanelEditWearable::showWearable(LLViewerWearable* wearable, BOOL show, BO
         const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
         if (!wearable_entry)
         {
-                llwarns << "called LLPanelEditWearable::showWearable with an invalid wearable type! (" << type << ")" << llendl;
+                LL_WARNS() << "called LLPanelEditWearable::showWearable with an invalid wearable type! (" << type << ")" << LL_ENDL;
                 return;
         }
 
@@ -1180,7 +1180,7 @@ void LLPanelEditWearable::showWearable(LLViewerWearable* wearable, BOOL show, BO
         
                         if (!subpart_entry)
                         {
-                                llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
+                                LL_WARNS() << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << LL_ENDL;
                                 continue;
                         }
         
@@ -1192,13 +1192,13 @@ void LLPanelEditWearable::showWearable(LLViewerWearable* wearable, BOOL show, BO
 			
                         if (!panel_list)
                         {
-                                llwarns << "could not get scrolling panel list: " << scrolling_panel << llendl;
+                                LL_WARNS() << "could not get scrolling panel list: " << scrolling_panel << LL_ENDL;
                                 continue;
                         }
         
                         if (!tab)
                         {
-                                llwarns << "could not get llaccordionctrltab from UI with name: " << accordion_tab << llendl;
+                                LL_WARNS() << "could not get llaccordionctrltab from UI with name: " << accordion_tab << LL_ENDL;
                                 continue;
                         }
 
@@ -1272,13 +1272,13 @@ void LLPanelEditWearable::changeCamera(U8 subpart)
         const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(mWearablePtr->getType());
         if (!wearable_entry)
         {
-                llinfos << "could not get wearable dictionary entry for wearable type: " << mWearablePtr->getType() << llendl;
+                LL_INFOS() << "could not get wearable dictionary entry for wearable type: " << mWearablePtr->getType() << LL_ENDL;
                 return;
         }
 
         if (subpart >= wearable_entry->mSubparts.size())
         {
-                llinfos << "accordion tab expanded for invalid subpart. Wearable type: " << mWearablePtr->getType() << " subpart num: " << subpart << llendl;
+                LL_INFOS() << "accordion tab expanded for invalid subpart. Wearable type: " << mWearablePtr->getType() << " subpart num: " << subpart << LL_ENDL;
                 return;
         }
 
@@ -1287,7 +1287,7 @@ void LLPanelEditWearable::changeCamera(U8 subpart)
 
         if (!subpart_entry)
         {
-                llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
+                LL_WARNS() << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << LL_ENDL;
                 return;
         }
 
@@ -1376,7 +1376,7 @@ void LLPanelEditWearable::updateScrollingPanelUI()
         
                         if (!panel_list)
                         {
-                                llwarns << "could not get scrolling panel list: " << scrolling_panel << llendl;
+                                LL_WARNS() << "could not get scrolling panel list: " << scrolling_panel << LL_ENDL;
                                 continue;
                         }
                         
@@ -1572,7 +1572,7 @@ void LLPanelEditWearable::onInvisibilityCommit(LLCheckBoxCtrl* checkbox_ctrl, LL
         if (!checkbox_ctrl) return;
         if (!getWearable()) return;
 
-        llinfos << "onInvisibilityCommit, self " << this << " checkbox_ctrl " << checkbox_ctrl << llendl;
+        LL_INFOS() << "onInvisibilityCommit, self " << this << " checkbox_ctrl " << checkbox_ctrl << LL_ENDL;
 
         bool new_invis_state = checkbox_ctrl->get();
         if (new_invis_state)
diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp
index df37a188fa..880cf517ff 100755
--- a/indra/newview/llpanelface.cpp
+++ b/indra/newview/llpanelface.cpp
@@ -659,7 +659,7 @@ void LLPanelFace::updateUI()
 		}
 		else
 		{
-			llwarns << "failed getChild for 'combobox matmedia'" << llendl;
+			LL_WARNS() << "failed getChild for 'combobox matmedia'" << LL_ENDL;
 		}
 		getChildView("combobox matmedia")->setEnabled(editable);
 
@@ -778,7 +778,7 @@ void LLPanelFace::updateUI()
 							}
 			else
 							{
-				llwarns << "failed childGetSelectionInterface for 'combobox bumpiness'" << llendl;
+				LL_WARNS() << "failed childGetSelectionInterface for 'combobox bumpiness'" << LL_ENDL;
 							}
 
 			getChildView("combobox bumpiness")->setEnabled(editable);
@@ -811,7 +811,7 @@ void LLPanelFace::updateUI()
                case GL_RGB: break;
                default:
                {
-                  llwarns << "Unexpected tex format in LLPanelFace...resorting to no alpha" << llendl;
+                  LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL;
 					}
                break;
 				}
@@ -847,7 +847,7 @@ void LLPanelFace::updateUI()
 			}
 			else
 			{
-				llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl;
+				LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL;
 			}
 
 			updateAlphaControls();
@@ -1165,7 +1165,7 @@ void LLPanelFace::updateUI()
 			}
 			else
 				{
-				llwarns << "failed childGetSelectionInterface for 'combobox texgen'" << llendl;
+				LL_WARNS() << "failed childGetSelectionInterface for 'combobox texgen'" << LL_ENDL;
 				}
 
 			getChildView("combobox texgen")->setEnabled(editable);
@@ -1284,7 +1284,7 @@ void LLPanelFace::updateUI()
 			}
 			else
 			{
-					llwarns << "failed childGetSelectionInterface for 'combobox alphamode'" << llendl;
+					LL_WARNS() << "failed childGetSelectionInterface for 'combobox alphamode'" << LL_ENDL;
 			}
 				getChild<LLUICtrl>("maskcutoff")->setValue(material->getAlphaMaskCutoff());
 				updateAlphaControls();
@@ -1804,7 +1804,7 @@ void LLPanelFace::onSelectTexture(const LLSD& data)
 		case GL_RGB: break;
 		default:
 			{
-				llwarns << "Unexpected tex format in LLPanelFace...resorting to no alpha" << llendl;
+				LL_WARNS() << "Unexpected tex format in LLPanelFace...resorting to no alpha" << LL_ENDL;
 			}
 			break;
 		}
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index ae217958f0..c9a066864c 100755
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -291,7 +291,7 @@ void LLPanelGroup::onBtnGroupChatClicked(void* user_data)
 
 void LLPanelGroup::onBtnJoin()
 {
-	lldebugs << "joining group: " << mID << llendl;
+	LL_DEBUGS() << "joining group: " << mID << LL_ENDL;
 	LLGroupActions::join(mID);
 }
 
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 0cd93b330a..1f30a497a9 100755
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -284,7 +284,7 @@ void LLPanelGroupGeneral::onClickInfo(void *userdata)
 
 	if ( !self ) return;
 
-	lldebugs << "open group info: " << self->mGroupID << llendl;
+	LL_DEBUGS() << "open group info: " << self->mGroupID << LL_ENDL;
 
 	LLGroupActions::show(self->mGroupID);
 
@@ -356,7 +356,7 @@ bool LLPanelGroupGeneral::apply(std::string& mesg)
 
 	if (has_power_in_group || mGroupID.isNull())
 	{
-		llinfos << "LLPanelGroupGeneral::apply" << llendl;
+		LL_INFOS() << "LLPanelGroupGeneral::apply" << LL_ENDL;
 
 		// Check to make sure mature has been set
 		if(mComboMature &&
@@ -743,7 +743,7 @@ void LLPanelGroupGeneral::updateMembers()
 
 	if (mMemberProgress == gdatap->mMembers.end())
 	{
-		lldebugs << "   member list completed." << llendl;
+		LL_DEBUGS() << "   member list completed." << LL_ENDL;
 		mListVisibleMembers->setEnabled(TRUE);
 	}
 	else
diff --git a/indra/newview/llpanelgroupinvite.cpp b/indra/newview/llpanelgroupinvite.cpp
index 133b269c11..04f4454adf 100755
--- a/indra/newview/llpanelgroupinvite.cpp
+++ b/indra/newview/llpanelgroupinvite.cpp
@@ -485,7 +485,7 @@ void LLPanelGroupInvite::addUsers(uuid_vec_t& agent_ids)
 			} 
 			else 
 			{
-				llwarns << "llPanelGroupInvite: Selected avatar has no name: " << dest->getID() << llendl;
+				LL_WARNS() << "llPanelGroupInvite: Selected avatar has no name: " << dest->getID() << LL_ENDL;
 				names.push_back("(Unknown)");
 			}
 		}
diff --git a/indra/newview/llpanelgrouplandmoney.cpp b/indra/newview/llpanelgrouplandmoney.cpp
index 524305e3fe..4d8ca6773e 100755
--- a/indra/newview/llpanelgrouplandmoney.cpp
+++ b/indra/newview/llpanelgrouplandmoney.cpp
@@ -324,7 +324,7 @@ bool LLPanelGroupLandMoney::impl::applyContribution()
 		if(!gAgent.setGroupContribution(mPanel.mGroupID, new_contribution))
 		{
 			// should never happen...
-			llwarns << "Unable to set contribution." << llendl;
+			LL_WARNS() << "Unable to set contribution." << LL_ENDL;
 			return false;
 		}
 	}
@@ -476,7 +476,7 @@ void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg)
 			if ( msg->getSizeFast(_PREHASH_QueryData, i, _PREHASH_ProductSKU) > 0 )
 			{
 				msg->getStringFast(	_PREHASH_QueryData, _PREHASH_ProductSKU, land_sku, i);
-				llinfos << "Land sku: " << land_sku << llendl;
+				LL_INFOS() << "Land sku: " << land_sku << LL_ENDL;
 				land_type = LLProductInfoRequestManager::instance().getDescriptionForSku(land_sku);
 			}
 			else
@@ -824,8 +824,8 @@ void LLPanelGroupLandMoney::processPlacesReply(LLMessageSystem* msg, void**)
 	group_id_map_t::iterator found_it = sGroupIDs.find(group_id);
 	if(found_it == sGroupIDs.end())
 	{
-		llinfos << "Group Panel Land L$ " << group_id << " no longer in existence."
-				<< llendl;
+		LL_INFOS() << "Group Panel Land L$ " << group_id << " no longer in existence."
+				<< LL_ENDL;
 		return;
 	}
 
@@ -1045,7 +1045,7 @@ void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg,
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
 	if (mImplementationp->getGroupID() != group_id) 
 	{
-		llwarns << "Group Account details not for this group!" << llendl;
+		LL_WARNS() << "Group Account details not for this group!" << LL_ENDL;
 		return;
 	}
 
@@ -1068,8 +1068,8 @@ void LLGroupMoneyDetailsTabEventHandler::processReply(LLMessageSystem* msg,
 	if ( interval_days != mImplementationp->mIntervalLength || 
 		 current_interval != mImplementationp->mCurrentInterval )
 	{
-		llinfos << "Out of date details packet " << interval_days << " " 
-			<< current_interval << llendl;
+		LL_INFOS() << "Out of date details packet " << interval_days << " " 
+			<< current_interval << LL_ENDL;
 		return;
 	}
 
@@ -1116,7 +1116,7 @@ void LLPanelGroupLandMoney::processGroupAccountDetailsReply(LLMessageSystem* msg
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group L$ history reply for another agent!" << llendl;
+		LL_WARNS() << "Got group L$ history reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -1125,7 +1125,7 @@ void LLPanelGroupLandMoney::processGroupAccountDetailsReply(LLMessageSystem* msg
 	LLGroupMoneyTabEventHandler* selfp = get_ptr_in_map(LLGroupMoneyTabEventHandler::sInstanceIDs, request_id);
 	if (!selfp)
 	{
-		llwarns << "GroupAccountDetails received for non-existent group panel." << llendl;
+		LL_WARNS() << "GroupAccountDetails received for non-existent group panel." << LL_ENDL;
 		return;
 	}
 
@@ -1186,7 +1186,7 @@ void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg,
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
 	if (mImplementationp->getGroupID() != group_id) 
 	{
-		llwarns << "Group Account Transactions not for this group!" << llendl;
+		LL_WARNS() << "Group Account Transactions not for this group!" << LL_ENDL;
 		return;
 	}
 
@@ -1203,8 +1203,8 @@ void LLGroupMoneySalesTabEventHandler::processReply(LLMessageSystem* msg,
 	if (interval_days != mImplementationp->mIntervalLength ||
 	    current_interval != mImplementationp->mCurrentInterval)
 	{
-		llinfos << "Out of date details packet " << interval_days << " " 
-			<< current_interval << llendl;
+		LL_INFOS() << "Out of date details packet " << interval_days << " " 
+			<< current_interval << LL_ENDL;
 		return;
 	}
 
@@ -1293,7 +1293,7 @@ void LLPanelGroupLandMoney::processGroupAccountTransactionsReply(LLMessageSystem
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group L$ history reply for another agent!" << llendl;
+		LL_WARNS() << "Got group L$ history reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -1305,7 +1305,7 @@ void LLPanelGroupLandMoney::processGroupAccountTransactionsReply(LLMessageSystem
 	self = get_ptr_in_map(LLGroupMoneyTabEventHandler::sInstanceIDs, request_id);
 	if (!self)
 	{
-		llwarns << "GroupAccountTransactions recieved for non-existent group panel." << llendl;
+		LL_WARNS() << "GroupAccountTransactions recieved for non-existent group panel." << LL_ENDL;
 		return;
 	}
 
@@ -1364,7 +1364,7 @@ void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg,
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_GroupID, group_id );
 	if (mImplementationp->getGroupID() != group_id) 
 	{
-		llwarns << "Group Account Summary received not for this group!" << llendl;
+		LL_WARNS() << "Group Account Summary received not for this group!" << LL_ENDL;
 		return;
 	}
 
@@ -1415,8 +1415,8 @@ void LLGroupMoneyPlanningTabEventHandler::processReply(LLMessageSystem* msg,
 	if (interval_days != mImplementationp->mIntervalLength || 
 		current_interval != mImplementationp->mCurrentInterval)
 	{
-		llinfos << "Out of date summary packet " << interval_days << " " 
-			<< current_interval << llendl;
+		LL_INFOS() << "Out of date summary packet " << interval_days << " " 
+			<< current_interval << LL_ENDL;
 		return;
 	}
 
@@ -1473,7 +1473,7 @@ void LLPanelGroupLandMoney::processGroupAccountSummaryReply(LLMessageSystem* msg
 	msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id );
 	if (gAgent.getID() != agent_id)
 	{
-		llwarns << "Got group L$ history reply for another agent!" << llendl;
+		LL_WARNS() << "Got group L$ history reply for another agent!" << LL_ENDL;
 		return;
 	}
 
@@ -1485,7 +1485,7 @@ void LLPanelGroupLandMoney::processGroupAccountSummaryReply(LLMessageSystem* msg
 	self = get_ptr_in_map(LLGroupMoneyTabEventHandler::sInstanceIDs, request_id);
 	if (!self)
 	{
-		llwarns << "GroupAccountSummary recieved for non-existent group L$ planning tab." << llendl;
+		LL_WARNS() << "GroupAccountSummary recieved for non-existent group L$ planning tab." << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index 522ba5afae..30c3908f4d 100755
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -117,7 +117,7 @@ LLGroupDropTarget::LLGroupDropTarget(const LLGroupDropTarget::Params& p)
 
 void LLGroupDropTarget::doDrop(EDragAndDropType cargo_type, void* cargo_data)
 {
-	llinfos << "LLGroupDropTarget::doDrop()" << llendl;
+	LL_INFOS() << "LLGroupDropTarget::doDrop()" << LL_ENDL;
 }
 
 BOOL LLGroupDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
@@ -439,7 +439,7 @@ void LLPanelGroupNotices::refreshNotices()
 {
 	onClickRefreshNotices(this);
 	/*
-	lldebugs << "LLPanelGroupNotices::onClickGetPastNotices" << llendl;
+	LL_DEBUGS() << "LLPanelGroupNotices::onClickGetPastNotices" << LL_ENDL;
 	
 	mNoticesList->deleteAllItems();
 
@@ -457,7 +457,7 @@ void LLPanelGroupNotices::refreshNotices()
 
 void LLPanelGroupNotices::onClickRefreshNotices(void* data)
 {
-	lldebugs << "LLPanelGroupNotices::onClickGetPastNotices" << llendl;
+	LL_DEBUGS() << "LLPanelGroupNotices::onClickGetPastNotices" << LL_ENDL;
 	LLPanelGroupNotices* self = (LLPanelGroupNotices*)data;
 	
 	self->mNoticesList->deleteAllItems();
@@ -484,16 +484,16 @@ void LLPanelGroupNotices::processGroupNoticesListReply(LLMessageSystem* msg, voi
 	std::map<LLUUID,LLPanelGroupNotices*>::iterator it = sInstances.find(group_id);
 	if (it == sInstances.end())
 	{
-		llinfos << "Group Panel Notices " << group_id << " no longer in existence."
-				<< llendl;
+		LL_INFOS() << "Group Panel Notices " << group_id << " no longer in existence."
+				<< LL_ENDL;
 		return;
 	}
 	
 	LLPanelGroupNotices* selfp = it->second;
 	if(!selfp)
 	{
-		llinfos << "Group Panel Notices " << group_id << " no longer in existence."
-				<< llendl;
+		LL_INFOS() << "Group Panel Notices " << group_id << " no longer in existence."
+				<< LL_ENDL;
 		return;
 	}
 
@@ -595,7 +595,7 @@ void LLPanelGroupNotices::onSelectNotice(LLUICtrl* ctrl, void* data)
 	msg->addUUID("GroupNoticeID",item->getUUID());
 	gAgent.sendReliableMessage();
 
-	lldebugs << "Item " << item->getUUID() << " selected." << llendl;
+	LL_DEBUGS() << "Item " << item->getUUID() << " selected." << LL_ENDL;
 }
 
 void LLPanelGroupNotices::showNotice(const std::string& subject,
diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp
index cfdac11d26..2d9b3118e1 100755
--- a/indra/newview/llpanelgrouproles.cpp
+++ b/indra/newview/llpanelgrouproles.cpp
@@ -72,8 +72,8 @@ bool agentCanAddToRole(const LLUUID& group_id,
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(group_id);
 	if (!gdatap) 
 	{
-		llwarns << "agentCanAddToRole "
-				<< "-- No group data!" << llendl;
+		LL_WARNS() << "agentCanAddToRole "
+				<< "-- No group data!" << LL_ENDL;
 		return false;
 	}
 
@@ -126,7 +126,7 @@ LLPanelGroupRoles::~LLPanelGroupRoles()
 
 BOOL LLPanelGroupRoles::postBuild()
 {
-	lldebugs << "LLPanelGroupRoles::postBuild()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRoles::postBuild()" << LL_ENDL;
 
 	mSubTabContainer = getChild<LLTabContainer>("roles_tab_container");
 
@@ -139,7 +139,7 @@ BOOL LLPanelGroupRoles::postBuild()
 		LLPanelGroupSubTab* subtabp = dynamic_cast<LLPanelGroupSubTab*>(panel);
 		if (!subtabp)
 		{
-			llwarns << "Invalid subtab panel: " << panel->getName() << llendl;
+			LL_WARNS() << "Invalid subtab panel: " << panel->getName() << LL_ENDL;
 			return FALSE;
 		}
 
@@ -342,7 +342,7 @@ void LLPanelGroupRoles::update(LLGroupChange gc)
 	}
 	else
 	{
-		llwarns << "LLPanelGroupRoles::update() -- No subtab to update!" << llendl;
+		LL_WARNS() << "LLPanelGroupRoles::update() -- No subtab to update!" << LL_ENDL;
 	}
 	
 }
@@ -538,7 +538,7 @@ void LLPanelGroupSubTab::buildActionsList(LLScrollListCtrl* ctrl,
 {
 	if (LLGroupMgr::getInstance()->mRoleActionSets.empty())
 	{
-		llwarns << "Can't build action list - no actions found." << llendl;
+		LL_WARNS() << "Can't build action list - no actions found." << LL_ENDL;
 		return;
 	}
 
@@ -567,7 +567,7 @@ void LLPanelGroupSubTab::buildActionCategory(LLScrollListCtrl* ctrl,
 											 BOOL filter,
 											 BOOL is_owner_role)
 {
-	lldebugs << "Building role list for: " << action_set->mActionSetData->mName << llendl;
+	LL_DEBUGS() << "Building role list for: " << action_set->mActionSetData->mName << LL_ENDL;
 	// See if the allow mask matches anything in this category.
 	if (show_all || (allowed_by_some & action_set->mActionSetData->mPowerBit))
 	{
@@ -860,7 +860,7 @@ void LLPanelGroupMembersSubTab::onMemberSelect(LLUICtrl* ctrl, void* user_data)
 
 void LLPanelGroupMembersSubTab::handleMemberSelect()
 {
-	lldebugs << "LLPanelGroupMembersSubTab::handleMemberSelect" << llendl;
+	LL_DEBUGS() << "LLPanelGroupMembersSubTab::handleMemberSelect" << LL_ENDL;
 
 	mAssignedRolesList->deleteAllItems();
 	mAllowedActionsList->deleteAllItems();
@@ -868,8 +868,8 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupMembersSubTab::handleMemberSelect() "
-				<< "-- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupMembersSubTab::handleMemberSelect() "
+				<< "-- No group data!" << LL_ENDL;
 		return;
 	}
 
@@ -1041,7 +1041,7 @@ void LLPanelGroupMembersSubTab::handleMemberSelect()
 		else
 		{
 			// This could happen if changes are not synced right on sub-panel change.
-			llwarns << "No group role data for " << iter->second << llendl;
+			LL_WARNS() << "No group role data for " << iter->second << LL_ENDL;
 		}
 	}
 	mAssignedRolesList->setEnabled(TRUE);
@@ -1301,7 +1301,7 @@ bool LLPanelGroupMembersSubTab::apply(std::string& mesg)
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap)
 	{
-		llwarns << "Unable to get group data for group " << mGroupID << llendl;
+		LL_WARNS() << "Unable to get group data for group " << mGroupID << LL_ENDL;
 
 		mesg.assign("Unable to save member data.  Try again later.");
 		return false;
@@ -1327,7 +1327,7 @@ bool LLPanelGroupMembersSubTab::apply(std::string& mesg)
 			}
 			else
 			{
-				llwarns << "Unable to get role information for the owner role in group " << mGroupID << llendl;
+				LL_WARNS() << "Unable to get role information for the owner role in group " << mGroupID << LL_ENDL;
 
 				mesg.assign("Unable to retried specific group information.  Try again later");
 				return false;
@@ -1363,7 +1363,7 @@ void LLPanelGroupMembersSubTab::applyMemberChanges()
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap)
 	{
-		llwarns << "Unable to get group data for group " << mGroupID << llendl;
+		LL_WARNS() << "Unable to get group data for group " << mGroupID << LL_ENDL;
 		return;
 	}
 
@@ -1427,21 +1427,21 @@ U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& ag
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- No group data!" << LL_ENDL;
 		return GP_NO_POWERS;
 	}
 
 	LLGroupMgrGroupData::member_list_t::iterator iter = gdatap->mMembers.find(agent_id);
 	if ( iter == gdatap->mMembers.end() )
 	{
-		llwarns << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- No member data for member with UUID " << agent_id << llendl;
+		LL_WARNS() << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- No member data for member with UUID " << agent_id << LL_ENDL;
 		return GP_NO_POWERS;
 	}
 
 	LLGroupMemberData* member_data = (*iter).second;
 	if (!member_data)
 	{
-		llwarns << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- Null member data for member with UUID " << agent_id << llendl;
+		LL_WARNS() << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- Null member data for member with UUID " << agent_id << LL_ENDL;
 		return GP_NO_POWERS;
 	}
 
@@ -1547,7 +1547,7 @@ void LLPanelGroupMembersSubTab::update(LLGroupChange gc)
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupMembersSubTab::update() -- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupMembersSubTab::update() -- No group data!" << LL_ENDL;
 		return;
 	}
 
@@ -1640,7 +1640,7 @@ void LLPanelGroupMembersSubTab::updateMembers()
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupMembersSubTab::updateMembers() -- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupMembersSubTab::updateMembers() -- No group data!" << LL_ENDL;
 		return;
 	}
 
@@ -1766,7 +1766,7 @@ BOOL LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root)
 	if (!mRolesList || !mAssignedMembersList || !mAllowedActionsList
 		|| !mRoleName || !mRoleTitle || !mRoleDescription || !mMemberVisibleCheck)
 	{
-		llwarns << "ARG! element not found." << llendl;
+		LL_WARNS() << "ARG! element not found." << LL_ENDL;
 		return FALSE;
 	}
 
@@ -1830,14 +1830,14 @@ void LLPanelGroupRolesSubTab::activate()
 
 void LLPanelGroupRolesSubTab::deactivate()
 {
-	lldebugs << "LLPanelGroupRolesSubTab::deactivate()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRolesSubTab::deactivate()" << LL_ENDL;
 
 	LLPanelGroupSubTab::deactivate();
 }
 
 bool LLPanelGroupRolesSubTab::needsApply(std::string& mesg)
 {
-	lldebugs << "LLPanelGroupRolesSubTab::needsApply()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRolesSubTab::needsApply()" << LL_ENDL;
 
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 
@@ -1847,7 +1847,7 @@ bool LLPanelGroupRolesSubTab::needsApply(std::string& mesg)
 
 bool LLPanelGroupRolesSubTab::apply(std::string& mesg)
 {
-	lldebugs << "LLPanelGroupRolesSubTab::apply()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRolesSubTab::apply()" << LL_ENDL;
 
 	saveRoleChanges(true);
 
@@ -1910,7 +1910,7 @@ bool LLPanelGroupRolesSubTab::matchesSearchFilter(std::string rolename, std::str
 
 void LLPanelGroupRolesSubTab::update(LLGroupChange gc)
 {
-	lldebugs << "LLPanelGroupRolesSubTab::update()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRolesSubTab::update()" << LL_ENDL;
 
 	if (mGroupID.isNull()) return;
 
@@ -1955,7 +1955,7 @@ void LLPanelGroupRolesSubTab::update(LLGroupChange gc)
 			}
 			else
 			{
-				llwarns << "LLPanelGroupRolesSubTab::update() No role data for role " << (*rit).first << llendl;
+				LL_WARNS() << "LLPanelGroupRolesSubTab::update() No role data for role " << (*rit).first << LL_ENDL;
 			}
 		}
 
@@ -2016,7 +2016,7 @@ void LLPanelGroupRolesSubTab::onRoleSelect(LLUICtrl* ctrl, void* user_data)
 void LLPanelGroupRolesSubTab::handleRoleSelect()
 {
 	BOOL can_delete = TRUE;
-	lldebugs << "LLPanelGroupRolesSubTab::handleRoleSelect()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRolesSubTab::handleRoleSelect()" << LL_ENDL;
 
 	mAssignedMembersList->deleteAllItems();
 	mAllowedActionsList->deleteAllItems();
@@ -2024,8 +2024,8 @@ void LLPanelGroupRolesSubTab::handleRoleSelect()
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupRolesSubTab::handleRoleSelect() "
-				<< "-- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupRolesSubTab::handleRoleSelect() "
+				<< "-- No group data!" << LL_ENDL;
 		return;
 	}
 
@@ -2113,8 +2113,8 @@ void LLPanelGroupRolesSubTab::buildMembersList()
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupRolesSubTab::handleRoleSelect() "
-				<< "-- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupRolesSubTab::handleRoleSelect() "
+				<< "-- No group data!" << LL_ENDL;
 		return;
 	}
 
@@ -2163,13 +2163,13 @@ void LLPanelGroupRolesSubTab::handleActionCheck(LLUICtrl* ctrl, bool force)
 	if (!check)
 		return;
 	
-	lldebugs << "LLPanelGroupRolesSubTab::handleActionSelect()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRolesSubTab::handleActionSelect()" << LL_ENDL;
 
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupRolesSubTab::handleRoleSelect() "
-				<< "-- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupRolesSubTab::handleRoleSelect() "
+				<< "-- No group data!" << LL_ENDL;
 		return;
 	}
 
@@ -2215,8 +2215,8 @@ void LLPanelGroupRolesSubTab::handleActionCheck(LLUICtrl* ctrl, bool force)
 			}
 			else
 			{
-				llwarns << "Unable to look up role information for role id: "
-						<< role_id << llendl;
+				LL_WARNS() << "Unable to look up role information for role id: "
+						<< role_id << LL_ENDL;
 			}
 		}
 		else
@@ -2289,13 +2289,13 @@ void LLPanelGroupRolesSubTab::onMemberVisibilityChange(LLUICtrl* ctrl, void* use
 
 void LLPanelGroupRolesSubTab::handleMemberVisibilityChange(bool value)
 {
-	lldebugs << "LLPanelGroupRolesSubTab::handleMemberVisibilityChange()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupRolesSubTab::handleMemberVisibilityChange()" << LL_ENDL;
 
 	LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID);
 	if (!gdatap) 
 	{
-		llwarns << "LLPanelGroupRolesSubTab::handleRoleSelect() "
-				<< "-- No group data!" << llendl;
+		LL_WARNS() << "LLPanelGroupRolesSubTab::handleRoleSelect() "
+				<< "-- No group data!" << LL_ENDL;
 		return;
 	}
 
@@ -2482,27 +2482,27 @@ void LLPanelGroupActionsSubTab::activate()
 
 void LLPanelGroupActionsSubTab::deactivate()
 {
-	lldebugs << "LLPanelGroupActionsSubTab::deactivate()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupActionsSubTab::deactivate()" << LL_ENDL;
 
 	LLPanelGroupSubTab::deactivate();
 }
 
 bool LLPanelGroupActionsSubTab::needsApply(std::string& mesg)
 {
-	lldebugs << "LLPanelGroupActionsSubTab::needsApply()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupActionsSubTab::needsApply()" << LL_ENDL;
 
 	return false;
 }
 
 bool LLPanelGroupActionsSubTab::apply(std::string& mesg)
 {
-	lldebugs << "LLPanelGroupActionsSubTab::apply()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupActionsSubTab::apply()" << LL_ENDL;
 	return true;
 }
 
 void LLPanelGroupActionsSubTab::update(LLGroupChange gc)
 {
-	lldebugs << "LLPanelGroupActionsSubTab::update()" << llendl;
+	LL_DEBUGS() << "LLPanelGroupActionsSubTab::update()" << LL_ENDL;
 
 	if (mGroupID.isNull()) return;
 
diff --git a/indra/newview/llpanelland.cpp b/indra/newview/llpanelland.cpp
index 5321ebc777..9b21fbf6b7 100755
--- a/indra/newview/llpanelland.cpp
+++ b/indra/newview/llpanelland.cpp
@@ -187,7 +187,7 @@ void LLPanelLandInfo::refresh()
 		}
 		else
 		{
-			lldebugs << "Invalid selection for joining land" << llendl;
+			LL_DEBUGS() << "Invalid selection for joining land" << LL_ENDL;
 			getChildView("button join land")->setEnabled(FALSE);
 		}
 
diff --git a/indra/newview/llpanellandmarkinfo.cpp b/indra/newview/llpanellandmarkinfo.cpp
index 79815e7be5..6ef9172516 100755
--- a/indra/newview/llpanellandmarkinfo.cpp
+++ b/indra/newview/llpanellandmarkinfo.cpp
@@ -435,7 +435,7 @@ void LLPanelLandmarkInfo::populateFoldersList()
 	const LLViewerInventoryCategory* lmcat = gInventory.getCategory(landmarks_id);
 	if (!lmcat)
 	{
-		llwarns << "Cannot find the landmarks folder" << llendl;
+		LL_WARNS() << "Cannot find the landmarks folder" << LL_ENDL;
 	}
 	else
 	{
@@ -483,7 +483,7 @@ static void collectLandmarkFolders(LLInventoryModel::cat_array_t& cats)
 	LLViewerInventoryCategory* favorites_cat = gInventory.getCategory(favorites_id);
 	if (!favorites_cat)
 	{
-		llwarns << "Cannot find the favorites folder" << llendl;
+		LL_WARNS() << "Cannot find the favorites folder" << LL_ENDL;
 	}
 	else
 	{
diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp
index 88400e4ef2..b941ee1f1b 100755
--- a/indra/newview/llpanellandmarks.cpp
+++ b/indra/newview/llpanellandmarks.cpp
@@ -264,7 +264,7 @@ void LLLandmarksPanel::onShowOnMap()
 {
 	if (NULL == mCurrentSelectedList)
 	{
-		llwarns << "There are no selected list. No actions are performed." << llendl;
+		LL_WARNS() << "There are no selected list. No actions are performed." << LL_ENDL;
 		return;
 	}
 
@@ -421,7 +421,7 @@ bool LLLandmarksPanel::isReceivedFolderSelected() const
 
 	// *TODO: it should be filled with logic when EXT-976 is done.
 
-	llwarns << "Not implemented yet until EXT-976 is done." << llendl;
+	LL_WARNS() << "Not implemented yet until EXT-976 is done." << LL_ENDL;
 
 	return false;
 }
@@ -529,7 +529,7 @@ void LLLandmarksPanel::setParcelID(const LLUUID& parcel_id)
 // virtual
 void LLLandmarksPanel::setErrorStatus(U32 status, const std::string& reason)
 {
-	llwarns << "Can't handle remote parcel request."<< " Http Status: "<< status << ". Reason : "<< reason<<llendl;
+	LL_WARNS() << "Can't handle remote parcel request."<< " Http Status: "<< status << ". Reason : "<< reason<<LL_ENDL;
 }
 
 
@@ -1042,7 +1042,7 @@ bool LLLandmarksPanel::isActionEnabled(const LLSD& userdata) const
 	}
 	else
 	{
-		llwarns << "Unprocessed command has come: " << command_name << llendl;
+		LL_WARNS() << "Unprocessed command has come: " << command_name << LL_ENDL;
 	}
 
 	return true;
@@ -1201,7 +1201,7 @@ bool LLLandmarksPanel::canItemBeModified(const std::string& command_name, LLFold
 		}
 		else
 		{
-			llwarns << "Unprocessed command has come: " << command_name << llendl;
+			LL_WARNS() << "Unprocessed command has come: " << command_name << LL_ENDL;
 		}
 	}
 
@@ -1359,9 +1359,9 @@ void LLLandmarksPanel::doCreatePick(LLLandmark* landmark)
 	}
 	else
 	{
-		llwarns << "Can't create pick for landmark for region" << region_id
+		LL_WARNS() << "Can't create pick for landmark for region" << region_id
 				<< ". Region: "	<< region->getName()
-				<< " does not support RemoteParcelRequest" << llendl;
+				<< " does not support RemoteParcelRequest" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index c96173f550..efcfd045ba 100755
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -281,12 +281,12 @@ void LLPanelLogin::addFavoritesToStartLocation()
 		S32 res = LLStringUtil::compareInsensitive(canonical_user_name, iter->first);
 		if (res != 0)
 		{
-			lldebugs << "Skipping favorites for " << iter->first << llendl;
+			LL_DEBUGS() << "Skipping favorites for " << iter->first << LL_ENDL;
 			continue;
 		}
 
 		combo->addSeparator();
-		lldebugs << "Loading favorites for " << iter->first << llendl;
+		LL_DEBUGS() << "Loading favorites for " << iter->first << LL_ENDL;
 		LLSD user_llsd = iter->second;
 		for (LLSD::array_const_iterator iter1 = user_llsd.beginArray();
 			iter1 != user_llsd.endArray(); ++iter1)
@@ -465,7 +465,7 @@ void LLPanelLogin::setFields(LLPointer<LLCredential> credential,
 {
 	if (!sInstance)
 	{
-		llwarns << "Attempted fillFields with no login view shown" << llendl;
+		LL_WARNS() << "Attempted fillFields with no login view shown" << LL_ENDL;
 		return;
 	}
 	LL_INFOS("Credentials") << "Setting login fields to " << *credential << LL_ENDL;
@@ -523,7 +523,7 @@ void LLPanelLogin::getFields(LLPointer<LLCredential>& credential,
 {
 	if (!sInstance)
 	{
-		llwarns << "Attempted getFields with no login view shown" << llendl;
+		LL_WARNS() << "Attempted getFields with no login view shown" << LL_ENDL;
 		return;
 	}
 	
@@ -613,7 +613,7 @@ BOOL LLPanelLogin::areCredentialFieldsDirty()
 {
 	if (!sInstance)
 	{
-		llwarns << "Attempted getServer with no login view shown" << llendl;
+		LL_WARNS() << "Attempted getServer with no login view shown" << LL_ENDL;
 	}
 	else
 	{
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index d6535c88e9..7bf5e28822 100755
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -156,7 +156,7 @@ BOOL LLPanelMainInventory::postBuild()
 	// Now load the stored settings from disk, if available.
 	std::ostringstream filterSaveName;
 	filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, FILTERS_FILENAME);
-	llinfos << "LLPanelMainInventory::init: reading from " << filterSaveName.str() << llendl;
+	LL_INFOS() << "LLPanelMainInventory::init: reading from " << filterSaveName.str() << LL_ENDL;
 	llifstream file(filterSaveName.str());
 	LLSD savedFilterState;
 	if (file.is_open())
@@ -242,7 +242,7 @@ LLPanelMainInventory::~LLPanelMainInventory( void )
 	llofstream filtersFile(filterSaveName.str());
 	if(!LLSDSerialize::toPrettyXML(filterRoot, filtersFile))
 	{
-		llwarns << "Could not write to filters save file " << filterSaveName << llendl;
+		LL_WARNS() << "Could not write to filters save file " << filterSaveName << LL_ENDL;
 	}
 	else
 		filtersFile.close();
@@ -598,7 +598,7 @@ void LLPanelMainInventory::onFocusReceived()
 	LLSidepanelInventory *sidepanel_inventory =	LLFloaterSidePanelContainer::getPanel<LLSidepanelInventory>("inventory");
 	if (!sidepanel_inventory)
 	{
-		llwarns << "Could not find Inventory Panel in My Inventory floater" << llendl;
+		LL_WARNS() << "Could not find Inventory Panel in My Inventory floater" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llpanelmarketplaceinboxinventory.cpp b/indra/newview/llpanelmarketplaceinboxinventory.cpp
index adfb2dee86..43321188e7 100755
--- a/indra/newview/llpanelmarketplaceinboxinventory.cpp
+++ b/indra/newview/llpanelmarketplaceinboxinventory.cpp
@@ -164,7 +164,7 @@ void LLInboxFolderViewFolder::computeFreshness()
 #if DEBUGGING_FRESHNESS
 		if (mFresh)
 		{
-			llinfos << "Item is fresh! -- creation " << mCreationDate << ", saved_freshness_date " << last_expansion_utc << llendl;
+			LL_INFOS() << "Item is fresh! -- creation " << mCreationDate << ", saved_freshness_date " << last_expansion_utc << LL_ENDL;
 		}
 #endif
 	}
@@ -242,7 +242,7 @@ void LLInboxFolderViewItem::computeFreshness()
 #if DEBUGGING_FRESHNESS
 		if (mFresh)
 		{
-			llinfos << "Item is fresh! -- creation " << mCreationDate << ", saved_freshness_date " << last_expansion_utc << llendl;
+			LL_INFOS() << "Item is fresh! -- creation " << mCreationDate << ", saved_freshness_date " << last_expansion_utc << LL_ENDL;
 		}
 #endif
 	}
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index 25ef9a3d6a..9123252f4c 100755
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -625,7 +625,7 @@ void LLPanelObject::getState( )
 		}
 		else
 		{
-			llinfos << "Unknown path " << (S32) path << " profile " << (S32) profile << " in getState" << llendl;
+			LL_INFOS() << "Unknown path " << (S32) path << " profile " << (S32) profile << " in getState" << LL_ENDL;
 			selected_item = MI_BOX;
 		}
 
@@ -1175,11 +1175,11 @@ void LLPanelObject::sendIsPhysical()
 		LLSelectMgr::getInstance()->selectionUpdatePhysics(value);
 		mIsPhysical = value;
 
-		llinfos << "update physics sent" << llendl;
+		LL_INFOS() << "update physics sent" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "update physics not changed" << llendl;
+		LL_INFOS() << "update physics not changed" << LL_ENDL;
 	}
 }
 
@@ -1191,11 +1191,11 @@ void LLPanelObject::sendIsTemporary()
 		LLSelectMgr::getInstance()->selectionUpdateTemporary(value);
 		mIsTemporary = value;
 
-		llinfos << "update temporary sent" << llendl;
+		LL_INFOS() << "update temporary sent" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "update temporary not changed" << llendl;
+		LL_INFOS() << "update temporary not changed" << LL_ENDL;
 	}
 }
 
@@ -1208,11 +1208,11 @@ void LLPanelObject::sendIsPhantom()
 		LLSelectMgr::getInstance()->selectionUpdatePhantom(value);
 		mIsPhantom = value;
 
-		llinfos << "update phantom sent" << llendl;
+		LL_INFOS() << "update phantom sent" << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "update phantom not changed" << llendl;
+		LL_INFOS() << "update phantom not changed" << LL_ENDL;
 	}
 }
 
@@ -1322,8 +1322,8 @@ void LLPanelObject::getVolumeParams(LLVolumeParams& volume_params)
 		break;
 		
 	default:
-		llwarns << "Unknown base type " << selected_type 
-			<< " in getVolumeParams()" << llendl;
+		LL_WARNS() << "Unknown base type " << selected_type 
+			<< " in getVolumeParams()" << LL_ENDL;
 		// assume a box
 		selected_type = MI_BOX;
 		profile = LL_PCODE_PROFILE_SQUARE;
@@ -1640,11 +1640,11 @@ void LLPanelObject::sendScale(BOOL btn_down)
 		}
 
 		LLSelectMgr::getInstance()->adjustTexturesByScale(TRUE, !dont_stretch_textures);
-//		llinfos << "scale sent" << llendl;
+//		LL_INFOS() << "scale sent" << LL_ENDL;
 	}
 	else
 	{
-//		llinfos << "scale not changed" << llendl;
+//		LL_INFOS() << "scale not changed" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llpanelobjectinventory.cpp b/indra/newview/llpanelobjectinventory.cpp
index 94cb90b993..77bfcec4e0 100755
--- a/indra/newview/llpanelobjectinventory.cpp
+++ b/indra/newview/llpanelobjectinventory.cpp
@@ -210,7 +210,7 @@ struct LLBuyInvItemData
 
 void LLTaskInvFVBridge::buyItem()
 {
-	llinfos << "LLTaskInvFVBridge::buyItem()" << llendl;
+	LL_INFOS() << "LLTaskInvFVBridge::buyItem()" << LL_ENDL;
 	LLInventoryItem* item = findItem();
 	if(!item || !item->getSaleInfo().isForSale()) return;
 	LLBuyInvItemData* inv = new LLBuyInvItemData(mPanel->getTaskUUID(),
@@ -225,7 +225,7 @@ void LLTaskInvFVBridge::buyItem()
 	if( ( obj = gObjectList.findObject( mPanel->getTaskUUID() ) ) && obj->isAttachment() )
 	{
 		LLNotificationsUtil::add("Cannot_Purchase_an_Attachment");
-		llinfos << "Attempt to purchase an attachment" << llendl;
+		LL_INFOS() << "Attempt to purchase an attachment" << LL_ENDL;
 		delete inv;
 	}
 	else
@@ -372,7 +372,7 @@ LLUIImagePtr LLTaskInvFVBridge::getIcon() const
 void LLTaskInvFVBridge::openItem()
 {
 	// no-op.
-	lldebugs << "LLTaskInvFVBridge::openItem()" << llendl;
+	LL_DEBUGS() << "LLTaskInvFVBridge::openItem()" << LL_ENDL;
 }
 
 BOOL LLTaskInvFVBridge::isItemRenameable() const
@@ -562,7 +562,7 @@ void LLTaskInvFVBridge::pasteLinkFromClipboard()
 
 BOOL LLTaskInvFVBridge::startDrag(EDragAndDropType* type, LLUUID* id) const
 {
-	//llinfos << "LLTaskInvFVBridge::startDrag()" << llendl;
+	//LL_INFOS() << "LLTaskInvFVBridge::startDrag()" << LL_ENDL;
 	if(mPanel)
 	{
 		LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID());
@@ -603,7 +603,7 @@ BOOL LLTaskInvFVBridge::dragOrDrop(MASK mask, BOOL drop,
 								   void* cargo_data,
 								   std::string& tooltip_msg)
 {
-	//llinfos << "LLTaskInvFVBridge::dragOrDrop()" << llendl;
+	//LL_INFOS() << "LLTaskInvFVBridge::dragOrDrop()" << LL_ENDL;
 	return FALSE;
 }
 
@@ -616,7 +616,7 @@ void LLTaskInvFVBridge::performAction(LLInventoryModel* model, std::string actio
 		S32 price = getPrice();
 		if (-1 == price)
 		{
-			llwarns << "label_buy_task_bridged_item: Invalid price" << llendl;
+			LL_WARNS() << "label_buy_task_bridged_item: Invalid price" << LL_ENDL;
 		}
 		else
 		{
@@ -665,7 +665,7 @@ void LLTaskInvFVBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 		S32 price = getPrice();
 		if (-1 == price)
 		{
-			llwarns << "label_buy_task_bridged_item: Invalid price" << llendl;
+			LL_WARNS() << "label_buy_task_bridged_item: Invalid price" << LL_ENDL;
 		}
 		else
 		{
@@ -799,7 +799,7 @@ void LLTaskCategoryBridge::openItem()
 
 BOOL LLTaskCategoryBridge::startDrag(EDragAndDropType* type, LLUUID* id) const
 {
-	//llinfos << "LLTaskInvFVBridge::startDrag()" << llendl;
+	//LL_INFOS() << "LLTaskInvFVBridge::startDrag()" << LL_ENDL;
 	if(mPanel && mUUID.notNull())
 	{
 		LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID());
@@ -822,7 +822,7 @@ BOOL LLTaskCategoryBridge::dragOrDrop(MASK mask, BOOL drop,
 									  void* cargo_data,
 									  std::string& tooltip_msg)
 {
-	//llinfos << "LLTaskCategoryBridge::dragOrDrop()" << llendl;
+	//LL_INFOS() << "LLTaskCategoryBridge::dragOrDrop()" << LL_ENDL;
 	BOOL accept = FALSE;
 	LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID());
 	if(object)
@@ -901,7 +901,7 @@ public:
 
 void LLTaskTextureBridge::openItem()
 {
-	llinfos << "LLTaskTextureBridge::openItem()" << llendl;
+	LL_INFOS() << "LLTaskTextureBridge::openItem()" << LL_ENDL;
 	LLPreviewTexture* preview = LLFloaterReg::showTypedInstance<LLPreviewTexture>("preview_texture", LLSD(mUUID), TAKE_FOCUS_YES);
 	if(preview)
 	{
@@ -978,7 +978,7 @@ void LLTaskSoundBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 		S32 price = getPrice();
 		if (-1 == price)
 		{
-			llwarns << "label_buy_task_bridged_item: Invalid price" << llendl;
+			LL_WARNS() << "label_buy_task_bridged_item: Invalid price" << LL_ENDL;
 		}
 		else
 		{
@@ -1095,7 +1095,7 @@ public:
 
 void LLTaskLSLBridge::openItem()
 {
-	llinfos << "LLTaskLSLBridge::openItem() " << mUUID << llendl;
+	LL_INFOS() << "LLTaskLSLBridge::openItem() " << mUUID << LL_ENDL;
 	LLViewerObject* object = gObjectList.findObject(mPanel->getTaskUUID());
 	if(!object || object->isInventoryPending())
 	{
@@ -1336,7 +1336,7 @@ void LLTaskMeshBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 		S32 price = getPrice();
 		if (-1 == price)
 		{
-			llwarns << "label_buy_task_bridged_item: Invalid price" << llendl;
+			LL_WARNS() << "label_buy_task_bridged_item: Invalid price" << LL_ENDL;
 		}
 		else
 		{
@@ -1417,7 +1417,7 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory*
 		break;
 	case LLAssetType::AT_SCRIPT:
 		// OLD SCRIPTS DEPRECATED - JC
-		llwarns << "Old script" << llendl;
+		LL_WARNS() << "Old script" << LL_ENDL;
 		//new_bridge = new LLTaskOldScriptBridge(panel,
 		//									   object_id,
 		//									   object_name);
@@ -1466,8 +1466,8 @@ LLTaskInvFVBridge* LLTaskInvFVBridge::createObjectBridge(LLPanelObjectInventory*
 										  object_name);
 		break;
 	default:
-		llinfos << "Unhandled inventory type (llassetstorage.h): "
-				<< (S32)type << llendl;
+		LL_INFOS() << "Unhandled inventory type (llassetstorage.h): "
+				<< (S32)type << LL_ENDL;
 		break;
 	}
 	return new_bridge;
@@ -1508,7 +1508,7 @@ LLPanelObjectInventory::~LLPanelObjectInventory()
 {
 	if (!gIdleCallbacks.deleteFunction(idle, this))
 	{
-		llwarns << "LLPanelObjectInventory::~LLPanelObjectInventory() failed to delete callback" << llendl;
+		LL_WARNS() << "LLPanelObjectInventory::~LLPanelObjectInventory() failed to delete callback" << LL_ENDL;
 	}
 }
 
@@ -1603,9 +1603,9 @@ void LLPanelObjectInventory::inventoryChanged(LLViewerObject* object,
 {
 	if(!object) return;
 
-	//llinfos << "invetnory arrived: \n"
+	//LL_INFOS() << "invetnory arrived: \n"
 	//		<< " panel UUID: " << panel->mTaskUUID << "\n"
-	//		<< " task  UUID: " << object->mID << llendl;
+	//		<< " task  UUID: " << object->mID << LL_ENDL;
 	if(mTaskUUID == object->mID)
 	{
 		mInventoryNeedsUpdate = TRUE;
@@ -1629,9 +1629,9 @@ void LLPanelObjectInventory::inventoryChanged(LLViewerObject* object,
 
 void LLPanelObjectInventory::updateInventory()
 {
-	//llinfos << "inventory arrived: \n"
+	//LL_INFOS() << "inventory arrived: \n"
 	//		<< " panel UUID: " << panel->mTaskUUID << "\n"
-	//		<< " task  UUID: " << object->mID << llendl;
+	//		<< " task  UUID: " << object->mID << LL_ENDL;
 	// We're still interested in this task's inventory.
 	std::vector<LLUUID> selected_item_ids;
 	std::set<LLFolderViewItem*> selected_items;
@@ -1812,7 +1812,7 @@ void LLPanelObjectInventory::createViewsForCategory(LLInventoryObject::object_li
 
 void LLPanelObjectInventory::refresh()
 {
-	//llinfos << "LLPanelObjectInventory::refresh()" << llendl;
+	//LL_INFOS() << "LLPanelObjectInventory::refresh()" << LL_ENDL;
 	BOOL has_inventory = FALSE;
 	const BOOL non_root_ok = TRUE;
 	LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(NULL, non_root_ok);
@@ -1866,7 +1866,7 @@ void LLPanelObjectInventory::refresh()
 		clearContents();
 	}
 	mInventoryViewModel.setTaskID(mTaskUUID);
-	//llinfos << "LLPanelObjectInventory::refresh() " << mTaskUUID << llendl;
+	//LL_INFOS() << "LLPanelObjectInventory::refresh() " << mTaskUUID << LL_ENDL;
 }
 
 void LLPanelObjectInventory::removeSelectedItem()
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp
index 7648e12f96..f91d92e646 100755
--- a/indra/newview/llpaneloutfitedit.cpp
+++ b/indra/newview/llpaneloutfitedit.cpp
@@ -176,7 +176,7 @@ private:
 		LLWearableType::EType type = LLWearableType::typeNameToType(param.asString());
 		if (type == LLWearableType::WT_NONE)
 		{
-			llwarns << "Invalid wearable type" << llendl;
+			LL_WARNS() << "Invalid wearable type" << LL_ENDL;
 			return;
 		}
 
@@ -263,7 +263,7 @@ private:
 		}
 		else
 		{
-			llwarns << "Unrecognized sort order action" << llendl;
+			LL_WARNS() << "Unrecognized sort order action" << LL_ENDL;
 			return;
 		}
 
@@ -306,7 +306,7 @@ private:
 				// If inventory panel is not sorted by date then it is sorted by name.
 				return LLWearableItemsList::E_SORT_BY_MOST_RECENT & ~sort_order;
 			}
-			llwarns << "Unrecognized inventory panel sort order" << llendl;
+			LL_WARNS() << "Unrecognized inventory panel sort order" << LL_ENDL;
 		}
 		else
 		{
@@ -324,7 +324,7 @@ private:
 			{
 				return LLWearableItemsList::E_SORT_BY_TYPE_NAME == sort_order;
 			}
-			llwarns << "Unrecognized wearable list sort order" << llendl;
+			LL_WARNS() << "Unrecognized wearable list sort order" << LL_ENDL;
 		}
 		return false;
 	}
@@ -842,7 +842,7 @@ void LLPanelOutfitEdit::onShopButtonClicked()
 	}
 	else
 	{
-		llwarns << "Agent avatar is invalid" << llendl;
+		LL_WARNS() << "Agent avatar is invalid" << LL_ENDL;
 
 		// the second argument is not important in this case: generic market place will be opened
 		url = url_resolver.resolveURL(LLWearableType::WT_NONE, SEX_FEMALE);
@@ -1154,7 +1154,7 @@ BOOL LLPanelOutfitEdit::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
 {
 	if (cargo_data == NULL)
 	{
-		llwarns << "cargo_data is NULL" << llendl;
+		LL_WARNS() << "cargo_data is NULL" << LL_ENDL;
 		return TRUE;
 	}
 
@@ -1260,7 +1260,7 @@ void LLPanelOutfitEdit::resetAccordionState()
 	}
 	else
 	{
-		llwarns << "mCOFWearables is NULL" << llendl;
+		LL_WARNS() << "mCOFWearables is NULL" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 4138558bad..c9688e743e 100755
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -382,7 +382,7 @@ private:
 		}
 		/*virtual*/ void changed(U32 mask)
 		{
-			lldebugs << "Inventory changed: " << mask << llendl;
+			LL_DEBUGS() << "Inventory changed: " << mask << LL_ENDL;
 
 			static bool synchronize_friends_folders = true;
 			if (synchronize_friends_folders)
@@ -398,9 +398,9 @@ private:
 			// That means LLInventoryObserver::STRUCTURE is present in MASK instead of LLInventoryObserver::REMOVE
 			if ((CALLINGCARD_ADDED & mask) == CALLINGCARD_ADDED)
 			{
-				lldebugs << "Calling card added: count: " << gInventory.getChangedIDs().size() 
+				LL_DEBUGS() << "Calling card added: count: " << gInventory.getChangedIDs().size() 
 					<< ", first Inventory ID: "<< (*gInventory.getChangedIDs().begin())
-					<< llendl;
+					<< LL_ENDL;
 
 				bool friendFound = false;
 				std::set<LLUUID> changedIDs = gInventory.getChangedIDs();
@@ -415,7 +415,7 @@ private:
 
 				if (friendFound)
 				{
-					lldebugs << "friend found, panel should be updated" << llendl;
+					LL_DEBUGS() << "friend found, panel should be updated" << LL_ENDL;
 					mUpdater->changed(LLFriendObserver::ADD);
 				}
 			}
@@ -543,7 +543,7 @@ void LLPanelPeople::onFriendsAccordionExpandedCollapsed(LLUICtrl* ctrl, const LL
 {
 	if(!avatar_list)
 	{
-		llerrs << "Bad parameter" << llendl;
+		LL_ERRS() << "Bad parameter" << LL_ENDL;
 		return;
 	}
 
@@ -650,7 +650,7 @@ BOOL LLPanelPeople::postBuild()
 	}
 	else
 	{
-		llwarns << "People->Groups list menu not found" << llendl;
+		LL_WARNS() << "People->Groups list menu not found" << LL_ENDL;
 	}
 
 	LLAccordionCtrlTab* accordion_tab = getChild<LLAccordionCtrlTab>("tab_all");
@@ -735,12 +735,12 @@ void LLPanelPeople::updateFriendList()
 
 	if (buddies_uuids.size() > 0)
 	{
-		lldebugs << "Friends added to the list: " << buddies_uuids.size() << llendl;
+		LL_DEBUGS() << "Friends added to the list: " << buddies_uuids.size() << LL_ENDL;
 		all_friendsp = buddies_uuids;
 	}
 	else
 	{
-		lldebugs << "No friends found" << llendl;
+		LL_DEBUGS() << "No friends found" << LL_ENDL;
 	}
 
 	LLAvatarTracker::buddy_map_t::const_iterator buddy_it = all_buddies.begin();
@@ -941,7 +941,7 @@ void LLPanelPeople::setSortOrder(LLAvatarList* list, ESortOrder order, bool save
 		list->sort();
 		break;
 	default:
-		llwarns << "Unrecognized people sort order for " << list->getName() << llendl;
+		LL_WARNS() << "Unrecognized people sort order for " << list->getName() << LL_ENDL;
 		return;
 	}
 
@@ -1337,7 +1337,7 @@ bool LLPanelPeople::notifyChildren(const LLSD& info)
 		LLSideTrayPanelContainer* container = dynamic_cast<LLSideTrayPanelContainer*>(getParent());
 		if (!container)
 		{
-			llwarns << "Cannot find People panel container" << llendl;
+			LL_WARNS() << "Cannot find People panel container" << LL_ENDL;
 			return true;
 		}
 
@@ -1359,7 +1359,7 @@ void LLPanelPeople::showAccordion(const std::string name, bool show)
 {
 	if(name.empty())
 	{
-		llwarns << "No name provided" << llendl;
+		LL_WARNS() << "No name provided" << LL_ENDL;
 		return;
 	}
 
@@ -1411,7 +1411,7 @@ void LLPanelPeople::setAccordionCollapsedByUser(LLUICtrl* acc_tab, bool collapse
 {
 	if(!acc_tab)
 	{
-		llwarns << "Invalid parameter" << llendl;
+		LL_WARNS() << "Invalid parameter" << LL_ENDL;
 		return;
 	}
 
@@ -1429,7 +1429,7 @@ bool LLPanelPeople::isAccordionCollapsedByUser(LLUICtrl* acc_tab)
 {
 	if(!acc_tab)
 	{
-		llwarns << "Invalid parameter" << llendl;
+		LL_WARNS() << "Invalid parameter" << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp
index 79bcf15c1d..58055d98c6 100755
--- a/indra/newview/llpanelpermissions.cpp
+++ b/indra/newview/llpanelpermissions.cpp
@@ -963,28 +963,28 @@ void LLPanelPermissions::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
 // static
 void LLPanelPermissions::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
 {
-	//llinfos << "LLPanelPermissions::onCommitNextOwnerModify" << llendl;
+	//LL_INFOS() << "LLPanelPermissions::onCommitNextOwnerModify" << LL_ENDL;
 	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
 }
 
 // static
 void LLPanelPermissions::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
 {
-	//llinfos << "LLPanelPermissions::onCommitNextOwnerCopy" << llendl;
+	//LL_INFOS() << "LLPanelPermissions::onCommitNextOwnerCopy" << LL_ENDL;
 	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
 }
 
 // static
 void LLPanelPermissions::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
 {
-	//llinfos << "LLPanelPermissions::onCommitNextOwnerTransfer" << llendl;
+	//LL_INFOS() << "LLPanelPermissions::onCommitNextOwnerTransfer" << LL_ENDL;
 	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
 }
 
 // static
 void LLPanelPermissions::onCommitName(LLUICtrl*, void* data)
 {
-	//llinfos << "LLPanelPermissions::onCommitName()" << llendl;
+	//LL_INFOS() << "LLPanelPermissions::onCommitName()" << LL_ENDL;
 	LLPanelPermissions* self = (LLPanelPermissions*)data;
 	LLLineEditor*	tb = self->getChild<LLLineEditor>("Object Name");
 	if(tb)
@@ -998,7 +998,7 @@ void LLPanelPermissions::onCommitName(LLUICtrl*, void* data)
 // static
 void LLPanelPermissions::onCommitDesc(LLUICtrl*, void* data)
 {
-	//llinfos << "LLPanelPermissions::onCommitDesc()" << llendl;
+	//LL_INFOS() << "LLPanelPermissions::onCommitDesc()" << LL_ENDL;
 	LLPanelPermissions* self = (LLPanelPermissions*)data;
 	LLLineEditor*	le = self->getChild<LLLineEditor>("Object Description");
 	if(le)
@@ -1023,7 +1023,7 @@ void LLPanelPermissions::onCommitSaleType(LLUICtrl*, void* data)
 
 void LLPanelPermissions::setAllSaleInfo()
 {
-	llinfos << "LLPanelPermissions::setAllSaleInfo()" << llendl;
+	LL_INFOS() << "LLPanelPermissions::setAllSaleInfo()" << LL_ENDL;
 	LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT;
 
 	LLCheckBoxCtrl *checkPurchase = getChild<LLCheckBoxCtrl>("checkbox for sale");
diff --git a/indra/newview/llpanelpicks.cpp b/indra/newview/llpanelpicks.cpp
index f2ef2ec003..7fbb2a078b 100755
--- a/indra/newview/llpanelpicks.cpp
+++ b/indra/newview/llpanelpicks.cpp
@@ -122,7 +122,7 @@ public:
 		}
 		else
 		{
-			llwarns << "unknown verb " << verb << llendl;
+			LL_WARNS() << "unknown verb " << verb << LL_ENDL;
 			return false;
 		}
 	}
@@ -173,7 +173,7 @@ public:
 		}
 		else
 		{
-			llwarns << "Can't edit a pick you did not create" << llendl;
+			LL_WARNS() << "Can't edit a pick you did not create" << LL_ENDL;
 		}
 
 		// remove our observer now that we're done
@@ -280,7 +280,7 @@ public:
 		{
 			if (c_info->creator_id == gAgent.getID())
 			{
-				llwarns << "edit in progress" << llendl;
+				LL_WARNS() << "edit in progress" << LL_ENDL;
 				// open the new classified panel on the Me > Picks sidetray
 				LLSD params;
 				params["id"] = gAgent.getID();
@@ -291,7 +291,7 @@ public:
 			}
 			else
 			{
-				llwarns << "Can't edit a classified you did not create" << llendl;
+				LL_WARNS() << "Can't edit a classified you did not create" << LL_ENDL;
 			}
 		}
 	}
@@ -676,7 +676,7 @@ void LLPanelPicks::onListCommit(const LLFlatListView* f_list)
 	}
 	else
 	{
-		llwarns << "Unknown list" << llendl;
+		LL_WARNS() << "Unknown list" << LL_ENDL;
 	}
 
 	updateButtons();
@@ -936,7 +936,7 @@ void LLPanelPicks::openClassifiedInfo(const LLSD &params)
 void LLPanelPicks::openClassifiedEdit(const LLSD& params)
 {
 	LLUUID classified_id = params["classified_id"].asUUID();;
-	llinfos << "opening classified " << classified_id << " for edit" << llendl;
+	LL_INFOS() << "opening classified " << classified_id << " for edit" << LL_ENDL;
 	editClassified(classified_id);
 }
 
@@ -1168,7 +1168,7 @@ void LLPanelPicks::editClassified(const LLUUID&  classified_id)
 	LLClassifiedItem* c_item = findClassifiedById(classified_id);
 	if (!c_item)
 	{
-		llwarns << "item not found for classified_id " << classified_id << llendl;
+		LL_WARNS() << "item not found for classified_id " << classified_id << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llpanelplaces.cpp b/indra/newview/llpanelplaces.cpp
index dc18cc6081..14623eb75a 100755
--- a/indra/newview/llpanelplaces.cpp
+++ b/indra/newview/llpanelplaces.cpp
@@ -219,8 +219,8 @@ public:
 	}
 	/*virtual*/ void setErrorStatus(U32 status, const std::string& reason)
 	{
-		llerrs << "Can't complete remote parcel request. Http Status: "
-			   << status << ". Reason : " << reason << llendl;
+		LL_ERRS() << "Can't complete remote parcel request. Http Status: "
+			   << status << ". Reason : " << reason << LL_ENDL;
 	}
 
 private:
@@ -308,13 +308,13 @@ BOOL LLPanelPlaces::postBuild()
 	mPlaceMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_place.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 	if (!mPlaceMenu)
 	{
-		llwarns << "Error loading Place menu" << llendl;
+		LL_WARNS() << "Error loading Place menu" << LL_ENDL;
 	}
 
 	mLandmarkMenu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_landmark.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
 	if (!mLandmarkMenu)
 	{
-		llwarns << "Error loading Landmark menu" << llendl;
+		LL_WARNS() << "Error loading Landmark menu" << LL_ENDL;
 	}
 
 	mTabContainer = getChild<LLTabContainer>("Places Tabs");
@@ -614,7 +614,7 @@ void LLPanelPlaces::onTeleportButtonClicked()
 		{
 			if (mItem.isNull())
 			{
-				llwarns << "NULL landmark item" << llendl;
+				LL_WARNS() << "NULL landmark item" << LL_ENDL;
 				llassert(mItem.notNull());
 				return;
 			}
@@ -902,7 +902,7 @@ void LLPanelPlaces::onOverflowMenuItemClicked(const LLSD& param)
 									favorites_id,
 									std::string(),
 									LLPointer<LLInventoryCallback>(NULL));
-				llinfos << "Copied inventory item #" << mItem->getUUID() << " to favorites." << llendl;
+				LL_INFOS() << "Copied inventory item #" << mItem->getUUID() << " to favorites." << LL_ENDL;
 			}
 		}
 	}
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index 76d38f067d..9845b58b9b 100755
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -828,7 +828,7 @@ bool LLPanelPrimMediaControls::isMouseOver()
 			if(hit_child && hit_child->getVisible())
 			{
 				// This was useful for debugging both coordinate translation and view hieararchy problems...
-				// llinfos << "mouse coords: " << x << ", " << y << " hit child " << hit_child->getName() << llendl;
+				// LL_INFOS() << "mouse coords: " << x << ", " << y << " hit child " << hit_child->getName() << LL_ENDL;
 
 				// This will be a direct child of the LLLayoutStack, which should be a layout_panel.
 				// These may not shown/hidden by the logic in updateShape(), so we need to do another hit test on the children of the layout panel,
@@ -839,7 +839,7 @@ bool LLPanelPrimMediaControls::isMouseOver()
 				if(hit_child_2 && hit_child_2->getVisible())
 				{
 					// This was useful for debugging both coordinate translation and view hieararchy problems...
-					// llinfos << "    mouse coords: " << x << ", " << y << " hit child 2 " << hit_child_2->getName() << llendl;
+					// LL_INFOS() << "    mouse coords: " << x << ", " << y << " hit child 2 " << hit_child_2->getName() << LL_ENDL;
 					result = true;
 				}
 			}
diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp
index 435797bf80..0e7a8b9d00 100755
--- a/indra/newview/llpanelprofile.cpp
+++ b/indra/newview/llpanelprofile.cpp
@@ -70,7 +70,7 @@ public:
 	{
 		if (params.size() < 1) return false;
 		std::string agent_name = params[0];
-		llinfos << "Profile, agent_name " << agent_name << llendl;
+		LL_INFOS() << "Profile, agent_name " << agent_name << LL_ENDL;
 		std::string url = getProfileURL(agent_name);
 		LLWeb::loadURLInternal(url);
 
@@ -212,7 +212,7 @@ bool LLPanelProfile::ChildStack::pop()
 {
 	if (mStack.size() == 0)
 	{
-		llwarns << "Empty stack" << llendl;
+		LL_WARNS() << "Empty stack" << LL_ENDL;
 		llassert(mStack.size() == 0);
 		return false;
 	}
@@ -251,7 +251,7 @@ void LLPanelProfile::ChildStack::postParentReshape()
 		for (view_list_t::const_iterator list_it = vlist.begin(); list_it != vlist.end(); ++list_it)
 		{
 			LLView* viewp = *list_it;
-			lldebugs << "removing " << viewp->getName() << llendl;
+			LL_DEBUGS() << "removing " << viewp->getName() << LL_ENDL;
 			mParent->removeChild(viewp);
 		}
 	}
@@ -260,7 +260,7 @@ void LLPanelProfile::ChildStack::postParentReshape()
 void LLPanelProfile::ChildStack::dump()
 {
 	unsigned lvl = 0;
-	lldebugs << "child stack dump:" << llendl;
+	LL_DEBUGS() << "child stack dump:" << LL_ENDL;
 	for (stack_t::const_iterator stack_it = mStack.begin(); stack_it != mStack.end(); ++stack_it, ++lvl)
 	{
 		std::ostringstream dbg_line;
@@ -270,7 +270,7 @@ void LLPanelProfile::ChildStack::dump()
 		{
 			dbg_line << " " << (*list_it)->getName();
 		}
-		lldebugs << dbg_line.str() << llendl;
+		LL_DEBUGS() << dbg_line.str() << LL_ENDL;
 	}
 }
 
@@ -415,7 +415,7 @@ void LLPanelProfile::closePanel(LLPanel* panel)
 		}
 		else
 		{
-			llwarns << "No underlying panel to focus." << llendl;
+			LL_WARNS() << "No underlying panel to focus." << LL_ENDL;
 		}
 	}
 }
diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp
index 2f29e758c6..5924448671 100755
--- a/indra/newview/llpanelsnapshot.cpp
+++ b/indra/newview/llpanelsnapshot.cpp
@@ -114,7 +114,7 @@ LLSideTrayPanelContainer* LLPanelSnapshot::getParentContainer()
 	LLSideTrayPanelContainer* parent = dynamic_cast<LLSideTrayPanelContainer*>(getParent());
 	if (!parent)
 	{
-		llwarns << "Cannot find panel container" << llendl;
+		LL_WARNS() << "Cannot find panel container" << LL_ENDL;
 		return NULL;
 	}
 
diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp
index 554fabe5b3..5fb6eb5df5 100755
--- a/indra/newview/llpanelsnapshotoptions.cpp
+++ b/indra/newview/llpanelsnapshotoptions.cpp
@@ -90,7 +90,7 @@ void LLPanelSnapshotOptions::openPanel(const std::string& panel_name)
 	LLSideTrayPanelContainer* parent = dynamic_cast<LLSideTrayPanelContainer*>(getParent());
 	if (!parent)
 	{
-		llwarns << "Cannot find panel container" << llendl;
+		LL_WARNS() << "Cannot find panel container" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llpanelsnapshotpostcard.cpp b/indra/newview/llpanelsnapshotpostcard.cpp
index f2bb8f530b..6a74f6211e 100755
--- a/indra/newview/llpanelsnapshotpostcard.cpp
+++ b/indra/newview/llpanelsnapshotpostcard.cpp
@@ -236,7 +236,7 @@ void LLPanelSnapshotPostcard::onTabButtonPress(S32 btn_idx)
 	other_btn->toggleState();
 	//other_btn->setEnabled(TRUE);
 
-	lldebugs << "Button #" << btn_idx << " (" << clicked_btn->getName() << ") clicked" << llendl;
+	LL_DEBUGS() << "Button #" << btn_idx << " (" << clicked_btn->getName() << ") clicked" << LL_ENDL;
 }
 
 void LLPanelSnapshotPostcard::onSend()
diff --git a/indra/newview/llpanelteleporthistory.cpp b/indra/newview/llpanelteleporthistory.cpp
index 018efbbc5c..25390adbf8 100755
--- a/indra/newview/llpanelteleporthistory.cpp
+++ b/indra/newview/llpanelteleporthistory.cpp
@@ -717,7 +717,7 @@ void LLTeleportHistoryPanel::refresh()
 											  mCurrentItem,
 											  filter_string);
 			if ( !curr_flat_view->addItem(item, LLUUID::null, ADD_BOTTOM, false) )
-				llerrs << "Couldn't add flat item to teleport history." << llendl;
+				LL_ERRS() << "Couldn't add flat item to teleport history." << LL_ENDL;
 			if (mLastSelectedItemIndex == mCurrentItem)
 				curr_flat_view->selectItem(item, true);
 		}
diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp
index 02d363d795..b28e593397 100755
--- a/indra/newview/llpanelvolume.cpp
+++ b/indra/newview/llpanelvolume.cpp
@@ -620,7 +620,7 @@ void LLPanelVolume::sendIsLight()
 	
 	BOOL value = getChild<LLUICtrl>("Light Checkbox Ctrl")->getValue();
 	volobjp->setIsLight(value);
-	llinfos << "update light sent" << llendl;
+	LL_INFOS() << "update light sent" << LL_ENDL;
 }
 
 void LLPanelVolume::sendIsFlexible()
@@ -652,7 +652,7 @@ void LLPanelVolume::sendIsFlexible()
 		LLSelectMgr::getInstance()->selectionUpdatePhantom(volobjp->flagPhantom());
 	}
 
-	llinfos << "update flexible sent" << llendl;
+	LL_INFOS() << "update flexible sent" << LL_ENDL;
 }
 
 void LLPanelVolume::sendPhysicsShapeType(LLUICtrl* ctrl, void* userdata)
diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp
index aa3ed22bee..33e44816ba 100755
--- a/indra/newview/llpanelwearing.cpp
+++ b/indra/newview/llpanelwearing.cpp
@@ -118,7 +118,7 @@ protected:
 
 			if (!item)
 			{
-				llwarns << "Invalid item" << llendl;
+				LL_WARNS() << "Invalid item" << LL_ENDL;
 				continue;
 			}
 
diff --git a/indra/newview/llpatchvertexarray.cpp b/indra/newview/llpatchvertexarray.cpp
index dece2928c0..6e3e375488 100755
--- a/indra/newview/llpatchvertexarray.cpp
+++ b/indra/newview/llpatchvertexarray.cpp
@@ -128,7 +128,7 @@ void LLPatchVertexArray::create(U32 surface_width, U32 patch_width, F32 meters_p
 	{
 		// init() and some other things all want to deref these
 		// pointers, so this is serious.
-		llerrs << "mRenderLevelp or mRenderStridep was NULL; we'd crash soon." << llendl;
+		LL_ERRS() << "mRenderLevelp or mRenderStridep was NULL; we'd crash soon." << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llpathfindingmanager.cpp b/indra/newview/llpathfindingmanager.cpp
index c277359133..ae5b3b4e76 100755
--- a/indra/newview/llpathfindingmanager.cpp
+++ b/indra/newview/llpathfindingmanager.cpp
@@ -736,8 +736,8 @@ std::string LLPathfindingManager::getCapabilityURLForRegion(LLViewerRegion *pReg
 
 	if (capabilityURL.empty())
 	{
-		llwarns << "cannot find capability '" << pCapabilityName << "' for current region '"
-			<< ((pRegion != NULL) ? pRegion->getName() : "<null>") << "'" << llendl;
+		LL_WARNS() << "cannot find capability '" << pCapabilityName << "' for current region '"
+			<< ((pRegion != NULL) ? pRegion->getName() : "<null>") << "'" << LL_ENDL;
 	}
 
 	return capabilityURL;
@@ -804,7 +804,7 @@ void NavMeshStatusResponder::result(const LLSD &pContent)
 
 void NavMeshStatusResponder::errorWithContent(U32 pStatus, const std::string& pReason, const LLSD& pContent)
 {
-	llwarns << "NavMeshStatusResponder error [status:" << pStatus << "]: " << pContent << llendl;
+	LL_WARNS() << "NavMeshStatusResponder error [status:" << pStatus << "]: " << pContent << LL_ENDL;
 	LLPathfindingNavMeshStatus navMeshStatus(mRegionUUID);
 	LLPathfindingManager::getInstance()->handleNavMeshStatusRequest(navMeshStatus, mRegion, mIsGetStatusOnly);
 }
@@ -859,7 +859,7 @@ void AgentStateResponder::result(const LLSD &pContent)
 
 void AgentStateResponder::errorWithContent(U32 pStatus, const std::string &pReason, const LLSD& pContent)
 {
-	llwarns << "AgentStateResponder error [status:" << pStatus << "]: " << pContent << llendl;
+	LL_WARNS() << "AgentStateResponder error [status:" << pStatus << "]: " << pContent << LL_ENDL;
 	LLPathfindingManager::getInstance()->handleAgentState(FALSE);
 }
 
@@ -885,7 +885,7 @@ void NavMeshRebakeResponder::result(const LLSD &pContent)
 
 void NavMeshRebakeResponder::errorWithContent(U32 pStatus, const std::string &pReason, const LLSD& pContent)
 {
-	llwarns << "NavMeshRebakeResponder error [status:" << pStatus << "]: " << pContent << llendl;
+	LL_WARNS() << "NavMeshRebakeResponder error [status:" << pStatus << "]: " << pContent << LL_ENDL;
 	mRebakeNavMeshCallback(false);
 }
 
@@ -921,8 +921,8 @@ void LinksetsResponder::handleObjectLinksetsResult(const LLSD &pContent)
 void LinksetsResponder::handleObjectLinksetsError(U32 pStatus, const std::string &pReason,
 												 const LLSD& pContent, const std::string &pURL)
 {
-	llwarns << "LinksetsResponder object linksets error with request to URL '" << pURL << "' [status:"
-			<< pStatus << "]: " << pContent << llendl;
+	LL_WARNS() << "LinksetsResponder object linksets error with request to URL '" << pURL << "' [status:"
+			<< pStatus << "]: " << pContent << LL_ENDL;
 	mObjectMessagingState = kReceivedError;
 	if (mTerrainMessagingState != kWaiting)
 	{
@@ -944,8 +944,8 @@ void LinksetsResponder::handleTerrainLinksetsResult(const LLSD &pContent)
 void LinksetsResponder::handleTerrainLinksetsError(U32 pStatus, const std::string &pReason,
 												   const LLSD& pContent, const std::string &pURL)
 {
-	llwarns << "LinksetsResponder terrain linksets error with request to URL '" << pURL << "' [status:"
-			<< pStatus << "]: " << pContent << llendl;
+	LL_WARNS() << "LinksetsResponder terrain linksets error with request to URL '" << pURL << "' [status:"
+			<< pStatus << "]: " << pContent << LL_ENDL;
 	mTerrainMessagingState = kReceivedError;
 	if (mObjectMessagingState != kWaiting)
 	{
@@ -1049,7 +1049,7 @@ void CharactersResponder::result(const LLSD &pContent)
 
 void CharactersResponder::errorWithContent(U32 pStatus, const std::string &pReason, const LLSD& pContent)
 {
-	llwarns << "CharactersResponder error [status:" << pStatus << "]: " << pContent << llendl;
+	LL_WARNS() << "CharactersResponder error [status:" << pStatus << "]: " << pContent << LL_ENDL;
 
 	LLPathfindingObjectListPtr characterListPtr =  LLPathfindingObjectListPtr(new LLPathfindingCharacterList());
 	mCharactersCallback(mRequestId, LLPathfindingManager::kRequestError, characterListPtr);
diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp
index 0c23e5ac92..40f5d8c23e 100755
--- a/indra/newview/llpathfindingnavmesh.cpp
+++ b/indra/newview/llpathfindingnavmesh.cpp
@@ -129,7 +129,7 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes
 		llassert(embeddedNavMeshVersion == pNavMeshVersion); // stinson 03/13/2012 : does this ever occur?
 		if (embeddedNavMeshVersion != pNavMeshVersion)
 		{
-			llwarns << "Mismatch between expected and embedded navmesh versions occurred" << llendl;
+			LL_WARNS() << "Mismatch between expected and embedded navmesh versions occurred" << LL_ENDL;
 			pNavMeshVersion = embeddedNavMeshVersion;
 		}
 	}
@@ -148,7 +148,7 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes
 			U8* pUncompressedNavMeshContainer = unzip_llsdNavMesh( valid, decompBinSize, streamdecomp, binSize ) ;
 			if ( !valid )
 			{
-				llwarns << "Unable to decompress the navmesh llsd." << llendl;
+				LL_WARNS() << "Unable to decompress the navmesh llsd." << LL_ENDL;
 				status = kNavMeshRequestError;
 			}
 			else
@@ -165,7 +165,7 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes
 		}
 		else
 		{
-			llwarns << "No mesh data received" << llendl;
+			LL_WARNS() << "No mesh data received" << LL_ENDL;
 			status = kNavMeshRequestError;
 		}
 		setRequestStatus(status);
@@ -186,8 +186,8 @@ void LLPathfindingNavMesh::handleNavMeshError()
 
 void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pReason, const LLSD& pContent, const std::string &pURL, U32 pNavMeshVersion)
 {
-	llwarns << "LLPathfindingNavMesh error with request to URL '" << pURL << "' [status:"
-			<< pStatus << "]: " << pContent << llendl;
+	LL_WARNS() << "LLPathfindingNavMesh error with request to URL '" << pURL << "' [status:"
+			<< pStatus << "]: " << pContent << LL_ENDL;
 	if (mNavMeshStatus.getVersion() == pNavMeshVersion)
 	{
 		handleNavMeshError();
diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index 18b85cc9c3..05ef436bd9 100755
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -224,7 +224,7 @@ BOOL LLPhysicsMotion::initialize()
         mParamDriver = (LLViewerVisualParam*)mCharacter->getVisualParam(mParamDriverName.c_str());
         if (mParamDriver == NULL)
         {
-                llinfos << "Failure reading in  [ " << mParamDriverName << " ]" << llendl;
+                LL_INFOS() << "Failure reading in  [ " << mParamDriverName << " ]" << LL_ENDL;
                 return FALSE;
         }
 
diff --git a/indra/newview/llplacesfolderview.cpp b/indra/newview/llplacesfolderview.cpp
index 3caa93ae71..9e1b75b7e9 100755
--- a/indra/newview/llplacesfolderview.cpp
+++ b/indra/newview/llplacesfolderview.cpp
@@ -59,7 +59,7 @@ BOOL LLPlacesFolderView::handleRightMouseDown(S32 x, S32 y, MASK mask)
         }
         else
         {
-            llwarns << "Requested menu handle for non-setup inventory type: " << inventory_type << llendl;
+            LL_WARNS() << "Requested menu handle for non-setup inventory type: " << inventory_type << LL_ENDL;
         }
 
     }
diff --git a/indra/newview/llplacesinventorybridge.cpp b/indra/newview/llplacesinventorybridge.cpp
index ebd9604c5b..a498d27d2b 100755
--- a/indra/newview/llplacesinventorybridge.cpp
+++ b/indra/newview/llplacesinventorybridge.cpp
@@ -162,7 +162,7 @@ LLInvFVBridge* LLPlacesInventoryBridgeBuilder::createBridge(
 	case LLAssetType::AT_LANDMARK:
 		if(!(inv_type == LLInventoryType::IT_LANDMARK))
 		{
-			llwarns << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << llendl;
+			LL_WARNS() << LLAssetType::lookup(asset_type) << " asset has inventory type " << LLInventoryType::lookupHumanReadable(inv_type) << " on uuid " << uuid << LL_ENDL;
 		}
 		new_listener = new LLPlacesLandmarkBridge(inv_type, inventory, root, uuid, flags);
 		break;
diff --git a/indra/newview/llpostcard.cpp b/indra/newview/llpostcard.cpp
index aebe636f59..649bb2fb2c 100755
--- a/indra/newview/llpostcard.cpp
+++ b/indra/newview/llpostcard.cpp
@@ -48,7 +48,7 @@ static void postcard_upload_callback(const LLUUID& asset_id, void *user_data, S3
 	if (result)
 	{
 		// TODO: display the error messages in UI
-		llwarns << "Failed to send postcard: " << LLAssetStorage::getErrorString(result) << llendl;
+		LL_WARNS() << "Failed to send postcard: " << LLAssetStorage::getErrorString(result) << LL_ENDL;
 		LLPostCard::reportPostResult(false);
 	}
 	else
@@ -97,14 +97,14 @@ public:
 
 	/*virtual*/ void uploadComplete(const LLSD& content)
 	{
-		llinfos << "Postcard sent" << llendl;
-		LL_DEBUGS("Snapshots") << "content: " << content << llendl;
+		LL_INFOS() << "Postcard sent" << LL_ENDL;
+		LL_DEBUGS("Snapshots") << "content: " << content << LL_ENDL;
 		LLPostCard::reportPostResult(true);
 	}
 
 	/*virtual*/ void uploadFailure(const LLSD& content)
 	{
-		llwarns << "Sending postcard failed: " << content << llendl;
+		LL_WARNS() << "Sending postcard failed: " << content << LL_ENDL;
 		LLPostCard::reportPostResult(false);
 	}
 };
@@ -128,17 +128,17 @@ void LLPostCard::send(LLPointer<LLImageFormatted> image, const LLSD& postcard_da
 	std::string url = gAgent.getRegion()->getCapability("SendPostcard");
 	if (!url.empty())
 	{
-		llinfos << "Sending postcard via capability" << llendl;
+		LL_INFOS() << "Sending postcard via capability" << LL_ENDL;
 		// the capability already encodes: agent ID, region ID
-		LL_DEBUGS("Snapshots") << "url: " << url << llendl;
-		LL_DEBUGS("Snapshots") << "body: " << postcard_data << llendl;
-		LL_DEBUGS("Snapshots") << "data size: " << image->getDataSize() << llendl;
+		LL_DEBUGS("Snapshots") << "url: " << url << LL_ENDL;
+		LL_DEBUGS("Snapshots") << "body: " << postcard_data << LL_ENDL;
+		LL_DEBUGS("Snapshots") << "data size: " << image->getDataSize() << LL_ENDL;
 		LLHTTPClient::post(url, postcard_data,
 			new LLPostcardSendResponder(postcard_data, asset_id, LLAssetType::AT_IMAGE_JPEG));
 	}
 	else
 	{
-		llinfos << "Sending postcard" << llendl;
+		LL_INFOS() << "Sending postcard" << LL_ENDL;
 		LLSD* data = new LLSD(postcard_data);
 		(*data)["asset-id"] = asset_id;
 		gAssetStorage->storeAssetData(transaction_id, LLAssetType::AT_IMAGE_JPEG,
diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp
index 3675d8694d..b379ef7bdb 100755
--- a/indra/newview/llpreview.cpp
+++ b/indra/newview/llpreview.cpp
@@ -134,10 +134,10 @@ void LLPreview::onCommit()
 		if (!item->isFinished())
 		{
 			// We are attempting to save an item that was never loaded
-			llwarns << "LLPreview::onCommit() called with mIsComplete == FALSE"
+			LL_WARNS() << "LLPreview::onCommit() called with mIsComplete == FALSE"
 					<< " Type: " << item->getType()
 					<< " ID: " << item->getUUID()
-					<< llendl;
+					<< LL_ENDL;
 			return;
 		}
 		
diff --git a/indra/newview/llpreviewgesture.cpp b/indra/newview/llpreviewgesture.cpp
index 36877696f5..c378738b05 100755
--- a/indra/newview/llpreviewgesture.cpp
+++ b/indra/newview/llpreviewgesture.cpp
@@ -873,7 +873,7 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs,
 			}
 			else
 			{
-				llwarns << "Unable to load gesture" << llendl;
+				LL_WARNS() << "Unable to load gesture" << LL_ENDL;
 			}
 
 			delete gesture;
@@ -893,7 +893,7 @@ void LLPreviewGesture::onLoadComplete(LLVFS *vfs,
 				LLDelayedGestureError::gestureFailedToLoad( *item_idp );
 			}
 
-			llwarns << "Problem loading gesture: " << status << llendl;
+			LL_WARNS() << "Problem loading gesture: " << status << LL_ENDL;
 			self->mAssetStatus = PREVIEW_ASSET_ERROR;
 		}
 	}
@@ -1019,7 +1019,7 @@ void LLPreviewGesture::saveIfNeeded()
 {
 	if (!gAssetStorage)
 	{
-		llwarns << "Can't save gesture, no asset storage system." << llendl;
+		LL_WARNS() << "Can't save gesture, no asset storage system." << LL_ENDL;
 		return;
 	}
 
@@ -1166,8 +1166,8 @@ void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data,
 			}
 			else
 			{
-				llwarns << "Inventory item for gesture " << info->mItemUUID
-						<< " is no longer in agent inventory." << llendl;
+				LL_WARNS() << "Inventory item for gesture " << info->mItemUUID
+						<< " is no longer in agent inventory." << LL_ENDL;
 			}
 		}
 		else
@@ -1202,7 +1202,7 @@ void LLPreviewGesture::onSaveComplete(const LLUUID& asset_uuid, void* user_data,
 	}
 	else
 	{
-		llwarns << "Problem saving gesture: " << status << llendl;
+		LL_WARNS() << "Problem saving gesture: " << status << LL_ENDL;
 		LLSD args;
 		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
 		LLNotificationsUtil::add("GestureSaveFailedReason", args);
@@ -1533,7 +1533,7 @@ void LLPreviewGesture::onClickAdd(void* data)
 
 	if( library_item_index >= STEP_EOF )
 	{
-		llerrs << "Unknown step type: " << library_text << llendl;
+		LL_ERRS() << "Unknown step type: " << library_text << LL_ENDL;
 		return;
 	}
 
@@ -1563,7 +1563,7 @@ LLScrollListItem* LLPreviewGesture::addStep( const EStepType step_type )
 			step = new LLGestureStepWait();			
 			break;
 		default:
-			llerrs << "Unknown step type: " << (S32)step_type << llendl;
+			LL_ERRS() << "Unknown step type: " << (S32)step_type << LL_ENDL;
 			return NULL;
 	}
 
diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp
index 97c9de4b72..c4858e241e 100755
--- a/indra/newview/llpreviewnotecard.cpp
+++ b/indra/newview/llpreviewnotecard.cpp
@@ -185,7 +185,7 @@ void LLPreviewNotecard::refreshFromInventory(const LLUUID& new_item_id)
 		mItemUUID = new_item_id;
 		setKey(LLSD(new_item_id));
 	}
-	lldebugs << "LLPreviewNotecard::refreshFromInventory()" << llendl;
+	LL_DEBUGS() << "LLPreviewNotecard::refreshFromInventory()" << LL_ENDL;
 	loadAsset();
 }
 
@@ -240,7 +240,7 @@ void LLPreviewNotecard::loadAsset()
 					else
 					{
 						// The object that we're trying to look at disappeared, bail.
-						llwarns << "Can't find object " << mObjectUUID << " associated with notecard." << llendl;
+						LL_WARNS() << "Can't find object " << mObjectUUID << " associated with notecard." << LL_ENDL;
 						mAssetID.setNull();
 						editor->setText(getString("no_object"));
 						editor->makePristine();
@@ -295,7 +295,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 									   LLAssetType::EType type,
 									   void* user_data, S32 status, LLExtStat ext_status)
 {
-	llinfos << "LLPreviewNotecard::onLoadComplete()" << llendl;
+	LL_INFOS() << "LLPreviewNotecard::onLoadComplete()" << LL_ENDL;
 	LLUUID* item_id = (LLUUID*)user_data;
 	
 	LLPreviewNotecard* preview = LLFloaterReg::findTypedInstance<LLPreviewNotecard>("preview_notecard", LLSD(*item_id));
@@ -320,7 +320,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 			{
 				if( !previewEditor->importBuffer( &buffer[0], file_length+1 ) )
 				{
-					llwarns << "Problem importing notecard" << llendl;
+					LL_WARNS() << "Problem importing notecard" << LL_ENDL;
 				}
 			}
 			else
@@ -353,7 +353,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 				LLNotificationsUtil::add("UnableToLoadNotecard");
 			}
 
-			llwarns << "Problem loading notecard: " << status << llendl;
+			LL_WARNS() << "Problem loading notecard: " << status << LL_ENDL;
 			preview->mAssetStatus = PREVIEW_ASSET_ERROR;
 		}
 	}
@@ -363,7 +363,7 @@ void LLPreviewNotecard::onLoadComplete(LLVFS *vfs,
 // static
 void LLPreviewNotecard::onClickSave(void* user_data)
 {
-	//llinfos << "LLPreviewNotecard::onBtnSave()" << llendl;
+	//LL_INFOS() << "LLPreviewNotecard::onBtnSave()" << LL_ENDL;
 	LLPreviewNotecard* preview = (LLPreviewNotecard*)user_data;
 	if(preview)
 	{
@@ -402,7 +402,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 
 	if(!editor)
 	{
-		llwarns << "Cannot get handle to the notecard editor." << llendl;
+		LL_WARNS() << "Cannot get handle to the notecard editor." << LL_ENDL;
 		return false;
 	}
 
@@ -435,7 +435,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 			const LLViewerRegion* region = gAgent.getRegion();
 			if (!region)
 			{
-				llwarns << "Not connected to a region, cannot save notecard." << llendl;
+				LL_WARNS() << "Not connected to a region, cannot save notecard." << LL_ENDL;
 				return false;
 			}
 			std::string agent_url = region->getCapability("UpdateNotecardAgentInventory");
@@ -448,8 +448,8 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 				setEnabled(FALSE);
 				LLSD body;
 				body["item_id"] = mItemUUID;
-				llinfos << "Saving notecard " << mItemUUID
-					<< " into agent inventory via " << agent_url << llendl;
+				LL_INFOS() << "Saving notecard " << mItemUUID
+					<< " into agent inventory via " << agent_url << LL_ENDL;
 				LLHTTPClient::post(agent_url, body,
 					new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
 			}
@@ -461,8 +461,8 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 				LLSD body;
 				body["task_id"] = mObjectUUID;
 				body["item_id"] = mItemUUID;
-				llinfos << "Saving notecard " << mItemUUID << " into task "
-					<< mObjectUUID << " via " << task_url << llendl;
+				LL_INFOS() << "Saving notecard " << mItemUUID << " into task "
+					<< mObjectUUID << " via " << task_url << LL_ENDL;
 				LLHTTPClient::post(task_url, body,
 					new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
 			}
@@ -477,7 +477,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
 			}
 			else // !gAssetStorage
 			{
-				llwarns << "Not connected to an asset storage system." << llendl;
+				LL_WARNS() << "Not connected to an asset storage system." << LL_ENDL;
 				return false;
 			}
 		}
@@ -518,8 +518,8 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data
 			}
 			else
 			{
-				llwarns << "Inventory item for script " << info->mItemUUID
-						<< " is no longer in agent inventory." << llendl;
+				LL_WARNS() << "Inventory item for script " << info->mItemUUID
+						<< " is no longer in agent inventory." << LL_ENDL;
 			}
 		}
 		else
@@ -562,7 +562,7 @@ void LLPreviewNotecard::onSaveComplete(const LLUUID& asset_uuid, void* user_data
 	}
 	else
 	{
-		llwarns << "Problem saving notecard: " << status << llendl;
+		LL_WARNS() << "Problem saving notecard: " << status << LL_ENDL;
 		LLSD args;
 		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
 		LLNotificationsUtil::add("SaveNotecardFailReason", args);
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index bfc779c057..70a280ca09 100755
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -531,14 +531,14 @@ bool LLScriptEdCore::loadScriptText(const std::string& filename)
 {
 	if (filename.empty())
 	{
-		llwarns << "Empty file name" << llendl;
+		LL_WARNS() << "Empty file name" << LL_ENDL;
 		return false;
 	}
 
 	LLFILE* file = LLFile::fopen(filename, "rb");		/*Flawfinder: ignore*/
 	if (!file)
 	{
-		llwarns << "Error opening " << filename << llendl;
+		LL_WARNS() << "Error opening " << filename << LL_ENDL;
 		return false;
 	}
 
@@ -550,7 +550,7 @@ bool LLScriptEdCore::loadScriptText(const std::string& filename)
 	size_t nread = fread(buffer, 1, file_length, file);
 	if (nread < file_length)
 	{
-		llwarns << "Short read" << llendl;
+		LL_WARNS() << "Short read" << LL_ENDL;
 	}
 	buffer[nread] = '\0';
 	fclose(file);
@@ -566,7 +566,7 @@ bool LLScriptEdCore::writeToFile(const std::string& filename)
 	LLFILE* fp = LLFile::fopen(filename, "wb");
 	if (!fp)
 	{
-		llwarns << "Unable to write to " << filename << llendl;
+		LL_WARNS() << "Unable to write to " << filename << LL_ENDL;
 
 		LLSD row;
 		row["columns"][0]["value"] = "Error writing to local file. Is your hard drive full?";
@@ -1021,8 +1021,8 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data)
 		LLStringUtil::replaceChar(line, ',',' ');
 		LLStringUtil::replaceChar(line, ')',' ');
 		sscanf(line.c_str(), "%d %d", &row, &column);
-		//llinfos << "LLScriptEdCore::onErrorList() - " << row << ", "
-		//<< column << llendl;
+		//LL_INFOS() << "LLScriptEdCore::onErrorList() - " << row << ", "
+		//<< column << LL_ENDL;
 		self->mEditor->setCursor(row, column);
 		self->mEditor->setFocus(TRUE);
 	}
@@ -1289,7 +1289,7 @@ BOOL LLPreviewLSL::postBuild()
 // virtual
 void LLPreviewLSL::callbackLSLCompileSucceeded()
 {
-	llinfos << "LSL Bytecode saved" << llendl;
+	LL_INFOS() << "LSL Bytecode saved" << LL_ENDL;
 	mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessful"));
 	mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
 	closeIfNeeded();
@@ -1298,7 +1298,7 @@ void LLPreviewLSL::callbackLSLCompileSucceeded()
 // virtual
 void LLPreviewLSL::callbackLSLCompileFailed(const LLSD& compile_errors)
 {
-	llinfos << "Compile failed!" << llendl;
+	LL_INFOS() << "Compile failed!" << LL_ENDL;
 
 	for(LLSD::array_const_iterator line = compile_errors.beginArray();
 		line < compile_errors.endArray();
@@ -1413,7 +1413,7 @@ void LLPreviewLSL::onSave(void* userdata, BOOL close_after_save)
 // fails, go ahead and save the text anyway.
 void LLPreviewLSL::saveIfNeeded(bool sync /*= true*/)
 {
-	// llinfos << "LLPreviewLSL::saveIfNeeded()" << llendl;
+	// LL_INFOS() << "LLPreviewLSL::saveIfNeeded()" << LL_ENDL;
 	if(!mScriptEd->hasChanged())
 	{
 		return;
@@ -1459,7 +1459,7 @@ void LLPreviewLSL::uploadAssetViaCaps(const std::string& url,
 									  const std::string& filename,
 									  const LLUUID& item_id)
 {
-	llinfos << "Update Agent Inventory via capability" << llendl;
+	LL_INFOS() << "Update Agent Inventory via capability" << LL_ENDL;
 	LLSD body;
 	body["item_id"] = item_id;
 	body["target"] = "lsl2";
@@ -1492,7 +1492,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename,
 						asset_id.asString().c_str(),
 						gAgent.isGodlike()))
 	{
-		llinfos << "Compile failed!" << llendl;
+		LL_INFOS() << "Compile failed!" << LL_ENDL;
 		//char command[256];
 		//sprintf(command, "type %s\n", err_filename.c_str());
 		//system(command);
@@ -1530,7 +1530,7 @@ void LLPreviewLSL::uploadAssetLegacy(const std::string& filename,
 	}
 	else
 	{
-		llinfos << "Compile worked!" << llendl;
+		LL_INFOS() << "Compile worked!" << LL_ENDL;
 		if(gAssetStorage)
 		{
 			getWindow()->incBusyCount();
@@ -1572,8 +1572,8 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32
 			}
 			else
 			{
-				llwarns << "Inventory item for script " << info->mItemUUID
-					<< " is no longer in agent inventory." << llendl;
+				LL_WARNS() << "Inventory item for script " << info->mItemUUID
+					<< " is no longer in agent inventory." << LL_ENDL;
 			}
 
 			// Find our window and close it if requested.
@@ -1592,7 +1592,7 @@ void LLPreviewLSL::onSaveComplete(const LLUUID& asset_uuid, void* user_data, S32
 	}
 	else
 	{
-		llwarns << "Problem saving script: " << status << llendl;
+		LL_WARNS() << "Problem saving script: " << status << LL_ENDL;
 		LLSD args;
 		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
 		LLNotificationsUtil::add("SaveScriptFailReason", args);
@@ -1630,7 +1630,7 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d
 	}
 	else
 	{
-		llwarns << "Problem saving LSL Bytecode (Preview)" << llendl;
+		LL_WARNS() << "Problem saving LSL Bytecode (Preview)" << LL_ENDL;
 		LLSD args;
 		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
 		LLNotificationsUtil::add("SaveBytecodeFailReason", args);
@@ -1642,8 +1642,8 @@ void LLPreviewLSL::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* user_d
 void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAssetType::EType type,
 								   void* user_data, S32 status, LLExtStat ext_status)
 {
-	lldebugs << "LLPreviewLSL::onLoadComplete: got uuid " << asset_uuid
-		 << llendl;
+	LL_DEBUGS() << "LLPreviewLSL::onLoadComplete: got uuid " << asset_uuid
+		 << LL_ENDL;
 	LLUUID* item_uuid = (LLUUID*)user_data;
 	LLPreviewLSL* preview = LLFloaterReg::findTypedInstance<LLPreviewLSL>("preview_script", *item_uuid);
 	if( preview )
@@ -1688,7 +1688,7 @@ void LLPreviewLSL::onLoadComplete( LLVFS *vfs, const LLUUID& asset_uuid, LLAsset
 			}
 
 			preview->mAssetStatus = PREVIEW_ASSET_ERROR;
-			llwarns << "Problem loading script: " << status << llendl;
+			LL_WARNS() << "Problem loading script: " << status << LL_ENDL;
 		}
 	}
 	delete item_uuid;
@@ -1755,7 +1755,7 @@ void LLLiveLSLEditor::callbackLSLCompileSucceeded(const LLUUID& task_id,
 												  const LLUUID& item_id,
 												  bool is_script_running)
 {
-	lldebugs << "LSL Bytecode saved" << llendl;
+	LL_DEBUGS() << "LSL Bytecode saved" << LL_ENDL;
 	mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessful"));
 	mScriptEd->mErrorList->setCommentText(LLTrans::getString("SaveComplete"));
 	closeIfNeeded();
@@ -1764,7 +1764,7 @@ void LLLiveLSLEditor::callbackLSLCompileSucceeded(const LLUUID& task_id,
 // virtual
 void LLLiveLSLEditor::callbackLSLCompileFailed(const LLSD& compile_errors)
 {
-	lldebugs << "Compile failed!" << llendl;
+	LL_DEBUGS() << "Compile failed!" << LL_ENDL;
 	for(LLSD::array_const_iterator line = compile_errors.beginArray();
 		line < compile_errors.endArray();
 		line++)
@@ -1783,7 +1783,7 @@ void LLLiveLSLEditor::callbackLSLCompileFailed(const LLSD& compile_errors)
 
 void LLLiveLSLEditor::loadAsset()
 {
-	//llinfos << "LLLiveLSLEditor::loadAsset()" << llendl;
+	//LL_INFOS() << "LLLiveLSLEditor::loadAsset()" << LL_ENDL;
 	if(!mIsNew)
 	{
 		LLViewerObject* object = gObjectList.findObject(mObjectUUID);
@@ -1795,7 +1795,7 @@ void LLLiveLSLEditor::loadAsset()
 				   || gAgent.isGodlike()))
 			{
 				mItem = new LLViewerInventoryItem(item);
-				//llinfos << "asset id " << mItem->getAssetUUID() << llendl;
+				//LL_INFOS() << "asset id " << mItem->getAssetUUID() << LL_ENDL;
 			}
 
 			if(!gAgent.isGodlike()
@@ -1887,8 +1887,8 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
 									 LLAssetType::EType type,
 									 void* user_data, S32 status, LLExtStat ext_status)
 {
-	lldebugs << "LLLiveLSLEditor::onLoadComplete: got uuid " << asset_id
-		 << llendl;
+	LL_DEBUGS() << "LLLiveLSLEditor::onLoadComplete: got uuid " << asset_id
+		 << LL_ENDL;
 	LLUUID* xored_id = (LLUUID*)user_data;
 	
 	LLLiveLSLEditor* instance = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", *xored_id);
@@ -1933,7 +1933,7 @@ void LLLiveLSLEditor::loadScriptText(LLVFS *vfs, const LLUUID &uuid, LLAssetType
 	if (file.getLastBytesRead() != file_length ||
 		file_length <= 0)
 	{
-		llwarns << "Error reading " << uuid << ":" << type << llendl;
+		LL_WARNS() << "Error reading " << uuid << ":" << type << LL_ENDL;
 	}
 
 	buffer[file_length] = '\0';
@@ -2156,7 +2156,7 @@ void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url,
 										 const LLUUID& item_id,
 										 BOOL is_running)
 {
-	llinfos << "Update Task Inventory via capability " << url << llendl;
+	LL_INFOS() << "Update Task Inventory via capability " << url << LL_ENDL;
 	LLSD body;
 	body["task_id"] = task_id;
 	body["item_id"] = item_id;
@@ -2195,7 +2195,7 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
 						gAgent.isGodlike()))
 	{
 		// load the error file into the error scrolllist
-		llinfos << "Compile failed!" << llendl;
+		LL_INFOS() << "Compile failed!" << LL_ENDL;
 		if(NULL != (fp = LLFile::fopen(err_filename, "r")))
 		{
 			char buffer[MAX_STRING];		/*Flawfinder: ignore*/
@@ -2233,12 +2233,12 @@ void LLLiveLSLEditor::uploadAssetLegacy(const std::string& filename,
 	}
 	else
 	{
-		llinfos << "Compile worked!" << llendl;
+		LL_INFOS() << "Compile worked!" << LL_ENDL;
 		mScriptEd->mErrorList->setCommentText(LLTrans::getString("CompileSuccessfulSaving"));
 		if(gAssetStorage)
 		{
-			llinfos << "LLLiveLSLEditor::saveAsset "
-					<< mItem->getAssetUUID() << llendl;
+			LL_INFOS() << "LLLiveLSLEditor::saveAsset "
+					<< mItem->getAssetUUID() << LL_ENDL;
 			getWindow()->incBusyCount();
 			mPendingUploads++;
 			LLLiveLSLSaveData* data = NULL;
@@ -2271,7 +2271,7 @@ void LLLiveLSLEditor::onSaveTextComplete(const LLUUID& asset_uuid, void* user_da
 
 	if (status)
 	{
-		llwarns << "Unable to save text for a script." << llendl;
+		LL_WARNS() << "Unable to save text for a script." << LL_ENDL;
 		LLSD args;
 		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
 		LLNotificationsUtil::add("CompileQueueSaveText", args);
@@ -2302,7 +2302,7 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use
 		return;
 	if(0 ==status)
 	{
-		llinfos << "LSL Bytecode saved" << llendl;
+		LL_INFOS() << "LSL Bytecode saved" << LL_ENDL;
 		LLLiveLSLEditor* self = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", data->mItem->getUUID()); //  ^ data->mSaveObjectID
 		if (self)
 		{
@@ -2328,8 +2328,8 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use
 	}
 	else
 	{
-		llinfos << "Problem saving LSL Bytecode (Live Editor)" << llendl;
-		llwarns << "Unable to save a compiled script." << llendl;
+		LL_INFOS() << "Problem saving LSL Bytecode (Live Editor)" << LL_ENDL;
+		LL_WARNS() << "Unable to save a compiled script." << LL_ENDL;
 
 		LLSD args;
 		args["REASON"] = std::string(LLAssetStorage::getErrorString(status));
diff --git a/indra/newview/llproductinforequest.cpp b/indra/newview/llproductinforequest.cpp
index 1390000fc5..e85194d173 100755
--- a/indra/newview/llproductinforequest.cpp
+++ b/indra/newview/llproductinforequest.cpp
@@ -45,8 +45,8 @@ public:
 	//If we get back an error (not found, etc...), handle it here
 	virtual void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "LLProductInfoRequest error [status:"
-				<< status << ":] " << content << llendl;
+		LL_WARNS() << "LLProductInfoRequest error [status:"
+				<< status << ":] " << content << LL_ENDL;
 	}
 };
 
@@ -76,7 +76,7 @@ std::string LLProductInfoRequestManager::getDescriptionForSku(const std::string&
 		 it != mSkuDescriptions.endArray();
 		 ++it)
 	{
-		//	llwarns <<  (*it)["sku"].asString() << " = " << (*it)["description"].asString() << llendl;
+		//	LL_WARNS() <<  (*it)["sku"].asString() << " = " << (*it)["description"].asString() << LL_ENDL;
 		if ((*it)["sku"].asString() == sku)
 		{
 			return (*it)["description"].asString();
diff --git a/indra/newview/llregioninfomodel.cpp b/indra/newview/llregioninfomodel.cpp
index 590e246482..25c576468b 100755
--- a/indra/newview/llregioninfomodel.cpp
+++ b/indra/newview/llregioninfomodel.cpp
@@ -192,11 +192,11 @@ void LLRegionInfoModel::sendEstateOwnerMessage(
 
 	if (!cur_region)
 	{
-		llwarns << "Agent region not set" << llendl;
+		LL_WARNS() << "Agent region not set" << LL_ENDL;
 		return;
 	}
 
-	llinfos << "Sending estate request '" << request << "'" << llendl;
+	LL_INFOS() << "Sending estate request '" << request << "'" << LL_ENDL;
 	msg->newMessage("EstateOwnerMessage");
 	msg->nextBlockFast(_PREHASH_AgentData);
 	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
@@ -217,7 +217,7 @@ void LLRegionInfoModel::sendEstateOwnerMessage(
 		std::vector<std::string>::const_iterator end = strings.end();
 		for (unsigned i = 0; it != end; ++it, ++i)
 		{
-			lldebugs << "- [" << i << "] " << (*it) << llendl;
+			LL_DEBUGS() << "- [" << i << "] " << (*it) << LL_ENDL;
 			msg->nextBlock("ParamList");
 			msg->addString("Parameter", *it);
 		}
diff --git a/indra/newview/llremoteparcelrequest.cpp b/indra/newview/llremoteparcelrequest.cpp
index 500dec7ee5..13120fdf45 100755
--- a/indra/newview/llremoteparcelrequest.cpp
+++ b/indra/newview/llremoteparcelrequest.cpp
@@ -64,8 +64,8 @@ void LLRemoteParcelRequestResponder::result(const LLSD& content)
 //virtual
 void LLRemoteParcelRequestResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llwarns << "LLRemoteParcelRequest error [status:"
-			<< status << "]: " << content << llendl;
+	LL_WARNS() << "LLRemoteParcelRequest error [status:"
+			<< status << "]: " << content << LL_ENDL;
 
 	// Panel inspecting the information may be closed and destroyed
 	// before this response is received.
diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp
index 168a941ec3..0ed6a840e0 100755
--- a/indra/newview/llscreenchannel.cpp
+++ b/indra/newview/llscreenchannel.cpp
@@ -599,7 +599,7 @@ void LLScreenChannel::showToastsBottom()
 			LLToast* toast = (it-1)->getToast();
 			if (!toast)
 			{
-				llwarns << "Attempt to display a deleted toast." << llendl;
+				LL_WARNS() << "Attempt to display a deleted toast." << LL_ENDL;
 				return;
 			}
 
@@ -610,7 +610,7 @@ void LLScreenChannel::showToastsBottom()
 		LLToast* toast = it->getToast();
 		if(!toast)
 		{
-			llwarns << "Attempt to display a deleted toast." << llendl;
+			LL_WARNS() << "Attempt to display a deleted toast." << LL_ENDL;
 			return;
 		}
 
@@ -698,7 +698,7 @@ void LLScreenChannel::showToastsCentre()
 	LLToast* toast = mToastList[0].getToast();
 	if (!toast)
 	{
-		llwarns << "Attempt to display a deleted toast." << llendl;
+		LL_WARNS() << "Attempt to display a deleted toast." << LL_ENDL;
 		return;
 	}
 
@@ -711,7 +711,7 @@ void LLScreenChannel::showToastsCentre()
 		LLToast* toast = it->getToast();
 		if (!toast)
 		{
-			llwarns << "Attempt to display a deleted toast." << llendl;
+			LL_WARNS() << "Attempt to display a deleted toast." << LL_ENDL;
 			return;
 		}
 
@@ -747,7 +747,7 @@ void LLScreenChannel::showToastsTop()
 			LLToast* toast = (it-1)->getToast();
 			if (!toast)
 			{
-				llwarns << "Attempt to display a deleted toast." << llendl;
+				LL_WARNS() << "Attempt to display a deleted toast." << LL_ENDL;
 				return;
 			}
 
@@ -758,7 +758,7 @@ void LLScreenChannel::showToastsTop()
 		LLToast* toast = it->getToast();
 		if (!toast)
 		{
-			llwarns << "Attempt to display a deleted toast." << llendl;
+			LL_WARNS() << "Attempt to display a deleted toast." << LL_ENDL;
 			return;
 		}
 
@@ -954,7 +954,7 @@ void LLScreenChannel::hideToastsFromScreen()
 		}
 		else
 		{
-			llwarns << "Attempt to hide a deleted toast." << llendl;
+			LL_WARNS() << "Attempt to hide a deleted toast." << LL_ENDL;
 		}
 	}
 }
@@ -972,7 +972,7 @@ void LLScreenChannel::hideToast(const LLUUID& notification_id)
 		}
 		else
 		{
-			llwarns << "Attempt to hide a deleted toast." << llendl;
+			LL_WARNS() << "Attempt to hide a deleted toast." << LL_ENDL;
 		}
 	}
 }
diff --git a/indra/newview/llscriptfloater.cpp b/indra/newview/llscriptfloater.cpp
index b5edeb4a0e..590a1c2647 100755
--- a/indra/newview/llscriptfloater.cpp
+++ b/indra/newview/llscriptfloater.cpp
@@ -306,7 +306,7 @@ void LLScriptFloater::dockToChiclet(bool dock)
 			LLChiclet * chicletp = chiclet_panelp->findChiclet<LLChiclet>(getNotificationId());
 			if (NULL == chicletp)
 			{
-				llwarns << "Dock chiclet for LLScriptFloater doesn't exist" << llendl;
+				LL_WARNS() << "Dock chiclet for LLScriptFloater doesn't exist" << LL_ENDL;
 				return;
 			}
 
@@ -350,7 +350,7 @@ void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id)
 {
 	if(notification_id.isNull())
 	{
-		llwarns << "Invalid notification ID" << llendl;
+		LL_WARNS() << "Invalid notification ID" << LL_ENDL;
 		return;
 	}
 
@@ -434,7 +434,7 @@ void LLScriptFloaterManager::onRemoveNotification(const LLUUID& notification_id)
 {
 	if(notification_id.isNull())
 	{
-		llwarns << "Invalid notification ID" << llendl;
+		LL_WARNS() << "Invalid notification ID" << LL_ENDL;
 		return;
 	}
 
@@ -505,7 +505,7 @@ LLScriptFloaterManager::EObjectType LLScriptFloaterManager::getObjectType(const
 {
 	if(notification_id.isNull())
 	{
-		llwarns << "Invalid notification ID" << llendl;
+		LL_WARNS() << "Invalid notification ID" << LL_ENDL;
 		return OBJ_UNKNOWN;
 	}
 
@@ -518,7 +518,7 @@ LLScriptFloaterManager::EObjectType LLScriptFloaterManager::getObjectType(const
 		return it->second;
 	}
 
-	llwarns << "Unknown object type" << llendl;
+	LL_WARNS() << "Unknown object type" << LL_ENDL;
 	return OBJ_UNKNOWN;
 }
 
@@ -529,7 +529,7 @@ std::string LLScriptFloaterManager::getObjectName(const LLUUID& notification_id)
 	LLNotificationPtr notification = LLNotifications::getInstance()->find(notification_id);
 	if(!notification)
 	{
-		llwarns << "Invalid notification" << llendl;
+		LL_WARNS() << "Invalid notification" << LL_ENDL;
 		return LLStringUtil::null;
 	}
 
@@ -586,7 +586,7 @@ void LLScriptFloaterManager::saveFloaterPosition(const LLUUID& object_id, const
 	}
 	else
 	{
-		llwarns << "Invalid object id" << llendl;
+		LL_WARNS() << "Invalid object id" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp
index 928d26646b..4345c33e48 100755
--- a/indra/newview/llsechandler_basic.cpp
+++ b/indra/newview/llsechandler_basic.cpp
@@ -1210,7 +1210,7 @@ void LLSecAPIBasicHandler::init()
 		// grab the application CA.pem file that contains the well-known certs shipped
 		// with the product
 		std::string ca_file_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem");
-		llinfos << "app path " << ca_file_path << llendl;
+		LL_INFOS() << "app path " << ca_file_path << LL_ENDL;
 		LLPointer<LLBasicCertificateStore> app_ca_store = new LLBasicCertificateStore(ca_file_path);
 		
 		// push the applicate CA files into the store, therefore adding any new CA certs that 
@@ -1362,7 +1362,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()
 		// EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData()
 		// Decided throwing an exception here was overkill until we figure out why this happens
 		//throw LLProtectedDataException("Error writing Protected Data Store");
-		llinfos << "LLProtectedDataException(Error writing Protected Data Store)" << llendl;
+		LL_INFOS() << "LLProtectedDataException(Error writing Protected Data Store)" << LL_ENDL;
 	}
 
 	// move the temporary file to the specified file location.
@@ -1375,7 +1375,7 @@ void LLSecAPIBasicHandler::_writeProtectedData()
 		// EXP-1825 crash in LLSecAPIBasicHandler::_writeProtectedData()
 		// Decided throwing an exception here was overkill until we figure out why this happens
 		//throw LLProtectedDataException("Could not overwrite protected data store");
-		llinfos << "LLProtectedDataException(Could not overwrite protected data store)" << llendl;
+		LL_INFOS() << "LLProtectedDataException(Could not overwrite protected data store)" << LL_ENDL;
 	}
 }
 		
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 06ad834f35..06ae95ee23 100755
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -326,7 +326,7 @@ LLObjectSelectionHandle LLSelectMgr::selectObjectOnly(LLViewerObject* object, S3
 		return NULL;
 	}
 
-	// llinfos << "Adding object to selected object list" << llendl;
+	// LL_INFOS() << "Adding object to selected object list" << LL_ENDL;
 
 	// Place it in the list and tag it.
 	// This will refresh dialogs.
@@ -892,7 +892,7 @@ void LLSelectMgr::addAsIndividual(LLViewerObject *objectp, S32 face, BOOL undoab
 	}
 	else
 	{
-		llerrs << "LLSelectMgr::add face " << face << " out-of-range" << llendl;
+		LL_ERRS() << "LLSelectMgr::add face " << face << " out-of-range" << LL_ENDL;
 		return;
 	}
 
@@ -1336,7 +1336,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable)
 		}
 		else
 		{
-			llerrs << "LLSelectMgr::remove - tried to remove TE " << te << " that wasn't selected" << llendl;
+			LL_ERRS() << "LLSelectMgr::remove - tried to remove TE " << te << " that wasn't selected" << LL_ENDL;
 			return;
 		}
 
@@ -1359,7 +1359,7 @@ void LLSelectMgr::remove(LLViewerObject *objectp, S32 te, BOOL undoable)
 	else
 	{
 		// ...out of range face
-		llerrs << "LLSelectMgr::remove - TE " << te << " out of range" << llendl;
+		LL_ERRS() << "LLSelectMgr::remove - TE " << te << " out of range" << LL_ENDL;
 	}
 
 	updateSelectionCenter();
@@ -1458,26 +1458,26 @@ void LLSelectMgr::demoteSelectionToIndividuals()
 //-----------------------------------------------------------------------------
 void LLSelectMgr::dump()
 {
-	llinfos << "Selection Manager: " << mSelectedObjects->getNumNodes() << " items" << llendl;
+	LL_INFOS() << "Selection Manager: " << mSelectedObjects->getNumNodes() << " items" << LL_ENDL;
 
-	llinfos << "TE mode " << mTEMode << llendl;
+	LL_INFOS() << "TE mode " << mTEMode << LL_ENDL;
 
 	S32 count = 0;
 	for (LLObjectSelection::iterator iter = getSelection()->begin();
 		 iter != getSelection()->end(); iter++ )
 	{
 		LLViewerObject* objectp = (*iter)->getObject();
-		llinfos << "Object " << count << " type " << LLPrimitive::pCodeToString(objectp->getPCode()) << llendl;
-		llinfos << "  hasLSL " << objectp->flagScripted() << llendl;
-		llinfos << "  hasTouch " << objectp->flagHandleTouch() << llendl;
-		llinfos << "  hasMoney " << objectp->flagTakesMoney() << llendl;
-		llinfos << "  getposition " << objectp->getPosition() << llendl;
-		llinfos << "  getpositionAgent " << objectp->getPositionAgent() << llendl;
-		llinfos << "  getpositionRegion " << objectp->getPositionRegion() << llendl;
-		llinfos << "  getpositionGlobal " << objectp->getPositionGlobal() << llendl;
+		LL_INFOS() << "Object " << count << " type " << LLPrimitive::pCodeToString(objectp->getPCode()) << LL_ENDL;
+		LL_INFOS() << "  hasLSL " << objectp->flagScripted() << LL_ENDL;
+		LL_INFOS() << "  hasTouch " << objectp->flagHandleTouch() << LL_ENDL;
+		LL_INFOS() << "  hasMoney " << objectp->flagTakesMoney() << LL_ENDL;
+		LL_INFOS() << "  getposition " << objectp->getPosition() << LL_ENDL;
+		LL_INFOS() << "  getpositionAgent " << objectp->getPositionAgent() << LL_ENDL;
+		LL_INFOS() << "  getpositionRegion " << objectp->getPositionRegion() << LL_ENDL;
+		LL_INFOS() << "  getpositionGlobal " << objectp->getPositionGlobal() << LL_ENDL;
 		LLDrawable* drawablep = objectp->mDrawable;
-		llinfos << "  " << (drawablep&& drawablep->isVisible() ? "visible" : "invisible") << llendl;
-		llinfos << "  " << (drawablep&& drawablep->isState(LLDrawable::FORCE_INVISIBLE) ? "force_invisible" : "") << llendl;
+		LL_INFOS() << "  " << (drawablep&& drawablep->isVisible() ? "visible" : "invisible") << LL_ENDL;
+		LL_INFOS() << "  " << (drawablep&& drawablep->isState(LLDrawable::FORCE_INVISIBLE) ? "force_invisible" : "") << LL_ENDL;
 		count++;
 	}
 
@@ -1493,14 +1493,14 @@ void LLSelectMgr::dump()
 		{
 			if (node->isTESelected(te))
 			{
-				llinfos << "Object " << objectp << " te " << te << llendl;
+				LL_INFOS() << "Object " << objectp << " te " << te << LL_ENDL;
 			}
 		}
 	}
 
-	llinfos << mHighlightedObjects->getNumNodes() << " objects currently highlighted." << llendl;
+	LL_INFOS() << mHighlightedObjects->getNumNodes() << " objects currently highlighted." << LL_ENDL;
 
-	llinfos << "Center global " << mSelectionCenterGlobal << llendl;
+	LL_INFOS() << "Center global " << mSelectionCenterGlobal << LL_ENDL;
 }
 
 //-----------------------------------------------------------------------------
@@ -1583,8 +1583,8 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid)
 		&& !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())
 		&& (mSelectedObjects->getNumNodes() > 1) )
 	{
-		llwarns << "Attempted to apply no-copy texture to multiple objects"
-				<< llendl;
+		LL_WARNS() << "Attempted to apply no-copy texture to multiple objects"
+				<< LL_ENDL;
 		return;
 	}
 
@@ -3513,7 +3513,7 @@ bool LLSelectMgr::confirmDelete(const LLSD& notification, const LLSD& response,
 	S32 option = LLNotification::getSelectedOption(notification, response);
 	if (!handle->getObjectCount())
 	{
-		llwarns << "Nothing to delete!" << llendl;
+		LL_WARNS() << "Nothing to delete!" << LL_ENDL;
 		return false;
 	}
 
@@ -3951,7 +3951,7 @@ void LLSelectMgr::packMultipleUpdate(LLSelectNode* node, void *user_data)
 	}
 	if (type & UPD_SCALE)
 	{
-		//llinfos << "Sending object scale " << object->getScale() << llendl;
+		//LL_INFOS() << "Sending object scale " << object->getScale() << LL_ENDL;
 		htonmemcpy(&data[offset], &(object->getScale().mV), MVT_LLVector3, 12); 
 		offset += 12;
 	}
@@ -4089,7 +4089,7 @@ void LLSelectMgr::packPermissionsHead(void* user_data)
 /*
 void LLSelectMgr::sendSelect()
 {
-	llerrs << "Not implemented" << llendl;
+	LL_ERRS() << "Not implemented" << LL_ENDL;
 }
 */
 
@@ -4203,9 +4203,9 @@ void LLSelectMgr::deselectAllIfTooFar()
 		{
 			if (mDebugSelectMgr)
 			{
-				llinfos << "Selection manager: auto-deselecting, select_dist = " << (F32) sqrt(select_dist_sq) << llendl;
-				llinfos << "agent pos global = " << gAgent.getPositionGlobal() << llendl;
-				llinfos << "selection pos global = " << selectionCenter << llendl;
+				LL_INFOS() << "Selection manager: auto-deselecting, select_dist = " << (F32) sqrt(select_dist_sq) << LL_ENDL;
+				LL_INFOS() << "agent pos global = " << gAgent.getPositionGlobal() << LL_ENDL;
+				LL_INFOS() << "selection pos global = " << selectionCenter << LL_ENDL;
 			}
 
 			deselectAll();
@@ -4917,7 +4917,7 @@ void LLSelectMgr::sendListToRegions(const std::string& message_name,
 		break;
 
 	default:
-		llerrs << "Bad send type " << send_type << " passed to SendListToRegions()" << llendl;
+		LL_ERRS() << "Bad send type " << send_type << " passed to SendListToRegions()" << LL_ENDL;
 	}
 
 	// bail if nothing selected
@@ -4991,7 +4991,7 @@ void LLSelectMgr::sendListToRegions(const std::string& message_name,
 		gMessageSystem->clearMessage();
 	}
 
-	// llinfos << "sendListToRegions " << message_name << " obj " << objects_sent << " pkt " << packets_sent << llendl;
+	// LL_INFOS() << "sendListToRegions " << message_name << " obj " << objects_sent << " pkt " << packets_sent << LL_ENDL;
 }
 
 
@@ -5108,7 +5108,7 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
 
 		if (!node)
 		{
-			llwarns << "Couldn't find object " << id << " selected." << llendl;
+			LL_WARNS() << "Couldn't find object " << id << " selected." << LL_ENDL;
 		}
 		else
 		{
@@ -6369,7 +6369,7 @@ S32 get_family_count(LLViewerObject *parent)
 {
 	if (!parent)
 	{
-		llwarns << "Trying to get_family_count on null parent!" << llendl;
+		LL_WARNS() << "Trying to get_family_count on null parent!" << LL_ENDL;
 	}
 	S32 count = 1;	// for this object
 	LLViewerObject::const_child_list_t& child_list = parent->getChildren();
@@ -6380,11 +6380,11 @@ S32 get_family_count(LLViewerObject *parent)
 
 		if (!child)
 		{
-			llwarns << "Family object has NULL child!  Show Doug." << llendl;
+			LL_WARNS() << "Family object has NULL child!  Show Doug." << LL_ENDL;
 		}
 		else if (child->isDead())
 		{
-			llwarns << "Family object has dead child object.  Show Doug." << llendl;
+			LL_WARNS() << "Family object has dead child object.  Show Doug." << LL_ENDL;
 		}
 		else
 		{
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index a405129a25..a8283b9208 100755
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -201,7 +201,7 @@ void LLSidepanelAppearance::updateToVisibility(const LLSD &new_visibility)
 			const LLViewerWearable *wearable_ptr = mEditWearable->getWearable();
 			if (!wearable_ptr)
 			{
-				llwarns << "Visibility change to invalid wearable" << llendl;
+				LL_WARNS() << "Visibility change to invalid wearable" << LL_ENDL;
 				return;
 			}
 			// Disable camera switch is currently just for WT_PHYSICS type since we don't want to freeze the avatar
diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp
index 8915bb2fef..d20f89456b 100755
--- a/indra/newview/llsidepanelinventory.cpp
+++ b/indra/newview/llsidepanelinventory.cpp
@@ -310,7 +310,7 @@ void LLSidepanelInventory::observeInboxModifications(const LLUUID& inboxID)
 
 	if (inboxID.isNull())
 	{
-		llwarns << "Attempting to track modifications to non-existent inbox" << llendl;
+		LL_WARNS() << "Attempting to track modifications to non-existent inbox" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp
index 92c2863ffd..d1e14632ff 100755
--- a/indra/newview/llsidepaneliteminfo.cpp
+++ b/indra/newview/llsidepaneliteminfo.cpp
@@ -678,7 +678,7 @@ void LLSidepanelItemInfo::startObjectInventoryObserver()
 
 	if (mObjectID.isNull())
 	{
-		llwarns << "Empty object id passed to inventory observer" << llendl;
+		LL_WARNS() << "Empty object id passed to inventory observer" << LL_ENDL;
 		return;
 	}
 
@@ -721,7 +721,7 @@ void LLSidepanelItemInfo::onClickOwner()
 // static
 void LLSidepanelItemInfo::onCommitName()
 {
-	//llinfos << "LLSidepanelItemInfo::onCommitName()" << llendl;
+	//LL_INFOS() << "LLSidepanelItemInfo::onCommitName()" << LL_ENDL;
 	LLViewerInventoryItem* item = findItem();
 	if(!item)
 	{
@@ -757,7 +757,7 @@ void LLSidepanelItemInfo::onCommitName()
 
 void LLSidepanelItemInfo::onCommitDescription()
 {
-	//llinfos << "LLSidepanelItemInfo::onCommitDescription()" << llendl;
+	//LL_INFOS() << "LLSidepanelItemInfo::onCommitDescription()" << LL_ENDL;
 	LLViewerInventoryItem* item = findItem();
 	if(!item) return;
 
@@ -795,7 +795,7 @@ void LLSidepanelItemInfo::onCommitDescription()
 // static
 void LLSidepanelItemInfo::onCommitPermissions()
 {
-	//llinfos << "LLSidepanelItemInfo::onCommitPermissions()" << llendl;
+	//LL_INFOS() << "LLSidepanelItemInfo::onCommitPermissions()" << LL_ENDL;
 	LLViewerInventoryItem* item = findItem();
 	if(!item) return;
 	LLPermissions perm(item->getPermissions());
@@ -892,14 +892,14 @@ void LLSidepanelItemInfo::onCommitPermissions()
 // static
 void LLSidepanelItemInfo::onCommitSaleInfo()
 {
-	//llinfos << "LLSidepanelItemInfo::onCommitSaleInfo()" << llendl;
+	//LL_INFOS() << "LLSidepanelItemInfo::onCommitSaleInfo()" << LL_ENDL;
 	updateSaleInfo();
 }
 
 // static
 void LLSidepanelItemInfo::onCommitSaleType()
 {
-	//llinfos << "LLSidepanelItemInfo::onCommitSaleType()" << llendl;
+	//LL_INFOS() << "LLSidepanelItemInfo::onCommitSaleType()" << LL_ENDL;
 	updateSaleInfo();
 }
 
diff --git a/indra/newview/llsidepaneltaskinfo.cpp b/indra/newview/llsidepaneltaskinfo.cpp
index 090ee64801..56f82b851a 100755
--- a/indra/newview/llsidepaneltaskinfo.cpp
+++ b/indra/newview/llsidepaneltaskinfo.cpp
@@ -995,28 +995,28 @@ void LLSidepanelTaskInfo::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
 // static
 void LLSidepanelTaskInfo::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
 {
-	//llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerModify" << llendl;
+	//LL_INFOS() << "LLSidepanelTaskInfo::onCommitNextOwnerModify" << LL_ENDL;
 	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
 }
 
 // static
 void LLSidepanelTaskInfo::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
 {
-	//llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerCopy" << llendl;
+	//LL_INFOS() << "LLSidepanelTaskInfo::onCommitNextOwnerCopy" << LL_ENDL;
 	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
 }
 
 // static
 void LLSidepanelTaskInfo::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
 {
-	//llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerTransfer" << llendl;
+	//LL_INFOS() << "LLSidepanelTaskInfo::onCommitNextOwnerTransfer" << LL_ENDL;
 	onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
 }
 
 // static
 void LLSidepanelTaskInfo::onCommitName(LLUICtrl*, void* data)
 {
-	//llinfos << "LLSidepanelTaskInfo::onCommitName()" << llendl;
+	//LL_INFOS() << "LLSidepanelTaskInfo::onCommitName()" << LL_ENDL;
 	LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
 	LLLineEditor*	tb = self->getChild<LLLineEditor>("Object Name");
 	if(tb)
@@ -1030,7 +1030,7 @@ void LLSidepanelTaskInfo::onCommitName(LLUICtrl*, void* data)
 // static
 void LLSidepanelTaskInfo::onCommitDesc(LLUICtrl*, void* data)
 {
-	//llinfos << "LLSidepanelTaskInfo::onCommitDesc()" << llendl;
+	//LL_INFOS() << "LLSidepanelTaskInfo::onCommitDesc()" << LL_ENDL;
 	LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
 	LLLineEditor*	le = self->getChild<LLLineEditor>("Object Description");
 	if(le)
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index ad659baa9e..f3b0108359 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -76,7 +76,7 @@ void sg_assert(BOOL expr)
 #if LL_OCTREE_PARANOIA_CHECK
 	if (!expr)
 	{
-		llerrs << "Octree invalid!" << llendl;
+		LL_ERRS() << "Octree invalid!" << LL_ENDL;
 	}
 #endif
 }
@@ -114,7 +114,7 @@ LLSpatialGroup::~LLSpatialGroup()
 {
 	/*if (sNoDelete)
 	{
-		llerrs << "Illegal deletion of LLSpatialGroup!" << llendl;
+		LL_ERRS() << "Illegal deletion of LLSpatialGroup!" << LL_ENDL;
 	}*/
 
 	if (gDebugGL)
@@ -300,7 +300,7 @@ void LLSpatialGroup::validate()
 			LLSpatialPartition* part = drawable->asPartition();
 			if (!part)
 			{
-				llerrs << "Drawable reports it is a spatial bridge but not a partition." << llendl;
+				LL_ERRS() << "Drawable reports it is a spatial bridge but not a partition." << LL_ENDL;
 			}
 			LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0);
 			group->validate();
@@ -685,7 +685,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 {
 	if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
-		llwarns << "Attempted to update distance for camera other than world camera!" << llendl;
+		LL_WARNS() << "Attempted to update distance for camera other than world camera!" << LL_ENDL;
 		return;
 	}
 
@@ -697,7 +697,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
 #if !LL_RELEASE_FOR_DOWNLOAD
 	if (hasState(LLSpatialGroup::OBJECT_DIRTY))
 	{
-		llerrs << "Spatial group dirty on distance update." << llendl;
+		LL_ERRS() << "Spatial group dirty on distance update." << LL_ENDL;
 	}
 #endif
 	if (!isEmpty())
@@ -859,7 +859,7 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
 			}
 			else
 	{
-				llerrs << "No Drawable found in the entry." << llendl;
+				LL_ERRS() << "No Drawable found in the entry." << LL_ENDL;
 			}
 		}
 		else
@@ -894,7 +894,7 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c
 	}
 	else
 	{
-		OCT_ERRS << "LLSpatialGroup redundancy detected." << llendl;
+		OCT_ERRS << "LLSpatialGroup redundancy detected." << LL_ENDL;
 	}
 
 	unbound();
@@ -991,7 +991,7 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
 {
 	if (!curp->removeObject(drawablep))
 	{
-		OCT_ERRS << "Failed to remove drawable from octree!" << llendl;
+		OCT_ERRS << "Failed to remove drawable from octree!" << LL_ENDL;
 	}
 	else
 	{
@@ -1009,7 +1009,7 @@ void LLSpatialPartition::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL
 	// who was seeing crashing here. (See VWR-424 reported by Bunny Mayne)
 	if (!drawablep)
 	{
-		OCT_ERRS << "LLSpatialPartition::move was passed a bad drawable." << llendl;
+		OCT_ERRS << "LLSpatialPartition::move was passed a bad drawable." << LL_ENDL;
 		return;
 	}
 		
@@ -1026,7 +1026,7 @@ void LLSpatialPartition::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL
 		}
 		else
 		{
-			OCT_ERRS << "Drawable lost between spatial partitions on outbound transition." << llendl;
+			OCT_ERRS << "Drawable lost between spatial partitions on outbound transition." << LL_ENDL;
 		}
 	}
 		
@@ -1041,7 +1041,7 @@ void LLSpatialPartition::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL
 	LLPointer<LLDrawable> ptr = drawablep;
 	if (curp && !remove(drawablep, curp))
 	{
-		OCT_ERRS << "Move couldn't find existing spatial group!" << llendl;
+		OCT_ERRS << "Move couldn't find existing spatial group!" << LL_ENDL;
 	}
 
 	put(drawablep, was_visible);
@@ -1973,7 +1973,7 @@ void renderUpdateType(LLDrawable* drawablep)
 		gGL.diffuseColor4f(0,0,1,0.5f);
 		break;
 	default:
-		llwarns << "Unknown update_type " << vobj->getLastUpdateType() << llendl;
+		LL_WARNS() << "Unknown update_type " << vobj->getLastUpdateType() << LL_ENDL;
 		break;
 	};
 	S32 num_faces = drawablep->getNumFaces();
@@ -2620,7 +2620,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
 	}
 	else 
 	{
-		llerrs << "Unhandled type" << llendl;
+		LL_ERRS() << "Unhandled type" << LL_ENDL;
 	}
 
 	gGL.popMatrix();
@@ -3368,11 +3368,11 @@ public:
 							{
 								if (facep->mDrawInfo->mTextureList.size() <= index)
 								{
-									llerrs << "Face texture index out of bounds." << llendl;
+									LL_ERRS() << "Face texture index out of bounds." << LL_ENDL;
 								}
 								else if (facep->mDrawInfo->mTextureList[index] != facep->getTexture())
 								{
-									llerrs << "Face texture index incorrect." << llendl;
+									LL_ERRS() << "Face texture index incorrect." << LL_ENDL;
 								}
 							}
 						}
@@ -3581,7 +3581,7 @@ public:
 		{
 			if (mInheritedMask[i] && !(group->mOcclusionState[i] & mInheritedMask[i]))
 			{
-				llerrs << "Spatial group failed inherited mask test." << llendl;
+				LL_ERRS() << "Spatial group failed inherited mask test." << LL_ENDL;
 			}
 		}
 
@@ -3598,7 +3598,7 @@ public:
 		{
 			if (!parent->hasState(state))
 			{
-				llerrs << "Spatial group failed parent state check." << llendl;
+				LL_ERRS() << "Spatial group failed parent state check." << LL_ENDL;
 			}
 			parent = parent->getParent();
 		}
@@ -3927,7 +3927,7 @@ LLDrawInfo::~LLDrawInfo()
 {
 	/*if (LLSpatialGroup::sNoDelete)
 	{
-		llerrs << "LLDrawInfo deleted illegally!" << llendl;
+		LL_ERRS() << "LLDrawInfo deleted illegally!" << LL_ENDL;
 	}*/
 
 	if (mFace)
@@ -4205,7 +4205,7 @@ void LLCullResult::assertDrawMapsEmpty()
 	{
 		if (mRenderMapSize[i] != 0)
 		{
-			llerrs << "Stale LLDrawInfo's in LLCullResult!" << llendl;
+			LL_ERRS() << "Stale LLDrawInfo's in LLCullResult!" << LL_ENDL;
 		}
 	}
 }
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 05ed70ab59..8d755e74b1 100755
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -79,7 +79,7 @@ public:
 
 	const LLDrawInfo& operator=(const LLDrawInfo& rhs)
 	{
-		llerrs << "Illegal operation!" << llendl;
+		LL_ERRS() << "Illegal operation!" << LL_ENDL;
 		return *this;
 	}
 
@@ -221,7 +221,7 @@ public:
 
 	const LLSpatialGroup& operator=(const LLSpatialGroup& rhs)
 	{
-		llerrs << "Illegal operation!" << llendl;
+		LL_ERRS() << "Illegal operation!" << LL_ENDL;
 		return *this;
 	}
 
diff --git a/indra/newview/llspeakers.cpp b/indra/newview/llspeakers.cpp
index 75e6b4f1a5..f25076d47e 100755
--- a/indra/newview/llspeakers.cpp
+++ b/indra/newview/llspeakers.cpp
@@ -278,7 +278,7 @@ public:
 	
 	virtual void error(U32 status, const std::string& reason)
 	{
-		llwarns << status << ": " << reason << llendl;
+		LL_WARNS() << status << ": " << reason << LL_ENDL;
 		
 		if ( gIMMgr )
 		{
@@ -341,7 +341,7 @@ LLPointer<LLSpeaker> LLSpeakerMgr::setSpeaker(const LLUUID& id, const std::strin
 		speakerp->mStatus = status;
 		mSpeakers.insert(std::make_pair(speakerp->mID, speakerp));
 		mSpeakersSorted.push_back(speakerp);
-		LL_DEBUGS("Speakers") << "Added speaker " << id << llendl;
+		LL_DEBUGS("Speakers") << "Added speaker " << id << LL_ENDL;
 		fireEvent(new LLSpeakerListChangeEvent(this, speakerp->mID), "add");
 	}
 	else
@@ -362,7 +362,7 @@ LLPointer<LLSpeaker> LLSpeakerMgr::setSpeaker(const LLUUID& id, const std::strin
 		}
 		else
 		{
-			LL_WARNS("Speakers") << "Speaker " << id << " not found" << llendl;
+			LL_WARNS("Speakers") << "Speaker " << id << " not found" << LL_ENDL;
 		}
 	}
 
@@ -426,7 +426,7 @@ void LLSpeakerMgr::update(BOOL resort_ok)
 			if (moderator_muted_voice != speakerp->mModeratorMutedVoice)
 			{
 				speakerp->mModeratorMutedVoice = moderator_muted_voice;
-				LL_DEBUGS("Speakers") << (speakerp->mModeratorMutedVoice? "Muted" : "Umuted") << " speaker " << speaker_id<< llendl;
+				LL_DEBUGS("Speakers") << (speakerp->mModeratorMutedVoice? "Muted" : "Umuted") << " speaker " << speaker_id<< LL_ENDL;
 				speakerp->fireEvent(new LLSpeakerVoiceModerationEvent(speakerp));
 			}
 
@@ -623,7 +623,7 @@ bool LLSpeakerMgr::removeSpeaker(const LLUUID& speaker_id)
 		}
 	}
 
-	LL_DEBUGS("Speakers") << "Removed speaker " << speaker_id << llendl;
+	LL_DEBUGS("Speakers") << "Removed speaker " << speaker_id << LL_ENDL;
 	fireEvent(new LLSpeakerListChangeEvent(this, speaker_id), "remove");
 
 	update(TRUE);
@@ -741,7 +741,7 @@ void LLIMSpeakerMgr::setSpeakers(const LLSD& speakers)
 				// Fire event only if moderator changed
 				if ( is_moderator != speakerp->mIsModerator )
 				{
-					LL_DEBUGS("Speakers") << "Speaker " << agent_id << (is_moderator ? "is now" : "no longer is") << " a moderator" << llendl;
+					LL_DEBUGS("Speakers") << "Speaker " << agent_id << (is_moderator ? "is now" : "no longer is") << " a moderator" << LL_ENDL;
 					fireEvent(new LLSpeakerUpdateModeratorEvent(speakerp), "update_moderator");
 				}
 			}
@@ -796,7 +796,7 @@ void LLIMSpeakerMgr::updateSpeakers(const LLSD& update)
 				}
 				else
 				{
-					llwarns << "bad membership list update " << ll_print_sd(agent_data["transition"]) << llendl;
+					LL_WARNS() << "bad membership list update " << ll_print_sd(agent_data["transition"]) << LL_ENDL;
 				}
 			}
 
@@ -814,7 +814,7 @@ void LLIMSpeakerMgr::updateSpeakers(const LLSD& update)
 					// Fire event only if moderator changed
 					if ( is_moderator != speakerp->mIsModerator )
 					{
-						LL_DEBUGS("Speakers") << "Speaker " << agent_id << (is_moderator ? "is now" : "no longer is") << " a moderator" << llendl;
+						LL_DEBUGS("Speakers") << "Speaker " << agent_id << (is_moderator ? "is now" : "no longer is") << " a moderator" << LL_ENDL;
 						fireEvent(new LLSpeakerUpdateModeratorEvent(speakerp), "update_moderator");
 					}
 				}
@@ -849,15 +849,15 @@ void LLIMSpeakerMgr::updateSpeakers(const LLSD& update)
 			}
 			else
 			{
-				llwarns << "bad membership list update "
-						<< agent_transition << llendl;
+				LL_WARNS() << "bad membership list update "
+						<< agent_transition << LL_ENDL;
 			}
 		}
 	}
 }
 /*prep#
 	virtual void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
-		llwarns << "ModerationResponder error [status:" << status << "]: " << content << llendl;
+		LL_WARNS() << "ModerationResponder error [status:" << status << "]: " << content << LL_ENDL;
 		*/
 void LLIMSpeakerMgr::toggleAllowTextChat(const LLUUID& speaker_id)
 {
@@ -974,7 +974,7 @@ void LLActiveSpeakerMgr::updateSpeakerList()
 	// always populate from active voice channel
 	if (LLVoiceChannel::getCurrentVoiceChannel() != mVoiceChannel) //MA: seems this is always false
 	{
-		LL_DEBUGS("Speakers") << "Removed all speakers" << llendl;
+		LL_DEBUGS("Speakers") << "Removed all speakers" << LL_ENDL;
 		fireEvent(new LLSpeakerListChangeEvent(this, LLUUID::null), "clear");
 		mSpeakers.clear();
 		mSpeakersSorted.clear();
diff --git a/indra/newview/llspeakingindicatormanager.cpp b/indra/newview/llspeakingindicatormanager.cpp
index 07e9371124..78fe7863c8 100755
--- a/indra/newview/llspeakingindicatormanager.cpp
+++ b/indra/newview/llspeakingindicatormanager.cpp
@@ -279,7 +279,7 @@ void SpeakingIndicatorManager::ensureInstanceDoesNotExist(LLSpeakingIndicator* c
 	// So, using stored deleted pointer leads to crash. See EXT-4782.
 	if (it != mSpeakingIndicators.end())
 	{
-		llwarns << "The same instance of indicator has already been registered, removing it: " << it->first << "|"<< speaking_indicator << llendl;
+		LL_WARNS() << "The same instance of indicator has already been registered, removing it: " << it->first << "|"<< speaking_indicator << LL_ENDL;
 		llassert(it == mSpeakingIndicators.end());
 		mSpeakingIndicators.erase(it);
 	}
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 933cc74064..3335ff6631 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1675,7 +1675,7 @@ bool idle_startup()
 		LLSD inv_basic = response["inventory-basic"];
  		if(inv_basic.isDefined())
  		{
-			llinfos << "Basic inventory root folder id is " << inv_basic["folder_id"] << llendl;
+			LL_INFOS() << "Basic inventory root folder id is " << inv_basic["folder_id"] << LL_ENDL;
  		}
 
 		LLSD buddy_list = response["buddy-list"];
@@ -1770,30 +1770,30 @@ bool idle_startup()
 		gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE,true);
 
 		// set up callbacks
-		llinfos << "Registering Callbacks" << llendl;
+		LL_INFOS() << "Registering Callbacks" << LL_ENDL;
 		LLMessageSystem* msg = gMessageSystem;
-		llinfos << " Inventory" << llendl;
+		LL_INFOS() << " Inventory" << LL_ENDL;
 		LLInventoryModel::registerCallbacks(msg);
-		llinfos << " AvatarTracker" << llendl;
+		LL_INFOS() << " AvatarTracker" << LL_ENDL;
 		LLAvatarTracker::instance().registerCallbacks(msg);
-		llinfos << " Landmark" << llendl;
+		LL_INFOS() << " Landmark" << LL_ENDL;
 		LLLandmark::registerCallbacks(msg);
 		display_startup();
 
 		// request mute list
-		llinfos << "Requesting Mute List" << llendl;
+		LL_INFOS() << "Requesting Mute List" << LL_ENDL;
 		LLMuteList::getInstance()->requestFromServer(gAgent.getID());
 		display_startup();
 		// Get L$ and ownership credit information
-		llinfos << "Requesting Money Balance" << llendl;
+		LL_INFOS() << "Requesting Money Balance" << LL_ENDL;
 		LLStatusBar::sendMoneyBalanceRequest();
 		display_startup();
 		// request all group information
-		llinfos << "Requesting Agent Data" << llendl;
+		LL_INFOS() << "Requesting Agent Data" << LL_ENDL;
 		gAgent.sendAgentDataUpdateRequest();
 		display_startup();
 		// Create the inventory views
-		llinfos << "Creating Inventory Views" << llendl;
+		LL_INFOS() << "Creating Inventory Views" << LL_ENDL;
 		LLFloaterReg::getInstance("inventory");
 		display_startup();
 		LLStartUp::setStartupState( STATE_MISC );
@@ -1948,7 +1948,7 @@ bool idle_startup()
 		// thus, do not show this alert.
 		if (!gAgent.isFirstLogin())
 		{
-			llinfos << "gAgentStartLocation : " << gAgentStartLocation << llendl;
+			LL_INFOS() << "gAgentStartLocation : " << gAgentStartLocation << LL_ENDL;
 			LLSLURL start_slurl = LLStartUp::getStartSLURL();
 			LL_DEBUGS("AppInit") << "start slurl "<<start_slurl.asString()<<LL_ENDL;
 			
@@ -2080,14 +2080,14 @@ bool idle_startup()
 				&& gAgentAvatarp->isFullyLoaded())
 		{
 			// wait for avatar to be completely loaded
-			//llinfos << "avatar fully loaded" << llendl;
+			//LL_INFOS() << "avatar fully loaded" << LL_ENDL;
 			LLStartUp::setStartupState( STATE_CLEANUP );
 		}
 		// OK to just get the wearables
 		else if (!gAgent.isFirstLogin() && gAgentWearables.areWearablesLoaded() )
 		{
 			// We have our clothing, proceed.
-			//llinfos << "wearables loaded" << llendl;
+			//LL_INFOS() << "wearables loaded" << LL_ENDL;
 			LLStartUp::setStartupState( STATE_CLEANUP );
 		}
 		else
@@ -2162,7 +2162,7 @@ bool idle_startup()
 
 		// Unmute audio if desired and setup volumes.
 		// This is a not-uncommon crash site, so surround it with
-		// llinfos output to aid diagnosis.
+		// LL_INFOS() output to aid diagnosis.
 		LL_INFOS("AppInit") << "Doing first audio_update_volume..." << LL_ENDL;
 		audio_update_volume();
 		LL_INFOS("AppInit") << "Done first audio_update_volume." << LL_ENDL;
@@ -2530,7 +2530,7 @@ bool callback_choose_gender(const LLSD& notification, const LLSD& response)
 void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name,
 								   const std::string& gender_name )
 {
-	lldebugs << "starting" << llendl;
+	LL_DEBUGS() << "starting" << LL_ENDL;
 
 	// Not going through the processAgentInitialWearables path, so need to set this here.
 	LLAppearanceMgr::instance().setAttachmentInvLinkEnable(true);
@@ -2540,18 +2540,18 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name,
 	ESex gender;
 	if (gender_name == "male")
 	{
-		lldebugs << "male" << llendl;
+		LL_DEBUGS() << "male" << LL_ENDL;
 		gender = SEX_MALE;
 	}
 	else
 	{
-		lldebugs << "female" << llendl;
+		LL_DEBUGS() << "female" << LL_ENDL;
 		gender = SEX_FEMALE;
 	}
 
 	if (!isAgentAvatarValid())
 	{
-		llwarns << "Trying to load an initial outfit for an invalid agent avatar" << llendl;
+		LL_WARNS() << "Trying to load an initial outfit for an invalid agent avatar" << LL_ENDL;
 		return;
 	}
 
@@ -2564,7 +2564,7 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name,
 		outfit_folder_name);
 	if (cat_id.isNull())
 	{
-		lldebugs << "standard wearables" << llendl;
+		LL_DEBUGS() << "standard wearables" << LL_ENDL;
 		gAgentWearables.createStandardWearables();
 	}
 	else
@@ -2580,7 +2580,7 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name,
 		// Need to fetch cof contents before we can wear.
 		callAfterCategoryFetch(LLAppearanceMgr::instance().getCOF(),
 							   boost::bind(&LLAppearanceMgr::wearInventoryCategory, LLAppearanceMgr::getInstance(), cat, do_copy, do_append));
-		lldebugs << "initial outfit category id: " << cat_id << llendl;
+		LL_DEBUGS() << "initial outfit category id: " << cat_id << LL_ENDL;
 	}
 
 	// This is really misnamed -- it means we have started loading
@@ -2592,16 +2592,16 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name,
 void LLStartUp::saveInitialOutfit()
 {
 	if (sInitialOutfit.empty()) {
-		lldebugs << "sInitialOutfit is empty" << llendl;
+		LL_DEBUGS() << "sInitialOutfit is empty" << LL_ENDL;
 		return;
 	}
 	
 	if (sWearablesLoadedCon.connected())
 	{
-		lldebugs << "sWearablesLoadedCon is connected, disconnecting" << llendl;
+		LL_DEBUGS() << "sWearablesLoadedCon is connected, disconnecting" << LL_ENDL;
 		sWearablesLoadedCon.disconnect();
 	}
-	lldebugs << "calling makeNewOutfitLinks( \"" << sInitialOutfit << "\" )" << llendl;
+	LL_DEBUGS() << "calling makeNewOutfitLinks( \"" << sInitialOutfit << "\" )" << LL_ENDL;
 	LLAppearanceMgr::getInstance()->makeNewOutfitLinks(sInitialOutfit,false);
 }
 
@@ -3140,7 +3140,7 @@ void apply_udp_blacklist(const std::string& csv)
 		}
 		std::string item(csv, start, comma-start);
 
-		lldebugs << "udp_blacklist " << item << llendl;
+		LL_DEBUGS() << "udp_blacklist " << item << LL_ENDL;
 		gMessageSystem->banUdpMessage(item);
 		
 		start = comma + 1;
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index c1d15947de..047538a32a 100755
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -391,7 +391,7 @@ void LLStatusBar::sendMoneyBalanceRequest()
 
 void LLStatusBar::setHealth(S32 health)
 {
-	//llinfos << "Setting health to: " << buffer << llendl;
+	//LL_INFOS() << "Setting health to: " << buffer << LL_ENDL;
 	if( mHealth > health )
 	{
 		if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp
index 88eec48703..e75af8db53 100755
--- a/indra/newview/llsurface.cpp
+++ b/indra/newview/llsurface.cpp
@@ -123,7 +123,7 @@ LLSurface::~LLSurface()
 	LLDrawPoolTerrain *poolp = (LLDrawPoolTerrain*) gPipeline.findPool(LLDrawPool::POOL_TERRAIN, mSTexturep);
 	if (!poolp)
 	{
-		llwarns << "No pool for terrain on destruction!" << llendl;
+		LL_WARNS() << "No pool for terrain on destruction!" << LL_ENDL;
 	}
 	else if (poolp->mReferences.empty())
 	{
@@ -140,7 +140,7 @@ LLSurface::~LLSurface()
 	}
 	else
 	{
-		llerrs << "Terrain pool not empty!" << llendl;
+		LL_ERRS() << "Terrain pool not empty!" << LL_ENDL;
 	}
 }
 
@@ -709,7 +709,7 @@ void LLSurface::decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL
 
 		if ((i >= mPatchesPerEdge) || (j >= mPatchesPerEdge))
 		{
-			llwarns << "Received invalid terrain packet - patch header patch ID incorrect!" 
+			LL_WARNS() << "Received invalid terrain packet - patch header patch ID incorrect!" 
 				<< " patches per edge " << mPatchesPerEdge
 				<< " i " << i
 				<< " j " << j
@@ -717,7 +717,7 @@ void LLSurface::decompressDCTPatch(LLBitPack &bitpack, LLGroupHeader *gopp, BOOL
 				<< " range " << (S32)ph.range
 				<< " quant_wbits " << (S32)ph.quant_wbits
 				<< " patchids " << (S32)ph.patchids
-				<< llendl;
+				<< LL_ENDL;
             LLAppViewer::instance()->badNetworkHandler();
 			return;
 		}
@@ -955,13 +955,13 @@ LLSurfacePatch *LLSurface::resolvePatchRegion(const F32 x, const F32 y) const
 	{
 		if(0 == mNumberOfPatches)
 		{
-			llwarns << "No patches for current region!" << llendl;
+			LL_WARNS() << "No patches for current region!" << LL_ENDL;
 			return NULL;
 		}
 		S32 old_index = index;
 		index = llclamp(old_index, 0, (mNumberOfPatches - 1));
-		llwarns << "Clamping out of range patch index " << old_index
-				<< " to " << index << llendl;
+		LL_WARNS() << "Clamping out of range patch index " << old_index
+				<< " to " << index << LL_ENDL;
 	}
 	return &(mPatchList[index]);
 }
@@ -1150,12 +1150,12 @@ LLSurfacePatch *LLSurface::getPatch(const S32 x, const S32 y) const
 {
 	if ((x < 0) || (x >= mPatchesPerEdge))
 	{
-		llerrs << "Asking for patch out of bounds" << llendl;
+		LL_ERRS() << "Asking for patch out of bounds" << LL_ENDL;
 		return NULL;
 	}
 	if ((y < 0) || (y >= mPatchesPerEdge))
 	{
-		llerrs << "Asking for patch out of bounds" << llendl;
+		LL_ERRS() << "Asking for patch out of bounds" << LL_ENDL;
 		return NULL;
 	}
 
@@ -1194,7 +1194,7 @@ void LLSurface::setWaterHeight(F32 height)
 	}
 	else
 	{
-		llwarns << "LLSurface::setWaterHeight with no water object!" << llendl;
+		LL_WARNS() << "LLSurface::setWaterHeight with no water object!" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp
index af51f9c7de..55afc3e454 100755
--- a/indra/newview/llsurfacepatch.cpp
+++ b/indra/newview/llsurfacepatch.cpp
@@ -99,7 +99,7 @@ void LLSurfacePatch::dirty()
 	}
 	else
 	{
-		llwarns << "No viewer object for this surface patch!" << llendl;
+		LL_WARNS() << "No viewer object for this surface patch!" << LL_ENDL;
 	}
 
 	mDirtyZStats = TRUE;
diff --git a/indra/newview/llsyswellwindow.cpp b/indra/newview/llsyswellwindow.cpp
index e92bd766ca..5612d09f7f 100755
--- a/indra/newview/llsyswellwindow.cpp
+++ b/indra/newview/llsyswellwindow.cpp
@@ -107,8 +107,8 @@ void LLSysWellWindow::removeItemByID(const LLUUID& id)
 	}
 	else
 	{
-		llwarns << "Unable to remove notification from the list, ID: " << id
-			<< llendl;
+		LL_WARNS() << "Unable to remove notification from the list, ID: " << id
+			<< LL_ENDL;
 	}
 
 	// hide chiclet window if there are no items left
@@ -127,7 +127,7 @@ void LLSysWellWindow::initChannel()
 	mChannel = dynamic_cast<LLNotificationsUI::LLScreenChannel*>(channel);
 	if(NULL == mChannel)
 	{
-		llwarns << "LLSysWellWindow::initChannel() - could not get a requested screen channel" << llendl;
+		LL_WARNS() << "LLSysWellWindow::initChannel() - could not get a requested screen channel" << LL_ENDL;
 	}
 }
 
@@ -355,9 +355,9 @@ void LLNotificationWellWindow::addItem(LLSysWellItem::Params p)
 	}
 	else
 	{
-		llwarns << "Unable to add Notification into the list, notification ID: " << p.notification_id
+		LL_WARNS() << "Unable to add Notification into the list, notification ID: " << p.notification_id
 			<< ", title: " << p.title
-			<< llendl;
+			<< LL_ENDL;
 
 		new_item->die();
 	}
@@ -495,7 +495,7 @@ void LLIMWellWindow::addObjectRow(const LLUUID& notification_id, bool new_messag
 		ObjectRowPanel* item = new ObjectRowPanel(notification_id, new_message);
 		if (!mMessageList->addItem(item, notification_id))
 		{
-			llwarns << "Unable to add Object Row into the list, notificationID: " << notification_id << llendl;
+			LL_WARNS() << "Unable to add Object Row into the list, notificationID: " << notification_id << LL_ENDL;
 			item->die();
 		}
 		reshapeWindow();
@@ -506,7 +506,7 @@ void LLIMWellWindow::removeObjectRow(const LLUUID& notification_id)
 {
 	if (!mMessageList->removeItemByValue(notification_id))
 	{
-		llwarns << "Unable to remove Object Row from the list, notificationID: " << notification_id << llendl;
+		LL_WARNS() << "Unable to remove Object Row from the list, notificationID: " << notification_id << LL_ENDL;
 	}
 
 	reshapeWindow();
diff --git a/indra/newview/llteleporthistory.cpp b/indra/newview/llteleporthistory.cpp
index 50a088b799..a20d69dd41 100755
--- a/indra/newview/llteleporthistory.cpp
+++ b/indra/newview/llteleporthistory.cpp
@@ -77,14 +77,14 @@ void LLTeleportHistory::goToItem(int idx)
 	// Validate specified index.
 	if (idx < 0 || idx >= (int)mItems.size())
 	{
-		llwarns << "Invalid teleport history index (" << idx << ") specified" << llendl;
+		LL_WARNS() << "Invalid teleport history index (" << idx << ") specified" << LL_ENDL;
 		dump();
 		return;
 	}
 	
 	if (idx == mCurrentItem)
 	{
-		llwarns << "Will not teleport to the same location." << llendl;
+		LL_WARNS() << "Will not teleport to the same location." << LL_ENDL;
 		dump();
 		return;
 	}
@@ -156,7 +156,7 @@ void LLTeleportHistory::updateCurrentLocation(const LLVector3d& new_pos)
 		// Update current history item.
 		if (mCurrentItem < 0 || mCurrentItem >= (int) mItems.size()) // sanity check
 		{
-			llwarns << "Invalid current item. (this should not happen)" << llendl;
+			LL_WARNS() << "Invalid current item. (this should not happen)" << LL_ENDL;
 			llassert(!"Invalid current teleport history item");
 			return;
 		}
@@ -222,7 +222,7 @@ std::string LLTeleportHistory::getCurrentLocationTitle(bool full, const LLVector
 
 void LLTeleportHistory::dump() const
 {
-	llinfos << "Teleport history dump (" << mItems.size() << " items):" << llendl;
+	LL_INFOS() << "Teleport history dump (" << mItems.size() << " items):" << LL_ENDL;
 	
 	for (size_t i=0; i<mItems.size(); i++)
 	{
@@ -231,6 +231,6 @@ void LLTeleportHistory::dump() const
 		line << i << ": " << mItems[i].mTitle;
 		line << " REGION_ID: " << mItems[i].mRegionID;
 		line << ", pos: " << mItems[i].mGlobalPos;
-		llinfos << line.str() << llendl;
+		LL_INFOS() << line.str() << LL_ENDL;
 	}
 }
diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp
index af5a047da4..f88f88a4fa 100755
--- a/indra/newview/llteleporthistorystorage.cpp
+++ b/indra/newview/llteleporthistorystorage.cpp
@@ -167,7 +167,7 @@ void LLTeleportHistoryStorage::save()
 	llofstream file (resolvedFilename);
 	if (!file.is_open())
 	{
-		llwarns << "can't open teleport history file \"" << mFilename << "\" for writing" << llendl;
+		LL_WARNS() << "can't open teleport history file \"" << mFilename << "\" for writing" << LL_ENDL;
 		return;
 	}
 
@@ -189,7 +189,7 @@ void LLTeleportHistoryStorage::load()
 	llifstream file(resolved_filename);
 	if (!file.is_open())
 	{
-		llwarns << "can't load teleport history from file \"" << mFilename << "\"" << llendl;
+		LL_WARNS() << "can't load teleport history from file \"" << mFilename << "\"" << LL_ENDL;
 		return;
 	}
 
@@ -205,7 +205,7 @@ void LLTeleportHistoryStorage::load()
 		std::istringstream iss(line);
 		if (parser->parse(iss, s_item, line.length()) == LLSDParser::PARSE_FAILURE)
 		{
-			llinfos << "Parsing saved teleport history failed" << llendl;
+			LL_INFOS() << "Parsing saved teleport history failed" << LL_ENDL;
 			break;
 		}
 
@@ -221,7 +221,7 @@ void LLTeleportHistoryStorage::load()
 
 void LLTeleportHistoryStorage::dump() const
 {
-	llinfos << "Teleport history storage dump (" << mItems.size() << " items):" << llendl;
+	LL_INFOS() << "Teleport history storage dump (" << mItems.size() << " items):" << LL_ENDL;
 
 	for (size_t i=0; i<mItems.size(); i++)
 	{
@@ -230,7 +230,7 @@ void LLTeleportHistoryStorage::dump() const
 		line << " global pos: " << mItems[i].mGlobalPos;
 		line << " date: " << mItems[i].mDate;
 
-		llinfos << line.str() << llendl;
+		LL_INFOS() << line.str() << LL_ENDL;
 	}
 }
 
@@ -244,7 +244,7 @@ void LLTeleportHistoryStorage::goToItem(S32 idx)
 	// Validate specified index.
 	if (idx < 0 || idx >= (S32)mItems.size())
 	{
-		llwarns << "Invalid teleport history index (" << idx << ") specified" << llendl;
+		LL_WARNS() << "Invalid teleport history index (" << idx << ") specified" << LL_ENDL;
 		dump();
 		return;
 	}
diff --git a/indra/newview/lltextureatlas.cpp b/indra/newview/lltextureatlas.cpp
index dbbe331954..1c8e4f796e 100755
--- a/indra/newview/lltextureatlas.cpp
+++ b/indra/newview/lltextureatlas.cpp
@@ -63,7 +63,7 @@ LLTextureAtlas::~LLTextureAtlas()
 {
 	if(mSpatialGroupList.size() > 0)
 	{
-		llerrs << "Not clean up the spatial groups!" << llendl ;
+		LL_ERRS() << "Not clean up the spatial groups!" << LL_ENDL ;
 	}
 	releaseUsageBits() ;
 }
@@ -105,7 +105,7 @@ LLGLuint LLTextureAtlas::insertSubTexture(LLImageGL* source_gl_tex, S32 discard_
 	BOOL res = gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, getTexName());
 	if (!res) 
 	{
-		llerrs << "bindTexture failed" << llendl;
+		LL_ERRS() << "bindTexture failed" << LL_ENDL;
 	}
 	
 	GLint xoffset = sSlotSize * slot_col ;
@@ -342,7 +342,7 @@ BOOL LLTextureAtlas::areUsageBitsMarked(S8 bits_len, U8 mask, S16 col, S16 row)
 
 	if(ret != ret2)
 	{
-		llerrs << "bits map corrupted." << llendl ;
+		LL_ERRS() << "bits map corrupted." << LL_ENDL ;
 	}
 #endif
 	return ret ;//FALSE ;
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index ee3b605cb0..79cc66fda5 100755
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -191,7 +191,7 @@ bool LLTextureCacheLocalFileWorker::doRead()
 
 		if (mImageFormat == IMG_CODEC_INVALID)
 		{
-// 			llwarns << "Unrecognized file extension " << extension << " for local texture " << mFileName << llendl;
+// 			LL_WARNS() << "Unrecognized file extension " << extension << " for local texture " << mFileName << LL_ENDL;
 			mDataSize = 0; // no data
 			return true;
 		}
@@ -232,9 +232,9 @@ bool LLTextureCacheLocalFileWorker::doRead()
 		{
 			if (mBytesRead != mBytesToRead)
 			{
-// 				llwarns << "Error reading file from local cache: " << local_filename
+// 				LL_WARNS() << "Error reading file from local cache: " << local_filename
 // 						<< " Bytes: " << mDataSize << " Offset: " << mOffset
-// 						<< " / " << mDataSize << llendl;
+// 						<< " / " << mDataSize << LL_ENDL;
 				mDataSize = 0; // failed
 				FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
 				mReadData = NULL;
@@ -257,9 +257,9 @@ bool LLTextureCacheLocalFileWorker::doRead()
 
 	if (bytes_read != mDataSize)
 	{
-// 		llwarns << "Error reading file from local cache: " << mFileName
+// 		LL_WARNS() << "Error reading file from local cache: " << mFileName
 // 				<< " Bytes: " << mDataSize << " Offset: " << mOffset
-// 				<< " / " << mDataSize << llendl;
+// 				<< " / " << mDataSize << LL_ENDL;
 		mDataSize = 0;
 		FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
 		mReadData = NULL;
@@ -390,16 +390,16 @@ bool LLTextureCacheRemoteWorker::doRead()
 											 mReadData, mOffset, mDataSize, mCache->getLocalAPRFilePool());
 		if (bytes_read != mDataSize)
 		{
- 			llwarns << "Error reading file from local cache: " << local_filename
+ 			LL_WARNS() << "Error reading file from local cache: " << local_filename
  					<< " Bytes: " << mDataSize << " Offset: " << mOffset
- 					<< " / " << mDataSize << llendl;
+ 					<< " / " << mDataSize << LL_ENDL;
 			mDataSize = 0;
 			FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
 			mReadData = NULL;
 		}
 		else
 		{
-			//llinfos << "texture " << mID.asString() << " found in local_assets" << llendl;
+			//LL_INFOS() << "texture " << mID.asString() << " found in local_assets" << LL_ENDL;
 			mImageSize = local_size;
 			mImageLocal = TRUE;
 		}
@@ -442,9 +442,9 @@ bool LLTextureCacheRemoteWorker::doRead()
 											 mReadData, offset, size, mCache->getLocalAPRFilePool());
 		if (bytes_read != size)
 		{
-			llwarns << "LLTextureCacheWorker: "  << mID
+			LL_WARNS() << "LLTextureCacheWorker: "  << mID
 					<< " incorrect number of bytes read from header: " << bytes_read
-					<< " / " << size << llendl;
+					<< " / " << size << LL_ENDL;
 			FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
 			mReadData = NULL;
 			mDataSize = -1; // failed
@@ -511,9 +511,9 @@ bool LLTextureCacheRemoteWorker::doRead()
 											 mCache->getLocalAPRFilePool());
 			if (bytes_read != file_size)
 			{
-				llwarns << "LLTextureCacheWorker: "  << mID
+				LL_WARNS() << "LLTextureCacheWorker: "  << mID
 						<< " incorrect number of bytes read from body: " << bytes_read
-						<< " / " << file_size << llendl;
+						<< " / " << file_size << LL_ENDL;
 				FREE_MEM(LLImageBase::getPrivatePool(), mReadData);
 				mReadData = NULL;
 				mDataSize = -1; // failed
@@ -524,7 +524,7 @@ bool LLTextureCacheRemoteWorker::doRead()
 		{
 			// No body, we're done.
 			mDataSize = llmax(TEXTURE_CACHE_ENTRY_SIZE - mOffset, 0);
-			lldebugs << "No body file for: " << filename << llendl;
+			LL_DEBUGS() << "No body file for: " << filename << LL_ENDL;
 		}	
 		// Nothing else to do at that point...
 		done = true;
@@ -582,8 +582,8 @@ bool LLTextureCacheRemoteWorker::doWrite()
 
 		if (idx < 0)
 		{
-			llwarns << "LLTextureCacheWorker: "  << mID
-					<< " Unable to create header entry for writing!" << llendl;
+			LL_WARNS() << "LLTextureCacheWorker: "  << mID
+					<< " Unable to create header entry for writing!" << LL_ENDL;
 			mDataSize = -1; // failed
 			done = true;
 		}
@@ -628,8 +628,8 @@ bool LLTextureCacheRemoteWorker::doWrite()
 
 		if (bytes_written <= 0)
 		{
-			llwarns << "LLTextureCacheWorker: "  << mID
-					<< " Unable to write header entry!" << llendl;
+			LL_WARNS() << "LLTextureCacheWorker: "  << mID
+					<< " Unable to write header entry!" << LL_ENDL;
 			mDataSize = -1; // failed
 			done = true;
 		}
@@ -655,16 +655,16 @@ bool LLTextureCacheRemoteWorker::doWrite()
 		{
 			// build the cache file name from the UUID
 			std::string filename = mCache->getTextureFileName(mID);			
-// 			llinfos << "Writing Body: " << filename << " Bytes: " << file_offset+file_size << llendl;
+// 			LL_INFOS() << "Writing Body: " << filename << " Bytes: " << file_offset+file_size << LL_ENDL;
 			S32 bytes_written = LLAPRFile::writeEx(	filename, 
 													mWriteData + TEXTURE_CACHE_ENTRY_SIZE,
 													0, file_size,
 													mCache->getLocalAPRFilePool());
 			if (bytes_written <= 0)
 			{
-				llwarns << "LLTextureCacheWorker: "  << mID
+				LL_WARNS() << "LLTextureCacheWorker: "  << mID
 						<< " incorrect number of bytes written to body: " << bytes_written
-						<< " / " << file_size << llendl;
+						<< " / " << file_size << LL_ENDL;
 				mDataSize = -1; // failed
 				done = true;
 			}
@@ -1135,7 +1135,7 @@ S32 LLTextureCache::openAndReadEntry(const LLUUID& id, Entry& entry, bool create
 		}
 		if(entry.mImageSize <= entry.mBodySize)//it happens on 64-bit systems, do not know why
 		{
-			llwarns << "corrupted entry: " << id << " entry image size: " << entry.mImageSize << " entry body size: " << entry.mBodySize << llendl ;
+			LL_WARNS() << "corrupted entry: " << id << " entry image size: " << entry.mImageSize << " entry body size: " << entry.mBodySize << LL_ENDL ;
 
 			//erase this entry and the cached texture from the cache.
 			std::string tex_filename = getTextureFileName(id);
@@ -1303,13 +1303,13 @@ U32 LLTextureCache::openAndReadEntries(std::vector<Entry>& entries)
 		S32 bytes_read = aprfile->read((void*)(&entry), (S32)sizeof(Entry));
 		if (bytes_read < sizeof(Entry))
 		{
-			llwarns << "Corrupted header entries, failed at " << idx << " / " << num_entries << llendl;
+			LL_WARNS() << "Corrupted header entries, failed at " << idx << " / " << num_entries << LL_ENDL;
 			closeHeaderEntriesFile();
 			purgeAllTextures(false);
 			return 0;
 		}
 		entries.push_back(entry);
-// 		llinfos << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << llendl;
+// 		LL_INFOS() << "ENTRY: " << entry.mTime << " TEX: " << entry.mID << " IDX: " << idx << " Size: " << entry.mImageSize << LL_ENDL;
 		if(entry.mImageSize > entry.mBodySize)
 		{
 			mHeaderIDMap[entry.mID] = idx;
@@ -1439,7 +1439,7 @@ void LLTextureCache::readHeaderCache()
 						if (entry.mBodySize > entry.mImageSize)
 						{
 							// Shouldn't happen, failsafe only
-							llwarns << "Bad entry: " << i << ": " << entry.mID << ": BodySize: " << entry.mBodySize << llendl;
+							LL_WARNS() << "Bad entry: " << i << ": " << entry.mID << ": BodySize: " << entry.mBodySize << LL_ENDL;
 							purge_list.insert(i);
 						}
 					}
@@ -1450,7 +1450,7 @@ void LLTextureCache::readHeaderCache()
 				// Special case: cache size was reduced, need to remove entries
 				// Note: After we prune entries, we will call this again and create the LRU
 				U32 entries_to_purge = (num_entries - empty_entries) - sCacheMaxEntries;
-				llinfos << "Texture Cache Entries: " << num_entries << " Max: " << sCacheMaxEntries << " Empty: " << empty_entries << " Purging: " << entries_to_purge << llendl;
+				LL_INFOS() << "Texture Cache Entries: " << num_entries << " Max: " << sCacheMaxEntries << " Empty: " << empty_entries << " Purging: " << entries_to_purge << LL_ENDL;
 				// We can exit the following loop with the given condition, since if we'd reach the end of the lru set we'd have:
 				// purge_list.size() = lru.size() = num_entries - empty_entries = entries_to_purge + sCacheMaxEntries >= entries_to_purge
 				// So, it's certain that iter will never reach lru.end() first.
@@ -1467,7 +1467,7 @@ void LLTextureCache::readHeaderCache()
 				for (std::set<lru_data_t>::iterator iter = lru.begin(); iter != lru.end(); ++iter)
 				{
 					mLRU.insert(entries[iter->second].mID);
-// 					llinfos << "LRU: " << iter->first << " : " << iter->second << llendl;
+// 					LL_INFOS() << "LRU: " << iter->first << " : " << iter->second << LL_ENDL;
 					if (--lru_entries <= 0)
 						break;
 				}
@@ -1513,7 +1513,7 @@ void LLTextureCache::readHeaderCache()
 //the header mutex is locked before calling this.
 void LLTextureCache::clearCorruptedCache()
 {
-	llwarns << "the texture cache is corrupted, need to be cleared." << llendl ;
+	LL_WARNS() << "the texture cache is corrupted, need to be cleared." << LL_ENDL ;
 
 	closeHeaderEntriesFile();//close possible file handler
 	purgeAllTextures(false) ; //clear the cache.
@@ -1543,7 +1543,7 @@ void LLTextureCache::purgeAllTextures(bool purge_directories)
 		for (S32 i=0; i<16; i++)
 		{
 			std::string dirname = mTexturesDirName + delem + subdirs[i];
-			llinfos << "Deleting files in directory: " << dirname << llendl;
+			LL_INFOS() << "Deleting files in directory: " << dirname << LL_ENDL;
 			gDirUtilp->deleteFilesInDir(dirname, mask);
 			if (purge_directories)
 			{
@@ -1568,7 +1568,7 @@ void LLTextureCache::purgeAllTextures(bool purge_directories)
 	mHeaderEntriesInfo.mEntries = 0;
 	writeEntriesHeader();
 
-	llinfos << "The entire texture cache is cleared." << llendl ;
+	LL_INFOS() << "The entire texture cache is cleared." << LL_ENDL ;
 }
 
 void LLTextureCache::purgeTextures(bool validate)
@@ -1586,7 +1586,7 @@ void LLTextureCache::purgeTextures(bool validate)
 	
 	LLMutexLock lock(&mHeaderMutex);
 
-	llinfos << "TEXTURE CACHE: Purging." << llendl;
+	LL_INFOS() << "TEXTURE CACHE: Purging." << LL_ENDL;
 
 	// Read the entries list
 	std::vector<Entry> entries;
@@ -1609,11 +1609,11 @@ void LLTextureCache::purgeTextures(bool validate)
 			{
 				S32 idx = iter2->second;
 				time_idx_set.insert(std::make_pair(entries[idx].mTime, idx));
-// 				llinfos << "TIME: " << entries[idx].mTime << " TEX: " << entries[idx].mID << " IDX: " << idx << " Size: " << entries[idx].mImageSize << llendl;
+// 				LL_INFOS() << "TIME: " << entries[idx].mTime << " TEX: " << entries[idx].mID << " IDX: " << idx << " Size: " << entries[idx].mImageSize << LL_ENDL;
 			}
 			else
 			{
-				llerrs << "mTexturesSizeMap / mHeaderIDMap corrupted." << llendl ;
+				LL_ERRS() << "mTexturesSizeMap / mHeaderIDMap corrupted." << LL_ENDL ;
 			}
 		}
 	}
@@ -1682,7 +1682,7 @@ void LLTextureCache::purgeTextures(bool validate)
 			<< " PURGED: " << purge_count
 			<< " ENTRIES: " << num_entries
 			<< " CACHE SIZE: " << mTexturesSizeTotal / (1024 * 1024) << " MB"
-			<< llendl;
+			<< LL_ENDL;
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -1900,7 +1900,7 @@ bool LLTextureCache::writeToFastCache(S32 id, LLPointer<LLImageRaw> raw, S32 dis
 	//rescale image if needed
 	if (raw.isNull() || !raw->getData())
 	{
-		llerrs << "Attempted to write NULL raw image to fastcache" << llendl;
+		LL_ERRS() << "Attempted to write NULL raw image to fastcache" << LL_ENDL;
 		return false;
 	}
 
@@ -2091,7 +2091,7 @@ void LLTextureCache::removeEntry(S32 idx, Entry& entry, std::string& filename)
 
 bool LLTextureCache::removeFromCache(const LLUUID& id)
 {
-	//llwarns << "Removing texture from cache: " << id << llendl;
+	//LL_WARNS() << "Removing texture from cache: " << id << LL_ENDL;
 	bool ret = false ;
 	if (!mReadOnly)
 	{
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index c09fe180f1..23ac67c313 100755
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -354,7 +354,7 @@ BOOL LLFloaterTexturePicker::handleDragAndDrop(
 	}
 
 	handled = TRUE;
-	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLFloaterTexturePicker " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLFloaterTexturePicker " << getName() << LL_ENDL;
 
 	return handled;
 }
@@ -1333,9 +1333,9 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id)
 			else
 			{
 			mImageItemID = floaterp->findItemID(floaterp->getAssetID(), FALSE);
-			lldebugs << "mImageItemID: " << mImageItemID << llendl;
+			LL_DEBUGS() << "mImageItemID: " << mImageItemID << LL_ENDL;
 			mImageAssetID = floaterp->getAssetID();
-			lldebugs << "mImageAssetID: " << mImageAssetID << llendl;
+			LL_DEBUGS() << "mImageAssetID: " << mImageAssetID << LL_ENDL;
 			}
 
 			if (op == TEXTURE_SELECT && mOnSelectCallback)
@@ -1436,7 +1436,7 @@ BOOL LLTextureCtrl::handleDragAndDrop(S32 x, S32 y, MASK mask,
 	}
 
 	handled = TRUE;
-	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLTextureCtrl " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLTextureCtrl " << getName() << LL_ENDL;
 
 	return handled;
 }
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index d85247c4ec..17703fcc21 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -900,7 +900,7 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
 	
 	calcWorkPriority();
 	mType = host.isOk() ? LLImageBase::TYPE_AVATAR_BAKE : LLImageBase::TYPE_NORMAL;
-// 	llinfos << "Create: " << mID << " mHost:" << host << " Discard=" << discard << llendl;
+// 	LL_INFOS() << "Create: " << mID << " mHost:" << host << " Discard=" << discard << LL_ENDL;
 	if (!mFetcher->mDebugPause)
 	{
 		U32 work_priority = mWorkPriority | LLWorkerThread::PRIORITY_HIGH;
@@ -911,10 +911,10 @@ LLTextureFetchWorker::LLTextureFetchWorker(LLTextureFetch* fetcher,
 
 LLTextureFetchWorker::~LLTextureFetchWorker()
 {
-// 	llinfos << "Destroy: " << mID
+// 	LL_INFOS() << "Destroy: " << mID
 // 			<< " Decoded=" << mDecodedDiscard
 // 			<< " Requested=" << mRequestedDiscard
-// 			<< " Desired=" << mDesiredDiscard << llendl;
+// 			<< " Desired=" << mDesiredDiscard << LL_ENDL;
 	llassert_always(!haveWork());
 
 	lockWorkMutex();													// +Mw (should be useless)
@@ -975,7 +975,7 @@ void LLTextureFetchWorker::setupPacketData()
 		mFirstPacket = (data_size - FIRST_PACKET_SIZE) / MAX_IMG_PACKET_SIZE + 1;
 		if (FIRST_PACKET_SIZE + (mFirstPacket-1) * MAX_IMG_PACKET_SIZE != data_size)
 		{
-			llwarns << "Bad CACHED TEXTURE size: " << data_size << " removing." << llendl;
+			LL_WARNS() << "Bad CACHED TEXTURE size: " << data_size << " removing." << LL_ENDL;
 			removeFromCache();
 			resetFormattedData();
 			clearPackets();
@@ -1098,14 +1098,14 @@ bool LLTextureFetchWorker::doWork(S32 param)
 	{
 		if (mState == INIT || mState == LOAD_FROM_NETWORK || mState == LOAD_FROM_SIMULATOR)
 		{
-			LL_DEBUGS("Texture") << mID << " abort: mImagePriority < F_ALMOST_ZERO" << llendl;
+			LL_DEBUGS("Texture") << mID << " abort: mImagePriority < F_ALMOST_ZERO" << LL_ENDL;
 			return true; // abort
 		}
 	}
 	if(mState > CACHE_POST && !mCanUseNET && !mCanUseHTTP)
 	{
 		//nowhere to get data, abort.
-		LL_WARNS("Texture") << mID << " abort, nowhere to get data" << llendl;
+		LL_WARNS("Texture") << mID << " abort, nowhere to get data" << LL_ENDL;
 		return true ;
 	}
 
@@ -1221,7 +1221,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				//
 				//This should never happen
 				//
-				LL_DEBUGS("Texture") << mID << " this should never happen" << llendl;
+				LL_DEBUGS("Texture") << mID << " this should never happen" << LL_ENDL;
 				return false;
 			}
 		}
@@ -1243,7 +1243,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			if (mLoadedDiscard < 0)
 			{
 				LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
-									<< ", should be >=0" << llendl;
+									<< ", should be >=0" << LL_ENDL;
 			}
 			setState(DECODE_IMAGE);
 			mInCache = TRUE;
@@ -1302,7 +1302,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			else
 			{
 				// This will happen if not logged in or if a region deoes not have HTTP Texture enabled
-				//llwarns << "Region not found for host: " << mHost << llendl;
+				//LL_WARNS() << "Region not found for host: " << mHost << LL_ENDL;
 				mCanUseHTTP = false;
 			}
 		}
@@ -1345,7 +1345,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			//recordTextureStart(false);
 			//setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority);
 
-			LL_DEBUGS("Texture") << mID << " does this happen?" << llendl;
+			LL_DEBUGS("Texture") << mID << " does this happen?" << LL_ENDL;
 			return false;
 		}
 	}
@@ -1363,15 +1363,15 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			if (mFormattedImage.isNull() || !mFormattedImage->getDataSize())
 			{
 				// processSimulatorPackets() failed
-// 				llwarns << "processSimulatorPackets() failed to load buffer" << llendl;
-				LL_WARNS("Texture") << mID << " processSimulatorPackets() failed to load buffer" << llendl;
+// 				LL_WARNS() << "processSimulatorPackets() failed to load buffer" << LL_ENDL;
+				LL_WARNS("Texture") << mID << " processSimulatorPackets() failed to load buffer" << LL_ENDL;
 				return true; // failed
 			}
 			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
 			if (mLoadedDiscard < 0)
 			{
 				LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
-									<< ", should be >=0" << llendl;
+									<< ", should be >=0" << LL_ENDL;
 			}
 			setState(DECODE_IMAGE);
 			mWriteToCacheState = SHOULD_WRITE;
@@ -1421,7 +1421,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 		if (! mCanUseHTTP)
 		{
 			releaseHttpSemaphore();
-			LL_WARNS("Texture") << mID << " abort: SEND_HTTP_REQ but !mCanUseHTTP" << llendl;
+			LL_WARNS("Texture") << mID << " abort: SEND_HTTP_REQ but !mCanUseHTTP" << LL_ENDL;
 			return true; // abort
 		}
 
@@ -1441,7 +1441,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 					if (mLoadedDiscard < 0)
 					{
 						LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
-											<< ", should be >=0" << llendl;
+											<< ", should be >=0" << LL_ENDL;
 					}
 					setState(DECODE_IMAGE);
 					releaseHttpSemaphore();
@@ -1450,7 +1450,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				else
 				{
 					releaseHttpSemaphore();
-					LL_WARNS("Texture") << mID << " SEND_HTTP_REQ abort: cur_size " << cur_size << " <=0" << llendl;
+					LL_WARNS("Texture") << mID << " SEND_HTTP_REQ abort: cur_size " << cur_size << " <=0" << LL_ENDL;
 					return true; // abort.
 				}
 			}
@@ -1498,7 +1498,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 		}
 		if (LLCORE_HTTP_HANDLE_INVALID == mHttpHandle)
 		{
-			llwarns << "HTTP GET request failed for " << mID << llendl;
+			LL_WARNS() << "HTTP GET request failed for " << mID << LL_ENDL;
 			resetFormattedData();
 			releaseHttpSemaphore();
 			return true; // failed
@@ -1528,11 +1528,11 @@ bool LLTextureFetchWorker::doWork(S32 param)
 					{
 						setState(DONE);
 						releaseHttpSemaphore();
-						LL_DEBUGS("Texture") << mID << " abort: WAIT_HTTP_REQ not found" << llendl;
+						LL_DEBUGS("Texture") << mID << " abort: WAIT_HTTP_REQ not found" << LL_ENDL;
 						return true; // failed, means no map tile on the empty region.
 					}
 
-					llwarns << "Texture missing from server (404): " << mUrl << llendl;
+					LL_WARNS() << "Texture missing from server (404): " << mUrl << LL_ENDL;
 
 					// roll back to try UDP
 					if (mCanUseNET)
@@ -1556,10 +1556,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				}
 				else
 				{
-					llinfos << "HTTP GET failed for: " << mUrl
+					LL_INFOS() << "HTTP GET failed for: " << mUrl
 							<< " Status: " << mGetStatus.toHex()
 							<< " Reason: '" << mGetReason << "'"
-							<< llendl;
+							<< LL_ENDL;
 				}
 
 				mUrl.clear();
@@ -1571,7 +1571,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 					if (mLoadedDiscard < 0)
 					{
 						LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
-											<< ", should be >=0" << llendl;
+											<< ", should be >=0" << LL_ENDL;
 					}
 					setState(DECODE_IMAGE);
 					releaseHttpSemaphore();
@@ -1582,7 +1582,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				resetFormattedData();
 				setState(DONE);
 				releaseHttpSemaphore();
-				LL_WARNS("Texture") << mID << " abort: fail harder" << llendl;
+				LL_WARNS("Texture") << mID << " abort: fail harder" << LL_ENDL;
 				return true; // failed
 			}
 			
@@ -1606,7 +1606,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 
 				// abort.
 				setState(DONE);
-				LL_WARNS("Texture") << mID << " abort: no data received" << llendl;
+				LL_WARNS("Texture") << mID << " abort: no data received" << LL_ENDL;
 				releaseHttpSemaphore();
 				return true;
 			}
@@ -1675,7 +1675,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			if (mLoadedDiscard < 0)
 			{
 				LL_WARNS("Texture") << mID << " mLoadedDiscard is " << mLoadedDiscard
-									<< ", should be >=0" << llendl;
+									<< ", should be >=0" << LL_ENDL;
 			}
 			setState(DECODE_IMAGE);
 			if (mWriteToCacheState != NOT_WRITE)
@@ -1716,26 +1716,26 @@ bool LLTextureFetchWorker::doWork(S32 param)
 		{
 			// We aborted, don't decode
 			setState(DONE);
-			LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: desired discard " << mDesiredDiscard << "<0" << llendl;
+			LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: desired discard " << mDesiredDiscard << "<0" << LL_ENDL;
 			return true;
 		}
 		
 		if (mFormattedImage->getDataSize() <= 0)
 		{
-			llwarns << "Decode entered with invalid mFormattedImage. ID = " << mID << llendl;
+			LL_WARNS() << "Decode entered with invalid mFormattedImage. ID = " << mID << LL_ENDL;
 			
 			//abort, don't decode
 			setState(DONE);
-			LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: (mFormattedImage->getDataSize() <= 0)" << llendl;
+			LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: (mFormattedImage->getDataSize() <= 0)" << LL_ENDL;
 			return true;
 		}
 		if (mLoadedDiscard < 0)
 		{
-			llwarns << "Decode entered with invalid mLoadedDiscard. ID = " << mID << llendl;
+			LL_WARNS() << "Decode entered with invalid mLoadedDiscard. ID = " << mID << LL_ENDL;
 
 			//abort, don't decode
 			setState(DONE);
-			LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: mLoadedDiscard < 0" << llendl;
+			LL_DEBUGS("Texture") << mID << " DECODE_IMAGE abort: mLoadedDiscard < 0" << LL_ENDL;
 			return true;
 		}
 
@@ -1768,7 +1768,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				if (mCachedSize > 0 && !mInLocalCache && mRetryAttempt == 0)
 				{
 					// Cache file should be deleted, try again
-// 					llwarns << mID << ": Decode of cached file failed (removed), retrying" << llendl;
+// 					LL_WARNS() << mID << ": Decode of cached file failed (removed), retrying" << LL_ENDL;
 					llassert_always(mDecodeHandle == 0);
 					mFormattedImage = NULL;
 					++mRetryAttempt;
@@ -1778,7 +1778,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 				}
 				else
 				{
-// 					llwarns << "UNABLE TO LOAD TEXTURE: " << mID << " RETRIES: " << mRetryAttempt << llendl;
+// 					LL_WARNS() << "UNABLE TO LOAD TEXTURE: " << mID << " RETRIES: " << mRetryAttempt << LL_ENDL;
 					setState(DONE); // failed
 				}
 			}
@@ -1860,7 +1860,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
 			setState(INIT);
 			LL_DEBUGS("Texture") << mID << " more data requested, returning to INIT: " 
 								 << " mDecodedDiscard " << mDecodedDiscard << ">= 0 && mDesiredDiscard " << mDesiredDiscard
-								 << "<" << " mDecodedDiscard " << mDecodedDiscard << llendl;
+								 << "<" << " mDecodedDiscard " << mDecodedDiscard << LL_ENDL;
 			setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
 			return false;
 		}
@@ -1903,22 +1903,22 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe
 	LL_DEBUGS("Texture") << "HTTP COMPLETE: " << mID
 						 << " status: " << status.toHex()
 						 << " '" << status.toString() << "'"
-						 << llendl;
+						 << LL_ENDL;
 //	unsigned int offset(0), length(0), full_length(0);
 //	response->getRange(&offset, &length, &full_length);
-// 	llwarns << "HTTP COMPLETE: " << mID << " handle: " << handle
+// 	LL_WARNS() << "HTTP COMPLETE: " << mID << " handle: " << handle
 // 			<< " status: " << status.toULong() << " '" << status.toString() << "'"
 // 			<< " req offset: " << mRequestedOffset << " req length: " << mRequestedSize
 // 			<< " offset: " << offset << " length: " << length
-// 			<< llendl;
+// 			<< LL_ENDL;
 
 	if (! status)
 	{
 		success = false;
 		std::string reason(status.toString());
 		setGetStatus(status, reason);
-		llwarns << "CURL GET FAILED, status: " << status.toHex()
-				<< " reason: " << reason << llendl;
+		LL_WARNS() << "CURL GET FAILED, status: " << status.toHex()
+				<< " reason: " << reason << LL_ENDL;
 	}
 	else
 	{
@@ -2128,13 +2128,13 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
 
 	if (mState != WAIT_HTTP_REQ)
 	{
-		llwarns << "callbackHttpGet for unrequested fetch worker: " << mID
-				<< " req=" << mSentRequest << " state= " << mState << llendl;
+		LL_WARNS() << "callbackHttpGet for unrequested fetch worker: " << mID
+				<< " req=" << mSentRequest << " state= " << mState << LL_ENDL;
 		return data_size;
 	}
 	if (mLoaded)
 	{
-		llwarns << "Duplicate callback for " << mID.asString() << llendl;
+		LL_WARNS() << "Duplicate callback for " << mID.asString() << LL_ENDL;
 		return data_size ; // ignore duplicate callback
 	}
 	if (success)
@@ -2199,7 +2199,7 @@ S32 LLTextureFetchWorker::callbackHttpGet(LLCore::HttpResponse * response,
 			else if (data_size > mRequestedSize)
 			{
 				// *TODO: This shouldn't be happening any more  (REALLY don't expect this anymore)
-				llwarns << "data_size = " << data_size << " > requested: " << mRequestedSize << llendl;
+				LL_WARNS() << "data_size = " << data_size << " > requested: " << mRequestedSize << LL_ENDL;
 				mHaveAllData = TRUE;
 				llassert_always(mDecodeHandle == 0);
 				mFormattedImage = NULL; // discard any previous data we had
@@ -2234,7 +2234,7 @@ void LLTextureFetchWorker::callbackCacheRead(bool success, LLImageFormatted* ima
 	LLMutexLock lock(&mWorkMutex);										// +Mw
 	if (mState != LOAD_FROM_TEXTURE_CACHE)
 	{
-// 		llwarns << "Read callback for " << mID << " with state = " << mState << llendl;
+// 		LL_WARNS() << "Read callback for " << mID << " with state = " << mState << LL_ENDL;
 		return;
 	}
 	if (success)
@@ -2259,7 +2259,7 @@ void LLTextureFetchWorker::callbackCacheWrite(bool success)
 	LLMutexLock lock(&mWorkMutex);										// +Mw
 	if (mState != WAIT_ON_WRITE)
 	{
-// 		llwarns << "Write callback for " << mID << " with state = " << mState << llendl;
+// 		LL_WARNS() << "Write callback for " << mID << " with state = " << mState << LL_ENDL;
 		return;
 	}
 	mWritten = TRUE;
@@ -2278,7 +2278,7 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag
 	}
 	if (mState != DECODE_IMAGE_UPDATE)
 	{
-// 		llwarns << "Decode callback for " << mID << " with state = " << mState << llendl;
+// 		LL_WARNS() << "Decode callback for " << mID << " with state = " << mState << LL_ENDL;
 		mDecodeHandle = 0;
 		return;
 	}
@@ -2296,12 +2296,12 @@ void LLTextureFetchWorker::callbackDecoded(bool success, LLImageRaw* raw, LLImag
 	}
 	else
 	{
-		llwarns << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << llendl;
+		LL_WARNS() << "DECODE FAILED: " << mID << " Discard: " << (S32)mFormattedImage->getDiscardLevel() << LL_ENDL;
 		removeFromCache();
 		mDecodedDiscard = -1; // Redundant, here for clarity and paranoia
 	}
 	mDecoded = TRUE;
-// 	llinfos << mID << " : DECODE COMPLETE " << llendl;
+// 	LL_INFOS() << mID << " : DECODE COMPLETE " << LL_ENDL;
 	setPriority(LLWorkerThread::PRIORITY_HIGH | mWorkPriority);
 	mCacheReadTime = mCacheReadTimer.getElapsedTimeF32();
 }																		// -Mw
@@ -2479,8 +2479,8 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
 	{
 		if (worker->mHost != host)
 		{
-			llwarns << "LLTextureFetch::createRequest " << id << " called with multiple hosts: "
-					<< host << " != " << worker->mHost << llendl;
+			LL_WARNS() << "LLTextureFetch::createRequest " << id << " called with multiple hosts: "
+					<< host << " != " << worker->mHost << LL_ENDL;
 			removeRequest(worker, true);
 			worker = NULL;
 			return false;
@@ -2491,7 +2491,7 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
 	std::string exten = gDirUtilp->getExtension(url);
 	if (!url.empty() && (!exten.empty() && LLImageBase::getCodecFromExtension(exten) != IMG_CODEC_J2C))
 	{
-		LL_DEBUGS("Texture") << "full request for " << id << " exten is not J2C: " << exten << llendl;
+		LL_DEBUGS("Texture") << "full request for " << id << " exten is not J2C: " << exten << LL_ENDL;
 		// Only do partial requests for J2C at the moment
 		desired_size = MAX_IMAGE_DATA_SIZE;
 		desired_discard = 0;
@@ -2558,7 +2558,7 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
 		worker->unlockWorkMutex();										// -Mw
 	}
 	
- 	LL_DEBUGS("Texture") << "REQUESTED: " << id << " Discard: " << desired_discard << " size " << desired_size << llendl;
+ 	LL_DEBUGS("Texture") << "REQUESTED: " << id << " Discard: " << desired_discard << " size " << desired_size << LL_ENDL;
 	return true;
 }
 
@@ -2752,7 +2752,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
 			// Should only happen if we set mDebugPause...
 			if (!mDebugPause)
 			{
-// 				llwarns << "Adding work for inactive worker: " << id << llendl;
+// 				LL_WARNS() << "Adding work for inactive worker: " << id << LL_ENDL;
 				worker->addWork(0, LLWorkerThread::PRIORITY_HIGH | worker->mWorkPriority);
 			}
 		}
@@ -2988,7 +2988,7 @@ void LLTextureFetch::threadedUpdate()
 		S32 q = mCurlGetRequest->getQueued();
 		if (q > 0)
 		{
-			llinfos << "Queued gets: " << q << llendl;
+			LL_INFOS() << "Queued gets: " << q << LL_ENDL;
 			info_timer.reset();
 		}
 	}
@@ -3037,7 +3037,7 @@ void LLTextureFetch::sendRequestListToSimulators()
 				(req->mState != LLTextureFetchWorker::LOAD_FROM_SIMULATOR))
 			{
 				// We already received our URL, remove from the queue
-				llwarns << "Worker: " << req->mID << " in mNetworkQueue but in wrong state: " << req->mState << llendl;
+				LL_WARNS() << "Worker: " << req->mID << " in mNetworkQueue but in wrong state: " << req->mState << LL_ENDL;
 				mNetworkQueue.erase(curiter);
 				continue;
 			}
@@ -3105,8 +3105,8 @@ void LLTextureFetch::sendRequestListToSimulators()
 				gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, req->mImagePriority);
 				gMessageSystem->addU32Fast(_PREHASH_Packet, packet);
 				gMessageSystem->addU8Fast(_PREHASH_Type, req->mType);
-// 				llinfos << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
-// 						<< " Packet: " << packet << " Priority: " << req->mImagePriority << llendl;
+// 				LL_INFOS() << "IMAGE REQUEST: " << req->mID << " Discard: " << req->mDesiredDiscard
+// 						<< " Packet: " << packet << " Priority: " << req->mImagePriority << LL_ENDL;
 
 				static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
 				static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
@@ -3127,7 +3127,7 @@ void LLTextureFetch::sendRequestListToSimulators()
 				sim_request_count++;
 				if (sim_request_count >= IMAGES_PER_REQUEST)
 				{
-// 					llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
+// 					LL_INFOS() << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << LL_ENDL;
 
 					gMessageSystem->sendSemiReliable(host, NULL, NULL);
 					sim_request_count = 0;
@@ -3136,7 +3136,7 @@ void LLTextureFetch::sendRequestListToSimulators()
 		}
 		if (gMessageSystem && sim_request_count > 0 && sim_request_count < IMAGES_PER_REQUEST)
 		{
-// 			llinfos << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << llendl;
+// 			LL_INFOS() << "REQUESTING " << sim_request_count << " IMAGES FROM HOST: " << host.getIPString() << LL_ENDL;
 			gMessageSystem->sendSemiReliable(host, NULL, NULL);
 			sim_request_count = 0;
 		}
@@ -3172,7 +3172,7 @@ void LLTextureFetch::sendRequestListToSimulators()
 					gMessageSystem->addF32Fast(_PREHASH_DownloadPriority, 0);
 					gMessageSystem->addU32Fast(_PREHASH_Packet, 0);
 					gMessageSystem->addU8Fast(_PREHASH_Type, 0);
-// 				llinfos << "CANCELING IMAGE REQUEST: " << (*iter2) << llendl;
+// 				LL_INFOS() << "CANCELING IMAGE REQUEST: " << (*iter2) << LL_ENDL;
 
 					request_count++;
 					if (request_count >= IMAGES_PER_REQUEST)
@@ -3200,12 +3200,12 @@ bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size)
 	mRequestedTimer.reset();
 	if (index >= mTotalPackets)
 	{
-// 		llwarns << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << llendl;
+// 		LL_WARNS() << "Received Image Packet " << index << " > max: " << mTotalPackets << " for image: " << mID << LL_ENDL;
 		return false;
 	}
 	if (index > 0 && index < mTotalPackets-1 && size != MAX_IMG_PACKET_SIZE)
 	{
-// 		llwarns << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << llendl;
+// 		LL_WARNS() << "Received bad sized packet: " << index << ", " << size << " != " << MAX_IMG_PACKET_SIZE << " for image: " << mID << LL_ENDL;
 		return false;
 	}
 	
@@ -3215,7 +3215,7 @@ bool LLTextureFetchWorker::insertPacket(S32 index, U8* data, S32 size)
 	}
 	else if (mPackets[index] != NULL)
 	{
-// 		llwarns << "Received duplicate packet: " << index << " for image: " << mID << llendl;
+// 		LL_WARNS() << "Received duplicate packet: " << index << " for image: " << mID << LL_ENDL;
 		return false;
 	}
 
@@ -3247,7 +3247,7 @@ void LLTextureFetchWorker::setState(e_state new_state)
 		"WAIT_ON_WRITE",
 		"DONE"
 	};
-	LL_DEBUGS("Texture") << "id: " << mID << " FTType: " << mFTType << " disc: " << mDesiredDiscard << " sz: " << mDesiredSize << " state: " << e_state_name[mState] << " => " << e_state_name[new_state] << llendl;
+	LL_DEBUGS("Texture") << "id: " << mID << " FTType: " << mFTType << " disc: " << mDesiredDiscard << " sz: " << mDesiredSize << " state: " << e_state_name[mState] << " => " << e_state_name[new_state] << LL_ENDL;
 	mState = new_state;
 }
 
@@ -3262,26 +3262,26 @@ bool LLTextureFetch::receiveImageHeader(const LLHost& host, const LLUUID& id, U8
 	
 	if (!worker)
 	{
-// 		llwarns << "Received header for non active worker: " << id << llendl;
+// 		LL_WARNS() << "Received header for non active worker: " << id << LL_ENDL;
 		res = false;
 	}
 	else if (worker->mState != LLTextureFetchWorker::LOAD_FROM_NETWORK ||
 			 worker->mSentRequest != LLTextureFetchWorker::SENT_SIM)
 	{
-// 		llwarns << "receiveImageHeader for worker: " << id
+// 		LL_WARNS() << "receiveImageHeader for worker: " << id
 // 				<< " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState]
-// 				<< " sent: " << worker->mSentRequest << llendl;
+// 				<< " sent: " << worker->mSentRequest << LL_ENDL;
 		res = false;
 	}
 	else if (worker->mLastPacket != -1)
 	{
 		// check to see if we've gotten this packet before
-// 		llwarns << "Received duplicate header for: " << id << llendl;
+// 		LL_WARNS() << "Received duplicate header for: " << id << LL_ENDL;
 		res = false;
 	}
 	else if (!data_size)
 	{
-// 		llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
+// 		LL_WARNS() << "Img: " << id << ":" << " Empty Image Header" << LL_ENDL;
 		res = false;
 	}
 	if (!res)
@@ -3323,17 +3323,17 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
 	
 	if (!worker)
 	{
-// 		llwarns << "Received packet " << packet_num << " for non active worker: " << id << llendl;
+// 		LL_WARNS() << "Received packet " << packet_num << " for non active worker: " << id << LL_ENDL;
 		res = false;
 	}
 	else if (worker->mLastPacket == -1)
 	{
-// 		llwarns << "Received packet " << packet_num << " before header for: " << id << llendl;
+// 		LL_WARNS() << "Received packet " << packet_num << " before header for: " << id << LL_ENDL;
 		res = false;
 	}
 	else if (!data_size)
 	{
-// 		llwarns << "Img: " << id << ":" << " Empty Image Header" << llendl;
+// 		LL_WARNS() << "Img: " << id << ":" << " Empty Image Header" << LL_ENDL;
 		res = false;
 	}
 	if (!res)
@@ -3361,8 +3361,8 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
 	}
 	else
 	{
-// 		llwarns << "receiveImagePacket " << packet_num << "/" << worker->mLastPacket << " for worker: " << id
-// 				<< " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] << llendl;
+// 		LL_WARNS() << "receiveImagePacket " << packet_num << "/" << worker->mLastPacket << " for worker: " << id
+// 				<< " in state: " << LLTextureFetchWorker::sStateDescs[worker->mState] << LL_ENDL;
 		removeFromNetworkQueue(worker, true); // failsafe
 	}
 
@@ -3454,33 +3454,33 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r
 
 void LLTextureFetch::dump()
 {
-	llinfos << "LLTextureFetch REQUESTS:" << llendl;
+	LL_INFOS() << "LLTextureFetch REQUESTS:" << LL_ENDL;
 	for (request_queue_t::iterator iter = mRequestQueue.begin();
 		 iter != mRequestQueue.end(); ++iter)
 	{
 		LLQueuedThread::QueuedRequest* qreq = *iter;
 		LLWorkerThread::WorkRequest* wreq = (LLWorkerThread::WorkRequest*)qreq;
 		LLTextureFetchWorker* worker = (LLTextureFetchWorker*)wreq->getWorkerClass();
-		llinfos << " ID: " << worker->mID
+		LL_INFOS() << " ID: " << worker->mID
 				<< " PRI: " << llformat("0x%08x",wreq->getPriority())
 				<< " STATE: " << worker->sStateDescs[worker->mState]
-				<< llendl;
+				<< LL_ENDL;
 	}
 
-	llinfos << "LLTextureFetch ACTIVE_HTTP:" << llendl;
+	LL_INFOS() << "LLTextureFetch ACTIVE_HTTP:" << LL_ENDL;
 	for (queue_t::const_iterator iter(mHTTPTextureQueue.begin());
 		 mHTTPTextureQueue.end() != iter;
 		 ++iter)
 	{
-		llinfos << " ID: " << (*iter) << llendl;
+		LL_INFOS() << " ID: " << (*iter) << LL_ENDL;
 	}
 
-	llinfos << "LLTextureFetch WAIT_HTTP_RESOURCE:" << llendl;
+	LL_INFOS() << "LLTextureFetch WAIT_HTTP_RESOURCE:" << LL_ENDL;
 	for (wait_http_res_queue_t::const_iterator iter(mHttpWaitResource.begin());
 		 mHttpWaitResource.end() != iter;
 		 ++iter)
 	{
-		llinfos << " ID: " << (*iter) << llendl;
+		LL_INFOS() << " ID: " << (*iter) << LL_ENDL;
 	}
 }
 
@@ -4393,14 +4393,14 @@ void LLTextureFetchDebugger::debugHTTP()
 	LLViewerRegion* region = gAgent.getRegion();
 	if (!region)
 	{
-		llinfos << "Fetch Debugger : Current region undefined. Cannot fetch textures through HTTP." << llendl;
+		LL_INFOS() << "Fetch Debugger : Current region undefined. Cannot fetch textures through HTTP." << LL_ENDL;
 		return;
 	}
 	
 	mHTTPUrl = region->getHttpUrl();
 	if (mHTTPUrl.empty())
 	{
-		llinfos << "Fetch Debugger : Current region URL undefined. Cannot fetch textures through HTTP." << llendl;
+		LL_INFOS() << "Fetch Debugger : Current region URL undefined. Cannot fetch textures through HTTP." << LL_ENDL;
 		return;
 	}
 	
@@ -4479,7 +4479,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue()
 			mFetchingHistory[i].mCurlState = FetchEntry::CURL_DONE;
 		}
 	}
-	//llinfos << "Fetch Debugger : Having " << mNbCurlRequests << " requests through the curl thread." << llendl;
+	//LL_INFOS() << "Fetch Debugger : Having " << mNbCurlRequests << " requests through the curl thread." << LL_ENDL;
 	return mNbCurlRequests;
 }
 
@@ -4781,7 +4781,7 @@ void LLTextureFetchDebugger::onCompleted(LLCore::HttpHandle handle, LLCore::Http
 	handle_fetch_map_t::iterator iter(mHandleToFetchIndex.find(handle));
 	if (mHandleToFetchIndex.end() == iter)
 	{
-		llinfos << "Fetch Debugger : Couldn't find handle " << handle << " in fetch list." << llendl;
+		LL_INFOS() << "Fetch Debugger : Couldn't find handle " << handle << " in fetch list." << LL_ENDL;
 		return;
 	}
 	
@@ -4789,7 +4789,7 @@ void LLTextureFetchDebugger::onCompleted(LLCore::HttpHandle handle, LLCore::Http
 	mHandleToFetchIndex.erase(iter);
 	if (fetch_ind >= mFetchingHistory.size() || mFetchingHistory[fetch_ind].mHttpHandle != handle)
 	{
-		llinfos << "Fetch Debugger : Handle and fetch object in disagreement.  Punting." << llendl;
+		LL_INFOS() << "Fetch Debugger : Handle and fetch object in disagreement.  Punting." << LL_ENDL;
 	}
 	else
 	{
@@ -4839,7 +4839,7 @@ void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpRespon
 		
 		S32 data_size = ba ? ba->size() : 0;
 		fetch.mCurlReceivedSize += data_size;
-		//llinfos << "Fetch Debugger : got results for " << fetch.mID << ", data_size = " << data_size << ", received = " << fetch.mCurlReceivedSize << ", requested = " << fetch.mRequestedSize << ", partial = " << partial << llendl;
+		//LL_INFOS() << "Fetch Debugger : got results for " << fetch.mID << ", data_size = " << data_size << ", received = " << fetch.mCurlReceivedSize << ", requested = " << fetch.mRequestedSize << ", partial = " << partial << LL_ENDL;
 		if ((fetch.mCurlReceivedSize >= fetch.mRequestedSize) || !partial || (fetch.mRequestedSize == 600))
 		{
 			U8* d_buffer = (U8*)ALLOCATE_MEM(LLImageBase::getPrivatePool(), data_size);
@@ -4865,9 +4865,9 @@ void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpRespon
 	}
 	else //failed
 	{
-		llinfos << "Fetch Debugger : CURL GET FAILED,  ID = " << fetch.mID
+		LL_INFOS() << "Fetch Debugger : CURL GET FAILED,  ID = " << fetch.mID
 				<< ", status: " << status.toHex()
-				<< " reason:  " << status.toString() << llendl;
+				<< " reason:  " << status.toString() << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/lltextureinfo.cpp b/indra/newview/lltextureinfo.cpp
index d467fd4d97..cd6e7ff464 100755
--- a/indra/newview/lltextureinfo.cpp
+++ b/indra/newview/lltextureinfo.cpp
@@ -155,14 +155,14 @@ void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, LLUnit<U64, L
 
 	if (mLogTextureDownloadsToViewerLog)
 	{
-		llinfos << "texture="   << id 
+		LL_INFOS() << "texture="   << id 
 			    << " start="    << details.mStartTime 
 			    << " end="      << details.mCompleteTime
 			    << " size="     << details.mSize
 			    << " offset="   << details.mOffset
 			    << " length="   << LLUnit<U32, LLUnits::Milliseconds>(details.mCompleteTime - details.mStartTime)
 			    << " protocol=" << protocol
-			    << llendl;
+			    << LL_ENDL;
 	}
 
 	if(mLogTextureDownloadsToSimulator)
diff --git a/indra/newview/lltexturestats.cpp b/indra/newview/lltexturestats.cpp
index 52fe78abf3..ca42d710f8 100755
--- a/indra/newview/lltexturestats.cpp
+++ b/indra/newview/lltexturestats.cpp
@@ -48,7 +48,7 @@ void send_texture_stats_to_sim(const LLSD &texture_stats)
 	texture_stats_report["stats_data"] = texture_stats;
 
 	std::string texture_cap_url = gAgent.getRegion()->getCapability("TextureStats");
-	llinfos << "uploading texture stats data to simulator" << llendl;
+	LL_INFOS() << "uploading texture stats data to simulator" << LL_ENDL;
 	LLTextureStatsUploader::uploadStatsToSimulator(texture_cap_url, texture_stats);
 }
 
diff --git a/indra/newview/lltexturestatsuploader.cpp b/indra/newview/lltexturestatsuploader.cpp
index 92ec63a113..c4809bc8e7 100755
--- a/indra/newview/lltexturestatsuploader.cpp
+++ b/indra/newview/lltexturestatsuploader.cpp
@@ -40,10 +40,10 @@ void LLTextureStatsUploader::uploadStatsToSimulator(const std::string texture_ca
 	}
 	else
 	{
-		llinfos << "Not sending texture stats: " 
+		LL_INFOS() << "Not sending texture stats: " 
 				<< texture_stats 
 				<< " as there is no cap url." 
-				<< llendl;
+				<< LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index c1b5309f82..501914a52f 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -776,7 +776,7 @@ void LLTextureView::draw()
 	
 		if (mPrintList)
 		{
-			llinfos << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << llendl;
+			LL_INFOS() << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << LL_ENDL;
 		}
 	
 		for (LLViewerTextureList::image_priority_list_t::iterator iter = gTextureList.mImageList.begin();
@@ -794,14 +794,14 @@ void LLTextureView::draw()
 			if (mPrintList)
 			{
 				S32 tex_mem = imagep->hasGLTexture() ? imagep->getTextureMemory() : 0 ;
-				llinfos << imagep->getID()
+				LL_INFOS() << imagep->getID()
 						<< "\t" << tex_mem
 						<< "\t" << imagep->getBoostLevel()
 						<< "\t" << imagep->getDecodePriority()
 						<< "\t" << imagep->getWidth()
 						<< "\t" << imagep->getHeight()
 						<< "\t" << cur_discard
-						<< llendl;
+						<< LL_ENDL;
 			}
 
 			if (imagep->getID() == LLAppViewer::getTextureFetch()->mDebugID)
diff --git a/indra/newview/lltoastalertpanel.cpp b/indra/newview/lltoastalertpanel.cpp
index 85232f4a0b..3c916345ec 100755
--- a/indra/newview/lltoastalertpanel.cpp
+++ b/indra/newview/lltoastalertpanel.cpp
@@ -174,7 +174,7 @@ LLToastAlertPanel::LLToastAlertPanel( LLNotificationPtr notification, bool modal
 	// Message: create text box using raw string, as text has been structure deliberately
 	// Use size of created text box to generate dialog box size
 	std::string msg = mNotification->getMessage();
-	llwarns << "Alert: " << msg << llendl;
+	LL_WARNS() << "Alert: " << msg << LL_ENDL;
 	LLTextBox::Params params;
 	params.name("Alert message");
 	params.font(font);
@@ -508,7 +508,7 @@ void LLToastAlertPanel::setEditTextArgs(const LLSD& edit_args)
 	}
 	else
 	{
-		llwarns << "LLToastAlertPanel::setEditTextArgs called on dialog with no line editor" << llendl;
+		LL_WARNS() << "LLToastAlertPanel::setEditTextArgs called on dialog with no line editor" << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/lltoastgroupnotifypanel.cpp b/indra/newview/lltoastgroupnotifypanel.cpp
index beb45e8179..e00b18dedb 100755
--- a/indra/newview/lltoastgroupnotifypanel.cpp
+++ b/indra/newview/lltoastgroupnotifypanel.cpp
@@ -61,7 +61,7 @@ LLToastGroupNotifyPanel::LLToastGroupNotifyPanel(const LLNotificationPtr& notifi
 	LLGroupData groupData;
 	if (!gAgent.getGroupData(payload["group_id"].asUUID(),groupData))
 	{
-		llwarns << "Group notice for unknown group: " << payload["group_id"].asUUID() << llendl;
+		LL_WARNS() << "Group notice for unknown group: " << payload["group_id"].asUUID() << LL_ENDL;
 	}
 
 	//group icon
diff --git a/indra/newview/lltoastimpanel.cpp b/indra/newview/lltoastimpanel.cpp
index 75e6e3d13a..81dfd95f16 100755
--- a/indra/newview/lltoastimpanel.cpp
+++ b/indra/newview/lltoastimpanel.cpp
@@ -167,7 +167,7 @@ void LLToastIMPanel::spawnGroupIconToolTip()
 	LLGroupData g_data;
 	if(!gAgent.getGroupData(mSessionID, g_data))
 	{
-		llwarns << "Error getting group data" << llendl;
+		LL_WARNS() << "Error getting group data" << LL_ENDL;
 	}
 
 	LLInspector::Params params;
@@ -200,7 +200,7 @@ void LLToastIMPanel::initIcon()
 		LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(mSessionID);
 		if(!im_session)
 		{
-			llwarns << "Invalid IM session" << llendl;
+			LL_WARNS() << "Invalid IM session" << LL_ENDL;
 			return;
 		}
 
@@ -220,7 +220,7 @@ void LLToastIMPanel::initIcon()
 			mAdhocIcon->setToolTip(im_session->mName);
 			break;
 		default:
-			llwarns << "Unknown IM session type" << llendl;
+			LL_WARNS() << "Unknown IM session type" << LL_ENDL;
 			break;
 		}
 	}
diff --git a/indra/newview/lltoastscripttextbox.cpp b/indra/newview/lltoastscripttextbox.cpp
index 45fbabad59..78d9e92b5c 100755
--- a/indra/newview/lltoastscripttextbox.cpp
+++ b/indra/newview/lltoastscripttextbox.cpp
@@ -109,7 +109,7 @@ void LLToastScriptTextbox::onClickSubmit()
 		}
 		mNotification->respond(response);
 		close();
-		llwarns << response << llendl;
+		LL_WARNS() << response << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/lltool.cpp b/indra/newview/lltool.cpp
index f4499f2da8..4aad650b68 100755
--- a/indra/newview/lltool.cpp
+++ b/indra/newview/lltool.cpp
@@ -55,7 +55,7 @@ LLTool::~LLTool()
 {
 	if( hasMouseCapture() )
 	{
-		llwarns << "Tool deleted holding mouse capture.  Mouse capture removed." << llendl;
+		LL_WARNS() << "Tool deleted holding mouse capture.  Mouse capture removed." << LL_ENDL;
 		gFocusMgr.removeMouseCaptureWithoutCallback( this );
 	}
 }
@@ -80,10 +80,10 @@ BOOL LLTool::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (gDebugClicks)
 	{
-		llinfos << "LLTool left mouse down" << llendl;
+		LL_INFOS() << "LLTool left mouse down" << LL_ENDL;
 	}
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleMouseDown" << llendl;
+	// LL_INFOS() << "LLTool::handleMouseDown" << LL_ENDL;
 	gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN);
 	return TRUE;
 }
@@ -92,10 +92,10 @@ BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
 {
 	if (gDebugClicks) 
 	{
-		llinfos << "LLTool left mouse up" << llendl;
+		LL_INFOS() << "LLTool left mouse up" << LL_ENDL;
 	}
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleMouseUp" << llendl;
+	// LL_INFOS() << "LLTool::handleMouseUp" << LL_ENDL;
 	gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP);
 	return TRUE;
 }
@@ -103,7 +103,7 @@ BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
 BOOL LLTool::handleHover(S32 x, S32 y, MASK mask)
 {
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);
-	LL_DEBUGS("UserInput") << "hover handled by a tool" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by a tool" << LL_ENDL;		
 	// by default, do nothing, say we handled it
 	return TRUE;
 }
@@ -111,13 +111,13 @@ BOOL LLTool::handleHover(S32 x, S32 y, MASK mask)
 BOOL LLTool::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleScrollWheel" << llendl;
+	// LL_INFOS() << "LLTool::handleScrollWheel" << LL_ENDL;
 	return FALSE;
 }
 
 BOOL LLTool::handleDoubleClick(S32 x,S32 y,MASK mask)
 {
-	// llinfos << "LLTool::handleDoubleClick" << llendl;
+	// LL_INFOS() << "LLTool::handleDoubleClick" << LL_ENDL;
 	// by default, pretend it's a left click
 	return FALSE;
 }
@@ -125,35 +125,35 @@ BOOL LLTool::handleDoubleClick(S32 x,S32 y,MASK mask)
 BOOL LLTool::handleRightMouseDown(S32 x,S32 y,MASK mask)
 {
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleRightMouseDown" << llendl;
+	// LL_INFOS() << "LLTool::handleRightMouseDown" << LL_ENDL;
 	return FALSE;
 }
 
 BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask)
 {
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleRightMouseDown" << llendl;
+	// LL_INFOS() << "LLTool::handleRightMouseDown" << LL_ENDL;
 	return FALSE;
 }
  
 BOOL LLTool::handleMiddleMouseDown(S32 x,S32 y,MASK mask)
 {
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleMiddleMouseDown" << llendl;
+	// LL_INFOS() << "LLTool::handleMiddleMouseDown" << LL_ENDL;
 	return FALSE;
 }
 
 BOOL LLTool::handleMiddleMouseUp(S32 x, S32 y, MASK mask)
 {
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleMiddleMouseUp" << llendl;
+	// LL_INFOS() << "LLTool::handleMiddleMouseUp" << LL_ENDL;
 	return FALSE;
 }
 
 BOOL LLTool::handleToolTip(S32 x, S32 y, MASK mask)
 {
 	// by default, didn't handle it
-	// llinfos << "LLTool::handleToolTip" << llendl;
+	// LL_INFOS() << "LLTool::handleToolTip" << LL_ENDL;
 	return FALSE;
 }
 
diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp
index ed0f22f16a..98eac008b3 100755
--- a/indra/newview/lltoolbarview.cpp
+++ b/indra/newview/lltoolbarview.cpp
@@ -201,7 +201,7 @@ bool LLToolBarView::addCommandInternal(const LLCommandId& command, LLToolBar* to
 	}
 	else 
 	{
-		llwarns	<< "Toolbars creation : the command with id " << command.uuid().asString() << " cannot be found in the command manager" << llendl;
+		LL_WARNS()	<< "Toolbars creation : the command with id " << command.uuid().asString() << " cannot be found in the command manager" << LL_ENDL;
 		return false;
 	}
 	return true;
@@ -220,20 +220,20 @@ bool LLToolBarView::loadToolbars(bool force_default)
 	}
 	else if (!gDirUtilp->fileExists(toolbar_file)) 
 	{
-		llwarns << "User toolbars def not found -> use default" << llendl;
+		LL_WARNS() << "User toolbars def not found -> use default" << LL_ENDL;
 		toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
 	}
 	
 	LLXMLNodePtr root;
 	if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
 	{
-		llwarns << "Unable to load toolbars from file: " << toolbar_file << llendl;
+		LL_WARNS() << "Unable to load toolbars from file: " << toolbar_file << LL_ENDL;
 		err = true;
 	}
 	
 	if (!err && !root->hasName("toolbars"))
 	{
-		llwarns << toolbar_file << " is not a valid toolbars definition file" << llendl;
+		LL_WARNS() << toolbar_file << " is not a valid toolbars definition file" << LL_ENDL;
 		err = true;
 	}
 	
@@ -246,7 +246,7 @@ bool LLToolBarView::loadToolbars(bool force_default)
 
 	if (!err && !toolbar_set.validateBlock())
 	{
-		llwarns << "Unable to validate toolbars from file: " << toolbar_file << llendl;
+		LL_WARNS() << "Unable to validate toolbars from file: " << toolbar_file << LL_ENDL;
 		err = true;
 	}
 	
@@ -254,7 +254,7 @@ bool LLToolBarView::loadToolbars(bool force_default)
 	{
 		if (force_default)
 		{
-			llerrs << "Unable to load toolbars from default file : " << toolbar_file << llendl;
+			LL_ERRS() << "Unable to load toolbars from default file : " << toolbar_file << LL_ENDL;
 		    return false;
 	    }
 
@@ -283,7 +283,7 @@ bool LLToolBarView::loadToolbars(bool force_default)
 		{
 			if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_LEFT]))
 			{
-				llwarns << "Error adding command '" << command_params.name() << "' to left toolbar." << llendl;
+				LL_WARNS() << "Error adding command '" << command_params.name() << "' to left toolbar." << LL_ENDL;
 			}
 		}
 	}
@@ -298,7 +298,7 @@ bool LLToolBarView::loadToolbars(bool force_default)
 		{
 			if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_RIGHT]))
 			{
-				llwarns << "Error adding command '" << command_params.name() << "' to right toolbar." << llendl;
+				LL_WARNS() << "Error adding command '" << command_params.name() << "' to right toolbar." << LL_ENDL;
 			}
 		}
 	}
@@ -313,7 +313,7 @@ bool LLToolBarView::loadToolbars(bool force_default)
 		{
 			if (addCommandInternal(LLCommandId(command_params), mToolbars[TOOLBAR_BOTTOM]))
 			{
-				llwarns << "Error adding command '" << command_params.name() << "' to bottom toolbar." << llendl;
+				LL_WARNS() << "Error adding command '" << command_params.name() << "' to bottom toolbar." << LL_ENDL;
 			}
 		}
 	}
@@ -651,7 +651,7 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t
 		}
 		else
 		{
-			llwarns << "Command couldn't be found in command manager" << llendl;
+			LL_WARNS() << "Command couldn't be found in command manager" << LL_ENDL;
 		}
 	}
 
diff --git a/indra/newview/lltoolbrush.cpp b/indra/newview/lltoolbrush.cpp
index 96b742aebc..56f0f8be25 100755
--- a/indra/newview/lltoolbrush.cpp
+++ b/indra/newview/lltoolbrush.cpp
@@ -403,7 +403,7 @@ BOOL LLToolBrushLand::handleHover( S32 x, S32 y, MASK mask )
 {
 	LL_DEBUGS("UserInput") << "hover handled by LLToolBrushLand ("
 								<< (hasMouseCapture() ? "active":"inactive")
-								<< ")" << llendl;
+								<< ")" << LL_ENDL;
 	mMouseX = x;
 	mMouseY = y;
 	mGotHover = TRUE;
@@ -456,7 +456,7 @@ void LLToolBrushLand::render()
 {
 	if(mGotHover)
 	{
-		//llinfos << "LLToolBrushLand::render()" << llendl;
+		//LL_INFOS() << "LLToolBrushLand::render()" << LL_ENDL;
 		LLVector3d spot;
 		if(gViewerWindow->mousePointOnLandGlobal(mMouseX, mMouseY, &spot))
 		{
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index ca28397d52..44303c838c 100755
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -174,7 +174,7 @@ public:
 	virtual void done()
 	{
 		/* no-op: it's fire n forget right? */
-		lldebugs << "LLCategoryFireAndForget::done()" << llendl;
+		LL_DEBUGS() << "LLCategoryFireAndForget::done()" << LL_ENDL;
 	}
 };
 
@@ -370,7 +370,7 @@ void LLToolDragAndDrop::beginDrag(EDragAndDropType type,
 {
 	if (type == DAD_NONE)
 	{
-		llwarns << "Attempted to start drag without a cargo type" << llendl;
+		LL_WARNS() << "Attempted to start drag without a cargo type" << LL_ENDL;
 		return;
 	}
 	mCargoTypes.clear();
@@ -442,7 +442,7 @@ void LLToolDragAndDrop::beginMultiDrag(
 	{
 		if (DAD_NONE == *types_it)
 		{
-			llwarns << "Attempted to start drag without a cargo type" << llendl;
+			LL_WARNS() << "Attempted to start drag without a cargo type" << LL_ENDL;
 			return;
 		}
 	}
@@ -597,7 +597,7 @@ BOOL LLToolDragAndDrop::handleHover( S32 x, S32 y, MASK mask )
 	ECursorType cursor = acceptanceToCursor(acceptance);
 	gViewerWindow->getWindow()->setCursor( cursor );
 
-	LL_DEBUGS("UserInput") << "hover handled by LLToolDragAndDrop" << llendl;
+	LL_DEBUGS("UserInput") << "hover handled by LLToolDragAndDrop" << LL_ENDL;
 	return TRUE;
 }
 
@@ -1034,7 +1034,7 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj,
 			}
 			else
 			{
-				llwarns << "Unable to find source object." << llendl;
+				LL_WARNS() << "Unable to find source object." << LL_ENDL;
 				return FALSE;
 			}
 		}
@@ -1084,7 +1084,7 @@ void LLToolDragAndDrop::dropTextureAllFaces(LLViewerObject* hit_obj,
 {
 	if (!item)
 	{
-		llwarns << "LLToolDragAndDrop::dropTextureAllFaces no texture item." << llendl;
+		LL_WARNS() << "LLToolDragAndDrop::dropTextureAllFaces no texture item." << LL_ENDL;
 		return;
 	}
 	LLUUID asset_id = item->getAssetUUID();
@@ -1114,7 +1114,7 @@ void LLToolDragAndDrop::dropMesh(LLViewerObject* hit_obj,
 {
 	if (!item)
 	{
-		llwarns << "no inventory item." << llendl;
+		LL_WARNS() << "no inventory item." << LL_ENDL;
 		return;
 	}
 	LLUUID asset_id = item->getAssetUUID();
@@ -1151,7 +1151,7 @@ void LLToolDragAndDrop::dropTextureOneFace(LLViewerObject* hit_obj,
 	if (hit_face == -1) return;
 	if (!item)
 	{
-		llwarns << "LLToolDragAndDrop::dropTextureOneFace no texture item." << llendl;
+		LL_WARNS() << "LLToolDragAndDrop::dropTextureOneFace no texture item." << LL_ENDL;
 		return;
 	}
 	LLUUID asset_id = item->getAssetUUID();
@@ -1182,8 +1182,8 @@ void LLToolDragAndDrop::dropScript(LLViewerObject* hit_obj,
 	if ((SOURCE_WORLD == LLToolDragAndDrop::getInstance()->mSource)
 	   || (SOURCE_NOTECARD == LLToolDragAndDrop::getInstance()->mSource))
 	{
-		llwarns << "Call to LLToolDragAndDrop::dropScript() from world"
-			<< " or notecard." << llendl;
+		LL_WARNS() << "Call to LLToolDragAndDrop::dropScript() from world"
+			<< " or notecard." << LL_ENDL;
 		return;
 	}
 	if (hit_obj && item)
@@ -1210,7 +1210,7 @@ void LLToolDragAndDrop::dropScript(LLViewerObject* hit_obj,
 				}
 				else
 				{
-					llwarns << "Unable to find source object." << llendl;
+					LL_WARNS() << "Unable to find source object." << LL_ENDL;
 					return;
 				}
 			}
@@ -1235,11 +1235,11 @@ void LLToolDragAndDrop::dropObject(LLViewerObject* raycast_target,
 	LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(mLastHitPos);
 	if (!regionp)
 	{
-		llwarns << "Couldn't find region to rez object" << llendl;
+		LL_WARNS() << "Couldn't find region to rez object" << LL_ENDL;
 		return;
 	}
 
-	//llinfos << "Rezzing object" << llendl;
+	//LL_INFOS() << "Rezzing object" << LL_ENDL;
 	make_ui_sound("UISndObjectRezIn");
 	LLViewerInventoryItem* item;
 	LLViewerInventoryCategory* cat;
@@ -1399,8 +1399,8 @@ void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj,
 	if ((SOURCE_WORLD == LLToolDragAndDrop::getInstance()->mSource)
 	   || (SOURCE_NOTECARD == LLToolDragAndDrop::getInstance()->mSource))
 	{
-		llwarns << "Call to LLToolDragAndDrop::dropInventory() from world"
-			<< " or notecard." << llendl;
+		LL_WARNS() << "Call to LLToolDragAndDrop::dropInventory() from world"
+			<< " or notecard." << LL_ENDL;
 		return;
 	}
 
@@ -1430,7 +1430,7 @@ void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj,
 			}
 			else
 			{
-				llwarns << "Unable to find source object." << llendl;
+				LL_WARNS() << "Unable to find source object." << LL_ENDL;
 				return;
 			}
 		}
@@ -1697,14 +1697,14 @@ bool LLToolDragAndDrop::handleGiveDragAndDrop(LLUUID dest_agent, LLUUID session_
 EAcceptance LLToolDragAndDrop::dad3dNULL(
 	LLViewerObject*, S32, MASK, BOOL)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dNULL()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dNULL()" << LL_ENDL;
 	return ACCEPT_NO;
 }
 
 EAcceptance LLToolDragAndDrop::dad3dRezAttachmentFromInv(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dRezAttachmentFromInv()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dRezAttachmentFromInv()" << LL_ENDL;
 	// must be in the user's inventory
 	if(mSource != SOURCE_AGENT && mSource != SOURCE_LIBRARY)
 	{
@@ -1767,7 +1767,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnLand(
 		return dad3dRezFromObjectOnLand(obj, face, mask, drop);
 	}
 
-	lldebugs << "LLToolDragAndDrop::dad3dRezObjectOnLand()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dRezObjectOnLand()" << LL_ENDL;
 	LLViewerInventoryItem* item;
 	LLViewerInventoryCategory* cat;
 	locateInventory(item, cat);
@@ -1830,7 +1830,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnObject(
 		return dad3dRezFromObjectOnObject(obj, face, mask, drop);
 	}
 
-	lldebugs << "LLToolDragAndDrop::dad3dRezObjectOnObject()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dRezObjectOnObject()" << LL_ENDL;
 	LLViewerInventoryItem* item;
 	LLViewerInventoryCategory* cat;
 	locateInventory(item, cat);
@@ -1902,7 +1902,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezObjectOnObject(
 EAcceptance LLToolDragAndDrop::dad3dRezScript(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dRezScript()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dRezScript()" << LL_ENDL;
 
 	// *HACK: In order to resolve SL-22177, we need to block drags
 	// from notecards and objects onto other objects.
@@ -1940,7 +1940,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezScript(
 EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop, EDragAndDropType cargo_type)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dApplyToObject()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dApplyToObject()" << LL_ENDL;
 
 	// *HACK: In order to resolve SL-22177, we need to block drags
 	// from notecards and objects onto other objects.
@@ -1991,7 +1991,7 @@ EAcceptance LLToolDragAndDrop::dad3dApplyToObject(
 		}
 		else
 		{
-			llwarns << "unsupported asset type" << llendl;
+			LL_WARNS() << "unsupported asset type" << LL_ENDL;
 		}
 		
 		// VEFFECT: SetTexture
@@ -2024,7 +2024,7 @@ EAcceptance LLToolDragAndDrop::dad3dMeshObject(
 EAcceptance LLToolDragAndDrop::dad3dTextureSelf(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dTextureAvatar()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dTextureAvatar()" << LL_ENDL;
 	if(drop)
 	{
 		if( !(mask & MASK_SHIFT) )
@@ -2039,7 +2039,7 @@ EAcceptance LLToolDragAndDrop::dad3dTextureSelf(
 EAcceptance LLToolDragAndDrop::dad3dWearItem(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dWearItem()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dWearItem()" << LL_ENDL;
 	LLViewerInventoryItem* item;
 	LLViewerInventoryCategory* cat;
 	locateInventory(item, cat);
@@ -2072,7 +2072,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearItem(
 EAcceptance LLToolDragAndDrop::dad3dActivateGesture(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dActivateGesture()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dActivateGesture()" << LL_ENDL;
 	LLViewerInventoryItem* item;
 	LLViewerInventoryCategory* cat;
 	locateInventory(item, cat);
@@ -2121,7 +2121,7 @@ EAcceptance LLToolDragAndDrop::dad3dActivateGesture(
 EAcceptance LLToolDragAndDrop::dad3dWearCategory(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dWearCategory()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dWearCategory()" << LL_ENDL;
 	LLViewerInventoryItem* item;
 	LLViewerInventoryCategory* category;
 	locateInventory(item, category);
@@ -2172,7 +2172,7 @@ EAcceptance LLToolDragAndDrop::dad3dWearCategory(
 EAcceptance LLToolDragAndDrop::dad3dUpdateInventory(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dadUpdateInventory()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dadUpdateInventory()" << LL_ENDL;
 
 	// *HACK: In order to resolve SL-22177, we need to block drags
 	// from notecards and objects onto other objects.
@@ -2212,10 +2212,10 @@ BOOL LLToolDragAndDrop::dadUpdateInventory(LLViewerObject* obj, BOOL drop)
 EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dUpdateInventoryCategory()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dUpdateInventoryCategory()" << LL_ENDL;
 	if (obj == NULL)
 	{
-		llwarns << "obj is NULL; aborting func with ACCEPT_NO" << llendl;
+		LL_WARNS() << "obj is NULL; aborting func with ACCEPT_NO" << LL_ENDL;
 		return ACCEPT_NO;
 	}
 
@@ -2248,7 +2248,7 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory(
 	cats.push_back(cat);
  	if (droppable.countNoCopy() > 0)
  	{
- 		llwarns << "*** Need to confirm this step" << llendl;
+ 		LL_WARNS() << "*** Need to confirm this step" << LL_ENDL;
  	}
 	LLViewerObject* root_object = obj;
 	if (obj->getParent())
@@ -2271,7 +2271,7 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory(
 		rv = gInventory.isCategoryComplete(cat->getUUID()) ? ACCEPT_YES_MULTI : ACCEPT_NO;
 		if(rv < ACCEPT_YES_SINGLE)
 		{
-			lldebugs << "Category " << cat->getUUID() << "is not complete." << llendl;
+			LL_DEBUGS() << "Category " << cat->getUUID() << "is not complete." << LL_ENDL;
 			break;
 		}
 	}
@@ -2293,7 +2293,7 @@ EAcceptance LLToolDragAndDrop::dad3dUpdateInventoryCategory(
 			rv = willObjectAcceptInventory(root_object, item);
 			if (rv < ACCEPT_YES_COPY_SINGLE)
 			{
-				lldebugs << "Object will not accept " << item->getUUID() << llendl;
+				LL_DEBUGS() << "Object will not accept " << item->getUUID() << LL_ENDL;
 				break;
 			}
 		}
@@ -2334,7 +2334,7 @@ BOOL LLToolDragAndDrop::dadUpdateInventoryCategory(LLViewerObject* obj,
 EAcceptance LLToolDragAndDrop::dad3dGiveInventoryObject(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dGiveInventoryObject()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dGiveInventoryObject()" << LL_ENDL;
 
 	// item has to be in agent inventory.
 	if(mSource != SOURCE_AGENT) return ACCEPT_NO;
@@ -2372,7 +2372,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryObject(
 EAcceptance LLToolDragAndDrop::dad3dGiveInventory(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dGiveInventory()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dGiveInventory()" << LL_ENDL;
 	// item has to be in agent inventory.
 	if(mSource != SOURCE_AGENT) return ACCEPT_NO;
 	LLViewerInventoryItem* item;
@@ -2395,7 +2395,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventory(
 EAcceptance LLToolDragAndDrop::dad3dGiveInventoryCategory(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dGiveInventoryCategory()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dGiveInventoryCategory()" << LL_ENDL;
 	if(drop && obj)
 	{
 		LLViewerInventoryItem* item;
@@ -2413,7 +2413,7 @@ EAcceptance LLToolDragAndDrop::dad3dGiveInventoryCategory(
 EAcceptance LLToolDragAndDrop::dad3dRezFromObjectOnLand(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dRezFromObjectOnLand()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dRezFromObjectOnLand()" << LL_ENDL;
 	LLViewerInventoryItem* item = NULL;
 	LLViewerInventoryCategory* cat = NULL;
 	locateInventory(item, cat);
@@ -2434,7 +2434,7 @@ EAcceptance LLToolDragAndDrop::dad3dRezFromObjectOnLand(
 EAcceptance LLToolDragAndDrop::dad3dRezFromObjectOnObject(
 	LLViewerObject* obj, S32 face, MASK mask, BOOL drop)
 {
-	lldebugs << "LLToolDragAndDrop::dad3dRezFromObjectOnObject()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dRezFromObjectOnObject()" << LL_ENDL;
 	LLViewerInventoryItem* item;
 	LLViewerInventoryCategory* cat;
 	locateInventory(item, cat);
@@ -2471,7 +2471,7 @@ EAcceptance LLToolDragAndDrop::dad3dCategoryOnLand(
 {
 	return ACCEPT_NO;
 	/*
-	lldebugs << "LLToolDragAndDrop::dad3dCategoryOnLand()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dCategoryOnLand()" << LL_ENDL;
 	LLInventoryItem* item;
 	LLInventoryCategory* cat;
 	locateInventory(item, cat);
@@ -2509,7 +2509,7 @@ EAcceptance LLToolDragAndDrop::dad3dAssetOnLand(
 {
 	return ACCEPT_NO;
 	/*
-	lldebugs << "LLToolDragAndDrop::dad3dAssetOnLand()" << llendl;
+	LL_DEBUGS() << "LLToolDragAndDrop::dad3dAssetOnLand()" << LL_ENDL;
 	LLViewerInventoryCategory::cat_array_t cats;
 	LLViewerInventoryItem::item_array_t items;
 	LLViewerInventoryItem::item_array_t copyable_items;
@@ -2660,7 +2660,7 @@ LLInventoryObject* LLToolDragAndDrop::locateMultipleInventory(LLViewerInventoryC
 
 // void LLToolDragAndDrop::createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name )
 // {
-// 	llwarns << "LLToolDragAndDrop::createContainer()" << llendl;
+// 	LL_WARNS() << "LLToolDragAndDrop::createContainer()" << LL_ENDL;
 // 	return;
 // }
 
diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp
index a320d37084..ee4ec112f8 100755
--- a/indra/newview/lltoolfocus.cpp
+++ b/indra/newview/lltoolfocus.cpp
@@ -334,7 +334,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 	{
 		if (!mValidClickPoint)
 		{
-			LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [invalid point]" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [invalid point]" << LL_ENDL;
 			gViewerWindow->setCursor(UI_CURSOR_NO);
 			gViewerWindow->showCursor();
 			return TRUE;
@@ -361,7 +361,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 
 				gViewerWindow->moveCursorToCenter();
 			}
-			LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [active]" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolFocus [active]" << LL_ENDL;
 		}
 		else if (	gCameraBtnPan ||
 					mask == MASK_PAN ||
@@ -389,7 +389,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 
 				gViewerWindow->moveCursorToCenter();
 			}
-			LL_DEBUGS("UserInput") << "hover handled by LLToolPan" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPan" << LL_ENDL;
 		}
 		else if (gCameraBtnZoom)
 		{
@@ -421,7 +421,7 @@ BOOL LLToolCamera::handleHover(S32 x, S32 y, MASK mask)
 				gViewerWindow->moveCursorToCenter();
 			}
 
-			LL_DEBUGS("UserInput") << "hover handled by LLToolZoom" << llendl;		
+			LL_DEBUGS("UserInput") << "hover handled by LLToolZoom" << LL_ENDL;		
 		}
 	}
 
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index a9216568c2..493c970141 100755
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -115,7 +115,7 @@ BOOL LLToolGrab::handleDoubleClick(S32 x, S32 y, MASK mask)
 {
 	if (gDebugClicks)
 	{
-		llinfos << "LLToolGrab handleDoubleClick (becoming mouseDown)" << llendl;
+		LL_INFOS() << "LLToolGrab handleDoubleClick (becoming mouseDown)" << LL_ENDL;
 	}
 
 	return FALSE;
@@ -125,7 +125,7 @@ BOOL LLToolGrab::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (gDebugClicks)
 	{
-		llinfos << "LLToolGrab handleMouseDown" << llendl;
+		LL_INFOS() << "LLToolGrab handleMouseDown" << LL_ENDL;
 	}
 
 	// call the base class to propogate info to sim
@@ -176,12 +176,12 @@ BOOL LLToolGrab::handleObjectHit(const LLPickInfo& info)
 
 	if (gDebugClicks)
 	{
-		llinfos << "LLToolGrab handleObjectHit " << info.mMousePt.mX << "," << info.mMousePt.mY << llendl;
+		LL_INFOS() << "LLToolGrab handleObjectHit " << info.mMousePt.mX << "," << info.mMousePt.mY << LL_ENDL;
 	}
 
 	if (NULL == objectp) // unexpected
 	{
-		llwarns << "objectp was NULL; returning FALSE" << llendl;
+		LL_WARNS() << "objectp was NULL; returning FALSE" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -707,7 +707,7 @@ void LLToolGrab::handleHoverActive(S32 x, S32 y, MASK mask)
 	// HACK to avoid assert: error checking system makes sure that the cursor is set during every handleHover.  This is actually a no-op since the cursor is hidden.
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);  
 
-	LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (active) [cursor hidden]" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (active) [cursor hidden]" << LL_ENDL;		
 }
  
 
@@ -871,7 +871,7 @@ void LLToolGrab::handleHoverNonPhysical(S32 x, S32 y, MASK mask)
 void LLToolGrab::handleHoverInactive(S32 x, S32 y, MASK mask)
 {
 	// JC - TODO - change cursor based on gGrabBtnVertical, gGrabBtnSpin
-	LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (inactive-not over editable object)" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (inactive-not over editable object)" << LL_ENDL;		
 	gViewerWindow->setCursor(UI_CURSOR_TOOLGRAB);
 }
 
@@ -881,7 +881,7 @@ void LLToolGrab::handleHoverFailed(S32 x, S32 y, MASK mask)
 	if( GRAB_NOOBJECT == mMode )
 	{
 		gViewerWindow->setCursor(UI_CURSOR_NO);
-		LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (not on object)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (not on object)" << LL_ENDL;		
 	}
 	else
 	{
@@ -894,13 +894,13 @@ void LLToolGrab::handleHoverFailed(S32 x, S32 y, MASK mask)
 			{
 			case GRAB_LOCKED:
 				gViewerWindow->setCursor(UI_CURSOR_GRABLOCKED);
-				LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed, no move permission)" << llendl;		
+				LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed, no move permission)" << LL_ENDL;		
 				break;
 
 //  Non physical now handled by handleHoverActive - CRO				
 //			case GRAB_NONPHYSICAL:
 //				gViewerWindow->setCursor(UI_CURSOR_ARROW);
-//				LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed, nonphysical)" << llendl;		
+//				LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed, nonphysical)" << LL_ENDL;		
 //				break;
 			default:
 				llassert(0);
@@ -909,7 +909,7 @@ void LLToolGrab::handleHoverFailed(S32 x, S32 y, MASK mask)
 		else
 		{
 			gViewerWindow->setCursor(UI_CURSOR_ARROW);
-			LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed but within slop)" << llendl;		
+			LL_DEBUGS("UserInput") << "hover handled by LLToolGrab (grab failed but within slop)" << LL_ENDL;		
 		}
 	}
 }
@@ -1108,16 +1108,16 @@ void send_ObjectGrab_message(LLViewerObject* object, const LLPickInfo & pick, co
 	msg->sendMessage( object->getRegion()->getHost());
 
 	/*  Diagnostic code
-	llinfos << "mUVCoords: " << pick.mUVCoords
+	LL_INFOS() << "mUVCoords: " << pick.mUVCoords
 			<< ", mSTCoords: " << pick.mSTCoords
 			<< ", mObjectFace: " << pick.mObjectFace
 			<< ", mIntersection: " << pick.mIntersection
 			<< ", mNormal: " << pick.mNormal
 			<< ", mBinormal: " << pick.mBinormal
-			<< llendl;
+			<< LL_ENDL;
 
-	llinfos << "Avatar pos: " << gAgent.getPositionAgent() << llendl;
-	llinfos << "Object pos: " << object->getPosition() << llendl;
+	LL_INFOS() << "Avatar pos: " << gAgent.getPositionAgent() << LL_ENDL;
+	LL_INFOS() << "Object pos: " << object->getPosition() << LL_ENDL;
 	*/
 }
 
diff --git a/indra/newview/lltoolgun.cpp b/indra/newview/lltoolgun.cpp
index 17795af65d..6c9155be85 100755
--- a/indra/newview/lltoolgun.cpp
+++ b/indra/newview/lltoolgun.cpp
@@ -116,11 +116,11 @@ BOOL LLToolGun::handleHover(S32 x, S32 y, MASK mask)
 			gViewerWindow->hideCursor();
 		}
 
-		LL_DEBUGS("UserInput") << "hover handled by LLToolGun (mouselook)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLToolGun (mouselook)" << LL_ENDL;
 	}
 	else
 	{
-		LL_DEBUGS("UserInput") << "hover handled by LLToolGun (not mouselook)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLToolGun (not mouselook)" << LL_ENDL;
 	}
 
 	// HACK to avoid assert: error checking system makes sure that the cursor is set during every handleHover.  This is actually a no-op since the cursor is hidden.
diff --git a/indra/newview/lltoolmgr.cpp b/indra/newview/lltoolmgr.cpp
index a135ba70f5..aa55caf7ec 100755
--- a/indra/newview/lltoolmgr.cpp
+++ b/indra/newview/lltoolmgr.cpp
@@ -357,7 +357,7 @@ void LLToolMgr::clearTransientTool()
 		mTransientTool = NULL;
 		if (!mBaseTool)
 		{
-			llwarns << "mBaseTool is NULL" << llendl;
+			LL_WARNS() << "mBaseTool is NULL" << LL_ENDL;
 		}
 	}
 	updateToolStatus();
diff --git a/indra/newview/lltoolobjpicker.cpp b/indra/newview/lltoolobjpicker.cpp
index b65c4c1ec8..0d9fe9e577 100755
--- a/indra/newview/lltoolobjpicker.cpp
+++ b/indra/newview/lltoolobjpicker.cpp
@@ -76,7 +76,7 @@ BOOL LLToolObjPicker::handleMouseDown(S32 x, S32 y, MASK mask)
 		}
 		else
 		{
-			llwarns << "PickerTool doesn't have mouse capture on mouseDown" << llendl;	
+			LL_WARNS() << "PickerTool doesn't have mouse capture on mouseDown" << LL_ENDL;	
 		}
 	}
 
@@ -109,7 +109,7 @@ BOOL LLToolObjPicker::handleMouseUp(S32 x, S32 y, MASK mask)
 	}
 	else
 	{
-		llwarns << "PickerTool doesn't have mouse capture on mouseUp" << llendl;	
+		LL_WARNS() << "PickerTool doesn't have mouse capture on mouseUp" << LL_ENDL;	
 	}
 	return handled;
 }
diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp
index fe520b26df..28d0abc9d2 100755
--- a/indra/newview/lltoolpie.cpp
+++ b/indra/newview/lltoolpie.cpp
@@ -558,7 +558,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
 		// could disable it here.
 		show_highlight = true;
 		// cursor set by media object
-		LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
+		LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << LL_ENDL;
 	}
 	else if (!mMouseOutsideSlop 
 		&& mMouseButtonDown 
@@ -595,7 +595,7 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
 			show_highlight = true;
 			ECursorType cursor = cursorFromObject(click_action_object);
 			gViewerWindow->setCursor(cursor);
-			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << LL_ENDL;
 		}
 		
 		else if ((object && !object->isAvatar() && object->flagUsePhysics()) 
@@ -603,19 +603,19 @@ BOOL LLToolPie::handleHover(S32 x, S32 y, MASK mask)
 		{
 			show_highlight = true;
 			gViewerWindow->setCursor(UI_CURSOR_TOOLGRAB);
-			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << LL_ENDL;
 		}
 		else if ( (object && object->flagHandleTouch()) 
 				  || (parent && parent->flagHandleTouch()))
 		{
 			show_highlight = true;
 			gViewerWindow->setCursor(UI_CURSOR_HAND);
-			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << LL_ENDL;
 		}
 		else
 		{
 			gViewerWindow->setCursor(UI_CURSOR_ARROW);
-			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolPie (inactive)" << LL_ENDL;
 		}
 	}
 
@@ -707,7 +707,7 @@ BOOL LLToolPie::handleDoubleClick(S32 x, S32 y, MASK mask)
 {
 	if (gDebugClicks)
 	{
-		llinfos << "LLToolPie handleDoubleClick (becoming mouseDown)" << llendl;
+		LL_INFOS() << "LLToolPie handleDoubleClick (becoming mouseDown)" << LL_ENDL;
 	}
 
 	if (gSavedSettings.getBOOL("DoubleClickAutoPilot"))
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index 3b1b40a7f0..ceb57d0172 100755
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -127,7 +127,7 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj,
 	LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(surface_pos_global);
 	if (!regionp)
 	{
-		llwarns << "Trying to add object outside of all known regions!" << llendl;
+		LL_WARNS() << "Trying to add object outside of all known regions!" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -178,7 +178,7 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
 
 	if (NULL == regionp)
 	{
-		llwarns << "regionp was NULL; aborting function." << llendl;
+		LL_WARNS() << "regionp was NULL; aborting function." << LL_ENDL;
 		return FALSE;
 	}
 
@@ -518,7 +518,7 @@ BOOL LLToolPlacer::placeObject(S32 x, S32 y, MASK mask)
 
 BOOL LLToolPlacer::handleHover(S32 x, S32 y, MASK mask)
 {
-	LL_DEBUGS("UserInput") << "hover handled by LLToolPlacer" << llendl;		
+	LL_DEBUGS("UserInput") << "hover handled by LLToolPlacer" << LL_ENDL;		
 	gViewerWindow->setCursor(UI_CURSOR_TOOLCREATE);
 	return TRUE;
 }
diff --git a/indra/newview/lltoolselectland.cpp b/indra/newview/lltoolselectland.cpp
index d44ac53db0..44c0cb3124 100755
--- a/indra/newview/lltoolselectland.cpp
+++ b/indra/newview/lltoolselectland.cpp
@@ -168,13 +168,13 @@ BOOL LLToolSelectLand::handleHover(S32 x, S32 y, MASK mask)
 				roundXY(mWestSouthBottom);
 				roundXY(mEastNorthTop);
 
-				LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, land)" << llendl;
+				LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, land)" << LL_ENDL;
 				gViewerWindow->setCursor(UI_CURSOR_ARROW);
 			}
 			else
 			{
 				mDragEndValid = FALSE;
-				LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, no land)" << llendl;
+				LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, no land)" << LL_ENDL;
 				gViewerWindow->setCursor(UI_CURSOR_NO);
 			}
 
@@ -183,13 +183,13 @@ BOOL LLToolSelectLand::handleHover(S32 x, S32 y, MASK mask)
 		}
 		else
 		{
-			LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, in slop)" << llendl;
+			LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (active, in slop)" << LL_ENDL;
 			gViewerWindow->setCursor(UI_CURSOR_ARROW);
 		}
 	}
 	else
 	{
-		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectLand (inactive)" << LL_ENDL;		
 		gViewerWindow->setCursor(UI_CURSOR_ARROW);
 	}
 
diff --git a/indra/newview/lltoolselectrect.cpp b/indra/newview/lltoolselectrect.cpp
index 271a417fb9..c5616fb208 100755
--- a/indra/newview/lltoolselectrect.cpp
+++ b/indra/newview/lltoolselectrect.cpp
@@ -144,11 +144,11 @@ BOOL LLToolSelectRect::handleHover(S32 x, S32 y, MASK mask)
 			return LLToolSelect::handleHover(x, y, mask);
 		}
 
-		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectRect (active)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectRect (active)" << LL_ENDL;		
 	}
 	else
 	{
-		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectRect (inactive)" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLToolSelectRect (inactive)" << LL_ENDL;		
 	}
 
 	gViewerWindow->setCursor(UI_CURSOR_ARROW);
diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp
index 34cbd25fd8..91a5777a74 100755
--- a/indra/newview/lltracker.cpp
+++ b/indra/newview/lltracker.cpp
@@ -782,7 +782,7 @@ void LLTracker::cacheLandmarkPosition()
 		}
 		else
 		{
-			llwarns << "LLTracker couldn't find home pos" << llendl;
+			LL_WARNS() << "LLTracker couldn't find home pos" << LL_ENDL;
 			mTrackedLandmarkAssetID.setNull();
 			mTrackedLandmarkItemID.setNull();
 		}
diff --git a/indra/newview/lltranslate.cpp b/indra/newview/lltranslate.cpp
index f3d8de1904..7e80d72dec 100755
--- a/indra/newview/lltranslate.cpp
+++ b/indra/newview/lltranslate.cpp
@@ -284,7 +284,7 @@ void LLTranslate::TranslationReceiver::completedRaw(
 			err_msg = LLTrans::getString("TranslationResponseParseError");
 		}
 
-		llwarns << "Translation request failed: " << err_msg << llendl;
+		LL_WARNS() << "Translation request failed: " << err_msg << LL_ENDL;
 		handleFailure(status, err_msg);
 	}
 }
diff --git a/indra/newview/lluploadfloaterobservers.cpp b/indra/newview/lluploadfloaterobservers.cpp
index 1d777b3f7f..248f1bf1d5 100755
--- a/indra/newview/lluploadfloaterobservers.cpp
+++ b/indra/newview/lluploadfloaterobservers.cpp
@@ -35,8 +35,8 @@ LLUploadModelPremissionsResponder::LLUploadModelPremissionsResponder(const LLHan
 
 void LLUploadModelPremissionsResponder::errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 {
-	llwarns << "LLUploadModelPremissionsResponder error [status:"
-			<< status << "]: " << content << llendl;
+	LL_WARNS() << "LLUploadModelPremissionsResponder error [status:"
+			<< status << "]: " << content << LL_ENDL;
 
 	LLUploadPermissionsObserver* observer = mObserverHandle.get();
 
diff --git a/indra/newview/llurl.cpp b/indra/newview/llurl.cpp
index aa90d16c67..01a81c5f83 100755
--- a/indra/newview/llurl.cpp
+++ b/indra/newview/llurl.cpp
@@ -126,13 +126,13 @@ void LLURL::init(const char * url)
 	strncpy(mPath,leftover_url, LL_MAX_PATH -1);		/* Flawfinder: ignore */
 	mPath[LL_MAX_PATH -1] = '\0';
 
-//	llinfos << url << "  decomposed into: " << llendl;
-//	llinfos << "  URI : <" << mURI << ">" << llendl;
-//	llinfos << "  Auth: <" << mAuthority << ">" << llendl;
-//	llinfos << "  Path: <" << mPath << ">" << llendl;
-//	llinfos << "  File: <" << mFilename << ">" << llendl;
-//	llinfos << "  Ext : <" << mExtension << ">" << llendl;
-//	llinfos << "  Tag : <" << mTag << ">" << llendl;
+//	LL_INFOS() << url << "  decomposed into: " << LL_ENDL;
+//	LL_INFOS() << "  URI : <" << mURI << ">" << LL_ENDL;
+//	LL_INFOS() << "  Auth: <" << mAuthority << ">" << LL_ENDL;
+//	LL_INFOS() << "  Path: <" << mPath << ">" << LL_ENDL;
+//	LL_INFOS() << "  File: <" << mFilename << ">" << LL_ENDL;
+//	LL_INFOS() << "  Ext : <" << mExtension << ">" << LL_ENDL;
+//	LL_INFOS() << "  Tag : <" << mTag << ">" << LL_ENDL;
 }
 
 void LLURL::cleanup()
diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp
index 00b15a5f26..9634098038 100755
--- a/indra/newview/llurldispatcher.cpp
+++ b/indra/newview/llurldispatcher.cpp
@@ -150,7 +150,7 @@ bool LLURLDispatcherImpl::dispatchApp(const LLSLURL& slurl,
 									  LLMediaCtrl* web,
 									  bool trusted_browser)
 {
-	llinfos << "cmd: " << slurl.getAppCmd() << " path: " << slurl.getAppPath() << " query: " << slurl.getAppQuery() << llendl;
+	LL_INFOS() << "cmd: " << slurl.getAppCmd() << " path: " << slurl.getAppPath() << " query: " << slurl.getAppQuery() << LL_ENDL;
 	const LLSD& query_map = LLURI::queryMap(slurl.getAppQuery());
 	bool handled = LLCommandDispatcher::dispatch(
 			slurl.getAppCmd(), slurl.getAppPath(), query_map, web, nav_type, trusted_browser);
diff --git a/indra/newview/llurlhistory.cpp b/indra/newview/llurlhistory.cpp
index dd17068be5..e0da1e7fe8 100755
--- a/indra/newview/llurlhistory.cpp
+++ b/indra/newview/llurlhistory.cpp
@@ -48,15 +48,15 @@ bool LLURLHistory::loadFile(const std::string& filename)
 
 		if (file.is_open())
 		{
-			llinfos << "Loading history.xml file at " << filename << llendl;
+			LL_INFOS() << "Loading history.xml file at " << filename << LL_ENDL;
 			LLSDSerialize::fromXML(data, file);
 		}
 
 		if (data.isUndefined())
 		{
-			llinfos << "file missing, ill-formed, "
+			LL_INFOS() << "file missing, ill-formed, "
 				"or simply undefined; not changing the"
-				" file" << llendl;
+				" file" << LL_ENDL;
 			sHistorySD = LLSD();
 			return false;
 		}
@@ -71,7 +71,7 @@ bool LLURLHistory::saveFile(const std::string& filename)
 	std::string temp_str = gDirUtilp->getLindenUserDir();
 	if( temp_str.empty() )
 	{
-		llinfos << "Can't save URL history - no user directory set yet." << llendl;
+		LL_INFOS() << "Can't save URL history - no user directory set yet." << LL_ENDL;
 		return false;
 	}
 
@@ -79,7 +79,7 @@ bool LLURLHistory::saveFile(const std::string& filename)
 	llofstream out(temp_str);
 	if (!out.good())
 	{
-		llwarns << "Unable to open " << filename << " for output." << llendl;
+		LL_WARNS() << "Unable to open " << filename << " for output." << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llurlwhitelist.cpp b/indra/newview/llurlwhitelist.cpp
index 72029203d9..8211ce12f6 100755
--- a/indra/newview/llurlwhitelist.cpp
+++ b/indra/newview/llurlwhitelist.cpp
@@ -117,7 +117,7 @@ bool LLUrlWhiteList::save ()
 
 	if (resolvedFilename.empty())
 	{
-		llinfos << "No per-user dir for saving URL whitelist - presumably not logged in yet.  Skipping." << llendl;
+		LL_INFOS() << "No per-user dir for saving URL whitelist - presumably not logged in yet.  Skipping." << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp
index 5c2dd20ec3..df65a637b7 100755
--- a/indra/newview/llviewerassetstorage.cpp
+++ b/indra/newview/llviewerassetstorage.cpp
@@ -117,7 +117,7 @@ void LLViewerAssetStorage::storeAssetData(
 {
 	LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
 	LL_DEBUGS("AssetStorage") << "LLViewerAssetStorage::storeAssetData (legacy) " << tid << ":" << LLAssetType::lookup(asset_type)
-			<< " ASSET_ID: " << asset_id << llendl;
+			<< " ASSET_ID: " << asset_id << LL_ENDL;
 	
 	if (mUpstreamHost.isOk())
 	{
@@ -137,7 +137,7 @@ void LLViewerAssetStorage::storeAssetData(
 			if (asset_size < 1)
 			{
 				// This can happen if there's a bug in our code or if the VFS has been corrupted.
-				llwarns << "LLViewerAssetStorage::storeAssetData()  Data _should_ already be in the VFS, but it's not! " << asset_id << llendl;
+				LL_WARNS() << "LLViewerAssetStorage::storeAssetData()  Data _should_ already be in the VFS, but it's not! " << asset_id << LL_ENDL;
 				// LLAssetStorage metric: Zero size VFS
 				reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" );
 
@@ -174,11 +174,11 @@ void LLViewerAssetStorage::storeAssetData(
 				if( bytes_read == asset_size )
 				{
 					req->mDataSentInFirstPacket = TRUE;
-					//llinfos << "LLViewerAssetStorage::createAsset sending data in first packet" << llendl;
+					//LL_INFOS() << "LLViewerAssetStorage::createAsset sending data in first packet" << LL_ENDL;
 				}
 				else
 				{
-					llwarns << "Probable corruption in VFS file, aborting store asset data" << llendl;
+					LL_WARNS() << "Probable corruption in VFS file, aborting store asset data" << LL_ENDL;
 
 					// LLAssetStorage metric: VFS corrupt - bogus size
 					reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, asset_size, MR_VFS_CORRUPTION, __FILE__, __LINE__, "VFS corruption" );
@@ -207,7 +207,7 @@ void LLViewerAssetStorage::storeAssetData(
 		}
 		else
 		{
-			llwarns << "AssetStorage: attempt to upload non-existent vfile " << asset_id << ":" << LLAssetType::lookup(asset_type) << llendl;
+			LL_WARNS() << "AssetStorage: attempt to upload non-existent vfile " << asset_id << ":" << LLAssetType::lookup(asset_type) << LL_ENDL;
 			// LLAssetStorage metric: Zero size VFS
 			reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_ZERO_SIZE, __FILE__, __LINE__, "The file didn't exist or was zero length (VFS - can't tell which)" );
 			if (callback)
@@ -218,7 +218,7 @@ void LLViewerAssetStorage::storeAssetData(
 	}
 	else
 	{
-		llwarns << "Attempt to move asset store request upstream w/o valid upstream provider" << llendl;
+		LL_WARNS() << "Attempt to move asset store request upstream w/o valid upstream provider" << LL_ENDL;
 		// LLAssetStorage metric: Upstream provider dead
 		reportMetric( asset_id, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_NO_UPSTREAM, __FILE__, __LINE__, "No upstream provider" );
 		if (callback)
@@ -243,14 +243,14 @@ void LLViewerAssetStorage::storeAssetData(
 	{
 		// LLAssetStorage metric: no filename
 		reportMetric( LLUUID::null, asset_type, LLStringUtil::null, LLUUID::null, 0, MR_VFS_CORRUPTION, __FILE__, __LINE__, "Filename missing" );
-		llerrs << "No filename specified" << llendl;
+		LL_ERRS() << "No filename specified" << LL_ENDL;
 		return;
 	}
 	
 	LLAssetID asset_id = tid.makeAssetID(gAgent.getSecureSessionID());
-	LL_DEBUGS("AssetStorage") << "LLViewerAssetStorage::storeAssetData (legacy)" << asset_id << ":" << LLAssetType::lookup(asset_type) << llendl;
+	LL_DEBUGS("AssetStorage") << "LLViewerAssetStorage::storeAssetData (legacy)" << asset_id << ":" << LLAssetType::lookup(asset_type) << LL_ENDL;
 
-	LL_DEBUGS("AssetStorage") << "ASSET_ID: " << asset_id << llendl;
+	LL_DEBUGS("AssetStorage") << "ASSET_ID: " << asset_id << LL_ENDL;
 
 	S32 size = 0;
 	LLFILE* fp = LLFile::fopen(filename, "rb");
@@ -369,7 +369,7 @@ void LLViewerAssetStorage::_queueDataRequest(
 			tpvf.setAsset(uuid, atype);
 			tpvf.setCallback(downloadCompleteCallback, req);
 
-			LL_DEBUGS("AssetStorage") << "Starting transfer for " << uuid << llendl;
+			LL_DEBUGS("AssetStorage") << "Starting transfer for " << uuid << LL_ENDL;
 			LLTransferTargetChannel *ttcp = gTransferManager.getTargetChannel(mUpstreamHost, LLTCT_ASSET);
 			ttcp->requestTransfer(spa, tpvf, 100.f + (is_priority ? 1.f : 0.f));
 
@@ -379,7 +379,7 @@ void LLViewerAssetStorage::_queueDataRequest(
 	else
 	{
 		// uh-oh, we shouldn't have gotten here
-		llwarns << "Attempt to move asset data request upstream w/o valid upstream provider" << llendl;
+		LL_WARNS() << "Attempt to move asset data request upstream w/o valid upstream provider" << LL_ENDL;
 		if (callback)
 		{
 			callback(mVFS, uuid, atype, user_data, LL_ERR_CIRCUIT_GONE, LL_EXSTAT_NO_UPSTREAM);
diff --git a/indra/newview/llvieweraudio.cpp b/indra/newview/llvieweraudio.cpp
index c1518833bd..885e7d7e92 100755
--- a/indra/newview/llvieweraudio.cpp
+++ b/indra/newview/llvieweraudio.cpp
@@ -126,7 +126,7 @@ void LLViewerAudio::startInternetStreamWithAutoFade(std::string streamURI)
 			break;
 
 		default:
-			llwarns << "Unknown fading state: " << mFadeState << llendl;
+			LL_WARNS() << "Unknown fading state: " << mFadeState << LL_ENDL;
 			break;
 	}
 }
@@ -292,7 +292,7 @@ void LLViewerAudio::onTeleportFailed()
 		if (parcel)
 		{
 			mNextStreamURI = parcel->getMusicURL();
-			llinfos << "Teleport failed -- setting music stream to " << mNextStreamURI << llendl;
+			LL_INFOS() << "Teleport failed -- setting music stream to " << mNextStreamURI << LL_ENDL;
 		}
 	}
 	mWasPlaying = false;
@@ -310,7 +310,7 @@ void LLViewerAudio::onTeleportFinished(const LLVector3d& pos, const bool& local)
 		if (parcel)
 		{
 			mNextStreamURI = parcel->getMusicURL();
-			llinfos << "Intraparcel teleport -- setting music stream to " << mNextStreamURI << llendl;
+			LL_INFOS() << "Intraparcel teleport -- setting music stream to " << mNextStreamURI << LL_ENDL;
 		}
 	}
 	mWasPlaying = false;
@@ -320,7 +320,7 @@ void init_audio()
 {
 	if (!gAudiop) 
 	{
-		llwarns << "Failed to create an appropriate Audio Engine" << llendl;
+		LL_WARNS() << "Failed to create an appropriate Audio Engine" << LL_ENDL;
 		return;
 	}
 	LLVector3d lpos_global = gAgentCamera.getCameraPositionGlobal();
diff --git a/indra/newview/llviewerchat.cpp b/indra/newview/llviewerchat.cpp
index 93687dbd5f..1c3c547bc1 100755
--- a/indra/newview/llviewerchat.cpp
+++ b/indra/newview/llviewerchat.cpp
@@ -241,7 +241,7 @@ std::string LLViewerChat::getSenderSLURL(const LLChat& chat, const LLSD& args)
 		return getObjectImSLURL(chat, args);
 
 	default:
-		llwarns << "Getting SLURL for an unsupported sender type: " << chat.mSourceType << llendl;
+		LL_WARNS() << "Getting SLURL for an unsupported sender type: " << chat.mSourceType << LL_ENDL;
 	}
 
 	return LLStringUtil::null;
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index afbb59e723..5523b541a9 100755
--- a/indra/newview/llviewercontrol.cpp
+++ b/indra/newview/llviewercontrol.cpp
@@ -262,7 +262,7 @@ static bool handleGammaChanged(const LLSD& newvalue)
 		// Only save it if it's changed
 		if (!gViewerWindow->getWindow()->setGamma(gamma))
 		{
-			llwarns << "setGamma failed!" << llendl;
+			LL_WARNS() << "setGamma failed!" << LL_ENDL;
 		}
 	}
 
@@ -497,7 +497,7 @@ bool handleVelocityInterpolate(const LLSD& newvalue)
 		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
 		gAgent.sendReliableMessage();
-		llinfos << "Velocity Interpolation On" << llendl;
+		LL_INFOS() << "Velocity Interpolation On" << LL_ENDL;
 	}
 	else
 	{
@@ -506,7 +506,7 @@ bool handleVelocityInterpolate(const LLSD& newvalue)
 		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
 		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
 		gAgent.sendReliableMessage();
-		llinfos << "Velocity Interpolation Off" << llendl;
+		LL_INFOS() << "Velocity Interpolation Off" << LL_ENDL;
 	}
 	return true;
 }
@@ -783,13 +783,13 @@ static LLCachedControl<std::string> test_BrowserHomePage("BrowserHomePage", "hah
 
 void test_cached_control()
 {
-#define do { TEST_LLCC(T, V) if((T)mySetting_##T != V) llerrs << "Fail "#T << llendl; } while(0)
+#define do { TEST_LLCC(T, V) if((T)mySetting_##T != V) LL_ERRS() << "Fail "#T << LL_ENDL; } while(0)
 	TEST_LLCC(U32, 666);
 	TEST_LLCC(S32, (S32)-666);
 	TEST_LLCC(F32, (F32)-666.666);
 	TEST_LLCC(bool, true);
 	TEST_LLCC(BOOL, FALSE);
-	if((std::string)mySetting_string != "Default String Value") llerrs << "Fail string" << llendl;
+	if((std::string)mySetting_string != "Default String Value") LL_ERRS() << "Fail string" << LL_ENDL;
 	TEST_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f));
 	TEST_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f));
 	TEST_LLCC(LLRect, LLRect(0, 0, 100, 500));
@@ -798,7 +798,7 @@ void test_cached_control()
 	TEST_LLCC(LLColor4U, LLColor4U(255, 200, 100, 255));
 //There's no LLSD comparsion for LLCC yet. TEST_LLCC(LLSD, test_llsd); 
 
-	if((std::string)test_BrowserHomePage != "http://www.secondlife.com") llerrs << "Fail BrowserHomePage" << llendl;
+	if((std::string)test_BrowserHomePage != "http://www.secondlife.com") LL_ERRS() << "Fail BrowserHomePage" << LL_ENDL;
 }
 #endif // TEST_CACHED_CONTROL
 
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 557403b914..965c6ffbc6 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -206,14 +206,14 @@ void display_update_camera()
 	LLWorld::getInstance()->setLandFarClip(final_far);
 }
 
-// Write some stats to llinfos
+// Write some stats to LL_INFOS()
 void display_stats()
 {
 	F32 fps_log_freq = gSavedSettings.getF32("FPSLogFrequency");
 	if (fps_log_freq > 0.f && gRecentFPSTime.getElapsedTimeF32() >= fps_log_freq)
 	{
 		F32 fps = gRecentFrameCount / fps_log_freq;
-		llinfos << llformat("FPS: %.02f", fps) << llendl;
+		LL_INFOS() << llformat("FPS: %.02f", fps) << LL_ENDL;
 		gRecentFrameCount = 0;
 		gRecentFPSTime.reset();
 	}
@@ -222,7 +222,7 @@ void display_stats()
 	{
 		gMemoryAllocated = LLMemory::getCurrentRSS();
 		U32 memory = (U32)(gMemoryAllocated / (1024*1024));
-		llinfos << llformat("MEMORY: %d MB", memory) << llendl;
+		LL_INFOS() << llformat("MEMORY: %d MB", memory) << LL_ENDL;
 		LLMemory::logMemoryInfo(TRUE) ;
 		gRecentMemoryTime.reset();
 	}
@@ -1574,7 +1574,7 @@ void render_disconnected_background()
 	gGL.color4f(1,1,1,1);
 	if (!gDisconnectedImagep && gDisconnected)
 	{
-		llinfos << "Loading last bitmap..." << llendl;
+		LL_INFOS() << "Loading last bitmap..." << LL_ENDL;
 
 		std::string temp_str;
 		temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + SCREEN_LAST_FILENAME;
@@ -1582,14 +1582,14 @@ void render_disconnected_background()
 		LLPointer<LLImageBMP> image_bmp = new LLImageBMP;
 		if( !image_bmp->load(temp_str) )
 		{
-			//llinfos << "Bitmap load failed" << llendl;
+			//LL_INFOS() << "Bitmap load failed" << LL_ENDL;
 			return;
 		}
 		
 		LLPointer<LLImageRaw> raw = new LLImageRaw;
 		if (!image_bmp->decode(raw, 0.0f))
 		{
-			llinfos << "Bitmap decode failed" << llendl;
+			LL_INFOS() << "Bitmap decode failed" << LL_ENDL;
 			gDisconnectedImagep = NULL;
 			return;
 		}
diff --git a/indra/newview/llviewerdisplayname.cpp b/indra/newview/llviewerdisplayname.cpp
index f81206ffec..3d794f0d91 100755
--- a/indra/newview/llviewerdisplayname.cpp
+++ b/indra/newview/llviewerdisplayname.cpp
@@ -62,8 +62,8 @@ public:
 	// only care about errors
 	/*virtual*/ void errorWithContent(U32 status, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "LLSetDisplayNameResponder error [status:"
-				<< status << "]: " << content << llendl;
+		LL_WARNS() << "LLSetDisplayNameResponder error [status:"
+				<< status << "]: " << content << LL_ENDL;
 		LLViewerDisplayName::sSetDisplayNameSignal(false, "", LLSD());
 		LLViewerDisplayName::sSetDisplayNameSignal.disconnect_all_slots();
 	}
@@ -103,7 +103,7 @@ void LLViewerDisplayName::set(const std::string& display_name, const set_name_sl
 	change_array.append(av_name.getDisplayName());
 	change_array.append(display_name);
 	
-	llinfos << "Set name POST to " << cap_url << llendl;
+	LL_INFOS() << "Set name POST to " << cap_url << LL_ENDL;
 
 	// Record our caller for when the server sends back a reply
 	sSetDisplayNameSignal.connect(slot);
@@ -132,7 +132,7 @@ public:
 		std::string reason = body["reason"].asString();
 		LLSD content = body["content"];
 
-		llinfos << "status " << status << " reason " << reason << llendl;
+		LL_INFOS() << "status " << status << " reason " << reason << LL_ENDL;
 
 		// If viewer's concept of display name is out-of-date, the set request
 		// will fail with 409 Conflict.  If that happens, fetch up-to-date
@@ -173,9 +173,9 @@ class LLDisplayNameUpdate : public LLHTTPNode
 		LLAvatarName av_name;
 		av_name.fromLLSD( name_data );
 
-		llinfos << "name-update now " << LLDate::now()
+		LL_INFOS() << "name-update now " << LLDate::now()
 			<< " next_update " << LLDate(av_name.mNextUpdate)
-			<< llendl;
+			<< LL_ENDL;
 
 		// Name expiration time may be provided in headers, or we may use a
 		// default value
diff --git a/indra/newview/llviewerfoldertype.cpp b/indra/newview/llviewerfoldertype.cpp
index a179b61cff..8a96f22027 100755
--- a/indra/newview/llviewerfoldertype.cpp
+++ b/indra/newview/llviewerfoldertype.cpp
@@ -155,7 +155,7 @@ bool LLViewerFolderDictionary::initEnsemblesFromFile()
 	LLXmlTree folder_def;
 	if (!folder_def.parseFile(xml_filename))
 	{
-		llerrs << "Failed to parse folders file " << xml_filename << llendl;
+		LL_ERRS() << "Failed to parse folders file " << xml_filename << LL_ENDL;
 		return false;
 	}
 
@@ -166,7 +166,7 @@ bool LLViewerFolderDictionary::initEnsemblesFromFile()
 	{
 		if (!ensemble->hasName("ensemble"))
 		{
-			llwarns << "Invalid ensemble definition node " << ensemble->getName() << llendl;
+			LL_WARNS() << "Invalid ensemble definition node " << ensemble->getName() << LL_ENDL;
 			continue;
 		}
 
@@ -174,14 +174,14 @@ bool LLViewerFolderDictionary::initEnsemblesFromFile()
 		static LLStdStringHandle ensemble_num_string = LLXmlTree::addAttributeString("foldertype_num");
 		if (!ensemble->getFastAttributeS32(ensemble_num_string, ensemble_type))
 		{
-			llwarns << "No ensemble type defined" << llendl;
+			LL_WARNS() << "No ensemble type defined" << LL_ENDL;
 			continue;
 		}
 
 
 		if (ensemble_type < S32(LLFolderType::FT_ENSEMBLE_START) || ensemble_type > S32(LLFolderType::FT_ENSEMBLE_END))
 		{
-			llwarns << "Exceeded maximum ensemble index" << LLFolderType::FT_ENSEMBLE_END << llendl;
+			LL_WARNS() << "Exceeded maximum ensemble index" << LLFolderType::FT_ENSEMBLE_END << LL_ENDL;
 			break;
 		}
 
@@ -189,7 +189,7 @@ bool LLViewerFolderDictionary::initEnsemblesFromFile()
 		static LLStdStringHandle xui_name_string = LLXmlTree::addAttributeString("xui_name");
 		if (!ensemble->getFastAttributeString(xui_name_string, xui_name))
 		{
-			llwarns << "No xui name defined" << llendl;
+			LL_WARNS() << "No xui name defined" << LL_ENDL;
 			continue;
 		}
 
@@ -197,7 +197,7 @@ bool LLViewerFolderDictionary::initEnsemblesFromFile()
 		static LLStdStringHandle icon_name_string = LLXmlTree::addAttributeString("icon_name");
 		if (!ensemble->getFastAttributeString(icon_name_string, icon_name))
 		{
-			llwarns << "No ensemble icon name defined" << llendl;
+			LL_WARNS() << "No ensemble icon name defined" << LL_ENDL;
 			continue;
 		}
 
diff --git a/indra/newview/llviewergenericmessage.cpp b/indra/newview/llviewergenericmessage.cpp
index f8a2be14d4..3df53a4a30 100755
--- a/indra/newview/llviewergenericmessage.cpp
+++ b/indra/newview/llviewergenericmessage.cpp
@@ -78,7 +78,7 @@ void process_generic_message(LLMessageSystem* msg, void**)
 	msg->getUUID("AgentData", "AgentID", agent_id);
 	if (agent_id != gAgent.getID())
 	{
-		llwarns << "GenericMessage for wrong agent" << llendl;
+		LL_WARNS() << "GenericMessage for wrong agent" << LL_ENDL;
 		return;
 	}
 
@@ -89,7 +89,7 @@ void process_generic_message(LLMessageSystem* msg, void**)
 
 	if(!gGenericDispatcher.dispatch(request, invoice, strings))
 	{
-		llwarns << "GenericMessage " << request << " failed to dispatch" 
-			<< llendl;
+		LL_WARNS() << "GenericMessage " << request << " failed to dispatch" 
+			<< LL_ENDL;
 	}
 }
diff --git a/indra/newview/llviewergesture.cpp b/indra/newview/llviewergesture.cpp
index 3f35a5001d..f30279d1e9 100755
--- a/indra/newview/llviewergesture.cpp
+++ b/indra/newview/llviewergesture.cpp
@@ -194,13 +194,13 @@ void LLViewerGestureList::xferCallback(void *data, S32 size, void** /*user_data*
 
 		if (end - buffer > size)
 		{
-			llerrs << "Read off of end of array, error in serialization" << llendl;
+			LL_ERRS() << "Read off of end of array, error in serialization" << LL_ENDL;
 		}
 
 		gGestureList.mIsLoaded = TRUE;
 	}
 	else
 	{
-		llwarns << "Unable to load gesture list!" << llendl;
+		LL_WARNS() << "Unable to load gesture list!" << LL_ENDL;
 	}
 }
diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp
index fff9821e86..a4773646ef 100755
--- a/indra/newview/llviewerinventory.cpp
+++ b/indra/newview/llviewerinventory.cpp
@@ -303,8 +303,8 @@ LLViewerInventoryItem::LLViewerInventoryItem(const LLViewerInventoryItem* other)
 	copyViewerItem(other);
 	if (!mIsComplete)
 	{
-		llwarns << "LLViewerInventoryItem copy constructor for incomplete item"
-			<< mUUID << llendl;
+		LL_WARNS() << "LLViewerInventoryItem copy constructor for incomplete item"
+			<< mUUID << LL_ENDL;
 	}
 }
 
@@ -347,8 +347,8 @@ void LLViewerInventoryItem::cloneViewerItem(LLPointer<LLViewerInventoryItem>& ne
 
 void LLViewerInventoryItem::removeFromServer()
 {
-	lldebugs << "Removing inventory item " << mUUID << " from server."
-			 << llendl;
+	LL_DEBUGS() << "Removing inventory item " << mUUID << " from server."
+			 << LL_ENDL;
 
 	LLInventoryModel::LLCategoryUpdate up(mParentUUID, -1);
 	gInventory.accountForUpdate(up);
@@ -369,15 +369,15 @@ void LLViewerInventoryItem::updateServer(BOOL is_new) const
 	{
 		// *FIX: deal with this better.
 		// If we're crashing here then the UI is incorrectly enabled.
-		llerrs << "LLViewerInventoryItem::updateServer() - for incomplete item"
-			   << llendl;
+		LL_ERRS() << "LLViewerInventoryItem::updateServer() - for incomplete item"
+			   << LL_ENDL;
 		return;
 	}
 	if(gAgent.getID() != mPermissions.getOwner())
 	{
 		// *FIX: deal with this better.
-		llwarns << "LLViewerInventoryItem::updateServer() - for unowned item"
-				<< llendl;
+		LL_WARNS() << "LLViewerInventoryItem::updateServer() - for unowned item"
+				<< LL_ENDL;
 		return;
 	}
 	LLInventoryModel::LLCategoryUpdate up(mParentUUID, is_new ? 1 : 0);
@@ -416,7 +416,7 @@ void LLViewerInventoryItem::fetchFromServer(void) const
 		}
 		else
 		{
-			llwarns << "Agent Region is absent" << llendl;
+			LL_WARNS() << "Agent Region is absent" << LL_ENDL;
 		}
 
 		if (!url.empty())
@@ -639,8 +639,8 @@ void LLViewerInventoryCategory::updateServer(BOOL is_new) const
 
 void LLViewerInventoryCategory::removeFromServer( void )
 {
-	llinfos << "Removing inventory category " << mUUID << " from server."
-			<< llendl;
+	LL_INFOS() << "Removing inventory category " << mUUID << " from server."
+			<< LL_ENDL;
 	// communicate that change with the server.
 	if(LLFolderType::lookupIsProtectedType(mPreferredType))
 	{
@@ -701,7 +701,7 @@ bool LLViewerInventoryCategory::fetch()
 		}
 		else
 		{
-			llwarns << "agent region is null" << llendl;
+			LL_WARNS() << "agent region is null" << LL_ENDL;
 		}
 		if (!url.empty()) //Capability found.  Build up LLSD and use it.
 		{
@@ -709,7 +709,7 @@ bool LLViewerInventoryCategory::fetch()
 		}
 		else
 		{	//Deprecated, but if we don't have a capability, use the old system.
-			llinfos << "FetchInventoryDescendents2 capability not found.  Using deprecated UDP message." << llendl;
+			LL_INFOS() << "FetchInventoryDescendents2 capability not found.  Using deprecated UDP message." << LL_ENDL;
 			LLMessageSystem* msg = gMessageSystem;
 			msg->newMessage("FetchInventoryDescendents");
 			msg->nextBlock("AgentData");
@@ -791,8 +791,8 @@ bool LLViewerInventoryCategory::importFileLocal(LLFILE* fp)
 		}
 		else
 		{
-			llwarns << "unknown keyword '" << keyword
-					<< "' in inventory import category "  << mUUID << llendl;
+			LL_WARNS() << "unknown keyword '" << keyword
+					<< "' in inventory import category "  << mUUID << LL_ENDL;
 		}
 	}
 	return true;
@@ -905,7 +905,7 @@ LLInventoryCallbackManager::LLInventoryCallbackManager() :
 {
 	if( sInstance != NULL )
 	{
-		llwarns << "LLInventoryCallbackManager::LLInventoryCallbackManager: unexpected multiple instances" << llendl;
+		LL_WARNS() << "LLInventoryCallbackManager::LLInventoryCallbackManager: unexpected multiple instances" << LL_ENDL;
 		return;
 	}
 	sInstance = this;
@@ -915,7 +915,7 @@ LLInventoryCallbackManager::~LLInventoryCallbackManager()
 {
 	if( sInstance != this )
 	{
-		llwarns << "LLInventoryCallbackManager::~LLInventoryCallbackManager: unexpected multiple instances" << llendl;
+		LL_WARNS() << "LLInventoryCallbackManager::~LLInventoryCallbackManager: unexpected multiple instances" << LL_ENDL;
 		return;
 	}
 	sInstance = NULL;
@@ -1099,12 +1099,12 @@ void link_inventory_item(
 	const LLInventoryObject *baseobj = gInventory.getObject(item_id);
 	if (!baseobj)
 	{
-		llwarns << "attempt to link to unknown item, linked-to-item's itemID " << item_id << llendl;
+		LL_WARNS() << "attempt to link to unknown item, linked-to-item's itemID " << item_id << LL_ENDL;
 		return;
 	}
 	if (baseobj && baseobj->getIsLinkType())
 	{
-		llwarns << "attempt to create a link to a link, linked-to-item's itemID " << item_id << llendl;
+		LL_WARNS() << "attempt to create a link to a link, linked-to-item's itemID " << item_id << LL_ENDL;
 		return;
 	}
 
@@ -1113,7 +1113,7 @@ void link_inventory_item(
 		// Fail if item can be found but is of a type that can't be linked.
 		// Arguably should fail if the item can't be found too, but that could
 		// be a larger behavioral change.
-		llwarns << "attempt to link an unlinkable item, type = " << baseobj->getActualType() << llendl;
+		LL_WARNS() << "attempt to link an unlinkable item, type = " << baseobj->getActualType() << LL_ENDL;
 		return;
 	}
 	
@@ -1134,7 +1134,7 @@ void link_inventory_item(
 
 #if 1 // debugging stuff
 	LLViewerInventoryCategory* cat = gInventory.getCategory(parent_id);
-	lldebugs << "cat: " << cat << llendl;
+	LL_DEBUGS() << "cat: " << cat << LL_ENDL;
 	
 #endif
 	LLMessageSystem* msg = gMessageSystem;
@@ -1347,7 +1347,7 @@ void menu_create_inventory_item(LLInventoryPanel* panel, LLFolderBridge *bridge,
 		}
 		else
 		{
-			llwarns << "Can't create unrecognized type " << type_name << llendl;
+			LL_WARNS() << "Can't create unrecognized type " << type_name << LL_ENDL;
 		}
 	}
 	panel->getRootFolder()->setNeedsAutoRename(TRUE);	
@@ -1582,7 +1582,7 @@ LLViewerInventoryItem *LLViewerInventoryItem::getLinkedItem() const
 		LLViewerInventoryItem *linked_item = gInventory.getItem(mAssetUUID);
 		if (linked_item && linked_item->getIsLinkType())
 		{
-			llwarns << "Warning: Accessing link to link" << llendl;
+			LL_WARNS() << "Warning: Accessing link to link" << LL_ENDL;
 			return NULL;
 		}
 		return linked_item;
diff --git a/indra/newview/llviewerjointattachment.cpp b/indra/newview/llviewerjointattachment.cpp
index 0e99e161c4..888decd3be 100755
--- a/indra/newview/llviewerjointattachment.cpp
+++ b/indra/newview/llviewerjointattachment.cpp
@@ -171,7 +171,7 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
 	// Same object reattached
 	if (isObjectAttached(object))
 	{
-		llinfos << "(same object re-attached)" << llendl;
+		LL_INFOS() << "(same object re-attached)" << LL_ENDL;
 		removeObject(object);
 		// Pass through anyway to let setupDrawable()
 		// re-connect object to the joint correctly
@@ -181,7 +181,7 @@ BOOL LLViewerJointAttachment::addObject(LLViewerObject* object)
 	// Request detach, and kill the object in the meantime.
 	if (getAttachedObject(object->getAttachmentItemID()))
 	{
-		llinfos << "(same object re-attached)" << llendl;
+		LL_INFOS() << "(same object re-attached)" << LL_ENDL;
 		object->markDead();
 
 		// If this happens to be attached to self, then detach.
@@ -233,7 +233,7 @@ void LLViewerJointAttachment::removeObject(LLViewerObject *object)
 	}
 	if (iter == mAttachedObjects.end())
 	{
-		llwarns << "Could not find object to detach" << llendl;
+		LL_WARNS() << "Could not find object to detach" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 6cf39d319b..76fb58b87b 100755
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -551,7 +551,7 @@ void LLViewerJointMesh::dump()
 {
 	if (mValid)
 	{
-		llinfos << "Usable LOD " << mName << llendl;
+		LL_INFOS() << "Usable LOD " << mName << LL_ENDL;
 	}
 }
 
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index f4155df4d1..ac968cfc67 100755
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -107,7 +107,7 @@ NDOF_HotPlugResult LLViewerJoystick::HotPlugAddCallback(NDOF_Device *dev)
 	LLViewerJoystick* joystick(LLViewerJoystick::getInstance());
 	if (joystick->mDriverState == JDS_UNINITIALIZED)
 	{
-        llinfos << "HotPlugAddCallback: will use device:" << llendl;
+        LL_INFOS() << "HotPlugAddCallback: will use device:" << LL_ENDL;
 		ndof_dump(dev);
 		joystick->mNdofDev = dev;
         joystick->mDriverState = JDS_INITIALIZED;
@@ -125,8 +125,8 @@ void LLViewerJoystick::HotPlugRemovalCallback(NDOF_Device *dev)
 	LLViewerJoystick* joystick(LLViewerJoystick::getInstance());
 	if (joystick->mNdofDev == dev)
 	{
-        llinfos << "HotPlugRemovalCallback: joystick->mNdofDev=" 
-				<< joystick->mNdofDev << "; removed device:" << llendl;
+        LL_INFOS() << "HotPlugRemovalCallback: joystick->mNdofDev=" 
+				<< joystick->mNdofDev << "; removed device:" << LL_ENDL;
 		ndof_dump(dev);
 		joystick->mDriverState = JDS_UNINITIALIZED;
 	}
@@ -215,7 +215,7 @@ void LLViewerJoystick::init(bool autoenable)
 			if (ndof_init_first(mNdofDev, NULL))
 			{
 				mDriverState = JDS_UNINITIALIZED;
-				llwarns << "ndof_init_first FAILED" << llendl;
+				LL_WARNS() << "ndof_init_first FAILED" << LL_ENDL;
 			}
 			else
 			{
@@ -259,8 +259,8 @@ void LLViewerJoystick::init(bool autoenable)
 		// No device connected, don't change any settings
 	}
 	
-	llinfos << "ndof: mDriverState=" << mDriverState << "; mNdofDev=" 
-			<< mNdofDev << "; libinit=" << libinit << llendl;
+	LL_INFOS() << "ndof: mDriverState=" << mDriverState << "; mNdofDev=" 
+			<< mNdofDev << "; libinit=" << libinit << LL_ENDL;
 #endif
 }
 
@@ -270,7 +270,7 @@ void LLViewerJoystick::terminate()
 #if LIB_NDOF
 
 	ndof_libcleanup();
-	llinfos << "Terminated connection with NDOF device." << llendl;
+	LL_INFOS() << "Terminated connection with NDOF device." << LL_ENDL;
 	mDriverState = JDS_UNINITIALIZED;
 #endif
 }
@@ -1101,7 +1101,7 @@ void LLViewerJoystick::setSNDefaults()
 #endif
 	
 	//gViewerWindow->alertXml("CacheWillClear");
-	llinfos << "restoring SpaceNavigator defaults..." << llendl;
+	LL_INFOS() << "restoring SpaceNavigator defaults..." << LL_ENDL;
 	
 	gSavedSettings.setS32("JoystickAxis0", 1); // z (at)
 	gSavedSettings.setS32("JoystickAxis1", 0); // x (slide)
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index e05df2389e..dc004af923 100755
--- a/indra/newview/llviewerkeyboard.cpp
+++ b/indra/newview/llviewerkeyboard.cpp
@@ -274,7 +274,7 @@ F32 get_orbit_rate()
 	if( time < NUDGE_TIME )
 	{
 		F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME;
-		//llinfos << rate << llendl;
+		//LL_INFOS() << rate << LL_ENDL;
 		return rate;
 	}
 	else
@@ -676,7 +676,7 @@ BOOL LLViewerKeyboard::handleKey(KEY translated_key,  MASK translated_mask, BOOL
 		return FALSE;
 	}
 
-	LL_DEBUGS("UserInput") << "keydown -" << translated_key << "-" << llendl;
+	LL_DEBUGS("UserInput") << "keydown -" << translated_key << "-" << LL_ENDL;
 	// skip skipped keys
 	if(mKeysSkippedByUI.find(translated_key) != mKeysSkippedByUI.end()) 
 	{
@@ -837,7 +837,7 @@ S32 LLViewerKeyboard::loadBindings(const std::string& filename)
 
 	if(filename.empty())
 	{
-		llerrs << " No filename specified" << llendl;
+		LL_ERRS() << " No filename specified" << LL_ENDL;
 		return 0;
 	}
 
@@ -869,35 +869,35 @@ S32 LLViewerKeyboard::loadBindings(const std::string& filename)
 
 		if (tokens_read == EOF)
 		{
-			llinfos << "Unexpected end-of-file at line " << line_count << " of key binding file " << filename << llendl;
+			LL_INFOS() << "Unexpected end-of-file at line " << line_count << " of key binding file " << filename << LL_ENDL;
 			fclose(fp);
 			return 0;
 		}
 		else if (tokens_read < 4)
 		{
-			llinfos << "Can't read line " << line_count << " of key binding file " << filename << llendl;
+			LL_INFOS() << "Can't read line " << line_count << " of key binding file " << filename << LL_ENDL;
 			continue;
 		}
 
 		// convert mode
 		if (!modeFromString(mode_string, &mode))
 		{
-			llinfos << "Unknown mode on line " << line_count << " of key binding file " << filename << llendl;
-			llinfos << "Mode must be one of FIRST_PERSON, THIRD_PERSON, EDIT, EDIT_AVATAR" << llendl;
+			LL_INFOS() << "Unknown mode on line " << line_count << " of key binding file " << filename << LL_ENDL;
+			LL_INFOS() << "Mode must be one of FIRST_PERSON, THIRD_PERSON, EDIT, EDIT_AVATAR" << LL_ENDL;
 			continue;
 		}
 
 		// convert key
 		if (!LLKeyboard::keyFromString(key_string, &key))
 		{
-			llinfos << "Can't interpret key on line " << line_count << " of key binding file " << filename << llendl;
+			LL_INFOS() << "Can't interpret key on line " << line_count << " of key binding file " << filename << LL_ENDL;
 			continue;
 		}
 
 		// convert mask
 		if (!LLKeyboard::maskFromString(mask_string, &mask))
 		{
-			llinfos << "Can't interpret mask on line " << line_count << " of key binding file " << filename << llendl;
+			LL_INFOS() << "Can't interpret mask on line " << line_count << " of key binding file " << filename << LL_ENDL;
 			continue;
 		}
 
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 2df028de69..ba7fb4f985 100755
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -166,7 +166,7 @@ public:
 	{
 		if(mMediaImpl->mMimeTypeProbe != NULL)
 		{
-			llerrs << "impl already has an outstanding responder" << llendl;
+			LL_ERRS() << "impl already has an outstanding responder" << LL_ENDL;
 		}
 		
 		mMediaImpl->mMimeTypeProbe = this;
@@ -183,7 +183,7 @@ public:
 		std::string::size_type idx1 = media_type.find_first_of(";");
 		std::string mime_type = media_type.substr(0, idx1);
 
-		lldebugs << "status is " << status << ", media type \"" << media_type << "\"" << llendl;
+		LL_DEBUGS() << "status is " << status << ", media type \"" << media_type << "\"" << LL_ENDL;
 		
 		// 2xx status codes indicate success.
 		// Most 4xx status codes are successful enough for our purposes.
@@ -214,7 +214,7 @@ public:
 		}
 		else
 		{
-			llwarns << "responder failed with status " << status << ", reason " << reason << llendl;
+			LL_WARNS() << "responder failed with status " << status << ", reason " << reason << LL_ENDL;
 		
 			if(mMediaImpl)
 			{
@@ -253,7 +253,7 @@ private:
 		{
 			if(mMediaImpl->mMimeTypeProbe != this)
 			{
-				llerrs << "internal error: mMediaImpl->mMimeTypeProbe != this" << llendl;
+				LL_ERRS() << "internal error: mMediaImpl->mMimeTypeProbe != this" << LL_ENDL;
 			}
 
 			mMediaImpl->mMimeTypeProbe = NULL;
@@ -429,10 +429,10 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s
 	// Try to find media with the same media ID
 	viewer_media_t media_impl = getMediaImplFromTextureID(media_entry->getMediaID());
 	
-	lldebugs << "called, current URL is \"" << media_entry->getCurrentURL() 
+	LL_DEBUGS() << "called, current URL is \"" << media_entry->getCurrentURL() 
 			<< "\", previous URL is \"" << previous_url 
 			<< "\", update_from_self is " << (update_from_self?"true":"false")
-			<< llendl;
+			<< LL_ENDL;
 			
 	bool was_loaded = false;
 	bool needs_navigate = false;
@@ -464,7 +464,7 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s
 				// The current media URL is now empty.  Unload the media source.
 				media_impl->unload();
 			
-				lldebugs << "Unloading media instance (new current URL is empty)." << llendl;
+				LL_DEBUGS() << "Unloading media instance (new current URL is empty)." << LL_ENDL;
 			}
 		}
 		else
@@ -478,9 +478,9 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s
 				needs_navigate = url_changed;
 			}
 			
-			lldebugs << "was_loaded is " << (was_loaded?"true":"false") 
+			LL_DEBUGS() << "was_loaded is " << (was_loaded?"true":"false") 
 					<< ", auto_play is " << (auto_play?"true":"false") 
-					<< ", needs_navigate is " << (needs_navigate?"true":"false") << llendl;
+					<< ", needs_navigate is " << (needs_navigate?"true":"false") << LL_ENDL;
 		}
 	}
 	else
@@ -506,7 +506,7 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s
 		if(needs_navigate)
 		{
 			media_impl->navigateTo(media_impl->mMediaEntryURL, "", true, true);
-			lldebugs << "navigating to URL " << media_impl->mMediaEntryURL << llendl;
+			LL_DEBUGS() << "navigating to URL " << media_impl->mMediaEntryURL << LL_ENDL;
 		}
 		else if(!media_impl->mMediaURL.empty() && (media_impl->mMediaURL != media_impl->mMediaEntryURL))
 		{
@@ -516,7 +516,7 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s
 			// If this causes a navigate at some point (such as after a reload), it should be considered server-driven so it isn't broadcast.
 			media_impl->mNavigateServerRequest = true;
 
-			lldebugs << "updating URL in the media impl to " << media_impl->mMediaEntryURL << llendl;
+			LL_DEBUGS() << "updating URL in the media impl to " << media_impl->mMediaEntryURL << LL_ENDL;
 		}
 	}
 	
@@ -561,7 +561,7 @@ std::string LLViewerMedia::getCurrentUserAgent()
 	codec << "SecondLife/";
 	codec << LLVersionInfo::getVersion();
 	codec << " (" << channel << "; " << skin_name << " skin)";
-	llinfos << codec.str() << llendl;
+	LL_INFOS() << codec.str() << LL_ENDL;
 	
 	return codec.str();
 }
@@ -678,7 +678,7 @@ bool LLViewerMedia::isInterestingEnough(const LLVOVolume *object, const F64 &obj
 	}
 	else 
 	{
-		lldebugs << "object interest = " << object_interest << ", lowest loadable = " << sLowestLoadableImplInterest << llendl;
+		LL_DEBUGS() << "object interest = " << object_interest << ", lowest loadable = " << sLowestLoadableImplInterest << LL_ENDL;
 		if(object_interest >= sLowestLoadableImplInterest)
 			result = true;
 	}
@@ -800,8 +800,8 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	sUpdatedCookies = getCookieStore()->getChangedCookies();
 	if(!sUpdatedCookies.empty())
 	{
-		lldebugs << "updated cookies will be sent to all loaded plugins: " << llendl;
-		lldebugs << sUpdatedCookies << llendl;
+		LL_DEBUGS() << "updated cookies will be sent to all loaded plugins: " << LL_ENDL;
+		LL_DEBUGS() << sUpdatedCookies << LL_ENDL;
 	}
 	
 	impl_list::iterator iter = sViewerMediaImplList.begin();
@@ -1036,7 +1036,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 		proximity_order[i]->mProximity = i;
 	}
 	
-	LL_DEBUGS("PluginPriority") << "Total reported CPU usage is " << total_cpu << llendl;
+	LL_DEBUGS("PluginPriority") << "Total reported CPU usage is " << total_cpu << LL_ENDL;
 
 }
 
@@ -1171,14 +1171,14 @@ void LLViewerMedia::clearAllCookies()
 	std::string target;
 	std::string filename;
 	
-	lldebugs << "base dir = " << base_dir << llendl;
+	LL_DEBUGS() << "base dir = " << base_dir << LL_ENDL;
 
 	// The non-logged-in version is easy
 	target = base_dir;
 	target += "browser_profile";
 	target += gDirUtilp->getDirDelimiter();
 	target += "cookies";
-	lldebugs << "target = " << target << llendl;
+	LL_DEBUGS() << "target = " << target << LL_ENDL;
 	if(LLFile::isfile(target))
 	{
 		LLFile::remove(target);
@@ -1191,7 +1191,7 @@ void LLViewerMedia::clearAllCookies()
 		target = gDirUtilp->add(base_dir, filename);
 		gDirUtilp->append(target, "browser_profile");
 		gDirUtilp->append(target, "cookies");
-		lldebugs << "target = " << target << llendl;
+		LL_DEBUGS() << "target = " << target << LL_ENDL;
 		if(LLFile::isfile(target))
 		{	
 			LLFile::remove(target);
@@ -1200,7 +1200,7 @@ void LLViewerMedia::clearAllCookies()
 		// Other accounts may have new-style cookie files too -- delete them as well
 		target = gDirUtilp->add(base_dir, filename);
 		gDirUtilp->append(target, PLUGIN_COOKIE_FILE_NAME);
-		lldebugs << "target = " << target << llendl;
+		LL_DEBUGS() << "target = " << target << LL_ENDL;
 		if(LLFile::isfile(target))
 		{	
 			LLFile::remove(target);
@@ -1282,7 +1282,7 @@ void LLViewerMedia::loadCookieFile()
 
 	if (resolved_filename.empty())
 	{
-		llinfos << "can't get path to plugin cookie file - probably not logged in yet." << llendl;
+		LL_INFOS() << "can't get path to plugin cookie file - probably not logged in yet." << LL_ENDL;
 		return;
 	}
 	
@@ -1290,7 +1290,7 @@ void LLViewerMedia::loadCookieFile()
 	llifstream file(resolved_filename);
 	if (!file.is_open())
 	{
-		llwarns << "can't load plugin cookies from file \"" << PLUGIN_COOKIE_FILE_NAME << "\"" << llendl;
+		LL_WARNS() << "can't load plugin cookies from file \"" << PLUGIN_COOKIE_FILE_NAME << "\"" << LL_ENDL;
 		return;
 	}
 	
@@ -1324,7 +1324,7 @@ void LLViewerMedia::saveCookieFile()
 
 	if (resolved_filename.empty())
 	{
-		llinfos << "can't get path to plugin cookie file - probably not logged in yet." << llendl;
+		LL_INFOS() << "can't get path to plugin cookie file - probably not logged in yet." << LL_ENDL;
 		return;
 	}
 
@@ -1332,7 +1332,7 @@ void LLViewerMedia::saveCookieFile()
 	llofstream file (resolved_filename);
 	if (!file.is_open())
 	{
-		llwarns << "can't open plugin cookie file \"" << PLUGIN_COOKIE_FILE_NAME << "\" for writing" << llendl;
+		LL_WARNS() << "can't open plugin cookie file \"" << PLUGIN_COOKIE_FILE_NAME << "\" for writing" << LL_ENDL;
 		return;
 	}
 
@@ -1438,8 +1438,8 @@ void LLViewerMedia::setOpenIDCookie()
 		std::string profile_url = getProfileURL("");
 		LLURL raw_profile_url( profile_url.c_str() );
 
-		LL_DEBUGS("MediaAuth") << "Requesting " << profile_url << llendl;
-		LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << llendl;
+		LL_DEBUGS("MediaAuth") << "Requesting " << profile_url << LL_ENDL;
+		LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL;
 		LLHTTPClient::get(profile_url,  
 			new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()),
 			headers);
@@ -1958,7 +1958,7 @@ bool LLViewerMediaImpl::initializePlugin(const std::string& media_type)
 		//  Due to the ordering of messages, it's possible we wouldn't get that information back in time to send cookies before sending a navigate message,
 		//  which could cause odd race conditions.
 		std::string all_cookies = LLViewerMedia::getCookieStore()->getAllCookies();
-		lldebugs << "setting cookies: " << all_cookies << llendl;
+		LL_DEBUGS() << "setting cookies: " << all_cookies << LL_ENDL;
 		if(!all_cookies.empty())
 		{
 			media_source->set_cookies(all_cookies);
@@ -2000,7 +2000,7 @@ void LLViewerMediaImpl::loadURI()
 										"<>#%"
 										";/?:@&=",
 										false);
-		llinfos << "Asking media source to load URI: " << uri << llendl;
+		LL_INFOS() << "Asking media source to load URI: " << uri << LL_ENDL;
 		
 		mMediaSource->loadURI( uri );
 		
@@ -2272,7 +2272,7 @@ void LLViewerMediaImpl::mouseDown(S32 x, S32 y, MASK mask, S32 button)
 	scaleMouse(&x, &y);
 	mLastMouseX = x;
 	mLastMouseY = y;
-//	llinfos << "mouse down (" << x << ", " << y << ")" << llendl;
+//	LL_INFOS() << "mouse down (" << x << ", " << y << ")" << LL_ENDL;
 	if (mMediaSource)
 	{
 		mMediaSource->mouseEvent(LLPluginClassMedia::MOUSE_EVENT_DOWN, button, x, y, mask);
@@ -2285,7 +2285,7 @@ void LLViewerMediaImpl::mouseUp(S32 x, S32 y, MASK mask, S32 button)
 	scaleMouse(&x, &y);
 	mLastMouseX = x;
 	mLastMouseY = y;
-//	llinfos << "mouse up (" << x << ", " << y << ")" << llendl;
+//	LL_INFOS() << "mouse up (" << x << ", " << y << ")" << LL_ENDL;
 	if (mMediaSource)
 	{
 		mMediaSource->mouseEvent(LLPluginClassMedia::MOUSE_EVENT_UP, button, x, y, mask);
@@ -2298,7 +2298,7 @@ void LLViewerMediaImpl::mouseMove(S32 x, S32 y, MASK mask)
     scaleMouse(&x, &y);
 	mLastMouseX = x;
 	mLastMouseY = y;
-//	llinfos << "mouse move (" << x << ", " << y << ")" << llendl;
+//	LL_INFOS() << "mouse move (" << x << ", " << y << ")" << LL_ENDL;
 	if (mMediaSource)
 	{
 		mMediaSource->mouseEvent(LLPluginClassMedia::MOUSE_EVENT_MOVE, 0, x, y, mask);
@@ -2567,7 +2567,7 @@ void LLViewerMediaImpl::navigateTo(const std::string& url, const std::string& mi
 	if(mPriority == LLPluginClassMedia::PRIORITY_UNLOADED)
 	{
 		// Helpful to have media urls in log file. Shouldn't be spammy.
-		llinfos << "NOT LOADING media id= " << mTextureId << " url=" << url << " mime_type=" << mime_type << llendl;
+		LL_INFOS() << "NOT LOADING media id= " << mTextureId << " url=" << url << " mime_type=" << mime_type << LL_ENDL;
 
 		// This impl should not be loaded at this time.
 		LL_DEBUGS("PluginPriority") << this << "Not loading (PRIORITY_UNLOADED)" << LL_ENDL;
@@ -2582,18 +2582,18 @@ void LLViewerMediaImpl::navigateTo(const std::string& url, const std::string& mi
 void LLViewerMediaImpl::navigateInternal()
 {
 	// Helpful to have media urls in log file. Shouldn't be spammy.
-	llinfos << "media id= " << mTextureId << " url=" << mMediaURL << " mime_type=" << mMimeType << llendl;
+	LL_INFOS() << "media id= " << mTextureId << " url=" << mMediaURL << " mime_type=" << mMimeType << LL_ENDL;
 
 	if(mNavigateSuspended)
 	{
-		llwarns << "Deferring navigate." << llendl;
+		LL_WARNS() << "Deferring navigate." << LL_ENDL;
 		mNavigateSuspendedDeferred = true;
 		return;
 	}
 	
 	if(mMimeTypeProbe != NULL)
 	{
-		llwarns << "MIME type probe already in progress -- bailing out." << llendl;
+		LL_WARNS() << "MIME type probe already in progress -- bailing out." << LL_ENDL;
 		return;
 	}
 	
@@ -3313,7 +3313,7 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
 		{
 			std::string uuid = plugin->getClickUUID();
 
-			llinfos << "MEDIA_EVENT_CLOSE_REQUEST for uuid " << uuid << llendl;
+			LL_INFOS() << "MEDIA_EVENT_CLOSE_REQUEST for uuid " << uuid << LL_ENDL;
 
 			if(uuid.empty())
 			{
@@ -3332,7 +3332,7 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
 		{
 			std::string uuid = plugin->getClickUUID();
 
-			llinfos << "MEDIA_EVENT_GEOMETRY_CHANGE for uuid " << uuid << llendl;
+			LL_INFOS() << "MEDIA_EVENT_GEOMETRY_CHANGE for uuid " << uuid << LL_ENDL;
 
 			if(uuid.empty())
 			{
@@ -3622,16 +3622,16 @@ void LLViewerMediaImpl::setNavState(EMediaNavState state)
 	
 	switch (state) 
 	{
-		case MEDIANAVSTATE_NONE: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_NONE" << llendl; break;
-		case MEDIANAVSTATE_BEGUN: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_BEGUN" << llendl; break;
-		case MEDIANAVSTATE_FIRST_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_FIRST_LOCATION_CHANGED" << llendl; break;
-		case MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS" << llendl; break;
-		case MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED" << llendl; break;
-		case MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS" << llendl; break;
-		case MEDIANAVSTATE_SERVER_SENT: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_SENT" << llendl; break;
-		case MEDIANAVSTATE_SERVER_BEGUN: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_BEGUN" << llendl; break;
-		case MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED" << llendl; break;
-		case MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED" << llendl; break;
+		case MEDIANAVSTATE_NONE: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_NONE" << LL_ENDL; break;
+		case MEDIANAVSTATE_BEGUN: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_BEGUN" << LL_ENDL; break;
+		case MEDIANAVSTATE_FIRST_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_FIRST_LOCATION_CHANGED" << LL_ENDL; break;
+		case MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS" << LL_ENDL; break;
+		case MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED" << LL_ENDL; break;
+		case MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS" << LL_ENDL; break;
+		case MEDIANAVSTATE_SERVER_SENT: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_SENT" << LL_ENDL; break;
+		case MEDIANAVSTATE_SERVER_BEGUN: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_BEGUN" << LL_ENDL; break;
+		case MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED" << LL_ENDL; break;
+		case MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED: LL_DEBUGS("Media") << "Setting nav state to MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED" << LL_ENDL; break;
 	}
 }
 
@@ -3663,7 +3663,7 @@ void LLViewerMediaImpl::cancelMimeTypeProbe()
 		// The above should already have set mMimeTypeProbe to NULL.
 		if(mMimeTypeProbe != NULL)
 		{
-			llerrs << "internal error: mMimeTypeProbe is not NULL after cancelling request." << llendl;
+			LL_ERRS() << "internal error: mMimeTypeProbe is not NULL after cancelling request." << LL_ENDL;
 		}
 	}
 }
@@ -3745,10 +3745,10 @@ bool LLViewerMediaImpl::shouldShowBasedOnClass() const
 	bool attached_to_another_avatar = isAttachedToAnotherAvatar();
 	bool inside_parcel = isInAgentParcel();
 	
-	//	llinfos << " hasFocus = " << hasFocus() <<
+	//	LL_INFOS() << " hasFocus = " << hasFocus() <<
 	//	" others = " << (attached_to_another_avatar && gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_ON_OTHERS_SETTING)) <<
 	//	" within = " << (inside_parcel && gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_WITHIN_PARCEL_SETTING)) <<
-	//	" outside = " << (!inside_parcel && gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING)) << llendl;
+	//	" outside = " << (!inside_parcel && gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING)) << LL_ENDL;
 	
 	// If it has focus, we should show it
 	// This is incorrect, and causes EXT-6750 (disabled attachment media still plays)
diff --git a/indra/newview/llviewermedia_streamingaudio.cpp b/indra/newview/llviewermedia_streamingaudio.cpp
index e2a74e8e3c..c107e8472c 100755
--- a/indra/newview/llviewermedia_streamingaudio.cpp
+++ b/indra/newview/llviewermedia_streamingaudio.cpp
@@ -56,20 +56,20 @@ void LLStreamingAudio_MediaPlugins::start(const std::string& url)
 	if (!mMediaPlugin) // lazy-init the underlying media plugin
 	{
 		mMediaPlugin = initializeMedia("audio/mpeg"); // assumes that whatever media implementation supports mp3 also supports vorbis.
-		llinfos << "streaming audio mMediaPlugin is now " << mMediaPlugin << llendl;
+		LL_INFOS() << "streaming audio mMediaPlugin is now " << mMediaPlugin << LL_ENDL;
 	}
 
 	if(!mMediaPlugin)
 		return;
 
 	if (!url.empty()) {
-		llinfos << "Starting internet stream: " << url << llendl;
+		LL_INFOS() << "Starting internet stream: " << url << LL_ENDL;
 		mURL = url;
 		mMediaPlugin->loadURI ( url );
 		mMediaPlugin->start();
-		llinfos << "Playing stream..." << llendl;		
+		LL_INFOS() << "Playing stream..." << LL_ENDL;		
 	} else {
-		llinfos << "setting stream to NULL"<< llendl;
+		LL_INFOS() << "setting stream to NULL"<< LL_ENDL;
 		mURL.clear();
 		mMediaPlugin->stop();
 	}
@@ -77,7 +77,7 @@ void LLStreamingAudio_MediaPlugins::start(const std::string& url)
 
 void LLStreamingAudio_MediaPlugins::stop()
 {
-	llinfos << "Stopping internet stream." << llendl;
+	LL_INFOS() << "Stopping internet stream." << LL_ENDL;
 	if(mMediaPlugin)
 	{
 		mMediaPlugin->stop();
@@ -93,12 +93,12 @@ void LLStreamingAudio_MediaPlugins::pause(int pause)
 	
 	if(pause)
 	{
-		llinfos << "Pausing internet stream." << llendl;
+		LL_INFOS() << "Pausing internet stream." << LL_ENDL;
 		mMediaPlugin->pause();
 	} 
 	else 
 	{
-		llinfos << "Unpausing internet stream." << llendl;
+		LL_INFOS() << "Unpausing internet stream." << LL_ENDL;
 		mMediaPlugin->start();
 	}
 }
diff --git a/indra/newview/llviewermediafocus.cpp b/indra/newview/llviewermediafocus.cpp
index 297906803b..aa019dfdd8 100755
--- a/indra/newview/llviewermediafocus.cpp
+++ b/indra/newview/llviewermediafocus.cpp
@@ -108,7 +108,7 @@ void LLViewerMediaFocus::setFocusFace(LLPointer<LLViewerObject> objectp, S32 fac
 		else
 		{
 			// This should never happen.
-			llwarns << "Can't find media entry for focused face" << llendl;
+			LL_WARNS() << "Can't find media entry for focused face" << LL_ENDL;
 		}
 
 		media_impl->focus(true);
@@ -223,7 +223,7 @@ void LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 normal,
 		F32 aspect_ratio = getBBoxAspectRatio(bbox, normal, &height, &width, &depth);
 		F32 camera_aspect = LLViewerCamera::getInstance()->getAspect();
 		
-		lldebugs << "normal = " << normal << ", aspect_ratio = " << aspect_ratio << ", camera_aspect = " << camera_aspect << llendl;
+		LL_DEBUGS() << "normal = " << normal << ", aspect_ratio = " << aspect_ratio << ", camera_aspect = " << camera_aspect << LL_ENDL;
 
 		// We will normally use the side of the volume aligned with the short side of the screen (i.e. the height for 
 		// a screen in a landscape aspect ratio), however there is an edge case where the aspect ratio of the object is 
@@ -241,14 +241,14 @@ void LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 normal,
 			angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect());
 			distance = width * 0.5 * padding_factor / tan(angle_of_view * 0.5f );
 
-			lldebugs << "using width (" << width << "), angle_of_view = " << angle_of_view << ", distance = " << distance << llendl;
+			LL_DEBUGS() << "using width (" << width << "), angle_of_view = " << angle_of_view << ", distance = " << distance << LL_ENDL;
 		}
 		else
 		{
 			angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView());
 			distance = height * 0.5 * padding_factor / tan(angle_of_view * 0.5f );
 
-			lldebugs << "using height (" << height << "), angle_of_view = " << angle_of_view << ", distance = " << distance << llendl;
+			LL_DEBUGS() << "using height (" << height << "), angle_of_view = " << angle_of_view << ", distance = " << distance << LL_ENDL;
 		}
 
 		distance += depth * 0.5;
@@ -452,7 +452,7 @@ F32 LLViewerMediaFocus::getBBoxAspectRatio(const LLBBox& bbox, const LLVector3&
 	F32 dot1 = 0.f;
 	F32 dot2 = 0.f;
 	
-	lldebugs << "bounding box local size = " << bbox_max << ", local_normal = " << local_normal << llendl;
+	LL_DEBUGS() << "bounding box local size = " << bbox_max << ", local_normal = " << local_normal << LL_ENDL;
 
 	// The largest component of the localized normal vector is the depth component
 	// meaning that the other two are the legs of the rectangle.
@@ -465,21 +465,21 @@ F32 LLViewerMediaFocus::getBBoxAspectRatio(const LLBBox& bbox, const LLVector3&
 	
 	if(XgtY && XgtZ)
 	{
-		lldebugs << "x component of normal is longest, using y and z" << llendl;
+		LL_DEBUGS() << "x component of normal is longest, using y and z" << LL_ENDL;
 		comp1.mV[VY] = bbox_max.mV[VY];
 		comp2.mV[VZ] = bbox_max.mV[VZ];
 		*depth = bbox_max.mV[VX];
 	}
 	else if(!XgtY && YgtZ)
 	{
-		lldebugs << "y component of normal is longest, using x and z" << llendl;
+		LL_DEBUGS() << "y component of normal is longest, using x and z" << LL_ENDL;
 		comp1.mV[VX] = bbox_max.mV[VX];
 		comp2.mV[VZ] = bbox_max.mV[VZ];
 		*depth = bbox_max.mV[VY];
 	}
 	else
 	{
-		lldebugs << "z component of normal is longest, using x and y" << llendl;
+		LL_DEBUGS() << "z component of normal is longest, using x and y" << LL_ENDL;
 		comp1.mV[VX] = bbox_max.mV[VX];
 		comp2.mV[VY] = bbox_max.mV[VY];
 		*depth = bbox_max.mV[VZ];
@@ -493,19 +493,19 @@ F32 LLViewerMediaFocus::getBBoxAspectRatio(const LLBBox& bbox, const LLVector3&
 		*height = comp1.length();
 		*width = comp2.length();
 
-		lldebugs << "comp1 = " << comp1 << ", height = " << *height << llendl;
-		lldebugs << "comp2 = " << comp2 << ", width = " << *width << llendl;
+		LL_DEBUGS() << "comp1 = " << comp1 << ", height = " << *height << LL_ENDL;
+		LL_DEBUGS() << "comp2 = " << comp2 << ", width = " << *width << LL_ENDL;
 	}
 	else
 	{
 		*height = comp2.length();
 		*width = comp1.length();
 
-		lldebugs << "comp2 = " << comp2 << ", height = " << *height << llendl;
-		lldebugs << "comp1 = " << comp1 << ", width = " << *width << llendl;
+		LL_DEBUGS() << "comp2 = " << comp2 << ", height = " << *height << LL_ENDL;
+		LL_DEBUGS() << "comp1 = " << comp1 << ", width = " << *width << LL_ENDL;
 	}
 	
-	lldebugs << "returning " << (*width / *height) << llendl;
+	LL_DEBUGS() << "returning " << (*width / *height) << LL_ENDL;
 
 	// Return the aspect ratio.
 	return *width / *height;
@@ -560,7 +560,7 @@ void LLViewerMediaFocus::focusZoomOnMedia(LLUUID media_id)
 			if(normal.isNull())
 			{
 				// If that didn't work, use the inverse of the camera "look at" axis, which should keep the camera pointed in the same direction.
-//				llinfos << "approximate face normal invalid, using camera direction." << llendl;
+//				LL_INFOS() << "approximate face normal invalid, using camera direction." << LL_ENDL;
 				normal = LLViewerCamera::getInstance()->getAtAxis();
 				normal *= (F32)-1.0f;
 			}
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 427fd89afb..41ed2faaa5 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1638,7 +1638,7 @@ class LLAdvancedAnimTenFaster : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		//llinfos << "LLAdvancedAnimTenFaster" << llendl;
+		//LL_INFOS() << "LLAdvancedAnimTenFaster" << LL_ENDL;
 		F32 time_factor = LLMotionController::getCurrentTimeFactor();
 		time_factor = llmin(time_factor + 0.1f, 2.f);	// Upper limit is 200% speed
 		set_all_animation_time_factors(time_factor);
@@ -1650,7 +1650,7 @@ class LLAdvancedAnimTenSlower : public view_listener_t
 {
 	bool handleEvent(const LLSD& userdata)
 	{
-		//llinfos << "LLAdvancedAnimTenSlower" << llendl;
+		//LL_INFOS() << "LLAdvancedAnimTenSlower" << LL_ENDL;
 		F32 time_factor = LLMotionController::getCurrentTimeFactor();
 		time_factor = llmax(time_factor - 0.1f, 0.1f);	// Lower limit is at 10% of normal speed
 		set_all_animation_time_factors(time_factor);
@@ -3104,7 +3104,7 @@ class LLAvatarDebug : public view_listener_t
 			{
 				((LLVOAvatarSelf *)avatar)->dumpLocalTextures();
 			}
-			llinfos << "Dumping temporary asset data to simulator logs for avatar " << avatar->getID() << llendl;
+			LL_INFOS() << "Dumping temporary asset data to simulator logs for avatar " << avatar->getID() << LL_ENDL;
 			std::vector<std::string> strings;
 			strings.push_back(avatar->getID().asString());
 			LLUUID invoice;
@@ -3378,7 +3378,7 @@ void handle_buy_contents(LLSaleInfo sale_info)
 
 void handle_region_dump_temp_asset_data(void*)
 {
-	llinfos << "Dumping temporary asset data to simulator logs" << llendl;
+	LL_INFOS() << "Dumping temporary asset data to simulator logs" << LL_ENDL;
 	std::vector<std::string> strings;
 	LLUUID invoice;
 	send_generic_message("dumptempassetdata", strings, invoice);
@@ -3386,7 +3386,7 @@ void handle_region_dump_temp_asset_data(void*)
 
 void handle_region_clear_temp_asset_data(void*)
 {
-	llinfos << "Clearing temporary asset data" << llendl;
+	LL_INFOS() << "Clearing temporary asset data" << LL_ENDL;
 	std::vector<std::string> strings;
 	LLUUID invoice;
 	send_generic_message("cleartempassetdata", strings, invoice);
@@ -3397,14 +3397,14 @@ void handle_region_dump_settings(void*)
 	LLViewerRegion* regionp = gAgent.getRegion();
 	if (regionp)
 	{
-		llinfos << "Damage:    " << (regionp->getAllowDamage() ? "on" : "off") << llendl;
-		llinfos << "Landmark:  " << (regionp->getAllowLandmark() ? "on" : "off") << llendl;
-		llinfos << "SetHome:   " << (regionp->getAllowSetHome() ? "on" : "off") << llendl;
-		llinfos << "ResetHome: " << (regionp->getResetHomeOnTeleport() ? "on" : "off") << llendl;
-		llinfos << "SunFixed:  " << (regionp->getSunFixed() ? "on" : "off") << llendl;
-		llinfos << "BlockFly:  " << (regionp->getBlockFly() ? "on" : "off") << llendl;
-		llinfos << "AllowP2P:  " << (regionp->getAllowDirectTeleport() ? "on" : "off") << llendl;
-		llinfos << "Water:     " << (regionp->getWaterHeight()) << llendl;
+		LL_INFOS() << "Damage:    " << (regionp->getAllowDamage() ? "on" : "off") << LL_ENDL;
+		LL_INFOS() << "Landmark:  " << (regionp->getAllowLandmark() ? "on" : "off") << LL_ENDL;
+		LL_INFOS() << "SetHome:   " << (regionp->getAllowSetHome() ? "on" : "off") << LL_ENDL;
+		LL_INFOS() << "ResetHome: " << (regionp->getResetHomeOnTeleport() ? "on" : "off") << LL_ENDL;
+		LL_INFOS() << "SunFixed:  " << (regionp->getSunFixed() ? "on" : "off") << LL_ENDL;
+		LL_INFOS() << "BlockFly:  " << (regionp->getBlockFly() ? "on" : "off") << LL_ENDL;
+		LL_INFOS() << "AllowP2P:  " << (regionp->getAllowDirectTeleport() ? "on" : "off") << LL_ENDL;
+		LL_INFOS() << "Water:     " << (regionp->getWaterHeight()) << LL_ENDL;
 	}
 }
 
@@ -3435,7 +3435,7 @@ void handle_dump_focus()
 {
 	LLUICtrl *ctrl = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
 
-	llinfos << "Keyboard focus " << (ctrl ? ctrl->getName() : "(none)") << llendl;
+	LL_INFOS() << "Keyboard focus " << (ctrl ? ctrl->getName() : "(none)") << LL_ENDL;
 }
 
 class LLSelfStandUp : public view_listener_t
@@ -3647,7 +3647,7 @@ void process_grant_godlike_powers(LLMessageSystem* msg, void**)
 	}
 	else
 	{
-		llwarns << "Grant godlike for wrong agent " << agent_id << llendl;
+		LL_WARNS() << "Grant godlike for wrong agent " << agent_id << LL_ENDL;
 	}
 }
 
@@ -3989,7 +3989,7 @@ class LLEditEnableDuplicate : public view_listener_t
 
 void handle_duplicate_in_place(void*)
 {
-	llinfos << "handle_duplicate_in_place" << llendl;
+	LL_INFOS() << "handle_duplicate_in_place" << LL_ENDL;
 
 	LLVector3 offset(0.f, 0.f, 0.f);
 	LLSelectMgr::getInstance()->selectDuplicate(offset, TRUE);
@@ -4206,7 +4206,7 @@ static bool get_derezzable_objects(
 			&& dest != DRD_RETURN_TO_OWNER)
 		{
 			// this object is an asset container, derez its contents, not it
-			llwarns << "Attempt to derez deprecated AssetContainer object type not supported." << llendl;
+			LL_WARNS() << "Attempt to derez deprecated AssetContainer object type not supported." << LL_ENDL;
 			/*
 			object->requestInventory(container_inventory_arrived, 
 				(void *)(BOOL)(DRD_TAKE_INTO_AGENT_INVENTORY == dest));
@@ -4277,7 +4277,7 @@ static void derez_objects(
 		// get them from selection
 		if (!get_derezzable_objects(dest, error, first_region, &derez_objects, false))
 		{
-			llwarns << "No objects to derez" << llendl;
+			LL_WARNS() << "No objects to derez" << LL_ENDL;
 			return;
 		}
 
@@ -4765,7 +4765,7 @@ bool callback_show_buy_currency(const LLSD& notification, const LLSD& response)
 	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
 	if (0 == option)
 	{
-		llinfos << "Loading page " << LLNotifications::instance().getGlobalString("BUY_CURRENCY_URL") << llendl;
+		LL_INFOS() << "Loading page " << LLNotifications::instance().getGlobalString("BUY_CURRENCY_URL") << LL_ENDL;
 		LLWeb::loadURL(LLNotifications::instance().getGlobalString("BUY_CURRENCY_URL"));
 	}
 	return false;
@@ -5452,7 +5452,7 @@ void print_agent_nvpairs(void*)
 {
 	LLViewerObject *objectp;
 
-	llinfos << "Agent Name Value Pairs" << llendl;
+	LL_INFOS() << "Agent Name Value Pairs" << LL_ENDL;
 
 	objectp = gObjectList.findObject(gAgentID);
 	if (objectp)
@@ -5461,10 +5461,10 @@ void print_agent_nvpairs(void*)
 	}
 	else
 	{
-		llinfos << "Can't find agent object" << llendl;
+		LL_INFOS() << "Can't find agent object" << LL_ENDL;
 	}
 
-	llinfos << "Camera at " << gAgentCamera.getCameraPositionGlobal() << llendl;
+	LL_INFOS() << "Camera at " << gAgentCamera.getCameraPositionGlobal() << LL_ENDL;
 }
 
 void show_debug_menus()
@@ -5517,7 +5517,7 @@ void toggle_debug_menus(void*)
 // 	{
 // 		return;
 // 	}
-// 	llinfos << "Exporting selected objects:" << llendl;
+// 	LL_INFOS() << "Exporting selected objects:" << LL_ENDL;
 
 // 	gExporterRequestID.generate();
 // 	gExportDirectory = "";
@@ -5536,7 +5536,7 @@ void toggle_debug_menus(void*)
 // 		LLViewerObject* object = node->getObject();
 // 		msg->nextBlockFast(_PREHASH_ObjectData);
 // 		msg->addUUIDFast(_PREHASH_ObjectID, object->getID());
-// 		llinfos << "Object: " << object->getID() << llendl;
+// 		LL_INFOS() << "Object: " << object->getID() << LL_ENDL;
 // 	}
 // 	msg->sendReliable(gAgent.getRegion()->getHost());
 
@@ -6072,7 +6072,7 @@ class LLPromptShowURL : public view_listener_t
 		}
 		else
 		{
-			llinfos << "PromptShowURL invalid parameters! Expecting \"ALERT,URL\"." << llendl;
+			LL_INFOS() << "PromptShowURL invalid parameters! Expecting \"ALERT,URL\"." << LL_ENDL;
 		}
 		return true;
 	}
@@ -6105,7 +6105,7 @@ class LLPromptShowFile : public view_listener_t
 		}
 		else
 		{
-			llinfos << "PromptShowFile invalid parameters! Expecting \"ALERT,FILE\"." << llendl;
+			LL_INFOS() << "PromptShowFile invalid parameters! Expecting \"ALERT,FILE\"." << LL_ENDL;
 		}
 		return true;
 	}
@@ -6361,7 +6361,7 @@ void callback_attachment_drop(const LLSD& notification, const LLSD& response)
 	
 	if (!object)
 	{
-		llwarns << "handle_drop_attachment() - no object to drop" << llendl;
+		LL_WARNS() << "handle_drop_attachment() - no object to drop" << LL_ENDL;
 		return;
 	}
 
@@ -6378,13 +6378,13 @@ void callback_attachment_drop(const LLSD& notification, const LLSD& response)
 
 	if (!object)
 	{
-		llwarns << "handle_detach() - no object to detach" << llendl;
+		LL_WARNS() << "handle_detach() - no object to detach" << LL_ENDL;
 		return;
 	}
 
 	if (object->isAvatar())
 	{
-		llwarns << "Trying to detach avatar from avatar." << llendl;
+		LL_WARNS() << "Trying to detach avatar from avatar." << LL_ENDL;
 		return;
 	}
 	
@@ -6409,7 +6409,7 @@ class LLAttachmentDrop : public view_listener_t
 		}
 		else
 		{
-			llwarns << "Drop object not found" << llendl;
+			LL_WARNS() << "Drop object not found" << LL_ENDL;
 			return true;
 		}
 
@@ -6483,7 +6483,7 @@ class LLAttachmentDetach : public view_listener_t
 		LLViewerObject *object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
 		if (!object)
 		{
-			llwarns << "handle_detach() - no object to detach" << llendl;
+			LL_WARNS() << "handle_detach() - no object to detach" << LL_ENDL;
 			return true;
 		}
 
@@ -6500,13 +6500,13 @@ class LLAttachmentDetach : public view_listener_t
 
 		if (!object)
 		{
-			llwarns << "handle_detach() - no object to detach" << llendl;
+			LL_WARNS() << "handle_detach() - no object to detach" << LL_ENDL;
 			return true;
 		}
 
 		if (object->isAvatar())
 		{
-			llwarns << "Trying to detach avatar from avatar." << llendl;
+			LL_WARNS() << "Trying to detach avatar from avatar." << LL_ENDL;
 			return true;
 		}
 
@@ -6770,14 +6770,14 @@ void queue_actions(LLFloaterScriptQueue* q, const std::string& msg)
 		}
 		else
 		{
-			llerrs << "Bad logic." << llendl;
+			LL_ERRS() << "Bad logic." << LL_ENDL;
 		}
 	}
 	else
 	{
 		if (!q->start())
 		{
-			llwarns << "Unexpected script compile failure." << llendl;
+			LL_WARNS() << "Unexpected script compile failure." << LL_ENDL;
 		}
 	}
 }
@@ -6832,7 +6832,7 @@ class LLToolsSelectedScriptAction : public view_listener_t
 		}
 		else
 		{
-			llwarns << "Failed to generate LLFloaterScriptQueue with action: " << action << llendl;
+			LL_WARNS() << "Failed to generate LLFloaterScriptQueue with action: " << action << LL_ENDL;
 		}
 		return true;
 	}
@@ -6964,12 +6964,12 @@ void handle_dump_attachments(void*)
 							!attached_object->mDrawable->isRenderType(0));
 			LLVector3 pos;
 			if (visible) pos = attached_object->mDrawable->getPosition();
-			llinfos << "ATTACHMENT " << key << ": item_id=" << attached_object->getAttachmentItemID()
+			LL_INFOS() << "ATTACHMENT " << key << ": item_id=" << attached_object->getAttachmentItemID()
 					<< (attached_object ? " present " : " absent ")
 					<< (visible ? "visible " : "invisible ")
 					<<  " at " << pos
 					<< " and " << (visible ? attached_object->getPosition() : LLVector3::zero)
-					<< llendl;
+					<< LL_ENDL;
 		}
 	}
 }
@@ -7409,7 +7409,7 @@ void handle_grab_baked_texture(void* data)
 	if (!isAgentAvatarValid()) return;
 
 	const LLUUID& asset_id = gAgentAvatarp->grabBakedTexture(baked_tex_index);
-	LL_INFOS("texture") << "Adding baked texture " << asset_id << " to inventory." << llendl;
+	LL_INFOS("texture") << "Adding baked texture " << asset_id << " to inventory." << LL_ENDL;
 	LLAssetType::EType asset_type = LLAssetType::AT_TEXTURE;
 	LLInventoryType::EType inv_type = LLInventoryType::IT_TEXTURE;
 	const LLUUID folder_id = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(asset_type));
@@ -7465,7 +7465,7 @@ void handle_grab_baked_texture(void* data)
 	}
 	else
 	{
-		llwarns << "Can't find a folder to put it in" << llendl;
+		LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL;
 	}
 }
 
@@ -7663,7 +7663,7 @@ void handle_buy_currency_test(void*)
 	replace["[LANGUAGE]"] = LLUI::getLanguage();
 	LLStringUtil::format(url, replace);
 
-	llinfos << "buy currency url " << url << llendl;
+	LL_INFOS() << "buy currency url " << url << LL_ENDL;
 
 	LLFloaterReg::showInstance("buy_currency_html", LLSD(url));
 }
@@ -8098,7 +8098,7 @@ class LLWorldEnvPreset : public view_listener_t
 		}
 		else
 		{
-			llwarns << "Unknown item selected" << llendl;
+			LL_WARNS() << "Unknown item selected" << LL_ENDL;
 		}
 
 		return true;
@@ -8131,7 +8131,7 @@ class LLWorldEnableEnvPreset : public view_listener_t
 		}
 		else
 		{
-			llwarns << "Unknown item" << llendl;
+			LL_WARNS() << "Unknown item" << LL_ENDL;
 		}
 
 		return false;
diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp
index b7282a8493..2930c130df 100755
--- a/indra/newview/llviewermenufile.cpp
+++ b/indra/newview/llviewermenufile.cpp
@@ -253,7 +253,7 @@ const std::string upload_pick(void* data)
 	LLFilePicker& picker = LLFilePicker::instance();
 	if (!picker.getOpenFile(type))
 	{
-		llinfos << "Couldn't import objects from file" << llendl;
+		LL_INFOS() << "Couldn't import objects from file" << LL_ENDL;
 		return std::string();
 	}
 
@@ -327,7 +327,7 @@ const std::string upload_pick(void* data)
 		std::string error_msg;
 		if (check_for_invalid_wav_formats(filename,error_msg))
 		{
-			llinfos << error_msg << ": " << filename << llendl;
+			LL_INFOS() << error_msg << ": " << filename << LL_ENDL;
 			LLSD args;
 			args["FILE"] = filename;
 			LLNotificationsUtil::add( error_msg, args );
@@ -455,7 +455,7 @@ class LLFileUploadBulk : public view_listener_t
 		}
 		else
 		{
-			llinfos << "Couldn't import objects from file" << llendl;
+			LL_INFOS() << "Couldn't import objects from file" << LL_ENDL;
 		}
 		return true;
 	}
@@ -463,11 +463,11 @@ class LLFileUploadBulk : public view_listener_t
 
 void upload_error(const std::string& error_message, const std::string& label, const std::string& filename, const LLSD& args) 
 {
-	llwarns << error_message << llendl;
+	LL_WARNS() << error_message << LL_ENDL;
 	LLNotificationsUtil::add(label, args);
 	if(LLFile::remove(filename) == -1)
 	{
-		lldebugs << "unable to remove temp file" << llendl;
+		LL_DEBUGS() << "unable to remove temp file" << LL_ENDL;
 	}
 	LLFilePicker::instance().reset();						
 }
@@ -542,7 +542,7 @@ class LLFileTakeSnapshotToDisk : public view_listener_t
 				formatted = new LLImageJPEG(gSavedSettings.getS32("SnapshotQuality"));
 				break;
 			default:
-				llwarns << "Unknown local snapshot format: " << fmt << llendl;
+				LL_WARNS() << "Unknown local snapshot format: " << fmt << LL_ENDL;
 			case LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG:
 				formatted = new LLImagePNG;
 				break;
@@ -579,8 +579,8 @@ void handle_compress_image(void*)
 		{
 			std::string outfile = infile + ".j2c";
 
-			llinfos << "Input:  " << infile << llendl;
-			llinfos << "Output: " << outfile << llendl;
+			LL_INFOS() << "Input:  " << infile << LL_ENDL;
+			LL_INFOS() << "Output: " << outfile << LL_ENDL;
 
 			BOOL success;
 
@@ -588,11 +588,11 @@ void handle_compress_image(void*)
 
 			if (success)
 			{
-				llinfos << "Compression complete" << llendl;
+				LL_INFOS() << "Compression complete" << LL_ENDL;
 			}
 			else
 			{
-				llinfos << "Compression failed: " << LLImage::getLastError() << llendl;
+				LL_INFOS() << "Compression failed: " << LLImage::getLastError() << LL_ENDL;
 			}
 
 			infile = picker.getNextFile();
@@ -660,7 +660,7 @@ LLUUID upload_new_resource(
 		asset_type = LLAssetType::AT_SOUND;  // tag it as audio
 		S32 encode_result = 0;
 
-		llinfos << "Attempting to encode wav as an ogg file" << llendl;
+		LL_INFOS() << "Attempting to encode wav as an ogg file" << LL_ENDL;
 
 		encode_result = encode_vorbis_file(src_filename, filename);
 		
@@ -711,8 +711,8 @@ LLUUID upload_new_resource(
 											 "%254s %254s\n",
 											 label, value);	 	
 
-                                         llinfos << "got: " << label << " = " << value	 	
-                                                         << llendl;	 	
+                                         LL_INFOS() << "got: " << label << " = " << value	 	
+                                                         << LL_ENDL;	 	
 
                                          if (EOF == tokens_read)	 	
                                          {	 	
@@ -765,7 +765,7 @@ LLUUID upload_new_resource(
                          // read in and throw out most of the header except for the type	 	
                          if (fread(buf, header_size, 1, in) != 1)
 						 {
-							 llwarns << "Short read" << llendl;
+							 LL_WARNS() << "Short read" << LL_ENDL;
 						 }
                          memcpy(&type_num, buf + 16, sizeof(S16));		/* Flawfinder: ignore */	 	
                          asset_type = (LLAssetType::EType)type_num;	 	
@@ -779,7 +779,7 @@ LLUUID upload_new_resource(
                          {	 	
 							 if (fwrite(buf, 1, readbytes, out) != readbytes)
 							 {
-								 llwarns << "Short write" << llendl;
+								 LL_WARNS() << "Short write" << LL_ENDL;
 							 }
                          }	 	
                          fclose(out);	 	
@@ -797,7 +797,7 @@ LLUUID upload_new_resource(
          }	 	
          else	 	
          {	 	
-                 llinfos << "Couldn't open .lin file " << src_filename << llendl;	 	
+                 LL_INFOS() << "Couldn't open .lin file " << src_filename << LL_ENDL;	 	
          }	 	
 	}
 	else if (exten == "bvh")
@@ -873,13 +873,13 @@ LLUUID upload_new_resource(
 	}
 	else
 	{
-		llwarns << error_message << llendl;
+		LL_WARNS() << error_message << LL_ENDL;
 		LLSD args;
 		args["ERROR_MESSAGE"] = error_message;
 		LLNotificationsUtil::add("ErrorMessage", args);
 		if(LLFile::remove(filename) == -1)
 		{
-			lldebugs << "unable to remove temp file" << llendl;
+			LL_DEBUGS() << "unable to remove temp file" << LL_ENDL;
 		}
 		LLFilePicker::instance().reset();
 	}
@@ -947,7 +947,7 @@ void upload_done_callback(
 			if(is_balance_sufficient)
 			{
 				// Actually add the upload to inventory
-				llinfos << "Adding " << uuid << " to inventory." << llendl;
+				LL_INFOS() << "Adding " << uuid << " to inventory." << LL_ENDL;
 				const LLUUID folder_id = gInventory.findCategoryUUIDForType(dest_loc);
 				if(folder_id.notNull())
 				{
@@ -964,7 +964,7 @@ void upload_done_callback(
 				}
 				else
 				{
-					llwarns << "Can't find a folder to put it in" << llendl;
+					LL_WARNS() << "Can't find a folder to put it in" << LL_ENDL;
 				}
 			}
 		}
@@ -1129,21 +1129,21 @@ void upload_new_resource(
 	upload_message.append(display_name);
 	LLUploadDialog::modalUploadDialog(upload_message);
 
-	llinfos << "*** Uploading: " << llendl;
-	llinfos << "Type: " << LLAssetType::lookup(asset_type) << llendl;
-	llinfos << "UUID: " << uuid << llendl;
-	llinfos << "Name: " << name << llendl;
-	llinfos << "Desc: " << desc << llendl;
-	llinfos << "Expected Upload Cost: " << expected_upload_cost << llendl;
-	lldebugs << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type) << llendl;
-	lldebugs << "Asset Type: " << LLAssetType::lookup(asset_type) << llendl;
+	LL_INFOS() << "*** Uploading: " << LL_ENDL;
+	LL_INFOS() << "Type: " << LLAssetType::lookup(asset_type) << LL_ENDL;
+	LL_INFOS() << "UUID: " << uuid << LL_ENDL;
+	LL_INFOS() << "Name: " << name << LL_ENDL;
+	LL_INFOS() << "Desc: " << desc << LL_ENDL;
+	LL_INFOS() << "Expected Upload Cost: " << expected_upload_cost << LL_ENDL;
+	LL_DEBUGS() << "Folder: " << gInventory.findCategoryUUIDForType((destination_folder_type == LLFolderType::FT_NONE) ? LLFolderType::assetTypeToFolderType(asset_type) : destination_folder_type) << LL_ENDL;
+	LL_DEBUGS() << "Asset Type: " << LLAssetType::lookup(asset_type) << LL_ENDL;
 
 	std::string url = gAgent.getRegion()->getCapability(
 		"NewFileAgentInventory");
 
 	if ( !url.empty() )
 	{
-		llinfos << "New Agent Inventory via capability" << llendl;
+		LL_INFOS() << "New Agent Inventory via capability" << LL_ENDL;
 
 		LLSD body;
 		body = generate_new_resource_upload_capability_body(
@@ -1166,7 +1166,7 @@ void upload_new_resource(
 	}
 	else
 	{
-		llinfos << "NewAgentInventory capability not found, new agent inventory via asset system." << llendl;
+		LL_INFOS() << "NewAgentInventory capability not found, new agent inventory via asset system." << LL_ENDL;
 		// check for adequate funds
 		// TODO: do this check on the sim
 		if (LLAssetType::AT_SOUND == asset_type ||
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 864418ad95..f12df23a36 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -375,7 +375,7 @@ void process_layer_data(LLMessageSystem *mesgsys, void **user_data)
 
 	if(!regionp)
 	{
-		llwarns << "Invalid region for layer data." << llendl;
+		LL_WARNS() << "Invalid region for layer data." << LL_ENDL;
 		return;
 	}
 	S32 size;
@@ -1215,7 +1215,7 @@ void open_inventory_offer(const uuid_vec_t& objects, const std::string& from_nam
 		const LLInventoryObject *obj = gInventory.getObject(obj_id);
 		if (!obj)
 		{
-			llwarns << "Cannot find object [ itemID:" << obj_id << " ] to open." << llendl;
+			LL_WARNS() << "Cannot find object [ itemID:" << obj_id << " ] to open." << LL_ENDL;
 			continue;
 		}
 
@@ -1491,7 +1491,7 @@ void LLOfferInfo::handleRespond(const LLSD& notification, const LLSD& response)
 	const std::string name = notification["name"].asString();
 	if(mRespondFunctions.find(name) == mRespondFunctions.end())
 	{
-		llwarns << "Unexpected notification name : " << name << llendl;
+		LL_WARNS() << "Unexpected notification name : " << name << LL_ENDL;
 		llassert(!"Unexpected notification name");
 		return;
 	}
@@ -3431,7 +3431,7 @@ protected:
 
 	void handleFailure(int status, const std::string& err_msg)
 	{
-		llwarns << "Translation failed for mesg " << m_origMesg << " toLang " << mToLang << " fromLang " << mFromLang << llendl;
+		LL_WARNS() << "Translation failed for mesg " << m_origMesg << " toLang " << mToLang << " fromLang " << mFromLang << LL_ENDL;
 
 		std::string msg = LLTrans::getString("TranslationFailed", LLSD().with("[REASON]", err_msg));
 		LLStringUtil::replaceString(msg, "\n", " "); // we want one-line error messages
@@ -4414,7 +4414,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 				update_sec = cur_sec;
 				//msg_number = 0;
 				max_update_count = llmax(max_update_count, update_count);
-				llinfos << "Sent " << update_count << " AgentUpdate messages per second, max is " << max_update_count << llendl;
+				LL_INFOS() << "Sent " << update_count << " AgentUpdate messages per second, max is " << max_update_count << LL_ENDL;
 			}
 			update_sec = cur_sec;
 			update_count = 0;
@@ -4845,7 +4845,7 @@ void process_sim_stats(LLMessageSystem *msg, void **user_data)
 		}
 		else
 		{
-			llwarns << "Unknown sim stat identifier: " << stat_id << llendl;
+			LL_WARNS() << "Unknown sim stat identifier: " << stat_id << LL_ENDL;
 		}
 	}
 
@@ -5412,8 +5412,8 @@ static std::string reason_from_transaction_type(S32 transaction_type,
 			return std::string();
 
 		default:
-			llwarns << "Unknown transaction type " 
-				<< transaction_type << llendl;
+			LL_WARNS() << "Unknown transaction type " 
+				<< transaction_type << LL_ENDL;
 			return std::string();
 	}
 }
@@ -5790,7 +5790,7 @@ bool attempt_standard_notification(LLMessageSystem* msgsystem)
 			std::istringstream llsdData(llsdRaw);
 			if (!LLSDSerialize::deserialize(llsdBlock, llsdData, llsdRaw.length()))
 			{
-				llwarns << "attempt_standard_notification: Attempted to read notification parameter data into LLSD but failed:" << llsdRaw << llendl;
+				LL_WARNS() << "attempt_standard_notification: Attempted to read notification parameter data into LLSD but failed:" << llsdRaw << LL_ENDL;
 			}
 		}
 		
@@ -6572,7 +6572,7 @@ void process_teleport_failed(LLMessageSystem *msg, void**)
 			std::istringstream llsd_data(llsd_raw);
 			if (!LLSDSerialize::deserialize(llsd_block, llsd_data, llsd_raw.length()))
 			{
-				llwarns << "process_teleport_failed: Attempted to read alert parameter data into LLSD but failed:" << llsd_raw << llendl;
+				LL_WARNS() << "process_teleport_failed: Attempted to read alert parameter data into LLSD but failed:" << llsd_raw << LL_ENDL;
 			}
 			else
 			{
@@ -7029,7 +7029,7 @@ void process_script_dialog(LLMessageSystem* msg, void**)
 	S32 button_count = msg->getNumberOfBlocks("Buttons");
 	if (button_count > SCRIPT_DIALOG_MAX_BUTTONS)
 	{
-		llwarns << "Too many script dialog buttons - omitting some" << llendl;
+		LL_WARNS() << "Too many script dialog buttons - omitting some" << LL_ENDL;
 		button_count = SCRIPT_DIALOG_MAX_BUTTONS;
 	}
 
@@ -7189,7 +7189,7 @@ void process_initiate_download(LLMessageSystem* msg, void**)
 
 	if (!gXferManager->validateFileForRequest(viewer_filename))
 	{
-		llwarns << "SECURITY: Unauthorized download to local file " << viewer_filename << llendl;
+		LL_WARNS() << "SECURITY: Unauthorized download to local file " << viewer_filename << LL_ENDL;
 		return;
 	}
 	gXferManager->requestFile(viewer_filename,
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 51328dc802..3d75f86154 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -174,13 +174,13 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco
 	case LL_PCODE_LEGACY_GRASS:
 	  res = new LLVOGrass(id, pcode, regionp); break;
 	case LL_PCODE_LEGACY_PART_SYS:
-// 	  llwarns << "Creating old part sys!" << llendl;
+// 	  LL_WARNS() << "Creating old part sys!" << LL_ENDL;
 // 	  res = new LLVOPart(id, pcode, regionp); break;
 	  res = NULL; break;
 	case LL_PCODE_LEGACY_TREE:
 	  res = new LLVOTree(id, pcode, regionp); break;
 	case LL_PCODE_TREE_NEW:
-// 	  llwarns << "Creating new tree!" << llendl;
+// 	  LL_WARNS() << "Creating new tree!" << LL_ENDL;
 // 	  res = new LLVOTree(id, pcode, regionp); break;
 	  res = NULL; break;
 	case LL_VO_SURFACE_PATCH:
@@ -200,7 +200,7 @@ LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pco
 	case LL_VO_WL_SKY:
 	  res = new LLVOWLSky(id, pcode, regionp); break;
 	default:
-	  llwarns << "Unknown object pcode " << (S32)pcode << llendl;
+	  LL_WARNS() << "Unknown object pcode " << (S32)pcode << LL_ENDL;
 	  res = NULL; break;
 	}
 	return res;
@@ -354,7 +354,7 @@ void LLViewerObject::markDead()
 {
 	if (!mDead)
 	{
-		//llinfos << "Marking self " << mLocalID << " as dead." << llendl;
+		//LL_INFOS() << "Marking self " << mLocalID << " as dead." << LL_ENDL;
 		
 		// Root object of this hierarchy unlinks itself.
 		if (getParent())
@@ -376,7 +376,7 @@ void LLViewerObject::markDead()
 			childp = mChildList.back();
 			if (childp->getPCode() != LL_PCODE_LEGACY_AVATAR)
 			{
-				//llinfos << "Marking child " << childp->getLocalID() << " as dead." << llendl;
+				//LL_INFOS() << "Marking child " << childp->getLocalID() << " as dead." << LL_ENDL;
 				childp->setParent(NULL); // LLViewerObject::markDead 1
 				childp->markDead();
 			}
@@ -446,17 +446,17 @@ void LLViewerObject::markDead()
 
 void LLViewerObject::dump() const
 {
-	llinfos << "Type: " << pCodeToString(mPrimitiveCode) << llendl;
-	llinfos << "Drawable: " << (LLDrawable *)mDrawable << llendl;
-	llinfos << "Update Age: " << LLFrameTimer::getElapsedSeconds() - mLastMessageUpdateSecs << llendl;
-
-	llinfos << "Parent: " << getParent() << llendl;
-	llinfos << "ID: " << mID << llendl;
-	llinfos << "LocalID: " << mLocalID << llendl;
-	llinfos << "PositionRegion: " << getPositionRegion() << llendl;
-	llinfos << "PositionAgent: " << getPositionAgent() << llendl;
-	llinfos << "PositionGlobal: " << getPositionGlobal() << llendl;
-	llinfos << "Velocity: " << getVelocity() << llendl;
+	LL_INFOS() << "Type: " << pCodeToString(mPrimitiveCode) << LL_ENDL;
+	LL_INFOS() << "Drawable: " << (LLDrawable *)mDrawable << LL_ENDL;
+	LL_INFOS() << "Update Age: " << LLFrameTimer::getElapsedSeconds() - mLastMessageUpdateSecs << LL_ENDL;
+
+	LL_INFOS() << "Parent: " << getParent() << LL_ENDL;
+	LL_INFOS() << "ID: " << mID << LL_ENDL;
+	LL_INFOS() << "LocalID: " << mLocalID << LL_ENDL;
+	LL_INFOS() << "PositionRegion: " << getPositionRegion() << LL_ENDL;
+	LL_INFOS() << "PositionAgent: " << getPositionAgent() << LL_ENDL;
+	LL_INFOS() << "PositionGlobal: " << getPositionGlobal() << LL_ENDL;
+	LL_INFOS() << "Velocity: " << getVelocity() << LL_ENDL;
 	if (mDrawable.notNull() && 
 		mDrawable->getNumFaces() && 
 		mDrawable->getFace(0))
@@ -464,31 +464,31 @@ void LLViewerObject::dump() const
 		LLFacePool *poolp = mDrawable->getFace(0)->getPool();
 		if (poolp)
 		{
-			llinfos << "Pool: " << poolp << llendl;
-			llinfos << "Pool reference count: " << poolp->mReferences.size() << llendl;
+			LL_INFOS() << "Pool: " << poolp << LL_ENDL;
+			LL_INFOS() << "Pool reference count: " << poolp->mReferences.size() << LL_ENDL;
 		}
 	}
-	//llinfos << "BoxTree Min: " << mDrawable->getBox()->getMin() << llendl;
-	//llinfos << "BoxTree Max: " << mDrawable->getBox()->getMin() << llendl;
+	//LL_INFOS() << "BoxTree Min: " << mDrawable->getBox()->getMin() << LL_ENDL;
+	//LL_INFOS() << "BoxTree Max: " << mDrawable->getBox()->getMin() << LL_ENDL;
 	/*
-	llinfos << "Velocity: " << getVelocity() << llendl;
-	llinfos << "AnyOwner: " << permAnyOwner() << " YouOwner: " << permYouOwner() << " Edit: " << mPermEdit << llendl;
-	llinfos << "UsePhysics: " << flagUsePhysics() << " CanSelect " << mbCanSelect << " UserSelected " << mUserSelected << llendl;
-	llinfos << "AppAngle: " << mAppAngle << llendl;
-	llinfos << "PixelArea: " << mPixelArea << llendl;
+	LL_INFOS() << "Velocity: " << getVelocity() << LL_ENDL;
+	LL_INFOS() << "AnyOwner: " << permAnyOwner() << " YouOwner: " << permYouOwner() << " Edit: " << mPermEdit << LL_ENDL;
+	LL_INFOS() << "UsePhysics: " << flagUsePhysics() << " CanSelect " << mbCanSelect << " UserSelected " << mUserSelected << LL_ENDL;
+	LL_INFOS() << "AppAngle: " << mAppAngle << LL_ENDL;
+	LL_INFOS() << "PixelArea: " << mPixelArea << LL_ENDL;
 
 	char buffer[1000];
 	char *key;
 	for (key = mNameValuePairs.getFirstKey(); key; key = mNameValuePairs.getNextKey() )
 	{
 		mNameValuePairs[key]->printNameValue(buffer);
-		llinfos << buffer << llendl;
+		LL_INFOS() << buffer << LL_ENDL;
 	}
 	for (child_list_t::iterator iter = mChildList.begin();
 		 iter != mChildList.end(); iter++)
 	{
 		LLViewerObject* child = *iter;
-		llinfos << "  child " << child->getID() << llendl;
+		LL_INFOS() << "  child " << child->getID() << LL_ENDL;
 	}
 	*/
 }
@@ -499,7 +499,7 @@ void LLViewerObject::printNameValuePairs() const
 		 iter != mNameValuePairs.end(); iter++)
 	{
 		LLNameValue* nv = iter->second;
-		llinfos << nv->printNameValue() << llendl;
+		LL_INFOS() << nv->printNameValue() << LL_ENDL;
 	}
 }
 
@@ -508,7 +508,7 @@ void LLViewerObject::initVOClasses()
 	// Initialized shared class stuff first.
 	LLVOAvatar::initClass();
 	LLVOTree::initClass();
-	llinfos << "Viewer Object size: " << sizeof(LLViewerObject) << llendl;
+	LL_INFOS() << "Viewer Object size: " << sizeof(LLViewerObject) << LL_ENDL;
 	LLVOGrass::initClass();
 	LLVOWater::initClass();
 	LLVOVolume::initClass();
@@ -745,7 +745,7 @@ void LLViewerObject::buildReturnablesForChildrenVO( std::vector<PotentialReturna
 {
 	if ( !pChild )
 	{
-		llerrs<<"child viewerobject is NULL "<<llendl;
+		LL_ERRS()<<"child viewerobject is NULL "<<LL_ENDL;
 	}
 	
 	constructAndAddReturnable( returnables, pChild, pTargetRegion );
@@ -1057,7 +1057,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 	// If region is removed from the list it is also deleted.
 	if (!LLWorld::instance().isRegionListed(mRegionp))
 	{
-		llwarns << "Updating object in an invalid region" << llendl;
+		LL_WARNS() << "Updating object in an invalid region" << LL_ENDL;
 		return retval;
 	}
 
@@ -1099,7 +1099,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		U32 x, y;
 		from_region_handle(region_handle, &x, &y);
 
-		llerrs << "Object has invalid region " << x << ":" << y << "!" << llendl;
+		LL_ERRS() << "Object has invalid region " << x << ":" << y << "!" << LL_ENDL;
 		return retval;
 	}
 
@@ -1158,7 +1158,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		case OUT_FULL:
 			{
 #ifdef DEBUG_UPDATE_TYPE
-				llinfos << "Full:" << getID() << llendl;
+				LL_INFOS() << "Full:" << getID() << LL_ENDL;
 #endif
 				//clear cost and linkset cost
 				mCostStale = true;
@@ -1464,7 +1464,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 						S32 param_size;
 						dp.unpackU16(param_type, "param_type");
 						dp.unpackBinaryData(param_block, param_size, "param_data");
-						//llinfos << "Param type: " << param_type << ", Size: " << param_size << llendl;
+						//LL_INFOS() << "Param type: " << param_type << ", Size: " << param_size << LL_ENDL;
 						LLDataPackerBinaryBuffer dp2(param_block, param_size);
 						unpackParameterEntry(param_type, &dp2);
 					}
@@ -1486,7 +1486,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		case OUT_TERSE_IMPROVED:
 			{
 #ifdef DEBUG_UPDATE_TYPE
-				llinfos << "TI:" << getID() << llendl;
+				LL_INFOS() << "TI:" << getID() << LL_ENDL;
 #endif
 				length = mesgsys->getSizeFast(_PREHASH_ObjectData, block_num, _PREHASH_ObjectData);
 				mesgsys->getBinaryDataFast(_PREHASH_ObjectData, _PREHASH_ObjectData, data, length, block_num);
@@ -1663,7 +1663,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 			case OUT_TERSE_IMPROVED:
 			{
 #ifdef DEBUG_UPDATE_TYPE
-				llinfos << "CompTI:" << getID() << llendl;
+				LL_INFOS() << "CompTI:" << getID() << LL_ENDL;
 #endif
 				U8		value;
 				dp->unpackU8(value, "agent");
@@ -1709,7 +1709,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 			case OUT_FULL_CACHED:
 			{
 #ifdef DEBUG_UPDATE_TYPE
-				llinfos << "CompFull:" << getID() << llendl;
+				LL_INFOS() << "CompFull:" << getID() << LL_ENDL;
 #endif
 				mCostStale = true;
 
@@ -1845,7 +1845,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 					S32 param_size;
 					dp->unpackU16(param_type, "param_type");
 					dp->unpackBinaryData(param_block, param_size, "param_data");
-					//llinfos << "Param type: " << param_type << ", Size: " << param_size << llendl;
+					//LL_INFOS() << "Param type: " << param_type << ", Size: " << param_size << LL_ENDL;
 					LLDataPackerBinaryBuffer dp2(param_block, param_size);
 					unpackParameterEntry(param_type, &dp2);
 				}
@@ -1940,7 +1940,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 				if (sent_parentp && sent_parentp->getParent() == this)
 				{
 					// Try to recover if we attempt to attach a parent to its child
-					llwarns << "Attempt to attach a parent to it's child: " << this->getID() << " to " << sent_parentp->getID() << llendl;
+					LL_WARNS() << "Attempt to attach a parent to it's child: " << this->getID() << " to " << sent_parentp->getID() << LL_ENDL;
 					this->removeChild(sent_parentp);
 					sent_parentp->setDrawableParent(NULL);
 				}
@@ -1959,7 +1959,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 					{
 						if (mDrawable->isDead() || !mDrawable->getVObj())
 						{
-							llwarns << "Drawable is dead or no VObj!" << llendl;
+							LL_WARNS() << "Drawable is dead or no VObj!" << LL_ENDL;
 							sent_parentp->addChild(this);
 						}
 						else
@@ -1969,9 +1969,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 								// Bad, we got a cycle somehow.
 								// Kill both the parent and the child, and
 								// set cache misses for both of them.
-								llwarns << "Attempting to recover from parenting cycle!" << llendl;
-								llwarns << "Killing " << sent_parentp->getID() << " and " << getID() << llendl;
-								llwarns << "Adding to cache miss list" << llendl;
+								LL_WARNS() << "Attempting to recover from parenting cycle!" << LL_ENDL;
+								LL_WARNS() << "Killing " << sent_parentp->getID() << " and " << getID() << LL_ENDL;
+								LL_WARNS() << "Adding to cache miss list" << LL_ENDL;
 								setParent(NULL);
 								sent_parentp->setParent(NULL);
 								getRegion()->addCacheMissFull(getLocalID());
@@ -2038,7 +2038,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 				//LLViewerObjectList::getUUIDFromLocal(parent_uuid, parent_id, mesgsys->getSenderIP(), mesgsys->getSenderPort() );
 				//if (parent_uuid != cur_parentp->getID() )
 				//{
-				//	llerrs << "Local ID match but UUID mismatch of viewer object" << llendl;
+				//	LL_ERRS() << "Local ID match but UUID mismatch of viewer object" << LL_ENDL;
 				//}
 			}
 			else
@@ -2120,9 +2120,9 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 							// Bad, we got a cycle somehow.
 							// Kill both the parent and the child, and
 							// set cache misses for both of them.
-							llwarns << "Attempting to recover from parenting cycle!" << llendl;
-							llwarns << "Killing " << sent_parentp->getID() << " and " << getID() << llendl;
-							llwarns << "Adding to cache miss list" << llendl;
+							LL_WARNS() << "Attempting to recover from parenting cycle!" << LL_ENDL;
+							LL_WARNS() << "Killing " << sent_parentp->getID() << " and " << getID() << LL_ENDL;
+							LL_WARNS() << "Adding to cache miss list" << LL_ENDL;
 							setParent(NULL);
 							sent_parentp->setParent(NULL);
 							getRegion()->addCacheMissFull(getLocalID());
@@ -2154,7 +2154,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 							// This is probably an object flying across a region boundary, the
 							// object probably ISN'T being reparented, but just got an object
 							// update out of order (child update before parent).
-							//llinfos << "Don't reparent object handoffs!" << llendl;
+							//LL_INFOS() << "Don't reparent object handoffs!" << LL_ENDL;
 							remove_parent = false;
 						}
 					}
@@ -2196,7 +2196,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		}
 		else
 		{
-			llwarns << "findCircuit() returned NULL; skipping interpolation" << llendl;
+			LL_WARNS() << "findCircuit() returned NULL; skipping interpolation" << LL_ENDL;
 		}
 	}
 
@@ -2250,7 +2250,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		}
 		else
 		{
-			llwarns << "Can not move the object/avatar to an infinite location!" << llendl ;	
+			LL_WARNS() << "Can not move the object/avatar to an infinite location!" << LL_ENDL ;	
 
 			retval |= INVALID_UPDATE ;
 		}
@@ -2367,7 +2367,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		// Don't clear invisibility flag on update if still orphaned!
 		if (mDrawable->isState(LLDrawable::FORCE_INVISIBLE) && !mOrphaned)
 		{
-// 			lldebugs << "Clearing force invisible: " << mID << ":" << getPCodeString() << ":" << getPositionAgent() << llendl;
+// 			LL_DEBUGS() << "Clearing force invisible: " << mID << ":" << getPCodeString() << ":" << getPositionAgent() << LL_ENDL;
 			mDrawable->clearState(LLDrawable::FORCE_INVISIBLE);
 			gPipeline.markRebuild( mDrawable, LLDrawable::REBUILD_ALL, TRUE );
 		}
@@ -2503,7 +2503,7 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 						if (time_since_last_update > sMaxUpdateInterpolationTime)
 						{	// Past the time limit, so stop the object
 							phase_out = 0.0;
-							//llinfos << "Motion phase out to zero" << llendl;
+							//LL_INFOS() << "Motion phase out to zero" << LL_ENDL;
 
 							// Kill angular motion as well.  Note - not adding this due to paranoia
 							// about stopping rotation for llTargetOmega objects and not having it restart
@@ -2513,13 +2513,13 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 						{	// Last update was already phased out a bit
 							phase_out = (sMaxUpdateInterpolationTime - time_since_last_update) / 
 										(sMaxUpdateInterpolationTime - time_since_last_interpolation);
-							//llinfos << "Continuing motion phase out of " << (F32) phase_out << llendl;
+							//LL_INFOS() << "Continuing motion phase out of " << (F32) phase_out << LL_ENDL;
 						}
 						else
 						{	// Phase out from full value
 							phase_out = (sMaxUpdateInterpolationTime - time_since_last_update) / 
 										(sMaxUpdateInterpolationTime - sPhaseOutUpdateInterpolationTime);
-							//llinfos << "Starting motion phase out of " << (F32) phase_out << llendl;
+							//LL_INFOS() << "Starting motion phase out of " << (F32) phase_out << LL_ENDL;
 						}
 						phase_out = llclamp(phase_out, 0.0, 1.0);
 
@@ -2564,8 +2564,8 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 			if (clip_pos_global != new_pos_global)
 			{	// Was clipped, so this means we hit a edge where there is no region to enter
 				
-				//llinfos << "Hit empty region edge, clipped predicted position to " << mRegionp->getPosRegionFromGlobal(clip_pos_global)
-				//	<< " from " << new_pos << llendl;
+				//LL_INFOS() << "Hit empty region edge, clipped predicted position to " << mRegionp->getPosRegionFromGlobal(clip_pos_global)
+				//	<< " from " << new_pos << LL_ENDL;
 				new_pos = mRegionp->getPosRegionFromGlobal(clip_pos_global);
 				
 				// Stop motion and get server update for bouncing on the edge
@@ -2574,7 +2574,7 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 			}
 			else
 			{	// Let predicted movement cross into another region
-				//llinfos << "Predicting region crossing to " << new_pos << llendl;
+				//LL_INFOS() << "Predicting region crossing to " << new_pos << LL_ENDL;
 			}
 		}
 
@@ -2722,7 +2722,7 @@ void LLViewerObject::saveScript(
 	 * XXXPAM Investigate not making this copy.  Seems unecessary, but I'm unsure about the
 	 * interaction with doUpdateInventory() called below.
 	 */
-	lldebugs << "LLViewerObject::saveScript() " << item->getUUID() << " " << item->getAssetUUID() << llendl;
+	LL_DEBUGS() << "LLViewerObject::saveScript() " << item->getUUID() << " " << item->getAssetUUID() << LL_ENDL;
 	LLPointer<LLViewerInventoryItem> task_item =
 		new LLViewerInventoryItem(item->getUUID(), mID, item->getPermissions(),
 								  item->getAssetUUID(), item->getType(),
@@ -2753,7 +2753,7 @@ void LLViewerObject::saveScript(
 void LLViewerObject::moveInventory(const LLUUID& folder_id,
 								   const LLUUID& item_id)
 {
-	lldebugs << "LLViewerObject::moveInventory " << item_id << llendl;
+	LL_DEBUGS() << "LLViewerObject::moveInventory " << item_id << LL_ENDL;
 	LLMessageSystem* msg = gMessageSystem;
 	msg->newMessageFast(_PREHASH_MoveTaskInventory);
 	msg->nextBlockFast(_PREHASH_AgentData);
@@ -2870,12 +2870,12 @@ struct LLFilenameAndTask
 	LLFilenameAndTask()
 	{
 		++sCount;
-		lldebugs << "Constructing LLFilenameAndTask: " << sCount << llendl;
+		LL_DEBUGS() << "Constructing LLFilenameAndTask: " << sCount << LL_ENDL;
 	}
 	~LLFilenameAndTask()
 	{
 		--sCount;
-		lldebugs << "Destroying LLFilenameAndTask: " << sCount << llendl;
+		LL_DEBUGS() << "Destroying LLFilenameAndTask: " << sCount << LL_ENDL;
 	}
 private:
 	LLFilenameAndTask(const LLFilenameAndTask& rhs);
@@ -2895,8 +2895,8 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data)
 	LLViewerObject* object = gObjectList.findObject(task_id);
 	if(!object)
 	{
-		llwarns << "LLViewerObject::processTaskInv object "
-			<< task_id << " does not exist." << llendl;
+		LL_WARNS() << "LLViewerObject::processTaskInv object "
+			<< task_id << " does not exist." << LL_ENDL;
 		return;
 	}
 
@@ -2910,7 +2910,7 @@ void LLViewerObject::processTaskInv(LLMessageSystem* msg, void** user_data)
 	
 	if(ft->mFilename.empty())
 	{
-		lldebugs << "Task has no inventory" << llendl;
+		LL_DEBUGS() << "Task has no inventory" << LL_ENDL;
 		// mock up some inventory to make a drop target.
 		if(object->mInventory)
 		{
@@ -2970,15 +2970,15 @@ void LLViewerObject::processTaskInvFile(void** user_data, S32 error_code, LLExtS
 			// MAINT-2597 - crash when trying to edit a no-mod object
 			// Somehow get an contents inventory response, but with an invalid stream (possibly 0 size?)
 			// Stated repro was specific to no-mod objects so failing without user interaction should be safe.
-			llwarns << "Trying to load invalid task inventory file. Ignoring file contents." << llendl;
+			LL_WARNS() << "Trying to load invalid task inventory file. Ignoring file contents." << LL_ENDL;
 		}
 	}
 	else
 	{
 		// This Occurs When to requests were made, and the first one
 		// has already handled it.
-		lldebugs << "Problem loading task inventory. Return code: "
-				 << error_code << llendl;
+		LL_DEBUGS() << "Problem loading task inventory. Return code: "
+				 << error_code << LL_ENDL;
 	}
 	delete ft;
 }
@@ -3019,8 +3019,8 @@ BOOL LLViewerObject::loadTaskInvFile(const std::string& filename)
 			}
 			else
 			{
-				llwarns << "Unknown token in inventory file '"
-						<< keyword << "'" << llendl;
+				LL_WARNS() << "Unknown token in inventory file '"
+						<< keyword << "'" << LL_ENDL;
 			}
 		}
 		ifs.close();
@@ -3028,8 +3028,8 @@ BOOL LLViewerObject::loadTaskInvFile(const std::string& filename)
 	}
 	else
 	{
-		llwarns << "unable to load task inventory: " << filename_and_local_path
-				<< llendl;
+		LL_WARNS() << "unable to load task inventory: " << filename_and_local_path
+				<< LL_ENDL;
 		return FALSE;
 	}
 	doInventoryCallback();
@@ -3053,7 +3053,7 @@ void LLViewerObject::doInventoryCallback()
 		}
 		else
 		{
-			llinfos << "LLViewerObject::doInventoryCallback() deleting bad listener entry." << llendl;
+			LL_INFOS() << "LLViewerObject::doInventoryCallback() deleting bad listener entry." << LL_ENDL;
 			delete info;
 			mInventoryCallbacks.erase(curiter);
 		}
@@ -3201,7 +3201,7 @@ LLInventoryObject* LLViewerObject::getInventoryRoot()
 LLViewerInventoryItem* LLViewerObject::getInventoryItemByAsset(const LLUUID& asset_id)
 {
 	if (mInventoryDirty)
-		llwarns << "Peforming inventory lookup for object " << mID << " that has dirty inventory!" << llendl;
+		LL_WARNS() << "Peforming inventory lookup for object " << mID << " that has dirty inventory!" << LL_ENDL;
 
 	LLViewerInventoryItem* rv = NULL;
 	if(mInventory)
@@ -3606,7 +3606,7 @@ void LLViewerObject::addNVPair(const std::string& data)
 
 //	char splat[MAX_STRING];
 //	temp->printNameValue(splat);
-//	llinfos << "addNVPair " << splat << llendl;
+//	LL_INFOS() << "addNVPair " << splat << LL_ENDL;
 
 	name_value_map_t::iterator iter = mNameValuePairs.find(nv->mName);
 	if (iter != mNameValuePairs.end())
@@ -3620,7 +3620,7 @@ void LLViewerObject::addNVPair(const std::string& data)
 		else
 		{
 			delete nv;
-//			llinfos << "Trying to write to Read Only NVPair " << temp->mName << " in addNVPair()" << llendl;
+//			LL_INFOS() << "Trying to write to Read Only NVPair " << temp->mName << " in addNVPair()" << LL_ENDL;
 			return;
 		}
 	}
@@ -3631,7 +3631,7 @@ BOOL LLViewerObject::removeNVPair(const std::string& name)
 {
 	char* canonical_name = gNVNameTable.addString(name);
 
-	lldebugs << "LLViewerObject::removeNVPair(): " << name << llendl;
+	LL_DEBUGS() << "LLViewerObject::removeNVPair(): " << name << LL_ENDL;
 
 	name_value_map_t::iterator iter = mNameValuePairs.find(canonical_name);
 	if (iter != mNameValuePairs.end())
@@ -3657,7 +3657,7 @@ BOOL LLViewerObject::removeNVPair(const std::string& name)
 		}
 		else
 		{
-			lldebugs << "removeNVPair - No region for object" << llendl;
+			LL_DEBUGS() << "removeNVPair - No region for object" << LL_ENDL;
 		}
 	}
 	return FALSE;
@@ -4437,7 +4437,7 @@ S32 LLViewerObject::setTEColor(const U8 te, const LLColor4& color)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (color != tep->getColor())
 	{
@@ -4457,7 +4457,7 @@ S32 LLViewerObject::setTEBumpmap(const U8 te, const U8 bump)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (bump != tep->getBumpmap())
 	{
@@ -4478,7 +4478,7 @@ S32 LLViewerObject::setTETexGen(const U8 te, const U8 texgen)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (texgen != tep->getTexGen())
 	{
@@ -4494,7 +4494,7 @@ S32 LLViewerObject::setTEMediaTexGen(const U8 te, const U8 media)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (media != tep->getMediaTexGen())
 	{
@@ -4510,7 +4510,7 @@ S32 LLViewerObject::setTEShiny(const U8 te, const U8 shiny)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (shiny != tep->getShiny())
 	{
@@ -4526,7 +4526,7 @@ S32 LLViewerObject::setTEFullbright(const U8 te, const U8 fullbright)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (fullbright != tep->getFullbright())
 	{
@@ -4548,7 +4548,7 @@ S32 LLViewerObject::setTEMediaFlags(const U8 te, const U8 media_flags)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (media_flags != tep->getMediaFlags())
 	{
@@ -4571,7 +4571,7 @@ S32 LLViewerObject::setTEGlow(const U8 te, const F32 glow)
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 	}
 	else if (glow != tep->getGlow())
 	{
@@ -4614,7 +4614,7 @@ S32 LLViewerObject::setTEMaterialParams(const U8 te, const LLMaterialPtr pMateri
 	const LLTextureEntry *tep = getTE(te);
 	if (!tep)
 	{
-		llwarns << "No texture entry for te " << (S32)te << ", object " << mID << llendl;
+		LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL;
 		return 0;
 	}
 
@@ -4735,7 +4735,7 @@ LLViewerTexture *LLViewerObject::getTEImage(const U8 face) const
 		}
 	}
 
-	llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl;
+	LL_ERRS() << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << LL_ENDL;
 
 	return NULL;
 }
@@ -4758,7 +4758,7 @@ LLViewerTexture *LLViewerObject::getTENormalMap(const U8 face) const
 		}
 	}
 	
-	llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl;
+	LL_ERRS() << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << LL_ENDL;
 	
 	return NULL;
 }
@@ -4780,14 +4780,14 @@ LLViewerTexture *LLViewerObject::getTESpecularMap(const U8 face) const
 		}
 	}
 	
-	llerrs << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << llendl;
+	LL_ERRS() << llformat("Requested Image from invalid face: %d/%d",face,getNumTEs()) << LL_ENDL;
 	
 	return NULL;
 }
 
 void LLViewerObject::fitFaceTexture(const U8 face)
 {
-	llinfos << "fitFaceTexture not implemented" << llendl;
+	LL_INFOS() << "fitFaceTexture not implemented" << LL_ENDL;
 }
 
 
@@ -5036,7 +5036,7 @@ void LLViewerObject::unpackParticleSource(const S32 block_num, const LLUUID& own
 		// We need to be able to deal with a particle source that hasn't changed, but still got an update!
 		if (pss)
 		{
-// 			llinfos << "Making particle system with owner " << owner_id << llendl;
+// 			LL_INFOS() << "Making particle system with owner " << owner_id << LL_ENDL;
 			pss->setOwnerUUID(owner_id);
 			mPartSourcep = pss;
 			LLViewerPartSim::getInstance()->addPartSource(pss);
@@ -5083,7 +5083,7 @@ void LLViewerObject::unpackParticleSource(LLDataPacker &dp, const LLUUID& owner_
 		// We need to be able to deal with a particle source that hasn't changed, but still got an update!
 		if (pss)
 		{
-// 			llinfos << "Making particle system with owner " << owner_id << llendl;
+// 			LL_INFOS() << "Making particle system with owner " << owner_id << LL_ENDL;
 			pss->setOwnerUUID(owner_id);
 			mPartSourcep = pss;
 			LLViewerPartSim::getInstance()->addPartSource(pss);
@@ -5167,7 +5167,7 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow
 			// At least, this appears to be how the scripts work.
 			// The attached sound ID is set to NULL to avoid it playing back when the
 			// object rezzes in on non-looping sounds.
-			//llinfos << "Clearing attached sound " << mAudioSourcep->getCurrentData()->getID() << llendl;
+			//LL_INFOS() << "Clearing attached sound " << mAudioSourcep->getCurrentData()->getID() << LL_ENDL;
 			gAudiop->cleanupAudioSource(mAudioSourcep);
 			mAudioSourcep = NULL;
 		}
@@ -5182,7 +5182,7 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow
 		&& mAudioSourcep && mAudioSourcep->isLoop() && mAudioSourcep->getCurrentData()
 		&& mAudioSourcep->getCurrentData()->getID() == audio_uuid)
 	{
-		//llinfos << "Already playing this sound on a loop, ignoring" << llendl;
+		//LL_INFOS() << "Already playing this sound on a loop, ignoring" << LL_ENDL;
 		return;
 	}
 
@@ -5196,7 +5196,7 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow
 	if (mAudioSourcep && mAudioSourcep->isMuted() &&
 	    mAudioSourcep->getCurrentData() && mAudioSourcep->getCurrentData()->getID() == audio_uuid)
 	{
-		//llinfos << "Already having this sound as muted sound, ignoring" << llendl;
+		//LL_INFOS() << "Already having this sound as muted sound, ignoring" << LL_ENDL;
 		return;
 	}
 
@@ -5219,7 +5219,7 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow
 		// Play this sound if region maturity permits
 		if( gAgent.canAccessMaturityAtGlobal(this->getPositionGlobal()) )
 		{
-			//llinfos << "Playing attached sound " << audio_uuid << llendl;
+			//LL_INFOS() << "Playing attached sound " << audio_uuid << LL_ENDL;
 			mAudioSourcep->play(audio_uuid);
 		}
 	}
@@ -5302,7 +5302,7 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para
 	  }
 	  default:
 	  {
-		  llinfos << "Unknown param type." << llendl;
+		  LL_INFOS() << "Unknown param type." << LL_ENDL;
 		  break;
 	  }
 	};
@@ -5440,7 +5440,7 @@ void LLViewerObject::parameterChanged(U16 param_type, LLNetworkData* data, BOOL
 		}
 		else
 		{
-			llwarns << "Failed to send object extra parameters: " << param_type << llendl;
+			LL_WARNS() << "Failed to send object extra parameters: " << param_type << LL_ENDL;
 		}
 	}
 }
@@ -5705,7 +5705,7 @@ void LLViewerObject::setRegion(LLViewerRegion *regionp)
 {
 	if (!regionp)
 	{
-		llwarns << "viewer object set region to NULL" << llendl;
+		LL_WARNS() << "viewer object set region to NULL" << LL_ENDL;
 	}
 	if(regionp != mRegionp)
 	{
@@ -5738,10 +5738,10 @@ void	LLViewerObject::updateRegion(LLViewerRegion *regionp)
 //	if (regionp)
 //	{
 //		F64 now = LLFrameTimer::getElapsedSeconds();
-//		llinfos << "Updating to region " << regionp->getName()
+//		LL_INFOS() << "Updating to region " << regionp->getName()
 //			<< ", ms since last update message: " << (F32)((now - mLastMessageUpdateSecs) * 1000.0)
 //			<< ", ms since last interpolation: " << (F32)((now - mLastInterpUpdateSecs) * 1000.0) 
-//			<< llendl;
+//			<< LL_ENDL;
 //	}
 }
 
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index d61b6ba18a..e8f68527e9 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -170,7 +170,7 @@ BOOL LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject* objectp)
 		U64 ipport = (((U64)ip) << 32) | (U64)port;
 		U32 index = sIPAndPortToIndex[ipport];
 		
-		// llinfos << "Removing object from table, local ID " << local_id << ", ip " << ip << ":" << port << llendl;
+		// LL_INFOS() << "Removing object from table, local ID " << local_id << ", ip " << ip << ":" << port << LL_ENDL;
 		
 		U64	indexid = (((U64)index) << 32) | (U64)local_id;
 		
@@ -187,8 +187,8 @@ BOOL LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject* objectp)
 			return TRUE;
 		}
 		// UUIDs did not match - this would zap a valid entry, so don't erase it
-		//llinfos << "Tried to erase entry where id in table (" 
-		//		<< iter->second	<< ") did not match object " << object.getID() << llendl;
+		//LL_INFOS() << "Tried to erase entry where id in table (" 
+		//		<< iter->second	<< ") did not match object " << object.getID() << LL_ENDL;
 	}
 	
 	return FALSE ;
@@ -213,8 +213,8 @@ void LLViewerObjectList::setUUIDAndLocal(const LLUUID &id,
 
 	sIndexAndLocalIDToUUID[indexid] = id;
 	
-	//llinfos << "Adding object to table, full ID " << id
-	//	<< ", local ID " << local_id << ", ip " << ip << ":" << port << llendl;
+	//LL_INFOS() << "Adding object to table, full ID " << id
+	//	<< ", local ID " << local_id << ", ip " << ip << ":" << port << LL_ENDL;
 }
 
 S32 gFullObjectUpdates = 0;
@@ -277,8 +277,8 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp,
 	{
 		if ( LLToolMgr::getInstance()->getCurrentTool() != LLToolPie::getInstance() )
 		{
-			// llinfos << "DEBUG selecting " << objectp->mID << " " 
-			// << objectp->mLocalID << llendl;
+			// LL_INFOS() << "DEBUG selecting " << objectp->mID << " " 
+			// << objectp->mLocalID << LL_ENDL;
 			LLSelectMgr::getInstance()->selectObjectAndFamily(objectp);
 			dialog_refresh_all();
 		}
@@ -350,7 +350,7 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 		
 		if (!objectp)
 		{
-			llinfos << "createObject failure for object: " << fullid << llendl;
+			LL_INFOS() << "createObject failure for object: " << fullid << LL_ENDL;
 			recorder.objectUpdateFailure(entry->getLocalID(), OUT_FULL_CACHED, 0);
 			return NULL;
 		}
@@ -360,7 +360,7 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 
 	if (objectp->isDead())
 	{
-		llwarns << "Dead object " << objectp->mID << " in UUID map 1!" << llendl;
+		LL_WARNS() << "Dead object " << objectp->mID << " in UUID map 1!" << LL_ENDL;
 	}
 		
 	processUpdateCore(objectp, NULL, 0, OUT_FULL_CACHED, cached_dpp, justCreated, true);
@@ -395,7 +395,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 	// I don't think this case is ever hit.  TODO* Test this.
 	if (!compressed && update_type != OUT_FULL)
 	{
-		//llinfos << "TEST: !cached && !compressed && update_type != OUT_FULL" << llendl;
+		//LL_INFOS() << "TEST: !cached && !compressed && update_type != OUT_FULL" << LL_ENDL;
 		gTerseObjectUpdates += num_objects;
 		/*
 		S32 size;
@@ -407,7 +407,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 		{
 			size = mesgsys->getReceiveSize();
 		}
-		llinfos << "Received terse " << num_objects << " in " << size << " byte (" << size/num_objects << ")" << llendl;
+		LL_INFOS() << "Received terse " << num_objects << " in " << size << " byte (" << size/num_objects << ")" << LL_ENDL;
 		*/
 	}
 	else
@@ -423,7 +423,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			size = mesgsys->getReceiveSize();
 		}
 
-		llinfos << "Received " << num_objects << " in " << size << " byte (" << size/num_objects << ")" << llendl;
+		LL_INFOS() << "Received " << num_objects << " in " << size << " byte (" << size/num_objects << ")" << LL_ENDL;
 		*/
 		gFullObjectUpdates += num_objects;
 	}
@@ -435,7 +435,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 
 	if (!regionp)
 	{
-		llwarns << "Object update from unknown region! " << region_handle << llendl;
+		LL_WARNS() << "Object update from unknown region! " << region_handle << LL_ENDL;
 		return;
 	}
 
@@ -487,7 +487,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 								 gMessageSystem->getSenderPort());
 				if (fullid.isNull())
 				{
-					// llwarns << "update for unknown localid " << local_id << " host " << gMessageSystem->getSender() << ":" << gMessageSystem->getSenderPort() << llendl;
+					// LL_WARNS() << "update for unknown localid " << local_id << " host " << gMessageSystem->getSender() << ":" << gMessageSystem->getSenderPort() << LL_ENDL;
 					mNumUnknownUpdates++;
 				}
 			}
@@ -503,7 +503,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 							gMessageSystem->getSenderPort());
 			if (fullid.isNull())
 			{
-				// llwarns << "update for unknown localid " << local_id << " host " << gMessageSystem->getSender() << llendl;
+				// LL_WARNS() << "update for unknown localid " << local_id << " host " << gMessageSystem->getSender() << LL_ENDL;
 				mNumUnknownUpdates++;
 			}
 		}
@@ -514,7 +514,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
 			msg_size += sizeof(LLUUID);
 			msg_size += sizeof(U32);
-			// llinfos << "Full Update, obj " << local_id << ", global ID" << fullid << "from " << mesgsys->getSender() << llendl;
+			// LL_INFOS() << "Full Update, obj " << local_id << ", global ID" << fullid << "from " << mesgsys->getSender() << LL_ENDL;
 		}
 		objectp = findObject(fullid);
 
@@ -532,13 +532,13 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 		{
 			//if (objectp->getRegion())
 			//{
-			//	llinfos << "Local ID change: Removing object from table, local ID " << objectp->mLocalID 
+			//	LL_INFOS() << "Local ID change: Removing object from table, local ID " << objectp->mLocalID 
 			//			<< ", id from message " << local_id << ", from " 
 			//			<< LLHost(objectp->getRegion()->getHost().getAddress(), objectp->getRegion()->getHost().getPort())
 			//			<< ", full id " << fullid 
 			//			<< ", objects id " << objectp->getID()
 			//			<< ", regionp " << (U32) regionp << ", object region " << (U32) objectp->getRegion()
-			//			<< llendl;
+			//			<< LL_ENDL;
 			//}
 			removeFromLocalIDTable(objectp);
 			setUUIDAndLocal(fullid,
@@ -563,7 +563,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			{
 				if (update_type == OUT_TERSE_IMPROVED)
 				{
-					// llinfos << "terse update for an unknown object (compressed):" << fullid << llendl;
+					// LL_INFOS() << "terse update for an unknown object (compressed):" << fullid << LL_ENDL;
 					recorder.objectUpdateFailure(local_id, update_type, msg_size);
 					continue;
 				}
@@ -572,7 +572,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			{
 				if (update_type != OUT_FULL)
 				{
-					//llinfos << "terse update for an unknown object:" << fullid << llendl;
+					//LL_INFOS() << "terse update for an unknown object:" << fullid << LL_ENDL;
 					recorder.objectUpdateFailure(local_id, update_type, msg_size);
 					continue;
 				}
@@ -585,7 +585,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			if (mDeadObjects.find(fullid) != mDeadObjects.end())
 			{
 				mNumDeadObjectUpdates++;
-				//llinfos << "update for a dead object:" << fullid << llendl;
+				//LL_INFOS() << "update for a dead object:" << fullid << LL_ENDL;
 				recorder.objectUpdateFailure(local_id, update_type, msg_size);
 				continue;
 			}
@@ -594,7 +594,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			objectp = createObject(pcode, regionp, fullid, local_id, gMessageSystem->getSender());
 			if (!objectp)
 			{
-				llinfos << "createObject failure for object: " << fullid << llendl;
+				LL_INFOS() << "createObject failure for object: " << fullid << LL_ENDL;
 				recorder.objectUpdateFailure(local_id, update_type, msg_size);
 				continue;
 			}
@@ -605,7 +605,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 
 		if (objectp->isDead())
 		{
-			llwarns << "Dead object " << objectp->mID << " in UUID map 1!" << llendl;
+			LL_WARNS() << "Dead object " << objectp->mID << " in UUID map 1!" << LL_ENDL;
 		}
 
 		bool bCached = false;
@@ -671,7 +671,7 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
 	LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(region_handle);
 	if (!regionp)
 	{
-		llwarns << "Object update from unknown region! " << region_handle << llendl;
+		LL_WARNS() << "Object update from unknown region! " << region_handle << LL_ENDL;
 		return;
 	}
 
@@ -810,10 +810,10 @@ public:
 
 	void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 	{
-		llwarns
+		LL_WARNS()
 			<< "Transport error requesting object cost "
 			<< "[status: " << statusNum << "]: "
-			<< content << llendl;
+			<< content << LL_ENDL;
 
 		// TODO*: Error message to user
 		// For now just clear the request from the pending list
@@ -826,11 +826,11 @@ public:
 		{
 			// Improper response or the request had an error,
 			// show an error to the user?
-			llwarns
+			LL_WARNS()
 				<< "Application level error when fetching object "
 				<< "cost.  Message: " << content["error"]["message"].asString()
 				<< ", identifier: " << content["error"]["identifier"].asString()
-				<< llendl;
+				<< LL_ENDL;
 
 			// TODO*: Adaptively adjust request size if the
 			// service says we've requested too many and retry
@@ -899,10 +899,10 @@ public:
 
 	void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 	{
-		llwarns
+		LL_WARNS()
 			<< "Transport error requesting object physics flags "
 			<< "[status: " << statusNum << "]: "
-			<< content << llendl;
+			<< content << LL_ENDL;
 
 		// TODO*: Error message to user
 		// For now just clear the request from the pending list
@@ -915,11 +915,11 @@ public:
 		{
 			// Improper response or the request had an error,
 			// show an error to the user?
-			llwarns
+			LL_WARNS()
 				<< "Application level error when fetching object "
 				<< "physics flags.  Message: " << content["error"]["message"].asString()
 				<< ", identifier: " << content["error"]["identifier"].asString()
-				<< llendl;
+				<< LL_ENDL;
 
 			// TODO*: Adaptively adjust request size if the
 			// service says we've requested too many and retry
@@ -984,7 +984,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 		phase_out_time < 0.0 ||
 		phase_out_time > interp_time)
 	{
-		llwarns << "Invalid values for InterpolationTime or InterpolationPhaseOut, resetting to defaults" << llendl;
+		LL_WARNS() << "Invalid values for InterpolationTime or InterpolationPhaseOut, resetting to defaults" << LL_ENDL;
 		interp_time = 3.0f;
 		phase_out_time = 1.0f;
 	}
@@ -1044,7 +1044,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 			else
 			{	// There shouldn't be any NULL pointers in the list, but they have caused
 				// crashes before.  This may be idleUpdate() messing with the list.
-				llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl;
+				LL_WARNS() << "LLViewerObjectList::update has a NULL objectp" << LL_ENDL;
 			}
 		}
 	}
@@ -1280,7 +1280,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 {
 	if (mDeadObjects.find(objectp->mID) != mDeadObjects.end())
 	{
-		llinfos << "Object " << objectp->mID << " already on dead list!" << llendl;	
+		LL_INFOS() << "Object " << objectp->mID << " already on dead list!" << LL_ENDL;	
 	}
 	else
 	{
@@ -1294,16 +1294,16 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 	
 	//if (objectp->getRegion())
 	//{
-	//	llinfos << "cleanupReferences removing object from table, local ID " << objectp->mLocalID << ", ip " 
+	//	LL_INFOS() << "cleanupReferences removing object from table, local ID " << objectp->mLocalID << ", ip " 
 	//				<< objectp->getRegion()->getHost().getAddress() << ":" 
-	//				<< objectp->getRegion()->getHost().getPort() << llendl;
+	//				<< objectp->getRegion()->getHost().getPort() << LL_ENDL;
 	//}	
 	
 	removeFromLocalIDTable(objectp);
 
 	if (objectp->onActiveList())
 	{
-		//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << llendl;
+		//LL_INFOS() << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << LL_ENDL;
 		objectp->setOnActiveList(FALSE);
 		removeFromActiveList(objectp);
 	}
@@ -1403,19 +1403,19 @@ void LLViewerObjectList::killAllObjects()
 
 	if(!mObjects.empty())
 	{
-		llwarns << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.size() << llendl;
+		LL_WARNS() << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.size() << LL_ENDL;
 		mObjects.clear();
 	}
 
 	if (!mActiveObjects.empty())
 	{
-		llwarns << "Some objects still on active object list!" << llendl;
+		LL_WARNS() << "Some objects still on active object list!" << LL_ENDL;
 		mActiveObjects.clear();
 	}
 
 	if (!mMapObjects.empty())
 	{
-		llwarns << "Some objects still on map object list!" << llendl;
+		LL_WARNS() << "Some objects still on map object list!" << LL_ENDL;
 		mMapObjects.clear();
 	}
 }
@@ -1506,7 +1506,7 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 	{
 		if (active)
 		{
-			//llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl;
+			//LL_INFOS() << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << LL_ENDL;
 			S32 idx = objectp->getListIndex();
 			if (idx <= -1)
 			{
@@ -1522,13 +1522,13 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
 				if (idx >= mActiveObjects.size() ||
 					mActiveObjects[idx] != objectp)
 				{
-					llwarns << "Invalid object list index detected!" << llendl;
+					LL_WARNS() << "Invalid object list index detected!" << LL_ENDL;
 				}
 			}
 		}
 		else
 		{
-			//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl;
+			//LL_INFOS() << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << LL_ENDL;
 			removeFromActiveList(objectp);
 			objectp->setOnActiveList(FALSE);
 		}
@@ -1566,7 +1566,7 @@ void LLViewerObjectList::updateObjectCost(const LLUUID& object_id, F32 object_co
 
 void LLViewerObjectList::onObjectCostFetchFailure(const LLUUID& object_id)
 {
-	//llwarns << "Failed to fetch object cost for object: " << object_id << llendl;
+	//LL_WARNS() << "Failed to fetch object cost for object: " << object_id << LL_ENDL;
 	mPendingObjectCost.erase(object_id);
 }
 
@@ -1605,7 +1605,7 @@ void LLViewerObjectList::updatePhysicsProperties(const LLUUID& object_id,
 
 void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id)
 {
-	//llwarns << "Failed to fetch physics flags for object: " << object_id << llendl;
+	//LL_WARNS() << "Failed to fetch physics flags for object: " << object_id << LL_ENDL;
 	mPendingPhysicsFlags.erase(object_id);
 }
 
@@ -1708,7 +1708,7 @@ void LLViewerObjectList::clearAllMapObjectsInRegion(LLViewerRegion* regionp)
 
 	if(dead_object_list.size() > 0)
 	{
-		llwarns << "There are " << dead_object_list.size() << " dead objects on the map!" << llendl ;
+		LL_WARNS() << "There are " << dead_object_list.size() << " dead objects on the map!" << LL_ENDL ;
 
 		for(std::set<LLViewerObject*>::iterator iter = dead_object_list.begin(); iter != dead_object_list.end(); ++iter)
 		{
@@ -1717,7 +1717,7 @@ void LLViewerObjectList::clearAllMapObjectsInRegion(LLViewerRegion* regionp)
 	}
 	if(region_object_list.size() > 0)
 	{
-		llwarns << "There are " << region_object_list.size() << " objects not removed from the deleted region!" << llendl ;
+		LL_WARNS() << "There are " << region_object_list.size() << " objects not removed from the deleted region!" << LL_ENDL ;
 
 		for(std::set<LLViewerObject*>::iterator iter = region_object_list.begin(); iter != region_object_list.end(); ++iter)
 		{
@@ -1983,7 +1983,7 @@ LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLVi
 	LLViewerObject *objectp = LLViewerObject::createObject(fullid, pcode, regionp);
 	if (!objectp)
 	{
-// 		llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << llendl;
+// 		LL_WARNS() << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << LL_ENDL;
 		return NULL;
 	}
 
@@ -2003,7 +2003,7 @@ LLViewerObject *LLViewerObjectList::createObjectFromCache(const LLPCode pcode, L
 	LLViewerObject *objectp = LLViewerObject::createObject(uuid, pcode, regionp);
 	if (!objectp)
 	{
-// 		llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << " id:" << fullid << llendl;
+// 		LL_WARNS() << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << " id:" << fullid << LL_ENDL;
 		return NULL;
 	}
 
@@ -2037,7 +2037,7 @@ LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRe
 	LLViewerObject *objectp = LLViewerObject::createObject(fullid, pcode, regionp);
 	if (!objectp)
 	{
-// 		llwarns << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << " id:" << fullid << llendl;
+// 		LL_WARNS() << "Couldn't create object of type " << LLPrimitive::pCodeToString(pcode) << " id:" << fullid << LL_ENDL;
 		return NULL;
 	}
 	if(regionp)
@@ -2106,7 +2106,7 @@ void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip
 				// object probably ISN'T being reparented, but just got an object
 				// update out of order (child update before parent).
 				make_invisible = false;
-				//llinfos << "Don't make object handoffs invisible!" << llendl;
+				//LL_INFOS() << "Don't make object handoffs invisible!" << LL_ENDL;
 			}
 		}
 
@@ -2138,8 +2138,8 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 {
 	if (objectp->isDead())
 	{
-		llwarns << "Trying to find orphans for dead obj " << objectp->mID 
-			<< ":" << objectp->getPCodeString() << llendl;
+		LL_WARNS() << "Trying to find orphans for dead obj " << objectp->mID 
+			<< ":" << objectp->getPCodeString() << LL_ENDL;
 		return;
 	}
 
@@ -2179,8 +2179,8 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 		{
 			if (childp == objectp)
 			{
-				llwarns << objectp->mID << " has self as parent, skipping!" 
-					<< llendl;
+				LL_WARNS() << objectp->mID << " has self as parent, skipping!" 
+					<< LL_ENDL;
 				continue;
 			}
 
@@ -2213,7 +2213,7 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
 		}
 		else
 		{
-			llinfos << "Missing orphan child, removing from list" << llendl;
+			LL_INFOS() << "Missing orphan child, removing from list" << LL_ENDL;
 
 			iter = mOrphanChildren.erase(iter);
 		}
diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h
index 2fabd50e97..20ed7d5562 100755
--- a/indra/newview/llviewerobjectlist.h
+++ b/indra/newview/llviewerobjectlist.h
@@ -272,7 +272,7 @@ inline LLViewerObject *LLViewerObjectList::getObject(const S32 index)
 	objectp = mObjects[index];
 	if (objectp->isDead())
 	{
-		//llwarns << "Dead object " << objectp->mID << " in getObject" << llendl;
+		//LL_WARNS() << "Dead object " << objectp->mID << " in getObject" << LL_ENDL;
 		return NULL;
 	}
 	return objectp;
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index bba3d26e09..443468235a 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -470,7 +470,7 @@ bool LLviewerOctreeGroup::removeFromGroup(LLViewerOctreeEntry* entry)
 	{
 		if (!mOctreeNode->remove(entry)) //this could cause *this* pointer to be destroyed, so no more function calls after this.
 		{
-			OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << llendl;
+			OCT_ERRS << "Could not remove LLVOCacheEntry from LLVOCacheOctreeGroup" << LL_ENDL;
 			return false;
 		}
 	}	
@@ -622,7 +622,7 @@ void LLviewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNo
 	}
 	else
 	{
-		OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << llendl;
+		OCT_ERRS << "LLviewerOctreeGroup redundancy detected." << LL_ENDL;
 	}
 
 	unbound();
@@ -667,7 +667,7 @@ bool LLviewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4
 	{	//don't do anything if there are no objects
 		if (empty && mOctreeNode->getParent())
 		{	//only root is allowed to be empty
-			OCT_ERRS << "Empty leaf found in octree." << llendl;
+			OCT_ERRS << "Empty leaf found in octree." << LL_ENDL;
 		}
 		return false;
 	}
@@ -862,7 +862,7 @@ void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, Octr
 	}
 	else
 	{
-		OCT_ERRS << "LLOcclusionCullingGroup redundancy detected." << llendl;
+		OCT_ERRS << "LLOcclusionCullingGroup redundancy detected." << LL_ENDL;
 	}
 
 	unbound();
@@ -1437,10 +1437,10 @@ void LLViewerOctreeCull::visit(const OctreeNode* branch)
 void LLViewerOctreeDebug::visit(const OctreeNode* branch)
 {
 #if 0
-	llinfos << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << llendl;
+	LL_INFOS() << "Node: " << (U32)branch << " # Elements: " << branch->getElementCount() << " # Children: " << branch->getChildCount() << LL_ENDL;
 	for (U32 i = 0; i < branch->getChildCount(); i++)
 	{
-		llinfos << "Child " << i << " : " << (U32)branch->getChild(i) << llendl;
+		LL_INFOS() << "Child " << i << " : " << (U32)branch->getChild(i) << LL_ENDL;
 	}
 #endif
 	LLviewerOctreeGroup* group = (LLviewerOctreeGroup*) branch->getListener(0);
@@ -1455,22 +1455,22 @@ void LLViewerOctreeDebug::processGroup(LLviewerOctreeGroup* group)
 	LLVector3 vec[2];
 	vec[0].set(vec4[0].getF32ptr());
 	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "Bounds: " << vec[0] << " : " << vec[1] << llendl;
+	LL_INFOS() << "Bounds: " << vec[0] << " : " << vec[1] << LL_ENDL;
 
 	vec4 = group->getExtents();
 	vec[0].set(vec4[0].getF32ptr());
 	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "Extents: " << vec[0] << " : " << vec[1] << llendl;
+	LL_INFOS() << "Extents: " << vec[0] << " : " << vec[1] << LL_ENDL;
 
 	vec4 = group->getObjectBounds();
 	vec[0].set(vec4[0].getF32ptr());
 	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "ObjectBounds: " << vec[0] << " : " << vec[1] << llendl;
+	LL_INFOS() << "ObjectBounds: " << vec[0] << " : " << vec[1] << LL_ENDL;
 
 	vec4 = group->getObjectExtents();
 	vec[0].set(vec4[0].getF32ptr());
 	vec[1].set(vec4[1].getF32ptr());
-	llinfos << "ObjectExtents: " << vec[0] << " : " << vec[1] << llendl;
+	LL_INFOS() << "ObjectExtents: " << vec[0] << " : " << vec[1] << LL_ENDL;
 #endif
 }
 //--------------------------------------------------------------
diff --git a/indra/newview/llviewerparcelmedia.cpp b/indra/newview/llviewerparcelmedia.cpp
index 386b2fd400..b55154f889 100755
--- a/indra/newview/llviewerparcelmedia.cpp
+++ b/indra/newview/llviewerparcelmedia.cpp
@@ -159,7 +159,7 @@ void LLViewerParcelMedia::update(LLParcel* parcel)
 // static
 void LLViewerParcelMedia::play(LLParcel* parcel)
 {
-	lldebugs << "LLViewerParcelMedia::play" << llendl;
+	LL_DEBUGS() << "LLViewerParcelMedia::play" << LL_ENDL;
 
 	if (!parcel) return;
 
@@ -471,7 +471,7 @@ void LLViewerParcelMedia::sendMediaNavigateMessage(const std::string& url)
 	}
 	else
 	{
-		llwarns << "can't get ParcelNavigateMedia capability" << llendl;
+		LL_WARNS() << "can't get ParcelNavigateMedia capability" << LL_ENDL;
 	}
 
 }
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index b25d042d28..10a3cd517c 100755
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -197,22 +197,22 @@ LLViewerParcelMgr::~LLViewerParcelMgr()
 
 void LLViewerParcelMgr::dump()
 {
-	llinfos << "Parcel Manager Dump" << llendl;
-	llinfos << "mSelected " << S32(mSelected) << llendl;
-	llinfos << "Selected parcel: " << llendl;
-	llinfos << mWestSouth << " to " << mEastNorth << llendl;
+	LL_INFOS() << "Parcel Manager Dump" << LL_ENDL;
+	LL_INFOS() << "mSelected " << S32(mSelected) << LL_ENDL;
+	LL_INFOS() << "Selected parcel: " << LL_ENDL;
+	LL_INFOS() << mWestSouth << " to " << mEastNorth << LL_ENDL;
 	mCurrentParcel->dump();
-	llinfos << "banning " << mCurrentParcel->mBanList.size() << llendl;
+	LL_INFOS() << "banning " << mCurrentParcel->mBanList.size() << LL_ENDL;
 	
 	access_map_const_iterator cit = mCurrentParcel->mBanList.begin();
 	access_map_const_iterator end = mCurrentParcel->mBanList.end();
 	for ( ; cit != end; ++cit)
 	{
-		llinfos << "ban id " << (*cit).first << llendl;
+		LL_INFOS() << "ban id " << (*cit).first << LL_ENDL;
 	}
-	llinfos << "Hover parcel:" << llendl;
+	LL_INFOS() << "Hover parcel:" << LL_ENDL;
 	mHoverParcel->dump();
-	llinfos << "Agent parcel:" << llendl;
+	LL_INFOS() << "Agent parcel:" << LL_ENDL;
 	mAgentParcel->dump();
 }
 
@@ -947,7 +947,7 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id)
 		return;
 	}
 
-	llinfos << "Claiming " << mWestSouth << " to " << mEastNorth << llendl;
+	LL_INFOS() << "Claiming " << mWestSouth << " to " << mEastNorth << LL_ENDL;
 
 	// BUG: Only works for the region containing mWestSouthBottom
 	LLVector3d east_north_region_check( mEastNorth );
@@ -970,7 +970,7 @@ void LLViewerParcelMgr::sendParcelGodForceOwner(const LLUUID& owner_id)
 		return;
 	}
 
-	llinfos << "Region " << region->getOriginGlobal() << llendl;
+	LL_INFOS() << "Region " << region->getOriginGlobal() << LL_ENDL;
 
 	LLSD payload;
 	payload["owner_id"] = owner_id;
@@ -1110,8 +1110,8 @@ LLViewerParcelMgr::ParcelBuyInfo* LLViewerParcelMgr::setupParcelBuy(
 	
 	if (is_claim)
 	{
-		llinfos << "Claiming " << mWestSouth << " to " << mEastNorth << llendl;
-		llinfos << "Region " << region->getOriginGlobal() << llendl;
+		LL_INFOS() << "Claiming " << mWestSouth << " to " << mEastNorth << LL_ENDL;
+		LL_INFOS() << "Region " << region->getOriginGlobal() << LL_ENDL;
 
 		// BUG: Only works for the region containing mWestSouthBottom
 		LLVector3d east_north_region_check( mEastNorth );
@@ -1281,7 +1281,7 @@ void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_ag
 
 	LLViewerRegion *region = use_agent_region ? gAgent.getRegion() : LLWorld::getInstance()->getRegionFromPosGlobal( mWestSouth );
 	if (!region) return;
-	//llinfos << "found region: " << region->getName() << llendl;
+	//LL_INFOS() << "found region: " << region->getName() << LL_ENDL;
 
 	LLSD body;
 	std::string url = region->getCapability("ParcelPropertiesUpdate");
@@ -1291,8 +1291,8 @@ void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_ag
 		U32 message_flags = 0x01;
 		body["flags"] = ll_sd_from_U32(message_flags);
 		parcel->packMessage(body);
-		llinfos << "Sending parcel properties update via capability to: "
-			<< url << llendl;
+		LL_INFOS() << "Sending parcel properties update via capability to: "
+			<< url << LL_ENDL;
 		LLHTTPClient::post(url, body, new LLHTTPClient::Responder());
 	}
 	else
@@ -1386,7 +1386,7 @@ void LLViewerParcelMgr::processParcelOverlay(LLMessageSystem *msg, void **user)
 
 	if (packed_overlay_size <= 0)
 	{
-		llwarns << "Overlay size " << packed_overlay_size << llendl;
+		LL_WARNS() << "Overlay size " << packed_overlay_size << LL_ENDL;
 		return;
 	}
 
@@ -1394,8 +1394,8 @@ void LLViewerParcelMgr::processParcelOverlay(LLMessageSystem *msg, void **user)
 	S32 expected_size = parcels_per_edge * parcels_per_edge / PARCEL_OVERLAY_CHUNKS;
 	if (packed_overlay_size != expected_size)
 	{
-		llwarns << "Got parcel overlay size " << packed_overlay_size
-			<< " expecting " << expected_size << llendl;
+		LL_WARNS() << "Got parcel overlay size " << packed_overlay_size
+			<< " expecting " << expected_size << LL_ENDL;
 		return;
 	}
 
@@ -1461,7 +1461,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
 	if (request_result == PARCEL_RESULT_NO_DATA)
 	{
 		// no valid parcel data
-		llinfos << "no valid parcel data" << llendl;
+		LL_INFOS() << "no valid parcel data" << LL_ENDL;
 		return;
 	}
 
@@ -1493,9 +1493,9 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
 	}
 	else
 	{
-		llinfos << "out of order agent parcel sequence id " << sequence_id
+		LL_INFOS() << "out of order agent parcel sequence id " << sequence_id
 			<< " last good " << parcel_mgr.mAgentParcelSequenceID
-			<< llendl;
+			<< LL_ENDL;
 		return;
 	}
 
@@ -1743,7 +1743,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
 					}
 					else
 					{
-						llinfos << "Stopping parcel music (invalid audio stream URL)" << llendl;
+						LL_INFOS() << "Stopping parcel music (invalid audio stream URL)" << LL_ENDL;
 						// clears the URL 
 						// null value causes fade out
 						LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLStringUtil::null);
@@ -1751,7 +1751,7 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
 				}
 				else if (!gAudiop->getInternetStreamURL().empty())
 				{
-					llinfos << "Stopping parcel music (parcel stream URL is empty)" << llendl;
+					LL_INFOS() << "Stopping parcel music (parcel stream URL is empty)" << LL_ENDL;
 					// null value causes fade out
 					LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLStringUtil::null);
 				}
@@ -1779,7 +1779,7 @@ void LLViewerParcelMgr::optionally_start_music(const std::string& music_url)
 		     gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) &&
 			 gSavedSettings.getBOOL("MediaTentativeAutoPlay")))
 		{
-			llinfos << "Starting parcel music " << music_url << llendl;
+			LL_INFOS() << "Starting parcel music " << music_url << LL_ENDL;
 			LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(music_url);
 		}
 		else
@@ -1808,7 +1808,7 @@ void LLViewerParcelMgr::processParcelAccessListReply(LLMessageSystem *msg, void
 	if (parcel_id != parcel->getLocalID())
 	{
 		LL_WARNS_ONCE("") << "processParcelAccessListReply for parcel " << parcel_id
-			<< " which isn't the selected parcel " << parcel->getLocalID()<< llendl;
+			<< " which isn't the selected parcel " << parcel->getLocalID()<< LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp
index e29eef2dda..4fd423b6f4 100755
--- a/indra/newview/llviewerparceloverlay.cpp
+++ b/indra/newview/llviewerparceloverlay.cpp
@@ -709,7 +709,7 @@ void LLViewerParcelOverlay::addPropertyLine(
 		break;
 
 	default:
-		llerrs << "Invalid edge in addPropertyLine" << llendl;
+		LL_ERRS() << "Invalid edge in addPropertyLine" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index a23a15da32..978c307c60 100755
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -125,7 +125,7 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 bo
 	
 	if (!mRegionp)
 	{
-		//llwarns << "No region at position, using agent region!" << llendl;
+		//LL_WARNS() << "No region at position, using agent region!" << LL_ENDL;
 		mRegionp = gAgent.getRegion();
 	}
 	mCenterAgent = center_agent;
@@ -451,12 +451,12 @@ void LLViewerPartSim::checkParticleCount(U32 size)
 {
 	if(LLViewerPartSim::sParticleCount2 != LLViewerPartSim::sParticleCount)
 	{
-		llerrs << "sParticleCount: " << LLViewerPartSim::sParticleCount << " ; sParticleCount2: " << LLViewerPartSim::sParticleCount2 << llendl ;
+		LL_ERRS() << "sParticleCount: " << LLViewerPartSim::sParticleCount << " ; sParticleCount2: " << LLViewerPartSim::sParticleCount2 << LL_ENDL ;
 	}
 
 	if(size > (U32)LLViewerPartSim::sParticleCount2)
 	{
-		llerrs << "curren particle size: " << LLViewerPartSim::sParticleCount2 << " array size: " << size << llendl ;
+		LL_ERRS() << "curren particle size: " << LLViewerPartSim::sParticleCount2 << " array size: " << size << LL_ENDL ;
 	}
 }
 
@@ -544,8 +544,8 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part)
 	if (part->mPosAgent.magVecSquared() > MAX_MAG || !part->mPosAgent.isFinite())
 	{
 #if 0 && !LL_RELEASE_FOR_DOWNLOAD
-		llwarns << "LLViewerPartSim::put Part out of range!" << llendl;
-		llwarns << part->mPosAgent << llendl;
+		LL_WARNS() << "LLViewerPartSim::put Part out of range!" << LL_ENDL;
+		LL_WARNS() << part->mPosAgent << LL_ENDL;
 #endif
 	}
 	else
@@ -574,9 +574,9 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part)
 									!(part->mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK));
 			if (!groupp->addPart(part))
 			{
-				llwarns << "LLViewerPartSim::put - Particle didn't go into its box!" << llendl;
-				llinfos << groupp->getCenterAgent() << llendl;
-				llinfos << part->mPosAgent << llendl;
+				LL_WARNS() << "LLViewerPartSim::put - Particle didn't go into its box!" << LL_ENDL;
+				LL_INFOS() << groupp->getCenterAgent() << LL_ENDL;
+				LL_INFOS() << part->mPosAgent << LL_ENDL;
 				mViewerPartGroups.pop_back() ;
 				delete groupp;
 				groupp = NULL ;
@@ -758,7 +758,7 @@ void LLViewerPartSim::updateSimulation()
 
 	updatePartBurstRate() ;
 
-	//llinfos << "Particles: " << sParticleCount << " Adaptive Rate: " << sParticleAdaptiveRate << llendl;
+	//LL_INFOS() << "Particles: " << sParticleCount << " Adaptive Rate: " << sParticleAdaptiveRate << LL_ENDL;
 }
 
 void LLViewerPartSim::updatePartBurstRate()
@@ -796,7 +796,7 @@ void LLViewerPartSim::addPartSource(LLPointer<LLViewerPartSource> sourcep)
 {
 	if (!sourcep)
 	{
-		llwarns << "Null part source!" << llendl;
+		LL_WARNS() << "Null part source!" << LL_ENDL;
 		return;
 	}
 	sourcep->setStart() ;
diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp
index b311f659fb..e8ce82e087 100755
--- a/indra/newview/llviewerpartsource.cpp
+++ b/indra/newview/llviewerpartsource.cpp
@@ -67,7 +67,7 @@ void LLViewerPartSource::updatePart(LLViewerPart &part, const F32 dt)
 
 void LLViewerPartSource::update(const F32 dt) 
 {
-	llerrs << "Creating default part source!" << llendl;
+	LL_ERRS() << "Creating default part source!" << LL_ENDL;
 }
 
 LLUUID LLViewerPartSource::getImageUUID() const
@@ -371,7 +371,7 @@ void LLViewerPartSourceScript::update(const F32 dt)
 			{
 				part->mPosAgent = mPosAgent;
 				part->mVelocity.setVec(0.f, 0.f, 0.f);
-				//llwarns << "Unknown source pattern " << (S32)mPartSysData.mPattern << llendl;
+				//LL_WARNS() << "Unknown source pattern " << (S32)mPartSysData.mPattern << LL_ENDL;
 			}
 
 			if (part->mFlags & LLPartData::LL_PART_FOLLOW_SRC_MASK ||	// SVC-193, VWR-717
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 34a9767fdf..3ad1c6ab0a 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -299,8 +299,8 @@ public:
 
 	void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "BaseCapabilitiesCompleteTracker error [status:"
-				<< statusNum << "]: " << content << llendl;
+		LL_WARNS() << "BaseCapabilitiesCompleteTracker error [status:"
+				<< statusNum << "]: " << content << LL_ENDL;
 	}
 
 	void result(const LLSD& content)
@@ -314,17 +314,17 @@ public:
 		for(iter = content.beginMap(); iter != content.endMap(); ++iter)
 		{
 			regionp->setCapabilityDebug(iter->first, iter->second);	
-			//llinfos<<"BaseCapabilitiesCompleteTracker New Caps "<<iter->first<<" "<< iter->second<<llendl;
+			//LL_INFOS()<<"BaseCapabilitiesCompleteTracker New Caps "<<iter->first<<" "<< iter->second<<LL_ENDL;
 		}
 		
 		if ( regionp->getRegionImpl()->mCapabilities.size() != regionp->getRegionImpl()->mSecondCapabilitiesTracker.size() )
 		{
-			llinfos<<"BaseCapabilitiesCompleteTracker "<<"Sim sent duplicate seed caps that differs in size - most likely content."<<llendl;			
+			LL_INFOS()<<"BaseCapabilitiesCompleteTracker "<<"Sim sent duplicate seed caps that differs in size - most likely content."<<LL_ENDL;			
 			//todo#add cap debug versus original check?
 			/*CapabilityMap::const_iterator iter = regionp->getRegionImpl()->mCapabilities.begin();
 			while (iter!=regionp->getRegionImpl()->mCapabilities.end() )
 			{
-				llinfos<<"BaseCapabilitiesCompleteTracker Original "<<iter->first<<" "<< iter->second<<llendl;
+				LL_INFOS()<<"BaseCapabilitiesCompleteTracker Original "<<iter->first<<" "<< iter->second<<LL_ENDL;
 				++iter;
 			}
 			*/
@@ -765,7 +765,7 @@ void LLViewerRegion::processRegionInfo(LLMessageSystem* msg, void**)
 {
 	// send it to 'observers'
 	// *TODO: switch the floaters to using LLRegionInfoModel
-	llinfos << "Processing region info" << llendl;
+	LL_INFOS() << "Processing region info" << LL_ENDL;
 	LLRegionInfoModel::instance().update(msg);
 	LLFloaterGodTools::processRegionInfo(msg);
 	LLFloaterRegionInfo::processRegionInfo(msg);
@@ -1323,7 +1323,7 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry)
 		addActiveCacheEntry(entry);
 
 		//object is already created, crash here for debug use.
-		llwarns << "Object is already created." << llendl;
+		LL_WARNS() << "Object is already created." << LL_ENDL;
 		llassert(!entry->getEntry()->hasDrawable());
 	}
 	return obj;
@@ -1537,7 +1537,7 @@ U32 LLViewerRegion::getPacketsLost() const
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(mImpl->mHost);
 	if (!cdp)
 	{
-		llinfos << "LLViewerRegion::getPacketsLost couldn't find circuit for " << mImpl->mHost << llendl;
+		LL_INFOS() << "LLViewerRegion::getPacketsLost couldn't find circuit for " << mImpl->mHost << LL_ENDL;
 		return 0;
 	}
 	else
@@ -1655,9 +1655,9 @@ public:
 		avatar_locs->clear();
 		avatar_ids->clear();
 
-		//llinfos << "coarse locations agent[0] " << input["body"]["AgentData"][0]["AgentID"].asUUID() << llendl;
-		//llinfos << "my agent id = " << gAgent.getID() << llendl;
-		//llinfos << ll_pretty_print_sd(input) << llendl;
+		//LL_INFOS() << "coarse locations agent[0] " << input["body"]["AgentData"][0]["AgentID"].asUUID() << LL_ENDL;
+		//LL_INFOS() << "my agent id = " << gAgent.getID() << LL_ENDL;
+		//LL_INFOS() << ll_pretty_print_sd(input) << LL_ENDL;
 
 		LLSD 
 			locs   = input["body"]["Location"],
@@ -1694,11 +1694,11 @@ public:
 				pos <<= 8;
 				pos |= z;
 				avatar_locs->push_back(pos);
-				//llinfos << "next pos: " << x << "," << y << "," << z << ": " << pos << llendl;
+				//LL_INFOS() << "next pos: " << x << "," << y << "," << z << ": " << pos << LL_ENDL;
 				if(has_agent_data) // for backwards compatibility with old message format
 				{
 					LLUUID agent_id(agents_it->get("AgentID").asUUID());
-					//llinfos << "next agent: " << agent_id.asString() << llendl;
+					//LL_INFOS() << "next agent: " << agent_id.asString() << LL_ENDL;
 					avatar_ids->push_back(agent_id);
 				}
 			}
@@ -1719,7 +1719,7 @@ LLHTTPRegistration<CoarseLocationUpdate>
 // the deprecated coarse location handler
 void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg)
 {
-	//llinfos << "CoarseLocationUpdate" << llendl;
+	//LL_INFOS() << "CoarseLocationUpdate" << LL_ENDL;
 	mMapAvatars.clear();
 	mMapAvatarIDs.clear(); // only matters in a rare case but it's good to be safe.
 
@@ -1747,9 +1747,9 @@ void LLViewerRegion::updateCoarseLocations(LLMessageSystem* msg)
 			msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id, i);
 		}
 
-		//llinfos << "  object X: " << (S32)x_pos << " Y: " << (S32)y_pos
+		//LL_INFOS() << "  object X: " << (S32)x_pos << " Y: " << (S32)y_pos
 		//		<< " Z: " << (S32)(z_pos * 4)
-		//		<< llendl;
+		//		<< LL_ENDL;
 
 		// treat the target specially for the map
 		if(i == target_index)
@@ -1800,7 +1800,7 @@ void LLViewerRegion::setSimulatorFeatures(const LLSD& sim_features)
 	std::stringstream str;
 	
 	LLSDSerialize::toPrettyXML(sim_features, str);
-	llinfos << str.str() << llendl;
+	LL_INFOS() << str.str() << LL_ENDL;
 	mSimulatorFeatures = sim_features;
 }
 
@@ -2120,14 +2120,14 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss
 		}
 		else
 		{
-			// llinfos << "CRC miss for " << local_id << llendl;
+			// LL_INFOS() << "CRC miss for " << local_id << LL_ENDL;
 
 			addCacheMiss(local_id, CACHE_MISS_TYPE_CRC);
 		}
 	}
 	else
 	{
-		// llinfos << "Cache miss for " << local_id << llendl;
+		// LL_INFOS() << "Cache miss for " << local_id << LL_ENDL;
 		addCacheMiss(local_id, CACHE_MISS_TYPE_FULL);
 	}
 
@@ -2182,7 +2182,7 @@ void LLViewerRegion::requestCacheMisses()
 	}
 
 	mCacheDirty = TRUE ;
-	// llinfos << "KILLDEBUG Sent cache miss full " << full_count << " crc " << crc_count << llendl;
+	// LL_INFOS() << "KILLDEBUG Sent cache miss full " << full_count << " crc " << crc_count << LL_ENDL;
 	LLViewerStatsRecorder::instance().requestCacheMissesEvent(mCacheMissList.size());
 	LLViewerStatsRecorder::instance().log(0.2f);
 
@@ -2217,14 +2217,14 @@ void LLViewerRegion::dumpCache()
 		change_bin[changes]++;
 	}
 
-	llinfos << "Count " << mImpl->mCacheMap.size() << llendl;
+	LL_INFOS() << "Count " << mImpl->mCacheMap.size() << LL_ENDL;
 	for (i = 0; i < BINS; i++)
 	{
-		llinfos << "Hits " << i << " " << hit_bin[i] << llendl;
+		LL_INFOS() << "Hits " << i << " " << hit_bin[i] << LL_ENDL;
 	}
 	for (i = 0; i < BINS; i++)
 	{
-		llinfos << "Changes " << i << " " << change_bin[i] << llendl;
+		LL_INFOS() << "Changes " << i << " " << change_bin[i] << LL_ENDL;
 	}
 }
 
@@ -2464,7 +2464,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 {
 	if (getCapability("Seed") == url)
     {	
-		//llwarns << "Ignoring duplicate seed capability" << llendl;
+		//LL_WARNS() << "Ignoring duplicate seed capability" << LL_ENDL;
 		//Instead of just returning we build up a second set of seed caps and compare them 
 		//to the "original" seed cap received and determine why there is problem!
 		LLSD capabilityNames = LLSD::emptyArray();
@@ -2483,7 +2483,7 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
 	LLSD capabilityNames = LLSD::emptyArray();
 	mImpl->buildCapabilityNames(capabilityNames);
 
-	llinfos << "posting to seed " << url << llendl;
+	LL_INFOS() << "posting to seed " << url << LL_ENDL;
 
 	S32 id = ++mImpl->mHttpResponderID;
 	LLHTTPClient::post(url, capabilityNames, 
@@ -2518,8 +2518,8 @@ void LLViewerRegion::failedSeedCapability()
 		LLSD capabilityNames = LLSD::emptyArray();
 		mImpl->buildCapabilityNames(capabilityNames);
 
-		llinfos << "posting to seed " << url << " (retry " 
-				<< mImpl->mSeedCapAttempts << ")" << llendl;
+		LL_INFOS() << "posting to seed " << url << " (retry " 
+				<< mImpl->mSeedCapAttempts << ")" << LL_ENDL;
 
 		S32 id = ++mImpl->mHttpResponderID;
 		LLHTTPClient::post(url, capabilityNames, 
@@ -2620,7 +2620,7 @@ std::string LLViewerRegion::getCapability(const std::string& name) const
 {
 	if (!capabilitiesReceived() && (name!=std::string("Seed")) && (name!=std::string("ObjectMedia")))
 	{
-		llwarns << "getCapability called before caps received" << llendl;
+		LL_WARNS() << "getCapability called before caps received" << LL_ENDL;
 	}
 	
 	CapabilityMap::const_iterator iter = mImpl->mCapabilities.find(name);
@@ -2665,10 +2665,10 @@ void LLViewerRegion::logActiveCapabilities() const
 	{
 		if (!iter->second.empty())
 		{
-			llinfos << iter->first << " URL is " << iter->second << llendl;
+			LL_INFOS() << iter->first << " URL is " << iter->second << LL_ENDL;
 		}
 	}
-	llinfos << "Dumped " << count << " entries." << llendl;
+	LL_INFOS() << "Dumped " << count << " entries." << LL_ENDL;
 }
 
 LLSpatialPartition* LLViewerRegion::getSpatialPartition(U32 type)
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 7d3c432fb3..745ca2c13d 100755
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -462,7 +462,7 @@ void LLViewerShaderMgr::setShaders()
 
 	// Shaders
 	LL_INFOS("ShaderLoading") << "\n~~~~~~~~~~~~~~~~~~\n Loading Shaders:\n~~~~~~~~~~~~~~~~~~" << LL_ENDL;
-	LL_INFOS("ShaderLoading") << llformat("Using GLSL %d.%d", gGLManager.mGLSLVersionMajor, gGLManager.mGLSLVersionMinor) << llendl;
+	LL_INFOS("ShaderLoading") << llformat("Using GLSL %d.%d", gGLManager.mGLSLVersionMajor, gGLManager.mGLSLVersionMinor) << LL_ENDL;
 
 	for (S32 i = 0; i < SHADER_COUNT; i++)
 	{
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index bb023ce422..8cb519b098 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -281,8 +281,8 @@ void LLViewerStats::addToMessage(LLSD &body)
 	misc["Vertex Buffers Enabled"] = getRecording().getMean(LLStatViewer::ENABLE_VBO);
 	
 	body["AgentPositionSnaps"] = getRecording().getSum(LLStatViewer::AGENT_POSITION_SNAP).value(); //mAgentPositionSnaps.asLLSD();
-	llinfos << "STAT: AgentPositionSnaps: Mean = " << getRecording().getMean(LLStatViewer::AGENT_POSITION_SNAP).value() << "; StdDev = " << getRecording().getStandardDeviation(LLStatViewer::AGENT_POSITION_SNAP).value() 
-			<< "; Count = " << getRecording().getSampleCount(LLStatViewer::AGENT_POSITION_SNAP) << llendl;
+	LL_INFOS() << "STAT: AgentPositionSnaps: Mean = " << getRecording().getMean(LLStatViewer::AGENT_POSITION_SNAP).value() << "; StdDev = " << getRecording().getStandardDeviation(LLStatViewer::AGENT_POSITION_SNAP).value() 
+			<< "; Count = " << getRecording().getSampleCount(LLStatViewer::AGENT_POSITION_SNAP) << LL_ENDL;
 }
 
 // *NOTE:Mani The following methods used to exist in viewer.cpp
@@ -417,13 +417,13 @@ public:
 
     void error(U32 statusNum, const std::string& reason)
     {
-		llinfos << "ViewerStatsResponder::error " << statusNum << " "
-				<< reason << llendl;
+		LL_INFOS() << "ViewerStatsResponder::error " << statusNum << " "
+				<< reason << LL_ENDL;
     }
 
     void result(const LLSD& content)
     {
-		llinfos << "ViewerStatsResponder::result" << llendl;
+		LL_INFOS() << "ViewerStatsResponder::result" << LL_ENDL;
 	}
 };
 
@@ -453,7 +453,7 @@ void send_stats()
 	std::string url = gAgent.getRegion()->getCapability("ViewerStats");
 
 	if (url.empty()) {
-		llwarns << "Could not get ViewerStats capability" << llendl;
+		LL_WARNS() << "Could not get ViewerStats capability" << LL_ENDL;
 		return;
 	}
 	
@@ -606,8 +606,8 @@ void send_stats()
 	F32 grey_time = LLVOAvatar::sGreyTime * 1000.f / gFrameTimeSeconds;
 	misc["int_2"] = LLSD::Integer(grey_time); // Steve: 1.22
 
-	llinfos << "Misc Stats: int_1: " << misc["int_1"] << " int_2: " << misc["int_2"] << llendl;
-	llinfos << "Misc Stats: string_1: " << misc["string_1"] << " string_2: " << misc["string_2"] << llendl;
+	LL_INFOS() << "Misc Stats: int_1: " << misc["int_1"] << " int_2: " << misc["int_2"] << LL_ENDL;
+	LL_INFOS() << "Misc Stats: string_1: " << misc["string_1"] << " string_2: " << misc["string_2"] << LL_ENDL;
 
 	body["DisplayNamesEnabled"] = gSavedSettings.getBOOL("UseDisplayNames");
 	body["DisplayNamesShowUsername"] = gSavedSettings.getBOOL("NameTagShowUsernames");
@@ -633,7 +633,7 @@ LLFrameTimer& LLViewerStats::PhaseMap::getPhaseTimer(const std::string& phase_na
 void LLViewerStats::PhaseMap::startPhase(const std::string& phase_name)
 {
 	LLFrameTimer& timer = getPhaseTimer(phase_name);
-	lldebugs << "startPhase " << phase_name << llendl;
+	LL_DEBUGS() << "startPhase " << phase_name << LL_ENDL;
 	timer.unpause();
 }
 
@@ -648,14 +648,14 @@ void LLViewerStats::PhaseMap::stopAllPhases()
 			// Going from started to paused state - record stats.
 			recordPhaseStat(phase_name,iter->second.getElapsedTimeF32());
 		}
-		lldebugs << "stopPhase (all) " << phase_name << llendl;
+		LL_DEBUGS() << "stopPhase (all) " << phase_name << LL_ENDL;
 		iter->second.pause();
 	}
 }
 
 void LLViewerStats::PhaseMap::clearPhases()
 {
-	lldebugs << "clearPhases" << llendl;
+	LL_DEBUGS() << "clearPhases" << LL_ENDL;
 
 	mPhaseMap.clear();
 }
diff --git a/indra/newview/llviewerstatsrecorder.cpp b/indra/newview/llviewerstatsrecorder.cpp
index 0e78bdc04c..b5ccf4ffa0 100755
--- a/indra/newview/llviewerstatsrecorder.cpp
+++ b/indra/newview/llviewerstatsrecorder.cpp
@@ -49,7 +49,7 @@ LLViewerStatsRecorder::LLViewerStatsRecorder() :
 {
 	if (NULL != sInstance)
 	{
-		llerrs << "Attempted to create multiple instances of LLViewerStatsRecorder!" << llendl;
+		LL_ERRS() << "Attempted to create multiple instances of LLViewerStatsRecorder!" << LL_ENDL;
 	}
 	sInstance = this;
 	clearStats();
@@ -132,7 +132,7 @@ void LLViewerStatsRecorder::recordObjectUpdateEvent(U32 local_id, const EObjectU
 		mObjectCacheHitSize += msg_size;
 		break;
 	default:
-		llwarns << "Unknown update_type" << llendl;
+		LL_WARNS() << "Unknown update_type" << LL_ENDL;
 		break;
 	};
 }
@@ -154,7 +154,7 @@ void LLViewerStatsRecorder::recordCacheFullUpdate(U32 local_id, const EObjectUpd
 			mObjectCacheUpdateReplacements++;
 			break;
 		default:
-			llwarns << "Unknown update_result type" << llendl;
+			LL_WARNS() << "Unknown update_result type" << LL_ENDL;
 			break;
 	};
 }
@@ -173,7 +173,7 @@ void LLViewerStatsRecorder::writeToLog( F32 interval )
 	if ( delta_time < interval || total_objects == 0) return;
 
 	mLastSnapshotTime = LLTimer::getTotalSeconds();
-	lldebugs << "ILX: " 
+	LL_DEBUGS() << "ILX: " 
 		<< mObjectCacheHitCount << " hits, " 
 		<< mObjectCacheMissFullCount << " full misses, "
 		<< mObjectCacheMissCrcCount << " crc misses, "
@@ -186,7 +186,7 @@ void LLViewerStatsRecorder::writeToLog( F32 interval )
 		<< mObjectCacheUpdateAdds << " cache update adds, "
 		<< mObjectCacheUpdateReplacements << " cache update replacements, "
 		<< mObjectUpdateFailures << " update failures"
-		<< llendl;
+		<< LL_ENDL;
 
 	if (mObjectCacheFile == NULL)
 	{
@@ -220,12 +220,12 @@ void LLViewerStatsRecorder::writeToLog( F32 interval )
 			data_size = data_msg.str().size();
 			if (fwrite(data_msg.str().c_str(), 1, data_size, mObjectCacheFile ) != data_size)
 			{
-				llwarns << "failed to write full headers to " << STATS_FILE_NAME << llendl;
+				LL_WARNS() << "failed to write full headers to " << STATS_FILE_NAME << LL_ENDL;
 			}
 		}
 		else
 		{
-			//llwarns << "Couldn't open " << STATS_FILE_NAME << " for logging." << llendl;
+			//LL_WARNS() << "Couldn't open " << STATS_FILE_NAME << " for logging." << LL_ENDL;
 			return;
 		}
 	}
@@ -257,7 +257,7 @@ void LLViewerStatsRecorder::writeToLog( F32 interval )
 	data_size = data_msg.str().size();
 	if ( data_size != fwrite(data_msg.str().c_str(), 1, data_size, mObjectCacheFile ))
 	{
-				llwarns << "Unable to write complete column data to " << STATS_FILE_NAME << llendl;
+				LL_WARNS() << "Unable to write complete column data to " << STATS_FILE_NAME << LL_ENDL;
 	}
 
 	clearStats();
diff --git a/indra/newview/llviewertexlayer.cpp b/indra/newview/llviewertexlayer.cpp
index 4cd4375146..62e8da81ec 100755
--- a/indra/newview/llviewertexlayer.cpp
+++ b/indra/newview/llviewertexlayer.cpp
@@ -118,7 +118,7 @@ void LLViewerTexLayerSetBuffer::destroyGLTexture()
 // static
 void LLViewerTexLayerSetBuffer::dumpTotalByteCount()
 {
-	llinfos << "Composite System GL Buffers: " << (LLViewerTexLayerSetBuffer::sGLByteCount/1024) << "KB" << llendl;
+	LL_INFOS() << "Composite System GL Buffers: " << (LLViewerTexLayerSetBuffer::sGLByteCount/1024) << "KB" << LL_ENDL;
 }
 
 void LLViewerTexLayerSetBuffer::requestUpdate()
@@ -231,7 +231,7 @@ void LLViewerTexLayerSetBuffer::midRenderTexLayerSet(BOOL success)
 	{
 		if (!success)
 		{
-			llinfos << "Failed attempt to bake " << mTexLayerSet->getBodyRegionName() << llendl;
+			LL_INFOS() << "Failed attempt to bake " << mTexLayerSet->getBodyRegionName() << LL_ENDL;
 			mUploadPending = FALSE;
 		}
 		else
@@ -363,7 +363,7 @@ BOOL LLViewerTexLayerSetBuffer::requestUpdateImmediate()
 void LLViewerTexLayerSetBuffer::doUpload()
 {
 	LLViewerTexLayerSet* layer_set = getViewerTexLayerSet();
-	LL_DEBUGS("Avatar") << "Uploading baked " << layer_set->getBodyRegionName() << llendl;
+	LL_DEBUGS("Avatar") << "Uploading baked " << layer_set->getBodyRegionName() << LL_ENDL;
 	add(LLStatViewer::TEX_BAKES, 1);
 
 	// Don't need caches since we're baked now.  (note: we won't *really* be baked 
@@ -449,7 +449,7 @@ void LLViewerTexLayerSetBuffer::doUpload()
 					LLSD body = LLSD::emptyMap();
 					// The responder will call LLViewerTexLayerSetBuffer::onTextureUploadComplete()
 					LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data));
-					llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl;
+					LL_INFOS() << "Baked texture upload via capability of " << mUploadID << " to " << url << LL_ENDL;
 				} 
 				else
 				{
@@ -460,7 +460,7 @@ void LLViewerTexLayerSetBuffer::doUpload()
 												  TRUE,		// temp_file
 												  TRUE,		// is_priority
 												  TRUE);	// store_local
-					llinfos << "Baked texture upload via Asset Store." <<  llendl;
+					LL_INFOS() << "Baked texture upload via Asset Store." <<  LL_ENDL;
 				}
 
 				if (highest_lod)
@@ -497,7 +497,7 @@ void LLViewerTexLayerSetBuffer::doUpload()
 				mUploadPending = FALSE;
 				LLVFile file(gVFS, asset_id, LLAssetType::AT_TEXTURE, LLVFile::WRITE);
 				file.remove();
-				llinfos << "Unable to create baked upload file (reason: corrupted)." << llendl;
+				LL_INFOS() << "Unable to create baked upload file (reason: corrupted)." << LL_ENDL;
 			}
 		}
 	}
@@ -505,7 +505,7 @@ void LLViewerTexLayerSetBuffer::doUpload()
 	{
 		// The VFS write file operation failed.
 		mUploadPending = FALSE;
-		llinfos << "Unable to create baked upload file (reason: failed to write file)" << llendl;
+		LL_INFOS() << "Unable to create baked upload file (reason: failed to write file)" << LL_ENDL;
 	}
 
 	delete [] baked_color_data;
@@ -587,14 +587,14 @@ void LLViewerTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
 				LLAvatarAppearanceDefines::ETextureIndex baked_te = gAgentAvatarp->getBakedTE(layerset_buffer->getViewerTexLayerSet());
 				// Update baked texture info with the new UUID
 				U64 now = LLFrameTimer::getTotalTime();		// Record starting time
-				llinfos << "Baked" << resolution << "texture upload for " << name << " took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << llendl;
+				LL_INFOS() << "Baked" << resolution << "texture upload for " << name << " took " << (S32)((now - baked_upload_data->mStartTime) / 1000) << " ms" << LL_ENDL;
 				gAgentAvatarp->setNewBakedTexture(baked_te, uuid);
 			}
 			else
 			{	
 				++failures;
 				S32 max_attempts = baked_upload_data->mIsHighestRes ? BAKE_UPLOAD_ATTEMPTS : 1; // only retry final bakes
-				llwarns << "Baked" << resolution << "texture upload for " << name << " failed (attempt " << failures << "/" << max_attempts << ")" << llendl;
+				LL_WARNS() << "Baked" << resolution << "texture upload for " << name << " failed (attempt " << failures << "/" << max_attempts << ")" << LL_ENDL;
 				if (failures < max_attempts)
 				{
 					layerset_buffer->mUploadFailCount = failures;
@@ -605,7 +605,7 @@ void LLViewerTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
 		}
 		else
 		{
-			llinfos << "Received baked texture out of date, ignored." << llendl;
+			LL_INFOS() << "Received baked texture out of date, ignored." << LL_ENDL;
 		}
 
 		gAgentAvatarp->dirtyMesh();
@@ -617,7 +617,7 @@ void LLViewerTexLayerSetBuffer::onTextureUploadComplete(const LLUUID& uuid,
 		// and rebake it at some point in the future (after login?)),
 		// or this response to upload is out of date, in which case a
 		// current response should be on the way or already processed.
-		llwarns << "Baked upload failed" << llendl;
+		LL_WARNS() << "Baked upload failed" << LL_ENDL;
 	}
 
 	delete baked_upload_data;
@@ -694,7 +694,7 @@ void LLViewerTexLayerSet::createComposite()
 		// Composite other avatars at reduced resolution
 		if( !mAvatarAppearance->isSelf() )
 		{
-			llerrs << "composites should not be created for non-self avatars!" << llendl;
+			LL_ERRS() << "composites should not be created for non-self avatars!" << LL_ENDL;
 		}
 		mComposite = new LLViewerTexLayerSetBuffer( this, width, height );
 	}
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index 16b51c457a..41a2c670e6 100755
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -100,7 +100,7 @@ public:
 			if (item_ptr.isNull())
 			{
 				// check to prevent a crash. See EXT-8459.
-				llwarns << "Passed handle contains a dead inventory item. Most likely notecard has been closed and embedded item was destroyed." << llendl;
+				LL_WARNS() << "Passed handle contains a dead inventory item. Most likely notecard has been closed and embedded item was destroyed." << LL_ENDL;
 			}
 			else
 			{
@@ -143,7 +143,7 @@ public:
 		LLInventoryItem* item = gInventory.getItem(inv_item);
 		if(!item)
 		{
-			llwarns << "Item add reported, but not found in inventory!: " << inv_item << llendl;
+			LL_WARNS() << "Item add reported, but not found in inventory!: " << inv_item << LL_ENDL;
 		}
 		else
 		{
@@ -438,7 +438,7 @@ llwchar	LLEmbeddedItems::getEmbeddedCharFromIndex(S32 index)
 {
 	if (index >= (S32)mEmbeddedIndexedChars.size())
 	{
-		llwarns << "No item for embedded char " << index << " using LL_UNKNOWN_CHAR" << llendl;
+		LL_WARNS() << "No item for embedded char " << index << " using LL_UNKNOWN_CHAR" << LL_ENDL;
 		return LL_UNKNOWN_CHAR;
 	}
 	return mEmbeddedIndexedChars[index];
@@ -494,7 +494,7 @@ S32 LLEmbeddedItems::getIndexFromEmbeddedChar(llwchar wch)
 	}
 	else
 	{
-		llwarns << "Embedded char " << wch << " not found, using 0" << llendl;
+		LL_WARNS() << "Embedded char " << wch << " not found, using 0" << LL_ENDL;
 		return 0;
 	}
 }
@@ -920,7 +920,7 @@ BOOL LLViewerTextEditor::handleDragAndDrop(S32 x, S32 y, MASK mask,
 	}
 
 	handled = TRUE;
-	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLViewerTextEditor " << getName() << llendl;
+	LL_DEBUGS("UserInput") << "dragAndDrop handled by LLViewerTextEditor " << getName() << LL_ENDL;
 
 	return handled;
 }
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index ed74bc744a..eb8faacac2 100755
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -222,7 +222,7 @@ LLViewerFetchedTexture* LLViewerTextureManager::staticCastToFetchedTexture(LLTex
 
 	if(report_error)
 	{
-		llerrs << "not a fetched texture type: " << type << llendl ;
+		LL_ERRS() << "not a fetched texture type: " << type << LL_ENDL ;
 	}
 
 	return NULL ;
@@ -620,7 +620,7 @@ LLViewerTexture::LLViewerTexture(const LLImageRaw* raw, BOOL usemipmaps) :
 
 LLViewerTexture::~LLViewerTexture()
 {
-	// LL_DEBUGS("Avatar") << mID << llendl;
+	// LL_DEBUGS("Avatar") << mID << LL_ENDL;
 	cleanup();
 	sImageCount--;
 }
@@ -664,9 +664,9 @@ void LLViewerTexture::dump()
 {
 	LLGLTexture::dump();
 
-	llinfos << "LLViewerTexture"
+	LL_INFOS() << "LLViewerTexture"
 			<< " mID " << mID
-			<< llendl;
+			<< LL_ENDL;
 }
 
 void LLViewerTexture::setBoostLevel(S32 level)
@@ -727,7 +727,7 @@ bool LLViewerTexture::bindDefaultImage(S32 stage)
 	}
 	if (!res)
 	{
-		llwarns << "LLViewerTexture::bindDefaultImage failed." << llendl;
+		LL_WARNS() << "LLViewerTexture::bindDefaultImage failed." << LL_ENDL;
 	}
 	stop_glerror();
 
@@ -1125,7 +1125,7 @@ void LLViewerFetchedTexture::loadFromFastCache()
 		{ 
 			//discard all oversized textures.
 			destroyRawImage();
-			llwarns << "oversized, setting as missing" << llendl;
+			LL_WARNS() << "oversized, setting as missing" << LL_ENDL;
 			setIsMissingAsset();
 			mRawDiscardLevel = INVALID_DISCARD_LEVEL ;
 		}
@@ -1202,25 +1202,25 @@ void LLViewerFetchedTexture::dump()
 {
 	LLViewerTexture::dump();
 
-	llinfos << "Dump : " << mID 
+	LL_INFOS() << "Dump : " << mID 
 			<< ", mIsMissingAsset = " << (S32)mIsMissingAsset
 			<< ", mFullWidth = " << (S32)mFullWidth
 			<< ", mFullHeight = " << (S32)mFullHeight
 			<< ", mOrigWidth = " << (S32)mOrigWidth
 			<< ", mOrigHeight = " << (S32)mOrigHeight
-			<< llendl;
-	llinfos << "     : " 
+			<< LL_ENDL;
+	LL_INFOS() << "     : " 
 			<< " mFullyLoaded = " << (S32)mFullyLoaded
 			<< ", mFetchState = " << (S32)mFetchState
 			<< ", mFetchPriority = " << (S32)mFetchPriority
 			<< ", mDownloadProgress = " << (F32)mDownloadProgress
-			<< llendl;
-	llinfos << "     : " 
+			<< LL_ENDL;
+	LL_INFOS() << "     : " 
 			<< " mHasFetcher = " << (S32)mHasFetcher
 			<< ", mIsFetching = " << (S32)mIsFetching
 			<< ", mIsFetched = " << (S32)mIsFetched
 			<< ", mBoostLevel = " << (S32)mBoostLevel
-			<< llendl;
+			<< LL_ENDL;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1236,7 +1236,7 @@ void LLViewerFetchedTexture::destroyTexture()
 		return ;
 	}
 
-	//LL_DEBUGS("Avatar") << mID << llendl;
+	//LL_DEBUGS("Avatar") << mID << LL_ENDL;
 	destroyGLTexture() ;
 	mFullyLoaded = FALSE ;
 }
@@ -1341,12 +1341,12 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
 	mNeedsCreateTexture	= FALSE;
 	if (mRawImage.isNull())
 	{
-		llerrs << "LLViewerTexture trying to create texture with no Raw Image" << llendl;
+		LL_ERRS() << "LLViewerTexture trying to create texture with no Raw Image" << LL_ENDL;
 	}
-// 	llinfos << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ",
+// 	LL_INFOS() << llformat("IMAGE Creating (%d) [%d x %d] Bytes: %d ",
 // 						mRawDiscardLevel, 
 // 						mRawImage->getWidth(), mRawImage->getHeight(),mRawImage->getDataSize())
-// 			<< mID.getString() << llendl;
+// 			<< mID.getString() << LL_ENDL;
 	BOOL res = TRUE;
 
 	// store original size only for locally-sourced images
@@ -1381,14 +1381,14 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
 	U32 raw_height = mRawImage->getHeight() << mRawDiscardLevel;
 	if( raw_width > MAX_IMAGE_SIZE || raw_height > MAX_IMAGE_SIZE )
 	{
-		llinfos << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << llendl;
+		LL_INFOS() << "Width or height is greater than " << MAX_IMAGE_SIZE << ": (" << raw_width << "," << raw_height << ")" << LL_ENDL;
 		size_okay = false;
 	}
 	
 	if (!LLImageGL::checkSize(mRawImage->getWidth(), mRawImage->getHeight()))
 	{
 		// A non power-of-two image was uploaded (through a non standard client)
-		llinfos << "Non power of two width or height: (" << mRawImage->getWidth() << "," << mRawImage->getHeight() << ")" << llendl;
+		LL_INFOS() << "Non power of two width or height: (" << mRawImage->getWidth() << "," << mRawImage->getHeight() << ")" << LL_ENDL;
 		size_okay = false;
 	}
 	
@@ -1397,7 +1397,7 @@ BOOL LLViewerFetchedTexture::createTexture(S32 usename/*= 0*/)
 		// An inappropriately-sized image was uploaded (through a non standard client)
 		// We treat these images as missing assets which causes them to
 		// be renderd as 'missing image' and to stop requesting data
-		llwarns << "!size_ok, setting as missing" << llendl;
+		LL_WARNS() << "!size_ok, setting as missing" << LL_ENDL;
 		setIsMissingAsset();
 		destroyRawImage();
 		return FALSE;
@@ -1864,7 +1864,7 @@ bool LLViewerFetchedTexture::updateFetch()
 				{ 
 					//discard all oversized textures.
 					destroyRawImage();
-					llwarns << "oversize, setting as missing" << llendl;
+					LL_WARNS() << "oversize, setting as missing" << LL_ENDL;
 					setIsMissingAsset();
 					mRawDiscardLevel = INVALID_DISCARD_LEVEL ;
 					mIsFetching = FALSE ;
@@ -1894,16 +1894,16 @@ bool LLViewerFetchedTexture::updateFetch()
 				// We finished but received no data
 				if (current_discard < 0)
 				{
-					llwarns << "!mIsFetching, setting as missing, decode_priority " << decode_priority
+					LL_WARNS() << "!mIsFetching, setting as missing, decode_priority " << decode_priority
 							<< " mRawDiscardLevel " << mRawDiscardLevel
 							<< " current_discard " << current_discard
-							<< llendl;
+							<< LL_ENDL;
 					setIsMissingAsset();
 					desired_discard = -1;
 				}
 				else
 				{
-					//llwarns << mID << ": Setting min discard to " << current_discard << llendl;
+					//LL_WARNS() << mID << ": Setting min discard to " << current_discard << LL_ENDL;
 					mMinDiscardLevel = current_discard;
 					desired_discard = current_discard;
 				}
@@ -1921,7 +1921,7 @@ bool LLViewerFetchedTexture::updateFetch()
 // 			// Useful debugging code for undesired deprioritization of textures.
 // 			if (decode_priority <= 0.0f && desired_discard >= 0 && desired_discard < current_discard)
 // 			{
-// 				llinfos << "Calling updateRequestPriority() with decode_priority = 0.0f" << llendl;
+// 				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.
@@ -2036,7 +2036,7 @@ bool LLViewerFetchedTexture::updateFetch()
 		const F32 FETCH_IDLE_TIME = 5.f;
 		if (mLastPacketTimer.getElapsedTimeF32() > FETCH_IDLE_TIME)
 		{
- 			LL_DEBUGS("Texture") << "exceeded idle time " << FETCH_IDLE_TIME << ", deleting request: " << getID() << llendl;
+ 			LL_DEBUGS("Texture") << "exceeded idle time " << FETCH_IDLE_TIME << ", deleting request: " << getID() << LL_ENDL;
 			LLAppViewer::getTextureFetch()->deleteRequest(getID(), true);
 			mHasFetcher = FALSE;
 		}
@@ -2080,14 +2080,14 @@ void LLViewerFetchedTexture::setIsMissingAsset()
 {
 	if (mUrl.empty())
 	{
-		llwarns << mID << ": Marking image as missing" << llendl;
+		LL_WARNS() << mID << ": Marking image as missing" << LL_ENDL;
 	}
 	else
 	{
 		// This may or may not be an error - it is normal to have no
 		// map tile on an empty region, but bad if we're failing on a
 		// server bake texture.
-		llwarns << mUrl << ": Marking image as missing" << llendl;
+		LL_WARNS() << mUrl << ": Marking image as missing" << LL_ENDL;
 	}
 	if (mHasFetcher)
 	{
@@ -2142,7 +2142,7 @@ void LLViewerFetchedTexture::setLoadedCallback( loaded_callback_func loaded_call
 	if (mNeedsAux && mAuxRawImage.isNull() && getDiscardLevel() >= 0)
 	{
 		// We need aux data, but we've already loaded the image, and it didn't have any
-		llwarns << "No aux data available for callback for image:" << getID() << llendl;
+		LL_WARNS() << "No aux data available for callback for image:" << getID() << LL_ENDL;
 	}
 	mLastCallBackActiveTime = sCurrentTime ;
 }
@@ -2437,7 +2437,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
 	if (run_raw_callbacks && mIsRawImageValid && (mRawDiscardLevel <= getMaxDiscardLevel()))
 	{
 		// Do callbacks which require raw image data.
-		//llinfos << "doLoadedCallbacks raw for " << getID() << llendl;
+		//LL_INFOS() << "doLoadedCallbacks raw for " << getID() << LL_ENDL;
 
 		// Call each party interested in the raw data.
 		for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
@@ -2455,11 +2455,11 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
 				//llassert_always(mRawImage.notNull());
 				if(mNeedsAux && mAuxRawImage.isNull())
 				{
-					llwarns << "Raw Image with no Aux Data for callback" << llendl;
+					LL_WARNS() << "Raw Image with no Aux Data for callback" << LL_ENDL;
 				}
 				BOOL final = mRawDiscardLevel <= entryp->mDesiredDiscard ? TRUE : FALSE;
-				//llinfos << "Running callback for " << getID() << llendl;
-				//llinfos << mRawImage->getWidth() << "x" << mRawImage->getHeight() << llendl;
+				//LL_INFOS() << "Running callback for " << getID() << LL_ENDL;
+				//LL_INFOS() << mRawImage->getWidth() << "x" << mRawImage->getHeight() << LL_ENDL;
 				entryp->mLastUsedDiscard = mRawDiscardLevel;
 				entryp->mCallback(TRUE, this, mRawImage, mAuxRawImage, mRawDiscardLevel, final, entryp->mUserData);
 				if (final)
@@ -2477,7 +2477,7 @@ bool LLViewerFetchedTexture::doLoadedCallbacks()
 	//
 	if (run_gl_callbacks && (gl_discard <= getMaxDiscardLevel()))
 	{
-		//llinfos << "doLoadedCallbacks GL for " << getID() << llendl;
+		//LL_INFOS() << "doLoadedCallbacks GL for " << getID() << LL_ENDL;
 
 		// Call the callbacks interested in GL data.
 		for(callback_list_t::iterator iter = mLoadedCallbackList.begin();
@@ -3279,7 +3279,7 @@ void LLViewerMediaTexture::addFace(U32 ch, LLFace* facep)
 	
 	if(te && te->getID().notNull()) //should have a texture
 	{
-		llerrs << "The face does not have a valid texture before media texture." << llendl ;
+		LL_ERRS() << "The face does not have a valid texture before media texture." << LL_ENDL ;
 	}
 }
 
@@ -3363,7 +3363,7 @@ void LLViewerMediaTexture::removeFace(U32 ch, LLFace* facep)
 
 	if(te && te->getID().notNull()) //should have a texture
 	{
-		llerrs << "mTextureList texture reference number is corrupted." << llendl ;
+		LL_ERRS() << "mTextureList texture reference number is corrupted." << LL_ENDL ;
 	}
 }
 
@@ -3720,7 +3720,7 @@ void LLTexturePipelineTester::compareTestSessions(std::ofstream* os)
 	LLTexturePipelineTester::LLTextureTestSession* current_sessionp = dynamic_cast<LLTexturePipelineTester::LLTextureTestSession*>(mCurrentSessionp) ;
 	if(!base_sessionp || !current_sessionp)
 	{
-		llerrs << "type of test session does not match!" << llendl ;
+		LL_ERRS() << "type of test session does not match!" << LL_ENDL ;
 	}
 
 	//compare and output the comparison
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 6948c6699b..b0eae7c071 100755
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -119,7 +119,7 @@ public:
 
 	virtual S8 getType() const;
 	virtual BOOL isMissingAsset()const ;
-	virtual void dump();	// debug info to llinfos
+	virtual void dump();	// debug info to LL_INFOS()
 	
 	/*virtual*/ bool bindDefaultImage(const S32 stage = 0) ;
 	/*virtual*/ bool bindDebugImage(const S32 stage = 0) ;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 9b89ee2ec9..63debe0464 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -336,7 +336,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromFile(const std::string&
 	std::string full_path = gDirUtilp->findSkinnedFilename("textures", filename);
 	if (full_path.empty())
 	{
-		llwarns << "Failed to find local image file: " << filename << LL_ENDL;
+		LL_WARNS() << "Failed to find local image file: " << filename << LL_ENDL;
 		return LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
 	}
 
@@ -377,7 +377,7 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string&
 		LLViewerFetchedTexture *texture = imagep.get();
 		if (texture->getUrl().empty())
 		{
-			llwarns << "Requested texture " << new_id << " already exists but does not have a URL" << LL_ENDL;
+			LL_WARNS() << "Requested texture " << new_id << " already exists but does not have a URL" << LL_ENDL;
 		}
 		else if (texture->getUrl() != url)
 		{
@@ -457,18 +457,18 @@ LLViewerFetchedTexture* LLViewerTextureList::getImage(const LLUUID &image_id,
 		if (request_from_host.isOk() &&
 			!texture->getTargetHost().isOk())
 		{
-			llwarns << "Requested texture " << image_id << " already exists but does not have a host" << LL_ENDL;
+			LL_WARNS() << "Requested texture " << image_id << " already exists but does not have a host" << LL_ENDL;
 		}
 		else if (request_from_host.isOk() &&
 				 texture->getTargetHost().isOk() &&
 				 request_from_host != texture->getTargetHost())
 		{
-			llwarns << "Requested texture " << image_id << " already exists with a different target host, requested: " 
+			LL_WARNS() << "Requested texture " << image_id << " already exists with a different target host, requested: " 
 					<< request_from_host << " current: " << texture->getTargetHost() << LL_ENDL;
 		}
 		if (f_type != FTT_DEFAULT && imagep->getFTType() != f_type)
 		{
-			llwarns << "FTType mismatch: requested " << f_type << " image has " << imagep->getFTType() << LL_ENDL;
+			LL_WARNS() << "FTType mismatch: requested " << f_type << " image has " << imagep->getFTType() << LL_ENDL;
 		}
 		
 	}
@@ -896,7 +896,7 @@ void LLViewerTextureList::setDebugFetching(LLViewerFetchedTexture* tex, S32 debu
  if (type_from_host == LLImageBase::TYPE_NORMAL
  && type_from_boost == LLImageBase::TYPE_AVATAR_BAKE)
  {
- llwarns << "TAT: get_image_type() type_from_host doesn't match type_from_boost"
+ LL_WARNS() << "TAT: get_image_type() type_from_host doesn't match type_from_boost"
  << " host " << target_host
  << " boost " << imagep->getBoostLevel()
  << " imageid " << imagep->getID()
@@ -1275,7 +1275,7 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
 			max_texmem = 128;
 		}
 
-		llwarns << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << LL_ENDL;
+		LL_WARNS() << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << LL_ENDL;
 	}
 
 	S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB
@@ -1506,7 +1506,7 @@ void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **
 	LLViewerFetchedTexture* image = gTextureList.findImage( image_id );
 	if( image )
 	{
-		llwarns << "not in db" << LL_ENDL;
+		LL_WARNS() << "not in db" << LL_ENDL;
 		image->setIsMissingAsset();
 	}
 }
@@ -1736,7 +1736,7 @@ bool LLUIImageList::initFromFile()
 	std::vector<std::string>::const_iterator pi(textures_paths.begin()), pend(textures_paths.end());
 	if (pi == pend)
 	{
-		llwarns << "No textures.xml found in skins directories" << LL_ENDL;
+		LL_WARNS() << "No textures.xml found in skins directories" << LL_ENDL;
 		return false;
 	}
 
@@ -1744,12 +1744,12 @@ bool LLUIImageList::initFromFile()
 	LLXMLNodePtr root;
 	if (!LLXMLNode::parseFile(*pi, root, NULL))
 	{
-		llwarns << "Unable to parse UI image list file " << *pi << LL_ENDL;
+		LL_WARNS() << "Unable to parse UI image list file " << *pi << LL_ENDL;
 		return false;
 	}
 	if (!root->hasAttribute("version"))
 	{
-		llwarns << "No valid version number in UI image list file " << *pi << LL_ENDL;
+		LL_WARNS() << "No valid version number in UI image list file " << *pi << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llviewerthrottle.cpp b/indra/newview/llviewerthrottle.cpp
index b8de5871ea..916dec86aa 100755
--- a/indra/newview/llviewerthrottle.cpp
+++ b/indra/newview/llviewerthrottle.cpp
@@ -146,7 +146,7 @@ LLViewerThrottleGroup LLViewerThrottleGroup::operator-(const LLViewerThrottleGro
 
 void LLViewerThrottleGroup::sendToSim() const
 {
-	llinfos << "Sending throttle settings, total BW " << mThrottleTotal << llendl;
+	LL_INFOS() << "Sending throttle settings, total BW " << mThrottleTotal << LL_ENDL;
 	LLMessageSystem* msg = gMessageSystem;
 
 	msg->newMessageFast(_PREHASH_AgentThrottle);
@@ -316,7 +316,7 @@ void LLViewerThrottle::updateDynamicThrottle()
 		mCurrentBandwidth = mMaxBandwidth * mThrottleFrac;
 		mCurrent = getThrottleGroup(mCurrentBandwidth / 1024.0f);
 		mCurrent.sendToSim();
-		llinfos << "Tightening network throttle to " << mCurrentBandwidth << llendl;
+		LL_INFOS() << "Tightening network throttle to " << mCurrentBandwidth << LL_ENDL;
 	}
 	else if (mean_packets_lost <= EASE_THROTTLE_THRESHOLD)
 	{
@@ -329,6 +329,6 @@ void LLViewerThrottle::updateDynamicThrottle()
 		mCurrentBandwidth = mMaxBandwidth * mThrottleFrac;
 		mCurrent = getThrottleGroup(mCurrentBandwidth/1024.0f);
 		mCurrent.sendToSim();
-		llinfos << "Easing network throttle to " << mCurrentBandwidth << llendl;
+		LL_INFOS() << "Easing network throttle to " << mCurrentBandwidth << LL_ENDL;
 	}
 }
diff --git a/indra/newview/llviewerwearable.cpp b/indra/newview/llviewerwearable.cpp
index c7e97cfe94..a544cc81da 100644
--- a/indra/newview/llviewerwearable.cpp
+++ b/indra/newview/llviewerwearable.cpp
@@ -104,7 +104,7 @@ LLWearable::EImportResult LLViewerWearable::importStream( std::istream& input_st
 	{
 		// Shouldn't really log the asset id for security reasons, but
 		// we need it in this case.
-		llwarns << "Bad Wearable asset header: " << mAssetID << llendl;
+		LL_WARNS() << "Bad Wearable asset header: " << mAssetID << LL_ENDL;
 		//gVFS->dumpMap();
 		return result;
 	}
@@ -144,7 +144,7 @@ BOOL LLViewerWearable::isOldVersion() const
 
 	if( LLWearable::sCurrentDefinitionVersion < mDefinitionVersion )
 	{
-		llwarns << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLWearable::sCurrentDefinitionVersion << ")" << llendl;
+		LL_WARNS() << "Wearable asset has newer version (" << mDefinitionVersion << ") than XML (" << LLWearable::sCurrentDefinitionVersion << ")" << LL_ENDL;
 		llassert(0);
 	}
 
@@ -537,8 +537,8 @@ struct LLWearableSaveData
 
 void LLViewerWearable::saveNewAsset() const
 {
-//	llinfos << "LLViewerWearable::saveNewAsset() type: " << getTypeName() << llendl;
-	//llinfos << *this << llendl;
+//	LL_INFOS() << "LLViewerWearable::saveNewAsset() type: " << getTypeName() << LL_ENDL;
+	//LL_INFOS() << *this << LL_ENDL;
 
 	const std::string filename = asset_id_to_filename(mAssetID);
 	LLFILE* fp = LLFile::fopen(filename, "wb");		/* Flawfinder: ignore */
@@ -555,7 +555,7 @@ void LLViewerWearable::saveNewAsset() const
 	if(!successful_save)
 	{
 		std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str());
-		llwarns << buffer << llendl;
+		LL_WARNS() << buffer << LL_ENDL;
 		
 		LLSD args;
 		args["NAME"] = mName;
@@ -570,7 +570,7 @@ void LLViewerWearable::saveNewAsset() const
 		std::string url = gAgent.getRegion()->getCapability("NewAgentInventory");
 		if (!url.empty())
 		{
-			llinfos << "Update Agent Inventory via capability" << llendl;
+			LL_INFOS() << "Update Agent Inventory via capability" << LL_ENDL;
 			LLSD body;
 			body["folder_id"] = gInventory.findCategoryUUIDForType(LLFolderType::assetToFolderType(getAssetType()));
 			body["asset_type"] = LLAssetType::lookup(getAssetType());
@@ -599,12 +599,12 @@ void LLViewerWearable::onSaveNewAssetComplete(const LLUUID& new_asset_id, void*
 	if(0 == status)
 	{
 		// Success
-		llinfos << "Saved wearable " << type_name << llendl;
+		LL_INFOS() << "Saved wearable " << type_name << LL_ENDL;
 	}
 	else
 	{
 		std::string buffer = llformat("Unable to save %s to central asset store.", type_name.c_str());
-		llwarns << buffer << " Status: " << status << llendl;
+		LL_WARNS() << buffer << " Status: " << status << LL_ENDL;
 		LLSD args;
 		args["NAME"] = type_name;
 		LLNotificationsUtil::add("CannotSaveToAssetStore", args);
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 4ec9485aee..12d58b7521 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -886,7 +886,7 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 
 		if (gDebugClicks)
 		{	
-			llinfos << "ViewerWindow " << buttonname << " mouse " << buttonstatestr << " at " << x << "," << y << llendl;
+			LL_INFOS() << "ViewerWindow " << buttonname << " mouse " << buttonstatestr << " at " << x << "," << y << LL_ENDL;
 		}
 
 		// Make sure we get a corresponding mouseup event, even if the mouse leaves the window
@@ -912,7 +912,7 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 			mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
 			if (LLView::sDebugMouseHandling)
 			{
-				llinfos << buttonname << " Mouse " << buttonstatestr << " handled by captor " << mouse_captor->getName() << llendl;
+				LL_INFOS() << buttonname << " Mouse " << buttonstatestr << " handled by captor " << mouse_captor->getName() << LL_ENDL;
 			}
 			return mouse_captor->handleAnyMouseClick(local_x, local_y, mask, clicktype, down);
 		}
@@ -946,13 +946,13 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 		{
 			if (LLView::sDebugMouseHandling)
 			{
-				llinfos << buttonname << " Mouse " << buttonstatestr << " " << LLView::sMouseHandlerMessage << llendl;
+				LL_INFOS() << buttonname << " Mouse " << buttonstatestr << " " << LLView::sMouseHandlerMessage << LL_ENDL;
 			}
 			return TRUE;
 		}
 		else if (LLView::sDebugMouseHandling)
 		{
-			llinfos << buttonname << " Mouse " << buttonstatestr << " not handled by view" << llendl;
+			LL_INFOS() << buttonname << " Mouse " << buttonstatestr << " not handled by view" << LL_ENDL;
 		}
 	}
 
@@ -1077,7 +1077,7 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi
 					S32 object_face = pick_info.mObjectFace;
 					std::string url = data;
 
-					lldebugs << "Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << llendl;
+					LL_DEBUGS() << "Object: picked at " << pos.mX << ", " << pos.mY << " - face = " << object_face << " - URL = " << url << LL_ENDL;
 
 					LLVOVolume *obj = dynamic_cast<LLVOVolume*>(static_cast<LLViewerObject*>(pick_info.getObject()));
 				
@@ -1566,7 +1566,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
 	LLNotifications::instance().setIgnoreAllNotifications(ignore);
 	if (ignore)
 	{
-	llinfos << "NOTE: ALL NOTIFICATIONS THAT OCCUR WILL GET ADDED TO IGNORE LIST FOR LATER RUNS." << llendl;
+	LL_INFOS() << "NOTE: ALL NOTIFICATIONS THAT OCCUR WILL GET ADDED TO IGNORE LIST FOR LATER RUNS." << LL_ENDL;
 	}
 
 	// Default to application directory.
@@ -1604,14 +1604,14 @@ LLViewerWindow::LLViewerWindow(const Params& p)
 	{
 		LLSplashScreen::update(LLTrans::getString("StartupRequireDriverUpdate"));
 	
-		LL_WARNS("Window") << "Failed to create window, to be shutting Down, be sure your graphics driver is updated." << llendl ;
+		LL_WARNS("Window") << "Failed to create window, to be shutting Down, be sure your graphics driver is updated." << LL_ENDL ;
 
 		ms_sleep(5000) ; //wait for 5 seconds.
 
 		LLSplashScreen::update(LLTrans::getString("ShuttingDown"));
 #if LL_LINUX || LL_SOLARIS
-		llwarns << "Unable to create window, be sure screen is set at 32-bit color and your graphics driver is configured correctly.  See README-linux.txt or README-solaris.txt for further information."
-				<< llendl;
+		LL_WARNS() << "Unable to create window, be sure screen is set at 32-bit color and your graphics driver is configured correctly.  See README-linux.txt or README-solaris.txt for further information."
+				<< LL_ENDL;
 #else
 		LL_WARNS("Window") << "Unable to create window, be sure screen is set at 32-bit color in Control Panels->Display->Settings"
 				<< LL_ENDL;
@@ -1631,7 +1631,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)
 
     if(p.fullscreen && ( scr.mX!=p.width || scr.mY!=p.height))
     {
-		llwarns << "Fullscreen has forced us in to a different resolution now using "<<scr.mX<<" x "<<scr.mY<<llendl;
+		LL_WARNS() << "Fullscreen has forced us in to a different resolution now using "<<scr.mX<<" x "<<scr.mY<<LL_ENDL;
 		gSavedSettings.setS32("FullScreenWidth",scr.mX);
 		gSavedSettings.setS32("FullScreenHeight",scr.mY);
     }
@@ -1983,24 +1983,24 @@ void LLViewerWindow::shutdownViews()
 	// clean up warning logger
 	LLError::removeRecorder(RecordToChatConsole::getInstance());
 
-	llinfos << "Warning logger is cleaned." << llendl ;
+	LL_INFOS() << "Warning logger is cleaned." << LL_ENDL ;
 
 	delete mDebugText;
 	mDebugText = NULL;
 	
-	llinfos << "DebugText deleted." << llendl ;
+	LL_INFOS() << "DebugText deleted." << LL_ENDL ;
 
 	// Cleanup global views
 	if (gMorphView)
 	{
 		gMorphView->setVisible(FALSE);
 	}
-	llinfos << "Global views cleaned." << llendl ;
+	LL_INFOS() << "Global views cleaned." << LL_ENDL ;
 	
 	// DEV-40930: Clear sModalStack. Otherwise, any LLModalDialog left open
 	// will crump with LL_ERRS.
 	LLModalDialog::shutdownModals();
-	llinfos << "LLModalDialog shut down." << llendl; 
+	LL_INFOS() << "LLModalDialog shut down." << LL_ENDL; 
 
 	// destroy the nav bar, not currently part of gViewerWindow
 	// *TODO: Make LLNavigationBar part of gViewerWindow
@@ -2008,17 +2008,17 @@ void LLViewerWindow::shutdownViews()
 	{
 		delete LLNavigationBar::getInstance();
 	}
-	llinfos << "LLNavigationBar destroyed." << llendl ;
+	LL_INFOS() << "LLNavigationBar destroyed." << LL_ENDL ;
 	
 	// destroy menus after instantiating navbar above, as it needs
 	// access to gMenuHolder
 	cleanup_menus();
-	llinfos << "menus destroyed." << llendl ;
+	LL_INFOS() << "menus destroyed." << LL_ENDL ;
 	
 	// Delete all child views.
 	delete mRootView;
 	mRootView = NULL;
-	llinfos << "RootView deleted." << llendl ;
+	LL_INFOS() << "RootView deleted." << LL_ENDL ;
 	
 	LLMenuOptionPathfindingRebakeNavmesh::getInstance()->quit();
 
@@ -2046,12 +2046,12 @@ void LLViewerWindow::shutdownGL()
 	gSky.cleanup();
 	stop_glerror();
 
-	llinfos << "Cleaning up pipeline" << llendl;
+	LL_INFOS() << "Cleaning up pipeline" << LL_ENDL;
 	gPipeline.cleanup();
 	stop_glerror();
 
 	//MUST clean up pipeline before cleaning up wearables
-	llinfos << "Cleaning up wearables" << llendl;
+	LL_INFOS() << "Cleaning up wearables" << LL_ENDL;
 	LLWearableList::instance().cleanup() ;
 
 	gTextureList.shutdown();
@@ -2065,12 +2065,12 @@ void LLViewerWindow::shutdownGL()
 	LLViewerTextureManager::cleanup() ;
 	LLImageGL::cleanupClass() ;
 
-	llinfos << "All textures and llimagegl images are destroyed!" << llendl ;
+	LL_INFOS() << "All textures and llimagegl images are destroyed!" << LL_ENDL ;
 
-	llinfos << "Cleaning up select manager" << llendl;
+	LL_INFOS() << "Cleaning up select manager" << LL_ENDL;
 	LLSelectMgr::getInstance()->cleanup();	
 
-	llinfos << "Stopping GL during shutdown" << llendl;
+	LL_INFOS() << "Stopping GL during shutdown" << LL_ENDL;
 	stopGL(FALSE);
 	stop_glerror();
 
@@ -2078,13 +2078,13 @@ void LLViewerWindow::shutdownGL()
 
 	LLVertexBuffer::cleanupClass();
 
-	llinfos << "LLVertexBuffer cleaned." << llendl ;
+	LL_INFOS() << "LLVertexBuffer cleaned." << LL_ENDL ;
 }
 
 // shutdownViews() and shutdownGL() need to be called first
 LLViewerWindow::~LLViewerWindow()
 {
-	llinfos << "Destroying Window" << llendl;
+	LL_INFOS() << "Destroying Window" << LL_ENDL;
 	destroyWindow();
 
 	delete mDebugText;
@@ -2681,7 +2681,7 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
 		mouse_captor->handleScrollWheel(local_x, local_y, clicks);
 		if (LLView::sDebugMouseHandling)
 		{
-			llinfos << "Scroll Wheel handled by captor " << mouse_captor->getName() << llendl;
+			LL_INFOS() << "Scroll Wheel handled by captor " << mouse_captor->getName() << LL_ENDL;
 		}
 		return;
 	}
@@ -2699,13 +2699,13 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
 	{
 		if (LLView::sDebugMouseHandling)
 		{
-			llinfos << "Scroll Wheel" << LLView::sMouseHandlerMessage << llendl;
+			LL_INFOS() << "Scroll Wheel" << LLView::sMouseHandlerMessage << LL_ENDL;
 		}
 		return;
 	}
 	else if (LLView::sDebugMouseHandling)
 	{
-		llinfos << "Scroll Wheel not handled by view" << llendl;
+		LL_INFOS() << "Scroll Wheel not handled by view" << LL_ENDL;
 	}
 
 	// Zoom the camera in and out behavior
@@ -3019,12 +3019,12 @@ void LLViewerWindow::updateUI()
 			handled = mouse_captor->handleHover(local_x, local_y, mask);
 			if (LLView::sDebugMouseHandling)
 			{
-				llinfos << "Hover handled by captor " << mouse_captor->getName() << llendl;
+				LL_INFOS() << "Hover handled by captor " << mouse_captor->getName() << LL_ENDL;
 			}
 
 			if( !handled )
 			{
-				LL_DEBUGS("UserInput") << "hover not handled by mouse captor" << llendl;
+				LL_DEBUGS("UserInput") << "hover not handled by mouse captor" << LL_ENDL;
 			}
 		}
 		else
@@ -3045,7 +3045,7 @@ void LLViewerWindow::updateUI()
 					if (LLView::sDebugMouseHandling && LLView::sMouseHandlerMessage != last_handle_msg)
 					{
 						last_handle_msg = LLView::sMouseHandlerMessage;
-						llinfos << "Hover" << LLView::sMouseHandlerMessage << llendl;
+						LL_INFOS() << "Hover" << LLView::sMouseHandlerMessage << LL_ENDL;
 					}
 					handled = TRUE;
 				}
@@ -3054,7 +3054,7 @@ void LLViewerWindow::updateUI()
 					if (last_handle_msg != LLStringUtil::null)
 					{
 						last_handle_msg.clear();
-						llinfos << "Hover not handled by view" << llendl;
+						LL_INFOS() << "Hover not handled by view" << LL_ENDL;
 					}
 				}
 			}
@@ -3643,11 +3643,11 @@ BOOL LLViewerWindow::clickPointOnSurfaceGlobal(const S32 x, const S32 y, LLViewe
 	if (!intersect)
 	{
 		point_global = clickPointInWorldGlobal(x, y, objectp);
-		llinfos << "approx intersection at " <<  (objectp->getPositionGlobal() - point_global) << llendl;
+		LL_INFOS() << "approx intersection at " <<  (objectp->getPositionGlobal() - point_global) << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "good intersection at " <<  (objectp->getPositionGlobal() - point_global) << llendl;
+		LL_INFOS() << "good intersection at " <<  (objectp->getPositionGlobal() - point_global) << LL_ENDL;
 	}
 
 	return intersect;
@@ -4015,13 +4015,13 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d
 		S32 grids_per_edge = (S32) regionp->getLand().mGridsPerEdge;
 		if ((i >= grids_per_edge) || (j >= grids_per_edge))
 		{
-			//llinfos << "LLViewerWindow::mousePointOnLand probe_point is out of region" << llendl;
+			//LL_INFOS() << "LLViewerWindow::mousePointOnLand probe_point is out of region" << LL_ENDL;
 			continue;
 		}
 
 		land_z = regionp->getLand().resolveHeightRegion(probe_point_region);
 
-		//llinfos << "mousePointOnLand initial z " << land_z << llendl;
+		//LL_INFOS() << "mousePointOnLand initial z " << land_z << LL_ENDL;
 
 		if (probe_point_region.mV[VZ] < land_z)
 		{
@@ -4062,7 +4062,7 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d
 			j = (S32) (local_probe_point.mV[VY]/regionp->getLand().getMetersPerGrid());
 			if ((i >= regionp->getLand().mGridsPerEdge) || (j >= regionp->getLand().mGridsPerEdge))
 			{
-				// llinfos << "LLViewerWindow::mousePointOnLand probe_point is out of region" << llendl;
+				// LL_INFOS() << "LLViewerWindow::mousePointOnLand probe_point is out of region" << LL_ENDL;
 				continue;
 			}
 			land_z = regionp->getLand().mSurfaceZ[ i + j * (regionp->getLand().mGridsPerEdge) ];
@@ -4070,7 +4070,7 @@ BOOL LLViewerWindow::mousePointOnLandGlobal(const S32 x, const S32 y, LLVector3d
 
 			land_z = regionp->getLand().resolveHeightRegion(probe_point_region);
 
-			//llinfos << "mousePointOnLand refine z " << land_z << llendl;
+			//LL_INFOS() << "mousePointOnLand refine z " << land_z << LL_ENDL;
 
 			if (probe_point_region.mV[VZ] < land_z)
 			{
@@ -4090,7 +4090,7 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, bool force_picke
 {
 	if (!image)
 	{
-		llwarns << "No image to save" << llendl;
+		LL_WARNS() << "No image to save" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -4150,7 +4150,7 @@ BOOL LLViewerWindow::saveImageNumbered(LLImageFormatted *image, bool force_picke
 	}
 	while( -1 != err );  // search until the file is not found (i.e., stat() gives an error).
 
-	llinfos << "Saving snapshot to " << filepath << llendl;
+	LL_INFOS() << "Saving snapshot to " << filepath << LL_ENDL;
 	return image->save(filepath);
 }
 
@@ -4173,7 +4173,7 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
 
 BOOL LLViewerWindow::saveSnapshot( const std::string& filepath, S32 image_width, S32 image_height, BOOL show_ui, BOOL do_rebuild, ESnapshotType type)
 {
-	llinfos << "Saving snapshot to: " << filepath << llendl;
+	LL_INFOS() << "Saving snapshot to: " << filepath << LL_ENDL;
 
 	LLPointer<LLImageRaw> raw = new LLImageRaw;
 	BOOL success = rawSnapshot(raw, image_width, image_height, TRUE, FALSE, show_ui, do_rebuild);
@@ -4188,12 +4188,12 @@ BOOL LLViewerWindow::saveSnapshot( const std::string& filepath, S32 image_width,
 		}
 		else
 		{
-			llwarns << "Unable to encode bmp snapshot" << llendl;
+			LL_WARNS() << "Unable to encode bmp snapshot" << LL_ENDL;
 		}
 	}
 	else
 	{
-		llwarns << "Unable to capture raw snapshot" << llendl;
+		LL_WARNS() << "Unable to capture raw snapshot" << LL_ENDL;
 	}
 
 	return success;
@@ -4234,7 +4234,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
 	{
 		if(!LLMemory::tryToAlloc(NULL, image_width * image_height * 3))
 		{
-			llwarns << "No enough memory to take the snapshot with size (w : h): " << image_width << " : " << image_height << llendl ;
+			LL_WARNS() << "No enough memory to take the snapshot with size (w : h): " << image_width << " : " << image_height << LL_ENDL ;
 			return FALSE ; //there is no enough memory for taking this snapshot.
 		}
 	}
@@ -4328,7 +4328,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
 	if (show_ui && scale_factor > 1.f)
 	{
 		// Note: we should never get there...
-		llwarns << "over scaling UI not supported." << llendl;
+		LL_WARNS() << "over scaling UI not supported." << LL_ENDL;
 	}
 
 	S32 buffer_x_offset = llfloor(((window_width  - snapshot_width)  * scale_factor) / 2.f);
@@ -4360,7 +4360,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
 	if (high_res && show_ui)
 	{
 		// Note: we should never get there...
-		llwarns << "High res UI snapshot not supported. " << llendl;
+		LL_WARNS() << "High res UI snapshot not supported. " << LL_ENDL;
 		/*send_agent_pause();
 		//rescale fonts
 		initFonts(scale_factor);
@@ -4725,10 +4725,10 @@ LLProgressView *LLViewerWindow::getProgressView() const
 
 void LLViewerWindow::dumpState()
 {
-	llinfos << "LLViewerWindow Active " << S32(mActive) << llendl;
-	llinfos << "mWindow visible " << S32(mWindow->getVisible())
+	LL_INFOS() << "LLViewerWindow Active " << S32(mActive) << LL_ENDL;
+	LL_INFOS() << "mWindow visible " << S32(mWindow->getVisible())
 		<< " minimized " << S32(mWindow->getMinimized())
-		<< llendl;
+		<< LL_ENDL;
 }
 
 void LLViewerWindow::stopGL(BOOL save_state)
@@ -4739,7 +4739,7 @@ void LLViewerWindow::stopGL(BOOL save_state)
 	//especially be careful to put anything behind gTextureList.destroyGL(save_state);
 	if (!gGLManager.mIsDisabled)
 	{
-		llinfos << "Shutting down GL..." << llendl;
+		LL_INFOS() << "Shutting down GL..." << LL_ENDL;
 
 		// Pause texture decode threads (will get unpaused during main loop)
 		LLAppViewer::getTextureCache()->pause();
@@ -4784,7 +4784,7 @@ void LLViewerWindow::stopGL(BOOL save_state)
 		gGLManager.mIsDisabled = TRUE;
 		stop_glerror();
 		
-		llinfos << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemory.value() << " bytes" << llendl;
+		LL_INFOS() << "Remaining allocated texture memory: " << LLImageGL::sGlobalTextureMemory.value() << " bytes" << LL_ENDL;
 	}
 }
 
@@ -4796,7 +4796,7 @@ void LLViewerWindow::restoreGL(const std::string& progress_message)
 	//especially, be careful to put something before gTextureList.restoreGL();
 	if (gGLManager.mIsDisabled)
 	{
-		llinfos << "Restoring GL..." << llendl;
+		LL_INFOS() << "Restoring GL..." << LL_ENDL;
 		gGLManager.mIsDisabled = FALSE;
 		
 		initGLDefaults();
@@ -4833,10 +4833,10 @@ void LLViewerWindow::restoreGL(const std::string& progress_message)
 			setShowProgress(TRUE);
 			setProgressString(progress_message);
 		}
-		llinfos << "...Restoring GL done" << llendl;
+		LL_INFOS() << "...Restoring GL done" << LL_ENDL;
 		if(!LLAppViewer::instance()->restoreErrorTrap())
 		{
-			llwarns << " Someone took over my signal/exception handler (post restoreGL)!" << llendl;
+			LL_WARNS() << " Someone took over my signal/exception handler (post restoreGL)!" << LL_ENDL;
 		}
 
 	}
@@ -4884,7 +4884,7 @@ void LLViewerWindow::checkSettings()
 
 void LLViewerWindow::restartDisplay(BOOL show_progress_bar)
 {
-	llinfos << "Restaring GL" << llendl;
+	LL_INFOS() << "Restaring GL" << LL_ENDL;
 	stopGL();
 	if (show_progress_bar)
 	{
@@ -4927,7 +4927,7 @@ BOOL LLViewerWindow::changeDisplaySettings(LLCoordScreen size, BOOL disable_vsyn
 
 	LLFocusableElement* keyboard_focus = gFocusMgr.getKeyboardFocus();
 	send_agent_pause();
-	llinfos << "Stopping GL during changeDisplaySettings" << llendl;
+	LL_INFOS() << "Stopping GL during changeDisplaySettings" << LL_ENDL;
 	stopGL();
 	mIgnoreActivate = TRUE;
 	LLCoordScreen old_size;
@@ -4953,7 +4953,7 @@ BOOL LLViewerWindow::changeDisplaySettings(LLCoordScreen size, BOOL disable_vsyn
 	}
 	send_agent_resume();
 
-	llinfos << "Restoring GL during resolution change" << llendl;
+	LL_INFOS() << "Restoring GL during resolution change" << LL_ENDL;
 	if (show_progress_bar)
 	{
 		restoreGL(LLTrans::getString("ProgressChangingResolution"));
@@ -5019,7 +5019,7 @@ void LLViewerWindow::calcDisplayScale()
 	
 	if (display_scale != mDisplayScale)
 	{
-		llinfos << "Setting display scale to " << display_scale << llendl;
+		LL_INFOS() << "Setting display scale to " << display_scale << LL_ENDL;
 
 		mDisplayScale = display_scale;
 		// Init default fonts
diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp
index cd2075b122..4e9400872a 100755
--- a/indra/newview/llvlcomposition.cpp
+++ b/indra/newview/llvlcomposition.cpp
@@ -287,7 +287,7 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y,
 				{
 					mDetailTextures[i]->destroyRawImage() ;
 				}
-				lldebugs << "cached raw data for terrain detail texture is not ready yet: " << mDetailTextures[i]->getID() << llendl;
+				LL_DEBUGS() << "cached raw data for terrain detail texture is not ready yet: " << mDetailTextures[i]->getID() << LL_ENDL;
 				return FALSE;
 			}
 
@@ -323,12 +323,12 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y,
 
 	if (x_end > mWidth)
 	{
-		llwarns << "x end > width" << llendl;
+		LL_WARNS() << "x end > width" << LL_ENDL;
 		x_end = mWidth;
 	}
 	if (y_end > mWidth)
 	{
-		llwarns << "y end > width" << llendl;
+		LL_WARNS() << "y end > width" << LL_ENDL;
 		y_end = mWidth;
 	}
 
@@ -358,7 +358,7 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y,
 	
 	if (tex_comps != st_comps)
 	{
-		llwarns << "Base texture comps != input texture comps" << llendl;
+		LL_WARNS() << "Base texture comps != input texture comps" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -416,8 +416,8 @@ BOOL LLVLComposition::generateTexture(const F32 x, const F32 y,
 				if (st_offset >= st_data_size[tex0] || st_offset >= st_data_size[tex1])
 				{
 					// SJB: This shouldn't be happening, but does... Rounding error?
-					//llwarns << "offset 0 [" << tex0 << "] =" << st_offset << " >= size=" << st_data_size[tex0] << llendl;
-					//llwarns << "offset 1 [" << tex1 << "] =" << st_offset << " >= size=" << st_data_size[tex1] << llendl;
+					//LL_WARNS() << "offset 0 [" << tex0 << "] =" << st_offset << " >= size=" << st_data_size[tex0] << LL_ENDL;
+					//LL_WARNS() << "offset 1 [" << tex1 << "] =" << st_offset << " >= size=" << st_data_size[tex1] << LL_ENDL;
 				}
 				else
 				{
diff --git a/indra/newview/llvlmanager.cpp b/indra/newview/llvlmanager.cpp
index b231abc9c5..9b55bbf277 100755
--- a/indra/newview/llvlmanager.cpp
+++ b/indra/newview/llvlmanager.cpp
@@ -68,7 +68,7 @@ void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size)
 	}
 	else
 	{
-		llerrs << "Unknown layer type!" << (S32)vl_datap->mType << llendl;
+		LL_ERRS() << "Unknown layer type!" << (S32)vl_datap->mType << LL_ENDL;
 	}
 
 	mPacketData.push_back(vl_datap);
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 04c1bd3968..5971da95ce 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -719,7 +719,7 @@ LLVOAvatar::LLVOAvatar(const LLUUID& id,
 	const BOOL needsSendToSim = false; // currently, this HUD effect doesn't need to pack and unpack data to do its job
 	mVoiceVisualizer = ( LLVoiceVisualizer *)LLHUDManager::getInstance()->createViewerEffect( LLHUDObject::LL_HUD_EFFECT_VOICE_VISUALIZER, needsSendToSim );
 
-	lldebugs << "LLVOAvatar Constructor (0x" << this << ") id:" << mID << llendl;
+	LL_DEBUGS() << "LLVOAvatar Constructor (0x" << this << ") id:" << mID << LL_ENDL;
 
 	mPelvisp = NULL;
 
@@ -792,7 +792,7 @@ void LLVOAvatar::debugAvatarRezTime(std::string notification_name, std::string c
 					   << "RuthTimer " << (U32)mRuthDebugTimer.getElapsedTimeF32()
 					   << " Notification " << notification_name
 					   << " : " << comment
-					   << llendl;
+					   << LL_ENDL;
 
 	if (gSavedSettings.getBOOL("DebugAvatarRezTime"))
 	{
@@ -820,7 +820,7 @@ LLVOAvatar::~LLVOAvatar()
 
 	logPendingPhases();
 	
-	lldebugs << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << llendl;
+	LL_DEBUGS() << "LLVOAvatar Destructor (0x" << this << ") id:" << mID << LL_ENDL;
 
 	std::for_each(mAttachmentPoints.begin(), mAttachmentPoints.end(), DeletePairedPointer());
 	mAttachmentPoints.clear();
@@ -832,7 +832,7 @@ LLVOAvatar::~LLVOAvatar()
 
 	getPhases().clearPhases();
 	
-	lldebugs << "LLVOAvatar Destructor end" << llendl;
+	LL_DEBUGS() << "LLVOAvatar Destructor end" << LL_ENDL;
 }
 
 void LLVOAvatar::markDead()
@@ -996,54 +996,54 @@ void LLVOAvatar::dumpBakedStatus()
 		 iter != LLCharacter::sInstances.end(); ++iter)
 	{
 		LLVOAvatar* inst = (LLVOAvatar*) *iter;
-		llinfos << "Avatar ";
+		LL_INFOS() << "Avatar ";
 
 		LLNameValue* firstname = inst->getNVPair("FirstName");
 		LLNameValue* lastname = inst->getNVPair("LastName");
 
 		if( firstname )
 		{
-			llcont << firstname->getString();
+			LL_CONT << firstname->getString();
 		}
 		if( lastname )
 		{
-			llcont << " " << lastname->getString();
+			LL_CONT << " " << lastname->getString();
 		}
 
-		llcont << " " << inst->mID;
+		LL_CONT << " " << inst->mID;
 
 		if( inst->isDead() )
 		{
-			llcont << " DEAD ("<< inst->getNumRefs() << " refs)";
+			LL_CONT << " DEAD ("<< inst->getNumRefs() << " refs)";
 		}
 
 		if( inst->isSelf() )
 		{
-			llcont << " (self)";
+			LL_CONT << " (self)";
 		}
 
 
 		F64 dist_to_camera = (inst->getPositionGlobal() - camera_pos_global).length();
-		llcont << " " << dist_to_camera << "m ";
+		LL_CONT << " " << dist_to_camera << "m ";
 
-		llcont << " " << inst->mPixelArea << " pixels";
+		LL_CONT << " " << inst->mPixelArea << " pixels";
 
 		if( inst->isVisible() )
 		{
-			llcont << " (visible)";
+			LL_CONT << " (visible)";
 		}
 		else
 		{
-			llcont << " (not visible)";
+			LL_CONT << " (not visible)";
 		}
 
 		if( inst->isFullyBaked() )
 		{
-			llcont << " Baked";
+			LL_CONT << " Baked";
 		}
 		else
 		{
-			llcont << " Unbaked (";
+			LL_CONT << " Unbaked (";
 			
 			for (LLAvatarAppearanceDictionary::BakedTextures::const_iterator iter = LLAvatarAppearanceDictionary::getInstance()->getBakedTextures().begin();
 				 iter != LLAvatarAppearanceDictionary::getInstance()->getBakedTextures().end();
@@ -1053,16 +1053,16 @@ void LLVOAvatar::dumpBakedStatus()
 				const ETextureIndex index = baked_dict->mTextureIndex;
 				if (!inst->isTextureDefined(index))
 				{
-					llcont << " " << LLAvatarAppearanceDictionary::getInstance()->getTexture(index)->mName;
+					LL_CONT << " " << LLAvatarAppearanceDictionary::getInstance()->getTexture(index)->mName;
 				}
 			}
-			llcont << " ) " << inst->getUnbakedPixelAreaRank();
+			LL_CONT << " ) " << inst->getUnbakedPixelAreaRank();
 			if( inst->isCulled() )
 			{
-				llcont << " culled";
+				LL_CONT << " culled";
 			}
 		}
-		llcont << llendl;
+		LL_CONT << LL_ENDL;
 	}
 }
 
@@ -1103,7 +1103,7 @@ void LLVOAvatar::deleteCachedImages(bool clearAll)
 {	
 	if (LLViewerTexLayerSet::sHasCaches)
 	{
-		lldebugs << "Deleting layer set caches" << llendl;
+		LL_DEBUGS() << "Deleting layer set caches" << LL_ENDL;
 		for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
 			 iter != LLCharacter::sInstances.end(); ++iter)
 		{
@@ -1604,14 +1604,14 @@ void LLVOAvatar::buildCharacter()
 	// If we don't have the Ooh morph, use the Kiss morph
 	if (!mOohMorph)
 	{
-		llwarns << "Missing 'Ooh' morph for lipsync, using fallback." << llendl;
+		LL_WARNS() << "Missing 'Ooh' morph for lipsync, using fallback." << LL_ENDL;
 		mOohMorph = getVisualParam( "Express_Kiss" );
 	}
 
 	// If we don't have the Aah morph, use the Open Mouth morph
 	if (!mAahMorph)
 	{
-		llwarns << "Missing 'Aah' morph for lipsync, using fallback." << llendl;
+		LL_WARNS() << "Missing 'Aah' morph for lipsync, using fallback." << LL_ENDL;
 		mAahMorph = getVisualParam( "Express_Open_Mouth" );
 	}
 
@@ -1689,7 +1689,7 @@ void LLVOAvatar::restoreMeshData()
 {
 	llassert(!isSelf());
 	
-	//llinfos << "Restoring" << llendl;
+	//LL_INFOS() << "Restoring" << LL_ENDL;
 	mMeshValid = TRUE;
 	updateJointLODs();
 
@@ -1800,7 +1800,7 @@ void LLVOAvatar::updateMeshData()
 			//   the case of more than one avatar in the pool (thus > 0 instead of >= 0)
 			if (facep->getGeomIndex() > 0)
 			{
-				llerrs << "non-zero geom index: " << facep->getGeomIndex() << " in LLVOAvatar::restoreMeshData" << llendl;
+				LL_ERRS() << "non-zero geom index: " << facep->getGeomIndex() << " in LLVOAvatar::restoreMeshData" << LL_ENDL;
 			}
 
 			for(S32 k = j ; k < part_index ; k++)
@@ -1866,8 +1866,8 @@ U32 LLVOAvatar::processUpdateMessage(LLMessageSystem *mesgsys,
 		}
 	}
 
-	//llinfos << getRotation() << llendl;
-	//llinfos << getPosition() << llendl;
+	//LL_INFOS() << getRotation() << LL_ENDL;
+	//LL_INFOS() << getPosition() << LL_ENDL;
 
 	return retval;
 }
@@ -1889,13 +1889,13 @@ LLViewerFetchedTexture *LLVOAvatar::getBakedTextureImage(const U8 te, const LLUU
 		const std::string url = getImageURL(te,uuid);
 		if (!url.empty())
 		{
-			LL_DEBUGS("Avatar") << avString() << "from URL " << url << llendl;
+			LL_DEBUGS("Avatar") << avString() << "from URL " << url << LL_ENDL;
 			result = LLViewerTextureManager::getFetchedTextureFromUrl(
 				url, FTT_SERVER_BAKE, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, uuid);
 		}
 		else
 		{
-			LL_DEBUGS("Avatar") << avString() << "from host " << uuid << llendl;
+			LL_DEBUGS("Avatar") << avString() << "from host " << uuid << LL_ENDL;
 			LLHost host = getObjectHost();
 			result = LLViewerTextureManager::getFetchedTexture(
 				uuid, FTT_HOST_BAKE, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host);
@@ -1926,7 +1926,7 @@ static LLFastTimer::DeclareTimer FTM_JOINT_UPDATE("Update Joints");
 //------------------------------------------------------------------------
 void LLVOAvatar::dumpAnimationState()
 {
-	llinfos << "==============================================" << llendl;
+	LL_INFOS() << "==============================================" << LL_ENDL;
 	for (LLVOAvatar::AnimIterator it = mSignaledAnimations.begin(); it != mSignaledAnimations.end(); ++it)
 	{
 		LLUUID id = it->first;
@@ -1935,7 +1935,7 @@ void LLVOAvatar::dumpAnimationState()
 		{
 			playtag = "*";
 		}
-		llinfos << gAnimLibrary.animationName(id) << playtag << llendl;
+		LL_INFOS() << gAnimLibrary.animationName(id) << playtag << LL_ENDL;
 	}
 	for (LLVOAvatar::AnimIterator it = mPlayingAnimations.begin(); it != mPlayingAnimations.end(); ++it)
 	{
@@ -1943,7 +1943,7 @@ void LLVOAvatar::dumpAnimationState()
 		bool is_signaled = mSignaledAnimations.find(id) != mSignaledAnimations.end();
 		if (!is_signaled)
 		{
-			llinfos << gAnimLibrary.animationName(id) << "!S" << llendl;
+			LL_INFOS() << gAnimLibrary.animationName(id) << "!S" << LL_ENDL;
 		}
 	}
 }
@@ -1957,7 +1957,7 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 
 	if (isDead())
 	{
-		llinfos << "Warning!  Idle on dead avatar" << llendl;
+		LL_INFOS() << "Warning!  Idle on dead avatar" << LL_ENDL;
 		return;
 	}	
 
@@ -2088,7 +2088,7 @@ void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled)
 					if ( mCurrentGesticulationLevel == 0 )	{ gestureString = "/voicelevel1";	}
 					else	if ( mCurrentGesticulationLevel == 1 )	{ gestureString = "/voicelevel2";	}
 					else	if ( mCurrentGesticulationLevel == 2 )	{ gestureString = "/voicelevel3";	}
-					else	{ llinfos << "oops - CurrentGesticulationLevel can be only 0, 1, or 2"  << llendl; }
+					else	{ LL_INFOS() << "oops - CurrentGesticulationLevel can be only 0, 1, or 2"  << LL_ENDL; }
 					
 					// this is the call that Karl S. created for triggering gestures from within the code.
 					LLGestureMgr::instance().triggerAndReviseString( gestureString );
@@ -2164,7 +2164,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 {
 	if (LLVOAvatar::sJointDebug)
 	{
-		llinfos << getFullname() << ": joint touches: " << LLJoint::sNumTouches << " updates: " << LLJoint::sNumUpdates << llendl;
+		LL_INFOS() << getFullname() << ": joint touches: " << LLJoint::sNumTouches << " updates: " << LLJoint::sNumUpdates << LL_ENDL;
 	}
 
 	LLJoint::sNumUpdates = 0;
@@ -3152,7 +3152,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 			removeAnimationData("Walk Speed");
 		}
 		mMotionController.setTimeStep(time_step);
-//		llinfos << "Setting timestep to " << time_quantum * pixel_area_scale << llendl;
+//		LL_INFOS() << "Setting timestep to " << time_quantum * pixel_area_scale << LL_ENDL;
 	}
 
 	if (getParent() && !mIsSitting)
@@ -3617,42 +3617,42 @@ void LLVOAvatar::updateVisibility()
 			}
 			else
 			{
-				llinfos << "Avatar " << this << " updating visiblity" << llendl;
+				LL_INFOS() << "Avatar " << this << " updating visiblity" << LL_ENDL;
 			}
 
 			if (visible)
 			{
-				llinfos << "Visible" << llendl;
+				LL_INFOS() << "Visible" << LL_ENDL;
 			}
 			else
 			{
-				llinfos << "Not visible" << llendl;
+				LL_INFOS() << "Not visible" << LL_ENDL;
 			}
 
 			/*if (avatar_in_frustum)
 			{
-				llinfos << "Avatar in frustum" << llendl;
+				LL_INFOS() << "Avatar in frustum" << LL_ENDL;
 			}
 			else
 			{
-				llinfos << "Avatar not in frustum" << llendl;
+				LL_INFOS() << "Avatar not in frustum" << LL_ENDL;
 			}*/
 
 			/*if (LLViewerCamera::getInstance()->sphereInFrustum(sel_pos_agent, 2.0f))
 			{
-				llinfos << "Sel pos visible" << llendl;
+				LL_INFOS() << "Sel pos visible" << LL_ENDL;
 			}
 			if (LLViewerCamera::getInstance()->sphereInFrustum(wrist_right_pos_agent, 0.2f))
 			{
-				llinfos << "Wrist pos visible" << llendl;
+				LL_INFOS() << "Wrist pos visible" << LL_ENDL;
 			}
 			if (LLViewerCamera::getInstance()->sphereInFrustum(getPositionAgent(), getMaxScale()*2.f))
 			{
-				llinfos << "Agent visible" << llendl;
+				LL_INFOS() << "Agent visible" << LL_ENDL;
 			}*/
-			llinfos << "PA: " << getPositionAgent() << llendl;
-			/*llinfos << "SPA: " << sel_pos_agent << llendl;
-			llinfos << "WPA: " << wrist_right_pos_agent << llendl;*/
+			LL_INFOS() << "PA: " << getPositionAgent() << LL_ENDL;
+			/*LL_INFOS() << "SPA: " << sel_pos_agent << LL_ENDL;
+			LL_INFOS() << "WPA: " << wrist_right_pos_agent << LL_ENDL;*/
 			for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); 
 				 iter != mAttachmentPoints.end();
 				 ++iter)
@@ -3667,11 +3667,11 @@ void LLVOAvatar::updateVisibility()
 					{
 						if(attached_object->mDrawable->isVisible())
 						{
-							llinfos << attachment->getName() << " visible" << llendl;
+							LL_INFOS() << attachment->getName() << " visible" << LL_ENDL;
 						}
 						else
 						{
-							llinfos << attachment->getName() << " not visible at " << mDrawable->getWorldPosition() << " and radius " << mDrawable->getRadius() << llendl;
+							LL_INFOS() << attachment->getName() << " not visible at " << mDrawable->getWorldPosition() << " and radius " << mDrawable->getRadius() << LL_ENDL;
 						}
 					}
 				}
@@ -3811,19 +3811,19 @@ U32 LLVOAvatar::renderSkinned()
 		}
 		else
 		{
-			llinfos << "Avatar " << this << " in render" << llendl;
+			LL_INFOS() << "Avatar " << this << " in render" << LL_ENDL;
 		}
 		if (!mIsBuilt)
 		{
-			llinfos << "Not built!" << llendl;
+			LL_INFOS() << "Not built!" << LL_ENDL;
 		}
 		else if (!gAgent.needsRenderAvatar())
 		{
-			llinfos << "Doesn't need avatar render!" << llendl;
+			LL_INFOS() << "Doesn't need avatar render!" << LL_ENDL;
 		}
 		else
 		{
-			llinfos << "Rendering!" << llendl;
+			LL_INFOS() << "Rendering!" << LL_ENDL;
 		}
 	}
 
@@ -4259,10 +4259,10 @@ void LLVOAvatar::releaseOldTextures()
 	S32 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 << ")" << llendl;  
+	//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;  
 	if (!isSelf() && new_total_mem > new_baked_mem)
 	{
-			llwarns << "extra local textures stored for non-self av" << llendl;
+			LL_WARNS() << "extra local textures stored for non-self av" << LL_ENDL;
 	}
 	for (std::set<LLUUID>::iterator it = mTextureIDs.begin(); it != mTextureIDs.end(); ++it)
 	{
@@ -4350,7 +4350,7 @@ void LLVOAvatar::updateTextures()
 		}
 		else
 		{
-			llwarns << "getTE( " << texture_index << " ) returned 0" <<llendl;
+			LL_WARNS() << "getTE( " << texture_index << " ) returned 0" <<LL_ENDL;
 		}
 
 		LLViewerFetchedTexture *imagep = NULL;
@@ -4381,7 +4381,7 @@ void LLVOAvatar::updateTextures()
 				LL_WARNS_ONCE("Texture") << "LLVOAvatar::updateTextures No host for texture "
 										 << imagep->getID() << " for avatar "
 										 << (isSelf() ? "<myself>" : getID().asString()) 
-										 << " on host " << getRegion()->getHost() << llendl;
+										 << " on host " << getRegion()->getHost() << LL_ENDL;
 			}
 
 			addBakedTextureStats( imagep, mPixelArea, texel_area_ratio, boost_level );			
@@ -4521,7 +4521,7 @@ const std::string LLVOAvatar::getImageURL(const U8 te, const LLUUID &uuid)
 		if (appearance_service_url.empty())
 		{
 			// Probably a server-side issue if we get here:
-			llwarns << "AgentAppearanceServiceURL not set - Baked texture requests will fail" << llendl;
+			LL_WARNS() << "AgentAppearanceServiceURL not set - Baked texture requests will fail" << LL_ENDL;
 			return url;
 		}
 	
@@ -4529,7 +4529,7 @@ const std::string LLVOAvatar::getImageURL(const U8 te, const LLUUID &uuid)
 		if (texture_entry != NULL)
 		{
 			url = appearance_service_url + "texture/" + getID().asString() + "/" + texture_entry->mDefaultImageName + "/" + uuid.asString();
-			//llinfos << "baked texture url: " << url << llendl;
+			//LL_INFOS() << "baked texture url: " << url << LL_ENDL;
 		}
 	}
 	return url;
@@ -4579,7 +4579,7 @@ void LLVOAvatar::resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos
 		LLVector3 relativePos = gAgent.getPosAgentFromGlobal(outPos) - obj->getPositionAgent();
 
 		LLVector3 linearComponent = angularVelocity % relativePos;
-//		llinfos << "Linear Component of Rotation Velocity " << linearComponent << llendl;
+//		LL_INFOS() << "Linear Component of Rotation Velocity " << linearComponent << LL_ENDL;
 		mStepObjectVelocity = obj->getVelocity() + linearComponent;
 	}
 }
@@ -4732,7 +4732,7 @@ BOOL LLVOAvatar::processSingleAnimationStateChange( const LLUUID& anim_id, BOOL
 		}
 		else
 		{
-			llwarns << "Failed to start motion!" << llendl;
+			LL_WARNS() << "Failed to start motion!" << LL_ENDL;
 		}
 	}
 	else //stop animation
@@ -4828,13 +4828,13 @@ LLUUID LLVOAvatar::remapMotionID(const LLUUID& id)
 //-----------------------------------------------------------------------------
 BOOL LLVOAvatar::startMotion(const LLUUID& id, F32 time_offset)
 {
-	lldebugs << "motion requested " << id.asString() << " " << gAnimLibrary.animationName(id) << llendl;
+	LL_DEBUGS() << "motion requested " << id.asString() << " " << gAnimLibrary.animationName(id) << LL_ENDL;
 
 	LLUUID remap_id = remapMotionID(id);
 
 	if (remap_id != id)
 	{
-		lldebugs << "motion resultant " << remap_id.asString() << " " << gAnimLibrary.animationName(remap_id) << llendl;
+		LL_DEBUGS() << "motion resultant " << remap_id.asString() << " " << gAnimLibrary.animationName(remap_id) << LL_ENDL;
 	}
 
 	if (isSelf() && remap_id == ANIM_AGENT_AWAY)
@@ -4850,13 +4850,13 @@ BOOL LLVOAvatar::startMotion(const LLUUID& id, F32 time_offset)
 //-----------------------------------------------------------------------------
 BOOL LLVOAvatar::stopMotion(const LLUUID& id, BOOL stop_immediate)
 {
-	lldebugs << "motion requested " << id.asString() << " " << gAnimLibrary.animationName(id) << llendl;
+	LL_DEBUGS() << "motion requested " << id.asString() << " " << gAnimLibrary.animationName(id) << LL_ENDL;
 
 	LLUUID remap_id = remapMotionID(id);
 	
 	if (remap_id != id)
 	{
-		lldebugs << "motion resultant " << remap_id.asString() << " " << gAnimLibrary.animationName(remap_id) << llendl;
+		LL_DEBUGS() << "motion resultant " << remap_id.asString() << " " << gAnimLibrary.animationName(remap_id) << LL_ENDL;
 	}
 
 	if (isSelf())
@@ -4949,7 +4949,7 @@ void LLVOAvatar::resetSpecificJointPosition( const std::string& name )
 	}
 	else
 	{
-		llinfos<<"Did not find "<< name.c_str()<<llendl;
+		LL_INFOS()<<"Did not find "<< name.c_str()<<LL_ENDL;
 	}
 }
 //-----------------------------------------------------------------------------
@@ -5123,7 +5123,7 @@ BOOL LLVOAvatar::loadSkeletonNode ()
 			LLJoint *parentJoint = getJoint(info->mJointName);
 			if (!parentJoint)
 			{
-				llwarns << "No parent joint by name " << info->mJointName << " found for attachment point " << info->mName << llendl;
+				LL_WARNS() << "No parent joint by name " << info->mJointName << " found for attachment point " << info->mName << LL_ENDL;
 				delete attachment;
 				continue;
 			}
@@ -5147,7 +5147,7 @@ BOOL LLVOAvatar::loadSkeletonNode ()
 			{
 				if (group < 0 || group >= 9)
 				{
-					llwarns << "Invalid group number (" << group << ") for attachment point " << info->mName << llendl;
+					LL_WARNS() << "Invalid group number (" << group << ") for attachment point " << info->mName << LL_ENDL;
 				}
 				else
 				{
@@ -5158,13 +5158,13 @@ BOOL LLVOAvatar::loadSkeletonNode ()
 			S32 attachmentID = info->mAttachmentID;
 			if (attachmentID < 1 || attachmentID > 255)
 			{
-				llwarns << "Attachment point out of range [1-255]: " << attachmentID << " on attachment point " << info->mName << llendl;
+				LL_WARNS() << "Attachment point out of range [1-255]: " << attachmentID << " on attachment point " << info->mName << LL_ENDL;
 				delete attachment;
 				continue;
 			}
 			if (mAttachmentPoints.find(attachmentID) != mAttachmentPoints.end())
 			{
-				llwarns << "Attachment point redefined with id " << attachmentID << " on attachment point " << info->mName << llendl;
+				LL_WARNS() << "Attachment point redefined with id " << attachmentID << " on attachment point " << info->mName << LL_ENDL;
 				delete attachment;
 				continue;
 			}
@@ -5350,7 +5350,7 @@ BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable)
 
 	if (!drawable)
 	{
-		llerrs << "LLVOAvatar::updateGeometry() called with NULL drawable" << llendl;
+		LL_ERRS() << "LLVOAvatar::updateGeometry() called with NULL drawable" << LL_ENDL;
 	}
 
 	return TRUE;
@@ -5436,7 +5436,7 @@ void LLVOAvatar::removeChild(LLViewerObject *childp)
 	LLViewerObject::removeChild(childp);
 	if (!detachObject(childp))
 	{
-		llwarns << "Calling detach on non-attached object " << llendl;
+		LL_WARNS() << "Calling detach on non-attached object " << LL_ENDL;
 	}
 }
 
@@ -5448,7 +5448,7 @@ LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* vi
 	// correctly, but putting this check in here to be safe.
 	if (attachmentID & ATTACHMENT_ADD)
 	{
-		llwarns << "Got an attachment with ATTACHMENT_ADD mask, removing ( attach pt:" << attachmentID << " )" << llendl;
+		LL_WARNS() << "Got an attachment with ATTACHMENT_ADD mask, removing ( attach pt:" << attachmentID << " )" << LL_ENDL;
 		attachmentID &= ~ATTACHMENT_ADD;
 	}
 	
@@ -5456,7 +5456,7 @@ LLViewerJointAttachment* LLVOAvatar::getTargetAttachmentPoint(LLViewerObject* vi
 
 	if (!attachment)
 	{
-		llwarns << "Object attachment point invalid: " << attachmentID << llendl;
+		LL_WARNS() << "Object attachment point invalid: " << attachmentID << LL_ENDL;
 		attachment = get_if_there(mAttachmentPoints, 1, (LLViewerJointAttachment*)NULL); // Arbitrary using 1 (chest)
 	}
 
@@ -5624,7 +5624,7 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
 		{
 			cleanupAttachedMesh( viewer_object );
 			attachment->removeObject(viewer_object);
-			lldebugs << "Detaching object " << viewer_object->mID << " from " << attachment->getName() << llendl;
+			LL_DEBUGS() << "Detaching object " << viewer_object->mID << " from " << attachment->getName() << LL_ENDL;
 			return TRUE;
 		}
 	}
@@ -5882,7 +5882,7 @@ void LLVOAvatar::onGlobalColorChanged(const LLTexGlobalColor* global_color, BOOL
 	} 
 	else if (global_color == mTexEyeColor)
 	{
-//		llinfos << "invalidateComposite cause: onGlobalColorChanged( eyecolor )" << llendl; 
+//		LL_INFOS() << "invalidateComposite cause: onGlobalColorChanged( eyecolor )" << LL_ENDL; 
 		invalidateComposite( mBakedTextureDatas[BAKED_EYES].mTexLayerSet,  upload_bake );
 	}
 	updateMeshTextures();
@@ -5980,11 +5980,11 @@ void LLVOAvatar::startPhase(const std::string& phase_name)
 	{
 		if (!completed)
 		{
-			LL_DEBUGS("Avatar") << avString() << "no-op, start when started already for " << phase_name << llendl;
+			LL_DEBUGS("Avatar") << avString() << "no-op, start when started already for " << phase_name << LL_ENDL;
 			return;
 		}
 	}
-	LL_DEBUGS("Avatar") << "started phase " << phase_name << llendl;
+	LL_DEBUGS("Avatar") << "started phase " << phase_name << LL_ENDL;
 	getPhases().startPhase(phase_name);
 }
 
@@ -5999,13 +5999,13 @@ void LLVOAvatar::stopPhase(const std::string& phase_name, bool err_check)
 			getPhases().stopPhase(phase_name);
 			completed = true;
 			logMetricsTimerRecord(phase_name, elapsed, completed);
-			LL_DEBUGS("Avatar") << avString() << "stopped phase " << phase_name << " elapsed " << elapsed << llendl;
+			LL_DEBUGS("Avatar") << avString() << "stopped phase " << phase_name << " elapsed " << elapsed << LL_ENDL;
 		}
 		else
 		{
 			if (err_check)
 			{
-				LL_DEBUGS("Avatar") << "no-op, stop when stopped already for " << phase_name << llendl;
+				LL_DEBUGS("Avatar") << "no-op, stop when stopped already for " << phase_name << LL_ENDL;
 			}
 		}
 	}
@@ -6013,7 +6013,7 @@ void LLVOAvatar::stopPhase(const std::string& phase_name, bool err_check)
 	{
 		if (err_check)
 		{
-			LL_DEBUGS("Avatar") << "no-op, stop when not started for " << phase_name << llendl;
+			LL_DEBUGS("Avatar") << "no-op, stop when not started for " << phase_name << LL_ENDL;
 		}
 	}
 }
@@ -6456,7 +6456,7 @@ void LLVOAvatar::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_com
 {
 	if (index >= BAKED_NUM_INDICES)
 	{
-		llwarns << "invalid baked texture index passed to applyMorphMask" << llendl;
+		LL_WARNS() << "invalid baked texture index passed to applyMorphMask" << LL_ENDL;
 		return;
 	}
 
@@ -6625,7 +6625,7 @@ LLBBox LLVOAvatar::getHUDBBox() const
 				const LLViewerObject* attached_object = (*attachment_iter);
 				if (attached_object == NULL)
 				{
-					llwarns << "HUD attached object is NULL!" << llendl;
+					LL_WARNS() << "HUD attached object is NULL!" << LL_ENDL;
 					continue;
 				}
 				// initialize bounding box to contain identity orientation and center point for attached object
@@ -6714,14 +6714,14 @@ bool LLVOAvatar::visualParamWeightsAreDefault()
 			    // we have to not care whether skirt weights are default, if we're not actually wearing a skirt
 			    (is_wearing_skirt || !is_skirt_param))
 			{
-				//llinfos << "param '" << param->getName() << "'=" << param->getWeight() << " which differs from default=" << param->getDefaultWeight() << llendl;
+				//LL_INFOS() << "param '" << param->getName() << "'=" << param->getWeight() << " which differs from default=" << param->getDefaultWeight() << LL_ENDL;
 				rtn = false;
 				break;
 			}
 		}
 	}
 
-	//llinfos << "params are default ? " << int(rtn) << llendl;
+	//LL_INFOS() << "params are default ? " << int(rtn) << LL_ENDL;
 
 	return rtn;
 }
@@ -6771,7 +6771,7 @@ void LLVOAvatar::dumpAppearanceMsgParams( const std::string& dump_prefix,
 	}
 	else
 	{
-		LL_DEBUGS("Avatar") << "dumping appearance message to " << fullpath << llendl;
+		LL_DEBUGS("Avatar") << "dumping appearance message to " << fullpath << LL_ENDL;
 	}
 
 	apr_file_printf(file, "<header>\n");
@@ -6814,7 +6814,7 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe
 		U8 av_u8;
 		mesgsys->getU8Fast(_PREHASH_AppearanceData, _PREHASH_AppearanceVersion, av_u8, 0);
 		contents.mAppearanceVersion = av_u8;
-		LL_DEBUGS("Avatar") << "appversion set by AppearanceData field: " << contents.mAppearanceVersion << llendl;
+		LL_DEBUGS("Avatar") << "appversion set by AppearanceData field: " << contents.mAppearanceVersion << LL_ENDL;
 		mesgsys->getS32Fast(_PREHASH_AppearanceData, _PREHASH_CofVersion, contents.mCOFVersion, 0);
 		// For future use:
 		//mesgsys->getU32Fast(_PREHASH_AppearanceData, _PREHASH_Flags, appearance_flags, 0);
@@ -6831,7 +6831,7 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe
 		llassert(param); // if this ever fires, we should do the same as when num_blocks<=1
 		if (!param)
 		{
-			llwarns << "No visual params!" << llendl;
+			LL_WARNS() << "No visual params!" << LL_ENDL;
 		}
 		else
 		{
@@ -6861,18 +6861,18 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe
 		const S32 expected_tweakable_count = getVisualParamCountInGroup(VISUAL_PARAM_GROUP_TWEAKABLE); // don't worry about VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT
 		if (num_blocks != expected_tweakable_count)
 		{
-			LL_DEBUGS("Avatar") << "Number of params in AvatarAppearance msg (" << num_blocks << ") does not match number of tweakable params in avatar xml file (" << expected_tweakable_count << ").  Processing what we can.  object: " << getID() << llendl;
+			LL_DEBUGS("Avatar") << "Number of params in AvatarAppearance msg (" << num_blocks << ") does not match number of tweakable params in avatar xml file (" << expected_tweakable_count << ").  Processing what we can.  object: " << getID() << LL_ENDL;
 		}
 	}
 	else
 	{
 		if (drop_visual_params_debug)
 		{
-			llinfos << "Debug-faked lack of parameters on AvatarAppearance for object: "  << getID() << llendl;
+			LL_INFOS() << "Debug-faked lack of parameters on AvatarAppearance for object: "  << getID() << LL_ENDL;
 		}
 		else
 		{
-			LL_DEBUGS("Avatar") << "AvatarAppearance msg received without any parameters, object: " << getID() << llendl;
+			LL_DEBUGS("Avatar") << "AvatarAppearance msg received without any parameters, object: " << getID() << LL_ENDL;
 		}
 	}
 
@@ -6884,7 +6884,7 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe
 		{
 			S32 index = it - contents.mParams.begin();
 			contents.mParamAppearanceVersion = llround(contents.mParamWeights[index]);
-			LL_DEBUGS("Avatar") << "appversion req by appearance_version param: " << contents.mParamAppearanceVersion << llendl;
+			LL_DEBUGS("Avatar") << "appversion req by appearance_version param: " << contents.mParamAppearanceVersion << LL_ENDL;
 		}
 	}
 }
@@ -6897,8 +6897,8 @@ bool resolve_appearance_version(const LLAppearanceMessageContents& contents, S32
 		(contents.mParamAppearanceVersion >= 0) &&
 		(contents.mAppearanceVersion != contents.mParamAppearanceVersion))
 	{
-		llwarns << "inconsistent appearance_version settings - field: " <<
-			contents.mAppearanceVersion << ", param: " <<  contents.mParamAppearanceVersion << llendl;
+		LL_WARNS() << "inconsistent appearance_version settings - field: " <<
+			contents.mAppearanceVersion << ", param: " <<  contents.mParamAppearanceVersion << LL_ENDL;
 		return false;
 	}
 	if (contents.mParamAppearanceVersion >= 0) // use visual param if available.
@@ -6915,7 +6915,7 @@ bool resolve_appearance_version(const LLAppearanceMessageContents& contents, S32
 	}
 	LL_DEBUGS("Avatar") << "appearance version info - field " << contents.mAppearanceVersion
 						<< " param: " << contents.mParamAppearanceVersion
-						<< " final: " << appearance_version << llendl;
+						<< " final: " << appearance_version << LL_ENDL;
 	return true;
 }
 
@@ -6924,13 +6924,13 @@ bool resolve_appearance_version(const LLAppearanceMessageContents& contents, S32
 //-----------------------------------------------------------------------------
 void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 {
-	LL_DEBUGS("Avatar") << "starts" << llendl;
+	LL_DEBUGS("Avatar") << "starts" << LL_ENDL;
 	
 	bool enable_verbose_dumps = gSavedSettings.getBOOL("DebugAvatarAppearanceMessage");
 	std::string dump_prefix = getFullname() + "_" + (isSelf()?"s":"o") + "_";
 	if (gSavedSettings.getBOOL("BlockAvatarAppearanceMessages"))
 	{
-		llwarns << "Blocking AvatarAppearance message" << llendl;
+		LL_WARNS() << "Blocking AvatarAppearance message" << LL_ENDL;
 		return;
 	}
 
@@ -6946,7 +6946,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 	S32 appearance_version;
 	if (!resolve_appearance_version(contents, appearance_version))
 	{
-		llwarns << "bad appearance version info, discarding" << llendl;
+		LL_WARNS() << "bad appearance version info, discarding" << LL_ENDL;
 		return;
 	}
 	S32 this_update_cof_version = contents.mCOFVersion;
@@ -6957,11 +6957,11 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 	{
 		LL_DEBUGS("Avatar") << "this_update_cof_version " << this_update_cof_version
 				<< " last_update_request_cof_version " << last_update_request_cof_version
-				<<  " my_cof_version " << LLAppearanceMgr::instance().getCOFVersion() << llendl;
+				<<  " my_cof_version " << LLAppearanceMgr::instance().getCOFVersion() << LL_ENDL;
 
 		if (getRegion() && (getRegion()->getCentralBakeVersion()==0))
 		{
-			llwarns << avString() << "Received AvatarAppearance message for self in non-server-bake region" << llendl;
+			LL_WARNS() << avString() << "Received AvatarAppearance message for self in non-server-bake region" << LL_ENDL;
 		}
 		if( mFirstTEMessageReceived && (appearance_version == 0))
 		{
@@ -6970,7 +6970,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 	}
 	else
 	{
-		LL_DEBUGS("Avatar") << "appearance message received" << llendl;
+		LL_DEBUGS("Avatar") << "appearance message received" << LL_ENDL;
 	}
 
 	// Check for stale update.
@@ -6978,14 +6978,14 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 		&& (appearance_version>0)
 		&& (this_update_cof_version < last_update_request_cof_version))
 	{
-		llwarns << "Stale appearance update, wanted version " << last_update_request_cof_version
-				<< ", got " << this_update_cof_version << llendl;
+		LL_WARNS() << "Stale appearance update, wanted version " << last_update_request_cof_version
+				<< ", got " << this_update_cof_version << LL_ENDL;
 		return;
 	}
 
 	if (isSelf() && isEditingAppearance())
 	{
-		LL_DEBUGS("Avatar") << "ignoring appearance message while in appearance edit" << llendl;
+		LL_DEBUGS("Avatar") << "ignoring appearance message while in appearance edit" << LL_ENDL;
 		return;
 	}
 
@@ -6996,7 +6996,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 		// appearance version, which may cause us to look for baked
 		// textures in the wrong place and flag them as missing
 		// assets.
-		LL_DEBUGS("Avatar") << "ignoring appearance message due to lack of params" << llendl;
+		LL_DEBUGS("Avatar") << "ignoring appearance message due to lack of params" << LL_ENDL;
 		return;
 	}
 
@@ -7064,7 +7064,7 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 		const S32 expected_tweakable_count = getVisualParamCountInGroup(VISUAL_PARAM_GROUP_TWEAKABLE); // don't worry about VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT
 		if (num_params != expected_tweakable_count)
 		{
-			LL_DEBUGS("Avatar") << "Number of params in AvatarAppearance msg (" << num_params << ") does not match number of tweakable params in avatar xml file (" << expected_tweakable_count << ").  Processing what we can.  object: " << getID() << llendl;
+			LL_DEBUGS("Avatar") << "Number of params in AvatarAppearance msg (" << num_params << ") does not match number of tweakable params in avatar xml file (" << expected_tweakable_count << ").  Processing what we can.  object: " << getID() << LL_ENDL;
 		}
 
 		if (params_changed)
@@ -7094,13 +7094,13 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys )
 		if (visualParamWeightsAreDefault() && mRuthTimer.getElapsedTimeF32() > LOADING_TIMEOUT_SECONDS)
 		{
 			// re-request appearance, hoping that it comes back with a shape next time
-			llinfos << "Re-requesting AvatarAppearance for object: "  << getID() << llendl;
+			LL_INFOS() << "Re-requesting AvatarAppearance for object: "  << getID() << LL_ENDL;
 			LLAvatarPropertiesProcessor::getInstance()->sendAvatarTexturesRequest(getID());
 			mRuthTimer.reset();
 		}
 		else
 		{
-			llinfos << "That's okay, we already have a non-default shape for object: "  << getID() << llendl;
+			LL_INFOS() << "That's okay, we already have a non-default shape for object: "  << getID() << LL_ENDL;
 			// we don't really care.
 		}
 	}
@@ -7154,7 +7154,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture
 {
 	if (!userdata) return;
 
-	//llinfos << "onBakedTextureMasksLoaded: " << src_vi->getID() << llendl;
+	//LL_INFOS() << "onBakedTextureMasksLoaded: " << src_vi->getID() << LL_ENDL;
 	const LLUUID id = src_vi->getID();
  
 	LLTextureMaskData* maskData = (LLTextureMaskData*) userdata;
@@ -7168,7 +7168,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture
 		{
 			if (!aux_src->getData())
 			{
-				llerrs << "No auxiliary source (morph mask) data for image id " << id << llendl;
+				LL_ERRS() << "No auxiliary source (morph mask) data for image id " << id << LL_ENDL;
 				return;
 			}
 
@@ -7189,7 +7189,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture
 
 			/* if( id == head_baked->getID() )
 			     if (self->mBakedTextureDatas[BAKED_HEAD].mTexLayerSet)
-				     //llinfos << "onBakedTextureMasksLoaded for head " << id << " discard = " << discard_level << llendl;
+				     //LL_INFOS() << "onBakedTextureMasksLoaded for head " << id << " discard = " << discard_level << LL_ENDL;
 					 self->mBakedTextureDatas[BAKED_HEAD].mTexLayerSet->applyMorphMask(aux_src->getData(), aux_src->getWidth(), aux_src->getHeight(), 1);
 					 maskData->mLastDiscardLevel = discard_level; */
 			BOOL found_texture_id = false;
@@ -7220,7 +7220,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture
 			}
 			if (!found_texture_id)
 			{
-				llinfos << "unexpected image id: " << id << llendl;
+				LL_INFOS() << "unexpected image id: " << id << LL_ENDL;
 			}
 			self->dirtyMesh();
 		}
@@ -7228,7 +7228,7 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture
 		{
             // this can happen when someone uses an old baked texture possibly provided by 
             // viewer-side baked texture caching
-			llwarns << "Masks loaded callback but NO aux source, id " << id << llendl;
+			LL_WARNS() << "Masks loaded callback but NO aux source, id " << id << LL_ENDL;
 		}
 	}
 
@@ -7308,7 +7308,7 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id )
 
 			if (isUsingLocalAppearance())
 			{
-				llinfos << "not changing to baked texture while isUsingLocalAppearance" << llendl;
+				LL_INFOS() << "not changing to baked texture while isUsingLocalAppearance" << LL_ENDL;
 			}
 			else
 			{
@@ -7401,7 +7401,7 @@ void LLVOAvatar::dumpArchetypeXML(const std::string& prefix, bool group_by_weara
 	}
 	else
 	{
-		llinfos << "xmlfile write handle obtained : " << fullpath << llendl;
+		LL_INFOS() << "xmlfile write handle obtained : " << fullpath << LL_ENDL;
 	}
 
 	apr_file_printf( file, "<?xml version=\"1.0\" encoding=\"US-ASCII\" standalone=\"yes\"?>\n" );
@@ -7540,7 +7540,7 @@ void LLVOAvatar::cullAvatarsByPixelArea()
 		if (inst->mCulled != culled)
 		{
 			inst->mCulled = culled;
-			lldebugs << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << llendl;
+			LL_DEBUGS() << "avatar " << inst->getID() << (culled ? " start culled" : " start not culled" ) << LL_ENDL;
 			inst->updateMeshTextures();
 		}
 
@@ -7604,7 +7604,7 @@ BOOL LLVOAvatar::isUsingServerBakes() const
 	F32 expect_wt = mUseServerBakes ? 1.0 : 0.0;
 	if (!is_approx_equal(wt,expect_wt))
 	{
-		llwarns << "wt " << wt << " differs from expected " << expect_wt << llendl;
+		LL_WARNS() << "wt " << wt << " differs from expected " << expect_wt << LL_ENDL;
 	}
 #endif
 
@@ -7871,7 +7871,7 @@ void LLVOAvatar::idleUpdateRenderCost()
 			if (all_textures.find(image_id) == all_textures.end())
 			{
 				// attachment texture not previously seen.
-				llinfos << "attachment_texture: " << image_id.asString() << llendl;
+				LL_INFOS() << "attachment_texture: " << image_id.asString() << LL_ENDL;
 				all_textures.insert(image_id);
 			}
 		}
@@ -7891,7 +7891,7 @@ void LLVOAvatar::idleUpdateRenderCost()
 				continue;
 			if (all_textures.find(image_id) == all_textures.end())
 			{
-				llinfos << "local_texture: " << texture_dict->mName << ": " << image_id << llendl;
+				LL_INFOS() << "local_texture: " << texture_dict->mName << ": " << image_id << LL_ENDL;
 				all_textures.insert(image_id);
 			}
 		}
@@ -7970,7 +7970,7 @@ BOOL LLVOAvatar::isTextureDefined(LLAvatarAppearanceDefines::ETextureIndex te, U
 
 	if( !getImage( te, index ) )
 	{
-		llwarns << "getImage( " << te << ", " << index << " ) returned 0" << llendl;
+		LL_WARNS() << "getImage( " << te << ", " << index << " ) returned 0" << LL_ENDL;
 		return FALSE;
 	}
 
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 117169678e..12b9744b24 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -165,7 +165,7 @@ LLVOAvatarSelf::LLVOAvatarSelf(const LLUUID& id,
 
 	mMotionController.mIsSelf = TRUE;
 
-	lldebugs << "Marking avatar as self " << id << llendl;
+	LL_DEBUGS() << "Marking avatar as self " << id << LL_ENDL;
 }
 
 // Called periodically for diagnostics, return true when done.
@@ -206,7 +206,7 @@ void LLVOAvatarSelf::initInstance()
 	// adds attachment points to mScreen among other things
 	LLVOAvatar::initInstance();
 
-	llinfos << "Self avatar object created. Starting timer." << llendl;
+	LL_INFOS() << "Self avatar object created. Starting timer." << LL_ENDL;
 	mDebugSelfLoadTimer.reset();
 	// clear all times to -1 for debugging
 	for (U32 i =0; i < LLAvatarAppearanceDefines::TEX_NUM_INDICES; ++i)
@@ -227,7 +227,7 @@ void LLVOAvatarSelf::initInstance()
 	status &= buildMenus();
 	if (!status)
 	{
-		llerrs << "Unable to load user's avatar" << llendl;
+		LL_ERRS() << "Unable to load user's avatar" << LL_ENDL;
 		return;
 	}
 
@@ -271,7 +271,7 @@ BOOL LLVOAvatarSelf::loadAvatarSelf()
 	// avatar_skeleton.xml
 	if (!buildSkeletonSelf(sAvatarSkeletonInfo))
 	{
-		llwarns << "avatar file: buildSkeleton() failed" << llendl;
+		LL_WARNS() << "avatar file: buildSkeleton() failed" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -889,9 +889,9 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 
 		// Diagnostic info
 		//LLVector3d pos_from_new_region = getPositionGlobal();
-		//llinfos << "pos_from_old_region is " << global_pos_from_old_region
+		//LL_INFOS() << "pos_from_old_region is " << global_pos_from_old_region
 		//	<< " while pos_from_new_region is " << pos_from_new_region
-		//	<< llendl;
+		//	<< LL_ENDL;
 	}
 
 	if (!regionp || (regionp->getHandle() != mLastRegionHandle))
@@ -903,7 +903,7 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 			record(LLStatViewer::REGION_CROSSING_TIME, delta);
 
 			// Diagnostics
-			llinfos << "Region crossing took " << (F32)(delta * 1000.0).value() << " ms " << llendl;
+			LL_INFOS() << "Region crossing took " << (F32)(delta * 1000.0).value() << " ms " << LL_ENDL;
 		}
 		if (regionp)
 		{
@@ -987,7 +987,7 @@ void LLVOAvatarSelf::idleUpdateTractorBeam()
 // virtual
 void LLVOAvatarSelf::restoreMeshData()
 {
-	//llinfos << "Restoring" << llendl;
+	//LL_INFOS() << "Restoring" << LL_ENDL;
 	mMeshValid = TRUE;
 	updateJointLODs();
 	updateAttachmentVisibility(gAgentCamera.getCameraMode());
@@ -1227,7 +1227,7 @@ BOOL LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object)
 		// Update COF contents, don't trigger appearance update.
 		if (!isValid())
 		{
-			llinfos << "removeItemLinks skipped, avatar is under destruction" << llendl;
+			LL_INFOS() << "removeItemLinks skipped, avatar is under destruction" << LL_ENDL;
 		}
 		else
 		{
@@ -1601,7 +1601,7 @@ void LLVOAvatarSelf::invalidateComposite( LLTexLayerSet* layerset, BOOL upload_r
 	{
 		return;
 	}
-	// llinfos << "LLVOAvatar::invalidComposite() " << layerset->getBodyRegionName() << llendl;
+	// LL_INFOS() << "LLVOAvatar::invalidComposite() " << layerset->getBodyRegionName() << LL_ENDL;
 
 	layer_set->requestUpdate();
 	layer_set->invalidateMorphMasks();
@@ -1754,7 +1754,7 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
 	{
 		if (type >= TEX_NUM_INDICES)
 		{
-			llerrs << "Tried to set local texture with invalid type: (" << (U32) type << ", " << index << ")" << llendl;
+			LL_ERRS() << "Tried to set local texture with invalid type: (" << (U32) type << ", " << index << ")" << LL_ENDL;
 			return;
 		}
 		LLWearableType::EType wearable_type = LLAvatarAppearanceDictionary::getInstance()->getTEWearableType(type);
@@ -1767,7 +1767,7 @@ void LLVOAvatarSelf::setLocalTexture(ETextureIndex type, LLViewerTexture* src_te
 		local_tex_obj = getLocalTextureObject(type,index);
 		if (!local_tex_obj)
 		{
-			llerrs << "Unable to create LocalTextureObject for wearable type & index: (" << (U32) wearable_type << ", " << index << ")" << llendl;
+			LL_ERRS() << "Unable to create LocalTextureObject for wearable type & index: (" << (U32) wearable_type << ", " << index << ")" << LL_ENDL;
 			return;
 		}
 		
@@ -1829,7 +1829,7 @@ void LLVOAvatarSelf::setBakedReady(LLAvatarAppearanceDefines::ETextureIndex type
 // virtual
 void LLVOAvatarSelf::dumpLocalTextures() const
 {
-	llinfos << "Local Textures:" << llendl;
+	LL_INFOS() << "Local Textures:" << LL_ENDL;
 
 	/* ETextureIndex baked_equiv[] = {
 	   TEX_UPPER_BAKED,
@@ -1853,22 +1853,22 @@ void LLVOAvatarSelf::dumpLocalTextures() const
 #if LL_RELEASE_FOR_DOWNLOAD
 			// End users don't get to trivially see avatar texture IDs, makes textures
 			// easier to steal. JC
-			llinfos << "LocTex " << name << ": Baked " << llendl;
+			LL_INFOS() << "LocTex " << name << ": Baked " << LL_ENDL;
 #else
-			llinfos << "LocTex " << name << ": Baked " << getTEImage(baked_equiv)->getID() << llendl;
+			LL_INFOS() << "LocTex " << name << ": Baked " << getTEImage(baked_equiv)->getID() << LL_ENDL;
 #endif
 		}
 		else if (local_tex_obj && local_tex_obj->getImage() != NULL)
 		{
 			if (local_tex_obj->getImage()->getID() == IMG_DEFAULT_AVATAR)
 			{
-				llinfos << "LocTex " << name << ": None" << llendl;
+				LL_INFOS() << "LocTex " << name << ": None" << LL_ENDL;
 			}
 			else
 			{
 				const LLViewerFetchedTexture* image = dynamic_cast<LLViewerFetchedTexture*>( local_tex_obj->getImage() );
 
-				llinfos << "LocTex " << name << ": "
+				LL_INFOS() << "LocTex " << name << ": "
 						<< "Discard " << image->getDiscardLevel() << ", "
 						<< "(" << image->getWidth() << ", " << image->getHeight() << ") " 
 #if !LL_RELEASE_FOR_DOWNLOAD
@@ -1877,12 +1877,12 @@ void LLVOAvatarSelf::dumpLocalTextures() const
 						<< image->getID() << " "
 #endif
 						<< "Priority: " << image->getDecodePriority()
-						<< llendl;
+						<< LL_ENDL;
 			}
 		}
 		else
 		{
-			llinfos << "LocTex " << name << ": No LLViewerTexture" << llendl;
+			LL_INFOS() << "LocTex " << name << ": No LLViewerTexture" << LL_ENDL;
 		}
 	}
 }
@@ -1938,7 +1938,7 @@ void LLVOAvatarSelf::dumpTotalLocalTextureByteCount()
 {
 	S32 gl_bytes = 0;
 	gAgentAvatarp->getLocalTextureByteCount(&gl_bytes);
-	llinfos << "Total Avatar LocTex GL:" << (gl_bytes/1024) << "KB" << llendl;
+	LL_INFOS() << "Total Avatar LocTex GL:" << (gl_bytes/1024) << "KB" << LL_ENDL;
 }
 
 BOOL LLVOAvatarSelf::getIsCloud() const
@@ -1962,12 +1962,12 @@ BOOL LLVOAvatarSelf::getIsCloud() const
 	{
 		if (do_warn)
 		{
-			llinfos << "Self is clouded due to missing one or more required body parts: "
+			LL_INFOS() << "Self is clouded due to missing one or more required body parts: "
 					<< (shape_count ? "" : "SHAPE ")
 					<< (hair_count ? "" : "HAIR ")
 					<< (eye_count ? "" : "EYES ")
 					<< (skin_count ? "" : "SKIN ")
-					<< llendl;
+					<< LL_ENDL;
 		}
 		return TRUE;
 	}
@@ -1976,7 +1976,7 @@ BOOL LLVOAvatarSelf::getIsCloud() const
 	{
 		if (do_warn)
 		{
-			llinfos << "Self is clouded because of no hair texture" << llendl;
+			LL_INFOS() << "Self is clouded because of no hair texture" << LL_ENDL;
 		}
 		return TRUE;
 	}
@@ -1988,7 +1988,7 @@ BOOL LLVOAvatarSelf::getIsCloud() const
 		{
 			if (do_warn)
 			{
-				llinfos << "Self is clouded because lower textures not baked" << llendl;
+				LL_INFOS() << "Self is clouded because lower textures not baked" << LL_ENDL;
 			}
 			return TRUE;
 		}
@@ -1998,7 +1998,7 @@ BOOL LLVOAvatarSelf::getIsCloud() const
 		{
 			if (do_warn)
 			{
-				llinfos << "Self is clouded because upper textures not baked" << llendl;
+				LL_INFOS() << "Self is clouded because upper textures not baked" << LL_ENDL;
 			}
 			return TRUE;
 		}
@@ -2018,14 +2018,14 @@ BOOL LLVOAvatarSelf::getIsCloud() const
 			{
 				if (do_warn)
 				{
-					llinfos << "Self is clouded because texture at index " << i
-							<< " (texture index is " << texture_data.mTextureIndex << ") is not loaded" << llendl;
+					LL_INFOS() << "Self is clouded because texture at index " << i
+							<< " (texture index is " << texture_data.mTextureIndex << ") is not loaded" << LL_ENDL;
 				}
 				return TRUE;
 			}
 		}
 
-		lldebugs << "Avatar de-clouded" << llendl;
+		LL_DEBUGS() << "Avatar de-clouded" << LL_ENDL;
 	}
 	return FALSE;
 }
@@ -2146,7 +2146,7 @@ void LLVOAvatarSelf::dumpAllTextures() const
 		if (!layerset_buffer) continue;
 		vd_text += verboseDebugDumpLocalTextureDataInfo(layerset);
 	}
-	LL_DEBUGS("Avatar") << vd_text << llendl;
+	LL_DEBUGS("Avatar") << vd_text << LL_ENDL;
 }
 
 const std::string LLVOAvatarSelf::debugDumpLocalTextureDataInfo(const LLViewerTexLayerSet* layerset) const
@@ -2433,7 +2433,7 @@ public:
 
 	/* virtual */ void result(const LLSD& content)
 	{
-		LL_DEBUGS("Avatar") << "status OK" << llendl;
+		LL_DEBUGS("Avatar") << "status OK" << LL_ENDL;
 	}
 
 	// Error
@@ -2442,7 +2442,7 @@ public:
 		if (isAgentAvatarValid())
 		{
 			LL_DEBUGS("Avatar") << "failed, will rebake [status:"
-					<< status << "]: " << content << llendl;
+					<< status << "]: " << content << LL_ENDL;
 			forceAppearanceUpdate();
 		}
 	}	
@@ -2501,7 +2501,7 @@ BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const
 	// Check if the texture hasn't been baked yet.
 	if (!isTextureDefined(tex_index, 0))
 	{
-		lldebugs << "getTEImage( " << (U32) tex_index << " )->getID() == IMG_DEFAULT_AVATAR" << llendl;
+		LL_DEBUGS() << "getTEImage( " << (U32) tex_index << " )->getID() == IMG_DEFAULT_AVATAR" << LL_ENDL;
 		return FALSE;
 	}
 
@@ -2520,7 +2520,7 @@ BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const
 		const ETextureIndex t_index = (*iter);
 		LLWearableType::EType wearable_type = LLAvatarAppearanceDictionary::getTEWearableType(t_index);
 		U32 count = gAgentWearables.getWearableCount(wearable_type);
-		lldebugs << "Checking index " << (U32) t_index << " count: " << count << llendl;
+		LL_DEBUGS() << "Checking index " << (U32) t_index << " count: " << count << LL_ENDL;
 		
 		for (U32 wearable_index = 0; wearable_index < count; ++wearable_index)
 		{
@@ -2542,7 +2542,7 @@ BOOL LLVOAvatarSelf::canGrabBakedTexture(EBakedTextureIndex baked_index) const
 													asset_id_matches);
 
 					BOOL can_grab = FALSE;
-					lldebugs << "item count for asset " << texture_id << ": " << items.size() << llendl;
+					LL_DEBUGS() << "item count for asset " << texture_id << ": " << items.size() << LL_ENDL;
 					if (items.size())
 					{
 						// search for full permissions version
@@ -2657,16 +2657,16 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid )
 
 	/* switch(te)
 		case TEX_HEAD_BAKED:
-			llinfos << "New baked texture: HEAD" << llendl; */
+			LL_INFOS() << "New baked texture: HEAD" << LL_ENDL; */
 	const LLAvatarAppearanceDictionary::TextureEntry *texture_dict = LLAvatarAppearanceDictionary::getInstance()->getTexture(te);
 	if (texture_dict->mIsBakedTexture)
 	{
 		debugBakedTextureUpload(texture_dict->mBakedTextureIndex, TRUE); // FALSE for start of upload, TRUE for finish.
-		llinfos << "New baked texture: " << texture_dict->mName << " UUID: " << uuid <<llendl;
+		LL_INFOS() << "New baked texture: " << texture_dict->mName << " UUID: " << uuid <<LL_ENDL;
 	}
 	else
 	{
-		llwarns << "New baked texture: unknown te " << te << llendl;
+		LL_WARNS() << "New baked texture: unknown te " << te << LL_ENDL;
 	}
 	
 	//	dumpAvatarTEs( "setNewBakedTexture() send" );
@@ -2689,7 +2689,7 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid )
 						<< "RuthTimer " << (U32)mRuthDebugTimer.getElapsedTimeF32()
 						<< " SelfLoadTimer " << (U32)mDebugSelfLoadTimer.getElapsedTimeF32()
 						<< " Notification " << "AvatarRezSelfBakedDoneNotification"
-						<< llendl;
+						<< LL_ENDL;
 			}
 			else
 			{
@@ -2701,7 +2701,7 @@ void LLVOAvatarSelf::setNewBakedTexture( ETextureIndex te, const LLUUID& uuid )
 						<< "RuthTimer " << (U32)mRuthDebugTimer.getElapsedTimeF32()
 						<< " SelfLoadTimer " << (U32)mDebugSelfLoadTimer.getElapsedTimeF32()
 						<< " Notification " << "AvatarRezSelfBakedUpdateNotification"
-						<< llendl;
+						<< LL_ENDL;
 			}
 		}
 
@@ -2718,11 +2718,11 @@ void LLVOAvatarSelf::outputRezDiagnostics() const
 	}
 
 	const F32 final_time = mDebugSelfLoadTimer.getElapsedTimeF32();
-	LL_DEBUGS("Avatar") << "REZTIME: Myself rez stats:" << llendl;
-	LL_DEBUGS("Avatar") << "\t Time from avatar creation to load wearables: " << (S32)mDebugTimeWearablesLoaded << llendl;
-	LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud: " << (S32)mDebugTimeAvatarVisible << llendl;
-	LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud for others: " << (S32)final_time << llendl;
-	LL_DEBUGS("Avatar") << "\t Load time for each texture: " << llendl;
+	LL_DEBUGS("Avatar") << "REZTIME: Myself rez stats:" << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Time from avatar creation to load wearables: " << (S32)mDebugTimeWearablesLoaded << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud: " << (S32)mDebugTimeAvatarVisible << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Time from avatar creation to de-cloud for others: " << (S32)final_time << LL_ENDL;
+	LL_DEBUGS("Avatar") << "\t Load time for each texture: " << LL_ENDL;
 	for (U32 i = 0; i < LLAvatarAppearanceDefines::TEX_NUM_INDICES; ++i)
 	{
 		std::stringstream out;
@@ -2750,10 +2750,10 @@ void LLVOAvatarSelf::outputRezDiagnostics() const
 			LL_DEBUGS("Avatar") << out.str() << LL_ENDL;
 		}
 	}
-	LL_DEBUGS("Avatar") << "\t Time points for each upload (start / finish)" << llendl;
+	LL_DEBUGS("Avatar") << "\t Time points for each upload (start / finish)" << LL_ENDL;
 	for (U32 i = 0; i < LLAvatarAppearanceDefines::BAKED_NUM_INDICES; ++i)
 	{
-		LL_DEBUGS("Avatar") << "\t\t (" << i << ") \t" << (S32)mDebugBakedTextureTimes[i][0] << " / " << (S32)mDebugBakedTextureTimes[i][1] << llendl;
+		LL_DEBUGS("Avatar") << "\t\t (" << i << ") \t" << (S32)mDebugBakedTextureTimes[i][0] << " / " << (S32)mDebugBakedTextureTimes[i][1] << LL_ENDL;
 	}
 
 	for (LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::BakedTextures::const_iterator baked_iter = LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::getInstance()->getBakedTextures().begin();
@@ -2765,7 +2765,7 @@ void LLVOAvatarSelf::outputRezDiagnostics() const
 		if (!layerset) continue;
 		const LLViewerTexLayerSetBuffer *layerset_buffer = layerset->getViewerComposite();
 		if (!layerset_buffer) continue;
-		LL_DEBUGS("Avatar") << layerset_buffer->dumpTextureInfo() << llendl;
+		LL_DEBUGS("Avatar") << layerset_buffer->dumpTextureInfo() << LL_ENDL;
 	}
 
 	dumpAllTextures();
@@ -2805,11 +2805,11 @@ void LLVOAvatarSelf::setCachedBakedTexture( ETextureIndex te, const LLUUID& uuid
 			{
 				if (mInitialBakeIDs[i] == uuid)
 				{
-					llinfos << "baked texture correctly loaded at login! " << i << llendl;
+					LL_INFOS() << "baked texture correctly loaded at login! " << i << LL_ENDL;
 				}
 				else
 				{
-					llwarns << "baked texture does not match id loaded at login!" << i << llendl;
+					LL_WARNS() << "baked texture does not match id loaded at login!" << i << LL_ENDL;
 				}
 				mInitialBakeIDs[i] = LLUUID::null;
 			}
@@ -2845,7 +2845,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
 				LLViewerTexLayerSet* layer_set = gAgentAvatarp->getLayerSet(index);
 				if (layer_set)
 				{
-					llinfos << "TAT: rebake - matched entry " << (S32)index << llendl;
+					LL_INFOS() << "TAT: rebake - matched entry " << (S32)index << LL_ENDL;
 					gAgentAvatarp->invalidateComposite(layer_set, TRUE);
 					found = TRUE;
 					add(LLStatViewer::TEX_REBAKES, 1);
@@ -2869,7 +2869,7 @@ void LLVOAvatarSelf::processRebakeAvatarTextures(LLMessageSystem* msg, void**)
 
 void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug)
 {
-	llinfos << "TAT: forced full rebake. " << llendl;
+	LL_INFOS() << "TAT: forced full rebake. " << LL_ENDL;
 
 	for (U32 i = 0; i < mBakedTextureDatas.size(); i++)
 	{
@@ -2888,7 +2888,7 @@ void LLVOAvatarSelf::forceBakeAllTextures(bool slam_for_debug)
 		}
 		else
 		{
-			llwarns << "TAT: NO LAYER SET FOR " << (S32)baked_index << llendl;
+			LL_WARNS() << "TAT: NO LAYER SET FOR " << (S32)baked_index << LL_ENDL;
 		}
 	}
 
@@ -3069,7 +3069,7 @@ void LLVOAvatarSelf::deleteScratchTextures()
 
 	if( sScratchTexBytes )
 	{
-		lldebugs << "Clearing Scratch Textures " << (sScratchTexBytes/1024) << "KB" << llendl;
+		LL_DEBUGS() << "Clearing Scratch Textures " << (sScratchTexBytes/1024) << "KB" << LL_ENDL;
 
 		delete_and_clear(sScratchTexNames);
 		LLImageGL::sGlobalTextureMemory -= sScratchTexBytes;
@@ -3080,7 +3080,7 @@ void LLVOAvatarSelf::deleteScratchTextures()
 // static 
 void LLVOAvatarSelf::dumpScratchTextureByteCount()
 {
-	llinfos << "Scratch Texture GL: " << (sScratchTexBytes/1024) << "KB" << llendl;
+	LL_INFOS() << "Scratch Texture GL: " << (sScratchTexBytes/1024) << "KB" << LL_ENDL;
 }
 
 void LLVOAvatarSelf::dumpWearableInfo(LLAPRFile& outfile)
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index d1c27edce7..98a924b3be 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -138,7 +138,7 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 			// We've got a bogus size, skip reading it.
 			// We won't bother seeking, because the rest of this file
 			// is likely bogus, and will be tossed anyway.
-			llwarns << "Bogus cache entry, size " << size << ", aborting!" << llendl;
+			LL_WARNS() << "Bogus cache entry, size " << size << ", aborting!" << LL_ENDL;
 			success = FALSE;
 		}
 	}
@@ -268,7 +268,7 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc)
 	if (  (mCRC != crc)
 		||(mDP.getBufferSize() == 0))
 	{
-		//llinfos << "Not getting cache entry, invalid!" << llendl;
+		//LL_INFOS() << "Not getting cache entry, invalid!" << LL_ENDL;
 		return NULL;
 	}
 	mHitCount++;
@@ -279,7 +279,7 @@ LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP()
 {
 	if (mDP.getBufferSize() == 0)
 	{
-		//llinfos << "Not getting cache entry, invalid!" << llendl;
+		//LL_INFOS() << "Not getting cache entry, invalid!" << LL_ENDL;
 		return NULL;
 	}
 	
@@ -295,12 +295,12 @@ void LLVOCacheEntry::recordHit()
 
 void LLVOCacheEntry::dump() const
 {
-	llinfos << "local " << mLocalID
+	LL_INFOS() << "local " << mLocalID
 		<< " crc " << mCRC
 		<< " hits " << mHitCount
 		<< " dupes " << mDupeCount
 		<< " change " << mCRCChangeCount
-		<< llendl;
+		<< LL_ENDL;
 }
 
 BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
@@ -640,13 +640,13 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version)
 {
 	if(!mEnabled)
 	{
-		llwarns << "Not initializing cache: Cache is currently disabled." << llendl;
+		LL_WARNS() << "Not initializing cache: Cache is currently disabled." << LL_ENDL;
 		return ;
 	}
 
 	if(mInitialized)
 	{
-		llwarns << "Cache already initialized." << llendl;
+		LL_WARNS() << "Cache already initialized." << LL_ENDL;
 		return ;
 	}
 	mInitialized = true;
@@ -684,15 +684,15 @@ void LLVOCache::removeCache(ELLPath location, bool started)
 
 	if(mReadOnly)
 	{
-		llwarns << "Not removing cache at " << location << ": Cache is currently in read-only mode." << llendl;
+		LL_WARNS() << "Not removing cache at " << location << ": Cache is currently in read-only mode." << LL_ENDL;
 		return ;
 	}	
 
-	llinfos << "about to remove the object cache due to settings." << llendl ;
+	LL_INFOS() << "about to remove the object cache due to settings." << LL_ENDL ;
 
 	std::string mask = "*";
 	std::string cache_dir = gDirUtilp->getExpandedFilename(location, object_cache_dirname);
-	llinfos << "Removing cache at " << cache_dir << llendl;
+	LL_INFOS() << "Removing cache at " << cache_dir << LL_ENDL;
 	gDirUtilp->deleteFilesInDir(cache_dir, mask); //delete all files
 	LLFile::rmdir(cache_dir);
 
@@ -705,17 +705,17 @@ void LLVOCache::removeCache()
 	if(!mInitialized)
 	{
 		//OK to remove cache even it is not initialized.
-		llwarns << "Object cache is not initialized yet." << llendl;
+		LL_WARNS() << "Object cache is not initialized yet." << LL_ENDL;
 	}
 
 	if(mReadOnly)
 	{
-		llwarns << "Not clearing object cache: Cache is currently in read-only mode." << llendl;
+		LL_WARNS() << "Not clearing object cache: Cache is currently in read-only mode." << LL_ENDL;
 		return ;
 	}
 
 	std::string mask = "*";
-	llinfos << "Removing object cache at " << mObjectCacheDirName << llendl;
+	LL_INFOS() << "Removing object cache at " << mObjectCacheDirName << LL_ENDL;
 	gDirUtilp->deleteFilesInDir(mObjectCacheDirName, mask); 
 
 	clearCacheInMemory() ;
@@ -787,7 +787,7 @@ void LLVOCache::removeFromCache(HeaderEntryInfo* entry)
 {
 	if(mReadOnly)
 	{
-		llwarns << "Not removing cache for handle " << entry->mHandle << ": Cache is currently in read-only mode." << llendl;
+		LL_WARNS() << "Not removing cache for handle " << entry->mHandle << ": Cache is currently in read-only mode." << LL_ENDL;
 		return ;
 	}
 
@@ -802,7 +802,7 @@ void LLVOCache::readCacheHeader()
 {
 	if(!mEnabled)
 	{
-		llwarns << "Not reading cache header: Cache is currently disabled." << llendl;
+		LL_WARNS() << "Not reading cache header: Cache is currently disabled." << LL_ENDL;
 		return;
 	}
 
@@ -832,7 +832,7 @@ void LLVOCache::readCacheHeader()
 								
 				if(!success) //failed
 				{
-					llwarns << "Error reading cache header entry. (entry_index=" << mNumEntries << ")" << llendl;
+					LL_WARNS() << "Error reading cache header entry. (entry_index=" << mNumEntries << ")" << LL_ENDL;
 					delete entry ;
 					entry = NULL ;
 					break ;
@@ -860,7 +860,7 @@ void LLVOCache::readCacheHeader()
 		//for(header_entry_queue_t::iterator iter = mHeaderEntryQueue.begin() ; success && iter != mHeaderEntryQueue.end(); ++iter)
 		//{
 		//	getObjectCacheFilename((*iter)->mHandle, name) ;
-		//	llinfos << name << llendl ;
+		//	LL_INFOS() << name << LL_ENDL ;
 		//}
 		//-----------
 	}
@@ -885,13 +885,13 @@ void LLVOCache::writeCacheHeader()
 {
 	if (!mEnabled)
 	{
-		llwarns << "Not writing cache header: Cache is currently disabled." << llendl;
+		LL_WARNS() << "Not writing cache header: Cache is currently disabled." << LL_ENDL;
 		return;
 	}
 
 	if(mReadOnly)
 	{
-		llwarns << "Not writing cache header: Cache is currently in read-only mode." << llendl;
+		LL_WARNS() << "Not writing cache header: Cache is currently in read-only mode." << LL_ENDL;
 		return;
 	}
 
@@ -945,7 +945,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 {
 	if(!mEnabled)
 	{
-		llwarns << "Not reading cache for handle " << handle << "): Cache is currently disabled." << llendl;
+		LL_WARNS() << "Not reading cache for handle " << handle << "): Cache is currently disabled." << LL_ENDL;
 		return ;
 	}
 	llassert_always(mInitialized);
@@ -953,7 +953,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 	handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ;
 	if(iter == mHandleEntryMap.end()) //no cache
 	{
-		llwarns << "No handle map entry for " << handle << llendl;
+		LL_WARNS() << "No handle map entry for " << handle << LL_ENDL;
 		return ;
 	}
 
@@ -970,7 +970,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 		{		
 			if(cache_id != id)
 			{
-				llinfos << "Cache ID doesn't match for this region, discarding"<< llendl;
+				LL_INFOS() << "Cache ID doesn't match for this region, discarding"<< LL_ENDL;
 				success = false ;
 			}
 
@@ -986,7 +986,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 						LLPointer<LLVOCacheEntry> entry = new LLVOCacheEntry(&apr_file);
 						if (!entry->getLocalID())
 						{
-							llwarns << "Aborting cache file load for " << filename << ", cache file corruption!" << llendl;
+							LL_WARNS() << "Aborting cache file load for " << filename << ", cache file corruption!" << LL_ENDL;
 							success = false ;
 							break ;
 						}
@@ -1026,14 +1026,14 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 {
 	if(!mEnabled)
 	{
-		llwarns << "Not writing cache for handle " << handle << "): Cache is currently disabled." << llendl;
+		LL_WARNS() << "Not writing cache for handle " << handle << "): Cache is currently disabled." << LL_ENDL;
 		return ;
 	}
 	llassert_always(mInitialized);
 
 	if(mReadOnly)
 	{
-		llwarns << "Not writing cache for handle " << handle << "): Cache is currently in read-only mode." << llendl;
+		LL_WARNS() << "Not writing cache for handle " << handle << "): Cache is currently in read-only mode." << LL_ENDL;
 		return ;
 	}	
 
@@ -1068,13 +1068,13 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 	//update cache header
 	if(!updateEntry(entry))
 	{
-		llwarns << "Failed to update cache header index " << entry->mIndex << ". handle = " << handle << llendl;
+		LL_WARNS() << "Failed to update cache header index " << entry->mIndex << ". handle = " << handle << LL_ENDL;
 		return ; //update failed.
 	}
 
 	if(!dirty_cache)
 	{
-		llwarns << "Skipping write to cache for handle " << handle << ": cache not dirty" << llendl;
+		LL_WARNS() << "Skipping write to cache for handle " << handle << ": cache not dirty" << LL_ENDL;
 		return ; //nothing changed, no need to update.
 	}
 
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 62fe6e7b12..a60d8a2284 100755
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -97,7 +97,7 @@ void LLVOGrass::updateSpecies()
 	
 	if (!sSpeciesTable.count(mSpecies))
 	{
-		llinfos << "Unknown grass type, substituting grass type." << llendl;
+		LL_INFOS() << "Unknown grass type, substituting grass type." << LL_ENDL;
 		SpeciesMap::const_iterator it = sSpeciesTable.begin();
 		mSpecies = (*it).first;
 	}
@@ -119,7 +119,7 @@ void LLVOGrass::initClass()
 
 	if (!grass_def_grass.parseFile(xml_filename))
 	{
-		llerrs << "Failed to parse grass file." << llendl;
+		LL_ERRS() << "Failed to parse grass file." << LL_ENDL;
 		return;
 	}
 
@@ -131,7 +131,7 @@ void LLVOGrass::initClass()
 	{
 		if (!grass_def->hasName("grass"))
 		{
-			llwarns << "Invalid grass definition node " << grass_def->getName() << llendl;
+			LL_WARNS() << "Invalid grass definition node " << grass_def->getName() << LL_ENDL;
 			continue;
 		}
 		F32 F32_val;
@@ -143,13 +143,13 @@ void LLVOGrass::initClass()
 		static LLStdStringHandle species_id_string = LLXmlTree::addAttributeString("species_id");
 		if (!grass_def->getFastAttributeS32(species_id_string, species))
 		{
-			llwarns << "No species id defined" << llendl;
+			LL_WARNS() << "No species id defined" << LL_ENDL;
 			continue;
 		}
 
 		if (species < 0)
 		{
-			llwarns << "Invalid species id " << species << llendl;
+			LL_WARNS() << "Invalid species id " << species << LL_ENDL;
 			continue;
 		}
 
@@ -170,7 +170,7 @@ void LLVOGrass::initClass()
 
 		if (sSpeciesTable.count(species))
 		{
-			llinfos << "Grass species " << species << " already defined! Duplicate discarded." << llendl;
+			LL_INFOS() << "Grass species " << species << " already defined! Duplicate discarded." << LL_ENDL;
 			delete newGrass;
 			continue;
 		}
@@ -186,7 +186,7 @@ void LLVOGrass::initClass()
 			std::string name;
 			static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
 			grass_def->getFastAttributeString(name_string, name);
-			llwarns << "Incomplete definition of grass " << name << llendl;
+			LL_WARNS() << "Incomplete definition of grass " << name << LL_ENDL;
 		}
 	}
 
@@ -257,7 +257,7 @@ U32 LLVOGrass::processUpdateMessage(LLMessageSystem *mesgsys,
 		||(getAcceleration().lengthSquared() > 0.f)
 		||(getAngularVelocity().lengthSquared() > 0.f))
 	{
-		llinfos << "ACK! Moving grass!" << llendl;
+		LL_INFOS() << "ACK! Moving grass!" << LL_ENDL;
 		setVelocity(LLVector3::zero);
 		setAcceleration(LLVector3::zero);
 		setAngularVelocity(LLVector3::zero);
@@ -444,7 +444,7 @@ void LLVOGrass::plantBlades()
 	// This is bad, but not the end of the world.
 	if (!sSpeciesTable.count(mSpecies))
 	{
-		llinfos << "Unknown grass species " << mSpecies << llendl;
+		LL_INFOS() << "Unknown grass species " << mSpecies << LL_ENDL;
 		return;
 	}
 	
diff --git a/indra/newview/llvoicevisualizer.cpp b/indra/newview/llvoicevisualizer.cpp
index 9281334d81..23a8a61b85 100755
--- a/indra/newview/llvoicevisualizer.cpp
+++ b/indra/newview/llvoicevisualizer.cpp
@@ -310,7 +310,7 @@ void LLVoiceVisualizer::lipSyncOohAah( F32& ooh, F32& aah )
 		aah = transfer_aah * sAah[elapsed_aahs];
 
 		/*
-		llinfos << " elapsed frames " << elapsed_frames
+		LL_INFOS() << " elapsed frames " << elapsed_frames
 				<< " ooh "            << ooh
 				<< " aah "            << aah
 				<< " transfer ooh"    << transfer_ooh
@@ -320,7 +320,7 @@ void LLVoiceVisualizer::lipSyncOohAah( F32& ooh, F32& aah )
 				<< " elapsed time "   << elapsed_time
 				<< " elapsed oohs "   << elapsed_oohs
 				<< " elapsed aahs "   << elapsed_aahs
-				<< llendl;
+				<< LL_ENDL;
 		*/
 	}
 	else
@@ -590,7 +590,7 @@ void LLVoiceVisualizer::unpackData(LLMessageSystem *mesgsys, S32 blocknum)
 	S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData);
 	if (size != 1)
 	{
-		llwarns << "Voice effect with bad size " << size << llendl;
+		LL_WARNS() << "Voice effect with bad size " << size << LL_ENDL;
 		return;
 	}
 	mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, 1, blocknum);
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index df5d413407..5e8a771929 100755
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -1364,7 +1364,7 @@ void LLVivoxVoiceClient::stateMachine()
 		    {
 				// Notify observers to let them know there is problem with voice
 				notifyStatusObservers(LLVoiceClientStatusObserver::STATUS_VOICE_DISABLED);
-				llwarns << "There seems to be problem with connection to voice server. Disabling voice chat abilities." << llendl;
+				LL_WARNS() << "There seems to be problem with connection to voice server. Disabling voice chat abilities." << LL_ENDL;
 		    }
 			
 			// Increase mSpatialJoiningNum only for spatial sessions- it's normal to reach this case for
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 487227f006..1f346b2928 100755
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -329,7 +329,7 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
 		facep = drawable->getFace(i);
 		if (!facep)
 		{
-			llwarns << "No face found for index " << i << "!" << llendl;
+			LL_WARNS() << "No face found for index " << i << "!" << LL_ENDL;
 			continue;
 		}
 
@@ -375,7 +375,7 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
 		LLFace* facep = drawable->getFace(i);
 		if (!facep)
 		{
-			llwarns << "No face found for index " << i << "!" << llendl;
+			LL_WARNS() << "No face found for index " << i << "!" << LL_ENDL;
 			continue;
 		}
 		facep->setTEOffset(i);
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index 4633b62bfb..178542cc88 100755
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -72,7 +72,7 @@ public:
 
 		if ((data_mask & type_mask) != data_mask)
 		{
-			llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl;
+			LL_ERRS() << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << LL_ENDL;
 		}
 
 		if (data_mask & MAP_NORMAL)
@@ -291,7 +291,7 @@ void LLVOSurfacePatch::updateFaceSize(S32 idx)
 {
 	if (idx != 0)
 	{
-		llwarns << "Terrain partition requested invalid face!!!" << llendl;
+		LL_WARNS() << "Terrain partition requested invalid face!!!" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index dc20d348c0..f5206b74ea 100755
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -112,7 +112,7 @@ void LLVOTree::initClass()
 
 	if (!tree_def_tree.parseFile(xml_filename))
 	{
-		llerrs << "Failed to parse tree file." << llendl;
+		LL_ERRS() << "Failed to parse tree file." << LL_ENDL;
 	}
 
 	LLXmlTreeNode* rootp = tree_def_tree.getRoot();
@@ -123,7 +123,7 @@ void LLVOTree::initClass()
 		{
 			if (!tree_def->hasName("tree"))
 			{
-				llwarns << "Invalid tree definition node " << tree_def->getName() << llendl;
+				LL_WARNS() << "Invalid tree definition node " << tree_def->getName() << LL_ENDL;
 				continue;
 			}
 			F32 F32_val;
@@ -138,19 +138,19 @@ void LLVOTree::initClass()
 			static LLStdStringHandle species_id_string = LLXmlTree::addAttributeString("species_id");
 			if (!tree_def->getFastAttributeS32(species_id_string, species))
 			{
-				llwarns << "No species id defined" << llendl;
+				LL_WARNS() << "No species id defined" << LL_ENDL;
 				continue;
 			}
 
 			if (species < 0)
 			{
-				llwarns << "Invalid species id " << species << llendl;
+				LL_WARNS() << "Invalid species id " << species << LL_ENDL;
 				continue;
 			}
 
 			if (sSpeciesTable.count(species))
 			{
-				llwarns << "Tree species " << species << " already defined! Duplicate discarded." << llendl;
+				LL_WARNS() << "Tree species " << species << " already defined! Duplicate discarded." << LL_ENDL;
 				continue;
 			}
 
@@ -241,7 +241,7 @@ void LLVOTree::initClass()
 				std::string name;
 				static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
 				tree_def->getFastAttributeString(name_string, name);
-				llwarns << "Incomplete definition of tree " << name << llendl;
+				LL_WARNS() << "Incomplete definition of tree " << name << LL_ENDL;
 			}
 		}
 		
@@ -283,7 +283,7 @@ U32 LLVOTree::processUpdateMessage(LLMessageSystem *mesgsys,
 		||(getAcceleration().lengthSquared() > 0.f)
 		||(getAngularVelocity().lengthSquared() > 0.f))
 	{
-		llinfos << "ACK! Moving tree!" << llendl;
+		LL_INFOS() << "ACK! Moving tree!" << LL_ENDL;
 		setVelocity(LLVector3::zero);
 		setAcceleration(LLVector3::zero);
 		setAngularVelocity(LLVector3::zero);
@@ -697,8 +697,8 @@ BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
 			slices = sLODSlices[lod];
 			F32 base_radius = 0.65f;
 			F32 top_radius = base_radius * sSpeciesTable[mSpecies]->mTaper;
-			//llinfos << "Species " << ((U32) mSpecies) << ", taper = " << sSpeciesTable[mSpecies].mTaper << llendl;
-			//llinfos << "Droop " << mDroop << ", branchlength: " << mBranchLength << llendl;
+			//LL_INFOS() << "Species " << ((U32) mSpecies) << ", taper = " << sSpeciesTable[mSpecies].mTaper << LL_ENDL;
+			//LL_INFOS() << "Droop " << mDroop << ", branchlength: " << mBranchLength << LL_ENDL;
 			F32 angle = 0;
 			F32 angle_inc = 360.f/(slices-1);
 			F32 z = 0.f;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 632f4d178a..547ea3369d 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -390,8 +390,8 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
 			BOOL res = LLVolumeMessage::unpackVolumeParams(&volume_params, *dp);
 			if (!res)
 			{
-				llwarns << "Bogus volume parameters in object " << getID() << llendl;
-				llwarns << getRegion()->getOriginGlobal() << llendl;
+				LL_WARNS() << "Bogus volume parameters in object " << getID() << LL_ENDL;
+				LL_WARNS() << getRegion()->getOriginGlobal() << LL_ENDL;
 			}
 
 			volume_params.setSculptID(sculpt_id, sculpt_type);
@@ -405,14 +405,14 @@ U32 LLVOVolume::processUpdateMessage(LLMessageSystem *mesgsys,
 			{
 				// There's something bogus in the data that we're unpacking.
 				dp->dumpBufferToLog();
-				llwarns << "Flushing cache files" << llendl;
+				LL_WARNS() << "Flushing cache files" << LL_ENDL;
 
 				if(LLVOCache::instanceExists() && getRegion())
 				{
 					LLVOCache::getInstance()->removeEntry(getRegion()->getHandle()) ;
 				}
 				
-				llwarns << "Bogus TE data in " << getID() << llendl;
+				LL_WARNS() << "Bogus TE data in " << getID() << LL_ENDL;
 			}
 			else 
 			{
@@ -1120,9 +1120,9 @@ void LLVOVolume::sculpt()
 			static S32 low_sculpty_discard_warning_count = 100;
 			if (++low_sculpty_discard_warning_count >= 100)
 			{	// Log first time, then every 100 afterwards otherwise this can flood the logs
-				llwarns << "WARNING!!: Current discard for sculpty " << mSculptTexture->getID() 
+				LL_WARNS() << "WARNING!!: Current discard for sculpty " << mSculptTexture->getID() 
 					<< " at " << current_discard 
-					<< " is less than -2." << llendl;
+					<< " is less than -2." << LL_ENDL;
 				low_sculpty_discard_warning_count = 0;
 			}
 			
@@ -1134,9 +1134,9 @@ void LLVOVolume::sculpt()
 			static S32 high_sculpty_discard_warning_count = 100;
 			if (++high_sculpty_discard_warning_count >= 100)
 			{	// Log first time, then every 100 afterwards otherwise this can flood the logs
-				llwarns << "WARNING!!: Current discard for sculpty " << mSculptTexture->getID() 
+				LL_WARNS() << "WARNING!!: Current discard for sculpty " << mSculptTexture->getID() 
 					<< " at " << current_discard 
-					<< " is more than than allowed max of " << MAX_DISCARD_LEVEL << llendl;
+					<< " is more than than allowed max of " << MAX_DISCARD_LEVEL << LL_ENDL;
 				high_sculpty_discard_warning_count = 0;
 			}
 
@@ -2148,7 +2148,7 @@ void LLVOVolume::updateObjectMediaData(const LLSD &media_data_array, const std::
 	if ( (S32)fetched_version > mLastFetchedMediaVersion)
 	{
 		mLastFetchedMediaVersion = fetched_version;
-		//llinfos << "updating:" << this->getID() << " " << ll_pretty_print_sd(media_data_array) << llendl;
+		//LL_INFOS() << "updating:" << this->getID() << " " << ll_pretty_print_sd(media_data_array) << LL_ENDL;
 		
 		LLSD::array_const_iterator iter = media_data_array.beginArray();
 		LLSD::array_const_iterator end = media_data_array.endArray();
@@ -2176,7 +2176,7 @@ void LLVOVolume::syncMediaData(S32 texture_index, const LLSD &media_data, bool m
 
 	LL_DEBUGS("MediaOnAPrim") << "BEFORE: texture_index = " << texture_index
 		<< " hasMedia = " << te->hasMedia() << " : " 
-		<< ((NULL == te->getMediaData()) ? "NULL MEDIA DATA" : ll_pretty_print_sd(te->getMediaData()->asLLSD())) << llendl;
+		<< ((NULL == te->getMediaData()) ? "NULL MEDIA DATA" : ll_pretty_print_sd(te->getMediaData()->asLLSD())) << LL_ENDL;
 
 	std::string previous_url;
 	LLMediaEntry* mep = te->getMediaData();
@@ -2218,7 +2218,7 @@ void LLVOVolume::syncMediaData(S32 texture_index, const LLSD &media_data, bool m
 
 	LL_DEBUGS("MediaOnAPrim") << "AFTER: texture_index = " << texture_index
 		<< " hasMedia = " << te->hasMedia() << " : " 
-		<< ((NULL == te->getMediaData()) ? "NULL MEDIA DATA" : ll_pretty_print_sd(te->getMediaData()->asLLSD())) << llendl;
+		<< ((NULL == te->getMediaData()) ? "NULL MEDIA DATA" : ll_pretty_print_sd(te->getMediaData()->asLLSD())) << LL_ENDL;
 }
 
 void LLVOVolume::mediaNavigateBounceBack(U8 texture_index)
@@ -4080,7 +4080,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep,
 	
 	if (!fullbright && type != LLRenderPass::PASS_GLOW && !facep->getVertexBuffer()->hasDataType(LLVertexBuffer::TYPE_NORMAL))
 	{
-		llwarns << "Non fullbright face has no normals!" << llendl;
+		LL_WARNS() << "Non fullbright face has no normals!" << LL_ENDL;
 		return;
 	}
 
@@ -4496,7 +4496,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 									for ( int i=0; i<jointCnt; ++i )
 									{
 										std::string lookingForJoint = pSkinData->mJointNames[i].c_str();
-										//llinfos<<"joint name "<<lookingForJoint.c_str()<<llendl;
+										//LL_INFOS()<<"joint name "<<lookingForJoint.c_str()<<LL_ENDL;
 										LLJoint* pJoint = pAvatarVO->getJoint( lookingForJoint );
 										if ( pJoint && pJoint->getId() != currentId )
 										{   									
@@ -4996,7 +4996,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 		//if not all buffers are unmapped
 		if(num_mapped_veretx_buffer != LLVertexBuffer::sMappedCount) 
 		{
-			llwarns << "Not all mapped vertex buffers are unmapped!" << llendl ; 
+			LL_WARNS() << "Not all mapped vertex buffers are unmapped!" << LL_ENDL ; 
 			for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
 			{
 				LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable();
@@ -5294,7 +5294,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 			
 			if (batch_textures && facep->getTextureIndex() == 255)
 			{
-				llerrs << "Invalid texture index." << llendl;
+				LL_ERRS() << "Invalid texture index." << LL_ENDL;
 			}
 			
 			{
@@ -5319,7 +5319,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 					if (!facep->getGeometryVolume(*volume, te_idx, 
 						vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true))
 					{
-						llwarns << "Failed to get geometry for face!" << llendl;
+						LL_WARNS() << "Failed to get geometry for face!" << LL_ENDL;
 					}
 
 					if (drawablep->isState(LLDrawable::ANIMATED_CHILD))
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index 0f2f49a975..96a94e0af4 100755
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -321,7 +321,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 
 		if(!success) 
 		{
-			llerrs << "Failed updating WindLight sky geometry." << llendl;
+			LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL;
 		}
 
 		buildFanBuffer(vertices, texCoords, indices);
@@ -345,7 +345,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 		// round up to a whole number of segments
 		const U32 strips_segments = (total_stacks+stacks_per_seg-1) / stacks_per_seg;
 
-		llinfos << "WL Skydome strips in " << strips_segments << " batches." << llendl;
+		LL_INFOS() << "WL Skydome strips in " << strips_segments << " batches." << LL_ENDL;
 
 		mStripsVerts.resize(strips_segments, NULL);
 
@@ -384,7 +384,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 
 			if(!success) 
 			{
-				llerrs << "Failed updating WindLight sky geometry." << llendl;
+				LL_ERRS() << "Failed updating WindLight sky geometry." << LL_ENDL;
 			}
 
 			// fill it
@@ -394,7 +394,7 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 			segment->flush();
 		}
 	
-		llinfos << "completed in " << llformat("%.2f", timer.getElapsedTimeF32().value()) << "seconds" << llendl;
+		LL_INFOS() << "completed in " << llformat("%.2f", timer.getElapsedTimeF32().value()) << "seconds" << LL_ENDL;
 	}
 #else
 	mStripsVerts = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB);
@@ -786,7 +786,7 @@ BOOL LLVOWLSky::updateStarGeometry(LLDrawable *drawable)
 
 	if(!success)
 	{
-		llerrs << "Failed updating star geometry." << llendl;
+		LL_ERRS() << "Failed updating star geometry." << LL_ENDL;
 	}
 
 	// *TODO: fix LLStrider with a real prefix increment operator so it can be
@@ -795,7 +795,7 @@ BOOL LLVOWLSky::updateStarGeometry(LLDrawable *drawable)
 
 	if (mStarVertices.size() < getStarsNumVerts())
 	{
-		llerrs << "Star reference geometry insufficient." << llendl;
+		LL_ERRS() << "Star reference geometry insufficient." << LL_ENDL;
 	}
 
 	for (U32 vtx = 0; vtx < getStarsNumVerts(); ++vtx)
diff --git a/indra/newview/llwatchdog.cpp b/indra/newview/llwatchdog.cpp
index c852f1869b..7b5bcf4db0 100755
--- a/indra/newview/llwatchdog.cpp
+++ b/indra/newview/llwatchdog.cpp
@@ -222,7 +222,7 @@ void LLWatchdog::run()
 	
 	if(current_run_delta > (WATCHDOG_SLEEP_TIME_USEC * TIME_ELAPSED_MULTIPLIER))
 	{
-		llinfos << "Watchdog thread delayed: resetting entries." << llendl;
+		LL_INFOS() << "Watchdog thread delayed: resetting entries." << LL_ENDL;
 		std::for_each(mSuspects.begin(), 
 			mSuspects.end(), 
 			std::mem_fun(&LLWatchdogEntry::reset)
@@ -244,7 +244,7 @@ void LLWatchdog::run()
 				mTimer->stop();
 			}
 
-			llinfos << "Watchdog detected error:" << llendl;
+			LL_INFOS() << "Watchdog detected error:" << LL_ENDL;
 			mKillerCallback();
 		}
 	}
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index ec1f0389ea..74100910f5 100755
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -103,7 +103,7 @@ void LLWaterParamManager::loadPresetsFromDir(const std::string& dir)
 		std::string path = gDirUtilp->add(dir, file);
 		if (!loadPreset(path))
 		{
-			llwarns << "Error loading water preset from " << path << llendl;
+			LL_WARNS() << "Error loading water preset from " << path << LL_ENDL;
 		}
 	}
 }
@@ -202,7 +202,7 @@ void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate)
 {
 	if (params.size() == 0)
 	{
-		llwarns << "Undefined water params" << llendl;
+		LL_WARNS() << "Undefined water params" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp
index c196d70617..ca60b79f9d 100755
--- a/indra/newview/llwearableitemslist.cpp
+++ b/indra/newview/llwearableitemslist.cpp
@@ -558,7 +558,7 @@ LLWearableItemTypeNameComparator::ETypeListOrder LLWearableItemTypeNameComparato
 
 	if(const_it == mWearableOrder.end())
 	{
-		llwarns<<"Absent information about order rang of items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
+		LL_WARNS()<<"Absent information about order rang of items of "<<LLAssetType::getDesc(item_type)<<" type"<<LL_ENDL;
 		return ORDER_RANK_UNKNOWN;
 	}
 
@@ -572,7 +572,7 @@ bool LLWearableItemTypeNameComparator::sortAssetTypeByName(LLAssetType::EType it
 
 	if(const_it == mWearableOrder.end())
 	{
-		llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
+		LL_WARNS()<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<LL_ENDL;
 		return true;
 	}
 
@@ -588,7 +588,7 @@ bool LLWearableItemTypeNameComparator::sortWearableTypeByName(LLAssetType::EType
 
 	if(const_it == mWearableOrder.end())
 	{
-		llwarns<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<llendl;
+		LL_WARNS()<<"Absent information about sorting items of "<<LLAssetType::getDesc(item_type)<<" type"<<LL_ENDL;
 		return true;
 }
 
@@ -648,7 +648,7 @@ void LLWearableItemsList::addNewItem(LLViewerInventoryItem* item, bool rearrange
 {
 	if (!item)
 	{
-		llwarns << "No inventory item. Couldn't create flat list item." << llendl;
+		LL_WARNS() << "No inventory item. Couldn't create flat list item." << LL_ENDL;
 		llassert(item != NULL);
 	}
 
@@ -659,7 +659,7 @@ void LLWearableItemsList::addNewItem(LLViewerInventoryItem* item, bool rearrange
 	bool is_item_added = addItem(list_item, item->getUUID(), ADD_BOTTOM, rearrange);
 	if (!is_item_added)
 	{
-		llwarns << "Couldn't add flat list item." << llendl;
+		LL_WARNS() << "Couldn't add flat list item." << LL_ENDL;
 		llassert(is_item_added);
 	}
 }
@@ -825,7 +825,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 {
 	if (!menu)
 	{
-		llwarns << "Invalid menu" << llendl;
+		LL_WARNS() << "Invalid menu" << LL_ENDL;
 		return;
 	}
 
@@ -846,7 +846,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 
 		if (!item)
 		{
-			llwarns << "Invalid item" << llendl;
+			LL_WARNS() << "Invalid item" << LL_ENDL;
 			// *NOTE: the logic below may not work in this case
 			continue;
 		}
@@ -919,7 +919,7 @@ void LLWearableItemsList::ContextMenu::updateItemsVisibility(LLContextMenu* menu
 
 	if (mask & MASK_UNKNOWN)
 	{
-		llwarns << "Non-wearable items passed." << llendl;
+		LL_WARNS() << "Non-wearable items passed." << LL_ENDL;
 	}
 
 	U32 num_visible_items = 0;
@@ -1026,7 +1026,7 @@ bool LLWearableItemsList::ContextMenu::canAddWearables(const uuid_vec_t& item_id
 		}
 		else
 		{
-			llwarns << "Unexpected wearable type" << llendl;
+			LL_WARNS() << "Unexpected wearable type" << LL_ENDL;
 			return false;
 		}
 	}
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp
index 79c2778253..6085893129 100755
--- a/indra/newview/llwearablelist.cpp
+++ b/indra/newview/llwearablelist.cpp
@@ -216,7 +216,7 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID
 
 LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearable, const std::string& new_name)
 {
-	lldebugs << "LLWearableList::createCopy()" << llendl;
+	LL_DEBUGS() << "LLWearableList::createCopy()" << LL_ENDL;
 
 	LLViewerWearable *wearable = generateNewWearable();
 	wearable->copyDataFrom(old_wearable);
@@ -235,7 +235,7 @@ LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearabl
 
 LLViewerWearable* LLWearableList::createNewWearable( LLWearableType::EType type, LLAvatarAppearance *avatarp )
 {
-	lldebugs << "LLWearableList::createNewWearable()" << llendl;
+	LL_DEBUGS() << "LLWearableList::createNewWearable()" << LL_ENDL;
 
 	LLViewerWearable *wearable = generateNewWearable();
 	wearable->setType( type, avatarp );
diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp
index 83337b386d..665671a38f 100755
--- a/indra/newview/llweb.cpp
+++ b/indra/newview/llweb.cpp
@@ -121,7 +121,7 @@ void LLWeb::loadURLExternal(const std::string& url, bool async, const std::strin
 	if(gSavedSettings.getBOOL("DisableExternalBrowser"))
 	{
 		// Don't open an external browser under any circumstances.
-		llwarns << "Blocked attempt to open external browser." << llendl;
+		LL_WARNS() << "Blocked attempt to open external browser." << LL_ENDL;
 		return;
 	}
 	
diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp
index 641f338f2c..b77a8375d1 100755
--- a/indra/newview/llwebprofile.cpp
+++ b/indra/newview/llwebprofile.cpp
@@ -80,7 +80,7 @@ public:
 
 		if (status != 200)
 		{
-			llwarns << "Failed to get upload config (" << status << ")" << llendl;
+			LL_WARNS() << "Failed to get upload config (" << status << ")" << LL_ENDL;
 			LLWebProfile::reportImageUploadStatus(false);
 			return;
 		}
@@ -89,7 +89,7 @@ public:
 		Json::Reader reader;
 		if (!reader.parse(body, root))
 		{
-			llwarns << "Failed to parse upload config: " << reader.getFormatedErrorMessages() << llendl;
+			LL_WARNS() << "Failed to parse upload config: " << reader.getFormatedErrorMessages() << LL_ENDL;
 			LLWebProfile::reportImageUploadStatus(false);
 			return;
 		}
@@ -112,7 +112,7 @@ public:
 		config["caption"]					= data.get("caption", "").asString();
 
 		// Do the actual image upload using the configuration.
-		LL_DEBUGS("Snapshots") << "Got upload config, POSTing image to " << upload_url << ", config=[" << config << "]" << llendl;
+		LL_DEBUGS("Snapshots") << "Got upload config, POSTing image to " << upload_url << ", config=[" << config << "]" << LL_ENDL;
 		LLWebProfile::post(mImagep, config, upload_url);
 	}
 
@@ -135,7 +135,7 @@ public:
 	{
 		if (status != 200)
 		{
-			llwarns << "Failed to upload image: " << status << " " << reason << llendl;
+			LL_WARNS() << "Failed to upload image: " << status << " " << reason << LL_ENDL;
 			LLWebProfile::reportImageUploadStatus(false);
 			return;
 		}
@@ -144,8 +144,8 @@ public:
 		std::stringstream strstrm;
 		strstrm << istr.rdbuf();
 		const std::string body = strstrm.str();
-		llinfos << "Image uploaded." << llendl;
-		LL_DEBUGS("Snapshots") << "Uploading image succeeded. Response: [" << body << "]" << llendl;
+		LL_INFOS() << "Image uploaded." << LL_ENDL;
+		LL_DEBUGS("Snapshots") << "Uploading image succeeded. Response: [" << body << "]" << LL_ENDL;
 		LLWebProfile::reportImageUploadStatus(true);
 	}
 
@@ -171,13 +171,13 @@ public:
 			LLSD headers = LLViewerMedia::getHeaders();
 			headers["Cookie"] = LLWebProfile::getAuthCookie();
 			const std::string& redir_url = content["location"];
-			LL_DEBUGS("Snapshots") << "Got redirection URL: " << redir_url << llendl;
+			LL_DEBUGS("Snapshots") << "Got redirection URL: " << redir_url << LL_ENDL;
 			LLHTTPClient::get(redir_url, new LLWebProfileResponders::PostImageRedirectResponder, headers);
 		}
 		else
 		{
-			llwarns << "Unexpected POST status: " << status << " " << reason << llendl;
-			LL_DEBUGS("Snapshots") << "headers: [" << content << "]" << llendl;
+			LL_WARNS() << "Unexpected POST status: " << status << " " << reason << LL_ENDL;
+			LL_DEBUGS("Snapshots") << "headers: [" << content << "]" << LL_ENDL;
 			LLWebProfile::reportImageUploadStatus(false);
 		}
 	}
@@ -204,7 +204,7 @@ void LLWebProfile::uploadImage(LLPointer<LLImageFormatted> image, const std::str
 	config_url += "?caption=" + LLURI::escape(caption);
 	config_url += "&add_loc=" + std::string(add_location ? "1" : "0");
 
-	LL_DEBUGS("Snapshots") << "Requesting " << config_url << llendl;
+	LL_DEBUGS("Snapshots") << "Requesting " << config_url << LL_ENDL;
 	LLSD headers = LLViewerMedia::getHeaders();
 	headers["Cookie"] = getAuthCookie();
 	LLHTTPClient::get(config_url, new LLWebProfileResponders::ConfigResponder(image), headers);
@@ -213,7 +213,7 @@ void LLWebProfile::uploadImage(LLPointer<LLImageFormatted> image, const std::str
 // static
 void LLWebProfile::setAuthCookie(const std::string& cookie)
 {
-	LL_DEBUGS("Snapshots") << "Setting auth cookie: " << cookie << llendl;
+	LL_DEBUGS("Snapshots") << "Setting auth cookie: " << cookie << LL_ENDL;
 	sAuthCookie = cookie;
 }
 
@@ -222,7 +222,7 @@ void LLWebProfile::post(LLPointer<LLImageFormatted> image, const LLSD& config, c
 {
 	if (dynamic_cast<LLImagePNG*>(image.get()) == 0)
 	{
-		llwarns << "Image to upload is not a PNG" << llendl;
+		LL_WARNS() << "Image to upload is not a PNG" << LL_ENDL;
 		llassert(dynamic_cast<LLImagePNG*>(image.get()) != 0);
 		return;
 	}
diff --git a/indra/newview/llwldaycycle.cpp b/indra/newview/llwldaycycle.cpp
index 4c0cb7c0f4..e9b0baf612 100755
--- a/indra/newview/llwldaycycle.cpp
+++ b/indra/newview/llwldaycycle.cpp
@@ -46,7 +46,7 @@ LLWLDayCycle::~LLWLDayCycle()
 
 void LLWLDayCycle::loadDayCycle(const LLSD& day_data, LLWLParamKey::EScope scope)
 {
-	lldebugs << "Loading day cycle (day_data.size() = " << day_data.size() << ", scope = " << scope << ")" << llendl;
+	LL_DEBUGS() << "Loading day cycle (day_data.size() = " << day_data.size() << ", scope = " << scope << ")" << LL_ENDL;
 	mTimeMap.clear();
 
 	// add each key frame
@@ -128,7 +128,7 @@ LLSD LLWLDayCycle::loadDayCycleFromPath(const std::string& file_path)
 void LLWLDayCycle::saveDayCycle(const std::string & fileName)
 {
 	std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", fileName));
-	//llinfos << "Saving WindLight settings to " << pathName << llendl;
+	//LL_INFOS() << "Saving WindLight settings to " << pathName << LL_ENDL;
 
 	save(pathName);
 }
@@ -154,7 +154,7 @@ LLSD LLWLDayCycle::asLLSD()
 		day_data.append(key);
 	}
 
-	lldebugs << "Dumping day cycle (" << mTimeMap.size() << ") to LLSD: " << day_data << llendl;
+	LL_DEBUGS() << "Dumping day cycle (" << mTimeMap.size() << ") to LLSD: " << day_data << LL_ENDL;
 	return day_data;
 }
 
@@ -169,7 +169,7 @@ bool LLWLDayCycle::getSkyRefs(std::map<LLWLParamKey, LLWLParamSet>& refs) const
 		const LLWLParamKey& key = iter->second;
 		if (!wl_mgr.getParamSet(key, refs[key]))
 		{
-			llwarns << "Cannot find sky [" << key.name << "] referenced by a day cycle" << llendl;
+			LL_WARNS() << "Cannot find sky [" << key.name << "] referenced by a day cycle" << LL_ENDL;
 			result = false;
 		}
 	}
@@ -192,7 +192,7 @@ bool LLWLDayCycle::getSkyMap(LLSD& sky_map) const
 
 void LLWLDayCycle::clearKeyframes()
 {
-	lldebugs << "Clearing key frames" << llendl;
+	LL_DEBUGS() << "Clearing key frames" << LL_ENDL;
 	mTimeMap.clear();
 }
 
@@ -209,18 +209,18 @@ bool LLWLDayCycle::addKeyframe(F32 newTime, LLWLParamKey frame)
 	if(mTimeMap.find(newTime) == mTimeMap.end()) 
 	{
 		mTimeMap.insert(std::pair<F32, LLWLParamKey>(newTime, frame));
-		lldebugs << "Adding key frame (" << newTime << ", " << frame.toLLSD() << ")" << llendl;
+		LL_DEBUGS() << "Adding key frame (" << newTime << ", " << frame.toLLSD() << ")" << LL_ENDL;
 		return true;
 	}
 
 	// otherwise, don't add, and return error
-	llwarns << "Error adding key frame (" << newTime << ", " << frame.toLLSD() << ")" << llendl;
+	LL_WARNS() << "Error adding key frame (" << newTime << ", " << frame.toLLSD() << ")" << LL_ENDL;
 	return false;
 }
 
 bool LLWLDayCycle::changeKeyframeTime(F32 oldTime, F32 newTime)
 {
-	lldebugs << "Changing key frame time (" << oldTime << " => " << newTime << ")" << llendl;
+	LL_DEBUGS() << "Changing key frame time (" << oldTime << " => " << newTime << ")" << LL_ENDL;
 
 	// just remove and add back
 	LLWLParamKey frame = mTimeMap[oldTime];
@@ -228,7 +228,7 @@ bool LLWLDayCycle::changeKeyframeTime(F32 oldTime, F32 newTime)
 	bool stat = removeKeyframe(oldTime);
 	if(stat == false) 
 	{
-		lldebugs << "Failed to change key frame time (" << oldTime << " => " << newTime << ")" << llendl;
+		LL_DEBUGS() << "Failed to change key frame time (" << oldTime << " => " << newTime << ")" << LL_ENDL;
 		return stat;
 	}
 
@@ -237,7 +237,7 @@ bool LLWLDayCycle::changeKeyframeTime(F32 oldTime, F32 newTime)
 
 bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key)
 {
-	lldebugs << "Changing key frame param (" << time << ", " << key.toLLSD() << ")" << llendl;
+	LL_DEBUGS() << "Changing key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL;
 
 	// just remove and add back
 	// make sure param exists
@@ -245,7 +245,7 @@ bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key)
 	bool stat = LLWLParamManager::getInstance()->getParamSet(key, tmp);
 	if(stat == false) 
 	{
-		lldebugs << "Failed to change key frame param (" << time << ", " << key.toLLSD() << ")" << llendl;
+		LL_DEBUGS() << "Failed to change key frame param (" << time << ", " << key.toLLSD() << ")" << LL_ENDL;
 		return stat;
 	}
 
@@ -256,7 +256,7 @@ bool LLWLDayCycle::changeKeyframeParam(F32 time, LLWLParamKey key)
 
 bool LLWLDayCycle::removeKeyframe(F32 time)
 {
-	lldebugs << "Removing key frame (" << time << ")" << llendl;
+	LL_DEBUGS() << "Removing key frame (" << time << ")" << LL_ENDL;
 
 	// look for the time.  If there, erase it
 	std::map<F32, LLWLParamKey>::iterator mIt = mTimeMap.find(time);
@@ -295,7 +295,7 @@ bool LLWLDayCycle::getKeyedParam(F32 time, LLWLParamSet& param)
 	}
 
 	// return error if not found
-	lldebugs << "Key " << time << " not found" << llendl;
+	LL_DEBUGS() << "Key " << time << " not found" << LL_ENDL;
 	return false;
 }
 
@@ -310,7 +310,7 @@ bool LLWLDayCycle::getKeyedParamName(F32 time, std::string & name)
 	}
 
 	// return error if not found
-	lldebugs << "Key " << time << " not found" << llendl;
+	LL_DEBUGS() << "Key " << time << " not found" << LL_ENDL;
 	return false;
 }
 
@@ -322,7 +322,7 @@ bool LLWLDayCycle::hasReferencesTo(const LLWLParamKey& keyframe) const
 
 void LLWLDayCycle::removeReferencesTo(const LLWLParamKey& keyframe)
 {
-	lldebugs << "Removing references to key frame " << keyframe.toLLSD() << llendl;
+	LL_DEBUGS() << "Removing references to key frame " << keyframe.toLLSD() << LL_ENDL;
 	F32 keytime;
 	bool might_exist;
 	do 
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index c729d6ff4f..6e6510d9c9 100755
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -128,12 +128,12 @@ void LLWLParamManager::clearParamSetsOfScope(LLWLParamKey::EScope scope)
 // side effect: applies changes to all internal structures!
 std::map<LLWLParamKey, LLWLParamSet> LLWLParamManager::finalizeFromDayCycle(LLWLParamKey::EScope scope)
 {
-	lldebugs << "mDay before finalizing:" << llendl;
+	LL_DEBUGS() << "mDay before finalizing:" << LL_ENDL;
 	{
 		for (std::map<F32, LLWLParamKey>::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter)
 		{
 			LLWLParamKey& key = iter->second;
-			lldebugs << iter->first << "->" << key.name << llendl;
+			LL_DEBUGS() << iter->first << "->" << key.name << LL_ENDL;
 		}
 	}
 
@@ -219,12 +219,12 @@ std::map<LLWLParamKey, LLWLParamSet> LLWLParamManager::finalizeFromDayCycle(LLWL
 		final_references[new_key] = iter->second;
 	}
 
-	lldebugs << "mDay after finalizing:" << llendl;
+	LL_DEBUGS() << "mDay after finalizing:" << LL_ENDL;
 	{
 		for (std::map<F32, LLWLParamKey>::iterator iter = mDay.mTimeMap.begin(); iter != mDay.mTimeMap.end(); ++iter)
 		{
 			LLWLParamKey& key = iter->second;
-			lldebugs << iter->first << "->" << key.name << llendl;
+			LL_DEBUGS() << iter->first << "->" << key.name << LL_ENDL;
 		}
 	}
 
@@ -286,7 +286,7 @@ void LLWLParamManager::loadPresetsFromDir(const std::string& dir)
 		std::string path = gDirUtilp->add(dir, file);
 		if (!loadPreset(path))
 		{
-			llwarns << "Error loading sky preset from " << path << llendl;
+			LL_WARNS() << "Error loading sky preset from " << path << LL_ENDL;
 		}
 	}
 }
@@ -577,7 +577,7 @@ void LLWLParamManager::removeParamSet(const LLWLParamKey& key, bool delete_from_
 
 	if (key.scope == LLEnvKey::SCOPE_REGION)
 	{
-		llwarns << "Removing region skies not supported" << llendl;
+		LL_WARNS() << "Removing region skies not supported" << LL_ENDL;
 		llassert(key.scope == LLEnvKey::SCOPE_LOCAL);
 		return;
 	}
@@ -677,7 +677,7 @@ void LLWLParamManager::initSingleton()
 	if (!LLDayCycleManager::instance().getPreset(preferred_day, mDay))
 	{
 		// Fall back to default.
-		llwarns << "No day cycle named " << preferred_day << ", falling back to defaults" << llendl;
+		LL_WARNS() << "No day cycle named " << preferred_day << ", falling back to defaults" << LL_ENDL;
 		mDay.loadDayCycleFromFile("Default.xml");
 
 		// *TODO: Fix user preferences accordingly.
@@ -687,7 +687,7 @@ void LLWLParamManager::initSingleton()
 	std::string sky = LLEnvManagerNew::instance().getSkyPresetName();
 	if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams))
 	{
-		llwarns << "No sky preset named " << sky << ", falling back to defaults" << llendl;
+		LL_WARNS() << "No sky preset named " << sky << ", falling back to defaults" << LL_ENDL;
 		getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams);
 
 		// *TODO: Fix user preferences accordingly.
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index bfc5077c90..101f3b203b 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -141,11 +141,11 @@ void LLWorld::destroyClass()
 
 LLViewerRegion* LLWorld::addRegion(const U64 &region_handle, const LLHost &host)
 {
-	llinfos << "Add region with handle: " << region_handle << " on host " << host << llendl;
+	LL_INFOS() << "Add region with handle: " << region_handle << " on host " << host << LL_ENDL;
 	LLViewerRegion *regionp = getRegionFromHandle(region_handle);
 	if (regionp)
 	{
-		llinfos << "Region exists, removing it " << llendl;
+		LL_INFOS() << "Region exists, removing it " << LL_ENDL;
 		LLHost old_host = regionp->getHost();
 		// region already exists!
 		if (host == old_host && regionp->isAlive())
@@ -156,12 +156,12 @@ LLViewerRegion* LLWorld::addRegion(const U64 &region_handle, const LLHost &host)
 
 		if (host != old_host)
 		{
-			llwarns << "LLWorld::addRegion exists, but old host " << old_host
-					<< " does not match new host " << host << llendl;
+			LL_WARNS() << "LLWorld::addRegion exists, but old host " << old_host
+					<< " does not match new host " << host << LL_ENDL;
 		}
 		if (!regionp->isAlive())
 		{
-			llwarns << "LLWorld::addRegion exists, but isn't alive" << llendl;
+			LL_WARNS() << "LLWorld::addRegion exists, but isn't alive" << LL_ENDL;
 		}
 
 		// Kill the old host, and then we can continue on and add the new host.  We have to kill even if the host
@@ -174,8 +174,8 @@ LLViewerRegion* LLWorld::addRegion(const U64 &region_handle, const LLHost &host)
 	from_region_handle(region_handle, &iindex, &jindex);
 	S32 x = (S32)(iindex/mWidth);
 	S32 y = (S32)(jindex/mWidth);
-	llinfos << "Adding new region (" << x << ":" << y << ")" << llendl;
-	llinfos << "Host: " << host << llendl;
+	LL_INFOS() << "Adding new region (" << x << ":" << y << ")" << LL_ENDL;
+	LL_INFOS() << "Host: " << host << LL_ENDL;
 
 	LLVector3d origin_global;
 
@@ -188,7 +188,7 @@ LLViewerRegion* LLWorld::addRegion(const U64 &region_handle, const LLHost &host)
 									getRegionWidthInMeters() );
 	if (!regionp)
 	{
-		llerrs << "Unable to create new region!" << llendl;
+		LL_ERRS() << "Unable to create new region!" << LL_ENDL;
 	}
 
 	mRegionList.push_back(regionp);
@@ -221,7 +221,7 @@ LLViewerRegion* LLWorld::addRegion(const U64 &region_handle, const LLHost &host)
 		neighborp = getRegionFromHandle(adj_handle);
 		if (neighborp)
 		{
-			//llinfos << "Connecting " << region_x << ":" << region_y << " -> " << adj_x << ":" << adj_y << llendl;
+			//LL_INFOS() << "Connecting " << region_x << ":" << region_y << " -> " << adj_x << ":" << adj_y << LL_ENDL;
 			regionp->connectNeighbor(neighborp, dir);
 		}
 	}
@@ -239,7 +239,7 @@ void LLWorld::removeRegion(const LLHost &host)
 	LLViewerRegion *regionp = getRegion(host);
 	if (!regionp)
 	{
-		llwarns << "Trying to remove region that doesn't exist!" << llendl;
+		LL_WARNS() << "Trying to remove region that doesn't exist!" << LL_ENDL;
 		return;
 	}
 	
@@ -249,21 +249,21 @@ void LLWorld::removeRegion(const LLHost &host)
 			 iter != mRegionList.end(); ++iter)
 		{
 			LLViewerRegion* reg = *iter;
-			llwarns << "RegionDump: " << reg->getName()
+			LL_WARNS() << "RegionDump: " << reg->getName()
 				<< " " << reg->getHost()
 				<< " " << reg->getOriginGlobal()
-				<< llendl;
+				<< LL_ENDL;
 		}
 
-		llwarns << "Agent position global " << gAgent.getPositionGlobal() 
+		LL_WARNS() << "Agent position global " << gAgent.getPositionGlobal() 
 			<< " agent " << gAgent.getPositionAgent()
-			<< llendl;
+			<< LL_ENDL;
 
-		llwarns << "Regions visited " << gAgent.getRegionsVisited() << llendl;
+		LL_WARNS() << "Regions visited " << gAgent.getRegionsVisited() << LL_ENDL;
 
-		llwarns << "gFrameTimeSeconds " << gFrameTimeSeconds << llendl;
+		LL_WARNS() << "gFrameTimeSeconds " << gFrameTimeSeconds << LL_ENDL;
 
-		llwarns << "Disabling region " << regionp->getName() << " that agent is in!" << llendl;
+		LL_WARNS() << "Disabling region " << regionp->getName() << " that agent is in!" << LL_ENDL;
 		LLAppViewer::instance()->forceDisconnect(LLTrans::getString("YouHaveBeenDisconnected"));
 
 		regionp->saveObjectCache() ; //force to save objects here in case that the object cache is about to be destroyed.
@@ -271,7 +271,7 @@ void LLWorld::removeRegion(const LLHost &host)
 	}
 
 	from_region_handle(regionp->getHandle(), &x, &y);
-	llinfos << "Removing region " << x << ":" << y << llendl;
+	LL_INFOS() << "Removing region " << x << ":" << y << LL_ENDL;
 
 	mRegionList.remove(regionp);
 	mActiveRegionList.remove(regionp);
@@ -756,8 +756,8 @@ void LLWorld::updateNetStats()
 
 void LLWorld::printPacketsLost()
 {
-	llinfos << "Simulators:" << llendl;
-	llinfos << "----------" << llendl;
+	LL_INFOS() << "Simulators:" << LL_ENDL;
+	LL_INFOS() << "----------" << LL_ENDL;
 
 	LLCircuitData *cdp = NULL;
 	for (region_list_t::iterator iter = mActiveRegionList.begin();
@@ -769,8 +769,8 @@ void LLWorld::printPacketsLost()
 		{
 			LLVector3d range = regionp->getCenterGlobal() - gAgent.getPositionGlobal();
 				
-			llinfos << regionp->getHost() << ", range: " << range.length()
-					<< " packets lost: " << cdp->getPacketsLost() << llendl;
+			LL_INFOS() << regionp->getHost() << ", range: " << range.length()
+					<< " packets lost: " << cdp->getPacketsLost() << LL_ENDL;
 		}
 	}
 }
@@ -826,7 +826,7 @@ void LLWorld::updateWaterObjects()
 	}
 	if (mRegionList.empty())
 	{
-		llwarns << "No regions!" << llendl;
+		LL_WARNS() << "No regions!" << LL_ENDL;
 		return;
 	}
 
@@ -1021,7 +1021,7 @@ void LLWorld::disconnectRegions()
 			continue;
 		}
 
-		llinfos << "Sending AgentQuitCopy to: " << regionp->getHost() << llendl;
+		LL_INFOS() << "Sending AgentQuitCopy to: " << regionp->getHost() << LL_ENDL;
 		msg->newMessageFast(_PREHASH_AgentQuitCopy);
 		msg->nextBlockFast(_PREHASH_AgentData);
 		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
@@ -1055,7 +1055,7 @@ void process_enable_simulator(LLMessageSystem *msg, void **user_data)
 	LLWorld::getInstance()->addRegion(handle, sim);
 
 	// give the simulator a message it can use to get ip and port
-	llinfos << "simulator_enable() Enabling " << sim << " with code " << msg->getOurCircuitCode() << llendl;
+	LL_INFOS() << "simulator_enable() Enabling " << sim << " with code " << msg->getOurCircuitCode() << LL_ENDL;
 	msg->newMessageFast(_PREHASH_UseCircuitCode);
 	msg->nextBlockFast(_PREHASH_CircuitCode);
 	msg->addU32Fast(_PREHASH_Code, msg->getOurCircuitCode());
@@ -1083,7 +1083,7 @@ public:
 			!input["body"].has("sim-ip-and-port") ||
 			!input["body"].has("seed-capability"))
 		{
-			llwarns << "invalid parameters" << llendl;
+			LL_WARNS() << "invalid parameters" << LL_ENDL;
             return;
 		}
 
@@ -1092,8 +1092,8 @@ public:
 		LLViewerRegion* regionp = LLWorld::getInstance()->getRegion(sim);
 		if (!regionp)
 		{
-			llwarns << "Got EstablishAgentCommunication for unknown region "
-					<< sim << llendl;
+			LL_WARNS() << "Got EstablishAgentCommunication for unknown region "
+					<< sim << LL_ENDL;
 			return;
 		}
 		regionp->setSeedCapability(input["body"]["seed-capability"]);
@@ -1106,7 +1106,7 @@ void process_disable_simulator(LLMessageSystem *mesgsys, void **user_data)
 {	
 	LLHost host = mesgsys->getSender();
 
-	//llinfos << "Disabling simulator with message from " << host << llendl;
+	//LL_INFOS() << "Disabling simulator with message from " << host << LL_ENDL;
 	LLWorld::getInstance()->removeRegion(host);
 
 	mesgsys->disableCircuit(host);
@@ -1119,8 +1119,8 @@ void process_region_handshake(LLMessageSystem* msg, void** user_data)
 	LLViewerRegion* regionp = LLWorld::getInstance()->getRegion(host);
 	if (!regionp)
 	{
-		llwarns << "Got region handshake for unknown region "
-			<< host << llendl;
+		LL_WARNS() << "Got region handshake for unknown region "
+			<< host << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llworldmapmessage.cpp b/indra/newview/llworldmapmessage.cpp
index 8307d32336..865292fa90 100755
--- a/indra/newview/llworldmapmessage.cpp
+++ b/indra/newview/llworldmapmessage.cpp
@@ -156,7 +156,7 @@ void LLWorldMapMessage::processMapBlockReply(LLMessageSystem* msg, void**)
 	// There's only one flag that we ever use here
 	if (agent_flags != LAYER_FLAG)
 	{
-		llwarns << "Invalid map image type returned! layer = " << agent_flags << llendl;
+		LL_WARNS() << "Invalid map image type returned! layer = " << agent_flags << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp
index 977d967a76..0f306af05a 100755
--- a/indra/newview/llworldmapview.cpp
+++ b/indra/newview/llworldmapview.cpp
@@ -1723,7 +1723,7 @@ BOOL LLWorldMapView::handleHover( S32 x, S32 y, MASK mask )
 		{
 			gViewerWindow->setCursor( UI_CURSOR_CROSS );
 		}
-		LL_DEBUGS("UserInput") << "hover handled by LLWorldMapView" << llendl;		
+		LL_DEBUGS("UserInput") << "hover handled by LLWorldMapView" << LL_ENDL;		
 		return TRUE;
 	}
 }
diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp
index 583196fb7a..8e164337b6 100755
--- a/indra/newview/llxmlrpctransaction.cpp
+++ b/indra/newview/llxmlrpctransaction.cpp
@@ -309,7 +309,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip)
 	}
 	if(!mCurlRequest->isValid())
 	{
-		llwarns << "mCurlRequest is invalid." << llendl ;
+		LL_WARNS() << "mCurlRequest is invalid." << LL_ENDL ;
 
 		delete mCurlRequest ;
 		mCurlRequest = NULL ;
@@ -375,7 +375,7 @@ bool LLXMLRPCTransaction::Impl::process()
 {
 	if(!mCurlRequest || !mCurlRequest->isValid())
 	{
-		llwarns << "transaction failed." << llendl ;
+		LL_WARNS() << "transaction failed." << LL_ENDL ;
 
 		delete mCurlRequest ;
 		mCurlRequest = NULL ;
@@ -425,10 +425,10 @@ bool LLXMLRPCTransaction::Impl::process()
 					// appropriate
 					setCurlStatus(result);
 				
-					llwarns << "LLXMLRPCTransaction CURL error "
-					<< mCurlCode << ": " << mCurlRequest->getErrorString() << llendl;
-					llwarns << "LLXMLRPCTransaction request URI: "
-					<< mURI << llendl;
+					LL_WARNS() << "LLXMLRPCTransaction CURL error "
+					<< mCurlCode << ": " << mCurlRequest->getErrorString() << LL_ENDL;
+					LL_WARNS() << "LLXMLRPCTransaction request URI: "
+					<< mURI << LL_ENDL;
 				}
 					
 				return true;
@@ -462,12 +462,12 @@ bool LLXMLRPCTransaction::Impl::process()
 			{
 				setStatus(LLXMLRPCTransaction::StatusXMLRPCError);
 				
-				llwarns << "LLXMLRPCTransaction XMLRPC "
+				LL_WARNS() << "LLXMLRPCTransaction XMLRPC "
 						<< (hasError ? "error " : "fault ")
 						<< faultCode << ": "
-						<< faultString << llendl;
-				llwarns << "LLXMLRPCTransaction request URI: "
-						<< mURI << llendl;
+						<< faultString << LL_ENDL;
+				LL_WARNS() << "LLXMLRPCTransaction request URI: "
+						<< mURI << LL_ENDL;
 			}
 			
 			return true;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1d9137c161..21cb19b8ec 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -459,7 +459,7 @@ void LLPipeline::connectRefreshCachedSettingsSafe(const std::string name)
 	LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(name);
 	if ( cntrl_ptr.isNull() )
 	{
-		llwarns << "Global setting name not found:" << name << llendl;
+		LL_WARNS() << "Global setting name not found:" << name << LL_ENDL;
 	}
 	else
 	{
@@ -681,11 +681,11 @@ void LLPipeline::cleanup()
 	
 	if (!mTerrainPools.empty())
 	{
-		llwarns << "Terrain Pools not cleaned up" << llendl;
+		LL_WARNS() << "Terrain Pools not cleaned up" << LL_ENDL;
 	}
 	if (!mTreePools.empty())
 	{
-		llwarns << "Tree Pools not cleaned up" << llendl;
+		LL_WARNS() << "Tree Pools not cleaned up" << LL_ENDL;
 	}
 		
 	delete mAlphaPool;
@@ -886,7 +886,7 @@ LLPipeline::eFBOStatus LLPipeline::doAllocateScreenBuffer(U32 resX, U32 resY)
 			releaseScreenBuffers();
 		}
 
-		llwarns << "Unable to allocate screen buffer at any resolution!" << llendl;
+		LL_WARNS() << "Unable to allocate screen buffer at any resolution!" << LL_ENDL;
 	}
 
 	return ret;
@@ -1476,7 +1476,7 @@ void LLPipeline::unloadShaders()
 
 void LLPipeline::assertInitializedDoError()
 {
-	llerrs << "LLPipeline used when uninitialized." << llendl;
+	LL_ERRS() << "LLPipeline used when uninitialized." << LL_ENDL;
 }
 
 //============================================================================
@@ -1661,7 +1661,7 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0)
 
 	default:
 		llassert(0);
-		llerrs << "Invalid Pool Type in  LLPipeline::findPool() type=" << type << llendl;
+		LL_ERRS() << "Invalid Pool Type in  LLPipeline::findPool() type=" << type << LL_ENDL;
 		break;
 	}
 
@@ -1798,9 +1798,9 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 		if (!drawablep->getSpatialGroup()->getSpatialPartition()->remove(drawablep, drawablep->getSpatialGroup()))
 		{
 #ifdef LL_RELEASE_FOR_DOWNLOAD
-			llwarns << "Couldn't remove object from spatial group!" << llendl;
+			LL_WARNS() << "Couldn't remove object from spatial group!" << LL_ENDL;
 #else
-			llerrs << "Couldn't remove object from spatial group!" << llendl;
+			LL_ERRS() << "Couldn't remove object from spatial group!" << LL_ENDL;
 #endif
 		}
 	}
@@ -1910,7 +1910,7 @@ void LLPipeline::createObject(LLViewerObject* vobj)
 	}
 	else
 	{
-		llerrs << "Redundant drawable creation!" << llendl;
+		LL_ERRS() << "Redundant drawable creation!" << LL_ENDL;
 	}
 		
 	llassert(drawablep);
@@ -1960,7 +1960,7 @@ void LLPipeline::updateMoveDampedAsync(LLDrawable* drawablep)
 	}
 	if (!drawablep)
 	{
-		llerrs << "updateMove called with NULL drawablep" << llendl;
+		LL_ERRS() << "updateMove called with NULL drawablep" << LL_ENDL;
 		return;
 	}
 	if (drawablep->isState(LLDrawable::EARLY_MOVE))
@@ -1990,7 +1990,7 @@ void LLPipeline::updateMoveNormalAsync(LLDrawable* drawablep)
 	}
 	if (!drawablep)
 	{
-		llerrs << "updateMove called with NULL drawablep" << llendl;
+		LL_ERRS() << "updateMove called with NULL drawablep" << LL_ENDL;
 		return;
 	}
 	if (drawablep->isState(LLDrawable::EARLY_MOVE))
@@ -2170,7 +2170,7 @@ void check_references(LLSpatialGroup* group, LLDrawable* drawable)
 	{
 		if (drawable == (LLDrawable*)(*i)->getDrawable())
 		{
-			llerrs << "LLDrawable deleted while actively reference by LLPipeline." << llendl;
+			LL_ERRS() << "LLDrawable deleted while actively reference by LLPipeline." << LL_ENDL;
 		}
 	}			
 }
@@ -2181,7 +2181,7 @@ void check_references(LLDrawable* drawable, LLFace* face)
 	{
 		if (drawable->getFace(i) == face)
 		{
-			llerrs << "LLFace deleted while actively referenced by LLPipeline." << llendl;
+			LL_ERRS() << "LLFace deleted while actively referenced by LLPipeline." << LL_ENDL;
 		}
 	}
 }
@@ -2257,7 +2257,7 @@ void LLPipeline::checkReferences(LLDrawable* drawable)
 		{
 			if (drawable == *iter)
 			{
-				llerrs << "LLDrawable deleted while actively referenced by LLPipeline." << llendl;
+				LL_ERRS() << "LLDrawable deleted while actively referenced by LLPipeline." << LL_ENDL;
 			}
 		}
 	}
@@ -2274,7 +2274,7 @@ void check_references(LLSpatialGroup* group, LLDrawInfo* draw_info)
 			LLDrawInfo* params = *j;
 			if (params == draw_info)
 			{
-				llerrs << "LLDrawInfo deleted while actively referenced by LLPipeline." << llendl;
+				LL_ERRS() << "LLDrawInfo deleted while actively referenced by LLPipeline." << LL_ENDL;
 			}
 		}
 	}
@@ -2316,7 +2316,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 		{
 			if (group == *iter)
 			{
-				llerrs << "LLSpatialGroup deleted while actively referenced by LLPipeline." << llendl;
+				LL_ERRS() << "LLSpatialGroup deleted while actively referenced by LLPipeline." << LL_ENDL;
 			}
 		}
 
@@ -2324,7 +2324,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 		{
 			if (group == *iter)
 			{
-				llerrs << "LLSpatialGroup deleted while actively referenced by LLPipeline." << llendl;
+				LL_ERRS() << "LLSpatialGroup deleted while actively referenced by LLPipeline." << LL_ENDL;
 			}
 		}
 
@@ -2332,7 +2332,7 @@ void LLPipeline::checkReferences(LLSpatialGroup* group)
 		{
 			if (group == *iter)
 			{
-				llerrs << "LLSpatialGroup deleted while actively referenced by LLPipeline." << llendl;
+				LL_ERRS() << "LLSpatialGroup deleted while actively referenced by LLPipeline." << LL_ENDL;
 			}
 		}
 	}
@@ -3083,13 +3083,13 @@ void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion)
 {
 	if (!drawablep)
 	{
-		//llerrs << "Sending null drawable to moved list!" << llendl;
+		//LL_ERRS() << "Sending null drawable to moved list!" << LL_ENDL;
 		return;
 	}
 	
 	if (drawablep->isDead())
 	{
-		llwarns << "Marking NULL or dead drawable moved!" << llendl;
+		LL_WARNS() << "Marking NULL or dead drawable moved!" << LL_ENDL;
 		return;
 	}
 	
@@ -4159,7 +4159,7 @@ void LLPipeline::renderHighlights()
 			LLFace *facep = mSelectedFaces[i];
 			if (!facep || facep->getDrawable()->isDead())
 			{
-				llerrs << "Bad face on selection" << llendl;
+				LL_ERRS() << "Bad face on selection" << LL_ENDL;
 				return;
 			}
 			
@@ -4207,7 +4207,7 @@ void LLPipeline::renderHighlights()
 			LLFace *facep = mSelectedFaces[i];
 			if (!facep || facep->getDrawable()->isDead())
 			{
-				llerrs << "Bad face on selection" << llendl;
+				LL_ERRS() << "Bad face on selection" << LL_ENDL;
 				return;
 			}
 
@@ -4237,7 +4237,7 @@ void LLPipeline::renderHighlights()
 			LLFace *facep = mSelectedFaces[i];
 			if (!facep || facep->getDrawable()->isDead())
 			{
-				llerrs << "Bad face on selection" << llendl;
+				LL_ERRS() << "Bad face on selection" << LL_ENDL;
 				return;
 			}
 
@@ -4291,7 +4291,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 	{
 		if (!verify())
 		{
-			llerrs << "Pipeline verification failed!" << llendl;
+			LL_ERRS() << "Pipeline verification failed!" << LL_ENDL;
 		}
 	}
 
@@ -5567,7 +5567,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mSimplePool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate simple pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate simple pool." << LL_ENDL;
 		}
 		else
 		{
@@ -5579,7 +5579,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mAlphaMaskPool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate alpha mask pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate alpha mask pool." << LL_ENDL;
 			break;
 		}
 		else
@@ -5592,7 +5592,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mFullbrightAlphaMaskPool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate alpha mask pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate alpha mask pool." << LL_ENDL;
 			break;
 		}
 		else
@@ -5605,7 +5605,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mGrassPool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate grass pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate grass pool." << LL_ENDL;
 		}
 		else
 		{
@@ -5617,7 +5617,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mFullbrightPool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate simple pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate simple pool." << LL_ENDL;
 		}
 		else
 		{
@@ -5629,7 +5629,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mInvisiblePool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate simple pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate simple pool." << LL_ENDL;
 		}
 		else
 		{
@@ -5641,7 +5641,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mGlowPool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate glow pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate glow pool." << LL_ENDL;
 		}
 		else
 		{
@@ -5661,7 +5661,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mBumpPool)
 		{
 			llassert(0);
-			llwarns << "Ignoring duplicate bump pool." << llendl;
+			LL_WARNS() << "Ignoring duplicate bump pool." << LL_ENDL;
 		}
 		else
 		{
@@ -5672,7 +5672,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if (mMaterialsPool)
 		{
 			llassert(0);
-			llwarns << "Ignorning duplicate materials pool." << llendl;
+			LL_WARNS() << "Ignorning duplicate materials pool." << LL_ENDL;
 		}
 		else
 		{
@@ -5683,7 +5683,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if( mAlphaPool )
 		{
 			llassert(0);
-			llwarns << "LLPipeline::addPool(): Ignoring duplicate Alpha pool" << llendl;
+			LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Alpha pool" << LL_ENDL;
 		}
 		else
 		{
@@ -5698,7 +5698,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if( mSkyPool )
 		{
 			llassert(0);
-			llwarns << "LLPipeline::addPool(): Ignoring duplicate Sky pool" << llendl;
+			LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Sky pool" << LL_ENDL;
 		}
 		else
 		{
@@ -5710,7 +5710,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if( mWaterPool )
 		{
 			llassert(0);
-			llwarns << "LLPipeline::addPool(): Ignoring duplicate Water pool" << llendl;
+			LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Water pool" << LL_ENDL;
 		}
 		else
 		{
@@ -5722,7 +5722,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if( mGroundPool )
 		{
 			llassert(0);
-			llwarns << "LLPipeline::addPool(): Ignoring duplicate Ground Pool" << llendl;
+			LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate Ground Pool" << LL_ENDL;
 		}
 		else
 		{ 
@@ -5734,7 +5734,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 		if( mWLSkyPool )
 		{
 			llassert(0);
-			llwarns << "LLPipeline::addPool(): Ignoring duplicate WLSky Pool" << llendl;
+			LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate WLSky Pool" << LL_ENDL;
 		}
 		else
 		{ 
@@ -5744,7 +5744,7 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp )
 
 	default:
 		llassert(0);
-		llwarns << "Invalid Pool Type in  LLPipeline::addPool()" << llendl;
+		LL_WARNS() << "Invalid Pool Type in  LLPipeline::addPool()" << LL_ENDL;
 		break;
 	}
 }
@@ -5859,7 +5859,7 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp )
 
 	default:
 		llassert(0);
-		llwarns << "Invalid Pool Type in  LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << llendl;
+		LL_WARNS() << "Invalid Pool Type in  LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << LL_ENDL;
 		break;
 	}
 }
@@ -6537,28 +6537,28 @@ void LLPipeline::findReferences(LLDrawable *drawablep)
 	assertInitialized();
 	if (mLights.find(drawablep) != mLights.end())
 	{
-		llinfos << "In mLights" << llendl;
+		LL_INFOS() << "In mLights" << LL_ENDL;
 	}
 	if (std::find(mMovedList.begin(), mMovedList.end(), drawablep) != mMovedList.end())
 	{
-		llinfos << "In mMovedList" << llendl;
+		LL_INFOS() << "In mMovedList" << LL_ENDL;
 	}
 	if (std::find(mShiftList.begin(), mShiftList.end(), drawablep) != mShiftList.end())
 	{
-		llinfos << "In mShiftList" << llendl;
+		LL_INFOS() << "In mShiftList" << LL_ENDL;
 	}
 	if (mRetexturedList.find(drawablep) != mRetexturedList.end())
 	{
-		llinfos << "In mRetexturedList" << llendl;
+		LL_INFOS() << "In mRetexturedList" << LL_ENDL;
 	}
 	
 	if (std::find(mBuildQ1.begin(), mBuildQ1.end(), drawablep) != mBuildQ1.end())
 	{
-		llinfos << "In mBuildQ1" << llendl;
+		LL_INFOS() << "In mBuildQ1" << LL_ENDL;
 	}
 	if (std::find(mBuildQ2.begin(), mBuildQ2.end(), drawablep) != mBuildQ2.end())
 	{
-		llinfos << "In mBuildQ2" << llendl;
+		LL_INFOS() << "In mBuildQ2" << LL_ENDL;
 	}
 
 	S32 count;
@@ -6566,7 +6566,7 @@ void LLPipeline::findReferences(LLDrawable *drawablep)
 	count = gObjectList.findReferences(drawablep);
 	if (count)
 	{
-		llinfos << "In other drawables: " << count << " references" << llendl;
+		LL_INFOS() << "In other drawables: " << count << " references" << LL_ENDL;
 	}
 }
 
@@ -6587,7 +6587,7 @@ BOOL LLPipeline::verify()
 
 	if (!ok)
 	{
-		llwarns << "Pipeline verify failed!" << llendl;
+		LL_WARNS() << "Pipeline verify failed!" << LL_ENDL;
 	}
 	return ok;
 }
@@ -6725,11 +6725,11 @@ void LLPipeline::toggleRenderTypeControl(void* data)
 	U32 bit = (1<<type);
 	if (gPipeline.hasRenderType(type))
 	{
-		llinfos << "Toggling render type mask " << std::hex << bit << " off" << std::dec << llendl;
+		LL_INFOS() << "Toggling render type mask " << std::hex << bit << " off" << std::dec << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "Toggling render type mask " << std::hex << bit << " on" << std::dec << llendl;
+		LL_INFOS() << "Toggling render type mask " << std::hex << bit << " on" << std::dec << LL_ENDL;
 	}
 	gPipeline.toggleRenderType(type);
 }
@@ -6755,11 +6755,11 @@ void LLPipeline::toggleRenderDebug(void* data)
 	U32 bit = (U32)(intptr_t)data;
 	if (gPipeline.hasRenderDebugMask(bit))
 	{
-		llinfos << "Toggling render debug mask " << std::hex << bit << " off" << std::dec << llendl;
+		LL_INFOS() << "Toggling render debug mask " << std::hex << bit << " off" << std::dec << LL_ENDL;
 	}
 	else
 	{
-		llinfos << "Toggling render debug mask " << std::hex << bit << " on" << std::dec << llendl;
+		LL_INFOS() << "Toggling render debug mask " << std::hex << bit << " on" << std::dec << LL_ENDL;
 	}
 	gPipeline.mRenderDebugMask ^= bit;
 }
@@ -6808,7 +6808,7 @@ void LLPipeline::popRenderDebugFeatureMask()
 {
 	if (mRenderDebugFeatureStack.empty())
 	{
-		llerrs << "Depleted render feature stack." << llendl;
+		LL_ERRS() << "Depleted render feature stack." << LL_ENDL;
 	}
 
 	mRenderDebugFeatureMask = mRenderDebugFeatureStack.top();
@@ -7242,7 +7242,7 @@ void LLPipeline::doResetVertexBuffers()
 
 	if (LLVertexBuffer::sGLCount > 0)
 	{
-		llwarns << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << llendl;
+		LL_WARNS() << "VBO wipe failed -- " << LLVertexBuffer::sGLCount << " buffers remaining." << LL_ENDL;
 	}
 
 	LLVertexBuffer::unbind();	
@@ -7325,18 +7325,18 @@ void validate_framebuffer_object()
 			break;
 		case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
 			// frame buffer not OK: probably means unsupported depth buffer format
-			llerrs << "Framebuffer Incomplete Missing Attachment." << llendl;
+			LL_ERRS() << "Framebuffer Incomplete Missing Attachment." << LL_ENDL;
 			break;
 		case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
 			// frame buffer not OK: probably means unsupported depth buffer format
-			llerrs << "Framebuffer Incomplete Attachment." << llendl;
+			LL_ERRS() << "Framebuffer Incomplete Attachment." << LL_ENDL;
 			break; 
 		case GL_FRAMEBUFFER_UNSUPPORTED:                    
 			/* choose different formats */                        
-			llerrs << "Framebuffer unsupported." << llendl;
+			LL_ERRS() << "Framebuffer unsupported." << LL_ENDL;
 			break;                                                
 		default:                                                
-			llerrs << "Unknown framebuffer status." << llendl;
+			LL_ERRS() << "Unknown framebuffer status." << LL_ENDL;
 			break;
 	}
 }
@@ -10864,7 +10864,7 @@ void LLPipeline::setRenderTypeMask(U32 type, ...)
 
 	if (type > END_RENDER_TYPES)
 	{
-		llerrs << "Invalid render type." << llendl;
+		LL_ERRS() << "Invalid render type." << LL_ENDL;
 	}
 }
 
@@ -10885,7 +10885,7 @@ BOOL LLPipeline::hasAnyRenderType(U32 type, ...) const
 
 	if (type > END_RENDER_TYPES)
 	{
-		llerrs << "Invalid render type." << llendl;
+		LL_ERRS() << "Invalid render type." << LL_ENDL;
 	}
 
 	return FALSE;
@@ -10902,7 +10902,7 @@ void LLPipeline::popRenderTypeMask()
 {
 	if (mRenderTypeEnableStack.empty())
 	{
-		llerrs << "Depleted render type stack." << llendl;
+		LL_ERRS() << "Depleted render type stack." << LL_ENDL;
 	}
 
 	memcpy(mRenderTypeEnabled, mRenderTypeEnableStack.top().data(), sizeof(mRenderTypeEnabled));
@@ -10933,7 +10933,7 @@ void LLPipeline::andRenderTypeMask(U32 type, ...)
 
 	if (type > END_RENDER_TYPES)
 	{
-		llerrs << "Invalid render type." << llendl;
+		LL_ERRS() << "Invalid render type." << LL_ENDL;
 	}
 
 	for (U32 i = 0; i < LLPipeline::NUM_RENDER_TYPES; ++i)
@@ -10958,7 +10958,7 @@ void LLPipeline::clearRenderTypeMask(U32 type, ...)
 
 	if (type > END_RENDER_TYPES)
 	{
-		llerrs << "Invalid render type." << llendl;
+		LL_ERRS() << "Invalid render type." << LL_ENDL;
 	}
 }
 
-- 
cgit v1.2.3


From cc31b4ae7934010762b8aaaa7e190c74a1cd7820 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 12 Aug 2013 20:05:16 -0700
Subject: SH-4399 FIX: Interesting: Texture console MB Bound 0/384 and texture
 queue bounces once per second SH-4346 FIX: Interesting: some integer
 Statistics are displayed as floating point after crossing region boundary
 made llerrs/infos/etc properly variadic wrt tags LL_INFOS("A", "B", "C")
 works, for example fixed unit tests remove llsimplestat

---
 indra/newview/CMakeLists.txt                       |   5 -
 indra/newview/llsimplestat.h                       | 152 ------
 indra/newview/llviewerassetstats.h                 |   1 -
 .../newview/skins/default/xui/en/floater_stats.xml |   1 -
 .../skins/default/xui/en/widgets/floater.xml       |   1 -
 indra/newview/tests/llsimplestat_test.cpp          | 580 ---------------------
 6 files changed, 740 deletions(-)
 delete mode 100755 indra/newview/llsimplestat.h
 delete mode 100755 indra/newview/tests/llsimplestat_test.cpp

(limited to 'indra/newview')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 1b779e5c99..b3e55ccc00 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -2259,11 +2259,6 @@ if (LL_TESTS)
     "${test_libs}"
     )
 
-  LL_ADD_INTEGRATION_TEST(llsimplestat
-    ""
-    "${test_libs}"
-    )
-
   LL_ADD_INTEGRATION_TEST(llviewerassetstats
     llviewerassetstats.cpp
     "${test_libs}"
diff --git a/indra/newview/llsimplestat.h b/indra/newview/llsimplestat.h
deleted file mode 100755
index 80ce99b774..0000000000
--- a/indra/newview/llsimplestat.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/** 
- * @file llsimplestat.h
- * @brief Runtime statistics accumulation.
- *
- * $LicenseInfo:firstyear=2010&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, 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$
- */
-
-#ifndef LL_SIMPLESTAT_H
-#define LL_SIMPLESTAT_H
-
-// History
-//
-// The original source for this code is the server repositories'
-// llcommon/llstat.h file.  This particular code was added after the
-// viewer/server code schism but before the effort to convert common
-// code to libraries was complete.  Rather than add to merge issues,
-// the needed code was cut'n'pasted into this new header as it isn't
-// too awful a burden.  Post-modularization, we can look at removing
-// this redundancy.
-
-
-/**
- * @class LLSimpleStatCounter
- * @brief Just counts events.
- *
- * Really not needed but have a pattern in mind in the future.
- * Interface limits what can be done at that's just fine.
- *
- * *TODO:  Update/transfer unit tests
- * Unit tests:  indra/test/llcommon_llstat_tut.cpp
- */
-class LLSimpleStatCounter
-{
-public:
-	inline LLSimpleStatCounter()		{ reset(); }
-	// Default destructor and assignment operator are valid
-
-	inline void reset()					{ mCount = 0; }
-
-	inline void merge(const LLSimpleStatCounter & src)
-										{ mCount += src.mCount; }
-	
-	inline U32 operator++()				{ return ++mCount; }
-
-	inline U32 getCount() const			{ return mCount; }
-		
-protected:
-	U32			mCount;
-};
-
-
-/**
- * @class LLSimpleStatMMM
- * @brief Templated collector of min, max and mean data for stats.
- *
- * Fed a stream of data samples, keeps a running account of the
- * min, max and mean seen since construction or the last reset()
- * call.  A freshly-constructed or reset instance returns counts
- * and values of zero.
- *
- * Overflows and underflows (integer, inf or -inf) and NaN's
- * are the caller's problem.  As is loss of precision when
- * the running sum's exponent (when parameterized by a floating
- * point of some type) differs from a given data sample's.
- *
- * Unit tests:  indra/test/llcommon_llstat_tut.cpp
- */
-template <typename VALUE_T = F32>
-class LLSimpleStatMMM
-{
-public:
-	typedef VALUE_T Value;
-	
-public:
-	LLSimpleStatMMM()				{ reset(); }
-	// Default destructor and assignment operator are valid
-
-	/**
-	 * Resets the object returning all counts and derived
-	 * values back to zero.
-	 */
-	void reset()
-	{
-		mCount = 0;
-		mMin = Value(0);
-		mMax = Value(0);
-		mTotal = Value(0);
-	}
-
-	void record(Value v)
-	{
-		if (mCount)
-		{
-			mMin = llmin(mMin, v);
-			mMax = llmax(mMax, v);
-		}
-		else
-		{
-			mMin = v;
-			mMax = v;
-		}
-		mTotal += v;
-		++mCount;
-	}
-
-	void merge(const LLSimpleStatMMM<VALUE_T> & src)
-	{
-		if (! mCount)
-		{
-			*this = src;
-		}
-		else if (src.mCount)
-		{
-			mMin = llmin(mMin, src.mMin);
-			mMax = llmax(mMax, src.mMax);
-			mCount += src.mCount;
-			mTotal += src.mTotal;
-		}
-	}
-	
-	inline U32 getCount() const		{ return mCount; }
-	inline Value getMin() const		{ return mMin; }
-	inline Value getMax() const		{ return mMax; }
-	inline Value getMean() const	{ return mCount ? mTotal / mCount : mTotal; }
-		
-protected:
-	U32			mCount;
-	Value		mMin;
-	Value		mMax;
-	Value		mTotal;
-};
-
-#endif // LL_SIMPLESTAT_H
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index 2126d569f8..a42060d4d8 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -34,7 +34,6 @@
 #include "llrefcount.h"
 #include "llviewerassettype.h"
 #include "llviewerassetstorage.h"
-#include "llsimplestat.h"
 #include "llsd.h"
 #include "llvoavatar.h"
 #include "lltrace.h"
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index d4dbb487f1..2a31524e1e 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -28,7 +28,6 @@
                  label="Basic"
                  follows="left|top|right"
                  show_label="true"
-                 show_bar="true"
                  setting="OpenDebugStatBasic">
         <stat_bar name="fps"
                   label="FPS"
diff --git a/indra/newview/skins/default/xui/en/widgets/floater.xml b/indra/newview/skins/default/xui/en/widgets/floater.xml
index 97a5ae7d4e..807b67d112 100755
--- a/indra/newview/skins/default/xui/en/widgets/floater.xml
+++ b/indra/newview/skins/default/xui/en/widgets/floater.xml
@@ -2,7 +2,6 @@
 <!-- See also settings.xml UIFloater* settings for configuration -->
 <floater
  name="floater"
- positioning="none"
  layout="topleft"
  bg_opaque_color="FloaterFocusBackgroundColor"
  bg_alpha_color="FloaterDefaultBackgroundColor"
diff --git a/indra/newview/tests/llsimplestat_test.cpp b/indra/newview/tests/llsimplestat_test.cpp
deleted file mode 100755
index b556941f4a..0000000000
--- a/indra/newview/tests/llsimplestat_test.cpp
+++ /dev/null
@@ -1,580 +0,0 @@
-/** 
- * @file llsimplestats_test.cpp
- * @date 2010-10-22
- * @brief Test cases for some of llsimplestat.h
- *
- * $LicenseInfo:firstyear=2010&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, 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 <tut/tut.hpp>
-
-#include "lltut.h"
-#include "../llsimplestat.h"
-#include "llsd.h"
-#include "llmath.h"
-
-// @brief Used as a pointer cast type to get access to LLSimpleStatCounter
-class TutStatCounter: public LLSimpleStatCounter
-{
-public:
-	TutStatCounter();							// Not defined
-	~TutStatCounter();							// Not defined
-	void operator=(const TutStatCounter &);		// Not defined
-	
-	void setRawCount(U32 c)				{ mCount = c; }
-	U32 getRawCount() const				{ return mCount; }
-};
-
-
-namespace tut
-{
-	struct stat_counter_index
-	{};
-	typedef test_group<stat_counter_index> stat_counter_index_t;
-	typedef stat_counter_index_t::object stat_counter_index_object_t;
-	tut::stat_counter_index_t tut_stat_counter_index("stat_counter_test");
-
-	// Testing LLSimpleStatCounter's external interface
-	template<> template<>
-	void stat_counter_index_object_t::test<1>()
-	{
-		LLSimpleStatCounter c1;
-		ensure("Initialized counter is zero", (0 == c1.getCount()));
-
-		ensure("Counter increment return is 1", (1 == ++c1));
-		ensure("Counter increment return is 2", (2 == ++c1));
-
-		ensure("Current counter is 2", (2 == c1.getCount()));
-
-		c1.reset();
-		ensure("Counter is 0 after reset", (0 == c1.getCount()));
-		
-		ensure("Counter increment return is 1", (1 == ++c1));
-	}
-
-	// Testing LLSimpleStatCounter's internal state
-	template<> template<>
-	void stat_counter_index_object_t::test<2>()
-	{
-		LLSimpleStatCounter c1;
-		TutStatCounter * tc1 = (TutStatCounter *) &c1;
-		
-		ensure("Initialized private counter is zero", (0 == tc1->getRawCount()));
-
-		++c1;
-		++c1;
-		
-		ensure("Current private counter is 2", (2 == tc1->getRawCount()));
-
-		c1.reset();
-		ensure("Raw counter is 0 after reset", (0 == tc1->getRawCount()));
-	}
-
-	// Testing LLSimpleStatCounter's wrapping behavior
-	template<> template<>
-	void stat_counter_index_object_t::test<3>()
-	{
-		LLSimpleStatCounter c1;
-		TutStatCounter * tc1 = (TutStatCounter *) &c1;
-
-		tc1->setRawCount(U32_MAX);
-		ensure("Initialized private counter is zero", (U32_MAX == c1.getCount()));
-
-		ensure("Increment of max value wraps to 0", (0 == ++c1));
-	}
-
-	// Testing LLSimpleStatMMM's external behavior
-	template<> template<>
-	void stat_counter_index_object_t::test<4>()
-	{
-		LLSimpleStatMMM<> m1;
-		typedef LLSimpleStatMMM<>::Value lcl_float;
-		lcl_float zero(0);
-
-		// Freshly-constructed
-		ensure("Constructed MMM<> has 0 count", (0 == m1.getCount()));
-		ensure("Constructed MMM<> has 0 min", (zero == m1.getMin()));
-		ensure("Constructed MMM<> has 0 max", (zero == m1.getMax()));
-		ensure("Constructed MMM<> has 0 mean no div-by-zero", (zero == m1.getMean()));
-
-		// Single insert
-		m1.record(1.0);
-		ensure("Single insert MMM<> has 1 count", (1 == m1.getCount()));
-		ensure("Single insert MMM<> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("Single insert MMM<> has 1.0 max", (1.0 == m1.getMax()));
-		ensure("Single insert MMM<> has 1.0 mean", (1.0 == m1.getMean()));
-		
-		// Second insert
-		m1.record(3.0);
-		ensure("2nd insert MMM<> has 2 count", (2 == m1.getCount()));
-		ensure("2nd insert MMM<> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("2nd insert MMM<> has 3.0 max", (3.0 == m1.getMax()));
-		ensure_approximately_equals("2nd insert MMM<> has 2.0 mean", m1.getMean(), lcl_float(2.0), 1);
-
-		// Third insert
-		m1.record(5.0);
-		ensure("3rd insert MMM<> has 3 count", (3 == m1.getCount()));
-		ensure("3rd insert MMM<> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("3rd insert MMM<> has 5.0 max", (5.0 == m1.getMax()));
-		ensure_approximately_equals("3rd insert MMM<> has 3.0 mean", m1.getMean(), lcl_float(3.0), 1);
-
-		// Fourth insert
-		m1.record(1000000.0);
-		ensure("4th insert MMM<> has 4 count", (4 == m1.getCount()));
-		ensure("4th insert MMM<> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("4th insert MMM<> has 100000.0 max", (1000000.0 == m1.getMax()));
-		ensure_approximately_equals("4th insert MMM<> has 250002.0 mean", m1.getMean(), lcl_float(250002.0), 1);
-
-		// Reset
-		m1.reset();
-		ensure("Reset MMM<> has 0 count", (0 == m1.getCount()));
-		ensure("Reset MMM<> has 0 min", (zero == m1.getMin()));
-		ensure("Reset MMM<> has 0 max", (zero == m1.getMax()));
-		ensure("Reset MMM<> has 0 mean no div-by-zero", (zero == m1.getMean()));
-	}
-
-	// Testing LLSimpleStatMMM's response to large values
-	template<> template<>
-	void stat_counter_index_object_t::test<5>()
-	{
-		LLSimpleStatMMM<> m1;
-		typedef LLSimpleStatMMM<>::Value lcl_float;
-		lcl_float zero(0);
-
-		// Insert overflowing values
-		const lcl_float bignum(F32_MAX / 2);
-
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(zero);
-
-		ensure("Overflowed MMM<> has 8 count", (8 == m1.getCount()));
-		ensure("Overflowed MMM<> has 0 min", (zero == m1.getMin()));
-		ensure("Overflowed MMM<> has huge max", (bignum == m1.getMax()));
-		ensure("Overflowed MMM<> has fetchable mean", (1.0 == m1.getMean() || true));
-		// We should be infinte but not interested in proving the IEEE standard here.
-		LLSD sd1(m1.getMean());
-		// std::cout << "Thingy:  " << m1.getMean() << " and as LLSD:  " << sd1 << std::endl;
-		ensure("Overflowed MMM<> produces LLSDable Real", (sd1.isReal()));
-	}
-
-	// Testing LLSimpleStatMMM<F32>'s external behavior
-	template<> template<>
-	void stat_counter_index_object_t::test<6>()
-	{
-		LLSimpleStatMMM<F32> m1;
-		typedef LLSimpleStatMMM<F32>::Value lcl_float;
-		lcl_float zero(0);
-
-		// Freshly-constructed
-		ensure("Constructed MMM<F32> has 0 count", (0 == m1.getCount()));
-		ensure("Constructed MMM<F32> has 0 min", (zero == m1.getMin()));
-		ensure("Constructed MMM<F32> has 0 max", (zero == m1.getMax()));
-		ensure("Constructed MMM<F32> has 0 mean no div-by-zero", (zero == m1.getMean()));
-
-		// Single insert
-		m1.record(1.0);
-		ensure("Single insert MMM<F32> has 1 count", (1 == m1.getCount()));
-		ensure("Single insert MMM<F32> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("Single insert MMM<F32> has 1.0 max", (1.0 == m1.getMax()));
-		ensure("Single insert MMM<F32> has 1.0 mean", (1.0 == m1.getMean()));
-		
-		// Second insert
-		m1.record(3.0);
-		ensure("2nd insert MMM<F32> has 2 count", (2 == m1.getCount()));
-		ensure("2nd insert MMM<F32> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("2nd insert MMM<F32> has 3.0 max", (3.0 == m1.getMax()));
-		ensure_approximately_equals("2nd insert MMM<F32> has 2.0 mean", m1.getMean(), lcl_float(2.0), 1);
-
-		// Third insert
-		m1.record(5.0);
-		ensure("3rd insert MMM<F32> has 3 count", (3 == m1.getCount()));
-		ensure("3rd insert MMM<F32> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("3rd insert MMM<F32> has 5.0 max", (5.0 == m1.getMax()));
-		ensure_approximately_equals("3rd insert MMM<F32> has 3.0 mean", m1.getMean(), lcl_float(3.0), 1);
-
-		// Fourth insert
-		m1.record(1000000.0);
-		ensure("4th insert MMM<F32> has 4 count", (4 == m1.getCount()));
-		ensure("4th insert MMM<F32> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("4th insert MMM<F32> has 1000000.0 max", (1000000.0 == m1.getMax()));
-		ensure_approximately_equals("4th insert MMM<F32> has 250002.0 mean", m1.getMean(), lcl_float(250002.0), 1);
-
-		// Reset
-		m1.reset();
-		ensure("Reset MMM<F32> has 0 count", (0 == m1.getCount()));
-		ensure("Reset MMM<F32> has 0 min", (zero == m1.getMin()));
-		ensure("Reset MMM<F32> has 0 max", (zero == m1.getMax()));
-		ensure("Reset MMM<F32> has 0 mean no div-by-zero", (zero == m1.getMean()));
-	}
-
-	// Testing LLSimpleStatMMM's response to large values
-	template<> template<>
-	void stat_counter_index_object_t::test<7>()
-	{
-		LLSimpleStatMMM<F32> m1;
-		typedef LLSimpleStatMMM<F32>::Value lcl_float;
-		lcl_float zero(0);
-
-		// Insert overflowing values
-		const lcl_float bignum(F32_MAX / 2);
-
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(zero);
-
-		ensure("Overflowed MMM<F32> has 8 count", (8 == m1.getCount()));
-		ensure("Overflowed MMM<F32> has 0 min", (zero == m1.getMin()));
-		ensure("Overflowed MMM<F32> has huge max", (bignum == m1.getMax()));
-		ensure("Overflowed MMM<F32> has fetchable mean", (1.0 == m1.getMean() || true));
-		// We should be infinte but not interested in proving the IEEE standard here.
-		LLSD sd1(m1.getMean());
-		// std::cout << "Thingy:  " << m1.getMean() << " and as LLSD:  " << sd1 << std::endl;
-		ensure("Overflowed MMM<F32> produces LLSDable Real", (sd1.isReal()));
-	}
-
-	// Testing LLSimpleStatMMM<F64>'s external behavior
-	template<> template<>
-	void stat_counter_index_object_t::test<8>()
-	{
-		LLSimpleStatMMM<F64> m1;
-		typedef LLSimpleStatMMM<F64>::Value lcl_float;
-		lcl_float zero(0);
-
-		// Freshly-constructed
-		ensure("Constructed MMM<F64> has 0 count", (0 == m1.getCount()));
-		ensure("Constructed MMM<F64> has 0 min", (zero == m1.getMin()));
-		ensure("Constructed MMM<F64> has 0 max", (zero == m1.getMax()));
-		ensure("Constructed MMM<F64> has 0 mean no div-by-zero", (zero == m1.getMean()));
-
-		// Single insert
-		m1.record(1.0);
-		ensure("Single insert MMM<F64> has 1 count", (1 == m1.getCount()));
-		ensure("Single insert MMM<F64> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("Single insert MMM<F64> has 1.0 max", (1.0 == m1.getMax()));
-		ensure("Single insert MMM<F64> has 1.0 mean", (1.0 == m1.getMean()));
-		
-		// Second insert
-		m1.record(3.0);
-		ensure("2nd insert MMM<F64> has 2 count", (2 == m1.getCount()));
-		ensure("2nd insert MMM<F64> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("2nd insert MMM<F64> has 3.0 max", (3.0 == m1.getMax()));
-		ensure_approximately_equals("2nd insert MMM<F64> has 2.0 mean", m1.getMean(), lcl_float(2.0), 1);
-
-		// Third insert
-		m1.record(5.0);
-		ensure("3rd insert MMM<F64> has 3 count", (3 == m1.getCount()));
-		ensure("3rd insert MMM<F64> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("3rd insert MMM<F64> has 5.0 max", (5.0 == m1.getMax()));
-		ensure_approximately_equals("3rd insert MMM<F64> has 3.0 mean", m1.getMean(), lcl_float(3.0), 1);
-
-		// Fourth insert
-		m1.record(1000000.0);
-		ensure("4th insert MMM<F64> has 4 count", (4 == m1.getCount()));
-		ensure("4th insert MMM<F64> has 1.0 min", (1.0 == m1.getMin()));
-		ensure("4th insert MMM<F64> has 1000000.0 max", (1000000.0 == m1.getMax()));
-		ensure_approximately_equals("4th insert MMM<F64> has 250002.0 mean", m1.getMean(), lcl_float(250002.0), 1);
-
-		// Reset
-		m1.reset();
-		ensure("Reset MMM<F64> has 0 count", (0 == m1.getCount()));
-		ensure("Reset MMM<F64> has 0 min", (zero == m1.getMin()));
-		ensure("Reset MMM<F64> has 0 max", (zero == m1.getMax()));
-		ensure("Reset MMM<F64> has 0 mean no div-by-zero", (zero == m1.getMean()));
-	}
-
-	// Testing LLSimpleStatMMM's response to large values
-	template<> template<>
-	void stat_counter_index_object_t::test<9>()
-	{
-		LLSimpleStatMMM<F64> m1;
-		typedef LLSimpleStatMMM<F64>::Value lcl_float;
-		lcl_float zero(0);
-
-		// Insert overflowing values
-		const lcl_float bignum(F64_MAX / 2);
-
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(zero);
-
-		ensure("Overflowed MMM<F64> has 8 count", (8 == m1.getCount()));
-		ensure("Overflowed MMM<F64> has 0 min", (zero == m1.getMin()));
-		ensure("Overflowed MMM<F64> has huge max", (bignum == m1.getMax()));
-		ensure("Overflowed MMM<F64> has fetchable mean", (1.0 == m1.getMean() || true));
-		// We should be infinte but not interested in proving the IEEE standard here.
-		LLSD sd1(m1.getMean());
-		// std::cout << "Thingy:  " << m1.getMean() << " and as LLSD:  " << sd1 << std::endl;
-		ensure("Overflowed MMM<F64> produces LLSDable Real", (sd1.isReal()));
-	}
-
-	// Testing LLSimpleStatMMM<U64>'s external behavior
-	template<> template<>
-	void stat_counter_index_object_t::test<10>()
-	{
-		LLSimpleStatMMM<U64> m1;
-		typedef LLSimpleStatMMM<U64>::Value lcl_int;
-		lcl_int zero(0);
-
-		// Freshly-constructed
-		ensure("Constructed MMM<U64> has 0 count", (0 == m1.getCount()));
-		ensure("Constructed MMM<U64> has 0 min", (zero == m1.getMin()));
-		ensure("Constructed MMM<U64> has 0 max", (zero == m1.getMax()));
-		ensure("Constructed MMM<U64> has 0 mean no div-by-zero", (zero == m1.getMean()));
-
-		// Single insert
-		m1.record(1);
-		ensure("Single insert MMM<U64> has 1 count", (1 == m1.getCount()));
-		ensure("Single insert MMM<U64> has 1 min", (1 == m1.getMin()));
-		ensure("Single insert MMM<U64> has 1 max", (1 == m1.getMax()));
-		ensure("Single insert MMM<U64> has 1 mean", (1 == m1.getMean()));
-		
-		// Second insert
-		m1.record(3);
-		ensure("2nd insert MMM<U64> has 2 count", (2 == m1.getCount()));
-		ensure("2nd insert MMM<U64> has 1 min", (1 == m1.getMin()));
-		ensure("2nd insert MMM<U64> has 3 max", (3 == m1.getMax()));
-		ensure("2nd insert MMM<U64> has 2 mean", (2 == m1.getMean()));
-
-		// Third insert
-		m1.record(5);
-		ensure("3rd insert MMM<U64> has 3 count", (3 == m1.getCount()));
-		ensure("3rd insert MMM<U64> has 1 min", (1 == m1.getMin()));
-		ensure("3rd insert MMM<U64> has 5 max", (5 == m1.getMax()));
-		ensure("3rd insert MMM<U64> has 3 mean", (3 == m1.getMean()));
-
-		// Fourth insert
-		m1.record(U64L(1000000000000));
-		ensure("4th insert MMM<U64> has 4 count", (4 == m1.getCount()));
-		ensure("4th insert MMM<U64> has 1 min", (1 == m1.getMin()));
-		ensure("4th insert MMM<U64> has 1000000000000ULL max", (U64L(1000000000000) == m1.getMax()));
-		ensure("4th insert MMM<U64> has 250000000002ULL mean", (U64L( 250000000002) == m1.getMean()));
-
-		// Reset
-		m1.reset();
-		ensure("Reset MMM<U64> has 0 count", (0 == m1.getCount()));
-		ensure("Reset MMM<U64> has 0 min", (zero == m1.getMin()));
-		ensure("Reset MMM<U64> has 0 max", (zero == m1.getMax()));
-		ensure("Reset MMM<U64> has 0 mean no div-by-zero", (zero == m1.getMean()));
-	}
-
-	// Testing LLSimpleStatMMM's response to large values
-	template<> template<>
-	void stat_counter_index_object_t::test<11>()
-	{
-		LLSimpleStatMMM<U64> m1;
-		typedef LLSimpleStatMMM<U64>::Value lcl_int;
-		lcl_int zero(0);
-
-		// Insert overflowing values
-		const lcl_int bignum(U64L(0xffffffffffffffff) / 2);
-
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(bignum);
-		m1.record(zero);
-
-		ensure("Overflowed MMM<U64> has 8 count", (8 == m1.getCount()));
-		ensure("Overflowed MMM<U64> has 0 min", (zero == m1.getMin()));
-		ensure("Overflowed MMM<U64> has huge max", (bignum == m1.getMax()));
-		ensure("Overflowed MMM<U64> has fetchable mean", (zero == m1.getMean() || true));
-	}
-
-    // Testing LLSimpleStatCounter's merge() method
-	template<> template<>
-	void stat_counter_index_object_t::test<12>()
-	{
-		LLSimpleStatCounter c1;
-		LLSimpleStatCounter c2;
-
-		++c1;
-		++c1;
-		++c1;
-		++c1;
-
-		++c2;
-		++c2;
-		c2.merge(c1);
-		
-		ensure_equals("4 merged into 2 results in 6", 6, c2.getCount());
-
-		ensure_equals("Source of merge is undamaged", 4, c1.getCount());
-	}
-
-    // Testing LLSimpleStatMMM's merge() method
-	template<> template<>
-	void stat_counter_index_object_t::test<13>()
-	{
-		LLSimpleStatMMM<> m1;
-		LLSimpleStatMMM<> m2;
-
-		m1.record(3.5);
-		m1.record(4.5);
-		m1.record(5.5);
-		m1.record(6.5);
-
-		m2.record(5.0);
-		m2.record(7.0);
-		m2.record(9.0);
-		
-		m2.merge(m1);
-
-		ensure_equals("Count after merge (p1)", 7, m2.getCount());
-		ensure_approximately_equals("Min after merge (p1)", F32(3.5), m2.getMin(), 22);
-		ensure_approximately_equals("Max after merge (p1)", F32(9.0), m2.getMax(), 22);
-		ensure_approximately_equals("Mean after merge (p1)", F32(41.000/7.000), m2.getMean(), 22);
-		
-
-		ensure_equals("Source count of merge is undamaged (p1)", 4, m1.getCount());
-		ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(3.5), m1.getMin(), 22);
-		ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(6.5), m1.getMax(), 22);
-		ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(5.0), m1.getMean(), 22);
-
-		m2.reset();
-
-		m2.record(-22.0);
-		m2.record(-1.0);
-		m2.record(30.0);
-		
-		m2.merge(m1);
-
-		ensure_equals("Count after merge (p2)", 7, m2.getCount());
-		ensure_approximately_equals("Min after merge (p2)", F32(-22.0), m2.getMin(), 22);
-		ensure_approximately_equals("Max after merge (p2)", F32(30.0), m2.getMax(), 22);
-		ensure_approximately_equals("Mean after merge (p2)", F32(27.000/7.000), m2.getMean(), 22);
-
-	}
-
-    // Testing LLSimpleStatMMM's merge() method when src contributes nothing
-	template<> template<>
-	void stat_counter_index_object_t::test<14>()
-	{
-		LLSimpleStatMMM<> m1;
-		LLSimpleStatMMM<> m2;
-
-		m2.record(5.0);
-		m2.record(7.0);
-		m2.record(9.0);
-		
-		m2.merge(m1);
-
-		ensure_equals("Count after merge (p1)", 3, m2.getCount());
-		ensure_approximately_equals("Min after merge (p1)", F32(5.0), m2.getMin(), 22);
-		ensure_approximately_equals("Max after merge (p1)", F32(9.0), m2.getMax(), 22);
-		ensure_approximately_equals("Mean after merge (p1)", F32(7.000), m2.getMean(), 22);
-
-		ensure_equals("Source count of merge is undamaged (p1)", 0, m1.getCount());
-		ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(0), m1.getMin(), 22);
-		ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(0), m1.getMax(), 22);
-		ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(0), m1.getMean(), 22);
-
-		m2.reset();
-
-		m2.record(-22.0);
-		m2.record(-1.0);
-		
-		m2.merge(m1);
-
-		ensure_equals("Count after merge (p2)", 2, m2.getCount());
-		ensure_approximately_equals("Min after merge (p2)", F32(-22.0), m2.getMin(), 22);
-		ensure_approximately_equals("Max after merge (p2)", F32(-1.0), m2.getMax(), 22);
-		ensure_approximately_equals("Mean after merge (p2)", F32(-11.5), m2.getMean(), 22);
-	}
-
-    // Testing LLSimpleStatMMM's merge() method when dst contributes nothing
-	template<> template<>
-	void stat_counter_index_object_t::test<15>()
-	{
-		LLSimpleStatMMM<> m1;
-		LLSimpleStatMMM<> m2;
-
-		m1.record(5.0);
-		m1.record(7.0);
-		m1.record(9.0);
-		
-		m2.merge(m1);
-
-		ensure_equals("Count after merge (p1)", 3, m2.getCount());
-		ensure_approximately_equals("Min after merge (p1)", F32(5.0), m2.getMin(), 22);
-		ensure_approximately_equals("Max after merge (p1)", F32(9.0), m2.getMax(), 22);
-		ensure_approximately_equals("Mean after merge (p1)", F32(7.000), m2.getMean(), 22);
-
-		ensure_equals("Source count of merge is undamaged (p1)", 3, m1.getCount());
-		ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(5.0), m1.getMin(), 22);
-		ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(9.0), m1.getMax(), 22);
-		ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(7.0), m1.getMean(), 22);
-
-		m1.reset();
-		m2.reset();
-		
-		m1.record(-22.0);
-		m1.record(-1.0);
-		
-		m2.merge(m1);
-
-		ensure_equals("Count after merge (p2)", 2, m2.getCount());
-		ensure_approximately_equals("Min after merge (p2)", F32(-22.0), m2.getMin(), 22);
-		ensure_approximately_equals("Max after merge (p2)", F32(-1.0), m2.getMax(), 22);
-		ensure_approximately_equals("Mean after merge (p2)", F32(-11.5), m2.getMean(), 22);
-	}
-
-    // Testing LLSimpleStatMMM's merge() method when neither dst nor src contributes
-	template<> template<>
-	void stat_counter_index_object_t::test<16>()
-	{
-		LLSimpleStatMMM<> m1;
-		LLSimpleStatMMM<> m2;
-
-		m2.merge(m1);
-
-		ensure_equals("Count after merge (p1)", 0, m2.getCount());
-		ensure_approximately_equals("Min after merge (p1)", F32(0), m2.getMin(), 22);
-		ensure_approximately_equals("Max after merge (p1)", F32(0), m2.getMax(), 22);
-		ensure_approximately_equals("Mean after merge (p1)", F32(0), m2.getMean(), 22);
-
-		ensure_equals("Source count of merge is undamaged (p1)", 0, m1.getCount());
-		ensure_approximately_equals("Source min of merge is undamaged (p1)", F32(0), m1.getMin(), 22);
-		ensure_approximately_equals("Source max of merge is undamaged (p1)", F32(0), m1.getMax(), 22);
-		ensure_approximately_equals("Source mean of merge is undamaged (p1)", F32(0), m1.getMean(), 22);
-	}
-}
-- 
cgit v1.2.3


From 1a093beb7f69e6911f34cb12d71502aa7a05982e Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 12 Aug 2013 20:05:37 -0700
Subject: disable scene load timing info by default

---
 indra/newview/app_settings/logcontrol.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml
index b500c37098..7da047aed5 100755
--- a/indra/newview/app_settings/logcontrol.xml
+++ b/indra/newview/app_settings/logcontrol.xml
@@ -42,8 +42,8 @@
 						</array>
 					<key>tags</key>
 						<array>
-							<string>SceneLoadTiming</string>
 						<!-- sample entry for debugging specific items	
+						     <string>SceneLoadTiming</string>
 						     <string>Avatar</string>
 						     <string>Voice</string>		
 						-->
-- 
cgit v1.2.3


From b39cf4770b6d73de51b0ed451139bb4502f396c8 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 12 Aug 2013 20:08:18 -0700
Subject: Backed out changeset: ed09997b4652

---
 indra/newview/llappviewer.cpp        | 4 ++--
 indra/newview/llappviewer.h          | 2 +-
 indra/newview/llstartup.cpp          | 5 ++---
 indra/newview/llviewerobjectlist.cpp | 5 ++---
 indra/newview/llviewerstats.cpp      | 2 +-
 5 files changed, 8 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 30c19ac55e..0a1a78c5b4 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -294,7 +294,7 @@ U32 gForegroundFrameCount = 0; // number of frames that app window was in foregr
 LLPumpIO* gServicePump = NULL;
 
 LLUnitImplicit<U64, LLUnits::Microseconds> gFrameTime = 0;
-F32 gFrameTimeSeconds = 0.f;
+LLUnitImplicit<F32, LLUnits::Seconds> gFrameTimeSeconds = 0.f;
 LLUnitImplicit<F32, LLUnits::Seconds> 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
@@ -1464,7 +1464,7 @@ bool LLAppViewer::mainLoop()
 					ms_sleep(500);
 				}
 
-				const F64 max_idle_time = llmin(.005f*10.0f*gFrameTimeSeconds, (0.005f)); // 5 ms a second
+				const F64 max_idle_time = llmin(.005*10.0*gFrameTimeSeconds, LLUnitImplicit<F32, LLUnits::Seconds>(0.005f)); // 5 ms a second
 				idleTimer.reset();
 				S32 total_work_pending = 0;
 				S32 total_io_pending = 0;	
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 76724a9662..60a1045f58 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -336,7 +336,7 @@ extern LLPumpIO* gServicePump;
 
 extern LLUnitImplicit<U64, LLUnits::Microseconds>	gStartTime;
 extern LLUnitImplicit<U64, LLUnits::Microseconds>   gFrameTime;					// The timestamp of the most-recently-processed frame
-extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
+extern LLUnitImplicit<F32, LLUnits::Seconds>		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
 extern LLUnitImplicit<F32, LLUnits::Seconds>		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
 extern F32		gFPSClamped;				// Frames per second, smoothed, weighted toward last frame
 extern F32		gFrameDTClamped;
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index ae8afd0eae..3335ff6631 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1429,9 +1429,8 @@ bool idle_startup()
 
 		LL_DEBUGS("AppInit") << "Initializing camera..." << LL_ENDL;
 		gFrameTime    = totalTime();
-		F32 last_time = gFrameTimeSeconds;
-		const F64 SEC_TO_MICROSEC = 1000000.f;
-		gFrameTimeSeconds = (F32)((gFrameTime - gStartTime) / SEC_TO_MICROSEC);
+		LLUnit<F32, LLUnits::Seconds> last_time = gFrameTimeSeconds;
+		gFrameTimeSeconds = (gFrameTime - gStartTime);
 
 		gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
 		if (gFrameIntervalSeconds < 0.f)
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 214d4f2bf6..e8f68527e9 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -999,10 +999,9 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	// Time _can_ go backwards, for example if the user changes the system clock.
 	// It doesn't cause any fatal problems (just some oddness with stats), so we shouldn't assert here.
 //	llassert(time > gFrameTime);
-	const F64 SEC_TO_MICROSEC = 1000000.f;
-	F64 time_diff = U64_to_F64(time - gFrameTime)/SEC_TO_MICROSEC;
+	LLUnit<F64, LLUnits::Seconds> time_diff = time - gFrameTime;
 	gFrameTime	= time;
-	F64 time_since_start = U64_to_F64(gFrameTime - gStartTime)/SEC_TO_MICROSEC;
+	LLUnit<F64, LLUnits::Seconds> time_since_start = gFrameTime - gStartTime;
 	gFrameTimeSeconds = time_since_start;
 
 	gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 06a2dad07f..8cb519b098 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -596,7 +596,7 @@ void send_stats()
 	S32 window_height = gViewerWindow->getWindowHeightRaw();
 	S32 window_size = (window_width * window_height) / 1024;
 	misc["string_1"] = llformat("%d", window_size);
-	misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds);
+	misc["string_2"] = llformat("Texture Time: %.2f, Total Time: %.2f", gTextureTimer.getElapsedTimeF32(), gFrameTimeSeconds.value());
 
 // 	misc["int_1"] = LLSD::Integer(gSavedSettings.getU32("RenderQualityPerformance")); // Steve: 1.21
 // 	misc["int_2"] = LLSD::Integer(gFrameStalls); // Steve: 1.21
-- 
cgit v1.2.3


From 9faaa28f4445425e8c5b7b002faffbe0365b905d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 13 Aug 2013 18:33:07 -0700
Subject: SH-4346 FIX Interesting: some integer Statistics are displayed as
 floating point after crossing region boundary fine-tuned heuristics for
 switching between mean and current values in stat bar display added comments
 to LLUnits unit test

---
 indra/newview/skins/default/xui/en/floater_stats.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 2a31524e1e..aaf191a98a 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -31,7 +31,7 @@
                  setting="OpenDebugStatBasic">
         <stat_bar name="fps"
                   label="FPS"
-                  unit_label="frames"
+                  unit_label="fps"
                   stat="FPS"
                   decimal_digits="1"
                   show_bar="true"
-- 
cgit v1.2.3


From 26581404e426b00cd0a07c38b5cb858d5d5faa28 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 14 Aug 2013 11:51:49 -0700
Subject: BUILDFIX: added header for numeric_limits support on gcc added
 convenience types for units F32Seconds, etc.

---
 indra/newview/llconversationlog.cpp   |  4 ++--
 indra/newview/llfasttimerview.cpp     | 26 +++++++++++++-------------
 indra/newview/llfasttimerview.h       |  6 +++---
 indra/newview/llscenemonitor.cpp      |  2 +-
 indra/newview/llstartup.cpp           |  2 +-
 indra/newview/lltexturefetch.cpp      |  7 +++----
 indra/newview/lltextureinfo.cpp       |  8 ++++----
 indra/newview/lltextureview.cpp       |  2 +-
 indra/newview/llviewerassetstats.cpp  |  4 ++--
 indra/newview/llviewerobjectlist.cpp  |  4 ++--
 indra/newview/llviewerstats.cpp       | 22 +++++++++++-----------
 indra/newview/llviewerstats.h         |  8 ++++----
 indra/newview/llviewertexture.cpp     | 22 +++++++++++-----------
 indra/newview/llviewertexturelist.cpp |  2 +-
 indra/newview/llviewertexturelist.h   |  8 ++++----
 indra/newview/llviewerthrottle.cpp    |  4 ++--
 indra/newview/llvoavatarself.cpp      |  2 +-
 indra/newview/llvoicevivox.cpp        |  2 +-
 indra/newview/llworld.cpp             |  6 +++---
 19 files changed, 70 insertions(+), 71 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index 8dd148e304..a17a4e5e21 100755
--- a/indra/newview/llconversationlog.cpp
+++ b/indra/newview/llconversationlog.cpp
@@ -132,7 +132,7 @@ const std::string LLConversation::createTimestamp(const LLUnit<U64, LLUnits::Sec
 
 bool LLConversation::isOlderThan(U32 days) const
 {
-	LLUnit<U64, LLUnits::Seconds> now = time_corrected();
+	LLUnit<U64, LLUnits::Seconds> now(time_corrected());
 	LLUnit<U32, LLUnits::Days> age = now - mTime;
 
 	return age > days;
@@ -535,7 +535,7 @@ bool LLConversationLog::loadFromFile(const std::string& filename)
 				history_file_name);
 
 		ConversationParams params;
-		params.time(time)
+		params.time(LLUnits::Seconds::fromValue(time))
 			.conversation_type((SessionType)stype)
 			.has_offline_ims(has_offline_ims)
 			.conversation_name(conv_name_buffer)
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index bb9e474098..11a9a70b18 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -260,7 +260,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 		TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mScrollIndex + mHoverBarIndex - 1];
 
 		TimerBar* hover_bar = NULL;
-		LLUnit<F32, LLUnits::Seconds> mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay;
+		LLUnits::F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay;
 		for (int bar_index = 0, end_index = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount(); 
 			bar_index < end_index; 
 			++bar_index)
@@ -996,7 +996,7 @@ void LLFastTimerView::printLineStats()
 			}
 			first = false;
 
-			LLUnit<F32, LLUnits::Seconds> ticks;
+			LLUnits::F32Seconds ticks;
 			if (mStatsIndex == 0)
 			{
 				ticks = mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH);
@@ -1029,7 +1029,7 @@ void LLFastTimerView::drawLineGraph()
 	LLLocalClipRect clip(mGraphRect);
 
 	//normalize based on last frame's maximum
-	static LLUnit<F32, LLUnits::Seconds> max_time = 0.000001;
+	static LLUnits::F32Seconds max_time(0.000001);
 	static U32 max_calls = 0;
 	static F32 alpha_interp = 0.f;
 
@@ -1060,7 +1060,7 @@ void LLFastTimerView::drawLineGraph()
 		}
 	}
 
-	LLUnit<F32, LLUnits::Seconds> cur_max = 0;
+	LLUnits::F32Seconds cur_max(0);
 	U32 cur_max_calls = 0;
 	for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 		it != end_timer_tree();
@@ -1101,7 +1101,7 @@ void LLFastTimerView::drawLineGraph()
 			j--)
 		{
 			LLTrace::Recording& recording = mRecording.getPrevRecording(j);
-			LLUnit<F32, LLUnits::Seconds> time = llmax(recording.getSum(*idp), LLUnits::Seconds::fromValue(0.000001));
+			LLUnits::F32Seconds time = llmax(recording.getSum(*idp), LLUnits::F64Seconds(0.000001));
 			U32 calls = recording.getSum(idp->callCount());
 
 			if (is_hover_timer)
@@ -1146,7 +1146,7 @@ void LLFastTimerView::drawLineGraph()
 	max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f));
 	if (llabs((max_time - cur_max).value()) <= 1)
 	{
-		max_time = llmax(LLUnits::Microseconds::fromValue(1.f), LLUnits::Microseconds::fromValue(cur_max));
+		max_time = llmax(LLUnits::F32Microseconds(1.f), LLUnits::F32Microseconds(cur_max));
 	}
 
 	max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f)));
@@ -1230,7 +1230,7 @@ void LLFastTimerView::drawLegend()
 			llassert(idp->getIndex() < sTimerColors.size());
 			gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]);
 
-			LLUnit<F32, LLUnits::Milliseconds> ms = 0;
+			LLUnit<F32, LLUnits::Milliseconds> ms(0);
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
@@ -1240,7 +1240,7 @@ void LLFastTimerView::drawLegend()
 			}
 			else
 			{
-				ms = LLUnit<F64, LLUnits::Seconds>(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH));
+				ms = LLUnits::F64Seconds(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH));
 				calls = (S32)mRecording.getPeriodMean(idp->callCount(), RUNNING_AVERAGE_WIDTH);
 			}
 
@@ -1423,7 +1423,7 @@ void LLFastTimerView::updateTotalTime()
 		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20);
 		break;
 	default:
-		mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(100);
+		mTotalTimeDisplay = LLUnits::F64Milliseconds(100);
 		break;
 	}
 
@@ -1511,14 +1511,14 @@ void LLFastTimerView::drawBars()
 
 static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
-LLUnit<F32, LLUnits::Seconds> LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
+LLUnits::F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
 {
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
-	const LLUnit<F32, LLUnits::Seconds> self_time = history_index == -1
+	const LLUnits::F32Seconds self_time = history_index == -1
 										? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) 
 										: mRecording.getPrevRecording(history_index).getSum(time_block->selfTime());
 
-	LLUnit<F32, LLUnits::Seconds> full_time = self_time;
+	LLUnits::F32Seconds full_time = self_time;
 
 	// reserve a spot for this bar to be rendered before its children
 	// even though we don't know its size yet
@@ -1544,7 +1544,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS);
 
 	TimerBar& timer_bar = row.mBars[timer_bar_index];
-	const LLUnit<F32, LLUnits::Seconds> bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime;
+	const LLUnits::F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime;
 	timer_bar.mChildrenStart = timer_bar.mSelfStart + timer_bar.mSelfTime / 2;
 	timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime;
 
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 9d88bb2d3f..8f61a2fc87 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -87,7 +87,7 @@ private:
 			mFirstChild(false),
 			mLastChild(false)
 		{}
-		LLUnit<F32, LLUnits::Seconds>	mTotalTime,
+		LLUnits::F32Seconds	mTotalTime,
 										mSelfTime,
 										mChildrenStart,
 										mChildrenEnd,
@@ -113,7 +113,7 @@ private:
 		TimerBar*	mBars;
 	};
 
-	LLUnit<F32, LLUnits::Seconds> updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
+	LLUnits::F32Seconds updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
 	S32 updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
 	S32 drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, bool visible = true, S32 bar_index = 0);
 	void setPauseState(bool pause_state);
@@ -128,7 +128,7 @@ private:
 		DISPLAY_HZ
 	}								mDisplayType;
 	bool							mPauseHistory;
-	LLUnit<F64, LLUnits::Seconds>	mAllTimeMax,
+	LLUnits::F64Seconds	mAllTimeMax,
 									mTotalTimeDisplay;
 	S32								mScrollIndex,
 									mHoverBarIndex,
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index f0c7a220a4..d16c2d3984 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -525,7 +525,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getResults();
 	const U32 frame_count = scene_load_recording.getNumRecordedPeriods();
 
-	LLUnit<F64, LLUnits::Seconds> frame_time;
+	LLUnits::F64Seconds frame_time;
 
 	os << "Stat";
 	for (S32 frame = 1; frame <= frame_count; frame++)
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 3335ff6631..3a3731d519 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1429,7 +1429,7 @@ bool idle_startup()
 
 		LL_DEBUGS("AppInit") << "Initializing camera..." << LL_ENDL;
 		gFrameTime    = totalTime();
-		LLUnit<F32, LLUnits::Seconds> last_time = gFrameTimeSeconds;
+		LLUnits::F32Seconds last_time = gFrameTimeSeconds;
 		gFrameTimeSeconds = (gFrameTime - gStartTime);
 
 		gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 17703fcc21..0e6ef76845 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -1888,12 +1888,11 @@ void LLTextureFetchWorker::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRe
 	
 	if (log_to_viewer_log || log_to_sim)
 	{
-		U64 timeNow = LLTimer::getTotalTime();
 		mFetcher->mTextureInfo.setRequestStartTime(mID, mMetricsStartTime.value());
 		mFetcher->mTextureInfo.setRequestType(mID, LLTextureInfoDetails::REQUEST_TYPE_HTTP);
 		mFetcher->mTextureInfo.setRequestSize(mID, mRequestedSize);
 		mFetcher->mTextureInfo.setRequestOffset(mID, mRequestedOffset);
-		mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, timeNow);
+		mFetcher->mTextureInfo.setRequestCompleteTimeAndLog(mID, LLTimer::getTotalTime());
 	}
 
 	bool success = true;
@@ -2394,7 +2393,7 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
 	  mFetcherLocked(FALSE)
 {
 	mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
-	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), LLUnits::Bytes::fromValue(gSavedSettings.getU32("TextureLoggingThreshold")));
+	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), LLUnits::U32Bytes(gSavedSettings.getU32("TextureLoggingThreshold")));
 
 	LLTextureFetchDebugger::sDebuggerEnabled = gSavedSettings.getBOOL("TextureFetchDebuggerEnabled");
 	if(LLTextureFetchDebugger::isEnabled())
@@ -2762,7 +2761,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
 			discard_level = worker->mDecodedDiscard;
 			raw = worker->mRawImage;
 			aux = worker->mAuxImage;
-			LLUnit<F32, LLUnits::Seconds> cache_read_time = worker->mCacheReadTime;
+			LLUnits::F32Seconds cache_read_time(worker->mCacheReadTime);
 			if (cache_read_time != 0.f)
 			{
 				record(sCacheReadLatency, cache_read_time);
diff --git a/indra/newview/lltextureinfo.cpp b/indra/newview/lltextureinfo.cpp
index cd6e7ff464..9dee92bf12 100755
--- a/indra/newview/lltextureinfo.cpp
+++ b/indra/newview/lltextureinfo.cpp
@@ -219,11 +219,11 @@ void LLTextureInfo::resetTextureStatistics()
 	mCurrentStatsBundleStartTime = LLTimer::getTotalTime();
 }
 
-LLUnit<U32, LLUnits::Microseconds> LLTextureInfo::getRequestStartTime(const LLUUID& id)
+LLUnits::U32Microseconds LLTextureInfo::getRequestStartTime(const LLUUID& id)
 {
 	if (!has(id))
 	{
-		return 0;
+		return LLUnits::U32Microseconds(0);
 	}
 	else
 	{
@@ -236,7 +236,7 @@ LLUnit<U32, LLUnits::Bytes> LLTextureInfo::getRequestSize(const LLUUID& id)
 {
 	if (!has(id))
 	{
-		return 0;
+		return LLUnits::U32Bytes(0);
 	}
 	else
 	{
@@ -275,7 +275,7 @@ LLUnit<U32, LLUnits::Microseconds> LLTextureInfo::getRequestCompleteTime(const L
 {
 	if (!has(id))
 	{
-		return 0;
+		return LLUnits::U32Microseconds(0);
 	}
 	else
 	{
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 501914a52f..c94064df5f 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -587,7 +587,7 @@ void LLGLTexMemBar::draw()
 
 	left = 550;
 	LLUnit<F32, LLUnits::Kibibits> bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
-	LLUnit<F32, LLUnits::Kibibits> max_bandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
+	LLUnit<F32, LLUnits::Kibibits> 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());
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index 579567bb14..b176c69691 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -233,7 +233,7 @@ namespace LLViewerAssetStatsFF
 		&sDequeuedAssetRequestsOther            
 	};
 
-	static LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp",
+	static LLTrace::EventStatHandle<LLUnits::F64Seconds >	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp",
 																							"Time spent responding to temporary texture asset http requests"),
 													sResponseAssetRequestsTempTextureUDP    ("assetresponsetimestemptextureudp", 
 																							"Time spent responding to temporary texture asset udp requests"),
@@ -250,7 +250,7 @@ namespace LLViewerAssetStatsFF
 													sResponsedAssetRequestsOther            ("assetresponsetimesother", 
 																							"Time spent responding to other asset requests");
 
-	static LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >* sResponse[EVACCount] = {
+	static LLTrace::EventStatHandle<LLUnits::F64Seconds >* sResponse[EVACCount] = {
 		&sResponseAssetRequestsTempTextureHTTP,   
 		&sResponseAssetRequestsTempTextureUDP,  
 		&sResponseAssetRequestsNonTempTextureHTTP,
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index e8f68527e9..a8183e76b4 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -999,9 +999,9 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	// Time _can_ go backwards, for example if the user changes the system clock.
 	// It doesn't cause any fatal problems (just some oddness with stats), so we shouldn't assert here.
 //	llassert(time > gFrameTime);
-	LLUnit<F64, LLUnits::Seconds> time_diff = time - gFrameTime;
+	LLUnits::F64Seconds time_diff = time - gFrameTime;
 	gFrameTime	= time;
-	LLUnit<F64, LLUnits::Seconds> time_since_start = gFrameTime - gStartTime;
+	LLUnits::F64Seconds time_since_start = gFrameTime - gStartTime;
 	gFrameTimeSeconds = time_since_start;
 
 	gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 8cb519b098..568d4b42ca 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -104,7 +104,7 @@ LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >
 							MESSAGE_SYSTEM_DATA_IN("messagedatain", "Incoming message system network data"),
 							MESSAGE_SYSTEM_DATA_OUT("messagedataout", "Outgoing message system network data");
 
-LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >	
+LLTrace::CountStatHandle<LLUnits::F64Seconds >	
 							SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
 							SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
 							LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
@@ -194,7 +194,7 @@ LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROSSING_TI
 																REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
 																RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
 	
-LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
+LLTrace::EventStatHandle<LLUnits::F64Seconds >	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
 															TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
 															MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
 															FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
@@ -219,7 +219,7 @@ void LLViewerStats::resetStats()
 	LLViewerStats::instance().mRecording.reset();
 }
 
-void LLViewerStats::updateFrameStats(const LLUnit<F64, LLUnits::Seconds> time_diff)
+void LLViewerStats::updateFrameStats(const LLUnits::F64Seconds time_diff)
 {
 	if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0)
 	{
@@ -299,13 +299,13 @@ F32		gAveLandCompression = 0.f,
 		gWorstLandCompression = 0.f, 
 		gWorstWaterCompression = 0.f;
 
-LLUnit<U32, LLUnits::Bytes>		gTotalWorldData = 0, 
-								gTotalObjectData = 0, 
-								gTotalTextureData = 0;
+LLUnits::U32Bytes				gTotalWorldData, 
+								gTotalObjectData, 
+								gTotalTextureData;
 U32								gSimPingCount = 0;
-LLUnit<U32, LLUnits::Bits>		gObjectData = 0;
+LLUnits::U32Bits				gObjectData;
 F32		gAvgSimPing = 0.f;
-LLUnit<U32, LLUnits::Bytes>		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {0};
+LLUnits::U32Bytes		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {LLUnits::U32Bytes(0)};
 
 extern U32  gVisCompared;
 extern U32  gVisTested;
@@ -345,8 +345,8 @@ void update_statistics()
 
 	typedef LLInstanceTracker<LLTrace::TraceType<LLTrace::TimeBlockAccumulator>, std::string> trace_type_t;
 
-	LLUnit<F64, LLUnits::Seconds> idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
-	LLUnit<F64, LLUnits::Seconds> network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
+	LLUnits::F64Seconds idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
+	LLUnits::F64Seconds network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
 
 	record(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Frame")));
 	record(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs);
@@ -364,7 +364,7 @@ void update_statistics()
 	}
 	else
 	{
-		sample(LLStatViewer::SIM_PING, LLUnits::Seconds::fromValue(10));
+		sample(LLStatViewer::SIM_PING, LLUnits::U32Seconds(10));
 	}
 
 	if (LLViewerStats::instance().getRecording().getSum(LLStatViewer::FPS))
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index b580606326..2cea575252 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -150,7 +150,7 @@ extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	ACTIVE_MESSAGE
 																	MESSAGE_SYSTEM_DATA_IN,
 																	MESSAGE_SYSTEM_DATA_OUT;
 
-extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Seconds> >		SIM_20_FPS_TIME,
+extern LLTrace::CountStatHandle<LLUnits::F64Seconds >		SIM_20_FPS_TIME,
 																	SIM_PHYSICS_20_FPS_TIME,
 																	LOSS_5_PERCENT_TIME;
 
@@ -233,7 +233,7 @@ extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROS
 														REBUILD_STACKTIME,
 														RENDER_STACKTIME;
 
-extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Seconds> >	AVATAR_EDIT_TIME,
+extern LLTrace::EventStatHandle<LLUnits::F64Seconds >	AVATAR_EDIT_TIME,
 																TOOLBOX_TIME,
 																MOUSELOOK_TIME,
 																FPS_10_TIME,
@@ -254,7 +254,7 @@ public:
 	LLViewerStats();
 	~LLViewerStats();
 
-	void updateFrameStats(const LLUnit<F64, LLUnits::Seconds> time_diff);
+	void updateFrameStats(const LLUnits::F64Seconds time_diff);
 	
 	void addToMessage(LLSD &body);
 
@@ -370,7 +370,7 @@ public:
 private:
 	LLTrace::Recording				mRecording;
 
-	LLUnit<F64, LLUnits::Seconds> mLastTimeDiff;  // used for time stat updates
+	LLUnits::F64Seconds mLastTimeDiff;  // used for time stat updates
 };
 
 static const F32 SEND_STATS_PERIOD = 300.0f;
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index eb8faacac2..c780814e50 100755
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -63,8 +63,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 // extern
-const LLUnit<S32, LLUnits::Mibibytes> gMinVideoRam = 32;
-const LLUnit<S32, LLUnits::Mibibytes> gMaxVideoRam = 512;
+const LLUnit<S32, LLUnits::Mibibytes> gMinVideoRam(32);
+const LLUnit<S32, LLUnits::Mibibytes> gMaxVideoRam(512);
 
 
 // statics
@@ -86,11 +86,11 @@ S32 LLViewerTexture::sAuxCount = 0;
 LLFrameTimer LLViewerTexture::sEvaluationTimer;
 F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
 F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
-LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sBoundTextureMemory = 0;
-LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sTotalTextureMemory = 0;
-LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxBoundTextureMem = 0;
-LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxTotalTextureMem = 0;
-LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sMaxDesiredTextureMem = 0 ;
+LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sBoundTextureMemory;
+LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sTotalTextureMemory;
+LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxBoundTextureMem;
+LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxTotalTextureMem;
+LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sMaxDesiredTextureMem;
 S8  LLViewerTexture::sCameraMovingDiscardBias = 0 ;
 F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
 S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
@@ -530,10 +530,10 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		LLViewerMediaTexture::updateClass() ;
 	}
 
-	sBoundTextureMemory = LLImageGL::sBoundTextureMemory;//in bytes
-	sTotalTextureMemory = LLImageGL::sGlobalTextureMemory;//in bytes
-	sMaxBoundTextureMem = gTextureList.getMaxResidentTexMem();//in MB	
-	sMaxTotalTextureMem = gTextureList.getMaxTotalTextureMem() ;//in MB
+	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.
 
 	if (sBoundTextureMemory >= sMaxBoundTextureMem ||
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 63debe0464..2030b490e4 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -1327,7 +1327,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem)
 	mMaxTotalTextureMemInMegaBytes = mMaxResidentTexMemInMegaBytes * 2;
 	if (mMaxResidentTexMemInMegaBytes > 640)
 	{
-		mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes >> 2);
+		mMaxTotalTextureMemInMegaBytes -= (mMaxResidentTexMemInMegaBytes / 4);
 	}
 
 	//system mem
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 5b6e927e32..673b55be69 100755
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -101,8 +101,8 @@ public:
 
 	void setUpdateStats(BOOL b)			{ mUpdateStats = b; }
 
-	S32	getMaxResidentTexMem() const	{ return mMaxResidentTexMemInMegaBytes; }
-	S32 getMaxTotalTextureMem() const   { return mMaxTotalTextureMemInMegaBytes;}
+	LLUnit<S32, LLUnits::Mibibytes>	getMaxResidentTexMem() const	{ return mMaxResidentTexMemInMegaBytes; }
+	LLUnit<S32, LLUnits::Mibibytes> getMaxTotalTextureMem() const   { return mMaxTotalTextureMemInMegaBytes;}
 	S32 getNumImages()					{ return mImageList.size(); }
 
 	void updateMaxResidentTexMem(S32 mem);
@@ -200,8 +200,8 @@ private:
 
 	BOOL mInitialized ;
 	BOOL mUpdateStats;
-	S32	mMaxResidentTexMemInMegaBytes;
-	S32 mMaxTotalTextureMemInMegaBytes;
+	LLUnit<S32, LLUnits::Mibibytes>	mMaxResidentTexMemInMegaBytes;
+	LLUnit<S32, LLUnits::Mibibytes> mMaxTotalTextureMemInMegaBytes;
 	LLFrameTimer mForceDecodeTimer;
 	
 private:
diff --git a/indra/newview/llviewerthrottle.cpp b/indra/newview/llviewerthrottle.cpp
index 916dec86aa..22de7e150b 100755
--- a/indra/newview/llviewerthrottle.cpp
+++ b/indra/newview/llviewerthrottle.cpp
@@ -48,8 +48,8 @@ const F32 MIN_FRACTIONAL = 0.2f;
 const F32 MIN_BANDWIDTH = 50.f;
 const F32 MAX_BANDWIDTH = 3000.f;
 const F32 STEP_FRACTIONAL = 0.1f;
-const LLUnit<F32, LLUnits::Percent> TIGHTEN_THROTTLE_THRESHOLD = 3.0f; // packet loss % per s
-const LLUnit<F32, LLUnits::Percent> EASE_THROTTLE_THRESHOLD = 0.5f; // packet loss % per s
+const LLUnit<F32, LLUnits::Percent> TIGHTEN_THROTTLE_THRESHOLD(3.0f); // packet loss % per s
+const LLUnit<F32, LLUnits::Percent> EASE_THROTTLE_THRESHOLD(0.5f); // packet loss % per s
 const F32 DYNAMIC_UPDATE_DURATION = 5.0f; // seconds
 
 LLViewerThrottle gViewerThrottle;
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 12b9744b24..66206fe53e 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -899,7 +899,7 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 		if (mLastRegionHandle != 0)
 		{
 			++mRegionCrossingCount;
-			LLUnit<F64, LLUnits::Seconds> delta = mRegionCrossingTimer.getElapsedTimeF32();
+			LLUnits::F64Seconds delta(mRegionCrossingTimer.getElapsedTimeF32());
 			record(LLStatViewer::REGION_CROSSING_TIME, delta);
 
 			// Diagnostics
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 5e8a771929..31b7e5a01c 100755
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -6547,7 +6547,7 @@ void LLVivoxVoiceClient::expireVoiceFonts()
 	// Give a warning notification if any voice fonts are due to expire.
 	if (will_expire)
 	{
-		LLUnit<S32, LLUnits::Seconds> seconds = gSavedSettings.getS32("VoiceEffectExpiryWarningTime");
+		LLUnit<S32, LLUnits::Seconds> seconds(gSavedSettings.getS32("VoiceEffectExpiryWarningTime"));
 		args["INTERVAL"] = llformat("%d", LLUnit<S32, LLUnits::Days>(seconds).value());
 
 		LLNotificationsUtil::add("VoiceEffectsWillExpire", args);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 7e4e80240d..38818e242b 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -717,7 +717,7 @@ void LLWorld::renderPropertyLines()
 
 void LLWorld::updateNetStats()
 {
-	LLUnit<F64, LLUnits::Bits> bits = 0.f;
+	LLUnits::F64Bits bits;
 	U32 packets = 0;
 
 	for (region_list_t::iterator iter = mActiveRegionList.begin();
@@ -735,8 +735,8 @@ void LLWorld::updateNetStats()
 	S32 packets_out = gMessageSystem->mPacketsOut - mLastPacketsOut;
 	S32 packets_lost = gMessageSystem->mDroppedPackets - mLastPacketsLost;
 
-	LLUnit<F64, LLUnits::Bits> actual_in_bits = gMessageSystem->mPacketRing.getAndResetActualInBits();
-	LLUnit<F64, LLUnits::Bits> actual_out_bits = gMessageSystem->mPacketRing.getAndResetActualOutBits();
+	LLUnit<F64, LLUnits::Bits> actual_in_bits(gMessageSystem->mPacketRing.getAndResetActualInBits());
+	LLUnit<F64, LLUnits::Bits> actual_out_bits(gMessageSystem->mPacketRing.getAndResetActualOutBits());
 
 	add(LLStatViewer::MESSAGE_SYSTEM_DATA_IN, actual_in_bits);
 	add(LLStatViewer::MESSAGE_SYSTEM_DATA_OUT, actual_out_bits);
-- 
cgit v1.2.3


From a9c7cc486f4de721d42279263af33b272e15c830 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 14 Aug 2013 14:55:12 -0600
Subject: remove some code which has nagetive impact on memory footprint.

---
 indra/newview/llviewerregion.cpp | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index cfe765a1cb..5cdf43486e 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1205,12 +1205,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 
 	max_update_time -= update_timer.getElapsedTimeF32();	
 
-	if(sNewObjectCreationThrottle < 0 && (LLStartUp::getStartupState() < STATE_STARTED || gTeleportDisplay))
-	{
-		//apply octree cullings here to pick up visible objects because rendering pipeline stops view culling at this moment
-		mImpl->mVOCachePartition->cull(*LLViewerCamera::getInstance(), false);
-	}	
-	else if(max_update_time < 0.f)
+	if(max_update_time < 0.f)
 	{
 		return did_update;
 	}
-- 
cgit v1.2.3


From 23214506d280b485cc74372a9dbb8d6b8c3937c5 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 14 Aug 2013 14:56:35 -0600
Subject: enable far clip plane culling on object cache view culling

---
 indra/newview/llvocache.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 7dfa131ebf..67a0b58241 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -531,7 +531,7 @@ public:
 
 	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
 	{
-#if 0
+#if 1
 		S32 res = AABBInRegionFrustumGroupBounds(group);
 #else	
 		S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
@@ -545,7 +545,7 @@ public:
 
 	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
 	{
-#if 0
+#if 1
 		S32 res = AABBInRegionFrustumObjectBounds(group);
 #else
 		S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
-- 
cgit v1.2.3


From d83c51a4e1923508e31f25576761f001d731ea93 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 14 Aug 2013 21:58:30 -0700
Subject: BUILDFIX: converted platform-specific files over to new LL_INFOS, etc
 macros

---
 indra/newview/llappviewerlinux.cpp                  | 18 +++++++++---------
 indra/newview/llappviewerlinux_api_dbus.cpp         |  6 +++---
 indra/newview/llappviewermacosx.cpp                 | 12 ++++++------
 indra/newview/llface.inl                            |  6 +++---
 indra/newview/llimpanel.cpp                         | 14 +++++++-------
 indra/newview/llsrv.cpp                             |  2 +-
 indra/newview/lltoolview.cpp                        |  2 +-
 indra/newview/tests/lltexturestatsuploader_test.cpp |  2 +-
 8 files changed, 31 insertions(+), 31 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp
index b16bb573e1..80f249612a 100755
--- a/indra/newview/llappviewerlinux.cpp
+++ b/indra/newview/llappviewerlinux.cpp
@@ -87,7 +87,7 @@ int main( int argc, char **argv )
 	bool ok = viewer_app_ptr->init();
 	if(!ok)
 	{
-		llwarns << "Application init failed." << llendl;
+		LL_WARNS() << "Application init failed." << LL_ENDL;
 		return -1;
 	}
 
@@ -207,7 +207,7 @@ void viewerappapi_init(ViewerAppAPI *server)
 			}
 			else 
 			{
-				llwarns << "Unable to register service name: " << error->message << llendl;
+				LL_WARNS() << "Unable to register service name: " << error->message << LL_ENDL;
 			}
 	
 			g_object_unref(serverproxy);
@@ -226,7 +226,7 @@ gboolean viewer_app_api_GoSLURL(ViewerAppAPI *obj, gchar *slurl, gboolean **succ
 {
 	bool success = false;
 
-	llinfos << "Was asked to go to slurl: " << slurl << llendl;
+	LL_INFOS() << "Was asked to go to slurl: " << slurl << LL_ENDL;
 
 	std::string url = slurl;
 	LLMediaCtrl* web = NULL;
@@ -292,14 +292,14 @@ bool LLAppViewerLinux::sendURLToOtherInstance(const std::string& url)
 		}
 		else
 		{
-			llinfos << "Call-out to other instance failed (perhaps not running): " << error->message << llendl;
+			LL_INFOS() << "Call-out to other instance failed (perhaps not running): " << error->message << LL_ENDL;
 		}
 
 		g_object_unref(G_OBJECT(remote_object));
 	}
 	else
 	{
-		llwarns << "Couldn't connect to session bus: " << error->message << llendl;
+		LL_WARNS() << "Couldn't connect to session bus: " << error->message << LL_ENDL;
 	}
 
 	if (error)
@@ -343,7 +343,7 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze)
 		if (pid == 0)
 		{ // child
 			execv(cmd.c_str(), cmdargv);		/* Flawfinder: Ignore */
-			llwarns << "execv failure when trying to start " << cmd << llendl;
+			LL_WARNS() << "execv failure when trying to start " << cmd << LL_ENDL;
 			_exit(1); // avoid atexit()
 		} else {
 			if (pid > 0)
@@ -352,7 +352,7 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze)
 				int childExitStatus;
 				waitpid(pid, &childExitStatus, 0);
 			} else {
-				llwarns << "fork failure." << llendl;
+				LL_WARNS() << "fork failure." << LL_ENDL;
 			}
 		}
 	}
@@ -371,7 +371,7 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze)
 		if (pid == 0)
 		{ // child
 			execv(cmd.c_str(), (char* const*) cmdargv);		/* Flawfinder: ignore */
-			llwarns << "execv failure when trying to start " << cmd << llendl;
+			LL_WARNS() << "execv failure when trying to start " << cmd << LL_ENDL;
 			_exit(1); // avoid atexit()
 		} 
 		else
@@ -386,7 +386,7 @@ void LLAppViewerLinux::handleCrashReporting(bool reportFreeze)
 			} 
 			else
 			{
-				llwarns << "fork failure." << llendl;
+				LL_WARNS() << "fork failure." << LL_ENDL;
 			}
 		}
 		// Sometimes signals don't seem to quit the viewer.  Also, we may
diff --git a/indra/newview/llappviewerlinux_api_dbus.cpp b/indra/newview/llappviewerlinux_api_dbus.cpp
index 32e7e0a83d..6ac30bd9b8 100755
--- a/indra/newview/llappviewerlinux_api_dbus.cpp
+++ b/indra/newview/llappviewerlinux_api_dbus.cpp
@@ -35,9 +35,9 @@ extern "C" {
 #include "apr_dso.h"
 }
 
-#define DEBUGMSG(...) do { lldebugs << llformat(__VA_ARGS__) << llendl; } while(0)
-#define INFOMSG(...) do { llinfos << llformat(__VA_ARGS__) << llendl; } while(0)
-#define WARNMSG(...) do { llwarns << llformat(__VA_ARGS__) << llendl; } while(0)
+#define DEBUGMSG(...) do { LL_DEBUGS() << llformat(__VA_ARGS__) << LL_ENDL; } while(0)
+#define INFOMSG(...) do { LL_INFOS() << llformat(__VA_ARGS__) << LL_ENDL; } while(0)
+#define WARNMSG(...) do { LL_WARNS() << llformat(__VA_ARGS__) << LL_ENDL; } while(0)
 
 #define LL_DBUS_SYM(REQUIRED, DBUSSYM, RTN, ...) RTN (*ll##DBUSSYM)(__VA_ARGS__) = NULL
 #include "llappviewerlinux_api_dbus_syms_raw.inc"
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp
index 4d340cafa9..8d6d52185a 100755
--- a/indra/newview/llappviewermacosx.cpp
+++ b/indra/newview/llappviewermacosx.cpp
@@ -72,9 +72,9 @@ int main( int argc, char **argv )
 	// Set the working dir to <bundle>/Contents/Resources
 	if (chdir(gDirUtilp->getAppRODataDir().c_str()) == -1)
 	{
-		llwarns << "Could not change directory to "
+		LL_WARNS() << "Could not change directory to "
 				<< gDirUtilp->getAppRODataDir() << ": " << strerror(errno)
-				<< llendl;
+				<< LL_ENDL;
 	}
 
 	LLAppViewerMacOSX* viewer_app_ptr = new LLAppViewerMacOSX();
@@ -88,7 +88,7 @@ int main( int argc, char **argv )
 	bool ok = viewer_app_ptr->init();
 	if(!ok)
 	{
-		llwarns << "Application init failed." << llendl;
+		LL_WARNS() << "Application init failed." << LL_ENDL;
 		return -1;
 	}
 
@@ -154,7 +154,7 @@ bool LLAppViewerMacOSX::initParseCommandLine(LLCommandLineParser& clp)
 	llifstream ifs(filename, llifstream::binary);
 	if (!ifs.is_open())
 	{
-		llwarns << "Unable to open file" << filename << llendl;
+		LL_WARNS() << "Unable to open file" << filename << LL_ENDL;
 		return false;
 	}
 	
@@ -561,13 +561,13 @@ void init_apple_menu(const char* product)
 	if(AEInstallEventHandler('GURL', 'GURL', NewAEEventHandlerUPP(AEGURLHandler),0, false) != noErr)
 	{
 		// Couldn't install AppleEvent handler.  This error shouldn't be fatal.
-		llinfos << "Couldn't install 'GURL' AppleEvent handler.  Continuing..." << llendl;
+		LL_INFOS() << "Couldn't install 'GURL' AppleEvent handler.  Continuing..." << LL_ENDL;
 	}
 
 	// Install a handler for 'quit' AppleEvents.  This makes quitting the application from the dock work.
 	if(AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(AEQuitHandler),0, false) != noErr)
 	{
 		// Couldn't install AppleEvent handler.  This error shouldn't be fatal.
-		llinfos << "Couldn't install Quit AppleEvent handler.  Continuing..." << llendl;
+		LL_INFOS() << "Couldn't install Quit AppleEvent handler.  Continuing..." << LL_ENDL;
 	}
 }
diff --git a/indra/newview/llface.inl b/indra/newview/llface.inl
index 85c35a88f3..c37b77d2cd 100755
--- a/indra/newview/llface.inl
+++ b/indra/newview/llface.inl
@@ -77,7 +77,7 @@ inline S32	LLFace::getColors     (LLStrider<LLColor4U> &colors)
 		if (!mBackupMem)
 		{
 			printDebugInfo();
-			llerrs << "No backup memory for face" << llendl;
+			LL_ERRS() << "No backup memory for face" << LL_ENDL;
 		}
 		colorp = (LLColor4U*)(mBackupMem + (4 * mIndicesCount) + (mGeomCount * mDrawPoolp->getStride()));
 		colors = colorp;
@@ -89,7 +89,7 @@ inline S32	LLFace::getColors     (LLStrider<LLColor4U> &colors)
 		if (!mDrawPoolp->getColorStrider(colors, mGeomIndex))
 		{
 			printDebugInfo();
-			llerrs << "No color pointer for a color strider!" << llendl;
+			LL_ERRS() << "No color pointer for a color strider!" << LL_ENDL;
 		}
 		mDrawPoolp->setDirtyColors();
 		return mGeomIndex;
@@ -107,7 +107,7 @@ inline S32	LLFace::getTexCoords  (LLStrider<LLVector2> &texCoords, S32 pass )
 		if (!mBackupMem)
 		{
 			printDebugInfo();
-			llerrs << "No backup memory for face" << llendl;
+			LL_ERRS() << "No backup memory for face" << LL_ENDL;
 		}
 		texCoords = (LLVector2*)(mBackupMem + (4 * mIndicesCount) + mDrawPoolp->mDataOffsets[LLDrawPool::DATA_TEX_COORDS0 + pass]);
 		texCoords.setStride( mDrawPoolp->getStride());
diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp
index 59272d721f..34ccab0302 100755
--- a/indra/newview/llimpanel.cpp
+++ b/indra/newview/llimpanel.cpp
@@ -159,7 +159,7 @@ LLFloaterIMPanel::LLFloaterIMPanel(const std::string& session_label,
 		mCallBackEnabled = LLVoiceClient::getInstance()->isSessionCallBackPossible(mSessionUUID);
 		break;
 	default:
-		llwarns << "Unknown session type" << llendl;
+		LL_WARNS() << "Unknown session type" << LL_ENDL;
 		xml_filename = "floater_instant_message.xml";
 		break;
 	}
@@ -396,8 +396,8 @@ public:
 
 	void errorWithContent(U32 statusNum, const std::string& reason, const LLSD& content)
 	{
-		llwarns << "Error inviting all agents to session [status:" 
-				<< statusNum << "]: " << content << llendl;
+		LL_WARNS() << "Error inviting all agents to session [status:" 
+				<< statusNum << "]: " << content << LL_ENDL;
 		//throw something back to the viewer here?
 	}
 
@@ -417,7 +417,7 @@ BOOL LLFloaterIMPanel::inviteToSession(const std::vector<LLUUID>& ids)
 
 	if( isInviteAllowed() && (count > 0) )
 	{
-		llinfos << "LLFloaterIMPanel::inviteToSession() - inviting participants" << llendl;
+		LL_INFOS() << "LLFloaterIMPanel::inviteToSession() - inviting participants" << LL_ENDL;
 
 		std::string url = region->getCapability("ChatSessionRequest");
 
@@ -439,9 +439,9 @@ BOOL LLFloaterIMPanel::inviteToSession(const std::vector<LLUUID>& ids)
 	}
 	else
 	{
-		llinfos << "LLFloaterIMPanel::inviteToSession -"
+		LL_INFOS() << "LLFloaterIMPanel::inviteToSession -"
 				<< " no need to invite agents for "
-				<< mDialog << llendl;
+				<< mDialog << LL_ENDL;
 		// successful add, because everyone that needed to get added
 		// was added.
 	}
@@ -778,7 +778,7 @@ void LLFloaterIMPanel::sendMsg()
 		&& (mDialog == IM_NOTHING_SPECIAL)
 		&& mOtherParticipantUUID.isNull())
 	{
-		llinfos << "Cannot send IM to everyone unless you're a god." << llendl;
+		LL_INFOS() << "Cannot send IM to everyone unless you're a god." << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llsrv.cpp b/indra/newview/llsrv.cpp
index 567c2a0158..8b9aead165 100755
--- a/indra/newview/llsrv.cpp
+++ b/indra/newview/llsrv.cpp
@@ -35,7 +35,7 @@ struct Responder : public LLAres::UriRewriteResponder
 	void rewriteResult(const std::vector<std::string> &uris) {
 		for (size_t i = 0; i < uris.size(); i++)
 		{
-			llinfos << "[" << i << "] " << uris[i] << llendl;
+			LL_INFOS() << "[" << i << "] " << uris[i] << LL_ENDL;
 		}
 		mUris = uris;
 	}
diff --git a/indra/newview/lltoolview.cpp b/indra/newview/lltoolview.cpp
index 8c40ff3cb3..678e2c241a 100755
--- a/indra/newview/lltoolview.cpp
+++ b/indra/newview/lltoolview.cpp
@@ -179,7 +179,7 @@ LLToolContainer* LLToolView::findToolContainer( LLTool *tool )
 			return contain;
 		}
 	}
-	llerrs << "LLToolView::findToolContainer - tool not found" << llendl;
+	LL_ERRS() << "LLToolView::findToolContainer - tool not found" << LL_ENDL;
 	return NULL;
 }
 
diff --git a/indra/newview/tests/lltexturestatsuploader_test.cpp b/indra/newview/tests/lltexturestatsuploader_test.cpp
index cfb2c267cc..4438523022 100755
--- a/indra/newview/tests/lltexturestatsuploader_test.cpp
+++ b/indra/newview/tests/lltexturestatsuploader_test.cpp
@@ -111,7 +111,7 @@ namespace tut
 	void texturestatsuploader_object_t::test<1>()
 	{
 		LLTextureStatsUploader tsu;
-		llinfos << &tsu << llendl;
+		LL_INFOS() << &tsu << LL_ENDL;
 		ensure("have we crashed?", true);
 	}
 
-- 
cgit v1.2.3


From 9f7bfa1c3710856cd2b0a0a8a429d6c45b0fcd09 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 15 Aug 2013 00:02:23 -0700
Subject: moved unit types out of LLUnits namespace, since they are prefixed

---
 indra/newview/llconversationlog.cpp     |  6 ++--
 indra/newview/llconversationlog.h       |  6 ++--
 indra/newview/llconversationloglist.cpp |  4 +--
 indra/newview/llfasttimerview.cpp       | 36 +++++++++++-----------
 indra/newview/llfasttimerview.h         |  6 ++--
 indra/newview/llscenemonitor.cpp        |  2 +-
 indra/newview/llstartup.cpp             |  2 +-
 indra/newview/lltexturefetch.cpp        |  8 ++---
 indra/newview/lltexturefetch.h          | 12 ++++----
 indra/newview/lltextureinfo.cpp         | 26 ++++++++--------
 indra/newview/lltextureinfo.h           | 14 ++++-----
 indra/newview/lltextureinfodetails.h    |  4 +--
 indra/newview/lltextureview.cpp         | 20 ++++++------
 indra/newview/llviewerassetstats.cpp    | 10 +++---
 indra/newview/llviewerassetstats.h      |  2 +-
 indra/newview/llviewermessage.cpp       | 18 +++++------
 indra/newview/llviewerobjectlist.cpp    |  6 ++--
 indra/newview/llviewerstats.cpp         | 54 ++++++++++++++++-----------------
 indra/newview/llviewerstats.h           | 30 +++++++++---------
 indra/newview/llviewertexture.cpp       | 16 +++++-----
 indra/newview/llviewertexture.h         | 14 ++++-----
 indra/newview/llviewertexturelist.cpp   |  8 ++---
 indra/newview/llviewertexturelist.h     |  8 ++---
 indra/newview/llviewerwindow.cpp        |  2 +-
 indra/newview/llvoavatarself.cpp        |  2 +-
 indra/newview/llvoicevivox.cpp          |  2 +-
 indra/newview/llworld.cpp               |  6 ++--
 27 files changed, 162 insertions(+), 162 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index a17a4e5e21..9311056a27 100755
--- a/indra/newview/llconversationlog.cpp
+++ b/indra/newview/llconversationlog.cpp
@@ -39,7 +39,7 @@ const int CONVERSATION_LIFETIME = 30; // lifetime of LLConversation is 30 days b
 
 struct ConversationParams : public LLInitParam::Block<ConversationParams>
 {
-	Mandatory<LLUnit<U64, LLUnits::Seconds> >	time;
+	Mandatory<U64Seconds >	time;
 	Mandatory<std::string>						timestamp;
 	Mandatory<SessionType>						conversation_type;
 	Mandatory<std::string>						conversation_name,
@@ -113,7 +113,7 @@ void LLConversation::onIMFloaterShown(const LLUUID& session_id)
 }
 
 // static
-const std::string LLConversation::createTimestamp(const LLUnit<U64, LLUnits::Seconds>& utc_time)
+const std::string LLConversation::createTimestamp(const U64Seconds& utc_time)
 {
 	std::string timeStr;
 	LLSD substitution;
@@ -132,7 +132,7 @@ const std::string LLConversation::createTimestamp(const LLUnit<U64, LLUnits::Sec
 
 bool LLConversation::isOlderThan(U32 days) const
 {
-	LLUnit<U64, LLUnits::Seconds> now(time_corrected());
+	U64Seconds now(time_corrected());
 	LLUnit<U32, LLUnits::Days> age = now - mTime;
 
 	return age > days;
diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h
index 5d94cb6497..fd6ad9ad66 100755
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -55,7 +55,7 @@ public:
 	const LLUUID&		getSessionID()			const	{ return mSessionID; }
 	const LLUUID&		getParticipantID()		const	{ return mParticipantID; }
 	const std::string&	getTimestamp()			const	{ return mTimestamp; }
-	const LLUnit<U64, LLUnits::Seconds>&
+	const U64Seconds&
 						getTime()				const	{ return mTime; }
 	bool				hasOfflineMessages()	const	{ return mHasOfflineIMs; }
 
@@ -76,7 +76,7 @@ public:
 	/*
 	 * returns string representation(in form of: mm/dd/yyyy hh:mm) of time when conversation was started
 	 */
-	static const std::string createTimestamp(const LLUnit<U64, LLUnits::Seconds>& utc_time);
+	static const std::string createTimestamp(const U64Seconds& utc_time);
 
 private:
 
@@ -88,7 +88,7 @@ private:
 
 	boost::signals2::connection mIMFloaterShowedConnection;
 
-	LLUnit<U64, LLUnits::Seconds> mTime; // last interaction time
+	U64Seconds mTime; // last interaction time
 	SessionType		mConversationType;
 	std::string		mConversationName;
 	std::string		mHistoryFileName;
diff --git a/indra/newview/llconversationloglist.cpp b/indra/newview/llconversationloglist.cpp
index bd5e0b8f88..93719ac7fb 100755
--- a/indra/newview/llconversationloglist.cpp
+++ b/indra/newview/llconversationloglist.cpp
@@ -518,8 +518,8 @@ bool LLConversationLogListNameComparator::doCompare(const LLConversationLogListI
 
 bool LLConversationLogListDateComparator::doCompare(const LLConversationLogListItem* conversation1, const LLConversationLogListItem* conversation2) const
 {
-	LLUnit<U64, LLUnits::Seconds> date1 = conversation1->getConversation()->getTime();
-	LLUnit<U64, LLUnits::Seconds> date2 = conversation2->getConversation()->getTime();
+	U64Seconds date1 = conversation1->getConversation()->getTime();
+	U64Seconds date2 = conversation2->getConversation()->getTime();
 	const LLUUID& id1 = conversation1->getConversation()->getParticipantID();
 	const LLUUID& id2 = conversation2->getConversation()->getParticipantID();
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 11a9a70b18..725a2f2daf 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -260,7 +260,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 		TimerBarRow& row = mHoverBarIndex == 0 ? mAverageTimerRow : mTimerBarRows[mScrollIndex + mHoverBarIndex - 1];
 
 		TimerBar* hover_bar = NULL;
-		LLUnits::F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay;
+		F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay;
 		for (int bar_index = 0, end_index = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount(); 
 			bar_index < end_index; 
 			++bar_index)
@@ -317,11 +317,11 @@ static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicReco
 	if (history_index == 0)
 	{
 		// by default, show average number of call
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<F64, LLUnits::Milliseconds>(frame_recording.getPeriodMean (timer, RUNNING_AVERAGE_WIDTH)).value(), (S32)frame_recording.getPeriodMean(timer.callCount(), RUNNING_AVERAGE_WIDTH));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)F64Milliseconds(frame_recording.getPeriodMean (timer, RUNNING_AVERAGE_WIDTH)).value(), (S32)frame_recording.getPeriodMean(timer.callCount(), RUNNING_AVERAGE_WIDTH));
 	}
 	else
 	{
-		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)LLUnit<F64, LLUnits::Milliseconds>(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount()));
+		tooltip = llformat("%s (%d ms, %d calls)", timer.getName().c_str(), (S32)F64Milliseconds(frame_recording.getPrevRecording(history_index).getSum(timer)).value(), (S32)frame_recording.getPrevRecording(history_index).getSum(timer.callCount()));
 	}
 	return tooltip;
 }
@@ -996,7 +996,7 @@ void LLFastTimerView::printLineStats()
 			}
 			first = false;
 
-			LLUnits::F32Seconds ticks;
+			F32Seconds ticks;
 			if (mStatsIndex == 0)
 			{
 				ticks = mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH);
@@ -1005,7 +1005,7 @@ void LLFastTimerView::printLineStats()
 			{
 				ticks = mRecording.getPrevRecording(mStatsIndex).getSum(*idp);
 			}
-			LLUnit<F32, LLUnits::Milliseconds> ms = ticks;
+			F32Milliseconds ms = ticks;
 
 			timer_stat += llformat("%.1f",ms.value());
 
@@ -1029,7 +1029,7 @@ void LLFastTimerView::drawLineGraph()
 	LLLocalClipRect clip(mGraphRect);
 
 	//normalize based on last frame's maximum
-	static LLUnits::F32Seconds max_time(0.000001);
+	static F32Seconds max_time(0.000001);
 	static U32 max_calls = 0;
 	static F32 alpha_interp = 0.f;
 
@@ -1060,7 +1060,7 @@ void LLFastTimerView::drawLineGraph()
 		}
 	}
 
-	LLUnits::F32Seconds cur_max(0);
+	F32Seconds cur_max(0);
 	U32 cur_max_calls = 0;
 	for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 		it != end_timer_tree();
@@ -1101,7 +1101,7 @@ void LLFastTimerView::drawLineGraph()
 			j--)
 		{
 			LLTrace::Recording& recording = mRecording.getPrevRecording(j);
-			LLUnits::F32Seconds time = llmax(recording.getSum(*idp), LLUnits::F64Seconds(0.000001));
+			F32Seconds time = llmax(recording.getSum(*idp), F64Seconds(0.000001));
 			U32 calls = recording.getSum(idp->callCount());
 
 			if (is_hover_timer)
@@ -1146,7 +1146,7 @@ void LLFastTimerView::drawLineGraph()
 	max_time = lerp(max_time.value(), cur_max.value(), LLSmoothInterpolation::getInterpolant(0.1f));
 	if (llabs((max_time - cur_max).value()) <= 1)
 	{
-		max_time = llmax(LLUnits::F32Microseconds(1.f), LLUnits::F32Microseconds(cur_max));
+		max_time = llmax(F32Microseconds(1.f), F32Microseconds(cur_max));
 	}
 
 	max_calls = llround(lerp((F32)max_calls, (F32) cur_max_calls, LLSmoothInterpolation::getInterpolant(0.1f)));
@@ -1179,7 +1179,7 @@ void LLFastTimerView::drawLineGraph()
 	switch(mDisplayType)
 	{
 	case DISPLAY_TIME:
-		axis_label = llformat("%4.2f ms", LLUnit<F32, LLUnits::Milliseconds>(max_time).value());
+		axis_label = llformat("%4.2f ms", F32Milliseconds(max_time).value());
 		break;
 	case DISPLAY_CALLS:
 		axis_label = llformat("%d calls", (int)max_calls);
@@ -1230,7 +1230,7 @@ void LLFastTimerView::drawLegend()
 			llassert(idp->getIndex() < sTimerColors.size());
 			gl_rect_2d(bar_rect, sTimerColors[idp->getIndex()]);
 
-			LLUnit<F32, LLUnits::Milliseconds> ms(0);
+			F32Milliseconds ms(0);
 			S32 calls = 0;
 			if (mHoverBarIndex > 0 && mHoverID)
 			{
@@ -1240,7 +1240,7 @@ void LLFastTimerView::drawLegend()
 			}
 			else
 			{
-				ms = LLUnits::F64Seconds(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH));
+				ms = F64Seconds(mRecording.getPeriodMean(*idp, RUNNING_AVERAGE_WIDTH));
 				calls = (S32)mRecording.getPeriodMean(idp->callCount(), RUNNING_AVERAGE_WIDTH);
 			}
 
@@ -1346,7 +1346,7 @@ void LLFastTimerView::drawTicks()
 {
 	// Draw MS ticks
 	{
-		LLUnit<U32, LLUnits::Milliseconds> ms = mTotalTimeDisplay;
+		U32Milliseconds ms = mTotalTimeDisplay;
 		std::string tick_label;
 		S32 x;
 		S32 barw = mBarRect.getWidth();
@@ -1423,7 +1423,7 @@ void LLFastTimerView::updateTotalTime()
 		mTotalTimeDisplay = mRecording.getPeriodMax(FTM_FRAME, 20);
 		break;
 	default:
-		mTotalTimeDisplay = LLUnits::F64Milliseconds(100);
+		mTotalTimeDisplay = F64Milliseconds(100);
 		break;
 	}
 
@@ -1511,14 +1511,14 @@ void LLFastTimerView::drawBars()
 
 static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
-LLUnits::F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
+F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
 {
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
-	const LLUnits::F32Seconds self_time = history_index == -1
+	const F32Seconds self_time = history_index == -1
 										? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) 
 										: mRecording.getPrevRecording(history_index).getSum(time_block->selfTime());
 
-	LLUnits::F32Seconds full_time = self_time;
+	F32Seconds full_time = self_time;
 
 	// reserve a spot for this bar to be rendered before its children
 	// even though we don't know its size yet
@@ -1544,7 +1544,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 	LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS);
 
 	TimerBar& timer_bar = row.mBars[timer_bar_index];
-	const LLUnits::F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime;
+	const F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime;
 	timer_bar.mChildrenStart = timer_bar.mSelfStart + timer_bar.mSelfTime / 2;
 	timer_bar.mChildrenEnd = timer_bar.mChildrenStart + timer_bar.mTotalTime - timer_bar.mSelfTime;
 
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 8f61a2fc87..d184aae03d 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -87,7 +87,7 @@ private:
 			mFirstChild(false),
 			mLastChild(false)
 		{}
-		LLUnits::F32Seconds	mTotalTime,
+		F32Seconds	mTotalTime,
 										mSelfTime,
 										mChildrenStart,
 										mChildrenEnd,
@@ -113,7 +113,7 @@ private:
 		TimerBar*	mBars;
 	};
 
-	LLUnits::F32Seconds updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
+	F32Seconds updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
 	S32 updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
 	S32 drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, bool visible = true, S32 bar_index = 0);
 	void setPauseState(bool pause_state);
@@ -128,7 +128,7 @@ private:
 		DISPLAY_HZ
 	}								mDisplayType;
 	bool							mPauseHistory;
-	LLUnits::F64Seconds	mAllTimeMax,
+	F64Seconds	mAllTimeMax,
 									mTotalTimeDisplay;
 	S32								mScrollIndex,
 									mHoverBarIndex,
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index d16c2d3984..ecee801e8e 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -525,7 +525,7 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 	PeriodicRecording& scene_load_recording = mSceneLoadRecording.getResults();
 	const U32 frame_count = scene_load_recording.getNumRecordedPeriods();
 
-	LLUnits::F64Seconds frame_time;
+	F64Seconds frame_time;
 
 	os << "Stat";
 	for (S32 frame = 1; frame <= frame_count; frame++)
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 3a3731d519..61def8f723 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1429,7 +1429,7 @@ bool idle_startup()
 
 		LL_DEBUGS("AppInit") << "Initializing camera..." << LL_ENDL;
 		gFrameTime    = totalTime();
-		LLUnits::F32Seconds last_time = gFrameTimeSeconds;
+		F32Seconds last_time = gFrameTimeSeconds;
 		gFrameTimeSeconds = (gFrameTime - gStartTime);
 
 		gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 0e6ef76845..07ff1de702 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -66,7 +66,7 @@
 
 bool LLTextureFetchDebugger::sDebuggerEnabled = false;
 LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > LLTextureFetch::sCacheHitRate("texture_cache_hits");
-LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> > LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
+LLTrace::EventStatHandle<F64Milliseconds > LLTextureFetch::sCacheReadLatency("texture_cache_read_latency");
 
 
 //////////////////////////////////////////////////////////////////////////////
@@ -2393,7 +2393,7 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
 	  mFetcherLocked(FALSE)
 {
 	mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
-	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), LLUnits::U32Bytes(gSavedSettings.getU32("TextureLoggingThreshold")));
+	mTextureInfo.setUpLogging(gSavedSettings.getBOOL("LogTextureDownloadsToViewerLog"), gSavedSettings.getBOOL("LogTextureDownloadsToSimulator"), U32Bytes(gSavedSettings.getU32("TextureLoggingThreshold")));
 
 	LLTextureFetchDebugger::sDebuggerEnabled = gSavedSettings.getBOOL("TextureFetchDebuggerEnabled");
 	if(LLTextureFetchDebugger::isEnabled())
@@ -2761,7 +2761,7 @@ bool LLTextureFetch::getRequestFinished(const LLUUID& id, S32& discard_level,
 			discard_level = worker->mDecodedDiscard;
 			raw = worker->mRawImage;
 			aux = worker->mAuxImage;
-			LLUnits::F32Seconds cache_read_time(worker->mCacheReadTime);
+			F32Seconds cache_read_time(worker->mCacheReadTime);
 			if (cache_read_time != 0.f)
 			{
 				record(sCacheReadLatency, cache_read_time);
@@ -3372,7 +3372,7 @@ bool LLTextureFetch::receiveImagePacket(const LLHost& host, const LLUUID& id, U1
 
 		if (log_to_viewer_log || log_to_sim)
 		{
-			LLUnit<U64, LLUnits::Microseconds> timeNow = LLTimer::getTotalTime();
+			U64Microseconds timeNow = LLTimer::getTotalTime();
 			mTextureInfo.setRequestSize(id, worker->mFileSize);
 			mTextureInfo.setRequestCompleteTimeAndLog(id, timeNow);
 		}
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index 38272b40dc..78b13cdd80 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(LLUnit<F32, LLUnits::Kibibits> bandwidth) { mTextureBandwidth = bandwidth; }
+	void setTextureBandwidth(F32Kibibits bandwidth) { mTextureBandwidth = bandwidth; }
 	
     // Threads:  T* (but not safe)
-	LLUnit<F32, LLUnits::Kibibits> getTextureBandwidth() { return mTextureBandwidth; }
+	F32Kibibits getTextureBandwidth() { return mTextureBandwidth; }
 	
     // Threads:  T*
 	BOOL isFromLocalCache(const LLUUID& id);
@@ -310,7 +310,7 @@ private:
 	LLMutex mNetworkQueueMutex; //to protect mNetworkQueue, mHTTPTextureQueue and mCancelQueue.
 
 	static LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > sCacheHitRate;
-	static LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> > sCacheReadLatency;
+	static LLTrace::EventStatHandle<F64Milliseconds > sCacheReadLatency;
 
 	LLTextureCache* mTextureCache;
 	LLImageDecodeThread* mImageDecodeThread;
@@ -325,12 +325,12 @@ private:
 	queue_t mHTTPTextureQueue;											// Mfnq
 	typedef std::map<LLHost,std::set<LLUUID> > cancel_queue_t;
 	cancel_queue_t mCancelQueue;										// Mfnq
-	LLUnit<F32, LLUnits::Kibibits> mTextureBandwidth;					// <none>
-	LLUnit<F32, LLUnits::Kibibits> mMaxBandwidth;						// Mfnq
+	F32Kibibits mTextureBandwidth;					// <none>
+	F32Kibibits mMaxBandwidth;						// Mfnq
 	LLTextureInfo mTextureInfo;
 
 	// XXX possible delete
-	LLUnit<U32, LLUnits::Bits> mHTTPTextureBits;												// Mfnq
+	U32Bits mHTTPTextureBits;												// Mfnq
 
 	// XXX possible delete
 	//debug use
diff --git a/indra/newview/lltextureinfo.cpp b/indra/newview/lltextureinfo.cpp
index 9dee92bf12..6906f82c1c 100755
--- a/indra/newview/lltextureinfo.cpp
+++ b/indra/newview/lltextureinfo.cpp
@@ -33,8 +33,8 @@
 
 static LLTrace::CountStatHandle<S32> sTextureDownloadsStarted("texture_downloads_started", "number of texture downloads initiated");
 static LLTrace::CountStatHandle<S32> sTextureDownloadsCompleted("texture_downloads_completed", "number of texture downloads completed");
-static LLTrace::CountStatHandle<LLUnit<S32, LLUnits::Bytes> > sTextureDataDownloaded("texture_data_downloaded", "amount of texture data downloaded");
-static LLTrace::CountStatHandle<LLUnit<U32, LLUnits::Milliseconds> > sTexureDownloadTime("texture_download_time", "amount of time spent fetching textures");
+static LLTrace::CountStatHandle<S32Bytes > sTextureDataDownloaded("texture_data_downloaded", "amount of texture data downloaded");
+static LLTrace::CountStatHandle<U32Milliseconds > sTexureDownloadTime("texture_download_time", "amount of time spent fetching textures");
 
 LLTextureInfo::LLTextureInfo() : 
 	mLogTextureDownloadsToViewerLog(false),
@@ -46,11 +46,11 @@ LLTextureInfo::LLTextureInfo() :
 	mRecording.start();
 }
 
-void LLTextureInfo::setUpLogging(bool writeToViewerLog, bool sendToSim, LLUnit<U32, LLUnits::Bytes> textureLogThreshold)
+void LLTextureInfo::setUpLogging(bool writeToViewerLog, bool sendToSim, U32Bytes textureLogThreshold)
 {
 	mLogTextureDownloadsToViewerLog = writeToViewerLog;
 	mLogTextureDownloadsToSimulator = sendToSim;
-	mTextureLogThreshold = LLUnit<U32, LLUnits::Bytes>(textureLogThreshold);
+	mTextureLogThreshold = U32Bytes(textureLogThreshold);
 }
 
 LLTextureInfo::~LLTextureInfo()
@@ -126,7 +126,7 @@ void LLTextureInfo::setRequestType(const LLUUID& id, LLTextureInfoDetails::LLReq
 	mTextures[id]->mType = type;
 }
 
-void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, LLUnit<U64, LLUnits::Microseconds> completeTime)
+void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, U64Microseconds completeTime)
 {
 	if (!has(id))
 	{
@@ -160,7 +160,7 @@ void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, LLUnit<U64, L
 			    << " end="      << details.mCompleteTime
 			    << " size="     << details.mSize
 			    << " offset="   << details.mOffset
-			    << " length="   << LLUnit<U32, LLUnits::Milliseconds>(details.mCompleteTime - details.mStartTime)
+			    << " length="   << U32Milliseconds(details.mCompleteTime - details.mStartTime)
 			    << " protocol=" << protocol
 			    << LL_ENDL;
 	}
@@ -193,7 +193,7 @@ LLSD LLTextureInfo::getAverages()
 {
 	LLSD averagedTextureData;
 	S32 averageDownloadRate;
-	LLUnit<U32, LLUnits::Milliseconds> download_time = mRecording.getSum(sTexureDownloadTime);
+	U32Milliseconds download_time = mRecording.getSum(sTexureDownloadTime);
 	if(download_time == 0)
 	{
 		averageDownloadRate = 0;
@@ -219,11 +219,11 @@ void LLTextureInfo::resetTextureStatistics()
 	mCurrentStatsBundleStartTime = LLTimer::getTotalTime();
 }
 
-LLUnits::U32Microseconds LLTextureInfo::getRequestStartTime(const LLUUID& id)
+U32Microseconds LLTextureInfo::getRequestStartTime(const LLUUID& id)
 {
 	if (!has(id))
 	{
-		return LLUnits::U32Microseconds(0);
+		return U32Microseconds(0);
 	}
 	else
 	{
@@ -232,11 +232,11 @@ LLUnits::U32Microseconds LLTextureInfo::getRequestStartTime(const LLUUID& id)
 	}
 }
 
-LLUnit<U32, LLUnits::Bytes> LLTextureInfo::getRequestSize(const LLUUID& id)
+U32Bytes LLTextureInfo::getRequestSize(const LLUUID& id)
 {
 	if (!has(id))
 	{
-		return LLUnits::U32Bytes(0);
+		return U32Bytes(0);
 	}
 	else
 	{
@@ -271,11 +271,11 @@ LLTextureInfoDetails::LLRequestType LLTextureInfo::getRequestType(const LLUUID&
 	}
 }
 
-LLUnit<U32, LLUnits::Microseconds> LLTextureInfo::getRequestCompleteTime(const LLUUID& id)
+U32Microseconds LLTextureInfo::getRequestCompleteTime(const LLUUID& id)
 {
 	if (!has(id))
 	{
-		return LLUnits::U32Microseconds(0);
+		return U32Microseconds(0);
 	}
 	else
 	{
diff --git a/indra/newview/lltextureinfo.h b/indra/newview/lltextureinfo.h
index a861a12668..176f2cbb74 100755
--- a/indra/newview/lltextureinfo.h
+++ b/indra/newview/lltextureinfo.h
@@ -38,18 +38,18 @@ public:
 	LLTextureInfo();
 	~LLTextureInfo();
 
-	void setUpLogging(bool writeToViewerLog, bool sendToSim, LLUnit<U32, LLUnits::Bytes> textureLogThreshold);
+	void setUpLogging(bool writeToViewerLog, bool sendToSim, U32Bytes textureLogThreshold);
 	bool has(const LLUUID& id);
 	void setRequestStartTime(const LLUUID& id, U64 startTime);
 	void setRequestSize(const LLUUID& id, U32 size);
 	void setRequestOffset(const LLUUID& id, U32 offset);
 	void setRequestType(const LLUUID& id, LLTextureInfoDetails::LLRequestType type);
-	void setRequestCompleteTimeAndLog(const LLUUID& id, LLUnit<U64, LLUnits::Microseconds> completeTime);
-	LLUnit<U32, LLUnits::Microseconds>getRequestStartTime(const LLUUID& id);
-	LLUnit<U32, LLUnits::Bytes> getRequestSize(const LLUUID& id);
+	void setRequestCompleteTimeAndLog(const LLUUID& id, U64Microseconds completeTime);
+	U32Microseconds getRequestStartTime(const LLUUID& id);
+	U32Bytes getRequestSize(const LLUUID& id);
 	U32 getRequestOffset(const LLUUID& id);
 	LLTextureInfoDetails::LLRequestType getRequestType(const LLUUID& id);
-	LLUnit<U32, LLUnits::Microseconds> getRequestCompleteTime(const LLUUID& id);
+	U32Microseconds getRequestCompleteTime(const LLUUID& id);
 	void resetTextureStatistics();
 	U32 getTextureInfoMapSize();
 	LLSD getAverages();
@@ -62,8 +62,8 @@ private:
 	bool										mLogTextureDownloadsToViewerLog,
 												mLogTextureDownloadsToSimulator;
 	std::string									mTextureDownloadProtocol;
-	LLUnit<U32, LLUnits::Bytes>					mTextureLogThreshold; 
-	LLUnit<U64, LLUnits::Microseconds>			mCurrentStatsBundleStartTime;
+	U32Bytes					mTextureLogThreshold; 
+	U64Microseconds			mCurrentStatsBundleStartTime;
 	LLTrace::Recording							mRecording;
 };
 
diff --git a/indra/newview/lltextureinfodetails.h b/indra/newview/lltextureinfodetails.h
index 28e957a7df..0ad95eb94e 100755
--- a/indra/newview/lltextureinfodetails.h
+++ b/indra/newview/lltextureinfodetails.h
@@ -39,10 +39,10 @@ struct LLTextureInfoDetails
 		REQUEST_TYPE_UDP
 	};
 
-	LLUnit<U32, LLUnits::Microseconds>	mStartTime,
+	U32Microseconds	mStartTime,
 										mCompleteTime;
 	U32									mOffset;
-	LLUnit<U32, LLUnits::Bytes>			mSize;
+	U32Bytes			mSize;
 	LLRequestType						mType;
 
 	LLTextureInfoDetails();
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index c94064df5f..f39d41c2b8 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -507,17 +507,17 @@ private:
 
 void LLGLTexMemBar::draw()
 {
-	LLUnit<S32, LLUnits::Mibibytes> bound_mem = LLViewerTexture::sBoundTextureMemory;
- 	LLUnit<S32, LLUnits::Mibibytes> max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
-	LLUnit<S32, LLUnits::Mibibytes> total_mem = LLViewerTexture::sTotalTextureMemory;
-	LLUnit<S32, LLUnits::Mibibytes> max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
+	S32Mibibytes bound_mem = LLViewerTexture::sBoundTextureMemory;
+ 	S32Mibibytes max_bound_mem = LLViewerTexture::sMaxBoundTextureMem;
+	S32Mibibytes total_mem = LLViewerTexture::sTotalTextureMemory;
+	S32Mibibytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;
-	F32 cache_usage = (F32)LLUnit<F32, LLUnits::Mibibytes>(LLAppViewer::getTextureCache()->getUsage()).value() ;
-	F32 cache_max_usage = (F32)LLUnit<F32, LLUnits::Mibibytes>(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
+	F32 cache_usage = (F32)F32Mibibytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
+	F32 cache_max_usage = (F32)F32Mibibytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
 	S32 line_height = LLFontGL::getFontMonospace()->getLineHeight();
 	S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f);
-	LLUnit<F32, LLUnits::Bytes> total_texture_downloaded = gTotalTextureData;
-	LLUnit<F32, LLUnits::Bytes> total_object_downloaded = gTotalObjectData;
+	F32Bytes total_texture_downloaded = gTotalTextureData;
+	F32Bytes total_object_downloaded = gTotalObjectData;
 	U32 total_http_requests = LLAppViewer::getTextureFetch()->getTotalNumHTTPRequests();
 	U32 total_active_cached_objects = LLWorld::getInstance()->getNumOfActiveCachedObjects();
 	U32 total_objects = gObjectList.getNumObjects();
@@ -586,8 +586,8 @@ void LLGLTexMemBar::draw()
 
 
 	left = 550;
-	LLUnit<F32, LLUnits::Kibibits> bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
-	LLUnit<F32, LLUnits::Kibibits> max_bandwidth(gSavedSettings.getF32("ThrottleBandwidthKBPS"));
+	F32Kibibits bandwidth = LLAppViewer::getTextureFetch()->getTextureBandwidth();
+	F32Kibibits 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());
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index b176c69691..e009863002 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -233,7 +233,7 @@ namespace LLViewerAssetStatsFF
 		&sDequeuedAssetRequestsOther            
 	};
 
-	static LLTrace::EventStatHandle<LLUnits::F64Seconds >	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp",
+	static LLTrace::EventStatHandle<F64Seconds >	sResponseAssetRequestsTempTextureHTTP   ("assetresponsetimestemptexturehttp",
 																							"Time spent responding to temporary texture asset http requests"),
 													sResponseAssetRequestsTempTextureUDP    ("assetresponsetimestemptextureudp", 
 																							"Time spent responding to temporary texture asset udp requests"),
@@ -250,7 +250,7 @@ namespace LLViewerAssetStatsFF
 													sResponsedAssetRequestsOther            ("assetresponsetimesother", 
 																							"Time spent responding to other asset requests");
 
-	static LLTrace::EventStatHandle<LLUnits::F64Seconds >* sResponse[EVACCount] = {
+	static LLTrace::EventStatHandle<F64Seconds >* sResponse[EVACCount] = {
 		&sResponseAssetRequestsTempTextureHTTP,   
 		&sResponseAssetRequestsTempTextureUDP,  
 		&sResponseAssetRequestsNonTempTextureHTTP,
@@ -487,10 +487,10 @@ void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 		grid_from_region_handle(it->first, &grid_x, &grid_y);
 		r	.grid_x(grid_x)
 			.grid_y(grid_y)
-			.duration(LLUnit<F64, LLUnits::Microseconds>(rec.getDuration()).value());
+			.duration(F64Microseconds(rec.getDuration()).value());
 	}
 
-	stats.duration(mCurRecording ? LLUnit<F64, LLUnits::Microseconds>(mCurRecording->getDuration()).value() : 0.0);
+	stats.duration(mCurRecording ? F64Microseconds(mCurRecording->getDuration()).value() : 0.0);
 }
 
 LLSD LLViewerAssetStats::asLLSD(bool compact_output)
@@ -540,7 +540,7 @@ void record_response(LLViewerAssetType::EType at, bool with_http, bool is_temp,
 {
 	const EViewerAssetCategories eac(asset_type_to_category(at, with_http, is_temp));
 
-	record(*sResponse[int(eac)], LLUnit<F64, LLUnits::Microseconds>(duration));
+	record(*sResponse[int(eac)], F64Microseconds(duration));
 }
 
 void init()
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index a42060d4d8..aaa299bf4b 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -82,7 +82,7 @@ public:
 	 * for compatibility with the pre-existing timestamp on the texture
 	 * fetcher class, LLTextureFetch.
 	 */
-	typedef LLUnit<U64, LLUnits::Microseconds> duration_t;
+	typedef U64Microseconds duration_t;
 
 	/**
 	 * Type for the region identifier used in stats.  Currently uses
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index f12df23a36..6c435bf147 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4487,18 +4487,18 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 
 // *TODO: Remove this dependency, or figure out a better way to handle
 // this hack.
-extern LLUnit<U32, LLUnits::Bits> gObjectData;
+extern U32Bits gObjectData;
 
 void process_object_update(LLMessageSystem *mesgsys, void **user_data)
 {	
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4510,11 +4510,11 @@ void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4526,11 +4526,11 @@ void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data)
 	// Update the data counters
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveSize();
 	}
 
 	// Update the object...
@@ -4542,11 +4542,11 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 {
 	if (mesgsys->getReceiveCompressedSize())
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveCompressedSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveCompressedSize();
 	}
 	else
 	{
-		gObjectData += (LLUnit<U32, LLUnits::Bytes>)mesgsys->getReceiveSize();
+		gObjectData += (U32Bytes)mesgsys->getReceiveSize();
 	}
 
 	gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index a8183e76b4..4643430c6b 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -995,13 +995,13 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 
 	// update global timer
 	F32 last_time = gFrameTimeSeconds;
-	LLUnit<U64, LLUnits::Microseconds> time = totalTime();				 // this will become the new gFrameTime when the update is done
+	U64Microseconds time = totalTime();				 // this will become the new gFrameTime when the update is done
 	// Time _can_ go backwards, for example if the user changes the system clock.
 	// It doesn't cause any fatal problems (just some oddness with stats), so we shouldn't assert here.
 //	llassert(time > gFrameTime);
-	LLUnits::F64Seconds time_diff = time - gFrameTime;
+	F64Seconds time_diff = time - gFrameTime;
 	gFrameTime	= time;
-	LLUnits::F64Seconds time_since_start = gFrameTime - gStartTime;
+	F64Seconds time_since_start = gFrameTime - gStartTime;
 	gFrameTimeSeconds = time_since_start;
 
 	gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 568d4b42ca..67005e1978 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -95,7 +95,7 @@ LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> >
 LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Kilotriangles> >
 							TRIANGLES_DRAWN_PER_FRAME("trianglesdrawnperframestat");
 
-LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	
+LLTrace::CountStatHandle<F64Kibibytes >	
 							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"),
@@ -104,7 +104,7 @@ LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >
 							MESSAGE_SYSTEM_DATA_IN("messagedatain", "Incoming message system network data"),
 							MESSAGE_SYSTEM_DATA_OUT("messagedataout", "Outgoing message system network data");
 
-LLTrace::CountStatHandle<LLUnits::F64Seconds >	
+LLTrace::CountStatHandle<F64Seconds >	
 							SIM_20_FPS_TIME("sim20fpstime", "Seconds with sim FPS below 20"),
 							SIM_PHYSICS_20_FPS_TIME("simphysics20fpstime", "Seconds with physics FPS below 20"),
 							LOSS_5_PERCENT_TIME("loss5percenttime", "Seconds with packet loss > 5%");
@@ -152,15 +152,15 @@ LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> >
 static LLTrace::SampleStatHandle<bool> 
 							CHAT_BUBBLES("chatbubbles", "Chat Bubbles Enabled");
 
-LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Megabytes> >	GL_TEX_MEM("gltexmemstat"),
+LLTrace::SampleStatHandle<F64Megabytes >	GL_TEX_MEM("gltexmemstat"),
 															GL_BOUND_MEM("glboundmemstat"),
 															RAW_MEM("rawmemstat"),
 															FORMATTED_MEM("formattedmemstat");
-LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
+LLTrace::SampleStatHandle<F64Kibibytes >	DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
 															MAX_BANDWIDTH("maxbandwidth", "Max bandwidth setting");
 
 	
-SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
+SimMeasurement<F64Milliseconds >	SIM_FRAME_TIME("simframemsec", "", LL_SIM_STAT_FRAMEMS),
 													SIM_NET_TIME("simnetmsec", "", LL_SIM_STAT_NETMS),
 													SIM_OTHER_TIME("simsimothermsec", "", LL_SIM_STAT_SIMOTHERMS),
 													SIM_PHYSICS_TIME("simsimphysicsmsec", "", LL_SIM_STAT_SIMPHYSICSMS),
@@ -175,10 +175,10 @@ SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME("simframemsec
 													SIM_SLEEP_TIME("simsleepmsec", "", LL_SIM_STAT_SIMSLEEPTIME),
 													SIM_PUMP_IO_TIME("simpumpiomsec", "", LL_SIM_STAT_IOPUMPTIME);
 	
-SimMeasurement<LLUnit<F64, LLUnits::Kilobytes> >	SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES);
-SimMeasurement<LLUnit<F64, LLUnits::Megabytes> >	SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
+SimMeasurement<F64Kilobytes >	SIM_UNACKED_BYTES("simtotalunackedbytes", "", LL_SIM_STAT_TOTAL_UNACKED_BYTES);
+SimMeasurement<F64Megabytes >	SIM_PHYSICS_MEM("physicsmemoryallocated", "", LL_SIM_STAT_SIMPHYSICSMEMORY);
 
-LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
+LLTrace::SampleStatHandle<F64Milliseconds >	FRAMETIME_JITTER("frametimejitter", "Average delta between successive frame times"),
 																FRAMETIME_SLEW("frametimeslew", "Average delta between frame time and mean"),
 																SIM_PING("simpingstat");
 
@@ -186,7 +186,7 @@ LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Meters> > AGENT_POSITION_SNAP("age
 
 LLTrace::EventStatHandle<>	LOADING_WEARABLES_LONG_DELAY("loadingwearableslongdelay", "Wearables took too long to load");
 	
-LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
+LLTrace::EventStatHandle<F64Milliseconds >	REGION_CROSSING_TIME("regioncrossingtime", "CROSSING_AVG"),
 																FRAME_STACKTIME("framestacktime", "FRAME_SECS"),
 																UPDATE_STACKTIME("updatestacktime", "UPDATE_SECS"),
 																NETWORK_STACKTIME("networkstacktime", "NETWORK_SECS"),
@@ -194,7 +194,7 @@ LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROSSING_TI
 																REBUILD_STACKTIME("rebuildstacktime", "REBUILD_SECS"),
 																RENDER_STACKTIME("renderstacktime", "RENDER_SECS");
 	
-LLTrace::EventStatHandle<LLUnits::F64Seconds >	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
+LLTrace::EventStatHandle<F64Seconds >	AVATAR_EDIT_TIME("avataredittime", "Seconds in Edit Appearance"),
 															TOOLBOX_TIME("toolboxtime", "Seconds using Toolbox"),
 															MOUSELOOK_TIME("mouselooktime", "Seconds in Mouselook"),
 															FPS_10_TIME("fps10time", "Seconds below 10 FPS"),
@@ -219,7 +219,7 @@ void LLViewerStats::resetStats()
 	LLViewerStats::instance().mRecording.reset();
 }
 
-void LLViewerStats::updateFrameStats(const LLUnits::F64Seconds time_diff)
+void LLViewerStats::updateFrameStats(const F64Seconds time_diff)
 {
 	if (getRecording().getLastValue(LLStatViewer::PACKETS_LOST_PERCENT) > 5.0)
 	{
@@ -258,15 +258,15 @@ void LLViewerStats::updateFrameStats(const LLUnits::F64Seconds time_diff)
 		add(LLStatViewer::FRAMETIME_DOUBLED, time_diff >= 2.0 * mLastTimeDiff ? 1 : 0);
 
 		// old stats that were never really used
-		sample(LLStatViewer::FRAMETIME_JITTER, LLUnit<F64, LLUnits::Milliseconds> (mLastTimeDiff - time_diff));
+		sample(LLStatViewer::FRAMETIME_JITTER, F64Milliseconds (mLastTimeDiff - time_diff));
 			
 		F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
-		sample(LLStatViewer::FRAMETIME_SLEW, LLUnit<F64, LLUnits::Milliseconds> (average_frametime - time_diff));
+		sample(LLStatViewer::FRAMETIME_SLEW, F64Milliseconds (average_frametime - time_diff));
 
 		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
 		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
-		sample(LLStatViewer::DELTA_BANDWIDTH, LLUnit<F64, LLUnits::Bits>(delta_bandwidth));
-		sample(LLStatViewer::MAX_BANDWIDTH, LLUnit<F64, LLUnits::Bits>(max_bandwidth));
+		sample(LLStatViewer::DELTA_BANDWIDTH, F64Bits(delta_bandwidth));
+		sample(LLStatViewer::MAX_BANDWIDTH, F64Bits(max_bandwidth));
 	}
 	
 	mLastTimeDiff = time_diff;
@@ -299,13 +299,13 @@ F32		gAveLandCompression = 0.f,
 		gWorstLandCompression = 0.f, 
 		gWorstWaterCompression = 0.f;
 
-LLUnits::U32Bytes				gTotalWorldData, 
+U32Bytes				gTotalWorldData, 
 								gTotalObjectData, 
 								gTotalTextureData;
 U32								gSimPingCount = 0;
-LLUnits::U32Bits				gObjectData;
+U32Bits				gObjectData;
 F32		gAvgSimPing = 0.f;
-LLUnits::U32Bytes		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {LLUnits::U32Bytes(0)};
+U32Bytes		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {U32Bytes(0)};
 
 extern U32  gVisCompared;
 extern U32  gVisTested;
@@ -345,8 +345,8 @@ void update_statistics()
 
 	typedef LLInstanceTracker<LLTrace::TraceType<LLTrace::TimeBlockAccumulator>, std::string> trace_type_t;
 
-	LLUnits::F64Seconds idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
-	LLUnits::F64Seconds network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
+	F64Seconds idle_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Idle"));
+	F64Seconds network_secs = last_frame_recording.getSum(*trace_type_t::getInstance("Network"));
 
 	record(LLStatViewer::FRAME_STACKTIME, last_frame_recording.getSum(*trace_type_t::getInstance("Frame")));
 	record(LLStatViewer::UPDATE_STACKTIME, idle_secs - network_secs);
@@ -358,13 +358,13 @@ void update_statistics()
 	LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(gAgent.getRegion()->getHost());
 	if (cdp)
 	{
-		sample(LLStatViewer::SIM_PING, LLUnit<F64, LLUnits::Milliseconds> (cdp->getPingDelay()));
+		sample(LLStatViewer::SIM_PING, F64Milliseconds (cdp->getPingDelay()));
 		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
 	{
-		sample(LLStatViewer::SIM_PING, LLUnits::U32Seconds(10));
+		sample(LLStatViewer::SIM_PING, U32Seconds(10));
 	}
 
 	if (LLViewerStats::instance().getRecording().getSum(LLStatViewer::FPS))
@@ -374,10 +374,10 @@ void update_statistics()
 	add(LLStatViewer::FPS, 1);
 
 	F32 layer_bits = (F32)(gVLManager.getLandBits() + gVLManager.getWindBits() + gVLManager.getCloudBits());
-	add(LLStatViewer::LAYERS_NETWORK_DATA_RECEIVED, LLUnit<F64, LLUnits::Bits>(layer_bits));
+	add(LLStatViewer::LAYERS_NETWORK_DATA_RECEIVED, F64Bits(layer_bits));
 	add(LLStatViewer::OBJECT_NETWORK_DATA_RECEIVED, gObjectData);
 	sample(LLStatViewer::PENDING_VFS_OPERATIONS, LLVFile::getVFSThread()->getPending());
-	add(LLStatViewer::ASSET_UDP_DATA_RECEIVED, LLUnit<F64, LLUnits::Bits>(gTransferManager.getTransferBitsIn(LLTCT_ASSET)));
+	add(LLStatViewer::ASSET_UDP_DATA_RECEIVED, F64Bits(gTransferManager.getTransferBitsIn(LLTCT_ASSET)));
 	gTransferManager.resetTransferBitsIn(LLTCT_ASSET);
 
 	if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
@@ -553,9 +553,9 @@ void send_stats()
 
 	LLSD &download = body["downloads"];
 
-	download["world_kbytes"] = LLUnit<F64, LLUnits::Kibibytes>(gTotalWorldData).value();
-	download["object_kbytes"] = LLUnit<F64, LLUnits::Kibibytes>(gTotalObjectData).value();
-	download["texture_kbytes"] = LLUnit<F64, LLUnits::Kibibytes>(gTotalTextureData).value();
+	download["world_kbytes"] = F64Kibibytes(gTotalWorldData).value();
+	download["object_kbytes"] = F64Kibibytes(gTotalObjectData).value();
+	download["texture_kbytes"] = F64Kibibytes(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 2cea575252..42c56e8835 100755
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -142,7 +142,7 @@ extern LLTrace::CountStatHandle<>			FPS,
 
 extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kilotriangles> > TRIANGLES_DRAWN;
 
-extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	ACTIVE_MESSAGE_DATA_RECEIVED,
+extern LLTrace::CountStatHandle<F64Kibibytes >	ACTIVE_MESSAGE_DATA_RECEIVED,
 																	LAYERS_NETWORK_DATA_RECEIVED,
 																	OBJECT_NETWORK_DATA_RECEIVED,
 																	ASSET_UDP_DATA_RECEIVED,
@@ -150,7 +150,7 @@ extern LLTrace::CountStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	ACTIVE_MESSAGE
 																	MESSAGE_SYSTEM_DATA_IN,
 																	MESSAGE_SYSTEM_DATA_OUT;
 
-extern LLTrace::CountStatHandle<LLUnits::F64Seconds >		SIM_20_FPS_TIME,
+extern LLTrace::CountStatHandle<F64Seconds >		SIM_20_FPS_TIME,
 																	SIM_PHYSICS_20_FPS_TIME,
 																	LOSS_5_PERCENT_TIME;
 
@@ -192,13 +192,13 @@ extern LLTrace::SampleStatHandle<>		FPS_SAMPLE,
 
 extern LLTrace::SampleStatHandle<LLUnit<F32, LLUnits::Percent> > PACKETS_LOST_PERCENT;
 
-extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Megabytes> >	GL_TEX_MEM,
+extern LLTrace::SampleStatHandle<F64Megabytes >	GL_TEX_MEM,
 																	GL_BOUND_MEM,
 																	RAW_MEM,
 																	FORMATTED_MEM;
-extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Kibibytes> >	DELTA_BANDWIDTH,
+extern LLTrace::SampleStatHandle<F64Kibibytes >	DELTA_BANDWIDTH,
 																	MAX_BANDWIDTH;
-extern SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME,
+extern SimMeasurement<F64Milliseconds >	SIM_FRAME_TIME,
 															SIM_NET_TIME,
 															SIM_OTHER_TIME,
 															SIM_PHYSICS_TIME,
@@ -213,11 +213,11 @@ extern SimMeasurement<LLUnit<F64, LLUnits::Milliseconds> >	SIM_FRAME_TIME,
 															SIM_SLEEP_TIME,
 															SIM_PUMP_IO_TIME;
 
-extern SimMeasurement<LLUnit<F64, LLUnits::Kilobytes> >	SIM_UNACKED_BYTES;
-extern SimMeasurement<LLUnit<F64, LLUnits::Megabytes> >	SIM_PHYSICS_MEM;
+extern SimMeasurement<F64Kilobytes >	SIM_UNACKED_BYTES;
+extern SimMeasurement<F64Megabytes >	SIM_PHYSICS_MEM;
 
 
-extern LLTrace::SampleStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	FRAMETIME_JITTER,
+extern LLTrace::SampleStatHandle<F64Milliseconds >	FRAMETIME_JITTER,
 																		FRAMETIME_SLEW,
 																		SIM_PING;
 
@@ -225,7 +225,7 @@ extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Meters> > AGENT_POSITION_SN
 
 extern LLTrace::EventStatHandle<>	LOADING_WEARABLES_LONG_DELAY;
 
-extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROSSING_TIME,
+extern LLTrace::EventStatHandle<F64Milliseconds >	REGION_CROSSING_TIME,
 														FRAME_STACKTIME,
 														UPDATE_STACKTIME,
 														NETWORK_STACKTIME,
@@ -233,7 +233,7 @@ extern LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Milliseconds> >	REGION_CROS
 														REBUILD_STACKTIME,
 														RENDER_STACKTIME;
 
-extern LLTrace::EventStatHandle<LLUnits::F64Seconds >	AVATAR_EDIT_TIME,
+extern LLTrace::EventStatHandle<F64Seconds >	AVATAR_EDIT_TIME,
 																TOOLBOX_TIME,
 																MOUSELOOK_TIME,
 																FPS_10_TIME,
@@ -254,7 +254,7 @@ public:
 	LLViewerStats();
 	~LLViewerStats();
 
-	void updateFrameStats(const LLUnits::F64Seconds time_diff);
+	void updateFrameStats(const F64Seconds time_diff);
 	
 	void addToMessage(LLSD &body);
 
@@ -370,7 +370,7 @@ public:
 private:
 	LLTrace::Recording				mRecording;
 
-	LLUnits::F64Seconds mLastTimeDiff;  // used for time stat updates
+	F64Seconds mLastTimeDiff;  // used for time stat updates
 };
 
 static const F32 SEND_STATS_PERIOD = 300.0f;
@@ -380,7 +380,7 @@ void update_statistics();
 void send_stats();
 
 extern LLFrameTimer gTextureTimer;
-extern LLUnit<U32, LLUnits::Bytes>	gTotalTextureData;
-extern LLUnit<U32, LLUnits::Bytes>  gTotalObjectData;
-extern LLUnit<U32, LLUnits::Bytes>  gTotalTextureBytesPerBoostLevel[] ;
+extern U32Bytes	gTotalTextureData;
+extern U32Bytes  gTotalObjectData;
+extern U32Bytes  gTotalTextureBytesPerBoostLevel[] ;
 #endif // LL_LLVIEWERSTATS_H
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index c780814e50..4290d338c1 100755
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -63,8 +63,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 // extern
-const LLUnit<S32, LLUnits::Mibibytes> gMinVideoRam(32);
-const LLUnit<S32, LLUnits::Mibibytes> gMaxVideoRam(512);
+const S32Mibibytes gMinVideoRam(32);
+const S32Mibibytes gMaxVideoRam(512);
 
 
 // statics
@@ -86,11 +86,11 @@ S32 LLViewerTexture::sAuxCount = 0;
 LLFrameTimer LLViewerTexture::sEvaluationTimer;
 F32 LLViewerTexture::sDesiredDiscardBias = 0.f;
 F32 LLViewerTexture::sDesiredDiscardScale = 1.1f;
-LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sBoundTextureMemory;
-LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sTotalTextureMemory;
-LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxBoundTextureMem;
-LLUnit<S32, LLUnits::Mibibytes> LLViewerTexture::sMaxTotalTextureMem;
-LLUnit<S32, LLUnits::Bytes> LLViewerTexture::sMaxDesiredTextureMem;
+S32Bytes LLViewerTexture::sBoundTextureMemory;
+S32Bytes LLViewerTexture::sTotalTextureMemory;
+S32Mibibytes LLViewerTexture::sMaxBoundTextureMem;
+S32Mibibytes LLViewerTexture::sMaxTotalTextureMem;
+S32Bytes LLViewerTexture::sMaxDesiredTextureMem;
 S8  LLViewerTexture::sCameraMovingDiscardBias = 0 ;
 F32 LLViewerTexture::sCameraMovingBias = 0.0f ;
 S32 LLViewerTexture::sMaxSculptRez = 128 ; //max sculpt image size
@@ -540,7 +540,7 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 		sTotalTextureMemory >= sMaxTotalTextureMem)
 	{
 		//when texture memory overflows, lower down the threshold to release the textures more aggressively.
-		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, LLUnit<S32, LLUnits::Bytes>(gMaxVideoRam));
+		sMaxDesiredTextureMem = llmin(sMaxDesiredTextureMem * 0.75f, S32Bytes(gMaxVideoRam));
 	
 		// If we are using more texture memory than we should,
 		// scale up the desired discard level
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index b0eae7c071..9a00ccd8c6 100755
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -38,8 +38,8 @@
 #include <map>
 #include <list>
 
-extern const LLUnit<S32, LLUnits::Mibibytes> gMinVideoRam;
-extern const LLUnit<S32, LLUnits::Mibibytes> gMaxVideoRam;
+extern const S32Mibibytes gMinVideoRam;
+extern const S32Mibibytes gMaxVideoRam;
 
 class LLImageGL ;
 class LLImageRaw;
@@ -205,11 +205,11 @@ public:
 	static LLFrameTimer sEvaluationTimer;
 	static F32 sDesiredDiscardBias;
 	static F32 sDesiredDiscardScale;
-	static LLUnit<S32, LLUnits::Bytes> sBoundTextureMemory;
-	static LLUnit<S32, LLUnits::Bytes> sTotalTextureMemory;
-	static LLUnit<S32, LLUnits::Mibibytes> sMaxBoundTextureMem;
-	static LLUnit<S32, LLUnits::Mibibytes> sMaxTotalTextureMem;
-	static LLUnit<S32, LLUnits::Bytes> sMaxDesiredTextureMem ;
+	static S32Bytes sBoundTextureMemory;
+	static S32Bytes sTotalTextureMemory;
+	static S32Mibibytes sMaxBoundTextureMem;
+	static S32Mibibytes sMaxTotalTextureMem;
+	static S32Bytes sMaxDesiredTextureMem ;
 	static S8  sCameraMovingDiscardBias;
 	static F32 sCameraMovingBias;
 	static S32 sMaxSculptRez ;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 2030b490e4..888174a6cf 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -670,8 +670,8 @@ void LLViewerTextureList::updateImages(F32 max_time)
 		sample(NUM_RAW_IMAGES, LLImageRaw::sRawImageCount);
 		sample(GL_TEX_MEM, LLImageGL::sGlobalTextureMemory);
 		sample(GL_BOUND_MEM, LLImageGL::sBoundTextureMemory);
-		sample(RAW_MEM, LLUnit<F64, LLUnits::Bytes>(LLImageRaw::sGlobalRawMemory));
-		sample(FORMATTED_MEM, LLUnit<F64, LLUnits::Bytes>(LLImageFormatted::sGlobalFormattedMemory));
+		sample(RAW_MEM, F64Bytes(LLImageRaw::sGlobalRawMemory));
+		sample(FORMATTED_MEM, F64Bytes(LLImageFormatted::sGlobalFormattedMemory));
 	}
 
 	{
@@ -1373,7 +1373,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 	{
 		received_size = msg->getReceiveSize() ;		
 	}
-	add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, LLUnit<F64, LLUnits::Bytes>(received_size));
+	add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, F64Bytes(received_size));
 	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	U8 codec;
@@ -1447,7 +1447,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 		received_size = msg->getReceiveSize() ;		
 	}
 
-	add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, LLUnit<F64, LLUnits::Bytes>(received_size));
+	add(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED, F64Bytes(received_size));
 	add(LLStatViewer::TEXTURE_PACKETS, 1);
 	
 	//llprintline("Start decode, image header...");
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 673b55be69..53bda6e6ab 100755
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -101,8 +101,8 @@ public:
 
 	void setUpdateStats(BOOL b)			{ mUpdateStats = b; }
 
-	LLUnit<S32, LLUnits::Mibibytes>	getMaxResidentTexMem() const	{ return mMaxResidentTexMemInMegaBytes; }
-	LLUnit<S32, LLUnits::Mibibytes> getMaxTotalTextureMem() const   { return mMaxTotalTextureMemInMegaBytes;}
+	S32Mibibytes	getMaxResidentTexMem() const	{ return mMaxResidentTexMemInMegaBytes; }
+	S32Mibibytes getMaxTotalTextureMem() const   { return mMaxTotalTextureMemInMegaBytes;}
 	S32 getNumImages()					{ return mImageList.size(); }
 
 	void updateMaxResidentTexMem(S32 mem);
@@ -200,8 +200,8 @@ private:
 
 	BOOL mInitialized ;
 	BOOL mUpdateStats;
-	LLUnit<S32, LLUnits::Mibibytes>	mMaxResidentTexMemInMegaBytes;
-	LLUnit<S32, LLUnits::Mibibytes> mMaxTotalTextureMemInMegaBytes;
+	S32Mibibytes	mMaxResidentTexMemInMegaBytes;
+	S32Mibibytes mMaxTotalTextureMemInMegaBytes;
 	LLFrameTimer mForceDecodeTimer;
 	
 private:
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 12d58b7521..1e60b59932 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -738,7 +738,7 @@ public:
 			{
 				if(gTotalTextureBytesPerBoostLevel[i] > 0)
 				{
-					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, LLUnit<F32, LLUnits::Mibibytes>(gTotalTextureBytesPerBoostLevel[i]).value()));
+					addText(xpos, ypos, llformat("Boost_Level %d:  %.3f MB", i, F32Mibibytes(gTotalTextureBytesPerBoostLevel[i]).value()));
 					ypos += y_inc;
 				}
 			}
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 66206fe53e..db6d2d6fe9 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -899,7 +899,7 @@ void LLVOAvatarSelf::updateRegion(LLViewerRegion *regionp)
 		if (mLastRegionHandle != 0)
 		{
 			++mRegionCrossingCount;
-			LLUnits::F64Seconds delta(mRegionCrossingTimer.getElapsedTimeF32());
+			F64Seconds delta(mRegionCrossingTimer.getElapsedTimeF32());
 			record(LLStatViewer::REGION_CROSSING_TIME, delta);
 
 			// Diagnostics
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 31b7e5a01c..93351d21f5 100755
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -6547,7 +6547,7 @@ void LLVivoxVoiceClient::expireVoiceFonts()
 	// Give a warning notification if any voice fonts are due to expire.
 	if (will_expire)
 	{
-		LLUnit<S32, LLUnits::Seconds> seconds(gSavedSettings.getS32("VoiceEffectExpiryWarningTime"));
+		S32Seconds seconds(gSavedSettings.getS32("VoiceEffectExpiryWarningTime"));
 		args["INTERVAL"] = llformat("%d", LLUnit<S32, LLUnits::Days>(seconds).value());
 
 		LLNotificationsUtil::add("VoiceEffectsWillExpire", args);
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 38818e242b..9d727dafbe 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -717,7 +717,7 @@ void LLWorld::renderPropertyLines()
 
 void LLWorld::updateNetStats()
 {
-	LLUnits::F64Bits bits;
+	F64Bits bits;
 	U32 packets = 0;
 
 	for (region_list_t::iterator iter = mActiveRegionList.begin();
@@ -735,8 +735,8 @@ void LLWorld::updateNetStats()
 	S32 packets_out = gMessageSystem->mPacketsOut - mLastPacketsOut;
 	S32 packets_lost = gMessageSystem->mDroppedPackets - mLastPacketsLost;
 
-	LLUnit<F64, LLUnits::Bits> actual_in_bits(gMessageSystem->mPacketRing.getAndResetActualInBits());
-	LLUnit<F64, LLUnits::Bits> actual_out_bits(gMessageSystem->mPacketRing.getAndResetActualOutBits());
+	F64Bits actual_in_bits(gMessageSystem->mPacketRing.getAndResetActualInBits());
+	F64Bits actual_out_bits(gMessageSystem->mPacketRing.getAndResetActualOutBits());
 
 	add(LLStatViewer::MESSAGE_SYSTEM_DATA_IN, actual_in_bits);
 	add(LLStatViewer::MESSAGE_SYSTEM_DATA_OUT, actual_out_bits);
-- 
cgit v1.2.3


From aa050ac946e372c72d0411cda95ccaf41603f394 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 15 Aug 2013 12:11:42 -0700
Subject: removed bad XUI that was generating warnings

---
 indra/newview/skins/default/xui/en/floater_stats.xml | 9 ---------
 1 file changed, 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index aaf191a98a..fc2369276c 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -52,13 +52,11 @@
      <stat_view name="advanced"
                  label="Advanced"
                  follows="left|top|right"
-                 show_bar="true"
                  show_label="true"
                  setting="OpenDebugStatAdvanced">
         <stat_view name="render"
                    label="Render"
                    follows="left|top|right"
-                   show_bar="true"
                    show_label="true"
                    setting="OpenDebugStatRender">
           <stat_bar name="ktrisframe"
@@ -84,7 +82,6 @@
         <stat_view name="texture"
                    label="Texture"
                    follows="left|top|right"
-                   show_bar="true"
                    show_label="true">
           <stat_bar name="texture_cache_hits"
                     label="Cache Hit Rate"
@@ -122,7 +119,6 @@
         <stat_view name="network"
                    label="Network"
                    follows="left|top|right"
-                   show_bar="true"         
                    show_label="true"
                    setting="OpenDebugStatNet">
           <stat_bar name="packetsinstat"
@@ -168,7 +164,6 @@
       <stat_view name="sim"
                  label="Simulator"
                  follows="left|top|right"
-                 show_bar="true"       
                  show_label="true"
                  setting="OpenDebugStatSim">
         <stat_bar name="simtimedilation"
@@ -189,7 +184,6 @@
         <stat_view name="physicsdetail"
                    label="Physics Details"
                    follows="left|top|right"
-                   show_bar="true"         
                    show_label="true">
           <stat_bar name="physicspinnedtasks"
                     label="Pinned Objects"
@@ -237,7 +231,6 @@
         <stat_view name="simpathfinding"
                    label="Pathfinding"
                    follows="left|top|right"
-                   show_bar="true"        
                    show_label="true">
           <stat_bar name="simsimaistepmsec"
                     label="AI Step Time"
@@ -274,7 +267,6 @@
         <stat_view name="simperf"
                    label="Time"
                    follows="left|top|right"
-                   show_bar="true"
                    show_label="true">
           <stat_bar name="simframemsec"
                     label="Total Frame Time"
@@ -311,7 +303,6 @@
           <stat_view name="timedetails"
                      label="Time Details"
                      follows="left|top|right"
-                     show_bar="true"
                      show_label="true">
             <stat_bar name="simsimphysicsstepmsec"
                       label="Physics Step"
-- 
cgit v1.2.3


From 25937040de9a787c221aae7f178f43827c799028 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 16 Aug 2013 12:38:12 -0700
Subject: SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms
 converted many values over to units system in effort to track down source of
 0 ping

---
 indra/newview/llappviewer.cpp               |  6 +--
 indra/newview/llappviewer.h                 |  2 +-
 indra/newview/llfloaterabout.cpp            |  2 +-
 indra/newview/llfloaterhardwaresettings.cpp |  8 ++--
 indra/newview/llinspect.cpp                 |  2 +-
 indra/newview/llstartup.cpp                 |  2 +-
 indra/newview/llviewercontrol.cpp           |  2 +-
 indra/newview/llviewerdisplay.cpp           |  4 +-
 indra/newview/llviewerobject.cpp            |  8 ++--
 indra/newview/llviewerobject.h              |  6 +--
 indra/newview/llviewerregion.h              |  8 ++--
 indra/newview/llviewerstats.cpp             | 10 ++---
 indra/newview/llviewertexturelist.cpp       | 63 +++++++++++++++--------------
 indra/newview/llviewertexturelist.h         |  8 ++--
 14 files changed, 66 insertions(+), 65 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0a1a78c5b4..339a8f1ab0 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -324,7 +324,7 @@ BOOL				gUseWireframe = FALSE;
 LLVFS* gStaticVFS = NULL;
 
 LLMemoryInfo gSysMemory;
-U64 gMemoryAllocated = 0; // updated in display_stats() in llviewerdisplay.cpp
+U64Bytes gMemoryAllocated(0); // updated in display_stats() in llviewerdisplay.cpp
 
 std::string gLastVersionChannel;
 
@@ -3329,8 +3329,8 @@ void LLAppViewer::writeSystemInfo()
 	gDebugInfo["CPUInfo"]["CPUSSE"] = gSysCPU.hasSSE();
 	gDebugInfo["CPUInfo"]["CPUSSE2"] = gSysCPU.hasSSE2();
 	
-	gDebugInfo["RAMInfo"]["Physical"] = (LLSD::Integer)(gSysMemory.getPhysicalMemoryKB());
-	gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated>>10); // MB -> KB
+	gDebugInfo["RAMInfo"]["Physical"] = (LLSD::Integer)(gSysMemory.getPhysicalMemoryKB().value());
+	gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated.valueInUnits<LLUnits::Kibibytes>());
 	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 60a1045f58..10452e64e2 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -367,7 +367,7 @@ class LLVFS;
 extern LLVFS	*gStaticVFS;
 
 extern LLMemoryInfo gSysMemory;
-extern U64 gMemoryAllocated;
+extern U64Bytes gMemoryAllocated;
 
 extern std::string gLastVersionChannel;
 
diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 84f0d115ae..ad94949863 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() / 1024);
+	info["MEMORY_MB"] = LLSD::Integer(gSysMemory.getPhysicalMemoryKB().valueInUnits<LLUnits::Mibibytes>());
 	// 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 116bd241c4..adb490d524 100755
--- a/indra/newview/llfloaterhardwaresettings.cpp
+++ b/indra/newview/llfloaterhardwaresettings.cpp
@@ -89,10 +89,10 @@ void LLFloaterHardwareSettings::refresh()
 
 void LLFloaterHardwareSettings::refreshEnabledState()
 {
-	S32 min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
-	S32 max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting();
-	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem);
-	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem);
+	S32Mibibytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
+	S32Mibibytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting();
+	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value());
+	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value());
 
 	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
 		!gGLManager.mHasVertexBufferObject)
diff --git a/indra/newview/llinspect.cpp b/indra/newview/llinspect.cpp
index 14382e82d7..e6cb068613 100755
--- a/indra/newview/llinspect.cpp
+++ b/indra/newview/llinspect.cpp
@@ -59,7 +59,7 @@ void LLInspect::draw()
 	}
 	else if (mCloseTimer.getStarted())
 	{
-		F32 alpha = clamp_rescale(mCloseTimer.getElapsedTimeF32(), 0.f, FADE_TIME, 1.f, 0.f);
+		F32 alpha = clamp_rescale(mCloseTimer.getElapsedTimeF32(), 0.f, FADE_TIME(), 1.f, 0.f);
 		LLViewDrawContext context(alpha);
 		LLFloater::draw();
 		if (mCloseTimer.getElapsedTimeF32() > FADE_TIME)
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 61def8f723..fdd289c823 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1507,7 +1507,7 @@ bool idle_startup()
 			gFirstSim,
 			gSavedSettings.getS32("UseCircuitCodeMaxRetries"),
 			FALSE,
-			gSavedSettings.getF32("UseCircuitCodeTimeout"),
+			(F32Seconds)gSavedSettings.getF32("UseCircuitCodeTimeout"),
 			use_circuit_callback,
 			NULL);
 
diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp
index 5523b541a9..d0491450dc 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(newvalue.asInteger());
+	gTextureList.updateMaxResidentTexMem(S32Mibibytes(newvalue.asInteger()));
 	return true;
 }
 
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 965c6ffbc6..cb5078b988 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -221,8 +221,8 @@ void display_stats()
 	if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq)
 	{
 		gMemoryAllocated = LLMemory::getCurrentRSS();
-		U32 memory = (U32)(gMemoryAllocated / (1024*1024));
-		LL_INFOS() << llformat("MEMORY: %d MB", memory) << LL_ENDL;
+		U32Mibibytes memory = gMemoryAllocated;
+		LL_INFOS() << llformat("MEMORY: %d MB", memory.value()) << LL_ENDL;
 		LLMemory::logMemoryInfo(TRUE) ;
 		gRecentMemoryTime.reset();
 	}
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 3d75f86154..b054e519e0 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -119,8 +119,8 @@ BOOL		LLViewerObject::sPulseEnabled(FALSE);
 BOOL		LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
 
 // sMaxUpdateInterpolationTime must be greater than sPhaseOutUpdateInterpolationTime
-F64			LLViewerObject::sMaxUpdateInterpolationTime = 3.0;		// For motion interpolation: after X seconds with no updates, don't predict object motion
-F64			LLViewerObject::sPhaseOutUpdateInterpolationTime = 2.0;	// For motion interpolation: after Y seconds with no updates, taper off motion prediction
+F64Seconds	LLViewerObject::sMaxUpdateInterpolationTime(3.0);		// For motion interpolation: after X seconds with no updates, don't predict object motion
+F64Seconds	LLViewerObject::sPhaseOutUpdateInterpolationTime(2.0);	// For motion interpolation: after Y seconds with no updates, taper off motion prediction
 
 std::map<std::string, U32> LLViewerObject::sObjectDataMap;
 
@@ -2190,7 +2190,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
 		LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(mesgsys->getSender());
 		if (cdp)
 		{
-			F32 ping_delay = 0.5f * mTimeDilation * ( ((F32)cdp->getPingDelay()) * 0.001f + gFrameDTClamped);
+			F32 ping_delay = 0.5f * mTimeDilation * ( ((F32)cdp->getPingDelay().valueInUnits<LLUnits::Seconds>()) + gFrameDTClamped);
 			LLVector3 diff = getVelocity() * ping_delay; 
 			new_pos_parent += diff;
 		}
@@ -2491,7 +2491,7 @@ void LLViewerObject::interpolateLinearMotion(const F64 & time, const F32 & dt)
 				if (cdp)
 				{
 					// Find out how many seconds since last packet arrived on the circuit
-					F64 time_since_last_packet = LLMessageSystem::getMessageTimeSeconds() - cdp->getLastPacketInTime();
+					F64Seconds time_since_last_packet = LLMessageSystem::getMessageTimeSeconds() - cdp->getLastPacketInTime();
 
 					if (!cdp->isAlive() ||		// Circuit is dead or blocked
 						 cdp->isBlocked() ||	// or doesn't seem to be getting any packets
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 5556a4c7d3..3943709049 100755
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -780,7 +780,7 @@ protected:
 	mutable LLVector3		mPositionRegion;
 	mutable LLVector3		mPositionAgent;
 
-	static void setPhaseOutUpdateInterpolationTime(F32 value)	{ sPhaseOutUpdateInterpolationTime = (F64) value;	}
+	static void setPhaseOutUpdateInterpolationTime(F32 value)	{ sPhaseOutUpdateInterpolationTime = (F64Seconds) value;	}
 	static void setMaxUpdateInterpolationTime(F32 value)		{ sMaxUpdateInterpolationTime = (F64) value;	}
 
 	static void	setVelocityInterpolate(BOOL value)		{ sVelocityInterpolate = value;	}
@@ -789,8 +789,8 @@ protected:
 private:	
 	static S32 sNumObjects;
 
-	static F64 sPhaseOutUpdateInterpolationTime;	// For motion interpolation
-	static F64 sMaxUpdateInterpolationTime;			// For motion interpolation
+	static F64Seconds sPhaseOutUpdateInterpolationTime;	// For motion interpolation
+	static F64Seconds sMaxUpdateInterpolationTime;			// For motion interpolation
 
 	static BOOL sVelocityInterpolate;
 	static BOOL sPingInterpolate;
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 9d2a333b1b..e07c2aa8d0 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -401,7 +401,7 @@ public:
 	LLWind  mWind;
 	LLViewerParcelOverlay	*mParcelOverlay;
 
-	F32		mBitsReceived;
+	F32Bits	mBitsReceived;
 	F32		mPacketsReceived;
 
 	LLMatrix4 mRenderMatrix;
@@ -436,14 +436,14 @@ private:
 	BOOL mIsEstateManager;
 
 	U32		mPacketsIn;
-	U32		mBitsIn;
-	U32		mLastBitsIn;
+	U32Bits	mBitsIn,
+			mLastBitsIn;
 	U32		mLastPacketsIn;
 	U32		mPacketsOut;
 	U32		mLastPacketsOut;
 	S32		mPacketsLost;
 	S32		mLastPacketsLost;
-	U32		mPingDelay;
+	U32Milliseconds		mPingDelay;
 	F32		mDeltaTime;				// Time since last measurement of lastPackets, Bits, etc
 
 	U64		mRegionFlags;			// includes damage flags
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 67005e1978..bb2c13df33 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -304,8 +304,8 @@ U32Bytes				gTotalWorldData,
 								gTotalTextureData;
 U32								gSimPingCount = 0;
 U32Bits				gObjectData;
-F32		gAvgSimPing = 0.f;
-U32Bytes		gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {U32Bytes(0)};
+F32Milliseconds		gAvgSimPing(0.f);
+U32Bytes			gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGORY] = {U32Bytes(0)};
 
 extern U32  gVisCompared;
 extern U32  gVisTested;
@@ -359,7 +359,7 @@ void update_statistics()
 	if (cdp)
 	{
 		sample(LLStatViewer::SIM_PING, F64Milliseconds (cdp->getPingDelay()));
-		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay())) / ((F32)gSimPingCount + 1);
+		gAvgSimPing = ((gAvgSimPing * (F32)gSimPingCount) + (F32)(cdp->getPingDelay().value())) / ((F32)gSimPingCount + 1);
 		gSimPingCount++;
 	}
 	else
@@ -494,14 +494,14 @@ void send_stats()
 	gSimFrames   = (F32) gFrameCount;
 
 	agent["agents_in_view"] = LLVOAvatar::sNumVisibleAvatars;
-	agent["ping"] = gAvgSimPing;
+	agent["ping"] = gAvgSimPing.value();
 	agent["meters_traveled"] = gAgent.getDistanceTraveled();
 	agent["regions_visited"] = gAgent.getRegionsVisited();
 	agent["mem_use"] = LLMemory::getCurrentRSS() / 1024.0;
 
 	LLSD &system = body["system"];
 	
-	system["ram"] = (S32) gSysMemory.getPhysicalMemoryKB();
+	system["ram"] = (S32) gSysMemory.getPhysicalMemoryKB().value();
 	system["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
 	system["cpu"] = gSysCPU.getCPUString();
 	unsigned char MACAddress[MAC_ADDRESS_BYTES];
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 888174a6cf..f4dc04bd51 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -89,7 +89,7 @@ void LLViewerTextureList::init()
 	mMaxTotalTextureMemInMegaBytes = 0 ;
 	
 	// Update how much texture RAM we're allowed to use.
-	updateMaxResidentTexMem(0); // 0 = use current
+	updateMaxResidentTexMem(S32Mibibytes(0)); // 0 = use current
 	
 	doPreloadImages();
 }
@@ -1231,28 +1231,28 @@ const S32 MIN_VIDEO_RAM = 32;
 const S32 MAX_VIDEO_RAM = 512; // 512MB max for performance reasons.
 
 // Returns min setting for TextureMemory (in MB)
-S32 LLViewerTextureList::getMinVideoRamSetting()
+S32Mibibytes LLViewerTextureList::getMinVideoRamSetting()
 {
-	S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped());
+	S32Mibibytes system_ram = gSysMemory.getPhysicalMemoryClamped();
 	//min texture mem sets to 64M if total physical mem is more than 1.5GB
-	return (system_ram > 1500) ? 64 : gMinVideoRam.value() ;
+	return (system_ram > S32Mibibytes(1500)) ? S32Mibibytes(64) : gMinVideoRam ;
 }
 
 //static
 // Returns max setting for TextureMemory (in MB)
-S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
+S32Mibibytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
 {
-	S32 max_texmem;
+	S32Mibibytes 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
-		S32 max_vram = gGLManager.mVRAM;
+		S32Mibibytes max_vram(gGLManager.mVRAM);
 
 		if(gGLManager.mIsATI)
 		{
 			//shrink the availabe vram for ATI cards because some of them do not handel texture swapping well.
-			max_vram = (S32)(max_vram * 0.75f);  
+			max_vram = max_vram * 0.75f; 
 		}
 
 		max_vram = llmax(max_vram, getMinVideoRamSetting());
@@ -1278,26 +1278,26 @@ S32 LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended)
 		LL_WARNS() << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << LL_ENDL;
 	}
 
-	S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB
+	S32Mibibytes 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, (S32)(system_ram/2));
+		max_texmem = llmin(max_texmem, system_ram/2);
 	else
-		max_texmem = llmin(max_texmem, (S32)(system_ram));
+		max_texmem = llmin(max_texmem, system_ram);
 		
-	max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), gMaxVideoRam.value()); 
+	max_texmem = llclamp(max_texmem, getMinVideoRamSetting(), gMaxVideoRam); 
 	
 	return max_texmem;
 }
 
-const S32 VIDEO_CARD_FRAMEBUFFER_MEM = 12; // MB
-const S32 MIN_MEM_FOR_NON_TEXTURE = 512 ; //MB
-void LLViewerTextureList::updateMaxResidentTexMem(S32 mem)
+const S32Mibibytes VIDEO_CARD_FRAMEBUFFER_MEM(12);
+const S32Mibibytes MIN_MEM_FOR_NON_TEXTURE(512);
+void LLViewerTextureList::updateMaxResidentTexMem(S32Mibibytes mem)
 {
 	// Initialize the image pipeline VRAM settings
-	S32 cur_mem = gSavedSettings.getS32("TextureMemory");
+	S32Mibibytes cur_mem(gSavedSettings.getS32("TextureMemory"));
 	F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
-	S32 default_mem = getMaxVideoRamSetting(true); // recommended default
+	S32Mibibytes default_mem(getMaxVideoRamSetting(true)); // recommended default
 	if (mem == 0)
 	{
 		mem = cur_mem > 0 ? cur_mem : default_mem;
@@ -1308,20 +1308,20 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem)
 	}
 
 	// limit the texture memory to a multiple of the default if we've found some cards to behave poorly otherwise
-	mem = llmin(mem, (S32) (mem_multiplier * (F32) default_mem));
+	mem = llmin(mem, S32Mibibytes(mem_multiplier * (F32Mibibytes)default_mem));
 
 	mem = llclamp(mem, getMinVideoRamSetting(), getMaxVideoRamSetting());
 	if (mem != cur_mem)
 	{
-		gSavedSettings.setS32("TextureMemory", mem);
+		gSavedSettings.setS32("TextureMemory", mem.value());
 		return; //listener will re-enter this function
 	}
 
 	// TODO: set available resident texture mem based on use by other subsystems
 	// currently max(12MB, VRAM/4) assumed...
 	
-	S32 vb_mem = mem;
-	S32 fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4);
+	S32Mibibytes vb_mem = mem;
+	S32Mibibytes fb_mem = llmax(VIDEO_CARD_FRAMEBUFFER_MEM, vb_mem/4);
 	mMaxResidentTexMemInMegaBytes = (vb_mem - fb_mem) ; //in MB
 	
 	mMaxTotalTextureMemInMegaBytes = mMaxResidentTexMemInMegaBytes * 2;
@@ -1331,12 +1331,12 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32 mem)
 	}
 
 	//system mem
-	S32 system_ram = (S32)BYTES_TO_MEGA_BYTES(gSysMemory.getPhysicalMemoryClamped()); // In MB
+	S32Mibibytes 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.
-	S32 min_non_texture_mem = llmin(system_ram / 2, MIN_MEM_FOR_NON_TEXTURE) ; 
+	S32Mibibytes min_non_texture_mem = llmin(system_ram / 2, MIN_MEM_FOR_NON_TEXTURE) ; 
 
 	if (mMaxTotalTextureMemInMegaBytes > system_ram - min_non_texture_mem)
 	{
@@ -1514,18 +1514,19 @@ void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **
 ///////////////////////////////////////////////////////////////////////////////
 
 //static
-const U32 SIXTEEN_MEG = 0x1000000;
-S32 LLViewerTextureList::calcMaxTextureRAM()
+const LLUnitImplicit<F32, LLUnits::Mibibytes> 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;
-	U32 available_memory = memory_info.getPhysicalMemoryClamped();
+	LLUnitImplicit<F32, LLUnits::Mibibytes> available_memory = memory_info.getPhysicalMemoryClamped();
 	
-	clamp_rescale((F32)available_memory,
-				  (F32)(SIXTEEN_MEG * 16),
-				  (F32)U32_MAX,
-				  (F32)(SIXTEEN_MEG * 4),
-				  (F32)(U32_MAX >> 1));
+	// 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 53bda6e6ab..9817fea811 100755
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -71,7 +71,7 @@ public:
 	static BOOL createUploadFile(const std::string& filename, const std::string& out_filename, const U8 codec);
 	static LLPointer<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> raw_image);
 	static void processImageNotInDatabase( LLMessageSystem *msg, void **user_data );
-	static S32 calcMaxTextureRAM();
+	static S32Bytes calcMaxTextureRAM();
 	static void receiveImageHeader(LLMessageSystem *msg, void **user_data);
 	static void receiveImagePacket(LLMessageSystem *msg, void **user_data);
 
@@ -105,7 +105,7 @@ public:
 	S32Mibibytes getMaxTotalTextureMem() const   { return mMaxTotalTextureMemInMegaBytes;}
 	S32 getNumImages()					{ return mImageList.size(); }
 
-	void updateMaxResidentTexMem(S32 mem);
+	void updateMaxResidentTexMem(S32Mibibytes mem);
 	
 	void doPreloadImages();
 	void doPrefetchImages();
@@ -113,8 +113,8 @@ public:
 	void clearFetchingRequests();
 	void setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level);
 
-	static S32 getMinVideoRamSetting();
-	static S32 getMaxVideoRamSetting(bool get_recommended = false);
+	static S32Mibibytes getMinVideoRamSetting();
+	static S32Mibibytes getMaxVideoRamSetting(bool get_recommended = false);
 	
 private:
 	void updateImagesDecodePriorities();
-- 
cgit v1.2.3


From 28151dd8367d558fa2622832eb3819624e19705d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 16 Aug 2013 17:58:41 -0600
Subject: fix for SH-4297: interesting: viewer-interesting starts loading
 cached scene late

---
 indra/newview/llviewerregion.cpp      | 36 +++++++++++++++++++++++------------
 indra/newview/llviewertexturelist.cpp | 24 ++++++++++++++---------
 indra/newview/pipeline.cpp            |  4 +++-
 3 files changed, 42 insertions(+), 22 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 24c56df8db..ba0402344e 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -72,6 +72,8 @@
 #include "llsdserialize.h"
 #include "llvieweroctree.h"
 #include "llviewerdisplay.h"
+#include "llviewerwindow.h"
+#include "llprogressview.h"
 
 #ifdef LL_WINDOWS
 	#pragma warning(disable:4355)
@@ -90,7 +92,7 @@ const U32 DEFAULT_MAX_REGION_WIDE_PRIM_COUNT = 15000;
 
 BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
 S32  LLViewerRegion::sLastCameraUpdated = 0;
-S32  LLViewerRegion::sNewObjectCreationThrottle = 0;
+S32  LLViewerRegion::sNewObjectCreationThrottle = -1;
 
 typedef std::map<std::string, std::string> CapabilityMap;
 
@@ -1205,7 +1207,12 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 
 	max_update_time -= update_timer.getElapsedTimeF32();	
 
-	if(max_update_time < 0.f)
+	if(gViewerWindow->getProgressView()->getVisible())
+	{
+		//in case rendering pipeline is not started yet.
+		mImpl->mVOCachePartition->cull(*(LLViewerCamera::getInstance()), false);
+	}
+	else if(max_update_time < 0.f)
 	{
 		return did_update;
 	}
@@ -1226,23 +1233,28 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 void LLViewerRegion::calcNewObjectCreationThrottle()
 {
 	static LLCachedControl<S32> new_object_creation_throttle(gSavedSettings,"NewObjectCreationThrottle");
+	static LLFrameTimer timer;
+
+	//
+	//sNewObjectCreationThrottle =
+	//-2: throttle is disabled because either the screen is showing progress view, or immediate after the screen is not black
+	//-1: throttle is disabled by the debug setting
+	//0:  no new object creation is allowed
+	//>0: valid throttling number
+	//
 
-	sNewObjectCreationThrottle = new_object_creation_throttle;
-	if(LLStartUp::getStartupState() < STATE_STARTED || gTeleportDisplay)
+	if(gViewerWindow->getProgressView()->getVisible())
 	{
-		sNewObjectCreationThrottle = -1; //cancel the throttling		
+		sNewObjectCreationThrottle = -2; //cancel the throttling
+		timer.reset();
 	}	
 	else if(sNewObjectCreationThrottle < 0) //just recoved from the login/teleport screen
 	{
-		if(new_object_creation_throttle > 0)
+		if(new_object_creation_throttle > 0 && timer.getElapsedTimeF32() > 2.0f) //wait for two seconds to reset the throttle
 		{
-			sNewObjectCreationThrottle = 4096; //a big number
+			sNewObjectCreationThrottle = new_object_creation_throttle; //reset
 		}
 	}
-	else
-	{
-		sNewObjectCreationThrottle = llmax((S32)new_object_creation_throttle, (S32)(sNewObjectCreationThrottle >> 1));
-	}
 }
 
 BOOL LLViewerRegion::isViewerCameraStatic()
@@ -1295,7 +1307,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 		mLastVisitedEntry = *iter;
 	}
 
-	mInvisibilityCheckHistory <<= 2;
+	mInvisibilityCheckHistory <<= 1;
 	if(!delete_list.empty())
 	{
 		mInvisibilityCheckHistory |= 1;
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 63debe0464..209334fb46 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -59,7 +59,8 @@
 #include "llxuiparser.h"
 #include "lltracerecording.h"
 #include "llviewerdisplay.h"
-#include "llstartup.h"
+#include "llviewerwindow.h"
+#include "llprogressview.h"
 ////////////////////////////////////////////////////////////////////////////
 
 void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
@@ -756,12 +757,9 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 		F32 lazy_flush_timeout = 30.f; // stop decoding
 		F32 max_inactive_time  = 20.f; // actually delete
 		S32 min_refs = 3; // 1 for mImageList, 1 for mUUIDMap, 1 for local reference
-		if(LLStartUp::getStartupState() < STATE_STARTED)
-		{
-			//do not remove pre-fetched images if viewer does not finish logging in.
-			lazy_flush_timeout = 30000.f;
-			max_inactive_time = 20000.f;
-		}
+
+		//reset imagep->getLastReferencedTimer() when screen is showing the progress view to avoid removing pre-fetched textures too soon.
+		bool reset_timer = gViewerWindow->getProgressView()->getVisible();
         
         static const S32 MAX_PRIO_UPDATES = gSavedSettings.getS32("TextureFetchUpdatePriorities");         // default: 32
 		const size_t max_update_count = llmin((S32) (MAX_PRIO_UPDATES*MAX_PRIO_UPDATES*gFrameIntervalSeconds.value()) + 1, MAX_PRIO_UPDATES);
@@ -789,7 +787,11 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 			S32 num_refs = imagep->getNumRefs();
 			if (num_refs == min_refs)
 			{
-				if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > lazy_flush_timeout)
+				if(reset_timer)
+				{
+					imagep->getLastReferencedTimer()->reset();
+				}
+				else if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > lazy_flush_timeout)
 				{
 					// Remove the unused image from the image list
 					deleteImage(imagep);
@@ -818,7 +820,11 @@ void LLViewerTextureList::updateImagesDecodePriorities()
 				}
 				else if(imagep->isInactive())
 				{
-					if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > max_inactive_time)
+					if(reset_timer)
+					{
+						imagep->getLastReferencedTimer()->reset();
+					}
+					else if (imagep->getLastReferencedTimer()->getElapsedTimeF32() > max_inactive_time)
 					{
 						imagep->setDeletionCandidate() ;
 					}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 6754918149..8d70629206 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -112,6 +112,7 @@
 #include "llfloaterpathfindingcharacters.h"
 #include "llpathfindingpathtool.h"
 #include "llscenemonitor.h"
+#include "llprogressview.h"
 
 #ifdef _DEBUG
 // Debug indices is disabled for now for debug performance - djs 4/24/02
@@ -2535,7 +2536,8 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 		LLVOCachePartition* vo_part = region->getVOCachePartition();
 		if(vo_part)
 		{
-			vo_part->cull(camera, can_use_occlusion && use_occlusion && !gUseWireframe);
+			bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe && !gViewerWindow->getProgressView()->getVisible();
+			vo_part->cull(camera, do_occlusion_cull);
 		}
 	}
 
-- 
cgit v1.2.3


From 612892b45a3413b16e40c49d3bfde77a4ca927fd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/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 +-
 41 files changed, 920 insertions(+), 940 deletions(-)

(limited to 'indra/newview')

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<U64, LLUnits::Microseconds> gFrameTime = 0;
-LLUnitImplicit<F32, LLUnits::Seconds> gFrameTimeSeconds = 0.f;
-LLUnitImplicit<F32, LLUnits::Seconds> 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<U64, LLUnits::Microseconds>	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<F32, LLUnits::Seconds>(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<LLUnits::Kibibytes>());
+	gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated.valueInUnits<LLUnits::Kilobytes>());
 	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<U64, LLUnits::Microseconds>	gStartTime;
-extern LLUnitImplicit<U64, LLUnits::Microseconds>   gFrameTime;					// The timestamp of the most-recently-processed frame
-extern LLUnitImplicit<F32, LLUnits::Seconds>		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
-extern LLUnitImplicit<F32, LLUnits::Seconds>		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 <boost/foreach.hpp>
 #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<ConversationParams>
 {
@@ -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<U32, LLUnits::Days> 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<LLUnits::Mibibytes>());
+	info["MEMORY_MB"] = LLSD::Integer(gSysMemory.getPhysicalMemoryKB().valueInUnits<LLUnits::Megabytes>());
 	// 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<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value());
 	getChild<LLSliderCtrl>("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<F32>  scene_load_sample_time(gSavedSettings, "SceneLoadingMonitorSampleTime");
+	static LLCachedControl<F32>  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<F32> 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<LLUnits::Kibibytes>();
+			os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(*it).valueInUnits<LLUnits::Kilobytes>();
 		}
 
 		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<U64, LLUnits::Microseconds> 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<LLHost,std::set<LLUUID> > cancel_queue_t;
 	cancel_queue_t mCancelQueue;										// Mfnq
-	F32Kibibits mTextureBandwidth;					// <none>
-	F32Kibibits mMaxBandwidth;						// Mfnq
+	F32 mTextureBandwidth;					// <none>
+	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<LLUnit<F64, LLUnits::Kilotriangles> >
 LLTrace::EventStatHandle<LLUnit<F64, LLUnits::Kilotriangles> >
 							TRIANGLES_DRAWN_PER_FRAME("trianglesdrawnperframestat");
 
-LLTrace::CountStatHandle<F64Kibibytes >	
+LLTrace::CountStatHandle<F64Kilobytes >	
 							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<F64Megabytes >	GL_TEX_MEM("gltexmemstat"),
 															GL_BOUND_MEM("glboundmemstat"),
 															RAW_MEM("rawmemstat"),
 															FORMATTED_MEM("formattedmemstat");
-LLTrace::SampleStatHandle<F64Kibibytes >	DELTA_BANDWIDTH("deltabandwidth", "Increase/Decrease in bandwidth based on packet loss"),
+LLTrace::SampleStatHandle<F64Kilobytes >	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<LLUnit<F64, LLUnits::Kilotriangles> > TRIANGLES_DRAWN;
 
-extern LLTrace::CountStatHandle<F64Kibibytes >	ACTIVE_MESSAGE_DATA_RECEIVED,
+extern LLTrace::CountStatHandle<F64Kilobytes >	ACTIVE_MESSAGE_DATA_RECEIVED,
 																	LAYERS_NETWORK_DATA_RECEIVED,
 																	OBJECT_NETWORK_DATA_RECEIVED,
 																	ASSET_UDP_DATA_RECEIVED,
@@ -196,7 +196,7 @@ extern LLTrace::SampleStatHandle<F64Megabytes >	GL_TEX_MEM,
 																	GL_BOUND_MEM,
 																	RAW_MEM,
 																	FORMATTED_MEM;
-extern LLTrace::SampleStatHandle<F64Kibibytes >	DELTA_BANDWIDTH,
+extern LLTrace::SampleStatHandle<F64Kilobytes >	DELTA_BANDWIDTH,
 																	MAX_BANDWIDTH;
 extern SimMeasurement<F64Milliseconds >	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> LLViewerFetchedTexture::sWhiteImagep = NULL;
 LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL;
 LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL;
 LLPointer<LLViewerFetchedTexture> 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<LLViewerFetchedTexture*>(tex) ;
+		return static_cast<LLViewerFetchedTexture*>(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<LLViewerTexture> LLViewerTextureManager::getLocalTexture(BOOL usemipmaps, BOOL generate_gl_tex)
 {
-	LLPointer<LLViewerTexture> tex = new LLViewerTexture(usemipmaps) ;
+	LLPointer<LLViewerTexture> 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<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLUUID& id, BOOL usemipmaps, BOOL generate_gl_tex) 
 {
-	LLPointer<LLViewerTexture> tex = new LLViewerTexture(id, usemipmaps) ;
+	LLPointer<LLViewerTexture> 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<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const LLImageRaw* raw, BOOL usemipmaps) 
 {
-	LLPointer<LLViewerTexture> tex = new LLViewerTexture(raw, usemipmaps) ;
-	tex->setCategory(LLGLTexture::LOCAL) ;
-	return tex ;
+	LLPointer<LLViewerTexture> tex = new LLViewerTexture(raw, usemipmaps);
+	tex->setCategory(LLGLTexture::LOCAL);
+	return tex;
 }
 LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 width, const U32 height, const U8 components, BOOL usemipmaps, BOOL generate_gl_tex) 
 {
-	LLPointer<LLViewerTexture> tex = new LLViewerTexture(width, height, components, usemipmaps) ;
+	LLPointer<LLViewerTexture> 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<LLImageRaw> 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<LLImageRaw> 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<LLViewerFetchedTexture> 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<bool> 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<S32>  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<bool> 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<LLViewerTexture> >::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<LLTexturePipelineTester::LLTextureTestSession*>(mBaseSessionp) ;
-	LLTexturePipelineTester::LLTextureTestSession* current_sessionp = dynamic_cast<LLTexturePipelineTester::LLTextureTestSession*>(mCurrentSessionp) ;
+	LLTexturePipelineTester::LLTextureTestSession* base_sessionp = dynamic_cast<LLTexturePipelineTester::LLTextureTestSession*>(mBaseSessionp);
+	LLTexturePipelineTester::LLTextureTestSession* current_sessionp = dynamic_cast<LLTexturePipelineTester::LLTextureTestSession*>(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 <map>
 #include <list>
 
-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<F32, LLUnits::Mibibytes> 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<F32, LLUnits::Mibibytes> 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<LLImageJ2C> convertToUploadFile(LLPointer<LLImageRaw> 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<LLVLData *> 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<LLUUID>& ids)
+S32Bytes LLVOAvatar::totalTextureMemForUUIDS(std::set<LLUUID>& ids)
 {
-	S32 result = 0;
+	S32Bytes result(0);
 	for (std::set<LLUUID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
 	{
 		LLViewerFetchedTexture *imagep = gTextureList.findImage(*it);
@@ -4242,12 +4242,12 @@ void LLVOAvatar::collectTextureUUIDs(std::set<LLUUID>& 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<LLUUID> 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<LLUUID> local_texture_ids;
 	collectLocalTextureUUIDs(local_texture_ids);
@@ -4256,7 +4256,7 @@ void LLVOAvatar::releaseOldTextures()
 	std::set<LLUUID> 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<LLUUID>& ids);
-	bool 						allTexturesCompletelyDownloaded(std::set<LLUUID>& 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<LLUUID>& ids) const;
-	void 						collectBakedTextureUUIDs(std::set<LLUUID>& ids) const;
-	void 						collectTextureUUIDs(std::set<LLUUID>& ids);
-	void						releaseOldTextures();
+	S32Bytes				totalTextureMemForUUIDS(std::set<LLUUID>& ids);
+	bool 					allTexturesCompletelyDownloaded(std::set<LLUUID>& 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<LLUUID>& ids) const;
+	void 					collectBakedTextureUUIDs(std::set<LLUUID>& ids) const;
+	void 					collectTextureUUIDs(std::set<LLUUID>& 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<U64, LLUnits::Microseconds> gFrameTime;
+extern U64MicrosecondsImplicit gFrameTime;
 
 LLPointer<LLVertexBuffer> 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<U64, LLUnits::Microseconds> space_time_usec)
+void LLWorld::setSpaceTimeUSec(const U64MicrosecondsImplicit space_time_usec)
 {
 	mSpaceTimeUSec = space_time_usec;
 }
 
-LLUnitImplicit<U64, LLUnits::Microseconds> 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<U64, LLUnits::Microseconds> space_time_usec);
-	LLUnitImplicit<U64, LLUnits::Microseconds> 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<U64, LLUnits::Microseconds> 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<F32, LLUnits::Seconds>(max_dtime));
+	max_dtime = llmax(update_timer.getElapsedTimeF32()+0.001f, F32SecondsImplicit(max_dtime));
 	LLSpatialGroup* last_group = NULL;
 	LLSpatialBridge* last_bridge = NULL;
 
-- 
cgit v1.2.3


From 3e31cb112daf0a759737ba4ec55a8772361483f2 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 19 Aug 2013 11:50:30 -0700
Subject: BUILDFIX: fixed some units errors

---
 indra/newview/tests/llviewerassetstats_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index bd42b59df2..9a39fdaa29 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -257,7 +257,7 @@ namespace tut
 
 		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_TEXTURE, false, false);
 
-		LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_GESTURE, false, false, 12300000ULL);
+		LLViewerAssetStatsFF::record_response(LLViewerAssetType::AT_GESTURE, false, false, (U64Microseconds)12300000ULL);
 	}
 
 	// Create a non-global instance and check the structure
-- 
cgit v1.2.3


From 9c256611f1814b843e1adc29f8a9185a3519eeaf Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 19 Aug 2013 16:05:03 -0700
Subject: BUILDFIX: removed consideration of some bad overloads in return type
 evaluation of unit operators

---
 indra/newview/llfasttimerview.cpp | 12 ++++++------
 indra/newview/llfasttimerview.h   |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 36cbd67333..e8db263fae 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -282,14 +282,14 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 		}
 
 		if (hover_bar)
-			{
+		{
 			mHoverID = hover_bar->mTimeBlock;
 			if (mHoverTimer != mHoverID)
-				{
-					// could be that existing tooltip is for a parent and is thus
-					// covering region for this new timer, go ahead and unblock 
-					// so we can create a new tooltip
-					LLToolTipMgr::instance().unblockToolTips();
+			{
+				// could be that existing tooltip is for a parent and is thus
+				// covering region for this new timer, go ahead and unblock 
+				// so we can create a new tooltip
+				LLToolTipMgr::instance().unblockToolTips();
 				mHoverTimer = mHoverID;
 				mToolTipRect.set(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(),
 								row.mTop,
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index d184aae03d..8c2c939c5e 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -128,7 +128,7 @@ private:
 		DISPLAY_HZ
 	}								mDisplayType;
 	bool							mPauseHistory;
-	F64Seconds	mAllTimeMax,
+	F64Seconds						mAllTimeMax,
 									mTotalTimeDisplay;
 	S32								mScrollIndex,
 									mHoverBarIndex,
-- 
cgit v1.2.3


From 31bf481a7b5f079d95be6a44a45502bb957e0941 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 21 Aug 2013 10:19:44 -0600
Subject: fix some objects not rendered when login process is very long

---
 indra/newview/llvieweroctree.h |  1 +
 indra/newview/llvocache.cpp    | 15 +++++++++++++--
 indra/newview/llvocache.h      |  7 +++----
 3 files changed, 17 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 7fdb5661d8..0cd0206223 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -327,6 +327,7 @@ public:
 
 	//virtual
 	BOOL isRecentlyVisible() const;
+	LLViewerOctreePartition* getSpatialPartition()const {return mSpatialPartition;}
 
 	static U32 getNewOcclusionQueryObjectName();
 	static void releaseOcclusionQueryObjectName(U32 name);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 838ac353d1..3bd71e2648 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -261,6 +261,12 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 	if(getEntry() != NULL && isState(INACTIVE))
 	{
 		updateParentBoundingInfo(entry);
+		if(getGroup())
+		{
+			LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup();
+			group->unbound();
+			((LLVOCachePartition*)group->getSpatialPartition())->setDirty();
+		}
 	}
 }
 	
@@ -479,12 +485,17 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 	new LLOcclusionCullingGroup(mOctree, this);
 }
 
+void LLVOCachePartition::setDirty()
+{
+	mDirty = TRUE;
+}
+
 void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
 {
 	llassert(entry->hasVOCacheEntry());
 
 	mOctree->insert(entry);
-	mDirty = TRUE;
+	setDirty();
 }
 	
 void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
@@ -615,7 +626,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	}
 
 	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
-	mCullHistory[LLViewerCamera::sCurCameraID] <<= 2;
+	mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
 
 	//localize the camera
 	LLVector3 region_agent = mRegionp->getOriginAgent();
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index c448b97b80..71be9de759 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -162,14 +162,13 @@ public:
 	/*virtual*/ S32 cull(LLCamera &camera, bool do_occlusion);
 	void addOccluders(LLviewerOctreeGroup* gp);
 	void resetOccluders();
-
-	static	LLTrace::MemStatHandle	sMemStat;
-
-public:	
 	void processOccluders(LLCamera* camera);
+	
+	void setDirty();
 
 public:
 	static BOOL sNeedsOcclusionCheck;
+	static	LLTrace::MemStatHandle	sMemStat;
 
 private:
 	BOOL  mDirty;
-- 
cgit v1.2.3


From 2c6bc5afa59a88136fd6de4ebf0cb99ea7cdef3f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/newview/llviewerobject.cpp                   |  9 ++-
 .../newview/skins/default/xui/en/floater_stats.xml | 88 +++++++---------------
 2 files changed, 33 insertions(+), 64 deletions(-)

(limited to 'indra/newview')

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_bar name="packet_loss"
                   label="Packet Loss"
-                  stat="packetslostpercentstat"
-                  decimal_digits="3"/>
+                  stat="packetslostpercentstat"/>
         <stat_bar name="ping"
                   label="Ping Sim"
                   stat="simpingstat"/>
@@ -71,12 +70,10 @@
                     stat="numobjectsstat"/>
           <stat_bar name="newobjs"
                     label="New Objects"
-                    stat="numnewobjectsstat"
-                    bar_max="2000"/>
+                    stat="numnewobjectsstat"/>
           <stat_bar name="object_cache_hits"
                     label="Object Cache Hit Rate"
                     stat="object_cache_hits"
-                    bar_max="100"
                     show_history="true"/>
         </stat_view>
         <stat_view name="texture"
@@ -86,7 +83,6 @@
           <stat_bar name="texture_cache_hits"
                     label="Cache Hit Rate"
                     stat="texture_cache_hits"
-                    bar_max="100"
                     show_history="true"/>
           <stat_bar name="texture_cache_read_latency"
                     label="Cache Read Latency"
@@ -100,20 +96,16 @@
                     stat="numrawimagesstat"/>
           <stat_bar name="gltexmemstat"
                     label="GL Mem"
-                    stat="gltexmemstat"
-                    decimal_digits="1"/>
+                    stat="gltexmemstat"/>
           <stat_bar name="formattedmemstat"
                     label="Formatted Mem"
-                    stat="formattedmemstat"
-                    decimal_digits="3"/>
+                    stat="formattedmemstat"/>
           <stat_bar name="rawmemstat"
                     label="Raw Mem"
-                    stat="rawmemstat"
-                    decimal_digits="3"/>
+                    stat="rawmemstat"/>
           <stat_bar name="glboundmemstat"
                     label="Bound Mem"
-                    stat="glboundmemstat"
-                    decimal_digits="3"/>
+                    stat="glboundmemstat"/>
         </stat_view>
         
         <stat_view name="network"
@@ -168,9 +160,7 @@
                  setting="OpenDebugStatSim">
         <stat_bar name="simtimedilation"
                   label="Time Dilation"
-                  stat="simtimedilation"
-                  decimal_digits="3"
-                  bar_max="1" />
+                  stat="simtimedilation"/>
         <stat_bar name="simfps"
                   label="Sim FPS"
                   stat="simfps"
@@ -202,28 +192,22 @@
                   decimal_digits="1"/>
         <stat_bar name="simmainagents"
                   label="Main Agents"
-                  stat="simmainagents"
-                  bar_max="80"/>
+                  stat="simmainagents"/>
         <stat_bar name="simchildagents"
                   label="Child Agents"
                   stat="simchildagents"/>
         <stat_bar name="simobjects"
                   label="Objects"
-                  stat="simobjects"
-                  bar_max="30000" />
+                  stat="simobjects"/>
         <stat_bar name="simactiveobjects"
                   label="Active Objects"
-                  stat="simactiveobjects"
-                  bar_max="5000"/>
+                  stat="simactiveobjects"/>
         <stat_bar name="simactivescripts"
                   label="Active Scripts"
-                  stat="simactivescripts"
-                  bar_max="15000"/>
+                  stat="simactivescripts"/>
         <stat_bar name="simpctscriptsrun"
                   label="Scripts Run"
-                  stat="simpctscriptsrun"
-                  bar_max="100"
-                  decimal_digits="3"/>
+                  stat="simpctscriptsrun"/>
         <stat_bar name="simscripteps"
                   label="Script Events"
                   stat="simscripteps"
@@ -234,16 +218,13 @@
                    show_label="true">
           <stat_bar name="simsimaistepmsec"
                     label="AI Step Time"
-                    stat="simsimaistepmsec"
-                    decimal_digits="3"/>
+                    stat="simsimaistepmsec"/>
           <stat_bar name="simsimskippedsilhouettesteps"
                     label="Skipped Silhouette Steps"
                     stat="simsimskippedsilhouettesteps"
-                    unit_label="/sec"
-                    bar_max="45"/>
+                    unit_label="/sec"/>
           <stat_bar name="simsimpctsteppedcharacters"
                     stat="simsimpctsteppedcharacters"
-                    bar_max="100"
                     decimal_digits="1"/>
         </stat_view>
         <stat_bar name="siminpps"
@@ -261,7 +242,7 @@
                   label="Pending Uploads"
                   stat="simpendinguploads"/>
         <stat_bar name="simtotalunackedbytes"
-                  label="Total Unacked Bytes"
+                  label="Total Unacked Data"
                   stat="simtotalunackedbytes"
                   decimal_digits="1"/>
         <stat_view name="simperf"
@@ -270,60 +251,47 @@
                    show_label="true">
           <stat_bar name="simframemsec"
                     label="Total Frame Time"
-                    stat="simframemsec"
-                    decimal_digits="3"/>
+                    stat="simframemsec"/>
           <stat_bar name="simnetmsec"
                     label="Net Time"
-                    stat="simnetmsec"
-                    decimal_digits="3"/>
+                    stat="simnetmsec"/>
           <stat_bar name="simsimphysicsmsec"
                     label="Physics Time"
-                    stat="simsimphysicsmsec"
-                    decimal_digits="3"/>
+                    stat="simsimphysicsmsec"/>
           <stat_bar name="simsimothermsec"
                     label="Simulation Time"
-                    stat="simsimothermsec"
-                    decimal_digits="3"/>
+                    stat="simsimothermsec"/>
           <stat_bar name="simagentmsec"
                     label="Agent Time"
-                    stat="simagentmsec"
-                    decimal_digits="3"/>
+                    stat="simagentmsec"/>
           <stat_bar name="simimagesmsec"
                     label="Images Time"
-                    stat="simimagesmsec"
-                    decimal_digits="3"/>
+                    stat="simimagesmsec"/>
           <stat_bar name="simscriptmsec"
                     label="Script Time"
-                    stat="simscriptmsec"
-                    decimal_digits="3"/>
+                    stat="simscriptmsec"/>
           <stat_bar name="simsparemsec"
                     label="Spare Time"
-                    stat="simsparemsec"
-                    decimal_digits="3"/>
+                    stat="simsparemsec"/>
           <stat_view name="timedetails"
                      label="Time Details"
                      follows="left|top|right"
                      show_label="true">
             <stat_bar name="simsimphysicsstepmsec"
                       label="Physics Step"
-                      stat="simsimphysicsstepmsec"
-                      decimal_digits="3"/>
+                      stat="simsimphysicsstepmsec"/>
             <stat_bar name="simsimphysicsshapeupdatemsec"
                       label="Update Phys Shapes"
-                      stat="simsimphysicsshapeupdatemsec"
-                      decimal_digits="3"/>
+                      stat="simsimphysicsshapeupdatemsec"/>
             <stat_bar name="simsimphysicsothermsec"
                       label="Physics Other"
-                      stat="simsimphysicsothermsec"
-                      decimal_digits="3"/>
+                      stat="simsimphysicsothermsec"/>
             <stat_bar name="simsleepmsec"
                       label="Sleep Time"
-                      stat="simsleepmsec"
-                      decimal_digits="3"/>
+                      stat="simsleepmsec"/>
             <stat_bar name="simpumpiomsec"
                       label="Pump IO"
-                      stat="simpumpiomsec"
-                      decimal_digits="3"/>
+                      stat="simpumpiomsec"/>
           </stat_view>
         </stat_view>
       </stat_view>
-- 
cgit v1.2.3


From 7b5618aeaeb4df31bd3f9436e067b26fb5be866b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 22 Aug 2013 12:22:34 -0600
Subject: fix for SH-4400: Interesting: Side effect 1 of unloading culled
 objects.

---
 indra/newview/lldrawable.cpp     | 16 ++--------------
 indra/newview/lldrawable.h       |  1 -
 indra/newview/llvieweroctree.cpp |  2 +-
 indra/newview/llvieweroctree.h   |  2 --
 indra/newview/llvocache.cpp      | 35 +++++++++++++++++++++++++++--------
 indra/newview/llvocache.h        |  6 ++++--
 6 files changed, 34 insertions(+), 28 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index ad3df55ef1..a480eed2e7 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1058,12 +1058,8 @@ bool LLDrawable::isRecentlyVisible() const
 
 	if(!vis)
 	{
-		LLviewerOctreeGroup* group = getGroup();
-		if (group && group->isRecentlyVisible())
-		{
-			LLViewerOctreeEntryData::setVisible();
-			vis = TRUE ;
-		}
+		const U32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one.
+		vis = (sCurVisible - getVisible() < MIN_VIS_FRAME_RANGE);
 	}
 
 	return vis ;
@@ -1140,14 +1136,6 @@ LLSpatialPartition* LLDrawable::getSpatialPartition()
 	return retval;
 }
 
-//virtual
-U32 LLDrawable::getMinFrameRange() const
-{
-	const U32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one.
-
-	return MIN_VIS_FRAME_RANGE ;
-}
-
 //=======================================
 // Spatial Partition Bridging Drawable
 //=======================================
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index efb3e1d89d..b94f663f21 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -194,7 +194,6 @@ public:
 
 	LLSpatialPartition* getSpatialPartition();
 	
-	virtual U32 getMinFrameRange()const;
 	void removeFromOctree();
 
 	void setSpatialBridge(LLSpatialBridge* bridge) { mSpatialBridge = (LLDrawable*) bridge; }
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 637505a826..481befdb44 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -409,7 +409,7 @@ bool LLViewerOctreeEntryData::isRecentlyVisible() const
 		return true;
 	}
 
-	return (sCurVisible - mEntry->mVisible < getMinFrameRange());
+	return false;
 }
 
 void LLViewerOctreeEntryData::setVisible() const
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 0cd0206223..e610db96eb 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -149,8 +149,6 @@ public:
 	
 	virtual void setOctreeEntry(LLViewerOctreeEntry* entry);
 
-	virtual U32  getMinFrameRange()const = 0;
-
 	F32                  getBinRadius() const   {return mEntry->getBinRadius();}
 	const LLVector4a*    getSpatialExtents() const;
 	LLviewerOctreeGroup* getGroup()const;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 3bd71e2648..2430fa556a 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -238,12 +238,6 @@ void LLVOCacheEntry::setState(U32 state)
 	}
 }
 
-//virtual 
-U32  LLVOCacheEntry::getMinFrameRange()const
-{
-	return mMinFrameRange;
-}
-
 void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 {
 	llassert(entry != NULL);
@@ -371,6 +365,28 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 	return success ;
 }
 
+bool LLVOCacheEntry::isRecentlyVisible() const
+{
+	bool vis = LLViewerOctreeEntryData::isRecentlyVisible();
+
+	if(!vis)
+	{
+		vis = (sCurVisible - getVisible() < mMinFrameRange);
+	}
+
+	if(!vis && !mParentID && mSceneContrib > 0.f)
+	{
+		//projection area: mSceneContrib
+
+		//squared distance
+		const F32 SQUARED_CUT_OFF_DIST = 225.0; //15m
+		F32 rad = getBinRadius();
+		vis = (rad * rad / mSceneContrib > SQUARED_CUT_OFF_DIST);
+	}
+
+	return vis;
+}
+
 void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update)
 {
 	if(!needs_update && getVisible() >= last_update)
@@ -387,8 +403,11 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool
 	lookAt.setSub(center, origin);
 	F32 squared_dist = lookAt.dot3(lookAt).getF32();
 
-	F32 rad = getBinRadius();
-	mSceneContrib = rad * rad / squared_dist;
+	if(squared_dist > 0.f)
+	{
+		F32 rad = getBinRadius();
+		mSceneContrib = rad * rad / squared_dist;
+	}
 
 	setVisible();
 }
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 71be9de759..4eca083445 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -83,12 +83,14 @@ public:
 	bool hasState(U32 state)   {return mState & state;}
 	U32  getState() const      {return mState;}
 	
+	//virtual
+	bool isRecentlyVisible() const;
+
 	U32 getLocalID() const			{ return mLocalID; }
 	U32 getCRC() const				{ return mCRC; }
 	S32 getHitCount() const			{ return mHitCount; }
 	S32 getCRCChangeCount() const	{ return mCRCChangeCount; }
-	U32 getMinFrameRange()const;	
-
+	
 	void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update);
 	void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;}
 	F32 getSceneContribution() const             { return mSceneContrib;}
-- 
cgit v1.2.3


From 11a78da4b12b99e820c2018f1a0b70ea2a222a07 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 23 Aug 2013 12:23:21 -0600
Subject: more fix for SH-4400: Interesting: Side effect 1 of unloading culled
 objects.

---
 indra/newview/llvocache.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 2430fa556a..ebde17dcef 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -374,14 +374,13 @@ bool LLVOCacheEntry::isRecentlyVisible() const
 		vis = (sCurVisible - getVisible() < mMinFrameRange);
 	}
 
-	if(!vis && !mParentID && mSceneContrib > 0.f)
+	//combination of projected area and squared distance
+	if(!vis && !mParentID && mSceneContrib > 0.0311f) //projection angle > 10 (degree)
 	{
-		//projection area: mSceneContrib
-
 		//squared distance
-		const F32 SQUARED_CUT_OFF_DIST = 225.0; //15m
+		const F32 SQUARED_CUT_OFF_DIST = 256.0; //16m
 		F32 rad = getBinRadius();
-		vis = (rad * rad / mSceneContrib > SQUARED_CUT_OFF_DIST);
+		vis = (rad * rad / mSceneContrib < SQUARED_CUT_OFF_DIST);
 	}
 
 	return vis;
-- 
cgit v1.2.3


From 55df26a7bf9e141205484543cf02759f599bf521 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 23 Aug 2013 12:24:58 -0600
Subject: temporary fix for rendering starts late when running on pdp station

---
 indra/newview/llvocache.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index ebde17dcef..dc7b907a35 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -638,10 +638,10 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	}
 	mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
 
-	if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
-	{
-		return 0; //nothing changed, skip culling
-	}
+	//if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
+	//{
+	//	return 0; //nothing changed, skip culling
+	//}
 
 	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
 	mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
-- 
cgit v1.2.3


From b667d20e00e4ea5f1d5a619d2868b502583deb43 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 23 Aug 2013 15:34:41 -0700
Subject: fixed issue with poor framerate after clearing cache

---
 indra/newview/llappviewer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index f506765da3..0f155b8ad7 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1463,7 +1463,7 @@ bool LLAppViewer::mainLoop()
 					ms_sleep(500);
 				}
 
-				const F64 max_idle_time = llmin(.005f*10.f*(F32MillisecondsImplicit)gFrameTimeSeconds, F32MillisecondsImplicit(5)); // 5 ms a second
+				const F64Milliseconds max_idle_time = llmin(.005f*10.f*(F32Milliseconds)gFrameTimeSeconds, F32Milliseconds(5)); // 5 ms a second
 				idleTimer.reset();
 				S32 total_work_pending = 0;
 				S32 total_io_pending = 0;	
-- 
cgit v1.2.3


From 74d4933ab77beee3c139065758033d51f474c5f1 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 26 Aug 2013 11:32:58 -0600
Subject: reversion of object cache version number change

---
 indra/newview/llappviewer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0f155b8ad7..7f37cee8b8 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -4030,7 +4030,7 @@ U32 LLAppViewer::getObjectCacheVersion()
 {
 	// Viewer object cache version, change if object update
 	// format changes. JC
-	const U32 INDRA_OBJECT_CACHE_VERSION = 15;
+	const U32 INDRA_OBJECT_CACHE_VERSION = 14;
 
 	return INDRA_OBJECT_CACHE_VERSION;
 }
-- 
cgit v1.2.3


From 041ab1c46c681de63c934af031c1d1a0b3f5a4da Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 26 Aug 2013 11:33:37 -0600
Subject: reversion of rendering starts late change

---
 indra/newview/llvocache.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index dc7b907a35..ebde17dcef 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -638,10 +638,10 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	}
 	mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
 
-	//if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
-	//{
-	//	return 0; //nothing changed, skip culling
-	//}
+	if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
+	{
+		return 0; //nothing changed, skip culling
+	}
 
 	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
 	mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
-- 
cgit v1.2.3


From 8535b87544cc2e71896716a4cd1c3c2445ff4af0 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 26 Aug 2013 18:00:24 -0700
Subject: removed some unecessary template parameters from LLUnit member
 functions forced unit conversion code to inline unit conversion now no longer
 converts all the way to base and back, but tries to find equivalent units as
 early as possible fixed another llinfos instance scene monitor now outputs
 n/a for invalid samples

---
 indra/newview/llscenemonitor.cpp  | 31 +++++++++++++++++++++++++------
 indra/newview/llviewermessage.cpp |  4 ++--
 2 files changed, 27 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 7fafabb493..57d58a9d4e 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -565,8 +565,9 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		for (S32 frame = 1; frame <= frame_count; frame++)
 		{
-			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getSum(*it);
+			Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame);
+			samples += recording.getSampleCount(*it);
+			row << ", " << recording.getSum(*it);
 		}
 
 		row << '\n';
@@ -597,8 +598,17 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		for (S32 frame = 1; frame <= frame_count; frame++)
 		{
-			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it);
+			Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame);
+			samples += recording.getSampleCount(*it);
+			F64 mean = recording.getMean(*it);
+			if (llisnan(mean))
+			{
+				row << ", n/a";
+			}
+			else
+			{
+				row << ", " << mean;
+			}
 		}
 
 		row << '\n';
@@ -629,8 +639,17 @@ void LLSceneMonitor::dumpToFile(std::string file_name)
 
 		for (S32 frame = 1; frame <= frame_count; frame++)
 		{
-			samples += scene_load_recording.getPrevRecording(frame_count - frame).getSampleCount(*it);
-			row << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMean(*it);
+			Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame);
+			samples += recording.getSampleCount(*it);
+			F64 mean = recording.getMean(*it);
+			if (llisnan(mean))
+			{
+				row << ", n/a";
+			}
+			else
+			{
+				row << ", " << mean;
+			}
 		}
 
 		row << '\n'; 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index b4ed2adb07..7de8e1ff12 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -7219,10 +7219,10 @@ void process_script_teleport_request(LLMessageSystem* msg, void**)
 	LLFloaterWorldMap* instance = LLFloaterWorldMap::getInstance();
 	if(instance)
 	{
-		llinfos << "Object named " << object_name 
+		LL_INFOS() << "Object named " << object_name 
 			<< " is offering TP to region "
 			<< sim_name << " position " << pos
-			<< llendl;
+			<< LL_ENDL;
 
 		instance->trackURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]);
 		LLFloaterReg::showInstance("world_map", "center");
-- 
cgit v1.2.3


From a7aed07a5b620977fb74e4070e432eef01d11d3c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Aug 2013 13:41:19 -0700
Subject: broke out llunit.h into llunittype.h and llunits.h for unit
 declarations changed unit declarations macros to make a lot more sense

---
 indra/newview/llappviewer.h          | 2 +-
 indra/newview/llfasttimerview.h      | 2 +-
 indra/newview/lltextureinfodetails.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 6b16a96c11..d642d55b14 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -32,7 +32,7 @@
 #include "llsys.h"			// for LLOSInfo
 #include "lltimer.h"
 #include "llappcorehttp.h"
-#include "llunit.h"
+#include "llunits.h"
 
 class LLCommandLineParser;
 class LLFrameTimer;
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 8c2c939c5e..8c8eb99b59 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -29,7 +29,7 @@
 
 #include "llfloater.h"
 #include "llfasttimer.h"
-#include "llunit.h"
+#include "llunits.h"
 #include "lltracerecording.h"
 #include <deque>
 
diff --git a/indra/newview/lltextureinfodetails.h b/indra/newview/lltextureinfodetails.h
index 7cba87e5a8..a42c335035 100755
--- a/indra/newview/lltextureinfodetails.h
+++ b/indra/newview/lltextureinfodetails.h
@@ -28,7 +28,7 @@
 #define LL_LLTEXTUREINFODETAILS_H
 
 #include "lluuid.h"
-#include "llunit.h"
+#include "llunits.h"
 
 struct LLTextureInfoDetails
 {
-- 
cgit v1.2.3


From bf99887cbb8d69b5f29d18566ad082d2d0109e9c Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Aug 2013 19:32:26 -0700
Subject: SH-4453 FIX: Interesting: SceneLoadingMonitorEnabled does not work
 until the camera turns set enabled flag before calling freeze scene

---
 indra/newview/llscenemonitor.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 57d58a9d4e..ecffc67993 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -274,17 +274,17 @@ void LLSceneMonitor::capture()
 	if(mEnabled != enabled)
 	{
 		if(mEnabled)
-		{
+		{			
+			mEnabled = enabled;
 			unfreezeScene();
 			reset();
 			force_capture = true;
 		}
 		else
 		{
+			mEnabled = enabled;
 			freezeScene();
 		}
-
-		mEnabled = enabled;
 	}
 
 	if (mEnabled 
-- 
cgit v1.2.3


From b1297dce44ccf4b4875ec9ce0d9d78d563d877ee Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 27 Aug 2013 19:33:03 -0700
Subject: SH-4453 Interesting: SceneLoadingMonitorEnabled does not work until
 the camera turns made sceneloadingmonitor setting not persist

---
 indra/newview/app_settings/settings.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 015c307afc..b2e3c8b683 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9846,7 +9846,7 @@
       <key>Comment</key>
       <string>Enabled scene loading monitor if set</string>
       <key>Persist</key>
-      <integer>1</integer>
+      <integer>0</integer>
       <key>Type</key>
       <string>Boolean</string>
       <key>Value</key>
-- 
cgit v1.2.3


From edd1478cc0ba240d428fc4c35f9c97af7d2ce346 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 28 Aug 2013 17:27:28 -0600
Subject: fix for SH-4332: Cacheable object highlights from Render Metadata ->
 Update Type do not render

---
 indra/newview/llviewerobjectlist.cpp | 24 ++++++++++++++++--------
 indra/newview/llvocache.cpp          | 12 ------------
 indra/newview/llvocache.h            |  1 -
 3 files changed, 16 insertions(+), 21 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 4643430c6b..897da7f0b3 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -365,7 +365,16 @@ LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry*
 		
 	processUpdateCore(objectp, NULL, 0, OUT_FULL_CACHED, cached_dpp, justCreated, true);
 	objectp->loadFlags(entry->getUpdateFlags()); //just in case, reload update flags from cache.
-
+	
+	if(entry->getHitCount() > 0)
+	{
+		objectp->setLastUpdateType(OUT_FULL_CACHED);
+	}
+	else
+	{
+		objectp->setLastUpdateType(OUT_FULL_COMPRESSED); //newly cached
+		objectp->setLastUpdateCached(TRUE);
+	}
 	recorder.log(0.2f);
 	LLVOAvatar::cullAvatarsByPixelArea();
 
@@ -467,10 +476,10 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			
 				if(flags & FLAGS_TEMPORARY_ON_REZ)
 				{
-				compressed_dp.unpackUUID(fullid, "ID");
-				compressed_dp.unpackU32(local_id, "LocalID");
-				compressed_dp.unpackU8(pcode, "PCode");
-			}
+					compressed_dp.unpackUUID(fullid, "ID");
+					compressed_dp.unpackU32(local_id, "LocalID");
+					compressed_dp.unpackU8(pcode, "PCode");
+				}
 				else //send to object cache
 				{
 					regionp->cacheFullUpdate(compressed_dp, flags);
@@ -608,7 +617,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			LL_WARNS() << "Dead object " << objectp->mID << " in UUID map 1!" << LL_ENDL;
 		}
 
-		bool bCached = false;
+		//bool bCached = false;
 		if (compressed)
 		{
 			if (update_type != OUT_TERSE_IMPROVED) // OUT_FULL_COMPRESSED only?
@@ -641,8 +650,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 			processUpdateCore(objectp, user_data, i, update_type, NULL, justCreated);
 		}
 		recorder.objectUpdateEvent(local_id, update_type, objectp, msg_size);
-		objectp->setLastUpdateType(update_type);
-		objectp->setLastUpdateCached(bCached);
+		objectp->setLastUpdateType(update_type);		
 	}
 
 	recorder.log(0.2f);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index ebde17dcef..dcd1ae391d 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -286,18 +286,6 @@ void LLVOCacheEntry::removeAllChildren()
 	mChildrenList.clear();
 }
 
-LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP(U32 crc)
-{
-	if (  (mCRC != crc)
-		||(mDP.getBufferSize() == 0))
-	{
-		//LL_INFOS() << "Not getting cache entry, invalid!" << LL_ENDL;
-		return NULL;
-	}
-	mHitCount++;
-	return &mDP;
-}
-
 LLDataPackerBinaryBuffer *LLVOCacheEntry::getDP()
 {
 	if (mDP.getBufferSize() == 0)
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 4eca083445..a385610a10 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -97,7 +97,6 @@ public:
 
 	void dump() const;
 	BOOL writeToFile(LLAPRFile* apr_file) const;
-	LLDataPackerBinaryBuffer *getDP(U32 crc);
 	LLDataPackerBinaryBuffer *getDP();
 	void recordHit();
 	void recordDupe() { mDupeCount++; }
-- 
cgit v1.2.3


From 1751650dbcad4ea66b2c3779aa52960ec1640466 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 29 Aug 2013 13:14:56 -0600
Subject: add some debug settings for easier tuning up performance.

---
 indra/newview/app_settings/settings.xml | 33 +++++++++++++++++++++++++++++++++
 indra/newview/llviewerregion.cpp        | 13 ++++++++++---
 indra/newview/llvocache.cpp             | 24 ++++++++++++++++++++----
 indra/newview/llvocache.h               |  5 +++++
 4 files changed, 68 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index b2e3c8b683..93cc605be0 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -721,6 +721,17 @@
       <integer>0</integer>
     </map>
 
+    <key>BackDistanceFactor</key>
+    <map>
+      <key>Comment</key>
+      <string>Keep invisible objects in memory which are in the distance range (the factor * draw_distance) to the camera</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>0.125</real>
+    </map>
     <key>BackgroundYieldTime</key>
     <map>
       <key>Comment</key>
@@ -732,6 +743,17 @@
       <key>Value</key>
       <integer>40</integer>
     </map>
+    <key>BackProjectionAngleSquared</key>
+    <map>
+      <key>Comment</key>
+      <string>squared tan(object bbox projection angle). that of invisible objects greater than this threshold are kept in memory</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>0.0311</real>
+    </map>
     <key>BottomPanelNew</key>
     <map>
       <key>Comment</key>
@@ -6306,6 +6328,17 @@
       <key>Value</key>
       <integer>64</integer>
     </map>
+    <key>NewObjectCreationThrottleDelayTime</key>
+    <map>
+      <key>Comment</key>
+      <string>time in seconds NewObjectCreationThrottle to take effect after the progress screen is lifted</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>2.0</real>
+    </map>
     <key>NextOwnerCopy</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index da01c0406a..9c038d54d5 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1233,6 +1233,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 void LLViewerRegion::calcNewObjectCreationThrottle()
 {
 	static LLCachedControl<S32> new_object_creation_throttle(gSavedSettings,"NewObjectCreationThrottle");
+	static LLCachedControl<F32> throttle_delay_time(gSavedSettings,"NewObjectCreationThrottleDelayTime");
 	static LLFrameTimer timer;
 
 	//
@@ -1243,16 +1244,20 @@ void LLViewerRegion::calcNewObjectCreationThrottle()
 	//>0: valid throttling number
 	//
 
-	if(gViewerWindow->getProgressView()->getVisible())
+	if(gViewerWindow->getProgressView()->getVisible() && throttle_delay_time > 0.f)
 	{
 		sNewObjectCreationThrottle = -2; //cancel the throttling
 		timer.reset();
 	}	
-	else if(sNewObjectCreationThrottle < 0) //just recoved from the login/teleport screen
+	else if(sNewObjectCreationThrottle < -1) //just recoved from the login/teleport screen
 	{
-		if(new_object_creation_throttle > 0 && timer.getElapsedTimeF32() > 2.0f) //wait for two seconds to reset the throttle
+		if(timer.getElapsedTimeF32() > throttle_delay_time) //wait for throttle_delay_time to reset the throttle
 		{
 			sNewObjectCreationThrottle = new_object_creation_throttle; //reset
+			if(sNewObjectCreationThrottle < -1)
+			{
+				sNewObjectCreationThrottle = -1;
+			}
 		}
 	}
 }
@@ -1285,6 +1290,8 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 	S32 update_counter = llmin(max_update, mImpl->mActiveSet.size());
 	LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(mLastVisitedEntry);	
 	
+	LLVOCacheEntry::updateBackCullingFactors();
+
 	for(; update_counter > 0; --update_counter, ++iter)
 	{	
 		if(iter == mImpl->mActiveSet.end())
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index dcd1ae391d..1cfda038a8 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -33,7 +33,10 @@
 #include "lldrawable.h"
 #include "llviewerregion.h"
 #include "pipeline.h"
+#include "llagentcamera.h"
 
+F32 LLVOCacheEntry::sBackDistanceSquared = 0.f;
+F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f;
 BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE;
 LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
 
@@ -353,6 +356,21 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 	return success ;
 }
 
+//static 
+void LLVOCacheEntry::updateBackCullingFactors()
+{
+	//distance to keep objects = back_dist_factor * draw_distance
+	static LLCachedControl<F32> back_dist_factor(gSavedSettings,"BackDistanceFactor");
+
+	//squared tan(projection angle of the bbox), default is 10 (degree)
+	static LLCachedControl<F32> squared_back_angle(gSavedSettings,"BackProjectionAngleSquared");
+
+	sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance;
+	sBackDistanceSquared *= sBackDistanceSquared;
+
+	sBackAngleTanSquared = squared_back_angle;
+}
+
 bool LLVOCacheEntry::isRecentlyVisible() const
 {
 	bool vis = LLViewerOctreeEntryData::isRecentlyVisible();
@@ -363,12 +381,10 @@ bool LLVOCacheEntry::isRecentlyVisible() const
 	}
 
 	//combination of projected area and squared distance
-	if(!vis && !mParentID && mSceneContrib > 0.0311f) //projection angle > 10 (degree)
+	if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) 
 	{
-		//squared distance
-		const F32 SQUARED_CUT_OFF_DIST = 256.0; //16m
 		F32 rad = getBinRadius();
-		vis = (rad * rad / mSceneContrib < SQUARED_CUT_OFF_DIST);
+		vis = (rad * rad / mSceneContrib < sBackDistanceSquared);
 	}
 
 	return vis;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index a385610a10..52b25b7f91 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -123,6 +123,8 @@ public:
 	void setUpdateFlags(U32 flags) {mUpdateFlags = flags;}
 	U32  getUpdateFlags() const    {return mUpdateFlags;}
 
+	static void updateBackCullingFactors();
+
 private:
 	static U32  getInvisibleObjectsLiveTime();
 
@@ -151,6 +153,9 @@ protected:
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 
 	BOOL                        mTouched; //if set, this entry is valid, otherwise it is invalid.
+
+	static F32                  sBackDistanceSquared;
+	static F32                  sBackAngleTanSquared;
 };
 
 class LLVOCachePartition : public LLViewerOctreePartition, public LLTrace::MemTrackable<LLVOCachePartition>
-- 
cgit v1.2.3


From e2212f86338728622651619f52e894f265aa320a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 29 Aug 2013 15:20:20 -0700
Subject: SH-4377 FIX: Interesting: Windows viewer crashes when
 SceneLoadingMonitorEnabled is enabled

---
 indra/newview/llscenemonitor.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

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.2.3


From f0a642898dad11f6519bad735857a58e1d83422e Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 29 Aug 2013 15:25:48 -0700
Subject: SH-4377 FIX: Interesting: Windows viewer crashes when
 SceneLoadingMonitorEnabled is enabled

---
 indra/newview/llscenemonitor.cpp | 1 +
 1 file changed, 1 insertion(+)

(limited to 'indra/newview')

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.2.3


From 4e2e3f3f959f4671b16d049a578911a06834fa84 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 29 Aug 2013 22:50:45 -0700
Subject: SH-4292 FIX: Interesting: My avatar declouds slower in Interesting
 viewer than in Release viewer moved occlusion culling earlier in login
 process

---
 indra/newview/llviewerdisplay.cpp | 2 +-
 indra/newview/pipeline.cpp        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index d2a702049a..92bb5a8beb 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -350,7 +350,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	// Bail out if we're in the startup state and don't want to try to
 	// render the world.
 	//
-	if (LLStartUp::getStartupState() < STATE_WEARABLES_WAIT)
+	if (LLStartUp::getStartupState() < STATE_PRECACHE)
 	{
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Startup");
 		display_startup();
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e77d85849d..af44acc64c 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2539,7 +2539,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 		LLVOCachePartition* vo_part = region->getVOCachePartition();
 		if(vo_part)
 		{
-			bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe && !gViewerWindow->getProgressView()->getVisible();
+			bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe/* && !gViewerWindow->getProgressView()->getVisible()*/;
 			vo_part->cull(camera, do_occlusion_cull);
 		}
 	}
-- 
cgit v1.2.3


From f713fe492f8b86a0743e0a553d62f06ff62500bb Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 30 Aug 2013 11:02:15 -0600
Subject: fix for SH-4295: Interesting: Teleporting to previous location leave
 some objects invisible.

---
 indra/newview/llagent.cpp            |  1 +
 indra/newview/llspatialpartition.cpp | 12 +++++++++---
 indra/newview/llspatialpartition.h   |  2 ++
 indra/newview/pipeline.cpp           |  1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 2d7008b4ef..a7bd628d5a 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -3802,6 +3802,7 @@ bool LLAgent::teleportCore(bool is_local)
 
 		//release geometry from old location
 		gPipeline.resetVertexBuffers();
+		LLSpatialPartition::sTeleportRequested = TRUE;
 	}
 	make_ui_sound("UISndTeleportOut");
 	
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 725afb9014..c7cd0919ec 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -68,6 +68,7 @@ BOOL LLSpatialGroup::sNoDelete = FALSE;
 static F32 sLastMaxTexPriority = 1.f;
 static F32 sCurMaxTexPriority = 1.f;
 
+BOOL LLSpatialPartition::sTeleportRequested = FALSE;
 
 //static counter for frame to switch LOD on
 
@@ -900,7 +901,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 {
 	setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY);
 
-	if (!keep_occlusion)
+	if (!keep_occlusion && !LLSpatialPartition::sTeleportRequested)
 	{ //going to need a rebuild
 		gPipeline.markRebuild(this, TRUE);
 	}
@@ -1392,6 +1393,8 @@ void drawBoxOutline(const LLVector4a& pos, const LLVector4a& size)
 class LLOctreeDirty : public OctreeTraveler
 {
 public:
+	LLOctreeDirty(bool no_rebuild) : mNoRebuild(no_rebuild){}
+
 	virtual void visit(const OctreeNode* state)
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0);
@@ -1404,7 +1407,7 @@ public:
 			{
 				continue;
 			}
-			if (drawable->getVObj().notNull() && !group->getSpatialPartition()->mRenderByGroup)
+			if (!mNoRebuild && drawable->getVObj().notNull() && !group->getSpatialPartition()->mRenderByGroup)
 			{
 				gPipeline.markRebuild(drawable, LLDrawable::REBUILD_ALL, TRUE);
 			}
@@ -1416,6 +1419,9 @@ public:
 			traverse(bridge->mOctree);
 		}
 	}
+
+private:
+	BOOL mNoRebuild;
 };
 
 void LLSpatialPartition::restoreGL()
@@ -1424,7 +1430,7 @@ void LLSpatialPartition::restoreGL()
 
 void LLSpatialPartition::resetVertexBuffers()
 {
-	LLOctreeDirty dirty;
+	LLOctreeDirty dirty(sTeleportRequested);
 	dirty.traverse(mOctree);
 }
 
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 5c4cdcdba1..4026175a9a 100755
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -450,6 +450,8 @@ public:
 	U32 mVertexDataMask;
 	F32 mSlopRatio; //percentage distance must change before drawables receive LOD update (default is 0.25);
 	BOOL mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering
+
+	static BOOL sTeleportRequested; //started to issue a teleport request
 };
 
 // class for creating bridges between spatial partitions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e77d85849d..e71355466a 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7314,6 +7314,7 @@ void LLPipeline::doResetVertexBuffers()
 			}
 		}
 	}
+	LLSpatialPartition::sTeleportRequested = FALSE;
 
 	resetDrawOrders();
 
-- 
cgit v1.2.3


From cbe397ad13665c7bc993e10d8fe1e4a876253378 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 5 Sep 2013 14:04:13 -0700
Subject: changed fast timer over to using macro another attempt to move mem
 stat into base class

---
 indra/newview/llagentcamera.cpp                    |   4 +-
 indra/newview/llappviewer.cpp                      | 140 +++++------
 indra/newview/llappviewer.h                        |   2 +-
 indra/newview/llchathistory.cpp                    |   4 +-
 .../newview/lldonotdisturbnotificationstorage.cpp  |   8 +-
 indra/newview/lldrawable.cpp                       |  24 +-
 indra/newview/lldrawable.h                         |   4 +-
 indra/newview/lldrawpoolalpha.cpp                  |   8 +-
 indra/newview/lldrawpoolavatar.cpp                 |  26 +-
 indra/newview/lldrawpoolbump.cpp                   |  74 +++---
 indra/newview/lldrawpoolmaterials.cpp              |   4 +-
 indra/newview/lldrawpoolsimple.cpp                 |  60 ++---
 indra/newview/lldrawpoolterrain.cpp                |  20 +-
 indra/newview/lldrawpooltree.cpp                   |  16 +-
 indra/newview/lldrawpoolwater.cpp                  |   4 +-
 indra/newview/lldrawpoolwlsky.cpp                  |   4 +-
 indra/newview/llface.cpp                           |  86 +++----
 indra/newview/llfasttimerview.cpp                  |  14 +-
 indra/newview/llflexibleobject.cpp                 |  14 +-
 indra/newview/llfolderviewmodelinventory.cpp       |   4 +-
 indra/newview/llhudmanager.cpp                     |   4 +-
 indra/newview/llhudobject.cpp                      |   4 +-
 indra/newview/llinventoryfilter.cpp                |   4 +-
 indra/newview/llinventoryitemslist.cpp             |   4 +-
 indra/newview/llinventorypanel.cpp                 |   8 +-
 indra/newview/llmaterialmgr.cpp                    |   4 +-
 indra/newview/llpersistentnotificationstorage.cpp  |   8 +-
 indra/newview/llscenemonitor.cpp                   |  14 +-
 indra/newview/llscreenchannel.cpp                  |   4 +-
 indra/newview/llspatialpartition.cpp               |  32 +--
 indra/newview/llviewerdisplay.cpp                  |  68 ++---
 indra/newview/llviewerjointmesh.cpp                |   4 +-
 indra/newview/llviewermedia.cpp                    |  40 +--
 indra/newview/llviewermessage.cpp                  |   8 +-
 indra/newview/llviewerobject.cpp                   |  10 +-
 indra/newview/llviewerobject.h                     |   2 +-
 indra/newview/llviewerobjectlist.cpp               |  24 +-
 indra/newview/llvieweroctree.cpp                   |  46 ++--
 indra/newview/llvieweroctree.h                     |  18 +-
 indra/newview/llviewerpartsim.cpp                  |   4 +-
 indra/newview/llviewertexture.cpp                  |  12 +-
 indra/newview/llviewertexturelist.cpp              |  40 +--
 indra/newview/llviewerwindow.cpp                   |  12 +-
 indra/newview/llvoavatar.cpp                       |  16 +-
 indra/newview/llvocache.cpp                        |   2 +-
 indra/newview/llvocache.h                          |   6 +-
 indra/newview/llvograss.cpp                        |   8 +-
 indra/newview/llvoicevivox.cpp                     |   4 +-
 indra/newview/llvopartgroup.cpp                    |  12 +-
 indra/newview/llvosky.cpp                          |   8 +-
 indra/newview/llvosurfacepatch.cpp                 |   8 +-
 indra/newview/llvotree.cpp                         |   4 +-
 indra/newview/llvovolume.cpp                       |  74 +++---
 indra/newview/llvowater.cpp                        |   4 +-
 indra/newview/llvowlsky.cpp                        |   4 +-
 indra/newview/llwaterparammanager.cpp              |   4 +-
 indra/newview/llwlparammanager.cpp                 |   6 +-
 indra/newview/llwlparamset.cpp                     |   4 +-
 indra/newview/llworld.cpp                          |   4 +-
 indra/newview/pipeline.cpp                         | 276 ++++++++++-----------
 indra/newview/pipeline.h                           |  40 +--
 61 files changed, 690 insertions(+), 688 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 93e0cddd64..5fec0d927f 100755
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1126,14 +1126,14 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_CAMERA("Camera");
+static LLTrace::TimeBlock FTM_UPDATE_CAMERA("Camera");
 
 //-----------------------------------------------------------------------------
 // updateCamera()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::updateCamera()
 {
-	LLFastTimer t(FTM_UPDATE_CAMERA);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA);
 
 	// - changed camera_skyward to the new global "mCameraUpVector"
 	mCameraUpVector = LLVector3::z_axis;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 7f37cee8b8..4f776aa15a 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1237,24 +1237,24 @@ void LLAppViewer::checkMemory()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_MESSAGES("System Messages");
-static LLFastTimer::DeclareTimer FTM_SLEEP("Sleep");
-static LLFastTimer::DeclareTimer FTM_YIELD("Yield");
-
-static LLFastTimer::DeclareTimer FTM_TEXTURE_CACHE("Texture Cache");
-static LLFastTimer::DeclareTimer FTM_DECODE("Image Decode");
-static LLFastTimer::DeclareTimer FTM_VFS("VFS Thread");
-static LLFastTimer::DeclareTimer FTM_LFS("LFS Thread");
-static LLFastTimer::DeclareTimer FTM_PAUSE_THREADS("Pause Threads");
-static LLFastTimer::DeclareTimer FTM_IDLE("Idle");
-static LLFastTimer::DeclareTimer FTM_PUMP("Pump");
-static LLFastTimer::DeclareTimer FTM_PUMP_ARES("Ares");
-static LLFastTimer::DeclareTimer FTM_PUMP_SERVICE("Service");
-static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback");
-static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot");
-static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update");
-
-LLFastTimer::DeclareTimer FTM_FRAME("Frame");
+static LLTrace::TimeBlock FTM_MESSAGES("System Messages");
+static LLTrace::TimeBlock FTM_SLEEP("Sleep");
+static LLTrace::TimeBlock FTM_YIELD("Yield");
+
+static LLTrace::TimeBlock FTM_TEXTURE_CACHE("Texture Cache");
+static LLTrace::TimeBlock FTM_DECODE("Image Decode");
+static LLTrace::TimeBlock FTM_VFS("VFS Thread");
+static LLTrace::TimeBlock FTM_LFS("LFS Thread");
+static LLTrace::TimeBlock FTM_PAUSE_THREADS("Pause Threads");
+static LLTrace::TimeBlock FTM_IDLE("Idle");
+static LLTrace::TimeBlock FTM_PUMP("Pump");
+static LLTrace::TimeBlock FTM_PUMP_ARES("Ares");
+static LLTrace::TimeBlock FTM_PUMP_SERVICE("Service");
+static LLTrace::TimeBlock FTM_SERVICE_CALLBACK("Callback");
+static LLTrace::TimeBlock FTM_AGENT_AUTOPILOT("Autopilot");
+static LLTrace::TimeBlock FTM_AGENT_UPDATE("Update");
+
+LLTrace::TimeBlock FTM_FRAME("Frame");
 
 bool LLAppViewer::mainLoop()
 {
@@ -1295,7 +1295,7 @@ bool LLAppViewer::mainLoop()
 	// Handle messages
 	while (!LLApp::isExiting())
 	{
-		LLFastTimer _(FTM_FRAME);
+		LL_RECORD_BLOCK_TIME(FTM_FRAME);
 		LLTrace::TimeBlock::processTimes();
 		LLTrace::get_frame_recording().nextPeriod();
 		LLTrace::TimeBlock::logStats();
@@ -1314,7 +1314,7 @@ bool LLAppViewer::mainLoop()
 
 			if (gViewerWindow)
 			{
-				LLFastTimer t2(FTM_MESSAGES);
+				LL_RECORD_BLOCK_TIME(FTM_MESSAGES);
 				gViewerWindow->getWindow()->processMiscNativeEvents();
 			}
 		
@@ -1322,7 +1322,7 @@ bool LLAppViewer::mainLoop()
 			
 			if (gViewerWindow)
 			{
-				LLFastTimer t2(FTM_MESSAGES);
+				LL_RECORD_BLOCK_TIME(FTM_MESSAGES);
 				if (!restoreErrorTrap())
 				{
 					LL_WARNS() << " Someone took over my signal/exception handler (post messagehandling)!" << LL_ENDL;
@@ -1372,24 +1372,24 @@ bool LLAppViewer::mainLoop()
 				{
 					pauseMainloopTimeout(); // *TODO: Remove. Messages shouldn't be stalling for 20+ seconds!
 					
-					LLFastTimer t3(FTM_IDLE);
+					LL_RECORD_BLOCK_TIME(FTM_IDLE);
 					idle();
 
 					if (gAres != NULL && gAres->isInitialized())
 					{
 						pingMainloopTimeout("Main:ServicePump");				
-						LLFastTimer t4(FTM_PUMP);
+						LL_RECORD_BLOCK_TIME(FTM_PUMP);
 						{
-							LLFastTimer t(FTM_PUMP_ARES);
+							LL_RECORD_BLOCK_TIME(FTM_PUMP_ARES);
 							gAres->process();
 						}
 						{
-							LLFastTimer t(FTM_PUMP_SERVICE);
+							LL_RECORD_BLOCK_TIME(FTM_PUMP_SERVICE);
 							// this pump is necessary to make the login screen show up
 							gServicePump->pump();
 
 							{
-								LLFastTimer t(FTM_SERVICE_CALLBACK);
+								LL_RECORD_BLOCK_TIME(FTM_SERVICE_CALLBACK);
 								gServicePump->callback();
 							}
 						}
@@ -1425,12 +1425,12 @@ bool LLAppViewer::mainLoop()
 
 			// Sleep and run background threads
 			{
-				LLFastTimer t2(FTM_SLEEP);
+				LL_RECORD_BLOCK_TIME(FTM_SLEEP);
 				
 				// yield some time to the os based on command line option
 				if(mYieldTime >= 0)
 				{
-					LLFastTimer t(FTM_YIELD);
+					LL_RECORD_BLOCK_TIME(FTM_YIELD);
 					ms_sleep(mYieldTime);
 				}
 
@@ -1476,11 +1476,11 @@ bool LLAppViewer::mainLoop()
 					work_pending += updateTextureThreads(max_time);
 
 					{
-						LLFastTimer ftm(FTM_VFS);
+						LL_RECORD_BLOCK_TIME(FTM_VFS);
 	 					io_pending += LLVFSThread::updateClass(1);
 					}
 					{
-						LLFastTimer ftm(FTM_LFS);
+						LL_RECORD_BLOCK_TIME(FTM_LFS);
 	 					io_pending += LLLFSThread::updateClass(1);
 					}
 
@@ -1595,15 +1595,15 @@ S32 LLAppViewer::updateTextureThreads(F32 max_time)
 {
 	S32 work_pending = 0;
 	{
-		LLFastTimer ftm(FTM_TEXTURE_CACHE);
+		LL_RECORD_BLOCK_TIME(FTM_TEXTURE_CACHE);
  		work_pending += LLAppViewer::getTextureCache()->update(max_time); // unpauses the texture cache thread
 	}
 	{
-		LLFastTimer ftm(FTM_DECODE);
+		LL_RECORD_BLOCK_TIME(FTM_DECODE);
 	 	work_pending += LLAppViewer::getImageDecodeThread()->update(max_time); // unpauses the image thread
 	}
 	{
-		LLFastTimer ftm(FTM_DECODE);
+		LL_RECORD_BLOCK_TIME(FTM_DECODE);
 	 	work_pending += LLAppViewer::getTextureFetch()->update(max_time); // unpauses the texture fetch thread
 	}
 	return work_pending;
@@ -4467,20 +4467,20 @@ public:
 		}
 };
 
-static LLFastTimer::DeclareTimer FTM_AUDIO_UPDATE("Update Audio");
-static LLFastTimer::DeclareTimer FTM_CLEANUP("Cleanup");
-static LLFastTimer::DeclareTimer FTM_CLEANUP_DRAWABLES("Drawables");
-static LLFastTimer::DeclareTimer FTM_CLEANUP_OBJECTS("Objects");
-static LLFastTimer::DeclareTimer FTM_IDLE_CB("Idle Callbacks");
-static LLFastTimer::DeclareTimer FTM_LOD_UPDATE("Update LOD");
-static LLFastTimer::DeclareTimer FTM_OBJECTLIST_UPDATE("Update Objectlist");
-static LLFastTimer::DeclareTimer FTM_REGION_UPDATE("Update Region");
-static LLFastTimer::DeclareTimer FTM_WORLD_UPDATE("Update World");
-static LLFastTimer::DeclareTimer FTM_NETWORK("Network");
-static LLFastTimer::DeclareTimer FTM_AGENT_NETWORK("Agent Network");
-static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager");
-static LLFastTimer::DeclareTimer FTM_AGENT_POSITION("Agent Position");
-static LLFastTimer::DeclareTimer FTM_HUD_EFFECTS("HUD Effects");
+static LLTrace::TimeBlock FTM_AUDIO_UPDATE("Update Audio");
+static LLTrace::TimeBlock FTM_CLEANUP("Cleanup");
+static LLTrace::TimeBlock FTM_CLEANUP_DRAWABLES("Drawables");
+static LLTrace::TimeBlock FTM_CLEANUP_OBJECTS("Objects");
+static LLTrace::TimeBlock FTM_IDLE_CB("Idle Callbacks");
+static LLTrace::TimeBlock FTM_LOD_UPDATE("Update LOD");
+static LLTrace::TimeBlock FTM_OBJECTLIST_UPDATE("Update Objectlist");
+static LLTrace::TimeBlock FTM_REGION_UPDATE("Update Region");
+static LLTrace::TimeBlock FTM_WORLD_UPDATE("Update World");
+static LLTrace::TimeBlock FTM_NETWORK("Network");
+static LLTrace::TimeBlock FTM_AGENT_NETWORK("Agent Network");
+static LLTrace::TimeBlock FTM_VLMANAGER("VL Manager");
+static LLTrace::TimeBlock FTM_AGENT_POSITION("Agent Position");
+static LLTrace::TimeBlock FTM_HUD_EFFECTS("HUD Effects");
 
 ///////////////////////////////////////////////////////
 // idle()
@@ -4554,7 +4554,7 @@ void LLAppViewer::idle()
 
 	if (!gDisconnected)
 	{
-		LLFastTimer t(FTM_NETWORK);
+		LL_RECORD_BLOCK_TIME(FTM_NETWORK);
 		// Update spaceserver timeinfo
 	    LLWorld::getInstance()->setSpaceTimeUSec(LLWorld::getInstance()->getSpaceTimeUSec() + LLUnits::Seconds::fromValue(dt_raw));
     
@@ -4570,7 +4570,7 @@ void LLAppViewer::idle()
 		}
 
 		{
-			LLFastTimer t(FTM_AGENT_AUTOPILOT);
+			LL_RECORD_BLOCK_TIME(FTM_AGENT_AUTOPILOT);
 			// Handle automatic walking towards points
 			gAgentPilot.updateTarget();
 			gAgent.autoPilot(&yaw);
@@ -4585,7 +4585,7 @@ void LLAppViewer::idle()
 		    
 	    if (flags_changed || (agent_update_time > (1.0f / (F32) AGENT_UPDATES_PER_SECOND)))
 	    {
-		    LLFastTimer t(FTM_AGENT_UPDATE);
+		    LL_RECORD_BLOCK_TIME(FTM_AGENT_UPDATE);
 		    // Send avatar and camera info
 		    last_control_flags = gAgent.getControlFlags();
 		    send_agent_update(TRUE);
@@ -4634,7 +4634,7 @@ void LLAppViewer::idle()
 
 	if (!gDisconnected)
 	{
-		LLFastTimer t(FTM_NETWORK);
+		LL_RECORD_BLOCK_TIME(FTM_NETWORK);
 	
 	    ////////////////////////////////////////////////
 	    //
@@ -4662,7 +4662,7 @@ void LLAppViewer::idle()
 	//
 
 	{
-// 		LLFastTimer t(FTM_IDLE_CB);
+// 		LL_RECORD_BLOCK_TIME(FTM_IDLE_CB);
 
 		// Do event notifications if necessary.  Yes, we may want to move this elsewhere.
 		gEventNotifier.update();
@@ -4709,14 +4709,14 @@ void LLAppViewer::idle()
 
 	{
 		// Handle pending gesture processing
-		LLFastTimer t(FTM_AGENT_POSITION);
+		LL_RECORD_BLOCK_TIME(FTM_AGENT_POSITION);
 		LLGestureMgr::instance().update();
 
 		gAgent.updateAgentPosition(gFrameDTClamped, yaw, current_mouse.mX, current_mouse.mY);
 	}
 
 	{
-		LLFastTimer t(FTM_OBJECTLIST_UPDATE); 
+		LL_RECORD_BLOCK_TIME(FTM_OBJECTLIST_UPDATE); 
 		
         if (!(logoutRequestSent() && hasSavedFinalSnapshot()))
 		{
@@ -4731,13 +4731,13 @@ void LLAppViewer::idle()
 	//
 
 	{
-		LLFastTimer t(FTM_CLEANUP);
+		LL_RECORD_BLOCK_TIME(FTM_CLEANUP);
 		{
-			LLFastTimer t(FTM_CLEANUP_OBJECTS);
+			LL_RECORD_BLOCK_TIME(FTM_CLEANUP_OBJECTS);
 			gObjectList.cleanDeadObjects();
 		}
 		{
-			LLFastTimer t(FTM_CLEANUP_DRAWABLES);
+			LL_RECORD_BLOCK_TIME(FTM_CLEANUP_DRAWABLES);
 			LLDrawable::cleanupDeadDrawables();
 		}
 	}
@@ -4756,7 +4756,7 @@ void LLAppViewer::idle()
 	//
 
 	{
-		LLFastTimer t(FTM_HUD_EFFECTS);
+		LL_RECORD_BLOCK_TIME(FTM_HUD_EFFECTS);
 		LLSelectMgr::getInstance()->updateEffects();
 		LLHUDManager::getInstance()->cleanupEffects();
 		LLHUDManager::getInstance()->sendEffects();
@@ -4768,7 +4768,7 @@ void LLAppViewer::idle()
 	//
 
 	{
-		LLFastTimer t(FTM_NETWORK);
+		LL_RECORD_BLOCK_TIME(FTM_NETWORK);
 		gVLManager.unpackData();
 	}
 	
@@ -4780,7 +4780,7 @@ void LLAppViewer::idle()
 	LLWorld::getInstance()->updateVisibilities();
 	{
 		const F32 max_region_update_time = .001f; // 1ms
-		LLFastTimer t(FTM_REGION_UPDATE);
+		LL_RECORD_BLOCK_TIME(FTM_REGION_UPDATE);
 		LLWorld::getInstance()->updateRegions(max_region_update_time);
 	}
 	
@@ -4817,7 +4817,7 @@ void LLAppViewer::idle()
 	// Here, particles are updated and drawables are moved.
 	//
 	
-	LLFastTimer t(FTM_WORLD_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_WORLD_UPDATE);
 	gPipeline.updateMove();
 
 	LLWorld::getInstance()->updateParticles();
@@ -4849,12 +4849,12 @@ void LLAppViewer::idle()
 
 	// objects and camera should be in sync, do LOD calculations now
 	{
-		LLFastTimer t(FTM_LOD_UPDATE);
+		LL_RECORD_BLOCK_TIME(FTM_LOD_UPDATE);
 		gObjectList.updateApparentAngles(gAgent);
 	}
 
 	{
-		LLFastTimer t(FTM_AUDIO_UPDATE);
+		LL_RECORD_BLOCK_TIME(FTM_AUDIO_UPDATE);
 		
 		if (gAudiop)
 		{
@@ -5073,12 +5073,12 @@ void LLAppViewer::idleNameCache()
 static F32 CheckMessagesMaxTime = CHECK_MESSAGES_DEFAULT_MAX_TIME;
 #endif
 
-static LLFastTimer::DeclareTimer FTM_IDLE_NETWORK("Idle Network");
-static LLFastTimer::DeclareTimer FTM_MESSAGE_ACKS("Message Acks");
-static LLFastTimer::DeclareTimer FTM_RETRANSMIT("Retransmit");
-static LLFastTimer::DeclareTimer FTM_TIMEOUT_CHECK("Timeout Check");
-static LLFastTimer::DeclareTimer FTM_DYNAMIC_THROTTLE("Dynamic Throttle");
-static LLFastTimer::DeclareTimer FTM_CHECK_REGION_CIRCUIT("Check Region Circuit");
+static LLTrace::TimeBlock FTM_IDLE_NETWORK("Idle Network");
+static LLTrace::TimeBlock FTM_MESSAGE_ACKS("Message Acks");
+static LLTrace::TimeBlock FTM_RETRANSMIT("Retransmit");
+static LLTrace::TimeBlock FTM_TIMEOUT_CHECK("Timeout Check");
+static LLTrace::TimeBlock FTM_DYNAMIC_THROTTLE("Dynamic Throttle");
+static LLTrace::TimeBlock FTM_CHECK_REGION_CIRCUIT("Check Region Circuit");
 
 void LLAppViewer::idleNetwork()
 {
@@ -5089,7 +5089,7 @@ void LLAppViewer::idleNetwork()
 
 	if (!gSavedSettings.getBOOL("SpeedTest"))
 	{
-		LLFastTimer t(FTM_IDLE_NETWORK); // decode
+		LL_RECORD_BLOCK_TIME(FTM_IDLE_NETWORK); // decode
 		
 		LLTimer check_message_timer;
 		//  Read all available packets from network 
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index d642d55b14..a258e24536 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -43,7 +43,7 @@ class LLTextureFetch;
 class LLWatchdogTimeout;
 class LLUpdaterService;
 
-extern LLFastTimer::DeclareTimer FTM_FRAME;
+extern LLTrace::TimeBlock FTM_FRAME;
 
 
 class LLAppViewer : public LLApp
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index 0f138873ac..5c3dd4ebe0 100755
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -733,11 +733,11 @@ void LLChatHistory::clear()
 	mLastFromID = LLUUID::null;
 }
 
-static LLFastTimer::DeclareTimer FTM_APPEND_MESSAGE("Append Chat Message");
+static LLTrace::TimeBlock FTM_APPEND_MESSAGE("Append Chat Message");
 
 void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LLStyle::Params& input_append_params)
 {
-	LLFastTimer _(FTM_APPEND_MESSAGE);
+	LL_RECORD_BLOCK_TIME(FTM_APPEND_MESSAGE);
 	bool use_plain_text_chat_history = args["use_plain_text_chat_history"].asBoolean();
 	bool square_brackets = false; // square brackets necessary for a system messages
 
diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp
index 82affcf068..5bdf9c612a 100755
--- a/indra/newview/lldonotdisturbnotificationstorage.cpp
+++ b/indra/newview/lldonotdisturbnotificationstorage.cpp
@@ -96,11 +96,11 @@ void LLDoNotDisturbNotificationStorage::resetDirty()
     mDirty = false;
 }
 
-static LLFastTimer::DeclareTimer FTM_SAVE_DND_NOTIFICATIONS("Save DND Notifications");
+static LLTrace::TimeBlock FTM_SAVE_DND_NOTIFICATIONS("Save DND Notifications");
 
 void LLDoNotDisturbNotificationStorage::saveNotifications()
 {
-	LLFastTimer _(FTM_SAVE_DND_NOTIFICATIONS);
+	LL_RECORD_BLOCK_TIME(FTM_SAVE_DND_NOTIFICATIONS);
 
 	LLNotificationChannelPtr channelPtr = getCommunicationChannel();
 	const LLCommunicationChannel *commChannel = dynamic_cast<LLCommunicationChannel*>(channelPtr.get());
@@ -126,11 +126,11 @@ void LLDoNotDisturbNotificationStorage::saveNotifications()
     resetDirty();
 }
 
-static LLFastTimer::DeclareTimer FTM_LOAD_DND_NOTIFICATIONS("Load DND Notifications");
+static LLTrace::TimeBlock FTM_LOAD_DND_NOTIFICATIONS("Load DND Notifications");
 
 void LLDoNotDisturbNotificationStorage::loadNotifications()
 {
-	LLFastTimer _(FTM_LOAD_DND_NOTIFICATIONS);
+	LL_RECORD_BLOCK_TIME(FTM_LOAD_DND_NOTIFICATIONS);
 	
 	LL_INFOS("LLDoNotDisturbNotificationStorage") << "start loading notifications" << LL_ENDL;
 
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index a480eed2e7..1837974604 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -56,10 +56,10 @@ const F32 MAX_INTERPOLATE_DISTANCE_SQUARED = 10.f * 10.f;
 const F32 OBJECT_DAMPING_TIME_CONSTANT = 0.06f;
 const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 
-static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
+static LLTrace::TimeBlock FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
-LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
+//LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 
 
 ////////////////////////
@@ -230,16 +230,16 @@ BOOL LLDrawable::isLight() const
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_CLEANUP_DRAWABLE("Cleanup Drawable");
-static LLFastTimer::DeclareTimer FTM_DEREF_DRAWABLE("Deref");
-static LLFastTimer::DeclareTimer FTM_DELETE_FACES("Faces");
+static LLTrace::TimeBlock FTM_CLEANUP_DRAWABLE("Cleanup Drawable");
+static LLTrace::TimeBlock FTM_DEREF_DRAWABLE("Deref");
+static LLTrace::TimeBlock FTM_DELETE_FACES("Faces");
 
 void LLDrawable::cleanupReferences()
 {
-	LLFastTimer t(FTM_CLEANUP_DRAWABLE);
+	LL_RECORD_BLOCK_TIME(FTM_CLEANUP_DRAWABLE);
 	
 	{
-		LLFastTimer t(FTM_DELETE_FACES);
+		LL_RECORD_BLOCK_TIME(FTM_DELETE_FACES);
 		std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
 		mFaces.clear();
 	}
@@ -251,7 +251,7 @@ void LLDrawable::cleanupReferences()
 	removeFromOctree();
 
 	{
-		LLFastTimer t(FTM_DEREF_DRAWABLE);
+		LL_RECORD_BLOCK_TIME(FTM_DEREF_DRAWABLE);
 		// Cleanup references to other objects
 		mVObjp = NULL;
 		mParent = NULL;
@@ -300,14 +300,14 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep)
 	return count;
 }
 
-static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face");
+static LLTrace::TimeBlock FTM_ALLOCATE_FACE("Allocate Face");
 
 LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)
 {
 	
 	LLFace *face;
 	{
-		LLFastTimer t(FTM_ALLOCATE_FACE);
+		LL_RECORD_BLOCK_TIME(FTM_ALLOCATE_FACE);
 		face = new LLFace(this, mVObjp);
 	}
 
@@ -335,7 +335,7 @@ LLFace*	LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep)
 	LLFace *face;
 
 	{
-		LLFastTimer t(FTM_ALLOCATE_FACE);
+		LL_RECORD_BLOCK_TIME(FTM_ALLOCATE_FACE);
 		face = new LLFace(this, mVObjp);
 	}
 
@@ -1192,7 +1192,7 @@ void LLSpatialBridge::updateSpatialExtents()
 	LLSpatialGroup* root = (LLSpatialGroup*) mOctree->getListener(0);
 	
 	{
-		LLFastTimer ftm(FTM_CULL_REBOUND);
+		LL_RECORD_BLOCK_TIME(FTM_CULL_REBOUND);
 		root->rebound();
 	}
 	
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index b94f663f21..3dab496a20 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -61,7 +61,7 @@ const U32 SILHOUETTE_HIGHLIGHT = 0;
 LL_ALIGN_PREFIX(16)
 class LLDrawable 
 :	public LLViewerOctreeEntryData,
-	public LLTrace::MemTrackable<LLDrawable>
+	public LLTrace::MemTrackable<LLDrawable, 16>
 {
 public:
 	LLDrawable(const LLDrawable& rhs) : LLViewerOctreeEntryData(rhs)
@@ -291,7 +291,7 @@ public:
 	F32				mDistanceWRTCamera;
 
 	static F32 sCurPixelAngle; //current pixels per radian
-	static LLTrace::MemStatHandle sMemStat;
+	//static LLTrace::MemStatHandle sMemStat;
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 604a9b1530..ef329ea8ff 100755
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -89,7 +89,7 @@ S32 LLDrawPoolAlpha::getNumPostDeferredPasses()
 
 void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) 
 { 
-	LLFastTimer t(FTM_RENDER_ALPHA);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA);
 
 	if (pass == 0)
 	{
@@ -142,7 +142,7 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass)
 
 void LLDrawPoolAlpha::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA);
 	
 	if (LLPipeline::sUnderWaterRender)
 	{
@@ -168,7 +168,7 @@ void LLDrawPoolAlpha::beginRenderPass(S32 pass)
 
 void LLDrawPoolAlpha::endRenderPass( S32 pass )
 {
-	LLFastTimer t(FTM_RENDER_ALPHA);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA);
 	LLRenderPass::endRenderPass(pass);
 
 	if(gPipeline.canUseWindLightShaders()) 
@@ -179,7 +179,7 @@ void LLDrawPoolAlpha::endRenderPass( S32 pass )
 
 void LLDrawPoolAlpha::render(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA);
 
 	LLGLSPipelineAlpha gls_pipeline_alpha;
 
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index e366de9b13..168f82e013 100755
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -100,7 +100,7 @@ S32 normal_channel = -1;
 S32 specular_channel = -1;
 S32 cube_channel = -1;
 
-static LLFastTimer::DeclareTimer FTM_SHADOW_AVATAR("Avatar Shadow");
+static LLTrace::TimeBlock FTM_SHADOW_AVATAR("Avatar Shadow");
 
 LLDrawPoolAvatar::LLDrawPoolAvatar() : 
 	LLFacePool(POOL_AVATAR)	
@@ -167,7 +167,7 @@ LLMatrix4& LLDrawPoolAvatar::getModelView()
 
 void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_CHARACTERS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_CHARACTERS);
 	
 	sSkipTransparent = TRUE;
 	is_deferred_render = true;
@@ -202,7 +202,7 @@ void LLDrawPoolAvatar::beginDeferredPass(S32 pass)
 
 void LLDrawPoolAvatar::endDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_CHARACTERS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_CHARACTERS);
 
 	sSkipTransparent = FALSE;
 	is_deferred_render = false;
@@ -401,7 +401,7 @@ S32 LLDrawPoolAvatar::getNumShadowPasses()
 
 void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_AVATAR);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_AVATAR);
 
 	if (pass == 0)
 	{
@@ -427,7 +427,7 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
 
 void LLDrawPoolAvatar::endShadowPass(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_AVATAR);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_AVATAR);
 	if (pass == 0)
 	{
 		if (sShaderLevel > 0)
@@ -446,7 +446,7 @@ void LLDrawPoolAvatar::endShadowPass(S32 pass)
 
 void LLDrawPoolAvatar::renderShadow(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_AVATAR);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_AVATAR);
 
 	if (mDrawFace.empty())
 	{
@@ -512,7 +512,7 @@ S32 LLDrawPoolAvatar::getNumDeferredPasses()
 
 void LLDrawPoolAvatar::render(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_CHARACTERS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_CHARACTERS);
 	if (LLPipeline::sImpostorRender)
 	{
 		renderAvatars(NULL, pass+2);
@@ -524,7 +524,7 @@ void LLDrawPoolAvatar::render(S32 pass)
 
 void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_CHARACTERS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_CHARACTERS);
 	//reset vertex buffer mappings
 	LLVertexBuffer::unbind();
 
@@ -575,7 +575,7 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
 
 void LLDrawPoolAvatar::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_CHARACTERS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_CHARACTERS);
 
 	if (LLPipeline::sImpostorRender)
 	{
@@ -1155,12 +1155,12 @@ void LLDrawPoolAvatar::endDeferredSkinned()
 	gGL.getTexUnit(0)->activate();
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_AVATARS("renderAvatars");
+static LLTrace::TimeBlock FTM_RENDER_AVATARS("renderAvatars");
 
 
 void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_AVATARS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_AVATARS);
 
 	if (pass == -1)
 	{
@@ -1815,11 +1815,11 @@ void LLDrawPoolAvatar::renderDeferredRiggedMaterial(LLVOAvatar* avatar, S32 pass
 	renderRigged(avatar, pass);
 }
 
-static LLFastTimer::DeclareTimer FTM_RIGGED_VBO("Rigged VBO");
+static LLTrace::TimeBlock FTM_RIGGED_VBO("Rigged VBO");
 
 void LLDrawPoolAvatar::updateRiggedVertexBuffers(LLVOAvatar* avatar)
 {
-	LLFastTimer t(FTM_RIGGED_VBO);
+	LL_RECORD_BLOCK_TIME(FTM_RIGGED_VBO);
 
 	//update rigged vertex buffers
 	for (U32 type = 0; type < NUM_RIGGED_PASSES; ++type)
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 6c4226a9a6..010e718689 100755
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -234,7 +234,7 @@ S32 LLDrawPoolBump::getNumPasses()
 
 void LLDrawPoolBump::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 	switch( pass )
 	{
 		case 0:
@@ -261,7 +261,7 @@ void LLDrawPoolBump::beginRenderPass(S32 pass)
 
 void LLDrawPoolBump::render(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 	
 	if (!gPipeline.hasRenderType(LLDrawPool::POOL_SIMPLE))
 	{
@@ -294,7 +294,7 @@ void LLDrawPoolBump::render(S32 pass)
 
 void LLDrawPoolBump::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 	switch( pass )
 	{
 		case 0:
@@ -325,7 +325,7 @@ void LLDrawPoolBump::endRenderPass(S32 pass)
 //static
 void LLDrawPoolBump::beginShiny(bool invisible)
 {
-	LLFastTimer t(FTM_RENDER_SHINY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SHINY);
 	if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| 
 		(invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
 	{
@@ -418,7 +418,7 @@ void LLDrawPoolBump::bindCubeMap(LLGLSLShader* shader, S32 shader_level, S32& di
 
 void LLDrawPoolBump::renderShiny(bool invisible)
 {
-	LLFastTimer t(FTM_RENDER_SHINY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SHINY);
 	if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| 
 		(invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
 	{
@@ -477,7 +477,7 @@ void LLDrawPoolBump::unbindCubeMap(LLGLSLShader* shader, S32 shader_level, S32&
 
 void LLDrawPoolBump::endShiny(bool invisible)
 {
-	LLFastTimer t(FTM_RENDER_SHINY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SHINY);
 	if ((!invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_SHINY))|| 
 		(invisible && !gPipeline.hasRenderBatches(LLRenderPass::PASS_INVISI_SHINY)))
 	{
@@ -497,7 +497,7 @@ void LLDrawPoolBump::endShiny(bool invisible)
 
 void LLDrawPoolBump::beginFullbrightShiny()
 {
-	LLFastTimer t(FTM_RENDER_SHINY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SHINY);
 	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY))
 	{
 		return;
@@ -559,7 +559,7 @@ void LLDrawPoolBump::beginFullbrightShiny()
 
 void LLDrawPoolBump::renderFullbrightShiny()
 {
-	LLFastTimer t(FTM_RENDER_SHINY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SHINY);
 	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY))
 	{
 		return;
@@ -582,7 +582,7 @@ void LLDrawPoolBump::renderFullbrightShiny()
 
 void LLDrawPoolBump::endFullbrightShiny()
 {
-	LLFastTimer t(FTM_RENDER_SHINY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SHINY);
 	if (!gPipeline.hasRenderBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY))
 	{
 		return;
@@ -713,7 +713,7 @@ void LLDrawPoolBump::beginBump(U32 pass)
 	}
 
 	sVertexMask = VERTEX_MASK_BUMP;
-	LLFastTimer t(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 	// Optional second pass: emboss bump map
 	stop_glerror();
 
@@ -765,7 +765,7 @@ void LLDrawPoolBump::renderBump(U32 pass)
 		return;
 	}
 
-	LLFastTimer ftm(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 	LLGLDisable fog(GL_FOG);
 	LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_LEQUAL);
 	LLGLEnable blend(GL_BLEND);
@@ -821,7 +821,7 @@ void LLDrawPoolBump::beginDeferredPass(S32 pass)
 	{
 		return;
 	}
-	LLFastTimer ftm(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 	mShiny = TRUE;
 	gDeferredBumpProgram.bind();
 	diffuse_channel = gDeferredBumpProgram.enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
@@ -836,7 +836,7 @@ void LLDrawPoolBump::endDeferredPass(S32 pass)
 	{
 		return;
 	}
-	LLFastTimer ftm(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 	mShiny = FALSE;
 	gDeferredBumpProgram.disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
 	gDeferredBumpProgram.disableTexture(LLViewerShaderMgr::BUMP_MAP);
@@ -850,7 +850,7 @@ void LLDrawPoolBump::renderDeferred(S32 pass)
 	{
 		return;
 	}
-	LLFastTimer ftm(FTM_RENDER_BUMP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BUMP);
 
 	U32 type = LLRenderPass::PASS_BUMP;
 	LLCullResult::drawinfo_iterator begin = gPipeline.beginRenderMap(type);
@@ -1093,7 +1093,7 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText
 }
 
 
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_STANDARD_LOADED("Bump Standard Callback");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_STANDARD_LOADED("Bump Standard Callback");
 
 // static
 void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata )
@@ -1117,22 +1117,22 @@ void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerFetchedTextu
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_BUMP_GEN_NORMAL("Generate Normal Map");
-static LLFastTimer::DeclareTimer FTM_BUMP_CREATE_TEXTURE("Create GL Normal Map");
+static LLTrace::TimeBlock FTM_BUMP_GEN_NORMAL("Generate Normal Map");
+static LLTrace::TimeBlock FTM_BUMP_CREATE_TEXTURE("Create GL Normal Map");
 
 void LLBumpImageList::onSourceStandardLoaded( BOOL success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata)
 {
 	if (success && LLPipeline::sRenderDeferred)
 	{
-		LLFastTimer t(FTM_BUMP_SOURCE_STANDARD_LOADED);
+		LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_STANDARD_LOADED);
 		LLPointer<LLImageRaw> nrm_image = new LLImageRaw(src->getWidth(), src->getHeight(), 4);
 		{
-			LLFastTimer t(FTM_BUMP_GEN_NORMAL);
+			LL_RECORD_BLOCK_TIME(FTM_BUMP_GEN_NORMAL);
 			generateNormalMapFromAlpha(src, nrm_image);
 		}
 		src_vi->setExplicitFormat(GL_RGBA, GL_RGBA);
 		{
-			LLFastTimer t(FTM_BUMP_CREATE_TEXTURE);
+			LL_RECORD_BLOCK_TIME(FTM_BUMP_CREATE_TEXTURE);
 			src_vi->createGLTexture(src_vi->getDiscardLevel(), nrm_image);
 		}
 	}
@@ -1194,27 +1194,27 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
 }
 
 
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_LOADED("Bump Source Loaded");
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_ENTRIES_UPDATE("Entries Update");
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_MIN_MAX("Min/Max");
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_RGB2LUM("RGB to Luminance");
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_RESCALE("Rescale");
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_GEN_NORMAL("Generate Normal");
-static LLFastTimer::DeclareTimer FTM_BUMP_SOURCE_CREATE("Bump Source Create");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_LOADED("Bump Source Loaded");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_ENTRIES_UPDATE("Entries Update");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_MIN_MAX("Min/Max");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_RGB2LUM("RGB to Luminance");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_RESCALE("Rescale");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_GEN_NORMAL("Generate Normal");
+static LLTrace::TimeBlock FTM_BUMP_SOURCE_CREATE("Bump Source Create");
 
 // static
 void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code )
 {
 	if( success )
 	{
-		LLFastTimer t(FTM_BUMP_SOURCE_LOADED);
+		LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_LOADED);
 
 
 		bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries );
 		bump_image_map_t::iterator iter = entries_list.find(source_asset_id);
 
 		{
-			LLFastTimer t(FTM_BUMP_SOURCE_ENTRIES_UPDATE);
+			LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_ENTRIES_UPDATE);
 			if (iter == entries_list.end() ||
 				iter->second.isNull() ||
 							iter->second->getWidth() != src->getWidth() ||
@@ -1257,7 +1257,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 			case 1:
 			case 2:
 				{
-					LLFastTimer t(FTM_BUMP_SOURCE_MIN_MAX);
+					LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_MIN_MAX);
 					if( src_data_size == dst_data_size * src_components )
 					{
 						for( S32 i = 0, j=0; i < dst_data_size; i++, j+= src_components )
@@ -1283,7 +1283,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 			case 3:
 			case 4:
 				{
-					LLFastTimer t(FTM_BUMP_SOURCE_RGB2LUM);
+					LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_RGB2LUM);
 					if( src_data_size == dst_data_size * src_components )
 					{
 						for( S32 i = 0, j=0; i < dst_data_size; i++, j+= src_components )
@@ -1316,7 +1316,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 
 			if( maximum > minimum )
 			{
-				LLFastTimer t(FTM_BUMP_SOURCE_RESCALE);
+				LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_RESCALE);
 				U8 bias_and_scale_lut[256];
 				F32 twice_one_over_range = 2.f / (maximum - minimum);
 				S32 i;
@@ -1352,7 +1352,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 
 			if (!LLPipeline::sRenderDeferred)
 			{
-				LLFastTimer t(FTM_BUMP_SOURCE_CREATE);
+				LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_CREATE);
 				bump->setExplicitFormat(GL_ALPHA8, GL_ALPHA);
 				bump->createGLTexture(0, dst_image);
 			}
@@ -1363,13 +1363,13 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 				bump->getGLTexture()->setAllowCompression(false);
 
 				{
-					LLFastTimer t(FTM_BUMP_SOURCE_CREATE);
+					LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_CREATE);
 					bump->setExplicitFormat(GL_RGBA8, GL_ALPHA);
 					bump->createGLTexture(0, dst_image);
 				}
 
 				{
-					LLFastTimer t(FTM_BUMP_SOURCE_GEN_NORMAL);
+					LL_RECORD_BLOCK_TIME(FTM_BUMP_SOURCE_GEN_NORMAL);
 					gPipeline.mScreen.bindTarget();
 					
 					LLGLDepthTest depth(GL_FALSE);
@@ -1561,7 +1561,7 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL
 
 void LLDrawPoolInvisible::render(S32 pass)
 { //render invisiprims
-	LLFastTimer t(FTM_RENDER_INVISIBLE);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_INVISIBLE);
   
 	if (gPipeline.canUseVertexShaders())
 	{
@@ -1601,7 +1601,7 @@ void LLDrawPoolInvisible::endDeferredPass( S32 pass )
 void LLDrawPoolInvisible::renderDeferred( S32 pass )
 { //render invisiprims; this doesn't work becaue it also blocks all the post-deferred stuff
 #if 0 
-	LLFastTimer t(FTM_RENDER_INVISIBLE);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_INVISIBLE);
   
 	U32 invisi_mask = LLVertexBuffer::MAP_VERTEX;
 	glStencilMask(0);
diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp
index 08a36bddf1..eea0f370ca 100644
--- a/indra/newview/lldrawpoolmaterials.cpp
+++ b/indra/newview/lldrawpoolmaterials.cpp
@@ -76,12 +76,12 @@ void LLDrawPoolMaterials::beginDeferredPass(S32 pass)
 
 	diffuse_channel = mShader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
 		
-	LLFastTimer t(FTM_RENDER_MATERIALS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_MATERIALS);
 }
 
 void LLDrawPoolMaterials::endDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_MATERIALS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_MATERIALS);
 
 	mShader->unbind();
 
diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index 2cf9d833c6..bbd80304f8 100755
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -41,8 +41,8 @@
 static LLGLSLShader* simple_shader = NULL;
 static LLGLSLShader* fullbright_shader = NULL;
 
-static LLFastTimer::DeclareTimer FTM_RENDER_SIMPLE_DEFERRED("Deferred Simple");
-static LLFastTimer::DeclareTimer FTM_RENDER_GRASS_DEFERRED("Deferred Grass");
+static LLTrace::TimeBlock FTM_RENDER_SIMPLE_DEFERRED("Deferred Simple");
+static LLTrace::TimeBlock FTM_RENDER_GRASS_DEFERRED("Deferred Grass");
 
 void LLDrawPoolGlow::beginPostDeferredPass(S32 pass)
 {
@@ -50,11 +50,11 @@ void LLDrawPoolGlow::beginPostDeferredPass(S32 pass)
 	gDeferredEmissiveProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f);
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_GLOW_PUSH("Glow Push");
+static LLTrace::TimeBlock FTM_RENDER_GLOW_PUSH("Glow Push");
 
 void LLDrawPoolGlow::renderPostDeferred(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_GLOW);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_GLOW);
 	LLGLEnable blend(GL_BLEND);
 	LLGLDisable test(GL_ALPHA_TEST);
 	gGL.flush();
@@ -67,7 +67,7 @@ void LLDrawPoolGlow::renderPostDeferred(S32 pass)
 	gGL.setColorMask(false, true);
 
 	{
-		LLFastTimer t(FTM_RENDER_GLOW_PUSH);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_GLOW_PUSH);
 		pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
 	}
 	
@@ -95,7 +95,7 @@ S32 LLDrawPoolGlow::getNumPasses()
 
 void LLDrawPoolGlow::render(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_GLOW);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_GLOW);
 	LLGLEnable blend(GL_BLEND);
 	LLGLDisable test(GL_ALPHA_TEST);
 	gGL.flush();
@@ -146,7 +146,7 @@ void LLDrawPoolSimple::prerender()
 
 void LLDrawPoolSimple::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_SIMPLE);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE);
 
 	if (LLPipeline::sUnderWaterRender)
 	{
@@ -173,7 +173,7 @@ void LLDrawPoolSimple::beginRenderPass(S32 pass)
 
 void LLDrawPoolSimple::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_SIMPLE);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE);
 	stop_glerror();
 	LLRenderPass::endRenderPass(pass);
 	stop_glerror();
@@ -188,7 +188,7 @@ void LLDrawPoolSimple::render(S32 pass)
 	LLGLDisable blend(GL_BLEND);
 	
 	{ //render simple
-		LLFastTimer t(FTM_RENDER_SIMPLE);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE);
 		gPipeline.enableLightsDynamic();
 
 		if (mVertexShaderLevel > 0)
@@ -225,7 +225,7 @@ void LLDrawPoolSimple::render(S32 pass)
 
 
 
-static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_MASK("Alpha Mask");
+static LLTrace::TimeBlock FTM_RENDER_ALPHA_MASK("Alpha Mask");
 
 LLDrawPoolAlphaMask::LLDrawPoolAlphaMask() :
 	LLRenderPass(POOL_ALPHA_MASK)
@@ -239,7 +239,7 @@ void LLDrawPoolAlphaMask::prerender()
 
 void LLDrawPoolAlphaMask::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA_MASK);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK);
 
 	if (LLPipeline::sUnderWaterRender)
 	{
@@ -266,7 +266,7 @@ void LLDrawPoolAlphaMask::beginRenderPass(S32 pass)
 
 void LLDrawPoolAlphaMask::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA_MASK);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK);
 	stop_glerror();
 	LLRenderPass::endRenderPass(pass);
 	stop_glerror();
@@ -279,7 +279,7 @@ void LLDrawPoolAlphaMask::endRenderPass(S32 pass)
 void LLDrawPoolAlphaMask::render(S32 pass)
 {
 	LLGLDisable blend(GL_BLEND);
-	LLFastTimer t(FTM_RENDER_ALPHA_MASK);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK);
 	
 	if (mVertexShaderLevel > 0)
 	{
@@ -312,7 +312,7 @@ void LLDrawPoolFullbrightAlphaMask::prerender()
 
 void LLDrawPoolFullbrightAlphaMask::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA_MASK);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK);
 
 	if (LLPipeline::sUnderWaterRender)
 	{
@@ -339,7 +339,7 @@ void LLDrawPoolFullbrightAlphaMask::beginRenderPass(S32 pass)
 
 void LLDrawPoolFullbrightAlphaMask::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA_MASK);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK);
 	stop_glerror();
 	LLRenderPass::endRenderPass(pass);
 	stop_glerror();
@@ -351,7 +351,7 @@ void LLDrawPoolFullbrightAlphaMask::endRenderPass(S32 pass)
 
 void LLDrawPoolFullbrightAlphaMask::render(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA_MASK);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK);
 
 	if (mVertexShaderLevel > 0)
 	{
@@ -385,13 +385,13 @@ void LLDrawPoolFullbrightAlphaMask::render(S32 pass)
 
 void LLDrawPoolSimple::beginDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_SIMPLE_DEFERRED);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE_DEFERRED);
 	gDeferredDiffuseProgram.bind();
 }
 
 void LLDrawPoolSimple::endDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_SIMPLE_DEFERRED);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE_DEFERRED);
 	LLRenderPass::endRenderPass(pass);
 
 	gDeferredDiffuseProgram.unbind();
@@ -403,12 +403,12 @@ void LLDrawPoolSimple::renderDeferred(S32 pass)
 	LLGLDisable alpha_test(GL_ALPHA_TEST);
 
 	{ //render simple
-		LLFastTimer t(FTM_RENDER_SIMPLE_DEFERRED);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_SIMPLE_DEFERRED);
 		pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_MASK_DEFERRED("Deferred Alpha Mask");
+static LLTrace::TimeBlock FTM_RENDER_ALPHA_MASK_DEFERRED("Deferred Alpha Mask");
 
 void LLDrawPoolAlphaMask::beginDeferredPass(S32 pass)
 {
@@ -422,7 +422,7 @@ void LLDrawPoolAlphaMask::endDeferredPass(S32 pass)
 
 void LLDrawPoolAlphaMask::renderDeferred(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_ALPHA_MASK_DEFERRED);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA_MASK_DEFERRED);
 	gDeferredDiffuseAlphaMaskProgram.bind();
 	gDeferredDiffuseAlphaMaskProgram.setMinimumAlpha(0.33f);
 	pushMaskBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
@@ -445,7 +445,7 @@ void LLDrawPoolGrass::prerender()
 
 void LLDrawPoolGrass::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_GRASS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_GRASS);
 	stop_glerror();
 
 	if (LLPipeline::sUnderWaterRender)
@@ -475,7 +475,7 @@ void LLDrawPoolGrass::beginRenderPass(S32 pass)
 
 void LLDrawPoolGrass::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_GRASS);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_GRASS);
 	LLRenderPass::endRenderPass(pass);
 
 	if (mVertexShaderLevel > 0)
@@ -493,7 +493,7 @@ void LLDrawPoolGrass::render(S32 pass)
 	LLGLDisable blend(GL_BLEND);
 	
 	{
-		LLFastTimer t(FTM_RENDER_GRASS);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_GRASS);
 		LLGLEnable test(GL_ALPHA_TEST);
 		gGL.setSceneBlendType(LLRender::BT_ALPHA);
 		//render grass
@@ -514,7 +514,7 @@ void LLDrawPoolGrass::endDeferredPass(S32 pass)
 void LLDrawPoolGrass::renderDeferred(S32 pass)
 {
 	{
-		LLFastTimer t(FTM_RENDER_GRASS_DEFERRED);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_GRASS_DEFERRED);
 		gDeferredNonIndexedDiffuseAlphaMaskProgram.bind();
 		gDeferredNonIndexedDiffuseAlphaMaskProgram.setMinimumAlpha(0.5f);
 		//render grass
@@ -541,7 +541,7 @@ void LLDrawPoolFullbright::beginPostDeferredPass(S32 pass)
 
 void LLDrawPoolFullbright::renderPostDeferred(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_FULLBRIGHT);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_FULLBRIGHT);
 	
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 	U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX;
@@ -556,7 +556,7 @@ void LLDrawPoolFullbright::endPostDeferredPass(S32 pass)
 
 void LLDrawPoolFullbright::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_FULLBRIGHT);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_FULLBRIGHT);
 	
 	if (LLPipeline::sUnderWaterRender)
 	{
@@ -570,7 +570,7 @@ void LLDrawPoolFullbright::beginRenderPass(S32 pass)
 
 void LLDrawPoolFullbright::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_FULLBRIGHT);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_FULLBRIGHT);
 	LLRenderPass::endRenderPass(pass);
 
 	stop_glerror();
@@ -585,7 +585,7 @@ void LLDrawPoolFullbright::endRenderPass(S32 pass)
 
 void LLDrawPoolFullbright::render(S32 pass)
 { //render fullbright
-	LLFastTimer t(FTM_RENDER_FULLBRIGHT);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_FULLBRIGHT);
 	gGL.setSceneBlendType(LLRender::BT_ALPHA);
 
 	stop_glerror();
@@ -638,7 +638,7 @@ void LLDrawPoolFullbrightAlphaMask::beginPostDeferredPass(S32 pass)
 
 void LLDrawPoolFullbrightAlphaMask::renderPostDeferred(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_FULLBRIGHT);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_FULLBRIGHT);
 	LLGLDisable blend(GL_BLEND);
 	U32 fullbright_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 | LLVertexBuffer::MAP_COLOR | LLVertexBuffer::MAP_TEXTURE_INDEX;
 	pushMaskBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, fullbright_mask, TRUE, TRUE);
diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp
index 0adb42428d..58a2cae6e4 100755
--- a/indra/newview/lldrawpoolterrain.cpp
+++ b/indra/newview/lldrawpoolterrain.cpp
@@ -55,7 +55,7 @@ int DebugDetailMap = 0;
 S32 LLDrawPoolTerrain::sDetailMode = 1;
 F32 LLDrawPoolTerrain::sDetailScale = DETAIL_SCALE;
 static LLGLSLShader* sShader = NULL;
-static LLFastTimer::DeclareTimer FTM_SHADOW_TERRAIN("Terrain Shadow");
+static LLTrace::TimeBlock FTM_SHADOW_TERRAIN("Terrain Shadow");
 
 
 LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerTexture *texturep) :
@@ -129,7 +129,7 @@ void LLDrawPoolTerrain::prerender()
 
 void LLDrawPoolTerrain::beginRenderPass( S32 pass )
 {
-	LLFastTimer t(FTM_RENDER_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN);
 	LLFacePool::beginRenderPass(pass);
 
 	sShader = LLPipeline::sUnderWaterRender ? 
@@ -144,7 +144,7 @@ void LLDrawPoolTerrain::beginRenderPass( S32 pass )
 
 void LLDrawPoolTerrain::endRenderPass( S32 pass )
 {
-	LLFastTimer t(FTM_RENDER_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN);
 	//LLFacePool::endRenderPass(pass);
 
 	if (mVertexShaderLevel > 1 && sShader->mShaderLevel > 0) {
@@ -160,7 +160,7 @@ S32 LLDrawPoolTerrain::getDetailMode()
 
 void LLDrawPoolTerrain::render(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN);
 	
 	if (mDrawFace.empty())
 	{
@@ -243,7 +243,7 @@ void LLDrawPoolTerrain::render(S32 pass)
 
 void LLDrawPoolTerrain::beginDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN);
 	LLFacePool::beginRenderPass(pass);
 
 	sShader = &gDeferredTerrainProgram;
@@ -253,14 +253,14 @@ void LLDrawPoolTerrain::beginDeferredPass(S32 pass)
 
 void LLDrawPoolTerrain::endDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN);
 	LLFacePool::endRenderPass(pass);
 	sShader->unbind();
 }
 
 void LLDrawPoolTerrain::renderDeferred(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TERRAIN);
 	if (mDrawFace.empty())
 	{
 		return;
@@ -270,7 +270,7 @@ void LLDrawPoolTerrain::renderDeferred(S32 pass)
 
 void LLDrawPoolTerrain::beginShadowPass(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_TERRAIN);
 	LLFacePool::beginRenderPass(pass);
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	gDeferredShadowProgram.bind();
@@ -278,14 +278,14 @@ void LLDrawPoolTerrain::beginShadowPass(S32 pass)
 
 void LLDrawPoolTerrain::endShadowPass(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_TERRAIN);
 	LLFacePool::endRenderPass(pass);
 	gDeferredShadowProgram.unbind();
 }
 
 void LLDrawPoolTerrain::renderShadow(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_TERRAIN);
 	if (mDrawFace.empty())
 	{
 		return;
diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp
index fedbd782dc..187a2045dd 100755
--- a/indra/newview/lldrawpooltree.cpp
+++ b/indra/newview/lldrawpooltree.cpp
@@ -41,7 +41,7 @@
 
 S32 LLDrawPoolTree::sDiffTex = 0;
 static LLGLSLShader* shader = NULL;
-static LLFastTimer::DeclareTimer FTM_SHADOW_TREE("Tree Shadow");
+static LLTrace::TimeBlock FTM_SHADOW_TREE("Tree Shadow");
 
 LLDrawPoolTree::LLDrawPoolTree(LLViewerTexture *texturep) :
 	LLFacePool(POOL_TREE),
@@ -62,7 +62,7 @@ void LLDrawPoolTree::prerender()
 
 void LLDrawPoolTree::beginRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TREES);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TREES);
 		
 	if (LLPipeline::sUnderWaterRender)
 	{
@@ -88,7 +88,7 @@ void LLDrawPoolTree::beginRenderPass(S32 pass)
 
 void LLDrawPoolTree::render(S32 pass)
 {
-	LLFastTimer t(LLPipeline::sShadowRender ? FTM_SHADOW_TREE : FTM_RENDER_TREES);
+	LL_RECORD_BLOCK_TIME(LLPipeline::sShadowRender ? FTM_SHADOW_TREE : FTM_RENDER_TREES);
 
 	if (mDrawFace.empty())
 	{
@@ -131,7 +131,7 @@ void LLDrawPoolTree::render(S32 pass)
 
 void LLDrawPoolTree::endRenderPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TREES);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TREES);
 		
 	if (gPipeline.canUseWindLightShadersOnObjects())
 	{
@@ -149,7 +149,7 @@ void LLDrawPoolTree::endRenderPass(S32 pass)
 //============================================
 void LLDrawPoolTree::beginDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TREES);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TREES);
 		
 	shader = &gDeferredTreeProgram;
 	shader->bind();
@@ -163,7 +163,7 @@ void LLDrawPoolTree::renderDeferred(S32 pass)
 
 void LLDrawPoolTree::endDeferredPass(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_TREES);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TREES);
 		
 	shader->unbind();
 }
@@ -173,7 +173,7 @@ void LLDrawPoolTree::endDeferredPass(S32 pass)
 //============================================
 void LLDrawPoolTree::beginShadowPass(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_TREE);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_TREE);
 	
 	glPolygonOffset(gSavedSettings.getF32("RenderDeferredTreeShadowOffset"),
 					gSavedSettings.getF32("RenderDeferredTreeShadowBias"));
@@ -189,7 +189,7 @@ void LLDrawPoolTree::renderShadow(S32 pass)
 
 void LLDrawPoolTree::endShadowPass(S32 pass)
 {
-	LLFastTimer t(FTM_SHADOW_TREE);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_TREE);
 	
 	glPolygonOffset(gSavedSettings.getF32("RenderDeferredSpotShadowOffset"),
 						gSavedSettings.getF32("RenderDeferredSpotShadowBias"));
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 0e118c7420..b33a4487b6 100755
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -142,7 +142,7 @@ void LLDrawPoolWater::endPostDeferredPass(S32 pass)
 //===============================
 void LLDrawPoolWater::renderDeferred(S32 pass)
 {
-	LLFastTimer t(FTM_RENDER_WATER);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
 	deferred_render = TRUE;
 	shade();
 	deferred_render = FALSE;
@@ -152,7 +152,7 @@ void LLDrawPoolWater::renderDeferred(S32 pass)
 
 void LLDrawPoolWater::render(S32 pass)
 {
-	LLFastTimer ftm(FTM_RENDER_WATER);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
 	if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1)
 	{
 		return;
diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp
index c3ba6c672d..a458fa23a2 100755
--- a/indra/newview/lldrawpoolwlsky.cpp
+++ b/indra/newview/lldrawpoolwlsky.cpp
@@ -306,7 +306,7 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
 	{
 		return;
 	}
-	LLFastTimer ftm(FTM_RENDER_WL_SKY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY);
 
 	const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius();
 
@@ -353,7 +353,7 @@ void LLDrawPoolWLSky::render(S32 pass)
 	{
 		return;
 	}
-	LLFastTimer ftm(FTM_RENDER_WL_SKY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_WL_SKY);
 
 	const F32 camHeightLocal = LLWLParamManager::getInstance()->getDomeOffset() * LLWLParamManager::getInstance()->getDomeRadius();
 
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index ef816ddaf6..16b1b8f10c 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1064,12 +1064,12 @@ bool LLFace::canRenderAsMask()
 }
 
 
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_VOLUME("Volume VB Cache");
+static LLTrace::TimeBlock FTM_FACE_GEOM_VOLUME("Volume VB Cache");
 
 //static 
 void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf)
 {
-	LLFastTimer t(FTM_FACE_GEOM_VOLUME);
+	LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_VOLUME);
 	U32 mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0 |
 				LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_NORMAL;
 	
@@ -1131,24 +1131,24 @@ void push_for_transform(LLVertexBuffer* buff, U32 source_count, U32 dest_count)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_FACE_GET_GEOM("Face Geom");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_POSITION("Position");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_NORMAL("Normal");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_TEXTURE("Texture");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_COLOR("Color");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_EMISSIVE("Emissive");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_WEIGHTS("Weights");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_TANGENT("Binormal");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_INDEX("Index");
-static LLFastTimer::DeclareTimer FTM_FACE_GEOM_INDEX_TAIL("Tail");
-static LLFastTimer::DeclareTimer FTM_FACE_POSITION_STORE("Pos");
-static LLFastTimer::DeclareTimer FTM_FACE_TEXTURE_INDEX_STORE("TexIdx");
-static LLFastTimer::DeclareTimer FTM_FACE_POSITION_PAD("Pad");
-static LLFastTimer::DeclareTimer FTM_FACE_TEX_DEFAULT("Default");
-static LLFastTimer::DeclareTimer FTM_FACE_TEX_QUICK("Quick");
-static LLFastTimer::DeclareTimer FTM_FACE_TEX_QUICK_NO_XFORM("No Xform");
-static LLFastTimer::DeclareTimer FTM_FACE_TEX_QUICK_XFORM("Xform");
-static LLFastTimer::DeclareTimer FTM_FACE_TEX_QUICK_PLANAR("Quick Planar");
+static LLTrace::TimeBlock FTM_FACE_GET_GEOM("Face Geom");
+static LLTrace::TimeBlock FTM_FACE_GEOM_POSITION("Position");
+static LLTrace::TimeBlock FTM_FACE_GEOM_NORMAL("Normal");
+static LLTrace::TimeBlock FTM_FACE_GEOM_TEXTURE("Texture");
+static LLTrace::TimeBlock FTM_FACE_GEOM_COLOR("Color");
+static LLTrace::TimeBlock FTM_FACE_GEOM_EMISSIVE("Emissive");
+static LLTrace::TimeBlock FTM_FACE_GEOM_WEIGHTS("Weights");
+static LLTrace::TimeBlock FTM_FACE_GEOM_TANGENT("Binormal");
+static LLTrace::TimeBlock FTM_FACE_GEOM_INDEX("Index");
+static LLTrace::TimeBlock FTM_FACE_GEOM_INDEX_TAIL("Tail");
+static LLTrace::TimeBlock FTM_FACE_POSITION_STORE("Pos");
+static LLTrace::TimeBlock FTM_FACE_TEXTURE_INDEX_STORE("TexIdx");
+static LLTrace::TimeBlock FTM_FACE_POSITION_PAD("Pad");
+static LLTrace::TimeBlock FTM_FACE_TEX_DEFAULT("Default");
+static LLTrace::TimeBlock FTM_FACE_TEX_QUICK("Quick");
+static LLTrace::TimeBlock FTM_FACE_TEX_QUICK_NO_XFORM("No Xform");
+static LLTrace::TimeBlock FTM_FACE_TEX_QUICK_XFORM("Xform");
+static LLTrace::TimeBlock FTM_FACE_TEX_QUICK_PLANAR("Quick Planar");
 
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 							   const S32 &f,
@@ -1156,7 +1156,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 								const U16 &index_offset,
 								bool force_rebuild)
 {
-	LLFastTimer t(FTM_FACE_GET_GEOM);
+	LL_RECORD_BLOCK_TIME(FTM_FACE_GET_GEOM);
 	llassert(verify());
 	const LLVolumeFace &vf = volume.getVolumeFace(f);
 	S32 num_vertices = (S32)vf.mNumVertices;
@@ -1292,7 +1292,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	// INDICES
 	if (full_rebuild)
 	{
-		LLFastTimer t(FTM_FACE_GEOM_INDEX);
+		LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_INDEX);
 		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex, mIndicesCount, map_range);
 
 		volatile __m128i* dst = (__m128i*) indicesp.get();
@@ -1308,7 +1308,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		}
 
 		{
-			LLFastTimer t(FTM_FACE_GEOM_INDEX_TAIL);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_INDEX_TAIL);
 			U16* idx = (U16*) dst;
 
 			for (S32 i = end*8; i < num_indices; ++i)
@@ -1386,7 +1386,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_pos)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_POSITION);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_POSITION);
 			gTransformPositionProgram.bind();
 
 			mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_VERTEX, mGeomIndex, mGeomCount);
@@ -1411,7 +1411,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_color)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_COLOR);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_COLOR);
 			gTransformColorProgram.bind();
 			
 			mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_COLOR, mGeomIndex, mGeomCount);
@@ -1427,7 +1427,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_emissive)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_EMISSIVE);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_EMISSIVE);
 			gTransformColorProgram.bind();
 			
 			mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_EMISSIVE, mGeomIndex, mGeomCount);
@@ -1448,7 +1448,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_normal)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_NORMAL);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_NORMAL);
 			gTransformNormalProgram.bind();
 			
 			mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_NORMAL, mGeomIndex, mGeomCount);
@@ -1461,7 +1461,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_tangent)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_TANGENT);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_TANGENT);
 			gTransformTangentProgram.bind();
 			
 			mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TANGENT, mGeomIndex, mGeomCount);
@@ -1474,7 +1474,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_tcoord)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_TEXTURE);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_TEXTURE);
 			gTransformTexCoordProgram.bind();
 			
 			mVertexBuffer->bindForFeedback(0, LLVertexBuffer::TYPE_TEXCOORD0, mGeomIndex, mGeomCount);
@@ -1514,7 +1514,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_tcoord)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_TEXTURE);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_TEXTURE);
 									
 			//bump setup
 			LLVector4a binormal_dir( -sin_ang, cos_ang, 0.f );
@@ -1637,18 +1637,18 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 				if (texgen != LLTextureEntry::TEX_GEN_PLANAR)
 				{
-					LLFastTimer t(FTM_FACE_TEX_QUICK);
+					LL_RECORD_BLOCK_TIME(FTM_FACE_TEX_QUICK);
 					if (!do_tex_mat)
 					{
 						if (!do_xform)
 						{
-							LLFastTimer t(FTM_FACE_TEX_QUICK_NO_XFORM);
+							LL_RECORD_BLOCK_TIME(FTM_FACE_TEX_QUICK_NO_XFORM);
 							S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF;
 							LLVector4a::memcpyNonAliased16((F32*) tex_coords0.get(), (F32*) vf.mTexCoords, tc_size);
 						}
 						else
 						{
-							LLFastTimer t(FTM_FACE_TEX_QUICK_XFORM);
+							LL_RECORD_BLOCK_TIME(FTM_FACE_TEX_QUICK_XFORM);
 							F32* dst = (F32*) tex_coords0.get();
 							LLVector4a* src = (LLVector4a*) vf.mTexCoords;
 
@@ -1701,7 +1701,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 				}
 				else
 				{ //no bump, tex gen planar
-					LLFastTimer t(FTM_FACE_TEX_QUICK_PLANAR);
+					LL_RECORD_BLOCK_TIME(FTM_FACE_TEX_QUICK_PLANAR);
 					if (do_tex_mat)
 					{
 						for (S32 i = 0; i < num_vertices; i++)
@@ -1746,7 +1746,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 			}
 			else
 			{ //bump mapped or has material, just do the whole expensive loop
-				LLFastTimer t(FTM_FACE_TEX_DEFAULT);
+				LL_RECORD_BLOCK_TIME(FTM_FACE_TEX_DEFAULT);
 
 				std::vector<LLVector2> bump_tc;
 		
@@ -1897,7 +1897,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_pos)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_POSITION);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_POSITION);
 			llassert(num_vertices > 0);
 		
 			mVertexBuffer->getVertexStrider(vert, mGeomIndex, mGeomCount, map_range);
@@ -1929,7 +1929,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 			texIdx.set(0,0,0,val);
 
 			{
-				LLFastTimer t(FTM_FACE_POSITION_STORE);
+				LL_RECORD_BLOCK_TIME(FTM_FACE_POSITION_STORE);
 				LLVector4a tmp;
 
 				do
@@ -1943,7 +1943,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 			}
 
 			{
-				LLFastTimer t(FTM_FACE_POSITION_PAD);
+				LL_RECORD_BLOCK_TIME(FTM_FACE_POSITION_PAD);
 				S32 aligned_pad_vertices = mGeomCount - num_vertices;
 				res.set(res[0], res[1], res[2], 0.f);
 
@@ -1964,7 +1964,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		
 		if (rebuild_normal)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_NORMAL);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_NORMAL);
 			mVertexBuffer->getNormalStrider(norm, mGeomIndex, mGeomCount, map_range);
 			F32* normals = (F32*) norm.get();
 			for (S32 i = 0; i < num_vertices; i++)
@@ -1984,7 +1984,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 		
 		if (rebuild_tangent)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_TANGENT);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_TANGENT);
 			mVertexBuffer->getTangentStrider(tangent, mGeomIndex, mGeomCount, map_range);
 			F32* tangents = (F32*) tangent.get();
 			
@@ -2013,7 +2013,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 	
 		if (rebuild_weights && vf.mWeights)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_WEIGHTS);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_WEIGHTS);
 			mVertexBuffer->getWeight4Strider(wght, mGeomIndex, mGeomCount, map_range);
 			F32* weights = (F32*) wght.get();
 			LLVector4a::memcpyNonAliased16(weights, (F32*) vf.mWeights, num_vertices*4*sizeof(F32));
@@ -2025,7 +2025,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_color && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_COLOR) )
 		{
-			LLFastTimer t(FTM_FACE_GEOM_COLOR);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_COLOR);
 			mVertexBuffer->getColorStrider(colors, mGeomIndex, mGeomCount, map_range);
 
 			LLVector4a src;
@@ -2056,7 +2056,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 
 		if (rebuild_emissive)
 		{
-			LLFastTimer t(FTM_FACE_GEOM_EMISSIVE);
+			LL_RECORD_BLOCK_TIME(FTM_FACE_GEOM_EMISSIVE);
 			LLStrider<LLColor4U> emissive;
 			mVertexBuffer->getEmissiveStrider(emissive, mGeomIndex, mGeomCount, map_range);
 
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index e8db263fae..bbd8f0792a 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -381,7 +381,7 @@ static std::vector<LLColor4> sTimerColors;
 
 void LLFastTimerView::draw()
 {
-	LLFastTimer t(FTM_RENDER_TIMER);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_TIMER);
 	
 	if (!mPauseHistory)
 	{
@@ -1019,11 +1019,11 @@ void LLFastTimerView::printLineStats()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_DRAW_LINE_GRAPH("Draw line graph");
+static LLTrace::TimeBlock FTM_DRAW_LINE_GRAPH("Draw line graph");
 
 void LLFastTimerView::drawLineGraph()
 {
-	LLFastTimer _(FTM_DRAW_LINE_GRAPH);
+	LL_RECORD_BLOCK_TIME(FTM_DRAW_LINE_GRAPH);
 	//draw line graph history
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 	LLLocalClipRect clip(mGraphRect);
@@ -1509,11 +1509,11 @@ void LLFastTimerView::drawBars()
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
+static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
 F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
 {
-	LLFastTimer _(FTM_UPDATE_TIMER_BAR_WIDTHS);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_WIDTHS);
 	const F32Seconds self_time = history_index == -1
 										? mRecording.getPeriodMean(time_block->selfTime(), RUNNING_AVERAGE_WIDTH) 
 										: mRecording.getPrevRecording(history_index).getSum(time_block->selfTime());
@@ -1537,11 +1537,11 @@ F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block,
 	return full_time;
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions");
+static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions");
 
 S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index)
 {
-	LLFastTimer _(FTM_UPDATE_TIMER_BAR_FRACTIONS);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_FRACTIONS);
 
 	TimerBar& timer_bar = row.mBars[timer_bar_index];
 	const F32Seconds bar_time = timer_bar.mTotalTime - timer_bar.mSelfTime;
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index caad0afec0..817a853190 100755
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -47,8 +47,8 @@
 std::vector<LLVolumeImplFlexible*> LLVolumeImplFlexible::sInstanceList;
 std::vector<S32> LLVolumeImplFlexible::sUpdateDelay;
 
-static LLFastTimer::DeclareTimer FTM_FLEXIBLE_REBUILD("Rebuild");
-static LLFastTimer::DeclareTimer FTM_DO_FLEXIBLE_UPDATE("Flexible Update");
+static LLTrace::TimeBlock FTM_FLEXIBLE_REBUILD("Rebuild");
+static LLTrace::TimeBlock FTM_DO_FLEXIBLE_UPDATE("Flexible Update");
 
 // LLFlexibleObjectData::pack/unpack now in llprimitive.cpp
 
@@ -331,14 +331,14 @@ void LLVolumeImplFlexible::updateRenderRes()
 // updated every time step. In the future, perhaps there could be an 
 // optimization similar to what Havok does for objects that are stationary. 
 //---------------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_FLEXIBLE_UPDATE("Update Flexies");
+static LLTrace::TimeBlock FTM_FLEXIBLE_UPDATE("Update Flexies");
 void LLVolumeImplFlexible::doIdleUpdate()
 {
 	LLDrawable* drawablep = mVO->mDrawable;
 
 	if (drawablep)
 	{
-		//LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
+		//LL_RECORD_BLOCK_TIME(FTM_FLEXIBLE_UPDATE);
 
 		//ensure drawable is active
 		drawablep->makeActive();
@@ -421,7 +421,7 @@ inline S32 log2(S32 x)
 
 void LLVolumeImplFlexible::doFlexibleUpdate()
 {
-	LLFastTimer ftm(FTM_DO_FLEXIBLE_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_DO_FLEXIBLE_UPDATE);
 	LLVolume* volume = mVO->getVolume();
 	LLPath *path = &volume->getPath();
 	if ((mSimulateRes == 0 || !mInitialized) && mVO->mDrawable->isVisible()) 
@@ -771,7 +771,7 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
 
 	if (mRenderRes > -1)
 	{
-		LLFastTimer t(FTM_DO_FLEXIBLE_UPDATE);
+		LL_RECORD_BLOCK_TIME(FTM_DO_FLEXIBLE_UPDATE);
 		doFlexibleUpdate();
 	}
 	
@@ -791,7 +791,7 @@ BOOL LLVolumeImplFlexible::doUpdateGeometry(LLDrawable *drawable)
 		volume->mDrawable->setState(LLDrawable::REBUILD_VOLUME);
 		volume->dirtySpatialGroup();
 		{
-			LLFastTimer t(FTM_FLEXIBLE_REBUILD);
+			LL_RECORD_BLOCK_TIME(FTM_FLEXIBLE_REBUILD);
 			doFlexibleRebuild();
 		}
 		volume->genBBoxes(isVolumeGlobal());
diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp
index 586965e5a0..52f4dd57e5 100755
--- a/indra/newview/llfolderviewmodelinventory.cpp
+++ b/indra/newview/llfolderviewmodelinventory.cpp
@@ -34,7 +34,7 @@
 //
 // class LLFolderViewModelInventory
 //
-static LLFastTimer::DeclareTimer FTM_INVENTORY_SORT("Sort");
+static LLTrace::TimeBlock FTM_INVENTORY_SORT("Sort");
 
 bool LLFolderViewModelInventory::startDrag(std::vector<LLFolderViewModelItem*>& items)
 {
@@ -63,7 +63,7 @@ bool LLFolderViewModelInventory::startDrag(std::vector<LLFolderViewModelItem*>&
 
 void LLFolderViewModelInventory::sort( LLFolderViewFolder* folder )
 {
-	LLFastTimer _(FTM_INVENTORY_SORT);
+	LL_RECORD_BLOCK_TIME(FTM_INVENTORY_SORT);
 
 	if (!needsSort(folder->getViewModelItem())) return;
 
diff --git a/indra/newview/llhudmanager.cpp b/indra/newview/llhudmanager.cpp
index fd28fdeab9..9d7b8b13e3 100755
--- a/indra/newview/llhudmanager.cpp
+++ b/indra/newview/llhudmanager.cpp
@@ -54,11 +54,11 @@ LLHUDManager::~LLHUDManager()
 {
 }
 
-static LLFastTimer::DeclareTimer FTM_HUD_EFFECTS("Hud Effects");
+static LLTrace::TimeBlock FTM_HUD_EFFECTS("Hud Effects");
 
 void LLHUDManager::updateEffects()
 {
-	LLFastTimer ftm(FTM_HUD_EFFECTS);
+	LL_RECORD_BLOCK_TIME(FTM_HUD_EFFECTS);
 	S32 i;
 	for (i = 0; i < mHUDEffects.size(); i++)
 	{
diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp
index 165201c8a1..4b0dadec38 100755
--- a/indra/newview/llhudobject.cpp
+++ b/indra/newview/llhudobject.cpp
@@ -252,12 +252,12 @@ LLHUDEffect *LLHUDObject::addHUDEffect(const U8 type)
 	return hud_objectp;
 }
 
-static LLFastTimer::DeclareTimer FTM_HUD_UPDATE("Update Hud");
+static LLTrace::TimeBlock FTM_HUD_UPDATE("Update Hud");
 
 // static
 void LLHUDObject::updateAll()
 {
-	LLFastTimer ftm(FTM_HUD_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_HUD_UPDATE);
 	LLHUDText::updateAll();
 	LLHUDIcon::updateAll();
 	LLHUDNameTag::updateAll();
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index baf93a0469..3265676f9b 100755
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -42,7 +42,7 @@
 #include "llclipboard.h"
 #include "lltrans.h"
 
-LLFastTimer::DeclareTimer FT_FILTER_CLIPBOARD("Filter Clipboard");
+LLTrace::TimeBlock FT_FILTER_CLIPBOARD("Filter Clipboard");
 
 LLInventoryFilter::FilterOps::FilterOps(const Params& p)
 :	mFilterObjectTypes(p.object_types),
@@ -313,7 +313,7 @@ bool LLInventoryFilter::checkAgainstClipboard(const LLUUID& object_id) const
 {
 	if (LLClipboard::instance().isCutMode())
 	{
-		LLFastTimer ft(FT_FILTER_CLIPBOARD);
+		LL_RECORD_BLOCK_TIME(FT_FILTER_CLIPBOARD);
 		LLUUID current_id = object_id;
 		LLInventoryObject *current_object = gInventory.getObject(object_id);
 		while (current_id.notNull() && current_object)
diff --git a/indra/newview/llinventoryitemslist.cpp b/indra/newview/llinventoryitemslist.cpp
index a84aa452dc..f6d0ecc5bf 100755
--- a/indra/newview/llinventoryitemslist.cpp
+++ b/indra/newview/llinventoryitemslist.cpp
@@ -133,11 +133,11 @@ void LLInventoryItemsList::idle(void* user_data)
 	}
 }
 
-LLFastTimer::DeclareTimer FTM_INVENTORY_ITEMS_REFRESH("Inventory List Refresh");
+LLTrace::TimeBlock FTM_INVENTORY_ITEMS_REFRESH("Inventory List Refresh");
 
 void LLInventoryItemsList::refresh()
 {
-	LLFastTimer _(FTM_INVENTORY_ITEMS_REFRESH);
+	LL_RECORD_BLOCK_TIME(FTM_INVENTORY_ITEMS_REFRESH);
 	static const unsigned ADD_LIMIT = 20;
 
 	uuid_vec_t added_items;
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 7239a7e850..2a7ae017fb 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -396,11 +396,11 @@ LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState()
 	return getFilter().getShowFolderState();
 }
 
-static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh");
+static LLTrace::TimeBlock FTM_REFRESH("Inventory Refresh");
 
 void LLInventoryPanel::modelChanged(U32 mask)
 {
-	LLFastTimer t2(FTM_REFRESH);
+	LL_RECORD_BLOCK_TIME(FTM_REFRESH);
 
 	if (!mViewsInitialized) return;
 	
@@ -1295,10 +1295,10 @@ void LLInventoryPanel::removeItemID(const LLUUID& id)
 	}
 }
 
-LLFastTimer::DeclareTimer FTM_GET_ITEM_BY_ID("Get FolderViewItem by ID");
+LLTrace::TimeBlock FTM_GET_ITEM_BY_ID("Get FolderViewItem by ID");
 LLFolderViewItem* LLInventoryPanel::getItemByID(const LLUUID& id)
 {
-	LLFastTimer _(FTM_GET_ITEM_BY_ID);
+	LL_RECORD_BLOCK_TIME(FTM_GET_ITEM_BY_ID);
 
 	std::map<LLUUID, LLFolderViewItem*>::iterator map_it;
 	map_it = mItemMap.find(id);
diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp
index 16871adc4d..c5b4aac2f0 100644
--- a/indra/newview/llmaterialmgr.cpp
+++ b/indra/newview/llmaterialmgr.cpp
@@ -526,11 +526,11 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_MATERIALS_IDLE("Materials");
+static LLTrace::TimeBlock FTM_MATERIALS_IDLE("Materials");
 
 void LLMaterialMgr::onIdle(void*)
 {
-	LLFastTimer t(FTM_MATERIALS_IDLE);
+	LL_RECORD_BLOCK_TIME(FTM_MATERIALS_IDLE);
 
 	LLMaterialMgr* instancep = LLMaterialMgr::getInstance();
 
diff --git a/indra/newview/llpersistentnotificationstorage.cpp b/indra/newview/llpersistentnotificationstorage.cpp
index 666f10df96..bd4b0a0b08 100755
--- a/indra/newview/llpersistentnotificationstorage.cpp
+++ b/indra/newview/llpersistentnotificationstorage.cpp
@@ -46,11 +46,11 @@ LLPersistentNotificationStorage::~LLPersistentNotificationStorage()
 {
 }
 
-static LLFastTimer::DeclareTimer FTM_SAVE_NOTIFICATIONS("Save Notifications");
+static LLTrace::TimeBlock FTM_SAVE_NOTIFICATIONS("Save Notifications");
 
 void LLPersistentNotificationStorage::saveNotifications()
 {
-	LLFastTimer _(FTM_SAVE_NOTIFICATIONS);
+	LL_RECORD_BLOCK_TIME(FTM_SAVE_NOTIFICATIONS);
 
 	boost::intrusive_ptr<LLPersistentNotificationChannel> history_channel = boost::dynamic_pointer_cast<LLPersistentNotificationChannel>(LLNotifications::instance().getChannel("Persistent"));
 	if (!history_channel)
@@ -81,11 +81,11 @@ void LLPersistentNotificationStorage::saveNotifications()
 	writeNotifications(output);
 }
 
-static LLFastTimer::DeclareTimer FTM_LOAD_NOTIFICATIONS("Load Notifications");
+static LLTrace::TimeBlock FTM_LOAD_NOTIFICATIONS("Load Notifications");
 
 void LLPersistentNotificationStorage::loadNotifications()
 {
-	LLFastTimer _(FTM_LOAD_NOTIFICATIONS);
+	LL_RECORD_BLOCK_TIME(FTM_LOAD_NOTIFICATIONS);
 
 	LL_INFOS("LLPersistentNotificationStorage") << "start loading notifications" << LL_ENDL;
 
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 666fb1a0e5..429d6a9258 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -331,8 +331,8 @@ bool LLSceneMonitor::needsUpdate() const
 	return mDiffState == NEED_DIFF;
 }
 
-static LLFastTimer::DeclareTimer FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture");
-static LLFastTimer::DeclareTimer FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Diff");
+static LLTrace::TimeBlock FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture");
+static LLTrace::TimeBlock FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Diff");
 
 void LLSceneMonitor::compare()
 {
@@ -350,14 +350,14 @@ void LLSceneMonitor::compare()
 		return; 
 	}
 
-	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
+	LL_RECORD_BLOCK_TIME(FTM_SCENE_LOAD_IMAGE_DIFF);
 	mDiffState = EXECUTE_DIFF;
 
 	S32 width = gViewerWindow->getWindowWidthRaw();
 	S32 height = gViewerWindow->getWindowHeightRaw();
 	if(!mDiff)
 	{
-		LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE);
+		LL_RECORD_BLOCK_TIME(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE);
 		mDiff = new LLRenderTarget();
 		mDiff->allocate(width, height, GL_RGBA, false, false, LLTexUnit::TT_TEXTURE, true);
 
@@ -365,7 +365,7 @@ void LLSceneMonitor::compare()
 	}
 	else if(mDiff->getWidth() != width || mDiff->getHeight() != height)
 	{
-		LLFastTimer _(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE);
+		LL_RECORD_BLOCK_TIME(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE);
 		mDiff->resize(width, height, GL_RGBA);
 		generateDitheringTexture(width, height);
 	}
@@ -416,7 +416,7 @@ void LLSceneMonitor::compare()
 //calculate Diff aggregate information in GPU, and enable gl occlusion query to capture it.
 void LLSceneMonitor::calcDiffAggregate()
 {
-	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
+	LL_RECORD_BLOCK_TIME(FTM_SCENE_LOAD_IMAGE_DIFF);
 
 	if(mDiffState != EXECUTE_DIFF && !mDebugViewerVisible)
 	{
@@ -469,7 +469,7 @@ void LLSceneMonitor::calcDiffAggregate()
 static LLTrace::EventStatHandle<> sFramePixelDiff("FramePixelDifference");
 void LLSceneMonitor::fetchQueryResult()
 {
-	LLFastTimer _(FTM_SCENE_LOAD_IMAGE_DIFF);
+	LL_RECORD_BLOCK_TIME(FTM_SCENE_LOAD_IMAGE_DIFF);
 
 	// also throttle timing here, to avoid going below sample time due to phasing with frame capture
 	static LLCachedControl<F32>  scene_load_sample_time_control(gSavedSettings, "SceneLoadingMonitorSampleTime");
diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp
index 0ed6a840e0..fbf3c8c401 100755
--- a/indra/newview/llscreenchannel.cpp
+++ b/indra/newview/llscreenchannel.cpp
@@ -49,10 +49,10 @@ using namespace LLNotificationsUI;
 
 bool LLScreenChannel::mWasStartUpToastShown = false;
 
-LLFastTimer::DeclareTimer FTM_GET_CHANNEL_RECT("Calculate Notification Channel Region");
+LLTrace::TimeBlock FTM_GET_CHANNEL_RECT("Calculate Notification Channel Region");
 LLRect LLScreenChannelBase::getChannelRect()
 {
-	LLFastTimer _(FTM_GET_CHANNEL_RECT);
+	LL_RECORD_BLOCK_TIME(FTM_GET_CHANNEL_RECT);
 
 	if (mFloaterSnapRegion == NULL)
 	{
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 725afb9014..6bd10ecd0d 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -53,8 +53,8 @@
 #include "lltextureatlas.h"
 #include "llviewershadermgr.h"
 
-static LLFastTimer::DeclareTimer FTM_FRUSTUM_CULL("Frustum Culling");
-static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound Partition");
+static LLTrace::TimeBlock FTM_FRUSTUM_CULL("Frustum Culling");
+static LLTrace::TimeBlock FTM_CULL_REBOUND("Cull Rebound Partition");
 
 extern bool gShiftFrame;
 
@@ -408,10 +408,10 @@ void LLSpatialGroup::rebuildMesh()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_VBO("VBO Rebuilt");
-static LLFastTimer::DeclareTimer FTM_ADD_GEOMETRY_COUNT("Add Geometry");
-static LLFastTimer::DeclareTimer FTM_CREATE_VB("Create VB");
-static LLFastTimer::DeclareTimer FTM_GET_GEOMETRY("Get Geometry");
+static LLTrace::TimeBlock FTM_REBUILD_VBO("VBO Rebuilt");
+static LLTrace::TimeBlock FTM_ADD_GEOMETRY_COUNT("Add Geometry");
+static LLTrace::TimeBlock FTM_CREATE_VB("Create VB");
+static LLTrace::TimeBlock FTM_GET_GEOMETRY("Get Geometry");
 
 void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group)
 {
@@ -426,7 +426,7 @@ void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group)
 		group->mLastUpdateViewAngle = group->mViewAngle;
 	}
 	
-	LLFastTimer ftm(FTM_REBUILD_VBO);	
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_VBO);	
 
 	group->clearDrawMap();
 	
@@ -435,14 +435,14 @@ void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group)
 	U32 vertex_count = 0;
 
 	{
-		LLFastTimer t(FTM_ADD_GEOMETRY_COUNT);
+		LL_RECORD_BLOCK_TIME(FTM_ADD_GEOMETRY_COUNT);
 		addGeometryCount(group, vertex_count, index_count);
 	}
 
 	if (vertex_count > 0 && index_count > 0)
 	{ //create vertex buffer containing volume geometry for this node
 		{
-			LLFastTimer t(FTM_CREATE_VB);
+			LL_RECORD_BLOCK_TIME(FTM_CREATE_VB);
 			group->mBuilt = 1.f;
 			if (group->mVertexBuffer.isNull() ||
 				!group->mVertexBuffer->isWriteable() ||
@@ -460,7 +460,7 @@ void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group)
 		}
 
 		{
-			LLFastTimer t(FTM_GET_GEOMETRY);
+			LL_RECORD_BLOCK_TIME(FTM_GET_GEOMETRY);
 			getGeometry(group);
 		}
 	}
@@ -1435,7 +1435,7 @@ BOOL LLSpatialPartition::getVisibleExtents(LLCamera& camera, LLVector3& visMin,
 	visMaxa.load3(visMax.mV);
 
 	{
-		LLFastTimer ftm(FTM_CULL_REBOUND);		
+		LL_RECORD_BLOCK_TIME(FTM_CULL_REBOUND);		
 		LLSpatialGroup* group = (LLSpatialGroup*) mOctree->getListener(0);
 		group->rebound();
 	}
@@ -1461,7 +1461,7 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* result
 	((LLSpatialGroup*)mOctree->getListener(0))->checkStates();
 #endif
 	{
-		LLFastTimer ftm(FTM_CULL_REBOUND);		
+		LL_RECORD_BLOCK_TIME(FTM_CULL_REBOUND);		
 		LLSpatialGroup* group = (LLSpatialGroup*) mOctree->getListener(0);
 		group->rebound();
 	}
@@ -1482,7 +1482,7 @@ S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion)
 	((LLSpatialGroup*)mOctree->getListener(0))->checkStates();
 #endif
 	{
-		LLFastTimer ftm(FTM_CULL_REBOUND);		
+		LL_RECORD_BLOCK_TIME(FTM_CULL_REBOUND);		
 		LLSpatialGroup* group = (LLSpatialGroup*) mOctree->getListener(0);
 		group->rebound();
 	}
@@ -1493,19 +1493,19 @@ S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion)
 
 	if (LLPipeline::sShadowRender)
 	{
-		LLFastTimer ftm(FTM_FRUSTUM_CULL);
+		LL_RECORD_BLOCK_TIME(FTM_FRUSTUM_CULL);
 		LLOctreeCullShadow culler(&camera);
 		culler.traverse(mOctree);
 	}
 	else if (mInfiniteFarClip || !LLPipeline::sUseFarClip)
 	{
-		LLFastTimer ftm(FTM_FRUSTUM_CULL);		
+		LL_RECORD_BLOCK_TIME(FTM_FRUSTUM_CULL);		
 		LLOctreeCullNoFarClip culler(&camera);
 		culler.traverse(mOctree);
 	}
 	else
 	{
-		LLFastTimer ftm(FTM_FRUSTUM_CULL);		
+		LL_RECORD_BLOCK_TIME(FTM_FRUSTUM_CULL);		
 		LLOctreeCull culler(&camera);
 		culler.traverse(mOctree);
 	}
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 92bb5a8beb..b6f6ed811e 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -180,11 +180,11 @@ void display_startup()
 	glClear(GL_DEPTH_BUFFER_BIT);
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_CAMERA("Update Camera");
+static LLTrace::TimeBlock FTM_UPDATE_CAMERA("Update Camera");
 
 void display_update_camera()
 {
-	LLFastTimer t(FTM_UPDATE_CAMERA);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA);
 	// TODO: cut draw distance down if customizing avatar?
 	// TODO: cut draw distance on per-parcel basis?
 
@@ -228,29 +228,29 @@ void display_stats()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_PICK("Picking");
-static LLFastTimer::DeclareTimer FTM_RENDER("Render");
-static LLFastTimer::DeclareTimer FTM_UPDATE_SKY("Update Sky");
-static LLFastTimer::DeclareTimer FTM_UPDATE_TEXTURES("Update Textures");
-static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE("Update Images");
-static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_CLASS("Class");
-static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_BUMP("Image Update Bump");
-static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_LIST("List");
-static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_DELETE("Delete");
-static LLFastTimer::DeclareTimer FTM_RESIZE_WINDOW("Resize Window");
-static LLFastTimer::DeclareTimer FTM_HUD_UPDATE("HUD Update");
-static LLFastTimer::DeclareTimer FTM_DISPLAY_UPDATE_GEOM("Update Geom");
-static LLFastTimer::DeclareTimer FTM_TEXTURE_UNBIND("Texture Unbind");
-static LLFastTimer::DeclareTimer FTM_TELEPORT_DISPLAY("Teleport Display");
+static LLTrace::TimeBlock FTM_PICK("Picking");
+static LLTrace::TimeBlock FTM_RENDER("Render");
+static LLTrace::TimeBlock FTM_UPDATE_SKY("Update Sky");
+static LLTrace::TimeBlock FTM_UPDATE_TEXTURES("Update Textures");
+static LLTrace::TimeBlock FTM_IMAGE_UPDATE("Update Images");
+static LLTrace::TimeBlock FTM_IMAGE_UPDATE_CLASS("Class");
+static LLTrace::TimeBlock FTM_IMAGE_UPDATE_BUMP("Image Update Bump");
+static LLTrace::TimeBlock FTM_IMAGE_UPDATE_LIST("List");
+static LLTrace::TimeBlock FTM_IMAGE_UPDATE_DELETE("Delete");
+static LLTrace::TimeBlock FTM_RESIZE_WINDOW("Resize Window");
+static LLTrace::TimeBlock FTM_HUD_UPDATE("HUD Update");
+static LLTrace::TimeBlock FTM_DISPLAY_UPDATE_GEOM("Update Geom");
+static LLTrace::TimeBlock FTM_TEXTURE_UNBIND("Texture Unbind");
+static LLTrace::TimeBlock FTM_TELEPORT_DISPLAY("Teleport Display");
 
 // Paint the display!
 void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 {
-	LLFastTimer t(FTM_RENDER);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER);
 
 	if (gWindowResized)
 	{ //skip render on frames where window has been resized
-		LLFastTimer t(FTM_RESIZE_WINDOW);
+		LL_RECORD_BLOCK_TIME(FTM_RESIZE_WINDOW);
 		gGL.flush();
 		glClear(GL_COLOR_BUFFER_BIT);
 		gViewerWindow->getWindow()->swapBuffers();
@@ -314,7 +314,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	gViewerWindow->checkSettings();
 	
 	{
-		LLFastTimer ftm(FTM_PICK);
+		LL_RECORD_BLOCK_TIME(FTM_PICK);
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Pick");
 		gViewerWindow->performPick();
 	}
@@ -393,7 +393,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 	if (gTeleportDisplay)
 	{
-		LLFastTimer t(FTM_TELEPORT_DISPLAY);
+		LL_RECORD_BLOCK_TIME(FTM_TELEPORT_DISPLAY);
 		LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport");
 		static LLCachedControl<F32> teleport_arrival_delay(gSavedSettings, "TeleportArrivalDelay");
 		static LLCachedControl<F32> teleport_local_delay(gSavedSettings, "TeleportLocalDelay");
@@ -590,7 +590,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 	if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES))
 	{
 		LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures");
-		LLFastTimer t(FTM_UPDATE_TEXTURES);
+		LL_RECORD_BLOCK_TIME(FTM_UPDATE_TEXTURES);
 		if (LLViewerDynamicTexture::updateAllInstances())
 		{
 			gGL.setColorMask(true, true);
@@ -624,14 +624,14 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 				
 		// *TODO: merge these two methods
 		{
-			LLFastTimer t(FTM_HUD_UPDATE);
+			LL_RECORD_BLOCK_TIME(FTM_HUD_UPDATE);
 			LLHUDManager::getInstance()->updateEffects();
 			LLHUDObject::updateAll();
 			stop_glerror();
 		}
 
 		{
-			LLFastTimer t(FTM_DISPLAY_UPDATE_GEOM);
+			LL_RECORD_BLOCK_TIME(FTM_DISPLAY_UPDATE_GEOM);
 			const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds.value(); // 50 ms/second update time
 			gPipeline.createObjects(max_geom_update_time);
 			gPipeline.processPartitionQ();
@@ -770,10 +770,10 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages");
 		
 		{
-			LLFastTimer t(FTM_IMAGE_UPDATE);
+			LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE);
 			
 			{
-				LLFastTimer t(FTM_IMAGE_UPDATE_CLASS);
+				LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_CLASS);
 				LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat();
 				LLTrace::CountStatHandle<>* angular_velocity_stat = LLViewerCamera::getAngularVelocityStat();
 				LLViewerTexture::updateClass(LLTrace::get_frame_recording().getPeriodMeanPerSec(*velocity_stat),
@@ -782,19 +782,19 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 			
 			{
-				LLFastTimer t(FTM_IMAGE_UPDATE_BUMP);
+				LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_BUMP);
 				gBumpImageList.updateImages();  // must be called before gTextureList version so that it's textures are thrown out first.
 			}
 
 			{
-				LLFastTimer t(FTM_IMAGE_UPDATE_LIST);
+				LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_LIST);
 				F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds.value(); // 50 ms/second decode time
 				max_image_decode_time = llclamp(max_image_decode_time, 0.002f, 0.005f ); // min 2ms/frame, max 5ms/frame)
 				gTextureList.updateImages(max_image_decode_time);
 			}
 
 			/*{
-				LLFastTimer t(FTM_IMAGE_UPDATE_DELETE);
+				LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_DELETE);
 				//remove dead textures from GL
 				LLImageGL::deleteDeadTextures();
 				stop_glerror();
@@ -839,7 +839,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 
 		{
 			LLAppViewer::instance()->pingMainloopTimeout("Display:Sky");
-			LLFastTimer t(FTM_UPDATE_SKY);	
+			LL_RECORD_BLOCK_TIME(FTM_UPDATE_SKY);	
 			gSky.updateSky();
 		}
 
@@ -971,7 +971,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		}
 
 		{
-			LLFastTimer t(FTM_TEXTURE_UNBIND);
+			LL_RECORD_BLOCK_TIME(FTM_TEXTURE_UNBIND);
 			for (U32 i = 0; i < gGLManager.mNumTextureImageUnits; i++)
 			{ //dummy cleanup of any currently bound textures
 				if (gGL.getTexUnit(i)->getCurrType() != LLTexUnit::TT_NONE)
@@ -1027,7 +1027,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 		LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI");
 		if (!for_snapshot)
 		{
-			LLFastTimer t(FTM_RENDER_UI);
+			LL_RECORD_BLOCK_TIME(FTM_RENDER_UI);
 			render_ui();
 			swap();
 		}
@@ -1298,7 +1298,7 @@ void render_ui(F32 zoom_factor, int subfield)
 		gGL.color4f(1,1,1,1);
 		if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI))
 		{
-			LLFastTimer t(FTM_RENDER_UI);
+			LL_RECORD_BLOCK_TIME(FTM_RENDER_UI);
 
 			if (!gDisconnected)
 			{
@@ -1331,11 +1331,11 @@ void render_ui(F32 zoom_factor, int subfield)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_SWAP("Swap");
+static LLTrace::TimeBlock FTM_SWAP("Swap");
 
 void swap()
 {
-	LLFastTimer t(FTM_SWAP);
+	LL_RECORD_BLOCK_TIME(FTM_SWAP);
 
 	if (gDisplaySwapBuffers)
 	{
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index 76fb58b87b..deabc9c8b3 100755
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -376,7 +376,7 @@ void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32
 //-----------------------------------------------------------------------------
 // updateFaceData()
 //-----------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_AVATAR_FACE("Avatar Face");
+static LLTrace::TimeBlock FTM_AVATAR_FACE("Avatar Face");
 
 void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
 {
@@ -399,7 +399,7 @@ void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_w
 	}
 
 
-	LLFastTimer t(FTM_AVATAR_FACE);
+	LL_RECORD_BLOCK_TIME(FTM_AVATAR_FACE);
 
 	LLStrider<LLVector3> verticesp;
 	LLStrider<LLVector3> normalsp;
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index ba7fb4f985..868cb740dc 100755
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -776,19 +776,19 @@ static bool proximity_comparitor(const LLViewerMediaImpl* i1, const LLViewerMedi
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_MEDIA_UPDATE("Update Media");
-static LLFastTimer::DeclareTimer FTM_MEDIA_SPARE_IDLE("Spare Idle");
-static LLFastTimer::DeclareTimer FTM_MEDIA_UPDATE_INTEREST("Update/Interest");
-static LLFastTimer::DeclareTimer FTM_MEDIA_SORT("Sort");
-static LLFastTimer::DeclareTimer FTM_MEDIA_SORT2("Sort 2");
-static LLFastTimer::DeclareTimer FTM_MEDIA_MISC("Misc");
+static LLTrace::TimeBlock FTM_MEDIA_UPDATE("Update Media");
+static LLTrace::TimeBlock FTM_MEDIA_SPARE_IDLE("Spare Idle");
+static LLTrace::TimeBlock FTM_MEDIA_UPDATE_INTEREST("Update/Interest");
+static LLTrace::TimeBlock FTM_MEDIA_SORT("Sort");
+static LLTrace::TimeBlock FTM_MEDIA_SORT2("Sort 2");
+static LLTrace::TimeBlock FTM_MEDIA_MISC("Misc");
 
 
 //////////////////////////////////////////////////////////////////////////////////////////
 // static
 void LLViewerMedia::updateMedia(void *dummy_arg)
 {
-	LLFastTimer t1(FTM_MEDIA_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_MEDIA_UPDATE);
 	
 	// Enable/disable the plugin read thread
 	LLPluginProcessParent::setUseReadThread(gSavedSettings.getBOOL("PluginUseReadThread"));
@@ -808,7 +808,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	impl_list::iterator end = sViewerMediaImplList.end();
 
 	{
-		LLFastTimer t(FTM_MEDIA_UPDATE_INTEREST);
+		LL_RECORD_BLOCK_TIME(FTM_MEDIA_UPDATE_INTEREST);
 		for(; iter != end;)
 		{
 			LLViewerMediaImpl* pimpl = *iter++;
@@ -820,12 +820,12 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	// Let the spare media source actually launch
 	if(sSpareBrowserMediaSource)
 	{
-		LLFastTimer t(FTM_MEDIA_SPARE_IDLE);
+		LL_RECORD_BLOCK_TIME(FTM_MEDIA_SPARE_IDLE);
 		sSpareBrowserMediaSource->idle();
 	}
 		
 	{
-		LLFastTimer t(FTM_MEDIA_SORT);
+		LL_RECORD_BLOCK_TIME(FTM_MEDIA_SORT);
 		// Sort the static instance list using our interest criteria
 		sViewerMediaImplList.sort(priorityComparitor);
 	}
@@ -857,7 +857,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	// If max_normal + max_low is less than max_instances, things will tend to get unloaded instead of being set to slideshow.
 	
 	{
-		LLFastTimer t(FTM_MEDIA_MISC);
+		LL_RECORD_BLOCK_TIME(FTM_MEDIA_MISC);
 		for(; iter != end; iter++)
 		{
 			LLViewerMediaImpl* pimpl = *iter;
@@ -1025,7 +1025,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	}
 	else
 	{
-		LLFastTimer t(FTM_MEDIA_SORT2);
+		LL_RECORD_BLOCK_TIME(FTM_MEDIA_SORT2);
 		// Use a distance-based sort for proximity values.  
 		std::stable_sort(proximity_order.begin(), proximity_order.end(), proximity_comparitor);
 	}
@@ -2746,14 +2746,14 @@ bool LLViewerMediaImpl::canNavigateBack()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-static LLFastTimer::DeclareTimer FTM_MEDIA_DO_UPDATE("Do Update");
-static LLFastTimer::DeclareTimer FTM_MEDIA_GET_DATA("Get Data");
-static LLFastTimer::DeclareTimer FTM_MEDIA_SET_SUBIMAGE("Set Subimage");
+static LLTrace::TimeBlock FTM_MEDIA_DO_UPDATE("Do Update");
+static LLTrace::TimeBlock FTM_MEDIA_GET_DATA("Get Data");
+static LLTrace::TimeBlock FTM_MEDIA_SET_SUBIMAGE("Set Subimage");
 
 
 void LLViewerMediaImpl::update()
 {
-	LLFastTimer t(FTM_MEDIA_DO_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_MEDIA_DO_UPDATE);
 	if(mMediaSource == NULL)
 	{
 		if(mPriority == LLPluginClassMedia::PRIORITY_UNLOADED)
@@ -2855,7 +2855,7 @@ void LLViewerMediaImpl::update()
 
 				U8* data = NULL;
 				{
-					LLFastTimer t(FTM_MEDIA_GET_DATA);
+					LL_RECORD_BLOCK_TIME(FTM_MEDIA_GET_DATA);
 					data = mMediaSource->getBitsData();
 				}
 
@@ -2864,7 +2864,7 @@ void LLViewerMediaImpl::update()
 				data += ( y_pos * mMediaSource->getTextureDepth() );
 				
 				{
-					LLFastTimer t(FTM_MEDIA_SET_SUBIMAGE);
+					LL_RECORD_BLOCK_TIME(FTM_MEDIA_SET_SUBIMAGE);
 					placeholder_image->setSubImage(
 							data, 
 							mMediaSource->getBitsWidth(), 
@@ -3435,11 +3435,11 @@ BOOL LLViewerMediaImpl::isUpdated()
 	return mIsUpdated ;
 }
 
-static LLFastTimer::DeclareTimer FTM_MEDIA_CALCULATE_INTEREST("Calculate Interest");
+static LLTrace::TimeBlock FTM_MEDIA_CALCULATE_INTEREST("Calculate Interest");
 
 void LLViewerMediaImpl::calculateInterest()
 {
-	LLFastTimer t(FTM_MEDIA_CALCULATE_INTEREST);
+	LL_RECORD_BLOCK_TIME(FTM_MEDIA_CALCULATE_INTEREST);
 	LLViewerMediaTexture* texture = LLViewerTextureManager::findMediaTexture( mTextureId );
 	
 	if(texture != NULL)
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 7de8e1ff12..c70efd9dfa 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4237,7 +4237,7 @@ const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f;	// ~= 2.5 degrees -- if its less th
 const F32 MAX_HEAD_ROT_QDOT = 0.99999f;			// ~= 0.5 degrees -- if its greater than this then no need to update head_rot
 												// between these values we delay the updates (but no more than one second)
 
-static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE_SEND("Send Message");
+static LLTrace::TimeBlock FTM_AGENT_UPDATE_SEND("Send Message");
 
 void send_agent_update(BOOL force_send, BOOL send_reliable)
 {
@@ -4421,7 +4421,7 @@ void send_agent_update(BOOL force_send, BOOL send_reliable)
 		}
 		*/
 
-		LLFastTimer t(FTM_AGENT_UPDATE_SEND);
+		LL_RECORD_BLOCK_TIME(FTM_AGENT_UPDATE_SEND);
 		// Build the message
 		msg->newMessageFast(_PREHASH_AgentUpdate);
 		msg->nextBlockFast(_PREHASH_AgentData);
@@ -4552,14 +4552,14 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 	gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
 }
 
-static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Kill Objects");
+static LLTrace::TimeBlock FTM_PROCESS_OBJECTS("Process Kill Objects");
 
 const U32 KILLOBJECT_DELETE_OPCODE = 0;
 
 
 void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 {
-	LLFastTimer t(FTM_PROCESS_OBJECTS);
+	LL_RECORD_BLOCK_TIME(FTM_PROCESS_OBJECTS);
 
 	LLUUID		id;
 
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 9235f23a8c..2c1ab3a73b 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -112,7 +112,7 @@ BOOL		LLViewerObject::sMapDebug = TRUE;
 LLColor4	LLViewerObject::sEditSelectColor(	1.0f, 1.f, 0.f, 0.3f);	// Edit OK
 LLColor4	LLViewerObject::sNoEditSelectColor(	1.0f, 0.f, 0.f, 0.3f);	// Can't edit
 S32			LLViewerObject::sAxisArrowLength(50);
-LLTrace::MemStatHandle	LLViewerObject::sMemStat("LLViewerObject");
+//LLTrace::MemStatHandle	LLViewerObject::sMemStat("LLViewerObject");
 
 
 BOOL		LLViewerObject::sPulseEnabled(FALSE);
@@ -133,13 +133,13 @@ std::map<std::string, U32> LLViewerObject::sObjectDataMap;
 
 const F32 PHYSICS_TIMESTEP = 1.f / 45.f;
 
-static LLFastTimer::DeclareTimer FTM_CREATE_OBJECT("Create Object");
+static LLTrace::TimeBlock FTM_CREATE_OBJECT("Create Object");
 
 // static
 LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
 {
 	LLViewerObject *res = NULL;
-	LLFastTimer t1(FTM_CREATE_OBJECT);
+	LL_RECORD_BLOCK_TIME(FTM_CREATE_OBJECT);
 	
 	switch (pcode)
 	{
@@ -2407,8 +2407,8 @@ void LLViewerObject::loadFlags(U32 flags)
 
 void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
-	//static LLFastTimer::DeclareTimer ftm("Viewer Object");
-	//LLFastTimer t(ftm);
+	//static LLTrace::TimeBlock ftm("Viewer Object");
+	//LL_RECORD_BLOCK_TIME(ftm);
 
 	if (!mDead)
 	{
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 24dff45ae8..e3972ccae8 100755
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -661,7 +661,7 @@ public:
 	LLPointer<class LLHUDIcon> mIcon;
 
 	static			BOOL		sUseSharedDrawables;
-	static	LLTrace::MemStatHandle	sMemStat;
+	//static	LLTrace::MemStatHandle	sMemStat;
 
 protected:
 	// delete an item in the inventory, but don't tell the
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 897da7f0b3..686eff8426 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -289,7 +289,7 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp,
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Objects");
+static LLTrace::TimeBlock FTM_PROCESS_OBJECTS("Process Objects");
 
 LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry* entry, LLViewerRegion* regionp)
 {
@@ -386,7 +386,7 @@ void LLViewerObjectList::processObjectUpdate(LLMessageSystem *mesgsys,
 											 const EObjectUpdateType update_type,
 											 bool compressed)
 {
-	LLFastTimer t(FTM_PROCESS_OBJECTS);	
+	LL_RECORD_BLOCK_TIME(FTM_PROCESS_OBJECTS);	
 	
 	LLViewerObject *objectp;
 	S32			num_objects;
@@ -978,7 +978,7 @@ private:
 	LLSD mObjectIDs;
 };
 
-static LLFastTimer::DeclareTimer FTM_IDLE_COPY("Idle Copy");
+static LLTrace::TimeBlock FTM_IDLE_COPY("Idle Copy");
 
 void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 {
@@ -1031,7 +1031,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 	U32 idle_count = 0;
 	
 	{
-		LLFastTimer t(FTM_IDLE_COPY);
+		LL_RECORD_BLOCK_TIME(FTM_IDLE_COPY);
 
  		for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
 			active_iter != mActiveObjects.end(); active_iter++)
@@ -1328,11 +1328,11 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 	mNumDeadObjects++;
 }
 
-static LLFastTimer::DeclareTimer FTM_REMOVE_DRAWABLE("Remove Drawable");
+static LLTrace::TimeBlock FTM_REMOVE_DRAWABLE("Remove Drawable");
 
 void LLViewerObjectList::removeDrawable(LLDrawable* drawablep)
 {
-	LLFastTimer t(FTM_REMOVE_DRAWABLE);
+	LL_RECORD_BLOCK_TIME(FTM_REMOVE_DRAWABLE);
 
 	if (!drawablep)
 	{
@@ -1617,9 +1617,9 @@ void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id)
 	mPendingPhysicsFlags.erase(object_id);
 }
 
-static LLFastTimer::DeclareTimer FTM_SHIFT_OBJECTS("Shift Objects");
-static LLFastTimer::DeclareTimer FTM_PIPELINE_SHIFT("Pipeline Shift");
-static LLFastTimer::DeclareTimer FTM_REGION_SHIFT("Region Shift");
+static LLTrace::TimeBlock FTM_SHIFT_OBJECTS("Shift Objects");
+static LLTrace::TimeBlock FTM_PIPELINE_SHIFT("Pipeline Shift");
+static LLTrace::TimeBlock FTM_REGION_SHIFT("Region Shift");
 
 void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 {
@@ -1632,7 +1632,7 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 		return;
 	}
 
-	LLFastTimer t(FTM_SHIFT_OBJECTS);
+	LL_RECORD_BLOCK_TIME(FTM_SHIFT_OBJECTS);
 
 	LLViewerObject *objectp;
 	for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
@@ -1651,12 +1651,12 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 	}
 
 	{
-		LLFastTimer t(FTM_PIPELINE_SHIFT);
+		LL_RECORD_BLOCK_TIME(FTM_PIPELINE_SHIFT);
 	gPipeline.shiftObjects(offset);
 	}
 
 	{
-		LLFastTimer t(FTM_REGION_SHIFT);
+		LL_RECORD_BLOCK_TIME(FTM_REGION_SHIFT);
 	LLWorld::getInstance()->shiftRegions(offset);
 }
 }
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 481befdb44..1e01c0fdef 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -983,8 +983,8 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_READBACK("Readback Occlusion");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_WAIT("Occlusion Wait");
+static LLTrace::TimeBlock FTM_OCCLUSION_READBACK("Readback Occlusion");
+static LLTrace::TimeBlock FTM_OCCLUSION_WAIT("Occlusion Wait");
 
 BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds)
 {
@@ -1038,7 +1038,7 @@ void LLOcclusionCullingGroup::checkOcclusion()
 {
 	if (LLPipeline::sUseOcclusion > 1)
 	{
-		LLFastTimer t(FTM_OCCLUSION_READBACK);
+		LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_READBACK);
 		LLOcclusionCullingGroup* parent = (LLOcclusionCullingGroup*)getParent();
 		if (parent && parent->isOcclusionState(LLOcclusionCullingGroup::OCCLUDED))
 		{	//if the parent has been marked as occluded, the child is implicitly occluded
@@ -1057,7 +1057,7 @@ void LLOcclusionCullingGroup::checkOcclusion()
 				if (wait_for_query && mOcclusionIssued[LLViewerCamera::sCurCameraID] < gFrameCount)
 				{ //query was issued last frame, wait until it's available
 					S32 max_loop = 1024;
-					LLFastTimer t(FTM_OCCLUSION_WAIT);
+					LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_WAIT);
 					while (!available && max_loop-- > 0)
 					{
 						//do some usefu work while we wait
@@ -1121,16 +1121,16 @@ void LLOcclusionCullingGroup::checkOcclusion()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_PUSH_OCCLUSION_VERTS("Push Occlusion");
-static LLFastTimer::DeclareTimer FTM_SET_OCCLUSION_STATE("Occlusion State");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_ALLOCATE("Allocate");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_BUILD("Build");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_BEGIN_QUERY("Begin Query");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_END_QUERY("End Query");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_SET_BUFFER("Set Buffer");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW_WATER("Draw Water");
-static LLFastTimer::DeclareTimer FTM_OCCLUSION_DRAW("Draw");
+static LLTrace::TimeBlock FTM_PUSH_OCCLUSION_VERTS("Push Occlusion");
+static LLTrace::TimeBlock FTM_SET_OCCLUSION_STATE("Occlusion State");
+static LLTrace::TimeBlock FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail");
+static LLTrace::TimeBlock FTM_OCCLUSION_ALLOCATE("Allocate");
+static LLTrace::TimeBlock FTM_OCCLUSION_BUILD("Build");
+static LLTrace::TimeBlock FTM_OCCLUSION_BEGIN_QUERY("Begin Query");
+static LLTrace::TimeBlock FTM_OCCLUSION_END_QUERY("End Query");
+static LLTrace::TimeBlock FTM_OCCLUSION_SET_BUFFER("Set Buffer");
+static LLTrace::TimeBlock FTM_OCCLUSION_DRAW_WATER("Draw Water");
+static LLTrace::TimeBlock FTM_OCCLUSION_DRAW("Draw");
 
 void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* region_agent)
 {
@@ -1150,7 +1150,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg
 		// Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension
 		if (earlyFail(camera, bounds))
 		{
-			LLFastTimer t(FTM_OCCLUSION_EARLY_FAIL);
+			LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_EARLY_FAIL);
 			setOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY);
 			assert_states_valid(this);
 			clearOcclusionState(LLOcclusionCullingGroup::OCCLUDED, LLOcclusionCullingGroup::STATE_MODE_DIFF);
@@ -1161,11 +1161,11 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg
 			if (!isOcclusionState(QUERY_PENDING) || isOcclusionState(DISCARD_QUERY))
 			{
 				{ //no query pending, or previous query to be discarded
-					LLFastTimer t(FTM_RENDER_OCCLUSION);
+					LL_RECORD_BLOCK_TIME(FTM_RENDER_OCCLUSION);
 
 					if (!mOcclusionQuery[LLViewerCamera::sCurCameraID])
 					{
-						LLFastTimer t(FTM_OCCLUSION_ALLOCATE);
+						LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_ALLOCATE);
 						mOcclusionQuery[LLViewerCamera::sCurCameraID] = getNewOcclusionQueryObjectName();
 					}
 
@@ -1189,13 +1189,13 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg
 #endif
 
 					{
-						LLFastTimer t(FTM_PUSH_OCCLUSION_VERTS);
+						LL_RECORD_BLOCK_TIME(FTM_PUSH_OCCLUSION_VERTS);
 						
 						//store which frame this query was issued on
 						mOcclusionIssued[LLViewerCamera::sCurCameraID] = gFrameCount;
 
 						{
-							LLFastTimer t(FTM_OCCLUSION_BEGIN_QUERY);
+							LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_BEGIN_QUERY);
 							glBeginQueryARB(mode, mOcclusionQuery[LLViewerCamera::sCurCameraID]);					
 						}
 					
@@ -1209,7 +1209,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg
 
 						if (!use_depth_clamp && mSpatialPartition->mDrawableType == LLDrawPool::POOL_VOIDWATER)
 						{
-							LLFastTimer t(FTM_OCCLUSION_DRAW_WATER);
+							LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_DRAW_WATER);
 
 							LLGLSquashToFarClip squash(glh_get_current_projection(), 1);
 							if (camera->getOrigin().isExactlyZero())
@@ -1224,7 +1224,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg
 						}
 						else
 						{
-							LLFastTimer t(FTM_OCCLUSION_DRAW);
+							LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_DRAW);
 							if (camera->getOrigin().isExactlyZero())
 							{ //origin is invalid, draw entire box
 								gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0);
@@ -1238,14 +1238,14 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg
 
 
 						{
-							LLFastTimer t(FTM_OCCLUSION_END_QUERY);
+							LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_END_QUERY);
 							glEndQueryARB(mode);
 						}
 					}
 				}
 
 				{
-					LLFastTimer t(FTM_SET_OCCLUSION_STATE);
+					LL_RECORD_BLOCK_TIME(FTM_SET_OCCLUSION_STATE);
 					setOcclusionState(LLOcclusionCullingGroup::QUERY_PENDING);
 					clearOcclusionState(LLOcclusionCullingGroup::DISCARD_QUERY);
 				}
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index e610db96eb..342d149491 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -210,15 +210,15 @@ 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);
-	}
+	//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);
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 09b6b8eb4b..eb89a887ac 100755
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -631,7 +631,7 @@ void LLViewerPartSim::shift(const LLVector3 &offset)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_SIMULATE_PARTICLES("Simulate Particles");
+static LLTrace::TimeBlock FTM_SIMULATE_PARTICLES("Simulate Particles");
 
 void LLViewerPartSim::updateSimulation()
 {
@@ -644,7 +644,7 @@ void LLViewerPartSim::updateSimulation()
 		return;
 	}
 
-	LLFastTimer ftm(FTM_SIMULATE_PARTICLES);
+	LL_RECORD_BLOCK_TIME(FTM_SIMULATE_PARTICLES);
 
 	// Start at a random particle system so the same
 	// particle system doesn't always get first pick at the
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 8cb35cd30b..09bf022008 100755
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -455,7 +455,7 @@ const S32 min_non_tex_system_mem = (128<<20); // 128 MB
 F32 texmem_lower_bound_scale = 0.85f;
 F32 texmem_middle_bound_scale = 0.925f;
 
-static LLFastTimer::DeclareTimer FTM_TEXTURE_MEMORY_CHECK("Memory Check");
+static LLTrace::TimeBlock FTM_TEXTURE_MEMORY_CHECK("Memory Check");
 
 //static 
 bool LLViewerTexture::isMemoryForTextureLow()
@@ -469,7 +469,7 @@ bool LLViewerTexture::isMemoryForTextureLow()
 	}
 	timer.reset();
 
-	LLFastTimer t(FTM_TEXTURE_MEMORY_CHECK);
+	LL_RECORD_BLOCK_TIME(FTM_TEXTURE_MEMORY_CHECK);
 
 	const S32Megabytes MIN_FREE_TEXTURE_MEMORY(5); //MB
 	const S32Megabytes MIN_FREE_MAIN_MEMORY(100); //MB	
@@ -510,8 +510,8 @@ bool LLViewerTexture::isMemoryForTextureLow()
 	return low_mem;
 }
 
-static LLFastTimer::DeclareTimer FTM_TEXTURE_UPDATE_MEDIA("Media");
-static LLFastTimer::DeclareTimer FTM_TEXTURE_UPDATE_TEST("Test");
+static LLTrace::TimeBlock FTM_TEXTURE_UPDATE_MEDIA("Media");
+static LLTrace::TimeBlock FTM_TEXTURE_UPDATE_TEST("Test");
 
 //static
 void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity)
@@ -521,12 +521,12 @@ void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity
 	LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName);
 	if (tester)
 	{
-		LLFastTimer t(FTM_TEXTURE_UPDATE_TEST);
+		LL_RECORD_BLOCK_TIME(FTM_TEXTURE_UPDATE_TEST);
 		tester->update();
 	}
 
 	{
-		LLFastTimer t(FTM_TEXTURE_UPDATE_MEDIA);
+		LL_RECORD_BLOCK_TIME(FTM_TEXTURE_UPDATE_MEDIA);
 		LLViewerMediaTexture::updateClass();
 	}
 
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index cb7ea1f637..4958c38c4e 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -68,7 +68,7 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
 S32 LLViewerTextureList::sNumImages = 0;
 
 LLViewerTextureList gTextureList;
-static LLFastTimer::DeclareTimer FTM_PROCESS_IMAGES("Process Images");
+static LLTrace::TimeBlock FTM_PROCESS_IMAGES("Process Images");
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -638,18 +638,18 @@ void LLViewerTextureList::dirtyImage(LLViewerFetchedTexture *image)
 }
 
 ////////////////////////////////////////////////////////////////////////////
-static LLFastTimer::DeclareTimer FTM_IMAGE_MARK_DIRTY("Dirty Images");
-static LLFastTimer::DeclareTimer FTM_IMAGE_UPDATE_PRIORITIES("Prioritize");
-static LLFastTimer::DeclareTimer FTM_IMAGE_CALLBACKS("Callbacks");
-static LLFastTimer::DeclareTimer FTM_IMAGE_FETCH("Fetch");
-static LLFastTimer::DeclareTimer FTM_FAST_CACHE_IMAGE_FETCH("Fast Cache Fetch");
-static LLFastTimer::DeclareTimer FTM_IMAGE_CREATE("Create");
-static LLFastTimer::DeclareTimer FTM_IMAGE_STATS("Stats");
-static LLFastTimer::DeclareTimer FTM_UPDATE_IMAGES("Update Images");
+static LLTrace::TimeBlock FTM_IMAGE_MARK_DIRTY("Dirty Images");
+static LLTrace::TimeBlock FTM_IMAGE_UPDATE_PRIORITIES("Prioritize");
+static LLTrace::TimeBlock FTM_IMAGE_CALLBACKS("Callbacks");
+static LLTrace::TimeBlock FTM_IMAGE_FETCH("Fetch");
+static LLTrace::TimeBlock FTM_FAST_CACHE_IMAGE_FETCH("Fast Cache Fetch");
+static LLTrace::TimeBlock FTM_IMAGE_CREATE("Create");
+static LLTrace::TimeBlock FTM_IMAGE_STATS("Stats");
+static LLTrace::TimeBlock FTM_UPDATE_IMAGES("Update Images");
 
 void LLViewerTextureList::updateImages(F32 max_time)
 {
-	LLFastTimer _(FTM_UPDATE_IMAGES);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_IMAGES);
 	static BOOL cleared = FALSE;
 	if(gTeleportDisplay)
 	{
@@ -677,37 +677,37 @@ void LLViewerTextureList::updateImages(F32 max_time)
 
 	{
 		//loading from fast cache 
-		LLFastTimer t(FTM_FAST_CACHE_IMAGE_FETCH);
+		LL_RECORD_BLOCK_TIME(FTM_FAST_CACHE_IMAGE_FETCH);
 		max_time -= updateImagesLoadingFastCache(max_time);
 	}
 
 	{
-		LLFastTimer t(FTM_IMAGE_UPDATE_PRIORITIES);
+		LL_RECORD_BLOCK_TIME(FTM_IMAGE_UPDATE_PRIORITIES);
 		updateImagesDecodePriorities();
 	}
 
 	F32 total_max_time = max_time;
 
 	{
-		LLFastTimer t(FTM_IMAGE_FETCH);
+		LL_RECORD_BLOCK_TIME(FTM_IMAGE_FETCH);
 		max_time -= updateImagesFetchTextures(max_time);
 	}
 	
 	{
-		LLFastTimer t(FTM_IMAGE_CREATE);
+		LL_RECORD_BLOCK_TIME(FTM_IMAGE_CREATE);
 		max_time = llmax(max_time, total_max_time*.50f); // at least 50% of max_time
 		max_time -= updateImagesCreateTextures(max_time);
 	}
 	
 	if (!mDirtyTextureList.empty())
 	{
-		LLFastTimer t(FTM_IMAGE_MARK_DIRTY);
+		LL_RECORD_BLOCK_TIME(FTM_IMAGE_MARK_DIRTY);
 		gPipeline.dirtyPoolObjectTextures(mDirtyTextureList);
 		mDirtyTextureList.clear();
 	}
 
 	{
-		LLFastTimer t(FTM_IMAGE_CALLBACKS);
+		LL_RECORD_BLOCK_TIME(FTM_IMAGE_CALLBACKS);
 		bool didone = false;
 		for (image_list_t::iterator iter = mCallbackList.begin();
 			iter != mCallbackList.end(); )
@@ -728,7 +728,7 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	}
 
 	{
-		LLFastTimer t(FTM_IMAGE_STATS);
+		LL_RECORD_BLOCK_TIME(FTM_IMAGE_STATS);
 		updateImagesUpdateStats();
 	}
 }
@@ -1360,7 +1360,7 @@ void LLViewerTextureList::receiveImageHeader(LLMessageSystem *msg, void **user_d
 {
 	static LLCachedControl<bool> log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ;
 
-	LLFastTimer t(FTM_PROCESS_IMAGES);
+	LL_RECORD_BLOCK_TIME(FTM_PROCESS_IMAGES);
 	
 	// Receive image header, copy into image object and decompresses 
 	// if this is a one-packet image. 
@@ -1432,7 +1432,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 {
 	static LLCachedControl<bool> log_texture_traffic(gSavedSettings,"LogTextureNetworkTraffic") ;
 
-	LLFastTimer t(FTM_PROCESS_IMAGES);
+	LL_RECORD_BLOCK_TIME(FTM_PROCESS_IMAGES);
 	
 	// Receives image packet, copy into image object,
 	// checks if all packets received, decompresses if so. 
@@ -1505,7 +1505,7 @@ void LLViewerTextureList::receiveImagePacket(LLMessageSystem *msg, void **user_d
 // static
 void LLViewerTextureList::processImageNotInDatabase(LLMessageSystem *msg,void **user_data)
 {
-	LLFastTimer t(FTM_PROCESS_IMAGES);
+	LL_RECORD_BLOCK_TIME(FTM_PROCESS_IMAGES);
 	LLUUID image_id;
 	msg->getUUIDFast(_PREHASH_ImageID, _PREHASH_ID, image_id);
 	
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 3a62ab68a0..ee4972e13b 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -2796,13 +2796,13 @@ void append_xui_tooltip(LLView* viewp, LLToolTip::Params& params)
 	}
 }
 
-static LLFastTimer::DeclareTimer ftm("Update UI");
+static LLTrace::TimeBlock ftm("Update UI");
 
 // Update UI based on stored mouse position from mouse-move
 // event processing.
 void LLViewerWindow::updateUI()
 {
-	LLFastTimer t(ftm);
+	LL_RECORD_BLOCK_TIME(ftm);
 
 	static std::string last_handle_msg;
 
@@ -3374,10 +3374,10 @@ void LLViewerWindow::updateKeyboardFocus()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_WORLD_VIEW("Update World View");
+static LLTrace::TimeBlock FTM_UPDATE_WORLD_VIEW("Update World View");
 void LLViewerWindow::updateWorldViewRect(bool use_full_window)
 {
-	LLFastTimer ft(FTM_UPDATE_WORLD_VIEW);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_WORLD_VIEW);
 
 	// start off using whole window to render world
 	LLRect new_world_rect = mWindowRectRaw;
@@ -4871,11 +4871,11 @@ void LLViewerWindow::requestResolutionUpdate()
 	mResDirty = true;
 }
 
-static LLFastTimer::DeclareTimer FTM_WINDOW_CHECK_SETTINGS("Window Settings");
+static LLTrace::TimeBlock FTM_WINDOW_CHECK_SETTINGS("Window Settings");
 
 void LLViewerWindow::checkSettings()
 {
-	LLFastTimer t(FTM_WINDOW_CHECK_SETTINGS);
+	LL_RECORD_BLOCK_TIME(FTM_WINDOW_CHECK_SETTINGS);
 	if (mStatesDirty)
 	{
 		gGL.refreshState();
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 724ba3c85e..1b5b83aa39 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1918,8 +1918,8 @@ S32 LLVOAvatar::setTETexture(const U8 te, const LLUUID& uuid)
 	return setTETextureCore(te, image);
 }
 
-static LLFastTimer::DeclareTimer FTM_AVATAR_UPDATE("Avatar Update");
-static LLFastTimer::DeclareTimer FTM_JOINT_UPDATE("Update Joints");
+static LLTrace::TimeBlock FTM_AVATAR_UPDATE("Avatar Update");
+static LLTrace::TimeBlock FTM_JOINT_UPDATE("Update Joints");
 
 //------------------------------------------------------------------------
 // LLVOAvatar::dumpAnimationState()
@@ -1953,7 +1953,7 @@ void LLVOAvatar::dumpAnimationState()
 //------------------------------------------------------------------------
 void LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
-	LLFastTimer t(FTM_AVATAR_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_AVATAR_UPDATE);
 
 	if (isDead())
 	{
@@ -1975,7 +1975,7 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 	// force asynchronous drawable update
 	if(mDrawable.notNull())
 	{	
-		LLFastTimer t(FTM_JOINT_UPDATE);
+		LL_RECORD_BLOCK_TIME(FTM_JOINT_UPDATE);
 	
 		if (mIsSitting && getParent())
 		{
@@ -2158,7 +2158,7 @@ void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled)
 	}//if ( voiceEnabled )
 }		
 
-static LLFastTimer::DeclareTimer FTM_ATTACHMENT_UPDATE("Update Attachments");
+static LLTrace::TimeBlock FTM_ATTACHMENT_UPDATE("Update Attachments");
 
 void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 {
@@ -2175,7 +2175,7 @@ void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 	// update attachments positions
 	if (detailed_update || !sUseImpostors)
 	{
-		LLFastTimer t(FTM_ATTACHMENT_UPDATE);
+		LL_RECORD_BLOCK_TIME(FTM_ATTACHMENT_UPDATE);
 		for (attachment_map_t::iterator iter = mAttachmentPoints.begin(); 
 			 iter != mAttachmentPoints.end();
 			 ++iter)
@@ -5334,10 +5334,10 @@ void LLVOAvatar::updateGL()
 //-----------------------------------------------------------------------------
 // updateGeometry()
 //-----------------------------------------------------------------------------
-static LLFastTimer::DeclareTimer FTM_UPDATE_AVATAR("Update Avatar");
+static LLTrace::TimeBlock FTM_UPDATE_AVATAR("Update Avatar");
 BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer ftm(FTM_UPDATE_AVATAR);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_AVATAR);
  	if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_AVATAR)))
 	{
 		return TRUE;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 1cfda038a8..3c09981f7d 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -38,7 +38,7 @@
 F32 LLVOCacheEntry::sBackDistanceSquared = 0.f;
 F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f;
 BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE;
-LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
+//LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 52b25b7f91..1fa019cfa6 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -37,7 +37,9 @@
 // Cache entries
 class LLCamera;
 
-class LLVOCacheEntry : public LLViewerOctreeEntryData
+class LLVOCacheEntry 
+:	public LLViewerOctreeEntryData,
+	public LLTrace::MemTrackable<LLVOCacheEntry, 16>
 {
 public:
 	enum //low 16-bit state
@@ -174,7 +176,7 @@ public:
 
 public:
 	static BOOL sNeedsOcclusionCheck;
-	static	LLTrace::MemStatHandle	sMemStat;
+	//static	LLTrace::MemStatHandle	sMemStat;
 
 private:
 	BOOL  mDirty;
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index a60d8a2284..1abb081e73 100755
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -412,11 +412,11 @@ LLDrawable* LLVOGrass::createDrawable(LLPipeline *pipeline)
 	return mDrawable;
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_GRASS("Update Grass");
+static LLTrace::TimeBlock FTM_UPDATE_GRASS("Update Grass");
 
 BOOL LLVOGrass::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer ftm(FTM_UPDATE_GRASS);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_GRASS);
 
 	dirtySpatialGroup();
 
@@ -670,11 +670,11 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_GRASS_VB("Grass VB");
+static LLTrace::TimeBlock FTM_REBUILD_GRASS_VB("Grass VB");
 
 void LLGrassPartition::getGeometry(LLSpatialGroup* group)
 {
-	LLFastTimer ftm(FTM_REBUILD_GRASS_VB);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_GRASS_VB);
 
 	std::sort(mFaceList.begin(), mFaceList.end(), LLFace::CompareDistanceGreater());
 
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 6ff849cfd2..f7224684bb 100755
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -6314,7 +6314,7 @@ LLVivoxProtocolParser::~LLVivoxProtocolParser()
 		XML_ParserFree(parser);
 }
 
-static LLFastTimer::DeclareTimer FTM_VIVOX_PROCESS("Vivox Process");
+static LLTrace::TimeBlock FTM_VIVOX_PROCESS("Vivox Process");
 
 // virtual
 LLIOPipe::EStatus LLVivoxProtocolParser::process_impl(
@@ -6324,7 +6324,7 @@ LLIOPipe::EStatus LLVivoxProtocolParser::process_impl(
 													  LLSD& context,
 													  LLPumpIO* pump)
 {
-	LLFastTimer t(FTM_VIVOX_PROCESS);
+	LL_RECORD_BLOCK_TIME(FTM_VIVOX_PROCESS);
 	LLBufferStream istr(channels, buffer.get());
 	std::ostringstream ostr;
 	while (istr.good())
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 6402a484ec..3c93460d33 100755
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -286,10 +286,10 @@ LLVector3 LLVOPartGroup::getCameraPosition() const
 	return gAgentCamera.getCameraPositionAgent();
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_PARTICLES("Update Particles");
+static LLTrace::TimeBlock FTM_UPDATE_PARTICLES("Update Particles");
 BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer ftm(FTM_UPDATE_PARTICLES);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_PARTICLES);
 
 	dirtySpatialGroup();
 	
@@ -611,7 +611,7 @@ LLHUDParticlePartition::LLHUDParticlePartition(LLViewerRegion* regionp) :
 	mPartitionType = LLViewerRegion::PARTITION_HUD_PARTICLE;
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_PARTICLE_VBO("Particle VBO");
+static LLTrace::TimeBlock FTM_REBUILD_PARTICLE_VBO("Particle VBO");
 
 void LLParticlePartition::rebuildGeom(LLSpatialGroup* group)
 {
@@ -626,7 +626,7 @@ void LLParticlePartition::rebuildGeom(LLSpatialGroup* group)
 		group->mLastUpdateViewAngle = group->mViewAngle;
 	}
 	
-	LLFastTimer ftm(FTM_REBUILD_PARTICLE_VBO);	
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_PARTICLE_VBO);	
 
 	group->clearDrawMap();
 	
@@ -700,11 +700,11 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
 }
 
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_PARTICLE_GEOM("Particle Geom");
+static LLTrace::TimeBlock FTM_REBUILD_PARTICLE_GEOM("Particle Geom");
 
 void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 {
-	LLFastTimer ftm(FTM_REBUILD_PARTICLE_GEOM);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_PARTICLE_GEOM);
 
 	std::sort(mFaceList.begin(), mFaceList.end(), LLFace::CompareDistanceGreater());
 
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 85e8fd8bf4..00e52531d6 100755
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -1243,7 +1243,7 @@ void LLVOSky::createDummyVertexBuffer()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_FAKE_VBO_UPDATE("Fake VBO Update");
+static LLTrace::TimeBlock FTM_RENDER_FAKE_VBO_UPDATE("Fake VBO Update");
 
 void LLVOSky::updateDummyVertexBuffer()
 {	
@@ -1256,7 +1256,7 @@ void LLVOSky::updateDummyVertexBuffer()
 		return ;
 	}
 
-	LLFastTimer t(FTM_RENDER_FAKE_VBO_UPDATE) ;
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_FAKE_VBO_UPDATE) ;
 
 	if(!mFace[FACE_DUMMY] || !mFace[FACE_DUMMY]->getVertexBuffer())
 		createDummyVertexBuffer() ;
@@ -1269,11 +1269,11 @@ void LLVOSky::updateDummyVertexBuffer()
 //----------------------------------
 //end of fake vertex buffer updating
 //----------------------------------
-static LLFastTimer::DeclareTimer FTM_GEO_SKY("Sky Geometry");
+static LLTrace::TimeBlock FTM_GEO_SKY("Sky Geometry");
 
 BOOL LLVOSky::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer ftm(FTM_GEO_SKY);
+	LL_RECORD_BLOCK_TIME(FTM_GEO_SKY);
 	if (mFace[FACE_REFLECTION] == NULL)
 	{
 		LLDrawPoolWater *poolp = (LLDrawPoolWater*) gPipeline.getPool(LLDrawPool::POOL_WATER);
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index 178542cc88..c77ba26ba3 100755
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -212,7 +212,7 @@ LLDrawable *LLVOSurfacePatch::createDrawable(LLPipeline *pipeline)
 	return mDrawable;
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_TERRAIN("Update Terrain");
+static LLTrace::TimeBlock FTM_UPDATE_TERRAIN("Update Terrain");
 
 void LLVOSurfacePatch::updateGL()
 {
@@ -224,7 +224,7 @@ void LLVOSurfacePatch::updateGL()
 
 BOOL LLVOSurfacePatch::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer ftm(FTM_UPDATE_TERRAIN);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_TERRAIN);
 
 	dirtySpatialGroup(TRUE);
 	
@@ -1070,10 +1070,10 @@ LLVertexBuffer* LLTerrainPartition::createVertexBuffer(U32 type_mask, U32 usage)
 	return new LLVertexBufferTerrain();
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_TERRAIN_VB("Terrain VB");
+static LLTrace::TimeBlock FTM_REBUILD_TERRAIN_VB("Terrain VB");
 void LLTerrainPartition::getGeometry(LLSpatialGroup* group)
 {
-	LLFastTimer ftm(FTM_REBUILD_TERRAIN_VB);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_TERRAIN_VB);
 
 	LLVertexBuffer* buffer = group->mVertexBuffer;
 
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index f5206b74ea..dad8ba09fe 100755
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -479,11 +479,11 @@ LLDrawable* LLVOTree::createDrawable(LLPipeline *pipeline)
 const S32 LEAF_INDICES = 24;
 const S32 LEAF_VERTICES = 16;
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_TREE("Update Tree");
+static LLTrace::TimeBlock FTM_UPDATE_TREE("Update Tree");
 
 BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer ftm(FTM_UPDATE_TREE);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_TREE);
 
 	if(mTrunkLOD >= sMAX_NUM_TREE_LOD_LEVELS) //do not display the tree.
 	{
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 4ff9bc6981..c6ad6234e5 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -96,9 +96,9 @@ S32 LLVOVolume::mRenderComplexity_current = 0;
 LLPointer<LLObjectMediaDataClient> LLVOVolume::sObjectMediaClient = NULL;
 LLPointer<LLObjectMediaNavigateClient> LLVOVolume::sObjectMediaNavigateClient = NULL;
 
-static LLFastTimer::DeclareTimer FTM_GEN_TRIANGLES("Generate Triangles");
-static LLFastTimer::DeclareTimer FTM_GEN_VOLUME("Generate Volumes");
-static LLFastTimer::DeclareTimer FTM_VOLUME_TEXTURES("Volume Textures");
+static LLTrace::TimeBlock FTM_GEN_TRIANGLES("Generate Triangles");
+static LLTrace::TimeBlock FTM_GEN_VOLUME("Generate Volumes");
+static LLTrace::TimeBlock FTM_VOLUME_TEXTURES("Volume Textures");
 
 // Implementation class of LLMediaDataClientObject.  See llmediadataclient.h
 class LLMediaDataClientObjectImpl : public LLMediaDataClientObject
@@ -659,7 +659,7 @@ BOOL LLVOVolume::isVisible() const
 
 void LLVOVolume::updateTextureVirtualSize(bool forced)
 {
-	LLFastTimer ftm(FTM_VOLUME_TEXTURES);
+	LL_RECORD_BLOCK_TIME(FTM_VOLUME_TEXTURES);
 	// Update the pixel area of all faces
 
 	if(!forced)
@@ -1602,18 +1602,18 @@ void LLVOVolume::updateRelativeXform(bool force_identity)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_GEN_FLEX("Generate Flexies");
-static LLFastTimer::DeclareTimer FTM_UPDATE_PRIMITIVES("Update Primitives");
-static LLFastTimer::DeclareTimer FTM_UPDATE_RIGGED_VOLUME("Update Rigged");
+static LLTrace::TimeBlock FTM_GEN_FLEX("Generate Flexies");
+static LLTrace::TimeBlock FTM_UPDATE_PRIMITIVES("Update Primitives");
+static LLTrace::TimeBlock FTM_UPDATE_RIGGED_VOLUME("Update Rigged");
 
 BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer t(FTM_UPDATE_PRIMITIVES);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_PRIMITIVES);
 	
 	if (mDrawable->isState(LLDrawable::REBUILD_RIGGED))
 	{
 		{
-			LLFastTimer t(FTM_UPDATE_RIGGED_VOLUME);
+			LL_RECORD_BLOCK_TIME(FTM_UPDATE_RIGGED_VOLUME);
 			updateRiggedVolume();
 		}
 		genBBoxes(FALSE);
@@ -1624,7 +1624,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
 	{
 		BOOL res;
 		{
-			LLFastTimer t(FTM_GEN_FLEX);
+			LL_RECORD_BLOCK_TIME(FTM_GEN_FLEX);
 			res = mVolumeImpl->doUpdateGeometry(drawable);
 		}
 		updateFaceFlags();
@@ -1654,14 +1654,14 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
 
 		if (mVolumeChanged)
 		{
-			LLFastTimer ftm(FTM_GEN_VOLUME);
+			LL_RECORD_BLOCK_TIME(FTM_GEN_VOLUME);
 			LLVolumeParams volume_params = getVolume()->getParams();
 			setVolume(volume_params, 0);
 			drawable->setState(LLDrawable::REBUILD_VOLUME);
 		}
 
 		{
-			LLFastTimer t(FTM_GEN_TRIANGLES);
+			LL_RECORD_BLOCK_TIME(FTM_GEN_TRIANGLES);
 			regenFaces();
 			genBBoxes(FALSE);
 		}
@@ -1680,7 +1680,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
 		old_volumep = NULL ;
 
 		{
-			LLFastTimer ftm(FTM_GEN_VOLUME);
+			LL_RECORD_BLOCK_TIME(FTM_GEN_VOLUME);
 			LLVolumeParams volume_params = getVolume()->getParams();
 			setVolume(volume_params, 0);
 		}
@@ -1703,7 +1703,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
 			drawable->setState(LLDrawable::REBUILD_VOLUME); // for face->genVolumeTriangles()
 
 			{
-				LLFastTimer t(FTM_GEN_TRIANGLES);
+				LL_RECORD_BLOCK_TIME(FTM_GEN_TRIANGLES);
 				if (new_num_faces != old_num_faces || mNumFaces != (S32)getNumTEs())
 				{
 					regenFaces();
@@ -1728,7 +1728,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
 	{
 		compiled = TRUE;
 		// All it did was move or we changed the texture coordinate offset
-		LLFastTimer t(FTM_GEN_TRIANGLES);
+		LL_RECORD_BLOCK_TIME(FTM_GEN_TRIANGLES);
 		genBBoxes(FALSE);
 	}
 
@@ -3865,8 +3865,8 @@ void LLVOVolume::updateRiggedVolume()
 
 }
 
-static LLFastTimer::DeclareTimer FTM_SKIN_RIGGED("Skin");
-static LLFastTimer::DeclareTimer FTM_RIGGED_OCTREE("Octree");
+static LLTrace::TimeBlock FTM_SKIN_RIGGED("Skin");
+static LLTrace::TimeBlock FTM_RIGGED_OCTREE("Octree");
 
 void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, const LLVolume* volume)
 {
@@ -3924,7 +3924,7 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
 
 			if( pos && weight && dst_face.mExtents )
 			{
-				LLFastTimer t(FTM_SKIN_RIGGED);
+				LL_RECORD_BLOCK_TIME(FTM_SKIN_RIGGED);
 
 				for (U32 j = 0; j < dst_face.mNumVertices; ++j)
 				{
@@ -3985,7 +3985,7 @@ void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, cons
 			}
 
 			{
-				LLFastTimer t(FTM_RIGGED_OCTREE);
+				LL_RECORD_BLOCK_TIME(FTM_RIGGED_OCTREE);
 				delete dst_face.mOctree;
 				dst_face.mOctree = NULL;
 
@@ -4058,11 +4058,11 @@ bool can_batch_texture(LLFace* facep)
 	return true;
 }
 
-static LLFastTimer::DeclareTimer FTM_REGISTER_FACE("Register Face");
+static LLTrace::TimeBlock FTM_REGISTER_FACE("Register Face");
 
 void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 type)
 {
-	LLFastTimer t(FTM_REGISTER_FACE);
+	LL_RECORD_BLOCK_TIME(FTM_REGISTER_FACE);
 	if (type == LLRenderPass::PASS_ALPHA && facep->getTextureEntry()->getMaterialParams().notNull() && !facep->getVertexBuffer()->hasDataType(LLVertexBuffer::TYPE_TANGENT))
 	{
 		LL_WARNS("RenderMaterials") << "Oh no! No binormals for this alpha blended face!" << LL_ENDL;
@@ -4289,9 +4289,9 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_VB("Volume VB");
-static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_FACE_LIST("Build Face List");
-static LLFastTimer::DeclareTimer FTM_REBUILD_VOLUME_GEN_DRAW_INFO("Gen Draw Info");
+static LLTrace::TimeBlock FTM_REBUILD_VOLUME_VB("Volume VB");
+static LLTrace::TimeBlock FTM_REBUILD_VOLUME_FACE_LIST("Build Face List");
+static LLTrace::TimeBlock FTM_REBUILD_VOLUME_GEN_DRAW_INFO("Gen Draw Info");
 
 static LLDrawPoolAvatar* get_avatar_drawpool(LLViewerObject* vobj)
 {
@@ -4340,7 +4340,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 		return;
 	}
 
-	LLFastTimer ftm(FTM_REBUILD_VOLUME_VB);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_VB);
 
 	group->mBuilt = 1.f;
 	
@@ -4397,7 +4397,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 	bool emissive = false;
 
 	{
-		LLFastTimer t(FTM_REBUILD_VOLUME_FACE_LIST);
+		LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_FACE_LIST);
 
 		//get all the faces into a list
 		for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
@@ -4933,8 +4933,8 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 	llassert(group);
 	if (group && group->hasState(LLSpatialGroup::MESH_DIRTY) && !group->hasState(LLSpatialGroup::GEOM_DIRTY))
 	{
-		LLFastTimer ftm(FTM_REBUILD_VOLUME_VB);
-		LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); //make sure getgeometryvolume shows up in the right place in timers
+		LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_VB);
+		LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_GEN_DRAW_INFO); //make sure getgeometryvolume shows up in the right place in timers
 
 		S32 num_mapped_veretx_buffer = LLVertexBuffer::sMappedCount ;
 
@@ -5068,11 +5068,11 @@ struct CompareBatchBreakerModified
 	}
 };
 
-static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_SORT("Draw Info Face Sort");
-static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_FACE_SIZE("Face Sizing");
-static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_ALLOCATE("Allocate VB");
-static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_FIND_VB("Find VB");
-static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB");
+static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_SORT("Draw Info Face Sort");
+static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_FACE_SIZE("Face Sizing");
+static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_ALLOCATE("Allocate VB");
+static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_FIND_VB("Find VB");
+static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB");
 
 
 
@@ -5080,7 +5080,7 @@ static LLFastTimer::DeclareTimer FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB");
 
 void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort, BOOL batch_textures, BOOL no_materials)
 {
-	LLFastTimer t(FTM_REBUILD_VOLUME_GEN_DRAW_INFO);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_VOLUME_GEN_DRAW_INFO);
 
 	U32 buffer_usage = group->mBufferUsage;
 	
@@ -5100,7 +5100,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 	max_vertices = llmin(max_vertices, (U32) 65535);
 
 	{
-		LLFastTimer t(FTM_GEN_DRAW_INFO_SORT);
+		LL_RECORD_BLOCK_TIME(FTM_GEN_DRAW_INFO_SORT);
 		if (!distance_sort)
 		{
 			//sort faces by things that break batches
@@ -5177,7 +5177,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 		std::vector<LLViewerTexture*> texture_list;
 
 		{
-			LLFastTimer t(FTM_GEN_DRAW_INFO_FACE_SIZE);
+			LL_RECORD_BLOCK_TIME(FTM_GEN_DRAW_INFO_FACE_SIZE);
 			if (batch_textures)
 			{
 				U8 cur_tex = 0;
@@ -5283,7 +5283,7 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
 		LLVertexBuffer* buffer = NULL;
 
 		{
-			LLFastTimer t(FTM_GEN_DRAW_INFO_ALLOCATE);
+			LL_RECORD_BLOCK_TIME(FTM_GEN_DRAW_INFO_ALLOCATE);
 			buffer = createVertexBuffer(mask, buffer_usage);
 			buffer->allocateBuffer(geom_count, index_count, TRUE);
 		}
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index fc85a670b5..9f01e56284 100755
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -123,11 +123,11 @@ LLDrawable *LLVOWater::createDrawable(LLPipeline *pipeline)
 	return mDrawable;
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_WATER("Update Water");
+static LLTrace::TimeBlock FTM_UPDATE_WATER("Update Water");
 
 BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
 {
-	LLFastTimer ftm(FTM_UPDATE_WATER);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATER);
 	LLFace *face;
 
 	if (drawable->getNumFaces() < 1)
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index 96a94e0af4..e798a6eb51 100755
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -301,11 +301,11 @@ void LLVOWLSky::restoreGL()
 	gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE);
 }
 
-static LLFastTimer::DeclareTimer FTM_GEO_SKY("Windlight Sky Geometry");
+static LLTrace::TimeBlock FTM_GEO_SKY("Windlight Sky Geometry");
 
 BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 {
-	LLFastTimer ftm(FTM_GEO_SKY);
+	LL_RECORD_BLOCK_TIME(FTM_GEO_SKY);
 	LLStrider<LLVector3>	vertices;
 	LLStrider<LLVector2>	texCoords;
 	LLStrider<U16>			indices;
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index 74100910f5..a11ba1720e 100755
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -216,11 +216,11 @@ void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_WATERPARAM("Update Water Params");
+static LLTrace::TimeBlock FTM_UPDATE_WATERPARAM("Update Water Params");
 
 void LLWaterParamManager::update(LLViewerCamera * cam)
 {
-	LLFastTimer ftm(FTM_UPDATE_WATERPARAM);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERPARAM);
 	
 	// update the shaders and the menu
 	propagateParameters();
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index 6e6510d9c9..dabf39b2a8 100755
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -364,11 +364,11 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader)
 	
 }
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_WLPARAM("Update Windlight Params");
+static LLTrace::TimeBlock FTM_UPDATE_WLPARAM("Update Windlight Params");
 
 void LLWLParamManager::propagateParameters(void)
 {
-	LLFastTimer ftm(FTM_UPDATE_WLPARAM);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_WLPARAM);
 	
 	LLVector4 sunDir;
 	LLVector4 moonDir;
@@ -439,7 +439,7 @@ void LLWLParamManager::propagateParameters(void)
 
 void LLWLParamManager::update(LLViewerCamera * cam)
 {
-	LLFastTimer ftm(FTM_UPDATE_WLPARAM);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_WLPARAM);
 	
 	// update clouds, sun, and general
 	mCurParams.updateCloudScrolling();
diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp
index dba3970635..7da0a0ad9e 100755
--- a/indra/newview/llwlparamset.cpp
+++ b/indra/newview/llwlparamset.cpp
@@ -44,11 +44,11 @@ LLWLParamSet::LLWLParamSet(void) :
 	mCloudScrollXOffset(0.f), mCloudScrollYOffset(0.f)	
 {}
 
-static LLFastTimer::DeclareTimer FTM_WL_PARAM_UPDATE("WL Param Update");
+static LLTrace::TimeBlock FTM_WL_PARAM_UPDATE("WL Param Update");
 
 void LLWLParamSet::update(LLGLSLShader * shader) const 
 {	
-	LLFastTimer t(FTM_WL_PARAM_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_WL_PARAM_UPDATE);
 
 	for(LLSD::map_const_iterator i = mParamValues.beginMap();
 		i != mParamValues.endMap();
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 2c160754a6..6a2653bc88 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1033,11 +1033,11 @@ void LLWorld::disconnectRegions()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_ENABLE_SIMULATOR("Enable Sim");
+static LLTrace::TimeBlock FTM_ENABLE_SIMULATOR("Enable Sim");
 
 void process_enable_simulator(LLMessageSystem *msg, void **user_data)
 {
-	LLFastTimer t(FTM_ENABLE_SIMULATOR);
+	LL_RECORD_BLOCK_TIME(FTM_ENABLE_SIMULATOR);
 	// enable the appropriate circuit for this simulator and 
 	// add its values into the gSimulator structure
 	U64		handle;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index af44acc64c..bc691d50d2 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -222,40 +222,40 @@ BOOL	gDebugPipeline = FALSE;
 LLPipeline gPipeline;
 const LLMatrix4* gGLLastMatrix = NULL;
 
-LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY("Render Geometry");
-LLFastTimer::DeclareTimer FTM_RENDER_GRASS("Grass");
-LLFastTimer::DeclareTimer FTM_RENDER_INVISIBLE("Invisible");
-LLFastTimer::DeclareTimer FTM_RENDER_OCCLUSION("Occlusion");
-LLFastTimer::DeclareTimer FTM_RENDER_SHINY("Shiny");
-LLFastTimer::DeclareTimer FTM_RENDER_SIMPLE("Simple");
-LLFastTimer::DeclareTimer FTM_RENDER_TERRAIN("Terrain");
-LLFastTimer::DeclareTimer FTM_RENDER_TREES("Trees");
-LLFastTimer::DeclareTimer FTM_RENDER_UI("UI");
-LLFastTimer::DeclareTimer FTM_RENDER_WATER("Water");
-LLFastTimer::DeclareTimer FTM_RENDER_WL_SKY("Windlight Sky");
-LLFastTimer::DeclareTimer FTM_RENDER_ALPHA("Alpha Objects");
-LLFastTimer::DeclareTimer FTM_RENDER_CHARACTERS("Avatars");
-LLFastTimer::DeclareTimer FTM_RENDER_BUMP("Bump");
-LLFastTimer::DeclareTimer FTM_RENDER_MATERIALS("Materials");
-LLFastTimer::DeclareTimer FTM_RENDER_FULLBRIGHT("Fullbright");
-LLFastTimer::DeclareTimer FTM_RENDER_GLOW("Glow");
-LLFastTimer::DeclareTimer FTM_GEO_UPDATE("Geo Update");
-LLFastTimer::DeclareTimer FTM_PIPELINE_CREATE("Pipeline Create");
-LLFastTimer::DeclareTimer FTM_POOLRENDER("RenderPool");
-LLFastTimer::DeclareTimer FTM_POOLS("Pools");
-LLFastTimer::DeclareTimer FTM_DEFERRED_POOLRENDER("RenderPool (Deferred)");
-LLFastTimer::DeclareTimer FTM_DEFERRED_POOLS("Pools (Deferred)");
-LLFastTimer::DeclareTimer FTM_POST_DEFERRED_POOLRENDER("RenderPool (Post)");
-LLFastTimer::DeclareTimer FTM_POST_DEFERRED_POOLS("Pools (Post)");
-LLFastTimer::DeclareTimer FTM_RENDER_BLOOM_FBO("First FBO");
-LLFastTimer::DeclareTimer FTM_STATESORT("Sort Draw State");
-LLFastTimer::DeclareTimer FTM_PIPELINE("Pipeline");
-LLFastTimer::DeclareTimer FTM_CLIENT_COPY("Client Copy");
-LLFastTimer::DeclareTimer FTM_RENDER_DEFERRED("Deferred Shading");
-
-
-static LLFastTimer::DeclareTimer FTM_STATESORT_DRAWABLE("Sort Drawables");
-static LLFastTimer::DeclareTimer FTM_STATESORT_POSTSORT("Post Sort");
+LLTrace::TimeBlock FTM_RENDER_GEOMETRY("Render Geometry");
+LLTrace::TimeBlock FTM_RENDER_GRASS("Grass");
+LLTrace::TimeBlock FTM_RENDER_INVISIBLE("Invisible");
+LLTrace::TimeBlock FTM_RENDER_OCCLUSION("Occlusion");
+LLTrace::TimeBlock FTM_RENDER_SHINY("Shiny");
+LLTrace::TimeBlock FTM_RENDER_SIMPLE("Simple");
+LLTrace::TimeBlock FTM_RENDER_TERRAIN("Terrain");
+LLTrace::TimeBlock FTM_RENDER_TREES("Trees");
+LLTrace::TimeBlock FTM_RENDER_UI("UI");
+LLTrace::TimeBlock FTM_RENDER_WATER("Water");
+LLTrace::TimeBlock FTM_RENDER_WL_SKY("Windlight Sky");
+LLTrace::TimeBlock FTM_RENDER_ALPHA("Alpha Objects");
+LLTrace::TimeBlock FTM_RENDER_CHARACTERS("Avatars");
+LLTrace::TimeBlock FTM_RENDER_BUMP("Bump");
+LLTrace::TimeBlock FTM_RENDER_MATERIALS("Materials");
+LLTrace::TimeBlock FTM_RENDER_FULLBRIGHT("Fullbright");
+LLTrace::TimeBlock FTM_RENDER_GLOW("Glow");
+LLTrace::TimeBlock FTM_GEO_UPDATE("Geo Update");
+LLTrace::TimeBlock FTM_PIPELINE_CREATE("Pipeline Create");
+LLTrace::TimeBlock FTM_POOLRENDER("RenderPool");
+LLTrace::TimeBlock FTM_POOLS("Pools");
+LLTrace::TimeBlock FTM_DEFERRED_POOLRENDER("RenderPool (Deferred)");
+LLTrace::TimeBlock FTM_DEFERRED_POOLS("Pools (Deferred)");
+LLTrace::TimeBlock FTM_POST_DEFERRED_POOLRENDER("RenderPool (Post)");
+LLTrace::TimeBlock FTM_POST_DEFERRED_POOLS("Pools (Post)");
+LLTrace::TimeBlock FTM_RENDER_BLOOM_FBO("First FBO");
+LLTrace::TimeBlock FTM_STATESORT("Sort Draw State");
+LLTrace::TimeBlock FTM_PIPELINE("Pipeline");
+LLTrace::TimeBlock FTM_CLIENT_COPY("Client Copy");
+LLTrace::TimeBlock FTM_RENDER_DEFERRED("Deferred Shading");
+
+
+static LLTrace::TimeBlock FTM_STATESORT_DRAWABLE("Sort Drawables");
+static LLTrace::TimeBlock FTM_STATESORT_POSTSORT("Post Sort");
 
 //----------------------------------------
 std::string gPoolNames[] = 
@@ -754,7 +754,7 @@ void LLPipeline::destroyGL()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
+static LLTrace::TimeBlock FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
 
 //static
 void LLPipeline::throttleNewMemoryAllocation(BOOL disable)
@@ -776,7 +776,7 @@ void LLPipeline::throttleNewMemoryAllocation(BOOL disable)
 
 void LLPipeline::resizeScreenTexture()
 {
-	LLFastTimer ft(FTM_RESIZE_SCREEN_TEXTURE);
+	LL_RECORD_BLOCK_TIME(FTM_RESIZE_SCREEN_TEXTURE);
 	if (gPipeline.canUseVertexShaders() && assertInitialized())
 	{
 		GLuint resX = gViewerWindow->getWorldViewWidthRaw();
@@ -1771,15 +1771,15 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj)
 }
 
 
-static LLFastTimer::DeclareTimer FTM_UNLINK("Unlink");
-static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_MOVE_LIST("Movelist");
-static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_SPATIAL_PARTITION("Spatial Partition");
-static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_LIGHT_SET("Light Set");
-static LLFastTimer::DeclareTimer FTM_REMOVE_FROM_HIGHLIGHT_SET("Highlight Set");
+static LLTrace::TimeBlock FTM_UNLINK("Unlink");
+static LLTrace::TimeBlock FTM_REMOVE_FROM_MOVE_LIST("Movelist");
+static LLTrace::TimeBlock FTM_REMOVE_FROM_SPATIAL_PARTITION("Spatial Partition");
+static LLTrace::TimeBlock FTM_REMOVE_FROM_LIGHT_SET("Light Set");
+static LLTrace::TimeBlock FTM_REMOVE_FROM_HIGHLIGHT_SET("Highlight Set");
 
 void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 {
-	LLFastTimer t(FTM_UNLINK);
+	LL_RECORD_BLOCK_TIME(FTM_UNLINK);
 
 	assertInitialized();
 
@@ -1788,7 +1788,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 	// Based on flags, remove the drawable from the queues that it's on.
 	if (drawablep->isState(LLDrawable::ON_MOVE_LIST))
 	{
-		LLFastTimer t(FTM_REMOVE_FROM_MOVE_LIST);
+		LL_RECORD_BLOCK_TIME(FTM_REMOVE_FROM_MOVE_LIST);
 		LLDrawable::drawable_vector_t::iterator iter = std::find(mMovedList.begin(), mMovedList.end(), drawablep);
 		if (iter != mMovedList.end())
 		{
@@ -1798,7 +1798,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 
 	if (drawablep->getSpatialGroup())
 	{
-		LLFastTimer t(FTM_REMOVE_FROM_SPATIAL_PARTITION);
+		LL_RECORD_BLOCK_TIME(FTM_REMOVE_FROM_SPATIAL_PARTITION);
 		if (!drawablep->getSpatialGroup()->getSpatialPartition()->remove(drawablep, drawablep->getSpatialGroup()))
 		{
 #ifdef LL_RELEASE_FOR_DOWNLOAD
@@ -1810,7 +1810,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 	}
 
 	{
-		LLFastTimer t(FTM_REMOVE_FROM_LIGHT_SET);
+		LL_RECORD_BLOCK_TIME(FTM_REMOVE_FROM_LIGHT_SET);
 		mLights.erase(drawablep);
 
 		for (light_set_t::iterator iter = mNearbyLights.begin();
@@ -1825,7 +1825,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 	}
 
 	{
-		LLFastTimer t(FTM_REMOVE_FROM_HIGHLIGHT_SET);
+		LL_RECORD_BLOCK_TIME(FTM_REMOVE_FROM_HIGHLIGHT_SET);
 		HighlightItem item(drawablep);
 		mHighlightSet.erase(item);
 
@@ -1854,7 +1854,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 //static
 void LLPipeline::removeMutedAVsLights(LLVOAvatar* muted_avatar)
 {
-	LLFastTimer t(FTM_REMOVE_FROM_LIGHT_SET);
+	LL_RECORD_BLOCK_TIME(FTM_REMOVE_FROM_LIGHT_SET);
 	for (light_set_t::iterator iter = gPipeline.mNearbyLights.begin();
 		 iter != gPipeline.mNearbyLights.end(); iter++)
 	{
@@ -1882,7 +1882,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj)
 
 void LLPipeline::createObjects(F32 max_dtime)
 {
-	LLFastTimer ftm(FTM_PIPELINE_CREATE);
+	LL_RECORD_BLOCK_TIME(FTM_PIPELINE_CREATE);
 
 	LLTimer update_timer;
 
@@ -2051,14 +2051,14 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_OCTREE_BALANCE("Balance Octree");
-static LLFastTimer::DeclareTimer FTM_UPDATE_MOVE("Update Move");
-static LLFastTimer::DeclareTimer FTM_RETEXTURE("Retexture");
-static LLFastTimer::DeclareTimer FTM_MOVED_LIST("Moved List");
+static LLTrace::TimeBlock FTM_OCTREE_BALANCE("Balance Octree");
+static LLTrace::TimeBlock FTM_UPDATE_MOVE("Update Move");
+static LLTrace::TimeBlock FTM_RETEXTURE("Retexture");
+static LLTrace::TimeBlock FTM_MOVED_LIST("Moved List");
 
 void LLPipeline::updateMove()
 {
-	LLFastTimer t(FTM_UPDATE_MOVE);
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_MOVE);
 
 	if (FreezeTime)
 	{
@@ -2068,7 +2068,7 @@ void LLPipeline::updateMove()
 	assertInitialized();
 
 	{
-		LLFastTimer t(FTM_RETEXTURE);
+		LL_RECORD_BLOCK_TIME(FTM_RETEXTURE);
 
 		for (LLDrawable::drawable_set_t::iterator iter = mRetexturedList.begin();
 			 iter != mRetexturedList.end(); ++iter)
@@ -2083,13 +2083,13 @@ void LLPipeline::updateMove()
 	}
 
 	{
-		LLFastTimer t(FTM_MOVED_LIST);
+		LL_RECORD_BLOCK_TIME(FTM_MOVED_LIST);
 		updateMovedList(mMovedList);
 	}
 
 	//balance octrees
 	{
- 		LLFastTimer ot(FTM_OCTREE_BALANCE);
+ 		LL_RECORD_BLOCK_TIME(FTM_OCTREE_BALANCE);
 
 		for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
 			iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
@@ -2408,7 +2408,7 @@ BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3&
 	return res;
 }
 
-static LLFastTimer::DeclareTimer FTM_CULL("Object Culling");
+static LLTrace::TimeBlock FTM_CULL("Object Culling");
 
 void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep)
 {
@@ -2417,7 +2417,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
 									&& LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") 
 									&& gGLManager.mHasOcclusionQuery;
 
-	LLFastTimer t(FTM_CULL);
+	LL_RECORD_BLOCK_TIME(FTM_CULL);
 
 	grabReferences(result);
 
@@ -2812,14 +2812,14 @@ BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority)
 	return update_complete;
 }
 
-static LLFastTimer::DeclareTimer FTM_SEED_VBO_POOLS("Seed VBO Pool");
+static LLTrace::TimeBlock FTM_SEED_VBO_POOLS("Seed VBO Pool");
 
-static LLFastTimer::DeclareTimer FTM_UPDATE_GL("Update GL");
+static LLTrace::TimeBlock FTM_UPDATE_GL("Update GL");
 
 void LLPipeline::updateGL()
 {
 	{
-		LLFastTimer t(FTM_UPDATE_GL);
+		LL_RECORD_BLOCK_TIME(FTM_UPDATE_GL);
 		while (!LLGLUpdate::sGLQ.empty())
 		{
 			LLGLUpdate* glu = LLGLUpdate::sGLQ.front();
@@ -2830,12 +2830,12 @@ void LLPipeline::updateGL()
 	}
 
 	{ //seed VBO Pools
-		LLFastTimer t(FTM_SEED_VBO_POOLS);
+		LL_RECORD_BLOCK_TIME(FTM_SEED_VBO_POOLS);
 		LLVertexBuffer::seedPools();
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_PRIORITY_GROUPS("Rebuild Priority Groups");
+static LLTrace::TimeBlock FTM_REBUILD_PRIORITY_GROUPS("Rebuild Priority Groups");
 
 void LLPipeline::clearRebuildGroups()
 {
@@ -2897,7 +2897,7 @@ void LLPipeline::clearRebuildGroups()
 
 void LLPipeline::rebuildPriorityGroups()
 {
-	LLFastTimer t(FTM_REBUILD_PRIORITY_GROUPS);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_PRIORITY_GROUPS);
 	LLTimer update_timer;
 	assertInitialized();
 
@@ -2919,7 +2919,7 @@ void LLPipeline::rebuildPriorityGroups()
 
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_GROUPS("Rebuild Groups");
+static LLTrace::TimeBlock FTM_REBUILD_GROUPS("Rebuild Groups");
 
 void LLPipeline::rebuildGroups()
 {
@@ -2928,7 +2928,7 @@ void LLPipeline::rebuildGroups()
 		return;
 	}
 
-	LLFastTimer t(FTM_REBUILD_GROUPS);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_GROUPS);
 	mGroupQ2Locked = true;
 	// Iterate through some drawables on the non-priority build queue
 	S32 size = (S32) mGroupQ2.size();
@@ -2972,7 +2972,7 @@ void LLPipeline::updateGeom(F32 max_dtime)
 	LLTimer update_timer;
 	LLPointer<LLDrawable> drawablep;
 
-	LLFastTimer t(FTM_GEO_UPDATE);
+	LL_RECORD_BLOCK_TIME(FTM_GEO_UPDATE);
 
 	assertInitialized();
 
@@ -3165,9 +3165,9 @@ void LLPipeline::markShift(LLDrawable *drawablep)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_SHIFT_DRAWABLE("Shift Drawable");
-static LLFastTimer::DeclareTimer FTM_SHIFT_OCTREE("Shift Octree");
-static LLFastTimer::DeclareTimer FTM_SHIFT_HUD("Shift HUD");
+static LLTrace::TimeBlock FTM_SHIFT_DRAWABLE("Shift Drawable");
+static LLTrace::TimeBlock FTM_SHIFT_OCTREE("Shift Octree");
+static LLTrace::TimeBlock FTM_SHIFT_HUD("Shift HUD");
 
 void LLPipeline::shiftObjects(const LLVector3 &offset)
 {
@@ -3180,7 +3180,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 	offseta.load3(offset.mV);
 
 	{
-		LLFastTimer t(FTM_SHIFT_DRAWABLE);
+		LL_RECORD_BLOCK_TIME(FTM_SHIFT_DRAWABLE);
 
 		for (LLDrawable::drawable_vector_t::iterator iter = mShiftList.begin();
 			 iter != mShiftList.end(); iter++)
@@ -3198,7 +3198,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 
 	
 	{
-		LLFastTimer t(FTM_SHIFT_OCTREE);
+		LL_RECORD_BLOCK_TIME(FTM_SHIFT_OCTREE);
 		for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); 
 				iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
 		{
@@ -3215,7 +3215,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset)
 	}
 
 	{
-		LLFastTimer t(FTM_SHIFT_HUD);
+		LL_RECORD_BLOCK_TIME(FTM_SHIFT_HUD);
 		LLHUDText::shiftAll(offset);
 		LLHUDNameTag::shiftAll(offset);
 	}
@@ -3249,10 +3249,10 @@ void LLPipeline::markPartitionMove(LLDrawable* drawable)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_PROCESS_PARTITIONQ("PartitionQ");
+static LLTrace::TimeBlock FTM_PROCESS_PARTITIONQ("PartitionQ");
 void LLPipeline::processPartitionQ()
 {
-	LLFastTimer t(FTM_PROCESS_PARTITIONQ);
+	LL_RECORD_BLOCK_TIME(FTM_PROCESS_PARTITIONQ);
 	for (LLDrawable::drawable_list_t::iterator iter = mPartitionQ.begin(); iter != mPartitionQ.end(); ++iter)
 	{
 		LLDrawable* drawable = *iter;
@@ -3340,7 +3340,7 @@ void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags f
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_RESET_DRAWORDER("Reset Draw Order");
+static LLTrace::TimeBlock FTM_RESET_DRAWORDER("Reset Draw Order");
 
 void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 {
@@ -3354,11 +3354,11 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 					  LLPipeline::END_RENDER_TYPES))
 	{
 		//clear faces from face pools
-		LLFastTimer t(FTM_RESET_DRAWORDER);
+		LL_RECORD_BLOCK_TIME(FTM_RESET_DRAWORDER);
 		gPipeline.resetDrawOrders();
 	}
 
-	LLFastTimer ftm(FTM_STATESORT);
+	LL_RECORD_BLOCK_TIME(FTM_STATESORT);
 
 	//LLVertexBuffer::unbind();
 
@@ -3442,7 +3442,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 	}
 	
 	{
-		LLFastTimer ftm(FTM_STATESORT_DRAWABLE);
+		LL_RECORD_BLOCK_TIME(FTM_STATESORT_DRAWABLE);
 		for (LLCullResult::drawable_iterator iter = sCull->beginVisibleList();
 			 iter != sCull->endVisibleList(); ++iter)
 		{
@@ -3772,7 +3772,7 @@ void renderSoundHighlights(LLDrawable* drawablep)
 
 void LLPipeline::postSort(LLCamera& camera)
 {
-	LLFastTimer ftm(FTM_STATESORT_POSTSORT);
+	LL_RECORD_BLOCK_TIME(FTM_STATESORT_POSTSORT);
 
 	assertInitialized();
 
@@ -3998,7 +3998,7 @@ void LLPipeline::postSort(LLCamera& camera)
 
 void render_hud_elements()
 {
-	LLFastTimer t(FTM_RENDER_UI);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_UI);
 	gPipeline.disableLights();		
 	
 	LLGLDisable fog(GL_FOG);
@@ -4277,7 +4277,7 @@ U32 LLPipeline::sCurRenderPoolType = 0 ;
 
 void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 {
-	LLFastTimer t(FTM_RENDER_GEOMETRY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY);
 
 	assertInitialized();
 
@@ -4364,7 +4364,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 	}
 
 	{
-		LLFastTimer t(FTM_POOLS);
+		LL_RECORD_BLOCK_TIME(FTM_POOLS);
 		
 		// HACK: don't calculate local lights if we're rendering the HUD!
 		//    Removing this check will cause bad flickering when there are 
@@ -4400,7 +4400,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate)
 			pool_set_t::iterator iter2 = iter1;
 			if (hasRenderType(poolp->getType()) && poolp->getNumPasses() > 0)
 			{
-				LLFastTimer t(FTM_POOLRENDER);
+				LL_RECORD_BLOCK_TIME(FTM_POOLRENDER);
 
 				gGLLastMatrix = NULL;
 				gGL.loadMatrix(gGLModelView);
@@ -4529,9 +4529,9 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 {
 	LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred");
 
-	LLFastTimer t(FTM_RENDER_GEOMETRY);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_GEOMETRY);
 
-	LLFastTimer t2(FTM_DEFERRED_POOLS);
+	LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLS);
 
 	LLGLEnable cull(GL_CULL_FACE);
 
@@ -4573,7 +4573,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 		pool_set_t::iterator iter2 = iter1;
 		if (hasRenderType(poolp->getType()) && poolp->getNumDeferredPasses() > 0)
 		{
-			LLFastTimer t(FTM_DEFERRED_POOLRENDER);
+			LL_RECORD_BLOCK_TIME(FTM_DEFERRED_POOLRENDER);
 
 			gGLLastMatrix = NULL;
 			gGL.loadMatrix(gGLModelView);
@@ -4625,7 +4625,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 
 void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion)
 {
-	LLFastTimer t(FTM_POST_DEFERRED_POOLS);
+	LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLS);
 	U32 cur_type = 0;
 
 	LLGLEnable cull(GL_CULL_FACE);
@@ -4659,7 +4659,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion)
 		pool_set_t::iterator iter2 = iter1;
 		if (hasRenderType(poolp->getType()) && poolp->getNumPostDeferredPasses() > 0)
 		{
-			LLFastTimer t(FTM_POST_DEFERRED_POOLRENDER);
+			LL_RECORD_BLOCK_TIME(FTM_POST_DEFERRED_POOLRENDER);
 
 			gGLLastMatrix = NULL;
 			gGL.loadMatrix(gGLModelView);
@@ -5565,11 +5565,11 @@ void LLPipeline::renderDebug()
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_POOLS("Rebuild Pools");
+static LLTrace::TimeBlock FTM_REBUILD_POOLS("Rebuild Pools");
 
 void LLPipeline::rebuildPools()
 {
-	LLFastTimer t(FTM_REBUILD_POOLS);
+	LL_RECORD_BLOCK_TIME(FTM_REBUILD_POOLS);
 
 	assertInitialized();
 
@@ -7287,7 +7287,7 @@ void LLPipeline::resetVertexBuffers()
 	mResetVertexBuffers = true;
 }
 
-static LLFastTimer::DeclareTimer FTM_RESET_VB("Reset VB");
+static LLTrace::TimeBlock FTM_RESET_VB("Reset VB");
 
 void LLPipeline::doResetVertexBuffers()
 {
@@ -7296,7 +7296,7 @@ void LLPipeline::doResetVertexBuffers()
 		return;
 	}
 
-	LLFastTimer t(FTM_RESET_VB);
+	LL_RECORD_BLOCK_TIME(FTM_RESET_VB);
 	mResetVertexBuffers = false;
 
 	mCubeVB = NULL;
@@ -7440,7 +7440,7 @@ void LLPipeline::bindScreenToTexture()
 	
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom");
+static LLTrace::TimeBlock FTM_RENDER_BLOOM("Bloom");
 
 void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 {
@@ -7465,7 +7465,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 	LLVector2 tc2((F32) mScreen.getWidth()*2,
 				  (F32) mScreen.getHeight()*2);
 
-	LLFastTimer ftm(FTM_RENDER_BLOOM);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM);
 	gGL.color4f(1,1,1,1);
 	LLGLDepthTest depth(GL_FALSE);
 	LLGLDisable blend(GL_BLEND);
@@ -7487,7 +7487,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 		
 	{
 		{
-			LLFastTimer ftm(FTM_RENDER_BLOOM_FBO);
+			LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM_FBO);
 			mGlow[2].bindTarget();
 			mGlow[2].clear();
 		}
@@ -7555,7 +7555,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 	for (S32 i = 0; i < kernel; i++)
 	{
 		{
-			LLFastTimer ftm(FTM_RENDER_BLOOM_FBO);
+			LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM_FBO);
 			mGlow[i%2].bindTarget();
 			mGlow[i%2].clear();
 		}
@@ -7597,7 +7597,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 	/*if (LLRenderTarget::sUseFBO)
 	{
-		LLFastTimer ftm(FTM_RENDER_BLOOM_FBO);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM_FBO);
 		glBindFramebuffer(GL_FRAMEBUFFER, 0);
 	}*/
 
@@ -8093,11 +8093,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 }
 
-static LLFastTimer::DeclareTimer FTM_BIND_DEFERRED("Bind Deferred");
+static LLTrace::TimeBlock FTM_BIND_DEFERRED("Bind Deferred");
 
 void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 noise_map)
 {
-	LLFastTimer t(FTM_BIND_DEFERRED);
+	LL_RECORD_BLOCK_TIME(FTM_BIND_DEFERRED);
 
 	if (noise_map == 0xFFFFFFFF)
 	{
@@ -8318,16 +8318,16 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f)
 	return v;
 }
 
-static LLFastTimer::DeclareTimer FTM_GI_TRACE("Trace");
-static LLFastTimer::DeclareTimer FTM_GI_GATHER("Gather");
-static LLFastTimer::DeclareTimer FTM_SUN_SHADOW("Shadow Map");
-static LLFastTimer::DeclareTimer FTM_SOFTEN_SHADOW("Shadow Soften");
-static LLFastTimer::DeclareTimer FTM_EDGE_DETECTION("Find Edges");
-static LLFastTimer::DeclareTimer FTM_LOCAL_LIGHTS("Local Lights");
-static LLFastTimer::DeclareTimer FTM_ATMOSPHERICS("Atmospherics");
-static LLFastTimer::DeclareTimer FTM_FULLSCREEN_LIGHTS("Fullscreen Lights");
-static LLFastTimer::DeclareTimer FTM_PROJECTORS("Projectors");
-static LLFastTimer::DeclareTimer FTM_POST("Post");
+static LLTrace::TimeBlock FTM_GI_TRACE("Trace");
+static LLTrace::TimeBlock FTM_GI_GATHER("Gather");
+static LLTrace::TimeBlock FTM_SUN_SHADOW("Shadow Map");
+static LLTrace::TimeBlock FTM_SOFTEN_SHADOW("Shadow Soften");
+static LLTrace::TimeBlock FTM_EDGE_DETECTION("Find Edges");
+static LLTrace::TimeBlock FTM_LOCAL_LIGHTS("Local Lights");
+static LLTrace::TimeBlock FTM_ATMOSPHERICS("Atmospherics");
+static LLTrace::TimeBlock FTM_FULLSCREEN_LIGHTS("Fullscreen Lights");
+static LLTrace::TimeBlock FTM_PROJECTORS("Projectors");
+static LLTrace::TimeBlock FTM_POST("Post");
 
 
 void LLPipeline::renderDeferredLighting()
@@ -8338,7 +8338,7 @@ void LLPipeline::renderDeferredLighting()
 	}
 
 	{
-		LLFastTimer ftm(FTM_RENDER_DEFERRED);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED);
 
 		LLViewerCamera* camera = LLViewerCamera::getInstance();
 		{
@@ -8394,7 +8394,7 @@ void LLPipeline::renderDeferredLighting()
 		{
 			mDeferredLight.bindTarget();
 			{ //paint shadow/SSAO light map (direct lighting lightmap)
-				LLFastTimer ftm(FTM_SUN_SHADOW);
+				LL_RECORD_BLOCK_TIME(FTM_SUN_SHADOW);
 				bindDeferredShader(gDeferredSunProgram, 0);
 				mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
 				glClearColor(1,1,1,1);
@@ -8438,7 +8438,7 @@ void LLPipeline::renderDeferredLighting()
 		
 		if (RenderDeferredSSAO)
 		{ //soften direct lighting lightmap
-			LLFastTimer ftm(FTM_SOFTEN_SHADOW);
+			LL_RECORD_BLOCK_TIME(FTM_SOFTEN_SHADOW);
 			//blur lightmap
 			mScreen.bindTarget();
 			glClearColor(1,1,1,1);
@@ -8513,7 +8513,7 @@ void LLPipeline::renderDeferredLighting()
 		
 		if (RenderDeferredAtmospheric)
 		{ //apply sunlight contribution 
-			LLFastTimer ftm(FTM_ATMOSPHERICS);
+			LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS);
 			bindDeferredShader(gDeferredSoftenProgram);	
 			{
 				LLGLDepthTest depth(GL_FALSE);
@@ -8650,7 +8650,7 @@ void LLPipeline::renderDeferredLighting()
 							col.mV[1] = powf(col.mV[1], 2.2f);
 							col.mV[2] = powf(col.mV[2], 2.2f);*/
 							
-							LLFastTimer ftm(FTM_LOCAL_LIGHTS);
+							LL_RECORD_BLOCK_TIME(FTM_LOCAL_LIGHTS);
 							gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c);
 							gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
 							gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
@@ -8691,7 +8691,7 @@ void LLPipeline::renderDeferredLighting()
 
 				for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter)
 				{
-					LLFastTimer ftm(FTM_PROJECTORS);
+					LL_RECORD_BLOCK_TIME(FTM_PROJECTORS);
 					LLDrawable* drawablep = *iter;
 
 					LLVOVolume* volume = drawablep->getVOVolume();
@@ -8752,7 +8752,7 @@ void LLPipeline::renderDeferredLighting()
 
 				while (!fullscreen_lights.empty())
 				{
-					LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS);
+					LL_RECORD_BLOCK_TIME(FTM_FULLSCREEN_LIGHTS);
 					light[count] = fullscreen_lights.front();
 					fullscreen_lights.pop_front();
 					col[count] = light_colors.front();
@@ -8787,7 +8787,7 @@ void LLPipeline::renderDeferredLighting()
 
 				for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter)
 				{
-					LLFastTimer ftm(FTM_PROJECTORS);
+					LL_RECORD_BLOCK_TIME(FTM_PROJECTORS);
 					LLDrawable* drawablep = *iter;
 					
 					LLVOVolume* volume = drawablep->getVOVolume();
@@ -9444,13 +9444,13 @@ glh::matrix4f scale_translate_to_fit(const LLVector3 min, const LLVector3 max)
 	return ret;
 }
 
-static LLFastTimer::DeclareTimer FTM_SHADOW_RENDER("Render Shadows");
-static LLFastTimer::DeclareTimer FTM_SHADOW_ALPHA("Alpha Shadow");
-static LLFastTimer::DeclareTimer FTM_SHADOW_SIMPLE("Simple Shadow");
+static LLTrace::TimeBlock FTM_SHADOW_RENDER("Render Shadows");
+static LLTrace::TimeBlock FTM_SHADOW_ALPHA("Alpha Shadow");
+static LLTrace::TimeBlock FTM_SHADOW_SIMPLE("Simple Shadow");
 
 void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, LLCullResult &result, BOOL use_shader, BOOL use_occlusion, U32 target_width)
 {
-	LLFastTimer t(FTM_SHADOW_RENDER);
+	LL_RECORD_BLOCK_TIME(FTM_SHADOW_RENDER);
 
 	//clip out geometry on the same side of water as the camera
 	S32 occlude = LLPipeline::sUseOcclusion;
@@ -9525,7 +9525,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
 		gGL.diffuseColor4f(1,1,1,1);
 		gGL.setColorMask(false, false);
 	
-		LLFastTimer ftm(FTM_SHADOW_SIMPLE);
+		LL_RECORD_BLOCK_TIME(FTM_SHADOW_SIMPLE);
 		
 		gGL.getTexUnit(0)->disable();
 		for (U32 i = 0; i < sizeof(types)/sizeof(U32); ++i)
@@ -9551,7 +9551,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
 	}
 
 	{
-		LLFastTimer ftm(FTM_SHADOW_ALPHA);
+		LL_RECORD_BLOCK_TIME(FTM_SHADOW_ALPHA);
 		gDeferredShadowAlphaMaskProgram.bind();
 		gDeferredShadowAlphaMaskProgram.uniform1f(LLShaderMgr::DEFERRED_SHADOW_TARGET_WIDTH, (float)target_width);
 
@@ -9604,10 +9604,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
 	LLPipeline::sShadowRender = FALSE;
 }
 
-static LLFastTimer::DeclareTimer FTM_VISIBLE_CLOUD("Visible Cloud");
+static LLTrace::TimeBlock FTM_VISIBLE_CLOUD("Visible Cloud");
 BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir)
 {
-	LLFastTimer t(FTM_VISIBLE_CLOUD);
+	LL_RECORD_BLOCK_TIME(FTM_VISIBLE_CLOUD);
 	//get point cloud of intersection of frust and min, max
 
 	if (getVisibleExtents(camera, min, max))
@@ -9854,7 +9854,7 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 }
 
 
-static LLFastTimer::DeclareTimer FTM_GEN_SUN_SHADOW("Gen Sun Shadow");
+static LLTrace::TimeBlock FTM_GEN_SUN_SHADOW("Gen Sun Shadow");
 
 void LLPipeline::generateSunShadow(LLCamera& camera)
 {
@@ -9863,7 +9863,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
 		return;
 	}
 
-	LLFastTimer t(FTM_GEN_SUN_SHADOW);
+	LL_RECORD_BLOCK_TIME(FTM_GEN_SUN_SHADOW);
 
 	BOOL skip_avatar_update = FALSE;
 	if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)
@@ -10644,11 +10644,11 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_MARK_VISIBLE("Impostor Mark Visible");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_SETUP("Impostor Setup");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_BACKGROUND("Impostor Background");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_ALLOCATE("Impostor Allocate");
-static LLFastTimer::DeclareTimer FTM_IMPOSTOR_RESIZE("Impostor Resize");
+static LLTrace::TimeBlock FTM_IMPOSTOR_MARK_VISIBLE("Impostor Mark Visible");
+static LLTrace::TimeBlock FTM_IMPOSTOR_SETUP("Impostor Setup");
+static LLTrace::TimeBlock FTM_IMPOSTOR_BACKGROUND("Impostor Background");
+static LLTrace::TimeBlock FTM_IMPOSTOR_ALLOCATE("Impostor Allocate");
+static LLTrace::TimeBlock FTM_IMPOSTOR_RESIZE("Impostor Resize");
 
 void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 {
@@ -10706,7 +10706,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	LLViewerCamera* viewer_camera = LLViewerCamera::getInstance();
 
 	{
-		LLFastTimer t(FTM_IMPOSTOR_MARK_VISIBLE);
+		LL_RECORD_BLOCK_TIME(FTM_IMPOSTOR_MARK_VISIBLE);
 		markVisible(avatar->mDrawable, *viewer_camera);
 		LLVOAvatar::sUseImpostors = FALSE;
 
@@ -10736,7 +10736,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	U32 resX = 0;
 
 	{
-		LLFastTimer t(FTM_IMPOSTOR_SETUP);
+		LL_RECORD_BLOCK_TIME(FTM_IMPOSTOR_SETUP);
 		const LLVector4a* ext = avatar->mDrawable->getSpatialExtents();
 		LLVector3 pos(avatar->getRenderPosition()+avatar->getImpostorOffset());
 
@@ -10793,7 +10793,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 
 		if (!avatar->mImpostor.isComplete())
 		{
-			LLFastTimer t(FTM_IMPOSTOR_ALLOCATE);
+			LL_RECORD_BLOCK_TIME(FTM_IMPOSTOR_ALLOCATE);
 			avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,FALSE);
 
 			if (LLPipeline::sRenderDeferred)
@@ -10808,7 +10808,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 		else if(resX != avatar->mImpostor.getWidth() ||
 			resY != avatar->mImpostor.getHeight())
 		{
-			LLFastTimer t(FTM_IMPOSTOR_RESIZE);
+			LL_RECORD_BLOCK_TIME(FTM_IMPOSTOR_RESIZE);
 			avatar->mImpostor.resize(resX,resY,GL_RGBA);
 		}
 
@@ -10830,7 +10830,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	}
 	
 	{ //create alpha mask based on depth buffer (grey out if muted)
-		LLFastTimer t(FTM_IMPOSTOR_BACKGROUND);
+		LL_RECORD_BLOCK_TIME(FTM_IMPOSTOR_BACKGROUND);
 		if (LLPipeline::sRenderDeferred)
 		{
 			GLuint buff = GL_COLOR_ATTACHMENT0;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index b12dc3edbb..178a935d98 100755
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -70,26 +70,26 @@ glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
 glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
 glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up);
 
-extern LLFastTimer::DeclareTimer FTM_RENDER_GEOMETRY;
-extern LLFastTimer::DeclareTimer FTM_RENDER_GRASS;
-extern LLFastTimer::DeclareTimer FTM_RENDER_INVISIBLE;
-extern LLFastTimer::DeclareTimer FTM_RENDER_OCCLUSION;
-extern LLFastTimer::DeclareTimer FTM_RENDER_SHINY;
-extern LLFastTimer::DeclareTimer FTM_RENDER_SIMPLE;
-extern LLFastTimer::DeclareTimer FTM_RENDER_TERRAIN;
-extern LLFastTimer::DeclareTimer FTM_RENDER_TREES;
-extern LLFastTimer::DeclareTimer FTM_RENDER_UI;
-extern LLFastTimer::DeclareTimer FTM_RENDER_WATER;
-extern LLFastTimer::DeclareTimer FTM_RENDER_WL_SKY;
-extern LLFastTimer::DeclareTimer FTM_RENDER_ALPHA;
-extern LLFastTimer::DeclareTimer FTM_RENDER_CHARACTERS;
-extern LLFastTimer::DeclareTimer FTM_RENDER_BUMP;
-extern LLFastTimer::DeclareTimer FTM_RENDER_MATERIALS;
-extern LLFastTimer::DeclareTimer FTM_RENDER_FULLBRIGHT;
-extern LLFastTimer::DeclareTimer FTM_RENDER_GLOW;
-extern LLFastTimer::DeclareTimer FTM_STATESORT;
-extern LLFastTimer::DeclareTimer FTM_PIPELINE;
-extern LLFastTimer::DeclareTimer FTM_CLIENT_COPY;
+extern LLTrace::TimeBlock FTM_RENDER_GEOMETRY;
+extern LLTrace::TimeBlock FTM_RENDER_GRASS;
+extern LLTrace::TimeBlock FTM_RENDER_INVISIBLE;
+extern LLTrace::TimeBlock FTM_RENDER_OCCLUSION;
+extern LLTrace::TimeBlock FTM_RENDER_SHINY;
+extern LLTrace::TimeBlock FTM_RENDER_SIMPLE;
+extern LLTrace::TimeBlock FTM_RENDER_TERRAIN;
+extern LLTrace::TimeBlock FTM_RENDER_TREES;
+extern LLTrace::TimeBlock FTM_RENDER_UI;
+extern LLTrace::TimeBlock FTM_RENDER_WATER;
+extern LLTrace::TimeBlock FTM_RENDER_WL_SKY;
+extern LLTrace::TimeBlock FTM_RENDER_ALPHA;
+extern LLTrace::TimeBlock FTM_RENDER_CHARACTERS;
+extern LLTrace::TimeBlock FTM_RENDER_BUMP;
+extern LLTrace::TimeBlock FTM_RENDER_MATERIALS;
+extern LLTrace::TimeBlock FTM_RENDER_FULLBRIGHT;
+extern LLTrace::TimeBlock FTM_RENDER_GLOW;
+extern LLTrace::TimeBlock FTM_STATESORT;
+extern LLTrace::TimeBlock FTM_PIPELINE;
+extern LLTrace::TimeBlock FTM_CLIENT_COPY;
 
 
 class LLPipeline
-- 
cgit v1.2.3


From 3fd68662f267a3fd96d101834b3a9563bde3f61e Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/newview/llagent.h               |  1 +
 indra/newview/llappviewer.cpp         |  4 ++--
 indra/newview/llremoteparcelrequest.h |  3 ++-
 indra/newview/llvieweroctree.cpp      | 16 ++++++++++++++++
 4 files changed, 21 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

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 <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
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<S32> 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<S32> 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.2.3


From f04fe8010ab1a0c980ecd197f37da66a7fda0ad6 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 9 Sep 2013 11:25:10 -0600
Subject: cancel redundant memory alignments for some base classes to get
 better memory performance

---
 indra/newview/llvieweroctree.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index e610db96eb..97dc1d4a0a 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -70,7 +70,7 @@ S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVect
 S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared);
 
 //defines data needed for octree of an entry
-LL_ALIGN_PREFIX(16)
+//LL_ALIGN_PREFIX(16)
 class LLViewerOctreeEntry : public LLRefCount
 {
 	friend class LLViewerOctreeEntryData;
@@ -128,10 +128,10 @@ private:
 	mutable S32		            mBinIndex;
 	mutable U32		            mVisible;	
 
-} LL_ALIGN_POSTFIX(16);
+} ;//LL_ALIGN_POSTFIX(16);
 
 //defines an abstract class for entry data
-LL_ALIGN_PREFIX(16)
+//LL_ALIGN_PREFIX(16)
 class LLViewerOctreeEntryData : public LLRefCount
 {
 protected:
@@ -178,11 +178,11 @@ protected:
 	LLPointer<LLViewerOctreeEntry>        mEntry;
 	LLViewerOctreeEntry::eEntryDataType_t mDataType;
 	static  U32                           sCurVisible; // Counter for what value of mVisible means currently visible
-}LL_ALIGN_POSTFIX(16);
+};//LL_ALIGN_POSTFIX(16);
 
 
 //defines an octree group for an octree node, which contains multiple entries.
-LL_ALIGN_PREFIX(16)
+//LL_ALIGN_PREFIX(16)
 class LLviewerOctreeGroup : public LLOctreeListener<LLViewerOctreeEntry>
 {
 	friend class LLViewerOctreeCull;
@@ -279,7 +279,7 @@ protected:
 public:
 	S32         mVisible[LLViewerCamera::NUM_CAMERAS];	
 
-}LL_ALIGN_POSTFIX(16);
+};//LL_ALIGN_POSTFIX(16);
 
 //octree group which has capability to support occlusion culling
 //LL_ALIGN_PREFIX(16)
-- 
cgit v1.2.3


From 01098f5daba77e12fe739a3c8eaa722a95b83ea9 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 9 Sep 2013 11:29:25 -0600
Subject: eliminate some redundant geometry rebuilding operations during
 teleporting

---
 indra/newview/llagent.cpp  |  1 +
 indra/newview/pipeline.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++-
 indra/newview/pipeline.h   |  1 +
 3 files changed, 55 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index a7bd628d5a..d7965c1e8f 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -4015,6 +4015,7 @@ void LLAgent::teleportCancel()
 	}
 	clearTeleportRequest();
 	gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
+	gPipeline.resetVertexBuffers();
 }
 
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 0ae9b08a4b..019b49b8fb 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2895,6 +2895,52 @@ void LLPipeline::clearRebuildGroups()
 	mGroupQ2Locked = false;
 }
 
+void LLPipeline::clearRebuildDrawables()
+{
+	// Clear all drawables on the priority build queue,
+	for (LLDrawable::drawable_list_t::iterator iter = mBuildQ1.begin();
+		 iter != mBuildQ1.end(); ++iter)
+	{
+		LLDrawable* drawablep = *iter;
+		if (drawablep && !drawablep->isDead())
+		{
+			drawablep->clearState(LLDrawable::IN_REBUILD_Q2);
+			drawablep->clearState(LLDrawable::IN_REBUILD_Q1);
+		}
+	}
+	mBuildQ1.clear();
+
+	// clear drawables on the non-priority build queue
+	for (LLDrawable::drawable_list_t::iterator iter = mBuildQ2.begin();
+		 iter != mBuildQ2.end(); ++iter)
+	{
+		LLDrawable* drawablep = *iter;
+		if (!drawablep->isDead())
+		{
+			drawablep->clearState(LLDrawable::IN_REBUILD_Q2);
+		}
+	}	
+	mBuildQ2.clear();
+	
+	//clear all moving bridges
+	for (LLDrawable::drawable_vector_t::iterator iter = mMovedBridge.begin();
+		 iter != mMovedBridge.end(); ++iter)
+	{
+		LLDrawable *drawablep = *iter;
+		drawablep->clearState(LLDrawable::EARLY_MOVE | LLDrawable::MOVE_UNDAMPED | LLDrawable::ON_MOVE_LIST | LLDrawable::ANIMATED_CHILD);
+	}
+	mMovedBridge.clear();
+
+	//clear all moving drawables
+	for (LLDrawable::drawable_vector_t::iterator iter = mMovedList.begin();
+		 iter != mMovedList.end(); ++iter)
+	{
+		LLDrawable *drawablep = *iter;
+		drawablep->clearState(LLDrawable::EARLY_MOVE | LLDrawable::MOVE_UNDAMPED | LLDrawable::ON_MOVE_LIST | LLDrawable::ANIMATED_CHILD);
+	}
+	mMovedList.clear();
+}
+
 void LLPipeline::rebuildPriorityGroups()
 {
 	LLFastTimer t(FTM_REBUILD_PRIORITY_GROUPS);
@@ -7314,7 +7360,13 @@ void LLPipeline::doResetVertexBuffers()
 			}
 		}
 	}
-	LLSpatialPartition::sTeleportRequested = FALSE;
+	if(LLSpatialPartition::sTeleportRequested)
+	{
+		LLSpatialPartition::sTeleportRequested = FALSE;
+
+		clearRebuildGroups();
+		clearRebuildDrawables();
+	}
 
 	resetDrawOrders();
 
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index b12dc3edbb..867a515cd5 100755
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -245,6 +245,7 @@ public:
 	void rebuildPriorityGroups();
 	void rebuildGroups();
 	void clearRebuildGroups();
+	void clearRebuildDrawables();
 
 	//calculate pixel area of given box from vantage point of given camera
 	static F32 calcPixelArea(LLVector3 center, LLVector3 size, LLCamera& camera);
-- 
cgit v1.2.3


From 1f9e73bbdb9c20de26f42bc33ed9c19457d43df7 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 9 Sep 2013 11:30:52 -0600
Subject: rebalance the object cache octrees.

---
 indra/newview/pipeline.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 019b49b8fb..a12a54d022 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2103,6 +2103,13 @@ void LLPipeline::updateMove()
 					part->mOctree->balance();
 				}
 			}
+
+			//balance the VO Cache tree
+			LLVOCachePartition* vo_part = region->getVOCachePartition();
+			if(vo_part)
+			{
+				vo_part->mOctree->balance();
+			}
 		}
 	}
 }
-- 
cgit v1.2.3


From a9d22b0f585cc90ba1bb94a68cc4175b3019b062 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 9 Sep 2013 11:58:52 -0600
Subject: some fix for SH-4416: Interesting: memory footprint is larger when
 loading from cache while ObjectCacheViewCullingEnabled is enabled than when
 it's disabled.

---
 indra/newview/llviewerregion.cpp | 12 ++++--------
 indra/newview/llvocache.cpp      |  5 +++++
 2 files changed, 9 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 9c038d54d5..7cc4195a3d 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1207,12 +1207,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 
 	max_update_time -= update_timer.getElapsedTimeF32();	
 
-	if(gViewerWindow->getProgressView()->getVisible())
-	{
-		//in case rendering pipeline is not started yet.
-		mImpl->mVOCachePartition->cull(*(LLViewerCamera::getInstance()), false);
-	}
-	else if(max_update_time < 0.f)
+	if(max_update_time < 0.f && !gViewerWindow->getProgressView()->getVisible())
 	{
 		return did_update;
 	}
@@ -1279,7 +1274,8 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 		return max_time;
 	}
 
-	size_t max_update = sNewObjectCreationThrottle < 0 ? mImpl->mActiveSet.size() : 64; 
+	bool unstable = sNewObjectCreationThrottle < 0;
+	size_t max_update = unstable ? mImpl->mActiveSet.size() : 64; 
 	if(!mInvisibilityCheckHistory && isViewerCameraStatic())
 	{
 		//history is clean, reduce number of checking
@@ -1299,7 +1295,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 			iter = mImpl->mActiveSet.begin();
 		}
 
-		if(!(*iter)->isRecentlyVisible() && (*iter)->mLastCameraUpdated < sLastCameraUpdated)
+		if(!(*iter)->isRecentlyVisible() && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated))
 		{
 			killObject((*iter), delete_list);
 		}
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 1cfda038a8..35af99cd42 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -636,6 +636,11 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		return 0;
 	}
 
+	if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0)
+	{
+		return 0; //no need for those cameras.
+	}
+
 	if(mCulledTime[LLViewerCamera::sCurCameraID] == LLViewerOctreeEntryData::getCurrentFrame())
 	{
 		return 0; //already culled
-- 
cgit v1.2.3


From 504c645ab6f13d0df35c714534d714e28f9e7534 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 9 Sep 2013 15:54:33 -0600
Subject: fix a login crash

---
 indra/newview/llvieweroctree.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 5e3cac260a..97dc1d4a0a 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -210,15 +210,15 @@ 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);
-	//}
+	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);
-- 
cgit v1.2.3


From 605060ea022670f4ff6f8850f79495032095b58e Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 12 Sep 2013 16:40:18 -0600
Subject: fix for SH-4477: Interesting: objects on adjacent region are not
 visible. #3 and SH-4457: Interesting: nearby content on adjacent region is
 not visible.

---
 indra/newview/llvieweroctree.cpp |  8 +++-----
 indra/newview/llvieweroctree.h   |  2 +-
 indra/newview/llvocache.cpp      | 11 ++++++-----
 3 files changed, 10 insertions(+), 11 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 1e01c0fdef..2457f15b50 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -1132,7 +1132,7 @@ static LLTrace::TimeBlock FTM_OCCLUSION_SET_BUFFER("Set Buffer");
 static LLTrace::TimeBlock FTM_OCCLUSION_DRAW_WATER("Draw Water");
 static LLTrace::TimeBlock FTM_OCCLUSION_DRAW("Draw");
 
-void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* region_agent)
+void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* shift)
 {
 	if (mSpatialPartition->isOcclusionEnabled() && LLPipeline::sUseOcclusion > 1)
 	{
@@ -1140,11 +1140,9 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector3* reg
 		LLVector4a bounds[2];
 		bounds[0] = mBounds[0];
 		bounds[1] = mBounds[1];
-		if(region_agent != NULL)
+		if(shift != NULL)
 		{
-			LLVector4a shift((*region_agent)[0], (*region_agent)[1], (*region_agent)[2]);
-			bounds[0].sub(shift);
-			bounds[1].sub(shift);
+			bounds[0].add(*shift);
 		}
 
 		// Don't cull hole/edge water, unless we have the GL_ARB_depth_clamp extension
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 97dc1d4a0a..bc3c7cbfa2 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -314,7 +314,7 @@ public:
 	void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 	void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 	void checkOcclusion(); //read back last occlusion query (if any)
-	void doOcclusion(LLCamera* camera, const LLVector3* region_agent = NULL); //issue occlusion query
+	void doOcclusion(LLCamera* camera, const LLVector4a* shift = NULL); //issue occlusion query
 	BOOL isOcclusionState(U32 state) const	{ return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }
 
 	BOOL needsUpdate();
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index f0c9546651..c2b09246e9 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -545,10 +545,10 @@ public:
 			base_group->getOctreeNode()->getParent()) //never occlusion cull the root node
 		{
 			LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
-			if(group->needsUpdate())//needs to issue new occlusion culling check.
+			if(group->needsUpdate())
 			{
-				mPartition->addOccluders(group);
-				return true;
+				//needs to issue new occlusion culling check, perform view culling check first.
+				return false;
 			}
 
 			group->checkOcclusion();
@@ -601,7 +601,7 @@ public:
 		}
 
 		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)base_group;
-		if(!group->isRecentlyVisible())//needs to issue new occlusion culling check.
+		if(group->needsUpdate() || !group->isRecentlyVisible())//needs to issue new occlusion culling check.
 		{
 			mPartition->addOccluders(group);
 			group->setVisible();
@@ -693,10 +693,11 @@ void LLVOCachePartition::processOccluders(LLCamera* camera)
 	}
 
 	LLVector3 region_agent = mRegionp->getOriginAgent();
+	LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]);
 	for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
 	{
 		LLOcclusionCullingGroup* group = *iter;
-		group->doOcclusion(camera, &region_agent);
+		group->doOcclusion(camera, &shift);
 	}	
 }
 
-- 
cgit v1.2.3


From 5c7b84c682ea0f92f3f4389b0dbe758b8cadc6eb Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 13 Sep 2013 10:49:31 -0600
Subject: fix for SH-4494: interesting: deleted objects reappear

---
 indra/newview/llviewermessage.cpp | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index ce83221d2c..2550ab34ee 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4560,9 +4560,6 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 
 static LLTrace::TimeBlock FTM_PROCESS_OBJECTS("Process Kill Objects");
 
-const U32 KILLOBJECT_DELETE_OPCODE = 0;
-
-
 void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 {
 	LL_RECORD_BLOCK_TIME(FTM_PROCESS_OBJECTS);
@@ -4577,20 +4574,12 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 		regionp = LLWorld::getInstance()->getRegion(host);
 	}
 
-	bool delete_object = false;
+	bool delete_object = LLViewerRegion::sVOCacheCullingEnabled;
 	S32	num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
 	for (S32 i = 0; i < num_objects; ++i)
 	{
 		U32	local_id;
 		mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
-		if (local_id == KILLOBJECT_DELETE_OPCODE)
-		{
-			// This local_id is invalid, but was sent by the server to flag
-			// all subsequent local_id's as objects that were actually deleted
-			// rather than unsubscribed from interestlist.
-			delete_object = true;
-			continue;
-		}
 
 		LLViewerObjectList::getUUIDFromLocal(id, local_id, ip, port); 
 		if (id == LLUUID::null)
@@ -4623,10 +4612,10 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 				gObjectList.killObject(objectp);
 			}
 
-		if(delete_object)
+			if(delete_object)
 			{
-			regionp->killCacheEntry(local_id);
-		}
+				regionp->killCacheEntry(local_id);
+			}
 
 		// We should remove the object from selection after it is marked dead by gObjectList to make LLToolGrab,
         // which is using the object, release the mouse capture correctly when the object dies.
-- 
cgit v1.2.3


From 42d66af3187994d729305fb332668610374bde30 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 13 Sep 2013 11:28:51 -0700
Subject: FIX: SH-4499 Mac generates lots of 'Entering main_loop' log spam

---
 indra/newview/llappviewer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 4eea1c873e..8f41f75c7d 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1260,11 +1260,11 @@ LLTrace::TimeBlock FTM_FRAME("Frame");
 
 bool LLAppViewer::mainLoop()
 {
-	LL_INFOS() << "Entering main_loop" << LL_ENDL;
 #ifdef LL_DARWIN
 	if (!mMainLoopInitialized)
 #endif
 	{
+        LL_INFOS() << "Entering main_loop" << LL_ENDL;
 		mMainloopTimeout = new LLWatchdogTimeout();
 		
 		//-------------------------------------------
-- 
cgit v1.2.3


From e86853db2ceb4e36e32482c88403bc1e3ee037eb Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 16 Sep 2013 21:45:48 -0600
Subject: fix to load neighboring regions faster.

---
 indra/newview/llworld.cpp | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 6a2653bc88..9009626a03 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -663,9 +663,6 @@ void LLWorld::updateVisibilities()
 
 void LLWorld::updateRegions(F32 max_update_time)
 {
-	LLTimer update_timer;
-	BOOL did_one = FALSE;
-	
 	if(LLViewerCamera::getInstance()->isChanged())
 	{
 		LLViewerRegion::sLastCameraUpdated = LLViewerOctreeEntryData::getCurrentFrame() + 1;
@@ -676,15 +673,7 @@ void LLWorld::updateRegions(F32 max_update_time)
 	for (region_list_t::iterator iter = mRegionList.begin();
 		 iter != mRegionList.end(); ++iter)
 	{
-		LLViewerRegion* regionp = *iter;
-		F32 max_time = max_update_time - update_timer.getElapsedTimeF32();
-		if (did_one && max_time <= 0.f)
-			break;
-		max_time = llmin(max_time, max_update_time*.1f);
-		if (regionp->idleUpdate(max_update_time))
-		{
-			did_one = TRUE;
-		}
+		(*iter)->idleUpdate(max_update_time);
 	}
 
 	mNumOfActiveCachedObjects = 0;
-- 
cgit v1.2.3


From 19137ac8fcdc8783b317c967a222136b42ff3ed0 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 18 Sep 2013 15:48:52 -0600
Subject: fix for SH-4500: Interesting: Some content on adjacent region not
 visible after teleport.

---
 indra/newview/llviewerregion.cpp | 27 ++++++++++++---------------
 indra/newview/llvocache.cpp      | 11 +++--------
 2 files changed, 15 insertions(+), 23 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 7cc4195a3d..abead17d6f 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1056,9 +1056,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	bool needs_update = ((cur_frame - mImpl->mLastCameraUpdate) > 5) && ((camera_origin - mImpl->mLastCameraOrigin).lengthSquared() > 10.f);	
 
 	//process visible entries
-	max_time *= 0.5f; //only use up to half available time to update entries.
-
-#if 1
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
 	{
 		LLVOCacheEntry* vo_entry = *iter;
@@ -1109,7 +1106,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 			++iter;
 		}
 	}
-#endif
 
 	//process visible groups
 	std::set< LLPointer<LLviewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
@@ -1146,7 +1142,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		mImpl->mLastCameraUpdate = cur_frame;
 	}
 
-	return 2.0f * max_time - update_timer.getElapsedTimeF32();
+	return max_time - update_timer.getElapsedTimeF32();
 }
 
 F32 LLViewerRegion::createVisibleObjects(F32 max_time)
@@ -1207,11 +1203,6 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 
 	max_update_time -= update_timer.getElapsedTimeF32();	
 
-	if(max_update_time < 0.f && !gViewerWindow->getProgressView()->getVisible())
-	{
-		return did_update;
-	}
-
 	//kill invisible objects
 	max_update_time = killInvisibleObjects(max_update_time);	
 	
@@ -1954,6 +1945,12 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 			{
 				entry->setBoundingInfo(pos, scale);
 				parent->addChild(entry);
+
+				if(parent->getGroup()) //re-insert parent to vo-cache tree because its bounding info changed.
+				{
+					removeFromVOCacheTree(parent);
+					addToVOCacheTree(parent);
+				}
 			}
 		}
 
@@ -1963,11 +1960,7 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 	//
 	//no parent
 	//
-	entry->setBoundingInfo(pos, scale);
-	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
-	{
-		addToVOCacheTree(entry);
-	}
+	entry->setBoundingInfo(pos, scale);	
 
 	if(!parent_id) //a potential parent
 	{
@@ -1990,6 +1983,10 @@ void LLViewerRegion::decodeBoundingInfo(LLVOCacheEntry* entry)
 		}
 	}
 	
+	if(!entry->getGroup() && entry->isState(LLVOCacheEntry::INACTIVE))
+	{
+		addToVOCacheTree(entry);
+	}
 	return ;
 }
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index c2b09246e9..5932fb87c1 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -258,12 +258,6 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 	if(getEntry() != NULL && isState(INACTIVE))
 	{
 		updateParentBoundingInfo(entry);
-		if(getGroup())
-		{
-			LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup();
-			group->unbound();
-			((LLVOCachePartition*)group->getSpatialPartition())->setDirty();
-		}
 	}
 }
 	
@@ -636,6 +630,8 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		return 0;
 	}
 
+	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
+
 	if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0)
 	{
 		return 0; //no need for those cameras.
@@ -651,8 +647,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	{
 		return 0; //nothing changed, skip culling
 	}
-
-	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
+	
 	mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
 
 	//localize the camera
-- 
cgit v1.2.3


From e464b855abb85e03dfec59691b7eccac27a323c4 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 19 Sep 2013 11:14:26 -0600
Subject: fix for SH-4501: Interesting: Occluded objects do not appear when
 Occluder object is deleted.

---
 indra/newview/llvocache.cpp | 32 ++++++++++++++++++++------------
 indra/newview/llvocache.h   |  3 ---
 2 files changed, 20 insertions(+), 15 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 5932fb87c1..6d2a17882a 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -491,8 +491,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 	mLODPeriod = 16;
 	mRegionp = regionp;
 	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;	
-	mDirty = FALSE;
-
+	
 	for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
 	{
 		mCulledTime[i] = 0;
@@ -501,17 +500,11 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 	new LLOcclusionCullingGroup(mOctree, this);
 }
 
-void LLVOCachePartition::setDirty()
-{
-	mDirty = TRUE;
-}
-
 void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
 {
 	llassert(entry->hasVOCacheEntry());
 
 	mOctree->insert(entry);
-	setDirty();
 }
 	
 void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
@@ -643,12 +636,28 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	}
 	mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
 
-	if(!mDirty && !mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
+	if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
 	{
-		return 0; //nothing changed, skip culling
+		static U32 hash = 0;
+
+		U32 seed = llmax(mLODPeriod >> 1, (U32)4);
+		if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
+		{
+			if(!(LLViewerOctreeEntryData::getCurrentFrame() % seed))
+			{
+				hash = (hash + 1) % seed;
+			}
+		}
+		if(LLViewerOctreeEntryData::getCurrentFrame() % seed != hash)
+		{
+			return 0; //nothing changed, reduce frequency of culling
+		}
 	}
 	
-	mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
+	if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
+	{
+		mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
+	}
 
 	//localize the camera
 	LLVector3 region_agent = mRegionp->getOriginAgent();
@@ -709,7 +718,6 @@ void LLVOCachePartition::resetOccluders()
 		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
 	}	
 	mOccludedGroups.clear();
-	mDirty = FALSE;
 	sNeedsOcclusionCheck = FALSE;
 }
 
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 1fa019cfa6..7c7b64ad5b 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -172,14 +172,11 @@ public:
 	void resetOccluders();
 	void processOccluders(LLCamera* camera);
 	
-	void setDirty();
-
 public:
 	static BOOL sNeedsOcclusionCheck;
 	//static	LLTrace::MemStatHandle	sMemStat;
 
 private:
-	BOOL  mDirty;
 	U32   mCullHistory[LLViewerCamera::NUM_CAMERAS];
 	U32   mCulledTime[LLViewerCamera::NUM_CAMERAS];
 	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
-- 
cgit v1.2.3


From 05ec5ca3d592ed7c730026582a2573d04c6e4c16 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 19 Sep 2013 20:05:53 -0700
Subject: BUILDFIX: forgot forward declaration better overrides for memclaim
 and memdisclaim of sizes added occlusion stats to stats floater stats now
 render range instead of mean

---
 indra/newview/llvieweroctree.cpp                     |  4 +---
 indra/newview/skins/default/xui/en/floater_stats.xml | 11 ++++++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 30658c57bf..47033afea3 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -42,7 +42,6 @@ BOOL LLViewerOctreeDebug::sInDebug = FALSE;
 static LLTrace::CountStatHandle<S32> 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<S32> sOcclusionQueriesInFlight("occlusion_queries_in_flight", "Number of occlusion queries waiting for results");
 
 //-----------------------------------------------------------------------------------
 //some global functions definitions
@@ -784,6 +783,7 @@ protected:
 	{
 #if LL_TRACK_PENDING_OCCLUSION_QUERIES
 		LLSpatialGroup::sPendingQueries.erase(name);
+
 #endif
 		llassert(std::find(mAvailableName.begin(), mAvailableName.end(), name) == mAvailableName.end());
 		mAvailableName.push_back(name);
@@ -1095,7 +1095,6 @@ 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
@@ -1200,7 +1199,6 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh
 					sPendingQueries.insert(mOcclusionQuery[LLViewerCamera::sCurCameraID]);
 #endif
 					add(sOcclusionQueries, 1);
-					add(sOcclusionQueriesInFlight, 1);
 
 					{
 						LL_RECORD_BLOCK_TIME(FTM_PUSH_OCCLUSION_VERTS);
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 02d1bf6a0e..fa1823ed67 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -75,7 +75,16 @@
                     label="Object Cache Hit Rate"
                     stat="object_cache_hits"
                     show_history="true"/>
-        </stat_view>
+					<stat_bar name="occlusion_queries"
+										label="Occlusion Queries Performed"
+										stat="occlusion_queries"/>
+					<stat_bar name="occluded"
+										label="Objects Occluded"
+										stat="occluded_objects"/>
+					<stat_bar name="unoccluded"
+										label="Object Unoccluded"
+										stat="unoccluded_objects"/>
+				</stat_view>
         <stat_view name="texture"
                    label="Texture"
                    follows="left|top|right"
-- 
cgit v1.2.3


From ba4f64ed7ad64deeed5f7109f33c796bae0c4423 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 20 Sep 2013 11:40:30 -0600
Subject: fix for SH-4430: Interesting: Light objects behind you are not loaded
 at login.

---
 indra/newview/llviewerregion.cpp |  8 ++--
 indra/newview/llviewerregion.h   |  2 +-
 indra/newview/llvocache.cpp      | 98 ++++++++++++++++++++++++++++++++++++++--
 indra/newview/llvocache.h        |  8 +++-
 4 files changed, 105 insertions(+), 11 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index abead17d6f..985f5a0a1f 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -963,14 +963,16 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
 	entry->setState(LLVOCacheEntry::INACTIVE);
 }
 
-void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
+bool LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
 {
 	if(mDead || group->isEmpty())
 	{
-		return;
+		return false;
 	}
-	group->setVisible();
+	
 	mImpl->mVisibleGroups.insert(group);
+
+	return true;
 }
 
 U32 LLViewerRegion::getNumOfVisibleGroups() const
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index e07c2aa8d0..b2df8d5325 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -229,7 +229,7 @@ public:
 	F32	getWidth() const						{ return mWidth; }
 
 	BOOL idleUpdate(F32 max_update_time);
-	void 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/llvocache.cpp b/indra/newview/llvocache.cpp
index 6d2a17882a..e3a3f0510b 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -490,7 +490,8 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 {
 	mLODPeriod = 16;
 	mRegionp = regionp;
-	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;	
+	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
+	mBackSlectionEnabled = -1;
 	
 	for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
 	{
@@ -517,7 +518,8 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
 class LLVOCacheOctreeCull : public LLViewerOctreeCull
 {
 public:
-	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) 
+	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, 
+		const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) 
 		: LLViewerOctreeCull(camera), 
 		  mRegionp(regionp),
 		  mPartition(part)
@@ -583,7 +585,10 @@ public:
 			!base_group->getOctreeNode()->getParent())
 		{ 
 			//no occlusion check
-			mRegionp->addVisibleGroup(base_group);
+			if(mRegionp->addVisibleGroup(base_group))
+			{
+				base_group->setVisible();
+			}
 			return;
 		}
 
@@ -603,7 +608,10 @@ public:
 		}
 		else
 		{
-			mRegionp->addVisibleGroup(base_group);
+			if(mRegionp->addVisibleGroup(base_group))
+			{
+				base_group->setVisible();
+			}
 		}
 	}
 
@@ -614,6 +622,81 @@ private:
 	bool                mUseObjectCacheOcclusion;
 };
 
+//select objects behind camera
+class LLVOCacheOctreeBackCull : public LLViewerOctreeCull
+{
+public:
+	LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp) 
+		: LLViewerOctreeCull(camera), mRegionp(regionp)
+	{
+		mLocalShift = shift;
+		mSphereRadius = 20.f; //20m
+	}
+
+	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
+	{			
+		const LLVector4a* exts = group->getExtents();
+		return backSphereCheck(exts[0], exts[1]);
+	}
+
+	virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
+	{
+		const LLVector4a* exts = group->getObjectExtents();
+		return backSphereCheck(exts[0], exts[1]);
+	}
+
+	virtual void processGroup(LLviewerOctreeGroup* base_group)
+	{
+		mRegionp->addVisibleGroup(base_group);
+		return;
+	}
+
+private:
+	//a sphere around the camera origin, including objects behind camera.
+	S32 backSphereCheck(const LLVector4a& min, const LLVector4a& max)
+	{
+		return AABBSphereIntersect(min, max, mCamera->getOrigin() - mLocalShift, mSphereRadius);
+	}
+
+private:
+	F32              mSphereRadius;
+	LLViewerRegion*  mRegionp;
+	LLVector3        mLocalShift; //shift vector from agent space to local region space.
+};
+
+void LLVOCachePartition::selectBackObjects(LLCamera &camera)
+{
+	if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
+	{
+		return;
+	}
+
+	if(mBackSlectionEnabled < 0)
+	{
+		mBackSlectionEnabled = LLVOCacheEntry::getInvisibleObjectsLiveTime() - 1;
+		mBackSlectionEnabled = llmax(mBackSlectionEnabled, (S32)1);
+	}
+
+	if(!mBackSlectionEnabled)
+	{
+		return;
+	}
+
+	//localize the camera
+	LLVector3 region_agent = mRegionp->getOriginAgent();
+	
+	LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp);
+	culler.traverse(mOctree);
+
+	mBackSlectionEnabled--;
+	if(!mRegionp->getNumOfVisibleGroups())
+	{
+		mBackSlectionEnabled = 0;
+	}
+
+	return;
+}
+
 S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 {
 	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
@@ -650,10 +733,15 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		}
 		if(LLViewerOctreeEntryData::getCurrentFrame() % seed != hash)
 		{
+			selectBackObjects(camera);//process back objects selection
 			return 0; //nothing changed, reduce frequency of culling
 		}
 	}
-	
+	else
+	{
+		mBackSlectionEnabled = -1; //reset it.
+	}
+
 	if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
 	{
 		mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 7c7b64ad5b..bab3be26b8 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -126,10 +126,9 @@ public:
 	U32  getUpdateFlags() const    {return mUpdateFlags;}
 
 	static void updateBackCullingFactors();
-
-private:
 	static U32  getInvisibleObjectsLiveTime();
 
+private:
 	void updateParentBoundingInfo(const LLVOCacheEntry* child);	
 
 public:
@@ -172,6 +171,9 @@ public:
 	void resetOccluders();
 	void processOccluders(LLCamera* camera);
 	
+private:
+	void selectBackObjects(LLCamera &camera); //select objects behind camera.
+
 public:
 	static BOOL sNeedsOcclusionCheck;
 	//static	LLTrace::MemStatHandle	sMemStat;
@@ -180,6 +182,8 @@ private:
 	U32   mCullHistory[LLViewerCamera::NUM_CAMERAS];
 	U32   mCulledTime[LLViewerCamera::NUM_CAMERAS];
 	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
+
+	S32   mBackSlectionEnabled; //enable to select back objects if > 0.
 };
 
 //
-- 
cgit v1.2.3


From 3eb226275b6c66ddf5b4aa4d40f9e8c855fb4a0f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 20 Sep 2013 11:46:51 -0600
Subject: more fix for SH-4501: Interesting: Occluded objects do not appear
 when Occluder object is deleted.

---
 indra/newview/llvocache.cpp | 7 +++----
 indra/newview/llvocache.h   | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index e3a3f0510b..dfc9ee57d8 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -492,6 +492,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 	mRegionp = regionp;
 	mPartitionType = LLViewerRegion::PARTITION_VO_CACHE;
 	mBackSlectionEnabled = -1;
+	mIdleHash = 0;
 	
 	for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
 	{
@@ -721,17 +722,15 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 
 	if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
 	{
-		static U32 hash = 0;
-
 		U32 seed = llmax(mLODPeriod >> 1, (U32)4);
 		if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
 		{
 			if(!(LLViewerOctreeEntryData::getCurrentFrame() % seed))
 			{
-				hash = (hash + 1) % seed;
+				mIdleHash = (mIdleHash + 1) % seed;
 			}
 		}
-		if(LLViewerOctreeEntryData::getCurrentFrame() % seed != hash)
+		if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash)
 		{
 			selectBackObjects(camera);//process back objects selection
 			return 0; //nothing changed, reduce frequency of culling
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index bab3be26b8..867f9ab93c 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -184,6 +184,7 @@ private:
 	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
 
 	S32   mBackSlectionEnabled; //enable to select back objects if > 0.
+	U32   mIdleHash;
 };
 
 //
-- 
cgit v1.2.3


From 0a87ffb876f3beec6bc7d192c3aba6edf9ded828 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 23 Sep 2013 16:10:13 -0700
Subject: added mem stats to floater_stats

---
 .../newview/skins/default/xui/en/floater_stats.xml | 38 +++++++---------------
 1 file changed, 12 insertions(+), 26 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index fa1823ed67..2291f81fcc 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -26,8 +26,6 @@
                     width="245" >
      <stat_view name="basic"
                  label="Basic"
-                 follows="left|top|right"
-                 show_label="true"
                  setting="OpenDebugStatBasic">
         <stat_bar name="fps"
                   label="FPS"
@@ -50,13 +48,9 @@
 
      <stat_view name="advanced"
                  label="Advanced"
-                 follows="left|top|right"
-                 show_label="true"
                  setting="OpenDebugStatAdvanced">
         <stat_view name="render"
                    label="Render"
-                   follows="left|top|right"
-                   show_label="true"
                    setting="OpenDebugStatRender">
           <stat_bar name="ktrisframe"
                     label="KTris per Frame"
@@ -86,9 +80,7 @@
 										stat="unoccluded_objects"/>
 				</stat_view>
         <stat_view name="texture"
-                   label="Texture"
-                   follows="left|top|right"
-                   show_label="true">
+                   label="Texture">
           <stat_bar name="texture_cache_hits"
                     label="Cache Hit Rate"
                     stat="texture_cache_hits"
@@ -116,11 +108,15 @@
                     label="Bound Mem"
                     stat="glboundmemstat"/>
         </stat_view>
-        
+			 <stat_view name="memory"
+									label="Memory Usage">
+				 <stat_bar name="LLView"
+                    label="LLView Memory"
+                    stat="class LLView"
+                    show_history="true"/>
+			 </stat_view>
         <stat_view name="network"
                    label="Network"
-                   follows="left|top|right"
-                   show_label="true"
                    setting="OpenDebugStatNet">
           <stat_bar name="packetsinstat"
                     label="Packets In"
@@ -164,8 +160,6 @@
 
       <stat_view name="sim"
                  label="Simulator"
-                 follows="left|top|right"
-                 show_label="true"
                  setting="OpenDebugStatSim">
         <stat_bar name="simtimedilation"
                   label="Time Dilation"
@@ -181,9 +175,7 @@
                   decimal_digits="1"
                   bar_max="45" />
         <stat_view name="physicsdetail"
-                   label="Physics Details"
-                   follows="left|top|right"
-                   show_label="true">
+                   label="Physics Details">
           <stat_bar name="physicspinnedtasks"
                     label="Pinned Objects"
                     stat="physicspinnedtasks"/>
@@ -222,9 +214,7 @@
                   stat="simscripteps"
                   unit_label="eps"/>
         <stat_view name="simpathfinding"
-                   label="Pathfinding"
-                   follows="left|top|right"
-                   show_label="true">
+                   label="Pathfinding">
           <stat_bar name="simsimaistepmsec"
                     label="AI Step Time"
                     stat="simsimaistepmsec"/>
@@ -255,9 +245,7 @@
                   stat="simtotalunackedbytes"
                   decimal_digits="1"/>
         <stat_view name="simperf"
-                   label="Time"
-                   follows="left|top|right"
-                   show_label="true">
+                   label="Time">
           <stat_bar name="simframemsec"
                     label="Total Frame Time"
                     stat="simframemsec"/>
@@ -283,9 +271,7 @@
                     label="Spare Time"
                     stat="simsparemsec"/>
           <stat_view name="timedetails"
-                     label="Time Details"
-                     follows="left|top|right"
-                     show_label="true">
+                     label="Time Details">
             <stat_bar name="simsimphysicsstepmsec"
                       label="Physics Step"
                       stat="simsimphysicsstepmsec"/>
-- 
cgit v1.2.3


From ab8f64a96754edaa68dd1ff97b9519eff4496aa6 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 24 Sep 2013 00:05:43 -0700
Subject: converted memory tracking units to KB from B added more memory
 tracking to LLFolderView and kin

---
 indra/newview/llinventorypanel.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 3276985114..6358620f0b 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -653,16 +653,16 @@ void LLInventoryPanel::idle(void* user_data)
 		EAcceptance last_accept = LLToolDragAndDrop::getInstance()->getLastAccept();
 		if (last_accept == ACCEPT_YES_SINGLE || last_accept == ACCEPT_YES_COPY_SINGLE)
 		{
-			panel->mFolderRoot->setShowSingleSelection(TRUE);
+			panel->mFolderRoot->setShowSingleSelection(true);
 		}
 		else
 		{
-			panel->mFolderRoot->setShowSingleSelection(FALSE);
+			panel->mFolderRoot->setShowSingleSelection(false);
 		}
 }
 	else
 	{
-		panel->mFolderRoot->setShowSingleSelection(FALSE);
+		panel->mFolderRoot->setShowSingleSelection(false);
 	}
 }
 
-- 
cgit v1.2.3


From 456ff3949a28542ecd89ec23b0287b55a166529f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 25 Sep 2013 16:40:05 -0600
Subject: fix for SH-4295: Interesting: Teleporting to previous location leave
 some objects invisible.

---
 indra/newview/llviewerregion.cpp | 55 ++++++++++++++++++++++++++++++++++++++++
 indra/newview/llviewerregion.h   |  2 +-
 indra/newview/llworld.cpp        | 10 ++++++++
 indra/newview/llworld.h          |  1 +
 indra/newview/pipeline.cpp       |  1 +
 5 files changed, 68 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 985f5a0a1f..24f419b4b1 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1178,6 +1178,61 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	return max_time - update_timer.getElapsedTimeF32();
 }
 
+void LLViewerRegion::clearCachedVisibleObjects()
+{
+	mImpl->mWaitingList.clear();
+	mImpl->mVisibleGroups.clear();
+
+	//clean visible entries
+	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
+	{
+		LLVOCacheEntry* entry = *iter;
+		LLVOCacheEntry* parent = getCacheEntry(entry->getParentID());
+
+		if(!entry->getParentID() || parent) //no child or parent is cache-able
+		{
+			if(parent) //has a cache-able parent
+			{
+				parent->addChild(entry);
+			}
+
+			LLVOCacheEntry::vocache_entry_set_t::iterator next_iter = iter;
+			++next_iter;
+			mImpl->mVisibleEntries.erase(iter);
+			iter = next_iter;
+		}
+		else //parent is not cache-able, leave it.
+		{
+			++iter;
+		}
+	}
+
+	//remove all visible entries.
+	mLastVisitedEntry = NULL;
+	std::vector<LLDrawable*> delete_list;
+	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
+		iter != mImpl->mActiveSet.end(); ++iter)
+	{
+		LLDrawable* drawablep = (LLDrawable*)(*iter)->getEntry()->getDrawable();
+	
+		if(drawablep && !drawablep->getParent())
+		{
+			delete_list.push_back(drawablep);
+		}
+	}
+
+	if(!delete_list.empty())
+	{
+		for(S32 i = 0; i < delete_list.size(); i++)
+		{
+			gObjectList.killObject(delete_list[i]->getVObj());
+		}
+		delete_list.clear();
+	}
+
+	return;
+}
+
 BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 {	
 	LLTimer update_timer;
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index b2df8d5325..8a375610d9 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -336,7 +336,7 @@ public:
 	//remove from object cache if the object receives a full-update or terse update
 	LLViewerObject* forceToRemoveFromCache(U32 local_id, LLViewerObject* objectp);
 	void findOrphans(U32 parent_id);
-
+	void clearCachedVisibleObjects();
 	void dumpCache();
 
 	void unpackRegionHandshake();
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 9009626a03..d600abeb0a 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -684,6 +684,16 @@ void LLWorld::updateRegions(F32 max_update_time)
 	}
 }
 
+void LLWorld::clearAllVisibleObjects()
+{
+	for (region_list_t::iterator iter = mRegionList.begin();
+		 iter != mRegionList.end(); ++iter)
+	{
+		//clear all cached visible objects.
+		(*iter)->clearCachedVisibleObjects();
+	}
+}
+
 void LLWorld::updateParticles()
 {
 	LLViewerPartSim::getInstance()->updateSimulation();
diff --git a/indra/newview/llworld.h b/indra/newview/llworld.h
index 287e41d323..b2d8418064 100755
--- a/indra/newview/llworld.h
+++ b/indra/newview/llworld.h
@@ -147,6 +147,7 @@ public:
 	void getInfo(LLSD& info);
 	U32  getNumOfActiveCachedObjects() const {return mNumOfActiveCachedObjects;}
 
+	void clearAllVisibleObjects();
 public:
 	typedef std::list<LLViewerRegion*> region_list_t;
 	const region_list_t& getRegionList() const { return mActiveRegionList; }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 38bef1f4f5..9d8aa849ba 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7371,6 +7371,7 @@ void LLPipeline::doResetVertexBuffers()
 	{
 		LLSpatialPartition::sTeleportRequested = FALSE;
 
+		LLWorld::getInstance()->clearAllVisibleObjects();
 		clearRebuildGroups();
 		clearRebuildDrawables();
 	}
-- 
cgit v1.2.3


From 053d97db1b283ca2548dc1f64756ddfc5166158f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 25 Sep 2013 19:12:35 -0700
Subject: better memory usage for LLTrace (tighter packing of recording arrays)
 removed complicated and unnecessary fast timer gapless handoff logic (it
 should be gapless anyway) improved MemTrackable API, better separation of
 shadow and footprint added memory usage stats to floater_stats.xml

---
 indra/newview/lldrawable.cpp                         |  1 -
 indra/newview/lldrawable.h                           |  1 -
 indra/newview/lltexturecache.h                       |  4 ++--
 indra/newview/lltextureview.cpp                      |  8 ++++----
 indra/newview/llviewerobject.cpp                     |  1 -
 indra/newview/llviewerobject.h                       |  1 -
 indra/newview/llvieweroctree.h                       |  2 +-
 indra/newview/llviewerprecompiledheaders.cpp         |  2 +-
 indra/newview/llvocache.cpp                          |  1 -
 indra/newview/llvocache.h                            |  1 -
 indra/newview/skins/default/xui/en/floater_stats.xml | 16 ++++++++++++++++
 11 files changed, 24 insertions(+), 14 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 1837974604..5baebab5a3 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -59,7 +59,6 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 static LLTrace::TimeBlock FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
-//LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 
 
 ////////////////////////
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 3dab496a20..a0ac417b24 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -291,7 +291,6 @@ public:
 	F32				mDistanceWRTCamera;
 
 	static F32 sCurPixelAngle; //current pixels per radian
-	//static LLTrace::MemStatHandle sMemStat;
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h
index c2a5cf9405..6ff4c44568 100755
--- a/indra/newview/lltexturecache.h
+++ b/indra/newview/lltexturecache.h
@@ -131,8 +131,8 @@ public:
 	// debug
 	S32 getNumReads() { return mReaders.size(); }
 	S32 getNumWrites() { return mWriters.size(); }
-	S64 getUsage() { return mTexturesSizeTotal; }
-	S64 getMaxUsage() { return sCacheMaxTexturesSize; }
+	S64Bytes getUsage() { return S64Bytes(mTexturesSizeTotal); }
+	S64Bytes getMaxUsage() { return S64Bytes(sCacheMaxTexturesSize); }
 	U32 getEntries() { return mHeaderEntriesInfo.mEntries; }
 	U32 getMaxEntries() { return sCacheMaxEntries; };
 	BOOL isInCache(const LLUUID& id) ;
diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp
index 3974668d09..17aebebd92 100755
--- a/indra/newview/lltextureview.cpp
+++ b/indra/newview/lltextureview.cpp
@@ -512,8 +512,8 @@ void LLGLTexMemBar::draw()
 	S32Megabytes total_mem = LLViewerTexture::sTotalTextureMemory;
 	S32Megabytes max_total_mem = LLViewerTexture::sMaxTotalTextureMem;
 	F32 discard_bias = LLViewerTexture::sDesiredDiscardBias;
-	F32 cache_usage = (F32)F32Megabytes(LLAppViewer::getTextureCache()->getUsage()).value() ;
-	F32 cache_max_usage = (F32)F32Megabytes(LLAppViewer::getTextureCache()->getMaxUsage()).value() ;
+	F32 cache_usage = F32Megabytes(LLAppViewer::getTextureCache()->getUsage()).value();
+	F32 cache_max_usage = 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;
@@ -555,8 +555,8 @@ void LLGLTexMemBar::draw()
 	LLAppViewer::getTextureFetch()->getStateStats(&cache_read, &cache_write, &res_wait);
 	
 	text = llformat("Net Tot Tex: %.1f MB Tot Obj: %.1f MB #Objs/#Cached: %d/%d Tot Htp: %d Cread: %u Cwrite: %u Rwait: %u",
-					total_texture_downloaded.value(),
-					total_object_downloaded.value(),
+					total_texture_downloaded.valueInUnits<LLUnits::Megabytes>(),
+					total_object_downloaded.valueInUnits<LLUnits::Megabytes>(),
 					total_objects, 
 					total_active_cached_objects,
 					total_http_requests,
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 2c1ab3a73b..394b11b759 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -112,7 +112,6 @@ BOOL		LLViewerObject::sMapDebug = TRUE;
 LLColor4	LLViewerObject::sEditSelectColor(	1.0f, 1.f, 0.f, 0.3f);	// Edit OK
 LLColor4	LLViewerObject::sNoEditSelectColor(	1.0f, 0.f, 0.f, 0.3f);	// Can't edit
 S32			LLViewerObject::sAxisArrowLength(50);
-//LLTrace::MemStatHandle	LLViewerObject::sMemStat("LLViewerObject");
 
 
 BOOL		LLViewerObject::sPulseEnabled(FALSE);
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index e3972ccae8..56518cca69 100755
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -661,7 +661,6 @@ public:
 	LLPointer<class LLHUDIcon> mIcon;
 
 	static			BOOL		sUseSharedDrawables;
-	//static	LLTrace::MemStatHandle	sMemStat;
 
 protected:
 	// delete an item in the inventory, but don't tell the
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index bc3c7cbfa2..6ebd1d6da1 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -135,7 +135,7 @@ private:
 class LLViewerOctreeEntryData : public LLRefCount
 {
 protected:
-	~LLViewerOctreeEntryData();
+	virtual ~LLViewerOctreeEntryData();
 
 public:
 	LLViewerOctreeEntryData(const LLViewerOctreeEntryData& rhs)
diff --git a/indra/newview/llviewerprecompiledheaders.cpp b/indra/newview/llviewerprecompiledheaders.cpp
index 307e903726..768f1f3387 100755
--- a/indra/newview/llviewerprecompiledheaders.cpp
+++ b/indra/newview/llviewerprecompiledheaders.cpp
@@ -26,7 +26,7 @@
 
 // source file that includes just the standard includes
 // newview.pch will be the pre-compiled header
-// llviewerprecompiledheaders.obj will contain the pre-compiled type information
+// llviewerprecompiledheaders.obj will contain the pre-compllviewiled type information
 
 #include "llviewerprecompiledheaders.h"
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index dfc9ee57d8..25dd1f4d07 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -38,7 +38,6 @@
 F32 LLVOCacheEntry::sBackDistanceSquared = 0.f;
 F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f;
 BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE;
-//LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 867f9ab93c..70900a7e22 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -176,7 +176,6 @@ private:
 
 public:
 	static BOOL sNeedsOcclusionCheck;
-	//static	LLTrace::MemStatHandle	sMemStat;
 
 private:
 	U32   mCullHistory[LLViewerCamera::NUM_CAMERAS];
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 2291f81fcc..f0a464dfc9 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -113,6 +113,22 @@
 				 <stat_bar name="LLView"
                     label="LLView Memory"
                     stat="class LLView"
+                    show_history="true"/>
+				 <stat_bar name="LLViewerObject"
+                    label="LLViewerObject Memory"
+                    stat="class LLViewerObject"
+                    show_history="true"/>
+					<stat_bar name="LLVOCacheEntry"
+                    label="LLVOCacheEntry Memory"
+                    stat="class LLVOCacheEntry"
+                    show_history="true"/>
+				 <stat_bar name="LLDrawable"
+                    label="LLDrawable Memory"
+                    stat="class LLDrawable"
+                    show_history="true"/>
+				 <stat_bar name="LLImage"
+                    label="LLImage Memory"
+                    stat="class LLImageBase"
                     show_history="true"/>
 			 </stat_view>
         <stat_view name="network"
-- 
cgit v1.2.3


From 9053b9020a380f95f23051ca123127519db53e29 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 26 Sep 2013 11:03:04 -0600
Subject: fix for SH-4521: Interesting viewer crash in Pipeline:RenderDrawPools

---
 indra/newview/llvieweroctree.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 47033afea3..e1684c19df 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -957,7 +957,7 @@ public:
 	{
 		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0);
 		
-		if (group->isOcclusionState(mState))
+		if (group && group->isOcclusionState(mState))
 		{
 			OctreeTraveler::traverse(n);
 		}
-- 
cgit v1.2.3


From 4db06820f0a89d480a3d5c49c26313a3bb78544d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 26 Sep 2013 11:34:07 -0700
Subject: fix for display of joystick statbar monitors

---
 indra/newview/llfloaterjoystick.cpp                     | 10 +++++-----
 indra/newview/skins/default/xui/en/floater_joystick.xml |  5 +++++
 2 files changed, 10 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp
index adcecbbb7a..b7fff6cae3 100755
--- a/indra/newview/llfloaterjoystick.cpp
+++ b/indra/newview/llfloaterjoystick.cpp
@@ -42,20 +42,20 @@
 #include "llviewerjoystick.h"
 #include "llcheckboxctrl.h"
 
-static LLTrace::SampleStatHandle<>	sJoystickAxis1("Joystick axis 1"),
+static LLTrace::SampleStatHandle<>	sJoystickAxis0("Joystick axis 0"),
+									sJoystickAxis1("Joystick axis 1"),
 									sJoystickAxis2("Joystick axis 2"),
 									sJoystickAxis3("Joystick axis 3"),
 									sJoystickAxis4("Joystick axis 4"),
-									sJoystickAxis5("Joystick axis 5"),
-									sJoystickAxis6("Joystick axis 6");
+									sJoystickAxis5("Joystick axis 5");
 static LLTrace::SampleStatHandle<>* sJoystickAxes[6] = 
 {
+	&sJoystickAxis0,
 	&sJoystickAxis1,
 	&sJoystickAxis2,
 	&sJoystickAxis3,
 	&sJoystickAxis4,
-	&sJoystickAxis5,
-	&sJoystickAxis6
+	&sJoystickAxis5
 };
 
 LLFloaterJoystick::LLFloaterJoystick(const LLSD& data)
diff --git a/indra/newview/skins/default/xui/en/floater_joystick.xml b/indra/newview/skins/default/xui/en/floater_joystick.xml
index 59f6a9434c..ca165d1a29 100755
--- a/indra/newview/skins/default/xui/en/floater_joystick.xml
+++ b/indra/newview/skins/default/xui/en/floater_joystick.xml
@@ -208,6 +208,7 @@
         <stat_bar
          bar_max="2"
          bar_min="-2"
+				 show_bar="true"
          height="0"
          label="Axis 0"
          label_spacing="1"
@@ -220,6 +221,7 @@
         <stat_bar
          bar_max="2"
          bar_min="-2"
+				 show_bar="true"
          label="Axis 1"
          label_spacing="1"
          layout="topleft"
@@ -228,6 +230,7 @@
         <stat_bar
          bar_max="2"
          bar_min="-2"
+				 show_bar="true"
          label="Axis 2"
          label_spacing="1"
          layout="topleft"
@@ -236,6 +239,7 @@
         <stat_bar
          bar_max="2"
          bar_min="-2"
+				 show_bar="true"
          label="Axis 3"
          label_spacing="1"
          layout="topleft"
@@ -244,6 +248,7 @@
         <stat_bar
          bar_max="2"
          bar_min="-2"
+				 show_bar="true"
          label="Axis 4"
          label_spacing="1"
          layout="topleft"
-- 
cgit v1.2.3


From 5cbd814d497c6772424cc555812da620370db37b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 26 Sep 2013 17:12:02 -0600
Subject: fix for SH-4523: interesting: viewer sometimes doesn't save
 objectcache file on disconnect from region

---
 indra/newview/llvocache.cpp | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 25dd1f4d07..91a5d4f973 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -312,11 +312,6 @@ void LLVOCacheEntry::dump() const
 
 BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 {
-	if(!mEntry)
-	{
-		return FALSE;
-	}
-
 	BOOL success;
 	success = check_write(apr_file, (void*)&mLocalID, sizeof(U32));
 	if(success)
@@ -1191,7 +1186,7 @@ void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::voca
 	
 				if(success)
 				{
-					for (S32 i = 0; i < num_entries; i++)
+					for (S32 i = 0; i < num_entries && apr_file.eof() != APR_EOF; i++)
 					{
 						LLPointer<LLVOCacheEntry> entry = new LLVOCacheEntry(&apr_file);
 						if (!entry->getLocalID())
@@ -1308,6 +1303,10 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 				if(!removal_enabled || iter->second->isTouched())
 				{
 					success = iter->second->writeToFile(&apr_file) ;
+					if(!success)
+					{
+						break;
+					}
 				}
 			}
 		}
@@ -1316,7 +1315,6 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry:
 	if(!success)
 	{
 		removeEntry(entry) ;
-
 	}
 
 	return ;
-- 
cgit v1.2.3


From 2fad2cc7365803b63bfe2466da2558182a1c25b9 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 26 Sep 2013 22:28:21 -0600
Subject: more optimization for memory footprint.

---
 indra/newview/llviewerregion.cpp |  7 ++++---
 indra/newview/llvocache.cpp      | 28 +++++++++-------------------
 indra/newview/llvocache.h        |  7 ++++---
 3 files changed, 17 insertions(+), 25 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 24f419b4b1..18232e75c9 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1303,6 +1303,9 @@ void LLViewerRegion::calcNewObjectCreationThrottle()
 			}
 		}
 	}
+
+	//update some LLVOCacheEntry debug setting factors.
+	LLVOCacheEntry::updateDebugSettings();
 }
 
 BOOL LLViewerRegion::isViewerCameraStatic()
@@ -1332,9 +1335,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 	
 	std::vector<LLDrawable*> delete_list;
 	S32 update_counter = llmin(max_update, mImpl->mActiveSet.size());
-	LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(mLastVisitedEntry);	
-	
-	LLVOCacheEntry::updateBackCullingFactors();
+	LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.upper_bound(mLastVisitedEntry);		
 
 	for(; update_counter > 0; --update_counter, ++iter)
 	{	
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 91a5d4f973..7ba0c31ffc 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -37,6 +37,7 @@
 
 F32 LLVOCacheEntry::sBackDistanceSquared = 0.f;
 F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f;
+U32 LLVOCacheEntry::sMinFrameRange = 0;
 BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE;
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
@@ -53,14 +54,6 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes)
 //---------------------------------------------------------------------------
 // LLVOCacheEntry
 //---------------------------------------------------------------------------
-//return number of frames invisible objects should stay in memory
-//static 
-U32 LLVOCacheEntry::getInvisibleObjectsLiveTime()
-{
-	static LLCachedControl<U32> inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime");
-
-	return inv_obj_time - 1; //make 0 to be the maximum 
-}
 
 LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &dp)
 	: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLVOCACHEENTRY),
@@ -78,7 +71,6 @@ LLVOCacheEntry::LLVOCacheEntry(U32 local_id, U32 crc, LLDataPackerBinaryBuffer &
 	mBuffer = new U8[dp.getBufferSize()];
 	mDP.assignBuffer(mBuffer, dp.getBufferSize());
 	mDP = dp;
-	mMinFrameRange = getInvisibleObjectsLiveTime();
 }
 
 LLVOCacheEntry::LLVOCacheEntry()
@@ -96,7 +88,6 @@ LLVOCacheEntry::LLVOCacheEntry()
 	mParentID(0)
 {
 	mDP.assignBuffer(mBuffer, 0);
-	mMinFrameRange = getInvisibleObjectsLiveTime();
 }
 
 LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
@@ -111,7 +102,6 @@ LLVOCacheEntry::LLVOCacheEntry(LLAPRFile* apr_file)
 	S32 size = -1;
 	BOOL success;
 
-	mMinFrameRange = getInvisibleObjectsLiveTime();
 	mDP.assignBuffer(mBuffer, 0);
 	
 	success = check_read(apr_file, &mLocalID, sizeof(U32));
@@ -222,7 +212,7 @@ void LLVOCacheEntry::setState(U32 state)
 
 	if(getState() == ACTIVE)
 	{
-		const S32 MIN_INTERVAL = 64 + mMinFrameRange;
+		const S32 MIN_INTERVAL = 64 + sMinFrameRange;
 		U32 last_visible = getVisible();
 		
 		setVisible();
@@ -345,7 +335,7 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 }
 
 //static 
-void LLVOCacheEntry::updateBackCullingFactors()
+void LLVOCacheEntry::updateDebugSettings()
 {
 	//distance to keep objects = back_dist_factor * draw_distance
 	static LLCachedControl<F32> back_dist_factor(gSavedSettings,"BackDistanceFactor");
@@ -353,6 +343,11 @@ void LLVOCacheEntry::updateBackCullingFactors()
 	//squared tan(projection angle of the bbox), default is 10 (degree)
 	static LLCachedControl<F32> squared_back_angle(gSavedSettings,"BackProjectionAngleSquared");
 
+	//the number of frames invisible objects stay in memory
+	static LLCachedControl<U32> inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime");
+
+	sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum 
+
 	sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance;
 	sBackDistanceSquared *= sBackDistanceSquared;
 
@@ -363,11 +358,6 @@ bool LLVOCacheEntry::isRecentlyVisible() const
 {
 	bool vis = LLViewerOctreeEntryData::isRecentlyVisible();
 
-	if(!vis)
-	{
-		vis = (sCurVisible - getVisible() < mMinFrameRange);
-	}
-
 	//combination of projected area and squared distance
 	if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) 
 	{
@@ -668,7 +658,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera)
 
 	if(mBackSlectionEnabled < 0)
 	{
-		mBackSlectionEnabled = LLVOCacheEntry::getInvisibleObjectsLiveTime() - 1;
+		mBackSlectionEnabled = LLVOCacheEntry::sMinFrameRange - 1;
 		mBackSlectionEnabled = llmax(mBackSlectionEnabled, (S32)1);
 	}
 
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 70900a7e22..cc755b6231 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -125,8 +125,7 @@ public:
 	void setUpdateFlags(U32 flags) {mUpdateFlags = flags;}
 	U32  getUpdateFlags() const    {return mUpdateFlags;}
 
-	static void updateBackCullingFactors();
-	static U32  getInvisibleObjectsLiveTime();
+	static void updateDebugSettings();
 
 private:
 	void updateParentBoundingInfo(const LLVOCacheEntry* child);	
@@ -149,7 +148,6 @@ protected:
 	U8							*mBuffer;
 
 	F32                         mSceneContrib; //projected scene contributuion of this object.
-	U32                         mMinFrameRange;
 	U32                         mState; //high 16 bits reserved for special use.
 	std::vector<LLVOCacheEntry*> mChildrenList; //children entries in a linked set.
 
@@ -157,6 +155,9 @@ protected:
 
 	static F32                  sBackDistanceSquared;
 	static F32                  sBackAngleTanSquared;
+
+public:
+	static U32                  sMinFrameRange;
 };
 
 class LLVOCachePartition : public LLViewerOctreePartition, public LLTrace::MemTrackable<LLVOCachePartition>
-- 
cgit v1.2.3


From e0a443f5a6b76fd1ab5ffaa8e7a1941d47c80f4f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 27 Sep 2013 11:18:39 -0700
Subject: BUILDFIX: fix for mac builds also, fixed alignment of tick labels on
 stat bars

---
 indra/newview/llappviewer.cpp                           | 1 +
 indra/newview/skins/default/xui/en/floater_joystick.xml | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 337ce22eac..1ea428ff03 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -3233,6 +3233,7 @@ bool LLAppViewer::initWindow()
 	//gViewerWindow->getWindow()->show();
 
 	LL_INFOS("AppInit") << "Window initialization done." << LL_ENDL;
+
 	return true;
 }
 
diff --git a/indra/newview/skins/default/xui/en/floater_joystick.xml b/indra/newview/skins/default/xui/en/floater_joystick.xml
index ca165d1a29..259acccb68 100755
--- a/indra/newview/skins/default/xui/en/floater_joystick.xml
+++ b/indra/newview/skins/default/xui/en/floater_joystick.xml
@@ -197,19 +197,18 @@
      name="JoystickFlycamEnabled"
      width="60" />
     <stat_view
-     height="250"
+     height="270"
      label="Joystick Monitor"
      layout="topleft"
      left="359"
      name="axis_view"
      show_label="true"
-     top="142"
+     top="135"
      width="200">
         <stat_bar
          bar_max="2"
          bar_min="-2"
 				 show_bar="true"
-         height="0"
          label="Axis 0"
          label_spacing="1"
          layout="topleft"
@@ -258,6 +257,7 @@
          bar_max="2"
          bar_min="-2"
          label="Axis 5"
+				 show_bar="true"				 
          label_spacing="1"
          layout="topleft"
          name="axis5"
-- 
cgit v1.2.3


From a5a1b81af28b16406687df3550730a436155589f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 1 Oct 2013 10:56:30 -0600
Subject: fix for SH-4521: Interesting viewer crash in Pipeline:RenderDrawPools

---
 indra/newview/llvieweroctree.cpp | 20 +++++++++++++++++---
 indra/newview/llviewerregion.cpp |  3 +++
 2 files changed, 20 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index e1684c19df..e8eba43242 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -809,7 +809,14 @@ class LLSpatialSetOcclusionState : public OctreeTraveler
 public:
 	U32 mState;
 	LLSpatialSetOcclusionState(U32 state) : mState(state) { }
-	virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->setOcclusionState(mState); }	
+	virtual void visit(const OctreeNode* branch) 
+	{ 
+		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)branch->getListener(0);
+		if(group)
+		{
+			group->setOcclusionState(mState); 
+		}
+	}
 };
 
 class LLSpatialSetOcclusionStateDiff : public LLSpatialSetOcclusionState
@@ -821,7 +828,7 @@ public:
 	{
 		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*) n->getListener(0);
 		
-		if (!group->isOcclusionState(mState))
+		if (group && !group->isOcclusionState(mState))
 		{
 			OctreeTraveler::traverse(n);
 		}
@@ -945,7 +952,14 @@ public:
 	U32 mState;
 	
 	LLSpatialClearOcclusionState(U32 state) : mState(state) { }
-	virtual void visit(const OctreeNode* branch) { ((LLOcclusionCullingGroup*) branch->getListener(0))->clearOcclusionState(mState); }
+	virtual void visit(const OctreeNode* branch) 
+	{ 
+		LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)branch->getListener(0);
+		if(group)
+		{
+			group->clearOcclusionState(mState); 
+		}
+	}
 };
 
 class LLSpatialClearOcclusionStateDiff : public LLSpatialClearOcclusionState
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 18232e75c9..0c2c2365c7 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1183,6 +1183,9 @@ void LLViewerRegion::clearCachedVisibleObjects()
 	mImpl->mWaitingList.clear();
 	mImpl->mVisibleGroups.clear();
 
+	//reset all occluders
+	mImpl->mVOCachePartition->resetOccluders();
+
 	//clean visible entries
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
 	{
-- 
cgit v1.2.3


From 12f0f8cb72f789e21b01b45063dcc5f1f5292087 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/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 +++++++++++++---------
 6 files changed, 40 insertions(+), 22 deletions(-)

(limited to 'indra/newview')

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, 16>("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<LLDrawable, 16>
 {
 public:
-	LLDrawable(const LLDrawable& rhs) : LLViewerOctreeEntryData(rhs)
+	LLDrawable(const LLDrawable& rhs) 
+	:	LLTrace::MemTrackable<LLDrawable, 16>("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>("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, 16>("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, 16>("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, 16>("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>("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 @@
 			 <stat_view name="memory"
 									label="Memory Usage">
 				 <stat_bar name="LLView"
-                    label="LLView Memory"
-                    stat="class LLView"
-                    show_history="true"/>
+                    label="UI"
+                    stat="LLView"/>
+				 <stat_bar name="LLFontFreetype"
+                    label="Fonts"
+                    stat="LLFontFreetype"/>
+				 <stat_bar name="LLInventoryObject"
+                    label="Inventory"
+                    stat="LLInventoryObject"/>
 				 <stat_bar name="LLViewerObject"
-                    label="LLViewerObject Memory"
-                    stat="class LLViewerObject"
-                    show_history="true"/>
+                    label="Viewer Objects"
+                    stat="LLViewerObject"/>
 					<stat_bar name="LLVOCacheEntry"
-                    label="LLVOCacheEntry Memory"
-                    stat="class LLVOCacheEntry"
-                    show_history="true"/>
+                    label="Viewer Object Cache"
+                    stat="LLVOCacheEntry"/>
 				 <stat_bar name="LLDrawable"
-                    label="LLDrawable Memory"
-                    stat="class LLDrawable"
-                    show_history="true"/>
+                    label="Drawables"
+                    stat="LLDrawable"/>
 				 <stat_bar name="LLImage"
-                    label="LLImage Memory"
-                    stat="class LLImageBase"
-                    show_history="true"/>
+                    label="Image Data"
+                    stat="LLImage"/>
+				 <stat_bar name="LLImageGL"
+                    label="GL Image Data"
+                    stat="LLImageGL"/>
+				 <stat_bar name="LLVertexBuffer"
+                    label="Vertex Buffers"
+                    stat="LLVertexBuffer"/>
 			 </stat_view>
         <stat_view name="network"
                    label="Network"
-- 
cgit v1.2.3


From 9bae912308a75cc1ceaec49d28b50f7119ec02ba Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 1 Oct 2013 17:18:35 -0700
Subject: BUILDFIX: old style fast timer use, broken unit test

---
 indra/newview/llscenemonitor.cpp |  4 ++--
 indra/newview/pipeline.cpp       | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 429d6a9258..c1ebd1f435 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -202,7 +202,7 @@ LLRenderTarget& LLSceneMonitor::getCaptureTarget()
 	
 	if(cur_target->getWidth() != width || cur_target->getHeight() != height) //size changed
 	{
-		cur_target->resize(width, height, GL_RGB);
+		cur_target->resize(width, height);
 	}
 
 	// we're promising the target exists
@@ -366,7 +366,7 @@ void LLSceneMonitor::compare()
 	else if(mDiff->getWidth() != width || mDiff->getHeight() != height)
 	{
 		LL_RECORD_BLOCK_TIME(FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE);
-		mDiff->resize(width, height, GL_RGBA);
+		mDiff->resize(width, height);
 		generateDitheringTexture(width, height);
 	}
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 1804f6eb64..52e9585029 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -9046,7 +9046,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 	}
 
 	{
-		LLFastTimer ftm(FTM_RENDER_DEFERRED);
+		LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED);
 
 		LLViewerCamera* camera = LLViewerCamera::getInstance();
 
@@ -9103,7 +9103,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 		{
 			mDeferredLight.bindTarget();
 			{ //paint shadow/SSAO light map (direct lighting lightmap)
-				LLFastTimer ftm(FTM_SUN_SHADOW);
+				LL_RECORD_BLOCK_TIME(FTM_SUN_SHADOW);
 				bindDeferredShader(gDeferredSunProgram);
 				mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
 				glClearColor(1,1,1,1);
@@ -9161,7 +9161,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 		
 		if (RenderDeferredAtmospheric)
 		{ //apply sunlight contribution 
-			LLFastTimer ftm(FTM_ATMOSPHERICS);
+			LL_RECORD_BLOCK_TIME(FTM_ATMOSPHERICS);
 			bindDeferredShader(gDeferredSoftenProgram);	
 			{
 				LLGLDepthTest depth(GL_FALSE);
@@ -9298,7 +9298,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 							col.mV[1] = powf(col.mV[1], 2.2f);
 							col.mV[2] = powf(col.mV[2], 2.2f);*/
 							
-							LLFastTimer ftm(FTM_LOCAL_LIGHTS);
+							LL_RECORD_BLOCK_TIME(FTM_LOCAL_LIGHTS);
 							gDeferredLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c);
 							gDeferredLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s);
 							gDeferredLightProgram.uniform3fv(LLShaderMgr::DIFFUSE_COLOR, 1, col.mV);
@@ -9339,7 +9339,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 
 				for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter)
 				{
-					LLFastTimer ftm(FTM_PROJECTORS);
+					LL_RECORD_BLOCK_TIME(FTM_PROJECTORS);
 					LLDrawable* drawablep = *iter;
 
 					LLVOVolume* volume = drawablep->getVOVolume();
@@ -9396,7 +9396,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 
 				while (!fullscreen_lights.empty())
 				{
-					LLFastTimer ftm(FTM_FULLSCREEN_LIGHTS);
+					LL_RECORD_BLOCK_TIME(FTM_FULLSCREEN_LIGHTS);
 					light[count] = fullscreen_lights.front();
 					fullscreen_lights.pop_front();
 					col[count] = light_colors.front();
@@ -9434,7 +9434,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
 
 				for (LLDrawable::drawable_list_t::iterator iter = fullscreen_spot_lights.begin(); iter != fullscreen_spot_lights.end(); ++iter)
 				{
-					LLFastTimer ftm(FTM_PROJECTORS);
+					LL_RECORD_BLOCK_TIME(FTM_PROJECTORS);
 					LLDrawable* drawablep = *iter;
 					
 					LLVOVolume* volume = drawablep->getVOVolume();
-- 
cgit v1.2.3


From 50c8c0fc7869f3babdfd1bb6c8dd72eefdba812d Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 2 Oct 2013 17:55:16 -0600
Subject: fix for SH-4521: Interesting viewer crash in Pipeline:RenderDrawPools

---
 indra/newview/llvieweroctree.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 6ebd1d6da1..174af5e22f 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -83,7 +83,9 @@ public:
 		NUM_DATA_TYPE
 	}eEntryDataType_t;
 
-	~LLViewerOctreeEntry();
+protected:
+	virtual ~LLViewerOctreeEntry();
+
 public:
 	LLViewerOctreeEntry();
 	
@@ -187,7 +189,7 @@ class LLviewerOctreeGroup : public LLOctreeListener<LLViewerOctreeEntry>
 {
 	friend class LLViewerOctreeCull;
 protected:
-	~LLviewerOctreeGroup();
+	virtual ~LLviewerOctreeGroup();
 
 public:	
 	enum
@@ -303,13 +305,15 @@ public:
 		STATE_MODE_ALL_CAMERAS,		//used for occlusion state, set state for all cameras
 	} eSetStateMode;
 
+protected:
+	virtual ~LLOcclusionCullingGroup();
+
 public:
 	LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part);
 	LLOcclusionCullingGroup(const LLOcclusionCullingGroup& rhs) : LLviewerOctreeGroup(rhs)
 	{
 		*this = rhs;
-	}
-	~LLOcclusionCullingGroup();
+	}	
 
 	void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
 	void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
-- 
cgit v1.2.3


From da8ac532072d5f054d30e46021b429fa72c3ab66 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 2 Oct 2013 17:55:37 -0600
Subject: more for SH-4521: Interesting viewer crash in
 Pipeline:RenderDrawPools

---
 indra/newview/llvocache.cpp | 49 +++++++++++++++++++++++++++++++++++++--------
 indra/newview/llvocache.h   | 17 ++++++++++++++--
 2 files changed, 56 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 7ba0c31ffc..5a2f477f19 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -470,6 +470,31 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child)
 //-------------------------------------------------------------------
 //LLVOCachePartition
 //-------------------------------------------------------------------
+LLVOCacheGroup::~LLVOCacheGroup()
+{
+	if(mOcclusionState[0] & ACTIVE_OCCLUSION)
+	{
+		((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this);
+	}
+}
+
+//virtual
+void LLVOCacheGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child)
+{
+	if (child->getListenerCount() == 0)
+	{
+		new LLVOCacheGroup(child, mSpatialPartition);
+	}
+	else
+	{
+		OCT_ERRS << "LLVOCacheGroup redundancy detected." << LL_ENDL;
+	}
+
+	unbound();
+	
+	((LLviewerOctreeGroup*)child->getListener(0))->unbound();
+}
+
 LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 {
 	mLODPeriod = 16;
@@ -483,7 +508,7 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 		mCulledTime[i] = 0;
 		mCullHistory[i] = -1;
 	}
-	new LLOcclusionCullingGroup(mOctree, this);
+	new LLVOCacheGroup(mOctree, this);
 }
 
 void LLVOCachePartition::addEntry(LLViewerOctreeEntry* entry)
@@ -751,11 +776,11 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 
 void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
 {
-	LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)gp;
+	LLVOCacheGroup* group = (LLVOCacheGroup*)gp;
 
 	if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
 	{
-		group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+		group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS);
 		mOccludedGroups.insert(group);
 	}
 }
@@ -769,9 +794,9 @@ void LLVOCachePartition::processOccluders(LLCamera* camera)
 
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]);
-	for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
+	for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
 	{
-		LLOcclusionCullingGroup* group = *iter;
+		LLVOCacheGroup* group = *iter;
 		group->doOcclusion(camera, &shift);
 	}	
 }
@@ -783,15 +808,23 @@ void LLVOCachePartition::resetOccluders()
 		return;
 	}
 
-	for(std::set<LLOcclusionCullingGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
+	for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
 	{
-		LLOcclusionCullingGroup* group = *iter;
-		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+		LLVOCacheGroup* group = *iter;
+		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS);
 	}	
 	mOccludedGroups.clear();
 	sNeedsOcclusionCheck = FALSE;
 }
 
+void LLVOCachePartition::removeOccluder(LLVOCacheGroup* group)
+{
+	if(mOccludedGroups.empty())
+	{
+		return;
+	}
+	mOccludedGroups.erase(group);
+}
 //-------------------------------------------------------------------
 //LLVOCache
 //-------------------------------------------------------------------
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index cc755b6231..16ed05dc94 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -160,6 +160,18 @@ public:
 	static U32                  sMinFrameRange;
 };
 
+class LLVOCacheGroup : public LLOcclusionCullingGroup
+{
+public:
+	LLVOCacheGroup(OctreeNode* node, LLViewerOctreePartition* part) : LLOcclusionCullingGroup(node, part){}	
+
+	//virtual
+	void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
+
+protected:
+	virtual ~LLVOCacheGroup();
+};
+
 class LLVOCachePartition : public LLViewerOctreePartition, public LLTrace::MemTrackable<LLVOCachePartition>
 {
 public:
@@ -171,7 +183,8 @@ public:
 	void addOccluders(LLviewerOctreeGroup* gp);
 	void resetOccluders();
 	void processOccluders(LLCamera* camera);
-	
+	void removeOccluder(LLVOCacheGroup* group);
+
 private:
 	void selectBackObjects(LLCamera &camera); //select objects behind camera.
 
@@ -181,7 +194,7 @@ public:
 private:
 	U32   mCullHistory[LLViewerCamera::NUM_CAMERAS];
 	U32   mCulledTime[LLViewerCamera::NUM_CAMERAS];
-	std::set<LLOcclusionCullingGroup*> mOccludedGroups;
+	std::set<LLVOCacheGroup*> mOccludedGroups;
 
 	S32   mBackSlectionEnabled; //enable to select back objects if > 0.
 	U32   mIdleHash;
-- 
cgit v1.2.3


From 754e8752a9b9a2e75d425a10cb8a0a6f85ad4bf5 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 3 Oct 2013 14:30:34 -0700
Subject: added initial memory usage tracking for lltrace

---
 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 +++
 4 files changed, 34 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

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 @@
 	  <key>Value</key>
 	  <string>Female Shape &amp; Outfit</string>
 	</map>
+	<key>DefaultLoginLocation</key>
+	<map>
+		<key>Comment</key>
+		<string>Startup destination default (if not specified on command line)</string>
+		<key>Persist</key>
+		<integer>1</integer>
+		<key>Type</key>
+		<string>String</string>
+		<key>Value</key>
+		<string/>
+	</map>
 	<key>DefaultMaleAvatar</key>
 	<map>
 	  <key>Comment</key>
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 @@
         </stat_view>
 			 <stat_view name="memory"
 									label="Memory Usage">
+				 <stat_bar name="LLTrace"
+                    label="LLTrace"
+                    stat="LLTrace"/>
 				 <stat_bar name="LLView"
                     label="UI"
                     stat="LLView"/>
-- 
cgit v1.2.3


From eeb5fb6d35fbc1782dc927ce9fa7357d93b8cc54 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 3 Oct 2013 15:36:23 -0600
Subject: Make the region hand shake flag bit of empry cache independent.

---
 indra/newview/llviewerregion.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 99db71c2ee..6e9f649d23 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2483,11 +2483,11 @@ void LLViewerRegion::unpackRegionHandshake()
 	U32 flags = 0;
 	if(sVOCacheCullingEnabled)
 	{
-		flags = 0x00000001; //set the bit 0 to be 1 to ask sim to send all cacheable objects.
-		if(mImpl->mCacheMap.empty())
-		{
-			flags |= 0x00000002; //set the bit 1 to be 1 to tell sim the cache file is empty, no need to send cache probes.
-		}
+		flags |= 0x00000001; //set the bit 0 to be 1 to ask sim to send all cacheable objects.		
+	}
+	if(mImpl->mCacheMap.empty())
+	{
+		flags |= 0x00000002; //set the bit 1 to be 1 to tell sim the cache file is empty, no need to send cache probes.
 	}
 	msg->addU32("Flags", flags );
 	msg->sendReliable(host);
-- 
cgit v1.2.3


From c2521e41d794c53cd6f0cedcff17ca97737debe5 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 3 Oct 2013 15:40:09 -0600
Subject: change debug setting name "ObjectCacheViewCullingEnabled" to
 "RequestFullRegionCache"

---
 indra/newview/app_settings/settings.xml | 4 ++--
 indra/newview/llworld.cpp               | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 051cf6d43e..305aaf2a3a 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -6868,10 +6868,10 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
-    <key>ObjectCacheViewCullingEnabled</key>
+    <key>RequestFullRegionCache</key>
     <map>
       <key>Comment</key>
-      <string>Enable the object cache view culling. Needs to restart viewer.</string>
+      <string>If set, ask sim to send full region object cache. Needs to restart viewer.</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index d600abeb0a..f283cdb4b8 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -110,7 +110,7 @@ LLWorld::LLWorld() :
 	gGL.getTexUnit(0)->bind(mDefaultWaterTexturep);
 	mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP);
 
-	LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled") && gSavedSettings.getBOOL("ObjectCacheEnabled");
+	LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("RequestFullRegionCache") && gSavedSettings.getBOOL("ObjectCacheEnabled");
 }
 
 
-- 
cgit v1.2.3


From 9ae025f8ee8688b25678a243ba19f1398de08060 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 3 Oct 2013 16:21:54 -0600
Subject: add a debug setting: "BackShpereCullingRadius"

---
 indra/newview/app_settings/settings.xml | 11 +++++++++++
 indra/newview/llvocache.cpp             | 11 ++++++-----
 indra/newview/llvocache.h               |  2 +-
 3 files changed, 18 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 305aaf2a3a..14e96a06cc 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -765,6 +765,17 @@
       <key>Value</key>
       <real>0.0311</real>
     </map>
+    <key>BackShpereCullingRadius</key>
+    <map>
+      <key>Comment</key>
+      <string>Radius of back sphere in meters, objects behind camera but within this radius are loaded for rendering</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>20.0</real>
+    </map>
     <key>BottomPanelNew</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 20e69cbea9..ada412be8c 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -640,11 +640,11 @@ private:
 class LLVOCacheOctreeBackCull : public LLViewerOctreeCull
 {
 public:
-	LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp) 
+	LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius) 
 		: LLViewerOctreeCull(camera), mRegionp(regionp)
 	{
 		mLocalShift = shift;
-		mSphereRadius = 20.f; //20m
+		mSphereRadius = back_sphere_radius;
 	}
 
 	virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
@@ -678,7 +678,7 @@ private:
 	LLVector3        mLocalShift; //shift vector from agent space to local region space.
 };
 
-void LLVOCachePartition::selectBackObjects(LLCamera &camera)
+void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius)
 {
 	if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
@@ -699,7 +699,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera)
 	//localize the camera
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	
-	LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp);
+	LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius);
 	culler.traverse(mOctree);
 
 	mBackSlectionEnabled--;
@@ -714,6 +714,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera)
 S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 {
 	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
+	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");
 	
 	if(!LLViewerRegion::sVOCacheCullingEnabled)
 	{
@@ -745,7 +746,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		}
 		if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash)
 		{
-			selectBackObjects(camera);//process back objects selection
+			selectBackObjects(camera, back_sphere_radius);//process back objects selection
 			return 0; //nothing changed, reduce frequency of culling
 		}
 	}
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 16ed05dc94..b58bb3d499 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -186,7 +186,7 @@ public:
 	void removeOccluder(LLVOCacheGroup* group);
 
 private:
-	void selectBackObjects(LLCamera &camera); //select objects behind camera.
+	void selectBackObjects(LLCamera &camera, F32 back_sphere_radius); //select objects behind camera.
 
 public:
 	static BOOL sNeedsOcclusionCheck;
-- 
cgit v1.2.3


From f8a85003ddd4bee1ae00fc329c1c1d66d6100cbd Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 3 Oct 2013 19:04:51 -0700
Subject: more memory optimizations of lltrace

---
 indra/newview/llfasttimerview.cpp |  2 +-
 indra/newview/llfasttimerview.h   | 12 ++++++------
 indra/newview/llstartup.cpp       |  4 ----
 3 files changed, 7 insertions(+), 11 deletions(-)

(limited to 'indra/newview')

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<TimeBlock*> 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.2.3


From b0aa408a665ce61ff374f99e421812482fe53848 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 4 Oct 2013 11:09:29 -0600
Subject: fix for SH-4544: Interesting: Shadows from platforms above the camera
 flicker

---
 indra/newview/llspatialpartition.cpp | 2 +-
 indra/newview/llvieweroctree.cpp     | 8 ++++++++
 indra/newview/llvieweroctree.h       | 4 +++-
 indra/newview/llvocache.cpp          | 6 ++++++
 4 files changed, 18 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 0fbe1578cf..50576b7a2c 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1105,7 +1105,7 @@ public:
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
 		if (group->needsUpdate() ||
-			group->mVisible[LLViewerCamera::sCurCameraID] < LLDrawable::getCurrentFrame() - 1)
+			group->getVisible(LLViewerCamera::sCurCameraID) < LLDrawable::getCurrentFrame() - 1)
 		{
 			group->doOcclusion(mCamera);
 		}
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index e8eba43242..56f10aba71 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -435,6 +435,7 @@ LLviewerOctreeGroup::~LLviewerOctreeGroup()
 
 LLviewerOctreeGroup::LLviewerOctreeGroup(OctreeNode* node) :
 	mOctreeNode(node),
+	mAnyVisible(0),
 	mState(CLEAN)
 {
 	LLVector4a tmp;
@@ -735,6 +736,7 @@ BOOL LLviewerOctreeGroup::isRecentlyVisible() const
 void LLviewerOctreeGroup::setVisible()
 {
 	mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
+	mAnyVisible = LLViewerOctreeEntryData::getCurrentFrame();
 }
 
 void LLviewerOctreeGroup::checkStates()
@@ -871,6 +873,12 @@ BOOL LLOcclusionCullingGroup::isRecentlyVisible() const
 	return (LLDrawable::getCurrentFrame() - mVisible[LLViewerCamera::sCurCameraID]) < MIN_VIS_FRAME_RANGE ;
 }
 
+BOOL LLOcclusionCullingGroup::isAnyRecentlyVisible() const
+{
+	const S32 MIN_VIS_FRAME_RANGE = 2;
+	return (LLDrawable::getCurrentFrame() - mAnyVisible) < MIN_VIS_FRAME_RANGE ;
+}
+
 //virtual 
 void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child)
 {
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 174af5e22f..90870baaea 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -233,6 +233,7 @@ public:
 	void setVisible();
 	BOOL isVisible() const;
 	virtual BOOL isRecentlyVisible() const;
+	S32  getVisible(LLViewerCamera::eCameraID id) const {return mVisible[id];}
 	bool isEmpty() const { return mOctreeNode->isEmpty(); }
 
 	U32  getState()				   {return mState; }
@@ -278,7 +279,7 @@ protected:
 	LL_ALIGN_16(LLVector4a mExtents[2]);       // extents (min, max) of this node and all its children
 	LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node	
 
-public:
+	S32         mAnyVisible; //latest visible to any camera
 	S32         mVisible[LLViewerCamera::NUM_CAMERAS];	
 
 };//LL_ALIGN_POSTFIX(16);
@@ -330,6 +331,7 @@ public:
 	//virtual
 	BOOL isRecentlyVisible() const;
 	LLViewerOctreePartition* getSpatialPartition()const {return mSpatialPartition;}
+	BOOL isAnyRecentlyVisible() const;
 
 	static U32 getNewOcclusionQueryObjectName();
 	static void releaseOcclusionQueryObjectName(U32 name);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index ada412be8c..71d5a92df3 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -361,6 +361,12 @@ bool LLVOCacheEntry::isRecentlyVisible() const
 {
 	bool vis = LLViewerOctreeEntryData::isRecentlyVisible();
 
+	if(!vis && getGroup())
+	{
+		//recently visible to any camera?
+		vis = ((LLOcclusionCullingGroup*)getGroup())->isAnyRecentlyVisible();
+	}
+
 	//combination of projected area and squared distance
 	if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) 
 	{
-- 
cgit v1.2.3


From d4d08762a883e227237eefc5cc23ce8a435c2edf Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 4 Oct 2013 11:10:01 -0600
Subject: trivial: replace llwarns by LL_WARNS()

---
 indra/newview/llviewerobject.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

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;
 	}
-- 
cgit v1.2.3


From c430673b95823f688c45d0fbda4198595bb41073 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 4 Oct 2013 17:54:24 -0600
Subject: more fix for SH-4521: Interesting viewer crash in
 Pipeline:RenderDrawPools

---
 indra/newview/llviewerregion.cpp | 12 +++++++++---
 indra/newview/llviewerregion.h   |  3 +++
 indra/newview/llvocache.cpp      | 20 ++++++++++++++++----
 3 files changed, 28 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 6e9f649d23..2ed7d59ec0 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -377,7 +377,8 @@ LLViewerRegion::LLViewerRegion(const U64 &handle,
 	mPacketsReceived(0.f),
 	mDead(FALSE),
 	mLastVisitedEntry(NULL),
-	mInvisibilityCheckHistory(-1)
+	mInvisibilityCheckHistory(-1),
+	mPaused(FALSE)
 {
 	mWidth = region_width_meters;
 	mImpl->mOriginGlobal = from_region_handle(handle); 
@@ -1185,6 +1186,7 @@ void LLViewerRegion::clearCachedVisibleObjects()
 
 	//reset all occluders
 	mImpl->mVOCachePartition->resetOccluders();
+	mPaused = TRUE;
 
 	//clean visible entries
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
@@ -1257,9 +1259,13 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	{
 		return did_update;
 	}	
-	
+	if(mPaused)
+	{
+		mPaused = FALSE; //unpause.
+	}
+
 	//reset all occluders
-	mImpl->mVOCachePartition->resetOccluders();
+	mImpl->mVOCachePartition->resetOccluders();	
 
 	max_update_time -= update_timer.getElapsedTimeF32();	
 
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 79a992a4c1..cc7ee5c6ee 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -373,6 +373,8 @@ public:
 	void removeFromCreatedList(U32 local_id);
 	void addToCreatedList(U32 local_id);	
 
+	BOOL isPaused() const {return mPaused;}
+
 private:
 	void addToVOCacheTree(LLVOCacheEntry* entry);
 	LLViewerObject* addNewObject(LLVOCacheEntry* entry);
@@ -482,6 +484,7 @@ private:
 	BOOL	mCapabilitiesReceived;
 	BOOL    mReleaseNotesRequested;
 	BOOL    mDead;  //if true, this region is in the process of deleting.
+	BOOL    mPaused; //pause processing the objects in the region
 
 	typedef std::map<U32, std::vector<U32> > orphan_list_t;
 	orphan_list_t mOrphanMap;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 71d5a92df3..b8a6141e2c 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -481,9 +481,13 @@ void LLVOCacheEntry::updateParentBoundingInfo(const LLVOCacheEntry* child)
 //-------------------------------------------------------------------
 LLVOCacheGroup::~LLVOCacheGroup()
 {
-	if(mOcclusionState[0] & ACTIVE_OCCLUSION)
+	for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
 	{
-		((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this);
+		if(mOcclusionState[i] & ACTIVE_OCCLUSION)
+		{
+			((LLVOCachePartition*)mSpatialPartition)->removeOccluder(this);
+			break;
+		}
 	}
 }
 
@@ -726,6 +730,10 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	{
 		return 0;
 	}
+	if(mRegionp->isPaused())
+	{
+		return 0;
+	}
 
 	((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
 
@@ -791,7 +799,7 @@ void LLVOCachePartition::addOccluders(LLviewerOctreeGroup* gp)
 
 	if(!group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
 	{
-		group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS);
+		group->setOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
 		mOccludedGroups.insert(group);
 	}
 }
@@ -808,7 +816,11 @@ void LLVOCachePartition::processOccluders(LLCamera* camera)
 	for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
 	{
 		LLVOCacheGroup* group = *iter;
-		group->doOcclusion(camera, &shift);
+		if(group->isOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION))
+		{
+			group->doOcclusion(camera, &shift);
+			group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
+		}
 	}	
 }
 
-- 
cgit v1.2.3


From 17df8988fec3f2ba991ca9e34ff8148253a2fc04 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
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/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 ++-
 17 files changed, 179 insertions(+), 217 deletions(-)

(limited to 'indra/newview')

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<LLTexture>::aligned_new<16>(size);
 	}
 
-	void operator delete(void* ptr)
+	void operator delete(void* ptr, size_t size)
 	{
-		ll_aligned_free_16(ptr);
+		LLTrace::MemTrackable<LLTexture>::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<LLFace, 16>
 {
 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, 16>("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, 16>("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<CountAccumulator> trace_count;
+	typedef StatType<CountAccumulator> 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<EventAccumulator> trace_event;
+	typedef StatType<EventAccumulator> 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<SampleAccumulator> trace_sample;
+	typedef StatType<SampleAccumulator> 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<MemStatAccumulator> trace_mem;
+	typedef StatType<MemAccumulator> 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<LLDrawable*>* 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, 16>("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<LLDrawInfo, 16>
 {
 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, 16>("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, 16>("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, 16>("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<LLViewerOctreeEntry>	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<LLViewerOctreeEntry, 16>
 {
 	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<LLViewerOctreeEntry>
+class LLViewerOctreeGroup
+:	public LLOctreeListener<LLViewerOctreeEntry>, public LLTrace::MemTrackable<LLViewerOctreeGroup, 16>
 {
 	friend class LLViewerOctreeCull;
 protected:
-	virtual ~LLviewerOctreeGroup();
+	virtual ~LLViewerOctreeGroup();
 
 public:	
 	enum
@@ -206,22 +197,13 @@ public:
 	typedef LLOctreeNode<LLViewerOctreeEntry>::element_iter element_iter;
 	typedef LLOctreeNode<LLViewerOctreeEntry>::element_list element_list;
 
-	LLviewerOctreeGroup(OctreeNode* node);
-	LLviewerOctreeGroup(const LLviewerOctreeGroup& rhs)
+	LLViewerOctreeGroup(OctreeNode* node);
+	LLViewerOctreeGroup(const LLViewerOctreeGroup& rhs)
+	: LLTrace::MemTrackable<LLViewerOctreeGroup, 16>("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<LLviewerOctreeGroup> >      mVisibleGroups; //visible groupa
+	std::set< LLPointer<LLViewerOctreeGroup> >      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<LLviewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
+	std::set< LLPointer<LLViewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
 	for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
 	{
-		LLPointer<LLviewerOctreeGroup> group = *group_iter;
+		LLPointer<LLViewerOctreeGroup> 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<LLTrace::TraceType<LLTrace::TimeBlockAccumulator>, std::string> trace_type_t;
+	typedef LLInstanceTracker<LLTrace::StatType<LLTrace::TimeBlockAccumulator>, 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<LLViewerObject>::aligned_new<16>(size);
 	}
 
-	void operator delete(void* ptr)
+	void operator delete(void* ptr, size_t size)
 	{
-		ll_aligned_free_16(ptr);
+		LLTrace::MemTrackable<LLViewerObject>::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 @@
 				 <stat_bar name="LLViewerObject"
                     label="Viewer Objects"
                     stat="LLViewerObject"/>
-					<stat_bar name="LLVOCacheEntry"
+				 <stat_bar name="LLViewerOctreeGroup"
+									 label="Octree Group Data"
+									 stat="LLViewerOctreeGroup"/>
+				 <stat_bar name="LLViewerOctreeEntry"
+									 label="Octree Data"
+									 stat="LLViewerOctreeEntry"/>
+				 <stat_bar name="LLVOCacheEntry"
                     label="Viewer Object Cache"
                     stat="LLVOCacheEntry"/>
 				 <stat_bar name="LLDrawable"
                     label="Drawables"
                     stat="LLDrawable"/>
+         <stat_bar name="LLFace"
+                     label="Face Data"
+                     stat="LLFace"/>
+          <stat_bar name="LLDrawInfo"
+                     label="Draw Info"
+                     stat="LLDrawInfo"/>
+          <stat_bar name="LLTexture"
+                     label="Texture Data"
+                     stat="LLTexture"/>
 				 <stat_bar name="LLImage"
                     label="Image Data"
                     stat="LLImage"/>
-- 
cgit v1.2.3


From c8067cfd9708fe30659b1f07f6d035508bea3033 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 9 Oct 2013 21:42:53 -0600
Subject: Enable the debug setting "NonvisibleObjectsInMemoryTime"

---
 indra/newview/app_settings/settings.xml | 24 ++++++++++++------------
 indra/newview/llvocache.cpp             |  7 ++++++-
 2 files changed, 18 insertions(+), 13 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 27342712c6..7bfca2834b 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4753,18 +4753,7 @@
       <string>Boolean</string>
       <key>Value</key>
       <integer>0</integer>
-    </map>
-    <key>InvisibleObjectsInMemoryTime</key>
-    <map>
-      <key>Comment</key>
-      <string>Number of frames invisible objects stay in memory before being removed. 0 means never to remove.</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>U32</string>
-      <key>Value</key>
-      <integer>64</integer>
-    </map>
+    </map>    
     <key>JoystickAvatarEnabled</key>
     <map>
       <key>Comment</key>
@@ -6581,6 +6570,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>NonvisibleObjectsInMemoryTime</key>
+    <map>
+      <key>Comment</key>
+      <string>Number of frames non-visible objects stay in memory before being removed. 0 means never to remove.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>U32</string>
+      <key>Value</key>
+      <integer>64</integer>
+    </map>
     <key>NoPreload</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 0466dea39d..f16f3507c3 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -347,7 +347,7 @@ void LLVOCacheEntry::updateDebugSettings()
 	static LLCachedControl<F32> squared_back_angle(gSavedSettings,"BackProjectionAngleSquared");
 
 	//the number of frames invisible objects stay in memory
-	static LLCachedControl<U32> inv_obj_time(gSavedSettings,"InvisibleObjectsInMemoryTime");
+	static LLCachedControl<U32> inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime");
 
 	sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum 
 
@@ -374,6 +374,11 @@ bool LLVOCacheEntry::isRecentlyVisible() const
 		vis = (rad * rad / mSceneContrib < sBackDistanceSquared);
 	}
 
+	if(!vis)
+	{
+		vis = (getVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame());
+	}
+
 	return vis;
 }
 
-- 
cgit v1.2.3


From 1acceb3633c0f0c4fdf29b17d77d67c8a9b71986 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 14 Oct 2013 10:18:41 -0700
Subject: changed ll_aligned_(malloc|free) to take alignment size as a template
 argument

---
 indra/newview/llvovolume.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 6b5d06376f..818232a5c6 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -4433,13 +4433,13 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
 	const U32 MAX_FACE_COUNT = 4096;
 	
-	static LLFace** fullbright_faces = (LLFace**) ll_aligned_malloc(64, MAX_FACE_COUNT*sizeof(LLFace*));
-	static LLFace** bump_faces = (LLFace**) ll_aligned_malloc(64, MAX_FACE_COUNT*sizeof(LLFace*));
-	static LLFace** simple_faces = (LLFace**) ll_aligned_malloc(64, MAX_FACE_COUNT*sizeof(LLFace*));
-	static LLFace** norm_faces = (LLFace**) ll_aligned_malloc(64, MAX_FACE_COUNT*sizeof(LLFace*));
-	static LLFace** spec_faces = (LLFace**) ll_aligned_malloc(64, MAX_FACE_COUNT*sizeof(LLFace*));
-	static LLFace** normspec_faces = (LLFace**) ll_aligned_malloc(64, MAX_FACE_COUNT*sizeof(LLFace*));
-	static LLFace** alpha_faces = (LLFace**) ll_aligned_malloc(64, MAX_FACE_COUNT*sizeof(LLFace*));
+	static LLFace** fullbright_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
+	static LLFace** bump_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
+	static LLFace** simple_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
+	static LLFace** norm_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
+	static LLFace** spec_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
+	static LLFace** normspec_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
+	static LLFace** alpha_faces = (LLFace**) ll_aligned_malloc<64>(MAX_FACE_COUNT*sizeof(LLFace*));
 	
 	U32 fullbright_count = 0;
 	U32 bump_count = 0;
-- 
cgit v1.2.3


From 45f93f5fbbd30cef52e61f6681e8af4795e64260 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 15 Oct 2013 10:19:52 -0700
Subject: add cached object count stat

---
 indra/newview/llworld.cpp                            | 3 +++
 indra/newview/skins/default/xui/en/floater_stats.xml | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index f283cdb4b8..e4e0a745ce 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -661,6 +661,8 @@ void LLWorld::updateVisibilities()
 	LLViewerCamera::getInstance()->setFar(cur_far_clip);
 }
 
+static LLTrace::SampleStatHandle<> sNumActiveCachedObjects("numactivecachedobjects", "Number of objects loaded from cache");
+
 void LLWorld::updateRegions(F32 max_update_time)
 {
 	if(LLViewerCamera::getInstance()->isChanged())
@@ -682,6 +684,7 @@ void LLWorld::updateRegions(F32 max_update_time)
 	{
 		mNumOfActiveCachedObjects += (*iter)->getNumOfActiveCachedObjects();
 	}
+	sample(sNumActiveCachedObjects, mNumOfActiveCachedObjects);
 }
 
 void LLWorld::clearAllVisibleObjects()
diff --git a/indra/newview/skins/default/xui/en/floater_stats.xml b/indra/newview/skins/default/xui/en/floater_stats.xml
index 6c776907f5..bee570d5d0 100755
--- a/indra/newview/skins/default/xui/en/floater_stats.xml
+++ b/indra/newview/skins/default/xui/en/floater_stats.xml
@@ -62,7 +62,10 @@
           <stat_bar name="objs"
                     label="Total Objects"
                     stat="numobjectsstat"/>
-          <stat_bar name="newobjs"
+					<stat_bar name="objs"
+                    label="Cached Objects"
+                    stat="numactivecachedobjects"/>
+					<stat_bar name="newobjs"
                     label="New Objects"
                     stat="numnewobjectsstat"/>
           <stat_bar name="object_cache_hits"
-- 
cgit v1.2.3


From 6a06619777d1e19bae9618c0015ef954203e2fc2 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 15 Oct 2013 14:03:59 -0600
Subject: fix for SH-4551: Interesting: some attachments do not appear after
 teleport

---
 indra/newview/llvovolume.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 6b5d06376f..f2d44f65f0 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1298,10 +1298,16 @@ BOOL LLVOVolume::calcLOD()
 		mLOD = cur_detail;		
 		return TRUE;
 	}
-	else
+	else if(cur_detail > MIN_LOD)
 	{
-		return FALSE;
+		LLFace* facep = mDrawable->getFace(0);
+		if(facep && !facep->getVertexBuffer())
+		{
+			return TRUE; //force geometry update if visible object does not have vertex buffer.
+		}
 	}
+
+	return FALSE;
 }
 
 BOOL LLVOVolume::updateLOD()
-- 
cgit v1.2.3


From 697d2e720ba75e142a4d56ae8794bab8d7698dad Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 15 Oct 2013 20:24:42 -0700
Subject: renamed TimeBlock to BlockTimerStatHandle

---
 indra/newview/llagentcamera.cpp                    |   2 +-
 indra/newview/llappviewer.cpp                      | 108 +++++++-------
 indra/newview/llappviewer.h                        |   2 +-
 indra/newview/llchathistory.cpp                    |   2 +-
 indra/newview/lldebugview.cpp                      |   2 +-
 .../newview/lldonotdisturbnotificationstorage.cpp  |   4 +-
 indra/newview/lldrawable.cpp                       |  10 +-
 indra/newview/lldrawpoolalpha.cpp                  |   4 +-
 indra/newview/lldrawpoolavatar.cpp                 |   6 +-
 indra/newview/lldrawpoolbump.cpp                   |  20 +--
 indra/newview/lldrawpoolsimple.cpp                 |  10 +-
 indra/newview/lldrawpoolterrain.cpp                |   2 +-
 indra/newview/lldrawpooltree.cpp                   |   2 +-
 indra/newview/llface.cpp                           |  56 ++++----
 indra/newview/llfasttimerview.cpp                  |  74 +++++-----
 indra/newview/llfasttimerview.h                    |  12 +-
 indra/newview/llflexibleobject.cpp                 |   8 +-
 indra/newview/llfolderviewmodelinventory.cpp       |   2 +-
 indra/newview/llhudmanager.cpp                     |   2 +-
 indra/newview/llhudobject.cpp                      |   2 +-
 indra/newview/llinventoryfilter.cpp                |   2 +-
 indra/newview/llinventoryitemslist.cpp             |   2 +-
 indra/newview/llinventorypanel.cpp                 |   4 +-
 indra/newview/llmaterialmgr.cpp                    |   2 +-
 indra/newview/llpersistentnotificationstorage.cpp  |   4 +-
 indra/newview/llscenemonitor.cpp                   |   4 +-
 indra/newview/llscreenchannel.cpp                  |   2 +-
 indra/newview/llspatialpartition.cpp               |  12 +-
 indra/newview/llviewerdisplay.cpp                  |  32 ++---
 indra/newview/llviewerfloaterreg.cpp               |   2 +-
 indra/newview/llviewerjointmesh.cpp                |   2 +-
 indra/newview/llviewermedia.cpp                    |  20 +--
 indra/newview/llviewermenu.cpp                     |   6 +-
 indra/newview/llviewermessage.cpp                  |   4 +-
 indra/newview/llviewerobject.cpp                   |   4 +-
 indra/newview/llviewerobjectlist.cpp               |  12 +-
 indra/newview/llvieweroctree.cpp                   |  24 ++--
 indra/newview/llviewerpartsim.cpp                  |   2 +-
 indra/newview/llviewerprecompiledheaders.cpp       |   2 +-
 indra/newview/llviewertexture.cpp                  |   6 +-
 indra/newview/llviewertexturelist.cpp              |  18 +--
 indra/newview/llviewerwindow.cpp                   |   8 +-
 indra/newview/llvoavatar.cpp                       |   8 +-
 indra/newview/llvograss.cpp                        |   4 +-
 indra/newview/llvoicevivox.cpp                     |   2 +-
 indra/newview/llvopartgroup.cpp                    |   6 +-
 indra/newview/llvosky.cpp                          |   4 +-
 indra/newview/llvosurfacepatch.cpp                 |   4 +-
 indra/newview/llvotree.cpp                         |   2 +-
 indra/newview/llvovolume.cpp                       |  36 ++---
 indra/newview/llvowater.cpp                        |   2 +-
 indra/newview/llvowlsky.cpp                        |   2 +-
 indra/newview/llwaterparammanager.cpp              |   2 +-
 indra/newview/llwlparammanager.cpp                 |   2 +-
 indra/newview/llwlparamset.cpp                     |   2 +-
 indra/newview/llworld.cpp                          |   2 +-
 indra/newview/pipeline.cpp                         | 156 ++++++++++-----------
 indra/newview/pipeline.h                           |  40 +++---
 58 files changed, 389 insertions(+), 389 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 5fec0d927f..d1dfbe3315 100755
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1126,7 +1126,7 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 	}
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_CAMERA("Camera");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera");
 
 //-----------------------------------------------------------------------------
 // updateCamera()
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 5fbdc0e23e..037a9bda86 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -627,7 +627,7 @@ public:
 		
 		while (!LLAppViewer::instance()->isQuitting())
 		{
-			LLTrace::TimeBlock::writeLog(os);
+			LLTrace::BlockTimerStatHandle::writeLog(os);
 			os.flush();
 			ms_sleep(32);
 		}
@@ -1240,24 +1240,24 @@ void LLAppViewer::checkMemory()
 	}
 }
 
-static LLTrace::TimeBlock FTM_MESSAGES("System Messages");
-static LLTrace::TimeBlock FTM_SLEEP("Sleep");
-static LLTrace::TimeBlock FTM_YIELD("Yield");
-
-static LLTrace::TimeBlock FTM_TEXTURE_CACHE("Texture Cache");
-static LLTrace::TimeBlock FTM_DECODE("Image Decode");
-static LLTrace::TimeBlock FTM_VFS("VFS Thread");
-static LLTrace::TimeBlock FTM_LFS("LFS Thread");
-static LLTrace::TimeBlock FTM_PAUSE_THREADS("Pause Threads");
-static LLTrace::TimeBlock FTM_IDLE("Idle");
-static LLTrace::TimeBlock FTM_PUMP("Pump");
-static LLTrace::TimeBlock FTM_PUMP_ARES("Ares");
-static LLTrace::TimeBlock FTM_PUMP_SERVICE("Service");
-static LLTrace::TimeBlock FTM_SERVICE_CALLBACK("Callback");
-static LLTrace::TimeBlock FTM_AGENT_AUTOPILOT("Autopilot");
-static LLTrace::TimeBlock FTM_AGENT_UPDATE("Update");
-
-LLTrace::TimeBlock FTM_FRAME("Frame");
+static LLTrace::BlockTimerStatHandle FTM_MESSAGES("System Messages");
+static LLTrace::BlockTimerStatHandle FTM_SLEEP("Sleep");
+static LLTrace::BlockTimerStatHandle FTM_YIELD("Yield");
+
+static LLTrace::BlockTimerStatHandle FTM_TEXTURE_CACHE("Texture Cache");
+static LLTrace::BlockTimerStatHandle FTM_DECODE("Image Decode");
+static LLTrace::BlockTimerStatHandle FTM_VFS("VFS Thread");
+static LLTrace::BlockTimerStatHandle FTM_LFS("LFS Thread");
+static LLTrace::BlockTimerStatHandle FTM_PAUSE_THREADS("Pause Threads");
+static LLTrace::BlockTimerStatHandle FTM_IDLE("Idle");
+static LLTrace::BlockTimerStatHandle FTM_PUMP("Pump");
+static LLTrace::BlockTimerStatHandle FTM_PUMP_ARES("Ares");
+static LLTrace::BlockTimerStatHandle FTM_PUMP_SERVICE("Service");
+static LLTrace::BlockTimerStatHandle FTM_SERVICE_CALLBACK("Callback");
+static LLTrace::BlockTimerStatHandle FTM_AGENT_AUTOPILOT("Autopilot");
+static LLTrace::BlockTimerStatHandle FTM_AGENT_UPDATE("Update");
+
+LLTrace::BlockTimerStatHandle FTM_FRAME("Frame");
 
 bool LLAppViewer::mainLoop()
 {
@@ -1315,9 +1315,9 @@ bool LLAppViewer::mainLoop()
 #endif
 	{
 		LL_RECORD_BLOCK_TIME(FTM_FRAME);
-		LLTrace::TimeBlock::processTimes();
+		LLTrace::BlockTimerStatHandle::processTimes();
 		LLTrace::get_frame_recording().nextPeriod();
-		LLTrace::TimeBlock::logStats();
+		LLTrace::BlockTimerStatHandle::logStats();
 
 		LLTrace::get_master_thread_recorder()->pullFromChildren();
 
@@ -1662,9 +1662,9 @@ bool LLAppViewer::cleanup()
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
 		LL_INFOS() << "Analyzing performance" << LL_ENDL;
-		std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp";
-		std::string current_name  = LLTrace::TimeBlock::sLogName + ".slp"; 
-		std::string report_name   = LLTrace::TimeBlock::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimerStatHandle::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimerStatHandle::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimerStatHandle::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -2018,9 +2018,9 @@ bool LLAppViewer::cleanup()
 	{
 		LL_INFOS() << "Analyzing performance" << LL_ENDL;
 		
-		std::string baseline_name = LLTrace::TimeBlock::sLogName + "_baseline.slp";
-		std::string current_name  = LLTrace::TimeBlock::sLogName + ".slp"; 
-		std::string report_name   = LLTrace::TimeBlock::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimerStatHandle::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimerStatHandle::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimerStatHandle::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -2139,10 +2139,10 @@ bool LLAppViewer::initThreads()
 													enable_threads && true,
 													app_metrics_qa_mode);	
 
-	if (LLTrace::TimeBlock::sLog || LLTrace::TimeBlock::sMetricLog)
+	if (LLTrace::BlockTimerStatHandle::sLog || LLTrace::BlockTimerStatHandle::sMetricLog)
 	{
-		LLTrace::TimeBlock::setLogLock(new LLMutex(NULL));
-		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::TimeBlock::sLogName);
+		LLTrace::BlockTimerStatHandle::setLogLock(new LLMutex(NULL));
+		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimerStatHandle::sLogName);
 		mFastTimerLogThread->start();
 	}
 
@@ -2597,18 +2597,18 @@ bool LLAppViewer::initConfiguration()
 
 	if (gSavedSettings.getBOOL("LogPerformance"))
 	{
-		LLTrace::TimeBlock::sLog = true;
-		LLTrace::TimeBlock::sLogName = std::string("performance");		
+		LLTrace::BlockTimerStatHandle::sLog = true;
+		LLTrace::BlockTimerStatHandle::sLogName = std::string("performance");		
 	}
 
 	std::string test_name(gSavedSettings.getString("LogMetrics"));
 	if (! test_name.empty())
 	{
-		LLTrace::TimeBlock::sMetricLog = TRUE ;
+		LLTrace::BlockTimerStatHandle::sMetricLog = TRUE ;
 		// '--logmetrics' is specified with a named test metric argument so the data gathering is done only on that test
 		// In the absence of argument, every metric would be gathered (makes for a rather slow run and hard to decipher report...)
 		LL_INFOS() << "'--logmetrics' argument : " << test_name << LL_ENDL;
-		LLTrace::TimeBlock::sLogName = test_name;
+		LLTrace::BlockTimerStatHandle::sLogName = test_name;
  	}
 
 	if (clp.hasOption("graphicslevel"))
@@ -4470,20 +4470,20 @@ public:
 		}
 };
 
-static LLTrace::TimeBlock FTM_AUDIO_UPDATE("Update Audio");
-static LLTrace::TimeBlock FTM_CLEANUP("Cleanup");
-static LLTrace::TimeBlock FTM_CLEANUP_DRAWABLES("Drawables");
-static LLTrace::TimeBlock FTM_CLEANUP_OBJECTS("Objects");
-static LLTrace::TimeBlock FTM_IDLE_CB("Idle Callbacks");
-static LLTrace::TimeBlock FTM_LOD_UPDATE("Update LOD");
-static LLTrace::TimeBlock FTM_OBJECTLIST_UPDATE("Update Objectlist");
-static LLTrace::TimeBlock FTM_REGION_UPDATE("Update Region");
-static LLTrace::TimeBlock FTM_WORLD_UPDATE("Update World");
-static LLTrace::TimeBlock FTM_NETWORK("Network");
-static LLTrace::TimeBlock FTM_AGENT_NETWORK("Agent Network");
-static LLTrace::TimeBlock FTM_VLMANAGER("VL Manager");
-static LLTrace::TimeBlock FTM_AGENT_POSITION("Agent Position");
-static LLTrace::TimeBlock FTM_HUD_EFFECTS("HUD Effects");
+static LLTrace::BlockTimerStatHandle FTM_AUDIO_UPDATE("Update Audio");
+static LLTrace::BlockTimerStatHandle FTM_CLEANUP("Cleanup");
+static LLTrace::BlockTimerStatHandle FTM_CLEANUP_DRAWABLES("Drawables");
+static LLTrace::BlockTimerStatHandle FTM_CLEANUP_OBJECTS("Objects");
+static LLTrace::BlockTimerStatHandle FTM_IDLE_CB("Idle Callbacks");
+static LLTrace::BlockTimerStatHandle FTM_LOD_UPDATE("Update LOD");
+static LLTrace::BlockTimerStatHandle FTM_OBJECTLIST_UPDATE("Update Objectlist");
+static LLTrace::BlockTimerStatHandle FTM_REGION_UPDATE("Update Region");
+static LLTrace::BlockTimerStatHandle FTM_WORLD_UPDATE("Update World");
+static LLTrace::BlockTimerStatHandle FTM_NETWORK("Network");
+static LLTrace::BlockTimerStatHandle FTM_AGENT_NETWORK("Agent Network");
+static LLTrace::BlockTimerStatHandle FTM_VLMANAGER("VL Manager");
+static LLTrace::BlockTimerStatHandle FTM_AGENT_POSITION("Agent Position");
+static LLTrace::BlockTimerStatHandle FTM_HUD_EFFECTS("HUD Effects");
 
 ///////////////////////////////////////////////////////
 // idle()
@@ -5079,12 +5079,12 @@ void LLAppViewer::idleNameCache()
 static F32 CheckMessagesMaxTime = CHECK_MESSAGES_DEFAULT_MAX_TIME;
 #endif
 
-static LLTrace::TimeBlock FTM_IDLE_NETWORK("Idle Network");
-static LLTrace::TimeBlock FTM_MESSAGE_ACKS("Message Acks");
-static LLTrace::TimeBlock FTM_RETRANSMIT("Retransmit");
-static LLTrace::TimeBlock FTM_TIMEOUT_CHECK("Timeout Check");
-static LLTrace::TimeBlock FTM_DYNAMIC_THROTTLE("Dynamic Throttle");
-static LLTrace::TimeBlock FTM_CHECK_REGION_CIRCUIT("Check Region Circuit");
+static LLTrace::BlockTimerStatHandle FTM_IDLE_NETWORK("Idle Network");
+static LLTrace::BlockTimerStatHandle FTM_MESSAGE_ACKS("Message Acks");
+static LLTrace::BlockTimerStatHandle FTM_RETRANSMIT("Retransmit");
+static LLTrace::BlockTimerStatHandle FTM_TIMEOUT_CHECK("Timeout Check");
+static LLTrace::BlockTimerStatHandle FTM_DYNAMIC_THROTTLE("Dynamic Throttle");
+static LLTrace::BlockTimerStatHandle FTM_CHECK_REGION_CIRCUIT("Check Region Circuit");
 
 void LLAppViewer::idleNetwork()
 {
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index e4dab8eb17..e9d86612ca 100755
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -43,7 +43,7 @@ class LLWatchdogTimeout;
 class LLUpdaterService;
 class LLViewerJoystick;
 
-extern LLTrace::TimeBlock FTM_FRAME;
+extern LLTrace::BlockTimerStatHandle FTM_FRAME;
 
 
 class LLAppViewer : public LLApp
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp
index e64068330e..534961840a 100755
--- a/indra/newview/llchathistory.cpp
+++ b/indra/newview/llchathistory.cpp
@@ -734,7 +734,7 @@ void LLChatHistory::clear()
 	mLastFromID = LLUUID::null;
 }
 
-static LLTrace::TimeBlock FTM_APPEND_MESSAGE("Append Chat Message");
+static LLTrace::BlockTimerStatHandle FTM_APPEND_MESSAGE("Append Chat Message");
 
 void LLChatHistory::appendMessage(const LLChat& chat, const LLSD &args, const LLStyle::Params& input_append_params)
 {
diff --git a/indra/newview/lldebugview.cpp b/indra/newview/lldebugview.cpp
index 98c1685feb..dc1c085c88 100755
--- a/indra/newview/lldebugview.cpp
+++ b/indra/newview/lldebugview.cpp
@@ -89,7 +89,7 @@ void LLDebugView::init()
 	r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), 
   									 (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f));
 	
-	mFastTimerView = dynamic_cast<LLFastTimerView*>(LLFloaterReg::getInstance("fast_timers"));
+	mFastTimerView = dynamic_cast<LLFastTimerView*>(LLFloaterReg::getInstance("block_timers"));
 
 	gSceneView = new LLSceneView(r);
 	gSceneView->setFollowsTop();
diff --git a/indra/newview/lldonotdisturbnotificationstorage.cpp b/indra/newview/lldonotdisturbnotificationstorage.cpp
index 93a98084d9..7836e2cb94 100755
--- a/indra/newview/lldonotdisturbnotificationstorage.cpp
+++ b/indra/newview/lldonotdisturbnotificationstorage.cpp
@@ -97,7 +97,7 @@ void LLDoNotDisturbNotificationStorage::resetDirty()
     mDirty = false;
 }
 
-static LLTrace::TimeBlock FTM_SAVE_DND_NOTIFICATIONS("Save DND Notifications");
+static LLTrace::BlockTimerStatHandle FTM_SAVE_DND_NOTIFICATIONS("Save DND Notifications");
 
 void LLDoNotDisturbNotificationStorage::saveNotifications()
 {
@@ -128,7 +128,7 @@ void LLDoNotDisturbNotificationStorage::saveNotifications()
     resetDirty();
 }
 
-static LLTrace::TimeBlock FTM_LOAD_DND_NOTIFICATIONS("Load DND Notifications");
+static LLTrace::BlockTimerStatHandle FTM_LOAD_DND_NOTIFICATIONS("Load DND Notifications");
 
 void LLDoNotDisturbNotificationStorage::loadNotifications()
 {
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 5981153bd5..7414b24811 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -56,7 +56,7 @@ const F32 MAX_INTERPOLATE_DISTANCE_SQUARED = 10.f * 10.f;
 const F32 OBJECT_DAMPING_TIME_CONSTANT = 0.06f;
 const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 
-static LLTrace::TimeBlock FTM_CULL_REBOUND("Cull Rebound");
+static LLTrace::BlockTimerStatHandle FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
 
@@ -236,9 +236,9 @@ BOOL LLDrawable::isLight() const
 	}
 }
 
-static LLTrace::TimeBlock FTM_CLEANUP_DRAWABLE("Cleanup Drawable");
-static LLTrace::TimeBlock FTM_DEREF_DRAWABLE("Deref");
-static LLTrace::TimeBlock FTM_DELETE_FACES("Faces");
+static LLTrace::BlockTimerStatHandle FTM_CLEANUP_DRAWABLE("Cleanup Drawable");
+static LLTrace::BlockTimerStatHandle FTM_DEREF_DRAWABLE("Deref");
+static LLTrace::BlockTimerStatHandle FTM_DELETE_FACES("Faces");
 
 void LLDrawable::cleanupReferences()
 {
@@ -306,7 +306,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep)
 	return count;
 }
 
-static LLTrace::TimeBlock FTM_ALLOCATE_FACE("Allocate Face");
+static LLTrace::BlockTimerStatHandle FTM_ALLOCATE_FACE("Allocate Face");
 
 LLFace*	LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep)
 {
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index 2f9e5813c0..96393996c3 100755
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -363,8 +363,8 @@ void LLDrawPoolAlpha::renderAlphaHighlight(U32 mask)
 	}
 }
 
-static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_GROUP_LOOP("Alpha Group");
-static LLFastTimer::DeclareTimer FTM_RENDER_ALPHA_PUSH("Alpha Push Verts");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_GROUP_LOOP("Alpha Group");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_PUSH("Alpha Push Verts");
 
 void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
 {
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index 7b785a0220..966298b5d8 100755
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -102,7 +102,7 @@ S32 normal_channel = -1;
 S32 specular_channel = -1;
 S32 cube_channel = -1;
 
-static LLTrace::TimeBlock FTM_SHADOW_AVATAR("Avatar Shadow");
+static LLTrace::BlockTimerStatHandle FTM_SHADOW_AVATAR("Avatar Shadow");
 
 LLDrawPoolAvatar::LLDrawPoolAvatar() : 
 	LLFacePool(POOL_AVATAR)	
@@ -1174,7 +1174,7 @@ void LLDrawPoolAvatar::endDeferredSkinned()
 	gGL.getTexUnit(0)->activate();
 }
 
-static LLTrace::TimeBlock FTM_RENDER_AVATARS("renderAvatars");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_AVATARS("renderAvatars");
 
 
 void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
@@ -1836,7 +1836,7 @@ void LLDrawPoolAvatar::renderDeferredRiggedMaterial(LLVOAvatar* avatar, S32 pass
 	renderRigged(avatar, pass);
 }
 
-static LLTrace::TimeBlock FTM_RIGGED_VBO("Rigged VBO");
+static LLTrace::BlockTimerStatHandle FTM_RIGGED_VBO("Rigged VBO");
 
 void LLDrawPoolAvatar::updateRiggedVertexBuffers(LLVOAvatar* avatar)
 {
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index ef41cbd989..211a96b32d 100755
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -1095,7 +1095,7 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText
 }
 
 
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_STANDARD_LOADED("Bump Standard Callback");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_STANDARD_LOADED("Bump Standard Callback");
 
 // static
 void LLBumpImageList::onSourceBrightnessLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata )
@@ -1119,8 +1119,8 @@ void LLBumpImageList::onSourceDarknessLoaded( BOOL success, LLViewerFetchedTextu
 	}
 }
 
-static LLTrace::TimeBlock FTM_BUMP_GEN_NORMAL("Generate Normal Map");
-static LLTrace::TimeBlock FTM_BUMP_CREATE_TEXTURE("Create GL Normal Map");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_GEN_NORMAL("Generate Normal Map");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_CREATE_TEXTURE("Create GL Normal Map");
 
 void LLBumpImageList::onSourceStandardLoaded( BOOL success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata)
 {
@@ -1196,13 +1196,13 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
 }
 
 
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_LOADED("Bump Source Loaded");
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_ENTRIES_UPDATE("Entries Update");
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_MIN_MAX("Min/Max");
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_RGB2LUM("RGB to Luminance");
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_RESCALE("Rescale");
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_GEN_NORMAL("Generate Normal");
-static LLTrace::TimeBlock FTM_BUMP_SOURCE_CREATE("Bump Source Create");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_LOADED("Bump Source Loaded");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_ENTRIES_UPDATE("Entries Update");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_MIN_MAX("Min/Max");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_RGB2LUM("RGB to Luminance");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_RESCALE("Rescale");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_GEN_NORMAL("Generate Normal");
+static LLTrace::BlockTimerStatHandle FTM_BUMP_SOURCE_CREATE("Bump Source Create");
 
 // static
 void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code )
diff --git a/indra/newview/lldrawpoolsimple.cpp b/indra/newview/lldrawpoolsimple.cpp
index f1289ab06a..61fbe6d5f6 100755
--- a/indra/newview/lldrawpoolsimple.cpp
+++ b/indra/newview/lldrawpoolsimple.cpp
@@ -42,8 +42,8 @@
 static LLGLSLShader* simple_shader = NULL;
 static LLGLSLShader* fullbright_shader = NULL;
 
-static LLTrace::TimeBlock FTM_RENDER_SIMPLE_DEFERRED("Deferred Simple");
-static LLTrace::TimeBlock FTM_RENDER_GRASS_DEFERRED("Deferred Grass");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_SIMPLE_DEFERRED("Deferred Simple");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_GRASS_DEFERRED("Deferred Grass");
 
 void LLDrawPoolGlow::beginPostDeferredPass(S32 pass)
 {
@@ -51,7 +51,7 @@ void LLDrawPoolGlow::beginPostDeferredPass(S32 pass)
 	gDeferredEmissiveProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f);
 }
 
-static LLTrace::TimeBlock FTM_RENDER_GLOW_PUSH("Glow Push");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_GLOW_PUSH("Glow Push");
 
 void LLDrawPoolGlow::renderPostDeferred(S32 pass)
 {
@@ -237,7 +237,7 @@ void LLDrawPoolSimple::render(S32 pass)
 
 
 
-static LLTrace::TimeBlock FTM_RENDER_ALPHA_MASK("Alpha Mask");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_MASK("Alpha Mask");
 
 LLDrawPoolAlphaMask::LLDrawPoolAlphaMask() :
 	LLRenderPass(POOL_ALPHA_MASK)
@@ -420,7 +420,7 @@ void LLDrawPoolSimple::renderDeferred(S32 pass)
 	}
 }
 
-static LLTrace::TimeBlock FTM_RENDER_ALPHA_MASK_DEFERRED("Deferred Alpha Mask");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA_MASK_DEFERRED("Deferred Alpha Mask");
 
 void LLDrawPoolAlphaMask::beginDeferredPass(S32 pass)
 {
diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp
index 3d7d34d30d..33ce3d0111 100755
--- a/indra/newview/lldrawpoolterrain.cpp
+++ b/indra/newview/lldrawpoolterrain.cpp
@@ -55,7 +55,7 @@ int DebugDetailMap = 0;
 S32 LLDrawPoolTerrain::sDetailMode = 1;
 F32 LLDrawPoolTerrain::sDetailScale = DETAIL_SCALE;
 static LLGLSLShader* sShader = NULL;
-static LLTrace::TimeBlock FTM_SHADOW_TERRAIN("Terrain Shadow");
+static LLTrace::BlockTimerStatHandle FTM_SHADOW_TERRAIN("Terrain Shadow");
 
 
 LLDrawPoolTerrain::LLDrawPoolTerrain(LLViewerTexture *texturep) :
diff --git a/indra/newview/lldrawpooltree.cpp b/indra/newview/lldrawpooltree.cpp
index 187a2045dd..b1f40781f7 100755
--- a/indra/newview/lldrawpooltree.cpp
+++ b/indra/newview/lldrawpooltree.cpp
@@ -41,7 +41,7 @@
 
 S32 LLDrawPoolTree::sDiffTex = 0;
 static LLGLSLShader* shader = NULL;
-static LLTrace::TimeBlock FTM_SHADOW_TREE("Tree Shadow");
+static LLTrace::BlockTimerStatHandle FTM_SHADOW_TREE("Tree Shadow");
 
 LLDrawPoolTree::LLDrawPoolTree(LLViewerTexture *texturep) :
 	LLFacePool(POOL_TREE),
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index 4c44e59d9b..f2727aa7b9 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -1081,7 +1081,7 @@ bool LLFace::canRenderAsMask()
 }
 
 
-static LLTrace::TimeBlock FTM_FACE_GEOM_VOLUME("Volume VB Cache");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_VOLUME("Volume VB Cache");
 
 //static 
 void LLFace::cacheFaceInVRAM(const LLVolumeFace& vf)
@@ -1148,33 +1148,33 @@ void push_for_transform(LLVertexBuffer* buff, U32 source_count, U32 dest_count)
 	}
 }
 
-static LLTrace::TimeBlock FTM_FACE_GET_GEOM("Face Geom");
-static LLTrace::TimeBlock FTM_FACE_GEOM_POSITION("Position");
-static LLTrace::TimeBlock FTM_FACE_GEOM_NORMAL("Normal");
-static LLTrace::TimeBlock FTM_FACE_GEOM_TEXTURE("Texture");
-static LLTrace::TimeBlock FTM_FACE_GEOM_COLOR("Color");
-static LLTrace::TimeBlock FTM_FACE_GEOM_EMISSIVE("Emissive");
-static LLTrace::TimeBlock FTM_FACE_GEOM_WEIGHTS("Weights");
-static LLTrace::TimeBlock FTM_FACE_GEOM_TANGENT("Binormal");
-
-static LLTrace::TimeBlock FTM_FACE_GEOM_FEEDBACK("Face Feedback");
-static LLTrace::TimeBlock FTM_FACE_GEOM_FEEDBACK_POSITION("Feedback Position");
-static LLTrace::TimeBlock FTM_FACE_GEOM_FEEDBACK_NORMAL("Feedback  Normal");
-static LLTrace::TimeBlock FTM_FACE_GEOM_FEEDBACK_TEXTURE("Feedback  Texture");
-static LLTrace::TimeBlock FTM_FACE_GEOM_FEEDBACK_COLOR("Feedback  Color");
-static LLTrace::TimeBlock FTM_FACE_GEOM_FEEDBACK_EMISSIVE("Feedback  Emissive");
-static LLTrace::TimeBlock FTM_FACE_GEOM_FEEDBACK_BINORMAL("Feedback Binormal");
-
-static LLTrace::TimeBlock FTM_FACE_GEOM_INDEX("Index");
-static LLTrace::TimeBlock FTM_FACE_GEOM_INDEX_TAIL("Tail");
-static LLTrace::TimeBlock FTM_FACE_POSITION_STORE("Pos");
-static LLTrace::TimeBlock FTM_FACE_TEXTURE_INDEX_STORE("TexIdx");
-static LLTrace::TimeBlock FTM_FACE_POSITION_PAD("Pad");
-static LLTrace::TimeBlock FTM_FACE_TEX_DEFAULT("Default");
-static LLTrace::TimeBlock FTM_FACE_TEX_QUICK("Quick");
-static LLTrace::TimeBlock FTM_FACE_TEX_QUICK_NO_XFORM("No Xform");
-static LLTrace::TimeBlock FTM_FACE_TEX_QUICK_XFORM("Xform");
-static LLTrace::TimeBlock FTM_FACE_TEX_QUICK_PLANAR("Quick Planar");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GET_GEOM("Face Geom");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_POSITION("Position");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_NORMAL("Normal");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_TEXTURE("Texture");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_COLOR("Color");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_EMISSIVE("Emissive");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_WEIGHTS("Weights");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_TANGENT("Binormal");
+
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_FEEDBACK("Face Feedback");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_FEEDBACK_POSITION("Feedback Position");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_FEEDBACK_NORMAL("Feedback  Normal");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_FEEDBACK_TEXTURE("Feedback  Texture");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_FEEDBACK_COLOR("Feedback  Color");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_FEEDBACK_EMISSIVE("Feedback  Emissive");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_FEEDBACK_BINORMAL("Feedback Binormal");
+
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_INDEX("Index");
+static LLTrace::BlockTimerStatHandle FTM_FACE_GEOM_INDEX_TAIL("Tail");
+static LLTrace::BlockTimerStatHandle FTM_FACE_POSITION_STORE("Pos");
+static LLTrace::BlockTimerStatHandle FTM_FACE_TEXTURE_INDEX_STORE("TexIdx");
+static LLTrace::BlockTimerStatHandle FTM_FACE_POSITION_PAD("Pad");
+static LLTrace::BlockTimerStatHandle FTM_FACE_TEX_DEFAULT("Default");
+static LLTrace::BlockTimerStatHandle FTM_FACE_TEX_QUICK("Quick");
+static LLTrace::BlockTimerStatHandle FTM_FACE_TEX_QUICK_NO_XFORM("No Xform");
+static LLTrace::BlockTimerStatHandle FTM_FACE_TEX_QUICK_XFORM("Xform");
+static LLTrace::BlockTimerStatHandle FTM_FACE_TEX_QUICK_PLANAR("Quick Planar");
 
 BOOL LLFace::getGeometryVolume(const LLVolume& volume,
 							   const S32 &f,
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 4809a6b7da..6153c43690 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -64,17 +64,17 @@ static const S32 MIN_BAR_HEIGHT = 3;
 static const S32 RUNNING_AVERAGE_WIDTH = 100;
 static const S32 NUM_FRAMES_HISTORY = 200;
 
-std::vector<TimeBlock*> ft_display_idx; // line of table entry for display purposes (for collapse)
+std::vector<BlockTimerStatHandle*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
-typedef LLTreeDFSIter<TimeBlock, TimeBlock::child_const_iter> timer_tree_iterator_t;
+typedef LLTreeDFSIter<BlockTimerStatHandle, BlockTimerStatHandle::child_const_iter> timer_tree_iterator_t;
 
 BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
 
-static timer_tree_iterator_t begin_timer_tree(TimeBlock& id) 
+static timer_tree_iterator_t begin_timer_tree(BlockTimerStatHandle& id) 
 { 
 	return timer_tree_iterator_t(&id, 
-							boost::bind(boost::mem_fn(&TimeBlock::beginChildren), _1), 
-							boost::bind(boost::mem_fn(&TimeBlock::endChildren), _1));
+							boost::bind(boost::mem_fn(&BlockTimerStatHandle::beginChildren), _1), 
+							boost::bind(boost::mem_fn(&BlockTimerStatHandle::endChildren), _1));
 }
 
 static timer_tree_iterator_t end_timer_tree() 
@@ -82,10 +82,10 @@ static timer_tree_iterator_t end_timer_tree()
 	return timer_tree_iterator_t(); 
 }
 
-S32 get_depth(const TimeBlock* blockp)
+S32 get_depth(const BlockTimerStatHandle* blockp)
 {
 	S32 depth = 0;
-	TimeBlock* timerp = blockp->getParent();
+	BlockTimerStatHandle* timerp = blockp->getParent();
 	while(timerp)
 	{
 		depth++;
@@ -172,7 +172,7 @@ BOOL LLFastTimerView::handleRightMouseDown(S32 x, S32 y, MASK mask)
 	return LLFloater::handleRightMouseDown(x, y, mask);
 }
 
-TimeBlock* LLFastTimerView::getLegendID(S32 y)
+BlockTimerStatHandle* LLFastTimerView::getLegendID(S32 y)
 {
 	S32 idx = (mLegendRect.mTop - y) / (LLFontGL::getFontMonospace()->getLineHeight() + 2);
 
@@ -199,7 +199,7 @@ BOOL LLFastTimerView::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	if (x < mBarRect.mLeft) 
 	{
-		TimeBlock* idp = getLegendID(y);
+		BlockTimerStatHandle* idp = getLegendID(y);
 		if (idp)
 		{
 			idp->getTreeNode().mCollapsed = !idp->getTreeNode().mCollapsed;
@@ -261,7 +261,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 
 		TimerBar* hover_bar = NULL;
 		F32Seconds mouse_time_offset = ((F32)(x - mBarRect.mLeft) / (F32)mBarRect.getWidth()) * mTotalTimeDisplay;
-		for (int bar_index = 0, end_index = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount(); 
+		for (int bar_index = 0, end_index = LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount(); 
 			bar_index < end_index; 
 			++bar_index)
 		{
@@ -275,7 +275,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 				hover_bar = &bar;
 				if (bar.mTimeBlock->getTreeNode().mCollapsed)
 		{
-					// stop on first collapsed timeblock, since we can't select any children
+					// stop on first collapsed BlockTimerStatHandle, since we can't select any children
 					break;
 				}
 			}
@@ -300,7 +300,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 	}
 	else if (x < mBarRect.mLeft) 
 	{
-		TimeBlock* timer_id = getLegendID(y);
+		BlockTimerStatHandle* timer_id = getLegendID(y);
 		if (timer_id)
 		{
 			mHoverID = timer_id;
@@ -311,7 +311,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask)
 }
 
 
-static std::string get_tooltip(TimeBlock& timer, S32 history_index, PeriodicRecording& frame_recording)
+static std::string get_tooltip(BlockTimerStatHandle& timer, S32 history_index, PeriodicRecording& frame_recording)
 {
 	std::string tooltip;
 	if (history_index == 0)
@@ -351,7 +351,7 @@ BOOL LLFastTimerView::handleToolTip(S32 x, S32 y, MASK mask)
 		// tooltips for timer legend
 		if (x < mBarRect.mLeft) 
 		{
-			TimeBlock* idp = getLegendID(y);
+			BlockTimerStatHandle* idp = getLegendID(y);
 			if (idp)
 			{
 				LLToolTipMgr::instance().show(get_tooltip(*idp, 0, mRecording));
@@ -373,7 +373,7 @@ BOOL LLFastTimerView::handleScrollWheel(S32 x, S32 y, S32 clicks)
 	return TRUE;
 }
 
-static TimeBlock FTM_RENDER_TIMER("Timers");
+static BlockTimerStatHandle FTM_RENDER_TIMER("Timers");
 static const S32 MARGIN = 10;
 static const S32 LEGEND_WIDTH = 220;
 
@@ -938,13 +938,13 @@ void LLFastTimerView::outputAllMetrics()
 //static
 void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
 {
-	if(TimeBlock::sLog)
+	if(BlockTimerStatHandle::sLog)
 	{
 		doAnalysisDefault(baseline, target, output) ;
 		return ;
 	}
 
-	if(TimeBlock::sMetricLog)
+	if(BlockTimerStatHandle::sMetricLog)
 	{
 		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
 		return ;
@@ -966,7 +966,7 @@ void LLFastTimerView::printLineStats()
 			it != end_timer_tree();
 			++it)
 		{
-			TimeBlock* idp = (*it);
+			BlockTimerStatHandle* idp = (*it);
 
 			if (!first)
 			{
@@ -988,7 +988,7 @@ void LLFastTimerView::printLineStats()
 			it != end_timer_tree();
 			++it)
 		{
-			TimeBlock* idp = (*it);
+			BlockTimerStatHandle* idp = (*it);
 
 			if (!first)
 			{
@@ -1019,7 +1019,7 @@ void LLFastTimerView::printLineStats()
 	}
 }
 
-static LLTrace::TimeBlock FTM_DRAW_LINE_GRAPH("Draw line graph");
+static LLTrace::BlockTimerStatHandle FTM_DRAW_LINE_GRAPH("Draw line graph");
 
 void LLFastTimerView::drawLineGraph()
 {
@@ -1066,7 +1066,7 @@ void LLFastTimerView::drawLineGraph()
 		it != end_timer_tree();
 		++it)
 	{
-		TimeBlock* idp = (*it);
+		BlockTimerStatHandle* idp = (*it);
 
 		//fatten highlighted timer
 		if (mHoverID == idp)
@@ -1208,12 +1208,12 @@ void LLFastTimerView::drawLegend()
 		LLLocalClipRect clip(mLegendRect);
 		S32 cur_line = 0;
 		ft_display_idx.clear();
-		std::map<TimeBlock*, S32> display_line;
+		std::map<BlockTimerStatHandle*, S32> display_line;
 		for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			TimeBlock* idp = (*it);
+			BlockTimerStatHandle* idp = (*it);
 			display_line[idp] = cur_line;
 			ft_display_idx.push_back(idp);
 			cur_line++;
@@ -1275,7 +1275,7 @@ void LLFastTimerView::drawLegend()
 
 			x += dx;
 			BOOL is_child_of_hover_item = (idp == mHoverID);
-			TimeBlock* next_parent = idp->getParent();
+			BlockTimerStatHandle* next_parent = idp->getParent();
 			while(!is_child_of_hover_item && next_parent)
 			{
 				is_child_of_hover_item = (mHoverID == next_parent);
@@ -1303,7 +1303,7 @@ void LLFastTimerView::generateUniqueColors()
 {
 	// generate unique colors
 	{
-		sTimerColors.resize(LLTrace::TimeBlock::getNumIndices());
+		sTimerColors.resize(LLTrace::BlockTimerStatHandle::getNumIndices());
 		sTimerColors[FTM_FRAME.getIndex()] = LLColor4::grey;
 
 		F32 hue = 0.f;
@@ -1312,7 +1312,7 @@ void LLFastTimerView::generateUniqueColors()
 			it != timer_tree_iterator_t();
 			++it)
 		{
-			TimeBlock* idp = (*it);
+			BlockTimerStatHandle* idp = (*it);
 
 			const F32 HUE_INCREMENT = 0.23f;
 			hue = fmodf(hue + HUE_INCREMENT, 1.f);
@@ -1462,7 +1462,7 @@ void LLFastTimerView::drawBars()
 			U32 bar_index = 0;
 			if (!mAverageTimerRow.mBars)
 			{
-				mAverageTimerRow.mBars = new TimerBar[LLInstanceTracker<LLTrace::TimeBlock>::instanceCount()];
+				mAverageTimerRow.mBars = new TimerBar[LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount()];
 			}
 			updateTimerBarWidths(&FTM_FRAME, mAverageTimerRow, -1, bar_index);
 			updateTimerBarOffsets(&FTM_FRAME, mAverageTimerRow);
@@ -1474,7 +1474,7 @@ void LLFastTimerView::drawBars()
 				bar_index = 0;
 				if (!row.mBars)
 				{
-					row.mBars = new TimerBar[LLInstanceTracker<LLTrace::TimeBlock>::instanceCount()];
+					row.mBars = new TimerBar[LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount()];
 					updateTimerBarWidths(&FTM_FRAME, row, history_index, bar_index);
 					updateTimerBarOffsets(&FTM_FRAME, row);
 				}
@@ -1509,9 +1509,9 @@ void LLFastTimerView::drawBars()
 	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_TIMER_BAR_WIDTHS("Update timer bar widths");
 
-F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
+F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 history_index, U32& bar_index)
 {
 	LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_WIDTHS);
 	const F32Seconds self_time = history_index == -1
@@ -1525,7 +1525,7 @@ F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block,
 	TimerBar& timer_bar = row.mBars[bar_index];
 	bar_index++;
 
-	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
+	for (BlockTimerStatHandle::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); it != end_it; ++it)
 	{
 		full_time += updateTimerBarWidths(*it, row, history_index, bar_index);
 	}
@@ -1537,9 +1537,9 @@ F32Seconds LLFastTimerView::updateTimerBarWidths(LLTrace::TimeBlock* time_block,
 	return full_time;
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_TIMER_BAR_FRACTIONS("Update timer bar fractions");
 
-S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index)
+S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 timer_bar_index)
 {
 	LL_RECORD_BLOCK_TIME(FTM_UPDATE_TIMER_BAR_FRACTIONS);
 
@@ -1560,14 +1560,14 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 	TimerBar* last_child_timer_bar = NULL;
 
 	bool first_child = true;
-	for (TimeBlock::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
+	for (BlockTimerStatHandle::child_iter it = time_block->beginChildren(), end_it = time_block->endChildren(); 
 		it != end_it; 
 		++it)
 	{
 		timer_bar_index++;
 		
 		TimerBar& child_timer_bar = row.mBars[timer_bar_index];
-		TimeBlock* child_time_block = *it;
+		BlockTimerStatHandle* child_time_block = *it;
 
 		if (last_child_timer_bar)
 		{
@@ -1603,7 +1603,7 @@ S32 LLFastTimerView::updateTimerBarOffsets(LLTrace::TimeBlock* time_block, Timer
 S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered, bool visible, S32 bar_index)
 {
 	TimerBar& timer_bar = row.mBars[bar_index];
-	LLTrace::TimeBlock* time_block = timer_bar.mTimeBlock;
+	LLTrace::BlockTimerStatHandle* time_block = timer_bar.mTimeBlock;
 
 	hovered |= mHoverID == time_block;
 
@@ -1648,7 +1648,7 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width,
 	bool children_visible = visible && !time_block->getTreeNode().mCollapsed;
 
 	bar_index++;
-	const U32 num_bars = LLInstanceTracker<LLTrace::TimeBlock>::instanceCount();
+	const U32 num_bars = LLTrace::BlockTimerStatHandle::instance_tracker_t::instanceCount();
 	if (bar_index < num_bars && row.mBars[bar_index].mFirstChild)
 	{
 		bool is_last = false;
diff --git a/indra/newview/llfasttimerview.h b/indra/newview/llfasttimerview.h
index 672bb5d7ca..c23846afab 100755
--- a/indra/newview/llfasttimerview.h
+++ b/indra/newview/llfasttimerview.h
@@ -62,7 +62,7 @@ public:
 	virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
 	virtual void draw();
 	virtual void onOpen(const LLSD& key);
-	LLTrace::TimeBlock* getLegendID(S32 y);
+	LLTrace::BlockTimerStatHandle* getLegendID(S32 y);
 
 private:	
 	virtual	void	onClickCloseBtn();
@@ -93,7 +93,7 @@ private:
 							mChildrenEnd,
 							mSelfStart,
 							mSelfEnd;
-		LLTrace::TimeBlock* mTimeBlock;
+		LLTrace::BlockTimerStatHandle* mTimeBlock;
 		bool				mVisible,
 							mFirstChild,
 							mLastChild;
@@ -113,8 +113,8 @@ private:
 		TimerBar*	mBars;
 	};
 
-	F32Seconds updateTimerBarWidths(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
-	S32 updateTimerBarOffsets(LLTrace::TimeBlock* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
+	F32Seconds updateTimerBarWidths(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 history_index, U32& bar_index);
+	S32 updateTimerBarOffsets(LLTrace::BlockTimerStatHandle* time_block, TimerBarRow& row, S32 timer_bar_index = 0);
 	S32 drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, S32 image_height, bool hovered = false, bool visible = true, S32 bar_index = 0);
 	void setPauseState(bool pause_state);
 
@@ -134,8 +134,8 @@ private:
 									mHoverBarIndex,
 									mStatsIndex;
 	S32								mDisplayMode;
-	LLTrace::TimeBlock*				mHoverID;
-	LLTrace::TimeBlock*				mHoverTimer;
+	LLTrace::BlockTimerStatHandle*				mHoverID;
+	LLTrace::BlockTimerStatHandle*				mHoverTimer;
 	LLRect							mToolTipRect,
 									mGraphRect,
 									mBarRect,
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 7c7b59445c..c589bea674 100755
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -47,8 +47,8 @@
 std::vector<LLVolumeImplFlexible*> LLVolumeImplFlexible::sInstanceList;
 std::vector<S32> LLVolumeImplFlexible::sUpdateDelay;
 
-static LLTrace::TimeBlock FTM_FLEXIBLE_REBUILD("Rebuild");
-static LLTrace::TimeBlock FTM_DO_FLEXIBLE_UPDATE("Flexible Update");
+static LLTrace::BlockTimerStatHandle FTM_FLEXIBLE_REBUILD("Rebuild");
+static LLTrace::BlockTimerStatHandle FTM_DO_FLEXIBLE_UPDATE("Flexible Update");
 
 // LLFlexibleObjectData::pack/unpack now in llprimitive.cpp
 
@@ -334,7 +334,7 @@ void LLVolumeImplFlexible::updateRenderRes()
 // updated every time step. In the future, perhaps there could be an 
 // optimization similar to what Havok does for objects that are stationary. 
 //---------------------------------------------------------------------------------
-static LLTrace::TimeBlock FTM_FLEXIBLE_UPDATE("Update Flexies");
+static LLTrace::BlockTimerStatHandle FTM_FLEXIBLE_UPDATE("Update Flexies");
 void LLVolumeImplFlexible::doIdleUpdate()
 {
 	LLDrawable* drawablep = mVO->mDrawable;
@@ -715,7 +715,7 @@ void LLVolumeImplFlexible::doFlexibleUpdate()
 	mLastSegmentRotation = parentSegmentRotation;
 }
 
-static LLFastTimer::DeclareTimer FTM_FLEXI_PREBUILD("Flexi Prebuild");
+static LLTrace::BlockTimerStatHandle FTM_FLEXI_PREBUILD("Flexi Prebuild");
 
 void LLVolumeImplFlexible::preRebuild()
 {
diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp
index d76d6d422f..0dc667f9f5 100755
--- a/indra/newview/llfolderviewmodelinventory.cpp
+++ b/indra/newview/llfolderviewmodelinventory.cpp
@@ -34,7 +34,7 @@
 //
 // class LLFolderViewModelInventory
 //
-static LLTrace::TimeBlock FTM_INVENTORY_SORT("Sort");
+static LLTrace::BlockTimerStatHandle FTM_INVENTORY_SORT("Sort");
 
 bool LLFolderViewModelInventory::startDrag(std::vector<LLFolderViewModelItem*>& items)
 {
diff --git a/indra/newview/llhudmanager.cpp b/indra/newview/llhudmanager.cpp
index 9d7b8b13e3..6b6d7d7e7f 100755
--- a/indra/newview/llhudmanager.cpp
+++ b/indra/newview/llhudmanager.cpp
@@ -54,7 +54,7 @@ LLHUDManager::~LLHUDManager()
 {
 }
 
-static LLTrace::TimeBlock FTM_HUD_EFFECTS("Hud Effects");
+static LLTrace::BlockTimerStatHandle FTM_HUD_EFFECTS("Hud Effects");
 
 void LLHUDManager::updateEffects()
 {
diff --git a/indra/newview/llhudobject.cpp b/indra/newview/llhudobject.cpp
index 4b0dadec38..45fa09e1a1 100755
--- a/indra/newview/llhudobject.cpp
+++ b/indra/newview/llhudobject.cpp
@@ -252,7 +252,7 @@ LLHUDEffect *LLHUDObject::addHUDEffect(const U8 type)
 	return hud_objectp;
 }
 
-static LLTrace::TimeBlock FTM_HUD_UPDATE("Update Hud");
+static LLTrace::BlockTimerStatHandle FTM_HUD_UPDATE("Update Hud");
 
 // static
 void LLHUDObject::updateAll()
diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp
index c71e610941..33f0e56e4b 100755
--- a/indra/newview/llinventoryfilter.cpp
+++ b/indra/newview/llinventoryfilter.cpp
@@ -42,7 +42,7 @@
 #include "llclipboard.h"
 #include "lltrans.h"
 
-LLTrace::TimeBlock FT_FILTER_CLIPBOARD("Filter Clipboard");
+LLTrace::BlockTimerStatHandle FT_FILTER_CLIPBOARD("Filter Clipboard");
 
 LLInventoryFilter::FilterOps::FilterOps(const Params& p)
 :	mFilterObjectTypes(p.object_types),
diff --git a/indra/newview/llinventoryitemslist.cpp b/indra/newview/llinventoryitemslist.cpp
index f6d0ecc5bf..36e1cc97d1 100755
--- a/indra/newview/llinventoryitemslist.cpp
+++ b/indra/newview/llinventoryitemslist.cpp
@@ -133,7 +133,7 @@ void LLInventoryItemsList::idle(void* user_data)
 	}
 }
 
-LLTrace::TimeBlock FTM_INVENTORY_ITEMS_REFRESH("Inventory List Refresh");
+LLTrace::BlockTimerStatHandle FTM_INVENTORY_ITEMS_REFRESH("Inventory List Refresh");
 
 void LLInventoryItemsList::refresh()
 {
diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp
index 6358620f0b..d10aa6d7b0 100755
--- a/indra/newview/llinventorypanel.cpp
+++ b/indra/newview/llinventorypanel.cpp
@@ -397,7 +397,7 @@ LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState()
 }
 
 // Called when something changed in the global model (new item, item coming through the wire, rename, move, etc...) (CHUI-849)
-static LLTrace::TimeBlock FTM_REFRESH("Inventory Refresh");
+static LLTrace::BlockTimerStatHandle FTM_REFRESH("Inventory Refresh");
 void LLInventoryPanel::modelChanged(U32 mask)
 {
 	LL_RECORD_BLOCK_TIME(FTM_REFRESH);
@@ -1295,7 +1295,7 @@ void LLInventoryPanel::removeItemID(const LLUUID& id)
 	}
 }
 
-LLTrace::TimeBlock FTM_GET_ITEM_BY_ID("Get FolderViewItem by ID");
+LLTrace::BlockTimerStatHandle FTM_GET_ITEM_BY_ID("Get FolderViewItem by ID");
 LLFolderViewItem* LLInventoryPanel::getItemByID(const LLUUID& id)
 {
 	LL_RECORD_BLOCK_TIME(FTM_GET_ITEM_BY_ID);
diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp
index a3a080ab59..973220007a 100644
--- a/indra/newview/llmaterialmgr.cpp
+++ b/indra/newview/llmaterialmgr.cpp
@@ -527,7 +527,7 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content)
 	}
 }
 
-static LLTrace::TimeBlock FTM_MATERIALS_IDLE("Materials");
+static LLTrace::BlockTimerStatHandle FTM_MATERIALS_IDLE("Materials");
 
 void LLMaterialMgr::onIdle(void*)
 {
diff --git a/indra/newview/llpersistentnotificationstorage.cpp b/indra/newview/llpersistentnotificationstorage.cpp
index c13c305791..ff47fa42a9 100755
--- a/indra/newview/llpersistentnotificationstorage.cpp
+++ b/indra/newview/llpersistentnotificationstorage.cpp
@@ -47,7 +47,7 @@ LLPersistentNotificationStorage::~LLPersistentNotificationStorage()
 {
 }
 
-static LLTrace::TimeBlock FTM_SAVE_NOTIFICATIONS("Save Notifications");
+static LLTrace::BlockTimerStatHandle FTM_SAVE_NOTIFICATIONS("Save Notifications");
 
 void LLPersistentNotificationStorage::saveNotifications()
 {
@@ -82,7 +82,7 @@ void LLPersistentNotificationStorage::saveNotifications()
 	writeNotifications(output);
 }
 
-static LLTrace::TimeBlock FTM_LOAD_NOTIFICATIONS("Load Notifications");
+static LLTrace::BlockTimerStatHandle FTM_LOAD_NOTIFICATIONS("Load Notifications");
 
 void LLPersistentNotificationStorage::loadNotifications()
 {
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp
index 142cda87a4..6c35ae2672 100644
--- a/indra/newview/llscenemonitor.cpp
+++ b/indra/newview/llscenemonitor.cpp
@@ -331,8 +331,8 @@ bool LLSceneMonitor::needsUpdate() const
 	return mDiffState == NEED_DIFF;
 }
 
-static LLTrace::TimeBlock FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture");
-static LLTrace::TimeBlock FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Diff");
+static LLTrace::BlockTimerStatHandle FTM_GENERATE_SCENE_LOAD_DITHER_TEXTURE("Generate Scene Load Dither Texture");
+static LLTrace::BlockTimerStatHandle FTM_SCENE_LOAD_IMAGE_DIFF("Scene Load Image Diff");
 
 static LLStaticHashedString sDitherScale("dither_scale");
 static LLStaticHashedString sDitherScaleS("dither_scale_s");
diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp
index fbf3c8c401..6a840f3f40 100755
--- a/indra/newview/llscreenchannel.cpp
+++ b/indra/newview/llscreenchannel.cpp
@@ -49,7 +49,7 @@ using namespace LLNotificationsUI;
 
 bool LLScreenChannel::mWasStartUpToastShown = false;
 
-LLTrace::TimeBlock FTM_GET_CHANNEL_RECT("Calculate Notification Channel Region");
+LLTrace::BlockTimerStatHandle FTM_GET_CHANNEL_RECT("Calculate Notification Channel Region");
 LLRect LLScreenChannelBase::getChannelRect()
 {
 	LL_RECORD_BLOCK_TIME(FTM_GET_CHANNEL_RECT);
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index fe4f53425e..449a192332 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -53,8 +53,8 @@
 #include "lltextureatlas.h"
 #include "llviewershadermgr.h"
 
-static LLTrace::TimeBlock FTM_FRUSTUM_CULL("Frustum Culling");
-static LLTrace::TimeBlock FTM_CULL_REBOUND("Cull Rebound Partition");
+static LLTrace::BlockTimerStatHandle FTM_FRUSTUM_CULL("Frustum Culling");
+static LLTrace::BlockTimerStatHandle FTM_CULL_REBOUND("Cull Rebound Partition");
 
 extern bool gShiftFrame;
 
@@ -409,10 +409,10 @@ void LLSpatialGroup::rebuildMesh()
 	}
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_VBO("VBO Rebuilt");
-static LLTrace::TimeBlock FTM_ADD_GEOMETRY_COUNT("Add Geometry");
-static LLTrace::TimeBlock FTM_CREATE_VB("Create VB");
-static LLTrace::TimeBlock FTM_GET_GEOMETRY("Get Geometry");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_VBO("VBO Rebuilt");
+static LLTrace::BlockTimerStatHandle FTM_ADD_GEOMETRY_COUNT("Add Geometry");
+static LLTrace::BlockTimerStatHandle FTM_CREATE_VB("Create VB");
+static LLTrace::BlockTimerStatHandle FTM_GET_GEOMETRY("Get Geometry");
 
 void LLSpatialPartition::rebuildGeom(LLSpatialGroup* group)
 {
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 6545f35091..ae16372963 100755
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -180,7 +180,7 @@ void display_startup()
 	glClear(GL_DEPTH_BUFFER_BIT);
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_CAMERA("Update Camera");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Update Camera");
 
 void display_update_camera()
 {
@@ -228,20 +228,20 @@ void display_stats()
 	}
 }
 
-static LLTrace::TimeBlock FTM_PICK("Picking");
-static LLTrace::TimeBlock FTM_RENDER("Render");
-static LLTrace::TimeBlock FTM_UPDATE_SKY("Update Sky");
-static LLTrace::TimeBlock FTM_UPDATE_TEXTURES("Update Textures");
-static LLTrace::TimeBlock FTM_IMAGE_UPDATE("Update Images");
-static LLTrace::TimeBlock FTM_IMAGE_UPDATE_CLASS("Class");
-static LLTrace::TimeBlock FTM_IMAGE_UPDATE_BUMP("Image Update Bump");
-static LLTrace::TimeBlock FTM_IMAGE_UPDATE_LIST("List");
-static LLTrace::TimeBlock FTM_IMAGE_UPDATE_DELETE("Delete");
-static LLTrace::TimeBlock FTM_RESIZE_WINDOW("Resize Window");
-static LLTrace::TimeBlock FTM_HUD_UPDATE("HUD Update");
-static LLTrace::TimeBlock FTM_DISPLAY_UPDATE_GEOM("Update Geom");
-static LLTrace::TimeBlock FTM_TEXTURE_UNBIND("Texture Unbind");
-static LLTrace::TimeBlock FTM_TELEPORT_DISPLAY("Teleport Display");
+static LLTrace::BlockTimerStatHandle FTM_PICK("Picking");
+static LLTrace::BlockTimerStatHandle FTM_RENDER("Render");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_SKY("Update Sky");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_TEXTURES("Update Textures");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE("Update Images");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_CLASS("Class");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_BUMP("Image Update Bump");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_LIST("List");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_DELETE("Delete");
+static LLTrace::BlockTimerStatHandle FTM_RESIZE_WINDOW("Resize Window");
+static LLTrace::BlockTimerStatHandle FTM_HUD_UPDATE("HUD Update");
+static LLTrace::BlockTimerStatHandle FTM_DISPLAY_UPDATE_GEOM("Update Geom");
+static LLTrace::BlockTimerStatHandle FTM_TEXTURE_UNBIND("Texture Unbind");
+static LLTrace::BlockTimerStatHandle FTM_TELEPORT_DISPLAY("Teleport Display");
 
 // Paint the display!
 void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
@@ -1331,7 +1331,7 @@ void render_ui(F32 zoom_factor, int subfield)
 	}
 }
 
-static LLTrace::TimeBlock FTM_SWAP("Swap");
+static LLTrace::BlockTimerStatHandle FTM_SWAP("Swap");
 
 void swap()
 {
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 39f8249300..3ba91ff3cd 100755
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -172,7 +172,7 @@ void LLViewerFloaterReg::registerFloaters()
 	// *NOTE: Please keep these alphabetized for easier merges
 
 	LLFloaterAboutUtil::registerFloater();
-	LLFloaterReg::add("fast_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>);
+	LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>);
 	LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>);
 	LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
 	LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>);
diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp
index deabc9c8b3..bf7cf08c63 100755
--- a/indra/newview/llviewerjointmesh.cpp
+++ b/indra/newview/llviewerjointmesh.cpp
@@ -376,7 +376,7 @@ void LLViewerJointMesh::updateFaceSizes(U32 &num_vertices, U32& num_indices, F32
 //-----------------------------------------------------------------------------
 // updateFaceData()
 //-----------------------------------------------------------------------------
-static LLTrace::TimeBlock FTM_AVATAR_FACE("Avatar Face");
+static LLTrace::BlockTimerStatHandle FTM_AVATAR_FACE("Avatar Face");
 
 void LLViewerJointMesh::updateFaceData(LLFace *face, F32 pixel_area, BOOL damp_wind, bool terse_update)
 {
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 868cb740dc..d8684a5e5c 100755
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -776,12 +776,12 @@ static bool proximity_comparitor(const LLViewerMediaImpl* i1, const LLViewerMedi
 	}
 }
 
-static LLTrace::TimeBlock FTM_MEDIA_UPDATE("Update Media");
-static LLTrace::TimeBlock FTM_MEDIA_SPARE_IDLE("Spare Idle");
-static LLTrace::TimeBlock FTM_MEDIA_UPDATE_INTEREST("Update/Interest");
-static LLTrace::TimeBlock FTM_MEDIA_SORT("Sort");
-static LLTrace::TimeBlock FTM_MEDIA_SORT2("Sort 2");
-static LLTrace::TimeBlock FTM_MEDIA_MISC("Misc");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_UPDATE("Update Media");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_SPARE_IDLE("Spare Idle");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_UPDATE_INTEREST("Update/Interest");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_SORT("Sort");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_SORT2("Sort 2");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_MISC("Misc");
 
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -2746,9 +2746,9 @@ bool LLViewerMediaImpl::canNavigateBack()
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
-static LLTrace::TimeBlock FTM_MEDIA_DO_UPDATE("Do Update");
-static LLTrace::TimeBlock FTM_MEDIA_GET_DATA("Get Data");
-static LLTrace::TimeBlock FTM_MEDIA_SET_SUBIMAGE("Set Subimage");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_DO_UPDATE("Do Update");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_GET_DATA("Get Data");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_SET_SUBIMAGE("Set Subimage");
 
 
 void LLViewerMediaImpl::update()
@@ -3435,7 +3435,7 @@ BOOL LLViewerMediaImpl::isUpdated()
 	return mIsUpdated ;
 }
 
-static LLTrace::TimeBlock FTM_MEDIA_CALCULATE_INTEREST("Calculate Interest");
+static LLTrace::BlockTimerStatHandle FTM_MEDIA_CALCULATE_INTEREST("Calculate Interest");
 
 void LLViewerMediaImpl::calculateInterest()
 {
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 792394b423..4b0957679c 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -524,7 +524,7 @@ class LLAdvancedToggleConsole : public view_listener_t
 		}
 		else if ("fast timers" == console_type)
 		{
-			LLFloaterReg::toggleInstance("fast_timers");
+			LLFloaterReg::toggleInstance("block_timers");
 		}
 		else if ("scene view" == console_type)
 		{
@@ -550,7 +550,7 @@ class LLAdvancedCheckConsole : public view_listener_t
 		}
 		else if ("fast timers" == console_type)
 		{
-			new_value = LLFloaterReg::instanceVisible("fast_timers");
+			new_value = LLFloaterReg::instanceVisible("block_timers");
 		}
 		else if ("scene view" == console_type)
 		{
@@ -7491,7 +7491,7 @@ void handle_dump_avatar_local_textures(void*)
 
 void handle_dump_timers()
 {
-	LLTrace::TimeBlock::dumpCurTimes();
+	LLTrace::BlockTimerStatHandle::dumpCurTimes();
 }
 
 void handle_debug_avatar_textures(void*)
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index b8d3d0387c..10df15a836 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4245,7 +4245,7 @@ const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f;	// ~= 2.5 degrees -- if its less th
 const F32 MAX_HEAD_ROT_QDOT = 0.99999f;			// ~= 0.5 degrees -- if its greater than this then no need to update head_rot
 												// between these values we delay the updates (but no more than one second)
 
-static LLTrace::TimeBlock FTM_AGENT_UPDATE_SEND("Send Message");
+static LLTrace::BlockTimerStatHandle FTM_AGENT_UPDATE_SEND("Send Message");
 
 void send_agent_update(BOOL force_send, BOOL send_reliable)
 {
@@ -4560,7 +4560,7 @@ void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_
 	gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
 }
 
-static LLTrace::TimeBlock FTM_PROCESS_OBJECTS("Process Kill Objects");
+static LLTrace::BlockTimerStatHandle FTM_PROCESS_OBJECTS("Process Kill Objects");
 
 void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
 {
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 9f49e8aff5..2dbcdeeb64 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -132,7 +132,7 @@ std::map<std::string, U32> LLViewerObject::sObjectDataMap;
 
 const F32 PHYSICS_TIMESTEP = 1.f / 45.f;
 
-static LLTrace::TimeBlock FTM_CREATE_OBJECT("Create Object");
+static LLTrace::BlockTimerStatHandle FTM_CREATE_OBJECT("Create Object");
 
 // static
 LLViewerObject *LLViewerObject::createObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
@@ -2409,7 +2409,7 @@ void LLViewerObject::loadFlags(U32 flags)
 
 void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
 {
-	//static LLTrace::TimeBlock ftm("Viewer Object");
+	//static LLTrace::BlockTimerStatHandle ftm("Viewer Object");
 	//LL_RECORD_BLOCK_TIME(ftm);
 
 	if (!mDead)
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 686eff8426..861fc1b8bc 100755
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -289,7 +289,7 @@ void LLViewerObjectList::processUpdateCore(LLViewerObject* objectp,
 	}
 }
 
-static LLTrace::TimeBlock FTM_PROCESS_OBJECTS("Process Objects");
+static LLTrace::BlockTimerStatHandle FTM_PROCESS_OBJECTS("Process Objects");
 
 LLViewerObject* LLViewerObjectList::processObjectUpdateFromCache(LLVOCacheEntry* entry, LLViewerRegion* regionp)
 {
@@ -978,7 +978,7 @@ private:
 	LLSD mObjectIDs;
 };
 
-static LLTrace::TimeBlock FTM_IDLE_COPY("Idle Copy");
+static LLTrace::BlockTimerStatHandle FTM_IDLE_COPY("Idle Copy");
 
 void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
 {
@@ -1328,7 +1328,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
 	mNumDeadObjects++;
 }
 
-static LLTrace::TimeBlock FTM_REMOVE_DRAWABLE("Remove Drawable");
+static LLTrace::BlockTimerStatHandle FTM_REMOVE_DRAWABLE("Remove Drawable");
 
 void LLViewerObjectList::removeDrawable(LLDrawable* drawablep)
 {
@@ -1617,9 +1617,9 @@ void LLViewerObjectList::onPhysicsFlagsFetchFailure(const LLUUID& object_id)
 	mPendingPhysicsFlags.erase(object_id);
 }
 
-static LLTrace::TimeBlock FTM_SHIFT_OBJECTS("Shift Objects");
-static LLTrace::TimeBlock FTM_PIPELINE_SHIFT("Pipeline Shift");
-static LLTrace::TimeBlock FTM_REGION_SHIFT("Region Shift");
+static LLTrace::BlockTimerStatHandle FTM_SHIFT_OBJECTS("Shift Objects");
+static LLTrace::BlockTimerStatHandle FTM_PIPELINE_SHIFT("Pipeline Shift");
+static LLTrace::BlockTimerStatHandle FTM_REGION_SHIFT("Region Shift");
 
 void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
 {
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index ce8eef7d86..e390249504 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -1020,8 +1020,8 @@ void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode)
 	}
 }
 
-static LLTrace::TimeBlock FTM_OCCLUSION_READBACK("Readback Occlusion");
-static LLTrace::TimeBlock FTM_OCCLUSION_WAIT("Occlusion Wait");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_READBACK("Readback Occlusion");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_WAIT("Occlusion Wait");
 
 BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* bounds)
 {
@@ -1158,16 +1158,16 @@ void LLOcclusionCullingGroup::checkOcclusion()
 	}
 }
 
-static LLTrace::TimeBlock FTM_PUSH_OCCLUSION_VERTS("Push Occlusion");
-static LLTrace::TimeBlock FTM_SET_OCCLUSION_STATE("Occlusion State");
-static LLTrace::TimeBlock FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail");
-static LLTrace::TimeBlock FTM_OCCLUSION_ALLOCATE("Allocate");
-static LLTrace::TimeBlock FTM_OCCLUSION_BUILD("Build");
-static LLTrace::TimeBlock FTM_OCCLUSION_BEGIN_QUERY("Begin Query");
-static LLTrace::TimeBlock FTM_OCCLUSION_END_QUERY("End Query");
-static LLTrace::TimeBlock FTM_OCCLUSION_SET_BUFFER("Set Buffer");
-static LLTrace::TimeBlock FTM_OCCLUSION_DRAW_WATER("Draw Water");
-static LLTrace::TimeBlock FTM_OCCLUSION_DRAW("Draw");
+static LLTrace::BlockTimerStatHandle FTM_PUSH_OCCLUSION_VERTS("Push Occlusion");
+static LLTrace::BlockTimerStatHandle FTM_SET_OCCLUSION_STATE("Occlusion State");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_EARLY_FAIL("Occlusion Early Fail");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_ALLOCATE("Allocate");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_BUILD("Build");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_BEGIN_QUERY("Begin Query");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_END_QUERY("End Query");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_SET_BUFFER("Set Buffer");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_DRAW_WATER("Draw Water");
+static LLTrace::BlockTimerStatHandle FTM_OCCLUSION_DRAW("Draw");
 
 void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* shift)
 {
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index cdb58f76d0..76418ad6a6 100755
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -657,7 +657,7 @@ void LLViewerPartSim::shift(const LLVector3 &offset)
 	}
 }
 
-static LLTrace::TimeBlock FTM_SIMULATE_PARTICLES("Simulate Particles");
+static LLTrace::BlockTimerStatHandle FTM_SIMULATE_PARTICLES("Simulate Particles");
 
 void LLViewerPartSim::updateSimulation()
 {
diff --git a/indra/newview/llviewerprecompiledheaders.cpp b/indra/newview/llviewerprecompiledheaders.cpp
index 768f1f3387..307e903726 100755
--- a/indra/newview/llviewerprecompiledheaders.cpp
+++ b/indra/newview/llviewerprecompiledheaders.cpp
@@ -26,7 +26,7 @@
 
 // source file that includes just the standard includes
 // newview.pch will be the pre-compiled header
-// llviewerprecompiledheaders.obj will contain the pre-compllviewiled type information
+// llviewerprecompiledheaders.obj will contain the pre-compiled type information
 
 #include "llviewerprecompiledheaders.h"
 
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 09bf022008..405fcff584 100755
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -455,7 +455,7 @@ const S32 min_non_tex_system_mem = (128<<20); // 128 MB
 F32 texmem_lower_bound_scale = 0.85f;
 F32 texmem_middle_bound_scale = 0.925f;
 
-static LLTrace::TimeBlock FTM_TEXTURE_MEMORY_CHECK("Memory Check");
+static LLTrace::BlockTimerStatHandle FTM_TEXTURE_MEMORY_CHECK("Memory Check");
 
 //static 
 bool LLViewerTexture::isMemoryForTextureLow()
@@ -510,8 +510,8 @@ bool LLViewerTexture::isMemoryForTextureLow()
 	return low_mem;
 }
 
-static LLTrace::TimeBlock FTM_TEXTURE_UPDATE_MEDIA("Media");
-static LLTrace::TimeBlock FTM_TEXTURE_UPDATE_TEST("Test");
+static LLTrace::BlockTimerStatHandle FTM_TEXTURE_UPDATE_MEDIA("Media");
+static LLTrace::BlockTimerStatHandle FTM_TEXTURE_UPDATE_TEST("Test");
 
 //static
 void LLViewerTexture::updateClass(const F32 velocity, const F32 angular_velocity)
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index cfcbe655b8..2f887d7185 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -68,7 +68,7 @@ void (*LLViewerTextureList::sUUIDCallback)(void **, const LLUUID&) = NULL;
 S32 LLViewerTextureList::sNumImages = 0;
 
 LLViewerTextureList gTextureList;
-static LLTrace::TimeBlock FTM_PROCESS_IMAGES("Process Images");
+static LLTrace::BlockTimerStatHandle FTM_PROCESS_IMAGES("Process Images");
 
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -662,14 +662,14 @@ void LLViewerTextureList::dirtyImage(LLViewerFetchedTexture *image)
 }
 
 ////////////////////////////////////////////////////////////////////////////
-static LLTrace::TimeBlock FTM_IMAGE_MARK_DIRTY("Dirty Images");
-static LLTrace::TimeBlock FTM_IMAGE_UPDATE_PRIORITIES("Prioritize");
-static LLTrace::TimeBlock FTM_IMAGE_CALLBACKS("Callbacks");
-static LLTrace::TimeBlock FTM_IMAGE_FETCH("Fetch");
-static LLTrace::TimeBlock FTM_FAST_CACHE_IMAGE_FETCH("Fast Cache Fetch");
-static LLTrace::TimeBlock FTM_IMAGE_CREATE("Create");
-static LLTrace::TimeBlock FTM_IMAGE_STATS("Stats");
-static LLTrace::TimeBlock FTM_UPDATE_IMAGES("Update Images");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_MARK_DIRTY("Dirty Images");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_UPDATE_PRIORITIES("Prioritize");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_CALLBACKS("Callbacks");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_FETCH("Fetch");
+static LLTrace::BlockTimerStatHandle FTM_FAST_CACHE_IMAGE_FETCH("Fast Cache Fetch");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_CREATE("Create");
+static LLTrace::BlockTimerStatHandle FTM_IMAGE_STATS("Stats");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_IMAGES("Update Images");
 
 void LLViewerTextureList::updateImages(F32 max_time)
 {
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 844f4344e0..3e1ffa573e 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -288,7 +288,7 @@ public:
 // LLDebugText
 //
 
-static LLTrace::TimeBlock FTM_DISPLAY_DEBUG_TEXT("Display Debug Text");
+static LLTrace::BlockTimerStatHandle FTM_DISPLAY_DEBUG_TEXT("Display Debug Text");
 
 class LLDebugText
 {
@@ -2839,7 +2839,7 @@ void append_xui_tooltip(LLView* viewp, LLToolTip::Params& params)
 	}
 }
 
-static LLTrace::TimeBlock ftm("Update UI");
+static LLTrace::BlockTimerStatHandle ftm("Update UI");
 
 // Update UI based on stored mouse position from mouse-move
 // event processing.
@@ -3417,7 +3417,7 @@ void LLViewerWindow::updateKeyboardFocus()
 	}
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_WORLD_VIEW("Update World View");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_WORLD_VIEW("Update World View");
 void LLViewerWindow::updateWorldViewRect(bool use_full_window)
 {
 	LL_RECORD_BLOCK_TIME(FTM_UPDATE_WORLD_VIEW);
@@ -4914,7 +4914,7 @@ void LLViewerWindow::requestResolutionUpdate()
 	mResDirty = true;
 }
 
-static LLTrace::TimeBlock FTM_WINDOW_CHECK_SETTINGS("Window Settings");
+static LLTrace::BlockTimerStatHandle FTM_WINDOW_CHECK_SETTINGS("Window Settings");
 
 void LLViewerWindow::checkSettings()
 {
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 64b4b2ee25..f6029f3bcd 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -1929,8 +1929,8 @@ S32 LLVOAvatar::setTETexture(const U8 te, const LLUUID& uuid)
 	return setTETextureCore(te, image);
 }
 
-static LLTrace::TimeBlock FTM_AVATAR_UPDATE("Avatar Update");
-static LLTrace::TimeBlock FTM_JOINT_UPDATE("Update Joints");
+static LLTrace::BlockTimerStatHandle FTM_AVATAR_UPDATE("Avatar Update");
+static LLTrace::BlockTimerStatHandle FTM_JOINT_UPDATE("Update Joints");
 
 //------------------------------------------------------------------------
 // LLVOAvatar::dumpAnimationState()
@@ -2169,7 +2169,7 @@ void LLVOAvatar::idleUpdateVoiceVisualizer(bool voice_enabled)
 	}//if ( voiceEnabled )
 }		
 
-static LLTrace::TimeBlock FTM_ATTACHMENT_UPDATE("Update Attachments");
+static LLTrace::BlockTimerStatHandle FTM_ATTACHMENT_UPDATE("Update Attachments");
 
 void LLVOAvatar::idleUpdateMisc(bool detailed_update)
 {
@@ -5426,7 +5426,7 @@ void LLVOAvatar::updateGL()
 //-----------------------------------------------------------------------------
 // updateGeometry()
 //-----------------------------------------------------------------------------
-static LLTrace::TimeBlock FTM_UPDATE_AVATAR("Update Avatar");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_AVATAR("Update Avatar");
 BOOL LLVOAvatar::updateGeometry(LLDrawable *drawable)
 {
 	LL_RECORD_BLOCK_TIME(FTM_UPDATE_AVATAR);
diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp
index 7aee0efe69..3d4d7aaa81 100755
--- a/indra/newview/llvograss.cpp
+++ b/indra/newview/llvograss.cpp
@@ -412,7 +412,7 @@ LLDrawable* LLVOGrass::createDrawable(LLPipeline *pipeline)
 	return mDrawable;
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_GRASS("Update Grass");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_GRASS("Update Grass");
 
 BOOL LLVOGrass::updateGeometry(LLDrawable *drawable)
 {
@@ -671,7 +671,7 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count
 	}
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_GRASS_VB("Grass VB");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_GRASS_VB("Grass VB");
 
 void LLGrassPartition::getGeometry(LLSpatialGroup* group)
 {
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 42211202f8..de553e9c42 100755
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -6314,7 +6314,7 @@ LLVivoxProtocolParser::~LLVivoxProtocolParser()
 		XML_ParserFree(parser);
 }
 
-static LLTrace::TimeBlock FTM_VIVOX_PROCESS("Vivox Process");
+static LLTrace::BlockTimerStatHandle FTM_VIVOX_PROCESS("Vivox Process");
 
 // virtual
 LLIOPipe::EStatus LLVivoxProtocolParser::process_impl(
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index cfc35692a8..f7289bcfaa 100755
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -292,7 +292,7 @@ LLVector3 LLVOPartGroup::getCameraPosition() const
 	return gAgentCamera.getCameraPositionAgent();
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_PARTICLES("Update Particles");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_PARTICLES("Update Particles");
 BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
 {
 	LL_RECORD_BLOCK_TIME(FTM_UPDATE_PARTICLES);
@@ -739,7 +739,7 @@ LLHUDParticlePartition::LLHUDParticlePartition(LLViewerRegion* regionp) :
 	mPartitionType = LLViewerRegion::PARTITION_HUD_PARTICLE;
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_PARTICLE_VBO("Particle VBO");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_PARTICLE_VBO("Particle VBO");
 
 void LLParticlePartition::rebuildGeom(LLSpatialGroup* group)
 {
@@ -828,7 +828,7 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
 }
 
 
-static LLTrace::TimeBlock FTM_REBUILD_PARTICLE_GEOM("Particle Geom");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_PARTICLE_GEOM("Particle Geom");
 
 void LLParticlePartition::getGeometry(LLSpatialGroup* group)
 {
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 00e52531d6..7bbcd3b709 100755
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -1243,7 +1243,7 @@ void LLVOSky::createDummyVertexBuffer()
 	}
 }
 
-static LLTrace::TimeBlock FTM_RENDER_FAKE_VBO_UPDATE("Fake VBO Update");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_FAKE_VBO_UPDATE("Fake VBO Update");
 
 void LLVOSky::updateDummyVertexBuffer()
 {	
@@ -1269,7 +1269,7 @@ void LLVOSky::updateDummyVertexBuffer()
 //----------------------------------
 //end of fake vertex buffer updating
 //----------------------------------
-static LLTrace::TimeBlock FTM_GEO_SKY("Sky Geometry");
+static LLTrace::BlockTimerStatHandle FTM_GEO_SKY("Sky Geometry");
 
 BOOL LLVOSky::updateGeometry(LLDrawable *drawable)
 {
diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp
index c77ba26ba3..79e1921f1b 100755
--- a/indra/newview/llvosurfacepatch.cpp
+++ b/indra/newview/llvosurfacepatch.cpp
@@ -212,7 +212,7 @@ LLDrawable *LLVOSurfacePatch::createDrawable(LLPipeline *pipeline)
 	return mDrawable;
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_TERRAIN("Update Terrain");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_TERRAIN("Update Terrain");
 
 void LLVOSurfacePatch::updateGL()
 {
@@ -1070,7 +1070,7 @@ LLVertexBuffer* LLTerrainPartition::createVertexBuffer(U32 type_mask, U32 usage)
 	return new LLVertexBufferTerrain();
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_TERRAIN_VB("Terrain VB");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_TERRAIN_VB("Terrain VB");
 void LLTerrainPartition::getGeometry(LLSpatialGroup* group)
 {
 	LL_RECORD_BLOCK_TIME(FTM_REBUILD_TERRAIN_VB);
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index dad8ba09fe..d33812ea68 100755
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -479,7 +479,7 @@ LLDrawable* LLVOTree::createDrawable(LLPipeline *pipeline)
 const S32 LEAF_INDICES = 24;
 const S32 LEAF_VERTICES = 16;
 
-static LLTrace::TimeBlock FTM_UPDATE_TREE("Update Tree");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_TREE("Update Tree");
 
 BOOL LLVOTree::updateGeometry(LLDrawable *drawable)
 {
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index ae18410ed1..52c4c24686 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -96,9 +96,9 @@ S32 LLVOVolume::mRenderComplexity_current = 0;
 LLPointer<LLObjectMediaDataClient> LLVOVolume::sObjectMediaClient = NULL;
 LLPointer<LLObjectMediaNavigateClient> LLVOVolume::sObjectMediaNavigateClient = NULL;
 
-static LLTrace::TimeBlock FTM_GEN_TRIANGLES("Generate Triangles");
-static LLTrace::TimeBlock FTM_GEN_VOLUME("Generate Volumes");
-static LLTrace::TimeBlock FTM_VOLUME_TEXTURES("Volume Textures");
+static LLTrace::BlockTimerStatHandle FTM_GEN_TRIANGLES("Generate Triangles");
+static LLTrace::BlockTimerStatHandle FTM_GEN_VOLUME("Generate Volumes");
+static LLTrace::BlockTimerStatHandle FTM_VOLUME_TEXTURES("Volume Textures");
 
 extern BOOL gGLDebugLoggingEnabled;
 
@@ -1630,9 +1630,9 @@ void LLVOVolume::updateRelativeXform(bool force_identity)
 	}
 }
 
-static LLTrace::TimeBlock FTM_GEN_FLEX("Generate Flexies");
-static LLTrace::TimeBlock FTM_UPDATE_PRIMITIVES("Update Primitives");
-static LLTrace::TimeBlock FTM_UPDATE_RIGGED_VOLUME("Update Rigged");
+static LLTrace::BlockTimerStatHandle FTM_GEN_FLEX("Generate Flexies");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_PRIMITIVES("Update Primitives");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_RIGGED_VOLUME("Update Rigged");
 
 BOOL LLVOVolume::updateGeometry(LLDrawable *drawable)
 {
@@ -3917,8 +3917,8 @@ void LLVOVolume::updateRiggedVolume()
 
 }
 
-static LLTrace::TimeBlock FTM_SKIN_RIGGED("Skin");
-static LLTrace::TimeBlock FTM_RIGGED_OCTREE("Octree");
+static LLTrace::BlockTimerStatHandle FTM_SKIN_RIGGED("Skin");
+static LLTrace::BlockTimerStatHandle FTM_RIGGED_OCTREE("Octree");
 
 void LLRiggedVolume::update(const LLMeshSkinInfo* skin, LLVOAvatar* avatar, const LLVolume* volume)
 {
@@ -4115,7 +4115,7 @@ bool can_batch_texture(LLFace* facep)
 	return true;
 }
 
-static LLTrace::TimeBlock FTM_REGISTER_FACE("Register Face");
+static LLTrace::BlockTimerStatHandle FTM_REGISTER_FACE("Register Face");
 
 void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, U32 type)
 {
@@ -4346,9 +4346,9 @@ void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group)
 
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_VOLUME_VB("Volume VB");
-static LLTrace::TimeBlock FTM_REBUILD_VOLUME_FACE_LIST("Build Face List");
-static LLTrace::TimeBlock FTM_REBUILD_VOLUME_GEN_DRAW_INFO("Gen Draw Info");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_VOLUME_VB("Volume VB");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_VOLUME_FACE_LIST("Build Face List");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_VOLUME_GEN_DRAW_INFO("Gen Draw Info");
 
 static LLDrawPoolAvatar* get_avatar_drawpool(LLViewerObject* vobj)
 {
@@ -5047,7 +5047,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 }
 }
 
-static LLFastTimer::DeclareTimer FTM_REBUILD_MESH_FLUSH("Flush Mesh");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_MESH_FLUSH("Flush Mesh");
 
 void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
 {
@@ -5195,11 +5195,11 @@ struct CompareBatchBreakerModified
 	}
 };
 
-static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_SORT("Draw Info Face Sort");
-static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_FACE_SIZE("Face Sizing");
-static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_ALLOCATE("Allocate VB");
-static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_FIND_VB("Find VB");
-static LLTrace::TimeBlock FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB");
+static LLTrace::BlockTimerStatHandle FTM_GEN_DRAW_INFO_SORT("Draw Info Face Sort");
+static LLTrace::BlockTimerStatHandle FTM_GEN_DRAW_INFO_FACE_SIZE("Face Sizing");
+static LLTrace::BlockTimerStatHandle FTM_GEN_DRAW_INFO_ALLOCATE("Allocate VB");
+static LLTrace::BlockTimerStatHandle FTM_GEN_DRAW_INFO_FIND_VB("Find VB");
+static LLTrace::BlockTimerStatHandle FTM_GEN_DRAW_INFO_RESIZE_VB("Resize VB");
 
 
 
diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp
index 9f01e56284..a140d927a5 100755
--- a/indra/newview/llvowater.cpp
+++ b/indra/newview/llvowater.cpp
@@ -123,7 +123,7 @@ LLDrawable *LLVOWater::createDrawable(LLPipeline *pipeline)
 	return mDrawable;
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_WATER("Update Water");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_WATER("Update Water");
 
 BOOL LLVOWater::updateGeometry(LLDrawable *drawable)
 {
diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp
index e798a6eb51..3a2ced9f72 100755
--- a/indra/newview/llvowlsky.cpp
+++ b/indra/newview/llvowlsky.cpp
@@ -301,7 +301,7 @@ void LLVOWLSky::restoreGL()
 	gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE);
 }
 
-static LLTrace::TimeBlock FTM_GEO_SKY("Windlight Sky Geometry");
+static LLTrace::BlockTimerStatHandle FTM_GEO_SKY("Windlight Sky Geometry");
 
 BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable)
 {
diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp
index b30475d7df..c854e1fc66 100755
--- a/indra/newview/llwaterparammanager.cpp
+++ b/indra/newview/llwaterparammanager.cpp
@@ -215,7 +215,7 @@ void LLWaterParamManager::applyParams(const LLSD& params, bool interpolate)
 	}
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_WATERPARAM("Update Water Params");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_WATERPARAM("Update Water Params");
 
 void LLWaterParamManager::update(LLViewerCamera * cam)
 {
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index a6cc651eda..91ea10d43d 100755
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -364,7 +364,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader)
 	
 }
 
-static LLTrace::TimeBlock FTM_UPDATE_WLPARAM("Update Windlight Params");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_WLPARAM("Update Windlight Params");
 
 void LLWLParamManager::propagateParameters(void)
 {
diff --git a/indra/newview/llwlparamset.cpp b/indra/newview/llwlparamset.cpp
index 58f10e9078..066cb9a0ac 100755
--- a/indra/newview/llwlparamset.cpp
+++ b/indra/newview/llwlparamset.cpp
@@ -60,7 +60,7 @@ LLWLParamSet::LLWLParamSet(void) :
 	mCloudScrollXOffset(0.f), mCloudScrollYOffset(0.f)	
 {}
 
-static LLTrace::TimeBlock FTM_WL_PARAM_UPDATE("WL Param Update");
+static LLTrace::BlockTimerStatHandle FTM_WL_PARAM_UPDATE("WL Param Update");
 
 void LLWLParamSet::update(LLGLSLShader * shader) const 
 {	
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index e4e0a745ce..1940bdcccc 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -1035,7 +1035,7 @@ void LLWorld::disconnectRegions()
 	}
 }
 
-static LLTrace::TimeBlock FTM_ENABLE_SIMULATOR("Enable Sim");
+static LLTrace::BlockTimerStatHandle FTM_ENABLE_SIMULATOR("Enable Sim");
 
 void process_enable_simulator(LLMessageSystem *msg, void **user_data)
 {
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index aba26bf586..5983fee222 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -228,40 +228,40 @@ BOOL	gDebugPipeline = FALSE;
 LLPipeline gPipeline;
 const LLMatrix4* gGLLastMatrix = NULL;
 
-LLTrace::TimeBlock FTM_RENDER_GEOMETRY("Render Geometry");
-LLTrace::TimeBlock FTM_RENDER_GRASS("Grass");
-LLTrace::TimeBlock FTM_RENDER_INVISIBLE("Invisible");
-LLTrace::TimeBlock FTM_RENDER_OCCLUSION("Occlusion");
-LLTrace::TimeBlock FTM_RENDER_SHINY("Shiny");
-LLTrace::TimeBlock FTM_RENDER_SIMPLE("Simple");
-LLTrace::TimeBlock FTM_RENDER_TERRAIN("Terrain");
-LLTrace::TimeBlock FTM_RENDER_TREES("Trees");
-LLTrace::TimeBlock FTM_RENDER_UI("UI");
-LLTrace::TimeBlock FTM_RENDER_WATER("Water");
-LLTrace::TimeBlock FTM_RENDER_WL_SKY("Windlight Sky");
-LLTrace::TimeBlock FTM_RENDER_ALPHA("Alpha Objects");
-LLTrace::TimeBlock FTM_RENDER_CHARACTERS("Avatars");
-LLTrace::TimeBlock FTM_RENDER_BUMP("Bump");
-LLTrace::TimeBlock FTM_RENDER_MATERIALS("Materials");
-LLTrace::TimeBlock FTM_RENDER_FULLBRIGHT("Fullbright");
-LLTrace::TimeBlock FTM_RENDER_GLOW("Glow");
-LLTrace::TimeBlock FTM_GEO_UPDATE("Geo Update");
-LLTrace::TimeBlock FTM_PIPELINE_CREATE("Pipeline Create");
-LLTrace::TimeBlock FTM_POOLRENDER("RenderPool");
-LLTrace::TimeBlock FTM_POOLS("Pools");
-LLTrace::TimeBlock FTM_DEFERRED_POOLRENDER("RenderPool (Deferred)");
-LLTrace::TimeBlock FTM_DEFERRED_POOLS("Pools (Deferred)");
-LLTrace::TimeBlock FTM_POST_DEFERRED_POOLRENDER("RenderPool (Post)");
-LLTrace::TimeBlock FTM_POST_DEFERRED_POOLS("Pools (Post)");
-LLTrace::TimeBlock FTM_RENDER_BLOOM_FBO("First FBO");
-LLTrace::TimeBlock FTM_STATESORT("Sort Draw State");
-LLTrace::TimeBlock FTM_PIPELINE("Pipeline");
-LLTrace::TimeBlock FTM_CLIENT_COPY("Client Copy");
-LLTrace::TimeBlock FTM_RENDER_DEFERRED("Deferred Shading");
-
-
-static LLTrace::TimeBlock FTM_STATESORT_DRAWABLE("Sort Drawables");
-static LLTrace::TimeBlock FTM_STATESORT_POSTSORT("Post Sort");
+LLTrace::BlockTimerStatHandle FTM_RENDER_GEOMETRY("Render Geometry");
+LLTrace::BlockTimerStatHandle FTM_RENDER_GRASS("Grass");
+LLTrace::BlockTimerStatHandle FTM_RENDER_INVISIBLE("Invisible");
+LLTrace::BlockTimerStatHandle FTM_RENDER_OCCLUSION("Occlusion");
+LLTrace::BlockTimerStatHandle FTM_RENDER_SHINY("Shiny");
+LLTrace::BlockTimerStatHandle FTM_RENDER_SIMPLE("Simple");
+LLTrace::BlockTimerStatHandle FTM_RENDER_TERRAIN("Terrain");
+LLTrace::BlockTimerStatHandle FTM_RENDER_TREES("Trees");
+LLTrace::BlockTimerStatHandle FTM_RENDER_UI("UI");
+LLTrace::BlockTimerStatHandle FTM_RENDER_WATER("Water");
+LLTrace::BlockTimerStatHandle FTM_RENDER_WL_SKY("Windlight Sky");
+LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA("Alpha Objects");
+LLTrace::BlockTimerStatHandle FTM_RENDER_CHARACTERS("Avatars");
+LLTrace::BlockTimerStatHandle FTM_RENDER_BUMP("Bump");
+LLTrace::BlockTimerStatHandle FTM_RENDER_MATERIALS("Materials");
+LLTrace::BlockTimerStatHandle FTM_RENDER_FULLBRIGHT("Fullbright");
+LLTrace::BlockTimerStatHandle FTM_RENDER_GLOW("Glow");
+LLTrace::BlockTimerStatHandle FTM_GEO_UPDATE("Geo Update");
+LLTrace::BlockTimerStatHandle FTM_PIPELINE_CREATE("Pipeline Create");
+LLTrace::BlockTimerStatHandle FTM_POOLRENDER("RenderPool");
+LLTrace::BlockTimerStatHandle FTM_POOLS("Pools");
+LLTrace::BlockTimerStatHandle FTM_DEFERRED_POOLRENDER("RenderPool (Deferred)");
+LLTrace::BlockTimerStatHandle FTM_DEFERRED_POOLS("Pools (Deferred)");
+LLTrace::BlockTimerStatHandle FTM_POST_DEFERRED_POOLRENDER("RenderPool (Post)");
+LLTrace::BlockTimerStatHandle FTM_POST_DEFERRED_POOLS("Pools (Post)");
+LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM_FBO("First FBO");
+LLTrace::BlockTimerStatHandle FTM_STATESORT("Sort Draw State");
+LLTrace::BlockTimerStatHandle FTM_PIPELINE("Pipeline");
+LLTrace::BlockTimerStatHandle FTM_CLIENT_COPY("Client Copy");
+LLTrace::BlockTimerStatHandle FTM_RENDER_DEFERRED("Deferred Shading");
+
+
+static LLTrace::BlockTimerStatHandle FTM_STATESORT_DRAWABLE("Sort Drawables");
+static LLTrace::BlockTimerStatHandle FTM_STATESORT_POSTSORT("Post Sort");
 
 static LLStaticHashedString sTint("tint");
 static LLStaticHashedString sAmbiance("ambiance");
@@ -772,7 +772,7 @@ void LLPipeline::destroyGL()
 	}
 }
 
-static LLTrace::TimeBlock FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
+static LLTrace::BlockTimerStatHandle FTM_RESIZE_SCREEN_TEXTURE("Resize Screen Texture");
 
 //static
 void LLPipeline::throttleNewMemoryAllocation(BOOL disable)
@@ -1821,11 +1821,11 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj)
 }
 
 
-static LLTrace::TimeBlock FTM_UNLINK("Unlink");
-static LLTrace::TimeBlock FTM_REMOVE_FROM_MOVE_LIST("Movelist");
-static LLTrace::TimeBlock FTM_REMOVE_FROM_SPATIAL_PARTITION("Spatial Partition");
-static LLTrace::TimeBlock FTM_REMOVE_FROM_LIGHT_SET("Light Set");
-static LLTrace::TimeBlock FTM_REMOVE_FROM_HIGHLIGHT_SET("Highlight Set");
+static LLTrace::BlockTimerStatHandle FTM_UNLINK("Unlink");
+static LLTrace::BlockTimerStatHandle FTM_REMOVE_FROM_MOVE_LIST("Movelist");
+static LLTrace::BlockTimerStatHandle FTM_REMOVE_FROM_SPATIAL_PARTITION("Spatial Partition");
+static LLTrace::BlockTimerStatHandle FTM_REMOVE_FROM_LIGHT_SET("Light Set");
+static LLTrace::BlockTimerStatHandle FTM_REMOVE_FROM_HIGHLIGHT_SET("Highlight Set");
 
 void LLPipeline::unlinkDrawable(LLDrawable *drawable)
 {
@@ -2101,10 +2101,10 @@ void LLPipeline::updateMovedList(LLDrawable::drawable_vector_t& moved_list)
 	}
 }
 
-static LLTrace::TimeBlock FTM_OCTREE_BALANCE("Balance Octree");
-static LLTrace::TimeBlock FTM_UPDATE_MOVE("Update Move");
-static LLTrace::TimeBlock FTM_RETEXTURE("Retexture");
-static LLTrace::TimeBlock FTM_MOVED_LIST("Moved List");
+static LLTrace::BlockTimerStatHandle FTM_OCTREE_BALANCE("Balance Octree");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_MOVE("Update Move");
+static LLTrace::BlockTimerStatHandle FTM_RETEXTURE("Retexture");
+static LLTrace::BlockTimerStatHandle FTM_MOVED_LIST("Moved List");
 
 void LLPipeline::updateMove()
 {
@@ -2465,7 +2465,7 @@ BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3&
 	return res;
 }
 
-static LLTrace::TimeBlock FTM_CULL("Object Culling");
+static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling");
 
 void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep)
 {
@@ -2869,9 +2869,9 @@ BOOL LLPipeline::updateDrawableGeom(LLDrawable* drawablep, BOOL priority)
 	return update_complete;
 }
 
-static LLTrace::TimeBlock FTM_SEED_VBO_POOLS("Seed VBO Pool");
+static LLTrace::BlockTimerStatHandle FTM_SEED_VBO_POOLS("Seed VBO Pool");
 
-static LLTrace::TimeBlock FTM_UPDATE_GL("Update GL");
+static LLTrace::BlockTimerStatHandle FTM_UPDATE_GL("Update GL");
 
 void LLPipeline::updateGL()
 {
@@ -2892,7 +2892,7 @@ void LLPipeline::updateGL()
 	}
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_PRIORITY_GROUPS("Rebuild Priority Groups");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_PRIORITY_GROUPS("Rebuild Priority Groups");
 
 void LLPipeline::clearRebuildGroups()
 {
@@ -3022,7 +3022,7 @@ void LLPipeline::rebuildPriorityGroups()
 
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_GROUPS("Rebuild Groups");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_GROUPS("Rebuild Groups");
 
 void LLPipeline::rebuildGroups()
 {
@@ -3268,9 +3268,9 @@ void LLPipeline::markShift(LLDrawable *drawablep)
 	}
 }
 
-static LLTrace::TimeBlock FTM_SHIFT_DRAWABLE("Shift Drawable");
-static LLTrace::TimeBlock FTM_SHIFT_OCTREE("Shift Octree");
-static LLTrace::TimeBlock FTM_SHIFT_HUD("Shift HUD");
+static LLTrace::BlockTimerStatHandle FTM_SHIFT_DRAWABLE("Shift Drawable");
+static LLTrace::BlockTimerStatHandle FTM_SHIFT_OCTREE("Shift Octree");
+static LLTrace::BlockTimerStatHandle FTM_SHIFT_HUD("Shift HUD");
 
 void LLPipeline::shiftObjects(const LLVector3 &offset)
 {
@@ -3352,7 +3352,7 @@ void LLPipeline::markPartitionMove(LLDrawable* drawable)
 	}
 }
 
-static LLTrace::TimeBlock FTM_PROCESS_PARTITIONQ("PartitionQ");
+static LLTrace::BlockTimerStatHandle FTM_PROCESS_PARTITIONQ("PartitionQ");
 void LLPipeline::processPartitionQ()
 {
 	LL_RECORD_BLOCK_TIME(FTM_PROCESS_PARTITIONQ);
@@ -3443,7 +3443,7 @@ void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags f
 	}
 }
 
-static LLTrace::TimeBlock FTM_RESET_DRAWORDER("Reset Draw Order");
+static LLTrace::BlockTimerStatHandle FTM_RESET_DRAWORDER("Reset Draw Order");
 
 void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
 {
@@ -5668,7 +5668,7 @@ void LLPipeline::renderDebug()
 	}
 }
 
-static LLTrace::TimeBlock FTM_REBUILD_POOLS("Rebuild Pools");
+static LLTrace::BlockTimerStatHandle FTM_REBUILD_POOLS("Rebuild Pools");
 
 void LLPipeline::rebuildPools()
 {
@@ -7383,7 +7383,7 @@ void LLPipeline::resetVertexBuffers()
 	mResetVertexBuffers = true;
 }
 
-static LLTrace::TimeBlock FTM_RESET_VB("Reset VB");
+static LLTrace::BlockTimerStatHandle FTM_RESET_VB("Reset VB");
 
 void LLPipeline::doResetVertexBuffers()
 {
@@ -7544,7 +7544,7 @@ void LLPipeline::bindScreenToTexture()
 	
 }
 
-static LLTrace::TimeBlock FTM_RENDER_BLOOM("Bloom");
+static LLTrace::BlockTimerStatHandle FTM_RENDER_BLOOM("Bloom");
 
 void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 {
@@ -8201,7 +8201,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
 
 }
 
-static LLTrace::TimeBlock FTM_BIND_DEFERRED("Bind Deferred");
+static LLTrace::BlockTimerStatHandle FTM_BIND_DEFERRED("Bind Deferred");
 
 void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 noise_map)
 {
@@ -8426,16 +8426,16 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f)
 	return v;
 }
 
-static LLTrace::TimeBlock FTM_GI_TRACE("Trace");
-static LLTrace::TimeBlock FTM_GI_GATHER("Gather");
-static LLTrace::TimeBlock FTM_SUN_SHADOW("Shadow Map");
-static LLTrace::TimeBlock FTM_SOFTEN_SHADOW("Shadow Soften");
-static LLTrace::TimeBlock FTM_EDGE_DETECTION("Find Edges");
-static LLTrace::TimeBlock FTM_LOCAL_LIGHTS("Local Lights");
-static LLTrace::TimeBlock FTM_ATMOSPHERICS("Atmospherics");
-static LLTrace::TimeBlock FTM_FULLSCREEN_LIGHTS("Fullscreen Lights");
-static LLTrace::TimeBlock FTM_PROJECTORS("Projectors");
-static LLTrace::TimeBlock FTM_POST("Post");
+static LLTrace::BlockTimerStatHandle FTM_GI_TRACE("Trace");
+static LLTrace::BlockTimerStatHandle FTM_GI_GATHER("Gather");
+static LLTrace::BlockTimerStatHandle FTM_SUN_SHADOW("Shadow Map");
+static LLTrace::BlockTimerStatHandle FTM_SOFTEN_SHADOW("Shadow Soften");
+static LLTrace::BlockTimerStatHandle FTM_EDGE_DETECTION("Find Edges");
+static LLTrace::BlockTimerStatHandle FTM_LOCAL_LIGHTS("Local Lights");
+static LLTrace::BlockTimerStatHandle FTM_ATMOSPHERICS("Atmospherics");
+static LLTrace::BlockTimerStatHandle FTM_FULLSCREEN_LIGHTS("Fullscreen Lights");
+static LLTrace::BlockTimerStatHandle FTM_PROJECTORS("Projectors");
+static LLTrace::BlockTimerStatHandle FTM_POST("Post");
 
 
 void LLPipeline::renderDeferredLighting()
@@ -10143,9 +10143,9 @@ glh::matrix4f scale_translate_to_fit(const LLVector3 min, const LLVector3 max)
 	return ret;
 }
 
-static LLTrace::TimeBlock FTM_SHADOW_RENDER("Render Shadows");
-static LLTrace::TimeBlock FTM_SHADOW_ALPHA("Alpha Shadow");
-static LLTrace::TimeBlock FTM_SHADOW_SIMPLE("Simple Shadow");
+static LLTrace::BlockTimerStatHandle FTM_SHADOW_RENDER("Render Shadows");
+static LLTrace::BlockTimerStatHandle FTM_SHADOW_ALPHA("Alpha Shadow");
+static LLTrace::BlockTimerStatHandle FTM_SHADOW_SIMPLE("Simple Shadow");
 
 void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera& shadow_cam, LLCullResult &result, BOOL use_shader, BOOL use_occlusion, U32 target_width)
 {
@@ -10303,7 +10303,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
 	LLPipeline::sShadowRender = FALSE;
 }
 
-static LLTrace::TimeBlock FTM_VISIBLE_CLOUD("Visible Cloud");
+static LLTrace::BlockTimerStatHandle FTM_VISIBLE_CLOUD("Visible Cloud");
 BOOL LLPipeline::getVisiblePointCloud(LLCamera& camera, LLVector3& min, LLVector3& max, std::vector<LLVector3>& fp, LLVector3 light_dir)
 {
 	LL_RECORD_BLOCK_TIME(FTM_VISIBLE_CLOUD);
@@ -10553,7 +10553,7 @@ void LLPipeline::generateHighlight(LLCamera& camera)
 }
 
 
-static LLTrace::TimeBlock FTM_GEN_SUN_SHADOW("Gen Sun Shadow");
+static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow");
 
 void LLPipeline::generateSunShadow(LLCamera& camera)
 {
@@ -11343,11 +11343,11 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu
 	}
 }
 
-static LLTrace::TimeBlock FTM_IMPOSTOR_MARK_VISIBLE("Impostor Mark Visible");
-static LLTrace::TimeBlock FTM_IMPOSTOR_SETUP("Impostor Setup");
-static LLTrace::TimeBlock FTM_IMPOSTOR_BACKGROUND("Impostor Background");
-static LLTrace::TimeBlock FTM_IMPOSTOR_ALLOCATE("Impostor Allocate");
-static LLTrace::TimeBlock FTM_IMPOSTOR_RESIZE("Impostor Resize");
+static LLTrace::BlockTimerStatHandle FTM_IMPOSTOR_MARK_VISIBLE("Impostor Mark Visible");
+static LLTrace::BlockTimerStatHandle FTM_IMPOSTOR_SETUP("Impostor Setup");
+static LLTrace::BlockTimerStatHandle FTM_IMPOSTOR_BACKGROUND("Impostor Background");
+static LLTrace::BlockTimerStatHandle FTM_IMPOSTOR_ALLOCATE("Impostor Allocate");
+static LLTrace::BlockTimerStatHandle FTM_IMPOSTOR_RESIZE("Impostor Resize");
 
 void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 {
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index bfcd0eec6b..469c7b329e 100755
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -70,26 +70,26 @@ glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
 glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar);
 glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up);
 
-extern LLTrace::TimeBlock FTM_RENDER_GEOMETRY;
-extern LLTrace::TimeBlock FTM_RENDER_GRASS;
-extern LLTrace::TimeBlock FTM_RENDER_INVISIBLE;
-extern LLTrace::TimeBlock FTM_RENDER_OCCLUSION;
-extern LLTrace::TimeBlock FTM_RENDER_SHINY;
-extern LLTrace::TimeBlock FTM_RENDER_SIMPLE;
-extern LLTrace::TimeBlock FTM_RENDER_TERRAIN;
-extern LLTrace::TimeBlock FTM_RENDER_TREES;
-extern LLTrace::TimeBlock FTM_RENDER_UI;
-extern LLTrace::TimeBlock FTM_RENDER_WATER;
-extern LLTrace::TimeBlock FTM_RENDER_WL_SKY;
-extern LLTrace::TimeBlock FTM_RENDER_ALPHA;
-extern LLTrace::TimeBlock FTM_RENDER_CHARACTERS;
-extern LLTrace::TimeBlock FTM_RENDER_BUMP;
-extern LLTrace::TimeBlock FTM_RENDER_MATERIALS;
-extern LLTrace::TimeBlock FTM_RENDER_FULLBRIGHT;
-extern LLTrace::TimeBlock FTM_RENDER_GLOW;
-extern LLTrace::TimeBlock FTM_STATESORT;
-extern LLTrace::TimeBlock FTM_PIPELINE;
-extern LLTrace::TimeBlock FTM_CLIENT_COPY;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_GEOMETRY;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_GRASS;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_INVISIBLE;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_OCCLUSION;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_SHINY;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_SIMPLE;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_TERRAIN;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_TREES;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_UI;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_WATER;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_WL_SKY;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_ALPHA;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_CHARACTERS;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_BUMP;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_MATERIALS;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_FULLBRIGHT;
+extern LLTrace::BlockTimerStatHandle FTM_RENDER_GLOW;
+extern LLTrace::BlockTimerStatHandle FTM_STATESORT;
+extern LLTrace::BlockTimerStatHandle FTM_PIPELINE;
+extern LLTrace::BlockTimerStatHandle FTM_CLIENT_COPY;
 
 
 class LLPipeline
-- 
cgit v1.2.3


From 1c26d4265666cd232d38724ad6f1e32fd2dc2d34 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 16 Oct 2013 16:42:27 -0700
Subject: moved tree iterators into llfasttimer.h

---
 indra/newview/llfasttimerview.cpp | 38 ++++++++++++--------------------------
 1 file changed, 12 insertions(+), 26 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 6153c43690..302cecb5b6 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -66,22 +66,8 @@ static const S32 NUM_FRAMES_HISTORY = 200;
 
 std::vector<BlockTimerStatHandle*> ft_display_idx; // line of table entry for display purposes (for collapse)
 
-typedef LLTreeDFSIter<BlockTimerStatHandle, BlockTimerStatHandle::child_const_iter> timer_tree_iterator_t;
-
 BOOL LLFastTimerView::sAnalyzePerformance = FALSE;
 
-static timer_tree_iterator_t begin_timer_tree(BlockTimerStatHandle& id) 
-{ 
-	return timer_tree_iterator_t(&id, 
-							boost::bind(boost::mem_fn(&BlockTimerStatHandle::beginChildren), _1), 
-							boost::bind(boost::mem_fn(&BlockTimerStatHandle::endChildren), _1));
-}
-
-static timer_tree_iterator_t end_timer_tree() 
-{ 
-	return timer_tree_iterator_t(); 
-}
-
 S32 get_depth(const BlockTimerStatHandle* blockp)
 {
 	S32 depth = 0;
@@ -186,8 +172,8 @@ BlockTimerStatHandle* LLFastTimerView::getLegendID(S32 y)
 
 BOOL LLFastTimerView::handleDoubleClick(S32 x, S32 y, MASK mask)
 {
-	for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-		it != end_timer_tree();
+	for(LLTrace::block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME);
+		it != LLTrace::end_block_timer_tree_df();
 		++it)
 	{
 		(*it)->getTreeNode().mCollapsed = false;
@@ -962,8 +948,8 @@ void LLFastTimerView::printLineStats()
 	{
 		std::string legend_stat;
 		bool first = true;
-		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-			it != end_timer_tree();
+		for(block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME);
+			it != LLTrace::end_block_timer_tree_df();
 			++it)
 		{
 			BlockTimerStatHandle* idp = (*it);
@@ -984,8 +970,8 @@ void LLFastTimerView::printLineStats()
 
 		std::string timer_stat;
 		first = true;
-		for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-			it != end_timer_tree();
+		for(block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME);
+			it != LLTrace::end_block_timer_tree_df();
 			++it)
 		{
 			BlockTimerStatHandle* idp = (*it);
@@ -1062,8 +1048,8 @@ void LLFastTimerView::drawLineGraph()
 
 	F32Seconds cur_max(0);
 	U32 cur_max_calls = 0;
-	for(timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-		it != end_timer_tree();
+	for(block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME);
+		it != LLTrace::end_block_timer_tree_df();
 		++it)
 	{
 		BlockTimerStatHandle* idp = (*it);
@@ -1209,8 +1195,8 @@ void LLFastTimerView::drawLegend()
 		S32 cur_line = 0;
 		ft_display_idx.clear();
 		std::map<BlockTimerStatHandle*, S32> display_line;
-		for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-			it != timer_tree_iterator_t();
+		for (block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME);
+			it != block_timer_tree_df_iterator_t();
 			++it)
 		{
 			BlockTimerStatHandle* idp = (*it);
@@ -1308,8 +1294,8 @@ void LLFastTimerView::generateUniqueColors()
 
 		F32 hue = 0.f;
 
-		for (timer_tree_iterator_t it = begin_timer_tree(FTM_FRAME);
-			it != timer_tree_iterator_t();
+		for (block_timer_tree_df_iterator_t it = LLTrace::begin_block_timer_tree_df(FTM_FRAME);
+			it != block_timer_tree_df_iterator_t();
 			++it)
 		{
 			BlockTimerStatHandle* idp = (*it);
-- 
cgit v1.2.3


From 82c93b52c5d4f31acb52f43b8e82a51ffa3ee584 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 16 Oct 2013 20:06:21 -0600
Subject: fix for SH-4552: Interesting: objects sometimes fail to load after
 teleport.

---
 indra/newview/llviewerregion.cpp | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index db91b5cd8b..b9c7ded50b 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2096,6 +2096,9 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
 			}
 			else //invisible
 			{
+				//copy some contents from old entry
+				entry->moveTo(new_entry);
+
 				//remove old entry
 				killCacheEntry(entry);
 				entry = new_entry;
-- 
cgit v1.2.3


From 2b4dfefda216a0333426ac2a8f06d23ee6ef0aee Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 16 Oct 2013 20:59:13 -0600
Subject: more fix for SH-4552: Interesting: objects sometimes fail to load
 after teleport.

---
 indra/newview/llviewerregion.cpp | 2 +-
 indra/newview/llvocache.cpp      | 4 ++--
 indra/newview/llvocache.h        | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index b9c7ded50b..0ad4402dcc 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2097,7 +2097,7 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLDataPackerB
 			else //invisible
 			{
 				//copy some contents from old entry
-				entry->moveTo(new_entry);
+				entry->moveTo(new_entry, true);
 
 				//remove old entry
 				killCacheEntry(entry);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index f16f3507c3..89a49ff1ed 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -191,10 +191,10 @@ void LLVOCacheEntry::setOctreeEntry(LLViewerOctreeEntry* entry)
 	LLViewerOctreeEntryData::setOctreeEntry(entry);
 }
 
-void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry)
+void LLVOCacheEntry::moveTo(LLVOCacheEntry* new_entry, bool no_entry_move)
 {
 	//copy LLViewerOctreeEntry
-	if(mEntry.notNull())
+	if(mEntry.notNull() && !no_entry_move)
 	{
 		new_entry->setOctreeEntry(mEntry);
 		mEntry = NULL;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index eef364dd5d..21b30f5373 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -103,7 +103,7 @@ public:
 	void recordHit();
 	void recordDupe() { mDupeCount++; }
 	
-	void moveTo(LLVOCacheEntry* new_entry); //copy variables 
+	void moveTo(LLVOCacheEntry* new_entry, bool no_entry_move = false); //copy variables 
 	/*virtual*/ void setOctreeEntry(LLViewerOctreeEntry* entry);
 
 	void setParentID(U32 id) {mParentID = id;}
-- 
cgit v1.2.3


From ec178690240a56ffa43b8f37c6b581c9008d3d7d Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 17 Oct 2013 14:48:01 -0700
Subject: BUILDFIX: bad typedef

---
 indra/newview/llviewerstats.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index c81a9a0ad3..b5aa052a90 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -343,7 +343,7 @@ void update_statistics()
 	sample(LLStatViewer::DRAW_DISTANCE,   (F64)gSavedSettings.getF32("RenderFarClip"));
 	sample(LLStatViewer::CHAT_BUBBLES,    gSavedSettings.getBOOL("UseChatBubbles"));
 
-	typedef LLInstanceTracker<LLTrace::StatType<LLTrace::TimeBlockAccumulator>, std::string> stat_type_t;
+	typedef LLTrace::StatType<LLTrace::TimeBlockAccumulator>::instance_tracker_t stat_type_t;
 
 	F64Seconds idle_secs = last_frame_recording.getSum(*stat_type_t::getInstance("Idle"));
 	F64Seconds network_secs = last_frame_recording.getSum(*stat_type_t::getInstance("Network"));
-- 
cgit v1.2.3


From 18aedf0241ba893e12140c0a3855f328d2b4eded Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 17 Oct 2013 19:18:53 -0700
Subject: fix for assert at runtime (reading stats from recording while it was
 active) fix for bad values returns from getPeriodMin and getPeriodMax on
 count stats when no counts recorded fix for gcc compile time error (typename
 ftw)

---
 indra/newview/llviewerstats.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index b5aa052a90..d5ae2d1030 100755
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -208,7 +208,7 @@ LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > OBJECT_CACHE_HIT_RATE("
 LLViewerStats::LLViewerStats() 
 :	mLastTimeDiff(0.0)
 {
-	mRecording.start();
+	getRecording().start();
 }
 
 LLViewerStats::~LLViewerStats()
@@ -216,7 +216,7 @@ LLViewerStats::~LLViewerStats()
 
 void LLViewerStats::resetStats()
 {
-	LLViewerStats::instance().mRecording.reset();
+	getRecording().reset();
 }
 
 void LLViewerStats::updateFrameStats(const F64Seconds time_diff)
@@ -457,6 +457,8 @@ void send_stats()
 		return;
 	}
 	
+	LLViewerStats::instance().getRecording().pause();
+
 	body["session_id"] = gAgentSessionID;
 	
 	LLSD &agent = body["agent"];
@@ -616,6 +618,8 @@ void send_stats()
 	
 	LLViewerStats::getInstance()->addToMessage(body);
 	LLHTTPClient::post(url, body, new ViewerStatsResponder());
+
+	LLViewerStats::instance().getRecording().resume();
 }
 
 LLFrameTimer& LLViewerStats::PhaseMap::getPhaseTimer(const std::string& phase_name)
-- 
cgit v1.2.3


From c8228b65f8a4a94220c92d89d1529ed484f6e84a Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 17 Oct 2013 20:21:17 -0600
Subject: fix for SH-4569: Objects are not culled by size in the distance

---
 indra/newview/app_settings/settings.xml | 12 +++++++++-
 indra/newview/llvieweroctree.cpp        | 19 +++++++++++++++
 indra/newview/llvieweroctree.h          |  7 ++++--
 indra/newview/llviewerregion.cpp        | 12 ++++++++++
 indra/newview/llvocache.cpp             | 41 +++++++++++++++++++++++++--------
 indra/newview/llvocache.h               |  2 +-
 6 files changed, 80 insertions(+), 13 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 7bfca2834b..fb0d9c98d4 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7114,7 +7114,17 @@
       <real>0.75</real>
     </array>
   </map>
-  
+  <key>ObjectProjectionAreaCutOFF</key>
+  <map>
+    <key>Comment</key>
+    <string>Threshold in number of pixels of the projection area in screen of object bounding sphere. Objects smaller than this threshold are not rendered.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>1.0</real>
+  </map>
     <key>ParcelMediaAutoPlayEnable</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index e390249504..425e7fbd1f 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -1430,6 +1430,25 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOct
 	return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist);
 }
 //------------------------------------------
+//check if the objects projection large enough
+bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 projection_cutoff)
+{	
+	LLVector3 local_orig = mCamera->getOrigin() - shift;
+	LLVector4a origin;
+	origin.load3(local_orig.mV);
+
+	LLVector4a lookAt;
+	lookAt.setSub(center, origin);
+	F32 squared_dist = lookAt.dot3(lookAt).getF32();
+	F32 squared_rad = size.dot3(size).getF32();
+
+	if(squared_dist > 0.f)
+	{
+		return squared_rad / squared_dist > projection_cutoff;
+	}
+
+	return true;
+}
 
 //virtual 
 bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group)
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index e673bb6349..6ea6130413 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -362,9 +362,11 @@ class LLViewerOctreeCull : public OctreeTraveler
 public:
 	LLViewerOctreeCull(LLCamera* camera)
 		: mCamera(camera), mRes(0) { }
-
-	virtual bool earlyFail(LLViewerOctreeGroup* group);
+	
 	virtual void traverse(const OctreeNode* n);
+
+protected:
+	virtual bool earlyFail(LLViewerOctreeGroup* group);	
 	
 	//agent space group cull
 	S32 AABBInFrustumNoFarClipGroupBounds(const LLViewerOctreeGroup* group);	
@@ -389,6 +391,7 @@ public:
 	virtual S32 frustumCheck(const LLViewerOctreeGroup* group) = 0;
 	virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) = 0;
 
+	bool checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 projection_cutoff);
 	virtual bool checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group);
 	virtual void preprocess(LLViewerOctreeGroup* group);
 	virtual void processGroup(LLViewerOctreeGroup* group);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 0ad4402dcc..13a71b17cf 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1157,6 +1157,8 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 {
+	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
+
 	if(mDead)
 	{
 		return max_time;
@@ -1166,6 +1168,11 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 		return max_time;
 	}
 
+	//object projected area threshold
+	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
+	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
+	projection_threshold *= projection_threshold;
+
 	S32 throttle = sNewObjectCreationThrottle;
 	LLTimer update_timer;	
 	for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin();
@@ -1173,6 +1180,11 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	{
 		LLVOCacheEntry* vo_entry = *iter;
 			
+		if(vo_entry->getSceneContribution() < projection_threshold)
+		{
+			break;
+		}
+
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{
 			addNewObject(vo_entry);
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 89a49ff1ed..4d598c8845 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -548,10 +548,11 @@ class LLVOCacheOctreeCull : public LLViewerOctreeCull
 {
 public:
 	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, 
-		const LLVector3& shift, bool use_object_cache_occlusion, LLVOCachePartition* part) 
+		const LLVector3& shift, bool use_object_cache_occlusion, F32 projection_area_cutoff, LLVOCachePartition* part) 
 		: LLViewerOctreeCull(camera), 
 		  mRegionp(regionp),
-		  mPartition(part)
+		  mPartition(part),
+		  mProjectionAreaCutOff(projection_area_cutoff)
 	{
 		mLocalShift = shift;
 		mUseObjectCacheOcclusion = use_object_cache_occlusion;
@@ -605,6 +606,14 @@ public:
 		{
 			res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift));
 		}
+
+		if(res != 0)
+		{
+			//check if the objects projection large enough
+			const LLVector4a* exts = group->getObjectExtents();
+			res = checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff);
+		}
+
 		return res;
 	}
 
@@ -648,6 +657,7 @@ private:
 	LLVOCachePartition* mPartition;
 	LLViewerRegion*     mRegionp;
 	LLVector3           mLocalShift; //shift vector from agent space to local region space.
+	F32                 mProjectionAreaCutOff;
 	bool                mUseObjectCacheOcclusion;
 };
 
@@ -655,8 +665,8 @@ private:
 class LLVOCacheOctreeBackCull : public LLViewerOctreeCull
 {
 public:
-	LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius) 
-		: LLViewerOctreeCull(camera), mRegionp(regionp)
+	LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius, F32 projection_area_cutoff) 
+		: LLViewerOctreeCull(camera), mRegionp(regionp), mProjectionAreaCutOff(projection_area_cutoff)
 	{
 		mLocalShift = shift;
 		mSphereRadius = back_sphere_radius;
@@ -671,7 +681,13 @@ public:
 	virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group)
 	{
 		const LLVector4a* exts = group->getObjectExtents();
-		return backSphereCheck(exts[0], exts[1]);
+		if(backSphereCheck(exts[0], exts[1]))
+		{
+			//check if the objects projection large enough
+			const LLVector4a* exts = group->getObjectExtents();
+			return checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff);
+		}
+		return false;
 	}
 
 	virtual void processGroup(LLViewerOctreeGroup* base_group)
@@ -691,9 +707,10 @@ private:
 	F32              mSphereRadius;
 	LLViewerRegion*  mRegionp;
 	LLVector3        mLocalShift; //shift vector from agent space to local region space.
+	F32              mProjectionAreaCutOff;
 };
 
-void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius)
+void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff)
 {
 	if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
@@ -714,7 +731,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad
 	//localize the camera
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	
-	LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius);
+	LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius, projection_area_cutoff);
 	culler.traverse(mOctree);
 
 	mBackSlectionEnabled--;
@@ -730,6 +747,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 {
 	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
 	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");
+	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
 	
 	if(!LLViewerRegion::sVOCacheCullingEnabled)
 	{
@@ -753,6 +771,11 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	}
 	mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
 
+	//object projected area threshold
+	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
+	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
+	projection_threshold *= projection_threshold;
+
 	if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
 	{
 		U32 seed = llmax(mLODPeriod >> 1, (U32)4);
@@ -765,7 +788,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		}
 		if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash)
 		{
-			selectBackObjects(camera, back_sphere_radius);//process back objects selection
+			selectBackObjects(camera, back_sphere_radius, projection_threshold);//process back objects selection
 			return 0; //nothing changed, reduce frequency of culling
 		}
 	}
@@ -783,7 +806,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	camera.calcRegionFrustumPlanes(region_agent);
 
-	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, this);
+	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, projection_threshold, this);
 	culler.traverse(mOctree);
 
 	if(mRegionp->getNumOfVisibleGroups() > 0)
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 21b30f5373..764c06f813 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -186,7 +186,7 @@ public:
 	void removeOccluder(LLVOCacheGroup* group);
 
 private:
-	void selectBackObjects(LLCamera &camera, F32 back_sphere_radius); //select objects behind camera.
+	void selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff); //select objects behind camera.
 
 public:
 	static BOOL sNeedsOcclusionCheck;
-- 
cgit v1.2.3


From 9f097380b85a307db472726175c3515fdeb5aed5 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Fri, 18 Oct 2013 09:14:53 -0700
Subject: removed asserts in order to get testable builds again added unpause()
 behavior and changed pause() to do nothing when already stopped

---
 indra/newview/llappviewer.cpp        | 2 --
 indra/newview/llviewerassetstats.cpp | 8 --------
 indra/newview/llviewerassetstats.h   | 4 ----
 3 files changed, 14 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 037a9bda86..0c9baec00a 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -5601,8 +5601,6 @@ void LLAppViewer::metricsSend(bool enable_reporting)
 			LLViewerAssetStats * main_stats(new LLViewerAssetStats(*gViewerAssetStats));
 			main_stats->stop();
 
-			main_stats->updateStats();
-			
 			// Send a report request into 'thread1' to get the rest of the data
 			// and provide some additional parameters while here.
 			LLAppViewer::sTextureFetch->commandSendMetrics(caps_url,
diff --git a/indra/newview/llviewerassetstats.cpp b/indra/newview/llviewerassetstats.cpp
index e009863002..54ac29723f 100755
--- a/indra/newview/llviewerassetstats.cpp
+++ b/indra/newview/llviewerassetstats.cpp
@@ -353,14 +353,6 @@ void LLViewerAssetStats::setRegion(region_handle_t region_handle)
 	mRegionHandle = region_handle;
 }
 
-void LLViewerAssetStats::updateStats()
-{
-	if (mCurRecording && mCurRecording->isStarted())
-	{
-		mCurRecording->update();
-	}
-}
-
 void LLViewerAssetStats::getStats(AssetStats& stats, bool compact_output)
 {
 	using namespace LLViewerAssetStatsFF;
diff --git a/indra/newview/llviewerassetstats.h b/indra/newview/llviewerassetstats.h
index aaa299bf4b..9d425c82fc 100755
--- a/indra/newview/llviewerassetstats.h
+++ b/indra/newview/llviewerassetstats.h
@@ -162,10 +162,6 @@ public:
 	// collection calls.
 	void setRegion(region_handle_t region_handle);
 
-	// gather latest metrics data
-	// call from main thread
-	void updateStats();
-	
 	// Retrieve current metrics for all visited regions (NULL region UUID/handle excluded)
     // Uses AssetStats structure seen above
 	void getStats(AssetStats& stats, bool compact_output);
-- 
cgit v1.2.3


From 7bfacf8ca6c7bfdd9b11a2036a914c8f47058a61 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 18 Oct 2013 16:14:40 -0600
Subject: stop other cameras than the world camera to asscee object cache.

---
 indra/newview/llviewerregion.cpp |  5 +++++
 indra/newview/llvocache.cpp      | 27 ++++++++++++---------------
 indra/newview/llvocache.h        |  4 +++-
 3 files changed, 20 insertions(+), 16 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 13a71b17cf..e73b4fb62c 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1165,6 +1165,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	}
 	if(mImpl->mWaitingList.empty())
 	{
+		mImpl->mVOCachePartition->setCullHistory(FALSE);
 		return max_time;
 	}
 
@@ -1174,6 +1175,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	projection_threshold *= projection_threshold;
 
 	S32 throttle = sNewObjectCreationThrottle;
+	BOOL has_new_obj = FALSE;
 	LLTimer update_timer;	
 	for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin();
 		iter != mImpl->mWaitingList.end(); ++iter)
@@ -1188,6 +1190,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{
 			addNewObject(vo_entry);
+			has_new_obj = TRUE;
 			if(throttle > 0 && !(--throttle) && update_timer.getElapsedTimeF32() > max_time)
 			{
 				break;
@@ -1195,6 +1198,8 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 		}
 	}	
 
+	mImpl->mVOCachePartition->setCullHistory(has_new_obj);
+
 	return max_time - update_timer.getElapsedTimeF32();
 }
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 4d598c8845..3f2a39ba2b 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -524,9 +524,10 @@ LLVOCachePartition::LLVOCachePartition(LLViewerRegion* regionp)
 	
 	for(S32 i = 0; i < LLViewerCamera::NUM_CAMERAS; i++)
 	{
-		mCulledTime[i] = 0;
-		mCullHistory[i] = -1;
+		mCulledTime[i] = 0;	
 	}
+	mCullHistory = -1;
+
 	new LLVOCacheGroup(mOctree, this);
 }
 
@@ -760,7 +761,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 
 	((LLViewerOctreeGroup*)mOctree->getListener(0))->rebound();
 
-	if(LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_WATER0)
+	if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
 		return 0; //no need for those cameras.
 	}
@@ -776,7 +777,7 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
 	projection_threshold *= projection_threshold;
 
-	if(!mCullHistory[LLViewerCamera::sCurCameraID] && LLViewerRegion::isViewerCameraStatic())
+	if(!mCullHistory && LLViewerRegion::isViewerCameraStatic())
 	{
 		U32 seed = llmax(mLODPeriod >> 1, (U32)4);
 		if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
@@ -797,22 +798,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		mBackSlectionEnabled = -1; //reset it.
 	}
 
-	if(LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
-	{
-		mCullHistory[LLViewerCamera::sCurCameraID] <<= 1;
-	}
-
 	//localize the camera
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	camera.calcRegionFrustumPlanes(region_agent);
 
 	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, projection_threshold, this);
-	culler.traverse(mOctree);
-
-	if(mRegionp->getNumOfVisibleGroups() > 0)
-	{
-		mCullHistory[LLViewerCamera::sCurCameraID] |= 1;
-	}
+	culler.traverse(mOctree);	
 
 	if(!sNeedsOcclusionCheck)
 	{
@@ -821,6 +812,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	return 1;
 }
 
+void LLVOCachePartition::setCullHistory(BOOL has_new_object)
+{
+	mCullHistory <<= 1;
+	mCullHistory |= has_new_object;
+}
+
 void LLVOCachePartition::addOccluders(LLViewerOctreeGroup* gp)
 {
 	LLVOCacheGroup* group = (LLVOCacheGroup*)gp;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 764c06f813..3ee9dcaac8 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -185,6 +185,8 @@ public:
 	void processOccluders(LLCamera* camera);
 	void removeOccluder(LLVOCacheGroup* group);
 
+	void setCullHistory(BOOL has_new_object);
+
 private:
 	void selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff); //select objects behind camera.
 
@@ -192,7 +194,7 @@ public:
 	static BOOL sNeedsOcclusionCheck;
 
 private:
-	U32   mCullHistory[LLViewerCamera::NUM_CAMERAS];
+	U32   mCullHistory;
 	U32   mCulledTime[LLViewerCamera::NUM_CAMERAS];
 	std::set<LLVOCacheGroup*> mOccludedGroups;
 
-- 
cgit v1.2.3


From 318a1eca57d2e4ee3a0845c137f48e721cc57b00 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 21 Oct 2013 11:24:35 -0700
Subject: more buildfix stuff

---
 indra/newview/tests/llcapabilitylistener_test.cpp | 12 ++++++------
 indra/newview/tests/llxmlrpclistener_test.cpp     |  8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llcapabilitylistener_test.cpp b/indra/newview/tests/llcapabilitylistener_test.cpp
index e1cbd28f92..bde991a01e 100755
--- a/indra/newview/tests/llcapabilitylistener_test.cpp
+++ b/indra/newview/tests/llcapabilitylistener_test.cpp
@@ -134,10 +134,10 @@ namespace tut
         std::string threw;
         try
         {
-            WrapLL_ERRS capture;
+            WrapLLErrs capture;
             regionPump.post(request);
         }
-        catch (const WrapLL_ERRS::FatalException& e)
+        catch (const WrapLLErrs::FatalException& e)
         {
             threw = e.what();
         }
@@ -181,10 +181,10 @@ namespace tut
         std::string threw;
         try
         {
-            WrapLL_ERRS capture;
+            WrapLLErrs capture;
             regionPump.post(request);
         }
-        catch (const WrapLL_ERRS::FatalException& e)
+        catch (const WrapLLErrs::FatalException& e)
         {
             threw = e.what();
         }
@@ -243,10 +243,10 @@ namespace tut
         std::string threw;
         try
         {
-            WrapLL_ERRS capture;
+            WrapLLErrs capture;
             regionPump.post(request);
         }
-        catch (const WrapLL_ERRS::FatalException& e)
+        catch (const WrapLLErrs::FatalException& e)
         {
             threw = e.what();
         }
diff --git a/indra/newview/tests/llxmlrpclistener_test.cpp b/indra/newview/tests/llxmlrpclistener_test.cpp
index 20f913b670..6e9756e7d5 100755
--- a/indra/newview/tests/llxmlrpclistener_test.cpp
+++ b/indra/newview/tests/llxmlrpclistener_test.cpp
@@ -85,7 +85,7 @@ namespace tut
     void object::test<1>()
     {
         set_test_name("request validation");
-        WrapLL_ERRS capture;
+        WrapLLErrs capture;
         LLSD request;
         request["uri"] = uri;
         std::string threw;
@@ -93,7 +93,7 @@ namespace tut
         {
             pumps.obtain("LLXMLRPCTransaction").post(request);
         }
-        catch (const WrapLL_ERRS::FatalException& e)
+        catch (const WrapLLErrs::FatalException& e)
         {
             threw = e.what();
         }
@@ -106,7 +106,7 @@ namespace tut
     void object::test<2>()
     {
         set_test_name("param types validation");
-        WrapLL_ERRS capture;
+        WrapLLErrs capture;
         LLSD request;
         request["uri"] = uri;
         request["method"] = "hello";
@@ -118,7 +118,7 @@ namespace tut
         {
             pumps.obtain("LLXMLRPCTransaction").post(request);
         }
-        catch (const WrapLL_ERRS::FatalException& e)
+        catch (const WrapLLErrs::FatalException& e)
         {
             threw = e.what();
         }
-- 
cgit v1.2.3


From 04397a095acd6ceeb280b3fc82cf122fd6ccf43a Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 21 Oct 2013 12:29:33 -0700
Subject: more buildfix

---
 indra/newview/tests/llviewerassetstats_test.cpp | 3 ---
 1 file changed, 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index 9a39fdaa29..7a84e65c91 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -390,7 +390,6 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
-		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 
 		// std::cout << sd << std::endl;
@@ -465,7 +464,6 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_GESTURE, false, false);
 
-		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 
 		ensure("Correct double-key LLSD map root", is_double_key_map(sd, "duration", "regions"));
@@ -533,7 +531,6 @@ namespace tut
 
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_LSL_BYTECODE, true, true);
 
-		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
-- 
cgit v1.2.3


From 54c9aba3d980b6cee4c8025bafe381ea16638d34 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 21 Oct 2013 12:54:21 -0700
Subject: more buildfix

---
 indra/newview/tests/llviewerassetstats_test.cpp | 1 -
 1 file changed, 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp
index 7a84e65c91..a08e32cb49 100755
--- a/indra/newview/tests/llviewerassetstats_test.cpp
+++ b/indra/newview/tests/llviewerassetstats_test.cpp
@@ -344,7 +344,6 @@ namespace tut
 		LLViewerAssetStatsFF::record_enqueue(LLViewerAssetType::AT_BODYPART, false, false);
 		LLViewerAssetStatsFF::record_dequeue(LLViewerAssetType::AT_BODYPART, false, false);
 
-		gViewerAssetStats->updateStats();
 		LLSD sd = gViewerAssetStats->asLLSD(false);
 		ensure("Correct single-key LLSD map root", is_double_key_map(sd, "regions", "duration"));
 		ensure("Correct single-slot LLSD array regions", is_single_slot_array(sd["regions"], region1_handle));
-- 
cgit v1.2.3


From e46c4fd1c6f8d99e87fd53e71d97fb8ce925a576 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 22 Oct 2013 15:47:50 -0600
Subject: trivial: convert to unix endings.

---
 indra/newview/llvieweroctree.cpp | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index af6f8bdede..993967ee94 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -761,22 +761,22 @@ public:
 	}
 
 protected:
-
-	virtual GLuint allocateName()
-	{
-		GLuint ret = 0;
-
-		glGenQueriesARB(1, &ret);
-	
-		return ret;
-	}
-
-	virtual void releaseName(GLuint name)
-	{
-#if LL_TRACK_PENDING_OCCLUSION_QUERIES
-		LLOcclusionCullingGroup::sPendingQueries.erase(name);
-#endif
-		glDeleteQueriesARB(1, &name);
+
+	virtual GLuint allocateName()
+	{
+		GLuint ret = 0;
+
+		glGenQueriesARB(1, &ret);
+	
+		return ret;
+	}
+
+	virtual void releaseName(GLuint name)
+	{
+#if LL_TRACK_PENDING_OCCLUSION_QUERIES
+		LLOcclusionCullingGroup::sPendingQueries.erase(name);
+#endif
+		glDeleteQueriesARB(1, &name);
 	}
 };
 
-- 
cgit v1.2.3


From e0ace6d8690b2f60fb9b359f4840081957a3ff25 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 22 Oct 2013 16:07:41 -0600
Subject: fix for various object missing bugs: SH-4552, SH-4564, SH-4573,
 SH-4568

---
 indra/newview/llvieweroctree.cpp |  7 +++++++
 indra/newview/llvieweroctree.h   |  1 +
 indra/newview/llviewerregion.cpp | 10 +++++++---
 indra/newview/llvocache.cpp      |  2 ++
 4 files changed, 17 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 993967ee94..ef802f2651 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -425,6 +425,13 @@ void LLViewerOctreeEntryData::setVisible() const
 	}
 }
 
+void LLViewerOctreeEntryData::resetVisible() const
+{
+	if(mEntry)
+	{
+		mEntry->mVisible = 0;
+	}
+}
 //-----------------------------------------------------------------------------------
 //class LLViewerOctreeGroup definitions
 //-----------------------------------------------------------------------------------
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 6ea6130413..611f285c8e 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -156,6 +156,7 @@ public:
 
 	U32          getVisible() const {return mEntry ? mEntry->mVisible : 0;}
 	void         setVisible() const;
+	void         resetVisible() const;
 	virtual bool isVisible() const;
 	virtual bool isRecentlyVisible() const;	
 	
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index e73b4fb62c..d619a2af8b 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1061,15 +1061,19 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 	LLTimer update_timer;
 
+	const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object.
 	const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin();
 	const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame();
 	bool needs_update = ((cur_frame - mImpl->mLastCameraUpdate) > 5) && ((camera_origin - mImpl->mLastCameraOrigin).lengthSquared() > 10.f);	
+	U32 last_update = mImpl->mLastCameraUpdate;
 
 	//process visible entries
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
 	{
 		LLVOCacheEntry* vo_entry = *iter;
-		vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);
+
+		//set a large number to force to load this object.
+		vo_entry->setSceneContribution(LARGE_SCENE_CONTRIBUTION);
 
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{			
@@ -1084,7 +1088,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 			child = vo_entry->getChild(i);
 			if(child->getState() < LLVOCacheEntry::WAITING)
 			{
-				child->setSceneContribution(vo_entry->getSceneContribution());
+				child->setSceneContribution(LARGE_SCENE_CONTRIBUTION); //a large number to force to load the child.
 				mImpl->mWaitingList.insert(child);
 			}
 			else
@@ -1140,7 +1144,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 					continue;
 				}
 
-				vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);				
+				vo_entry->calcSceneContribution(camera_origin, needs_update, last_update);				
 				mImpl->mWaitingList.insert(vo_entry);
 			}
 		}
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 3f2a39ba2b..72270eec46 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -250,6 +250,7 @@ void LLVOCacheEntry::addChild(LLVOCacheEntry* entry)
 	if(getEntry() != NULL && isState(INACTIVE))
 	{
 		updateParentBoundingInfo(entry);
+		resetVisible();
 	}
 }
 	
@@ -441,6 +442,7 @@ void LLVOCacheEntry::updateParentBoundingInfo()
 	{
 		updateParentBoundingInfo(mChildrenList[i]);
 	}
+	resetVisible();
 }
 
 //make the parent bounding box to include this child
-- 
cgit v1.2.3


From ab43be5ddb50198304de1ae0e82b641c7d343449 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 23 Oct 2013 13:24:47 -0700
Subject: moved some common functionality from LLTrace::BlockTimerStatHandle to
 BlockTimer updates appearance utility dependency

---
 indra/newview/llappviewer.cpp     | 32 ++++++++++++++++----------------
 indra/newview/llfasttimerview.cpp |  4 ++--
 indra/newview/llviewermenu.cpp    |  2 +-
 3 files changed, 19 insertions(+), 19 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0c9baec00a..7acb3e3b26 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -627,7 +627,7 @@ public:
 		
 		while (!LLAppViewer::instance()->isQuitting())
 		{
-			LLTrace::BlockTimerStatHandle::writeLog(os);
+			LLTrace::BlockTimer::writeLog(os);
 			os.flush();
 			ms_sleep(32);
 		}
@@ -1315,9 +1315,9 @@ bool LLAppViewer::mainLoop()
 #endif
 	{
 		LL_RECORD_BLOCK_TIME(FTM_FRAME);
-		LLTrace::BlockTimerStatHandle::processTimes();
+		LLTrace::BlockTimer::processTimes();
 		LLTrace::get_frame_recording().nextPeriod();
-		LLTrace::BlockTimerStatHandle::logStats();
+		LLTrace::BlockTimer::logStats();
 
 		LLTrace::get_master_thread_recorder()->pullFromChildren();
 
@@ -1662,9 +1662,9 @@ bool LLAppViewer::cleanup()
 	if (LLFastTimerView::sAnalyzePerformance)
 	{
 		LL_INFOS() << "Analyzing performance" << LL_ENDL;
-		std::string baseline_name = LLTrace::BlockTimerStatHandle::sLogName + "_baseline.slp";
-		std::string current_name  = LLTrace::BlockTimerStatHandle::sLogName + ".slp"; 
-		std::string report_name   = LLTrace::BlockTimerStatHandle::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -2018,9 +2018,9 @@ bool LLAppViewer::cleanup()
 	{
 		LL_INFOS() << "Analyzing performance" << LL_ENDL;
 		
-		std::string baseline_name = LLTrace::BlockTimerStatHandle::sLogName + "_baseline.slp";
-		std::string current_name  = LLTrace::BlockTimerStatHandle::sLogName + ".slp"; 
-		std::string report_name   = LLTrace::BlockTimerStatHandle::sLogName + "_report.csv";
+		std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp";
+		std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; 
+		std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";
 
 		LLFastTimerView::doAnalysis(
 			gDirUtilp->getExpandedFilename(LL_PATH_LOGS, baseline_name),
@@ -2139,10 +2139,10 @@ bool LLAppViewer::initThreads()
 													enable_threads && true,
 													app_metrics_qa_mode);	
 
-	if (LLTrace::BlockTimerStatHandle::sLog || LLTrace::BlockTimerStatHandle::sMetricLog)
+	if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog)
 	{
-		LLTrace::BlockTimerStatHandle::setLogLock(new LLMutex(NULL));
-		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimerStatHandle::sLogName);
+		LLTrace::BlockTimer::setLogLock(new LLMutex(NULL));
+		mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName);
 		mFastTimerLogThread->start();
 	}
 
@@ -2597,18 +2597,18 @@ bool LLAppViewer::initConfiguration()
 
 	if (gSavedSettings.getBOOL("LogPerformance"))
 	{
-		LLTrace::BlockTimerStatHandle::sLog = true;
-		LLTrace::BlockTimerStatHandle::sLogName = std::string("performance");		
+		LLTrace::BlockTimer::sLog = true;
+		LLTrace::BlockTimer::sLogName = std::string("performance");		
 	}
 
 	std::string test_name(gSavedSettings.getString("LogMetrics"));
 	if (! test_name.empty())
 	{
-		LLTrace::BlockTimerStatHandle::sMetricLog = TRUE ;
+		LLTrace::BlockTimer::sMetricLog = TRUE ;
 		// '--logmetrics' is specified with a named test metric argument so the data gathering is done only on that test
 		// In the absence of argument, every metric would be gathered (makes for a rather slow run and hard to decipher report...)
 		LL_INFOS() << "'--logmetrics' argument : " << test_name << LL_ENDL;
-		LLTrace::BlockTimerStatHandle::sLogName = test_name;
+		LLTrace::BlockTimer::sLogName = test_name;
  	}
 
 	if (clp.hasOption("graphicslevel"))
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 302cecb5b6..bd92b4b6ca 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -924,13 +924,13 @@ void LLFastTimerView::outputAllMetrics()
 //static
 void LLFastTimerView::doAnalysis(std::string baseline, std::string target, std::string output)
 {
-	if(BlockTimerStatHandle::sLog)
+	if(BlockTimer::sLog)
 	{
 		doAnalysisDefault(baseline, target, output) ;
 		return ;
 	}
 
-	if(BlockTimerStatHandle::sMetricLog)
+	if(BlockTimer::sMetricLog)
 	{
 		LLMetricPerformanceTesterBasic::doAnalysisMetrics(baseline, target, output) ;
 		return ;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 4b0957679c..05b1236df5 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -7491,7 +7491,7 @@ void handle_dump_avatar_local_textures(void*)
 
 void handle_dump_timers()
 {
-	LLTrace::BlockTimerStatHandle::dumpCurTimes();
+	LLTrace::BlockTimer::dumpCurTimes();
 }
 
 void handle_debug_avatar_textures(void*)
-- 
cgit v1.2.3


From 806cd01a0da1c67aaccd0bdcb40c104d48ed9d25 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 23 Oct 2013 15:45:15 -0600
Subject: fix for SH-4551: Interesting: some attachments do not appear after
 teleport

---
 indra/newview/llspatialpartition.cpp | 2 +-
 indra/newview/llvovolume.cpp         | 8 --------
 indra/newview/pipeline.cpp           | 1 -
 3 files changed, 1 insertion(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 449a192332..55c0acd3f9 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -903,7 +903,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
 {
 	setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY);
 
-	if (!keep_occlusion && !LLSpatialPartition::sTeleportRequested)
+	if (!keep_occlusion)
 	{ //going to need a rebuild
 		gPipeline.markRebuild(this, TRUE);
 	}
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 52c4c24686..2828f1ba6a 100755
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1298,14 +1298,6 @@ BOOL LLVOVolume::calcLOD()
 		mLOD = cur_detail;		
 		return TRUE;
 	}
-	else if(cur_detail > MIN_LOD)
-	{
-		LLFace* facep = mDrawable->getFace(0);
-		if(facep && !facep->getVertexBuffer())
-		{
-			return TRUE; //force geometry update if visible object does not have vertex buffer.
-		}
-	}
 
 	return FALSE;
 }
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index efc3663ff3..2cf59d212b 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -7415,7 +7415,6 @@ void LLPipeline::doResetVertexBuffers()
 		LLSpatialPartition::sTeleportRequested = FALSE;
 
 		LLWorld::getInstance()->clearAllVisibleObjects();
-		clearRebuildGroups();
 		clearRebuildDrawables();
 	}
 
-- 
cgit v1.2.3


From dc60a7564abf16cbf269e47cfc33ed00c6bb0870 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Thu, 24 Oct 2013 14:37:57 -0700
Subject: SH-4577 WIP Interesting: viewer crashed when clicking a offline
 Conversation containing a shared object potential fix by making instance
 tracker allow key collisions for LLToastNotifyPanel changed assertion macro
 to use original unpreprocessed source code renamed instance tracker behavior
 macros to use LL prefix added RestoreCameraPosOnLogin setting to optionally
 restore old camera positioning behavior

---
 indra/newview/CMakeLists.txt            | 18 +++++++++---------
 indra/newview/app_settings/settings.xml | 13 ++++++++++++-
 indra/newview/llstartup.cpp             |  7 +++----
 indra/newview/lltoastnotifypanel.cpp    |  2 +-
 indra/newview/lltoastnotifypanel.h      |  2 +-
 5 files changed, 26 insertions(+), 16 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 3e1cbb2ac6..0cf0fc1322 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -238,6 +238,9 @@ set(viewer_SOURCE_FILES
     llfloaterhelpbrowser.cpp
     llfloaterhud.cpp
     llfloaterimagepreview.cpp
+    llfloaterimsessiontab.cpp
+    llfloaterimsession.cpp
+    llfloaterimcontainer.cpp
     llfloaterinspect.cpp
     llfloaterinventory.cpp
     llfloaterjoystick.cpp
@@ -320,9 +323,6 @@ set(viewer_SOURCE_FILES
     llhudrender.cpp
     llhudtext.cpp
     llhudview.cpp
-    llfloaterimsessiontab.cpp
-    llfloaterimsession.cpp
-    llfloaterimcontainer.cpp
     llimhandler.cpp
     llimview.cpp
     llinspect.cpp
@@ -826,6 +826,12 @@ set(viewer_HEADER_FILES
     llfloaterhelpbrowser.h
     llfloaterhud.h
     llfloaterimagepreview.h
+    llfloaterimnearbychat.h
+    llfloaterimnearbychathandler.h
+    llfloaterimnearbychatlistener.h
+    llfloaterimsessiontab.h
+    llfloaterimsession.h
+    llfloaterimcontainer.h
     llfloaterinspect.h
     llfloaterinventory.h
     llfloaterjoystick.h
@@ -907,9 +913,6 @@ set(viewer_HEADER_FILES
     llhudrender.h
     llhudtext.h
     llhudview.h
-    llfloaterimsessiontab.h
-    llfloaterimsession.h
-    llfloaterimcontainer.h
     llimview.h
     llinspect.h
     llinspectavatar.h
@@ -961,9 +964,6 @@ set(viewer_HEADER_FILES
     llnameeditor.h
     llnamelistctrl.h
     llnavigationbar.h
-    llfloaterimnearbychat.h
-    llfloaterimnearbychathandler.h
-    llfloaterimnearbychatlistener.h
     llnetmap.h
     llnotificationhandler.h
     llnotificationmanager.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index fb0d9c98d4..09d74a7f5e 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1467,7 +1467,18 @@
         <real>0.0</real>
       </array>
     </map>
-    <key>CameraPositionSmoothing</key>
+    <key>RestoreCameraPosOnLogin</key>
+    <map>
+      <key>Comment</key>
+      <string>Reset camera position to location at logout</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+			<integer>0</integer>
+    </map>
+		<key>CameraPositionSmoothing</key>
     <map>
       <key>Comment</key>
       <string>Smooths camera position over time</string>
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 72c76f9424..de3be7f3c5 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1962,10 +1962,9 @@ bool idle_startup()
 				((start_slurl.getType() == LLSLURL::LAST_LOCATION) && (gAgentStartLocation == "last")) ||
 				((start_slurl.getType() == LLSLURL::HOME_LOCATION) && (gAgentStartLocation == "home")))
 			{
-				// Start location is OK
-				// Disabled code to restore camera location and focus if logging in to default location
-				static bool samename = false;
-				if (samename)
+				if (start_slurl.getType() == LLSLURL::LAST_LOCATION 
+					&& gAgentStartLocation == "last" 
+					&& gSavedSettings.getBOOL("RestoreCameraPosOnLogin"))
 				{
 					// restore old camera pos
 					gAgentCamera.setFocusOnAvatar(FALSE, FALSE);
diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp
index 94d07b37ef..5b110d843d 100755
--- a/indra/newview/lltoastnotifypanel.cpp
+++ b/indra/newview/lltoastnotifypanel.cpp
@@ -57,7 +57,7 @@ LLToastNotifyPanel::button_click_signal_t LLToastNotifyPanel::sButtonClickSignal
 
 LLToastNotifyPanel::LLToastNotifyPanel(const LLNotificationPtr& notification, const LLRect& rect, bool show_images) 
 :	LLToastPanel(notification),
-	LLInstanceTracker<LLToastNotifyPanel, LLUUID>(notification->getID())
+	LLInstanceTracker<LLToastNotifyPanel, LLUUID, LLInstanceTrackerAllowKeyCollisions>(notification->getID())
 {
 	init(rect, show_images);
 }
diff --git a/indra/newview/lltoastnotifypanel.h b/indra/newview/lltoastnotifypanel.h
index d02171b512..dfd6e110b9 100755
--- a/indra/newview/lltoastnotifypanel.h
+++ b/indra/newview/lltoastnotifypanel.h
@@ -47,7 +47,7 @@ class LLNotificationForm;
  * @deprecated this class will be removed after all toast panel types are
  *  implemented in separate classes.
  */
-class LLToastNotifyPanel: public LLToastPanel, public LLInstanceTracker<LLToastNotifyPanel, LLUUID>
+class LLToastNotifyPanel: public LLToastPanel, public LLInstanceTracker<LLToastNotifyPanel, LLUUID, LLInstanceTrackerAllowKeyCollisions>
 {
 public:
 	/**
-- 
cgit v1.2.3


From d98b6a932deb3125422c5b544aced9d05ff8f89f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 24 Oct 2013 19:46:09 -0600
Subject: fix a flaw LLViewerOctreeEntry::mVisible not initialized.

---
 indra/newview/llvieweroctree.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index ef802f2651..3646133e91 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -36,7 +36,7 @@
 //-----------------------------------------------------------------------------------
 //static variables definitions
 //-----------------------------------------------------------------------------------
-U32 LLViewerOctreeEntryData::sCurVisible = 0;
+U32 LLViewerOctreeEntryData::sCurVisible = 10; //reserve the low numbers for special use.
 BOOL LLViewerOctreeDebug::sInDebug = FALSE;
 
 static LLTrace::CountStatHandle<S32> sOcclusionQueries("occlusion_queries", "Number of occlusion queries executed"),
@@ -234,7 +234,8 @@ LLViewerOctreeEntry::LLViewerOctreeEntry()
 :	LLTrace::MemTrackable<LLViewerOctreeEntry, 16>("LLViewerOctreeEntry"),
 	mGroup(NULL),
 	mBinRadius(0.f),
-	mBinIndex(-1)
+	mBinIndex(-1),
+	mVisible(0)
 {
 	mPositionGroup.clear();
 	mExtents[0].clear();
-- 
cgit v1.2.3


From bd8f98ff3d870e17893154ba0d9ecf7396899bec Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 24 Oct 2013 19:48:44 -0600
Subject: add throttle to number of pokes to potential visible objects per
 frame.

---
 indra/newview/llviewerregion.cpp | 61 +++++++++++++++++++++++++++++-----------
 1 file changed, 44 insertions(+), 17 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index d619a2af8b..dee52abea7 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1049,6 +1049,8 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 
 F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 {
+	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
+
 	if(mDead)
 	{
 		return max_time;
@@ -1059,8 +1061,27 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		return max_time;
 	}
 
+	if(!sNewObjectCreationThrottle)
+	{
+		return max_time;
+	}
+	U32 new_obj_count = sNewObjectCreationThrottle;
+	if(sNewObjectCreationThrottle < 0)
+	{
+		new_obj_count = (U32)-1; //maximum
+	}
+	else
+	{
+		new_obj_count *= 1.5f; //load 50% more for selection
+	}
+
 	LLTimer update_timer;
 
+	//object projected area threshold
+	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
+	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
+	projection_threshold *= projection_threshold;
+	
 	const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object.
 	const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin();
 	const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame();
@@ -1068,7 +1089,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	U32 last_update = mImpl->mLastCameraUpdate;
 
 	//process visible entries
-	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
+	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); new_obj_count > 0 && iter != mImpl->mVisibleEntries.end();)
 	{
 		LLVOCacheEntry* vo_entry = *iter;
 
@@ -1078,6 +1099,10 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{			
 			mImpl->mWaitingList.insert(vo_entry);
+			if(!(--new_obj_count))
+			{
+				break;
+			}
 		}
 
 		LLVOCacheEntry* child;
@@ -1090,6 +1115,11 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 			{
 				child->setSceneContribution(LARGE_SCENE_CONTRIBUTION); //a large number to force to load the child.
 				mImpl->mWaitingList.insert(child);
+
+				if(!(--new_obj_count))
+				{
+					break;
+				}
 			}
 			else
 			{
@@ -1123,7 +1153,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 	//process visible groups
 	std::set< LLPointer<LLViewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
-	for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
+	for(; new_obj_count > 0 && group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
 	{
 		LLPointer<LLViewerOctreeGroup> group = *group_iter;
 		if(group->getNumRefs() < 3 || //group to be deleted
@@ -1145,7 +1175,16 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 				}
 
 				vo_entry->calcSceneContribution(camera_origin, needs_update, last_update);				
-				mImpl->mWaitingList.insert(vo_entry);
+
+				if(vo_entry->getSceneContribution() > projection_threshold)
+				{
+					mImpl->mWaitingList.insert(vo_entry);
+					
+					if(!(--new_obj_count))
+					{
+						break;
+					}
+				}
 			}
 		}
 	}
@@ -1161,8 +1200,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 {
-	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
-
 	if(mDead)
 	{
 		return max_time;
@@ -1171,12 +1208,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	{
 		mImpl->mVOCachePartition->setCullHistory(FALSE);
 		return max_time;
-	}
-
-	//object projected area threshold
-	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
-	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
-	projection_threshold *= projection_threshold;
+	}	
 
 	S32 throttle = sNewObjectCreationThrottle;
 	BOOL has_new_obj = FALSE;
@@ -1184,12 +1216,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin();
 		iter != mImpl->mWaitingList.end(); ++iter)
 	{
-		LLVOCacheEntry* vo_entry = *iter;
-			
-		if(vo_entry->getSceneContribution() < projection_threshold)
-		{
-			break;
-		}
+		LLVOCacheEntry* vo_entry = *iter;		
 
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{
-- 
cgit v1.2.3


From 555cf227ffed470184b55bc5a87b125da66f0a16 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 25 Oct 2013 10:29:45 -0600
Subject: trivial: fix several weird compiling errors.

---
 indra/newview/llflexibleobject.cpp   | 2 +-
 indra/newview/llmeshrepository.cpp   | 2 +-
 indra/newview/llspatialpartition.cpp | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index c589bea674..3cd4367891 100755
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -660,7 +660,7 @@ void LLVolumeImplFlexible::doFlexibleUpdate()
 	mSection[i].mdPosition = (mSection[i].mPosition - mSection[i-1].mPosition) * inv_section_length;
 
 	// Create points
-	llassert(mRenderRes > -1)
+	llassert(mRenderRes > -1);
 	S32 num_render_sections = 1<<mRenderRes;
 	if (path->getPathLength() != num_render_sections+1)
 	{
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 77ea965136..a876e1f755 100755
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -736,7 +736,7 @@ void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
 		if (pending != mPendingLOD.end())
 		{ //append this lod request to existing header request
 			pending->second.push_back(lod);
-			llassert(pending->second.size() <= LLModel::NUM_LODS)
+			llassert(pending->second.size() <= LLModel::NUM_LODS);
 		}
 		else
 		{ //if no header request is pending, fetch header
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 55c0acd3f9..86d1948baa 100755
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1201,7 +1201,7 @@ public:
 	{
 		LLSpatialGroup* group = (LLSpatialGroup*)base_group;
 		
-		llassert(!group->hasState(LLSpatialGroup::DIRTY) && !group->isEmpty())
+		llassert(!group->hasState(LLSpatialGroup::DIRTY) && !group->isEmpty());
 		
 		if (mRes < 2)
 		{
-- 
cgit v1.2.3


From 0857eda4f68d10a3cf46ffe67d5739c0c6d25f76 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 25 Oct 2013 11:46:33 -0600
Subject: revert the changeset 71221dddea16: add throttle to number of pokes to
 potential visible objects per frame.

---
 indra/newview/llviewerregion.cpp | 52 ++++++++++++----------------------------
 1 file changed, 15 insertions(+), 37 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index dee52abea7..fdeb65e5a3 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1049,8 +1049,6 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 
 F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 {
-	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
-
 	if(mDead)
 	{
 		return max_time;
@@ -1065,22 +1063,8 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	{
 		return max_time;
 	}
-	U32 new_obj_count = sNewObjectCreationThrottle;
-	if(sNewObjectCreationThrottle < 0)
-	{
-		new_obj_count = (U32)-1; //maximum
-	}
-	else
-	{
-		new_obj_count *= 1.5f; //load 50% more for selection
-	}
 
 	LLTimer update_timer;
-
-	//object projected area threshold
-	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
-	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
-	projection_threshold *= projection_threshold;
 	
 	const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object.
 	const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin();
@@ -1089,7 +1073,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	U32 last_update = mImpl->mLastCameraUpdate;
 
 	//process visible entries
-	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); new_obj_count > 0 && iter != mImpl->mVisibleEntries.end();)
+	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
 	{
 		LLVOCacheEntry* vo_entry = *iter;
 
@@ -1099,10 +1083,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{			
 			mImpl->mWaitingList.insert(vo_entry);
-			if(!(--new_obj_count))
-			{
-				break;
-			}
 		}
 
 		LLVOCacheEntry* child;
@@ -1115,11 +1095,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 			{
 				child->setSceneContribution(LARGE_SCENE_CONTRIBUTION); //a large number to force to load the child.
 				mImpl->mWaitingList.insert(child);
-
-				if(!(--new_obj_count))
-				{
-					break;
-				}
 			}
 			else
 			{
@@ -1153,7 +1128,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 	//process visible groups
 	std::set< LLPointer<LLViewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
-	for(; new_obj_count > 0 && group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
+	for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
 	{
 		LLPointer<LLViewerOctreeGroup> group = *group_iter;
 		if(group->getNumRefs() < 3 || //group to be deleted
@@ -1175,16 +1150,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 				}
 
 				vo_entry->calcSceneContribution(camera_origin, needs_update, last_update);				
-
-				if(vo_entry->getSceneContribution() > projection_threshold)
-				{
-					mImpl->mWaitingList.insert(vo_entry);
-					
-					if(!(--new_obj_count))
-					{
-						break;
-					}
-				}
+				mImpl->mWaitingList.insert(vo_entry);			
 			}
 		}
 	}
@@ -1200,6 +1166,8 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 {
+	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
+
 	if(mDead)
 	{
 		return max_time;
@@ -1210,6 +1178,11 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 		return max_time;
 	}	
 
+	//object projected area threshold
+	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
+	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
+	projection_threshold *= projection_threshold;
+
 	S32 throttle = sNewObjectCreationThrottle;
 	BOOL has_new_obj = FALSE;
 	LLTimer update_timer;	
@@ -1218,6 +1191,11 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	{
 		LLVOCacheEntry* vo_entry = *iter;		
 
+		if(vo_entry->getSceneContribution() < projection_threshold)
+		{
+			break;
+		}
+
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{
 			addNewObject(vo_entry);
-- 
cgit v1.2.3


From d9d696de388ab7ce0626a18ce461ce7e84b86793 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Fri, 25 Oct 2013 11:48:59 -0600
Subject: trivial: convert to unix endings.

---
 indra/newview/llviewerregion.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index fdeb65e5a3..23660dd3ce 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1178,9 +1178,9 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 		return max_time;
 	}	
 
-	//object projected area threshold
-	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
-	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
+	//object projected area threshold
+	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
+	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
 	projection_threshold *= projection_threshold;
 
 	S32 throttle = sNewObjectCreationThrottle;
@@ -1191,9 +1191,9 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 	{
 		LLVOCacheEntry* vo_entry = *iter;		
 
-		if(vo_entry->getSceneContribution() < projection_threshold)
-		{
-			break;
+		if(vo_entry->getSceneContribution() < projection_threshold)
+		{
+			break;
 		}
 
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
-- 
cgit v1.2.3


From 237627181dbd9c7712ddaa8da6cdf1a8828d1279 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 29 Oct 2013 19:05:28 -0700
Subject: always dump entire fast timer log on right click...not just visible
 timers

---
 indra/newview/llfasttimerview.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index bd92b4b6ca..768f7c1a03 100755
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -961,10 +961,10 @@ void LLFastTimerView::printLineStats()
 			first = false;
 			legend_stat += idp->getName();
 
-			if (idp->getTreeNode().mCollapsed)
-			{
-				it.skipDescendants();
-			}
+			//if (idp->getTreeNode().mCollapsed)
+			//{
+			//	it.skipDescendants();
+			//}
 		}
 		LL_INFOS() << legend_stat << LL_ENDL;
 
@@ -995,10 +995,10 @@ void LLFastTimerView::printLineStats()
 
 			timer_stat += llformat("%.1f",ms.value());
 
-			if (idp->getTreeNode().mCollapsed)
-			{
-				it.skipDescendants();
-			}
+			//if (idp->getTreeNode().mCollapsed)
+			//{
+			//	it.skipDescendants();
+			//}
 		}
 		LL_INFOS() << timer_stat << LL_ENDL;
 		mStatsIndex = -1;
-- 
cgit v1.2.3


From 92decff3d41ccd9b517a453da7b42fff2fca268f Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 29 Oct 2013 20:06:43 -0700
Subject: SH-4585 FIX: Viewer crashes after attempt to login with invalid SOCKS
 5 proxy. don't have 2 login panels at the same time

---
 indra/newview/llpanellogin.cpp | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index 707f43660c..e2b4d098e9 100755
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -111,16 +111,6 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
 	setBackgroundVisible(FALSE);
 	setBackgroundOpaque(TRUE);
 
-	// instance management
-	if (LLPanelLogin::sInstance)
-	{
-		LL_WARNS("AppInit") << "Duplicate instance of login view deleted" << LL_ENDL;
-		// Don't leave bad pointer in gFocusMgr
-		gFocusMgr.setDefaultKeyboardFocus(NULL);
-
-		delete LLPanelLogin::sInstance;
-	}
-
 	mPasswordModified = FALSE;
 	LLPanelLogin::sInstance = this;
 
@@ -442,6 +432,16 @@ void LLPanelLogin::show(const LLRect &rect,
 						void (*callback)(S32 option, void* user_data),
 						void* callback_data)
 {
+	// instance management
+	if (LLPanelLogin::sInstance)
+	{
+		LL_WARNS("AppInit") << "Duplicate instance of login view deleted" << LL_ENDL;
+		// Don't leave bad pointer in gFocusMgr
+		gFocusMgr.setDefaultKeyboardFocus(NULL);
+
+		delete LLPanelLogin::sInstance;
+	}
+
 	new LLPanelLogin(rect, callback, callback_data);
 
 	if( !gFocusMgr.getKeyboardFocus() )
-- 
cgit v1.2.3


From 8582cd06ba4ec417efe9dc24971fe7011309a51c Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Tue, 29 Oct 2013 22:46:07 -0600
Subject: fix to decrease number of triangles rendered per frame

---
 indra/newview/llvieweroctree.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 3646133e91..1b3d7da90d 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -746,7 +746,11 @@ BOOL LLViewerOctreeGroup::isRecentlyVisible() const
 void LLViewerOctreeGroup::setVisible()
 {
 	mVisible[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
-	mAnyVisible = LLViewerOctreeEntryData::getCurrentFrame();
+	
+	if(LLViewerCamera::sCurCameraID < LLViewerCamera::CAMERA_WATER0)
+	{
+		mAnyVisible = LLViewerOctreeEntryData::getCurrentFrame();
+	}
 }
 
 void LLViewerOctreeGroup::checkStates()
-- 
cgit v1.2.3


From 787ff3937d697526284e8d0a812a7353ad916dea Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 30 Oct 2013 11:37:53 -0600
Subject: fix for SH-4584: Interesting: objectprojectionAreaCutOFF hides large
 objects on adjacent regions.

---
 indra/newview/llviewerregion.cpp | 4 +++-
 indra/newview/llvocache.cpp      | 9 ++-------
 indra/newview/llvocache.h        | 2 +-
 3 files changed, 6 insertions(+), 9 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 23660dd3ce..cbce2674a7 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1071,6 +1071,8 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 	const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame();
 	bool needs_update = ((cur_frame - mImpl->mLastCameraUpdate) > 5) && ((camera_origin - mImpl->mLastCameraOrigin).lengthSquared() > 10.f);	
 	U32 last_update = mImpl->mLastCameraUpdate;
+	LLVector4a local_origin;
+	local_origin.load3((camera_origin - getOriginAgent()).mV);
 
 	//process visible entries
 	for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
@@ -1149,7 +1151,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 					continue;
 				}
 
-				vo_entry->calcSceneContribution(camera_origin, needs_update, last_update);				
+				vo_entry->calcSceneContribution(local_origin, needs_update, last_update);				
 				mImpl->mWaitingList.insert(vo_entry);			
 			}
 		}
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 72270eec46..b1c7423b49 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -383,20 +383,15 @@ bool LLVOCacheEntry::isRecentlyVisible() const
 	return vis;
 }
 
-void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update)
+void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update)
 {
 	if(!needs_update && getVisible() >= last_update)
 	{
 		return; //no need to update
 	}
 
-	const LLVector4a& center = getPositionGroup();
-	
-	LLVector4a origin;
-	origin.load3(camera_origin.mV);
-
 	LLVector4a lookAt;
-	lookAt.setSub(center, origin);
+	lookAt.setSub(getPositionGroup(), camera_origin);
 	F32 squared_dist = lookAt.dot3(lookAt).getF32();
 
 	if(squared_dist > 0.f)
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 3ee9dcaac8..446111620d 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -93,7 +93,7 @@ public:
 	S32 getHitCount() const			{ return mHitCount; }
 	S32 getCRCChangeCount() const	{ return mCRCChangeCount; }
 	
-	void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update);
+	void calcSceneContribution(const LLVector4a& camera_origin, bool needs_update, U32 last_update);
 	void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;}
 	F32 getSceneContribution() const             { return mSceneContrib;}
 
-- 
cgit v1.2.3


From 960765e8c7d49a48e66f2e55e980c60645d9ca37 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 30 Oct 2013 23:17:40 -0600
Subject: more fix to reduce number of rendered triangles per frame.

---
 indra/newview/llvieweroctree.h   |  1 +
 indra/newview/llviewerregion.cpp | 32 +++++++++++++++++++-------------
 indra/newview/llvocache.cpp      | 32 ++++++++++++++++++++------------
 indra/newview/llvocache.h        |  3 +--
 4 files changed, 41 insertions(+), 27 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index 611f285c8e..b03047cbbe 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -217,6 +217,7 @@ public:
 	BOOL isVisible() const;
 	virtual BOOL isRecentlyVisible() const;
 	S32  getVisible(LLViewerCamera::eCameraID id) const {return mVisible[id];}
+	S32  getAnyVisible() const {return mAnyVisible;}
 	bool isEmpty() const { return mOctreeNode->isEmpty(); }
 
 	U32  getState()				   {return mState; }
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index cbce2674a7..a4b7efc56a 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1359,6 +1359,8 @@ BOOL LLViewerRegion::isViewerCameraStatic()
 
 F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 {
+	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");
+
 #if 1
 	if(!sVOCacheCullingEnabled)
 	{
@@ -1369,6 +1371,10 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 		return max_time;
 	}
 
+	LLVector4a camera_origin;
+	camera_origin.load3(LLViewerCamera::getInstance()->getOrigin().mV);
+	F32 squared_back_threshold = back_sphere_radius * back_sphere_radius;
+
 	bool unstable = sNewObjectCreationThrottle < 0;
 	size_t max_update = unstable ? mImpl->mActiveSet.size() : 64; 
 	if(!mInvisibilityCheckHistory && isViewerCameraStatic())
@@ -1388,7 +1394,7 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 			iter = mImpl->mActiveSet.begin();
 		}
 
-		if(!(*iter)->isRecentlyVisible() && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated))
+		if(!(*iter)->isAnyVisible(camera_origin, squared_back_threshold) && (unstable || (*iter)->mLastCameraUpdated < sLastCameraUpdated))
 		{
 			killObject((*iter), delete_list);
 		}
@@ -1425,18 +1431,18 @@ void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>&
 
 	if(!drawablep->getParent())
 	{
-		LLViewerObject::const_child_list_t& child_list = drawablep->getVObj()->getChildren();
-		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
-			iter != child_list.end(); iter++)
-		{
-			LLViewerObject* child = *iter;
-			if(child->mDrawable->isRecentlyVisible())
-			{
-				//set the parent group visible if any of its children visible.
-				((LLViewerOctreeEntryData*)drawablep)->setVisible();
-				return;
-			}
-		}
+		//LLViewerObject::const_child_list_t& child_list = drawablep->getVObj()->getChildren();
+		//for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
+		//	iter != child_list.end(); iter++)
+		//{
+		//	LLViewerObject* child = *iter;
+		//	if(child->mDrawable->isRecentlyVisible())
+		//	{
+		//		//set the parent group visible if any of its children visible.
+		//		((LLViewerOctreeEntryData*)drawablep)->setVisible();
+		//		return;
+		//	}
+		//}
 		delete_list.push_back(drawablep);				
 	}				
 }
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index b1c7423b49..70b65f14be 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -358,26 +358,34 @@ void LLVOCacheEntry::updateDebugSettings()
 	sBackAngleTanSquared = squared_back_angle;
 }
 
-bool LLVOCacheEntry::isRecentlyVisible() const
+bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold)
 {
-	bool vis = LLViewerOctreeEntryData::isRecentlyVisible();
-
-	if(!vis && getGroup())
+	LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup();
+	if(!group)
 	{
-		//recently visible to any camera?
-		vis = ((LLOcclusionCullingGroup*)getGroup())->isAnyRecentlyVisible();
+		return false;
 	}
 
-	//combination of projected area and squared distance
-	if(!vis && !mParentID && mSceneContrib > sBackAngleTanSquared) 
+	//any visible
+	bool vis = group->isAnyRecentlyVisible();
+
+	//not ready to remove
+	if(!vis)
 	{
-		F32 rad = getBinRadius();
-		vis = (rad * rad / mSceneContrib < sBackDistanceSquared);
+		vis = (group->getAnyVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame());
 	}
 
-	if(!vis)
+	//within the back sphere
+	if(!vis && !mParentID)
 	{
-		vis = (getVisible() + sMinFrameRange > LLViewerOctreeEntryData::getCurrentFrame());
+		LLVector4a lookAt;
+		lookAt.setSub(getPositionGroup(), camera_origin);
+		F32 squared_dist = lookAt.dot3(lookAt).getF32();
+		F32 rad = getBinRadius();
+		rad *= rad;
+		
+		//rough estimation
+		vis = (squared_dist - rad < squared_dist_threshold);
 	}
 
 	return vis;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 446111620d..ae32fb0cee 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -85,8 +85,7 @@ public:
 	bool hasState(U32 state)   {return mState & state;}
 	U32  getState() const      {return mState;}
 	
-	//virtual
-	bool isRecentlyVisible() const;
+	bool isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold);
 
 	U32 getLocalID() const			{ return mLocalID; }
 	U32 getCRC() const				{ return mCRC; }
-- 
cgit v1.2.3


From ccb921b287b14129918c07072f57078c69ca7e65 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 31 Oct 2013 15:10:10 -0600
Subject: more fix for performance regression.

---
 indra/newview/llviewerregion.cpp | 4 ++++
 indra/newview/llvocache.cpp      | 6 +++++-
 indra/newview/pipeline.cpp       | 4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index a4b7efc56a..b3837a41fe 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1299,6 +1299,9 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 		mPaused = FALSE; //unpause.
 	}
 
+	LLViewerCamera::eCameraID old_camera_id = LLViewerCamera::sCurCameraID;
+	LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
+
 	//reset all occluders
 	mImpl->mVOCachePartition->resetOccluders();	
 
@@ -1313,6 +1316,7 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	mImpl->mWaitingList.clear();
 	mImpl->mVisibleGroups.clear();
 
+	LLViewerCamera::sCurCameraID = old_camera_id;
 	return did_update;
 }
 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 70b65f14be..be7ff00c05 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -840,6 +840,10 @@ void LLVOCachePartition::processOccluders(LLCamera* camera)
 	{
 		return;
 	}
+	if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
+	{
+		return; //no need for those cameras.
+	}
 
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	LLVector4a shift(region_agent[0], region_agent[1], region_agent[2]);
@@ -864,7 +868,7 @@ void LLVOCachePartition::resetOccluders()
 	for(std::set<LLVOCacheGroup*>::iterator iter = mOccludedGroups.begin(); iter != mOccludedGroups.end(); ++iter)
 	{
 		LLVOCacheGroup* group = *iter;
-		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION, LLOcclusionCullingGroup::STATE_MODE_ALL_CAMERAS);
+		group->clearOcclusionState(LLOcclusionCullingGroup::ACTIVE_OCCLUSION);
 	}	
 	mOccludedGroups.clear();
 	sNeedsOcclusionCheck = FALSE;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 2cf59d212b..c5148690a5 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -2155,11 +2155,11 @@ void LLPipeline::updateMove()
 			}
 
 			//balance the VO Cache tree
-			LLVOCachePartition* vo_part = region->getVOCachePartition();
+			/*LLVOCachePartition* vo_part = region->getVOCachePartition();
 			if(vo_part)
 			{
 				vo_part->mOctree->balance();
-			}
+			}*/
 		}
 	}
 }
-- 
cgit v1.2.3


From fc6cd5954b94aa3b49a88b5d8192607c432cd54b Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Thu, 31 Oct 2013 16:13:29 -0600
Subject: fix for SH-4599: Interesting: objects flicker between LODs while you
 alt-zoom and SH-4598: Interesting: objects near the edge of the screen
 flicker

---
 indra/newview/llviewerregion.cpp | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index b3837a41fe..f549f6740d 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1435,18 +1435,22 @@ void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>&
 
 	if(!drawablep->getParent())
 	{
-		//LLViewerObject::const_child_list_t& child_list = drawablep->getVObj()->getChildren();
-		//for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
-		//	iter != child_list.end(); iter++)
-		//{
-		//	LLViewerObject* child = *iter;
-		//	if(child->mDrawable->isRecentlyVisible())
-		//	{
-		//		//set the parent group visible if any of its children visible.
-		//		((LLViewerOctreeEntryData*)drawablep)->setVisible();
-		//		return;
-		//	}
-		//}
+		LLViewerObject::const_child_list_t& child_list = drawablep->getVObj()->getChildren();
+		for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin();
+			iter != child_list.end(); iter++)
+		{
+			LLViewerObject* child = *iter;
+			if(child->mDrawable)
+			{
+				LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)child->mDrawable->getGroup();
+				if(group && group->isAnyRecentlyVisible())
+				{
+					//set the parent group visible if any of its children visible.
+					((LLViewerOctreeEntryData*)drawablep)->setVisible();
+					return;
+				}
+			}
+		}
 		delete_list.push_back(drawablep);				
 	}				
 }
-- 
cgit v1.2.3


From 0ce7008521b776451c0ce38299fa87c9e64c63cd Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 4 Nov 2013 16:41:06 -0700
Subject: fix for SH-4596: Interesting: MacBook Pro has worse framerate than on
 Release

---
 indra/newview/llviewerregion.cpp | 81 ++++++++++++++++++++++++++--------------
 indra/newview/llviewerregion.h   | 38 ++++++++++++++++---
 indra/newview/llworld.cpp        | 48 +++++++++++++++++++++---
 3 files changed, 128 insertions(+), 39 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index f549f6740d..fe420fe551 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1047,25 +1047,23 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
 	mImpl->mVisibleEntries.insert(entry);
 }
 
-F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
+void LLViewerRegion::updateVisibleEntries(F32 max_time)
 {
 	if(mDead)
 	{
-		return max_time;
+		return;
 	}
 
 	if(mImpl->mVisibleGroups.empty() && mImpl->mVisibleEntries.empty())
 	{
-		return max_time;
+		return;
 	}
 
 	if(!sNewObjectCreationThrottle)
 	{
-		return max_time;
+		return;
 	}
 
-	LLTimer update_timer;
-	
 	const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object.
 	const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin();
 	const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame();
@@ -1163,21 +1161,21 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
 		mImpl->mLastCameraUpdate = cur_frame;
 	}
 
-	return max_time - update_timer.getElapsedTimeF32();
+	return;
 }
 
-F32 LLViewerRegion::createVisibleObjects(F32 max_time)
+void LLViewerRegion::createVisibleObjects(F32 max_time)
 {
 	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
 
 	if(mDead)
 	{
-		return max_time;
+		return;
 	}
 	if(mImpl->mWaitingList.empty())
 	{
 		mImpl->mVOCachePartition->setCullHistory(FALSE);
-		return max_time;
+		return;
 	}	
 
 	//object projected area threshold
@@ -1211,7 +1209,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
 
 	mImpl->mVOCachePartition->setCullHistory(has_new_obj);
 
-	return max_time - update_timer.getElapsedTimeF32();
+	return;
 }
 
 void LLViewerRegion::clearCachedVisibleObjects()
@@ -1273,12 +1271,31 @@ void LLViewerRegion::clearCachedVisibleObjects()
 	return;
 }
 
-BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
+//perform some necessary but very light updates.
+//to replace the function idleUpdate(...) in case there is no enough time.
+void LLViewerRegion::lightIdleUpdate()
+{
+	if(!sVOCacheCullingEnabled)
+	{
+		return;
+	}
+	if(mImpl->mCacheMap.empty())
+	{
+		return;
+	}
+
+	//reset all occluders
+	mImpl->mVOCachePartition->resetOccluders();	
+}
+
+void LLViewerRegion::idleUpdate(F32 max_update_time)
 {	
 	LLTimer update_timer;
+	F32 max_time;
 
-	// did_update returns TRUE if we did at least one significant update
-	BOOL did_update = mImpl->mLandp->idleUpdate(max_update_time);
+	mLastUpdate = LLViewerOctreeEntryData::getCurrentFrame();
+
+	mImpl->mLandp->idleUpdate(max_update_time);
 	
 	if (mParcelOverlay)
 	{
@@ -1288,11 +1305,11 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	
 	if(!sVOCacheCullingEnabled)
 	{
-		return did_update;
+		return;
 	}
 	if(mImpl->mCacheMap.empty())
 	{
-		return did_update;
+		return;
 	}	
 	if(mPaused)
 	{
@@ -1305,19 +1322,22 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
 	//reset all occluders
 	mImpl->mVOCachePartition->resetOccluders();	
 
-	max_update_time -= update_timer.getElapsedTimeF32();	
+	max_time = max_update_time - update_timer.getElapsedTimeF32();	
 
 	//kill invisible objects
-	max_update_time = killInvisibleObjects(max_update_time);	
-	
-	max_update_time = updateVisibleEntries(max_update_time);
-	createVisibleObjects(max_update_time);
+	killInvisibleObjects(max_time * 0.4f);	
+	max_time = max_update_time - update_timer.getElapsedTimeF32();	
+
+	updateVisibleEntries(max_time);
+	max_time = max_update_time - update_timer.getElapsedTimeF32();	
+
+	createVisibleObjects(max_time);
 
 	mImpl->mWaitingList.clear();
 	mImpl->mVisibleGroups.clear();
 
 	LLViewerCamera::sCurCameraID = old_camera_id;
-	return did_update;
+	return;
 }
 
 //update the throttling number for new object creation
@@ -1361,20 +1381,20 @@ BOOL LLViewerRegion::isViewerCameraStatic()
 	return sLastCameraUpdated < LLViewerOctreeEntryData::getCurrentFrame();
 }
 
-F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
+void LLViewerRegion::killInvisibleObjects(F32 max_time)
 {
 	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");
 
-#if 1
 	if(!sVOCacheCullingEnabled)
 	{
-		return max_time;
+		return;
 	}
 	if(mImpl->mActiveSet.empty())
 	{
-		return max_time;
+		return;
 	}
 
+	LLTimer update_timer;
 	LLVector4a camera_origin;
 	camera_origin.load3(LLViewerCamera::getInstance()->getOrigin().mV);
 	F32 squared_back_threshold = back_sphere_radius * back_sphere_radius;
@@ -1402,6 +1422,11 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 		{
 			killObject((*iter), delete_list);
 		}
+
+		if(max_time < update_timer.getElapsedTimeF32()) //time out
+		{
+			break;
+		}
 	}
 
 	if(iter == mImpl->mActiveSet.end())
@@ -1423,8 +1448,8 @@ F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
 		}
 		delete_list.clear();
 	}
-#endif
-	return max_time;
+
+	return;
 }
 
 void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector<LLDrawable*>& delete_list)
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 06a8d781a1..a6c1eb65d4 100755
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -229,7 +229,8 @@ public:
 
 	F32	getWidth() const						{ return mWidth; }
 
-	BOOL idleUpdate(F32 max_update_time);
+	void idleUpdate(F32 max_update_time);
+	void lightIdleUpdate();
 	bool addVisibleGroup(LLViewerOctreeGroup* group);
 	void addVisibleCacheEntry(LLVOCacheEntry* entry);
 	void addActiveCacheEntry(LLVOCacheEntry* entry);
@@ -374,6 +375,9 @@ public:
 	void addToCreatedList(U32 local_id);	
 
 	BOOL isPaused() const {return mPaused;}
+	S32  getLastUpdate() const {return mLastUpdate;}
+
+	static BOOL isNewObjectCreationThrottleDisabled() {return sNewObjectCreationThrottle < 0;}
 
 private:
 	void addToVOCacheTree(LLVOCacheEntry* entry);
@@ -383,9 +387,9 @@ private:
 	void replaceVisibleCacheEntry(LLVOCacheEntry* old_entry, LLVOCacheEntry* new_entry);
 	void killCacheEntry(LLVOCacheEntry* entry); //physically delete the cache entry	
 
-	F32 killInvisibleObjects(F32 max_time);
-	F32 createVisibleObjects(F32 max_time);
-	F32 updateVisibleEntries(F32 max_time); //update visible entries
+	void killInvisibleObjects(F32 max_time);
+	void createVisibleObjects(F32 max_time);
+	void updateVisibleEntries(F32 max_time); //update visible entries
 
 	void addCacheMiss(U32 id, LLViewerRegion::eCacheMissType miss_type);
 	void decodeBoundingInfo(LLVOCacheEntry* entry);
@@ -426,9 +430,32 @@ public:
 	static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
 	static S32  sLastCameraUpdated;
 
-
 	LLFrameTimer &	getRenderInfoRequestTimer()			{ return mRenderInfoRequestTimer;		};
 
+	struct CompareRegionByLastUpdate
+	{
+		bool operator()(const LLViewerRegion* const& lhs, const LLViewerRegion* const& rhs)
+		{
+			S32 lpa = lhs->getLastUpdate();
+			S32 rpa = rhs->getLastUpdate();
+
+			//small mLastUpdate first
+			if(lpa < rpa)		
+			{
+				return true;
+			}
+			else if(lpa > rpa)
+			{
+				return false;
+			}
+			else
+			{
+				return lhs < rhs;
+			}			
+		}
+	};
+	typedef std::set<LLViewerRegion*, CompareRegionByLastUpdate> region_priority_list_t;
+
 private:
 	static S32  sNewObjectCreationThrottle;
 	LLViewerRegionImpl * mImpl;
@@ -437,6 +464,7 @@ private:
 	F32			mWidth;			// Width of region on a side (meters)
 	U64			mHandle;
 	F32			mTimeDilation;	// time dilation of physics simulation on simulator
+	S32         mLastUpdate; //last time called idleUpdate()
 
 	// simulator name
 	std::string mName;
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 1940bdcccc..d67e4ca71d 100755
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -665,25 +665,61 @@ static LLTrace::SampleStatHandle<> sNumActiveCachedObjects("numactivecachedobjec
 
 void LLWorld::updateRegions(F32 max_update_time)
 {
+	LLTimer update_timer;
+	mNumOfActiveCachedObjects = 0;
+
 	if(LLViewerCamera::getInstance()->isChanged())
 	{
 		LLViewerRegion::sLastCameraUpdated = LLViewerOctreeEntryData::getCurrentFrame() + 1;
 	}
 	LLViewerRegion::calcNewObjectCreationThrottle();
+	if(LLViewerRegion::isNewObjectCreationThrottleDisabled())
+	{
+		max_update_time = llmax(max_update_time, 1.0f); //seconds, loosen the time throttle.
+	}
 
-	// Perform idle time updates for the regions (and associated surfaces)
+	F32 max_time = llmin((F32)(max_update_time - update_timer.getElapsedTimeF32()), max_update_time * 0.25f);
+	//update the self avatar region
+	LLViewerRegion* self_regionp = gAgent.getRegion();
+	if(self_regionp)
+	{		
+		self_regionp->idleUpdate(max_time);
+	}
+
+	//sort regions by its mLastUpdate
+	//smaller mLastUpdate first to make sure every region has chance to get updated.
+	LLViewerRegion::region_priority_list_t region_list;
 	for (region_list_t::iterator iter = mRegionList.begin();
 		 iter != mRegionList.end(); ++iter)
 	{
-		(*iter)->idleUpdate(max_update_time);
+		LLViewerRegion* regionp = *iter;
+		if(regionp != self_regionp)
+		{
+			region_list.insert(regionp);
+		}
+		mNumOfActiveCachedObjects += regionp->getNumOfActiveCachedObjects();
 	}
 
-	mNumOfActiveCachedObjects = 0;
-	for (region_list_t::iterator iter = mRegionList.begin();
-		 iter != mRegionList.end(); ++iter)
+	// Perform idle time updates for the regions (and associated surfaces)
+	for (LLViewerRegion::region_priority_list_t::iterator iter = region_list.begin();
+		 iter != region_list.end(); ++iter)
 	{
-		mNumOfActiveCachedObjects += (*iter)->getNumOfActiveCachedObjects();
+		if(max_time > 0.f)
+		{
+			max_time = llmin((F32)(max_update_time - update_timer.getElapsedTimeF32()), max_update_time * 0.25f);
+		}
+
+		if(max_time > 0.f)
+		{
+			(*iter)->idleUpdate(max_time);
+		}
+		else
+		{
+			//perform some necessary but very light updates.
+			(*iter)->lightIdleUpdate();
+		}		
 	}
+
 	sample(sNumActiveCachedObjects, mNumOfActiveCachedObjects);
 }
 
-- 
cgit v1.2.3


From c35801ef1c56b6c84063f47b490a8d2220b77ca7 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 5 Nov 2013 19:26:23 -0800
Subject: fixed focus issue on inventory

---
 indra/newview/app_settings/settings.xml            |  44 ---------
 indra/newview/llavatariconctrl.cpp                 |  67 ++++++++-----
 indra/newview/llavatariconctrl.h                   |  46 +++++++--
 indra/newview/llsidepanelinventory.cpp             |   2 +-
 indra/newview/llviewertexturelist.cpp              |  51 +++++++---
 indra/newview/llviewertexturelist.h                |  10 +-
 indra/newview/skins/default/textures/textures.xml  |  10 +-
 .../textures/widgets/horizontal_drag_handle.png    | Bin 197 -> 217 bytes
 .../textures/widgets/vertical_drag_handle.png      | Bin 196 -> 238 bytes
 .../skins/default/xui/en/panel_main_inventory.xml  |   2 -
 .../skins/default/xui/en/sidepanel_inventory.xml   | 105 ++++++++++-----------
 .../skins/default/xui/en/widgets/avatar_icon.xml   |  12 ++-
 12 files changed, 189 insertions(+), 160 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 09d74a7f5e..df9dd3e1b5 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12004,50 +12004,6 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
-    <key>UIAvatariconctrlSymbolHPad</key>
-    <map>
-      <key>Comment</key>
-      <string>UI Avatar Icon Control Symbol Horizontal Pad</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <real>2</real>
-    </map>    
-    <key>UIAvatariconctrlSymbolVPad</key>
-    <map>
-      <key>Comment</key>
-      <string>UI Avatar Icon Control Symbol Vertical Pad</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <real>2</real>
-    </map>    
-    <key>UIAvatariconctrlSymbolSize</key>
-    <map>
-      <key>Comment</key>
-      <string>UI Avatar Icon Control Symbol Size</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <real>5</real>
-    </map>    
-    <key>UIAvatariconctrlSymbolPosition</key>
-    <map>
-      <key>Comment</key>
-      <string>UI Avatar Icon Control Symbol Position (TopLeft|TopRight|BottomLeft|BottomRight)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string>BottomRight</string>
-    </map>
     <key>UIButtonOrigHPad</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llavatariconctrl.cpp b/indra/newview/llavatariconctrl.cpp
index 7a49b77490..746b541f9d 100755
--- a/indra/newview/llavatariconctrl.cpp
+++ b/indra/newview/llavatariconctrl.cpp
@@ -49,6 +49,18 @@
 
 static LLDefaultChildRegistry::Register<LLAvatarIconCtrl> r("avatar_icon");
 
+namespace LLInitParam
+{
+	void TypeValues<LLAvatarIconCtrlEnums::ESymbolPos>::declareValues()
+	{
+		declare("BottomLeft",   LLAvatarIconCtrlEnums::BOTTOM_LEFT);
+		declare("BottomRight",  LLAvatarIconCtrlEnums::BOTTOM_RIGHT);
+		declare("TopLeft",		LLAvatarIconCtrlEnums::TOP_LEFT);
+		declare("TopRight",		LLAvatarIconCtrlEnums::TOP_RIGHT);
+	}
+}
+
+
 bool LLAvatarIconIDCache::LLAvatarIconIDCacheItem::expired()
 {
 	const F64 SEC_PER_DAY_PLUS_HOUR = (24.0 + 1.0) * 60.0 * 60.0;
@@ -145,52 +157,63 @@ void LLAvatarIconIDCache::remove	(const LLUUID& avatar_id)
 LLAvatarIconCtrl::Params::Params()
 :	avatar_id("avatar_id"),
 	draw_tooltip("draw_tooltip", true),
-	default_icon_name("default_icon_name")
+	default_icon_name("default_icon_name"),
+	symbol_hpad("symbol_hpad"),
+	symbol_vpad("symbol_vpad"),
+	symbol_size("symbol_size", 1),
+	symbol_pos("symbol_pos", LLAvatarIconCtrlEnums::BOTTOM_RIGHT)
 {
+	changeDefault(min_width, 32);
+	changeDefault(min_height, 32);
 }
 
 
 LLAvatarIconCtrl::LLAvatarIconCtrl(const LLAvatarIconCtrl::Params& p)
-	: LLIconCtrl(p),
+:	LLIconCtrl(p),
 	LLAvatarPropertiesObserver(),
 	mAvatarId(),
 	mFullName(),
 	mDrawTooltip(p.draw_tooltip),
 	mDefaultIconName(p.default_icon_name),
-	mAvatarNameCacheConnection()
+	mAvatarNameCacheConnection(),
+	mSymbolHpad(p.symbol_hpad),
+	mSymbolVpad(p.symbol_vpad),
+	mSymbolSize(p.symbol_size),
+	mSymbolPos(p.symbol_pos)
 {
 	mPriority = LLViewerFetchedTexture::BOOST_ICON;
 	
 	LLRect rect = p.rect;
-	mDrawWidth  = llmax(32, rect.getWidth()) ;
-	mDrawHeight = llmax(32, rect.getHeight()) ;
-
-	static LLUICachedControl<S32> llavatariconctrl_symbol_hpad("UIAvatariconctrlSymbolHPad", 2);
-	static LLUICachedControl<S32> llavatariconctrl_symbol_vpad("UIAvatariconctrlSymbolVPad", 2);
-	static LLUICachedControl<S32> llavatariconctrl_symbol_size("UIAvatariconctrlSymbolSize", 5);
-	static LLUICachedControl<std::string> llavatariconctrl_symbol_pos("UIAvatariconctrlSymbolPosition", "BottomRight");
 
 	// BottomRight is the default position
-	S32 left = rect.getWidth() - llavatariconctrl_symbol_size - llavatariconctrl_symbol_hpad;
-	S32 bottom = llavatariconctrl_symbol_vpad;
+	S32 left = rect.getWidth() - mSymbolSize - mSymbolHpad;
+	S32 bottom = mSymbolVpad;
 
-	if ("BottomLeft" == (std::string)llavatariconctrl_symbol_pos)
+	switch(mSymbolPos)
+	{
+	case LLAvatarIconCtrlEnums::BOTTOM_LEFT:
 	{
-		left = llavatariconctrl_symbol_hpad;
-		bottom = llavatariconctrl_symbol_vpad;
+		left = mSymbolHpad;
+		bottom = mSymbolVpad;
 	}
-	else if ("TopLeft" == (std::string)llavatariconctrl_symbol_pos)
+
+	case LLAvatarIconCtrlEnums::TOP_LEFT:
 	{
-		left = llavatariconctrl_symbol_hpad;
-		bottom = rect.getHeight() - llavatariconctrl_symbol_size - llavatariconctrl_symbol_vpad;
+		left = mSymbolHpad;
+		bottom = rect.getHeight() - mSymbolSize - mSymbolVpad;
 	}
-	else if ("TopRight" == (std::string)llavatariconctrl_symbol_pos)
+
+	case LLAvatarIconCtrlEnums::TOP_RIGHT:
 	{
-		left = rect.getWidth() - llavatariconctrl_symbol_size - llavatariconctrl_symbol_hpad;
-		bottom = rect.getHeight() - llavatariconctrl_symbol_size - llavatariconctrl_symbol_vpad;
+		left = rect.getWidth() - mSymbolSize - mSymbolHpad;
+		bottom = rect.getHeight() - mSymbolSize - mSymbolVpad;
 	}
 
-	rect.setOriginAndSize(left, bottom, llavatariconctrl_symbol_size, llavatariconctrl_symbol_size);
+	case LLAvatarIconCtrlEnums::BOTTOM_RIGHT:
+		// fallthrough, is default
+	default:
+		rect.setOriginAndSize(left, bottom, mSymbolSize, mSymbolSize);
+	}
 
 	if (p.avatar_id.isProvided())
 	{
diff --git a/indra/newview/llavatariconctrl.h b/indra/newview/llavatariconctrl.h
index 4929efb7d0..5b5720f4ac 100755
--- a/indra/newview/llavatariconctrl.h
+++ b/indra/newview/llavatariconctrl.h
@@ -29,7 +29,7 @@
 
 #include <boost/signals2.hpp>
 
-#include "../llui/lliconctrl.h"
+#include "lliconctrl.h"
 #include "llavatarpropertiesprocessor.h"
 #include "llviewermenu.h"
 
@@ -41,14 +41,14 @@ public:
 	struct LLAvatarIconIDCacheItem
 	{
 		LLUUID icon_id;
-		LLDate cached_time;	
+		LLDate cached_time;
 
 		bool expired();
 	};
 
-	LLAvatarIconIDCache():mFilename("avatar_icons_cache.txt")
-	{
-	}
+	LLAvatarIconIDCache()
+	:	mFilename("avatar_icons_cache.txt")
+	{}
 
 	void				load	();
 	void				save	();
@@ -64,15 +64,41 @@ protected:
 	std::map<LLUUID,LLAvatarIconIDCacheItem> mCache;//we cache only LLUID and time
 };
 
+namespace LLAvatarIconCtrlEnums
+{
+	enum ESymbolPos
+	{
+		BOTTOM_LEFT,
+		BOTTOM_RIGHT,
+		TOP_LEFT,
+		TOP_RIGHT
+	};
+}
+
+
+namespace LLInitParam
+{
+	template<>
+	struct TypeValues<LLAvatarIconCtrlEnums::ESymbolPos> : public TypeValuesHelper<LLAvatarIconCtrlEnums::ESymbolPos>
+	{
+		static void declareValues();
+	};
+}
+
 class LLAvatarIconCtrl
 : public LLIconCtrl, public LLAvatarPropertiesObserver
 {
 public:
 	struct Params : public LLInitParam::Block<Params, LLIconCtrl::Params>
 	{
-		Optional <LLUUID> avatar_id;
-		Optional <bool> draw_tooltip;
-		Optional <std::string> default_icon_name;
+		Optional<LLUUID>		avatar_id;
+		Optional<bool>			draw_tooltip;
+		Optional<std::string>	default_icon_name;
+		Optional<S32>			symbol_hpad,
+								symbol_vpad,
+								symbol_size;
+		Optional<LLAvatarIconCtrlEnums::ESymbolPos>	symbol_pos;
+
 		Params();
 	};
 	
@@ -98,6 +124,10 @@ protected:
 	std::string                 mFullName;
 	bool                        mDrawTooltip;
 	std::string                 mDefaultIconName;
+	S32							mSymbolHpad,
+								mSymbolVpad,
+								mSymbolSize;
+	LLAvatarIconCtrlEnums::ESymbolPos	mSymbolPos;
 
 	bool updateFromCache();
 
diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp
index d20f89456b..7121822015 100755
--- a/indra/newview/llsidepanelinventory.cpp
+++ b/indra/newview/llsidepanelinventory.cpp
@@ -161,7 +161,7 @@ BOOL LLSidepanelInventory::postBuild()
 {
 	// UI elements from inventory panel
 	{
-		mInventoryPanel = getChild<LLPanel>("sidepanel__inventory_panel");
+		mInventoryPanel = getChild<LLPanel>("sidepanel_inventory_panel");
 
 		mInfoBtn = mInventoryPanel->getChild<LLButton>("info_btn");
 		mInfoBtn->setClickedCallback(boost::bind(&LLSidepanelInventory::onInfoButtonClicked, this));
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 2f887d7185..dae76272ec 100755
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -70,6 +70,7 @@ S32 LLViewerTextureList::sNumImages = 0;
 LLViewerTextureList gTextureList;
 static LLTrace::BlockTimerStatHandle FTM_PROCESS_IMAGES("Process Images");
 
+
 ///////////////////////////////////////////////////////////////////////////////
 
 LLViewerTextureList::LLViewerTextureList() 
@@ -1587,28 +1588,31 @@ LLUIImagePtr LLUIImageList::getUIImage(const std::string& image_name, S32 priori
 }
 
 LLUIImagePtr LLUIImageList::loadUIImageByName(const std::string& name, const std::string& filename,
-											  BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority )
+											  BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority,
+											  LLUIImage::EScaleStyle scale_style)
 {
 	if (boost_priority == LLGLTexture::BOOST_NONE)
 	{
 		boost_priority = LLGLTexture::BOOST_UI;
 	}
 	LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTextureFromFile(filename, FTT_LOCAL_FILE, MIPMAP_NO, boost_priority);
-	return loadUIImage(imagep, name, use_mips, scale_rect, clip_rect);
+	return loadUIImage(imagep, name, use_mips, scale_rect, clip_rect, scale_style);
 }
 
 LLUIImagePtr LLUIImageList::loadUIImageByID(const LLUUID& id,
-											BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority)
+											BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLViewerTexture::EBoostLevel boost_priority,
+											LLUIImage::EScaleStyle scale_style)
 {
 	if (boost_priority == LLGLTexture::BOOST_NONE)
 	{
 		boost_priority = LLGLTexture::BOOST_UI;
 	}
 	LLViewerFetchedTexture* imagep = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, MIPMAP_NO, boost_priority);
-	return loadUIImage(imagep, id.asString(), use_mips, scale_rect, clip_rect);
+	return loadUIImage(imagep, id.asString(), use_mips, scale_rect, clip_rect, scale_style);
 }
 
-LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect)
+LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect,
+										LLUIImage::EScaleStyle scale_style)
 {
 	if (!imagep) return NULL;
 
@@ -1621,6 +1625,8 @@ LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const st
 	imagep->setNoDelete();
 
 	LLUIImagePtr new_imagep = new LLUIImage(name, imagep);
+	new_imagep->setScaleStyle(scale_style);
+
 	mUIImages.insert(std::make_pair(name, new_imagep));
 	mUITextureList.push_back(imagep);
 
@@ -1639,7 +1645,7 @@ LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const st
 	return new_imagep;
 }
 
-LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect)
+LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLUIImage::EScaleStyle scale_style)
 {
 	// look for existing image
 	uuid_ui_image_map_t::iterator found_it = mUIImages.find(name);
@@ -1649,7 +1655,7 @@ LLUIImagePtr LLUIImageList::preloadUIImage(const std::string& name, const std::s
 		LL_ERRS() << "UI Image " << name << " already loaded." << LL_ENDL;
 	}
 
-	return loadUIImageByName(name, filename, use_mips, scale_rect, clip_rect);
+	return loadUIImageByName(name, filename, use_mips, scale_rect, clip_rect, LLGLTexture::BOOST_UI, scale_style);
 }
 
 //static 
@@ -1709,14 +1715,28 @@ void LLUIImageList::onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_v
 	}
 }
 
+namespace LLInitParam
+{
+	template<>
+	struct TypeValues<LLUIImage::EScaleStyle> : public TypeValuesHelper<LLUIImage::EScaleStyle>
+	{
+		static void declareValues()
+		{
+			declare("scale_inner",	LLUIImage::SCALE_INNER);
+			declare("scale_outer",	LLUIImage::SCALE_OUTER);
+		}
+	};
+}
+
 struct UIImageDeclaration : public LLInitParam::Block<UIImageDeclaration>
 {
-	Mandatory<std::string>	name;
-	Optional<std::string>	file_name;
-	Optional<bool>			preload;
-	Optional<LLRect>		scale;
-	Optional<LLRect>		clip;
-	Optional<bool>			use_mips;
+	Mandatory<std::string>		name;
+	Optional<std::string>		file_name;
+	Optional<bool>				preload;
+	Optional<LLRect>			scale;
+	Optional<LLRect>			clip;
+	Optional<bool>				use_mips;
+	Optional<LLUIImage::EScaleStyle> scale_type;
 
 	UIImageDeclaration()
 	:	name("name"),
@@ -1724,7 +1744,8 @@ struct UIImageDeclaration : public LLInitParam::Block<UIImageDeclaration>
 		preload("preload", false),
 		scale("scale"),
 		clip("clip"),
-		use_mips("use_mips", false)
+		use_mips("use_mips", false),
+		scale_type("scale_type", LLUIImage::SCALE_INNER)
 	{}
 };
 
@@ -1812,7 +1833,7 @@ bool LLUIImageList::initFromFile()
 			{
 				continue;
 			}
-			preloadUIImage(image.name, file_name, image.use_mips, image.scale, image.clip);
+			preloadUIImage(image.name, file_name, image.use_mips, image.scale, image.clip, image.scale_type);
 		}
 
 		if (cur_pass == PASS_DECODE_NOW && !gSavedSettings.getBOOL("NoPreload"))
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 9dd3a9ee8b..2f84d0947a 100755
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -218,20 +218,22 @@ public:
 
 	bool initFromFile();
 
-	LLPointer<LLUIImage> preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect);
+	LLPointer<LLUIImage> preloadUIImage(const std::string& name, const std::string& filename, BOOL use_mips, const LLRect& scale_rect, const LLRect& clip_rect, LLUIImage::EScaleStyle stype);
 	
 	static void onUIImageLoaded( BOOL success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* src_aux, S32 discard_level, BOOL final, void* userdata );
 private:
 	LLPointer<LLUIImage> loadUIImageByName(const std::string& name, const std::string& filename,
 		                           BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null, 
 								   const LLRect& clip_rect = LLRect::null,
-		                           LLViewerTexture::EBoostLevel boost_priority = LLGLTexture::BOOST_UI);
+		                           LLViewerTexture::EBoostLevel boost_priority = LLGLTexture::BOOST_UI,
+								   LLUIImage::EScaleStyle = LLUIImage::SCALE_INNER);
 	LLPointer<LLUIImage> loadUIImageByID(const LLUUID& id,
 								 BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null, 
 								 const LLRect& clip_rect = LLRect::null,
-								 LLViewerTexture::EBoostLevel boost_priority = LLGLTexture::BOOST_UI);
+								 LLViewerTexture::EBoostLevel boost_priority = LLGLTexture::BOOST_UI,
+								 LLUIImage::EScaleStyle = LLUIImage::SCALE_INNER);
 
-	LLPointer<LLUIImage> loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null, const LLRect& clip_rect = LLRect::null);
+	LLPointer<LLUIImage> loadUIImage(LLViewerFetchedTexture* imagep, const std::string& name, BOOL use_mips = FALSE, const LLRect& scale_rect = LLRect::null, const LLRect& clip_rect = LLRect::null, LLUIImage::EScaleStyle = LLUIImage::SCALE_INNER);
 
 
 	struct LLUIImageLoadData
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index 54f60f4441..ff0a692741 100755
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -29,7 +29,7 @@ with the same filename but different name
 -->
 
 <textures version="101">
-  <!-- Please add new files alphabetically to prevent merge conflicts. JC -->
+	<!-- Please add new files alphabetically to prevent merge conflicts. JC -->
   <texture name="Accordion_ArrowClosed_Off" file_name="containers/Accordion_ArrowClosed_Off.png" preload="false" />
   <texture name="Accordion_ArrowClosed_Press" file_name="containers/Accordion_ArrowClosed_Press.png" preload="false" />
   <texture name="Accordion_ArrowOpened_Off" file_name="containers/Accordion_ArrowOpened_Off.png" preload="false" />
@@ -231,8 +231,9 @@ with the same filename but different name
 
 
   <texture name="Home_Off" file_name="navbar/Home_Off.png" preload="false" />
+	<texture name="Horizontal Drag Handle" file_name="widgets/horizontal_drag_handle.png" scale.left="8" scale.right="120" scale.bottom="1" scale.top="6" scale_type="scale_outer"/>
 
-  <texture name="Icon_Close_Foreground" file_name="windows/Icon_Close_Foreground.png" preload="true" />
+	<texture name="Icon_Close_Foreground" file_name="windows/Icon_Close_Foreground.png" preload="true" />
   <texture name="Icon_Close_Press" file_name="windows/Icon_Close_Press.png" preload="true" />
   <texture name="Icon_Close_Toast" file_name="windows/Icon_Close_Toast.png" preload="true" />
 
@@ -646,8 +647,9 @@ with the same filename but different name
   <texture name="Unread_Chiclet" file_name="bottomtray/Unread_Chiclet.png" preload="false" />
 
   <texture name="UpArrow_Off" file_name="icons/UpArrow_Off.png" preload="false" />
+	<texture name="Vertical Drag Handle" file_name="widgets/vertical_drag_handle.png" scale.left="2" scale.right="7" scale.bottom="8" scale.top="120"  scale_type="scale_outer"/>
 
-    <texture name="Volume_Background" file_name="windows/Volume_Background.png" preload="false"
+	<texture name="Volume_Background" file_name="windows/Volume_Background.png" preload="false"
            scale.left="6" scale.top="33" scale.right="63" scale.bottom="10" />
 
   <texture name="VoicePTT_Lvl1" file_name="bottomtray/VoicePTT_Lvl1.png" preload="false" />
@@ -775,6 +777,4 @@ with the same filename but different name
   <texture name="Camera_Drag_Dot" file_name="world/CameraDragDot.png"/>
   <texture name="NavBar Separator" file_name="navbar/separator.png"/>
 
-  <texture name="Horizontal Drag Handle" file_name="widgets/horizontal_drag_handle.png"/>
-  <texture name="Vertical Drag Handle" file_name="widgets/vertical_drag_handle.png"/>
 </textures>
diff --git a/indra/newview/skins/default/textures/widgets/horizontal_drag_handle.png b/indra/newview/skins/default/textures/widgets/horizontal_drag_handle.png
index 642eac4065..5f5a33be42 100644
Binary files a/indra/newview/skins/default/textures/widgets/horizontal_drag_handle.png and b/indra/newview/skins/default/textures/widgets/horizontal_drag_handle.png differ
diff --git a/indra/newview/skins/default/textures/widgets/vertical_drag_handle.png b/indra/newview/skins/default/textures/widgets/vertical_drag_handle.png
index b06b70cf36..2ce5208c21 100644
Binary files a/indra/newview/skins/default/textures/widgets/vertical_drag_handle.png and b/indra/newview/skins/default/textures/widgets/vertical_drag_handle.png differ
diff --git a/indra/newview/skins/default/xui/en/panel_main_inventory.xml b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
index 1c882bb099..0518688f45 100755
--- a/indra/newview/skins/default/xui/en/panel_main_inventory.xml
+++ b/indra/newview/skins/default/xui/en/panel_main_inventory.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <panel
- default_tab_group="1"
  follows="all"
  height="423"
  label="Things"
@@ -57,7 +56,6 @@
      left="7"
      name="inventory filter tabs"
      tab_height="30"
-     tab_group="1"
      tab_position="top"
      tab_min_width="100"
      top_pad="10"
diff --git a/indra/newview/skins/default/xui/en/sidepanel_inventory.xml b/indra/newview/skins/default/xui/en/sidepanel_inventory.xml
index 14bd349480..d3e24a19ef 100755
--- a/indra/newview/skins/default/xui/en/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/en/sidepanel_inventory.xml
@@ -12,17 +12,19 @@
 		 follows="all"
 		 layout="topleft"
 		 left="0"
-		 name="sidepanel__inventory_panel"
+		 name="sidepanel_inventory_panel"
 		 top="0"
 		 label=""
 		 height="570"
 		 visible="true"
+		 default_tab_group="1"
 		 width="330">
-         <layout_stack
+      <layout_stack
               follows="left|right|top|bottom"
               layout="topleft"
               left="0"
               top="0"
+							tab_group="1"
               orientation="vertical"
               name="inventory_layout_stack"
               height="535"
@@ -75,7 +77,7 @@
                      <button
                         control_name="InventoryInboxToggleState"
                         label="Received items"
-						font="SansSerifMedium"
+												font="SansSerifMedium"
                         name="inbox_btn"
                         height="35"
                         width="308"
@@ -116,61 +118,56 @@
                         background_opaque="true"
                         tool_tip="Drag and drop items to your inventory to use them"
                         >
-                        <text
-							name="inbox_inventory_placeholder"
-							type="string"
-							follows="all"
-							layout="topleft"
-							top="0"
-							left="0"
-							width="308"
-							height="200"
-							wrap="true"
-							halign="center">
-							Purchases from the marketplace will be delivered here.
-						</text>
+                        <text name="inbox_inventory_placeholder"
+															type="string"
+															follows="all"
+															layout="topleft"
+															top="0"
+															left="0"
+															width="308"
+															height="200"
+															wrap="true"
+															halign="center">
+Purchases from the marketplace will be delivered here.
+												</text>
                     </panel>
                  </panel>
              </layout_panel>
          </layout_stack>
-		<panel
-		     follows="bottom|left|right"
-			 height="30"
-			 layout="topleft"
-			 name="button_panel"
-			 left="9"
-             top_pad="7"
-			 width="308">
-			<layout_stack
-     	         follows="bottom|left|right"
-		         height="23"
-		         layout="topleft"
-		         mouse_opaque="false"
-		         name="button_panel_ls"
-		         left="0"
-		         orientation="horizontal"
-		         top="0"
-		         width="308">	
-			    <layout_panel
-			         follows="bottom|left|right"
-			         height="23"
-                     layout="bottomleft"
-                     left="0"			
-                     mouse_opaque="false"
-                     name="info_btn_lp"
-                     auto_resize="true"
-                     width="101">
-                    <button
-                         enabled="true"
-                         follows="bottom|left|right"
-                         height="23"
-                         label="Profile"
-                         layout="topleft"
-                         left="1"
-                         name="info_btn"
-                         tool_tip="Show object profile"
-                         top="0"
-                         width="100" />
+			<panel follows="bottom|left|right"
+					 height="30"
+					 layout="topleft"
+					 name="button_panel"
+					 left="9"
+					 top_pad="7"
+					 width="308">
+				<layout_stack follows="bottom|left|right"
+											height="23"
+											layout="topleft"
+											mouse_opaque="false"
+											name="button_panel_ls"
+											left="0"
+											orientation="horizontal"
+											top="0"
+											width="308">	
+			    <layout_panel follows="bottom|left|right"
+												height="23"
+												layout="bottomleft"
+												left="0"			
+												mouse_opaque="false"
+												name="info_btn_lp"
+												auto_resize="true"
+												width="101">
+						<button enabled="true"
+										follows="bottom|left|right"
+										height="23"
+										label="Profile"
+										layout="topleft"
+										left="1"
+										name="info_btn"
+										tool_tip="Show object profile"
+										top="0"
+										width="100" />
 			    </layout_panel>
 			    <layout_panel
                      follows="bottom|left|right"
diff --git a/indra/newview/skins/default/xui/en/widgets/avatar_icon.xml b/indra/newview/skins/default/xui/en/widgets/avatar_icon.xml
index 4d69dda7eb..7f8fac04d0 100755
--- a/indra/newview/skins/default/xui/en/widgets/avatar_icon.xml
+++ b/indra/newview/skins/default/xui/en/widgets/avatar_icon.xml
@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 
-<avatar_icon
-    name="avatar_icon"
-    default_icon_name="Generic_Person_Large"
-    use_draw_context_alpha="false">
-</avatar_icon>
+<avatar_icon name="avatar_icon"
+						 default_icon_name="Generic_Person_Large"
+						 use_draw_context_alpha="false"
+						 symbol_hpad = "2"
+						 symbol_vpad = "1"
+						 symbol_size = "5"/>
+
-- 
cgit v1.2.3


From a10eb7b240675b009430f6718d410399d8045581 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Tue, 5 Nov 2013 19:30:38 -0800
Subject: further fix of inventory keyboard focus and tab order calculations

---
 indra/newview/llfloateravatarpicker.cpp            |   2 +-
 indra/newview/llfloatermodelpreview.cpp            |  32 +-
 indra/newview/llpanelgroup.cpp                     |  10 +-
 indra/newview/llpaneloutfitsinventory.cpp          |  14 +-
 indra/newview/llviewermenu.cpp                     |   8 +-
 .../skins/default/xui/da/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/de/sidepanel_inventory.xml   |   2 +-
 .../xui/en/floater_conversation_preview.xml        |   1 -
 .../skins/default/xui/en/floater_im_session.xml    |   2 -
 .../skins/default/xui/en/floater_toybox.xml        |   1 -
 .../skins/default/xui/en/panel_bottomtray_lite.xml |   1 -
 .../skins/default/xui/en/panel_nearby_chat_bar.xml |   1 -
 .../skins/default/xui/en/panel_outfit_edit.xml     | 963 ++++++++++-----------
 .../newview/skins/default/xui/en/panel_people.xml  |   2 -
 .../skins/default/xui/es/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/fr/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/it/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/ja/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/pl/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/pt/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/ru/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/tr/sidepanel_inventory.xml   |   2 +-
 .../skins/default/xui/zh/sidepanel_inventory.xml   |   2 +-
 23 files changed, 519 insertions(+), 540 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp
index 7d091a79c5..c1e6673406 100755
--- a/indra/newview/llfloateravatarpicker.cpp
+++ b/indra/newview/llfloateravatarpicker.cpp
@@ -736,7 +736,7 @@ void LLFloaterAvatarPicker::processResponse(const LLUUID& query_id, const LLSD&
 		if (search_results->isEmpty())
 		{
 			LLStringUtil::format_map_t map;
-			map["[TEXT]"] = childGetText("Edit");
+			map["[TEXT]"] = getChild<LLUICtrl>("Edit")->getValue().asString();
 			LLSD item;
 			item["id"] = LLUUID::null;
 			item["columns"][0]["column"] = "name";
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 05c08b038c..424fa293da 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -591,7 +591,7 @@ bool LLFloaterModelPreview::isViewOptionChecked(const LLSD& userdata)
 
 bool LLFloaterModelPreview::isViewOptionEnabled(const LLSD& userdata)
 {
-	return childIsEnabled(userdata.asString());
+	return getChildView(userdata.asString())->getEnabled();
 }
 
 void LLFloaterModelPreview::setViewOptionEnabled(const std::string& option, bool enabled)
@@ -3587,11 +3587,11 @@ void LLModelPreview::loadModel(std::string filename, S32 lod, bool force_disable
 	
 	if (lod == mPreviewLOD)
 	{
-		mFMP->childSetText("lod_file_" + lod_name[lod], mLODFile[lod]);
+		mFMP->childSetValue("lod_file_" + lod_name[lod], mLODFile[lod]);
 	}
 	else if (lod == LLModel::LOD_PHYSICS)
 	{
-		mFMP->childSetText("physics_file", mLODFile[lod]);
+		mFMP->childSetValue("physics_file", mLODFile[lod]);
 	}
 
 	mFMP->openFloater();
@@ -3606,7 +3606,7 @@ void LLModelPreview::setPhysicsFromLOD(S32 lod)
 		mModel[LLModel::LOD_PHYSICS] = mModel[lod];
 		mScene[LLModel::LOD_PHYSICS] = mScene[lod];
 		mLODFile[LLModel::LOD_PHYSICS].clear();
-		mFMP->childSetText("physics_file", mLODFile[LLModel::LOD_PHYSICS]);
+		mFMP->childSetValue("physics_file", mLODFile[LLModel::LOD_PHYSICS]);
 		mVertexBuffer[LLModel::LOD_PHYSICS].clear();
 		rebuildUploadData();
 		refresh();
@@ -4322,8 +4322,8 @@ void LLModelPreview::updateStatusMessages()
 
 		if (total_tris[lod] > 0)
 		{
-			mFMP->childSetText(lod_triangles_name[lod], llformat("%d", total_tris[lod]));
-			mFMP->childSetText(lod_vertices_name[lod], llformat("%d", total_verts[lod]));
+			mFMP->childSetValue(lod_triangles_name[lod], llformat("%d", total_tris[lod]));
+			mFMP->childSetValue(lod_vertices_name[lod], llformat("%d", total_verts[lod]));
 		}
 		else
 		{
@@ -4344,8 +4344,8 @@ void LLModelPreview::updateStatusMessages()
 				}
 			}
 
-			mFMP->childSetText(lod_triangles_name[lod], mesh_status_na);
-			mFMP->childSetText(lod_vertices_name[lod], mesh_status_na);
+			mFMP->childSetValue(lod_triangles_name[lod], mesh_status_na);
+			mFMP->childSetValue(lod_vertices_name[lod], mesh_status_na);
 		}
 
 		const U32 lod_high = LLModel::LOD_HIGH;
@@ -4394,7 +4394,7 @@ void LLModelPreview::updateStatusMessages()
 
 		if (lod == mPreviewLOD)
 		{
-			mFMP->childSetText("lod_status_message_text", mFMP->getString(message));
+			mFMP->childSetValue("lod_status_message_text", mFMP->getString(message));
 			icon = mFMP->getChild<LLIconCtrl>("lod_status_message_icon");
 			icon->setImage(img);
 		}
@@ -4645,12 +4645,12 @@ void LLModelPreview::updateLodControls(S32 lod)
 		fmp->mLODMode[lod] = 0;
 		for (U32 i = 0; i < num_file_controls; ++i)
 		{
-			mFMP->childShow(file_controls[i] + lod_name[lod]);
+			mFMP->childSetVisible(file_controls[i] + lod_name[lod], true);
 		}
 
 		for (U32 i = 0; i < num_lod_controls; ++i)
 		{
-			mFMP->childHide(lod_controls[i] + lod_name[lod]);
+			mFMP->childSetVisible(lod_controls[i] + lod_name[lod], true);
 		}
 	}
 	else if (lod_mode == USE_LOD_ABOVE) // use LoD above
@@ -4658,12 +4658,12 @@ void LLModelPreview::updateLodControls(S32 lod)
 		fmp->mLODMode[lod] = 2;
 		for (U32 i = 0; i < num_file_controls; ++i)
 		{
-			mFMP->childHide(file_controls[i] + lod_name[lod]);
+			mFMP->childSetVisible(file_controls[i] + lod_name[lod], false);
 		}
 
 		for (U32 i = 0; i < num_lod_controls; ++i)
 		{
-			mFMP->childHide(lod_controls[i] + lod_name[lod]);
+			mFMP->childSetVisible(lod_controls[i] + lod_name[lod], false);
 		}
 
 		if (lod < LLModel::LOD_HIGH)
@@ -4688,12 +4688,12 @@ void LLModelPreview::updateLodControls(S32 lod)
 
 		for (U32 i = 0; i < num_file_controls; ++i)
 		{
-			mFMP->childHide(file_controls[i] + lod_name[lod]);
+			mFMP->getChildView(file_controls[i] + lod_name[lod])->setVisible(false);
 		}
 
 		for (U32 i = 0; i < num_lod_controls; ++i)
 		{
-			mFMP->childShow(lod_controls[i] + lod_name[lod]);
+			mFMP->getChildView(lod_controls[i] + lod_name[lod])->setVisible(true);
 		}
 
 
@@ -5644,7 +5644,7 @@ void LLModelPreview::setPreviewLOD(S32 lod)
 
 		LLComboBox* combo_box = mFMP->getChild<LLComboBox>("preview_lod_combo");
 		combo_box->setCurrentByIndex((NUM_LOD-1)-mPreviewLOD); // combo box list of lods is in reverse order
-		mFMP->childSetText("lod_file_" + lod_name[mPreviewLOD], mLODFile[mPreviewLOD]);
+		mFMP->childSetValue("lod_file_" + lod_name[mPreviewLOD], mLODFile[mPreviewLOD]);
 
 		LLComboBox* combo_box2 = mFMP->getChild<LLComboBox>("preview_lod_combo2");
 		combo_box2->setCurrentByIndex((NUM_LOD-1)-mPreviewLOD); // combo box list of lods is in reverse order
diff --git a/indra/newview/llpanelgroup.cpp b/indra/newview/llpanelgroup.cpp
index c9a066864c..30bbc5dba0 100755
--- a/indra/newview/llpanelgroup.cpp
+++ b/indra/newview/llpanelgroup.cpp
@@ -329,8 +329,9 @@ void LLPanelGroup::update(LLGroupChange gc)
 	if(gdatap)
 	{
 		std::string group_name =  gdatap->mName.empty() ? LLTrans::getString("LoadingData") : gdatap->mName;
-		childSetValue("group_name", group_name);
-		childSetToolTip("group_name",group_name);
+		LLUICtrl* group_name_ctrl = getChild<LLUICtrl>("group_name");
+		group_name_ctrl->setValue(group_name);
+		group_name_ctrl->setToolTip(group_name);
 		
 		LLGroupData agent_gdatap;
 		bool is_member = gAgent.getGroupData(mID,agent_gdatap) || gAgent.isGodlike();
@@ -376,8 +377,9 @@ void LLPanelGroup::setGroupID(const LLUUID& group_id)
 	if(gdatap)
 	{
 		std::string group_name =  gdatap->mName.empty() ? LLTrans::getString("LoadingData") : gdatap->mName;
-		childSetValue("group_name", group_name);
-		childSetToolTip("group_name",group_name);
+		LLUICtrl* group_name_ctrl = getChild<LLUICtrl>("group_name");
+		group_name_ctrl->setValue(group_name);
+		group_name_ctrl->setToolTip(group_name);
 	}
 
 	LLButton* button_apply = findChild<LLButton>("btn_apply");
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp
index f90236f6f2..3e106c8d69 100755
--- a/indra/newview/llpaneloutfitsinventory.cpp
+++ b/indra/newview/llpaneloutfitsinventory.cpp
@@ -242,18 +242,12 @@ void LLPanelOutfitsInventory::updateListCommands()
 	bool wear_visible = !isCOFPanelActive();
 	bool make_outfit_enabled = isActionEnabled("save_outfit");
 
+	LLButton* wear_btn = mListCommands->getChild<LLButton>("wear_btn");
 	mMyOutfitsPanel->childSetEnabled("trash_btn", trash_enabled);
-	mListCommands->childSetEnabled("wear_btn", wear_enabled);
-	mListCommands->childSetVisible("wear_btn", wear_visible);
+	wear_btn->setEnabled(wear_enabled);
+	wear_btn->setVisible(wear_visible);
 	mSaveComboBtn->setMenuItemEnabled("save_outfit", make_outfit_enabled);
-	if (mMyOutfitsPanel->hasItemSelected())
-	{
-		mListCommands->childSetToolTip("wear_btn", getString("wear_items_tooltip"));
-	}
-	else
-	{
-		mListCommands->childSetToolTip("wear_btn", getString("wear_outfit_tooltip"));
-	}
+	wear_btn->setToolTip(getString(mMyOutfitsPanel->hasItemSelected() ? "wear_items_tooltip" : "wear_outfit_tooltip"));
 }
 
 void LLPanelOutfitsInventory::onTrashButtonClick()
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 05b1236df5..981e0e3fdb 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2537,11 +2537,11 @@ bool enable_object_touch(LLUICtrl* ctrl)
 	LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
 	if (node && node->mValid && !node->mTouchName.empty())
 	{
-		gMenuHolder->childSetText(item_name, node->mTouchName);
+		gMenuHolder->childSetValue(item_name, node->mTouchName);
 	}
 	else
 	{
-		gMenuHolder->childSetText(item_name, get_default_item_label(item_name));
+		gMenuHolder->childSetValue(item_name, get_default_item_label(item_name));
 	}
 
 	return new_value;
@@ -5951,11 +5951,11 @@ bool enable_object_sit(LLUICtrl* ctrl)
 		LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
 		if (node && node->mValid && !node->mSitName.empty())
 		{
-			gMenuHolder->childSetText(item_name, node->mSitName);
+			gMenuHolder->childSetValue(item_name, node->mSitName);
 		}
 		else
 		{
-			gMenuHolder->childSetText(item_name, get_default_item_label(item_name));
+			gMenuHolder->childSetValue(item_name, get_default_item_label(item_name));
 		}
 	}
 	return !sitting_on_sel && is_object_sittable();
diff --git a/indra/newview/skins/default/xui/da/sidepanel_inventory.xml b/indra/newview/skins/default/xui/da/sidepanel_inventory.xml
index b3293b981e..b4b494cafa 100755
--- a/indra/newview/skins/default/xui/da/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/da/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Ting" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<panel name="button_panel">
 			<layout_stack name="button_panel_ls">
 				<layout_panel name="info_btn_lp">
diff --git a/indra/newview/skins/default/xui/de/sidepanel_inventory.xml b/indra/newview/skins/default/xui/de/sidepanel_inventory.xml
index 18aad64f96..2585c5dc90 100755
--- a/indra/newview/skins/default/xui/de/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/de/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Sonstiges" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/en/floater_conversation_preview.xml b/indra/newview/skins/default/xui/en/floater_conversation_preview.xml
index 764b9d8385..99ad59a7a3 100755
--- a/indra/newview/skins/default/xui/en/floater_conversation_preview.xml
+++ b/indra/newview/skins/default/xui/en/floater_conversation_preview.xml
@@ -2,7 +2,6 @@
 <floater
  legacy_header_height="18"
  can_resize="true"
- default_tab_group="1"
  help_topic="conversation_preview"
  height="391"
  layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/floater_im_session.xml b/indra/newview/skins/default/xui/en/floater_im_session.xml
index 43d0f2fb18..468f05d492 100755
--- a/indra/newview/skins/default/xui/en/floater_im_session.xml
+++ b/indra/newview/skins/default/xui/en/floater_im_session.xml
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <floater
  background_visible="true"
- default_tab_group="1"
  height="355"
  help_topic="floater_im_box"
  layout="topleft"
@@ -213,7 +212,6 @@
                      min_width="172">
                         <layout_stack
                          animate="true" 
-                         default_tab_group="2"
                          follows="all"
                          orientation="vertical"
                          name="translate_and_chat_stack"
diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml
index d8211c24a7..bc19d6e79f 100755
--- a/indra/newview/skins/default/xui/en/floater_toybox.xml
+++ b/indra/newview/skins/default/xui/en/floater_toybox.xml
@@ -4,7 +4,6 @@
   can_dock="false"
   can_minimize="false"
   can_resize="false"
-  default_tab_group="1"
   height="375"
   help_topic="toybox"
   layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_bottomtray_lite.xml b/indra/newview/skins/default/xui/en/panel_bottomtray_lite.xml
index 27a27473d8..1c0b205c4f 100755
--- a/indra/newview/skins/default/xui/en/panel_bottomtray_lite.xml
+++ b/indra/newview/skins/default/xui/en/panel_bottomtray_lite.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <panel
- default_tab_group="2"
  mouse_opaque="true"
  background_visible="true"
  bg_alpha_color="DkGray"
diff --git a/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml b/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
index 19143cef89..1e43db08f7 100755
--- a/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_nearby_chat_bar.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <panel
- default_tab_group="1"
  follows="left|bottom|right"
  height="25"
  layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
index b61f110e32..3f13cea58e 100755
--- a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
+++ b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml
@@ -12,32 +12,32 @@
  name="outfit_edit"
  top="0"
  width="320">
-    <string
-     name="No Outfit"
-     value="No Outfit"/>
-    <string
-     name="unsaved_changes"
-     value="Unsaved Changes"/>
-    <string
-     name="now_editing"
-     value="Now Editing"/>
-    <string
-     name="folder_view_off"
-     value="Hierarchy_View_Disabled"
-     translate="false"/>
-    <string
-     name="folder_view_on"
-     value="Hierarchy_View_On"
-     translate="false"/>
-    <string
-     name="list_view_off"
-     value="List_View_Disabled"
-     translate="false"/>
-    <string
-     name="list_view_on"
-     value="List_View_On"
-     translate="false"/>
-	
+	<string
+	 name="No Outfit"
+	 value="No Outfit"/>
+	<string
+	 name="unsaved_changes"
+	 value="Unsaved Changes"/>
+	<string
+	 name="now_editing"
+	 value="Now Editing"/>
+	<string
+	 name="folder_view_off"
+	 value="Hierarchy_View_Disabled"
+	 translate="false"/>
+	<string
+	 name="folder_view_on"
+	 value="Hierarchy_View_On"
+	 translate="false"/>
+	<string
+	 name="list_view_off"
+	 value="List_View_Disabled"
+	 translate="false"/>
+	<string
+	 name="list_view_on"
+	 value="List_View_On"
+	 translate="false"/>
+
 	<panel.string
 		name="not_available">
 		(N\A)
@@ -47,475 +47,466 @@
 		(unknown)
 	</panel.string>
 
-    <!-- Wearables filtering strings -->
-    <string name="Filter.All" value="All"/>
-    <string name="Filter.Clothes/Body" value="Clothes/Body"/>
-    <string name="Filter.Objects" value="Objects"/>
-    <string name="Filter.Clothing" value="Clothing"/>
-    <string name="Filter.Bodyparts" value="Body parts"/>
+	<!-- Wearables filtering strings -->
+	<string name="Filter.All" value="All"/>
+	<string name="Filter.Clothes/Body" value="Clothes/Body"/>
+	<string name="Filter.Objects" value="Objects"/>
+	<string name="Filter.Clothing" value="Clothing"/>
+	<string name="Filter.Bodyparts" value="Body parts"/>
+
+	<string
+	 name="replace_body_part"
+	 value="Click to replace your existing shape"/>
 
-    <string
-     name="replace_body_part"
-     value="Click to replace your existing shape"/>
-  
 
-    <button
-     follows="top|left"
-     height="24"
-     image_hover_unselected="BackButton_Over"
-     image_pressed="BackButton_Press"
-     image_unselected="BackButton_Off"
-     layout="topleft"
-     name="back_btn"
-     left="5"
-     tab_stop="false"
-     top="1"
-     width="30"
-     use_draw_context_alpha="false" />
-    <text
-     follows="top|left|right"
-     font="SansSerifHugeBold"
-     height="26"
-     layout="topleft"
-     left_pad="10"
-     name="title"
-     text_color="LtGray"
-     top="0"
-     value="Edit Outfit"
-     use_ellipses="true"
-     width="275" /> 
+	<button
+	 follows="top|left"
+	 height="24"
+	 image_hover_unselected="BackButton_Over"
+	 image_pressed="BackButton_Press"
+	 image_unselected="BackButton_Off"
+	 layout="topleft"
+	 name="back_btn"
+	 left="5"
+	 tab_stop="false"
+	 top="1"
+	 width="30"
+	 use_draw_context_alpha="false" />
+	<text
+	 follows="top|left|right"
+	 font="SansSerifHugeBold"
+	 height="26"
+	 layout="topleft"
+	 left_pad="10"
+	 name="title"
+	 text_color="LtGray"
+	 top="0"
+	 value="Edit Outfit"
+	 use_ellipses="true"
+	 width="275" />
 
-<!-- "HEADER WITH ICON, STATUS TEXT AND OUTFIT NAME" -->
-    <panel
-     background_visible="true"
-     bg_alpha_color="DkGray2"
-     bevel_style="none"
-     follows="top|left|right"
-     height="40"
-     layout="topleft"
-     left="6"
-     name="header_panel"
-     top_pad="5" 
-     width="311">
-        <icon
-         follows="left|top"
-         height="31"
-         image_name="Shirt_Large"
-         left="2"
-         mouse_opaque="false"
-         name="outfit_icon"
-         top="2"
-         scale_image="true"
-         visible="true"
-         width="31" />
-            <panel
-             bevel_style="none"
-             follows="top|left|right"
-             height="37"
-             layout="topleft"
-             left_pad="5"
-             name="outfit_name_and_status"
-             top="2"
-             width="270">
-                <text
-                 follows="top|left|right"
-                 font="SansSerifSmallBold"
-                 height="13"
-                 layout="topleft"
-                 name="status"
-                 text_color="EmphasisColor"
-                 top="2"
-                 value="Now editing..."
-                 use_ellipses="true"
-                 width="245" /> 
-                <text
-                 follows="bottom|left|right"
-                 font="SansSerifLargeBold"
-                 height="18"
-                 layout="topleft"
-                 name="curr_outfit_name"
-                 parse_urls="false"
-                 text_color="LtGray"
-                 top_pad="2"
-                 value="[Current Outfit]"
-                 use_ellipses="true"
-                 width="245" /> 
-                <loading_indicator
-                 follows="right|top"
-                 height="24"
-                 layout="topleft"
-                 right="-2"
-                 name="edit_outfit_loading_indicator"
-                 top="6"
-                 width="24" />
-            </panel>
-    </panel>
+	<!-- "HEADER WITH ICON, STATUS TEXT AND OUTFIT NAME" -->
+	<panel
+	 background_visible="true"
+	 bg_alpha_color="DkGray2"
+	 bevel_style="none"
+	 follows="top|left|right"
+	 height="40"
+	 layout="topleft"
+	 left="6"
+	 name="header_panel"
+	 top_pad="5"
+	 width="311">
+		<icon
+		 follows="left|top"
+		 height="31"
+		 image_name="Shirt_Large"
+		 left="2"
+		 mouse_opaque="false"
+		 name="outfit_icon"
+		 top="2"
+		 scale_image="true"
+		 visible="true"
+		 width="31" />
+		<panel
+		 bevel_style="none"
+		 follows="top|left|right"
+		 height="37"
+		 layout="topleft"
+		 left_pad="5"
+		 name="outfit_name_and_status"
+		 top="2"
+		 width="270">
+			<text
+			 follows="top|left|right"
+			 font="SansSerifSmallBold"
+			 height="13"
+			 layout="topleft"
+			 name="status"
+			 text_color="EmphasisColor"
+			 top="2"
+			 value="Now editing..."
+			 use_ellipses="true"
+			 width="245" />
+			<text
+			 follows="bottom|left|right"
+			 font="SansSerifLargeBold"
+			 height="18"
+			 layout="topleft"
+			 name="curr_outfit_name"
+			 parse_urls="false"
+			 text_color="LtGray"
+			 top_pad="2"
+			 value="[Current Outfit]"
+			 use_ellipses="true"
+			 width="245" />
+			<loading_indicator
+			 follows="right|top"
+			 height="24"
+			 layout="topleft"
+			 right="-2"
+			 name="edit_outfit_loading_indicator"
+			 top="6"
+			 width="24" />
+		</panel>
+	</panel>
 
 
-<!-- LIST OF WEARABLES (CURRENT OUTFIT/ WEARABLES TO ADD) -->
-<!-- *NOTE: border_size is used to calculate space between layout panels and also to calculate resize bar's height.
+	<!-- LIST OF WEARABLES (CURRENT OUTFIT/ WEARABLES TO ADD) -->
+	<!-- *NOTE: border_size is used to calculate space between layout panels and also to calculate resize bar's height.
 Required height for dragbar (icon in spec) is 10, so resizebar height should be 10 px.
 It is calculated as border_size + 2*UIResizeBarOverlap
 -->
-    <layout_stack
-     animate="true"
-     border_size="8"
-     clip="false"
-     default_tab_group="2"
-     follows="all"
-     height="465"
-     width="313"
-     layout="topleft"
-     orientation="vertical"
-     name="im_panels"
-     tab_group="1"
-     top_pad="5"
-     left="5">
-        <layout_panel
-         layout="topleft"
-         height="187"
-         min_height="155"
-         name="outfit_wearables_panel"
-         width="313"
-         auto_resize="true"
-         user_resize="true">
+	<layout_stack
+	 animate="true"
+	 border_size="8"
+	 clip="false"
+	 default_tab_group="2"
+	 follows="all"
+	 height="465"
+	 width="313"
+	 layout="topleft"
+	 orientation="vertical"
+	 name="im_panels"
+	 tab_group="1"
+	 top_pad="5"
+	 left="5">
+		<layout_panel
+		 layout="topleft"
+		 height="187"
+		 min_height="155"
+		 name="outfit_wearables_panel"
+		 width="313"
+		 auto_resize="true"
+		 user_resize="true">
 
-            <layout_stack
-             animate="true"
-             border_size="0"
-             follows="all"
-             height="185"
-             width="313"
-             orientation="vertical" 
-             layout="topleft"
-             name="filter_panels"
-             top="0"
-             left="0">
-                <layout_panel
-                 auto_resize="true" 
-                 background_visible="false"
-                 layout="topleft"
-                 height="154"
-                 name="add_button_and_combobox"
-                 width="311"
-                 visible="true">
+			<layout_stack
+			 animate="true"
+			 border_size="0"
+			 follows="all"
+			 height="185"
+			 width="313"
+			 orientation="vertical"
+			 layout="topleft"
+			 name="filter_panels"
+			 top="0"
+			 left="0">
+				<layout_panel
+				 auto_resize="true"
+				 background_visible="false"
+				 layout="topleft"
+				 height="154"
+				 name="add_button_and_combobox"
+				 width="311"
+				 visible="true">
 
-            <!-- List containing items from the COF and Base outfit -->
-            <panel
-             background_visible="false"
-             class="cof_wearables"
-             filename="panel_cof_wearables.xml"
-                     follows="all" 
-                     height="129"
-             layout="topleft"
-             left="1"
-             name="cof_wearables_list"
-             top="0"
-             width="311" />
+					<!-- List containing items from the COF and Base outfit -->
+					<panel
+					 background_visible="false"
+					 class="cof_wearables"
+					 filename="panel_cof_wearables.xml"
+									 follows="all"
+									 height="129"
+					 layout="topleft"
+					 left="1"
+					 name="cof_wearables_list"
+					 top="0"
+					 width="311" />
 
-                    <button
-                     follows="left|bottom" 
-                     height="22"
-                     image_pressed="PushButton_Press"
-                     image_pressed_selected="PushButton_Selected_Press"
-                     image_selected="PushButton_Selected_Press"
-                     is_toggle="true"
-                     label="Add More..."
-                     layout="topleft"
-                     left="2"
-                     name="show_add_wearables_btn"
-                     top_pad="2"
-                     tool_tip="Open/Close"
-                     width="125" />
+					<button
+					 follows="left|bottom"
+					 height="22"
+					 image_pressed="PushButton_Press"
+					 image_pressed_selected="PushButton_Selected_Press"
+					 image_selected="PushButton_Selected_Press"
+					 is_toggle="true"
+					 label="Add More..."
+					 layout="topleft"
+					 left="2"
+					 name="show_add_wearables_btn"
+					 top_pad="2"
+					 tool_tip="Open/Close"
+					 width="125" />
 
-                    <combo_box
-                     follows="left|right|bottom"
-                     height="22"
-             layout="topleft"
-                     left_pad="5"
-                     name="list_view_filter_combobox"
-                     top_delta="0"
-                     visible="false"
-                     width="152"/>
-                    <combo_box
-                     follows="left|right|bottom"
-                     height="22"
-                     layout="topleft"
-                     left_delta="0"
-                     name="folder_view_filter_combobox"
-                     top_delta="0"
-                     visible="false"
-                     width="152"/>
-                    
-            <button
-                     follows="bottom|right"
-                     height="22"
-             image_overlay="Search_Icon"
-                     image_pressed="PushButton_Press"
-                     image_pressed_selected="PushButton_Selected_Press"
-                     image_selected="PushButton_Selected_Press"
-             is_toggle="true"
-             layout="topleft"
-             name="filter_button"
-                     right="-5"
-             top_delta="0"
-                     visible="false"
-             width="20" />
-                </layout_panel>
+					<combo_box
+					 follows="left|right|bottom"
+					 height="22"
+	 layout="topleft"
+					 left_pad="5"
+					 name="list_view_filter_combobox"
+					 top_delta="0"
+					 visible="false"
+					 width="152"/>
+					<combo_box
+					 follows="left|right|bottom"
+					 height="22"
+					 layout="topleft"
+					 left_delta="0"
+					 name="folder_view_filter_combobox"
+					 top_delta="0"
+					 visible="false"
+					 width="152"/>
 
-                <layout_panel
-                 auto_resize="false"
-                 background_visible="true"
-                 bg_alpha_color="DkGray2"
-                 height="30"
-                 name="filter_panel"
-                 width="311"
-                 visible="false">
+					<button
+									 follows="bottom|right"
+									 height="22"
+					 image_overlay="Search_Icon"
+									 image_pressed="PushButton_Press"
+									 image_pressed_selected="PushButton_Selected_Press"
+									 image_selected="PushButton_Selected_Press"
+					 is_toggle="true"
+					 layout="topleft"
+					 name="filter_button"
+									 right="-5"
+					 top_delta="0"
+									 visible="false"
+					 width="20" />
+				</layout_panel>
 
-                    <filter_editor
-		             background_image="TextField_Search_Off"
-		             enabled="true"
-		             follows="left|right|top"
-		             label="Filter Inventory Wearables"
-		             layout="topleft"
-		             left="5"
-		             width="290"
-		             height="25"
-		             name="look_item_filter"
-		             search_button_visible="true"
-		             text_color="black"
-		             visible="true"/>
-                    
-                </layout_panel>
-            </layout_stack>
-                </layout_panel>
+				<layout_panel
+				 auto_resize="false"
+				 background_visible="true"
+				 bg_alpha_color="DkGray2"
+				 height="30"
+				 name="filter_panel"
+				 width="311"
+				 visible="false">
 
+					<filter_editor
+			 background_image="TextField_Search_Off"
+			 enabled="true"
+			 follows="left|right|top"
+			 label="Filter Inventory Wearables"
+			 layout="topleft"
+			 left="5"
+			 width="290"
+			 height="25"
+			 name="look_item_filter"
+			 search_button_visible="true"
+			 text_color="black"
+			 visible="true"/>
 
-                <layout_panel
-         background_visible="false"
-         bg_alpha_color="DkGray2"
-                 auto_resize="true"
-         default_tab_group="3"
-         height="450"
-         min_height="80"
-         name="add_wearables_panel"
-         width="313"
-         tab_group="2"
-         user_resize="true"
-         visible="false">
+				</layout_panel>
+			</layout_stack>
+		</layout_panel>
+
+
+		<layout_panel background_visible="false"
+									bg_alpha_color="DkGray2"
+									auto_resize="true"
+									height="450"
+									min_height="80"
+									name="add_wearables_panel"
+									width="313"
+									tab_group="2"
+									user_resize="true"
+									visible="false">
 
 			<!-- this icon represent dragbar between layout panels.
           	 This is a workaround implemented in EXT-7255 becouse of an issue with layout stack (EXT-7471) -->
-            <icon
-             follows="left|top|right"
-             height="10"
-             image_name="Dragbar"
-             left="0"
-             top_pad="-9"
-             width="313" />
+			<icon follows="left|top|right"
+						height="10"
+						image_name="Dragbar"
+						left="0"
+						top_pad="-9"
+						width="313" />
+			<inventory_panel allow_multi_select="true"
+											 background_visible="false"
+											 border="false"
+											 follows="left|top|right|bottom"
+											 height="418"
+											 layout="topleft"
+											 left="0"
+											 mouse_opaque="false"
+											 name="folder_view"
+											 top_pad="0"
+											 width="313"
+											 visible="false"/>
+			<panel name="filtered_wearables_panel"
+						 background_opaque="true"
+						 background_visible="false"
+						 layout="topleft"
+						 follows="left|top|right|bottom"
+						 border="false"
+						 height="418"
+						 left="0"
+						 mouse_opaque="false"
+						 width="310"
+						 top_delta="0"
+						 visible="true">
+				<wearable_items_list color="0.107 0.107 0.107 1"
+														 name="list_view"
+														 allow_select="true"
+														 layout="topleft"
+														 follows="all"
+														 multi_select="true"
+														 width="313"
+														 height="418"
+														 left="0"
+														 top="0"/>
+			</panel>
+			<button follows="bottom|left"
+							height="22"
+							left="2"
+							label="Wear Item"
+							layout="topleft"
+							name="plus_btn"
+							top_pad="5"
+							width="130" />
+		</layout_panel>
+	</layout_stack>
 
-                    <inventory_panel
-		             allow_multi_select="true"
-		             background_visible="false"
-		             border="false"
-		             follows="left|top|right|bottom"
-             height="418"
-		             layout="topleft"
-		             left="0"
-		             mouse_opaque="false"
-             name="folder_view"
-             top_pad="0"
-             width="313"
-		             visible="false"/>
-		            <panel
-		             name="filtered_wearables_panel"
-		             background_opaque="true"
-		             background_visible="false"
-		             layout="topleft"
-		             follows="left|top|right|bottom"
-		             border="false"
-             height="418"
-		             left="0"
-		             mouse_opaque="false"
-             width="310"
-		             top_delta="0"
-		             visible="true">
-		             <wearable_items_list
-		              color="0.107 0.107 0.107 1"
-                 name="list_view"
-		              allow_select="true"
-		              layout="topleft"
-		              follows="all"
-		              multi_select="true"
-                 width="313"
-                 height="418"
-		              left="0"
-		              top="0"/>
-		            </panel>
-            <button
-	         follows="bottom|left"
-	         height="22"
-	         left="2"
-	         label="Wear Item"
-	         layout="topleft"
-	         name="plus_btn"
-	         top_pad="5"
-	         width="130" />
 
-       </layout_panel>
-    </layout_stack>
+	<!-- BUTTON BAR -->
+	<panel
+	 background_visible="true"
+	 bevel_style="none"
+	 follows="bottom|left|right"
+	 height="27"
+	 layout="topleft"
+	 left="5"
+	 name="no_add_wearables_button_bar"
+	 top_pad="0"
+	 width="313">
+		<menu_button
+		 follows="bottom|left"
+		 height="25"
+		 image_hover_unselected="Toolbar_Left_Over"
+		 image_overlay="OptionsMenu_Off"
+		 image_selected="Toolbar_Left_Selected"
+		 image_unselected="Toolbar_Left_Off"
+		 layout="topleft"
+		 left="0"
+		 name="gear_menu_btn"
+		 top="1"
+		 width="31" />
+		<icon
+		 follows="bottom|left|right"
+		 height="25"
+		 image_name="Toolbar_Middle_Off"
+		 layout="topleft"
+		 left_pad="1"
+		 name="dummy_right_icon"
+		 width="250" />
+		<button
+		 follows="bottom|right"
+		 height="25"
+		 image_hover_unselected="Toolbar_Right_Over"
+		 image_overlay="Shop"
+		 image_selected="Toolbar_Right_Selected"
+		 image_unselected="Toolbar_Right_Off"
+		 layout="topleft"
+		 left_pad="1"
+		 name="shop_btn_1"
+		 top="1"
+		 tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it"
+		 width="31" />
+	</panel>
 
 
-    <!-- BUTTON BAR -->
-    <panel
-     background_visible="true"
-     bevel_style="none"
-     follows="bottom|left|right"
-     height="27"
-     layout="topleft"
-     left="5"
-     name="no_add_wearables_button_bar"
-     top_pad="0"
-     width="313">
-        <menu_button
-         follows="bottom|left"
-         height="25"
-         image_hover_unselected="Toolbar_Left_Over"
-         image_overlay="OptionsMenu_Off"
-         image_selected="Toolbar_Left_Selected"
-         image_unselected="Toolbar_Left_Off"
-         layout="topleft"
-         left="0"
-         name="gear_menu_btn"
-         top="1"
-         width="31" />
-        <icon
-         follows="bottom|left|right"
-         height="25"
-         image_name="Toolbar_Middle_Off"
-         layout="topleft"
-         left_pad="1"
-         name="dummy_right_icon"
-         width="250" />
-        <button
-         follows="bottom|right"
-         height="25"
-         image_hover_unselected="Toolbar_Right_Over"
-         image_overlay="Shop"
-         image_selected="Toolbar_Right_Selected"
-         image_unselected="Toolbar_Right_Off"
-         layout="topleft"
-         left_pad="1"
-         name="shop_btn_1"
-         top="1"
-         tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it"
-         width="31" />
-    </panel>
-    
-    
-    <!-- BUTTON BAR - WEARABLES ADDING MODE -->
-    <panel
-     background_visible="true"
-     bevel_style="none"
-     follows="left|right|bottom"
-     height="27"
-     layout="topleft"
-     left="5"
-     name="add_wearables_button_bar"
-     top_delta="0"
-     visible="false"
-     width="313">
-        <menu_button
-         follows="bottom|left"
-         height="25"
-         image_hover_unselected="Toolbar_Left_Over"
-         image_overlay="OptionsMenu_Off"
-         image_selected="Toolbar_Left_Selected"
-         image_unselected="Toolbar_Left_Off"
-         layout="topleft"
-         left="0"
-         name="wearables_gear_menu_btn"
-         top="1"
-         width="31" />
-        <button
-         follows="bottom|left"
-         height="25"
-         image_hover_unselected="Toolbar_Middle_Over"
-         image_overlay="Hierarchy_View_Disabled"
-         image_selected="Toolbar_Middle_Selected"
-         image_unselected="Toolbar_Middle_Off"
-         is_toggle="true"
-         layout="topleft"
-         left_pad="1"
-         name="folder_view_btn"
-         top="1"
-         width="31" />
-        <button
-         follows="bottom|left"
-         height="25"
-         image_hover_unselected="Toolbar_Middle_Over"
-         image_overlay="List_View_On"
-         image_selected="Toolbar_Middle_Selected"
-         image_unselected="Toolbar_Middle_Off"
-         is_toggle="true"
-         layout="topleft"
-         left_pad="1"
-         name="list_view_btn"
-         top="1"
-         width="31" />
-       <icon
-        follows="bottom|left|right"
-        height="25"
-         image_name="Toolbar_Middle_Off"
-        layout="topleft"
-        left_pad="1"
-         name="dummy_right_icon"
-         width="186" >
-       </icon>
-        <button
-         follows="bottom|right"
-         height="25"
-         image_hover_unselected="Toolbar_Right_Over"
-         image_overlay="Shop"
-         image_selected="Toolbar_Right_Selected"
-         image_unselected="Toolbar_Right_Off"
-         layout="topleft"
-         left_pad="1"
-         name="shop_btn_2"
-         top="1"
-         tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it"
-         width="31" />
-    </panel>
+	<!-- BUTTON BAR - WEARABLES ADDING MODE -->
+	<panel
+	 background_visible="true"
+	 bevel_style="none"
+	 follows="left|right|bottom"
+	 height="27"
+	 layout="topleft"
+	 left="5"
+	 name="add_wearables_button_bar"
+	 top_delta="0"
+	 visible="false"
+	 width="313">
+		<menu_button
+		 follows="bottom|left"
+		 height="25"
+		 image_hover_unselected="Toolbar_Left_Over"
+		 image_overlay="OptionsMenu_Off"
+		 image_selected="Toolbar_Left_Selected"
+		 image_unselected="Toolbar_Left_Off"
+		 layout="topleft"
+		 left="0"
+		 name="wearables_gear_menu_btn"
+		 top="1"
+		 width="31" />
+		<button
+		 follows="bottom|left"
+		 height="25"
+		 image_hover_unselected="Toolbar_Middle_Over"
+		 image_overlay="Hierarchy_View_Disabled"
+		 image_selected="Toolbar_Middle_Selected"
+		 image_unselected="Toolbar_Middle_Off"
+		 is_toggle="true"
+		 layout="topleft"
+		 left_pad="1"
+		 name="folder_view_btn"
+		 top="1"
+		 width="31" />
+		<button
+		 follows="bottom|left"
+		 height="25"
+		 image_hover_unselected="Toolbar_Middle_Over"
+		 image_overlay="List_View_On"
+		 image_selected="Toolbar_Middle_Selected"
+		 image_unselected="Toolbar_Middle_Off"
+		 is_toggle="true"
+		 layout="topleft"
+		 left_pad="1"
+		 name="list_view_btn"
+		 top="1"
+		 width="31" />
+		<icon
+		 follows="bottom|left|right"
+		 height="25"
+			image_name="Toolbar_Middle_Off"
+		 layout="topleft"
+		 left_pad="1"
+			name="dummy_right_icon"
+			width="186" >
+		</icon>
+		<button
+		 follows="bottom|right"
+		 height="25"
+		 image_hover_unselected="Toolbar_Right_Over"
+		 image_overlay="Shop"
+		 image_selected="Toolbar_Right_Selected"
+		 image_unselected="Toolbar_Right_Off"
+		 layout="topleft"
+		 left_pad="1"
+		 name="shop_btn_2"
+		 top="1"
+		 tool_tip="Visit the SL Marketplace. You can also select something you are wearing, then click here to see more things like it"
+		 width="31" />
+	</panel>
 
-    <!-- SAVE AND REVERT BUTTONS -->
-    <panel
-     follows="left|right|bottom"
-     height="30"
-     layout="topleft"
-     left="4"
-     top_pad="2"
-     name="save_revert_button_bar"
-     width="300">
-			<layout_stack
-     	         follows="bottom|left|right"
-		         height="23"
-		         layout="topleft"
-		         mouse_opaque="false"
-		         name="button_bar_ls"
-		         left="0"
-		         orientation="horizontal"
-		         top="0"
-		         width="313">	
-			    <layout_panel
-			         follows="bottom|left|right"
-			         height="23"
-                     layout="bottomleft"
-                     left="0"			
-                     mouse_opaque="false"
-                     name="save_btn_lp"
-                     auto_resize="true"
-                     width="156">
-        <button
+	<!-- SAVE AND REVERT BUTTONS -->
+	<panel
+	 follows="left|right|bottom"
+	 height="30"
+	 layout="topleft"
+	 left="4"
+	 top_pad="2"
+	 name="save_revert_button_bar"
+	 width="300">
+		<layout_stack
+						 follows="bottom|left|right"
+					 height="23"
+					 layout="topleft"
+					 mouse_opaque="false"
+					 name="button_bar_ls"
+					 left="0"
+					 orientation="horizontal"
+					 top="0"
+					 width="313">
+			<layout_panel
+					 follows="bottom|left|right"
+					 height="23"
+								 layout="bottomleft"
+								 left="0"
+								 mouse_opaque="false"
+								 name="save_btn_lp"
+								 auto_resize="true"
+								 width="156">
+				<button
                          follows="bottom|left|right"
          height="23"
          label="Save"
@@ -524,7 +515,7 @@ It is calculated as border_size + 2*UIResizeBarOverlap
          name="save_btn"
          top="0"
          width="155" />
-        <button
+				<button
                          follows="bottom|right"
          height="23"
          name="save_flyout_btn"
@@ -539,17 +530,17 @@ It is calculated as border_size + 2*UIResizeBarOverlap
          image_pressed_selected="SegmentedBtn_Right_Selected_Press"
          image_overlay="Arrow_Small_Up"
          width="20"/>
-			    </layout_panel>
-			    <layout_panel
-                     follows="bottom|left|right"
-                     height="23"
-                     layout="bottomleft"
-                     left_pad="3"			
-                     mouse_opaque="false"
-                     name="revert_btn_lp"
-                     auto_resize="true"
-                     width="147">
-        <button
+			</layout_panel>
+			<layout_panel
+								 follows="bottom|left|right"
+								 height="23"
+								 layout="bottomleft"
+								 left_pad="3"
+								 mouse_opaque="false"
+								 name="revert_btn_lp"
+								 auto_resize="true"
+								 width="147">
+				<button
          follows="bottom|left|right"
          height="23"
                          left="0"
@@ -559,7 +550,7 @@ It is calculated as border_size + 2*UIResizeBarOverlap
          top="0"
          tool_tip="Revert to last saved version"
          width="147" />
-			    </layout_panel>
-			</layout_stack>
-    </panel>
+			</layout_panel>
+		</layout_stack>
+	</panel>
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_people.xml b/indra/newview/skins/default/xui/en/panel_people.xml
index ed274d0233..31a2bbd1cb 100755
--- a/indra/newview/skins/default/xui/en/panel_people.xml
+++ b/indra/newview/skins/default/xui/en/panel_people.xml
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <!-- Side tray panel -->
 <panel
- default_tab_group="1"
  follows="all"
  height="449"
  label="People"
@@ -60,7 +59,6 @@ Looking for people to hang out with? Try the [secondlife:///app/worldmap World M
      layout="topleft"
      left="3"
      name="tabs"
-     tab_group="1"
      tab_min_width="70"
      tab_height="30"
      tab_position="top"
diff --git a/indra/newview/skins/default/xui/es/sidepanel_inventory.xml b/indra/newview/skins/default/xui/es/sidepanel_inventory.xml
index f68dcc65e3..9ce14c856f 100755
--- a/indra/newview/skins/default/xui/es/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/es/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Cosas" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/fr/sidepanel_inventory.xml b/indra/newview/skins/default/xui/fr/sidepanel_inventory.xml
index 1b9c832679..ec7dd8c095 100755
--- a/indra/newview/skins/default/xui/fr/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/fr/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Choses" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/it/sidepanel_inventory.xml b/indra/newview/skins/default/xui/it/sidepanel_inventory.xml
index 5ac0961bd7..907857bf5a 100755
--- a/indra/newview/skins/default/xui/it/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/it/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Cose" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/ja/sidepanel_inventory.xml b/indra/newview/skins/default/xui/ja/sidepanel_inventory.xml
index 51d6d48f90..32e84ce542 100755
--- a/indra/newview/skins/default/xui/ja/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/ja/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="もの" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/pl/sidepanel_inventory.xml b/indra/newview/skins/default/xui/pl/sidepanel_inventory.xml
index c2e50473a5..1034a06f1f 100755
--- a/indra/newview/skins/default/xui/pl/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/pl/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Rzeczy" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<panel name="button_panel">
 			<layout_stack name="button_panel_ls">
 				<layout_panel name="info_btn_lp">
diff --git a/indra/newview/skins/default/xui/pt/sidepanel_inventory.xml b/indra/newview/skins/default/xui/pt/sidepanel_inventory.xml
index 7908ea5f3a..c44345323f 100755
--- a/indra/newview/skins/default/xui/pt/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/pt/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Coisas" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/ru/sidepanel_inventory.xml b/indra/newview/skins/default/xui/ru/sidepanel_inventory.xml
index c106c2de79..1741f63074 100755
--- a/indra/newview/skins/default/xui/ru/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/ru/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Вещи" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/tr/sidepanel_inventory.xml b/indra/newview/skins/default/xui/tr/sidepanel_inventory.xml
index 938b5a76d8..3241d52c81 100755
--- a/indra/newview/skins/default/xui/tr/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/tr/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="Eşyalar" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
diff --git a/indra/newview/skins/default/xui/zh/sidepanel_inventory.xml b/indra/newview/skins/default/xui/zh/sidepanel_inventory.xml
index c8aae15011..4034a7154f 100755
--- a/indra/newview/skins/default/xui/zh/sidepanel_inventory.xml
+++ b/indra/newview/skins/default/xui/zh/sidepanel_inventory.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes"?>
 <panel label="事物" name="objects panel">
-	<panel label="" name="sidepanel__inventory_panel">
+	<panel label="" name="sidepanel_inventory_panel">
 		<layout_stack name="inventory_layout_stack">
 			<layout_panel name="inbox_layout_panel">
 				<panel label="" name="marketplace_inbox">
-- 
cgit v1.2.3


From 463a8930c8bddd8740478f6400561a48220ee584 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 6 Nov 2013 09:42:06 -0700
Subject: re-organize the code of processing the debug setting
 "ObjectProjectionAreaCutOff"

---
 indra/newview/app_settings/settings.xml |  2 +-
 indra/newview/llviewerregion.cpp        |  8 ++------
 indra/newview/llvocache.cpp             | 22 ++++++++++++++++------
 indra/newview/llvocache.h               |  1 +
 4 files changed, 20 insertions(+), 13 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 09d74a7f5e..c87da95d41 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7125,7 +7125,7 @@
       <real>0.75</real>
     </array>
   </map>
-  <key>ObjectProjectionAreaCutOFF</key>
+  <key>ObjectProjectionAreaCutOff</key>
   <map>
     <key>Comment</key>
     <string>Threshold in number of pixels of the projection area in screen of object bounding sphere. Objects smaller than this threshold are not rendered.</string>
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index fe420fe551..56e0142dd6 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1166,8 +1166,6 @@ void LLViewerRegion::updateVisibleEntries(F32 max_time)
 
 void LLViewerRegion::createVisibleObjects(F32 max_time)
 {
-	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
-
 	if(mDead)
 	{
 		return;
@@ -1179,10 +1177,8 @@ void LLViewerRegion::createVisibleObjects(F32 max_time)
 	}	
 
 	//object projected area threshold
-	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
-	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
-	projection_threshold *= projection_threshold;
-
+	F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold();
+	
 	S32 throttle = sNewObjectCreationThrottle;
 	BOOL has_new_obj = FALSE;
 	LLTimer update_timer;	
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index be7ff00c05..d0061fc777 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -358,6 +358,19 @@ void LLVOCacheEntry::updateDebugSettings()
 	sBackAngleTanSquared = squared_back_angle;
 }
 
+//static 
+F32 LLVOCacheEntry::getSquaredObjectScreenAreaThreshold()
+{
+	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOff");
+
+	//object projected area threshold
+	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
+	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
+	projection_threshold *= projection_threshold;
+
+	return projection_threshold;
+}
+
 bool LLVOCacheEntry::isAnyVisible(const LLVector4a& camera_origin, F32 squared_dist_threshold)
 {
 	LLOcclusionCullingGroup* group = (LLOcclusionCullingGroup*)getGroup();
@@ -752,8 +765,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad
 S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 {
 	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
-	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");
-	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
+	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");	
 	
 	if(!LLViewerRegion::sVOCacheCullingEnabled)
 	{
@@ -778,10 +790,8 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
 
 	//object projected area threshold
-	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
-	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
-	projection_threshold *= projection_threshold;
-
+	F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold();
+	
 	if(!mCullHistory && LLViewerRegion::isViewerCameraStatic())
 	{
 		U32 seed = llmax(mLODPeriod >> 1, (U32)4);
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index ae32fb0cee..09766b297e 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -125,6 +125,7 @@ public:
 	U32  getUpdateFlags() const    {return mUpdateFlags;}
 
 	static void updateDebugSettings();
+	static F32  getSquaredObjectScreenAreaThreshold();
 
 private:
 	void updateParentBoundingInfo(const LLVOCacheEntry* child);	
-- 
cgit v1.2.3


From 22beac78135e23ede5002f4125e2c3006bcad7f2 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 6 Nov 2013 10:02:58 -0700
Subject: increase the default value of "ObjectProjectionAreaCutOff" to be 16
 pixels.

---
 indra/newview/app_settings/settings.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c87da95d41..04be4e5f00 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7134,7 +7134,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>1.0</real>
+    <real>16.0</real>
   </map>
     <key>ParcelMediaAutoPlayEnable</key>
     <map>
-- 
cgit v1.2.3


From 2cb781705e56e31e11c4c37891b2ac86326aa411 Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Wed, 6 Nov 2013 10:18:06 -0700
Subject: remove some unused debug settings.

---
 indra/newview/app_settings/settings.xml | 23 -----------------------
 indra/newview/llvocache.cpp             | 13 -------------
 indra/newview/llvocache.h               |  3 ---
 3 files changed, 39 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 04be4e5f00..db7be5abc4 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -731,18 +731,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-
-    <key>BackDistanceFactor</key>
-    <map>
-      <key>Comment</key>
-      <string>Keep invisible objects in memory which are in the distance range (the factor * draw_distance) to the camera</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>F32</string>
-      <key>Value</key>
-      <real>0.125</real>
-    </map>
     <key>BackgroundYieldTime</key>
     <map>
       <key>Comment</key>
@@ -754,17 +742,6 @@
       <key>Value</key>
       <integer>40</integer>
     </map>
-    <key>BackProjectionAngleSquared</key>
-    <map>
-      <key>Comment</key>
-      <string>squared tan(object bbox projection angle). that of invisible objects greater than this threshold are kept in memory</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>F32</string>
-      <key>Value</key>
-      <real>0.0311</real>
-    </map>
     <key>BackShpereCullingRadius</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index d0061fc777..2ff2d0f341 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -35,8 +35,6 @@
 #include "pipeline.h"
 #include "llagentcamera.h"
 
-F32 LLVOCacheEntry::sBackDistanceSquared = 0.f;
-F32 LLVOCacheEntry::sBackAngleTanSquared = 0.f;
 U32 LLVOCacheEntry::sMinFrameRange = 0;
 BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE;
 
@@ -341,21 +339,10 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const
 //static 
 void LLVOCacheEntry::updateDebugSettings()
 {
-	//distance to keep objects = back_dist_factor * draw_distance
-	static LLCachedControl<F32> back_dist_factor(gSavedSettings,"BackDistanceFactor");
-
-	//squared tan(projection angle of the bbox), default is 10 (degree)
-	static LLCachedControl<F32> squared_back_angle(gSavedSettings,"BackProjectionAngleSquared");
-
 	//the number of frames invisible objects stay in memory
 	static LLCachedControl<U32> inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime");
 
 	sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum 
-
-	sBackDistanceSquared = back_dist_factor * gAgentCamera.mDrawDistance;
-	sBackDistanceSquared *= sBackDistanceSquared;
-
-	sBackAngleTanSquared = squared_back_angle;
 }
 
 //static 
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 09766b297e..af97f9fdce 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -153,9 +153,6 @@ protected:
 
 	BOOL                        mTouched; //if set, this entry is valid, otherwise it is invalid.
 
-	static F32                  sBackDistanceSquared;
-	static F32                  sBackAngleTanSquared;
-
 public:
 	static U32                  sMinFrameRange;
 };
-- 
cgit v1.2.3


From c4fc085f74392d8bd2746134e703edbbbc911012 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 6 Nov 2013 18:16:57 -0800
Subject: fixed some warnings

---
 indra/newview/llfacebookconnect.cpp     |  4 ++--
 indra/newview/llsnapshotlivepreview.cpp |  4 ++--
 indra/newview/llviewermenu.cpp          |  8 ++++----
 indra/newview/llviewermessage.cpp       |  2 +-
 indra/newview/llviewerwindow.cpp        | 18 +++++++++---------
 indra/newview/llvoavatar.cpp            |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llfacebookconnect.cpp b/indra/newview/llfacebookconnect.cpp
index 611d18d6d6..ac27ade2b4 100644
--- a/indra/newview/llfacebookconnect.cpp
+++ b/indra/newview/llfacebookconnect.cpp
@@ -275,7 +275,7 @@ public:
 	{
 		if (isGoodStatus(status))
 		{
-			llinfos << "Facebook: Info received" << llendl;
+			LL_INFOS() << "Facebook: Info received" << LL_ENDL;
 			LL_DEBUGS("FacebookConnect") << "Getting Facebook info successful. info: " << info << LL_ENDL;
 			LLFacebookConnect::instance().storeInfo(info);
 		}
@@ -453,7 +453,7 @@ void LLFacebookConnect::sharePhoto(LLPointer<LLImageFormatted> image, const std:
 	}
 	else
 	{
-		llwarns << "Image to upload is not a PNG or JPEG" << llendl;
+		LL_WARNS() << "Image to upload is not a PNG or JPEG" << LL_ENDL;
 		return;
 	}
 	
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index 791d9cf4e0..737f665954 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -827,7 +827,7 @@ void LLSnapshotLivePreview::saveTexture()
 	else
 	{
 		LLNotificationsUtil::add("ErrorEncodingSnapshot");
-		llwarns << "Error encoding snapshot" << LL_ENDL;
+		LL_WARNS() << "Error encoding snapshot" << LL_ENDL;
 	}
 
 	add(LLStatViewer::SNAPSHOT, 1);
@@ -853,7 +853,7 @@ void LLSnapshotLivePreview::saveWeb()
 	LLImageJPEG* jpg = dynamic_cast<LLImageJPEG*>(mFormattedImage.get());
 	if(!jpg)
 	{
-		llwarns << "Formatted image not a JPEG" << LL_ENDL;
+		LL_WARNS() << "Formatted image not a JPEG" << LL_ENDL;
 		return;
 	}
 
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index aeafbaa358..1c5c4e0cc7 100755
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -1954,9 +1954,9 @@ class LLAdvancedViewerEventRecorder : public view_listener_t
 		std::string command = userdata.asString();
 		if ("start playback" == command)
 		{
-			llinfos << "Event Playback starting" << llendl;
+			LL_INFOS() << "Event Playback starting" << LL_ENDL;
 			LLViewerEventRecorder::instance().playbackRecording();
-			llinfos << "Event Playback completed" << llendl;
+			LL_INFOS() << "Event Playback completed" << LL_ENDL;
 		}
 		else if ("stop playback" == command)
 		{
@@ -1965,12 +1965,12 @@ class LLAdvancedViewerEventRecorder : public view_listener_t
 		else if ("start recording" == command)
 		{
 			LLViewerEventRecorder::instance().setEventLoggingOn();
-			llinfos << "Event recording started" << llendl;
+			LL_INFOS() << "Event recording started" << LL_ENDL;
 		}
 		else if ("stop recording" == command)
 		{
 			LLViewerEventRecorder::instance().setEventLoggingOff();
-			llinfos << "Event recording stopped" << llendl;
+			LL_INFOS() << "Event recording stopped" << LL_ENDL;
 		} 
 
 		return true;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index cb2d0fa2ac..01e1137fb8 100755
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -6882,7 +6882,7 @@ bool teleport_request_callback(const LLSD& notification, const LLSD& response)
 	LLUUID from_id = notification["payload"]["from_id"].asUUID();
 	if(from_id.isNull())
 	{
-		llwarns << "from_id is NULL" << llendl;
+		LL_WARNS() << "from_id is NULL" << LL_ENDL;
 		return false;
 	}
 
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index e192c93d0a..7ab3a17587 100755
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -963,7 +963,7 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 			BOOL r = mouse_captor->handleAnyMouseClick(local_x, local_y, mask, clicktype, down); 
 			if (r) {
 
-				lldebugs << "LLViewerWindow::handleAnyMouseClick viewer with mousecaptor calling updatemouseeventinfo - local_x|global x  "<< local_x << " " << x  << "local/global y " << local_y << " " << y << llendl;
+				LL_DEBUGS() << "LLViewerWindow::handleAnyMouseClick viewer with mousecaptor calling updatemouseeventinfo - local_x|global x  "<< local_x << " " << x  << "local/global y " << local_y << " " << y << LL_ENDL;
 
 				LLViewerEventRecorder::instance().setMouseGlobalCoords(x,y);
 				LLViewerEventRecorder::instance().logMouseEvent(std::string(buttonstatestr),std::string(buttonname)); 
@@ -983,7 +983,7 @@ BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window,  LLCoordGL pos, MASK
 		if (r) 
 		{
 
-			lldebugs << "LLViewerWindow::handleAnyMouseClick calling updatemouseeventinfo - global x  "<< " " << x	<< "global y " << y	 << "buttonstate: " << buttonstatestr << " buttonname " << buttonname << llendl;
+			LL_DEBUGS() << "LLViewerWindow::handleAnyMouseClick calling updatemouseeventinfo - global x  "<< " " << x	<< "global y " << y	 << "buttonstate: " << buttonstatestr << " buttonname " << buttonname << LL_ENDL;
 
 			LLViewerEventRecorder::instance().setMouseGlobalCoords(x,y);
 
@@ -2531,7 +2531,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 		||(gLoginMenuBarView && gLoginMenuBarView->handleKey(key, mask, TRUE))
 		||(gMenuHolder && gMenuHolder->handleKey(key, mask, TRUE)))
 	{
-		lldebugs << "LLviewerWindow::handleKey handle nav keys for nav" << llendl;
+		LL_DEBUGS() << "LLviewerWindow::handleKey handle nav keys for nav" << LL_ENDL;
 		LLViewerEventRecorder::instance().logKeyEvent(key,mask);
 		return TRUE;
 	}
@@ -2564,7 +2564,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 	// if nothing has focus, go to first or last UI element as appropriate
 	if (key == KEY_TAB && (mask & MASK_CONTROL || gFocusMgr.getKeyboardFocus() == NULL))
 	{
-		llwarns << "LLviewerWindow::handleKey give floaters first chance at tab key " << llendl;
+		LL_WARNS() << "LLviewerWindow::handleKey give floaters first chance at tab key " << LL_ENDL;
 		if (gMenuHolder) gMenuHolder->hideMenus();
 
 		// if CTRL-tabbing (and not just TAB with no focus), go into window cycle mode
@@ -2626,17 +2626,17 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 		if (keyboard_focus->handleKey(key, mask, FALSE))
 		{
 
-			lldebugs << "LLviewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey an it returned true" << llendl;
+			LL_DEBUGS() << "LLviewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey an it returned true" << LL_ENDL;
 			LLViewerEventRecorder::instance().logKeyEvent(key,mask); 
 			return TRUE;
 		} else {
-			lldebugs << "LLviewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey an it returned FALSE" << llendl;
+			LL_DEBUGS() << "LLviewerWindow::handleKey - in 'traverse up' - no loops seen... just called keyboard_focus->handleKey an it returned FALSE" << LL_ENDL;
 		}
 	}
 
 	if( LLToolMgr::getInstance()->getCurrentTool()->handleKey(key, mask) )
 	{
-		lldebugs << "LLviewerWindow::handleKey toolbar handling?" << llendl;
+		LL_DEBUGS() << "LLviewerWindow::handleKey toolbar handling?" << LL_ENDL;
 		LLViewerEventRecorder::instance().logKeyEvent(key,mask);
 		return TRUE;
 	}
@@ -2644,7 +2644,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 	// Try for a new-format gesture
 	if (LLGestureMgr::instance().triggerGesture(key, mask))
 	{
-		lldebugs << "LLviewerWindow::handleKey new gesture feature" << llendl;
+		LL_DEBUGS() << "LLviewerWindow::handleKey new gesture feature" << LL_ENDL;
 		LLViewerEventRecorder::instance().logKeyEvent(key,mask);
 		return TRUE;
 	}
@@ -2653,7 +2653,7 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask)
 	// don't pass it down to the menus.
 	if (gGestureList.trigger(key, mask))
 	{
-		lldebugs << "LLviewerWindow::handleKey check gesture trigger" << llendl;
+		LL_DEBUGS() << "LLviewerWindow::handleKey check gesture trigger" << LL_ENDL;
 		LLViewerEventRecorder::instance().logKeyEvent(key,mask);
 		return TRUE;
 	}
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 8bd220c752..7ca8a4ed3a 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -8042,7 +8042,7 @@ LLColor4 LLVOAvatar::calcMutedAVColor(F32 value, S32 range_low, S32 range_high)
 	//LL_INFOS() << "From value " << std::setprecision(3) << value << " returning color " << new_color 
 	//	<< " using indexes " << spectrum_index_1 << ", " << spectrum_index_2
 	//	<< " and fractBetween " << fractBetween
-	//	<< llendl;
+	//	<< LL_ENDL;
 
 	return new_color;
 }
-- 
cgit v1.2.3


From d71cafa4bcecb311bce626a15dd185e4750994ea Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Wed, 6 Nov 2013 20:05:28 -0800
Subject: final settings tweaks renamed BackShpereCullingRadius to
 BackSphereCullingRadius

---
 indra/newview/app_settings/settings.xml | 10 +++++-----
 indra/newview/llviewerregion.cpp        |  2 +-
 indra/newview/llvocache.cpp             |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 7b30bbebab..14384edc1f 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -742,7 +742,7 @@
       <key>Value</key>
       <integer>40</integer>
     </map>
-    <key>BackShpereCullingRadius</key>
+    <key>BackSphereCullingRadius</key>
     <map>
       <key>Comment</key>
       <string>Radius of back sphere in meters, objects behind camera but within this radius are loaded for rendering</string>
@@ -751,7 +751,7 @@
       <key>Type</key>
       <string>F32</string>
       <key>Value</key>
-      <real>20.0</real>
+      <real>100.0</real>
     </map>
     <key>BottomPanelNew</key>
     <map>
@@ -6456,7 +6456,7 @@
       <key>Type</key>
       <string>S32</string>
       <key>Value</key>
-      <integer>64</integer>
+      <integer>200</integer>
     </map>
     <key>NewObjectCreationThrottleDelayTime</key>
     <map>
@@ -6577,7 +6577,7 @@
       <key>Type</key>
       <string>U32</string>
       <key>Value</key>
-      <integer>64</integer>
+			<integer>300</integer>
     </map>
     <key>NoPreload</key>
     <map>
@@ -7121,7 +7121,7 @@
     <key>Type</key>
     <string>F32</string>
     <key>Value</key>
-    <real>16.0</real>
+    <real>100.0</real>
   </map>
     <key>ParcelMediaAutoPlayEnable</key>
     <map>
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 6ba620964b..8093ce523f 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1379,7 +1379,7 @@ BOOL LLViewerRegion::isViewerCameraStatic()
 
 void LLViewerRegion::killInvisibleObjects(F32 max_time)
 {
-	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");
+	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackSphereCullingRadius");
 
 	if(!sVOCacheCullingEnabled)
 	{
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 2ff2d0f341..f2c048cd34 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -752,7 +752,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad
 S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 {
 	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
-	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackShpereCullingRadius");	
+	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackSphereCullingRadius");	
 	
 	if(!LLViewerRegion::sVOCacheCullingEnabled)
 	{
-- 
cgit v1.2.3


From 83c2098fb99c4a4d33dfa5f4a71ab64ca39b547f Mon Sep 17 00:00:00 2001
From: Xiaohong Bao <bao@lindenlab.com>
Date: Mon, 11 Nov 2013 14:50:32 -0700
Subject: fix for SH-4607: Create new object cache tuning parameters

---
 indra/newview/app_settings/settings.xml | 66 +++++++++++++++++---------
 indra/newview/llvieweroctree.cpp        | 11 ++---
 indra/newview/llvieweroctree.h          |  2 +-
 indra/newview/llviewerregion.cpp        | 26 +++++-----
 indra/newview/llvocache.cpp             | 84 ++++++++++++++++++++++++---------
 indra/newview/llvocache.h               | 13 +++--
 6 files changed, 134 insertions(+), 68 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 14384edc1f..adcea5103e 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -742,17 +742,6 @@
       <key>Value</key>
       <integer>40</integer>
     </map>
-    <key>BackSphereCullingRadius</key>
-    <map>
-      <key>Comment</key>
-      <string>Radius of back sphere in meters, objects behind camera but within this radius are loaded for rendering</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>F32</string>
-      <key>Value</key>
-      <real>100.0</real>
-    </map>
     <key>BottomPanelNew</key>
     <map>
       <key>Comment</key>
@@ -7111,17 +7100,6 @@
       <real>0.0</real>
       <real>0.75</real>
     </array>
-  </map>
-  <key>ObjectProjectionAreaCutOff</key>
-  <map>
-    <key>Comment</key>
-    <string>Threshold in number of pixels of the projection area in screen of object bounding sphere. Objects smaller than this threshold are not rendered.</string>
-    <key>Persist</key>
-    <integer>1</integer>
-    <key>Type</key>
-    <string>F32</string>
-    <key>Value</key>
-    <real>100.0</real>
   </map>
     <key>ParcelMediaAutoPlayEnable</key>
     <map>
@@ -10231,6 +10209,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>SceneLoadFrontPixelThreshold</key>
+    <map>
+      <key>Comment</key>
+      <string>in pixels, all objects in view frustum whose screen area is greater than this threshold will be loaded</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>100.0</real>
+    </map>
     <key>SceneLoadingMonitorEnabled</key>
     <map>
       <key>Comment</key>
@@ -10264,6 +10253,39 @@
       <key>Value</key>
       <real>0.02</real>
     </map>
+    <key>SceneLoadMinRadius</key>
+    <map>
+      <key>Comment</key>
+      <string>in meters, all objects (visible or invisible) within this radius will remain loaded in memory</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>16.0</real>
+    </map>
+  <key>SceneLoadRearMaxRadiusFraction</key>
+  <map>
+    <key>Comment</key>
+    <string>a percentage of draw distance beyond which all objects outside of view frustum will be unloaded, regardless of pixel threshold</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>20.0</real>
+  </map>
+    <key>SceneLoadRearPixelThreshold</key>
+    <map>
+      <key>Comment</key>
+      <string>in pixels, all objects out of view frustum whose screen area is greater than this threshold will remain loaded</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>200.0</real>
+    </map>
     <key>ScriptHelpFollowsCursor</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index 1b3d7da90d..06ff68c6c3 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -1429,7 +1429,7 @@ S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLViewerOct
 }
 //------------------------------------------
 //check if the objects projection large enough
-bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 projection_cutoff)
+bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 pixel_threshold, F32 near_squared_radius)
 {	
 	LLVector3 local_orig = mCamera->getOrigin() - shift;
 	LLVector4a origin;
@@ -1438,14 +1438,13 @@ bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLV
 	LLVector4a lookAt;
 	lookAt.setSub(center, origin);
 	F32 squared_dist = lookAt.dot3(lookAt).getF32();
-	F32 squared_rad = size.dot3(size).getF32();
-
-	if(squared_dist > 0.f)
+	if(squared_dist < near_squared_radius)
 	{
-		return squared_rad / squared_dist > projection_cutoff;
+		return true; //always load closeby objects
 	}
 
-	return true;
+	F32 squared_rad = size.dot3(size).getF32();
+	return squared_rad / squared_dist > pixel_threshold;
 }
 
 //virtual 
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index b03047cbbe..20eb18278f 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -393,7 +393,7 @@ protected:
 	virtual S32 frustumCheck(const LLViewerOctreeGroup* group) = 0;
 	virtual S32 frustumCheckObjects(const LLViewerOctreeGroup* group) = 0;
 
-	bool checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 projection_cutoff);
+	bool checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 pixel_threshold, F32 near_squared_radius);
 	virtual bool checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group);
 	virtual void preprocess(LLViewerOctreeGroup* group);
 	virtual void processGroup(LLViewerOctreeGroup* group);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 8093ce523f..afc00764b8 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1064,7 +1064,7 @@ void LLViewerRegion::updateVisibleEntries(F32 max_time)
 		return;
 	}
 
-	const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object.
+	const F32 LARGE_SCENE_CONTRIBUTION = 1000.f; //a large number to force to load the object.
 	const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin();
 	const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame();
 	bool needs_update = ((cur_frame - mImpl->mLastCameraUpdate) > 5) && ((camera_origin - mImpl->mLastCameraOrigin).lengthSquared() > 10.f);	
@@ -1126,7 +1126,11 @@ void LLViewerRegion::updateVisibleEntries(F32 max_time)
 		}
 	}
 
+	//
 	//process visible groups
+	//
+	//object projected area threshold
+	F32 projection_threshold = LLVOCacheEntry::getSquaredPixelThreshold(mImpl->mVOCachePartition->isFrontCull());
 	std::set< LLPointer<LLViewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
 	for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
 	{
@@ -1149,8 +1153,11 @@ void LLViewerRegion::updateVisibleEntries(F32 max_time)
 					continue;
 				}
 
-				vo_entry->calcSceneContribution(local_origin, needs_update, last_update);				
-				mImpl->mWaitingList.insert(vo_entry);			
+				vo_entry->calcSceneContribution(local_origin, needs_update, last_update);
+				if(vo_entry->getSceneContribution() > projection_threshold)
+				{
+					mImpl->mWaitingList.insert(vo_entry);			
+				}
 			}
 		}
 	}
@@ -1175,9 +1182,6 @@ void LLViewerRegion::createVisibleObjects(F32 max_time)
 		mImpl->mVOCachePartition->setCullHistory(FALSE);
 		return;
 	}	
-
-	//object projected area threshold
-	F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold();
 	
 	S32 throttle = sNewObjectCreationThrottle;
 	BOOL has_new_obj = FALSE;
@@ -1187,11 +1191,6 @@ void LLViewerRegion::createVisibleObjects(F32 max_time)
 	{
 		LLVOCacheEntry* vo_entry = *iter;		
 
-		if(vo_entry->getSceneContribution() < projection_threshold)
-		{
-			break;
-		}
-
 		if(vo_entry->getState() < LLVOCacheEntry::WAITING)
 		{
 			addNewObject(vo_entry);
@@ -1379,8 +1378,6 @@ BOOL LLViewerRegion::isViewerCameraStatic()
 
 void LLViewerRegion::killInvisibleObjects(F32 max_time)
 {
-	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackSphereCullingRadius");
-
 	if(!sVOCacheCullingEnabled)
 	{
 		return;
@@ -1393,7 +1390,8 @@ void LLViewerRegion::killInvisibleObjects(F32 max_time)
 	LLTimer update_timer;
 	LLVector4a camera_origin;
 	camera_origin.load3(LLViewerCamera::getInstance()->getOrigin().mV);
-	F32 squared_back_threshold = back_sphere_radius * back_sphere_radius;
+	F32 squared_back_threshold = LLVOCacheEntry::sRearFarRadius;
+	squared_back_threshold *= squared_back_threshold;
 
 	bool unstable = sNewObjectCreationThrottle < 0;
 	size_t max_update = unstable ? mImpl->mActiveSet.size() : 64; 
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index f2c048cd34..3bacf5c319 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -35,7 +35,12 @@
 #include "pipeline.h"
 #include "llagentcamera.h"
 
+//static variables
 U32 LLVOCacheEntry::sMinFrameRange = 0;
+F32 LLVOCacheEntry::sNearRadiusSquared = 1.0f;
+F32 LLVOCacheEntry::sRearFarRadius = 1.0f;
+F32 LLVOCacheEntry::sFrontPixelThreshold = 1.0f;
+F32 LLVOCacheEntry::sRearPixelThreshold = 1.0f;
 BOOL LLVOCachePartition::sNeedsOcclusionCheck = FALSE;
 
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
@@ -341,18 +346,46 @@ void LLVOCacheEntry::updateDebugSettings()
 {
 	//the number of frames invisible objects stay in memory
 	static LLCachedControl<U32> inv_obj_time(gSavedSettings,"NonvisibleObjectsInMemoryTime");
-
 	sMinFrameRange = inv_obj_time - 1; //make 0 to be the maximum 
+
+	//min radius: all objects within this radius remain loaded in memory
+	static LLCachedControl<F32> min_radius(gSavedSettings,"SceneLoadMinRadius");
+	sNearRadiusSquared = llmin((F32)min_radius, gAgentCamera.mDrawDistance); //can not exceed the draw distance
+	sNearRadiusSquared *= sNearRadiusSquared;
+	sNearRadiusSquared = llmax(sNearRadiusSquared, 1.f); //minimum value is 1.0m
+
+	//objects within the view frustum whose visible area is greater than this threshold will be loaded
+	static LLCachedControl<F32> front_pixel_threshold(gSavedSettings,"SceneLoadFrontPixelThreshold");
+	sFrontPixelThreshold = front_pixel_threshold;
+
+	//objects out of the view frustum whose visible area is greater than this threshold will remain loaded
+	static LLCachedControl<F32> rear_pixel_threshold(gSavedSettings,"SceneLoadRearPixelThreshold");
+	sRearPixelThreshold = rear_pixel_threshold;
+	sRearPixelThreshold = llmax(sRearPixelThreshold, sFrontPixelThreshold); //can not be smaller than sFrontPixelThreshold.
+
+	// a percentage of draw distance beyond which all objects outside of view frustum will be unloaded, regardless of pixel threshold
+	static LLCachedControl<F32> rear_max_radius_frac(gSavedSettings,"SceneLoadRearMaxRadiusFraction");
+	sRearFarRadius = llmax(rear_max_radius_frac * gAgentCamera.mDrawDistance / 100.f, 1.0f); //minimum value is 1.0m
+	sRearFarRadius = llmax(sRearFarRadius, (F32)min_radius); //can not be less than "SceneLoadMinRadius".
+	sRearFarRadius = llmin(sRearFarRadius, gAgentCamera.mDrawDistance); //can not be more than the draw distance.
 }
 
 //static 
-F32 LLVOCacheEntry::getSquaredObjectScreenAreaThreshold()
+F32 LLVOCacheEntry::getSquaredPixelThreshold(bool is_front)
 {
-	static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOff");
+	F32 threshold;
+	if(is_front)
+	{
+		threshold = sFrontPixelThreshold;
+	}
+	else
+	{
+		threshold = sRearPixelThreshold;
+	}
 
 	//object projected area threshold
 	F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
-	F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
+	F32 projection_threshold = pixel_meter_ratio > 0.f ? threshold / pixel_meter_ratio : 0.f;
 	projection_threshold *= projection_threshold;
 
 	return projection_threshold;
@@ -402,7 +435,13 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector4a& camera_origin, bool
 	lookAt.setSub(getPositionGroup(), camera_origin);
 	F32 squared_dist = lookAt.dot3(lookAt).getF32();
 
-	if(squared_dist > 0.f)
+	if(squared_dist < sNearRadiusSquared)
+	{
+		//nearby objects, set a large number
+		const F32 LARGE_SCENE_CONTRIBUTION = 1000.f; //a large number to force to load the object.
+		mSceneContrib = LARGE_SCENE_CONTRIBUTION;
+	}
+	else
 	{
 		F32 rad = getBinRadius();
 		mSceneContrib = rad * rad / squared_dist;
@@ -554,14 +593,15 @@ class LLVOCacheOctreeCull : public LLViewerOctreeCull
 {
 public:
 	LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, 
-		const LLVector3& shift, bool use_object_cache_occlusion, F32 projection_area_cutoff, LLVOCachePartition* part) 
+		const LLVector3& shift, bool use_object_cache_occlusion, F32 pixel_threshold, LLVOCachePartition* part) 
 		: LLViewerOctreeCull(camera), 
 		  mRegionp(regionp),
 		  mPartition(part),
-		  mProjectionAreaCutOff(projection_area_cutoff)
+		  mPixelThreshold(pixel_threshold)
 	{
 		mLocalShift = shift;
 		mUseObjectCacheOcclusion = use_object_cache_occlusion;
+		mSquaredNearRadius = LLVOCacheEntry::sNearRadiusSquared;
 	}
 
 	virtual bool earlyFail(LLViewerOctreeGroup* base_group)
@@ -617,7 +657,7 @@ public:
 		{
 			//check if the objects projection large enough
 			const LLVector4a* exts = group->getObjectExtents();
-			res = checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff);
+			res = checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mSquaredNearRadius);
 		}
 
 		return res;
@@ -663,7 +703,8 @@ private:
 	LLVOCachePartition* mPartition;
 	LLViewerRegion*     mRegionp;
 	LLVector3           mLocalShift; //shift vector from agent space to local region space.
-	F32                 mProjectionAreaCutOff;
+	F32                 mPixelThreshold;
+	F32                 mSquaredNearRadius;
 	bool                mUseObjectCacheOcclusion;
 };
 
@@ -671,11 +712,11 @@ private:
 class LLVOCacheOctreeBackCull : public LLViewerOctreeCull
 {
 public:
-	LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 back_sphere_radius, F32 projection_area_cutoff) 
-		: LLViewerOctreeCull(camera), mRegionp(regionp), mProjectionAreaCutOff(projection_area_cutoff)
+	LLVOCacheOctreeBackCull(LLCamera* camera, const LLVector3& shift, LLViewerRegion* regionp, F32 pixel_threshold) 
+		: LLViewerOctreeCull(camera), mRegionp(regionp), mPixelThreshold(pixel_threshold)
 	{
 		mLocalShift = shift;
-		mSphereRadius = back_sphere_radius;
+		mSphereRadius = LLVOCacheEntry::sRearFarRadius;
 	}
 
 	virtual S32 frustumCheck(const LLViewerOctreeGroup* group)
@@ -691,7 +732,7 @@ public:
 		{
 			//check if the objects projection large enough
 			const LLVector4a* exts = group->getObjectExtents();
-			return checkProjectionArea(exts[0], exts[1], mLocalShift, mProjectionAreaCutOff);
+			return checkProjectionArea(exts[0], exts[1], mLocalShift, mPixelThreshold, mSphereRadius * mSphereRadius);
 		}
 		return false;
 	}
@@ -713,10 +754,10 @@ private:
 	F32              mSphereRadius;
 	LLViewerRegion*  mRegionp;
 	LLVector3        mLocalShift; //shift vector from agent space to local region space.
-	F32              mProjectionAreaCutOff;
+	F32              mPixelThreshold;
 };
 
-void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff)
+void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 pixel_threshold)
 {
 	if(LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD)
 	{
@@ -737,7 +778,7 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad
 	//localize the camera
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	
-	LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, back_sphere_radius, projection_area_cutoff);
+	LLVOCacheOctreeBackCull culler(&camera, region_agent, mRegionp, pixel_threshold);
 	culler.traverse(mOctree);
 
 	mBackSlectionEnabled--;
@@ -752,7 +793,6 @@ void LLVOCachePartition::selectBackObjects(LLCamera &camera, F32 back_sphere_rad
 S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 {
 	static LLCachedControl<bool> use_object_cache_occlusion(gSavedSettings,"UseObjectCacheOcclusion");
-	static LLCachedControl<F32> back_sphere_radius(gSavedSettings,"BackSphereCullingRadius");	
 	
 	if(!LLViewerRegion::sVOCacheCullingEnabled)
 	{
@@ -776,9 +816,6 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	}
 	mCulledTime[LLViewerCamera::sCurCameraID] = LLViewerOctreeEntryData::getCurrentFrame();
 
-	//object projected area threshold
-	F32 projection_threshold = LLVOCacheEntry::getSquaredObjectScreenAreaThreshold();
-	
 	if(!mCullHistory && LLViewerRegion::isViewerCameraStatic())
 	{
 		U32 seed = llmax(mLODPeriod >> 1, (U32)4);
@@ -791,7 +828,8 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 		}
 		if(LLViewerOctreeEntryData::getCurrentFrame() % seed != mIdleHash)
 		{
-			selectBackObjects(camera, back_sphere_radius, projection_threshold);//process back objects selection
+			mFrontCull = FALSE;
+			selectBackObjects(camera, LLVOCacheEntry::getSquaredPixelThreshold(mFrontCull));//process back objects selection
 			return 0; //nothing changed, reduce frequency of culling
 		}
 	}
@@ -804,7 +842,9 @@ S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion)
 	LLVector3 region_agent = mRegionp->getOriginAgent();
 	camera.calcRegionFrustumPlanes(region_agent);
 
-	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, projection_threshold, this);
+	mFrontCull = TRUE;
+	LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent, do_occlusion && use_object_cache_occlusion, 
+		LLVOCacheEntry::getSquaredPixelThreshold(mFrontCull), this);
 	culler.traverse(mOctree);	
 
 	if(!sNeedsOcclusionCheck)
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index af97f9fdce..9d851288b4 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -125,7 +125,7 @@ public:
 	U32  getUpdateFlags() const    {return mUpdateFlags;}
 
 	static void updateDebugSettings();
-	static F32  getSquaredObjectScreenAreaThreshold();
+	static F32  getSquaredPixelThreshold(bool is_front);
 
 private:
 	void updateParentBoundingInfo(const LLVOCacheEntry* child);	
@@ -154,7 +154,11 @@ protected:
 	BOOL                        mTouched; //if set, this entry is valid, otherwise it is invalid.
 
 public:
-	static U32                  sMinFrameRange;
+	static U32  sMinFrameRange;
+	static F32  sNearRadiusSquared;
+	static F32  sRearFarRadius;
+	static F32  sFrontPixelThreshold;
+	static F32  sRearPixelThreshold;
 };
 
 class LLVOCacheGroup : public LLOcclusionCullingGroup
@@ -184,13 +188,16 @@ public:
 
 	void setCullHistory(BOOL has_new_object);
 
+	bool isFrontCull() const {return mFrontCull;}
+
 private:
-	void selectBackObjects(LLCamera &camera, F32 back_sphere_radius, F32 projection_area_cutoff); //select objects behind camera.
+	void selectBackObjects(LLCamera &camera, F32 projection_area_cutoff); //select objects behind camera.
 
 public:
 	static BOOL sNeedsOcclusionCheck;
 
 private:
+	BOOL  mFrontCull; //the view frustum cull if set, otherwise is back sphere cull.
 	U32   mCullHistory;
 	U32   mCulledTime[LLViewerCamera::NUM_CAMERAS];
 	std::set<LLVOCacheGroup*> mOccludedGroups;
-- 
cgit v1.2.3