[Mesa-dev] [PATCH 01/13] mesa: Add new MESA_FORMATs for ETC2 compressed textures

Ian Romanick idr at freedesktop.org
Thu Dec 6 17:48:17 PST 2012


From: Anuj Phogat <anuj.phogat at gmail.com>

It is required by OpenGL ES 3.0 to support ETC2 textures.
This patch adds new MESA_FORMATs for following etc2 texture
formats:
 GL_COMPRESSED_RGB8_ETC2
 GL_COMPRESSED_SRGB8_ETC2
 GL_COMPRESSED_RGBA8_ETC2_EAC
 GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
 GL_COMPRESSED_R11_EAC
 GL_COMPRESSED_RG11_EAC
 GL_COMPRESSED_SIGNED_R11_EAC
 GL_COMPRESSED_SIGNED_RG11_EAC
 MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
 MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1

Above formats are currently available in only gles 3.0.

v2: Add entries in texfetch_funcs[] array.

Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
Reviewed-by: Brian Paul <brianp at vmware.com>

v3 (Paul Berry <stereotype441 at gmail.com>): comment out symbols that
are not implemented yet, so that this commit compiles on its own;
future commits will uncomment the symbols as they become available.
---
 src/mesa/main/format_unpack.c |  75 +++++++++++++++++++++++-
 src/mesa/main/formats.c       | 133 ++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/formats.h       |  10 ++++
 src/mesa/main/glformats.c     |  21 +++++++
 src/mesa/main/texcompress.c   | 100 +++++++++++++++++++++++++++++++
 src/mesa/main/texformat.c     |  37 ++++++++++++
 src/mesa/main/teximage.c      |  21 +++++++
 src/mesa/main/texstore.c      |  12 ++++
 src/mesa/swrast/s_texfetch.c  |  60 +++++++++++++++++++
 9 files changed, 468 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 04fd1d6..7bbdebb 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1337,6 +1337,68 @@ unpack_ETC1_RGB8(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
+unpack_ETC2_RGB8(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_SRGB8(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_RGBA8_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_SRGB8_ALPHA8_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_R11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_RG11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_SIGNED_R11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_SIGNED_RG11_EAC(const void *src, GLfloat dst[][4], GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src, GLfloat dst[][4],
+                                      GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
+unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1(const void *src, GLfloat dst[][4],
+                                      GLuint n)
+{
+   /* XXX to do */
+}
+
+static void
 unpack_SIGNED_A8(const void *src, GLfloat dst[][4], GLuint n)
 {
    const GLbyte *s = ((const GLbyte *) src);
@@ -1585,7 +1647,18 @@ get_unpack_rgba_function(gl_format format)
       table[MESA_FORMAT_SIGNED_LA_LATC2] = unpack_SIGNED_LA_LATC2;
 
       table[MESA_FORMAT_ETC1_RGB8] = unpack_ETC1_RGB8;
-
+      table[MESA_FORMAT_ETC2_RGB8] = unpack_ETC2_RGB8;
+      table[MESA_FORMAT_ETC2_SRGB8] = unpack_ETC2_SRGB8;
+      table[MESA_FORMAT_ETC2_RGBA8_EAC] = unpack_ETC2_RGBA8_EAC;
+      table[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = unpack_ETC2_SRGB8_ALPHA8_EAC;
+      table[MESA_FORMAT_ETC2_R11_EAC] = unpack_ETC2_R11_EAC;
+      table[MESA_FORMAT_ETC2_RG11_EAC] = unpack_ETC2_RG11_EAC;
+      table[MESA_FORMAT_ETC2_SIGNED_R11_EAC] = unpack_ETC2_SIGNED_R11_EAC;
+      table[MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = unpack_ETC2_SIGNED_RG11_EAC;
+      table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
+         unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
+      table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
+         unpack_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
       table[MESA_FORMAT_SIGNED_A8] = unpack_SIGNED_A8;
       table[MESA_FORMAT_SIGNED_L8] = unpack_SIGNED_L8;
       table[MESA_FORMAT_SIGNED_AL88] = unpack_SIGNED_AL88;
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index df23af1..47a1d68 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1398,6 +1398,106 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       4, 4, 8                     /* 8 bytes per 4x4 block */
    },
 
+   {
+      MESA_FORMAT_ETC2_RGB8,
+      "MESA_FORMAT_ETC2_RGB8",
+      GL_RGB,
+      GL_UNSIGNED_NORMALIZED,
+      8, 8, 8, 0,
+      0, 0, 0, 0, 0,
+      4, 4, 8                     /* 8 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_SRGB8,
+      "MESA_FORMAT_ETC2_SRGB8",
+      GL_RGB,
+      GL_UNSIGNED_NORMALIZED,
+      8, 8, 8, 0,
+      0, 0, 0, 0, 0,
+      4, 4, 8                     /* 8 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_RGBA8_EAC,
+      "MESA_FORMAT_ETC2_RGBA8_EAC",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      8, 8, 8, 8,
+      0, 0, 0, 0, 0,
+      4, 4, 16                    /* 16 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
+      "MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      8, 8, 8, 8,
+      0, 0, 0, 0, 0,
+      4, 4, 16                    /* 16 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_R11_EAC,
+      "MESA_FORMAT_ETC2_R11_EAC",
+      GL_RED,
+      GL_UNSIGNED_NORMALIZED,
+      11, 0, 0, 0,
+      0, 0, 0, 0, 0,
+      4, 4, 8                    /* 8 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_RG11_EAC,
+      "MESA_FORMAT_ETC2_RG11_EAC",
+      GL_RG,
+      GL_UNSIGNED_NORMALIZED,
+      11, 11, 0, 0,
+      0, 0, 0, 0, 0,
+      4, 4, 16                    /* 16 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+      "MESA_FORMAT_ETC2_SIGNED_R11_EAC",
+      GL_RED,
+      GL_SIGNED_NORMALIZED,
+      11, 0, 0, 0,
+      0, 0, 0, 0, 0,
+      4, 4, 8                    /* 8 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
+      "MESA_FORMAT_ETC2_SIGNED_RG11_EAC",
+      GL_RG,
+      GL_SIGNED_NORMALIZED,
+      11, 11, 0, 0,
+      0, 0, 0, 0, 0,
+      4, 4, 16                    /* 16 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
+      "MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      8, 8, 8, 1,
+      0, 0, 0, 0, 0,
+      4, 4, 8                     /* 8 bytes per 4x4 block */
+   },
+
+   {
+      MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
+      "MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1",
+      GL_RGBA,
+      GL_UNSIGNED_NORMALIZED,
+      8, 8, 8, 1,
+      0, 0, 0, 0, 0,
+      4, 4, 8                     /* 8 bytes per 4x4 block */
+   },
+
    /* Signed formats from EXT_texture_snorm that are not in GL3.1 */
    {
       MESA_FORMAT_SIGNED_A8,
@@ -1840,7 +1940,20 @@ _mesa_get_uncompressed_format(gl_format format)
    case MESA_FORMAT_SIGNED_LA_LATC2:
       return MESA_FORMAT_SIGNED_AL88;
    case MESA_FORMAT_ETC1_RGB8:
+   case MESA_FORMAT_ETC2_RGB8:
+   case MESA_FORMAT_ETC2_SRGB8:
       return MESA_FORMAT_RGB888;
+   case MESA_FORMAT_ETC2_RGBA8_EAC:
+   case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+   case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+   case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+      return MESA_FORMAT_RGBA8888;
+   case MESA_FORMAT_ETC2_R11_EAC:
+   case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+      return MESA_FORMAT_R16;
+   case MESA_FORMAT_ETC2_RG11_EAC:
+   case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+      return MESA_FORMAT_RG1616;
    default:
 #ifdef DEBUG
       assert(!_mesa_is_format_compressed(format));
@@ -2282,6 +2395,16 @@ _mesa_format_to_type_and_comps(gl_format format,
    case MESA_FORMAT_LA_LATC2:
    case MESA_FORMAT_SIGNED_LA_LATC2:
    case MESA_FORMAT_ETC1_RGB8:
+   case MESA_FORMAT_ETC2_RGB8:
+   case MESA_FORMAT_ETC2_SRGB8:
+   case MESA_FORMAT_ETC2_RGBA8_EAC:
+   case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+   case MESA_FORMAT_ETC2_R11_EAC:
+   case MESA_FORMAT_ETC2_RG11_EAC:
+   case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+   case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+   case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+   case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
       /* XXX generate error instead? */
       *datatype = GL_UNSIGNED_BYTE;
       *comps = 0;
@@ -2912,6 +3035,16 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
       return GL_FALSE;
 
    case MESA_FORMAT_ETC1_RGB8:
+   case MESA_FORMAT_ETC2_RGB8:
+   case MESA_FORMAT_ETC2_SRGB8:
+   case MESA_FORMAT_ETC2_RGBA8_EAC:
+   case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+   case MESA_FORMAT_ETC2_R11_EAC:
+   case MESA_FORMAT_ETC2_RG11_EAC:
+   case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+   case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+   case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+   case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
       return GL_FALSE;
 
    case MESA_FORMAT_SIGNED_A8:
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 1843eb6..050fce9 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -259,6 +259,16 @@ typedef enum
    /*@}*/
 
    MESA_FORMAT_ETC1_RGB8,
+   MESA_FORMAT_ETC2_RGB8,
+   MESA_FORMAT_ETC2_SRGB8,
+   MESA_FORMAT_ETC2_RGBA8_EAC,
+   MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
+   MESA_FORMAT_ETC2_R11_EAC,
+   MESA_FORMAT_ETC2_RG11_EAC,
+   MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+   MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
+   MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
+   MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
 
    MESA_FORMAT_SIGNED_A8,         /*                               AAAA AAAA */
    MESA_FORMAT_SIGNED_L8,         /*                               LLLL LLLL */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 69caef7..fefa9c4 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -570,6 +570,16 @@ _mesa_is_color_format(GLenum format)
       case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
       case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
       case GL_ETC1_RGB8_OES:
+      case GL_COMPRESSED_RGB8_ETC2:
+      case GL_COMPRESSED_SRGB8_ETC2:
+      case GL_COMPRESSED_RGBA8_ETC2_EAC:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+      case GL_COMPRESSED_R11_EAC:
+      case GL_COMPRESSED_RG11_EAC:
+      case GL_COMPRESSED_SIGNED_R11_EAC:
+      case GL_COMPRESSED_SIGNED_RG11_EAC:
+      case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+      case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
       /* generic integer formats */
       case GL_RED_INTEGER_EXT:
       case GL_GREEN_INTEGER_EXT:
@@ -829,6 +839,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
    case GL_ETC1_RGB8_OES:
       return _mesa_is_gles(ctx)
          && ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
+   case GL_COMPRESSED_RGB8_ETC2:
+   case GL_COMPRESSED_SRGB8_ETC2:
+   case GL_COMPRESSED_RGBA8_ETC2_EAC:
+   case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+   case GL_COMPRESSED_R11_EAC:
+   case GL_COMPRESSED_RG11_EAC:
+   case GL_COMPRESSED_SIGNED_R11_EAC:
+   case GL_COMPRESSED_SIGNED_RG11_EAC:
+   case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+   case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+      return _mesa_is_gles3(ctx);
    case GL_PALETTE4_RGB8_OES:
    case GL_PALETTE4_RGBA8_OES:
    case GL_PALETTE4_R5_G6_B5_OES:
diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 957cc6d..58b346b 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -33,6 +33,7 @@
 #include "glheader.h"
 #include "imports.h"
 #include "colormac.h"
+#include "context.h"
 #include "formats.h"
 #include "mfeatures.h"
 #include "mtypes.h"
@@ -77,12 +78,16 @@ _mesa_gl_compressed_format_base_format(GLenum format)
 {
    switch (format) {
    case GL_COMPRESSED_RED:
+   case GL_COMPRESSED_R11_EAC:
    case GL_COMPRESSED_RED_RGTC1:
+   case GL_COMPRESSED_SIGNED_R11_EAC:
    case GL_COMPRESSED_SIGNED_RED_RGTC1:
       return GL_RED;
 
    case GL_COMPRESSED_RG:
+   case GL_COMPRESSED_RG11_EAC:
    case GL_COMPRESSED_RG_RGTC2:
+   case GL_COMPRESSED_SIGNED_RG11_EAC:
    case GL_COMPRESSED_SIGNED_RG_RGTC2:
       return GL_RG;
 
@@ -92,6 +97,8 @@ _mesa_gl_compressed_format_base_format(GLenum format)
    case GL_COMPRESSED_RGB_FXT1_3DFX:
    case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
    case GL_ETC1_RGB8_OES:
+   case GL_COMPRESSED_RGB8_ETC2:
+   case GL_COMPRESSED_SRGB8_ETC2:
       return GL_RGB;
 
    case GL_COMPRESSED_RGBA:
@@ -107,6 +114,10 @@ _mesa_gl_compressed_format_base_format(GLenum format)
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
    case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+   case GL_COMPRESSED_RGBA8_ETC2_EAC:
+   case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+   case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+   case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
       return GL_RGBA;
 
    case GL_COMPRESSED_ALPHA:
@@ -293,6 +304,23 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
       }
    }
 
+   if (_mesa_is_gles3(ctx)) {
+      if (formats) {
+         formats[n++] = GL_COMPRESSED_RGB8_ETC2;
+         formats[n++] = GL_COMPRESSED_SRGB8_ETC2;
+         formats[n++] = GL_COMPRESSED_RGBA8_ETC2_EAC;
+         formats[n++] = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
+         formats[n++] = GL_COMPRESSED_R11_EAC;
+         formats[n++] = GL_COMPRESSED_RG11_EAC;
+         formats[n++] = GL_COMPRESSED_SIGNED_R11_EAC;
+         formats[n++] = GL_COMPRESSED_SIGNED_RG11_EAC;
+         formats[n++] = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+         formats[n++] = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+      }
+      else {
+         n += 10;
+      }
+   }
    return n;
 }
 
@@ -352,6 +380,26 @@ _mesa_glenum_to_compressed_format(GLenum format)
 
    case GL_ETC1_RGB8_OES:
       return MESA_FORMAT_ETC1_RGB8;
+   case GL_COMPRESSED_RGB8_ETC2:
+      return MESA_FORMAT_ETC2_RGB8;
+   case GL_COMPRESSED_SRGB8_ETC2:
+      return MESA_FORMAT_ETC2_SRGB8;
+   case GL_COMPRESSED_RGBA8_ETC2_EAC:
+      return MESA_FORMAT_ETC2_RGBA8_EAC;
+   case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+      return MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC;
+   case GL_COMPRESSED_R11_EAC:
+      return MESA_FORMAT_ETC2_R11_EAC;
+   case GL_COMPRESSED_RG11_EAC:
+      return MESA_FORMAT_ETC2_RG11_EAC;
+   case GL_COMPRESSED_SIGNED_R11_EAC:
+      return MESA_FORMAT_ETC2_SIGNED_R11_EAC;
+   case GL_COMPRESSED_SIGNED_RG11_EAC:
+      return MESA_FORMAT_ETC2_SIGNED_RG11_EAC;
+   case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+      return MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
+   case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+      return MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1;
 
    default:
       return MESA_FORMAT_NONE;
@@ -413,6 +461,26 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat)
 
    case MESA_FORMAT_ETC1_RGB8:
       return GL_ETC1_RGB8_OES;
+   case MESA_FORMAT_ETC2_RGB8:
+      return GL_COMPRESSED_RGB8_ETC2;
+   case MESA_FORMAT_ETC2_SRGB8:
+      return GL_COMPRESSED_SRGB8_ETC2;
+   case MESA_FORMAT_ETC2_RGBA8_EAC:
+      return GL_COMPRESSED_RGBA8_ETC2_EAC;
+   case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+      return GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
+   case MESA_FORMAT_ETC2_R11_EAC:
+      return GL_COMPRESSED_R11_EAC;
+   case MESA_FORMAT_ETC2_RG11_EAC:
+      return GL_COMPRESSED_RG11_EAC;
+   case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+      return GL_COMPRESSED_SIGNED_R11_EAC;
+   case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+      return GL_COMPRESSED_SIGNED_RG11_EAC;
+   case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+      return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
+   case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+      return GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
 
    default:
       _mesa_problem(ctx, "Unexpected mesa texture format in"
@@ -538,6 +606,38 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
       fetch = _mesa_fetch_texel_2d_f_etc1_rgb8;
       break;
 
+   /* ETC2 formats */
+   case MESA_FORMAT_ETC2_RGB8:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_rgb8; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_SRGB8:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_srgb8; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_RGBA8_EAC:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_rgba8_eac; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_R11_EAC:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_r11_eac; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_RG11_EAC:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_rg11_eac; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_signed_r11_eac; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_SIGNED_RG11_EAC:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1; -- not implemented yet */
+      break;
+   case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+      /* fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1; -- not implemented yet */
+      break;
+
    default:
       _mesa_problem(NULL, "Unexpected format in _mesa_decompress_image()");
       return;
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index f0bc7fd..b3ffc6c 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -972,6 +972,43 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
       }
    }
 
+   if (_mesa_is_gles3(ctx)) {
+      switch (internalFormat) {
+      case GL_COMPRESSED_RGB8_ETC2:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RGB8);
+         break;
+      case GL_COMPRESSED_SRGB8_ETC2:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SRGB8);
+         break;
+      case GL_COMPRESSED_RGBA8_ETC2_EAC:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RGBA8_EAC);
+         break;
+      case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC);
+         break;
+      case GL_COMPRESSED_R11_EAC:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_R11_EAC);
+         break;
+      case GL_COMPRESSED_RG11_EAC:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RG11_EAC);
+         break;
+      case GL_COMPRESSED_SIGNED_R11_EAC:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SIGNED_R11_EAC);
+         break;
+      case GL_COMPRESSED_SIGNED_RG11_EAC:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SIGNED_RG11_EAC);
+         break;
+      case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1);
+         break;
+      case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+         RETURN_IF_SUPPORTED(MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1);
+         break;
+      default:
+         ; /* fallthrough */
+      }
+   }
+
    _mesa_problem(ctx, "unexpected format %s in _mesa_choose_tex_format()",
                  _mesa_lookup_enum_by_nr(internalFormat));
    return MESA_FORMAT_NONE;
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index a720c38..83b7e14 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -529,6 +529,27 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
       }
    }
 
