Mesa (master): mesa: Unbind deleted textures from the shader image units.

Francisco Jerez currojerez at kemper.freedesktop.org
Wed Jan 15 15:43:32 UTC 2014


Module: Mesa
Branch: master
Commit: ace31f4bc05ad35ef42626ecd667a4bbbe044ddc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ace31f4bc05ad35ef42626ecd667a4bbbe044ddc

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Fri Nov 22 19:54:47 2013 -0800

mesa: Unbind deleted textures from the shader image units.

>From ARB_shader_image_load_store:

   If a texture object bound to one or more image units is deleted by
   DeleteTextures, it is detached from each such image unit, as though
   BindImageTexture were called with <unit> identifying the image unit
   and <texture> set to zero.

Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
Reviewed-by: Paul Berry <stereotype441 at gmail.com>

---

 src/mesa/main/texobj.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 319dd1d..3c64c437 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1100,6 +1100,25 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
 
 
 /**
+ * Check if the given texture object is bound to any shader image unit
+ * and unbind it if that's the case.
+ */
+static void
+unbind_texobj_from_imgunits(struct gl_context *ctx,
+                            struct gl_texture_object *texObj)
+{
+   int i;
+
+   for (i = 0; i < ctx->Const.MaxImageUnits; i++) {
+      struct gl_image_unit *unit = &ctx->ImageUnits[i];
+
+      if (texObj == unit->TexObj)
+         _mesa_reference_texobj(&unit->TexObj, NULL);
+   }
+}
+
+
+/**
  * Delete named textures.
  *
  * \param n number of textures to be deleted.
@@ -1146,6 +1165,12 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
              */
             unbind_texobj_from_texunits(ctx, delObj);
 
+            /* Check if this texture is currently bound to any shader
+             * image unit.  If so, unbind it.
+             * See section 3.9.X of GL_ARB_shader_image_load_store.
+             */
+            unbind_texobj_from_imgunits(ctx, delObj);
+
             _mesa_unlock_texture(ctx, delObj);
 
             ctx->NewState |= _NEW_TEXTURE;




More information about the mesa-commit mailing list