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 "i915_batch.h"
33 #include "pipe/internal/p_winsys_screen.h"
34 #include "pipe/p_debug.h"
39 struct debug_stream
*stream
,
45 va_start( args
, fmt
);
46 debug_vprintf( fmt
, args
);
51 static boolean
debug( struct debug_stream
*stream
, const char *name
, unsigned len
)
54 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
57 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
62 if (stream
->print_addresses
)
63 PRINTF(stream
, "%08x: ", stream
->offset
);
66 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
67 for (i
= 0; i
< len
; i
++)
68 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
71 stream
->offset
+= len
* sizeof(unsigned);
77 static const char *get_prim_name( unsigned val
)
79 switch (val
& PRIM3D_MASK
) {
80 case PRIM3D_TRILIST
: return "TRILIST"; break;
81 case PRIM3D_TRISTRIP
: return "TRISTRIP"; break;
82 case PRIM3D_TRISTRIP_RVRSE
: return "TRISTRIP_RVRSE"; break;
83 case PRIM3D_TRIFAN
: return "TRIFAN"; break;
84 case PRIM3D_POLY
: return "POLY"; break;
85 case PRIM3D_LINELIST
: return "LINELIST"; break;
86 case PRIM3D_LINESTRIP
: return "LINESTRIP"; break;
87 case PRIM3D_RECTLIST
: return "RECTLIST"; break;
88 case PRIM3D_POINTLIST
: return "POINTLIST"; break;
89 case PRIM3D_DIB
: return "DIB"; break;
90 case PRIM3D_CLEAR_RECT
: return "CLEAR_RECT"; break;
91 case PRIM3D_ZONE_INIT
: return "ZONE_INIT"; break;
92 default: return "????"; break;
96 static boolean
debug_prim( struct debug_stream
*stream
, const char *name
,
100 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
101 const char *prim
= get_prim_name( ptr
[0] );
106 PRINTF(stream
, "%s %s (%d dwords):\n", name
, prim
, len
);
107 PRINTF(stream
, "\t0x%08x\n", ptr
[0]);
108 for (i
= 1; i
< len
; i
++) {
110 PRINTF(stream
, "\t0x%08x // %f\n", ptr
[i
], *(float *)&ptr
[i
]);
112 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
116 PRINTF(stream
, "\n");
118 stream
->offset
+= len
* sizeof(unsigned);
126 static boolean
debug_program( struct debug_stream
*stream
, const char *name
, unsigned len
)
128 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
131 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
136 if (stream
->print_addresses
)
137 PRINTF(stream
, "%08x: ", stream
->offset
);
139 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
140 i915_disassemble_program( stream
, ptr
, len
);
142 stream
->offset
+= len
* sizeof(unsigned);
147 static boolean
debug_chain( struct debug_stream
*stream
, const char *name
, unsigned len
)
149 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
150 unsigned old_offset
= stream
->offset
+ len
* sizeof(unsigned);
153 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
154 for (i
= 0; i
< len
; i
++)
155 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
157 stream
->offset
= ptr
[1] & ~0x3;
159 if (stream
->offset
< old_offset
)
160 PRINTF(stream
, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
161 old_offset
, stream
->offset
);
163 PRINTF(stream
, "\n... skipping from 0x%x --> 0x%x ...\n\n",
164 old_offset
, stream
->offset
);
171 static boolean
debug_variable_length_prim( struct debug_stream
*stream
)
173 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
174 const char *prim
= get_prim_name( ptr
[0] );
177 ushort
*idx
= (ushort
*)(ptr
+1);
178 for (i
= 0; idx
[i
] != 0xffff; i
++)
183 PRINTF(stream
, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim
, i
, len
);
184 for (i
= 0; i
< len
; i
++)
185 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
186 PRINTF(stream
, "\n");
188 stream
->offset
+= len
* sizeof(unsigned);
195 struct debug_stream
*stream
,
203 unsigned himask
= ~0UL >> (31 - (hi
));
205 PRINTF(stream
, "\t\t ");
207 va_start( args
, fmt
);
208 debug_vprintf( fmt
, args
);
211 PRINTF(stream
, ": 0x%x\n", ((dw
) & himask
) >> (lo
));
215 #define MBZ( dw, hi, lo) do { \
216 unsigned x = (dw) >> (lo); \
217 unsigned lomask = (1 << (lo)) - 1; \
219 himask = (1UL << (hi)) - 1; \
220 assert ((x & himask & ~lomask) == 0); \
223 #define MBZ( dw, hi, lo) do { \
229 struct debug_stream
*stream
,
235 if (((dw
) >> (bit
)) & 1) {
238 PRINTF(stream
, "\t\t ");
240 va_start( args
, fmt
);
241 debug_vprintf( fmt
, args
);
244 PRINTF(stream
, "\n");
248 static boolean
debug_load_immediate( struct debug_stream
*stream
,
252 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
253 unsigned bits
= (ptr
[0] >> 4) & 0xff;
256 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
257 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
260 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
261 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
262 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
266 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
267 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
268 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
269 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
274 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
275 for (i
= 0; i
< 8; i
++) {
276 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
278 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
283 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
287 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
288 BITS(stream
, ptr
[j
], 31, 23, "point width");
289 BITS(stream
, ptr
[j
], 22, 19, "line width");
290 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
291 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
292 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
293 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
294 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
295 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
296 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
297 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
298 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
299 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
300 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
301 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
302 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
303 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
304 FLAG(stream
, ptr
[j
], 1, "sprite point");
305 FLAG(stream
, ptr
[j
], 0, "antialiasing");
309 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
310 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
311 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
312 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
313 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
314 FLAG(stream
, ptr
[j
], 24, "fog enable");
315 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
316 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
317 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
318 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
319 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
320 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
321 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
322 FLAG(stream
, ptr
[j
], 1, "color dither enable");
323 FLAG(stream
, ptr
[j
], 0, "logiop enable");
327 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
328 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
329 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
330 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
331 FLAG(stream
, ptr
[j
], 19, "depth test enable");
332 BITS(stream
, ptr
[j
], 18, 16, "depth func");
333 FLAG(stream
, ptr
[j
], 15, "blend enable");
334 BITS(stream
, ptr
[j
], 14, 12, "blend func");
335 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
336 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
337 FLAG(stream
, ptr
[j
], 3, "depth write enable");
338 FLAG(stream
, ptr
[j
], 2, "color write enable");
339 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
344 PRINTF(stream
, "\n");
348 stream
->offset
+= len
* sizeof(unsigned);
355 static boolean
debug_load_indirect( struct debug_stream
*stream
,
359 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
360 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
363 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
364 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
366 for (i
= 0; i
< 6; i
++) {
369 case LI0_STATE_STATIC_INDIRECT
:
370 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
371 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
373 case LI0_STATE_DYNAMIC_INDIRECT
:
374 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
376 case LI0_STATE_SAMPLER
:
377 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
378 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
381 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
382 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
384 case LI0_STATE_PROGRAM
:
385 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
386 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
388 case LI0_STATE_CONSTANTS
:
389 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
390 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
400 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
403 PRINTF(stream
, "\n");
408 stream
->offset
+= len
* sizeof(unsigned);
413 static void BR13( struct debug_stream
*stream
,
416 PRINTF(stream
, "\t0x%08x\n", val
);
417 FLAG(stream
, val
, 30, "clipping enable");
418 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
419 BITS(stream
, val
, 23, 16, "raster op");
420 BITS(stream
, val
, 15, 0, "dest pitch");
424 static void BR22( struct debug_stream
*stream
,
427 PRINTF(stream
, "\t0x%08x\n", val
);
428 BITS(stream
, val
, 31, 16, "dest y1");
429 BITS(stream
, val
, 15, 0, "dest x1");
432 static void BR23( struct debug_stream
*stream
,
435 PRINTF(stream
, "\t0x%08x\n", val
);
436 BITS(stream
, val
, 31, 16, "dest y2");
437 BITS(stream
, val
, 15, 0, "dest x2");
440 static void BR09( struct debug_stream
*stream
,
443 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
446 static void BR26( struct debug_stream
*stream
,
449 PRINTF(stream
, "\t0x%08x\n", val
);
450 BITS(stream
, val
, 31, 16, "src y1");
451 BITS(stream
, val
, 15, 0, "src x1");
454 static void BR11( struct debug_stream
*stream
,
457 PRINTF(stream
, "\t0x%08x\n", val
);
458 BITS(stream
, val
, 15, 0, "src pitch");
461 static void BR12( struct debug_stream
*stream
,
464 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
467 static void BR16( struct debug_stream
*stream
,
470 PRINTF(stream
, "\t0x%08x -- color\n", val
);
473 static boolean
debug_copy_blit( struct debug_stream
*stream
,
477 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
480 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
481 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
483 BR13(stream
, ptr
[j
++]);
484 BR22(stream
, ptr
[j
++]);
485 BR23(stream
, ptr
[j
++]);
486 BR09(stream
, ptr
[j
++]);
487 BR26(stream
, ptr
[j
++]);
488 BR11(stream
, ptr
[j
++]);
489 BR12(stream
, ptr
[j
++]);
491 stream
->offset
+= len
* sizeof(unsigned);
496 static boolean
debug_color_blit( struct debug_stream
*stream
,
500 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
503 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
504 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
506 BR13(stream
, ptr
[j
++]);
507 BR22(stream
, ptr
[j
++]);
508 BR23(stream
, ptr
[j
++]);
509 BR09(stream
, ptr
[j
++]);
510 BR16(stream
, ptr
[j
++]);
512 stream
->offset
+= len
* sizeof(unsigned);
517 static boolean
debug_modes4( struct debug_stream
*stream
,
521 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
524 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
525 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
526 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
527 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
528 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
529 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
530 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
533 stream
->offset
+= len
* sizeof(unsigned);
538 static boolean
debug_map_state( struct debug_stream
*stream
,
542 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
545 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
546 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
549 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
550 BITS(stream
, ptr
[j
], 15, 0, "map mask");
556 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
557 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
558 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
559 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
564 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
565 BITS(stream
, ptr
[j
], 31, 21, "height");
566 BITS(stream
, ptr
[j
], 20, 10, "width");
567 BITS(stream
, ptr
[j
], 9, 7, "surface format");
568 BITS(stream
, ptr
[j
], 6, 3, "texel format");
569 FLAG(stream
, ptr
[j
], 2, "use fence regs");
570 FLAG(stream
, ptr
[j
], 1, "tiled surface");
571 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
575 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
576 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
577 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
578 BITS(stream
, ptr
[j
], 14, 9, "max lod");
579 FLAG(stream
, ptr
[j
], 8, "mip layout right");
580 BITS(stream
, ptr
[j
], 7, 0, "depth");
585 stream
->offset
+= len
* sizeof(unsigned);
590 static boolean
debug_sampler_state( struct debug_stream
*stream
,
594 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
597 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
598 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
601 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
602 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
608 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
609 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
610 FLAG(stream
, ptr
[j
], 30, "planar to packed");
611 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
612 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
613 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
614 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
615 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
616 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
617 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
618 FLAG(stream
, ptr
[j
], 4, "shadow enable");
619 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
620 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
625 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
626 BITS(stream
, ptr
[j
], 31, 24, "min lod");
627 MBZ( ptr
[j
], 23, 18 );
628 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
629 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
630 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
631 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
632 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
633 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
634 FLAG(stream
, ptr
[j
], 5, "normalized coords");
635 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
636 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
640 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
645 stream
->offset
+= len
* sizeof(unsigned);
650 static boolean
debug_dest_vars( struct debug_stream
*stream
,
654 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
657 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
658 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
661 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
662 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
663 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
664 FLAG(stream
, ptr
[j
], 29, "bypass iz");
665 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
666 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
667 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
668 FLAG(stream
, ptr
[j
], 24, "debug dither");
669 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
670 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
671 MBZ (ptr
[j
], 15, 15 );
672 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
673 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
674 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
675 FLAG(stream
, ptr
[j
], 1, "vert line stride");
676 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
680 stream
->offset
+= len
* sizeof(unsigned);
685 static boolean
debug_buf_info( struct debug_stream
*stream
,
689 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
692 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
693 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
696 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
697 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
698 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
699 FLAG(stream
, ptr
[j
], 23, "use fence regs");
700 FLAG(stream
, ptr
[j
], 22, "tiled surface");
701 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
702 MBZ (ptr
[j
], 20, 14);
703 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
708 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
710 stream
->offset
+= len
* sizeof(unsigned);
715 static boolean
i915_debug_packet( struct debug_stream
*stream
)
717 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
720 switch (((cmd
>> 29) & 0x7)) {
722 switch ((cmd
>> 23) & 0x3f) {
724 return debug(stream
, "MI_NOOP", 1);
726 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
728 return debug(stream
, "MI_FLUSH", 1);
730 debug(stream
, "MI_BATCH_BUFFER_END", 1);
733 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
735 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
737 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
743 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
747 switch ((cmd
>> 22) & 0xff) {
749 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
751 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
753 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
757 switch ((cmd
>> 24) & 0x1f) {
759 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
761 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
763 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
765 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
767 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
769 return debug(stream
, "3DSTATE_MODES5", 1);
771 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
773 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
775 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
778 switch((cmd
>> 19) & 0x1f) {
780 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
782 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
784 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
791 switch ((cmd
>> 16) & 0xff) {
793 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
795 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
797 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
799 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
801 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
803 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
805 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
807 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
809 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
811 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
813 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
815 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
817 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
819 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
821 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
823 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
825 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
827 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
835 return debug(stream
, "???", (cmd
& 0xffff) + 1);
837 return debug(stream
, "", 1);
840 if ((cmd
& (1 << 23)) == 0)
841 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
842 else if (cmd
& (1 << 17))
844 if ((cmd
& 0xffff) == 0)
845 return debug_variable_length_prim(stream
);
847 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
850 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
853 return debug(stream
, "", 0);
867 i915_dump_batchbuffer( struct i915_batchbuffer
*batch
)
869 struct debug_stream stream
;
870 unsigned *start
= (unsigned*)batch
->map
;
871 unsigned *end
= (unsigned*)batch
->ptr
;
872 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
873 boolean done
= FALSE
;
876 stream
.ptr
= (char *)start
;
877 stream
.print_addresses
= 0;
879 if (!start
|| !end
) {
880 debug_printf( "\n\nBATCH: ???\n");
884 debug_printf( "\n\nBATCH: (%d)\n", bytes
/ 4);
887 stream
.offset
< bytes
)
889 if (!i915_debug_packet( &stream
))
892 assert(stream
.offset
<= bytes
&&
896 debug_printf( "END-BATCH\n\n\n");