From 893e894ffff9f54985eeeafc82096fdcc1f907e5 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 8 Mar 2019 15:40:41 -0500 Subject: [PATCH] cogl: Remove always-true COGL_FEATURE_SHADERS_GLSL https://gitlab.gnome.org/GNOME/mutter/merge_requests/546 --- clutter/clutter/clutter-feature.c | 3 +- cogl/cogl/cogl-context.h | 2 - cogl/cogl/cogl-framebuffer.c | 42 ++++++------------- cogl/cogl/cogl-pipeline-state.h | 4 -- cogl/cogl/cogl-pipeline.c | 5 +-- cogl/cogl/cogl-renderer.c | 3 +- cogl/cogl/cogl-types.h | 2 - cogl/cogl/deprecated/cogl-material-compat.h | 4 -- cogl/cogl/deprecated/cogl-shader.h | 5 --- cogl/cogl/driver/gl/cogl-pipeline-opengl.c | 21 +++------- .../driver/gl/cogl-pipeline-progend-glsl.c | 3 -- cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 3 -- cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 3 +- cogl/test-fixtures/test-utils.c | 6 --- 14 files changed, 24 insertions(+), 82 deletions(-) diff --git a/clutter/clutter/clutter-feature.c b/clutter/clutter/clutter-feature.c index 6ce76273f..08d9749df 100644 --- a/clutter/clutter/clutter-feature.c +++ b/clutter/clutter/clutter-feature.c @@ -73,8 +73,7 @@ clutter_features_from_cogl (guint cogl_flags) if (cogl_flags & COGL_FEATURE_TEXTURE_READ_PIXELS) clutter_flags |= CLUTTER_FEATURE_TEXTURE_READ_PIXELS; - if (cogl_flags & COGL_FEATURE_SHADERS_GLSL) - clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL; + clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL; if (cogl_flags & COGL_FEATURE_OFFSCREEN) clutter_flags |= CLUTTER_FEATURE_OFFSCREEN; diff --git a/cogl/cogl/cogl-context.h b/cogl/cogl/cogl-context.h index 5016a216b..bc5df324e 100644 --- a/cogl/cogl/cogl-context.h +++ b/cogl/cogl/cogl-context.h @@ -199,7 +199,6 @@ cogl_is_context (void *object); * offscreen framebuffers * @COGL_FEATURE_ID_ONSCREEN_MULTIPLE: Multiple onscreen framebuffers * supported. - * @COGL_FEATURE_ID_GLSL: GLSL support * @COGL_FEATURE_ID_UNSIGNED_INT_INDICES: Set if * %COGL_INDICES_TYPE_UNSIGNED_INT is supported in * cogl_indices_new(). @@ -240,7 +239,6 @@ typedef enum _CoglFeatureID COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT, COGL_FEATURE_ID_TEXTURE_NPOT, COGL_FEATURE_ID_TEXTURE_RECTANGLE, - COGL_FEATURE_ID_GLSL, COGL_FEATURE_ID_OFFSCREEN, COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE, COGL_FEATURE_ID_ONSCREEN_MULTIPLE, diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c index f847d0ccd..86ac5507b 100644 --- a/cogl/cogl/cogl-framebuffer.c +++ b/cogl/cogl/cogl-framebuffer.c @@ -1992,15 +1992,6 @@ get_wire_line_indices (CoglContext *ctx, return ret; } -static gboolean -remove_layer_cb (CoglPipeline *pipeline, - int layer_index, - void *user_data) -{ - cogl_pipeline_remove_layer (pipeline, layer_index); - return TRUE; -} - static void pipeline_destroyed_cb (CoglPipeline *weak_pipeline, void *user_data) { @@ -2052,6 +2043,8 @@ draw_wireframe (CoglContext *ctx, if (!wire_pipeline) { + static CoglSnippet *snippet = NULL; + wire_pipeline = _cogl_pipeline_weak_copy (pipeline, pipeline_destroyed_cb, NULL); @@ -2063,29 +2056,20 @@ draw_wireframe (CoglContext *ctx, * vertex program and since we'd like to see the results of the * vertex program in the wireframe we just add a final clobber * of the wire color leaving the rest of the state untouched. */ - if (cogl_has_feature (framebuffer->context, COGL_FEATURE_ID_GLSL)) - { - static CoglSnippet *snippet = NULL; - /* The snippet is cached so that it will reuse the program - * from the pipeline cache if possible */ - if (snippet == NULL) - { - snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, - NULL, - NULL); - cogl_snippet_set_replace (snippet, - "cogl_color_out = " - "vec4 (0.0, 1.0, 0.0, 1.0);\n"); - } - - cogl_pipeline_add_snippet (wire_pipeline, snippet); - } - else + /* The snippet is cached so that it will reuse the program + * from the pipeline cache if possible */ + if (snippet == NULL) { - cogl_pipeline_foreach_layer (wire_pipeline, remove_layer_cb, NULL); - cogl_pipeline_set_color4f (wire_pipeline, 0, 1, 0, 1); + snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT, + NULL, + NULL); + cogl_snippet_set_replace (snippet, + "cogl_color_out = " + "vec4 (0.0, 1.0, 0.0, 1.0);\n"); } + + cogl_pipeline_add_snippet (wire_pipeline, snippet); } /* temporarily disable the wireframe to avoid recursion! */ diff --git a/cogl/cogl/cogl-pipeline-state.h b/cogl/cogl/cogl-pipeline-state.h index 6ea39f63c..5ac9bc9d3 100644 --- a/cogl/cogl/cogl-pipeline-state.h +++ b/cogl/cogl/cogl-pipeline-state.h @@ -626,10 +626,6 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline); * meantime we hope this will handle most practical GLSL and ARBfp * requirements. * - * Also remember you need to check for either the - * %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before - * using the cogl_program or cogl_shader API. - * * Since: 2.0 * Stability: Unstable */ diff --git a/cogl/cogl/cogl-pipeline.c b/cogl/cogl/cogl-pipeline.c index d61ee668d..cdcf5a657 100644 --- a/cogl/cogl/cogl-pipeline.c +++ b/cogl/cogl/cogl-pipeline.c @@ -3054,11 +3054,10 @@ _cogl_pipeline_get_layer_state_for_fragment_codegen (CoglContext *context) COGL_PIPELINE_LAYER_STATE_UNIT | COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS); - /* If the driver supports GLSL then we might be using gl_PointCoord + /* Since the driver supports GLSL then we might be using gl_PointCoord * to implement the sprite coords. In that case the generated code * depends on the point sprite state */ - if (cogl_has_feature (context, COGL_FEATURE_ID_GLSL)) - state |= COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS; + state |= COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS; return state; } diff --git a/cogl/cogl/cogl-renderer.c b/cogl/cogl/cogl-renderer.c index 854aa1fdd..7b39e439d 100644 --- a/cogl/cogl/cogl-renderer.c +++ b/cogl/cogl/cogl-renderer.c @@ -784,8 +784,7 @@ cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer) _COGL_GET_CONTEXT (ctx, 0); #if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2) - if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL)) - GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n)); + GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n)); #endif return n; diff --git a/cogl/cogl/cogl-types.h b/cogl/cogl/cogl-types.h index 981b74fff..1b8d511e4 100644 --- a/cogl/cogl/cogl-types.h +++ b/cogl/cogl/cogl-types.h @@ -322,7 +322,6 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/ * and %COGL_FEATURE_TEXTURE_NPOT_REPEAT features combined. * @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support * @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support - * @COGL_FEATURE_SHADERS_GLSL: GLSL support * @COGL_FEATURE_OFFSCREEN: FBO support * @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: Multisample support on FBOs * @COGL_FEATURE_OFFSCREEN_BLIT: Blit support on FBOs @@ -364,7 +363,6 @@ typedef enum COGL_FEATURE_TEXTURE_NPOT = (1 << 2), COGL_FEATURE_TEXTURE_YUV = (1 << 3), COGL_FEATURE_TEXTURE_READ_PIXELS = (1 << 4), - COGL_FEATURE_SHADERS_GLSL = (1 << 5), COGL_FEATURE_OFFSCREEN = (1 << 6), COGL_FEATURE_OFFSCREEN_MULTISAMPLE = (1 << 7), COGL_FEATURE_OFFSCREEN_BLIT = (1 << 8), diff --git a/cogl/cogl/deprecated/cogl-material-compat.h b/cogl/cogl/deprecated/cogl-material-compat.h index 45845e9a4..31c9c0f95 100644 --- a/cogl/cogl/deprecated/cogl-material-compat.h +++ b/cogl/cogl/deprecated/cogl-material-compat.h @@ -756,10 +756,6 @@ cogl_material_get_user_program (CoglMaterial *material); * meantime we hope this will handle most practical GLSL and ARBfp * requirements. * - * Also remember you need to check for either the - * %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before - * using the cogl_program or cogl_shader API. - * * Since: 1.4 * Deprecated: 1.16: Use #CoglSnippet api instead instead */ diff --git a/cogl/cogl/deprecated/cogl-shader.h b/cogl/cogl/deprecated/cogl-shader.h index 7f6785efb..88acc181f 100644 --- a/cogl/cogl/deprecated/cogl-shader.h +++ b/cogl/cogl/deprecated/cogl-shader.h @@ -48,11 +48,6 @@ G_BEGIN_DECLS * Cogl allows accessing the GL programmable pipeline in order to create * vertex and fragment shaders. * - * The shader source code can either be GLSL or ARBfp. If the source - * code is ARBfp, it must begin with the string “!!ARBfp1.0”. The - * application should check for the %COGL_FEATURE_SHADERS_GLSL or - * %COGL_FEATURE_SHADERS_ARBFP features before using shaders. - * * When using GLSL Cogl provides replacement names for most of the * builtin varyings and uniforms. It is recommended to use these names * wherever possible to increase portability between OpenGL 2.0 and diff --git a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c index cadb2d2ef..481962354 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-opengl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-opengl.c @@ -673,22 +673,13 @@ get_max_activateable_texture_units (void) #ifdef HAVE_COGL_GL if (!_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_EMBEDDED)) { - /* GL_MAX_TEXTURE_COORDS is provided for both GLSL and ARBfp. It - defines the number of texture coordinates that can be - uploaded (but doesn't necessarily relate to how many texture - images can be sampled) */ - if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL)) - /* Previously this code subtracted the value by one but there - was no explanation for why it did this and it doesn't seem - to make sense so it has been removed */ - GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_COORDS, - values + n_values++)); + /* GL_MAX_TEXTURE_COORDS defines the number of texture coordinates + * that can be uploaded (but doesn't necessarily relate to how many + * texture images can be sampled) */ + GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_COORDS, values + n_values++)); - /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is defined for GLSL but - not ARBfp */ - if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL)) - GE (ctx, glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, - values + n_values++)); + GE (ctx, glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, + values + n_values++)); } #endif /* HAVE_COGL_GL */ diff --git a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c index 1f9baa9be..25a64e8d8 100644 --- a/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c +++ b/cogl/cogl/driver/gl/cogl-pipeline-progend-glsl.c @@ -644,9 +644,6 @@ _cogl_pipeline_progend_glsl_start (CoglPipeline *pipeline) _COGL_GET_CONTEXT (ctx, FALSE); - if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL)) - return FALSE; - user_program = cogl_pipeline_get_user_program (pipeline); if (user_program && _cogl_program_get_language (user_program) != COGL_SHADER_LANGUAGE_GLSL) diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index ab92b0e08..3e709baaa 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -451,9 +451,6 @@ _cogl_driver_update_features (CoglContext *ctx, COGL_FLAGS_SET (private_features, COGL_PRIVATE_FEATURE_BLEND_CONSTANT, TRUE); - flags |= COGL_FEATURE_SHADERS_GLSL; - COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_GLSL, TRUE); - flags |= COGL_FEATURE_POINT_SPRITE; COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_POINT_SPRITE, TRUE); diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index 49a81ba0d..33d1ba0db 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -302,12 +302,11 @@ _cogl_driver_update_features (CoglContext *context, gl_minor, gl_extensions); - flags |= COGL_FEATURE_SHADERS_GLSL | COGL_FEATURE_OFFSCREEN; + flags |= COGL_FEATURE_OFFSCREEN; /* Note GLES 2 core doesn't support mipmaps for npot textures or * repeat modes other than CLAMP_TO_EDGE. */ flags |= COGL_FEATURE_TEXTURE_NPOT_BASIC; flags |= COGL_FEATURE_DEPTH_RANGE; - COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_GLSL, TRUE); COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_OFFSCREEN, TRUE); COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, TRUE); diff --git a/cogl/test-fixtures/test-utils.c b/cogl/test-fixtures/test-utils.c index 1bf2acd26..183c6a3e9 100644 --- a/cogl/test-fixtures/test-utils.c +++ b/cogl/test-fixtures/test-utils.c @@ -66,12 +66,6 @@ check_flags (TestFlags flags, return FALSE; } - if (flags & TEST_REQUIREMENT_GLSL && - !cogl_has_feature (test_ctx, COGL_FEATURE_ID_GLSL)) - { - return FALSE; - } - if (flags & TEST_REQUIREMENT_OFFSCREEN && !cogl_has_feature (test_ctx, COGL_FEATURE_ID_OFFSCREEN)) {