[Cogl] [PATCH] pipeline: Remove all fog apis and state tracking

Robert Bragg robert at sixbynine.org
Tue Aug 28 08:46:48 PDT 2012


From: Robert Bragg <robert at linux.intel.com>

This removes the fixed-function fogging support from Cogl and we now
expect applications wanting to use fog like effects to depend on
programmable hardware and use Cogl's GLSL snippet api.
---
 cogl/cogl-pipeline-fragend-arbfp.c |    4 --
 cogl/cogl-pipeline-fragend-fixed.c |   47 ------------------------
 cogl/cogl-pipeline-private.h       |   19 ----------
 cogl/cogl-pipeline-state-private.h |   12 ------
 cogl/cogl-pipeline-state.c         |   70 ------------------------------------
 cogl/cogl-pipeline.c               |   35 +-----------------
 cogl/cogl-types.h                  |   34 -----------------
 cogl/cogl.symbols                  |    2 -
 8 files changed, 1 insertions(+), 222 deletions(-)

diff --git a/cogl/cogl-pipeline-fragend-arbfp.c b/cogl/cogl-pipeline-fragend-arbfp.c
index c9dc65f..04bfbc2 100644
--- a/cogl/cogl-pipeline-fragend-arbfp.c
+++ b/cogl/cogl-pipeline-fragend-arbfp.c
@@ -167,10 +167,6 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline,
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_ARBFP))
     return FALSE;
 
-  /* TODO: support fog */
-  if (_cogl_pipeline_get_fog_enabled (pipeline))
-    return FALSE;
-
   /* Fragment snippets are only supported in the GLSL fragend */
   if (_cogl_pipeline_has_fragment_snippets (pipeline))
     return FALSE;
diff --git a/cogl/cogl-pipeline-fragend-fixed.c b/cogl/cogl-pipeline-fragend-fixed.c
index 49325b4..a7c0ca7 100644
--- a/cogl/cogl-pipeline-fragend-fixed.c
+++ b/cogl/cogl-pipeline-fragend-fixed.c
@@ -374,53 +374,6 @@ _cogl_pipeline_fragend_fixed_end (CoglPipeline *pipeline,
   for (i = highest_unit_index + 1; i < ctx->texture_units->len; i++)
     _cogl_disable_texture_unit (i);
 
-  if (pipelines_difference & COGL_PIPELINE_STATE_FOG)
-    {
-      CoglPipeline *authority =
-        _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FOG);
-      CoglPipelineFogState *fog_state = &authority->big_state->fog_state;
-
-      if (fog_state->enabled)
-        {
-          GLfloat fogColor[4];
-          GLenum gl_mode = GL_LINEAR;
-
-          fogColor[0] = cogl_color_get_red_float (&fog_state->color);
-          fogColor[1] = cogl_color_get_green_float (&fog_state->color);
-          fogColor[2] = cogl_color_get_blue_float (&fog_state->color);
-          fogColor[3] = cogl_color_get_alpha_float (&fog_state->color);
-
-          GE (ctx, glEnable (GL_FOG));
-
-          GE (ctx, glFogfv (GL_FOG_COLOR, fogColor));
-
-          if (ctx->driver == COGL_DRIVER_GLES1)
-            switch (fog_state->mode)
-              {
-              case COGL_FOG_MODE_LINEAR:
-                gl_mode = GL_LINEAR;
-                break;
-              case COGL_FOG_MODE_EXPONENTIAL:
-                gl_mode = GL_EXP;
-                break;
-              case COGL_FOG_MODE_EXPONENTIAL_SQUARED:
-                gl_mode = GL_EXP2;
-                break;
-              }
-          /* TODO: support other modes for GLES2 */
-
-          /* NB: GLES doesn't have glFogi */
-          GE (ctx, glFogf (GL_FOG_MODE, gl_mode));
-          GE (ctx, glHint (GL_FOG_HINT, GL_NICEST));
-
-          GE (ctx, glFogf (GL_FOG_DENSITY, fog_state->density));
-          GE (ctx, glFogf (GL_FOG_START, fog_state->z_near));
-          GE (ctx, glFogf (GL_FOG_END, fog_state->z_far));
-        }
-      else
-        GE (ctx, glDisable (GL_FOG));
-    }
-
   return TRUE;
 }
 
diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
index 5e1091c..36422cc 100644
--- a/cogl/cogl-pipeline-private.h
+++ b/cogl/cogl-pipeline-private.h
@@ -176,7 +176,6 @@ typedef enum
   COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE_INDEX,
   COGL_PIPELINE_STATE_BLEND_INDEX,
   COGL_PIPELINE_STATE_DEPTH_INDEX,
