summaryrefslogtreecommitdiff
path: root/indra/llrender/llglslshader.cpp
diff options
context:
space:
mode:
authorPtolemy <ptolemy@lindenlab.com>2021-04-29 08:41:50 -0700
committerPtolemy <ptolemy@lindenlab.com>2021-04-29 14:07:57 -0700
commite371fdbf311e450ac0cc7f4d3fdacc938b489d92 (patch)
treeff5d1dec0a5371a661ccf103bf68ebac2f1ec3d3 /indra/llrender/llglslshader.cpp
parenteb1e2a231410f8d2fefa4b4903b46b24f4259b04 (diff)
SL-14113: Remove magic numbers. Take advantage of existing shader #defines injection by extending shader loading to make use of addConstant() instead of hard-coding magic number constants in each GLSL file.
Diffstat (limited to 'indra/llrender/llglslshader.cpp')
-rw-r--r--indra/llrender/llglslshader.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 74cfa60b27..458f83aabe 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -62,6 +62,23 @@ U32 LLGLSLShader::sTotalDrawCalls = 0;
LLGLSLShader gUIProgram;
LLGLSLShader gSolidColorProgram;
+// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync!
+const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] =
+{
+ "LL_SHADER_CONST_CLOUD_DEPTH"
+ , "LL_SHADER_CONST_MOON_DEPTH"
+ , "LL_SHADER_CONST_STAR_DEPTH"
+};
+
+// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync!
+const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] =
+{
+ "0.999985" // SHADER_CONST_CLOUD_DEPTH // SL-14113
+ , "0.999985" // SHADER_CONST_MOON_DEPTH // SL-14113
+ , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113
+};
+
+
BOOL shouldChange(const LLVector4& v1, const LLVector4& v2)
{
return v1 != v2;
@@ -755,6 +772,11 @@ void LLGLSLShader::addPermutation(std::string name, std::string value)
mDefines[name] = value;
}
+void LLGLSLShader::addConstant( const LLGLSLShader::eShaderConsts shader_const )
+{
+ addPermutation( gShaderConstsKey[ shader_const ], gShaderConstsVal[ shader_const ] );
+}
+
void LLGLSLShader::removePermutation(std::string name)
{
mDefines[name].erase();