<div dir="ltr"><div>I taken your recommendation: <a href="http://cgit.freedesktop.org/~ldeks/mesa/commit/?h=adsa-textures&id=c984a04159fa1febf6ec4a5e900961f88c06e84c">http://cgit.freedesktop.org/~ldeks/mesa/commit/?h=adsa-textures&id=c984a04159fa1febf6ec4a5e900961f88c06e84c</a><br><br></div>Thanks.<br><br>Laura<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 31, 2014 at 10:45 AM, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</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 Mon, Dec 15, 2014 at 5:22 PM, Laura Ekstrand <<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>> wrote:<br>
> In implementing ARB_DIRECT_STATE_ACCESS functions, it is often necessary to<br>
> abstract the functionality of a traditional GL API function into a backend<br>
> that both the traditional and dsa API functions can share.  For instance,<br>
> glTexParameteri and glTextureParameteri both call _mesa_texture_parameteri,<br>
> which takes a context object and a texture object as arguments.<br>
><br>
> The existance of such backend functions provides the opportunity for<br>
> driver internals (such as meta) to pass around the actual texture object<br>
> rather than its ID or target, saving on texture object storage and look-up<br>
> overhead.<br>
><br>
> This patch provides nameless texture creation and deletion for meta.  This<br>
> will be used in an upcoming refactor of meta.<br>
> ---<br>
>  src/mesa/main/texobj.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++<br>
>  src/mesa/main/texobj.h |  7 ++++++<br>
>  2 files changed, 67 insertions(+)<br>
><br>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c<br>
> index eb16f47..01088e3 100644<br>
> --- a/src/mesa/main/texobj.c<br>
> +++ b/src/mesa/main/texobj.c<br>
> @@ -1102,6 +1102,27 @@ invalidate_tex_image_error_check(struct gl_context *ctx, GLuint texture,<br>
>     return t;<br>
>  }<br>
><br>
> +/**<br>
> + * Wrapper for the driver function. Need this because _mesa_new_texture_object<br>
> + * permits a target of 0 and does not initialize targetIndex.<br>
> + */<br>
> +struct gl_texture_object *<br>
> +_mesa_create_nameless_texture( struct gl_context *ctx, GLenum target )<br>
> +{<br>
> +      struct gl_texture_object *texObj = NULL;<br>
> +      GLint targetIndex;<br>
> +<br>
> +      if (target == 0)<br>
> +         return texObj;<br>
> +<br>
> +      texObj = ctx->Driver.NewTextureObject(ctx, 0, target);<br>
> +      targetIndex = _mesa_tex_target_to_index(ctx, texObj->Target);<br>
> +      assert(targetIndex < NUM_TEXTURE_TARGETS);<br>
> +      texObj->TargetIndex = targetIndex;<br>
> +<br>
> +      return texObj;<br>
> +}<br>
> +<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>
> @@ -1405,6 +1426,45 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)<br>
>     }<br>
>  }<br>
><br>
> +/**<br>
> + * This deletes a texObj without altering the hash table.<br>
> + */<br>
> +void<br>
> +_mesa_delete_nameless_texture( struct gl_context *ctx,<br>
> +                               struct gl_texture_object *texObj )<br>
> +{<br>
> +   FLUSH_VERTICES(ctx, 0);<br>
> +   if (texObj) {<br>
</div></div>might use:<br>
if (!texObj)<br>
   return;<br>
<div><div class="h5">> +      _mesa_lock_texture(ctx, texObj);<br>
> +<br>
> +      /* Check if texture is bound to any framebuffer objects.<br>
> +       * If so, unbind.<br>
> +       * See section 4.4.2.3 of GL_EXT_framebuffer_object.<br>
> +       */<br>
> +      unbind_texobj_from_fbo(ctx, texObj);<br>
> +<br>
> +      /* Check if this texture is currently bound to any texture units.<br>
> +       * If so, unbind it.<br>
> +       */<br>
> +      unbind_texobj_from_texunits(ctx, texObj);<br>
> +<br>
> +      /* Check if this texture is currently bound to any shader<br>
> +       * image unit.  If so, unbind it.<br>
> +       * See section 3.9.X of GL_ARB_shader_image_load_store.<br>
> +       */<br>
> +      unbind_texobj_from_image_units(ctx, texObj);<br>
> +<br>
> +      _mesa_unlock_texture(ctx, texObj);<br>
> +<br>
> +      ctx->NewState |= _NEW_TEXTURE;<br>
> +<br>
> +      /* Unreference the texobj.  If refcount hits zero, the texture<br>
> +       * will be deleted.<br>
> +       */<br>
> +      _mesa_reference_texobj(&texObj, NULL);<br>
> +   }<br>
> +}<br>
> +<br>
><br>
>  /**<br>
>   * Convert a GL texture target enum such as GL_TEXTURE_2D or GL_TEXTURE_3D<br>
> diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h<br>
> index 34daebb..3a62d63 100644<br>
> --- a/src/mesa/main/texobj.h<br>
> +++ b/src/mesa/main/texobj.h<br>
> @@ -190,6 +190,13 @@ _mesa_unlock_context_textures( struct gl_context *ctx );<br>
>  extern void<br>
>  _mesa_lock_context_textures( struct gl_context *ctx );<br>
><br>
> +extern struct gl_texture_object *<br>
> +_mesa_create_nameless_texture( struct gl_context *ctx, GLenum target );<br>
> +<br>
> +extern void<br>
> +_mesa_delete_nameless_texture( struct gl_context *ctx,<br>
> +                               struct gl_texture_object *texObj );<br>
> +<br>
>  extern void<br>
>  _mesa_bind_texture_unit( struct gl_context *ctx,<br>
>                           GLuint unit,<br>
> --<br>
> 2.1.0<br>
><br>
</div></div>> _______________________________________________<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><br></div>