summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/format_utils.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-07-11 08:41:49 -0700
committerJason Ekstrand <[email protected]>2014-08-05 10:56:16 -0700
commitd55f77b503ab7b59ecdd8f31c4f7dc498710e75b (patch)
tree88f3461e990201b51f8226a40bbc7e870abf8e14 /src/mesa/main/format_utils.h
parent452d64986bd510753d13b56b33951f1b4348e3a9 (diff)
mesa/format_utils: Add a general format conversion function
Most format conversion operations required by GL can be performed by converting one channel at a time, shuffling the channels around, and optionally filling missing channels with zeros and ones. This adds a function to do just that in a general, yet efficient, way. v2: * Add better comments including full docs for functions * Don't use __typeof__ * Use inline helpers instead of writing out conversions by hand, * Force full loop unrolling for better performance v3: Add another set of parens around the MAX_INT macro Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/format_utils.h')
-rw-r--r--src/mesa/main/format_utils.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/main/format_utils.h b/src/mesa/main/format_utils.h
new file mode 100644
index 00000000000..11546aaf04b
--- /dev/null
+++ b/src/mesa/main/format_utils.h
@@ -0,0 +1,41 @@
+/**
+ * \file format_utils.h
+ * A collection of format conversion utility functions.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 2014 Intel Corporation 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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 FORMAT_UTILS_H
+#define FORMAT_UTILS_H
+
+#include "imports.h"
+
+void
+_mesa_swizzle_and_convert(void *dst, GLenum dst_type, int num_dst_channels,
+ const void *src, GLenum src_type, int num_src_channels,
+ const uint8_t swizzle[4], bool normalized, int count);
+
+#endif