From aab1361d59555ffe084e9da15bb41452d8495f90 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 16 Mar 2020 12:57:48 +0100 Subject: [PATCH] compiler/nir: move tan-calculation to helper Reviewed-by: Alyssa Rosenzweig Reviewed-By: Karol Herbst Part-of: --- 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: { -- 2.30.2