From 74904f39e15961ada40221be418bbd758a5969ef Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Fri, 29 Nov 2019 18:31:50 +0200 Subject: SL-1130 Prevent crash on mMatrix --- indra/llrender/llrender.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llrender.cpp') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 65d6181920..5bcccb35af 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1458,9 +1458,15 @@ void LLRender::matrixMode(U32 mode) if (mode == MM_TEXTURE) { mode = MM_TEXTURE0 + gGL.getCurrentTexUnitIndex(); + 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; } -- cgit v1.2.3 From 278853824d5da452f66f7dc4cc8858884f53505d Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 20 Apr 2020 21:44:34 +0300 Subject: Fixed merge conflict and restored SL-1130 --- indra/llrender/llrender.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/llrender/llrender.cpp') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index c3345c5c16..4e7c71a374 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1539,8 +1539,15 @@ 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); + llassert(tex_index <= 3); mode = eMatrixMode(MM_TEXTURE0 + gGL.getCurrentTexUnitIndex()); + 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; + } } mMatrixMode = mode; -- cgit v1.2.3 From abe5cc57873267724673c767ff3ec87016534a6c Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 21 Apr 2020 10:32:45 +0300 Subject: Fix for 'release' configuration llassert is not used in 'release' configuration and build fails due to unused tex_index --- indra/llrender/llrender.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llrender.cpp') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 4e7c71a374..9b5231ad06 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1540,7 +1540,7 @@ 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(tex_index <= 3); - mode = eMatrixMode(MM_TEXTURE0 + gGL.getCurrentTexUnitIndex()); + mode = eMatrixMode(MM_TEXTURE0 + tex_index); if (mode > MM_TEXTURE3) { // getCurrentTexUnitIndex() can go as high as 32 (LL_NUM_TEXTURE_LAYERS) -- cgit v1.2.3 From 84d30655967fa29cc800783db2cd43df6f28d35e Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Mon, 8 Jun 2020 15:47:41 -0600 Subject: SL-13281, add missing srgb->linear conversion for specular --- indra/llrender/llrender.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'indra/llrender/llrender.cpp') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 9b5231ad06..cabf0528f0 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -849,26 +849,32 @@ void LLTexUnit::debugTextureUnit(void) } } -void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) { +void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) +{ mTexColorSpace = space; #if USE_SRGB_DECODE - if (gGLManager.mHasTexturesRGBDecode) { - - if (space == TCS_SRGB) { + if (gGLManager.mHasTexturesRGBDecode) + { + if (space == TCS_SRGB) + { glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); } - else { + else + { glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); } - if (gDebugGL) { + if (gDebugGL) + { assert_glerror(); } } + else #endif - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); - + { + glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); + } } LLLightState::LLLightState(S32 index) -- cgit v1.2.3 From 107a7fec34df0160c959de81d0d682ec671b5958 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Tue, 4 Aug 2020 17:14:19 -0600 Subject: SL-13521 add an avatar appearance light to deferred mode --- indra/llrender/llrender.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llrender/llrender.cpp') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index cabf0528f0..e0d1ee4f4c 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1216,7 +1216,7 @@ void LLRender::syncLightState() LLVector3 diffuse_b[8]; bool sun_primary[8]; - for (U32 i = 0; i < 8; i++) + for (U32 i = 0; i < LL_NUM_LIGHT_UNITS; i++) { LLLightState* light = mLightState[i]; -- cgit v1.2.3 From 8b314a646f67c8b0ebb81c8b81400b6509c51737 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 5 Aug 2020 12:05:23 -0600 Subject: SL-13521, stamp out some remaining hard-coded 8s --- indra/llrender/llrender.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/llrender/llrender.cpp') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index e0d1ee4f4c..5208db48d2 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1209,12 +1209,12 @@ void LLRender::syncLightState() { 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 < LL_NUM_LIGHT_UNITS; i++) { @@ -1228,10 +1228,10 @@ void LLRender::syncLightState() 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_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); -- cgit v1.2.3 From 92ee1be5cf08158a40113a4bab5b7c5a9fc42055 Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Wed, 5 Aug 2020 12:30:24 -0600 Subject: SL-13521, clang-format LLRender::syncLightState() (whitespace) --- indra/llrender/llrender.cpp | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'indra/llrender/llrender.cpp') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 5208db48d2..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[LL_NUM_LIGHT_UNITS]; - LLVector3 direction[LL_NUM_LIGHT_UNITS]; - LLVector4 attenuation[LL_NUM_LIGHT_UNITS]; - LLVector3 diffuse[LL_NUM_LIGHT_UNITS]; + 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 < LL_NUM_LIGHT_UNITS; 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, 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->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() -- cgit v1.2.3