i965/fs: Remove fs_reg::sechalf.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 15 Jan 2014 21:21:50 +0000 (22:21 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Wed, 12 Feb 2014 22:39:24 +0000 (23:39 +0100)
The same effect can be achieved using ::subreg_offset.  Remove the
less flexible alternative and define a convenience function to keep
the fs_reg interface sane.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_generator.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index d45d4cf5f0adb28788dfac40050469e558e231a2..4f5558b329c7ef3250def4b60b8f7851cdb3daf1 100644 (file)
@@ -1219,22 +1219,18 @@ fs_visitor::emit_samplepos_setup(ir_variable *ir)
 
    emit(MOV(int_sample_x, fs_reg(sample_pos_reg)));
    if (dispatch_width == 16) {
-      int_sample_x.sechalf = true;
-      fs_inst *inst = emit(MOV(int_sample_x,
+      fs_inst *inst = emit(MOV(half(int_sample_x, 1),
                                fs_reg(suboffset(sample_pos_reg, 16))));
       inst->force_sechalf = true;
-      int_sample_x.sechalf = false;
    }
    /* Compute gl_SamplePosition.x */
    compute_sample_position(pos, int_sample_x);
    pos.reg_offset++;
    emit(MOV(int_sample_y, fs_reg(suboffset(sample_pos_reg, 1))));
    if (dispatch_width == 16) {
-      int_sample_y.sechalf = true;
-      fs_inst *inst = emit(MOV(int_sample_y,
+      fs_inst *inst = emit(MOV(half(int_sample_y, 1),
                                fs_reg(suboffset(sample_pos_reg, 17))));
       inst->force_sechalf = true;
-      int_sample_y.sechalf = false;
    }
    /* Compute gl_SamplePosition.y */
    compute_sample_position(pos, int_sample_y);
index 85d06ff214ce8716f7ffb8992370e0813aca6e1b..c6f4ffb4a1986738c91a600d22b7b268268e4a20 100644 (file)
@@ -105,7 +105,6 @@ public:
    int type;
    bool negate;
    bool abs;
-   bool sechalf;
    struct brw_reg fixed_hw_reg;
 
    /** Smear a channel of the reg to all channels. */
@@ -138,6 +137,19 @@ byte_offset(fs_reg reg, unsigned delta)
    return reg;
 }
 
+/**
+ * Get either of the 8-component halves of a 16-component register.
+ *
+ * Note: this also works if \c reg represents a SIMD16 pair of registers.
+ */
+static inline fs_reg
+half(const fs_reg &reg, unsigned idx)
+{
+   assert(idx < 2);
+   assert(idx == 0 || (reg.file != HW_REG && reg.file != IMM));
+   return byte_offset(reg, 8 * idx * reg.stride * type_sz(reg.type));
+}
+
 static const fs_reg reg_undef;
 static const fs_reg reg_null_f(retype(brw_null_reg(), BRW_REGISTER_TYPE_F));
 static const fs_reg reg_null_d(retype(brw_null_reg(), BRW_REGISTER_TYPE_D));
index b79fcca01e709433fc25579e828c80fccf620317..00f19dcac71c6f1fdfe9acf8f9c1096f7c003c30 100644 (file)
@@ -1038,8 +1038,6 @@ brw_reg_from_fs_reg(fs_reg *reg)
       }
 
       brw_reg = retype(brw_reg, reg->type);
-      if (reg->sechalf)
-        brw_reg = sechalf(brw_reg);
       brw_reg = byte_offset(brw_reg, reg->subreg_offset);
       break;
    case IMM:
index b67ea302a037c6ccde3ab446422aa43fb4fb0bb7..45b053d540eb01c1fb65741357f84e72f7925bf5 100644 (file)
@@ -2654,12 +2654,10 @@ fs_visitor::emit_color_write(int target, int index, int first_color_mrf)
         inst->saturate = c->key.clamp_fragment_color;
         pop_force_uncompressed();
 
-        color.sechalf = true;
         inst = emit(MOV(fs_reg(MRF, first_color_mrf + index + 4, color.type),
-                         color));
+                         half(color, 1)));
         inst->force_sechalf = true;
         inst->saturate = c->key.clamp_fragment_color;
-        color.sechalf = false;
       }
    }
 }