[gtk+/wip/otte/shader: 118/226] gskslqualifier: Handle uniform variables



commit 60add60236f1c634ba693f06fde331342be87288
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 21f286f..3f182ab 100644
--- a/gsk/gskslqualifier.c
+++ b/gsk/gskslqualifier.c
@@ -159,6 +159,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";
     }
 }
 
@@ -173,6 +175,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;
@@ -260,6 +263,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.");
@@ -363,6 +381,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);
@@ -464,6 +483,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:
@@ -504,6 +524,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]