Don't create a layer when enabling texture coordinate attributes

When a primitive is drawn with an attribute that contains texture
coordinates Cogl will fetch the corresponding layer in order to
determine the unit number. However if the pipeline didn't actually
have a layer it would end up redundantly creating it. It's probably
not a good idea to be modifying the pipeline while flushing the
attributes state so this patch makes it pass the no-create flag to the
get_layer function and then skips out enabling the attribute if the
layer didn't already exist.

https://bugzilla.gnome.org/show_bug.cgi?id=702570

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 7507ad1a55a2aeb5beb8c0e3343e1e1f2805ddde)
This commit is contained in:
Neil Roberts 2013-06-21 18:01:48 +01:00
parent e926c1dab4
commit 2f4d66f950

View File

@ -251,17 +251,25 @@ setup_legacy_buffered_attribute (CoglContext *ctx,
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
{ {
int layer_number = attribute->name_state->layer_number; int layer_number = attribute->name_state->layer_number;
const CoglPipelineGetLayerFlags flags =
COGL_PIPELINE_GET_LAYER_NO_CREATE;
CoglPipelineLayer *layer = CoglPipelineLayer *layer =
_cogl_pipeline_get_layer (pipeline, layer_number); _cogl_pipeline_get_layer_with_flags (pipeline, layer_number, flags);
int unit = _cogl_pipeline_layer_get_unit_index (layer);
_cogl_bitmask_set (&ctx->enable_texcoord_attributes_tmp, unit, TRUE); if (layer)
{
int unit = _cogl_pipeline_layer_get_unit_index (layer);
GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit)); _cogl_bitmask_set (&ctx->enable_texcoord_attributes_tmp,
GE (ctx, glTexCoordPointer (attribute->d.buffered.n_components, unit,
attribute->d.buffered.type, TRUE);
attribute->d.buffered.stride,
base + attribute->d.buffered.offset)); GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
GE (ctx, glTexCoordPointer (attribute->d.buffered.n_components,
attribute->d.buffered.type,
attribute->d.buffered.stride,
base + attribute->d.buffered.offset));
}
break; break;
} }
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY: case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
@ -316,13 +324,24 @@ setup_legacy_const_attribute (CoglContext *ctx,
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
{ {
int layer_number = attribute->name_state->layer_number; int layer_number = attribute->name_state->layer_number;
const CoglPipelineGetLayerFlags flags =
COGL_PIPELINE_GET_LAYER_NO_CREATE;
CoglPipelineLayer *layer = CoglPipelineLayer *layer =
_cogl_pipeline_get_layer (pipeline, layer_number); _cogl_pipeline_get_layer_with_flags (pipeline,
int unit = _cogl_pipeline_layer_get_unit_index (layer); layer_number,
flags);
GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit)); if (layer)
{
int unit = _cogl_pipeline_layer_get_unit_index (layer);
GE (ctx, glMultiTexCoord4f (vector[0], vector[1], vector[2], vector[3])); GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
GE (ctx, glMultiTexCoord4f (vector[0],
vector[1],
vector[2],
vector[3]));
}
break; break;
} }
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY: case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY: