[Mesa-dev] [PATCH 2/4] mesa: add ATI_texture_compression_3dc

Marek Olšák maraeo at gmail.com
Sun Mar 6 19:28:07 PST 2011


LUMINANCE_ALPHA_LATC2 = LUMINANCE_ALPHA_3DC, so this is easy.

Note that there is no specification for 3DC, just a few white papers
from ATI.
---
 src/mesa/main/extensions.c  |    2 ++
 src/mesa/main/glheader.h    |    4 ++++
 src/mesa/main/image.c       |    3 +++
 src/mesa/main/mtypes.h      |    1 +
 src/mesa/main/texcompress.c |    1 +
 src/mesa/main/texformat.c   |   10 ++++++++++
 src/mesa/main/teximage.c    |    9 +++++++++
 7 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 519e94f..68740e2 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -259,6 +259,7 @@ static const struct extension extension_table[] = {
    { "GL_ATI_envmap_bumpmap",                      o(ATI_envmap_bumpmap),                      GL             },
    { "GL_ATI_fragment_shader",                     o(ATI_fragment_shader),                     GL             },
    { "GL_ATI_separate_stencil",                    o(ATI_separate_stencil),                    GL             },
+   { "GL_ATI_texture_compression_3dc",             o(ATI_texture_compression_3dc),             GL             },
    { "GL_ATI_texture_env_combine3",                o(ATI_texture_env_combine3),                GL             },
    { "GL_ATI_texture_mirror_once",                 o(ATI_texture_mirror_once),                 GL             },
    { "GL_IBM_multimode_draw_arrays",               o(IBM_multimode_draw_arrays),               GL             },
@@ -449,6 +450,7 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)
 #if FEATURE_ATI_fragment_shader
    ctx->Extensions.ATI_fragment_shader = GL_TRUE;
 #endif
+   ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE;
    ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
    ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
    ctx->Extensions.ATI_separate_stencil = GL_TRUE;
diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
index 08ad5f3..0df8119 100644
--- a/src/mesa/main/glheader.h
+++ b/src/mesa/main/glheader.h
@@ -121,6 +121,10 @@ typedef void *GLeglImageOES;
 #define GL_MAX_FRAGMENT_UNIFORM_VECTORS     0x8DFD
 #endif
 
+#ifndef GL_ATI_texture_compression_3dc
+#define GL_ATI_texture_compression_3dc 1
+#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837
+#endif
 
 
 /**
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 18abf28..bbde380 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -747,6 +747,7 @@ _mesa_is_color_format(GLenum format)
       case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
       case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
       case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+      case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
       /* signed, normalized texture formats */
       case GL_RGBA_SNORM:
       case GL_RGBA8_SNORM:
@@ -1034,6 +1035,8 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
    case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
    case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
       return ctx->Extensions.EXT_texture_compression_latc;
+   case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+      return ctx->Extensions.ATI_texture_compression_3dc;
    default:
       return GL_FALSE;
    }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 71d8e1d..1ce1120 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2826,6 +2826,7 @@ struct gl_extensions
    GLboolean APPLE_vertex_array_object;
    GLboolean APPLE_object_purgeable;
    GLboolean ATI_envmap_bumpmap;
+   GLboolean ATI_texture_compression_3dc;
    GLboolean ATI_texture_mirror_once;
    GLboolean ATI_texture_env_combine3;
    GLboolean ATI_fragment_shader;
diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 942d996..d820ae9 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -178,6 +178,7 @@ _mesa_glenum_to_compressed_format(GLenum format)
    case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
       return MESA_FORMAT_SIGNED_L_LATC1;
    case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+   case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
       return MESA_FORMAT_LA_LATC2;
    case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
       return MESA_FORMAT_SIGNED_LA_LATC2;
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 521b9a0..5eabf2a 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -640,6 +640,16 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
       }
    }
 
+   if (ctx->Extensions.ATI_texture_compression_3dc) {
+      switch (internalFormat) {
+         case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+            RETURN_IF_SUPPORTED(MESA_FORMAT_LA_LATC2);
+            break;
+         default:
+            ; /* fallthrough */
+      }
+   }
+
    _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
    return MESA_FORMAT_NONE;
 }
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 6ec6610..2a3037f 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -522,6 +522,15 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
       }
    }
 
+   if (ctx->Extensions.ATI_texture_compression_3dc) {
+      switch (internalFormat) {
+      case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+         return GL_LUMINANCE_ALPHA;
+      default:
+         ; /* fallthrough */
+      }
+   }
+
    return -1; /* error */
 }
 
-- 
1.7.1



More information about the mesa-dev mailing list