[Mesa-dev] [PATCH] mesa: GLES2 should return different error enums for invalid fbo queries

Ian Romanick idr at freedesktop.org
Tue Jul 19 17:27:01 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/18/2011 06:11 PM, Marek Olšák wrote:
> ES 2.0.25 page 127 says:
> 
>   If the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is NONE, then
>   querying any other pname will generate INVALID_ENUM.

Hurray for be different just for the sake of being different!

> See also:
> b9e9df78a03edb35472c2e231aef4747e09db792
> 
> NOTE: This is a candidate for the 7.10 and 7.11 branches.
> ---
>  src/mesa/main/fbobject.c |   22 +++++++++++++++-------
>  1 files changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 8496936..1e11513 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -2134,10 +2134,13 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>  {
>     const struct gl_renderbuffer_attachment *att;
>     struct gl_framebuffer *buffer;
> +   GLboolean is_gl;
>     GET_CURRENT_CONTEXT(ctx);
>  
>     ASSERT_OUTSIDE_BEGIN_END(ctx);
>  
> +   is_gl = ctx->API == API_OPENGL;
> +

Maybe this would be better

   GLenum err = (ctx->API == API_OPENGL) ? GL_INVALID_OPERATION :
GL_INVALID_ENUM;

Every time I look at error generation code in Mesa, I feel a little ill.
 It always ends up being so much ugly code.  meh.

>     buffer = get_framebuffer_target(ctx, target);
>     if (!buffer) {
>        _mesa_error(ctx, GL_INVALID_ENUM,
> @@ -2188,7 +2191,12 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>        }
>        else {
>           assert(att->Type == GL_NONE);
> -         *params = 0;
> +         if (is_gl) {
> +            *params = 0;
> +         } else {
> +            _mesa_error(ctx, GL_INVALID_ENUM,
> +                        "glGetFramebufferAttachmentParameterivEXT(pname)");
> +         }
>        }
>        return;
>     case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT:
> @@ -2196,7 +2204,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>  	 *params = att->TextureLevel;
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, GL_INVALID_OPERATION,
> +         _mesa_error(ctx, is_gl ? GL_INVALID_OPERATION : GL_INVALID_ENUM,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else {
> @@ -2214,7 +2222,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>           }
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, GL_INVALID_OPERATION,
> +         _mesa_error(ctx, is_gl ? GL_INVALID_OPERATION : GL_INVALID_ENUM,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else {
> @@ -2232,7 +2240,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>           }
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, GL_INVALID_OPERATION,
> +         _mesa_error(ctx, is_gl ? GL_INVALID_OPERATION : GL_INVALID_ENUM,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else {
> @@ -2246,7 +2254,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, GL_INVALID_OPERATION,
> +         _mesa_error(ctx, is_gl ? GL_INVALID_OPERATION : GL_INVALID_ENUM,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else {
> @@ -2267,7 +2275,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>           return;
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, GL_INVALID_OPERATION,
> +         _mesa_error(ctx, is_gl ? GL_INVALID_OPERATION : GL_INVALID_ENUM,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else {
> @@ -2301,7 +2309,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, GL_INVALID_OPERATION,
> +         _mesa_error(ctx, is_gl ? GL_INVALID_OPERATION : GL_INVALID_ENUM,
>                       "glGetFramebufferAttachmentParameterivEXT(pname)");
>        }
>        else if (att->Texture) {
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk4mINUACgkQX1gOwKyEAw/O5ACdEu8vAh6KY0fa+/GJpMH9UwaM
hIEAn3VAcVw5XvNpHlXZ9YJP+st+MMJp
=SvMB
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list