diff options
author | Jordan Justen <[email protected]> | 2012-06-25 14:14:25 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2012-08-14 17:07:42 -0700 |
commit | 6671d0dad300e591ac7c0e5110c6778373d0149a (patch) | |
tree | 20dc52264f0e7d05e706b96bf3a3f4766718a372 /src/mesa | |
parent | f7333b6345deb1c0322079039544bc322ca1dad9 (diff) |
mesa ReadPixels: handle signed/unsigned integer clamping
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/readpix.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index f9d3c37973b..f0bc157d83a 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -322,6 +322,8 @@ slow_read_rgba_pixels( struct gl_context *ctx, void *rgba; GLubyte *dst, *map; int dstStride, stride, j; + GLboolean dst_is_integer = _mesa_is_enum_format_integer(format); + GLboolean dst_is_uint = _mesa_is_format_unsigned(rbFormat); dstStride = _mesa_image_row_stride(packing, width, format, type); dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, @@ -339,12 +341,17 @@ slow_read_rgba_pixels( struct gl_context *ctx, goto done; for (j = 0; j < height; j++) { - if (_mesa_is_enum_format_integer(format)) { + if (dst_is_integer) { _mesa_unpack_uint_rgba_row(rbFormat, width, map, (GLuint (*)[4]) rgba); _mesa_rebase_rgba_uint(width, (GLuint (*)[4]) rgba, rb->_BaseFormat); - _mesa_pack_rgba_span_from_uints(ctx, width, (GLuint (*)[4]) rgba, format, - type, dst); + if (dst_is_uint) { + _mesa_pack_rgba_span_from_uints(ctx, width, (GLuint (*)[4]) rgba, format, + type, dst); + } else { + _mesa_pack_rgba_span_from_ints(ctx, width, (GLint (*)[4]) rgba, format, + type, dst); + } } else { _mesa_unpack_rgba_row(rbFormat, width, map, (GLfloat (*)[4]) rgba); _mesa_rebase_rgba_float(width, (GLfloat (*)[4]) rgba, |