From c9f893b1003b2d9db01362430dbbfa59a91d4fd7 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Wed, 31 Aug 2022 11:36:00 -0500
Subject: [PATCH] SL-18065 WIP -- Adjust max virtual size to keep debug floater
 readable.  Make assert on shutdown less frequent (still not gone, likely race
 condition).  Fix unrelated assertion in reflection probes.

---
 indra/newview/llappviewer.cpp            | 8 ++++++--
 indra/newview/llreflectionmapmanager.cpp | 3 ++-
 indra/newview/llviewertexture.cpp        | 5 ++---
 indra/newview/llviewertexture.h          | 1 -
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 0e2828332ea..6ca35684d96 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2068,8 +2068,12 @@ bool LLAppViewer::cleanup()
 	//MUST happen AFTER SUBSYSTEM_CLEANUP(LLCurl)
 	delete sTextureCache;
     sTextureCache = NULL;
-	delete sTextureFetch;
-    sTextureFetch = NULL;
+    if (sTextureFetch)
+    {
+        sTextureFetch->shutdown();
+        delete sTextureFetch;
+        sTextureFetch = NULL;
+    }
 	delete sImageDecodeThread;
     sImageDecodeThread = NULL;
 	delete mFastTimerLogThread;
diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp
index b285cc531ec..d349b7e0242 100644
--- a/indra/newview/llreflectionmapmanager.cpp
+++ b/indra/newview/llreflectionmapmanager.cpp
@@ -166,7 +166,7 @@ void LLReflectionMapManager::update()
 
         if (realtime && 
             closestDynamic == nullptr && 
-            probe->mCubeArray.notNull() &&
+            probe->mCubeIndex != -1 &&
             probe->getIsDynamic())
         {
             closestDynamic = probe;
@@ -324,6 +324,7 @@ S32 LLReflectionMapManager::allocateCubeIndex()
         {
             S32 ret = mProbes[i]->mCubeIndex;
             mProbes[i]->mCubeIndex = -1;
+            mProbes[i]->mCubeArray = nullptr;
             return ret;
         }
     }
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index 0c23214b521..62e5fedb7dc 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -78,7 +78,7 @@ LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL;
 LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = NULL;
 LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap;
 LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL;
-F32 LLViewerFetchedTexture::sMaxVirtualSize = F32_MAX/2.f;
+F32 LLViewerFetchedTexture::sMaxVirtualSize = 8192.f*8192.f;
 
 const std::string sTesterName("TextureTester");
 
@@ -99,7 +99,6 @@ U32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256.
 U32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA;
 bool LLViewerTexture::sFreezeImageUpdates = false;
 F32 LLViewerTexture::sCurrentTime = 0.0f;
-F32  LLViewerTexture::sTexelPixelRatio = 1.0f;
 
 LLViewerTexture::EDebugTexels LLViewerTexture::sDebugTexelsMode = LLViewerTexture::DEBUG_TEXELS_OFF;
 
@@ -809,7 +808,7 @@ void LLViewerTexture::addTextureStats(F32 virtual_size, BOOL needs_gltexture) co
 		mNeedsGLTexture = TRUE;
 	}
 
-	virtual_size *= sTexelPixelRatio;
+    llassert(virtual_size <= LLViewerFetchedTexture::sMaxVirtualSize);
 
 	if (virtual_size > mMaxVirtualSize)
 	{
diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h
index 5893f549d02..a57886ff6fc 100644
--- a/indra/newview/llviewertexture.h
+++ b/indra/newview/llviewertexture.h
@@ -218,7 +218,6 @@ class LLViewerTexture : public LLGLTexture
 	LL::WorkQueue::weak_t mMainQueue;
 	LL::WorkQueue::weak_t mImageQueue;
 
-	static F32 sTexelPixelRatio;
 public:
 	static const U32 sCurrentFileVersion;	
 	static S32 sImageCount;
-- 
GitLab