[mutter] cogl: Remove never-changing COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE state



commit e71f44dbd60ce540f8b4b1308b1be7e44a30ab66
Author: Adam Jackson <ajax redhat com>
Date:   Fri Mar 8 12:42:55 2019 -0500

    cogl: Remove never-changing COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE state
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/546

 cogl/cogl/cogl-pipeline-layer-private.h          |  11 --
 cogl/cogl/cogl-pipeline-layer-state-private.h    |  10 --
 cogl/cogl/cogl-pipeline-layer-state.c            | 131 +----------------------
 cogl/cogl/cogl-pipeline-layer.c                  |  16 ---
 cogl/cogl/cogl-pipeline.c                        |   5 +-
 cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c |  10 +-
 cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c |   5 +-
 7 files changed, 7 insertions(+), 181 deletions(-)
---
diff --git a/cogl/cogl/cogl-pipeline-layer-private.h b/cogl/cogl/cogl-pipeline-layer-private.h
index b4080c96b..e40003319 100644
--- a/cogl/cogl/cogl-pipeline-layer-private.h
+++ b/cogl/cogl/cogl-pipeline-layer-private.h
@@ -55,7 +55,6 @@ typedef enum
 {
   /* sparse state */
   COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
-  COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
   COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
   COGL_PIPELINE_LAYER_STATE_SAMPLER_INDEX,
   COGL_PIPELINE_LAYER_STATE_COMBINE_INDEX,
@@ -82,8 +81,6 @@ typedef enum
 {
   COGL_PIPELINE_LAYER_STATE_UNIT =
     1L<<COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
-  COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE =
-    1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
   COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA =
     1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
   COGL_PIPELINE_LAYER_STATE_SAMPLER =
@@ -237,11 +234,6 @@ struct _CoglPipelineLayer
   /* Each layer is directly associated with a single texture unit */
   int                        unit_index;
 
-  /* The type of the texture. This is always set even if the texture
-     is NULL and it will be used to determine what type of texture
-     lookups to use in any shaders generated by the pipeline
-     backends. */
-  CoglTextureType            texture_type;
   /* The texture for this layer, or NULL for an empty
    * layer */
   CoglTexture               *texture;
@@ -347,9 +339,6 @@ _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
 CoglTexture *
 _cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
 
-CoglTextureType
-_cogl_pipeline_layer_get_texture_type (CoglPipelineLayer *layer);
-
 CoglPipelineFilter
 _cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer);
 
diff --git a/cogl/cogl/cogl-pipeline-layer-state-private.h b/cogl/cogl/cogl-pipeline-layer-state-private.h
index 75589019a..a09208964 100644
--- a/cogl/cogl/cogl-pipeline-layer-state-private.h
+++ b/cogl/cogl/cogl-pipeline-layer-state-private.h
@@ -50,11 +50,6 @@ CoglPipelineFilter
 _cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline,
                                      int layer_index);
 
-gboolean
-_cogl_pipeline_layer_texture_type_equal (CoglPipelineLayer *authority0,
-                                         CoglPipelineLayer *authority1,
-                                         CoglPipelineEvalFlags flags);
-
 gboolean
 _cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
                                          CoglPipelineLayer *authority1,
@@ -93,11 +88,6 @@ _cogl_pipeline_layer_hash_unit_state (CoglPipelineLayer *authority,
                                       CoglPipelineLayer **authorities,
                                       CoglPipelineHashState *state);
 
-void
-_cogl_pipeline_layer_hash_texture_type_state (CoglPipelineLayer *authority,
-                                              CoglPipelineLayer **authorities,
-                                              CoglPipelineHashState *state);
-
 void
 _cogl_pipeline_layer_hash_texture_data_state (CoglPipelineLayer *authority,
                                               CoglPipelineLayer **authorities,
diff --git a/cogl/cogl/cogl-pipeline-layer-state.c b/cogl/cogl/cogl-pipeline-layer-state.c
index eeca3953c..f3ce3767c 100644
--- a/cogl/cogl/cogl-pipeline-layer-state.c
+++ b/cogl/cogl/cogl-pipeline-layer-state.c
@@ -136,87 +136,6 @@ cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
   return _cogl_pipeline_layer_get_texture (layer);
 }
 
