From 9e71ffdcac2167427dbbb78b4a81b0da09cc3a64 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 7 Dec 2022 23:01:29 -0500
Subject: [PATCH] The Great Linking Hammer

---
 indra/llcharacter/lljoint.cpp        |  2 +-
 indra/newview/CMakeLists.txt         |  1 +
 indra/newview/lldrawpoolalpha.cpp    |  4 ++--
 indra/newview/lldrawpoolavatar.cpp   | 10 +++++-----
 indra/newview/lldrawpoolwater.cpp    |  2 +-
 indra/newview/llsettingsvo.cpp       |  4 ++--
 indra/newview/llspatialpartition.cpp | 12 ++++++------
 indra/newview/llviewerdisplay.cpp    | 22 +++++++++++-----------
 indra/newview/llviewermedia.cpp      |  2 +-
 indra/newview/llviewershadermgr.h    |  2 +-
 indra/newview/llvopartgroup.cpp      |  2 +-
 indra/newview/llvosky.cpp            | 13 ++++++-------
 indra/newview/llvotree.cpp           |  4 ++--
 indra/newview/llvovolume.cpp         | 21 +++++----------------
 indra/newview/pipeline.cpp           |  5 +++--
 indra/newview/rlveffects.cpp         | 10 ++--------
 indra/newview/rlvmodifiers.h         |  2 +-
 17 files changed, 51 insertions(+), 67 deletions(-)

diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index 45ad3a32251..698d5d65c4e 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -884,7 +884,7 @@ void LLJoint::setWorldRotation( const LLQuaternion& rot )
 	LLMatrix4a temp_mat(rota);
 
 	LLMatrix4a invParentWorldMatrix = mParent->getWorldMatrix();
-	invParentWorldMatrix.setTranslate_affine(LLVector3(0.f));
+	invParentWorldMatrix.setTranslate_affine(LLVector3(0.f, 0.f, 0.f));
 
 	invParentWorldMatrix.invert();
 
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index d934c3a7242..67ba5beb0b1 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -2166,6 +2166,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
     ${LLCHARACTER_LIBRARIES}
     ${LLIMAGE_LIBRARIES}
     ${LLINVENTORY_LIBRARIES}
+    ${LLMESHOPTIMIZER_LIBRARIES}
     ${LLMESSAGE_LIBRARIES}
     ${LLPLUGIN_LIBRARIES}
     ${LLPRIMITIVE_LIBRARIES}
diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp
index a92afead037..655b79f26b3 100644
--- a/indra/newview/lldrawpoolalpha.cpp
+++ b/indra/newview/lldrawpoolalpha.cpp
@@ -91,8 +91,8 @@ S32 LLDrawPoolAlpha::getNumPostDeferredPasses()
 // set some common parameters on the given shader to prepare for alpha rendering
 static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool deferredEnvironment)
 {
-    static LLCachedControl<F32> displayGamma(gSavedSettings, "RenderDeferredDisplayGamma");
-    F32 gamma = displayGamma;
+    //static LLCachedControl<F32> displayGamma(gSavedSettings, "RenderDeferredDisplayGamma");
+    //F32 gamma = displayGamma;
 
     // Does this deferred shader need environment uniforms set such as sun_dir, etc. ?
     // NOTE: We don't actually need a gbuffer since we are doing forward rendering (for transparency) post deferred rendering
diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp
index b15573d728f..5e68dee4dbd 100644
--- a/indra/newview/lldrawpoolavatar.cpp
+++ b/indra/newview/lldrawpoolavatar.cpp
@@ -240,11 +240,11 @@ void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass)
 
 	sSkipOpaque = TRUE;
 	sShaderLevel = mShaderLevel;
-	if (LLPipeline::sUnderWaterRender)
-	{
-		sVertexProgram = &gDeferredAvatarAlphaWaterProgram;
-	}
-	else
+	//if (LLPipeline::sUnderWaterRender)
+	//{
+	//	sVertexProgram = &gDeferredAvatarAlphaWaterProgram;
+	//}
+	//else
 	{
 		sVertexProgram = &gDeferredAvatarAlphaProgram;
 	}
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 1ab81eccb8f..28d9f13ec5c 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -630,7 +630,7 @@ void LLDrawPoolWater::renderWater()
         shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, pwater->getBlurMultiplier());
 
         F32 sunAngle    = llmax(0.f, light_dir.mV[1]);
