From e371fdbf311e450ac0cc7f4d3fdacc938b489d92 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 08:41:50 -0700 Subject: 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. --- indra/llrender/llglslshader.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'indra/llrender/llglslshader.cpp') 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(); -- cgit v1.2.3 From 3f4b8423a46bae4736ebcc28082ee1a9d5b71d6b Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 10:27:09 -0700 Subject: SL-14113: Merge duplicate shader constant for clarity. --- indra/llrender/llglslshader.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'indra/llrender/llglslshader.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 458f83aabe..74c8b2e448 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -62,20 +62,18 @@ U32 LLGLSLShader::sTotalDrawCalls = 0; LLGLSLShader gUIProgram; LLGLSLShader gSolidColorProgram; -// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +// 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_CLOUD_MOON_DEPTH" , "LL_SHADER_CONST_STAR_DEPTH" }; -// NOTE:Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! +// 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 + "0.999985" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 + , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 }; -- cgit v1.2.3 From d3c439b3743490ee22d5356ec3b61cb13c86f487 Mon Sep 17 00:00:00 2001 From: Ptolemy Date: Thu, 29 Apr 2021 14:06:37 -0700 Subject: SL-14113: Remove useless last digit in constant to help readability based on Euclid's feedback --- indra/llrender/llglslshader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llrender/llglslshader.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 74c8b2e448..d669e7134c 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -72,8 +72,8 @@ const std::string gShaderConstsKey[ LLGLSLShader::NUM_SHADER_CONSTS ] = // NOTE: Keep gShaderConsts* and LLGLSLShader::ShaderConsts_e in sync! const std::string gShaderConstsVal[ LLGLSLShader::NUM_SHADER_CONSTS ] = { - "0.999985" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 - , "0.999995" // SHADER_CONST_STAR_DEPTH // SL-14113 + "0.99998" // SHADER_CONST_CLOUD_MOON_DEPTH // SL-14113 + , "0.99999" // SHADER_CONST_STAR_DEPTH // SL-14113 }; -- cgit v1.2.3 From b854eceee3a867d64b20de18d6b7ce91b33abed0 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 11 Jun 2021 21:16:08 +0300 Subject: SL-15391 Crash at getUniformLocation --- indra/llrender/llglslshader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llglslshader.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 42b8c35442..d3942c7552 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -1427,7 +1427,11 @@ GLint LLGLSLShader::getUniformLocation(U32 index) GLint ret = -1; if (mProgramObject) { - llassert(index < mUniform.size()); + if (index >= mUniform.size()) + { + LL_WARNS_ONCE("Shader") << "Uniform index " << index << " out of bounds " << (S32)mUniform.size() << LL_ENDL; + return ret; + } return mUniform[index]; } -- cgit v1.2.3 From 7ce17542d46ff7cb6b88d33d4cad5ba4808c6c58 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 12 Nov 2021 17:34:13 +0200 Subject: DRTVWR-528 Reverting multiple commits due to moving them into D546 branch This reverts commits 9b5b2eac82b1f423daec463b3d55d0f3d3979bbc SL-15933 53c0144dd272470172591b967a84beaa4019b728 SL-11687 492ea7c3a03d5ef0d3679b873a44c08baaced0f1 SL-16056 b854eceee3a867d64b20de18d6b7ce91b33abed0 SL-15391 921c3f5f69c90b5924d2f4bbbd32455f8c9c8173 SL-13561 639acb6ff7495a6840d437dd8473172ec03e200a SL-15333 --- indra/llrender/llglslshader.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra/llrender/llglslshader.cpp') diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index d3942c7552..42b8c35442 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -1427,11 +1427,7 @@ GLint LLGLSLShader::getUniformLocation(U32 index) GLint ret = -1; if (mProgramObject) { - if (index >= mUniform.size()) - { - LL_WARNS_ONCE("Shader") << "Uniform index " << index << " out of bounds " << (S32)mUniform.size() << LL_ENDL; - return ret; - } + llassert(index < mUniform.size()); return mUniform[index]; } -- cgit v1.2.3