mesa: fix reuse of deleted texture object

Deleting a texture object will only cause it to be unbound from the
current context. To avoid reusing something that it still bound in
another context we need to check the DeletePending flag first.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Fixes: 842c91300f ("mesa: enable GL name reuse by default for all drivers except virgl")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12710
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12722
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12830
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34091>
This commit is contained in:
Timothy Arceri 2025-03-19 10:20:45 +11:00 committed by Marge Bot
parent 0f0834275d
commit 9b85142e40
2 changed files with 5 additions and 1 deletions

View file

@ -932,6 +932,7 @@ struct gl_texture_object
GLboolean _IsFloat; /**< GL_OES_float_texture */
GLboolean _IsHalfFloat; /**< GL_OES_half_float_texture */
bool HandleAllocated; /**< GL_ARB_bindless_texture */
bool DeletePending; /**< true if texture object is removed from the hash */
/* This should not be restored by glPopAttrib: */
bool StencilSampling; /**< Should we sample stencil instead of depth? */

View file

@ -1560,6 +1560,8 @@ delete_textures(struct gl_context *ctx, GLsizei n, const GLuint *textures)
*/
_mesa_make_texture_handles_non_resident(ctx, delObj);
delObj->DeletePending = true;
_mesa_unlock_texture(ctx, delObj);
ctx->NewState |= _NEW_TEXTURE_OBJECT;
@ -1985,7 +1987,8 @@ bind_textures(struct gl_context *ctx, GLuint first, GLsizei count,
struct gl_texture_object *current = texUnit->_Current;
struct gl_texture_object *texObj;
if (current && current->Name == textures[i])
if (current && !current->DeletePending &&
current->Name == textures[i])
texObj = current;
else
texObj = _mesa_lookup_texture_locked(ctx, textures[i]);