-        F32 scaledAngle = 1.f - sunAngle;
+        //F32 scaledAngle = 1.f - sunAngle;
 
         shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_up ? 1 : 0);
         shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp
index 15c44781d96..d71b7690530 100644
--- a/indra/newview/llsettingsvo.cpp
+++ b/indra/newview/llsettingsvo.cpp
@@ -735,7 +735,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force)
     shader->uniform1f(LLShaderMgr::DISTANCE_MULTIPLIER, getDistanceMultiplier());
     
     F32 g             = getGamma();
-    F32 display_gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma");
+    //F32 display_gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma");
 
     shader->uniform1f(LLShaderMgr::GAMMA, g);
 }
@@ -954,7 +954,7 @@ void LLSettingsVOWater::applySpecial(void *ptarget, bool force)
         ep.negate();
         enorm.copyComponent<3>(ep);
 
-        shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, enorm.getF32ptr());
+        shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, enorm.getF32ptr());
 
         LLVector4 light_direction = env.getClampedLightNorm();
 
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 92cc95fa9b1..95302715eb7 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -1494,7 +1494,7 @@ void pushVerts(LLVolume* volume)
 	for (S32 i = 0; i < volume->getNumVolumeFaces(); ++i)
 	{
 		const LLVolumeFace& face = volume->getVolumeFace(i);
-		LLVertexBuffer::drawElements(LLRender::TRIANGLES, face.mNumVertices, face.mPositions, NULL, face.mNumIndices, face.mIndices);
+		LLVertexBuffer::drawElements(LLRender::TRIANGLES, face.mPositions, NULL, face.mNumIndices, face.mIndices);
 	}
 }
 
@@ -2531,11 +2531,11 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
 
 				llassert(LLGLSLShader::sCurBoundShader != 0);
 				
-				LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mNumHullPoints, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
+				LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
 				
 				gGL.diffuseColor4fv(color.mV);
 				glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-				LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mNumHullPoints, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
+				LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
 				
 			}
 			else
