From c0456a65658b9e5dea0e6f1fb48ae4bf0add23ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 3 Oct 2020 00:55:57 -0400 Subject: [PATCH] mesa: remove gl_texture_object references from glPush/PopAttrib stack MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I don't see why this is needed and it's not used anywhere. As long as apps don't call glDeleteTextures, nothing will release them. And even if they do, we don't use the saved textures anywhere. Also, BindTexture will fail for deleted textures anyway, so they can't be popped. The existing code already binds the Name that was saved, not the texture object that was saved. Reviewed-by: Zoltán Böszörményi Part-of: --- src/mesa/main/attrib.c | 24 +----------------------- src/mesa/main/mtypes.h | 6 ------ 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 0d16ee00163..b03457b56c0 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -232,16 +232,6 @@ _mesa_PushAttrib(GLbitfield mask) memcpy(&head->Texture.FixedFuncUnit, &ctx->Texture.FixedFuncUnit, sizeof(ctx->Texture.FixedFuncUnit)); - /* Save references to the currently bound texture objects so they don't - * accidentally get deleted while referenced in the attribute stack. - */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - _mesa_reference_texobj(&head->Texture.SavedTexRef[u][tex], - ctx->Texture.Unit[u].CurrentTex[tex]); - } - } - /* copy state/contents of the currently bound texture objects */ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { head->Texture.LodBias[u] = ctx->Texture.Unit[u].LodBias; @@ -606,11 +596,6 @@ pop_texture_group(struct gl_context *ctx, struct gl_texture_attrib_node *texstat sizeof(savedObj->Sampler.Attrib)); memcpy(&texObj->Attrib, &savedObj->Attrib, sizeof(savedObj->Attrib)); } - - /* remove saved references to the texture objects */ - for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&texstate->SavedTexRef[u][tgt], NULL); - } } if (!ctx->Driver.TexEnv && !ctx->Driver.TexGen) { @@ -1488,15 +1473,8 @@ _mesa_free_attrib_data(struct gl_context *ctx) ctx->AttribStackDepth--; attr = &ctx->AttribStack[ctx->AttribStackDepth]; - if (attr->Mask & GL_TEXTURE_BIT) { - /* clear references to the saved texture objects */ - for (unsigned u = 0; u < ctx->Const.MaxTextureUnits; u++) { - for (unsigned tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { - _mesa_reference_texobj(&attr->Texture.SavedTexRef[u][tgt], NULL); - } - } + if (attr->Mask & GL_TEXTURE_BIT) _mesa_reference_shared_state(ctx, &attr->Texture.SharedRef, NULL); - } } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 5993ae25172..bc42670855f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -5044,12 +5044,6 @@ struct gl_texture_attrib_node /** to save per texture object state (wrap modes, filters, etc): */ struct gl_texture_object SavedObj[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; - /** - * To save references to texture objects (so they don't get accidentally - * deleted while saved in the attribute stack). - */ - struct gl_texture_object *SavedTexRef[MAX_TEXTURE_UNITS][NUM_TEXTURE_TARGETS]; - /* We need to keep a reference to the shared state. That's where the * default texture objects are kept. We don't want that state to be * freed while the attribute stack contains pointers to any default -- 2.34.1