Mesa (mesa_7_5_branch): Fast path when rebinding the same texture in single context environment

Ian Romanick idr at kemper.freedesktop.org
Wed Jun 17 20:32:40 UTC 2009


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Wed Jun  3 17:49:05 2009 +0100

Fast path when rebinding the same texture in single context environment

If there is no shared context, there is no purpose in rebinding the same
texture.  In some artificial tests this improves performance 10% - 30%.
(cherry picked from commit 7f8000db8bd45bb95bda4a4f8535c49b8ef74254)

---

 src/mesa/main/texobj.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index b63f747..9b8d377 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -891,6 +891,7 @@ _mesa_BindTexture( GLenum target, GLuint texName )
    struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
    struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL;
    GLint targetIndex;
+   GLboolean early_out = GL_FALSE;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
@@ -944,6 +945,17 @@ _mesa_BindTexture( GLenum target, GLuint texName )
 
    assert(valid_texture_object(newTexObj));
 
+   _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+   if ((ctx->Shared->RefCount == 1)
+       && (newTexObj == texUnit->CurrentTex[targetIndex])) {
+      early_out = GL_TRUE;
+   }
+   _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+   if (early_out) {
+      return;
+   }
+
    /* flush before changing binding */
    FLUSH_VERTICES(ctx, _NEW_TEXTURE);
 




More information about the mesa-commit mailing list