[Mesa-dev] [PATCH 22/27] Add a new texture format GL_COMPRESSED_SIGNED_R11_EAC

Anuj Phogat anuj.phogat at gmail.com
Fri Oct 19 16:28:57 PDT 2012


Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 src/mesa/main/format_unpack.c |    7 +++++++
 src/mesa/main/formats.c       |   14 ++++++++++++++
 src/mesa/main/formats.h       |    1 +
 src/mesa/main/glformats.c     |    2 ++
 src/mesa/main/texcompress.c   |    9 +++++++++
 src/mesa/main/texformat.c     |    3 +++
 src/mesa/main/teximage.c      |    1 +
 src/mesa/main/texstore.c      |    1 +
 8 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 2cf2e04..2fd706b 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1373,6 +1373,12 @@ unpack_ETC2_RG11_EAC(const void *src, GLfloat dst[][4], GLuint n)
 }
 
 static void
+unpack_ETC2_SIGNED_R11_EAC(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);
@@ -1627,6 +1633,7 @@ get_unpack_rgba_function(gl_format format)
       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_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 14ecd9a..fd38ee0 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1458,6 +1458,16 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
       4, 4, 16                    /* 16 bytes per 4x4 block */
    },
 
+   {
+      MESA_FORMAT_ETC2_SIGNED_R11_EAC,
+      "MESA_FORMAT_ETC2_SIGNED_R11_EAC",
+      GL_RED,
+      GL_UNSIGNED_NORMALIZED,
+      11, 0, 0, 0,
+      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,
@@ -1910,6 +1920,8 @@ _mesa_get_uncompressed_format(gl_format format)
       return MESA_FORMAT_R16;
    case MESA_FORMAT_ETC2_RG11_EAC:
       return MESA_FORMAT_RG1616;
+   case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+      return MESA_FORMAT_SIGNED_R16;
    default:
 #ifdef DEBUG
       assert(!_mesa_is_format_compressed(format));
@@ -2365,6 +2377,7 @@ _mesa_format_to_type_and_comps(gl_format format,
    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:
       /* XXX generate error instead? */
       *datatype = GL_UNSIGNED_BYTE;
       *comps = 0;
@@ -3001,6 +3014,7 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
    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:
       return GL_FALSE;
 
    case MESA_FORMAT_SIGNED_A8:
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index f5dc259..230c776 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -265,6 +265,7 @@ typedef enum
    MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
    MESA_FORMAT_ETC2_R11_EAC,
    MESA_FORMAT_ETC2_RG11_EAC,
+   MESA_FORMAT_ETC2_SIGNED_R11_EAC,
 
    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 d4ab4b1..094a3fc 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -578,6 +578,7 @@ _mesa_is_color_format(GLenum format)
       case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
       case GL_COMPRESSED_R11_EAC:
       case GL_COMPRESSED_RG11_EAC:
+      case GL_COMPRESSED_SIGNED_R11_EAC:
       /* generic integer formats */
       case GL_RED_INTEGER_EXT:
       case GL_GREEN_INTEGER_EXT:
@@ -841,6 +842,7 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
    case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
    case GL_COMPRESSED_R11_EAC:
    case GL_COMPRESSED_RG11_EAC:
+   case GL_COMPRESSED_SIGNED_R11_EAC:
       return _mesa_is_gles3(ctx);
 #if FEATURE_ES
    case GL_PALETTE4_RGB8_OES:
diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 3aab1c3..90f020a 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -80,6 +80,7 @@ _mesa_gl_compressed_format_base_format(GLenum 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;
 
@@ -290,6 +291,7 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
          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;
       }
       else {
          n += 1;
@@ -387,6 +389,8 @@ _mesa_glenum_to_compressed_format(GLenum format)
       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;
 
    default:
       return MESA_FORMAT_NONE;
@@ -467,6 +471,8 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat)
       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;
 
    default:
       _mesa_problem(ctx, "Unexpected mesa texture format in"
@@ -611,6 +617,9 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
    case MESA_FORMAT_ETC2_RG11_EAC:
       fetch = _mesa_fetch_texel_2d_f_etc2_rg11_eac;
       break;
+   case MESA_FORMAT_ETC2_SIGNED_R11_EAC:
+      fetch = _mesa_fetch_texel_2d_f_etc2_signed_r11_eac;
+      break;
 
    default:
       _mesa_problem(NULL, "Unexpected format in _mesa_decompress_image()");
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 697389e..e8ba9cc 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -998,6 +998,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
          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;
          default:
             ; /* fallthrough */
       }
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 80545f2..f6f1fee 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -534,6 +534,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
       case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
          return GL_RGBA;
       case GL_COMPRESSED_R11_EAC:
+      case GL_COMPRESSED_SIGNED_R11_EAC:
          return GL_RED;
       case GL_COMPRESSED_RG11_EAC:
          return GL_RG;
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 898e782..cbeead2 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4144,6 +4144,7 @@ _mesa_get_texstore_func(gl_format format)
       table[MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC] = _mesa_texstore_etc2_srgb8_alpha8_eac;
       table[MESA_FORMAT_ETC2_R11_EAC] = _mesa_texstore_etc2_r11_eac;
       table[MESA_FORMAT_ETC2_RG11_EAC] = _mesa_texstore_etc2_rg11_eac;
+      table[MESA_FORMAT_ETC2_SIGNED_R11_EAC] = _mesa_texstore_etc2_signed_r11_eac;
       table[MESA_FORMAT_SIGNED_A8] = _mesa_texstore_snorm8;
       table[MESA_FORMAT_SIGNED_L8] = _mesa_texstore_snorm8;
       table[MESA_FORMAT_SIGNED_AL88] = _mesa_texstore_snorm88;
-- 
1.7.7.6



More information about the mesa-dev mailing list