Sorry, I pushed this patch accidentally. I will revert if needed. Marek
On Mon, Jul 11, 2011 at 3:04 AM, Marek Olšák <mar...@gmail.com> wrote: > Tested with the new piglit fbo-depthstencil test. > --- > src/mesa/main/pack.c | 21 ++++++++++++++++----- > src/mesa/main/pack.h | 4 ++-- > src/mesa/state_tracker/st_cb_readpixels.c | 2 +- > src/mesa/swrast/s_readpix.c | 2 +- > 4 files changed, 20 insertions(+), 9 deletions(-) > > diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c > index d42ae7b..7de1d05 100644 > --- a/src/mesa/main/pack.c > +++ b/src/mesa/main/pack.c > @@ -5056,10 +5056,11 @@ _mesa_pack_depth_span( struct gl_context *ctx, GLuint > n, GLvoid *dest, > > > /** > - * Pack depth and stencil values as GL_DEPTH_STENCIL/GL_UNSIGNED_INT_24_8. > + * Pack depth and stencil values as GL_DEPTH_STENCIL (GL_UNSIGNED_INT_24_8 > etc) > */ > void > -_mesa_pack_depth_stencil_span(struct gl_context *ctx, GLuint n, GLuint *dest, > +_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n, > + GLenum dstType, GLuint *dest, > const GLfloat *depthVals, > const GLstencil *stencilVals, > const struct gl_pixelstore_attrib *dstPacking) > @@ -5089,9 +5090,19 @@ _mesa_pack_depth_stencil_span(struct gl_context *ctx, > GLuint n, GLuint *dest, > stencilVals = stencilCopy; > } > > - for (i = 0; i < n; i++) { > - GLuint z = (GLuint) (depthVals[i] * 0xffffff); > - dest[i] = (z << 8) | (stencilVals[i] & 0xff); > + switch (dstType) { > + case GL_UNSIGNED_INT_24_8: > + for (i = 0; i < n; i++) { > + GLuint z = (GLuint) (depthVals[i] * 0xffffff); > + dest[i] = (z << 8) | (stencilVals[i] & 0xff); > + } > + break; > + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: > + for (i = 0; i < n; i++) { > + ((GLfloat*)dest)[i*2] = depthVals[i]; > + dest[i*2+1] = stencilVals[i] & 0xff; > + } > + break; > } > > if (dstPacking->SwapBytes) { > diff --git a/src/mesa/main/pack.h b/src/mesa/main/pack.h > index 78238ea..00aab40 100644 > --- a/src/mesa/main/pack.h > +++ b/src/mesa/main/pack.h > @@ -130,8 +130,8 @@ _mesa_pack_depth_span(struct gl_context *ctx, GLuint n, > GLvoid *dest, > > > extern void > -_mesa_pack_depth_stencil_span(struct gl_context *ctx, > - GLuint n, GLuint *dest, > +_mesa_pack_depth_stencil_span(struct gl_context *ctx,GLuint n, > + GLenum dstType, GLuint *dest, > const GLfloat *depthVals, > const GLstencil *stencilVals, > const struct gl_pixelstore_attrib *dstPacking); > diff --git a/src/mesa/state_tracker/st_cb_readpixels.c > b/src/mesa/state_tracker/st_cb_readpixels.c > index 02ddad7..e2b29fe 100644 > --- a/src/mesa/state_tracker/st_cb_readpixels.c > +++ b/src/mesa/state_tracker/st_cb_readpixels.c > @@ -177,7 +177,7 @@ st_read_stencil_pixels(struct gl_context *ctx, GLint x, > GLint y, > dest = _mesa_image_address2d(packing, pixels, width, height, > format, type, j, 0); > if (format == GL_DEPTH_STENCIL) { > - _mesa_pack_depth_stencil_span(ctx, width, dest, > + _mesa_pack_depth_stencil_span(ctx, width, type, dest, > zValues, sValues, packing); > } > else { > diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c > index 214f2ea..66ca392 100644 > --- a/src/mesa/swrast/s_readpix.c > +++ b/src/mesa/swrast/s_readpix.c > @@ -446,7 +446,7 @@ read_depth_stencil_pixels(struct gl_context *ctx, > GLfloat depthVals[MAX_WIDTH]; > _swrast_read_depth_span_float(ctx, depthRb, width, x, y + i, > depthVals); > - _mesa_pack_depth_stencil_span(ctx, width, depthStencilDst, > + _mesa_pack_depth_stencil_span(ctx, width, type, depthStencilDst, > depthVals, stencilVals, packing); > } > } > -- > 1.7.4.1 > > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev