Mesa (master): glsl: Add method ast_type_qualifier::interpolation_string()

Chad Versace chadversary at kemper.freedesktop.org
Mon Jan 17 18:21:19 UTC 2011


Module: Mesa
Branch: master
Commit: 0e2f8936c8ef872cb464e54a9f09ae0324487147
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0e2f8936c8ef872cb464e54a9f09ae0324487147

Author: Chad Versace <chad.versace at intel.com>
Date:   Tue Jan 11 16:59:24 2011 -0800

glsl: Add method ast_type_qualifier::interpolation_string()

If an interpolation qualifier is present, then the method returns that
qualifier's string representation. For example, if the noperspective bit
is set, then it returns "noperspective".

---

 src/glsl/ast.h        |   12 ++++++++++++
 src/glsl/ast_type.cpp |   13 +++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index cd933cf..c096f9a 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -364,6 +364,18 @@ struct ast_type_qualifier {
     * This field is only valid if \c explicit_location is set.
     */
    unsigned location;
+
+   /**
+    * \brief Return string representation of interpolation qualifier.
+    *
+    * If an interpolation qualifier is present, then return that qualifier's
+    * string representation. Otherwise, return null. For example, if the
+    * noperspective bit is set, then this returns "noperspective".
+    *
+    * If multiple interpolation qualifiers are somehow present, then the
+    * returned string is undefined but not null.
+    */
+   const char *interpolation_string() const;
 };
 
 class ast_struct_specifier : public ast_node {
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index b7488cf..a876161 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -116,3 +116,16 @@ ast_fully_specified_type::has_qualifiers() const
 {
    return this->qualifier.flags.i != 0;
 }
+
+const char*
+ast_type_qualifier::interpolation_string() const
+{
+   if (this->flags.q.smooth)
+      return "smooth";
+   else if (this->flags.q.flat)
+      return "flat";
+   else if (this->flags.q.noperspective)
+      return "noperspective";
+   else
+      return NULL;
+}




More information about the mesa-commit mailing list