[Cogl] [PATCH] Remove the pipeline layer user matrix
Robert Bragg
robert at sixbynine.org
Wed Nov 21 13:32:31 PST 2012
I'm slightly apprehensive about this from the pov that we loose support for
a quite basic feature on fixed function hardware which seems a bit of a
shame but we did talk about this before and figured that there's nothing
stopping us adding it back later if we want.
I think the patch looks good to land to me:
Reviewed-by: Robert Bragg <robert at linux.intel.com>
thanks,
- Robert
On Wed, Nov 21, 2012 at 7:04 PM, Neil Roberts <neil at linux.intel.com> wrote:
> The pipeline layer user matrix is not used very often and the way it
> is currently implemented comes at a non-trivial cost. Any pipeline
> layer that requires the big state needs to have a CoglMatrix added to
> its state. The generated vertex shader will always multiply the
> coordinates by the matrix even if it is just the identity matrix.
>
> The same functionality can be achieved on programmable hardware using
> a shader snippet. The snippet hook for the texture coordinate
> transform is still available to make this convenient.
>
> If we later decide that this is a really useful feature for fixed
> function hardware then we can add it back in and try to make it work
> more efficiently. In the meantime however it seems like a good idea to
> get rid of the API now before Cogl 2.0 is released and the API becomes
> fixed.
> ---
> cogl/cogl-journal.c | 6 +-
> cogl/cogl-pipeline-layer-private.h | 11 ---
> cogl/cogl-pipeline-layer-state-private.h | 9 --
> cogl/cogl-pipeline-layer-state.c | 128
> ------------------------
> cogl/cogl-pipeline-layer-state.h | 17 ----
> cogl/cogl-pipeline-layer.c | 9 --
> cogl/cogl-pipeline-private.h | 4 -
> cogl/cogl-pipeline-state-private.h | 3 -
> cogl/cogl-pipeline-state.c | 52 ----------
> cogl/cogl-pipeline.c | 4 +-
> cogl/cogl-primitives.c | 25 -----
> cogl/cogl-snippet.h | 29 ++----
> cogl/driver/gl/cogl-pipeline-progend-glsl.c | 36 -------
> cogl/driver/gl/cogl-pipeline-vertend-fixed.c | 23 -----
> cogl/driver/gl/cogl-pipeline-vertend-glsl.c | 27 ++---
> doc/reference/cogl2/cogl2-sections.txt | 1 -
> tests/conform/Makefile.am | 1 -
> tests/conform/test-conform-main.c | 1 -
> tests/conform/test-pipeline-user-matrix.c | 141
> ---------------------------
> tests/conform/test-snippets.c | 16 +--
> 20 files changed, 23 insertions(+), 520 deletions(-)
> delete mode 100644 tests/conform/test-pipeline-user-matrix.c
>
> diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c
> index 79fc016..45752fc 100644
> --- a/cogl/cogl-journal.c
> +++ b/cogl/cogl-journal.c
> @@ -781,10 +781,10 @@ can_software_clip_entry (CoglJournalEntry
> *journal_entry,
> entries using the same pipeline as the previous entry */
> if (prev_journal_entry == NULL || pipeline !=
> prev_journal_entry->pipeline)
> {
> - /* If there is a custom texture transform; either due to custom
> shader
> - * snippets or a custom texture matrix then we can't reliably
> modify the
> + /* If there are any snippets then we can't reliably modify the
> * texture coordinates. */
> - if (_cogl_pipeline_maybe_has_custom_texture_transform (pipeline))
> + if (_cogl_pipeline_has_vertex_snippets (pipeline) ||
> + _cogl_pipeline_has_fragment_snippets (pipeline))
> return FALSE;
> }
>
> diff --git a/cogl/cogl-pipeline-layer-private.h
> b/cogl/cogl-pipeline-layer-private.h
> index 84ccd9d..90ceeab 100644
> --- a/cogl/cogl-pipeline-layer-private.h
> +++ b/cogl/cogl-pipeline-layer-private.h
> @@ -54,7 +54,6 @@ typedef enum
> COGL_PIPELINE_LAYER_STATE_SAMPLER_INDEX,
> COGL_PIPELINE_LAYER_STATE_COMBINE_INDEX,
> COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT_INDEX,
> - COGL_PIPELINE_LAYER_STATE_USER_MATRIX_INDEX,
> COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS_INDEX,
> COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS_INDEX,
> COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS_INDEX,
> @@ -87,8 +86,6 @@ typedef enum
> 1L<<COGL_PIPELINE_LAYER_STATE_COMBINE_INDEX,
> COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT =
> 1L<<COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT_INDEX,
> - COGL_PIPELINE_LAYER_STATE_USER_MATRIX =
> - 1L<<COGL_PIPELINE_LAYER_STATE_USER_MATRIX_INDEX,
>
> COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS =
> 1L<<COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS_INDEX,
> @@ -115,7 +112,6 @@ typedef enum
> #define COGL_PIPELINE_LAYER_STATE_NEEDS_BIG_STATE \
> (COGL_PIPELINE_LAYER_STATE_COMBINE | \
> COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT | \
> - COGL_PIPELINE_LAYER_STATE_USER_MATRIX | \
> COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS | \
> COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS | \
> COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS)
> @@ -176,9 +172,6 @@ typedef struct
>
> float texture_combine_constant[4];
>
> - /* The texture matrix dscribes how to transform texture coordinates */
> - CoglMatrix matrix;
> -
> CoglBool point_sprite_coords;
>
> CoglPipelineSnippetList vertex_snippets;
> @@ -295,10 +288,6 @@ _cogl_pipeline_layer_prune_redundant_ancestry
> (CoglPipelineLayer *layer);
> CoglBool
> _cogl_pipeline_layer_has_alpha (CoglPipelineLayer *layer);
>
> -CoglBool
> -_cogl_pipeline_layer_has_user_matrix (CoglPipeline *pipeline,
> - int layer_index);
> -
> /*
> * Calls the pre_paint method on the layer texture if there is
> * one. This will determine whether mipmaps are needed based on the
> diff --git a/cogl/cogl-pipeline-layer-state-private.h
> b/cogl/cogl-pipeline-layer-state-private.h
> index db3ae81..c4eb027 100644
> --- a/cogl/cogl-pipeline-layer-state-private.h
> +++ b/cogl/cogl-pipeline-layer-state-private.h
> @@ -67,10 +67,6 @@ _cogl_pipeline_layer_sampler_equal (CoglPipelineLayer
> *authority0,
> CoglPipelineLayer *authority1);
>
> CoglBool
> -_cogl_pipeline_layer_user_matrix_equal (CoglPipelineLayer *authority0,
> - CoglPipelineLayer *authority1);
> -
> -CoglBool
> _cogl_pipeline_layer_point_sprite_coords_equal (CoglPipelineLayer
> *authority0,
> CoglPipelineLayer
> *authority1);
>
> @@ -113,11 +109,6 @@ _cogl_pipeline_layer_hash_combine_constant_state
> (CoglPipelineLayer *authority,
> CoglPipelineHashState
> *state);
>
> void
> -_cogl_pipeline_layer_hash_user_matrix_state (CoglPipelineLayer *authority,
> - CoglPipelineLayer
> **authorities,
> - CoglPipelineHashState
> *state);
> -
> -void
> _cogl_pipeline_layer_hash_point_sprite_state (CoglPipelineLayer
> *authority,
> CoglPipelineLayer
> **authorities,
> CoglPipelineHashState
> *state);
> diff --git a/cogl/cogl-pipeline-layer-state.c
> b/cogl/cogl-pipeline-layer-state.c
> index b69ff46..5c05d16 100644
> --- a/cogl/cogl-pipeline-layer-state.c
> +++ b/cogl/cogl-pipeline-layer-state.c
> @@ -1043,19 +1043,6 @@ _cogl_pipeline_layer_sampler_equal
> (CoglPipelineLayer *authority0,
> }
>
> CoglBool
> -_cogl_pipeline_layer_user_matrix_equal (CoglPipelineLayer *authority0,
> - CoglPipelineLayer *authority1)
> -{
> - CoglPipelineLayerBigState *big_state0 = authority0->big_state;
> - CoglPipelineLayerBigState *big_state1 = authority1->big_state;
> -
> - if (!cogl_matrix_equal (&big_state0->matrix, &big_state1->matrix))
> - return FALSE;
> -
> - return TRUE;
> -}
> -
> -CoglBool
> _cogl_pipeline_layer_point_sprite_coords_equal (CoglPipelineLayer
> *authority0,
> CoglPipelineLayer
> *authority1)
> {
> @@ -1381,94 +1368,6 @@ _cogl_pipeline_get_layer_combine_constant
> (CoglPipeline *pipeline,
> sizeof (float) * 4);
> }
>
> -/* We should probably make a public API version of this that has a
> - matrix out-param. For an internal API it's good to be able to avoid
> - copying the matrix */
> -const CoglMatrix *
> -_cogl_pipeline_get_layer_matrix (CoglPipeline *pipeline, int layer_index)
> -{
> - CoglPipelineLayerState change =
> - COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
> - CoglPipelineLayer *layer;
> - CoglPipelineLayer *authority;
> -
> - _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), NULL);
> -
> - layer = _cogl_pipeline_get_layer (pipeline, layer_index);
> -
> - authority = _cogl_pipeline_layer_get_authority (layer, change);
> - return &authority->big_state->matrix;
> -}
> -
> -void
> -cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
> - int layer_index,
> - const CoglMatrix *matrix)
> -{
> - CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
> - CoglPipelineLayer *layer;
> - CoglPipelineLayer *authority;
> - CoglPipelineLayer *new;
> -
> - _COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
> -
> - /* 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, state);
> -
> - if (cogl_matrix_equal (matrix, &authority->big_state->matrix))
> - return;
> -
> - new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, state);
> - 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, state);
> -
> - if (cogl_matrix_equal (matrix,
> &old_authority->big_state->matrix))
> - {
> - layer->differences &= ~state;
> -
> - g_assert (layer->owner == pipeline);
> - if (layer->differences == 0)
> - _cogl_pipeline_prune_empty_layer_difference (pipeline,
> - layer);
> - return;
> - }
> - }
> - }
> -
> - layer->big_state->matrix = *matrix;
> -
> - /* 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 |= state;
> - _cogl_pipeline_layer_prune_redundant_ancestry (layer);
> - }
> -}
> -
> CoglTexture *
> _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer)
> {
> @@ -1477,23 +1376,6 @@ _cogl_pipeline_layer_get_texture (CoglPipelineLayer
> *layer)
> return _cogl_pipeline_layer_get_texture_real (layer);
> }
>
> -CoglBool
> -_cogl_pipeline_layer_has_user_matrix (CoglPipeline *pipeline,
> - int layer_index)
> -{
> - CoglPipelineLayer *layer;
> - CoglPipelineLayer *authority;
> -
> - layer = _cogl_pipeline_get_layer (pipeline, layer_index);
> -
> - authority =
> - _cogl_pipeline_layer_get_authority (layer,
> -
> COGL_PIPELINE_LAYER_STATE_USER_MATRIX);
> -
> - /* If the authority is the default pipeline then no, otherwise yes */
> - return _cogl_pipeline_layer_get_parent (authority) ? TRUE : FALSE;
> -}
> -
> void
> _cogl_pipeline_layer_get_filters (CoglPipelineLayer *layer,
> CoglPipelineFilter *min_filter,
> @@ -1766,16 +1648,6 @@ done:
> }
>
> void
> -_cogl_pipeline_layer_hash_user_matrix_state (CoglPipelineLayer *authority,
> - CoglPipelineLayer
> **authorities,
> - CoglPipelineHashState *state)
> -{
> - CoglPipelineLayerBigState *big_state = authority->big_state;
> - state->hash = _cogl_util_one_at_a_time_hash (state->hash,
> &big_state->matrix,
> - sizeof (float) * 16);
> -}
> -
> -void
> _cogl_pipeline_layer_hash_point_sprite_state (CoglPipelineLayer
> *authority,
> CoglPipelineLayer
> **authorities,
> CoglPipelineHashState
> *state)
> diff --git a/cogl/cogl-pipeline-layer-state.h
> b/cogl/cogl-pipeline-layer-state.h
> index a785411..9380ddf 100644
> --- a/cogl/cogl-pipeline-layer-state.h
> +++ b/cogl/cogl-pipeline-layer-state.h
> @@ -318,23 +318,6 @@ cogl_pipeline_set_layer_combine_constant
> (CoglPipeline *pipeline,
> const CoglColor *constant);
>
> /**
> - * cogl_pipeline_set_layer_matrix:
> - * @pipeline: A #CoglPipeline object
> - * @layer_index: the index for the layer inside @pipeline
> - * @matrix: the transformation matrix for the layer
> - *
> - * This function lets you set a matrix that can be used to e.g. translate
> - * and rotate a single layer of a pipeline used to fill your geometry.
> - *
> - * Since: 1.10
> - * Stability: unstable
> - */
> -void
> -cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
> - int layer_index,
> - const CoglMatrix *matrix);
> -
> -/**
> * cogl_pipeline_get_n_layers:
> * @pipeline: A #CoglPipeline object
> *
> diff --git a/cogl/cogl-pipeline-layer.c b/cogl/cogl-pipeline-layer.c
> index d9590c8..a3a4545 100644
> --- a/cogl/cogl-pipeline-layer.c
> +++ b/cogl/cogl-pipeline-layer.c
> @@ -168,7 +168,6 @@ _cogl_pipeline_layer_init_multi_property_sparse_state (
> 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:
> case COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT:
> case COGL_PIPELINE_LAYER_STATE_SAMPLER:
> g_return_if_reached ();
> @@ -593,12 +592,6 @@ _cogl_pipeline_layer_equal (CoglPipelineLayer *layer0,
> _cogl_pipeline_layer_sampler_equal))
> return FALSE;
>
> - if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX &&
> - !layer_state_equal (COGL_PIPELINE_LAYER_STATE_USER_MATRIX_INDEX,
> - authorities0, authorities1,
> - _cogl_pipeline_layer_user_matrix_equal))
> - return FALSE;
> -
> if (layers_difference & COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS &&
> !layer_state_equal
> (COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS_INDEX,
> authorities0, authorities1,
> @@ -693,8 +686,6 @@ _cogl_pipeline_init_default_layers (void)
>
> big_state->point_sprite_coords = FALSE;
>
> - cogl_matrix_init_identity (&big_state->matrix);
> -
> ctx->default_layer_0 = _cogl_pipeline_layer_object_new (layer);
>
> /* TODO: we should make default_layer_n comprise of two
> diff --git a/cogl/cogl-pipeline-private.h b/cogl/cogl-pipeline-private.h
> index 1a3d049..e3411a2 100644
> --- a/cogl/cogl-pipeline-private.h
> +++ b/cogl/cogl-pipeline-private.h
> @@ -793,10 +793,6 @@ _cogl_pipeline_journal_ref (CoglPipeline *pipeline);
> void
> _cogl_pipeline_journal_unref (CoglPipeline *pipeline);
>
> -const CoglMatrix *
> -_cogl_pipeline_get_layer_matrix (CoglPipeline *pipeline,
> - int layer_index);
> -
> void
> _cogl_pipeline_texture_storage_change_notify (CoglTexture *texture);
>
> diff --git a/cogl/cogl-pipeline-state-private.h
> b/cogl/cogl-pipeline-state-private.h
> index 8c8b2b8..a4079a9 100644
> --- a/cogl/cogl-pipeline-state-private.h
> +++ b/cogl/cogl-pipeline-state-private.h
> @@ -46,9 +46,6 @@ _cogl_pipeline_get_colorubv (CoglPipeline *pipeline,
> }
>
> CoglBool
> -_cogl_pipeline_maybe_has_custom_texture_transform (CoglPipeline
> *pipeline);
> -
> -CoglBool
> _cogl_pipeline_has_vertex_snippets (CoglPipeline *pipeline);
>
> CoglBool
> diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
> index c4ec4ea..726d418 100644
> --- a/cogl/cogl-pipeline-state.c
> +++ b/cogl/cogl-pipeline-state.c
> @@ -1252,58 +1252,6 @@ _cogl_pipeline_has_fragment_snippets (CoglPipeline
> *pipeline)
> return found_fragment_snippet;
> }
>
> -static CoglBool
> -check_maybe_has_custom_texture_transform (CoglPipelineLayer *layer,
> - void *user_data)
> -{
> - CoglBool *maybe_has_custom_texture_transform = user_data;
> - unsigned long matrix_state = COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
> - unsigned long frag_state = COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS;
> - unsigned long vert_state = COGL_PIPELINE_LAYER_STATE_VERTEX_SNIPPETS;
> - CoglPipelineLayer *matrix_authority;
> - CoglPipelineLayer *frag_authority;
> - CoglPipelineLayer *vert_authority;
> -
> - matrix_authority = _cogl_pipeline_layer_get_authority (layer,
> matrix_state);
> - if (!_cogl_pipeline_layer_get_parent (matrix_authority))
> - {
> - *maybe_has_custom_texture_transform = TRUE;
> - return FALSE;
> - }
> -
> - frag_authority = _cogl_pipeline_layer_get_authority (layer, frag_state);
> - if (!COGL_LIST_EMPTY (&frag_authority->big_state->fragment_snippets))
> - {
> - *maybe_has_custom_texture_transform = TRUE;
> - return FALSE;
> - }
> -
> - vert_authority = _cogl_pipeline_layer_get_authority (layer, vert_state);
> - if (!COGL_LIST_EMPTY (&vert_authority->big_state->vertex_snippets))
> - {
> - *maybe_has_custom_texture_transform = TRUE;
> - return FALSE;
> - }
> -
> - return TRUE;
> -}
> -
> -CoglBool
> -_cogl_pipeline_maybe_has_custom_texture_transform (CoglPipeline *pipeline)
> -{
> - CoglBool maybe_has_custom_texture_transform = FALSE;
> -
> - if (_cogl_pipeline_has_non_layer_fragment_snippets (pipeline))
> - return TRUE;
> -
> - _cogl_pipeline_foreach_layer_internal (
> - pipeline,
> -
> check_maybe_has_custom_texture_transform,
> -
> &maybe_has_custom_texture_transform);
> -
> - return maybe_has_custom_texture_transform;
> -}
> -
> void
> _cogl_pipeline_hash_color_state (CoglPipeline *authority,
> CoglPipelineHashState *state)
> diff --git a/cogl/cogl-pipeline.c b/cogl/cogl-pipeline.c
> index 85264ab..35d0094 100644
> --- a/cogl/cogl-pipeline.c
> +++ b/cogl/cogl-pipeline.c
> @@ -2338,8 +2338,6 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
> _cogl_pipeline_layer_hash_combine_state;
>
> layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT_INDEX]
> =
> _cogl_pipeline_layer_hash_combine_constant_state;
> - layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_USER_MATRIX_INDEX]
> =
> - _cogl_pipeline_layer_hash_user_matrix_state;
> _index = COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS_INDEX;
> layer_state_hash_functions[_index] =
> _cogl_pipeline_layer_hash_point_sprite_state;
> @@ -2352,7 +2350,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");
> diff --git a/cogl/cogl-primitives.c b/cogl/cogl-primitives.c
> index 87ca8bc..89a7106 100644
> --- a/cogl/cogl-primitives.c
> +++ b/cogl/cogl-primitives.c
> @@ -589,31 +589,6 @@ _cogl_rectangles_validate_layer_cb (CoglPipeline
> *pipeline,
> }
> }
>
> -#ifdef COGL_ENABLE_DEBUG
> - /* If the texture can't be repeated with the GPU (e.g. because it has
> - * waste or if using GL_TEXTURE_RECTANGLE_ARB) then if a texture matrix
> - * is also in use we don't know if the result will end up trying
> - * to texture from the waste area.
> - *
> - * Note: we check can_hardware_repeat() first since it's cheaper.
> - *
> - * Note: cases where the texture coordinates will require repeating
> - * will be caught by later validation.
> - */
> - if (!_cogl_texture_can_hardware_repeat (texture) &&
> - _cogl_pipeline_layer_has_user_matrix (pipeline, layer_index))
> - {
> - static CoglBool warning_seen = FALSE;
> - if (!warning_seen)
> - g_warning ("layer %d of your pipeline uses a custom "
> - "texture matrix but because the texture doesn't "
> - "support hardware repeating you may see artefacts "
> - "due to sampling beyond the texture's bounds.",
> - state->i);
> - warning_seen = TRUE;
> - }
> -#endif
> -
> return TRUE;
> }
>
> diff --git a/cogl/cogl-snippet.h b/cogl/cogl-snippet.h
> index b9b97f3..5348363 100644
> --- a/cogl/cogl-snippet.h
> +++ b/cogl/cogl-snippet.h
> @@ -144,14 +144,6 @@ G_BEGIN_DECLS
> * equivalent to #gl_ModelViewProjectionMatrix.
> * </para></glossdef>
> * </glossentry>
> - * <glossentry>
> - * <glossterm>uniform mat4
> - * <emphasis>cogl_texture_matrix</emphasis>[]</glossterm>
> - * <glossdef><para>
> - * An array of matrices for transforming the texture
> - * coordinates. This is equivalent to #gl_TextureMatrix.
> - * </para></glossdef>
> - * </glossentry>
> * </glosslist>
> *
> * In a vertex shader, the following are also available:
> @@ -317,8 +309,8 @@ typedef struct _CoglSnippet CoglSnippet;
> * @COGL_SNIPPET_HOOK_VERTEX_TRANSFORM: A hook for the vertex
> transformation.
> * @COGL_SNIPPET_HOOK_FRAGMENT: A hook for the entire fragment
> * processing stage of the pipeline.
> - * @COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM: A hook for applying the
> - * layer matrix to a texture coordinate for a layer.
> + * @COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM: A hook for transforming
> + * the texture coordinates for a layer.
> * @COGL_SNIPPET_HOOK_LAYER_FRAGMENT: A hook for the fragment
> * processing of a particular layer.
> * @COGL_SNIPPET_HOOK_TEXTURE_LOOKUP: A hook for the texture lookup
> @@ -433,16 +425,13 @@ typedef struct _CoglSnippet CoglSnippet;
> * the processing for a layer or to modify the results.
> * </para>
> * <para>
> - * Within the snippet code for this hook there are two extra
> - * variables. The first is a mat4 called cogl_matrix which represents
> - * the user matrix for this layer. The second is called cogl_tex_coord
> - * and represents the incoming and outgoing texture coordinate. On
> - * entry to the hook, cogl_tex_coord contains the value of the
> - * corresponding texture coordinate attribute for this layer. The hook
> - * is expected to modify this variable. The output will be passed as a
> - * varying to the fragment processing stage. The default code will
> - * just multiply cogl_matrix by cogl_tex_coord and store the result in
> - * cogl_tex_coord.
> + * Within the snippet code for this hook there is an extra variable
> + * called cogl_tex_coord and represents the incoming and outgoing
> + * texture coordinate. On entry to the hook, cogl_tex_coord contains
> + * the value of the corresponding texture coordinate attribute for
> + * this layer. The hook is expected to modify this variable. The
> + * output will be passed as a varying to the fragment processing
> + * stage. The default code will leave cogl_tex_coord untouched.
> * </para>
> * <para>
> * The ‘declarations’ string in @snippet will be inserted in the
> diff --git a/cogl/driver/gl/cogl-pipeline-progend-glsl.c
> b/cogl/driver/gl/cogl-pipeline-progend-glsl.c
> index 245ed7f..484e356 100644
> --- a/cogl/driver/gl/cogl-pipeline-progend-glsl.c
> +++ b/cogl/driver/gl/cogl-pipeline-progend-glsl.c
> @@ -91,11 +91,8 @@ const CoglPipelineProgend _cogl_pipeline_glsl_progend;
> typedef struct _UnitState
> {
> unsigned int dirty_combine_constant:1;
> - unsigned int dirty_texture_matrix:1;
>
> GLint combine_constant_uniform;
> -
> - GLint texture_matrix_uniform;
> } UnitState;
>
> typedef struct
> @@ -370,16 +367,6 @@ get_uniform_cb (CoglPipeline *pipeline,
>
> unit_state->combine_constant_uniform = uniform_location;
>
> - g_string_set_size (ctx->codegen_source_buffer, 0);
> - g_string_append_printf (ctx->codegen_source_buffer,
> - "cogl_texture_matrix%i", layer_index);
> -
> - GE_RET( uniform_location,
> - ctx, glGetUniformLocation (state->gl_program,
> - ctx->codegen_source_buffer->str) );
> -
> - unit_state->texture_matrix_uniform = uniform_location;
> -
> state->unit++;
>
> return TRUE;
> @@ -408,19 +395,6 @@ update_constants_cb (CoglPipeline *pipeline,
> unit_state->dirty_combine_constant = FALSE;
> }
>
> - if (unit_state->texture_matrix_uniform != -1 &&
> - (state->update_all || unit_state->dirty_texture_matrix))
> - {
> - const CoglMatrix *matrix;
> - const float *array;
> -
> - matrix = _cogl_pipeline_get_layer_matrix (pipeline, layer_index);
> - array = cogl_matrix_get_array (matrix);
> - GE (ctx, glUniformMatrix4fv (unit_state->texture_matrix_uniform,
> - 1, FALSE, array));
> - unit_state->dirty_texture_matrix = FALSE;
> - }
> -
> return TRUE;
> }
>
> @@ -833,16 +807,6 @@ _cogl_pipeline_progend_glsl_layer_pre_change_notify (
> program_state->unit_state[unit_index].dirty_combine_constant =
> TRUE;
> }
> }
> -
> - if (change & COGL_PIPELINE_LAYER_STATE_USER_MATRIX)
> - {
> - CoglPipelineProgramState *program_state = get_program_state (owner);
> - if (program_state)
> - {
> - int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
> - program_state->unit_state[unit_index].dirty_texture_matrix =
> TRUE;
> - }
> - }
> }
>
> static void
> diff --git a/cogl/driver/gl/cogl-pipeline-vertend-fixed.c
> b/cogl/driver/gl/cogl-pipeline-vertend-fixed.c
> index 606cb41..61d9eba 100644
> --- a/cogl/driver/gl/cogl-pipeline-vertend-fixed.c
> +++ b/cogl/driver/gl/cogl-pipeline-vertend-fixed.c
> @@ -57,29 +57,6 @@ _cogl_pipeline_vertend_fixed_add_layer (CoglPipeline
> *pipeline,
> unsigned long layers_difference,
> CoglFramebuffer *framebuffer)
> {
> - CoglContext *ctx = framebuffer->context;
> - int unit_index = _cogl_pipeline_layer_get_unit_index (layer);
> - CoglTextureUnit *unit = _cogl_get_texture_unit (unit_index);
> -
> - if (layers_difference & COGL_PIPELINE_LAYER_STATE_USER_MATRIX)
> - {
> - CoglPipelineLayerState state =
> COGL_PIPELINE_LAYER_STATE_USER_MATRIX;
> - CoglPipelineLayer *authority =
> - _cogl_pipeline_layer_get_authority (layer, state);
> - CoglMatrixEntry *matrix_entry;
> -
> - _cogl_matrix_stack_set (unit->matrix_stack,
> - &authority->big_state->matrix);
> -
> - _cogl_set_active_texture_unit (unit_index);
> -
> - matrix_entry = unit->matrix_stack->last_entry;
> - _cogl_matrix_entry_flush_to_gl_builtins (ctx, matrix_entry,
> - COGL_MATRIX_TEXTURE,
> - framebuffer,
> - FALSE /* enable flip */);
> - }
> -
> return TRUE;
> }
>
> diff --git a/cogl/driver/gl/cogl-pipeline-vertend-glsl.c
> b/cogl/driver/gl/cogl-pipeline-vertend-glsl.c
> index 6387473..13759ab 100644
> --- a/cogl/driver/gl/cogl-pipeline-vertend-glsl.c
> +++ b/cogl/driver/gl/cogl-pipeline-vertend-glsl.c
> @@ -249,33 +249,23 @@ _cogl_pipeline_vertend_glsl_add_layer (CoglPipeline
> *pipeline,
> return TRUE;
>
> g_string_append_printf (shader_state->header,
> - "uniform mat4 cogl_texture_matrix%i;\n"
> "attribute vec4 cogl_tex_coord%i_in;\n"
> "varying vec4 _cogl_tex_coord%i;\n"
> "#define cogl_tex_coord%i_out
> _cogl_tex_coord%i\n",
> layer_index,
> layer_index,
> layer_index,
> - layer_index,
> layer_index);
>
> - /* Transform the texture coordinates by the layer's user matrix.
> - *
> - * FIXME: this should avoid doing the transform if there is no user
> - * matrix set. This might need a separate layer state flag for
> - * whether there is a user matrix
> - *
> - * FIXME: we could be more clever here and try to detect if the
> - * fragment program is going to use the texture coordinates and
> - * avoid setting them if not
> + /* Hook to transform the texture coordinates. By default this just
> + * directly uses the texture coordinates.
> */
>
> g_string_append_printf (shader_state->header,
> "vec4\n"
> - "cogl_real_transform_layer%i (mat4 matrix, "
> - "vec4 tex_coord)\n"
> + "cogl_real_transform_layer%i (vec4 tex_coord)\n"
> "{\n"
> - " return matrix * tex_coord;\n"
> + " return tex_coord;\n"
> "}\n",
> layer_index);
>
> @@ -292,8 +282,8 @@ _cogl_pipeline_vertend_glsl_add_layer (CoglPipeline
> *pipeline,
> snippet_data.return_type = "vec4";
> snippet_data.return_variable = "cogl_tex_coord";
> snippet_data.return_variable_is_argument = TRUE;
> - snippet_data.arguments = "cogl_matrix, cogl_tex_coord";
> - snippet_data.argument_declarations = "mat4 cogl_matrix, vec4
> cogl_tex_coord";
> + snippet_data.arguments = "cogl_tex_coord";
> + snippet_data.argument_declarations = "vec4 cogl_tex_coord";
> snippet_data.source_buf = shader_state->header;
>
> _cogl_pipeline_snippet_generate_code (&snippet_data);
> @@ -304,10 +294,7 @@ _cogl_pipeline_vertend_glsl_add_layer (CoglPipeline
> *pipeline,
>
> g_string_append_printf (shader_state->source,
> " cogl_tex_coord%i_out = "
> - "cogl_transform_layer%i
> (cogl_texture_matrix%i,\n"
> - " "
> - "
> cogl_tex_coord%i_in);\n",
> - layer_index,
> + "cogl_transform_layer%i
> (cogl_tex_coord%i_in);\n",
> layer_index,
> layer_index,
> layer_index);
> diff --git a/doc/reference/cogl2/cogl2-sections.txt
> b/doc/reference/cogl2/cogl2-sections.txt
> index ba43264..004c0c0 100644
> --- a/doc/reference/cogl2/cogl2-sections.txt
> +++ b/doc/reference/cogl2/cogl2-sections.txt
> @@ -617,7 +617,6 @@ cogl_pipeline_set_layer_wrap_mode_t
> cogl_pipeline_set_layer_wrap_mode_p
> cogl_pipeline_set_layer_combine
> cogl_pipeline_set_layer_combine_constant
> -cogl_pipeline_set_layer_matrix
> cogl_pipeline_set_layer_point_sprite_coords_enabled
> cogl_pipeline_get_layer_point_sprite_coords_enabled
>
> diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
> index b6430e2..3645f14 100644
> --- a/tests/conform/Makefile.am
> +++ b/tests/conform/Makefile.am
> @@ -35,7 +35,6 @@ test_sources = \
> test-backface-culling.c \
> test-just-vertex-shader.c \
> test-path.c \
> - test-pipeline-user-matrix.c \
> test-pipeline-uniforms.c \
> test-pixel-buffer.c \
> test-premult.c \
> diff --git a/tests/conform/test-conform-main.c
> b/tests/conform/test-conform-main.c
> index b510543..5b89870 100644
> --- a/tests/conform/test-conform-main.c
> +++ b/tests/conform/test-conform-main.c
> @@ -52,7 +52,6 @@ main (int argc, char **argv)
> UNPORTED_TEST (test_object);
> UNPORTED_TEST (test_fixed);
> UNPORTED_TEST (test_materials);
> - ADD_TEST (test_pipeline_user_matrix, 0, 0);
> ADD_TEST (test_blend_strings, 0, 0);
> ADD_TEST (test_premult, 0, 0);
> UNPORTED_TEST (test_readpixels);
> diff --git a/tests/conform/test-pipeline-user-matrix.c
> b/tests/conform/test-pipeline-user-matrix.c
> deleted file mode 100644
> index 9a7beea..0000000
> --- a/tests/conform/test-pipeline-user-matrix.c
> +++ /dev/null
> @@ -1,141 +0,0 @@
> -#include <cogl/cogl.h>
> -
> -#include <string.h>
> -
> -#include "test-utils.h"
> -
> -typedef struct _TestState
> -{
> - int width;
> - int height;
> -} TestState;
> -
> -static void
> -validate_result (TestState *state)
> -{
> - uint32_t *pixels, *p;
> - char *screen_pixel;
> - const char *intended_pixel = "#ffffff";
> -
> - /* The textures are setup so that when added together with the
> - correct matrices then all of the pixels should be white. We can
> - verify this by reading back the entire stage */
> - pixels = g_malloc (state->width * state->height * 4);
> -
> - cogl_framebuffer_read_pixels (test_fb,
> - 0, 0, state->width, state->height,
> - COGL_PIXEL_FORMAT_RGBA_8888_PRE,
> - (uint8_t *)pixels);
> -
> - for (p = pixels; p < pixels + state->width * state->height; p++)
> - {
> - screen_pixel = g_strdup_printf ("#%06x", GUINT32_FROM_BE (*p) >> 8);
> - g_assert_cmpstr (screen_pixel, ==, intended_pixel);
> - g_free (screen_pixel);
> - }
> -}
> -
> -static void
> -paint (TestState *state)
> -{
> - /* This texture is painted mirrored around the x-axis */
> - uint8_t data0[] = {
> - 0xff, 0x00, 0x00, /* red -> becomes bottom left */
> - 0x00, 0xff, 0x00, /* green -> becomes bottom right */
> - 0x00, 0x00, 0xff, /* blue -> becomes top left */
> - 0xff, 0x00, 0xff /* magenta -> becomes top right */
> - };
> - /* This texture is painted mirrored about the y-axis */
> - uint8_t data1[] = {
> - 0x00, 0xff, 0x00, /* green -> becomes top right */
> - 0xff, 0xff, 0x00, /* yellow -> becomes top left */
> - 0xff, 0x00, 0xff, /* magenta -> becomes bottom right */
> - 0x00, 0xff, 0xff /* cyan -> becomes bottom left */
> - };
> - CoglTexture *tex0, *tex1;
> - CoglPipeline *pipeline;
> - CoglMatrix matrix;
> - CoglError *error = NULL;
> -
> - cogl_framebuffer_orthographic (test_fb,
> - 0, 0,
> - state->width,
> - state->height,
> - -1,
> - 100);
> -
> - cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
> -
> - cogl_matrix_init_identity (&matrix);
> - cogl_framebuffer_set_modelview_matrix (test_fb, &matrix);
> -
> - tex0 = cogl_texture_new_from_data (2, 2,
> - COGL_TEXTURE_NO_ATLAS,
> - COGL_PIXEL_FORMAT_RGB_888,
> - COGL_PIXEL_FORMAT_ANY,
> - 6,
> - data0);
> - tex1 = cogl_texture_new_from_data (2, 2,
> - COGL_TEXTURE_NO_ATLAS,
> - COGL_PIXEL_FORMAT_RGB_888,
> - COGL_PIXEL_FORMAT_ANY,
> - 6,
> - data1);
> -
> - pipeline = cogl_pipeline_new (test_ctx);
> -
> - /* Set the two textures as layers */
> - cogl_pipeline_set_layer_texture (pipeline, 0, tex0);
> - cogl_pipeline_set_layer_filters (pipeline, 0,
> - COGL_PIPELINE_FILTER_NEAREST,
> - COGL_PIPELINE_FILTER_NEAREST);
> - cogl_pipeline_set_layer_texture (pipeline, 1, tex1);
> - cogl_pipeline_set_layer_filters (pipeline, 1,
> - COGL_PIPELINE_FILTER_NEAREST,
> - COGL_PIPELINE_FILTER_NEAREST);
> -
> - /* Set a combine mode so that the two textures get added together */
> - if (!cogl_pipeline_set_layer_combine (pipeline, 1,
> - "RGBA=ADD(PREVIOUS, TEXTURE)",
> - &error))
> - {
> - g_warning ("Error setting blend string: %s", error->message);
> - g_assert_not_reached ();
> - }
> -
> - /* Set a matrix on the first layer so that it will mirror about the
> y-axis */
> - cogl_matrix_init_identity (&matrix);
> - cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f);
> - cogl_matrix_scale (&matrix, 1.0f, -1.0f, 1.0f);
> - cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
> -
> - /* Set a matrix on the second layer so that it will mirror about the
> x-axis */
> - cogl_matrix_init_identity (&matrix);
> - cogl_matrix_translate (&matrix, 1.0f, 0.0f, 0.0f);
> - cogl_matrix_scale (&matrix, -1.0f, 1.0f, 1.0f);
> - cogl_pipeline_set_layer_matrix (pipeline, 1, &matrix);
> -
> - cogl_framebuffer_draw_rectangle (test_fb,
> - pipeline,
> - 0, 0,
> - state->width, state->height);
> -
> - cogl_object_unref (tex1);
> - cogl_object_unref (tex0);
> - cogl_object_unref (pipeline);
> -}
> -
> -void
> -test_pipeline_user_matrix (void)
> -{
> - TestState state;
> -
> - state.width = cogl_framebuffer_get_width (test_fb);
> - state.height = cogl_framebuffer_get_height (test_fb);
> -
> - paint (&state);
> - validate_result (&state);
> -
> - if (cogl_test_verbose ())
> - g_print ("OK\n");
> -}
> diff --git a/tests/conform/test-snippets.c b/tests/conform/test-snippets.c
> index 51bd090..eeb1cdb 100644
> --- a/tests/conform/test-snippets.c
> +++ b/tests/conform/test-snippets.c
> @@ -430,15 +430,10 @@ test_modify_vertex_layer (TestState *state)
> {
> CoglPipeline *pipeline;
> CoglSnippet *snippet;
> - CoglMatrix matrix;
>
> /* Test modifying the vertex layer code */
> pipeline = create_texture_pipeline (state);
>
> - cogl_matrix_init_identity (&matrix);
> - cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f);
> - cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
> -
> snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM,
> NULL,
> "cogl_tex_coord.x = 1.0;");
> @@ -448,7 +443,7 @@ test_modify_vertex_layer (TestState *state)
> cogl_framebuffer_draw_textured_rectangle (test_fb,
> pipeline,
> 130, 0, 140, 10,
> - 0, 0, 0, 0);
> + 0, 1, 0, 1);
> cogl_object_unref (pipeline);
>
> test_utils_check_pixel (test_fb, 135, 5, 0xffff00ff);
> @@ -459,26 +454,21 @@ test_replace_vertex_layer (TestState *state)
> {
> CoglPipeline *pipeline;
> CoglSnippet *snippet;
> - CoglMatrix matrix;
>
> /* Test replacing the vertex layer code */
> pipeline = create_texture_pipeline (state);
>
> - cogl_matrix_init_identity (&matrix);
> - cogl_matrix_translate (&matrix, 0.0f, 1.0f, 0.0f);
> - cogl_pipeline_set_layer_matrix (pipeline, 0, &matrix);
> -
> snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM,
> NULL,
> NULL);
> - cogl_snippet_set_replace (snippet, "cogl_tex_coord.x = 1.0;\n");
> + cogl_snippet_set_replace (snippet, "cogl_tex_coord.xy = vec2 (1.0,
> 0.0);\n");
> cogl_pipeline_add_layer_snippet (pipeline, 0, snippet);
> cogl_object_unref (snippet);
>
> cogl_framebuffer_draw_textured_rectangle (test_fb,
> pipeline,
> 140, 0, 150, 10,
> - 0, 0, 0, 0);
> + 1, 1, 1, 1);
> cogl_object_unref (pipeline);
>
> test_utils_check_pixel (test_fb, 145, 5, 0x00ff00ff);
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/cogl/attachments/20121121/75d696ce/attachment-0001.html>
More information about the Cogl
mailing list