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_WAIT_FOR_EVENT(struct drm_intel_decode *ctx)
146 uint32_t data = ctx->data[0];
153 switch ((data >> cc_shift) & 0x1f) {
155 cc_wait = ", cc wait 1";
158 cc_wait = ", cc wait 2";
161 cc_wait = ", cc wait 3";
164 cc_wait = ", cc wait 4";
167 cc_wait = ", cc wait 4";
175 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
176 data & (1<<18)? ", pipe B start vblank wait": "",
177 data & (1<<17)? ", pipe A start vblank wait": "",
178 data & (1<<16)? ", overlay flip pending wait": "",
179 data & (1<<14)? ", pipe B hblank wait": "",
180 data & (1<<13)? ", pipe A hblank wait": "",
182 data & (1<<8)? ", plane C pending flip wait": "",
183 data & (1<<7)? ", pipe B vblank wait": "",
184 data & (1<<6)? ", plane B pending flip wait": "",
185 data & (1<<5)? ", pipe B scan line wait": "",
186 data & (1<<4)? ", fbc idle wait": "",
187 data & (1<<3)? ", pipe A vblank wait": "",
188 data & (1<<2)? ", plane A pending flip wait": "",
189 data & (1<<1)? ", plane A scan line wait": "");
191 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s\n",
192 data & (1<<20)? ", sprite C pending flip wait": "", /* ivb */
194 data & (1<<13)? ", pipe B hblank wait": "",
195 data & (1<<11)? ", pipe B vblank wait": "",
196 data & (1<<10)? ", sprite B pending flip wait": "",
197 data & (1<<9)? ", plane B pending flip wait": "",
198 data & (1<<8)? ", plane B scan line wait": "",
199 data & (1<<5)? ", pipe A hblank wait": "",
200 data & (1<<3)? ", pipe A vblank wait": "",
201 data & (1<<2)? ", sprite A pending flip wait": "",
202 data & (1<<1)? ", plane A pending flip wait": "",
203 data & (1<<0)? ", plane A scan line wait": "");
210 decode_mi(struct drm_intel_decode *ctx)
212 unsigned int opcode, len = -1;
213 const char *post_sync_op = "";
214 uint32_t *data = ctx->data;
219 unsigned int min_len;
220 unsigned int max_len;
222 int (*func)(struct drm_intel_decode *ctx);
224 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
225 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
226 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
227 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
228 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
229 { 0x04, 0, 1, 1, "MI_FLUSH" },
230 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
231 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
232 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
233 { 0x00, 0, 1, 1, "MI_NOOP" },
234 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
235 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
236 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
237 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
238 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
239 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
240 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
241 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT", decode_MI_WAIT_FOR_EVENT },
242 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
243 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
244 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
245 }, *opcode_mi = NULL;
247 /* check instruction length */
248 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
250 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
252 if (opcodes_mi[opcode].max_len > 1) {
254 (data[0] & opcodes_mi[opcode].len_mask) + 2;
255 if (len < opcodes_mi[opcode].min_len
256 || len > opcodes_mi[opcode].max_len) {
258 "Bad length (%d) in %s, [%d, %d]\n",
259 len, opcodes_mi[opcode].name,
260 opcodes_mi[opcode].min_len,
261 opcodes_mi[opcode].max_len);
264 opcode_mi = &opcodes_mi[opcode];
269 if (opcode_mi && opcode_mi->func)
270 return opcode_mi->func(ctx);
272 switch ((data[0] & 0x1f800000) >> 23) {
274 instr_out(ctx, 0, "MI_BATCH_BUFFER_END\n");
277 instr_out(ctx, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
278 data[0] & (1 << 22) ? " global gtt," : "",
279 data[0] & (1 << 21) ? " update semaphore," : "",
280 data[0] & (1 << 20) ? " compare semaphore," : "",
281 data[0] & (1 << 18) ? " use compare reg" : "",
282 (data[0] & (0x3 << 16)) >> 16);
283 instr_out(ctx, 1, "value\n");
284 instr_out(ctx, 2, "address\n");
287 instr_out(ctx, 0, "MI_STORE_DATA_INDEX%s\n",
288 data[0] & (1 << 21) ? " use per-process HWS," : "");
289 instr_out(ctx, 1, "index\n");
290 instr_out(ctx, 2, "dword\n");
292 instr_out(ctx, 3, "upper dword\n");
295 if (data[0] & (1 << 22))
297 "MI_NOOP write NOPID reg, val=0x%x\n",
298 data[0] & ((1 << 22) - 1));
300 instr_out(ctx, 0, "MI_NOOP\n");
303 switch (data[0] & (0x3 << 14)) {
305 post_sync_op = "no write";
308 post_sync_op = "write data";
311 post_sync_op = "reserved";
314 post_sync_op = "write TIMESTAMP";
318 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
319 data[0] & (1 << 22) ?
320 " enable protected mem (BCS-only)," : "",
321 data[0] & (1 << 21) ? " store in hws," : "",
322 data[0] & (1 << 18) ? " invalidate tlb," : "",
323 data[0] & (1 << 17) ? " flush gfdt," : "",
325 data[0] & (1 << 8) ? " enable notify interrupt," : "",
327 " invalidate video state (BCS-only)," : "");
328 if (data[0] & (1 << 21))
329 instr_out(ctx, 1, "hws index\n");
331 instr_out(ctx, 1, "address\n");
332 instr_out(ctx, 2, "dword\n");
334 instr_out(ctx, 3, "upper dword\n");
338 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
340 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
343 instr_out(ctx, 0, "%s\n",
344 opcodes_mi[opcode].name);
345 for (i = 1; i < len; i++) {
346 instr_out(ctx, i, "dword %d\n", i);
353 instr_out(ctx, 0, "MI UNKNOWN\n");
358 decode_2d_br00(struct drm_intel_decode *ctx, const char *cmd)
361 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
363 (ctx->data[0] & (1 << 20)) ? "en" : "dis",
364 (ctx->data[0] & (1 << 21)) ? "en" : "dis",
365 (ctx->data[0] >> 15) & 1,
366 (ctx->data[0] >> 11) & 1);
370 decode_2d_br01(struct drm_intel_decode *ctx)
373 switch ((ctx->data[1] >> 24) & 0x3) {
389 "format %s, pitch %d, rop 0x%02x, "
390 "clipping %sabled, %s%s \n",
392 (short)(ctx->data[1] & 0xffff),
393 (ctx->data[1] >> 16) & 0xff,
394 ctx->data[1] & (1 << 30) ? "en" : "dis",
395 ctx->data[1] & (1 << 31) ? "solid pattern enabled, " : "",
396 ctx->data[1] & (1 << 31) ?
397 "mono pattern transparency enabled, " : "");
402 decode_2d(struct drm_intel_decode *ctx)
404 unsigned int opcode, len;
405 uint32_t *data = ctx->data;
409 unsigned int min_len;
410 unsigned int max_len;
413 { 0x40, 5, 5, "COLOR_BLT" },
414 { 0x43, 6, 6, "SRC_COPY_BLT" },
415 { 0x01, 8, 8, "XY_SETUP_BLT" },
416 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
417 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
418 { 0x24, 2, 2, "XY_PIXEL_BLT" },
419 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
420 { 0x26, 4, 4, "Y_TEXT_BLT" },
421 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
422 { 0x50, 6, 6, "XY_COLOR_BLT" },
423 { 0x51, 6, 6, "XY_PAT_BLT" },
424 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
425 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
426 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
427 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
428 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
429 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
430 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
431 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
432 { 0x55, 9, 9, "XY_FULL_BLT" },
433 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
434 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
435 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
436 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
437 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
440 switch ((data[0] & 0x1fc00000) >> 22) {
443 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
444 (data[0] >> 12) & 0x8,
445 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
447 len = (data[0] & 0x000000ff) + 2;
449 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
451 instr_out(ctx, 1, "dest (%d,%d)\n",
452 data[1] & 0xffff, data[1] >> 16);
453 instr_out(ctx, 2, "dest (%d,%d)\n",
454 data[2] & 0xffff, data[2] >> 16);
457 decode_2d_br00(ctx, "XY_SETUP_BLT");
459 len = (data[0] & 0x000000ff) + 2;
461 fprintf(out, "Bad count in XY_SETUP_BLT\n");
464 instr_out(ctx, 2, "cliprect (%d,%d)\n",
465 data[2] & 0xffff, data[2] >> 16);
466 instr_out(ctx, 3, "cliprect (%d,%d)\n",
467 data[3] & 0xffff, data[3] >> 16);
468 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
470 instr_out(ctx, 5, "setup background color\n");
471 instr_out(ctx, 6, "setup foreground color\n");
472 instr_out(ctx, 7, "color pattern offset\n");
475 decode_2d_br00(ctx, "XY_SETUP_CLIP_BLT");
477 len = (data[0] & 0x000000ff) + 2;
479 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
481 instr_out(ctx, 1, "cliprect (%d,%d)\n",
482 data[1] & 0xffff, data[2] >> 16);
483 instr_out(ctx, 2, "cliprect (%d,%d)\n",
484 data[2] & 0xffff, data[3] >> 16);
487 decode_2d_br00(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT");
489 len = (data[0] & 0x000000ff) + 2;
492 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
495 instr_out(ctx, 2, "cliprect (%d,%d)\n",
496 data[2] & 0xffff, data[2] >> 16);
497 instr_out(ctx, 3, "cliprect (%d,%d)\n",
498 data[3] & 0xffff, data[3] >> 16);
499 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
501 instr_out(ctx, 5, "setup background color\n");
502 instr_out(ctx, 6, "setup foreground color\n");
503 instr_out(ctx, 7, "mono pattern dw0\n");
504 instr_out(ctx, 8, "mono pattern dw1\n");
507 decode_2d_br00(ctx, "XY_COLOR_BLT");
509 len = (data[0] & 0x000000ff) + 2;
511 fprintf(out, "Bad count in XY_COLOR_BLT\n");
514 instr_out(ctx, 2, "(%d,%d)\n",
515 data[2] & 0xffff, data[2] >> 16);
516 instr_out(ctx, 3, "(%d,%d)\n",
517 data[3] & 0xffff, data[3] >> 16);
518 instr_out(ctx, 4, "offset 0x%08x\n", data[4]);
519 instr_out(ctx, 5, "color\n");
522 decode_2d_br00(ctx, "XY_SRC_COPY_BLT");
524 len = (data[0] & 0x000000ff) + 2;
526 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
529 instr_out(ctx, 2, "dst (%d,%d)\n",
530 data[2] & 0xffff, data[2] >> 16);
531 instr_out(ctx, 3, "dst (%d,%d)\n",
532 data[3] & 0xffff, data[3] >> 16);
533 instr_out(ctx, 4, "dst offset 0x%08x\n", data[4]);
534 instr_out(ctx, 5, "src (%d,%d)\n",
535 data[5] & 0xffff, data[5] >> 16);
536 instr_out(ctx, 6, "src pitch %d\n",
537 (short)(data[6] & 0xffff));
538 instr_out(ctx, 7, "src offset 0x%08x\n", data[7]);
542 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
544 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
548 instr_out(ctx, 0, "%s\n",
549 opcodes_2d[opcode].name);
550 if (opcodes_2d[opcode].max_len > 1) {
551 len = (data[0] & 0x000000ff) + 2;
552 if (len < opcodes_2d[opcode].min_len ||
553 len > opcodes_2d[opcode].max_len) {
554 fprintf(out, "Bad count in %s\n",
555 opcodes_2d[opcode].name);
559 for (i = 1; i < len; i++) {
560 instr_out(ctx, i, "dword %d\n", i);
567 instr_out(ctx, 0, "2D UNKNOWN\n");
572 decode_3d_1c(struct drm_intel_decode *ctx)
574 uint32_t *data = ctx->data;
577 opcode = (data[0] & 0x00f80000) >> 19;
582 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
585 instr_out(ctx, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
586 data[0] & 1 ? "enabled" : "disabled");
589 instr_out(ctx, 0, "3DSTATE_MAP_COORD_SET_I830\n");
592 instr_out(ctx, 0, "3DSTATE_MAP_CUBE_I830\n");
595 instr_out(ctx, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
599 instr_out(ctx, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
604 /** Sets the string dstname to describe the destination of the PS instruction */
606 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
608 uint32_t a0 = data[i];
609 int dst_nr = (a0 >> 14) & 0xf;
614 if (((a0 >> 10) & 0xf) == 0xf) {
617 int dstmask_index = 0;
619 dstmask[dstmask_index++] = '.';
621 dstmask[dstmask_index++] = 'x';
623 dstmask[dstmask_index++] = 'y';
625 dstmask[dstmask_index++] = 'z';
627 dstmask[dstmask_index++] = 'w';
628 dstmask[dstmask_index++] = 0;
640 switch ((a0 >> 19) & 0x7) {
643 fprintf(out, "bad destination reg R%d\n", dst_nr);
644 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
648 fprintf(out, "bad destination reg oC%d\n", dst_nr);
649 sprintf(dstname, "oC%s%s", dstmask, sat);
653 fprintf(out, "bad destination reg oD%d\n", dst_nr);
654 sprintf(dstname, "oD%s%s", dstmask, sat);
658 fprintf(out, "bad destination reg U%d\n", dst_nr);
659 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
662 sprintf(dstname, "RESERVED");
668 i915_get_channel_swizzle(uint32_t select)
670 switch (select & 0x7) {
672 return (select & 8) ? "-x" : "x";
674 return (select & 8) ? "-y" : "y";
676 return (select & 8) ? "-z" : "z";
678 return (select & 8) ? "-w" : "w";
680 return (select & 8) ? "-0" : "0";
682 return (select & 8) ? "-1" : "1";
684 return (select & 8) ? "-bad" : "bad";
689 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
693 sprintf(name, "R%d", src_nr);
695 fprintf(out, "bad src reg %s\n", name);
699 sprintf(name, "T%d", src_nr);
700 else if (src_nr == 8)
701 sprintf(name, "DIFFUSE");
702 else if (src_nr == 9)
703 sprintf(name, "SPECULAR");
704 else if (src_nr == 10)
705 sprintf(name, "FOG");
707 fprintf(out, "bad src reg T%d\n", src_nr);
708 sprintf(name, "RESERVED");
712 sprintf(name, "C%d", src_nr);
714 fprintf(out, "bad src reg %s\n", name);
719 fprintf(out, "bad src reg oC%d\n", src_nr);
724 fprintf(out, "bad src reg oD%d\n", src_nr);
727 sprintf(name, "U%d", src_nr);
729 fprintf(out, "bad src reg %s\n", name);
732 fprintf(out, "bad src reg type %d\n", src_type);
733 sprintf(name, "RESERVED");
738 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
740 uint32_t a0 = data[i];
741 uint32_t a1 = data[i + 1];
742 int src_nr = (a0 >> 2) & 0x1f;
743 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
744 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
745 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
746 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
749 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
750 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
752 if (strcmp(swizzle, ".xyzw") != 0)
753 strcat(srcname, swizzle);
756 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
758 uint32_t a1 = data[i + 1];
759 uint32_t a2 = data[i + 2];
760 int src_nr = (a1 >> 8) & 0x1f;
761 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
762 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
763 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
764 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
767 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
768 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
770 if (strcmp(swizzle, ".xyzw") != 0)
771 strcat(srcname, swizzle);
774 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
776 uint32_t a2 = data[i + 2];
777 int src_nr = (a2 >> 16) & 0x1f;
778 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
779 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
780 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
781 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
784 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
785 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
787 if (strcmp(swizzle, ".xyzw") != 0)
788 strcat(srcname, swizzle);
792 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
796 sprintf(name, "R%d", src_nr);
798 fprintf(out, "bad src reg %s\n", name);
802 sprintf(name, "T%d", src_nr);
803 else if (src_nr == 8)
804 sprintf(name, "DIFFUSE");
805 else if (src_nr == 9)
806 sprintf(name, "SPECULAR");
807 else if (src_nr == 10)
808 sprintf(name, "FOG");
810 fprintf(out, "bad src reg T%d\n", src_nr);
811 sprintf(name, "RESERVED");
817 fprintf(out, "bad src reg oC%d\n", src_nr);
822 fprintf(out, "bad src reg oD%d\n", src_nr);
825 fprintf(out, "bad src reg type %d\n", src_type);
826 sprintf(name, "RESERVED");
832 i915_decode_alu1(struct drm_intel_decode *ctx,
833 int i, char *instr_prefix, const char *op_name)
835 char dst[100], src0[100];
837 i915_get_instruction_dst(ctx->data, i, dst, 1);
838 i915_get_instruction_src0(ctx->data, i, src0);
840 instr_out(ctx, i++, "%s: %s %s, %s\n", instr_prefix,
842 instr_out(ctx, i++, "%s\n", instr_prefix);
843 instr_out(ctx, i++, "%s\n", instr_prefix);
847 i915_decode_alu2(struct drm_intel_decode *ctx,
848 int i, char *instr_prefix, const char *op_name)
850 char dst[100], src0[100], src1[100];
852 i915_get_instruction_dst(ctx->data, i, dst, 1);
853 i915_get_instruction_src0(ctx->data, i, src0);
854 i915_get_instruction_src1(ctx->data, i, src1);
856 instr_out(ctx, i++, "%s: %s %s, %s, %s\n", instr_prefix,
857 op_name, dst, src0, src1);
858 instr_out(ctx, i++, "%s\n", instr_prefix);
859 instr_out(ctx, i++, "%s\n", instr_prefix);
863 i915_decode_alu3(struct drm_intel_decode *ctx,
864 int i, char *instr_prefix, const char *op_name)
866 char dst[100], src0[100], src1[100], src2[100];
868 i915_get_instruction_dst(ctx->data, i, dst, 1);
869 i915_get_instruction_src0(ctx->data, i, src0);
870 i915_get_instruction_src1(ctx->data, i, src1);
871 i915_get_instruction_src2(ctx->data, i, src2);
873 instr_out(ctx, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
874 op_name, dst, src0, src1, src2);
875 instr_out(ctx, i++, "%s\n", instr_prefix);
876 instr_out(ctx, i++, "%s\n", instr_prefix);
880 i915_decode_tex(struct drm_intel_decode *ctx, int i,
881 const char *instr_prefix, const char *tex_name)
883 uint32_t t0 = ctx->data[i];
884 uint32_t t1 = ctx->data[i + 1];
889 i915_get_instruction_dst(ctx->data, i, dst_name, 0);
890 i915_get_instruction_addr((t1 >> 24) & 0x7,
891 (t1 >> 17) & 0xf, addr_name);
892 sampler_nr = t0 & 0xf;
894 instr_out(ctx, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
895 tex_name, dst_name, sampler_nr, addr_name);
896 instr_out(ctx, i++, "%s\n", instr_prefix);
897 instr_out(ctx, i++, "%s\n", instr_prefix);
901 i915_decode_dcl(struct drm_intel_decode *ctx, int i, char *instr_prefix)
903 uint32_t d0 = ctx->data[i];
904 const char *sampletype;
905 int dcl_nr = (d0 >> 14) & 0xf;
906 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
907 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
908 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
909 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
912 switch ((d0 >> 19) & 0x3) {
914 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
915 if (strcmp(dcl_mask, ".") == 0)
916 fprintf(out, "bad (empty) dcl mask\n");
919 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
921 if (strcmp(dcl_mask, ".x") != 0 &&
922 strcmp(dcl_mask, ".xy") != 0 &&
923 strcmp(dcl_mask, ".xz") != 0 &&
924 strcmp(dcl_mask, ".w") != 0 &&
925 strcmp(dcl_mask, ".xyzw") != 0) {
926 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
929 instr_out(ctx, i++, "%s: DCL T%d%s\n",
930 instr_prefix, dcl_nr, dcl_mask);
932 if (strcmp(dcl_mask, ".xz") == 0)
933 fprintf(out, "errataed bad dcl mask %s\n",
935 else if (strcmp(dcl_mask, ".xw") == 0)
936 fprintf(out, "errataed bad dcl mask %s\n",
938 else if (strcmp(dcl_mask, ".xzw") == 0)
939 fprintf(out, "errataed bad dcl mask %s\n",
944 "%s: DCL DIFFUSE%s\n", instr_prefix,
946 } else if (dcl_nr == 9) {
948 "%s: DCL SPECULAR%s\n", instr_prefix,
950 } else if (dcl_nr == 10) {
952 "%s: DCL FOG%s\n", instr_prefix,
956 instr_out(ctx, i++, "%s\n", instr_prefix);
957 instr_out(ctx, i++, "%s\n", instr_prefix);
960 switch ((d0 >> 22) & 0x3) {
971 sampletype = "RESERVED";
975 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
976 instr_out(ctx, i++, "%s: DCL S%d %s\n",
977 instr_prefix, dcl_nr, sampletype);
978 instr_out(ctx, i++, "%s\n", instr_prefix);
979 instr_out(ctx, i++, "%s\n", instr_prefix);
982 instr_out(ctx, i++, "%s: DCL RESERVED%d\n",
983 instr_prefix, dcl_nr);
984 instr_out(ctx, i++, "%s\n", instr_prefix);
985 instr_out(ctx, i++, "%s\n", instr_prefix);
990 i915_decode_instruction(struct drm_intel_decode *ctx,
991 int i, char *instr_prefix)
993 switch ((ctx->data[i] >> 24) & 0x1f) {
995 instr_out(ctx, i++, "%s: NOP\n", instr_prefix);
996 instr_out(ctx, i++, "%s\n", instr_prefix);
997 instr_out(ctx, i++, "%s\n", instr_prefix);
1000 i915_decode_alu2(ctx, i, instr_prefix, "ADD");
1003 i915_decode_alu1(ctx, i, instr_prefix, "MOV");
1006 i915_decode_alu2(ctx, i, instr_prefix, "MUL");
1009 i915_decode_alu3(ctx, i, instr_prefix, "MAD");
1012 i915_decode_alu3(ctx, i, instr_prefix, "DP2ADD");
1015 i915_decode_alu2(ctx, i, instr_prefix, "DP3");
1018 i915_decode_alu2(ctx, i, instr_prefix, "DP4");
1021 i915_decode_alu1(ctx, i, instr_prefix, "FRC");
1024 i915_decode_alu1(ctx, i, instr_prefix, "RCP");
1027 i915_decode_alu1(ctx, i, instr_prefix, "RSQ");
1030 i915_decode_alu1(ctx, i, instr_prefix, "EXP");
1033 i915_decode_alu1(ctx, i, instr_prefix, "LOG");
1036 i915_decode_alu2(ctx, i, instr_prefix, "CMP");
1039 i915_decode_alu2(ctx, i, instr_prefix, "MIN");
1042 i915_decode_alu2(ctx, i, instr_prefix, "MAX");
1045 i915_decode_alu1(ctx, i, instr_prefix, "FLR");
1048 i915_decode_alu1(ctx, i, instr_prefix, "MOD");
1051 i915_decode_alu1(ctx, i, instr_prefix, "TRC");
1054 i915_decode_alu2(ctx, i, instr_prefix, "SGE");
1057 i915_decode_alu2(ctx, i, instr_prefix, "SLT");
1060 i915_decode_tex(ctx, i, instr_prefix, "TEXLD");
1063 i915_decode_tex(ctx, i, instr_prefix, "TEXLDP");
1066 i915_decode_tex(ctx, i, instr_prefix, "TEXLDB");
1069 i915_decode_dcl(ctx, i, instr_prefix);
1072 instr_out(ctx, i++, "%s: unknown\n", instr_prefix);
1073 instr_out(ctx, i++, "%s\n", instr_prefix);
1074 instr_out(ctx, i++, "%s\n", instr_prefix);
1080 decode_compare_func(uint32_t op)
1104 decode_stencil_op(uint32_t op)
1129 decode_logic_op(uint32_t op)
1170 decode_blend_fact(uint32_t op)
1180 return "inv_src_colr";
1184 return "inv_src_alpha";
1188 return "inv_dst_alpha";
1192 return "inv_dst_colr";
1194 return "src_alpha_sat";
1198 return "inv_cnst_colr";
1200 return "cnst_alpha";
1202 return "inv_const_alpha";
1208 decode_tex_coord_mode(uint32_t mode)
1210 switch (mode & 0x7) {
1216 return "clamp_edge";
1220 return "clamp_border";
1222 return "mirror_once";
1228 decode_sample_filter(uint32_t mode)
1230 switch (mode & 0x7) {
1236 return "anisotropic";
1250 decode_3d_1d(struct drm_intel_decode *ctx)
1252 unsigned int len, i, c, idx, word, map, sampler, instr;
1253 const char *format, *zformat, *type;
1255 uint32_t *data = ctx->data;
1256 uint32_t devid = ctx->devid;
1261 unsigned int min_len;
1262 unsigned int max_len;
1264 } opcodes_3d_1d[] = {
1265 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1266 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1267 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1268 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1269 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1270 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1271 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1272 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1273 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1274 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1275 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1276 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1277 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1278 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1279 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1280 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1283 opcode = (data[0] & 0x00ff0000) >> 16;
1287 /* This instruction is unusual. A 0 length means just
1288 * 1 DWORD instead of 2. The 0 length is specified in
1289 * one place to be unsupported, but stated to be
1290 * required in another, and 0 length LOAD_INDIRECTs
1291 * appear to cause no harm at least.
1293 instr_out(ctx, 0, "3DSTATE_LOAD_INDIRECT\n");
1294 len = (data[0] & 0x000000ff) + 1;
1296 if (data[0] & (0x01 << 8)) {
1297 instr_out(ctx, i++, "SIS.0\n");
1298 instr_out(ctx, i++, "SIS.1\n");
1300 if (data[0] & (0x02 << 8)) {
1301 instr_out(ctx, i++, "DIS.0\n");
1303 if (data[0] & (0x04 << 8)) {
1304 instr_out(ctx, i++, "SSB.0\n");
1305 instr_out(ctx, i++, "SSB.1\n");
1307 if (data[0] & (0x08 << 8)) {
1308 instr_out(ctx, i++, "MSB.0\n");
1309 instr_out(ctx, i++, "MSB.1\n");
1311 if (data[0] & (0x10 << 8)) {
1312 instr_out(ctx, i++, "PSP.0\n");
1313 instr_out(ctx, i++, "PSP.1\n");
1315 if (data[0] & (0x20 << 8)) {
1316 instr_out(ctx, i++, "PSC.0\n");
1317 instr_out(ctx, i++, "PSC.1\n");
1320 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1326 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1327 len = (data[0] & 0x0000000f) + 2;
1329 for (word = 0; word <= 8; word++) {
1330 if (data[0] & (1 << (4 + word))) {
1331 /* save vertex state for decode */
1332 if (!IS_GEN2(devid)) {
1347 "S0: vbo offset: 0x%08x%s\n",
1350 ", auto cache invalidate disabled"
1355 "S1: vertex width: %i, vertex pitch: %i\n",
1363 "S2: texcoord formats: ");
1365 tex_num < 8; tex_num++) {
1411 "S3: not documented\n");
1415 const char *cullmode = "";
1416 const char *vfmt_xyzw = "";
1417 switch ((data[i] >> 13)
1454 case 1 << 6 | 1 << 2:
1458 case 2 << 6 | 1 << 2:
1462 case 3 << 6 | 1 << 2:
1466 case 4 << 6 | 1 << 2:
1472 "S4: point_width=%i, line_width=%.1f,"
1473 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1536 "force default diffuse, "
1542 "force default specular, "
1548 "local depth ofs enable, "
1554 "point sprite enable, "
1568 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1569 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1570 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1600 " force default point size,"
1606 " last pixel enable,"
1612 " global depth ofs enable,"
1638 "stencil write enable, "
1644 "stencil test enable, "
1650 "color dither enable, "
1662 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1663 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1664 "%s%stristrip_provoking_vertex=%i\n",
1665 data[i] & (1 << 31) ?
1666 "alpha test enable, "
1674 data[i] & (1 << 15) ?
1675 "cbuf blend enable, "
1677 decode_blend_fact(data
1681 decode_blend_fact(data
1685 data[i] & (1 << 3) ?
1686 "depth write enable, "
1688 data[i] & (1 << 2) ?
1689 "cbuf write enable, "
1695 "S7: depth offset constant: 0x%08x\n",
1701 "S%d: 0x%08x\n", i, data[i]);
1708 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1713 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1714 len = (data[0] & 0x0000000f) + 2;
1716 for (word = 6; word <= 14; word++) {
1717 if (data[0] & (1 << word)) {
1721 else if (word >= 7 && word <= 10) {
1723 "TB%dC\n", word - 7);
1725 "TB%dA\n", word - 7);
1726 } else if (word >= 11 && word <= 14) {
1728 "TM%dS0: offset=0x%08x, %s\n",
1730 data[i] & 0xfffffffe,
1731 data[i] & 1 ? "use fence" :
1735 "TM%dS1: height=%i, width=%i, %s\n",
1736 word - 11, data[i] >> 21,
1737 (data[i] >> 10) & 0x3ff,
1738 data[i] & 2 ? (data[i] & 1 ?
1744 "TM%dS2: pitch=%i, \n",
1746 ((data[i] >> 21) + 1) * 4);
1749 "TM%dS3\n", word - 11);
1751 "TM%dS4: dflt color\n",
1758 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1762 instr_out(ctx, 0, "3DSTATE_MAP_STATE\n");
1763 len = (data[0] & 0x0000003f) + 2;
1764 instr_out(ctx, 1, "mask\n");
1767 for (map = 0; map <= 15; map++) {
1768 if (data[1] & (1 << map)) {
1769 int width, height, pitch, dword;
1774 "map %d MS2 %s%s%s\n", map,
1776 "untrusted surface, " : "",
1778 "vertical line stride enable, " : "",
1780 "vertical ofs enable, " : "");
1783 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1784 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1787 if (dword & (1 << 2))
1789 else if (dword & (1 << 1))
1790 tiling = dword & (1 << 0) ? "Y" : "X";
1793 switch ((dword >> 7) & 0x7) {
1796 switch ((dword >> 3) & 0xf) {
1813 switch ((dword >> 3) & 0xf) {
1818 format = " argb1555";
1821 format = " argb4444";
1827 format = " bump655";
1842 switch ((dword >> 3) & 0xf) {
1844 format = " argb8888";
1847 format = " abgr8888";
1850 format = " xrgb8888";
1853 format = " xbgr8888";
1856 format = " qwvu8888";
1859 format = " axvu8888";
1862 format = " lxvu8888";
1865 format = " xlvu8888";
1868 format = " argb2101010";
1871 format = " abgr2101010";
1874 format = " awvu2101010";
1895 switch ((dword >> 3) & 0xf) {
1897 format = " yuv_swapy";
1903 format = " yuv_swapuv";
1906 format = " yuv_swapuvy";
1911 type = "compressed";
1912 switch ((dword >> 3) & 0x7) {
1926 format = " dxt1_rb";
1931 type = "4b indexed";
1932 switch ((dword >> 3) & 0xf) {
1934 format = " argb8888";
1941 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1942 map, width, height, type, format,
1944 dword & (1 << 9) ? " palette select" :
1949 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1951 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1952 map, pitch, (dword >> 9) & 0x3f,
1953 dword & 0xff, (dword >> 15) & 0x3f,
1954 dword & (1 << 8) ? "miplayout legacy"
1955 : "miplayout right");
1959 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1965 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1966 len = (data[0] & 0x000000ff) + 2;
1969 for (c = 0; c <= 31; c++) {
1970 if (data[1] & (1 << c)) {
1971 instr_out(ctx, i, "C%d.X = %f\n", c,
1972 int_as_float(data[i]));
1974 instr_out(ctx, i, "C%d.Y = %f\n",
1975 c, int_as_float(data[i]));
1977 instr_out(ctx, i, "C%d.Z = %f\n",
1978 c, int_as_float(data[i]));
1980 instr_out(ctx, i, "C%d.W = %f\n",
1981 c, int_as_float(data[i]));
1987 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1991 instr_out(ctx, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1992 len = (data[0] & 0x000000ff) + 2;
1993 if ((len - 1) % 3 != 0 || len > 370) {
1995 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1998 for (instr = 0; instr < (len - 1) / 3; instr++) {
1999 char instr_prefix[10];
2001 sprintf(instr_prefix, "PS%03d", instr);
2002 i915_decode_instruction(ctx, i,
2010 instr_out(ctx, 0, "3DSTATE_SAMPLER_STATE\n");
2011 instr_out(ctx, 1, "mask\n");
2012 len = (data[0] & 0x0000003f) + 2;
2014 for (sampler = 0; sampler <= 15; sampler++) {
2015 if (data[1] & (1 << sampler)) {
2017 const char *mip_filter = "";
2020 switch ((dword >> 20) & 0x3) {
2022 mip_filter = "none";
2025 mip_filter = "nearest";
2028 mip_filter = "linear";
2032 "sampler %d SS2:%s%s%s "
2033 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
2034 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
2036 dword & (1 << 31) ? " reverse gamma,"
2038 dword & (1 << 30) ? " packed2planar,"
2041 " colorspace conversion," : "",
2042 (dword >> 22) & 0x1f, mip_filter,
2043 decode_sample_filter(dword >> 17),
2044 decode_sample_filter(dword >> 14),
2045 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2046 dword & (1 << 4) ? " shadow," : "",
2047 dword & (1 << 3) ? 4 : 2,
2048 decode_compare_func(dword));
2051 "sampler %d SS3: min_lod=%.2f,%s "
2052 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2054 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2056 " kill pixel enable," : "",
2057 decode_tex_coord_mode(dword >> 12),
2058 decode_tex_coord_mode(dword >> 9),
2059 decode_tex_coord_mode(dword >> 6),
2061 " normalized coords," : "",
2063 dword & (1 << 0) ? " deinterlacer," :
2067 "sampler %d SS4: border color\n",
2072 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2076 len = (data[0] & 0x0000000f) + 2;
2080 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2083 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2085 switch ((data[1] >> 8) & 0xf) {
2090 format = "x1r5g5b5";
2096 format = "a8r8g8b8";
2099 format = "ycrcb_swapy";
2102 format = "ycrcb_normal";
2105 format = "ycrcb_swapuv";
2108 format = "ycrcb_swapuvy";
2111 format = "a4r4g4b4";
2114 format = "a1r5g5b5";
2117 format = "a2r10g10b10";
2123 switch ((data[1] >> 2) & 0x3) {
2138 "%s format, %s depth format, early Z %sabled\n",
2140 (data[1] & (1 << 31)) ? "en" : "dis");
2145 const char *name, *tiling;
2147 len = (data[0] & 0x0000000f) + 2;
2150 "Bad count in 3DSTATE_BUFFER_INFO\n");
2152 switch ((data[1] >> 24) & 0x7) {
2165 if (data[1] & (1 << 23))
2167 else if (data[1] & (1 << 22))
2168 tiling = data[1] & (1 << 21) ? "Y" : "X";
2170 instr_out(ctx, 0, "3DSTATE_BUFFER_INFO\n");
2172 "%s, tiling = %s, pitch=%d\n", name, tiling,
2175 instr_out(ctx, 2, "address\n");
2179 len = (data[0] & 0x0000000f) + 2;
2183 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2185 instr_out(ctx, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2186 instr_out(ctx, 1, "(%d,%d)\n",
2187 data[1] & 0xffff, data[1] >> 16);
2188 instr_out(ctx, 2, "(%d,%d)\n",
2189 data[2] & 0xffff, data[2] >> 16);
2193 len = (data[0] & 0x0000000f) + 2;
2197 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2199 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2200 instr_out(ctx, 1, "%s\n",
2201 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2202 instr_out(ctx, 2, "(%d,%d)\n",
2203 data[2] & 0xffff, data[2] >> 16);
2204 instr_out(ctx, 3, "(%d,%d)\n",
2205 data[3] & 0xffff, data[3] >> 16);
2206 instr_out(ctx, 4, "(%d,%d)\n",
2207 data[4] & 0xffff, data[4] >> 16);
2211 len = (data[0] & 0x0000000f) + 2;
2214 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2216 instr_out(ctx, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2217 instr_out(ctx, 1, "prim_type=%s, clear=%s%s%s\n",
2218 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2219 data[1] & (1 << 2) ? "color," : "",
2220 data[1] & (1 << 1) ? "depth," : "",
2221 data[1] & (1 << 0) ? "stencil," : "");
2222 instr_out(ctx, 2, "clear color\n");
2223 instr_out(ctx, 3, "clear depth/stencil\n");
2224 instr_out(ctx, 4, "color value (rgba8888)\n");
2225 instr_out(ctx, 5, "depth value %f\n",
2226 int_as_float(data[5]));
2227 instr_out(ctx, 6, "clear stencil\n");
2231 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2232 opcode_3d_1d = &opcodes_3d_1d[idx];
2233 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2236 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2239 instr_out(ctx, 0, "%s\n",
2240 opcode_3d_1d->name);
2241 if (opcode_3d_1d->max_len > 1) {
2242 len = (data[0] & 0x0000ffff) + 2;
2243 if (len < opcode_3d_1d->min_len ||
2244 len > opcode_3d_1d->max_len) {
2245 fprintf(out, "Bad count in %s\n",
2246 opcode_3d_1d->name);
2250 for (i = 1; i < len; i++) {
2251 instr_out(ctx, i, "dword %d\n", i);
2258 instr_out(ctx, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2264 decode_3d_primitive(struct drm_intel_decode *ctx)
2266 uint32_t *data = ctx->data;
2267 uint32_t count = ctx->count;
2268 char immediate = (data[0] & (1 << 23)) == 0;
2269 unsigned int len, i, j, ret;
2270 const char *primtype;
2271 int original_s2 = saved_s2;
2272 int original_s4 = saved_s4;
2274 switch ((data[0] >> 18) & 0xf) {
2276 primtype = "TRILIST";
2279 primtype = "TRISTRIP";
2282 primtype = "TRISTRIP_REVERSE";
2285 primtype = "TRIFAN";
2288 primtype = "POLYGON";
2291 primtype = "LINELIST";
2294 primtype = "LINESTRIP";
2297 primtype = "RECTLIST";
2300 primtype = "POINTLIST";
2306 primtype = "CLEAR_RECT";
2311 primtype = "unknown";
2315 /* XXX: 3DPRIM_DIB not supported */
2317 len = (data[0] & 0x0003ffff) + 2;
2318 instr_out(ctx, 0, "3DPRIMITIVE inline %s\n",
2321 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2322 if (!saved_s2_set || !saved_s4_set) {
2323 fprintf(out, "unknown vertex format\n");
2324 for (i = 1; i < len; i++) {
2326 " vertex data (%f float)\n",
2327 int_as_float(data[i]));
2330 unsigned int vertex = 0;
2331 for (i = 1; i < len;) {
2334 #define VERTEX_OUT(fmt, ...) do { \
2336 instr_out(ctx, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2338 fprintf(out, " missing data in V%d\n", vertex); \
2342 VERTEX_OUT("X = %f", int_as_float(data[i]));
2343 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2344 switch (saved_s4 >> 6 & 0x7) {
2346 VERTEX_OUT("Z = %f",
2347 int_as_float(data[i]));
2350 VERTEX_OUT("Z = %f",
2351 int_as_float(data[i]));
2352 VERTEX_OUT("W = %f",
2353 int_as_float(data[i]));
2358 VERTEX_OUT("W = %f",
2359 int_as_float(data[i]));
2362 fprintf(out, "bad S4 position mask\n");
2365 if (saved_s4 & (1 << 10)) {
2367 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2368 "B=0x%02x)", data[i] >> 24,
2369 (data[i] >> 16) & 0xff,
2370 (data[i] >> 8) & 0xff,
2373 if (saved_s4 & (1 << 11)) {
2375 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2376 "B=0x%02x)", data[i] >> 24,
2377 (data[i] >> 16) & 0xff,
2378 (data[i] >> 8) & 0xff,
2381 if (saved_s4 & (1 << 12))
2382 VERTEX_OUT("width = 0x%08x)", data[i]);
2384 for (tc = 0; tc <= 7; tc++) {
2385 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2387 VERTEX_OUT("T%d.X = %f", tc,
2390 VERTEX_OUT("T%d.Y = %f", tc,
2395 VERTEX_OUT("T%d.X = %f", tc,
2398 VERTEX_OUT("T%d.Y = %f", tc,
2401 VERTEX_OUT("T%d.Z = %f", tc,
2406 VERTEX_OUT("T%d.X = %f", tc,
2409 VERTEX_OUT("T%d.Y = %f", tc,
2412 VERTEX_OUT("T%d.Z = %f", tc,
2415 VERTEX_OUT("T%d.W = %f", tc,
2420 VERTEX_OUT("T%d.X = %f", tc,
2426 ("T%d.XY = 0x%08x half-float",
2431 ("T%d.XY = 0x%08x half-float",
2434 ("T%d.ZW = 0x%08x half-float",
2441 "bad S2.T%d format\n",
2451 /* indirect vertices */
2452 len = data[0] & 0x0000ffff; /* index count */
2453 if (data[0] & (1 << 17)) {
2454 /* random vertex access */
2455 if (count < (len + 1) / 2 + 1) {
2456 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2457 "3DPRIMITIVE random indirect");
2460 "3DPRIMITIVE random indirect %s (%d)\n",
2463 /* vertex indices continue until 0xffff is
2466 for (i = 1; i < count; i++) {
2467 if ((data[i] & 0xffff) == 0xffff) {
2469 " indices: (terminator)\n");
2472 } else if ((data[i] >> 16) == 0xffff) {
2474 " indices: 0x%04x, (terminator)\n",
2480 " indices: 0x%04x, 0x%04x\n",
2486 "3DPRIMITIVE: no terminator found in index buffer\n");
2490 /* fixed size vertex index buffer */
2491 for (j = 1, i = 0; i < len; i += 2, j++) {
2492 if (i * 2 == len - 1) {
2494 " indices: 0x%04x\n",
2498 " indices: 0x%04x, 0x%04x\n",
2504 ret = (len + 1) / 2 + 1;
2507 /* sequential vertex access */
2509 "3DPRIMITIVE sequential indirect %s, %d starting from "
2510 "%d\n", primtype, len, data[1] & 0xffff);
2511 instr_out(ctx, 1, " start\n");
2518 saved_s2 = original_s2;
2519 saved_s4 = original_s4;
2524 decode_3d(struct drm_intel_decode *ctx)
2528 uint32_t *data = ctx->data;
2532 unsigned int min_len;
2533 unsigned int max_len;
2536 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2537 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2538 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2539 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2540 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2541 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2542 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2543 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2544 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2547 opcode = (data[0] & 0x1f000000) >> 24;
2551 return decode_3d_primitive(ctx);
2553 return decode_3d_1d(ctx);
2555 return decode_3d_1c(ctx);
2558 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2559 opcode_3d = &opcodes_3d[idx];
2560 if (opcode == opcode_3d->opcode) {
2561 unsigned int len = 1, i;
2563 instr_out(ctx, 0, "%s\n", opcode_3d->name);
2564 if (opcode_3d->max_len > 1) {
2565 len = (data[0] & 0xff) + 2;
2566 if (len < opcode_3d->min_len ||
2567 len > opcode_3d->max_len) {
2568 fprintf(out, "Bad count in %s\n",
2573 for (i = 1; i < len; i++) {
2574 instr_out(ctx, i, "dword %d\n", i);
2580 instr_out(ctx, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2584 static const char *get_965_surfacetype(unsigned int surfacetype)
2586 switch (surfacetype) {
2604 static const char *get_965_depthformat(unsigned int depthformat)
2606 switch (depthformat) {
2608 return "s8_z24float";
2620 static const char *get_965_element_component(uint32_t data, int component)
2622 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2624 switch (component_control) {
2628 switch (component) {
2653 static const char *get_965_prim_type(uint32_t primtype)
2657 return "point list";
2661 return "line strip";
2671 return "quad strip";
2673 return "line list adj";
2675 return "line strip adj";
2677 return "tri list adj";
2679 return "tri strip adj";
2681 return "tri strip reverse";
2689 return "point list bf";
2691 return "line strip cont";
2693 return "line strip bf";
2695 return "line strip cont bf";
2697 return "tri fan no stipple";
2704 i965_decode_urb_fence(struct drm_intel_decode *ctx, int len)
2706 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2707 uint32_t *data = ctx->data;
2710 fprintf(out, "Bad count in URB_FENCE\n");
2712 vs_fence = data[1] & 0x3ff;
2713 gs_fence = (data[1] >> 10) & 0x3ff;
2714 clip_fence = (data[1] >> 20) & 0x3ff;
2715 sf_fence = data[2] & 0x3ff;
2716 vfe_fence = (data[2] >> 10) & 0x3ff;
2717 cs_fence = (data[2] >> 20) & 0x7ff;
2719 instr_out(ctx, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2720 (data[0] >> 13) & 1 ? "cs " : "",
2721 (data[0] >> 12) & 1 ? "vfe " : "",
2722 (data[0] >> 11) & 1 ? "sf " : "",
2723 (data[0] >> 10) & 1 ? "clip " : "",
2724 (data[0] >> 9) & 1 ? "gs " : "",
2725 (data[0] >> 8) & 1 ? "vs " : "");
2727 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2728 vs_fence, clip_fence, gs_fence);
2730 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2731 sf_fence, vfe_fence, cs_fence);
2732 if (gs_fence < vs_fence)
2733 fprintf(out, "gs fence < vs fence!\n");
2734 if (clip_fence < gs_fence)
2735 fprintf(out, "clip fence < gs fence!\n");
2736 if (sf_fence < clip_fence)
2737 fprintf(out, "sf fence < clip fence!\n");
2738 if (cs_fence < sf_fence)
2739 fprintf(out, "cs fence < sf fence!\n");
2745 state_base_out(struct drm_intel_decode *ctx, unsigned int index,
2748 if (ctx->data[index] & 1) {
2749 instr_out(ctx, index,
2750 "%s state base address 0x%08x\n", name,
2751 ctx->data[index] & ~1);
2753 instr_out(ctx, index, "%s state base not updated\n",
2759 state_max_out(struct drm_intel_decode *ctx, unsigned int index,
2762 if (ctx->data[index] & 1) {
2763 if (ctx->data[index] == 1) {
2764 instr_out(ctx, index,
2765 "%s state upper bound disabled\n", name);
2767 instr_out(ctx, index,
2768 "%s state upper bound 0x%08x\n", name,
2769 ctx->data[index] & ~1);
2772 instr_out(ctx, index,
2773 "%s state upper bound not updated\n", name);
2778 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct drm_intel_decode *ctx)
2780 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_CC\n");
2781 instr_out(ctx, 1, "pointer to CC viewport\n");
2787 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct drm_intel_decode *ctx)
2789 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP\n");
2790 instr_out(ctx, 1, "pointer to SF_CLIP viewport\n");
2796 gen7_3DSTATE_BLEND_STATE_POINTERS(struct drm_intel_decode *ctx)
2798 instr_out(ctx, 0, "3DSTATE_BLEND_STATE_POINTERS\n");
2799 instr_out(ctx, 1, "pointer to BLEND_STATE at 0x%08x (%s)\n",
2801 (ctx->data[1] & 1) ? "changed" : "unchanged");
2807 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct drm_intel_decode *ctx)
2809 instr_out(ctx, 0, "3DSTATE_DEPTH_STENCIL_STATE_POINTERS\n");
2811 "pointer to DEPTH_STENCIL_STATE at 0x%08x (%s)\n",
2813 (ctx->data[1] & 1) ? "changed" : "unchanged");
2819 gen7_3DSTATE_HIER_DEPTH_BUFFER(struct drm_intel_decode *ctx)
2821 instr_out(ctx, 0, "3DSTATE_HIER_DEPTH_BUFFER\n");
2822 instr_out(ctx, 1, "pitch %db\n",
2823 (ctx->data[1] & 0x1ffff) + 1);
2824 instr_out(ctx, 2, "pointer to HiZ buffer\n");
2830 gen6_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2832 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2833 instr_out(ctx, 1, "blend change %d\n", ctx->data[1] & 1);
2834 instr_out(ctx, 2, "depth stencil change %d\n",
2836 instr_out(ctx, 3, "cc change %d\n", ctx->data[3] & 1);
2842 gen7_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2844 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2845 instr_out(ctx, 1, "pointer to COLOR_CALC_STATE at 0x%08x "
2848 (ctx->data[1] & 1) ? "changed" : "unchanged");
2854 gen7_3DSTATE_URB_unit(struct drm_intel_decode *ctx, const char *unit)
2856 int start_kb = ((ctx->data[1] >> 25) & 0x3f) * 8;
2857 /* the field is # of 512-bit rows - 1, we print bytes */
2858 int entry_size = (((ctx->data[1] >> 16) & 0x1ff) + 1);
2859 int nr_entries = ctx->data[1] & 0xffff;
2861 instr_out(ctx, 0, "3DSTATE_URB_%s\n", unit);
2863 "%dKB start, size=%d 64B rows, nr_entries=%d, total size %dB\n",
2864 start_kb, entry_size, nr_entries, nr_entries * 64 * entry_size);
2870 gen7_3DSTATE_URB_VS(struct drm_intel_decode *ctx)
2872 return gen7_3DSTATE_URB_unit(ctx, "VS");
2876 gen7_3DSTATE_URB_HS(struct drm_intel_decode *ctx)
2878 return gen7_3DSTATE_URB_unit(ctx, "HS");
2882 gen7_3DSTATE_URB_DS(struct drm_intel_decode *ctx)
2884 return gen7_3DSTATE_URB_unit(ctx, "DS");
2888 gen7_3DSTATE_URB_GS(struct drm_intel_decode *ctx)
2890 return gen7_3DSTATE_URB_unit(ctx, "GS");
2894 gen7_3DSTATE_CONSTANT(struct drm_intel_decode *ctx, const char *unit)
2898 rlen[0] = (ctx->data[1] >> 0) & 0xffff;
2899 rlen[1] = (ctx->data[1] >> 16) & 0xffff;
2900 rlen[2] = (ctx->data[2] >> 0) & 0xffff;
2901 rlen[3] = (ctx->data[2] >> 16) & 0xffff;
2903 instr_out(ctx, 0, "3DSTATE_CONSTANT_%s\n", unit);
2904 instr_out(ctx, 1, "len 0 = %d, len 1 = %d\n", rlen[0], rlen[1]);
2905 instr_out(ctx, 2, "len 2 = %d, len 3 = %d\n", rlen[2], rlen[3]);
2906 instr_out(ctx, 3, "pointer to constbuf 0\n");
2907 instr_out(ctx, 4, "pointer to constbuf 1\n");
2908 instr_out(ctx, 5, "pointer to constbuf 2\n");
2909 instr_out(ctx, 6, "pointer to constbuf 3\n");
2915 gen7_3DSTATE_CONSTANT_VS(struct drm_intel_decode *ctx)
2917 return gen7_3DSTATE_CONSTANT(ctx, "VS");
2921 gen7_3DSTATE_CONSTANT_GS(struct drm_intel_decode *ctx)
2923 return gen7_3DSTATE_CONSTANT(ctx, "GS");
2927 gen7_3DSTATE_CONSTANT_PS(struct drm_intel_decode *ctx)
2929 return gen7_3DSTATE_CONSTANT(ctx, "PS");
2933 gen7_3DSTATE_CONSTANT_DS(struct drm_intel_decode *ctx)
2935 return gen7_3DSTATE_CONSTANT(ctx, "DS");
2939 gen7_3DSTATE_CONSTANT_HS(struct drm_intel_decode *ctx)
2941 return gen7_3DSTATE_CONSTANT(ctx, "HS");
2946 gen6_3DSTATE_WM(struct drm_intel_decode *ctx)
2948 instr_out(ctx, 0, "3DSTATE_WM\n");
2949 instr_out(ctx, 1, "kernel start pointer 0\n");
2951 "SPF=%d, VME=%d, Sampler Count %d, "
2952 "Binding table count %d\n",
2953 (ctx->data[2] >> 31) & 1,
2954 (ctx->data[2] >> 30) & 1,
2955 (ctx->data[2] >> 27) & 7,
2956 (ctx->data[2] >> 18) & 0xff);
2957 instr_out(ctx, 3, "scratch offset\n");
2959 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
2960 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
2961 (ctx->data[4] & (1 << 30)) != 0,
2962 (ctx->data[4] & (1 << 28)) != 0,
2963 (ctx->data[4] & (1 << 27)) != 0,
2964 (ctx->data[4] >> 16) & 0x7f,
2965 (ctx->data[4] >> 8) & 0x7f,
2966 (ctx->data[4] & 0x7f));
2968 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
2969 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, "
2970 "Dispatch32 %d, Dispatch16 %d, Dispatch8 %d\n",
2971 ((ctx->data[5] >> 25) & 0x7f) + 1,
2972 (ctx->data[5] & (1 << 22)) != 0,
2973 (ctx->data[5] & (1 << 21)) != 0,
2974 (ctx->data[5] & (1 << 20)) != 0,
2975 (ctx->data[5] & (1 << 19)) != 0,
2976 (ctx->data[5] & (1 << 8)) != 0,
2977 (ctx->data[5] & (1 << 2)) != 0,
2978 (ctx->data[5] & (1 << 1)) != 0,
2979 (ctx->data[5] & (1 << 0)) != 0);
2981 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
2982 "Barycentric interp mode 0x%x, Point raster rule %d, "
2983 "Multisample mode %d, "
2984 "Multisample Dispatch mode %d\n",
2985 (ctx->data[6] >> 20) & 0x3f,
2986 (ctx->data[6] >> 18) & 3,
2987 (ctx->data[6] >> 16) & 3,
2988 (ctx->data[6] >> 10) & 0x3f,
2989 (ctx->data[6] & (1 << 9)) != 0,
2990 (ctx->data[6] >> 1) & 3,
2991 (ctx->data[6] & 1));
2992 instr_out(ctx, 7, "kernel start pointer 1\n");
2993 instr_out(ctx, 8, "kernel start pointer 2\n");
2999 gen7_3DSTATE_WM(struct drm_intel_decode *ctx)
3001 const char *computed_depth = "";
3002 const char *early_depth = "";
3003 const char *zw_interp = "";
3005 switch ((ctx->data[1] >> 23) & 0x3) {
3007 computed_depth = "";
3010 computed_depth = "computed depth";
3013 computed_depth = "computed depth >=";
3016 computed_depth = "computed depth <=";
3020 switch ((ctx->data[1] >> 21) & 0x3) {
3025 early_depth = ", EDSC_PSEXEC";
3028 early_depth = ", EDSC_PREPS";
3031 early_depth = ", BAD EDSC";
3035 switch ((ctx->data[1] >> 17) & 0x3) {
3040 early_depth = ", BAD ZW interp";
3043 early_depth = ", ZW centroid";
3046 early_depth = ", ZW sample";
3050 instr_out(ctx, 0, "3DSTATE_WM\n");
3051 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",
3052 (ctx->data[1] & (1 << 11)) ? "PP " : "",
3053 (ctx->data[1] & (1 << 12)) ? "PC " : "",
3054 (ctx->data[1] & (1 << 13)) ? "PS " : "",
3055 (ctx->data[1] & (1 << 14)) ? "NPP " : "",
3056 (ctx->data[1] & (1 << 15)) ? "NPC " : "",
3057 (ctx->data[1] & (1 << 16)) ? "NPS " : "",
3058 (ctx->data[1] & (1 << 30)) ? ", depth clear" : "",
3059 (ctx->data[1] & (1 << 29)) ? "" : ", disabled",
3060 (ctx->data[1] & (1 << 28)) ? ", depth resolve" : "",
3061 (ctx->data[1] & (1 << 27)) ? ", hiz resolve" : "",
3062 (ctx->data[1] & (1 << 25)) ? ", kill" : "",
3066 (ctx->data[1] & (1 << 20)) ? ", source depth" : "",
3067 (ctx->data[1] & (1 << 19)) ? ", source W" : "",
3068 (ctx->data[1] & (1 << 10)) ? ", coverage" : "",
3069 (ctx->data[1] & (1 << 4)) ? ", poly stipple" : "",
3070 (ctx->data[1] & (1 << 3)) ? ", line stipple" : "",
3071 (ctx->data[1] & (1 << 2)) ? ", point UL" : ", point UR"
3073 instr_out(ctx, 2, "MS\n");
3079 gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
3082 "3DPRIMITIVE: %s %s\n",
3083 get_965_prim_type((ctx->data[0] >> 10) & 0x1f),
3084 (ctx->data[0] & (1 << 15)) ? "random" : "sequential");
3085 instr_out(ctx, 1, "vertex count\n");
3086 instr_out(ctx, 2, "start vertex\n");
3087 instr_out(ctx, 3, "instance count\n");
3088 instr_out(ctx, 4, "start instance\n");
3089 instr_out(ctx, 5, "index bias\n");
3095 gen7_3DPRIMITIVE(struct drm_intel_decode *ctx)
3097 bool indirect = !!(ctx->data[0] & (1 << 10));
3100 "3DPRIMITIVE: %s%s\n",
3101 indirect ? " indirect" : "",
3102 (ctx->data[0] & (1 << 8)) ? " predicated" : "");
3103 instr_out(ctx, 1, "%s %s\n",
3104 get_965_prim_type(ctx->data[1] & 0x3f),
3105 (ctx->data[1] & (1 << 8)) ? "random" : "sequential");
3106 instr_out(ctx, 2, indirect ? "ignored" : "vertex count\n");
3107 instr_out(ctx, 3, indirect ? "ignored" : "start vertex\n");
3108 instr_out(ctx, 4, indirect ? "ignored" : "instance count\n");
3109 instr_out(ctx, 5, indirect ? "ignored" : "start instance\n");
3110 instr_out(ctx, 6, indirect ? "ignored" : "index bias\n");
3116 decode_3d_965(struct drm_intel_decode *ctx)
3120 unsigned int i, j, sba_len;
3121 const char *desc1 = NULL;
3122 uint32_t *data = ctx->data;
3123 uint32_t devid = ctx->devid;
3128 int unsigned min_len;
3129 int unsigned max_len;
3132 int (*func)(struct drm_intel_decode *ctx);
3134 { 0x6000, 0x00ff, 3, 3, "URB_FENCE" },
3135 { 0x6001, 0xffff, 2, 2, "CS_URB_STATE" },
3136 { 0x6002, 0x00ff, 2, 2, "CONSTANT_BUFFER" },
3137 { 0x6101, 0xffff, 6, 10, "STATE_BASE_ADDRESS" },
3138 { 0x6102, 0xffff, 2, 2, "STATE_SIP" },
3139 { 0x6104, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3140 { 0x680b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3141 { 0x6904, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3142 { 0x7800, 0xffff, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
3143 { 0x7801, 0x00ff, 4, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
3144 { 0x7802, 0x00ff, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
3145 { 0x7805, 0x00ff, 7, 7, "3DSTATE_DEPTH_BUFFER", 7 },
3146 { 0x7805, 0x00ff, 3, 3, "3DSTATE_URB" },
3147 { 0x7804, 0x00ff, 3, 3, "3DSTATE_CLEAR_PARAMS" },
3148 { 0x7806, 0x00ff, 3, 3, "3DSTATE_STENCIL_BUFFER" },
3149 { 0x7807, 0x00ff, 4, 4, "3DSTATE_HIER_DEPTH_BUFFER", 6 },
3150 { 0x7807, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 7, gen7_3DSTATE_HIER_DEPTH_BUFFER },
3151 { 0x7808, 0x00ff, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
3152 { 0x7809, 0x00ff, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
3153 { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" },
3154 { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3155 { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
3156 { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS },
3157 { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS },
3158 { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" },
3159 { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" },
3160 { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" },
3161 { 0x7812, 0x00ff, 4, 4, "3DSTATE_CLIP" },
3162 { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF", 6 },
3163 { 0x7813, 0x00ff, 7, 7, "3DSTATE_SF", 7 },
3164 { 0x7814, 0x00ff, 3, 3, "3DSTATE_WM", 7, gen7_3DSTATE_WM },
3165 { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM", 6, gen6_3DSTATE_WM },
3166 { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE", 6 },
3167 { 0x7815, 0x00ff, 7, 7, "3DSTATE_CONSTANT_VS", 7, gen7_3DSTATE_CONSTANT_VS },
3168 { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE", 6 },
3169 { 0x7816, 0x00ff, 7, 7, "3DSTATE_CONSTANT_GS", 7, gen7_3DSTATE_CONSTANT_GS },
3170 { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE", 6 },
3171 { 0x7817, 0x00ff, 7, 7, "3DSTATE_CONSTANT_PS", 7, gen7_3DSTATE_CONSTANT_PS },
3172 { 0x7818, 0xffff, 2, 2, "3DSTATE_SAMPLE_MASK" },
3173 { 0x7819, 0x00ff, 7, 7, "3DSTATE_CONSTANT_HS", 7, gen7_3DSTATE_CONSTANT_HS },
3174 { 0x781a, 0x00ff, 7, 7, "3DSTATE_CONSTANT_DS", 7, gen7_3DSTATE_CONSTANT_DS },
3175 { 0x781b, 0x00ff, 7, 7, "3DSTATE_HS" },
3176 { 0x781c, 0x00ff, 4, 4, "3DSTATE_TE" },
3177 { 0x781d, 0x00ff, 6, 6, "3DSTATE_DS" },
3178 { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" },
3179 { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" },
3180 { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" },
3181 { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP },
3182 { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC },
3183 { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS },
3184 { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS },
3185 { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" },
3186 { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" },
3187 { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" },
3188 { 0x7829, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_GS" },
3189 { 0x782a, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_PS" },
3190 { 0x782b, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_VS" },
3191 { 0x782c, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_HS" },
3192 { 0x782d, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_DS" },
3193 { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" },
3194 { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" },
3195 { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS },
3196 { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS },
3197 { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS },
3198 { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS },
3199 { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
3200 { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" },
3201 { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" },
3202 { 0x7906, 0xffff, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
3203 { 0x7907, 0xffff, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
3204 { 0x7908, 0xffff, 3, 3, "3DSTATE_LINE_STIPPLE" },
3205 { 0x7909, 0xffff, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
3206 { 0x7909, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3207 { 0x790a, 0xffff, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
3208 { 0x790b, 0xffff, 4, 4, "3DSTATE_GS_SVB_INDEX" },
3209 { 0x790d, 0xffff, 3, 3, "3DSTATE_MULTISAMPLE", 6 },
3210 { 0x790d, 0xffff, 4, 4, "3DSTATE_MULTISAMPLE", 7 },
3211 { 0x7910, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3212 { 0x7912, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_VS" },
3213 { 0x7913, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_HS" },
3214 { 0x7914, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_DS" },
3215 { 0x7915, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_GS" },
3216 { 0x7916, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_PS" },
3217 { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" },
3218 { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" },
3219 { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" },
3220 { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE },
3221 { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
3222 }, *opcode_3d = NULL;
3224 opcode = (data[0] & 0xffff0000) >> 16;
3226 for (i = 0; i < ARRAY_SIZE(opcodes_3d); i++) {
3227 if (opcode != opcodes_3d[i].opcode)
3230 /* If it's marked as not our gen, skip. */
3231 if (opcodes_3d[i].gen && opcodes_3d[i].gen != ctx->gen)
3234 opcode_3d = &opcodes_3d[i];
3239 if (opcode_3d->max_len == 1)
3242 len = (data[0] & opcode_3d->len_mask) + 2;
3244 if (len < opcode_3d->min_len ||
3245 len > opcode_3d->max_len) {
3246 fprintf(out, "Bad length %d in %s, expected %d-%d\n",
3247 len, opcode_3d->name,
3248 opcode_3d->min_len, opcode_3d->max_len);
3251 len = (data[0] & 0x0000ffff) + 2;
3256 return i965_decode_urb_fence(ctx, len);
3258 instr_out(ctx, 0, "CS_URB_STATE\n");
3260 "entry_size: %d [%d bytes], n_entries: %d\n",
3261 (data[1] >> 4) & 0x1f,
3262 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
3265 instr_out(ctx, 0, "CONSTANT_BUFFER: %s\n",
3266 (data[0] >> 8) & 1 ? "valid" : "invalid");
3268 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
3269 ((data[1] & 0x3f) + 1) * 64);
3273 instr_out(ctx, 0, "STATE_BASE_ADDRESS\n");
3276 if (IS_GEN6(devid) || IS_GEN7(devid))
3278 else if (IS_GEN5(devid))
3283 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
3285 state_base_out(ctx, i++, "general");
3286 state_base_out(ctx, i++, "surface");
3287 if (IS_GEN6(devid) || IS_GEN7(devid))
3288 state_base_out(ctx, i++, "dynamic");
3289 state_base_out(ctx, i++, "indirect");
3290 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3291 state_base_out(ctx, i++, "instruction");
3293 state_max_out(ctx, i++, "general");
3294 if (IS_GEN6(devid) || IS_GEN7(devid))
3295 state_max_out(ctx, i++, "dynamic");
3296 state_max_out(ctx, i++, "indirect");
3297 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3298 state_max_out(ctx, i++, "instruction");
3302 instr_out(ctx, 0, "3DSTATE_PIPELINED_POINTERS\n");
3303 instr_out(ctx, 1, "VS state\n");
3304 instr_out(ctx, 2, "GS state\n");
3305 instr_out(ctx, 3, "Clip state\n");
3306 instr_out(ctx, 4, "SF state\n");
3307 instr_out(ctx, 5, "WM state\n");
3308 instr_out(ctx, 6, "CC state\n");
3311 if (len != 6 && len != 4)
3313 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
3316 "3DSTATE_BINDING_TABLE_POINTERS\n");
3317 instr_out(ctx, 1, "VS binding table\n");
3318 instr_out(ctx, 2, "GS binding table\n");
3319 instr_out(ctx, 3, "Clip binding table\n");
3320 instr_out(ctx, 4, "SF binding table\n");
3321 instr_out(ctx, 5, "WM binding table\n");
3324 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
3325 "GS mod %d, PS mod %d\n",
3326 (data[0] & (1 << 8)) != 0,
3327 (data[0] & (1 << 9)) != 0,
3328 (data[0] & (1 << 12)) != 0);
3329 instr_out(ctx, 1, "VS binding table\n");
3330 instr_out(ctx, 2, "GS binding table\n");
3331 instr_out(ctx, 3, "WM binding table\n");
3337 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
3338 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
3339 (data[0] & (1 << 9)) != 0,
3340 (data[0] & (1 << 12)) != 0);
3341 instr_out(ctx, 1, "VS sampler state\n");
3342 instr_out(ctx, 2, "GS sampler state\n");
3343 instr_out(ctx, 3, "WM sampler state\n");
3346 /* Actually 3DSTATE_DEPTH_BUFFER on gen7. */
3350 instr_out(ctx, 0, "3DSTATE_URB\n");
3352 "VS entries %d, alloc size %d (1024bit row)\n",
3353 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
3355 "GS entries %d, alloc size %d (1024bit row)\n",
3356 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
3360 if ((len - 1) % 4 != 0)
3361 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
3362 instr_out(ctx, 0, "3DSTATE_VERTEX_BUFFERS\n");
3364 for (i = 1; i < len;) {
3366 if (IS_GEN6(devid)) {
3374 "buffer %d: %s, pitch %db\n", data[i] >> idx,
3375 data[i] & (1 << access) ? "random" :
3376 "sequential", data[i] & 0x07ff);
3378 instr_out(ctx, i++, "buffer address\n");
3379 instr_out(ctx, i++, "max index\n");
3380 instr_out(ctx, i++, "mbz\n");
3385 if ((len + 1) % 2 != 0)
3386 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3387 instr_out(ctx, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3389 for (i = 1; i < len;) {
3391 "buffer %d: %svalid, type 0x%04x, "
3392 "src offset 0x%04x bytes\n",
3393 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3394 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3395 "" : "in", (data[i] >> 16) & 0x1ff,
3398 instr_out(ctx, i, "(%s, %s, %s, %s), "
3399 "dst offset 0x%02x bytes\n",
3400 get_965_element_component(data[i], 0),
3401 get_965_element_component(data[i], 1),
3402 get_965_element_component(data[i], 2),
3403 get_965_element_component(data[i], 3),
3404 (data[i] & 0xff) * 4);
3411 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3412 instr_out(ctx, 1, "clip\n");
3413 instr_out(ctx, 2, "sf\n");
3414 instr_out(ctx, 3, "cc\n");
3418 instr_out(ctx, 0, "3DSTATE_INDEX_BUFFER\n");
3419 instr_out(ctx, 1, "beginning buffer address\n");
3420 instr_out(ctx, 2, "ending buffer address\n");
3424 instr_out(ctx, 0, "3DSTATE_SCISSOR_POINTERS\n");
3425 instr_out(ctx, 1, "scissor rect offset\n");
3429 instr_out(ctx, 0, "3DSTATE_VS\n");
3430 instr_out(ctx, 1, "kernel pointer\n");
3432 "SPF=%d, VME=%d, Sampler Count %d, "
3433 "Binding table count %d\n", (data[2] >> 31) & 1,
3434 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3435 (data[2] >> 18) & 0xff);
3436 instr_out(ctx, 3, "scratch offset\n");
3438 "Dispatch GRF start %d, VUE read length %d, "
3439 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3440 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3442 "Max Threads %d, Vertex Cache %sable, "
3443 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3444 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3445 (data[5] & 1) != 0 ? "en" : "dis");
3449 instr_out(ctx, 0, "3DSTATE_GS\n");
3450 instr_out(ctx, 1, "kernel pointer\n");
3452 "SPF=%d, VME=%d, Sampler Count %d, "
3453 "Binding table count %d\n", (data[2] >> 31) & 1,
3454 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3455 (data[2] >> 18) & 0xff);
3456 instr_out(ctx, 3, "scratch offset\n");
3458 "Dispatch GRF start %d, VUE read length %d, "
3459 "VUE read offset %d\n", (data[4] & 0xf),
3460 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3462 "Max Threads %d, Rendering %sable\n",
3463 ((data[5] >> 25) & 0x7f) + 1,
3464 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3466 "Reorder %sable, Discard Adjaceny %sable, "
3468 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3469 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3470 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3474 instr_out(ctx, 0, "3DSTATE_CLIP\n");
3476 "UserClip distance cull test mask 0x%x\n",
3479 "Clip %sable, API mode %s, Viewport XY test %sable, "
3480 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3481 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3482 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3483 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3484 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3485 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3486 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3487 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3488 (data[2] >> 13) & 7,
3489 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3490 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3491 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3494 "Min PointWidth %d, Max PointWidth %d, "
3495 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3496 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3497 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3505 instr_out(ctx, 0, "3DSTATE_SF\n");
3507 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3508 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3509 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3510 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3512 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3513 "VP transform %sable, FrontWinding_%s\n",
3514 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3515 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3516 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3517 (data[2] & 1) != 0 ? "CCW" : "CW");
3519 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3520 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3521 (data[3] >> 29) & 3,
3522 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3523 (data[3] >> 8) & 3);
3525 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3526 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3527 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3528 (data[4] & (1 << 11)) != 0);
3530 "Global Depth Offset Constant %f\n",
3531 *(float *)(&data[5]));
3532 instr_out(ctx, 6, "Global Depth Offset Scale %f\n",
3533 *(float *)(&data[6]));
3534 instr_out(ctx, 7, "Global Depth Offset Clamp %f\n",
3535 *(float *)(&data[7]));
3537 for (i = 0, j = 0; i < 8; i++, j += 2)
3538 instr_out(ctx, i + 8,
3539 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3540 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3542 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3543 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3544 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3545 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3546 (data[8 + i] >> 25) & 3,
3547 (data[8 + i] >> 22) & 3,
3548 (data[8 + i] >> 16) & 0x1f, j,
3549 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3550 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3551 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3552 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3553 (data[8 + i] >> 9) & 3,
3554 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3556 "Point Sprite TexCoord Enable\n");
3557 instr_out(ctx, 17, "Const Interp Enable\n");
3559 "Attrib 7-0 WrapShortest Enable\n");
3561 "Attrib 15-8 WrapShortest Enable\n");
3566 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3567 instr_out(ctx, 1, "top left: %d,%d\n",
3568 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3569 instr_out(ctx, 2, "bottom right: %d,%d\n",
3570 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3571 instr_out(ctx, 3, "origin: %d,%d\n",
3572 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3577 instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n");
3578 if (IS_GEN5(devid) || IS_GEN6(devid))
3580 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3581 get_965_surfacetype(data[1] >> 29),
3582 get_965_depthformat((data[1] >> 18) & 0x7),
3583 (data[1] & 0x0001ffff) + 1,
3584 data[1] & (1 << 27) ? "" : "not ",
3585 (data[1] & (1 << 22)) != 0,
3586 (data[1] & (1 << 21)) != 0);
3589 "%s, %s, pitch = %d bytes, %stiled\n",
3590 get_965_surfacetype(data[1] >> 29),
3591 get_965_depthformat((data[1] >> 18) & 0x7),
3592 (data[1] & 0x0001ffff) + 1,
3593 data[1] & (1 << 27) ? "" : "not ");
3594 instr_out(ctx, 2, "depth offset\n");
3595 instr_out(ctx, 3, "%dx%d\n",
3596 ((data[3] & 0x0007ffc0) >> 6) + 1,
3597 ((data[3] & 0xfff80000) >> 19) + 1);
3598 instr_out(ctx, 4, "volume depth\n");
3600 instr_out(ctx, 5, "\n");
3603 instr_out(ctx, 6, "\n");
3606 "render target view extent\n");
3612 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3614 if (len != 4 && len != 5)
3615 fprintf(out, "Bad count in PIPE_CONTROL\n");
3617 switch ((data[1] >> 14) & 0x3) {
3622 desc1 = "qword write";
3625 desc1 = "PS_DEPTH_COUNT write";
3628 desc1 = "TIMESTAMP write";
3631 instr_out(ctx, 0, "PIPE_CONTROL\n");
3633 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3635 data[1] & (1 << 20) ? "cs stall, " : "",
3636 data[1] & (1 << 19) ?
3637 "global snapshot count reset, " : "",
3638 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3639 data[1] & (1 << 17) ? "gfdt flush, " : "",
3640 data[1] & (1 << 17) ? "media state clear, " :
3642 data[1] & (1 << 13) ? "depth stall, " : "",
3643 data[1] & (1 << 12) ?
3644 "render target cache flush, " : "",
3645 data[1] & (1 << 11) ?
3646 "instruction cache invalidate, " : "",
3647 data[1] & (1 << 10) ?
3648 "texture cache invalidate, " : "",
3649 data[1] & (1 << 9) ?
3650 "indirect state invalidate, " : "",
3651 data[1] & (1 << 8) ? "notify irq, " : "",
3652 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3654 data[1] & (1 << 6) ? "protect mem app_id, " :
3655 "", data[1] & (1 << 5) ? "DC flush, " : "",
3656 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3658 data[1] & (1 << 3) ?
3659 "constant cache invalidate, " : "",
3660 data[1] & (1 << 2) ?
3661 "state cache invalidate, " : "",
3662 data[1] & (1 << 1) ? "stall at scoreboard, " :
3664 data[1] & (1 << 0) ? "depth cache flush, " :
3668 "destination address\n");
3670 "immediate dword low\n");
3672 "immediate dword high\n");
3674 for (i = 2; i < len; i++) {
3675 instr_out(ctx, i, "\n");
3681 fprintf(out, "Bad count in PIPE_CONTROL\n");
3683 switch ((data[0] >> 14) & 0x3) {
3688 desc1 = "qword write";
3691 desc1 = "PS_DEPTH_COUNT write";
3694 desc1 = "TIMESTAMP write";
3698 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3701 data[0] & (1 << 13) ? "" : "no ",
3702 data[0] & (1 << 12) ? "" : "no ",
3703 data[0] & (1 << 11) ? "" : "no ");
3704 instr_out(ctx, 1, "destination address\n");
3705 instr_out(ctx, 2, "immediate dword low\n");
3706 instr_out(ctx, 3, "immediate dword high\n");
3712 if (opcode_3d->func) {
3713 return opcode_3d->func(ctx);
3717 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3719 for (i = 1; i < len; i++) {
3720 instr_out(ctx, i, "dword %d\n", i);
3726 instr_out(ctx, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3732 decode_3d_i830(struct drm_intel_decode *ctx)
3736 uint32_t *data = ctx->data;
3740 unsigned int min_len;
3741 unsigned int max_len;
3744 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3745 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3746 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3747 { 0x05, 1, 1, "3DSTATE_VFT0" },
3748 { 0x06, 1, 1, "3DSTATE_AA" },
3749 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3750 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3751 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3752 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3753 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3754 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3755 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3756 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3757 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3758 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3759 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3762 opcode = (data[0] & 0x1f000000) >> 24;
3766 return decode_3d_primitive(ctx);
3768 return decode_3d_1d(ctx);
3770 return decode_3d_1c(ctx);
3773 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3774 opcode_3d = &opcodes_3d[idx];
3775 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3776 unsigned int len = 1, i;
3778 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3779 if (opcode_3d->max_len > 1) {
3780 len = (data[0] & 0xff) + 2;
3781 if (len < opcode_3d->min_len ||
3782 len > opcode_3d->max_len) {
3783 fprintf(out, "Bad count in %s\n",
3788 for (i = 1; i < len; i++) {
3789 instr_out(ctx, i, "dword %d\n", i);
3795 instr_out(ctx, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3800 struct drm_intel_decode *
3801 drm_intel_decode_context_alloc(uint32_t devid)
3803 struct drm_intel_decode *ctx;
3805 ctx = calloc(1, sizeof(struct drm_intel_decode));
3814 else if (IS_GEN6(devid))
3816 else if (IS_GEN5(devid))
3818 else if (IS_GEN4(devid))
3820 else if (IS_9XX(devid))
3823 assert(IS_GEN2(devid));
3831 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3837 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3840 ctx->dump_past_end = !!dump_past_end;
3844 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3845 void *data, uint32_t hw_offset, int count)
3847 ctx->base_data = data;
3848 ctx->base_hw_offset = hw_offset;
3849 ctx->base_count = count;
3853 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3854 uint32_t head, uint32_t tail)
3861 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3868 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3870 * \param data batch buffer contents
3871 * \param count number of DWORDs to decode in the batch buffer
3872 * \param hw_offset hardware address for the buffer
3875 drm_intel_decode(struct drm_intel_decode *ctx)
3878 unsigned int index = 0;
3880 int size = ctx->base_count * 4;
3886 /* Put a scratch page full of obviously undefined data after
3887 * the batchbuffer. This lets us avoid a bunch of length
3888 * checking in statically sized packets.
3890 temp = malloc(size + 4096);
3891 memcpy(temp, ctx->base_data, size);
3892 memset((char *)temp + size, 0xd0, 4096);
3895 ctx->hw_offset = ctx->base_hw_offset;
3896 ctx->count = ctx->base_count;
3899 head_offset = ctx->head;
3900 tail_offset = ctx->tail;
3906 while (ctx->count > 0) {
3909 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3911 ret = decode_mi(ctx);
3913 /* If MI_BATCHBUFFER_END happened, then dump
3914 * the rest of the output in case we some day
3915 * want it in debugging, but don't decode it
3916 * since it'll just confuse in the common
3920 if (ctx->dump_past_end) {
3923 for (index = index + 1; index < ctx->count;
3925 instr_out(ctx, index, "\n");
3932 index += decode_2d(ctx);
3935 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3938 } else if (IS_GEN3(devid)) {
3939 index += decode_3d(ctx);
3942 decode_3d_i830(ctx);
3946 instr_out(ctx, index, "UNKNOWN\n");
3952 if (ctx->count < index)
3955 ctx->count -= index;
3957 ctx->hw_offset += 4 * index;