[Mesa-dev] [PATCH 10/17] mesa: Add missing check of format and type in glTexSubImageXD on GLES 3.0

Ian Romanick idr at freedesktop.org
Wed Jul 29 12:59:18 PDT 2015


On 07/29/2015 07:01 AM, Samuel Iglesias Gonsalvez wrote:
> From: Eduardo Lima Mitev <elima at igalia.com>
> 
> Argument validation for glTexSubImageXD is missing a check of format and type
> against texture object's internal format when profile is OpenGL-ES 3.0+.

Blarg.  I see that we have nearly identical code in
teximage_error_check.  I think we should extract a bunch of this out to
a helper function that both can use... especially since you've
structured the code slightly different from what's in teximage_error_check.

> This patch also groups together all format and type checks into a single
> block of code for clarity.
> 
> Fixes 2 dEQP tests:
> * dEQP-GLES3.functional.negative_api.texture.texsubimage2d
> * dEQP-GLES3.functional.negative_api.texture.texsubimage3d
> ---
>  src/mesa/main/teximage.c | 57 ++++++++++++++++++++++++++++++------------------
>  1 file changed, 36 insertions(+), 21 deletions(-)
> 
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index c71b818..0b755ea 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -2493,19 +2493,12 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
>        return GL_TRUE;
>     }
>  
> -   /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
> -    * combinations of format and type that can be used.  Formats and types
> -    * that require additional extensions (e.g., GL_FLOAT requires
> -    * GL_OES_texture_float) are filtered elsewhere.
> -    */
> -   if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) {
> -      err = _mesa_es_error_check_format_and_type(format, type, dimensions);
> -      if (err != GL_NO_ERROR) {
> -         _mesa_error(ctx, err, "%s(format = %s, type = %s)",
> -                     callerName, _mesa_enum_to_string(format),
> -                     _mesa_enum_to_string(type));
> -         return GL_TRUE;
> -      }
> +   texImage = _mesa_select_tex_image(texObj, target, level);
> +   if (!texImage) {
> +      /* non-existant texture level */
> +      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture image)",
> +                  callerName);
> +      return GL_TRUE;
>     }
>  
>     err = _mesa_error_check_format_and_type(ctx, format, type);
> @@ -2517,6 +2510,36 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
>        return GL_TRUE;
>     }
>  
> +   /* OpenGL ES impose additional restrictions on the combinations of format
> +    * and type that can be used. Formats and types that require additional
> +    * extensions (e.g., GL_FLOAT requires GL_OES_texture_float) are filtered
> +    * elsewhere.
> +    */
> +   if (_mesa_is_gles(ctx)) {
> +      if (!_mesa_is_gles3(ctx)) {
> +         err = _mesa_es_error_check_format_and_type(format, type, dimensions);
> +         if (err != GL_NO_ERROR) {
> +            _mesa_error(ctx, err, "%s(format = %s, type = %s)",
> +                        callerName, _mesa_enum_to_string(format),
> +                        _mesa_enum_to_string(type));
> +            return GL_TRUE;
> +         }
> +      }
> +      else {
> +         err = _mesa_es3_error_check_format_and_type(ctx, format, type,
> +                                                     texImage->InternalFormat);
> +         if (err != GL_NO_ERROR) {
> +            _mesa_error(ctx, err,
> +                        "%s(incompatible format = %s, type = %s, "
> +                        "internalformat = %s)",
> +                        callerName, _mesa_enum_to_string(format),
> +                        _mesa_enum_to_string(type),
> +                        _mesa_enum_to_string(texImage->InternalFormat));
> +            return GL_TRUE;
> +         }
> +      }
> +   }
> +
>     /* validate the bound PBO, if any */
>     if (!_mesa_validate_pbo_source(ctx, dimensions, &ctx->Unpack,
>                                    width, height, depth, format, type,
> @@ -2524,14 +2547,6 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
>        return GL_TRUE;
>     }
>  
> -   texImage = _mesa_select_tex_image(texObj, target, level);
> -   if (!texImage) {
> -      /* non-existant texture level */
> -      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture image)",
> -                  callerName);
> -      return GL_TRUE;
> -   }
> -
>     if (error_check_subtexture_dimensions(ctx, dimensions,
>                                           texImage, xoffset, yoffset, zoffset,
>                                           width, height, depth, callerName)) {
> 



More information about the mesa-dev mailing list