summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndreyL ProductEngine <none@none>2018-01-29 22:02:32 +0200
committerAndreyL ProductEngine <none@none>2018-01-29 22:02:32 +0200
commited233126bbf4ec3cb4a8588b050fe7d4636267de (patch)
treeb2307c1d41c30cbc3cf1dccd1da5d4ab8685fcc0 /indra
parent3ec6b8eae41446d80a68ad57c030a80729badff7 (diff)
parentb654513257ea7e5f74d61c9b4586e480838be23c (diff)
Merged in lindenlab/viewer-bear
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llglsandbox.cpp171
1 files changed, 94 insertions, 77 deletions
diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp
index dc18d6c647..fc93181ef4 100644
--- a/indra/newview/llglsandbox.cpp
+++ b/indra/newview/llglsandbox.cpp
@@ -881,8 +881,100 @@ void LLViewerObjectList::renderObjectBeacons()
}
+//-----------------------------------------------------------------------------
+// gpu_benchmark() helper classes
+//-----------------------------------------------------------------------------
+
+// This struct is used to ensure that once we call initProfile(), it will
+// definitely be matched by a corresponding call to finishProfile(). It's
+// a struct rather than a class simply because every member is public.
+struct ShaderProfileHelper
+{
+ ShaderProfileHelper()
+ {
+ LLGLSLShader::initProfile();
+ }
+ ~ShaderProfileHelper()
+ {
+ LLGLSLShader::finishProfile(false);
+ }
+};
+
+// This helper class is used to ensure that each generateTextures() call
+// is matched by a corresponding deleteTextures() call. It also handles
+// the bindManual() calls using those textures.
+class TextureHolder
+{
+public:
+ TextureHolder(U32 unit, U32 size) :
+ texUnit(gGL.getTexUnit(unit)),
+ source(size) // preallocate vector
+ {
+ // takes (count, pointer)
+ // &vector[0] gets pointer to contiguous array
+ LLImageGL::generateTextures(source.size(), &source[0]);
+ }
+
+ ~TextureHolder()
+ {
+ // unbind
+ if (texUnit)
+ {
+ texUnit->unbind(LLTexUnit::TT_TEXTURE);
+ }
+ // ensure that we delete these textures regardless of how we exit
+ LLImageGL::deleteTextures(source.size(), &source[0]);
+ }
+
+ bool bind(U32 index)
+ {
+ if (texUnit) // should always be there with dummy (-1), but just in case
+ {
+ return texUnit->bindManual(LLTexUnit::TT_TEXTURE, source[index]);
+ }
+ return false;
+ }
+
+private:
+ // capture which LLTexUnit we're going to use
+ LLTexUnit* texUnit;
+
+ // use std::vector for implicit resource management
+ std::vector<U32> source;
+};
+
+class ShaderBinder
+{
+public:
+ ShaderBinder(LLGLSLShader& shader) :
+ mShader(shader)
+ {
+ mShader.bind();
+ }
+ ~ShaderBinder()
+ {
+ mShader.unbind();
+ }
+
+private:
+ LLGLSLShader& mShader;
+};
+
+
+//-----------------------------------------------------------------------------
+// gpu_benchmark()
+//-----------------------------------------------------------------------------
F32 gpu_benchmark()
{
+#if LL_WINDOWS
+ if (gGLManager.mIsIntel
+ && std::string::npos != LLOSInfo::instance().getOSStringSimple().find("Microsoft Windows 8")) // or 8.1
+ { // don't run benchmark on Windows 8/8.1 based PCs with Intel GPU (MAINT-8197)
+ LL_WARNS() << "Skipping gpu_benchmark() for Intel graphics on Windows 8." << LL_ENDL;
+ return -1.f;
+ }
+#endif
+
if (!gGLManager.mHasShaderObjects || !gGLManager.mHasTimerQuery)
{ // don't bother benchmarking the fixed function
// or venerable drivers which don't support accurate timing anyway
@@ -922,66 +1014,9 @@ F32 gpu_benchmark()
//number of samples to take
const S32 samples = 64;
-
- // This struct is used to ensure that once we call initProfile(), it will
- // definitely be matched by a corresponding call to finishProfile(). It's
- // a struct rather than a class simply because every member is public.
- struct ShaderProfileHelper
- {
- ShaderProfileHelper()
- {
- LLGLSLShader::initProfile();
- }
- ~ShaderProfileHelper()
- {
- LLGLSLShader::finishProfile(false);
- }
- };
+
ShaderProfileHelper initProfile;
-
- // This helper class is used to ensure that each generateTextures() call
- // is matched by a corresponding deleteTextures() call. It also handles
- // the bindManual() calls using those textures.
- class TextureHolder
- {
- public:
- TextureHolder(U32 unit, U32 size):
- texUnit(gGL.getTexUnit(unit)),
- source(size) // preallocate vector
- {
- // takes (count, pointer)
- // &vector[0] gets pointer to contiguous array
- LLImageGL::generateTextures(source.size(), &source[0]);
- }
-
- ~TextureHolder()
- {
- // unbind
- if (texUnit)
- {
- texUnit->unbind(LLTexUnit::TT_TEXTURE);
- }
- // ensure that we delete these textures regardless of how we exit
- LLImageGL::deleteTextures(source.size(), &source[0]);
- }
-
- bool bind(U32 index)
- {
- if (texUnit) // should always be there with dummy (-1), but just in case
- {
- return texUnit->bindManual(LLTexUnit::TT_TEXTURE, source[index]);
- }
- return false;
- }
-
- private:
- // capture which LLTexUnit we're going to use
- LLTexUnit* texUnit;
-
- // use std::vector for implicit resource management
- std::vector<U32> source;
- };
-
+
std::vector<LLRenderTarget> dest(count);
TextureHolder texHolder(0, count);
std::vector<F32> results;
@@ -994,7 +1029,6 @@ F32 gpu_benchmark()
pixels[i] = (U8) ll_rand(255);
}
-
gGL.setColorMask(true, true);
LLGLDepthTest depth(GL_FALSE);
@@ -1056,22 +1090,6 @@ F32 gpu_benchmark()
buff->flush();
// ensure matched pair of bind() and unbind() calls
- class ShaderBinder
- {
- public:
- ShaderBinder(LLGLSLShader& shader):
- mShader(shader)
- {
- mShader.bind();
- }
- ~ShaderBinder()
- {
- mShader.unbind();
- }
-
- private:
- LLGLSLShader& mShader;
- };
ShaderBinder binder(gBenchmarkProgram);
buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
@@ -1130,4 +1148,3 @@ F32 gpu_benchmark()
return gbps;
}
-