-  COGL_PIPELINE_STATE_FOG_INDEX,
   COGL_PIPELINE_STATE_POINT_SIZE_INDEX,
   COGL_PIPELINE_STATE_LOGIC_OPS_INDEX,
   COGL_PIPELINE_STATE_CULL_FACE_INDEX,
@@ -219,8 +218,6 @@ typedef enum _CoglPipelineState
     1L<<COGL_PIPELINE_STATE_BLEND_INDEX,
   COGL_PIPELINE_STATE_DEPTH =
     1L<<COGL_PIPELINE_STATE_DEPTH_INDEX,
-  COGL_PIPELINE_STATE_FOG =
-    1L<<COGL_PIPELINE_STATE_FOG_INDEX,
   COGL_PIPELINE_STATE_POINT_SIZE =
     1L<<COGL_PIPELINE_STATE_POINT_SIZE_INDEX,
   COGL_PIPELINE_STATE_LOGIC_OPS =
@@ -263,7 +260,6 @@ typedef enum _CoglPipelineState
    COGL_PIPELINE_STATE_ALPHA_FUNC_REFERENCE | \
    COGL_PIPELINE_STATE_BLEND | \
    COGL_PIPELINE_STATE_DEPTH | \
-   COGL_PIPELINE_STATE_FOG | \
    COGL_PIPELINE_STATE_POINT_SIZE | \
    COGL_PIPELINE_STATE_LOGIC_OPS | \
    COGL_PIPELINE_STATE_CULL_FACE | \
