[Mesa-dev] [RFC][PATCH 1/1] intel: add ANGLE_texture_compression_dxt extension support.

Ian Romanick idr at freedesktop.org
Fri Aug 24 08:12:22 PDT 2012


On 08/24/2012 03:16 AM, oliver.mcfadden at linux.intel.com wrote:
> From: Oliver McFadden <oliver.mcfadden at linux.intel.com>
>
> http://angleproject.googlecode.com/svn/trunk/extensions/ANGLE_texture_compression_dxt.txt
>

This might be a better link:

http://www.khronos.org/registry/gles/extensions/ANGLE/ANGLE_texture_compression_dxt.txt

> Signed-off-by: Oliver McFadden <oliver.mcfadden at linux.intel.com>
> ---
>   src/glx/glxextensions.h                       |    1 +
>   src/mapi/glapi/gen/es_EXT.xml                 |   13 +++++++++----
>   src/mesa/drivers/dri/intel/intel_extensions.c |    5 +++++
>   src/mesa/main/APIspec.xml                     |    9 +++++++++
>   src/mesa/main/extensions.c                    |    1 +
>   src/mesa/main/formats.c                       |    2 ++
>   src/mesa/main/mfeatures.h                     |    1 +
>   src/mesa/main/mtypes.h                        |    1 +
>   src/mesa/main/texcompress.c                   |    2 ++
>   src/mesa/main/texcompress_s3tc.c              |    4 ++--
>   src/mesa/main/texcompress_s3tc.h              |    6 +++---
>   src/mesa/main/texformat.c                     |   20 +++++++++++++-------
>   src/mesa/state_tracker/st_format.c            |    4 ++++
>   13 files changed, 53 insertions(+), 16 deletions(-)
>
> diff --git a/src/glx/glxextensions.h b/src/glx/glxextensions.h
> index 90c27a7..2cbd8d4 100644
> --- a/src/glx/glxextensions.h
> +++ b/src/glx/glxextensions.h
> @@ -132,6 +132,7 @@ enum
>      GL_EXT_texture_bit,
>      GL_EXT_texture3D_bit,
>      GL_EXT_texture_compression_dxt1_bit,
> +   GL_ANGLE_texture_compression_dxt_bit,
>      GL_EXT_texture_compression_s3tc_bit,
>      GL_EXT_texture_edge_clamp_bit,
>      GL_EXT_texture_env_combine_bit,
> diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml
> index d012ccd..e32a5b3 100644
> --- a/src/mapi/glapi/gen/es_EXT.xml
> +++ b/src/mapi/glapi/gen/es_EXT.xml
> @@ -599,11 +599,16 @@
>       <enum name="COMPRESSED_RGBA_S3TC_DXT1_EXT"            value="0x83F1"/>
>   </category>
>
> -<category name="GL_EXT_texture_format_BGRA8888" number="51">
> +<category name="ANGLE_texture_compression_dxt" number="51">

It's actually extension 111.

