ir_variable: Add method to get string representing interpolation qualifier
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 19 Jun 2010 02:00:28 +0000 (19:00 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 23 Jun 2010 17:56:03 +0000 (10:56 -0700)
ir.cpp
ir.h

diff --git a/ir.cpp b/ir.cpp
index 7fc260db390cedde2d798967f401634ad767787e..61589c3ff20e08e33c93ecc87bc6b7f1305adba4 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -738,6 +738,23 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name)
 }
 
 
+const char *
+ir_variable::interpolation_string() const
+{
+   if (!this->shader_in && !this->shader_out)
+      return "";
+
+   switch (this->interpolation) {
+   case ir_var_smooth:        return "smooth";
+   case ir_var_flat:          return "flat";
+   case ir_var_noperspective: return "noperspective";
+   }
+
+   assert(!"Should not get here.");
+   return "";
+}
+
+
 ir_function_signature::ir_function_signature(const glsl_type *return_type)
    : return_type(return_type), is_defined(false)
 {
diff --git a/ir.h b/ir.h
index a04b688894b24172d2f05e18b87197e3842068f4..04ecb582e482268f3f18a85ab1210b5974e4f707 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -177,6 +177,16 @@ public:
       return var;
    }
 
+   /**
+    * Get the string value for the interpolation qualifier
+    *
+    * \return
+    * If none of \c shader_in or \c shader_out is set, an empty string will
+    * be returned.  Otherwise the string that would be used in a shader to
+    * specify \c mode will be returned.
+    */
+   const char *interpolation_string() const;
+
    const char *name;
 
    /**