From be1f7870bde1b81384ce0ea1d1a15808e7826630 Mon Sep 17 00:00:00 2001 From: Rye Date: Wed, 24 Sep 2025 10:58:40 -0400 Subject: [PATCH 1/2] Fix calling setTextureAddressModeFast and setTextureFilteringOptionFast with invalid tex type during fast binds --- indra/llrender/llrender.cpp | 38 ++++++++++++++++++------------------- indra/llrender/llrender.h | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 4f646cdc33..57be8570af 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -210,8 +210,8 @@ void LLTexUnit::bindFast(LLTexture* texture) if (gl_tex->mTexOptionsDirty) { gl_tex->mTexOptionsDirty = false; - setTextureAddressModeFast(gl_tex->mAddressMode); - setTextureFilteringOptionFast(gl_tex->mFilterOption); + setTextureAddressModeFast(gl_tex->mAddressMode, gl_tex->getTarget()); + setTextureFilteringOptionFast(gl_tex->mFilterOption, gl_tex->getTarget()); } } @@ -467,16 +467,16 @@ void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode) activate(); - setTextureAddressModeFast(mode); + setTextureAddressModeFast(mode, mCurrTexType); } -void LLTexUnit::setTextureAddressModeFast(eTextureAddressMode mode) +void LLTexUnit::setTextureAddressModeFast(eTextureAddressMode mode, eTextureType tex_type) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); - if (mCurrTexType == TT_CUBE_MAP) + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); + if (tex_type == TT_CUBE_MAP || tex_type == TT_CUBE_MAP_ARRAY || tex_type == TT_TEXTURE_3D) { - glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); } } @@ -486,44 +486,44 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio gGL.flush(); - setTextureFilteringOptionFast(option); + setTextureFilteringOptionFast(option, mCurrTexType); } -void LLTexUnit::setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions option) +void LLTexUnit::setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions option, eTextureType tex_type) { if (option == TFO_POINT) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MAG_FILTER, GL_NEAREST); } else { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MAG_FILTER, GL_LINEAR); } if (option >= TFO_TRILINEAR && mHasMipMaps) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } else if (option >= TFO_BILINEAR) { if (mHasMipMaps) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); } else { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_LINEAR); } } else { if (mHasMipMaps) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); } else { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(sGLTextureType[tex_type], GL_TEXTURE_MIN_FILTER, GL_NEAREST); } } @@ -531,11 +531,11 @@ void LLTexUnit::setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions o { if (LLImageGL::sGlobalUseAnisotropic && option == TFO_ANISOTROPIC) { - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy); + glTexParameterf(sGLTextureType[tex_type], GL_TEXTURE_MAX_ANISOTROPY, gGLManager.mMaxAnisotropy); } else { - glTexParameterf(sGLTextureType[mCurrTexType], GL_TEXTURE_MAX_ANISOTROPY, 1.f); + glTexParameterf(sGLTextureType[tex_type], GL_TEXTURE_MAX_ANISOTROPY, 1.f); } } } diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 755aee4bd6..0801c12fb4 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -209,14 +209,14 @@ class LLTexUnit // make sure you want to permanently change the address mode for the bound texture. void setTextureAddressMode(eTextureAddressMode mode); // MUST already be active and bound - void setTextureAddressModeFast(eTextureAddressMode mode); + void setTextureAddressModeFast(eTextureAddressMode mode, eTextureType tex_type); // Sets the filtering options used to sample the texture // Warning: this stays set for the bound texture forever, // make sure you want to permanently change the filtering for the bound texture. void setTextureFilteringOption(LLTexUnit::eTextureFilterOptions option); // MUST already be active and bound - void setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions option); + void setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions option, eTextureType tex_type); static U32 getInternalType(eTextureType type); From edfdd40bf9ae06941a72883f4a34dc9195e4b1c8 Mon Sep 17 00:00:00 2001 From: Rye Date: Fri, 26 Sep 2025 12:55:17 -0400 Subject: [PATCH 2/2] Restore mRT->screen to GL_RGBA16F to fix lighting banding --- indra/newview/pipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 2fe67a5457..856dee3dd4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -858,7 +858,7 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY) GLuint screenFormat = hdr ? GL_RGBA16F : GL_RGBA; - if (!mRT->screen.allocate(resX, resY, screenFormat)) return false; + if (!mRT->screen.allocate(resX, resY, GL_RGBA16F)) return false; mRT->deferredScreen.shareDepthBuffer(mRT->screen);