@@ -2612,11 +2612,11 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
 		{
 			gGL.diffuseColor4fv(line_color.mV);
 			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
-			LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mNumHullPoints, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
+			LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
 
 			gGL.diffuseColor4fv(color.mV);
 			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
-			LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mNumHullPoints, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
+			LLVertexBuffer::drawElements(LLRender::TRIANGLES, phys_volume->mHullPoints, NULL, phys_volume->mNumHullIndices, phys_volume->mHullIndices);
 		}
 		else
 		{
@@ -3150,7 +3150,7 @@ void renderRaycast(LLDrawable* drawablep)
 					{
 						//render face positions
 						gGL.diffuseColor4f(0.f, 1.f, 1.f, 0.5f);
-						LLVertexBuffer::drawElements(LLRender::TRIANGLES, face.mNumVertices, face.mPositions, NULL, face.mNumIndices, face.mIndices);
+						LLVertexBuffer::drawElements(LLRender::TRIANGLES, face.mPositions, NULL, face.mNumIndices, face.mIndices);
 					}
 					
 					if (!volume->isUnique())
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index e2ced628fb9..855aa080da4 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -289,7 +289,7 @@ static std::string STR_DISPLAY_DONE("Display:Done");
 // Paint the display!
 void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
 {
-	LL_ALWAYS_RECORD_BLOCK_TIME(FTM_RENDER);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER);
 	LLVBOPool::deleteReleasedBuffers();
 
 	if (gWindowResized)
@@ -699,7 +699,7 @@ pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")
 		{
 			LL_RECORD_BLOCK_TIME(FTM_EEP_UPDATE);
             // update all the sky/atmospheric/water settings
-            LLEnvironment::getInstance()->update(&vwrCamera);
+            LLEnvironment::instance().update(LLViewerCamera::getInstance());
 		}
 
 		// *TODO: merge these two methods
@@ -743,8 +743,8 @@ pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")
 
 		static LLCullResult result;
 		LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
-		LLPipeline::sUnderWaterRender = vwrCamera.cameraUnderWater();
-		gPipeline.updateCull(vwrCamera, result);
+		LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater();
+		gPipeline.updateCull(*LLViewerCamera::getInstance(), result);
 		stop_glerror();
 
 		LLGLState::checkStates();
@@ -771,7 +771,7 @@ pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")
 				if (gFrameCount > 1)
 				{ //for some reason, ATI 4800 series will error out if you 
 				  //try to generate a shadow before the first frame is through
-					gPipeline.generateSunShadow(vwrCamera);
+					gPipeline.generateSunShadow(*LLViewerCamera::getInstance());
 				}
 
 				LLVertexBuffer::unbind();
@@ -807,8 +807,8 @@ pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")
 		{
 			LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("display - 3")
 			LLAppViewer::instance()->pingMainloopTimeout(STR_DISPLAY_IMAGERY);
-			gPipeline.generateWaterReflection(vwrCamera);
-			gPipeline.generateHighlight(vwrCamera);
+			gPipeline.generateWaterReflection(*LLViewerCamera::getInstance());
+			gPipeline.generateHighlight(*LLViewerCamera::getInstance());
 			gPipeline.renderPhysicsDisplay();
 		}
 
@@ -867,7 +867,7 @@ pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")
 		{
 			LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("display - 4")
 			LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
-			gPipeline.stateSort(vwrCamera, result);
+			gPipeline.stateSort(*LLViewerCamera::getInstance(), result);
 			stop_glerror();
 				
 			if (rebuild)
@@ -942,7 +942,7 @@ pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")
 		//	gGL.popMatrix();
 		//}
 
-		LLPipeline::sUnderWaterRender = vwrCamera.cameraUnderWater() ? TRUE : FALSE;
+		LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE;
 
 		LLGLState::checkStates();
 
@@ -1002,11 +1002,11 @@ pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")
 			gGL.setColorMask(true, false);
 			if (LLPipeline::sRenderDeferred)
 			{
-				gPipeline.renderGeomDeferred(vwrCamera);
+				gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance());
 			}
 			else
 			{
-				gPipeline.renderGeom(vwrCamera, TRUE);
+				gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE);
 			}
 			
 			gGL.setColorMask(true, true);
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 644f6b0f16a..b541d4a686e 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -3018,7 +3018,7 @@ LLViewerMediaTexture* LLViewerMediaImpl::updateMediaImage()
     LL_PROFILE_ZONE_SCOPED_CATEGORY_MEDIA;
 //    if (!mMediaSource)
 // [SL:KB] - Patch: Render-TextureToggle (Catznip-4.0)
