From 9c7ec66d248369ebfb589a9c84cf951f8d4b93b5 Mon Sep 17 00:00:00 2001
From: Runitai Linden <davep@lindenlab.com>
Date: Mon, 24 Jan 2022 11:04:11 -0600
Subject: [PATCH] SL-16691 Add GPU memory bandwidth to ViewerStats

---
 indra/newview/llfeaturemanager.cpp | 2 ++
 indra/newview/llfeaturemanager.h   | 5 +++++
 indra/newview/llviewerstats.cpp    | 1 +
 3 files changed, 8 insertions(+)

diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index c3780e42c6d..08130577145 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -419,6 +419,8 @@ bool LLFeatureManager::loadGPUClass()
 			LL_WARNS("RenderInit") << "GPU benchmark failed: " << e.what() << LL_ENDL;
 		}
 	
+        mGPUMemoryBandwidth = gbps;
+
         // bias by CPU speed
         F32 cpu_basis_mhz = gSavedSettings.getF32("RenderCPUBasis");
         F32 cpu_mhz = (F32) gSysCPU.getMHz();
diff --git a/indra/newview/llfeaturemanager.h b/indra/newview/llfeaturemanager.h
index 42a226cd18f..651404d8905 100644
--- a/indra/newview/llfeaturemanager.h
+++ b/indra/newview/llfeaturemanager.h
@@ -111,6 +111,10 @@ class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManag
 
 	EGPUClass getGPUClass() 			{ return mGPUClass; }
 	std::string& getGPUString() 		{ return mGPUString; }
+    
+    // get the measured GPU memory bandwidth in GB/sec
+    // may return 0 of benchmark has not been run or failed to run
+    F32 getGPUMemoryBandwidth() { return mGPUMemoryBandwidth; }
 	BOOL isGPUSupported()				{ return mGPUSupported; }
 	F32 getExpectedGLVersion()			{ return mExpectedGLVersion; }
 	
@@ -162,6 +166,7 @@ class LLFeatureManager : public LLFeatureList, public LLSingleton<LLFeatureManag
 	S32			mTableVersion;
 	BOOL		mSafe;					// Reinitialize everything to the "safe" mask
 	EGPUClass	mGPUClass;
+    F32         mGPUMemoryBandwidth = 0.f;  // measured memory bandwidth of GPU in GB/second
 	F32			mExpectedGLVersion;		//expected GL version according to gpu table
 	std::string	mGPUString;
 	BOOL		mGPUSupported;
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 5ce97c086d1..a560778ef43 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -512,6 +512,7 @@ void send_viewer_stats(bool include_preferences)
 
 	system["gpu"] = gpu_desc;
 	system["gpu_class"] = (S32)LLFeatureManager::getInstance()->getGPUClass();
+    system["gpu_memory_bandwidth"] = LLFeatureManager::getInstance()->getGPUMemoryBandwidth();
 	system["gpu_vendor"] = gGLManager.mGLVendorShort;
 	system["gpu_version"] = gGLManager.mDriverVersionVendorString;
 	system["opengl_version"] = gGLManager.mGLVersionString;
-- 
GitLab