From ba3ff9272eb8b104b72bdf385d9800c066cd84c8 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 7 Dec 2022 23:49:17 -0500
Subject: [PATCH] The great hammer. It screamed.

---
 indra/cmake/LLPrimitive.cmake        |  8 ++++----
 indra/cmake/Sentry.cmake             |  4 ++--
 indra/llcommon/llsdserialize.cpp     |  2 +-
 indra/llcommon/llsys.cpp             |  2 +-
 indra/llprimitive/llmodel.cpp        |  2 +-
 indra/llrender/llgl.cpp              |  3 ++-
 indra/newview/CMakeLists.txt         |  2 +-
 indra/newview/llenvironment.cpp      | 16 +++++-----------
 indra/newview/llsettingsvo.cpp       |  1 +
 indra/newview/llviewermenu.cpp       |  1 -
 indra/newview/llviewerobjectlist.cpp |  2 +-
 indra/newview/llvosky.cpp            | 19 ++++++++++---------
 indra/newview/llvovolume.cpp         |  2 +-
 indra/newview/pipeline.cpp           |  8 ++++----
 14 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/indra/cmake/LLPrimitive.cmake b/indra/cmake/LLPrimitive.cmake
index 4aa8aee7db2..654cc0419ba 100644
--- a/indra/cmake/LLPrimitive.cmake
+++ b/indra/cmake/LLPrimitive.cmake
@@ -6,7 +6,7 @@ include(Prebuilt)
 include(Boost)
 include(LibXML2)
 include(URIPARSER)
-include(ZLIB)
+include(ZLIBNG)
 
 use_prebuilt_binary(colladadom)
 use_prebuilt_binary(minizip-ng) # needed for colladadom
@@ -25,7 +25,7 @@ if (WINDOWS)
         ${LIBXML2_LIBRARIES}
         ${URIPARSER_LIBRARIES}
         ${MINIZIP_LIBRARIES}
-        ${ZLIB_LIBRARIES}
+        ${ZLIBNG_LIBRARIES}
         )
 elseif (DARWIN)
     set(LLPRIMITIVE_LIBRARIES 
@@ -37,7 +37,7 @@ elseif (DARWIN)
         ${LIBXML2_LIBRARIES}
         ${URIPARSER_LIBRARIES}
         ${MINIZIP_LIBRARIES}
-        ${ZLIB_LIBRARIES}
+        ${ZLIBNG_LIBRARIES}
         )
 elseif (LINUX)
     set(LLPRIMITIVE_LIBRARIES 
@@ -49,7 +49,7 @@ elseif (LINUX)
         ${LIBXML2_LIBRARIES}
         ${URIPARSER_LIBRARIES}
         ${MINIZIP_LIBRARIES}
-        ${ZLIB_LIBRARIES}
+        ${ZLIBNG_LIBRARIES}
         )
 endif (WINDOWS)
 
diff --git a/indra/cmake/Sentry.cmake b/indra/cmake/Sentry.cmake
index 8df371de2a8..4cf0fce0bf3 100644
--- a/indra/cmake/Sentry.cmake
+++ b/indra/cmake/Sentry.cmake
@@ -13,14 +13,14 @@ if (USE_SENTRY)
             include(CURL)
             include(NGHTTP2)
             include(OpenSSL)
-            include(ZLIB)
+            include(ZLIBNG)
             set(SENTRY_LIBRARIES 
                 ${ARCH_PREBUILT_DIRS_RELEASE}/libsentry.a
                 ${ARCH_PREBUILT_DIRS_RELEASE}/libbreakpad_client.a
                 ${CURL_LIBRARIES}
                 ${NGHTTP2_LIBRARIES}
                 ${OPENSSL_LIBRARIES}
-                ${ZLIB_LIBRARIES})
+                ${ZLIBNG_LIBRARIES})
         endif ()
     else ()
         find_package(Sentry REQUIRED)
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index 1b3bd4a5c3e..3a28f521d54 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -40,7 +40,7 @@
 #ifdef LL_USESYSTEMLIBS
 # include <zlib.h>
 #else
-# include "zlib-ng/zlib.h"  // for davep's dirty little zip functions
+# include "zlib/zlib.h"  // for davep's dirty little zip functions
 #endif
 
 #if !LL_WINDOWS
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 94255960f52..867db04d539 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -32,7 +32,7 @@
 #ifdef LL_USESYSTEMLIBS
 # include <zlib.h>
 #else
-# include "zlib-ng/zlib.h"
+# include "zlib/zlib.h"
 #endif
 
 #include "llprocessor.h"
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 83a20c299c6..63b3b6d9b1e 100644
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -36,7 +36,7 @@
 #ifdef LL_USESYSTEMLIBS
 # include <zlib.h>
 #else
