[Mesa-dev] [PATCH 2/2] i965: Remove ir_txf coord+offset special case in visitors

Chris Forbes chrisf at ijw.co.nz
Sat Oct 12 14:04:58 CEST 2013


Just let it be handled by the lowering pass.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 60 +++++++-------------------
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 25 ++---------
 2 files changed, 18 insertions(+), 67 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 5910e45..f897880 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1092,34 +1092,19 @@ fs_visitor::emit_texture_gen5(ir_texture *ir, fs_reg dst, fs_reg coordinate,
    const int vector_elements =
       ir->coordinate ? ir->coordinate->type->vector_elements : 0;
 
-   if (ir->offset != NULL && ir->op == ir_txf) {
-      /* It appears that the ld instruction used for txf does its
-       * address bounds check before adding in the offset.  To work
-       * around this, just add the integer offset to the integer texel
-       * coordinate, and don't put the offset in the header.
+   if (ir->offset) {
+      /* The offsets set up by the ir_texture visitor are in the
+       * m1 header, so we can't go headerless.
        */
-      ir_constant *offset = ir->offset->as_constant();
-      for (int i = 0; i < vector_elements; i++) {
-	 emit(ADD(fs_reg(MRF, base_mrf + mlen + i * reg_width, coordinate.type),
-                  coordinate,
-                  offset->value.i[i]));
-	 coordinate.reg_offset++;
-      }
-   } else {
-      if (ir->offset) {
-	 /* The offsets set up by the ir_texture visitor are in the
-	  * m1 header, so we can't go headerless.
-	  */
-	 header_present = true;
-	 mlen++;
-	 base_mrf--;
-      }
+      header_present = true;
+      mlen++;
+      base_mrf--;
+   }
 
-      for (int i = 0; i < vector_elements; i++) {
-	 emit(MOV(fs_reg(MRF, base_mrf + mlen + i * reg_width, coordinate.type),
-                  coordinate));
-	 coordinate.reg_offset++;
-      }
+   for (int i = 0; i < vector_elements; i++) {
+      emit(MOV(fs_reg(MRF, base_mrf + mlen + i * reg_width, coordinate.type),
+               coordinate));
+      coordinate.reg_offset++;
    }
    mlen += vector_elements * reg_width;
 
@@ -1230,7 +1215,6 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
    int base_mrf = 2;
    int reg_width = dispatch_width / 8;
    bool header_present = false;
-   int offsets[3];
 
    if (ir->op == ir_tg4 || (ir->offset && ir->op != ir_txf)) {
       /* * The offsets set up by the ir_texture visitor are in the
@@ -1300,23 +1284,9 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       mlen += reg_width;
       break;
    case ir_txf:
-      /* It appears that the ld instruction used for txf does its
-       * address bounds check before adding in the offset.  To work
-       * around this, just add the integer offset to the integer texel
-       * coordinate, and don't put the offset in the header.
-       */
-      if (ir->offset) {
-	 ir_constant *offset = ir->offset->as_constant();
-	 offsets[0] = offset->value.i[0];
-	 offsets[1] = offset->value.i[1];
-	 offsets[2] = offset->value.i[2];
-      } else {
-	 memset(offsets, 0, sizeof(offsets));
-      }
-
       /* Unfortunately, the parameters for LD are intermixed: u, lod, v, r. */
-      emit(ADD(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D),
-               coordinate, offsets[0]));
+      emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D),
+               coordinate));
       coordinate.reg_offset++;
       mlen += reg_width;
 
@@ -1324,8 +1294,8 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,
       mlen += reg_width;
 
       for (int i = 1; i < ir->coordinate->type->vector_elements; i++) {
-	 emit(ADD(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D),
-                  coordinate, offsets[i]));
+	 emit(MOV(fs_reg(MRF, base_mrf + mlen, BRW_REGISTER_TYPE_D),
+                  coordinate));
 	 coordinate.reg_offset++;
 	 mlen += reg_width;
       }
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index e2f4910..7ae5337 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2317,28 +2317,9 @@ vec4_visitor::visit(ir_texture *ir)
       int coord_mask = (1 << ir->coordinate->type->vector_elements) - 1;
       int zero_mask = 0xf & ~coord_mask;
 
-      if (ir->offset && ir->op == ir_txf) {
-	 /* It appears that the ld instruction used for txf does its
-	  * address bounds check before adding in the offset.  To work
-	  * around this, just add the integer offset to the integer
-	  * texel coordinate, and don't put the offset in the header.
-	  */
-	 ir_constant *offset = ir->offset->as_constant();
-	 assert(offset);
-
-	 for (int j = 0; j < ir->coordinate->type->vector_elements; j++) {
-	    src_reg src = coordinate;
-	    src.swizzle = BRW_SWIZZLE4(BRW_GET_SWZ(src.swizzle, j),
-				       BRW_GET_SWZ(src.swizzle, j),
-				       BRW_GET_SWZ(src.swizzle, j),
-				       BRW_GET_SWZ(src.swizzle, j));
-	    emit(ADD(dst_reg(MRF, param_base, ir->coordinate->type, 1 << j),
-		     src, offset->value.i[j]));
-	 }
-      } else {
-	 emit(MOV(dst_reg(MRF, param_base, ir->coordinate->type, coord_mask),
-		  coordinate));
-      }
+      emit(MOV(dst_reg(MRF, param_base, ir->coordinate->type, coord_mask),
+               coordinate));
+
       if (zero_mask != 0) {
          emit(MOV(dst_reg(MRF, param_base, ir->coordinate->type, zero_mask),
                   src_reg(0)));
-- 
1.8.4



More information about the mesa-dev mailing list