intel/isl: Add an isl_color_value_is_zero helper
[mesa.git] / src / intel / isl / isl.c
index 4dce0596d23cbd28bc3d300ccf9df2e49fbcd2cd..1a32c028183f9723b49b910e1dbacf2b125db3a0 100644 (file)
@@ -268,6 +268,26 @@ isl_tiling_get_info(enum isl_tiling tiling,
    };
 }
 
+bool
+isl_color_value_is_zero(union isl_color_value value,
+                        enum isl_format format)
+{
+   const struct isl_format_layout *fmtl = isl_format_get_layout(format);
+
+#define RETURN_FALSE_IF_NOT_0(c, i) \
+   if (fmtl->channels.c.bits && value.u32[i] != 0) \
+      return false
+
+   RETURN_FALSE_IF_NOT_0(r, 0);
+   RETURN_FALSE_IF_NOT_0(g, 1);
+   RETURN_FALSE_IF_NOT_0(b, 2);
+   RETURN_FALSE_IF_NOT_0(a, 3);
+
+#undef RETURN_FALSE_IF_NOT_0
+
+   return true;
+}
+
 bool
 isl_color_value_is_zero_one(union isl_color_value value,
                             enum isl_format format)