diff options
author | Geenz <geenz@geenzo.com> | 2019-03-30 17:22:54 -0700 |
---|---|---|
committer | Geenz <geenz@geenzo.com> | 2019-03-30 17:22:54 -0700 |
commit | a158c879578822a116e3f6a8c5dbbd1a14bb8c83 (patch) | |
tree | df80bb3400bd19d69561902cc40bf9fc6b2fde12 /indra/llrender | |
parent | 2513aa0ed1331ca022fb8bbd7442b1ba750ead4d (diff) |
Hide sRGB decode behind a flag, and make sure that sRGB decodes is strictly opt-in.
Diffstat (limited to 'indra/llrender')
-rw-r--r-- | indra/llrender/llgl.cpp | 6 | ||||
-rw-r--r-- | indra/llrender/llgl.h | 1 | ||||
-rw-r--r-- | indra/llrender/llrender.cpp | 43 | ||||
-rw-r--r-- | indra/llrender/llrender.h | 2 |
4 files changed, 36 insertions, 16 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 54a41c9d23..d18512f613 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -999,6 +999,12 @@ void LLGLManager::initExtensions() mHassRGBFramebuffer = ExtensionExists("GL_EXT_framebuffer_sRGB", gGLHExts.mSysExts); #endif +#ifdef GL_EXT_texture_sRGB_decode + mHasTexturesRGBDecode = ExtensionExists("GL_EXT_texture_sRGB_decode", gGLHExts.mSysExts); +#else + mHasTexturesRGBDecode = ExtensionExists("GL_ARB_texture_sRGB_decode", gGLHExts.mSysExts); +#endif + mHasMipMapGeneration = mHasFramebufferObject || mGLVersion >= 1.4f; mHasDrawBuffers = ExtensionExists("GL_ARB_draw_buffers", gGLHExts.mSysExts); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 362fda5fb1..a7faea7d33 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -118,6 +118,7 @@ public: BOOL mHasDebugOutput; BOOL mHassRGBTexture; BOOL mHassRGBFramebuffer; + BOOL mHasTexturesRGBDecode; // Vendor-specific extensions BOOL mIsATI; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 53a30a63c4..5dc61d0e8f 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -105,7 +105,7 @@ LLTexUnit::LLTexUnit(S32 index) mCurrColorOp(TBO_MULT), mCurrAlphaOp(TBO_MULT), mCurrColorSrc1(TBS_TEX_COLOR), mCurrColorSrc2(TBS_PREV_COLOR), mCurrAlphaSrc1(TBS_TEX_ALPHA), mCurrAlphaSrc2(TBS_PREV_ALPHA), - mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0), + mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0), mTexColorSpace(TCS_LINEAR), mHasMipMaps(false), mIndex(index) { @@ -162,6 +162,8 @@ void LLTexUnit::refreshState(void) setTextureCombiner(mCurrColorOp, mCurrColorSrc1, mCurrColorSrc2, false); setTextureCombiner(mCurrAlphaOp, mCurrAlphaSrc1, mCurrAlphaSrc2, true); } + + setTextureColorSpace(mTexColorSpace); } void LLTexUnit::activate(void) @@ -191,7 +193,6 @@ void LLTexUnit::enable(eTextureType type) stop_glerror(); } mCurrTexType = type; - gGL.flush(); if (!LLGLSLShader::sNoFixedFunction && type != LLTexUnit::TT_MULTISAMPLE_TEXTURE && @@ -219,6 +220,8 @@ void LLTexUnit::disable(void) { glDisable(sGLTextureType[mCurrTexType]); } + + setTextureColorSpace(TCS_LINEAR); mCurrTexType = TT_NONE; } @@ -255,7 +258,8 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) gl_tex->mTexOptionsDirty = false; setTextureAddressMode(gl_tex->mAddressMode); setTextureFilteringOption(gl_tex->mFilterOption); - } + } + setTextureColorSpace(mTexColorSpace); } } else @@ -330,6 +334,7 @@ bool LLTexUnit::bind(LLImageGL* texture, bool for_rendering, bool forceBind) setTextureFilteringOption(texture->mFilterOption); stop_glerror(); } + setTextureColorSpace(mTexColorSpace); } stop_glerror(); @@ -355,7 +360,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) { activate(); enable(LLTexUnit::TT_CUBE_MAP); - mCurrTexture = cubeMap->mImages[0]->getTexName(); + mCurrTexture = cubeMap->mImages[0]->getTexName(); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, mCurrTexture); mHasMipMaps = cubeMap->mImages[0]->mHasMipMaps; cubeMap->mImages[0]->updateBindStats(cubeMap->mImages[0]->mTextureMemory); @@ -364,7 +369,8 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap) cubeMap->mImages[0]->mTexOptionsDirty = false; setTextureAddressMode(cubeMap->mImages[0]->mAddressMode); setTextureFilteringOption(cubeMap->mImages[0]->mFilterOption); - } + } + setTextureColorSpace(mTexColorSpace); return true; } else @@ -415,7 +421,8 @@ bool LLTexUnit::bindManual(eTextureType type, U32 texture, bool hasMips) enable(type); mCurrTexture = texture; glBindTexture(sGLTextureType[type], texture); - mHasMipMaps = hasMips; + mHasMipMaps = hasMips; + setTextureColorSpace(mTexColorSpace); } return true; } @@ -435,6 +442,9 @@ void LLTexUnit::unbind(eTextureType type) if (mCurrTexType == type) { mCurrTexture = 0; + + // Always make sure our texture color space is reset to linear. SRGB sampling should be opt-in in the vast majority of cases. Also prevents color space "popping". + mTexColorSpace = TCS_LINEAR; if (LLGLSLShader::sNoFixedFunction && type == LLTexUnit::TT_TEXTURE) { glBindTexture(sGLTextureType[type], sWhiteTexture); @@ -840,15 +850,18 @@ void LLTexUnit::debugTextureUnit(void) void LLTexUnit::setTextureColorSpace(eTextureColorSpace space) { mTexColorSpace = space; - if (space == TCS_SRGB) { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); - } - else { - glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); - } - - if (gDebugGL) { - assert_glerror(); + if (gGLManager.mHasTexturesRGBDecode) { + + if (space == TCS_SRGB) { + glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_DECODE_EXT); + } + else { + glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); + } + + if (gDebugGL) { + assert_glerror(); + } } } diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index 2f15edc20e..41f4fe4017 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -159,7 +159,7 @@ public: // Binds the LLImageGL to this texture unit // (automatically enables the unit for the LLImageGL's texture type) bool bind(LLImageGL* texture, bool for_rendering = false, bool forceBind = false); - bool bind(LLTexture* texture, bool for_rendering = false, bool forceBind = false); + bool bind(LLTexture* texture, bool for_rendering = false, bool forceBind = false); // Binds a cubemap to this texture unit // (automatically enables the texture unit for cubemaps) |