aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/format_pack.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-02-22 09:28:23 +0100
committermarha <marha@users.sourceforge.net>2012-02-22 09:28:23 +0100
commitecc59cb52ffe4a84fddae997bba64adad35d5e93 (patch)
tree233c2cf0ea65dcf0b671f28e14b1fb083dac87e3 /mesalib/src/mesa/main/format_pack.c
parentd19dd4c9cf37b7b691552c4f4dd873471e31ca68 (diff)
parent6baac61e6ca9cd314e689dfe7f84771aad08c66e (diff)
downloadvcxsrv-ecc59cb52ffe4a84fddae997bba64adad35d5e93.tar.gz
vcxsrv-ecc59cb52ffe4a84fddae997bba64adad35d5e93.tar.bz2
vcxsrv-ecc59cb52ffe4a84fddae997bba64adad35d5e93.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa/main/format_pack.c')
-rw-r--r--mesalib/src/mesa/main/format_pack.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
index ea1d95ee9..ff08ac561 100644
--- a/mesalib/src/mesa/main/format_pack.c
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -42,6 +42,14 @@
#include "../../gallium/auxiliary/util/u_format_r11g11b10f.h"
+/** Helper struct for MESA_FORMAT_Z32_FLOAT_X24S8 */
+struct z32f_x24s8
+{
+ float z;
+ uint32_t x24s8;
+};
+
+
typedef void (*pack_ubyte_rgba_row_func)(GLuint n,
const GLubyte src[][4], void *dst);
@@ -2372,10 +2380,10 @@ _mesa_pack_float_z_row(gl_format format, GLuint n,
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
- GLfloat *d = ((GLfloat *) dst);
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
GLuint i;
for (i = 0; i < n; i++) {
- d[i * 2] = src[i];
+ d[i].z = src[i];
}
}
break;
@@ -2445,13 +2453,13 @@ _mesa_pack_uint_z_row(gl_format format, GLuint n,
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
- GLfloat *d = ((GLfloat *) dst);
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
const GLdouble scale = 1.0 / (GLdouble) 0xffffffff;
GLuint i;
for (i = 0; i < n; i++) {
- d[i * 2] = src[i] * scale;
- assert(d[i * 2] >= 0.0f);
- assert(d[i * 2] <= 1.0f);
+ d[i].z = src[i] * scale;
+ assert(d[i].z >= 0.0f);
+ assert(d[i].z <= 1.0f);
}
}
break;
@@ -2495,10 +2503,10 @@ _mesa_pack_ubyte_stencil_row(gl_format format, GLuint n,
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
- GLuint *d = dst;
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
GLuint i;
for (i = 0; i < n; i++) {
- d[i * 2 + 1] = src[i];
+ d[i].x24s8 = src[i];
}
}
break;
@@ -2530,6 +2538,18 @@ _mesa_pack_uint_24_8_depth_stencil_row(gl_format format, GLuint n,
}
}
break;
+ case MESA_FORMAT_Z32_FLOAT_X24S8:
+ {
+ const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
+ GLint i;
+ for (i = 0; i < n; i++) {
+ GLfloat z = (src[i] >> 8) * scale;
+ d[i].z = z;
+ d[i].x24s8 = src[i];
+ }
+ }
+ break;
default:
_mesa_problem(NULL, "bad format %s in _mesa_pack_ubyte_s_row",
_mesa_get_format_name(format));