summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2009-06-03 17:49:05 +0100
committerIan Romanick <ian.d.romanick@intel.com>2009-06-03 17:50:37 +0100
commit7f8000db8bd45bb95bda4a4f8535c49b8ef74254 (patch)
tree445cccb492aac0eba9be2c45e8190f05c4a29738 /src
parent54576130a88fe93a64367f882cd680e37f0ec0ac (diff)
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%.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/texobj.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index d51e7b76ec..2082f945f1 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -945,6 +945,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))
@@ -998,6 +999,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);