@@ -275,7 +271,6 @@ typedef enum _CoglPipelineState
   (COGL_PIPELINE_STATE_LAYERS | \
    COGL_PIPELINE_STATE_BLEND | \
    COGL_PIPELINE_STATE_DEPTH | \
-   COGL_PIPELINE_STATE_FOG | \
    COGL_PIPELINE_STATE_LOGIC_OPS | \
    COGL_PIPELINE_STATE_CULL_FACE | \
    COGL_PIPELINE_STATE_UNIFORMS | \
@@ -318,16 +313,6 @@ typedef struct
 
 typedef struct
 {
-  CoglBool        enabled;
-  CoglColor       color;
-  CoglFogMode     mode;
-  float           density;
-  float           z_near;
-  float           z_far;
-} CoglPipelineFogState;
-
-typedef struct
-{
   CoglColorMask color_mask;
 } CoglPipelineLogicOpsState;
 
@@ -356,7 +341,6 @@ typedef struct
   CoglPipelineAlphaFuncState alpha_state;
   CoglPipelineBlendState blend_state;
   CoglDepthState depth_state;
-  CoglPipelineFogState fog_state;
   float point_size;
   CoglPipelineLogicOpsState logic_ops_state;
   CoglPipelineCullFaceState cull_face_state;
@@ -902,9 +886,6 @@ void
 _cogl_pipeline_set_blend_enabled (CoglPipeline *pipeline,
                                   CoglPipelineBlendEnable enable);
 
-CoglBool
-_cogl_pipeline_get_fog_enabled (CoglPipeline *pipeline);
-
 void
 _cogl_pipeline_set_static_breadcrumb (CoglPipeline *pipeline,
                                       const char *breadcrumb);
diff --git a/cogl/cogl-pipeline-state-private.h b/cogl/cogl-pipeline-state-private.h
index f96f777..3954f23 100644
--- a/cogl/cogl-pipeline-state-private.h
+++ b/cogl/cogl-pipeline-state-private.h
@@ -43,10 +43,6 @@ _cogl_pipeline_has_non_layer_vertex_snippets (CoglPipeline *pipeline);
 CoglBool
 _cogl_pipeline_has_non_layer_fragment_snippets (CoglPipeline *pipeline);
 
-void
-_cogl_pipeline_set_fog_state (CoglPipeline *pipeline,
-                              const CoglPipelineFogState *fog_state);
-
 CoglBool
 _cogl_pipeline_color_equal (CoglPipeline *authority0,
                             CoglPipeline *authority1);
@@ -68,10 +64,6 @@ _cogl_pipeline_depth_state_equal (CoglPipeline *authority0,
                                   CoglPipeline *authority1);
 
 CoglBool
-_cogl_pipeline_fog_state_equal (CoglPipeline *authority0,
-                                CoglPipeline *authority1);
-
-CoglBool
 _cogl_pipeline_point_size_equal (CoglPipeline *authority0,
                                  CoglPipeline *authority1);
 
@@ -132,10 +124,6 @@ _cogl_pipeline_hash_depth_state (CoglPipeline *authority,
                                  CoglPipelineHashState *state);
 
 void
-_cogl_pipeline_hash_fog_state (CoglPipeline *authority,
-                               CoglPipelineHashState *state);
-
-void
 _cogl_pipeline_hash_point_size_state (CoglPipeline *authority,
                                       CoglPipelineHashState *state);
 
diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
index 6a9b541..b0a83de 100644
--- a/cogl/cogl-pipeline-state.c
+++ b/cogl/cogl-pipeline-state.c
@@ -142,24 +142,6 @@ _cogl_pipeline_depth_state_equal (CoglPipeline *authority0,
 }
 
 CoglBool
-_cogl_pipeline_fog_state_equal (CoglPipeline *authority0,
-                                CoglPipeline *authority1)
-{
-  CoglPipelineFogState *fog_state0 = &authority0->big_state->fog_state;
-  CoglPipelineFogState *fog_state1 = &authority1->big_state->fog_state;
-
-  if (fog_state0->enabled == fog_state1->enabled &&
-      cogl_color_equal (&fog_state0->color, &fog_state1->color) &&
-      fog_state0->mode == fog_state1->mode &&
-      fog_state0->density == fog_state1->density &&
-      fog_state0->z_near == fog_state1->z_near &&
-      fog_state0->z_far == fog_state1->z_far)
-    return TRUE;
-  else
-    return FALSE;
-}
-
-CoglBool
 _cogl_pipeline_point_size_equal (CoglPipeline *authority0,
                                  CoglPipeline *authority1)
 {
@@ -887,41 +869,6 @@ cogl_pipeline_set_color_mask (CoglPipeline *pipeline,
 }
 
 void
-_cogl_pipeline_set_fog_state (CoglPipeline *pipeline,
-                              const CoglPipelineFogState *fog_state)
-{
-  CoglPipelineState state = COGL_PIPELINE_STATE_FOG;
-  CoglPipeline *authority;
-  CoglPipelineFogState *current_fog_state;
-
-  _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
-
-  authority = _cogl_pipeline_get_authority (pipeline, state);
-
-  current_fog_state = &authority->big_state->fog_state;
-
-  if (current_fog_state->enabled == fog_state->enabled &&
-      cogl_color_equal (&current_fog_state->color, &fog_state->color) &&
-      current_fog_state->mode == fog_state->mode &&
-      current_fog_state->density == fog_state->density &&
-      current_fog_state->z_near == fog_state->z_near &&
-      current_fog_state->z_far == fog_state->z_far)
-    return;
-
-  /* - Flush journal primitives referencing the current state.
-   * - Make sure the pipeline has no dependants so it may be modified.
-   * - If the pipeline isn't currently an authority for the state being
-   *   changed, then initialize that state from the current authority.
-   */
-  _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE);
-
-  pipeline->big_state->fog_state = *fog_state;
-
-  _cogl_pipeline_update_authority (pipeline, authority, state,
-                                   _cogl_pipeline_fog_state_equal);
-}
-
-void
 cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
                                   CoglPipelineCullFaceMode cull_face_mode)
 {
@@ -1495,23 +1442,6 @@ _cogl_pipeline_hash_depth_state (CoglPipeline *authority,
 }
 
 void
-_cogl_pipeline_hash_fog_state (CoglPipeline *authority,
-                               CoglPipelineHashState *state)
-{
-  CoglPipelineFogState *fog_state = &authority->big_state->fog_state;
-  unsigned long hash = state->hash;
-
-  if (!fog_state->enabled)
-    hash = _cogl_util_one_at_a_time_hash (hash, &fog_state->enabled,
-                                          sizeof (fog_state->enabled));
-  else
-    hash = _cogl_util_one_at_a_time_hash (hash, &fog_state,
-                                          sizeof (CoglPipelineFogState));
-
-  state->hash = hash;
-}
-
-void
 _cogl_pipeline_hash_point_size_state (CoglPipeline *authority,
                                       CoglPipelineHashState *state)
 {
diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
index 9ed7231..855d815 100644
--- a/cogl/cogl-pipeline.c
+++ b/cogl/cogl-pipeline.c
@@ -852,13 +852,6 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
               sizeof (CoglDepthState));
     }
 
-  if (differences & COGL_PIPELINE_STATE_FOG)
-    {
-      memcpy (&big_state->fog_state,
-              &src->big_state->fog_state,
-              sizeof (CoglPipelineFogState));
-    }
-
   if (differences & COGL_PIPELINE_STATE_POINT_SIZE)
     big_state->point_size = src->big_state->point_size;
 
