Mesa (master): gallium: Add util_format_is_unorm8 check

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 9 21:17:59 UTC 2019


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Fri Jul  5 08:40:22 2019 -0700

gallium: Add util_format_is_unorm8 check

Useful for formats that would work with the same driver code path as
RGBA8 UNORM but that don't meet the util_format_is_rgba8_variant
criteria due to a smaller channel count.

v2: Use simpler logic (suggested by Iago).

v3: Fix spelling erorr. boolean->bool (thank you airlied).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/gallium/auxiliary/util/u_format.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index cf69460e050..abf1141993f 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -788,7 +788,6 @@ util_format_is_rgba8_variant(const struct util_format_description *desc)
    return TRUE;
 }
 
-
 /**
  * Return total bits needed for the pixel format per block.
  */
@@ -1265,6 +1264,22 @@ util_format_get_first_non_void_channel(enum pipe_format format)
    return i;
 }
 
+/**
+ * Whether this format is any 8-bit UNORM variant. Looser than
+ * util_is_rgba8_variant (also includes alpha textures, for instance).
+ */
+
+static inline bool
+util_format_is_unorm8(const struct util_format_description *desc)
+{
+   int c = util_format_get_first_non_void_channel(desc->format);
+
+   if (c == -1)
+      return false;
+
+   return desc->is_unorm && desc->is_array && desc->channel[c].size == 8;
+}
+
 /*
  * Format access functions.
  */




More information about the mesa-commit mailing list