Mesa (main): nir,glsl_to_nir: use nir_fdot()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 18:05:35 UTC 2021


Module: Mesa
Branch: main
Commit: cfc4433015d9b5d8081036419b7fcdcc39f7c312
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cfc4433015d9b5d8081036419b7fcdcc39f7c312

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Wed Jan 13 15:11:57 2021 +0000

nir,glsl_to_nir: use nir_fdot()

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8056>

---

 src/compiler/glsl/glsl_to_nir.cpp      |  8 +-------
 src/compiler/nir/nir_builtin_builder.c | 11 +----------
 src/compiler/nir/nir_convert_ycbcr.c   |  6 +++---
 src/compiler/nir/nir_lower_clip.c      |  2 +-
 4 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index aa226643dc4..3baa7fc84ec 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -2273,13 +2273,7 @@ nir_visitor::visit(ir_expression *ir)
       }
       break;
    case ir_binop_dot:
-      switch (ir->operands[0]->type->vector_elements) {
-         case 2: result = nir_fdot2(&b, srcs[0], srcs[1]); break;
-         case 3: result = nir_fdot3(&b, srcs[0], srcs[1]); break;
-         case 4: result = nir_fdot4(&b, srcs[0], srcs[1]); break;
-         default:
-            unreachable("not reached");
-      }
+      result = nir_fdot(&b, srcs[0], srcs[1]);
       break;
    case ir_binop_vector_extract: {
       result = nir_channel(&b, srcs[0], 0);
diff --git a/src/compiler/nir/nir_builtin_builder.c b/src/compiler/nir/nir_builtin_builder.c
index c8845f48325..d2fa24a4578 100644
--- a/src/compiler/nir/nir_builtin_builder.c
+++ b/src/compiler/nir/nir_builtin_builder.c
@@ -54,16 +54,7 @@ nir_cross4(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y)
 nir_ssa_def*
 nir_fast_length(nir_builder *b, nir_ssa_def *vec)
 {
-   switch (vec->num_components) {
-   case 1: return nir_fsqrt(b, nir_fmul(b, vec, vec));
-   case 2: return nir_fsqrt(b, nir_fdot2(b, vec, vec));
-   case 3: return nir_fsqrt(b, nir_fdot3(b, vec, vec));
-   case 4: return nir_fsqrt(b, nir_fdot4(b, vec, vec));
-   case 8: return nir_fsqrt(b, nir_fdot8(b, vec, vec));
-   case 16: return nir_fsqrt(b, nir_fdot16(b, vec, vec));
-   default:
-      unreachable("Invalid number of components");
-   }
+   return nir_fsqrt(b, nir_fdot(b, vec, vec));
 }
 
 nir_ssa_def*
diff --git a/src/compiler/nir/nir_convert_ycbcr.c b/src/compiler/nir/nir_convert_ycbcr.c
index 2a111699fdb..c411586cdba 100644
--- a/src/compiler/nir/nir_convert_ycbcr.c
+++ b/src/compiler/nir/nir_convert_ycbcr.c
@@ -131,9 +131,9 @@ nir_convert_ycbcr_to_rgb(nir_builder *b,
       ycbcr_model_to_rgb_matrix(model);
 
    nir_ssa_def *converted_channels[] = {
-      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[0])),
-      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[1])),
-      nir_fdot4(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[2]))
+      nir_fdot(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[0])),
+      nir_fdot(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[1])),
+      nir_fdot(b, expanded_channels, nir_build_imm(b, 4, 32, conversion_matrix->v[2]))
    };
 
    return nir_vec4(b,
diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c
index 3a3e98d0e8c..91945f42c4a 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -258,7 +258,7 @@ lower_clip_outputs(nir_builder *b, nir_variable *position,
          nir_ssa_def *ucp = get_ucp(b, plane, clipplane_state_tokens);
 
          /* calculate clipdist[plane] - dot(ucp, cv): */
-         clipdist[plane] = nir_fdot4(b, ucp, cv);
+         clipdist[plane] = nir_fdot(b, ucp, cv);
       } else {
          /* 0.0 == don't-clip == disabled: */
          clipdist[plane] = nir_imm_float(b, 0.0);



More information about the mesa-commit mailing list