-CoglTextureType
-_cogl_pipeline_layer_get_texture_type (CoglPipelineLayer *layer)
-{
-  CoglPipelineLayer *authority =
-    _cogl_pipeline_layer_get_authority (layer,
-                                        COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE);
-
-  return authority->texture_type;
-}
-
-static void
-_cogl_pipeline_set_layer_texture_type (CoglPipeline *pipeline,
-                                       int layer_index,
-                                       CoglTextureType texture_type)
-{
-  CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE;
-  CoglPipelineLayer *layer;
-  CoglPipelineLayer *authority;
-  CoglPipelineLayer *new;
-
-  /* Note: this will ensure that the layer exists, creating one if it
-   * doesn't already.
-   *
-   * Note: If the layer already existed it's possibly owned by another
-   * pipeline. If the layer is created then it will be owned by
-   * pipeline. */
-  layer = _cogl_pipeline_get_layer (pipeline, layer_index);
-
-  /* Now find the ancestor of the layer that is the authority for the
-   * state we want to change */
-  authority = _cogl_pipeline_layer_get_authority (layer, change);
-
-  if (texture_type == authority->texture_type)
-    return;
-
-  new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, change);
-  if (new != layer)
-    layer = new;
-  else
-    {
-      /* If the original layer we found is currently the authority on
-       * the state we are changing see if we can revert to one of our
-       * ancestors being the authority. */
-      if (layer == authority &&
-          _cogl_pipeline_layer_get_parent (authority) != NULL)
-        {
-          CoglPipelineLayer *parent =
-            _cogl_pipeline_layer_get_parent (authority);
-          CoglPipelineLayer *old_authority =
-            _cogl_pipeline_layer_get_authority (parent, change);
-
-          if (old_authority->texture_type == texture_type)
-            {
-              layer->differences &= ~change;
-
-              g_assert (layer->owner == pipeline);
-              if (layer->differences == 0)
-                _cogl_pipeline_prune_empty_layer_difference (pipeline,
-                                                             layer);
-              goto changed;
-            }
-        }
-    }
-
-  layer->texture_type = texture_type;
-
-  /* If we weren't previously the authority on this state then we need
-   * to extended our differences mask and so it's possible that some
-   * of our ancestry will now become redundant, so we aim to reparent
-   * ourselves if that's true... */
-  if (layer != authority)
-    {
-      layer->differences |= change;
-      _cogl_pipeline_layer_prune_redundant_ancestry (layer);
-    }
-
-changed:
-
-  pipeline->dirty_real_blend_enable = TRUE;
-}
-
 static void
 _cogl_pipeline_set_layer_texture_data (CoglPipeline *pipeline,
                                        int layer_index,
@@ -301,32 +220,6 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
                                  int layer_index,
                                  CoglTexture *texture)
 {
-  /* For the convenience of fragend code we separate texture state
-   * into the "type" and the "data", and setting a layer texture
-   * updates both of these properties.
-   *
-   * One example for why this is helpful is that the fragends may
-   * cache programs they generate and want to re-use those programs
-   * with all pipelines having equivalent fragment processing state.
-   * For the sake of determining if pipelines have equivalent fragment
-   * processing state we don't need to compare that the same
-   * underlying texture objects are referenced by the pipelines but we
-   * do need to see if they use the same texture types. Making this
-   * distinction is much simpler if they are in different state
-   * groups.
-   *
-   * Note: if a NULL texture is set then we leave the type unchanged
-   * so we can avoid needlessly invalidating any associated fragment
-   * program.
-   */
-  if (texture)
-    {
-      CoglTextureType texture_type =
-        _cogl_texture_get_type (texture);
-      _cogl_pipeline_set_layer_texture_type (pipeline,
-                                             layer_index,
-                                             texture_type);
-    }
   _cogl_pipeline_set_layer_texture_data (pipeline, layer_index, texture);
 }
 
@@ -335,7 +228,6 @@ cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline,
                                       int layer_index,
                                       CoglTextureType texture_type)
 {
-  _cogl_pipeline_set_layer_texture_type (pipeline, layer_index, texture_type);
   _cogl_pipeline_set_layer_texture_data (pipeline, layer_index, NULL);
 }
 
@@ -922,14 +814,6 @@ cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
                                                snippet);
 }
 
-gboolean
-_cogl_pipeline_layer_texture_type_equal (CoglPipelineLayer *authority0,
-                                         CoglPipelineLayer *authority1,
-                                         CoglPipelineEvalFlags flags)
-{
-  return authority0->texture_type == authority1->texture_type;
-}
-
 gboolean
 _cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
                                          CoglPipelineLayer *authority1,
@@ -938,8 +822,7 @@ _cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
   if (authority0->texture == NULL)
     {
       if (authority1->texture == NULL)
-        return (_cogl_pipeline_layer_get_texture_type (authority0) ==
-                _cogl_pipeline_layer_get_texture_type (authority1));
+        return TRUE;
       else
         return FALSE;
     }
@@ -1619,18 +1502,6 @@ _cogl_pipeline_layer_hash_unit_state (CoglPipelineLayer *authority,
     _cogl_util_one_at_a_time_hash (state->hash, &unit, sizeof (unit));
 }
 