-	if ( (!mMediaSource) || || ((LLViewerFetchedTexture::sDefaultDiffuseImagep.notNull()) && (LLViewerFetchedTexture::sDefaultDiffuseImagep->getID() == mTextureId))
+	if ( (!mMediaSource) || ((LLViewerFetchedTexture::sDefaultDiffuseImagep.notNull()) && (LLViewerFetchedTexture::sDefaultDiffuseImagep->getID() == mTextureId)))
 // [/SL:KB]
     {
         return nullptr; // not ready for updating
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index 85381bcdd0e..681957dbf36 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -297,7 +297,7 @@ extern LLGLSLShader			gDeferredFullbrightAlphaMaskWaterProgram;
 extern LLGLSLShader			gDeferredEmissiveProgram;
 extern LLGLSLShader			gDeferredAvatarEyesProgram;
 extern LLGLSLShader			gDeferredAvatarAlphaProgram;
-extern LLGLSLShader			gDeferredAvatarAlphaWaterProgram;
+//extern LLGLSLShader			gDeferredAvatarAlphaWaterProgram;
 extern LLGLSLShader			gDeferredWLSkyProgram;
 extern LLGLSLShader			gDeferredWLCloudProgram;
 extern LLGLSLShader			gDeferredWLSunProgram;
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index d6d10bd43ae..2280b868319 100644
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -712,7 +712,7 @@ void LLVOPartGroup::getGeometry(S32 idx,
 	*colorsp++ = color;
 
 	//Only add emissive attributes if glowing (doing it for all particles is INCREDIBLY inefficient as it leads to a second, slower, render pass.)
-	if (gPipeline.canUseVertexShaders() && (pglow.mV[3] > 0 || part.mGlow.mV[3] > 0))
+	if (pglow.mV[3] > 0 || part.mGlow.mV[3] > 0)
 	{ //only write glow if it is not zero
 		*emissivep++ = pglow;
 		*emissivep++ = pglow;
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index db10138e020..a5068477fb8 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -642,7 +642,7 @@ void LLVOSky::createSkyTexture(const LLSettingsSky::ptr_t &psky, AtmosphericsVar
 	}
 }
 
-void LLVOSky::updateDirections(LLSettingsSky::ptr_t psky)
+void LLVOSky::updateDirections(const LLSettingsSky::ptr_t& psky)
 {
     mSun.setDirection(psky->getSunDirection());
     mMoon.setDirection(psky->getMoonDirection());
@@ -707,7 +707,7 @@ bool LLVOSky::updateSky()
         if (mNeedUpdate && (mForceUpdateThrottle.hasExpired() || mForceUpdate))
 		{
             // start updating cube map sides
-            updateFog(LLViewerCamera::getInstance()->getFar());
+            updateFog(&environment, psky, LLViewerCamera::getInstance()->getFar());
             mCubeMapUpdateStage = 0;
             mForceUpdate = FALSE;
 		}
@@ -1521,15 +1521,14 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H,
 }
 }
 
-void LLVOSky::updateFog(const F32 distance)
+void LLVOSky::updateFog(LLEnvironment* environment, const LLSettingsSky::ptr_t& psky, const F32 distance)
 {
-    LLEnvironment& environment = LLEnvironment::instance();
-    if (environment.getCurrentSky() != nullptr)
+    if (psky)
 	{
-        LLVector3 light_dir = LLVector3(environment.getClampedLightNorm());
+        LLVector3 light_dir = LLVector3(environment->getClampedLightNorm());
         m_legacyAtmospherics.updateFog(distance, light_dir);
-		}
 	}
+}
 
 void LLVOSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir_cfr, const LLVector3 &moon_dir_cfr)
 {
diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp
index 3f0972b4f02..8313760fd7f 100644
--- a/indra/newview/llvotree.cpp
+++ b/indra/newview/llvotree.cpp
@@ -901,7 +901,7 @@ void LLVOTree::updateMesh()
 
 
 	LLMatrix4a rot_mat = trans_mat;
-	rot_mat.mul(LLQuaternion2(rot));
+	rot_mat.mul(LLMatrix4a(LLQuaternion2(rot)));
 
 	F32 radius = getScale().magVec()*0.05f;
 	rot_mat.applyScale_affine(radius);
@@ -1068,7 +1068,7 @@ void LLVOTree::genBranchPipeline(LLStrider<LLVector4a>& vertices,
 					LLQuaternion(((constant_twist + ((i%2==0)?twist:-twist))*i)*DEG_TO_RAD, LLVector4(0.f, 0.f, 1.f));
 
 				LLMatrix4a rot_mat = trans_mat;
-				rot_mat.mul(LLQuaternion2(rot));
+				rot_mat.mul(LLMatrix4a(LLQuaternion2(rot)));
 
 				genBranchPipeline(vertices, normals, tex_coords, colors, indices, index_offset, rot_mat, trunk_LOD, stop_level, depth - 1, 0, scale*mScaleStep, twist, droop, branches, alpha);
 			}
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index f80f751faaa..89444ff9452 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1797,22 +1797,11 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
         }
     }
 
-    bool rigged = false;
-
-    if (!isAnimatedObject())
-    {
-        rigged = isRiggedMesh() && isAttachment();
-    }
-    else
-    {
-        rigged = isRiggedMesh() && getControlAvatar() && getControlAvatar()->mPlaying;
-    }
-
     if (any_valid_boxes)
     {
         if (rebuild)
         {
-#ifdef SHOW_DEBUG
+            //get the Avatar associated with this object if it's rigged
             LLVOAvatar* avatar = nullptr;
             if (isRiggedMesh())
             {
@@ -1832,7 +1821,7 @@ BOOL LLVOVolume::genBBoxes(BOOL force_global)
                     }
                 }
             }
-#endif
+
             mDrawable->setSpatialExtents(min, max);
 
             if (avatar)
