[Mesa-dev] [PATCH 02/23] i965: Pass in start_offset to brw_compact_instructions().

Matt Turner mattst88 at gmail.com
Mon May 19 11:55:28 PDT 2014


Let's us avoid recompacting the SIMD8 instructions when we compact the
SIMD16 program.
---
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp    |  2 +-
 src/mesa/drivers/dri/i965/brw_clip.c             |  2 +-
 src/mesa/drivers/dri/i965/brw_eu.h               |  2 +-
 src/mesa/drivers/dri/i965/brw_eu_compact.c       | 18 +++++++++---------
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp   |  4 ++--
 src/mesa/drivers/dri/i965/brw_gs.c               |  2 +-
 src/mesa/drivers/dri/i965/brw_sf.c               |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |  2 +-
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index 28c01c4..4b2c667 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -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);
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c
index 11f0b69..57c49f0 100644
--- a/src/mesa/drivers/dri/i965/brw_clip.c
+++ b/src/mesa/drivers/dri/i965/brw_clip.c
@@ -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
     */
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index 51d5214..65008a0 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -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);
diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c
index c85bc89..c3a2ec3 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_compact.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c
@@ -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) {
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index c61cc5c..9518e72 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -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);
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index ec1e14a..18b0956 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -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
     */
diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c
index 152d258..e11de26 100644
--- a/src/mesa/drivers/dri/i965/brw_sf.c
+++ b/src/mesa/drivers/dri/i965/brw_sf.c
@@ -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
     */
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 4e0fe52..e4bc682 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -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);
 }
 
-- 
1.8.3.2



More information about the mesa-dev mailing list