[Mesa-dev] [PATCH 2/4] mesa: don't try (generic) compression of 1D and 1D_ARRAY textures

Anuj Phogat anuj.phogat at gmail.com
Fri Aug 24 10:33:48 PDT 2012


On Fri, Aug 24, 2012 at 7:53 AM, Brian Paul <brianp at vmware.com> wrote:
> See comments in the code for details.
>
> Note: we only need to special-case the generic compressed formats since
> specific texture formats are error-checked earlier to see if the compression
> format is compatible with the texture type.
> ---
>  src/mesa/main/texformat.c |   38 ++++++++++++++++++++++++++------------
>  1 files changed, 26 insertions(+), 12 deletions(-)
>
> diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
> index 57f5352..1a318ab 100644
> --- a/src/mesa/main/texformat.c
> +++ b/src/mesa/main/texformat.c
> @@ -236,21 +236,33 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
>          RETURN_IF_SUPPORTED(MESA_FORMAT_I8);
>          break;
>        case GL_COMPRESSED_RGB_ARB:
> -         if (ctx->Extensions.EXT_texture_compression_s3tc ||
> -             ctx->Extensions.S3_s3tc)
> -           RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1);
> -         if (ctx->Extensions.TDFX_texture_compression_FXT1)
> -           RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FXT1);
> +         /* We don't use texture compression for 1D and 1D array textures.
> +          * For 1D textures, compressions doesn't buy us much.
> +          * For 1D ARRAY textures, there's complicated issues with updating
> +          * sub-regions on non-block boundaries with glCopyTexSubImage, among
> +          * other issues.  FWIW, the GL_EXT_texture_array extension prohibits
> +          * 1D ARRAY textures in S3TC format.
> +          */
> +         if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) {
> +            if (ctx->Extensions.EXT_texture_compression_s3tc ||
> +                ctx->Extensions.S3_s3tc)
> +               RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1);
> +            if (ctx->Extensions.TDFX_texture_compression_FXT1)
> +               RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FXT1);
> +         }
>          RETURN_IF_SUPPORTED(MESA_FORMAT_RGB888);
>          RETURN_IF_SUPPORTED(MESA_FORMAT_XRGB8888);
>          RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
>          break;
>        case GL_COMPRESSED_RGBA_ARB:
> -         if (ctx->Extensions.EXT_texture_compression_s3tc ||
> -             ctx->Extensions.S3_s3tc)
> -           RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); /* Not rgba_dxt1, see spec */
> -         if (ctx->Extensions.TDFX_texture_compression_FXT1)
> -           RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FXT1);
> +         /* We don't use texture compression for 1D and 1D array textures. */
> +         if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) {
> +            if (ctx->Extensions.EXT_texture_compression_s3tc ||
> +                ctx->Extensions.S3_s3tc)
> +               RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); /* Not rgba_dxt1, see spec */
> +            if (ctx->Extensions.TDFX_texture_compression_FXT1)
> +               RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FXT1);
> +         }
>          RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA8888);
>          RETURN_IF_SUPPORTED(MESA_FORMAT_ARGB8888);
>          break;
> @@ -775,7 +787,8 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
>          break;
>
>        case GL_COMPRESSED_RED:
> -        RETURN_IF_SUPPORTED(MESA_FORMAT_RED_RGTC1);
> +         if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY)
> +            RETURN_IF_SUPPORTED(MESA_FORMAT_RED_RGTC1);
>          RETURN_IF_SUPPORTED(MESA_FORMAT_R8);
>          break;
>
> @@ -789,7 +802,8 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
>          break;
>
>        case GL_COMPRESSED_RG:
> -        RETURN_IF_SUPPORTED(MESA_FORMAT_RG_RGTC2);
> +         if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY)
> +            RETURN_IF_SUPPORTED(MESA_FORMAT_RG_RGTC2);
>          RETURN_IF_SUPPORTED(MESA_FORMAT_GR88);
>          break;
>
> --
> 1.7.3.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Looks good to me.
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list