[Mesa-dev] [PATCH 02/22] mesa: Add _mesa_lookup_vao_err

Laura Ekstrand laura at jlekstrand.net
Fri Mar 20 15:32:34 PDT 2015


On Wed, Mar 18, 2015 at 4:18 PM, Fredrik Höglund <fredrik at kde.org> wrote:

> ---
>  src/mesa/main/arrayobj.c | 50
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  src/mesa/main/arrayobj.h |  3 +++
>  2 files changed, 53 insertions(+)
>
> diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
> index 0c15630..ac081b0 100644
> --- a/src/mesa/main/arrayobj.c
> +++ b/src/mesa/main/arrayobj.c
> @@ -75,6 +75,56 @@ _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
>
>
>  /**
> + * Looks up the array object for the given ID.
> + *
> + * Unlike _mesa_lookup_vao, this function generates a GL_INVALID_OPERATION
> + * error if the buffer object does not exist. It also returns the default
> + * array object when id is zero, and ctx is a compatibility profile
> context.
> + */
> +struct gl_vertex_array_object *
> +_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char
> *caller)
> +{
> +   /* The ARB_direct_state_access specification says:
> +    *
> +    *    "<vaobj> is [compatibility profile:
> +    *     zero, indicating the default vertex array object, or]
> +    *     the name of the vertex array object."
> +    */
> +   if (id == 0) {
> +      if (ctx->API == API_OPENGL_CORE) {
> +         _mesa_error(ctx, GL_INVALID_OPERATION,
> +                     "%s(zero is not valid vaobj name in a core profile "
> +                     "context)", caller);
>
Maybe a more concise error message such as "%s(id = 0 is invalid for core
profile)" ?

> +         return NULL;
> +      }
> +
> +      return ctx->Array.DefaultVAO;
> +   } else {
> +      struct gl_vertex_array_object *vao =
> +         (struct gl_vertex_array_object *)
> +         _mesa_HashLookup(ctx->Array.Objects, id);
> +
> +      /* The ARB_direct_state_access specification says:
> +       *
> +       *    "An INVALID_OPERATION error is generated if <vaobj> is not
> +       *     [compatibility profile: zero or] the name of an existing
> +       *     vertex array object."
> +       */
> +      if (!vao || !vao->EverBound) {
> +         const char *format = ctx->API == API_OPENGL_CORE ?
> +            "%s(vaobj=%d is not the name of an existing vertex array
> object)" :
> +            "%s(vaobj=%d is not zero or the name of an existing vertex "
> +            "array object)";
>
Maybe more concise error messages like "%s(non-existent vaobj=%d)" and
"%s(non-existent, non-zero vaobj=%d)" ?

> +         _mesa_error(ctx, GL_INVALID_OPERATION, format, caller, id);
> +         return NULL;
> +      }
> +
> +      return vao;
> +   }
> +}
> +
> +
> +/**
>   * For all the vertex binding points in the array object, unbind any
> pointers
>   * to any buffer objects (VBOs).
>   * This is done just prior to array object destruction.
> diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
> index ae671e3..1e7436b 100644
> --- a/src/mesa/main/arrayobj.h
> +++ b/src/mesa/main/arrayobj.h
> @@ -49,6 +49,9 @@ extern struct gl_vertex_array_object *
>  _mesa_lookup_vao(struct gl_context *ctx, GLuint id);
>
>  extern struct gl_vertex_array_object *
> +_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char
> *caller);
> +
> +extern struct gl_vertex_array_object *
>  _mesa_new_vao(struct gl_context *ctx, GLuint name);
>
>  extern void
> --
> 1.8.5.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150320/066f5243/attachment.html>


More information about the mesa-dev mailing list