[gtk/wip/baedert/for-master: 17/22] shader builder: Improve error output




commit 8ebcef97ffb2316ba24dd295b2520f888f3d116a
Author: Timm Bäder <mail baedert org>
Date:   Thu Jan 28 12:31:18 2021 +0100

    shader builder: Improve error output

 gsk/gl/gskglshaderbuilder.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gsk/gl/gskglshaderbuilder.c b/gsk/gl/gskglshaderbuilder.c
index 7e47fbd702..d16ad4feb5 100644
--- a/gsk/gl/gskglshaderbuilder.c
+++ b/gsk/gl/gskglshaderbuilder.c
@@ -64,8 +64,10 @@ prepend_line_numbers (char    *code,
 }
 
 static gboolean
-check_shader_error (int     shader_id,
-                    GError **error)
+check_shader_error (int          shader_id,
+                    int          shader_type,
+                    const char  *resource_path,
+                    GError     **error)
 {
   int status;
   int log_len;
@@ -91,7 +93,9 @@ check_shader_error (int     shader_id,
   prepend_line_numbers (code, s);
 
   g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
-               "Compilation failure in shader.\nSource Code: %s\n\nError Message:\n%s\n\n",
+               "Compilation failure in %s shader %s.\nSource Code:\n%s\n\nError Message:\n%s\n\n",
+               (shader_type == GL_FRAGMENT_SHADER ? "fragment" : "vertex"),
+               resource_path,
                s->str,
                buffer);
 
@@ -184,7 +188,7 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder  *self,
                   });
   glCompileShader (vertex_id);
 
-  if (!check_shader_error (vertex_id, error))
+  if (!check_shader_error (vertex_id, GL_VERTEX_SHADER, resource_path, error))
     {
       glDeleteShader (vertex_id);
       goto out;
@@ -218,7 +222,7 @@ gsk_gl_shader_builder_create_program (GskGLShaderBuilder  *self,
                   });
   glCompileShader (fragment_id);
 
-  if (!check_shader_error (fragment_id, error))
+  if (!check_shader_error (fragment_id, GL_FRAGMENT_SHADER, resource_path, error))
     {
       glDeleteShader (fragment_id);
       goto out;


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