2 * Copyright © 2009-2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
33 #include "intel_chipset.h"
34 #include "intel_bufmgr.h"
36 /* Struct for tracking drm_intel_decode state. */
37 struct drm_intel_decode {
38 /** stdio file where the output should land. Defaults to stdout. */
45 * Shorthand device identifier: 3 is 915, 4 is 965, 5 is
50 /** GPU address of the start of the current packet. */
52 /** CPU virtual address of the start of the current packet. */
54 /** DWORDs of remaining batchbuffer data starting from the packet. */
57 /** GPU address of the start of the batchbuffer data. */
58 uint32_t base_hw_offset;
59 /** CPU Virtual address of the start of the batchbuffer data. */
61 /** Number of DWORDs of batchbuffer data. */
65 * GPU head and tail pointers, which will be noted in the dump, or ~0.
71 * Whether to dump the dwords after MI_BATCHBUFFER_END.
73 * This sometimes provides clues in corrupted batchbuffers,
74 * and is used by the intel-gpu-tools.
82 static uint32_t saved_s2 = 0, saved_s4 = 0;
83 static char saved_s2_set = 0, saved_s4_set = 0;
84 static uint32_t head_offset = 0xffffffff; /* undefined */
85 static uint32_t tail_offset = 0xffffffff; /* undefined */
88 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
91 #define BUFFER_FAIL(_count, _len, _name) do { \
92 fprintf(out, "Buffer size too small in %s (%d < %d)\n", \
93 (_name), (_count), (_len)); \
97 static float int_as_float(uint32_t intval)
108 static void DRM_PRINTFLIKE(3, 4)
109 instr_out(struct drm_intel_decode *ctx, unsigned int index,
110 const char *fmt, ...)
113 const char *parseinfo;
114 uint32_t offset = ctx->hw_offset + index * 4;
116 if (index > ctx->count) {
117 if (!ctx->overflowed) {
118 fprintf(out, "ERROR: Decode attempted to continue beyond end of batchbuffer\n");
119 ctx->overflowed = true;
124 if (offset == head_offset)
126 else if (offset == tail_offset)
131 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
132 ctx->data[index], index == 0 ? "" : " ");
134 vfprintf(out, fmt, va);
139 decode_MI_SET_CONTEXT(struct drm_intel_decode *ctx)
141 uint32_t data = ctx->data[1];
145 instr_out(ctx, 0, "MI_SET_CONTEXT\n");
146 instr_out(ctx, 1, "gtt offset = 0x%x%s%s\n",
148 data & (1<<1)? ", Force Restore": "",
149 data & (1<<0)? ", Restore Inhibit": "");
155 decode_MI_WAIT_FOR_EVENT(struct drm_intel_decode *ctx)
159 uint32_t data = ctx->data[0];
166 switch ((data >> cc_shift) & 0x1f) {
168 cc_wait = ", cc wait 1";
171 cc_wait = ", cc wait 2";
174 cc_wait = ", cc wait 3";
177 cc_wait = ", cc wait 4";
180 cc_wait = ", cc wait 4";
188 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
189 data & (1<<18)? ", pipe B start vblank wait": "",
190 data & (1<<17)? ", pipe A start vblank wait": "",
191 data & (1<<16)? ", overlay flip pending wait": "",
192 data & (1<<14)? ", pipe B hblank wait": "",
193 data & (1<<13)? ", pipe A hblank wait": "",
195 data & (1<<8)? ", plane C pending flip wait": "",
196 data & (1<<7)? ", pipe B vblank wait": "",
197 data & (1<<6)? ", plane B pending flip wait": "",
198 data & (1<<5)? ", pipe B scan line wait": "",
199 data & (1<<4)? ", fbc idle wait": "",
200 data & (1<<3)? ", pipe A vblank wait": "",
201 data & (1<<2)? ", plane A pending flip wait": "",
202 data & (1<<1)? ", plane A scan line wait": "");
204 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s\n",
205 data & (1<<20)? ", sprite C pending flip wait": "", /* ivb */
207 data & (1<<13)? ", pipe B hblank wait": "",
208 data & (1<<11)? ", pipe B vblank wait": "",
209 data & (1<<10)? ", sprite B pending flip wait": "",
210 data & (1<<9)? ", plane B pending flip wait": "",
211 data & (1<<8)? ", plane B scan line wait": "",
212 data & (1<<5)? ", pipe A hblank wait": "",
213 data & (1<<3)? ", pipe A vblank wait": "",
214 data & (1<<2)? ", sprite A pending flip wait": "",
215 data & (1<<1)? ", plane A pending flip wait": "",
216 data & (1<<0)? ", plane A scan line wait": "");
223 decode_mi(struct drm_intel_decode *ctx)
225 unsigned int opcode, len = -1;
226 const char *post_sync_op = "";
227 uint32_t *data = ctx->data;
232 unsigned int min_len;
233 unsigned int max_len;
235 int (*func)(struct drm_intel_decode *ctx);
237 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
238 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
239 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
240 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
241 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
242 { 0x04, 0, 1, 1, "MI_FLUSH" },
243 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
244 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
245 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
246 { 0x00, 0, 1, 1, "MI_NOOP" },
247 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
248 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
249 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT", decode_MI_SET_CONTEXT },
250 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
251 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
252 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
253 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
254 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT", decode_MI_WAIT_FOR_EVENT },
255 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
256 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
257 { 0x28, 0x3f, 3, 3, "MI_REPORT_PERF_COUNT" },
258 { 0x29, 0xff, 3, 3, "MI_LOAD_REGISTER_MEM" },
259 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
260 }, *opcode_mi = NULL;
262 /* check instruction length */
263 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
265 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
267 if (opcodes_mi[opcode].max_len > 1) {
269 (data[0] & opcodes_mi[opcode].len_mask) + 2;
270 if (len < opcodes_mi[opcode].min_len
271 || len > opcodes_mi[opcode].max_len) {
273 "Bad length (%d) in %s, [%d, %d]\n",
274 len, opcodes_mi[opcode].name,
275 opcodes_mi[opcode].min_len,
276 opcodes_mi[opcode].max_len);
279 opcode_mi = &opcodes_mi[opcode];
284 if (opcode_mi && opcode_mi->func)
285 return opcode_mi->func(ctx);
287 switch ((data[0] & 0x1f800000) >> 23) {
289 instr_out(ctx, 0, "MI_BATCH_BUFFER_END\n");
292 instr_out(ctx, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
293 data[0] & (1 << 22) ? " global gtt," : "",
294 data[0] & (1 << 21) ? " update semaphore," : "",
295 data[0] & (1 << 20) ? " compare semaphore," : "",
296 data[0] & (1 << 18) ? " use compare reg" : "",
297 (data[0] & (0x3 << 16)) >> 16);
298 instr_out(ctx, 1, "value\n");
299 instr_out(ctx, 2, "address\n");
302 instr_out(ctx, 0, "MI_STORE_DATA_INDEX%s\n",
303 data[0] & (1 << 21) ? " use per-process HWS," : "");
304 instr_out(ctx, 1, "index\n");
305 instr_out(ctx, 2, "dword\n");
307 instr_out(ctx, 3, "upper dword\n");
310 if (data[0] & (1 << 22))
312 "MI_NOOP write NOPID reg, val=0x%x\n",
313 data[0] & ((1 << 22) - 1));
315 instr_out(ctx, 0, "MI_NOOP\n");
318 switch (data[0] & (0x3 << 14)) {
320 post_sync_op = "no write";
323 post_sync_op = "write data";
326 post_sync_op = "reserved";
329 post_sync_op = "write TIMESTAMP";
333 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
334 data[0] & (1 << 22) ?
335 " enable protected mem (BCS-only)," : "",
336 data[0] & (1 << 21) ? " store in hws," : "",
337 data[0] & (1 << 18) ? " invalidate tlb," : "",
338 data[0] & (1 << 17) ? " flush gfdt," : "",
340 data[0] & (1 << 8) ? " enable notify interrupt," : "",
342 " invalidate video state (BCS-only)," : "");
343 if (data[0] & (1 << 21))
344 instr_out(ctx, 1, "hws index\n");
346 instr_out(ctx, 1, "address\n");
347 instr_out(ctx, 2, "dword\n");
349 instr_out(ctx, 3, "upper dword\n");
353 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
355 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
358 instr_out(ctx, 0, "%s\n",
359 opcodes_mi[opcode].name);
360 for (i = 1; i < len; i++) {
361 instr_out(ctx, i, "dword %d\n", i);
368 instr_out(ctx, 0, "MI UNKNOWN\n");
373 decode_2d_br00(struct drm_intel_decode *ctx, const char *cmd)
376 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
378 (ctx->data[0] & (1 << 20)) ? "en" : "dis",
379 (ctx->data[0] & (1 << 21)) ? "en" : "dis",
380 (ctx->data[0] >> 15) & 1,
381 (ctx->data[0] >> 11) & 1);
385 decode_2d_br01(struct drm_intel_decode *ctx)
388 switch ((ctx->data[1] >> 24) & 0x3) {
404 "format %s, pitch %d, rop 0x%02x, "
405 "clipping %sabled, %s%s \n",
407 (short)(ctx->data[1] & 0xffff),
408 (ctx->data[1] >> 16) & 0xff,
409 ctx->data[1] & (1 << 30) ? "en" : "dis",
410 ctx->data[1] & (1 << 31) ? "solid pattern enabled, " : "",
411 ctx->data[1] & (1 << 31) ?
412 "mono pattern transparency enabled, " : "");
417 decode_2d(struct drm_intel_decode *ctx)
419 unsigned int opcode, len;
420 uint32_t *data = ctx->data;
424 unsigned int min_len;
425 unsigned int max_len;
428 { 0x40, 5, 5, "COLOR_BLT" },
429 { 0x43, 6, 6, "SRC_COPY_BLT" },
430 { 0x01, 8, 8, "XY_SETUP_BLT" },
431 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
432 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
433 { 0x24, 2, 2, "XY_PIXEL_BLT" },
434 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
435 { 0x26, 4, 4, "Y_TEXT_BLT" },
436 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
437 { 0x50, 6, 6, "XY_COLOR_BLT" },
438 { 0x51, 6, 6, "XY_PAT_BLT" },
439 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
440 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
441 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
442 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
443 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
444 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
445 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
446 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
447 { 0x55, 9, 9, "XY_FULL_BLT" },
448 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
449 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
450 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
451 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
452 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
455 switch ((data[0] & 0x1fc00000) >> 22) {
458 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
459 (data[0] >> 12) & 0x8,
460 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
462 len = (data[0] & 0x000000ff) + 2;
464 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
466 instr_out(ctx, 1, "dest (%d,%d)\n",
467 data[1] & 0xffff, data[1] >> 16);
468 instr_out(ctx, 2, "dest (%d,%d)\n",
469 data[2] & 0xffff, data[2] >> 16);
472 decode_2d_br00(ctx, "XY_SETUP_BLT");
474 len = (data[0] & 0x000000ff) + 2;
476 fprintf(out, "Bad count in XY_SETUP_BLT\n");
479 instr_out(ctx, 2, "cliprect (%d,%d)\n",
480 data[2] & 0xffff, data[2] >> 16);
481 instr_out(ctx, 3, "cliprect (%d,%d)\n",
482 data[3] & 0xffff, data[3] >> 16);
483 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
485 instr_out(ctx, 5, "setup background color\n");
486 instr_out(ctx, 6, "setup foreground color\n");
487 instr_out(ctx, 7, "color pattern offset\n");
490 decode_2d_br00(ctx, "XY_SETUP_CLIP_BLT");
492 len = (data[0] & 0x000000ff) + 2;
494 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
496 instr_out(ctx, 1, "cliprect (%d,%d)\n",
497 data[1] & 0xffff, data[2] >> 16);
498 instr_out(ctx, 2, "cliprect (%d,%d)\n",
499 data[2] & 0xffff, data[3] >> 16);
502 decode_2d_br00(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT");
504 len = (data[0] & 0x000000ff) + 2;
507 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
510 instr_out(ctx, 2, "cliprect (%d,%d)\n",
511 data[2] & 0xffff, data[2] >> 16);
512 instr_out(ctx, 3, "cliprect (%d,%d)\n",
513 data[3] & 0xffff, data[3] >> 16);
514 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
516 instr_out(ctx, 5, "setup background color\n");
517 instr_out(ctx, 6, "setup foreground color\n");
518 instr_out(ctx, 7, "mono pattern dw0\n");
519 instr_out(ctx, 8, "mono pattern dw1\n");
522 decode_2d_br00(ctx, "XY_COLOR_BLT");
524 len = (data[0] & 0x000000ff) + 2;
526 fprintf(out, "Bad count in XY_COLOR_BLT\n");
529 instr_out(ctx, 2, "(%d,%d)\n",
530 data[2] & 0xffff, data[2] >> 16);
531 instr_out(ctx, 3, "(%d,%d)\n",
532 data[3] & 0xffff, data[3] >> 16);
533 instr_out(ctx, 4, "offset 0x%08x\n", data[4]);
534 instr_out(ctx, 5, "color\n");
537 decode_2d_br00(ctx, "XY_SRC_COPY_BLT");
539 len = (data[0] & 0x000000ff) + 2;
541 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
544 instr_out(ctx, 2, "dst (%d,%d)\n",
545 data[2] & 0xffff, data[2] >> 16);
546 instr_out(ctx, 3, "dst (%d,%d)\n",
547 data[3] & 0xffff, data[3] >> 16);
548 instr_out(ctx, 4, "dst offset 0x%08x\n", data[4]);
549 instr_out(ctx, 5, "src (%d,%d)\n",
550 data[5] & 0xffff, data[5] >> 16);
551 instr_out(ctx, 6, "src pitch %d\n",
552 (short)(data[6] & 0xffff));
553 instr_out(ctx, 7, "src offset 0x%08x\n", data[7]);
557 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
559 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
563 instr_out(ctx, 0, "%s\n",
564 opcodes_2d[opcode].name);
565 if (opcodes_2d[opcode].max_len > 1) {
566 len = (data[0] & 0x000000ff) + 2;
567 if (len < opcodes_2d[opcode].min_len ||
568 len > opcodes_2d[opcode].max_len) {
569 fprintf(out, "Bad count in %s\n",
570 opcodes_2d[opcode].name);
574 for (i = 1; i < len; i++) {
575 instr_out(ctx, i, "dword %d\n", i);
582 instr_out(ctx, 0, "2D UNKNOWN\n");
587 decode_3d_1c(struct drm_intel_decode *ctx)
589 uint32_t *data = ctx->data;
592 opcode = (data[0] & 0x00f80000) >> 19;
597 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
600 instr_out(ctx, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
601 data[0] & 1 ? "enabled" : "disabled");
604 instr_out(ctx, 0, "3DSTATE_MAP_COORD_SET_I830\n");
607 instr_out(ctx, 0, "3DSTATE_MAP_CUBE_I830\n");
610 instr_out(ctx, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
614 instr_out(ctx, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
619 /** Sets the string dstname to describe the destination of the PS instruction */
621 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
623 uint32_t a0 = data[i];
624 int dst_nr = (a0 >> 14) & 0xf;
629 if (((a0 >> 10) & 0xf) == 0xf) {
632 int dstmask_index = 0;
634 dstmask[dstmask_index++] = '.';
636 dstmask[dstmask_index++] = 'x';
638 dstmask[dstmask_index++] = 'y';
640 dstmask[dstmask_index++] = 'z';
642 dstmask[dstmask_index++] = 'w';
643 dstmask[dstmask_index++] = 0;
655 switch ((a0 >> 19) & 0x7) {
658 fprintf(out, "bad destination reg R%d\n", dst_nr);
659 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
663 fprintf(out, "bad destination reg oC%d\n", dst_nr);
664 sprintf(dstname, "oC%s%s", dstmask, sat);
668 fprintf(out, "bad destination reg oD%d\n", dst_nr);
669 sprintf(dstname, "oD%s%s", dstmask, sat);
673 fprintf(out, "bad destination reg U%d\n", dst_nr);
674 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
677 sprintf(dstname, "RESERVED");
683 i915_get_channel_swizzle(uint32_t select)
685 switch (select & 0x7) {
687 return (select & 8) ? "-x" : "x";
689 return (select & 8) ? "-y" : "y";
691 return (select & 8) ? "-z" : "z";
693 return (select & 8) ? "-w" : "w";
695 return (select & 8) ? "-0" : "0";
697 return (select & 8) ? "-1" : "1";
699 return (select & 8) ? "-bad" : "bad";
704 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
708 sprintf(name, "R%d", src_nr);
710 fprintf(out, "bad src reg %s\n", name);
714 sprintf(name, "T%d", src_nr);
715 else if (src_nr == 8)
716 sprintf(name, "DIFFUSE");
717 else if (src_nr == 9)
718 sprintf(name, "SPECULAR");
719 else if (src_nr == 10)
720 sprintf(name, "FOG");
722 fprintf(out, "bad src reg T%d\n", src_nr);
723 sprintf(name, "RESERVED");
727 sprintf(name, "C%d", src_nr);
729 fprintf(out, "bad src reg %s\n", name);
734 fprintf(out, "bad src reg oC%d\n", src_nr);
739 fprintf(out, "bad src reg oD%d\n", src_nr);
742 sprintf(name, "U%d", src_nr);
744 fprintf(out, "bad src reg %s\n", name);
747 fprintf(out, "bad src reg type %d\n", src_type);
748 sprintf(name, "RESERVED");
753 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
755 uint32_t a0 = data[i];
756 uint32_t a1 = data[i + 1];
757 int src_nr = (a0 >> 2) & 0x1f;
758 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
759 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
760 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
761 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
764 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
765 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
767 if (strcmp(swizzle, ".xyzw") != 0)
768 strcat(srcname, swizzle);
771 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
773 uint32_t a1 = data[i + 1];
774 uint32_t a2 = data[i + 2];
775 int src_nr = (a1 >> 8) & 0x1f;
776 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
777 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
778 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
779 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
782 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
783 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
785 if (strcmp(swizzle, ".xyzw") != 0)
786 strcat(srcname, swizzle);
789 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
791 uint32_t a2 = data[i + 2];
792 int src_nr = (a2 >> 16) & 0x1f;
793 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
794 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
795 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
796 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
799 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
800 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
802 if (strcmp(swizzle, ".xyzw") != 0)
803 strcat(srcname, swizzle);
807 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
811 sprintf(name, "R%d", src_nr);
813 fprintf(out, "bad src reg %s\n", name);
817 sprintf(name, "T%d", src_nr);
818 else if (src_nr == 8)
819 sprintf(name, "DIFFUSE");
820 else if (src_nr == 9)
821 sprintf(name, "SPECULAR");
822 else if (src_nr == 10)
823 sprintf(name, "FOG");
825 fprintf(out, "bad src reg T%d\n", src_nr);
826 sprintf(name, "RESERVED");
832 fprintf(out, "bad src reg oC%d\n", src_nr);
837 fprintf(out, "bad src reg oD%d\n", src_nr);
840 fprintf(out, "bad src reg type %d\n", src_type);
841 sprintf(name, "RESERVED");
847 i915_decode_alu1(struct drm_intel_decode *ctx,
848 int i, char *instr_prefix, const char *op_name)
850 char dst[100], src0[100];
852 i915_get_instruction_dst(ctx->data, i, dst, 1);
853 i915_get_instruction_src0(ctx->data, i, src0);
855 instr_out(ctx, i++, "%s: %s %s, %s\n", instr_prefix,
857 instr_out(ctx, i++, "%s\n", instr_prefix);
858 instr_out(ctx, i++, "%s\n", instr_prefix);
862 i915_decode_alu2(struct drm_intel_decode *ctx,
863 int i, char *instr_prefix, const char *op_name)
865 char dst[100], src0[100], src1[100];
867 i915_get_instruction_dst(ctx->data, i, dst, 1);
868 i915_get_instruction_src0(ctx->data, i, src0);
869 i915_get_instruction_src1(ctx->data, i, src1);
871 instr_out(ctx, i++, "%s: %s %s, %s, %s\n", instr_prefix,
872 op_name, dst, src0, src1);
873 instr_out(ctx, i++, "%s\n", instr_prefix);
874 instr_out(ctx, i++, "%s\n", instr_prefix);
878 i915_decode_alu3(struct drm_intel_decode *ctx,
879 int i, char *instr_prefix, const char *op_name)
881 char dst[100], src0[100], src1[100], src2[100];
883 i915_get_instruction_dst(ctx->data, i, dst, 1);
884 i915_get_instruction_src0(ctx->data, i, src0);
885 i915_get_instruction_src1(ctx->data, i, src1);
886 i915_get_instruction_src2(ctx->data, i, src2);
888 instr_out(ctx, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
889 op_name, dst, src0, src1, src2);
890 instr_out(ctx, i++, "%s\n", instr_prefix);
891 instr_out(ctx, i++, "%s\n", instr_prefix);
895 i915_decode_tex(struct drm_intel_decode *ctx, int i,
896 const char *instr_prefix, const char *tex_name)
898 uint32_t t0 = ctx->data[i];
899 uint32_t t1 = ctx->data[i + 1];
904 i915_get_instruction_dst(ctx->data, i, dst_name, 0);
905 i915_get_instruction_addr((t1 >> 24) & 0x7,
906 (t1 >> 17) & 0xf, addr_name);
907 sampler_nr = t0 & 0xf;
909 instr_out(ctx, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
910 tex_name, dst_name, sampler_nr, addr_name);
911 instr_out(ctx, i++, "%s\n", instr_prefix);
912 instr_out(ctx, i++, "%s\n", instr_prefix);
916 i915_decode_dcl(struct drm_intel_decode *ctx, int i, char *instr_prefix)
918 uint32_t d0 = ctx->data[i];
919 const char *sampletype;
920 int dcl_nr = (d0 >> 14) & 0xf;
921 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
922 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
923 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
924 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
927 switch ((d0 >> 19) & 0x3) {
929 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
930 if (strcmp(dcl_mask, ".") == 0)
931 fprintf(out, "bad (empty) dcl mask\n");
934 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
936 if (strcmp(dcl_mask, ".x") != 0 &&
937 strcmp(dcl_mask, ".xy") != 0 &&
938 strcmp(dcl_mask, ".xz") != 0 &&
939 strcmp(dcl_mask, ".w") != 0 &&
940 strcmp(dcl_mask, ".xyzw") != 0) {
941 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
944 instr_out(ctx, i++, "%s: DCL T%d%s\n",
945 instr_prefix, dcl_nr, dcl_mask);
947 if (strcmp(dcl_mask, ".xz") == 0)
948 fprintf(out, "errataed bad dcl mask %s\n",
950 else if (strcmp(dcl_mask, ".xw") == 0)
951 fprintf(out, "errataed bad dcl mask %s\n",
953 else if (strcmp(dcl_mask, ".xzw") == 0)
954 fprintf(out, "errataed bad dcl mask %s\n",
959 "%s: DCL DIFFUSE%s\n", instr_prefix,
961 } else if (dcl_nr == 9) {
963 "%s: DCL SPECULAR%s\n", instr_prefix,
965 } else if (dcl_nr == 10) {
967 "%s: DCL FOG%s\n", instr_prefix,
971 instr_out(ctx, i++, "%s\n", instr_prefix);
972 instr_out(ctx, i++, "%s\n", instr_prefix);
975 switch ((d0 >> 22) & 0x3) {
986 sampletype = "RESERVED";
990 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
991 instr_out(ctx, i++, "%s: DCL S%d %s\n",
992 instr_prefix, dcl_nr, sampletype);
993 instr_out(ctx, i++, "%s\n", instr_prefix);
994 instr_out(ctx, i++, "%s\n", instr_prefix);
997 instr_out(ctx, i++, "%s: DCL RESERVED%d\n",
998 instr_prefix, dcl_nr);
999 instr_out(ctx, i++, "%s\n", instr_prefix);
1000 instr_out(ctx, i++, "%s\n", instr_prefix);
1005 i915_decode_instruction(struct drm_intel_decode *ctx,
1006 int i, char *instr_prefix)
1008 switch ((ctx->data[i] >> 24) & 0x1f) {
1010 instr_out(ctx, i++, "%s: NOP\n", instr_prefix);
1011 instr_out(ctx, i++, "%s\n", instr_prefix);
1012 instr_out(ctx, i++, "%s\n", instr_prefix);
1015 i915_decode_alu2(ctx, i, instr_prefix, "ADD");
1018 i915_decode_alu1(ctx, i, instr_prefix, "MOV");
1021 i915_decode_alu2(ctx, i, instr_prefix, "MUL");
1024 i915_decode_alu3(ctx, i, instr_prefix, "MAD");
1027 i915_decode_alu3(ctx, i, instr_prefix, "DP2ADD");
1030 i915_decode_alu2(ctx, i, instr_prefix, "DP3");
1033 i915_decode_alu2(ctx, i, instr_prefix, "DP4");
1036 i915_decode_alu1(ctx, i, instr_prefix, "FRC");
1039 i915_decode_alu1(ctx, i, instr_prefix, "RCP");
1042 i915_decode_alu1(ctx, i, instr_prefix, "RSQ");
1045 i915_decode_alu1(ctx, i, instr_prefix, "EXP");
1048 i915_decode_alu1(ctx, i, instr_prefix, "LOG");
1051 i915_decode_alu2(ctx, i, instr_prefix, "CMP");
1054 i915_decode_alu2(ctx, i, instr_prefix, "MIN");
1057 i915_decode_alu2(ctx, i, instr_prefix, "MAX");
1060 i915_decode_alu1(ctx, i, instr_prefix, "FLR");
1063 i915_decode_alu1(ctx, i, instr_prefix, "MOD");
1066 i915_decode_alu1(ctx, i, instr_prefix, "TRC");
1069 i915_decode_alu2(ctx, i, instr_prefix, "SGE");
1072 i915_decode_alu2(ctx, i, instr_prefix, "SLT");
1075 i915_decode_tex(ctx, i, instr_prefix, "TEXLD");
1078 i915_decode_tex(ctx, i, instr_prefix, "TEXLDP");
1081 i915_decode_tex(ctx, i, instr_prefix, "TEXLDB");
1084 i915_decode_dcl(ctx, i, instr_prefix);
1087 instr_out(ctx, i++, "%s: unknown\n", instr_prefix);
1088 instr_out(ctx, i++, "%s\n", instr_prefix);
1089 instr_out(ctx, i++, "%s\n", instr_prefix);
1095 decode_compare_func(uint32_t op)
1119 decode_stencil_op(uint32_t op)
1144 decode_logic_op(uint32_t op)
1185 decode_blend_fact(uint32_t op)
1195 return "inv_src_colr";
1199 return "inv_src_alpha";
1203 return "inv_dst_alpha";
1207 return "inv_dst_colr";
1209 return "src_alpha_sat";
1213 return "inv_cnst_colr";
1215 return "cnst_alpha";
1217 return "inv_const_alpha";
1223 decode_tex_coord_mode(uint32_t mode)
1225 switch (mode & 0x7) {
1231 return "clamp_edge";
1235 return "clamp_border";
1237 return "mirror_once";
1243 decode_sample_filter(uint32_t mode)
1245 switch (mode & 0x7) {
1251 return "anisotropic";
1265 decode_3d_1d(struct drm_intel_decode *ctx)
1267 unsigned int len, i, c, idx, word, map, sampler, instr;
1268 const char *format, *zformat, *type;
1270 uint32_t *data = ctx->data;
1271 uint32_t devid = ctx->devid;
1276 unsigned int min_len;
1277 unsigned int max_len;
1279 } opcodes_3d_1d[] = {
1280 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1281 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1282 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1283 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1284 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1285 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1286 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1287 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1288 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1289 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1290 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1291 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1292 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1293 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1294 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1295 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1298 opcode = (data[0] & 0x00ff0000) >> 16;
1302 /* This instruction is unusual. A 0 length means just
1303 * 1 DWORD instead of 2. The 0 length is specified in
1304 * one place to be unsupported, but stated to be
1305 * required in another, and 0 length LOAD_INDIRECTs
1306 * appear to cause no harm at least.
1308 instr_out(ctx, 0, "3DSTATE_LOAD_INDIRECT\n");
1309 len = (data[0] & 0x000000ff) + 1;
1311 if (data[0] & (0x01 << 8)) {
1312 instr_out(ctx, i++, "SIS.0\n");
1313 instr_out(ctx, i++, "SIS.1\n");
1315 if (data[0] & (0x02 << 8)) {
1316 instr_out(ctx, i++, "DIS.0\n");
1318 if (data[0] & (0x04 << 8)) {
1319 instr_out(ctx, i++, "SSB.0\n");
1320 instr_out(ctx, i++, "SSB.1\n");
1322 if (data[0] & (0x08 << 8)) {
1323 instr_out(ctx, i++, "MSB.0\n");
1324 instr_out(ctx, i++, "MSB.1\n");
1326 if (data[0] & (0x10 << 8)) {
1327 instr_out(ctx, i++, "PSP.0\n");
1328 instr_out(ctx, i++, "PSP.1\n");
1330 if (data[0] & (0x20 << 8)) {
1331 instr_out(ctx, i++, "PSC.0\n");
1332 instr_out(ctx, i++, "PSC.1\n");
1335 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1341 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1342 len = (data[0] & 0x0000000f) + 2;
1344 for (word = 0; word <= 8; word++) {
1345 if (data[0] & (1 << (4 + word))) {
1346 /* save vertex state for decode */
1347 if (!IS_GEN2(devid)) {
1362 "S0: vbo offset: 0x%08x%s\n",
1365 ", auto cache invalidate disabled"
1370 "S1: vertex width: %i, vertex pitch: %i\n",
1378 "S2: texcoord formats: ");
1380 tex_num < 8; tex_num++) {
1426 "S3: not documented\n");
1430 const char *cullmode = "";
1431 const char *vfmt_xyzw = "";
1432 switch ((data[i] >> 13)
1469 case 1 << 6 | 1 << 2:
1473 case 2 << 6 | 1 << 2:
1477 case 3 << 6 | 1 << 2:
1481 case 4 << 6 | 1 << 2:
1487 "S4: point_width=%i, line_width=%.1f,"
1488 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1551 "force default diffuse, "
1557 "force default specular, "
1563 "local depth ofs enable, "
1569 "point sprite enable, "
1583 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1584 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1585 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1615 " force default point size,"
1621 " last pixel enable,"
1627 " global depth ofs enable,"
1653 "stencil write enable, "
1659 "stencil test enable, "
1665 "color dither enable, "
1677 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1678 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1679 "%s%stristrip_provoking_vertex=%i\n",
1680 data[i] & (1 << 31) ?
1681 "alpha test enable, "
1689 data[i] & (1 << 15) ?
1690 "cbuf blend enable, "
1692 decode_blend_fact(data
1696 decode_blend_fact(data
1700 data[i] & (1 << 3) ?
1701 "depth write enable, "
1703 data[i] & (1 << 2) ?
1704 "cbuf write enable, "
1710 "S7: depth offset constant: 0x%08x\n",
1716 "S%d: 0x%08x\n", word, data[i]);
1723 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1728 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1729 len = (data[0] & 0x0000000f) + 2;
1731 for (word = 6; word <= 14; word++) {
1732 if (data[0] & (1 << word)) {
1736 else if (word >= 7 && word <= 10) {
1738 "TB%dC\n", word - 7);
1740 "TB%dA\n", word - 7);
1741 } else if (word >= 11 && word <= 14) {
1743 "TM%dS0: offset=0x%08x, %s\n",
1745 data[i] & 0xfffffffe,
1746 data[i] & 1 ? "use fence" :
1750 "TM%dS1: height=%i, width=%i, %s\n",
1751 word - 11, data[i] >> 21,
1752 (data[i] >> 10) & 0x3ff,
1753 data[i] & 2 ? (data[i] & 1 ?
1759 "TM%dS2: pitch=%i, \n",
1761 ((data[i] >> 21) + 1) * 4);
1764 "TM%dS3\n", word - 11);
1766 "TM%dS4: dflt color\n",
1773 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1777 instr_out(ctx, 0, "3DSTATE_MAP_STATE\n");
1778 len = (data[0] & 0x0000003f) + 2;
1779 instr_out(ctx, 1, "mask\n");
1782 for (map = 0; map <= 15; map++) {
1783 if (data[1] & (1 << map)) {
1784 int width, height, pitch, dword;
1789 "map %d MS2 %s%s%s\n", map,
1791 "untrusted surface, " : "",
1793 "vertical line stride enable, " : "",
1795 "vertical ofs enable, " : "");
1798 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1799 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1802 if (dword & (1 << 2))
1804 else if (dword & (1 << 1))
1805 tiling = dword & (1 << 0) ? "Y" : "X";
1808 switch ((dword >> 7) & 0x7) {
1811 switch ((dword >> 3) & 0xf) {
1828 switch ((dword >> 3) & 0xf) {
1833 format = " argb1555";
1836 format = " argb4444";
1842 format = " bump655";
1857 switch ((dword >> 3) & 0xf) {
1859 format = " argb8888";
1862 format = " abgr8888";
1865 format = " xrgb8888";
1868 format = " xbgr8888";
1871 format = " qwvu8888";
1874 format = " axvu8888";
1877 format = " lxvu8888";
1880 format = " xlvu8888";
1883 format = " argb2101010";
1886 format = " abgr2101010";
1889 format = " awvu2101010";
1910 switch ((dword >> 3) & 0xf) {
1912 format = " yuv_swapy";
1918 format = " yuv_swapuv";
1921 format = " yuv_swapuvy";
1926 type = "compressed";
1927 switch ((dword >> 3) & 0x7) {
1941 format = " dxt1_rb";
1946 type = "4b indexed";
1947 switch ((dword >> 3) & 0xf) {
1949 format = " argb8888";
1956 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1957 map, width, height, type, format,
1959 dword & (1 << 9) ? " palette select" :
1964 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1966 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1967 map, pitch, (dword >> 9) & 0x3f,
1968 dword & 0xff, (dword >> 15) & 0x3f,
1969 dword & (1 << 8) ? "miplayout legacy"
1970 : "miplayout right");
1974 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1980 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1981 len = (data[0] & 0x000000ff) + 2;
1984 for (c = 0; c <= 31; c++) {
1985 if (data[1] & (1 << c)) {
1986 instr_out(ctx, i, "C%d.X = %f\n", c,
1987 int_as_float(data[i]));
1989 instr_out(ctx, i, "C%d.Y = %f\n",
1990 c, int_as_float(data[i]));
1992 instr_out(ctx, i, "C%d.Z = %f\n",
1993 c, int_as_float(data[i]));
1995 instr_out(ctx, i, "C%d.W = %f\n",
1996 c, int_as_float(data[i]));
2002 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
2006 instr_out(ctx, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
2007 len = (data[0] & 0x000000ff) + 2;
2008 if ((len - 1) % 3 != 0 || len > 370) {
2010 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
2013 for (instr = 0; instr < (len - 1) / 3; instr++) {
2014 char instr_prefix[10];
2016 sprintf(instr_prefix, "PS%03d", instr);
2017 i915_decode_instruction(ctx, i,
2025 instr_out(ctx, 0, "3DSTATE_SAMPLER_STATE\n");
2026 instr_out(ctx, 1, "mask\n");
2027 len = (data[0] & 0x0000003f) + 2;
2029 for (sampler = 0; sampler <= 15; sampler++) {
2030 if (data[1] & (1 << sampler)) {
2032 const char *mip_filter = "";
2035 switch ((dword >> 20) & 0x3) {
2037 mip_filter = "none";
2040 mip_filter = "nearest";
2043 mip_filter = "linear";
2047 "sampler %d SS2:%s%s%s "
2048 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
2049 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
2051 dword & (1 << 31) ? " reverse gamma,"
2053 dword & (1 << 30) ? " packed2planar,"
2056 " colorspace conversion," : "",
2057 (dword >> 22) & 0x1f, mip_filter,
2058 decode_sample_filter(dword >> 17),
2059 decode_sample_filter(dword >> 14),
2060 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2061 dword & (1 << 4) ? " shadow," : "",
2062 dword & (1 << 3) ? 4 : 2,
2063 decode_compare_func(dword));
2066 "sampler %d SS3: min_lod=%.2f,%s "
2067 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2069 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2071 " kill pixel enable," : "",
2072 decode_tex_coord_mode(dword >> 12),
2073 decode_tex_coord_mode(dword >> 9),
2074 decode_tex_coord_mode(dword >> 6),
2076 " normalized coords," : "",
2078 dword & (1 << 0) ? " deinterlacer," :
2082 "sampler %d SS4: border color\n",
2087 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2091 len = (data[0] & 0x0000000f) + 2;
2095 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2098 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2100 switch ((data[1] >> 8) & 0xf) {
2105 format = "x1r5g5b5";
2111 format = "a8r8g8b8";
2114 format = "ycrcb_swapy";
2117 format = "ycrcb_normal";
2120 format = "ycrcb_swapuv";
2123 format = "ycrcb_swapuvy";
2126 format = "a4r4g4b4";
2129 format = "a1r5g5b5";
2132 format = "a2r10g10b10";
2138 switch ((data[1] >> 2) & 0x3) {
2153 "%s format, %s depth format, early Z %sabled\n",
2155 (data[1] & (1 << 31)) ? "en" : "dis");
2160 const char *name, *tiling;
2162 len = (data[0] & 0x0000000f) + 2;
2165 "Bad count in 3DSTATE_BUFFER_INFO\n");
2167 switch ((data[1] >> 24) & 0x7) {
2180 if (data[1] & (1 << 23))
2182 else if (data[1] & (1 << 22))
2183 tiling = data[1] & (1 << 21) ? "Y" : "X";
2185 instr_out(ctx, 0, "3DSTATE_BUFFER_INFO\n");
2187 "%s, tiling = %s, pitch=%d\n", name, tiling,
2190 instr_out(ctx, 2, "address\n");
2194 len = (data[0] & 0x0000000f) + 2;
2198 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2200 instr_out(ctx, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2201 instr_out(ctx, 1, "(%d,%d)\n",
2202 data[1] & 0xffff, data[1] >> 16);
2203 instr_out(ctx, 2, "(%d,%d)\n",
2204 data[2] & 0xffff, data[2] >> 16);
2208 len = (data[0] & 0x0000000f) + 2;
2212 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2214 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2215 instr_out(ctx, 1, "%s\n",
2216 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2217 instr_out(ctx, 2, "(%d,%d)\n",
2218 data[2] & 0xffff, data[2] >> 16);
2219 instr_out(ctx, 3, "(%d,%d)\n",
2220 data[3] & 0xffff, data[3] >> 16);
2221 instr_out(ctx, 4, "(%d,%d)\n",
2222 data[4] & 0xffff, data[4] >> 16);
2226 len = (data[0] & 0x0000000f) + 2;
2229 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2231 instr_out(ctx, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2232 instr_out(ctx, 1, "prim_type=%s, clear=%s%s%s\n",
2233 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2234 data[1] & (1 << 2) ? "color," : "",
2235 data[1] & (1 << 1) ? "depth," : "",
2236 data[1] & (1 << 0) ? "stencil," : "");
2237 instr_out(ctx, 2, "clear color\n");
2238 instr_out(ctx, 3, "clear depth/stencil\n");
2239 instr_out(ctx, 4, "color value (rgba8888)\n");
2240 instr_out(ctx, 5, "depth value %f\n",
2241 int_as_float(data[5]));
2242 instr_out(ctx, 6, "clear stencil\n");
2246 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2247 opcode_3d_1d = &opcodes_3d_1d[idx];
2248 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2251 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2254 instr_out(ctx, 0, "%s\n",
2255 opcode_3d_1d->name);
2256 if (opcode_3d_1d->max_len > 1) {
2257 len = (data[0] & 0x0000ffff) + 2;
2258 if (len < opcode_3d_1d->min_len ||
2259 len > opcode_3d_1d->max_len) {
2260 fprintf(out, "Bad count in %s\n",
2261 opcode_3d_1d->name);
2265 for (i = 1; i < len; i++) {
2266 instr_out(ctx, i, "dword %d\n", i);
2273 instr_out(ctx, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2279 decode_3d_primitive(struct drm_intel_decode *ctx)
2281 uint32_t *data = ctx->data;
2282 uint32_t count = ctx->count;
2283 char immediate = (data[0] & (1 << 23)) == 0;
2284 unsigned int len, i, j, ret;
2285 const char *primtype;
2286 int original_s2 = saved_s2;
2287 int original_s4 = saved_s4;
2289 switch ((data[0] >> 18) & 0xf) {
2291 primtype = "TRILIST";
2294 primtype = "TRISTRIP";
2297 primtype = "TRISTRIP_REVERSE";
2300 primtype = "TRIFAN";
2303 primtype = "POLYGON";
2306 primtype = "LINELIST";
2309 primtype = "LINESTRIP";
2312 primtype = "RECTLIST";
2315 primtype = "POINTLIST";
2321 primtype = "CLEAR_RECT";
2326 primtype = "unknown";
2330 /* XXX: 3DPRIM_DIB not supported */
2332 len = (data[0] & 0x0003ffff) + 2;
2333 instr_out(ctx, 0, "3DPRIMITIVE inline %s\n",
2336 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2337 if (!saved_s2_set || !saved_s4_set) {
2338 fprintf(out, "unknown vertex format\n");
2339 for (i = 1; i < len; i++) {
2341 " vertex data (%f float)\n",
2342 int_as_float(data[i]));
2345 unsigned int vertex = 0;
2346 for (i = 1; i < len;) {
2349 #define VERTEX_OUT(fmt, ...) do { \
2351 instr_out(ctx, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2353 fprintf(out, " missing data in V%d\n", vertex); \
2357 VERTEX_OUT("X = %f", int_as_float(data[i]));
2358 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2359 switch (saved_s4 >> 6 & 0x7) {
2361 VERTEX_OUT("Z = %f",
2362 int_as_float(data[i]));
2365 VERTEX_OUT("Z = %f",
2366 int_as_float(data[i]));
2367 VERTEX_OUT("W = %f",
2368 int_as_float(data[i]));
2373 VERTEX_OUT("W = %f",
2374 int_as_float(data[i]));
2377 fprintf(out, "bad S4 position mask\n");
2380 if (saved_s4 & (1 << 10)) {
2382 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2383 "B=0x%02x)", data[i] >> 24,
2384 (data[i] >> 16) & 0xff,
2385 (data[i] >> 8) & 0xff,
2388 if (saved_s4 & (1 << 11)) {
2390 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2391 "B=0x%02x)", data[i] >> 24,
2392 (data[i] >> 16) & 0xff,
2393 (data[i] >> 8) & 0xff,
2396 if (saved_s4 & (1 << 12))
2397 VERTEX_OUT("width = 0x%08x)", data[i]);
2399 for (tc = 0; tc <= 7; tc++) {
2400 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2402 VERTEX_OUT("T%d.X = %f", tc,
2405 VERTEX_OUT("T%d.Y = %f", tc,
2410 VERTEX_OUT("T%d.X = %f", tc,
2413 VERTEX_OUT("T%d.Y = %f", tc,
2416 VERTEX_OUT("T%d.Z = %f", tc,
2421 VERTEX_OUT("T%d.X = %f", tc,
2424 VERTEX_OUT("T%d.Y = %f", tc,
2427 VERTEX_OUT("T%d.Z = %f", tc,
2430 VERTEX_OUT("T%d.W = %f", tc,
2435 VERTEX_OUT("T%d.X = %f", tc,
2441 ("T%d.XY = 0x%08x half-float",
2446 ("T%d.XY = 0x%08x half-float",
2449 ("T%d.ZW = 0x%08x half-float",
2456 "bad S2.T%d format\n",
2466 /* indirect vertices */
2467 len = data[0] & 0x0000ffff; /* index count */
2468 if (data[0] & (1 << 17)) {
2469 /* random vertex access */
2470 if (count < (len + 1) / 2 + 1) {
2471 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2472 "3DPRIMITIVE random indirect");
2475 "3DPRIMITIVE random indirect %s (%d)\n",
2478 /* vertex indices continue until 0xffff is
2481 for (i = 1; i < count; i++) {
2482 if ((data[i] & 0xffff) == 0xffff) {
2484 " indices: (terminator)\n");
2487 } else if ((data[i] >> 16) == 0xffff) {
2489 " indices: 0x%04x, (terminator)\n",
2495 " indices: 0x%04x, 0x%04x\n",
2501 "3DPRIMITIVE: no terminator found in index buffer\n");
2505 /* fixed size vertex index buffer */
2506 for (j = 1, i = 0; i < len; i += 2, j++) {
2507 if (i * 2 == len - 1) {
2509 " indices: 0x%04x\n",
2513 " indices: 0x%04x, 0x%04x\n",
2519 ret = (len + 1) / 2 + 1;
2522 /* sequential vertex access */
2524 "3DPRIMITIVE sequential indirect %s, %d starting from "
2525 "%d\n", primtype, len, data[1] & 0xffff);
2526 instr_out(ctx, 1, " start\n");
2533 saved_s2 = original_s2;
2534 saved_s4 = original_s4;
2539 decode_3d(struct drm_intel_decode *ctx)
2543 uint32_t *data = ctx->data;
2547 unsigned int min_len;
2548 unsigned int max_len;
2551 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2552 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2553 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2554 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2555 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2556 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2557 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2558 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2559 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2562 opcode = (data[0] & 0x1f000000) >> 24;
2566 return decode_3d_primitive(ctx);
2568 return decode_3d_1d(ctx);
2570 return decode_3d_1c(ctx);
2573 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2574 opcode_3d = &opcodes_3d[idx];
2575 if (opcode == opcode_3d->opcode) {
2576 unsigned int len = 1, i;
2578 instr_out(ctx, 0, "%s\n", opcode_3d->name);
2579 if (opcode_3d->max_len > 1) {
2580 len = (data[0] & 0xff) + 2;
2581 if (len < opcode_3d->min_len ||
2582 len > opcode_3d->max_len) {
2583 fprintf(out, "Bad count in %s\n",
2588 for (i = 1; i < len; i++) {
2589 instr_out(ctx, i, "dword %d\n", i);
2595 instr_out(ctx, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2599 static const char *get_965_surfacetype(unsigned int surfacetype)
2601 switch (surfacetype) {
2619 static const char *get_965_depthformat(unsigned int depthformat)
2621 switch (depthformat) {
2623 return "s8_z24float";
2635 static const char *get_965_element_component(uint32_t data, int component)
2637 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2639 switch (component_control) {
2643 switch (component) {
2668 static const char *get_965_prim_type(uint32_t primtype)
2672 return "point list";
2676 return "line strip";
2686 return "quad strip";
2688 return "line list adj";
2690 return "line strip adj";
2692 return "tri list adj";
2694 return "tri strip adj";
2696 return "tri strip reverse";
2704 return "point list bf";
2706 return "line strip cont";
2708 return "line strip bf";
2710 return "line strip cont bf";
2712 return "tri fan no stipple";
2719 i965_decode_urb_fence(struct drm_intel_decode *ctx, int len)
2721 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2722 uint32_t *data = ctx->data;
2725 fprintf(out, "Bad count in URB_FENCE\n");
2727 vs_fence = data[1] & 0x3ff;
2728 gs_fence = (data[1] >> 10) & 0x3ff;
2729 clip_fence = (data[1] >> 20) & 0x3ff;
2730 sf_fence = data[2] & 0x3ff;
2731 vfe_fence = (data[2] >> 10) & 0x3ff;
2732 cs_fence = (data[2] >> 20) & 0x7ff;
2734 instr_out(ctx, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2735 (data[0] >> 13) & 1 ? "cs " : "",
2736 (data[0] >> 12) & 1 ? "vfe " : "",
2737 (data[0] >> 11) & 1 ? "sf " : "",
2738 (data[0] >> 10) & 1 ? "clip " : "",
2739 (data[0] >> 9) & 1 ? "gs " : "",
2740 (data[0] >> 8) & 1 ? "vs " : "");
2742 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2743 vs_fence, clip_fence, gs_fence);
2745 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2746 sf_fence, vfe_fence, cs_fence);
2747 if (gs_fence < vs_fence)
2748 fprintf(out, "gs fence < vs fence!\n");
2749 if (clip_fence < gs_fence)
2750 fprintf(out, "clip fence < gs fence!\n");
2751 if (sf_fence < clip_fence)
2752 fprintf(out, "sf fence < clip fence!\n");
2753 if (cs_fence < sf_fence)
2754 fprintf(out, "cs fence < sf fence!\n");
2760 state_base_out(struct drm_intel_decode *ctx, unsigned int index,
2763 if (ctx->data[index] & 1) {
2764 instr_out(ctx, index,
2765 "%s state base address 0x%08x\n", name,
2766 ctx->data[index] & ~1);
2768 instr_out(ctx, index, "%s state base not updated\n",
2774 state_max_out(struct drm_intel_decode *ctx, unsigned int index,
2777 if (ctx->data[index] & 1) {
2778 if (ctx->data[index] == 1) {
2779 instr_out(ctx, index,
2780 "%s state upper bound disabled\n", name);
2782 instr_out(ctx, index,
2783 "%s state upper bound 0x%08x\n", name,
2784 ctx->data[index] & ~1);
2787 instr_out(ctx, index,
2788 "%s state upper bound not updated\n", name);
2793 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct drm_intel_decode *ctx)
2795 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_CC\n");
2796 instr_out(ctx, 1, "pointer to CC viewport\n");
2802 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct drm_intel_decode *ctx)
2804 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP\n");
2805 instr_out(ctx, 1, "pointer to SF_CLIP viewport\n");
2811 gen7_3DSTATE_BLEND_STATE_POINTERS(struct drm_intel_decode *ctx)
2813 instr_out(ctx, 0, "3DSTATE_BLEND_STATE_POINTERS\n");
2814 instr_out(ctx, 1, "pointer to BLEND_STATE at 0x%08x (%s)\n",
2816 (ctx->data[1] & 1) ? "changed" : "unchanged");
2822 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct drm_intel_decode *ctx)
2824 instr_out(ctx, 0, "3DSTATE_DEPTH_STENCIL_STATE_POINTERS\n");
2826 "pointer to DEPTH_STENCIL_STATE at 0x%08x (%s)\n",
2828 (ctx->data[1] & 1) ? "changed" : "unchanged");
2834 gen7_3DSTATE_HIER_DEPTH_BUFFER(struct drm_intel_decode *ctx)
2836 instr_out(ctx, 0, "3DSTATE_HIER_DEPTH_BUFFER\n");
2837 instr_out(ctx, 1, "pitch %db\n",
2838 (ctx->data[1] & 0x1ffff) + 1);
2839 instr_out(ctx, 2, "pointer to HiZ buffer\n");
2845 gen6_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2847 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2848 instr_out(ctx, 1, "blend change %d\n", ctx->data[1] & 1);
2849 instr_out(ctx, 2, "depth stencil change %d\n",
2851 instr_out(ctx, 3, "cc change %d\n", ctx->data[3] & 1);
2857 gen7_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2859 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2860 instr_out(ctx, 1, "pointer to COLOR_CALC_STATE at 0x%08x "
2863 (ctx->data[1] & 1) ? "changed" : "unchanged");
2869 gen7_3DSTATE_URB_unit(struct drm_intel_decode *ctx, const char *unit)
2871 int start_kb = ((ctx->data[1] >> 25) & 0x3f) * 8;
2872 /* the field is # of 512-bit rows - 1, we print bytes */
2873 int entry_size = (((ctx->data[1] >> 16) & 0x1ff) + 1);
2874 int nr_entries = ctx->data[1] & 0xffff;
2876 instr_out(ctx, 0, "3DSTATE_URB_%s\n", unit);
2878 "%dKB start, size=%d 64B rows, nr_entries=%d, total size %dB\n",
2879 start_kb, entry_size, nr_entries, nr_entries * 64 * entry_size);
2885 gen7_3DSTATE_URB_VS(struct drm_intel_decode *ctx)
2887 return gen7_3DSTATE_URB_unit(ctx, "VS");
2891 gen7_3DSTATE_URB_HS(struct drm_intel_decode *ctx)
2893 return gen7_3DSTATE_URB_unit(ctx, "HS");
2897 gen7_3DSTATE_URB_DS(struct drm_intel_decode *ctx)
2899 return gen7_3DSTATE_URB_unit(ctx, "DS");
2903 gen7_3DSTATE_URB_GS(struct drm_intel_decode *ctx)
2905 return gen7_3DSTATE_URB_unit(ctx, "GS");
2909 gen7_3DSTATE_CONSTANT(struct drm_intel_decode *ctx, const char *unit)
2913 rlen[0] = (ctx->data[1] >> 0) & 0xffff;
2914 rlen[1] = (ctx->data[1] >> 16) & 0xffff;
2915 rlen[2] = (ctx->data[2] >> 0) & 0xffff;
2916 rlen[3] = (ctx->data[2] >> 16) & 0xffff;
2918 instr_out(ctx, 0, "3DSTATE_CONSTANT_%s\n", unit);
2919 instr_out(ctx, 1, "len 0 = %d, len 1 = %d\n", rlen[0], rlen[1]);
2920 instr_out(ctx, 2, "len 2 = %d, len 3 = %d\n", rlen[2], rlen[3]);
2921 instr_out(ctx, 3, "pointer to constbuf 0\n");
2922 instr_out(ctx, 4, "pointer to constbuf 1\n");
2923 instr_out(ctx, 5, "pointer to constbuf 2\n");
2924 instr_out(ctx, 6, "pointer to constbuf 3\n");
2930 gen7_3DSTATE_CONSTANT_VS(struct drm_intel_decode *ctx)
2932 return gen7_3DSTATE_CONSTANT(ctx, "VS");
2936 gen7_3DSTATE_CONSTANT_GS(struct drm_intel_decode *ctx)
2938 return gen7_3DSTATE_CONSTANT(ctx, "GS");
2942 gen7_3DSTATE_CONSTANT_PS(struct drm_intel_decode *ctx)
2944 return gen7_3DSTATE_CONSTANT(ctx, "PS");
2948 gen7_3DSTATE_CONSTANT_DS(struct drm_intel_decode *ctx)
2950 return gen7_3DSTATE_CONSTANT(ctx, "DS");
2954 gen7_3DSTATE_CONSTANT_HS(struct drm_intel_decode *ctx)
2956 return gen7_3DSTATE_CONSTANT(ctx, "HS");
2961 gen6_3DSTATE_WM(struct drm_intel_decode *ctx)
2963 instr_out(ctx, 0, "3DSTATE_WM\n");
2964 instr_out(ctx, 1, "kernel start pointer 0\n");
2966 "SPF=%d, VME=%d, Sampler Count %d, "
2967 "Binding table count %d\n",
2968 (ctx->data[2] >> 31) & 1,
2969 (ctx->data[2] >> 30) & 1,
2970 (ctx->data[2] >> 27) & 7,
2971 (ctx->data[2] >> 18) & 0xff);
2972 instr_out(ctx, 3, "scratch offset\n");
2974 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
2975 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
2976 (ctx->data[4] & (1 << 30)) != 0,
2977 (ctx->data[4] & (1 << 28)) != 0,
2978 (ctx->data[4] & (1 << 27)) != 0,
2979 (ctx->data[4] >> 16) & 0x7f,
2980 (ctx->data[4] >> 8) & 0x7f,
2981 (ctx->data[4] & 0x7f));
2983 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
2984 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, "
2985 "Dispatch32 %d, Dispatch16 %d, Dispatch8 %d\n",
2986 ((ctx->data[5] >> 25) & 0x7f) + 1,
2987 (ctx->data[5] & (1 << 22)) != 0,
2988 (ctx->data[5] & (1 << 21)) != 0,
2989 (ctx->data[5] & (1 << 20)) != 0,
2990 (ctx->data[5] & (1 << 19)) != 0,
2991 (ctx->data[5] & (1 << 8)) != 0,
2992 (ctx->data[5] & (1 << 2)) != 0,
2993 (ctx->data[5] & (1 << 1)) != 0,
2994 (ctx->data[5] & (1 << 0)) != 0);
2996 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
2997 "Barycentric interp mode 0x%x, Point raster rule %d, "
2998 "Multisample mode %d, "
2999 "Multisample Dispatch mode %d\n",
3000 (ctx->data[6] >> 20) & 0x3f,
3001 (ctx->data[6] >> 18) & 3,
3002 (ctx->data[6] >> 16) & 3,
3003 (ctx->data[6] >> 10) & 0x3f,
3004 (ctx->data[6] & (1 << 9)) != 0,
3005 (ctx->data[6] >> 1) & 3,
3006 (ctx->data[6] & 1));
3007 instr_out(ctx, 7, "kernel start pointer 1\n");
3008 instr_out(ctx, 8, "kernel start pointer 2\n");
3014 gen7_3DSTATE_WM(struct drm_intel_decode *ctx)
3016 const char *computed_depth = "";
3017 const char *early_depth = "";
3018 const char *zw_interp = "";
3020 switch ((ctx->data[1] >> 23) & 0x3) {
3022 computed_depth = "";
3025 computed_depth = "computed depth";
3028 computed_depth = "computed depth >=";
3031 computed_depth = "computed depth <=";
3035 switch ((ctx->data[1] >> 21) & 0x3) {
3040 early_depth = ", EDSC_PSEXEC";
3043 early_depth = ", EDSC_PREPS";
3046 early_depth = ", BAD EDSC";
3050 switch ((ctx->data[1] >> 17) & 0x3) {
3055 early_depth = ", BAD ZW interp";
3058 early_depth = ", ZW centroid";
3061 early_depth = ", ZW sample";
3065 instr_out(ctx, 0, "3DSTATE_WM\n");
3066 instr_out(ctx, 1, "(%s%s%s%s%s%s)%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3067 (ctx->data[1] & (1 << 11)) ? "PP " : "",
3068 (ctx->data[1] & (1 << 12)) ? "PC " : "",
3069 (ctx->data[1] & (1 << 13)) ? "PS " : "",
3070 (ctx->data[1] & (1 << 14)) ? "NPP " : "",
3071 (ctx->data[1] & (1 << 15)) ? "NPC " : "",
3072 (ctx->data[1] & (1 << 16)) ? "NPS " : "",
3073 (ctx->data[1] & (1 << 30)) ? ", depth clear" : "",
3074 (ctx->data[1] & (1 << 29)) ? "" : ", disabled",
3075 (ctx->data[1] & (1 << 28)) ? ", depth resolve" : "",
3076 (ctx->data[1] & (1 << 27)) ? ", hiz resolve" : "",
3077 (ctx->data[1] & (1 << 25)) ? ", kill" : "",
3081 (ctx->data[1] & (1 << 20)) ? ", source depth" : "",
3082 (ctx->data[1] & (1 << 19)) ? ", source W" : "",
3083 (ctx->data[1] & (1 << 10)) ? ", coverage" : "",
3084 (ctx->data[1] & (1 << 4)) ? ", poly stipple" : "",
3085 (ctx->data[1] & (1 << 3)) ? ", line stipple" : "",
3086 (ctx->data[1] & (1 << 2)) ? ", point UL" : ", point UR"
3088 instr_out(ctx, 2, "MS\n");
3094 gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
3097 "3DPRIMITIVE: %s %s\n",
3098 get_965_prim_type((ctx->data[0] >> 10) & 0x1f),
3099 (ctx->data[0] & (1 << 15)) ? "random" : "sequential");
3100 instr_out(ctx, 1, "vertex count\n");
3101 instr_out(ctx, 2, "start vertex\n");
3102 instr_out(ctx, 3, "instance count\n");
3103 instr_out(ctx, 4, "start instance\n");
3104 instr_out(ctx, 5, "index bias\n");
3110 gen7_3DPRIMITIVE(struct drm_intel_decode *ctx)
3112 bool indirect = !!(ctx->data[0] & (1 << 10));
3115 "3DPRIMITIVE: %s%s\n",
3116 indirect ? " indirect" : "",
3117 (ctx->data[0] & (1 << 8)) ? " predicated" : "");
3118 instr_out(ctx, 1, "%s %s\n",
3119 get_965_prim_type(ctx->data[1] & 0x3f),
3120 (ctx->data[1] & (1 << 8)) ? "random" : "sequential");
3121 instr_out(ctx, 2, indirect ? "ignored" : "vertex count\n");
3122 instr_out(ctx, 3, indirect ? "ignored" : "start vertex\n");
3123 instr_out(ctx, 4, indirect ? "ignored" : "instance count\n");
3124 instr_out(ctx, 5, indirect ? "ignored" : "start instance\n");
3125 instr_out(ctx, 6, indirect ? "ignored" : "index bias\n");
3131 decode_3d_965(struct drm_intel_decode *ctx)
3135 unsigned int i, j, sba_len;
3136 const char *desc1 = NULL;
3137 uint32_t *data = ctx->data;
3138 uint32_t devid = ctx->devid;
3143 int unsigned min_len;
3144 int unsigned max_len;
3147 int (*func)(struct drm_intel_decode *ctx);
3149 { 0x6000, 0x00ff, 3, 3, "URB_FENCE" },
3150 { 0x6001, 0xffff, 2, 2, "CS_URB_STATE" },
3151 { 0x6002, 0x00ff, 2, 2, "CONSTANT_BUFFER" },
3152 { 0x6101, 0xffff, 6, 10, "STATE_BASE_ADDRESS" },
3153 { 0x6102, 0xffff, 2, 2, "STATE_SIP" },
3154 { 0x6104, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3155 { 0x680b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3156 { 0x6904, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3157 { 0x7800, 0xffff, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
3158 { 0x7801, 0x00ff, 4, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
3159 { 0x7802, 0x00ff, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
3160 { 0x7805, 0x00ff, 7, 7, "3DSTATE_DEPTH_BUFFER", 7 },
3161 { 0x7805, 0x00ff, 3, 3, "3DSTATE_URB" },
3162 { 0x7804, 0x00ff, 3, 3, "3DSTATE_CLEAR_PARAMS" },
3163 { 0x7806, 0x00ff, 3, 3, "3DSTATE_STENCIL_BUFFER" },
3164 { 0x790f, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 6 },
3165 { 0x7807, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 7, gen7_3DSTATE_HIER_DEPTH_BUFFER },
3166 { 0x7808, 0x00ff, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
3167 { 0x7809, 0x00ff, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
3168 { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" },
3169 { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3170 { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
3171 { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS },
3172 { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS },
3173 { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" },
3174 { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" },
3175 { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" },
3176 { 0x7812, 0x00ff, 4, 4, "3DSTATE_CLIP" },
3177 { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF", 6 },
3178 { 0x7813, 0x00ff, 7, 7, "3DSTATE_SF", 7 },
3179 { 0x7814, 0x00ff, 3, 3, "3DSTATE_WM", 7, gen7_3DSTATE_WM },
3180 { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM", 6, gen6_3DSTATE_WM },
3181 { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE", 6 },
3182 { 0x7815, 0x00ff, 7, 7, "3DSTATE_CONSTANT_VS", 7, gen7_3DSTATE_CONSTANT_VS },
3183 { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE", 6 },
3184 { 0x7816, 0x00ff, 7, 7, "3DSTATE_CONSTANT_GS", 7, gen7_3DSTATE_CONSTANT_GS },
3185 { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE", 6 },
3186 { 0x7817, 0x00ff, 7, 7, "3DSTATE_CONSTANT_PS", 7, gen7_3DSTATE_CONSTANT_PS },
3187 { 0x7818, 0xffff, 2, 2, "3DSTATE_SAMPLE_MASK" },
3188 { 0x7819, 0x00ff, 7, 7, "3DSTATE_CONSTANT_HS", 7, gen7_3DSTATE_CONSTANT_HS },
3189 { 0x781a, 0x00ff, 7, 7, "3DSTATE_CONSTANT_DS", 7, gen7_3DSTATE_CONSTANT_DS },
3190 { 0x781b, 0x00ff, 7, 7, "3DSTATE_HS" },
3191 { 0x781c, 0x00ff, 4, 4, "3DSTATE_TE" },
3192 { 0x781d, 0x00ff, 6, 6, "3DSTATE_DS" },
3193 { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" },
3194 { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" },
3195 { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" },
3196 { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP },
3197 { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC },
3198 { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS },
3199 { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS },
3200 { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" },
3201 { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" },
3202 { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" },
3203 { 0x7829, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_GS" },
3204 { 0x782a, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_PS" },
3205 { 0x782b, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_VS" },
3206 { 0x782c, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_HS" },
3207 { 0x782d, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_DS" },
3208 { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" },
3209 { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" },
3210 { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS },
3211 { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS },
3212 { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS },
3213 { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS },
3214 { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
3215 { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" },
3216 { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" },
3217 { 0x7906, 0xffff, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
3218 { 0x7907, 0xffff, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
3219 { 0x7908, 0xffff, 3, 3, "3DSTATE_LINE_STIPPLE" },
3220 { 0x7909, 0xffff, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
3221 { 0x7909, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3222 { 0x790a, 0xffff, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
3223 { 0x790b, 0xffff, 4, 4, "3DSTATE_GS_SVB_INDEX" },
3224 { 0x790d, 0xffff, 3, 3, "3DSTATE_MULTISAMPLE", 6 },
3225 { 0x790d, 0xffff, 4, 4, "3DSTATE_MULTISAMPLE", 7 },
3226 { 0x7910, 0x00ff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3227 { 0x7912, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_VS" },
3228 { 0x7913, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_HS" },
3229 { 0x7914, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_DS" },
3230 { 0x7915, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_GS" },
3231 { 0x7916, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_PS" },
3232 { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" },
3233 { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" },
3234 { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" },
3235 { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE },
3236 { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
3237 }, *opcode_3d = NULL;
3239 opcode = (data[0] & 0xffff0000) >> 16;
3241 for (i = 0; i < ARRAY_SIZE(opcodes_3d); i++) {
3242 if (opcode != opcodes_3d[i].opcode)
3245 /* If it's marked as not our gen, skip. */
3246 if (opcodes_3d[i].gen && opcodes_3d[i].gen != ctx->gen)
3249 opcode_3d = &opcodes_3d[i];
3254 if (opcode_3d->max_len == 1)
3257 len = (data[0] & opcode_3d->len_mask) + 2;
3259 if (len < opcode_3d->min_len ||
3260 len > opcode_3d->max_len) {
3261 fprintf(out, "Bad length %d in %s, expected %d-%d\n",
3262 len, opcode_3d->name,
3263 opcode_3d->min_len, opcode_3d->max_len);
3266 len = (data[0] & 0x0000ffff) + 2;
3271 return i965_decode_urb_fence(ctx, len);
3273 instr_out(ctx, 0, "CS_URB_STATE\n");
3275 "entry_size: %d [%d bytes], n_entries: %d\n",
3276 (data[1] >> 4) & 0x1f,
3277 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
3280 instr_out(ctx, 0, "CONSTANT_BUFFER: %s\n",
3281 (data[0] >> 8) & 1 ? "valid" : "invalid");
3283 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
3284 ((data[1] & 0x3f) + 1) * 64);
3288 instr_out(ctx, 0, "STATE_BASE_ADDRESS\n");
3291 if (IS_GEN6(devid) || IS_GEN7(devid))
3293 else if (IS_GEN5(devid))
3298 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
3300 state_base_out(ctx, i++, "general");
3301 state_base_out(ctx, i++, "surface");
3302 if (IS_GEN6(devid) || IS_GEN7(devid))
3303 state_base_out(ctx, i++, "dynamic");
3304 state_base_out(ctx, i++, "indirect");
3305 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3306 state_base_out(ctx, i++, "instruction");
3308 state_max_out(ctx, i++, "general");
3309 if (IS_GEN6(devid) || IS_GEN7(devid))
3310 state_max_out(ctx, i++, "dynamic");
3311 state_max_out(ctx, i++, "indirect");
3312 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3313 state_max_out(ctx, i++, "instruction");
3317 instr_out(ctx, 0, "3DSTATE_PIPELINED_POINTERS\n");
3318 instr_out(ctx, 1, "VS state\n");
3319 instr_out(ctx, 2, "GS state\n");
3320 instr_out(ctx, 3, "Clip state\n");
3321 instr_out(ctx, 4, "SF state\n");
3322 instr_out(ctx, 5, "WM state\n");
3323 instr_out(ctx, 6, "CC state\n");
3326 if (len != 6 && len != 4)
3328 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
3331 "3DSTATE_BINDING_TABLE_POINTERS\n");
3332 instr_out(ctx, 1, "VS binding table\n");
3333 instr_out(ctx, 2, "GS binding table\n");
3334 instr_out(ctx, 3, "Clip binding table\n");
3335 instr_out(ctx, 4, "SF binding table\n");
3336 instr_out(ctx, 5, "WM binding table\n");
3339 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
3340 "GS mod %d, PS mod %d\n",
3341 (data[0] & (1 << 8)) != 0,
3342 (data[0] & (1 << 9)) != 0,
3343 (data[0] & (1 << 12)) != 0);
3344 instr_out(ctx, 1, "VS binding table\n");
3345 instr_out(ctx, 2, "GS binding table\n");
3346 instr_out(ctx, 3, "WM binding table\n");
3352 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
3353 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
3354 (data[0] & (1 << 9)) != 0,
3355 (data[0] & (1 << 12)) != 0);
3356 instr_out(ctx, 1, "VS sampler state\n");
3357 instr_out(ctx, 2, "GS sampler state\n");
3358 instr_out(ctx, 3, "WM sampler state\n");
3361 /* Actually 3DSTATE_DEPTH_BUFFER on gen7. */
3365 instr_out(ctx, 0, "3DSTATE_URB\n");
3367 "VS entries %d, alloc size %d (1024bit row)\n",
3368 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
3370 "GS entries %d, alloc size %d (1024bit row)\n",
3371 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
3375 if ((len - 1) % 4 != 0)
3376 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
3377 instr_out(ctx, 0, "3DSTATE_VERTEX_BUFFERS\n");
3379 for (i = 1; i < len;) {
3381 if (IS_GEN6(devid)) {
3389 "buffer %d: %s, pitch %db\n", data[i] >> idx,
3390 data[i] & (1 << access) ? "random" :
3391 "sequential", data[i] & 0x07ff);
3393 instr_out(ctx, i++, "buffer address\n");
3394 instr_out(ctx, i++, "max index\n");
3395 instr_out(ctx, i++, "mbz\n");
3400 if ((len + 1) % 2 != 0)
3401 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3402 instr_out(ctx, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3404 for (i = 1; i < len;) {
3406 "buffer %d: %svalid, type 0x%04x, "
3407 "src offset 0x%04x bytes\n",
3408 data[i] >> ((IS_GEN6(devid) || IS_GEN7(devid)) ? 26 : 27),
3409 data[i] & (1 << ((IS_GEN6(devid) || IS_GEN7(devid)) ? 25 : 26)) ?
3410 "" : "in", (data[i] >> 16) & 0x1ff,
3413 instr_out(ctx, i, "(%s, %s, %s, %s), "
3414 "dst offset 0x%02x bytes\n",
3415 get_965_element_component(data[i], 0),
3416 get_965_element_component(data[i], 1),
3417 get_965_element_component(data[i], 2),
3418 get_965_element_component(data[i], 3),
3419 (data[i] & 0xff) * 4);
3426 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3427 instr_out(ctx, 1, "clip\n");
3428 instr_out(ctx, 2, "sf\n");
3429 instr_out(ctx, 3, "cc\n");
3433 instr_out(ctx, 0, "3DSTATE_INDEX_BUFFER\n");
3434 instr_out(ctx, 1, "beginning buffer address\n");
3435 instr_out(ctx, 2, "ending buffer address\n");
3439 instr_out(ctx, 0, "3DSTATE_SCISSOR_POINTERS\n");
3440 instr_out(ctx, 1, "scissor rect offset\n");
3444 instr_out(ctx, 0, "3DSTATE_VS\n");
3445 instr_out(ctx, 1, "kernel pointer\n");
3447 "SPF=%d, VME=%d, Sampler Count %d, "
3448 "Binding table count %d\n", (data[2] >> 31) & 1,
3449 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3450 (data[2] >> 18) & 0xff);
3451 instr_out(ctx, 3, "scratch offset\n");
3453 "Dispatch GRF start %d, VUE read length %d, "
3454 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3455 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3457 "Max Threads %d, Vertex Cache %sable, "
3458 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3459 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3460 (data[5] & 1) != 0 ? "en" : "dis");
3464 instr_out(ctx, 0, "3DSTATE_GS\n");
3465 instr_out(ctx, 1, "kernel pointer\n");
3467 "SPF=%d, VME=%d, Sampler Count %d, "
3468 "Binding table count %d\n", (data[2] >> 31) & 1,
3469 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3470 (data[2] >> 18) & 0xff);
3471 instr_out(ctx, 3, "scratch offset\n");
3473 "Dispatch GRF start %d, VUE read length %d, "
3474 "VUE read offset %d\n", (data[4] & 0xf),
3475 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3477 "Max Threads %d, Rendering %sable\n",
3478 ((data[5] >> 25) & 0x7f) + 1,
3479 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3481 "Reorder %sable, Discard Adjaceny %sable, "
3483 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3484 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3485 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3489 instr_out(ctx, 0, "3DSTATE_CLIP\n");
3491 "UserClip distance cull test mask 0x%x\n",
3494 "Clip %sable, API mode %s, Viewport XY test %sable, "
3495 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3496 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3497 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3498 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3499 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3500 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3501 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3502 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3503 (data[2] >> 13) & 7,
3504 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3505 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3506 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3509 "Min PointWidth %d, Max PointWidth %d, "
3510 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3511 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3512 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3520 instr_out(ctx, 0, "3DSTATE_SF\n");
3522 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3523 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3524 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3525 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3527 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3528 "VP transform %sable, FrontWinding_%s\n",
3529 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3530 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3531 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3532 (data[2] & 1) != 0 ? "CCW" : "CW");
3534 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3535 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3536 (data[3] >> 29) & 3,
3537 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3538 (data[3] >> 8) & 3);
3540 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3541 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3542 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3543 (data[4] & (1 << 11)) != 0);
3545 "Global Depth Offset Constant %f\n",
3546 *(float *)(&data[5]));
3547 instr_out(ctx, 6, "Global Depth Offset Scale %f\n",
3548 *(float *)(&data[6]));
3549 instr_out(ctx, 7, "Global Depth Offset Clamp %f\n",
3550 *(float *)(&data[7]));
3552 for (i = 0, j = 0; i < 8; i++, j += 2)
3553 instr_out(ctx, i + 8,
3554 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3555 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3557 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3558 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3559 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3560 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3561 (data[8 + i] >> 25) & 3,
3562 (data[8 + i] >> 22) & 3,
3563 (data[8 + i] >> 16) & 0x1f, j,
3564 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3565 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3566 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3567 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3568 (data[8 + i] >> 9) & 3,
3569 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3571 "Point Sprite TexCoord Enable\n");
3572 instr_out(ctx, 17, "Const Interp Enable\n");
3574 "Attrib 7-0 WrapShortest Enable\n");
3576 "Attrib 15-8 WrapShortest Enable\n");
3581 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3582 instr_out(ctx, 1, "top left: %d,%d\n",
3583 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3584 instr_out(ctx, 2, "bottom right: %d,%d\n",
3585 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3586 instr_out(ctx, 3, "origin: %d,%d\n",
3587 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3592 instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n");
3593 if (IS_GEN5(devid) || IS_GEN6(devid))
3595 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3596 get_965_surfacetype(data[1] >> 29),
3597 get_965_depthformat((data[1] >> 18) & 0x7),
3598 (data[1] & 0x0001ffff) + 1,
3599 data[1] & (1 << 27) ? "" : "not ",
3600 (data[1] & (1 << 22)) != 0,
3601 (data[1] & (1 << 21)) != 0);
3604 "%s, %s, pitch = %d bytes, %stiled\n",
3605 get_965_surfacetype(data[1] >> 29),
3606 get_965_depthformat((data[1] >> 18) & 0x7),
3607 (data[1] & 0x0001ffff) + 1,
3608 data[1] & (1 << 27) ? "" : "not ");
3609 instr_out(ctx, 2, "depth offset\n");
3610 instr_out(ctx, 3, "%dx%d\n",
3611 ((data[3] & 0x0007ffc0) >> 6) + 1,
3612 ((data[3] & 0xfff80000) >> 19) + 1);
3613 instr_out(ctx, 4, "volume depth\n");
3615 instr_out(ctx, 5, "\n");
3618 instr_out(ctx, 6, "\n");
3621 "render target view extent\n");
3627 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3629 if (len != 4 && len != 5)
3630 fprintf(out, "Bad count in PIPE_CONTROL\n");
3632 switch ((data[1] >> 14) & 0x3) {
3637 desc1 = "qword write";
3640 desc1 = "PS_DEPTH_COUNT write";
3643 desc1 = "TIMESTAMP write";
3646 instr_out(ctx, 0, "PIPE_CONTROL\n");
3648 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3650 data[1] & (1 << 20) ? "cs stall, " : "",
3651 data[1] & (1 << 19) ?
3652 "global snapshot count reset, " : "",
3653 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3654 data[1] & (1 << 17) ? "gfdt flush, " : "",
3655 data[1] & (1 << 17) ? "media state clear, " :
3657 data[1] & (1 << 13) ? "depth stall, " : "",
3658 data[1] & (1 << 12) ?
3659 "render target cache flush, " : "",
3660 data[1] & (1 << 11) ?
3661 "instruction cache invalidate, " : "",
3662 data[1] & (1 << 10) ?
3663 "texture cache invalidate, " : "",
3664 data[1] & (1 << 9) ?
3665 "indirect state invalidate, " : "",
3666 data[1] & (1 << 8) ? "notify irq, " : "",
3667 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3669 data[1] & (1 << 6) ? "protect mem app_id, " :
3670 "", data[1] & (1 << 5) ? "DC flush, " : "",
3671 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3673 data[1] & (1 << 3) ?
3674 "constant cache invalidate, " : "",
3675 data[1] & (1 << 2) ?
3676 "state cache invalidate, " : "",
3677 data[1] & (1 << 1) ? "stall at scoreboard, " :
3679 data[1] & (1 << 0) ? "depth cache flush, " :
3683 "destination address\n");
3685 "immediate dword low\n");
3687 "immediate dword high\n");
3689 for (i = 2; i < len; i++) {
3690 instr_out(ctx, i, "\n");
3696 fprintf(out, "Bad count in PIPE_CONTROL\n");
3698 switch ((data[0] >> 14) & 0x3) {
3703 desc1 = "qword write";
3706 desc1 = "PS_DEPTH_COUNT write";
3709 desc1 = "TIMESTAMP write";
3713 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3716 data[0] & (1 << 13) ? "" : "no ",
3717 data[0] & (1 << 12) ? "" : "no ",
3718 data[0] & (1 << 11) ? "" : "no ");
3719 instr_out(ctx, 1, "destination address\n");
3720 instr_out(ctx, 2, "immediate dword low\n");
3721 instr_out(ctx, 3, "immediate dword high\n");
3727 if (opcode_3d->func) {
3728 return opcode_3d->func(ctx);
3732 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3734 for (i = 1; i < len; i++) {
3735 instr_out(ctx, i, "dword %d\n", i);
3741 instr_out(ctx, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3747 decode_3d_i830(struct drm_intel_decode *ctx)
3751 uint32_t *data = ctx->data;
3755 unsigned int min_len;
3756 unsigned int max_len;
3759 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3760 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3761 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3762 { 0x05, 1, 1, "3DSTATE_VFT0" },
3763 { 0x06, 1, 1, "3DSTATE_AA" },
3764 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3765 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3766 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3767 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3768 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3769 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3770 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3771 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3772 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3773 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3774 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3777 opcode = (data[0] & 0x1f000000) >> 24;
3781 return decode_3d_primitive(ctx);
3783 return decode_3d_1d(ctx);
3785 return decode_3d_1c(ctx);
3788 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3789 opcode_3d = &opcodes_3d[idx];
3790 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3791 unsigned int len = 1, i;
3793 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3794 if (opcode_3d->max_len > 1) {
3795 len = (data[0] & 0xff) + 2;
3796 if (len < opcode_3d->min_len ||
3797 len > opcode_3d->max_len) {
3798 fprintf(out, "Bad count in %s\n",
3803 for (i = 1; i < len; i++) {
3804 instr_out(ctx, i, "dword %d\n", i);
3810 instr_out(ctx, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3815 struct drm_intel_decode *
3816 drm_intel_decode_context_alloc(uint32_t devid)
3818 struct drm_intel_decode *ctx;
3820 ctx = calloc(1, sizeof(struct drm_intel_decode));
3829 else if (IS_GEN7(devid))
3831 else if (IS_GEN6(devid))
3833 else if (IS_GEN5(devid))
3835 else if (IS_GEN4(devid))
3837 else if (IS_9XX(devid))
3840 assert(IS_GEN2(devid));
3848 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3854 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3857 ctx->dump_past_end = !!dump_past_end;
3861 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3862 void *data, uint32_t hw_offset, int count)
3864 ctx->base_data = data;
3865 ctx->base_hw_offset = hw_offset;
3866 ctx->base_count = count;
3870 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3871 uint32_t head, uint32_t tail)
3878 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3885 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3887 * \param data batch buffer contents
3888 * \param count number of DWORDs to decode in the batch buffer
3889 * \param hw_offset hardware address for the buffer
3892 drm_intel_decode(struct drm_intel_decode *ctx)
3895 unsigned int index = 0;
3897 int size = ctx->base_count * 4;
3903 /* Put a scratch page full of obviously undefined data after
3904 * the batchbuffer. This lets us avoid a bunch of length
3905 * checking in statically sized packets.
3907 temp = malloc(size + 4096);
3908 memcpy(temp, ctx->base_data, size);
3909 memset((char *)temp + size, 0xd0, 4096);
3912 ctx->hw_offset = ctx->base_hw_offset;
3913 ctx->count = ctx->base_count;
3916 head_offset = ctx->head;
3917 tail_offset = ctx->tail;
3923 while (ctx->count > 0) {
3926 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3928 ret = decode_mi(ctx);
3930 /* If MI_BATCHBUFFER_END happened, then dump
3931 * the rest of the output in case we some day
3932 * want it in debugging, but don't decode it
3933 * since it'll just confuse in the common
3937 if (ctx->dump_past_end) {
3940 for (index = index + 1; index < ctx->count;
3942 instr_out(ctx, index, "\n");
3949 index += decode_2d(ctx);
3952 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3955 } else if (IS_GEN3(devid)) {
3956 index += decode_3d(ctx);
3959 decode_3d_i830(ctx);
3963 instr_out(ctx, index, "UNKNOWN\n");
3969 if (ctx->count < index)
3972 ctx->count -= index;
3974 ctx->hw_offset += 4 * index;