[Mesa-dev] [PATCH 1/2] isl/isl_format: Add some channel size helpers

Nanley Chery nanleychery at gmail.com
Mon Nov 20 21:54:38 UTC 2017


One helper is not used in this series, but is included because it may be
useful when working with CNL's 10-10-10-2 formats.

Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/intel/isl/isl.h        |  4 ++++
 src/intel/isl/isl_format.c | 20 ++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index e3acb0ec28..ef9cdc38d8 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1423,6 +1423,10 @@ bool isl_format_has_ufloat_channel(enum isl_format fmt) ATTRIBUTE_CONST;
 bool isl_format_has_sfloat_channel(enum isl_format fmt) ATTRIBUTE_CONST;
 bool isl_format_has_uint_channel(enum isl_format fmt) ATTRIBUTE_CONST;
 bool isl_format_has_sint_channel(enum isl_format fmt) ATTRIBUTE_CONST;
+bool isl_format_channels_have_size(enum isl_format fmt, uint8_t size)
+   ATTRIBUTE_CONST;
+bool isl_format_channels_have_same_size(enum isl_format fmt)
+   ATTRIBUTE_CONST UNUSED;
 
 static inline bool
 isl_format_has_normalized_channel(enum isl_format fmt)
diff --git a/src/intel/isl/isl_format.c b/src/intel/isl/isl_format.c
index 03c591071b..33cc022772 100644
--- a/src/intel/isl/isl_format.c
+++ b/src/intel/isl/isl_format.c
@@ -697,6 +697,26 @@ isl_format_get_num_channels(enum isl_format fmt)
           (fmtl->channels.i.bits > 0);
 }
 
+bool
+isl_format_channels_have_size(enum isl_format fmt, uint8_t size)
+{
+   const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
+   for (unsigned i = 0; i < ARRAY_SIZE(fmtl->channels_array); i++) {
+      const uint8_t chan_size = fmtl->channels_array[i].bits;
+      if (chan_size > 0 && chan_size != size)
+         return false;
+   }
+   return true;
+}
+
+bool
+isl_format_channels_have_same_size(enum isl_format fmt)
+{
+   const unsigned fmt_width = isl_format_get_layout(fmt)->bpb;
+   const unsigned num_channels = isl_format_get_num_channels(fmt);
+   return isl_format_channels_have_size(fmt, fmt_width / num_channels);
+}
+
 uint32_t
 isl_format_get_depth_format(enum isl_format fmt, bool has_stencil)
 {
-- 
2.14.3



More information about the mesa-dev mailing list