util/u_format: add _is_alpha()
authorRob Clark <robclark@freedesktop.org>
Fri, 12 Sep 2014 12:42:03 +0000 (08:42 -0400)
committerRob Clark <robclark@freedesktop.org>
Fri, 12 Sep 2014 20:23:52 +0000 (16:23 -0400)
Because of render-to-alpha (000x) shenanigans, freedreno needs to do
some special handling when rendering to alpha-only formats.  And I
noticed that while we had _is_luminance(), _is_intensity(), etc, an
_is_alpha() helper was missing.  So fix that.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/auxiliary/util/u_format.c
src/gallium/auxiliary/util/u_format.h

index d53dd7884f0157ca83c1522fc1e5ffd6eda3b7ba..c1ce408119f115816e62693e143e0ce44ac8982f 100644 (file)
@@ -91,6 +91,23 @@ util_format_is_luminance(enum pipe_format format)
    return FALSE;
 }
 
+boolean
+util_format_is_alpha(enum pipe_format format)
+{
+   const struct util_format_description *desc =
+      util_format_description(format);
+
+   if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
+        desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
+       desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_0 &&
+       desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0 &&
+       desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0 &&
+       desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
+      return TRUE;
+   }
+   return FALSE;
+}
+
 boolean
 util_format_is_pure_integer(enum pipe_format format)
 {
index df31400af900971f529dca90b13c0edda2c35309..621574c967378703b73f475daf9ed5b12f91675d 100644 (file)
@@ -661,6 +661,8 @@ util_format_has_alpha(enum pipe_format format);
 boolean
 util_format_is_luminance(enum pipe_format format);
 
+boolean
+util_format_is_alpha(enum pipe_format format);
 
 boolean
 util_format_is_luminance_alpha(enum pipe_format format);