diff options
author | Eric Anholt <[email protected]> | 2012-01-24 14:16:59 -0800 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2012-02-07 10:20:07 -0800 |
commit | c1ccb52c72e73ad657bc5b5d2cb04759953fd3ab (patch) | |
tree | 7fa782a1527c1017bec3108e760f3dfc9beee79b | |
parent | 35af0909077b13ec198ca6b46101260a4c47a960 (diff) |
mesa: Add clamping for packing of integer data.
Mostly fixes piglit EXT_texture_integer/getteximage-clamping. The
remaining failure involves precision loss on storing of int32 texture
data (something I knew was an issue, but wasn't trying to test).
NOTE: This is a candidate for the 8.0 branch.
Reviewed-by: Brian Paul <[email protected]>
(cherry picked from commit 8b97bb02fb1a55a6b0fe558ea1eb97bb4dae0347)
-rw-r--r-- | src/mesa/main/pack.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c index ad76c98784a..23e9d1d5b3e 100644 --- a/src/mesa/main/pack.c +++ b/src/mesa/main/pack.c @@ -462,7 +462,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLushort -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) MIN2(x, 0xffff) #define FN_NAME pack_ushort_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE @@ -470,7 +470,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLshort -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) CLAMP((int)x, -32768, 32767) #define FN_NAME pack_short_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE @@ -478,7 +478,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLubyte -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) MIN2(x, 0xff) #define FN_NAME pack_ubyte_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE @@ -486,7 +486,7 @@ get_type_min_max(GLenum type, GLfloat *min, GLfloat *max) #undef FN_NAME #define DST_TYPE GLbyte -#define SRC_CONVERT(x) (x) +#define SRC_CONVERT(x) CLAMP((int)x, -128, 127) #define FN_NAME pack_byte_from_uint_rgba #include "pack_tmp.h" #undef DST_TYPE |