[mutter] cogl: Remove no-op cogl_shader_compile and cogl_shader_get_info_log



commit 5c704e3f81557a8722f4415a9b8d6bd2da88cf61
Author: Adam Jackson <ajax redhat com>
Date:   Thu Jan 16 15:15:34 2020 -0500

    cogl: Remove no-op cogl_shader_compile and cogl_shader_get_info_log
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/1024

 clutter/clutter/clutter-shader-effect.c            | 38 +++---------
 cogl/cogl/cogl-pipeline-state.h                    |  1 -
 cogl/cogl/deprecated/cogl-material-compat.h        |  1 -
 cogl/cogl/deprecated/cogl-shader.c                 | 72 ----------------------
 cogl/cogl/deprecated/cogl-shader.h                 | 44 -------------
 cogl/tests/conform/test-just-vertex-shader.c       |  8 ---
 .../clutter/interactive/test-cogl-shader-glsl.c    |  1 -
 7 files changed, 7 insertions(+), 158 deletions(-)
---
diff --git a/clutter/clutter/clutter-shader-effect.c b/clutter/clutter/clutter-shader-effect.c
index f61f37e8f..59fc1a891 100644
--- a/clutter/clutter/clutter-shader-effect.c
+++ b/clutter/clutter/clutter-shader-effect.c
@@ -367,24 +367,12 @@ clutter_shader_effect_try_static_source (ClutterShaderEffect *self)
 
           CLUTTER_NOTE (SHADER, "Compiling shader effect");
 
-          cogl_shader_compile (class_priv->shader);
+          class_priv->program = cogl_create_program ();
 
-          if (cogl_shader_is_compiled (class_priv->shader))
-            {
-              class_priv->program = cogl_create_program ();
+          cogl_program_attach_shader (class_priv->program,
+                                      class_priv->shader);
 
-              cogl_program_attach_shader (class_priv->program,
-                                          class_priv->shader);
-
-              cogl_program_link (class_priv->program);
-            }
-          else
-            {
-              gchar *log_buf = cogl_shader_get_info_log (class_priv->shader);
-
-              g_warning (G_STRLOC ": Unable to compile the GLSL shader: %s", log_buf);
-              g_free (log_buf);
-            }
+          cogl_program_link (class_priv->program);
         }
 
       priv->shader = cogl_object_ref (class_priv->shader);
@@ -902,23 +890,11 @@ clutter_shader_effect_set_shader_source (ClutterShaderEffect *effect,
 
   CLUTTER_NOTE (SHADER, "Compiling shader effect");
 
-  cogl_shader_compile (priv->shader);
+  priv->program = cogl_create_program ();
 
-  if (cogl_shader_is_compiled (priv->shader))
-    {
-      priv->program = cogl_create_program ();
+  cogl_program_attach_shader (priv->program, priv->shader);
 
-      cogl_program_attach_shader (priv->program, priv->shader);
-
-      cogl_program_link (priv->program);
-    }
-  else
-    {
-      gchar *log_buf = cogl_shader_get_info_log (priv->shader);
-
-      g_warning (G_STRLOC ": Unable to compile the GLSL shader: %s", log_buf);
-      g_free (log_buf);
-    }
+  cogl_program_link (priv->program);
 
   return TRUE;
 }
diff --git a/cogl/cogl/cogl-pipeline-state.h b/cogl/cogl/cogl-pipeline-state.h
index ff5e1ebe2..4a1cf9143 100644
--- a/cogl/cogl/cogl-pipeline-state.h
+++ b/cogl/cogl/cogl-pipeline-state.h
@@ -418,7 +418,6 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline);
  *                     "!!ARBfp1.0\n"
  *                     "MOV result.color,fragment.color;\n"
  *                     "END\n");
- * cogl_shader_compile (shader);
  *
  * program = cogl_create_program ();
  * cogl_program_attach_shader (program, shader);
