[cogl] pipeline: Avoid reseting texture target for NULL textures
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] pipeline: Avoid reseting texture target for NULL textures
- Date: Thu, 30 Jun 2011 13:37:32 +0000 (UTC)
commit 098a19380215104f4dcf3474b4155f2d1b04f03d
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.
Signed-off-by: Neil Roberts <neil linux intel com>
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 45fc077..aba4d22 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]