From dfa71e2bb59e81de93f626fada6975ae46b01bb6 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 31 May 2022 11:57:15 -0500
Subject: [PATCH] SL-17490 Only update a subset of textures each frame and
 remove dead debug code.

---
 indra/newview/CMakeLists.txt                  |    2 -
 indra/newview/app_settings/settings.xml       |  103 +-
 indra/newview/llappviewer.cpp                 |   19 +-
 .../newview/llfloatertexturefetchdebugger.cpp |  480 --------
 indra/newview/llfloatertexturefetchdebugger.h |   77 --
 indra/newview/lltexturefetch.cpp              | 1005 +----------------
 indra/newview/lltexturefetch.h                |  219 ----
 indra/newview/llviewerfloaterreg.cpp          |    5 -
 indra/newview/llviewermenu.cpp                |   10 -
 indra/newview/llviewerstats.cpp               |   15 -
 indra/newview/llviewerstats.h                 |    1 -
 indra/newview/llviewertexture.cpp             |   13 -
 indra/newview/llviewertexture.h               |    1 -
 indra/newview/llviewertexturelist.cpp         |  171 +--
 indra/newview/llviewertexturelist.h           |    5 -
 indra/newview/llviewerwindow.cpp              |   12 -
 .../xui/en/floater_texture_fetch_debugger.xml |  440 --------
 .../skins/default/xui/en/menu_viewer.xml      |   14 -
 18 files changed, 25 insertions(+), 2567 deletions(-)
 delete mode 100644 indra/newview/llfloatertexturefetchdebugger.cpp
 delete mode 100644 indra/newview/llfloatertexturefetchdebugger.h
 delete mode 100644 indra/newview/skins/default/xui/en/floater_texture_fetch_debugger.xml

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 964615320db..c253eca94e9 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -319,7 +319,6 @@ set(viewer_SOURCE_FILES
     llfloatertelehub.cpp
     llfloatertestinspectors.cpp
     llfloatertestlistview.cpp
-    llfloatertexturefetchdebugger.cpp
     llfloatertools.cpp
     llfloatertopobjects.cpp
     llfloatertos.cpp
@@ -958,7 +957,6 @@ set(viewer_HEADER_FILES
     llfloatertelehub.h
     llfloatertestinspectors.h
     llfloatertestlistview.h
-    llfloatertexturefetchdebugger.h
     llfloatertools.h
     llfloatertopobjects.h
     llfloatertos.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index c41118d6a7d..64269641909 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -12436,17 +12436,6 @@
       <key>Value</key>
       <real>20.0</real>
     </map>
-    <key>TexelPixelRatio</key>
-    <map>
-      <key>Comment</key>
-      <string>texel pixel ratio = texel / pixel</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>F32</string>
-      <key>Value</key>
-      <real>2.0</real>
-    </map>
     <key>TextureCameraMotionThreshold</key>
     <map>
       <key>Comment</key>
@@ -12546,17 +12535,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>TextureFetchDebuggerEnabled</key>
-    <map>
-      <key>Comment</key>
-      <string>Enable the texture fetching debugger if set</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
     <key>TextureFetchMinTimeToLog</key>
     <map>
       <key>Comment</key>
@@ -12579,76 +12557,10 @@
     <key>Value</key>
     <real>0.0</real>
   </map>
-    <key>TextureFetchSource</key>
-    <map>
-      <key>Comment</key>
-      <string>Debug use: Source to fetch textures</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
-    <key>TextureFetchUpdateHighPriority</key>
-    <map>
-      <key>Comment</key>
-      <string>Number of high priority textures to update per frame</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>32</integer>
-    </map>
-    <key>TextureFetchUpdateMaxMediumPriority</key>
-    <map>
-      <key>Comment</key>
-      <string>Maximum number of medium priority textures to update per frame</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>256</integer>
-    </map>
-    <key>TextureFetchUpdateMinMediumPriority</key>
-    <map>
-      <key>Comment</key>
-      <string>Minimum number of medium priority textures to update per frame</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>S32</string>
-      <key>Value</key>
-      <integer>32</integer>
-    </map>
-    <key>TextureFetchUpdatePriorityThreshold</key>
-    <map>
-      <key>Comment</key>
-      <string>Threshold under which textures will be considered too low priority and skipped for update</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>F32</string>
-      <key>Value</key>
-      <real>0.0</real>
-    </map>
-    <key>TextureFetchUpdateSkipLowPriority</key>
-    <map>
-      <key>Comment</key>
-      <string>Flag indicating if we want to skip textures with too low of a priority</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Boolean</string>
-      <key>Value</key>
-      <integer>0</integer>
-    </map>
-    <key>TextureFetchUpdatePriorities</key>
+    <key>TextureFetchUpdateMinCount</key>
     <map>
       <key>Comment</key>
-      <string>Number of priority texture to update per frame</string>
+      <string>Minimum number of textures to update per frame</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -12656,17 +12568,6 @@
       <key>Value</key>
       <integer>32</integer>
     </map>
-    <key>TextureListFetchingThreshold</key>
-    <map>
-      <key>Comment</key>
-      <string>If the ratio between fetched and all textures in the list is greater than this threshold, which we assume that almost all textures are fetched</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>F32</string>
-      <key>Value</key>
-      <real>0.97</real>
-    </map>
     <key>TextureLoadFullRes</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index e9bf6bf4e51..a172308d2aa 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -103,7 +103,6 @@
 #include "lldiskcache.h"
 #include "llvopartgroup.h"
 #include "llweb.h"
-#include "llfloatertexturefetchdebugger.h"
 #include "llspellcheck.h"
 #include "llscenemonitor.h"
 #include "llavatarrenderinfoaccountant.h"
@@ -1627,21 +1626,9 @@ bool LLAppViewer::doFrame()
 				LLLFSThread::sLocal->pause();
 			}
 
-			//texture fetching debugger
-			if(LLTextureFetchDebugger::isEnabled())
-			{
-				LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df tex_fetch_debugger_instance" )
-				LLFloaterTextureFetchDebugger* tex_fetch_debugger_instance =
-					LLFloaterReg::findTypedInstance<LLFloaterTextureFetchDebugger>("tex_fetch_debugger");
-				if(tex_fetch_debugger_instance)
-				{
-					tex_fetch_debugger_instance->idle() ;
-				}
-			}
-
 			{
 				LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df resumeMainloopTimeout" )
-			resumeMainloopTimeout();
+			    resumeMainloopTimeout();
 			}
 			pingMainloopTimeout("Main:End");
 		}
@@ -4679,10 +4666,6 @@ void LLAppViewer::idle()
 	//
 	// Special case idle if still starting up
 	//
