Re: [Mesa-dev] [PATCH] mesa: Add unpack_uint_z_row support for floating-point depth buffers
On 1 February 2012 23:12, Brian Paul bri...@vmware.com wrote: +static void +unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n) +{ + const float *s = ((const float *)src); More parens than necessary there. The entire cast is unnecessary, IMO. But of course that would apply to the other functions in that file as well. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa: Add unpack_uint_z_row support for floating-point depth buffers
On 02/02/2012 06:41 AM, Henri Verbeet wrote: On 1 February 2012 23:12, Brian Paulbri...@vmware.com wrote: +static void +unpack_uint_z_Z32_FLOAT(const void *src, GLuint *dst, GLuint n) +{ + const float *s = ((const float *)src); More parens than necessary there. The entire cast is unnecessary, IMO. But of course that would apply to the other functions in that file as well. Right. This was a copy-and-paste of another Z32_FLOAT function. I'm not too worried about the cosmetics of this code. I'm planning to convert a bunch of these mechanical things over to generated code for 8.1. Each copy-and-paste bug that I find (see my recent patches) reinforces my desire to do that conversion. :) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa: Add unpack_uint_z_row support for floating-point depth buffers
From: Ian Romanick ian.d.roman...@intel.com 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. Signed-off-by: Ian Romanick ian.d.roman...@intel.com --- 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 cd16a9e..b45dde2 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -2916,6 +2916,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. @@ -2943,6 +2969,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)); -- 1.7.6.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa: Add unpack_uint_z_row support for floating-point depth buffers
On 02/01/2012 02:38 PM, Ian Romanick wrote: From: Ian Romanickian.d.roman...@intel.com 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. Signed-off-by: Ian Romanickian.d.roman...@intel.com --- 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 cd16a9e..b45dde2 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -2916,6 +2916,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); More parens than necessary there. + 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. @@ -2943,6 +2969,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)); Reviewed-by: Brian Paul bri...@vmware.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev