From 5fd46065915d3958569ebb590104b69886352157 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 1 Aug 2007 13:04:58 -0600 Subject: s/Z24_S8/S8_Z24/ (stencil is in the high byte) --- src/mesa/main/renderbuffer.c | 2 +- src/mesa/pipe/p_defines.h | 2 +- src/mesa/pipe/softpipe/sp_clear.c | 2 +- src/mesa/pipe/softpipe/sp_quad_depth_test.c | 2 +- src/mesa/pipe/softpipe/sp_surface.c | 61 +++++++++++++++-------------- 5 files changed, 36 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c index 9509df3159..d89704196a 100644 --- a/src/mesa/main/renderbuffer.c +++ b/src/mesa/main/renderbuffer.c @@ -1147,7 +1147,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->StencilBits = 8; if (!rb->surface) rb->surface = (struct pipe_surface *) - pipe->surface_alloc(pipe, PIPE_FORMAT_Z24_S8); + pipe->surface_alloc(pipe, PIPE_FORMAT_S8_Z24); pixelSize = sizeof(GLuint); break; case GL_COLOR_INDEX8_EXT: diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h index 58f01758e3..c92895342e 100644 --- a/src/mesa/pipe/p_defines.h +++ b/src/mesa/pipe/p_defines.h @@ -145,7 +145,7 @@ #define PIPE_FORMAT_U_Z16 10 /**< ushort Z/depth */ #define PIPE_FORMAT_U_Z32 11 /**< uint Z/depth */ #define PIPE_FORMAT_F_Z32 12 /**< float Z/depth */ -#define PIPE_FORMAT_Z24_S8 13 /**< 24-bit Z + 8-bit stencil */ +#define PIPE_FORMAT_S8_Z24 13 /**< 8-bit stencil + 24-bit Z */ #define PIPE_FORMAT_U_S8 14 /**< 8-bit stencil */ diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c index 40b1156715..6266d124be 100644 --- a/src/mesa/pipe/softpipe/sp_clear.c +++ b/src/mesa/pipe/softpipe/sp_clear.c @@ -105,7 +105,7 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth, case PIPE_FORMAT_U_Z32: clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff); break; - case PIPE_FORMAT_Z24_S8: + case PIPE_FORMAT_S8_Z24: clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); break; default: diff --git a/src/mesa/pipe/softpipe/sp_quad_depth_test.c b/src/mesa/pipe/softpipe/sp_quad_depth_test.c index a26bd51d84..3a8df33e67 100644 --- a/src/mesa/pipe/softpipe/sp_quad_depth_test.c +++ b/src/mesa/pipe/softpipe/sp_quad_depth_test.c @@ -59,7 +59,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad) */ if (sps->surface.format == PIPE_FORMAT_U_Z16) scale = 65535.0; - else if (sps->surface.format == PIPE_FORMAT_Z24_S8) + else if (sps->surface.format == PIPE_FORMAT_S8_Z24) scale = (float) ((1 << 24) - 1); else assert(0); /* XXX fix this someday */ diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c index cf89d28941..819243ae6e 100644 --- a/src/mesa/pipe/softpipe/sp_surface.c +++ b/src/mesa/pipe/softpipe/sp_surface.c @@ -215,66 +215,69 @@ z32_write_quad_z(struct softpipe_surface *sps, } static void -z24s8_read_quad_z(struct softpipe_surface *sps, +s8z24_read_quad_z(struct softpipe_surface *sps, GLint x, GLint y, GLuint zzzz[QUAD_SIZE]) { + static const GLuint mask = 0x00ffffff; const GLuint *src = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); - zzzz[0] = src[0] >> 8; - zzzz[1] = src[1] >> 8; + zzzz[0] = src[0] & mask; + zzzz[1] = src[1] & mask; src += sps->surface.region->pitch; - zzzz[2] = src[0] >> 8; - zzzz[3] = src[1] >> 8; + zzzz[2] = src[0] & mask; + zzzz[3] = src[1] & mask; } static void -z24s8_write_quad_z(struct softpipe_surface *sps, +s8z24_write_quad_z(struct softpipe_surface *sps, GLint x, GLint y, const GLuint zzzz[QUAD_SIZE]) { + static const GLuint mask = 0xff000000; GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); assert(zzzz[0] <= 0xffffff); - dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); - dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); + dst[0] = (dst[0] & mask) | zzzz[0]; + dst[1] = (dst[1] & mask) | zzzz[1]; dst += sps->surface.region->pitch; - dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); - dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); + dst[0] = (dst[0] & mask) | zzzz[2]; + dst[1] = (dst[1] & mask) | zzzz[3]; } static void -z24s8_read_quad_stencil(struct softpipe_surface *sps, +s8z24_read_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, GLubyte ssss[QUAD_SIZE]) { const GLuint *src = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); - ssss[0] = src[0] & 0xff; - ssss[1] = src[1] & 0xff; + ssss[0] = src[0] >> 24; + ssss[1] = src[1] >> 24; src += sps->surface.region->pitch; - ssss[2] = src[0] & 0xff; - ssss[3] = src[1] & 0xff; + ssss[2] = src[0] >> 24; + ssss[3] = src[1] >> 24; } static void -z24s8_write_quad_stencil(struct softpipe_surface *sps, +s8z24_write_quad_stencil(struct softpipe_surface *sps, GLint x, GLint y, const GLubyte ssss[QUAD_SIZE]) { + static const GLuint mask = 0x00ffffff; GLuint *dst = (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; - assert(sps->surface.format == PIPE_FORMAT_Z24_S8); + assert(sps->surface.format == PIPE_FORMAT_S8_Z24); - dst[0] = (dst[0] & 0xffffff00) | ssss[0]; - dst[1] = (dst[1] & 0xffffff00) | ssss[1]; + dst[0] = (dst[0] & mask) | (ssss[0] << 24); + dst[1] = (dst[1] & mask) | (ssss[1] << 24); dst += sps->surface.region->pitch; - dst[0] = (dst[0] & 0xffffff00) | ssss[2]; - dst[1] = (dst[1] & 0xffffff00) | ssss[3]; + dst[0] = (dst[0] & mask) | (ssss[2] << 24); + dst[1] = (dst[1] & mask) | (ssss[3] << 24); } @@ -324,11 +327,11 @@ init_quad_funcs(struct softpipe_surface *sps) sps->read_quad_z = z32_read_quad_z; sps->write_quad_z = z32_write_quad_z; break; - case PIPE_FORMAT_Z24_S8: - sps->read_quad_z = z24s8_read_quad_z; - sps->write_quad_z = z24s8_write_quad_z; - sps->read_quad_stencil = z24s8_read_quad_stencil; - sps->write_quad_stencil = z24s8_write_quad_stencil; + case PIPE_FORMAT_S8_Z24: + sps->read_quad_z = s8z24_read_quad_z; + sps->write_quad_z = s8z24_write_quad_z; + sps->read_quad_stencil = s8z24_read_quad_stencil; + sps->write_quad_stencil = s8z24_write_quad_stencil; break; case PIPE_FORMAT_U_S8: sps->read_quad_stencil = s8_read_quad_stencil; -- cgit v1.2.3