Mesa (master): mesa: Add a _BoundTextures field in gl_texture_unit

Fredrik Höglund fredrik at kemper.freedesktop.org
Fri May 2 01:21:26 UTC 2014


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

Author: Fredrik Höglund <fredrik at kde.org>
Date:   Tue Nov 12 17:28:12 2013 +0100

mesa: Add a _BoundTextures field in gl_texture_unit

This will be used by glBindTextures() when unbinding textures,
to avoid having to loop over all the targets.

Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/mtypes.h   |    3 +++
 src/mesa/main/texobj.c   |    6 ++++++
 src/mesa/main/texstate.c |    3 +++
 3 files changed, 12 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index c0a2f86..f31788a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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;
 };
 
 
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 42d057c..a72b753 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -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);
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 91b2906..19508cf 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -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;
 }
 
 




More information about the mesa-commit mailing list