1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
29 #include "i915_context.h"
30 #include "i915_screen.h"
31 #include "i915_debug.h"
32 #include "i915_debug_private.h"
33 #include "i915_batch.h"
34 #include "util/u_debug.h"
38 static const struct debug_named_value debug_options
[] = {
39 {"blit", DBG_BLIT
, "Print when using the 2d blitter"},
40 {"emit", DBG_EMIT
, "State emit information"},
41 {"atoms", DBG_ATOMS
, "Print dirty state atoms"},
42 {"flush", DBG_FLUSH
, "Flushing information"},
43 {"texture", DBG_TEXTURE
, "Texture information"},
44 {"constants", DBG_CONSTANTS
, "Constant buffers"},
48 unsigned i915_debug
= 0;
49 boolean i915_tiling
= TRUE
;
51 void i915_debug_init(struct i915_screen
*screen
)
53 i915_debug
= debug_get_flags_option("I915_DEBUG", debug_options
, 0);
54 i915_tiling
= !debug_get_bool_option("I915_NO_TILING", FALSE
);
59 /***********************************************************************
65 struct debug_stream
*stream
,
71 va_start( args
, fmt
);
72 debug_vprintf( fmt
, args
);
77 static boolean
debug( struct debug_stream
*stream
, const char *name
, unsigned len
)
80 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
83 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
88 if (stream
->print_addresses
)
89 PRINTF(stream
, "%08x: ", stream
->offset
);
92 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
93 for (i
= 0; i
< len
; i
++)
94 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
97 stream
->offset
+= len
* sizeof(unsigned);
103 static const char *get_prim_name( unsigned val
)
105 switch (val
& PRIM3D_MASK
) {
106 case PRIM3D_TRILIST
: return "TRILIST"; break;
107 case PRIM3D_TRISTRIP
: return "TRISTRIP"; break;
108 case PRIM3D_TRISTRIP_RVRSE
: return "TRISTRIP_RVRSE"; break;
109 case PRIM3D_TRIFAN
: return "TRIFAN"; break;
110 case PRIM3D_POLY
: return "POLY"; break;
111 case PRIM3D_LINELIST
: return "LINELIST"; break;
112 case PRIM3D_LINESTRIP
: return "LINESTRIP"; break;
113 case PRIM3D_RECTLIST
: return "RECTLIST"; break;
114 case PRIM3D_POINTLIST
: return "POINTLIST"; break;
115 case PRIM3D_DIB
: return "DIB"; break;
116 case PRIM3D_CLEAR_RECT
: return "CLEAR_RECT"; break;
117 case PRIM3D_ZONE_INIT
: return "ZONE_INIT"; break;
118 default: return "????"; break;
122 static boolean
debug_prim( struct debug_stream
*stream
, const char *name
,
126 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
127 const char *prim
= get_prim_name( ptr
[0] );
132 PRINTF(stream
, "%s %s (%d dwords):\n", name
, prim
, len
);
133 PRINTF(stream
, "\t0x%08x\n", ptr
[0]);
134 for (i
= 1; i
< len
; i
++) {
136 PRINTF(stream
, "\t0x%08x // %f\n", ptr
[i
], *(float *)&ptr
[i
]);
138 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
142 PRINTF(stream
, "\n");
144 stream
->offset
+= len
* sizeof(unsigned);
152 static boolean
debug_program( struct debug_stream
*stream
, const char *name
, unsigned len
)
154 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
157 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
162 if (stream
->print_addresses
)
163 PRINTF(stream
, "%08x: ", stream
->offset
);
165 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
166 i915_disassemble_program( stream
, ptr
, len
);
168 stream
->offset
+= len
* sizeof(unsigned);
173 static boolean
debug_chain( struct debug_stream
*stream
, const char *name
, unsigned len
)
175 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
176 unsigned old_offset
= stream
->offset
+ len
* sizeof(unsigned);
179 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
180 for (i
= 0; i
< len
; i
++)
181 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
183 stream
->offset
= ptr
[1] & ~0x3;
185 if (stream
->offset
< old_offset
)
186 PRINTF(stream
, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
187 old_offset
, stream
->offset
);
189 PRINTF(stream
, "\n... skipping from 0x%x --> 0x%x ...\n\n",
190 old_offset
, stream
->offset
);
197 static boolean
debug_variable_length_prim( struct debug_stream
*stream
)
199 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
200 const char *prim
= get_prim_name( ptr
[0] );
203 ushort
*idx
= (ushort
*)(ptr
+1);
204 for (i
= 0; idx
[i
] != 0xffff; i
++)
209 PRINTF(stream
, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim
, i
, len
);
210 for (i
= 0; i
< len
; i
++)
211 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
212 PRINTF(stream
, "\n");
214 stream
->offset
+= len
* sizeof(unsigned);
221 struct debug_stream
*stream
,
229 unsigned himask
= ~0UL >> (31 - (hi
));
231 PRINTF(stream
, "\t\t ");
233 va_start( args
, fmt
);
234 debug_vprintf( fmt
, args
);
237 PRINTF(stream
, ": 0x%x\n", ((dw
) & himask
) >> (lo
));
241 #define MBZ( dw, hi, lo) do { \
242 unsigned x = (dw) >> (lo); \
243 unsigned lomask = (1 << (lo)) - 1; \
245 himask = (1UL << (hi)) - 1; \
246 assert ((x & himask & ~lomask) == 0); \
249 #define MBZ( dw, hi, lo) do { \
255 struct debug_stream
*stream
,
261 if (((dw
) >> (bit
)) & 1) {
264 PRINTF(stream
, "\t\t ");
266 va_start( args
, fmt
);
267 debug_vprintf( fmt
, args
);
270 PRINTF(stream
, "\n");
274 static boolean
debug_load_immediate( struct debug_stream
*stream
,
278 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
279 unsigned bits
= (ptr
[0] >> 4) & 0xff;
282 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
283 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
286 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
287 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
288 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
292 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
293 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
294 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
295 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
300 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
301 for (i
= 0; i
< 8; i
++) {
302 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
304 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
309 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
313 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
314 BITS(stream
, ptr
[j
], 31, 23, "point width");
315 BITS(stream
, ptr
[j
], 22, 19, "line width");
316 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
317 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
318 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
319 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
320 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
321 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
322 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
323 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
324 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
325 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
326 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
327 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
328 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
329 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
330 FLAG(stream
, ptr
[j
], 1, "sprite point");
331 FLAG(stream
, ptr
[j
], 0, "antialiasing");
335 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
336 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
337 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
338 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
339 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
340 FLAG(stream
, ptr
[j
], 24, "fog enable");
341 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
342 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
343 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
344 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
345 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
346 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
347 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
348 FLAG(stream
, ptr
[j
], 1, "color dither enable");
349 FLAG(stream
, ptr
[j
], 0, "logiop enable");
353 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
354 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
355 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
356 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
357 FLAG(stream
, ptr
[j
], 19, "depth test enable");
358 BITS(stream
, ptr
[j
], 18, 16, "depth func");
359 FLAG(stream
, ptr
[j
], 15, "blend enable");
360 BITS(stream
, ptr
[j
], 14, 12, "blend func");
361 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
362 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
363 FLAG(stream
, ptr
[j
], 3, "depth write enable");
364 FLAG(stream
, ptr
[j
], 2, "color write enable");
365 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
370 PRINTF(stream
, "\n");
374 stream
->offset
+= len
* sizeof(unsigned);
381 static boolean
debug_load_indirect( struct debug_stream
*stream
,
385 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
386 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
389 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
390 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
392 for (i
= 0; i
< 6; i
++) {
395 case LI0_STATE_STATIC_INDIRECT
:
396 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
397 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
399 case LI0_STATE_DYNAMIC_INDIRECT
:
400 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
402 case LI0_STATE_SAMPLER
:
403 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
404 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
407 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
408 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
410 case LI0_STATE_PROGRAM
:
411 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
412 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
414 case LI0_STATE_CONSTANTS
:
415 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
416 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
426 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
429 PRINTF(stream
, "\n");
434 stream
->offset
+= len
* sizeof(unsigned);
439 static void BR13( struct debug_stream
*stream
,
442 PRINTF(stream
, "\t0x%08x\n", val
);
443 FLAG(stream
, val
, 30, "clipping enable");
444 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
445 BITS(stream
, val
, 23, 16, "raster op");
446 BITS(stream
, val
, 15, 0, "dest pitch");
450 static void BR22( struct debug_stream
*stream
,
453 PRINTF(stream
, "\t0x%08x\n", val
);
454 BITS(stream
, val
, 31, 16, "dest y1");
455 BITS(stream
, val
, 15, 0, "dest x1");
458 static void BR23( struct debug_stream
*stream
,
461 PRINTF(stream
, "\t0x%08x\n", val
);
462 BITS(stream
, val
, 31, 16, "dest y2");
463 BITS(stream
, val
, 15, 0, "dest x2");
466 static void BR09( struct debug_stream
*stream
,
469 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
472 static void BR26( struct debug_stream
*stream
,
475 PRINTF(stream
, "\t0x%08x\n", val
);
476 BITS(stream
, val
, 31, 16, "src y1");
477 BITS(stream
, val
, 15, 0, "src x1");
480 static void BR11( struct debug_stream
*stream
,
483 PRINTF(stream
, "\t0x%08x\n", val
);
484 BITS(stream
, val
, 15, 0, "src pitch");
487 static void BR12( struct debug_stream
*stream
,
490 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
493 static void BR16( struct debug_stream
*stream
,
496 PRINTF(stream
, "\t0x%08x -- color\n", val
);
499 static boolean
debug_copy_blit( struct debug_stream
*stream
,
503 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
506 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
507 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
509 BR13(stream
, ptr
[j
++]);
510 BR22(stream
, ptr
[j
++]);
511 BR23(stream
, ptr
[j
++]);
512 BR09(stream
, ptr
[j
++]);
513 BR26(stream
, ptr
[j
++]);
514 BR11(stream
, ptr
[j
++]);
515 BR12(stream
, ptr
[j
++]);
517 stream
->offset
+= len
* sizeof(unsigned);
522 static boolean
debug_color_blit( struct debug_stream
*stream
,
526 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
529 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
530 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
532 BR13(stream
, ptr
[j
++]);
533 BR22(stream
, ptr
[j
++]);
534 BR23(stream
, ptr
[j
++]);
535 BR09(stream
, ptr
[j
++]);
536 BR16(stream
, ptr
[j
++]);
538 stream
->offset
+= len
* sizeof(unsigned);
543 static boolean
debug_modes4( struct debug_stream
*stream
,
547 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
550 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
551 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
552 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
553 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
554 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
555 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
556 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
559 stream
->offset
+= len
* sizeof(unsigned);
564 static boolean
debug_map_state( struct debug_stream
*stream
,
568 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
571 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
572 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
575 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
576 BITS(stream
, ptr
[j
], 15, 0, "map mask");
582 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
583 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
584 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
585 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
590 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
591 BITS(stream
, ptr
[j
], 31, 21, "height");
592 BITS(stream
, ptr
[j
], 20, 10, "width");
593 BITS(stream
, ptr
[j
], 9, 7, "surface format");
594 BITS(stream
, ptr
[j
], 6, 3, "texel format");
595 FLAG(stream
, ptr
[j
], 2, "use fence regs");
596 FLAG(stream
, ptr
[j
], 1, "tiled surface");
597 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
601 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
602 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
603 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
604 BITS(stream
, ptr
[j
], 14, 9, "max lod");
605 FLAG(stream
, ptr
[j
], 8, "mip layout right");
606 BITS(stream
, ptr
[j
], 7, 0, "depth");
611 stream
->offset
+= len
* sizeof(unsigned);
616 static boolean
debug_sampler_state( struct debug_stream
*stream
,
620 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
623 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
624 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
627 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
628 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
634 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
635 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
636 FLAG(stream
, ptr
[j
], 30, "planar to packed");
637 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
638 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
639 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
640 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
641 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
642 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
643 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
644 FLAG(stream
, ptr
[j
], 4, "shadow enable");
645 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
646 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
651 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
652 BITS(stream
, ptr
[j
], 31, 24, "min lod");
653 MBZ( ptr
[j
], 23, 18 );
654 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
655 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
656 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
657 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
658 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
659 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
660 FLAG(stream
, ptr
[j
], 5, "normalized coords");
661 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
662 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
666 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
671 stream
->offset
+= len
* sizeof(unsigned);
676 static boolean
debug_dest_vars( struct debug_stream
*stream
,
680 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
683 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
684 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
687 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
688 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
689 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
690 FLAG(stream
, ptr
[j
], 29, "bypass iz");
691 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
692 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
693 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
694 FLAG(stream
, ptr
[j
], 24, "debug dither");
695 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
696 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
697 MBZ (ptr
[j
], 15, 15 );
698 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
699 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
700 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
701 FLAG(stream
, ptr
[j
], 1, "vert line stride");
702 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
706 stream
->offset
+= len
* sizeof(unsigned);
711 static boolean
debug_buf_info( struct debug_stream
*stream
,
715 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
718 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
719 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
722 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
723 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
724 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
725 FLAG(stream
, ptr
[j
], 23, "use fence regs");
726 FLAG(stream
, ptr
[j
], 22, "tiled surface");
727 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
728 MBZ (ptr
[j
], 20, 14);
729 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
734 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
736 stream
->offset
+= len
* sizeof(unsigned);
741 static boolean
i915_debug_packet( struct debug_stream
*stream
)
743 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
746 switch (((cmd
>> 29) & 0x7)) {
748 switch ((cmd
>> 23) & 0x3f) {
750 return debug(stream
, "MI_NOOP", 1);
752 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
754 return debug(stream
, "MI_FLUSH", 1);
756 debug(stream
, "MI_BATCH_BUFFER_END", 1);
759 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
761 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
763 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
769 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
773 switch ((cmd
>> 22) & 0xff) {
775 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
777 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
779 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
783 switch ((cmd
>> 24) & 0x1f) {
785 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
787 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
789 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
791 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
793 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
795 return debug(stream
, "3DSTATE_MODES5", 1);
797 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
799 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
801 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
804 switch((cmd
>> 19) & 0x1f) {
806 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
808 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
810 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
817 switch ((cmd
>> 16) & 0xff) {
819 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
821 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
823 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
825 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
827 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
829 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
831 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
833 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
835 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
837 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
839 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
841 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
843 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
845 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
847 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
849 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
851 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
853 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
861 return debug(stream
, "???", (cmd
& 0xffff) + 1);
863 return debug(stream
, "", 1);
866 if ((cmd
& (1 << 23)) == 0)
867 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
868 else if (cmd
& (1 << 17))
870 if ((cmd
& 0xffff) == 0)
871 return debug_variable_length_prim(stream
);
873 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
876 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
879 return debug(stream
, "", 0);
894 i915_dump_batchbuffer( struct i915_winsys_batchbuffer
*batch
)
896 struct debug_stream stream
;
897 unsigned *start
= (unsigned*)batch
->map
;
898 unsigned *end
= (unsigned*)batch
->ptr
;
899 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
900 boolean done
= FALSE
;
903 stream
.ptr
= (char *)start
;
904 stream
.print_addresses
= 0;
906 if (!start
|| !end
) {
907 debug_printf( "\n\nBATCH: ???\n");
911 debug_printf( "\n\nBATCH: (%d)\n", (int)bytes
/ 4);
914 stream
.offset
< bytes
)
916 if (!i915_debug_packet( &stream
))
919 assert(stream
.offset
<= bytes
&&
923 debug_printf( "END-BATCH\n\n\n");
928 /***********************************************************************
929 * Dirty state atom dumping
933 i915_dump_dirty(struct i915_context
*i915
, const char *func
)
939 {I915_NEW_VIEWPORT
, "viewport"},
940 {I915_NEW_RASTERIZER
, "rasterizer"},
942 {I915_NEW_BLEND
, "blend"},
943 {I915_NEW_CLIP
, "clip"},
944 {I915_NEW_SCISSOR
, "scissor"},
945 {I915_NEW_STIPPLE
, "stipple"},
946 {I915_NEW_FRAMEBUFFER
, "framebuffer"},
947 {I915_NEW_ALPHA_TEST
, "alpha_test"},
948 {I915_NEW_DEPTH_STENCIL
, "depth_stencil"},
949 {I915_NEW_SAMPLER
, "sampler"},
950 {I915_NEW_SAMPLER_VIEW
, "sampler_view"},
951 {I915_NEW_VS_CONSTANTS
, "vs_const"},
952 {I915_NEW_FS_CONSTANTS
, "fs_const"},
953 {I915_NEW_VBO
, "vbo"},
959 debug_printf("%s: ", func
);
960 for (i
= 0; l
[i
].name
; i
++)
961 if (i915
->dirty
& l
[i
].dirty
)
962 debug_printf("%s ", l
[i
].name
);
967 i915_dump_hardware_dirty(struct i915_context
*i915
, const char *func
)
973 {I915_HW_STATIC
, "static"},
974 {I915_HW_DYNAMIC
, "dynamic"},
975 {I915_HW_SAMPLER
, "sampler"},
976 {I915_HW_MAP
, "map"},
977 {I915_HW_PROGRAM
, "program"},
978 {I915_HW_CONSTANTS
, "constants"},
979 {I915_HW_IMMEDIATE
, "immediate"},
980 {I915_HW_INVARIANT
, "invariant"},
985 debug_printf("%s: ", func
);
986 for (i
= 0; l
[i
].name
; i
++)
987 if (i915
->hardware_dirty
& l
[i
].dirty
)
988 debug_printf("%s ", l
[i
].name
);