summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/format_pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/format_pack.c')
-rw-r--r--src/mesa/main/format_pack.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
index e20e361c842..ff08ac56112 100644
--- a/src/mesa/main/format_pack.c
+++ b/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;
@@ -2533,13 +2541,12 @@ _mesa_pack_uint_24_8_depth_stencil_row(gl_format format, GLuint n,
case MESA_FORMAT_Z32_FLOAT_X24S8:
{
const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
- GLuint *destu = (GLuint *) dst;
- GLfloat *destf = (GLfloat *) dst;
+ struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
GLint i;
for (i = 0; i < n; i++) {
GLfloat z = (src[i] >> 8) * scale;
- destf[i * 2 + 0] = z;
- destu[i * 2 + 1] = src[i] & 0xff;
+ d[i].z = z;
+ d[i].x24s8 = src[i];
}
}
break;