[Mesa-dev] [PATCH 02/14] glsl: Add a new ast_type_qualifier::has_storage() method.

Kenneth Graunke kenneth at whitecape.org
Mon Jul 15 19:32:04 PDT 2013


This makes it easy to check if any storage qualifiers are set.

XXX: I'm not sure if centroid should be in this or not

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/glsl/ast.h        |  5 +++++
 src/glsl/ast_type.cpp | 12 ++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 441b389..78d24ae 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -463,6 +463,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.
     *
     * If an interpolation qualifier is present, then return that qualifier's
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index 4e870a7..71bab99 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -74,6 +74,18 @@ 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.centroid
+          || this->flags.q.in
+          || this->flags.q.out
+          || this->flags.q.uniform;
+}
+
 const char*
 ast_type_qualifier::interpolation_string() const
 {
-- 
1.8.3.2



More information about the mesa-dev mailing list