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
32 #include "intel_chipset.h"
33 #include "intel_bufmgr.h"
35 /* Struct for tracking drm_intel_decode state. */
36 struct drm_intel_decode {
37 /** stdio file where the output should land. Defaults to stdout. */
44 * Shorthand device identifier: 3 is 915, 4 is 965, 5 is
49 /** GPU address of the start of the current packet. */
51 /** CPU virtual address of the start of the current packet. */
53 /** DWORDs of remaining batchbuffer data starting from the packet. */
56 /** GPU address of the start of the batchbuffer data. */
57 uint32_t base_hw_offset;
58 /** CPU Virtual address of the start of the batchbuffer data. */
60 /** Number of DWORDs of batchbuffer data. */
64 * GPU head and tail pointers, which will be noted in the dump, or ~0.
70 * Whether to dump the dwords after MI_BATCHBUFFER_END.
72 * This sometimes provides clues in corrupted batchbuffers,
73 * and is used by the intel-gpu-tools.
81 static uint32_t saved_s2 = 0, saved_s4 = 0;
82 static char saved_s2_set = 0, saved_s4_set = 0;
83 static uint32_t head_offset = 0xffffffff; /* undefined */
84 static uint32_t tail_offset = 0xffffffff; /* undefined */
87 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
90 #define BUFFER_FAIL(_count, _len, _name) do { \
91 fprintf(out, "Buffer size too small in %s (%d < %d)\n", \
92 (_name), (_count), (_len)); \
96 static float int_as_float(uint32_t intval)
108 instr_out(struct drm_intel_decode *ctx, unsigned int index,
109 const char *fmt, ...) __attribute__((format(__printf__, 3, 4)));
112 instr_out(struct drm_intel_decode *ctx, unsigned int index,
113 const char *fmt, ...)
116 const char *parseinfo;
117 uint32_t offset = ctx->hw_offset + index * 4;
119 if (index > ctx->count) {
120 if (!ctx->overflowed) {
121 fprintf(out, "ERROR: Decode attempted to continue beyond end of batchbuffer\n");
122 ctx->overflowed = true;
127 if (offset == head_offset)
129 else if (offset == tail_offset)
134 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
135 ctx->data[index], index == 0 ? "" : " ");
137 vfprintf(out, fmt, va);
142 decode_mi(struct drm_intel_decode *ctx)
144 unsigned int opcode, len = -1;
145 const char *post_sync_op = "";
146 uint32_t *data = ctx->data;
151 unsigned int min_len;
152 unsigned int max_len;
155 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
156 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
157 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
158 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
159 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
160 { 0x04, 0, 1, 1, "MI_FLUSH" },
161 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
162 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
163 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
164 { 0x00, 0, 1, 1, "MI_NOOP" },
165 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
166 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
167 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
168 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
169 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
170 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
171 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
172 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
173 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
174 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
175 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
178 /* check instruction length */
179 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
181 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
183 if (opcodes_mi[opcode].max_len > 1) {
185 (data[0] & opcodes_mi[opcode].len_mask) + 2;
186 if (len < opcodes_mi[opcode].min_len
187 || len > opcodes_mi[opcode].max_len) {
189 "Bad length (%d) in %s, [%d, %d]\n",
190 len, opcodes_mi[opcode].name,
191 opcodes_mi[opcode].min_len,
192 opcodes_mi[opcode].max_len);
199 switch ((data[0] & 0x1f800000) >> 23) {
201 instr_out(ctx, 0, "MI_BATCH_BUFFER_END\n");
204 instr_out(ctx, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
205 data[0] & (1 << 22) ? " global gtt," : "",
206 data[0] & (1 << 21) ? " update semaphore," : "",
207 data[0] & (1 << 20) ? " compare semaphore," : "",
208 data[0] & (1 << 18) ? " use compare reg" : "",
209 (data[0] & (0x3 << 16)) >> 16);
210 instr_out(ctx, 1, "value\n");
211 instr_out(ctx, 2, "address\n");
214 instr_out(ctx, 0, "MI_STORE_DATA_INDEX%s\n",
215 data[0] & (1 << 21) ? " use per-process HWS," : "");
216 instr_out(ctx, 1, "index\n");
217 instr_out(ctx, 2, "dword\n");
219 instr_out(ctx, 3, "upper dword\n");
222 if (data[0] & (1 << 22))
224 "MI_NOOP write NOPID reg, val=0x%x\n",
225 data[0] & ((1 << 22) - 1));
227 instr_out(ctx, 0, "MI_NOOP\n");
230 switch (data[0] & (0x3 << 14)) {
232 post_sync_op = "no write";
235 post_sync_op = "write data";
238 post_sync_op = "reserved";
241 post_sync_op = "write TIMESTAMP";
245 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
246 data[0] & (1 << 22) ?
247 " enable protected mem (BCS-only)," : "",
248 data[0] & (1 << 21) ? " store in hws," : "",
249 data[0] & (1 << 18) ? " invalidate tlb," : "",
250 data[0] & (1 << 17) ? " flush gfdt," : "",
252 data[0] & (1 << 8) ? " enable notify interrupt," : "",
254 " invalidate video state (BCS-only)," : "");
255 if (data[0] & (1 << 21))
256 instr_out(ctx, 1, "hws index\n");
258 instr_out(ctx, 1, "address\n");
259 instr_out(ctx, 2, "dword\n");
261 instr_out(ctx, 3, "upper dword\n");
265 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
267 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
270 instr_out(ctx, 0, "%s\n",
271 opcodes_mi[opcode].name);
272 for (i = 1; i < len; i++) {
273 instr_out(ctx, i, "dword %d\n", i);
280 instr_out(ctx, 0, "MI UNKNOWN\n");
285 decode_2d_br00(struct drm_intel_decode *ctx, const char *cmd)
288 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
290 (ctx->data[0] & (1 << 20)) ? "en" : "dis",
291 (ctx->data[0] & (1 << 21)) ? "en" : "dis",
292 (ctx->data[0] >> 15) & 1,
293 (ctx->data[0] >> 11) & 1);
297 decode_2d_br01(struct drm_intel_decode *ctx)
300 switch ((ctx->data[1] >> 24) & 0x3) {
316 "format %s, pitch %d, rop 0x%02x, "
317 "clipping %sabled, %s%s \n",
319 (short)(ctx->data[1] & 0xffff),
320 (ctx->data[1] >> 16) & 0xff,
321 ctx->data[1] & (1 << 30) ? "en" : "dis",
322 ctx->data[1] & (1 << 31) ? "solid pattern enabled, " : "",
323 ctx->data[1] & (1 << 31) ?
324 "mono pattern transparency enabled, " : "");
329 decode_2d(struct drm_intel_decode *ctx)
331 unsigned int opcode, len;
332 uint32_t *data = ctx->data;
336 unsigned int min_len;
337 unsigned int max_len;
340 { 0x40, 5, 5, "COLOR_BLT" },
341 { 0x43, 6, 6, "SRC_COPY_BLT" },
342 { 0x01, 8, 8, "XY_SETUP_BLT" },
343 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
344 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
345 { 0x24, 2, 2, "XY_PIXEL_BLT" },
346 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
347 { 0x26, 4, 4, "Y_TEXT_BLT" },
348 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
349 { 0x50, 6, 6, "XY_COLOR_BLT" },
350 { 0x51, 6, 6, "XY_PAT_BLT" },
351 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
352 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
353 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
354 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
355 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
356 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
357 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
358 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
359 { 0x55, 9, 9, "XY_FULL_BLT" },
360 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
361 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
362 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
363 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
364 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
367 switch ((data[0] & 0x1fc00000) >> 22) {
370 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
371 (data[0] >> 12) & 0x8,
372 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
374 len = (data[0] & 0x000000ff) + 2;
376 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
378 instr_out(ctx, 1, "dest (%d,%d)\n",
379 data[1] & 0xffff, data[1] >> 16);
380 instr_out(ctx, 2, "dest (%d,%d)\n",
381 data[2] & 0xffff, data[2] >> 16);
384 decode_2d_br00(ctx, "XY_SETUP_BLT");
386 len = (data[0] & 0x000000ff) + 2;
388 fprintf(out, "Bad count in XY_SETUP_BLT\n");
391 instr_out(ctx, 2, "cliprect (%d,%d)\n",
392 data[2] & 0xffff, data[2] >> 16);
393 instr_out(ctx, 3, "cliprect (%d,%d)\n",
394 data[3] & 0xffff, data[3] >> 16);
395 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
397 instr_out(ctx, 5, "setup background color\n");
398 instr_out(ctx, 6, "setup foreground color\n");
399 instr_out(ctx, 7, "color pattern offset\n");
402 decode_2d_br00(ctx, "XY_SETUP_CLIP_BLT");
404 len = (data[0] & 0x000000ff) + 2;
406 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
408 instr_out(ctx, 1, "cliprect (%d,%d)\n",
409 data[1] & 0xffff, data[2] >> 16);
410 instr_out(ctx, 2, "cliprect (%d,%d)\n",
411 data[2] & 0xffff, data[3] >> 16);
414 decode_2d_br00(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT");
416 len = (data[0] & 0x000000ff) + 2;
419 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
422 instr_out(ctx, 2, "cliprect (%d,%d)\n",
423 data[2] & 0xffff, data[2] >> 16);
424 instr_out(ctx, 3, "cliprect (%d,%d)\n",
425 data[3] & 0xffff, data[3] >> 16);
426 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
428 instr_out(ctx, 5, "setup background color\n");
429 instr_out(ctx, 6, "setup foreground color\n");
430 instr_out(ctx, 7, "mono pattern dw0\n");
431 instr_out(ctx, 8, "mono pattern dw1\n");
434 decode_2d_br00(ctx, "XY_COLOR_BLT");
436 len = (data[0] & 0x000000ff) + 2;
438 fprintf(out, "Bad count in XY_COLOR_BLT\n");
441 instr_out(ctx, 2, "(%d,%d)\n",
442 data[2] & 0xffff, data[2] >> 16);
443 instr_out(ctx, 3, "(%d,%d)\n",
444 data[3] & 0xffff, data[3] >> 16);
445 instr_out(ctx, 4, "offset 0x%08x\n", data[4]);
446 instr_out(ctx, 5, "color\n");
449 decode_2d_br00(ctx, "XY_SRC_COPY_BLT");
451 len = (data[0] & 0x000000ff) + 2;
453 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
456 instr_out(ctx, 2, "dst (%d,%d)\n",
457 data[2] & 0xffff, data[2] >> 16);
458 instr_out(ctx, 3, "dst (%d,%d)\n",
459 data[3] & 0xffff, data[3] >> 16);
460 instr_out(ctx, 4, "dst offset 0x%08x\n", data[4]);
461 instr_out(ctx, 5, "src (%d,%d)\n",
462 data[5] & 0xffff, data[5] >> 16);
463 instr_out(ctx, 6, "src pitch %d\n",
464 (short)(data[6] & 0xffff));
465 instr_out(ctx, 7, "src offset 0x%08x\n", data[7]);
469 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
471 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
475 instr_out(ctx, 0, "%s\n",
476 opcodes_2d[opcode].name);
477 if (opcodes_2d[opcode].max_len > 1) {
478 len = (data[0] & 0x000000ff) + 2;
479 if (len < opcodes_2d[opcode].min_len ||
480 len > opcodes_2d[opcode].max_len) {
481 fprintf(out, "Bad count in %s\n",
482 opcodes_2d[opcode].name);
486 for (i = 1; i < len; i++) {
487 instr_out(ctx, i, "dword %d\n", i);
494 instr_out(ctx, 0, "2D UNKNOWN\n");
499 decode_3d_1c(struct drm_intel_decode *ctx)
501 uint32_t *data = ctx->data;
504 opcode = (data[0] & 0x00f80000) >> 19;
509 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
512 instr_out(ctx, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
513 data[0] & 1 ? "enabled" : "disabled");
516 instr_out(ctx, 0, "3DSTATE_MAP_COORD_SET_I830\n");
519 instr_out(ctx, 0, "3DSTATE_MAP_CUBE_I830\n");
522 instr_out(ctx, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
526 instr_out(ctx, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
531 /** Sets the string dstname to describe the destination of the PS instruction */
533 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
535 uint32_t a0 = data[i];
536 int dst_nr = (a0 >> 14) & 0xf;
541 if (((a0 >> 10) & 0xf) == 0xf) {
544 int dstmask_index = 0;
546 dstmask[dstmask_index++] = '.';
548 dstmask[dstmask_index++] = 'x';
550 dstmask[dstmask_index++] = 'y';
552 dstmask[dstmask_index++] = 'z';
554 dstmask[dstmask_index++] = 'w';
555 dstmask[dstmask_index++] = 0;
567 switch ((a0 >> 19) & 0x7) {
570 fprintf(out, "bad destination reg R%d\n", dst_nr);
571 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
575 fprintf(out, "bad destination reg oC%d\n", dst_nr);
576 sprintf(dstname, "oC%s%s", dstmask, sat);
580 fprintf(out, "bad destination reg oD%d\n", dst_nr);
581 sprintf(dstname, "oD%s%s", dstmask, sat);
585 fprintf(out, "bad destination reg U%d\n", dst_nr);
586 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
589 sprintf(dstname, "RESERVED");
595 i915_get_channel_swizzle(uint32_t select)
597 switch (select & 0x7) {
599 return (select & 8) ? "-x" : "x";
601 return (select & 8) ? "-y" : "y";
603 return (select & 8) ? "-z" : "z";
605 return (select & 8) ? "-w" : "w";
607 return (select & 8) ? "-0" : "0";
609 return (select & 8) ? "-1" : "1";
611 return (select & 8) ? "-bad" : "bad";
616 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
620 sprintf(name, "R%d", src_nr);
622 fprintf(out, "bad src reg %s\n", name);
626 sprintf(name, "T%d", src_nr);
627 else if (src_nr == 8)
628 sprintf(name, "DIFFUSE");
629 else if (src_nr == 9)
630 sprintf(name, "SPECULAR");
631 else if (src_nr == 10)
632 sprintf(name, "FOG");
634 fprintf(out, "bad src reg T%d\n", src_nr);
635 sprintf(name, "RESERVED");
639 sprintf(name, "C%d", src_nr);
641 fprintf(out, "bad src reg %s\n", name);
646 fprintf(out, "bad src reg oC%d\n", src_nr);
651 fprintf(out, "bad src reg oD%d\n", src_nr);
654 sprintf(name, "U%d", src_nr);
656 fprintf(out, "bad src reg %s\n", name);
659 fprintf(out, "bad src reg type %d\n", src_type);
660 sprintf(name, "RESERVED");
665 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
667 uint32_t a0 = data[i];
668 uint32_t a1 = data[i + 1];
669 int src_nr = (a0 >> 2) & 0x1f;
670 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
671 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
672 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
673 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
676 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
677 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
679 if (strcmp(swizzle, ".xyzw") != 0)
680 strcat(srcname, swizzle);
683 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
685 uint32_t a1 = data[i + 1];
686 uint32_t a2 = data[i + 2];
687 int src_nr = (a1 >> 8) & 0x1f;
688 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
689 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
690 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
691 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
694 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
695 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
697 if (strcmp(swizzle, ".xyzw") != 0)
698 strcat(srcname, swizzle);
701 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
703 uint32_t a2 = data[i + 2];
704 int src_nr = (a2 >> 16) & 0x1f;
705 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
706 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
707 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
708 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
711 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
712 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
714 if (strcmp(swizzle, ".xyzw") != 0)
715 strcat(srcname, swizzle);
719 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
723 sprintf(name, "R%d", src_nr);
725 fprintf(out, "bad src reg %s\n", name);
729 sprintf(name, "T%d", src_nr);
730 else if (src_nr == 8)
731 sprintf(name, "DIFFUSE");
732 else if (src_nr == 9)
733 sprintf(name, "SPECULAR");
734 else if (src_nr == 10)
735 sprintf(name, "FOG");
737 fprintf(out, "bad src reg T%d\n", src_nr);
738 sprintf(name, "RESERVED");
744 fprintf(out, "bad src reg oC%d\n", src_nr);
749 fprintf(out, "bad src reg oD%d\n", src_nr);
752 fprintf(out, "bad src reg type %d\n", src_type);
753 sprintf(name, "RESERVED");
759 i915_decode_alu1(struct drm_intel_decode *ctx,
760 int i, char *instr_prefix, const char *op_name)
762 char dst[100], src0[100];
764 i915_get_instruction_dst(ctx->data, i, dst, 1);
765 i915_get_instruction_src0(ctx->data, i, src0);
767 instr_out(ctx, i++, "%s: %s %s, %s\n", instr_prefix,
769 instr_out(ctx, i++, "%s\n", instr_prefix);
770 instr_out(ctx, i++, "%s\n", instr_prefix);
774 i915_decode_alu2(struct drm_intel_decode *ctx,
775 int i, char *instr_prefix, const char *op_name)
777 char dst[100], src0[100], src1[100];
779 i915_get_instruction_dst(ctx->data, i, dst, 1);
780 i915_get_instruction_src0(ctx->data, i, src0);
781 i915_get_instruction_src1(ctx->data, i, src1);
783 instr_out(ctx, i++, "%s: %s %s, %s, %s\n", instr_prefix,
784 op_name, dst, src0, src1);
785 instr_out(ctx, i++, "%s\n", instr_prefix);
786 instr_out(ctx, i++, "%s\n", instr_prefix);
790 i915_decode_alu3(struct drm_intel_decode *ctx,
791 int i, char *instr_prefix, const char *op_name)
793 char dst[100], src0[100], src1[100], src2[100];
795 i915_get_instruction_dst(ctx->data, i, dst, 1);
796 i915_get_instruction_src0(ctx->data, i, src0);
797 i915_get_instruction_src1(ctx->data, i, src1);
798 i915_get_instruction_src2(ctx->data, i, src2);
800 instr_out(ctx, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
801 op_name, dst, src0, src1, src2);
802 instr_out(ctx, i++, "%s\n", instr_prefix);
803 instr_out(ctx, i++, "%s\n", instr_prefix);
807 i915_decode_tex(struct drm_intel_decode *ctx, int i,
808 const char *instr_prefix, const char *tex_name)
810 uint32_t t0 = ctx->data[i];
811 uint32_t t1 = ctx->data[i + 1];
816 i915_get_instruction_dst(ctx->data, i, dst_name, 0);
817 i915_get_instruction_addr((t1 >> 24) & 0x7,
818 (t1 >> 17) & 0xf, addr_name);
819 sampler_nr = t0 & 0xf;
821 instr_out(ctx, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
822 tex_name, dst_name, sampler_nr, addr_name);
823 instr_out(ctx, i++, "%s\n", instr_prefix);
824 instr_out(ctx, i++, "%s\n", instr_prefix);
828 i915_decode_dcl(struct drm_intel_decode *ctx, int i, char *instr_prefix)
830 uint32_t d0 = ctx->data[i];
831 const char *sampletype;
832 int dcl_nr = (d0 >> 14) & 0xf;
833 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
834 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
835 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
836 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
839 switch ((d0 >> 19) & 0x3) {
841 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
842 if (strcmp(dcl_mask, ".") == 0)
843 fprintf(out, "bad (empty) dcl mask\n");
846 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
848 if (strcmp(dcl_mask, ".x") != 0 &&
849 strcmp(dcl_mask, ".xy") != 0 &&
850 strcmp(dcl_mask, ".xz") != 0 &&
851 strcmp(dcl_mask, ".w") != 0 &&
852 strcmp(dcl_mask, ".xyzw") != 0) {
853 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
856 instr_out(ctx, i++, "%s: DCL T%d%s\n",
857 instr_prefix, dcl_nr, dcl_mask);
859 if (strcmp(dcl_mask, ".xz") == 0)
860 fprintf(out, "errataed bad dcl mask %s\n",
862 else if (strcmp(dcl_mask, ".xw") == 0)
863 fprintf(out, "errataed bad dcl mask %s\n",
865 else if (strcmp(dcl_mask, ".xzw") == 0)
866 fprintf(out, "errataed bad dcl mask %s\n",
871 "%s: DCL DIFFUSE%s\n", instr_prefix,
873 } else if (dcl_nr == 9) {
875 "%s: DCL SPECULAR%s\n", instr_prefix,
877 } else if (dcl_nr == 10) {
879 "%s: DCL FOG%s\n", instr_prefix,
883 instr_out(ctx, i++, "%s\n", instr_prefix);
884 instr_out(ctx, i++, "%s\n", instr_prefix);
887 switch ((d0 >> 22) & 0x3) {
898 sampletype = "RESERVED";
902 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
903 instr_out(ctx, i++, "%s: DCL S%d %s\n",
904 instr_prefix, dcl_nr, sampletype);
905 instr_out(ctx, i++, "%s\n", instr_prefix);
906 instr_out(ctx, i++, "%s\n", instr_prefix);
909 instr_out(ctx, i++, "%s: DCL RESERVED%d\n",
910 instr_prefix, dcl_nr);
911 instr_out(ctx, i++, "%s\n", instr_prefix);
912 instr_out(ctx, i++, "%s\n", instr_prefix);
917 i915_decode_instruction(struct drm_intel_decode *ctx,
918 int i, char *instr_prefix)
920 switch ((ctx->data[i] >> 24) & 0x1f) {
922 instr_out(ctx, i++, "%s: NOP\n", instr_prefix);
923 instr_out(ctx, i++, "%s\n", instr_prefix);
924 instr_out(ctx, i++, "%s\n", instr_prefix);
927 i915_decode_alu2(ctx, i, instr_prefix, "ADD");
930 i915_decode_alu1(ctx, i, instr_prefix, "MOV");
933 i915_decode_alu2(ctx, i, instr_prefix, "MUL");
936 i915_decode_alu3(ctx, i, instr_prefix, "MAD");
939 i915_decode_alu3(ctx, i, instr_prefix, "DP2ADD");
942 i915_decode_alu2(ctx, i, instr_prefix, "DP3");
945 i915_decode_alu2(ctx, i, instr_prefix, "DP4");
948 i915_decode_alu1(ctx, i, instr_prefix, "FRC");
951 i915_decode_alu1(ctx, i, instr_prefix, "RCP");
954 i915_decode_alu1(ctx, i, instr_prefix, "RSQ");
957 i915_decode_alu1(ctx, i, instr_prefix, "EXP");
960 i915_decode_alu1(ctx, i, instr_prefix, "LOG");
963 i915_decode_alu2(ctx, i, instr_prefix, "CMP");
966 i915_decode_alu2(ctx, i, instr_prefix, "MIN");
969 i915_decode_alu2(ctx, i, instr_prefix, "MAX");
972 i915_decode_alu1(ctx, i, instr_prefix, "FLR");
975 i915_decode_alu1(ctx, i, instr_prefix, "MOD");
978 i915_decode_alu1(ctx, i, instr_prefix, "TRC");
981 i915_decode_alu2(ctx, i, instr_prefix, "SGE");
984 i915_decode_alu2(ctx, i, instr_prefix, "SLT");
987 i915_decode_tex(ctx, i, instr_prefix, "TEXLD");
990 i915_decode_tex(ctx, i, instr_prefix, "TEXLDP");
993 i915_decode_tex(ctx, i, instr_prefix, "TEXLDB");
996 i915_decode_dcl(ctx, i, instr_prefix);
999 instr_out(ctx, i++, "%s: unknown\n", instr_prefix);
1000 instr_out(ctx, i++, "%s\n", instr_prefix);
1001 instr_out(ctx, i++, "%s\n", instr_prefix);
1007 decode_compare_func(uint32_t op)
1031 decode_stencil_op(uint32_t op)
1056 decode_logic_op(uint32_t op)
1097 decode_blend_fact(uint32_t op)
1107 return "inv_src_colr";
1111 return "inv_src_alpha";
1115 return "inv_dst_alpha";
1119 return "inv_dst_colr";
1121 return "src_alpha_sat";
1125 return "inv_cnst_colr";
1127 return "cnst_alpha";
1129 return "inv_const_alpha";
1135 decode_tex_coord_mode(uint32_t mode)
1137 switch (mode & 0x7) {
1143 return "clamp_edge";
1147 return "clamp_border";
1149 return "mirror_once";
1155 decode_sample_filter(uint32_t mode)
1157 switch (mode & 0x7) {
1163 return "anisotropic";
1177 decode_3d_1d(struct drm_intel_decode *ctx)
1179 unsigned int len, i, c, idx, word, map, sampler, instr;
1180 const char *format, *zformat, *type;
1182 uint32_t *data = ctx->data;
1183 uint32_t devid = ctx->devid;
1188 unsigned int min_len;
1189 unsigned int max_len;
1191 } opcodes_3d_1d[] = {
1192 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1193 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1194 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1195 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1196 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1197 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1198 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1199 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1200 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1201 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1202 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1203 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1204 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1205 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1206 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1207 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1210 opcode = (data[0] & 0x00ff0000) >> 16;
1214 /* This instruction is unusual. A 0 length means just
1215 * 1 DWORD instead of 2. The 0 length is specified in
1216 * one place to be unsupported, but stated to be
1217 * required in another, and 0 length LOAD_INDIRECTs
1218 * appear to cause no harm at least.
1220 instr_out(ctx, 0, "3DSTATE_LOAD_INDIRECT\n");
1221 len = (data[0] & 0x000000ff) + 1;
1223 if (data[0] & (0x01 << 8)) {
1224 instr_out(ctx, i++, "SIS.0\n");
1225 instr_out(ctx, i++, "SIS.1\n");
1227 if (data[0] & (0x02 << 8)) {
1228 instr_out(ctx, i++, "DIS.0\n");
1230 if (data[0] & (0x04 << 8)) {
1231 instr_out(ctx, i++, "SSB.0\n");
1232 instr_out(ctx, i++, "SSB.1\n");
1234 if (data[0] & (0x08 << 8)) {
1235 instr_out(ctx, i++, "MSB.0\n");
1236 instr_out(ctx, i++, "MSB.1\n");
1238 if (data[0] & (0x10 << 8)) {
1239 instr_out(ctx, i++, "PSP.0\n");
1240 instr_out(ctx, i++, "PSP.1\n");
1242 if (data[0] & (0x20 << 8)) {
1243 instr_out(ctx, i++, "PSC.0\n");
1244 instr_out(ctx, i++, "PSC.1\n");
1247 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1253 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1254 len = (data[0] & 0x0000000f) + 2;
1256 for (word = 0; word <= 8; word++) {
1257 if (data[0] & (1 << (4 + word))) {
1258 /* save vertex state for decode */
1259 if (!IS_GEN2(devid)) {
1274 "S0: vbo offset: 0x%08x%s\n",
1277 ", auto cache invalidate disabled"
1282 "S1: vertex width: %i, vertex pitch: %i\n",
1290 "S2: texcoord formats: ");
1292 tex_num < 8; tex_num++) {
1338 "S3: not documented\n");
1342 const char *cullmode = "";
1343 const char *vfmt_xyzw = "";
1344 switch ((data[i] >> 13)
1381 case 1 << 6 | 1 << 2:
1385 case 2 << 6 | 1 << 2:
1389 case 3 << 6 | 1 << 2:
1393 case 4 << 6 | 1 << 2:
1399 "S4: point_width=%i, line_width=%.1f,"
1400 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1463 "force default diffuse, "
1469 "force default specular, "
1475 "local depth ofs enable, "
1481 "point sprite enable, "
1495 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1496 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1497 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1527 " force default point size,"
1533 " last pixel enable,"
1539 " global depth ofs enable,"
1565 "stencil write enable, "
1571 "stencil test enable, "
1577 "color dither enable, "
1589 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1590 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1591 "%s%stristrip_provoking_vertex=%i\n",
1592 data[i] & (1 << 31) ?
1593 "alpha test enable, "
1601 data[i] & (1 << 15) ?
1602 "cbuf blend enable, "
1604 decode_blend_fact(data
1608 decode_blend_fact(data
1612 data[i] & (1 << 3) ?
1613 "depth write enable, "
1615 data[i] & (1 << 2) ?
1616 "cbuf write enable, "
1622 "S7: depth offset constant: 0x%08x\n",
1628 "S%d: 0x%08x\n", i, data[i]);
1635 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1640 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1641 len = (data[0] & 0x0000000f) + 2;
1643 for (word = 6; word <= 14; word++) {
1644 if (data[0] & (1 << word)) {
1648 else if (word >= 7 && word <= 10) {
1650 "TB%dC\n", word - 7);
1652 "TB%dA\n", word - 7);
1653 } else if (word >= 11 && word <= 14) {
1655 "TM%dS0: offset=0x%08x, %s\n",
1657 data[i] & 0xfffffffe,
1658 data[i] & 1 ? "use fence" :
1662 "TM%dS1: height=%i, width=%i, %s\n",
1663 word - 11, data[i] >> 21,
1664 (data[i] >> 10) & 0x3ff,
1665 data[i] & 2 ? (data[i] & 1 ?
1671 "TM%dS2: pitch=%i, \n",
1673 ((data[i] >> 21) + 1) * 4);
1676 "TM%dS3\n", word - 11);
1678 "TM%dS4: dflt color\n",
1685 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1689 instr_out(ctx, 0, "3DSTATE_MAP_STATE\n");
1690 len = (data[0] & 0x0000003f) + 2;
1691 instr_out(ctx, 1, "mask\n");
1694 for (map = 0; map <= 15; map++) {
1695 if (data[1] & (1 << map)) {
1696 int width, height, pitch, dword;
1701 "map %d MS2 %s%s%s\n", map,
1703 "untrusted surface, " : "",
1705 "vertical line stride enable, " : "",
1707 "vertical ofs enable, " : "");
1710 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1711 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1714 if (dword & (1 << 2))
1716 else if (dword & (1 << 1))
1717 tiling = dword & (1 << 0) ? "Y" : "X";
1720 switch ((dword >> 7) & 0x7) {
1723 switch ((dword >> 3) & 0xf) {
1740 switch ((dword >> 3) & 0xf) {
1745 format = " argb1555";
1748 format = " argb4444";
1754 format = " bump655";
1769 switch ((dword >> 3) & 0xf) {
1771 format = " argb8888";
1774 format = " abgr8888";
1777 format = " xrgb8888";
1780 format = " xbgr8888";
1783 format = " qwvu8888";
1786 format = " axvu8888";
1789 format = " lxvu8888";
1792 format = " xlvu8888";
1795 format = " argb2101010";
1798 format = " abgr2101010";
1801 format = " awvu2101010";
1822 switch ((dword >> 3) & 0xf) {
1824 format = " yuv_swapy";
1830 format = " yuv_swapuv";
1833 format = " yuv_swapuvy";
1838 type = "compressed";
1839 switch ((dword >> 3) & 0x7) {
1853 format = " dxt1_rb";
1858 type = "4b indexed";
1859 switch ((dword >> 3) & 0xf) {
1861 format = " argb8888";
1868 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1869 map, width, height, type, format,
1871 dword & (1 << 9) ? " palette select" :
1876 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1878 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1879 map, pitch, (dword >> 9) & 0x3f,
1880 dword & 0xff, (dword >> 15) & 0x3f,
1881 dword & (1 << 8) ? "miplayout legacy"
1882 : "miplayout right");
1886 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1892 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1893 len = (data[0] & 0x000000ff) + 2;
1896 for (c = 0; c <= 31; c++) {
1897 if (data[1] & (1 << c)) {
1898 instr_out(ctx, i, "C%d.X = %f\n", c,
1899 int_as_float(data[i]));
1901 instr_out(ctx, i, "C%d.Y = %f\n",
1902 c, int_as_float(data[i]));
1904 instr_out(ctx, i, "C%d.Z = %f\n",
1905 c, int_as_float(data[i]));
1907 instr_out(ctx, i, "C%d.W = %f\n",
1908 c, int_as_float(data[i]));
1914 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1918 instr_out(ctx, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1919 len = (data[0] & 0x000000ff) + 2;
1920 if ((len - 1) % 3 != 0 || len > 370) {
1922 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1925 for (instr = 0; instr < (len - 1) / 3; instr++) {
1926 char instr_prefix[10];
1928 sprintf(instr_prefix, "PS%03d", instr);
1929 i915_decode_instruction(ctx, i,
1937 instr_out(ctx, 0, "3DSTATE_SAMPLER_STATE\n");
1938 instr_out(ctx, 1, "mask\n");
1939 len = (data[0] & 0x0000003f) + 2;
1941 for (sampler = 0; sampler <= 15; sampler++) {
1942 if (data[1] & (1 << sampler)) {
1944 const char *mip_filter = "";
1947 switch ((dword >> 20) & 0x3) {
1949 mip_filter = "none";
1952 mip_filter = "nearest";
1955 mip_filter = "linear";
1959 "sampler %d SS2:%s%s%s "
1960 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
1961 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
1963 dword & (1 << 31) ? " reverse gamma,"
1965 dword & (1 << 30) ? " packed2planar,"
1968 " colorspace conversion," : "",
1969 (dword >> 22) & 0x1f, mip_filter,
1970 decode_sample_filter(dword >> 17),
1971 decode_sample_filter(dword >> 14),
1972 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
1973 dword & (1 << 4) ? " shadow," : "",
1974 dword & (1 << 3) ? 4 : 2,
1975 decode_compare_func(dword));
1978 "sampler %d SS3: min_lod=%.2f,%s "
1979 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
1981 ((dword >> 24) & 0xff) / (0x10 * 1.0),
1983 " kill pixel enable," : "",
1984 decode_tex_coord_mode(dword >> 12),
1985 decode_tex_coord_mode(dword >> 9),
1986 decode_tex_coord_mode(dword >> 6),
1988 " normalized coords," : "",
1990 dword & (1 << 0) ? " deinterlacer," :
1994 "sampler %d SS4: border color\n",
1999 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2003 len = (data[0] & 0x0000000f) + 2;
2007 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2010 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2012 switch ((data[1] >> 8) & 0xf) {
2017 format = "x1r5g5b5";
2023 format = "a8r8g8b8";
2026 format = "ycrcb_swapy";
2029 format = "ycrcb_normal";
2032 format = "ycrcb_swapuv";
2035 format = "ycrcb_swapuvy";
2038 format = "a4r4g4b4";
2041 format = "a1r5g5b5";
2044 format = "a2r10g10b10";
2050 switch ((data[1] >> 2) & 0x3) {
2065 "%s format, %s depth format, early Z %sabled\n",
2067 (data[1] & (1 << 31)) ? "en" : "dis");
2072 const char *name, *tiling;
2074 len = (data[0] & 0x0000000f) + 2;
2077 "Bad count in 3DSTATE_BUFFER_INFO\n");
2079 switch ((data[1] >> 24) & 0x7) {
2092 if (data[1] & (1 << 23))
2094 else if (data[1] & (1 << 22))
2095 tiling = data[1] & (1 << 21) ? "Y" : "X";
2097 instr_out(ctx, 0, "3DSTATE_BUFFER_INFO\n");
2099 "%s, tiling = %s, pitch=%d\n", name, tiling,
2102 instr_out(ctx, 2, "address\n");
2106 len = (data[0] & 0x0000000f) + 2;
2110 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2112 instr_out(ctx, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2113 instr_out(ctx, 1, "(%d,%d)\n",
2114 data[1] & 0xffff, data[1] >> 16);
2115 instr_out(ctx, 2, "(%d,%d)\n",
2116 data[2] & 0xffff, data[2] >> 16);
2120 len = (data[0] & 0x0000000f) + 2;
2124 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2126 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2127 instr_out(ctx, 1, "%s\n",
2128 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2129 instr_out(ctx, 2, "(%d,%d)\n",
2130 data[2] & 0xffff, data[2] >> 16);
2131 instr_out(ctx, 3, "(%d,%d)\n",
2132 data[3] & 0xffff, data[3] >> 16);
2133 instr_out(ctx, 4, "(%d,%d)\n",
2134 data[4] & 0xffff, data[4] >> 16);
2138 len = (data[0] & 0x0000000f) + 2;
2141 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2143 instr_out(ctx, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2144 instr_out(ctx, 1, "prim_type=%s, clear=%s%s%s\n",
2145 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2146 data[1] & (1 << 2) ? "color," : "",
2147 data[1] & (1 << 1) ? "depth," : "",
2148 data[1] & (1 << 0) ? "stencil," : "");
2149 instr_out(ctx, 2, "clear color\n");
2150 instr_out(ctx, 3, "clear depth/stencil\n");
2151 instr_out(ctx, 4, "color value (rgba8888)\n");
2152 instr_out(ctx, 5, "depth value %f\n",
2153 int_as_float(data[5]));
2154 instr_out(ctx, 6, "clear stencil\n");
2158 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2159 opcode_3d_1d = &opcodes_3d_1d[idx];
2160 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2163 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2166 instr_out(ctx, 0, "%s\n",
2167 opcode_3d_1d->name);
2168 if (opcode_3d_1d->max_len > 1) {
2169 len = (data[0] & 0x0000ffff) + 2;
2170 if (len < opcode_3d_1d->min_len ||
2171 len > opcode_3d_1d->max_len) {
2172 fprintf(out, "Bad count in %s\n",
2173 opcode_3d_1d->name);
2177 for (i = 1; i < len; i++) {
2178 instr_out(ctx, i, "dword %d\n", i);
2185 instr_out(ctx, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2191 decode_3d_primitive(struct drm_intel_decode *ctx)
2193 uint32_t *data = ctx->data;
2194 uint32_t count = ctx->count;
2195 char immediate = (data[0] & (1 << 23)) == 0;
2196 unsigned int len, i, j, ret;
2197 const char *primtype;
2198 int original_s2 = saved_s2;
2199 int original_s4 = saved_s4;
2201 switch ((data[0] >> 18) & 0xf) {
2203 primtype = "TRILIST";
2206 primtype = "TRISTRIP";
2209 primtype = "TRISTRIP_REVERSE";
2212 primtype = "TRIFAN";
2215 primtype = "POLYGON";
2218 primtype = "LINELIST";
2221 primtype = "LINESTRIP";
2224 primtype = "RECTLIST";
2227 primtype = "POINTLIST";
2233 primtype = "CLEAR_RECT";
2238 primtype = "unknown";
2242 /* XXX: 3DPRIM_DIB not supported */
2244 len = (data[0] & 0x0003ffff) + 2;
2245 instr_out(ctx, 0, "3DPRIMITIVE inline %s\n",
2248 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2249 if (!saved_s2_set || !saved_s4_set) {
2250 fprintf(out, "unknown vertex format\n");
2251 for (i = 1; i < len; i++) {
2253 " vertex data (%f float)\n",
2254 int_as_float(data[i]));
2257 unsigned int vertex = 0;
2258 for (i = 1; i < len;) {
2261 #define VERTEX_OUT(fmt, ...) do { \
2263 instr_out(ctx, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2265 fprintf(out, " missing data in V%d\n", vertex); \
2269 VERTEX_OUT("X = %f", int_as_float(data[i]));
2270 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2271 switch (saved_s4 >> 6 & 0x7) {
2273 VERTEX_OUT("Z = %f",
2274 int_as_float(data[i]));
2277 VERTEX_OUT("Z = %f",
2278 int_as_float(data[i]));
2279 VERTEX_OUT("W = %f",
2280 int_as_float(data[i]));
2285 VERTEX_OUT("W = %f",
2286 int_as_float(data[i]));
2289 fprintf(out, "bad S4 position mask\n");
2292 if (saved_s4 & (1 << 10)) {
2294 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2295 "B=0x%02x)", data[i] >> 24,
2296 (data[i] >> 16) & 0xff,
2297 (data[i] >> 8) & 0xff,
2300 if (saved_s4 & (1 << 11)) {
2302 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2303 "B=0x%02x)", data[i] >> 24,
2304 (data[i] >> 16) & 0xff,
2305 (data[i] >> 8) & 0xff,
2308 if (saved_s4 & (1 << 12))
2309 VERTEX_OUT("width = 0x%08x)", data[i]);
2311 for (tc = 0; tc <= 7; tc++) {
2312 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2314 VERTEX_OUT("T%d.X = %f", tc,
2317 VERTEX_OUT("T%d.Y = %f", tc,
2322 VERTEX_OUT("T%d.X = %f", tc,
2325 VERTEX_OUT("T%d.Y = %f", tc,
2328 VERTEX_OUT("T%d.Z = %f", tc,
2333 VERTEX_OUT("T%d.X = %f", tc,
2336 VERTEX_OUT("T%d.Y = %f", tc,
2339 VERTEX_OUT("T%d.Z = %f", tc,
2342 VERTEX_OUT("T%d.W = %f", tc,
2347 VERTEX_OUT("T%d.X = %f", tc,
2353 ("T%d.XY = 0x%08x half-float",
2358 ("T%d.XY = 0x%08x half-float",
2361 ("T%d.ZW = 0x%08x half-float",
2368 "bad S2.T%d format\n",
2378 /* indirect vertices */
2379 len = data[0] & 0x0000ffff; /* index count */
2380 if (data[0] & (1 << 17)) {
2381 /* random vertex access */
2382 if (count < (len + 1) / 2 + 1) {
2383 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2384 "3DPRIMITIVE random indirect");
2387 "3DPRIMITIVE random indirect %s (%d)\n",
2390 /* vertex indices continue until 0xffff is
2393 for (i = 1; i < count; i++) {
2394 if ((data[i] & 0xffff) == 0xffff) {
2396 " indices: (terminator)\n");
2399 } else if ((data[i] >> 16) == 0xffff) {
2401 " indices: 0x%04x, (terminator)\n",
2407 " indices: 0x%04x, 0x%04x\n",
2413 "3DPRIMITIVE: no terminator found in index buffer\n");
2417 /* fixed size vertex index buffer */
2418 for (j = 1, i = 0; i < len; i += 2, j++) {
2419 if (i * 2 == len - 1) {
2421 " indices: 0x%04x\n",
2425 " indices: 0x%04x, 0x%04x\n",
2431 ret = (len + 1) / 2 + 1;
2434 /* sequential vertex access */
2436 "3DPRIMITIVE sequential indirect %s, %d starting from "
2437 "%d\n", primtype, len, data[1] & 0xffff);
2438 instr_out(ctx, 1, " start\n");
2445 saved_s2 = original_s2;
2446 saved_s4 = original_s4;
2451 decode_3d(struct drm_intel_decode *ctx)
2455 uint32_t *data = ctx->data;
2459 unsigned int min_len;
2460 unsigned int max_len;
2463 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2464 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2465 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2466 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2467 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2468 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2469 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2470 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2471 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2474 opcode = (data[0] & 0x1f000000) >> 24;
2478 return decode_3d_primitive(ctx);
2480 return decode_3d_1d(ctx);
2482 return decode_3d_1c(ctx);
2485 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2486 opcode_3d = &opcodes_3d[idx];
2487 if (opcode == opcode_3d->opcode) {
2488 unsigned int len = 1, i;
2490 instr_out(ctx, 0, "%s\n", opcode_3d->name);
2491 if (opcode_3d->max_len > 1) {
2492 len = (data[0] & 0xff) + 2;
2493 if (len < opcode_3d->min_len ||
2494 len > opcode_3d->max_len) {
2495 fprintf(out, "Bad count in %s\n",
2500 for (i = 1; i < len; i++) {
2501 instr_out(ctx, i, "dword %d\n", i);
2507 instr_out(ctx, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2511 static const char *get_965_surfacetype(unsigned int surfacetype)
2513 switch (surfacetype) {
2531 static const char *get_965_depthformat(unsigned int depthformat)
2533 switch (depthformat) {
2535 return "s8_z24float";
2547 static const char *get_965_element_component(uint32_t data, int component)
2549 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2551 switch (component_control) {
2555 switch (component) {
2580 static const char *get_965_prim_type(uint32_t primtype)
2584 return "point list";
2588 return "line strip";
2598 return "quad strip";
2600 return "line list adj";
2602 return "line strip adj";
2604 return "tri list adj";
2606 return "tri strip adj";
2608 return "tri strip reverse";
2616 return "point list bf";
2618 return "line strip cont";
2620 return "line strip bf";
2622 return "line strip cont bf";
2624 return "tri fan no stipple";
2631 i965_decode_urb_fence(struct drm_intel_decode *ctx, int len)
2633 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2634 uint32_t *data = ctx->data;
2637 fprintf(out, "Bad count in URB_FENCE\n");
2639 vs_fence = data[1] & 0x3ff;
2640 gs_fence = (data[1] >> 10) & 0x3ff;
2641 clip_fence = (data[1] >> 20) & 0x3ff;
2642 sf_fence = data[2] & 0x3ff;
2643 vfe_fence = (data[2] >> 10) & 0x3ff;
2644 cs_fence = (data[2] >> 20) & 0x7ff;
2646 instr_out(ctx, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2647 (data[0] >> 13) & 1 ? "cs " : "",
2648 (data[0] >> 12) & 1 ? "vfe " : "",
2649 (data[0] >> 11) & 1 ? "sf " : "",
2650 (data[0] >> 10) & 1 ? "clip " : "",
2651 (data[0] >> 9) & 1 ? "gs " : "",
2652 (data[0] >> 8) & 1 ? "vs " : "");
2654 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2655 vs_fence, clip_fence, gs_fence);
2657 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2658 sf_fence, vfe_fence, cs_fence);
2659 if (gs_fence < vs_fence)
2660 fprintf(out, "gs fence < vs fence!\n");
2661 if (clip_fence < gs_fence)
2662 fprintf(out, "clip fence < gs fence!\n");
2663 if (sf_fence < clip_fence)
2664 fprintf(out, "sf fence < clip fence!\n");
2665 if (cs_fence < sf_fence)
2666 fprintf(out, "cs fence < sf fence!\n");
2672 state_base_out(struct drm_intel_decode *ctx, unsigned int index,
2675 if (ctx->data[index] & 1) {
2676 instr_out(ctx, index,
2677 "%s state base address 0x%08x\n", name,
2678 ctx->data[index] & ~1);
2680 instr_out(ctx, index, "%s state base not updated\n",
2686 state_max_out(struct drm_intel_decode *ctx, unsigned int index,
2689 if (ctx->data[index] & 1) {
2690 if (ctx->data[index] == 1) {
2691 instr_out(ctx, index,
2692 "%s state upper bound disabled\n", name);
2694 instr_out(ctx, index,
2695 "%s state upper bound 0x%08x\n", name,
2696 ctx->data[index] & ~1);
2699 instr_out(ctx, index,
2700 "%s state upper bound not updated\n", name);
2705 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct drm_intel_decode *ctx)
2707 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_CC\n");
2708 instr_out(ctx, 1, "pointer to CC viewport\n");
2714 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct drm_intel_decode *ctx)
2716 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP\n");
2717 instr_out(ctx, 1, "pointer to SF_CLIP viewport\n");
2723 gen7_3DSTATE_BLEND_STATE_POINTERS(struct drm_intel_decode *ctx)
2725 instr_out(ctx, 0, "3DSTATE_BLEND_STATE_POINTERS\n");
2726 instr_out(ctx, 1, "pointer to BLEND_STATE at 0x%08x (%s)\n",
2728 (ctx->data[1] & 1) ? "changed" : "unchanged");
2734 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct drm_intel_decode *ctx)
2736 instr_out(ctx, 0, "3DSTATE_DEPTH_STENCIL_STATE_POINTERS\n");
2738 "pointer to DEPTH_STENCIL_STATE at 0x%08x (%s)\n",
2740 (ctx->data[1] & 1) ? "changed" : "unchanged");
2746 gen7_3DSTATE_HIER_DEPTH_BUFFER(struct drm_intel_decode *ctx)
2748 instr_out(ctx, 0, "3DSTATE_HIER_DEPTH_BUFFER\n");
2749 instr_out(ctx, 1, "pitch %db\n",
2750 (ctx->data[1] & 0x1ffff) + 1);
2751 instr_out(ctx, 2, "pointer to HiZ buffer\n");
2757 gen6_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2759 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2760 instr_out(ctx, 1, "blend change %d\n", ctx->data[1] & 1);
2761 instr_out(ctx, 2, "depth stencil change %d\n",
2763 instr_out(ctx, 3, "cc change %d\n", ctx->data[3] & 1);
2769 gen7_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2771 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2772 instr_out(ctx, 1, "pointer to COLOR_CALC_STATE at 0x%08x "
2775 (ctx->data[1] & 1) ? "changed" : "unchanged");
2781 gen7_3DSTATE_URB_unit(struct drm_intel_decode *ctx, const char *unit)
2783 int start_kb = ((ctx->data[1] >> 25) & 0x3f) * 8;
2784 /* the field is # of 512-bit rows - 1, we print bytes */
2785 int entry_size = (((ctx->data[1] >> 16) & 0x1ff) + 1);
2786 int nr_entries = ctx->data[1] & 0xffff;
2788 instr_out(ctx, 0, "3DSTATE_URB_%s\n", unit);
2790 "%dKB start, size=%d 64B rows, nr_entries=%d, total size %dB\n",
2791 start_kb, entry_size, nr_entries, nr_entries * 64 * entry_size);
2797 gen7_3DSTATE_URB_VS(struct drm_intel_decode *ctx)
2799 return gen7_3DSTATE_URB_unit(ctx, "VS");
2803 gen7_3DSTATE_URB_HS(struct drm_intel_decode *ctx)
2805 return gen7_3DSTATE_URB_unit(ctx, "HS");
2809 gen7_3DSTATE_URB_DS(struct drm_intel_decode *ctx)
2811 return gen7_3DSTATE_URB_unit(ctx, "DS");
2815 gen7_3DSTATE_URB_GS(struct drm_intel_decode *ctx)
2817 return gen7_3DSTATE_URB_unit(ctx, "GS");
2821 gen7_3DSTATE_CONSTANT(struct drm_intel_decode *ctx, const char *unit)
2825 rlen[0] = (ctx->data[1] >> 0) & 0xffff;
2826 rlen[1] = (ctx->data[1] >> 16) & 0xffff;
2827 rlen[2] = (ctx->data[2] >> 0) & 0xffff;
2828 rlen[3] = (ctx->data[2] >> 16) & 0xffff;
2830 instr_out(ctx, 0, "3DSTATE_CONSTANT_%s\n", unit);
2831 instr_out(ctx, 1, "len 0 = %d, len 1 = %d\n", rlen[0], rlen[1]);
2832 instr_out(ctx, 2, "len 2 = %d, len 3 = %d\n", rlen[2], rlen[3]);
2833 instr_out(ctx, 3, "pointer to constbuf 0\n");
2834 instr_out(ctx, 4, "pointer to constbuf 1\n");
2835 instr_out(ctx, 5, "pointer to constbuf 2\n");
2836 instr_out(ctx, 6, "pointer to constbuf 3\n");
2842 gen7_3DSTATE_CONSTANT_VS(struct drm_intel_decode *ctx)
2844 return gen7_3DSTATE_CONSTANT(ctx, "VS");
2848 gen7_3DSTATE_CONSTANT_GS(struct drm_intel_decode *ctx)
2850 return gen7_3DSTATE_CONSTANT(ctx, "GS");
2854 gen7_3DSTATE_CONSTANT_PS(struct drm_intel_decode *ctx)
2856 return gen7_3DSTATE_CONSTANT(ctx, "PS");
2860 gen7_3DSTATE_CONSTANT_DS(struct drm_intel_decode *ctx)
2862 return gen7_3DSTATE_CONSTANT(ctx, "DS");
2866 gen7_3DSTATE_CONSTANT_HS(struct drm_intel_decode *ctx)
2868 return gen7_3DSTATE_CONSTANT(ctx, "HS");
2873 gen6_3DSTATE_WM(struct drm_intel_decode *ctx)
2875 instr_out(ctx, 0, "3DSTATE_WM\n");
2876 instr_out(ctx, 1, "kernel start pointer 0\n");
2878 "SPF=%d, VME=%d, Sampler Count %d, "
2879 "Binding table count %d\n",
2880 (ctx->data[2] >> 31) & 1,
2881 (ctx->data[2] >> 30) & 1,
2882 (ctx->data[2] >> 27) & 7,
2883 (ctx->data[2] >> 18) & 0xff);
2884 instr_out(ctx, 3, "scratch offset\n");
2886 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
2887 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
2888 (ctx->data[4] & (1 << 30)) != 0,
2889 (ctx->data[4] & (1 << 28)) != 0,
2890 (ctx->data[4] & (1 << 27)) != 0,
2891 (ctx->data[4] >> 16) & 0x7f,
2892 (ctx->data[4] >> 8) & 0x7f,
2893 (ctx->data[4] & 0x7f));
2895 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
2896 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, "
2897 "Dispatch32 %d, Dispatch16 %d, Dispatch8 %d\n",
2898 ((ctx->data[5] >> 25) & 0x7f) + 1,
2899 (ctx->data[5] & (1 << 22)) != 0,
2900 (ctx->data[5] & (1 << 21)) != 0,
2901 (ctx->data[5] & (1 << 20)) != 0,
2902 (ctx->data[5] & (1 << 19)) != 0,
2903 (ctx->data[5] & (1 << 8)) != 0,
2904 (ctx->data[5] & (1 << 2)) != 0,
2905 (ctx->data[5] & (1 << 1)) != 0,
2906 (ctx->data[5] & (1 << 0)) != 0);
2908 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
2909 "Barycentric interp mode 0x%x, Point raster rule %d, "
2910 "Multisample mode %d, "
2911 "Multisample Dispatch mode %d\n",
2912 (ctx->data[6] >> 20) & 0x3f,
2913 (ctx->data[6] >> 18) & 3,
2914 (ctx->data[6] >> 16) & 3,
2915 (ctx->data[6] >> 10) & 0x3f,
2916 (ctx->data[6] & (1 << 9)) != 0,
2917 (ctx->data[6] >> 1) & 3,
2918 (ctx->data[6] & 1));
2919 instr_out(ctx, 7, "kernel start pointer 1\n");
2920 instr_out(ctx, 8, "kernel start pointer 2\n");
2926 gen7_3DSTATE_WM(struct drm_intel_decode *ctx)
2928 const char *computed_depth = "";
2929 const char *early_depth = "";
2930 const char *zw_interp = "";
2932 switch ((ctx->data[1] >> 23) & 0x3) {
2934 computed_depth = "";
2937 computed_depth = "computed depth";
2940 computed_depth = "computed depth >=";
2943 computed_depth = "computed depth <=";
2947 switch ((ctx->data[1] >> 21) & 0x3) {
2952 early_depth = ", EDSC_PSEXEC";
2955 early_depth = ", EDSC_PREPS";
2958 early_depth = ", BAD EDSC";
2962 switch ((ctx->data[1] >> 17) & 0x3) {
2967 early_depth = ", BAD ZW interp";
2970 early_depth = ", ZW centroid";
2973 early_depth = ", ZW sample";
2977 instr_out(ctx, 0, "3DSTATE_WM\n");
2978 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",
2979 (ctx->data[1] & (1 << 11)) ? "PP " : "",
2980 (ctx->data[1] & (1 << 12)) ? "PC " : "",
2981 (ctx->data[1] & (1 << 13)) ? "PS " : "",
2982 (ctx->data[1] & (1 << 14)) ? "NPP " : "",
2983 (ctx->data[1] & (1 << 15)) ? "NPC " : "",
2984 (ctx->data[1] & (1 << 16)) ? "NPS " : "",
2985 (ctx->data[1] & (1 << 30)) ? ", depth clear" : "",
2986 (ctx->data[1] & (1 << 29)) ? "" : ", disabled",
2987 (ctx->data[1] & (1 << 28)) ? ", depth resolve" : "",
2988 (ctx->data[1] & (1 << 27)) ? ", hiz resolve" : "",
2989 (ctx->data[1] & (1 << 25)) ? ", kill" : "",
2993 (ctx->data[1] & (1 << 20)) ? ", source depth" : "",
2994 (ctx->data[1] & (1 << 19)) ? ", source W" : "",
2995 (ctx->data[1] & (1 << 10)) ? ", coverage" : "",
2996 (ctx->data[1] & (1 << 4)) ? ", poly stipple" : "",
2997 (ctx->data[1] & (1 << 3)) ? ", line stipple" : "",
2998 (ctx->data[1] & (1 << 2)) ? ", point UL" : ", point UR"
3000 instr_out(ctx, 2, "MS\n");
3006 gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
3009 "3DPRIMITIVE: %s %s\n",
3010 get_965_prim_type((ctx->data[0] >> 10) & 0x1f),
3011 (ctx->data[0] & (1 << 15)) ? "random" : "sequential");
3012 instr_out(ctx, 1, "vertex count\n");
3013 instr_out(ctx, 2, "start vertex\n");
3014 instr_out(ctx, 3, "instance count\n");
3015 instr_out(ctx, 4, "start instance\n");
3016 instr_out(ctx, 5, "index bias\n");
3022 gen7_3DPRIMITIVE(struct drm_intel_decode *ctx)
3024 bool indirect = !!(ctx->data[0] & (1 << 10));
3027 "3DPRIMITIVE: %s%s\n",
3028 indirect ? " indirect" : "",
3029 (ctx->data[0] & (1 << 8)) ? " predicated" : "");
3030 instr_out(ctx, 1, "%s %s\n",
3031 get_965_prim_type(ctx->data[1] & 0x3f),
3032 (ctx->data[1] & (1 << 8)) ? "random" : "sequential");
3033 instr_out(ctx, 2, indirect ? "ignored" : "vertex count\n");
3034 instr_out(ctx, 3, indirect ? "ignored" : "start vertex\n");
3035 instr_out(ctx, 4, indirect ? "ignored" : "instance count\n");
3036 instr_out(ctx, 5, indirect ? "ignored" : "start instance\n");
3037 instr_out(ctx, 6, indirect ? "ignored" : "index bias\n");
3043 decode_3d_965(struct drm_intel_decode *ctx)
3047 unsigned int i, j, sba_len;
3048 const char *desc1 = NULL;
3049 uint32_t *data = ctx->data;
3050 uint32_t devid = ctx->devid;
3055 int unsigned min_len;
3056 int unsigned max_len;
3059 int (*func)(struct drm_intel_decode *ctx);
3061 { 0x6000, 0x00ff, 3, 3, "URB_FENCE" },
3062 { 0x6001, 0xffff, 2, 2, "CS_URB_STATE" },
3063 { 0x6002, 0x00ff, 2, 2, "CONSTANT_BUFFER" },
3064 { 0x6101, 0xffff, 6, 10, "STATE_BASE_ADDRESS" },
3065 { 0x6102, 0xffff, 2, 2, "STATE_SIP" },
3066 { 0x6104, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3067 { 0x680b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3068 { 0x6904, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3069 { 0x7800, 0xffff, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
3070 { 0x7801, 0x00ff, 4, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
3071 { 0x7802, 0x00ff, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
3072 { 0x7805, 0x00ff, 7, 7, "3DSTATE_DEPTH_BUFFER", 7 },
3073 { 0x7805, 0x00ff, 3, 3, "3DSTATE_URB" },
3074 { 0x7804, 0x00ff, 3, 3, "3DSTATE_CLEAR_PARAMS" },
3075 { 0x7806, 0x00ff, 3, 3, "3DSTATE_STENCIL_BUFFER" },
3076 { 0x7807, 0x00ff, 4, 4, "3DSTATE_HIER_DEPTH_BUFFER", 6 },
3077 { 0x7807, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 7, gen7_3DSTATE_HIER_DEPTH_BUFFER },
3078 { 0x7808, 0x00ff, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
3079 { 0x7809, 0x00ff, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
3080 { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" },
3081 { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3082 { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
3083 { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS },
3084 { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS },
3085 { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" },
3086 { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" },
3087 { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" },
3088 { 0x7812, 0x00ff, 4, 4, "3DSTATE_CLIP" },
3089 { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF", 6 },
3090 { 0x7813, 0x00ff, 7, 7, "3DSTATE_SF", 7 },
3091 { 0x7814, 0x00ff, 3, 3, "3DSTATE_WM", 7, gen7_3DSTATE_WM },
3092 { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM", 6, gen6_3DSTATE_WM },
3093 { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE", 6 },
3094 { 0x7815, 0x00ff, 7, 7, "3DSTATE_CONSTANT_VS", 7, gen7_3DSTATE_CONSTANT_VS },
3095 { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE", 6 },
3096 { 0x7816, 0x00ff, 7, 7, "3DSTATE_CONSTANT_GS", 7, gen7_3DSTATE_CONSTANT_GS },
3097 { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE", 6 },
3098 { 0x7817, 0x00ff, 7, 7, "3DSTATE_CONSTANT_PS", 7, gen7_3DSTATE_CONSTANT_PS },
3099 { 0x7818, 0xffff, 2, 2, "3DSTATE_SAMPLE_MASK" },
3100 { 0x7819, 0x00ff, 7, 7, "3DSTATE_CONSTANT_HS", 7, gen7_3DSTATE_CONSTANT_HS },
3101 { 0x781a, 0x00ff, 7, 7, "3DSTATE_CONSTANT_DS", 7, gen7_3DSTATE_CONSTANT_DS },
3102 { 0x781b, 0x00ff, 7, 7, "3DSTATE_HS" },
3103 { 0x781c, 0x00ff, 4, 4, "3DSTATE_TE" },
3104 { 0x781d, 0x00ff, 6, 6, "3DSTATE_DS" },
3105 { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" },
3106 { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" },
3107 { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" },
3108 { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP },
3109 { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC },
3110 { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS },
3111 { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS },
3112 { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" },
3113 { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" },
3114 { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" },
3115 { 0x7829, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_GS" },
3116 { 0x782a, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_PS" },
3117 { 0x782b, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_VS" },
3118 { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" },
3119 { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" },
3120 { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS },
3121 { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS },
3122 { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS },
3123 { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS },
3124 { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
3125 { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" },
3126 { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" },
3127 { 0x7906, 0xffff, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
3128 { 0x7907, 0xffff, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
3129 { 0x7908, 0xffff, 3, 3, "3DSTATE_LINE_STIPPLE" },
3130 { 0x7909, 0xffff, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
3131 { 0x7909, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3132 { 0x790a, 0xffff, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
3133 { 0x790b, 0xffff, 4, 4, "3DSTATE_GS_SVB_INDEX" },
3134 { 0x790d, 0xffff, 3, 3, "3DSTATE_MULTISAMPLE", 6 },
3135 { 0x790d, 0xffff, 4, 4, "3DSTATE_MULTISAMPLE", 7 },
3136 { 0x7910, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3137 { 0x7912, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_VS" },
3138 { 0x7916, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_PS" },
3139 { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" },
3140 { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" },
3141 { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" },
3142 { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE },
3143 { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
3144 }, *opcode_3d = NULL;
3146 opcode = (data[0] & 0xffff0000) >> 16;
3148 for (i = 0; i < ARRAY_SIZE(opcodes_3d); i++) {
3149 if (opcode != opcodes_3d[i].opcode)
3152 /* If it's marked as not our gen, skip. */
3153 if (opcodes_3d[i].gen && opcodes_3d[i].gen != ctx->gen)
3156 opcode_3d = &opcodes_3d[i];
3161 if (opcode_3d->max_len == 1)
3164 len = (data[0] & opcode_3d->len_mask) + 2;
3166 if (len < opcode_3d->min_len ||
3167 len > opcode_3d->max_len) {
3168 fprintf(out, "Bad length %d in %s, expected %d-%d\n",
3169 len, opcode_3d->name,
3170 opcode_3d->min_len, opcode_3d->max_len);
3173 len = (data[0] & 0x0000ffff) + 2;
3178 return i965_decode_urb_fence(ctx, len);
3180 instr_out(ctx, 0, "CS_URB_STATE\n");
3182 "entry_size: %d [%d bytes], n_entries: %d\n",
3183 (data[1] >> 4) & 0x1f,
3184 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
3187 instr_out(ctx, 0, "CONSTANT_BUFFER: %s\n",
3188 (data[0] >> 8) & 1 ? "valid" : "invalid");
3190 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
3191 ((data[1] & 0x3f) + 1) * 64);
3195 instr_out(ctx, 0, "STATE_BASE_ADDRESS\n");
3198 if (IS_GEN6(devid) || IS_GEN7(devid))
3200 else if (IS_GEN5(devid))
3205 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
3207 state_base_out(ctx, i++, "general");
3208 state_base_out(ctx, i++, "surface");
3209 if (IS_GEN6(devid) || IS_GEN7(devid))
3210 state_base_out(ctx, i++, "dynamic");
3211 state_base_out(ctx, i++, "indirect");
3212 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3213 state_base_out(ctx, i++, "instruction");
3215 state_max_out(ctx, i++, "general");
3216 if (IS_GEN6(devid) || IS_GEN7(devid))
3217 state_max_out(ctx, i++, "dynamic");
3218 state_max_out(ctx, i++, "indirect");
3219 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3220 state_max_out(ctx, i++, "instruction");
3224 instr_out(ctx, 0, "3DSTATE_PIPELINED_POINTERS\n");
3225 instr_out(ctx, 1, "VS state\n");
3226 instr_out(ctx, 2, "GS state\n");
3227 instr_out(ctx, 3, "Clip state\n");
3228 instr_out(ctx, 4, "SF state\n");
3229 instr_out(ctx, 5, "WM state\n");
3230 instr_out(ctx, 6, "CC state\n");
3233 if (len != 6 && len != 4)
3235 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
3238 "3DSTATE_BINDING_TABLE_POINTERS\n");
3239 instr_out(ctx, 1, "VS binding table\n");
3240 instr_out(ctx, 2, "GS binding table\n");
3241 instr_out(ctx, 3, "Clip binding table\n");
3242 instr_out(ctx, 4, "SF binding table\n");
3243 instr_out(ctx, 5, "WM binding table\n");
3246 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
3247 "GS mod %d, PS mod %d\n",
3248 (data[0] & (1 << 8)) != 0,
3249 (data[0] & (1 << 9)) != 0,
3250 (data[0] & (1 << 12)) != 0);
3251 instr_out(ctx, 1, "VS binding table\n");
3252 instr_out(ctx, 2, "GS binding table\n");
3253 instr_out(ctx, 3, "WM binding table\n");
3259 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
3260 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
3261 (data[0] & (1 << 9)) != 0,
3262 (data[0] & (1 << 12)) != 0);
3263 instr_out(ctx, 1, "VS sampler state\n");
3264 instr_out(ctx, 2, "GS sampler state\n");
3265 instr_out(ctx, 3, "WM sampler state\n");
3268 /* Actually 3DSTATE_DEPTH_BUFFER on gen7. */
3272 instr_out(ctx, 0, "3DSTATE_URB\n");
3274 "VS entries %d, alloc size %d (1024bit row)\n",
3275 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
3277 "GS entries %d, alloc size %d (1024bit row)\n",
3278 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
3282 if ((len - 1) % 4 != 0)
3283 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
3284 instr_out(ctx, 0, "3DSTATE_VERTEX_BUFFERS\n");
3286 for (i = 1; i < len;) {
3288 if (IS_GEN6(devid)) {
3296 "buffer %d: %s, pitch %db\n", data[i] >> idx,
3297 data[i] & (1 << access) ? "random" :
3298 "sequential", data[i] & 0x07ff);
3300 instr_out(ctx, i++, "buffer address\n");
3301 instr_out(ctx, i++, "max index\n");
3302 instr_out(ctx, i++, "mbz\n");
3307 if ((len + 1) % 2 != 0)
3308 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3309 instr_out(ctx, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3311 for (i = 1; i < len;) {
3313 "buffer %d: %svalid, type 0x%04x, "
3314 "src offset 0x%04x bytes\n",
3315 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3316 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3317 "" : "in", (data[i] >> 16) & 0x1ff,
3320 instr_out(ctx, i, "(%s, %s, %s, %s), "
3321 "dst offset 0x%02x bytes\n",
3322 get_965_element_component(data[i], 0),
3323 get_965_element_component(data[i], 1),
3324 get_965_element_component(data[i], 2),
3325 get_965_element_component(data[i], 3),
3326 (data[i] & 0xff) * 4);
3333 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3334 instr_out(ctx, 1, "clip\n");
3335 instr_out(ctx, 2, "sf\n");
3336 instr_out(ctx, 3, "cc\n");
3340 instr_out(ctx, 0, "3DSTATE_INDEX_BUFFER\n");
3341 instr_out(ctx, 1, "beginning buffer address\n");
3342 instr_out(ctx, 2, "ending buffer address\n");
3346 instr_out(ctx, 0, "3DSTATE_SCISSOR_POINTERS\n");
3347 instr_out(ctx, 1, "scissor rect offset\n");
3351 instr_out(ctx, 0, "3DSTATE_VS\n");
3352 instr_out(ctx, 1, "kernel pointer\n");
3354 "SPF=%d, VME=%d, Sampler Count %d, "
3355 "Binding table count %d\n", (data[2] >> 31) & 1,
3356 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3357 (data[2] >> 18) & 0xff);
3358 instr_out(ctx, 3, "scratch offset\n");
3360 "Dispatch GRF start %d, VUE read length %d, "
3361 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3362 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3364 "Max Threads %d, Vertex Cache %sable, "
3365 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3366 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3367 (data[5] & 1) != 0 ? "en" : "dis");
3371 instr_out(ctx, 0, "3DSTATE_GS\n");
3372 instr_out(ctx, 1, "kernel pointer\n");
3374 "SPF=%d, VME=%d, Sampler Count %d, "
3375 "Binding table count %d\n", (data[2] >> 31) & 1,
3376 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3377 (data[2] >> 18) & 0xff);
3378 instr_out(ctx, 3, "scratch offset\n");
3380 "Dispatch GRF start %d, VUE read length %d, "
3381 "VUE read offset %d\n", (data[4] & 0xf),
3382 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3384 "Max Threads %d, Rendering %sable\n",
3385 ((data[5] >> 25) & 0x7f) + 1,
3386 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3388 "Reorder %sable, Discard Adjaceny %sable, "
3390 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3391 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3392 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3396 instr_out(ctx, 0, "3DSTATE_CLIP\n");
3398 "UserClip distance cull test mask 0x%x\n",
3401 "Clip %sable, API mode %s, Viewport XY test %sable, "
3402 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3403 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3404 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3405 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3406 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3407 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3408 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3409 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3410 (data[2] >> 13) & 7,
3411 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3412 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3413 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3416 "Min PointWidth %d, Max PointWidth %d, "
3417 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3418 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3419 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3427 instr_out(ctx, 0, "3DSTATE_SF\n");
3429 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3430 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3431 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3432 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3434 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3435 "VP transform %sable, FrontWinding_%s\n",
3436 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3437 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3438 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3439 (data[2] & 1) != 0 ? "CCW" : "CW");
3441 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3442 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3443 (data[3] >> 29) & 3,
3444 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3445 (data[3] >> 8) & 3);
3447 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3448 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3449 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3450 (data[4] & (1 << 11)) != 0);
3452 "Global Depth Offset Constant %f\n",
3453 *(float *)(&data[5]));
3454 instr_out(ctx, 6, "Global Depth Offset Scale %f\n",
3455 *(float *)(&data[6]));
3456 instr_out(ctx, 7, "Global Depth Offset Clamp %f\n",
3457 *(float *)(&data[7]));
3459 for (i = 0, j = 0; i < 8; i++, j += 2)
3460 instr_out(ctx, i + 8,
3461 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3462 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3464 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3465 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3466 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3467 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3468 (data[8 + i] >> 25) & 3,
3469 (data[8 + i] >> 22) & 3,
3470 (data[8 + i] >> 16) & 0x1f, j,
3471 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3472 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3473 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3474 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3475 (data[8 + i] >> 9) & 3,
3476 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3478 "Point Sprite TexCoord Enable\n");
3479 instr_out(ctx, 17, "Const Interp Enable\n");
3481 "Attrib 7-0 WrapShortest Enable\n");
3483 "Attrib 15-8 WrapShortest Enable\n");
3488 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3489 instr_out(ctx, 1, "top left: %d,%d\n",
3490 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3491 instr_out(ctx, 2, "bottom right: %d,%d\n",
3492 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3493 instr_out(ctx, 3, "origin: %d,%d\n",
3494 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3499 instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n");
3500 if (IS_GEN5(devid) || IS_GEN6(devid))
3502 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3503 get_965_surfacetype(data[1] >> 29),
3504 get_965_depthformat((data[1] >> 18) & 0x7),
3505 (data[1] & 0x0001ffff) + 1,
3506 data[1] & (1 << 27) ? "" : "not ",
3507 (data[1] & (1 << 22)) != 0,
3508 (data[1] & (1 << 21)) != 0);
3511 "%s, %s, pitch = %d bytes, %stiled\n",
3512 get_965_surfacetype(data[1] >> 29),
3513 get_965_depthformat((data[1] >> 18) & 0x7),
3514 (data[1] & 0x0001ffff) + 1,
3515 data[1] & (1 << 27) ? "" : "not ");
3516 instr_out(ctx, 2, "depth offset\n");
3517 instr_out(ctx, 3, "%dx%d\n",
3518 ((data[3] & 0x0007ffc0) >> 6) + 1,
3519 ((data[3] & 0xfff80000) >> 19) + 1);
3520 instr_out(ctx, 4, "volume depth\n");
3522 instr_out(ctx, 5, "\n");
3525 instr_out(ctx, 6, "\n");
3528 "render target view extent\n");
3534 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3536 if (len != 4 && len != 5)
3537 fprintf(out, "Bad count in PIPE_CONTROL\n");
3539 switch ((data[1] >> 14) & 0x3) {
3544 desc1 = "qword write";
3547 desc1 = "PS_DEPTH_COUNT write";
3550 desc1 = "TIMESTAMP write";
3553 instr_out(ctx, 0, "PIPE_CONTROL\n");
3555 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3557 data[1] & (1 << 20) ? "cs stall, " : "",
3558 data[1] & (1 << 19) ?
3559 "global snapshot count reset, " : "",
3560 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3561 data[1] & (1 << 17) ? "gfdt flush, " : "",
3562 data[1] & (1 << 17) ? "media state clear, " :
3564 data[1] & (1 << 13) ? "depth stall, " : "",
3565 data[1] & (1 << 12) ?
3566 "render target cache flush, " : "",
3567 data[1] & (1 << 11) ?
3568 "instruction cache invalidate, " : "",
3569 data[1] & (1 << 10) ?
3570 "texture cache invalidate, " : "",
3571 data[1] & (1 << 9) ?
3572 "indirect state invalidate, " : "",
3573 data[1] & (1 << 8) ? "notify irq, " : "",
3574 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3576 data[1] & (1 << 6) ? "protect mem app_id, " :
3577 "", data[1] & (1 << 5) ? "DC flush, " : "",
3578 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3580 data[1] & (1 << 3) ?
3581 "constant cache invalidate, " : "",
3582 data[1] & (1 << 2) ?
3583 "state cache invalidate, " : "",
3584 data[1] & (1 << 1) ? "stall at scoreboard, " :
3586 data[1] & (1 << 0) ? "depth cache flush, " :
3590 "destination address\n");
3592 "immediate dword low\n");
3594 "immediate dword high\n");
3596 for (i = 2; i < len; i++) {
3597 instr_out(ctx, i, "\n");
3603 fprintf(out, "Bad count in PIPE_CONTROL\n");
3605 switch ((data[0] >> 14) & 0x3) {
3610 desc1 = "qword write";
3613 desc1 = "PS_DEPTH_COUNT write";
3616 desc1 = "TIMESTAMP write";
3620 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3623 data[0] & (1 << 13) ? "" : "no ",
3624 data[0] & (1 << 12) ? "" : "no ",
3625 data[0] & (1 << 11) ? "" : "no ");
3626 instr_out(ctx, 1, "destination address\n");
3627 instr_out(ctx, 2, "immediate dword low\n");
3628 instr_out(ctx, 3, "immediate dword high\n");
3634 if (opcode_3d->func) {
3635 return opcode_3d->func(ctx);
3639 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3641 for (i = 1; i < len; i++) {
3642 instr_out(ctx, i, "dword %d\n", i);
3648 instr_out(ctx, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3654 decode_3d_i830(struct drm_intel_decode *ctx)
3658 uint32_t *data = ctx->data;
3662 unsigned int min_len;
3663 unsigned int max_len;
3666 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3667 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3668 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3669 { 0x05, 1, 1, "3DSTATE_VFT0" },
3670 { 0x06, 1, 1, "3DSTATE_AA" },
3671 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3672 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3673 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3674 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3675 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3676 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3677 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3678 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3679 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3680 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3681 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3684 opcode = (data[0] & 0x1f000000) >> 24;
3688 return decode_3d_primitive(ctx);
3690 return decode_3d_1d(ctx);
3692 return decode_3d_1c(ctx);
3695 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3696 opcode_3d = &opcodes_3d[idx];
3697 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3698 unsigned int len = 1, i;
3700 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3701 if (opcode_3d->max_len > 1) {
3702 len = (data[0] & 0xff) + 2;
3703 if (len < opcode_3d->min_len ||
3704 len > opcode_3d->max_len) {
3705 fprintf(out, "Bad count in %s\n",
3710 for (i = 1; i < len; i++) {
3711 instr_out(ctx, i, "dword %d\n", i);
3717 instr_out(ctx, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3722 struct drm_intel_decode *
3723 drm_intel_decode_context_alloc(uint32_t devid)
3725 struct drm_intel_decode *ctx;
3727 ctx = calloc(1, sizeof(struct drm_intel_decode));
3736 else if (IS_GEN6(devid))
3738 else if (IS_GEN5(devid))
3740 else if (IS_GEN4(devid))
3742 else if (IS_9XX(devid))
3745 assert(IS_GEN2(devid));
3753 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3759 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3762 ctx->dump_past_end = !!dump_past_end;
3766 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3767 void *data, uint32_t hw_offset, int count)
3769 ctx->base_data = data;
3770 ctx->base_hw_offset = hw_offset;
3771 ctx->base_count = count;
3775 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3776 uint32_t head, uint32_t tail)
3783 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3790 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3792 * \param data batch buffer contents
3793 * \param count number of DWORDs to decode in the batch buffer
3794 * \param hw_offset hardware address for the buffer
3797 drm_intel_decode(struct drm_intel_decode *ctx)
3800 unsigned int index = 0;
3802 int size = ctx->base_count * 4;
3808 /* Put a scratch page full of obviously undefined data after
3809 * the batchbuffer. This lets us avoid a bunch of length
3810 * checking in statically sized packets.
3812 temp = malloc(size + 4096);
3813 memcpy(temp, ctx->base_data, size);
3814 memset((char *)temp + size, 0xd0, 4096);
3817 ctx->hw_offset = ctx->base_hw_offset;
3818 ctx->count = ctx->base_count;
3821 head_offset = ctx->head;
3822 tail_offset = ctx->tail;
3828 while (ctx->count > 0) {
3831 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3833 ret = decode_mi(ctx);
3835 /* If MI_BATCHBUFFER_END happened, then dump
3836 * the rest of the output in case we some day
3837 * want it in debugging, but don't decode it
3838 * since it'll just confuse in the common
3842 if (ctx->dump_past_end) {
3845 for (index = index + 1; index < ctx->count;
3847 instr_out(ctx, index, "\n");
3854 index += decode_2d(ctx);
3857 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3860 } else if (IS_GEN3(devid)) {
3861 index += decode_3d(ctx);
3864 decode_3d_i830(ctx);
3868 instr_out(ctx, index, "UNKNOWN\n");
3874 if (ctx->count < index)
3877 ctx->count -= index;
3879 ctx->hw_offset += 4 * index;