diff options
Diffstat (limited to 'indra/llrender')
38 files changed, 158 insertions, 56 deletions
diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index 331f988382..331f988382 100755..100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index af4e3fdda0..af4e3fdda0 100755..100644 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp diff --git a/indra/llrender/llcubemap.h b/indra/llrender/llcubemap.h index ee2c41e026..ee2c41e026 100755..100644 --- a/indra/llrender/llcubemap.h +++ b/indra/llrender/llcubemap.h diff --git a/indra/llrender/llfontbitmapcache.cpp b/indra/llrender/llfontbitmapcache.cpp index f128636ab2..f128636ab2 100755..100644 --- a/indra/llrender/llfontbitmapcache.cpp +++ b/indra/llrender/llfontbitmapcache.cpp diff --git a/indra/llrender/llfontbitmapcache.h b/indra/llrender/llfontbitmapcache.h index 75df3a94a7..75df3a94a7 100755..100644 --- a/indra/llrender/llfontbitmapcache.h +++ b/indra/llrender/llfontbitmapcache.h diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index de26d19efc..de26d19efc 100755..100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index a5ece42b88..a5ece42b88 100755..100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 53ca080d66..53ca080d66 100755..100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index 0988e99deb..0988e99deb 100755..100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp index d003687415..d003687415 100755..100644 --- a/indra/llrender/llfontregistry.cpp +++ b/indra/llrender/llfontregistry.cpp diff --git a/indra/llrender/llfontregistry.h b/indra/llrender/llfontregistry.h index 177eb6c8a5..177eb6c8a5 100755..100644 --- a/indra/llrender/llfontregistry.h +++ b/indra/llrender/llfontregistry.h diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index e24d3bb5ba..e24d3bb5ba 100755..100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 75e5fe86ec..75e5fe86ec 100755..100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h diff --git a/indra/llrender/llgldbg.cpp b/indra/llrender/llgldbg.cpp index 0f1d4ae742..0f1d4ae742 100755..100644 --- a/indra/llrender/llgldbg.cpp +++ b/indra/llrender/llgldbg.cpp diff --git a/indra/llrender/llgldbg.h b/indra/llrender/llgldbg.h index 963579cb82..963579cb82 100755..100644 --- a/indra/llrender/llgldbg.h +++ b/indra/llrender/llgldbg.h diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index a95872e883..a95872e883 100755..100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 3ceed95248..0f260674ed 100755..100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -702,37 +702,138 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type) BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms) { - BOOL res = TRUE; - - mTotalUniformSize = 0; - mActiveTextureChannels = 0; - mUniform.clear(); - mUniformMap.clear(); - mUniformNameMap.clear(); - mTexture.clear(); - mValue.clear(); - //initialize arrays - U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size(); - mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); - mTexture.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); - - bind(); - - //get the number of active uniforms - GLint activeCount; - glGetObjectParameterivARB(mProgramObject, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &activeCount); - - for (S32 i = 0; i < activeCount; i++) - { - mapUniform(i, uniforms); - } - - unbind(); - - LL_DEBUGS("ShaderLoading") << "Total Uniform Size: " << mTotalUniformSize << LL_ENDL; - return res; + BOOL res = TRUE; + + mTotalUniformSize = 0; + mActiveTextureChannels = 0; + mUniform.clear(); + mUniformMap.clear(); + mUniformNameMap.clear(); + mTexture.clear(); + mValue.clear(); + //initialize arrays + U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size(); + mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); + mTexture.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1); + + bind(); + + //get the number of active uniforms + GLint activeCount; + glGetObjectParameterivARB(mProgramObject, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &activeCount); + + //........................................................................................................................................ + //........................................................................................ + + /* + EXPLANATION: + This is part of code is temporary because as the final result the mapUniform() should be rewrited. + But it's a huge a volume of work which is need to be a more carefully performed for avoid possible + regression's (i.e. it should be formalized a separate ticket in JIRA). + + RESON: + The reason of this code is that SL engine is very sensitive to fact that "diffuseMap" should be appear + first as uniform parameter which is should get 0-"texture channel" index (see mapUniformTextureChannel() and mActiveTextureChannels) + it influence to which is texture matrix will be updated during rendering. + + But, order of indexe's of uniform variables is not defined and GLSL compiler can change it as want + , 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 + */ + + + S32 diffuseMap = glGetUniformLocationARB(mProgramObject, "diffuseMap"); + S32 bumpMap = glGetUniformLocationARB(mProgramObject, "bumpMap"); + S32 environmentMap = glGetUniformLocationARB(mProgramObject, "environmentMap"); + + std::set<S32> skip_index; + + if (-1 != diffuseMap && (-1 != bumpMap || -1 != environmentMap)) + { + GLenum type; + GLsizei length; + GLint size = -1; + char name[1024]; + + diffuseMap = bumpMap = environmentMap = -1; + + for (S32 i = 0; i < activeCount; i++) + { + name[0] = '\0'; + + glGetActiveUniformARB(mProgramObject, i, 1024, &length, &size, &type, (GLcharARB *)name); + + if (-1 == diffuseMap && std::string(name) == "diffuseMap") + { + diffuseMap = i; + continue; + } + + if (-1 == bumpMap && std::string(name) == "bumpMap") + { + bumpMap = i; + continue; + } + + if (-1 == environmentMap && std::string(name) == "environmentMap") + { + environmentMap = i; + continue; + } + } + + bool bumpLessDiff = bumpMap < diffuseMap && -1 != bumpMap; + bool envLessDiff = environmentMap < diffuseMap && -1 != environmentMap; + + if (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); + + skip_index.insert(diffuseMap); + skip_index.insert(environmentMap); + } + } + + //........................................................................................ + + for (S32 i = 0; i < activeCount; i++) + { + //........................................................................................ + if (skip_index.end() != skip_index.find(i)) continue; + //........................................................................................ + + mapUniform(i, uniforms); + } + //........................................................................................................................................ + + unbind(); + + LL_DEBUGS("ShaderLoading") << "Total Uniform Size: " << mTotalUniformSize << LL_ENDL; + return res; } + BOOL LLGLSLShader::link(BOOL suppress_errors) { BOOL success = LLShaderMgr::instance()->linkProgramObject(mProgramObject, suppress_errors); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 5abddf274b..5abddf274b 100755..100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h diff --git a/indra/llrender/llglstates.h b/indra/llrender/llglstates.h index 0e2c3bcb44..0e2c3bcb44 100755..100644 --- a/indra/llrender/llglstates.h +++ b/indra/llrender/llglstates.h diff --git a/indra/llrender/llgltypes.h b/indra/llrender/llgltypes.h index 6c217ef727..6c217ef727 100755..100644 --- a/indra/llrender/llgltypes.h +++ b/indra/llrender/llgltypes.h diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index ebed454271..ebed454271 100755..100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 21982eab1d..21982eab1d 100755..100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index b6ea5aa7f1..b6ea5aa7f1 100755..100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp diff --git a/indra/llrender/llpostprocess.h b/indra/llrender/llpostprocess.h index ce17b6693d..ce17b6693d 100755..100644 --- a/indra/llrender/llpostprocess.h +++ b/indra/llrender/llpostprocess.h diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 1ca6e99ecf..69420dd0bb 100755..100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -104,10 +104,10 @@ LLTexUnit::LLTexUnit(S32 index) mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR), mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA), mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0), - mHasMipMaps(false) + mHasMipMaps(false), + mIndex(index) { llassert_always(index < (S32)LL_NUM_TEXTURE_LAYERS); - mIndex = index; } //static @@ -227,33 +227,34 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) stop_glerror(); if (mIndex >= 0) { - gGL.flush(); + gGL.flush(); + + LLImageGL* gl_tex = NULL ; - LLImageGL* gl_tex = NULL ; if (texture != NULL && (gl_tex = texture->getGLTexture())) - { - if (gl_tex->getTexName()) //if texture exists - { - //in audit, replace the selected texture by the default one. - if ((mCurrTexture != gl_tex->getTexName()) || forceBind) - { - activate(); - enable(gl_tex->getTarget()); - mCurrTexture = gl_tex->getTexName(); - glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); - if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) - { - texture->setActive() ; - texture->updateBindStatsForTester() ; - } - mHasMipMaps = gl_tex->mHasMipMaps; - if (gl_tex->mTexOptionsDirty) { - gl_tex->mTexOptionsDirty = false; - setTextureAddressMode(gl_tex->mAddressMode); - setTextureFilteringOption(gl_tex->mFilterOption); - } - } + if (gl_tex->getTexName()) //if texture exists + { + //in audit, replace the selected texture by the default one. + if ((mCurrTexture != gl_tex->getTexName()) || forceBind) + { + activate(); + enable(gl_tex->getTarget()); + mCurrTexture = gl_tex->getTexName(); + glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture); + if(gl_tex->updateBindStats(gl_tex->mTextureMemory)) + { + texture->setActive() ; + texture->updateBindStatsForTester() ; + } + mHasMipMaps = gl_tex->mHasMipMaps; + if (gl_tex->mTexOptionsDirty) + { + gl_tex->mTexOptionsDirty = false; + setTextureAddressMode(gl_tex->mAddressMode); + setTextureFilteringOption(gl_tex->mFilterOption); + } + } } else { diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 42b02a8159..a67fb8da52 100755..100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -198,7 +198,7 @@ public: void setHasMipMaps(bool hasMips) { mHasMipMaps = hasMips; } protected: - S32 mIndex; + const S32 mIndex; U32 mCurrTexture; eTextureType mCurrTexType; eTextureBlendType mCurrBlendType; diff --git a/indra/llrender/llrendernavprim.cpp b/indra/llrender/llrendernavprim.cpp index ca72964832..ca72964832 100755..100644 --- a/indra/llrender/llrendernavprim.cpp +++ b/indra/llrender/llrendernavprim.cpp diff --git a/indra/llrender/llrendernavprim.h b/indra/llrender/llrendernavprim.h index a3a5dfec3a..a3a5dfec3a 100755..100644 --- a/indra/llrender/llrendernavprim.h +++ b/indra/llrender/llrendernavprim.h diff --git a/indra/llrender/llrendersphere.cpp b/indra/llrender/llrendersphere.cpp index 26bfe036e8..26bfe036e8 100755..100644 --- a/indra/llrender/llrendersphere.cpp +++ b/indra/llrender/llrendersphere.cpp diff --git a/indra/llrender/llrendersphere.h b/indra/llrender/llrendersphere.h index f8e9e86e7f..f8e9e86e7f 100755..100644 --- a/indra/llrender/llrendersphere.h +++ b/indra/llrender/llrendersphere.h diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index cd484b4fe9..cd484b4fe9 100755..100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index 6dc84d978d..6dc84d978d 100755..100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index b2be3cc3b6..b2be3cc3b6 100755..100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 394b38f832..394b38f832 100755..100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h diff --git a/indra/llrender/lltexture.cpp b/indra/llrender/lltexture.cpp index 90fbcec2be..90fbcec2be 100755..100644 --- a/indra/llrender/lltexture.cpp +++ b/indra/llrender/lltexture.cpp diff --git a/indra/llrender/lltexture.h b/indra/llrender/lltexture.h index 9fca8b8cd3..9fca8b8cd3 100755..100644 --- a/indra/llrender/lltexture.h +++ b/indra/llrender/lltexture.h diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 0fae600a90..0fae600a90 100755..100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index c05fd01595..c05fd01595 100755..100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h |