+   if (_mesa_is_gles3(ctx)) {
+      switch (internalFormat) {
+      case GL_COMPRESSED_RGB8_ETC2:
+      case GL_COMPRESSED_SRGB8_ETC2:
+         return GL_RGB;
+      case GL_COMPRESSED_RGBA8_ETC2_EAC:
+      case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
+      case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+      case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
+         return GL_RGBA;
+      case GL_COMPRESSED_R11_EAC:
+      case GL_COMPRESSED_SIGNED_R11_EAC:
+         return GL_RED;
+      case GL_COMPRESSED_RG11_EAC:
+      case GL_COMPRESSED_SIGNED_RG11_EAC:
+         return GL_RG;
+      default:
+         ; /* fallthrough */
+      }
+   }
+
    if (ctx->API == API_OPENGLES) {
       switch (internalFormat) {
       case GL_PALETTE4_RGB8_OES:
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 1c08810..b542e5c 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4124,6 +4124,18 @@ _mesa_get_texstore_func(gl_format format)
       table[MESA_FORMAT_LA_LATC2] = _mesa_texstore_rg_rgtc2;
       table[MESA_FORMAT_SIGNED_LA_LATC2] = _mesa_texstore_signed_rg_rgtc2;
       table[MESA_FORMAT_ETC1_RGB8] = _mesa_texstore_etc1_rgb8;
+      /* table[MESA_FORMAT_ETC2_RGB8] = _mesa_texstore_etc2_rgb8; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_SRGB8] = _mesa_texstore_etc2_srgb8; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_RGBA8_EAC] = _mesa_texstore_etc2_rgba8_eac; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = _mesa_texstore_etc2_srgb8_alpha8_eac; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_R11_EAC] = _mesa_texstore_etc2_r11_eac; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_RG11_EAC] = _mesa_texstore_etc2_rg11_eac; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_SIGNED_R11_EAC] = _mesa_texstore_etc2_signed_r11_eac; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = _mesa_texstore_etc2_signed_rg11_eac; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
+         _mesa_texstore_etc2_rgb8_punchthrough_alpha1; -- not implemented yet */
+      /* table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] =
+         _mesa_texstore_etc2_srgb8_punchthrough_alpha1; -- not implemented yet */
       table[MESA_FORMAT_SIGNED_A8] = _mesa_texstore_snorm8;
       table[MESA_FORMAT_SIGNED_L8] = _mesa_texstore_snorm8;
       table[MESA_FORMAT_SIGNED_AL88] = _mesa_texstore_snorm88;
diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
index 7bfe3b9..8f0f9b7 100644
--- a/src/mesa/swrast/s_texfetch.c
+++ b/src/mesa/swrast/s_texfetch.c
@@ -1029,6 +1029,66 @@ texfetch_funcs[] =
       NULL
    },
    {
+      MESA_FORMAT_ETC2_RGB8,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_rgb8 -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_SRGB8,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_srgb8 -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_RGBA8_EAC,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_rgba8_eac -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_R11_EAC,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_r11_eac -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_RG11_EAC,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_rg11_eac -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_signed_r11_eac -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1 -- not implemented yet */,
+      NULL
+   },
+   {
+      MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
+      NULL,
+      NULL /* _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1 -- not implemented yet */,
+      NULL
+   },
+   {
       MESA_FORMAT_SIGNED_A8,
       fetch_texel_1d_signed_a8,
       fetch_texel_2d_signed_a8,
-- 
1.7.11.7



More information about the mesa-dev mailing list