-void
-_cogl_pipeline_layer_hash_texture_type_state (CoglPipelineLayer *authority,
-                                              CoglPipelineLayer **authorities,
-                                              CoglPipelineHashState *state)
-{
-  CoglTextureType texture_type = authority->texture_type;
-
-  state->hash = _cogl_util_one_at_a_time_hash (state->hash,
-                                               &texture_type,
-                                               sizeof (texture_type));
-}
-
 void
 _cogl_pipeline_layer_hash_texture_data_state (CoglPipelineLayer *authority,
                                               CoglPipelineLayer **authorities,
diff --git a/cogl/cogl/cogl-pipeline-layer.c b/cogl/cogl/cogl-pipeline-layer.c
index 823d4b285..580f88aac 100644
--- a/cogl/cogl/cogl-pipeline-layer.c
+++ b/cogl/cogl/cogl-pipeline-layer.c
@@ -187,10 +187,6 @@ _cogl_pipeline_layer_copy_differences (CoglPipelineLayer *dest,
           g_warn_if_reached ();
           break;
 
-        case COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX:
-          dest->texture_type = src->texture_type;
-          break;
-
         case COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX:
           dest->texture = src->texture;
           if (dest->texture)
@@ -272,7 +268,6 @@ _cogl_pipeline_layer_init_multi_property_sparse_state (
     /* XXX: avoid using a default: label so we get a warning if we
      * don't explicitly handle a newly defined state-group here. */
     case COGL_PIPELINE_LAYER_STATE_UNIT:
-    case COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE:
     case COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA:
     case COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS:
     case COGL_PIPELINE_LAYER_STATE_USER_MATRIX:
@@ -662,16 +657,6 @@ _cogl_pipeline_layer_equal (CoglPipelineLayer *layer0,
                                             layers_difference,
                                             authorities1);
 
-  if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE)
-    {
-      CoglPipelineLayerStateIndex state_index =
-        COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX;
-      if (!_cogl_pipeline_layer_texture_type_equal (authorities0[state_index],
-                                                    authorities1[state_index],
-                                                    flags))
-        return FALSE;
-    }
-
   if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA)
     {
       CoglPipelineLayerStateIndex state_index =
@@ -767,7 +752,6 @@ _cogl_pipeline_init_default_layers (void)
   layer->unit_index = 0;
 
   layer->texture = NULL;
-  layer->texture_type = COGL_TEXTURE_TYPE_2D;
 
   layer->sampler_cache_entry =
     _cogl_sampler_cache_get_default_entry (ctx->sampler_cache);
diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c
index 4112daa2e..6d88c44f6 100644
--- a/cogl/cogl/cogl-pipeline.c
+++ b/cogl/cogl/cogl-pipeline.c
@@ -2611,8 +2611,6 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
   CoglPipelineLayerStateIndex _index;
   layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_UNIT_INDEX] =
     _cogl_pipeline_layer_hash_unit_state;
-  layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX] =
-    _cogl_pipeline_layer_hash_texture_type_state;
   layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX] =
     _cogl_pipeline_layer_hash_texture_data_state;
   layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_SAMPLER_INDEX] =
@@ -2635,7 +2633,7 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
 
   {
   /* So we get a big error if we forget to update this code! */
-  _COGL_STATIC_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 10,
+  _COGL_STATIC_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 9,
                        "Don't forget to install a hash function for new "
                        "pipeline state and update assert at end of "
                        "_cogl_pipeline_init_state_hash_functions");
@@ -3040,7 +3038,6 @@ _cogl_pipeline_get_layer_state_for_fragment_codegen (CoglContext *context)
 {
   CoglPipelineLayerState state =
     (COGL_PIPELINE_LAYER_STATE_COMBINE |
-     COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE |
      COGL_PIPELINE_LAYER_STATE_UNIT |
      COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS);
 
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c 
b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
index 8f5d50981..0628c4f46 100644
--- a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
@@ -233,11 +233,10 @@ add_layer_declaration_cb (CoglPipelineLayer *layer,
                           void *user_data)
 {
   CoglPipelineShaderState *shader_state = user_data;
-  CoglTextureType texture_type =
-    _cogl_pipeline_layer_get_texture_type (layer);
   const char *target_string;
 
-  _cogl_gl_util_get_texture_target_string (texture_type, &target_string, NULL);
+  _cogl_gl_util_get_texture_target_string (COGL_TEXTURE_TYPE_2D,
+                                           &target_string, NULL);
 
   g_string_append_printf (shader_state->header,
                           "uniform sampler%s cogl_sampler%i;\n",
@@ -411,7 +410,6 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
 {
   int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
   CoglPipelineSnippetData snippet_data;
-  CoglTextureType texture_type;
   const char *target_string, *tex_coord_swizzle;
 
   _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@@ -419,9 +417,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
   if (shader_state->unit_state[unit_index].sampled)
     return;
 
-  texture_type =
-    _cogl_pipeline_layer_get_texture_type (layer);
-  _cogl_gl_util_get_texture_target_string (texture_type,
+  _cogl_gl_util_get_texture_target_string (COGL_TEXTURE_TYPE_2D,
                                            &target_string,
                                            &tex_coord_swizzle);
 
diff --git a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c 
b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c
index 54a8e5a2c..e27895602 100644
--- a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c
+++ b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c
@@ -169,11 +169,10 @@ add_layer_declaration_cb (CoglPipelineLayer *layer,
                           void *user_data)
 {
   CoglPipelineShaderState *shader_state = user_data;
-  CoglTextureType texture_type =
-    _cogl_pipeline_layer_get_texture_type (layer);
   const char *target_string;
 
-  _cogl_gl_util_get_texture_target_string (texture_type, &target_string, NULL);
+  _cogl_gl_util_get_texture_target_string (COGL_TEXTURE_TYPE_2D,
+                                           &target_string, NULL);
 
   g_string_append_printf (shader_state->header,
                           "uniform sampler%s cogl_sampler%i;\n",


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