Mesa (master): glsl: add ir_variable::determine_interpolation_mode() function.

Paul Berry stereotype441 at kemper.freedesktop.org
Fri Oct 28 00:08:48 UTC 2011


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

Author: Paul Berry <stereotype441 at gmail.com>
Date:   Fri Oct 21 07:55:48 2011 -0700

glsl: add ir_variable::determine_interpolation_mode() function.

This function determines how a variable should be interpolated based
both on interpolation qualifiers and the current shade model.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/glsl/ir.cpp |   15 +++++++++++++++
 src/glsl/ir.h   |   11 +++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 9aad0fc..ef7300e 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1354,6 +1354,21 @@ ir_variable::interpolation_string() const
 }
 
 
+glsl_interp_qualifier
+ir_variable::determine_interpolation_mode(bool flat_shade)
+{
+   if (this->interpolation != INTERP_QUALIFIER_NONE)
+      return (glsl_interp_qualifier) this->interpolation;
+   int location = this->location;
+   bool is_gl_Color =
+      location == FRAG_ATTRIB_COL0 || location == FRAG_ATTRIB_COL1;
+   if (flat_shade && is_gl_Color)
+      return INTERP_QUALIFIER_FLAT;
+   else
+      return INTERP_QUALIFIER_SMOOTH;
+}
+
+
 ir_function_signature::ir_function_signature(const glsl_type *return_type)
    : return_type(return_type), is_defined(false), _function(NULL)
 {
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 0c0cccb..404d4cf 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -292,6 +292,17 @@ public:
    const char *interpolation_string() const;
 
    /**
+    * Determine how this variable should be interpolated based on its
+    * interpolation qualifier (if present), whether it is gl_Color or
+    * gl_SecondaryColor, and whether flatshading is enabled in the current GL
+    * state.
+    *
+    * The return value will always be either INTERP_QUALIFIER_SMOOTH,
+    * INTERP_QUALIFIER_NOPERSPECTIVE, or INTERP_QUALIFIER_FLAT.
+    */
+   glsl_interp_qualifier determine_interpolation_mode(bool flat_shade);
+
+   /**
     * Delcared name of the variable
     */
    const char *name;




More information about the mesa-commit mailing list