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
38 #include "intel_chipset.h"
39 #include "intel_bufmgr.h"
41 /* Struct for tracking drm_intel_decode state. */
42 struct drm_intel_decode {
43 /** stdio file where the output should land. Defaults to stdout. */
50 * Shorthand device identifier: 3 is 915, 4 is 965, 5 is
55 /** GPU address of the start of the current packet. */
57 /** CPU virtual address of the start of the current packet. */
59 /** DWORDs of remaining batchbuffer data starting from the packet. */
62 /** GPU address of the start of the batchbuffer data. */
63 uint32_t base_hw_offset;
64 /** CPU Virtual address of the start of the batchbuffer data. */
66 /** Number of DWORDs of batchbuffer data. */
70 * GPU head and tail pointers, which will be noted in the dump, or ~0.
76 * Whether to dump the dwords after MI_BATCHBUFFER_END.
78 * This sometimes provides clues in corrupted batchbuffers,
79 * and is used by the intel-gpu-tools.
87 static uint32_t saved_s2 = 0, saved_s4 = 0;
88 static char saved_s2_set = 0, saved_s4_set = 0;
89 static uint32_t head_offset = 0xffffffff; /* undefined */
90 static uint32_t tail_offset = 0xffffffff; /* undefined */
93 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
96 #define BUFFER_FAIL(_count, _len, _name) do { \
97 fprintf(out, "Buffer size too small in %s (%d < %d)\n", \
98 (_name), (_count), (_len)); \
102 static float int_as_float(uint32_t intval)
113 static void DRM_PRINTFLIKE(3, 4)
114 instr_out(struct drm_intel_decode *ctx, unsigned int index,
115 const char *fmt, ...)
118 const char *parseinfo;
119 uint32_t offset = ctx->hw_offset + index * 4;
121 if (index > ctx->count) {
122 if (!ctx->overflowed) {
123 fprintf(out, "ERROR: Decode attempted to continue beyond end of batchbuffer\n");
124 ctx->overflowed = true;
129 if (offset == head_offset)
131 else if (offset == tail_offset)
136 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
137 ctx->data[index], index == 0 ? "" : " ");
139 vfprintf(out, fmt, va);
144 decode_MI_SET_CONTEXT(struct drm_intel_decode *ctx)
146 uint32_t data = ctx->data[1];
150 instr_out(ctx, 0, "MI_SET_CONTEXT\n");
151 instr_out(ctx, 1, "gtt offset = 0x%x%s%s\n",
153 data & (1<<1)? ", Force Restore": "",
154 data & (1<<0)? ", Restore Inhibit": "");
160 decode_MI_WAIT_FOR_EVENT(struct drm_intel_decode *ctx)
164 uint32_t data = ctx->data[0];
171 switch ((data >> cc_shift) & 0x1f) {
173 cc_wait = ", cc wait 1";
176 cc_wait = ", cc wait 2";
179 cc_wait = ", cc wait 3";
182 cc_wait = ", cc wait 4";
185 cc_wait = ", cc wait 4";
193 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
194 data & (1<<18)? ", pipe B start vblank wait": "",
195 data & (1<<17)? ", pipe A start vblank wait": "",
196 data & (1<<16)? ", overlay flip pending wait": "",
197 data & (1<<14)? ", pipe B hblank wait": "",
198 data & (1<<13)? ", pipe A hblank wait": "",
200 data & (1<<8)? ", plane C pending flip wait": "",
201 data & (1<<7)? ", pipe B vblank wait": "",
202 data & (1<<6)? ", plane B pending flip wait": "",
203 data & (1<<5)? ", pipe B scan line wait": "",
204 data & (1<<4)? ", fbc idle wait": "",
205 data & (1<<3)? ", pipe A vblank wait": "",
206 data & (1<<2)? ", plane A pending flip wait": "",
207 data & (1<<1)? ", plane A scan line wait": "");
209 instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s\n",
210 data & (1<<20)? ", sprite C pending flip wait": "", /* ivb */
212 data & (1<<13)? ", pipe B hblank wait": "",
213 data & (1<<11)? ", pipe B vblank wait": "",
214 data & (1<<10)? ", sprite B pending flip wait": "",
215 data & (1<<9)? ", plane B pending flip wait": "",
216 data & (1<<8)? ", plane B scan line wait": "",
217 data & (1<<5)? ", pipe A hblank wait": "",
218 data & (1<<3)? ", pipe A vblank wait": "",
219 data & (1<<2)? ", sprite A pending flip wait": "",
220 data & (1<<1)? ", plane A pending flip wait": "",
221 data & (1<<0)? ", plane A scan line wait": "");
228 decode_mi(struct drm_intel_decode *ctx)
230 unsigned int opcode, len = -1;
231 const char *post_sync_op = "";
232 uint32_t *data = ctx->data;
237 unsigned int min_len;
238 unsigned int max_len;
240 int (*func)(struct drm_intel_decode *ctx);
242 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
243 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
244 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
245 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
246 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
247 { 0x04, 0, 1, 1, "MI_FLUSH" },
248 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
249 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
250 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
251 { 0x00, 0, 1, 1, "MI_NOOP" },
252 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
253 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
254 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT", decode_MI_SET_CONTEXT },
255 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
256 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
257 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
258 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
259 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT", decode_MI_WAIT_FOR_EVENT },
260 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
261 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
262 { 0x28, 0x3f, 3, 3, "MI_REPORT_PERF_COUNT" },
263 { 0x29, 0xff, 3, 3, "MI_LOAD_REGISTER_MEM" },
264 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
265 }, *opcode_mi = NULL;
267 /* check instruction length */
268 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
270 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
272 if (opcodes_mi[opcode].max_len > 1) {
274 (data[0] & opcodes_mi[opcode].len_mask) + 2;
275 if (len < opcodes_mi[opcode].min_len
276 || len > opcodes_mi[opcode].max_len) {
278 "Bad length (%d) in %s, [%d, %d]\n",
279 len, opcodes_mi[opcode].name,
280 opcodes_mi[opcode].min_len,
281 opcodes_mi[opcode].max_len);
284 opcode_mi = &opcodes_mi[opcode];
289 if (opcode_mi && opcode_mi->func)
290 return opcode_mi->func(ctx);
292 switch ((data[0] & 0x1f800000) >> 23) {
294 instr_out(ctx, 0, "MI_BATCH_BUFFER_END\n");
297 instr_out(ctx, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
298 data[0] & (1 << 22) ? " global gtt," : "",
299 data[0] & (1 << 21) ? " update semaphore," : "",
300 data[0] & (1 << 20) ? " compare semaphore," : "",
301 data[0] & (1 << 18) ? " use compare reg" : "",
302 (data[0] & (0x3 << 16)) >> 16);
303 instr_out(ctx, 1, "value\n");
304 instr_out(ctx, 2, "address\n");
307 instr_out(ctx, 0, "MI_STORE_DATA_INDEX%s\n",
308 data[0] & (1 << 21) ? " use per-process HWS," : "");
309 instr_out(ctx, 1, "index\n");
310 instr_out(ctx, 2, "dword\n");
312 instr_out(ctx, 3, "upper dword\n");
315 if (data[0] & (1 << 22))
317 "MI_NOOP write NOPID reg, val=0x%x\n",
318 data[0] & ((1 << 22) - 1));
320 instr_out(ctx, 0, "MI_NOOP\n");
323 switch (data[0] & (0x3 << 14)) {
325 post_sync_op = "no write";
328 post_sync_op = "write data";
331 post_sync_op = "reserved";
334 post_sync_op = "write TIMESTAMP";
338 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
339 data[0] & (1 << 22) ?
340 " enable protected mem (BCS-only)," : "",
341 data[0] & (1 << 21) ? " store in hws," : "",
342 data[0] & (1 << 18) ? " invalidate tlb," : "",
343 data[0] & (1 << 17) ? " flush gfdt," : "",
345 data[0] & (1 << 8) ? " enable notify interrupt," : "",
347 " invalidate video state (BCS-only)," : "");
348 if (data[0] & (1 << 21))
349 instr_out(ctx, 1, "hws index\n");
351 instr_out(ctx, 1, "address\n");
352 instr_out(ctx, 2, "dword\n");
354 instr_out(ctx, 3, "upper dword\n");
358 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
360 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
363 instr_out(ctx, 0, "%s\n",
364 opcodes_mi[opcode].name);
365 for (i = 1; i < len; i++) {
366 instr_out(ctx, i, "dword %d\n", i);
373 instr_out(ctx, 0, "MI UNKNOWN\n");
378 decode_2d_br00(struct drm_intel_decode *ctx, const char *cmd)
381 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
383 (ctx->data[0] & (1 << 20)) ? "en" : "dis",
384 (ctx->data[0] & (1 << 21)) ? "en" : "dis",
385 (ctx->data[0] >> 15) & 1,
386 (ctx->data[0] >> 11) & 1);
390 decode_2d_br01(struct drm_intel_decode *ctx)
393 switch ((ctx->data[1] >> 24) & 0x3) {
409 "format %s, pitch %d, rop 0x%02x, "
410 "clipping %sabled, %s%s \n",
412 (short)(ctx->data[1] & 0xffff),
413 (ctx->data[1] >> 16) & 0xff,
414 ctx->data[1] & (1 << 30) ? "en" : "dis",
415 ctx->data[1] & (1 << 31) ? "solid pattern enabled, " : "",
416 ctx->data[1] & (1 << 31) ?
417 "mono pattern transparency enabled, " : "");
422 decode_2d(struct drm_intel_decode *ctx)
424 unsigned int opcode, len;
425 uint32_t *data = ctx->data;
429 unsigned int min_len;
430 unsigned int max_len;
433 { 0x40, 5, 5, "COLOR_BLT" },
434 { 0x43, 6, 6, "SRC_COPY_BLT" },
435 { 0x01, 8, 8, "XY_SETUP_BLT" },
436 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
437 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
438 { 0x24, 2, 2, "XY_PIXEL_BLT" },
439 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
440 { 0x26, 4, 4, "Y_TEXT_BLT" },
441 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
442 { 0x50, 6, 6, "XY_COLOR_BLT" },
443 { 0x51, 6, 6, "XY_PAT_BLT" },
444 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
445 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
446 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
447 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
448 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
449 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
450 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
451 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
452 { 0x55, 9, 9, "XY_FULL_BLT" },
453 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
454 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
455 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
456 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
457 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
460 switch ((data[0] & 0x1fc00000) >> 22) {
463 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
464 (data[0] >> 12) & 0x8,
465 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
467 len = (data[0] & 0x000000ff) + 2;
469 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
471 instr_out(ctx, 1, "dest (%d,%d)\n",
472 data[1] & 0xffff, data[1] >> 16);
473 instr_out(ctx, 2, "dest (%d,%d)\n",
474 data[2] & 0xffff, data[2] >> 16);
477 decode_2d_br00(ctx, "XY_SETUP_BLT");
479 len = (data[0] & 0x000000ff) + 2;
481 fprintf(out, "Bad count in XY_SETUP_BLT\n");
484 instr_out(ctx, 2, "cliprect (%d,%d)\n",
485 data[2] & 0xffff, data[2] >> 16);
486 instr_out(ctx, 3, "cliprect (%d,%d)\n",
487 data[3] & 0xffff, data[3] >> 16);
488 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
490 instr_out(ctx, 5, "setup background color\n");
491 instr_out(ctx, 6, "setup foreground color\n");
492 instr_out(ctx, 7, "color pattern offset\n");
495 decode_2d_br00(ctx, "XY_SETUP_CLIP_BLT");
497 len = (data[0] & 0x000000ff) + 2;
499 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
501 instr_out(ctx, 1, "cliprect (%d,%d)\n",
502 data[1] & 0xffff, data[2] >> 16);
503 instr_out(ctx, 2, "cliprect (%d,%d)\n",
504 data[2] & 0xffff, data[3] >> 16);
507 decode_2d_br00(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT");
509 len = (data[0] & 0x000000ff) + 2;
512 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
515 instr_out(ctx, 2, "cliprect (%d,%d)\n",
516 data[2] & 0xffff, data[2] >> 16);
517 instr_out(ctx, 3, "cliprect (%d,%d)\n",
518 data[3] & 0xffff, data[3] >> 16);
519 instr_out(ctx, 4, "setup dst offset 0x%08x\n",
521 instr_out(ctx, 5, "setup background color\n");
522 instr_out(ctx, 6, "setup foreground color\n");
523 instr_out(ctx, 7, "mono pattern dw0\n");
524 instr_out(ctx, 8, "mono pattern dw1\n");
527 decode_2d_br00(ctx, "XY_COLOR_BLT");
529 len = (data[0] & 0x000000ff) + 2;
531 fprintf(out, "Bad count in XY_COLOR_BLT\n");
534 instr_out(ctx, 2, "(%d,%d)\n",
535 data[2] & 0xffff, data[2] >> 16);
536 instr_out(ctx, 3, "(%d,%d)\n",
537 data[3] & 0xffff, data[3] >> 16);
538 instr_out(ctx, 4, "offset 0x%08x\n", data[4]);
539 instr_out(ctx, 5, "color\n");
542 decode_2d_br00(ctx, "XY_SRC_COPY_BLT");
544 len = (data[0] & 0x000000ff) + 2;
546 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
549 instr_out(ctx, 2, "dst (%d,%d)\n",
550 data[2] & 0xffff, data[2] >> 16);
551 instr_out(ctx, 3, "dst (%d,%d)\n",
552 data[3] & 0xffff, data[3] >> 16);
553 instr_out(ctx, 4, "dst offset 0x%08x\n", data[4]);
554 instr_out(ctx, 5, "src (%d,%d)\n",
555 data[5] & 0xffff, data[5] >> 16);
556 instr_out(ctx, 6, "src pitch %d\n",
557 (short)(data[6] & 0xffff));
558 instr_out(ctx, 7, "src offset 0x%08x\n", data[7]);
562 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
564 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
568 instr_out(ctx, 0, "%s\n",
569 opcodes_2d[opcode].name);
570 if (opcodes_2d[opcode].max_len > 1) {
571 len = (data[0] & 0x000000ff) + 2;
572 if (len < opcodes_2d[opcode].min_len ||
573 len > opcodes_2d[opcode].max_len) {
574 fprintf(out, "Bad count in %s\n",
575 opcodes_2d[opcode].name);
579 for (i = 1; i < len; i++) {
580 instr_out(ctx, i, "dword %d\n", i);
587 instr_out(ctx, 0, "2D UNKNOWN\n");
592 decode_3d_1c(struct drm_intel_decode *ctx)
594 uint32_t *data = ctx->data;
597 opcode = (data[0] & 0x00f80000) >> 19;
602 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
605 instr_out(ctx, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
606 data[0] & 1 ? "enabled" : "disabled");
609 instr_out(ctx, 0, "3DSTATE_MAP_COORD_SET_I830\n");
612 instr_out(ctx, 0, "3DSTATE_MAP_CUBE_I830\n");
615 instr_out(ctx, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
619 instr_out(ctx, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
624 /** Sets the string dstname to describe the destination of the PS instruction */
626 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
628 uint32_t a0 = data[i];
629 int dst_nr = (a0 >> 14) & 0xf;
634 if (((a0 >> 10) & 0xf) == 0xf) {
637 int dstmask_index = 0;
639 dstmask[dstmask_index++] = '.';
641 dstmask[dstmask_index++] = 'x';
643 dstmask[dstmask_index++] = 'y';
645 dstmask[dstmask_index++] = 'z';
647 dstmask[dstmask_index++] = 'w';
648 dstmask[dstmask_index++] = 0;
660 switch ((a0 >> 19) & 0x7) {
663 fprintf(out, "bad destination reg R%d\n", dst_nr);
664 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
668 fprintf(out, "bad destination reg oC%d\n", dst_nr);
669 sprintf(dstname, "oC%s%s", dstmask, sat);
673 fprintf(out, "bad destination reg oD%d\n", dst_nr);
674 sprintf(dstname, "oD%s%s", dstmask, sat);
678 fprintf(out, "bad destination reg U%d\n", dst_nr);
679 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
682 sprintf(dstname, "RESERVED");
688 i915_get_channel_swizzle(uint32_t select)
690 switch (select & 0x7) {
692 return (select & 8) ? "-x" : "x";
694 return (select & 8) ? "-y" : "y";
696 return (select & 8) ? "-z" : "z";
698 return (select & 8) ? "-w" : "w";
700 return (select & 8) ? "-0" : "0";
702 return (select & 8) ? "-1" : "1";
704 return (select & 8) ? "-bad" : "bad";
709 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
713 sprintf(name, "R%d", src_nr);
715 fprintf(out, "bad src reg %s\n", name);
719 sprintf(name, "T%d", src_nr);
720 else if (src_nr == 8)
721 sprintf(name, "DIFFUSE");
722 else if (src_nr == 9)
723 sprintf(name, "SPECULAR");
724 else if (src_nr == 10)
725 sprintf(name, "FOG");
727 fprintf(out, "bad src reg T%d\n", src_nr);
728 sprintf(name, "RESERVED");
732 sprintf(name, "C%d", src_nr);
734 fprintf(out, "bad src reg %s\n", name);
739 fprintf(out, "bad src reg oC%d\n", src_nr);
744 fprintf(out, "bad src reg oD%d\n", src_nr);
747 sprintf(name, "U%d", src_nr);
749 fprintf(out, "bad src reg %s\n", name);
752 fprintf(out, "bad src reg type %d\n", src_type);
753 sprintf(name, "RESERVED");
758 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
760 uint32_t a0 = data[i];
761 uint32_t a1 = data[i + 1];
762 int src_nr = (a0 >> 2) & 0x1f;
763 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
764 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
765 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
766 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
769 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
770 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
772 if (strcmp(swizzle, ".xyzw") != 0)
773 strcat(srcname, swizzle);
776 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
778 uint32_t a1 = data[i + 1];
779 uint32_t a2 = data[i + 2];
780 int src_nr = (a1 >> 8) & 0x1f;
781 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
782 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
783 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
784 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
787 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
788 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
790 if (strcmp(swizzle, ".xyzw") != 0)
791 strcat(srcname, swizzle);
794 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
796 uint32_t a2 = data[i + 2];
797 int src_nr = (a2 >> 16) & 0x1f;
798 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
799 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
800 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
801 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
804 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
805 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
807 if (strcmp(swizzle, ".xyzw") != 0)
808 strcat(srcname, swizzle);
812 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
816 sprintf(name, "R%d", src_nr);
818 fprintf(out, "bad src reg %s\n", name);
822 sprintf(name, "T%d", src_nr);
823 else if (src_nr == 8)
824 sprintf(name, "DIFFUSE");
825 else if (src_nr == 9)
826 sprintf(name, "SPECULAR");
827 else if (src_nr == 10)
828 sprintf(name, "FOG");
830 fprintf(out, "bad src reg T%d\n", src_nr);
831 sprintf(name, "RESERVED");
837 fprintf(out, "bad src reg oC%d\n", src_nr);
842 fprintf(out, "bad src reg oD%d\n", src_nr);
845 fprintf(out, "bad src reg type %d\n", src_type);
846 sprintf(name, "RESERVED");
852 i915_decode_alu1(struct drm_intel_decode *ctx,
853 int i, char *instr_prefix, const char *op_name)
855 char dst[100], src0[100];
857 i915_get_instruction_dst(ctx->data, i, dst, 1);
858 i915_get_instruction_src0(ctx->data, i, src0);
860 instr_out(ctx, i++, "%s: %s %s, %s\n", instr_prefix,
862 instr_out(ctx, i++, "%s\n", instr_prefix);
863 instr_out(ctx, i++, "%s\n", instr_prefix);
867 i915_decode_alu2(struct drm_intel_decode *ctx,
868 int i, char *instr_prefix, const char *op_name)
870 char dst[100], src0[100], src1[100];
872 i915_get_instruction_dst(ctx->data, i, dst, 1);
873 i915_get_instruction_src0(ctx->data, i, src0);
874 i915_get_instruction_src1(ctx->data, i, src1);
876 instr_out(ctx, i++, "%s: %s %s, %s, %s\n", instr_prefix,
877 op_name, dst, src0, src1);
878 instr_out(ctx, i++, "%s\n", instr_prefix);
879 instr_out(ctx, i++, "%s\n", instr_prefix);
883 i915_decode_alu3(struct drm_intel_decode *ctx,
884 int i, char *instr_prefix, const char *op_name)
886 char dst[100], src0[100], src1[100], src2[100];
888 i915_get_instruction_dst(ctx->data, i, dst, 1);
889 i915_get_instruction_src0(ctx->data, i, src0);
890 i915_get_instruction_src1(ctx->data, i, src1);
891 i915_get_instruction_src2(ctx->data, i, src2);
893 instr_out(ctx, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
894 op_name, dst, src0, src1, src2);
895 instr_out(ctx, i++, "%s\n", instr_prefix);
896 instr_out(ctx, i++, "%s\n", instr_prefix);
900 i915_decode_tex(struct drm_intel_decode *ctx, int i,
901 const char *instr_prefix, const char *tex_name)
903 uint32_t t0 = ctx->data[i];
904 uint32_t t1 = ctx->data[i + 1];
909 i915_get_instruction_dst(ctx->data, i, dst_name, 0);
910 i915_get_instruction_addr((t1 >> 24) & 0x7,
911 (t1 >> 17) & 0xf, addr_name);
912 sampler_nr = t0 & 0xf;
914 instr_out(ctx, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
915 tex_name, dst_name, sampler_nr, addr_name);
916 instr_out(ctx, i++, "%s\n", instr_prefix);
917 instr_out(ctx, i++, "%s\n", instr_prefix);
921 i915_decode_dcl(struct drm_intel_decode *ctx, int i, char *instr_prefix)
923 uint32_t d0 = ctx->data[i];
924 const char *sampletype;
925 int dcl_nr = (d0 >> 14) & 0xf;
926 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
927 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
928 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
929 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
932 switch ((d0 >> 19) & 0x3) {
934 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
935 if (strcmp(dcl_mask, ".") == 0)
936 fprintf(out, "bad (empty) dcl mask\n");
939 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
941 if (strcmp(dcl_mask, ".x") != 0 &&
942 strcmp(dcl_mask, ".xy") != 0 &&
943 strcmp(dcl_mask, ".xz") != 0 &&
944 strcmp(dcl_mask, ".w") != 0 &&
945 strcmp(dcl_mask, ".xyzw") != 0) {
946 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
949 instr_out(ctx, i++, "%s: DCL T%d%s\n",
950 instr_prefix, dcl_nr, dcl_mask);
952 if (strcmp(dcl_mask, ".xz") == 0)
953 fprintf(out, "errataed bad dcl mask %s\n",
955 else if (strcmp(dcl_mask, ".xw") == 0)
956 fprintf(out, "errataed bad dcl mask %s\n",
958 else if (strcmp(dcl_mask, ".xzw") == 0)
959 fprintf(out, "errataed bad dcl mask %s\n",
964 "%s: DCL DIFFUSE%s\n", instr_prefix,
966 } else if (dcl_nr == 9) {
968 "%s: DCL SPECULAR%s\n", instr_prefix,
970 } else if (dcl_nr == 10) {
972 "%s: DCL FOG%s\n", instr_prefix,
976 instr_out(ctx, i++, "%s\n", instr_prefix);
977 instr_out(ctx, i++, "%s\n", instr_prefix);
980 switch ((d0 >> 22) & 0x3) {
991 sampletype = "RESERVED";
995 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
996 instr_out(ctx, i++, "%s: DCL S%d %s\n",
997 instr_prefix, dcl_nr, sampletype);
998 instr_out(ctx, i++, "%s\n", instr_prefix);
999 instr_out(ctx, i++, "%s\n", instr_prefix);
1002 instr_out(ctx, i++, "%s: DCL RESERVED%d\n",
1003 instr_prefix, dcl_nr);
1004 instr_out(ctx, i++, "%s\n", instr_prefix);
1005 instr_out(ctx, i++, "%s\n", instr_prefix);
1010 i915_decode_instruction(struct drm_intel_decode *ctx,
1011 int i, char *instr_prefix)
1013 switch ((ctx->data[i] >> 24) & 0x1f) {
1015 instr_out(ctx, i++, "%s: NOP\n", instr_prefix);
1016 instr_out(ctx, i++, "%s\n", instr_prefix);
1017 instr_out(ctx, i++, "%s\n", instr_prefix);
1020 i915_decode_alu2(ctx, i, instr_prefix, "ADD");
1023 i915_decode_alu1(ctx, i, instr_prefix, "MOV");
1026 i915_decode_alu2(ctx, i, instr_prefix, "MUL");
1029 i915_decode_alu3(ctx, i, instr_prefix, "MAD");
1032 i915_decode_alu3(ctx, i, instr_prefix, "DP2ADD");
1035 i915_decode_alu2(ctx, i, instr_prefix, "DP3");
1038 i915_decode_alu2(ctx, i, instr_prefix, "DP4");
1041 i915_decode_alu1(ctx, i, instr_prefix, "FRC");
1044 i915_decode_alu1(ctx, i, instr_prefix, "RCP");
1047 i915_decode_alu1(ctx, i, instr_prefix, "RSQ");
1050 i915_decode_alu1(ctx, i, instr_prefix, "EXP");
1053 i915_decode_alu1(ctx, i, instr_prefix, "LOG");
1056 i915_decode_alu2(ctx, i, instr_prefix, "CMP");
1059 i915_decode_alu2(ctx, i, instr_prefix, "MIN");
1062 i915_decode_alu2(ctx, i, instr_prefix, "MAX");
1065 i915_decode_alu1(ctx, i, instr_prefix, "FLR");
1068 i915_decode_alu1(ctx, i, instr_prefix, "MOD");
1071 i915_decode_alu1(ctx, i, instr_prefix, "TRC");
1074 i915_decode_alu2(ctx, i, instr_prefix, "SGE");
1077 i915_decode_alu2(ctx, i, instr_prefix, "SLT");
1080 i915_decode_tex(ctx, i, instr_prefix, "TEXLD");
1083 i915_decode_tex(ctx, i, instr_prefix, "TEXLDP");
1086 i915_decode_tex(ctx, i, instr_prefix, "TEXLDB");
1089 i915_decode_dcl(ctx, i, instr_prefix);
1092 instr_out(ctx, i++, "%s: unknown\n", instr_prefix);
1093 instr_out(ctx, i++, "%s\n", instr_prefix);
1094 instr_out(ctx, i++, "%s\n", instr_prefix);
1100 decode_compare_func(uint32_t op)
1124 decode_stencil_op(uint32_t op)
1149 decode_logic_op(uint32_t op)
1190 decode_blend_fact(uint32_t op)
1200 return "inv_src_colr";
1204 return "inv_src_alpha";
1208 return "inv_dst_alpha";
1212 return "inv_dst_colr";
1214 return "src_alpha_sat";
1218 return "inv_cnst_colr";
1220 return "cnst_alpha";
1222 return "inv_const_alpha";
1228 decode_tex_coord_mode(uint32_t mode)
1230 switch (mode & 0x7) {
1236 return "clamp_edge";
1240 return "clamp_border";
1242 return "mirror_once";
1248 decode_sample_filter(uint32_t mode)
1250 switch (mode & 0x7) {
1256 return "anisotropic";
1270 decode_3d_1d(struct drm_intel_decode *ctx)
1272 unsigned int len, i, c, idx, word, map, sampler, instr;
1273 const char *format, *zformat, *type;
1275 uint32_t *data = ctx->data;
1276 uint32_t devid = ctx->devid;
1281 unsigned int min_len;
1282 unsigned int max_len;
1284 } opcodes_3d_1d[] = {
1285 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1286 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1287 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1288 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1289 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1290 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1291 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1292 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1293 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1294 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1295 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1296 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1297 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1298 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1299 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1300 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1303 opcode = (data[0] & 0x00ff0000) >> 16;
1307 /* This instruction is unusual. A 0 length means just
1308 * 1 DWORD instead of 2. The 0 length is specified in
1309 * one place to be unsupported, but stated to be
1310 * required in another, and 0 length LOAD_INDIRECTs
1311 * appear to cause no harm at least.
1313 instr_out(ctx, 0, "3DSTATE_LOAD_INDIRECT\n");
1314 len = (data[0] & 0x000000ff) + 1;
1316 if (data[0] & (0x01 << 8)) {
1317 instr_out(ctx, i++, "SIS.0\n");
1318 instr_out(ctx, i++, "SIS.1\n");
1320 if (data[0] & (0x02 << 8)) {
1321 instr_out(ctx, i++, "DIS.0\n");
1323 if (data[0] & (0x04 << 8)) {
1324 instr_out(ctx, i++, "SSB.0\n");
1325 instr_out(ctx, i++, "SSB.1\n");
1327 if (data[0] & (0x08 << 8)) {
1328 instr_out(ctx, i++, "MSB.0\n");
1329 instr_out(ctx, i++, "MSB.1\n");
1331 if (data[0] & (0x10 << 8)) {
1332 instr_out(ctx, i++, "PSP.0\n");
1333 instr_out(ctx, i++, "PSP.1\n");
1335 if (data[0] & (0x20 << 8)) {
1336 instr_out(ctx, i++, "PSC.0\n");
1337 instr_out(ctx, i++, "PSC.1\n");
1340 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1346 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1347 len = (data[0] & 0x0000000f) + 2;
1349 for (word = 0; word <= 8; word++) {
1350 if (data[0] & (1 << (4 + word))) {
1351 /* save vertex state for decode */
1352 if (!IS_GEN2(devid)) {
1367 "S0: vbo offset: 0x%08x%s\n",
1370 ", auto cache invalidate disabled"
1375 "S1: vertex width: %i, vertex pitch: %i\n",
1383 "S2: texcoord formats: ");
1385 tex_num < 8; tex_num++) {
1431 "S3: not documented\n");
1435 const char *cullmode = "";
1436 const char *vfmt_xyzw = "";
1437 switch ((data[i] >> 13)
1474 case 1 << 6 | 1 << 2:
1478 case 2 << 6 | 1 << 2:
1482 case 3 << 6 | 1 << 2:
1486 case 4 << 6 | 1 << 2:
1492 "S4: point_width=%i, line_width=%.1f,"
1493 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1556 "force default diffuse, "
1562 "force default specular, "
1568 "local depth ofs enable, "
1574 "point sprite enable, "
1588 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1589 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1590 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1620 " force default point size,"
1626 " last pixel enable,"
1632 " global depth ofs enable,"
1658 "stencil write enable, "
1664 "stencil test enable, "
1670 "color dither enable, "
1682 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1683 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1684 "%s%stristrip_provoking_vertex=%i\n",
1685 data[i] & (1 << 31) ?
1686 "alpha test enable, "
1694 data[i] & (1 << 15) ?
1695 "cbuf blend enable, "
1697 decode_blend_fact(data
1701 decode_blend_fact(data
1705 data[i] & (1 << 3) ?
1706 "depth write enable, "
1708 data[i] & (1 << 2) ?
1709 "cbuf write enable, "
1715 "S7: depth offset constant: 0x%08x\n",
1721 "S%d: 0x%08x\n", word, data[i]);
1728 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1733 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1734 len = (data[0] & 0x0000000f) + 2;
1736 for (word = 6; word <= 14; word++) {
1737 if (data[0] & (1 << word)) {
1741 else if (word >= 7 && word <= 10) {
1743 "TB%dC\n", word - 7);
1745 "TB%dA\n", word - 7);
1746 } else if (word >= 11 && word <= 14) {
1748 "TM%dS0: offset=0x%08x, %s\n",
1750 data[i] & 0xfffffffe,
1751 data[i] & 1 ? "use fence" :
1755 "TM%dS1: height=%i, width=%i, %s\n",
1756 word - 11, data[i] >> 21,
1757 (data[i] >> 10) & 0x3ff,
1758 data[i] & 2 ? (data[i] & 1 ?
1764 "TM%dS2: pitch=%i, \n",
1766 ((data[i] >> 21) + 1) * 4);
1769 "TM%dS3\n", word - 11);
1771 "TM%dS4: dflt color\n",
1778 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1782 instr_out(ctx, 0, "3DSTATE_MAP_STATE\n");
1783 len = (data[0] & 0x0000003f) + 2;
1784 instr_out(ctx, 1, "mask\n");
1787 for (map = 0; map <= 15; map++) {
1788 if (data[1] & (1 << map)) {
1789 int width, height, pitch, dword;
1794 "map %d MS2 %s%s%s\n", map,
1796 "untrusted surface, " : "",
1798 "vertical line stride enable, " : "",
1800 "vertical ofs enable, " : "");
1803 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1804 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1807 if (dword & (1 << 2))
1809 else if (dword & (1 << 1))
1810 tiling = dword & (1 << 0) ? "Y" : "X";
1813 switch ((dword >> 7) & 0x7) {
1816 switch ((dword >> 3) & 0xf) {
1833 switch ((dword >> 3) & 0xf) {
1838 format = " argb1555";
1841 format = " argb4444";
1847 format = " bump655";
1862 switch ((dword >> 3) & 0xf) {
1864 format = " argb8888";
1867 format = " abgr8888";
1870 format = " xrgb8888";
1873 format = " xbgr8888";
1876 format = " qwvu8888";
1879 format = " axvu8888";
1882 format = " lxvu8888";
1885 format = " xlvu8888";
1888 format = " argb2101010";
1891 format = " abgr2101010";
1894 format = " awvu2101010";
1915 switch ((dword >> 3) & 0xf) {
1917 format = " yuv_swapy";
1923 format = " yuv_swapuv";
1926 format = " yuv_swapuvy";
1931 type = "compressed";
1932 switch ((dword >> 3) & 0x7) {
1946 format = " dxt1_rb";
1951 type = "4b indexed";
1952 switch ((dword >> 3) & 0xf) {
1954 format = " argb8888";
1961 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1962 map, width, height, type, format,
1964 dword & (1 << 9) ? " palette select" :
1969 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1971 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1972 map, pitch, (dword >> 9) & 0x3f,
1973 dword & 0xff, (dword >> 15) & 0x3f,
1974 dword & (1 << 8) ? "miplayout legacy"
1975 : "miplayout right");
1979 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1985 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1986 len = (data[0] & 0x000000ff) + 2;
1989 for (c = 0; c <= 31; c++) {
1990 if (data[1] & (1 << c)) {
1991 instr_out(ctx, i, "C%d.X = %f\n", c,
1992 int_as_float(data[i]));
1994 instr_out(ctx, i, "C%d.Y = %f\n",
1995 c, int_as_float(data[i]));
1997 instr_out(ctx, i, "C%d.Z = %f\n",
1998 c, int_as_float(data[i]));
2000 instr_out(ctx, i, "C%d.W = %f\n",
2001 c, int_as_float(data[i]));
2007 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
2011 instr_out(ctx, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
2012 len = (data[0] & 0x000000ff) + 2;
2013 if ((len - 1) % 3 != 0 || len > 370) {
2015 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
2018 for (instr = 0; instr < (len - 1) / 3; instr++) {
2019 char instr_prefix[10];
2021 sprintf(instr_prefix, "PS%03d", instr);
2022 i915_decode_instruction(ctx, i,
2030 instr_out(ctx, 0, "3DSTATE_SAMPLER_STATE\n");
2031 instr_out(ctx, 1, "mask\n");
2032 len = (data[0] & 0x0000003f) + 2;
2034 for (sampler = 0; sampler <= 15; sampler++) {
2035 if (data[1] & (1 << sampler)) {
2037 const char *mip_filter = "";
2040 switch ((dword >> 20) & 0x3) {
2042 mip_filter = "none";
2045 mip_filter = "nearest";
2048 mip_filter = "linear";
2052 "sampler %d SS2:%s%s%s "
2053 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
2054 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
2056 dword & (1 << 31) ? " reverse gamma,"
2058 dword & (1 << 30) ? " packed2planar,"
2061 " colorspace conversion," : "",
2062 (dword >> 22) & 0x1f, mip_filter,
2063 decode_sample_filter(dword >> 17),
2064 decode_sample_filter(dword >> 14),
2065 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2066 dword & (1 << 4) ? " shadow," : "",
2067 dword & (1 << 3) ? 4 : 2,
2068 decode_compare_func(dword));
2071 "sampler %d SS3: min_lod=%.2f,%s "
2072 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2074 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2076 " kill pixel enable," : "",
2077 decode_tex_coord_mode(dword >> 12),
2078 decode_tex_coord_mode(dword >> 9),
2079 decode_tex_coord_mode(dword >> 6),
2081 " normalized coords," : "",
2083 dword & (1 << 0) ? " deinterlacer," :
2087 "sampler %d SS4: border color\n",
2092 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2096 len = (data[0] & 0x0000000f) + 2;
2100 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2103 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2105 switch ((data[1] >> 8) & 0xf) {
2110 format = "x1r5g5b5";
2116 format = "a8r8g8b8";
2119 format = "ycrcb_swapy";
2122 format = "ycrcb_normal";
2125 format = "ycrcb_swapuv";
2128 format = "ycrcb_swapuvy";
2131 format = "a4r4g4b4";
2134 format = "a1r5g5b5";
2137 format = "a2r10g10b10";
2143 switch ((data[1] >> 2) & 0x3) {
2158 "%s format, %s depth format, early Z %sabled\n",
2160 (data[1] & (1 << 31)) ? "en" : "dis");
2165 const char *name, *tiling;
2167 len = (data[0] & 0x0000000f) + 2;
2170 "Bad count in 3DSTATE_BUFFER_INFO\n");
2172 switch ((data[1] >> 24) & 0x7) {
2185 if (data[1] & (1 << 23))
2187 else if (data[1] & (1 << 22))
2188 tiling = data[1] & (1 << 21) ? "Y" : "X";
2190 instr_out(ctx, 0, "3DSTATE_BUFFER_INFO\n");
2192 "%s, tiling = %s, pitch=%d\n", name, tiling,
2195 instr_out(ctx, 2, "address\n");
2199 len = (data[0] & 0x0000000f) + 2;
2203 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2205 instr_out(ctx, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2206 instr_out(ctx, 1, "(%d,%d)\n",
2207 data[1] & 0xffff, data[1] >> 16);
2208 instr_out(ctx, 2, "(%d,%d)\n",
2209 data[2] & 0xffff, data[2] >> 16);
2213 len = (data[0] & 0x0000000f) + 2;
2217 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2219 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2220 instr_out(ctx, 1, "%s\n",
2221 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2222 instr_out(ctx, 2, "(%d,%d)\n",
2223 data[2] & 0xffff, data[2] >> 16);
2224 instr_out(ctx, 3, "(%d,%d)\n",
2225 data[3] & 0xffff, data[3] >> 16);
2226 instr_out(ctx, 4, "(%d,%d)\n",
2227 data[4] & 0xffff, data[4] >> 16);
2231 len = (data[0] & 0x0000000f) + 2;
2234 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2236 instr_out(ctx, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2237 instr_out(ctx, 1, "prim_type=%s, clear=%s%s%s\n",
2238 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2239 data[1] & (1 << 2) ? "color," : "",
2240 data[1] & (1 << 1) ? "depth," : "",
2241 data[1] & (1 << 0) ? "stencil," : "");
2242 instr_out(ctx, 2, "clear color\n");
2243 instr_out(ctx, 3, "clear depth/stencil\n");
2244 instr_out(ctx, 4, "color value (rgba8888)\n");
2245 instr_out(ctx, 5, "depth value %f\n",
2246 int_as_float(data[5]));
2247 instr_out(ctx, 6, "clear stencil\n");
2251 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2252 opcode_3d_1d = &opcodes_3d_1d[idx];
2253 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2256 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2259 instr_out(ctx, 0, "%s\n",
2260 opcode_3d_1d->name);
2261 if (opcode_3d_1d->max_len > 1) {
2262 len = (data[0] & 0x0000ffff) + 2;
2263 if (len < opcode_3d_1d->min_len ||
2264 len > opcode_3d_1d->max_len) {
2265 fprintf(out, "Bad count in %s\n",
2266 opcode_3d_1d->name);
2270 for (i = 1; i < len; i++) {
2271 instr_out(ctx, i, "dword %d\n", i);
2278 instr_out(ctx, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2284 decode_3d_primitive(struct drm_intel_decode *ctx)
2286 uint32_t *data = ctx->data;
2287 uint32_t count = ctx->count;
2288 char immediate = (data[0] & (1 << 23)) == 0;
2289 unsigned int len, i, j, ret;
2290 const char *primtype;
2291 int original_s2 = saved_s2;
2292 int original_s4 = saved_s4;
2294 switch ((data[0] >> 18) & 0xf) {
2296 primtype = "TRILIST";
2299 primtype = "TRISTRIP";
2302 primtype = "TRISTRIP_REVERSE";
2305 primtype = "TRIFAN";
2308 primtype = "POLYGON";
2311 primtype = "LINELIST";
2314 primtype = "LINESTRIP";
2317 primtype = "RECTLIST";
2320 primtype = "POINTLIST";
2326 primtype = "CLEAR_RECT";
2331 primtype = "unknown";
2335 /* XXX: 3DPRIM_DIB not supported */
2337 len = (data[0] & 0x0003ffff) + 2;
2338 instr_out(ctx, 0, "3DPRIMITIVE inline %s\n",
2341 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2342 if (!saved_s2_set || !saved_s4_set) {
2343 fprintf(out, "unknown vertex format\n");
2344 for (i = 1; i < len; i++) {
2346 " vertex data (%f float)\n",
2347 int_as_float(data[i]));
2350 unsigned int vertex = 0;
2351 for (i = 1; i < len;) {
2354 #define VERTEX_OUT(fmt, ...) do { \
2356 instr_out(ctx, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2358 fprintf(out, " missing data in V%d\n", vertex); \
2362 VERTEX_OUT("X = %f", int_as_float(data[i]));
2363 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2364 switch (saved_s4 >> 6 & 0x7) {
2366 VERTEX_OUT("Z = %f",
2367 int_as_float(data[i]));
2370 VERTEX_OUT("Z = %f",
2371 int_as_float(data[i]));
2372 VERTEX_OUT("W = %f",
2373 int_as_float(data[i]));
2378 VERTEX_OUT("W = %f",
2379 int_as_float(data[i]));
2382 fprintf(out, "bad S4 position mask\n");
2385 if (saved_s4 & (1 << 10)) {
2387 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2388 "B=0x%02x)", data[i] >> 24,
2389 (data[i] >> 16) & 0xff,
2390 (data[i] >> 8) & 0xff,
2393 if (saved_s4 & (1 << 11)) {
2395 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2396 "B=0x%02x)", data[i] >> 24,
2397 (data[i] >> 16) & 0xff,
2398 (data[i] >> 8) & 0xff,
2401 if (saved_s4 & (1 << 12))
2402 VERTEX_OUT("width = 0x%08x)", data[i]);
2404 for (tc = 0; tc <= 7; tc++) {
2405 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2407 VERTEX_OUT("T%d.X = %f", tc,
2410 VERTEX_OUT("T%d.Y = %f", tc,
2415 VERTEX_OUT("T%d.X = %f", tc,
2418 VERTEX_OUT("T%d.Y = %f", tc,
2421 VERTEX_OUT("T%d.Z = %f", tc,
2426 VERTEX_OUT("T%d.X = %f", tc,
2429 VERTEX_OUT("T%d.Y = %f", tc,
2432 VERTEX_OUT("T%d.Z = %f", tc,
2435 VERTEX_OUT("T%d.W = %f", tc,
2440 VERTEX_OUT("T%d.X = %f", tc,
2446 ("T%d.XY = 0x%08x half-float",
2451 ("T%d.XY = 0x%08x half-float",
2454 ("T%d.ZW = 0x%08x half-float",
2461 "bad S2.T%d format\n",
2471 /* indirect vertices */
2472 len = data[0] & 0x0000ffff; /* index count */
2473 if (data[0] & (1 << 17)) {
2474 /* random vertex access */
2475 if (count < (len + 1) / 2 + 1) {
2476 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2477 "3DPRIMITIVE random indirect");
2480 "3DPRIMITIVE random indirect %s (%d)\n",
2483 /* vertex indices continue until 0xffff is
2486 for (i = 1; i < count; i++) {
2487 if ((data[i] & 0xffff) == 0xffff) {
2489 " indices: (terminator)\n");
2492 } else if ((data[i] >> 16) == 0xffff) {
2494 " indices: 0x%04x, (terminator)\n",
2500 " indices: 0x%04x, 0x%04x\n",
2506 "3DPRIMITIVE: no terminator found in index buffer\n");
2510 /* fixed size vertex index buffer */
2511 for (j = 1, i = 0; i < len; i += 2, j++) {
2512 if (i * 2 == len - 1) {
2514 " indices: 0x%04x\n",
2518 " indices: 0x%04x, 0x%04x\n",
2524 ret = (len + 1) / 2 + 1;
2527 /* sequential vertex access */
2529 "3DPRIMITIVE sequential indirect %s, %d starting from "
2530 "%d\n", primtype, len, data[1] & 0xffff);
2531 instr_out(ctx, 1, " start\n");
2538 saved_s2 = original_s2;
2539 saved_s4 = original_s4;
2544 decode_3d(struct drm_intel_decode *ctx)
2548 uint32_t *data = ctx->data;
2552 unsigned int min_len;
2553 unsigned int max_len;
2556 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2557 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2558 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2559 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2560 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2561 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2562 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2563 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2564 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2567 opcode = (data[0] & 0x1f000000) >> 24;
2571 return decode_3d_primitive(ctx);
2573 return decode_3d_1d(ctx);
2575 return decode_3d_1c(ctx);
2578 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2579 opcode_3d = &opcodes_3d[idx];
2580 if (opcode == opcode_3d->opcode) {
2581 unsigned int len = 1, i;
2583 instr_out(ctx, 0, "%s\n", opcode_3d->name);
2584 if (opcode_3d->max_len > 1) {
2585 len = (data[0] & 0xff) + 2;
2586 if (len < opcode_3d->min_len ||
2587 len > opcode_3d->max_len) {
2588 fprintf(out, "Bad count in %s\n",
2593 for (i = 1; i < len; i++) {
2594 instr_out(ctx, i, "dword %d\n", i);
2600 instr_out(ctx, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2604 static const char *get_965_surfacetype(unsigned int surfacetype)
2606 switch (surfacetype) {
2624 static const char *get_965_depthformat(unsigned int depthformat)
2626 switch (depthformat) {
2628 return "s8_z24float";
2640 static const char *get_965_element_component(uint32_t data, int component)
2642 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2644 switch (component_control) {
2648 switch (component) {
2673 static const char *get_965_prim_type(uint32_t primtype)
2677 return "point list";
2681 return "line strip";
2691 return "quad strip";
2693 return "line list adj";
2695 return "line strip adj";
2697 return "tri list adj";
2699 return "tri strip adj";
2701 return "tri strip reverse";
2709 return "point list bf";
2711 return "line strip cont";
2713 return "line strip bf";
2715 return "line strip cont bf";
2717 return "tri fan no stipple";
2724 i965_decode_urb_fence(struct drm_intel_decode *ctx, int len)
2726 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2727 uint32_t *data = ctx->data;
2730 fprintf(out, "Bad count in URB_FENCE\n");
2732 vs_fence = data[1] & 0x3ff;
2733 gs_fence = (data[1] >> 10) & 0x3ff;
2734 clip_fence = (data[1] >> 20) & 0x3ff;
2735 sf_fence = data[2] & 0x3ff;
2736 vfe_fence = (data[2] >> 10) & 0x3ff;
2737 cs_fence = (data[2] >> 20) & 0x7ff;
2739 instr_out(ctx, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2740 (data[0] >> 13) & 1 ? "cs " : "",
2741 (data[0] >> 12) & 1 ? "vfe " : "",
2742 (data[0] >> 11) & 1 ? "sf " : "",
2743 (data[0] >> 10) & 1 ? "clip " : "",
2744 (data[0] >> 9) & 1 ? "gs " : "",
2745 (data[0] >> 8) & 1 ? "vs " : "");
2747 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2748 vs_fence, clip_fence, gs_fence);
2750 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2751 sf_fence, vfe_fence, cs_fence);
2752 if (gs_fence < vs_fence)
2753 fprintf(out, "gs fence < vs fence!\n");
2754 if (clip_fence < gs_fence)
2755 fprintf(out, "clip fence < gs fence!\n");
2756 if (sf_fence < clip_fence)
2757 fprintf(out, "sf fence < clip fence!\n");
2758 if (cs_fence < sf_fence)
2759 fprintf(out, "cs fence < sf fence!\n");
2765 state_base_out(struct drm_intel_decode *ctx, unsigned int index,
2768 if (ctx->data[index] & 1) {
2769 instr_out(ctx, index,
2770 "%s state base address 0x%08x\n", name,
2771 ctx->data[index] & ~1);
2773 instr_out(ctx, index, "%s state base not updated\n",
2779 state_max_out(struct drm_intel_decode *ctx, unsigned int index,
2782 if (ctx->data[index] & 1) {
2783 if (ctx->data[index] == 1) {
2784 instr_out(ctx, index,
2785 "%s state upper bound disabled\n", name);
2787 instr_out(ctx, index,
2788 "%s state upper bound 0x%08x\n", name,
2789 ctx->data[index] & ~1);
2792 instr_out(ctx, index,
2793 "%s state upper bound not updated\n", name);
2798 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct drm_intel_decode *ctx)
2800 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_CC\n");
2801 instr_out(ctx, 1, "pointer to CC viewport\n");
2807 gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct drm_intel_decode *ctx)
2809 instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP\n");
2810 instr_out(ctx, 1, "pointer to SF_CLIP viewport\n");
2816 gen7_3DSTATE_BLEND_STATE_POINTERS(struct drm_intel_decode *ctx)
2818 instr_out(ctx, 0, "3DSTATE_BLEND_STATE_POINTERS\n");
2819 instr_out(ctx, 1, "pointer to BLEND_STATE at 0x%08x (%s)\n",
2821 (ctx->data[1] & 1) ? "changed" : "unchanged");
2827 gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct drm_intel_decode *ctx)
2829 instr_out(ctx, 0, "3DSTATE_DEPTH_STENCIL_STATE_POINTERS\n");
2831 "pointer to DEPTH_STENCIL_STATE at 0x%08x (%s)\n",
2833 (ctx->data[1] & 1) ? "changed" : "unchanged");
2839 gen7_3DSTATE_HIER_DEPTH_BUFFER(struct drm_intel_decode *ctx)
2841 instr_out(ctx, 0, "3DSTATE_HIER_DEPTH_BUFFER\n");
2842 instr_out(ctx, 1, "pitch %db\n",
2843 (ctx->data[1] & 0x1ffff) + 1);
2844 instr_out(ctx, 2, "pointer to HiZ buffer\n");
2850 gen6_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2852 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2853 instr_out(ctx, 1, "blend change %d\n", ctx->data[1] & 1);
2854 instr_out(ctx, 2, "depth stencil change %d\n",
2856 instr_out(ctx, 3, "cc change %d\n", ctx->data[3] & 1);
2862 gen7_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
2864 instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
2865 instr_out(ctx, 1, "pointer to COLOR_CALC_STATE at 0x%08x "
2868 (ctx->data[1] & 1) ? "changed" : "unchanged");
2874 gen7_3DSTATE_URB_unit(struct drm_intel_decode *ctx, const char *unit)
2876 int start_kb = ((ctx->data[1] >> 25) & 0x3f) * 8;
2877 /* the field is # of 512-bit rows - 1, we print bytes */
2878 int entry_size = (((ctx->data[1] >> 16) & 0x1ff) + 1);
2879 int nr_entries = ctx->data[1] & 0xffff;
2881 instr_out(ctx, 0, "3DSTATE_URB_%s\n", unit);
2883 "%dKB start, size=%d 64B rows, nr_entries=%d, total size %dB\n",
2884 start_kb, entry_size, nr_entries, nr_entries * 64 * entry_size);
2890 gen7_3DSTATE_URB_VS(struct drm_intel_decode *ctx)
2892 return gen7_3DSTATE_URB_unit(ctx, "VS");
2896 gen7_3DSTATE_URB_HS(struct drm_intel_decode *ctx)
2898 return gen7_3DSTATE_URB_unit(ctx, "HS");
2902 gen7_3DSTATE_URB_DS(struct drm_intel_decode *ctx)
2904 return gen7_3DSTATE_URB_unit(ctx, "DS");
2908 gen7_3DSTATE_URB_GS(struct drm_intel_decode *ctx)
2910 return gen7_3DSTATE_URB_unit(ctx, "GS");
2914 gen7_3DSTATE_CONSTANT(struct drm_intel_decode *ctx, const char *unit)
2918 rlen[0] = (ctx->data[1] >> 0) & 0xffff;
2919 rlen[1] = (ctx->data[1] >> 16) & 0xffff;
2920 rlen[2] = (ctx->data[2] >> 0) & 0xffff;
2921 rlen[3] = (ctx->data[2] >> 16) & 0xffff;
2923 instr_out(ctx, 0, "3DSTATE_CONSTANT_%s\n", unit);
2924 instr_out(ctx, 1, "len 0 = %d, len 1 = %d\n", rlen[0], rlen[1]);
2925 instr_out(ctx, 2, "len 2 = %d, len 3 = %d\n", rlen[2], rlen[3]);
2926 instr_out(ctx, 3, "pointer to constbuf 0\n");
2927 instr_out(ctx, 4, "pointer to constbuf 1\n");
2928 instr_out(ctx, 5, "pointer to constbuf 2\n");
2929 instr_out(ctx, 6, "pointer to constbuf 3\n");
2935 gen7_3DSTATE_CONSTANT_VS(struct drm_intel_decode *ctx)
2937 return gen7_3DSTATE_CONSTANT(ctx, "VS");
2941 gen7_3DSTATE_CONSTANT_GS(struct drm_intel_decode *ctx)
2943 return gen7_3DSTATE_CONSTANT(ctx, "GS");
2947 gen7_3DSTATE_CONSTANT_PS(struct drm_intel_decode *ctx)
2949 return gen7_3DSTATE_CONSTANT(ctx, "PS");
2953 gen7_3DSTATE_CONSTANT_DS(struct drm_intel_decode *ctx)
2955 return gen7_3DSTATE_CONSTANT(ctx, "DS");
2959 gen7_3DSTATE_CONSTANT_HS(struct drm_intel_decode *ctx)
2961 return gen7_3DSTATE_CONSTANT(ctx, "HS");
2966 gen6_3DSTATE_WM(struct drm_intel_decode *ctx)
2968 instr_out(ctx, 0, "3DSTATE_WM\n");
2969 instr_out(ctx, 1, "kernel start pointer 0\n");
2971 "SPF=%d, VME=%d, Sampler Count %d, "
2972 "Binding table count %d\n",
2973 (ctx->data[2] >> 31) & 1,
2974 (ctx->data[2] >> 30) & 1,
2975 (ctx->data[2] >> 27) & 7,
2976 (ctx->data[2] >> 18) & 0xff);
2977 instr_out(ctx, 3, "scratch offset\n");
2979 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
2980 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
2981 (ctx->data[4] & (1 << 30)) != 0,
2982 (ctx->data[4] & (1 << 28)) != 0,
2983 (ctx->data[4] & (1 << 27)) != 0,
2984 (ctx->data[4] >> 16) & 0x7f,
2985 (ctx->data[4] >> 8) & 0x7f,
2986 (ctx->data[4] & 0x7f));
2988 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
2989 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, "
2990 "Dispatch32 %d, Dispatch16 %d, Dispatch8 %d\n",
2991 ((ctx->data[5] >> 25) & 0x7f) + 1,
2992 (ctx->data[5] & (1 << 22)) != 0,
2993 (ctx->data[5] & (1 << 21)) != 0,
2994 (ctx->data[5] & (1 << 20)) != 0,
2995 (ctx->data[5] & (1 << 19)) != 0,
2996 (ctx->data[5] & (1 << 8)) != 0,
2997 (ctx->data[5] & (1 << 2)) != 0,
2998 (ctx->data[5] & (1 << 1)) != 0,
2999 (ctx->data[5] & (1 << 0)) != 0);
3001 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
3002 "Barycentric interp mode 0x%x, Point raster rule %d, "
3003 "Multisample mode %d, "
3004 "Multisample Dispatch mode %d\n",
3005 (ctx->data[6] >> 20) & 0x3f,
3006 (ctx->data[6] >> 18) & 3,
3007 (ctx->data[6] >> 16) & 3,
3008 (ctx->data[6] >> 10) & 0x3f,
3009 (ctx->data[6] & (1 << 9)) != 0,
3010 (ctx->data[6] >> 1) & 3,
3011 (ctx->data[6] & 1));
3012 instr_out(ctx, 7, "kernel start pointer 1\n");
3013 instr_out(ctx, 8, "kernel start pointer 2\n");
3019 gen7_3DSTATE_WM(struct drm_intel_decode *ctx)
3021 const char *computed_depth = "";
3022 const char *early_depth = "";
3023 const char *zw_interp = "";
3025 switch ((ctx->data[1] >> 23) & 0x3) {
3027 computed_depth = "";
3030 computed_depth = "computed depth";
3033 computed_depth = "computed depth >=";
3036 computed_depth = "computed depth <=";
3040 switch ((ctx->data[1] >> 21) & 0x3) {
3045 early_depth = ", EDSC_PSEXEC";
3048 early_depth = ", EDSC_PREPS";
3051 early_depth = ", BAD EDSC";
3055 switch ((ctx->data[1] >> 17) & 0x3) {
3060 early_depth = ", BAD ZW interp";
3063 early_depth = ", ZW centroid";
3066 early_depth = ", ZW sample";
3070 instr_out(ctx, 0, "3DSTATE_WM\n");
3071 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",
3072 (ctx->data[1] & (1 << 11)) ? "PP " : "",
3073 (ctx->data[1] & (1 << 12)) ? "PC " : "",
3074 (ctx->data[1] & (1 << 13)) ? "PS " : "",
3075 (ctx->data[1] & (1 << 14)) ? "NPP " : "",
3076 (ctx->data[1] & (1 << 15)) ? "NPC " : "",
3077 (ctx->data[1] & (1 << 16)) ? "NPS " : "",
3078 (ctx->data[1] & (1 << 30)) ? ", depth clear" : "",
3079 (ctx->data[1] & (1 << 29)) ? "" : ", disabled",
3080 (ctx->data[1] & (1 << 28)) ? ", depth resolve" : "",
3081 (ctx->data[1] & (1 << 27)) ? ", hiz resolve" : "",
3082 (ctx->data[1] & (1 << 25)) ? ", kill" : "",
3086 (ctx->data[1] & (1 << 20)) ? ", source depth" : "",
3087 (ctx->data[1] & (1 << 19)) ? ", source W" : "",
3088 (ctx->data[1] & (1 << 10)) ? ", coverage" : "",
3089 (ctx->data[1] & (1 << 4)) ? ", poly stipple" : "",
3090 (ctx->data[1] & (1 << 3)) ? ", line stipple" : "",
3091 (ctx->data[1] & (1 << 2)) ? ", point UL" : ", point UR"
3093 instr_out(ctx, 2, "MS\n");
3099 gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
3102 "3DPRIMITIVE: %s %s\n",
3103 get_965_prim_type((ctx->data[0] >> 10) & 0x1f),
3104 (ctx->data[0] & (1 << 15)) ? "random" : "sequential");
3105 instr_out(ctx, 1, "vertex count\n");
3106 instr_out(ctx, 2, "start vertex\n");
3107 instr_out(ctx, 3, "instance count\n");
3108 instr_out(ctx, 4, "start instance\n");
3109 instr_out(ctx, 5, "index bias\n");
3115 gen7_3DPRIMITIVE(struct drm_intel_decode *ctx)
3117 bool indirect = !!(ctx->data[0] & (1 << 10));
3120 "3DPRIMITIVE: %s%s\n",
3121 indirect ? " indirect" : "",
3122 (ctx->data[0] & (1 << 8)) ? " predicated" : "");
3123 instr_out(ctx, 1, "%s %s\n",
3124 get_965_prim_type(ctx->data[1] & 0x3f),
3125 (ctx->data[1] & (1 << 8)) ? "random" : "sequential");
3126 instr_out(ctx, 2, indirect ? "ignored" : "vertex count\n");
3127 instr_out(ctx, 3, indirect ? "ignored" : "start vertex\n");
3128 instr_out(ctx, 4, indirect ? "ignored" : "instance count\n");
3129 instr_out(ctx, 5, indirect ? "ignored" : "start instance\n");
3130 instr_out(ctx, 6, indirect ? "ignored" : "index bias\n");
3136 decode_3d_965(struct drm_intel_decode *ctx)
3140 unsigned int i, j, sba_len;
3141 const char *desc1 = NULL;
3142 uint32_t *data = ctx->data;
3143 uint32_t devid = ctx->devid;
3148 int unsigned min_len;
3149 int unsigned max_len;
3152 int (*func)(struct drm_intel_decode *ctx);
3154 { 0x6000, 0x00ff, 3, 3, "URB_FENCE" },
3155 { 0x6001, 0xffff, 2, 2, "CS_URB_STATE" },
3156 { 0x6002, 0x00ff, 2, 2, "CONSTANT_BUFFER" },
3157 { 0x6101, 0xffff, 6, 10, "STATE_BASE_ADDRESS" },
3158 { 0x6102, 0xffff, 2, 2, "STATE_SIP" },
3159 { 0x6104, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3160 { 0x680b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3161 { 0x6904, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
3162 { 0x7800, 0xffff, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
3163 { 0x7801, 0x00ff, 4, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
3164 { 0x7802, 0x00ff, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
3165 { 0x7805, 0x00ff, 7, 7, "3DSTATE_DEPTH_BUFFER", 7 },
3166 { 0x7805, 0x00ff, 3, 3, "3DSTATE_URB" },
3167 { 0x7804, 0x00ff, 3, 3, "3DSTATE_CLEAR_PARAMS" },
3168 { 0x7806, 0x00ff, 3, 3, "3DSTATE_STENCIL_BUFFER" },
3169 { 0x790f, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 6 },
3170 { 0x7807, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 7, gen7_3DSTATE_HIER_DEPTH_BUFFER },
3171 { 0x7808, 0x00ff, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
3172 { 0x7809, 0x00ff, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
3173 { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" },
3174 { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
3175 { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
3176 { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS },
3177 { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS },
3178 { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" },
3179 { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" },
3180 { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" },
3181 { 0x7812, 0x00ff, 4, 4, "3DSTATE_CLIP" },
3182 { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF", 6 },
3183 { 0x7813, 0x00ff, 7, 7, "3DSTATE_SF", 7 },
3184 { 0x7814, 0x00ff, 3, 3, "3DSTATE_WM", 7, gen7_3DSTATE_WM },
3185 { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM", 6, gen6_3DSTATE_WM },
3186 { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE", 6 },
3187 { 0x7815, 0x00ff, 7, 7, "3DSTATE_CONSTANT_VS", 7, gen7_3DSTATE_CONSTANT_VS },
3188 { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE", 6 },
3189 { 0x7816, 0x00ff, 7, 7, "3DSTATE_CONSTANT_GS", 7, gen7_3DSTATE_CONSTANT_GS },
3190 { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE", 6 },
3191 { 0x7817, 0x00ff, 7, 7, "3DSTATE_CONSTANT_PS", 7, gen7_3DSTATE_CONSTANT_PS },
3192 { 0x7818, 0xffff, 2, 2, "3DSTATE_SAMPLE_MASK" },
3193 { 0x7819, 0x00ff, 7, 7, "3DSTATE_CONSTANT_HS", 7, gen7_3DSTATE_CONSTANT_HS },
3194 { 0x781a, 0x00ff, 7, 7, "3DSTATE_CONSTANT_DS", 7, gen7_3DSTATE_CONSTANT_DS },
3195 { 0x781b, 0x00ff, 7, 7, "3DSTATE_HS" },
3196 { 0x781c, 0x00ff, 4, 4, "3DSTATE_TE" },
3197 { 0x781d, 0x00ff, 6, 6, "3DSTATE_DS" },
3198 { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" },
3199 { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" },
3200 { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" },
3201 { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP },
3202 { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC },
3203 { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS },
3204 { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS },
3205 { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" },
3206 { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" },
3207 { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" },
3208 { 0x7829, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_GS" },
3209 { 0x782a, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_PS" },
3210 { 0x782b, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_VS" },
3211 { 0x782c, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_HS" },
3212 { 0x782d, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_DS" },
3213 { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" },
3214 { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" },
3215 { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS },
3216 { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS },
3217 { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS },
3218 { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS },
3219 { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
3220 { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" },
3221 { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" },
3222 { 0x7906, 0xffff, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
3223 { 0x7907, 0xffff, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
3224 { 0x7908, 0xffff, 3, 3, "3DSTATE_LINE_STIPPLE" },
3225 { 0x7909, 0xffff, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
3226 { 0x7909, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3227 { 0x790a, 0xffff, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
3228 { 0x790b, 0xffff, 4, 4, "3DSTATE_GS_SVB_INDEX" },
3229 { 0x790d, 0xffff, 3, 3, "3DSTATE_MULTISAMPLE", 6 },
3230 { 0x790d, 0xffff, 4, 4, "3DSTATE_MULTISAMPLE", 7 },
3231 { 0x7910, 0x00ff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
3232 { 0x7912, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_VS" },
3233 { 0x7913, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_HS" },
3234 { 0x7914, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_DS" },
3235 { 0x7915, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_GS" },
3236 { 0x7916, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_PS" },
3237 { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" },
3238 { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" },
3239 { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" },
3240 { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE },
3241 { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
3242 }, *opcode_3d = NULL;
3244 opcode = (data[0] & 0xffff0000) >> 16;
3246 for (i = 0; i < ARRAY_SIZE(opcodes_3d); i++) {
3247 if (opcode != opcodes_3d[i].opcode)
3250 /* If it's marked as not our gen, skip. */
3251 if (opcodes_3d[i].gen && opcodes_3d[i].gen != ctx->gen)
3254 opcode_3d = &opcodes_3d[i];
3259 if (opcode_3d->max_len == 1)
3262 len = (data[0] & opcode_3d->len_mask) + 2;
3264 if (len < opcode_3d->min_len ||
3265 len > opcode_3d->max_len) {
3266 fprintf(out, "Bad length %d in %s, expected %d-%d\n",
3267 len, opcode_3d->name,
3268 opcode_3d->min_len, opcode_3d->max_len);
3271 len = (data[0] & 0x0000ffff) + 2;
3276 return i965_decode_urb_fence(ctx, len);
3278 instr_out(ctx, 0, "CS_URB_STATE\n");
3280 "entry_size: %d [%d bytes], n_entries: %d\n",
3281 (data[1] >> 4) & 0x1f,
3282 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
3285 instr_out(ctx, 0, "CONSTANT_BUFFER: %s\n",
3286 (data[0] >> 8) & 1 ? "valid" : "invalid");
3288 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
3289 ((data[1] & 0x3f) + 1) * 64);
3293 instr_out(ctx, 0, "STATE_BASE_ADDRESS\n");
3296 if (IS_GEN6(devid) || IS_GEN7(devid))
3298 else if (IS_GEN5(devid))
3303 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
3305 state_base_out(ctx, i++, "general");
3306 state_base_out(ctx, i++, "surface");
3307 if (IS_GEN6(devid) || IS_GEN7(devid))
3308 state_base_out(ctx, i++, "dynamic");
3309 state_base_out(ctx, i++, "indirect");
3310 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3311 state_base_out(ctx, i++, "instruction");
3313 state_max_out(ctx, i++, "general");
3314 if (IS_GEN6(devid) || IS_GEN7(devid))
3315 state_max_out(ctx, i++, "dynamic");
3316 state_max_out(ctx, i++, "indirect");
3317 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
3318 state_max_out(ctx, i++, "instruction");
3322 instr_out(ctx, 0, "3DSTATE_PIPELINED_POINTERS\n");
3323 instr_out(ctx, 1, "VS state\n");
3324 instr_out(ctx, 2, "GS state\n");
3325 instr_out(ctx, 3, "Clip state\n");
3326 instr_out(ctx, 4, "SF state\n");
3327 instr_out(ctx, 5, "WM state\n");
3328 instr_out(ctx, 6, "CC state\n");
3331 if (len != 6 && len != 4)
3333 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
3336 "3DSTATE_BINDING_TABLE_POINTERS\n");
3337 instr_out(ctx, 1, "VS binding table\n");
3338 instr_out(ctx, 2, "GS binding table\n");
3339 instr_out(ctx, 3, "Clip binding table\n");
3340 instr_out(ctx, 4, "SF binding table\n");
3341 instr_out(ctx, 5, "WM binding table\n");
3344 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
3345 "GS mod %d, PS mod %d\n",
3346 (data[0] & (1 << 8)) != 0,
3347 (data[0] & (1 << 9)) != 0,
3348 (data[0] & (1 << 12)) != 0);
3349 instr_out(ctx, 1, "VS binding table\n");
3350 instr_out(ctx, 2, "GS binding table\n");
3351 instr_out(ctx, 3, "WM binding table\n");
3357 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
3358 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
3359 (data[0] & (1 << 9)) != 0,
3360 (data[0] & (1 << 12)) != 0);
3361 instr_out(ctx, 1, "VS sampler state\n");
3362 instr_out(ctx, 2, "GS sampler state\n");
3363 instr_out(ctx, 3, "WM sampler state\n");
3366 /* Actually 3DSTATE_DEPTH_BUFFER on gen7. */
3370 instr_out(ctx, 0, "3DSTATE_URB\n");
3372 "VS entries %d, alloc size %d (1024bit row)\n",
3373 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
3375 "GS entries %d, alloc size %d (1024bit row)\n",
3376 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
3380 if ((len - 1) % 4 != 0)
3381 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
3382 instr_out(ctx, 0, "3DSTATE_VERTEX_BUFFERS\n");
3384 for (i = 1; i < len;) {
3386 if (IS_GEN6(devid)) {
3394 "buffer %d: %s, pitch %db\n", data[i] >> idx,
3395 data[i] & (1 << access) ? "random" :
3396 "sequential", data[i] & 0x07ff);
3398 instr_out(ctx, i++, "buffer address\n");
3399 instr_out(ctx, i++, "max index\n");
3400 instr_out(ctx, i++, "mbz\n");
3405 if ((len + 1) % 2 != 0)
3406 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3407 instr_out(ctx, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3409 for (i = 1; i < len;) {
3411 "buffer %d: %svalid, type 0x%04x, "
3412 "src offset 0x%04x bytes\n",
3413 data[i] >> ((IS_GEN6(devid) || IS_GEN7(devid)) ? 26 : 27),
3414 data[i] & (1 << ((IS_GEN6(devid) || IS_GEN7(devid)) ? 25 : 26)) ?
3415 "" : "in", (data[i] >> 16) & 0x1ff,
3418 instr_out(ctx, i, "(%s, %s, %s, %s), "
3419 "dst offset 0x%02x bytes\n",
3420 get_965_element_component(data[i], 0),
3421 get_965_element_component(data[i], 1),
3422 get_965_element_component(data[i], 2),
3423 get_965_element_component(data[i], 3),
3424 (data[i] & 0xff) * 4);
3431 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3432 instr_out(ctx, 1, "clip\n");
3433 instr_out(ctx, 2, "sf\n");
3434 instr_out(ctx, 3, "cc\n");
3438 instr_out(ctx, 0, "3DSTATE_INDEX_BUFFER\n");
3439 instr_out(ctx, 1, "beginning buffer address\n");
3440 instr_out(ctx, 2, "ending buffer address\n");
3444 instr_out(ctx, 0, "3DSTATE_SCISSOR_POINTERS\n");
3445 instr_out(ctx, 1, "scissor rect offset\n");
3449 instr_out(ctx, 0, "3DSTATE_VS\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] >> 20) & 0x1f,
3460 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3462 "Max Threads %d, Vertex Cache %sable, "
3463 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3464 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3465 (data[5] & 1) != 0 ? "en" : "dis");
3469 instr_out(ctx, 0, "3DSTATE_GS\n");
3470 instr_out(ctx, 1, "kernel pointer\n");
3472 "SPF=%d, VME=%d, Sampler Count %d, "
3473 "Binding table count %d\n", (data[2] >> 31) & 1,
3474 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3475 (data[2] >> 18) & 0xff);
3476 instr_out(ctx, 3, "scratch offset\n");
3478 "Dispatch GRF start %d, VUE read length %d, "
3479 "VUE read offset %d\n", (data[4] & 0xf),
3480 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3482 "Max Threads %d, Rendering %sable\n",
3483 ((data[5] >> 25) & 0x7f) + 1,
3484 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3486 "Reorder %sable, Discard Adjaceny %sable, "
3488 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3489 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3490 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3494 instr_out(ctx, 0, "3DSTATE_CLIP\n");
3496 "UserClip distance cull test mask 0x%x\n",
3499 "Clip %sable, API mode %s, Viewport XY test %sable, "
3500 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3501 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3502 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3503 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3504 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3505 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3506 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3507 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3508 (data[2] >> 13) & 7,
3509 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3510 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3511 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3514 "Min PointWidth %d, Max PointWidth %d, "
3515 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3516 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3517 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3525 instr_out(ctx, 0, "3DSTATE_SF\n");
3527 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3528 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3529 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3530 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3532 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3533 "VP transform %sable, FrontWinding_%s\n",
3534 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3535 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3536 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3537 (data[2] & 1) != 0 ? "CCW" : "CW");
3539 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3540 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3541 (data[3] >> 29) & 3,
3542 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3543 (data[3] >> 8) & 3);
3545 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3546 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3547 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3548 (data[4] & (1 << 11)) != 0);
3550 "Global Depth Offset Constant %f\n",
3551 *(float *)(&data[5]));
3552 instr_out(ctx, 6, "Global Depth Offset Scale %f\n",
3553 *(float *)(&data[6]));
3554 instr_out(ctx, 7, "Global Depth Offset Clamp %f\n",
3555 *(float *)(&data[7]));
3557 for (i = 0, j = 0; i < 8; i++, j += 2)
3558 instr_out(ctx, i + 8,
3559 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3560 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3562 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3563 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3564 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3565 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3566 (data[8 + i] >> 25) & 3,
3567 (data[8 + i] >> 22) & 3,
3568 (data[8 + i] >> 16) & 0x1f, j,
3569 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3570 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3571 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3572 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3573 (data[8 + i] >> 9) & 3,
3574 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3576 "Point Sprite TexCoord Enable\n");
3577 instr_out(ctx, 17, "Const Interp Enable\n");
3579 "Attrib 7-0 WrapShortest Enable\n");
3581 "Attrib 15-8 WrapShortest Enable\n");
3586 instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3587 instr_out(ctx, 1, "top left: %d,%d\n",
3588 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3589 instr_out(ctx, 2, "bottom right: %d,%d\n",
3590 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3591 instr_out(ctx, 3, "origin: %d,%d\n",
3592 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3597 instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n");
3598 if (IS_GEN5(devid) || IS_GEN6(devid))
3600 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3601 get_965_surfacetype(data[1] >> 29),
3602 get_965_depthformat((data[1] >> 18) & 0x7),
3603 (data[1] & 0x0001ffff) + 1,
3604 data[1] & (1 << 27) ? "" : "not ",
3605 (data[1] & (1 << 22)) != 0,
3606 (data[1] & (1 << 21)) != 0);
3609 "%s, %s, pitch = %d bytes, %stiled\n",
3610 get_965_surfacetype(data[1] >> 29),
3611 get_965_depthformat((data[1] >> 18) & 0x7),
3612 (data[1] & 0x0001ffff) + 1,
3613 data[1] & (1 << 27) ? "" : "not ");
3614 instr_out(ctx, 2, "depth offset\n");
3615 instr_out(ctx, 3, "%dx%d\n",
3616 ((data[3] & 0x0007ffc0) >> 6) + 1,
3617 ((data[3] & 0xfff80000) >> 19) + 1);
3618 instr_out(ctx, 4, "volume depth\n");
3620 instr_out(ctx, 5, "\n");
3623 instr_out(ctx, 6, "\n");
3626 "render target view extent\n");
3632 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3634 if (len != 4 && len != 5)
3635 fprintf(out, "Bad count in PIPE_CONTROL\n");
3637 switch ((data[1] >> 14) & 0x3) {
3642 desc1 = "qword write";
3645 desc1 = "PS_DEPTH_COUNT write";
3648 desc1 = "TIMESTAMP write";
3651 instr_out(ctx, 0, "PIPE_CONTROL\n");
3653 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3655 data[1] & (1 << 20) ? "cs stall, " : "",
3656 data[1] & (1 << 19) ?
3657 "global snapshot count reset, " : "",
3658 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3659 data[1] & (1 << 17) ? "gfdt flush, " : "",
3660 data[1] & (1 << 17) ? "media state clear, " :
3662 data[1] & (1 << 13) ? "depth stall, " : "",
3663 data[1] & (1 << 12) ?
3664 "render target cache flush, " : "",
3665 data[1] & (1 << 11) ?
3666 "instruction cache invalidate, " : "",
3667 data[1] & (1 << 10) ?
3668 "texture cache invalidate, " : "",
3669 data[1] & (1 << 9) ?
3670 "indirect state invalidate, " : "",
3671 data[1] & (1 << 8) ? "notify irq, " : "",
3672 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3674 data[1] & (1 << 6) ? "protect mem app_id, " :
3675 "", data[1] & (1 << 5) ? "DC flush, " : "",
3676 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3678 data[1] & (1 << 3) ?
3679 "constant cache invalidate, " : "",
3680 data[1] & (1 << 2) ?
3681 "state cache invalidate, " : "",
3682 data[1] & (1 << 1) ? "stall at scoreboard, " :
3684 data[1] & (1 << 0) ? "depth cache flush, " :
3688 "destination address\n");
3690 "immediate dword low\n");
3692 "immediate dword high\n");
3694 for (i = 2; i < len; i++) {
3695 instr_out(ctx, i, "\n");
3701 fprintf(out, "Bad count in PIPE_CONTROL\n");
3703 switch ((data[0] >> 14) & 0x3) {
3708 desc1 = "qword write";
3711 desc1 = "PS_DEPTH_COUNT write";
3714 desc1 = "TIMESTAMP write";
3718 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3721 data[0] & (1 << 13) ? "" : "no ",
3722 data[0] & (1 << 12) ? "" : "no ",
3723 data[0] & (1 << 11) ? "" : "no ");
3724 instr_out(ctx, 1, "destination address\n");
3725 instr_out(ctx, 2, "immediate dword low\n");
3726 instr_out(ctx, 3, "immediate dword high\n");
3732 if (opcode_3d->func) {
3733 return opcode_3d->func(ctx);
3737 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3739 for (i = 1; i < len; i++) {
3740 instr_out(ctx, i, "dword %d\n", i);
3746 instr_out(ctx, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3752 decode_3d_i830(struct drm_intel_decode *ctx)
3756 uint32_t *data = ctx->data;
3760 unsigned int min_len;
3761 unsigned int max_len;
3764 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3765 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3766 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3767 { 0x05, 1, 1, "3DSTATE_VFT0" },
3768 { 0x06, 1, 1, "3DSTATE_AA" },
3769 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3770 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3771 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3772 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3773 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3774 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3775 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3776 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3777 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3778 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3779 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3782 opcode = (data[0] & 0x1f000000) >> 24;
3786 return decode_3d_primitive(ctx);
3788 return decode_3d_1d(ctx);
3790 return decode_3d_1c(ctx);
3793 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3794 opcode_3d = &opcodes_3d[idx];
3795 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3796 unsigned int len = 1, i;
3798 instr_out(ctx, 0, "%s\n", opcode_3d->name);
3799 if (opcode_3d->max_len > 1) {
3800 len = (data[0] & 0xff) + 2;
3801 if (len < opcode_3d->min_len ||
3802 len > opcode_3d->max_len) {
3803 fprintf(out, "Bad count in %s\n",
3808 for (i = 1; i < len; i++) {
3809 instr_out(ctx, i, "dword %d\n", i);
3815 instr_out(ctx, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3820 drm_public struct drm_intel_decode *
3821 drm_intel_decode_context_alloc(uint32_t devid)
3823 struct drm_intel_decode *ctx;
3825 ctx = calloc(1, sizeof(struct drm_intel_decode));
3834 else if (IS_GEN7(devid))
3836 else if (IS_GEN6(devid))
3838 else if (IS_GEN5(devid))
3840 else if (IS_GEN4(devid))
3842 else if (IS_9XX(devid))
3845 assert(IS_GEN2(devid));
3853 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3859 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3862 ctx->dump_past_end = !!dump_past_end;
3866 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3867 void *data, uint32_t hw_offset, int count)
3869 ctx->base_data = data;
3870 ctx->base_hw_offset = hw_offset;
3871 ctx->base_count = count;
3875 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3876 uint32_t head, uint32_t tail)
3883 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3890 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3892 * \param data batch buffer contents
3893 * \param count number of DWORDs to decode in the batch buffer
3894 * \param hw_offset hardware address for the buffer
3897 drm_intel_decode(struct drm_intel_decode *ctx)
3900 unsigned int index = 0;
3902 int size = ctx->base_count * 4;
3908 /* Put a scratch page full of obviously undefined data after
3909 * the batchbuffer. This lets us avoid a bunch of length
3910 * checking in statically sized packets.
3912 temp = malloc(size + 4096);
3913 memcpy(temp, ctx->base_data, size);
3914 memset((char *)temp + size, 0xd0, 4096);
3917 ctx->hw_offset = ctx->base_hw_offset;
3918 ctx->count = ctx->base_count;
3921 head_offset = ctx->head;
3922 tail_offset = ctx->tail;
3928 while (ctx->count > 0) {
3931 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3933 ret = decode_mi(ctx);
3935 /* If MI_BATCHBUFFER_END happened, then dump
3936 * the rest of the output in case we some day
3937 * want it in debugging, but don't decode it
3938 * since it'll just confuse in the common
3942 if (ctx->dump_past_end) {
3945 for (index = index + 1; index < ctx->count;
3947 instr_out(ctx, index, "\n");
3954 index += decode_2d(ctx);
3957 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3960 } else if (IS_GEN3(devid)) {
3961 index += decode_3d(ctx);
3964 decode_3d_i830(ctx);
3968 instr_out(ctx, index, "UNKNOWN\n");
3974 if (ctx->count < index)
3977 ctx->count -= index;
3979 ctx->hw_offset += 4 * index;