> +    <enum name="COMPRESSED_RGBA_S3TC_DXT3_ANGLE"        value="0x83F2"/>
> +    <enum name="COMPRESSED_RGBA_S3TC_DXT5_ANGLE"        value="0x83F3"/>
> +</category>
> +
> +<category name="GL_EXT_texture_format_BGRA8888" number="52">
>       <enum name="BGRA_EXT"                                 value="0x80E1"/>
>   </category>
>
> -<category name="GL_EXT_texture_lod_bias" number="60">
> +<category name="GL_EXT_texture_lod_bias" number="61">
>       <enum name="TEXTURE_FILTER_CONTROL_EXT"               value="0x8500"/>
>       <enum name="TEXTURE_LOD_BIAS_EXT"                     value="0x8501"/>
>       <enum name="MAX_TEXTURE_LOD_BIAS_EXT"                 value="0x84FD"/>
> @@ -611,7 +616,7 @@
>
>   <!-- 65. GL_EXT_blend_minmax -->
>
> -<category name="GL_EXT_read_format_bgra" number="66">
> +<category name="GL_EXT_read_format_bgra" number="67">
>       <enum name="BGRA_EXT"                                 value="0x80E1"/>
>       <enum name="UNSIGNED_SHORT_4_4_4_4_REV_EXT"           value="0x8365"/>
>       <enum name="UNSIGNED_SHORT_1_5_5_5_REV_EXT"           value="0x8366"/>
> @@ -620,7 +625,7 @@
>   <!-- 69. GL_EXT_multi_draw_arrays -->
>
>   <!-- 87. GL_OES_EGL_image_external -->
> -<category name="GL_OES_EGL_image_external" number="87">
> +<category name="GL_OES_EGL_image_external" number="88">
>       <enum name="TEXTURE_EXTERNAL_OES"                     value="0x8D65"/>
>       <enum name="SAMPLER_EXTERNAL_OES"                     value="0x8D66"/>
>       <enum name="TEXTURE_BINDING_EXTERNAL_OES"             value="0x8D67"/>
> diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
> index c2bc072..e3e4432 100755
> --- a/src/mesa/drivers/dri/intel/intel_extensions.c
> +++ b/src/mesa/drivers/dri/intel/intel_extensions.c
> @@ -167,6 +167,11 @@ intelInitExtensions(struct gl_context *ctx)
>      }
>
>      if (intel->ctx.Mesa_DXTn) {
> +      /* Does not require compression, but still needs the library for
> +       * decompression! */
> +      ctx->Extensions.ANGLE_texture_compression_dxt = true;
> +
> +      /* Requires both compression and decompression functions. */
>         ctx->Extensions.EXT_texture_compression_s3tc = true;
>         ctx->Extensions.S3_s3tc = true;
>      }
> diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
> index b6cf52d..c89d6f7 100644
> --- a/src/mesa/main/APIspec.xml
> +++ b/src/mesa/main/APIspec.xml
> @@ -2502,6 +2502,9 @@

I'd like to hold off on this patch for just a few more days... so that I 
can finish killing off APIspec.xml.

