Mesa (8.0): mesa: Add unpack_uint_z_row support for floating-point depth buffers
Ian Romanick
idr at kemper.freedesktop.org
Thu Feb 2 18:51:57 UTC 2012
Module: Mesa
Branch: 8.0
Commit: 9da7b58b39658f9d42777a4cb387bb668b28d491
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9da7b58b39658f9d42777a4cb387bb668b28d491
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Wed Jan 18 11:56:12 2012 -0800
mesa: Add unpack_uint_z_row support for floating-point depth buffers
This is a hack, and it will result in incorrect rendering. However,
it does eliminate spurious warnings in several piglit CopyPixels tests
that involve floating-point depth buffers.
The real solution is to add a zf field to SWspan to store float Z
values. When a float depth buffer is involved, swrast should also
populate the zf field. I'll consider this post-8.0 work.
NOTE: This is a candidate for the 8.0 branch.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
(cherry picked from commit af1477b088448aeca762f515410c80054cb225b9)
---
src/mesa/main/format_unpack.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index ff98c69..be39873 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -2537,6 +2537,32 @@ unpack_uint_z_Z32(const void *src, GLuint *dst, GLuint n)
memcpy(dst, src, n * sizeof(GLuint));
}
+static void
+unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n)
+{
+ const float *s = (const float *)src;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = FLOAT_TO_UINT(IROUND(CLAMP((s[i]), 0.0F, 1.0F)));
+ }
+}
+
+static void
+unpack_uint_z_Z32_FLOAT_X24S8(const void *src, GLuint *dst, GLuint n)
+{
+ struct z32f_x24s8 {
+ float z;
+ uint32_t x24s8;
+ };
+
+ const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
+ GLuint i;
+
+ for (i = 0; i < n; i++) {
+ dst[i] = FLOAT_TO_UINT(IROUND(CLAMP((s[i].z), 0.0F, 1.0F)));
+ }
+}
+
/**
* Unpack Z values.
@@ -2564,6 +2590,12 @@ _mesa_unpack_uint_z_row(gl_format format, GLuint n,
case MESA_FORMAT_Z32:
unpack = unpack_uint_z_Z32;
break;
+ case MESA_FORMAT_Z32_FLOAT:
+ unpack = unpack_uint_z_Z32_FLOAT;
+ break;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ unpack = unpack_uint_z_Z32_FLOAT_X24S8;
+ break;
default:
_mesa_problem(NULL, "bad format %s in _mesa_unpack_uint_z_row",
_mesa_get_format_name(format));
More information about the mesa-commit
mailing list