[Mesa-dev] [PATCH 02/59] compiler/spirv: implement 16-bit asin

Iago Toral Quiroga itoral at igalia.com
Tue Dec 4 07:16:26 UTC 2018


---
 src/compiler/spirv/vtn_glsl450.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 06a49e48e3f..e85123725da 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -200,19 +200,25 @@ build_log(nir_builder *b, nir_ssa_def *x)
  * in each case.
  */
 static nir_ssa_def *
-build_asin(nir_builder *b, nir_ssa_def *x, float p0, float p1)
+build_asin(nir_builder *b, nir_ssa_def *x, float _p0, float _p1)
 {
+   nir_ssa_def *p0 = nir_imm_floatN_t(b, _p0, x->bit_size);
+   nir_ssa_def *p1 = nir_imm_floatN_t(b, _p1, x->bit_size);
+   nir_ssa_def *one = nir_imm_floatN_t(b, 1.0f, x->bit_size);
+   nir_ssa_def *m_pi_2 = nir_imm_floatN_t(b, M_PI_2f, x->bit_size);
+   nir_ssa_def *m_pi_4_minus_one =
+      nir_imm_floatN_t(b, M_PI_4f - 1.0f, x->bit_size);
    nir_ssa_def *abs_x = nir_fabs(b, x);
    return nir_fmul(b, nir_fsign(b, x),
-                   nir_fsub(b, nir_imm_float(b, M_PI_2f),
-                            nir_fmul(b, nir_fsqrt(b, nir_fsub(b, nir_imm_float(b, 1.0f), abs_x)),
-                                     nir_fadd(b, nir_imm_float(b, M_PI_2f),
+                   nir_fsub(b, m_pi_2,
+                            nir_fmul(b, nir_fsqrt(b, nir_fsub(b, one, abs_x)),
+                                     nir_fadd(b, m_pi_2,
                                               nir_fmul(b, abs_x,
-                                                       nir_fadd(b, nir_imm_float(b, M_PI_4f - 1.0f),
+                                                       nir_fadd(b, m_pi_4_minus_one,
                                                                 nir_fmul(b, abs_x,
-                                                                         nir_fadd(b, nir_imm_float(b, p0),
+                                                                         nir_fadd(b, p0,
                                                                                   nir_fmul(b, abs_x,
-                                                                                           nir_imm_float(b, p1))))))))));
+                                                                                           p1)))))))));
 }
 
 /**
-- 
2.17.1



More information about the mesa-dev mailing list