[Mesa-dev] [PATCH] mesa: Make sure the buffer exists in _mesa_lookup_bufferobj_err

Fredrik Höglund fredrik at kde.org
Thu Mar 19 17:05:17 PDT 2015


On Friday 20 March 2015, Anuj Phogat wrote:
> On Thu, Mar 19, 2015 at 4:29 PM, Laura Ekstrand <laura at jlekstrand.net> wrote:
> > You are right; I missed that subtle OpenGL definition of "exist" in the
> > lookup functions.
> >
> > On Thu, Mar 19, 2015 at 3:48 PM, Fredrik Höglund <fredrik at kde.org> wrote:
> >>
> >> Generate GL_INVALID_OPERATION and return NULL when the buffer object
> >> hasn't been created.  All callers expect this.
> >>
> >> Cc: Laura Ekstrand <laura at jlekstrand.net>
> >> ---
> >>  src/mesa/main/bufferobj.c | 11 +++++++----
> >>  1 file changed, 7 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> >> index 78d3d78..41455f3 100644
> >> --- a/src/mesa/main/bufferobj.c
> >> +++ b/src/mesa/main/bufferobj.c
> >> @@ -1003,8 +1003,8 @@ _mesa_lookup_bufferobj_locked(struct gl_context
> >> *ctx, GLuint buffer)
> >>
> >>  /**
> >>   * A convenience function for direct state access functions that throws
> >> - * GL_INVALID_OPERATION if buffer is not the name of a buffer object in
> >> the
> >> - * hash table.
> >> + * GL_INVALID_OPERATION if buffer is not the name of an existing
> >> + * buffer object.
> >>   */
> >>  struct gl_buffer_object *
> >>  _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
> >> @@ -1013,9 +1013,12 @@ _mesa_lookup_bufferobj_err(struct gl_context *ctx,
> >> GLuint buffer,
> >>     struct gl_buffer_object *bufObj;
> >>
> >>     bufObj = _mesa_lookup_bufferobj(ctx, buffer);
> >> -   if (!bufObj)
> >> +   if (!bufObj || bufObj == &DummyBufferObject) {
> >>        _mesa_error(ctx, GL_INVALID_OPERATION,
> >> -                  "%s(non-generated buffer name %u)", caller, buffer);
> >
> > This should be more concise.  How about "%s(non-existent buffer object %u)"
> > ?
> How about "%s(non-generated buffer object name %u)" ? Existing one is not
> bad either. Adding object makes it more clear.

The point of the change is that generated does not mean that
the buffer object exists.

> >>
> >> +                  "%s(%u is not the name of an existing buffer object)",
> >> +                  caller, buffer);
> >> +      return NULL;
> >> +   }
> >>
> >>     return bufObj;
> >>  }
> >> --
> >> 2.1.4
> >>
> >
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
> 
> Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
> 



More information about the mesa-dev mailing list