cogl-material: Compare whether textures are equal by their GL handle
Textures within a layer were compared for equality by comparing their texture handle. However this means that sub textures and atlas textures which may be internally using the same GL handle would not be batched together. Instead it now tries to determine the underlying GL handle using either the slice override or _cogl_texture_get_gl_texture and then compares those.
This commit is contained in:
parent
8538bdbdea
commit
89c535f50d
@ -2640,18 +2640,26 @@ static gboolean
|
|||||||
_cogl_material_layer_texture_equal (CoglMaterialLayer *authority0,
|
_cogl_material_layer_texture_equal (CoglMaterialLayer *authority0,
|
||||||
CoglMaterialLayer *authority1)
|
CoglMaterialLayer *authority1)
|
||||||
{
|
{
|
||||||
if (authority0->texture != authority1->texture)
|
GLuint gl_handle0, gl_handle1;
|
||||||
return FALSE;
|
GLenum gl_target0, gl_target1;
|
||||||
|
|
||||||
if (authority0->texture_overridden != authority1->texture_overridden)
|
if (authority0->texture_overridden)
|
||||||
return FALSE;
|
{
|
||||||
|
gl_handle0 = authority0->slice_gl_texture;
|
||||||
|
gl_target0 = authority0->slice_gl_target;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cogl_texture_get_gl_texture (authority0->texture, &gl_handle0, &gl_target0);
|
||||||
|
|
||||||
if (authority0->texture_overridden &&
|
if (authority1->texture_overridden)
|
||||||
(authority0->slice_gl_texture != authority1->slice_gl_texture ||
|
{
|
||||||
authority0->slice_gl_target != authority1->slice_gl_target))
|
gl_handle1 = authority1->slice_gl_texture;
|
||||||
return FALSE;
|
gl_target1 = authority1->slice_gl_target;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cogl_texture_get_gl_texture (authority1->texture, &gl_handle1, &gl_target1);
|
||||||
|
|
||||||
return TRUE;
|
return gl_handle0 == gl_handle1 && gl_target0 == gl_target1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine the mask of differences between two layers.
|
/* Determine the mask of differences between two layers.
|
||||||
@ -3183,6 +3191,15 @@ simple_property_equal (CoglMaterial *material0,
|
|||||||
* It is acceptable to have false negatives - although they will result
|
* It is acceptable to have false negatives - although they will result
|
||||||
* in redundant OpenGL calls that try and update the state.
|
* in redundant OpenGL calls that try and update the state.
|
||||||
*
|
*
|
||||||
|
* When comparing texture layers, _cogl_material_equal will actually
|
||||||
|
* compare the underlying GL texture handle that the Cogl texture uses
|
||||||
|
* so that atlas textures and sub textures will be considered equal if
|
||||||
|
* they point to the same texture. This is useful for comparing
|
||||||
|
* materials in the journal but it means that _cogl_material_equal
|
||||||
|
* doesn't strictly compare whether the materials are the same. If we
|
||||||
|
* needed those semantics we could perhaps add another function or
|
||||||
|
* some flags to control the behaviour.
|
||||||
|
*
|
||||||
* False positives aren't allowed.
|
* False positives aren't allowed.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user