nv50/ir: silence unsupported TGSI_PROPERTY_CS_FIXED_BLOCK_*
[mesa.git] / src / intel / isl / isl_format.c
index 32bd70186c667b95fd45b66ba2358e8b7a5348d0..4d02b1dd1e6283b5faa19be7c1b492bf56b6e417 100644 (file)
 
 #include "isl.h"
 
-bool
-isl_format_has_uint_channel(enum isl_format fmt)
+static inline bool
+isl_format_has_channel_type(enum isl_format fmt, enum isl_base_type type)
 {
    const struct isl_format_layout *fmtl = isl_format_get_layout(fmt);
 
-   return fmtl->channels.r.type == ISL_UINT ||
-          fmtl->channels.g.type == ISL_UINT ||
-          fmtl->channels.b.type == ISL_UINT ||
-          fmtl->channels.a.type == ISL_UINT ||
-          fmtl->channels.l.type == ISL_UINT ||
-          fmtl->channels.i.type == ISL_UINT ||
-          fmtl->channels.p.type == ISL_UINT;
+   return fmtl->channels.r.type == type ||
+          fmtl->channels.g.type == type ||
+          fmtl->channels.b.type == type ||
+          fmtl->channels.a.type == type ||
+          fmtl->channels.l.type == type ||
+          fmtl->channels.i.type == type ||
+          fmtl->channels.p.type == type;
+}
+
+bool
+isl_format_has_unorm_channel(enum isl_format fmt)
+{
+   return isl_format_has_channel_type(fmt, ISL_UNORM);
+}
+
+bool
+isl_format_has_snorm_channel(enum isl_format fmt)
+{
+   return isl_format_has_channel_type(fmt, ISL_SNORM);
+}
+
+bool
+isl_format_has_ufloat_channel(enum isl_format fmt)
+{
+   return isl_format_has_channel_type(fmt, ISL_UFLOAT);
+}
+
+bool
+isl_format_has_sfloat_channel(enum isl_format fmt)
+{
+   return isl_format_has_channel_type(fmt, ISL_SFLOAT);
+}
+
+bool
+isl_format_has_uint_channel(enum isl_format fmt)
+{
+   return isl_format_has_channel_type(fmt, ISL_UINT);
 }
 
 bool
 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);
 
-   return fmtl->channels.r.type == ISL_SINT ||
-          fmtl->channels.g.type == ISL_SINT ||
-          fmtl->channels.b.type == ISL_SINT ||
-          fmtl->channels.a.type == ISL_SINT ||
-          fmtl->channels.l.type == ISL_SINT ||
-          fmtl->channels.i.type == ISL_SINT ||
-          fmtl->channels.p.type == ISL_SINT;
+   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