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_screen.h"
31 #include "i915_debug.h"
32 #include "i915_debug_private.h"
33 #include "i915_batch.h"
34 #include "util/u_debug.h"
38 static const struct debug_named_value debug_options
[] = {
39 {"blit", DBG_BLIT
, "Print when using the 2d blitter"},
40 {"emit", DBG_EMIT
, "State emit information"},
41 {"atoms", DBG_ATOMS
, "Print dirty state atoms"},
42 {"flush", DBG_FLUSH
, "Flushing information"},
43 {"texture", DBG_TEXTURE
, "Texture information"},
44 {"constants", DBG_CONSTANTS
, "Constant buffers"},
48 unsigned i915_debug
= 0;
50 void i915_debug_init(struct i915_screen
*screen
)
52 i915_debug
= debug_get_flags_option("I915_DEBUG", debug_options
, 0);
57 /***********************************************************************
63 struct debug_stream
*stream
,
69 va_start( args
, fmt
);
70 debug_vprintf( fmt
, args
);
75 static boolean
debug( struct debug_stream
*stream
, const char *name
, unsigned len
)
78 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
81 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
86 if (stream
->print_addresses
)
87 PRINTF(stream
, "%08x: ", stream
->offset
);
90 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
91 for (i
= 0; i
< len
; i
++)
92 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
95 stream
->offset
+= len
* sizeof(unsigned);
101 static const char *get_prim_name( unsigned val
)
103 switch (val
& PRIM3D_MASK
) {
104 case PRIM3D_TRILIST
: return "TRILIST"; break;
105 case PRIM3D_TRISTRIP
: return "TRISTRIP"; break;
106 case PRIM3D_TRISTRIP_RVRSE
: return "TRISTRIP_RVRSE"; break;
107 case PRIM3D_TRIFAN
: return "TRIFAN"; break;
108 case PRIM3D_POLY
: return "POLY"; break;
109 case PRIM3D_LINELIST
: return "LINELIST"; break;
110 case PRIM3D_LINESTRIP
: return "LINESTRIP"; break;
111 case PRIM3D_RECTLIST
: return "RECTLIST"; break;
112 case PRIM3D_POINTLIST
: return "POINTLIST"; break;
113 case PRIM3D_DIB
: return "DIB"; break;
114 case PRIM3D_CLEAR_RECT
: return "CLEAR_RECT"; break;
115 case PRIM3D_ZONE_INIT
: return "ZONE_INIT"; break;
116 default: return "????"; break;
120 static boolean
debug_prim( struct debug_stream
*stream
, const char *name
,
124 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
125 const char *prim
= get_prim_name( ptr
[0] );
130 PRINTF(stream
, "%s %s (%d dwords):\n", name
, prim
, len
);
131 PRINTF(stream
, "\t0x%08x\n", ptr
[0]);
132 for (i
= 1; i
< len
; i
++) {
134 PRINTF(stream
, "\t0x%08x // %f\n", ptr
[i
], *(float *)&ptr
[i
]);
136 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
140 PRINTF(stream
, "\n");
142 stream
->offset
+= len
* sizeof(unsigned);
150 static boolean
debug_program( struct debug_stream
*stream
, const char *name
, unsigned len
)
152 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
155 PRINTF(stream
, "Error - zero length packet (0x%08x)\n", stream
->ptr
[0]);
160 if (stream
->print_addresses
)
161 PRINTF(stream
, "%08x: ", stream
->offset
);
163 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
164 i915_disassemble_program( stream
, ptr
, len
);
166 stream
->offset
+= len
* sizeof(unsigned);
171 static boolean
debug_chain( struct debug_stream
*stream
, const char *name
, unsigned len
)
173 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
174 unsigned old_offset
= stream
->offset
+ len
* sizeof(unsigned);
177 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
178 for (i
= 0; i
< len
; i
++)
179 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
181 stream
->offset
= ptr
[1] & ~0x3;
183 if (stream
->offset
< old_offset
)
184 PRINTF(stream
, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
185 old_offset
, stream
->offset
);
187 PRINTF(stream
, "\n... skipping from 0x%x --> 0x%x ...\n\n",
188 old_offset
, stream
->offset
);
195 static boolean
debug_variable_length_prim( struct debug_stream
*stream
)
197 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
198 const char *prim
= get_prim_name( ptr
[0] );
201 ushort
*idx
= (ushort
*)(ptr
+1);
202 for (i
= 0; idx
[i
] != 0xffff; i
++)
207 PRINTF(stream
, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim
, i
, len
);
208 for (i
= 0; i
< len
; i
++)
209 PRINTF(stream
, "\t0x%08x\n", ptr
[i
]);
210 PRINTF(stream
, "\n");
212 stream
->offset
+= len
* sizeof(unsigned);
219 struct debug_stream
*stream
,
227 unsigned himask
= ~0UL >> (31 - (hi
));
229 PRINTF(stream
, "\t\t ");
231 va_start( args
, fmt
);
232 debug_vprintf( fmt
, args
);
235 PRINTF(stream
, ": 0x%x\n", ((dw
) & himask
) >> (lo
));
239 #define MBZ( dw, hi, lo) do { \
240 unsigned x = (dw) >> (lo); \
241 unsigned lomask = (1 << (lo)) - 1; \
243 himask = (1UL << (hi)) - 1; \
244 assert ((x & himask & ~lomask) == 0); \
247 #define MBZ( dw, hi, lo) do { \
253 struct debug_stream
*stream
,
259 if (((dw
) >> (bit
)) & 1) {
262 PRINTF(stream
, "\t\t ");
264 va_start( args
, fmt
);
265 debug_vprintf( fmt
, args
);
268 PRINTF(stream
, "\n");
272 static boolean
debug_load_immediate( struct debug_stream
*stream
,
276 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
277 unsigned bits
= (ptr
[0] >> 4) & 0xff;
280 PRINTF(stream
, "%s (%d dwords, flags: %x):\n", name
, len
, bits
);
281 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
284 PRINTF(stream
, "\t LIS0: 0x%08x\n", ptr
[j
]);
285 PRINTF(stream
, "\t vb address: 0x%08x\n", (ptr
[j
] & ~0x3));
286 BITS(stream
, ptr
[j
], 0, 0, "vb invalidate disable");
290 PRINTF(stream
, "\t LIS1: 0x%08x\n", ptr
[j
]);
291 BITS(stream
, ptr
[j
], 29, 24, "vb dword width");
292 BITS(stream
, ptr
[j
], 21, 16, "vb dword pitch");
293 BITS(stream
, ptr
[j
], 15, 0, "vb max index");
298 PRINTF(stream
, "\t LIS2: 0x%08x\n", ptr
[j
]);
299 for (i
= 0; i
< 8; i
++) {
300 unsigned tc
= (ptr
[j
] >> (i
* 4)) & 0xf;
302 BITS(stream
, tc
, 3, 0, "tex coord %d", i
);
307 PRINTF(stream
, "\t LIS3: 0x%08x\n", ptr
[j
]);
311 PRINTF(stream
, "\t LIS4: 0x%08x\n", ptr
[j
]);
312 BITS(stream
, ptr
[j
], 31, 23, "point width");
313 BITS(stream
, ptr
[j
], 22, 19, "line width");
314 FLAG(stream
, ptr
[j
], 18, "alpha flatshade");
315 FLAG(stream
, ptr
[j
], 17, "fog flatshade");
316 FLAG(stream
, ptr
[j
], 16, "spec flatshade");
317 FLAG(stream
, ptr
[j
], 15, "rgb flatshade");
318 BITS(stream
, ptr
[j
], 14, 13, "cull mode");
319 FLAG(stream
, ptr
[j
], 12, "vfmt: point width");
320 FLAG(stream
, ptr
[j
], 11, "vfmt: specular/fog");
321 FLAG(stream
, ptr
[j
], 10, "vfmt: rgba");
322 FLAG(stream
, ptr
[j
], 9, "vfmt: depth offset");
323 BITS(stream
, ptr
[j
], 8, 6, "vfmt: position (2==xyzw)");
324 FLAG(stream
, ptr
[j
], 5, "force dflt diffuse");
325 FLAG(stream
, ptr
[j
], 4, "force dflt specular");
326 FLAG(stream
, ptr
[j
], 3, "local depth offset enable");
327 FLAG(stream
, ptr
[j
], 2, "vfmt: fp32 fog coord");
328 FLAG(stream
, ptr
[j
], 1, "sprite point");
329 FLAG(stream
, ptr
[j
], 0, "antialiasing");
333 PRINTF(stream
, "\t LIS5: 0x%08x\n", ptr
[j
]);
334 BITS(stream
, ptr
[j
], 31, 28, "rgba write disables");
335 FLAG(stream
, ptr
[j
], 27, "force dflt point width");
336 FLAG(stream
, ptr
[j
], 26, "last pixel enable");
337 FLAG(stream
, ptr
[j
], 25, "global z offset enable");
338 FLAG(stream
, ptr
[j
], 24, "fog enable");
339 BITS(stream
, ptr
[j
], 23, 16, "stencil ref");
340 BITS(stream
, ptr
[j
], 15, 13, "stencil test");
341 BITS(stream
, ptr
[j
], 12, 10, "stencil fail op");
342 BITS(stream
, ptr
[j
], 9, 7, "stencil pass z fail op");
343 BITS(stream
, ptr
[j
], 6, 4, "stencil pass z pass op");
344 FLAG(stream
, ptr
[j
], 3, "stencil write enable");
345 FLAG(stream
, ptr
[j
], 2, "stencil test enable");
346 FLAG(stream
, ptr
[j
], 1, "color dither enable");
347 FLAG(stream
, ptr
[j
], 0, "logiop enable");
351 PRINTF(stream
, "\t LIS6: 0x%08x\n", ptr
[j
]);
352 FLAG(stream
, ptr
[j
], 31, "alpha test enable");
353 BITS(stream
, ptr
[j
], 30, 28, "alpha func");
354 BITS(stream
, ptr
[j
], 27, 20, "alpha ref");
355 FLAG(stream
, ptr
[j
], 19, "depth test enable");
356 BITS(stream
, ptr
[j
], 18, 16, "depth func");
357 FLAG(stream
, ptr
[j
], 15, "blend enable");
358 BITS(stream
, ptr
[j
], 14, 12, "blend func");
359 BITS(stream
, ptr
[j
], 11, 8, "blend src factor");
360 BITS(stream
, ptr
[j
], 7, 4, "blend dst factor");
361 FLAG(stream
, ptr
[j
], 3, "depth write enable");
362 FLAG(stream
, ptr
[j
], 2, "color write enable");
363 BITS(stream
, ptr
[j
], 1, 0, "provoking vertex");
368 PRINTF(stream
, "\n");
372 stream
->offset
+= len
* sizeof(unsigned);
379 static boolean
debug_load_indirect( struct debug_stream
*stream
,
383 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
384 unsigned bits
= (ptr
[0] >> 8) & 0x3f;
387 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
388 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
390 for (i
= 0; i
< 6; i
++) {
393 case LI0_STATE_STATIC_INDIRECT
:
394 PRINTF(stream
, " STATIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
395 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
397 case LI0_STATE_DYNAMIC_INDIRECT
:
398 PRINTF(stream
, " DYNAMIC: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
400 case LI0_STATE_SAMPLER
:
401 PRINTF(stream
, " SAMPLER: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
402 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
405 PRINTF(stream
, " MAP: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
406 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
408 case LI0_STATE_PROGRAM
:
409 PRINTF(stream
, " PROGRAM: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
410 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
412 case LI0_STATE_CONSTANTS
:
413 PRINTF(stream
, " CONSTANTS: 0x%08x | %x\n", ptr
[j
]&~3, ptr
[j
]&3); j
++;
414 PRINTF(stream
, " 0x%08x\n", ptr
[j
++]);
424 PRINTF(stream
, "\t DUMMY: 0x%08x\n", ptr
[j
++]);
427 PRINTF(stream
, "\n");
432 stream
->offset
+= len
* sizeof(unsigned);
437 static void BR13( struct debug_stream
*stream
,
440 PRINTF(stream
, "\t0x%08x\n", val
);
441 FLAG(stream
, val
, 30, "clipping enable");
442 BITS(stream
, val
, 25, 24, "color depth (3==32bpp)");
443 BITS(stream
, val
, 23, 16, "raster op");
444 BITS(stream
, val
, 15, 0, "dest pitch");
448 static void BR22( struct debug_stream
*stream
,
451 PRINTF(stream
, "\t0x%08x\n", val
);
452 BITS(stream
, val
, 31, 16, "dest y1");
453 BITS(stream
, val
, 15, 0, "dest x1");
456 static void BR23( struct debug_stream
*stream
,
459 PRINTF(stream
, "\t0x%08x\n", val
);
460 BITS(stream
, val
, 31, 16, "dest y2");
461 BITS(stream
, val
, 15, 0, "dest x2");
464 static void BR09( struct debug_stream
*stream
,
467 PRINTF(stream
, "\t0x%08x -- dest address\n", val
);
470 static void BR26( struct debug_stream
*stream
,
473 PRINTF(stream
, "\t0x%08x\n", val
);
474 BITS(stream
, val
, 31, 16, "src y1");
475 BITS(stream
, val
, 15, 0, "src x1");
478 static void BR11( struct debug_stream
*stream
,
481 PRINTF(stream
, "\t0x%08x\n", val
);
482 BITS(stream
, val
, 15, 0, "src pitch");
485 static void BR12( struct debug_stream
*stream
,
488 PRINTF(stream
, "\t0x%08x -- src address\n", val
);
491 static void BR16( struct debug_stream
*stream
,
494 PRINTF(stream
, "\t0x%08x -- color\n", val
);
497 static boolean
debug_copy_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 BR26(stream
, ptr
[j
++]);
512 BR11(stream
, ptr
[j
++]);
513 BR12(stream
, ptr
[j
++]);
515 stream
->offset
+= len
* sizeof(unsigned);
520 static boolean
debug_color_blit( struct debug_stream
*stream
,
524 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
527 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
528 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
530 BR13(stream
, ptr
[j
++]);
531 BR22(stream
, ptr
[j
++]);
532 BR23(stream
, ptr
[j
++]);
533 BR09(stream
, ptr
[j
++]);
534 BR16(stream
, ptr
[j
++]);
536 stream
->offset
+= len
* sizeof(unsigned);
541 static boolean
debug_modes4( struct debug_stream
*stream
,
545 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
548 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
549 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
550 BITS(stream
, ptr
[j
], 21, 18, "logicop func");
551 FLAG(stream
, ptr
[j
], 17, "stencil test mask modify-enable");
552 FLAG(stream
, ptr
[j
], 16, "stencil write mask modify-enable");
553 BITS(stream
, ptr
[j
], 15, 8, "stencil test mask");
554 BITS(stream
, ptr
[j
], 7, 0, "stencil write mask");
557 stream
->offset
+= len
* sizeof(unsigned);
562 static boolean
debug_map_state( struct debug_stream
*stream
,
566 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
569 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
570 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
573 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
574 BITS(stream
, ptr
[j
], 15, 0, "map mask");
580 PRINTF(stream
, "\t TMn.0: 0x%08x\n", ptr
[j
]);
581 PRINTF(stream
, "\t map address: 0x%08x\n", (ptr
[j
] & ~0x3));
582 FLAG(stream
, ptr
[j
], 1, "vertical line stride");
583 FLAG(stream
, ptr
[j
], 0, "vertical line stride offset");
588 PRINTF(stream
, "\t TMn.1: 0x%08x\n", ptr
[j
]);
589 BITS(stream
, ptr
[j
], 31, 21, "height");
590 BITS(stream
, ptr
[j
], 20, 10, "width");
591 BITS(stream
, ptr
[j
], 9, 7, "surface format");
592 BITS(stream
, ptr
[j
], 6, 3, "texel format");
593 FLAG(stream
, ptr
[j
], 2, "use fence regs");
594 FLAG(stream
, ptr
[j
], 1, "tiled surface");
595 FLAG(stream
, ptr
[j
], 0, "tile walk ymajor");
599 PRINTF(stream
, "\t TMn.2: 0x%08x\n", ptr
[j
]);
600 BITS(stream
, ptr
[j
], 31, 21, "dword pitch");
601 BITS(stream
, ptr
[j
], 20, 15, "cube face enables");
602 BITS(stream
, ptr
[j
], 14, 9, "max lod");
603 FLAG(stream
, ptr
[j
], 8, "mip layout right");
604 BITS(stream
, ptr
[j
], 7, 0, "depth");
609 stream
->offset
+= len
* sizeof(unsigned);
614 static boolean
debug_sampler_state( struct debug_stream
*stream
,
618 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
621 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
622 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
625 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
626 BITS(stream
, ptr
[j
], 15, 0, "sampler mask");
632 PRINTF(stream
, "\t TSn.0: 0x%08x\n", ptr
[j
]);
633 FLAG(stream
, ptr
[j
], 31, "reverse gamma");
634 FLAG(stream
, ptr
[j
], 30, "planar to packed");
635 FLAG(stream
, ptr
[j
], 29, "yuv->rgb");
636 BITS(stream
, ptr
[j
], 28, 27, "chromakey index");
637 BITS(stream
, ptr
[j
], 26, 22, "base mip level");
638 BITS(stream
, ptr
[j
], 21, 20, "mip mode filter");
639 BITS(stream
, ptr
[j
], 19, 17, "mag mode filter");
640 BITS(stream
, ptr
[j
], 16, 14, "min mode filter");
641 BITS(stream
, ptr
[j
], 13, 5, "lod bias (s4.4)");
642 FLAG(stream
, ptr
[j
], 4, "shadow enable");
643 FLAG(stream
, ptr
[j
], 3, "max-aniso-4");
644 BITS(stream
, ptr
[j
], 2, 0, "shadow func");
649 PRINTF(stream
, "\t TSn.1: 0x%08x\n", ptr
[j
]);
650 BITS(stream
, ptr
[j
], 31, 24, "min lod");
651 MBZ( ptr
[j
], 23, 18 );
652 FLAG(stream
, ptr
[j
], 17, "kill pixel enable");
653 FLAG(stream
, ptr
[j
], 16, "keyed tex filter mode");
654 FLAG(stream
, ptr
[j
], 15, "chromakey enable");
655 BITS(stream
, ptr
[j
], 14, 12, "tcx wrap mode");
656 BITS(stream
, ptr
[j
], 11, 9, "tcy wrap mode");
657 BITS(stream
, ptr
[j
], 8, 6, "tcz wrap mode");
658 FLAG(stream
, ptr
[j
], 5, "normalized coords");
659 BITS(stream
, ptr
[j
], 4, 1, "map (surface) index");
660 FLAG(stream
, ptr
[j
], 0, "EAST deinterlacer enable");
664 PRINTF(stream
, "\t TSn.2: 0x%08x (default color)\n", ptr
[j
]);
669 stream
->offset
+= len
* sizeof(unsigned);
674 static boolean
debug_dest_vars( struct debug_stream
*stream
,
678 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
681 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
682 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
685 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
686 FLAG(stream
, ptr
[j
], 31, "early classic ztest");
687 FLAG(stream
, ptr
[j
], 30, "opengl tex default color");
688 FLAG(stream
, ptr
[j
], 29, "bypass iz");
689 FLAG(stream
, ptr
[j
], 28, "lod preclamp");
690 BITS(stream
, ptr
[j
], 27, 26, "dither pattern");
691 FLAG(stream
, ptr
[j
], 25, "linear gamma blend");
692 FLAG(stream
, ptr
[j
], 24, "debug dither");
693 BITS(stream
, ptr
[j
], 23, 20, "dstorg x");
694 BITS(stream
, ptr
[j
], 19, 16, "dstorg y");
695 MBZ (ptr
[j
], 15, 15 );
696 BITS(stream
, ptr
[j
], 14, 12, "422 write select");
697 BITS(stream
, ptr
[j
], 11, 8, "cbuf format");
698 BITS(stream
, ptr
[j
], 3, 2, "zbuf format");
699 FLAG(stream
, ptr
[j
], 1, "vert line stride");
700 FLAG(stream
, ptr
[j
], 1, "vert line stride offset");
704 stream
->offset
+= len
* sizeof(unsigned);
709 static boolean
debug_buf_info( struct debug_stream
*stream
,
713 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
716 PRINTF(stream
, "%s (%d dwords):\n", name
, len
);
717 PRINTF(stream
, "\t0x%08x\n", ptr
[j
++]);
720 PRINTF(stream
, "\t0x%08x\n", ptr
[j
]);
721 BITS(stream
, ptr
[j
], 28, 28, "aux buffer id");
722 BITS(stream
, ptr
[j
], 27, 24, "buffer id (7=depth, 3=back)");
723 FLAG(stream
, ptr
[j
], 23, "use fence regs");
724 FLAG(stream
, ptr
[j
], 22, "tiled surface");
725 FLAG(stream
, ptr
[j
], 21, "tile walk ymajor");
726 MBZ (ptr
[j
], 20, 14);
727 BITS(stream
, ptr
[j
], 13, 2, "dword pitch");
732 PRINTF(stream
, "\t0x%08x -- buffer base address\n", ptr
[j
++]);
734 stream
->offset
+= len
* sizeof(unsigned);
739 static boolean
i915_debug_packet( struct debug_stream
*stream
)
741 unsigned *ptr
= (unsigned *)(stream
->ptr
+ stream
->offset
);
744 switch (((cmd
>> 29) & 0x7)) {
746 switch ((cmd
>> 23) & 0x3f) {
748 return debug(stream
, "MI_NOOP", 1);
750 return debug(stream
, "MI_WAIT_FOR_EVENT", 1);
752 return debug(stream
, "MI_FLUSH", 1);
754 debug(stream
, "MI_BATCH_BUFFER_END", 1);
757 return debug(stream
, "MI_LOAD_REGISTER_IMM", 3);
759 return debug_chain(stream
, "MI_BATCH_BUFFER_START", 2);
761 (void)debug(stream
, "UNKNOWN 0x0 case!", 1);
767 (void) debug(stream
, "UNKNOWN 0x1 case!", 1);
771 switch ((cmd
>> 22) & 0xff) {
773 return debug_color_blit(stream
, "XY_COLOR_BLT", (cmd
& 0xff) + 2);
775 return debug_copy_blit(stream
, "XY_SRC_COPY_BLT", (cmd
& 0xff) + 2);
777 return debug(stream
, "blit command", (cmd
& 0xff) + 2);
781 switch ((cmd
>> 24) & 0x1f) {
783 return debug(stream
, "3DSTATE_ANTI_ALIASING", 1);
785 return debug(stream
, "3DSTATE_RASTERIZATION_RULES", 1);
787 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
789 return debug(stream
, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
791 return debug(stream
, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
793 return debug(stream
, "3DSTATE_MODES5", 1);
795 return debug_modes4(stream
, "3DSTATE_MODES4", 1);
797 return debug(stream
, "3DSTATE_FOG_COLOR", 1);
799 return debug(stream
, "3DSTATE_COORD_SET_BINDINGS", 1);
802 switch((cmd
>> 19) & 0x1f) {
804 return debug(stream
, "3DSTATE_SCISSOR_ENABLE", 1);
806 return debug(stream
, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
808 (void) debug(stream
, "UNKNOWN 0x1c case!", 1);
815 switch ((cmd
>> 16) & 0xff) {
817 return debug_map_state(stream
, "3DSTATE_MAP_STATE", (cmd
& 0x1f) + 2);
819 return debug_sampler_state(stream
, "3DSTATE_SAMPLER_STATE", (cmd
& 0x1f) + 2);
821 return debug_load_immediate(stream
, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd
& 0xf) + 2);
823 return debug_program(stream
, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd
& 0x1ff) + 2);
825 return debug(stream
, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd
& 0xff) + 2);
827 return debug_load_indirect(stream
, "3DSTATE_LOAD_INDIRECT", (cmd
& 0xff) + 2);
829 return debug(stream
, "3DSTATE_DRAWING_RECTANGLE", (cmd
& 0xffff) + 2);
831 return debug(stream
, "3DSTATE_SCISSOR_RECTANGLE", (cmd
& 0xffff) + 2);
833 return debug(stream
, "3DSTATE_SPAN_STIPPLE", (cmd
& 0xffff) + 2);
835 return debug_dest_vars(stream
, "3DSTATE_DEST_BUFFER_VARS", (cmd
& 0xffff) + 2);
837 return debug(stream
, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd
& 0xffff) + 2);
839 return debug(stream
, "3DSTATE_FOG_MODE", (cmd
& 0xffff) + 2);
841 return debug_buf_info(stream
, "3DSTATE_BUFFER_INFO", (cmd
& 0xffff) + 2);
843 return debug(stream
, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd
& 0xffff) + 2);
845 return debug(stream
, "3DSTATE_DEFAULT_Z", (cmd
& 0xffff) + 2);
847 return debug(stream
, "3DSTATE_DEFAULT_DIFFUSE", (cmd
& 0xffff) + 2);
849 return debug(stream
, "3DSTATE_DEFAULT_SPECULAR", (cmd
& 0xffff) + 2);
851 return debug(stream
, "3DSTATE_CLEAR_PARAMETERS", (cmd
& 0xffff) + 2);
859 return debug(stream
, "???", (cmd
& 0xffff) + 1);
861 return debug(stream
, "", 1);
864 if ((cmd
& (1 << 23)) == 0)
865 return debug_prim(stream
, "3DPRIM (inline)", 1, (cmd
& 0x1ffff) + 2);
866 else if (cmd
& (1 << 17))
868 if ((cmd
& 0xffff) == 0)
869 return debug_variable_length_prim(stream
);
871 return debug_prim(stream
, "3DPRIM (indexed)", 0, (((cmd
& 0xffff) + 1) / 2) + 1);
874 return debug_prim(stream
, "3DPRIM (indirect sequential)", 0, 2);
877 return debug(stream
, "", 0);
892 i915_dump_batchbuffer( struct i915_winsys_batchbuffer
*batch
)
894 struct debug_stream stream
;
895 unsigned *start
= (unsigned*)batch
->map
;
896 unsigned *end
= (unsigned*)batch
->ptr
;
897 unsigned long bytes
= (unsigned long) (end
- start
) * 4;
898 boolean done
= FALSE
;
901 stream
.ptr
= (char *)start
;
902 stream
.print_addresses
= 0;
904 if (!start
|| !end
) {
905 debug_printf( "\n\nBATCH: ???\n");
909 debug_printf( "\n\nBATCH: (%d)\n", (int)bytes
/ 4);
912 stream
.offset
< bytes
)
914 if (!i915_debug_packet( &stream
))
917 assert(stream
.offset
<= bytes
&&
921 debug_printf( "END-BATCH\n\n\n");
926 /***********************************************************************
927 * Dirty state atom dumping
931 i915_dump_dirty(struct i915_context
*i915
, const char *func
)
937 {I915_NEW_VIEWPORT
, "viewport"},
938 {I915_NEW_RASTERIZER
, "rasterizer"},
940 {I915_NEW_BLEND
, "blend"},
941 {I915_NEW_CLIP
, "clip"},
942 {I915_NEW_SCISSOR
, "scissor"},
943 {I915_NEW_STIPPLE
, "stipple"},
944 {I915_NEW_FRAMEBUFFER
, "framebuffer"},
945 {I915_NEW_ALPHA_TEST
, "alpha_test"},
946 {I915_NEW_DEPTH_STENCIL
, "depth_stencil"},
947 {I915_NEW_SAMPLER
, "sampler"},
948 {I915_NEW_SAMPLER_VIEW
, "sampler_view"},
949 {I915_NEW_CONSTANTS
, "constants"},
950 {I915_NEW_VBO
, "vbo"},
956 debug_printf("%s: ", func
);
957 for (i
= 0; l
[i
].name
; i
++)
958 if (i915
->dirty
& l
[i
].dirty
)
959 debug_printf("%s ", l
[i
].name
);
964 i915_dump_hardware_dirty(struct i915_context
*i915
, const char *func
)
970 {I915_HW_STATIC
, "static"},
971 {I915_HW_DYNAMIC
, "dynamic"},
972 {I915_HW_SAMPLER
, "sampler"},
973 {I915_HW_MAP
, "map"},
974 {I915_HW_PROGRAM
, "program"},
975 {I915_HW_CONSTANTS
, "constants"},
976 {I915_HW_IMMEDIATE
, "immediate"},
977 {I915_HW_INVARIENT
, "invarient"},
982 debug_printf("%s: ", func
);
983 for (i
= 0; l
[i
].name
; i
++)
984 if (i915
->hardware_dirty
& l
[i
].dirty
)
985 debug_printf("%s ", l
[i
].name
);