Revert "i965/tex_image: Reference the renderbuffer miptree in setTexBuffer2"
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 16 Oct 2017 22:30:47 +0000 (15:30 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 16 Oct 2017 23:02:53 +0000 (16:02 -0700)
This reverts commit d80cbbeaff9329fdc78ae3d97097c1e65dfcdd61.

It turns out that formats do matter - the framebuffer's miptree has an
sRGB format, and the one we created did not.  This broke rendering when
using KWin compositing, GNOME Terminal Fedora (with a transparent
background), and Qt menu rendering in general, to name a few.

It's been a month and this hasn't been fixed, and I'm sick of reverting
this patch or applying NAK'd hacks and restarting various programs at
random times every day, multiple times a day, to keep my desktop
environment functional.

The only benefit of this patch was to prepare the way for modifiers,
which AFAIK aren't finished yet anyway, so there's really no downside
to reverting it.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102924

src/mesa/drivers/dri/i965/intel_tex_image.c

index 5396e0a43bcee489b87f537dce6ef71d31b6e1f5..37c8e24f0327f79be8ddbc31648e44d989b3b1d2 100644 (file)
@@ -441,6 +441,8 @@ 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;
+   struct intel_mipmap_tree *mt;
    GLenum internal_format = 0;
 
    texObj = _mesa_get_current_tex_object(ctx, target);
@@ -460,20 +462,33 @@ 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);
+   intel_miptree_make_shareable(brw, rb->mt);
+   mt = intel_miptree_create_for_bo(brw, rb->mt->bo, texFormat, 0,
+                                    rb->Base.Base.Width,
+                                    rb->Base.Base.Height,
+                                    1, rb->mt->surf.row_pitch,
+                                    MIPTREE_CREATE_DEFAULT);
+   if (mt == NULL)
+       return;
+   mt->target = target;
 
    _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, mt);
+   intel_miptree_release(&mt);
    _mesa_unlock_texture(&brw->ctx, texObj);
 }