Merge branch 'llvm-cliptest-viewport'
[mesa.git] / src / mesa / drivers / dri / i965 / brw_fs_vector_splitting.cpp
index 83b4af05bcbb6c9c7c5409216ee473eaabac5e28..2be6b08b5c7a26b0c7688e087e5b967f68cea2c0 100644 (file)
@@ -212,7 +212,6 @@ public:
    struct variable_entry *get_splitting_entry(ir_variable *var);
 
    exec_list *variable_list;
-   void *mem_ctx;
 };
 
 struct variable_entry *
@@ -264,8 +263,10 @@ ir_vector_splitting_visitor::visit_leave(ir_assignment *ir)
    variable_entry *rhs = rhs_deref ? get_splitting_entry(rhs_deref->var) : NULL;
 
    if (lhs_deref && rhs_deref && (lhs || rhs) && !ir->condition) {
+      unsigned int rhs_chan = 0;
+
       /* Straight assignment of vector variables. */
-      for (unsigned int i = 0; i < ir->rhs->type->vector_elements; i++) {
+      for (unsigned int i = 0; i < ir->lhs->type->vector_elements; i++) {
         ir_dereference *new_lhs;
         ir_rvalue *new_rhs;
         void *mem_ctx = lhs ? lhs->mem_ctx : rhs->mem_ctx;
@@ -283,18 +284,22 @@ ir_vector_splitting_visitor::visit_leave(ir_assignment *ir)
         }
 
         if (rhs) {
-           new_rhs = new(mem_ctx) ir_dereference_variable(rhs->components[i]);
+           new_rhs =
+              new(mem_ctx) ir_dereference_variable(rhs->components[rhs_chan]);
         } else {
            new_rhs = new(mem_ctx) ir_swizzle(ir->rhs->clone(mem_ctx, NULL),
-                                             i, i, i, i, 1);
+                                             rhs_chan, 0, 0, 0, 1);
         }
 
         ir->insert_before(new(mem_ctx) ir_assignment(new_lhs,
                                                      new_rhs,
                                                      NULL, writemask));
+
+        rhs_chan++;
       }
       ir->remove();
    } else if (lhs) {
+      void *mem_ctx = lhs->mem_ctx;
       int elem = -1;
 
       switch (ir->write_mask) {
@@ -328,7 +333,6 @@ ir_vector_splitting_visitor::visit_leave(ir_assignment *ir)
    return visit_continue;
 }
 
-extern "C" {
 bool
 brw_do_vector_splitting(exec_list *instructions)
 {
@@ -386,4 +390,3 @@ brw_do_vector_splitting(exec_list *instructions)
 
    return true;
 }
-}