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(struct drm_intel_decode *ctx, const char *cmd)
275 instr_out(ctx->data, ctx->hw_offset, 0,
276 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
278 (ctx->data[0] & (1 << 20)) ? "en" : "dis",
279 (ctx->data[0] & (1 << 21)) ? "en" : "dis",
280 (ctx->data[0] >> 15) & 1,
281 (ctx->data[0] >> 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(ctx, "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(ctx, "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(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT");
410 len = (data[0] & 0x000000ff) + 2;
413 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
415 BUFFER_FAIL(count, len, "XY_SETUP_MONO_PATTERN_SL_BLT");
417 decode_2d_br01(data, 1, hw_offset);
418 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
419 data[2] & 0xffff, data[2] >> 16);
420 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
421 data[3] & 0xffff, data[3] >> 16);
422 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
424 instr_out(data, hw_offset, 5, "setup background color\n");
425 instr_out(data, hw_offset, 6, "setup foreground color\n");
426 instr_out(data, hw_offset, 7, "mono pattern dw0\n");
427 instr_out(data, hw_offset, 8, "mono pattern dw1\n");
430 decode_2d_br00(ctx, "XY_COLOR_BLT");
432 len = (data[0] & 0x000000ff) + 2;
434 fprintf(out, "Bad count in XY_COLOR_BLT\n");
436 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
438 decode_2d_br01(data, 1, hw_offset);
439 instr_out(data, hw_offset, 2, "(%d,%d)\n",
440 data[2] & 0xffff, data[2] >> 16);
441 instr_out(data, hw_offset, 3, "(%d,%d)\n",
442 data[3] & 0xffff, data[3] >> 16);
443 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
444 instr_out(data, hw_offset, 5, "color\n");
447 decode_2d_br00(ctx, "XY_SRC_COPY_BLT");
449 len = (data[0] & 0x000000ff) + 2;
451 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
453 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
455 decode_2d_br01(data, 1, hw_offset);
456 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
457 data[2] & 0xffff, data[2] >> 16);
458 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
459 data[3] & 0xffff, data[3] >> 16);
460 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
461 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
462 data[5] & 0xffff, data[5] >> 16);
463 instr_out(data, hw_offset, 6, "src pitch %d\n",
464 (short)(data[6] & 0xffff));
465 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
469 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
471 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
475 instr_out(data, hw_offset, 0, "%s\n",
476 opcodes_2d[opcode].name);
477 if (opcodes_2d[opcode].max_len > 1) {
478 len = (data[0] & 0x000000ff) + 2;
479 if (len < opcodes_2d[opcode].min_len ||
480 len > opcodes_2d[opcode].max_len) {
481 fprintf(out, "Bad count in %s\n",
482 opcodes_2d[opcode].name);
486 for (i = 1; i < len; i++) {
488 BUFFER_FAIL(count, len,
489 opcodes_2d[opcode].name);
490 instr_out(data, hw_offset, i, "dword %d\n", i);
497 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
502 decode_3d_1c(struct drm_intel_decode *ctx)
504 uint32_t *data = ctx->data;
505 uint32_t hw_offset = ctx->hw_offset;
508 opcode = (data[0] & 0x00f80000) >> 19;
512 instr_out(data, hw_offset, 0,
513 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
516 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
517 data[0] & 1 ? "enabled" : "disabled");
520 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
523 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
526 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
530 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
535 /** Sets the string dstname to describe the destination of the PS instruction */
537 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
539 uint32_t a0 = data[i];
540 int dst_nr = (a0 >> 14) & 0xf;
545 if (((a0 >> 10) & 0xf) == 0xf) {
548 int dstmask_index = 0;
550 dstmask[dstmask_index++] = '.';
552 dstmask[dstmask_index++] = 'x';
554 dstmask[dstmask_index++] = 'y';
556 dstmask[dstmask_index++] = 'z';
558 dstmask[dstmask_index++] = 'w';
559 dstmask[dstmask_index++] = 0;
571 switch ((a0 >> 19) & 0x7) {
574 fprintf(out, "bad destination reg R%d\n", dst_nr);
575 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
579 fprintf(out, "bad destination reg oC%d\n", dst_nr);
580 sprintf(dstname, "oC%s%s", dstmask, sat);
584 fprintf(out, "bad destination reg oD%d\n", dst_nr);
585 sprintf(dstname, "oD%s%s", dstmask, sat);
589 fprintf(out, "bad destination reg U%d\n", dst_nr);
590 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
593 sprintf(dstname, "RESERVED");
599 i915_get_channel_swizzle(uint32_t select)
601 switch (select & 0x7) {
603 return (select & 8) ? "-x" : "x";
605 return (select & 8) ? "-y" : "y";
607 return (select & 8) ? "-z" : "z";
609 return (select & 8) ? "-w" : "w";
611 return (select & 8) ? "-0" : "0";
613 return (select & 8) ? "-1" : "1";
615 return (select & 8) ? "-bad" : "bad";
620 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
624 sprintf(name, "R%d", src_nr);
626 fprintf(out, "bad src reg %s\n", name);
630 sprintf(name, "T%d", src_nr);
631 else if (src_nr == 8)
632 sprintf(name, "DIFFUSE");
633 else if (src_nr == 9)
634 sprintf(name, "SPECULAR");
635 else if (src_nr == 10)
636 sprintf(name, "FOG");
638 fprintf(out, "bad src reg T%d\n", src_nr);
639 sprintf(name, "RESERVED");
643 sprintf(name, "C%d", src_nr);
645 fprintf(out, "bad src reg %s\n", name);
650 fprintf(out, "bad src reg oC%d\n", src_nr);
655 fprintf(out, "bad src reg oD%d\n", src_nr);
658 sprintf(name, "U%d", src_nr);
660 fprintf(out, "bad src reg %s\n", name);
663 fprintf(out, "bad src reg type %d\n", src_type);
664 sprintf(name, "RESERVED");
669 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
671 uint32_t a0 = data[i];
672 uint32_t a1 = data[i + 1];
673 int src_nr = (a0 >> 2) & 0x1f;
674 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
675 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
676 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
677 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
680 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
681 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
683 if (strcmp(swizzle, ".xyzw") != 0)
684 strcat(srcname, swizzle);
687 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
689 uint32_t a1 = data[i + 1];
690 uint32_t a2 = data[i + 2];
691 int src_nr = (a1 >> 8) & 0x1f;
692 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
693 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
694 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
695 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
698 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
699 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
701 if (strcmp(swizzle, ".xyzw") != 0)
702 strcat(srcname, swizzle);
705 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
707 uint32_t a2 = data[i + 2];
708 int src_nr = (a2 >> 16) & 0x1f;
709 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
710 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
711 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
712 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
715 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
716 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
718 if (strcmp(swizzle, ".xyzw") != 0)
719 strcat(srcname, swizzle);
723 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
727 sprintf(name, "R%d", src_nr);
729 fprintf(out, "bad src reg %s\n", name);
733 sprintf(name, "T%d", src_nr);
734 else if (src_nr == 8)
735 sprintf(name, "DIFFUSE");
736 else if (src_nr == 9)
737 sprintf(name, "SPECULAR");
738 else if (src_nr == 10)
739 sprintf(name, "FOG");
741 fprintf(out, "bad src reg T%d\n", src_nr);
742 sprintf(name, "RESERVED");
748 fprintf(out, "bad src reg oC%d\n", src_nr);
753 fprintf(out, "bad src reg oD%d\n", src_nr);
756 fprintf(out, "bad src reg type %d\n", src_type);
757 sprintf(name, "RESERVED");
763 i915_decode_alu1(uint32_t *data, uint32_t hw_offset,
764 int i, char *instr_prefix, const char *op_name)
766 char dst[100], src0[100];
768 i915_get_instruction_dst(data, i, dst, 1);
769 i915_get_instruction_src0(data, i, src0);
771 instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
773 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
774 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
778 i915_decode_alu2(uint32_t *data, uint32_t hw_offset,
779 int i, char *instr_prefix, const char *op_name)
781 char dst[100], src0[100], src1[100];
783 i915_get_instruction_dst(data, i, dst, 1);
784 i915_get_instruction_src0(data, i, src0);
785 i915_get_instruction_src1(data, i, src1);
787 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
788 op_name, dst, src0, src1);
789 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
790 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
794 i915_decode_alu3(uint32_t *data, uint32_t hw_offset,
795 int i, char *instr_prefix, const char *op_name)
797 char dst[100], src0[100], src1[100], src2[100];
799 i915_get_instruction_dst(data, i, dst, 1);
800 i915_get_instruction_src0(data, i, src0);
801 i915_get_instruction_src1(data, i, src1);
802 i915_get_instruction_src2(data, i, src2);
804 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
805 op_name, dst, src0, src1, src2);
806 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
807 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
811 i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i,
812 const char *instr_prefix, const char *tex_name)
814 uint32_t t0 = data[i];
815 uint32_t t1 = data[i + 1];
820 i915_get_instruction_dst(data, i, dst_name, 0);
821 i915_get_instruction_addr((t1 >> 24) & 0x7,
822 (t1 >> 17) & 0xf, addr_name);
823 sampler_nr = t0 & 0xf;
825 instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
826 tex_name, dst_name, sampler_nr, addr_name);
827 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
828 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
832 i915_decode_dcl(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
834 uint32_t d0 = data[i];
835 const char *sampletype;
836 int dcl_nr = (d0 >> 14) & 0xf;
837 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
838 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
839 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
840 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
843 switch ((d0 >> 19) & 0x3) {
845 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
846 if (strcmp(dcl_mask, ".") == 0)
847 fprintf(out, "bad (empty) dcl mask\n");
850 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
852 if (strcmp(dcl_mask, ".x") != 0 &&
853 strcmp(dcl_mask, ".xy") != 0 &&
854 strcmp(dcl_mask, ".xz") != 0 &&
855 strcmp(dcl_mask, ".w") != 0 &&
856 strcmp(dcl_mask, ".xyzw") != 0) {
857 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
860 instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n",
861 instr_prefix, dcl_nr, dcl_mask);
863 if (strcmp(dcl_mask, ".xz") == 0)
864 fprintf(out, "errataed bad dcl mask %s\n",
866 else if (strcmp(dcl_mask, ".xw") == 0)
867 fprintf(out, "errataed bad dcl mask %s\n",
869 else if (strcmp(dcl_mask, ".xzw") == 0)
870 fprintf(out, "errataed bad dcl mask %s\n",
874 instr_out(data, hw_offset, i++,
875 "%s: DCL DIFFUSE%s\n", instr_prefix,
877 } else if (dcl_nr == 9) {
878 instr_out(data, hw_offset, i++,
879 "%s: DCL SPECULAR%s\n", instr_prefix,
881 } else if (dcl_nr == 10) {
882 instr_out(data, hw_offset, i++,
883 "%s: DCL FOG%s\n", instr_prefix,
887 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
888 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
891 switch ((d0 >> 22) & 0x3) {
902 sampletype = "RESERVED";
906 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
907 instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n",
908 instr_prefix, dcl_nr, sampletype);
909 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
910 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
913 instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n",
914 instr_prefix, dcl_nr);
915 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
916 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
921 i915_decode_instruction(uint32_t *data, uint32_t hw_offset,
922 int i, char *instr_prefix)
924 switch ((data[i] >> 24) & 0x1f) {
926 instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
927 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
928 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
931 i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
934 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
937 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
940 i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
943 i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
946 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
949 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
952 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
955 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
958 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
961 i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
964 i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
967 i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
970 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
973 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
976 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
979 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
982 i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
985 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
988 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
991 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
994 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
997 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
1000 i915_decode_dcl(data, hw_offset, i, instr_prefix);
1003 instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
1004 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1005 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1011 decode_compare_func(uint32_t op)
1035 decode_stencil_op(uint32_t op)
1060 decode_logic_op(uint32_t op)
1101 decode_blend_fact(uint32_t op)
1111 return "inv_src_colr";
1115 return "inv_src_alpha";
1119 return "inv_dst_alpha";
1123 return "inv_dst_colr";
1125 return "src_alpha_sat";
1129 return "inv_cnst_colr";
1131 return "cnst_alpha";
1133 return "inv_const_alpha";
1139 decode_tex_coord_mode(uint32_t mode)
1141 switch (mode & 0x7) {
1147 return "clamp_edge";
1151 return "clamp_border";
1153 return "mirror_once";
1159 decode_sample_filter(uint32_t mode)
1161 switch (mode & 0x7) {
1167 return "anisotropic";
1181 decode_3d_1d(struct drm_intel_decode *ctx)
1183 unsigned int len, i, c, idx, word, map, sampler, instr;
1184 const char *format, *zformat, *type;
1186 uint32_t hw_offset = ctx->hw_offset;
1187 uint32_t *data = ctx->data;
1188 uint32_t count = ctx->count;
1189 uint32_t devid = ctx->devid;
1194 unsigned int min_len;
1195 unsigned int max_len;
1197 } opcodes_3d_1d[] = {
1198 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1199 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1200 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1201 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1202 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1203 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1204 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1205 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1206 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1207 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1208 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1209 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1210 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1211 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1212 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1213 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1216 opcode = (data[0] & 0x00ff0000) >> 16;
1220 /* This instruction is unusual. A 0 length means just
1221 * 1 DWORD instead of 2. The 0 length is specified in
1222 * one place to be unsupported, but stated to be
1223 * required in another, and 0 length LOAD_INDIRECTs
1224 * appear to cause no harm at least.
1226 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
1227 len = (data[0] & 0x000000ff) + 1;
1229 if (data[0] & (0x01 << 8)) {
1231 BUFFER_FAIL(count, len,
1232 "3DSTATE_LOAD_INDIRECT");
1233 instr_out(data, hw_offset, i++, "SIS.0\n");
1234 instr_out(data, hw_offset, i++, "SIS.1\n");
1236 if (data[0] & (0x02 << 8)) {
1238 BUFFER_FAIL(count, len,
1239 "3DSTATE_LOAD_INDIRECT");
1240 instr_out(data, hw_offset, i++, "DIS.0\n");
1242 if (data[0] & (0x04 << 8)) {
1244 BUFFER_FAIL(count, len,
1245 "3DSTATE_LOAD_INDIRECT");
1246 instr_out(data, hw_offset, i++, "SSB.0\n");
1247 instr_out(data, hw_offset, i++, "SSB.1\n");
1249 if (data[0] & (0x08 << 8)) {
1251 BUFFER_FAIL(count, len,
1252 "3DSTATE_LOAD_INDIRECT");
1253 instr_out(data, hw_offset, i++, "MSB.0\n");
1254 instr_out(data, hw_offset, i++, "MSB.1\n");
1256 if (data[0] & (0x10 << 8)) {
1258 BUFFER_FAIL(count, len,
1259 "3DSTATE_LOAD_INDIRECT");
1260 instr_out(data, hw_offset, i++, "PSP.0\n");
1261 instr_out(data, hw_offset, i++, "PSP.1\n");
1263 if (data[0] & (0x20 << 8)) {
1265 BUFFER_FAIL(count, len,
1266 "3DSTATE_LOAD_INDIRECT");
1267 instr_out(data, hw_offset, i++, "PSC.0\n");
1268 instr_out(data, hw_offset, i++, "PSC.1\n");
1271 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1276 instr_out(data, hw_offset, 0,
1277 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1278 len = (data[0] & 0x0000000f) + 2;
1280 for (word = 0; word <= 8; word++) {
1281 if (data[0] & (1 << (4 + word))) {
1283 BUFFER_FAIL(count, len,
1284 "3DSTATE_LOAD_STATE_IMMEDIATE_1");
1286 /* save vertex state for decode */
1287 if (!IS_GEN2(devid)) {
1301 instr_out(data, hw_offset, i,
1302 "S0: vbo offset: 0x%08x%s\n",
1305 ", auto cache invalidate disabled"
1309 instr_out(data, hw_offset, i,
1310 "S1: vertex width: %i, vertex pitch: %i\n",
1317 instr_out(data, hw_offset, i,
1318 "S2: texcoord formats: ");
1320 tex_num < 8; tex_num++) {
1365 instr_out(data, hw_offset, i,
1366 "S3: not documented\n");
1370 const char *cullmode = "";
1371 const char *vfmt_xyzw = "";
1372 switch ((data[i] >> 13)
1409 case 1 << 6 | 1 << 2:
1413 case 2 << 6 | 1 << 2:
1417 case 3 << 6 | 1 << 2:
1421 case 4 << 6 | 1 << 2:
1428 "S4: point_width=%i, line_width=%.1f,"
1429 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1492 "force default diffuse, "
1498 "force default specular, "
1504 "local depth ofs enable, "
1510 "point sprite enable, "
1525 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1526 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1527 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1557 " force default point size,"
1563 " last pixel enable,"
1569 " global depth ofs enable,"
1595 "stencil write enable, "
1601 "stencil test enable, "
1607 "color dither enable, "
1618 instr_out(data, hw_offset, i,
1619 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1620 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1621 "%s%stristrip_provoking_vertex=%i\n",
1622 data[i] & (1 << 31) ?
1623 "alpha test enable, "
1631 data[i] & (1 << 15) ?
1632 "cbuf blend enable, "
1634 decode_blend_fact(data
1638 decode_blend_fact(data
1642 data[i] & (1 << 3) ?
1643 "depth write enable, "
1645 data[i] & (1 << 2) ?
1646 "cbuf write enable, "
1651 instr_out(data, hw_offset, i,
1652 "S7: depth offset constant: 0x%08x\n",
1657 instr_out(data, hw_offset, i,
1658 "S%d: 0x%08x\n", i, data[i]);
1665 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1669 instr_out(data, hw_offset, 0,
1670 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1671 len = (data[0] & 0x0000000f) + 2;
1673 for (word = 6; word <= 14; word++) {
1674 if (data[0] & (1 << word)) {
1676 BUFFER_FAIL(count, len,
1677 "3DSTATE_LOAD_STATE_IMMEDIATE_2");
1680 instr_out(data, hw_offset, i++,
1682 else if (word >= 7 && word <= 10) {
1683 instr_out(data, hw_offset, i++,
1684 "TB%dC\n", word - 7);
1685 instr_out(data, hw_offset, i++,
1686 "TB%dA\n", word - 7);
1687 } else if (word >= 11 && word <= 14) {
1688 instr_out(data, hw_offset, i,
1689 "TM%dS0: offset=0x%08x, %s\n",
1691 data[i] & 0xfffffffe,
1692 data[i] & 1 ? "use fence" :
1695 instr_out(data, hw_offset, i,
1696 "TM%dS1: height=%i, width=%i, %s\n",
1697 word - 11, data[i] >> 21,
1698 (data[i] >> 10) & 0x3ff,
1699 data[i] & 2 ? (data[i] & 1 ?
1704 instr_out(data, hw_offset, i,
1705 "TM%dS2: pitch=%i, \n",
1707 ((data[i] >> 21) + 1) * 4);
1709 instr_out(data, hw_offset, i++,
1710 "TM%dS3\n", word - 11);
1711 instr_out(data, hw_offset, i++,
1712 "TM%dS4: dflt color\n",
1719 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1723 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
1724 len = (data[0] & 0x0000003f) + 2;
1725 instr_out(data, hw_offset, 1, "mask\n");
1728 for (map = 0; map <= 15; map++) {
1729 if (data[1] & (1 << map)) {
1730 int width, height, pitch, dword;
1734 BUFFER_FAIL(count, len,
1735 "3DSTATE_MAP_STATE");
1738 instr_out(data, hw_offset, i++,
1739 "map %d MS2 %s%s%s\n", map,
1741 "untrusted surface, " : "",
1743 "vertical line stride enable, " : "",
1745 "vertical ofs enable, " : "");
1748 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1749 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1752 if (dword & (1 << 2))
1754 else if (dword & (1 << 1))
1755 tiling = dword & (1 << 0) ? "Y" : "X";
1758 switch ((dword >> 7) & 0x7) {
1761 switch ((dword >> 3) & 0xf) {
1778 switch ((dword >> 3) & 0xf) {
1783 format = " argb1555";
1786 format = " argb4444";
1792 format = " bump655";
1807 switch ((dword >> 3) & 0xf) {
1809 format = " argb8888";
1812 format = " abgr8888";
1815 format = " xrgb8888";
1818 format = " xbgr8888";
1821 format = " qwvu8888";
1824 format = " axvu8888";
1827 format = " lxvu8888";
1830 format = " xlvu8888";
1833 format = " argb2101010";
1836 format = " abgr2101010";
1839 format = " awvu2101010";
1860 switch ((dword >> 3) & 0xf) {
1862 format = " yuv_swapy";
1868 format = " yuv_swapuv";
1871 format = " yuv_swapuvy";
1876 type = "compressed";
1877 switch ((dword >> 3) & 0x7) {
1891 format = " dxt1_rb";
1896 type = "4b indexed";
1897 switch ((dword >> 3) & 0xf) {
1899 format = " argb8888";
1905 instr_out(data, hw_offset, i++,
1906 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1907 map, width, height, type, format,
1909 dword & (1 << 9) ? " palette select" :
1914 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1915 instr_out(data, hw_offset, i++,
1916 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1917 map, pitch, (dword >> 9) & 0x3f,
1918 dword & 0xff, (dword >> 15) & 0x3f,
1919 dword & (1 << 8) ? "miplayout legacy"
1920 : "miplayout right");
1924 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1929 instr_out(data, hw_offset, 0,
1930 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1931 len = (data[0] & 0x000000ff) + 2;
1934 for (c = 0; c <= 31; c++) {
1935 if (data[1] & (1 << c)) {
1937 BUFFER_FAIL(count, len,
1938 "3DSTATE_PIXEL_SHADER_CONSTANTS");
1939 instr_out(data, hw_offset, i, "C%d.X = %f\n", c,
1940 int_as_float(data[i]));
1942 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
1943 c, int_as_float(data[i]));
1945 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
1946 c, int_as_float(data[i]));
1948 instr_out(data, hw_offset, i, "C%d.W = %f\n",
1949 c, int_as_float(data[i]));
1955 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1959 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1960 len = (data[0] & 0x000000ff) + 2;
1961 if ((len - 1) % 3 != 0 || len > 370) {
1963 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1966 for (instr = 0; instr < (len - 1) / 3; instr++) {
1967 char instr_prefix[10];
1970 BUFFER_FAIL(count, len,
1971 "3DSTATE_PIXEL_SHADER_PROGRAM");
1972 sprintf(instr_prefix, "PS%03d", instr);
1973 i915_decode_instruction(data, hw_offset, i,
1981 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
1982 instr_out(data, hw_offset, 1, "mask\n");
1983 len = (data[0] & 0x0000003f) + 2;
1985 for (sampler = 0; sampler <= 15; sampler++) {
1986 if (data[1] & (1 << sampler)) {
1988 const char *mip_filter = "";
1990 BUFFER_FAIL(count, len,
1991 "3DSTATE_SAMPLER_STATE");
1993 switch ((dword >> 20) & 0x3) {
1995 mip_filter = "none";
1998 mip_filter = "nearest";
2001 mip_filter = "linear";
2004 instr_out(data, hw_offset, i++,
2005 "sampler %d SS2:%s%s%s "
2006 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
2007 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
2009 dword & (1 << 31) ? " reverse gamma,"
2011 dword & (1 << 30) ? " packed2planar,"
2014 " colorspace conversion," : "",
2015 (dword >> 22) & 0x1f, mip_filter,
2016 decode_sample_filter(dword >> 17),
2017 decode_sample_filter(dword >> 14),
2018 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2019 dword & (1 << 4) ? " shadow," : "",
2020 dword & (1 << 3) ? 4 : 2,
2021 decode_compare_func(dword));
2023 instr_out(data, hw_offset, i++,
2024 "sampler %d SS3: min_lod=%.2f,%s "
2025 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2027 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2029 " kill pixel enable," : "",
2030 decode_tex_coord_mode(dword >> 12),
2031 decode_tex_coord_mode(dword >> 9),
2032 decode_tex_coord_mode(dword >> 6),
2034 " normalized coords," : "",
2036 dword & (1 << 0) ? " deinterlacer," :
2039 instr_out(data, hw_offset, i++,
2040 "sampler %d SS4: border color\n",
2045 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2049 len = (data[0] & 0x0000000f) + 2;
2053 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2055 BUFFER_FAIL(count, len,
2056 "3DSTATE_DEST_BUFFER_VARIABLES");
2058 instr_out(data, hw_offset, 0,
2059 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2061 switch ((data[1] >> 8) & 0xf) {
2066 format = "x1r5g5b5";
2072 format = "a8r8g8b8";
2075 format = "ycrcb_swapy";
2078 format = "ycrcb_normal";
2081 format = "ycrcb_swapuv";
2084 format = "ycrcb_swapuvy";
2087 format = "a4r4g4b4";
2090 format = "a1r5g5b5";
2093 format = "a2r10g10b10";
2099 switch ((data[1] >> 2) & 0x3) {
2113 instr_out(data, hw_offset, 1,
2114 "%s format, %s depth format, early Z %sabled\n",
2116 (data[1] & (1 << 31)) ? "en" : "dis");
2121 const char *name, *tiling;
2123 len = (data[0] & 0x0000000f) + 2;
2126 "Bad count in 3DSTATE_BUFFER_INFO\n");
2128 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
2130 switch ((data[1] >> 24) & 0x7) {
2143 if (data[1] & (1 << 23))
2145 else if (data[1] & (1 << 22))
2146 tiling = data[1] & (1 << 21) ? "Y" : "X";
2148 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
2149 instr_out(data, hw_offset, 1,
2150 "%s, tiling = %s, pitch=%d\n", name, tiling,
2153 instr_out(data, hw_offset, 2, "address\n");
2157 len = (data[0] & 0x0000000f) + 2;
2161 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2163 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_RECTANGLE");
2165 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2166 instr_out(data, hw_offset, 1, "(%d,%d)\n",
2167 data[1] & 0xffff, data[1] >> 16);
2168 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2169 data[2] & 0xffff, data[2] >> 16);
2173 len = (data[0] & 0x0000000f) + 2;
2177 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2179 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2181 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2182 instr_out(data, hw_offset, 1, "%s\n",
2183 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2184 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2185 data[2] & 0xffff, data[2] >> 16);
2186 instr_out(data, hw_offset, 3, "(%d,%d)\n",
2187 data[3] & 0xffff, data[3] >> 16);
2188 instr_out(data, hw_offset, 4, "(%d,%d)\n",
2189 data[4] & 0xffff, data[4] >> 16);
2193 len = (data[0] & 0x0000000f) + 2;
2196 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2198 BUFFER_FAIL(count, len, "3DSTATE_CLEAR_PARAMETERS");
2200 instr_out(data, hw_offset, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2201 instr_out(data, hw_offset, 1, "prim_type=%s, clear=%s%s%s\n",
2202 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2203 data[1] & (1 << 2) ? "color," : "",
2204 data[1] & (1 << 1) ? "depth," : "",
2205 data[1] & (1 << 0) ? "stencil," : "");
2206 instr_out(data, hw_offset, 2, "clear color\n");
2207 instr_out(data, hw_offset, 3, "clear depth/stencil\n");
2208 instr_out(data, hw_offset, 4, "color value (rgba8888)\n");
2209 instr_out(data, hw_offset, 5, "depth value %f\n",
2210 int_as_float(data[5]));
2211 instr_out(data, hw_offset, 6, "clear stencil\n");
2215 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2216 opcode_3d_1d = &opcodes_3d_1d[idx];
2217 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2220 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2223 instr_out(data, hw_offset, 0, "%s\n",
2224 opcode_3d_1d->name);
2225 if (opcode_3d_1d->max_len > 1) {
2226 len = (data[0] & 0x0000ffff) + 2;
2227 if (len < opcode_3d_1d->min_len ||
2228 len > opcode_3d_1d->max_len) {
2229 fprintf(out, "Bad count in %s\n",
2230 opcode_3d_1d->name);
2234 for (i = 1; i < len; i++) {
2236 BUFFER_FAIL(count, len,
2237 opcode_3d_1d->name);
2238 instr_out(data, hw_offset, i, "dword %d\n", i);
2245 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2251 decode_3d_primitive(struct drm_intel_decode *ctx)
2253 uint32_t *data = ctx->data;
2254 uint32_t hw_offset = ctx->hw_offset;
2255 uint32_t count = ctx->count;
2256 char immediate = (data[0] & (1 << 23)) == 0;
2257 unsigned int len, i, j, ret;
2258 const char *primtype;
2259 int original_s2 = saved_s2;
2260 int original_s4 = saved_s4;
2262 switch ((data[0] >> 18) & 0xf) {
2264 primtype = "TRILIST";
2267 primtype = "TRISTRIP";
2270 primtype = "TRISTRIP_REVERSE";
2273 primtype = "TRIFAN";
2276 primtype = "POLYGON";
2279 primtype = "LINELIST";
2282 primtype = "LINESTRIP";
2285 primtype = "RECTLIST";
2288 primtype = "POINTLIST";
2294 primtype = "CLEAR_RECT";
2299 primtype = "unknown";
2303 /* XXX: 3DPRIM_DIB not supported */
2305 len = (data[0] & 0x0003ffff) + 2;
2306 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n",
2309 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2310 if (!saved_s2_set || !saved_s4_set) {
2311 fprintf(out, "unknown vertex format\n");
2312 for (i = 1; i < len; i++) {
2313 instr_out(data, hw_offset, i,
2314 " vertex data (%f float)\n",
2315 int_as_float(data[i]));
2318 unsigned int vertex = 0;
2319 for (i = 1; i < len;) {
2322 #define VERTEX_OUT(fmt, ...) do { \
2324 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2326 fprintf(out, " missing data in V%d\n", vertex); \
2330 VERTEX_OUT("X = %f", int_as_float(data[i]));
2331 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2332 switch (saved_s4 >> 6 & 0x7) {
2334 VERTEX_OUT("Z = %f",
2335 int_as_float(data[i]));
2338 VERTEX_OUT("Z = %f",
2339 int_as_float(data[i]));
2340 VERTEX_OUT("W = %f",
2341 int_as_float(data[i]));
2346 VERTEX_OUT("W = %f",
2347 int_as_float(data[i]));
2350 fprintf(out, "bad S4 position mask\n");
2353 if (saved_s4 & (1 << 10)) {
2355 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2356 "B=0x%02x)", data[i] >> 24,
2357 (data[i] >> 16) & 0xff,
2358 (data[i] >> 8) & 0xff,
2361 if (saved_s4 & (1 << 11)) {
2363 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2364 "B=0x%02x)", data[i] >> 24,
2365 (data[i] >> 16) & 0xff,
2366 (data[i] >> 8) & 0xff,
2369 if (saved_s4 & (1 << 12))
2370 VERTEX_OUT("width = 0x%08x)", data[i]);
2372 for (tc = 0; tc <= 7; tc++) {
2373 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2375 VERTEX_OUT("T%d.X = %f", tc,
2378 VERTEX_OUT("T%d.Y = %f", tc,
2383 VERTEX_OUT("T%d.X = %f", tc,
2386 VERTEX_OUT("T%d.Y = %f", tc,
2389 VERTEX_OUT("T%d.Z = %f", tc,
2394 VERTEX_OUT("T%d.X = %f", tc,
2397 VERTEX_OUT("T%d.Y = %f", tc,
2400 VERTEX_OUT("T%d.Z = %f", tc,
2403 VERTEX_OUT("T%d.W = %f", tc,
2408 VERTEX_OUT("T%d.X = %f", tc,
2414 ("T%d.XY = 0x%08x half-float",
2419 ("T%d.XY = 0x%08x half-float",
2422 ("T%d.ZW = 0x%08x half-float",
2429 "bad S2.T%d format\n",
2439 /* indirect vertices */
2440 len = data[0] & 0x0000ffff; /* index count */
2441 if (data[0] & (1 << 17)) {
2442 /* random vertex access */
2443 if (count < (len + 1) / 2 + 1) {
2444 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2445 "3DPRIMITIVE random indirect");
2447 instr_out(data, hw_offset, 0,
2448 "3DPRIMITIVE random indirect %s (%d)\n",
2451 /* vertex indices continue until 0xffff is
2454 for (i = 1; i < count; i++) {
2455 if ((data[i] & 0xffff) == 0xffff) {
2456 instr_out(data, hw_offset, i,
2457 " indices: (terminator)\n");
2460 } else if ((data[i] >> 16) == 0xffff) {
2461 instr_out(data, hw_offset, i,
2462 " indices: 0x%04x, (terminator)\n",
2467 instr_out(data, hw_offset, i,
2468 " indices: 0x%04x, 0x%04x\n",
2474 "3DPRIMITIVE: no terminator found in index buffer\n");
2478 /* fixed size vertex index buffer */
2479 for (j = 1, i = 0; i < len; i += 2, j++) {
2480 if (i * 2 == len - 1) {
2481 instr_out(data, hw_offset, j,
2482 " indices: 0x%04x\n",
2485 instr_out(data, hw_offset, j,
2486 " indices: 0x%04x, 0x%04x\n",
2492 ret = (len + 1) / 2 + 1;
2495 /* sequential vertex access */
2497 BUFFER_FAIL(count, 2,
2498 "3DPRIMITIVE seq indirect");
2499 instr_out(data, hw_offset, 0,
2500 "3DPRIMITIVE sequential indirect %s, %d starting from "
2501 "%d\n", primtype, len, data[1] & 0xffff);
2502 instr_out(data, hw_offset, 1, " start\n");
2509 saved_s2 = original_s2;
2510 saved_s4 = original_s4;
2515 decode_3d(struct drm_intel_decode *ctx)
2519 uint32_t *data = ctx->data;
2520 uint32_t hw_offset = ctx->hw_offset;
2521 uint32_t count = ctx->count;
2525 unsigned int min_len;
2526 unsigned int max_len;
2529 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2530 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2531 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2532 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2533 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2534 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2535 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2536 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2537 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2540 opcode = (data[0] & 0x1f000000) >> 24;
2544 return decode_3d_primitive(ctx);
2546 return decode_3d_1d(ctx);
2548 return decode_3d_1c(ctx);
2551 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2552 opcode_3d = &opcodes_3d[idx];
2553 if (opcode == opcode_3d->opcode) {
2554 unsigned int len = 1, i;
2556 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2557 if (opcode_3d->max_len > 1) {
2558 len = (data[0] & 0xff) + 2;
2559 if (len < opcode_3d->min_len ||
2560 len > opcode_3d->max_len) {
2561 fprintf(out, "Bad count in %s\n",
2566 for (i = 1; i < len; i++) {
2568 BUFFER_FAIL(count, len,
2570 instr_out(data, hw_offset, i, "dword %d\n", i);
2576 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2580 static const char *get_965_surfacetype(unsigned int surfacetype)
2582 switch (surfacetype) {
2600 static const char *get_965_depthformat(unsigned int depthformat)
2602 switch (depthformat) {
2604 return "s8_z24float";
2616 static const char *get_965_element_component(uint32_t data, int component)
2618 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2620 switch (component_control) {
2624 switch (component) {
2649 static const char *get_965_prim_type(uint32_t data)
2651 uint32_t primtype = (data >> 10) & 0x1f;
2655 return "point list";
2659 return "line strip";
2669 return "quad strip";
2671 return "line list adj";
2673 return "line strip adj";
2675 return "tri list adj";
2677 return "tri strip adj";
2679 return "tri strip reverse";
2687 return "point list bf";
2689 return "line strip cont";
2691 return "line strip bf";
2693 return "line strip cont bf";
2695 return "tri fan no stipple";
2702 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len,
2705 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2708 fprintf(out, "Bad count in URB_FENCE\n");
2710 BUFFER_FAIL(count, len, "URB_FENCE");
2712 vs_fence = data[1] & 0x3ff;
2713 gs_fence = (data[1] >> 10) & 0x3ff;
2714 clip_fence = (data[1] >> 20) & 0x3ff;
2715 sf_fence = data[2] & 0x3ff;
2716 vfe_fence = (data[2] >> 10) & 0x3ff;
2717 cs_fence = (data[2] >> 20) & 0x7ff;
2719 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2720 (data[0] >> 13) & 1 ? "cs " : "",
2721 (data[0] >> 12) & 1 ? "vfe " : "",
2722 (data[0] >> 11) & 1 ? "sf " : "",
2723 (data[0] >> 10) & 1 ? "clip " : "",
2724 (data[0] >> 9) & 1 ? "gs " : "",
2725 (data[0] >> 8) & 1 ? "vs " : "");
2726 instr_out(data, hw_offset, 1,
2727 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2728 vs_fence, clip_fence, gs_fence);
2729 instr_out(data, hw_offset, 2,
2730 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2731 sf_fence, vfe_fence, cs_fence);
2732 if (gs_fence < vs_fence)
2733 fprintf(out, "gs fence < vs fence!\n");
2734 if (clip_fence < gs_fence)
2735 fprintf(out, "clip fence < gs fence!\n");
2736 if (sf_fence < clip_fence)
2737 fprintf(out, "sf fence < clip fence!\n");
2738 if (cs_fence < sf_fence)
2739 fprintf(out, "cs fence < sf fence!\n");
2745 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2748 if (data[index] & 1) {
2749 instr_out(data, hw_offset, index,
2750 "%s state base address 0x%08x\n", name,
2753 instr_out(data, hw_offset, index, "%s state base not updated\n",
2759 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2762 if (data[index] & 1) {
2763 if (data[index] == 1) {
2764 instr_out(data, hw_offset, index,
2765 "%s state upper bound disabled\n", name);
2767 instr_out(data, hw_offset, index,
2768 "%s state upper bound 0x%08x\n", name,
2772 instr_out(data, hw_offset, index,
2773 "%s state upper bound not updated\n", name);
2778 decode_3d_965(struct drm_intel_decode *ctx)
2781 unsigned int idx, len;
2782 unsigned int i, j, sba_len;
2783 const char *desc1 = NULL;
2784 uint32_t *data = ctx->data;
2785 uint32_t hw_offset = ctx->hw_offset;
2786 uint32_t count = ctx->count;
2787 uint32_t devid = ctx->devid;
2791 int unsigned min_len;
2792 int unsigned max_len;
2795 { 0x6000, 3, 3, "URB_FENCE" },
2796 { 0x6001, 2, 2, "CS_URB_STATE" },
2797 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
2798 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
2799 { 0x6102, 2, 2, "STATE_SIP" },
2800 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2801 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
2802 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2803 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
2804 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
2805 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
2806 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
2807 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
2808 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
2809 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
2810 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
2811 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
2812 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
2813 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
2814 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
2815 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
2816 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2817 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
2818 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
2819 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
2820 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2821 { 0x7b00, 6, 6, "3DPRIMITIVE" },
2822 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
2823 { 0x7805, 3, 3, "3DSTATE_URB" },
2824 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
2825 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
2826 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
2827 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
2828 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
2829 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
2830 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
2831 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
2832 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
2833 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
2834 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
2835 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK"},
2838 len = (data[0] & 0x0000ffff) + 2;
2840 opcode = (data[0] & 0xffff0000) >> 16;
2843 len = (data[0] & 0x000000ff) + 2;
2844 return i965_decode_urb_fence(data, hw_offset, len, count);
2846 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
2847 instr_out(data, hw_offset, 1,
2848 "entry_size: %d [%d bytes], n_entries: %d\n",
2849 (data[1] >> 4) & 0x1f,
2850 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
2853 len = (data[0] & 0x000000ff) + 2;
2854 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
2855 (data[0] >> 8) & 1 ? "valid" : "invalid");
2856 instr_out(data, hw_offset, 1,
2857 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
2858 ((data[1] & 0x3f) + 1) * 64);
2862 instr_out(data, hw_offset, 0, "STATE_BASE_ADDRESS\n");
2865 if (IS_GEN6(devid) || IS_GEN7(devid))
2867 else if (IS_GEN5(devid))
2872 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
2874 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
2876 state_base_out(data, hw_offset, i++, "general");
2877 state_base_out(data, hw_offset, i++, "surface");
2878 if (IS_GEN6(devid) || IS_GEN7(devid))
2879 state_base_out(data, hw_offset, i++, "dynamic");
2880 state_base_out(data, hw_offset, i++, "indirect");
2881 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2882 state_base_out(data, hw_offset, i++, "instruction");
2884 state_max_out(data, hw_offset, i++, "general");
2885 if (IS_GEN6(devid) || IS_GEN7(devid))
2886 state_max_out(data, hw_offset, i++, "dynamic");
2887 state_max_out(data, hw_offset, i++, "indirect");
2888 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2889 state_max_out(data, hw_offset, i++, "instruction");
2895 "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
2897 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
2899 instr_out(data, hw_offset, 0, "3DSTATE_PIPELINED_POINTERS\n");
2900 instr_out(data, hw_offset, 1, "VS state\n");
2901 instr_out(data, hw_offset, 2, "GS state\n");
2902 instr_out(data, hw_offset, 3, "Clip state\n");
2903 instr_out(data, hw_offset, 4, "SF state\n");
2904 instr_out(data, hw_offset, 5, "WM state\n");
2905 instr_out(data, hw_offset, 6, "CC state\n");
2908 len = (data[0] & 0x000000ff) + 2;
2909 if (len != 6 && len != 4)
2911 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
2914 BUFFER_FAIL(count, len,
2915 "3DSTATE_BINDING_TABLE_POINTERS");
2916 instr_out(data, hw_offset, 0,
2917 "3DSTATE_BINDING_TABLE_POINTERS\n");
2918 instr_out(data, hw_offset, 1, "VS binding table\n");
2919 instr_out(data, hw_offset, 2, "GS binding table\n");
2920 instr_out(data, hw_offset, 3, "Clip binding table\n");
2921 instr_out(data, hw_offset, 4, "SF binding table\n");
2922 instr_out(data, hw_offset, 5, "WM binding table\n");
2925 BUFFER_FAIL(count, len,
2926 "3DSTATE_BINDING_TABLE_POINTERS");
2928 instr_out(data, hw_offset, 0,
2929 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
2930 "GS mod %d, PS mod %d\n",
2931 (data[0] & (1 << 8)) != 0,
2932 (data[0] & (1 << 9)) != 0,
2933 (data[0] & (1 << 12)) != 0);
2934 instr_out(data, hw_offset, 1, "VS binding table\n");
2935 instr_out(data, hw_offset, 2, "GS binding table\n");
2936 instr_out(data, hw_offset, 3, "WM binding table\n");
2941 len = (data[0] & 0xff) + 2;
2944 "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
2946 BUFFER_FAIL(count, len,
2947 "3DSTATE_SAMPLER_STATE_POINTERS");
2948 instr_out(data, hw_offset, 0,
2949 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
2950 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
2951 (data[0] & (1 << 9)) != 0,
2952 (data[0] & (1 << 12)) != 0);
2953 instr_out(data, hw_offset, 1, "VS sampler state\n");
2954 instr_out(data, hw_offset, 2, "GS sampler state\n");
2955 instr_out(data, hw_offset, 3, "WM sampler state\n");
2958 len = (data[0] & 0xff) + 2;
2960 fprintf(out, "Bad count in 3DSTATE_URB\n");
2962 BUFFER_FAIL(count, len, "3DSTATE_URB");
2963 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
2964 instr_out(data, hw_offset, 1,
2965 "VS entries %d, alloc size %d (1024bit row)\n",
2966 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
2967 instr_out(data, hw_offset, 2,
2968 "GS entries %d, alloc size %d (1024bit row)\n",
2969 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
2973 len = (data[0] & 0xff) + 2;
2974 if ((len - 1) % 4 != 0)
2975 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
2977 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
2978 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
2980 for (i = 1; i < len;) {
2982 if (IS_GEN6(devid)) {
2989 instr_out(data, hw_offset, i,
2990 "buffer %d: %s, pitch %db\n", data[i] >> idx,
2991 data[i] & (1 << access) ? "random" :
2992 "sequential", data[i] & 0x07ff);
2994 instr_out(data, hw_offset, i++, "buffer address\n");
2995 instr_out(data, hw_offset, i++, "max index\n");
2996 instr_out(data, hw_offset, i++, "mbz\n");
3001 len = (data[0] & 0xff) + 2;
3002 if ((len + 1) % 2 != 0)
3003 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3005 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
3006 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3008 for (i = 1; i < len;) {
3009 instr_out(data, hw_offset, i,
3010 "buffer %d: %svalid, type 0x%04x, "
3011 "src offset 0x%04x bytes\n",
3012 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3013 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3014 "" : "in", (data[i] >> 16) & 0x1ff,
3017 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
3018 "dst offset 0x%02x bytes\n",
3019 get_965_element_component(data[i], 0),
3020 get_965_element_component(data[i], 1),
3021 get_965_element_component(data[i], 2),
3022 get_965_element_component(data[i], 3),
3023 (data[i] & 0xff) * 4);
3029 len = (data[0] & 0xff) + 2;
3032 "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
3034 BUFFER_FAIL(count, len,
3035 "3DSTATE_VIEWPORT_STATE_POINTERS");
3036 instr_out(data, hw_offset, 0,
3037 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3038 instr_out(data, hw_offset, 1, "clip\n");
3039 instr_out(data, hw_offset, 2, "sf\n");
3040 instr_out(data, hw_offset, 3, "cc\n");
3044 len = (data[0] & 0xff) + 2;
3046 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
3048 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
3049 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
3050 instr_out(data, hw_offset, 1, "beginning buffer address\n");
3051 instr_out(data, hw_offset, 2, "ending buffer address\n");
3055 len = (data[0] & 0xff) + 2;
3058 "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
3060 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
3061 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
3062 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
3063 instr_out(data, hw_offset, 2, "depth stencil change %d\n",
3065 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
3069 len = (data[0] & 0xff) + 2;
3071 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
3073 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
3074 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
3075 instr_out(data, hw_offset, 1, "scissor rect offset\n");
3079 len = (data[0] & 0xff) + 2;
3081 fprintf(out, "Bad count in 3DSTATE_VS\n");
3083 BUFFER_FAIL(count, len, "3DSTATE_VS");
3084 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
3085 instr_out(data, hw_offset, 1, "kernel pointer\n");
3086 instr_out(data, hw_offset, 2,
3087 "SPF=%d, VME=%d, Sampler Count %d, "
3088 "Binding table count %d\n", (data[2] >> 31) & 1,
3089 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3090 (data[2] >> 18) & 0xff);
3091 instr_out(data, hw_offset, 3, "scratch offset\n");
3092 instr_out(data, hw_offset, 4,
3093 "Dispatch GRF start %d, VUE read length %d, "
3094 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3095 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3096 instr_out(data, hw_offset, 5,
3097 "Max Threads %d, Vertex Cache %sable, "
3098 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3099 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3100 (data[5] & 1) != 0 ? "en" : "dis");
3104 len = (data[0] & 0xff) + 2;
3106 fprintf(out, "Bad count in 3DSTATE_GS\n");
3108 BUFFER_FAIL(count, len, "3DSTATE_GS");
3109 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
3110 instr_out(data, hw_offset, 1, "kernel pointer\n");
3111 instr_out(data, hw_offset, 2,
3112 "SPF=%d, VME=%d, Sampler Count %d, "
3113 "Binding table count %d\n", (data[2] >> 31) & 1,
3114 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3115 (data[2] >> 18) & 0xff);
3116 instr_out(data, hw_offset, 3, "scratch offset\n");
3117 instr_out(data, hw_offset, 4,
3118 "Dispatch GRF start %d, VUE read length %d, "
3119 "VUE read offset %d\n", (data[4] & 0xf),
3120 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3121 instr_out(data, hw_offset, 5,
3122 "Max Threads %d, Rendering %sable\n",
3123 ((data[5] >> 25) & 0x7f) + 1,
3124 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3125 instr_out(data, hw_offset, 6,
3126 "Reorder %sable, Discard Adjaceny %sable, "
3128 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3129 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3130 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3134 len = (data[0] & 0xff) + 2;
3136 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
3138 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
3139 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
3140 instr_out(data, hw_offset, 1,
3141 "UserClip distance cull test mask 0x%x\n",
3143 instr_out(data, hw_offset, 2,
3144 "Clip %sable, API mode %s, Viewport XY test %sable, "
3145 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3146 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3147 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3148 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3149 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3150 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3151 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3152 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3153 (data[2] >> 13) & 7,
3154 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3155 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3156 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3158 instr_out(data, hw_offset, 3,
3159 "Min PointWidth %d, Max PointWidth %d, "
3160 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3161 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3162 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3167 len = (data[0] & 0xff) + 2;
3169 fprintf(out, "Bad count in 3DSTATE_SF\n");
3171 BUFFER_FAIL(count, len, "3DSTATE_SF");
3172 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
3173 instr_out(data, hw_offset, 1,
3174 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3175 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3176 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3177 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3178 instr_out(data, hw_offset, 2,
3179 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3180 "VP transform %sable, FrontWinding_%s\n",
3181 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3182 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3183 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3184 (data[2] & 1) != 0 ? "CCW" : "CW");
3185 instr_out(data, hw_offset, 3,
3186 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3187 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3188 (data[3] >> 29) & 3,
3189 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3190 (data[3] >> 8) & 3);
3191 instr_out(data, hw_offset, 4,
3192 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3193 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3194 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3195 (data[4] & (1 << 11)) != 0);
3196 instr_out(data, hw_offset, 5,
3197 "Global Depth Offset Constant %f\n",
3198 *(float *)(&data[5]));
3199 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n",
3200 *(float *)(&data[6]));
3201 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n",
3202 *(float *)(&data[7]));
3204 for (i = 0, j = 0; i < 8; i++, j += 2)
3205 instr_out(data, hw_offset, i + 8,
3206 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3207 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3209 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3210 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3211 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3212 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3213 (data[8 + i] >> 25) & 3,
3214 (data[8 + i] >> 22) & 3,
3215 (data[8 + i] >> 16) & 0x1f, j,
3216 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3217 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3218 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3219 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3220 (data[8 + i] >> 9) & 3,
3221 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3222 instr_out(data, hw_offset, 16,
3223 "Point Sprite TexCoord Enable\n");
3224 instr_out(data, hw_offset, 17, "Const Interp Enable\n");
3225 instr_out(data, hw_offset, 18,
3226 "Attrib 7-0 WrapShortest Enable\n");
3227 instr_out(data, hw_offset, 19,
3228 "Attrib 15-8 WrapShortest Enable\n");
3233 len = (data[0] & 0xff) + 2;
3235 fprintf(out, "Bad count in 3DSTATE_WM\n");
3237 BUFFER_FAIL(count, len, "3DSTATE_WM");
3238 instr_out(data, hw_offset, 0, "3DSTATE_WM\n");
3239 instr_out(data, hw_offset, 1, "kernel start pointer 0\n");
3240 instr_out(data, hw_offset, 2,
3241 "SPF=%d, VME=%d, Sampler Count %d, "
3242 "Binding table count %d\n", (data[2] >> 31) & 1,
3243 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3244 (data[2] >> 18) & 0xff);
3245 instr_out(data, hw_offset, 3, "scratch offset\n");
3246 instr_out(data, hw_offset, 4,
3247 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
3248 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
3249 (data[4] & (1 << 30)) != 0,
3250 (data[4] & (1 << 28)) != 0,
3251 (data[4] & (1 << 27)) != 0, (data[4] >> 16) & 0x7f,
3252 (data[4] >> 8) & 0x7f, (data[4] & 0x7f));
3253 instr_out(data, hw_offset, 5,
3254 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
3255 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
3256 "Dispatch16 %d, Dispatch8 %d\n",
3257 ((data[5] >> 25) & 0x7f) + 1,
3258 (data[5] & (1 << 22)) != 0,
3259 (data[5] & (1 << 21)) != 0,
3260 (data[5] & (1 << 20)) != 0,
3261 (data[5] & (1 << 19)) != 0, (data[5] & (1 << 8)) != 0,
3262 (data[5] & (1 << 2)) != 0, (data[5] & (1 << 1)) != 0,
3263 (data[5] & (1 << 0)) != 0);
3264 instr_out(data, hw_offset, 6,
3265 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
3266 "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
3267 "Multisample Dispatch mode %d\n",
3268 (data[6] >> 20) & 0x3f, (data[6] >> 18) & 3,
3269 (data[6] >> 16) & 3, (data[6] >> 10) & 0x3f,
3270 (data[6] & (1 << 9)) != 0, (data[6] >> 1) & 3,
3272 instr_out(data, hw_offset, 7, "kernel start pointer 1\n");
3273 instr_out(data, hw_offset, 8, "kernel start pointer 2\n");
3280 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
3282 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
3284 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3285 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
3286 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3287 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
3288 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3289 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
3290 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3295 if (len < 5 || len > 7)
3296 fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
3298 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
3300 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_BUFFER\n");
3301 if (IS_GEN5(devid) || IS_GEN6(devid))
3302 instr_out(data, hw_offset, 1,
3303 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3304 get_965_surfacetype(data[1] >> 29),
3305 get_965_depthformat((data[1] >> 18) & 0x7),
3306 (data[1] & 0x0001ffff) + 1,
3307 data[1] & (1 << 27) ? "" : "not ",
3308 (data[1] & (1 << 22)) != 0,
3309 (data[1] & (1 << 21)) != 0);
3311 instr_out(data, hw_offset, 1,
3312 "%s, %s, pitch = %d bytes, %stiled\n",
3313 get_965_surfacetype(data[1] >> 29),
3314 get_965_depthformat((data[1] >> 18) & 0x7),
3315 (data[1] & 0x0001ffff) + 1,
3316 data[1] & (1 << 27) ? "" : "not ");
3317 instr_out(data, hw_offset, 2, "depth offset\n");
3318 instr_out(data, hw_offset, 3, "%dx%d\n",
3319 ((data[3] & 0x0007ffc0) >> 6) + 1,
3320 ((data[3] & 0xfff80000) >> 19) + 1);
3321 instr_out(data, hw_offset, 4, "volume depth\n");
3323 instr_out(data, hw_offset, 5, "\n");
3326 instr_out(data, hw_offset, 6, "\n");
3328 instr_out(data, hw_offset, 6,
3329 "render target view extent\n");
3335 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3337 len = (data[0] & 0xff) + 2;
3338 if (len != 4 && len != 5)
3339 fprintf(out, "Bad count in PIPE_CONTROL\n");
3341 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3343 switch ((data[1] >> 14) & 0x3) {
3348 desc1 = "qword write";
3351 desc1 = "PS_DEPTH_COUNT write";
3354 desc1 = "TIMESTAMP write";
3357 instr_out(data, hw_offset, 0, "PIPE_CONTROL\n");
3358 instr_out(data, hw_offset, 1,
3359 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3361 data[1] & (1 << 20) ? "cs stall, " : "",
3362 data[1] & (1 << 19) ?
3363 "global snapshot count reset, " : "",
3364 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3365 data[1] & (1 << 17) ? "gfdt flush, " : "",
3366 data[1] & (1 << 17) ? "media state clear, " :
3368 data[1] & (1 << 13) ? "depth stall, " : "",
3369 data[1] & (1 << 12) ?
3370 "render target cache flush, " : "",
3371 data[1] & (1 << 11) ?
3372 "instruction cache invalidate, " : "",
3373 data[1] & (1 << 10) ?
3374 "texture cache invalidate, " : "",
3375 data[1] & (1 << 9) ?
3376 "indirect state invalidate, " : "",
3377 data[1] & (1 << 8) ? "notify irq, " : "",
3378 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3380 data[1] & (1 << 6) ? "protect mem app_id, " :
3381 "", data[1] & (1 << 5) ? "DC flush, " : "",
3382 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3384 data[1] & (1 << 3) ?
3385 "constant cache invalidate, " : "",
3386 data[1] & (1 << 2) ?
3387 "state cache invalidate, " : "",
3388 data[1] & (1 << 1) ? "stall at scoreboard, " :
3390 data[1] & (1 << 0) ? "depth cache flush, " :
3393 instr_out(data, hw_offset, 2,
3394 "destination address\n");
3395 instr_out(data, hw_offset, 3,
3396 "immediate dword low\n");
3397 instr_out(data, hw_offset, 4,
3398 "immediate dword high\n");
3400 for (i = 2; i < len; i++) {
3401 instr_out(data, hw_offset, i, "\n");
3406 len = (data[0] & 0xff) + 2;
3408 fprintf(out, "Bad count in PIPE_CONTROL\n");
3410 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3412 switch ((data[0] >> 14) & 0x3) {
3417 desc1 = "qword write";
3420 desc1 = "PS_DEPTH_COUNT write";
3423 desc1 = "TIMESTAMP write";
3426 instr_out(data, hw_offset, 0,
3427 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3430 data[0] & (1 << 13) ? "" : "no ",
3431 data[0] & (1 << 12) ? "" : "no ",
3432 data[0] & (1 << 11) ? "" : "no ");
3433 instr_out(data, hw_offset, 1, "destination address\n");
3434 instr_out(data, hw_offset, 2, "immediate dword low\n");
3435 instr_out(data, hw_offset, 3, "immediate dword high\n");
3439 len = (data[0] & 0xff) + 2;
3441 fprintf(out, "Bad count in 3DPRIMITIVE\n");
3443 BUFFER_FAIL(count, len, "3DPRIMITIVE");
3445 instr_out(data, hw_offset, 0,
3446 "3DPRIMITIVE: %s %s\n",
3447 get_965_prim_type(data[0]),
3448 (data[0] & (1 << 15)) ? "random" : "sequential");
3449 instr_out(data, hw_offset, 1, "vertex count\n");
3450 instr_out(data, hw_offset, 2, "start vertex\n");
3451 instr_out(data, hw_offset, 3, "instance count\n");
3452 instr_out(data, hw_offset, 4, "start instance\n");
3453 instr_out(data, hw_offset, 5, "index bias\n");
3457 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3458 opcode_3d = &opcodes_3d[idx];
3459 if ((data[0] & 0xffff0000) >> 16 == opcode_3d->opcode) {
3463 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3464 if (opcode_3d->max_len > 1) {
3465 len = (data[0] & 0xff) + 2;
3466 if (len < opcode_3d->min_len ||
3467 len > opcode_3d->max_len) {
3468 fprintf(out, "Bad count in %s\n",
3473 for (i = 1; i < len; i++) {
3475 BUFFER_FAIL(count, len,
3477 instr_out(data, hw_offset, i, "dword %d\n", i);
3483 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3489 decode_3d_i830(struct drm_intel_decode *ctx)
3493 uint32_t *data = ctx->data;
3494 uint32_t hw_offset = ctx->hw_offset;
3495 uint32_t count = ctx->count;
3499 unsigned int min_len;
3500 unsigned int max_len;
3503 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3504 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3505 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3506 { 0x05, 1, 1, "3DSTATE_VFT0" },
3507 { 0x06, 1, 1, "3DSTATE_AA" },
3508 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3509 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3510 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3511 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3512 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3513 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3514 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3515 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3516 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3517 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3518 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3521 opcode = (data[0] & 0x1f000000) >> 24;
3525 return decode_3d_primitive(ctx);
3527 return decode_3d_1d(ctx);
3529 return decode_3d_1c(ctx);
3532 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3533 opcode_3d = &opcodes_3d[idx];
3534 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3535 unsigned int len = 1, i;
3537 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3538 if (opcode_3d->max_len > 1) {
3539 len = (data[0] & 0xff) + 2;
3540 if (len < opcode_3d->min_len ||
3541 len > opcode_3d->max_len) {
3542 fprintf(out, "Bad count in %s\n",
3547 for (i = 1; i < len; i++) {
3549 BUFFER_FAIL(count, len,
3551 instr_out(data, hw_offset, i, "dword %d\n", i);
3557 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3562 struct drm_intel_decode *
3563 drm_intel_decode_context_alloc(uint32_t devid)
3565 struct drm_intel_decode *ctx;
3567 ctx = calloc(1, sizeof(struct drm_intel_decode));
3578 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3584 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3587 ctx->dump_past_end = !!dump_past_end;
3591 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3592 void *data, uint32_t hw_offset, int count)
3594 ctx->base_data = data;
3595 ctx->base_hw_offset = hw_offset;
3596 ctx->base_count = count;
3600 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3601 uint32_t head, uint32_t tail)
3608 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3615 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3617 * \param data batch buffer contents
3618 * \param count number of DWORDs to decode in the batch buffer
3619 * \param hw_offset hardware address for the buffer
3622 drm_intel_decode(struct drm_intel_decode *ctx)
3625 unsigned int index = 0;
3631 ctx->data = ctx->base_data;
3632 ctx->hw_offset = ctx->base_hw_offset;
3633 ctx->count = ctx->base_count;
3636 head_offset = ctx->head;
3637 tail_offset = ctx->tail;
3643 while (ctx->count > 0) {
3646 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3648 ret = decode_mi(ctx);
3650 /* If MI_BATCHBUFFER_END happened, then dump
3651 * the rest of the output in case we some day
3652 * want it in debugging, but don't decode it
3653 * since it'll just confuse in the common
3657 if (ctx->dump_past_end) {
3660 for (index = index + 1; index < ctx->count;
3662 instr_out(ctx->data,
3671 index += decode_2d(ctx);
3674 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3677 } else if (IS_GEN3(devid)) {
3678 index += decode_3d(ctx);
3681 decode_3d_i830(ctx);
3685 instr_out(ctx->data, ctx->hw_offset, index,
3692 if (ctx->count < index)
3695 ctx->count -= index;
3697 ctx->hw_offset += 4 * index;