summaryrefslogtreecommitdiffstats
path: root/src/glsl/lower_variable_index_to_cond_assign.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2011-07-17 17:33:26 -0700
committerIan Romanick <ian.d.romanick@intel.com>2011-07-23 01:24:18 -0700
commit5f83dfe5b70337bcffe215f7c32d0b862b5e7a3b (patch)
tree8a18305a6eab6069f145fd0ffead325f9de4861f /src/glsl/lower_variable_index_to_cond_assign.cpp
parent1731ac308631138ca98d34e8b7070c6e3f981939 (diff)
downloadexternal_mesa3d-5f83dfe5b70337bcffe215f7c32d0b862b5e7a3b.zip
external_mesa3d-5f83dfe5b70337bcffe215f7c32d0b862b5e7a3b.tar.gz
external_mesa3d-5f83dfe5b70337bcffe215f7c32d0b862b5e7a3b.tar.bz2
glsl: When lowering non-constant array indexing, respect existing conditions
If the non-constant index was in the LHS of an assignment, any existing condititon on that assignment would be lost. Fixes i965 piglit: fs-temp-array-mat[234]-col-row-wr fs-temp-array-mat[234]-index-col-row-wr fs-temp-array-mat[234]-index-col-wr fs-temp-array-mat[234]-index-row-wr vs-varying-array-mat[234]-index-col-wr Reviewed-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'src/glsl/lower_variable_index_to_cond_assign.cpp')
-rw-r--r--src/glsl/lower_variable_index_to_cond_assign.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp
index 107bcc6..e08ec13 100644
--- a/src/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/glsl/lower_variable_index_to_cond_assign.cpp
@@ -417,9 +417,24 @@ public:
switch_generator sg(ag, index, 4, 4);
- exec_list list;
- sg.generate(0, length, &list);
- base_ir->insert_before(&list);
+ /* If the original assignment has a condition, respect that original
+ * condition! This is acomplished by wrapping the new conditional
+ * assignments in an if-statement that uses the original condition.
+ */
+ if ((orig_assign != NULL) && (orig_assign->condition != NULL)) {
+ /* No need to clone the condition because the IR that it hangs on is
+ * going to be removed from the instruction sequence.
+ */
+ ir_if *if_stmt = new(mem_ctx) ir_if(orig_assign->condition);
+
+ sg.generate(0, length, &if_stmt->then_instructions);
+ base_ir->insert_before(if_stmt);
+ } else {
+ exec_list list;
+
+ sg.generate(0, length, &list);
+ base_ir->insert_before(&list);
+ }
return var;
}