llvmpipe: Scalar -> vector broadcasting.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 11 Aug 2009 12:09:54 +0000 (13:09 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Sat, 29 Aug 2009 08:21:29 +0000 (09:21 +0100)
src/gallium/drivers/llvmpipe/lp_bld_swizzle.c
src/gallium/drivers/llvmpipe/lp_bld_swizzle.h

index 1f83bf67828cb837757b837a3367b8d5f34f9b41..3182573db29cc425d04ddd97c1ece51fea5f781f 100644 (file)
 #include "lp_bld_swizzle.h"
 
 
+LLVMValueRef
+lp_build_broadcast_scalar(struct lp_build_context *bld,
+                          LLVMValueRef scalar)
+{
+   const union lp_type type = bld->type;
+   LLVMValueRef res;
+   unsigned i;
+
+   res = bld->undef;
+   for(i = 0; i < type.length; ++i) {
+      LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0);
+      res = LLVMBuildInsertElement(bld->builder, res, scalar, index, "");
+   }
+
+   return res;
+}
+
+
 LLVMValueRef
 lp_build_broadcast_aos(struct lp_build_context *bld,
                        LLVMValueRef a,
index aeb4f42fa8ae35e7f1f61465b537a0eb0366a158..dede675e588b326574797a4d984a9f4e2f53027d 100644 (file)
@@ -44,6 +44,11 @@ union lp_type type;
 struct lp_build_context;
 
 
+LLVMValueRef
+lp_build_broadcast_scalar(struct lp_build_context *bld,
+                          LLVMValueRef scalar);
+
+
 /**
  * Broadcast one channel of a vector composed of arrays of XYZW structures into
  * all four channel.