From 114385b2cf0f6aa09725bece92ce8eae6e5823e2 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 19 Feb 2009 09:20:20 +0000 Subject: [PATCH] [cogl-material] Always glBindTexture when flushing material state Bug #1457 - Creating a new texture messes up the cogl material state cache; reported by Neil Roberts We still don't have caching of bound texture state so we always have to re-bind the texture when flushing the GL state of any material layers. --- common/cogl-material.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/common/cogl-material.c b/common/cogl-material.c index b7cf11c5f..7ee64196e 100644 --- a/common/cogl-material.c +++ b/common/cogl-material.c @@ -903,25 +903,6 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material, (fallback_mask & (1<current_layers->len) - { - gl_layer_info = - &g_array_index (ctx->current_layers, CoglLayerInfo, i); - -#ifndef DISABLE_MATERIAL_CACHE - if (gl_layer_info->handle == layer_handle && - !(layer->flags & COGL_MATERIAL_LAYER_FLAG_DIRTY) && - !(gl_layer_info->layer0_overridden || - new_gl_layer_info.layer0_overridden) && - (gl_layer_info->fallback - == new_gl_layer_info.fallback) && - (gl_layer_info->disabled - == new_gl_layer_info.disabled)) - { - continue; - } -#endif - } tex_handle = layer->texture; cogl_texture_get_gl_texture (tex_handle, &gl_texture, &gl_target); @@ -972,6 +953,29 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material, GE (glBindTexture (gl_target, gl_texture)); #endif + /* XXX: Once we add caching for glBindTexture state, these + * checks should be moved back up to the top of the loop! + */ + if (i < ctx->current_layers->len) + { + gl_layer_info = + &g_array_index (ctx->current_layers, CoglLayerInfo, i); + +#ifndef DISABLE_MATERIAL_CACHE + if (gl_layer_info->handle == layer_handle && + !(layer->flags & COGL_MATERIAL_LAYER_FLAG_DIRTY) && + !(gl_layer_info->layer0_overridden || + new_gl_layer_info.layer0_overridden) && + (gl_layer_info->fallback + == new_gl_layer_info.fallback) && + (gl_layer_info->disabled + == new_gl_layer_info.disabled)) + { + continue; + } +#endif + } + /* Disable the previous target if it was different */ #ifndef DISABLE_MATERIAL_CACHE if (gl_layer_info &&