From 4393ca7956bd03e07b4d7a019705fc62d4ac7155 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 11 Aug 2009 13:09:54 +0100 Subject: llvmpipe: Scalar -> vector broadcasting. --- src/gallium/drivers/llvmpipe/lp_bld_swizzle.c | 18 ++++++++++++++++++ src/gallium/drivers/llvmpipe/lp_bld_swizzle.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c index 1f83bf6782..3182573db2 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c @@ -33,6 +33,24 @@ #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, diff --git a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h index aeb4f42fa8..dede675e58 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h @@ -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. -- cgit v1.2.3