util/half: Add double_to_float16_ru/rd helpers

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41295>
This commit is contained in:
Faith Ekstrand 2026-04-30 11:05:19 -04:00 committed by Marge Bot
parent 7e26f9e2a9
commit 4084f6900e
2 changed files with 22 additions and 0 deletions

View file

@ -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

View file

@ -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);
}