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

Ben Widawsky benjamin.widawsky at intel.com
Thu Dec 1 22:10:00 UTC 2016


From: Ben Widawsky <ben at bwidawsk.net>

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>
---
 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 593fa67..00d48c7 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1645,10 +1645,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 ||
@@ -1704,10 +1718,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 74db507..cfecfd1 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -911,11 +911,10 @@ intel_miptree_create_for_image(struct brw_context *intel,
 int
 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;
@@ -926,18 +925,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.
@@ -977,7 +965,6 @@ intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
    return 0;
 
 fail:
-   intel_miptree_release(&irb->singlesample_mt);
    intel_miptree_release(&irb->mt);
    return -1;
 }
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 85fe118..19c8bec 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -729,7 +729,7 @@ intel_miptree_create_for_image(struct brw_context *intel,
 int
 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.10.2



More information about the mesa-dev mailing list