gallium/aux: add is_unorm() helper
[mesa.git] / src / gallium / auxiliary / util / u_format.c
index e43a619313e08b57ca34de5f9c84f9c6cf357e8c..231e89017b41e34006c84eca1b0d5dcb67858cc7 100644 (file)
@@ -169,6 +169,27 @@ util_format_is_snorm(enum pipe_format format)
           desc->channel[i].normalized;
 }
 
+/**
+ * Returns true if all non-void channels are normalized unsigned.
+ */
+boolean
+util_format_is_unorm(enum pipe_format format)
+{
+   const struct util_format_description *desc = util_format_description(format);
+   int i;
+
+   if (desc->is_mixed)
+      return FALSE;
+
+   i = util_format_get_first_non_void_channel(format);
+   if (i == -1)
+      return FALSE;
+
+   return desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED &&
+          !desc->channel[i].pure_integer &&
+          desc->channel[i].normalized;
+}
+
 boolean
 util_format_is_snorm8(enum pipe_format format)
 {