[Mesa-dev] [PATCH 24/32] i965/miptree: Allocate mt earlier in update winsys

Ben Widawsky ben at bwidawsk.net
Tue Jan 3 02:37:15 UTC 2017


Allows us to continue utilizing common miptree creation using __DRIimage
without creating a new DRIimage (for the intel_process_dri2_buffer()
case).

This is a bit ugly, but I think it's the best one can do.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
Acked-by: Daniel Stone <daniels at collabora.com>
---
 src/mesa/drivers/dri/i965/brw_context.c       | 31 +++++++++++++++++++++++----
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 17 ++-------------
 src/mesa/drivers/dri/i965/intel_mipmap_tree.h |  2 +-
 3 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 7e350c4e47..ce01605826 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1652,10 +1652,24 @@ intel_process_dri2_buffer(struct brw_context *brw,
       return;
    }
 
-   if (!intel_update_winsys_renderbuffer_miptree(brw, rb, bo,
+   struct intel_mipmap_tree *mt = intel_miptree_create_for_bo(brw,
+                                                              bo,
+                                                              intel_rb_format(rb),
+                                                              0,
+                                                              drawable->w,
+                                                              drawable->h,
+                                                              1,
+                                                              buffer->pitch,
+                                                              MIPTREE_LAYOUT_FOR_SCANOUT);
+   if (!mt)
+      return;
+
+   if (!intel_update_winsys_renderbuffer_miptree(brw, rb, mt,
                                                  drawable->w, drawable->h,
-                                                 buffer->pitch))
+                                                 buffer->pitch)) {
+      intel_miptree_release(&mt);
       return;
+   }
 
    if (_mesa_is_front_buffer_drawing(fb) &&
        (buffer->attachment == __DRI_BUFFER_FRONT_LEFT ||
@@ -1711,10 +1725,19 @@ intel_update_image_buffer(struct brw_context *intel,
    if (last_mt && last_mt->bo == buffer->bo)
       return;
 
-   if (!intel_update_winsys_renderbuffer_miptree(intel, rb, buffer->bo,
+   struct intel_mipmap_tree *mt = intel_miptree_create_for_image(intel,
+                                                                 buffer, intel_rb_format(rb), 0,
+                                                                 buffer->width, buffer->height,
+                                                                 buffer->pitch, MIPTREE_LAYOUT_FOR_SCANOUT);
+   if (!mt)
+      return;
+
+   if (!intel_update_winsys_renderbuffer_miptree(intel, rb, mt,
                                                  buffer->width, buffer->height,
-                                                 buffer->pitch))
+                                                 buffer->pitch)) {
+      intel_miptree_release(&mt);
       return;
+   }
 
    if (_mesa_is_front_buffer_drawing(fb) &&
        buffer_type == __DRI_IMAGE_BUFFER_FRONT &&
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index a6cc64365d..5057d517a6 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -919,11 +919,10 @@ intel_miptree_create_for_image(struct brw_context *intel,
 bool
 intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
                                          struct intel_renderbuffer *irb,
-                                         drm_intel_bo *bo,
+                                         struct intel_mipmap_tree *singlesample_mt,
                                          uint32_t width, uint32_t height,
                                          uint32_t pitch)
 {
-   struct intel_mipmap_tree *singlesample_mt = NULL;
    struct intel_mipmap_tree *multisample_mt = NULL;
    struct gl_renderbuffer *rb = &irb->Base.Base;
    mesa_format format = rb->Format;
@@ -934,18 +933,7 @@ intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
     */
    assert(_mesa_get_format_base_format(format) == GL_RGB ||
           _mesa_get_format_base_format(format) == GL_RGBA);
-
-   singlesample_mt = intel_miptree_create_for_bo(intel,
-                                                 bo,
-                                                 format,
-                                                 0,
-                                                 width,
-                                                 height,
-                                                 1,
-                                                 pitch,
-                                                 MIPTREE_LAYOUT_FOR_SCANOUT);
-   if (!singlesample_mt)
-      goto fail;
+   assert(singlesample_mt);
 
    /* If this miptree is capable of supporting fast color clears, set
     * mcs_state appropriately to ensure that fast clears will occur.
@@ -985,7 +973,6 @@ intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
    return true;
 
 fail:
-   intel_miptree_release(&irb->singlesample_mt);
    intel_miptree_release(&irb->mt);
    return false;
 }
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 9b4c85e509..1f1166a12b 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -733,7 +733,7 @@ intel_miptree_create_for_image(struct brw_context *intel,
 bool
 intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
                                          struct intel_renderbuffer *irb,
-                                         drm_intel_bo *bo,
+                                         struct intel_mipmap_tree *singlesample_mt,
                                          uint32_t width, uint32_t height,
                                          uint32_t pitch);
 
-- 
2.11.0



More information about the mesa-dev mailing list