[cogl/wip/neil/snippets: 3/22] attribute: Fix flushing custom attributes



commit 0d3266c19074af8a8c8cd7869816ccfa842515f1
Author: Neil Roberts <neil linux intel com>
Date:   Tue Nov 29 21:51:46 2011 +0000

    attribute: Fix flushing custom attributes
    
    There were two problems with flushing custom attributes:
    
    - The callback function to toggle the enabled attribute was assuming
      the bit indices are the Cogl interned numbers for the attribute
      names so it had to lookup the real location from the
      pipeline. However the bits are actually set according the the real
      GL number so it was enabling the wrong arrays. This also greatly
      simplifies the function.
    
    - The setup_generic_attribute function was using the wrong bitmask to
      enable the attribute so it wouldn't actually get enabled.

 cogl/cogl-attribute.c |   46 +++-------------------------------------------
 1 files changed, 3 insertions(+), 43 deletions(-)
---
diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c
index 547736f..72ee081 100644
--- a/cogl/cogl-attribute.c
+++ b/cogl/cogl-attribute.c
@@ -446,51 +446,11 @@ toggle_custom_attribute_enabled_cb (int bit_num, void *user_data)
   ForeachChangedBitState *state = user_data;
   gboolean enabled = _cogl_bitmask_get (state->new_bits, bit_num);
   CoglContext *context = state->context;
-  int enable_location;
-  int disable_location;
 
   if (enabled)
-    {
-      CoglPipeline *pipeline = state->pipeline;
-      CoglPipeline *prev_pipeline = context->current_pipeline;
-
-      enable_location =
-        _cogl_pipeline_progend_glsl_get_attrib_location (pipeline, bit_num);
-
-      if (G_LIKELY (prev_pipeline))
-        {
-          disable_location =
-            _cogl_pipeline_progend_glsl_get_attrib_location (prev_pipeline,
-                                                             bit_num);
-
-          if (enable_location != disable_location)
-            GE( context, glDisableVertexAttribArray (disable_location) );
-        }
-
-      GE( context, glEnableVertexAttribArray (enable_location) );
-    }
+    GE( context, glEnableVertexAttribArray (bit_num) );
   else
-    {
-      CoglPipeline *prev_pipeline = context->current_pipeline;
-
-      /* XXX: we only expect ctx->current_pipeline to be NULL the
-       * first time we are flushing a pipeline so we should never need
-       * to be disabling anything in that case.
-       *
-       * If we later change things so ctx->current_pipeline can be
-       * NULL at other times then this code will be affected because
-       * we need a way of mapping a name_index to a GLSL program
-       * attribute location which is currently only possible via the
-       * CoglPipelineProgramState associated with the currently
-       * flushed pipeline. */
-      _COGL_RETURN_VAL_IF_FAIL (prev_pipeline != NULL, TRUE);
-
-      disable_location =
-        _cogl_pipeline_progend_glsl_get_attrib_location (prev_pipeline,
-                                                         bit_num);
-
-      GE( context, glDisableVertexAttribArray (disable_location) );
-    }
+    GE( context, glDisableVertexAttribArray (bit_num) );
 
   return TRUE;
 }
@@ -535,7 +495,7 @@ setup_generic_attribute (CoglContext *context,
                                           attribute->normalized,
                                           attribute->stride,
                                           base + attribute->offset) );
-      _cogl_bitmask_set (&context->enabled_custom_attributes,
+      _cogl_bitmask_set (&context->enable_custom_attributes_tmp,
                          attrib_location, TRUE);
     }
 }



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