From 56e079dbdd94fc673bb8c9eb7aa2181c94e2807e Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sun, 27 Aug 2023 18:50:07 -0400
Subject: [PATCH] Decrufting

---
 indra/llrender/llcubemap.cpp      |  5 -----
 indra/llrender/llgl.cpp           | 35 ++++++-------------------------
 indra/llrender/llglslshader.cpp   | 14 ++++++-------
 indra/llrender/llglslshader.h     |  8 +++----
 indra/llrender/llrender.cpp       | 17 +--------------
 indra/llrender/llrender.h         | 11 ----------
 indra/llrender/llrendertarget.cpp | 17 ---------------
 7 files changed, 17 insertions(+), 90 deletions(-)

diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp
index 2add0d61920..b73a5cd1432 100644
--- a/indra/llrender/llcubemap.cpp
+++ b/indra/llrender/llcubemap.cpp
@@ -75,11 +75,6 @@ void LLCubeMap::initGL()
 			for (int i = 0; i < 6; i++)
 			{
 				mImages[i] = new LLImageGL(RESOLUTION, RESOLUTION, 4, FALSE);
-            #if USE_SRGB_DECODE
-                if (mIssRGB) {
-                    mImages[i]->setExplicitFormat(GL_SRGB8_ALPHA8, GL_RGBA);
-                }
-            #endif
 				mImages[i]->setTarget(mTargets[i], LLTexUnit::TT_CUBE_MAP);
 				mRawImages[i] = new LLImageRaw(RESOLUTION, RESOLUTION, 4);
 				mImages[i]->createGLTexture(0, mRawImages[i], texname);
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 92b19ad8e09..9f1e4ba3d03 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -1270,8 +1270,8 @@ void LLGLManager::getGLInfo(LLSD& info)
 	}
 
 #if !LL_MESA_HEADLESS
-#if !LL_DARWIN
-    if (mGLVersion >= 3.0f && glGetStringi) {
+    if (glGetStringi) 
+    {
         std::vector<std::string> gl_extension_str_vec;
         GLint n, i;
         glGetIntegerv(GL_NUM_EXTENSIONS, &n);
@@ -1280,15 +1280,6 @@ void LLGLManager::getGLInfo(LLSD& info)
             if (!exten.empty())
                 info["GLInfo"]["GLExtensions"].append(exten);
         }
-    } else
-#endif
-    {
-        std::string all_exts = ll_safe_string((const char *) glGetString(GL_EXTENSIONS));
-        boost::char_separator<char> sep(" ");
-        boost::tokenizer<boost::char_separator<char> > tok(all_exts, sep);
-        for (boost::tokenizer<boost::char_separator<char> >::iterator i = tok.begin(); i != tok.end(); ++i) {
-            info["GLInfo"]["GLExtensions"].append(*i);
-        }
     }
 #endif
 }
@@ -1311,8 +1302,8 @@ std::string LLGLManager::getGLInfoString()
 	}
 
 #if !LL_MESA_HEADLESS
-#if !LL_DARWIN
-    if (mGLVersion >= 3.0f && glGetStringi) {
+    if (glGetStringi) 
+    {
         std::stringstream gl_extension_strstrm;
         GLint n, i;
         glGetIntegerv(GL_NUM_EXTENSIONS, &n);
@@ -1322,12 +1313,6 @@ std::string LLGLManager::getGLInfoString()
                 gl_extension_strstrm << exten << "\n";
         }
         info_str += std::string("GL_EXTENSIONS:\n") + gl_extension_strstrm.str() + std::string("\n");
-    } else
-#endif
-    {
-        std::string all_exts = ll_safe_string((const char *) glGetString(GL_EXTENSIONS));
-        LLStringUtil::replaceChar(all_exts, ' ', '\n');
-        info_str += std::string("GL_EXTENSIONS:\n") + all_exts + std::string("\n");
     }
 #endif
 
@@ -1350,8 +1335,8 @@ void LLGLManager::printGLInfoString()
 	}
 
 #if !LL_MESA_HEADLESS
-#if !LL_DARWIN
-    if (mGLVersion >= 3.0f && glGetStringi) {
+    if (glGetStringi)
+    {
         std::stringstream gl_extension_strstrm;
         GLint n, i;
         glGetIntegerv(GL_NUM_EXTENSIONS, &n);
@@ -1362,13 +1347,6 @@ void LLGLManager::printGLInfoString()
         }
         LL_INFOS("RenderInit") << "GL_EXTENSIONS:\n" << gl_extension_strstrm.str() << LL_ENDL;
     }
