diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 15bff7bd6fd..d91d5381a48 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -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? */ diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 436e082b763..22e68e6fd87 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -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]);