i965/emit: Do the sampler index adjustment directly in header.0.3
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 22 Jan 2015 21:46:44 +0000 (13:46 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 22 Jan 2015 23:19:13 +0000 (15:19 -0800)
Prior to this commit, the adjust_sampler_state_pointer function took an
extra register that it could use as scratch space.  The usual candidate was
the destination of the sampler instruction.  However, if that register ever
aliased anything important such as the sampler index, this would scratch
all over important data.  Fortunately, the calculation is such that we can
just do it in place and we don't need the scratch space at all.

Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
src/mesa/drivers/dri/i965/brw_eu.h
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_fs_generator.cpp
src/mesa/drivers/dri/i965/brw_vec4_generator.cpp

index 22d5a0acab31bee3e8c8c533040aff3293649e05..a94ea4221ad2ba2d8c30ccf7c9a0d62d7f8d31f4 100644 (file)
@@ -283,8 +283,7 @@ void brw_SAMPLE(struct brw_compile *p,
 
 void brw_adjust_sampler_state_pointer(struct brw_compile *p,
                                       struct brw_reg header,
-                                      struct brw_reg sampler_index,
-                                      struct brw_reg scratch);
+                                      struct brw_reg sampler_index);
 
 void gen4_math(struct brw_compile *p,
               struct brw_reg dest,
index c26bed2dee341e63c1ef132ba90e70687887d63c..39b2022bcccccff65e81e69feddc49977ffc0250 100644 (file)
@@ -2383,8 +2383,7 @@ void brw_SAMPLE(struct brw_compile *p,
  */
 void brw_adjust_sampler_state_pointer(struct brw_compile *p,
                                       struct brw_reg header,
-                                      struct brw_reg sampler_index,
-                                      struct brw_reg scratch)
+                                      struct brw_reg sampler_index)
 {
    /* The "Sampler Index" field can only store values between 0 and 15.
     * However, we can add an offset to the "Sampler State Pointer"
@@ -2414,7 +2413,7 @@ void brw_adjust_sampler_state_pointer(struct brw_compile *p,
          return;
       }
 
-      struct brw_reg temp = vec1(retype(scratch, BRW_REGISTER_TYPE_UD));
+      struct brw_reg temp = get_element_ud(header, 3);
 
       brw_AND(p, temp, get_element_ud(sampler_index, 0), brw_imm_ud(0x0f0));
       brw_SHL(p, temp, temp, brw_imm_ud(4));
index d473739452d6ffcd36a3384b0311214c20028527..447490218d7b837e4a06a18472c689c8691da1ba 100644 (file)
@@ -697,7 +697,7 @@ fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src
                        brw_imm_ud(inst->offset));
          }
 
-         brw_adjust_sampler_state_pointer(p, header_reg, sampler_index, dst);
+         brw_adjust_sampler_state_pointer(p, header_reg, sampler_index);
          brw_pop_insn_state(p);
       }
    }
index d718f2eac80cfdc837f4c532e16563adb536d423..898a6db4abfadc2d90177b3f3104f2f392418fcd 100644 (file)
@@ -354,7 +354,7 @@ vec4_generator::generate_tex(vec4_instruction *inst,
          if (dw2)
             brw_MOV(p, get_element_ud(header, 2), brw_imm_ud(dw2));
 
-         brw_adjust_sampler_state_pointer(p, header, sampler_index, dst);
+         brw_adjust_sampler_state_pointer(p, header, sampler_index);
          brw_pop_insn_state(p);
       }
    }