<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 4, 2017 at 6:32 AM, Tapani Pälli <span dir="ltr"><<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Change b3a44ae7a4 caused regressions on Android where DRI and renderbuffer<br>
can disagree on the format being used. This patch removes the colorspace<br>
parameter and instead we pass renderbuffer format. For non-winsys images we<br>
still do srgb/linear modification in same manner as change b3a44ae7a4 wanted<br>
but take format from renderbuffer instead of DRI image.<br>
<br>
This patch fixes regressions seen with following test sets:<br>
<br>
   dEQP-EGL.functional.color_<wbr>clears*<br>
   dEQP-EGL.functional.render*<br>
<br>
Signed-off-by: Tapani Pälli <<a href="mailto:tapani.palli@intel.com">tapani.palli@intel.com</a>><br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=102999" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=102999</a><br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>context.c       | 14 +----------<br>
 src/mesa/drivers/dri/i965/<wbr>intel_fbo.c         |  2 +-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 34 ++++++++++-----------------<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h |  2 +-<br>
 src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c   |  4 ++--<br>
 5 files changed, 18 insertions(+), 38 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_context.c b/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
index 1fd967e424..751b026439 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
@@ -1596,21 +1596,9 @@ intel_update_image_buffer(<wbr>struct brw_context *intel,<br>
    if (last_mt && last_mt->bo == buffer->bo)<br>
       return;<br>
<br>
-   enum isl_colorspace colorspace;<br>
-   switch (_mesa_get_format_color_<wbr>encoding(intel_rb_format(rb))) {<br>
-   case GL_SRGB:<br>
-      colorspace = ISL_COLORSPACE_SRGB;<br>
-      break;<br>
-   case GL_LINEAR:<br>
-      colorspace = ISL_COLORSPACE_LINEAR;<br>
-      break;<br>
-   default:<br>
-      unreachable("Invalid color encoding");<br>
-   }<br>
-<br>
    struct intel_mipmap_tree *mt =<br>
       intel_miptree_create_for_dri_<wbr>image(intel, buffer, GL_TEXTURE_2D,<br>
-                                         colorspace, true);<br>
+                                         intel_rb_format(rb), true);<br>
    if (!mt)<br>
       return;<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
index 46f140c028..4a592f37ef 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_fbo.c<br>
@@ -364,7 +364,7 @@ intel_image_target_<wbr>renderbuffer_storage(struct gl_context *ctx,<br>
     * content.<br>
     */<br>
    irb->mt = intel_miptree_create_for_dri_<wbr>image(brw, image, GL_TEXTURE_2D,<br>
-                                                ISL_COLORSPACE_NONE, false);<br>
+                                                image->format, false);<br>
    if (!irb->mt)<br>
       return;<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
index 5b7cde82f6..9870748711 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
@@ -959,34 +959,26 @@ create_ccs_buf_for_image(<wbr>struct brw_context *brw,<br>
 struct intel_mipmap_tree *<br>
 intel_miptree_create_for_dri_<wbr>image(struct brw_context *brw,<br>
                                    __DRIimage *image, GLenum target,<br>
-                                   enum isl_colorspace colorspace,<br>
+                                   mesa_format format,<br>
                                    bool is_winsys_image)<br>
 {<br>
-   if (image->planar_format && image->planar_format->nplanes > 1) {<br>
-      assert(colorspace == ISL_COLORSPACE_NONE ||<br>
-             colorspace == ISL_COLORSPACE_YUV);<br>
+   if (image->planar_format && image->planar_format->nplanes > 1)<br>
       return miptree_create_for_planar_<wbr>image(brw, image, target);<br>
-   }<br>
<br>
    if (image->planar_format)<br>
       assert(image->planar_format-><wbr>planes[0].dri_format == image->dri_format);<br>
<br>
-   mesa_format format = image->format;<br>
-   switch (colorspace) {<br>
-   case ISL_COLORSPACE_NONE:<br>
-      /* Keep the image format unmodified */<br>
-      break;<br>
-<br>
-   case ISL_COLORSPACE_LINEAR:<br>
-      format =_mesa_get_srgb_format_linear(<wbr>format);<br>
-      break;<br>
-<br>
-   case ISL_COLORSPACE_SRGB:<br>
-      format =_mesa_get_linear_format_srgb(<wbr>format);<br>
-      break;<br>
-<br>
-   default:<br>
-      unreachable("Inalid colorspace for non-planar image");<br>
+   if (!is_winsys_image) {<br>
+      switch(_mesa_get_format_color_<wbr>encoding(format)) {<br>
+      case GL_SRGB:<br>
+         format =_mesa_get_linear_format_srgb(<wbr>format);<br>
+         break;<br>
+      case GL_LINEAR:<br>
+         format =_mesa_get_srgb_format_linear(<wbr>format);<br>
+         break;<br>
+      default:<br>
+         unreachable("Invalid color encoding");<br>
+      }<br></blockquote><div><br></div><div>This switch statement does nothing since it's switching on the current format's encoding.  Let's just drop it.  With that,</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></div><div><br></div><div>We should still figure out why Android is giving us the wrong image format but let's focus on getting the bug fixed first.  This shouldn't be any more wrong than we were before I did all the colorspace stuff.<br></div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    }<br>
<br>
    if (!brw->ctx.<wbr>TextureFormatSupported[format]<wbr>) {<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
index 2fce28c524..439b0f66ae 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h<br>
@@ -407,7 +407,7 @@ struct intel_mipmap_tree *<br>
 intel_miptree_create_for_dri_<wbr>image(struct brw_context *brw,<br>
                                    __DRIimage *image,<br>
                                    GLenum target,<br>
-                                   enum isl_colorspace colorspace,<br>
+                                   mesa_format format,<br>
                                    bool is_winsys_image);<br>
<br>
 bool<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c b/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
index 7712f7085f..7396597d9f 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_tex_image.c<br>
@@ -524,8 +524,8 @@ intel_image_target_texture_2d(<wbr>struct gl_context *ctx, GLenum target,<br>
       return;<br>
    }<br>
<br>
-   mt = intel_miptree_create_for_dri_<wbr>image(brw, image, target,<br>
-                                           ISL_COLORSPACE_NONE, false);<br>
+   mt = intel_miptree_create_for_dri_<wbr>image(brw, image, target, image->format,<br>
+                                           false);<br>
    if (mt == NULL)<br>
       return;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.13.5<br>
<br>
</font></span></blockquote></div><br></div></div>