summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-09-16 19:45:09 +0200
committerIan Romanick <ian.d.romanick@intel.com>2010-09-17 10:56:11 +0200
commit2959cf04546aa0fa801083653d609ae3a0cfb753 (patch)
tree217494fc65847aa2412966f8575b5e5946f342d2
parent074de49a4206ad3e17a9d93334d71282172bdcb3 (diff)
glsl2: Fix linear portion of index search for writes
If the array access is a read, read the first element of this subregion unconditionally. The remaining tests will possibly overwrite this value with one of the other array elements. This optimization cannot be done for writes because it will cause the first element of the subregion to be written possibly *in addition* to one of the other elements.
-rw-r--r--src/glsl/lower_variable_index_to_cond_assign.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp
index b313e9b460..cad43b427b 100644
--- a/src/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/glsl/lower_variable_index_to_cond_assign.cpp
@@ -94,13 +94,23 @@ struct switch_generator
if (begin == end)
return;
- /* do the first one unconditionally
- * FINISHME: may not want this in some cases
+ /* If the array access is a read, read the first element of this subregion
+ * unconditionally. The remaining tests will possibly overwrite this
+ * value with one of the other array elements.
+ *
+ * This optimization cannot be done for writes because it will cause the
+ * first element of the subregion to be written possibly *in addition* to
+ * one of the other elements.
*/
+ unsigned first;
+ if (!this->generator.is_write) {
+ this->generator.generate(begin, 0, list);
+ first = begin + 1;
+ } else {
+ first = begin;
+ }
- this->generator.generate(begin, 0, list);
-
- for (unsigned i = begin + 1; i < end; i += 4) {
+ for (unsigned i = first; i < end; i += 4) {
const unsigned comps = MIN2(condition_components, end - i);
ir_rvalue *broadcast_index =