i965: Pass in start_offset to brw_compact_instructions().
authorMatt Turner <mattst88@gmail.com>
Thu, 15 May 2014 23:56:13 +0000 (16:56 -0700)
committerMatt Turner <mattst88@gmail.com>
Sun, 25 May 2014 06:03:22 +0000 (23:03 -0700)
Let's us avoid recompacting the SIMD8 instructions when we compact the
SIMD16 program.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
src/mesa/drivers/dri/i965/brw_clip.c
src/mesa/drivers/dri/i965/brw_eu.h
src/mesa/drivers/dri/i965/brw_eu_compact.c
src/mesa/drivers/dri/i965/brw_fs_generator.cpp
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_sf.c
src/mesa/drivers/dri/i965/brw_vec4_generator.cpp

index 28c01c4..4b2c667 100644 (file)
@@ -490,7 +490,7 @@ brw_blorp_const_color_program::compile(struct brw_context *brw,
       fprintf(stderr, "\n");
    }
 
-   brw_compact_instructions(&func);
+   brw_compact_instructions(&func, 0);
    return brw_get_program(&func, program_size);
 }
 
index 11f0b69..57c49f0 100644 (file)
@@ -110,7 +110,7 @@ static void compile_clip_prog( struct brw_context *brw,
       return;
    }
 
-   brw_compact_instructions(&c.func);
+   brw_compact_instructions(&c.func, 0);
 
    /* get the program
     */
index 51d5214..65008a0 100644 (file)
@@ -410,7 +410,7 @@ uint32_t brw_swap_cmod(uint32_t cmod);
 
 /* brw_eu_compact.c */
 void brw_init_compaction_tables(struct brw_context *brw);
-void brw_compact_instructions(struct brw_compile *p);
+void brw_compact_instructions(struct brw_compile *p, int start_offset);
 void brw_uncompact_instruction(struct brw_context *brw,
                               struct brw_instruction *dst,
                               struct brw_compact_instruction *src);
index c85bc89..c3a2ec3 100644 (file)
@@ -661,18 +661,18 @@ brw_init_compaction_tables(struct brw_context *brw)
 }
 
 void
-brw_compact_instructions(struct brw_compile *p)
+brw_compact_instructions(struct brw_compile *p, int start_offset)
 {
    struct brw_context *brw = p->brw;
-   void *store = p->store;
+   void *store = p->store + start_offset / 16;
    /* For an instruction at byte offset 8*i before compaction, this is the number
     * of compacted instructions that preceded it.
     */
-   int compacted_counts[p->next_insn_offset / 8];
+   int compacted_counts[(p->next_insn_offset - start_offset) / 8];
    /* For an instruction at byte offset 8*i after compaction, this is the
     * 8-byte offset it was at before compaction.
     */
-   int old_ip[p->next_insn_offset / 8];
+   int old_ip[(p->next_insn_offset - start_offset) / 8];
 
    if (brw->gen < 6)
       return;
@@ -680,7 +680,7 @@ brw_compact_instructions(struct brw_compile *p)
    int src_offset;
    int offset = 0;
    int compacted_count = 0;
-   for (src_offset = 0; src_offset < p->nr_insn * 16;) {
+   for (src_offset = 0; src_offset < p->next_insn_offset - start_offset;) {
       struct brw_instruction *src = store + src_offset;
       void *dst = store + offset;
 
@@ -734,8 +734,8 @@ brw_compact_instructions(struct brw_compile *p)
    }
 
    /* Fix up control flow offsets. */
-   p->next_insn_offset = offset;
-   for (offset = 0; offset < p->next_insn_offset;) {
+   p->next_insn_offset = start_offset + offset;
+   for (offset = 0; offset < p->next_insn_offset - start_offset;) {
       struct brw_instruction *insn = store + offset;
       int this_old_ip = old_ip[offset / 8];
       int this_compacted_count = compacted_counts[this_old_ip];
@@ -786,10 +786,10 @@ brw_compact_instructions(struct brw_compile *p)
 
    if (0) {
       fprintf(stderr, "dumping compacted program\n");
-      brw_disassemble(brw, p->store, 0, p->next_insn_offset, stderr);
+      brw_disassemble(brw, store, 0, p->next_insn_offset - start_offset, stderr);
 
       int cmp = 0;
-      for (offset = 0; offset < p->next_insn_offset;) {
+      for (offset = 0; offset < p->next_insn_offset - start_offset;) {
          struct brw_instruction *insn = store + offset;
 
          if (insn->header.cmpt_control) {
index c61cc5c..9518e72 100644 (file)
@@ -1852,7 +1852,7 @@ fs_generator::generate_assembly(exec_list *simd8_instructions,
    if (simd8_instructions) {
       dispatch_width = 8;
       generate_code(simd8_instructions, dump_file);
-      brw_compact_instructions(p);
+      brw_compact_instructions(p, 0);
    }
 
    if (simd16_instructions) {
@@ -1868,7 +1868,7 @@ fs_generator::generate_assembly(exec_list *simd8_instructions,
 
       dispatch_width = 16;
       generate_code(simd16_instructions, dump_file);
-      brw_compact_instructions(p);
+      brw_compact_instructions(p, prog_data->prog_offset_16);
    }
 
    return brw_get_program(p, assembly_size);
index ec1e14a..18b0956 100644 (file)
@@ -128,7 +128,7 @@ static void compile_ff_gs_prog(struct brw_context *brw,
       }
    }
 
-   brw_compact_instructions(&c.func);
+   brw_compact_instructions(&c.func, 0);
 
    /* get the program
     */
index 152d258..e11de26 100644 (file)
@@ -109,7 +109,7 @@ static void compile_sf_prog( struct brw_context *brw,
       return;
    }
 
-   brw_compact_instructions(&c.func);
+   brw_compact_instructions(&c.func, 0);
 
    /* get the program
     */
index 4e0fe52..e4bc682 100644 (file)
@@ -1363,7 +1363,7 @@ vec4_generator::generate_assembly(exec_list *instructions,
 {
    brw_set_access_mode(p, BRW_ALIGN_16);
    generate_code(instructions);
-   brw_compact_instructions(p);
+   brw_compact_instructions(p, 0);
    return brw_get_program(p, assembly_size);
 }