mesa: Fix _mesa_swizzle_and_convert integer conversions to clamp properly
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Mon, 27 Oct 2014 15:15:36 +0000 (16:15 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 12 Jan 2015 10:20:27 +0000 (11:20 +0100)
commitfea1be8d0bd53f817f62d9b4fa82cfcb667fd3c3
treedb9fd82be67f8fbf78d1d38e3dcff990a15bbc6c
parent483b04348848e193d7c71c2f40ce58c447d51755
mesa: Fix _mesa_swizzle_and_convert integer conversions to clamp properly

Fix various conversion paths that involved integer data types of different
sizes (uint16_t to uint8_t, int16_t to uint8_t, etc) that were not
being clamped properly.

Also, one of the paths was incorrectly assigning the value 12, instead of 1,
to the constant "one".

v2:
- Create auxiliary clamping functions and use them in all paths that
  required clamp because of different source and destination sizes
  and signed-unsigned conversions.

v3:
- Create MIN_INT macro and use it.

v4:
- Add _mesa_float_to_[un]signed() and mesa_half_to_[un]signed() auxiliary
  functions.
- Add clamp for float-to-integer conversions in _mesa_swizzle_and_convert()

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/main/format_utils.c
src/mesa/main/format_utils.h