<div dir="ltr"><div>These problems have all been corrected except one:<br><br><span style="font-family:arial,helvetica,sans-serif">In glGenTextures it is create_textures(ctx, 0 ... rather than GL_NONE because the original glGenTextures had the [now removed] line:<br></span><pre class=""><span style="font-family:arial,helvetica,sans-serif"><span class="">-      GLenum target = 0;<br></span></span></pre><pre class=""><span style="font-family:arial,helvetica,sans-serif"><span class="">So I passed in 0 to preserve the original functionality.<br><br><br></span></span></pre></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 17, 2014 at 6:20 AM, Fredrik Höglund <span dir="ltr"><<a href="mailto:fredrik@kde.org" target="_blank">fredrik@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tuesday 16 December 2014, Laura Ekstrand wrote:<br>
> ---<br>
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |   8 ++<br>
>  src/mesa/main/texobj.c                         | 109 +++++++++++++++++++------<br>
>  src/mesa/main/texobj.h                         |   2 +<br>
>  3 files changed, 92 insertions(+), 27 deletions(-)<br>
><br>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> index fcec608..9f2eacb 100644<br>
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml<br>
> @@ -7,5 +7,13 @@<br>
>     <enum name="QUERY_TARGET"    value="0x82EA"/><br>
>     <enum name="TEXTURE_BINDING" value="0x82EB"/><br>
><br>
> +   <!-- Texture object functions --><br>
> +<br>
> +   <function name="CreateTextures" offset="assign"><br>
> +      <param name="target" type="GLenum" /><br>
> +      <param name="n" type="GLsizei" /><br>
> +      <param name="textures" type="GLuint *" /><br>
> +   </function><br>
> +<br>
>  </category><br>
>  </OpenGLAPI><br>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c<br>
> index 6215fe3..26d07ee 100644<br>
> --- a/src/mesa/main/texobj.c<br>
> +++ b/src/mesa/main/texobj.c<br>
> @@ -1100,38 +1100,23 @@ invalidate_tex_image_error_check(struct gl_context *ctx, GLuint texture,<br>
>     return t;<br>
>  }<br>
><br>
> -/*@}*/<br>
> -<br>
> -<br>
> -/***********************************************************************/<br>
> -/** \name API functions */<br>
> -/*@{*/<br>
> -<br>
> -<br>
> -/**<br>
> - * Generate texture names.<br>
> - *<br>
> - * \param n number of texture names to be generated.<br>
> - * \param textures an array in which will hold the generated texture names.<br>
> - *<br>
> - * \sa glGenTextures().<br>
> - *<br>
> - * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture<br>
> - * IDs which are stored in \p textures.  Corresponding empty texture<br>
> - * objects are also generated.<br>
> - */<br>
> -void GLAPIENTRY<br>
> -_mesa_GenTextures( GLsizei n, GLuint *textures )<br>
> +/* Helper function for glCreateTextures and glGenTextures. Need this because<br>
> + * glCreateTextures should throw errors if target = 0. This is not exposed to<br>
> + * the rest of Mesa to encourage Mesa internals to use nameless textures,<br>
> + * which do not require expensive hash lookups. */<br>
> +static void<br>
> +create_textures( struct gl_context *ctx, GLenum target,<br>
> +   GLsizei n, GLuint *textures, bool dsa )<br>
>  {<br>
> -   GET_CURRENT_CONTEXT(ctx);<br>
>     GLuint first;<br>
>     GLint i;<br>
> +   const char *func = dsa ? "Create" : "Gen";<br>
><br>
>     if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))<br>
> -      _mesa_debug(ctx, "glGenTextures %d\n", n);<br>
> +      _mesa_debug(ctx, "gl%sTextures %d\n", func, n);<br>
><br>
>     if (n < 0) {<br>
> -      _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" );<br>
> +      _mesa_error( ctx, GL_INVALID_VALUE, "gl%sTextures", func );<br>
>        return;<br>
>     }<br>
><br>
> @@ -1148,15 +1133,28 @@ _mesa_GenTextures( GLsizei n, GLuint *textures )<br>
>     /* Allocate new, empty texture objects */<br>
>     for (i = 0; i < n; i++) {<br>
>        struct gl_texture_object *texObj;<br>
> +      GLint targetIndex;<br>
>        GLuint name = first + i;<br>
> -      GLenum target = 0;<br>
>        texObj = ctx->Driver.NewTextureObject(ctx, name, target);<br>
>        if (!texObj) {<br>
>           mtx_unlock(&ctx->Shared->Mutex);<br>
> -         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures");<br>
> +         _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sTextures", func);<br>
>           return;<br>
>        }<br>
><br>
> +      /* Initialize the target index if target is non-zero. */<br>
> +      if (target != 0)<br>
> +      {<br>
> +         targetIndex = _mesa_tex_target_to_index(ctx, texObj->Target);<br>
> +         if (targetIndex < 0) { /* Bad Target */<br>
> +            mtx_unlock(&ctx->Shared->Mutex);<br>
> +            _mesa_error(ctx, GL_INVALID_ENUM, "gl%sTextures(target)", func);<br>
<br>
</div></div>I suggest including the value passed in the target parameter in the error<br>
message.  The same goes for other error messages introduced this series.<br>
<div><div class="h5"><br>
> +            return;<br>
> +         }<br>
> +         assert(targetIndex < NUM_TEXTURE_TARGETS);<br>
> +         texObj->TargetIndex = targetIndex;<br>
> +      }<br>
> +<br>
>        /* insert into hash table */<br>
>        _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);<br>
><br>
> @@ -1166,6 +1164,63 @@ _mesa_GenTextures( GLsizei n, GLuint *textures )<br>
>     mtx_unlock(&ctx->Shared->Mutex);<br>
>  }<br>
><br>
> +/*@}*/<br>
> +<br>
> +<br>
> +/***********************************************************************/<br>
> +/** \name API functions */<br>
> +/*@{*/<br>
> +<br>
> +<br>
> +/**<br>
> + * Generate texture names.<br>
> + *<br>
> + * \param n number of texture names to be generated.<br>
> + * \param textures an array in which will hold the generated texture names.<br>
> + *<br>
> + * \sa glGenTextures(), glCreateTextures().<br>
> + *<br>
> + * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture<br>
> + * IDs which are stored in \p textures.  Corresponding empty texture<br>
> + * objects are also generated.<br>
> + */<br>
> +void GLAPIENTRY<br>
> +_mesa_GenTextures( GLsizei n, GLuint *textures )<br>
> +{<br>
> +   GET_CURRENT_CONTEXT(ctx);<br>
> +   create_textures(ctx, 0, n, textures, false);<br>
> +}<br>
> +<br>
> +/**<br>
> + * Create texture objects.<br>
> + *<br>
> + * \param target the texture target for each name to be generated.<br>
> + * \param n number of texture names to be generated.<br>
> + * \param textures an array in which will hold the generated texture names.<br>
> + *<br>
> + * \sa glCreateTextures(), glGenTextures().<br>
> + *<br>
> + * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture<br>
> + * IDs which are stored in \p textures.  Corresponding empty texture<br>
> + * objects are also generated.<br>
> + */<br>
> +void GLAPIENTRY<br>
> +_mesa_CreateTextures( GLenum target, GLsizei n, GLuint *textures )<br>
> +{<br>
> +   GLint targetIndex;<br>
> +   GET_CURRENT_CONTEXT(ctx);<br>
> +<br>
> +   /* The 4.5 core profile spec (20141030) doesn't specify what<br>
> +    * glCreateTextures should do with invalid targets, which was probably an<br>
> +    * oversight.  This conforms to the spec for glBindTexture. */<br>
> +   targetIndex = _mesa_tex_target_to_index(ctx, target);<br>
> +   if (targetIndex < 0) {<br>
> +      _mesa_error(ctx, GL_INVALID_ENUM, "glCreateTextures(target)");<br>
> +      return;<br>
> +   }<br>
<br>
</div></div>The target is error checked both here and in create_textures().<br>
<div class="HOEnZb"><div class="h5"><br>
> +   create_textures(ctx, target, n, textures, true);<br>
> +}<br>
><br>
>  /**<br>
>   * Check if the given texture object is bound to the current draw or<br>
> diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h<br>
> index 90cb51a..b957ac5 100644<br>
> --- a/src/mesa/main/texobj.h<br>
> +++ b/src/mesa/main/texobj.h<br>
> @@ -200,6 +200,8 @@ _mesa_lock_context_textures( struct gl_context *ctx );<br>
>  extern void GLAPIENTRY<br>
>  _mesa_GenTextures( GLsizei n, GLuint *textures );<br>
><br>
> +extern void GLAPIENTRY<br>
> +_mesa_CreateTextures( GLenum target, GLsizei n, GLuint *textures );<br>
><br>
>  extern void GLAPIENTRY<br>
>  _mesa_DeleteTextures( GLsizei n, const GLuint *textures );<br>
><br>
<br>
</div></div></blockquote></div><br></div>