6 #include "intel_decode.h"
7 #include "intel_chipset.h"
10 static uint32_t saved_s2 = 0, saved_s4 = 0;
11 static char saved_s2_set = 0, saved_s4_set = 0;
12 static uint32_t head_offset = 0xffffffff; /* undefined */
13 static uint32_t tail_offset = 0xffffffff; /* undefined */
16 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
19 #define BUFFER_FAIL(_count, _len, _name) do { \
20 fprintf(out, "Buffer size too small in %s (%d < %d)\n", \
21 (_name), (_count), (_len)); \
28 int_as_float(uint32_t intval)
40 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
45 uint32_t offset = hw_offset + index * 4;
47 if (offset == head_offset)
49 else if (offset == tail_offset)
54 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
56 index == 0 ? "" : " ");
58 vfprintf(out, fmt, va);
63 decode_mi(uint32_t *data, int count, uint32_t hw_offset, int *failures)
74 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
75 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
76 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
77 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
78 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
79 { 0x04, 0, 1, 1, "MI_FLUSH" },
80 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
81 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
82 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
83 { 0x00, 0, 1, 1, "MI_NOOP" },
84 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
85 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
86 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
87 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
88 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
89 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
90 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
91 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
94 switch ((data[0] & 0x1f800000) >> 23) {
96 instr_out(data, hw_offset, 0, "MI_BATCH_BUFFER_END\n");
100 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
102 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
103 unsigned int len = 1, i;
105 instr_out(data, hw_offset, 0, "%s\n", opcodes_mi[opcode].name);
106 if (opcodes_mi[opcode].max_len > 1) {
107 len = (data[0] & opcodes_mi[opcode].len_mask) + 2;
108 if (len < opcodes_mi[opcode].min_len ||
109 len > opcodes_mi[opcode].max_len)
111 fprintf(out, "Bad length (%d) in %s, [%d, %d]\n",
112 len, opcodes_mi[opcode].name,
113 opcodes_mi[opcode].min_len,
114 opcodes_mi[opcode].max_len);
118 for (i = 1; i < len; i++) {
120 BUFFER_FAIL(count, len, opcodes_mi[opcode].name);
121 instr_out(data, hw_offset, i, "dword %d\n", i);
128 instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
134 decode_2d(uint32_t *data, int count, uint32_t hw_offset, int *failures)
136 unsigned int opcode, len;
145 { 0x40, 5, 5, "COLOR_BLT" },
146 { 0x43, 6, 6, "SRC_COPY_BLT" },
147 { 0x01, 8, 8, "XY_SETUP_BLT" },
148 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
149 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
150 { 0x24, 2, 2, "XY_PIXEL_BLT" },
151 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
152 { 0x26, 4, 4, "Y_TEXT_BLT" },
153 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
154 { 0x50, 6, 6, "XY_COLOR_BLT" },
155 { 0x51, 6, 6, "XY_PAT_BLT" },
156 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
157 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
158 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
159 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
160 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
161 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
162 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
163 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
164 { 0x55, 9, 9, "XY_FULL_BLT" },
165 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
166 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
167 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
168 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
169 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT" },
172 switch ((data[0] & 0x1fc00000) >> 22) {
174 instr_out(data, hw_offset, 0,
175 "XY_COLOR_BLT (rgb %sabled, alpha %sabled, dst tile %d)\n",
176 (data[0] & (1 << 20)) ? "en" : "dis",
177 (data[0] & (1 << 21)) ? "en" : "dis",
178 (data[0] >> 11) & 1);
180 len = (data[0] & 0x000000ff) + 2;
182 fprintf(out, "Bad count in XY_COLOR_BLT\n");
184 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
186 switch ((data[1] >> 24) & 0x3) {
201 instr_out(data, hw_offset, 1, "format %s, pitch %d, "
202 "clipping %sabled\n", format,
203 (short)(data[1] & 0xffff),
204 data[1] & (1 << 30) ? "en" : "dis");
205 instr_out(data, hw_offset, 2, "(%d,%d)\n",
206 data[2] & 0xffff, data[2] >> 16);
207 instr_out(data, hw_offset, 3, "(%d,%d)\n",
208 data[3] & 0xffff, data[3] >> 16);
209 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
210 instr_out(data, hw_offset, 5, "color\n");
213 instr_out(data, hw_offset, 0,
214 "XY_SRC_COPY_BLT (rgb %sabled, alpha %sabled, "
215 "src tile %d, dst tile %d)\n",
216 (data[0] & (1 << 20)) ? "en" : "dis",
217 (data[0] & (1 << 21)) ? "en" : "dis",
219 (data[0] >> 11) & 1);
221 len = (data[0] & 0x000000ff) + 2;
223 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
225 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
227 switch ((data[1] >> 24) & 0x3) {
242 instr_out(data, hw_offset, 1, "format %s, dst pitch %d, "
243 "clipping %sabled\n", format,
244 (short)(data[1] & 0xffff),
245 data[1] & (1 << 30) ? "en" : "dis");
246 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
247 data[2] & 0xffff, data[2] >> 16);
248 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
249 data[3] & 0xffff, data[3] >> 16);
250 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
251 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
252 data[5] & 0xffff, data[5] >> 16);
253 instr_out(data, hw_offset, 6, "src pitch %d\n",
254 (short)(data[6] & 0xffff));
255 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
259 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
261 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
265 instr_out(data, hw_offset, 0, "%s\n", opcodes_2d[opcode].name);
266 if (opcodes_2d[opcode].max_len > 1) {
267 len = (data[0] & 0x000000ff) + 2;
268 if (len < opcodes_2d[opcode].min_len ||
269 len > opcodes_2d[opcode].max_len)
271 fprintf(out, "Bad count in %s\n", opcodes_2d[opcode].name);
275 for (i = 1; i < len; i++) {
277 BUFFER_FAIL(count, len, opcodes_2d[opcode].name);
278 instr_out(data, hw_offset, i, "dword %d\n", i);
285 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
291 decode_3d_1c(uint32_t *data, int count, uint32_t hw_offset, int *failures)
295 opcode = (data[0] & 0x00f80000) >> 19;
299 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
302 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE\n");
305 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
308 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
311 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
315 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
321 /** Sets the string dstname to describe the destination of the PS instruction */
323 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
325 uint32_t a0 = data[i];
326 int dst_nr = (a0 >> 14) & 0xf;
331 if (((a0 >> 10) & 0xf) == 0xf) {
334 int dstmask_index = 0;
336 dstmask[dstmask_index++] = '.';
338 dstmask[dstmask_index++] = 'x';
340 dstmask[dstmask_index++] = 'y';
342 dstmask[dstmask_index++] = 'z';
344 dstmask[dstmask_index++] = 'w';
345 dstmask[dstmask_index++] = 0;
357 switch ((a0 >> 19) & 0x7) {
360 fprintf(out, "bad destination reg R%d\n", dst_nr);
361 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
365 fprintf(out, "bad destination reg oC%d\n", dst_nr);
366 sprintf(dstname, "oC%s%s", dstmask, sat);
370 fprintf(out, "bad destination reg oD%d\n", dst_nr);
371 sprintf(dstname, "oD%s%s", dstmask, sat);
375 fprintf(out, "bad destination reg U%d\n", dst_nr);
376 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
379 sprintf(dstname, "RESERVED");
385 i915_get_channel_swizzle(uint32_t select)
387 switch (select & 0x7) {
389 return (select & 8) ? "-x" : "x";
391 return (select & 8) ? "-y" : "y";
393 return (select & 8) ? "-z" : "z";
395 return (select & 8) ? "-w" : "w";
397 return (select & 8) ? "-0" : "0";
399 return (select & 8) ? "-1" : "1";
401 return (select & 8) ? "-bad" : "bad";
406 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
410 sprintf(name, "R%d", src_nr);
412 fprintf(out, "bad src reg %s\n", name);
416 sprintf(name, "T%d", src_nr);
417 else if (src_nr == 8)
418 sprintf(name, "DIFFUSE");
419 else if (src_nr == 9)
420 sprintf(name, "SPECULAR");
421 else if (src_nr == 10)
422 sprintf(name, "FOG");
424 fprintf(out, "bad src reg T%d\n", src_nr);
425 sprintf(name, "RESERVED");
429 sprintf(name, "C%d", src_nr);
431 fprintf(out, "bad src reg %s\n", name);
436 fprintf(out, "bad src reg oC%d\n", src_nr);
441 fprintf(out, "bad src reg oD%d\n", src_nr);
444 sprintf(name, "U%d", src_nr);
446 fprintf(out, "bad src reg %s\n", name);
449 fprintf(out, "bad src reg type %d\n", src_type);
450 sprintf(name, "RESERVED");
456 i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
458 uint32_t a0 = data[i];
459 uint32_t a1 = data[i + 1];
460 int src_nr = (a0 >> 2) & 0x1f;
461 char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
462 char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
463 char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
464 char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
467 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
468 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w);
469 if (strcmp(swizzle, ".xyzw") != 0)
470 strcat(srcname, swizzle);
474 i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
476 uint32_t a1 = data[i + 1];
477 uint32_t a2 = data[i + 2];
478 int src_nr = (a1 >> 8) & 0x1f;
479 char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
480 char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
481 char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
482 char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
485 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
486 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w);
487 if (strcmp(swizzle, ".xyzw") != 0)
488 strcat(srcname, swizzle);
492 i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
494 uint32_t a2 = data[i + 2];
495 int src_nr = (a2 >> 16) & 0x1f;
496 char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
497 char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
498 char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
499 char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
502 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
503 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, swizzle_w);
504 if (strcmp(swizzle, ".xyzw") != 0)
505 strcat(srcname, swizzle);
509 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
513 sprintf(name, "R%d", src_nr);
515 fprintf(out, "bad src reg %s\n", name);
519 sprintf(name, "T%d", src_nr);
520 else if (src_nr == 8)
521 sprintf(name, "DIFFUSE");
522 else if (src_nr == 9)
523 sprintf(name, "SPECULAR");
524 else if (src_nr == 10)
525 sprintf(name, "FOG");
527 fprintf(out, "bad src reg T%d\n", src_nr);
528 sprintf(name, "RESERVED");
534 fprintf(out, "bad src reg oC%d\n", src_nr);
539 fprintf(out, "bad src reg oD%d\n", src_nr);
542 fprintf(out, "bad src reg type %d\n", src_type);
543 sprintf(name, "RESERVED");
549 i915_decode_alu1(uint32_t *data, uint32_t hw_offset,
550 int i, char *instr_prefix, char *op_name)
552 char dst[100], src0[100];
554 i915_get_instruction_dst(data, i, dst, 1);
555 i915_get_instruction_src0(data, i, src0);
557 instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
559 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
560 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
564 i915_decode_alu2(uint32_t *data, uint32_t hw_offset,
565 int i, char *instr_prefix, char *op_name)
567 char dst[100], src0[100], src1[100];
569 i915_get_instruction_dst(data, i, dst, 1);
570 i915_get_instruction_src0(data, i, src0);
571 i915_get_instruction_src1(data, i, src1);
573 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
574 op_name, dst, src0, src1);
575 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
576 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
580 i915_decode_alu3(uint32_t *data, uint32_t hw_offset,
581 int i, char *instr_prefix, char *op_name)
583 char dst[100], src0[100], src1[100], src2[100];
585 i915_get_instruction_dst(data, i, dst, 1);
586 i915_get_instruction_src0(data, i, src0);
587 i915_get_instruction_src1(data, i, src1);
588 i915_get_instruction_src2(data, i, src2);
590 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
591 op_name, dst, src0, src1, src2);
592 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
593 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
597 i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix,
600 uint32_t t0 = data[i];
601 uint32_t t1 = data[i + 1];
606 i915_get_instruction_dst(data, i, dst_name, 0);
607 i915_get_instruction_addr((t1 >> 24) & 0x7,
610 sampler_nr = t0 & 0xf;
612 instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
613 tex_name, dst_name, sampler_nr, addr_name);
614 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
615 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
619 i915_decode_dcl(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
621 uint32_t d0 = data[i];
623 int dcl_nr = (d0 >> 14) & 0xf;
624 char *dcl_x = d0 & (1 << 10) ? "x" : "";
625 char *dcl_y = d0 & (1 << 11) ? "y" : "";
626 char *dcl_z = d0 & (1 << 12) ? "z" : "";
627 char *dcl_w = d0 & (1 << 13) ? "w" : "";
630 switch ((d0 >> 19) & 0x3) {
632 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
633 if (strcmp(dcl_mask, ".") == 0)
634 fprintf(out, "bad (empty) dcl mask\n");
637 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
639 if (strcmp(dcl_mask, ".x") != 0 &&
640 strcmp(dcl_mask, ".xy") != 0 &&
641 strcmp(dcl_mask, ".xz") != 0 &&
642 strcmp(dcl_mask, ".w") != 0 &&
643 strcmp(dcl_mask, ".xyzw") != 0) {
644 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr, dcl_mask);
646 instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n", instr_prefix,
649 if (strcmp(dcl_mask, ".xz") == 0)
650 fprintf(out, "errataed bad dcl mask %s\n", dcl_mask);
651 else if (strcmp(dcl_mask, ".xw") == 0)
652 fprintf(out, "errataed bad dcl mask %s\n", dcl_mask);
653 else if (strcmp(dcl_mask, ".xzw") == 0)
654 fprintf(out, "errataed bad dcl mask %s\n", dcl_mask);
657 instr_out(data, hw_offset, i++, "%s: DCL DIFFUSE%s\n", instr_prefix,
659 } else if (dcl_nr == 9) {
660 instr_out(data, hw_offset, i++, "%s: DCL SPECULAR%s\n", instr_prefix,
662 } else if (dcl_nr == 10) {
663 instr_out(data, hw_offset, i++, "%s: DCL FOG%s\n", instr_prefix,
667 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
668 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
671 switch ((d0 >> 22) & 0x3) {
682 sampletype = "RESERVED";
686 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
687 instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n", instr_prefix,
689 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
690 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
693 instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n", instr_prefix, dcl_nr);
694 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
695 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
700 i915_decode_instruction(uint32_t *data, uint32_t hw_offset,
701 int i, char *instr_prefix)
703 switch ((data[i] >> 24) & 0x1f) {
705 instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
706 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
707 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
710 i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
713 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
716 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
719 i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
722 i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
725 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
728 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
731 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
734 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
737 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
740 i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
743 i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
746 i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
749 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
752 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
755 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
758 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
761 i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
764 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
767 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
770 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
773 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
776 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
779 i915_decode_dcl(data, hw_offset, i, instr_prefix);
782 instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
783 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
784 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
790 decode_3d_1d(uint32_t *data, int count,
795 unsigned int len, i, c, idx, word, map, sampler, instr;
805 } opcodes_3d_1d[] = {
806 { 0x8e, 0, 3, 3, "3DSTATE_BUFFER_INFO" },
807 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
808 { 0x9c, 0, 7, 7, "3DSTATE_CLEAR_PARAMETERS" },
809 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
810 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
811 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
812 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
813 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
814 { 0x85, 0, 2, 2, "3DSTATE_DEST_BUFFER_VARIABLES" },
815 { 0x80, 0, 5, 5, "3DSTATE_DRAWING_RECTANGLE" },
816 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
817 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
818 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
819 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
820 { 0x81, 0, 3, 3, "3DSTATE_SCISSOR_RECTANGLE" },
821 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
822 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
823 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
824 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
825 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
826 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830" },
829 opcode = (data[0] & 0x00ff0000) >> 16;
833 /* This instruction is unusual. A 0 length means just 1 DWORD instead of
834 * 2. The 0 length is specified in one place to be unsupported, but
835 * stated to be required in another, and 0 length LOAD_INDIRECTs appear
836 * to cause no harm at least.
838 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
839 len = (data[0] & 0x000000ff) + 1;
841 if (data[0] & (0x01 << 8)) {
843 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
844 instr_out(data, hw_offset, i++, "SIS.0\n");
845 instr_out(data, hw_offset, i++, "SIS.1\n");
847 if (data[0] & (0x02 << 8)) {
849 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
850 instr_out(data, hw_offset, i++, "DIS.0\n");
852 if (data[0] & (0x04 << 8)) {
854 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
855 instr_out(data, hw_offset, i++, "SSB.0\n");
856 instr_out(data, hw_offset, i++, "SSB.1\n");
858 if (data[0] & (0x08 << 8)) {
860 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
861 instr_out(data, hw_offset, i++, "MSB.0\n");
862 instr_out(data, hw_offset, i++, "MSB.1\n");
864 if (data[0] & (0x10 << 8)) {
866 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
867 instr_out(data, hw_offset, i++, "PSP.0\n");
868 instr_out(data, hw_offset, i++, "PSP.1\n");
870 if (data[0] & (0x20 << 8)) {
872 BUFFER_FAIL(count, len, "3DSTATE_LOAD_INDIRECT");
873 instr_out(data, hw_offset, i++, "PSC.0\n");
874 instr_out(data, hw_offset, i++, "PSC.1\n");
877 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
883 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
884 len = (data[0] & 0x0000000f) + 2;
886 for (word = 0; word <= 8; word++) {
887 if (data[0] & (1 << (4 + word))) {
889 BUFFER_FAIL(count, len, "3DSTATE_LOAD_STATE_IMMEDIATE_1");
891 /* save vertex state for decode */
903 instr_out(data, hw_offset, i++, "S%d\n", word);
907 fprintf(out, "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
912 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
913 len = (data[0] & 0x0000000f) + 2;
915 for (word = 6; word <= 14; word++) {
916 if (data[0] & (1 << word)) {
918 BUFFER_FAIL(count, len, "3DSTATE_LOAD_STATE_IMMEDIATE_2");
921 instr_out(data, hw_offset, i++, "TBCF\n");
922 else if (word >= 7 && word <= 10) {
923 instr_out(data, hw_offset, i++, "TB%dC\n", word - 7);
924 instr_out(data, hw_offset, i++, "TB%dA\n", word - 7);
925 } else if (word >= 11 && word <= 14) {
926 instr_out(data, hw_offset, i++, "TM%dS0\n", word - 11);
927 instr_out(data, hw_offset, i++, "TM%dS1\n", word - 11);
928 instr_out(data, hw_offset, i++, "TM%dS2\n", word - 11);
929 instr_out(data, hw_offset, i++, "TM%dS3\n", word - 11);
930 instr_out(data, hw_offset, i++, "TM%dS4\n", word - 11);
935 fprintf(out, "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
940 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
941 len = (data[0] & 0x0000003f) + 2;
942 instr_out(data, hw_offset, 1, "mask\n");
945 for (map = 0; map <= 15; map++) {
946 if (data[1] & (1 << map)) {
947 int width, height, pitch, dword;
951 BUFFER_FAIL(count, len, "3DSTATE_MAP_STATE");
953 instr_out(data, hw_offset, i++, "map %d MS2\n", map);
956 width = ((dword >> 10) & ((1 << 11) - 1))+1;
957 height = ((dword >> 21) & ((1 << 11) - 1))+1;
960 if (dword & (1 << 2))
962 else if (dword & (1 << 1))
963 tiling = dword & (1 << 0) ? "Y" : "X";
964 instr_out(data, hw_offset, i++, "map %d MS3 [width=%d, height=%d, tiling=%s]\n", map, width, height, tiling);
967 pitch = 4*(((dword >> 21) & ((1 << 11) - 1))+1);
968 instr_out(data, hw_offset, i++, "map %d MS4 [pitch=%d]\n", map, pitch);
972 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
978 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
979 len = (data[0] & 0x000000ff) + 2;
982 for (c = 0; c <= 31; c++) {
983 if (data[1] & (1 << c)) {
985 BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_CONSTANTS");
986 instr_out(data, hw_offset, i, "C%d.X = %f\n",
987 c, int_as_float(data[i]));
989 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
990 c, int_as_float(data[i]));
992 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
993 c, int_as_float(data[i]));
995 instr_out(data, hw_offset, i, "C%d.W = %f\n",
996 c, int_as_float(data[i]));
1001 fprintf(out, "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1006 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1007 len = (data[0] & 0x000000ff) + 2;
1008 if ((len - 1) % 3 != 0 || len > 370) {
1009 fprintf(out, "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1013 for (instr = 0; instr < (len - 1) / 3; instr++) {
1014 char instr_prefix[10];
1017 BUFFER_FAIL(count, len, "3DSTATE_PIXEL_SHADER_PROGRAM");
1018 sprintf(instr_prefix, "PS%03d", instr);
1019 i915_decode_instruction(data, hw_offset, i, instr_prefix);
1026 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
1027 instr_out(data, hw_offset, 1, "mask\n");
1028 len = (data[0] & 0x0000003f) + 2;
1030 for (sampler = 0; sampler <= 15; sampler++) {
1031 if (data[1] & (1 << sampler)) {
1033 BUFFER_FAIL(count, len, "3DSTATE_SAMPLER_STATE");
1034 instr_out(data, hw_offset, i++, "sampler %d SS2\n",
1036 instr_out(data, hw_offset, i++, "sampler %d SS3\n",
1038 instr_out(data, hw_offset, i++, "sampler %d SS4\n",
1043 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
1048 len = (data[0] & 0x0000000f) + 2;
1051 fprintf(out, "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
1053 BUFFER_FAIL(count, len, "3DSTATE_DEST_BUFFER_VARIABLES");
1055 instr_out(data, hw_offset, 0,
1056 "3DSTATE_DEST_BUFFER_VARIABLES\n");
1058 switch ((data[1] >> 8) & 0xf) {
1059 case 0x0: format = "g8"; break;
1060 case 0x1: format = "x1r5g5b5"; break;
1061 case 0x2: format = "r5g6b5"; break;
1062 case 0x3: format = "a8r8g8b8"; break;
1063 case 0x4: format = "ycrcb_swapy"; break;
1064 case 0x5: format = "ycrcb_normal"; break;
1065 case 0x6: format = "ycrcb_swapuv"; break;
1066 case 0x7: format = "ycrcb_swapuvy"; break;
1067 case 0x8: format = "a4r4g4b4"; break;
1068 case 0x9: format = "a1r5g5b5"; break;
1069 case 0xa: format = "a2r10g10b10"; break;
1070 default: format = "BAD"; break;
1072 instr_out(data, hw_offset, 1, "%s format, early Z %sabled\n",
1074 (data[1] & (1 << 31)) ? "en" : "dis");
1079 const char *name, *tiling;
1081 len = (data[0] & 0x0000000f) + 2;
1083 fprintf(out, "Bad count in 3DSTATE_BUFFER_INFO\n");
1085 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
1087 switch((data[1] >> 24) & 0x7) {
1088 case 0x3: name = "color"; break;
1089 case 0x7: name = "depth"; break;
1090 default: name = "unknown"; break;
1094 if (data[1] & (1 << 23))
1096 else if (data[1] & (1 << 22))
1097 tiling = data[1] & (1 << 21) ? "Y" : "X";
1099 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
1100 instr_out(data, hw_offset, 1, "%s, tiling = %s, pitch=%d\n", name, tiling, data[1]&0xffff);
1102 instr_out(data, hw_offset, 2, "address\n");
1107 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++)
1109 opcode_3d_1d = &opcodes_3d_1d[idx];
1110 if (opcode_3d_1d->i830_only && IS_9XX(devid))
1113 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
1116 instr_out(data, hw_offset, 0, "%s\n", opcode_3d_1d->name);
1117 if (opcode_3d_1d->max_len > 1) {
1118 len = (data[0] & 0x0000ffff) + 2;
1119 if (len < opcode_3d_1d->min_len ||
1120 len > opcode_3d_1d->max_len)
1122 fprintf(out, "Bad count in %s\n",
1123 opcode_3d_1d->name);
1128 for (i = 1; i < len; i++) {
1130 BUFFER_FAIL(count, len, opcode_3d_1d->name);
1131 instr_out(data, hw_offset, i, "dword %d\n", i);
1138 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n", opcode);
1144 decode_3d_primitive(uint32_t *data, int count, uint32_t hw_offset,
1147 char immediate = (data[0] & (1 << 23)) == 0;
1148 unsigned int len, i, j, ret;
1150 int original_s2 = saved_s2;
1151 int original_s4 = saved_s4;
1153 switch ((data[0] >> 18) & 0xf) {
1154 case 0x0: primtype = "TRILIST"; break;
1155 case 0x1: primtype = "TRISTRIP"; break;
1156 case 0x2: primtype = "TRISTRIP_REVERSE"; break;
1157 case 0x3: primtype = "TRIFAN"; break;
1158 case 0x4: primtype = "POLYGON"; break;
1159 case 0x5: primtype = "LINELIST"; break;
1160 case 0x6: primtype = "LINESTRIP"; break;
1161 case 0x7: primtype = "RECTLIST"; break;
1162 case 0x8: primtype = "POINTLIST"; break;
1163 case 0x9: primtype = "DIB"; break;
1164 case 0xa: primtype = "CLEAR_RECT"; saved_s4 = 3 << 6; saved_s2 = ~0; break;
1165 default: primtype = "unknown"; break;
1168 /* XXX: 3DPRIM_DIB not supported */
1170 len = (data[0] & 0x0003ffff) + 2;
1171 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n", primtype);
1173 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
1174 if (!saved_s2_set || !saved_s4_set) {
1175 fprintf(out, "unknown vertex format\n");
1176 for (i = 1; i < len; i++) {
1177 instr_out(data, hw_offset, i,
1178 " vertex data (%f float)\n",
1179 int_as_float(data[i]));
1182 unsigned int vertex = 0;
1183 for (i = 1; i < len;) {
1186 #define VERTEX_OUT(fmt, ...) do { \
1188 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
1190 fprintf(out, " missing data in V%d\n", vertex); \
1194 VERTEX_OUT("X = %f", int_as_float(data[i]));
1195 VERTEX_OUT("Y = %f", int_as_float(data[i]));
1196 switch (saved_s4 >> 6 & 0x7) {
1198 VERTEX_OUT("Z = %f", int_as_float(data[i]));
1201 VERTEX_OUT("Z = %f", int_as_float(data[i]));
1202 VERTEX_OUT("W = %f", int_as_float(data[i]));
1207 VERTEX_OUT("W = %f", int_as_float(data[i]));
1210 fprintf(out, "bad S4 position mask\n");
1213 if (saved_s4 & (1 << 10)) {
1214 VERTEX_OUT("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
1217 (data[i] >> 16) & 0xff,
1218 (data[i] >> 8) & 0xff,
1221 if (saved_s4 & (1 << 11)) {
1222 VERTEX_OUT("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
1225 (data[i] >> 16) & 0xff,
1226 (data[i] >> 8) & 0xff,
1229 if (saved_s4 & (1 << 12))
1230 VERTEX_OUT("width = 0x%08x)", data[i]);
1232 for (tc = 0; tc <= 7; tc++) {
1233 switch ((saved_s2 >> (tc * 4)) & 0xf) {
1235 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
1236 VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
1239 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
1240 VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
1241 VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
1244 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
1245 VERTEX_OUT("T%d.Y = %f", tc, int_as_float(data[i]));
1246 VERTEX_OUT("T%d.Z = %f", tc, int_as_float(data[i]));
1247 VERTEX_OUT("T%d.W = %f", tc, int_as_float(data[i]));
1250 VERTEX_OUT("T%d.X = %f", tc, int_as_float(data[i]));
1253 VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
1256 VERTEX_OUT("T%d.XY = 0x%08x half-float", tc, data[i]);
1257 VERTEX_OUT("T%d.ZW = 0x%08x half-float", tc, data[i]);
1262 fprintf(out, "bad S2.T%d format\n", tc);
1271 /* indirect vertices */
1272 len = data[0] & 0x0000ffff; /* index count */
1273 if (data[0] & (1 << 17)) {
1274 /* random vertex access */
1275 if (count < (len + 1) / 2 + 1) {
1276 BUFFER_FAIL(count, (len + 1) / 2 + 1,
1277 "3DPRIMITIVE random indirect");
1279 instr_out(data, hw_offset, 0,
1280 "3DPRIMITIVE random indirect %s (%d)\n", primtype, len);
1282 /* vertex indices continue until 0xffff is found */
1283 for (i = 1; i < count; i++) {
1284 if ((data[i] & 0xffff) == 0xffff) {
1285 instr_out(data, hw_offset, i,
1286 " indices: (terminator)\n");
1289 } else if ((data[i] >> 16) == 0xffff) {
1290 instr_out(data, hw_offset, i,
1291 " indices: 0x%04x, (terminator)\n",
1296 instr_out(data, hw_offset, i,
1297 " indices: 0x%04x, 0x%04x\n",
1298 data[i] & 0xffff, data[i] >> 16);
1302 "3DPRIMITIVE: no terminator found in index buffer\n");
1307 /* fixed size vertex index buffer */
1308 for (j = 1, i = 0; i < len; i += 2, j++) {
1309 if (i * 2 == len - 1) {
1310 instr_out(data, hw_offset, j,
1311 " indices: 0x%04x\n",
1314 instr_out(data, hw_offset, j,
1315 " indices: 0x%04x, 0x%04x\n",
1316 data[j] & 0xffff, data[j] >> 16);
1320 ret = (len + 1) / 2 + 1;
1323 /* sequential vertex access */
1325 BUFFER_FAIL(count, 2, "3DPRIMITIVE seq indirect");
1326 instr_out(data, hw_offset, 0,
1327 "3DPRIMITIVE sequential indirect %s, %d starting from "
1328 "%d\n", primtype, len, data[1] & 0xffff);
1329 instr_out(data, hw_offset, 1, " start\n");
1336 saved_s2 = original_s2;
1337 saved_s4 = original_s4;
1342 decode_3d(uint32_t *data, int count, uint32_t hw_offset, uint32_t devid, int *failures)
1353 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
1354 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
1355 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
1356 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
1357 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
1358 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
1359 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
1360 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
1361 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
1364 opcode = (data[0] & 0x1f000000) >> 24;
1368 return decode_3d_primitive(data, count, hw_offset, failures);
1370 return decode_3d_1d(data, count, hw_offset, devid, failures);
1372 return decode_3d_1c(data, count, hw_offset, failures);
1375 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
1376 opcode_3d = &opcodes_3d[idx];
1377 if (opcode == opcode_3d->opcode) {
1378 unsigned int len = 1, i;
1380 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
1381 if (opcode_3d->max_len > 1) {
1382 len = (data[0] & 0xff) + 2;
1383 if (len < opcode_3d->min_len ||
1384 len > opcode_3d->max_len)
1386 fprintf(out, "Bad count in %s\n", opcode_3d->name);
1390 for (i = 1; i < len; i++) {
1392 BUFFER_FAIL(count, len, opcode_3d->name);
1393 instr_out(data, hw_offset, i, "dword %d\n", i);
1399 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
1405 get_965_surfacetype(unsigned int surfacetype)
1407 switch (surfacetype) {
1408 case 0: return "1D";
1409 case 1: return "2D";
1410 case 2: return "3D";
1411 case 3: return "CUBE";
1412 case 4: return "BUFFER";
1413 case 7: return "NULL";
1414 default: return "unknown";
1419 get_965_depthformat(unsigned int depthformat)
1421 switch (depthformat) {
1422 case 0: return "s8_z24float";
1423 case 1: return "z32float";
1424 case 2: return "z24s8";
1425 case 5: return "z16";
1426 default: return "unknown";
1431 get_965_element_component(uint32_t data, int component)
1433 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
1435 switch (component_control) {
1439 switch (component) {
1444 default: return "fail";
1460 get_965_prim_type(uint32_t data)
1462 uint32_t primtype = (data >> 10) & 0x1f;
1465 case 0x01: return "point list";
1466 case 0x02: return "line list";
1467 case 0x03: return "line strip";
1468 case 0x04: return "tri list";
1469 case 0x05: return "tri strip";
1470 case 0x06: return "tri fan";
1471 case 0x07: return "quad list";
1472 case 0x08: return "quad strip";
1473 case 0x09: return "line list adj";
1474 case 0x0a: return "line strip adj";
1475 case 0x0b: return "tri list adj";
1476 case 0x0c: return "tri strip adj";
1477 case 0x0d: return "tri strip reverse";
1478 case 0x0e: return "polygon";
1479 case 0x0f: return "rect list";
1480 case 0x10: return "line loop";
1481 case 0x11: return "point list bf";
1482 case 0x12: return "line strip cont";
1483 case 0x13: return "line strip bf";
1484 case 0x14: return "line strip cont bf";
1485 case 0x15: return "tri fan no stipple";
1486 default: return "fail";
1491 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len, int count,
1494 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
1497 fprintf(out, "Bad count in URB_FENCE\n");
1499 BUFFER_FAIL(count, len, "URB_FENCE");
1501 vs_fence = data[1] & 0x3ff;
1502 gs_fence = (data[1] >> 10) & 0x3ff;
1503 clip_fence = (data[1] >> 20) & 0x3ff;
1504 sf_fence = data[2] & 0x3ff;
1505 vfe_fence = (data[2] >> 10) & 0x3ff;
1506 cs_fence = (data[2] >> 20) & 0x7ff;
1508 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
1509 (data[0] >> 13) & 1 ? "cs " : "",
1510 (data[0] >> 12) & 1 ? "vfe " : "",
1511 (data[0] >> 11) & 1 ? "sf " : "",
1512 (data[0] >> 10) & 1 ? "clip " : "",
1513 (data[0] >> 9) & 1 ? "gs " : "",
1514 (data[0] >> 8) & 1 ? "vs " : "");
1515 instr_out(data, hw_offset, 1,
1516 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
1517 vs_fence, clip_fence, gs_fence);
1518 instr_out(data, hw_offset, 2,
1519 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
1520 sf_fence, vfe_fence, cs_fence);
1521 if (gs_fence < vs_fence)
1522 fprintf(out, "gs fence < vs fence!\n");
1523 if (clip_fence < gs_fence)
1524 fprintf(out, "clip fence < gs fence!\n");
1525 if (sf_fence < clip_fence)
1526 fprintf(out, "sf fence < clip fence!\n");
1527 if (cs_fence < sf_fence)
1528 fprintf(out, "cs fence < sf fence!\n");
1534 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
1537 if (data[index] & 1) {
1538 instr_out(data, hw_offset, index, "%s state base address 0x%08x\n",
1539 name, data[index] & ~1);
1541 instr_out(data, hw_offset, index, "%s state base not updated\n",
1547 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
1550 if (data[index] & 1) {
1551 if (data[index] == 1) {
1552 instr_out(data, hw_offset, index,
1553 "%s state upper bound disabled\n", name);
1555 instr_out(data, hw_offset, index, "%s state upper bound 0x%08x\n",
1556 name, data[index] & ~1);
1559 instr_out(data, hw_offset, index, "%s state upper bound not updated\n",
1565 decode_3d_965(uint32_t *data, int count, uint32_t hw_offset, uint32_t devid, int *failures)
1568 unsigned int idx, len;
1578 { 0x6000, 3, 3, "URB_FENCE" },
1579 { 0x6001, 2, 2, "CS_URB_STATE" },
1580 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
1581 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
1582 { 0x6102, 2, 2 , "STATE_SIP" },
1583 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
1584 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
1585 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
1586 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
1587 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
1588 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
1589 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
1590 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
1591 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
1592 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
1593 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
1594 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
1595 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
1596 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
1597 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
1598 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
1599 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
1600 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
1601 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
1602 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
1603 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
1604 { 0x7b00, 6, 6, "3DPRIMITIVE" },
1605 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
1606 { 0x7805, 3, 3, "3DSTATE_URB" },
1607 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
1608 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
1609 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
1610 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
1611 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
1612 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
1613 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
1614 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
1615 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
1616 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
1617 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
1618 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK" },
1621 len = (data[0] & 0x0000ffff) + 2;
1623 opcode = (data[0] & 0xffff0000) >> 16;
1626 len = (data[0] & 0x000000ff) + 2;
1627 return i965_decode_urb_fence(data, hw_offset, len, count, failures);
1629 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
1630 instr_out(data, hw_offset, 1, "entry_size: %d [%d bytes], n_entries: %d\n",
1631 (data[1] >> 4) & 0x1f,
1632 (((data[1] >> 4) & 0x1f) + 1) * 64,
1636 len = (data[0] & 0x000000ff) + 2;
1637 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
1638 (data[0] >> 8) & 1 ? "valid" : "invalid");
1639 instr_out(data, hw_offset, 1, "offset: 0x%08x, length: %d bytes\n",
1640 data[1] & ~0x3f, ((data[1] & 0x3f) + 1) * 64);
1645 else if (IS_IRONLAKE(devid))
1650 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
1652 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
1655 instr_out(data, hw_offset, 0,
1656 "STATE_BASE_ADDRESS\n");
1659 state_base_out(data, hw_offset, i++, "general");
1660 state_base_out(data, hw_offset, i++, "surface");
1662 state_base_out(data, hw_offset, i++, "dynamic");
1663 state_base_out(data, hw_offset, i++, "indirect");
1664 if (IS_IRONLAKE(devid) || IS_GEN6(devid))
1665 state_base_out(data, hw_offset, i++, "instruction");
1667 state_max_out(data, hw_offset, i++, "general");
1669 state_max_out(data, hw_offset, i++, "dynamic");
1670 state_max_out(data, hw_offset, i++, "indirect");
1671 if (IS_IRONLAKE(devid) || IS_GEN6(devid))
1672 state_max_out(data, hw_offset, i++, "instruction");
1677 fprintf(out, "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
1679 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
1681 instr_out(data, hw_offset, 0,
1682 "3DSTATE_PIPELINED_POINTERS\n");
1683 instr_out(data, hw_offset, 1, "VS state\n");
1684 instr_out(data, hw_offset, 2, "GS state\n");
1685 instr_out(data, hw_offset, 3, "Clip state\n");
1686 instr_out(data, hw_offset, 4, "SF state\n");
1687 instr_out(data, hw_offset, 5, "WM state\n");
1688 instr_out(data, hw_offset, 6, "CC state\n");
1691 len = (data[0] & 0x000000ff) + 2;
1692 if (len != 6 && len != 4)
1693 fprintf(out, "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
1696 BUFFER_FAIL(count, len, "3DSTATE_BINDING_TABLE_POINTERS");
1697 instr_out(data, hw_offset, 0,
1698 "3DSTATE_BINDING_TABLE_POINTERS\n");
1699 instr_out(data, hw_offset, 1, "VS binding table\n");
1700 instr_out(data, hw_offset, 2, "GS binding table\n");
1701 instr_out(data, hw_offset, 3, "Clip binding table\n");
1702 instr_out(data, hw_offset, 4, "SF binding table\n");
1703 instr_out(data, hw_offset, 5, "WM binding table\n");
1706 BUFFER_FAIL(count, len, "3DSTATE_BINDING_TABLE_POINTERS");
1708 instr_out(data, hw_offset, 0,
1709 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
1710 "GS mod %d, PS mod %d\n",
1711 (data[0] & (1 << 8)) != 0,
1712 (data[0] & (1 << 9)) != 0,
1713 (data[0] & (1 << 10)) != 0);
1714 instr_out(data, hw_offset, 1, "VS binding table\n");
1715 instr_out(data, hw_offset, 2, "GS binding table\n");
1716 instr_out(data, hw_offset, 3, "WM binding table\n");
1721 len = (data[0] & 0xff) + 2;
1723 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
1725 BUFFER_FAIL(count, len, "3DSTATE_SAMPLER_STATE_POINTERS");
1726 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
1727 "GS mod %d, PS mod %d\n",
1728 (data[0] & (1 << 8)) != 0,
1729 (data[0] & (1 << 9)) != 0,
1730 (data[0] & (1 << 12)) != 0);
1731 instr_out(data, hw_offset, 1, "VS sampler state\n");
1732 instr_out(data, hw_offset, 2, "GS sampler state\n");
1733 instr_out(data, hw_offset, 3, "WM sampler state\n");
1736 len = (data[0] & 0xff) + 2;
1738 fprintf(out, "Bad count in 3DSTATE_URB\n");
1740 BUFFER_FAIL(count, len, "3DSTATE_URB");
1741 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
1742 instr_out(data, hw_offset, 1, "VS entries %d, alloc size %d (1024bit row)\n",
1743 data[1] & 0xffff, ((data[1] >> 16) & 0x0fff) - 1);
1744 instr_out(data, hw_offset, 2, "GS entries %d, alloc size %d (1024bit row)\n",
1745 (data[2] >> 8) & 0x3ff, (data[2] & 7) - 1);
1749 len = (data[0] & 0xff) + 2;
1750 if ((len - 1) % 4 != 0)
1751 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
1753 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
1754 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
1756 for (i = 1; i < len;) {
1758 if (IS_GEN6(devid)) {
1765 instr_out(data, hw_offset, i, "buffer %d: %s, pitch %db\n",
1767 data[i] & (1 << access) ? "random" : "sequential",
1770 instr_out(data, hw_offset, i++, "buffer address\n");
1771 instr_out(data, hw_offset, i++, "max index\n");
1772 instr_out(data, hw_offset, i++, "mbz\n");
1777 len = (data[0] & 0xff) + 2;
1778 if ((len + 1) % 2 != 0)
1779 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
1781 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
1782 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
1784 for (i = 1; i < len;) {
1785 instr_out(data, hw_offset, i, "buffer %d: %svalid, type 0x%04x, "
1786 "src offset 0x%04x bytes\n",
1787 data[i] >> (IS_GEN6(devid) ? 26 : 27),
1788 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ? "" : "in",
1789 (data[i] >> 16) & 0x1ff,
1792 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
1793 "dst offset 0x%02x bytes\n",
1794 get_965_element_component(data[i], 0),
1795 get_965_element_component(data[i], 1),
1796 get_965_element_component(data[i], 2),
1797 get_965_element_component(data[i], 3),
1798 (data[i] & 0xff) * 4);
1804 len = (data[0] & 0xff) + 2;
1806 fprintf(out, "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
1808 BUFFER_FAIL(count, len, "3DSTATE_VIEWPORT_STATE_POINTERS");
1809 instr_out(data, hw_offset, 0, "3DSTATE_VIEWPORT_STATE_POINTERS\n");
1810 instr_out(data, hw_offset, 1, "clip\n");
1811 instr_out(data, hw_offset, 2, "sf\n");
1812 instr_out(data, hw_offset, 3, "cc\n");
1816 len = (data[0] & 0xff) + 2;
1818 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
1820 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
1821 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
1822 instr_out(data, hw_offset, 1, "beginning buffer address\n");
1823 instr_out(data, hw_offset, 2, "ending buffer address\n");
1827 len = (data[0] & 0xff) + 2;
1829 fprintf(out, "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
1831 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
1832 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
1833 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
1834 instr_out(data, hw_offset, 2, "depth stencil change %d\n", data[2] & 1);
1835 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
1839 len = (data[0] & 0xff) + 2;
1841 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
1843 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
1844 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
1845 instr_out(data, hw_offset, 1, "scissor rect offset\n");
1849 len = (data[0] & 0xff) + 2;
1851 fprintf(out, "Bad count in 3DSTATE_VS\n");
1853 BUFFER_FAIL(count, len, "3DSTATE_VS");
1854 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
1855 instr_out(data, hw_offset, 1, "kernel pointer\n");
1856 instr_out(data, hw_offset, 2, "SPF=%d, VME=%d, Sampler Count %d, "
1857 "Binding table count %d\n",
1858 (data[2] >> 31) & 1,
1859 (data[2] >> 30) & 1,
1860 (data[2] >> 27) & 7,
1861 (data[2] >> 18) & 0xff);
1862 instr_out(data, hw_offset, 3, "scratch offset\n");
1863 instr_out(data, hw_offset, 4, "Dispatch GRF start %d, VUE read length %d, "
1864 "VUE read offset %d\n",
1865 (data[4] >> 20) & 0x1f,
1866 (data[4] >> 11) & 0x3f,
1867 (data[4] >> 4) & 0x3f);
1868 instr_out(data, hw_offset, 5, "Max Threads %d, Vertex Cache %sable, "
1870 ((data[5] >> 25) & 0x7f) + 1,
1871 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
1872 (data[5] & 1) != 0 ? "en" : "dis");
1876 len = (data[0] & 0xff) + 2;
1878 fprintf(out, "Bad count in 3DSTATE_GS\n");
1880 BUFFER_FAIL(count, len, "3DSTATE_GS");
1881 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
1882 instr_out(data, hw_offset, 1, "kernel pointer\n");
1883 instr_out(data, hw_offset, 2, "SPF=%d, VME=%d, Sampler Count %d, "
1884 "Binding table count %d\n",
1885 (data[2] >> 31) & 1,
1886 (data[2] >> 30) & 1,
1887 (data[2] >> 27) & 7,
1888 (data[2] >> 18) & 0xff);
1889 instr_out(data, hw_offset, 3, "scratch offset\n");
1890 instr_out(data, hw_offset, 4, "Dispatch GRF start %d, VUE read length %d, "
1891 "VUE read offset %d\n",
1893 (data[4] >> 11) & 0x3f,
1894 (data[4] >> 4) & 0x3f);
1895 instr_out(data, hw_offset, 5, "Max Threads %d, Rendering %sable\n",
1896 ((data[5] >> 25) & 0x7f) + 1,
1897 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
1898 instr_out(data, hw_offset, 6, "Reorder %sable, Discard Adjaceny %sable, "
1900 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
1901 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
1902 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
1906 len = (data[0] & 0xff) + 2;
1908 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
1910 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
1911 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
1912 instr_out(data, hw_offset, 1, "UserClip distance cull test mask 0x%x\n",
1914 instr_out(data, hw_offset, 2, "Clip %sable, API mode %s, Viewport XY test %sable, "
1915 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
1916 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
1917 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
1918 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
1919 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
1920 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
1921 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
1922 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
1923 (data[2] >> 13) & 7,
1924 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
1925 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
1929 instr_out(data, hw_offset, 3, "Min PointWidth %d, Max PointWidth %d, "
1930 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
1931 (data[3] >> 17) & 0x7ff,
1932 (data[3] >> 6) & 0x7ff,
1933 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
1938 len = (data[0] & 0xff) + 2;
1940 fprintf(out, "Bad count in 3DSTATE_SF\n");
1942 BUFFER_FAIL(count, len, "3DSTATE_SF");
1943 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
1944 instr_out(data, hw_offset, 1, "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
1945 "VUE read offset %d\n",
1946 (data[1] >> 22) & 0x3f,
1947 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
1948 (data[1] >> 11) & 0x1f,
1949 (data[1] >> 4) & 0x3f);
1950 instr_out(data, hw_offset, 2, "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
1951 "VP transform %sable, FrontWinding_%s\n",
1952 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
1955 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
1956 (data[2] & 1) != 0 ? "CCW" : "CW");
1957 instr_out(data, hw_offset, 3, "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
1958 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
1959 (data[3] >> 29) & 3,
1960 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
1961 (data[3] >> 8) & 3);
1962 instr_out(data, hw_offset, 4, "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
1963 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
1964 (data[4] & (1 << 12)) != 0 ? 4 : 8,
1965 (data[4] & (1 << 11)) != 0);
1966 instr_out(data, hw_offset, 5, "Global Depth Offset Constant %f\n", data[5]);
1967 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n", data[6]);
1968 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n", data[7]);
1970 for (i = 0, j = 0; i < 8; i++, j+=2)
1971 instr_out(data, hw_offset, i+8, "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
1972 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
1974 (data[8+i] & (1 << 31)) != 0 ? "W":"",
1975 (data[8+i] & (1 << 30)) != 0 ? "Z":"",
1976 (data[8+i] & (1 << 29)) != 0 ? "Y":"",
1977 (data[8+i] & (1 << 28)) != 0 ? "X":"",
1978 (data[8+i] >> 25) & 3, (data[8+i] >> 22) & 3,
1979 (data[8+i] >> 16) & 0x1f,
1981 (data[8+i] & (1 << 15)) != 0 ? "W":"",
1982 (data[8+i] & (1 << 14)) != 0 ? "Z":"",
1983 (data[8+i] & (1 << 13)) != 0 ? "Y":"",
1984 (data[8+i] & (1 << 12)) != 0 ? "X":"",
1985 (data[8+i] >> 9) & 3, (data[8+i] >> 6) & 3,
1986 (data[8+i] & 0x1f));
1987 instr_out(data, hw_offset, 16, "Point Sprite TexCoord Enable\n");
1988 instr_out(data, hw_offset, 17, "Const Interp Enable\n");
1989 instr_out(data, hw_offset, 18, "Attrib 7-0 WrapShortest Enable\n");
1990 instr_out(data, hw_offset, 19, "Attrib 15-8 WrapShortest Enable\n");
1995 len = (data[0] & 0xff) + 2;
1997 fprintf(out, "Bad count in 3DSTATE_WM\n");
1999 BUFFER_FAIL(count, len, "3DSTATE_WM");
2000 instr_out(data, hw_offset, 0, "3DSTATE_WM\n");
2001 instr_out(data, hw_offset, 1, "kernel start pointer 0\n");
2002 instr_out(data, hw_offset, 2, "SPF=%d, VME=%d, Sampler Count %d, "
2003 "Binding table count %d\n",
2004 (data[2] >> 31) & 1,
2005 (data[2] >> 30) & 1,
2006 (data[2] >> 27) & 7,
2007 (data[2] >> 18) & 0xff);
2008 instr_out(data, hw_offset, 3, "scratch offset\n");
2009 instr_out(data, hw_offset, 4, "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
2010 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
2011 (data[4] & (1 << 30)) != 0,
2012 (data[4] & (1 << 28)) != 0,
2013 (data[4] & (1 << 27)) != 0,
2014 (data[4] >> 16) & 0x7f,
2015 (data[4] >> 8) & 0x7f,
2017 instr_out(data, hw_offset, 5, "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
2018 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
2019 "Dispatch16 %d, Dispatch8 %d\n",
2020 ((data[5] >> 25) & 0x7f) + 1,
2021 (data[5] & (1 << 22)) != 0,
2022 (data[5] & (1 << 21)) != 0,
2023 (data[5] & (1 << 20)) != 0,
2024 (data[5] & (1 << 19)) != 0,
2025 (data[5] & (1 << 8)) != 0,
2026 (data[5] & (1 << 2)) != 0,
2027 (data[5] & (1 << 1)) != 0,
2028 (data[5] & (1 << 0)) != 0);
2029 instr_out(data, hw_offset, 6, "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
2030 "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
2031 "Multisample Dispatch mode %d\n",
2032 (data[6] >> 20) & 0x3f,
2033 (data[6] >> 18) & 3,
2034 (data[6] >> 16) & 3,
2035 (data[6] >> 10) & 0x3f,
2036 (data[6] & (1 << 9)) != 0,
2039 instr_out(data, hw_offset, 7, "kernel start pointer 1\n");
2040 instr_out(data, hw_offset, 8, "kernel start pointer 2\n");
2046 fprintf(out, "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2048 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2050 instr_out(data, hw_offset, 0,
2051 "3DSTATE_DRAWING_RECTANGLE\n");
2052 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
2054 (data[1] >> 16) & 0xffff);
2055 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
2057 (data[2] >> 16) & 0xffff);
2058 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
2059 (int)data[3] & 0xffff,
2060 ((int)data[3] >> 16) & 0xffff);
2065 if (len < 5 || len > 7)
2066 fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
2068 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
2070 instr_out(data, hw_offset, 0,
2071 "3DSTATE_DEPTH_BUFFER\n");
2072 if (IS_IRONLAKE(devid) || IS_GEN6(devid))
2073 instr_out(data, hw_offset, 1, "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
2074 get_965_surfacetype(data[1] >> 29),
2075 get_965_depthformat((data[1] >> 18) & 0x7),
2076 (data[1] & 0x0001ffff) + 1,
2077 data[1] & (1 << 27) ? "" : "not ",
2078 (data[1] & (1 << 22)) != 0,
2079 (data[1] & (1 << 21)) != 0);
2081 instr_out(data, hw_offset, 1, "%s, %s, pitch = %d bytes, %stiled\n",
2082 get_965_surfacetype(data[1] >> 29),
2083 get_965_depthformat((data[1] >> 18) & 0x7),
2084 (data[1] & 0x0001ffff) + 1,
2085 data[1] & (1 << 27) ? "" : "not ");
2086 instr_out(data, hw_offset, 2, "depth offset\n");
2087 instr_out(data, hw_offset, 3, "%dx%d\n",
2088 ((data[3] & 0x0007ffc0) >> 6) + 1,
2089 ((data[3] & 0xfff80000) >> 19) + 1);
2090 instr_out(data, hw_offset, 4, "volume depth\n");
2092 instr_out(data, hw_offset, 5, "\n");
2095 instr_out(data, hw_offset, 6, "\n");
2097 instr_out(data, hw_offset, 6, "render target view extent\n");
2104 if (IS_GEN6(devid)) {
2106 len = (data[0] & 0xff) + 2;
2107 if (len != 4 && len != 5)
2108 fprintf(out, "Bad count in PIPE_CONTROL\n");
2110 BUFFER_FAIL(count, len, "PIPE_CONTROL");
2112 switch ((data[1] >> 14) & 0x3) {
2113 case 0: desc1 = "no write"; break;
2114 case 1: desc1 = "qword write"; break;
2115 case 2: desc1 = "PS_DEPTH_COUNT write"; break;
2116 case 3: desc1 = "TIMESTAMP write"; break;
2118 instr_out(data, hw_offset, 0, "PIPE_CONTROL\n");
2119 instr_out(data, hw_offset, 1,
2120 "%s, %scs stall, %stlb invalidate, "
2121 "%ssync gfdt, %sdepth stall, %sRC write flush, "
2122 "%sinst flush, %sTC flush\n",
2124 data[1] & (1 << 20) ? "" : "no ",
2125 data[1] & (1 << 18) ? "" : "no ",
2126 data[1] & (1 << 17) ? "" : "no ",
2127 data[1] & (1 << 13) ? "" : "no ",
2128 data[1] & (1 << 12) ? "" : "no ",
2129 data[1] & (1 << 11) ? "" : "no ",
2130 data[1] & (1 << 10) ? "" : "no ");
2132 instr_out(data, hw_offset, 2, "destination address\n");
2133 instr_out(data, hw_offset, 3, "immediate dword low\n");
2134 instr_out(data, hw_offset, 4, "immediate dword high\n");
2136 for (i = 2; i < len; i++) {
2137 instr_out(data, hw_offset, i, "\n");
2142 len = (data[0] & 0xff) + 2;
2144 fprintf(out, "Bad count in PIPE_CONTROL\n");
2146 BUFFER_FAIL(count, len, "PIPE_CONTROL");
2148 switch ((data[0] >> 14) & 0x3) {
2149 case 0: desc1 = "no write"; break;
2150 case 1: desc1 = "qword write"; break;
2151 case 2: desc1 = "PS_DEPTH_COUNT write"; break;
2152 case 3: desc1 = "TIMESTAMP write"; break;
2154 instr_out(data, hw_offset, 0,
2155 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
2158 data[0] & (1 << 13) ? "" : "no ",
2159 data[0] & (1 << 12) ? "" : "no ",
2160 data[0] & (1 << 11) ? "" : "no ");
2161 instr_out(data, hw_offset, 1, "destination address\n");
2162 instr_out(data, hw_offset, 2, "immediate dword low\n");
2163 instr_out(data, hw_offset, 3, "immediate dword high\n");
2167 len = (data[0] & 0xff) + 2;
2169 fprintf(out, "Bad count in 3DPRIMITIVE\n");
2171 BUFFER_FAIL(count, len, "3DPRIMITIVE");
2173 instr_out(data, hw_offset, 0,
2174 "3DPRIMITIVE: %s %s\n",
2175 get_965_prim_type(data[0]),
2176 (data[0] & (1 << 15)) ? "random" : "sequential");
2177 instr_out(data, hw_offset, 1, "vertex count\n");
2178 instr_out(data, hw_offset, 2, "start vertex\n");
2179 instr_out(data, hw_offset, 3, "instance count\n");
2180 instr_out(data, hw_offset, 4, "start instance\n");
2181 instr_out(data, hw_offset, 5, "index bias\n");
2185 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2186 opcode_3d = &opcodes_3d[idx];
2187 if ((data[0] & 0xffff0000) >> 16 == opcode_3d->opcode) {
2191 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2192 if (opcode_3d->max_len > 1) {
2193 len = (data[0] & 0xff) + 2;
2194 if (len < opcode_3d->min_len ||
2195 len > opcode_3d->max_len)
2197 fprintf(out, "Bad count in %s\n", opcode_3d->name);
2201 for (i = 1; i < len; i++) {
2203 BUFFER_FAIL(count, len, opcode_3d->name);
2204 instr_out(data, hw_offset, i, "dword %d\n", i);
2210 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n", opcode);
2216 decode_3d_i830(uint32_t *data, int count, uint32_t hw_offset, uint32_t devid, int *failures)
2227 { 0x02, 1, 1, "3DSTATE_MODES_3" },
2228 { 0x03, 1, 1, "3DSTATE_ENABLES_1"},
2229 { 0x04, 1, 1, "3DSTATE_ENABLES_2"},
2230 { 0x05, 1, 1, "3DSTATE_VFT0"},
2231 { 0x06, 1, 1, "3DSTATE_AA"},
2232 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
2233 { 0x08, 1, 1, "3DSTATE_MODES_1" },
2234 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
2235 { 0x0a, 1, 1, "3DSTATE_VFT1"},
2236 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
2237 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2238 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
2239 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
2240 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
2241 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2242 { 0x16, 1, 1, "3DSTATE_MODES_4" },
2245 opcode = (data[0] & 0x1f000000) >> 24;
2249 return decode_3d_primitive(data, count, hw_offset, failures);
2251 return decode_3d_1d(data, count, hw_offset, devid, failures);
2253 return decode_3d_1c(data, count, hw_offset, failures);
2256 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2257 opcode_3d = &opcodes_3d[idx];
2258 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
2259 unsigned int len = 1, i;
2261 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2262 if (opcode_3d->max_len > 1) {
2263 len = (data[0] & 0xff) + 2;
2264 if (len < opcode_3d->min_len ||
2265 len > opcode_3d->max_len)
2267 fprintf(out, "Bad count in %s\n", opcode_3d->name);
2271 for (i = 1; i < len; i++) {
2273 BUFFER_FAIL(count, len, opcode_3d->name);
2274 instr_out(data, hw_offset, i, "dword %d\n", i);
2280 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n", opcode);
2286 * Decodes an i830-i915 batch buffer, writing the output to stdout.
2288 * \param data batch buffer contents
2289 * \param count number of DWORDs to decode in the batch buffer
2290 * \param hw_offset hardware address for the buffer
2293 intel_decode(uint32_t *data, int count,
2296 uint32_t ignore_end_of_batchbuffer)
2304 while (index < count) {
2305 switch ((data[index] & 0xe0000000) >> 29) {
2307 ret = decode_mi(data + index, count - index,
2308 hw_offset + index * 4, &failures);
2310 /* If MI_BATCHBUFFER_END happened, then dump the rest of the
2311 * output in case we some day want it in debugging, but don't
2312 * decode it since it'll just confuse in the common case.
2315 if (ignore_end_of_batchbuffer) {
2318 for (index = index + 1; index < count; index++) {
2319 instr_out(data, hw_offset, index, "\n");
2326 index += decode_2d(data + index, count - index,
2327 hw_offset + index * 4, &failures);
2330 if (IS_965(devid)) {
2331 index += decode_3d_965(data + index, count - index,
2332 hw_offset + index * 4,
2334 } else if (IS_9XX(devid)) {
2335 index += decode_3d(data + index, count - index,
2336 hw_offset + index * 4,
2339 index += decode_3d_i830(data + index, count - index,
2340 hw_offset + index * 4,
2345 instr_out(data, hw_offset, index, "UNKNOWN\n");
2356 void intel_decode_context_reset(void)
2362 void intel_decode_context_set_head_tail(uint32_t head, uint32_t tail)