From e4455041c8439ce9f5b5e1f9ee9c7e0a4927a4ec Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 1 Feb 2010 13:25:19 +0000 Subject: [PATCH] cogl-material: Compare GL texture numbers for material layer textures When deciding if a material layer is equal it now compares the GL target and texture number if the textures are not sliced. This is needed to get batching across atlased textures. --- cogl/cogl-material.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cogl/cogl-material.c b/cogl/cogl-material.c index 35e898f77..589a753db 100644 --- a/cogl/cogl-material.c +++ b/cogl/cogl-material.c @@ -1712,13 +1712,36 @@ _cogl_material_flush_gl_state (CoglHandle handle, 0, sizeof (CoglMaterialFlushOptions)); } +static gboolean +_cogl_material_texture_equal (CoglHandle texture0, CoglHandle texture1) +{ + GLenum gl_handle0, gl_handle1, gl_target0, gl_target1; + + /* If the texture handles are the same then the textures are + definitely equal */ + if (texture0 == texture1) + return TRUE; + + /* If neither texture is sliced then they could still be the same if + the are referring to the same GL texture */ + if (cogl_texture_is_sliced (texture0) || + cogl_texture_is_sliced (texture1)) + return FALSE; + + cogl_texture_get_gl_texture (texture0, &gl_handle0, &gl_target0); + cogl_texture_get_gl_texture (texture1, &gl_handle1, &gl_target1); + + return gl_handle0 == gl_handle1 && gl_target0 == gl_target1; +} + static gboolean _cogl_material_layer_equal (CoglMaterialLayer *material0_layer, CoglHandle material0_layer_texture, CoglMaterialLayer *material1_layer, CoglHandle material1_layer_texture) { - if (material0_layer_texture != material1_layer_texture) + if (!_cogl_material_texture_equal (material0_layer_texture, + material1_layer_texture)) return FALSE; if ((material0_layer->flags & COGL_MATERIAL_LAYER_FLAG_DEFAULT_COMBINE) !=