glsl: Add a new ast_type_qualifier::has_storage() method.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 13 Jul 2013 05:36:31 +0000 (22:36 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 18 Jul 2013 23:57:22 +0000 (16:57 -0700)
This makes it easy to check if any storage qualifiers are set.

"centroid" is not considered a storage qualifier.  In the old language
rules, you can't specify "centroid" by itself; it's always "centroid
in", "centroid out", or "centroid varying."  So one of the other storage
qualifiers will always be set; there's no need to specifically check for
centroid.

In the new 4.20 rules, centroid is an auxiliary storage qualifier, not a
storage qualifier.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/ast.h
src/glsl/ast_type.cpp

index 441b389a74a97d427c539fc77eff9ff61685b3db..78d24ae069d41953f3262371fc41d8cad98a2d4f 100644 (file)
@@ -462,6 +462,11 @@ struct ast_type_qualifier {
     */
    bool has_layout() const;
 
+   /**
+    * Return whether a storage qualifier is present.
+    */
+   bool has_storage() const;
+
    /**
     * \brief Return string representation of interpolation qualifier.
     *
index 4e870a7074213a07b5557bdc80a3e0e8e63490a9..2e55b76762b9f6d1250f5b857aa35dbedda2d554 100644 (file)
@@ -74,6 +74,17 @@ ast_type_qualifier::has_layout() const
           || this->flags.q.explicit_index;
 }
 
+bool
+ast_type_qualifier::has_storage() const
+{
+   return this->flags.q.constant
+          || this->flags.q.attribute
+          || this->flags.q.varying
+          || this->flags.q.in
+          || this->flags.q.out
+          || this->flags.q.uniform;
+}
+
 const char*
 ast_type_qualifier::interpolation_string() const
 {