[Mesa-dev] [PATCH] glsl: Copy propagate in array index function parameters

Juan A. Suarez Romero jasuarez at igalia.com
Wed May 4 09:57:59 UTC 2016


Copy propagate is not applied in function parameters when they are out
or inout.

But if the parameter is an array, we can copy propagate the index array.

This also fixes several shaders at out-parameter-indexing piglit tests,
that exposes a wrong handling of inout function parameters in Mesa.

This commit does not produce any piglit regression, nor any change in
shader-db results.
---
 src/compiler/glsl/opt_copy_propagation.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/compiler/glsl/opt_copy_propagation.cpp b/src/compiler/glsl/opt_copy_propagation.cpp
index ae62921..141dfeb 100644
--- a/src/compiler/glsl/opt_copy_propagation.cpp
+++ b/src/compiler/glsl/opt_copy_propagation.cpp
@@ -193,6 +193,12 @@ ir_copy_propagation_visitor::visit_enter(ir_call *ir)
       if (sig_param->data.mode != ir_var_function_out
           && sig_param->data.mode != ir_var_function_inout) {
          ir->accept(this);
+      } else {
+         /* If parameter is an array, we can copy propagate the index */
+         ir_dereference_array *ir_array = ir->as_dereference_array();
+         if (ir_array) {
+            ir_array->array_index->accept(this);
+         }
       }
    }
 
-- 
2.5.5



More information about the mesa-dev mailing list