cogl: Use a CoglBitmask to store the list of used texcoord arrays

Instead of directly using a guint32 to store a bitmask for each used
texcoord array, it now stores them in a CoglBitmask. This removes the
limitation of 32 layers (although there are still other places in Cogl
that imply this restriction). To disable texcoord arrays code should
call _cogl_disable_other_texcoord_arrays which takes a bitmask of
texcoord arrays that should not be disabled. There are two extra
bitmasks stored in the CoglContext which are used temporarily for this
function to avoid allocating a new bitmask each time.

http://bugzilla.openedhand.com/show_bug.cgi?id=2132
This commit is contained in:
Neil Roberts
2010-05-24 12:40:11 +01:00
parent 4fb784d111
commit aaf5600b2d
8 changed files with 56 additions and 35 deletions

View File

@ -1518,7 +1518,6 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
GLuint generic_index = 0;
#endif
unsigned long enable_flags = 0;
unsigned int texcoord_arrays_used = 0;
const GList *layers;
guint32 fallback_layers = 0;
int i;
@ -1534,6 +1533,8 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
memset (&options.wrap_mode_overrides, 0,
sizeof (options.wrap_mode_overrides));
_cogl_bitmask_clear_all (&ctx->temp_bitmask);
for (tmp = buffer->submitted_vbos; tmp != NULL; tmp = tmp->next)
{
CoglVertexBufferVBO *cogl_vbo = tmp->data;
@ -1596,7 +1597,8 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
gl_type,
attribute->stride,
pointer));
texcoord_arrays_used |= (1 << attribute->texture_unit);
_cogl_bitmask_set (&ctx->temp_bitmask,
attribute->texture_unit, TRUE);
break;
case COGL_VERTEX_BUFFER_ATTRIB_FLAG_VERTEX_ARRAY:
enable_flags |= COGL_ENABLE_VERTEX_ARRAY;
@ -1698,8 +1700,8 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
}
}
_cogl_disable_texcoord_arrays (ctx->texcoord_arrays_enabled &
~texcoord_arrays_used);
/* Disable any tex coord arrays that we didn't use */
_cogl_disable_other_texcoord_arrays (&ctx->temp_bitmask);
/* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the material state) when flushing the clip stack, so should