i965/miptree: Add a helper for getting the aux usage for texturing
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 22 Jun 2017 03:19:32 +0000 (20:19 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sun, 23 Jul 2017 03:59:22 +0000 (20:59 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index b31e6ff7ddc7ca45b75b5bc7ceb82c84abb5897f..ae3a226ba6ab23aa799c196479fc1cf3c64684ea 100644 (file)
@@ -2421,6 +2421,33 @@ can_texture_with_ccs(struct brw_context *brw,
    return true;
 }
 
+enum isl_aux_usage
+intel_miptree_texture_aux_usage(struct brw_context *brw,
+                                struct intel_mipmap_tree *mt,
+                                enum isl_format view_format)
+{
+   switch (mt->aux_usage) {
+   case ISL_AUX_USAGE_HIZ:
+      if (intel_miptree_sample_with_hiz(brw, mt))
+         return ISL_AUX_USAGE_HIZ;
+      break;
+
+   case ISL_AUX_USAGE_MCS:
+      return ISL_AUX_USAGE_MCS;
+
+   case ISL_AUX_USAGE_CCS_D:
+   case ISL_AUX_USAGE_CCS_E:
+      if (mt->mcs_buf && can_texture_with_ccs(brw, mt, view_format))
+         return ISL_AUX_USAGE_CCS_E;
+      break;
+
+   default:
+      break;
+   }
+
+   return ISL_AUX_USAGE_NONE;
+}
+
 static void
 intel_miptree_prepare_texture_slices(struct brw_context *brw,
                                      struct intel_mipmap_tree *mt,
@@ -2429,31 +2456,23 @@ intel_miptree_prepare_texture_slices(struct brw_context *brw,
                                      uint32_t start_layer, uint32_t num_layers,
                                      bool *aux_supported_out)
 {
-   bool aux_supported, clear_supported;
-   if (_mesa_is_format_color_format(mt->format)) {
-      if (mt->surf.samples > 1) {
-         aux_supported = clear_supported = true;
-      } else {
-         aux_supported = can_texture_with_ccs(brw, mt, view_format);
-      }
+   enum isl_aux_usage aux_usage =
+      intel_miptree_texture_aux_usage(brw, mt, view_format);
+   bool clear_supported = aux_usage != ISL_AUX_USAGE_NONE;
 
-      /* Clear color is specified as ints or floats and the conversion is
-       * done by the sampler.  If we have a texture view, we would have to
-       * perform the clear color conversion manually.  Just disable clear
-       * color.
-       */
-      clear_supported = aux_supported && (mt->format == view_format);
-   } else if (mt->format == MESA_FORMAT_S_UINT8) {
-      aux_supported = clear_supported = false;
-   } else {
-      aux_supported = clear_supported = intel_miptree_sample_with_hiz(brw, mt);
-   }
+   /* Clear color is specified as ints or floats and the conversion is done by
+    * the sampler.  If we have a texture view, we would have to perform the
+    * clear color conversion manually.  Just disable clear color.
+    */
+   if (mt->format != view_format)
+      clear_supported = false;
 
    intel_miptree_prepare_access(brw, mt, start_level, num_levels,
                                 start_layer, num_layers,
-                                aux_supported, clear_supported);
+                                aux_usage != ISL_AUX_USAGE_NONE,
+                                clear_supported);
    if (aux_supported_out)
-      *aux_supported_out = aux_supported;
+      *aux_supported_out = aux_usage != ISL_AUX_USAGE_NONE;
 }
 
 void
index 4a5fed2091ee63272b9e42a63e9d6fb49827ec86..fbb6b9cd83fad819cc6f5e2f0ea6a2d3faaef6b5 100644 (file)
@@ -610,6 +610,10 @@ intel_miptree_access_raw(struct brw_context *brw,
       intel_miptree_finish_write(brw, mt, level, layer, 1, false);
 }
 
+enum isl_aux_usage
+intel_miptree_texture_aux_usage(struct brw_context *brw,
+                                struct intel_mipmap_tree *mt,
+                                enum isl_format view_format);
 void
 intel_miptree_prepare_texture(struct brw_context *brw,
                               struct intel_mipmap_tree *mt,