-# include "zlib-ng/zlib.h"
+# include "zlib/zlib.h"
 #endif
 
 std::string model_names[] =
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 1efb39fc0f3..b8ad8c4cfb5 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -169,6 +169,7 @@ LLGLManager::LLGLManager() :
 	mHasOcclusionQuery2(FALSE),
 	mHasPointParameters(FALSE),
 	mHasDrawBuffers(FALSE),
+	mHasDepthClamp(FALSE),
 	mHasTextureRectangle(FALSE),
 	mHasTextureMultisample(FALSE),
 	mHasTransformFeedback(FALSE),
@@ -797,7 +798,7 @@ void LLGLManager::initExtensions()
 	mHasMapBufferRange = mGLVersion >= 3.0f || epoxy_has_gl_extension("GL_ARB_map_buffer_range");
 	mHasFlushBufferRange = epoxy_has_gl_extension("GL_APPLE_flush_buffer_range");
     // NOTE: Using extensions breaks reflections when Shadows are set to projector.  See: SL-16727
-	mHasDepthClamp = mGLVersion >= 3.2f || (epoxy_has_gl_extension("GL_ARB_depth_clamp") || epoxy_has_gl_extension("GL_NV_depth_clamp"));
+	//mHasDepthClamp = mGLVersion >= 3.2f || (epoxy_has_gl_extension("GL_ARB_depth_clamp") || epoxy_has_gl_extension("GL_NV_depth_clamp"));
 	// mask out FBO support when packed_depth_stencil isn't there 'cause we need it for LLRenderTarget -Brad
 #ifdef GL_ARB_framebuffer_object
 	mHasFramebufferObject = mGLVersion >= 3.0f || epoxy_has_gl_extension("GL_ARB_framebuffer_object");
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 5b03807e69d..085e1835ba5 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -75,7 +75,7 @@ include_directories(
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMAKE_CURRENT_BINARY_DIR}
     ${DBUSGLIB_INCLUDE_DIRS}
-    ${ZLIB_INCLUDE_DIRS}
+    ${ZLIBNG_INCLUDE_DIRS}
     ${LIBXML2_INCLUDE_DIRS}
     ${LLAUDIO_INCLUDE_DIRS}
     ${LLCHARACTER_INCLUDE_DIRS}
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 56c32733346..6002e665529 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -1613,16 +1613,10 @@ void LLEnvironment::update(const LLViewerCamera * cam)
         end_shaders = LLViewerShaderMgr::instance()->endShaders();
         for (shaders_iter = LLViewerShaderMgr::instance()->beginShaders(); shaders_iter != end_shaders; ++shaders_iter)
         {
-			if ((shaders_iter->mProgramObject != 0) &&
-				(shaders_iter->mFeatures.atmosphericHelpers
-					|| shaders_iter->mFeatures.calculatesAtmospherics
-					|| shaders_iter->mFeatures.hasAtmospherics
-					|| shaders_iter->mFeatures.hasGamma
-					|| shaders_iter->mFeatures.hasTransport
-					|| shaders_iter->mFeatures.hasWaterFog) &&
-				(gPipeline.canUseWindLightShaders()
-					|| shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER))
-			{
+            if ((shaders_iter->mProgramObject != 0)
+                && (gPipeline.canUseWindLightShaders()
+                || shaders_iter->mShaderGroup == LLGLSLShader::SG_WATER))
+            {
                 shaders_iter->mUniformsDirty = TRUE;
             }
         }
@@ -2623,7 +2617,7 @@ void LLEnvironment::setExperienceEnvironment(LLUUID experience_id, LLSD data, F3
 
     if (!water.isUndefined())
     {
-        environment->injectWaterSettings(sky, experience_id, LLSettingsBase::Seconds(transition_time));
+        environment->injectWaterSettings(water, experience_id, LLSettingsBase::Seconds(transition_time));
     }
 
     if (updateenvironment)
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index 39187a73886..6e64cc5660e 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -738,6 +738,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
     //F32 display_gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma");
 
     shader->uniform1f(LLShaderMgr::GAMMA, g);
+    //shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, display_gamma);
 }
 
 const LLSettingsSky::parammapping_t& LLSettingsVOSky::getParameterMap() const
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 78cf3f61055..1564a3ba10a 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -4222,7 +4222,6 @@ void handle_object_sit(LLViewerObject *object, const LLVector3 &offset)
 			gRlvHandler.setSitSource(gAgent.getPositionGlobal());
 		}
 // [/RLVa:KB]
