aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIago Toral Quiroga <[email protected]>2018-04-18 09:36:41 +0200
committerIago Toral Quiroga <[email protected]>2019-01-02 07:54:05 +0100
commit1c8de08ec92bff7c44f9e4732c591b05ba1f2d76 (patch)
tree5b9e6c1edb8ad440297c3acc05b4ce986f733b6d
parentdf118535cabe2d5149b64a23988a4987518c95fb (diff)
compiler/spirv: implement 16-bit atan
v2: - use nir_fadd_imm and nir_fmul_imm helpers (Jason) - rebased on top of new sized boolean opcodes - use nir_b2f helper Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/spirv/vtn_glsl450.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 9211bca301c..1548c52dbe1 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -237,8 +237,10 @@ build_fsum(nir_builder *b, nir_ssa_def **xs, int terms)
static nir_ssa_def *
build_atan(nir_builder *b, nir_ssa_def *y_over_x)
{
+ const uint32_t bit_size = y_over_x->bit_size;
+
nir_ssa_def *abs_y_over_x = nir_fabs(b, y_over_x);
- nir_ssa_def *one = nir_imm_float(b, 1.0f);
+ nir_ssa_def *one = nir_imm_floatN_t(b, 1.0f, bit_size);
/*
* range-reduction, first step:
@@ -265,12 +267,12 @@ build_atan(nir_builder *b, nir_ssa_def *y_over_x)
nir_ssa_def *x_11 = nir_fmul(b, x_9, x_2);
nir_ssa_def *polynomial_terms[] = {
- nir_fmul(b, x, nir_imm_float(b, 0.9999793128310355f)),
- nir_fmul(b, x_3, nir_imm_float(b, -0.3326756418091246f)),
- nir_fmul(b, x_5, nir_imm_float(b, 0.1938924977115610f)),
- nir_fmul(b, x_7, nir_imm_float(b, -0.1173503194786851f)),
- nir_fmul(b, x_9, nir_imm_float(b, 0.0536813784310406f)),
- nir_fmul(b, x_11, nir_imm_float(b, -0.0121323213173444f)),
+ nir_fmul_imm(b, x, 0.9999793128310355f),
+ nir_fmul_imm(b, x_3, -0.3326756418091246f),
+ nir_fmul_imm(b, x_5, 0.1938924977115610f),
+ nir_fmul_imm(b, x_7, -0.1173503194786851f),
+ nir_fmul_imm(b, x_9, 0.0536813784310406f),
+ nir_fmul_imm(b, x_11, -0.0121323213173444f),
};
nir_ssa_def *tmp =
@@ -278,11 +280,8 @@ build_atan(nir_builder *b, nir_ssa_def *y_over_x)
/* range-reduction fixup */
tmp = nir_fadd(b, tmp,
- nir_fmul(b,
- nir_b2f32(b, nir_flt(b, one, abs_y_over_x)),
- nir_fadd(b, nir_fmul(b, tmp,
- nir_imm_float(b, -2.0f)),
- nir_imm_float(b, M_PI_2f))));
+ nir_fmul(b, nir_b2f(b, nir_flt(b, one, abs_y_over_x), bit_size),
+ nir_fadd_imm(b, nir_fmul_imm(b, tmp, -2.0f), M_PI_2f)));
/* sign fixup */
return nir_fmul(b, tmp, nir_fsign(b, y_over_x));