From 024c49e95e04dc6ec86c851450bfc954e46265d6 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 18 Jun 2015 17:34:55 -0700 Subject: [PATCH] nir/builder: add a nir_fdot() convenience function --- src/glsl/nir/nir_builder.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index 08b40f8ea7c..3aa0efded3c 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -217,6 +217,23 @@ nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4], nir_imov_alu(build, alu_src, num_components); } +/* Selects the right fdot given the number of components in each source. */ +static inline nir_ssa_def * +nir_fdot(nir_builder *build, nir_ssa_def *src0, nir_ssa_def *src1) +{ + assert(src0->num_components == src1->num_components); + switch (src0->num_components) { + case 1: return nir_fmul(build, src0, src1); + case 2: return nir_fdot2(build, src0, src1); + case 3: return nir_fdot3(build, src0, src1); + case 4: return nir_fdot4(build, src0, src1); + default: + unreachable("bad component size"); + } + + return NULL; +} + /** * Turns a nir_src into a nir_ssa_def * so it can be passed to * nir_build_alu()-based builder calls. -- 2.30.2