util/format_pack: Clamp SNORM values to [-1, 1] when unpacking

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 20:02:39 -05:00
committed by Marge Bot
parent 354f0958af
commit 3797fc18d8
2 changed files with 4 additions and 5 deletions
+4
View File
@@ -397,6 +397,10 @@ def conversion_expr(src_channel,
# bigger than single precision mantissa, use double
value = '(%s * (1.0/0x%x))' % (value, one)
src_size = 64
if src_norm and src_type == SIGNED:
value = 'MAX2(-1.0f, %s)' % (value)
src_norm = False
else:
if src_size <= 23 or dst_channel.size <= 32: