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_SET_CONTEXT(struct drm_intel_decode *ctx)
144 uint32_t data = ctx->data[1];
148 instr_out(ctx, 0, "MI_SET_CONTEXT\n");
149 instr_out(ctx, 1, "gtt offset = 0x%x%s%s\n",
151 data & (1<<1)? ", Force Restore": "",
152 data & (1<<0)? ", Restore Inhibit": "");
158 decode_MI_WAIT_FOR_EVENT(struct drm_intel_decode *ctx)
162 uint32_t data = ctx->data[0];
169 switch ((data >> cc_shift) & 0x1f) {
171 cc_wait = ", cc wait 1";
174 cc_wait = ", cc wait 2";
177 cc_wait = ", cc wait 3";
180 cc_wait = ", cc wait 4";
183 cc_wait = ", cc wait 4";
191 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
192 data & (1<<18)? ", pipe B start vblank wait": "",
193 data & (1<<17)? ", pipe A start vblank wait": "",
194 data & (1<<16)? ", overlay flip pending wait": "",
195 data & (1<<14)? ", pipe B hblank wait": "",
196 data & (1<<13)? ", pipe A hblank wait": "",
198 data & (1<<8)? ", plane C pending flip wait": "",
199 data & (1<<7)? ", pipe B vblank wait": "",
200 data & (1<<6)? ", plane B pending flip wait": "",
201 data & (1<<5)? ", pipe B scan line wait": "",
202 data & (1<<4)? ", fbc idle wait": "",
203 data & (1<<3)? ", pipe A vblank wait": "",
204 data & (1<<2)? ", plane A pending flip wait": "",
205 data & (1<<1)? ", plane A scan line wait": "");
207 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s\n",
208 data & (1<<20)? ", sprite C pending flip wait": "", /* ivb */
210 data & (1<<13)? ", pipe B hblank wait": "",
211 data & (1<<11)? ", pipe B vblank wait": "",
212 data & (1<<10)? ", sprite B pending flip wait": "",
213 data & (1<<9)? ", plane B pending flip wait": "",
214 data & (1<<8)? ", plane B scan line wait": "",
215 data & (1<<5)? ", pipe A hblank wait": "",
216 data & (1<<3)? ", pipe A vblank wait": "",
217 data & (1<<2)? ", sprite A pending flip wait": "",
218 data & (1<<1)? ", plane A pending flip wait": "",
219 data & (1<<0)? ", plane A scan line wait": "");
226 decode_mi(struct drm_intel_decode *ctx)
228 unsigned int opcode, len = -1;
229 const char *post_sync_op = "";
230 uint32_t *data = ctx->data;
235 unsigned int min_len;
236 unsigned int max_len;
238 int (*func)(struct drm_intel_decode *ctx);
240 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
241 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
242 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
243 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
244 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
245 { 0x04, 0, 1, 1, "MI_FLUSH" },
246 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
247 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
248 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
249 { 0x00, 0, 1, 1, "MI_NOOP" },
250 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
251 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
252 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT", decode_MI_SET_CONTEXT },
253 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
254 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
255 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
256 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
257 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT", decode_MI_WAIT_FOR_EVENT },
258 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
259 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
260 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
261 }, *opcode_mi = NULL;
263 /* check instruction length */
264 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
266 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
268 if (opcodes_mi[opcode].max_len > 1) {
270 (data[0] & opcodes_mi[opcode].len_mask) + 2;
271 if (len < opcodes_mi[opcode].min_len
272 || len > opcodes_mi[opcode].max_len) {
274 "Bad length (%d) in %s, [%d, %d]\n",
275 len, opcodes_mi[opcode].name,
276 opcodes_mi[opcode].min_len,
277 opcodes_mi[opcode].max_len);
280 opcode_mi = &opcodes_mi[opcode];
285 if (opcode_mi && opcode_mi->func)
286 return opcode_mi->func(ctx);
288 switch ((data[0] & 0x1f800000) >> 23) {
290 instr_out(ctx, 0, "MI_BATCH_BUFFER_END\n");
293 instr_out(ctx, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
294 data[0] & (1 << 22) ? " global gtt," : "",
295 data[0] & (1 << 21) ? " update semaphore," : "",
296 data[0] & (1 << 20) ? " compare semaphore," : "",
297 data[0] & (1 << 18) ? " use compare reg" : "",
298 (data[0] & (0x3 << 16)) >> 16);
299 instr_out(ctx, 1, "value\n");
300 instr_out(ctx, 2, "address\n");
303 instr_out(ctx, 0, "MI_STORE_DATA_INDEX%s\n",
304 data[0] & (1 << 21) ? " use per-process HWS," : "");
305 instr_out(ctx, 1, "index\n");
306 instr_out(ctx, 2, "dword\n");
308 instr_out(ctx, 3, "upper dword\n");
311 if (data[0] & (1 << 22))
313 "MI_NOOP write NOPID reg, val=0x%x\n",
314 data[0] & ((1 << 22) - 1));
316 instr_out(ctx, 0, "MI_NOOP\n");
319 switch (data[0] & (0x3 << 14)) {
321 post_sync_op = "no write";
324 post_sync_op = "write data";
327 post_sync_op = "reserved";
330 post_sync_op = "write TIMESTAMP";
334 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
335 data[0] & (1 << 22) ?
336 " enable protected mem (BCS-only)," : "",
337 data[0] & (1 << 21) ? " store in hws," : "",
338 data[0] & (1 << 18) ? " invalidate tlb," : "",
339 data[0] & (1 << 17) ? " flush gfdt," : "",
341 data[0] & (1 << 8) ? " enable notify interrupt," : "",
343 " invalidate video state (BCS-only)," : "");
344 if (data[0] & (1 << 21))
345 instr_out(ctx, 1, "hws index\n");
347 instr_out(ctx, 1, "address\n");
348 instr_out(ctx, 2, "dword\n");
350 instr_out(ctx, 3, "upper dword\n");
354 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
356 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
359 instr_out(ctx, 0, "%s\n",
360 opcodes_mi[opcode].name);
361 for (i = 1; i < len; i++) {
362 instr_out(ctx, i, "dword %d\n", i);
369 instr_out(ctx, 0, "MI UNKNOWN\n");
374 decode_2d_br00(struct drm_intel_decode *ctx, const char *cmd)
377 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
379 (ctx->data[0] & (1 << 20)) ? "en" : "dis",
380 (ctx->data[0] & (1 << 21)) ? "en" : "dis",
381 (ctx->data[0] >> 15) & 1,
382 (ctx->data[0] >> 11) & 1);
386 decode_2d_br01(struct drm_intel_decode *ctx)
389 switch ((ctx->data[1] >> 24) & 0x3) {
405 "format %s, pitch %d, rop 0x%02x, "
406 "clipping %sabled, %s%s \n",
408 (short)(ctx->data[1] & 0xffff),
409 (ctx->data[1] >> 16) & 0xff,
410 ctx->data[1] & (1 << 30) ? "en" : "dis",
411 ctx->data[1] & (1 << 31) ? "solid pattern enabled, " : "",
412 ctx->data[1] & (1 << 31) ?
413 "mono pattern transparency enabled, " : "");
418 decode_2d(struct drm_intel_decode *ctx)
420 unsigned int opcode, len;
421 uint32_t *data = ctx->data;
425 unsigned int min_len;
426 unsigned int max_len;
429 { 0x40, 5, 5, "COLOR_BLT" },
430 { 0x43, 6, 6, "SRC_COPY_BLT" },
431 { 0x01, 8, 8, "XY_SETUP_BLT" },
432 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
433 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
434 { 0x24, 2, 2, "XY_PIXEL_BLT" },
435 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
436 { 0x26, 4, 4, "Y_TEXT_BLT" },
437 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
438 { 0x50, 6, 6, "XY_COLOR_BLT" },
439 { 0x51, 6, 6, "XY_PAT_BLT" },
440 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
441 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
442 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
443 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
444 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
445 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
446 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
447 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
448 { 0x55, 9, 9, "XY_FULL_BLT" },
449 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
450 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
451 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
452 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
453 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
456 switch ((data[0] & 0x1fc00000) >> 22) {
459 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
460 (data[0] >> 12) & 0x8,
461 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
463 len = (data[0] & 0x000000ff) + 2;
465 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
467 instr_out(ctx, 1, "dest (%d,%d)\n",
468 data[1] & 0xffff, data[1] >> 16);
469 instr_out(ctx, 2, "dest (%d,%d)\n",
470 data[2] & 0xffff, data[2] >> 16);
473 decode_2d_br00(ctx, "XY_SETUP_BLT");
475 len = (data[0] & 0x000000ff) + 2;
477 fprintf(out, "Bad count in XY_SETUP_BLT\n");
480 instr_out(ctx, 2, "cliprect (%d,%d)\n",
481 data[2] & 0xffff, data[2] >> 16);
482 instr_out(ctx, 3, "cliprect (%d,%d)\n",
483 data[3] & 0xffff, data[3] >> 16);
484 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
486 instr_out(ctx, 5, "setup background color\n");
487 instr_out(ctx, 6, "setup foreground color\n");
488 instr_out(ctx, 7, "color pattern offset\n");
491 decode_2d_br00(ctx, "XY_SETUP_CLIP_BLT");
493 len = (data[0] & 0x000000ff) + 2;
495 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
497 instr_out(ctx, 1, "cliprect (%d,%d)\n",
498 data[1] & 0xffff, data[2] >> 16);
499 instr_out(ctx, 2, "cliprect (%d,%d)\n",
500 data[2] & 0xffff, data[3] >> 16);
503 decode_2d_br00(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT");
505 len = (data[0] & 0x000000ff) + 2;
508 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
511 instr_out(ctx, 2, "cliprect (%d,%d)\n",
512 data[2] & 0xffff, data[2] >> 16);
513 instr_out(ctx, 3, "cliprect (%d,%d)\n",
514 data[3] & 0xffff, data[3] >> 16);
515 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
517 instr_out(ctx, 5, "setup background color\n");
518 instr_out(ctx, 6, "setup foreground color\n");
519 instr_out(ctx, 7, "mono pattern dw0\n");
520 instr_out(ctx, 8, "mono pattern dw1\n");
523 decode_2d_br00(ctx, "XY_COLOR_BLT");
525 len = (data[0] & 0x000000ff) + 2;
527 fprintf(out, "Bad count in XY_COLOR_BLT\n");
530 instr_out(ctx, 2, "(%d,%d)\n",
531 data[2] & 0xffff, data[2] >> 16);
532 instr_out(ctx, 3, "(%d,%d)\n",
533 data[3] & 0xffff, data[3] >> 16);
534 instr_out(ctx, 4, "offset 0x%08x\n", data[4]);
535 instr_out(ctx, 5, "color\n");
538 decode_2d_br00(ctx, "XY_SRC_COPY_BLT");
540 len = (data[0] & 0x000000ff) + 2;
542 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
545 instr_out(ctx, 2, "dst (%d,%d)\n",
546 data[2] & 0xffff, data[2] >> 16);
547 instr_out(ctx, 3, "dst (%d,%d)\n",
548 data[3] & 0xffff, data[3] >> 16);
549 instr_out(ctx, 4, "dst offset 0x%08x\n", data[4]);
550 instr_out(ctx, 5, "src (%d,%d)\n",
551 data[5] & 0xffff, data[5] >> 16);
552 instr_out(ctx, 6, "src pitch %d\n",
553 (short)(data[6] & 0xffff));
554 instr_out(ctx, 7, "src offset 0x%08x\n", data[7]);
558 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
560 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
564 instr_out(ctx, 0, "%s\n",
565 opcodes_2d[opcode].name);
566 if (opcodes_2d[opcode].max_len > 1) {
567 len = (data[0] & 0x000000ff) + 2;
568 if (len < opcodes_2d[opcode].min_len ||
569 len > opcodes_2d[opcode].max_len) {
570 fprintf(out, "Bad count in %s\n",
571 opcodes_2d[opcode].name);
575 for (i = 1; i < len; i++) {
576 instr_out(ctx, i, "dword %d\n", i);
583 instr_out(ctx, 0, "2D UNKNOWN\n");
588 decode_3d_1c(struct drm_intel_decode *ctx)
590 uint32_t *data = ctx->data;
593 opcode = (data[0] & 0x00f80000) >> 19;
598 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
601 instr_out(ctx, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
602 data[0] & 1 ? "enabled" : "disabled");
605 instr_out(ctx, 0, "3DSTATE_MAP_COORD_SET_I830\n");
608 instr_out(ctx, 0, "3DSTATE_MAP_CUBE_I830\n");
611 instr_out(ctx, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
615 instr_out(ctx, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
620 /** Sets the string dstname to describe the destination of the PS instruction */
622 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
624 uint32_t a0 = data[i];
625 int dst_nr = (a0 >> 14) & 0xf;
630 if (((a0 >> 10) & 0xf) == 0xf) {
633 int dstmask_index = 0;
635 dstmask[dstmask_index++] = '.';
637 dstmask[dstmask_index++] = 'x';
639 dstmask[dstmask_index++] = 'y';
641 dstmask[dstmask_index++] = 'z';
643 dstmask[dstmask_index++] = 'w';
644 dstmask[dstmask_index++] = 0;
656 switch ((a0 >> 19) & 0x7) {
659 fprintf(out, "bad destination reg R%d\n", dst_nr);
660 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
664 fprintf(out, "bad destination reg oC%d\n", dst_nr);
665 sprintf(dstname, "oC%s%s", dstmask, sat);
669 fprintf(out, "bad destination reg oD%d\n", dst_nr);
670 sprintf(dstname, "oD%s%s", dstmask, sat);
674 fprintf(out, "bad destination reg U%d\n", dst_nr);
675 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
678 sprintf(dstname, "RESERVED");
684 i915_get_channel_swizzle(uint32_t select)
686 switch (select & 0x7) {
688 return (select & 8) ? "-x" : "x";
690 return (select & 8) ? "-y" : "y";
692 return (select & 8) ? "-z" : "z";
694 return (select & 8) ? "-w" : "w";
696 return (select & 8) ? "-0" : "0";
698 return (select & 8) ? "-1" : "1";
700 return (select & 8) ? "-bad" : "bad";
705 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
709 sprintf(name, "R%d", src_nr);
711 fprintf(out, "bad src reg %s\n", name);
715 sprintf(name, "T%d", src_nr);
716 else if (src_nr == 8)
717 sprintf(name, "DIFFUSE");
718 else if (src_nr == 9)
719 sprintf(name, "SPECULAR");
720 else if (src_nr == 10)
721 sprintf(name, "FOG");
723 fprintf(out, "bad src reg T%d\n", src_nr);
724 sprintf(name, "RESERVED");
728 sprintf(name, "C%d", src_nr);
730 fprintf(out, "bad src reg %s\n", name);
735 fprintf(out, "bad src reg oC%d\n", src_nr);
740 fprintf(out, "bad src reg oD%d\n", src_nr);
743 sprintf(name, "U%d", src_nr);
745 fprintf(out, "bad src reg %s\n", name);
748 fprintf(out, "bad src reg type %d\n", src_type);
749 sprintf(name, "RESERVED");
754 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
756 uint32_t a0 = data[i];
757 uint32_t a1 = data[i + 1];
758 int src_nr = (a0 >> 2) & 0x1f;
759 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
760 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
761 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
762 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
765 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
766 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
768 if (strcmp(swizzle, ".xyzw") != 0)
769 strcat(srcname, swizzle);
772 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
774 uint32_t a1 = data[i + 1];
775 uint32_t a2 = data[i + 2];
776 int src_nr = (a1 >> 8) & 0x1f;
777 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
778 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
779 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
780 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
783 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
784 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
786 if (strcmp(swizzle, ".xyzw") != 0)
787 strcat(srcname, swizzle);
790 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
792 uint32_t a2 = data[i + 2];
793 int src_nr = (a2 >> 16) & 0x1f;
794 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
795 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
796 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
797 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
800 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
801 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
803 if (strcmp(swizzle, ".xyzw") != 0)
804 strcat(srcname, swizzle);
808 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
812 sprintf(name, "R%d", src_nr);
814 fprintf(out, "bad src reg %s\n", name);
818 sprintf(name, "T%d", src_nr);
819 else if (src_nr == 8)
820 sprintf(name, "DIFFUSE");
821 else if (src_nr == 9)
822 sprintf(name, "SPECULAR");
823 else if (src_nr == 10)
824 sprintf(name, "FOG");
826 fprintf(out, "bad src reg T%d\n", src_nr);
827 sprintf(name, "RESERVED");
833 fprintf(out, "bad src reg oC%d\n", src_nr);
838 fprintf(out, "bad src reg oD%d\n", src_nr);
841 fprintf(out, "bad src reg type %d\n", src_type);
842 sprintf(name, "RESERVED");
848 i915_decode_alu1(struct drm_intel_decode *ctx,
849 int i, char *instr_prefix, const char *op_name)
851 char dst[100], src0[100];
853 i915_get_instruction_dst(ctx->data, i, dst, 1);
854 i915_get_instruction_src0(ctx->data, i, src0);
856 instr_out(ctx, i++, "%s: %s %s, %s\n", instr_prefix,
858 instr_out(ctx, i++, "%s\n", instr_prefix);
859 instr_out(ctx, i++, "%s\n", instr_prefix);
863 i915_decode_alu2(struct drm_intel_decode *ctx,
864 int i, char *instr_prefix, const char *op_name)
866 char dst[100], src0[100], src1[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);
872 instr_out(ctx, i++, "%s: %s %s, %s, %s\n", instr_prefix,
873 op_name, dst, src0, src1);
874 instr_out(ctx, i++, "%s\n", instr_prefix);
875 instr_out(ctx, i++, "%s\n", instr_prefix);
879 i915_decode_alu3(struct drm_intel_decode *ctx,
880 int i, char *instr_prefix, const char *op_name)
882 char dst[100], src0[100], src1[100], src2[100];
884 i915_get_instruction_dst(ctx->data, i, dst, 1);
885 i915_get_instruction_src0(ctx->data, i, src0);
886 i915_get_instruction_src1(ctx->data, i, src1);
887 i915_get_instruction_src2(ctx->data, i, src2);
889 instr_out(ctx, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
890 op_name, dst, src0, src1, src2);
891 instr_out(ctx, i++, "%s\n", instr_prefix);
892 instr_out(ctx, i++, "%s\n", instr_prefix);
896 i915_decode_tex(struct drm_intel_decode *ctx, int i,
897 const char *instr_prefix, const char *tex_name)
899 uint32_t t0 = ctx->data[i];
900 uint32_t t1 = ctx->data[i + 1];
905 i915_get_instruction_dst(ctx->data, i, dst_name, 0);
906 i915_get_instruction_addr((t1 >> 24) & 0x7,
907 (t1 >> 17) & 0xf, addr_name);
908 sampler_nr = t0 & 0xf;
910 instr_out(ctx, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
911 tex_name, dst_name, sampler_nr, addr_name);
912 instr_out(ctx, i++, "%s\n", instr_prefix);
913 instr_out(ctx, i++, "%s\n", instr_prefix);
917 i915_decode_dcl(struct drm_intel_decode *ctx, int i, char *instr_prefix)
919 uint32_t d0 = ctx->data[i];
920 const char *sampletype;
921 int dcl_nr = (d0 >> 14) & 0xf;
922 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
923 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
924 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
925 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
928 switch ((d0 >> 19) & 0x3) {
930 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
931 if (strcmp(dcl_mask, ".") == 0)
932 fprintf(out, "bad (empty) dcl mask\n");
935 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
937 if (strcmp(dcl_mask, ".x") != 0 &&
938 strcmp(dcl_mask, ".xy") != 0 &&
939 strcmp(dcl_mask, ".xz") != 0 &&
940 strcmp(dcl_mask, ".w") != 0 &&
941 strcmp(dcl_mask, ".xyzw") != 0) {
942 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
945 instr_out(ctx, i++, "%s: DCL T%d%s\n",
946 instr_prefix, dcl_nr, dcl_mask);
948 if (strcmp(dcl_mask, ".xz") == 0)
949 fprintf(out, "errataed bad dcl mask %s\n",
951 else if (strcmp(dcl_mask, ".xw") == 0)
952 fprintf(out, "errataed bad dcl mask %s\n",
954 else if (strcmp(dcl_mask, ".xzw") == 0)
955 fprintf(out, "errataed bad dcl mask %s\n",
960 "%s: DCL DIFFUSE%s\n", instr_prefix,
962 } else if (dcl_nr == 9) {
964 "%s: DCL SPECULAR%s\n", instr_prefix,
966 } else if (dcl_nr == 10) {
968 "%s: DCL FOG%s\n", instr_prefix,
972 instr_out(ctx, i++, "%s\n", instr_prefix);
973 instr_out(ctx, i++, "%s\n", instr_prefix);
976 switch ((d0 >> 22) & 0x3) {
987 sampletype = "RESERVED";
991 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
992 instr_out(ctx, i++, "%s: DCL S%d %s\n",
993 instr_prefix, dcl_nr, sampletype);
994 instr_out(ctx, i++, "%s\n", instr_prefix);
995 instr_out(ctx, i++, "%s\n", instr_prefix);
998 instr_out(ctx, i++, "%s: DCL RESERVED%d\n",
999 instr_prefix, dcl_nr);
1000 instr_out(ctx, i++, "%s\n", instr_prefix);
1001 instr_out(ctx, i++, "%s\n", instr_prefix);
1006 i915_decode_instruction(struct drm_intel_decode *ctx,
1007 int i, char *instr_prefix)
1009 switch ((ctx->data[i] >> 24) & 0x1f) {
1011 instr_out(ctx, i++, "%s: NOP\n", instr_prefix);
1012 instr_out(ctx, i++, "%s\n", instr_prefix);
1013 instr_out(ctx, i++, "%s\n", instr_prefix);
1016 i915_decode_alu2(ctx, i, instr_prefix, "ADD");
1019 i915_decode_alu1(ctx, i, instr_prefix, "MOV");
1022 i915_decode_alu2(ctx, i, instr_prefix, "MUL");
1025 i915_decode_alu3(ctx, i, instr_prefix, "MAD");
1028 i915_decode_alu3(ctx, i, instr_prefix, "DP2ADD");
1031 i915_decode_alu2(ctx, i, instr_prefix, "DP3");
1034 i915_decode_alu2(ctx, i, instr_prefix, "DP4");
1037 i915_decode_alu1(ctx, i, instr_prefix, "FRC");
1040 i915_decode_alu1(ctx, i, instr_prefix, "RCP");
1043 i915_decode_alu1(ctx, i, instr_prefix, "RSQ");
1046 i915_decode_alu1(ctx, i, instr_prefix, "EXP");
1049 i915_decode_alu1(ctx, i, instr_prefix, "LOG");
1052 i915_decode_alu2(ctx, i, instr_prefix, "CMP");
1055 i915_decode_alu2(ctx, i, instr_prefix, "MIN");
1058 i915_decode_alu2(ctx, i, instr_prefix, "MAX");
1061 i915_decode_alu1(ctx, i, instr_prefix, "FLR");
1064 i915_decode_alu1(ctx, i, instr_prefix, "MOD");
1067 i915_decode_alu1(ctx, i, instr_prefix, "TRC");
1070 i915_decode_alu2(ctx, i, instr_prefix, "SGE");
1073 i915_decode_alu2(ctx, i, instr_prefix, "SLT");
1076 i915_decode_tex(ctx, i, instr_prefix, "TEXLD");
1079 i915_decode_tex(ctx, i, instr_prefix, "TEXLDP");
1082 i915_decode_tex(ctx, i, instr_prefix, "TEXLDB");
1085 i915_decode_dcl(ctx, i, instr_prefix);
1088 instr_out(ctx, i++, "%s: unknown\n", instr_prefix);
1089 instr_out(ctx, i++, "%s\n", instr_prefix);
1090 instr_out(ctx, i++, "%s\n", instr_prefix);
1096 decode_compare_func(uint32_t op)
1120 decode_stencil_op(uint32_t op)
1145 decode_logic_op(uint32_t op)
1186 decode_blend_fact(uint32_t op)
1196 return "inv_src_colr";
1200 return "inv_src_alpha";
1204 return "inv_dst_alpha";
1208 return "inv_dst_colr";
1210 return "src_alpha_sat";
1214 return "inv_cnst_colr";
1216 return "cnst_alpha";
1218 return "inv_const_alpha";
1224 decode_tex_coord_mode(uint32_t mode)
1226 switch (mode & 0x7) {
1232 return "clamp_edge";
1236 return "clamp_border";
1238 return "mirror_once";
1244 decode_sample_filter(uint32_t mode)
1246 switch (mode & 0x7) {
1252 return "anisotropic";
1266 decode_3d_1d(struct drm_intel_decode *ctx)
1268 unsigned int len, i, c, idx, word, map, sampler, instr;
1269 const char *format, *zformat, *type;
1271 uint32_t *data = ctx->data;
1272 uint32_t devid = ctx->devid;
1277 unsigned int min_len;
1278 unsigned int max_len;
1280 } opcodes_3d_1d[] = {
1281 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1282 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1283 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1284 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1285 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1286 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1287 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1288 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1289 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1290 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1291 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1292 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1293 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1294 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1295 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1296 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1299 opcode = (data[0] & 0x00ff0000) >> 16;
1303 /* This instruction is unusual. A 0 length means just
1304 * 1 DWORD instead of 2. The 0 length is specified in
1305 * one place to be unsupported, but stated to be
1306 * required in another, and 0 length LOAD_INDIRECTs
1307 * appear to cause no harm at least.
1309 instr_out(ctx, 0, "3DSTATE_LOAD_INDIRECT\n");
1310 len = (data[0] & 0x000000ff) + 1;
1312 if (data[0] & (0x01 << 8)) {
1313 instr_out(ctx, i++, "SIS.0\n");
1314 instr_out(ctx, i++, "SIS.1\n");
1316 if (data[0] & (0x02 << 8)) {
1317 instr_out(ctx, i++, "DIS.0\n");
1319 if (data[0] & (0x04 << 8)) {
1320 instr_out(ctx, i++, "SSB.0\n");
1321 instr_out(ctx, i++, "SSB.1\n");
1323 if (data[0] & (0x08 << 8)) {
1324 instr_out(ctx, i++, "MSB.0\n");
1325 instr_out(ctx, i++, "MSB.1\n");
1327 if (data[0] & (0x10 << 8)) {
1328 instr_out(ctx, i++, "PSP.0\n");
1329 instr_out(ctx, i++, "PSP.1\n");
1331 if (data[0] & (0x20 << 8)) {
1332 instr_out(ctx, i++, "PSC.0\n");
1333 instr_out(ctx, i++, "PSC.1\n");
1336 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1342 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1343 len = (data[0] & 0x0000000f) + 2;
1345 for (word = 0; word <= 8; word++) {
1346 if (data[0] & (1 << (4 + word))) {
1347 /* save vertex state for decode */
1348 if (!IS_GEN2(devid)) {
1363 "S0: vbo offset: 0x%08x%s\n",
1366 ", auto cache invalidate disabled"
1371 "S1: vertex width: %i, vertex pitch: %i\n",
1379 "S2: texcoord formats: ");
1381 tex_num < 8; tex_num++) {
1427 "S3: not documented\n");
1431 const char *cullmode = "";
1432 const char *vfmt_xyzw = "";
1433 switch ((data[i] >> 13)
1470 case 1 << 6 | 1 << 2:
1474 case 2 << 6 | 1 << 2:
1478 case 3 << 6 | 1 << 2:
1482 case 4 << 6 | 1 << 2:
1488 "S4: point_width=%i, line_width=%.1f,"
1489 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1552 "force default diffuse, "
1558 "force default specular, "
1564 "local depth ofs enable, "
1570 "point sprite enable, "
1584 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1585 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1586 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1616 " force default point size,"
1622 " last pixel enable,"
1628 " global depth ofs enable,"
1654 "stencil write enable, "
1660 "stencil test enable, "
1666 "color dither enable, "
1678 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1679 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1680 "%s%stristrip_provoking_vertex=%i\n",
1681 data[i] & (1 << 31) ?
1682 "alpha test enable, "
1690 data[i] & (1 << 15) ?
1691 "cbuf blend enable, "
1693 decode_blend_fact(data
1697 decode_blend_fact(data
1701 data[i] & (1 << 3) ?
1702 "depth write enable, "
1704 data[i] & (1 << 2) ?
1705 "cbuf write enable, "
1711 "S7: depth offset constant: 0x%08x\n",
1717 "S%d: 0x%08x\n", i, data[i]);
1724 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1729 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1730 len = (data[0] & 0x0000000f) + 2;
1732 for (word = 6; word <= 14; word++) {
1733 if (data[0] & (1 << word)) {
1737 else if (word >= 7 && word <= 10) {
1739 "TB%dC\n", word - 7);
1741 "TB%dA\n", word - 7);
1742 } else if (word >= 11 && word <= 14) {
1744 "TM%dS0: offset=0x%08x, %s\n",
1746 data[i] & 0xfffffffe,
1747 data[i] & 1 ? "use fence" :
1751 "TM%dS1: height=%i, width=%i, %s\n",
1752 word - 11, data[i] >> 21,
1753 (data[i] >> 10) & 0x3ff,
1754 data[i] & 2 ? (data[i] & 1 ?
1760 "TM%dS2: pitch=%i, \n",
1762 ((data[i] >> 21) + 1) * 4);
1765 "TM%dS3\n", word - 11);
1767 "TM%dS4: dflt color\n",
1774 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1778 instr_out(ctx, 0, "3DSTATE_MAP_STATE\n");
1779 len = (data[0] & 0x0000003f) + 2;
1780 instr_out(ctx, 1, "mask\n");
1783 for (map = 0; map <= 15; map++) {
1784 if (data[1] & (1 << map)) {
1785 int width, height, pitch, dword;
1790 "map %d MS2 %s%s%s\n", map,
1792 "untrusted surface, " : "",
1794 "vertical line stride enable, " : "",
1796 "vertical ofs enable, " : "");
1799 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1800 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1803 if (dword & (1 << 2))
1805 else if (dword & (1 << 1))
1806 tiling = dword & (1 << 0) ? "Y" : "X";
1809 switch ((dword >> 7) & 0x7) {
1812 switch ((dword >> 3) & 0xf) {
1829 switch ((dword >> 3) & 0xf) {
1834 format = " argb1555";
1837 format = " argb4444";
1843 format = " bump655";
1858 switch ((dword >> 3) & 0xf) {
1860 format = " argb8888";
1863 format = " abgr8888";
1866 format = " xrgb8888";
1869 format = " xbgr8888";
1872 format = " qwvu8888";
1875 format = " axvu8888";
1878 format = " lxvu8888";
1881 format = " xlvu8888";
1884 format = " argb2101010";
1887 format = " abgr2101010";
1890 format = " awvu2101010";
1911 switch ((dword >> 3) & 0xf) {
1913 format = " yuv_swapy";
1919 format = " yuv_swapuv";
1922 format = " yuv_swapuvy";
1927 type = "compressed";
1928 switch ((dword >> 3) & 0x7) {
1942 format = " dxt1_rb";
1947 type = "4b indexed";
1948 switch ((dword >> 3) & 0xf) {
1950 format = " argb8888";
1957 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1958 map, width, height, type, format,
1960 dword & (1 << 9) ? " palette select" :
1965 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1967 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1968 map, pitch, (dword >> 9) & 0x3f,
1969 dword & 0xff, (dword >> 15) & 0x3f,
1970 dword & (1 << 8) ? "miplayout legacy"
1971 : "miplayout right");
1975 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1981 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1982 len = (data[0] & 0x000000ff) + 2;
1985 for (c = 0; c <= 31; c++) {
1986 if (data[1] & (1 << c)) {
1987 instr_out(ctx, i, "C%d.X = %f\n", c,
1988 int_as_float(data[i]));
1990 instr_out(ctx, i, "C%d.Y = %f\n",
1991 c, int_as_float(data[i]));
1993 instr_out(ctx, i, "C%d.Z = %f\n",
1994 c, int_as_float(data[i]));
1996 instr_out(ctx, i, "C%d.W = %f\n",
1997 c, int_as_float(data[i]));
2003 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
2007 instr_out(ctx, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
2008 len = (data[0] & 0x000000ff) + 2;
2009 if ((len - 1) % 3 != 0 || len > 370) {
2011 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
2014 for (instr = 0; instr < (len - 1) / 3; instr++) {
2015 char instr_prefix[10];
2017 sprintf(instr_prefix, "PS%03d", instr);
2018 i915_decode_instruction(ctx, i,
2026 instr_out(ctx, 0, "3DSTATE_SAMPLER_STATE\n");
2027 instr_out(ctx, 1, "mask\n");
2028 len = (data[0] & 0x0000003f) + 2;
2030 for (sampler = 0; sampler <= 15; sampler++) {
2031 if (data[1] & (1 << sampler)) {
2033 const char *mip_filter = "";
2036 switch ((dword >> 20) & 0x3) {
2038 mip_filter = "none";
2041 mip_filter = "nearest";
2044 mip_filter = "linear";
2048 "sampler %d SS2:%s%s%s "
2049 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
2050 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
2052 dword & (1 << 31) ? " reverse gamma,"
2054 dword & (1 << 30) ? " packed2planar,"
2057 " colorspace conversion," : "",
2058 (dword >> 22) & 0x1f, mip_filter,
2059 decode_sample_filter(dword >> 17),
2060 decode_sample_filter(dword >> 14),
2061 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2062 dword & (1 << 4) ? " shadow," : "",
2063 dword & (1 << 3) ? 4 : 2,
2064 decode_compare_func(dword));
2067 "sampler %d SS3: min_lod=%.2f,%s "
2068 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2070 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2072 " kill pixel enable," : "",
2073 decode_tex_coord_mode(dword >> 12),
2074 decode_tex_coord_mode(dword >> 9),
2075 decode_tex_coord_mode(dword >> 6),
2077 " normalized coords," : "",
2079 dword & (1 << 0) ? " deinterlacer," :
2083 "sampler %d SS4: border color\n",
2088 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2092 len = (data[0] & 0x0000000f) + 2;
2096 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2099 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2101 switch ((data[1] >> 8) & 0xf) {
2106 format = "x1r5g5b5";
2112 format = "a8r8g8b8";
2115 format = "ycrcb_swapy";
2118 format = "ycrcb_normal";
2121 format = "ycrcb_swapuv";
2124 format = "ycrcb_swapuvy";
2127 format = "a4r4g4b4";
2130 format = "a1r5g5b5";
2133 format = "a2r10g10b10";
2139 switch ((data[1] >> 2) & 0x3) {
2154 "%s format, %s depth format, early Z %sabled\n",
2156 (data[1] & (1 << 31)) ? "en" : "dis");
2161 const char *name, *tiling;
2163 len = (data[0] & 0x0000000f) + 2;
2166 "Bad count in 3DSTATE_BUFFER_INFO\n");
2168 switch ((data[1] >> 24) & 0x7) {
2181 if (data[1] & (1 << 23))
2183 else if (data[1] & (1 << 22))
2184 tiling = data[1] & (1 << 21) ? "Y" : "X";
2186 instr_out(ctx, 0, "3DSTATE_BUFFER_INFO\n");
2188 "%s, tiling = %s, pitch=%d\n", name, tiling,
2191 instr_out(ctx, 2, "address\n");
2195 len = (data[0] & 0x0000000f) + 2;
2199 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2201 instr_out(ctx, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2202 instr_out(ctx, 1, "(%d,%d)\n",
2203 data[1] & 0xffff, data[1] >> 16);
2204 instr_out(ctx, 2, "(%d,%d)\n",
2205 data[2] & 0xffff, data[2] >> 16);
2209 len = (data[0] & 0x0000000f) + 2;
2213 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2215 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2216 instr_out(ctx, 1, "%s\n",
2217 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2218 instr_out(ctx, 2, "(%d,%d)\n",
2219 data[2] & 0xffff, data[2] >> 16);
2220 instr_out(ctx, 3, "(%d,%d)\n",
2221 data[3] & 0xffff, data[3] >> 16);
2222 instr_out(ctx, 4, "(%d,%d)\n",
2223 data[4] & 0xffff, data[4] >> 16);
2227 len = (data[0] & 0x0000000f) + 2;
2230 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2232 instr_out(ctx, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2233 instr_out(ctx, 1, "prim_type=%s, clear=%s%s%s\n",
2234 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2235 data[1] & (1 << 2) ? "color," : "",
2236 data[1] & (1 << 1) ? "depth," : "",
2237 data[1] & (1 << 0) ? "stencil," : "");
2238 instr_out(ctx, 2, "clear color\n");
2239 instr_out(ctx, 3, "clear depth/stencil\n");
2240 instr_out(ctx, 4, "color value (rgba8888)\n");
2241 instr_out(ctx, 5, "depth value %f\n",
2242 int_as_float(data[5]));
2243 instr_out(ctx, 6, "clear stencil\n");
2247 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2248 opcode_3d_1d = &opcodes_3d_1d[idx];
2249 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2252 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2255 instr_out(ctx, 0, "%s\n",
2256 opcode_3d_1d->name);
2257 if (opcode_3d_1d->max_len > 1) {
2258 len = (data[0] & 0x0000ffff) + 2;
2259 if (len < opcode_3d_1d->min_len ||
2260 len > opcode_3d_1d->max_len) {
2261 fprintf(out, "Bad count in %s\n",
2262 opcode_3d_1d->name);
2266 for (i = 1; i < len; i++) {
2267 instr_out(ctx, i, "dword %d\n", i);
2274 instr_out(ctx, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2280 decode_3d_primitive(struct drm_intel_decode *ctx)
2282 uint32_t *data = ctx->data;
2283 uint32_t count = ctx->count;
2284 char immediate = (data[0] & (1 << 23)) == 0;
2285 unsigned int len, i, j, ret;
2286 const char *primtype;
2287 int original_s2 = saved_s2;
2288 int original_s4 = saved_s4;
2290 switch ((data[0] >> 18) & 0xf) {
2292 primtype = "TRILIST";
2295 primtype = "TRISTRIP";
2298 primtype = "TRISTRIP_REVERSE";
2301 primtype = "TRIFAN";
2304 primtype = "POLYGON";
2307 primtype = "LINELIST";
2310 primtype = "LINESTRIP";
2313 primtype = "RECTLIST";
2316 primtype = "POINTLIST";
2322 primtype = "CLEAR_RECT";
2327 primtype = "unknown";
2331 /* XXX: 3DPRIM_DIB not supported */
2333 len = (data[0] & 0x0003ffff) + 2;
2334 instr_out(ctx, 0, "3DPRIMITIVE inline %s\n",
2337 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2338 if (!saved_s2_set || !saved_s4_set) {
2339 fprintf(out, "unknown vertex format\n");
2340 for (i = 1; i < len; i++) {
2342 " vertex data (%f float)\n",
2343 int_as_float(data[i]));
2346 unsigned int vertex = 0;
2347 for (i = 1; i < len;) {
2350 #define VERTEX_OUT(fmt, ...) do { \
2352 instr_out(ctx, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2354 fprintf(out, " missing data in V%d\n", vertex); \
2358 VERTEX_OUT("X = %f", int_as_float(data[i]));
2359 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2360 switch (saved_s4 >> 6 & 0x7) {
2362 VERTEX_OUT("Z = %f",
2363 int_as_float(data[i]));
2366 VERTEX_OUT("Z = %f",
2367 int_as_float(data[i]));
2368 VERTEX_OUT("W = %f",
2369 int_as_float(data[i]));
2374 VERTEX_OUT("W = %f",
2375 int_as_float(data[i]));
2378 fprintf(out, "bad S4 position mask\n");
2381 if (saved_s4 & (1 << 10)) {
2383 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2384 "B=0x%02x)", data[i] >> 24,
2385 (data[i] >> 16) & 0xff,
2386 (data[i] >> 8) & 0xff,
2389 if (saved_s4 & (1 << 11)) {
2391 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2392 "B=0x%02x)", data[i] >> 24,
2393 (data[i] >> 16) & 0xff,
2394 (data[i] >> 8) & 0xff,
2397 if (saved_s4 & (1 << 12))
2398 VERTEX_OUT("width = 0x%08x)", data[i]);
2400 for (tc = 0; tc <= 7; tc++) {
2401 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2403 VERTEX_OUT("T%d.X = %f", tc,
2406 VERTEX_OUT("T%d.Y = %f", tc,
2411 VERTEX_OUT("T%d.X = %f", tc,
2414 VERTEX_OUT("T%d.Y = %f", tc,
2417 VERTEX_OUT("T%d.Z = %f", tc,
2422 VERTEX_OUT("T%d.X = %f", tc,
2425 VERTEX_OUT("T%d.Y = %f", tc,
2428 VERTEX_OUT("T%d.Z = %f", tc,
2431 VERTEX_OUT("T%d.W = %f", tc,
2436 VERTEX_OUT("T%d.X = %f", tc,
2442 ("T%d.XY = 0x%08x half-float",
2447 ("T%d.XY = 0x%08x half-float",
2450 ("T%d.ZW = 0x%08x half-float",
2457 "bad S2.T%d format\n",
2467 /* indirect vertices */
2468 len = data[0] & 0x0000ffff; /* index count */
2469 if (data[0] & (1 << 17)) {
2470 /* random vertex access */
2471 if (count < (len + 1) / 2 + 1) {
2472 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2473 "3DPRIMITIVE random indirect");
2476 "3DPRIMITIVE random indirect %s (%d)\n",
2479 /* vertex indices continue until 0xffff is
2482 for (i = 1; i < count; i++) {
2483 if ((data[i] & 0xffff) == 0xffff) {
2485 " indices: (terminator)\n");
2488 } else if ((data[i] >> 16) == 0xffff) {
2490 " indices: 0x%04x, (terminator)\n",
2496 " indices: 0x%04x, 0x%04x\n",
2502 "3DPRIMITIVE: no terminator found in index buffer\n");
2506 /* fixed size vertex index buffer */
2507 for (j = 1, i = 0; i < len; i += 2, j++) {
2508 if (i * 2 == len - 1) {
2510 " indices: 0x%04x\n",
2514 " indices: 0x%04x, 0x%04x\n",
2520 ret = (len + 1) / 2 + 1;
2523 /* sequential vertex access */
2525 "3DPRIMITIVE sequential indirect %s, %d starting from "
2526 "%d\n", primtype, len, data[1] & 0xffff);
2527 instr_out(ctx, 1, " start\n");
2534 saved_s2 = original_s2;
2535 saved_s4 = original_s4;
2540 decode_3d(struct drm_intel_decode *ctx)
2544 uint32_t *data = ctx->data;
2548 unsigned int min_len;
2549 unsigned int max_len;
2552 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2553 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2554 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2555 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2556 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2557 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2558 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2559 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2560 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2563 opcode = (data[0] & 0x1f000000) >> 24;
2567 return decode_3d_primitive(ctx);
2569 return decode_3d_1d(ctx);
2571 return decode_3d_1c(ctx);
2574 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2575 opcode_3d = &opcodes_3d[idx];
2576 if (opcode == opcode_3d->opcode) {
2577 unsigned int len = 1, i;
2579 instr_out(ctx, 0, "%s\n", opcode_3d->name);
2580 if (opcode_3d->max_len > 1) {
2581 len = (data[0] & 0xff) + 2;
2582 if (len < opcode_3d->min_len ||
2583 len > opcode_3d->max_len) {
2584 fprintf(out, "Bad count in %s\n",
2589 for (i = 1; i < len; i++) {
2590 instr_out(ctx, i, "dword %d\n", i);
2596 instr_out(ctx, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2600 static const char *get_965_surfacetype(unsigned int surfacetype)
2602 switch (surfacetype) {
2620 static const char *get_965_depthformat(unsigned int depthformat)
2622 switch (depthformat) {
2624 return "s8_z24float";
2636 static const char *get_965_element_component(uint32_t data, int component)
2638 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2640 switch (component_control) {
2644 switch (component) {
2669 static const char *get_965_prim_type(uint32_t primtype)
2673 return "point list";
2677 return "line strip";
2687 return "quad strip";
2689 return "line list adj";
2691 return "line strip adj";
2693 return "tri list adj";
2695 return "tri strip adj";
2697 return "tri strip reverse";
2705 return "point list bf";
2707 return "line strip cont";
2709 return "line strip bf";
2711 return "line strip cont bf";
2713 return "tri fan no stipple";
2720 i965_decode_urb_fence(struct drm_intel_decode *ctx, int len)
2722 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2723 uint32_t *data = ctx->data;
2726 fprintf(out, "Bad count in URB_FENCE\n");
2728 vs_fence = data[1] & 0x3ff;
2729 gs_fence = (data[1] >> 10) & 0x3ff;
2730 clip_fence = (data[1] >> 20) & 0x3ff;
2731 sf_fence = data[2] & 0x3ff;
2732 vfe_fence = (data[2] >> 10) & 0x3ff;
2733 cs_fence = (data[2] >> 20) & 0x7ff;
2735 instr_out(ctx, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2736 (data[0] >> 13) & 1 ? "cs " : "",
2737 (data[0] >> 12) & 1 ? "vfe " : "",
2738 (data[0] >> 11) & 1 ? "sf " : "",
2739 (data[0] >> 10) & 1 ? "clip " : "",
2740 (data[0] >> 9) & 1 ? "gs " : "",
2741 (data[0] >> 8) & 1 ? "vs " : "");
2743 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2744 vs_fence, clip_fence, gs_fence);
2746 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2747 sf_fence, vfe_fence, cs_fence);
2748 if (gs_fence < vs_fence)
2749 fprintf(out, "gs fence < vs fence!\n");
2750 if (clip_fence < gs_fence)
2751 fprintf(out, "clip fence < gs fence!\n");
2752 if (sf_fence < clip_fence)
2753 fprintf(out, "sf fence < clip fence!\n");
2754 if (cs_fence < sf_fence)
2755 fprintf(out, "cs fence < sf fence!\n");
2761 state_base_out(struct drm_intel_decode *ctx, unsigned int index,
2764 if (ctx->data[index] & 1) {
2765 instr_out(ctx, index,
2766 "%s state base address 0x%08x\n", name,
2767 ctx->data[index] & ~1);
2769 instr_out(ctx, index, "%s state base not updated\n",
2775 state_max_out(struct drm_intel_decode *ctx, unsigned int index,
2778 if (ctx->data[index] & 1) {
2779 if (ctx->data[index] == 1) {
2780 instr_out(ctx, index,
2781 "%s state upper bound disabled\n", name);
2783 instr_out(ctx, index,
2784 "%s state upper bound 0x%08x\n", name,
2785 ctx->data[index] & ~1);
2788 instr_out(ctx, index,
2789 "%s state upper bound not updated\n", name);
2794 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct drm_intel_decode *ctx)
2796 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_CC\n");
2797 instr_out(ctx, 1, "pointer to CC viewport\n");
2803 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct drm_intel_decode *ctx)
2805 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP\n");
2806 instr_out(ctx, 1, "pointer to SF_CLIP viewport\n");
2812 gen7_3DSTATE_BLEND_STATE_POINTERS(struct drm_intel_decode *ctx)
2814 instr_out(ctx, 0, "3DSTATE_BLEND_STATE_POINTERS\n");
2815 instr_out(ctx, 1, "pointer to BLEND_STATE at 0x%08x (%s)\n",
2817 (ctx->data[1] & 1) ? "changed" : "unchanged");
2823 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct drm_intel_decode *ctx)
2825 instr_out(ctx, 0, "3DSTATE_DEPTH_STENCIL_STATE_POINTERS\n");
2827 "pointer to DEPTH_STENCIL_STATE at 0x%08x (%s)\n",
2829 (ctx->data[1] & 1) ? "changed" : "unchanged");
2835 gen7_3DSTATE_HIER_DEPTH_BUFFER(struct drm_intel_decode *ctx)
2837 instr_out(ctx, 0, "3DSTATE_HIER_DEPTH_BUFFER\n");
2838 instr_out(ctx, 1, "pitch %db\n",
2839 (ctx->data[1] & 0x1ffff) + 1);
2840 instr_out(ctx, 2, "pointer to HiZ buffer\n");
2846 gen6_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2848 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2849 instr_out(ctx, 1, "blend change %d\n", ctx->data[1] & 1);
2850 instr_out(ctx, 2, "depth stencil change %d\n",
2852 instr_out(ctx, 3, "cc change %d\n", ctx->data[3] & 1);
2858 gen7_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2860 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2861 instr_out(ctx, 1, "pointer to COLOR_CALC_STATE at 0x%08x "
2864 (ctx->data[1] & 1) ? "changed" : "unchanged");
2870 gen7_3DSTATE_URB_unit(struct drm_intel_decode *ctx, const char *unit)
2872 int start_kb = ((ctx->data[1] >> 25) & 0x3f) * 8;
2873 /* the field is # of 512-bit rows - 1, we print bytes */
2874 int entry_size = (((ctx->data[1] >> 16) & 0x1ff) + 1);
2875 int nr_entries = ctx->data[1] & 0xffff;
2877 instr_out(ctx, 0, "3DSTATE_URB_%s\n", unit);
2879 "%dKB start, size=%d 64B rows, nr_entries=%d, total size %dB\n",
2880 start_kb, entry_size, nr_entries, nr_entries * 64 * entry_size);
2886 gen7_3DSTATE_URB_VS(struct drm_intel_decode *ctx)
2888 return gen7_3DSTATE_URB_unit(ctx, "VS");
2892 gen7_3DSTATE_URB_HS(struct drm_intel_decode *ctx)
2894 return gen7_3DSTATE_URB_unit(ctx, "HS");
2898 gen7_3DSTATE_URB_DS(struct drm_intel_decode *ctx)
2900 return gen7_3DSTATE_URB_unit(ctx, "DS");
2904 gen7_3DSTATE_URB_GS(struct drm_intel_decode *ctx)
2906 return gen7_3DSTATE_URB_unit(ctx, "GS");
2910 gen7_3DSTATE_CONSTANT(struct drm_intel_decode *ctx, const char *unit)
2914 rlen[0] = (ctx->data[1] >> 0) & 0xffff;
2915 rlen[1] = (ctx->data[1] >> 16) & 0xffff;
2916 rlen[2] = (ctx->data[2] >> 0) & 0xffff;
2917 rlen[3] = (ctx->data[2] >> 16) & 0xffff;
2919 instr_out(ctx, 0, "3DSTATE_CONSTANT_%s\n", unit);
2920 instr_out(ctx, 1, "len 0 = %d, len 1 = %d\n", rlen[0], rlen[1]);
2921 instr_out(ctx, 2, "len 2 = %d, len 3 = %d\n", rlen[2], rlen[3]);
2922 instr_out(ctx, 3, "pointer to constbuf 0\n");
2923 instr_out(ctx, 4, "pointer to constbuf 1\n");
2924 instr_out(ctx, 5, "pointer to constbuf 2\n");
2925 instr_out(ctx, 6, "pointer to constbuf 3\n");
2931 gen7_3DSTATE_CONSTANT_VS(struct drm_intel_decode *ctx)
2933 return gen7_3DSTATE_CONSTANT(ctx, "VS");
2937 gen7_3DSTATE_CONSTANT_GS(struct drm_intel_decode *ctx)
2939 return gen7_3DSTATE_CONSTANT(ctx, "GS");
2943 gen7_3DSTATE_CONSTANT_PS(struct drm_intel_decode *ctx)
2945 return gen7_3DSTATE_CONSTANT(ctx, "PS");
2949 gen7_3DSTATE_CONSTANT_DS(struct drm_intel_decode *ctx)
2951 return gen7_3DSTATE_CONSTANT(ctx, "DS");
2955 gen7_3DSTATE_CONSTANT_HS(struct drm_intel_decode *ctx)
2957 return gen7_3DSTATE_CONSTANT(ctx, "HS");
2962 gen6_3DSTATE_WM(struct drm_intel_decode *ctx)
2964 instr_out(ctx, 0, "3DSTATE_WM\n");
2965 instr_out(ctx, 1, "kernel start pointer 0\n");
2967 "SPF=%d, VME=%d, Sampler Count %d, "
2968 "Binding table count %d\n",
2969 (ctx->data[2] >> 31) & 1,
2970 (ctx->data[2] >> 30) & 1,
2971 (ctx->data[2] >> 27) & 7,
2972 (ctx->data[2] >> 18) & 0xff);
2973 instr_out(ctx, 3, "scratch offset\n");
2975 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
2976 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
2977 (ctx->data[4] & (1 << 30)) != 0,
2978 (ctx->data[4] & (1 << 28)) != 0,
2979 (ctx->data[4] & (1 << 27)) != 0,
2980 (ctx->data[4] >> 16) & 0x7f,
2981 (ctx->data[4] >> 8) & 0x7f,
2982 (ctx->data[4] & 0x7f));
2984 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
2985 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, "
2986 "Dispatch32 %d, Dispatch16 %d, Dispatch8 %d\n",
2987 ((ctx->data[5] >> 25) & 0x7f) + 1,
2988 (ctx->data[5] & (1 << 22)) != 0,
2989 (ctx->data[5] & (1 << 21)) != 0,
2990 (ctx->data[5] & (1 << 20)) != 0,
2991 (ctx->data[5] & (1 << 19)) != 0,
2992 (ctx->data[5] & (1 << 8)) != 0,
2993 (ctx->data[5] & (1 << 2)) != 0,
2994 (ctx->data[5] & (1 << 1)) != 0,
2995 (ctx->data[5] & (1 << 0)) != 0);
2997 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
2998 "Barycentric interp mode 0x%x, Point raster rule %d, "
2999 "Multisample mode %d, "
3000 "Multisample Dispatch mode %d\n",
3001 (ctx->data[6] >> 20) & 0x3f,
3002 (ctx->data[6] >> 18) & 3,
3003 (ctx->data[6] >> 16) & 3,
3004 (ctx->data[6] >> 10) & 0x3f,
3005 (ctx->data[6] & (1 << 9)) != 0,
3006 (ctx->data[6] >> 1) & 3,
3007 (ctx->data[6] & 1));
3008 instr_out(ctx, 7, "kernel start pointer 1\n");
3009 instr_out(ctx, 8, "kernel start pointer 2\n");
3015 gen7_3DSTATE_WM(struct drm_intel_decode *ctx)
3017 const char *computed_depth = "";
3018 const char *early_depth = "";
3019 const char *zw_interp = "";
3021 switch ((ctx->data[1] >> 23) & 0x3) {
3023 computed_depth = "";
3026 computed_depth = "computed depth";
3029 computed_depth = "computed depth >=";
3032 computed_depth = "computed depth <=";
3036 switch ((ctx->data[1] >> 21) & 0x3) {
3041 early_depth = ", EDSC_PSEXEC";
3044 early_depth = ", EDSC_PREPS";
3047 early_depth = ", BAD EDSC";
3051 switch ((ctx->data[1] >> 17) & 0x3) {
3056 early_depth = ", BAD ZW interp";
3059 early_depth = ", ZW centroid";
3062 early_depth = ", ZW sample";
3066 instr_out(ctx, 0, "3DSTATE_WM\n");
3067 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",
3068 (ctx->data[1] & (1 << 11)) ? "PP " : "",
3069 (ctx->data[1] & (1 << 12)) ? "PC " : "",
3070 (ctx->data[1] & (1 << 13)) ? "PS " : "",
3071 (ctx->data[1] & (1 << 14)) ? "NPP " : "",
3072 (ctx->data[1] & (1 << 15)) ? "NPC " : "",
3073 (ctx->data[1] & (1 << 16)) ? "NPS " : "",
3074 (ctx->data[1] & (1 << 30)) ? ", depth clear" : "",
3075 (ctx->data[1] & (1 << 29)) ? "" : ", disabled",
3076 (ctx->data[1] & (1 << 28)) ? ", depth resolve" : "",
3077 (ctx->data[1] & (1 << 27)) ? ", hiz resolve" : "",
3078 (ctx->data[1] & (1 << 25)) ? ", kill" : "",
3082 (ctx->data[1] & (1 << 20)) ? ", source depth" : "",
3083 (ctx->data[1] & (1 << 19)) ? ", source W" : "",
3084 (ctx->data[1] & (1 << 10)) ? ", coverage" : "",
3085 (ctx->data[1] & (1 << 4)) ? ", poly stipple" : "",
3086 (ctx->data[1] & (1 << 3)) ? ", line stipple" : "",
3087 (ctx->data[1] & (1 << 2)) ? ", point UL" : ", point UR"
3089 instr_out(ctx, 2, "MS\n");
3095 gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
3098 "3DPRIMITIVE: %s %s\n",
3099 get_965_prim_type((ctx->data[0] >> 10) & 0x1f),
3100 (ctx->data[0] & (1 << 15)) ? "random" : "sequential");
3101 instr_out(ctx, 1, "vertex count\n");
3102 instr_out(ctx, 2, "start vertex\n");
3103 instr_out(ctx, 3, "instance count\n");
3104 instr_out(ctx, 4, "start instance\n");
3105 instr_out(ctx, 5, "index bias\n");
3111 gen7_3DPRIMITIVE(struct drm_intel_decode *ctx)
3113 bool indirect = !!(ctx->data[0] & (1 << 10));
3116 "3DPRIMITIVE: %s%s\n",
3117 indirect ? " indirect" : "",
3118 (ctx->data[0] & (1 << 8)) ? " predicated" : "");
3119 instr_out(ctx, 1, "%s %s\n",
3120 get_965_prim_type(ctx->data[1] & 0x3f),
3121 (ctx->data[1] & (1 << 8)) ? "random" : "sequential");
3122 instr_out(ctx, 2, indirect ? "ignored" : "vertex count\n");
3123 instr_out(ctx, 3, indirect ? "ignored" : "start vertex\n");
3124 instr_out(ctx, 4, indirect ? "ignored" : "instance count\n");
3125 instr_out(ctx, 5, indirect ? "ignored" : "start instance\n");
3126 instr_out(ctx, 6, indirect ? "ignored" : "index bias\n");
3132 decode_3d_965(struct drm_intel_decode *ctx)
3136 unsigned int i, j, sba_len;
3137 const char *desc1 = NULL;
3138 uint32_t *data = ctx->data;
3139 uint32_t devid = ctx->devid;
3144 int unsigned min_len;
3145 int unsigned max_len;
3148 int (*func)(struct drm_intel_decode *ctx);
3150 { 0x6000, 0x00ff, 3, 3, "URB_FENCE" },
3151 { 0x6001, 0xffff, 2, 2, "CS_URB_STATE" },
3152 { 0x6002, 0x00ff, 2, 2, "CONSTANT_BUFFER" },
3153 { 0x6101, 0xffff, 6, 10, "STATE_BASE_ADDRESS" },
3154 { 0x6102, 0xffff, 2, 2, "STATE_SIP" },
3155 { 0x6104, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3156 { 0x680b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3157 { 0x6904, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3158 { 0x7800, 0xffff, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
3159 { 0x7801, 0x00ff, 4, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
3160 { 0x7802, 0x00ff, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
3161 { 0x7805, 0x00ff, 7, 7, "3DSTATE_DEPTH_BUFFER", 7 },
3162 { 0x7805, 0x00ff, 3, 3, "3DSTATE_URB" },
3163 { 0x7804, 0x00ff, 3, 3, "3DSTATE_CLEAR_PARAMS" },
3164 { 0x7806, 0x00ff, 3, 3, "3DSTATE_STENCIL_BUFFER" },
3165 { 0x7807, 0x00ff, 4, 4, "3DSTATE_HIER_DEPTH_BUFFER", 6 },
3166 { 0x7807, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 7, gen7_3DSTATE_HIER_DEPTH_BUFFER },
3167 { 0x7808, 0x00ff, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
3168 { 0x7809, 0x00ff, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
3169 { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" },
3170 { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3171 { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
3172 { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS },
3173 { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS },
3174 { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" },
3175 { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" },
3176 { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" },
3177 { 0x7812, 0x00ff, 4, 4, "3DSTATE_CLIP" },
3178 { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF", 6 },
3179 { 0x7813, 0x00ff, 7, 7, "3DSTATE_SF", 7 },
3180 { 0x7814, 0x00ff, 3, 3, "3DSTATE_WM", 7, gen7_3DSTATE_WM },
3181 { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM", 6, gen6_3DSTATE_WM },
3182 { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE", 6 },
3183 { 0x7815, 0x00ff, 7, 7, "3DSTATE_CONSTANT_VS", 7, gen7_3DSTATE_CONSTANT_VS },
3184 { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE", 6 },
3185 { 0x7816, 0x00ff, 7, 7, "3DSTATE_CONSTANT_GS", 7, gen7_3DSTATE_CONSTANT_GS },
3186 { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE", 6 },
3187 { 0x7817, 0x00ff, 7, 7, "3DSTATE_CONSTANT_PS", 7, gen7_3DSTATE_CONSTANT_PS },
3188 { 0x7818, 0xffff, 2, 2, "3DSTATE_SAMPLE_MASK" },
3189 { 0x7819, 0x00ff, 7, 7, "3DSTATE_CONSTANT_HS", 7, gen7_3DSTATE_CONSTANT_HS },
3190 { 0x781a, 0x00ff, 7, 7, "3DSTATE_CONSTANT_DS", 7, gen7_3DSTATE_CONSTANT_DS },
3191 { 0x781b, 0x00ff, 7, 7, "3DSTATE_HS" },
3192 { 0x781c, 0x00ff, 4, 4, "3DSTATE_TE" },
3193 { 0x781d, 0x00ff, 6, 6, "3DSTATE_DS" },
3194 { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" },
3195 { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" },
3196 { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" },
3197 { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP },
3198 { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC },
3199 { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS },
3200 { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS },
3201 { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" },
3202 { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" },
3203 { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" },
3204 { 0x7829, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_GS" },
3205 { 0x782a, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_PS" },
3206 { 0x782b, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_VS" },
3207 { 0x782c, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_HS" },
3208 { 0x782d, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_DS" },
3209 { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" },
3210 { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" },
3211 { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS },
3212 { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS },
3213 { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS },
3214 { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS },
3215 { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
3216 { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" },
3217 { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" },
3218 { 0x7906, 0xffff, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
3219 { 0x7907, 0xffff, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
3220 { 0x7908, 0xffff, 3, 3, "3DSTATE_LINE_STIPPLE" },
3221 { 0x7909, 0xffff, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
3222 { 0x7909, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3223 { 0x790a, 0xffff, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
3224 { 0x790b, 0xffff, 4, 4, "3DSTATE_GS_SVB_INDEX" },
3225 { 0x790d, 0xffff, 3, 3, "3DSTATE_MULTISAMPLE", 6 },
3226 { 0x790d, 0xffff, 4, 4, "3DSTATE_MULTISAMPLE", 7 },
3227 { 0x7910, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3228 { 0x7912, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_VS" },
3229 { 0x7913, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_HS" },
3230 { 0x7914, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_DS" },
3231 { 0x7915, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_GS" },
3232 { 0x7916, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_PS" },
3233 { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" },
3234 { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" },
3235 { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" },
3236 { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE },
3237 { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
3238 }, *opcode_3d = NULL;
3240 opcode = (data[0] & 0xffff0000) >> 16;
3242 for (i = 0; i < ARRAY_SIZE(opcodes_3d); i++) {
3243 if (opcode != opcodes_3d[i].opcode)
3246 /* If it's marked as not our gen, skip. */
3247 if (opcodes_3d[i].gen && opcodes_3d[i].gen != ctx->gen)
3250 opcode_3d = &opcodes_3d[i];
3255 if (opcode_3d->max_len == 1)
3258 len = (data[0] & opcode_3d->len_mask) + 2;
3260 if (len < opcode_3d->min_len ||
3261 len > opcode_3d->max_len) {
3262 fprintf(out, "Bad length %d in %s, expected %d-%d\n",
3263 len, opcode_3d->name,
3264 opcode_3d->min_len, opcode_3d->max_len);
3267 len = (data[0] & 0x0000ffff) + 2;
3272 return i965_decode_urb_fence(ctx, len);
3274 instr_out(ctx, 0, "CS_URB_STATE\n");
3276 "entry_size: %d [%d bytes], n_entries: %d\n",
3277 (data[1] >> 4) & 0x1f,
3278 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
3281 instr_out(ctx, 0, "CONSTANT_BUFFER: %s\n",
3282 (data[0] >> 8) & 1 ? "valid" : "invalid");
3284 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
3285 ((data[1] & 0x3f) + 1) * 64);
3289 instr_out(ctx, 0, "STATE_BASE_ADDRESS\n");
3292 if (IS_GEN6(devid) || IS_GEN7(devid))
3294 else if (IS_GEN5(devid))
3299 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
3301 state_base_out(ctx, i++, "general");
3302 state_base_out(ctx, i++, "surface");
3303 if (IS_GEN6(devid) || IS_GEN7(devid))
3304 state_base_out(ctx, i++, "dynamic");
3305 state_base_out(ctx, i++, "indirect");
3306 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3307 state_base_out(ctx, i++, "instruction");
3309 state_max_out(ctx, i++, "general");
3310 if (IS_GEN6(devid) || IS_GEN7(devid))
3311 state_max_out(ctx, i++, "dynamic");
3312 state_max_out(ctx, i++, "indirect");
3313 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3314 state_max_out(ctx, i++, "instruction");
3318 instr_out(ctx, 0, "3DSTATE_PIPELINED_POINTERS\n");
3319 instr_out(ctx, 1, "VS state\n");
3320 instr_out(ctx, 2, "GS state\n");
3321 instr_out(ctx, 3, "Clip state\n");
3322 instr_out(ctx, 4, "SF state\n");
3323 instr_out(ctx, 5, "WM state\n");
3324 instr_out(ctx, 6, "CC state\n");
3327 if (len != 6 && len != 4)
3329 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
3332 "3DSTATE_BINDING_TABLE_POINTERS\n");
3333 instr_out(ctx, 1, "VS binding table\n");
3334 instr_out(ctx, 2, "GS binding table\n");
3335 instr_out(ctx, 3, "Clip binding table\n");
3336 instr_out(ctx, 4, "SF binding table\n");
3337 instr_out(ctx, 5, "WM binding table\n");
3340 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
3341 "GS mod %d, PS mod %d\n",
3342 (data[0] & (1 << 8)) != 0,
3343 (data[0] & (1 << 9)) != 0,
3344 (data[0] & (1 << 12)) != 0);
3345 instr_out(ctx, 1, "VS binding table\n");
3346 instr_out(ctx, 2, "GS binding table\n");
3347 instr_out(ctx, 3, "WM binding table\n");
3353 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
3354 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
3355 (data[0] & (1 << 9)) != 0,
3356 (data[0] & (1 << 12)) != 0);
3357 instr_out(ctx, 1, "VS sampler state\n");
3358 instr_out(ctx, 2, "GS sampler state\n");
3359 instr_out(ctx, 3, "WM sampler state\n");
3362 /* Actually 3DSTATE_DEPTH_BUFFER on gen7. */
3366 instr_out(ctx, 0, "3DSTATE_URB\n");
3368 "VS entries %d, alloc size %d (1024bit row)\n",
3369 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
3371 "GS entries %d, alloc size %d (1024bit row)\n",
3372 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
3376 if ((len - 1) % 4 != 0)
3377 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
3378 instr_out(ctx, 0, "3DSTATE_VERTEX_BUFFERS\n");
3380 for (i = 1; i < len;) {
3382 if (IS_GEN6(devid)) {
3390 "buffer %d: %s, pitch %db\n", data[i] >> idx,
3391 data[i] & (1 << access) ? "random" :
3392 "sequential", data[i] & 0x07ff);
3394 instr_out(ctx, i++, "buffer address\n");
3395 instr_out(ctx, i++, "max index\n");
3396 instr_out(ctx, i++, "mbz\n");
3401 if ((len + 1) % 2 != 0)
3402 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3403 instr_out(ctx, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3405 for (i = 1; i < len;) {
3407 "buffer %d: %svalid, type 0x%04x, "
3408 "src offset 0x%04x bytes\n",
3409 data[i] >> ((IS_GEN6(devid) || IS_GEN7(devid)) ? 26 : 27),
3410 data[i] & (1 << ((IS_GEN6(devid) || IS_GEN7(devid)) ? 25 : 26)) ?
3411 "" : "in", (data[i] >> 16) & 0x1ff,
3414 instr_out(ctx, i, "(%s, %s, %s, %s), "
3415 "dst offset 0x%02x bytes\n",
3416 get_965_element_component(data[i], 0),
3417 get_965_element_component(data[i], 1),
3418 get_965_element_component(data[i], 2),
3419 get_965_element_component(data[i], 3),
3420 (data[i] & 0xff) * 4);
3427 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3428 instr_out(ctx, 1, "clip\n");
3429 instr_out(ctx, 2, "sf\n");
3430 instr_out(ctx, 3, "cc\n");
3434 instr_out(ctx, 0, "3DSTATE_INDEX_BUFFER\n");
3435 instr_out(ctx, 1, "beginning buffer address\n");
3436 instr_out(ctx, 2, "ending buffer address\n");
3440 instr_out(ctx, 0, "3DSTATE_SCISSOR_POINTERS\n");
3441 instr_out(ctx, 1, "scissor rect offset\n");
3445 instr_out(ctx, 0, "3DSTATE_VS\n");
3446 instr_out(ctx, 1, "kernel pointer\n");
3448 "SPF=%d, VME=%d, Sampler Count %d, "
3449 "Binding table count %d\n", (data[2] >> 31) & 1,
3450 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3451 (data[2] >> 18) & 0xff);
3452 instr_out(ctx, 3, "scratch offset\n");
3454 "Dispatch GRF start %d, VUE read length %d, "
3455 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3456 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3458 "Max Threads %d, Vertex Cache %sable, "
3459 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3460 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3461 (data[5] & 1) != 0 ? "en" : "dis");
3465 instr_out(ctx, 0, "3DSTATE_GS\n");
3466 instr_out(ctx, 1, "kernel pointer\n");
3468 "SPF=%d, VME=%d, Sampler Count %d, "
3469 "Binding table count %d\n", (data[2] >> 31) & 1,
3470 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3471 (data[2] >> 18) & 0xff);
3472 instr_out(ctx, 3, "scratch offset\n");
3474 "Dispatch GRF start %d, VUE read length %d, "
3475 "VUE read offset %d\n", (data[4] & 0xf),
3476 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3478 "Max Threads %d, Rendering %sable\n",
3479 ((data[5] >> 25) & 0x7f) + 1,
3480 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3482 "Reorder %sable, Discard Adjaceny %sable, "
3484 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3485 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3486 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3490 instr_out(ctx, 0, "3DSTATE_CLIP\n");
3492 "UserClip distance cull test mask 0x%x\n",
3495 "Clip %sable, API mode %s, Viewport XY test %sable, "
3496 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3497 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3498 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3499 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3500 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3501 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3502 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3503 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3504 (data[2] >> 13) & 7,
3505 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3506 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3507 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3510 "Min PointWidth %d, Max PointWidth %d, "
3511 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3512 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3513 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3521 instr_out(ctx, 0, "3DSTATE_SF\n");
3523 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3524 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3525 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3526 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3528 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3529 "VP transform %sable, FrontWinding_%s\n",
3530 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3531 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3532 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3533 (data[2] & 1) != 0 ? "CCW" : "CW");
3535 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3536 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3537 (data[3] >> 29) & 3,
3538 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3539 (data[3] >> 8) & 3);
3541 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3542 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3543 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3544 (data[4] & (1 << 11)) != 0);
3546 "Global Depth Offset Constant %f\n",
3547 *(float *)(&data[5]));
3548 instr_out(ctx, 6, "Global Depth Offset Scale %f\n",
3549 *(float *)(&data[6]));
3550 instr_out(ctx, 7, "Global Depth Offset Clamp %f\n",
3551 *(float *)(&data[7]));
3553 for (i = 0, j = 0; i < 8; i++, j += 2)
3554 instr_out(ctx, i + 8,
3555 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3556 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3558 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3559 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3560 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3561 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3562 (data[8 + i] >> 25) & 3,
3563 (data[8 + i] >> 22) & 3,
3564 (data[8 + i] >> 16) & 0x1f, j,
3565 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3566 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3567 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3568 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3569 (data[8 + i] >> 9) & 3,
3570 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3572 "Point Sprite TexCoord Enable\n");
3573 instr_out(ctx, 17, "Const Interp Enable\n");
3575 "Attrib 7-0 WrapShortest Enable\n");
3577 "Attrib 15-8 WrapShortest Enable\n");
3582 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3583 instr_out(ctx, 1, "top left: %d,%d\n",
3584 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3585 instr_out(ctx, 2, "bottom right: %d,%d\n",
3586 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3587 instr_out(ctx, 3, "origin: %d,%d\n",
3588 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3593 instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n");
3594 if (IS_GEN5(devid) || IS_GEN6(devid))
3596 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3597 get_965_surfacetype(data[1] >> 29),
3598 get_965_depthformat((data[1] >> 18) & 0x7),
3599 (data[1] & 0x0001ffff) + 1,
3600 data[1] & (1 << 27) ? "" : "not ",
3601 (data[1] & (1 << 22)) != 0,
3602 (data[1] & (1 << 21)) != 0);
3605 "%s, %s, pitch = %d bytes, %stiled\n",
3606 get_965_surfacetype(data[1] >> 29),
3607 get_965_depthformat((data[1] >> 18) & 0x7),
3608 (data[1] & 0x0001ffff) + 1,
3609 data[1] & (1 << 27) ? "" : "not ");
3610 instr_out(ctx, 2, "depth offset\n");
3611 instr_out(ctx, 3, "%dx%d\n",
3612 ((data[3] & 0x0007ffc0) >> 6) + 1,
3613 ((data[3] & 0xfff80000) >> 19) + 1);
3614 instr_out(ctx, 4, "volume depth\n");
3616 instr_out(ctx, 5, "\n");
3619 instr_out(ctx, 6, "\n");
3622 "render target view extent\n");
3628 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3630 if (len != 4 && len != 5)
3631 fprintf(out, "Bad count in PIPE_CONTROL\n");
3633 switch ((data[1] >> 14) & 0x3) {
3638 desc1 = "qword write";
3641 desc1 = "PS_DEPTH_COUNT write";
3644 desc1 = "TIMESTAMP write";
3647 instr_out(ctx, 0, "PIPE_CONTROL\n");
3649 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3651 data[1] & (1 << 20) ? "cs stall, " : "",
3652 data[1] & (1 << 19) ?
3653 "global snapshot count reset, " : "",
3654 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3655 data[1] & (1 << 17) ? "gfdt flush, " : "",
3656 data[1] & (1 << 17) ? "media state clear, " :
3658 data[1] & (1 << 13) ? "depth stall, " : "",
3659 data[1] & (1 << 12) ?
3660 "render target cache flush, " : "",
3661 data[1] & (1 << 11) ?
3662 "instruction cache invalidate, " : "",
3663 data[1] & (1 << 10) ?
3664 "texture cache invalidate, " : "",
3665 data[1] & (1 << 9) ?
3666 "indirect state invalidate, " : "",
3667 data[1] & (1 << 8) ? "notify irq, " : "",
3668 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3670 data[1] & (1 << 6) ? "protect mem app_id, " :
3671 "", data[1] & (1 << 5) ? "DC flush, " : "",
3672 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3674 data[1] & (1 << 3) ?
3675 "constant cache invalidate, " : "",
3676 data[1] & (1 << 2) ?
3677 "state cache invalidate, " : "",
3678 data[1] & (1 << 1) ? "stall at scoreboard, " :
3680 data[1] & (1 << 0) ? "depth cache flush, " :
3684 "destination address\n");
3686 "immediate dword low\n");
3688 "immediate dword high\n");
3690 for (i = 2; i < len; i++) {
3691 instr_out(ctx, i, "\n");
3697 fprintf(out, "Bad count in PIPE_CONTROL\n");
3699 switch ((data[0] >> 14) & 0x3) {
3704 desc1 = "qword write";
3707 desc1 = "PS_DEPTH_COUNT write";
3710 desc1 = "TIMESTAMP write";
3714 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3717 data[0] & (1 << 13) ? "" : "no ",
3718 data[0] & (1 << 12) ? "" : "no ",
3719 data[0] & (1 << 11) ? "" : "no ");
3720 instr_out(ctx, 1, "destination address\n");
3721 instr_out(ctx, 2, "immediate dword low\n");
3722 instr_out(ctx, 3, "immediate dword high\n");
3728 if (opcode_3d->func) {
3729 return opcode_3d->func(ctx);
3733 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3735 for (i = 1; i < len; i++) {
3736 instr_out(ctx, i, "dword %d\n", i);
3742 instr_out(ctx, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3748 decode_3d_i830(struct drm_intel_decode *ctx)
3752 uint32_t *data = ctx->data;
3756 unsigned int min_len;
3757 unsigned int max_len;
3760 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3761 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3762 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3763 { 0x05, 1, 1, "3DSTATE_VFT0" },
3764 { 0x06, 1, 1, "3DSTATE_AA" },
3765 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3766 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3767 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3768 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3769 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3770 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3771 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3772 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3773 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3774 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3775 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3778 opcode = (data[0] & 0x1f000000) >> 24;
3782 return decode_3d_primitive(ctx);
3784 return decode_3d_1d(ctx);
3786 return decode_3d_1c(ctx);
3789 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3790 opcode_3d = &opcodes_3d[idx];
3791 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3792 unsigned int len = 1, i;
3794 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3795 if (opcode_3d->max_len > 1) {
3796 len = (data[0] & 0xff) + 2;
3797 if (len < opcode_3d->min_len ||
3798 len > opcode_3d->max_len) {
3799 fprintf(out, "Bad count in %s\n",
3804 for (i = 1; i < len; i++) {
3805 instr_out(ctx, i, "dword %d\n", i);
3811 instr_out(ctx, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3816 struct drm_intel_decode *
3817 drm_intel_decode_context_alloc(uint32_t devid)
3819 struct drm_intel_decode *ctx;
3821 ctx = calloc(1, sizeof(struct drm_intel_decode));
3830 else if (IS_GEN6(devid))
3832 else if (IS_GEN5(devid))
3834 else if (IS_GEN4(devid))
3836 else if (IS_9XX(devid))
3839 assert(IS_GEN2(devid));
3847 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3853 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3856 ctx->dump_past_end = !!dump_past_end;
3860 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3861 void *data, uint32_t hw_offset, int count)
3863 ctx->base_data = data;
3864 ctx->base_hw_offset = hw_offset;
3865 ctx->base_count = count;
3869 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3870 uint32_t head, uint32_t tail)
3877 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3884 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3886 * \param data batch buffer contents
3887 * \param count number of DWORDs to decode in the batch buffer
3888 * \param hw_offset hardware address for the buffer
3891 drm_intel_decode(struct drm_intel_decode *ctx)
3894 unsigned int index = 0;
3896 int size = ctx->base_count * 4;
3902 /* Put a scratch page full of obviously undefined data after
3903 * the batchbuffer. This lets us avoid a bunch of length
3904 * checking in statically sized packets.
3906 temp = malloc(size + 4096);
3907 memcpy(temp, ctx->base_data, size);
3908 memset((char *)temp + size, 0xd0, 4096);
3911 ctx->hw_offset = ctx->base_hw_offset;
3912 ctx->count = ctx->base_count;
3915 head_offset = ctx->head;
3916 tail_offset = ctx->tail;
3922 while (ctx->count > 0) {
3925 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3927 ret = decode_mi(ctx);
3929 /* If MI_BATCHBUFFER_END happened, then dump
3930 * the rest of the output in case we some day
3931 * want it in debugging, but don't decode it
3932 * since it'll just confuse in the common
3936 if (ctx->dump_past_end) {
3939 for (index = index + 1; index < ctx->count;
3941 instr_out(ctx, index, "\n");
3948 index += decode_2d(ctx);
3951 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3954 } else if (IS_GEN3(devid)) {
3955 index += decode_3d(ctx);
3958 decode_3d_i830(ctx);
3962 instr_out(ctx, index, "UNKNOWN\n");
3968 if (ctx->count < index)
3971 ctx->count -= index;
3973 ctx->hw_offset += 4 * index;