Mesa (master): isl/format: Add a get_num_channels helper

Jason Ekstrand jekstrand at kemper.freedesktop.org
Fri Apr 22 03:45:38 UTC 2016


Module: Mesa
Branch: master
Commit: 2980507a1983b2af157dc538fb22e759c1d257e8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2980507a1983b2af157dc538fb22e759c1d257e8

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Fri Apr 15 21:36:21 2016 -0700

isl/format: Add a get_num_channels helper

Reviewed-by: Chad Versace <chad.versace at intel.com>

---

 src/intel/isl/isl.h        |  2 ++
 src/intel/isl/isl_format.c | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index bc242db..2a29b28 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -854,6 +854,8 @@ isl_format_has_int_channel(enum isl_format fmt)
           isl_format_has_sint_channel(fmt);
 }
 
+unsigned isl_format_get_num_channels(enum isl_format fmt);
+
 static inline bool
 isl_format_is_compressed(enum isl_format fmt)
 {
diff --git a/src/intel/isl/isl_format.c b/src/intel/isl/isl_format.c
index fd16ea1..4d02b1d 100644
--- a/src/intel/isl/isl_format.c
+++ b/src/intel/isl/isl_format.c
@@ -75,6 +75,21 @@ isl_format_has_sint_channel(enum isl_format fmt)
    return isl_format_has_channel_type(fmt, ISL_SINT);
 }
 
+unsigned
+isl_format_get_num_channels(enum isl_format fmt)
+{
+   const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
+
+   assert(fmtl->channels.p.bits == 0);
+
+   return (fmtl->channels.r.bits > 0) +
+          (fmtl->channels.g.bits > 0) +
+          (fmtl->channels.b.bits > 0) +
+          (fmtl->channels.a.bits > 0) +
+          (fmtl->channels.l.bits > 0) +
+          (fmtl->channels.i.bits > 0);
+}
+
 enum isl_format
 isl_format_rgb_to_rgba(enum isl_format rgb)
 {




More information about the mesa-commit mailing list