diff options
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format.c | 16 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format.h | 18 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 13 |
3 files changed, 36 insertions, 11 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c index 9ef3bb53f..6b602bf32 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.c +++ b/mesalib/src/gallium/auxiliary/util/u_format.c @@ -215,9 +215,8 @@ util_format_is_supported(enum pipe_format format, unsigned bind) * default MRD will be 1.0 / ((1 << 24) - 1). */ double -util_get_depth_format_mrd(enum pipe_format format) +util_get_depth_format_mrd(const struct util_format_description *desc) { - struct util_format_description *format_desc; /* * Depth buffer formats without a depth component OR scenarios * without a bound depth buffer default to D24. @@ -225,23 +224,20 @@ util_get_depth_format_mrd(enum pipe_format format) double mrd = 1.0 / ((1 << 24) - 1); unsigned depth_channel; - format_desc = (struct util_format_description *) - util_format_description(format); - - assert(format_desc); + assert(desc); /* * Some depth formats do not store the depth component in the first * channel, detect the format and adjust the depth channel. Get the * swizzled depth component channel. */ - depth_channel = format_desc->swizzle[0]; + depth_channel = desc->swizzle[0]; - if (format_desc->channel[depth_channel].type == UTIL_FORMAT_TYPE_UNSIGNED && - format_desc->channel[depth_channel].normalized) { + if (desc->channel[depth_channel].type == UTIL_FORMAT_TYPE_UNSIGNED && + desc->channel[depth_channel].normalized) { int depth_bits; - depth_bits = format_desc->channel[depth_channel].size; + depth_bits = desc->channel[depth_channel].size; mrd = 1.0 / ((1ULL << depth_bits) - 1); } diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h index 369c3994a..0fbaf4cc1 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.h +++ b/mesalib/src/gallium/auxiliary/util/u_format.h @@ -546,13 +546,29 @@ util_format_is_depth_and_stencil(enum pipe_format format) /** + * Calculates the depth format type based upon the incoming format description. + */ +static INLINE unsigned +util_get_depth_format_type(const struct util_format_description *desc) +{ + unsigned depth_channel = desc->swizzle[0]; + if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS && + depth_channel != UTIL_FORMAT_SWIZZLE_NONE) { + return desc->channel[depth_channel].type; + } else { + return UTIL_FORMAT_TYPE_VOID; + } +} + + +/** * Calculates the MRD for the depth format. MRD is used in depth bias * for UNORM and unbound depth buffers. When the depth buffer is floating * point, the depth bias calculation does not use the MRD. However, the * default MRD will be 1.0 / ((1 << 24) - 1). */ double -util_get_depth_format_mrd(enum pipe_format format); +util_get_depth_format_mrd(const struct util_format_description *desc); /** diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index f5c14ef8d..426d5daa7 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -246,6 +246,19 @@ union di { /** + * Extract the IEEE float32 exponent. + */ +static INLINE signed +util_get_float32_exponent(float x) { + union fi f; + + f.f = x; + + return ((f.ui >> 23) & 0xff) - 127; +} + + +/** * Fast version of 2^x * Identity: exp2(a + b) = exp2(a) * exp2(b) * Let ipart = int(x) |