-	if (LLStartUp::getStartupState() >= STATE_WORLD_INIT)
-	{
-		update_texture_time();
-	}
 	if (LLStartUp::getStartupState() < STATE_STARTED)
 	{
 		// Skip rest if idle startup returns false (essentially, no world yet)
diff --git a/indra/newview/llfloatertexturefetchdebugger.cpp b/indra/newview/llfloatertexturefetchdebugger.cpp
deleted file mode 100644
index cda4dc8bccb..00000000000
--- a/indra/newview/llfloatertexturefetchdebugger.cpp
+++ /dev/null
@@ -1,480 +0,0 @@
-/** 
- * @file llfloatertexturefetchdebugger.cpp
- * @brief LLFloaterTextureFetchDebugger class definition
- *
- * $LicenseInfo:firstyear=2007&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2012, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llfloatertexturefetchdebugger.h"
-
-#include "lluictrlfactory.h"
-#include "llbutton.h"
-#include "llspinctrl.h"
-#include "llresmgr.h"
-
-#include "llmath.h"
-#include "llviewerwindow.h"
-#include "llappviewer.h"
-#include "lltexturefetch.h"
-#include "llviewercontrol.h"
-#include "llviewerassetstats.h" //gTextureTimer
-
-LLFloaterTextureFetchDebugger::LLFloaterTextureFetchDebugger(const LLSD& key)
-	: LLFloater(key),
-	mDebugger(NULL)
-{
-	setTitle("Texture Fetching Debugger Floater");
-	
-	mCommitCallbackRegistrar.add("TexFetchDebugger.ChangeTexelPixelRatio",	boost::bind(&LLFloaterTextureFetchDebugger::onChangeTexelPixelRatio, this));
-
-	mCommitCallbackRegistrar.add("TexFetchDebugger.Start",	boost::bind(&LLFloaterTextureFetchDebugger::onClickStart, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.Clear",	boost::bind(&LLFloaterTextureFetchDebugger::onClickClear, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.Close",	boost::bind(&LLFloaterTextureFetchDebugger::onClickClose, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.ResetFetchTime",	boost::bind(&LLFloaterTextureFetchDebugger::onClickResetFetchTime, this));
-
-	mCommitCallbackRegistrar.add("TexFetchDebugger.CacheRead",	boost::bind(&LLFloaterTextureFetchDebugger::onClickCacheRead, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.CacheWrite",	boost::bind(&LLFloaterTextureFetchDebugger::onClickCacheWrite, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.HTTPLoad",	boost::bind(&LLFloaterTextureFetchDebugger::onClickHTTPLoad, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.Decode",	boost::bind(&LLFloaterTextureFetchDebugger::onClickDecode, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.GLTexture",	boost::bind(&LLFloaterTextureFetchDebugger::onClickGLTexture, this));
-
-	mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchVisCache",	boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchVisCache, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchVisHTTP",	boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchVisHTTP, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchAllCache",	boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchAllCache, this));
-	mCommitCallbackRegistrar.add("TexFetchDebugger.RefetchAllHTTP",	boost::bind(&LLFloaterTextureFetchDebugger::onClickRefetchAllHTTP, this));
-}
-//----------------------------------------------
-
-BOOL LLFloaterTextureFetchDebugger::postBuild(void) 
-{	
-	mDebugger = LLAppViewer::getTextureFetch()->getFetchDebugger();
-	mStartStatus = (S32)LLTextureFetchDebugger::IDLE;
-
-	//set states for buttons
-	mButtonStateMap["start_btn"] = true;
-	mButtonStateMap["close_btn"] = true;
-	mButtonStateMap["clear_btn"] = true;
-	mButtonStateMap["cacheread_btn"] = false;
-	mButtonStateMap["cachewrite_btn"] = false;
-	mButtonStateMap["http_btn"] = false;
-	mButtonStateMap["decode_btn"] = false;
-	mButtonStateMap["gl_btn"] = false;
-
-	mButtonStateMap["refetchviscache_btn"] = false;
-	mButtonStateMap["refetchvishttp_btn"] = false;
-	mButtonStateMap["refetchallcache_btn"] = false;
-	mButtonStateMap["refetchallhttp_btn"] = false;
-
-	updateButtons();
-
-	getChild<LLUICtrl>("texel_pixel_ratio")->setValue(gSavedSettings.getF32("TexelPixelRatio"));
-
-	return TRUE ;
-}
-
-LLFloaterTextureFetchDebugger::~LLFloaterTextureFetchDebugger()
-{
-	//stop everything
-	mDebugger->setStopDebug();
-}
-
-void LLFloaterTextureFetchDebugger::updateButtons()
-{
-	for(std::map<std::string, bool>::iterator iter = mButtonStateMap.begin(); iter != mButtonStateMap.end(); ++iter)
-	{
-		if(iter->second)
-		{
-			childEnable(iter->first.c_str());
-		}
-		else
-		{
-			childDisable(iter->first.c_str());
-		}
-	}
-}
-
-void LLFloaterTextureFetchDebugger::disableButtons()
-{
-	childDisable("start_btn");
-	childDisable("clear_btn");
-	childDisable("cacheread_btn");
-	childDisable("cachewrite_btn");
-	childDisable("http_btn");
-	childDisable("decode_btn");
-	childDisable("gl_btn");
-	childDisable("refetchviscache_btn");
-	childDisable("refetchvishttp_btn");
-	childDisable("refetchallcache_btn");
-	childDisable("refetchallhttp_btn");
-}
-void LLFloaterTextureFetchDebugger::setStartStatus(S32 status)
-{
-	llassert_always(LLTextureFetchDebugger::IDLE == (LLTextureFetchDebugger::e_debug_state)mStartStatus) ;
-	mStartStatus = status;
-}
-	
-bool LLFloaterTextureFetchDebugger::idleStart()
-{
-	if(mStartStatus != (S32)LLTextureFetchDebugger::IDLE)
-	{
-		mDebugger->startWork((LLTextureFetchDebugger::e_debug_state)mStartStatus);
-		mStartStatus = (S32)LLTextureFetchDebugger::IDLE;
-		return true;
-	}
-
-	return false;
-}
-
-void LLFloaterTextureFetchDebugger::idle()
-{	
-	if(idleStart())
-	{
-		return;
-	}
-
-	const F32 max_time = 0.005f; //5ms
-	LLTextureFetchDebugger::e_debug_state state = mDebugger->getState();	
-	if(mDebugger->update(max_time))
-	{
-		switch(state)
-		{
-		case LLTextureFetchDebugger::IDLE:
-			break;
-		case LLTextureFetchDebugger::START_DEBUG:
-			mButtonStateMap["cacheread_btn"] = true;
-			mButtonStateMap["http_btn"] = true;
-			mButtonStateMap["refetchviscache_btn"] = true;
-			mButtonStateMap["refetchvishttp_btn"] = true;
-			mButtonStateMap["refetchallcache_btn"] = true;
-			mButtonStateMap["refetchallhttp_btn"] = true;
-			break;
-		case LLTextureFetchDebugger::READ_CACHE:			
-			mButtonStateMap["decode_btn"] = true;			
-			break;
-		case LLTextureFetchDebugger::WRITE_CACHE:			
-			break;
-		case LLTextureFetchDebugger::DECODING:
-			mButtonStateMap["gl_btn"] = true;			
-			break;
-		case LLTextureFetchDebugger::HTTP_FETCHING:
-			mButtonStateMap["cacheread_btn"] = true;
-			mButtonStateMap["cachewrite_btn"] = true;
-			mButtonStateMap["decode_btn"] = true;			
-			break;
-		case LLTextureFetchDebugger::GL_TEX:			
-			break;
-		case LLTextureFetchDebugger::REFETCH_VIS_CACHE:			
-			break;
-		case LLTextureFetchDebugger::REFETCH_VIS_HTTP:			
-			break;
-		case LLTextureFetchDebugger::REFETCH_ALL_CACHE:			
-			break;
-		case LLTextureFetchDebugger::REFETCH_ALL_HTTP:
-			break;
-		default:
-			break;
-		}
-
-		if(state != LLTextureFetchDebugger::IDLE)
-		{
-			updateButtons();
-		}
-	}
-}
-
-//----------------------
-void LLFloaterTextureFetchDebugger::onChangeTexelPixelRatio()
-{
-	gSavedSettings.setF32("TexelPixelRatio", getChild<LLUICtrl>("texel_pixel_ratio")->getValue().asReal());
-}
-
-void LLFloaterTextureFetchDebugger::onClickStart()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::START_DEBUG);	
-
-	mButtonStateMap["start_btn"] = false;
-
-	updateButtons();
-}
-
-void LLFloaterTextureFetchDebugger::onClickClose()
-{
-	setVisible(FALSE);
-	
-	//stop everything
-	mDebugger->setStopDebug();
-
-	delete this;
-}
-
-void LLFloaterTextureFetchDebugger::onClickResetFetchTime()
-{
-	gTextureTimer.start();
-	gTextureTimer.pause();
-}
-
-void LLFloaterTextureFetchDebugger::onClickClear()
-{
-	mButtonStateMap["start_btn"] = true;
-	mButtonStateMap["close_btn"] = true;
-	mButtonStateMap["clear_btn"] = true;
-	mButtonStateMap["cacheread_btn"] = false;
-	mButtonStateMap["cachewrite_btn"] = false;
-	mButtonStateMap["http_btn"] = false;
-	mButtonStateMap["decode_btn"] = false;
-	mButtonStateMap["gl_btn"] = false;
-	mButtonStateMap["refetchviscache_btn"] = true;
-	mButtonStateMap["refetchvishttp_btn"] = true;
-	updateButtons();
-
-	//stop everything
-	mDebugger->setStopDebug();
-	mDebugger->clearHistory();
-}
-
-void LLFloaterTextureFetchDebugger::onClickCacheRead()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::READ_CACHE);
-}
-
-void LLFloaterTextureFetchDebugger::onClickCacheWrite()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::WRITE_CACHE);
-}
-
-void LLFloaterTextureFetchDebugger::onClickHTTPLoad()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::HTTP_FETCHING);
-}
-
-void LLFloaterTextureFetchDebugger::onClickDecode()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::DECODING);
-}
-
-void LLFloaterTextureFetchDebugger::onClickGLTexture()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::GL_TEX);	
-}
-
-void LLFloaterTextureFetchDebugger::onClickRefetchVisCache()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::REFETCH_VIS_CACHE);
-}
-
-void LLFloaterTextureFetchDebugger::onClickRefetchVisHTTP()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::REFETCH_VIS_HTTP);	
-}
-
-void LLFloaterTextureFetchDebugger::onClickRefetchAllCache()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::REFETCH_ALL_CACHE);
-}
-
-void LLFloaterTextureFetchDebugger::onClickRefetchAllHTTP()
-{
-	disableButtons();
-
-	setStartStatus((S32)LLTextureFetchDebugger::REFETCH_ALL_HTTP);	
-}
-
-void LLFloaterTextureFetchDebugger::draw()
-{
-	//total number of fetched textures
-	{
-		getChild<LLUICtrl>("total_num_fetched_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumFetchedTextures()));
-	}
-
-	//total number of fetching requests
-	{
-		getChild<LLUICtrl>("total_num_fetching_requests_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumFetchingRequests()));
-	}
-
-	//total number of cache hits
-	{
-		getChild<LLUICtrl>("total_num_cache_hits_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumCacheHits()));
-	}
-
-	//total number of visible textures
-	{
-		getChild<LLUICtrl>("total_num_visible_tex_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumVisibleFetchedTextures()));
-	}
-
-	//total number of visible texture fetching requests
-	{
-		getChild<LLUICtrl>("total_num_visible_tex_fetch_req_label")->setTextArg("[NUM]", llformat("%d", mDebugger->getNumVisibleFetchingRequests()));
-	}
-
-	//total number of fetched data
-	{
-		getChild<LLUICtrl>("total_fetched_data_label")->setTextArg("[SIZE1]", llformat("%d", mDebugger->getFetchedData() >> 10));		
-		getChild<LLUICtrl>("total_fetched_data_label")->setTextArg("[SIZE2]", llformat("%d", mDebugger->getDecodedData() >> 10));
-		getChild<LLUICtrl>("total_fetched_data_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getFetchedPixels() / 1000000.f));
-	}
-
-	//total number of visible fetched data
-	{		
-		getChild<LLUICtrl>("total_fetched_vis_data_label")->setTextArg("[SIZE1]", llformat("%d", mDebugger->getVisibleFetchedData() >> 10));		
-		getChild<LLUICtrl>("total_fetched_vis_data_label")->setTextArg("[SIZE2]", llformat("%d", mDebugger->getVisibleDecodedData() >> 10));
-	}
-
-	//total number of rendered fetched data
-	{
-		getChild<LLUICtrl>("total_fetched_rendered_data_label")->setTextArg("[SIZE1]", llformat("%d", mDebugger->getRenderedData() >> 10));		
-		getChild<LLUICtrl>("total_fetched_rendered_data_label")->setTextArg("[SIZE2]", llformat("%d", mDebugger->getRenderedDecodedData() >> 10));
-		getChild<LLUICtrl>("total_fetched_rendered_data_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRenderedPixels() / 1000000.f));
-	}
-
-	//total time on cache readings
-	if(mDebugger->getCacheReadTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_cache_read_label")->setTextArg("[TIME]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_cache_read_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getCacheReadTime()));
-	}
-
-	//total time on cache writings
-	if(mDebugger->getCacheWriteTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_cache_write_label")->setTextArg("[TIME]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_cache_write_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getCacheWriteTime()));
-	}
-
-	//total time on decoding
-	if(mDebugger->getDecodeTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_decode_label")->setTextArg("[TIME]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_decode_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getDecodeTime()));
-	}
-
-	//total time on gl texture creation
-	if(mDebugger->getGLCreationTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_gl_label")->setTextArg("[TIME]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_gl_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getGLCreationTime()));
-	}
-
-	//total time on HTTP fetching
-	if(mDebugger->getHTTPTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_http_label")->setTextArg("[TIME]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_http_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getHTTPTime()));
-	}
-
-	//total time on entire fetching
-	{
-		getChild<LLUICtrl>("total_time_fetch_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getTotalFetchingTime()));
-	}
-
-	//total time on refetching visible textures from cache
-	if(mDebugger->getRefetchVisCacheTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[TIME]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[SIZE]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[PIXEL]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchVisCacheTime()));
-		getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedVisData() >> 10));
-		getChild<LLUICtrl>("total_time_refetch_vis_cache_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedVisPixels() / 1000000.f));
-	}
-
-	//total time on refetching all textures from cache
-	if(mDebugger->getRefetchAllCacheTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[TIME]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[SIZE]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[PIXEL]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchAllCacheTime()));
-		getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedAllData() >> 10));
-		getChild<LLUICtrl>("total_time_refetch_all_cache_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedAllPixels() / 1000000.f));
-	}
-
-	//total time on refetching visible textures from http
-	if(mDebugger->getRefetchVisHTTPTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[TIME]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[SIZE]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[PIXEL]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchVisHTTPTime()));
-		getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedVisData() >> 10));
-		getChild<LLUICtrl>("total_time_refetch_vis_http_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedVisPixels() / 1000000.f));
-	}
-
-	//total time on refetching all textures from http
-	if(mDebugger->getRefetchAllHTTPTime() < 0.f)
-	{
-		getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[TIME]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[SIZE]", std::string("----"));
-		getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[PIXEL]", std::string("----"));
-	}
-	else
-	{
-		getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[TIME]", llformat("%.3f", mDebugger->getRefetchAllHTTPTime()));
-		getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[SIZE]", llformat("%d", mDebugger->getRefetchedAllData() >> 10));
-		getChild<LLUICtrl>("total_time_refetch_all_http_label")->setTextArg("[PIXEL]", llformat("%.3f", mDebugger->getRefetchedAllPixels() / 1000000.f));
-	}
-
-	LLFloater::draw();
-}
diff --git a/indra/newview/llfloatertexturefetchdebugger.h b/indra/newview/llfloatertexturefetchdebugger.h
deleted file mode 100644
index 637f3b03e5e..00000000000
--- a/indra/newview/llfloatertexturefetchdebugger.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/** 
- * @file llfloatertexturefetchdebugger.h
- * @brief texture fetching debugger window, debug use only
- *
- * $LicenseInfo:firstyear=2004&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_FLOATER_TEXTURE_FETCH_DEBUGGER__H
-#define LL_FLOATER_TEXTURE_FETCH_DEBUGGER__H
-
-#include "llfloater.h"
-class LLTextureFetchDebugger;
-
-class LLFloaterTextureFetchDebugger : public LLFloater
-{
-	friend class LLFloaterReg;
-public:
-	/// initialize all the callbacks for the menu
-
-	virtual BOOL postBuild() ;
-	virtual void draw() ;
-	
-	void onChangeTexelPixelRatio();
-	
-	void onClickStart();
-	void onClickClear();
-	void onClickClose();
-	void onClickResetFetchTime();
-
-	void onClickCacheRead();
-	void onClickCacheWrite();
-	void onClickHTTPLoad();
-	void onClickDecode();
-	void onClickGLTexture();
-
-	void onClickRefetchVisCache();
-	void onClickRefetchVisHTTP();
-	void onClickRefetchAllCache();
-	void onClickRefetchAllHTTP();
-public:
-	void idle() ;
-
-private:	
-	LLFloaterTextureFetchDebugger(const LLSD& key);
-	virtual ~LLFloaterTextureFetchDebugger();
-
-	void updateButtons();
-	void disableButtons();
-
-	void setStartStatus(S32 status);
-	bool idleStart();
-private:	
-	LLTextureFetchDebugger* mDebugger;
-	std::map<std::string, bool> mButtonStateMap;
-	S32 mStartStatus;
-};
-
-#endif // LL_FLOATER_TEXTURE_FETCH_DEBUGGER__H
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 543e8b0dab8..d811b32f4f0 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -62,8 +62,6 @@
 #include "llcorehttputil.h"
 #include "llhttpretrypolicy.h"
 
-bool LLTextureFetchDebugger::sDebuggerEnabled = false ;
-
 LLTrace::CountStatHandle<F64> LLTextureFetch::sCacheHit("texture_cache_hit");
 LLTrace::CountStatHandle<F64> LLTextureFetch::sCacheAttempt("texture_cache_attempt");
 LLTrace::EventStatHandle<LLUnit<F32, LLUnits::Percent> > LLTextureFetch::sCacheHitRate("texture_cache_hits");
@@ -244,8 +242,8 @@ static const S32 HTTP_REQUESTS_RANGE_END_MAX = 20000000;
 //////////////////////////////////////////////////////////////////////////////
 namespace
 {
-    // The NoOpDeletor is used when passing certain objects (the LLTextureFetchWorker and
-    // the LLTextureFetchDebugger) in a smart pointer below for passage into 
+    // The NoOpDeletor is used when passing certain objects (the LLTextureFetchWorker)
+    // in a smart pointer below for passage into 
     // the LLCore::Http libararies. When the smart pointer is destroyed,  no 
     // action will be taken since we do not in these cases want the object to 
     // be destroyed at the end of the call.
@@ -283,7 +281,6 @@ class LLTextureFetchWorker : public LLWorkerClass, public LLCore::HttpHandler
 
 {
 	friend class LLTextureFetch;
-	friend class LLTextureFetchDebugger;
 	
 private:
 	class CacheReadResponder : public LLTextureCache::ReadResponder
@@ -1883,11 +1880,6 @@ bool LLTextureFetchWorker::doWork(S32 param)
         LL_PROFILE_ZONE_NAMED_CATEGORY_THREAD("tfwdw - DECODE_IMAGE_UPDATE");
 		if (mDecoded)
 		{
-			if(mFetcher->getFetchDebugger() && !mInLocalCache)
-			{
-				mFetcher->getFetchDebugger()->addHistoryEntry(this);
-			}
-
             mDecodeTime = mDecodeTimer.getElapsedTimeF32();
 
 			if (mDecodedDiscard < 0)
@@ -2574,10 +2566,8 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
 	  mTotalCacheReadCount(0U),
 	  mTotalCacheWriteCount(0U),
 	  mTotalResourceWaitCount(0U),
-	  mFetchDebugger(NULL),
 	  mFetchSource(LLTextureFetch::FROM_ALL),
 	  mOriginFetchSource(LLTextureFetch::FROM_ALL),
-	  mFetcherLocked(FALSE),
 	  mTextureInfoMainThread(false)
 {
 	mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
@@ -2598,21 +2588,6 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
 	mHttpLowWater = HTTP_NONPIPE_REQUESTS_LOW_WATER;
 	mHttpSemaphore = 0;
 
-	// Conditionally construct debugger object after 'this' is
-	// fully initialized.
-	LLTextureFetchDebugger::sDebuggerEnabled = gSavedSettings.getBOOL("TextureFetchDebuggerEnabled");
-	if(LLTextureFetchDebugger::isEnabled())
-	{
-		mFetchDebugger = new LLTextureFetchDebugger(this, cache, imagedecodethread) ;
-		mFetchSource = (e_tex_source)gSavedSettings.getS32("TextureFetchSource");
-		if(mFetchSource < 0 && mFetchSource >= INVALID_SOURCE)
-		{
-			mFetchSource = LLTextureFetch::FROM_ALL;
-			gSavedSettings.setS32("TextureFetchSource", 0);
-		}
-		mOriginFetchSource = mFetchSource;
-	}
-
 	// If that test log has ben requested but not yet created, create it
 	if (LLMetricPerformanceTesterBasic::isMetricLogRequested(sTesterName) && !LLMetricPerformanceTesterBasic::getTester(sTesterName))
 	{
@@ -2641,9 +2616,6 @@ LLTextureFetch::~LLTextureFetch()
 	delete mHttpRequest;
 	mHttpRequest = NULL;
 
-	delete mFetchDebugger;
-	mFetchDebugger = NULL;
-	
 	// ~LLQueuedThread() called here
 }
 
@@ -2651,10 +2623,6 @@ bool LLTextureFetch::createRequest(FTType f_type, const std::string& url, const
 								   S32 w, S32 h, S32 c, S32 desired_discard, bool needs_aux, bool can_use_http)
 {
     LL_PROFILE_ZONE_SCOPED;
-	if(mFetcherLocked)
-	{
-		return false;
-	}
 	if (mDebugPause)
 	{
 		return false;
@@ -3181,11 +3149,6 @@ S32 LLTextureFetch::update(F32 max_time_ms)
 		commonUpdate();
 	}
 
-	if (mFetchDebugger)
-	{
-		mFetchDebugger->tryToStopDebug(); //check if need to stop debugger.
-	}
-
 	return res;
 }
 
@@ -4218,970 +4181,6 @@ truncate_viewer_metrics(int max_regions, LLSD & metrics)
 
 } // end of anonymous namespace
 
-
-///////////////////////////////////////////////////////////////////////////////////////////
-//Start LLTextureFetchDebugger
-///////////////////////////////////////////////////////////////////////////////////////////
-//---------------------
-class LLDebuggerCacheReadResponder : public LLTextureCache::ReadResponder
-{
-public:
-	LLDebuggerCacheReadResponder(LLTextureFetchDebugger* debugger, S32 id, LLImageFormatted* image)
-		: mDebugger(debugger), mID(id)
-	{
-		setImage(image);
-	}
-	virtual void completed(bool success)
-	{
-		mDebugger->callbackCacheRead(mID, success, mFormattedImage, mImageSize, mImageLocal);
-	}
-private:
-	LLTextureFetchDebugger* mDebugger;
-	S32 mID;
-};
-
-class LLDebuggerCacheWriteResponder : public LLTextureCache::WriteResponder
-{
-public:
-	LLDebuggerCacheWriteResponder(LLTextureFetchDebugger* debugger, S32 id)
-		: mDebugger(debugger), mID(id)
-	{
-	}
-	virtual void completed(bool success)
-	{
-		mDebugger->callbackCacheWrite(mID, success);
-	}
-private:
-	LLTextureFetchDebugger* mDebugger;
-	S32 mID;
-};
-
-class LLDebuggerDecodeResponder : public LLImageDecodeThread::Responder
-{
-public:
-	LLDebuggerDecodeResponder(LLTextureFetchDebugger* debugger, S32 id)
-		: mDebugger(debugger), mID(id)
-	{
-	}
-	virtual void completed(bool success, LLImageRaw* raw, LLImageRaw* aux)
-	{
-		mDebugger->callbackDecoded(mID, success, raw, aux);
-	}
-private:
-	LLTextureFetchDebugger* mDebugger;
-	S32 mID;
-};
-
-
-LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextureCache* cache, LLImageDecodeThread* imagedecodethread) :
-	LLCore::HttpHandler(),
-	mFetcher(fetcher),
-	mTextureCache(cache),
-	mImageDecodeThread(imagedecodethread),
-	mHttpHeaders(),
-	mHttpPolicyClass(fetcher->getPolicyClass()),
-	mNbCurlCompleted(0),
-	mTempIndex(0),
-	mHistoryListIndex(0)
-{
-	init();
-}
-	
-LLTextureFetchDebugger::~LLTextureFetchDebugger()
-{
-	mFetchingHistory.clear();
-	mStopDebug = TRUE;
-	tryToStopDebug();
-}
-
-void LLTextureFetchDebugger::init()
-{
-	setDebuggerState(IDLE);
-	
-	mCacheReadTime = -1.f;
-	mCacheWriteTime = -1.f;
-	mDecodingTime = -1.f;
-	mHTTPTime = -1.f;
-	mGLCreationTime = -1.f;
-
-	mTotalFetchingTime = 0.f;
-	mRefetchVisCacheTime = -1.f;
-	mRefetchVisHTTPTime = -1.f;
-	mRefetchAllCacheTime = -1.f;
-	mRefetchAllHTTPTime = -1.f;
-
-	mNumFetchedTextures = 0;
-	mNumCacheHits = 0;
-	mNumVisibleFetchedTextures = 0;
-	mNumVisibleFetchingRequests = 0;
-	mFetchedData = 0;
-	mDecodedData = 0;
-	mVisibleFetchedData = 0;
-	mVisibleDecodedData = 0;
-	mRenderedData = 0;
-	mRenderedDecodedData = 0;
-	mFetchedPixels = 0;
-	mRenderedPixels = 0;
-	mRefetchedVisData = 0;
-	mRefetchedVisPixels = 0;
-	mRefetchedAllData = 0;
-	mRefetchedAllPixels = 0;
-
-	mFreezeHistory = FALSE;
-	mStopDebug = FALSE;
-	mClearHistory = FALSE;
-	mRefetchNonVis = FALSE;
-	
-	mNbCurlRequests = 0;
-
-	if (! mHttpHeaders)
-	{
-        mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders);
-		mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C);
-	}
-}
-
-void LLTextureFetchDebugger::startWork(e_debug_state state)
-{
-	switch(state)
-	{
-		case IDLE:
-			break;
-		case START_DEBUG:
-			startDebug();
-			break;
-		case READ_CACHE:			
-			debugCacheRead();
-			break;
-		case WRITE_CACHE:
-			debugCacheWrite();
-			break;
-		case DECODING:
-			debugDecoder();
-			break;
-		case HTTP_FETCHING:
-			debugHTTP();
-			break;
-		case GL_TEX:
-			debugGLTextureCreation();
-			break;
-		case REFETCH_VIS_CACHE:
-			debugRefetchVisibleFromCache();
-			break;
-		case REFETCH_VIS_HTTP:
-			debugRefetchVisibleFromHTTP();
-			break;
-		case REFETCH_ALL_CACHE:
-			debugRefetchAllFromCache();
-			break;
-		case REFETCH_ALL_HTTP:
-			debugRefetchAllFromHTTP();
-			break;
-		default:
-			break;
-	}
-	return;
-}
-
-void LLTextureFetchDebugger::startDebug()
-{
-	//lock the fetcher
-	mFetcher->lockFetcher(true);
-	mFreezeHistory = TRUE;
-	mFetcher->resetLoadSource();
-
-	//clear the current fetching queue
-	gTextureList.clearFetchingRequests();
-
-	setDebuggerState(START_DEBUG);
-}
-
-bool LLTextureFetchDebugger::processStartDebug(F32 max_time)
-{
-	mTimer.reset();
-
-	//wait for all works to be done
-	while(1)
-	{
-		S32 pending = 0;
-		pending += LLAppViewer::getTextureCache()->update(1); 
-		pending += LLAppViewer::getImageDecodeThread()->update(1); 
-		// pending += LLAppViewer::getTextureFetch()->update(1);  // This causes infinite recursion in some cases
-		pending += mNbCurlRequests;
-		if(!pending)
-		{
-			break;
-		}
-
-		if(mTimer.getElapsedTimeF32() > max_time)
-		{
-			return false;
-		}
-	}
-
-	//collect statistics
-	mTotalFetchingTime = gTextureTimer.getElapsedTimeF32() - mTotalFetchingTime;
-	
-	std::set<LLUUID> fetched_textures;
-	S32 size = mFetchingHistory.size();
-	for(S32 i = 0 ; i < size; i++)
-	{
-		bool in_list = true;
-		if(fetched_textures.find(mFetchingHistory[i].mID) == fetched_textures.end())
-		{
-			fetched_textures.insert(mFetchingHistory[i].mID);
-			in_list = false;
-		}
-
-        std::vector<LLViewerFetchedTexture*> textures;
-        LLViewerTextureManager::findFetchedTextures(mFetchingHistory[i].mID, textures);
-        std::vector<LLViewerFetchedTexture*>::iterator iter = textures.begin();
-        while (iter != textures.end())
-        {
-            LLViewerFetchedTexture* tex = *iter++;
-            // fetched data will be counted for both ui and regular elements
-            if (tex && tex->isJustBound()) //visible
-            {
-                if (!in_list)
-                {
-                    mNumVisibleFetchedTextures++;
-                }
-                mNumVisibleFetchingRequests++;
-
-                mVisibleFetchedData += mFetchingHistory[i].mFetchedSize;
-                mVisibleDecodedData += mFetchingHistory[i].mDecodedSize;
-
-                if (tex->getDiscardLevel() >= mFetchingHistory[i].mDecodedLevel)
-                {
-                    mRenderedData += mFetchingHistory[i].mFetchedSize;
-                    mRenderedDecodedData += mFetchingHistory[i].mDecodedSize;
-                    mRenderedPixels += tex->getWidth() * tex->getHeight();
-                }
-            }
-        }
-	}
-
-	mNumFetchedTextures = fetched_textures.size();
-
-	return true;
-}
-
-void LLTextureFetchDebugger::tryToStopDebug()
-{
-	if(!mStopDebug)
-	{
-		return;
-	}
-
-	//clear the current debug work
-	S32 size = mFetchingHistory.size();
-	switch(mDebuggerState)
-	{
-	case READ_CACHE:		
-		for(S32 i = 0 ; i < size; i++)
-		{
-			if (mFetchingHistory[i]. mCacheHandle != LLTextureCache::nullHandle())
-			{
-				mTextureCache->readComplete(mFetchingHistory[i].mCacheHandle, true);
-			}
- 		}	
-		break;
-	case WRITE_CACHE:
-		for(S32 i = 0 ; i < size; i++)
-		{
-			if (mFetchingHistory[i].mCacheHandle != LLTextureCache::nullHandle())
-			{
-				mTextureCache->writeComplete(mFetchingHistory[i].mCacheHandle, true);
-			}
-		}
-		break;
-	case DECODING:
-		break;
-	case HTTP_FETCHING:
-		break;
-	case GL_TEX:
-		break;
-	case REFETCH_VIS_CACHE:
-		break;
-	case REFETCH_VIS_HTTP:
-		break;
-	case REFETCH_ALL_CACHE:
-		mRefetchList.clear();
-		break;
-	case REFETCH_ALL_HTTP:
-		mRefetchList.clear();
-		break;
-	default:
-		break;
-	}
-
-	if(update(0.005f))
-	{
-		//unlock the fetcher
-		mFetcher->lockFetcher(false);
-		mFetcher->resetLoadSource();
-		mFreezeHistory = FALSE;		
-		mStopDebug = FALSE;
-
-		if(mClearHistory)
-		{
-			mFetchingHistory.clear();
-			mHandleToFetchIndex.clear();
-			init();	
-			mTotalFetchingTime = gTextureTimer.getElapsedTimeF32(); //reset
-		}
-	}
-}
-
-//called in the main thread and when the fetching queue is empty
-void LLTextureFetchDebugger::clearHistory()
-{
-	mClearHistory = TRUE;	
-}
-
-void LLTextureFetchDebugger::addHistoryEntry(LLTextureFetchWorker* worker)
-{
-	if(worker->mRawImage.isNull() || worker->mFormattedImage.isNull())
-	{
-		return;
-	}
-
-	if(mFreezeHistory)
-	{
-		if(mDebuggerState == REFETCH_VIS_CACHE || mDebuggerState == REFETCH_VIS_HTTP)
-		{
-			mRefetchedVisPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight();
-			mRefetchedVisData += worker->mFormattedImage->getDataSize();
-		}
-		else
-		{
-			mRefetchedAllPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight();
-			mRefetchedAllData += worker->mFormattedImage->getDataSize();
-
-			// refetch list only requests/creates normal images, so requesting ui='false'
-			LLViewerFetchedTexture* tex = LLViewerTextureManager::findFetchedTexture(worker->mID, TEX_LIST_STANDARD);
-			if(tex && mRefetchList[tex].begin() != mRefetchList[tex].end())
-			{
-				if(worker->mDecodedDiscard == mFetchingHistory[mRefetchList[tex][0]].mDecodedLevel)
-				{
-					mRefetchList[tex].erase(mRefetchList[tex].begin());
-				}
-			}
-		}
-		return;
-	}
-
-	if(worker->mInCache)
-	{
-		mNumCacheHits++;
-	}
-	mFetchedData += worker->mFormattedImage->getDataSize();
-	mDecodedData += worker->mRawImage->getDataSize();
-	mFetchedPixels += worker->mRawImage->getWidth() * worker->mRawImage->getHeight();
-
-	mFetchingHistory.push_back(FetchEntry(worker->mID, worker->mDesiredSize, worker->mDecodedDiscard, 
-		worker->mFormattedImage->getDataSize(), worker->mRawImage->getDataSize()));
-}
-
-void LLTextureFetchDebugger::lockCache()
-{
-}
-	
-void LLTextureFetchDebugger::unlockCache()
-{
-}
-	
-void LLTextureFetchDebugger::debugCacheRead()
-{
-	lockCache();
-	llassert_always(mDebuggerState == IDLE);
-	mTimer.reset();
-	setDebuggerState(READ_CACHE);
-	mCacheReadTime = -1.f;
-
-	S32 size = mFetchingHistory.size();
-	for(S32 i = 0 ; i < size ; i++)
-	{		
-		mFetchingHistory[i].mFormattedImage = NULL;
-		mFetchingHistory[i].mCacheHandle = mTextureCache->readFromCache(mFetchingHistory[i].mID, 0, mFetchingHistory[i].mFetchedSize, 
-			new LLDebuggerCacheReadResponder(this, i, mFetchingHistory[i].mFormattedImage));
-	}
-}
-	
-void LLTextureFetchDebugger::clearCache()
-{
-	S32 size = mFetchingHistory.size();
-	{
-		std::set<LLUUID> deleted_list;
-		for(S32 i = 0 ; i < size ; i++)
-		{
-			if(deleted_list.find(mFetchingHistory[i].mID) == deleted_list.end())
-			{
-				deleted_list.insert(mFetchingHistory[i].mID);
-				mTextureCache->removeFromCache(mFetchingHistory[i].mID);
-			}
-		}
-	}
-}
-
-void LLTextureFetchDebugger::debugCacheWrite()
-{
-	//remove from cache
-	clearCache();
-
-	lockCache();
-	llassert_always(mDebuggerState == IDLE);
-	mTimer.reset();
-	setDebuggerState(WRITE_CACHE);
-	mCacheWriteTime = -1.f;
-
-	S32 size = mFetchingHistory.size();
-	for(S32 i = 0 ; i < size ; i++)
-	{		
-		if(mFetchingHistory[i].mFormattedImage.notNull())
-		{
-			mFetchingHistory[i].mCacheHandle = mTextureCache->writeToCache(mFetchingHistory[i].mID,
-                mFetchingHistory[i].mFormattedImage->getData(), mFetchingHistory[i].mFetchedSize,
-				mFetchingHistory[i].mDecodedLevel == 0 ? mFetchingHistory[i].mFetchedSize : mFetchingHistory[i].mFetchedSize + 1, 
-				NULL, 0, new LLDebuggerCacheWriteResponder(this, i));					
-		}
-	}
-}
-
-void LLTextureFetchDebugger::lockDecoder()
-{
-}
-	
-void LLTextureFetchDebugger::unlockDecoder()
-{
-}
-
-void LLTextureFetchDebugger::debugDecoder()
-{
-	lockDecoder();
-	llassert_always(mDebuggerState == IDLE);
-	mTimer.reset();
-	setDebuggerState(DECODING);
-	mDecodingTime = -1.f;
-
-	S32 size = mFetchingHistory.size();
-	for(S32 i = 0 ; i < size ; i++)
-	{		
-		if(mFetchingHistory[i].mFormattedImage.isNull())
-		{
-			continue;
-		}
-
-		mImageDecodeThread->decodeImage(mFetchingHistory[i].mFormattedImage,
-			mFetchingHistory[i].mDecodedLevel, mFetchingHistory[i].mNeedsAux,
-			new LLDebuggerDecodeResponder(this, i));
-	}
-}
-
-void LLTextureFetchDebugger::debugHTTP()
-{
-	llassert_always(mDebuggerState == IDLE);
-
-	LLViewerRegion* region = gAgent.getRegion();
-	if (!region)
-	{
-		LL_INFOS(LOG_TXT) << "Fetch Debugger : Current region undefined. Cannot fetch textures through HTTP." << LL_ENDL;
-		return;
-	}
-	
-	mHTTPUrl = region->getViewerAssetUrl();
-	if (mHTTPUrl.empty())
-	{
-		LL_INFOS(LOG_TXT) << "Fetch Debugger : Current region URL undefined. Cannot fetch textures through HTTP." << LL_ENDL;
-		return;
-	}
-	
-	mTimer.reset();
-	setDebuggerState(HTTP_FETCHING);
-	mHTTPTime = -1.f;
-	
-	S32 size = mFetchingHistory.size();
-	for (S32 i = 0 ; i < size ; i++)
-	{
-		mFetchingHistory[i].mCurlState = FetchEntry::CURL_NOT_DONE;
-		mFetchingHistory[i].mCurlReceivedSize = 0;
-		mFetchingHistory[i].mFormattedImage = NULL;
-	}
-	mNbCurlRequests = 0;
-	mNbCurlCompleted = 0;
-	
-	fillCurlQueue();
-}
-
-S32 LLTextureFetchDebugger::fillCurlQueue()
-{
-	if(mStopDebug) //stop
-	{
-		mNbCurlCompleted = mFetchingHistory.size();
-		return 0;
-	}
-	if (mNbCurlRequests > HTTP_NONPIPE_REQUESTS_LOW_WATER)
-	{
-		return mNbCurlRequests;
-	}
-	
-	S32 size = mFetchingHistory.size();
-	for (S32 i = 0 ; i < size ; i++)
-	{		
-		if (mFetchingHistory[i].mCurlState != FetchEntry::CURL_NOT_DONE)
-		{
-			continue;
-		}
-		std::string texture_url = mHTTPUrl + "/?texture_id=" + mFetchingHistory[i].mID.asString().c_str();
-		S32 requestedSize = mFetchingHistory[i].mRequestedSize;
-		// We request the whole file if the size was not set.
-		requestedSize = llmax(0,requestedSize);
-		// We request the whole file if the size was set to an absurdly high value (meaning all file)
-		requestedSize = (requestedSize == 33554432 ? 0 : requestedSize);
-
-		LLCore::HttpHandle handle = mFetcher->getHttpRequest().requestGetByteRange(mHttpPolicyClass,
-																				   texture_url,
-																				   0,
-																				   requestedSize,
-																				   LLCore::HttpOptions::ptr_t(),
-																				   mHttpHeaders,
-                                                                                   LLCore::HttpHandler::ptr_t(this, &NoOpDeletor));
-		if (LLCORE_HTTP_HANDLE_INVALID != handle)
-		{
-			mHandleToFetchIndex[handle] = i;
-			mFetchingHistory[i].mHttpHandle = handle;
-			mFetchingHistory[i].mCurlState = FetchEntry::CURL_IN_PROGRESS;
-			mNbCurlRequests++;
-			if (mNbCurlRequests >= HTTP_NONPIPE_REQUESTS_HIGH_WATER)	// emulate normal pipeline
-			{
-				break;
-			}
-		}
-		else 
-		{
-			// Failed to queue request, log it and mark it done.
-			LLCore::HttpStatus status(mFetcher->getHttpRequest().getStatus());
-
-			LL_WARNS(LOG_TXT) << "Couldn't issue HTTP request in debugger for texture "
-							  << mFetchingHistory[i].mID
-							  << ", status: " << status.toTerseString()
-							  << " reason:  " << status.toString()
-							  << LL_ENDL;
-			mFetchingHistory[i].mCurlState = FetchEntry::CURL_DONE;
-		}
-	}
-	//LL_INFOS(LOG_TXT) << "Fetch Debugger : Having " << mNbCurlRequests << " requests through the curl thread." << LL_ENDL;
-	return mNbCurlRequests;
-}
-
-void LLTextureFetchDebugger::debugGLTextureCreation()
-{
-	llassert_always(mDebuggerState == IDLE);
-	setDebuggerState(GL_TEX);
-	mTempTexList.clear();
-
-	S32 size = mFetchingHistory.size();
-	for(S32 i = 0 ; i < size ; i++)
-	{
-		if(mFetchingHistory[i].mRawImage.notNull())
-		{
-            std::vector<LLViewerFetchedTexture*> textures;
-            gTextureList.findTexturesByID(mFetchingHistory[i].mID, textures);
-            std::vector<LLViewerFetchedTexture*>::iterator iter = textures.begin();
-            while (iter != textures.end())
-            {
-                LLViewerFetchedTexture* tex = *iter++;
-                if (tex && !tex->isForSculptOnly())
-                {
-                    tex->destroyGLTexture();
-                    mTempTexList.push_back(tex);
-                }
-            }
-		}
-	}
-	
-	mGLCreationTime = -1.f;
-	mTempIndex = 0;
-	mHistoryListIndex = 0;
-	
-	return;
-}
-
-bool LLTextureFetchDebugger::processGLCreation(F32 max_time)
-{
-	mTimer.reset();
-
-	bool done = true;
-	S32 size = mFetchingHistory.size();
-	S32 size1 = mTempTexList.size();
-	for(; mHistoryListIndex < size && mTempIndex < size1; mHistoryListIndex++)
-	{
-		if(mFetchingHistory[mHistoryListIndex].mRawImage.notNull())
-		{
-			if(mFetchingHistory[mHistoryListIndex].mID == mTempTexList[mTempIndex]->getID())
-			{
-				mTempTexList[mTempIndex]->createGLTexture(mFetchingHistory[mHistoryListIndex].mDecodedLevel, 
-					mFetchingHistory[mHistoryListIndex].mRawImage, 0, TRUE, mTempTexList[mTempIndex]->getBoostLevel());
-				mTempIndex++;
-			}
-		}
-
-		if(mTimer.getElapsedTimeF32() > max_time)
-		{
-			done = false;
-			break;
-		}
-	}
-
-	if(mGLCreationTime < 0.f)
-	{
-		mGLCreationTime = mTimer.getElapsedTimeF32() ;
-	}
-	else
-	{
-		mGLCreationTime += mTimer.getElapsedTimeF32() ;
-	}
-
-	return done;
-}
-
-//clear fetching results of all textures.
-void LLTextureFetchDebugger::clearTextures()
-{
-	S32 size = mFetchingHistory.size();
-	for(S32 i = 0 ; i < size ; i++)
-	{
-        std::vector<LLViewerFetchedTexture*> textures;
-        gTextureList.findTexturesByID(mFetchingHistory[i].mID, textures);
-        std::vector<LLViewerFetchedTexture*>::iterator iter = textures.begin();
-        while (iter != textures.end())
-        {
-            LLViewerFetchedTexture* tex = *iter++;
-            if (tex)
-            {
-                tex->clearFetchedResults();
-            }
-        }
-	}
-}
-
-void LLTextureFetchDebugger::makeRefetchList()
-{
-	mRefetchList.clear();
-	S32 size = mFetchingHistory.size();
-	for(S32 i = 0 ; i < size; i++)
-	{		
-		LLViewerFetchedTexture* tex = LLViewerTextureManager::getFetchedTexture(mFetchingHistory[i].mID);
-		if(tex && tex->isJustBound()) //visible
-		{
-			continue; //the texture fetch pipeline will take care of visible textures.
-		}
-
-		// todo: Will attempt to refetch icons and ui elements as normal images (boost_none)
-		// thus will create unnecessary LLViewerFetchedTexture, consider supporting separate UI textures
-		mRefetchList[tex].push_back(i); 		
-	}
-}
-
-void LLTextureFetchDebugger::scanRefetchList()
-{
-	if(mStopDebug)
-	{
-		return;
-	}
-	if(!mRefetchNonVis)
-	{
-		return;
-	}
-
-	for(std::map< LLPointer<LLViewerFetchedTexture>, std::vector<S32> >::iterator iter = mRefetchList.begin();
-		iter != mRefetchList.end(); )
-	{
-		if(iter->second.empty())
-		{
-			gTextureList.setDebugFetching(iter->first, -1);
-			mRefetchList.erase(iter++);		// This is the correct method to "erase and move on" in an std::map
-		}
-		else
-		{
-			gTextureList.setDebugFetching(iter->first, mFetchingHistory[iter->second[0]].mDecodedLevel);
-			++iter;
-		}
-	}
-}
-
-void LLTextureFetchDebugger::debugRefetchVisibleFromCache()
-{
-	llassert_always(mDebuggerState == IDLE);
-	setDebuggerState(REFETCH_VIS_CACHE);
-
-	clearTextures();
-	mFetcher->setLoadSource(LLTextureFetch::FROM_ALL);
-	
-	mTimer.reset();
-	mFetcher->lockFetcher(false);
-	mRefetchVisCacheTime = -1.f;
-	mRefetchedVisData = 0;
-	mRefetchedVisPixels = 0;
-}
-
-void LLTextureFetchDebugger::debugRefetchVisibleFromHTTP()
-{
-	llassert_always(mDebuggerState == IDLE);
-	setDebuggerState(REFETCH_VIS_HTTP);
-
-	clearTextures();
-	mFetcher->setLoadSource(LLTextureFetch::FROM_HTTP_ONLY);
-
-	mTimer.reset();
-	mFetcher->lockFetcher(false);
-	mRefetchVisHTTPTime = -1.f;
-	mRefetchedVisData = 0;
-	mRefetchedVisPixels = 0;
-}
-
-void LLTextureFetchDebugger::debugRefetchAllFromCache()
-{
-	llassert_always(mDebuggerState == IDLE);
-	setDebuggerState(REFETCH_ALL_CACHE);
-
-	clearTextures();
-	makeRefetchList();
-	mFetcher->setLoadSource(LLTextureFetch::FROM_ALL);
-
-	mTimer.reset();
-	mFetcher->lockFetcher(false);
-	mRefetchAllCacheTime = -1.f;
-	mRefetchedAllData = 0;
-	mRefetchedAllPixels = 0;
-	mRefetchNonVis = FALSE;
-}
-
-void LLTextureFetchDebugger::debugRefetchAllFromHTTP()
-{
-	llassert_always(mDebuggerState == IDLE);
-	setDebuggerState(REFETCH_ALL_HTTP);
-
-	clearTextures();
-	makeRefetchList();
-	mFetcher->setLoadSource(LLTextureFetch::FROM_HTTP_ONLY);
-
-	mTimer.reset();
-	mFetcher->lockFetcher(false);
-	mRefetchAllHTTPTime = -1.f;
-	mRefetchedAllData = 0;
-	mRefetchedAllPixels = 0;
-	mRefetchNonVis = TRUE;
-}
-
-bool LLTextureFetchDebugger::update(F32 max_time)
-{
-	switch(mDebuggerState)
-	{
-	case START_DEBUG:
-		if(processStartDebug(max_time))
-		{
-			setDebuggerState(IDLE);
-		}
-		break;
-	case READ_CACHE:
-		if(!mTextureCache->update(1))
-		{
-			mCacheReadTime = mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE);
-			unlockCache();
-		}
-		break;
-	case WRITE_CACHE:
-		if(!mTextureCache->update(1))
-		{
-			mCacheWriteTime = mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE);
-			unlockCache();
-		}
-		break;
-	case DECODING:
-		if(!mImageDecodeThread->update(1))
-		{
-			mDecodingTime =  mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE);
-			unlockDecoder();
-		}
-		break;
-	case HTTP_FETCHING:
-		// Do some notifications...
-		mFetcher->getHttpRequest().update(10);
-		if (!fillCurlQueue() && mNbCurlCompleted == mFetchingHistory.size())
-		{
-			mHTTPTime =  mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE);
-		}
-		break;
-	case GL_TEX:
-		if(processGLCreation(max_time))
-		{
-			setDebuggerState(IDLE);
-			mTempTexList.clear();
-		}
-		break;
-	case REFETCH_VIS_CACHE:
-		if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
-		{
-			mRefetchVisCacheTime = mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE);
-			mFetcher->lockFetcher(true);
-			mFetcher->resetLoadSource();
-		}
-		break;
-	case REFETCH_VIS_HTTP:
-		if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
-		{
-			mRefetchVisHTTPTime = mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE);
-			mFetcher->lockFetcher(true);
-			mFetcher->resetLoadSource();
-		}
-		break;
-	case REFETCH_ALL_CACHE:
-		scanRefetchList();
-		if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
-		{
-			if(!mRefetchNonVis)
-			{
-				mRefetchNonVis = TRUE; //start to fetch non-vis
-				scanRefetchList();
-				break;
-			}
-
-			mRefetchAllCacheTime = mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE); 
-			mFetcher->lockFetcher(true);
-			mFetcher->resetLoadSource();
-			mRefetchList.clear();
-			mRefetchNonVis = FALSE;
-		}
-		break;
-	case REFETCH_ALL_HTTP:
-		scanRefetchList();
-		if (LLAppViewer::getTextureFetch()->getNumRequests() == 0)
-		{
-			mRefetchAllHTTPTime = mTimer.getElapsedTimeF32() ;
-			setDebuggerState(IDLE);
-			mFetcher->lockFetcher(true);
-			mFetcher->resetLoadSource();
-			mRefetchList.clear();
-			mRefetchNonVis = FALSE;
-		}
-		break;
-	default:
-		setDebuggerState(IDLE);
-		break;
-	}
-
-	return mDebuggerState == IDLE;
-}
-
-void LLTextureFetchDebugger::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response)
-{
-	handle_fetch_map_t::iterator iter(mHandleToFetchIndex.find(handle));
-	if (mHandleToFetchIndex.end() == iter)
-	{
-		LL_INFOS(LOG_TXT) << "Fetch Debugger : Couldn't find handle " << handle << " in fetch list." << LL_ENDL;
-		return;
-	}
-	
-	S32 fetch_ind(iter->second);
-	mHandleToFetchIndex.erase(iter);
-	if (fetch_ind >= mFetchingHistory.size() || mFetchingHistory[fetch_ind].mHttpHandle != handle)
-	{
-		LL_INFOS(LOG_TXT) << "Fetch Debugger : Handle and fetch object in disagreement.  Punting." << LL_ENDL;
-	}
-	else
-	{
-		callbackHTTP(mFetchingHistory[fetch_ind], response);
-		mFetchingHistory[fetch_ind].mHttpHandle = LLCORE_HTTP_HANDLE_INVALID;	// Not valid after notification
-	}
-}
-
-void LLTextureFetchDebugger::callbackCacheRead(S32 id, bool success, LLImageFormatted* image,
-						   S32 imagesize, BOOL islocal)
-{
-	if (success)
-	{
-		mFetchingHistory[id].mFormattedImage = image;
-	}
-	mTextureCache->readComplete(mFetchingHistory[id].mCacheHandle, false);
-	mFetchingHistory[id].mCacheHandle = LLTextureCache::nullHandle();
-}
-
-void LLTextureFetchDebugger::callbackCacheWrite(S32 id, bool success)
-{
-	mTextureCache->writeComplete(mFetchingHistory[id].mCacheHandle);
-	mFetchingHistory[id].mCacheHandle = LLTextureCache::nullHandle();
-}
-
-void LLTextureFetchDebugger::callbackDecoded(S32 id, bool success, LLImageRaw* raw, LLImageRaw* aux)
-{
-	if (success)
-	{
-		llassert_always(raw);
-		mFetchingHistory[id].mRawImage = raw;
-	}
-}
-
-void LLTextureFetchDebugger::callbackHTTP(FetchEntry & fetch, LLCore::HttpResponse * response)
-{
-	static const LLCore::HttpStatus par_status(HTTP_PARTIAL_CONTENT);
-	
-	LLCore::HttpStatus status(response->getStatus());
-	mNbCurlRequests--;
-	mNbCurlCompleted++;
-	fetch.mCurlState = FetchEntry::CURL_DONE;
-	if (status)
-	{
-		const bool partial(par_status == status);
-		LLCore::BufferArray * ba(response->getBody());	// *Not* holding reference to body
-		
-		S32 data_size = ba ? ba->size() : 0;
-		fetch.mCurlReceivedSize += data_size;
-		//LL_INFOS(LOG_TXT) << "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*)ll_aligned_malloc_16(data_size);
-			if (ba)
-			{
-				ba->read(0, d_buffer, data_size);
-			}
-			
-			llassert_always(fetch.mFormattedImage.isNull());
-			{
-				// For now, create formatted image based on extension
-				std::string texture_url = mHTTPUrl + "/?texture_id=" + fetch.mID.asString().c_str();
-				std::string extension = gDirUtilp->getExtension(texture_url);
-				fetch.mFormattedImage = LLImageFormatted::createFromType(LLImageBase::getCodecFromExtension(extension));
-				if (fetch.mFormattedImage.isNull())
-				{
-					fetch.mFormattedImage = new LLImageJ2C; // default
-				}
-			}
-						
-			fetch.mFormattedImage->setData(d_buffer, data_size);	
-		}
-	}
-	else //failed
-	{
-		LL_INFOS(LOG_TXT) << "Fetch Debugger : CURL GET FAILED,  ID = " << fetch.mID
-						  << ", status: " << status.toTerseString()
-						  << " reason:  " << status.toString() << LL_ENDL;
-	}
-}
-
-
-//---------------------
-///////////////////////////////////////////////////////////////////////////////////////////
-//End LLTextureFetchDebugger
-///////////////////////////////////////////////////////////////////////////////////////////
-
 LLTextureFetchTester::LLTextureFetchTester() : LLMetricPerformanceTesterBasic(sTesterName) 
 {
 	mTextureFetchTime = 0;
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index ff6bb8b5053..320511f343b 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -48,7 +48,6 @@ class LLTextureFetchWorker;
 class LLImageDecodeThread;
 class LLHost;
 class LLViewerAssetStats;
-class LLTextureFetchDebugger;
 class LLTextureCache;
 class LLTextureFetchTester;
 
@@ -412,10 +411,6 @@ class LLTextureFetch : public LLWorkerThread
 	static LLTextureFetchTester* sTesterp;
 
 private:
-	//debug use
-	LLTextureFetchDebugger* mFetchDebugger;
-	bool mFetcherLocked;
-	
 	e_tex_source mFetchSource;
 	e_tex_source mOriginFetchSource;
 
@@ -423,10 +418,6 @@ class LLTextureFetch : public LLWorkerThread
 	//LLAdaptiveRetryPolicy mFetchRetryPolicy;
 	
 public:
-	//debug use
-	LLTextureFetchDebugger* getFetchDebugger() { return mFetchDebugger;}
-	void lockFetcher(bool lock) { mFetcherLocked = lock;}
-
 	void setLoadSource(e_tex_source source) {mFetchSource = source;}
 	void resetLoadSource() {mFetchSource = mOriginFetchSource;}
 	bool canLoadFromCache() { return mFetchSource != FROM_HTTP_ONLY;}
@@ -434,216 +425,6 @@ class LLTextureFetch : public LLWorkerThread
 
 //debug use
 class LLViewerFetchedTexture;
-class LLTextureFetchDebugger : public LLCore::HttpHandler
-{
-	friend class LLTextureFetch;
-public:
-	LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextureCache* cache, LLImageDecodeThread* imagedecodethread) ;
-	~LLTextureFetchDebugger();
-
-public:
-	enum e_debug_state
-	{
-		IDLE = 0,
-		START_DEBUG,
-		READ_CACHE,
-		WRITE_CACHE,
-		DECODING,
-		HTTP_FETCHING,
-		GL_TEX,
-		REFETCH_VIS_CACHE,
-		REFETCH_VIS_HTTP,
-		REFETCH_ALL_CACHE,
-		REFETCH_ALL_HTTP,
-		INVALID
-	};
-
-private:	
-	struct FetchEntry
-	{
-		enum e_curl_state
-		{
-			CURL_NOT_DONE = 0,
-			CURL_IN_PROGRESS,
-			CURL_DONE
-		};
-		LLUUID mID;
-		S32 mRequestedSize;
-		S32 mDecodedLevel;
-		S32 mFetchedSize;
-		S32 mDecodedSize;
-		BOOL mNeedsAux;
-		U32 mCacheHandle;
-		LLPointer<LLImageFormatted> mFormattedImage;
-		LLPointer<LLImageRaw> mRawImage;
-		e_curl_state mCurlState;
-		S32 mCurlReceivedSize;
-		LLCore::HttpHandle mHttpHandle;
-
-		FetchEntry() :
-			mDecodedLevel(-1),
-			mFetchedSize(0),
-			mDecodedSize(0),
-			mHttpHandle(LLCORE_HTTP_HANDLE_INVALID)
-			{}
-		FetchEntry(LLUUID& id, S32 r_size, /*S32 f_discard, S32 c,*/ S32 level, S32 f_size, S32 d_size) :
-			mID(id),
-			mRequestedSize(r_size),
-			mDecodedLevel(level),
-			mFetchedSize(f_size),
-			mDecodedSize(d_size),
-			mNeedsAux(false),
-			mHttpHandle(LLCORE_HTTP_HANDLE_INVALID)
-			{}
-	};
-	typedef std::vector<FetchEntry> fetch_list_t;
-	fetch_list_t mFetchingHistory;
-
-	typedef std::map<LLCore::HttpHandle, S32> handle_fetch_map_t;
-	handle_fetch_map_t mHandleToFetchIndex;
-
-	void setDebuggerState(e_debug_state new_state) { mDebuggerState = new_state; }
-	e_debug_state mDebuggerState;
-	
-	F32 mCacheReadTime;
-	F32 mCacheWriteTime;
-	F32 mDecodingTime;
-	F32 mHTTPTime;
-	F32 mGLCreationTime;
-
-	F32 mTotalFetchingTime;
-	F32 mRefetchVisCacheTime;
-	F32 mRefetchVisHTTPTime;
-	F32 mRefetchAllCacheTime;
-	F32 mRefetchAllHTTPTime;
-
-	LLTimer mTimer;
-	
-	LLTextureFetch* mFetcher;
-	LLTextureCache* mTextureCache;
-	LLImageDecodeThread* mImageDecodeThread;
-	LLCore::HttpHeaders::ptr_t mHttpHeaders;
-	LLCore::HttpRequest::policy_t mHttpPolicyClass;
-	
-	S32 mNumFetchedTextures;
-	S32 mNumCacheHits;
-	S32 mNumVisibleFetchedTextures;
-	S32 mNumVisibleFetchingRequests;
-	U32 mFetchedData;
-	U32 mDecodedData;
-	U32 mVisibleFetchedData;
-	U32 mVisibleDecodedData;
-	U32 mRenderedData;
-	U32 mRenderedDecodedData;
-	U32 mFetchedPixels;
-	U32 mRenderedPixels;
-	U32 mRefetchedVisData;
-	U32 mRefetchedVisPixels;
-	U32 mRefetchedAllData;
-	U32 mRefetchedAllPixels;
-
-	BOOL mFreezeHistory;
-	BOOL mStopDebug;
-	BOOL mClearHistory;
-	BOOL mRefetchNonVis;
-
-	std::string mHTTPUrl;
-	S32 mNbCurlRequests;
-	S32 mNbCurlCompleted;
-
-	std::map< LLPointer<LLViewerFetchedTexture>, std::vector<S32> > mRefetchList; // treats UI textures as normal textures
-	std::vector< LLPointer<LLViewerFetchedTexture> > mTempTexList;
-	S32 mTempIndex;
-	S32 mHistoryListIndex;
-
-public:
-	bool update(F32 max_time); //called in the main thread once per frame
-
-	//fetching history
-	void clearHistory();
-	void addHistoryEntry(LLTextureFetchWorker* worker);
-	
-	// Inherited from LLCore::HttpHandler
-	// Threads:  Ttf
-	virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response);
-
-	void startWork(e_debug_state state);
-	void setStopDebug() {mStopDebug = TRUE;}
-	void tryToStopDebug(); //stop everything
-	void callbackCacheRead(S32 id, bool success, LLImageFormatted* image,
-						   S32 imagesize, BOOL islocal);
-	void callbackCacheWrite(S32 id, bool success);
-	void callbackDecoded(S32 id, bool success, LLImageRaw* raw, LLImageRaw* aux);
-	void callbackHTTP(FetchEntry & fetch, LLCore::HttpResponse * response);
-
-	e_debug_state getState()             {return mDebuggerState;}
-	S32  getNumFetchedTextures()         {return mNumFetchedTextures;}
-	S32  getNumFetchingRequests()        {return mFetchingHistory.size();}
-	S32  getNumCacheHits()               {return mNumCacheHits;}
-	S32  getNumVisibleFetchedTextures()  {return mNumVisibleFetchedTextures;}
-	S32  getNumVisibleFetchingRequests() {return mNumVisibleFetchingRequests;}
-	U32  getFetchedData()                {return mFetchedData;}
-	U32  getDecodedData()                {return mDecodedData;}
-	U32  getVisibleFetchedData()         {return mVisibleFetchedData;}
-	U32  getVisibleDecodedData()         {return mVisibleDecodedData;}
-	U32  getRenderedData()               {return mRenderedData;}
-	U32  getRenderedDecodedData()        {return mRenderedDecodedData;}
-	U32  getFetchedPixels()              {return mFetchedPixels;}
-	U32  getRenderedPixels()             {return mRenderedPixels;}
-	U32  getRefetchedVisData()              {return mRefetchedVisData;}
-	U32  getRefetchedVisPixels()            {return mRefetchedVisPixels;}
-	U32  getRefetchedAllData()              {return mRefetchedAllData;}
-	U32  getRefetchedAllPixels()            {return mRefetchedAllPixels;}
-
-	F32  getCacheReadTime()     {return mCacheReadTime;}
-	F32  getCacheWriteTime()    {return mCacheWriteTime;}
-	F32  getDecodeTime()        {return mDecodingTime;}
-	F32  getGLCreationTime()    {return mGLCreationTime;}
-	F32  getHTTPTime()          {return mHTTPTime;}
-	F32  getTotalFetchingTime() {return mTotalFetchingTime;}
-	F32  getRefetchVisCacheTime() {return mRefetchVisCacheTime;}
-	F32  getRefetchVisHTTPTime()  {return mRefetchVisHTTPTime;}
-	F32  getRefetchAllCacheTime() {return mRefetchAllCacheTime;}
-	F32  getRefetchAllHTTPTime()  {return mRefetchAllHTTPTime;}
-
-private:
-	void init();
-	void clearTextures();//clear fetching results of all textures.
-	void clearCache();
-	void makeRefetchList();
-	void scanRefetchList();
-
-	void lockFetcher();
-	void unlockFetcher();
-
-	void lockCache();
-	void unlockCache();
-
-	void lockDecoder();
-	void unlockDecoder();
-	
-	S32 fillCurlQueue();
-
-	void startDebug();
-	void debugCacheRead();
-	void debugCacheWrite();	
-	void debugHTTP();
-	void debugDecoder();
-	void debugGLTextureCreation();
-	void debugRefetchVisibleFromCache();
-	void debugRefetchVisibleFromHTTP();
-	void debugRefetchAllFromCache();
-	void debugRefetchAllFromHTTP();
-
-	bool processStartDebug(F32 max_time);
-	bool processGLCreation(F32 max_time);
-
-private:
-	static bool sDebuggerEnabled;
-public:
-	static bool isEnabled() {return sDebuggerEnabled;}
-};
-
 
 class LLTextureFetchTester : public LLMetricPerformanceTesterBasic
 {
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index dd03d6cfdd6..5a3a3581733 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -132,7 +132,6 @@
 #include "llfloatertelehub.h"
 #include "llfloatertestinspectors.h"
 #include "llfloatertestlistview.h"
-#include "llfloatertexturefetchdebugger.h"
 #include "llfloatertools.h"
 #include "llfloatertopobjects.h"
 #include "llfloatertos.h"
@@ -283,10 +282,6 @@ void LLViewerFloaterReg::registerFloaters()
 	
 	LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>);
 
