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:
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 =
/* 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));