[Mesa-dev] [PATCH 058/133] i965/fs_nir: Do retyping for ALU srouces in get_nir_alu_src

Jason Ekstrand jason at jlekstrand.net
Mon Dec 15 22:05:08 PST 2014


---
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 99094c7..1fac9a0 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -404,8 +404,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) {
@@ -416,10 +416,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:
@@ -989,6 +987,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;
 
@@ -1006,20 +1005,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;
-- 
2.2.0



More information about the mesa-dev mailing list