From 6ea55d35254b7769c65f064170d8965c0bf34a27 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 11 Aug 2007 13:48:19 +0100 Subject: [PATCH] Make it easier to compare against the pipe driver debug code. --- src/mesa/drivers/dri/i915tex/i915_debug.c | 180 +++++++++---------- src/mesa/drivers/dri/i915tex/i915_debug_fp.c | 80 +++++---- 2 files changed, 131 insertions(+), 129 deletions(-) diff --git a/src/mesa/drivers/dri/i915tex/i915_debug.c b/src/mesa/drivers/dri/i915tex/i915_debug.c index d5e4ff7ae09..c0e1242a0ea 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug.c @@ -31,7 +31,7 @@ #include "i915_context.h" #include "i915_debug.h" - +#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) static GLboolean debug( struct debug_stream *stream, const char *name, GLuint len ) { @@ -39,19 +39,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("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("%08x: ", stream->offset); - _mesa_printf("%s (%d dwords):\n", name, len); + PRINTF("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t0x%08x\n", ptr[i]); - _mesa_printf("\n"); + PRINTF("\t0x%08x\n", ptr[i]); + PRINTF("\n"); stream->offset += len * sizeof(GLuint); @@ -88,17 +88,17 @@ static GLboolean debug_prim( struct debug_stream *stream, const char *name, - _mesa_printf("%s %s (%d dwords):\n", name, prim, len); - _mesa_printf("\t0x%08x\n", ptr[0]); + PRINTF("%s %s (%d dwords):\n", name, prim, len); + PRINTF("\t0x%08x\n", ptr[0]); for (i = 1; i < len; i++) { if (dump_floats) - _mesa_printf("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); + PRINTF("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); else - _mesa_printf("\t0x%08x\n", ptr[i]); + PRINTF("\t0x%08x\n", ptr[i]); } - _mesa_printf("\n"); + PRINTF("\n"); stream->offset += len * sizeof(GLuint); @@ -113,15 +113,15 @@ 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("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("%08x: ", stream->offset); - _mesa_printf("%s (%d dwords):\n", name, len); + PRINTF("%s (%d dwords):\n", name, len); i915_disassemble_program( ptr, len ); stream->offset += len * sizeof(GLuint); @@ -135,17 +135,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("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) - _mesa_printf("\t0x%08x\n", ptr[i]); + PRINTF("\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("\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("\n... skipping from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); @@ -165,10 +165,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("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); for (i = 0; i < len; i++) - _mesa_printf("\t0x%08x\n", ptr[i]); - _mesa_printf("\n"); + PRINTF("\t0x%08x\n", ptr[i]); + PRINTF("\n"); stream->offset += len * sizeof(GLuint); return GL_TRUE; @@ -178,9 +178,9 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream ) #define BITS( dw, hi, lo, ... ) \ do { \ unsigned himask = ~0UL >> (31 - (hi)); \ - _mesa_printf("\t\t "); \ - _mesa_printf(__VA_ARGS__); \ - _mesa_printf(": 0x%x\n", ((dw) & himask) >> (lo)); \ + PRINTF("\t\t "); \ + PRINTF(__VA_ARGS__); \ + PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \ } while (0) #define MBZ( dw, hi, lo) do { \ @@ -194,9 +194,9 @@ do { \ #define FLAG( dw, bit, ... ) \ do { \ if (((dw) >> (bit)) & 1) { \ - _mesa_printf("\t\t "); \ - _mesa_printf(__VA_ARGS__); \ - _mesa_printf("\n"); \ + PRINTF("\t\t "); \ + PRINTF(__VA_ARGS__); \ + PRINTF("\n"); \ } \ } while (0) @@ -208,17 +208,17 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, GLuint bits = (ptr[0] >> 4) & 0xff; GLuint j = 0; - _mesa_printf("%s (%d dwords, flags: %x):\n", name, len, bits); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords, flags: %x):\n", name, len, bits); + PRINTF("\t0x%08x\n", ptr[j++]); if (bits & (1<<0)) { - _mesa_printf("\t LIS0: 0x%08x\n", ptr[j]); - _mesa_printf("\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); + PRINTF("\t LIS0: 0x%08x\n", ptr[j]); + PRINTF("\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); BITS(ptr[j], 0, 0, "vb invalidate disable"); j++; } if (bits & (1<<1)) { - _mesa_printf("\t LIS1: 0x%08x\n", ptr[j]); + PRINTF("\t LIS1: 0x%08x\n", ptr[j]); BITS(ptr[j], 29, 24, "vb dword width"); BITS(ptr[j], 21, 16, "vb dword pitch"); BITS(ptr[j], 15, 0, "vb max index"); @@ -226,20 +226,20 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, } if (bits & (1<<2)) { int i; - _mesa_printf("\t LIS2: 0x%08x\n", ptr[j]); + PRINTF("\t LIS2: 0x%08x\n", ptr[j]); for (i = 0; i < 8; i++) { unsigned tc = (ptr[j] >> (i * 4)) & 0xf; -// if (tc != 0xf) + if (tc != 0xf) BITS(tc, 3, 0, "tex coord %d", i); } j++; } if (bits & (1<<3)) { - _mesa_printf("\t LIS3: 0x%08x\n", ptr[j]); + PRINTF("\t LIS3: 0x%08x\n", ptr[j]); j++; } if (bits & (1<<4)) { - _mesa_printf("\t LIS4: 0x%08x\n", ptr[j]); + PRINTF("\t LIS4: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 23, "point width"); BITS(ptr[j], 22, 19, "line width"); FLAG(ptr[j], 18, "alpha flatshade"); @@ -261,7 +261,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, j++; } if (bits & (1<<5)) { - _mesa_printf("\t LIS5: 0x%08x\n", ptr[j]); + PRINTF("\t LIS5: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 28, "rgba write disables"); FLAG(ptr[j], 27, "force dflt point width"); FLAG(ptr[j], 26, "last pixel enable"); @@ -279,7 +279,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, j++; } if (bits & (1<<6)) { - _mesa_printf("\t LIS6: 0x%08x\n", ptr[j]); + PRINTF("\t LIS6: 0x%08x\n", ptr[j]); FLAG(ptr[j], 31, "alpha test enable"); BITS(ptr[j], 30, 28, "alpha func"); BITS(ptr[j], 27, 20, "alpha ref"); @@ -296,7 +296,7 @@ static GLboolean debug_load_immediate( struct debug_stream *stream, } - _mesa_printf("\n"); + PRINTF("\n"); assert(j == len); @@ -315,34 +315,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("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); for (i = 0; i < 6; i++) { if (bits & (1<ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR22(stream, ptr[j++]); @@ -455,8 +455,8 @@ static GLboolean debug_color_blit( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR22(stream, ptr[j++]); @@ -476,8 +476,8 @@ static GLboolean debug_modes4( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 21, 18, "logicop func"); FLAG(ptr[j], 17, "stencil test mask modify-enable"); FLAG(ptr[j], 16, "stencil write mask modify-enable"); @@ -497,26 +497,26 @@ static GLboolean debug_map_state( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_printf("\t0x%08x\n", ptr[j]); + PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "map mask"); j++; } while (j < len) { { - _mesa_printf("\t TMn.0: 0x%08x\n", ptr[j]); - _mesa_printf("\t map address: 0x%08x\n", (ptr[j] & ~0x3)); + PRINTF("\t TMn.0: 0x%08x\n", ptr[j]); + PRINTF("\t map address: 0x%08x\n", (ptr[j] & ~0x3)); FLAG(ptr[j], 1, "vertical line stride"); FLAG(ptr[j], 0, "vertical line stride offset"); j++; } { - _mesa_printf("\t TMn.1: 0x%08x\n", ptr[j]); + PRINTF("\t TMn.1: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 21, "height"); BITS(ptr[j], 20, 10, "width"); BITS(ptr[j], 9, 7, "surface format"); @@ -527,7 +527,7 @@ static GLboolean debug_map_state( struct debug_stream *stream, j++; } { - _mesa_printf("\t TMn.2: 0x%08x\n", ptr[j]); + PRINTF("\t TMn.2: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 21, "dword pitch"); BITS(ptr[j], 20, 15, "cube face enables"); BITS(ptr[j], 14, 9, "max lod"); @@ -549,18 +549,18 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_printf("\t0x%08x\n", ptr[j]); + PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "sampler mask"); j++; } while (j < len) { { - _mesa_printf("\t TSn.0: 0x%08x\n", ptr[j]); + PRINTF("\t TSn.0: 0x%08x\n", ptr[j]); FLAG(ptr[j], 31, "reverse gamma"); FLAG(ptr[j], 30, "planar to packed"); FLAG(ptr[j], 29, "yuv->rgb"); @@ -577,7 +577,7 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, } { - _mesa_printf("\t TSn.1: 0x%08x\n", ptr[j]); + PRINTF("\t TSn.1: 0x%08x\n", ptr[j]); BITS(ptr[j], 31, 24, "min lod"); MBZ( ptr[j], 23, 18 ); FLAG(ptr[j], 17, "kill pixel enable"); @@ -592,7 +592,7 @@ static GLboolean debug_sampler_state( struct debug_stream *stream, j++; } { - _mesa_printf("\t TSn.2: 0x%08x (default color)\n", ptr[j]); + PRINTF("\t TSn.2: 0x%08x (default color)\n", ptr[j]); j++; } } @@ -609,11 +609,11 @@ static GLboolean debug_dest_vars( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_printf("\t0x%08x\n", ptr[j]); + PRINTF("\t0x%08x\n", ptr[j]); FLAG(ptr[j], 31, "early classic ztest"); FLAG(ptr[j], 30, "opengl tex default color"); FLAG(ptr[j], 29, "bypass iz"); @@ -644,11 +644,11 @@ static GLboolean debug_buf_info( struct debug_stream *stream, GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; - _mesa_printf("%s (%d dwords):\n", name, len); - _mesa_printf("\t0x%08x\n", ptr[j++]); + PRINTF("%s (%d dwords):\n", name, len); + PRINTF("\t0x%08x\n", ptr[j++]); { - _mesa_printf("\t0x%08x\n", ptr[j]); + PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 28, 28, "aux buffer id"); BITS(ptr[j], 27, 24, "buffer id (7=depth, 3=back)"); FLAG(ptr[j], 23, "use fence regs"); @@ -660,7 +660,7 @@ static GLboolean debug_buf_info( struct debug_stream *stream, j++; } - _mesa_printf("\t0x%08x -- buffer base address\n", ptr[j++]); + PRINTF("\t0x%08x -- buffer base address\n", ptr[j++]); stream->offset += len * sizeof(GLuint); assert(j == len); @@ -820,7 +820,7 @@ i915_dump_batchbuffer( GLuint *start, GLuint bytes = (end - start) * 4; GLboolean done = GL_FALSE; - fprintf(stderr, "\n\nBATCH: (%d)\n", bytes / 4); + PRINTF("\n\nBATCH: (%d)\n", bytes / 4); stream.offset = 0; stream.ptr = (char *)start; @@ -837,7 +837,7 @@ i915_dump_batchbuffer( GLuint *start, stream.offset >= 0); } - fprintf(stderr, "END-BATCH\n\n\n"); + PRINTF("END-BATCH\n\n\n"); } diff --git a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c index 0e70b32b9e7..84347a01efe 100644 --- a/src/mesa/drivers/dri/i915tex/i915_debug_fp.c +++ b/src/mesa/drivers/dri/i915tex/i915_debug_fp.c @@ -34,6 +34,8 @@ #include "shader/prog_instruction.h" #include "shader/prog_print.h" +#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) + static const char *opcodes[0x20] = { "NOP", "ADD", @@ -124,27 +126,27 @@ print_reg_type_nr(GLuint type, GLuint nr) case REG_TYPE_T: switch (nr) { case T_DIFFUSE: - _mesa_printf("T_DIFFUSE"); + PRINTF("T_DIFFUSE"); return; case T_SPECULAR: - _mesa_printf("T_SPECULAR"); + PRINTF("T_SPECULAR"); return; case T_FOG_W: - _mesa_printf("T_FOG_W"); + PRINTF("T_FOG_W"); return; default: - _mesa_printf("T_TEX%d", nr); + PRINTF("T_TEX%d", nr); return; } case REG_TYPE_OC: if (nr == 0) { - _mesa_printf("oC"); + PRINTF("oC"); return; } break; case REG_TYPE_OD: if (nr == 0) { - _mesa_printf("oD"); + PRINTF("oD"); return; } break; @@ -152,7 +154,7 @@ print_reg_type_nr(GLuint type, GLuint nr) break; } - _mesa_printf("%s[%d]", regname[type], nr); + PRINTF("%s[%d]", regname[type], nr); } #define REG_SWIZZLE_MASK 0x7777 @@ -173,33 +175,33 @@ print_reg_neg_swizzle(GLuint reg) (reg & REG_NEGATE_MASK) == 0) return; - _mesa_printf("."); + PRINTF("."); for (i = 3; i >= 0; i--) { if (reg & (1 << ((i * 4) + 3))) - _mesa_printf("-"); + PRINTF("-"); switch ((reg >> (i * 4)) & 0x7) { case 0: - _mesa_printf("x"); + PRINTF("x"); break; case 1: - _mesa_printf("y"); + PRINTF("y"); break; case 2: - _mesa_printf("z"); + PRINTF("z"); break; case 3: - _mesa_printf("w"); + PRINTF("w"); break; case 4: - _mesa_printf("0"); + PRINTF("0"); break; case 5: - _mesa_printf("1"); + PRINTF("1"); break; default: - _mesa_printf("?"); + PRINTF("?"); break; } } @@ -224,15 +226,15 @@ print_dest_reg(GLuint dword) print_reg_type_nr(type, nr); if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL) return; - _mesa_printf("."); + PRINTF("."); if (dword & A0_DEST_CHANNEL_X) - _mesa_printf("x"); + PRINTF("x"); if (dword & A0_DEST_CHANNEL_Y) - _mesa_printf("y"); + PRINTF("y"); if (dword & A0_DEST_CHANNEL_Z) - _mesa_printf("z"); + PRINTF("z"); if (dword & A0_DEST_CHANNEL_W) - _mesa_printf("w"); + PRINTF("w"); } @@ -247,29 +249,29 @@ print_arith_op(GLuint opcode, const GLuint * program) if (opcode != A0_NOP) { print_dest_reg(program[0]); if (program[0] & A0_DEST_SATURATE) - _mesa_printf(" = SATURATE "); + PRINTF(" = SATURATE "); else - _mesa_printf(" = "); + PRINTF(" = "); } - _mesa_printf("%s ", opcodes[opcode]); + PRINTF("%s ", opcodes[opcode]); print_src_reg(GET_SRC0_REG(program[0], program[1])); if (args[opcode] == 1) { - _mesa_printf("\n"); + PRINTF("\n"); return; } - _mesa_printf(", "); + PRINTF(", "); print_src_reg(GET_SRC1_REG(program[1], program[2])); if (args[opcode] == 2) { - _mesa_printf("\n"); + PRINTF("\n"); return; } - _mesa_printf(", "); + PRINTF(", "); print_src_reg(GET_SRC2_REG(program[2])); - _mesa_printf("\n"); + PRINTF("\n"); return; } @@ -278,24 +280,24 @@ static void print_tex_op(GLuint opcode, const GLuint * program) { print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - _mesa_printf(" = "); + PRINTF(" = "); - _mesa_printf("%s ", opcodes[opcode]); + PRINTF("%s ", opcodes[opcode]); - _mesa_printf("S[%d],", program[0] & T0_SAMPLER_NR_MASK); + PRINTF("S[%d],", program[0] & T0_SAMPLER_NR_MASK); print_reg_type_nr((program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK, (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK); - _mesa_printf("\n"); + PRINTF("\n"); } static void print_dcl_op(GLuint opcode, const GLuint * program) { - _mesa_printf("%s ", opcodes[opcode]); + PRINTF("%s ", opcodes[opcode]); print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL); - _mesa_printf("\n"); + PRINTF("\n"); } @@ -305,7 +307,7 @@ i915_disassemble_program(const GLuint * program, GLuint sz) GLuint size = program[0] & 0x1ff; GLint i; - _mesa_printf("\t\tBEGIN\n"); + PRINTF("\t\tBEGIN\n"); assert(size + 2 == sz); @@ -313,7 +315,7 @@ 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("\t\t"); if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT) print_arith_op(opcode >> 24, program); @@ -322,10 +324,10 @@ i915_disassemble_program(const GLuint * program, GLuint sz) else if (opcode == D0_DCL) print_dcl_op(opcode >> 24, program); else - _mesa_printf("Unknown opcode 0x%x\n", opcode); + PRINTF("Unknown opcode 0x%x\n", opcode); } - _mesa_printf("\t\tEND\n\n"); + PRINTF("\t\tEND\n\n"); } -- 2.30.2