i965/fs: Use the actual regsister width in brw_reg_from_fs_reg
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 1 Oct 2014 17:46:48 +0000 (10:46 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 2 Oct 2014 20:17:03 +0000 (13:17 -0700)
This fixes a bug where 1-wide operations don't properly translate down to
1-wide instructions.

Signed-off-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_generator.cpp

index e20d3ccb8a43b947f044aefc6ef3c225217bd21f..c2010c036c9ac3a2f7bad7399034c078a39074e1 100644 (file)
@@ -1211,7 +1211,20 @@ brw_reg_from_fs_reg(fs_reg *reg)
    case MRF:
       if (reg->stride == 0) {
          brw_reg = brw_vec1_reg(brw_file_from_reg(reg), reg->reg, 0);
+      } else if (reg->width < 8) {
+         brw_reg = brw_vec8_reg(brw_file_from_reg(reg), reg->reg, 0);
+         brw_reg = stride(brw_reg, reg->width * reg->stride,
+                          reg->width, reg->stride);
       } else {
+         /* From the Haswell PRM:
+          *
+          * VertStride must be used to cross GRF register boundaries. This
+          * rule implies that elements within a 'Width' cannot cross GRF
+          * boundaries.
+          *
+          * So, for registers with width > 8, we have to use a width of 8
+          * and trust the compression state to sort out the exec size.
+          */
          brw_reg = brw_vec8_reg(brw_file_from_reg(reg), reg->reg, 0);
          brw_reg = stride(brw_reg, 8 * reg->stride, 8, reg->stride);
       }