From ba14b043bc1ab87e8e5e46e6e909a8def9535028 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Sat, 4 Apr 2009 16:04:59 +0200 Subject: gallium: Add utility helper for packing combined depth/stencil values. --- src/gallium/auxiliary/util/u_pack_color.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/gallium/auxiliary') diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index e0e8aa8e9f..e05d032253 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -440,6 +440,26 @@ util_pack_z(enum pipe_format format, double z) return 0; } } + + +/** + * Note: it's assumed that z is in [0,1] and s in [0,255] + */ +static INLINE uint +util_pack_z_stencil(enum pipe_format format, double z, uint s) +{ + switch (format) { + case PIPE_FORMAT_S8Z24_UNORM: + return util_pack_z(format, z) | s << 24; + case PIPE_FORMAT_Z24S8_UNORM: + return util_pack_z(format, z) | s; + default: + debug_print_format("gallium: unhandled format in util_pack_z_stencil()", + format); + assert(0); + return 0; + } +} /** -- cgit v1.2.3