s/Z24_S8/S8_Z24/ (stencil is in the high byte)

This commit is contained in:
Brian
2007-08-01 13:04:58 -06:00
parent fb206809ba
commit 5fd4606591
5 changed files with 36 additions and 33 deletions

View File

@@ -1147,7 +1147,7 @@ _mesa_soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
rb->StencilBits = 8; rb->StencilBits = 8;
if (!rb->surface) if (!rb->surface)
rb->surface = (struct pipe_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); pixelSize = sizeof(GLuint);
break; break;
case GL_COLOR_INDEX8_EXT: case GL_COLOR_INDEX8_EXT:

View File

@@ -145,7 +145,7 @@
#define PIPE_FORMAT_U_Z16 10 /**< ushort Z/depth */ #define PIPE_FORMAT_U_Z16 10 /**< ushort Z/depth */
#define PIPE_FORMAT_U_Z32 11 /**< uint Z/depth */ #define PIPE_FORMAT_U_Z32 11 /**< uint Z/depth */
#define PIPE_FORMAT_F_Z32 12 /**< float 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 */ #define PIPE_FORMAT_U_S8 14 /**< 8-bit stencil */

View File

@@ -105,7 +105,7 @@ softpipe_clear(struct pipe_context *pipe, GLboolean color, GLboolean depth,
case PIPE_FORMAT_U_Z32: case PIPE_FORMAT_U_Z32:
clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff); clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffffff);
break; break;
case PIPE_FORMAT_Z24_S8: case PIPE_FORMAT_S8_Z24:
clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff); clearVal = (GLuint) (softpipe->depth_test.clear * 0xffffff);
break; break;
default: default:

View File

@@ -59,7 +59,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
*/ */
if (sps->surface.format == PIPE_FORMAT_U_Z16) if (sps->surface.format == PIPE_FORMAT_U_Z16)
scale = 65535.0; 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); scale = (float) ((1 << 24) - 1);
else else
assert(0); /* XXX fix this someday */ assert(0); /* XXX fix this someday */

View File

@@ -215,66 +215,69 @@ z32_write_quad_z(struct softpipe_surface *sps,
} }
static void 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]) GLint x, GLint y, GLuint zzzz[QUAD_SIZE])
{ {
static const GLuint mask = 0x00ffffff;
const GLuint *src const GLuint *src
= (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; = (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[0] = src[0] & mask;
zzzz[1] = src[1] >> 8; zzzz[1] = src[1] & mask;
src += sps->surface.region->pitch; src += sps->surface.region->pitch;
zzzz[2] = src[0] >> 8; zzzz[2] = src[0] & mask;
zzzz[3] = src[1] >> 8; zzzz[3] = src[1] & mask;
} }
static void 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]) 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; 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); assert(zzzz[0] <= 0xffffff);
dst[0] = (dst[0] & 0xff) | (zzzz[0] << 8); dst[0] = (dst[0] & mask) | zzzz[0];
dst[1] = (dst[1] & 0xff) | (zzzz[1] << 8); dst[1] = (dst[1] & mask) | zzzz[1];
dst += sps->surface.region->pitch; dst += sps->surface.region->pitch;
dst[0] = (dst[0] & 0xff) | (zzzz[2] << 8); dst[0] = (dst[0] & mask) | zzzz[2];
dst[1] = (dst[1] & 0xff) | (zzzz[3] << 8); dst[1] = (dst[1] & mask) | zzzz[3];
} }
static void 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]) GLint x, GLint y, GLubyte ssss[QUAD_SIZE])
{ {
const GLuint *src const GLuint *src
= (GLuint *) sps->surface.region->map + y * sps->surface.region->pitch + x; = (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[0] = src[0] >> 24;
ssss[1] = src[1] & 0xff; ssss[1] = src[1] >> 24;
src += sps->surface.region->pitch; src += sps->surface.region->pitch;
ssss[2] = src[0] & 0xff; ssss[2] = src[0] >> 24;
ssss[3] = src[1] & 0xff; ssss[3] = src[1] >> 24;
} }
static void 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]) 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; 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[0] = (dst[0] & mask) | (ssss[0] << 24);
dst[1] = (dst[1] & 0xffffff00) | ssss[1]; dst[1] = (dst[1] & mask) | (ssss[1] << 24);
dst += sps->surface.region->pitch; dst += sps->surface.region->pitch;
dst[0] = (dst[0] & 0xffffff00) | ssss[2]; dst[0] = (dst[0] & mask) | (ssss[2] << 24);
dst[1] = (dst[1] & 0xffffff00) | ssss[3]; 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->read_quad_z = z32_read_quad_z;
sps->write_quad_z = z32_write_quad_z; sps->write_quad_z = z32_write_quad_z;
break; break;
case PIPE_FORMAT_Z24_S8: case PIPE_FORMAT_S8_Z24:
sps->read_quad_z = z24s8_read_quad_z; sps->read_quad_z = s8z24_read_quad_z;
sps->write_quad_z = z24s8_write_quad_z; sps->write_quad_z = s8z24_write_quad_z;
sps->read_quad_stencil = z24s8_read_quad_stencil; sps->read_quad_stencil = s8z24_read_quad_stencil;
sps->write_quad_stencil = z24s8_write_quad_stencil; sps->write_quad_stencil = s8z24_write_quad_stencil;
break; break;
case PIPE_FORMAT_U_S8: case PIPE_FORMAT_U_S8:
sps->read_quad_stencil = s8_read_quad_stencil; sps->read_quad_stencil = s8_read_quad_stencil;