From: José Fonseca Date: Tue, 11 Aug 2009 12:09:54 +0000 (+0100) Subject: llvmpipe: Scalar -> vector broadcasting. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4393ca7956bd03e07b4d7a019705fc62d4ac7155;p=mesa.git llvmpipe: Scalar -> vector broadcasting. --- diff --git a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.c index 1f83bf67828..3182573db29 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 aeb4f42fa8a..dede675e588 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.