>
>   		<value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
>   		<value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
> +
> +		<value name="GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE" category="ANGLE_texture_compression_dxt"/>
> +		<value name="GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE" category="ANGLE_texture_compression_dxt"/>
>   	</desc>
>
>   	<desc name="border" error="GL_INVALID_VALUE">
> @@ -2542,6 +2545,9 @@
>   	<desc name="format">
>   		<value name="GL_COMPRESSED_RGB_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
>   		<value name="GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" category="EXT_texture_compression_dxt1"/>
> +
> +		<value name="GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE" category="ANGLE_texture_compression_dxt"/>
> +		<value name="GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE" category="ANGLE_texture_compression_dxt"/>
>   	</desc>
>   </template>
>
> @@ -4163,6 +4169,9 @@
>   	<category name="NV_draw_buffers"/>
>   	<category name="NV_read_buffer"/>
>
> +	<!-- GL_ANGLE_texture_compression_dxt -->
> +	<category name="ANGLE_texture_compression_dxt"/>
> +
>   	<function name="DrawBuffersNV" template="DrawBuffers"/>
>   	<function name="ReadBufferNV" template="ReadBuffer"/>
>
> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
> index 0675ce7..bf91088 100644
> --- a/src/mesa/main/extensions.c
> +++ b/src/mesa/main/extensions.c
> @@ -193,6 +193,7 @@ static const struct extension extension_table[] = {
>      { "GL_EXT_texture3D",                           o(EXT_texture3D),                           GL,             1996 },
>      { "GL_EXT_texture_array",                       o(EXT_texture_array),                       GL,             2006 },
>      { "GL_EXT_texture_compression_dxt1",            o(EXT_texture_compression_s3tc),            GL | ES1 | ES2, 2004 },

Since GL_EXT_texture_compression_dxt1 is similar to the ANGLE 
extensions, we should probably change it to use the same extension 
enable bit.

> +   { "GL_ANGLE_texture_compression_dxt",           o(ANGLE_texture_compression_dxt),           ES2,            2011 },

This extension spec confuses me a little bit.  The name of the spec is 
GL_ANGLE_texture_compression_dxt, but it lists the name strings as 
GL_ANGLE_texture_compression_dxt3 and GL_ANGLE_texture_compression_dxt5. 
  It's not clear to me which strings an implementation is supposed to 
expose.

I also think this extension should be exposed on ES1.

>      { "GL_EXT_texture_compression_latc",            o(EXT_texture_compression_latc),            GL,             2006 },
>      { "GL_EXT_texture_compression_rgtc",            o(ARB_texture_compression_rgtc),            GL,             2004 },
>      { "GL_EXT_texture_compression_s3tc",            o(EXT_texture_compression_s3tc),            GL,             2000 },
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index c65c9c2..498fad0 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -2248,9 +2248,11 @@ _mesa_format_to_type_and_comps(gl_format format,
>      case MESA_FORMAT_RGB_FXT1:
>      case MESA_FORMAT_RGBA_FXT1:
>   #endif
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
>   #if FEATURE_texture_s3tc
>      case MESA_FORMAT_RGB_DXT1:
>      case MESA_FORMAT_RGBA_DXT1:
> +#endif
>      case MESA_FORMAT_RGBA_DXT3:
>      case MESA_FORMAT_RGBA_DXT5:
>   #if FEATURE_EXT_texture_sRGB
> diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h
> index b67f046..38325e8 100644
> --- a/src/mesa/main/mfeatures.h
> +++ b/src/mesa/main/mfeatures.h
> @@ -105,6 +105,7 @@
>   #define FEATURE_rastpos                   FEATURE_GL
>   #define FEATURE_texture_fxt1              FEATURE_GL
>   #define FEATURE_texture_s3tc              FEATURE_GL
> +#define FEATURE_ANGLE_texture_compression_dxt                   FEATURE_ES2
>
>   #define FEATURE_extra_context_init        FEATURE_ES
>   #define FEATURE_point_size_array          FEATURE_ES
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 3d59dc6..f13b134 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3032,6 +3032,7 @@ struct gl_extensions
>      GLboolean EXT_texture_array;
>      GLboolean EXT_texture_compression_latc;
>      GLboolean EXT_texture_compression_s3tc;
> +   GLboolean ANGLE_texture_compression_dxt;
>      GLboolean EXT_texture_env_dot3;
>      GLboolean EXT_texture_filter_anisotropic;
>      GLboolean EXT_texture_integer;
> diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
> index c376b97..f4f2226 100644
> --- a/src/mesa/main/texcompress.c
> +++ b/src/mesa/main/texcompress.c
> @@ -381,11 +381,13 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat)
>      case MESA_FORMAT_RGBA_FXT1:
>         return GL_COMPRESSED_RGBA_FXT1_3DFX;
>   #endif
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
>   #if FEATURE_texture_s3tc
>      case MESA_FORMAT_RGB_DXT1:
>         return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
>      case MESA_FORMAT_RGBA_DXT1:
>         return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
> +#endif
>      case MESA_FORMAT_RGBA_DXT3:
>         return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
>      case MESA_FORMAT_RGBA_DXT5:
> diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
> index e30890c..b911150 100644
> --- a/src/mesa/main/texcompress_s3tc.c
> +++ b/src/mesa/main/texcompress_s3tc.c
> @@ -47,7 +47,7 @@
>   #include "swrast/s_context.h"
>
>
> -#if FEATURE_texture_s3tc
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
>
>
>   #if defined(_WIN32) || defined(WIN32)
> @@ -533,4 +533,4 @@ _mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage,
>   #endif /* FEATURE_EXT_texture_sRGB */
>
>
> -#endif /* FEATURE_texture_s3tc */
> +#endif /* FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt */
> diff --git a/src/mesa/main/texcompress_s3tc.h b/src/mesa/main/texcompress_s3tc.h
> index 23793d1..31b28e9 100644
> --- a/src/mesa/main/texcompress_s3tc.h
> +++ b/src/mesa/main/texcompress_s3tc.h
> @@ -33,7 +33,7 @@
>   struct gl_context;
>   struct swrast_texture_image;
>
> -#if FEATURE_texture_s3tc
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
>
>   extern GLboolean
>   _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS);
> @@ -82,7 +82,7 @@ _mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage,
>   extern void
>   _mesa_init_texture_s3tc(struct gl_context *ctx);
>
> -#else /* FEATURE_texture_s3tc */
> +#else /* FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt */
>
>   /* these are used only in texstore_funcs[] */
>   #define _mesa_texstore_rgb_dxt1 NULL
> @@ -105,6 +105,6 @@ _mesa_init_texture_s3tc(struct gl_context *ctx)
>   {
>   }
>
> -#endif /* FEATURE_texture_s3tc */
> +#endif /* FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt */
>
>   #endif /* TEXCOMPRESS_S3TC_H */
> diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
> index 26bcbc1..a4cb6e6 100644
> --- a/src/mesa/main/texformat.c
> +++ b/src/mesa/main/texformat.c
> @@ -292,15 +292,18 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
>      }
>   #endif
>
> -#if FEATURE_texture_s3tc
> -   if (ctx->Extensions.EXT_texture_compression_s3tc) {
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
> +   if (ctx->Extensions.EXT_texture_compression_s3tc ||
> +       ctx->Extensions.ANGLE_texture_compression_dxt) {
>         switch (internalFormat) {
> +#if FEATURE_texture_s3tc
>            case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1);
>   	    break;
>            case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT1);
>   	    break;
> +#endif
>            case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3);
>   	    break;
> @@ -583,14 +586,15 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8);
>   	    break;
>            case GL_COMPRESSED_SRGB_ALPHA_EXT:
> -#if FEATURE_texture_s3tc
> -            if (ctx->Extensions.EXT_texture_compression_s3tc)
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
> +            if (ctx->Extensions.EXT_texture_compression_s3tc ||
> +		ctx->Extensions.ANGLE_texture_compression_dxt)
>   	       RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1, see spec */
>   #endif
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA8);
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8);
>   	    break;
> -#if FEATURE_texture_s3tc
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
>            case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
>               if (ctx->Extensions.EXT_texture_compression_s3tc)
>   	       RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1);
> @@ -602,12 +606,14 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8);
>               break;
>            case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
> -            if (ctx->Extensions.EXT_texture_compression_s3tc)
> +            if (ctx->Extensions.EXT_texture_compression_s3tc ||
> +		ctx->Extensions.ANGLE_texture_compression_dxt)
>   	       RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3);
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8);
>               break;
>            case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
> -            if (ctx->Extensions.EXT_texture_compression_s3tc)
> +            if (ctx->Extensions.EXT_texture_compression_s3tc ||
> +		ctx->Extensions.ANGLE_texture_compression_dxt)
>   	       RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT5);
>   	    RETURN_IF_SUPPORTED(MESA_FORMAT_SARGB8);
>               break;
> diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
> index 57d3441..d52ad96 100644
> --- a/src/mesa/state_tracker/st_format.c
> +++ b/src/mesa/state_tracker/st_format.c
> @@ -118,11 +118,13 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
>         return PIPE_FORMAT_Z32_FLOAT_S8X24_UINT;
>      case MESA_FORMAT_YCBCR:
>         return PIPE_FORMAT_UYVY;
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
>   #if FEATURE_texture_s3tc
>      case MESA_FORMAT_RGB_DXT1:
>         return PIPE_FORMAT_DXT1_RGB;
>      case MESA_FORMAT_RGBA_DXT1:
>         return PIPE_FORMAT_DXT1_RGBA;
> +#endif
>      case MESA_FORMAT_RGBA_DXT3:
>         return PIPE_FORMAT_DXT3_RGBA;
>      case MESA_FORMAT_RGBA_DXT5:
> @@ -448,11 +450,13 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
>      case PIPE_FORMAT_YUYV:
>         return MESA_FORMAT_YCBCR_REV;
>
> +#if FEATURE_texture_s3tc || FEATURE_ANGLE_texture_compression_dxt
>   #if FEATURE_texture_s3tc
>      case PIPE_FORMAT_DXT1_RGB:
>         return MESA_FORMAT_RGB_DXT1;
>      case PIPE_FORMAT_DXT1_RGBA:
>         return MESA_FORMAT_RGBA_DXT1;
> +#endif
>      case PIPE_FORMAT_DXT3_RGBA:
>         return MESA_FORMAT_RGBA_DXT3;
>      case PIPE_FORMAT_DXT5_RGBA:
>


More information about the mesa-dev mailing list