summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@tungstengraphics.com>2008-06-11 14:51:41 +0100
committerAlan Hourihane <alanh@tungstengraphics.com>2008-06-11 14:51:41 +0100
commit4dd1917e4be3ae48b436ed333bd2fcd37603d1ed (patch)
treeed52815b129dffa18670e8d60232203f64375fed /src/gallium/auxiliary/util
parent4566b006f1a6bbdb96871e511e10e16f18bad23e (diff)
small optimization
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 655e2c8259..06abb34d5a 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -255,20 +255,28 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
static INLINE uint
util_pack_z(enum pipe_format format, double z)
{
+ if (z == 0.0)
+ return 0;
+
switch (format) {
case PIPE_FORMAT_Z16_UNORM:
+ if (z == 1.0)
+ return 0xffff;
return (uint) (z * 0xffff);
case PIPE_FORMAT_Z32_UNORM:
/* special-case to avoid overflow */
if (z == 1.0)
return 0xffffffff;
- else
- return (uint) (z * 0xffffffff);
+ return (uint) (z * 0xffffffff);
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
+ if (z == 1.0)
+ return 0xffffff;
return (uint) (z * 0xffffff);
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_Z24X8_UNORM:
+ if (z == 1.0)
+ return 0xffffff00;
return ((uint) (z * 0xffffff)) << 8;
default:
debug_print_format("gallium: unhandled format in util_pack_z()", format);