util/u_format: Round when converting depth values from float to z16_unorm.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 20 Dec 2012 12:03:45 +0000 (12:03 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 21 Dec 2012 10:04:51 +0000 (10:04 +0000)
This makes the z16_unorm -> float -> z16_unorm conversion lossless.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/util/u_format_zs.c

index 816ef14204c54a3c35c3b15ff9a0d7b1b28c2edb..ed45c52f9c973fc863cb3a355f0075a52a2d30c7 100644 (file)
@@ -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