[Mesa-dev] [PATCH 05/22] mesa: Add a new texture format GL_COMPRESSED_RGBA8_ETC2_EAC
Anuj Phogat
anuj.phogat at gmail.com
Fri Nov 9 23:29:52 PST 2012
v2 : Add entry in texfetch_funcs[] array
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/mesa/main/format_unpack.c | 8 ++++++++
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 | 2 ++
src/mesa/main/texstore.c | 1 +
src/mesa/swrast/s_texfetch.c | 6 ++++++
9 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index fc339a9..c472c39 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -1347,6 +1347,13 @@ 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_SIGNED_A8(const void *src, GLfloat dst[][4], GLuint n)
{
@@ -1598,6 +1605,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_ETC2_RGBA8_EAC] = unpack_ETC2_RGBA8_EAC;
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 461ce8f..e02dad5 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1418,6 +1418,16 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
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 */
+ },
+
/* Signed formats from EXT_texture_snorm that are not in GL3.1 */
{
MESA_FORMAT_SIGNED_A8,
@@ -1863,6 +1873,8 @@ _mesa_get_uncompressed_format(gl_format format)
case MESA_FORMAT_ETC2_RGB8:
case MESA_FORMAT_ETC2_SRGB8:
return MESA_FORMAT_RGB888;
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ return MESA_FORMAT_RGBA8888;
default:
#ifdef DEBUG
assert(!_mesa_is_format_compressed(format));
@@ -2306,6 +2318,7 @@ _mesa_format_to_type_and_comps(gl_format format,
case MESA_FORMAT_ETC1_RGB8:
case MESA_FORMAT_ETC2_RGB8:
case MESA_FORMAT_ETC2_SRGB8:
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
/* XXX generate error instead? */
*datatype = GL_UNSIGNED_BYTE;
*comps = 0;
@@ -2938,6 +2951,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:
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
return GL_FALSE;
case MESA_FORMAT_SIGNED_A8:
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index eb82c1b..2a75c22 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -261,6 +261,7 @@ typedef enum
MESA_FORMAT_ETC1_RGB8,
MESA_FORMAT_ETC2_RGB8,
MESA_FORMAT_ETC2_SRGB8,
+ MESA_FORMAT_ETC2_RGBA8_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 d7fddca..dd24cad 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -572,6 +572,7 @@ _mesa_is_color_format(GLenum format)
case GL_ETC1_RGB8_OES:
case GL_COMPRESSED_RGB8_ETC2:
case GL_COMPRESSED_SRGB8_ETC2:
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
/* generic integer formats */
case GL_RED_INTEGER_EXT:
case GL_GREEN_INTEGER_EXT:
@@ -833,6 +834,7 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
&& ctx->Extensions.OES_compressed_ETC1_RGB8_texture;
case GL_COMPRESSED_RGB8_ETC2:
case GL_COMPRESSED_SRGB8_ETC2:
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
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 46965b1..6a99194 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -110,6 +110,7 @@ _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:
return GL_RGBA;
case GL_COMPRESSED_ALPHA:
@@ -300,6 +301,7 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
if (formats) {
formats[n++] = GL_COMPRESSED_RGB8_ETC2;
formats[n++] = GL_COMPRESSED_SRGB8_ETC2;
+ formats[n++] = GL_COMPRESSED_RGBA8_ETC2_EAC;
}
else {
n += 1;
@@ -368,6 +370,8 @@ _mesa_glenum_to_compressed_format(GLenum format)
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;
default:
return MESA_FORMAT_NONE;
@@ -433,6 +437,8 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat)
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;
default:
_mesa_problem(ctx, "Unexpected mesa texture format in"
@@ -565,6 +571,9 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
case MESA_FORMAT_ETC2_SRGB8:
fetch = _mesa_fetch_texel_2d_f_etc2_srgb8;
break;
+ case MESA_FORMAT_ETC2_RGBA8_EAC:
+ fetch = _mesa_fetch_texel_2d_f_etc2_rgba8_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 06fc2f6..f87fabd 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -980,6 +980,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
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;
default:
; /* fallthrough */
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index f280f14..abb3538 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -534,6 +534,8 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
case GL_COMPRESSED_RGB8_ETC2:
case GL_COMPRESSED_SRGB8_ETC2:
return GL_RGB;
+ case GL_COMPRESSED_RGBA8_ETC2_EAC:
+ return GL_RGBA;
default:
; /* fallthrough */
}
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 1ffa638..81f84a4 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -4126,6 +4126,7 @@ _mesa_get_texstore_func(gl_format format)
table[MESA_FORMAT_ETC1_RGB8] = _mesa_texstore_etc1_rgb8;
table[MESA_FORMAT_ETC2_RGB8] = _mesa_texstore_etc2_rgb8;
table[MESA_FORMAT_ETC2_SRGB8] = _mesa_texstore_etc2_srgb8;
+ table[MESA_FORMAT_ETC2_RGBA8_EAC] = _mesa_texstore_etc2_rgba8_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;
diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
index 01544e6..26adac0 100644
--- a/src/mesa/swrast/s_texfetch.c
+++ b/src/mesa/swrast/s_texfetch.c
@@ -1041,6 +1041,12 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
NULL
},
{
+ MESA_FORMAT_ETC2_RGBA8_EAC,
+ NULL,
+ _mesa_fetch_texel_2d_f_etc2_rgba8_eac,
+ NULL
+ },
+ {
MESA_FORMAT_SIGNED_A8,
fetch_texel_1d_signed_a8,
fetch_texel_2d_signed_a8,
--
1.7.7.6
More information about the mesa-dev
mailing list