[Mesa-dev] [PATCH 2/8] glsl: add ir_variable::determine_interpolation_mode() function.
Paul Berry
stereotype441 at gmail.com
Mon Oct 24 14:38:40 PDT 2011
This function determines how a variable should be interpolated based
both on interpolation qualifiers and the current shade model.
---
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 a833c80..0b5c35a 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1354,6 +1354,21 @@ ir_variable::interpolation_string() const
}
+ir_variable_interpolation
+ir_variable::determine_interpolation_mode(bool flat_shade)
+{
+ if (this->interpolation != ir_var_interp_unspecified)
+ return (ir_variable_interpolation) 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 ir_var_interp_flat;
+ else
+ return ir_var_interp_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 e8ce28d..6262369 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -298,6 +298,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 ir_var_interp_smooth,
+ * ir_var_interp_noperspective, or ir_var_interp_flat.
+ */
+ ir_variable_interpolation determine_interpolation_mode(bool flat_shade);
+
+ /**
* Delcared name of the variable
*/
const char *name;
--
1.7.6.4
More information about the mesa-dev
mailing list