@@ -1900,7 +1889,7 @@ void LLVOVolume::updateRelativeXform(bool force_identity)
 		}
 		else
 		{
-			mRelativeXform = LLQuaternion2(mDrawable->getRotation());
+			mRelativeXform = LLMatrix4a(LLQuaternion2(mDrawable->getRotation()));
 			mRelativeXform.applyScale_affine(mDrawable->getScale());
 			mRelativeXform.setTranslate_affine(mDrawable->getPosition());
 		}
@@ -1916,7 +1905,7 @@ void LLVOVolume::updateRelativeXform(bool force_identity)
 		LLQuaternion2 rot(getRotation());
 		if (mParent)
 		{
-			LLMatrix4a lrot = LLQuaternion2(mParent->getRotation());
+			LLMatrix4a lrot = LLMatrix4a(LLQuaternion2(mParent->getRotation()));
 			lrot.rotate(pos,pos);
 			LLVector4a lpos;
 			lpos.load3(mParent->getPosition().mV);
@@ -1924,7 +1913,7 @@ void LLVOVolume::updateRelativeXform(bool force_identity)
 			rot.mul(LLQuaternion2(mParent->getRotation()));
 		}
 
-		mRelativeXform = rot;
+		mRelativeXform = LLMatrix4a(rot);
 		mRelativeXform.applyScale_affine(getScale());
 		mRelativeXform.setTranslate_affine(LLVector3(pos.getF32ptr()));
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 415d1cefb7a..33616f4375d 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -3982,7 +3982,7 @@ void LLPipeline::postSort(LLCamera& camera)
                 if (!sShadowRender && !sReflectionRender)
                 {
                     touchTextures(info);
-                    addTrianglesDrawn(info->mCount, info->mDrawMode);
+                    //addTrianglesDrawn(info->mCount, info->mDrawMode);
                 }
 			}
 		}
@@ -8623,9 +8623,10 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target)
     LLRenderTarget *deferred_depth_target = &mDeferredDepth;
     LLRenderTarget *deferred_light_target = &mDeferredLight;
 
+	LLViewerCamera& camera = LLViewerCamera::instance();
+
     {
         LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED);
-        LLViewerCamera *camera = LLViewerCamera::getInstance();
         {
             LLGLDepthTest depth(GL_TRUE);
             deferred_depth_target->copyContents(*deferred_target,
diff --git a/indra/newview/rlveffects.cpp b/indra/newview/rlveffects.cpp
index b4b661f2d44..74e74fcc73c 100644
--- a/indra/newview/rlveffects.cpp
+++ b/indra/newview/rlveffects.cpp
@@ -114,10 +114,7 @@ void RlvOverlayEffect::run(const LLVisualEffectParams*)
 {
 	if (m_pImage)
 	{
-		if (LLGLSLShader::sNoFixedFunction)
-		{
-			gUIProgram.bind();
-		}
+		gUIProgram.bind();
 
 		int nWidth = gViewerWindow->getWorldViewWidthScaled();
 		int nHeight = gViewerWindow->getWorldViewHeightScaled();
@@ -144,10 +141,7 @@ void RlvOverlayEffect::run(const LLVisualEffectParams*)
 		gGL.flush();
 		gViewerWindow->setup3DRender();
 
-		if (LLGLSLShader::sNoFixedFunction)
-		{
-			gUIProgram.unbind();
-		}
+		gUIProgram.unbind();
 	}
 }
 
diff --git a/indra/newview/rlvmodifiers.h b/indra/newview/rlvmodifiers.h
index 374ef585670..a17a7525a1e 100644
--- a/indra/newview/rlvmodifiers.h
+++ b/indra/newview/rlvmodifiers.h
@@ -121,7 +121,7 @@ class RlvCachedBehaviourModifier
 public:
 	RlvCachedBehaviourModifier(ERlvBehaviourModifier eModifier)
 	{
-		if ((mCachedModifierPtr = RlvBehaviourModifierCache<T>::getInstance(eModifier)) == nullptr)
+		if ((mCachedModifierPtr = RlvBehaviourModifierCache<T>::getInstance(eModifier).get()) == nullptr)
 			mCachedModifierPtr = new RlvBehaviourModifierCache<T>(eModifier);
 	}
 
-- 
GitLab