i965: Add helper for detecting lossless compression
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Thu, 11 Feb 2016 08:42:13 +0000 (10:42 +0200)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Tue, 16 Feb 2016 06:52:23 +0000 (08:52 +0200)
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Ben Widawsky <benjamin.widawsky@intel.com>
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index 1f4c59b6cc3773a3273c383394a5d372be562c78..f926265316b78f591c2ed36480a9c5193b50962d 100644 (file)
@@ -266,6 +266,32 @@ intel_miptree_supports_non_msrt_fast_clear(struct brw_context *brw,
       return true;
 }
 
+/* On Gen9 support for color buffer compression was extended to single
+ * sampled surfaces. This is a helper considering both auxiliary buffer
+ * type and number of samples telling if the given miptree represents
+ * the new single sampled case - also called lossless compression.
+ */
+bool
+intel_miptree_is_lossless_compressed(const struct brw_context *brw,
+                                     const struct intel_mipmap_tree *mt)
+{
+   /* Only available from Gen9 onwards. */
+   if (brw->gen < 9)
+      return false;
+
+   /* Compression always requires auxiliary buffer. */
+   if (!mt->mcs_mt)
+      return false;
+
+   /* Single sample compression is represented re-using msaa compression
+    * layout type: "Compressed Multisampled Surfaces".
+    */
+   if (mt->msaa_layout != INTEL_MSAA_LAYOUT_CMS)
+      return false;
+
+   /* And finally distinguish between msaa and single sample case. */
+   return mt->num_samples <= 1;
+}
 
 /**
  * Determine depth format corresponding to a depth+stencil format,
index 08cb1b8fb39b2a90eb5c7c4668fa73e64cb20eea..155e507d583323f1c1632404cbff484aa89c8739 100644 (file)
@@ -666,6 +666,10 @@ void
 intel_get_non_msrt_mcs_alignment(struct intel_mipmap_tree *mt,
                                  unsigned *width_px, unsigned *height);
 
+bool
+intel_miptree_is_lossless_compressed(const struct brw_context *brw,
+                                     const struct intel_mipmap_tree *mt);
+
 bool
 intel_miptree_alloc_non_msrt_mcs(struct brw_context *brw,
                                  struct intel_mipmap_tree *mt);