From 8c79297a8957fec13fadd2a2932b4b03b148d5a5 Mon Sep 17 00:00:00 2001
From: "Jonathan \"Geenz\" Goodman" <geenz@geenzo.com>
Date: Mon, 26 Feb 2024 01:21:41 -0800
Subject: [PATCH] #682 Further tweak the conservative update mechanism.

---
 indra/newview/app_settings/settings.xml | 13 ++++++++++++-
 indra/newview/llheroprobemanager.cpp    |  7 ++++++-
 indra/newview/llheroprobemanager.h      |  1 -
 indra/newview/pipeline.cpp              |  3 +++
 indra/newview/pipeline.h                |  1 +
 5 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 6a84f640307..e707e1eb5e5 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -10399,7 +10399,18 @@
     <key>Type</key>
     <string>S32</string>
     <key>Value</key>
-    <real>1</real>
+    <integer>2</integer>
+  </map>
+  <key>RenderHeroProbeConservativeUpdateMultiplier</key>
+  <map>
+    <key>Comment</key>
+    <string>How many probe updates to wait until it's time to update faces that are not directly facing the camera.  Acts as a multiplier.  E.g., frames to the periphery of the camera updating once every 3 updates, vs ones directly facing the camera updating every update.</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>S32</string>
+    <key>Value</key>
+    <integer>16</integer>
   </map>
     <key>RenderReflectionProbeVolumes</key>
     <map>
diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp
index 3adf4604326..a00b6d6b5d9 100644
--- a/indra/newview/llheroprobemanager.cpp
+++ b/indra/newview/llheroprobemanager.cpp
@@ -165,7 +165,12 @@ void LLHeroProbeManager::update()
             {
                 float shouldUpdate = cam_direction * cubeFaces[i] * 0.5 + 0.5;
                 
-                int updateRate = fmaxf(1, (1 - shouldUpdate) * 8);
+                int updateRate = ceilf((1 - shouldUpdate) * gPipeline.RenderHeroProbeConservativeUpdateMultiplier);
+                
+                // Chances are this is a face that's non-visible to the camera when it's being reflected.
+                // Set it to 0.  It will be skipped below.
+                if (updateRate == gPipeline.RenderHeroProbeConservativeUpdateMultiplier)
+                    updateRate = 0;
                 
                 mFaceUpdateList[i] = updateRate;
             }
diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h
index 038a8fd45a9..e430cae2032 100644
--- a/indra/newview/llheroprobemanager.h
+++ b/indra/newview/llheroprobemanager.h
@@ -138,7 +138,6 @@ class alignas(16) LLHeroProbeManager
     std::map<int, int> mFaceUpdateList;
     
     U32 mCurrentProbeUpdateFrame = 0;
-    U32 mLowPriorityFaceThrottle = 2;
     
     std::vector<LLVOVolume*>                       mHeroVOList;
     LLVOVolume*                                 mNearestHero;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index e3e2da3b30a..94ec5c0817b 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -200,6 +200,7 @@ S32 LLPipeline::RenderScreenSpaceReflectionGlossySamples;
 S32 LLPipeline::RenderBufferVisualization;
 bool LLPipeline::RenderMirrors;
 S32 LLPipeline::RenderHeroProbeUpdateRate;
+S32 LLPipeline::RenderHeroProbeConservativeUpdateMultiplier;
 LLTrace::EventStatHandle<S64> LLPipeline::sStatBatchSize("renderbatchsize");
 
 const U32 LLPipeline::MAX_BAKE_WIDTH = 512;
@@ -561,6 +562,7 @@ void LLPipeline::init()
 	connectRefreshCachedSettingsSafe("RenderBufferVisualization");
     connectRefreshCachedSettingsSafe("RenderMirrors");
     connectRefreshCachedSettingsSafe("RenderHeroProbeUpdateRate");
+    connectRefreshCachedSettingsSafe("RenderHeroProbeConservativeUpdateMultiplier");
 	gSavedSettings.getControl("RenderAutoHideSurfaceAreaLimit")->getCommitSignal()->connect(boost::bind(&LLPipeline::refreshCachedSettings));
 }
 
@@ -1074,6 +1076,7 @@ void LLPipeline::refreshCachedSettings()
         LLViewerShaderMgr::instance()->setShaders();
     }
     RenderHeroProbeUpdateRate = gSavedSettings.getS32("RenderHeroProbeUpdateRate");
+    RenderHeroProbeConservativeUpdateMultiplier = gSavedSettings.getS32("RenderHeroProbeConservativeUpdateMultiplier");
 
     sReflectionProbesEnabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionsEnabled") && gSavedSettings.getBOOL("RenderReflectionsEnabled");
 	RenderSpotLight = nullptr;
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index fe00c52e6d7..817750b4a1c 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -1057,6 +1057,7 @@ class LLPipeline
 	static S32 RenderBufferVisualization;
 	static bool RenderMirrors;
 	static S32 RenderHeroProbeUpdateRate;
+    static S32 RenderHeroProbeConservativeUpdateMultiplier;
 };
 
 void render_bbox(const LLVector3 &min, const LLVector3 &max);
-- 
GitLab