diff options
author | Fredrik Höglund <[email protected]> | 2013-11-12 17:34:35 +0100 |
---|---|---|
committer | Fredrik Höglund <[email protected]> | 2014-05-02 02:53:25 +0200 |
commit | 30af8ce3f807f8a4990fa8c750038b1f75e5154f (patch) | |
tree | 12953b30318c126cf4a7b949cbe852e88bed3474 /src/mesa/main/texobj.c | |
parent | 4bd82720880bef34895f34ac8141d0d9246b2b6d (diff) |
mesa: Optimize unbind_texobj_from_texunits()
The texture can only be bound to the index that corresponds to its
target, so there is no need to loop over all possible indices
for every unit and checking if the texture is bound to it.
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main/texobj.c')
-rw-r--r-- | src/mesa/main/texobj.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index a72b75317f9..43cf1c5c5a1 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1093,18 +1093,20 @@ static void unbind_texobj_from_texunits(struct gl_context *ctx, struct gl_texture_object *texObj) { - GLuint u, tex; + const gl_texture_index index = texObj->TargetIndex; + GLuint u; + + if (texObj->Target == 0) + return; for (u = 0; u < ctx->Texture.NumCurrentTexUsed; u++) { struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; - for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) { - if (texObj == unit->CurrentTex[tex]) { - _mesa_reference_texobj(&unit->CurrentTex[tex], - ctx->Shared->DefaultTex[tex]); - ASSERT(unit->CurrentTex[tex]); - unit->_BoundTextures &= ~(1 << tex); - break; - } + + if (texObj == unit->CurrentTex[index]) { + /* Bind the default texture for this unit/target */ + _mesa_reference_texobj(&unit->CurrentTex[index], + ctx->Shared->DefaultTex[index]); + unit->_BoundTextures &= ~(1 << index); } } } |