-	if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
-	{
-		LLFloaterReg::add("tex_fetch_debugger", "floater_texture_fetch_debugger.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTextureFetchDebugger>);
-	}
 	LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMediaSettings>);	
 	LLFloaterReg::add("marketplace_listings", "floater_marketplace_listings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceListings>);
 	LLFloaterReg::add("marketplace_validation", "floater_marketplace_validation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceValidation>);
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index e3de4267dc4..d95948ac043 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2519,14 +2519,6 @@ class LLDevelopSetLoggingLevel : public view_listener_t
 	}
 };
 
-class LLDevelopTextureFetchDebugger : public view_listener_t
-{
-	bool handleEvent(const LLSD& userdata)
-	{
-		return gSavedSettings.getBOOL("TextureFetchDebuggerEnabled");
-	}
-};
-
 //////////////////
 // ADMIN MENU   //
 //////////////////
@@ -9398,8 +9390,6 @@ void initialize_menus()
 	view_listener_t::addMenu(new LLDevelopCheckLoggingLevel(), "Develop.CheckLoggingLevel");
 	view_listener_t::addMenu(new LLDevelopSetLoggingLevel(), "Develop.SetLoggingLevel");
 	
-	//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) );
 
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 71526e5e8c5..57d52ae9ee4 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -316,8 +316,6 @@ U32Bytes			gTotalTextureBytesPerBoostLevel[LLViewerTexture::MAX_GL_IMAGE_CATEGOR
 extern U32  gVisCompared;
 extern U32  gVisTested;
 
-LLFrameTimer gTextureTimer;
-
 void update_statistics()
 {
 	gTotalWorldData += gVLManager.getTotalBytes();
@@ -413,19 +411,6 @@ void update_statistics()
 	}
 }
 
