summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm/lp_bld_quad.c
diff options
context:
space:
mode:
authorJames Benton <jbenton@vmware.com>2012-09-13 16:04:42 +0100
committerJosé Fonseca <jfonseca@vmware.com>2012-11-28 19:14:36 +0000
commitfa1b481c09b14e01eca1b3db8e0854033f6dee3d (patch)
tree170810687d31e60041309682e8f923f409174077 /src/gallium/auxiliary/gallivm/lp_bld_quad.c
parent1d3789bccbbcc814fd7b339e9f5b5631e30d9f0e (diff)
downloadexternal_mesa3d-fa1b481c09b14e01eca1b3db8e0854033f6dee3d.zip
external_mesa3d-fa1b481c09b14e01eca1b3db8e0854033f6dee3d.tar.gz
external_mesa3d-fa1b481c09b14e01eca1b3db8e0854033f6dee3d.tar.bz2
llvmpipe: Unswizzled rendering.
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_quad.c')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_quad.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_quad.c b/src/gallium/auxiliary/gallivm/lp_bld_quad.c
index c7c58ed..8a0efed 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_quad.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_quad.c
@@ -31,6 +31,7 @@
#include "lp_bld_const.h"
#include "lp_bld_swizzle.h"
#include "lp_bld_quad.h"
+#include "lp_bld_pack.h"
static const unsigned char
@@ -156,3 +157,52 @@ lp_build_packed_ddx_ddy_twocoord(struct lp_build_context *bld,
return LLVMBuildSub(builder, vec2, vec1, "ddxddyddxddy");
}
+
+/**
+ * Twiddle from quad format to row format
+ *
+ * src0 src1
+ * ######### ######### #################
+ * # 0 | 1 # # 4 | 5 # # 0 | 1 | 4 | 5 # src0
+ * #---+---# #---+---# -> #################
+ * # 2 | 3 # # 6 | 7 # # 2 | 3 | 6 | 7 # src1
+ * ######### ######### #################
+ *
+ */
+void
+lp_bld_quad_twiddle(struct gallivm_state *gallivm,
+ struct lp_type lp_dst_type,
+ const LLVMValueRef* src,
+ unsigned src_count,
+ LLVMValueRef* dst)
+{
+ LLVMBuilderRef builder = gallivm->builder;
+ LLVMTypeRef dst_type_ref;
+ LLVMTypeRef type2_ref;
+ struct lp_type type2;
+ unsigned i;
+
+ assert((src_count % 2) == 0);
+
+ /* Create a type with only 2 elements */
+ type2 = lp_dst_type;
+ type2.width = (lp_dst_type.width * lp_dst_type.length) / 2;
+ type2.length = 2;
+ type2.floating = 0;
+
+ type2_ref = lp_build_vec_type(gallivm, type2);
+ dst_type_ref = lp_build_vec_type(gallivm, lp_dst_type);
+
+ for (i = 0; i < src_count; i += 2) {
+ LLVMValueRef src0, src1;
+
+ src0 = LLVMBuildBitCast(builder, src[i + 0], type2_ref, "");
+ src1 = LLVMBuildBitCast(builder, src[i + 1], type2_ref, "");
+
+ dst[i + 0] = lp_build_interleave2(gallivm, type2, src0, src1, 0);
+ dst[i + 1] = lp_build_interleave2(gallivm, type2, src0, src1, 1);
+
+ dst[i + 0] = LLVMBuildBitCast(builder, dst[i + 0], dst_type_ref, "");
+ dst[i + 1] = LLVMBuildBitCast(builder, dst[i + 1], dst_type_ref, "");
+ }
+}