From a513bee2f247d7cf9cd8e9c3d50f2bd48f136776 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 1 Jun 2011 13:00:14 -0700 Subject: meta: Don't do srgb to linear decode when blitting srgb textures. Fixes the GL_SRGB8_ALPHA8 -> GL_RGBA8 blits in fbo-srgb-blit.c Reviewed-by: Brian Paul --- src/mesa/drivers/common/meta.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/mesa/drivers/common') diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 08b6024639f..a0d4b9e7cf7 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1186,6 +1186,7 @@ blitframebuffer_texture(struct gl_context *ctx, const GLint maxLevelSave = texObj->MaxLevel; const GLenum wrapSSave = texObj->Sampler.WrapS; const GLenum wrapTSave = texObj->Sampler.WrapT; + const GLenum srgbSave = texObj->Sampler.sRGBDecode; const GLenum target = texObj->Target; if (drawAtt->Texture == readAtt->Texture) { @@ -1217,6 +1218,12 @@ blitframebuffer_texture(struct gl_context *ctx, } _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + if (ctx->Extensions.EXT_texture_sRGB_decode) { + _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, + GL_SKIP_DECODE_EXT); + } + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); _mesa_set_enable(ctx, target, GL_TRUE); @@ -1278,6 +1285,9 @@ blitframebuffer_texture(struct gl_context *ctx, } _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, wrapSSave); _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, wrapTSave); + if (ctx->Extensions.EXT_texture_sRGB_decode) { + _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave); + } /* Done with color buffer */ mask &= ~GL_COLOR_BUFFER_BIT; -- cgit v1.2.3 From e8ea8793e3c65f7feef063c6edc7b86bf0e66997 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 1 Jun 2011 13:15:28 -0700 Subject: meta: Don't do sRGB encode for framebuffer blits on sRGB-enabled framebuffers. Fixes fbo-srgb-blit. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=35373 Reviewed-by: Brian Paul --- src/mesa/drivers/common/meta.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/mesa/drivers/common') diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index a0d4b9e7cf7..979926a7e8f 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1187,6 +1187,7 @@ blitframebuffer_texture(struct gl_context *ctx, const GLenum wrapSSave = texObj->Sampler.WrapS; const GLenum wrapTSave = texObj->Sampler.WrapT; const GLenum srgbSave = texObj->Sampler.sRGBDecode; + const GLenum fbo_srgb_save = ctx->Color.sRGBEnabled; const GLenum target = texObj->Target; if (drawAtt->Texture == readAtt->Texture) { @@ -1219,10 +1220,12 @@ blitframebuffer_texture(struct gl_context *ctx, _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + /* Always do our blits with no sRGB decode or encode.*/ if (ctx->Extensions.EXT_texture_sRGB_decode) { _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); } + _mesa_Disable(GL_FRAMEBUFFER_SRGB_EXT); _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); _mesa_set_enable(ctx, target, GL_TRUE); @@ -1288,6 +1291,9 @@ blitframebuffer_texture(struct gl_context *ctx, if (ctx->Extensions.EXT_texture_sRGB_decode) { _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, srgbSave); } + if (ctx->Extensions.EXT_texture_sRGB_decode && fbo_srgb_save) { + _mesa_Enable(GL_FRAMEBUFFER_SRGB_EXT); + } /* Done with color buffer */ mask &= ~GL_COLOR_BUFFER_BIT; -- cgit v1.2.3