From e46323b0b9fea77522ee4637a82e2e86de15bb83 Mon Sep 17 00:00:00 2001
From: Dave Parks <davep@lindenlab.com>
Date: Tue, 29 Nov 2022 10:50:25 -0600
Subject: [PATCH] SL-18682 WIP -- Clear BOOST_SELECTED as needed.  GL 3.2
 compatibility pass.  Fix for stack underflow when reflection probes disabled.

---
 .gitignore                                    | 13 +++++
 indra/newview/app_settings/settings.xml       |  2 +-
 indra/newview/lldrawpoolbump.cpp              |  1 -
 indra/newview/llfloaterpreference.cpp         | 10 ++++
 indra/newview/llviewerobject.cpp              |  2 +-
 indra/newview/llviewerobjectlist.cpp          | 54 +++++++++----------
 indra/newview/llvovolume.cpp                  |  8 ++-
 .../floater_preferences_graphics_advanced.xml |  2 +-
 8 files changed, 60 insertions(+), 32 deletions(-)

diff --git a/.gitignore b/.gitignore
index 839d14bc0df..e9b544a6ce8 100755
--- a/.gitignore
+++ b/.gitignore
@@ -7,9 +7,18 @@
 *.pyc
 *.rej
 *.swp
+*.vcxproj
+*.filters
+*.sln
+*.depend
+*.stamp
+*.rc
+
 *~
 
 # Specific paths and/or names
+CMakeCache.txt
+cmake_install.cmake
 LICENSES
 build-darwin-*
 build-linux-*
@@ -17,6 +26,10 @@ debian/files
 debian/secondlife-appearance-utility*
 debian/secondlife-viewer*
 indra/.distcc
+indra/cmake/*
+indra/out/*
+
+indra/packages/*
 build-vc80/
 build-vc100/
 build-vc120/
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 8c96ccd1074..bea54f0b69f 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9235,7 +9235,7 @@
   <key>RenderMaxVRAMBudget</key>
   <map>
     <key>Comment</key>
-    <string>Maximum amount of texture memory to budget for, or 0 for autodetect.  Requires restart.</string>
+    <string>Maximum amount of texture memory to budget for (in MB), or 0 for autodetect.  Requires restart.</string>
     <key>Persist</key>
     <integer>1</integer>
     <key>Type</key>
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index cd9ff0192e9..684cf55b6b2 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -535,7 +535,6 @@ void LLDrawPoolBump::endFullbrightShiny()
 	if( cube_map )
 	{
 		cube_map->disable();
-        cube_map->restoreMatrix();
         if (shader->mFeatures.hasReflectionProbes)
         {
             gPipeline.unbindReflectionProbes(*shader);
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index b3403fda0fd..81b3c23417d 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -1215,6 +1215,16 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState()
 	ctrl_shadow->setEnabled(enabled);
 	shadow_text->setEnabled(enabled);
 
+    if (!LLFeatureManager::instance().isFeatureAvailable("RenderFSAASamples"))
+    {
+        getChildView("fsaa")->setEnabled(FALSE);
+    }
+
+    if (!LLFeatureManager::instance().isFeatureAvailable("RenderReflectionProbeDetail"))
+    {
+        getChildView("ReflectionDetail")->setEnabled(FALSE);
+    }
+
 	// Hardware settings
 	
 	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures"))
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 47cb9e9732d..2e76103773a 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -4062,7 +4062,7 @@ void LLViewerObject::updateTextures()
 
 void LLViewerObject::boostTexturePriority(BOOL boost_children /* = TRUE */)
 {
-	if (isDead())
+	if (isDead() || !getVolume())
 	{
 		return;
 	}
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index dc0785f9901..816fa6607e7 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -789,7 +789,33 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 		max_value = llmin((S32) mObjects.size(), mCurLazyUpdateIndex + num_updates);
 	}
 
-#if 0
+	// Iterate through some of the objects and lazy update their texture priorities
+	for (i = mCurLazyUpdateIndex; i < max_value; i++)
+	{
+		objectp = mObjects[i];
+		if (!objectp->isDead())
+		{
+			num_objects++;
+
+			//  Update distance & gpw 
+			objectp->setPixelAreaAndAngle(agent); // Also sets the approx. pixel area
+			objectp->updateTextures();	// Update the image levels of textures for this object.
+		}
+	}
+
+	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;
+	}
+
+#if 1
 	// Slam priorities for textures that we care about (hovered, selected, and focused)
 	// Hovered
 	// Assumes only one level deep of parenting
@@ -822,32 +848,6 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
 	LLSelectMgr::getInstance()->getSelection()->applyToRootObjects(&func);
 #endif
 
-	// Iterate through some of the objects and lazy update their texture priorities
-	for (i = mCurLazyUpdateIndex; i < max_value; i++)
-	{
-		objectp = mObjects[i];
-		if (!objectp->isDead())
-		{
-			num_objects++;
-
-			//  Update distance & gpw 
-			objectp->setPixelAreaAndAngle(agent); // Also sets the approx. pixel area
-			objectp->updateTextures();	// Update the image levels of textures for this object.
-		}
-	}
-
-	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;
-	}
-
 	LLVOAvatar::cullAvatarsByPixelArea();
 }
 
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 41b57b8a6ba..038935963d7 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -800,7 +800,13 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
 		{
 			continue;
 		}
-		
+
+        // clear out boost selected periodically
+        if (imagep->getBoostLevel() == LLGLTexture::BOOST_SELECTED)
+        {
+            imagep->setBoostLevel(LLGLTexture::BOOST_NONE);
+        }
+
 		F32 vsize;
 		F32 old_size = face->getVirtualSize();
 
diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml
index 4a08cc5285b..75b50c0e395 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml
@@ -666,7 +666,7 @@
    layout="topleft"
    left_delta="130"
    top_delta="0"
-   name="ReflectionDetial"
+   name="ReflectionDetail"
    width="150">
     <combo_box.item
       label="Disabled"
-- 
GitLab