From 3e0407e8c160ba6f79fb25e9e4ea21f3b68f9aa9 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sat, 11 Apr 2020 20:54:43 -0400
Subject: [PATCH] Cache frequently hit RenderNormalMapScale

---
 indra/newview/lldrawpoolbump.cpp | 4 ++--
 indra/newview/pipeline.cpp       | 4 +++-
 indra/newview/pipeline.h         | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index 43d0b5d6e5f..962552d19fa 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -1171,7 +1171,7 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr
 
 	S32 src_cmp = src->getComponents();
 
-	F32 norm_scale = gSavedSettings.getF32("RenderNormalMapScale");
+	F32 norm_scale = LLPipeline::RenderNormalMapScale;
 
 	U32 idx = 0;
 	//generate normal map from pseudo-heightfield
@@ -1405,7 +1405,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
 					static LLStaticHashedString sStepX("stepX");
 					static LLStaticHashedString sStepY("stepY");
 
-					gNormalMapGenProgram.uniform1f(sNormScale, gSavedSettings.getF32("RenderNormalMapScale"));
+					gNormalMapGenProgram.uniform1f(sNormScale, LLPipeline::RenderNormalMapScale);
 					gNormalMapGenProgram.uniform1f(sStepX, 1.f/bump->getWidth());
 					gNormalMapGenProgram.uniform1f(sStepY, 1.f/bump->getHeight());
 
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index dba41c503b5..8688802df57 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -214,6 +214,7 @@ bool LLPipeline::CameraOffset;
 F32 LLPipeline::CameraMaxCoF;
 F32 LLPipeline::CameraDoFResScale;
 F32 LLPipeline::RenderAutoHideSurfaceAreaLimit;
+F32 LLPipeline::RenderNormalMapScale;
 LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
 
 const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
@@ -618,7 +619,7 @@ void LLPipeline::init()
 	connectRefreshCachedSettingsSafe("CameraMaxCoF");
 	connectRefreshCachedSettingsSafe("CameraDoFResScale");
 	connectRefreshCachedSettingsSafe("RenderAutoHideSurfaceAreaLimit");
-	gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings));
+	connectRefreshCachedSettingsSafe("RenderNormalMapScale");
 }
 
 LLPipeline::~LLPipeline()
@@ -1194,6 +1195,7 @@ void LLPipeline::refreshCachedSettings()
 	CameraMaxCoF = gSavedSettings.getF32("CameraMaxCoF");
 	CameraDoFResScale = gSavedSettings.getF32("CameraDoFResScale");
 	RenderAutoHideSurfaceAreaLimit = gSavedSettings.getF32("RenderAutoHideSurfaceAreaLimit");
+	RenderNormalMapScale = gSavedSettings.getF32("RenderNormalMapScale");
 	RenderSpotLight = nullptr;
 	updateRenderDeferred();
 }
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index ace36b5d97f..a6570b1437a 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -960,6 +960,7 @@ class LLPipeline
 	static F32 CameraMaxCoF;
 	static F32 CameraDoFResScale;
 	static F32 RenderAutoHideSurfaceAreaLimit;
+	static F32 RenderNormalMapScale;
 };
 
 void render_bbox(const LLVector3 &min, const LLVector3 &max);
-- 
GitLab