From 4393ca7956bd03e07b4d7a019705fc62d4ac7155 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Tue, 11 Aug 2009 13:09:54 +0100 Subject: [PATCH] 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 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. -- 2.30.2