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 **************************************************************************/
28 //#include "imports.h"
31 #include "i915_context.h"
32 #include "i915_winsys.h"
33 #include "i915_debug.h"
34 #include "pipe/p_winsys.h"
39 struct debug_stream
*stream
,
46 va_start( args
, fmt
);
47 vsprintf( buffer
, fmt
, args
);
48 stream
->winsys
->printf( stream
->winsys
, buffer
);
53 static boolean
debug( struct debug_stream
*stream
, const char *name
, unsigned len
)
56 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
59 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
64 if (stream
->print_addresses
)
65 PRINTF(stream
, "%08x: ", stream
->offset
);
68 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
69 for (i
= 0; i
< len
; i
++)
70 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
73 stream
->offset
+= len
* sizeof(unsigned);
79 static const char *get_prim_name( unsigned val
)
81 switch (val
& PRIM3D_MASK
) {
82 case PRIM3D_TRILIST
: return "TRILIST"; break;
83 case PRIM3D_TRISTRIP
: return "TRISTRIP"; break;
84 case PRIM3D_TRISTRIP_RVRSE
: return "TRISTRIP_RVRSE"; break;
85 case PRIM3D_TRIFAN
: return "TRIFAN"; break;
86 case PRIM3D_POLY
: return "POLY"; break;
87 case PRIM3D_LINELIST
: return "LINELIST"; break;
88 case PRIM3D_LINESTRIP
: return "LINESTRIP"; break;
89 case PRIM3D_RECTLIST
: return "RECTLIST"; break;
90 case PRIM3D_POINTLIST
: return "POINTLIST"; break;
91 case PRIM3D_DIB
: return "DIB"; break;
92 case PRIM3D_CLEAR_RECT
: return "CLEAR_RECT"; break;
93 case PRIM3D_ZONE_INIT
: return "ZONE_INIT"; break;
94 default: return "????"; break;
98 static boolean
debug_prim( struct debug_stream
*stream
, const char *name
,
102 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
103 const char *prim
= get_prim_name( ptr
[0] );
108 PRINTF(stream
, "%s %s (%d dwords):\n", name
, prim
, len
);
109 PRINTF(stream
, "\t0x%08x\n", ptr
[0]);
110 for (i
= 1; i
< len
; i
++) {
112 PRINTF(stream
, "\t0x%08x // %f\n", ptr
[i
], *(float *)&ptr
[i
]);
114 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
118 PRINTF(stream
, "\n");
120 stream
->offset
+= len
* sizeof(unsigned);
128 static boolean
debug_program( struct debug_stream
*stream
, const char *name
, unsigned len
)
130 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
133 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
138 if (stream
->print_addresses
)
139 PRINTF(stream
, "%08x: ", stream
->offset
);
141 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
142 i915_disassemble_program( stream
, ptr
, len
);
144 stream
->offset
+= len
* sizeof(unsigned);
149 static boolean
debug_chain( struct debug_stream
*stream
, const char *name
, unsigned len
)
151 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
152 unsigned old_offset
= stream
->offset
+ len
* sizeof(unsigned);
155 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
156 for (i
= 0; i
< len
; i
++)
157 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
159 stream
->offset
= ptr
[1] & ~0x3;
161 if (stream
->offset
< old_offset
)
162 PRINTF(stream
, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
163 old_offset
, stream
->offset
);
165 PRINTF(stream
, "\n... skipping from 0x%x --> 0x%x ...\n\n",
166 old_offset
, stream
->offset
);
173 static boolean
debug_variable_length_prim( struct debug_stream
*stream
)
175 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
176 const char *prim
= get_prim_name( ptr
[0] );
179 ushort
*idx
= (ushort
*)(ptr
+1);
180 for (i
= 0; idx
[i
] != 0xffff; i
++)
185 PRINTF(stream
, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim
, i
, len
);
186 for (i
= 0; i
< len
; i
++)
187 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
188 PRINTF(stream
, "\n");
190 stream
->offset
+= len
* sizeof(unsigned);
197 struct debug_stream
*stream
,
206 unsigned himask
= ~0UL >> (31 - (hi
));
208 PRINTF(stream
, "\t\t ");
210 va_start( args
, fmt
);
211 vsprintf( buffer
, fmt
, args
);
212 stream
->winsys
->printf( stream
->winsys
, buffer
);
215 PRINTF(stream
, ": 0x%x\n", ((dw
) & himask
) >> (lo
));
218 #define MBZ( dw, hi, lo) do { \
219 unsigned x = (dw) >> (lo); \
220 unsigned lomask = (1 << (lo)) - 1; \
222 himask = (1UL << (hi)) - 1; \
223 assert ((x & himask & ~lomask) == 0); \
228 struct debug_stream
*stream
,
234 if (((dw
) >> (bit
)) & 1) {
238 PRINTF(stream
, "\t\t ");
240 va_start( args
, fmt
);
241 vsprintf( buffer
, fmt
, args
);
242 stream
->winsys
->printf( stream
->winsys
, buffer
);
245 PRINTF(stream
, "\n");
249 static boolean
debug_load_immediate( struct debug_stream
*stream
,
253 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
254 unsigned bits
= (ptr
[0] >> 4) & 0xff;
257 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
258 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
261 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
262 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
263 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
267 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
268 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
269 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
270 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
275 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
276 for (i
= 0; i
< 8; i
++) {
277 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
279 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
284 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
288 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
289 BITS(stream
, ptr
[j
], 31, 23, "point width");
290 BITS(stream
, ptr
[j
], 22, 19, "line width");
291 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
292 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
293 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
294 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
295 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
296 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
297 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
298 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
299 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
300 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
301 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
302 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
303 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
304 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
305 FLAG(stream
, ptr
[j
], 1, "sprite point");
306 FLAG(stream
, ptr
[j
], 0, "antialiasing");
310 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
311 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
312 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
313 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
314 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
315 FLAG(stream
, ptr
[j
], 24, "fog enable");
316 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
317 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
318 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
319 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
320 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
321 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
322 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
323 FLAG(stream
, ptr
[j
], 1, "color dither enable");
324 FLAG(stream
, ptr
[j
], 0, "logiop enable");
328 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
329 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
330 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
331 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
332 FLAG(stream
, ptr
[j
], 19, "depth test enable");
333 BITS(stream
, ptr
[j
], 18, 16, "depth func");
334 FLAG(stream
, ptr
[j
], 15, "blend enable");
335 BITS(stream
, ptr
[j
], 14, 12, "blend func");
336 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
337 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
338 FLAG(stream
, ptr
[j
], 3, "depth write enable");
339 FLAG(stream
, ptr
[j
], 2, "color write enable");
340 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
345 PRINTF(stream
, "\n");
349 stream
->offset
+= len
* sizeof(unsigned);
356 static boolean
debug_load_indirect( struct debug_stream
*stream
,
360 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
361 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
364 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
365 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
367 for (i
= 0; i
< 6; i
++) {
370 case LI0_STATE_STATIC_INDIRECT
:
371 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
372 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
374 case LI0_STATE_DYNAMIC_INDIRECT
:
375 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
377 case LI0_STATE_SAMPLER
:
378 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
379 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
382 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
383 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
385 case LI0_STATE_PROGRAM
:
386 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
387 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
389 case LI0_STATE_CONSTANTS
:
390 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
391 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
401 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
404 PRINTF(stream
, "\n");
409 stream
->offset
+= len
* sizeof(unsigned);
414 static void BR13( struct debug_stream
*stream
,
417 PRINTF(stream
, "\t0x%08x\n", val
);
418 FLAG(stream
, val
, 30, "clipping enable");
419 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
420 BITS(stream
, val
, 23, 16, "raster op");
421 BITS(stream
, val
, 15, 0, "dest pitch");
425 static void BR22( struct debug_stream
*stream
,
428 PRINTF(stream
, "\t0x%08x\n", val
);
429 BITS(stream
, val
, 31, 16, "dest y1");
430 BITS(stream
, val
, 15, 0, "dest x1");
433 static void BR23( struct debug_stream
*stream
,
436 PRINTF(stream
, "\t0x%08x\n", val
);
437 BITS(stream
, val
, 31, 16, "dest y2");
438 BITS(stream
, val
, 15, 0, "dest x2");
441 static void BR09( struct debug_stream
*stream
,
444 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
447 static void BR26( struct debug_stream
*stream
,
450 PRINTF(stream
, "\t0x%08x\n", val
);
451 BITS(stream
, val
, 31, 16, "src y1");
452 BITS(stream
, val
, 15, 0, "src x1");
455 static void BR11( struct debug_stream
*stream
,
458 PRINTF(stream
, "\t0x%08x\n", val
);
459 BITS(stream
, val
, 15, 0, "src pitch");
462 static void BR12( struct debug_stream
*stream
,
465 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
468 static void BR16( struct debug_stream
*stream
,
471 PRINTF(stream
, "\t0x%08x -- color\n", val
);
474 static boolean
debug_copy_blit( struct debug_stream
*stream
,
478 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
481 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
482 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
484 BR13(stream
, ptr
[j
++]);
485 BR22(stream
, ptr
[j
++]);
486 BR23(stream
, ptr
[j
++]);
487 BR09(stream
, ptr
[j
++]);
488 BR26(stream
, ptr
[j
++]);
489 BR11(stream
, ptr
[j
++]);
490 BR12(stream
, ptr
[j
++]);
492 stream
->offset
+= len
* sizeof(unsigned);
497 static boolean
debug_color_blit( struct debug_stream
*stream
,
501 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
504 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
505 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
507 BR13(stream
, ptr
[j
++]);
508 BR22(stream
, ptr
[j
++]);
509 BR23(stream
, ptr
[j
++]);
510 BR09(stream
, ptr
[j
++]);
511 BR16(stream
, ptr
[j
++]);
513 stream
->offset
+= len
* sizeof(unsigned);
518 static boolean
debug_modes4( struct debug_stream
*stream
,
522 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
525 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
526 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
527 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
528 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
529 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
530 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
531 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
534 stream
->offset
+= len
* sizeof(unsigned);
539 static boolean
debug_map_state( struct debug_stream
*stream
,
543 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
546 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
547 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
550 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
551 BITS(stream
, ptr
[j
], 15, 0, "map mask");
557 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
558 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
559 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
560 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
565 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
566 BITS(stream
, ptr
[j
], 31, 21, "height");
567 BITS(stream
, ptr
[j
], 20, 10, "width");
568 BITS(stream
, ptr
[j
], 9, 7, "surface format");
569 BITS(stream
, ptr
[j
], 6, 3, "texel format");
570 FLAG(stream
, ptr
[j
], 2, "use fence regs");
571 FLAG(stream
, ptr
[j
], 1, "tiled surface");
572 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
576 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
577 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
578 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
579 BITS(stream
, ptr
[j
], 14, 9, "max lod");
580 FLAG(stream
, ptr
[j
], 8, "mip layout right");
581 BITS(stream
, ptr
[j
], 7, 0, "depth");
586 stream
->offset
+= len
* sizeof(unsigned);
591 static boolean
debug_sampler_state( struct debug_stream
*stream
,
595 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
598 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
599 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
602 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
603 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
609 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
610 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
611 FLAG(stream
, ptr
[j
], 30, "planar to packed");
612 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
613 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
614 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
615 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
616 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
617 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
618 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
619 FLAG(stream
, ptr
[j
], 4, "shadow enable");
620 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
621 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
626 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
627 BITS(stream
, ptr
[j
], 31, 24, "min lod");
628 MBZ( ptr
[j
], 23, 18 );
629 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
630 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
631 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
632 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
633 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
634 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
635 FLAG(stream
, ptr
[j
], 5, "normalized coords");
636 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
637 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
641 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
646 stream
->offset
+= len
* sizeof(unsigned);
651 static boolean
debug_dest_vars( struct debug_stream
*stream
,
655 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
658 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
659 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
662 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
663 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
664 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
665 FLAG(stream
, ptr
[j
], 29, "bypass iz");
666 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
667 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
668 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
669 FLAG(stream
, ptr
[j
], 24, "debug dither");
670 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
671 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
672 MBZ (ptr
[j
], 15, 15 );
673 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
674 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
675 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
676 FLAG(stream
, ptr
[j
], 1, "vert line stride");
677 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
681 stream
->offset
+= len
* sizeof(unsigned);
686 static boolean
debug_buf_info( struct debug_stream
*stream
,
690 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
693 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
694 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
697 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
698 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
699 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
700 FLAG(stream
, ptr
[j
], 23, "use fence regs");
701 FLAG(stream
, ptr
[j
], 22, "tiled surface");
702 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
703 MBZ (ptr
[j
], 20, 14);
704 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
709 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
711 stream
->offset
+= len
* sizeof(unsigned);
716 static boolean
i915_debug_packet( struct debug_stream
*stream
)
718 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
721 switch (((cmd
>> 29) & 0x7)) {
723 switch ((cmd
>> 23) & 0x3f) {
725 return debug(stream
, "MI_NOOP", 1);
727 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
729 return debug(stream
, "MI_FLUSH", 1);
731 debug(stream
, "MI_BATCH_BUFFER_END", 1);
734 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
736 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
738 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
744 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
748 switch ((cmd
>> 22) & 0xff) {
750 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
752 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
754 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
758 switch ((cmd
>> 24) & 0x1f) {
760 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
762 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
764 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
766 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
768 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
770 return debug(stream
, "3DSTATE_MODES5", 1);
772 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
774 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
776 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
779 switch((cmd
>> 19) & 0x1f) {
781 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
783 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
785 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
792 switch ((cmd
>> 16) & 0xff) {
794 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
796 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
798 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
800 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
802 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
804 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
806 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
808 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
810 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
812 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
814 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
816 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
818 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
820 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
822 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
824 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
826 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
828 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
836 return debug(stream
, "???", (cmd
& 0xffff) + 1);
838 return debug(stream
, "", 1);
841 if ((cmd
& (1 << 23)) == 0)
842 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
843 else if (cmd
& (1 << 17))
845 if ((cmd
& 0xffff) == 0)
846 return debug_variable_length_prim(stream
);
848 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
851 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
854 return debug(stream
, "", 0);
868 i915_dump_batchbuffer( struct i915_context
*i915
)
870 struct debug_stream stream
;
871 unsigned *start
= i915
->batch_start
;
872 unsigned *end
= i915
->winsys
->batch_start( i915
->winsys
, 0, 0 );
873 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
874 boolean done
= FALSE
;
877 stream
.ptr
= (char *)start
;
878 stream
.print_addresses
= 0;
879 stream
.winsys
= i915
->pipe
.winsys
;
881 if (!start
|| !end
) {
882 stream
.winsys
->printf( stream
.winsys
, "\n\nBATCH: ???\n");
886 stream
.winsys
->printf( stream
.winsys
, "\n\nBATCH: (%d)\n", bytes
/ 4);
889 stream
.offset
< bytes
)
891 if (!i915_debug_packet( &stream
))
894 assert(stream
.offset
<= bytes
&&
898 stream
.winsys
->printf( stream
.winsys
, "END-BATCH\n\n\n");