<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 23, 2017 at 10:21 PM, Ben Widawsky <span dir="ltr"><<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Allows us to continue utilizing common miptree creation using __DRIimage<br>
without creating a new DRIimage (for the intel_process_dri2_buffer()<br>
case).<br>
<br>
This is a bit ugly, but I think it's the best one can do.<br>
<br>
Signed-off-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
Acked-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>context.c       | 31 +++++++++++++++++++++++----<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 17 ++-------------<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.h |  2 +-<br>
 3 files changed, 30 insertions(+), 20 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 d2b3140ea1..ca879004c9 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_context.c<br>
@@ -1646,10 +1646,24 @@ intel_process_dri2_buffer(<wbr>struct brw_context *brw,<br>
       return;<br>
    }<br>
<br>
-   if (!intel_update_winsys_<wbr>renderbuffer_miptree(brw, rb, bo,<br>
+   struct intel_mipmap_tree *mt = intel_miptree_create_for_bo(<wbr>brw,<br>
+                                                              bo,<br>
+                                                              intel_rb_format(rb),<br>
+                                                              0,<br>
+                                                              drawable->w,<br>
+                                                              drawable->h,<br>
+                                                              1,<br>
+                                                              buffer->pitch,<br>
+                                                              MIPTREE_LAYOUT_FOR_SCANOUT);<br>
+   if (!mt)<br></blockquote><div><br></div><div>Unref the BO here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      return;<br>
+<br>
+   if (!intel_update_winsys_<wbr>renderbuffer_miptree(brw, rb, mt,<br>
                                                  drawable->w, drawable->h,<br>
-                                                 buffer->pitch))<br>
+                                                 buffer->pitch)) {<br>
+      intel_miptree_release(&mt);<br>
       return;<br>
+   }<br>
<br>
    if (_mesa_is_front_buffer_<wbr>drawing(fb) &&<br>
        (buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||<br>
@@ -1705,10 +1719,19 @@ intel_update_image_buffer(<wbr>struct brw_context *intel,<br>
    if (last_mt && last_mt->bo == buffer->bo)<br>
       return;<br>
<br>
-   if (!intel_update_winsys_<wbr>renderbuffer_miptree(intel, rb, buffer->bo,<br>
+   struct intel_mipmap_tree *mt = intel_miptree_create_for_<wbr>image(intel,<br>
+                                                                 buffer, intel_rb_format(rb), 0,<br>
+                                                                 buffer->width, buffer->height,<br>
+                                                                 buffer->pitch, MIPTREE_LAYOUT_FOR_SCANOUT);<br>
+   if (!mt)<br>
+      return;<br>
+<br>
+   if (!intel_update_winsys_<wbr>renderbuffer_miptree(intel, rb, mt,<br>
                                                  buffer->width, buffer->height,<br>
-                                                 buffer->pitch))<br>
+                                                 buffer->pitch)) {<br>
+      intel_miptree_release(&mt);<br>
       return;<br>
+   }<br>
<br>
    if (_mesa_is_front_buffer_<wbr>drawing(fb) &&<br>
        buffer_type == __DRI_IMAGE_BUFFER_FRONT &&<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 7d08bb6920..095d001eae 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>
@@ -918,11 +918,10 @@ intel_miptree_create_for_<wbr>image(struct brw_context *intel,<br>
 bool<br>
 intel_update_winsys_<wbr>renderbuffer_miptree(struct brw_context *intel,<br>
                                          struct intel_renderbuffer *irb,<br>
-                                         drm_intel_bo *bo,<br>
+                                         struct intel_mipmap_tree *singlesample_mt,<br>
                                          uint32_t width, uint32_t height,<br>
                                          uint32_t pitch)<br>
 {<br>
-   struct intel_mipmap_tree *singlesample_mt = NULL;<br>
    struct intel_mipmap_tree *multisample_mt = NULL;<br>
    struct gl_renderbuffer *rb = &irb->Base.Base;<br>
    mesa_format format = rb->Format;<br>
@@ -933,18 +932,7 @@ intel_update_winsys_<wbr>renderbuffer_miptree(struct brw_context *intel,<br>
     */<br>
    assert(_mesa_get_format_base_<wbr>format(format) == GL_RGB ||<br>
           _mesa_get_format_base_format(<wbr>format) == GL_RGBA);<br>
-<br>
-   singlesample_mt = intel_miptree_create_for_bo(<wbr>intel,<br>
-                                                 bo,<br>
-                                                 format,<br>
-                                                 0,<br>
-                                                 width,<br>
-                                                 height,<br>
-                                                 1,<br>
-                                                 pitch,<br>
-                                                 MIPTREE_LAYOUT_FOR_SCANOUT);<br>
-   if (!singlesample_mt)<br>
-      goto fail;<br>
+   assert(singlesample_mt);<br>
<br>
    /* If this miptree is capable of supporting fast color clears, set<br>
     * mcs_state appropriately to ensure that fast clears will occur.<br>
@@ -984,7 +972,6 @@ intel_update_winsys_<wbr>renderbuffer_miptree(struct brw_context *intel,<br>
    return true;<br>
<br>
 fail:<br>
-   intel_miptree_release(&irb-><wbr>singlesample_mt);<br>
    intel_miptree_release(&irb-><wbr>mt);<br>
    return false;<br>
 }<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 9b4c85e509..1f1166a12b 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>
@@ -733,7 +733,7 @@ intel_miptree_create_for_<wbr>image(struct brw_context *intel,<br>
 bool<br>
 intel_update_winsys_<wbr>renderbuffer_miptree(struct brw_context *intel,<br>
                                          struct intel_renderbuffer *irb,<br>
-                                         drm_intel_bo *bo,<br>
+                                         struct intel_mipmap_tree *singlesample_mt,<br>
                                          uint32_t width, uint32_t height,<br>
                                          uint32_t pitch);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>