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