From: Jason Ekstrand Date: Sat, 23 Aug 2014 15:36:46 +0000 (-0700) Subject: mesa: Fix clamping to -1.0 in snorm_to_float X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d1b08ac44cf2531b0df39f52ead93ad216ea233;p=mesa.git mesa: Fix clamping to -1.0 in snorm_to_float This patch fixes the return of a wrong value when x is lower than -MAX_INT(src_bits) as the result would not be between [-1.0 1.0]. v2 by Samuel Iglesias : - Modify snorm_to_float() to avoid doing the division when x == -MAX_INT(src_bits) Cc: 10.4 Reviewed-by: Ian Romanick Reviewed-by: Jason Ekstrand --- diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c index 93a0ceac0a0..5dd08483a03 100644 --- a/src/mesa/main/format_utils.c +++ b/src/mesa/main/format_utils.c @@ -152,7 +152,7 @@ unorm_to_float(unsigned x, unsigned src_bits) static inline float snorm_to_float(int x, unsigned src_bits) { - if (x == -MAX_INT(src_bits)) + if (x <= -MAX_INT(src_bits)) return -1.0f; else return x * (1.0f / (float)MAX_INT(src_bits));