[gtk+/wip/otte/shader: 141/175] gskslqualifier: Handle uniform variables



commit 5baa483f5f7893930487b519596709146a9e25d6
Author: Benjamin Otte <otte redhat com>
Date:   Sun Oct 1 21:04:33 2017 +0200

    gskslqualifier: Handle uniform variables

 gsk/gskslqualifier.c        |   23 +++++++++++++++++++++++
 gsk/gskslqualifierprivate.h |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskslqualifier.c b/gsk/gskslqualifier.c
index 4e99257..1f473ec 100644
--- a/gsk/gskslqualifier.c
+++ b/gsk/gskslqualifier.c
@@ -158,6 +158,8 @@ gsk_sl_storage_get_name (GskSlStorage storage)
       return "out";
     case GSK_SL_STORAGE_PARAMETER_INOUT:
       return "inout";
+    case GSK_SL_STORAGE_GLOBAL_UNIFORM:
+      return "uniform";
     case GSK_SL_STORAGE_PARAMETER_CONST:
       return "const in";
     }
@@ -174,6 +176,7 @@ gsk_sl_storage_allows_const (GskSlStorage storage)
     default:
       g_assert_not_reached ();
     case GSK_SL_STORAGE_GLOBAL_OUT:
+    case GSK_SL_STORAGE_GLOBAL_UNIFORM:
     case GSK_SL_STORAGE_PARAMETER_OUT:
     case GSK_SL_STORAGE_PARAMETER_INOUT:
       return FALSE;
@@ -261,6 +264,21 @@ gsk_sl_qualifier_parse (GskSlQualifier         *qualifier,
           gsk_sl_preprocessor_consume (preproc, NULL);
           break;
 
+        case GSK_SL_TOKEN_UNIFORM:
+          if (seen_const)
+            gsk_sl_preprocessor_error (preproc, SYNTAX, "Const variables cannot have \"uniform\" 
qualifier.");
+          else if (qualifier->storage == GSK_SL_STORAGE_DEFAULT)
+            {
+              if (location != GSK_SL_QUALIFIER_GLOBAL)
+                gsk_sl_preprocessor_error (preproc, SYNTAX, "\"uniform\" can only be used on globals.");
+              else
+                qualifier->storage = GSK_SL_STORAGE_GLOBAL_UNIFORM;
+            }
+          else
+            gsk_sl_preprocessor_error (preproc, SYNTAX, "Qualifiers \"%s\" and \"uniform\" cannot be 
combined.", gsk_sl_storage_get_name (qualifier->storage));
+          gsk_sl_preprocessor_consume (preproc, NULL);
+          break;
+
         case GSK_SL_TOKEN_INVARIANT:
           if (qualifier->invariant)
             gsk_sl_preprocessor_error (preproc, SYNTAX, "Duplicate \"invariant\" qualifier.");
@@ -364,6 +382,7 @@ out:
 
     case GSK_SL_STORAGE_GLOBAL_IN:
     case GSK_SL_STORAGE_GLOBAL_OUT:
+    case GSK_SL_STORAGE_GLOBAL_UNIFORM:
     case GSK_SL_STORAGE_PARAMETER_OUT:
     case GSK_SL_STORAGE_PARAMETER_INOUT:
       g_assert (!seen_const);
@@ -465,6 +484,7 @@ gsk_sl_qualifier_is_constant (const GskSlQualifier *qualifier)
       g_assert_not_reached ();
       return TRUE;
 
+    case GSK_SL_STORAGE_GLOBAL_UNIFORM:
     case GSK_SL_STORAGE_GLOBAL_CONST:
     case GSK_SL_STORAGE_LOCAL_CONST:
     case GSK_SL_STORAGE_PARAMETER_CONST:
@@ -505,6 +525,9 @@ gsk_sl_qualifier_get_storage_class (const GskSlQualifier *qualifier)
     case GSK_SL_STORAGE_GLOBAL_OUT:
       return GSK_SPV_STORAGE_CLASS_OUTPUT;
 
+    case GSK_SL_STORAGE_GLOBAL_UNIFORM:
+      return GSK_SPV_STORAGE_CLASS_UNIFORM;
+
     case GSK_SL_STORAGE_LOCAL:
     case GSK_SL_STORAGE_LOCAL_CONST:
       return GSK_SPV_STORAGE_CLASS_FUNCTION;
diff --git a/gsk/gskslqualifierprivate.h b/gsk/gskslqualifierprivate.h
index a11f08a..aedfd66 100644
--- a/gsk/gskslqualifierprivate.h
+++ b/gsk/gskslqualifierprivate.h
@@ -40,6 +40,7 @@ typedef enum {
   GSK_SL_STORAGE_GLOBAL_CONST,
   GSK_SL_STORAGE_GLOBAL_IN,
   GSK_SL_STORAGE_GLOBAL_OUT,
+  GSK_SL_STORAGE_GLOBAL_UNIFORM,
 
   GSK_SL_STORAGE_LOCAL,
   GSK_SL_STORAGE_LOCAL_CONST,


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