From 062be76dd515d3c6630c0a2c8ff953ef22ff3a0d Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 15 Dec 2017 12:43:54 +0000
Subject: [PATCH] MAINT-4354 Render stalls in object heavy regions

---
 indra/newview/llviewerobjectlist.cpp  | 10 +++++++---
 indra/newview/llviewertexturelist.cpp |  5 +----
 indra/newview/llviewertexturelist.h   |  3 ---
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 3c83e3a006..fede9a792f 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -732,9 +732,9 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 	S32 num_updates, max_value;
 	if (NUM_BINS - 1 == mCurBin)
 	{
+		// Remainder (mObjects.size() could have changed)
 		num_updates = (S32) mObjects.size() - mCurLazyUpdateIndex;
 		max_value = (S32) mObjects.size();
-		gTextureList.setUpdateStats(TRUE);
 	}
 	else
 	{
@@ -791,10 +791,14 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 	mCurLazyUpdateIndex = max_value;
 	if (mCurLazyUpdateIndex == mObjects.size())
 	{
+		// restart
 		mCurLazyUpdateIndex = 0;
+		mCurBin = 0; // keep in sync with index (mObjects.size() could have changed)
+	}
+	else
+	{
+		mCurBin = (mCurBin + 1) % NUM_BINS;
 	}
-
-	mCurBin = (mCurBin + 1) % NUM_BINS;
 
 	LLVOAvatar::cullAvatarsByPixelArea();
 }
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index d7080051da..fb8e897dbd 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -92,7 +92,6 @@ LLTextureKey::LLTextureKey(LLUUID id, ETexListType tex_type)
 
 LLViewerTextureList::LLViewerTextureList() 
 	: mForceResetTextureStats(FALSE),
-	mUpdateStats(FALSE),
 	mMaxResidentTexMemInMegaBytes(0),
 	mMaxTotalTextureMemInMegaBytes(0),
 	mInitialized(FALSE)
@@ -103,7 +102,6 @@ void LLViewerTextureList::init()
 {			
 	mInitialized = TRUE ;
 	sNumImages = 0;
-	mUpdateStats = TRUE;
 	mMaxResidentTexMemInMegaBytes = (U32Bytes)0;
 	mMaxTotalTextureMemInMegaBytes = (U32Bytes)0;
 	
@@ -1171,7 +1169,7 @@ F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time)
 
 void LLViewerTextureList::updateImagesUpdateStats()
 {
-	if (mUpdateStats && mForceResetTextureStats)
+	if (mForceResetTextureStats)
 	{
 		for (image_priority_list_t::iterator iter = mImageList.begin();
 			 iter != mImageList.end(); )
@@ -1179,7 +1177,6 @@ void LLViewerTextureList::updateImagesUpdateStats()
 			LLViewerFetchedTexture* imagep = *iter++;
 			imagep->resetTextureStats();
 		}
-		mUpdateStats = FALSE;
 		mForceResetTextureStats = FALSE;
 	}
 }
diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h
index 070544063a..281d23c671 100644
--- a/indra/newview/llviewertexturelist.h
+++ b/indra/newview/llviewertexturelist.h
@@ -124,8 +124,6 @@ public:
 
 	void handleIRCallback(void **data, const S32 number);
 
-	void setUpdateStats(BOOL b)			{ mUpdateStats = b; }
-
 	S32Megabytes	getMaxResidentTexMem() const	{ return mMaxResidentTexMemInMegaBytes; }
 	S32Megabytes getMaxTotalTextureMem() const   { return mMaxTotalTextureMemInMegaBytes;}
 	S32 getNumImages()					{ return mImageList.size(); }
@@ -224,7 +222,6 @@ private:
 	std::set<LLPointer<LLViewerFetchedTexture> > mImagePreloads;
 
 	BOOL mInitialized ;
-	BOOL mUpdateStats;
 	S32Megabytes	mMaxResidentTexMemInMegaBytes;
 	S32Megabytes mMaxTotalTextureMemInMegaBytes;
 	LLFrameTimer mForceDecodeTimer;
-- 
GitLab