util/format_pack: Also use iround for SCALED formats

This is probably not necessary but more correct.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28793>
This commit is contained in:
Faith Ekstrand
2024-04-17 13:01:30 -05:00
committed by Marge Bot
parent b187be5b1c
commit 354f0958af

View File

@@ -414,11 +414,14 @@ def conversion_expr(src_channel,
if dst_channel.norm or dst_channel.type == FIXED:
dst_one = get_one(dst_channel)
if dst_channel.size <= 23:
value = 'util_iround(%s * 0x%x)' % (value, dst_one)
value = '(%s * 0x%x)' % (value, dst_one)
else:
# bigger than single precision mantissa, use double
value = '(%s * (double)0x%x)' % (value, dst_one)
if dst_channel.size <= 23:
value = 'util_iround(%s)' % (value)
# Cast to an integer with the correct signedness first
if dst_channel.type == UNSIGNED:
value = '(uint%u_t)(%s) ' % (max(dst_channel.size, 32), value)