From 098a19380215104f4dcf3474b4155f2d1b04f03d Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 27 Jun 2011 21:09:27 +0100 Subject: [PATCH] pipeline: Avoid reseting texture target for NULL textures When setting a NULL texture on a CoglPipeline we would also reset the texture target to a dummy value of 0. Reseting the target also had the effect of making fragends discard any associated program. In cases where the NULL texture was only transient until a replacement texture could be set we were re-running lots of redundant codegen and shader compilations. Signed-off-by: Neil Roberts --- cogl/cogl-pipeline.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 45fc077d5..aba4d2278 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -2384,10 +2384,9 @@ get_texture_target (CoglHandle texture) GLuint ignore_handle; GLenum gl_target; - if (texture) - cogl_texture_get_gl_texture (texture, &ignore_handle, &gl_target); - else - return 0;/* XXX: An invalid GL target enum */ + g_return_val_if_fail (texture, 0); + + cogl_texture_get_gl_texture (texture, &ignore_handle, &gl_target); return gl_target; } @@ -2410,9 +2409,14 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline, * do need to see if they use the same texture targets. Making this * distinction is much simpler if they are in different state * groups. + * + * Note: if a NULL texture is set then we leave the target unchanged + * so we can avoid needlessly invalidating any associated fragment + * program. */ - _cogl_pipeline_set_layer_texture_target (pipeline, layer_index, - get_texture_target (texture)); + if (texture) + _cogl_pipeline_set_layer_texture_target (pipeline, layer_index, + get_texture_target (texture)); _cogl_pipeline_set_layer_texture_data (pipeline, layer_index, texture); }