diff options
author | Jason Ekstrand <[email protected]> | 2014-08-23 08:36:46 -0700 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2015-01-17 14:59:56 +0000 |
commit | a25e26f67f2479dff4c33885255e546a7869db1c (patch) | |
tree | 84e6b0929d3a37acf8aa9aeeb47bacf635d5db14 /src | |
parent | 021d71b8480393c3f0bbe35fd2f8bb7052c7ff31 (diff) |
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 <[email protected]>:
- Modify snorm_to_float() to avoid doing the division when
x == -MAX_INT(src_bits)
Cc: 10.4 <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
(cherry picked from commit 7d1b08ac44cf2531b0df39f52ead93ad216ea233)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/format_utils.c | 2 |
1 files changed, 1 insertions, 1 deletions
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)); |