summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util/u_format.h
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-07-26 23:50:00 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-08-29 09:21:15 +0100
commit15422b2d99be074e1d6ac064b6f791245975da83 (patch)
tree44d51409d6c873d603a0b1c7eb3626c5567f8bf0 /src/gallium/auxiliary/util/u_format.h
parent946f432a08112148d743eb9faf6b27bb8cc7fa76 (diff)
util: Pixel format database.
There are some inconsistencies in pipe_format, but above all, there simply aren't enough bits in an enum to conveniently store all information about a pixel format we need to be able to dynamically generate pixel packing/unpacking code.
Diffstat (limited to 'src/gallium/auxiliary/util/u_format.h')
-rw-r--r--src/gallium/auxiliary/util/u_format.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
new file mode 100644
index 0000000000..2d7730fbc5
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -0,0 +1,111 @@
+/**************************************************************************
+ *
+ * Copyright 2009 Vmware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef U_FORMAT_H
+#define U_FORMAT_H
+
+
+#include "pipe/p_format.h"
+
+
+enum util_format_layout {
+ UTIL_FORMAT_LAYOUT_RGBA = 0,
+ UTIL_FORMAT_LAYOUT_ZS = 1,
+ UTIL_FORMAT_LAYOUT_YUV = 2,
+ UTIL_FORMAT_LAYOUT_DXT = 3
+};
+
+
+struct util_format_block
+{
+ /** Block width in pixels */
+ unsigned width;
+
+ /** Block height in pixels */
+ unsigned height;
+
+ /** Block size in bytes */
+ unsigned bits;
+};
+
+
+enum util_format_type {
+ UTIL_FORMAT_TYPE_VOID = 0,
+ UTIL_FORMAT_TYPE_UNSIGNED = 1,
+ UTIL_FORMAT_TYPE_SIGNED = 2,
+ UTIL_FORMAT_TYPE_FIXED = 3,
+ UTIL_FORMAT_TYPE_FLOAT = 4
+};
+
+
+enum util_format_swizzle {
+ UTIL_FORMAT_SWIZZLE_X = 0,
+ UTIL_FORMAT_SWIZZLE_Y = 1,
+ UTIL_FORMAT_SWIZZLE_Z = 2,
+ UTIL_FORMAT_SWIZZLE_W = 3,
+ UTIL_FORMAT_SWIZZLE_0 = 4,
+ UTIL_FORMAT_SWIZZLE_1 = 5,
+ UTIL_FORMAT_SWIZZLE_NONE = 6
+};
+
+
+enum util_format_colorspace {
+ UTIL_FORMAT_COLORSPACE_RGB = 0,
+ UTIL_FORMAT_COLORSPACE_SRGB = 1
+};
+
+
+struct util_format_channel_description
+{
+ unsigned type:6;
+ unsigned normalized:1;
+ unsigned size:9;
+};
+
+
+struct util_format_description
+{
+ enum pipe_format format;
+ const char *name;
+ struct util_format_block block;
+ enum util_format_layout layout;
+ struct util_format_channel_description channel[4];
+ unsigned char swizzle[4];
+ enum util_format_colorspace colorspace;
+};
+
+
+extern const struct util_format_description
+util_format_description_table[];
+
+
+const struct util_format_description *
+util_format_description(enum pipe_format format);
+
+
+#endif /* ! U_FORMAT_H */