Replace "duplicate" formats
authorBrian <brian.paul@tungstengraphics.com>
Fri, 7 Dec 2007 23:15:14 +0000 (16:15 -0700)
committerBen Skeggs <skeggsb@gmail.com>
Sun, 9 Dec 2007 01:05:27 +0000 (12:05 +1100)
src/mesa/state_tracker/st_cb_clear.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_readpixels.c
src/mesa/state_tracker/st_format.c

index 8ac6699..1f0d1e6 100644 (file)
@@ -65,13 +65,13 @@ color_value(GLuint pipeFormat, const GLfloat color[4])
    UNCLAMPED_FLOAT_TO_UBYTE(a, color[3]);
 
    switch (pipeFormat) {
-   case PIPE_FORMAT_U_R8_G8_B8_A8:
+   case PIPE_FORMAT_R8G8B8A8_UNORM:
       return (r << 24) | (g << 16) | (b << 8) | a;
-   case PIPE_FORMAT_U_A8_R8_G8_B8:
+   case PIPE_FORMAT_A8R8G8B8_UNORM:
       return (a << 24) | (r << 16) | (g << 8) | b;
-   case PIPE_FORMAT_U_B8_G8_R8_A8:
+   case PIPE_FORMAT_B8G8R8A8_UNORM:
       return (b << 24) | (g << 16) | (r << 8) | a;
-   case PIPE_FORMAT_U_R5_G6_B5:
+   case PIPE_FORMAT_R5G6B5_UNORM:
       return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
    default:
       assert(0);
@@ -84,17 +84,17 @@ static uint
 depth_value(GLuint pipeFormat, GLfloat value)
 {
    switch (pipeFormat) {
-   case PIPE_FORMAT_U_Z16:
+   case PIPE_FORMAT_Z16_UNORM:
       return (uint) (value * 0xffff);
-   case PIPE_FORMAT_U_Z32:
+   case PIPE_FORMAT_Z32_UNORM:
       /* special-case to avoid overflow */
       if (value == 1.0)
          return 0xffffffff;
       else
          return (uint) (value * 0xffffffff);
-   case PIPE_FORMAT_S8_Z24:
+   case PIPE_FORMAT_S8Z24_UNORM:
       return (uint) (value * 0xffffff);
-   case PIPE_FORMAT_Z24_S8:
+   case PIPE_FORMAT_Z24S8_UNORM:
       return ((uint) (value * 0xffffff)) << 8;
    default:
       assert(0);
@@ -107,8 +107,8 @@ static GLboolean
 is_depth_stencil_format(GLuint pipeFormat)
 {
    switch (pipeFormat) {
-   case PIPE_FORMAT_S8_Z24:
-   case PIPE_FORMAT_Z24_S8:
+   case PIPE_FORMAT_S8Z24_UNORM:
+   case PIPE_FORMAT_Z24S8_UNORM:
       return GL_TRUE;
    default:
       return GL_FALSE;
@@ -523,10 +523,10 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
       GLuint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear);
 
       switch (strb->surface->format) {
-      case PIPE_FORMAT_S8_Z24:
+      case PIPE_FORMAT_S8Z24_UNORM:
          clearValue |= ctx->Stencil.Clear << 24;
          break;
-      case PIPE_FORMAT_Z24_S8:
+      case PIPE_FORMAT_Z24S8_UNORM:
          clearValue |= clearValue | ctx->Stencil.Clear;
          break;
       default:
index a61daff..464cf5c 100644 (file)
@@ -734,42 +734,42 @@ compatible_formats(GLenum format, GLenum type, GLuint pipeFormat)
    static const GLuint one = 1;
    GLubyte littleEndian = *((GLubyte *) &one);
 
-   if (pipeFormat == PIPE_FORMAT_U_R8_G8_B8_A8 &&
+   if (pipeFormat == PIPE_FORMAT_R8G8B8A8_UNORM &&
        format == GL_RGBA &&
        type == GL_UNSIGNED_BYTE &&
        !littleEndian) {
       return GL_TRUE;
    }
-   else if (pipeFormat == PIPE_FORMAT_U_R8_G8_B8_A8 &&
+   else if (pipeFormat == PIPE_FORMAT_R8G8B8A8_UNORM &&
             format == GL_ABGR_EXT &&
             type == GL_UNSIGNED_BYTE &&
             littleEndian) {
       return GL_TRUE;
    }
-   else if (pipeFormat == PIPE_FORMAT_U_A8_R8_G8_B8 &&
+   else if (pipeFormat == PIPE_FORMAT_A8R8G8B8_UNORM &&
             format == GL_BGRA &&
             type == GL_UNSIGNED_BYTE &&
             littleEndian) {
       return GL_TRUE;
    }
-   else if (pipeFormat == PIPE_FORMAT_U_R5_G6_B5 &&
+   else if (pipeFormat == PIPE_FORMAT_R5G6B5_UNORM &&
             format == GL_RGB &&
             type == GL_UNSIGNED_SHORT_5_6_5) {
       /* endian don't care */
       return GL_TRUE;
    }
-   else if (pipeFormat == PIPE_FORMAT_U_R5_G6_B5 &&
+   else if (pipeFormat == PIPE_FORMAT_R5G6B5_UNORM &&
             format == GL_BGR &&
             type == GL_UNSIGNED_SHORT_5_6_5_REV) {
       /* endian don't care */
       return GL_TRUE;
    }
-   else if (pipeFormat == PIPE_FORMAT_U_S8 &&
+   else if (pipeFormat == PIPE_FORMAT_S8_UNORM &&
             format == GL_STENCIL_INDEX &&
             type == GL_UNSIGNED_BYTE) {
       return GL_TRUE;
    }
-   else if (pipeFormat == PIPE_FORMAT_U_Z32 &&
+   else if (pipeFormat == PIPE_FORMAT_Z32_UNORM &&
             format == GL_DEPTH_COMPONENT &&
             type == GL_UNSIGNED_INT) {
       return GL_TRUE;
@@ -888,7 +888,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
                   memcpy(dest, values, spanWidth);
                }
                break;
-            case PIPE_FORMAT_S8_Z24:
+            case PIPE_FORMAT_S8Z24_UNORM:
                {
                   uint *dest = (uint *) stmap + spanY * ps->pitch + spanX;
                   GLint k;
@@ -998,8 +998,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
       cpp = 1;
       comp = 0;
    }
-   else if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) {
-      format = PIPE_FORMAT_U_A8_R8_G8_B8;
+   else if (pipe->is_format_supported( pipe, PIPE_FORMAT_A8R8G8B8_UNORM )) {
+      format = PIPE_FORMAT_A8R8G8B8_UNORM;
       internal_format = GL_RGBA8;
       cpp = 4;
       comp = 3; /* alpha channel */ /*XXX little-endian dependency */
@@ -1167,7 +1167,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
       src = buffer + i * width;
 
       switch (psDraw->format) {
-      case PIPE_FORMAT_S8_Z24:
+      case PIPE_FORMAT_S8Z24_UNORM:
          {
             uint *dst4 = (uint *) dst;
             int j;
index e2243e7..96829fc 100644 (file)
@@ -90,7 +90,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
             memcpy(values, src, width);
          }
          break;
-      case PIPE_FORMAT_S8_Z24:
+      case PIPE_FORMAT_S8Z24_UNORM:
          {
             const uint *src = (uint *) stmap + srcY * ps->pitch + x;
             GLint k;
@@ -99,7 +99,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
             }
          }
          break;
-      case PIPE_FORMAT_Z24_S8:
+      case PIPE_FORMAT_Z24S8_UNORM:
          {
             const uint *src = (uint *) stmap + srcY * ps->pitch + x;
             GLint k;
index f93f7f4..9e249a4 100644 (file)
@@ -120,7 +120,7 @@ st_get_format_info(
 #endif
 
       /* Data type */
-      if (format == PIPE_FORMAT_U_A1_R5_G5_B5 || format == PIPE_FORMAT_U_R5_G6_B5) {
+      if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) {
          pinfo->datatype = GL_UNSIGNED_SHORT;
       }
       else {
@@ -255,9 +255,9 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
       /* fix this */
    case MESA_FORMAT_ARGB8888_REV:
    case MESA_FORMAT_ARGB8888:
-      return PIPE_FORMAT_U_A8_R8_G8_B8;
+      return PIPE_FORMAT_A8R8G8B8_UNORM;
    case MESA_FORMAT_ARGB4444:
-      return PIPE_FORMAT_U_A4_R4_G4_B4;
+      return PIPE_FORMAT_A4R4G4B4_UNORM;
    case MESA_FORMAT_AL88:
       return PIPE_FORMAT_U_A8_L8;
    case MESA_FORMAT_A8:
@@ -267,7 +267,7 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
    case MESA_FORMAT_I8:
       return PIPE_FORMAT_U_I8;
    case MESA_FORMAT_Z16:
-      return PIPE_FORMAT_U_Z16;
+      return PIPE_FORMAT_Z16_UNORM;
    default:
       assert(0);
       return 0;
@@ -282,10 +282,10 @@ default_rgba_format(
    struct pipe_context *pipe )
 {
    static const uint colorFormats[] = {
-      PIPE_FORMAT_U_R8_G8_B8_A8,
-      PIPE_FORMAT_U_A8_R8_G8_B8,
-      PIPE_FORMAT_U_B8_G8_R8_A8,
-      PIPE_FORMAT_U_R5_G6_B5
+      PIPE_FORMAT_R8G8B8A8_UNORM,
+      PIPE_FORMAT_A8R8G8B8_UNORM,
+      PIPE_FORMAT_B8G8R8A8_UNORM,
+      PIPE_FORMAT_R5G6B5_UNORM
    };
    uint i;
    for (i = 0; i < Elements(colorFormats); i++) {
@@ -304,8 +304,8 @@ static GLuint
 default_deep_rgba_format(
    struct pipe_context *pipe )
 {
-   if (pipe->is_format_supported( pipe, PIPE_FORMAT_S_R16_G16_B16_A16 )) {
-      return PIPE_FORMAT_S_R16_G16_B16_A16;
+   if (pipe->is_format_supported( pipe, PIPE_FORMAT_R16G16B16A16_SNORM )) {
+      return PIPE_FORMAT_R16G16B16A16_SNORM;
    }
    return PIPE_FORMAT_NONE;
 }
@@ -319,10 +319,10 @@ default_depth_format(
    struct pipe_context *pipe )
 {
    static const uint zFormats[] = {
-      PIPE_FORMAT_U_Z16,
-      PIPE_FORMAT_U_Z32,
-      PIPE_FORMAT_S8_Z24,
-      PIPE_FORMAT_Z24_S8
+      PIPE_FORMAT_Z16_UNORM,
+      PIPE_FORMAT_Z32_UNORM,
+      PIPE_FORMAT_S8Z24_UNORM,
+      PIPE_FORMAT_Z24S8_UNORM
    };
    uint i;
    for (i = 0; i < Elements(zFormats); i++) {
@@ -358,16 +358,16 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_COMPRESSED_RGBA:
       if (format == GL_BGRA) {
          if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
-            if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 ))
-               return PIPE_FORMAT_U_A8_R8_G8_B8;
+            if (pipe->is_format_supported( pipe, PIPE_FORMAT_A8R8G8B8_UNORM ))
+               return PIPE_FORMAT_A8R8G8B8_UNORM;
          }
          else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
-            if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 ))
-               return PIPE_FORMAT_U_A4_R4_G4_B4;
+            if (pipe->is_format_supported( pipe, PIPE_FORMAT_A4R4G4B4_UNORM ))
+               return PIPE_FORMAT_A4R4G4B4_UNORM;
          }
          else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
-            if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 ))
-               return PIPE_FORMAT_U_A1_R5_G5_B5;
+            if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM ))
+               return PIPE_FORMAT_A1R5G5B5_UNORM;
          }
       }
       return default_rgba_format( pipe );
@@ -376,8 +376,8 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_RGB:
    case GL_COMPRESSED_RGB:
       if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
-         if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R5_G6_B5 ))
-            return PIPE_FORMAT_U_R5_G6_B5;
+         if (pipe->is_format_supported( pipe, PIPE_FORMAT_R5G6B5_UNORM ))
+            return PIPE_FORMAT_R5G6B5_UNORM;
       }
       return default_rgba_format( pipe );
 
@@ -390,13 +390,13 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
 
    case GL_RGBA4:
    case GL_RGBA2:
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 ))
-         return PIPE_FORMAT_U_A4_R4_G4_B4;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_A4R4G4B4_UNORM ))
+         return PIPE_FORMAT_A4R4G4B4_UNORM;
       return default_rgba_format( pipe );
 
    case GL_RGB5_A1:
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 ))
-         return PIPE_FORMAT_U_A1_R5_G5_B5;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM ))
+         return PIPE_FORMAT_A1R5G5B5_UNORM;
       return default_rgba_format( pipe );
 
    case GL_RGB8:
