Mesa (10.4): mesa: Fix clamping to -1.0 in snorm_to_float
Emil Velikov
evelikov at kemper.freedesktop.org
Thu Jan 22 16:19:52 UTC 2015
Module: Mesa
Branch: 10.4
Commit: a25e26f67f2479dff4c33885255e546a7869db1c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a25e26f67f2479dff4c33885255e546a7869db1c
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Sat Aug 23 08:36:46 2014 -0700
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 <siglesias at igalia.com>:
- Modify snorm_to_float() to avoid doing the division when
x == -MAX_INT(src_bits)
Cc: 10.4 <mesa-stable at lists.freedesktop.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
(cherry picked from commit 7d1b08ac44cf2531b0df39f52ead93ad216ea233)
---
src/mesa/main/format_utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mesa/main/format_utils.c b/src/mesa/main/format_utils.c
index 93a0cea..5dd0848 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));
More information about the mesa-commit
mailing list