[cogl/cogl-1.16] Don't create a layer when enabling texture coordinate attributes



commit 2f4d66f95037382e94240efe5a11647e01eb312d
Author: Neil Roberts <neil linux intel com>
Date:   Fri Jun 21 18:01:48 2013 +0100

    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)

 cogl/driver/gl/cogl-attribute-gl.c |   43 ++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/cogl/driver/gl/cogl-attribute-gl.c b/cogl/driver/gl/cogl-attribute-gl.c
index c46bcf2..08354a8 100644
--- a/cogl/driver/gl/cogl-attribute-gl.c
+++ b/cogl/driver/gl/cogl-attribute-gl.c
@@ -251,17 +251,25 @@ setup_legacy_buffered_attribute (CoglContext *ctx,
     case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
       {
         int layer_number = attribute->name_state->layer_number;
+        const CoglPipelineGetLayerFlags flags =
+          COGL_PIPELINE_GET_LAYER_NO_CREATE;
         CoglPipelineLayer *layer =
-          _cogl_pipeline_get_layer (pipeline, layer_number);
-        int unit = _cogl_pipeline_layer_get_unit_index (layer);
+          _cogl_pipeline_get_layer_with_flags (pipeline, layer_number, flags);
 
-        _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));
-        GE (ctx, glTexCoordPointer (attribute->d.buffered.n_components,
-                                    attribute->d.buffered.type,
-                                    attribute->d.buffered.stride,
-                                    base + attribute->d.buffered.offset));
+            _cogl_bitmask_set (&ctx->enable_texcoord_attributes_tmp,
+                               unit,
+                               TRUE);
+
+            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;
       }
     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:
           {
             int layer_number = attribute->name_state->layer_number;
+            const CoglPipelineGetLayerFlags flags =
+              COGL_PIPELINE_GET_LAYER_NO_CREATE;
             CoglPipelineLayer *layer =
-              _cogl_pipeline_get_layer (pipeline, layer_number);
-            int unit = _cogl_pipeline_layer_get_unit_index (layer);
+              _cogl_pipeline_get_layer_with_flags (pipeline,
+                                                   layer_number,
+                                                   flags);
 
-            GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
+            if (layer)
+              {
+                int unit = _cogl_pipeline_layer_get_unit_index (layer);
+
+                GE (ctx, glClientActiveTexture (GL_TEXTURE0 + unit));
 
-            GE (ctx, glMultiTexCoord4f (vector[0], vector[1], vector[2], vector[3]));
+                GE (ctx, glMultiTexCoord4f (vector[0],
+                                            vector[1],
+                                            vector[2],
+                                            vector[3]));
+              }
             break;
           }
         case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]