summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2010-07-16 12:50:01 +0100
committerJosé Fonseca <[email protected]>2010-07-29 19:15:10 +0100
commita258701cd949d45041ed571ca08fedc40de2cf69 (patch)
tree1bb8a1d6276d826f1c587899bbebe63c5c7f9bc9
parentbdaa8be5b7dce396dd98f05e7ad66d48633cc4cb (diff)
util: add uint version of pack_z_stencil
Useful for packing mask values.
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 3ebef9fb749..5f113f742b1 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -425,6 +425,53 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color *
}
}
+/* Integer versions of util_pack_z and util_pack_z_stencil - useful for
+ * constructing clear masks.
+ */
+static INLINE uint
+util_pack_uint_z(enum pipe_format format, unsigned z)
+{
+ switch (format) {
+ case PIPE_FORMAT_Z16_UNORM:
+ return z & 0xffff;
+ case PIPE_FORMAT_Z32_UNORM:
+ case PIPE_FORMAT_Z32_FLOAT:
+ return z;
+ case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+ case PIPE_FORMAT_Z24X8_UNORM:
+ return z & 0xffffff;
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
+ return (z & 0xffffff) << 8;
+ case PIPE_FORMAT_S8_USCALED:
+ return 0;
+ default:
+ debug_print_format("gallium: unhandled format in util_pack_z()", format);
+ assert(0);
+ return 0;
+ }
+}
+
+static INLINE uint
+util_pack_uint_z_stencil(enum pipe_format format, double z, uint s)
+{
+ unsigned packed = util_pack_uint_z(format, z);
+
+ s &= 0xff;
+
+ switch (format) {
+ case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
+ return packed | (s << 24);
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ return packed | s;
+ case PIPE_FORMAT_S8_USCALED:
+ return packed | s;
+ default:
+ return packed;
+ }
+}
+
+
/**
* Note: it's assumed that z is in [0,1]