i965: Fix PBO cache coherency issue after _mesa_meta_pbo_GetTexSubImage().
[mesa.git] / src / mesa / drivers / dri / i965 / brw_fs_sel_peephole.cpp
index 28e41638e038dcf4bce4ccac4e4ab1e97d103987..52aa5590c2e6b9a217f576f53cbe9527fd260c7c 100644 (file)
@@ -128,20 +128,25 @@ fs_visitor::opt_peephole_sel()
       /* IF instructions, by definition, can only be found at the ends of
        * basic blocks.
        */
-      fs_inst *if_inst = (fs_inst *) block->end;
+      fs_inst *if_inst = (fs_inst *)block->end();
       if (if_inst->opcode != BRW_OPCODE_IF)
          continue;
 
-      if (!block->else_block)
-         continue;
-
-      assert(block->else_block->end->opcode == BRW_OPCODE_ELSE);
-
       fs_inst *else_mov[MAX_MOVS] = { NULL };
       fs_inst *then_mov[MAX_MOVS] = { NULL };
 
-      bblock_t *then_block = (bblock_t *)block->link.next;
-      bblock_t *else_block = (bblock_t *)block->else_block->link.next;
+      bblock_t *then_block = block->next();
+      bblock_t *else_block = NULL;
+      foreach_list_typed(bblock_link, child, link, &block->children) {
+         if (child->block != then_block) {
+            if (child->block->prev()->end()->opcode == BRW_OPCODE_ELSE) {
+               else_block = child->block;
+            }
+            break;
+         }
+      }
+      if (else_block == NULL)
+         continue;
 
       int movs = count_movs_from_if(then_mov, else_mov, then_block, else_block);
 
@@ -153,7 +158,7 @@ fs_visitor::opt_peephole_sel()
 
       enum brw_predicate predicate;
       bool predicate_inverse;
-      if (brw->gen == 6 && if_inst->conditional_mod) {
+      if (devinfo->gen == 6 && if_inst->conditional_mod) {
          /* For Sandybridge with IF with embedded comparison */
          predicate = BRW_PREDICATE_NORMAL;
          predicate_inverse = false;
@@ -171,7 +176,9 @@ fs_visitor::opt_peephole_sel()
          /* Check that the MOVs are the right form. */
          if (!then_mov[i]->dst.equals(else_mov[i]->dst) ||
              then_mov[i]->is_partial_write() ||
-             else_mov[i]->is_partial_write()) {
+             else_mov[i]->is_partial_write() ||
+             then_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE ||
+             else_mov[i]->conditional_mod != BRW_CONDITIONAL_NONE) {
             movs = i;
             break;
          }
@@ -191,7 +198,7 @@ fs_visitor::opt_peephole_sel()
              */
             fs_reg src0(then_mov[i]->src[0]);
             if (src0.file == IMM) {
-               src0 = fs_reg(this, glsl_type::float_type);
+               src0 = vgrf(glsl_type::float_type);
                src0.type = then_mov[i]->src[0].type;
                mov_imm_inst[i] = MOV(src0, then_mov[i]->src[0]);
             }
@@ -206,7 +213,7 @@ fs_visitor::opt_peephole_sel()
          continue;
 
       /* Emit a CMP if our IF used the embedded comparison */
-      if (brw->gen == 6 && if_inst->conditional_mod) {
+      if (devinfo->gen == 6 && if_inst->conditional_mod) {
          fs_inst *cmp_inst = CMP(reg_null_d, if_inst->src[0], if_inst->src[1],
                                  if_inst->conditional_mod);
          if_inst->insert_before(block, cmp_inst);