-void update_texture_time()
-{
-	if (gTextureList.isPrioRequestsFetched())
-	{
-		gTextureTimer.pause();
-	}
-	else
-	{		
-		gTextureTimer.unpause();
-	}
-
-	record(LLStatViewer::TEXTURE_FETCH_TIME, gTextureTimer.getElapsedTimeF32());
-}
 /*
  * The sim-side LLSD is in newsim/llagentinfo.cpp:forwardViewerStats.
  *
diff --git a/indra/newview/llviewerstats.h b/indra/newview/llviewerstats.h
index 8d1182d0541..c21c06256ea 100644
--- a/indra/newview/llviewerstats.h
+++ b/indra/newview/llviewerstats.h
@@ -294,7 +294,6 @@ void update_statistics();
 void send_viewer_stats(bool include_preferences);
 void update_texture_time();
 
-extern LLFrameTimer gTextureTimer;
 extern U32Bytes	gTotalTextureData;
 extern U32Bytes  gTotalObjectData;
 extern U32Bytes  gTotalTextureBytesPerBoostLevel[] ;
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index b8de5d34ebc..0544bceb9f6 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -463,11 +463,6 @@ void LLViewerTextureManager::cleanup()
 void LLViewerTexture::initClass()
 {
 	LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture();
-	
-	if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
-	{
-		sTexelPixelRatio = gSavedSettings.getF32("TexelPixelRatio");
-	}
 }
 
 // tuning params
@@ -4014,7 +4009,6 @@ void LLTexturePipelineTester::compareTestSessions(llofstream* os)
 	*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, "TotalStablizingTime", base_sessionp->mTotalStablizingTime, current_sessionp->mTotalStablizingTime);
 	compareTestResults(os, "StartTimeLoadingSculpties", base_sessionp->mStartTimeLoadingSculpties, current_sessionp->mStartTimeLoadingSculpties);		
@@ -4074,7 +4068,6 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
 		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;
@@ -4109,7 +4102,6 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
 		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;
 
@@ -4117,14 +4109,12 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
 			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;
 		}
 		else
 		{
-			total_fetching_time = cur_time - start_time;
 			total_gray_time = (*log)[label]["TotalGrayTime"].asReal();
 			total_stablizing_time = (*log)[label]["TotalStablizingTime"].asReal();
 
@@ -4170,7 +4160,6 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo
 		in_log = (*log).has(currentLabel);
 	}
 
-	sessionp->mTotalFetchingTime += total_fetching_time;
 	sessionp->mTotalGrayTime += total_gray_time;
 	sessionp->mTotalStablizingTime += total_stablizing_time;
 
@@ -4192,8 +4181,6 @@ LLTexturePipelineTester::LLTextureTestSession::~LLTextureTestSession()
 }
 void LLTexturePipelineTester::LLTextureTestSession::reset() 
 {
-	mTotalFetchingTime = 0.0f;
-
 	mTotalGrayTime = 0.0f;
 	mTotalStablizingTime = 0.0f;
 
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 49d030bcb84..a5e5c37c22e 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -763,7 +763,6 @@ class LLTexturePipelineTester : public LLMetricPerformanceTesterWithSession
 
 		void reset() ;
 
-		F32 mTotalFetchingTime ;
 		F32 mTotalGrayTime ;
 		F32 mTotalStablizingTime ;
 		F32 mStartTimeLoadingSculpties ; 
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index 71a5de11761..555355059a7 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -196,10 +196,8 @@ static std::string get_texture_list_name()
 void LLViewerTextureList::doPrefetchImages()
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
-	gTextureTimer.start();
-	gTextureTimer.pause();
 
-	if (LLAppViewer::instance()->getPurgeCache())
+    if (LLAppViewer::instance()->getPurgeCache())
 	{
 		// cache was purged, no point
 		return;
@@ -784,8 +782,6 @@ void LLViewerTextureList::updateImages(F32 max_time)
 	//loading from fast cache 
 	max_time -= updateImagesLoadingFastCache(max_time);
 	
-	updateImagesDecodePriorities();
-	
     F32 total_max_time = max_time;
 
 	max_time -= updateImagesFetchTextures(max_time);
@@ -838,32 +834,6 @@ void LLViewerTextureList::clearFetchingRequests()
 	}
 }
 
-void LLViewerTextureList::updateImagesDecodePriorities()
-{
-#if 0
-    LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
-    // 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.value()) + 1, MAX_PRIO_UPDATES);
-    S32 update_counter = llmin(max_update_count, mUUIDMap.size());
-    uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateKey);*/
-    //while ((update_counter-- > 0) && !mUUIDMap.empty())
-    for (uuid_map_t::iterator iter = mUUIDMap.begin(); iter != mUUIDMap.end(); ++iter)
-    {
-        /*if (iter == mUUIDMap.end())
-        {
-            iter = mUUIDMap.begin();
-        }*/
-        mLastUpdateKey = iter->first;
-        LLPointer<LLViewerFetchedTexture> imagep = iter->second;
-        //++iter; // safe to increment now
-
-        updateImageDecodePriority(imagep);
-    }
-#endif
-}
-
 void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep)
 {
     if (imagep->isInDebug() || imagep->isUnremovable())
@@ -1058,102 +1028,29 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
     typedef std::vector<LLViewerFetchedTexture*> entries_list_t;
     entries_list_t entries;
 
-	// Update fetch for N images each frame
-#if 0
-	static const S32 MAX_UPDATE_COUNT = gSavedSettings.getS32("TextureFetchUpdateMaxMediumPriority");       // default: 256
-	
-	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.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.value())+1, MAX_UPDATE_COUNT);
-	max_update_count = llmin(max_update_count, total_update_count);	
-	
-	// MAX_HIGH_PRIO_COUNT high priority entries
-	
-	//size_t update_counter = max_priority_count;
-    size_t update_counter = mImageList.size();
-	image_priority_list_t::iterator iter1 = mImageList.begin();
-	while(update_counter > 0)
-	{
-		entries.push_back(*iter1);
-		
-		++iter1;
-		update_counter--;
-	}
-	
-	// MAX_UPDATE_COUNT cycled entries
-	update_counter = max_update_count;
-	if(update_counter > 0)
-	{
-		uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchKey);
-		while ((update_counter > 0) && (total_update_count > 0))
-		{
-			if (iter2 == mUUIDMap.end())
-			{
-				iter2 = mUUIDMap.begin();
-			}
-			LLViewerFetchedTexture* imagep = iter2->second;
-            // Skip the textures where there's really nothing to do so to give some times to others. Also skip the texture if it's already in the high prio set.
-            if (!SKIP_LOW_PRIO || (SKIP_LOW_PRIO && ((imagep->getDecodePriority() > MIN_PRIORITY_THRESHOLD) || imagep->hasFetcher())))
-            {
-                entries.push_back(imagep);
-                update_counter--;
-            }
-
-			iter2++;
-			total_update_count--;
-		}
-	}
-	
-	S32 fetch_count = 0;
-	//size_t min_update_count = llmin(MIN_UPDATE_COUNT,(S32)(entries.size()-max_priority_count));
-	//S32 min_count = max_priority_count + min_update_count;
-	for (entries_list_t::iterator iter3 = entries.begin();
-		 iter3 != entries.end(); )
-	{
-		LLViewerFetchedTexture* imagep = *iter3++;
-        updateImageDecodePriority(imagep);
-		fetch_count += (imagep->updateFetch() ? 1 : 0);
-		//if (min_count <= min_update_count)
-		{
-			mLastFetchKey = LLTextureKey(imagep->getID(), (ETexListType)imagep->getTextureListType());
-		}
-		/*if ((min_count-- <= 0) && (image_op_timer.getElapsedTimeF32() > max_time))
-		{
-			break;
-		}*/
-	}
-#else
-
     // update N textures at beginning of mImageList
     U32 update_count = 0;
