[Mesa-dev] [PATCH] main: Fix target checking for CompressedTexSubImage*D.
Anuj Phogat
anuj.phogat at gmail.com
Thu Feb 26 11:46:25 PST 2015
On Wed, Feb 25, 2015 at 3:58 PM, Laura Ekstrand <laura at jlekstrand.net> wrote:
> This fixes a dEQP test failure. In the test,
> glCompressedTexSubImage2D was called with target = 0 and failed to throw
> INVALID ENUM. This failure was caused by _mesa_get_current_tex_object(ctx,
> target) being called before the target checking. To remedy this, target
> checking was made into its own function and called prior to
> _mesa_get_current_tex_object.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89311
> ---
> src/mesa/main/teximage.c | 80 +++++++++++++++++++++++++++++++++++++++---------
> 1 file changed, 65 insertions(+), 15 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index faec444..87231df 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -4456,25 +4456,21 @@ out:
>
>
> /**
> - * Error checking for glCompressedTexSubImage[123]D().
> + * Target checking for glCompressedTexSubImage[123]D().
> * \return GL_TRUE if error, GL_FALSE if no error
> + * Must come before other error checking so that the texture object can
> + * be correctly retrieved using _mesa_get_current_tex_object.
> */
> static GLboolean
> -compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
> - const struct gl_texture_object *texObj,
> - GLenum target, GLint level,
> - GLint xoffset, GLint yoffset, GLint zoffset,
> - GLsizei width, GLsizei height, GLsizei depth,
> - GLenum format, GLsizei imageSize, bool dsa)
> +compressed_subtexture_target_check(struct gl_context *ctx, GLenum target,
> + GLint dims, GLenum format, bool dsa,
> + const char *caller)
> {
> - struct gl_texture_image *texImage;
> - GLint expectedSize;
> GLboolean targetOK;
> - const char *suffix = dsa ? "ture" : "";
>
> if (dsa && target == GL_TEXTURE_RECTANGLE) {
> - _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glCompressedSubTexture%dD(target)", dims);
> + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller,
> + _mesa_lookup_enum_by_nr(target));
> return GL_TRUE;
> }
>
> @@ -4537,7 +4533,9 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
> }
> if (invalidformat) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glCompressedTex%sSubImage%uD(target)", suffix, dims);
> + "%s(invalid target %s for format %s)", caller,
> + _mesa_lookup_enum_by_nr(target),
> + _mesa_lookup_enum_by_nr(format));
> return GL_TRUE;
> }
> }
> @@ -4551,11 +4549,30 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
> }
>
> if (!targetOK) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glCompressedTex%sSubImage%uD(target)", suffix, dims);
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller,
> + _mesa_lookup_enum_by_nr(target));
> return GL_TRUE;
> }
>
> + return GL_FALSE;
> +}
> +
> +/**
> + * Error checking for glCompressedTexSubImage[123]D().
> + * \return GL_TRUE if error, GL_FALSE if no error
> + */
> +static GLboolean
> +compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
> + const struct gl_texture_object *texObj,
> + GLenum target, GLint level,
> + GLint xoffset, GLint yoffset, GLint zoffset,
> + GLsizei width, GLsizei height, GLsizei depth,
> + GLenum format, GLsizei imageSize, bool dsa)
> +{
> + struct gl_texture_image *texImage;
> + GLint expectedSize;
> + const char *suffix = dsa ? "ture" : "";
> +
> /* this will catch any invalid compressed format token */
> if (!_mesa_is_compressed_format(ctx, format)) {
> _mesa_error(ctx, GL_INVALID_ENUM,
> @@ -4702,6 +4719,11 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
>
> GET_CURRENT_CONTEXT(ctx);
>
> + if (compressed_subtexture_target_check(ctx, target, 1, format, false,
> + "glCompressedTexSubImage1D")) {
> + return;
> + }
> +
> texObj = _mesa_get_current_tex_object(ctx, target);
> if (!texObj)
> return;
> @@ -4737,6 +4759,12 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
> if (!texObj)
> return;
>
> + if (compressed_subtexture_target_check(ctx, texObj->Target, 1, format,
> + true,
> + "glCompressedTextureSubImage1D")) {
> + return;
> + }
> +
> if (compressed_subtexture_error_check(ctx, 1, texObj, texObj->Target,
> level, xoffset, 0, 0,
> width, 1, 1,
> @@ -4767,6 +4795,11 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
>
> GET_CURRENT_CONTEXT(ctx);
>
> + if (compressed_subtexture_target_check(ctx, target, 2, format, false,
> + "glCompressedTexSubImage2D")) {
> + return;
> + }
> +
> texObj = _mesa_get_current_tex_object(ctx, target);
> if (!texObj)
> return;
> @@ -4805,6 +4838,12 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
> if (!texObj)
> return;
>
> + if (compressed_subtexture_target_check(ctx, texObj->Target, 2, format,
> + true,
> + "glCompressedTextureSubImage2D")) {
> + return;
> + }
> +
> if (compressed_subtexture_error_check(ctx, 2, texObj, texObj->Target,
> level, xoffset, yoffset, 0,
> width, height, 1,
> @@ -4833,6 +4872,11 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
>
> GET_CURRENT_CONTEXT(ctx);
>
> + if (compressed_subtexture_target_check(ctx, target, 3, format, false,
> + "glCompressedTexSubImage3D")) {
> + return;
> + }
> +
> texObj = _mesa_get_current_tex_object(ctx, target);
> if (!texObj)
> return;
> @@ -4874,6 +4918,12 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
> if (!texObj)
> return;
>
> + if (compressed_subtexture_target_check(ctx, texObj->Target, 3, format,
> + true,
> + "glCompressedTextureSubImage3D")) {
> + return;
> + }
> +
> if (compressed_subtexture_error_check(ctx, 3, texObj, texObj->Target,
> level, xoffset, yoffset, zoffset,
> width, height, depth,
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
More information about the mesa-dev
mailing list