mesa: remove gl_texture_object references from glPush/PopAttrib stack
authorMarek Olšák <marek.olsak@amd.com>
Sat, 3 Oct 2020 04:55:57 +0000 (00:55 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 1 Dec 2020 11:52:11 +0000 (11:52 +0000)
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 <zboszor@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6946>

src/mesa/main/attrib.c
src/mesa/main/mtypes.h

index 0d16ee0..b03457b 100644 (file)
@@ -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);
-      }
    }
 }
 
index 5993ae2..bc42670 100644 (file)
@@ -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