mesa: Support Z24S8 wherever S8Z24 is supported.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 27 Mar 2009 19:50:15 +0000 (19:50 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 27 Mar 2009 19:51:33 +0000 (19:51 +0000)
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_readpixels.c

index 821ea67ce463ad0a21886d660830eda2b8b2c1fa..f9f139ff0737c948ec9e6aacae3a281345d1a533 100644 (file)
@@ -686,6 +686,17 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
                   }
                }
                break;
+            case PIPE_FORMAT_Z24S8_UNORM:
+               {
+                  uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
+                  GLint k;
+                  for (k = 0; k < spanWidth; k++) {
+                     uint p = dest[k];
+                     p = (p & 0xffffff00) | (values[k] & 0xff);
+                     dest[k] = p;
+                  }
+               }
+               break;
             default:
                assert(0);
             }
@@ -821,6 +832,16 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
             }
          }
          break;
+      case PIPE_FORMAT_Z24S8_UNORM:
+         {
+            uint *dst4 = (uint *) dst;
+            int j;
+            for (j = 0; j < width; j++) {
+               *dst4 = (*dst4 & 0xffffff00) | (src[j] & 0xff);
+               dst4++;
+            }
+         }
+         break;
       case PIPE_FORMAT_S8_UNORM:
          memcpy(dst, src, width);
          break;
index 2a4beccd90e3c7c40b9fe91f665df993879d4e4b..ce7a8cda4e86e7167b4149c89c190c740f90011d 100644 (file)
@@ -420,6 +420,33 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
             }
          }
       }
+      else if (trans->format == PIPE_FORMAT_Z24S8_UNORM ||
+               trans->format == PIPE_FORMAT_Z24X8_UNORM) {
+         if (format == GL_DEPTH_COMPONENT) {
+            for (i = 0; i < height; i++) {
+               GLuint ztemp[MAX_WIDTH];
+               GLfloat zfloat[MAX_WIDTH];
+               const double scale = 1.0 / ((1 << 24) - 1);
+               pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0);
+               y += yStep;
+               for (j = 0; j < width; j++) {
+                  zfloat[j] = (float) (scale * ((ztemp[j] >> 8) & 0xffffff));
+               }
+               _mesa_pack_depth_span(ctx, width, dst, type,
+                                     zfloat, &clippedPacking);
+               dst += dstStride;
+            }
+         }
+         else {
+            /* untested, but simple: */
+            assert(format == GL_DEPTH_STENCIL_EXT);
+            for (i = 0; i < height; i++) {
+               pipe_get_tile_raw(trans, 0, y, width, 1, dst, 0);
+               y += yStep;
+               dst += dstStride;
+            }
+         }
+      }
       else if (trans->format == PIPE_FORMAT_Z16_UNORM) {
          for (i = 0; i < height; i++) {
             GLushort ztemp[MAX_WIDTH];