nir: add support for round to zero rounding mode to nir_op_f2f32
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Wed, 13 Feb 2019 09:31:37 +0000 (10:31 +0100)
committerAndres Gomez <agomez@igalia.com>
Tue, 17 Sep 2019 20:39:18 +0000 (23:39 +0300)
f2f16's rounding modes are already handled and f2f64 don't need it
as there is not a floating point type with higher bit size than 64 for
now.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/compiler/nir/nir_constant_expressions.py
src/compiler/nir/nir_opcodes.py

index 1df97aa100094ef1bf1976ca6d8277e5264c82e0..219d91c1cbd74cd40392a28a71b9fed486f1323a 100644 (file)
@@ -63,6 +63,7 @@ template = """\
 #include <math.h>
 #include "util/rounding.h" /* for _mesa_roundeven */
 #include "util/half_float.h"
+#include "util/double.h"
 #include "util/bigmath.h"
 #include "nir_constant_expressions.h"
 
index 3020da98264e8253bb3855579f9374b7c682c21e..13f64d78c4ff053a9246c7e302875278f2767d8e 100644 (file)
@@ -224,6 +224,16 @@ for src_t in [tint, tuint, tfloat, tbool]:
                   unop_numeric_convert("{0}2{1}{2}{3}".format(src_t[0], dst_t[0],
                                                               bit_size, rnd_mode),
                                        dst_t + str(bit_size), src_t, "src0")
+          elif bit_size == 32 and dst_t == tfloat and src_t == tfloat:
+              conv_expr = """
+              if (bit_size > 32 && nir_is_rounding_mode_rtz(execution_mode, 32)) {
+                 dst = _mesa_double_to_float_rtz(src0);
+              } else {
+                 dst = src0;
+              }
+              """
+              unop_numeric_convert("{0}2{1}{2}".format(src_t[0], dst_t[0], bit_size),
+                                   dst_t + str(bit_size), src_t, conv_expr)
           else:
               conv_expr = "src0 != 0" if dst_t == tbool else "src0"
               unop_numeric_convert("{0}2{1}{2}".format(src_t[0], dst_t[0], bit_size),