/** Largest index of a texture unit with _Current != NULL. */
GLint _MaxEnabledTexImageUnit;
+
+ /** Largest index + 1 of texture units that have had any CurrentTex set. */
+ GLint NumCurrentTexUsed;
};
{
GLuint u, tex;
- for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ 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]) {
* count hits zero.
*/
_mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj);
+ ctx->Texture.NumCurrentTexUsed = MAX2(ctx->Texture.NumCurrentTexUsed,
+ ctx->Texture.CurrentUnit + 1);
ASSERT(texUnit->CurrentTex[targetIndex]);
/* Pass BindTexture call to device driver */
for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
_mesa_reference_texobj(&dst->Texture.Unit[u].CurrentTex[tex],
src->Texture.Unit[u].CurrentTex[tex]);
+ if (src->Texture.Unit[u].CurrentTex[tex]) {
+ dst->Texture.NumCurrentTexUsed =
+ MAX2(dst->Texture.NumCurrentTexUsed, u + 1);
+ }
}
_mesa_unlock_context_textures(dst);
}
_mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject,
ctx->Shared->NullBufferObj);
+ ctx->Texture.NumCurrentTexUsed = 0;
+
return GL_TRUE;
}