[Mesa-dev] [PATCH 11/13] gallium/util: implement pack functions for Z32F and Z32F_S8X24

Marek Olšák maraeo at gmail.com
Thu Jun 30 17:29:43 PDT 2011


The suffix of 64 means it returns uint64_t.
---
 src/gallium/auxiliary/util/u_pack_color.h |   64 +++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 5378f2d..d2dfba5 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -458,6 +458,19 @@ util_pack_mask_z(enum pipe_format format, uint32_t z)
    }
 }
 
+
+static INLINE uint64_t
+util_pack_mask_z64(enum pipe_format format, uint32_t z)
+{
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      return z;
+   default:
+      return util_pack_mask_z(format, z);
+   }
+}
+
+
 static INLINE uint32_t
 util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s)
 {
@@ -481,6 +494,21 @@ util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s)
 }
 
 
+static INLINE uint64_t
+util_pack_mask_z_stencil64(enum pipe_format format, uint32_t z, uint8_t s)
+{
+   uint64_t packed;
+
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      packed = util_pack_mask_z64(format, z);
+      packed |= (uint64_t)s << 32ull;
+      return packed;
+   default:
+      return util_pack_mask_z_stencil(format, z, s);
+   }
+}
+
 
 /**
  * Note: it's assumed that z is in [0,1]
@@ -525,6 +553,24 @@ util_pack_z(enum pipe_format format, double z)
       return 0;
    }
 }
+
+
+static INLINE uint64_t
+util_pack_z64(enum pipe_format format, double z)
+{
+   union fi fui;
+
+   if (z == 0)
+      return 0;
+
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      fui.f = (float)z;
+      return fui.ui;
+   default:
+      return util_pack_z(format, z);
+   }
+}
  
 
 /**
@@ -554,6 +600,24 @@ util_pack_z_stencil(enum pipe_format format, double z, uint8_t s)
 }
 
 
+static INLINE uint64_t
+util_pack_z_stencil64(enum pipe_format format, double z, uint8_t s)
+{
+   uint64_t packed;
+
+   switch (format) {
+   case PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED:
+      packed = util_pack_z64(format, z);
+      packed |= (uint64_t)s << 32ull;
+      break;
+   default:
+      return util_pack_z_stencil(format, z, s);
+   }
+
+   return packed;
+}
+
+
 /**
  * Pack 4 ubytes into a 4-byte word
  */
-- 
1.7.4.1



More information about the mesa-dev mailing list