[Mesa-dev] [PATCH 05/10] i965/disasm: Disassemble the compaction control bit.

Matt Turner mattst88 at gmail.com
Tue May 13 14:52:09 PDT 2014


brw_disasm doesn't disassemble compacted instructions, so we uncompact
before disassembling them which would unset the compaction control bit.
Instead pass it as a separate argument.
---
 src/mesa/drivers/dri/i965/brw_clip.c        | 2 +-
 src/mesa/drivers/dri/i965/brw_context.h     | 2 +-
 src/mesa/drivers/dri/i965/brw_disasm.c      | 9 ++++++++-
 src/mesa/drivers/dri/i965/brw_eu.c          | 3 ++-
 src/mesa/drivers/dri/i965/brw_eu_compact.c  | 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_state_dump.c  | 2 +-
 src/mesa/drivers/dri/i965/test_eu_compact.c | 2 +-
 9 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c
index c32bf5c..d1815f2 100644
--- a/src/mesa/drivers/dri/i965/brw_clip.c
+++ b/src/mesa/drivers/dri/i965/brw_clip.c
@@ -121,7 +121,7 @@ static void compile_clip_prog( struct brw_context *brw,
       fprintf(stderr, "clip:\n");
       for (i = 0; i < program_size / sizeof(struct brw_instruction); i++)
 	 brw_disasm(stderr, &((struct brw_instruction *)program)[i],
-		    brw->gen);
+		    brw->gen, false);
       fprintf(stderr, "\n");
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 92e1592..b02846e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1559,7 +1559,7 @@ void brw_fs_alloc_reg_sets(struct intel_screen *screen);
 void brw_vec4_alloc_reg_set(struct intel_screen *screen);
 
 /* brw_disasm.c */
-int brw_disasm (FILE *file, struct brw_instruction *inst, int gen);
+int brw_disasm (FILE *file, struct brw_instruction *inst, int gen, bool is_compacted);
 
 /* brw_vs.c */
 gl_clip_plane *brw_select_clip_planes(struct gl_context *ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c b/src/mesa/drivers/dri/i965/brw_disasm.c
index e54172c..b9654a3 100644
--- a/src/mesa/drivers/dri/i965/brw_disasm.c
+++ b/src/mesa/drivers/dri/i965/brw_disasm.c
@@ -167,6 +167,11 @@ static const char * const saturate[2] = {
     [1] = ".sat"
 };
 
+static const char * const cmpt_ctrl[2] = {
+   [0] = "",
+   [1] = "compacted"
+};
+
 static const char * const accwr[2] = {
     [0] = "",
     [1] = "AccWrEnable"
@@ -1114,7 +1119,7 @@ static int qtr_ctrl(FILE *file, struct brw_instruction *inst)
     return 0;
 }
 
-int brw_disasm (FILE *file, struct brw_instruction *inst, int gen)
+int brw_disasm (FILE *file, struct brw_instruction *inst, int gen, bool is_compacted)
 {
     int	err = 0;
     int space = 0;
@@ -1136,6 +1141,7 @@ int brw_disasm (FILE *file, struct brw_instruction *inst, int gen)
 
     err |= print_opcode (file, inst->header.opcode);
     err |= control (file, "saturate", saturate, inst->header.saturate, NULL);
+
     err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL);
 
     if (inst->header.opcode == BRW_OPCODE_MATH) {
@@ -1449,6 +1455,7 @@ int brw_disasm (FILE *file, struct brw_instruction *inst, int gen)
 	    }
 	}
 
+	err |= control (file, "compaction control", cmpt_ctrl, is_compacted, &space);
 	err |= control (file, "thread control", thread_ctrl, inst->header.thread_control, &space);
 	if (gen >= 6)
 	    err |= control (file, "acc write control", accwr, inst->header.acc_wr_control, &space);
diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c
index bb84029..15105c2 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.c
+++ b/src/mesa/drivers/dri/i965/brw_eu.c
@@ -265,6 +265,7 @@ brw_dump_compile(struct brw_compile *p, FILE *out, int start, int end)
    for (int offset = start; offset < end;) {
       struct brw_instruction *insn = store + offset;
       struct brw_instruction uncompacted;
+      bool compacted = insn->header.cmpt_control;
       fprintf(out, "0x%08x: ", offset);
 
       if (insn->header.cmpt_control) {
@@ -289,6 +290,6 @@ brw_dump_compile(struct brw_compile *p, FILE *out, int start, int end)
 	 offset += 16;
       }
 
-      brw_disasm(out, insn, p->brw->gen);
+      brw_disasm(out, insn, p->brw->gen, compacted);
    }
 }
diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c
index 3004843..fd05ce2 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_compact.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c
@@ -585,10 +585,10 @@ void brw_debug_compact_uncompact(struct brw_context *brw,
            brw->gen);
 
    fprintf(stderr, "  before: ");
-   brw_disasm(stderr, orig, brw->gen);
+   brw_disasm(stderr, orig, brw->gen, true);
 
    fprintf(stderr, "  after:  ");
-   brw_disasm(stderr, uncompacted, brw->gen);
+   brw_disasm(stderr, uncompacted, brw->gen, false);
 
    uint32_t *before_bits = (uint32_t *)orig;
    uint32_t *after_bits = (uint32_t *)uncompacted;
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index ddfb296..866d298 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -138,7 +138,7 @@ static void compile_ff_gs_prog(struct brw_context *brw,
       fprintf(stderr, "gs:\n");
       for (i = 0; i < program_size / sizeof(struct brw_instruction); i++)
 	 brw_disasm(stderr, &((struct brw_instruction *)program)[i],
-		    brw->gen);
+		    brw->gen, false);
       fprintf(stderr, "\n");
     }
 
diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c
index 7714aae..61d308a 100644
--- a/src/mesa/drivers/dri/i965/brw_sf.c
+++ b/src/mesa/drivers/dri/i965/brw_sf.c
@@ -118,7 +118,7 @@ static void compile_sf_prog( struct brw_context *brw,
       fprintf(stderr, "sf:\n");
       for (i = 0; i < program_size / sizeof(struct brw_instruction); i++)
 	 brw_disasm(stderr, &((struct brw_instruction *)program)[i],
-		    brw->gen);
+		    brw->gen, false);
       fprintf(stderr, "\n");
    }
 
diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c
index 40b5c65..57dd2e7 100644
--- a/src/mesa/drivers/dri/i965/brw_state_dump.c
+++ b/src/mesa/drivers/dri/i965/brw_state_dump.c
@@ -530,7 +530,7 @@ dump_prog_cache(struct brw_context *brw)
 		    name,
 		    data[i * 4], data[i * 4 + 1], data[i * 4 + 2], data[i * 4 + 3]);
 
-	    brw_disasm(stderr, (void *)(data + i * 4), brw->gen);
+	    brw_disasm(stderr, (void *)(data + i * 4), brw->gen, false);
 	 }
       }
    }
diff --git a/src/mesa/drivers/dri/i965/test_eu_compact.c b/src/mesa/drivers/dri/i965/test_eu_compact.c
index cc0c6e4..2735967 100644
--- a/src/mesa/drivers/dri/i965/test_eu_compact.c
+++ b/src/mesa/drivers/dri/i965/test_eu_compact.c
@@ -51,7 +51,7 @@ test_compact_instruction(struct brw_compile *p, struct brw_instruction src)
       if (memcmp(&unchanged, &dst, sizeof(dst))) {
 	 fprintf(stderr, "Failed to compact, but dst changed\n");
 	 fprintf(stderr, "  Instruction: ");
-	 brw_disasm(stderr, &src, brw->gen);
+	 brw_disasm(stderr, &src, brw->gen, false);
 	 return false;
       }
    }
-- 
1.8.3.2



More information about the mesa-dev mailing list