From: José Fonseca Date: Thu, 20 Dec 2012 12:03:45 +0000 (+0000) Subject: util/u_format: Round when converting depth values from float to z16_unorm. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=74f07319533d39a509ddc3159a51cfe89cd47225;p=mesa.git util/u_format: Round when converting depth values from float to z16_unorm. This makes the z16_unorm -> float -> z16_unorm conversion lossless. Reviewed-by: Roland Scheidegger --- diff --git a/src/gallium/auxiliary/util/u_format_zs.c b/src/gallium/auxiliary/util/u_format_zs.c index 816ef14204c..ed45c52f9c9 100644 --- a/src/gallium/auxiliary/util/u_format_zs.c +++ b/src/gallium/auxiliary/util/u_format_zs.c @@ -72,7 +72,7 @@ static INLINE uint16_t z32_float_to_z16_unorm(float z) { const float scale = 0xffff; - return (uint16_t)(z * scale); + return (uint16_t)(z * scale + 0.5f); } static INLINE float