From ae6d32c938fc79ff5019806a2592097ca97bd945 Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Wed, 20 Apr 2022 14:30:30 +0300 Subject: [PATCH] gallium: refactor a channel loop in draw_llvm.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Marek Olšák Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/auxiliary/draw/draw_llvm.c | 36 ++++++++++---------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 1f68170d99e..ee4ff8178a8 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -1651,29 +1651,19 @@ generate_clipmask(struct draw_llvm *llvm, indices[0] = lp_build_const_int32(gallivm, 0); indices[1] = lp_build_const_int32(gallivm, plane_idx); - indices[2] = lp_build_const_int32(gallivm, 0); - plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, ""); - plane1 = LLVMBuildLoad2(builder, vs_elem_type, plane_ptr, "plane_x"); - planes = lp_build_broadcast(gallivm, vs_type_llvm, plane1); - sum = LLVMBuildFMul(builder, planes, cv_x, ""); - - indices[2] = lp_build_const_int32(gallivm, 1); - plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, ""); - plane1 = LLVMBuildLoad2(builder, vs_elem_type, plane_ptr, "plane_y"); - planes = lp_build_broadcast(gallivm, vs_type_llvm, plane1); - sum = lp_build_fmuladd(builder, planes, cv_y, sum); - - indices[2] = lp_build_const_int32(gallivm, 2); - plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, ""); - plane1 = LLVMBuildLoad2(builder, vs_elem_type, plane_ptr, "plane_z"); - planes = lp_build_broadcast(gallivm, vs_type_llvm, plane1); - sum = lp_build_fmuladd(builder, planes, cv_z, sum); - - indices[2] = lp_build_const_int32(gallivm, 3); - plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, ""); - plane1 = LLVMBuildLoad2(builder, vs_elem_type, plane_ptr, "plane_w"); - planes = lp_build_broadcast(gallivm, vs_type_llvm, plane1); - sum = lp_build_fmuladd(builder, planes, cv_w, sum); + for (int i = 0; i < 4; ++i) { + indices[2] = lp_build_const_int32(gallivm, i); + plane_ptr = LLVMBuildGEP(builder, planes_ptr, indices, 3, ""); + plane1 = LLVMBuildLoad2(builder, vs_elem_type, plane_ptr, + (const char *[]){"plane_x", "plane_y", "plane_z", "plane_w"}[i]); + planes = lp_build_broadcast(gallivm, vs_type_llvm, plane1); + if (i == 0) { + sum = LLVMBuildFMul(builder, planes, cv_x, ""); + } else { + sum = lp_build_fmuladd(builder, planes, + (LLVMValueRef[]){cv_x, cv_y, cv_z, cv_w}[i], sum); + } + } test = lp_build_compare(gallivm, f32_type, PIPE_FUNC_GREATER, zero, sum); temp = lp_build_const_int_vec(gallivm, i32_type, 1LL << plane_idx);