-
-    /*for (auto& imagep : mImageList)
-    {
-        if (update_count++ > MAX_HIGH_PRIO_COUNT)
-        {
-            break;
-        }
-
-        entries.push_back(imagep);
-    }*/
-
+    static const S32 MIN_UPDATE_COUNT = gSavedSettings.getS32("TextureFetchUpdateMinCount");       // default: 32
     // WIP -- dumb code here
     //update MIN_UPDATE_COUNT or 10% of other textures, whichever is greater
-    //update_count = llmax((U32) MIN_UPDATE_COUNT, (U32) mUUIDMap.size()/10);
-    //update_count = llmin(update_count, (U32) mUUIDMap.size());
-    update_count -= mUUIDMap.size();
-
-    entries.reserve(update_count);
-    //uuid_map_t::iterator iter2 = mUUIDMap.upper_bound(mLastFetchKey);
-    //while (update_count-- > 0)
-    for (auto iter2 = mUUIDMap.begin(); iter2 != mUUIDMap.end(); ++iter2)
+    update_count = llmax((U32) MIN_UPDATE_COUNT, (U32) mUUIDMap.size()/10);
+    update_count = llmin(update_count, (U32) mUUIDMap.size());
+    
     {
-        entries.push_back(iter2->second);
+        LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vtluift - copy");
+
+        // copy entries out of UUID map for updating
+        entries.reserve(update_count);
+        uuid_map_t::iterator iter = mUUIDMap.upper_bound(mLastUpdateKey);
+        while (update_count-- > 0)
+        {
+            if (iter == mUUIDMap.end())
+            {
+                iter = mUUIDMap.begin();
+            }
+            entries.push_back(iter->second);
+            ++iter;
+        }
     }
 
     for (auto* imagep : entries)
