summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorJames Benton <[email protected]>2012-05-30 14:38:52 +0100
committerJosé Fonseca <[email protected]>2012-11-28 19:14:36 +0000
commit71c6fe76c05aa7fc1300cb13e6507abbea5a1e19 (patch)
tree2c5a42958b12947b027b7ad3905a05b87b21cd3e /src/gallium/auxiliary
parentcd548836a1410220090dbd7866735a7493c7cf47 (diff)
gallivm: Add a function to generate lp_type for a format.
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c8
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_type.h30
2 files changed, 31 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
index b163fbc66d6..609b9d415d6 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos_array.c
@@ -58,13 +58,7 @@ lp_build_fetch_rgba_aos_array(struct gallivm_state *gallivm,
LLVMValueRef ptr, res = NULL;
struct lp_type src_type;
- memset(&src_type, 0, sizeof src_type);
- src_type.floating = format_desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT;
- src_type.fixed = format_desc->channel[0].type == UTIL_FORMAT_TYPE_FIXED;
- src_type.sign = format_desc->channel[0].type != UTIL_FORMAT_TYPE_UNSIGNED;
- src_type.norm = format_desc->channel[0].normalized;
- src_type.width = format_desc->channel[0].size;
- src_type.length = format_desc->nr_channels;
+ lp_type_from_format_desc(&src_type, format_desc);
assert(src_type.length <= dst_type.length);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h
index 75310e05f3e..6ce5501baf4 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_type.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h
@@ -37,6 +37,7 @@
#define LP_BLD_TYPE_H
+#include "util/u_format.h"
#include "pipe/p_compiler.h"
#include "gallivm/lp_bld.h"
@@ -165,6 +166,35 @@ struct lp_build_context
};
+/**
+ * Converts a format description into an lp_type.
+ *
+ * Only works with "array formats".
+ *
+ * e.g. With PIPE_FORMAT_R32G32B32A32_FLOAT returns an lp_type with float[4]
+ */
+static INLINE void
+lp_type_from_format_desc(struct lp_type* type, const struct util_format_description *format_desc)
+{
+ assert(util_format_is_array(format_desc));
+
+ memset(type, 0, sizeof(struct lp_type));
+ type->floating = format_desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT;
+ type->fixed = format_desc->channel[0].type == UTIL_FORMAT_TYPE_FIXED;
+ type->sign = format_desc->channel[0].type != UTIL_FORMAT_TYPE_UNSIGNED;
+ type->norm = format_desc->channel[0].normalized;
+ type->width = format_desc->channel[0].size;
+ type->length = format_desc->nr_channels;
+}
+
+
+static INLINE void
+lp_type_from_format(struct lp_type* type, enum pipe_format format)
+{
+ lp_type_from_format_desc(type, util_format_description(format));
+}
+
+
static INLINE unsigned
lp_type_width(struct lp_type type)
{