[gtk+/wip/otte/shader: 88/151] gskspv: emit Debug information



commit 10a4182715aee4a4a9c2da1673606f18545e1e0b
Author: Benjamin Otte <otte redhat com>
Date:   Sat Oct 7 19:56:50 2017 +0200

    gskspv: emit Debug information

 gsk/gskslfunction.c |   15 ++++++++++-----
 gsk/gsksltype.c     |   26 +++++++++++++++++++++++---
 gsk/gskslvariable.c |   19 +++++++++++++------
 gsk/gskspvwriter.c  |    5 +++++
 4 files changed, 51 insertions(+), 14 deletions(-)
---
diff --git a/gsk/gskslfunction.c b/gsk/gskslfunction.c
index 1c9d55c..d4da987 100644
--- a/gsk/gskslfunction.c
+++ b/gsk/gskslfunction.c
@@ -426,12 +426,17 @@ gsk_sl_function_declared_write_call_spv (GskSlFunction *function,
                                          guint32       *arguments)
 {
   GskSlFunctionDeclared *declared = (GskSlFunctionDeclared *) function;
+  guint32 result;
 
-  return gsk_spv_writer_function_call (writer,
-                                       declared->return_type,
-                                       gsk_spv_writer_get_id_for_function (writer, function),
-                                       arguments,
-                                       declared->n_arguments);
+  result = gsk_spv_writer_function_call (writer,
+                                         declared->return_type,
+                                         gsk_spv_writer_get_id_for_function (writer, function),
+                                         arguments,
+                                         declared->n_arguments);
+
+  gsk_spv_writer_name (writer, result, declared->name);
+
+  return result;
 }
 
 static const GskSlFunctionClass GSK_SL_FUNCTION_DECLARED = {
diff --git a/gsk/gsksltype.c b/gsk/gsksltype.c
index 9df31cf..91a0f32 100644
--- a/gsk/gsksltype.c
+++ b/gsk/gsksltype.c
@@ -1149,12 +1149,19 @@ gsk_sl_type_struct_can_convert (const GskSlType *target,
   return gsk_sl_type_equal (target, source);
 }
 
+static gboolean
+gsk_sl_type_struct_has_name (const GskSlTypeStruct *struc)
+{
+  return !g_str_has_prefix (struc->name, "struct { ");
+}
+
 static guint32
 gsk_sl_type_struct_write_spv (GskSlType    *type,
                               GskSpvWriter *writer)
 {
   GskSlTypeStruct *struc = (GskSlTypeStruct *) type;
   guint32 ids[struc->n_members];
+  guint32 result_id;
   guint i;
 
   for (i = 0; i < struc->n_members; i++)
@@ -1162,9 +1169,22 @@ gsk_sl_type_struct_write_spv (GskSlType    *type,
       ids[i] = gsk_spv_writer_get_id_for_type (writer, struc->members[i].type);
     }
 
-  return gsk_spv_writer_type_struct (writer,
-                                     ids,
-                                     struc->n_members);
+  result_id = gsk_spv_writer_type_struct (writer,
+                                          ids,
+                                          struc->n_members);
+
+  
+  if (gsk_sl_type_struct_has_name (struc))
+    gsk_spv_writer_name (writer, result_id, struc->name);
+  else
+    gsk_spv_writer_name (writer, result_id, "");
+
+  for (i = 0; i < struc->n_members; i++)
+    {
+      gsk_spv_writer_member_name (writer, result_id, i, struc->members[i].name);
+    }
+
+  return result_id;
 }
 
 static void
diff --git a/gsk/gskslvariable.c b/gsk/gskslvariable.c
index 60e1dba..356f9eb 100644
--- a/gsk/gskslvariable.c
+++ b/gsk/gskslvariable.c
@@ -151,10 +151,12 @@ guint32
 gsk_sl_variable_write_spv (const GskSlVariable *variable,
                            GskSpvWriter        *writer)
 {
+  guint32 result_id;
+
   if (gsk_sl_qualifier_get_location (gsk_sl_pointer_type_get_qualifier (variable->type)) == 
GSK_SL_QUALIFIER_PARAMETER)
     {
-      return gsk_spv_writer_function_parameter (writer,
-                                                gsk_sl_pointer_type_get_type (variable->type));
+      result_id = gsk_spv_writer_function_parameter (writer,
+                                                     gsk_sl_pointer_type_get_type (variable->type));
     }
   else
     {
@@ -165,9 +167,14 @@ gsk_sl_variable_write_spv (const GskSlVariable *variable,
       else
         value_id = 0;
 
-      return gsk_spv_writer_variable (writer,
-                                      variable->type,
-                                      gsk_sl_qualifier_get_storage_class (gsk_sl_pointer_type_get_qualifier 
(variable->type)),
-                                      value_id);
+      result_id = gsk_spv_writer_variable (writer,
+                                           variable->type,
+                                           gsk_sl_qualifier_get_storage_class 
(gsk_sl_pointer_type_get_qualifier (variable->type)),
+                                           value_id);
     }
+
+  if (variable->name)
+    gsk_spv_writer_name (writer, result_id, variable->name);
+
+  return result_id;
 }
diff --git a/gsk/gskspvwriter.c b/gsk/gskspvwriter.c
index 8063d44..945ce58 100644
--- a/gsk/gskspvwriter.c
+++ b/gsk/gskspvwriter.c
@@ -152,6 +152,11 @@ gsk_spv_writer_write_header (GskSpvWriter *writer)
   gsk_spv_writer_execution_mode (writer,
                                  entry_point,
                                  GSK_SPV_EXECUTION_MODE_ORIGIN_UPPER_LEFT);
+  gsk_spv_writer_source (writer,
+                         GSK_SPV_SOURCE_LANGUAGE_GLSL,
+                         440,
+                         0,
+                         NULL);
 }
 
 static void


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