📄 i915_debug.c
字号:
/************************************************************************** * * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **************************************************************************/#include "imports.h"#include "i915_reg.h"#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 ){ GLuint i; GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); assert(0); return GL_FALSE; } if (stream->print_addresses) PRINTF("%08x: ", stream->offset); PRINTF("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) PRINTF("\t0x%08x\n", ptr[i]); PRINTF("\n"); stream->offset += len * sizeof(GLuint); return GL_TRUE;}static const char *get_prim_name( GLuint val ){ switch (val & PRIM3D_MASK) { case PRIM3D_TRILIST: return "TRILIST"; break; case PRIM3D_TRISTRIP: return "TRISTRIP"; break; case PRIM3D_TRISTRIP_RVRSE: return "TRISTRIP_RVRSE"; break; case PRIM3D_TRIFAN: return "TRIFAN"; break; case PRIM3D_POLY: return "POLY"; break; case PRIM3D_LINELIST: return "LINELIST"; break; case PRIM3D_LINESTRIP: return "LINESTRIP"; break; case PRIM3D_RECTLIST: return "RECTLIST"; break; case PRIM3D_POINTLIST: return "POINTLIST"; break; case PRIM3D_DIB: return "DIB"; break; case PRIM3D_CLEAR_RECT: return "CLEAR_RECT"; break; case PRIM3D_ZONE_INIT: return "ZONE_INIT"; break; default: return "????"; break; }}static GLboolean debug_prim( struct debug_stream *stream, const char *name, GLboolean dump_floats, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); const char *prim = get_prim_name( ptr[0] ); GLuint i; PRINTF("%s %s (%d dwords):\n", name, prim, len); PRINTF("\t0x%08x\n", ptr[0]); for (i = 1; i < len; i++) { if (dump_floats) PRINTF("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); else PRINTF("\t0x%08x\n", ptr[i]); } PRINTF("\n"); stream->offset += len * sizeof(GLuint); return GL_TRUE;} static GLboolean debug_program( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); if (len == 0) { PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); assert(0); return GL_FALSE; } if (stream->print_addresses) PRINTF("%08x: ", stream->offset); PRINTF("%s (%d dwords):\n", name, len); i915_disassemble_program( ptr, len ); stream->offset += len * sizeof(GLuint); return GL_TRUE;}static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); GLuint old_offset = stream->offset + len * sizeof(GLuint); GLuint i; PRINTF("%s (%d dwords):\n", name, len); for (i = 0; i < len; i++) PRINTF("\t0x%08x\n", ptr[i]); stream->offset = ptr[1] & ~0x3; if (stream->offset < old_offset) PRINTF("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); else PRINTF("\n... skipping from 0x%x --> 0x%x ...\n\n", old_offset, stream->offset ); return GL_TRUE;}static GLboolean debug_variable_length_prim( struct debug_stream *stream ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); const char *prim = get_prim_name( ptr[0] ); GLuint i, len; GLushort *idx = (GLushort *)(ptr+1); for (i = 0; idx[i] != 0xffff; i++) ; len = 1+(i+2)/2; PRINTF("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); for (i = 0; i < len; i++) PRINTF("\t0x%08x\n", ptr[i]); PRINTF("\n"); stream->offset += len * sizeof(GLuint); return GL_TRUE;}#define BITS( dw, hi, lo, ... ) \do { \ unsigned himask = 0xffffffffU >> (31 - (hi)); \ PRINTF("\t\t "); \ PRINTF(__VA_ARGS__); \ PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \} while (0)#define MBZ( dw, hi, lo) do { \ unsigned x = (dw) >> (lo); \ unsigned lomask = (1 << (lo)) - 1; \ unsigned himask; \ himask = (1UL << (hi)) - 1; \ assert ((x & himask & ~lomask) == 0); \} while (0)#define FLAG( dw, bit, ... ) \do { \ if (((dw) >> (bit)) & 1) { \ PRINTF("\t\t "); \ PRINTF(__VA_ARGS__); \ PRINTF("\n"); \ } \} while (0)static GLboolean debug_load_immediate( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); GLuint bits = (ptr[0] >> 4) & 0xff; GLuint j = 0; PRINTF("%s (%d dwords, flags: %x):\n", name, len, bits); PRINTF("\t0x%08x\n", ptr[j++]); if (bits & (1<<0)) { 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)) { 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"); j++; } if (bits & (1<<2)) { int i; PRINTF("\t LIS2: 0x%08x\n", ptr[j]); for (i = 0; i < 8; i++) { unsigned tc = (ptr[j] >> (i * 4)) & 0xf; if (tc != 0xf) BITS(tc, 3, 0, "tex coord %d", i); } j++; } if (bits & (1<<3)) { PRINTF("\t LIS3: 0x%08x\n", ptr[j]); j++; } if (bits & (1<<4)) { 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"); FLAG(ptr[j], 17, "fog flatshade"); FLAG(ptr[j], 16, "spec flatshade"); FLAG(ptr[j], 15, "rgb flatshade"); BITS(ptr[j], 14, 13, "cull mode"); FLAG(ptr[j], 12, "vfmt: point width"); FLAG(ptr[j], 11, "vfmt: specular/fog"); FLAG(ptr[j], 10, "vfmt: rgba"); FLAG(ptr[j], 9, "vfmt: depth offset"); BITS(ptr[j], 8, 6, "vfmt: position (2==xyzw)"); FLAG(ptr[j], 5, "force dflt diffuse"); FLAG(ptr[j], 4, "force dflt specular"); FLAG(ptr[j], 3, "local depth offset enable"); FLAG(ptr[j], 2, "vfmt: fp32 fog coord"); FLAG(ptr[j], 1, "sprite point"); FLAG(ptr[j], 0, "antialiasing"); j++; } if (bits & (1<<5)) { 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"); FLAG(ptr[j], 25, "global z offset enable"); FLAG(ptr[j], 24, "fog enable"); BITS(ptr[j], 23, 16, "stencil ref"); BITS(ptr[j], 15, 13, "stencil test"); BITS(ptr[j], 12, 10, "stencil fail op"); BITS(ptr[j], 9, 7, "stencil pass z fail op"); BITS(ptr[j], 6, 4, "stencil pass z pass op"); FLAG(ptr[j], 3, "stencil write enable"); FLAG(ptr[j], 2, "stencil test enable"); FLAG(ptr[j], 1, "color dither enable"); FLAG(ptr[j], 0, "logiop enable"); j++; } if (bits & (1<<6)) { 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"); FLAG(ptr[j], 19, "depth test enable"); BITS(ptr[j], 18, 16, "depth func"); FLAG(ptr[j], 15, "blend enable"); BITS(ptr[j], 14, 12, "blend func"); BITS(ptr[j], 11, 8, "blend src factor"); BITS(ptr[j], 7, 4, "blend dst factor"); FLAG(ptr[j], 3, "depth write enable"); FLAG(ptr[j], 2, "color write enable"); BITS(ptr[j], 1, 0, "provoking vertex"); j++; } PRINTF("\n"); assert(j == len); stream->offset += len * sizeof(GLuint); return GL_TRUE;} static GLboolean debug_load_indirect( struct debug_stream *stream, const char *name, GLuint len ){ GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); GLuint bits = (ptr[0] >> 8) & 0x3f; GLuint i, j = 0; PRINTF("%s (%d dwords):\n", name, len); PRINTF("\t0x%08x\n", ptr[j++]); for (i = 0; i < 6; i++) { if (bits & (1<<i)) { switch (1<<(8+i)) { case LI0_STATE_STATIC_INDIRECT: PRINTF(" STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; PRINTF(" 0x%08x\n", ptr[j++]); break; case LI0_STATE_DYNAMIC_INDIRECT: PRINTF(" DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; break; case LI0_STATE_SAMPLER: PRINTF(" SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; PRINTF(" 0x%08x\n", ptr[j++]); break; case LI0_STATE_MAP: PRINTF(" MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; PRINTF(" 0x%08x\n", ptr[j++]); break; case LI0_STATE_PROGRAM: PRINTF(" PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; PRINTF(" 0x%08x\n", ptr[j++]); break; case LI0_STATE_CONSTANTS: PRINTF(" CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; PRINTF(" 0x%08x\n", ptr[j++]); break; default: assert(0); break; } } } if (bits == 0) { PRINTF("\t DUMMY: 0x%08x\n", ptr[j++]); } PRINTF("\n"); assert(j == len); stream->offset += len * sizeof(GLuint); return GL_TRUE;} static void BR13( struct debug_stream *stream, GLuint val ){ PRINTF("\t0x%08x\n", val); FLAG(val, 30, "clipping enable"); BITS(val, 25, 24, "color depth (3==32bpp)"); BITS(val, 23, 16, "raster op"); BITS(val, 15, 0, "dest pitch");}static void BR2223( struct debug_stream *stream, GLuint val22, GLuint val23 ){ union { GLuint val; short field[2]; } BR22, BR23; BR22.val = val22; BR23.val = val23; PRINTF("\t0x%08x\n", val22); BITS(val22, 31, 16, "dest y1"); BITS(val22, 15, 0, "dest x1"); PRINTF("\t0x%08x\n", val23); BITS(val23, 31, 16, "dest y2"); BITS(val23, 15, 0, "dest x2"); /* The blit engine may produce unexpected results when these aren't met */ assert(BR22.field[0] < BR23.field[0]); assert(BR22.field[1] < BR23.field[1]);}static void BR09( struct debug_stream *stream, GLuint val ){ PRINTF("\t0x%08x -- dest address\n", val);}static void BR26( struct debug_stream *stream, GLuint val ){ PRINTF("\t0x%08x\n", val); BITS(val, 31, 16, "src y1"); BITS(val, 15, 0, "src x1");}static void BR11( struct debug_stream *stream, GLuint val ){ PRINTF("\t0x%08x\n", val); BITS(val, 15, 0, "src pitch");}static void BR12( struct debug_stream *stream, GLuint val ){ PRINTF("\t0x%08x -- src address\n", val);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -