Mesa (glsl2): glsl2: When inlining, don' t clone and assign sampler arguments.

Eric Anholt anholt at kemper.freedesktop.org
Thu Jul 22 20:58:44 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 8ec0b8187ea695353c75eed7314e86344df60e5a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ec0b8187ea695353c75eed7314e86344df60e5a

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jul 22 13:52:41 2010 -0700

glsl2: When inlining, don't clone and assign sampler arguments.

Instead, just use the incoming sampler param.  Fixes many texture-using
piglit tests since the linker rework.

---

 src/glsl/ir_function_inlining.cpp |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/glsl/ir_function_inlining.cpp b/src/glsl/ir_function_inlining.cpp
index c391f12..b143190 100644
--- a/src/glsl/ir_function_inlining.cpp
+++ b/src/glsl/ir_function_inlining.cpp
@@ -133,17 +133,27 @@ ir_call::generate_inline(ir_instruction *next_ir)
    exec_list_iterator sig_param_iter = this->callee->parameters.iterator();
    exec_list_iterator param_iter = this->actual_parameters.iterator();
    for (i = 0; i < num_parameters; i++) {
-      const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get();
+      ir_variable *sig_param = (ir_variable *) sig_param_iter.get();
       ir_rvalue *param = (ir_rvalue *) param_iter.get();
 
       /* Generate a new variable for the parameter. */
-      parameters[i] = sig_param->clone(ht);
-      parameters[i]->mode = ir_var_auto;
-      next_ir->insert_before(parameters[i]);
+      if (sig_param->type->base_type == GLSL_TYPE_SAMPLER) {
+	 /* For samplers, we want the inlined sampler references
+	  * referencing the passed in sampler variable, since that
+	  * will have the location information, which an assignment of
+	  * a sampler wouldn't.
+	  */
+	 parameters[i] = NULL;
+	 hash_table_insert(ht, param->variable_referenced(), sig_param);
+      } else {
+	 parameters[i] = sig_param->clone(ht);
+	 parameters[i]->mode = ir_var_auto;
+	 next_ir->insert_before(parameters[i]);
+      }
 
       /* Move the actual param into our param variable if it's an 'in' type. */
-      if (sig_param->mode == ir_var_in ||
-	  sig_param->mode == ir_var_inout) {
+      if (parameters[i] && (sig_param->mode == ir_var_in ||
+			    sig_param->mode == ir_var_inout)) {
 	 ir_assignment *assign;
 
 	 assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]),
@@ -175,8 +185,8 @@ ir_call::generate_inline(ir_instruction *next_ir)
       const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get();
 
       /* Move our param variable into the actual param if it's an 'out' type. */
-      if (sig_param->mode == ir_var_out ||
-	  sig_param->mode == ir_var_inout) {
+      if (parameters[i] && (sig_param->mode == ir_var_out ||
+			    sig_param->mode == ir_var_inout)) {
 	 ir_assignment *assign;
 
 	 assign = new(ctx) ir_assignment(param->clone(NULL)->as_rvalue(),




More information about the mesa-commit mailing list