i915_debug.c revision 8cf9085bc7b96819d2bec1e749e15af58eefb2f3
1/************************************************************************** 2 * 3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28#include "imports.h" 29 30#include "i915_reg.h" 31#include "i915_context.h" 32#include "i915_debug.h" 33 34#define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) 35 36static GLboolean debug( struct debug_stream *stream, const char *name, GLuint len ) 37{ 38 GLuint i; 39 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 40 41 if (len == 0) { 42 PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); 43 assert(0); 44 return GL_FALSE; 45 } 46 47 if (stream->print_addresses) 48 PRINTF("%08x: ", stream->offset); 49 50 51 PRINTF("%s (%d dwords):\n", name, len); 52 for (i = 0; i < len; i++) 53 PRINTF("\t0x%08x\n", ptr[i]); 54 PRINTF("\n"); 55 56 stream->offset += len * sizeof(GLuint); 57 58 return GL_TRUE; 59} 60 61 62static const char *get_prim_name( GLuint val ) 63{ 64 switch (val & PRIM3D_MASK) { 65 case PRIM3D_TRILIST: return "TRILIST"; break; 66 case PRIM3D_TRISTRIP: return "TRISTRIP"; break; 67 case PRIM3D_TRISTRIP_RVRSE: return "TRISTRIP_RVRSE"; break; 68 case PRIM3D_TRIFAN: return "TRIFAN"; break; 69 case PRIM3D_POLY: return "POLY"; break; 70 case PRIM3D_LINELIST: return "LINELIST"; break; 71 case PRIM3D_LINESTRIP: return "LINESTRIP"; break; 72 case PRIM3D_RECTLIST: return "RECTLIST"; break; 73 case PRIM3D_POINTLIST: return "POINTLIST"; break; 74 case PRIM3D_DIB: return "DIB"; break; 75 case PRIM3D_CLEAR_RECT: return "CLEAR_RECT"; break; 76 case PRIM3D_ZONE_INIT: return "ZONE_INIT"; break; 77 default: return "????"; break; 78 } 79} 80 81static GLboolean debug_prim( struct debug_stream *stream, const char *name, 82 GLboolean dump_floats, 83 GLuint len ) 84{ 85 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 86 const char *prim = get_prim_name( ptr[0] ); 87 GLuint i; 88 89 90 91 PRINTF("%s %s (%d dwords):\n", name, prim, len); 92 PRINTF("\t0x%08x\n", ptr[0]); 93 for (i = 1; i < len; i++) { 94 if (dump_floats) 95 PRINTF("\t0x%08x // %f\n", ptr[i], *(GLfloat *)&ptr[i]); 96 else 97 PRINTF("\t0x%08x\n", ptr[i]); 98 } 99 100 101 PRINTF("\n"); 102 103 stream->offset += len * sizeof(GLuint); 104 105 return GL_TRUE; 106} 107 108 109 110 111static GLboolean debug_program( struct debug_stream *stream, const char *name, GLuint len ) 112{ 113 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 114 115 if (len == 0) { 116 PRINTF("Error - zero length packet (0x%08x)\n", stream->ptr[0]); 117 assert(0); 118 return GL_FALSE; 119 } 120 121 if (stream->print_addresses) 122 PRINTF("%08x: ", stream->offset); 123 124 PRINTF("%s (%d dwords):\n", name, len); 125 i915_disassemble_program( ptr, len ); 126 127 stream->offset += len * sizeof(GLuint); 128 return GL_TRUE; 129} 130 131 132static GLboolean debug_chain( struct debug_stream *stream, const char *name, GLuint len ) 133{ 134 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 135 GLuint old_offset = stream->offset + len * sizeof(GLuint); 136 GLuint i; 137 138 PRINTF("%s (%d dwords):\n", name, len); 139 for (i = 0; i < len; i++) 140 PRINTF("\t0x%08x\n", ptr[i]); 141 142 stream->offset = ptr[1] & ~0x3; 143 144 if (stream->offset < old_offset) 145 PRINTF("\n... skipping backwards from 0x%x --> 0x%x ...\n\n", 146 old_offset, stream->offset ); 147 else 148 PRINTF("\n... skipping from 0x%x --> 0x%x ...\n\n", 149 old_offset, stream->offset ); 150 151 152 return GL_TRUE; 153} 154 155 156static GLboolean debug_variable_length_prim( struct debug_stream *stream ) 157{ 158 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 159 const char *prim = get_prim_name( ptr[0] ); 160 GLuint i, len; 161 162 GLushort *idx = (GLushort *)(ptr+1); 163 for (i = 0; idx[i] != 0xffff; i++) 164 ; 165 166 len = 1+(i+2)/2; 167 168 PRINTF("3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len); 169 for (i = 0; i < len; i++) 170 PRINTF("\t0x%08x\n", ptr[i]); 171 PRINTF("\n"); 172 173 stream->offset += len * sizeof(GLuint); 174 return GL_TRUE; 175} 176 177 178#define BITS( dw, hi, lo, ... ) \ 179do { \ 180 unsigned himask = ~0UL >> (31 - (hi)); \ 181 PRINTF("\t\t "); \ 182 PRINTF(__VA_ARGS__); \ 183 PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \ 184} while (0) 185 186#define MBZ( dw, hi, lo) do { \ 187 unsigned x = (dw) >> (lo); \ 188 unsigned lomask = (1 << (lo)) - 1; \ 189 unsigned himask; \ 190 himask = (1UL << (hi)) - 1; \ 191 assert ((x & himask & ~lomask) == 0); \ 192} while (0) 193 194#define FLAG( dw, bit, ... ) \ 195do { \ 196 if (((dw) >> (bit)) & 1) { \ 197 PRINTF("\t\t "); \ 198 PRINTF(__VA_ARGS__); \ 199 PRINTF("\n"); \ 200 } \ 201} while (0) 202 203static GLboolean debug_load_immediate( struct debug_stream *stream, 204 const char *name, 205 GLuint len ) 206{ 207 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 208 GLuint bits = (ptr[0] >> 4) & 0xff; 209 GLuint j = 0; 210 211 PRINTF("%s (%d dwords, flags: %x):\n", name, len, bits); 212 PRINTF("\t0x%08x\n", ptr[j++]); 213 214 if (bits & (1<<0)) { 215 PRINTF("\t LIS0: 0x%08x\n", ptr[j]); 216 PRINTF("\t vb address: 0x%08x\n", (ptr[j] & ~0x3)); 217 BITS(ptr[j], 0, 0, "vb invalidate disable"); 218 j++; 219 } 220 if (bits & (1<<1)) { 221 PRINTF("\t LIS1: 0x%08x\n", ptr[j]); 222 BITS(ptr[j], 29, 24, "vb dword width"); 223 BITS(ptr[j], 21, 16, "vb dword pitch"); 224 BITS(ptr[j], 15, 0, "vb max index"); 225 j++; 226 } 227 if (bits & (1<<2)) { 228 int i; 229 PRINTF("\t LIS2: 0x%08x\n", ptr[j]); 230 for (i = 0; i < 8; i++) { 231 unsigned tc = (ptr[j] >> (i * 4)) & 0xf; 232 if (tc != 0xf) 233 BITS(tc, 3, 0, "tex coord %d", i); 234 } 235 j++; 236 } 237 if (bits & (1<<3)) { 238 PRINTF("\t LIS3: 0x%08x\n", ptr[j]); 239 j++; 240 } 241 if (bits & (1<<4)) { 242 PRINTF("\t LIS4: 0x%08x\n", ptr[j]); 243 BITS(ptr[j], 31, 23, "point width"); 244 BITS(ptr[j], 22, 19, "line width"); 245 FLAG(ptr[j], 18, "alpha flatshade"); 246 FLAG(ptr[j], 17, "fog flatshade"); 247 FLAG(ptr[j], 16, "spec flatshade"); 248 FLAG(ptr[j], 15, "rgb flatshade"); 249 BITS(ptr[j], 14, 13, "cull mode"); 250 FLAG(ptr[j], 12, "vfmt: point width"); 251 FLAG(ptr[j], 11, "vfmt: specular/fog"); 252 FLAG(ptr[j], 10, "vfmt: rgba"); 253 FLAG(ptr[j], 9, "vfmt: depth offset"); 254 BITS(ptr[j], 8, 6, "vfmt: position (2==xyzw)"); 255 FLAG(ptr[j], 5, "force dflt diffuse"); 256 FLAG(ptr[j], 4, "force dflt specular"); 257 FLAG(ptr[j], 3, "local depth offset enable"); 258 FLAG(ptr[j], 2, "vfmt: fp32 fog coord"); 259 FLAG(ptr[j], 1, "sprite point"); 260 FLAG(ptr[j], 0, "antialiasing"); 261 j++; 262 } 263 if (bits & (1<<5)) { 264 PRINTF("\t LIS5: 0x%08x\n", ptr[j]); 265 BITS(ptr[j], 31, 28, "rgba write disables"); 266 FLAG(ptr[j], 27, "force dflt point width"); 267 FLAG(ptr[j], 26, "last pixel enable"); 268 FLAG(ptr[j], 25, "global z offset enable"); 269 FLAG(ptr[j], 24, "fog enable"); 270 BITS(ptr[j], 23, 16, "stencil ref"); 271 BITS(ptr[j], 15, 13, "stencil test"); 272 BITS(ptr[j], 12, 10, "stencil fail op"); 273 BITS(ptr[j], 9, 7, "stencil pass z fail op"); 274 BITS(ptr[j], 6, 4, "stencil pass z pass op"); 275 FLAG(ptr[j], 3, "stencil write enable"); 276 FLAG(ptr[j], 2, "stencil test enable"); 277 FLAG(ptr[j], 1, "color dither enable"); 278 FLAG(ptr[j], 0, "logiop enable"); 279 j++; 280 } 281 if (bits & (1<<6)) { 282 PRINTF("\t LIS6: 0x%08x\n", ptr[j]); 283 FLAG(ptr[j], 31, "alpha test enable"); 284 BITS(ptr[j], 30, 28, "alpha func"); 285 BITS(ptr[j], 27, 20, "alpha ref"); 286 FLAG(ptr[j], 19, "depth test enable"); 287 BITS(ptr[j], 18, 16, "depth func"); 288 FLAG(ptr[j], 15, "blend enable"); 289 BITS(ptr[j], 14, 12, "blend func"); 290 BITS(ptr[j], 11, 8, "blend src factor"); 291 BITS(ptr[j], 7, 4, "blend dst factor"); 292 FLAG(ptr[j], 3, "depth write enable"); 293 FLAG(ptr[j], 2, "color write enable"); 294 BITS(ptr[j], 1, 0, "provoking vertex"); 295 j++; 296 } 297 298 299 PRINTF("\n"); 300 301 assert(j == len); 302 303 stream->offset += len * sizeof(GLuint); 304 305 return GL_TRUE; 306} 307 308 309 310static GLboolean debug_load_indirect( struct debug_stream *stream, 311 const char *name, 312 GLuint len ) 313{ 314 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 315 GLuint bits = (ptr[0] >> 8) & 0x3f; 316 GLuint i, j = 0; 317 318 PRINTF("%s (%d dwords):\n", name, len); 319 PRINTF("\t0x%08x\n", ptr[j++]); 320 321 for (i = 0; i < 6; i++) { 322 if (bits & (1<<i)) { 323 switch (1<<(8+i)) { 324 case LI0_STATE_STATIC_INDIRECT: 325 PRINTF(" STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; 326 PRINTF(" 0x%08x\n", ptr[j++]); 327 break; 328 case LI0_STATE_DYNAMIC_INDIRECT: 329 PRINTF(" DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; 330 break; 331 case LI0_STATE_SAMPLER: 332 PRINTF(" SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; 333 PRINTF(" 0x%08x\n", ptr[j++]); 334 break; 335 case LI0_STATE_MAP: 336 PRINTF(" MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; 337 PRINTF(" 0x%08x\n", ptr[j++]); 338 break; 339 case LI0_STATE_PROGRAM: 340 PRINTF(" PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; 341 PRINTF(" 0x%08x\n", ptr[j++]); 342 break; 343 case LI0_STATE_CONSTANTS: 344 PRINTF(" CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++; 345 PRINTF(" 0x%08x\n", ptr[j++]); 346 break; 347 default: 348 assert(0); 349 break; 350 } 351 } 352 } 353 354 if (bits == 0) { 355 PRINTF("\t DUMMY: 0x%08x\n", ptr[j++]); 356 } 357 358 PRINTF("\n"); 359 360 361 assert(j == len); 362 363 stream->offset += len * sizeof(GLuint); 364 365 return GL_TRUE; 366} 367 368static void BR13( struct debug_stream *stream, 369 GLuint val ) 370{ 371 PRINTF("\t0x%08x\n", val); 372 FLAG(val, 30, "clipping enable"); 373 BITS(val, 25, 24, "color depth (3==32bpp)"); 374 BITS(val, 23, 16, "raster op"); 375 BITS(val, 15, 0, "dest pitch"); 376} 377 378 379static void BR22( struct debug_stream *stream, 380 GLuint val ) 381{ 382 PRINTF("\t0x%08x\n", val); 383 BITS(val, 31, 16, "dest y1"); 384 BITS(val, 15, 0, "dest x1"); 385} 386 387static void BR23( struct debug_stream *stream, 388 GLuint val ) 389{ 390 PRINTF("\t0x%08x\n", val); 391 BITS(val, 31, 16, "dest y2"); 392 BITS(val, 15, 0, "dest x2"); 393} 394 395static void BR09( struct debug_stream *stream, 396 GLuint val ) 397{ 398 PRINTF("\t0x%08x -- dest address\n", val); 399} 400 401static void BR26( struct debug_stream *stream, 402 GLuint val ) 403{ 404 PRINTF("\t0x%08x\n", val); 405 BITS(val, 31, 16, "src y1"); 406 BITS(val, 15, 0, "src x1"); 407} 408 409static void BR11( struct debug_stream *stream, 410 GLuint val ) 411{ 412 PRINTF("\t0x%08x\n", val); 413 BITS(val, 15, 0, "src pitch"); 414} 415 416static void BR12( struct debug_stream *stream, 417 GLuint val ) 418{ 419 PRINTF("\t0x%08x -- src address\n", val); 420} 421 422static void BR16( struct debug_stream *stream, 423 GLuint val ) 424{ 425 PRINTF("\t0x%08x -- color\n", val); 426} 427 428static GLboolean debug_copy_blit( struct debug_stream *stream, 429 const char *name, 430 GLuint len ) 431{ 432 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 433 int j = 0; 434 435 PRINTF("%s (%d dwords):\n", name, len); 436 PRINTF("\t0x%08x\n", ptr[j++]); 437 438 BR13(stream, ptr[j++]); 439 BR22(stream, ptr[j++]); 440 BR23(stream, ptr[j++]); 441 BR09(stream, ptr[j++]); 442 BR26(stream, ptr[j++]); 443 BR11(stream, ptr[j++]); 444 BR12(stream, ptr[j++]); 445 446 stream->offset += len * sizeof(GLuint); 447 assert(j == len); 448 return GL_TRUE; 449} 450 451static GLboolean debug_color_blit( struct debug_stream *stream, 452 const char *name, 453 GLuint len ) 454{ 455 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 456 int j = 0; 457 458 PRINTF("%s (%d dwords):\n", name, len); 459 PRINTF("\t0x%08x\n", ptr[j++]); 460 461 BR13(stream, ptr[j++]); 462 BR22(stream, ptr[j++]); 463 BR23(stream, ptr[j++]); 464 BR09(stream, ptr[j++]); 465 BR16(stream, ptr[j++]); 466 467 stream->offset += len * sizeof(GLuint); 468 assert(j == len); 469 return GL_TRUE; 470} 471 472static GLboolean debug_modes4( struct debug_stream *stream, 473 const char *name, 474 GLuint len ) 475{ 476 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 477 int j = 0; 478 479 PRINTF("%s (%d dwords):\n", name, len); 480 PRINTF("\t0x%08x\n", ptr[j]); 481 BITS(ptr[j], 21, 18, "logicop func"); 482 FLAG(ptr[j], 17, "stencil test mask modify-enable"); 483 FLAG(ptr[j], 16, "stencil write mask modify-enable"); 484 BITS(ptr[j], 15, 8, "stencil test mask"); 485 BITS(ptr[j], 7, 0, "stencil write mask"); 486 j++; 487 488 stream->offset += len * sizeof(GLuint); 489 assert(j == len); 490 return GL_TRUE; 491} 492 493static GLboolean debug_map_state( struct debug_stream *stream, 494 const char *name, 495 GLuint len ) 496{ 497 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 498 int j = 0; 499 500 PRINTF("%s (%d dwords):\n", name, len); 501 PRINTF("\t0x%08x\n", ptr[j++]); 502 503 { 504 PRINTF("\t0x%08x\n", ptr[j]); 505 BITS(ptr[j], 15, 0, "map mask"); 506 j++; 507 } 508 509 while (j < len) { 510 { 511 PRINTF("\t TMn.0: 0x%08x\n", ptr[j]); 512 PRINTF("\t map address: 0x%08x\n", (ptr[j] & ~0x3)); 513 FLAG(ptr[j], 1, "vertical line stride"); 514 FLAG(ptr[j], 0, "vertical line stride offset"); 515 j++; 516 } 517 518 { 519 PRINTF("\t TMn.1: 0x%08x\n", ptr[j]); 520 BITS(ptr[j], 31, 21, "height"); 521 BITS(ptr[j], 20, 10, "width"); 522 BITS(ptr[j], 9, 7, "surface format"); 523 BITS(ptr[j], 6, 3, "texel format"); 524 FLAG(ptr[j], 2, "use fence regs"); 525 FLAG(ptr[j], 1, "tiled surface"); 526 FLAG(ptr[j], 0, "tile walk ymajor"); 527 j++; 528 } 529 { 530 PRINTF("\t TMn.2: 0x%08x\n", ptr[j]); 531 BITS(ptr[j], 31, 21, "dword pitch"); 532 BITS(ptr[j], 20, 15, "cube face enables"); 533 BITS(ptr[j], 14, 9, "max lod"); 534 FLAG(ptr[j], 8, "mip layout right"); 535 BITS(ptr[j], 7, 0, "depth"); 536 j++; 537 } 538 } 539 540 stream->offset += len * sizeof(GLuint); 541 assert(j == len); 542 return GL_TRUE; 543} 544 545static GLboolean debug_sampler_state( struct debug_stream *stream, 546 const char *name, 547 GLuint len ) 548{ 549 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 550 int j = 0; 551 552 PRINTF("%s (%d dwords):\n", name, len); 553 PRINTF("\t0x%08x\n", ptr[j++]); 554 555 { 556 PRINTF("\t0x%08x\n", ptr[j]); 557 BITS(ptr[j], 15, 0, "sampler mask"); 558 j++; 559 } 560 561 while (j < len) { 562 { 563 PRINTF("\t TSn.0: 0x%08x\n", ptr[j]); 564 FLAG(ptr[j], 31, "reverse gamma"); 565 FLAG(ptr[j], 30, "planar to packed"); 566 FLAG(ptr[j], 29, "yuv->rgb"); 567 BITS(ptr[j], 28, 27, "chromakey index"); 568 BITS(ptr[j], 26, 22, "base mip level"); 569 BITS(ptr[j], 21, 20, "mip mode filter"); 570 BITS(ptr[j], 19, 17, "mag mode filter"); 571 BITS(ptr[j], 16, 14, "min mode filter"); 572 BITS(ptr[j], 13, 5, "lod bias (s4.4)"); 573 FLAG(ptr[j], 4, "shadow enable"); 574 FLAG(ptr[j], 3, "max-aniso-4"); 575 BITS(ptr[j], 2, 0, "shadow func"); 576 j++; 577 } 578 579 { 580 PRINTF("\t TSn.1: 0x%08x\n", ptr[j]); 581 BITS(ptr[j], 31, 24, "min lod"); 582 MBZ( ptr[j], 23, 18 ); 583 FLAG(ptr[j], 17, "kill pixel enable"); 584 FLAG(ptr[j], 16, "keyed tex filter mode"); 585 FLAG(ptr[j], 15, "chromakey enable"); 586 BITS(ptr[j], 14, 12, "tcx wrap mode"); 587 BITS(ptr[j], 11, 9, "tcy wrap mode"); 588 BITS(ptr[j], 8, 6, "tcz wrap mode"); 589 FLAG(ptr[j], 5, "normalized coords"); 590 BITS(ptr[j], 4, 1, "map (surface) index"); 591 FLAG(ptr[j], 0, "EAST deinterlacer enable"); 592 j++; 593 } 594 { 595 PRINTF("\t TSn.2: 0x%08x (default color)\n", ptr[j]); 596 j++; 597 } 598 } 599 600 stream->offset += len * sizeof(GLuint); 601 assert(j == len); 602 return GL_TRUE; 603} 604 605static GLboolean debug_dest_vars( struct debug_stream *stream, 606 const char *name, 607 GLuint len ) 608{ 609 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 610 int j = 0; 611 612 PRINTF("%s (%d dwords):\n", name, len); 613 PRINTF("\t0x%08x\n", ptr[j++]); 614 615 { 616 PRINTF("\t0x%08x\n", ptr[j]); 617 FLAG(ptr[j], 31, "early classic ztest"); 618 FLAG(ptr[j], 30, "opengl tex default color"); 619 FLAG(ptr[j], 29, "bypass iz"); 620 FLAG(ptr[j], 28, "lod preclamp"); 621 BITS(ptr[j], 27, 26, "dither pattern"); 622 FLAG(ptr[j], 25, "linear gamma blend"); 623 FLAG(ptr[j], 24, "debug dither"); 624 BITS(ptr[j], 23, 20, "dstorg x"); 625 BITS(ptr[j], 19, 16, "dstorg y"); 626 MBZ (ptr[j], 15, 15 ); 627 BITS(ptr[j], 14, 12, "422 write select"); 628 BITS(ptr[j], 11, 8, "cbuf format"); 629 BITS(ptr[j], 3, 2, "zbuf format"); 630 FLAG(ptr[j], 1, "vert line stride"); 631 FLAG(ptr[j], 1, "vert line stride offset"); 632 j++; 633 } 634 635 stream->offset += len * sizeof(GLuint); 636 assert(j == len); 637 return GL_TRUE; 638} 639 640static GLboolean debug_buf_info( struct debug_stream *stream, 641 const char *name, 642 GLuint len ) 643{ 644 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 645 int j = 0; 646 647 PRINTF("%s (%d dwords):\n", name, len); 648 PRINTF("\t0x%08x\n", ptr[j++]); 649 650 { 651 PRINTF("\t0x%08x\n", ptr[j]); 652 BITS(ptr[j], 28, 28, "aux buffer id"); 653 BITS(ptr[j], 27, 24, "buffer id (7=depth, 3=back)"); 654 FLAG(ptr[j], 23, "use fence regs"); 655 FLAG(ptr[j], 22, "tiled surface"); 656 FLAG(ptr[j], 21, "tile walk ymajor"); 657 MBZ (ptr[j], 20, 14); 658 BITS(ptr[j], 13, 2, "dword pitch"); 659 MBZ (ptr[j], 2, 0); 660 j++; 661 } 662 663 PRINTF("\t0x%08x -- buffer base address\n", ptr[j++]); 664 665 stream->offset += len * sizeof(GLuint); 666 assert(j == len); 667 return GL_TRUE; 668} 669 670static GLboolean i915_debug_packet( struct debug_stream *stream ) 671{ 672 GLuint *ptr = (GLuint *)(stream->ptr + stream->offset); 673 GLuint cmd = *ptr; 674 675 switch (((cmd >> 29) & 0x7)) { 676 case 0x0: 677 switch ((cmd >> 23) & 0x3f) { 678 case 0x0: 679 return debug(stream, "MI_NOOP", 1); 680 case 0x3: 681 return debug(stream, "MI_WAIT_FOR_EVENT", 1); 682 case 0x4: 683 return debug(stream, "MI_FLUSH", 1); 684 case 0xA: 685 debug(stream, "MI_BATCH_BUFFER_END", 1); 686 return GL_FALSE; 687 case 0x22: 688 return debug(stream, "MI_LOAD_REGISTER_IMM", 3); 689 case 0x31: 690 return debug_chain(stream, "MI_BATCH_BUFFER_START", 2); 691 default: 692 break; 693 } 694 break; 695 case 0x1: 696 break; 697 case 0x2: 698 switch ((cmd >> 22) & 0xff) { 699 case 0x50: 700 return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2); 701 case 0x53: 702 return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2); 703 default: 704 return debug(stream, "blit command", (cmd & 0xff) + 2); 705 } 706 break; 707 case 0x3: 708 switch ((cmd >> 24) & 0x1f) { 709 case 0x6: 710 return debug(stream, "3DSTATE_ANTI_ALIASING", 1); 711 case 0x7: 712 return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1); 713 case 0x8: 714 return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 2); 715 case 0x9: 716 return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1); 717 case 0xb: 718 return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1); 719 case 0xc: 720 return debug(stream, "3DSTATE_MODES5", 1); 721 case 0xd: 722 return debug_modes4(stream, "3DSTATE_MODES4", 1); 723 case 0x15: 724 return debug(stream, "3DSTATE_FOG_COLOR", 1); 725 case 0x16: 726 return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1); 727 case 0x1c: 728 /* 3DState16NP */ 729 switch((cmd >> 19) & 0x1f) { 730 case 0x10: 731 return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1); 732 case 0x11: 733 return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1); 734 default: 735 break; 736 } 737 break; 738 case 0x1d: 739 /* 3DStateMW */ 740 switch ((cmd >> 16) & 0xff) { 741 case 0x0: 742 return debug_map_state(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2); 743 case 0x1: 744 return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2); 745 case 0x4: 746 return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2); 747 case 0x5: 748 return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd & 0x1ff) + 2); 749 case 0x6: 750 return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd & 0xff) + 2); 751 case 0x7: 752 return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT", (cmd & 0xff) + 2); 753 case 0x80: 754 return debug(stream, "3DSTATE_DRAWING_RECTANGLE", (cmd & 0xffff) + 2); 755 case 0x81: 756 return debug(stream, "3DSTATE_SCISSOR_RECTANGLE", (cmd & 0xffff) + 2); 757 case 0x83: 758 return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2); 759 case 0x85: 760 return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2); 761 case 0x88: 762 return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2); 763 case 0x89: 764 return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2); 765 case 0x8e: 766 return debug_buf_info(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2); 767 case 0x97: 768 return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2); 769 case 0x98: 770 return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2); 771 case 0x99: 772 return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2); 773 case 0x9a: 774 return debug(stream, "3DSTATE_DEFAULT_SPECULAR", (cmd & 0xffff) + 2); 775 case 0x9c: 776 return debug(stream, "3DSTATE_CLEAR_PARAMETERS", (cmd & 0xffff) + 2); 777 default: 778 assert(0); 779 return 0; 780 } 781 break; 782 case 0x1e: 783 if (cmd & (1 << 23)) 784 return debug(stream, "???", (cmd & 0xffff) + 1); 785 else 786 return debug(stream, "", 1); 787 break; 788 case 0x1f: 789 if ((cmd & (1 << 23)) == 0) 790 return debug_prim(stream, "3DPRIM (inline)", 1, (cmd & 0x1ffff) + 2); 791 else if (cmd & (1 << 17)) 792 { 793 if ((cmd & 0xffff) == 0) 794 return debug_variable_length_prim(stream); 795 else 796 return debug_prim(stream, "3DPRIM (indexed)", 0, (((cmd & 0xffff) + 1) / 2) + 1); 797 } 798 else 799 return debug_prim(stream, "3DPRIM (indirect sequential)", 0, 2); 800 break; 801 default: 802 return debug(stream, "", 0); 803 } 804 default: 805 assert(0); 806 return 0; 807 } 808 809 assert(0); 810 return 0; 811} 812 813 814 815void 816i915_dump_batchbuffer( GLuint *start, 817 GLuint *end ) 818{ 819 struct debug_stream stream; 820 GLuint bytes = (end - start) * 4; 821 GLboolean done = GL_FALSE; 822 823 PRINTF("\n\nBATCH: (%d)\n", bytes / 4); 824 825 stream.offset = 0; 826 stream.ptr = (char *)start; 827 stream.print_addresses = 0; 828 829 while (!done && 830 stream.offset < bytes && 831 stream.offset >= 0) 832 { 833 if (!i915_debug_packet( &stream )) 834 break; 835 836 assert(stream.offset <= bytes && 837 stream.offset >= 0); 838 } 839 840 PRINTF("END-BATCH\n\n\n"); 841} 842 843 844