[Mesa-dev] [PATCH v13 19/36] i965/miptree: Add a helper function for image creation

Daniel Stone daniels at collabora.com
Fri May 19 09:38:02 UTC 2017


From: Ben Widawsky <ben at bwidawsk.net>

This provides a common function or creating miptrees when there is an
existing DRIimage to use. That provides an easy way to add CCS
allocation.

v2: Make the new function assume there are always no layout flags. This
will be adjusted later.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
Acked-by: Daniel Stone <daniels at collabora.com>
Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 src/mesa/drivers/dri/i965/intel_fbo.c         | 17 ++++++++---------
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 25 ++++++++++++++++++++++++-
 src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 10 ++++++++++
 src/mesa/drivers/dri/i965/intel_tex_image.c   | 17 ++++++++---------
 4 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c
index 21e8e86d2c..b321ddf0ea 100644
--- a/src/mesa/drivers/dri/i965/intel_fbo.c
+++ b/src/mesa/drivers/dri/i965/intel_fbo.c
@@ -362,15 +362,14 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
     * buffer's content to the main buffer nor for invalidating the aux buffer's
     * content.
     */
-   irb->mt = intel_miptree_create_for_bo(brw,
-                                         image->bo,
-                                         image->format,
-                                         image->offset,
-                                         image->width,
-                                         image->height,
-                                         1,
-                                         image->pitch,
-                                         MIPTREE_LAYOUT_DISABLE_AUX);
+   irb->mt = intel_miptree_create_for_image(brw,
+                                            image,
+                                            image->format,
+                                            image->offset,
+                                            image->width,
+                                            image->height,
+                                            image->pitch,
+                                            0);
    if (!irb->mt)
       return;
 
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index db0a397527..7744206bae 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -24,7 +24,6 @@
  */
 
 #include <GL/gl.h>
-#include <GL/internal/dri_interface.h>
 
 #include "intel_batchbuffer.h"
 #include "intel_mipmap_tree.h"
@@ -32,6 +31,7 @@
 #include "intel_tex.h"
 #include "intel_blit.h"
 #include "intel_fbo.h"
+#include "intel_image.h"
 
 #include "brw_blorp.h"
 #include "brw_context.h"
@@ -765,6 +765,29 @@ intel_miptree_create_for_bo(struct brw_context *brw,
    return mt;
 }
 
+struct intel_mipmap_tree *
+intel_miptree_create_for_image(struct brw_context *intel,
+                               __DRIimage *image,
+                               mesa_format format,
+                               uint32_t offset,
+                               uint32_t width,
+                               uint32_t height,
+                               uint32_t pitch,
+                               uint32_t layout_flags)
+{
+   assert(layout_flags == 0);
+   layout_flags = MIPTREE_LAYOUT_DISABLE_AUX;
+   return intel_miptree_create_for_bo(intel,
+                                      image->bo,
+                                      format,
+                                      offset,
+                                      width,
+                                      height,
+                                      1,
+                                      pitch,
+                                      layout_flags);
+}
+
 /**
  * For a singlesample renderbuffer, this simply wraps the given BO with a
  * miptree.
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 7aabac006f..8ec1278d0b 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -707,6 +707,16 @@ intel_miptree_create_for_bo(struct brw_context *brw,
                             int pitch,
                             uint32_t layout_flags);
 
+struct intel_mipmap_tree *
+intel_miptree_create_for_image(struct brw_context *intel,
+                               __DRIimage *image,
+                               mesa_format format,
+                               uint32_t offset,
+                               uint32_t width,
+                               uint32_t height,
+                               uint32_t pitch,
+                               uint32_t layout_flags);
+
 void
 intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
                                          struct intel_renderbuffer *irb,
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 7208d8eb4a..0906caa490 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -221,11 +221,11 @@ create_mt_for_planar_dri_image(struct brw_context *brw,
        * invalidating the aux buffer's content.
        */
       struct intel_mipmap_tree *mt =
-         intel_miptree_create_for_bo(brw, image->bo, format,
-                                     image->offsets[index],
-                                     width, height, 1,
-                                     image->strides[index],
-                                     MIPTREE_LAYOUT_DISABLE_AUX);
+         intel_miptree_create_for_image(brw, image, format,
+                                        image->offsets[index],
+                                        width, height,
+                                        image->strides[index],
+                                        0);
       if (mt == NULL)
          return NULL;
 
@@ -259,10 +259,9 @@ create_mt_for_dri_image(struct brw_context *brw,
     * buffer's content to the main buffer nor for invalidating the aux buffer's
     * content.
     */
-   mt = intel_miptree_create_for_bo(brw, image->bo, image->format,
-                                    0, image->width, image->height, 1,
-                                    image->pitch,
-                                    MIPTREE_LAYOUT_DISABLE_AUX);
+   mt = intel_miptree_create_for_image(brw, image, image->format,
+                                       0, image->width, image->height,
+                                       image->pitch, 0);
    if (mt == NULL)
       return NULL;
 
-- 
2.13.0



More information about the mesa-dev mailing list