[Mesa-dev] [PATCH 03/22] mesa: Add a new texture format GL_COMPRESSED_SRGB8_ETC2

Brian Paul brianp at vmware.com
Mon Nov 12 07:45:40 PST 2012


On 11/10/2012 12:29 AM, Anuj Phogat wrote:
> v2 : Add entry in texfetch_funcs[] array
> Signed-off-by: Anuj Phogat<anuj.phogat at gmail.com>
> ---
>   src/mesa/main/format_unpack.c |    6 ++++++
>   src/mesa/main/formats.c       |   13 +++++++++++++
>   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 +
>   src/mesa/swrast/s_texfetch.c  |    6 ++++++
>   9 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index d0029ab..fc339a9 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -1343,6 +1343,11 @@ unpack_ETC2_RGB8(const void *src, GLfloat dst[][4], GLuint n)
>   }
>
>   static void
> +unpack_ETC2_SRGB8(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);
> @@ -1592,6 +1597,7 @@ get_unpack_rgba_function(gl_format format)
>
>         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_SIGNED_A8] = unpack_SIGNED_A8;
>         table[MESA_FORMAT_SIGNED_L8] = unpack_SIGNED_L8;
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index a83abc3..461ce8f 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -1408,6 +1408,16 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
>         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 */
> +   },
> +
>      /* Signed formats from EXT_texture_snorm that are not in GL3.1 */
>      {
>         MESA_FORMAT_SIGNED_A8,
> @@ -1851,6 +1861,7 @@ _mesa_get_uncompressed_format(gl_format format)
>         return MESA_FORMAT_SIGNED_AL88;
>      case MESA_FORMAT_ETC1_RGB8:
>      case MESA_FORMAT_ETC2_RGB8:
> +   case MESA_FORMAT_ETC2_SRGB8:
>         return MESA_FORMAT_RGB888;
>      default:
>   #ifdef DEBUG
> @@ -2294,6 +2305,7 @@ _mesa_format_to_type_and_comps(gl_format format,
>      case MESA_FORMAT_SIGNED_LA_LATC2:
>      case MESA_FORMAT_ETC1_RGB8:
>      case MESA_FORMAT_ETC2_RGB8:
> +   case MESA_FORMAT_ETC2_SRGB8:
>         /* XXX generate error instead? */
>         *datatype = GL_UNSIGNED_BYTE;
>         *comps = 0;
> @@ -2925,6 +2937,7 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
>
>      case MESA_FORMAT_ETC1_RGB8:
>      case MESA_FORMAT_ETC2_RGB8:
> +   case MESA_FORMAT_ETC2_SRGB8:
>         return GL_FALSE;
>
>      case MESA_FORMAT_SIGNED_A8:
> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
> index 1d3cc35..eb82c1b 100644
> --- a/src/mesa/main/formats.h
> +++ b/src/mesa/main/formats.h
> @@ -260,6 +260,7 @@ typedef enum
>
>      MESA_FORMAT_ETC1_RGB8,
>      MESA_FORMAT_ETC2_RGB8,
> +   MESA_FORMAT_ETC2_SRGB8,
>
>      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 cc7ad22..d7fddca 100644
> --- a/src/mesa/main/glformats.c
> +++ b/src/mesa/main/glformats.c
> @@ -571,6 +571,7 @@ _mesa_is_color_format(GLenum format)
>         case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
>         case GL_ETC1_RGB8_OES:
>         case GL_COMPRESSED_RGB8_ETC2:
> +      case GL_COMPRESSED_SRGB8_ETC2:
>         /* generic integer formats */
>         case GL_RED_INTEGER_EXT:
>         case GL_GREEN_INTEGER_EXT:
> @@ -831,6 +832,7 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
>         return _mesa_is_gles(ctx)
>            &&  ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
>      case GL_COMPRESSED_RGB8_ETC2:
> +   case GL_COMPRESSED_SRGB8_ETC2:
>         return _mesa_is_gles3(ctx);
>      case GL_PALETTE4_RGB8_OES:
>      case GL_PALETTE4_RGBA8_OES:
> diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
> index 14a1634..46965b1 100644
> --- a/src/mesa/main/texcompress.c
> +++ b/src/mesa/main/texcompress.c
> @@ -94,6 +94,7 @@ _mesa_gl_compressed_format_base_format(GLenum format)
>      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:
> @@ -298,6 +299,7 @@ _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;
>         }
>         else {
>            n += 1;

Don't you need to increment n by 2 in the else clause?


-Brian


More information about the mesa-dev mailing list