[Mesa-dev] [PATCH 02/41] main: Created a standard function that looks up a texture object by its ID and throws INVALID_OPERATION if the ID isn't in the hash table.

Laura Ekstrand laura at jlekstrand.net
Wed Dec 17 17:51:49 PST 2014


That makes sense. It's now

main: Added utility function _mesa_lookup_texture_err().

On Wed, Dec 17, 2014 at 3:47 AM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
>
> Keep the subject of commit message short (under 50 chars) and use present
> tense.
> Here you can use "mesa: Add utility function _mesa_lookup_texture_error()".
>
> On Tue, Dec 16, 2014 at 6:52 AM, Laura Ekstrand <laura at jlekstrand.net>
> wrote:
> > Most ARB_DIRECT_STATE_ACCESS functions take an object's ID and use it to
> look
> > up the object in its hash table.  If the user passes a fake object ID
> (ie. a
> > non-generated name), the implementation should throw INVALID_OPERATION.
> > This is a convenience function for texture objects.
> > ---
> >  src/mesa/main/texobj.c | 17 ++++++++++++++++-
> >  src/mesa/main/texobj.h |  3 +++
> >  2 files changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> > index 923cf60..49ab2c4 100644
> > --- a/src/mesa/main/texobj.c
> > +++ b/src/mesa/main/texobj.c
> > @@ -60,6 +60,22 @@ _mesa_lookup_texture(struct gl_context *ctx, GLuint
> id)
> >        _mesa_HashLookup(ctx->Shared->TexObjects, id);
> >  }
> >
> > +/**
> > + * Wrapper around _mesa_lookup_texture that throws GL_INVALID_OPERATION
> if id
> > + * is not in the hash table. After calling _mesa_error, it returns NULL.
> > + */
> > +struct gl_texture_object *
> > +_mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char*
> func)
> I would use the name _mesa_lookup_texture_error() here.
> > +{
> > +   struct gl_texture_object *texObj;
> > +
> > +   texObj = _mesa_lookup_texture(ctx, id); /* Returns NULL if not
> found. */
> > +
> > +   if (!texObj)
> > +      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture)", func);
> > +
> > +   return texObj;
> > +}
> >
> >  void
> >  _mesa_begin_texture_lookups(struct gl_context *ctx)
> > @@ -1419,7 +1435,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
> >        ctx->Driver.BindTexture(ctx, ctx->Texture.CurrentUnit, target,
> newTexObj);
> >  }
> >
> > -
> unwanted change.
> >  void GLAPIENTRY
> >  _mesa_BindTextures(GLuint first, GLsizei count, const GLuint *textures)
> >  {
> > diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
> > index b1b7a30..abf03a1 100644
> > --- a/src/mesa/main/texobj.h
> > +++ b/src/mesa/main/texobj.h
> > @@ -46,6 +46,9 @@
> >  extern struct gl_texture_object *
> >  _mesa_lookup_texture(struct gl_context *ctx, GLuint id);
> >
> > +extern struct gl_texture_object *
> > +_mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char*
> func);
> > +
> >  extern void
> >  _mesa_begin_texture_lookups(struct gl_context *ctx);
> >
> > --
> > 2.1.0
> >
> > _______________________________________________
> > 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/20141217/04dd2643/attachment.html>


More information about the mesa-dev mailing list