[Mesa-dev] [PATCH 2/3] mesa: Fix the error for glCopyBufferSubData() with a buffer of 0.

Ian Romanick idr at freedesktop.org
Thu Jan 26 14:03:44 PST 2012


On 01/25/2012 05:51 PM, Eric Anholt wrote:
> The INVALID_ENUM here may have been trying to catch someone passing
> something bogus as the target rather than having a non-buffer bound.
> The extension spec and the GL 3.2 specs doesn't say anything specific
> for error results for either bad target enums or things that aren't
> buffer objects other than "0".  Given that, provide at least correct
> behavior for the specified case.

Page 16 (page 32 of the PDF) of the OpenGL 3.0 spec says:

     "If a command that requires an enumerated value is passed a
     symbolic constant that is not one of those specified as
     allowable for that command, the error INVALID ENUM is
     generated. This is the case even if the argument is a
     pointer to a symbolic constant, if the value pointed to is
     not allowable for the given command."

> ---
>   src/mesa/main/bufferobj.c |    4 ++--
>   1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index e4f964f..471442c 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -1311,14 +1311,14 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
>
>      src = get_buffer(ctx, readTarget);

I think putting

    if (src == NULL) {
       _mesa_error(ctx, GL_INVALID_ENUM,
                   "glCopyBuffserSubData(readTarget = 0x%x)",
                   readTarget);
       return;
    }

and a similar block after the next get_buffer maintains all the correct 
error generation behavior.

>      if (!_mesa_is_bufferobj(src)) {
> -      _mesa_error(ctx, GL_INVALID_ENUM,
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>                     "glCopyBuffserSubData(readTarget = 0x%x)", readTarget);
>         return;
>      }
>
>      dst = get_buffer(ctx, writeTarget);
>      if (!_mesa_is_bufferobj(dst)) {
> -      _mesa_error(ctx, GL_INVALID_ENUM,
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>                     "glCopyBuffserSubData(writeTarget = 0x%x)", writeTarget);
>         return;
>      }



More information about the mesa-dev mailing list