From 1775b0238df4bc07c87262251397930a11605f12 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 20 Sep 2017 10:22:21 -0700 Subject: [PATCH] i965: Restore format whacking in SetTexBuffer2 gnome-terminal-fedora (with transparency) in gnome-shell started rendering way too dark after commit d80cbbeaff9329fdc78ae3d97097c. We believe the darkness is caused by botching sRGB - SetTexBuffer2 used to whack the formats to non-sRGB explicitly, and now it doesn't. The commit message said that the miptree format shouldn't matter. But intel_set_texture_image_mt actually sets the format in the gl_texture_image as well, and that does matter. v2 (Jason Ekstrand): - Set the gl_texture_object format instead of whacking the format in the intel_mipmap_tree. Fixes: d80cbbeaff9329fdc78ae3d97097c1e65dfcdd61 (i965/tex_image: Reference the renderbuffer miptree in setTexBuffer2) --- src/mesa/drivers/dri/i965/intel_tex_image.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c index 7712f70..a257ca9 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_image.c +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c @@ -374,6 +374,7 @@ static void intel_set_texture_image_mt(struct brw_context *brw, struct gl_texture_image *image, GLenum internal_format, + mesa_format format, struct intel_mipmap_tree *mt) { @@ -384,7 +385,7 @@ intel_set_texture_image_mt(struct brw_context *brw, _mesa_init_teximage_fields(&brw->ctx, image, mt->surf.logical_level0_px.width, mt->surf.logical_level0_px.height, 1, - 0, internal_format, mt->format); + 0, internal_format, format); brw->ctx.Driver.FreeTextureImageBuffer(&brw->ctx, image); @@ -410,6 +411,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, struct intel_renderbuffer *rb; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + mesa_format texFormat = MESA_FORMAT_NONE; GLenum internal_format = 0; texObj = _mesa_get_current_tex_object(ctx, target); @@ -429,20 +431,25 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, return; if (rb->mt->cpp == 4) { - if (texture_format == __DRI_TEXTURE_FORMAT_RGB) + if (texture_format == __DRI_TEXTURE_FORMAT_RGB) { internal_format = GL_RGB; - else + texFormat = MESA_FORMAT_B8G8R8X8_UNORM; + } else { internal_format = GL_RGBA; + texFormat = MESA_FORMAT_B8G8R8A8_UNORM; + } } else if (rb->mt->cpp == 2) { /* This is 565 */ internal_format = GL_RGB; + texFormat = MESA_FORMAT_B5G6R5_UNORM; } intel_miptree_prepare_external(brw, rb->mt); _mesa_lock_texture(&brw->ctx, texObj); texImage = _mesa_get_tex_image(ctx, texObj, target, 0); - intel_set_texture_image_mt(brw, texImage, internal_format, rb->mt); + intel_set_texture_image_mt(brw, texImage, internal_format, + texFormat, rb->mt); _mesa_unlock_texture(&brw->ctx, texObj); } @@ -535,7 +542,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target, const GLenum internal_format = image->internal_format != 0 ? image->internal_format : _mesa_get_format_base_format(mt->format); - intel_set_texture_image_mt(brw, texImage, internal_format, mt); + intel_set_texture_image_mt(brw, texImage, internal_format, mt->format, mt); intel_miptree_release(&mt); } -- 2.5.0.400.gff86faf