-    else
-#endif
-    {
-        std::string all_exts = ll_safe_string((const char *) glGetString(GL_EXTENSIONS));
-        LLStringUtil::replaceChar(all_exts, ' ', '\n');
-        LL_INFOS("RenderInit") << "GL_EXTENSIONS:\n" << all_exts << LL_ENDL;
-    }
 #endif
 }
 
@@ -1451,7 +1429,6 @@ void LLGLManager::initExtensions()
     mHasCubeMapArray = mGLVersion >= 3.99f; 
     mHasTransformFeedback = mGLVersion >= 3.99f;
     mHasDebugOutput = mGLVersion >= 4.29f;
-    mHasGPUShader4  = mGLVersion >= 3.0f;
     mHasTextureSwizzle = mGLVersion >= 3.29f;
     mHasTextureFilterAnisotropic = mGLVersion >= 4.59f || ExtensionExists("GL_EXT_texture_filter_anisotropic", gGLHExts.mSysExts);
 
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 6b163aed75d..4a8ca8373ad 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -1082,17 +1082,17 @@ void LLGLSLShader::unbind(void)
     sCurBoundShaderPtr = NULL;
 }
 
-S32 LLGLSLShader::bindTexture(const std::string& uniform, LLTexture* texture, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace colorspace)
+S32 LLGLSLShader::bindTexture(const std::string& uniform, LLTexture* texture, LLTexUnit::eTextureType mode)
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
 
     S32 channel = 0;
     channel = getUniformLocation(uniform);
 
-    return bindTexture(channel, texture, mode, colorspace);
+    return bindTexture(channel, texture, mode);
 }
 
-S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture* texture, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace colorspace)
+S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture* texture, LLTexUnit::eTextureType mode)
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
 
@@ -1107,7 +1107,6 @@ S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture* texture, LLTexUnit::eTextu
     if (uniform > -1)
     {
         gGL.getTexUnit(uniform)->bindFast(texture);
-        gGL.getTexUnit(uniform)->setTextureColorSpace(colorspace);
     }
 
     return uniform;
@@ -1185,7 +1184,7 @@ S32 LLGLSLShader::getTextureChannel(S32 uniform) const
     return mTexture[uniform];
 }
 
-S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace space)
+S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
 
@@ -1199,12 +1198,11 @@ S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTex
     {
         gGL.getTexUnit(index)->activate();
         gGL.getTexUnit(index)->enable(mode);
-        gGL.getTexUnit(index)->setTextureColorSpace(space);
     }
     return index;
 }
 
-S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace space)
+S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
 {
     LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER;
 
@@ -1216,7 +1214,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTe
     S32 index = mTexture[uniform];
     if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE)
     {
-        if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode && gGL.getTexUnit(index)->getCurrColorSpace() != space)
+        if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode)
         {
             if (gDebugSession)
             {
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 5fbaf0928ee..01fbb11b74f 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -250,16 +250,16 @@ class LLGLSLShader
     //if given texture uniform is active in the shader, 
     //the corresponding channel will be active upon return
     //returns channel texture is enabled in from [0-MAX)
-    S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
-    S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
+    S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
+    S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
 
     // get the texture channel of the given uniform, or -1 if uniform is not used as a texture
     S32 getTextureChannel(S32 uniform) const;
 
     // bindTexture returns the texture unit we've bound the texture to.
     // You can reuse the return value to unbind a texture when required.
-    S32 bindTexture(const std::string& uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
-    S32 bindTexture(S32 uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
+    S32 bindTexture(const std::string& uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
+    S32 bindTexture(S32 uniform, LLTexture* texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
     S32 bindTexture(const std::string& uniform, LLRenderTarget* texture, bool depth = false, LLTexUnit::eTextureFilterOptions mode = LLTexUnit::TFO_BILINEAR);
     S32 bindTexture(S32 uniform, LLRenderTarget* texture, bool depth = false, LLTexUnit::eTextureFilterOptions mode = LLTexUnit::TFO_BILINEAR, U32 index = 0);
     S32 unbindTexture(const std::string& uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index d4ae5db0e02..cee314f8098 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -122,7 +122,7 @@ static const GLenum sGLBlendFactor[] =
 
 LLTexUnit::LLTexUnit(S32 index)
 	: mCurrTexType(TT_NONE),
-    mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0), mTexColorSpace(TCS_SRGB),
+    mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0),
 	mHasMipMaps(false),
 	mIndex(index)
 {
@@ -152,8 +152,6 @@ void LLTexUnit::refreshState(void)
 	{
 		glBindTexture(GL_TEXTURE_2D, 0);	
 	}
-
-    setTextureColorSpace(mTexColorSpace);
 }
 
 void LLTexUnit::activate(void)
@@ -248,7 +246,6 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind)
 						setTextureAddressMode(gl_tex->mAddressMode);
 						setTextureFilteringOption(gl_tex->mFilterOption);
                     }
-                    setTextureColorSpace(mTexColorSpace);
 				}
 			}
 			else
@@ -329,7 +326,6 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind, S32
 			setTextureFilteringOption(texture->mFilterOption);
 			stop_glerror();
 		}
