mesa: add unpacking code for MESA_FORMAT_Z32_FLOAT_S8X24_UINT

Fixes glGetTexImage() when converting from MESA_FORMAT_Z32_FLOAT_S8X24_UINT
to GL_UNSIGNED_INT_24_8.  Hit by the piglit
ext_packed_depth_stencil-getteximage test.

Cc: "10.0" "10.1" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit a12d4d0398)
This commit is contained in:
Brian Paul 2014-02-28 07:55:04 -07:00 committed by Carl Worth
parent ef793cbf6d
commit fd5f0644af

View file

@ -4115,12 +4115,31 @@ unpack_uint_24_8_depth_stencil_S8_Z24(const GLuint *src, GLuint *dst, GLuint n)
}
}
static void
unpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint *src,
GLuint *dst, GLuint n)
{
GLuint i;
for (i = 0; i < n; i++) {
/* 8 bytes per pixel (float + uint32) */
GLfloat zf = ((GLfloat *) src)[i * 2 + 0];
GLuint z24 = (GLuint) (zf * (GLfloat) 0xffffff);
GLuint s = src[i * 2 + 1] & 0xff;
dst[i] = (z24 << 8) | s;
}
}
static void
unpack_uint_24_8_depth_stencil_Z24_S8(const GLuint *src, GLuint *dst, GLuint n)
{
memcpy(dst, src, n * 4);
}
/**
* Unpack depth/stencil returning as GL_UNSIGNED_INT_24_8.
* \param format the source data format
*/
void
_mesa_unpack_uint_24_8_depth_stencil_row(gl_format format, GLuint n,
const void *src, GLuint *dst)
@ -4132,6 +4151,9 @@ _mesa_unpack_uint_24_8_depth_stencil_row(gl_format format, GLuint n,
case MESA_FORMAT_S8_Z24:
unpack_uint_24_8_depth_stencil_S8_Z24(src, dst, n);
break;
case MESA_FORMAT_Z32_FLOAT_X24S8:
unpack_uint_24_8_depth_stencil_Z32_S8X24(src, dst, n);
break;
default:
_mesa_problem(NULL,
"bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",