From 8cac82318f23c967af3853e23c15d87cceceef62 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 7 Mar 2019 13:44:49 -0500 Subject: [PATCH 1/5] cogl: Remove unused CoglPipelineProgramType There is only GLSL. https://gitlab.gnome.org/GNOME/mutter/merge_requests/819 --- cogl/cogl/cogl-context-private.h | 2 - cogl/cogl/cogl-context.c | 2 - cogl/cogl/cogl-pipeline-private.h | 10 +- cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 92 +------------------ .../driver/gl/cogl-pipeline-progend-glsl.c | 3 +- 5 files changed, 4 insertions(+), 105 deletions(-) diff --git a/cogl/cogl/cogl-context-private.h b/cogl/cogl/cogl-context-private.h index 04040ce8c83..e497c445149 100644 --- a/cogl/cogl/cogl-context-private.h +++ b/cogl/cogl/cogl-context-private.h @@ -249,8 +249,6 @@ struct _CoglContext /* Fragment processing programs */ CoglHandle current_program; - CoglPipelineProgramType current_fragment_program_type; - CoglPipelineProgramType current_vertex_program_type; GLuint current_gl_program; gboolean current_gl_dither_enabled; diff --git a/cogl/cogl/cogl-context.c b/cogl/cogl/cogl-context.c index f1a8bf2fc32..0bc8163c736 100644 --- a/cogl/cogl/cogl-context.c +++ b/cogl/cogl/cogl-context.c @@ -299,8 +299,6 @@ cogl_context_new (CoglDisplay *display, context->max_texture_units = -1; context->max_activateable_texture_units = -1; - context->current_fragment_program_type = COGL_PIPELINE_PROGRAM_TYPE_GLSL; - context->current_vertex_program_type = COGL_PIPELINE_PROGRAM_TYPE_GLSL; context->current_gl_program = 0; context->current_gl_dither_enabled = TRUE; diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 59f043b67fc..79e41d67637 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -481,11 +481,6 @@ typedef struct void (* pre_paint) (CoglPipeline *pipeline, CoglFramebuffer *framebuffer); } CoglPipelineProgend; -typedef enum -{ - COGL_PIPELINE_PROGRAM_TYPE_GLSL = 1, -} CoglPipelineProgramType; - extern const CoglPipelineFragend * _cogl_pipeline_fragends[COGL_PIPELINE_N_FRAGENDS]; extern const CoglPipelineVertend * @@ -618,10 +613,7 @@ typedef struct _CoglPipelineFlushOptions } CoglPipelineFlushOptions; void -_cogl_use_fragment_program (GLuint gl_program, CoglPipelineProgramType type); - -void -_cogl_use_vertex_program (GLuint gl_program, CoglPipelineProgramType type); +cogl_use_program (GLuint gl_program); unsigned int _cogl_get_n_args_for_combine_func (CoglPipelineCombineFunc func); diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index adda9356702..4ae5bea74dc 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -238,8 +238,8 @@ _cogl_pipeline_texture_storage_change_notify (CoglTexture *texture) } } -static void -set_glsl_program (GLuint gl_program) +void +cogl_use_program (GLuint gl_program) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -257,94 +257,6 @@ set_glsl_program (GLuint gl_program) } } -void -_cogl_use_fragment_program (GLuint gl_program, CoglPipelineProgramType type) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - /* If we're changing program type... */ - if (type != ctx->current_fragment_program_type) - { - /* ... disable the old type */ - switch (ctx->current_fragment_program_type) - { - case COGL_PIPELINE_PROGRAM_TYPE_GLSL: - /* If the program contains a vertex shader then we shouldn't - disable it */ - if (ctx->current_vertex_program_type != - COGL_PIPELINE_PROGRAM_TYPE_GLSL) - set_glsl_program (0); - break; - } - - /* ... and enable the new type */ - switch (type) - { - case COGL_PIPELINE_PROGRAM_TYPE_GLSL: - /* don't need to to anything */ - break; - } - } - - if (type == COGL_PIPELINE_PROGRAM_TYPE_GLSL) - { -#ifdef COGL_PIPELINE_FRAGEND_GLSL - set_glsl_program (gl_program); - -#else - - g_warning ("Unexpected use of GLSL fragend!"); - -#endif /* COGL_PIPELINE_FRAGEND_GLSL */ - } - - ctx->current_fragment_program_type = type; -} - -void -_cogl_use_vertex_program (GLuint gl_program, CoglPipelineProgramType type) -{ - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - /* If we're changing program type... */ - if (type != ctx->current_vertex_program_type) - { - /* ... disable the old type */ - switch (ctx->current_vertex_program_type) - { - case COGL_PIPELINE_PROGRAM_TYPE_GLSL: - /* If the program contains a fragment shader then we shouldn't - disable it */ - if (ctx->current_fragment_program_type != - COGL_PIPELINE_PROGRAM_TYPE_GLSL) - set_glsl_program (0); - break; - } - - /* ... and enable the new type */ - switch (type) - { - case COGL_PIPELINE_PROGRAM_TYPE_GLSL: - /* don't need to to anything */ - break; - } - } - - if (type == COGL_PIPELINE_PROGRAM_TYPE_GLSL) - { -#ifdef COGL_PIPELINE_VERTEND_GLSL - set_glsl_program (gl_program); - -#else - - g_warning ("Unexpected use of GLSL vertend!"); - -#endif /* COGL_PIPELINE_VERTEND_GLSL */ - } - - ctx->current_vertex_program_type = type; -} - #if defined(HAVE_COGL_GLES2) || defined(HAVE_COGL_GL) static gboolean diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c index dfcd8ce8fb7..06d6afc22be 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c @@ -773,8 +773,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, gl_program = program_state->program; - _cogl_use_fragment_program (gl_program, COGL_PIPELINE_PROGRAM_TYPE_GLSL); - _cogl_use_vertex_program (gl_program, COGL_PIPELINE_PROGRAM_TYPE_GLSL); + cogl_use_program (gl_program); state.unit = 0; state.gl_program = gl_program; -- GitLab From f5050a4f80ea967a187c9c848f692e731d31fae8 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 7 Mar 2019 13:50:35 -0500 Subject: [PATCH 2/5] cogl: Remove unused CoglPipelineFragend::pipeline_set_parent_notify https://gitlab.gnome.org/GNOME/mutter/merge_requests/819 --- cogl/cogl/cogl-pipeline-private.h | 1 - cogl/cogl/cogl-pipeline.c | 17 ----------------- .../cogl/driver/gl/cogl-pipeline-fragend-glsl.c | 1 - 3 files changed, 19 deletions(-) diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 79e41d67637..93f31f40617 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -436,7 +436,6 @@ typedef struct _CoglPipelineFragend void (*pipeline_pre_change_notify) (CoglPipeline *pipeline, CoglPipelineState change, const CoglColor *new_color); - void (*pipeline_set_parent_notify) (CoglPipeline *pipeline); void (*layer_pre_change_notify) (CoglPipeline *owner, CoglPipelineLayer *layer, CoglPipelineLayerState change); diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index b119a2c125d..04a8a7cd2a9 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -227,23 +227,6 @@ _cogl_pipeline_set_parent (CoglPipeline *pipeline, * layers could now be invalid so free it... */ if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS) recursively_free_layer_caches (pipeline); - - /* If the backends are also caching state along with the pipeline - * that depends on the pipeline's ancestry then it may be notified - * here... - */ - if (pipeline->progend != COGL_PIPELINE_PROGEND_UNDEFINED) - { - const CoglPipelineProgend *progend = - _cogl_pipeline_progends[pipeline->progend]; - const CoglPipelineFragend *fragend = - _cogl_pipeline_fragends[progend->fragend]; - - /* Currently only the fragends ever care about reparenting of - * pipelines... */ - if (fragend->pipeline_set_parent_notify) - fragend->pipeline_set_parent_notify (pipeline); - } } static void diff --git a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c index e543498a2c3..6beed12eb62 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c @@ -1122,7 +1122,6 @@ const CoglPipelineFragend _cogl_pipeline_glsl_fragend = NULL, /* passthrough */ _cogl_pipeline_fragend_glsl_end, _cogl_pipeline_fragend_glsl_pre_change_notify, - NULL, /* pipeline_set_parent_notify */ _cogl_pipeline_fragend_glsl_layer_pre_change_notify }; -- GitLab From e922c640efa70da43ee3869743e0a751f86b97b4 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 7 Mar 2019 13:52:33 -0500 Subject: [PATCH 3/5] cogl: Remove unused CoglPipelineFragend::passthrough https://gitlab.gnome.org/GNOME/mutter/merge_requests/819 --- cogl/cogl/cogl-pipeline-private.h | 1 - cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c | 1 - cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 7 ------- 3 files changed, 9 deletions(-) diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 93f31f40617..4d6a589c109 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -429,7 +429,6 @@ typedef struct _CoglPipelineFragend gboolean (*add_layer) (CoglPipeline *pipeline, CoglPipelineLayer *layer, unsigned long layers_difference); - gboolean (*passthrough) (CoglPipeline *pipeline); gboolean (*end) (CoglPipeline *pipeline, unsigned long pipelines_difference); diff --git a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c index 6beed12eb62..9019e12a64f 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c @@ -1119,7 +1119,6 @@ const CoglPipelineFragend _cogl_pipeline_glsl_fragend = { _cogl_pipeline_fragend_glsl_start, _cogl_pipeline_fragend_glsl_add_layer, - NULL, /* passthrough */ _cogl_pipeline_fragend_glsl_end, _cogl_pipeline_fragend_glsl_pre_change_notify, _cogl_pipeline_fragend_glsl_layer_pre_change_notify diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index 4ae5bea74dc..b73eab7e3bc 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -1173,13 +1173,6 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx, if (G_UNLIKELY (state.error_adding_layer)) continue; - if (!state.added_layer) - { - if (fragend->passthrough && - G_UNLIKELY (!fragend->passthrough (pipeline))) - continue; - } - if (G_UNLIKELY (!fragend->end (pipeline, pipelines_difference))) continue; -- GitLab From 5aa971b177451fd3a349ab94538194ef3b7ced7f Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 30 Sep 2019 12:07:58 -0400 Subject: [PATCH 4/5] cogl: Collapse some COGL_PIPELINE_{VERT,FRAG,PROG}END arrays There is only GLSL now. https://gitlab.gnome.org/GNOME/mutter/merge_requests/819 --- cogl/cogl/cogl-pipeline-layer.c | 10 +- cogl/cogl/cogl-pipeline-private.h | 32 +--- cogl/cogl/cogl-pipeline-state.c | 3 - cogl/cogl/cogl-pipeline.c | 73 +++------ cogl/cogl/driver/gl/cogl-attribute-gl.c | 142 +----------------- .../driver/gl/cogl-pipeline-fragend-glsl.c | 5 - cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 18 +-- .../driver/gl/cogl-pipeline-progend-glsl.c | 6 - .../driver/gl/cogl-pipeline-vertend-glsl.c | 4 - 9 files changed, 34 insertions(+), 259 deletions(-) diff --git a/cogl/cogl/cogl-pipeline-layer.c b/cogl/cogl/cogl-pipeline-layer.c index 457614d5c75..c6f13696a8e 100644 --- a/cogl/cogl/cogl-pipeline-layer.c +++ b/cogl/cogl/cogl-pipeline-layer.c @@ -390,14 +390,10 @@ _cogl_pipeline_layer_pre_change_notify (CoglPipeline *required_owner, * have a single owner and can only be associated with a single * backend that needs to be notified of the layer change... */ - if (required_owner->progend != COGL_PIPELINE_PROGEND_UNDEFINED) { - const CoglPipelineProgend *progend = - _cogl_pipeline_progends[required_owner->progend]; - const CoglPipelineFragend *fragend = - _cogl_pipeline_fragends[progend->fragend]; - const CoglPipelineVertend *vertend = - _cogl_pipeline_vertends[progend->vertend]; + const CoglPipelineProgend *progend = _cogl_pipeline_progend; + const CoglPipelineFragend *fragend = _cogl_pipeline_fragend; + const CoglPipelineVertend *vertend = _cogl_pipeline_vertend; if (fragend->layer_pre_change_notify) fragend->layer_pre_change_notify (required_owner, layer, change); diff --git a/cogl/cogl/cogl-pipeline-private.h b/cogl/cogl/cogl-pipeline-private.h index 4d6a589c109..8031aa1e635 100644 --- a/cogl/cogl/cogl-pipeline-private.h +++ b/cogl/cogl/cogl-pipeline-private.h @@ -49,25 +49,12 @@ #include -#if defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2) - -#define COGL_PIPELINE_PROGEND_GLSL 0 -#define COGL_PIPELINE_VERTEND_GLSL 0 -#define COGL_PIPELINE_FRAGEND_GLSL 0 - -#define COGL_PIPELINE_N_PROGENDS 1 -#define COGL_PIPELINE_N_VERTENDS 1 -#define COGL_PIPELINE_N_FRAGENDS 1 - -#else /* defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2) */ +#if !(defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2)) #error No drivers defined #endif /* defined(HAVE_COGL_GL) || defined(HAVE_COGL_GLES2) */ -#define COGL_PIPELINE_PROGEND_DEFAULT 0 -#define COGL_PIPELINE_PROGEND_UNDEFINED 3 - /* XXX: should I rename these as * COGL_PIPELINE_STATE_INDEX_XYZ... ? */ @@ -413,12 +400,6 @@ struct _CoglPipeline * where the pipeline originates from */ unsigned int has_static_breadcrumb:1; #endif - - /* There are multiple fragment and vertex processing backends for - * CoglPipeline, glsl, arbfp and fixed that are bundled under a - * "progend". This identifies the backend being used for the - * pipeline. */ - unsigned int progend:3; }; typedef struct _CoglPipelineFragend @@ -462,8 +443,6 @@ typedef struct _CoglPipelineVertend typedef struct { - int vertend; - int fragend; gboolean (*start) (CoglPipeline *pipeline); void (*end) (CoglPipeline *pipeline, unsigned long pipelines_difference); @@ -479,12 +458,9 @@ typedef struct void (* pre_paint) (CoglPipeline *pipeline, CoglFramebuffer *framebuffer); } CoglPipelineProgend; -extern const CoglPipelineFragend * -_cogl_pipeline_fragends[COGL_PIPELINE_N_FRAGENDS]; -extern const CoglPipelineVertend * -_cogl_pipeline_vertends[COGL_PIPELINE_N_VERTENDS]; -extern const CoglPipelineProgend * -_cogl_pipeline_progends[]; +extern const CoglPipelineFragend *_cogl_pipeline_fragend; +extern const CoglPipelineVertend *_cogl_pipeline_vertend; +extern const CoglPipelineProgend *_cogl_pipeline_progend; void _cogl_pipeline_init_default_pipeline (void); diff --git a/cogl/cogl/cogl-pipeline-state.c b/cogl/cogl/cogl-pipeline-state.c index db56de88b06..c012e45e587 100644 --- a/cogl/cogl/cogl-pipeline-state.c +++ b/cogl/cogl/cogl-pipeline-state.c @@ -805,9 +805,6 @@ cogl_pipeline_set_user_program (CoglPipeline *pipeline, */ _cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE); - if (program != NULL) - _cogl_pipeline_set_progend (pipeline, COGL_PIPELINE_PROGEND_UNDEFINED); - /* If we are the current authority see if we can revert to one of our * ancestors being the authority */ if (pipeline == authority && diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index 04a8a7cd2a9..37fcfa26347 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -58,24 +58,13 @@ static void _cogl_pipeline_free (CoglPipeline *tex); static void recursively_free_layer_caches (CoglPipeline *pipeline); static gboolean _cogl_pipeline_is_weak (CoglPipeline *pipeline); -const CoglPipelineFragend *_cogl_pipeline_fragends[COGL_PIPELINE_N_FRAGENDS]; -const CoglPipelineVertend *_cogl_pipeline_vertends[COGL_PIPELINE_N_VERTENDS]; -/* The 'MAX' here is so that we don't define an empty array when there - are no progends */ -const CoglPipelineProgend * -_cogl_pipeline_progends[MAX (COGL_PIPELINE_N_PROGENDS, 1)]; - -#ifdef COGL_PIPELINE_FRAGEND_GLSL -#include "driver/gl/cogl-pipeline-fragend-glsl-private.h" -#endif +const CoglPipelineFragend *_cogl_pipeline_fragend; +const CoglPipelineVertend *_cogl_pipeline_vertend; +const CoglPipelineProgend *_cogl_pipeline_progend; -#ifdef COGL_PIPELINE_VERTEND_GLSL +#include "driver/gl/cogl-pipeline-fragend-glsl-private.h" #include "driver/gl/cogl-pipeline-vertend-glsl-private.h" -#endif - -#ifdef COGL_PIPELINE_PROGEND_GLSL #include "driver/gl/cogl-pipeline-progend-glsl-private.h" -#endif COGL_OBJECT_DEFINE (Pipeline, pipeline); COGL_GTYPE_DEFINE_CLASS (Pipeline, pipeline); @@ -103,25 +92,14 @@ _cogl_pipeline_init_default_pipeline (void) _COGL_GET_CONTEXT (ctx, NO_RETVAL); /* Take this opportunity to setup the backends... */ -#ifdef COGL_PIPELINE_FRAGEND_GLSL - _cogl_pipeline_fragends[COGL_PIPELINE_FRAGEND_GLSL] = - &_cogl_pipeline_glsl_fragend; -#endif -#ifdef COGL_PIPELINE_PROGEND_GLSL - _cogl_pipeline_progends[COGL_PIPELINE_PROGEND_GLSL] = - &_cogl_pipeline_glsl_progend; -#endif - -#ifdef COGL_PIPELINE_VERTEND_GLSL - _cogl_pipeline_vertends[COGL_PIPELINE_VERTEND_GLSL] = - &_cogl_pipeline_glsl_vertend; -#endif + _cogl_pipeline_fragend = &_cogl_pipeline_glsl_fragend; + _cogl_pipeline_progend = &_cogl_pipeline_glsl_progend; + _cogl_pipeline_vertend = &_cogl_pipeline_glsl_vertend; _cogl_pipeline_node_init (COGL_NODE (pipeline)); pipeline->is_weak = FALSE; pipeline->journal_ref_count = 0; - pipeline->progend = COGL_PIPELINE_PROGEND_UNDEFINED; pipeline->differences = COGL_PIPELINE_STATE_ALL_SPARSE; pipeline->real_blend_enable = FALSE; @@ -306,8 +284,6 @@ _cogl_pipeline_copy (CoglPipeline *src, gboolean is_weak) pipeline->deprecated_get_layers_list = NULL; pipeline->deprecated_get_layers_list_dirty = TRUE; - pipeline->progend = src->progend; - pipeline->has_static_breadcrumb = FALSE; pipeline->age = 0; @@ -840,12 +816,6 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline, return FALSE; } -void -_cogl_pipeline_set_progend (CoglPipeline *pipeline, int progend) -{ - pipeline->progend = progend; -} - static void _cogl_pipeline_copy_differences (CoglPipeline *dest, CoglPipeline *src, @@ -1179,28 +1149,21 @@ _cogl_pipeline_pre_change_notify (CoglPipeline *pipeline, */ if (!from_layer_change) { - int i; - - for (i = 0; i < COGL_PIPELINE_N_PROGENDS; i++) - { - const CoglPipelineProgend *progend = _cogl_pipeline_progends[i]; - const CoglPipelineVertend *vertend = - _cogl_pipeline_vertends[progend->vertend]; - const CoglPipelineFragend *fragend = - _cogl_pipeline_fragends[progend->fragend]; + const CoglPipelineProgend *progend = _cogl_pipeline_progend; + const CoglPipelineVertend *vertend = _cogl_pipeline_vertend; + const CoglPipelineFragend *fragend = _cogl_pipeline_fragend; - if (vertend->pipeline_pre_change_notify) - vertend->pipeline_pre_change_notify (pipeline, change, new_color); + if (vertend->pipeline_pre_change_notify) + vertend->pipeline_pre_change_notify (pipeline, change, new_color); - /* TODO: make the vertend and fragend implementation details - * of the progend */ + /* TODO: make the vertend and fragend implementation details + * of the progend */ - if (fragend->pipeline_pre_change_notify) - fragend->pipeline_pre_change_notify (pipeline, change, new_color); + if (fragend->pipeline_pre_change_notify) + fragend->pipeline_pre_change_notify (pipeline, change, new_color); - if (progend->pipeline_pre_change_notify) - progend->pipeline_pre_change_notify (pipeline, change, new_color); - } + if (progend->pipeline_pre_change_notify) + progend->pipeline_pre_change_notify (pipeline, change, new_color); } /* There may be an arbitrary tree of descendants of this pipeline; diff --git a/cogl/cogl/driver/gl/cogl-attribute-gl.c b/cogl/cogl/driver/gl/cogl-attribute-gl.c index 8a5f2fa11b6..a29ea82b932 100644 --- a/cogl/cogl/driver/gl/cogl-attribute-gl.c +++ b/cogl/cogl/driver/gl/cogl-attribute-gl.c @@ -156,8 +156,6 @@ foreach_changed_bit_and_save (CoglContext *context, _cogl_bitmask_set_bits (current_bits, new_bits); } -#ifdef COGL_PIPELINE_PROGEND_GLSL - static void setup_generic_buffered_attribute (CoglContext *context, CoglPipeline *pipeline, @@ -229,136 +227,6 @@ setup_generic_const_attribute (CoglContext *context, } } -#endif /* COGL_PIPELINE_PROGEND_GLSL */ - -static void -setup_legacy_buffered_attribute (CoglContext *ctx, - CoglPipeline *pipeline, - CoglAttribute *attribute, - uint8_t *base) -{ - switch (attribute->name_state->name_id) - { - case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY: - _cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp, - COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY, TRUE); - GE (ctx, glColorPointer (attribute->d.buffered.n_components, - attribute->d.buffered.type, - attribute->d.buffered.stride, - base + attribute->d.buffered.offset)); - break; - case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY: - _cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp, - COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY, TRUE); - GE (ctx, glNormalPointer (attribute->d.buffered.type, - attribute->d.buffered.stride, - base + attribute->d.buffered.offset)); - break; - 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_with_flags (pipeline, layer_number, flags); - - if (layer) - { - int unit = _cogl_pipeline_layer_get_unit_index (layer); - - _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: - _cogl_bitmask_set (&ctx->enable_builtin_attributes_tmp, - COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY, TRUE); - GE (ctx, glVertexPointer (attribute->d.buffered.n_components, - attribute->d.buffered.type, - attribute->d.buffered.stride, - base + attribute->d.buffered.offset)); - break; - case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY: -#ifdef COGL_PIPELINE_PROGEND_GLSL - if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE)) - setup_generic_buffered_attribute (ctx, pipeline, attribute, base); -#endif - break; - default: - g_warn_if_reached (); - } -} - -static void -setup_legacy_const_attribute (CoglContext *ctx, - CoglPipeline *pipeline, - CoglAttribute *attribute) -{ -#ifdef COGL_PIPELINE_PROGEND_GLSL - if (attribute->name_state->name_id == COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY) - { - if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE)) - setup_generic_const_attribute (ctx, pipeline, attribute); - } - else -#endif - { - float vector[4] = { 0, 0, 0, 1 }; - float *boxed = attribute->d.constant.boxed.v.float_value; - int n_components = attribute->d.constant.boxed.size; - int i; - - for (i = 0; i < n_components; i++) - vector[i] = boxed[i]; - - switch (attribute->name_state->name_id) - { - case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY: - GE (ctx, glColor4f (vector[0], vector[1], vector[2], vector[3])); - break; - case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY: - GE (ctx, glNormal3f (vector[0], vector[1], vector[2])); - break; - 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_with_flags (pipeline, - layer_number, - flags); - - 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])); - } - break; - } - case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY: - GE (ctx, glVertex4f (vector[0], vector[1], vector[2], vector[3])); - break; - default: - g_warn_if_reached (); - } - } -} - static void apply_attribute_enable_updates (CoglContext *context, CoglPipeline *pipeline) @@ -502,19 +370,13 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER, NULL); - if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL) - setup_generic_buffered_attribute (ctx, pipeline, attribute, base); - else - setup_legacy_buffered_attribute (ctx, pipeline, attribute, base); + setup_generic_buffered_attribute (ctx, pipeline, attribute, base); _cogl_buffer_gl_unbind (buffer); } else { - if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL) - setup_generic_const_attribute (ctx, pipeline, attribute); - else - setup_legacy_const_attribute (ctx, pipeline, attribute); + setup_generic_const_attribute (ctx, pipeline, attribute); } } diff --git a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c index 9019e12a64f..8a41e7f5d73 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-fragend-glsl.c @@ -44,8 +44,6 @@ #include "cogl-list.h" #include "driver/gl/cogl-util-gl-private.h" -#ifdef COGL_PIPELINE_FRAGEND_GLSL - #include "cogl-context-private.h" #include "cogl-object-private.h" #include "cogl-pipeline-cache.h" @@ -1123,6 +1121,3 @@ const CoglPipelineFragend _cogl_pipeline_glsl_fragend = _cogl_pipeline_fragend_glsl_pre_change_notify, _cogl_pipeline_fragend_glsl_layer_pre_change_notify }; - -#endif /* COGL_PIPELINE_FRAGEND_GLSL */ - diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index b73eab7e3bc..89696b9668a 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -998,7 +998,6 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx, unsigned long pipelines_difference; int n_layers; unsigned long *layer_differences; - int i; CoglTextureUnit *unit1; const CoglPipelineProgend *progend; @@ -1113,23 +1112,19 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx, * with the given progend so we will simply use that to avoid * fallback code paths. */ - if (pipeline->progend == COGL_PIPELINE_PROGEND_UNDEFINED) - _cogl_pipeline_set_progend (pipeline, COGL_PIPELINE_PROGEND_DEFAULT); - for (i = pipeline->progend; - i < COGL_PIPELINE_N_PROGENDS; - i++, _cogl_pipeline_set_progend (pipeline, i)) + do { const CoglPipelineVertend *vertend; const CoglPipelineFragend *fragend; CoglPipelineAddLayerState state; - progend = _cogl_pipeline_progends[i]; + progend = _cogl_pipeline_progend; if (G_UNLIKELY (!progend->start (pipeline))) continue; - vertend = _cogl_pipeline_vertends[progend->vertend]; + vertend = _cogl_pipeline_vertend; vertend->start (pipeline, n_layers, @@ -1159,7 +1154,7 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx, * ctx->codegen_source_buffer as a scratch buffer. */ - fragend = _cogl_pipeline_fragends[progend->fragend]; + fragend = _cogl_pipeline_fragend; state.fragend = fragend; fragend->start (pipeline, @@ -1180,6 +1175,7 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx, progend->end (pipeline, pipelines_difference); break; } + while (0); /* FIXME: This reference is actually resulting in lots of * copy-on-write reparenting because one-shot pipelines end up @@ -1200,13 +1196,13 @@ _cogl_pipeline_flush_gl_state (CoglContext *ctx, done: - progend = _cogl_pipeline_progends[pipeline->progend]; + progend = _cogl_pipeline_progend; /* We can't assume the color will be retained between flushes when * using the glsl progend because the generic attribute values are * not stored as part of the program object so they could be * overridden by any attribute changes in another program */ - if (pipeline->progend == COGL_PIPELINE_PROGEND_GLSL && !with_color_attrib) + if (!with_color_attrib) { int attribute; CoglPipeline *authority = diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c index 06d6afc22be..df4a04b722e 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c @@ -42,8 +42,6 @@ #include "driver/gl/cogl-util-gl-private.h" #include "driver/gl/cogl-pipeline-opengl-private.h" -#ifdef COGL_PIPELINE_PROGEND_GLSL - #include "cogl-context-private.h" #include "cogl-object-private.h" #include "cogl-pipeline-cache.h" @@ -1056,13 +1054,9 @@ update_float_uniform (CoglPipeline *pipeline, const CoglPipelineProgend _cogl_pipeline_glsl_progend = { - COGL_PIPELINE_VERTEND_GLSL, - COGL_PIPELINE_FRAGEND_GLSL, _cogl_pipeline_progend_glsl_start, _cogl_pipeline_progend_glsl_end, _cogl_pipeline_progend_glsl_pre_change_notify, _cogl_pipeline_progend_glsl_layer_pre_change_notify, _cogl_pipeline_progend_glsl_pre_paint }; - -#endif /* COGL_PIPELINE_PROGEND_GLSL */ diff --git a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c index 77f2458e9db..e7fbc2cbeda 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-vertend-glsl.c @@ -42,8 +42,6 @@ #include "driver/gl/cogl-util-gl-private.h" #include "driver/gl/cogl-pipeline-opengl-private.h" -#ifdef COGL_PIPELINE_VERTEND_GLSL - #include "cogl-context-private.h" #include "cogl-object-private.h" #include "cogl-pipeline-state-private.h" @@ -668,5 +666,3 @@ UNIT_TEST (check_point_size_shader, /* The fourth pipeline should be exactly the same as the first */ g_assert (shader_states[0] == shader_states[3]); } - -#endif /* COGL_PIPELINE_VERTEND_GLSL */ -- GitLab From 22d1febf3c40510ddb6ed2fd5e70b96c3382cb7a Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 17 Oct 2019 16:12:22 -0400 Subject: [PATCH 5/5] cogl: Remove unused CoglShaderLanguage There is only GLSL. https://gitlab.gnome.org/GNOME/mutter/merge_requests/819 --- cogl/cogl/deprecated/cogl-program-private.h | 3 -- cogl/cogl/deprecated/cogl-program.c | 41 +++---------------- cogl/cogl/deprecated/cogl-shader-private.h | 6 --- cogl/cogl/deprecated/cogl-shader.c | 10 ----- .../driver/gl/cogl-pipeline-progend-glsl.c | 11 ----- 5 files changed, 6 insertions(+), 65 deletions(-) diff --git a/cogl/cogl/deprecated/cogl-program-private.h b/cogl/cogl/deprecated/cogl-program-private.h index a692e2ebd81..38b5f59d817 100644 --- a/cogl/cogl/deprecated/cogl-program-private.h +++ b/cogl/cogl/deprecated/cogl-program-private.h @@ -76,9 +76,6 @@ _cogl_program_flush_uniforms (CoglProgram *program, GLuint gl_program, gboolean gl_program_changed); -CoglShaderLanguage -_cogl_program_get_language (CoglHandle handle); - gboolean _cogl_program_has_fragment_shader (CoglHandle handle); diff --git a/cogl/cogl/deprecated/cogl-program.c b/cogl/cogl/deprecated/cogl-program.c index d4d1cdd9968..49fd9a28138 100644 --- a/cogl/cogl/deprecated/cogl-program.c +++ b/cogl/cogl/deprecated/cogl-program.c @@ -96,7 +96,6 @@ cogl_program_attach_shader (CoglHandle program_handle, CoglHandle shader_handle) { CoglProgram *program; - CoglShader *shader; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -104,11 +103,6 @@ cogl_program_attach_shader (CoglHandle program_handle, return; program = program_handle; - shader = shader_handle; - - if (shader->language == COGL_SHADER_LANGUAGE_GLSL) - g_return_if_fail (_cogl_program_get_language (program) == - COGL_SHADER_LANGUAGE_GLSL); program->attached_shaders = g_slist_prepend (program->attached_shaders, @@ -355,26 +349,19 @@ _cogl_program_flush_uniforms (CoglProgram *program, { if (gl_program_changed || !uniform->location_valid) { - if (_cogl_program_get_language (program) == - COGL_SHADER_LANGUAGE_GLSL) - uniform->location = - ctx->glGetUniformLocation (gl_program, uniform->name); + uniform->location = + ctx->glGetUniformLocation (gl_program, uniform->name); - uniform->location_valid = TRUE; + uniform->location_valid = TRUE; } /* If the uniform isn't really in the program then there's no need to actually set it */ if (uniform->location != -1) { - switch (_cogl_program_get_language (program)) - { - case COGL_SHADER_LANGUAGE_GLSL: - _cogl_boxed_value_set_uniform (ctx, - uniform->location, - &uniform->value); - break; - } + _cogl_boxed_value_set_uniform (ctx, + uniform->location, + &uniform->value); } uniform->dirty = FALSE; @@ -382,22 +369,6 @@ _cogl_program_flush_uniforms (CoglProgram *program, } } -CoglShaderLanguage -_cogl_program_get_language (CoglHandle handle) -{ - CoglProgram *program = handle; - - /* Use the language of the first shader */ - - if (program->attached_shaders) - { - CoglShader *shader = program->attached_shaders->data; - return shader->language; - } - else - return COGL_SHADER_LANGUAGE_GLSL; -} - static gboolean _cogl_program_has_shader_type (CoglProgram *program, CoglShaderType type) diff --git a/cogl/cogl/deprecated/cogl-shader-private.h b/cogl/cogl/deprecated/cogl-shader-private.h index 76eed7225a1..f19aaa22c85 100644 --- a/cogl/cogl/deprecated/cogl-shader-private.h +++ b/cogl/cogl/deprecated/cogl-shader-private.h @@ -38,18 +38,12 @@ typedef struct _CoglShader CoglShader; -typedef enum -{ - COGL_SHADER_LANGUAGE_GLSL, -} CoglShaderLanguage; - struct _CoglShader { CoglHandleObject _parent; GLuint gl_handle; CoglPipeline *compilation_pipeline; CoglShaderType type; - CoglShaderLanguage language; char *source; }; diff --git a/cogl/cogl/deprecated/cogl-shader.c b/cogl/cogl/deprecated/cogl-shader.c index 05f46e75171..589850fd118 100644 --- a/cogl/cogl/deprecated/cogl-shader.c +++ b/cogl/cogl/deprecated/cogl-shader.c @@ -84,7 +84,6 @@ cogl_create_shader (CoglShaderType type) } shader = g_slice_new (CoglShader); - shader->language = COGL_SHADER_LANGUAGE_GLSL; shader->gl_handle = 0; shader->compilation_pipeline = NULL; shader->type = type; @@ -114,7 +113,6 @@ cogl_shader_source (CoglHandle handle, const char *source) { CoglShader *shader; - CoglShaderLanguage language; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -122,16 +120,8 @@ cogl_shader_source (CoglHandle handle, return; shader = handle; - language = COGL_SHADER_LANGUAGE_GLSL; - - /* Delete the old object if the language is changing... */ - if (G_UNLIKELY (language != shader->language) && - shader->gl_handle) - delete_shader (shader); shader->source = g_strdup (source); - - shader->language = language; } void diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c index df4a04b722e..af7797ead15 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c @@ -638,15 +638,6 @@ _cogl_pipeline_progend_glsl_flush_uniforms (CoglPipeline *pipeline, static gboolean _cogl_pipeline_progend_glsl_start (CoglPipeline *pipeline) { - CoglHandle user_program; - - _COGL_GET_CONTEXT (ctx, FALSE); - - user_program = cogl_pipeline_get_user_program (pipeline); - if (user_program && - _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL) - return FALSE; - return TRUE; } @@ -742,8 +733,6 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline, _cogl_shader_compile_real (shader, pipeline); - g_assert (shader->language == COGL_SHADER_LANGUAGE_GLSL); - GE( ctx, glAttachShader (program_state->program, shader->gl_handle) ); } -- GitLab