[Mesa-dev] [PATCH 4/6] mesa: Add a new texture format GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
Brian Paul
brianp at vmware.com
Thu Oct 25 15:17:09 PDT 2012
On 10/24/2012 02:22 PM, Anuj Phogat wrote:
>
> Signed-off-by: Anuj Phogat<anuj.phogat at gmail.com>
> ---
> src/mesa/main/format_unpack.c | 9 +++++++++
> 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 | 2 ++
> 8 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index 1a8f113..d31d2fa 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -1392,6 +1392,13 @@ unpack_ETC2_RGB8_PUNCHTHROUGH_ALPHA1(const void *src, GLfloat dst[][4],
> }
>
> 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);
> @@ -1650,6 +1657,8 @@ get_unpack_rgba_function(gl_format format)
> 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 cba51ee..8aa4f28 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -1488,6 +1488,16 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
> 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 */
> + },
> +
Anytime we add a new format to the format_info[] array we have to
add/update the corresponding entry in texfetch_funcs[] array in
swrast/s_texfetch.c
There's a runtime assertion that'll detect missing entries, but only
if you run swrast.
> /* Signed formats from EXT_texture_snorm that are not in GL3.1 */
> {
> MESA_FORMAT_SIGNED_A8,
> @@ -1936,6 +1946,7 @@ _mesa_get_uncompressed_format(gl_format format)
> 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:
> return MESA_FORMAT_R16;
> @@ -2403,6 +2414,7 @@ _mesa_format_to_type_and_comps(gl_format format,
> 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;
> @@ -3042,6 +3054,7 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
> 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 d4ca8c8..050fce9 100644
> --- a/src/mesa/main/formats.h
> +++ b/src/mesa/main/formats.h
> @@ -268,6 +268,7 @@ typedef enum
> 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 bff8890..ab9b266 100644
> --- a/src/mesa/main/glformats.c
> +++ b/src/mesa/main/glformats.c
> @@ -581,6 +581,7 @@ _mesa_is_color_format(GLenum format)
> 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:
> @@ -847,6 +848,7 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
> 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);
> #if FEATURE_ES
> case GL_PALETTE4_RGB8_OES:
> diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
> index 997023d..764d40c 100644
> --- a/src/mesa/main/texcompress.c
> +++ b/src/mesa/main/texcompress.c
> @@ -117,6 +117,7 @@ _mesa_gl_compressed_format_base_format(GLenum format)
> 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:
> @@ -296,6 +297,7 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
> 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 += 1;
> @@ -399,6 +401,8 @@ _mesa_glenum_to_compressed_format(GLenum format)
> 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;
> @@ -485,6 +489,8 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat)
> 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"
> @@ -638,6 +644,9 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
> case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
> fetch = _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1;
> break;
> + case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
> + fetch = _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1;
> + 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 214a767..ad47c0c 100644
> --- a/src/mesa/main/texformat.c
> +++ b/src/mesa/main/texformat.c
> @@ -1007,6 +1007,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
> 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 */
> }
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 398263b..9fc3d41 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -533,6 +533,7 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
> 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:
> diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
> index 93b3890..c3a1bc1 100644
> --- a/src/mesa/main/texstore.c
> +++ b/src/mesa/main/texstore.c
> @@ -4148,6 +4148,8 @@ _mesa_get_texstore_func(gl_format format)
> table[MESA_FORMAT_ETC2_SIGNED_RG11_EAC] = _mesa_texstore_etc2_signed_rg11_eac;
> table[MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1] =
> _mesa_texstore_etc2_rgb8_punchthrough_alpha1;
> + table[MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1] =
> + _mesa_texstore_etc2_srgb8_punchthrough_alpha1;
> table[MESA_FORMAT_SIGNED_A8] = _mesa_texstore_snorm8;
> table[MESA_FORMAT_SIGNED_L8] = _mesa_texstore_snorm8;
> table[MESA_FORMAT_SIGNED_AL88] = _mesa_texstore_snorm88;
More information about the mesa-dev
mailing list