diff options
Diffstat (limited to 'src/mesa/drivers/common/meta.c')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 1b71aa19445..82b072eeb8c 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -2452,6 +2452,15 @@ _mesa_meta_check_generate_mipmap_fallback(struct gl_context *ctx, GLenum target, return GL_TRUE; } + if (_mesa_get_format_color_encoding(baseImage->TexFormat) == GL_SRGB && + !ctx->Extensions.EXT_texture_sRGB_decode) { + /* The texture format is sRGB but we can't turn off sRGB->linear + * texture sample conversion. So we won't be able to generate the + * right colors when rendering. Need to use a fallback. + */ + return GL_TRUE; + } + /* * Test that we can actually render in the texture's format. */ @@ -2669,6 +2678,8 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, const GLenum wrapSSave = texObj->Sampler.WrapS; const GLenum wrapTSave = texObj->Sampler.WrapT; const GLenum wrapRSave = texObj->Sampler.WrapR; + const GLenum srgbDecodeSave = texObj->Sampler.sRGBDecode; + const GLenum srgbBufferSave = ctx->Color.sRGBEnabled; const GLuint fboSave = ctx->DrawBuffer->Name; const GLuint original_active_unit = ctx->Texture.CurrentUnit; GLenum faceTarget; @@ -2731,6 +2742,15 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + /* We don't want to encode or decode sRGB values; treat them as linear */ + if (ctx->Extensions.EXT_texture_sRGB_decode) { + _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, + GL_SKIP_DECODE_EXT); + } + if (ctx->Extensions.EXT_framebuffer_sRGB) { + _mesa_Disable(GL_FRAMEBUFFER_SRGB_EXT); + } + _mesa_set_enable(ctx, target, GL_TRUE); /* setup texcoords (XXX what about border?) */ @@ -2875,6 +2895,14 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4); } + if (ctx->Extensions.EXT_texture_sRGB_decode) { + _mesa_TexParameteri(target, GL_TEXTURE_SRGB_DECODE_EXT, + srgbDecodeSave); + } + if (ctx->Extensions.EXT_framebuffer_sRGB && srgbBufferSave) { + _mesa_Enable(GL_FRAMEBUFFER_SRGB_EXT); + } + _mesa_lock_texture(ctx, texObj); /* relock */ _mesa_meta_end(ctx); |