@@ -965,13 +958,6 @@ _cogl_pipeline_init_multi_property_sparse_state (CoglPipeline *pipeline,
                 sizeof (CoglDepthState));
         break;
       }
-    case COGL_PIPELINE_STATE_FOG:
-      {
-        memcpy (&pipeline->big_state->fog_state,
-                &authority->big_state->fog_state,
-                sizeof (CoglPipelineFogState));
-        break;
-      }
     case COGL_PIPELINE_STATE_LOGIC_OPS:
       {
         memcpy (&pipeline->big_state->logic_ops_state,
@@ -2143,11 +2129,6 @@ _cogl_pipeline_equal (CoglPipeline *pipeline0,
                                                  authorities1[bit]))
             goto done;
           break;
-        case COGL_PIPELINE_STATE_FOG_INDEX:
-          if (!_cogl_pipeline_fog_state_equal (authorities0[bit],
-                                               authorities1[bit]))
-            goto done;
-          break;
         case COGL_PIPELINE_STATE_CULL_FACE_INDEX:
           if (!_cogl_pipeline_cull_face_state_equal (authorities0[bit],
                                                      authorities1[bit]))
@@ -2271,18 +2252,6 @@ _cogl_pipeline_update_authority (CoglPipeline *pipeline,
     }
 }
 
-CoglBool
-_cogl_pipeline_get_fog_enabled (CoglPipeline *pipeline)
-{
-  CoglPipeline *authority;
-
-  _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
-
-  authority =
-    _cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_FOG);
-  return authority->big_state->fog_state.enabled;
-}
-
 unsigned long
 _cogl_pipeline_get_age (CoglPipeline *pipeline)
 {
@@ -2556,8 +2525,6 @@ _cogl_pipeline_init_state_hash_functions (void)
     _cogl_pipeline_hash_blend_state;
   state_hash_functions[COGL_PIPELINE_STATE_DEPTH_INDEX] =
     _cogl_pipeline_hash_depth_state;
-  state_hash_functions[COGL_PIPELINE_STATE_FOG_INDEX] =
-    _cogl_pipeline_hash_fog_state;
   state_hash_functions[COGL_PIPELINE_STATE_CULL_FACE_INDEX] =
     _cogl_pipeline_hash_cull_face_state;
   state_hash_functions[COGL_PIPELINE_STATE_POINT_SIZE_INDEX] =
@@ -2573,7 +2540,7 @@ _cogl_pipeline_init_state_hash_functions (void)
 
   {
   /* So we get a big error if we forget to update this code! */
-  _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 14,
+  _COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 13,
                        "Make sure to install a hash function for "
                        "newly added pipeline state and update assert "
                        "in _cogl_pipeline_init_state_hash_functions");
diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h
index 5b9c0f8..7684412 100644
--- a/cogl/cogl-types.h
+++ b/cogl/cogl-types.h
@@ -466,40 +466,6 @@ typedef enum {
 } CoglTextureFlags;
 
 /**
- * CoglFogMode:
- * @COGL_FOG_MODE_LINEAR: Calculates the fog blend factor as:
- * |[
- *   f = end - eye_distance / end - start
- * ]|
- * @COGL_FOG_MODE_EXPONENTIAL: Calculates the fog blend factor as:
- * |[
- *   f = e ^ -(density * eye_distance)
- * ]|
- * @COGL_FOG_MODE_EXPONENTIAL_SQUARED: Calculates the fog blend factor as:
- * |[
- *   f = e ^ -(density * eye_distance)^2
- * ]|
- *
- * The fog mode determines the equation used to calculate the fogging blend
- * factor while fogging is enabled. The simplest %COGL_FOG_MODE_LINEAR mode
- * determines f as:
- *
- * |[
- *   f = end - eye_distance / end - start
- * ]|
- *
- * Where eye_distance is the distance of the current fragment in eye
- * coordinates from the origin.
- *
- * Since: 1.0
- */
-typedef enum {
-  COGL_FOG_MODE_LINEAR,
-  COGL_FOG_MODE_EXPONENTIAL,
-  COGL_FOG_MODE_EXPONENTIAL_SQUARED
-} CoglFogMode;
-
-/**
  * COGL_BLEND_STRING_ERROR:
  *
  * #GError domain for blend string parser errors
diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols
index 821bb31..6ee2ead 100644
--- a/cogl/cogl.symbols
+++ b/cogl/cogl.symbols
@@ -179,8 +179,6 @@ cogl_euler_init_from_quaternion
 cogl_features_available
 cogl_feature_flags_get_type
 
-cogl_fog_mode_get_type
-
 cogl_foreach_feature
 
 cogl_flush
-- 
1.7.7.6



More information about the Cogl mailing list