[cogl/wip/example-crate: 15/20] pipeline: Avoid reseting texture target for NULL textures
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/example-crate: 15/20] pipeline: Avoid reseting texture target for NULL textures
- Date: Wed, 29 Jun 2011 15:13:23 +0000 (UTC)
commit 66ab889bb20d843518997458b41299a5abc02db0
Author: Robert Bragg <robert linux intel com>
Date: Mon Jun 27 21:09:27 2011 +0100
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.
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 6e89c92..e1d5856 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]