Mesa (master): util: Utility function to determine the channels that can be written in a color format .
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Sun Sep 5 09:18:03 UTC 2010
Module: Mesa
Branch: master
Commit: f25b6e546e66955d70a1aa72135a5054c4f0ed3e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f25b6e546e66955d70a1aa72135a5054c4f0ed3e
Author: José Fonseca <jfonseca at vmware.com>
Date: Fri Sep 3 20:21:33 2010 +0100
util: Utility function to determine the channels that can be written in a color format.
---
src/gallium/auxiliary/util/u_format.h | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 8e786a3..59bd03b 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -440,6 +440,39 @@ util_format_is_depth_and_stencil(enum pipe_format format)
desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
}
+
+/**
+ * Give the RGBA colormask of the channels that can be represented in this
+ * format.
+ *
+ * That is, the channels whose values are preserved.
+ */
+static INLINE unsigned
+util_format_colormask(const struct util_format_description *desc)
+{
+ unsigned colormask;
+ unsigned chan;
+
+ switch (desc->colorspace) {
+ case UTIL_FORMAT_COLORSPACE_RGB:
+ case UTIL_FORMAT_COLORSPACE_SRGB:
+ case UTIL_FORMAT_COLORSPACE_YUV:
+ colormask = 0;
+ for (chan = 0; chan < 4; ++chan) {
+ if (desc->swizzle[chan] < 4) {
+ colormask |= (1 << chan);
+ }
+ }
+ return colormask;
+ case UTIL_FORMAT_COLORSPACE_ZS:
+ return 0;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+
/**
* Whether this format is a rgab8 variant.
*
More information about the mesa-commit
mailing list