compiler/nir: move tan-calculation to helper
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 16 Mar 2020 11:57:48 +0000 (12:57 +0100)
committerMarge Bot <eric+marge@anholt.net>
Mon, 4 May 2020 11:31:29 +0000 (11:31 +0000)
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-By: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4811>

src/compiler/nir/nir_builtin_builder.h
src/compiler/spirv/vtn_glsl450.c

index e4c836541b7ecb66615835863e4304ed5034a582..ef668d2f64ae7ee51d3b87cb8febd3b2e069850b 100644 (file)
@@ -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)
 {
index 2d4743d59f0a9e598d808d6651fab4674d8fcded..8a234827dc57afaeeb1e0f58aa9484b0a50a1c8c 100644 (file)
@@ -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: {