Mesa (master): nir: add support for 64-bit in SmoothStep function

Juan Antonio Suárez Romero jasuarez at kemper.freedesktop.org
Tue Jun 27 10:08:32 UTC 2017


Module: Mesa
Branch: master
Commit: b5ae17fe59b5f303f2aa42608474ad37ffdf3971
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b5ae17fe59b5f303f2aa42608474ad37ffdf3971

Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date:   Thu Jun  8 11:03:42 2017 +0000

nir: add support for 64-bit in SmoothStep function

According to GLSL.std.450 spec, SmoothStep expects input to be a
floating-point type, but it does not restrict the bitsize.

Current implementation relies on inputs to be 32-bit.

This commit extends the support to 64-bit size inputs.

Reviewed by: Elie Tournier <elie.tournier at collabora.com>

---

 src/compiler/spirv/vtn_glsl450.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 5d384319e0..96e3407dee 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -465,6 +465,8 @@ vtn_nir_alu_op_for_spirv_glsl_opcode(enum GLSLstd450 opcode)
    }
 }
 
+#define NIR_IMM_FP(n, v) (src[0]->bit_size == 64 ? nir_imm_double(n, v) : nir_imm_float(n, v))
+
 static void
 handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
                    const uint32_t *w, unsigned count)
@@ -560,12 +562,12 @@ handle_glsl450_alu(struct vtn_builder *b, enum GLSLstd450 entrypoint,
       nir_ssa_def *t =
          build_fclamp(nb, nir_fdiv(nb, nir_fsub(nb, src[2], src[0]),
                                        nir_fsub(nb, src[1], src[0])),
-                          nir_imm_float(nb, 0.0), nir_imm_float(nb, 1.0));
+                          NIR_IMM_FP(nb, 0.0), NIR_IMM_FP(nb, 1.0));
       /* result = t * t * (3 - 2 * t) */
       val->ssa->def =
          nir_fmul(nb, t, nir_fmul(nb, t,
-            nir_fsub(nb, nir_imm_float(nb, 3.0),
-                         nir_fmul(nb, nir_imm_float(nb, 2.0), t))));
+            nir_fsub(nb, NIR_IMM_FP(nb, 3.0),
+                         nir_fmul(nb, NIR_IMM_FP(nb, 2.0), t))));
       return;
    }
 




More information about the mesa-commit mailing list