From 4caa2746f3b1d336947dcc9e277af8b8c08b44e0 Mon Sep 17 00:00:00 2001
From: davep <none@none>
Date: Fri, 19 Sep 2014 13:01:41 -0500
Subject: MAINT-3131 Discard improbably high memory bandwidth measurements on
 OSX and default to Class 3

---
 indra/newview/llfeaturemanager.cpp |  6 +++++-
 indra/newview/llglsandbox.cpp      | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

(limited to 'indra')

diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index 92e6f70566..4db0422634 100755
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -426,7 +426,10 @@ bool LLFeatureManager::loadGPUClass()
 
 	if (gbps < 0.f)
 	{ //couldn't bench, use GLVersion
-
+#if LL_DARWIN
+        //GLVersion is misleading on OSX, just default to class 3 if we can't bench
+        mGPUClass = GPU_CLASS_3;
+#else
 		if (gGLManager.mGLVersion < 2.f)
 		{
 			mGPUClass = GPU_CLASS_0;
@@ -447,6 +450,7 @@ bool LLFeatureManager::loadGPUClass()
 		{
 			mGPUClass = GPU_CLASS_4;
 		}
+#endif
 	}
 	else if (gbps < 5.f)
 	{
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index 0548de3895..4b8ac2b3cf 100755
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -928,7 +928,7 @@ F32 gpu_benchmark()
 	std::vector<F32> results;
 
 	//build a random texture
-	U8 pixels[res*res*4];
+	U8* pixels = new U8[res*res*4];
 
 	for (U32 i = 0; i < res*res*4; ++i)
 	{
@@ -950,6 +950,8 @@ F32 gpu_benchmark()
 		LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_RGBA, res,res,GL_RGBA, GL_UNSIGNED_BYTE, pixels);
 	}
 
+    delete [] pixels;
+
 	//make a dummy triangle to draw with
 	LLPointer<LLVertexBuffer> buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, GL_STATIC_DRAW_ARB);
 	buff->allocateBuffer(3, 0, true);
@@ -1031,7 +1033,16 @@ F32 gpu_benchmark()
 	F32 gbps = results[results.size()/2];
 
 	LL_INFOS() << "Memory bandwidth is " << llformat("%.3f", gbps) << "GB/sec according to CPU timers" << LL_ENDL;
-	
+  
+#if LL_DARWIN
+    if (gbps > 512.f)
+    { 
+        LL_INFOS() << "Memory bandwidth is improbably high and likely incorrect." << LL_ENDL;
+        //OSX is probably lying, discard result
+        gbps = -1.f;
+    }
+#endif
+
 	if (gGLManager.mHasTimerQuery)
 	{
 		F32 ms = gBenchmarkProgram.mTimeElapsed/1000000.f;
-- 
cgit v1.2.3