mesa: remove support for GL_APPLE_client_storage extension
[mesa.git] / src / glsl / opt_constant_propagation.cpp
index 1fff7175395c7220acee4e7049f45dd4a283d202..af77e4906896173ce421e8491a176d82c8cc05e1 100644 (file)
@@ -41,8 +41,6 @@
 #include "ir_optimization.h"
 #include "glsl_types.h"
 
-using std::memset;
-
 class acp_entry : public exec_node
 {
 public:
@@ -53,11 +51,23 @@ public:
       this->var = var;
       this->write_mask = write_mask;
       this->constant = constant;
+      this->initial_values = write_mask;
+   }
+
+   acp_entry(const acp_entry *src)
+   {
+      this->var = src->var;
+      this->write_mask = src->write_mask;
+      this->constant = src->constant;
+      this->initial_values = src->initial_values;
    }
 
    ir_variable *var;
    ir_constant *constant;
    unsigned write_mask;
+
+   /** Mask of values initially available in the constant. */
+   unsigned initial_values;
 };
 
 
@@ -174,7 +184,7 @@ ir_constant_propagation_visitor::handle_rvalue(ir_rvalue **rvalue)
       for (int j = 0; j < 4; j++) {
         if (j == channel)
            break;
-        if (found->write_mask & (1 << j))
+        if (found->initial_values & (1 << j))
            rhs_channel++;
       }
 
@@ -287,8 +297,7 @@ ir_constant_propagation_visitor::handle_if_block(exec_list *instructions)
    /* Populate the initial acp with a constant of the original */
    foreach_iter(exec_list_iterator, iter, *orig_acp) {
       acp_entry *a = (acp_entry *)iter.get();
-      this->acp->push_tail(new(this->mem_ctx) acp_entry(a->var, a->write_mask,
-                                                       a->constant));
+      this->acp->push_tail(new(this->mem_ctx) acp_entry(a));
    }
 
    visit_list_elements(this, instructions);
@@ -400,11 +409,8 @@ ir_constant_propagation_visitor::add_constant(ir_assignment *ir)
 {
    acp_entry *entry;
 
-   if (ir->condition) {
-      ir_constant *condition = ir->condition->as_constant();
-      if (!condition || !condition->value.b[0])
-        return;
-   }
+   if (ir->condition)
+      return;
 
    if (!ir->write_mask)
       return;