Mesa (master): compiler/nir: move tan-calculation to helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 4 11:53:42 UTC 2020


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Mon Mar 16 12:57:48 2020 +0100

compiler/nir: move tan-calculation to helper

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-By: Karol Herbst <kherbst at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4811>

---

 src/compiler/nir/nir_builtin_builder.h | 6 ++++++
 src/compiler/spirv/vtn_glsl450.c       | 3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_builtin_builder.h b/src/compiler/nir/nir_builtin_builder.h
index e4c836541b7..ef668d2f64a 100644
--- a/src/compiler/nir/nir_builtin_builder.h
+++ b/src/compiler/nir/nir_builtin_builder.h
@@ -255,6 +255,12 @@ nir_select(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *s)
    return nir_bcsel(b, nir_ieq(b, s, nir_imm_intN_t(b, 0, s->bit_size)), x, y);
 }
 
+static inline nir_ssa_def *
+nir_ftan(nir_builder *b, nir_ssa_def *x)
+{
+   return nir_fdiv(b, nir_fsin(b, x), nir_fcos(b, x));
+}
+
 static inline nir_ssa_def *
 nir_clz_u(nir_builder *b, nir_ssa_def *a)
 {
diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 2d4743d59f0..8a234827dc5 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -309,8 +309,7 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
       val->ssa->def = nir_degrees(nb, src[0]);
       return;
    case GLSLstd450Tan:
-      val->ssa->def = nir_fdiv(nb, nir_fsin(nb, src[0]),
-                               nir_fcos(nb, src[0]));
+      val->ssa->def = nir_ftan(nb, src[0]);
       return;
 
    case GLSLstd450Modf: {



More information about the mesa-commit mailing list