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
31 #include "intel_chipset.h"
32 #include "intel_bufmgr.h"
34 /* Struct for tracking drm_intel_decode state. */
35 struct drm_intel_decode {
36 /** stdio file where the output should land. Defaults to stdout. */
42 /** GPU address of the start of the current packet. */
44 /** CPU virtual address of the start of the current packet. */
46 /** DWORDs of remaining batchbuffer data starting from the packet. */
49 /** GPU address of the start of the batchbuffer data. */
50 uint32_t base_hw_offset;
51 /** CPU Virtual address of the start of the batchbuffer data. */
53 /** Number of DWORDs of batchbuffer data. */
57 * GPU head and tail pointers, which will be noted in the dump, or ~0.
63 * Whether to dump the dwords after MI_BATCHBUFFER_END.
65 * This sometimes provides clues in corrupted batchbuffers,
66 * and is used by the intel-gpu-tools.
72 static uint32_t saved_s2 = 0, saved_s4 = 0;
73 static char saved_s2_set = 0, saved_s4_set = 0;
74 static uint32_t head_offset = 0xffffffff; /* undefined */
75 static uint32_t tail_offset = 0xffffffff; /* undefined */
78 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
81 #define BUFFER_FAIL(_count, _len, _name) do { \
82 fprintf(out, "Buffer size too small in %s (%d < %d)\n", \
83 (_name), (_count), (_len)); \
87 static float int_as_float(uint32_t intval)
99 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
100 const char *fmt, ...) __attribute__((format(__printf__, 4, 5)));
103 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
104 const char *fmt, ...)
107 const char *parseinfo;
108 uint32_t offset = hw_offset + index * 4;
110 if (offset == head_offset)
112 else if (offset == tail_offset)
117 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
118 data[index], index == 0 ? "" : " ");
120 vfprintf(out, fmt, va);
125 decode_mi(struct drm_intel_decode *ctx)
127 unsigned int opcode, len = -1;
128 const char *post_sync_op = "";
129 uint32_t *data = ctx->data;
130 uint32_t hw_offset = ctx->hw_offset;
131 uint32_t count = ctx->count;
136 unsigned int min_len;
137 unsigned int max_len;
140 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
141 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
142 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
143 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
144 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
145 { 0x04, 0, 1, 1, "MI_FLUSH" },
146 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
147 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
148 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
149 { 0x00, 0, 1, 1, "MI_NOOP" },
150 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
151 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
152 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
153 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
154 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
155 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
156 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
157 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
158 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
159 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
160 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
163 /* check instruction length */
164 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
166 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
168 if (opcodes_mi[opcode].max_len > 1) {
170 (data[0] & opcodes_mi[opcode].len_mask) + 2;
171 if (len < opcodes_mi[opcode].min_len
172 || len > opcodes_mi[opcode].max_len) {
174 "Bad length (%d) in %s, [%d, %d]\n",
175 len, opcodes_mi[opcode].name,
176 opcodes_mi[opcode].min_len,
177 opcodes_mi[opcode].max_len);
184 switch ((data[0] & 0x1f800000) >> 23) {
186 instr_out(data, hw_offset, 0, "MI_BATCH_BUFFER_END\n");
189 instr_out(data, hw_offset, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
190 data[0] & (1 << 22) ? " global gtt," : "",
191 data[0] & (1 << 21) ? " update semaphore," : "",
192 data[0] & (1 << 20) ? " compare semaphore," : "",
193 data[0] & (1 << 18) ? " use compare reg" : "",
194 (data[0] & (0x3 << 16)) >> 16);
195 instr_out(data, hw_offset, 1, "value\n");
196 instr_out(data, hw_offset, 2, "address\n");
199 instr_out(data, hw_offset, 0, "MI_STORE_DATA_INDEX%s\n",
200 data[0] & (1 << 21) ? " use per-process HWS," : "");
201 instr_out(data, hw_offset, 1, "index\n");
202 instr_out(data, hw_offset, 2, "dword\n");
204 instr_out(data, hw_offset, 3, "upper dword\n");
207 if (data[0] & (1 << 22))
208 instr_out(data, hw_offset, 0,
209 "MI_NOOP write NOPID reg, val=0x%x\n",
210 data[0] & ((1 << 22) - 1));
212 instr_out(data, hw_offset, 0, "MI_NOOP\n");
215 switch (data[0] & (0x3 << 14)) {
217 post_sync_op = "no write";
220 post_sync_op = "write data";
223 post_sync_op = "reserved";
226 post_sync_op = "write TIMESTAMP";
229 instr_out(data, hw_offset, 0,
230 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
231 data[0] & (1 << 22) ?
232 " enable protected mem (BCS-only)," : "",
233 data[0] & (1 << 21) ? " store in hws," : "",
234 data[0] & (1 << 18) ? " invalidate tlb," : "",
235 data[0] & (1 << 17) ? " flush gfdt," : "",
237 data[0] & (1 << 8) ? " enable notify interrupt," : "",
239 " invalidate video state (BCS-only)," : "");
240 if (data[0] & (1 << 21))
241 instr_out(data, hw_offset, 1, "hws index\n");
243 instr_out(data, hw_offset, 1, "address\n");
244 instr_out(data, hw_offset, 2, "dword\n");
246 instr_out(data, hw_offset, 3, "upper dword\n");
250 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
252 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
255 instr_out(data, hw_offset, 0, "%s\n",
256 opcodes_mi[opcode].name);
257 for (i = 1; i < len; i++) {
259 BUFFER_FAIL(count, len,
260 opcodes_mi[opcode].name);
261 instr_out(data, hw_offset, i, "dword %d\n", i);
268 instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
273 decode_2d_br00(uint32_t *data, uint32_t count, uint32_t hw_offset,
276 instr_out(data, hw_offset, 0,
277 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
279 (data[count] & (1 << 20)) ? "en" : "dis",
280 (data[count] & (1 << 21)) ? "en" : "dis",
281 (data[count] >> 15) & 1, (data[count] >> 11) & 1);
284 static void decode_2d_br01(uint32_t *data, uint32_t count, uint32_t hw_offset)
287 switch ((data[count] >> 24) & 0x3) {
302 instr_out(data, hw_offset, count, "format %s, pitch %d, rop 0x%02x, "
303 "clipping %sabled, %s%s \n",
305 (short)(data[count] & 0xffff),
306 (data[count] >> 16) & 0xff,
307 data[count] & (1 << 30) ? "en" : "dis",
308 data[count] & (1 << 31) ? "solid pattern enabled, " : "",
309 data[count] & (1 << 31) ?
310 "mono pattern transparency enabled, " : "");
315 decode_2d(struct drm_intel_decode *ctx)
317 unsigned int opcode, len;
318 uint32_t *data = ctx->data;
319 uint32_t hw_offset = ctx->hw_offset;
320 uint32_t count = ctx->count;
324 unsigned int min_len;
325 unsigned int max_len;
328 { 0x40, 5, 5, "COLOR_BLT" },
329 { 0x43, 6, 6, "SRC_COPY_BLT" },
330 { 0x01, 8, 8, "XY_SETUP_BLT" },
331 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
332 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
333 { 0x24, 2, 2, "XY_PIXEL_BLT" },
334 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
335 { 0x26, 4, 4, "Y_TEXT_BLT" },
336 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
337 { 0x50, 6, 6, "XY_COLOR_BLT" },
338 { 0x51, 6, 6, "XY_PAT_BLT" },
339 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
340 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
341 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
342 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
343 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
344 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
345 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
346 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
347 { 0x55, 9, 9, "XY_FULL_BLT" },
348 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
349 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
350 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
351 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
352 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
355 switch ((data[0] & 0x1fc00000) >> 22) {
357 instr_out(data, hw_offset, 0,
358 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
359 (data[0] >> 12) & 0x8,
360 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
362 len = (data[0] & 0x000000ff) + 2;
364 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
366 BUFFER_FAIL(count, len, "XY_SCANLINES_BLT");
368 instr_out(data, hw_offset, 1, "dest (%d,%d)\n",
369 data[1] & 0xffff, data[1] >> 16);
370 instr_out(data, hw_offset, 2, "dest (%d,%d)\n",
371 data[2] & 0xffff, data[2] >> 16);
374 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_BLT");
376 len = (data[0] & 0x000000ff) + 2;
378 fprintf(out, "Bad count in XY_SETUP_BLT\n");
380 BUFFER_FAIL(count, len, "XY_SETUP_BLT");
382 decode_2d_br01(data, 1, hw_offset);
383 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
384 data[2] & 0xffff, data[2] >> 16);
385 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
386 data[3] & 0xffff, data[3] >> 16);
387 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
389 instr_out(data, hw_offset, 5, "setup background color\n");
390 instr_out(data, hw_offset, 6, "setup foreground color\n");
391 instr_out(data, hw_offset, 7, "color pattern offset\n");
394 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_CLIP_BLT");
396 len = (data[0] & 0x000000ff) + 2;
398 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
400 BUFFER_FAIL(count, len, "XY_SETUP_CLIP_BLT");
402 instr_out(data, hw_offset, 1, "cliprect (%d,%d)\n",
403 data[1] & 0xffff, data[2] >> 16);
404 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
405 data[2] & 0xffff, data[3] >> 16);
408 decode_2d_br00(data, 0, hw_offset,
409 "XY_SETUP_MONO_PATTERN_SL_BLT");
411 len = (data[0] & 0x000000ff) + 2;
414 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
416 BUFFER_FAIL(count, len, "XY_SETUP_MONO_PATTERN_SL_BLT");
418 decode_2d_br01(data, 1, hw_offset);
419 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
420 data[2] & 0xffff, data[2] >> 16);
421 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
422 data[3] & 0xffff, data[3] >> 16);
423 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
425 instr_out(data, hw_offset, 5, "setup background color\n");
426 instr_out(data, hw_offset, 6, "setup foreground color\n");
427 instr_out(data, hw_offset, 7, "mono pattern dw0\n");
428 instr_out(data, hw_offset, 8, "mono pattern dw1\n");
431 decode_2d_br00(data, 0, hw_offset, "XY_COLOR_BLT");
433 len = (data[0] & 0x000000ff) + 2;
435 fprintf(out, "Bad count in XY_COLOR_BLT\n");
437 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
439 decode_2d_br01(data, 1, hw_offset);
440 instr_out(data, hw_offset, 2, "(%d,%d)\n",
441 data[2] & 0xffff, data[2] >> 16);
442 instr_out(data, hw_offset, 3, "(%d,%d)\n",
443 data[3] & 0xffff, data[3] >> 16);
444 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
445 instr_out(data, hw_offset, 5, "color\n");
448 decode_2d_br00(data, 0, hw_offset, "XY_SRC_COPY_BLT");
450 len = (data[0] & 0x000000ff) + 2;
452 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
454 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
456 decode_2d_br01(data, 1, hw_offset);
457 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
458 data[2] & 0xffff, data[2] >> 16);
459 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
460 data[3] & 0xffff, data[3] >> 16);
461 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
462 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
463 data[5] & 0xffff, data[5] >> 16);
464 instr_out(data, hw_offset, 6, "src pitch %d\n",
465 (short)(data[6] & 0xffff));
466 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
470 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
472 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
476 instr_out(data, hw_offset, 0, "%s\n",
477 opcodes_2d[opcode].name);
478 if (opcodes_2d[opcode].max_len > 1) {
479 len = (data[0] & 0x000000ff) + 2;
480 if (len < opcodes_2d[opcode].min_len ||
481 len > opcodes_2d[opcode].max_len) {
482 fprintf(out, "Bad count in %s\n",
483 opcodes_2d[opcode].name);
487 for (i = 1; i < len; i++) {
489 BUFFER_FAIL(count, len,
490 opcodes_2d[opcode].name);
491 instr_out(data, hw_offset, i, "dword %d\n", i);
498 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
503 decode_3d_1c(struct drm_intel_decode *ctx)
505 uint32_t *data = ctx->data;
506 uint32_t hw_offset = ctx->hw_offset;
509 opcode = (data[0] & 0x00f80000) >> 19;
513 instr_out(data, hw_offset, 0,
514 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
517 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
518 data[0] & 1 ? "enabled" : "disabled");
521 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
524 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
527 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
531 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
536 /** Sets the string dstname to describe the destination of the PS instruction */
538 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
540 uint32_t a0 = data[i];
541 int dst_nr = (a0 >> 14) & 0xf;
546 if (((a0 >> 10) & 0xf) == 0xf) {
549 int dstmask_index = 0;
551 dstmask[dstmask_index++] = '.';
553 dstmask[dstmask_index++] = 'x';
555 dstmask[dstmask_index++] = 'y';
557 dstmask[dstmask_index++] = 'z';
559 dstmask[dstmask_index++] = 'w';
560 dstmask[dstmask_index++] = 0;
572 switch ((a0 >> 19) & 0x7) {
575 fprintf(out, "bad destination reg R%d\n", dst_nr);
576 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
580 fprintf(out, "bad destination reg oC%d\n", dst_nr);
581 sprintf(dstname, "oC%s%s", dstmask, sat);
585 fprintf(out, "bad destination reg oD%d\n", dst_nr);
586 sprintf(dstname, "oD%s%s", dstmask, sat);
590 fprintf(out, "bad destination reg U%d\n", dst_nr);
591 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
594 sprintf(dstname, "RESERVED");
600 i915_get_channel_swizzle(uint32_t select)
602 switch (select & 0x7) {
604 return (select & 8) ? "-x" : "x";
606 return (select & 8) ? "-y" : "y";
608 return (select & 8) ? "-z" : "z";
610 return (select & 8) ? "-w" : "w";
612 return (select & 8) ? "-0" : "0";
614 return (select & 8) ? "-1" : "1";
616 return (select & 8) ? "-bad" : "bad";
621 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
625 sprintf(name, "R%d", src_nr);
627 fprintf(out, "bad src reg %s\n", name);
631 sprintf(name, "T%d", src_nr);
632 else if (src_nr == 8)
633 sprintf(name, "DIFFUSE");
634 else if (src_nr == 9)
635 sprintf(name, "SPECULAR");
636 else if (src_nr == 10)
637 sprintf(name, "FOG");
639 fprintf(out, "bad src reg T%d\n", src_nr);
640 sprintf(name, "RESERVED");
644 sprintf(name, "C%d", src_nr);
646 fprintf(out, "bad src reg %s\n", name);
651 fprintf(out, "bad src reg oC%d\n", src_nr);
656 fprintf(out, "bad src reg oD%d\n", src_nr);
659 sprintf(name, "U%d", src_nr);
661 fprintf(out, "bad src reg %s\n", name);
664 fprintf(out, "bad src reg type %d\n", src_type);
665 sprintf(name, "RESERVED");
670 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
672 uint32_t a0 = data[i];
673 uint32_t a1 = data[i + 1];
674 int src_nr = (a0 >> 2) & 0x1f;
675 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
676 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
677 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
678 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
681 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
682 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
684 if (strcmp(swizzle, ".xyzw") != 0)
685 strcat(srcname, swizzle);
688 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
690 uint32_t a1 = data[i + 1];
691 uint32_t a2 = data[i + 2];
692 int src_nr = (a1 >> 8) & 0x1f;
693 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
694 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
695 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
696 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
699 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
700 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
702 if (strcmp(swizzle, ".xyzw") != 0)
703 strcat(srcname, swizzle);
706 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
708 uint32_t a2 = data[i + 2];
709 int src_nr = (a2 >> 16) & 0x1f;
710 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
711 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
712 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
713 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
716 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
717 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
719 if (strcmp(swizzle, ".xyzw") != 0)
720 strcat(srcname, swizzle);
724 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
728 sprintf(name, "R%d", src_nr);
730 fprintf(out, "bad src reg %s\n", name);
734 sprintf(name, "T%d", src_nr);
735 else if (src_nr == 8)
736 sprintf(name, "DIFFUSE");
737 else if (src_nr == 9)
738 sprintf(name, "SPECULAR");
739 else if (src_nr == 10)
740 sprintf(name, "FOG");
742 fprintf(out, "bad src reg T%d\n", src_nr);
743 sprintf(name, "RESERVED");
749 fprintf(out, "bad src reg oC%d\n", src_nr);
754 fprintf(out, "bad src reg oD%d\n", src_nr);
757 fprintf(out, "bad src reg type %d\n", src_type);
758 sprintf(name, "RESERVED");
764 i915_decode_alu1(uint32_t *data, uint32_t hw_offset,
765 int i, char *instr_prefix, const char *op_name)
767 char dst[100], src0[100];
769 i915_get_instruction_dst(data, i, dst, 1);
770 i915_get_instruction_src0(data, i, src0);
772 instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
774 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
775 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
779 i915_decode_alu2(uint32_t *data, uint32_t hw_offset,
780 int i, char *instr_prefix, const char *op_name)
782 char dst[100], src0[100], src1[100];
784 i915_get_instruction_dst(data, i, dst, 1);
785 i915_get_instruction_src0(data, i, src0);
786 i915_get_instruction_src1(data, i, src1);
788 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
789 op_name, dst, src0, src1);
790 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
791 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
795 i915_decode_alu3(uint32_t *data, uint32_t hw_offset,
796 int i, char *instr_prefix, const char *op_name)
798 char dst[100], src0[100], src1[100], src2[100];
800 i915_get_instruction_dst(data, i, dst, 1);
801 i915_get_instruction_src0(data, i, src0);
802 i915_get_instruction_src1(data, i, src1);
803 i915_get_instruction_src2(data, i, src2);
805 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
806 op_name, dst, src0, src1, src2);
807 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
808 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
812 i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i,
813 const char *instr_prefix, const char *tex_name)
815 uint32_t t0 = data[i];
816 uint32_t t1 = data[i + 1];
821 i915_get_instruction_dst(data, i, dst_name, 0);
822 i915_get_instruction_addr((t1 >> 24) & 0x7,
823 (t1 >> 17) & 0xf, addr_name);
824 sampler_nr = t0 & 0xf;
826 instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
827 tex_name, dst_name, sampler_nr, addr_name);
828 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
829 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
833 i915_decode_dcl(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
835 uint32_t d0 = data[i];
836 const char *sampletype;
837 int dcl_nr = (d0 >> 14) & 0xf;
838 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
839 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
840 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
841 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
844 switch ((d0 >> 19) & 0x3) {
846 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
847 if (strcmp(dcl_mask, ".") == 0)
848 fprintf(out, "bad (empty) dcl mask\n");
851 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
853 if (strcmp(dcl_mask, ".x") != 0 &&
854 strcmp(dcl_mask, ".xy") != 0 &&
855 strcmp(dcl_mask, ".xz") != 0 &&
856 strcmp(dcl_mask, ".w") != 0 &&
857 strcmp(dcl_mask, ".xyzw") != 0) {
858 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
861 instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n",
862 instr_prefix, dcl_nr, dcl_mask);
864 if (strcmp(dcl_mask, ".xz") == 0)
865 fprintf(out, "errataed bad dcl mask %s\n",
867 else if (strcmp(dcl_mask, ".xw") == 0)
868 fprintf(out, "errataed bad dcl mask %s\n",
870 else if (strcmp(dcl_mask, ".xzw") == 0)
871 fprintf(out, "errataed bad dcl mask %s\n",
875 instr_out(data, hw_offset, i++,
876 "%s: DCL DIFFUSE%s\n", instr_prefix,
878 } else if (dcl_nr == 9) {
879 instr_out(data, hw_offset, i++,
880 "%s: DCL SPECULAR%s\n", instr_prefix,
882 } else if (dcl_nr == 10) {
883 instr_out(data, hw_offset, i++,
884 "%s: DCL FOG%s\n", instr_prefix,
888 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
889 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
892 switch ((d0 >> 22) & 0x3) {
903 sampletype = "RESERVED";
907 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
908 instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n",
909 instr_prefix, dcl_nr, sampletype);
910 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
911 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
914 instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n",
915 instr_prefix, dcl_nr);
916 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
917 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
922 i915_decode_instruction(uint32_t *data, uint32_t hw_offset,
923 int i, char *instr_prefix)
925 switch ((data[i] >> 24) & 0x1f) {
927 instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
928 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
929 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
932 i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
935 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
938 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
941 i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
944 i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
947 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
950 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
953 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
956 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
959 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
962 i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
965 i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
968 i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
971 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
974 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
977 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
980 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
983 i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
986 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
989 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
992 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
995 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
998 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
1001 i915_decode_dcl(data, hw_offset, i, instr_prefix);
1004 instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
1005 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1006 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1012 decode_compare_func(uint32_t op)
1036 decode_stencil_op(uint32_t op)
1061 decode_logic_op(uint32_t op)
1102 decode_blend_fact(uint32_t op)
1112 return "inv_src_colr";
1116 return "inv_src_alpha";
1120 return "inv_dst_alpha";
1124 return "inv_dst_colr";
1126 return "src_alpha_sat";
1130 return "inv_cnst_colr";
1132 return "cnst_alpha";
1134 return "inv_const_alpha";
1140 decode_tex_coord_mode(uint32_t mode)
1142 switch (mode & 0x7) {
1148 return "clamp_edge";
1152 return "clamp_border";
1154 return "mirror_once";
1160 decode_sample_filter(uint32_t mode)
1162 switch (mode & 0x7) {
1168 return "anisotropic";
1182 decode_3d_1d(struct drm_intel_decode *ctx)
1184 unsigned int len, i, c, idx, word, map, sampler, instr;
1185 const char *format, *zformat, *type;
1187 uint32_t hw_offset = ctx->hw_offset;
1188 uint32_t *data = ctx->data;
1189 uint32_t count = ctx->count;
1190 uint32_t devid = ctx->devid;
1195 unsigned int min_len;
1196 unsigned int max_len;
1198 } opcodes_3d_1d[] = {
1199 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1200 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1201 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1202 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1203 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1204 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1205 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1206 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1207 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1208 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1209 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1210 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1211 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1212 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1213 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1214 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1217 opcode = (data[0] & 0x00ff0000) >> 16;
1221 /* This instruction is unusual. A 0 length means just
1222 * 1 DWORD instead of 2. The 0 length is specified in
1223 * one place to be unsupported, but stated to be
1224 * required in another, and 0 length LOAD_INDIRECTs
1225 * appear to cause no harm at least.
1227 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
1228 len = (data[0] & 0x000000ff) + 1;
1230 if (data[0] & (0x01 << 8)) {
1232 BUFFER_FAIL(count, len,
1233 "3DSTATE_LOAD_INDIRECT");
1234 instr_out(data, hw_offset, i++, "SIS.0\n");
1235 instr_out(data, hw_offset, i++, "SIS.1\n");
1237 if (data[0] & (0x02 << 8)) {
1239 BUFFER_FAIL(count, len,
1240 "3DSTATE_LOAD_INDIRECT");
1241 instr_out(data, hw_offset, i++, "DIS.0\n");
1243 if (data[0] & (0x04 << 8)) {
1245 BUFFER_FAIL(count, len,
1246 "3DSTATE_LOAD_INDIRECT");
1247 instr_out(data, hw_offset, i++, "SSB.0\n");
1248 instr_out(data, hw_offset, i++, "SSB.1\n");
1250 if (data[0] & (0x08 << 8)) {
1252 BUFFER_FAIL(count, len,
1253 "3DSTATE_LOAD_INDIRECT");
1254 instr_out(data, hw_offset, i++, "MSB.0\n");
1255 instr_out(data, hw_offset, i++, "MSB.1\n");
1257 if (data[0] & (0x10 << 8)) {
1259 BUFFER_FAIL(count, len,
1260 "3DSTATE_LOAD_INDIRECT");
1261 instr_out(data, hw_offset, i++, "PSP.0\n");
1262 instr_out(data, hw_offset, i++, "PSP.1\n");
1264 if (data[0] & (0x20 << 8)) {
1266 BUFFER_FAIL(count, len,
1267 "3DSTATE_LOAD_INDIRECT");
1268 instr_out(data, hw_offset, i++, "PSC.0\n");
1269 instr_out(data, hw_offset, i++, "PSC.1\n");
1272 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1277 instr_out(data, hw_offset, 0,
1278 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1279 len = (data[0] & 0x0000000f) + 2;
1281 for (word = 0; word <= 8; word++) {
1282 if (data[0] & (1 << (4 + word))) {
1284 BUFFER_FAIL(count, len,
1285 "3DSTATE_LOAD_STATE_IMMEDIATE_1");
1287 /* save vertex state for decode */
1288 if (!IS_GEN2(devid)) {
1302 instr_out(data, hw_offset, i,
1303 "S0: vbo offset: 0x%08x%s\n",
1306 ", auto cache invalidate disabled"
1310 instr_out(data, hw_offset, i,
1311 "S1: vertex width: %i, vertex pitch: %i\n",
1318 instr_out(data, hw_offset, i,
1319 "S2: texcoord formats: ");
1321 tex_num < 8; tex_num++) {
1366 instr_out(data, hw_offset, i,
1367 "S3: not documented\n");
1371 const char *cullmode = "";
1372 const char *vfmt_xyzw = "";
1373 switch ((data[i] >> 13)
1410 case 1 << 6 | 1 << 2:
1414 case 2 << 6 | 1 << 2:
1418 case 3 << 6 | 1 << 2:
1422 case 4 << 6 | 1 << 2:
1429 "S4: point_width=%i, line_width=%.1f,"
1430 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1493 "force default diffuse, "
1499 "force default specular, "
1505 "local depth ofs enable, "
1511 "point sprite enable, "
1526 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1527 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1528 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1558 " force default point size,"
1564 " last pixel enable,"
1570 " global depth ofs enable,"
1596 "stencil write enable, "
1602 "stencil test enable, "
1608 "color dither enable, "
1619 instr_out(data, hw_offset, i,
1620 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1621 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1622 "%s%stristrip_provoking_vertex=%i\n",
1623 data[i] & (1 << 31) ?
1624 "alpha test enable, "
1632 data[i] & (1 << 15) ?
1633 "cbuf blend enable, "
1635 decode_blend_fact(data
1639 decode_blend_fact(data
1643 data[i] & (1 << 3) ?
1644 "depth write enable, "
1646 data[i] & (1 << 2) ?
1647 "cbuf write enable, "
1652 instr_out(data, hw_offset, i,
1653 "S7: depth offset constant: 0x%08x\n",
1658 instr_out(data, hw_offset, i,
1659 "S%d: 0x%08x\n", i, data[i]);
1666 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1670 instr_out(data, hw_offset, 0,
1671 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1672 len = (data[0] & 0x0000000f) + 2;
1674 for (word = 6; word <= 14; word++) {
1675 if (data[0] & (1 << word)) {
1677 BUFFER_FAIL(count, len,
1678 "3DSTATE_LOAD_STATE_IMMEDIATE_2");
1681 instr_out(data, hw_offset, i++,
1683 else if (word >= 7 && word <= 10) {
1684 instr_out(data, hw_offset, i++,
1685 "TB%dC\n", word - 7);
1686 instr_out(data, hw_offset, i++,
1687 "TB%dA\n", word - 7);
1688 } else if (word >= 11 && word <= 14) {
1689 instr_out(data, hw_offset, i,
1690 "TM%dS0: offset=0x%08x, %s\n",
1692 data[i] & 0xfffffffe,
1693 data[i] & 1 ? "use fence" :
1696 instr_out(data, hw_offset, i,
1697 "TM%dS1: height=%i, width=%i, %s\n",
1698 word - 11, data[i] >> 21,
1699 (data[i] >> 10) & 0x3ff,
1700 data[i] & 2 ? (data[i] & 1 ?
1705 instr_out(data, hw_offset, i,
1706 "TM%dS2: pitch=%i, \n",
1708 ((data[i] >> 21) + 1) * 4);
1710 instr_out(data, hw_offset, i++,
1711 "TM%dS3\n", word - 11);
1712 instr_out(data, hw_offset, i++,
1713 "TM%dS4: dflt color\n",
1720 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1724 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
1725 len = (data[0] & 0x0000003f) + 2;
1726 instr_out(data, hw_offset, 1, "mask\n");
1729 for (map = 0; map <= 15; map++) {
1730 if (data[1] & (1 << map)) {
1731 int width, height, pitch, dword;
1735 BUFFER_FAIL(count, len,
1736 "3DSTATE_MAP_STATE");
1739 instr_out(data, hw_offset, i++,
1740 "map %d MS2 %s%s%s\n", map,
1742 "untrusted surface, " : "",
1744 "vertical line stride enable, " : "",
1746 "vertical ofs enable, " : "");
1749 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1750 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1753 if (dword & (1 << 2))
1755 else if (dword & (1 << 1))
1756 tiling = dword & (1 << 0) ? "Y" : "X";
1759 switch ((dword >> 7) & 0x7) {
1762 switch ((dword >> 3) & 0xf) {
1779 switch ((dword >> 3) & 0xf) {
1784 format = " argb1555";
1787 format = " argb4444";
1793 format = " bump655";
1808 switch ((dword >> 3) & 0xf) {
1810 format = " argb8888";
1813 format = " abgr8888";
1816 format = " xrgb8888";
1819 format = " xbgr8888";
1822 format = " qwvu8888";
1825 format = " axvu8888";
1828 format = " lxvu8888";
1831 format = " xlvu8888";
1834 format = " argb2101010";
1837 format = " abgr2101010";
1840 format = " awvu2101010";
1861 switch ((dword >> 3) & 0xf) {
1863 format = " yuv_swapy";
1869 format = " yuv_swapuv";
1872 format = " yuv_swapuvy";
1877 type = "compressed";
1878 switch ((dword >> 3) & 0x7) {
1892 format = " dxt1_rb";
1897 type = "4b indexed";
1898 switch ((dword >> 3) & 0xf) {
1900 format = " argb8888";
1906 instr_out(data, hw_offset, i++,
1907 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1908 map, width, height, type, format,
1910 dword & (1 << 9) ? " palette select" :
1915 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1916 instr_out(data, hw_offset, i++,
1917 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1918 map, pitch, (dword >> 9) & 0x3f,
1919 dword & 0xff, (dword >> 15) & 0x3f,
1920 dword & (1 << 8) ? "miplayout legacy"
1921 : "miplayout right");
1925 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1930 instr_out(data, hw_offset, 0,
1931 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1932 len = (data[0] & 0x000000ff) + 2;
1935 for (c = 0; c <= 31; c++) {
1936 if (data[1] & (1 << c)) {
1938 BUFFER_FAIL(count, len,
1939 "3DSTATE_PIXEL_SHADER_CONSTANTS");
1940 instr_out(data, hw_offset, i, "C%d.X = %f\n", c,
1941 int_as_float(data[i]));
1943 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
1944 c, int_as_float(data[i]));
1946 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
1947 c, int_as_float(data[i]));
1949 instr_out(data, hw_offset, i, "C%d.W = %f\n",
1950 c, int_as_float(data[i]));
1956 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1960 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1961 len = (data[0] & 0x000000ff) + 2;
1962 if ((len - 1) % 3 != 0 || len > 370) {
1964 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1967 for (instr = 0; instr < (len - 1) / 3; instr++) {
1968 char instr_prefix[10];
1971 BUFFER_FAIL(count, len,
1972 "3DSTATE_PIXEL_SHADER_PROGRAM");
1973 sprintf(instr_prefix, "PS%03d", instr);
1974 i915_decode_instruction(data, hw_offset, i,
1982 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
1983 instr_out(data, hw_offset, 1, "mask\n");
1984 len = (data[0] & 0x0000003f) + 2;
1986 for (sampler = 0; sampler <= 15; sampler++) {
1987 if (data[1] & (1 << sampler)) {
1989 const char *mip_filter = "";
1991 BUFFER_FAIL(count, len,
1992 "3DSTATE_SAMPLER_STATE");
1994 switch ((dword >> 20) & 0x3) {
1996 mip_filter = "none";
1999 mip_filter = "nearest";
2002 mip_filter = "linear";
2005 instr_out(data, hw_offset, i++,
2006 "sampler %d SS2:%s%s%s "
2007 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
2008 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
2010 dword & (1 << 31) ? " reverse gamma,"
2012 dword & (1 << 30) ? " packed2planar,"
2015 " colorspace conversion," : "",
2016 (dword >> 22) & 0x1f, mip_filter,
2017 decode_sample_filter(dword >> 17),
2018 decode_sample_filter(dword >> 14),
2019 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2020 dword & (1 << 4) ? " shadow," : "",
2021 dword & (1 << 3) ? 4 : 2,
2022 decode_compare_func(dword));
2024 instr_out(data, hw_offset, i++,
2025 "sampler %d SS3: min_lod=%.2f,%s "
2026 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2028 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2030 " kill pixel enable," : "",
2031 decode_tex_coord_mode(dword >> 12),
2032 decode_tex_coord_mode(dword >> 9),
2033 decode_tex_coord_mode(dword >> 6),
2035 " normalized coords," : "",
2037 dword & (1 << 0) ? " deinterlacer," :
2040 instr_out(data, hw_offset, i++,
2041 "sampler %d SS4: border color\n",
2046 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2050 len = (data[0] & 0x0000000f) + 2;
2054 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2056 BUFFER_FAIL(count, len,
2057 "3DSTATE_DEST_BUFFER_VARIABLES");
2059 instr_out(data, hw_offset, 0,
2060 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2062 switch ((data[1] >> 8) & 0xf) {
2067 format = "x1r5g5b5";
2073 format = "a8r8g8b8";
2076 format = "ycrcb_swapy";
2079 format = "ycrcb_normal";
2082 format = "ycrcb_swapuv";
2085 format = "ycrcb_swapuvy";
2088 format = "a4r4g4b4";
2091 format = "a1r5g5b5";
2094 format = "a2r10g10b10";
2100 switch ((data[1] >> 2) & 0x3) {
2114 instr_out(data, hw_offset, 1,
2115 "%s format, %s depth format, early Z %sabled\n",
2117 (data[1] & (1 << 31)) ? "en" : "dis");
2122 const char *name, *tiling;
2124 len = (data[0] & 0x0000000f) + 2;
2127 "Bad count in 3DSTATE_BUFFER_INFO\n");
2129 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
2131 switch ((data[1] >> 24) & 0x7) {
2144 if (data[1] & (1 << 23))
2146 else if (data[1] & (1 << 22))
2147 tiling = data[1] & (1 << 21) ? "Y" : "X";
2149 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
2150 instr_out(data, hw_offset, 1,
2151 "%s, tiling = %s, pitch=%d\n", name, tiling,
2154 instr_out(data, hw_offset, 2, "address\n");
2158 len = (data[0] & 0x0000000f) + 2;
2162 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2164 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_RECTANGLE");
2166 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2167 instr_out(data, hw_offset, 1, "(%d,%d)\n",
2168 data[1] & 0xffff, data[1] >> 16);
2169 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2170 data[2] & 0xffff, data[2] >> 16);
2174 len = (data[0] & 0x0000000f) + 2;
2178 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2180 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2182 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2183 instr_out(data, hw_offset, 1, "%s\n",
2184 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2185 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2186 data[2] & 0xffff, data[2] >> 16);
2187 instr_out(data, hw_offset, 3, "(%d,%d)\n",
2188 data[3] & 0xffff, data[3] >> 16);
2189 instr_out(data, hw_offset, 4, "(%d,%d)\n",
2190 data[4] & 0xffff, data[4] >> 16);
2194 len = (data[0] & 0x0000000f) + 2;
2197 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2199 BUFFER_FAIL(count, len, "3DSTATE_CLEAR_PARAMETERS");
2201 instr_out(data, hw_offset, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2202 instr_out(data, hw_offset, 1, "prim_type=%s, clear=%s%s%s\n",
2203 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2204 data[1] & (1 << 2) ? "color," : "",
2205 data[1] & (1 << 1) ? "depth," : "",
2206 data[1] & (1 << 0) ? "stencil," : "");
2207 instr_out(data, hw_offset, 2, "clear color\n");
2208 instr_out(data, hw_offset, 3, "clear depth/stencil\n");
2209 instr_out(data, hw_offset, 4, "color value (rgba8888)\n");
2210 instr_out(data, hw_offset, 5, "depth value %f\n",
2211 int_as_float(data[5]));
2212 instr_out(data, hw_offset, 6, "clear stencil\n");
2216 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2217 opcode_3d_1d = &opcodes_3d_1d[idx];
2218 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2221 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2224 instr_out(data, hw_offset, 0, "%s\n",
2225 opcode_3d_1d->name);
2226 if (opcode_3d_1d->max_len > 1) {
2227 len = (data[0] & 0x0000ffff) + 2;
2228 if (len < opcode_3d_1d->min_len ||
2229 len > opcode_3d_1d->max_len) {
2230 fprintf(out, "Bad count in %s\n",
2231 opcode_3d_1d->name);
2235 for (i = 1; i < len; i++) {
2237 BUFFER_FAIL(count, len,
2238 opcode_3d_1d->name);
2239 instr_out(data, hw_offset, i, "dword %d\n", i);
2246 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2252 decode_3d_primitive(struct drm_intel_decode *ctx)
2254 uint32_t *data = ctx->data;
2255 uint32_t hw_offset = ctx->hw_offset;
2256 uint32_t count = ctx->count;
2257 char immediate = (data[0] & (1 << 23)) == 0;
2258 unsigned int len, i, j, ret;
2259 const char *primtype;
2260 int original_s2 = saved_s2;
2261 int original_s4 = saved_s4;
2263 switch ((data[0] >> 18) & 0xf) {
2265 primtype = "TRILIST";
2268 primtype = "TRISTRIP";
2271 primtype = "TRISTRIP_REVERSE";
2274 primtype = "TRIFAN";
2277 primtype = "POLYGON";
2280 primtype = "LINELIST";
2283 primtype = "LINESTRIP";
2286 primtype = "RECTLIST";
2289 primtype = "POINTLIST";
2295 primtype = "CLEAR_RECT";
2300 primtype = "unknown";
2304 /* XXX: 3DPRIM_DIB not supported */
2306 len = (data[0] & 0x0003ffff) + 2;
2307 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n",
2310 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2311 if (!saved_s2_set || !saved_s4_set) {
2312 fprintf(out, "unknown vertex format\n");
2313 for (i = 1; i < len; i++) {
2314 instr_out(data, hw_offset, i,
2315 " vertex data (%f float)\n",
2316 int_as_float(data[i]));
2319 unsigned int vertex = 0;
2320 for (i = 1; i < len;) {
2323 #define VERTEX_OUT(fmt, ...) do { \
2325 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2327 fprintf(out, " missing data in V%d\n", vertex); \
2331 VERTEX_OUT("X = %f", int_as_float(data[i]));
2332 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2333 switch (saved_s4 >> 6 & 0x7) {
2335 VERTEX_OUT("Z = %f",
2336 int_as_float(data[i]));
2339 VERTEX_OUT("Z = %f",
2340 int_as_float(data[i]));
2341 VERTEX_OUT("W = %f",
2342 int_as_float(data[i]));
2347 VERTEX_OUT("W = %f",
2348 int_as_float(data[i]));
2351 fprintf(out, "bad S4 position mask\n");
2354 if (saved_s4 & (1 << 10)) {
2356 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2357 "B=0x%02x)", data[i] >> 24,
2358 (data[i] >> 16) & 0xff,
2359 (data[i] >> 8) & 0xff,
2362 if (saved_s4 & (1 << 11)) {
2364 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2365 "B=0x%02x)", data[i] >> 24,
2366 (data[i] >> 16) & 0xff,
2367 (data[i] >> 8) & 0xff,
2370 if (saved_s4 & (1 << 12))
2371 VERTEX_OUT("width = 0x%08x)", data[i]);
2373 for (tc = 0; tc <= 7; tc++) {
2374 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2376 VERTEX_OUT("T%d.X = %f", tc,
2379 VERTEX_OUT("T%d.Y = %f", tc,
2384 VERTEX_OUT("T%d.X = %f", tc,
2387 VERTEX_OUT("T%d.Y = %f", tc,
2390 VERTEX_OUT("T%d.Z = %f", tc,
2395 VERTEX_OUT("T%d.X = %f", tc,
2398 VERTEX_OUT("T%d.Y = %f", tc,
2401 VERTEX_OUT("T%d.Z = %f", tc,
2404 VERTEX_OUT("T%d.W = %f", tc,
2409 VERTEX_OUT("T%d.X = %f", tc,
2415 ("T%d.XY = 0x%08x half-float",
2420 ("T%d.XY = 0x%08x half-float",
2423 ("T%d.ZW = 0x%08x half-float",
2430 "bad S2.T%d format\n",
2440 /* indirect vertices */
2441 len = data[0] & 0x0000ffff; /* index count */
2442 if (data[0] & (1 << 17)) {
2443 /* random vertex access */
2444 if (count < (len + 1) / 2 + 1) {
2445 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2446 "3DPRIMITIVE random indirect");
2448 instr_out(data, hw_offset, 0,
2449 "3DPRIMITIVE random indirect %s (%d)\n",
2452 /* vertex indices continue until 0xffff is
2455 for (i = 1; i < count; i++) {
2456 if ((data[i] & 0xffff) == 0xffff) {
2457 instr_out(data, hw_offset, i,
2458 " indices: (terminator)\n");
2461 } else if ((data[i] >> 16) == 0xffff) {
2462 instr_out(data, hw_offset, i,
2463 " indices: 0x%04x, (terminator)\n",
2468 instr_out(data, hw_offset, i,
2469 " indices: 0x%04x, 0x%04x\n",
2475 "3DPRIMITIVE: no terminator found in index buffer\n");
2479 /* fixed size vertex index buffer */
2480 for (j = 1, i = 0; i < len; i += 2, j++) {
2481 if (i * 2 == len - 1) {
2482 instr_out(data, hw_offset, j,
2483 " indices: 0x%04x\n",
2486 instr_out(data, hw_offset, j,
2487 " indices: 0x%04x, 0x%04x\n",
2493 ret = (len + 1) / 2 + 1;
2496 /* sequential vertex access */
2498 BUFFER_FAIL(count, 2,
2499 "3DPRIMITIVE seq indirect");
2500 instr_out(data, hw_offset, 0,
2501 "3DPRIMITIVE sequential indirect %s, %d starting from "
2502 "%d\n", primtype, len, data[1] & 0xffff);
2503 instr_out(data, hw_offset, 1, " start\n");
2510 saved_s2 = original_s2;
2511 saved_s4 = original_s4;
2516 decode_3d(struct drm_intel_decode *ctx)
2520 uint32_t *data = ctx->data;
2521 uint32_t hw_offset = ctx->hw_offset;
2522 uint32_t count = ctx->count;
2526 unsigned int min_len;
2527 unsigned int max_len;
2530 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2531 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2532 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2533 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2534 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2535 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2536 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2537 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2538 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2541 opcode = (data[0] & 0x1f000000) >> 24;
2545 return decode_3d_primitive(ctx);
2547 return decode_3d_1d(ctx);
2549 return decode_3d_1c(ctx);
2552 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2553 opcode_3d = &opcodes_3d[idx];
2554 if (opcode == opcode_3d->opcode) {
2555 unsigned int len = 1, i;
2557 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2558 if (opcode_3d->max_len > 1) {
2559 len = (data[0] & 0xff) + 2;
2560 if (len < opcode_3d->min_len ||
2561 len > opcode_3d->max_len) {
2562 fprintf(out, "Bad count in %s\n",
2567 for (i = 1; i < len; i++) {
2569 BUFFER_FAIL(count, len,
2571 instr_out(data, hw_offset, i, "dword %d\n", i);
2577 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2581 static const char *get_965_surfacetype(unsigned int surfacetype)
2583 switch (surfacetype) {
2601 static const char *get_965_depthformat(unsigned int depthformat)
2603 switch (depthformat) {
2605 return "s8_z24float";
2617 static const char *get_965_element_component(uint32_t data, int component)
2619 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2621 switch (component_control) {
2625 switch (component) {
2650 static const char *get_965_prim_type(uint32_t data)
2652 uint32_t primtype = (data >> 10) & 0x1f;
2656 return "point list";
2660 return "line strip";
2670 return "quad strip";
2672 return "line list adj";
2674 return "line strip adj";
2676 return "tri list adj";
2678 return "tri strip adj";
2680 return "tri strip reverse";
2688 return "point list bf";
2690 return "line strip cont";
2692 return "line strip bf";
2694 return "line strip cont bf";
2696 return "tri fan no stipple";
2703 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len,
2706 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2709 fprintf(out, "Bad count in URB_FENCE\n");
2711 BUFFER_FAIL(count, len, "URB_FENCE");
2713 vs_fence = data[1] & 0x3ff;
2714 gs_fence = (data[1] >> 10) & 0x3ff;
2715 clip_fence = (data[1] >> 20) & 0x3ff;
2716 sf_fence = data[2] & 0x3ff;
2717 vfe_fence = (data[2] >> 10) & 0x3ff;
2718 cs_fence = (data[2] >> 20) & 0x7ff;
2720 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2721 (data[0] >> 13) & 1 ? "cs " : "",
2722 (data[0] >> 12) & 1 ? "vfe " : "",
2723 (data[0] >> 11) & 1 ? "sf " : "",
2724 (data[0] >> 10) & 1 ? "clip " : "",
2725 (data[0] >> 9) & 1 ? "gs " : "",
2726 (data[0] >> 8) & 1 ? "vs " : "");
2727 instr_out(data, hw_offset, 1,
2728 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2729 vs_fence, clip_fence, gs_fence);
2730 instr_out(data, hw_offset, 2,
2731 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2732 sf_fence, vfe_fence, cs_fence);
2733 if (gs_fence < vs_fence)
2734 fprintf(out, "gs fence < vs fence!\n");
2735 if (clip_fence < gs_fence)
2736 fprintf(out, "clip fence < gs fence!\n");
2737 if (sf_fence < clip_fence)
2738 fprintf(out, "sf fence < clip fence!\n");
2739 if (cs_fence < sf_fence)
2740 fprintf(out, "cs fence < sf fence!\n");
2746 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2749 if (data[index] & 1) {
2750 instr_out(data, hw_offset, index,
2751 "%s state base address 0x%08x\n", name,
2754 instr_out(data, hw_offset, index, "%s state base not updated\n",
2760 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2763 if (data[index] & 1) {
2764 if (data[index] == 1) {
2765 instr_out(data, hw_offset, index,
2766 "%s state upper bound disabled\n", name);
2768 instr_out(data, hw_offset, index,
2769 "%s state upper bound 0x%08x\n", name,
2773 instr_out(data, hw_offset, index,
2774 "%s state upper bound not updated\n", name);
2779 decode_3d_965(struct drm_intel_decode *ctx)
2782 unsigned int idx, len;
2783 unsigned int i, j, sba_len;
2784 const char *desc1 = NULL;
2785 uint32_t *data = ctx->data;
2786 uint32_t hw_offset = ctx->hw_offset;
2787 uint32_t count = ctx->count;
2788 uint32_t devid = ctx->devid;
2792 int unsigned min_len;
2793 int unsigned max_len;
2796 { 0x6000, 3, 3, "URB_FENCE" },
2797 { 0x6001, 2, 2, "CS_URB_STATE" },
2798 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
2799 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
2800 { 0x6102, 2, 2, "STATE_SIP" },
2801 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2802 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
2803 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2804 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
2805 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
2806 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
2807 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
2808 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
2809 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
2810 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
2811 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
2812 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
2813 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
2814 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
2815 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
2816 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
2817 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2818 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
2819 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
2820 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
2821 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2822 { 0x7b00, 6, 6, "3DPRIMITIVE" },
2823 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
2824 { 0x7805, 3, 3, "3DSTATE_URB" },
2825 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
2826 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
2827 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
2828 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
2829 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
2830 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
2831 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
2832 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
2833 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
2834 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
2835 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
2836 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK"},
2839 len = (data[0] & 0x0000ffff) + 2;
2841 opcode = (data[0] & 0xffff0000) >> 16;
2844 len = (data[0] & 0x000000ff) + 2;
2845 return i965_decode_urb_fence(data, hw_offset, len, count);
2847 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
2848 instr_out(data, hw_offset, 1,
2849 "entry_size: %d [%d bytes], n_entries: %d\n",
2850 (data[1] >> 4) & 0x1f,
2851 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
2854 len = (data[0] & 0x000000ff) + 2;
2855 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
2856 (data[0] >> 8) & 1 ? "valid" : "invalid");
2857 instr_out(data, hw_offset, 1,
2858 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
2859 ((data[1] & 0x3f) + 1) * 64);
2863 instr_out(data, hw_offset, 0, "STATE_BASE_ADDRESS\n");
2866 if (IS_GEN6(devid) || IS_GEN7(devid))
2868 else if (IS_GEN5(devid))
2873 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
2875 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
2877 state_base_out(data, hw_offset, i++, "general");
2878 state_base_out(data, hw_offset, i++, "surface");
2879 if (IS_GEN6(devid) || IS_GEN7(devid))
2880 state_base_out(data, hw_offset, i++, "dynamic");
2881 state_base_out(data, hw_offset, i++, "indirect");
2882 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2883 state_base_out(data, hw_offset, i++, "instruction");
2885 state_max_out(data, hw_offset, i++, "general");
2886 if (IS_GEN6(devid) || IS_GEN7(devid))
2887 state_max_out(data, hw_offset, i++, "dynamic");
2888 state_max_out(data, hw_offset, i++, "indirect");
2889 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2890 state_max_out(data, hw_offset, i++, "instruction");
2896 "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
2898 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
2900 instr_out(data, hw_offset, 0, "3DSTATE_PIPELINED_POINTERS\n");
2901 instr_out(data, hw_offset, 1, "VS state\n");
2902 instr_out(data, hw_offset, 2, "GS state\n");
2903 instr_out(data, hw_offset, 3, "Clip state\n");
2904 instr_out(data, hw_offset, 4, "SF state\n");
2905 instr_out(data, hw_offset, 5, "WM state\n");
2906 instr_out(data, hw_offset, 6, "CC state\n");
2909 len = (data[0] & 0x000000ff) + 2;
2910 if (len != 6 && len != 4)
2912 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
2915 BUFFER_FAIL(count, len,
2916 "3DSTATE_BINDING_TABLE_POINTERS");
2917 instr_out(data, hw_offset, 0,
2918 "3DSTATE_BINDING_TABLE_POINTERS\n");
2919 instr_out(data, hw_offset, 1, "VS binding table\n");
2920 instr_out(data, hw_offset, 2, "GS binding table\n");
2921 instr_out(data, hw_offset, 3, "Clip binding table\n");
2922 instr_out(data, hw_offset, 4, "SF binding table\n");
2923 instr_out(data, hw_offset, 5, "WM binding table\n");
2926 BUFFER_FAIL(count, len,
2927 "3DSTATE_BINDING_TABLE_POINTERS");
2929 instr_out(data, hw_offset, 0,
2930 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
2931 "GS mod %d, PS mod %d\n",
2932 (data[0] & (1 << 8)) != 0,
2933 (data[0] & (1 << 9)) != 0,
2934 (data[0] & (1 << 12)) != 0);
2935 instr_out(data, hw_offset, 1, "VS binding table\n");
2936 instr_out(data, hw_offset, 2, "GS binding table\n");
2937 instr_out(data, hw_offset, 3, "WM binding table\n");
2942 len = (data[0] & 0xff) + 2;
2945 "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
2947 BUFFER_FAIL(count, len,
2948 "3DSTATE_SAMPLER_STATE_POINTERS");
2949 instr_out(data, hw_offset, 0,
2950 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
2951 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
2952 (data[0] & (1 << 9)) != 0,
2953 (data[0] & (1 << 12)) != 0);
2954 instr_out(data, hw_offset, 1, "VS sampler state\n");
2955 instr_out(data, hw_offset, 2, "GS sampler state\n");
2956 instr_out(data, hw_offset, 3, "WM sampler state\n");
2959 len = (data[0] & 0xff) + 2;
2961 fprintf(out, "Bad count in 3DSTATE_URB\n");
2963 BUFFER_FAIL(count, len, "3DSTATE_URB");
2964 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
2965 instr_out(data, hw_offset, 1,
2966 "VS entries %d, alloc size %d (1024bit row)\n",
2967 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
2968 instr_out(data, hw_offset, 2,
2969 "GS entries %d, alloc size %d (1024bit row)\n",
2970 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
2974 len = (data[0] & 0xff) + 2;
2975 if ((len - 1) % 4 != 0)
2976 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
2978 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
2979 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
2981 for (i = 1; i < len;) {
2983 if (IS_GEN6(devid)) {
2990 instr_out(data, hw_offset, i,
2991 "buffer %d: %s, pitch %db\n", data[i] >> idx,
2992 data[i] & (1 << access) ? "random" :
2993 "sequential", data[i] & 0x07ff);
2995 instr_out(data, hw_offset, i++, "buffer address\n");
2996 instr_out(data, hw_offset, i++, "max index\n");
2997 instr_out(data, hw_offset, i++, "mbz\n");
3002 len = (data[0] & 0xff) + 2;
3003 if ((len + 1) % 2 != 0)
3004 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3006 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
3007 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3009 for (i = 1; i < len;) {
3010 instr_out(data, hw_offset, i,
3011 "buffer %d: %svalid, type 0x%04x, "
3012 "src offset 0x%04x bytes\n",
3013 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3014 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3015 "" : "in", (data[i] >> 16) & 0x1ff,
3018 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
3019 "dst offset 0x%02x bytes\n",
3020 get_965_element_component(data[i], 0),
3021 get_965_element_component(data[i], 1),
3022 get_965_element_component(data[i], 2),
3023 get_965_element_component(data[i], 3),
3024 (data[i] & 0xff) * 4);
3030 len = (data[0] & 0xff) + 2;
3033 "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
3035 BUFFER_FAIL(count, len,
3036 "3DSTATE_VIEWPORT_STATE_POINTERS");
3037 instr_out(data, hw_offset, 0,
3038 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3039 instr_out(data, hw_offset, 1, "clip\n");
3040 instr_out(data, hw_offset, 2, "sf\n");
3041 instr_out(data, hw_offset, 3, "cc\n");
3045 len = (data[0] & 0xff) + 2;
3047 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
3049 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
3050 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
3051 instr_out(data, hw_offset, 1, "beginning buffer address\n");
3052 instr_out(data, hw_offset, 2, "ending buffer address\n");
3056 len = (data[0] & 0xff) + 2;
3059 "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
3061 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
3062 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
3063 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
3064 instr_out(data, hw_offset, 2, "depth stencil change %d\n",
3066 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
3070 len = (data[0] & 0xff) + 2;
3072 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
3074 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
3075 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
3076 instr_out(data, hw_offset, 1, "scissor rect offset\n");
3080 len = (data[0] & 0xff) + 2;
3082 fprintf(out, "Bad count in 3DSTATE_VS\n");
3084 BUFFER_FAIL(count, len, "3DSTATE_VS");
3085 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
3086 instr_out(data, hw_offset, 1, "kernel pointer\n");
3087 instr_out(data, hw_offset, 2,
3088 "SPF=%d, VME=%d, Sampler Count %d, "
3089 "Binding table count %d\n", (data[2] >> 31) & 1,
3090 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3091 (data[2] >> 18) & 0xff);
3092 instr_out(data, hw_offset, 3, "scratch offset\n");
3093 instr_out(data, hw_offset, 4,
3094 "Dispatch GRF start %d, VUE read length %d, "
3095 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3096 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3097 instr_out(data, hw_offset, 5,
3098 "Max Threads %d, Vertex Cache %sable, "
3099 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3100 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3101 (data[5] & 1) != 0 ? "en" : "dis");
3105 len = (data[0] & 0xff) + 2;
3107 fprintf(out, "Bad count in 3DSTATE_GS\n");
3109 BUFFER_FAIL(count, len, "3DSTATE_GS");
3110 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
3111 instr_out(data, hw_offset, 1, "kernel pointer\n");
3112 instr_out(data, hw_offset, 2,
3113 "SPF=%d, VME=%d, Sampler Count %d, "
3114 "Binding table count %d\n", (data[2] >> 31) & 1,
3115 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3116 (data[2] >> 18) & 0xff);
3117 instr_out(data, hw_offset, 3, "scratch offset\n");
3118 instr_out(data, hw_offset, 4,
3119 "Dispatch GRF start %d, VUE read length %d, "
3120 "VUE read offset %d\n", (data[4] & 0xf),
3121 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3122 instr_out(data, hw_offset, 5,
3123 "Max Threads %d, Rendering %sable\n",
3124 ((data[5] >> 25) & 0x7f) + 1,
3125 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3126 instr_out(data, hw_offset, 6,
3127 "Reorder %sable, Discard Adjaceny %sable, "
3129 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3130 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3131 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3135 len = (data[0] & 0xff) + 2;
3137 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
3139 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
3140 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
3141 instr_out(data, hw_offset, 1,
3142 "UserClip distance cull test mask 0x%x\n",
3144 instr_out(data, hw_offset, 2,
3145 "Clip %sable, API mode %s, Viewport XY test %sable, "
3146 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3147 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3148 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3149 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3150 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3151 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3152 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3153 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3154 (data[2] >> 13) & 7,
3155 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3156 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3157 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3159 instr_out(data, hw_offset, 3,
3160 "Min PointWidth %d, Max PointWidth %d, "
3161 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3162 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3163 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3168 len = (data[0] & 0xff) + 2;
3170 fprintf(out, "Bad count in 3DSTATE_SF\n");
3172 BUFFER_FAIL(count, len, "3DSTATE_SF");
3173 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
3174 instr_out(data, hw_offset, 1,
3175 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3176 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3177 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3178 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3179 instr_out(data, hw_offset, 2,
3180 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3181 "VP transform %sable, FrontWinding_%s\n",
3182 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3183 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3184 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3185 (data[2] & 1) != 0 ? "CCW" : "CW");
3186 instr_out(data, hw_offset, 3,
3187 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3188 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3189 (data[3] >> 29) & 3,
3190 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3191 (data[3] >> 8) & 3);
3192 instr_out(data, hw_offset, 4,
3193 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3194 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3195 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3196 (data[4] & (1 << 11)) != 0);
3197 instr_out(data, hw_offset, 5,
3198 "Global Depth Offset Constant %f\n",
3199 *(float *)(&data[5]));
3200 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n",
3201 *(float *)(&data[6]));
3202 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n",
3203 *(float *)(&data[7]));
3205 for (i = 0, j = 0; i < 8; i++, j += 2)
3206 instr_out(data, hw_offset, i + 8,
3207 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3208 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3210 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3211 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3212 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3213 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3214 (data[8 + i] >> 25) & 3,
3215 (data[8 + i] >> 22) & 3,
3216 (data[8 + i] >> 16) & 0x1f, j,
3217 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3218 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3219 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3220 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3221 (data[8 + i] >> 9) & 3,
3222 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3223 instr_out(data, hw_offset, 16,
3224 "Point Sprite TexCoord Enable\n");
3225 instr_out(data, hw_offset, 17, "Const Interp Enable\n");
3226 instr_out(data, hw_offset, 18,
3227 "Attrib 7-0 WrapShortest Enable\n");
3228 instr_out(data, hw_offset, 19,
3229 "Attrib 15-8 WrapShortest Enable\n");
3234 len = (data[0] & 0xff) + 2;
3236 fprintf(out, "Bad count in 3DSTATE_WM\n");
3238 BUFFER_FAIL(count, len, "3DSTATE_WM");
3239 instr_out(data, hw_offset, 0, "3DSTATE_WM\n");
3240 instr_out(data, hw_offset, 1, "kernel start pointer 0\n");
3241 instr_out(data, hw_offset, 2,
3242 "SPF=%d, VME=%d, Sampler Count %d, "
3243 "Binding table count %d\n", (data[2] >> 31) & 1,
3244 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3245 (data[2] >> 18) & 0xff);
3246 instr_out(data, hw_offset, 3, "scratch offset\n");
3247 instr_out(data, hw_offset, 4,
3248 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
3249 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
3250 (data[4] & (1 << 30)) != 0,
3251 (data[4] & (1 << 28)) != 0,
3252 (data[4] & (1 << 27)) != 0, (data[4] >> 16) & 0x7f,
3253 (data[4] >> 8) & 0x7f, (data[4] & 0x7f));
3254 instr_out(data, hw_offset, 5,
3255 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
3256 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
3257 "Dispatch16 %d, Dispatch8 %d\n",
3258 ((data[5] >> 25) & 0x7f) + 1,
3259 (data[5] & (1 << 22)) != 0,
3260 (data[5] & (1 << 21)) != 0,
3261 (data[5] & (1 << 20)) != 0,
3262 (data[5] & (1 << 19)) != 0, (data[5] & (1 << 8)) != 0,
3263 (data[5] & (1 << 2)) != 0, (data[5] & (1 << 1)) != 0,
3264 (data[5] & (1 << 0)) != 0);
3265 instr_out(data, hw_offset, 6,
3266 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
3267 "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
3268 "Multisample Dispatch mode %d\n",
3269 (data[6] >> 20) & 0x3f, (data[6] >> 18) & 3,
3270 (data[6] >> 16) & 3, (data[6] >> 10) & 0x3f,
3271 (data[6] & (1 << 9)) != 0, (data[6] >> 1) & 3,
3273 instr_out(data, hw_offset, 7, "kernel start pointer 1\n");
3274 instr_out(data, hw_offset, 8, "kernel start pointer 2\n");
3281 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
3283 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
3285 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3286 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
3287 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3288 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
3289 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3290 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
3291 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3296 if (len < 5 || len > 7)
3297 fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
3299 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
3301 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_BUFFER\n");
3302 if (IS_GEN5(devid) || IS_GEN6(devid))
3303 instr_out(data, hw_offset, 1,
3304 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3305 get_965_surfacetype(data[1] >> 29),
3306 get_965_depthformat((data[1] >> 18) & 0x7),
3307 (data[1] & 0x0001ffff) + 1,
3308 data[1] & (1 << 27) ? "" : "not ",
3309 (data[1] & (1 << 22)) != 0,
3310 (data[1] & (1 << 21)) != 0);
3312 instr_out(data, hw_offset, 1,
3313 "%s, %s, pitch = %d bytes, %stiled\n",
3314 get_965_surfacetype(data[1] >> 29),
3315 get_965_depthformat((data[1] >> 18) & 0x7),
3316 (data[1] & 0x0001ffff) + 1,
3317 data[1] & (1 << 27) ? "" : "not ");
3318 instr_out(data, hw_offset, 2, "depth offset\n");
3319 instr_out(data, hw_offset, 3, "%dx%d\n",
3320 ((data[3] & 0x0007ffc0) >> 6) + 1,
3321 ((data[3] & 0xfff80000) >> 19) + 1);
3322 instr_out(data, hw_offset, 4, "volume depth\n");
3324 instr_out(data, hw_offset, 5, "\n");
3327 instr_out(data, hw_offset, 6, "\n");
3329 instr_out(data, hw_offset, 6,
3330 "render target view extent\n");
3336 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3338 len = (data[0] & 0xff) + 2;
3339 if (len != 4 && len != 5)
3340 fprintf(out, "Bad count in PIPE_CONTROL\n");
3342 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3344 switch ((data[1] >> 14) & 0x3) {
3349 desc1 = "qword write";
3352 desc1 = "PS_DEPTH_COUNT write";
3355 desc1 = "TIMESTAMP write";
3358 instr_out(data, hw_offset, 0, "PIPE_CONTROL\n");
3359 instr_out(data, hw_offset, 1,
3360 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3362 data[1] & (1 << 20) ? "cs stall, " : "",
3363 data[1] & (1 << 19) ?
3364 "global snapshot count reset, " : "",
3365 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3366 data[1] & (1 << 17) ? "gfdt flush, " : "",
3367 data[1] & (1 << 17) ? "media state clear, " :
3369 data[1] & (1 << 13) ? "depth stall, " : "",
3370 data[1] & (1 << 12) ?
3371 "render target cache flush, " : "",
3372 data[1] & (1 << 11) ?
3373 "instruction cache invalidate, " : "",
3374 data[1] & (1 << 10) ?
3375 "texture cache invalidate, " : "",
3376 data[1] & (1 << 9) ?
3377 "indirect state invalidate, " : "",
3378 data[1] & (1 << 8) ? "notify irq, " : "",
3379 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3381 data[1] & (1 << 6) ? "protect mem app_id, " :
3382 "", data[1] & (1 << 5) ? "DC flush, " : "",
3383 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3385 data[1] & (1 << 3) ?
3386 "constant cache invalidate, " : "",
3387 data[1] & (1 << 2) ?
3388 "state cache invalidate, " : "",
3389 data[1] & (1 << 1) ? "stall at scoreboard, " :
3391 data[1] & (1 << 0) ? "depth cache flush, " :
3394 instr_out(data, hw_offset, 2,
3395 "destination address\n");
3396 instr_out(data, hw_offset, 3,
3397 "immediate dword low\n");
3398 instr_out(data, hw_offset, 4,
3399 "immediate dword high\n");
3401 for (i = 2; i < len; i++) {
3402 instr_out(data, hw_offset, i, "\n");
3407 len = (data[0] & 0xff) + 2;
3409 fprintf(out, "Bad count in PIPE_CONTROL\n");
3411 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3413 switch ((data[0] >> 14) & 0x3) {
3418 desc1 = "qword write";
3421 desc1 = "PS_DEPTH_COUNT write";
3424 desc1 = "TIMESTAMP write";
3427 instr_out(data, hw_offset, 0,
3428 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3431 data[0] & (1 << 13) ? "" : "no ",
3432 data[0] & (1 << 12) ? "" : "no ",
3433 data[0] & (1 << 11) ? "" : "no ");
3434 instr_out(data, hw_offset, 1, "destination address\n");
3435 instr_out(data, hw_offset, 2, "immediate dword low\n");
3436 instr_out(data, hw_offset, 3, "immediate dword high\n");
3440 len = (data[0] & 0xff) + 2;
3442 fprintf(out, "Bad count in 3DPRIMITIVE\n");
3444 BUFFER_FAIL(count, len, "3DPRIMITIVE");
3446 instr_out(data, hw_offset, 0,
3447 "3DPRIMITIVE: %s %s\n",
3448 get_965_prim_type(data[0]),
3449 (data[0] & (1 << 15)) ? "random" : "sequential");
3450 instr_out(data, hw_offset, 1, "vertex count\n");
3451 instr_out(data, hw_offset, 2, "start vertex\n");
3452 instr_out(data, hw_offset, 3, "instance count\n");
3453 instr_out(data, hw_offset, 4, "start instance\n");
3454 instr_out(data, hw_offset, 5, "index bias\n");
3458 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3459 opcode_3d = &opcodes_3d[idx];
3460 if ((data[0] & 0xffff0000) >> 16 == opcode_3d->opcode) {
3464 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3465 if (opcode_3d->max_len > 1) {
3466 len = (data[0] & 0xff) + 2;
3467 if (len < opcode_3d->min_len ||
3468 len > opcode_3d->max_len) {
3469 fprintf(out, "Bad count in %s\n",
3474 for (i = 1; i < len; i++) {
3476 BUFFER_FAIL(count, len,
3478 instr_out(data, hw_offset, i, "dword %d\n", i);
3484 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3490 decode_3d_i830(struct drm_intel_decode *ctx)
3494 uint32_t *data = ctx->data;
3495 uint32_t hw_offset = ctx->hw_offset;
3496 uint32_t count = ctx->count;
3500 unsigned int min_len;
3501 unsigned int max_len;
3504 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3505 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3506 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3507 { 0x05, 1, 1, "3DSTATE_VFT0" },
3508 { 0x06, 1, 1, "3DSTATE_AA" },
3509 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3510 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3511 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3512 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3513 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3514 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3515 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3516 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3517 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3518 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3519 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3522 opcode = (data[0] & 0x1f000000) >> 24;
3526 return decode_3d_primitive(ctx);
3528 return decode_3d_1d(ctx);
3530 return decode_3d_1c(ctx);
3533 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3534 opcode_3d = &opcodes_3d[idx];
3535 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3536 unsigned int len = 1, i;
3538 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3539 if (opcode_3d->max_len > 1) {
3540 len = (data[0] & 0xff) + 2;
3541 if (len < opcode_3d->min_len ||
3542 len > opcode_3d->max_len) {
3543 fprintf(out, "Bad count in %s\n",
3548 for (i = 1; i < len; i++) {
3550 BUFFER_FAIL(count, len,
3552 instr_out(data, hw_offset, i, "dword %d\n", i);
3558 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3563 struct drm_intel_decode *
3564 drm_intel_decode_context_alloc(uint32_t devid)
3566 struct drm_intel_decode *ctx;
3568 ctx = calloc(1, sizeof(struct drm_intel_decode));
3579 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3585 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3588 ctx->dump_past_end = !!dump_past_end;
3592 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3593 void *data, uint32_t hw_offset, int count)
3595 ctx->base_data = data;
3596 ctx->base_hw_offset = hw_offset;
3597 ctx->base_count = count;
3601 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3602 uint32_t head, uint32_t tail)
3609 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3616 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3618 * \param data batch buffer contents
3619 * \param count number of DWORDs to decode in the batch buffer
3620 * \param hw_offset hardware address for the buffer
3623 drm_intel_decode(struct drm_intel_decode *ctx)
3626 unsigned int index = 0;
3632 ctx->data = ctx->base_data;
3633 ctx->hw_offset = ctx->base_hw_offset;
3634 ctx->count = ctx->base_count;
3637 head_offset = ctx->head;
3638 tail_offset = ctx->tail;
3644 while (ctx->count > 0) {
3647 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3649 ret = decode_mi(ctx);
3651 /* If MI_BATCHBUFFER_END happened, then dump
3652 * the rest of the output in case we some day
3653 * want it in debugging, but don't decode it
3654 * since it'll just confuse in the common
3658 if (ctx->dump_past_end) {
3661 for (index = index + 1; index < ctx->count;
3663 instr_out(ctx->data,
3672 index += decode_2d(ctx);
3675 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3678 } else if (IS_GEN3(devid)) {
3679 index += decode_3d(ctx);
3682 decode_3d_i830(ctx);
3686 instr_out(ctx->data, ctx->hw_offset, index,
3693 if (ctx->count < index)
3696 ctx->count -= index;
3698 ctx->hw_offset += 4 * index;