diff options
author | Dave Houlton <euclid@lindenlab.com> | 2020-09-29 14:02:22 -0600 |
---|---|---|
committer | Dave Houlton <euclid@lindenlab.com> | 2020-09-29 14:02:22 -0600 |
commit | eb6c8c937e214f58cc4da48bd4db455315de4c20 (patch) | |
tree | 529ce1546477d9620c18095ab73e54bbd7ea8d90 /indra/llrender | |
parent | 7781e1417e5a747a501e76ee9e976226a2656b6a (diff) | |
parent | bac6652cdcd2d8333df04c3ebd3a6a7b752328b3 (diff) |
Merge branch 'master' 6.4.10 into DRTVWR-510
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llrender.cpp | 66 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 2 |
2 files changed, 37 insertions, 31 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index eb9da34ca8..11d9ef3f57 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1198,46 +1198,46 @@ void LLRender::refreshState(void) void LLRender::syncLightState() { - LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + LLGLSLShader *shader = LLGLSLShader::sCurBoundShaderPtr; - if (!shader) - { - return; - } + if (!shader) + { + return; + } - if (shader->mLightHash != mLightHash) - { - shader->mLightHash = mLightHash; + if (shader->mLightHash != mLightHash) + { + shader->mLightHash = mLightHash; - LLVector4 position[8]; - LLVector3 direction[8]; - LLVector4 attenuation[8]; - LLVector3 diffuse[8]; - LLVector3 diffuse_b[8]; - bool sun_primary[8]; + LLVector4 position[LL_NUM_LIGHT_UNITS]; + LLVector3 direction[LL_NUM_LIGHT_UNITS]; + LLVector4 attenuation[LL_NUM_LIGHT_UNITS]; + LLVector3 diffuse[LL_NUM_LIGHT_UNITS]; + LLVector3 diffuse_b[LL_NUM_LIGHT_UNITS]; + bool sun_primary[LL_NUM_LIGHT_UNITS]; - for (U32 i = 0; i < 8; i++) - { - LLLightState* light = mLightState[i]; + for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; i++) + { + LLLightState *light = mLightState[i]; - position[i] = light->mPosition; - direction[i] = light->mSpotDirection; + position[i] = light->mPosition; + direction[i] = light->mSpotDirection; attenuation[i].set(light->mLinearAtten, light->mQuadraticAtten, light->mSpecular.mV[2], light->mSpecular.mV[3]); - diffuse[i].set(light->mDiffuse.mV); + diffuse[i].set(light->mDiffuse.mV); diffuse_b[i].set(light->mDiffuseB.mV); sun_primary[i] = light->mSunIsPrimary; - } + } - shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, 8, position[0].mV); - shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, 8, direction[0].mV); - shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, 8, attenuation[0].mV); - shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV); - shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); + shader->uniform4fv(LLShaderMgr::LIGHT_POSITION, LL_NUM_LIGHT_UNITS, position[0].mV); + shader->uniform3fv(LLShaderMgr::LIGHT_DIRECTION, LL_NUM_LIGHT_UNITS, direction[0].mV); + shader->uniform4fv(LLShaderMgr::LIGHT_ATTENUATION, LL_NUM_LIGHT_UNITS, attenuation[0].mV); + shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, LL_NUM_LIGHT_UNITS, diffuse[0].mV); + shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0); shader->uniform4fv(LLShaderMgr::AMBIENT, 1, mAmbientLightColor.mV); shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); - } + } } void LLRender::syncMatrices() @@ -1545,11 +1545,17 @@ void LLRender::matrixMode(eMatrixMode mode) { U32 tex_index = gGL.getCurrentTexUnitIndex(); // the shaders don't actually reference anything beyond texture_matrix0/1 outside of terrain rendering - llassert_always(tex_index <= 3); - mode = eMatrixMode(MM_TEXTURE0 + gGL.getCurrentTexUnitIndex()); + llassert(tex_index <= 3); + mode = eMatrixMode(MM_TEXTURE0 + tex_index); + if (mode > MM_TEXTURE3) + { + // getCurrentTexUnitIndex() can go as high as 32 (LL_NUM_TEXTURE_LAYERS) + // Large value will result in a crash at mMatrix + LL_WARNS_ONCE() << "Attempted to assign matrix mode out of bounds: " << mode << LL_ENDL; + mode = MM_TEXTURE0; + } } - llassert(mode < NUM_MATRIX_MODES); mMatrixMode = mode; } diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 1383020873..236ebbd78f 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1180,7 +1180,7 @@ void LLShaderMgr::initAttribsAndUniforms() llassert(mReservedUniforms.size() == LLShaderMgr::MULTI_LIGHT_FAR_Z+1); - + //NOTE: MUST match order in eGLSLReservedUniforms mReservedUniforms.push_back("proj_mat"); mReservedUniforms.push_back("proj_near"); mReservedUniforms.push_back("proj_p"); |