glsl: Parse the "binding" keyword and store it in ast_type_qualifier.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 16 Jul 2013 05:20:03 +0000 (22:20 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 18 Jul 2013 23:57:23 +0000 (16:57 -0700)
Nothing actually uses this yet.

v2: Remove >= 0 checks.  They'll be handled in later validation.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/ast.h
src/glsl/ast_type.cpp
src/glsl/glsl_parser.yy

index 6aede009c8cbe92ee8e446fcddd1002f8f40520a..d98f1a39b4720303d0e25880e9553c6b08bc02d6 100644 (file)
@@ -413,6 +413,12 @@ struct ast_type_qualifier {
          */
         unsigned explicit_index:1;
 
+         /**
+          * Flag set if GL_ARB_shading_language_420pack "binding" layout
+          * qualifier is used.
+          */
+         unsigned explicit_binding:1;
+
          /** \name Layout qualifiers for GL_AMD_conservative_depth */
          /** \{ */
          unsigned depth_any:1;
@@ -455,6 +461,14 @@ struct ast_type_qualifier {
     */
    int index;
 
+   /**
+    * Binding specified via GL_ARB_shading_language_420pack's "binding" keyword.
+    *
+    * \note
+    * This field is only valid if \c explicit_binding is set.
+    */
+   int binding;
+
    /**
     * Return true if and only if an interpolation qualifier is present.
     */
index 4cbb835ee1e339d67d745658e60b3393b33897f2..275b2a1d0ac4521bd8dea2a694c6dc234a7ef310 100644 (file)
@@ -71,7 +71,8 @@ ast_type_qualifier::has_layout() const
           || this->flags.q.row_major
           || this->flags.q.packed
           || this->flags.q.explicit_location
-          || this->flags.q.explicit_index;
+          || this->flags.q.explicit_index
+          || this->flags.q.explicit_binding;
 }
 
 bool
@@ -145,6 +146,9 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
    if (q.flags.q.explicit_index)
       this->index = q.index;
 
+   if (q.flags.q.explicit_binding)
+      this->binding = q.binding;
+
    return true;
 }
 
index b73ec6b3e19666d3426e52c0205dc178009a8f6b..cbd94b41f82c8044f2c277977c330fe75647c0d3 100644 (file)
@@ -1254,6 +1254,12 @@ layout_qualifier_id:
          }
       }
 
+      if (state->ARB_shading_language_420pack_enable &&
+          strcmp("binding", $1) == 0) {
+         $$.flags.q.explicit_binding = 1;
+         $$.binding = $3;
+      }
+
       /* If the identifier didn't match any known layout identifiers,
        * emit an error.
        */