diff --git a/cogl/cogl/deprecated/cogl-material-compat.h b/cogl/cogl/deprecated/cogl-material-compat.h
index 8e678bad8..51385e9aa 100644
--- a/cogl/cogl/deprecated/cogl-material-compat.h
+++ b/cogl/cogl/deprecated/cogl-material-compat.h
@@ -404,7 +404,6 @@ cogl_material_set_point_size (CoglMaterial *material,
  *                     "!!ARBfp1.0\n"
  *                     "MOV result.color,fragment.color;\n"
  *                     "END\n");
- * cogl_shader_compile (shader);
  *
  * program = cogl_create_program ();
  * cogl_program_attach_shader (program, shader);
diff --git a/cogl/cogl/deprecated/cogl-shader.c b/cogl/cogl/deprecated/cogl-shader.c
index 589850fd1..701545477 100644
--- a/cogl/cogl/deprecated/cogl-shader.c
+++ b/cogl/cogl/deprecated/cogl-shader.c
@@ -124,19 +124,6 @@ cogl_shader_source (CoglHandle   handle,
   shader->source = g_strdup (source);
 }
 
-void
-cogl_shader_compile (CoglHandle handle)
-{
-  /* XXX: For GLSL we don't actually compile anything until the shader
-   * gets used so we have an opportunity to add some boilerplate to
-   * the shader.
-   *
-   * At the end of the day this is obviously a badly designed API
-   * given that we are having to lie to the user. It was a mistake to
-   * so thinly wrap the OpenGL shader API and the current plan is to
-   * replace it with a pipeline snippets API. */
-}
-
 void
 _cogl_shader_compile_real (CoglHandle handle,
                            CoglPipeline *pipeline)
@@ -208,33 +195,6 @@ _cogl_shader_compile_real (CoglHandle handle,
     }
 }
 
-char *
-cogl_shader_get_info_log (CoglHandle handle)
-{
-  if (!cogl_is_shader (handle))
-    return NULL;
-
-  /* XXX: This API doesn't really do anything!
-   *
-   * This API is purely for compatibility
-   *
-   * The reason we don't do anything is because a shader needs to
-   * be associated with a CoglPipeline for Cogl to be able to
-   * compile and link anything.
-   *
-   * The way this API was originally designed as a very thin wrapper
-   * over the GL api was a mistake and it's now very difficult to
-   * make the API work in a meaningful way given how the rest of Cogl
-   * has evolved.
-   *
-   * The CoglShader API is mostly deprecated by CoglSnippets and so
-   * these days we do the bare minimum to support the existing users
-   * of it until they are able to migrate to the snippets api.
-   */
-
-  return g_strdup ("");
-}
-
 CoglShaderType
 cogl_shader_get_type (CoglHandle  handle)
 {
@@ -251,35 +211,3 @@ cogl_shader_get_type (CoglHandle  handle)
   shader = handle;
   return shader->type;
 }
-
-gboolean
-cogl_shader_is_compiled (CoglHandle handle)
-{
-#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2)
-  if (!cogl_is_shader (handle))
-    return FALSE;
-
-  /* XXX: This API doesn't really do anything!
-   *
-   * This API is purely for compatibility and blatantly lies to the
-   * user about whether their shader has been compiled.
-   *
-   * I suppose we could say we're stretching the definition of
-   * "compile" and are deferring any related errors to be "linker"
-   * errors.
-   *
-   * The reason we don't do anything is because a shader needs to
-   * be associated with a CoglPipeline for Cogl to be able to
-   * compile and link anything.
-   *
-   * The CoglShader API is mostly deprecated by CoglSnippets and so
-   * these days we do the bare minimum to support the existing users
-   * of it until they are able to migrate to the snippets api.
-   */
-
-  return TRUE;
-
-#else
-  return FALSE;
-#endif
-}
diff --git a/cogl/cogl/deprecated/cogl-shader.h b/cogl/cogl/deprecated/cogl-shader.h
index beb5ed38d..67d1ef362 100644
--- a/cogl/cogl/deprecated/cogl-shader.h
+++ b/cogl/cogl/deprecated/cogl-shader.h
@@ -281,37 +281,6 @@ void
 cogl_shader_source (CoglHandle  shader,
                     const char *source);
 
