aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-11-08 13:12:15 +0100
committermarha <marha@users.sourceforge.net>2013-11-08 13:12:15 +0100
commitf707ea3ce065f0ce40f586c40283fab42059b485 (patch)
tree055a5ccdecaec105365d1de9a90d7d6b38f257fb /mesalib/src/gallium/auxiliary/util
parentc8483dc2831dc37d93a36804022f6b064f5962ea (diff)
parent09e94a8e392e8fe6fd89ddefbf3897a92e525b5b (diff)
downloadvcxsrv-f707ea3ce065f0ce40f586c40283fab42059b485.tar.gz
vcxsrv-f707ea3ce065f0ce40f586c40283fab42059b485.tar.bz2
vcxsrv-f707ea3ce065f0ce40f586c40283fab42059b485.zip
Merge remote-tracking branch 'origin/released'
* origin/released: Added presentproto-1.0 libxtrans libxcb xcb-proto mesa git update 8 nov 2013 Conflicts: X11/xtrans/Xtransint.h X11/xtrans/Xtranssock.c libxcb/src/.gitignore mesalib/src/mesa/drivers/dri/common/dri_util.c
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.c16
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h18
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h13
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)