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;
50 DEBUG_GET_ONCE_FLAGS_OPTION(i915_debug
, "I915_DEBUG", debug_options
, 0)
51 DEBUG_GET_ONCE_BOOL_OPTION(i915_no_tiling
, "I915_NO_TILING", FALSE
)
52 DEBUG_GET_ONCE_BOOL_OPTION(i915_lie
, "I915_LIE", FALSE
)
53 DEBUG_GET_ONCE_BOOL_OPTION(i915_use_blitter
, "I915_USE_BLITTER", FALSE
)
55 void i915_debug_init(struct i915_screen
*is
)
57 i915_debug
= debug_get_option_i915_debug();
58 is
->debug
.tiling
= !debug_get_option_i915_no_tiling();
59 is
->debug
.lie
= debug_get_option_i915_lie();
60 is
->debug
.use_blitter
= debug_get_option_i915_use_blitter();
65 /***********************************************************************
71 struct debug_stream
*stream
,
77 va_start( args
, fmt
);
78 debug_vprintf( fmt
, args
);
83 static boolean
debug( struct debug_stream
*stream
, const char *name
, unsigned len
)
86 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
89 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
94 if (stream
->print_addresses
)
95 PRINTF(stream
, "%08x: ", stream
->offset
);
98 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
99 for (i
= 0; i
< len
; i
++)
100 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
101 PRINTF(stream
, "\n");
103 stream
->offset
+= len
* sizeof(unsigned);
109 static const char *get_prim_name( unsigned val
)
111 switch (val
& PRIM3D_MASK
) {
112 case PRIM3D_TRILIST
: return "TRILIST"; break;
113 case PRIM3D_TRISTRIP
: return "TRISTRIP"; break;
114 case PRIM3D_TRISTRIP_RVRSE
: return "TRISTRIP_RVRSE"; break;
115 case PRIM3D_TRIFAN
: return "TRIFAN"; break;
116 case PRIM3D_POLY
: return "POLY"; break;
117 case PRIM3D_LINELIST
: return "LINELIST"; break;
118 case PRIM3D_LINESTRIP
: return "LINESTRIP"; break;
119 case PRIM3D_RECTLIST
: return "RECTLIST"; break;
120 case PRIM3D_POINTLIST
: return "POINTLIST"; break;
121 case PRIM3D_DIB
: return "DIB"; break;
122 case PRIM3D_CLEAR_RECT
: return "CLEAR_RECT"; break;
123 case PRIM3D_ZONE_INIT
: return "ZONE_INIT"; break;
124 default: return "????"; break;
128 static boolean
debug_prim( struct debug_stream
*stream
, const char *name
,
132 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
133 const char *prim
= get_prim_name( ptr
[0] );
138 PRINTF(stream
, "%s %s (%d dwords):\n", name
, prim
, len
);
139 PRINTF(stream
, "\t0x%08x\n", ptr
[0]);
140 for (i
= 1; i
< len
; i
++) {
142 PRINTF(stream
, "\t0x%08x // %f\n", ptr
[i
], *(float *)&ptr
[i
]);
144 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
148 PRINTF(stream
, "\n");
150 stream
->offset
+= len
* sizeof(unsigned);
158 static boolean
debug_program( struct debug_stream
*stream
, const char *name
, unsigned len
)
160 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
163 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
168 if (stream
->print_addresses
)
169 PRINTF(stream
, "%08x: ", stream
->offset
);
171 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
172 i915_disassemble_program( stream
, ptr
, len
);
174 stream
->offset
+= len
* sizeof(unsigned);
179 static boolean
debug_chain( struct debug_stream
*stream
, const char *name
, unsigned len
)
181 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
182 unsigned old_offset
= stream
->offset
+ len
* sizeof(unsigned);
185 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
186 for (i
= 0; i
< len
; i
++)
187 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
189 stream
->offset
= ptr
[1] & ~0x3;
191 if (stream
->offset
< old_offset
)
192 PRINTF(stream
, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
193 old_offset
, stream
->offset
);
195 PRINTF(stream
, "\n... skipping from 0x%x --> 0x%x ...\n\n",
196 old_offset
, stream
->offset
);
203 static boolean
debug_variable_length_prim( struct debug_stream
*stream
)
205 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
206 const char *prim
= get_prim_name( ptr
[0] );
209 ushort
*idx
= (ushort
*)(ptr
+1);
210 for (i
= 0; idx
[i
] != 0xffff; i
++)
215 PRINTF(stream
, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim
, i
, len
);
216 for (i
= 0; i
< len
; i
++)
217 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
218 PRINTF(stream
, "\n");
220 stream
->offset
+= len
* sizeof(unsigned);
227 struct debug_stream
*stream
,
235 unsigned himask
= ~0UL >> (31 - (hi
));
237 PRINTF(stream
, "\t\t ");
239 va_start( args
, fmt
);
240 debug_vprintf( fmt
, args
);
243 PRINTF(stream
, ": 0x%x\n", ((dw
) & himask
) >> (lo
));
247 #define MBZ( dw, hi, lo) do { \
248 unsigned x = (dw) >> (lo); \
249 unsigned lomask = (1 << (lo)) - 1; \
251 himask = (1UL << (hi)) - 1; \
252 assert ((x & himask & ~lomask) == 0); \
255 #define MBZ( dw, hi, lo) do { \
261 struct debug_stream
*stream
,
267 if (((dw
) >> (bit
)) & 1) {
270 PRINTF(stream
, "\t\t ");
272 va_start( args
, fmt
);
273 debug_vprintf( fmt
, args
);
276 PRINTF(stream
, "\n");
280 static boolean
debug_load_immediate( struct debug_stream
*stream
,
284 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
285 unsigned bits
= (ptr
[0] >> 4) & 0xff;
288 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
289 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
292 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
293 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
294 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
298 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
299 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
300 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
301 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
306 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
307 for (i
= 0; i
< 8; i
++) {
308 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
310 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
315 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
319 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
320 BITS(stream
, ptr
[j
], 31, 23, "point width");
321 BITS(stream
, ptr
[j
], 22, 19, "line width");
322 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
323 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
324 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
325 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
326 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
327 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
328 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
329 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
330 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
331 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
332 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
333 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
334 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
335 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
336 FLAG(stream
, ptr
[j
], 1, "sprite point");
337 FLAG(stream
, ptr
[j
], 0, "antialiasing");
341 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
342 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
343 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
344 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
345 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
346 FLAG(stream
, ptr
[j
], 24, "fog enable");
347 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
348 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
349 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
350 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
351 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
352 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
353 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
354 FLAG(stream
, ptr
[j
], 1, "color dither enable");
355 FLAG(stream
, ptr
[j
], 0, "logiop enable");
359 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
360 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
361 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
362 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
363 FLAG(stream
, ptr
[j
], 19, "depth test enable");
364 BITS(stream
, ptr
[j
], 18, 16, "depth func");
365 FLAG(stream
, ptr
[j
], 15, "blend enable");
366 BITS(stream
, ptr
[j
], 14, 12, "blend func");
367 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
368 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
369 FLAG(stream
, ptr
[j
], 3, "depth write enable");
370 FLAG(stream
, ptr
[j
], 2, "color write enable");
371 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
376 PRINTF(stream
, "\n");
380 stream
->offset
+= len
* sizeof(unsigned);
387 static boolean
debug_load_indirect( struct debug_stream
*stream
,
391 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
392 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
395 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
396 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
398 for (i
= 0; i
< 6; i
++) {
401 case LI0_STATE_STATIC_INDIRECT
:
402 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
403 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
405 case LI0_STATE_DYNAMIC_INDIRECT
:
406 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
408 case LI0_STATE_SAMPLER
:
409 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
410 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
413 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
414 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
416 case LI0_STATE_PROGRAM
:
417 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
418 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
420 case LI0_STATE_CONSTANTS
:
421 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
422 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
432 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
435 PRINTF(stream
, "\n");
440 stream
->offset
+= len
* sizeof(unsigned);
445 static void BR13( struct debug_stream
*stream
,
448 PRINTF(stream
, "\t0x%08x\n", val
);
449 FLAG(stream
, val
, 30, "clipping enable");
450 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
451 BITS(stream
, val
, 23, 16, "raster op");
452 BITS(stream
, val
, 15, 0, "dest pitch");
456 static void BR22( struct debug_stream
*stream
,
459 PRINTF(stream
, "\t0x%08x\n", val
);
460 BITS(stream
, val
, 31, 16, "dest y1");
461 BITS(stream
, val
, 15, 0, "dest x1");
464 static void BR23( struct debug_stream
*stream
,
467 PRINTF(stream
, "\t0x%08x\n", val
);
468 BITS(stream
, val
, 31, 16, "dest y2");
469 BITS(stream
, val
, 15, 0, "dest x2");
472 static void BR09( struct debug_stream
*stream
,
475 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
478 static void BR26( struct debug_stream
*stream
,
481 PRINTF(stream
, "\t0x%08x\n", val
);
482 BITS(stream
, val
, 31, 16, "src y1");
483 BITS(stream
, val
, 15, 0, "src x1");
486 static void BR11( struct debug_stream
*stream
,
489 PRINTF(stream
, "\t0x%08x\n", val
);
490 BITS(stream
, val
, 15, 0, "src pitch");
493 static void BR12( struct debug_stream
*stream
,
496 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
499 static void BR16( struct debug_stream
*stream
,
502 PRINTF(stream
, "\t0x%08x -- color\n", val
);
505 static boolean
debug_copy_blit( struct debug_stream
*stream
,
509 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
512 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
513 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
515 BR13(stream
, ptr
[j
++]);
516 BR22(stream
, ptr
[j
++]);
517 BR23(stream
, ptr
[j
++]);
518 BR09(stream
, ptr
[j
++]);
519 BR26(stream
, ptr
[j
++]);
520 BR11(stream
, ptr
[j
++]);
521 BR12(stream
, ptr
[j
++]);
523 stream
->offset
+= len
* sizeof(unsigned);
528 static boolean
debug_color_blit( struct debug_stream
*stream
,
532 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
535 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
536 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
538 BR13(stream
, ptr
[j
++]);
539 BR22(stream
, ptr
[j
++]);
540 BR23(stream
, ptr
[j
++]);
541 BR09(stream
, ptr
[j
++]);
542 BR16(stream
, ptr
[j
++]);
544 stream
->offset
+= len
* sizeof(unsigned);
549 static boolean
debug_modes4( struct debug_stream
*stream
,
553 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
556 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
557 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
558 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
559 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
560 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
561 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
562 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
565 stream
->offset
+= len
* sizeof(unsigned);
570 static boolean
debug_map_state( struct debug_stream
*stream
,
574 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
577 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
578 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
581 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
582 BITS(stream
, ptr
[j
], 15, 0, "map mask");
588 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
589 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
590 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
591 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
596 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
597 BITS(stream
, ptr
[j
], 31, 21, "height");
598 BITS(stream
, ptr
[j
], 20, 10, "width");
599 BITS(stream
, ptr
[j
], 9, 7, "surface format");
600 BITS(stream
, ptr
[j
], 6, 3, "texel format");
601 FLAG(stream
, ptr
[j
], 2, "use fence regs");
602 FLAG(stream
, ptr
[j
], 1, "tiled surface");
603 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
607 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
608 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
609 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
610 BITS(stream
, ptr
[j
], 14, 9, "max lod");
611 FLAG(stream
, ptr
[j
], 8, "mip layout right");
612 BITS(stream
, ptr
[j
], 7, 0, "depth");
617 stream
->offset
+= len
* sizeof(unsigned);
622 static boolean
debug_sampler_state( struct debug_stream
*stream
,
626 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
629 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
630 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
633 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
634 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
640 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
641 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
642 FLAG(stream
, ptr
[j
], 30, "planar to packed");
643 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
644 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
645 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
646 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
647 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
648 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
649 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
650 FLAG(stream
, ptr
[j
], 4, "shadow enable");
651 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
652 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
657 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
658 BITS(stream
, ptr
[j
], 31, 24, "min lod");
659 MBZ( ptr
[j
], 23, 18 );
660 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
661 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
662 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
663 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
664 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
665 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
666 FLAG(stream
, ptr
[j
], 5, "normalized coords");
667 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
668 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
672 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
677 stream
->offset
+= len
* sizeof(unsigned);
682 static boolean
debug_dest_vars( struct debug_stream
*stream
,
686 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
689 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
690 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
693 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
694 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
695 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
696 FLAG(stream
, ptr
[j
], 29, "bypass iz");
697 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
698 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
699 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
700 FLAG(stream
, ptr
[j
], 24, "debug dither");
701 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
702 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
703 MBZ (ptr
[j
], 15, 15 );
704 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
705 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
706 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
707 FLAG(stream
, ptr
[j
], 1, "vert line stride");
708 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
712 stream
->offset
+= len
* sizeof(unsigned);
717 static boolean
debug_buf_info( struct debug_stream
*stream
,
721 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
724 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
725 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
728 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
729 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
730 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
731 FLAG(stream
, ptr
[j
], 23, "use fence regs");
732 FLAG(stream
, ptr
[j
], 22, "tiled surface");
733 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
734 MBZ (ptr
[j
], 20, 14);
735 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
740 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
742 stream
->offset
+= len
* sizeof(unsigned);
747 static boolean
i915_debug_packet( struct debug_stream
*stream
)
749 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
752 switch (((cmd
>> 29) & 0x7)) {
754 switch ((cmd
>> 23) & 0x3f) {
756 return debug(stream
, "MI_NOOP", 1);
758 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
760 return debug(stream
, "MI_FLUSH", 1);
762 debug(stream
, "MI_BATCH_BUFFER_END", 1);
765 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
767 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
769 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
775 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
779 switch ((cmd
>> 22) & 0xff) {
781 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
783 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
785 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
789 switch ((cmd
>> 24) & 0x1f) {
791 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
793 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
795 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
797 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
799 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
801 return debug(stream
, "3DSTATE_MODES5", 1);
803 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
805 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
807 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
810 switch((cmd
>> 19) & 0x1f) {
812 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
814 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
816 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
823 switch ((cmd
>> 16) & 0xff) {
825 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
827 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
829 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
831 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
833 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
835 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
837 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
839 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
841 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
843 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
845 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
847 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
849 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
851 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
853 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
855 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
857 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
859 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
867 return debug(stream
, "???", (cmd
& 0xffff) + 1);
869 return debug(stream
, "", 1);
872 if ((cmd
& (1 << 23)) == 0)
873 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
874 else if (cmd
& (1 << 17))
876 if ((cmd
& 0xffff) == 0)
877 return debug_variable_length_prim(stream
);
879 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
882 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
885 return debug(stream
, "", 0);
900 i915_dump_batchbuffer( struct i915_winsys_batchbuffer
*batch
)
902 struct debug_stream stream
;
903 unsigned *start
= (unsigned*)batch
->map
;
904 unsigned *end
= (unsigned*)batch
->ptr
;
905 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
906 boolean done
= FALSE
;
909 stream
.ptr
= (char *)start
;
910 stream
.print_addresses
= 0;
912 if (!start
|| !end
) {
913 debug_printf( "\n\nBATCH: ???\n");
917 debug_printf( "\n\nBATCH: (%d)\n", (int)bytes
/ 4);
920 stream
.offset
< bytes
)
922 if (!i915_debug_packet( &stream
))
925 assert(stream
.offset
<= bytes
&&
929 debug_printf( "END-BATCH\n\n\n");
934 /***********************************************************************
935 * Dirty state atom dumping
939 i915_dump_dirty(struct i915_context
*i915
, const char *func
)
945 {I915_NEW_VIEWPORT
, "viewport"},
946 {I915_NEW_RASTERIZER
, "rasterizer"},
948 {I915_NEW_BLEND
, "blend"},
949 {I915_NEW_CLIP
, "clip"},
950 {I915_NEW_SCISSOR
, "scissor"},
951 {I915_NEW_STIPPLE
, "stipple"},
952 {I915_NEW_FRAMEBUFFER
, "framebuffer"},
953 {I915_NEW_ALPHA_TEST
, "alpha_test"},
954 {I915_NEW_DEPTH_STENCIL
, "depth_stencil"},
955 {I915_NEW_SAMPLER
, "sampler"},
956 {I915_NEW_SAMPLER_VIEW
, "sampler_view"},
957 {I915_NEW_VS_CONSTANTS
, "vs_const"},
958 {I915_NEW_FS_CONSTANTS
, "fs_const"},
959 {I915_NEW_VBO
, "vbo"},
965 debug_printf("%s: ", func
);
966 for (i
= 0; l
[i
].name
; i
++)
967 if (i915
->dirty
& l
[i
].dirty
)
968 debug_printf("%s ", l
[i
].name
);
973 i915_dump_hardware_dirty(struct i915_context
*i915
, const char *func
)
979 {I915_HW_STATIC
, "static"},
980 {I915_HW_DYNAMIC
, "dynamic"},
981 {I915_HW_SAMPLER
, "sampler"},
982 {I915_HW_MAP
, "map"},
983 {I915_HW_PROGRAM
, "program"},
984 {I915_HW_CONSTANTS
, "constants"},
985 {I915_HW_IMMEDIATE
, "immediate"},
986 {I915_HW_INVARIANT
, "invariant"},
991 debug_printf("%s: ", func
);
992 for (i
= 0; l
[i
].name
; i
++)
993 if (i915
->hardware_dirty
& l
[i
].dirty
)
994 debug_printf("%s ", l
[i
].name
);