@@ -408,8 +408,8 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 ))
-         return PIPE_FORMAT_U_A1_R5_G5_B5;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM ))
+         return PIPE_FORMAT_A1R5G5B5_UNORM;
       return default_rgba_format( pipe );
 
    case GL_ALPHA:
@@ -491,18 +491,18 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
 #endif
 
    case GL_DEPTH_COMPONENT16:
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z16 ))
-         return PIPE_FORMAT_U_Z16;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z16_UNORM ))
+         return PIPE_FORMAT_Z16_UNORM;
       /* fall-through */
    case GL_DEPTH_COMPONENT24:
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 ))
-         return PIPE_FORMAT_S8_Z24;
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 ))
-         return PIPE_FORMAT_Z24_S8;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM ))
+         return PIPE_FORMAT_S8Z24_UNORM;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM ))
+         return PIPE_FORMAT_Z24S8_UNORM;
       /* fall-through */
    case GL_DEPTH_COMPONENT32:
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 ))
-         return PIPE_FORMAT_U_Z32;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z32_UNORM ))
+         return PIPE_FORMAT_Z32_UNORM;
       /* fall-through */
    case GL_DEPTH_COMPONENT:
       return default_depth_format( pipe );
@@ -514,18 +514,18 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
    case GL_STENCIL_INDEX16_EXT:
       if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_S8 ))
          return PIPE_FORMAT_U_S8;
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 ))
-         return PIPE_FORMAT_S8_Z24;
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 ))
-         return PIPE_FORMAT_Z24_S8;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM ))
+         return PIPE_FORMAT_S8Z24_UNORM;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM ))
+         return PIPE_FORMAT_Z24S8_UNORM;
       return PIPE_FORMAT_NONE;
 
    case GL_DEPTH_STENCIL_EXT:
    case GL_DEPTH24_STENCIL8_EXT:
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 ))
-         return PIPE_FORMAT_S8_Z24;
-      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24_S8 ))
-         return PIPE_FORMAT_Z24_S8;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM ))
+         return PIPE_FORMAT_S8Z24_UNORM;
+      if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM ))
+         return PIPE_FORMAT_Z24S8_UNORM;
       return PIPE_FORMAT_NONE;
 
    default: