summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2014-09-12 08:42:03 -0400
committerRob Clark <[email protected]>2014-09-12 16:23:52 -0400
commit3e0a82b52ebbf306adb0dd0f0990f7a8e8b271c5 (patch)
tree2ae0041a314c48a223af72d60ee0b2266ee59f51 /src/gallium/auxiliary
parent480fe244dd41a034111963440a9f51999cfc9035 (diff)
util/u_format: add _is_alpha()
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 <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/util/u_format.c17
-rw-r--r--src/gallium/auxiliary/util/u_format.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
index d53dd7884f0..c1ce408119f 100644
--- a/src/gallium/auxiliary/util/u_format.c
+++ b/src/gallium/auxiliary/util/u_format.c
@@ -92,6 +92,23 @@ util_format_is_luminance(enum pipe_format format)
}
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)
{
const struct util_format_description *desc = util_format_description(format);
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index df31400af90..621574c9673 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -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);