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_winsys.h"
31 #include "i915_debug.h"
32 #include "pipe/p_winsys.h"
33 #include "pipe/p_debug.h"
38 struct debug_stream
*stream
,
44 va_start( args
, fmt
);
45 debug_vprintf( fmt
, args
);
50 static boolean
debug( struct debug_stream
*stream
, const char *name
, unsigned len
)
53 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
56 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
61 if (stream
->print_addresses
)
62 PRINTF(stream
, "%08x: ", stream
->offset
);
65 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
66 for (i
= 0; i
< len
; i
++)
67 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
70 stream
->offset
+= len
* sizeof(unsigned);
76 static const char *get_prim_name( unsigned val
)
78 switch (val
& PRIM3D_MASK
) {
79 case PRIM3D_TRILIST
: return "TRILIST"; break;
80 case PRIM3D_TRISTRIP
: return "TRISTRIP"; break;
81 case PRIM3D_TRISTRIP_RVRSE
: return "TRISTRIP_RVRSE"; break;
82 case PRIM3D_TRIFAN
: return "TRIFAN"; break;
83 case PRIM3D_POLY
: return "POLY"; break;
84 case PRIM3D_LINELIST
: return "LINELIST"; break;
85 case PRIM3D_LINESTRIP
: return "LINESTRIP"; break;
86 case PRIM3D_RECTLIST
: return "RECTLIST"; break;
87 case PRIM3D_POINTLIST
: return "POINTLIST"; break;
88 case PRIM3D_DIB
: return "DIB"; break;
89 case PRIM3D_CLEAR_RECT
: return "CLEAR_RECT"; break;
90 case PRIM3D_ZONE_INIT
: return "ZONE_INIT"; break;
91 default: return "????"; break;
95 static boolean
debug_prim( struct debug_stream
*stream
, const char *name
,
99 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
100 const char *prim
= get_prim_name( ptr
[0] );
105 PRINTF(stream
, "%s %s (%d dwords):\n", name
, prim
, len
);
106 PRINTF(stream
, "\t0x%08x\n", ptr
[0]);
107 for (i
= 1; i
< len
; i
++) {
109 PRINTF(stream
, "\t0x%08x // %f\n", ptr
[i
], *(float *)&ptr
[i
]);
111 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
115 PRINTF(stream
, "\n");
117 stream
->offset
+= len
* sizeof(unsigned);
125 static boolean
debug_program( struct debug_stream
*stream
, const char *name
, unsigned len
)
127 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
130 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
135 if (stream
->print_addresses
)
136 PRINTF(stream
, "%08x: ", stream
->offset
);
138 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
139 i915_disassemble_program( stream
, ptr
, len
);
141 stream
->offset
+= len
* sizeof(unsigned);
146 static boolean
debug_chain( struct debug_stream
*stream
, const char *name
, unsigned len
)
148 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
149 unsigned old_offset
= stream
->offset
+ len
* sizeof(unsigned);
152 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
153 for (i
= 0; i
< len
; i
++)
154 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
156 stream
->offset
= ptr
[1] & ~0x3;
158 if (stream
->offset
< old_offset
)
159 PRINTF(stream
, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
160 old_offset
, stream
->offset
);
162 PRINTF(stream
, "\n... skipping from 0x%x --> 0x%x ...\n\n",
163 old_offset
, stream
->offset
);
170 static boolean
debug_variable_length_prim( struct debug_stream
*stream
)
172 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
173 const char *prim
= get_prim_name( ptr
[0] );
176 ushort
*idx
= (ushort
*)(ptr
+1);
177 for (i
= 0; idx
[i
] != 0xffff; i
++)
182 PRINTF(stream
, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim
, i
, len
);
183 for (i
= 0; i
< len
; i
++)
184 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
185 PRINTF(stream
, "\n");
187 stream
->offset
+= len
* sizeof(unsigned);
194 struct debug_stream
*stream
,
202 unsigned himask
= ~0UL >> (31 - (hi
));
204 PRINTF(stream
, "\t\t ");
206 va_start( args
, fmt
);
207 debug_vprintf( fmt
, args
);
210 PRINTF(stream
, ": 0x%x\n", ((dw
) & himask
) >> (lo
));
214 #define MBZ( dw, hi, lo) do { \
215 unsigned x = (dw) >> (lo); \
216 unsigned lomask = (1 << (lo)) - 1; \
218 himask = (1UL << (hi)) - 1; \
219 assert ((x & himask & ~lomask) == 0); \
222 #define MBZ( dw, hi, lo) do { \
228 struct debug_stream
*stream
,
234 if (((dw
) >> (bit
)) & 1) {
237 PRINTF(stream
, "\t\t ");
239 va_start( args
, fmt
);
240 debug_vprintf( fmt
, args
);
243 PRINTF(stream
, "\n");
247 static boolean
debug_load_immediate( struct debug_stream
*stream
,
251 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
252 unsigned bits
= (ptr
[0] >> 4) & 0xff;
255 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
256 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
259 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
260 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
261 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
265 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
266 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
267 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
268 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
273 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
274 for (i
= 0; i
< 8; i
++) {
275 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
277 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
282 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
286 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
287 BITS(stream
, ptr
[j
], 31, 23, "point width");
288 BITS(stream
, ptr
[j
], 22, 19, "line width");
289 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
290 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
291 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
292 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
293 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
294 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
295 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
296 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
297 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
298 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
299 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
300 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
301 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
302 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
303 FLAG(stream
, ptr
[j
], 1, "sprite point");
304 FLAG(stream
, ptr
[j
], 0, "antialiasing");
308 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
309 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
310 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
311 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
312 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
313 FLAG(stream
, ptr
[j
], 24, "fog enable");
314 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
315 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
316 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
317 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
318 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
319 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
320 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
321 FLAG(stream
, ptr
[j
], 1, "color dither enable");
322 FLAG(stream
, ptr
[j
], 0, "logiop enable");
326 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
327 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
328 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
329 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
330 FLAG(stream
, ptr
[j
], 19, "depth test enable");
331 BITS(stream
, ptr
[j
], 18, 16, "depth func");
332 FLAG(stream
, ptr
[j
], 15, "blend enable");
333 BITS(stream
, ptr
[j
], 14, 12, "blend func");
334 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
335 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
336 FLAG(stream
, ptr
[j
], 3, "depth write enable");
337 FLAG(stream
, ptr
[j
], 2, "color write enable");
338 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
343 PRINTF(stream
, "\n");
347 stream
->offset
+= len
* sizeof(unsigned);
354 static boolean
debug_load_indirect( struct debug_stream
*stream
,
358 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
359 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
362 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
363 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
365 for (i
= 0; i
< 6; i
++) {
368 case LI0_STATE_STATIC_INDIRECT
:
369 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
370 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
372 case LI0_STATE_DYNAMIC_INDIRECT
:
373 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
375 case LI0_STATE_SAMPLER
:
376 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
377 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
380 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
381 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
383 case LI0_STATE_PROGRAM
:
384 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
385 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
387 case LI0_STATE_CONSTANTS
:
388 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
389 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
399 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
402 PRINTF(stream
, "\n");
407 stream
->offset
+= len
* sizeof(unsigned);
412 static void BR13( struct debug_stream
*stream
,
415 PRINTF(stream
, "\t0x%08x\n", val
);
416 FLAG(stream
, val
, 30, "clipping enable");
417 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
418 BITS(stream
, val
, 23, 16, "raster op");
419 BITS(stream
, val
, 15, 0, "dest pitch");
423 static void BR22( struct debug_stream
*stream
,
426 PRINTF(stream
, "\t0x%08x\n", val
);
427 BITS(stream
, val
, 31, 16, "dest y1");
428 BITS(stream
, val
, 15, 0, "dest x1");
431 static void BR23( struct debug_stream
*stream
,
434 PRINTF(stream
, "\t0x%08x\n", val
);
435 BITS(stream
, val
, 31, 16, "dest y2");
436 BITS(stream
, val
, 15, 0, "dest x2");
439 static void BR09( struct debug_stream
*stream
,
442 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
445 static void BR26( struct debug_stream
*stream
,
448 PRINTF(stream
, "\t0x%08x\n", val
);
449 BITS(stream
, val
, 31, 16, "src y1");
450 BITS(stream
, val
, 15, 0, "src x1");
453 static void BR11( struct debug_stream
*stream
,
456 PRINTF(stream
, "\t0x%08x\n", val
);
457 BITS(stream
, val
, 15, 0, "src pitch");
460 static void BR12( struct debug_stream
*stream
,
463 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
466 static void BR16( struct debug_stream
*stream
,
469 PRINTF(stream
, "\t0x%08x -- color\n", val
);
472 static boolean
debug_copy_blit( struct debug_stream
*stream
,
476 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
479 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
480 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
482 BR13(stream
, ptr
[j
++]);
483 BR22(stream
, ptr
[j
++]);
484 BR23(stream
, ptr
[j
++]);
485 BR09(stream
, ptr
[j
++]);
486 BR26(stream
, ptr
[j
++]);
487 BR11(stream
, ptr
[j
++]);
488 BR12(stream
, ptr
[j
++]);
490 stream
->offset
+= len
* sizeof(unsigned);
495 static boolean
debug_color_blit( struct debug_stream
*stream
,
499 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
502 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
503 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
505 BR13(stream
, ptr
[j
++]);
506 BR22(stream
, ptr
[j
++]);
507 BR23(stream
, ptr
[j
++]);
508 BR09(stream
, ptr
[j
++]);
509 BR16(stream
, ptr
[j
++]);
511 stream
->offset
+= len
* sizeof(unsigned);
516 static boolean
debug_modes4( struct debug_stream
*stream
,
520 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
523 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
524 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
525 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
526 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
527 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
528 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
529 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
532 stream
->offset
+= len
* sizeof(unsigned);
537 static boolean
debug_map_state( struct debug_stream
*stream
,
541 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
544 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
545 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
548 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
549 BITS(stream
, ptr
[j
], 15, 0, "map mask");
555 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
556 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
557 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
558 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
563 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
564 BITS(stream
, ptr
[j
], 31, 21, "height");
565 BITS(stream
, ptr
[j
], 20, 10, "width");
566 BITS(stream
, ptr
[j
], 9, 7, "surface format");
567 BITS(stream
, ptr
[j
], 6, 3, "texel format");
568 FLAG(stream
, ptr
[j
], 2, "use fence regs");
569 FLAG(stream
, ptr
[j
], 1, "tiled surface");
570 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
574 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
575 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
576 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
577 BITS(stream
, ptr
[j
], 14, 9, "max lod");
578 FLAG(stream
, ptr
[j
], 8, "mip layout right");
579 BITS(stream
, ptr
[j
], 7, 0, "depth");
584 stream
->offset
+= len
* sizeof(unsigned);
589 static boolean
debug_sampler_state( struct debug_stream
*stream
,
593 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
596 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
597 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
600 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
601 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
607 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
608 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
609 FLAG(stream
, ptr
[j
], 30, "planar to packed");
610 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
611 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
612 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
613 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
614 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
615 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
616 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
617 FLAG(stream
, ptr
[j
], 4, "shadow enable");
618 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
619 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
624 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
625 BITS(stream
, ptr
[j
], 31, 24, "min lod");
626 MBZ( ptr
[j
], 23, 18 );
627 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
628 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
629 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
630 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
631 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
632 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
633 FLAG(stream
, ptr
[j
], 5, "normalized coords");
634 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
635 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
639 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
644 stream
->offset
+= len
* sizeof(unsigned);
649 static boolean
debug_dest_vars( struct debug_stream
*stream
,
653 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
656 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
657 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
660 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
661 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
662 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
663 FLAG(stream
, ptr
[j
], 29, "bypass iz");
664 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
665 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
666 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
667 FLAG(stream
, ptr
[j
], 24, "debug dither");
668 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
669 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
670 MBZ (ptr
[j
], 15, 15 );
671 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
672 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
673 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
674 FLAG(stream
, ptr
[j
], 1, "vert line stride");
675 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
679 stream
->offset
+= len
* sizeof(unsigned);
684 static boolean
debug_buf_info( struct debug_stream
*stream
,
688 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
691 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
692 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
695 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
696 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
697 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
698 FLAG(stream
, ptr
[j
], 23, "use fence regs");
699 FLAG(stream
, ptr
[j
], 22, "tiled surface");
700 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
701 MBZ (ptr
[j
], 20, 14);
702 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
707 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
709 stream
->offset
+= len
* sizeof(unsigned);
714 static boolean
i915_debug_packet( struct debug_stream
*stream
)
716 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
719 switch (((cmd
>> 29) & 0x7)) {
721 switch ((cmd
>> 23) & 0x3f) {
723 return debug(stream
, "MI_NOOP", 1);
725 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
727 return debug(stream
, "MI_FLUSH", 1);
729 debug(stream
, "MI_BATCH_BUFFER_END", 1);
732 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
734 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
736 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
742 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
746 switch ((cmd
>> 22) & 0xff) {
748 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
750 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
752 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
756 switch ((cmd
>> 24) & 0x1f) {
758 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
760 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
762 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
764 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
766 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
768 return debug(stream
, "3DSTATE_MODES5", 1);
770 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
772 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
774 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
777 switch((cmd
>> 19) & 0x1f) {
779 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
781 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
783 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
790 switch ((cmd
>> 16) & 0xff) {
792 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
794 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
796 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
798 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
800 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
802 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
804 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
806 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
808 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
810 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
812 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
814 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
816 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
818 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
820 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
822 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
824 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
826 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
834 return debug(stream
, "???", (cmd
& 0xffff) + 1);
836 return debug(stream
, "", 1);
839 if ((cmd
& (1 << 23)) == 0)
840 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
841 else if (cmd
& (1 << 17))
843 if ((cmd
& 0xffff) == 0)
844 return debug_variable_length_prim(stream
);
846 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
849 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
852 return debug(stream
, "", 0);
866 i915_dump_batchbuffer( struct i915_context
*i915
)
868 struct debug_stream stream
;
870 unsigned *start
= 0;/*i915->batch_start;*/
871 unsigned *end
= 0;/*i915->winsys->batch_start( i915->winsys, 0, 0 );*/
872 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
873 boolean done
= FALSE
;
876 stream
.ptr
= (char *)start
;
877 stream
.print_addresses
= 0;
878 stream
.winsys
= i915
->pipe
.winsys
;
880 if (!start
|| !end
) {
881 debug_printf( "\n\nBATCH: ???\n");
885 debug_printf( "\n\nBATCH: (%d)\n", bytes
/ 4);
888 stream
.offset
< bytes
)
890 if (!i915_debug_packet( &stream
))
893 assert(stream
.offset
<= bytes
&&
897 debug_printf( "END-BATCH\n\n\n");