mesa: Add a _BoundTextures field in gl_texture_unit
authorFredrik Höglund <fredrik@kde.org>
Tue, 12 Nov 2013 16:28:12 +0000 (17:28 +0100)
committerFredrik Höglund <fredrik@kde.org>
Fri, 2 May 2014 00:53:25 +0000 (02:53 +0200)
This will be used by glBindTextures() when unbinding textures,
to avoid having to loop over all the targets.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/mtypes.h
src/mesa/main/texobj.c
src/mesa/main/texstate.c

index c0a2f866e6da2ea5398ba44492fc46299f82f935..f31788aefab7db977c5d20cd9f41606384bb222d 100644 (file)
@@ -1370,6 +1370,9 @@ struct gl_texture_unit
 
    /** Points to highest priority, complete and enabled texture object */
    struct gl_texture_object *_Current;
+
+   /** Texture targets that have a non-default texture bound */
+   GLbitfield _BoundTextures;
 };
 
 
index 42d057c6ae367f548a09961694f3e35ecf042c66..a72b75317f990f8dee81a34e558289b9ec5b73de 100644 (file)
@@ -1102,6 +1102,7 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
             _mesa_reference_texobj(&unit->CurrentTex[tex],
                                    ctx->Shared->DefaultTex[tex]);
             ASSERT(unit->CurrentTex[tex]);
+            unit->_BoundTextures &= ~(1 << tex);
             break;
          }
       }
@@ -1359,6 +1360,11 @@ _mesa_BindTexture( GLenum target, GLuint texName )
                                          ctx->Texture.CurrentUnit + 1);
    ASSERT(texUnit->CurrentTex[targetIndex]);
 
+   if (texName != 0)
+      texUnit->_BoundTextures |= (1 << targetIndex);
+   else
+      texUnit->_BoundTextures &= ~(1 << targetIndex);
+
    /* Pass BindTexture call to device driver */
    if (ctx->Driver.BindTexture)
       ctx->Driver.BindTexture(ctx, target, newTexObj);
index 91b29069169bf7a515f1997902c6db10d0a472fe..19508cf39d009768b743f79d6aeabc5df4a8c2c1 100644 (file)
@@ -113,6 +113,7 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
                   MAX2(dst->Texture.NumCurrentTexUsed, u + 1);
             }
          }
+         dst->Texture.Unit[u]._BoundTextures = src->Texture.Unit[u]._BoundTextures;
          _mesa_unlock_context_textures(dst);
       }
    }
@@ -877,6 +878,8 @@ init_texture_unit( struct gl_context *ctx, GLuint unit )
       _mesa_reference_texobj(&texUnit->CurrentTex[tex],
                              ctx->Shared->DefaultTex[tex]);
    }
+
+   texUnit->_BoundTextures = 0;
 }