diff options
author | Robert Bragg <robert@linux.intel.com> | 2011-06-27 21:09:27 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2011-06-27 21:13:52 +0100 |
commit | 66ab889bb20d843518997458b41299a5abc02db0 (patch) | |
tree | 4a1d13c69bfc0f9313b2b36dc2e6f27b93c40025 | |
parent | 9670cf8567a87fb03ce859285605c266e0e1f7be (diff) | |
download | cogl-66ab889bb20d843518997458b41299a5abc02db0.tar.gz |
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.
-rw-r--r-- | cogl/cogl-pipeline.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c index 6e89c926..e1d5856c 100644 --- a/cogl/cogl-pipeline.c +++ b/cogl/cogl-pipeline.c @@ -2393,10 +2393,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; } @@ -2419,9 +2418,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); } |