diff options
-rw-r--r-- | src/mesa/pipe/i915simple/i915_blit.c | 4 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_context.h | 1 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_debug.c | 83 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_debug.h | 45 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_debug_fp.c | 134 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_state_fragprog.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_winsys.h | 4 |
7 files changed, 164 insertions, 109 deletions
diff --git a/src/mesa/pipe/i915simple/i915_blit.c b/src/mesa/pipe/i915simple/i915_blit.c index c4eafa71d45..4fc216dd33b 100644 --- a/src/mesa/pipe/i915simple/i915_blit.c +++ b/src/mesa/pipe/i915simple/i915_blit.c @@ -36,6 +36,7 @@ #include "i915_reg.h" #include "i915_batch.h" +#define FILE_DEBUG_FLAG DEBUG_BLIT void i915_fill_blit(struct i915_context *i915, @@ -102,7 +103,8 @@ i915_copy_blit( struct i915_context *i915, BATCH_LOCALS; - printf("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", + DBG(i915, + "%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", __FUNCTION__, src_buffer, src_pitch, src_offset, src_x, src_y, dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h); diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h index c9fd2e9a3f8..550d9c012ff 100644 --- a/src/mesa/pipe/i915simple/i915_context.h +++ b/src/mesa/pipe/i915simple/i915_context.h @@ -120,6 +120,7 @@ struct i915_context struct i915_state current; GLuint hardware_dirty; + GLuint debug; struct pipe_scissor_state cliprect; diff --git a/src/mesa/pipe/i915simple/i915_debug.c b/src/mesa/pipe/i915simple/i915_debug.c index 0951319d38d..0ea6f03e494 100644 --- a/src/mesa/pipe/i915simple/i915_debug.c +++ b/src/mesa/pipe/i915simple/i915_debug.c @@ -29,8 +29,10 @@ #include "i915_reg.h" #include "i915_context.h" +#include "i915_winsys.h" #include "i915_debug.h" +#define PRINTF( stream, ... ) (stream)->winsys->printf( (stream)->winsys, __VA_ARGS__ ) static GLboolean debug( struct debug_stream *stream, const char *name, GLuint len ) @@ -39,19 +41,19 @@ static GLboolean debug( struct debug_stream *stream, const char *name, GLuint le GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { - _mesa_printf("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + PRINTF( stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0] ); assert(0); return GL_FALSE; } if (stream->print_addresses) - _mesa_printf("%08x: ", stream->offset); + PRINTF(stream, "%08x: ", stream->offset); - _mesa_printf("%s (%d dwords):\n", name, len); + PRINTF(stream, "%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t\t0x%08x\n", ptr[i]); - _mesa_printf("\n"); + PRINTF(stream, "\t\t0x%08x\n", ptr[i]); + PRINTF(stream, "\n"); stream->offset += len * sizeof(GLuint); @@ -88,17 +90,17 @@ static GLboolean debug_prim( struct debug_stream *stream, const char *name, - _mesa_printf("%s %s (%d dwords):\n", name, prim, len); - _mesa_printf("\t\t0x%08x\n", ptr[0]); + PRINTF(stream, "%s %s (%d dwords):\n", name, prim, len); + PRINTF(stream, "\t\t0x%08x\n", ptr[0]); for (i = 1; i < len; i++) { if (dump_floats) - _mesa_printf("\t\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); + PRINTF(stream, "\t\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); else - _mesa_printf("\t\t0x%08x\n", ptr[i]); + PRINTF(stream, "\t\t0x%08x\n", ptr[i]); } - _mesa_printf("\n"); + PRINTF(stream, "\n"); stream->offset += len * sizeof(GLuint); @@ -113,16 +115,16 @@ static GLboolean debug_program( struct debug_stream *stream, const char *name, G GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { - _mesa_printf("Error - zero length packet (0x%08x)\n", stream->ptr[0]); + PRINTF(stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0]); assert(0); return GL_FALSE; } if (stream->print_addresses) - _mesa_printf("%08x: ", stream->offset); + PRINTF(stream, "%08x: ", stream->offset); - _mesa_printf("%s (%d dwords):\n", name, len); - i915_disassemble_program( ptr, len ); + PRINTF(stream, "%s (%d dwords):\n", name, len); + i915_disassemble_program( stream, ptr, len ); stream->offset += len * sizeof(GLuint); return GL_TRUE; @@ -135,17 +137,17 @@ static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLu GLuint old_offset = stream->offset + len * sizeof(GLuint); GLuint i; - _mesa_printf("%s (%d dwords):\n", name, len); + PRINTF(stream, "%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t\t0x%08x\n", ptr[i]); + PRINTF(stream, "\t\t0x%08x\n", ptr[i]); stream->offset = ptr[1] & ~0x3; if (stream->offset < old_offset) - _mesa_printf("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", + PRINTF(stream, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); else - _mesa_printf("\n... skipping from 0x%x --> 0x%x ...\n\n", + PRINTF(stream, "\n... skipping from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); @@ -165,10 +167,10 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) len = 1+(i+2)/2; - _mesa_printf("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); + PRINTF(stream, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); for (i = 0; i < len; i++) - _mesa_printf("\t\t0x%08x\n", ptr[i]); - _mesa_printf("\n"); + PRINTF(stream, "\t\t0x%08x\n", ptr[i]); + PRINTF(stream, "\n"); stream->offset += len * sizeof(GLuint); return GL_TRUE; @@ -183,16 +185,16 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, GLuint bits = (ptr[0] >> 4) & 0xff; GLuint i, j = 0; - _mesa_printf("%s (%d dwords, flags: %x):\n", name, len, bits); - _mesa_printf("\t\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords, flags: %x):\n", name, len, bits); + PRINTF(stream, "\t\t0x%08x\n", ptr[j++]); for (i = 0; i < 8; i++) { if (bits & (1<<i)) { - _mesa_printf("\t LIS%d: 0x%08x\n", i, ptr[j++]); + PRINTF(stream, "\t LIS%d: 0x%08x\n", i, ptr[j++]); } } - _mesa_printf("\n"); + PRINTF(stream, "\n"); assert(j == len); @@ -211,34 +213,34 @@ static GLboolean debug_load_indirect( struct debug_stream *stream, GLuint bits = (ptr[0] >> 8) & 0x3f; GLuint i, j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t\t0x%08x\n", ptr[j++]); + PRINTF(stream, "%s (%d dwords):\n", name, len); + PRINTF(stream, "\t\t0x%08x\n", ptr[j++]); for (i = 0; i < 6; i++) { if (bits & (1<<i)) { switch (1<<(8+i)) { case LI0_STATE_STATIC_INDIRECT: - _mesa_printf(" STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; - _mesa_printf(" 0x%08x\n", ptr[j++]); + PRINTF(stream, " STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(stream, " 0x%08x\n", ptr[j++]); break; case LI0_STATE_DYNAMIC_INDIRECT: - _mesa_printf(" DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(stream, " DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; break; case LI0_STATE_SAMPLER: - _mesa_printf(" SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; - _mesa_printf(" 0x%08x\n", ptr[j++]); + PRINTF(stream, " SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(stream, " 0x%08x\n", ptr[j++]); break; case LI0_STATE_MAP: - _mesa_printf(" MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; - _mesa_printf(" 0x%08x\n", ptr[j++]); + PRINTF(stream, " MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(stream, " 0x%08x\n", ptr[j++]); break; case LI0_STATE_PROGRAM: - _mesa_printf(" PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; - _mesa_printf(" 0x%08x\n", ptr[j++]); + PRINTF(stream, " PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(stream, " 0x%08x\n", ptr[j++]); break; case LI0_STATE_CONSTANTS: - _mesa_printf(" CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; - _mesa_printf(" 0x%08x\n", ptr[j++]); + PRINTF(stream, " CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; + PRINTF(stream, " 0x%08x\n", ptr[j++]); break; default: assert(0); @@ -248,10 +250,10 @@ static GLboolean debug_load_indirect( struct debug_stream *stream, } if (bits == 0) { - _mesa_printf("\t DUMMY: 0x%08x\n", ptr[j++]); + PRINTF(stream, "\t DUMMY: 0x%08x\n", ptr[j++]); } - _mesa_printf("\n"); + PRINTF(stream, "\n"); assert(j == len); @@ -421,6 +423,7 @@ i915_dump_batchbuffer( struct i915_context *i915, stream.offset = 0; stream.ptr = (char *)start; stream.print_addresses = 0; + stream.winsys = i915->winsys; while (!done && stream.offset < bytes && diff --git a/src/mesa/pipe/i915simple/i915_debug.h b/src/mesa/pipe/i915simple/i915_debug.h index 3e01db64342..f0f72780d3e 100644 --- a/src/mesa/pipe/i915simple/i915_debug.h +++ b/src/mesa/pipe/i915simple/i915_debug.h @@ -39,18 +39,51 @@ struct debug_stream char *ptr; /* pointer to gtt offset zero */ char *end; /* pointer to gtt offset zero */ unsigned print_addresses; + struct i915_winsys *winsys; }; +/* Internal functions + */ +void i915_disassemble_program(struct debug_stream *stream, + const unsigned *program, unsigned sz); + +void i915_print_ureg(const char *msg, unsigned ureg); + + +#define DEBUG_BATCH 0x1 +#define DEBUG_BLIT 0x2 +#define DEBUG_BUFFER 0x4 +#define DEBUG_CONSTANTS 0x8 +#define DEBUG_CONTEXT 0x10 +#define DEBUG_DRAW 0x20 +#define DEBUG_DYNAMIC 0x40 +#define DEBUG_FLUSH 0x80 +#define DEBUG_MAP 0x100 +#define DEBUG_PROGRAM 0x200 +#define DEBUG_REGIONS 0x400 +#define DEBUG_SAMPLER 0x800 +#define DEBUG_STATIC 0x1000 +#define DEBUG_SURFACE 0x2000 +#define DEBUG_WINSYS 0x4000 + +#ifdef DEBUG +#include "i915_winsys.h" +#define DBG( i915, ... ) \ + if ((i915)->debug & FILE_DEBUG_FLAG) (i915)->winsys->printf( (i915)->winsys, __VA_ARGS__ ) +#else +#define DBG( i915, ... ) \ + (void)i915 +#endif + + +void i915_dump_batchbuffer( struct i915_context *i915, + unsigned *start, + unsigned *end ); -extern void i915_disassemble_program(const unsigned *program, unsigned sz); -extern void i915_print_ureg(const char *msg, unsigned ureg); -void -i915_dump_batchbuffer( struct i915_context *i915, - unsigned *start, - unsigned *end ); +void i915_debug_init( struct i915_context *i915 ); #endif diff --git a/src/mesa/pipe/i915simple/i915_debug_fp.c b/src/mesa/pipe/i915simple/i915_debug_fp.c index f4e8ae95ade..95476d3c559 100644 --- a/src/mesa/pipe/i915simple/i915_debug_fp.c +++ b/src/mesa/pipe/i915simple/i915_debug_fp.c @@ -29,11 +29,19 @@ #include "i915_reg.h" #include "i915_debug.h" +#include "i915_winsys.h" //#include "i915_fpc.h" #include "shader/program.h" #include "shader/prog_instruction.h" #include "shader/prog_print.h" + + +#define PRINTF( stream, ... ) (stream)->winsys->printf( (stream)->winsys, __VA_ARGS__ ) + + + + static const char *opcodes[0x20] = { "NOP", "ADD", @@ -118,33 +126,33 @@ static const char *regname[0x8] = { }; static void -print_reg_type_nr(GLuint type, GLuint nr) +print_reg_type_nr(struct debug_stream *stream, GLuint type, GLuint nr) { switch (type) { case REG_TYPE_T: switch (nr) { case T_DIFFUSE: - _mesa_printf("T_DIFFUSE"); + PRINTF(stream, "T_DIFFUSE"); return; case T_SPECULAR: - _mesa_printf("T_SPECULAR"); + PRINTF(stream, "T_SPECULAR"); return; case T_FOG_W: - _mesa_printf("T_FOG_W"); + PRINTF(stream, "T_FOG_W"); return; default: - _mesa_printf("T_TEX%d", nr); + PRINTF(stream, "T_TEX%d", nr); return; } case REG_TYPE_OC: if (nr == 0) { - _mesa_printf("oC"); + PRINTF(stream, "oC"); return; } break; case REG_TYPE_OD: if (nr == 0) { - _mesa_printf("oD"); + PRINTF(stream, "oD"); return; } break; @@ -152,7 +160,7 @@ print_reg_type_nr(GLuint type, GLuint nr) break; } - _mesa_printf("%s[%d]", regname[type], nr); + PRINTF(stream, "%s[%d]", regname[type], nr); } #define REG_SWIZZLE_MASK 0x7777 @@ -165,7 +173,7 @@ print_reg_type_nr(GLuint type, GLuint nr) static void -print_reg_neg_swizzle(GLuint reg) +print_reg_neg_swizzle(struct debug_stream *stream, GLuint reg) { int i; @@ -173,33 +181,33 @@ print_reg_neg_swizzle(GLuint reg) (reg & REG_NEGATE_MASK) == 0) return; - _mesa_printf("."); + PRINTF(stream, "."); for (i = 3; i >= 0; i--) { if (reg & (1 << ((i * 4) + 3))) - _mesa_printf("-"); + PRINTF(stream, "-"); switch ((reg >> (i * 4)) & 0x7) { case 0: - _mesa_printf("x"); + PRINTF(stream, "x"); break; case 1: - _mesa_printf("y"); + PRINTF(stream, "y"); break; case 2: - _mesa_printf("z"); + PRINTF(stream, "z"); break; case 3: - _mesa_printf("w"); + PRINTF(stream, "w"); break; case 4: - _mesa_printf("0"); + PRINTF(stream, "0"); break; case 5: - _mesa_printf("1"); + PRINTF(stream, "1"); break; default: - _mesa_printf("?"); + PRINTF(stream, "?"); break; } } @@ -207,32 +215,32 @@ print_reg_neg_swizzle(GLuint reg) static void -print_src_reg(GLuint dword) +print_src_reg(struct debug_stream *stream, GLuint dword) { GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK; GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr(type, nr); - print_reg_neg_swizzle(dword); + print_reg_type_nr(stream, type, nr); + print_reg_neg_swizzle(stream, dword); } static void -print_dest_reg(GLuint dword) +print_dest_reg(struct debug_stream *stream, GLuint dword) { GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK; GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK; - print_reg_type_nr(type, nr); + print_reg_type_nr(stream, type, nr); if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) return; - _mesa_printf("."); + PRINTF(stream, "."); if (dword & A0_DEST_CHANNEL_X) - _mesa_printf("x"); + PRINTF(stream, "x"); if (dword & A0_DEST_CHANNEL_Y) - _mesa_printf("y"); + PRINTF(stream, "y"); if (dword & A0_DEST_CHANNEL_Z) - _mesa_printf("z"); + PRINTF(stream, "z"); if (dword & A0_DEST_CHANNEL_W) - _mesa_printf("w"); + PRINTF(stream, "w"); } @@ -242,70 +250,76 @@ print_dest_reg(GLuint dword) static void -print_arith_op(GLuint opcode, const GLuint * program) +print_arith_op(struct debug_stream *stream, + GLuint opcode, const GLuint * program) { if (opcode != A0_NOP) { - print_dest_reg(program[0]); + print_dest_reg(stream, program[0]); if (program[0] & A0_DEST_SATURATE) - _mesa_printf(" = SATURATE "); + PRINTF(stream, " = SATURATE "); else - _mesa_printf(" = "); + PRINTF(stream, " = "); } - _mesa_printf("%s ", opcodes[opcode]); + PRINTF(stream, "%s ", opcodes[opcode]); - print_src_reg(GET_SRC0_REG(program[0], program[1])); + print_src_reg(stream, GET_SRC0_REG(program[0], program[1])); if (args[opcode] == 1) { - _mesa_printf("\n"); + PRINTF(stream, "\n"); return; } - _mesa_printf(", "); - print_src_reg(GET_SRC1_REG(program[1], program[2])); + PRINTF(stream, ", "); + print_src_reg(stream, GET_SRC1_REG(program[1], program[2])); if (args[opcode] == 2) { - _mesa_printf("\n"); + PRINTF(stream, "\n"); return; } - _mesa_printf(", "); - print_src_reg(GET_SRC2_REG(program[2])); - _mesa_printf("\n"); + PRINTF(stream, ", "); + print_src_reg(stream, GET_SRC2_REG(program[2])); + PRINTF(stream, "\n"); return; } static void -print_tex_op(GLuint opcode, const GLuint * program) +print_tex_op(struct debug_stream *stream, + GLuint opcode, const GLuint * program) { - print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - _mesa_printf(" = "); + print_dest_reg(stream, program[0] | A0_DEST_CHANNEL_ALL); + PRINTF(stream, " = "); - _mesa_printf("%s ", opcodes[opcode]); + PRINTF(stream, "%s ", opcodes[opcode]); - _mesa_printf("S[%d],", program[0] & T0_SAMPLER_NR_MASK); + PRINTF(stream, "S[%d],", program[0] & T0_SAMPLER_NR_MASK); - print_reg_type_nr((program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & + print_reg_type_nr(stream, + (program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK, (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); - _mesa_printf("\n"); + PRINTF(stream, "\n"); } static void -print_dcl_op(GLuint opcode, const GLuint * program) +print_dcl_op(struct debug_stream *stream, + GLuint opcode, const GLuint * program) { - _mesa_printf("%s ", opcodes[opcode]); - print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - _mesa_printf("\n"); + PRINTF(stream, "%s ", opcodes[opcode]); + print_dest_reg(stream, + program[0] | A0_DEST_CHANNEL_ALL); + PRINTF(stream, "\n"); } void -i915_disassemble_program(const GLuint * program, GLuint sz) +i915_disassemble_program(struct debug_stream *stream, + const GLuint * program, GLuint sz) { GLuint size = program[0] & 0x1ff; GLint i; - _mesa_printf("\t\tBEGIN\n"); + PRINTF(stream, "\t\tBEGIN\n"); assert(size + 2 == sz); @@ -313,19 +327,19 @@ i915_disassemble_program(const GLuint * program, GLuint sz) for (i = 1; i < sz; i += 3, program += 3) { GLuint opcode = program[0] & (0x1f << 24); - _mesa_printf("\t\t"); + PRINTF(stream, "\t\t"); if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) - print_arith_op(opcode >> 24, program); + print_arith_op(stream, opcode >> 24, program); else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL) - print_tex_op(opcode >> 24, program); + print_tex_op(stream, opcode >> 24, program); else if (opcode == D0_DCL) - print_dcl_op(opcode >> 24, program); + print_dcl_op(stream, opcode >> 24, program); else - _mesa_printf("Unknown opcode 0x%x\n", opcode); + PRINTF(stream, "Unknown opcode 0x%x\n", opcode); } - _mesa_printf("\t\tEND\n\n"); + PRINTF(stream, "\t\tEND\n\n"); } diff --git a/src/mesa/pipe/i915simple/i915_state_fragprog.c b/src/mesa/pipe/i915simple/i915_state_fragprog.c index 83f43befafa..163883b07ac 100644 --- a/src/mesa/pipe/i915simple/i915_state_fragprog.c +++ b/src/mesa/pipe/i915simple/i915_state_fragprog.c @@ -56,8 +56,6 @@ static unsigned passthrough[] = unsigned *i915_passthrough_program( unsigned *dwords ) { - i915_disassemble_program( passthrough, Elements(passthrough) ); - *dwords = Elements(passthrough); return passthrough; } diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h index 50cb231422d..887308f5dda 100644 --- a/src/mesa/pipe/i915simple/i915_winsys.h +++ b/src/mesa/pipe/i915simple/i915_winsys.h @@ -50,6 +50,10 @@ struct pipe_buffer_handle; struct i915_winsys { + /* debug output + */ + void (*printf)( struct i915_winsys *sws, + const char *, ... ); /* Many of the winsys's are probably going to have a similar * buffer-manager interface, as something almost identical is |