-/**
- * cogl_shader_compile:
- * @handle: #CoglHandle for a shader.
- *
- * Compiles the shader, no return value, but the shader is now ready
- * for linking into a program. Note that calling this function is
- * optional. If it is not called then the shader will be automatically
- * compiled when it is linked.
- * Deprecated: 1.16: Use #CoglSnippet api
- */
-COGL_DEPRECATED_FOR (cogl_snippet_)
-void
-cogl_shader_compile (CoglHandle handle);
-
-/**
- * cogl_shader_get_info_log:
- * @handle: #CoglHandle for a shader.
- *
- * Retrieves the information log for a coglobject, can be used in conjunction
- * with cogl_shader_get_parameteriv() to retrieve the compiler warnings/error
- * messages that caused a shader to not compile correctly, mainly useful for
- * debugging purposes.
- *
- * Return value: a newly allocated string containing the info log. Use
- *   g_free() to free it
- * Deprecated: 1.16: Use #CoglSnippet api
- */
-COGL_DEPRECATED_FOR (cogl_snippet_)
-char *
-cogl_shader_get_info_log (CoglHandle handle);
-
 /**
  * cogl_shader_get_type:
  * @handle: #CoglHandle for a shader.
@@ -326,19 +295,6 @@ COGL_DEPRECATED_FOR (cogl_snippet_)
 CoglShaderType
 cogl_shader_get_type (CoglHandle handle);
 
-/**
- * cogl_shader_is_compiled:
- * @handle: #CoglHandle for a shader.
- *
- * Retrieves whether a shader #CoglHandle has been compiled
- *
- * Return value: %TRUE if the shader object has sucessfully be compiled
- * Deprecated: 1.16: Use #CoglSnippet api
- */
-COGL_DEPRECATED_FOR (cogl_snippet_)
-gboolean
-cogl_shader_is_compiled (CoglHandle handle);
-
 /**
  * cogl_create_program:
  *
diff --git a/cogl/tests/conform/test-just-vertex-shader.c b/cogl/tests/conform/test-just-vertex-shader.c
index ea7b2ac12..2e9cab0e8 100644
--- a/cogl/tests/conform/test-just-vertex-shader.c
+++ b/cogl/tests/conform/test-just-vertex-shader.c
@@ -69,14 +69,6 @@ paint (TestState *state)
                       "  cogl_color_out = cogl_color_in;\n"
                       "  cogl_tex_coord_out[0] = cogl_tex_coord_in;\n"
                       "}\n");
-  cogl_shader_compile (shader);
-  if (!cogl_shader_is_compiled (shader))
-    {
-      char *log = cogl_shader_get_info_log (shader);
-      g_warning ("Shader compilation failed:\n%s", log);
-      g_free (log);
-      g_assert_not_reached ();
-    }
 
   program = cogl_create_program ();
   cogl_program_attach_shader (program, shader);
diff --git a/src/tests/clutter/interactive/test-cogl-shader-glsl.c 
b/src/tests/clutter/interactive/test-cogl-shader-glsl.c
index 32f35a1ea..84461d34d 100644
--- a/src/tests/clutter/interactive/test-cogl-shader-glsl.c
+++ b/src/tests/clutter/interactive/test-cogl-shader-glsl.c
@@ -196,7 +196,6 @@ set_shader_num (int new_no)
 
   shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
   cogl_shader_source (shader, shaders[new_no].source);
-  cogl_shader_compile (shader);
 
   program = cogl_create_program ();
   cogl_program_attach_shader (program, shader);


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