diff --git a/src/util/half_float.h b/src/util/half_float.h index 10797454fe9..3ed47981f43 100644 --- a/src/util/half_float.h +++ b/src/util/half_float.h @@ -223,6 +223,18 @@ _mesa_double_to_float16_rtz(double val) return _mesa_float_to_float16_rtz(_mesa_reduce_double_for_f16(val)); } +static inline uint16_t +_mesa_double_to_float16_ru(double val) +{ + return _mesa_float_to_float16_ru(_mesa_reduce_double_for_f16(val)); +} + +static inline uint16_t +_mesa_double_to_float16_rd(double val) +{ + return _mesa_float_to_float16_rd(_mesa_reduce_double_for_f16(val)); +} + #ifdef __cplusplus namespace mesa diff --git a/src/util/tests/half_float_test.cpp b/src/util/tests/half_float_test.cpp index 1469e95f2af..f34692f7e75 100644 --- a/src/util/tests/half_float_test.cpp +++ b/src/util/tests/half_float_test.cpp @@ -539,3 +539,13 @@ TEST(double_to_float16_rtz, rounding) { test_double_to_half_rounding(_mesa_double_to_float16_rtz, RTZ); } + +TEST(double_to_float16_ru, rounding) +{ + test_double_to_half_rounding(_mesa_double_to_float16_ru, RU); +} + +TEST(double_to_float16_rd, rounding) +{ + test_double_to_half_rounding(_mesa_double_to_float16_rd, RD); +}