i965: pass wanted format to intel_miptree_create_for_dri_image
authorTapani Pälli <tapani.palli@intel.com>
Wed, 4 Oct 2017 13:32:05 +0000 (16:32 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Fri, 6 Oct 2017 05:06:13 +0000 (08:06 +0300)
Change b3a44ae7a4 caused regressions on Android where DRI and renderbuffer
can disagree on the format being used. This patch removes the colorspace
parameter and instead we pass renderbuffer format. For non-winsys images we
still do srgb/linear modification in same manner as change b3a44ae7a4 wanted
but take format from renderbuffer instead of DRI image.

This patch fixes regressions seen with following test sets:

   dEQP-EGL.functional.color_clears*
   dEQP-EGL.functional.render*

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102999
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/intel_fbo.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h
src/mesa/drivers/dri/i965/intel_tex_image.c

index 1fd967e42454cb6771976d5569783a6b2b8d0ae6..751b0264395145c9d43a17b351471f1e89ce9a6d 100644 (file)
@@ -1596,21 +1596,9 @@ intel_update_image_buffer(struct brw_context *intel,
    if (last_mt && last_mt->bo == buffer->bo)
       return;
 
-   enum isl_colorspace colorspace;
-   switch (_mesa_get_format_color_encoding(intel_rb_format(rb))) {
-   case GL_SRGB:
-      colorspace = ISL_COLORSPACE_SRGB;
-      break;
-   case GL_LINEAR:
-      colorspace = ISL_COLORSPACE_LINEAR;
-      break;
-   default:
-      unreachable("Invalid color encoding");
-   }
-
    struct intel_mipmap_tree *mt =
       intel_miptree_create_for_dri_image(intel, buffer, GL_TEXTURE_2D,
-                                         colorspace, true);
+                                         intel_rb_format(rb), true);
    if (!mt)
       return;
 
index 46f140c0280165d5e29474587a501b9273598166..4a592f37ef3f73485515eed526e61755281ae364 100644 (file)
@@ -364,7 +364,7 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
     * content.
     */
    irb->mt = intel_miptree_create_for_dri_image(brw, image, GL_TEXTURE_2D,
-                                                ISL_COLORSPACE_NONE, false);
+                                                image->format, false);
    if (!irb->mt)
       return;
 
index 5b7cde82f65afdbfd7e5bf48f2327dc7a90a1f78..670a92c1168a5affc9e337d1df7c06d53f7366ee 100644 (file)
@@ -959,36 +959,15 @@ create_ccs_buf_for_image(struct brw_context *brw,
 struct intel_mipmap_tree *
 intel_miptree_create_for_dri_image(struct brw_context *brw,
                                    __DRIimage *image, GLenum target,
-                                   enum isl_colorspace colorspace,
+                                   mesa_format format,
                                    bool is_winsys_image)
 {
-   if (image->planar_format && image->planar_format->nplanes > 1) {
-      assert(colorspace == ISL_COLORSPACE_NONE ||
-             colorspace == ISL_COLORSPACE_YUV);
+   if (image->planar_format && image->planar_format->nplanes > 1)
       return miptree_create_for_planar_image(brw, image, target);
-   }
 
    if (image->planar_format)
       assert(image->planar_format->planes[0].dri_format == image->dri_format);
 
-   mesa_format format = image->format;
-   switch (colorspace) {
-   case ISL_COLORSPACE_NONE:
-      /* Keep the image format unmodified */
-      break;
-
-   case ISL_COLORSPACE_LINEAR:
-      format =_mesa_get_srgb_format_linear(format);
-      break;
-
-   case ISL_COLORSPACE_SRGB:
-      format =_mesa_get_linear_format_srgb(format);
-      break;
-
-   default:
-      unreachable("Inalid colorspace for non-planar image");
-   }
-
    if (!brw->ctx.TextureFormatSupported[format]) {
       /* The texture storage paths in core Mesa detect if the driver does not
        * support the user-requested format, and then searches for a
index 2fce28c524b33f67b67e814fc4b2c33beb449076..439b0f66aeb0d29e20a435c6647d4655bd5ee297 100644 (file)
@@ -407,7 +407,7 @@ struct intel_mipmap_tree *
 intel_miptree_create_for_dri_image(struct brw_context *brw,
                                    __DRIimage *image,
                                    GLenum target,
-                                   enum isl_colorspace colorspace,
+                                   mesa_format format,
                                    bool is_winsys_image);
 
 bool
index 7712f7085f468aa7934c0e76e8c83a965c4b6afa..7396597d9f98b46873ac8100a7f6f363788f2998 100644 (file)
@@ -524,8 +524,8 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
       return;
    }
 
-   mt = intel_miptree_create_for_dri_image(brw, image, target,
-                                           ISL_COLORSPACE_NONE, false);
+   mt = intel_miptree_create_for_dri_image(brw, image, target, image->format,
+                                           false);
    if (mt == NULL)
       return;