[gtk+/wip/ebassi/gsk-renderer: 441/545] gsk: Add debugging notes to ShaderBuilder
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 441/545] gsk: Add debugging notes to ShaderBuilder
- Date: Mon, 17 Oct 2016 13:48:16 +0000 (UTC)
commit 8f13992d9c736a97added0e3bd696afef6426a68
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Jul 3 22:38:27 2016 +0100
gsk: Add debugging notes to ShaderBuilder
Print out the generated shader and the list of available uniforms and
attributes.
gsk/gskshaderbuilder.c | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskshaderbuilder.c b/gsk/gskshaderbuilder.c
index 16a0e1e..5142e43 100644
--- a/gsk/gskshaderbuilder.c
+++ b/gsk/gskshaderbuilder.c
@@ -2,6 +2,8 @@
#include "gskshaderbuilderprivate.h"
+#include "gskdebugprivate.h"
+
#include <gdk/gdk.h>
#include <epoxy/gl.h>
@@ -194,6 +196,8 @@ gsk_shader_builder_compile_shader (GskShaderBuilder *builder,
return -1;
}
+ g_string_append_c (code, '\n');
+
if (!lookup_shader_code (code, builder->resource_base_path, shader_source, error))
{
g_string_free (code, TRUE);
@@ -206,6 +210,16 @@ gsk_shader_builder_compile_shader (GskShaderBuilder *builder,
glShaderSource (shader_id, 1, (const GLchar **) &source, NULL);
glCompileShader (shader_id);
+#ifdef G_ENABLE_DEBUG
+ if (GSK_DEBUG_CHECK (OPENGL))
+ {
+ g_print ("*** Compiling %s shader ***\n"
+ "%s\n",
+ shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
+ source);
+ }
+#endif
+
g_free (source);
glGetShaderiv (shader_id, GL_COMPILE_STATUS, &status);
@@ -311,6 +325,30 @@ gsk_shader_builder_create_program (GskShaderBuilder *builder,
builder->program_id = program_id;
+#ifdef G_ENABLE_DEBUG
+ if (GSK_DEBUG_CHECK (OPENGL))
+ {
+ GHashTableIter iter;
+ gpointer name_p, location_p;
+
+ g_hash_table_iter_init (&iter, builder->uniform_locations);
+ while (g_hash_table_iter_next (&iter, &name_p, &location_p))
+ {
+ g_print ("Uniform '%s' - location: %d\n",
+ g_quark_to_string (GPOINTER_TO_INT (name_p)),
+ GPOINTER_TO_INT (location_p));
+ }
+
+ g_hash_table_iter_init (&iter, builder->attribute_locations);
+ while (g_hash_table_iter_next (&iter, &name_p, &location_p))
+ {
+ g_print ("Attribute '%s' - location: %d\n",
+ g_quark_to_string (GPOINTER_TO_INT (name_p)),
+ GPOINTER_TO_INT (location_p));
+ }
+ }
+#endif
+
out:
glDetachShader (program_id, vertex_id);
glDetachShader (program_id, fragment_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]