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
));
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); \
223 struct debug_stream
*stream
,
229 if (((dw
) >> (bit
)) & 1) {
232 PRINTF(stream
, "\t\t ");
234 va_start( args
, fmt
);
235 debug_vprintf( fmt
, args
);
238 PRINTF(stream
, "\n");
242 static boolean
debug_load_immediate( struct debug_stream
*stream
,
246 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
247 unsigned bits
= (ptr
[0] >> 4) & 0xff;
250 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
251 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
254 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
255 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
256 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
260 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
261 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
262 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
263 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
268 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
269 for (i
= 0; i
< 8; i
++) {
270 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
272 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
277 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
281 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
282 BITS(stream
, ptr
[j
], 31, 23, "point width");
283 BITS(stream
, ptr
[j
], 22, 19, "line width");
284 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
285 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
286 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
287 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
288 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
289 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
290 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
291 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
292 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
293 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
294 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
295 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
296 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
297 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
298 FLAG(stream
, ptr
[j
], 1, "sprite point");
299 FLAG(stream
, ptr
[j
], 0, "antialiasing");
303 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
304 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
305 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
306 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
307 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
308 FLAG(stream
, ptr
[j
], 24, "fog enable");
309 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
310 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
311 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
312 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
313 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
314 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
315 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
316 FLAG(stream
, ptr
[j
], 1, "color dither enable");
317 FLAG(stream
, ptr
[j
], 0, "logiop enable");
321 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
322 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
323 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
324 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
325 FLAG(stream
, ptr
[j
], 19, "depth test enable");
326 BITS(stream
, ptr
[j
], 18, 16, "depth func");
327 FLAG(stream
, ptr
[j
], 15, "blend enable");
328 BITS(stream
, ptr
[j
], 14, 12, "blend func");
329 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
330 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
331 FLAG(stream
, ptr
[j
], 3, "depth write enable");
332 FLAG(stream
, ptr
[j
], 2, "color write enable");
333 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
338 PRINTF(stream
, "\n");
342 stream
->offset
+= len
* sizeof(unsigned);
349 static boolean
debug_load_indirect( struct debug_stream
*stream
,
353 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
354 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
357 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
358 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
360 for (i
= 0; i
< 6; i
++) {
363 case LI0_STATE_STATIC_INDIRECT
:
364 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
365 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
367 case LI0_STATE_DYNAMIC_INDIRECT
:
368 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
370 case LI0_STATE_SAMPLER
:
371 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
372 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
375 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
376 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
378 case LI0_STATE_PROGRAM
:
379 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
380 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
382 case LI0_STATE_CONSTANTS
:
383 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
384 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
394 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
397 PRINTF(stream
, "\n");
402 stream
->offset
+= len
* sizeof(unsigned);
407 static void BR13( struct debug_stream
*stream
,
410 PRINTF(stream
, "\t0x%08x\n", val
);
411 FLAG(stream
, val
, 30, "clipping enable");
412 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
413 BITS(stream
, val
, 23, 16, "raster op");
414 BITS(stream
, val
, 15, 0, "dest pitch");
418 static void BR22( struct debug_stream
*stream
,
421 PRINTF(stream
, "\t0x%08x\n", val
);
422 BITS(stream
, val
, 31, 16, "dest y1");
423 BITS(stream
, val
, 15, 0, "dest x1");
426 static void BR23( struct debug_stream
*stream
,
429 PRINTF(stream
, "\t0x%08x\n", val
);
430 BITS(stream
, val
, 31, 16, "dest y2");
431 BITS(stream
, val
, 15, 0, "dest x2");
434 static void BR09( struct debug_stream
*stream
,
437 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
440 static void BR26( struct debug_stream
*stream
,
443 PRINTF(stream
, "\t0x%08x\n", val
);
444 BITS(stream
, val
, 31, 16, "src y1");
445 BITS(stream
, val
, 15, 0, "src x1");
448 static void BR11( struct debug_stream
*stream
,
451 PRINTF(stream
, "\t0x%08x\n", val
);
452 BITS(stream
, val
, 15, 0, "src pitch");
455 static void BR12( struct debug_stream
*stream
,
458 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
461 static void BR16( struct debug_stream
*stream
,
464 PRINTF(stream
, "\t0x%08x -- color\n", val
);
467 static boolean
debug_copy_blit( struct debug_stream
*stream
,
471 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
474 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
475 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
477 BR13(stream
, ptr
[j
++]);
478 BR22(stream
, ptr
[j
++]);
479 BR23(stream
, ptr
[j
++]);
480 BR09(stream
, ptr
[j
++]);
481 BR26(stream
, ptr
[j
++]);
482 BR11(stream
, ptr
[j
++]);
483 BR12(stream
, ptr
[j
++]);
485 stream
->offset
+= len
* sizeof(unsigned);
490 static boolean
debug_color_blit( struct debug_stream
*stream
,
494 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
497 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
498 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
500 BR13(stream
, ptr
[j
++]);
501 BR22(stream
, ptr
[j
++]);
502 BR23(stream
, ptr
[j
++]);
503 BR09(stream
, ptr
[j
++]);
504 BR16(stream
, ptr
[j
++]);
506 stream
->offset
+= len
* sizeof(unsigned);
511 static boolean
debug_modes4( struct debug_stream
*stream
,
515 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
518 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
519 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
520 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
521 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
522 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
523 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
524 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
527 stream
->offset
+= len
* sizeof(unsigned);
532 static boolean
debug_map_state( struct debug_stream
*stream
,
536 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
539 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
540 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
543 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
544 BITS(stream
, ptr
[j
], 15, 0, "map mask");
550 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
551 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
552 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
553 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
558 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
559 BITS(stream
, ptr
[j
], 31, 21, "height");
560 BITS(stream
, ptr
[j
], 20, 10, "width");
561 BITS(stream
, ptr
[j
], 9, 7, "surface format");
562 BITS(stream
, ptr
[j
], 6, 3, "texel format");
563 FLAG(stream
, ptr
[j
], 2, "use fence regs");
564 FLAG(stream
, ptr
[j
], 1, "tiled surface");
565 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
569 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
570 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
571 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
572 BITS(stream
, ptr
[j
], 14, 9, "max lod");
573 FLAG(stream
, ptr
[j
], 8, "mip layout right");
574 BITS(stream
, ptr
[j
], 7, 0, "depth");
579 stream
->offset
+= len
* sizeof(unsigned);
584 static boolean
debug_sampler_state( struct debug_stream
*stream
,
588 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
591 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
592 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
595 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
596 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
602 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
603 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
604 FLAG(stream
, ptr
[j
], 30, "planar to packed");
605 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
606 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
607 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
608 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
609 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
610 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
611 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
612 FLAG(stream
, ptr
[j
], 4, "shadow enable");
613 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
614 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
619 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
620 BITS(stream
, ptr
[j
], 31, 24, "min lod");
621 MBZ( ptr
[j
], 23, 18 );
622 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
623 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
624 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
625 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
626 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
627 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
628 FLAG(stream
, ptr
[j
], 5, "normalized coords");
629 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
630 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
634 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
639 stream
->offset
+= len
* sizeof(unsigned);
644 static boolean
debug_dest_vars( struct debug_stream
*stream
,
648 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
651 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
652 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
655 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
656 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
657 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
658 FLAG(stream
, ptr
[j
], 29, "bypass iz");
659 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
660 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
661 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
662 FLAG(stream
, ptr
[j
], 24, "debug dither");
663 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
664 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
665 MBZ (ptr
[j
], 15, 15 );
666 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
667 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
668 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
669 FLAG(stream
, ptr
[j
], 1, "vert line stride");
670 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
674 stream
->offset
+= len
* sizeof(unsigned);
679 static boolean
debug_buf_info( struct debug_stream
*stream
,
683 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
686 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
687 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
690 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
691 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
692 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
693 FLAG(stream
, ptr
[j
], 23, "use fence regs");
694 FLAG(stream
, ptr
[j
], 22, "tiled surface");
695 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
696 MBZ (ptr
[j
], 20, 14);
697 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
702 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
704 stream
->offset
+= len
* sizeof(unsigned);
709 static boolean
i915_debug_packet( struct debug_stream
*stream
)
711 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
714 switch (((cmd
>> 29) & 0x7)) {
716 switch ((cmd
>> 23) & 0x3f) {
718 return debug(stream
, "MI_NOOP", 1);
720 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
722 return debug(stream
, "MI_FLUSH", 1);
724 debug(stream
, "MI_BATCH_BUFFER_END", 1);
727 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
729 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
731 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
737 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
741 switch ((cmd
>> 22) & 0xff) {
743 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
745 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
747 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
751 switch ((cmd
>> 24) & 0x1f) {
753 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
755 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
757 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
759 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
761 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
763 return debug(stream
, "3DSTATE_MODES5", 1);
765 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
767 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
769 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
772 switch((cmd
>> 19) & 0x1f) {
774 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
776 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
778 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
785 switch ((cmd
>> 16) & 0xff) {
787 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
789 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
791 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
793 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
795 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
797 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
799 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
801 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
803 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
805 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
807 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
809 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
811 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
813 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
815 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
817 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
819 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
821 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
829 return debug(stream
, "???", (cmd
& 0xffff) + 1);
831 return debug(stream
, "", 1);
834 if ((cmd
& (1 << 23)) == 0)
835 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
836 else if (cmd
& (1 << 17))
838 if ((cmd
& 0xffff) == 0)
839 return debug_variable_length_prim(stream
);
841 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
844 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
847 return debug(stream
, "", 0);
861 i915_dump_batchbuffer( struct i915_context
*i915
)
863 struct debug_stream stream
;
864 unsigned *start
= 0;/*i915->batch_start;*/
865 unsigned *end
= i915
->winsys
->batch_start( i915
->winsys
, 0, 0 );
866 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
867 boolean done
= FALSE
;
870 stream
.ptr
= (char *)start
;
871 stream
.print_addresses
= 0;
872 stream
.winsys
= i915
->pipe
.winsys
;
874 if (!start
|| !end
) {
875 debug_printf( "\n\nBATCH: ???\n");
879 debug_printf( "\n\nBATCH: (%d)\n", bytes
/ 4);
882 stream
.offset
< bytes
)
884 if (!i915_debug_packet( &stream
))
887 assert(stream
.offset
<= bytes
&&
891 debug_printf( "END-BATCH\n\n\n");