diff options
author | Samuel Iglesias Gonsálvez <[email protected]> | 2019-02-13 10:31:37 +0100 |
---|---|---|
committer | Andres Gomez <[email protected]> | 2019-09-17 23:39:18 +0300 |
commit | 0ac07c7ca7207f3f1388c0450b456ecc578d9c5b (patch) | |
tree | 32e30311a6d9d90a9346bcf292959453b17d1bee /src/compiler | |
parent | 5308333e789e19956172d4e77e7ae4cf2fb4eafb (diff) |
nir: add support for round to zero rounding mode to nir_op_f2f32
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 <[email protected]>
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir_constant_expressions.py | 1 | ||||
-rw-r--r-- | src/compiler/nir/nir_opcodes.py | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_constant_expressions.py b/src/compiler/nir/nir_constant_expressions.py index 1df97aa1000..219d91c1cbd 100644 --- a/src/compiler/nir/nir_constant_expressions.py +++ b/src/compiler/nir/nir_constant_expressions.py @@ -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" diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 3020da98264..13f64d78c4f 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -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), |