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_debug.h"
31 #include "i915_batch.h"
32 #include "util/u_debug.h"
37 struct debug_stream
*stream
,
43 va_start( args
, fmt
);
44 debug_vprintf( fmt
, args
);
49 static boolean
debug( struct debug_stream
*stream
, const char *name
, unsigned len
)
52 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
55 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
60 if (stream
->print_addresses
)
61 PRINTF(stream
, "%08x: ", stream
->offset
);
64 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
65 for (i
= 0; i
< len
; i
++)
66 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
69 stream
->offset
+= len
* sizeof(unsigned);
75 static const char *get_prim_name( unsigned val
)
77 switch (val
& PRIM3D_MASK
) {
78 case PRIM3D_TRILIST
: return "TRILIST"; break;
79 case PRIM3D_TRISTRIP
: return "TRISTRIP"; break;
80 case PRIM3D_TRISTRIP_RVRSE
: return "TRISTRIP_RVRSE"; break;
81 case PRIM3D_TRIFAN
: return "TRIFAN"; break;
82 case PRIM3D_POLY
: return "POLY"; break;
83 case PRIM3D_LINELIST
: return "LINELIST"; break;
84 case PRIM3D_LINESTRIP
: return "LINESTRIP"; break;
85 case PRIM3D_RECTLIST
: return "RECTLIST"; break;
86 case PRIM3D_POINTLIST
: return "POINTLIST"; break;
87 case PRIM3D_DIB
: return "DIB"; break;
88 case PRIM3D_CLEAR_RECT
: return "CLEAR_RECT"; break;
89 case PRIM3D_ZONE_INIT
: return "ZONE_INIT"; break;
90 default: return "????"; break;
94 static boolean
debug_prim( struct debug_stream
*stream
, const char *name
,
98 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
99 const char *prim
= get_prim_name( ptr
[0] );
104 PRINTF(stream
, "%s %s (%d dwords):\n", name
, prim
, len
);
105 PRINTF(stream
, "\t0x%08x\n", ptr
[0]);
106 for (i
= 1; i
< len
; i
++) {
108 PRINTF(stream
, "\t0x%08x // %f\n", ptr
[i
], *(float *)&ptr
[i
]);
110 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
114 PRINTF(stream
, "\n");
116 stream
->offset
+= len
* sizeof(unsigned);
124 static boolean
debug_program( struct debug_stream
*stream
, const char *name
, unsigned len
)
126 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
129 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
134 if (stream
->print_addresses
)
135 PRINTF(stream
, "%08x: ", stream
->offset
);
137 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
138 i915_disassemble_program( stream
, ptr
, len
);
140 stream
->offset
+= len
* sizeof(unsigned);
145 static boolean
debug_chain( struct debug_stream
*stream
, const char *name
, unsigned len
)
147 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
148 unsigned old_offset
= stream
->offset
+ len
* sizeof(unsigned);
151 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
152 for (i
= 0; i
< len
; i
++)
153 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
155 stream
->offset
= ptr
[1] & ~0x3;
157 if (stream
->offset
< old_offset
)
158 PRINTF(stream
, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
159 old_offset
, stream
->offset
);
161 PRINTF(stream
, "\n... skipping from 0x%x --> 0x%x ...\n\n",
162 old_offset
, stream
->offset
);
169 static boolean
debug_variable_length_prim( struct debug_stream
*stream
)
171 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
172 const char *prim
= get_prim_name( ptr
[0] );
175 ushort
*idx
= (ushort
*)(ptr
+1);
176 for (i
= 0; idx
[i
] != 0xffff; i
++)
181 PRINTF(stream
, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim
, i
, len
);
182 for (i
= 0; i
< len
; i
++)
183 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
184 PRINTF(stream
, "\n");
186 stream
->offset
+= len
* sizeof(unsigned);
193 struct debug_stream
*stream
,
201 unsigned himask
= ~0UL >> (31 - (hi
));
203 PRINTF(stream
, "\t\t ");
205 va_start( args
, fmt
);
206 debug_vprintf( fmt
, args
);
209 PRINTF(stream
, ": 0x%x\n", ((dw
) & himask
) >> (lo
));
213 #define MBZ( dw, hi, lo) do { \
214 unsigned x = (dw) >> (lo); \
215 unsigned lomask = (1 << (lo)) - 1; \
217 himask = (1UL << (hi)) - 1; \
218 assert ((x & himask & ~lomask) == 0); \
221 #define MBZ( dw, hi, lo) do { \
227 struct debug_stream
*stream
,
233 if (((dw
) >> (bit
)) & 1) {
236 PRINTF(stream
, "\t\t ");
238 va_start( args
, fmt
);
239 debug_vprintf( fmt
, args
);
242 PRINTF(stream
, "\n");
246 static boolean
debug_load_immediate( struct debug_stream
*stream
,
250 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
251 unsigned bits
= (ptr
[0] >> 4) & 0xff;
254 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
255 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
258 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
259 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
260 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
264 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
265 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
266 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
267 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
272 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
273 for (i
= 0; i
< 8; i
++) {
274 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
276 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
281 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
285 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
286 BITS(stream
, ptr
[j
], 31, 23, "point width");
287 BITS(stream
, ptr
[j
], 22, 19, "line width");
288 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
289 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
290 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
291 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
292 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
293 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
294 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
295 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
296 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
297 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
298 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
299 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
300 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
301 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
302 FLAG(stream
, ptr
[j
], 1, "sprite point");
303 FLAG(stream
, ptr
[j
], 0, "antialiasing");
307 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
308 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
309 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
310 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
311 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
312 FLAG(stream
, ptr
[j
], 24, "fog enable");
313 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
314 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
315 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
316 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
317 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
318 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
319 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
320 FLAG(stream
, ptr
[j
], 1, "color dither enable");
321 FLAG(stream
, ptr
[j
], 0, "logiop enable");
325 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
326 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
327 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
328 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
329 FLAG(stream
, ptr
[j
], 19, "depth test enable");
330 BITS(stream
, ptr
[j
], 18, 16, "depth func");
331 FLAG(stream
, ptr
[j
], 15, "blend enable");
332 BITS(stream
, ptr
[j
], 14, 12, "blend func");
333 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
334 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
335 FLAG(stream
, ptr
[j
], 3, "depth write enable");
336 FLAG(stream
, ptr
[j
], 2, "color write enable");
337 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
342 PRINTF(stream
, "\n");
346 stream
->offset
+= len
* sizeof(unsigned);
353 static boolean
debug_load_indirect( struct debug_stream
*stream
,
357 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
358 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
361 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
362 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
364 for (i
= 0; i
< 6; i
++) {
367 case LI0_STATE_STATIC_INDIRECT
:
368 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
369 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
371 case LI0_STATE_DYNAMIC_INDIRECT
:
372 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
374 case LI0_STATE_SAMPLER
:
375 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
376 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
379 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
380 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
382 case LI0_STATE_PROGRAM
:
383 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
384 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
386 case LI0_STATE_CONSTANTS
:
387 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
388 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
398 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
401 PRINTF(stream
, "\n");
406 stream
->offset
+= len
* sizeof(unsigned);
411 static void BR13( struct debug_stream
*stream
,
414 PRINTF(stream
, "\t0x%08x\n", val
);
415 FLAG(stream
, val
, 30, "clipping enable");
416 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
417 BITS(stream
, val
, 23, 16, "raster op");
418 BITS(stream
, val
, 15, 0, "dest pitch");
422 static void BR22( struct debug_stream
*stream
,
425 PRINTF(stream
, "\t0x%08x\n", val
);
426 BITS(stream
, val
, 31, 16, "dest y1");
427 BITS(stream
, val
, 15, 0, "dest x1");
430 static void BR23( struct debug_stream
*stream
,
433 PRINTF(stream
, "\t0x%08x\n", val
);
434 BITS(stream
, val
, 31, 16, "dest y2");
435 BITS(stream
, val
, 15, 0, "dest x2");
438 static void BR09( struct debug_stream
*stream
,
441 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
444 static void BR26( struct debug_stream
*stream
,
447 PRINTF(stream
, "\t0x%08x\n", val
);
448 BITS(stream
, val
, 31, 16, "src y1");
449 BITS(stream
, val
, 15, 0, "src x1");
452 static void BR11( struct debug_stream
*stream
,
455 PRINTF(stream
, "\t0x%08x\n", val
);
456 BITS(stream
, val
, 15, 0, "src pitch");
459 static void BR12( struct debug_stream
*stream
,
462 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
465 static void BR16( struct debug_stream
*stream
,
468 PRINTF(stream
, "\t0x%08x -- color\n", val
);
471 static boolean
debug_copy_blit( struct debug_stream
*stream
,
475 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
478 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
479 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
481 BR13(stream
, ptr
[j
++]);
482 BR22(stream
, ptr
[j
++]);
483 BR23(stream
, ptr
[j
++]);
484 BR09(stream
, ptr
[j
++]);
485 BR26(stream
, ptr
[j
++]);
486 BR11(stream
, ptr
[j
++]);
487 BR12(stream
, ptr
[j
++]);
489 stream
->offset
+= len
* sizeof(unsigned);
494 static boolean
debug_color_blit( struct debug_stream
*stream
,
498 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
501 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
502 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
504 BR13(stream
, ptr
[j
++]);
505 BR22(stream
, ptr
[j
++]);
506 BR23(stream
, ptr
[j
++]);
507 BR09(stream
, ptr
[j
++]);
508 BR16(stream
, ptr
[j
++]);
510 stream
->offset
+= len
* sizeof(unsigned);
515 static boolean
debug_modes4( struct debug_stream
*stream
,
519 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
522 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
523 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
524 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
525 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
526 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
527 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
528 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
531 stream
->offset
+= len
* sizeof(unsigned);
536 static boolean
debug_map_state( struct debug_stream
*stream
,
540 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
543 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
544 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
547 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
548 BITS(stream
, ptr
[j
], 15, 0, "map mask");
554 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
555 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
556 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
557 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
562 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
563 BITS(stream
, ptr
[j
], 31, 21, "height");
564 BITS(stream
, ptr
[j
], 20, 10, "width");
565 BITS(stream
, ptr
[j
], 9, 7, "surface format");
566 BITS(stream
, ptr
[j
], 6, 3, "texel format");
567 FLAG(stream
, ptr
[j
], 2, "use fence regs");
568 FLAG(stream
, ptr
[j
], 1, "tiled surface");
569 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
573 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
574 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
575 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
576 BITS(stream
, ptr
[j
], 14, 9, "max lod");
577 FLAG(stream
, ptr
[j
], 8, "mip layout right");
578 BITS(stream
, ptr
[j
], 7, 0, "depth");
583 stream
->offset
+= len
* sizeof(unsigned);
588 static boolean
debug_sampler_state( struct debug_stream
*stream
,
592 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
595 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
596 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
599 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
600 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
606 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
607 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
608 FLAG(stream
, ptr
[j
], 30, "planar to packed");
609 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
610 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
611 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
612 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
613 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
614 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
615 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
616 FLAG(stream
, ptr
[j
], 4, "shadow enable");
617 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
618 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
623 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
624 BITS(stream
, ptr
[j
], 31, 24, "min lod");
625 MBZ( ptr
[j
], 23, 18 );
626 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
627 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
628 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
629 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
630 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
631 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
632 FLAG(stream
, ptr
[j
], 5, "normalized coords");
633 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
634 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
638 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
643 stream
->offset
+= len
* sizeof(unsigned);
648 static boolean
debug_dest_vars( struct debug_stream
*stream
,
652 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
655 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
656 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
659 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
660 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
661 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
662 FLAG(stream
, ptr
[j
], 29, "bypass iz");
663 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
664 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
665 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
666 FLAG(stream
, ptr
[j
], 24, "debug dither");
667 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
668 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
669 MBZ (ptr
[j
], 15, 15 );
670 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
671 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
672 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
673 FLAG(stream
, ptr
[j
], 1, "vert line stride");
674 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
678 stream
->offset
+= len
* sizeof(unsigned);
683 static boolean
debug_buf_info( struct debug_stream
*stream
,
687 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
690 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
691 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
694 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
695 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
696 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
697 FLAG(stream
, ptr
[j
], 23, "use fence regs");
698 FLAG(stream
, ptr
[j
], 22, "tiled surface");
699 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
700 MBZ (ptr
[j
], 20, 14);
701 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
706 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
708 stream
->offset
+= len
* sizeof(unsigned);
713 static boolean
i915_debug_packet( struct debug_stream
*stream
)
715 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
718 switch (((cmd
>> 29) & 0x7)) {
720 switch ((cmd
>> 23) & 0x3f) {
722 return debug(stream
, "MI_NOOP", 1);
724 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
726 return debug(stream
, "MI_FLUSH", 1);
728 debug(stream
, "MI_BATCH_BUFFER_END", 1);
731 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
733 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
735 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
741 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
745 switch ((cmd
>> 22) & 0xff) {
747 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
749 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
751 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
755 switch ((cmd
>> 24) & 0x1f) {
757 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
759 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
761 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
763 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
765 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
767 return debug(stream
, "3DSTATE_MODES5", 1);
769 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
771 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
773 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
776 switch((cmd
>> 19) & 0x1f) {
778 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
780 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
782 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
789 switch ((cmd
>> 16) & 0xff) {
791 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
793 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
795 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
797 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
799 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
801 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
803 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
805 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
807 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
809 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
811 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
813 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
815 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
817 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
819 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
821 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
823 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
825 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
833 return debug(stream
, "???", (cmd
& 0xffff) + 1);
835 return debug(stream
, "", 1);
838 if ((cmd
& (1 << 23)) == 0)
839 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
840 else if (cmd
& (1 << 17))
842 if ((cmd
& 0xffff) == 0)
843 return debug_variable_length_prim(stream
);
845 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
848 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
851 return debug(stream
, "", 0);
866 i915_dump_batchbuffer( struct i915_winsys_batchbuffer
*batch
)
868 struct debug_stream stream
;
869 unsigned *start
= (unsigned*)batch
->map
;
870 unsigned *end
= (unsigned*)batch
->ptr
;
871 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
872 boolean done
= FALSE
;
875 stream
.ptr
= (char *)start
;
876 stream
.print_addresses
= 0;
878 if (!start
|| !end
) {
879 debug_printf( "\n\nBATCH: ???\n");
883 debug_printf( "\n\nBATCH: (%d)\n", (int)bytes
/ 4);
886 stream
.offset
< bytes
)
888 if (!i915_debug_packet( &stream
))
891 assert(stream
.offset
<= bytes
&&
895 debug_printf( "END-BATCH\n\n\n");