gallium/aux: add is_unorm() helper
authorRob Clark <robdclark@gmail.com>
Tue, 11 Dec 2018 16:13:49 +0000 (11:13 -0500)
committerRob Clark <robdclark@gmail.com>
Thu, 13 Dec 2018 20:51:01 +0000 (15:51 -0500)
We already had one for is_snorm() but not unorm.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/auxiliary/util/u_format.c
src/gallium/auxiliary/util/u_format.h

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)
 {
index 5bcfc1f1154c092f9615ae8c5303b5081e85346b..8dcc438a4a1d75f81fe2a3ddcecf630aacb86995 100644 (file)
@@ -726,6 +726,9 @@ util_format_is_pure_uint(enum pipe_format format);
 boolean
 util_format_is_snorm(enum pipe_format format);
 
+boolean
+util_format_is_unorm(enum pipe_format format);
+
 boolean
 util_format_is_snorm8(enum pipe_format format);