s/Z24_S8/S8_Z24/ (stencil is in the high byte)
authorBrian <brian@i915.localnet.net>
Wed, 1 Aug 2007 19:04:58 +0000 (13:04 -0600)
committerBrian <brian@i915.localnet.net>
Wed, 1 Aug 2007 19:04:58 +0000 (13:04 -0600)
src/mesa/main/renderbuffer.c
src/mesa/pipe/p_defines.h
src/mesa/pipe/softpipe/sp_clear.c
src/mesa/pipe/softpipe/sp_quad_depth_test.c
src/mesa/pipe/softpipe/sp_surface.c

index 9509df315936c463a25913ab4ba21a2d895956df..d89704196af9486bd33a99c7279051fd67b6be6d 100644 (file)
@@ -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:
index 58f01758e326e0918c11ed480af32d7e3356a1b5..c92895342e602eeb4fa88ad307ca5c9583bd8fd3 100644 (file)
 #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 */
 
 
index 40b1156715a7bdde0555fafbdc60e4cf3605cccb..6266d124be0e1d04e524ff711c7fa5853196ae21 100644 (file)
@@ -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:
index a26bd51d84616838cf49dd0dbf824e63480ea3ca..3a8df33e6743f2295ec2e54f728938a31fe50b93 100644 (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)
       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 */
index cf89d28941eeabfd937c6b124ce996a24189e2b4..819243ae6e43ca7162afd40d40a2fc13aeb9a451 100644 (file)
@@ -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;