📄 i915_debug.c
字号:
static void BR16( struct debug_stream *stream, GLuint val ){ PRINTF("\t0x%08x -- color\n", val);} static GLboolean debug_copy_blit( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; PRINTF("%s (%d dwords):\n", name, len); PRINTF("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR2223(stream, ptr[j], ptr[j+1]); j += 2; BR09(stream, ptr[j++]); BR26(stream, ptr[j++]); BR11(stream, ptr[j++]); BR12(stream, ptr[j++]); stream->offset += len * sizeof(GLuint); assert(j == len); return GL_TRUE;}static GLboolean debug_color_blit( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; PRINTF("%s (%d dwords):\n", name, len); PRINTF("\t0x%08x\n", ptr[j++]); BR13(stream, ptr[j++]); BR2223(stream, ptr[j], ptr[j+1]); j += 2; BR09(stream, ptr[j++]); BR16(stream, ptr[j++]); stream->offset += len * sizeof(GLuint); assert(j == len); return GL_TRUE;}static GLboolean debug_modes4( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; 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"); BITS(ptr[j], 15, 8, "stencil test mask"); BITS(ptr[j], 7, 0, "stencil write mask"); j++; stream->offset += len * sizeof(GLuint); assert(j == len); return GL_TRUE;}static GLboolean debug_map_state( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; PRINTF("%s (%d dwords):\n", name, len); PRINTF("\t0x%08x\n", ptr[j++]); { PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "map mask"); j++; } while (j < len) { { 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++; } { 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"); BITS(ptr[j], 6, 3, "texel format"); FLAG(ptr[j], 2, "use fence regs"); FLAG(ptr[j], 1, "tiled surface"); FLAG(ptr[j], 0, "tile walk ymajor"); 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"); FLAG(ptr[j], 8, "mip layout right"); BITS(ptr[j], 7, 0, "depth"); j++; } } stream->offset += len * sizeof(GLuint); assert(j == len); return GL_TRUE;}static GLboolean debug_sampler_state( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; PRINTF("%s (%d dwords):\n", name, len); PRINTF("\t0x%08x\n", ptr[j++]); { PRINTF("\t0x%08x\n", ptr[j]); BITS(ptr[j], 15, 0, "sampler mask"); j++; } while (j < len) { { 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"); BITS(ptr[j], 28, 27, "chromakey index"); BITS(ptr[j], 26, 22, "base mip level"); BITS(ptr[j], 21, 20, "mip mode filter"); BITS(ptr[j], 19, 17, "mag mode filter"); BITS(ptr[j], 16, 14, "min mode filter"); BITS(ptr[j], 13, 5, "lod bias (s4.4)"); FLAG(ptr[j], 4, "shadow enable"); FLAG(ptr[j], 3, "max-aniso-4"); BITS(ptr[j], 2, 0, "shadow func"); 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"); FLAG(ptr[j], 16, "keyed tex filter mode"); FLAG(ptr[j], 15, "chromakey enable"); BITS(ptr[j], 14, 12, "tcx wrap mode"); BITS(ptr[j], 11, 9, "tcy wrap mode"); BITS(ptr[j], 8, 6, "tcz wrap mode"); FLAG(ptr[j], 5, "normalized coords"); BITS(ptr[j], 4, 1, "map (surface) index"); FLAG(ptr[j], 0, "EAST deinterlacer enable"); j++; } { PRINTF("\t TSn.2: 0x%08x (default color)\n", ptr[j]); j++; } } stream->offset += len * sizeof(GLuint); assert(j == len); return GL_TRUE;}static GLboolean debug_dest_vars( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; PRINTF("%s (%d dwords):\n", name, len); 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"); FLAG(ptr[j], 28, "lod preclamp"); BITS(ptr[j], 27, 26, "dither pattern"); FLAG(ptr[j], 25, "linear gamma blend"); FLAG(ptr[j], 24, "debug dither"); BITS(ptr[j], 23, 20, "dstorg x"); BITS(ptr[j], 19, 16, "dstorg y"); MBZ (ptr[j], 15, 15 ); BITS(ptr[j], 14, 12, "422 write select"); BITS(ptr[j], 11, 8, "cbuf format"); BITS(ptr[j], 3, 2, "zbuf format"); FLAG(ptr[j], 1, "vert line stride"); FLAG(ptr[j], 1, "vert line stride offset"); j++; } stream->offset += len * sizeof(GLuint); assert(j == len); return GL_TRUE;}static GLboolean debug_buf_info( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); int j = 0; PRINTF("%s (%d dwords):\n", name, len); 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"); FLAG(ptr[j], 22, "tiled surface"); FLAG(ptr[j], 21, "tile walk ymajor"); MBZ (ptr[j], 20, 14); BITS(ptr[j], 13, 2, "dword pitch"); MBZ (ptr[j], 2, 0); j++; } PRINTF("\t0x%08x -- buffer base address\n", ptr[j++]); stream->offset += len * sizeof(GLuint); assert(j == len); return GL_TRUE;}static GLboolean i915_debug_packet( struct debug_stream *stream ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); GLuint cmd = *ptr; switch (((cmd >> 29) & 0x7)) { case 0x0: switch ((cmd >> 23) & 0x3f) { case 0x0: return debug(stream, "MI_NOOP", 1); case 0x3: return debug(stream, "MI_WAIT_FOR_EVENT", 1); case 0x4: return debug(stream, "MI_FLUSH", 1); case 0xA: debug(stream, "MI_BATCH_BUFFER_END", 1); return GL_FALSE; case 0x22: return debug(stream, "MI_LOAD_REGISTER_IMM", 3); case 0x31: return debug_chain(stream, "MI_BATCH_BUFFER_START", 2); default: break; } break; case 0x1: break; case 0x2: switch ((cmd >> 22) & 0xff) { case 0x50: return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2); case 0x53: return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2); default: return debug(stream, "blit command", (cmd & 0xff) + 2); } break; case 0x3: switch ((cmd >> 24) & 0x1f) { case 0x6: return debug(stream, "3DSTATE_ANTI_ALIASING", 1); case 0x7: return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1); case 0x8: return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 2); case 0x9: return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1); case 0xb: return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1); case 0xc: return debug(stream, "3DSTATE_MODES5", 1); case 0xd: return debug_modes4(stream, "3DSTATE_MODES4", 1); case 0x15: return debug(stream, "3DSTATE_FOG_COLOR", 1); case 0x16: return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1); case 0x1c: /* 3DState16NP */ switch((cmd >> 19) & 0x1f) { case 0x10: return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1); case 0x11: return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1); default: break; } break; case 0x1d: /* 3DStateMW */ switch ((cmd >> 16) & 0xff) { case 0x0: return debug_map_state(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2); case 0x1: return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2); case 0x4: return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2); case 0x5: return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd & 0x1ff) + 2); case 0x6: return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd & 0xff) + 2); case 0x7: return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT", (cmd & 0xff) + 2); case 0x80: return debug(stream, "3DSTATE_DRAWING_RECTANGLE", (cmd & 0xffff) + 2); case 0x81: return debug(stream, "3DSTATE_SCISSOR_RECTANGLE", (cmd & 0xffff) + 2); case 0x83: return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2); case 0x85: return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2); case 0x88: return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2); case 0x89: return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2); case 0x8e: return debug_buf_info(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2); case 0x97: return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2); case 0x98: return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2); case 0x99: return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2); case 0x9a: return debug(stream, "3DSTATE_DEFAULT_SPECULAR", (cmd & 0xffff) + 2); case 0x9c: return debug(stream, "3DSTATE_CLEAR_PARAMETERS", (cmd & 0xffff) + 2); default: assert(0); return 0; } break; case 0x1e: if (cmd & (1 << 23)) return debug(stream, "???", (cmd & 0xffff) + 1); else return debug(stream, "", 1); break; case 0x1f: if ((cmd & (1 << 23)) == 0) return debug_prim(stream, "3DPRIM (inline)", 1, (cmd & 0x1ffff) + 2); else if (cmd & (1 << 17)) { if ((cmd & 0xffff) == 0) return debug_variable_length_prim(stream); else return debug_prim(stream, "3DPRIM (indexed)", 0, (((cmd & 0xffff) + 1) / 2) + 1); } else return debug_prim(stream, "3DPRIM (indirect sequential)", 0, 2); break; default: return debug(stream, "", 0); } default: assert(0); return 0; } assert(0); return 0;}voidi915_dump_batchbuffer( GLuint *start, GLuint *end ){ struct debug_stream stream; GLuint bytes = (end - start) * 4; GLboolean done = GL_FALSE; PRINTF("\n\nBATCH: (%d)\n", bytes / 4); stream.offset = 0; stream.ptr = (char *)start; stream.print_addresses = 0; while (!done && stream.offset < bytes && stream.offset >= 0) { if (!i915_debug_packet( &stream )) break; assert(stream.offset <= bytes && stream.offset >= 0); } PRINTF("END-BATCH\n\n\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -