[Mesa-dev] [PATCH 2/2] mesa: don't clear proxy image fields when regular GL error is generated

Anuj Phogat anuj.phogat at gmail.com
Wed Aug 22 17:29:06 PDT 2012


On Tue, Aug 21, 2012 at 7:28 PM, Brian Paul <brianp at vmware.com> wrote:
> If a proxy texture call generates a regular GL error, we should not
> clear the proxy image's width/height/depth/format fields.  Use a new
> PROXY_ERROR token to distinguish proxy errors from regular GL errors.
>
> Some additional clean-ups could still be done but this fixes the problem
> at hand.
> ---
>  src/mesa/main/teximage.c |   41 ++++++++++++++++++++++++++++++-----------
>  1 files changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 95efa70..64dac61 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1537,6 +1537,13 @@ mutable_tex_object(struct gl_context *ctx, GLenum target)
>  }
>
>
> +/**
> + * Special value returned by error some texture error checking functions when
> + * an error is detected and the proxy texture image's width/height/depth/format
> + * fields should be zeroed-out.
> + */
> +#define PROXY_ERROR 2
> +
>
>  /**
>   * Test the glTexImage[123]D() parameters for errors.
> @@ -1553,13 +1560,14 @@ mutable_tex_object(struct gl_context *ctx, GLenum target)
>   * \param depth image depth given by the user.
>   * \param border image border given by the user.
>   *
> - * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
> + * \return PROXY_ERROR if there's an error that should zero-out the proxy image,
> + *         GL_TRUE if a regular GL error is found, or GL_FALSE if no error,
>   *
>   * Verifies each of the parameters against the constants specified in
>   * __struct gl_contextRec::Const and the supported extensions, and according
>   * to the OpenGL specification.
>   */
> -static GLboolean
> +static GLenum
>  texture_error_check( struct gl_context *ctx,
>                       GLuint dimensions, GLenum target,
>                       GLint level, GLint internalFormat,
> @@ -1622,12 +1630,16 @@ texture_error_check( struct gl_context *ctx,
>                                                      type, width, height,
>                                                      depth, border);
>     if (!sizeOK) {
> -      if (!isProxy) {
> +      if (isProxy) {
> +         /* No GL error is recorded, but we need to zero-out the image dims */
> +         return PROXY_ERROR;
> +      }
> +      else {
>           _mesa_error(ctx, GL_INVALID_VALUE,
>                       "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)",
>                       dimensions, level, width, height, depth);
> +         return GL_TRUE;
>        }
> -      return GL_TRUE;
>     }
>
>     /* Check internalFormat */
> @@ -2478,7 +2490,7 @@ teximage(struct gl_context *ctx, GLuint dims,
>           GLint border, GLenum format, GLenum type,
>           const GLvoid *pixels)
>  {
> -   GLboolean error;
> +   GLenum error;
>     struct gl_pixelstore_attrib unpack_no_border;
>     const struct gl_pixelstore_attrib *unpack = &ctx->Unpack;
>
> @@ -2511,12 +2523,12 @@ teximage(struct gl_context *ctx, GLuint dims,
>        struct gl_texture_image *texImage =
>           _mesa_get_proxy_tex_image(ctx, target, level);
>
> -      if (error) {
> -         /* when error, clear all proxy texture image parameters */
> +      if (error == PROXY_ERROR) {
> +         /* image too large, etc.  Clear all proxy texture image parameters. */
>           if (texImage)
>              clear_teximage_fields(texImage);
>        }
> -      else {
> +      else if (error == GL_FALSE) {
>           /* no error, set the tex image parameters */
>           struct gl_texture_object *texObj =
>              _mesa_get_current_tex_object(ctx, target);
> @@ -3100,7 +3112,7 @@ get_compressed_block_size(GLenum glformat, GLuint *bw, GLuint *bh)
>  /**
>   * Error checking for glCompressedTexImage[123]D().
>   * \param reason  returns reason for error, if any
> - * \return error code or GL_NO_ERROR.
> + * \return error code or GL_NO_ERROR or PROXY_ERROR.
>   */
>  static GLenum
>  compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
> @@ -3236,6 +3248,9 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
>                                       width, height, depth, border)) {
>        /* See error comment above */
>        *reason = "invalid width, height or format";
> +      if (target == proxyTarget) {
> +         return PROXY_ERROR;
> +      }
>        return GL_INVALID_OPERATION;
>     }
>
> @@ -3472,16 +3487,20 @@ compressedteximage(struct gl_context *ctx, GLuint dims,
>
>        texImage = _mesa_get_proxy_tex_image(ctx, target, level);
>        if (texImage) {
> -         if (error) {
> +         if (error == PROXY_ERROR) {
>              /* if error, clear all proxy texture image parameters */
>              clear_teximage_fields(texImage);
>           }
> -         else {
> +         else if (error == GL_NO_ERROR) {
>              /* no error: store the teximage parameters */
>              _mesa_init_teximage_fields(ctx, texImage, width, height,
>                                         depth, border, internalFormat,
>                                         MESA_FORMAT_NONE);
>           }
> +         else {
> +            /* other, regular error */
> +            _mesa_error(ctx, error, "glCompressedTexImage%uD(%s)", dims, reason);
> +         }
>        }
>     }
>     else {
> --
> 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