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);
285 decode_2d_br01(struct drm_intel_decode *ctx)
288 switch ((ctx->data[1] >> 24) & 0x3) {
303 instr_out(ctx->data, ctx->hw_offset, 1,
304 "format %s, pitch %d, rop 0x%02x, "
305 "clipping %sabled, %s%s \n",
307 (short)(ctx->data[1] & 0xffff),
308 (ctx->data[1] >> 16) & 0xff,
309 ctx->data[1] & (1 << 30) ? "en" : "dis",
310 ctx->data[1] & (1 << 31) ? "solid pattern enabled, " : "",
311 ctx->data[1] & (1 << 31) ?
312 "mono pattern transparency enabled, " : "");
317 decode_2d(struct drm_intel_decode *ctx)
319 unsigned int opcode, len;
320 uint32_t *data = ctx->data;
321 uint32_t hw_offset = ctx->hw_offset;
322 uint32_t count = ctx->count;
326 unsigned int min_len;
327 unsigned int max_len;
330 { 0x40, 5, 5, "COLOR_BLT" },
331 { 0x43, 6, 6, "SRC_COPY_BLT" },
332 { 0x01, 8, 8, "XY_SETUP_BLT" },
333 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
334 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
335 { 0x24, 2, 2, "XY_PIXEL_BLT" },
336 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
337 { 0x26, 4, 4, "Y_TEXT_BLT" },
338 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
339 { 0x50, 6, 6, "XY_COLOR_BLT" },
340 { 0x51, 6, 6, "XY_PAT_BLT" },
341 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
342 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
343 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
344 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
345 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
346 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
347 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
348 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
349 { 0x55, 9, 9, "XY_FULL_BLT" },
350 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
351 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
352 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
353 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
354 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
357 switch ((data[0] & 0x1fc00000) >> 22) {
359 instr_out(data, hw_offset, 0,
360 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
361 (data[0] >> 12) & 0x8,
362 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
364 len = (data[0] & 0x000000ff) + 2;
366 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
368 BUFFER_FAIL(count, len, "XY_SCANLINES_BLT");
370 instr_out(data, hw_offset, 1, "dest (%d,%d)\n",
371 data[1] & 0xffff, data[1] >> 16);
372 instr_out(data, hw_offset, 2, "dest (%d,%d)\n",
373 data[2] & 0xffff, data[2] >> 16);
376 decode_2d_br00(ctx, "XY_SETUP_BLT");
378 len = (data[0] & 0x000000ff) + 2;
380 fprintf(out, "Bad count in XY_SETUP_BLT\n");
382 BUFFER_FAIL(count, len, "XY_SETUP_BLT");
385 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
386 data[2] & 0xffff, data[2] >> 16);
387 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
388 data[3] & 0xffff, data[3] >> 16);
389 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
391 instr_out(data, hw_offset, 5, "setup background color\n");
392 instr_out(data, hw_offset, 6, "setup foreground color\n");
393 instr_out(data, hw_offset, 7, "color pattern offset\n");
396 decode_2d_br00(ctx, "XY_SETUP_CLIP_BLT");
398 len = (data[0] & 0x000000ff) + 2;
400 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
402 BUFFER_FAIL(count, len, "XY_SETUP_CLIP_BLT");
404 instr_out(data, hw_offset, 1, "cliprect (%d,%d)\n",
405 data[1] & 0xffff, data[2] >> 16);
406 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
407 data[2] & 0xffff, data[3] >> 16);
410 decode_2d_br00(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT");
412 len = (data[0] & 0x000000ff) + 2;
415 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
417 BUFFER_FAIL(count, len, "XY_SETUP_MONO_PATTERN_SL_BLT");
420 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
421 data[2] & 0xffff, data[2] >> 16);
422 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
423 data[3] & 0xffff, data[3] >> 16);
424 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
426 instr_out(data, hw_offset, 5, "setup background color\n");
427 instr_out(data, hw_offset, 6, "setup foreground color\n");
428 instr_out(data, hw_offset, 7, "mono pattern dw0\n");
429 instr_out(data, hw_offset, 8, "mono pattern dw1\n");
432 decode_2d_br00(ctx, "XY_COLOR_BLT");
434 len = (data[0] & 0x000000ff) + 2;
436 fprintf(out, "Bad count in XY_COLOR_BLT\n");
438 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
441 instr_out(data, hw_offset, 2, "(%d,%d)\n",
442 data[2] & 0xffff, data[2] >> 16);
443 instr_out(data, hw_offset, 3, "(%d,%d)\n",
444 data[3] & 0xffff, data[3] >> 16);
445 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
446 instr_out(data, hw_offset, 5, "color\n");
449 decode_2d_br00(ctx, "XY_SRC_COPY_BLT");
451 len = (data[0] & 0x000000ff) + 2;
453 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
455 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
458 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
459 data[2] & 0xffff, data[2] >> 16);
460 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
461 data[3] & 0xffff, data[3] >> 16);
462 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
463 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
464 data[5] & 0xffff, data[5] >> 16);
465 instr_out(data, hw_offset, 6, "src pitch %d\n",
466 (short)(data[6] & 0xffff));
467 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
471 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
473 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
477 instr_out(data, hw_offset, 0, "%s\n",
478 opcodes_2d[opcode].name);
479 if (opcodes_2d[opcode].max_len > 1) {
480 len = (data[0] & 0x000000ff) + 2;
481 if (len < opcodes_2d[opcode].min_len ||
482 len > opcodes_2d[opcode].max_len) {
483 fprintf(out, "Bad count in %s\n",
484 opcodes_2d[opcode].name);
488 for (i = 1; i < len; i++) {
490 BUFFER_FAIL(count, len,
491 opcodes_2d[opcode].name);
492 instr_out(data, hw_offset, i, "dword %d\n", i);
499 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
504 decode_3d_1c(struct drm_intel_decode *ctx)
506 uint32_t *data = ctx->data;
507 uint32_t hw_offset = ctx->hw_offset;
510 opcode = (data[0] & 0x00f80000) >> 19;
514 instr_out(data, hw_offset, 0,
515 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
518 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
519 data[0] & 1 ? "enabled" : "disabled");
522 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
525 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
528 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
532 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
537 /** Sets the string dstname to describe the destination of the PS instruction */
539 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
541 uint32_t a0 = data[i];
542 int dst_nr = (a0 >> 14) & 0xf;
547 if (((a0 >> 10) & 0xf) == 0xf) {
550 int dstmask_index = 0;
552 dstmask[dstmask_index++] = '.';
554 dstmask[dstmask_index++] = 'x';
556 dstmask[dstmask_index++] = 'y';
558 dstmask[dstmask_index++] = 'z';
560 dstmask[dstmask_index++] = 'w';
561 dstmask[dstmask_index++] = 0;
573 switch ((a0 >> 19) & 0x7) {
576 fprintf(out, "bad destination reg R%d\n", dst_nr);
577 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
581 fprintf(out, "bad destination reg oC%d\n", dst_nr);
582 sprintf(dstname, "oC%s%s", dstmask, sat);
586 fprintf(out, "bad destination reg oD%d\n", dst_nr);
587 sprintf(dstname, "oD%s%s", dstmask, sat);
591 fprintf(out, "bad destination reg U%d\n", dst_nr);
592 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
595 sprintf(dstname, "RESERVED");
601 i915_get_channel_swizzle(uint32_t select)
603 switch (select & 0x7) {
605 return (select & 8) ? "-x" : "x";
607 return (select & 8) ? "-y" : "y";
609 return (select & 8) ? "-z" : "z";
611 return (select & 8) ? "-w" : "w";
613 return (select & 8) ? "-0" : "0";
615 return (select & 8) ? "-1" : "1";
617 return (select & 8) ? "-bad" : "bad";
622 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
626 sprintf(name, "R%d", src_nr);
628 fprintf(out, "bad src reg %s\n", name);
632 sprintf(name, "T%d", src_nr);
633 else if (src_nr == 8)
634 sprintf(name, "DIFFUSE");
635 else if (src_nr == 9)
636 sprintf(name, "SPECULAR");
637 else if (src_nr == 10)
638 sprintf(name, "FOG");
640 fprintf(out, "bad src reg T%d\n", src_nr);
641 sprintf(name, "RESERVED");
645 sprintf(name, "C%d", src_nr);
647 fprintf(out, "bad src reg %s\n", name);
652 fprintf(out, "bad src reg oC%d\n", src_nr);
657 fprintf(out, "bad src reg oD%d\n", src_nr);
660 sprintf(name, "U%d", src_nr);
662 fprintf(out, "bad src reg %s\n", name);
665 fprintf(out, "bad src reg type %d\n", src_type);
666 sprintf(name, "RESERVED");
671 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
673 uint32_t a0 = data[i];
674 uint32_t a1 = data[i + 1];
675 int src_nr = (a0 >> 2) & 0x1f;
676 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
677 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
678 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
679 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
682 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
683 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
685 if (strcmp(swizzle, ".xyzw") != 0)
686 strcat(srcname, swizzle);
689 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
691 uint32_t a1 = data[i + 1];
692 uint32_t a2 = data[i + 2];
693 int src_nr = (a1 >> 8) & 0x1f;
694 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
695 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
696 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
697 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
700 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
701 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
703 if (strcmp(swizzle, ".xyzw") != 0)
704 strcat(srcname, swizzle);
707 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
709 uint32_t a2 = data[i + 2];
710 int src_nr = (a2 >> 16) & 0x1f;
711 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
712 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
713 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
714 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
717 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
718 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
720 if (strcmp(swizzle, ".xyzw") != 0)
721 strcat(srcname, swizzle);
725 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
729 sprintf(name, "R%d", src_nr);
731 fprintf(out, "bad src reg %s\n", name);
735 sprintf(name, "T%d", src_nr);
736 else if (src_nr == 8)
737 sprintf(name, "DIFFUSE");
738 else if (src_nr == 9)
739 sprintf(name, "SPECULAR");
740 else if (src_nr == 10)
741 sprintf(name, "FOG");
743 fprintf(out, "bad src reg T%d\n", src_nr);
744 sprintf(name, "RESERVED");
750 fprintf(out, "bad src reg oC%d\n", src_nr);
755 fprintf(out, "bad src reg oD%d\n", src_nr);
758 fprintf(out, "bad src reg type %d\n", src_type);
759 sprintf(name, "RESERVED");
765 i915_decode_alu1(uint32_t *data, uint32_t hw_offset,
766 int i, char *instr_prefix, const char *op_name)
768 char dst[100], src0[100];
770 i915_get_instruction_dst(data, i, dst, 1);
771 i915_get_instruction_src0(data, i, src0);
773 instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
775 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
776 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
780 i915_decode_alu2(uint32_t *data, uint32_t hw_offset,
781 int i, char *instr_prefix, const char *op_name)
783 char dst[100], src0[100], src1[100];
785 i915_get_instruction_dst(data, i, dst, 1);
786 i915_get_instruction_src0(data, i, src0);
787 i915_get_instruction_src1(data, i, src1);
789 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
790 op_name, dst, src0, src1);
791 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
792 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
796 i915_decode_alu3(uint32_t *data, uint32_t hw_offset,
797 int i, char *instr_prefix, const char *op_name)
799 char dst[100], src0[100], src1[100], src2[100];
801 i915_get_instruction_dst(data, i, dst, 1);
802 i915_get_instruction_src0(data, i, src0);
803 i915_get_instruction_src1(data, i, src1);
804 i915_get_instruction_src2(data, i, src2);
806 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
807 op_name, dst, src0, src1, src2);
808 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
809 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
813 i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i,
814 const char *instr_prefix, const char *tex_name)
816 uint32_t t0 = data[i];
817 uint32_t t1 = data[i + 1];
822 i915_get_instruction_dst(data, i, dst_name, 0);
823 i915_get_instruction_addr((t1 >> 24) & 0x7,
824 (t1 >> 17) & 0xf, addr_name);
825 sampler_nr = t0 & 0xf;
827 instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
828 tex_name, dst_name, sampler_nr, addr_name);
829 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
830 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
834 i915_decode_dcl(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
836 uint32_t d0 = data[i];
837 const char *sampletype;
838 int dcl_nr = (d0 >> 14) & 0xf;
839 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
840 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
841 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
842 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
845 switch ((d0 >> 19) & 0x3) {
847 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
848 if (strcmp(dcl_mask, ".") == 0)
849 fprintf(out, "bad (empty) dcl mask\n");
852 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
854 if (strcmp(dcl_mask, ".x") != 0 &&
855 strcmp(dcl_mask, ".xy") != 0 &&
856 strcmp(dcl_mask, ".xz") != 0 &&
857 strcmp(dcl_mask, ".w") != 0 &&
858 strcmp(dcl_mask, ".xyzw") != 0) {
859 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
862 instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n",
863 instr_prefix, dcl_nr, dcl_mask);
865 if (strcmp(dcl_mask, ".xz") == 0)
866 fprintf(out, "errataed bad dcl mask %s\n",
868 else if (strcmp(dcl_mask, ".xw") == 0)
869 fprintf(out, "errataed bad dcl mask %s\n",
871 else if (strcmp(dcl_mask, ".xzw") == 0)
872 fprintf(out, "errataed bad dcl mask %s\n",
876 instr_out(data, hw_offset, i++,
877 "%s: DCL DIFFUSE%s\n", instr_prefix,
879 } else if (dcl_nr == 9) {
880 instr_out(data, hw_offset, i++,
881 "%s: DCL SPECULAR%s\n", instr_prefix,
883 } else if (dcl_nr == 10) {
884 instr_out(data, hw_offset, i++,
885 "%s: DCL FOG%s\n", instr_prefix,
889 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
890 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
893 switch ((d0 >> 22) & 0x3) {
904 sampletype = "RESERVED";
908 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
909 instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n",
910 instr_prefix, dcl_nr, sampletype);
911 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
912 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
915 instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n",
916 instr_prefix, dcl_nr);
917 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
918 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
923 i915_decode_instruction(uint32_t *data, uint32_t hw_offset,
924 int i, char *instr_prefix)
926 switch ((data[i] >> 24) & 0x1f) {
928 instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
929 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
930 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
933 i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
936 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
939 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
942 i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
945 i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
948 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
951 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
954 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
957 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
960 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
963 i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
966 i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
969 i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
972 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
975 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
978 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
981 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
984 i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
987 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
990 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
993 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
996 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
999 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
1002 i915_decode_dcl(data, hw_offset, i, instr_prefix);
1005 instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
1006 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1007 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1013 decode_compare_func(uint32_t op)
1037 decode_stencil_op(uint32_t op)
1062 decode_logic_op(uint32_t op)
1103 decode_blend_fact(uint32_t op)
1113 return "inv_src_colr";
1117 return "inv_src_alpha";
1121 return "inv_dst_alpha";
1125 return "inv_dst_colr";
1127 return "src_alpha_sat";
1131 return "inv_cnst_colr";
1133 return "cnst_alpha";
1135 return "inv_const_alpha";
1141 decode_tex_coord_mode(uint32_t mode)
1143 switch (mode & 0x7) {
1149 return "clamp_edge";
1153 return "clamp_border";
1155 return "mirror_once";
1161 decode_sample_filter(uint32_t mode)
1163 switch (mode & 0x7) {
1169 return "anisotropic";
1183 decode_3d_1d(struct drm_intel_decode *ctx)
1185 unsigned int len, i, c, idx, word, map, sampler, instr;
1186 const char *format, *zformat, *type;
1188 uint32_t hw_offset = ctx->hw_offset;
1189 uint32_t *data = ctx->data;
1190 uint32_t count = ctx->count;
1191 uint32_t devid = ctx->devid;
1196 unsigned int min_len;
1197 unsigned int max_len;
1199 } opcodes_3d_1d[] = {
1200 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1201 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1202 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1203 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1204 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1205 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1206 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1207 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1208 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1209 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1210 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1211 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1212 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1213 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1214 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1215 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1218 opcode = (data[0] & 0x00ff0000) >> 16;
1222 /* This instruction is unusual. A 0 length means just
1223 * 1 DWORD instead of 2. The 0 length is specified in
1224 * one place to be unsupported, but stated to be
1225 * required in another, and 0 length LOAD_INDIRECTs
1226 * appear to cause no harm at least.
1228 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
1229 len = (data[0] & 0x000000ff) + 1;
1231 if (data[0] & (0x01 << 8)) {
1233 BUFFER_FAIL(count, len,
1234 "3DSTATE_LOAD_INDIRECT");
1235 instr_out(data, hw_offset, i++, "SIS.0\n");
1236 instr_out(data, hw_offset, i++, "SIS.1\n");
1238 if (data[0] & (0x02 << 8)) {
1240 BUFFER_FAIL(count, len,
1241 "3DSTATE_LOAD_INDIRECT");
1242 instr_out(data, hw_offset, i++, "DIS.0\n");
1244 if (data[0] & (0x04 << 8)) {
1246 BUFFER_FAIL(count, len,
1247 "3DSTATE_LOAD_INDIRECT");
1248 instr_out(data, hw_offset, i++, "SSB.0\n");
1249 instr_out(data, hw_offset, i++, "SSB.1\n");
1251 if (data[0] & (0x08 << 8)) {
1253 BUFFER_FAIL(count, len,
1254 "3DSTATE_LOAD_INDIRECT");
1255 instr_out(data, hw_offset, i++, "MSB.0\n");
1256 instr_out(data, hw_offset, i++, "MSB.1\n");
1258 if (data[0] & (0x10 << 8)) {
1260 BUFFER_FAIL(count, len,
1261 "3DSTATE_LOAD_INDIRECT");
1262 instr_out(data, hw_offset, i++, "PSP.0\n");
1263 instr_out(data, hw_offset, i++, "PSP.1\n");
1265 if (data[0] & (0x20 << 8)) {
1267 BUFFER_FAIL(count, len,
1268 "3DSTATE_LOAD_INDIRECT");
1269 instr_out(data, hw_offset, i++, "PSC.0\n");
1270 instr_out(data, hw_offset, i++, "PSC.1\n");
1273 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1278 instr_out(data, hw_offset, 0,
1279 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1280 len = (data[0] & 0x0000000f) + 2;
1282 for (word = 0; word <= 8; word++) {
1283 if (data[0] & (1 << (4 + word))) {
1285 BUFFER_FAIL(count, len,
1286 "3DSTATE_LOAD_STATE_IMMEDIATE_1");
1288 /* save vertex state for decode */
1289 if (!IS_GEN2(devid)) {
1303 instr_out(data, hw_offset, i,
1304 "S0: vbo offset: 0x%08x%s\n",
1307 ", auto cache invalidate disabled"
1311 instr_out(data, hw_offset, i,
1312 "S1: vertex width: %i, vertex pitch: %i\n",
1319 instr_out(data, hw_offset, i,
1320 "S2: texcoord formats: ");
1322 tex_num < 8; tex_num++) {
1367 instr_out(data, hw_offset, i,
1368 "S3: not documented\n");
1372 const char *cullmode = "";
1373 const char *vfmt_xyzw = "";
1374 switch ((data[i] >> 13)
1411 case 1 << 6 | 1 << 2:
1415 case 2 << 6 | 1 << 2:
1419 case 3 << 6 | 1 << 2:
1423 case 4 << 6 | 1 << 2:
1430 "S4: point_width=%i, line_width=%.1f,"
1431 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1494 "force default diffuse, "
1500 "force default specular, "
1506 "local depth ofs enable, "
1512 "point sprite enable, "
1527 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1528 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1529 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1559 " force default point size,"
1565 " last pixel enable,"
1571 " global depth ofs enable,"
1597 "stencil write enable, "
1603 "stencil test enable, "
1609 "color dither enable, "
1620 instr_out(data, hw_offset, i,
1621 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1622 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1623 "%s%stristrip_provoking_vertex=%i\n",
1624 data[i] & (1 << 31) ?
1625 "alpha test enable, "
1633 data[i] & (1 << 15) ?
1634 "cbuf blend enable, "
1636 decode_blend_fact(data
1640 decode_blend_fact(data
1644 data[i] & (1 << 3) ?
1645 "depth write enable, "
1647 data[i] & (1 << 2) ?
1648 "cbuf write enable, "
1653 instr_out(data, hw_offset, i,
1654 "S7: depth offset constant: 0x%08x\n",
1659 instr_out(data, hw_offset, i,
1660 "S%d: 0x%08x\n", i, data[i]);
1667 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1671 instr_out(data, hw_offset, 0,
1672 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1673 len = (data[0] & 0x0000000f) + 2;
1675 for (word = 6; word <= 14; word++) {
1676 if (data[0] & (1 << word)) {
1678 BUFFER_FAIL(count, len,
1679 "3DSTATE_LOAD_STATE_IMMEDIATE_2");
1682 instr_out(data, hw_offset, i++,
1684 else if (word >= 7 && word <= 10) {
1685 instr_out(data, hw_offset, i++,
1686 "TB%dC\n", word - 7);
1687 instr_out(data, hw_offset, i++,
1688 "TB%dA\n", word - 7);
1689 } else if (word >= 11 && word <= 14) {
1690 instr_out(data, hw_offset, i,
1691 "TM%dS0: offset=0x%08x, %s\n",
1693 data[i] & 0xfffffffe,
1694 data[i] & 1 ? "use fence" :
1697 instr_out(data, hw_offset, i,
1698 "TM%dS1: height=%i, width=%i, %s\n",
1699 word - 11, data[i] >> 21,
1700 (data[i] >> 10) & 0x3ff,
1701 data[i] & 2 ? (data[i] & 1 ?
1706 instr_out(data, hw_offset, i,
1707 "TM%dS2: pitch=%i, \n",
1709 ((data[i] >> 21) + 1) * 4);
1711 instr_out(data, hw_offset, i++,
1712 "TM%dS3\n", word - 11);
1713 instr_out(data, hw_offset, i++,
1714 "TM%dS4: dflt color\n",
1721 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1725 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
1726 len = (data[0] & 0x0000003f) + 2;
1727 instr_out(data, hw_offset, 1, "mask\n");
1730 for (map = 0; map <= 15; map++) {
1731 if (data[1] & (1 << map)) {
1732 int width, height, pitch, dword;
1736 BUFFER_FAIL(count, len,
1737 "3DSTATE_MAP_STATE");
1740 instr_out(data, hw_offset, i++,
1741 "map %d MS2 %s%s%s\n", map,
1743 "untrusted surface, " : "",
1745 "vertical line stride enable, " : "",
1747 "vertical ofs enable, " : "");
1750 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1751 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1754 if (dword & (1 << 2))
1756 else if (dword & (1 << 1))
1757 tiling = dword & (1 << 0) ? "Y" : "X";
1760 switch ((dword >> 7) & 0x7) {
1763 switch ((dword >> 3) & 0xf) {
1780 switch ((dword >> 3) & 0xf) {
1785 format = " argb1555";
1788 format = " argb4444";
1794 format = " bump655";
1809 switch ((dword >> 3) & 0xf) {
1811 format = " argb8888";
1814 format = " abgr8888";
1817 format = " xrgb8888";
1820 format = " xbgr8888";
1823 format = " qwvu8888";
1826 format = " axvu8888";
1829 format = " lxvu8888";
1832 format = " xlvu8888";
1835 format = " argb2101010";
1838 format = " abgr2101010";
1841 format = " awvu2101010";
1862 switch ((dword >> 3) & 0xf) {
1864 format = " yuv_swapy";
1870 format = " yuv_swapuv";
1873 format = " yuv_swapuvy";
1878 type = "compressed";
1879 switch ((dword >> 3) & 0x7) {
1893 format = " dxt1_rb";
1898 type = "4b indexed";
1899 switch ((dword >> 3) & 0xf) {
1901 format = " argb8888";
1907 instr_out(data, hw_offset, i++,
1908 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1909 map, width, height, type, format,
1911 dword & (1 << 9) ? " palette select" :
1916 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1917 instr_out(data, hw_offset, i++,
1918 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1919 map, pitch, (dword >> 9) & 0x3f,
1920 dword & 0xff, (dword >> 15) & 0x3f,
1921 dword & (1 << 8) ? "miplayout legacy"
1922 : "miplayout right");
1926 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1931 instr_out(data, hw_offset, 0,
1932 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1933 len = (data[0] & 0x000000ff) + 2;
1936 for (c = 0; c <= 31; c++) {
1937 if (data[1] & (1 << c)) {
1939 BUFFER_FAIL(count, len,
1940 "3DSTATE_PIXEL_SHADER_CONSTANTS");
1941 instr_out(data, hw_offset, i, "C%d.X = %f\n", c,
1942 int_as_float(data[i]));
1944 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
1945 c, int_as_float(data[i]));
1947 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
1948 c, int_as_float(data[i]));
1950 instr_out(data, hw_offset, i, "C%d.W = %f\n",
1951 c, int_as_float(data[i]));
1957 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1961 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1962 len = (data[0] & 0x000000ff) + 2;
1963 if ((len - 1) % 3 != 0 || len > 370) {
1965 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1968 for (instr = 0; instr < (len - 1) / 3; instr++) {
1969 char instr_prefix[10];
1972 BUFFER_FAIL(count, len,
1973 "3DSTATE_PIXEL_SHADER_PROGRAM");
1974 sprintf(instr_prefix, "PS%03d", instr);
1975 i915_decode_instruction(data, hw_offset, i,
1983 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
1984 instr_out(data, hw_offset, 1, "mask\n");
1985 len = (data[0] & 0x0000003f) + 2;
1987 for (sampler = 0; sampler <= 15; sampler++) {
1988 if (data[1] & (1 << sampler)) {
1990 const char *mip_filter = "";
1992 BUFFER_FAIL(count, len,
1993 "3DSTATE_SAMPLER_STATE");
1995 switch ((dword >> 20) & 0x3) {
1997 mip_filter = "none";
2000 mip_filter = "nearest";
2003 mip_filter = "linear";
2006 instr_out(data, hw_offset, i++,
2007 "sampler %d SS2:%s%s%s "
2008 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
2009 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
2011 dword & (1 << 31) ? " reverse gamma,"
2013 dword & (1 << 30) ? " packed2planar,"
2016 " colorspace conversion," : "",
2017 (dword >> 22) & 0x1f, mip_filter,
2018 decode_sample_filter(dword >> 17),
2019 decode_sample_filter(dword >> 14),
2020 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2021 dword & (1 << 4) ? " shadow," : "",
2022 dword & (1 << 3) ? 4 : 2,
2023 decode_compare_func(dword));
2025 instr_out(data, hw_offset, i++,
2026 "sampler %d SS3: min_lod=%.2f,%s "
2027 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2029 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2031 " kill pixel enable," : "",
2032 decode_tex_coord_mode(dword >> 12),
2033 decode_tex_coord_mode(dword >> 9),
2034 decode_tex_coord_mode(dword >> 6),
2036 " normalized coords," : "",
2038 dword & (1 << 0) ? " deinterlacer," :
2041 instr_out(data, hw_offset, i++,
2042 "sampler %d SS4: border color\n",
2047 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2051 len = (data[0] & 0x0000000f) + 2;
2055 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2057 BUFFER_FAIL(count, len,
2058 "3DSTATE_DEST_BUFFER_VARIABLES");
2060 instr_out(data, hw_offset, 0,
2061 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2063 switch ((data[1] >> 8) & 0xf) {
2068 format = "x1r5g5b5";
2074 format = "a8r8g8b8";
2077 format = "ycrcb_swapy";
2080 format = "ycrcb_normal";
2083 format = "ycrcb_swapuv";
2086 format = "ycrcb_swapuvy";
2089 format = "a4r4g4b4";
2092 format = "a1r5g5b5";
2095 format = "a2r10g10b10";
2101 switch ((data[1] >> 2) & 0x3) {
2115 instr_out(data, hw_offset, 1,
2116 "%s format, %s depth format, early Z %sabled\n",
2118 (data[1] & (1 << 31)) ? "en" : "dis");
2123 const char *name, *tiling;
2125 len = (data[0] & 0x0000000f) + 2;
2128 "Bad count in 3DSTATE_BUFFER_INFO\n");
2130 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
2132 switch ((data[1] >> 24) & 0x7) {
2145 if (data[1] & (1 << 23))
2147 else if (data[1] & (1 << 22))
2148 tiling = data[1] & (1 << 21) ? "Y" : "X";
2150 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
2151 instr_out(data, hw_offset, 1,
2152 "%s, tiling = %s, pitch=%d\n", name, tiling,
2155 instr_out(data, hw_offset, 2, "address\n");
2159 len = (data[0] & 0x0000000f) + 2;
2163 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2165 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_RECTANGLE");
2167 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2168 instr_out(data, hw_offset, 1, "(%d,%d)\n",
2169 data[1] & 0xffff, data[1] >> 16);
2170 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2171 data[2] & 0xffff, data[2] >> 16);
2175 len = (data[0] & 0x0000000f) + 2;
2179 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2181 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2183 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2184 instr_out(data, hw_offset, 1, "%s\n",
2185 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2186 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2187 data[2] & 0xffff, data[2] >> 16);
2188 instr_out(data, hw_offset, 3, "(%d,%d)\n",
2189 data[3] & 0xffff, data[3] >> 16);
2190 instr_out(data, hw_offset, 4, "(%d,%d)\n",
2191 data[4] & 0xffff, data[4] >> 16);
2195 len = (data[0] & 0x0000000f) + 2;
2198 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2200 BUFFER_FAIL(count, len, "3DSTATE_CLEAR_PARAMETERS");
2202 instr_out(data, hw_offset, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2203 instr_out(data, hw_offset, 1, "prim_type=%s, clear=%s%s%s\n",
2204 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2205 data[1] & (1 << 2) ? "color," : "",
2206 data[1] & (1 << 1) ? "depth," : "",
2207 data[1] & (1 << 0) ? "stencil," : "");
2208 instr_out(data, hw_offset, 2, "clear color\n");
2209 instr_out(data, hw_offset, 3, "clear depth/stencil\n");
2210 instr_out(data, hw_offset, 4, "color value (rgba8888)\n");
2211 instr_out(data, hw_offset, 5, "depth value %f\n",
2212 int_as_float(data[5]));
2213 instr_out(data, hw_offset, 6, "clear stencil\n");
2217 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2218 opcode_3d_1d = &opcodes_3d_1d[idx];
2219 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2222 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2225 instr_out(data, hw_offset, 0, "%s\n",
2226 opcode_3d_1d->name);
2227 if (opcode_3d_1d->max_len > 1) {
2228 len = (data[0] & 0x0000ffff) + 2;
2229 if (len < opcode_3d_1d->min_len ||
2230 len > opcode_3d_1d->max_len) {
2231 fprintf(out, "Bad count in %s\n",
2232 opcode_3d_1d->name);
2236 for (i = 1; i < len; i++) {
2238 BUFFER_FAIL(count, len,
2239 opcode_3d_1d->name);
2240 instr_out(data, hw_offset, i, "dword %d\n", i);
2247 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2253 decode_3d_primitive(struct drm_intel_decode *ctx)
2255 uint32_t *data = ctx->data;
2256 uint32_t hw_offset = ctx->hw_offset;
2257 uint32_t count = ctx->count;
2258 char immediate = (data[0] & (1 << 23)) == 0;
2259 unsigned int len, i, j, ret;
2260 const char *primtype;
2261 int original_s2 = saved_s2;
2262 int original_s4 = saved_s4;
2264 switch ((data[0] >> 18) & 0xf) {
2266 primtype = "TRILIST";
2269 primtype = "TRISTRIP";
2272 primtype = "TRISTRIP_REVERSE";
2275 primtype = "TRIFAN";
2278 primtype = "POLYGON";
2281 primtype = "LINELIST";
2284 primtype = "LINESTRIP";
2287 primtype = "RECTLIST";
2290 primtype = "POINTLIST";
2296 primtype = "CLEAR_RECT";
2301 primtype = "unknown";
2305 /* XXX: 3DPRIM_DIB not supported */
2307 len = (data[0] & 0x0003ffff) + 2;
2308 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n",
2311 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2312 if (!saved_s2_set || !saved_s4_set) {
2313 fprintf(out, "unknown vertex format\n");
2314 for (i = 1; i < len; i++) {
2315 instr_out(data, hw_offset, i,
2316 " vertex data (%f float)\n",
2317 int_as_float(data[i]));
2320 unsigned int vertex = 0;
2321 for (i = 1; i < len;) {
2324 #define VERTEX_OUT(fmt, ...) do { \
2326 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2328 fprintf(out, " missing data in V%d\n", vertex); \
2332 VERTEX_OUT("X = %f", int_as_float(data[i]));
2333 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2334 switch (saved_s4 >> 6 & 0x7) {
2336 VERTEX_OUT("Z = %f",
2337 int_as_float(data[i]));
2340 VERTEX_OUT("Z = %f",
2341 int_as_float(data[i]));
2342 VERTEX_OUT("W = %f",
2343 int_as_float(data[i]));
2348 VERTEX_OUT("W = %f",
2349 int_as_float(data[i]));
2352 fprintf(out, "bad S4 position mask\n");
2355 if (saved_s4 & (1 << 10)) {
2357 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2358 "B=0x%02x)", data[i] >> 24,
2359 (data[i] >> 16) & 0xff,
2360 (data[i] >> 8) & 0xff,
2363 if (saved_s4 & (1 << 11)) {
2365 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2366 "B=0x%02x)", data[i] >> 24,
2367 (data[i] >> 16) & 0xff,
2368 (data[i] >> 8) & 0xff,
2371 if (saved_s4 & (1 << 12))
2372 VERTEX_OUT("width = 0x%08x)", data[i]);
2374 for (tc = 0; tc <= 7; tc++) {
2375 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2377 VERTEX_OUT("T%d.X = %f", tc,
2380 VERTEX_OUT("T%d.Y = %f", tc,
2385 VERTEX_OUT("T%d.X = %f", tc,
2388 VERTEX_OUT("T%d.Y = %f", tc,
2391 VERTEX_OUT("T%d.Z = %f", tc,
2396 VERTEX_OUT("T%d.X = %f", tc,
2399 VERTEX_OUT("T%d.Y = %f", tc,
2402 VERTEX_OUT("T%d.Z = %f", tc,
2405 VERTEX_OUT("T%d.W = %f", tc,
2410 VERTEX_OUT("T%d.X = %f", tc,
2416 ("T%d.XY = 0x%08x half-float",
2421 ("T%d.XY = 0x%08x half-float",
2424 ("T%d.ZW = 0x%08x half-float",
2431 "bad S2.T%d format\n",
2441 /* indirect vertices */
2442 len = data[0] & 0x0000ffff; /* index count */
2443 if (data[0] & (1 << 17)) {
2444 /* random vertex access */
2445 if (count < (len + 1) / 2 + 1) {
2446 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2447 "3DPRIMITIVE random indirect");
2449 instr_out(data, hw_offset, 0,
2450 "3DPRIMITIVE random indirect %s (%d)\n",
2453 /* vertex indices continue until 0xffff is
2456 for (i = 1; i < count; i++) {
2457 if ((data[i] & 0xffff) == 0xffff) {
2458 instr_out(data, hw_offset, i,
2459 " indices: (terminator)\n");
2462 } else if ((data[i] >> 16) == 0xffff) {
2463 instr_out(data, hw_offset, i,
2464 " indices: 0x%04x, (terminator)\n",
2469 instr_out(data, hw_offset, i,
2470 " indices: 0x%04x, 0x%04x\n",
2476 "3DPRIMITIVE: no terminator found in index buffer\n");
2480 /* fixed size vertex index buffer */
2481 for (j = 1, i = 0; i < len; i += 2, j++) {
2482 if (i * 2 == len - 1) {
2483 instr_out(data, hw_offset, j,
2484 " indices: 0x%04x\n",
2487 instr_out(data, hw_offset, j,
2488 " indices: 0x%04x, 0x%04x\n",
2494 ret = (len + 1) / 2 + 1;
2497 /* sequential vertex access */
2499 BUFFER_FAIL(count, 2,
2500 "3DPRIMITIVE seq indirect");
2501 instr_out(data, hw_offset, 0,
2502 "3DPRIMITIVE sequential indirect %s, %d starting from "
2503 "%d\n", primtype, len, data[1] & 0xffff);
2504 instr_out(data, hw_offset, 1, " start\n");
2511 saved_s2 = original_s2;
2512 saved_s4 = original_s4;
2517 decode_3d(struct drm_intel_decode *ctx)
2521 uint32_t *data = ctx->data;
2522 uint32_t hw_offset = ctx->hw_offset;
2523 uint32_t count = ctx->count;
2527 unsigned int min_len;
2528 unsigned int max_len;
2531 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2532 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2533 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2534 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2535 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2536 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2537 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2538 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2539 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2542 opcode = (data[0] & 0x1f000000) >> 24;
2546 return decode_3d_primitive(ctx);
2548 return decode_3d_1d(ctx);
2550 return decode_3d_1c(ctx);
2553 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2554 opcode_3d = &opcodes_3d[idx];
2555 if (opcode == opcode_3d->opcode) {
2556 unsigned int len = 1, i;
2558 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2559 if (opcode_3d->max_len > 1) {
2560 len = (data[0] & 0xff) + 2;
2561 if (len < opcode_3d->min_len ||
2562 len > opcode_3d->max_len) {
2563 fprintf(out, "Bad count in %s\n",
2568 for (i = 1; i < len; i++) {
2570 BUFFER_FAIL(count, len,
2572 instr_out(data, hw_offset, i, "dword %d\n", i);
2578 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2582 static const char *get_965_surfacetype(unsigned int surfacetype)
2584 switch (surfacetype) {
2602 static const char *get_965_depthformat(unsigned int depthformat)
2604 switch (depthformat) {
2606 return "s8_z24float";
2618 static const char *get_965_element_component(uint32_t data, int component)
2620 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2622 switch (component_control) {
2626 switch (component) {
2651 static const char *get_965_prim_type(uint32_t data)
2653 uint32_t primtype = (data >> 10) & 0x1f;
2657 return "point list";
2661 return "line strip";
2671 return "quad strip";
2673 return "line list adj";
2675 return "line strip adj";
2677 return "tri list adj";
2679 return "tri strip adj";
2681 return "tri strip reverse";
2689 return "point list bf";
2691 return "line strip cont";
2693 return "line strip bf";
2695 return "line strip cont bf";
2697 return "tri fan no stipple";
2704 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len,
2707 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2710 fprintf(out, "Bad count in URB_FENCE\n");
2712 BUFFER_FAIL(count, len, "URB_FENCE");
2714 vs_fence = data[1] & 0x3ff;
2715 gs_fence = (data[1] >> 10) & 0x3ff;
2716 clip_fence = (data[1] >> 20) & 0x3ff;
2717 sf_fence = data[2] & 0x3ff;
2718 vfe_fence = (data[2] >> 10) & 0x3ff;
2719 cs_fence = (data[2] >> 20) & 0x7ff;
2721 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2722 (data[0] >> 13) & 1 ? "cs " : "",
2723 (data[0] >> 12) & 1 ? "vfe " : "",
2724 (data[0] >> 11) & 1 ? "sf " : "",
2725 (data[0] >> 10) & 1 ? "clip " : "",
2726 (data[0] >> 9) & 1 ? "gs " : "",
2727 (data[0] >> 8) & 1 ? "vs " : "");
2728 instr_out(data, hw_offset, 1,
2729 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2730 vs_fence, clip_fence, gs_fence);
2731 instr_out(data, hw_offset, 2,
2732 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2733 sf_fence, vfe_fence, cs_fence);
2734 if (gs_fence < vs_fence)
2735 fprintf(out, "gs fence < vs fence!\n");
2736 if (clip_fence < gs_fence)
2737 fprintf(out, "clip fence < gs fence!\n");
2738 if (sf_fence < clip_fence)
2739 fprintf(out, "sf fence < clip fence!\n");
2740 if (cs_fence < sf_fence)
2741 fprintf(out, "cs fence < sf fence!\n");
2747 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2750 if (data[index] & 1) {
2751 instr_out(data, hw_offset, index,
2752 "%s state base address 0x%08x\n", name,
2755 instr_out(data, hw_offset, index, "%s state base not updated\n",
2761 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2764 if (data[index] & 1) {
2765 if (data[index] == 1) {
2766 instr_out(data, hw_offset, index,
2767 "%s state upper bound disabled\n", name);
2769 instr_out(data, hw_offset, index,
2770 "%s state upper bound 0x%08x\n", name,
2774 instr_out(data, hw_offset, index,
2775 "%s state upper bound not updated\n", name);
2780 decode_3d_965(struct drm_intel_decode *ctx)
2783 unsigned int idx, len;
2784 unsigned int i, j, sba_len;
2785 const char *desc1 = NULL;
2786 uint32_t *data = ctx->data;
2787 uint32_t hw_offset = ctx->hw_offset;
2788 uint32_t count = ctx->count;
2789 uint32_t devid = ctx->devid;
2793 int unsigned min_len;
2794 int unsigned max_len;
2797 { 0x6000, 3, 3, "URB_FENCE" },
2798 { 0x6001, 2, 2, "CS_URB_STATE" },
2799 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
2800 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
2801 { 0x6102, 2, 2, "STATE_SIP" },
2802 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2803 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
2804 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2805 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
2806 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
2807 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
2808 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
2809 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
2810 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
2811 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
2812 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
2813 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
2814 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
2815 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
2816 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
2817 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
2818 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2819 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
2820 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
2821 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
2822 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2823 { 0x7b00, 6, 6, "3DPRIMITIVE" },
2824 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
2825 { 0x7805, 3, 3, "3DSTATE_URB" },
2826 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
2827 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
2828 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
2829 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
2830 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
2831 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
2832 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
2833 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
2834 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
2835 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
2836 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
2837 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK"},
2840 len = (data[0] & 0x0000ffff) + 2;
2842 opcode = (data[0] & 0xffff0000) >> 16;
2845 len = (data[0] & 0x000000ff) + 2;
2846 return i965_decode_urb_fence(data, hw_offset, len, count);
2848 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
2849 instr_out(data, hw_offset, 1,
2850 "entry_size: %d [%d bytes], n_entries: %d\n",
2851 (data[1] >> 4) & 0x1f,
2852 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
2855 len = (data[0] & 0x000000ff) + 2;
2856 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
2857 (data[0] >> 8) & 1 ? "valid" : "invalid");
2858 instr_out(data, hw_offset, 1,
2859 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
2860 ((data[1] & 0x3f) + 1) * 64);
2864 instr_out(data, hw_offset, 0, "STATE_BASE_ADDRESS\n");
2867 if (IS_GEN6(devid) || IS_GEN7(devid))
2869 else if (IS_GEN5(devid))
2874 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
2876 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
2878 state_base_out(data, hw_offset, i++, "general");
2879 state_base_out(data, hw_offset, i++, "surface");
2880 if (IS_GEN6(devid) || IS_GEN7(devid))
2881 state_base_out(data, hw_offset, i++, "dynamic");
2882 state_base_out(data, hw_offset, i++, "indirect");
2883 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2884 state_base_out(data, hw_offset, i++, "instruction");
2886 state_max_out(data, hw_offset, i++, "general");
2887 if (IS_GEN6(devid) || IS_GEN7(devid))
2888 state_max_out(data, hw_offset, i++, "dynamic");
2889 state_max_out(data, hw_offset, i++, "indirect");
2890 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2891 state_max_out(data, hw_offset, i++, "instruction");
2897 "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
2899 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
2901 instr_out(data, hw_offset, 0, "3DSTATE_PIPELINED_POINTERS\n");
2902 instr_out(data, hw_offset, 1, "VS state\n");
2903 instr_out(data, hw_offset, 2, "GS state\n");
2904 instr_out(data, hw_offset, 3, "Clip state\n");
2905 instr_out(data, hw_offset, 4, "SF state\n");
2906 instr_out(data, hw_offset, 5, "WM state\n");
2907 instr_out(data, hw_offset, 6, "CC state\n");
2910 len = (data[0] & 0x000000ff) + 2;
2911 if (len != 6 && len != 4)
2913 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
2916 BUFFER_FAIL(count, len,
2917 "3DSTATE_BINDING_TABLE_POINTERS");
2918 instr_out(data, hw_offset, 0,
2919 "3DSTATE_BINDING_TABLE_POINTERS\n");
2920 instr_out(data, hw_offset, 1, "VS binding table\n");
2921 instr_out(data, hw_offset, 2, "GS binding table\n");
2922 instr_out(data, hw_offset, 3, "Clip binding table\n");
2923 instr_out(data, hw_offset, 4, "SF binding table\n");
2924 instr_out(data, hw_offset, 5, "WM binding table\n");
2927 BUFFER_FAIL(count, len,
2928 "3DSTATE_BINDING_TABLE_POINTERS");
2930 instr_out(data, hw_offset, 0,
2931 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
2932 "GS mod %d, PS mod %d\n",
2933 (data[0] & (1 << 8)) != 0,
2934 (data[0] & (1 << 9)) != 0,
2935 (data[0] & (1 << 12)) != 0);
2936 instr_out(data, hw_offset, 1, "VS binding table\n");
2937 instr_out(data, hw_offset, 2, "GS binding table\n");
2938 instr_out(data, hw_offset, 3, "WM binding table\n");
2943 len = (data[0] & 0xff) + 2;
2946 "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
2948 BUFFER_FAIL(count, len,
2949 "3DSTATE_SAMPLER_STATE_POINTERS");
2950 instr_out(data, hw_offset, 0,
2951 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
2952 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
2953 (data[0] & (1 << 9)) != 0,
2954 (data[0] & (1 << 12)) != 0);
2955 instr_out(data, hw_offset, 1, "VS sampler state\n");
2956 instr_out(data, hw_offset, 2, "GS sampler state\n");
2957 instr_out(data, hw_offset, 3, "WM sampler state\n");
2960 len = (data[0] & 0xff) + 2;
2962 fprintf(out, "Bad count in 3DSTATE_URB\n");
2964 BUFFER_FAIL(count, len, "3DSTATE_URB");
2965 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
2966 instr_out(data, hw_offset, 1,
2967 "VS entries %d, alloc size %d (1024bit row)\n",
2968 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
2969 instr_out(data, hw_offset, 2,
2970 "GS entries %d, alloc size %d (1024bit row)\n",
2971 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
2975 len = (data[0] & 0xff) + 2;
2976 if ((len - 1) % 4 != 0)
2977 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
2979 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
2980 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
2982 for (i = 1; i < len;) {
2984 if (IS_GEN6(devid)) {
2991 instr_out(data, hw_offset, i,
2992 "buffer %d: %s, pitch %db\n", data[i] >> idx,
2993 data[i] & (1 << access) ? "random" :
2994 "sequential", data[i] & 0x07ff);
2996 instr_out(data, hw_offset, i++, "buffer address\n");
2997 instr_out(data, hw_offset, i++, "max index\n");
2998 instr_out(data, hw_offset, i++, "mbz\n");
3003 len = (data[0] & 0xff) + 2;
3004 if ((len + 1) % 2 != 0)
3005 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3007 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
3008 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3010 for (i = 1; i < len;) {
3011 instr_out(data, hw_offset, i,
3012 "buffer %d: %svalid, type 0x%04x, "
3013 "src offset 0x%04x bytes\n",
3014 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3015 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3016 "" : "in", (data[i] >> 16) & 0x1ff,
3019 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
3020 "dst offset 0x%02x bytes\n",
3021 get_965_element_component(data[i], 0),
3022 get_965_element_component(data[i], 1),
3023 get_965_element_component(data[i], 2),
3024 get_965_element_component(data[i], 3),
3025 (data[i] & 0xff) * 4);
3031 len = (data[0] & 0xff) + 2;
3034 "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
3036 BUFFER_FAIL(count, len,
3037 "3DSTATE_VIEWPORT_STATE_POINTERS");
3038 instr_out(data, hw_offset, 0,
3039 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3040 instr_out(data, hw_offset, 1, "clip\n");
3041 instr_out(data, hw_offset, 2, "sf\n");
3042 instr_out(data, hw_offset, 3, "cc\n");
3046 len = (data[0] & 0xff) + 2;
3048 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
3050 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
3051 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
3052 instr_out(data, hw_offset, 1, "beginning buffer address\n");
3053 instr_out(data, hw_offset, 2, "ending buffer address\n");
3057 len = (data[0] & 0xff) + 2;
3060 "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
3062 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
3063 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
3064 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
3065 instr_out(data, hw_offset, 2, "depth stencil change %d\n",
3067 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
3071 len = (data[0] & 0xff) + 2;
3073 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
3075 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
3076 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
3077 instr_out(data, hw_offset, 1, "scissor rect offset\n");
3081 len = (data[0] & 0xff) + 2;
3083 fprintf(out, "Bad count in 3DSTATE_VS\n");
3085 BUFFER_FAIL(count, len, "3DSTATE_VS");
3086 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
3087 instr_out(data, hw_offset, 1, "kernel pointer\n");
3088 instr_out(data, hw_offset, 2,
3089 "SPF=%d, VME=%d, Sampler Count %d, "
3090 "Binding table count %d\n", (data[2] >> 31) & 1,
3091 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3092 (data[2] >> 18) & 0xff);
3093 instr_out(data, hw_offset, 3, "scratch offset\n");
3094 instr_out(data, hw_offset, 4,
3095 "Dispatch GRF start %d, VUE read length %d, "
3096 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3097 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3098 instr_out(data, hw_offset, 5,
3099 "Max Threads %d, Vertex Cache %sable, "
3100 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3101 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3102 (data[5] & 1) != 0 ? "en" : "dis");
3106 len = (data[0] & 0xff) + 2;
3108 fprintf(out, "Bad count in 3DSTATE_GS\n");
3110 BUFFER_FAIL(count, len, "3DSTATE_GS");
3111 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
3112 instr_out(data, hw_offset, 1, "kernel pointer\n");
3113 instr_out(data, hw_offset, 2,
3114 "SPF=%d, VME=%d, Sampler Count %d, "
3115 "Binding table count %d\n", (data[2] >> 31) & 1,
3116 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3117 (data[2] >> 18) & 0xff);
3118 instr_out(data, hw_offset, 3, "scratch offset\n");
3119 instr_out(data, hw_offset, 4,
3120 "Dispatch GRF start %d, VUE read length %d, "
3121 "VUE read offset %d\n", (data[4] & 0xf),
3122 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3123 instr_out(data, hw_offset, 5,
3124 "Max Threads %d, Rendering %sable\n",
3125 ((data[5] >> 25) & 0x7f) + 1,
3126 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3127 instr_out(data, hw_offset, 6,
3128 "Reorder %sable, Discard Adjaceny %sable, "
3130 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3131 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3132 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3136 len = (data[0] & 0xff) + 2;
3138 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
3140 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
3141 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
3142 instr_out(data, hw_offset, 1,
3143 "UserClip distance cull test mask 0x%x\n",
3145 instr_out(data, hw_offset, 2,
3146 "Clip %sable, API mode %s, Viewport XY test %sable, "
3147 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3148 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3149 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3150 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3151 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3152 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3153 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3154 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3155 (data[2] >> 13) & 7,
3156 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3157 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3158 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3160 instr_out(data, hw_offset, 3,
3161 "Min PointWidth %d, Max PointWidth %d, "
3162 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3163 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3164 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3169 len = (data[0] & 0xff) + 2;
3171 fprintf(out, "Bad count in 3DSTATE_SF\n");
3173 BUFFER_FAIL(count, len, "3DSTATE_SF");
3174 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
3175 instr_out(data, hw_offset, 1,
3176 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3177 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3178 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3179 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3180 instr_out(data, hw_offset, 2,
3181 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3182 "VP transform %sable, FrontWinding_%s\n",
3183 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3184 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3185 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3186 (data[2] & 1) != 0 ? "CCW" : "CW");
3187 instr_out(data, hw_offset, 3,
3188 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3189 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3190 (data[3] >> 29) & 3,
3191 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3192 (data[3] >> 8) & 3);
3193 instr_out(data, hw_offset, 4,
3194 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3195 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3196 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3197 (data[4] & (1 << 11)) != 0);
3198 instr_out(data, hw_offset, 5,
3199 "Global Depth Offset Constant %f\n",
3200 *(float *)(&data[5]));
3201 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n",
3202 *(float *)(&data[6]));
3203 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n",
3204 *(float *)(&data[7]));
3206 for (i = 0, j = 0; i < 8; i++, j += 2)
3207 instr_out(data, hw_offset, i + 8,
3208 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3209 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3211 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3212 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3213 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3214 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3215 (data[8 + i] >> 25) & 3,
3216 (data[8 + i] >> 22) & 3,
3217 (data[8 + i] >> 16) & 0x1f, j,
3218 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3219 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3220 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3221 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3222 (data[8 + i] >> 9) & 3,
3223 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3224 instr_out(data, hw_offset, 16,
3225 "Point Sprite TexCoord Enable\n");
3226 instr_out(data, hw_offset, 17, "Const Interp Enable\n");
3227 instr_out(data, hw_offset, 18,
3228 "Attrib 7-0 WrapShortest Enable\n");
3229 instr_out(data, hw_offset, 19,
3230 "Attrib 15-8 WrapShortest Enable\n");
3235 len = (data[0] & 0xff) + 2;
3237 fprintf(out, "Bad count in 3DSTATE_WM\n");
3239 BUFFER_FAIL(count, len, "3DSTATE_WM");
3240 instr_out(data, hw_offset, 0, "3DSTATE_WM\n");
3241 instr_out(data, hw_offset, 1, "kernel start pointer 0\n");
3242 instr_out(data, hw_offset, 2,
3243 "SPF=%d, VME=%d, Sampler Count %d, "
3244 "Binding table count %d\n", (data[2] >> 31) & 1,
3245 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3246 (data[2] >> 18) & 0xff);
3247 instr_out(data, hw_offset, 3, "scratch offset\n");
3248 instr_out(data, hw_offset, 4,
3249 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
3250 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
3251 (data[4] & (1 << 30)) != 0,
3252 (data[4] & (1 << 28)) != 0,
3253 (data[4] & (1 << 27)) != 0, (data[4] >> 16) & 0x7f,
3254 (data[4] >> 8) & 0x7f, (data[4] & 0x7f));
3255 instr_out(data, hw_offset, 5,
3256 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
3257 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
3258 "Dispatch16 %d, Dispatch8 %d\n",
3259 ((data[5] >> 25) & 0x7f) + 1,
3260 (data[5] & (1 << 22)) != 0,
3261 (data[5] & (1 << 21)) != 0,
3262 (data[5] & (1 << 20)) != 0,
3263 (data[5] & (1 << 19)) != 0, (data[5] & (1 << 8)) != 0,
3264 (data[5] & (1 << 2)) != 0, (data[5] & (1 << 1)) != 0,
3265 (data[5] & (1 << 0)) != 0);
3266 instr_out(data, hw_offset, 6,
3267 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
3268 "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
3269 "Multisample Dispatch mode %d\n",
3270 (data[6] >> 20) & 0x3f, (data[6] >> 18) & 3,
3271 (data[6] >> 16) & 3, (data[6] >> 10) & 0x3f,
3272 (data[6] & (1 << 9)) != 0, (data[6] >> 1) & 3,
3274 instr_out(data, hw_offset, 7, "kernel start pointer 1\n");
3275 instr_out(data, hw_offset, 8, "kernel start pointer 2\n");
3282 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
3284 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
3286 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3287 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
3288 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3289 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
3290 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3291 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
3292 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3297 if (len < 5 || len > 7)
3298 fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
3300 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
3302 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_BUFFER\n");
3303 if (IS_GEN5(devid) || IS_GEN6(devid))
3304 instr_out(data, hw_offset, 1,
3305 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3306 get_965_surfacetype(data[1] >> 29),
3307 get_965_depthformat((data[1] >> 18) & 0x7),
3308 (data[1] & 0x0001ffff) + 1,
3309 data[1] & (1 << 27) ? "" : "not ",
3310 (data[1] & (1 << 22)) != 0,
3311 (data[1] & (1 << 21)) != 0);
3313 instr_out(data, hw_offset, 1,
3314 "%s, %s, pitch = %d bytes, %stiled\n",
3315 get_965_surfacetype(data[1] >> 29),
3316 get_965_depthformat((data[1] >> 18) & 0x7),
3317 (data[1] & 0x0001ffff) + 1,
3318 data[1] & (1 << 27) ? "" : "not ");
3319 instr_out(data, hw_offset, 2, "depth offset\n");
3320 instr_out(data, hw_offset, 3, "%dx%d\n",
3321 ((data[3] & 0x0007ffc0) >> 6) + 1,
3322 ((data[3] & 0xfff80000) >> 19) + 1);
3323 instr_out(data, hw_offset, 4, "volume depth\n");
3325 instr_out(data, hw_offset, 5, "\n");
3328 instr_out(data, hw_offset, 6, "\n");
3330 instr_out(data, hw_offset, 6,
3331 "render target view extent\n");
3337 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3339 len = (data[0] & 0xff) + 2;
3340 if (len != 4 && len != 5)
3341 fprintf(out, "Bad count in PIPE_CONTROL\n");
3343 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3345 switch ((data[1] >> 14) & 0x3) {
3350 desc1 = "qword write";
3353 desc1 = "PS_DEPTH_COUNT write";
3356 desc1 = "TIMESTAMP write";
3359 instr_out(data, hw_offset, 0, "PIPE_CONTROL\n");
3360 instr_out(data, hw_offset, 1,
3361 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3363 data[1] & (1 << 20) ? "cs stall, " : "",
3364 data[1] & (1 << 19) ?
3365 "global snapshot count reset, " : "",
3366 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3367 data[1] & (1 << 17) ? "gfdt flush, " : "",
3368 data[1] & (1 << 17) ? "media state clear, " :
3370 data[1] & (1 << 13) ? "depth stall, " : "",
3371 data[1] & (1 << 12) ?
3372 "render target cache flush, " : "",
3373 data[1] & (1 << 11) ?
3374 "instruction cache invalidate, " : "",
3375 data[1] & (1 << 10) ?
3376 "texture cache invalidate, " : "",
3377 data[1] & (1 << 9) ?
3378 "indirect state invalidate, " : "",
3379 data[1] & (1 << 8) ? "notify irq, " : "",
3380 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3382 data[1] & (1 << 6) ? "protect mem app_id, " :
3383 "", data[1] & (1 << 5) ? "DC flush, " : "",
3384 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3386 data[1] & (1 << 3) ?
3387 "constant cache invalidate, " : "",
3388 data[1] & (1 << 2) ?
3389 "state cache invalidate, " : "",
3390 data[1] & (1 << 1) ? "stall at scoreboard, " :
3392 data[1] & (1 << 0) ? "depth cache flush, " :
3395 instr_out(data, hw_offset, 2,
3396 "destination address\n");
3397 instr_out(data, hw_offset, 3,
3398 "immediate dword low\n");
3399 instr_out(data, hw_offset, 4,
3400 "immediate dword high\n");
3402 for (i = 2; i < len; i++) {
3403 instr_out(data, hw_offset, i, "\n");
3408 len = (data[0] & 0xff) + 2;
3410 fprintf(out, "Bad count in PIPE_CONTROL\n");
3412 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3414 switch ((data[0] >> 14) & 0x3) {
3419 desc1 = "qword write";
3422 desc1 = "PS_DEPTH_COUNT write";
3425 desc1 = "TIMESTAMP write";
3428 instr_out(data, hw_offset, 0,
3429 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3432 data[0] & (1 << 13) ? "" : "no ",
3433 data[0] & (1 << 12) ? "" : "no ",
3434 data[0] & (1 << 11) ? "" : "no ");
3435 instr_out(data, hw_offset, 1, "destination address\n");
3436 instr_out(data, hw_offset, 2, "immediate dword low\n");
3437 instr_out(data, hw_offset, 3, "immediate dword high\n");
3441 len = (data[0] & 0xff) + 2;
3443 fprintf(out, "Bad count in 3DPRIMITIVE\n");
3445 BUFFER_FAIL(count, len, "3DPRIMITIVE");
3447 instr_out(data, hw_offset, 0,
3448 "3DPRIMITIVE: %s %s\n",
3449 get_965_prim_type(data[0]),
3450 (data[0] & (1 << 15)) ? "random" : "sequential");
3451 instr_out(data, hw_offset, 1, "vertex count\n");
3452 instr_out(data, hw_offset, 2, "start vertex\n");
3453 instr_out(data, hw_offset, 3, "instance count\n");
3454 instr_out(data, hw_offset, 4, "start instance\n");
3455 instr_out(data, hw_offset, 5, "index bias\n");
3459 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3460 opcode_3d = &opcodes_3d[idx];
3461 if ((data[0] & 0xffff0000) >> 16 == opcode_3d->opcode) {
3465 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3466 if (opcode_3d->max_len > 1) {
3467 len = (data[0] & 0xff) + 2;
3468 if (len < opcode_3d->min_len ||
3469 len > opcode_3d->max_len) {
3470 fprintf(out, "Bad count in %s\n",
3475 for (i = 1; i < len; i++) {
3477 BUFFER_FAIL(count, len,
3479 instr_out(data, hw_offset, i, "dword %d\n", i);
3485 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3491 decode_3d_i830(struct drm_intel_decode *ctx)
3495 uint32_t *data = ctx->data;
3496 uint32_t hw_offset = ctx->hw_offset;
3497 uint32_t count = ctx->count;
3501 unsigned int min_len;
3502 unsigned int max_len;
3505 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3506 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3507 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3508 { 0x05, 1, 1, "3DSTATE_VFT0" },
3509 { 0x06, 1, 1, "3DSTATE_AA" },
3510 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3511 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3512 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3513 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3514 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3515 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3516 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3517 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3518 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3519 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3520 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3523 opcode = (data[0] & 0x1f000000) >> 24;
3527 return decode_3d_primitive(ctx);
3529 return decode_3d_1d(ctx);
3531 return decode_3d_1c(ctx);
3534 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3535 opcode_3d = &opcodes_3d[idx];
3536 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3537 unsigned int len = 1, i;
3539 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3540 if (opcode_3d->max_len > 1) {
3541 len = (data[0] & 0xff) + 2;
3542 if (len < opcode_3d->min_len ||
3543 len > opcode_3d->max_len) {
3544 fprintf(out, "Bad count in %s\n",
3549 for (i = 1; i < len; i++) {
3551 BUFFER_FAIL(count, len,
3553 instr_out(data, hw_offset, i, "dword %d\n", i);
3559 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3564 struct drm_intel_decode *
3565 drm_intel_decode_context_alloc(uint32_t devid)
3567 struct drm_intel_decode *ctx;
3569 ctx = calloc(1, sizeof(struct drm_intel_decode));
3580 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3586 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3589 ctx->dump_past_end = !!dump_past_end;
3593 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3594 void *data, uint32_t hw_offset, int count)
3596 ctx->base_data = data;
3597 ctx->base_hw_offset = hw_offset;
3598 ctx->base_count = count;
3602 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3603 uint32_t head, uint32_t tail)
3610 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3617 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3619 * \param data batch buffer contents
3620 * \param count number of DWORDs to decode in the batch buffer
3621 * \param hw_offset hardware address for the buffer
3624 drm_intel_decode(struct drm_intel_decode *ctx)
3627 unsigned int index = 0;
3633 ctx->data = ctx->base_data;
3634 ctx->hw_offset = ctx->base_hw_offset;
3635 ctx->count = ctx->base_count;
3638 head_offset = ctx->head;
3639 tail_offset = ctx->tail;
3645 while (ctx->count > 0) {
3648 switch ((ctx->data[index] & 0xe0000000) >> 29) {
3650 ret = decode_mi(ctx);
3652 /* If MI_BATCHBUFFER_END happened, then dump
3653 * the rest of the output in case we some day
3654 * want it in debugging, but don't decode it
3655 * since it'll just confuse in the common
3659 if (ctx->dump_past_end) {
3662 for (index = index + 1; index < ctx->count;
3664 instr_out(ctx->data,
3673 index += decode_2d(ctx);
3676 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3679 } else if (IS_GEN3(devid)) {
3680 index += decode_3d(ctx);
3683 decode_3d_i830(ctx);
3687 instr_out(ctx->data, ctx->hw_offset, index,
3694 if (ctx->count < index)
3697 ctx->count -= index;
3699 ctx->hw_offset += 4 * index;