diff options
author | Samuel Iglesias Gonsálvez <[email protected]> | 2019-02-04 15:10:35 +0100 |
---|---|---|
committer | Andres Gomez <[email protected]> | 2019-09-17 23:39:18 +0300 |
commit | 5e22f3e29a21eb4623759b517619543f3553caea (patch) | |
tree | dc0fec7bb38b78b065d89b9a4bd15c98a5b63e8e /src/compiler | |
parent | ef681cf9713664bcd3e95d54cc158b93b3542dc8 (diff) |
nir/constant_expressions: mind rounding mode converting from float to float16 destinations
v2:
- Move the op-code specific knowledge to nir_opcodes.py even if it
means a rount trip conversion (Connor).
Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]>
Signed-off-by: Andres Gomez <[email protected]>
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir_constant_expressions.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_constant_expressions.py b/src/compiler/nir/nir_constant_expressions.py index baba66e5d02..377f54d6521 100644 --- a/src/compiler/nir/nir_constant_expressions.py +++ b/src/compiler/nir/nir_constant_expressions.py @@ -364,7 +364,11 @@ struct ${type}${width}_vec { ## Sanitize the C value to a proper NIR 0/-1 bool _dst_val[_i].${get_const_field(output_type)} = -(int)dst; % elif output_type == "float16": - _dst_val[_i].u16 = _mesa_float_to_half(dst); + if (nir_is_rounding_mode_rtz(execution_mode, 16)) { + _dst_val[_i].u16 = _mesa_float_to_float16_rtz(dst); + } else { + _dst_val[_i].u16 = _mesa_float_to_float16_rtne(dst); + } % else: _dst_val[_i].${get_const_field(output_type)} = dst; % endif @@ -408,7 +412,11 @@ struct ${type}${width}_vec { ## Sanitize the C value to a proper NIR 0/-1 bool _dst_val[${k}].${get_const_field(output_type)} = -(int)dst.${"xyzw"[k]}; % elif output_type == "float16": - _dst_val[${k}].u16 = _mesa_float_to_half(dst.${"xyzw"[k]}); + if (nir_is_rounding_mode_rtz(execution_mode, 16)) { + _dst_val[${k}].u16 = _mesa_float_to_float16_rtz(dst.${"xyzw"[k]}); + } else { + _dst_val[${k}].u16 = _mesa_float_to_float16_rtne(dst.${"xyzw"[k]}); + } % else: _dst_val[${k}].${get_const_field(output_type)} = dst.${"xyzw"[k]}; % endif |