Mesa (staging/22.1): isl: add new helper for format component compatibility

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 12 17:20:16 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: 56b7c79ccff6cf9c3889e5e6fbdbe4f63c799db6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=56b7c79ccff6cf9c3889e5e6fbdbe4f63c799db6

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Fri Jul  1 10:43:21 2022 +0300

isl: add new helper for format component compatibility

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Cc: mesa-stable
Reviewed-by: Nanley Chery <nanley.g.chery at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17329>
(cherry picked from commit ab4beaf3fb015fce743acac9efb933c110881bf5)

---

 .pick_status.json          |  2 +-
 src/intel/isl/isl.h        |  3 +++
 src/intel/isl/isl_format.c | 29 ++++++++++++++++++++++-------
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 3d4896ac9c9..0ea4044bfb7 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -409,7 +409,7 @@
         "description": "isl: add new helper for format component compatibility",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index c2db422fc8e..da44e01d49a 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1863,6 +1863,9 @@ bool isl_formats_are_ccs_e_compatible(const struct intel_device_info *devinfo,
 uint8_t isl_format_get_aux_map_encoding(enum isl_format format);
 uint8_t isl_get_render_compression_format(enum isl_format format);
 
+bool isl_formats_have_same_bits_per_channel(enum isl_format format1,
+                                            enum isl_format format2);
+
 bool isl_format_has_unorm_channel(enum isl_format fmt) ATTRIBUTE_CONST;
 bool isl_format_has_snorm_channel(enum isl_format fmt) ATTRIBUTE_CONST;
 bool isl_format_has_ufloat_channel(enum isl_format fmt) ATTRIBUTE_CONST;
diff --git a/src/intel/isl/isl_format.c b/src/intel/isl/isl_format.c
index 334246f6dbf..e0c539bf935 100644
--- a/src/intel/isl/isl_format.c
+++ b/src/intel/isl/isl_format.c
@@ -934,6 +934,27 @@ isl_format_supports_multisampling(const struct intel_device_info *devinfo,
    }
 }
 
+/**
+ * Returns true if the two formats are component size compatible meaning that
+ * each component from one format has the same number of bits as the other
+ * format.
+ *
+ * This is useful to check whether an image used with 2 different formats can
+ * be fast cleared with a non 0 clear color.
+ */
+bool
+isl_formats_have_same_bits_per_channel(enum isl_format format1,
+                                       enum isl_format format2)
+{
+   const struct isl_format_layout *fmtl1 = isl_format_get_layout(format1);
+   const struct isl_format_layout *fmtl2 = isl_format_get_layout(format2);
+
+   return fmtl1->channels.r.bits == fmtl2->channels.r.bits &&
+          fmtl1->channels.g.bits == fmtl2->channels.g.bits &&
+          fmtl1->channels.b.bits == fmtl2->channels.b.bits &&
+          fmtl1->channels.a.bits == fmtl2->channels.a.bits;
+}
+
 /**
  * Returns true if the two formats are "CCS_E compatible" meaning that you can
  * render in one format with CCS_E enabled and then texture using the other
@@ -962,16 +983,10 @@ isl_formats_are_ccs_e_compatible(const struct intel_device_info *devinfo,
    if (format2 == ISL_FORMAT_A8_UNORM)
       format2 = ISL_FORMAT_R8_UNORM;
 
-   const struct isl_format_layout *fmtl1 = isl_format_get_layout(format1);
-   const struct isl_format_layout *fmtl2 = isl_format_get_layout(format2);
-
    /* The compression used by CCS is not dependent on the actual data encoding
     * of the format but only depends on the bit-layout of the channels.
     */
-   return fmtl1->channels.r.bits == fmtl2->channels.r.bits &&
-          fmtl1->channels.g.bits == fmtl2->channels.g.bits &&
-          fmtl1->channels.b.bits == fmtl2->channels.b.bits &&
-          fmtl1->channels.a.bits == fmtl2->channels.a.bits;
+   return isl_formats_have_same_bits_per_channel(format1, format2);
 }
 
 static bool



More information about the mesa-commit mailing list