Mesa (master): gallivm/nir: add fsum support

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Nov 15 21:13:06 UTC 2020


Module: Mesa
Branch: master
Commit: 2a3fd242b06283867feab9ba7831eb76c0fe8098
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a3fd242b06283867feab9ba7831eb76c0fe8098

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Oct 26 13:55:01 2020 +1000

gallivm/nir: add fsum support

This is needed for lowered dot products, this opcode just
sums all the vector elements.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7595>

---

 src/gallium/auxiliary/gallivm/lp_bld_nir.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
index db098a8c2c9..4ab8d5bf956 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c
@@ -978,6 +978,11 @@ static void visit_alu(struct lp_build_nir_context *bld_base, const nir_alu_instr
    case nir_op_cube_face_index:
       src_components = 3;
       break;
+   case nir_op_fsum2:
+   case nir_op_fsum3:
+   case nir_op_fsum4:
+      src_components = nir_src_num_components(instr->src[0].src);
+      break;
    default:
       src_components = num_components;
       break;
@@ -992,7 +997,14 @@ static void visit_alu(struct lp_build_nir_context *bld_base, const nir_alu_instr
       for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
          result[i] = cast_type(bld_base, src[i], nir_op_infos[instr->op].input_types[i], src_bit_size[i]);
       }
-   } else {
+   } else if (instr->op == nir_op_fsum4 || instr->op == nir_op_fsum3 || instr->op == nir_op_fsum2) {
+      for (unsigned c = 0; c < nir_src_num_components(instr->src[0].src); c++) {
+         LLVMValueRef temp_chan = LLVMBuildExtractValue(gallivm->builder,
+                                                          src[0], c, "");
+         temp_chan = cast_type(bld_base, temp_chan, nir_op_infos[instr->op].input_types[0], src_bit_size[0]);
+         result[0] = (c == 0) ? temp_chan : lp_build_add(get_flt_bld(bld_base, src_bit_size[0]), result[0], temp_chan);
+      }
+    } else {
       for (unsigned c = 0; c < num_components; c++) {
          LLVMValueRef src_chan[NIR_MAX_VEC_COMPONENTS];
 



More information about the mesa-commit mailing list