summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_format.h
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-04-02 05:23:32 +0200
committerLuca Barbieri <[email protected]>2010-04-02 06:16:30 +0200
commit5126683e3b971ccfb51e50e560750ce44e86bae8 (patch)
treeccdb7104752d266653a1201a97e551bed94ecd23 /src/gallium/auxiliary/util/u_format.h
parent52e9b990a192a9329006d5f7dd2ac222effea5a5 (diff)
gallium/util: add util_format_is_supported to check for pack/unpack
This improves the code by making it more readable, and removes special knowledge of S3TC and other formats from softpipe.
Diffstat (limited to 'src/gallium/auxiliary/util/u_format.h')
-rw-r--r--src/gallium/auxiliary/util/u_format.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index f7daa6d9236..fc550405d87 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -32,7 +32,7 @@
#include "pipe/p_format.h"
#include "util/u_debug.h"
-#include "util/u_inline_init.h"
+#include "util/u_format_s3tc.h"
#ifdef __cplusplus
extern "C" {
@@ -169,6 +169,13 @@ struct util_format_description
unsigned is_mixed:1;
/**
+ * Whether the pack/unpack functions actually work.
+ *
+ * Call util_format_is_supported instead of using this directly.
+ */
+ unsigned is_supported:1;
+
+ /**
* Input channel description.
*
* Only valid for UTIL_FORMAT_LAYOUT_PLAIN formats.
@@ -507,6 +514,20 @@ util_format_get_nr_components(enum pipe_format format)
* Format access functions.
*/
+static INLINE boolean
+util_format_is_supported(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+
+ if(!desc)
+ return FALSE;
+
+ if(desc->layout == UTIL_FORMAT_LAYOUT_S3TC)
+ util_format_s3tc_init();
+
+ return desc->is_supported;
+}
+
void
util_format_read_4f(enum pipe_format format,
float *dst, unsigned dst_stride,