-        setTextureColorSpace(mTexColorSpace);
 	}
 
 	stop_glerror();
@@ -365,7 +361,6 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)
 				setTextureAddressMode(cubeMap->mImages[0]->mAddressMode);
 				setTextureFilteringOption(cubeMap->mImages[0]->mFilterOption);
             }
-            setTextureColorSpace(mTexColorSpace);
 			return true;
 		}
 		else
@@ -414,7 +409,6 @@ bool LLTexUnit::bindManual(eTextureType type, U32 texture, bool hasMips)
 		mCurrTexture = texture;
 		glBindTexture(sGLTextureType[type], texture);
         mHasMipMaps = hasMips;
-        setTextureColorSpace(mTexColorSpace);
 	}
 	return true;
 }
@@ -435,8 +429,6 @@ void LLTexUnit::unbind(eTextureType type)
 	{
 		mCurrTexture = 0;
 
-        // Always make sure our texture color space is reset to linear.  SRGB sampling should be opt-in in the vast majority of cases.  Also prevents color space "popping".
-        mTexColorSpace = TCS_SRGB;
 		if (type == LLTexUnit::TT_TEXTURE)
 		{
 			glBindTexture(sGLTextureType[type], sWhiteTexture);
@@ -458,8 +450,6 @@ void LLTexUnit::unbindFast(eTextureType type)
     {
         mCurrTexture = 0;
 
-        // Always make sure our texture color space is reset to linear.  SRGB sampling should be opt-in in the vast majority of cases.  Also prevents color space "popping".
-        mTexColorSpace = TCS_LINEAR;
         if (type == LLTexUnit::TT_TEXTURE)
         {
             glBindTexture(sGLTextureType[type], sWhiteTexture);
@@ -654,11 +644,6 @@ void LLTexUnit::debugTextureUnit(void)
 	}
 }
 
-void LLTexUnit::setTextureColorSpace(eTextureColorSpace space)
-{
-    mTexColorSpace = space;
-}
-
 LLLightState::LLLightState(S32 index)
 : mIndex(index),
   mEnabled(false),
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index e298689ba59..e0cd5d479a9 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -144,12 +144,6 @@ class LLTexUnit
 		TBS_ONE_MINUS_CONST_ALPHA
 	} eTextureBlendSrc;
 
-    typedef enum
-    {
-        TCS_LINEAR = 0,
-        TCS_SRGB
-    } eTextureColorSpace;
-
 	LLTexUnit(S32 index = -1);
 
 	// Refreshes renderer state of the texture unit to the cached values
@@ -222,17 +216,12 @@ class LLTexUnit
 
 	void setHasMipMaps(bool hasMips) { mHasMipMaps = hasMips; }
 
-    void setTextureColorSpace(eTextureColorSpace space);
-
-    eTextureColorSpace getCurrColorSpace() { return mTexColorSpace; }
-
 protected:
     friend class LLRender;
 
 	S32		        	mIndex;
 	U32					mCurrTexture;
 	eTextureType		mCurrTexType;
-    eTextureColorSpace  mTexColorSpace;
 	S32					mCurrColorScale;
 	S32					mCurrAlphaScale;
 	bool				mHasMipMaps;
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index 88c48e51660..7039bc63669 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -491,24 +491,7 @@ U32 LLRenderTarget::getNumTextures() const
 void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilterOptions filter_options)
 {
     gGL.getTexUnit(channel)->bindManual(mUsage, getTexture(index), filter_options == LLTexUnit::TFO_TRILINEAR || filter_options == LLTexUnit::TFO_ANISOTROPIC);
-
-    bool isSRGB = false;
-    llassert(mInternalFormat.size() > index);
-    switch (mInternalFormat[index])
-    {
-        case GL_SRGB:
-        case GL_SRGB8:
-        case GL_SRGB_ALPHA:
-        case GL_SRGB8_ALPHA8:
-            isSRGB = true;
-            break;
-
-        default:
-            break;
-    }
-
     gGL.getTexUnit(channel)->setTextureFilteringOption(filter_options);
-    gGL.getTexUnit(channel)->setTextureColorSpace(isSRGB ? LLTexUnit::TCS_SRGB : LLTexUnit::TCS_LINEAR);
 }
 
 void LLRenderTarget::flush()
-- 
GitLab