summaryrefslogtreecommitdiff
path: root/indra/llrender/llrender.cpp
diff options
context:
space:
mode:
authorGeenz <geenz@geenzo.com>2019-03-30 17:22:54 -0700
committerGeenz <geenz@geenzo.com>2019-03-30 17:22:54 -0700
commita158c879578822a116e3f6a8c5dbbd1a14bb8c83 (patch)
treedf80bb3400bd19d69561902cc40bf9fc6b2fde12 /indra/llrender/llrender.cpp
parent2513aa0ed1331ca022fb8bbd7442b1ba750ead4d (diff)
Hide sRGB decode behind a flag, and make sure that sRGB decodes is strictly opt-in.
Diffstat (limited to 'indra/llrender/llrender.cpp')
-rw-r--r--indra/llrender/llrender.cpp43
1 files changed, 28 insertions, 15 deletions
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();
+ }
}
}