@@ -1165,10 +1062,9 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
     if (entries.size() > 0)
     {
         LLViewerFetchedTexture* imagep = *entries.rbegin();
-        mLastFetchKey = LLTextureKey(imagep->getID(), (ETexListType)imagep->getTextureListType());
+        mLastUpdateKey = LLTextureKey(imagep->getID(), (ETexListType)imagep->getTextureListType());
     }
 
-#endif
 	return image_op_timer.getElapsedTimeF32();
 }
 
@@ -1350,33 +1246,6 @@ LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImage
 	return compressedImage;
 }
 
-bool LLViewerTextureList::isPrioRequestsFetched()
-{
-	static LLCachedControl<F32> prio_threshold(gSavedSettings, "TextureFetchUpdatePriorityThreshold", 0.0f);
-	static LLCachedControl<F32> fetching_textures_threshold(gSavedSettings, "TextureListFetchingThreshold", 0.97f);
-	S32 fetching_tex_count = 0;
-	S32 tex_count_threshold = gTextureList.mImageList.size() * (1 - fetching_textures_threshold);
-
-	for (LLViewerTextureList::image_priority_list_t::iterator iter = gTextureList.mImageList.begin();
-		iter != gTextureList.mImageList.end(); )
-	{
-		LLPointer<LLViewerFetchedTexture> imagep = *iter++;
-		if (imagep->getMaxVirtualSize() > prio_threshold)
-		{
-			if (imagep->hasFetcher() || imagep->isFetching())
-			{
-				fetching_tex_count++;
-				if (fetching_tex_count >= tex_count_threshold)
-				{
-					return false;
-				}
-			}
-		}
-	}
-
-	return true;
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 // static
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 8d70add7927..bd60c990b5e 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -132,11 +132,7 @@ class LLViewerTextureList
 	void clearFetchingRequests();
 	void setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level);
 