-	{
 
 		gMessageSystem->newMessageFast(_PREHASH_AgentRequestSit);
 		gMessageSystem->nextBlockFast(_PREHASH_AgentData);
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp
index 9d6c4731574..0d6b689e435 100644
--- a/indra/newview/llviewerobjectlist.cpp
+++ b/indra/newview/llviewerobjectlist.cpp
@@ -72,7 +72,7 @@
 #ifdef LL_USESYSTEMLIBS
 #include <zlib.h>
 #else
-#include "zlib-ng/zlib.h"
+#include "zlib/zlib.h"
 #endif
 #include "object_flags.h"
 
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 1fb4a9642df..0c11d68d92c 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -64,7 +64,7 @@ namespace
 	constexpr S32 NUM_TILES_X = 8;
 	constexpr S32 NUM_TILES_Y = 4;
 	constexpr S32 NUM_TILES = NUM_TILES_X * NUM_TILES_Y;
-	constexpr S32 NUM_CUBEMAP_FACES = 6; // See sResolution for face dimensions
+	constexpr S32 NUM_CUBEMAP_FACES = 6; // See SKYTEX_RESOLUTION for face dimensions
 	constexpr S32 TOTAL_TILES = NUM_CUBEMAP_FACES * NUM_TILES;
 	constexpr S32 MAX_TILES = TOTAL_TILES + 1;
 
@@ -75,9 +75,9 @@ namespace
 
 // Texture coordinates:
     const LLVector2 TEX00 = LLVector2(0.f, 0.f);
-	const LLVector2 TEX01 = LLVector2(0.f, 1.f);
-	const LLVector2 TEX10 = LLVector2(1.f, 0.f);
-	const LLVector2 TEX11 = LLVector2(1.f, 1.f);
+    const LLVector2 TEX01 = LLVector2(0.f, 1.f);
+    const LLVector2 TEX10 = LLVector2(1.f, 0.f);
+    const LLVector2 TEX11 = LLVector2(1.f, 1.f);
 
 	constexpr F32Seconds UPDATE_EXPRY(0.25f);
 
@@ -89,6 +89,7 @@ namespace
 
 S32 LLSkyTex::sCurrent = 0;
 
+
 LLSkyTex::LLSkyTex() :
 	mSkyData(NULL),
 	mSkyDirs(NULL),
@@ -567,11 +568,11 @@ void LLVOSky::restoreGL()
 
 	const LLSettingsSky::ptr_t& psky = LLEnvironment::instance().getCurrentSky();
 
-	if (psky)
+    if (psky)
 	{
-		setSunTextures(psky->getSunTextureId(), psky->getNextSunTextureId());
-		setMoonTextures(psky->getMoonTextureId(), psky->getNextMoonTextureId());
-	}
+        setSunTextures(psky->getSunTextureId(), psky->getNextSunTextureId());
+        setMoonTextures(psky->getMoonTextureId(), psky->getNextMoonTextureId());
+    }
 
 	updateDirections(psky);
 
@@ -580,7 +581,7 @@ void LLVOSky::restoreGL()
 		initCubeMap();
 	}
 
-	forceSkyUpdate();
+    forceSkyUpdate();
 
 	if (mDrawable)
 	{
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 7275e19f9f4..b04ceff9107 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -6822,7 +6822,7 @@ void LLVolumeGeometryManager::addGeometryCount(LLSpatialGroup* group, U32& verte
 
         if (drawablep->isAnimating())
         { //fall back to stream draw for animating verts
-            usage = GL_STREAM_DRAW_ARB;
+            usage = GL_STREAM_DRAW;
         }
     }
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 87946345ca8..0096af875c0 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -4704,7 +4704,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
 			}
 		}
 
-		LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0);
+		LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE : 0);
 
 		LLVertexBuffer::unbind();
 
@@ -11192,11 +11192,11 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar)
 			for(auto attachment_iter = avatar->mAttachedObjectsVector.begin(), attachment_end = avatar->mAttachedObjectsVector.end();
 				attachment_iter != attachment_end;++attachment_iter)
 			{{
-				LLViewerObject* attached_object = attachment_iter->first
+				LLViewerObject* attached_object = attachment_iter->first;
 #endif
                     if (attached_object && attached_object->isRiggedMesh())
                     {
-                        markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
+                        markVisible(attached_object->mDrawable->getSpatialBridge(), viewer_camera);
                     }
                 }
             }
@@ -11216,7 +11216,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar, bool preview_avatar)
                     LLViewerObject* attached_object = attachment_iter->get();
                     if (attached_object)
                     {
-                        markVisible(attached_object->mDrawable->getSpatialBridge(), *viewer_camera);
+                        markVisible(attached_object->mDrawable->getSpatialBridge(), viewer_camera);
                     }
                 }
             }
-- 
GitLab