i965/fs_nir: Do retyping for ALU srouces in get_nir_alu_src
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 12 Dec 2014 21:05:25 +0000 (13:05 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 15 Jan 2015 15:19:00 +0000 (07:19 -0800)
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_nir.cpp

index d27ec356ce839a2d0dd529740cb522837fd504f1..8c6a5738f8497062ed13f7f0fd51be1bd36ed62e 100644 (file)
@@ -403,8 +403,8 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
    struct brw_wm_prog_key *fs_key = (struct brw_wm_prog_key *) this->key;
 
    fs_reg op[3];
-   fs_reg dest = retype(get_nir_dest(instr->dest.dest),
-                        brw_type_for_nir_type(nir_op_infos[instr->op].output_type));
+   fs_reg dest = get_nir_dest(instr->dest.dest);
+   dest.type = brw_type_for_nir_type(nir_op_infos[instr->op].output_type);
 
    fs_reg result;
    if (instr->has_predicate) {
@@ -415,10 +415,8 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
    }
 
 
-   for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
-      op[i] = retype(get_nir_alu_src(instr, i),
-                     brw_type_for_nir_type(nir_op_infos[instr->op].input_types[i]));
-   }
+   for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++)
+      op[i] = get_nir_alu_src(instr, i);
 
    switch (instr->op) {
    case nir_op_fmov:
@@ -987,6 +985,7 @@ fs_visitor::get_nir_alu_src(nir_alu_instr *instr, unsigned src)
 {
    fs_reg reg = get_nir_src(instr->src[src].src);
 
+   reg.type = brw_type_for_nir_type(nir_op_infos[instr->op].input_types[src]);
    reg.abs = instr->src[src].abs;
    reg.negate = instr->src[src].negate;
 
@@ -1004,20 +1003,14 @@ fs_visitor::get_nir_alu_src(nir_alu_instr *instr, unsigned src)
 
    if (needs_swizzle) {
       /* resolve the swizzle through MOV's */
-      fs_reg new_reg = fs_reg(GRF, virtual_grf_alloc(num_components));
+      fs_reg new_reg = fs_reg(GRF, virtual_grf_alloc(num_components), reg.type);
 
       for (unsigned i = 0; i < 4; i++) {
          if (!nir_alu_instr_channel_used(instr, src, i))
             continue;
 
-         fs_reg dest = new_reg;
-         dest.type = reg.type;
-         dest.reg_offset = i;
-
-         fs_reg src0 = reg;
-         src0.reg_offset += instr->src[src].swizzle[i];
-
-         emit(MOV(dest, src0));
+         emit(MOV(offset(new_reg, i),
+                  offset(reg, instr->src[src].swizzle[i])));
       }
 
       return new_reg;