summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2018-06-01 15:34:21 +0100
committerGraham Linden <graham@lindenlab.com>2018-06-01 15:34:21 +0100
commit37e8fd20c3823482f3a15b4bfd544f7847070db8 (patch)
treeb31e3a1ef86431cda7703621f779b38a98c14a3e /indra/llrender
parent64302d3000b69b31e72eb6a3bd8a981c80cb88de (diff)
parentbd84cbfa11fbe2b3aa5ceba5978841310488b8e4 (diff)
Merge to 5.1.6
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/CMakeLists.txt2
-rw-r--r--indra/llrender/llgl.h17
-rw-r--r--indra/llrender/llglcommonfunc.cpp37
-rw-r--r--indra/llrender/llglcommonfunc.h30
-rw-r--r--indra/llrender/llglslshader.cpp54
-rw-r--r--indra/llrender/llglslshader.h11
-rw-r--r--indra/llrender/llvertexbuffer.cpp16
-rw-r--r--indra/llrender/llvertexbuffer.h4
8 files changed, 138 insertions, 33 deletions
diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt
index 26aaf10d07..bcb5a847f6 100644
--- a/indra/llrender/CMakeLists.txt
+++ b/indra/llrender/CMakeLists.txt
@@ -54,6 +54,7 @@ set(llrender_SOURCE_FILES
lltexture.cpp
lluiimage.cpp
llvertexbuffer.cpp
+ llglcommonfunc.cpp
)
set(llrender_HEADER_FILES
@@ -82,6 +83,7 @@ set(llrender_HEADER_FILES
lltexture.h
lluiimage.h
llvertexbuffer.h
+ llglcommonfunc.h
)
set_source_files_properties(${llrender_HEADER_FILES}
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index aa98b3f6bc..4c4302d05b 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -256,6 +256,9 @@ void clear_glerror();
if the existing GL state does not match the expected GL state.
*/
+
+#include "boost/function.hpp"
+
class LLGLState
{
public:
@@ -297,6 +300,20 @@ public:
LLGLEnableAlphaReject(bool enable);
};
+// Enable with functor
+class LLGLEnableFunc : LLGLState
+{
+public:
+ LLGLEnableFunc(LLGLenum state, bool enable, boost::function<void()> func)
+ : LLGLState(state, enable)
+ {
+ if (enable)
+ {
+ func();
+ }
+ }
+};
+
/// TODO: Being deprecated.
class LLGLEnable : public LLGLState
{
diff --git a/indra/llrender/llglcommonfunc.cpp b/indra/llrender/llglcommonfunc.cpp
new file mode 100644
index 0000000000..e9ec28927f
--- /dev/null
+++ b/indra/llrender/llglcommonfunc.cpp
@@ -0,0 +1,37 @@
+/**
+* @file llglcommonfunc.cpp
+* @brief Implementation of the LLGLCommonFunc.
+*
+* $LicenseInfo:firstyear=2001&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2010, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+* $/LicenseInfo$
+*/
+
+#include "llglheaders.h"
+#include "llglcommonfunc.h"
+
+namespace LLGLCommonFunc
+{
+ void selected_stencil_test()
+ {
+ glStencilFunc(GL_ALWAYS, 2, 0xffff);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ }
+}
diff --git a/indra/llrender/llglcommonfunc.h b/indra/llrender/llglcommonfunc.h
new file mode 100644
index 0000000000..f1f8ff7bc4
--- /dev/null
+++ b/indra/llrender/llglcommonfunc.h
@@ -0,0 +1,30 @@
+/**
+* @file llphoenixfunc.h
+* @brief File include common opengl code snippets
+*
+* $LicenseInfo:firstyear=2003&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2010, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+* $/LicenseInfo$
+*/
+
+namespace LLGLCommonFunc
+{
+ void selected_stencil_test();
+}
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 9bdbc9c80a..b027a24017 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -755,24 +755,25 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
, even if the "diffuseMap" will be appear and use first in shader code.
As example where this situation appear see: "Deferred Material Shader 28/29/30/31"
- And tickets: MAINT-4165, MAINT-4839, MAINT-3568
+ And tickets: MAINT-4165, MAINT-4839, MAINT-3568, MAINT-6437
*/
S32 diffuseMap = glGetUniformLocationARB(mProgramObject, "diffuseMap");
+ S32 specularMap = glGetUniformLocationARB(mProgramObject, "specularMap");
S32 bumpMap = glGetUniformLocationARB(mProgramObject, "bumpMap");
S32 environmentMap = glGetUniformLocationARB(mProgramObject, "environmentMap");
std::set<S32> skip_index;
- if (-1 != diffuseMap && (-1 != bumpMap || -1 != environmentMap))
+ if (-1 != diffuseMap && (-1 != specularMap || -1 != bumpMap || -1 != environmentMap))
{
GLenum type;
GLsizei length;
GLint size = -1;
char name[1024];
- diffuseMap = bumpMap = environmentMap = -1;
+ diffuseMap = specularMap = bumpMap = environmentMap = -1;
for (S32 i = 0; i < activeCount; i++)
{
@@ -786,6 +787,18 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
continue;
}
+ if (-1 == specularMap && std::string(name) == "specularMap")
+ {
+ specularMap = i;
+ continue;
+ }
+
+ if (-1 == specularMap && std::string(name) == "specularMap")
+ {
+ specularMap = i;
+ continue;
+ }
+
if (-1 == bumpMap && std::string(name) == "bumpMap")
{
bumpMap = i;
@@ -799,34 +812,29 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
}
}
+ bool specularDiff = specularMap < diffuseMap && -1 != specularMap;
bool bumpLessDiff = bumpMap < diffuseMap && -1 != bumpMap;
bool envLessDiff = environmentMap < diffuseMap && -1 != environmentMap;
- if (bumpLessDiff && envLessDiff)
+ if (specularDiff || bumpLessDiff || envLessDiff)
{
mapUniform(diffuseMap, uniforms);
- mapUniform(bumpMap, uniforms);
- mapUniform(environmentMap, uniforms);
-
skip_index.insert(diffuseMap);
- skip_index.insert(bumpMap);
- skip_index.insert(environmentMap);
- }
- else if (bumpLessDiff)
- {
- mapUniform(diffuseMap, uniforms);
- mapUniform(bumpMap, uniforms);
- skip_index.insert(diffuseMap);
- skip_index.insert(bumpMap);
- }
- else if (envLessDiff)
- {
- mapUniform(diffuseMap, uniforms);
- mapUniform(environmentMap, uniforms);
+ if (-1 != specularMap) {
+ mapUniform(specularMap, uniforms);
+ skip_index.insert(specularMap);
+ }
- skip_index.insert(diffuseMap);
- skip_index.insert(environmentMap);
+ if (-1 != bumpMap) {
+ mapUniform(bumpMap, uniforms);
+ skip_index.insert(bumpMap);
+ }
+
+ if (-1 != environmentMap) {
+ mapUniform(environmentMap, uniforms);
+ skip_index.insert(environmentMap);
+ }
}
}
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 562cbdcba9..59edd7b36f 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -175,7 +175,18 @@ public:
typedef std::map < S32, magmin_values_t> magmin_filter_t;
GLhandleARB mProgramObject;
+#if LL_RELEASE_WITH_DEBUG_INFO
+ struct attr_name
+ {
+ GLint loc;
+ const char *name;
+ void operator = (GLint _loc) { loc = _loc; }
+ operator GLint () { return loc; }
+ };
+ std::vector<attr_name> mAttribute; //lookup table of attribute enum to attribute channel
+#else
std::vector<GLint> mAttribute; //lookup table of attribute enum to attribute channel
+#endif
U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask())
uniforms_index_t mUniform;
uniforms_index_t mTexture;
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index 7293fbfbcc..a33f84518f 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -327,7 +327,7 @@ void LLVBOPool::cleanup()
//NOTE: each component must be AT LEAST 4 bytes in size to avoid a performance penalty on AMD hardware
-S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
+const S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
{
sizeof(LLVector4), // TYPE_VERTEX,
sizeof(LLVector4), // TYPE_NORMAL,
@@ -344,7 +344,7 @@ S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
sizeof(LLVector4), // TYPE_TEXTURE_INDEX (actually exists as position.w), no extra data, but stride is 16 bytes
};
-static std::string vb_type_name[] =
+static const std::string vb_type_name[] =
{
"TYPE_VERTEX",
"TYPE_NORMAL",
@@ -363,7 +363,7 @@ static std::string vb_type_name[] =
"TYPE_INDEX",
};
-U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] =
+const U32 LLVertexBuffer::sGLMode[LLRender::NUM_MODES] =
{
GL_TRIANGLES,
GL_TRIANGLE_STRIP,
@@ -512,7 +512,7 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
}
}
- U32 map_tc[] =
+ static const U32 map_tc[] =
{
MAP_TEXCOORD1,
MAP_TEXCOORD2,
@@ -1382,7 +1382,7 @@ void LLVertexBuffer::setupVertexArray()
#endif
sGLRenderArray = mGLArray;
- U32 attrib_size[] =
+ static const U32 attrib_size[] =
{
3, //TYPE_VERTEX,
3, //TYPE_NORMAL,
@@ -1399,7 +1399,7 @@ void LLVertexBuffer::setupVertexArray()
1, //TYPE_TEXTURE_INDEX
};
- U32 attrib_type[] =
+ static const U32 attrib_type[] =
{
GL_FLOAT, //TYPE_VERTEX,
GL_FLOAT, //TYPE_NORMAL,
@@ -1416,7 +1416,7 @@ void LLVertexBuffer::setupVertexArray()
GL_UNSIGNED_INT, //TYPE_TEXTURE_INDEX
};
- bool attrib_integer[] =
+ static const bool attrib_integer[] =
{
false, //TYPE_VERTEX,
false, //TYPE_NORMAL,
@@ -1433,7 +1433,7 @@ void LLVertexBuffer::setupVertexArray()
true, //TYPE_TEXTURE_INDEX
};
- U32 attrib_normalized[] =
+ static const U32 attrib_normalized[] =
{
GL_FALSE, //TYPE_VERTEX,
GL_FALSE, //TYPE_NORMAL,
diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h
index bd27296eb6..c89d7e3958 100644
--- a/indra/llrender/llvertexbuffer.h
+++ b/indra/llrender/llvertexbuffer.h
@@ -341,8 +341,8 @@ public:
static bool sDisableVBOMapping; //disable glMapBufferARB
static bool sEnableVBOs;
- static S32 sTypeSize[TYPE_MAX];
- static U32 sGLMode[LLRender::NUM_MODES];
+ static const S32 sTypeSize[TYPE_MAX];
+ static const U32 sGLMode[LLRender::NUM_MODES];
static U32 sGLRenderBuffer;
static U32 sGLRenderArray;
static U32 sGLRenderIndices;