-	static bool isPrioRequestsFetched();
-	
 private:
-	void updateImagesDecodePriorities();
-
     // do some book keeping on the specified texture
     // - updates decode priority
     // - updates desired discard level
@@ -214,7 +210,6 @@ class LLViewerTextureList
     typedef std::map< LLTextureKey, LLPointer<LLViewerFetchedTexture> > uuid_map_t;
     uuid_map_t mUUIDMap;
     LLTextureKey mLastUpdateKey;
-    LLTextureKey mLastFetchKey;
 	
     typedef std::set < LLPointer<LLViewerFetchedTexture> > image_priority_list_t;
 	image_priority_list_t mImageList;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 65010f19855..e27b5caab77 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -493,24 +493,12 @@ class LLDebugText
 		
 		if (gSavedSettings.getBOOL("DebugShowTime"))
 		{
-			{
-			const U32 y_inc2 = 15;
-				LLFrameTimer& timer = gTextureTimer;
-				F32 time = timer.getElapsedTimeF32();
-				S32 hours = (S32)(time / (60*60));
-				S32 mins = (S32)((time - hours*(60*60)) / 60);
-				S32 secs = (S32)((time - hours*(60*60) - mins*60));
-				addText(xpos, ypos, llformat("Texture: %d:%02d:%02d", hours,mins,secs)); ypos += y_inc2;
-			}
-			
-			{
 			F32 time = gFrameTimeSeconds;
 			S32 hours = (S32)(time / (60*60));
 			S32 mins = (S32)((time - hours*(60*60)) / 60);
 			S32 secs = (S32)((time - hours*(60*60) - mins*60));
 			addText(xpos, ypos, llformat("Time: %d:%02d:%02d", hours,mins,secs)); ypos += y_inc;
 		}
-		}
 		
 		if (gSavedSettings.getBOOL("DebugShowMemory"))
 		{
diff --git a/indra/newview/skins/default/xui/en/floater_texture_fetch_debugger.xml b/indra/newview/skins/default/xui/en/floater_texture_fetch_debugger.xml
deleted file mode 100644
index 9278a1a5982..00000000000
--- a/indra/newview/skins/default/xui/en/floater_texture_fetch_debugger.xml
+++ /dev/null
@@ -1,440 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<floater
- legacy_header_height="18"
- can_minimize="false"
- height="600"
- layout="topleft"
- name="TexFetchDebugger"
- help_topic="texfetchdebugger"
- title="Texture Fetching Debugger"
- width="540">
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left="10"
-   name="total_num_fetched_label"
-   top="30"
-   width="400">
-    1, Total number of fetched textures: [NUM]
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_num_fetching_requests_label"
-   top_delta="25"
-   width="400">
-    2, Total number of fetching requests: [NUM]
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_num_cache_hits_label"
-   top_delta="25"
-   width="400">
-    3, Total number of cache hits: [NUM]
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_num_visible_tex_label"
-   top_delta="25"
-   width="400">
-    4, Total number of visible textures: [NUM]
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_num_visible_tex_fetch_req_label"
-   top_delta="25"
-   width="450">
-    5, Total number of visible texture fetching requests: [NUM]
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_fetched_data_label"
-   top_delta="25"
-   width="530">
-    6, Total number of fetched data: [SIZE1]KB, Decoded Data: [SIZE2]KB, [PIXEL]MPixels
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_fetched_vis_data_label"
-   top_delta="25"
-   width="480">
-    7, Total number of visible data: [SIZE1]KB, Decoded Data: [SIZE2]KB
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_fetched_rendered_data_label"
-   top_delta="25"
-   width="530">
-    8, Total number of rendered data: [SIZE1]KB, Decoded Data: [SIZE2]KB, [PIXEL]MPixels
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_time_cache_read_label"
-   top_delta="25"
-   width="400">
-    9, Total time on cache readings: [TIME] seconds
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_time_cache_write_label"
-   top_delta="25"
-   width="400">
-    10, Total time on cache writings: [TIME] seconds
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_time_decode_label"
-   top_delta="25"
-   width="400">
-    11, Total time on decodings: [TIME] seconds
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_time_gl_label"
-   top_delta="25"
-   width="400">
-    12, Total time on gl texture creation: [TIME] seconds
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_time_http_label"
-   top_delta="25"
-   width="400">
-    13, Total time on HTTP fetching: [TIME] seconds
-  </text>
-  <text
-   type="string"
-   length="1"
-   follows="left|top"
-   height="25"
-   layout="topleft"
-   left_delta="0"
-   name="total_time_fetch_label"
-   top_delta="25"
-   width="400">
-    14, Total time on entire fetching: [TIME] seconds
-  </text>
-  <text
-  type="string"
-  length="1"
-  follows="left|top"
-  height="25"
-  layout="topleft"
-  left_delta="0"
-  name="total_time_refetch_vis_cache_label"
-  top_delta="25"
-  width="540">
-    15, Refetching visibles from cache, Time: [TIME] seconds, Fetched: [SIZE]KB, [PIXEL]MPixels
-  </text>
-  <text
-  type="string"
-  length="1"
-  follows="left|top"
-  height="25"
-  layout="topleft"
-  left_delta="0"
-  name="total_time_refetch_all_cache_label"
-  top_delta="25"
-  width="540">
-    16, Refetching all textures from cache, Time: [TIME] seconds, Fetched: [SIZE]KB, [PIXEL]MPixels
-  </text>
-  <text
-  type="string"
-  length="1"
-  follows="left|top"
-  height="25"
-  layout="topleft"
-  left_delta="0"
-  name="total_time_refetch_vis_http_label"
-  top_delta="25"
-  width="540">
-    17, Refetching visibles from HTTP, Time: [TIME] seconds, Fetched: [SIZE]KB, [PIXEL]MPixels
-  </text>
-  <text
-  type="string"
-  length="1"
-  follows="left|top"
-  height="25"
-  layout="topleft"
-  left_delta="0"
-  name="total_time_refetch_all_http_label"
-  top_delta="25"
-  width="540">
-    18, Refetching all textures from HTTP, Time: [TIME] seconds, Fetched: [SIZE]KB, [PIXEL]MPixels
-  </text>
-  <spinner
-     decimal_digits="2"
-     follows="left|top"
-     height="20"
-     increment="0.01"
-     initial_value="1.0"
-     label="19, Ratio of Texel/Pixel:"
-     label_width="130"
-     layout="topleft"
-     left_delta="0"
-     max_val="10.0"
-     min_val="0.01"
-     name="texel_pixel_ratio"
-     top_delta="30"
-     width="200">
-    <spinner.commit_callback
-		function="TexFetchDebugger.ChangeTexelPixelRatio" />
-  </spinner>
-  <text
-  type="string"
-  length="1"
-  follows="left|top"
-  height="25"
-  layout="topleft"
-  left_delta="0"
-  name="texture_source_label"
-  top_delta="30"
-  width="110">
-    20, Texture Source:
-  </text>
-  <radio_group
-     control_name="TextureFetchSource"
-     follows="top|left"
-     draw_border="false"
-     height="25"
-     layout="topleft"
-     left_pad="0"
-     name="texture_source"
-     top_delta="0"
-     width="264">
-    <radio_item
-     height="16"
-     label="Cache + HTTP"
-     layout="topleft"
-     left="3"
-     name="0"
-     top="0"
-     width="100" />
-    <radio_item
-     height="16"
-     label="HTTP Only"
-     layout="topleft"
-     left_delta="100"
-     name="1"
-     top_delta="0"
-     width="200" />
-  </radio_group>
-  <button
-   follows="left|top"
-   height="20"
-   label="Start"
-   layout="topleft"
-   left="10"
-   name="start_btn"
-   top_delta="20"
-   width="70">
-    <button.commit_callback
-		function="TexFetchDebugger.Start" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Reset"
-   layout="topleft"
-   left_pad="7"
-   name="clear_btn"
-   top_delta="0"
-   width="70">
-    <button.commit_callback
-		function="TexFetchDebugger.Clear" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Close"
-   layout="topleft"
-   left_pad="7"
-   name="close_btn"
-   top_delta="0"
-   width="70">
-    <button.commit_callback
-		function="TexFetchDebugger.Close" />
-  </button>
-  <button
-   follows="left|top"
-   height="22"
-   label="Reset Fetching Time"
-   layout="topleft"
-   left_pad="175"
-   name="reset_time_btn"
-   top_delta="0"
-   width="120">
-    <button.commit_callback
-		function="TexFetchDebugger.ResetFetchTime" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Cache Read"
-   layout="topleft"
-   left="10"
-   name="cacheread_btn"
-   top_delta="20"
-   width="80">
-    <button.commit_callback
-		function="TexFetchDebugger.CacheRead" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Cache Write"
-   layout="topleft"
-   left_pad="7"
-   name="cachewrite_btn"
-   top_delta="0"
-   width="80">
-    <button.commit_callback
-		function="TexFetchDebugger.CacheWrite" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="HTTP"
-   layout="topleft"
-   left_pad="7"
-   name="http_btn"
-   top_delta="0"
-   width="70">
-    <button.commit_callback
-		function="TexFetchDebugger.HTTPLoad" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Decode"
-   layout="topleft"
-   left_pad="7"
-   name="decode_btn"
-   top_delta="0"
-   width="70">
-    <button.commit_callback
-		function="TexFetchDebugger.Decode" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="GL Texture"
-   layout="topleft"
-   left_pad="7"
-   name="gl_btn"
-   top_delta="0"
-   width="70">
-    <button.commit_callback
-		function="TexFetchDebugger.GLTexture" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Refetch Vis Cache"
-   layout="topleft"
-   left="10"
-   name="refetchviscache_btn"
-   top_delta="20"
-   width="120">
-    <button.commit_callback
-		function="TexFetchDebugger.RefetchVisCache" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Refetch All Cache"
-   layout="topleft"
-   left_pad="7"
-   name="refetchallcache_btn"
-   top_delta="0"
-   width="120">
-    <button.commit_callback
-		function="TexFetchDebugger.RefetchAllCache" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Refetch Vis HTTP"
-   layout="topleft"
-   left_pad="7"
-   name="refetchvishttp_btn"
-   top_delta="0"
-   width="120">
-    <button.commit_callback
-		function="TexFetchDebugger.RefetchVisHTTP" />
-  </button>
-  <button
-   follows="left|top"
-   height="20"
-   label="Refetch All HTTP"
-   layout="topleft"
-   left_pad="7"
-   name="refetchallhttp_btn"
-   top_delta="0"
-   width="120">
-    <button.commit_callback
-		function="TexFetchDebugger.RefetchAllHTTP" />
-  </button>
-</floater>
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 8d7cfe1116f..85c20268d0b 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -2438,20 +2438,6 @@ function="World.EnvPreset"
                function="Advanced.ToggleConsole"
                parameter="scene monitor" />
             </menu_item_check>
-            <menu_item_call
-              enabled="false"
-              visible="false"
-              label="Texture Fetch Debug Console"
-              name="Texture Fetch Debug Console">
-              <menu_item_call.on_click
-                function="Floater.Show"
-                parameter="tex_fetch_debugger" />
-              <on_enable
-                function="Develop.SetTexFetchDebugger" />
-              <on_visible
-                function="Develop.SetTexFetchDebugger" />
-            </menu_item_call>
-          
             <menu_item_separator/>
 
             <menu_item_call
-- 
GitLab