<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 28, 2014 at 8:10 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 src/mesa/drivers/dri/i965/brw_eu_compact.c | 39 ++++++++++++++++++------------<br>
 1 file changed, 24 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c<br>
index 5008ba6..9c23d55 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_eu_compact.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c<br>
@@ -23,12 +23,12 @@<br>
<br>
 /** @file brw_eu_compact.c<br>
  *<br>
- * Instruction compaction is a feature of gm45 and newer hardware that allows<br>
+ * Instruction compaction is a feature of G45 and newer hardware that allows<br>
  * for a smaller instruction encoding.<br>
  *<br>
  * The instruction cache is on the order of 32KB, and many programs generate<br>
  * far more instructions than that.  The instruction cache is built to barely<br>
- * keep up with instruction dispatch abaility in cache hit cases -- L1<br>
+ * keep up with instruction dispatch ability in cache hit cases -- L1<br>
  * instruction cache misses that still hit in the next level could limit<br>
  * throughput by around 50%.<br>
  *<br>
@@ -1207,14 +1207,15 @@ static void<br>
 update_gen4_jump_count(struct brw_context *brw, brw_inst *insn,<br>
                        int this_old_ip, int *compacted_counts)<br>
 {<br>
-   assert(brw->gen == 5);<br>
+   assert(brw->gen == 5 || brw->is_g4x);<br>
<br>
    /* Jump Count is in units of:<br>
+    *    - uncompacted instructions on G45; and<br>
     *    - compacted instructions on Gen5.<br>
     */<br>
    int jump_count = brw_inst_gen4_jump_count(brw, insn);<br>
-   int jump_count_compacted = jump_count;<br>
-   int jump_count_uncompacted = jump_count / 2;<br>
+   int jump_count_compacted = jump_count * (brw->is_g4x ? 2 : 1);<br>
+   int jump_count_uncompacted = jump_count / (brw->is_g4x ? 1 : 2);<br>
<br>
    int target_old_ip = this_old_ip + jump_count_uncompacted;<br>
<br>
@@ -1222,7 +1223,8 @@ update_gen4_jump_count(struct brw_context *brw, brw_inst *insn,<br>
    int target_compacted_count = compacted_counts[target_old_ip];<br>
<br>
    jump_count_compacted -= (target_compacted_count - this_compacted_count);<br>
-   brw_inst_set_gen4_jump_count(brw, insn, jump_count_compacted);<br>
+   brw_inst_set_gen4_jump_count(brw, insn, jump_count_compacted /<br>
+                                           (brw->is_g4x ? 2 : 1));<br>
 }<br>
<br>
 void<br>
@@ -1265,13 +1267,14 @@ brw_init_compaction_tables(struct brw_context *brw)<br>
       src_index_table = gen6_src_index_table;<br>
       break;<br>
    case 5:<br>
+   case 4:<br>
       control_index_table = g45_control_index_table;<br>
       datatype_table = g45_datatype_table;<br>
       subreg_table = g45_subreg_table;<br>
       src_index_table = g45_src_index_table;<br>
       break;<br>
    default:<br>
-      return;<br>
+      unreachable("unknown generation");<br>
    }<br>
 }<br>
<br>
@@ -1282,7 +1285,8 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
    struct brw_context *brw = p->brw;<br>
    void *store = p->store + start_offset / 16;<br>
    /* For an instruction at byte offset 16*i before compaction, this is the<br>
-    * number of compacted instructions that preceded it.<br>
+    * number of compacted instructions minus the number of padding NOP/NENOPs<br>
+    * that preceded it.<br>
     */<br>
    int compacted_counts[(p->next_insn_offset - start_offset) / sizeof(brw_inst)];<br>
    /* For an instruction at byte offset 8*i after compaction, this was its IP<br>
@@ -1290,7 +1294,7 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
     */<br>
    int old_ip[(p->next_insn_offset - start_offset) / sizeof(brw_compact_inst)];<br>
<br>
-   if (brw->gen == 4)<br>
+   if (brw->gen == 4 && !brw->is_g4x)<br>
       return;<br>
<br>
    int offset = 0;<br>
@@ -1319,17 +1323,22 @@ brw_compact_instructions(struct brw_compile *p, int start_offset,<br>
          offset += sizeof(brw_compact_inst);<br>
       } else {<br>
          /* It appears that the end of thread SEND instruction needs to be<br>
-          * aligned, or the GPU hangs.<br>
+          * aligned, or the GPU hangs. All uncompacted instructions need to be<br>
+          * aligned on G45.<br>
           */<br>
-         if ((brw_inst_opcode(brw, src) == BRW_OPCODE_SEND ||<br>
-              brw_inst_opcode(brw, src) == BRW_OPCODE_SENDC) &&<br>
-             brw_inst_eot(brw, src) &&<br>
-             (offset & sizeof(brw_compact_inst)) != 0) {<br>
+         if ((offset & sizeof(brw_compact_inst)) != 0 &&<br>
+             (((brw_inst_opcode(brw, src) == BRW_OPCODE_SEND ||<br>
+                brw_inst_opcode(brw, src) == BRW_OPCODE_SENDC) &&<br>
+               brw_inst_eot(brw, src)) ||<br>
+              brw->is_g4x)) {<br>
             brw_compact_inst *align = store + offset;<br>
             memset(align, 0, sizeof(*align));<br>
-            brw_compact_inst_set_opcode(align, BRW_OPCODE_NOP);<br>
+            brw_compact_inst_set_opcode(align, brw->is_g4x ? BRW_OPCODE_NENOP :<br>
+                                                             BRW_OPCODE_NOP);<br>
             brw_compact_inst_set_cmpt_control(align, true);<br>
             offset += sizeof(brw_compact_inst);<br>
+            compacted_count--;<br>
+            compacted_counts[src_offset / sizeof(brw_inst)] = compacted_count;<br></blockquote><div><br></div><div>Do these two lines really belong in this patch?  They seem completely unrelated to stuff on G45.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
             old_ip[offset / sizeof(brw_compact_inst)] = src_offset / sizeof(brw_inst);<br>
<br>
             dst = store + offset;<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.5.5<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>