From aa9773d056a8799050304f75c1bf4c1f470e7e53 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 5 Nov 2009 15:34:18 +0000 Subject: [PATCH] i965g: disassemble more than one instruction at a time --- src/gallium/drivers/i965/brw_context.h | 4 ++- src/gallium/drivers/i965/brw_disasm.c | 28 ++++++++++++++++---- src/gallium/drivers/i965/brw_vs_emit.c | 4 +-- src/gallium/drivers/i965/brw_wm_emit.c | 6 +---- src/gallium/drivers/i965/brw_wm_glsl.c | 4 +-- src/gallium/winsys/drm/i965/xlib/xlib_i965.c | 22 ++++++--------- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h index 580251d2f12..e0c1c57ed77 100644 --- a/src/gallium/drivers/i965/brw_context.h +++ b/src/gallium/drivers/i965/brw_context.h @@ -794,7 +794,9 @@ int brw_upload_urb_fence(struct brw_context *brw); int brw_upload_cs_urb_state(struct brw_context *brw); /* brw_disasm.c */ -int brw_disasm (FILE *file, struct brw_instruction *inst); +int brw_disasm (FILE *file, + const struct brw_instruction *inst, + unsigned count); /*====================================================================== * Inline conversion functions. These are better-typed than the diff --git a/src/gallium/drivers/i965/brw_disasm.c b/src/gallium/drivers/i965/brw_disasm.c index 29fe8480057..df0c7b9a2b8 100644 --- a/src/gallium/drivers/i965/brw_disasm.c +++ b/src/gallium/drivers/i965/brw_disasm.c @@ -455,7 +455,7 @@ static int reg (FILE *file, GLuint _reg_file, GLuint _reg_nr) return err; } -static int dest (FILE *file, struct brw_instruction *inst) +static int dest (FILE *file, const struct brw_instruction *inst) { int err = 0; @@ -621,7 +621,7 @@ static int src_da16 (FILE *file, } -static int imm (FILE *file, GLuint type, struct brw_instruction *inst) { +static int imm (FILE *file, GLuint type, const struct brw_instruction *inst) { switch (type) { case BRW_REGISTER_TYPE_UD: format (file, "0x%08xUD", inst->bits3.ud); @@ -650,7 +650,7 @@ static int imm (FILE *file, GLuint type, struct brw_instruction *inst) { return 0; } -static int src0 (FILE *file, struct brw_instruction *inst) +static int src0 (FILE *file, const struct brw_instruction *inst) { if (inst->bits1.da1.src0_reg_file == BRW_IMMEDIATE_VALUE) return imm (file, inst->bits1.da1.src0_reg_type, @@ -710,7 +710,7 @@ static int src0 (FILE *file, struct brw_instruction *inst) } } -static int src1 (FILE *file, struct brw_instruction *inst) +static int src1 (FILE *file, const struct brw_instruction *inst) { if (inst->bits1.da1.src1_reg_file == BRW_IMMEDIATE_VALUE) return imm (file, inst->bits1.da1.src1_reg_type, @@ -770,7 +770,7 @@ static int src1 (FILE *file, struct brw_instruction *inst) } } -int brw_disasm (FILE *file, struct brw_instruction *inst) +static int brw_disasm_insn (FILE *file, const struct brw_instruction *inst) { int err = 0; int space = 0; @@ -900,3 +900,21 @@ int brw_disasm (FILE *file, struct brw_instruction *inst) newline (file); return err; } + + +int brw_disasm (FILE *file, + const struct brw_instruction *inst, + unsigned count) +{ + int i, err; + + for (i = 0; i < count; i++) { + err = brw_disasm_insn(stderr, &inst[i]); + if (err) + return err; + } + + fprintf(file, "\n"); + return 0; +} + diff --git a/src/gallium/drivers/i965/brw_vs_emit.c b/src/gallium/drivers/i965/brw_vs_emit.c index 95e2b8e2cb6..d86e2104d8d 100644 --- a/src/gallium/drivers/i965/brw_vs_emit.c +++ b/src/gallium/drivers/i965/brw_vs_emit.c @@ -1627,8 +1627,6 @@ void brw_vs_emit(struct brw_vs_compile *c) int i; debug_printf("vs-native:\n"); - for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i]); - debug_printf("\n"); + brw_disasm(stderr, p->store, p->nr_insn); } } diff --git a/src/gallium/drivers/i965/brw_wm_emit.c b/src/gallium/drivers/i965/brw_wm_emit.c index a705d8b3449..1c38f80cda7 100644 --- a/src/gallium/drivers/i965/brw_wm_emit.c +++ b/src/gallium/drivers/i965/brw_wm_emit.c @@ -1512,11 +1512,7 @@ void brw_wm_emit( struct brw_wm_compile *c ) } if (BRW_DEBUG & DEBUG_WM) { - int i; - debug_printf("wm-native:\n"); - for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i]); - debug_printf("\n"); + brw_disasm(stderr, p->store, p->nr_insn); } } diff --git a/src/gallium/drivers/i965/brw_wm_glsl.c b/src/gallium/drivers/i965/brw_wm_glsl.c index a06b0a446ef..284f819bf89 100644 --- a/src/gallium/drivers/i965/brw_wm_glsl.c +++ b/src/gallium/drivers/i965/brw_wm_glsl.c @@ -2003,9 +2003,7 @@ static void brw_wm_emit_branching_shader(struct brw_context *brw, struct brw_wm_ if (BRW_DEBUG & DEBUG_WM) { debug_printf("wm-native:\n"); - for (i = 0; i < p->nr_insn; i++) - brw_disasm(stderr, &p->store[i]); - debug_printf("\n"); + brw_disasm(stderr, p->store, p->nr_insn); } } diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c index 54cf56c8119..d129067ba37 100644 --- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c +++ b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c @@ -47,7 +47,9 @@ #define MAX_VRAM (128*1024*1024) -extern int brw_disasm (FILE *file, struct brw_instruction *inst); +extern int brw_disasm (FILE *file, + const struct brw_instruction *inst, + unsigned count ); struct xlib_brw_buffer { @@ -236,7 +238,11 @@ xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer, brw_dump_cc_unit_state( data ); break; case BRW_DATA_GS_WM_PROG: - brw_disasm( stderr, data ); /* disassem */ + case BRW_DATA_GS_SF_PROG: + case BRW_DATA_GS_VS_PROG: + case BRW_DATA_GS_GS_PROG: + case BRW_DATA_GS_CLIP_PROG: + brw_disasm( stderr, data, size / sizeof(struct brw_instruction) ); break; case BRW_DATA_GS_SAMPLER_DEFAULT_COLOR: brw_dump_sampler_default_color( data ); @@ -247,9 +253,6 @@ xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer, case BRW_DATA_GS_WM_UNIT: brw_dump_wm_unit_state( data ); break; - case BRW_DATA_GS_SF_PROG: - brw_disasm( stderr, data ); /* disassem */ - break; case BRW_DATA_GS_SF_VP: brw_dump_sf_viewport( data ); break; @@ -259,24 +262,15 @@ xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer, case BRW_DATA_GS_VS_UNIT: brw_dump_vs_unit_state( data ); break; - case BRW_DATA_GS_VS_PROG: - brw_disasm( stderr, data ); /* disassem */ - break; case BRW_DATA_GS_GS_UNIT: brw_dump_gs_unit_state( data ); break; - case BRW_DATA_GS_GS_PROG: - brw_disasm( stderr, data ); /* disassem */ - break; case BRW_DATA_GS_CLIP_VP: brw_dump_clipper_viewport( data ); break; case BRW_DATA_GS_CLIP_UNIT: brw_dump_clip_unit_state( data ); break; - case BRW_DATA_GS_CLIP_PROG: - brw_disasm( stderr, data ); /* disassem */ - break; case BRW_DATA_SS_SURFACE: brw_dump_surface_state( data ); break; -- 2.30.2