[Mesa-dev] [PATCH] mesa: fix incorrect error for glCompressedSubTexImage

Eric Anholt eric at anholt.net
Mon Sep 24 17:42:29 PDT 2012


Brian Paul <brian.e.paul at gmail.com> writes:

> From: Brian Paul <brianp at vmware.com>
>
> If a subtexture region isn't aligned to the compressed block size,
> return GL_INVALID_OPERATION, not gl_INVALID_VALUE.
>
> NOTE: This is a candidate for the stable branches.
> ---
>  src/mesa/main/teximage.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 08af668..c22e853 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -3574,13 +3574,13 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dimensions,
>     get_compressed_block_size(format, &bw, &bh);
>  
>     if ((xoffset % bw != 0) || (yoffset % bh != 0))
> -      return GL_INVALID_VALUE;
> +      return GL_INVALID_OPERATION;
>  
>     if ((width % bw != 0) && width != 2 && width != 1)
> -      return GL_INVALID_VALUE;
> +      return GL_INVALID_OPERATION;
>  
>     if ((height % bh != 0) && height != 2 && height != 1)
> -      return GL_INVALID_VALUE;
> +      return GL_INVALID_OPERATION;

Reviewed-by: Eric Anholt <eric at anholt.net>

The conditions are pretty bogus, though.  The s3tc text says:

    INVALID_OPERATION is generated by CompressedTexSubImage2D if
    TEXTURE_INTERNAL_FORMAT is COMPRESSED_RGB_S3TC_DXT1_EXT,
    COMPRESSED_RGBA_S3TC_DXT1_EXT, COMPRESSED_RGBA_S3TC_DXT3_EXT, or
    COMPRESSED_RGBA_S3TC_DXT5_EXT and any of the following apply:

        * <width> is not a multiple of four, and <width> plus <xoffset> is not
          equal to TEXTURE_WIDTH;

        * <height> is not a multiple of four, and <height> plus <yoffset> is
          not equal to TEXTURE_HEIGHT; or

and the 3.1 core spec text says (section 3.8.3):

    These commands will result in an INVALID_OPERATION error if one of
    the following conditions occurs:

    • width is not a multiple of four, and width + xoffset is not equal
      to the value of TEXTURE_WIDTH.

    • height is not a multiple of four, and height + yoffset is not
      equal to the value of TEXTURE_HEIGHT.

    • xoffset or yoffset is not a multiple of four.

Looks like this code wants to live in
compressed_subtexture_error_check2(), which has some overlapping checks
in it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20120924/3fb83863/attachment.pgp>


More information about the mesa-dev mailing list