[gtk+/wip/otte/shader: 71/127] gskslqualifier: Implement layout(push_constant)



commit 6aac76c6bcf81fa5ae49a882f9e8e74c03e222a6
Author: Benjamin Otte <otte redhat com>
Date:   Mon Oct 2 00:05:46 2017 +0200

    gskslqualifier: Implement layout(push_constant)

 gsk/gskslqualifier.c        |   19 +++++++++++++++++--
 gsk/gskslqualifierprivate.h |    1 +
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskslqualifier.c b/gsk/gskslqualifier.c
index 3f182ab..17dfd09 100644
--- a/gsk/gskslqualifier.c
+++ b/gsk/gskslqualifier.c
@@ -115,6 +115,11 @@ gsk_sl_qualifier_parse_layout (GskSlQualifier    *qualifier,
             gsk_sl_qualifier_parse_layout_assignment (preproc, scope, &qualifier->layout.binding);
           else if (g_str_equal (token->str, "set"))
             gsk_sl_qualifier_parse_layout_assignment (preproc, scope, &qualifier->layout.set);
+          else if (g_str_equal (token->str, "push_constant"))
+            {
+              qualifier->layout.push_constant = TRUE;
+              gsk_sl_preprocessor_consume (preproc, NULL);
+            }
           else
             {
               gsk_sl_preprocessor_error (preproc, UNSUPPORTED, "Unknown layout identifier.");
@@ -402,7 +407,8 @@ gsk_sl_qualifier_has_layout (const GskSlQualifier *qualifier)
   return qualifier->layout.set >= 0
       || qualifier->layout.binding >= 0
       || qualifier->layout.location >= 0
-      || qualifier->layout.component >= 0;
+      || qualifier->layout.component >= 0
+      || qualifier->layout.push_constant;
 }
 
 static gboolean
@@ -464,6 +470,12 @@ gsk_sl_qualifier_print (const GskSlQualifier *qualifier,
       had_value = print_qualifier (printer, "binding", qualifier->layout.binding, had_value);
       had_value = print_qualifier (printer, "location", qualifier->layout.location, had_value);
       had_value = print_qualifier (printer, "component", qualifier->layout.component, had_value);
+      if (qualifier->layout.push_constant)
+        {
+          if (had_value)
+            gsk_sl_printer_append (printer, ", ");
+          gsk_sl_printer_append (printer, "push_constant");
+        }
       gsk_sl_printer_append (printer, ")");
       need_space = TRUE;
     }
@@ -525,7 +537,10 @@ gsk_sl_qualifier_get_storage_class (const GskSlQualifier *qualifier)
       return GSK_SPV_STORAGE_CLASS_OUTPUT;
 
     case GSK_SL_STORAGE_GLOBAL_UNIFORM:
-      return GSK_SPV_STORAGE_CLASS_UNIFORM;
+      if (qualifier->layout.push_constant)
+        return GSK_SPV_STORAGE_CLASS_PUSH_CONSTANT;
+      else
+        return GSK_SPV_STORAGE_CLASS_UNIFORM;
 
     case GSK_SL_STORAGE_LOCAL:
     case GSK_SL_STORAGE_LOCAL_CONST:
diff --git a/gsk/gskslqualifierprivate.h b/gsk/gskslqualifierprivate.h
index aedfd66..f432a2d 100644
--- a/gsk/gskslqualifierprivate.h
+++ b/gsk/gskslqualifierprivate.h
@@ -60,6 +60,7 @@ struct _GskSlQualifier
     gint binding;
     gint location;
     gint component;
+    guint push_constant :1;
   } layout;
 
   guint invariant :1;


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