summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorGeenz <geenz@geenzo.com>2019-03-30 03:18:02 -0700
committerGeenz <geenz@geenzo.com>2019-03-30 03:18:02 -0700
commit2513aa0ed1331ca022fb8bbd7442b1ba750ead4d (patch)
treea600bb791f27a974d42742ab840daac82dbb040b /indra
parent9b34751614cf67ceddcae6e67f751ab02519b6a5 (diff)
Additional gamma correction work: start moving over to EXT_texture_sRGB_decode.
Diffstat (limited to 'indra')
-rw-r--r--indra/llrender/llglslshader.cpp7
-rw-r--r--indra/llrender/llglslshader.h4
-rw-r--r--indra/llrender/llimagegl.cpp4
-rw-r--r--indra/llrender/llrender.cpp14
-rw-r--r--indra/llrender/llrender.h11
-rw-r--r--indra/newview/pipeline.cpp11
6 files changed, 39 insertions, 12 deletions
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index 8f3a56e1cf..f8b5dd0559 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -974,7 +974,7 @@ S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
return uniform;
}
-S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
+S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace space)
{
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
@@ -986,11 +986,12 @@ S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
gGL.getTexUnit(index)->activate();
gGL.getTexUnit(index)->enable(mode);
+ gGL.getTexUnit(index)->setTextureColorSpace(space);
}
return index;
}
-S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
+S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode, LLTexUnit::eTextureColorSpace space)
{
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
@@ -1000,7 +1001,7 @@ S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
S32 index = mTexture[uniform];
if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE)
{
- if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode)
+ if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode && gGL.getTexUnit(index)->getCurrColorSpace() != space)
{
if (gDebugSession)
{
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index c1ce3d3aad..974d0ea005 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -153,8 +153,8 @@ public:
//if given texture uniform is active in the shader,
//the corresponding channel will be active upon return
//returns channel texture is enabled in from [0-MAX)
- S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
- S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
+ S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
+ S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE, LLTexUnit::eTextureColorSpace space = LLTexUnit::TCS_LINEAR);
// bindTexture returns the texture unit we've bound the texture to.
// You can reuse the return value to unbind a texture when required.
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 2d526a2113..8b51bf4b9f 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -1385,12 +1385,12 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S
mFormatType = GL_UNSIGNED_BYTE;
break;
case 3:
- mFormatInternal = GL_RGB8;
+ mFormatInternal = GL_SRGB8;
mFormatPrimary = GL_RGB;
mFormatType = GL_UNSIGNED_BYTE;
break;
case 4:
- mFormatInternal = GL_RGBA8;
+ mFormatInternal = GL_SRGB8_ALPHA8;
mFormatPrimary = GL_RGBA;
mFormatType = GL_UNSIGNED_BYTE;
break;
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 2bf7ad9902..53a30a63c4 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -838,6 +838,20 @@ 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();
+ }
+}
+
LLLightState::LLLightState(S32 index)
: mIndex(index),
mEnabled(false),
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index ad9cd11283..2f15edc20e 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -131,6 +131,12 @@ public:
TBS_ONE_MINUS_CONST_ALPHA
} eTextureBlendSrc;
+ typedef enum
+ {
+ TCS_LINEAR = 0,
+ TCS_SRGB
+ } eTextureColorSpace;
+
LLTexUnit(S32 index);
// Refreshes renderer state of the texture unit to the cached values
@@ -198,6 +204,10 @@ public:
void setHasMipMaps(bool hasMips) { mHasMipMaps = hasMips; }
+ void setTextureColorSpace(eTextureColorSpace space);
+
+ eTextureColorSpace getCurrColorSpace() { return mTexColorSpace; }
+
protected:
const S32 mIndex;
U32 mCurrTexture;
@@ -209,6 +219,7 @@ protected:
eTextureBlendOp mCurrAlphaOp;
eTextureBlendSrc mCurrAlphaSrc1;
eTextureBlendSrc mCurrAlphaSrc2;
+ eTextureColorSpace mTexColorSpace;
S32 mCurrColorScale;
S32 mCurrAlphaScale;
bool mHasMipMaps;
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index f84cd594c9..b9a917cfb4 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -8779,7 +8779,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
- gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION);
+ gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB);
for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter)
{
@@ -8807,7 +8807,8 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center));
}
- gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION);
+ gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB);
+
unbindDeferredShader(gDeferredSpotLightProgram);
}
@@ -8863,7 +8864,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
bindDeferredShader(gDeferredMultiSpotLightProgram);
- gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION);
+ gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB);
mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
@@ -8894,7 +8895,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target)
mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
}
- gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION);
+ gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB);
unbindDeferredShader(gDeferredMultiSpotLightProgram);
gGL.popMatrix();
@@ -9139,7 +9140,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
img = LLViewerFetchedTexture::sWhiteImagep;
}
- S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_PROJECTION);
+ S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB);
if (channel > -1)
{