i965: Reset miptree aux state on update_image_buffer
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 12 Sep 2017 22:24:40 +0000 (15:24 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 18 Sep 2017 19:16:50 +0000 (12:16 -0700)
When we get a miptree in through glxBindImageEXT, we don't know the
current aux state so we have to assume the worst-case.  If the image
gets recreated, everything is fine because miptreecreate_for_dri_image
sets it to the default.  However, if our miptree is recycled, then we
may have stale aux_usage and we need to reset to the default otherwise
our aux_state tracking will get messed up.

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

index ee1badd94b3832d79d471f07598111d71449fd5b..9cb16f3fb1641373117aac5657b9c7f6bdb4414e 100644 (file)
@@ -1592,8 +1592,10 @@ intel_update_image_buffer(struct brw_context *intel,
    else
       last_mt = rb->singlesample_mt;
 
-   if (last_mt && last_mt->bo == buffer->bo)
+   if (last_mt && last_mt->bo == buffer->bo) {
+      intel_miptree_finish_external(intel, last_mt);
       return;
+   }
 
    enum isl_colorspace colorspace;
    switch (_mesa_get_format_color_encoding(intel_rb_format(rb))) {
index 5b7cde82f65afdbfd7e5bf48f2327dc7a90a1f78..5740f031c49885aff2e030cbf17efb457c57fcae 100644 (file)
@@ -2820,6 +2820,25 @@ intel_miptree_prepare_external(struct brw_context *brw,
                                 aux_usage, supports_fast_clear);
 }
 
+void
+intel_miptree_finish_external(struct brw_context *brw,
+                              struct intel_mipmap_tree *mt)
+{
+   if (!mt->mcs_buf)
+      return;
+
+   /* We just got this image in from the window system via glxBindTexImageEXT
+    * or similar and have no idea what the actual aux state is other than that
+    * we aren't in AUX_INVALID.  Reset the aux state to the default for the
+    * image's modifier.
+    */
+   enum isl_aux_state default_aux_state =
+      isl_drm_modifier_get_default_aux_state(mt->drm_modifier);
+   assert(mt->last_level == mt->first_level);
+   intel_miptree_set_aux_state(brw, mt, 0, 0, INTEL_REMAINING_LAYERS,
+                               default_aux_state);
+}
+
 /**
  * Make it possible to share the BO backing the given miptree with another
  * process or another miptree.
index 2fce28c524b33f67b67e814fc4b2c33beb449076..08aa9a7b3b2e165537609d805b213b13ac8e65fe 100644 (file)
@@ -674,6 +674,9 @@ intel_miptree_finish_depth(struct brw_context *brw,
 void
 intel_miptree_prepare_external(struct brw_context *brw,
                                struct intel_mipmap_tree *mt);
+void
+intel_miptree_finish_external(struct brw_context *brw,
+                              struct intel_mipmap_tree *mt);
 
 void
 intel_miptree_make_shareable(struct brw_context *brw,