[Mesa-dev] [PATCH 15/27] i965/miptree: Add a helper functions for image creation

Ben Widawsky benjamin.widawsky at intel.com
Thu Dec 1 22:09:56 UTC 2016


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.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 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 de0cd6a..f6e1759 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 a9b350e..cfa2dc0 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"
@@ -810,6 +810,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)
+{
+   layout_flags = (layout_flags & MIPTREE_LAYOUT_FOR_SCANOUT) ?
+      MIPTREE_LAYOUT_FOR_SCANOUT : 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 c67b4de..7b9a7be 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -716,6 +716,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 141996f..2d79183 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.10.2



More information about the mesa-dev mailing list