i965/miptree: Add support for window system images to create_for_dri_image
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 16 Jun 2017 16:57:12 +0000 (09:57 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 13 Jul 2017 04:15:46 +0000 (21:15 -0700)
We want to start using create_for_dri_image for all miptrees created
from __DRIimage, including those which come from a window system.  In
order to allow for fast clears to still work on window system buffers,
we need to allow for creating aux surfaces.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
src/mesa/drivers/dri/i965/intel_fbo.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h
src/mesa/drivers/dri/i965/intel_tex_image.c

index 3670c2a0b7f275b705d1a13e1eb2a8978de91345..03427e8c8fed674b42e1f55228d8e5db6812540c 100644 (file)
@@ -363,7 +363,7 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx,
     * content.
     */
    irb->mt = intel_miptree_create_for_dri_image(brw, image, GL_TEXTURE_2D,
-                                                ISL_COLORSPACE_NONE);
+                                                ISL_COLORSPACE_NONE, false);
    if (!irb->mt)
       return;
 
index 6159fb31a25c1e978cec0b1f94178d079da1bb51..3c37fe3bf09242d054c3844aa37bf4ffb4ceeed9 100644 (file)
@@ -1041,7 +1041,8 @@ miptree_create_for_planar_image(struct brw_context *brw,
 struct intel_mipmap_tree *
 intel_miptree_create_for_dri_image(struct brw_context *brw,
                                    __DRIimage *image, GLenum target,
-                                   enum isl_colorspace colorspace)
+                                   enum isl_colorspace colorspace,
+                                   bool is_winsys_image)
 {
    if (image->planar_format && image->planar_format->nplanes > 0) {
       assert(colorspace == ISL_COLORSPACE_NONE ||
@@ -1083,6 +1084,16 @@ intel_miptree_create_for_dri_image(struct brw_context *brw,
    if (!brw->ctx.TextureFormatSupported[format])
       return NULL;
 
+   /* If this image comes in from a window system, we have different
+    * requirements than if it comes in via an EGL import operation.  Window
+    * system images can use any form of auxiliary compression we wish because
+    * they get "flushed" before being handed off to the window system and we
+    * have the opportunity to do resolves.  Window system buffers also may be
+    * used for scanout so we need to flag that appropriately.
+    */
+   const uint32_t mt_layout_flags =
+      is_winsys_image ? MIPTREE_LAYOUT_FOR_SCANOUT : MIPTREE_LAYOUT_DISABLE_AUX;
+
    /* Disable creation of the texture's aux buffers because the driver exposes
     * no EGL API to manage them. That is, there is no API for resolving the aux
     * buffer's content to the main buffer nor for invalidating the aux buffer's
@@ -1091,8 +1102,7 @@ intel_miptree_create_for_dri_image(struct brw_context *brw,
    struct intel_mipmap_tree *mt =
       intel_miptree_create_for_bo(brw, image->bo, format,
                                   image->offset, image->width, image->height, 1,
-                                  image->pitch,
-                                  MIPTREE_LAYOUT_DISABLE_AUX);
+                                  image->pitch, mt_layout_flags);
    if (mt == NULL)
       return NULL;
 
index 6668d317a26ad02d64366fc18cf8d2d89cb5f52a..c4ed525934f00041a599bd8b4bd56d282699fb8a 100644 (file)
@@ -690,7 +690,8 @@ struct intel_mipmap_tree *
 intel_miptree_create_for_dri_image(struct brw_context *brw,
                                    __DRIimage *image,
                                    GLenum target,
-                                   enum isl_colorspace colorspace);
+                                   enum isl_colorspace colorspace,
+                                   bool is_winsys_image);
 
 bool
 intel_update_winsys_renderbuffer_miptree(struct brw_context *intel,
index 7765d1bddf84abd6f8da6a661426dfa4cac7ff51..68d0a5766709134838fdfa48fb671a65440a7dcd 100644 (file)
@@ -357,7 +357,7 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
    }
 
    mt = intel_miptree_create_for_dri_image(brw, image, target,
-                                           ISL_COLORSPACE_NONE);
+                                           ISL_COLORSPACE_NONE, false);
    if (mt == NULL)
       return;