From 4e4e4c8ba1e7569b0a9ab0ae9b73ef0e18c5357f Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Fri, 16 Apr 2010 10:31:32 +0100 Subject: glBindTexture: Bail out earlier for redundant binds Commit 7f8000db8bd4 made it possible to bail out of glBindTexture early in single context environments when the user is rebinding the same texture name. This makes the early exit even earlier by comparing the given texName with texUnit->CurrentTex[targetIndex]->Name instead of waiting until we have validated the given texture name and found the corresponding gl_texture_object. If it matches then it's implicitly validated. --- src/mesa/main/texobj.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 1b61d3a63f..5ea2ad733d 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1065,6 +1065,20 @@ _mesa_BindTexture( GLenum target, GLuint texName ) } assert(targetIndex < NUM_TEXTURE_TARGETS); + /* Check if this texture is only used by this context and is already bound. + * If so, just return. + */ + { + GLboolean early_out; + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + early_out = ((ctx->Shared->RefCount == 1) + && (newTexObj == texUnit->CurrentTex[targetIndex])); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + if (early_out) { + return; + } + } + /* * Get pointer to new texture object (newTexObj) */ @@ -1105,20 +1119,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) assert(valid_texture_object(newTexObj)); - /* Check if this texture is only used by this context and is already bound. - * If so, just return. - */ - { - GLboolean early_out; - _glthread_LOCK_MUTEX(ctx->Shared->Mutex); - early_out = ((ctx->Shared->RefCount == 1) - && (newTexObj == texUnit->CurrentTex[targetIndex])); - _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - if (early_out) { - return; - } - } - /* flush before changing binding */ FLUSH_VERTICES(ctx, _NEW_TEXTURE); -- cgit v1.2.3